@neurodevs/meta-node 0.19.12 → 0.19.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/launch.json +1 -0
- package/build/__tests__/impl/NpmAutopackage.test.d.ts +28 -2
- package/build/__tests__/impl/NpmAutopackage.test.js +248 -44
- package/build/__tests__/impl/NpmAutopackage.test.js.map +1 -1
- package/build/impl/NpmAutopackage.d.ts +29 -5
- package/build/impl/NpmAutopackage.js +131 -14
- package/build/impl/NpmAutopackage.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/impl/NpmAutopackage.test.ts +346 -47
- package/src/impl/NpmAutopackage.ts +199 -19
package/.vscode/launch.json
CHANGED
|
@@ -13,16 +13,28 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
13
13
|
private static readonly packageDir;
|
|
14
14
|
private static readonly packageJsonPath;
|
|
15
15
|
private static readonly gitignorePath;
|
|
16
|
-
private static readonly
|
|
16
|
+
private static readonly originalGitignore;
|
|
17
|
+
private static readonly updatedGitignore;
|
|
18
|
+
private static readonly tsconfigPath;
|
|
17
19
|
private static readonly tasksJsonPath;
|
|
18
20
|
private static readonly testDirPath;
|
|
19
21
|
private static readonly abstractTestPath;
|
|
22
|
+
private static readonly eslintConfigPath;
|
|
23
|
+
private static readonly prettierConfigPath;
|
|
24
|
+
private static readonly customLib;
|
|
25
|
+
private static readonly customType;
|
|
26
|
+
private static readonly customInclude;
|
|
27
|
+
private static readonly customOption;
|
|
20
28
|
private static readonly setupVscodeCmd;
|
|
21
29
|
private static readonly checkGenerateIdVersionCmd;
|
|
22
30
|
private static readonly checkNodeTddVersionCmd;
|
|
31
|
+
private static readonly checkEslintConfigNdxVersionCmd;
|
|
32
|
+
private static readonly checkPrettierConfigNdxVersionCmd;
|
|
23
33
|
private static readonly dependencies;
|
|
24
34
|
private static readonly yarnInstallDevDepsCommand;
|
|
25
35
|
private static readonly abstractTestFile;
|
|
36
|
+
private static readonly eslintConfigFile;
|
|
37
|
+
private static readonly prettierConfigFile;
|
|
26
38
|
private static readonly defaultOptions;
|
|
27
39
|
protected static beforeEach(): Promise<void>;
|
|
28
40
|
protected static createsInstance(): Promise<void>;
|
|
@@ -38,6 +50,8 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
38
50
|
protected static thenCommitUpdatePackage(): Promise<void>;
|
|
39
51
|
protected static thenAddBuildDirToGitignore(): Promise<void>;
|
|
40
52
|
protected static thenCommitUpdateGitignore(): Promise<void>;
|
|
53
|
+
protected static thenUpdatesTsconfig(): Promise<void>;
|
|
54
|
+
protected static thenCommitsUpdateTsconfig(): Promise<void>;
|
|
41
55
|
protected static thenSpruceSetupVscode(): Promise<void>;
|
|
42
56
|
protected static thenCommitVscodeChanges(): Promise<void>;
|
|
43
57
|
protected static thenUpdatesVscodeTasksJson(): Promise<void>;
|
|
@@ -47,9 +61,15 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
47
61
|
protected static thenInstallsTestsDirectory(): Promise<void>;
|
|
48
62
|
protected static thenInstallsAbstractPackageTest(): Promise<void>;
|
|
49
63
|
protected static thenCommitsInstallAbstractPackageTest(): Promise<void>;
|
|
64
|
+
protected static thenInstallsEslintConfigFile(): Promise<void>;
|
|
65
|
+
protected static thenCommitsInstallEslintConfigFile(): Promise<void>;
|
|
66
|
+
protected static thenInstallsPrettierConfigFile(): Promise<void>;
|
|
67
|
+
protected static thenCommitsInstallPrettierConfigFile(): Promise<void>;
|
|
50
68
|
protected static lastlyOpensVscodeAtEnd(): Promise<void>;
|
|
51
69
|
protected static installsDevDependenciesIfGenerateIdNotLatest(): Promise<void>;
|
|
52
70
|
protected static installsDevDependenciesIfNodeTddNotLatest(): Promise<void>;
|
|
71
|
+
protected static installsDevDependenciesIfEslintConfigNdxNotLatest(): Promise<void>;
|
|
72
|
+
protected static installsDevDependenciesIfPrettierConfigNdxNotLatest(): Promise<void>;
|
|
53
73
|
protected static makeNpmNamespaceOptional(): Promise<void>;
|
|
54
74
|
protected static doesNotCreateRepoInGithubOrgIfDone(): Promise<void>;
|
|
55
75
|
protected static doesNotCloneRepoIfDone(): Promise<void>;
|
|
@@ -58,6 +78,7 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
58
78
|
protected static doesNotCommitCreatePackageIfDone(): Promise<void>;
|
|
59
79
|
protected static doesNotCommitUpdatePackageIfDone(): Promise<void>;
|
|
60
80
|
protected static doesNotCommitUpdateGitignoreIfDone(): Promise<void>;
|
|
81
|
+
protected static doesNotCommitUpdateTsconfigIfDone(): Promise<void>;
|
|
61
82
|
protected static doesNotCommitSetupVscodeIfDone(): Promise<void>;
|
|
62
83
|
protected static doesNotOverrideOriginalDependencies(): Promise<void>;
|
|
63
84
|
protected static doesNotUpdateTasksJsonIfAlreadyDone(): Promise<void>;
|
|
@@ -65,8 +86,11 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
65
86
|
protected static doesNotThrowIfGenerateIdNotInPackageJson(): Promise<void>;
|
|
66
87
|
protected static doesNotInstallAbstractPackageTestIfTsExists(): Promise<void>;
|
|
67
88
|
protected static doesNotInstallAbstractPackageTestIfTsxExists(): Promise<void>;
|
|
89
|
+
protected static doesNotInstallEslintConfigFileIfExists(): Promise<void>;
|
|
90
|
+
protected static doesNotInstallPrettierConfigFileIfExists(): Promise<void>;
|
|
68
91
|
private static run;
|
|
69
|
-
private static
|
|
92
|
+
private static runTwice;
|
|
93
|
+
private static setShouldInstallDevDeps;
|
|
70
94
|
private static get scopedPackageName();
|
|
71
95
|
private static get createModuleCmd();
|
|
72
96
|
private static orderJsonKeys;
|
|
@@ -82,6 +106,8 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
82
106
|
private static get orgsUrl();
|
|
83
107
|
private static get originalPackageJson();
|
|
84
108
|
private static get updatedPackageJson();
|
|
109
|
+
private static get originalTsconfig();
|
|
110
|
+
private static get updatedTsconfig();
|
|
85
111
|
private static originalTasksJson;
|
|
86
112
|
private static get updatedTasksJson();
|
|
87
113
|
private static NpmAutopackage;
|
|
@@ -28,18 +28,28 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
28
28
|
static packageDir = path.join(this.installDir, this.packageName);
|
|
29
29
|
static packageJsonPath = path.join(this.packageDir, 'package.json');
|
|
30
30
|
static gitignorePath = path.join(this.packageDir, '.gitignore');
|
|
31
|
-
static
|
|
31
|
+
static originalGitignore = this.generateId();
|
|
32
|
+
static updatedGitignore = `${this.originalGitignore}\nbuild/`;
|
|
33
|
+
static tsconfigPath = path.join(this.packageDir, 'tsconfig.json');
|
|
32
34
|
static tasksJsonPath = path.join(this.packageDir, '.vscode', 'tasks.json');
|
|
33
35
|
static testDirPath = path.join(this.packageDir, 'src', '__tests__');
|
|
34
36
|
static abstractTestPath = path.join(this.testDirPath, 'AbstractPackageTest.ts');
|
|
37
|
+
static eslintConfigPath = path.join(this.packageDir, 'eslint.config.js');
|
|
38
|
+
static prettierConfigPath = path.join(this.packageDir, 'prettier.config.js');
|
|
39
|
+
static customLib = this.generateId();
|
|
40
|
+
static customType = this.generateId();
|
|
41
|
+
static customInclude = this.generateId();
|
|
42
|
+
static customOption = this.generateId();
|
|
35
43
|
static setupVscodeCmd = 'spruce setup.vscode --all true';
|
|
36
44
|
static checkGenerateIdVersionCmd = `yarn info @neurodevs/generate-id version --silent`;
|
|
37
45
|
static checkNodeTddVersionCmd = `yarn info @neurodevs/node-tdd version --silent`;
|
|
46
|
+
static checkEslintConfigNdxVersionCmd = `yarn info @neurodevs/eslint-config-ndx version --silent`;
|
|
47
|
+
static checkPrettierConfigNdxVersionCmd = `yarn info @neurodevs/prettier-config-ndx version --silent`;
|
|
38
48
|
static dependencies = {
|
|
39
49
|
[this.generateId()]: this.generateId(),
|
|
40
50
|
[this.generateId()]: this.generateId(),
|
|
41
51
|
};
|
|
42
|
-
static yarnInstallDevDepsCommand = 'yarn add -D @neurodevs/generate-id
|
|
52
|
+
static yarnInstallDevDepsCommand = 'yarn add -D @neurodevs/generate-id @neurodevs/node-tdd @neurodevs/eslint-config-ndx @neurodevs/prettier-config-ndx';
|
|
43
53
|
static abstractTestFile = `import AbstractModuleTest from '@neurodevs/node-tdd'
|
|
44
54
|
|
|
45
55
|
export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
@@ -47,6 +57,14 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
47
57
|
await super.beforeEach()
|
|
48
58
|
}
|
|
49
59
|
}
|
|
60
|
+
`;
|
|
61
|
+
static eslintConfigFile = `import esConfigNdx from './src/eslint.config.js'
|
|
62
|
+
|
|
63
|
+
export default esConfigNdx
|
|
64
|
+
`;
|
|
65
|
+
static prettierConfigFile = `import prettierConfigNdx from '@neurodevs/prettier-config-ndx'
|
|
66
|
+
|
|
67
|
+
export default prettierConfigNdx
|
|
50
68
|
`;
|
|
51
69
|
static defaultOptions = {
|
|
52
70
|
installDir: this.installDir,
|
|
@@ -191,7 +209,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
191
209
|
await this.run();
|
|
192
210
|
assert.isEqualDeep(callsToWriteFile[1], {
|
|
193
211
|
file: this.gitignorePath,
|
|
194
|
-
data:
|
|
212
|
+
data: '\nbuild/\n',
|
|
195
213
|
options: { encoding: 'utf-8', flag: 'a' },
|
|
196
214
|
}, 'Did not update .gitignore as expected!');
|
|
197
215
|
}
|
|
@@ -202,6 +220,21 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
202
220
|
cwd: this.packageDir,
|
|
203
221
|
}, 'Did not commit .gitignore changes!');
|
|
204
222
|
}
|
|
223
|
+
static async thenUpdatesTsconfig() {
|
|
224
|
+
await this.run();
|
|
225
|
+
assert.isEqualDeep(callsToWriteFile[2], {
|
|
226
|
+
file: this.tsconfigPath,
|
|
227
|
+
data: JSON.stringify(this.updatedTsconfig, null, 4) + '\n',
|
|
228
|
+
options: { encoding: 'utf-8', flag: 'a' },
|
|
229
|
+
}, 'Did not update tsconfig as expected!');
|
|
230
|
+
}
|
|
231
|
+
static async thenCommitsUpdateTsconfig() {
|
|
232
|
+
await this.run();
|
|
233
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[3], {
|
|
234
|
+
commitMessage: `patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
235
|
+
cwd: this.packageDir,
|
|
236
|
+
}, 'Did not commit tsconfig changes!');
|
|
237
|
+
}
|
|
205
238
|
static async thenSpruceSetupVscode() {
|
|
206
239
|
await this.run();
|
|
207
240
|
assert.isEqualDeep(callsToExec[5], {
|
|
@@ -211,14 +244,14 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
211
244
|
}
|
|
212
245
|
static async thenCommitVscodeChanges() {
|
|
213
246
|
await this.run();
|
|
214
|
-
assert.isEqualDeep(FakeAutocommit.callsToConstructor[
|
|
247
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[4], {
|
|
215
248
|
commitMessage: `patch: setup vscode (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
216
249
|
cwd: this.packageDir,
|
|
217
250
|
}, 'Did not commit vscode changes!');
|
|
218
251
|
}
|
|
219
252
|
static async thenUpdatesVscodeTasksJson() {
|
|
220
253
|
await this.run();
|
|
221
|
-
assert.isEqualDeep(callsToWriteFile[
|
|
254
|
+
assert.isEqualDeep(callsToWriteFile[3], {
|
|
222
255
|
file: this.tasksJsonPath,
|
|
223
256
|
data: this.updatedTasksJson,
|
|
224
257
|
options: { encoding: 'utf-8' },
|
|
@@ -226,21 +259,23 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
226
259
|
}
|
|
227
260
|
static async thenCommitsUpdateVscodeTasksJson() {
|
|
228
261
|
await this.run();
|
|
229
|
-
assert.isEqualDeep(FakeAutocommit.callsToConstructor[
|
|
262
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[5], {
|
|
230
263
|
commitMessage: `patch: update vscode tasks.json (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
231
264
|
cwd: this.packageDir,
|
|
232
265
|
}, 'Did not commit updated vscode tasks.json changes!');
|
|
233
266
|
}
|
|
234
267
|
static async thenInstallsDefaultDevDependencies() {
|
|
268
|
+
this.setShouldInstallDevDeps();
|
|
235
269
|
await this.run();
|
|
236
|
-
assert.isEqualDeep(callsToExec[
|
|
270
|
+
assert.isEqualDeep(callsToExec[10], {
|
|
237
271
|
command: this.yarnInstallDevDepsCommand,
|
|
238
272
|
options: { cwd: this.packageDir },
|
|
239
273
|
}, 'Did not install default devDependencies!');
|
|
240
274
|
}
|
|
241
275
|
static async thenCommitsInstallDefaultDevDependencies() {
|
|
276
|
+
this.setShouldInstallDevDeps();
|
|
242
277
|
await this.run();
|
|
243
|
-
assert.isEqualDeep(FakeAutocommit.callsToConstructor[
|
|
278
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[6], {
|
|
244
279
|
commitMessage: `patch: install default devDependencies (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
245
280
|
cwd: this.packageDir,
|
|
246
281
|
}, 'Did not commit install devDependencies changes!');
|
|
@@ -253,29 +288,65 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
253
288
|
}, 'Did not install tests directory!');
|
|
254
289
|
}
|
|
255
290
|
static async thenInstallsAbstractPackageTest() {
|
|
291
|
+
this.setShouldInstallDevDeps();
|
|
256
292
|
await this.run();
|
|
257
|
-
assert.isEqualDeep(callsToWriteFile[
|
|
293
|
+
assert.isEqualDeep(callsToWriteFile[4], {
|
|
258
294
|
file: this.abstractTestPath,
|
|
259
295
|
data: this.abstractTestFile,
|
|
260
296
|
options: { encoding: 'utf-8' },
|
|
261
297
|
}, 'Did not install AbstractPackageTest!');
|
|
262
298
|
}
|
|
263
299
|
static async thenCommitsInstallAbstractPackageTest() {
|
|
300
|
+
this.setShouldInstallDevDeps();
|
|
264
301
|
await this.run();
|
|
265
|
-
assert.isEqualDeep(FakeAutocommit.callsToConstructor[
|
|
302
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[7], {
|
|
266
303
|
commitMessage: `patch: install AbstractPackageTest (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
267
304
|
cwd: this.packageDir,
|
|
268
305
|
}, 'Did not commit install AbstractPackageTest changes!');
|
|
269
306
|
}
|
|
307
|
+
static async thenInstallsEslintConfigFile() {
|
|
308
|
+
this.setShouldInstallDevDeps();
|
|
309
|
+
await this.run();
|
|
310
|
+
assert.isEqualDeep(callsToWriteFile[5], {
|
|
311
|
+
file: this.eslintConfigPath,
|
|
312
|
+
data: this.eslintConfigFile,
|
|
313
|
+
options: { encoding: 'utf-8' },
|
|
314
|
+
}, 'Did not install eslint.config.js!');
|
|
315
|
+
}
|
|
316
|
+
static async thenCommitsInstallEslintConfigFile() {
|
|
317
|
+
this.setShouldInstallDevDeps();
|
|
318
|
+
await this.run();
|
|
319
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[8], {
|
|
320
|
+
commitMessage: `patch: install eslint.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
321
|
+
cwd: this.packageDir,
|
|
322
|
+
}, 'Did not commit install eslint.config.js changes!');
|
|
323
|
+
}
|
|
324
|
+
static async thenInstallsPrettierConfigFile() {
|
|
325
|
+
this.setShouldInstallDevDeps();
|
|
326
|
+
await this.run();
|
|
327
|
+
assert.isEqualDeep(callsToWriteFile[6], {
|
|
328
|
+
file: this.prettierConfigPath,
|
|
329
|
+
data: this.prettierConfigFile,
|
|
330
|
+
options: { encoding: 'utf-8' },
|
|
331
|
+
}, 'Did not install prettier.config.js!');
|
|
332
|
+
}
|
|
333
|
+
static async thenCommitsInstallPrettierConfigFile() {
|
|
334
|
+
this.setShouldInstallDevDeps();
|
|
335
|
+
await this.run();
|
|
336
|
+
assert.isEqualDeep(FakeAutocommit.callsToConstructor[9], {
|
|
337
|
+
commitMessage: `patch: install prettier.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
338
|
+
cwd: this.packageDir,
|
|
339
|
+
}, 'Did not commit install prettier.config.js changes!');
|
|
340
|
+
}
|
|
270
341
|
static async lastlyOpensVscodeAtEnd() {
|
|
271
342
|
await this.run();
|
|
272
|
-
assert.isEqualDeep(callsToExec[
|
|
343
|
+
assert.isEqualDeep(callsToExec[10], { command: 'code .', options: { cwd: this.packageDir } }, 'Did not open vscode at end!');
|
|
273
344
|
}
|
|
274
345
|
static async installsDevDependenciesIfGenerateIdNotLatest() {
|
|
275
346
|
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
276
347
|
stdout: '0.0.1',
|
|
277
348
|
});
|
|
278
|
-
await this.
|
|
349
|
+
await this.runTwice();
|
|
279
350
|
const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
|
|
280
351
|
assert.isEqualDeep(calls[0], {
|
|
281
352
|
command: this.yarnInstallDevDepsCommand,
|
|
@@ -283,13 +354,26 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
283
354
|
}, 'Should install default devDependencies if not already installed!');
|
|
284
355
|
}
|
|
285
356
|
static async installsDevDependenciesIfNodeTddNotLatest() {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
357
|
+
this.setShouldInstallDevDeps();
|
|
358
|
+
await this.runTwice();
|
|
359
|
+
const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
|
|
360
|
+
assert.isEqualDeep(calls[0], {
|
|
361
|
+
command: this.yarnInstallDevDepsCommand,
|
|
362
|
+
options: { cwd: this.packageDir },
|
|
363
|
+
}, 'Should install default devDependencies if not already installed!');
|
|
364
|
+
}
|
|
365
|
+
static async installsDevDependenciesIfEslintConfigNdxNotLatest() {
|
|
366
|
+
this.setShouldInstallDevDeps();
|
|
367
|
+
await this.runTwice();
|
|
368
|
+
const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
|
|
369
|
+
assert.isEqualDeep(calls[0], {
|
|
370
|
+
command: this.yarnInstallDevDepsCommand,
|
|
371
|
+
options: { cwd: this.packageDir },
|
|
372
|
+
}, 'Should install default devDependencies if not already installed!');
|
|
373
|
+
}
|
|
374
|
+
static async installsDevDependenciesIfPrettierConfigNdxNotLatest() {
|
|
375
|
+
this.setShouldInstallDevDeps();
|
|
376
|
+
await this.runTwice();
|
|
293
377
|
const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
|
|
294
378
|
assert.isEqualDeep(calls[0], {
|
|
295
379
|
command: this.yarnInstallDevDepsCommand,
|
|
@@ -305,87 +389,116 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
305
389
|
assert.doesInclude(callsToWriteFile[0]?.data, `"name": "${this.packageName}"`, 'Did not handle missing npmNamespace!');
|
|
306
390
|
}
|
|
307
391
|
static async doesNotCreateRepoInGithubOrgIfDone() {
|
|
308
|
-
|
|
309
|
-
status: 200,
|
|
310
|
-
statusText: 'OK',
|
|
311
|
-
});
|
|
312
|
-
setFakeFetchResponse(this.reposUrl, fakeResponse);
|
|
313
|
-
await this.createAndRunAutopackage();
|
|
392
|
+
await this.runTwice();
|
|
314
393
|
const numCalls = callsToFetch.filter((call) => call.input === this.orgsUrl).length;
|
|
315
|
-
assert.isEqual(numCalls,
|
|
394
|
+
assert.isEqual(numCalls, 1, 'Should have created repo once!');
|
|
316
395
|
}
|
|
317
396
|
static async doesNotCloneRepoIfDone() {
|
|
318
|
-
await this.
|
|
397
|
+
await this.runTwice();
|
|
319
398
|
assert.isEqual(callsToExec.filter((call) => call?.command ===
|
|
320
399
|
`git clone https://github.com/${this.gitNamespace}/${this.packageName}.git`).length, 1, 'Did not clone repo once!');
|
|
321
400
|
}
|
|
322
401
|
static async doesNotSpruceCreateModuleIfDone() {
|
|
323
|
-
await this.
|
|
402
|
+
await this.runTwice();
|
|
324
403
|
assert.isEqual(callsToExec.filter((call) => call?.command === this.createModuleCmd)
|
|
325
404
|
.length, 1, 'Did not call spruce create.module once!');
|
|
326
405
|
}
|
|
327
406
|
static async doesNotRunSetupVscodeIfDone() {
|
|
328
|
-
await this.
|
|
407
|
+
await this.runTwice();
|
|
329
408
|
assert.isEqual(callsToExec.filter((call) => call?.command === this.setupVscodeCmd)
|
|
330
409
|
.length, 1, 'Did not call spruce setup.vscode once!');
|
|
331
410
|
}
|
|
332
411
|
static async doesNotCommitCreatePackageIfDone() {
|
|
333
|
-
await this.
|
|
412
|
+
await this.runTwice();
|
|
334
413
|
assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
|
|
335
414
|
`patch: create package (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit create package changes once!');
|
|
336
415
|
}
|
|
337
416
|
static async doesNotCommitUpdatePackageIfDone() {
|
|
338
|
-
await this.
|
|
417
|
+
await this.runTwice();
|
|
339
418
|
assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
|
|
340
419
|
`patch: update package.json (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit update package changes once!');
|
|
341
420
|
}
|
|
342
421
|
static async doesNotCommitUpdateGitignoreIfDone() {
|
|
343
|
-
await this.
|
|
422
|
+
await this.runTwice();
|
|
344
423
|
assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
|
|
345
424
|
`patch: add build dir to gitignore (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit gitignore changes once!');
|
|
346
425
|
}
|
|
426
|
+
static async doesNotCommitUpdateTsconfigIfDone() {
|
|
427
|
+
await this.runTwice();
|
|
428
|
+
assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
|
|
429
|
+
`patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit tsconfig changes once!');
|
|
430
|
+
}
|
|
347
431
|
static async doesNotCommitSetupVscodeIfDone() {
|
|
348
|
-
await this.
|
|
432
|
+
await this.runTwice();
|
|
349
433
|
assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
|
|
350
434
|
`patch: setup vscode (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit vscode changes once!');
|
|
351
435
|
}
|
|
352
436
|
static async doesNotOverrideOriginalDependencies() {
|
|
353
|
-
await this.
|
|
437
|
+
await this.runTwice();
|
|
354
438
|
assert.isEqualDeep(JSON.parse(callsToWriteFile[0]?.data).dependencies, this.dependencies, 'Did not update package.json as expected!');
|
|
355
439
|
}
|
|
356
440
|
static async doesNotUpdateTasksJsonIfAlreadyDone() {
|
|
357
|
-
|
|
358
|
-
await this.createAndRunAutopackage();
|
|
441
|
+
await this.runTwice();
|
|
359
442
|
assert.isEqualDeep(callsToWriteFile.filter((call) => call.file === this.tasksJsonPath)
|
|
360
|
-
.length,
|
|
443
|
+
.length, 1, 'Did not update tasks.json once!');
|
|
361
444
|
}
|
|
362
445
|
static async doesNotOpenVscodeIfNotCloned() {
|
|
363
446
|
setPathShouldExist(this.packageDir, true);
|
|
364
|
-
await this.
|
|
447
|
+
await this.run();
|
|
365
448
|
assert.isFalse(callsToExec.some((call) => call?.command === 'code .'), 'Should not open vscode if not cloned!');
|
|
366
449
|
}
|
|
367
450
|
static async doesNotThrowIfGenerateIdNotInPackageJson() {
|
|
368
451
|
setFakeReadFileResult(this.packageJsonPath, this.originalPackageJson.replace('@neurodevs/generate-id', ''));
|
|
369
|
-
await this.
|
|
452
|
+
await this.runTwice();
|
|
370
453
|
}
|
|
371
454
|
static async doesNotInstallAbstractPackageTestIfTsExists() {
|
|
372
455
|
setPathShouldExist(this.abstractTestPath, true);
|
|
373
|
-
await this.
|
|
456
|
+
await this.run();
|
|
374
457
|
const calls = callsToWriteFile.filter((call) => call.file === this.abstractTestPath);
|
|
375
458
|
assert.isEqual(calls.length, 0, 'Should not install AbstractPackageTest.ts if already exists!');
|
|
376
459
|
}
|
|
377
460
|
static async doesNotInstallAbstractPackageTestIfTsxExists() {
|
|
378
461
|
setPathShouldExist(`${this.abstractTestPath}x`, true);
|
|
379
|
-
await this.
|
|
462
|
+
await this.run();
|
|
380
463
|
const calls = callsToWriteFile.filter((call) => call.file === this.abstractTestPath);
|
|
381
464
|
assert.isEqual(calls.length, 0, 'Should not install AbstractPackageTest.tsx if already exists!');
|
|
382
465
|
}
|
|
466
|
+
static async doesNotInstallEslintConfigFileIfExists() {
|
|
467
|
+
setPathShouldExist(this.eslintConfigPath, true);
|
|
468
|
+
await this.run();
|
|
469
|
+
const calls = callsToWriteFile.filter((call) => call.file === this.eslintConfigPath);
|
|
470
|
+
assert.isEqual(calls.length, 0, 'Should not install eslint.config.js if already exists!');
|
|
471
|
+
}
|
|
472
|
+
static async doesNotInstallPrettierConfigFileIfExists() {
|
|
473
|
+
setPathShouldExist(this.prettierConfigPath, true);
|
|
474
|
+
await this.run();
|
|
475
|
+
const calls = callsToWriteFile.filter((call) => call.file === this.prettierConfigPath);
|
|
476
|
+
assert.isEqual(calls.length, 0, 'Should not install prettier.config.js if already exists!');
|
|
477
|
+
}
|
|
383
478
|
static async run() {
|
|
384
479
|
await this.instance.run();
|
|
385
480
|
}
|
|
386
|
-
static async
|
|
387
|
-
|
|
388
|
-
|
|
481
|
+
static async runTwice() {
|
|
482
|
+
await this.run();
|
|
483
|
+
setPathShouldExist(this.packageDir, true);
|
|
484
|
+
setPathShouldExist(this.packageJsonPath, true);
|
|
485
|
+
setPathShouldExist(this.abstractTestPath, true);
|
|
486
|
+
setPathShouldExist(this.tasksJsonPath, true);
|
|
487
|
+
setFakeReadFileResult(this.packageJsonPath, this.updatedPackageJson);
|
|
488
|
+
setFakeReadFileResult(this.gitignorePath, this.updatedGitignore);
|
|
489
|
+
setFakeReadFileResult(this.tasksJsonPath, this.updatedTasksJson);
|
|
490
|
+
setFakeReadFileResult(this.tsconfigPath, JSON.stringify(this.updatedTsconfig));
|
|
491
|
+
const fakeResponse = new Response(null, {
|
|
492
|
+
status: 200,
|
|
493
|
+
statusText: 'OK',
|
|
494
|
+
});
|
|
495
|
+
setFakeFetchResponse(this.reposUrl, fakeResponse);
|
|
496
|
+
await this.run();
|
|
497
|
+
}
|
|
498
|
+
static setShouldInstallDevDeps() {
|
|
499
|
+
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
500
|
+
stdout: '0.0.1',
|
|
501
|
+
});
|
|
389
502
|
}
|
|
390
503
|
static get scopedPackageName() {
|
|
391
504
|
return `@${this.npmNamespace}/${this.packageName}`;
|
|
@@ -412,6 +525,18 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
412
525
|
NpmAutopackage.exec = fakeExec;
|
|
413
526
|
resetCallsToExec();
|
|
414
527
|
this.setFakeMetaNodeVersion();
|
|
528
|
+
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
529
|
+
stdout: '1.0.0',
|
|
530
|
+
});
|
|
531
|
+
setFakeExecResult(this.checkNodeTddVersionCmd, {
|
|
532
|
+
stdout: '1.0.0',
|
|
533
|
+
});
|
|
534
|
+
setFakeExecResult(this.checkEslintConfigNdxVersionCmd, {
|
|
535
|
+
stdout: '1.0.0',
|
|
536
|
+
});
|
|
537
|
+
setFakeExecResult(this.checkPrettierConfigNdxVersionCmd, {
|
|
538
|
+
stdout: '1.0.0',
|
|
539
|
+
});
|
|
415
540
|
}
|
|
416
541
|
static fakeFetch() {
|
|
417
542
|
NpmAutopackage.fetch = fakeFetch;
|
|
@@ -424,6 +549,9 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
424
549
|
static fakePathExists() {
|
|
425
550
|
NpmAutopackage.pathExists = fakePathExists;
|
|
426
551
|
resetCallsToPathExists();
|
|
552
|
+
setPathShouldExist(this.packageDir, false);
|
|
553
|
+
setPathShouldExist(this.packageJsonPath, false);
|
|
554
|
+
setPathShouldExist(this.tasksJsonPath, false);
|
|
427
555
|
setPathShouldExist(this.abstractTestPath, false);
|
|
428
556
|
}
|
|
429
557
|
static fakeReadFile() {
|
|
@@ -431,6 +559,8 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
431
559
|
resetCallsToReadFile();
|
|
432
560
|
setFakeReadFileResult(this.packageJsonPath, this.originalPackageJson);
|
|
433
561
|
setFakeReadFileResult(this.tasksJsonPath, JSON.stringify(this.originalTasksJson));
|
|
562
|
+
setFakeReadFileResult(this.tsconfigPath, JSON.stringify(this.originalTsconfig));
|
|
563
|
+
setFakeReadFileResult(this.gitignorePath, this.originalGitignore);
|
|
434
564
|
}
|
|
435
565
|
static fakeWriteFile() {
|
|
436
566
|
NpmAutopackage.writeFile = fakeWriteFile;
|
|
@@ -461,6 +591,8 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
461
591
|
devDependencies: {
|
|
462
592
|
'@neurodevs/generate-id': '^1.0.0',
|
|
463
593
|
'@neurodevs/node-tdd': '^1.0.0',
|
|
594
|
+
'@neurodevs/eslint-config-ndx': '^1.0.0',
|
|
595
|
+
'@neurodevs/prettier-config-ndx': '^1.0.0',
|
|
464
596
|
},
|
|
465
597
|
});
|
|
466
598
|
}
|
|
@@ -469,6 +601,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
469
601
|
...JSON.parse(this.originalPackageJson),
|
|
470
602
|
name: this.scopedPackageName,
|
|
471
603
|
description: this.description,
|
|
604
|
+
type: 'module',
|
|
472
605
|
keywords: this.keywords,
|
|
473
606
|
license: this.license,
|
|
474
607
|
author: this.author,
|
|
@@ -484,6 +617,44 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
484
617
|
dependencies: this.dependencies,
|
|
485
618
|
});
|
|
486
619
|
}
|
|
620
|
+
static get originalTsconfig() {
|
|
621
|
+
return {
|
|
622
|
+
compilerOptions: {
|
|
623
|
+
lib: [this.customLib],
|
|
624
|
+
types: [this.customType],
|
|
625
|
+
},
|
|
626
|
+
include: [this.customInclude],
|
|
627
|
+
customOption: this.customOption,
|
|
628
|
+
};
|
|
629
|
+
}
|
|
630
|
+
static get updatedTsconfig() {
|
|
631
|
+
return {
|
|
632
|
+
...this.originalTsconfig,
|
|
633
|
+
compilerOptions: {
|
|
634
|
+
module: 'nodenext',
|
|
635
|
+
moduleResolution: 'nodenext',
|
|
636
|
+
target: 'ES2022',
|
|
637
|
+
lib: [this.customLib, 'ES2022'],
|
|
638
|
+
types: [this.customType, 'node'],
|
|
639
|
+
baseUrl: 'src',
|
|
640
|
+
outDir: 'build',
|
|
641
|
+
sourceMap: false,
|
|
642
|
+
strict: true,
|
|
643
|
+
noImplicitAny: true,
|
|
644
|
+
noImplicitReturns: true,
|
|
645
|
+
noUnusedLocals: true,
|
|
646
|
+
forceConsistentCasingInFileNames: true,
|
|
647
|
+
declaration: true,
|
|
648
|
+
skipLibCheck: true,
|
|
649
|
+
esModuleInterop: true,
|
|
650
|
+
moduleDetection: 'force',
|
|
651
|
+
allowJs: true,
|
|
652
|
+
resolveJsonModule: true,
|
|
653
|
+
experimentalDecorators: true,
|
|
654
|
+
},
|
|
655
|
+
include: [this.customInclude, './src/*.ts', './src/**/*.ts'],
|
|
656
|
+
};
|
|
657
|
+
}
|
|
487
658
|
static originalTasksJson = {
|
|
488
659
|
[this.randomId]: this.randomId,
|
|
489
660
|
tasks: [
|
|
@@ -569,6 +740,12 @@ __decorate([
|
|
|
569
740
|
__decorate([
|
|
570
741
|
test()
|
|
571
742
|
], NpmAutopackageTest, "thenCommitUpdateGitignore", null);
|
|
743
|
+
__decorate([
|
|
744
|
+
test()
|
|
745
|
+
], NpmAutopackageTest, "thenUpdatesTsconfig", null);
|
|
746
|
+
__decorate([
|
|
747
|
+
test()
|
|
748
|
+
], NpmAutopackageTest, "thenCommitsUpdateTsconfig", null);
|
|
572
749
|
__decorate([
|
|
573
750
|
test()
|
|
574
751
|
], NpmAutopackageTest, "thenSpruceSetupVscode", null);
|
|
@@ -596,6 +773,18 @@ __decorate([
|
|
|
596
773
|
__decorate([
|
|
597
774
|
test()
|
|
598
775
|
], NpmAutopackageTest, "thenCommitsInstallAbstractPackageTest", null);
|
|
776
|
+
__decorate([
|
|
777
|
+
test()
|
|
778
|
+
], NpmAutopackageTest, "thenInstallsEslintConfigFile", null);
|
|
779
|
+
__decorate([
|
|
780
|
+
test()
|
|
781
|
+
], NpmAutopackageTest, "thenCommitsInstallEslintConfigFile", null);
|
|
782
|
+
__decorate([
|
|
783
|
+
test()
|
|
784
|
+
], NpmAutopackageTest, "thenInstallsPrettierConfigFile", null);
|
|
785
|
+
__decorate([
|
|
786
|
+
test()
|
|
787
|
+
], NpmAutopackageTest, "thenCommitsInstallPrettierConfigFile", null);
|
|
599
788
|
__decorate([
|
|
600
789
|
test()
|
|
601
790
|
], NpmAutopackageTest, "lastlyOpensVscodeAtEnd", null);
|
|
@@ -605,6 +794,12 @@ __decorate([
|
|
|
605
794
|
__decorate([
|
|
606
795
|
test()
|
|
607
796
|
], NpmAutopackageTest, "installsDevDependenciesIfNodeTddNotLatest", null);
|
|
797
|
+
__decorate([
|
|
798
|
+
test()
|
|
799
|
+
], NpmAutopackageTest, "installsDevDependenciesIfEslintConfigNdxNotLatest", null);
|
|
800
|
+
__decorate([
|
|
801
|
+
test()
|
|
802
|
+
], NpmAutopackageTest, "installsDevDependenciesIfPrettierConfigNdxNotLatest", null);
|
|
608
803
|
__decorate([
|
|
609
804
|
test()
|
|
610
805
|
], NpmAutopackageTest, "makeNpmNamespaceOptional", null);
|
|
@@ -629,6 +824,9 @@ __decorate([
|
|
|
629
824
|
__decorate([
|
|
630
825
|
test()
|
|
631
826
|
], NpmAutopackageTest, "doesNotCommitUpdateGitignoreIfDone", null);
|
|
827
|
+
__decorate([
|
|
828
|
+
test()
|
|
829
|
+
], NpmAutopackageTest, "doesNotCommitUpdateTsconfigIfDone", null);
|
|
632
830
|
__decorate([
|
|
633
831
|
test()
|
|
634
832
|
], NpmAutopackageTest, "doesNotCommitSetupVscodeIfDone", null);
|
|
@@ -650,4 +848,10 @@ __decorate([
|
|
|
650
848
|
__decorate([
|
|
651
849
|
test()
|
|
652
850
|
], NpmAutopackageTest, "doesNotInstallAbstractPackageTestIfTsxExists", null);
|
|
851
|
+
__decorate([
|
|
852
|
+
test()
|
|
853
|
+
], NpmAutopackageTest, "doesNotInstallEslintConfigFileIfExists", null);
|
|
854
|
+
__decorate([
|
|
855
|
+
test()
|
|
856
|
+
], NpmAutopackageTest, "doesNotInstallPrettierConfigFileIfExists", null);
|
|
653
857
|
//# sourceMappingURL=NpmAutopackage.test.js.map
|