Skip to content

Commit e201eb2

Browse files
committed
Anonymize version and path in test code rather than in shipped code
Includes removing options.forTests.
1 parent ac053d7 commit e201eb2

31 files changed

Lines changed: 115 additions & 206 deletions

.eslintrc.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ module.exports = {
101101
'@typescript-eslint/ban-ts-comment': [
102102
'warn',
103103
{
104-
'ts-expect-error': {descriptionFormat: '^\\(TS\\d+\\): .+$'},
105104
'ts-check': false
106105
}
107106
],

lib/anonymize.js

Lines changed: 0 additions & 76 deletions
This file was deleted.

lib/build.js

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const fs = require('graceful-fs');
1515
const wrap = require('wrap-ansi');
1616
const exit = require('../vendor/exit');
1717
const elmCompiler = require('../vendor/node-elm-compiler');
18-
const Anonymize = require('./anonymize');
1918
const Benchmark = require('./benchmark');
2019
const Debug = require('./debug');
2120
const {getElmBinary} = require('./elm-binary');
@@ -166,10 +165,7 @@ please use ${chalk.greenBright('--config some/path/to/review')}`,
166165
let elmModulePath = options.elmModulePath(appHash);
167166
if (!options.forceBuild && fs.existsSync(elmModulePath)) {
168167
Debug.log(
169-
`Review application is already built. Using ${Anonymize.path(
170-
options,
171-
elmModulePath
172-
)}`,
168+
`Review application is already built. Using ${elmModulePath}`,
173169
options.debug
174170
);
175171
} else {
@@ -285,11 +281,7 @@ function createSymLinkForLocalElmReview(options, buildFolder, reviewElmJson) {
285281
* @returns {Promise<BuildResult>}
286282
*/
287283
async function buildFromGitHubTemplate(options, template) {
288-
Spinner.setText(
289-
'Fetching template information',
290-
options.report,
291-
options.forTests
292-
);
284+
Spinner.setText('Fetching template information', options.report);
293285
const commit = await RemoteTemplate.getRelevantCommit(options, template);
294286
const reviewElmJson = await RemoteTemplate.getRemoteElmJson(
295287
options,
@@ -304,10 +296,7 @@ async function buildFromGitHubTemplate(options, template) {
304296
let elmModulePath = options.templateElmModulePath(commit);
305297
if (fs.existsSync(elmModulePath)) {
306298
Debug.log(
307-
`Review application is already built. Using ${Anonymize.path(
308-
options,
309-
elmModulePath
310-
)}`,
299+
`Review application is already built. Using ${elmModulePath}`,
311300
options.debug
312301
);
313302

@@ -319,11 +308,7 @@ async function buildFromGitHubTemplate(options, template) {
319308

320309
const buildFolder = path.join(options.buildFolder(), 'template');
321310

322-
Spinner.setText(
323-
'Downloading configuration files',
324-
options.report,
325-
options.forTests
326-
);
311+
Spinner.setText('Downloading configuration files', options.report);
327312
// Download all files from the template
328313
await RemoteTemplate.downloadSourceDirectories(
329314
options,
@@ -335,11 +320,7 @@ async function buildFromGitHubTemplate(options, template) {
335320

336321
Debug.log('Starting template review application build', options.debug);
337322

338-
Spinner.setText(
339-
'Building review application',
340-
options.report,
341-
options.forTests
342-
);
323+
Spinner.setText('Building review application', options.report);
343324

344325
const cleanupSymlink = createSymLinkForLocalElmReview(
345326
options,

lib/elm-files.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
const path = require('node:path');
77
const chalk = require('chalk');
88
const {glob} = require('tinyglobby');
9-
const Anonymize = require('./anonymize');
109
const Benchmark = require('./benchmark');
1110
const Cache = require('./cache');
1211
const Debug = require('./debug');
@@ -158,7 +157,7 @@ async function readFile(
158157
relativePathToElmJson,
159158
filePath
160159
) {
161-
Debug.log(` - ${Anonymize.path(options, filePath)}`, options.debug);
160+
Debug.log(` - ${filePath}`, options.debug);
162161
const relativeFilePath = path.relative(relativePathToElmJson, filePath);
163162

164163
const lastUpdatedTime = options.watch

lib/error-message.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55
const chalk = require('chalk');
66
const stripAnsi = require('strip-ansi');
7-
const Anonymize = require('./anonymize');
87

98
class CustomError extends Error {
109
/**
@@ -28,20 +27,14 @@ class CustomError extends Error {
2827
*/
2928
function report(options, err, defaultPath) {
3029
if (options.report === 'json') {
31-
return Anonymize.pathsAndVersions(
32-
options,
33-
Anonymize.pathsAndVersions(
34-
options,
35-
JSON.stringify(
36-
formatJson(options.debug, err, defaultPath),
37-
null,
38-
options.debug || options.forTests ? 2 : 0
39-
)
40-
)
30+
return JSON.stringify(
31+
formatJson(options.debug, err, defaultPath),
32+
null,
33+
options.debug ? 2 : 0
4134
);
4235
}
4336

44-
return Anonymize.pathsAndVersions(options, formatHuman(options.debug, err));
37+
return formatHuman(options.debug, err);
4538
}
4639

4740
/**

lib/help.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
* @import {Options} from './types/options';
33
*/
44
const chalk = require('chalk');
5-
const Anonymize = require('./anonymize');
65
const Flags = require('./flags');
76

87
/**
@@ -14,7 +13,7 @@ function review(options) {
1413

1514
console.log(
1615
// prettier-ignore
17-
`You are using ${chalk.greenBright(`elm-review ${Anonymize.version(options)}`)}.
16+
`You are using ${chalk.greenBright(`elm-review ${options.packageJsonVersion}`)}.
1817
1918
${chalk.magenta('elm-review <zero-or-more-files-or-directories>')}
2019
Analyzes your project, and lists the locations where patterns forbidden

lib/init.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const fs = require('graceful-fs');
88
const chalk = require('chalk');
99
const prompts = require('prompts');
1010
const FS = require('./fs-wrapper');
11-
const Anonymize = require('./anonymize');
1211
const RemoteTemplate = require('./remote-template');
1312
const {getElmBinary, getElmVersion} = require('./elm-binary');
1413
const TemplateDependencies = require('./template-dependencies');
@@ -31,7 +30,7 @@ async function promptAndCreate(options) {
3130
message: `Would you like me to create ${chalk.yellow(
3231
'elm.json'
3332
)} and ${chalk.yellow('src/ReviewConfig.elm')} inside ${chalk.yellow(
34-
Anonymize.path(options, directory)
33+
directory
3534
)}?`,
3635
initial: true
3736
});
@@ -94,12 +93,12 @@ async function createFromTemplate(options, template, directory) {
9493
*/
9594
function logInit(options, directory) {
9695
const message = options.template
97-
? templateInitMessage(options, directory)
98-
: regularInitMessage(options, directory);
96+
? templateInitMessage(directory)
97+
: regularInitMessage(directory);
9998

10099
console.log(
101100
`All done! I have created a review project at ${chalk.green(
102-
(Anonymize.path(options, directory) + '/').replace(/\/\//g, '/')
101+
(directory + '/').replace(/\/\//g, '/')
103102
)} for you.
104103
105104
${message}
@@ -116,29 +115,27 @@ ${options.template ? templateRecommendation : ''}`
116115
}
117116

118117
/**
119-
* @param {Options} options
120118
* @param {Path} directory
121119
* @returns {string}
122120
*/
123-
function regularInitMessage(options, directory) {
121+
function regularInitMessage(directory) {
124122
return `You can now define your review configuration by editing ${chalk.green(
125-
Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm'))
123+
path.join(directory, 'src/ReviewConfig.elm')
126124
)}.`;
127125
}
128126

129127
const orange = chalk.keyword('orange');
130128

131129
/**
132-
* @param {Options} options
133130
* @param {Path} directory
134131
* @returns {string}
135132
*/
136-
function templateInitMessage(options, directory) {
133+
function templateInitMessage(directory) {
137134
return `You chose to use someone's review configuration which can be great to get started
138135
but don't forget to review the configuration to make sure it fits your needs,
139136
both by removing rules you disagree with and by finding new rules to aid you.
140137
You can do so by editing ${chalk.green(
141-
Anonymize.path(options, path.join(directory, 'src/ReviewConfig.elm'))
138+
path.join(directory, 'src/ReviewConfig.elm')
142139
)}.`;
143140
}
144141

lib/main.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ const path = require('node:path');
55
const process = require('node:process');
66
const chalk = require('chalk');
77
const exit = require('../vendor/exit');
8-
const Anonymize = require('./anonymize');
98
const AppWrapper = require('./app-wrapper');
109
const Builder = require('./build');
1110
const ElmBinary = require('./elm-binary');
@@ -221,7 +220,7 @@ async function main() {
221220
*/
222221
async function app(options, errorHandler) {
223222
if (options.version) {
224-
console.log(Anonymize.version(options));
223+
console.log(options.packageJsonVersion);
225224
return;
226225
}
227226

lib/new-package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ async function createProject(
213213
await FS.mkdirp(path.join(dir, 'tests', ruleNameFolder));
214214
} catch {}
215215

216-
Spinner.setText('Adding elm.json', options.report, options.forTests);
216+
Spinner.setText('Adding elm.json', options.report);
217217
const packageElmJson = elmJson(authorName, packageName, ruleName, license);
218218
await writeFile(dir, 'elm.json', JSON.stringify(packageElmJson, null, 4));
219219

lib/options.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ try re-running it with ${chalk.cyan('--elmjson <path-to-elm.json>')}.`,
185185
? parseTemplate(subcommand, args.template)
186186
: null;
187187

188-
const forTests = args['FOR-TESTS'];
189-
190188
const gitHubPat = parseGitHubAuth(subcommand, args['github-auth']);
191189

192190
const localElmReview = process.env.LOCAL_ELM_REVIEW;
@@ -221,7 +219,6 @@ try re-running it with ${chalk.cyan('--elmjson <path-to-elm.json>')}.`,
221219
return {
222220
debug: args.debug,
223221
showBenchmark: args['benchmark-info'],
224-
forTests,
225222
enableExtract: args.extract,
226223
version: args.version,
227224
help: args.help,

0 commit comments

Comments
 (0)