@neurodevs/meta-node 0.19.12 → 0.19.14

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.
@@ -17,6 +17,7 @@
17
17
  "runtimeArgs": [
18
18
  "--inspect-brk",
19
19
  "--trace-warnings",
20
+ "--experimental-vm-modules",
20
21
  "${workspaceFolder}/node_modules/.bin/jest",
21
22
  "${fileBasenameNoExtension}",
22
23
  "--detectOpenHandles"
@@ -13,16 +13,29 @@ 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 buildDirGitignorePattern;
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 eslintConfigMjsPath;
23
+ private static readonly eslintConfigJsPath;
24
+ private static readonly prettierConfigPath;
25
+ private static readonly customLib;
26
+ private static readonly customType;
27
+ private static readonly customInclude;
28
+ private static readonly customOption;
20
29
  private static readonly setupVscodeCmd;
21
30
  private static readonly checkGenerateIdVersionCmd;
22
31
  private static readonly checkNodeTddVersionCmd;
32
+ private static readonly checkEslintConfigNdxVersionCmd;
33
+ private static readonly checkPrettierConfigNdxVersionCmd;
23
34
  private static readonly dependencies;
24
35
  private static readonly yarnInstallDevDepsCommand;
25
36
  private static readonly abstractTestFile;
37
+ private static readonly eslintConfigFile;
38
+ private static readonly prettierConfigFile;
26
39
  private static readonly defaultOptions;
27
40
  protected static beforeEach(): Promise<void>;
28
41
  protected static createsInstance(): Promise<void>;
@@ -38,6 +51,8 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
38
51
  protected static thenCommitUpdatePackage(): Promise<void>;
39
52
  protected static thenAddBuildDirToGitignore(): Promise<void>;
40
53
  protected static thenCommitUpdateGitignore(): Promise<void>;
54
+ protected static thenUpdatesTsconfig(): Promise<void>;
55
+ protected static thenCommitsUpdateTsconfig(): Promise<void>;
41
56
  protected static thenSpruceSetupVscode(): Promise<void>;
42
57
  protected static thenCommitVscodeChanges(): Promise<void>;
43
58
  protected static thenUpdatesVscodeTasksJson(): Promise<void>;
@@ -47,9 +62,16 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
47
62
  protected static thenInstallsTestsDirectory(): Promise<void>;
48
63
  protected static thenInstallsAbstractPackageTest(): Promise<void>;
49
64
  protected static thenCommitsInstallAbstractPackageTest(): Promise<void>;
65
+ protected static thenDeletesOldEslintConfigMjs(): Promise<void>;
66
+ protected static thenInstallsNewEslintConfigJs(): Promise<void>;
67
+ protected static thenCommitsInstallEslintConfigFile(): Promise<void>;
68
+ protected static thenInstallsPrettierConfigFile(): Promise<void>;
69
+ protected static thenCommitsInstallPrettierConfigFile(): Promise<void>;
50
70
  protected static lastlyOpensVscodeAtEnd(): Promise<void>;
51
71
  protected static installsDevDependenciesIfGenerateIdNotLatest(): Promise<void>;
52
72
  protected static installsDevDependenciesIfNodeTddNotLatest(): Promise<void>;
73
+ protected static installsDevDependenciesIfEslintConfigNdxNotLatest(): Promise<void>;
74
+ protected static installsDevDependenciesIfPrettierConfigNdxNotLatest(): Promise<void>;
53
75
  protected static makeNpmNamespaceOptional(): Promise<void>;
54
76
  protected static doesNotCreateRepoInGithubOrgIfDone(): Promise<void>;
55
77
  protected static doesNotCloneRepoIfDone(): Promise<void>;
@@ -58,6 +80,7 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
58
80
  protected static doesNotCommitCreatePackageIfDone(): Promise<void>;
59
81
  protected static doesNotCommitUpdatePackageIfDone(): Promise<void>;
60
82
  protected static doesNotCommitUpdateGitignoreIfDone(): Promise<void>;
83
+ protected static doesNotCommitUpdateTsconfigIfDone(): Promise<void>;
61
84
  protected static doesNotCommitSetupVscodeIfDone(): Promise<void>;
62
85
  protected static doesNotOverrideOriginalDependencies(): Promise<void>;
63
86
  protected static doesNotUpdateTasksJsonIfAlreadyDone(): Promise<void>;
@@ -65,8 +88,12 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
65
88
  protected static doesNotThrowIfGenerateIdNotInPackageJson(): Promise<void>;
66
89
  protected static doesNotInstallAbstractPackageTestIfTsExists(): Promise<void>;
67
90
  protected static doesNotInstallAbstractPackageTestIfTsxExists(): Promise<void>;
91
+ protected static doesNotRemoveEslintConfigMjsIfNotExists(): Promise<void>;
92
+ protected static doesNotInstallEslintConfigFileIfExists(): Promise<void>;
93
+ protected static doesNotInstallPrettierConfigFileIfExists(): Promise<void>;
68
94
  private static run;
69
- private static createAndRunAutopackage;
95
+ private static runTwice;
96
+ private static setShouldInstallDevDeps;
70
97
  private static get scopedPackageName();
71
98
  private static get createModuleCmd();
72
99
  private static orderJsonKeys;
@@ -82,6 +109,8 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
82
109
  private static get orgsUrl();
83
110
  private static get originalPackageJson();
84
111
  private static get updatedPackageJson();
112
+ private static get originalTsconfig();
113
+ private static get updatedTsconfig();
85
114
  private static originalTasksJson;
86
115
  private static get updatedTasksJson();
87
116
  private static NpmAutopackage;
@@ -28,18 +28,29 @@ 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 buildDirGitignorePattern = '\nbuild/\n';
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 eslintConfigMjsPath = path.join(this.packageDir, 'eslint.config.mjs');
38
+ static eslintConfigJsPath = path.join(this.packageDir, 'eslint.config.js');
39
+ static prettierConfigPath = path.join(this.packageDir, 'prettier.config.js');
40
+ static customLib = this.generateId();
41
+ static customType = this.generateId();
42
+ static customInclude = this.generateId();
43
+ static customOption = this.generateId();
35
44
  static setupVscodeCmd = 'spruce setup.vscode --all true';
36
45
  static checkGenerateIdVersionCmd = `yarn info @neurodevs/generate-id version --silent`;
37
46
  static checkNodeTddVersionCmd = `yarn info @neurodevs/node-tdd version --silent`;
47
+ static checkEslintConfigNdxVersionCmd = `yarn info @neurodevs/eslint-config-ndx version --silent`;
48
+ static checkPrettierConfigNdxVersionCmd = `yarn info @neurodevs/prettier-config-ndx version --silent`;
38
49
  static dependencies = {
39
50
  [this.generateId()]: this.generateId(),
40
51
  [this.generateId()]: this.generateId(),
41
52
  };
42
- static yarnInstallDevDepsCommand = 'yarn add -D @neurodevs/generate-id@latest @neurodevs/node-tdd@latest';
53
+ static yarnInstallDevDepsCommand = 'yarn add -D @neurodevs/generate-id @neurodevs/node-tdd @neurodevs/eslint-config-ndx @neurodevs/prettier-config-ndx';
43
54
  static abstractTestFile = `import AbstractModuleTest from '@neurodevs/node-tdd'
44
55
 
45
56
  export default abstract class AbstractPackageTest extends AbstractModuleTest {
@@ -47,6 +58,14 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
47
58
  await super.beforeEach()
48
59
  }
49
60
  }
61
+ `;
62
+ static eslintConfigFile = `import esConfigNdx from './src/eslint.config.js'
63
+
64
+ export default esConfigNdx
65
+ `;
66
+ static prettierConfigFile = `import prettierConfigNdx from '@neurodevs/prettier-config-ndx'
67
+
68
+ export default prettierConfigNdx
50
69
  `;
51
70
  static defaultOptions = {
52
71
  installDir: this.installDir,
@@ -191,7 +210,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
191
210
  await this.run();
192
211
  assert.isEqualDeep(callsToWriteFile[1], {
193
212
  file: this.gitignorePath,
194
- data: this.buildDirGitignorePattern,
213
+ data: '\nbuild/\n',
195
214
  options: { encoding: 'utf-8', flag: 'a' },
196
215
  }, 'Did not update .gitignore as expected!');
197
216
  }
@@ -202,6 +221,21 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
202
221
  cwd: this.packageDir,
203
222
  }, 'Did not commit .gitignore changes!');
204
223
  }
224
+ static async thenUpdatesTsconfig() {
225
+ await this.run();
226
+ assert.isEqualDeep(callsToWriteFile[2], {
227
+ file: this.tsconfigPath,
228
+ data: JSON.stringify(this.updatedTsconfig, null, 4) + '\n',
229
+ options: { encoding: 'utf-8', flag: 'a' },
230
+ }, 'Did not update tsconfig as expected!');
231
+ }
232
+ static async thenCommitsUpdateTsconfig() {
233
+ await this.run();
234
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[3], {
235
+ commitMessage: `patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`,
236
+ cwd: this.packageDir,
237
+ }, 'Did not commit tsconfig changes!');
238
+ }
205
239
  static async thenSpruceSetupVscode() {
206
240
  await this.run();
207
241
  assert.isEqualDeep(callsToExec[5], {
@@ -211,14 +245,14 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
211
245
  }
212
246
  static async thenCommitVscodeChanges() {
213
247
  await this.run();
214
- assert.isEqualDeep(FakeAutocommit.callsToConstructor[3], {
248
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[4], {
215
249
  commitMessage: `patch: setup vscode (@neurodevs/meta-node: ${this.metaNodeVersion})`,
216
250
  cwd: this.packageDir,
217
251
  }, 'Did not commit vscode changes!');
218
252
  }
219
253
  static async thenUpdatesVscodeTasksJson() {
220
254
  await this.run();
221
- assert.isEqualDeep(callsToWriteFile[2], {
255
+ assert.isEqualDeep(callsToWriteFile[3], {
222
256
  file: this.tasksJsonPath,
223
257
  data: this.updatedTasksJson,
224
258
  options: { encoding: 'utf-8' },
@@ -226,21 +260,23 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
226
260
  }
227
261
  static async thenCommitsUpdateVscodeTasksJson() {
228
262
  await this.run();
229
- assert.isEqualDeep(FakeAutocommit.callsToConstructor[4], {
263
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[5], {
230
264
  commitMessage: `patch: update vscode tasks.json (@neurodevs/meta-node: ${this.metaNodeVersion})`,
231
265
  cwd: this.packageDir,
232
266
  }, 'Did not commit updated vscode tasks.json changes!');
233
267
  }
234
268
  static async thenInstallsDefaultDevDependencies() {
269
+ this.setShouldInstallDevDeps();
235
270
  await this.run();
236
- assert.isEqualDeep(callsToExec[8], {
271
+ assert.isEqualDeep(callsToExec[10], {
237
272
  command: this.yarnInstallDevDepsCommand,
238
273
  options: { cwd: this.packageDir },
239
274
  }, 'Did not install default devDependencies!');
240
275
  }
241
276
  static async thenCommitsInstallDefaultDevDependencies() {
277
+ this.setShouldInstallDevDeps();
242
278
  await this.run();
243
- assert.isEqualDeep(FakeAutocommit.callsToConstructor[5], {
279
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[6], {
244
280
  commitMessage: `patch: install default devDependencies (@neurodevs/meta-node: ${this.metaNodeVersion})`,
245
281
  cwd: this.packageDir,
246
282
  }, 'Did not commit install devDependencies changes!');
@@ -253,29 +289,74 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
253
289
  }, 'Did not install tests directory!');
254
290
  }
255
291
  static async thenInstallsAbstractPackageTest() {
292
+ this.setShouldInstallDevDeps();
256
293
  await this.run();
257
- assert.isEqualDeep(callsToWriteFile[3], {
294
+ assert.isEqualDeep(callsToWriteFile[4], {
258
295
  file: this.abstractTestPath,
259
296
  data: this.abstractTestFile,
260
297
  options: { encoding: 'utf-8' },
261
298
  }, 'Did not install AbstractPackageTest!');
262
299
  }
263
300
  static async thenCommitsInstallAbstractPackageTest() {
301
+ this.setShouldInstallDevDeps();
264
302
  await this.run();
265
- assert.isEqualDeep(FakeAutocommit.callsToConstructor[6], {
303
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[7], {
266
304
  commitMessage: `patch: install AbstractPackageTest (@neurodevs/meta-node: ${this.metaNodeVersion})`,
267
305
  cwd: this.packageDir,
268
306
  }, 'Did not commit install AbstractPackageTest changes!');
269
307
  }
308
+ static async thenDeletesOldEslintConfigMjs() {
309
+ setPathShouldExist(path.join(this.packageDir, 'eslint.config.mjs'), true);
310
+ this.setShouldInstallDevDeps();
311
+ await this.run();
312
+ assert.isEqualDeep(callsToExec[11], {
313
+ command: `git rm eslint.config.mjs`,
314
+ options: { cwd: this.packageDir },
315
+ }, 'Did not delete old eslint.config.mjs!');
316
+ }
317
+ static async thenInstallsNewEslintConfigJs() {
318
+ this.setShouldInstallDevDeps();
319
+ await this.run();
320
+ assert.isEqualDeep(callsToWriteFile[5], {
321
+ file: this.eslintConfigJsPath,
322
+ data: this.eslintConfigFile,
323
+ options: { encoding: 'utf-8' },
324
+ }, 'Did not install eslint.config.js!');
325
+ }
326
+ static async thenCommitsInstallEslintConfigFile() {
327
+ this.setShouldInstallDevDeps();
328
+ await this.run();
329
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[8], {
330
+ commitMessage: `patch: install eslint.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
331
+ cwd: this.packageDir,
332
+ }, 'Did not commit install eslint.config.js changes!');
333
+ }
334
+ static async thenInstallsPrettierConfigFile() {
335
+ this.setShouldInstallDevDeps();
336
+ await this.run();
337
+ assert.isEqualDeep(callsToWriteFile[6], {
338
+ file: this.prettierConfigPath,
339
+ data: this.prettierConfigFile,
340
+ options: { encoding: 'utf-8' },
341
+ }, 'Did not install prettier.config.js!');
342
+ }
343
+ static async thenCommitsInstallPrettierConfigFile() {
344
+ this.setShouldInstallDevDeps();
345
+ await this.run();
346
+ assert.isEqualDeep(FakeAutocommit.callsToConstructor[9], {
347
+ commitMessage: `patch: install prettier.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
348
+ cwd: this.packageDir,
349
+ }, 'Did not commit install prettier.config.js changes!');
350
+ }
270
351
  static async lastlyOpensVscodeAtEnd() {
271
352
  await this.run();
272
- assert.isEqualDeep(callsToExec[9], { command: 'code .', options: { cwd: this.packageDir } }, 'Did not open vscode at end!');
353
+ assert.isEqualDeep(callsToExec[11], { command: 'code .', options: { cwd: this.packageDir } }, 'Did not open vscode at end!');
273
354
  }
274
355
  static async installsDevDependenciesIfGenerateIdNotLatest() {
275
356
  setFakeExecResult(this.checkGenerateIdVersionCmd, {
276
357
  stdout: '0.0.1',
277
358
  });
278
- await this.createAndRunAutopackage();
359
+ await this.runTwice();
279
360
  const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
280
361
  assert.isEqualDeep(calls[0], {
281
362
  command: this.yarnInstallDevDepsCommand,
@@ -283,13 +364,26 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
283
364
  }, 'Should install default devDependencies if not already installed!');
284
365
  }
285
366
  static async installsDevDependenciesIfNodeTddNotLatest() {
286
- setFakeExecResult(this.checkGenerateIdVersionCmd, {
287
- stdout: '1.0.0',
288
- });
289
- setFakeExecResult(this.checkNodeTddVersionCmd, {
290
- stdout: '0.0.1',
291
- });
292
- await this.createAndRunAutopackage();
367
+ this.setShouldInstallDevDeps();
368
+ await this.runTwice();
369
+ const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
370
+ assert.isEqualDeep(calls[0], {
371
+ command: this.yarnInstallDevDepsCommand,
372
+ options: { cwd: this.packageDir },
373
+ }, 'Should install default devDependencies if not already installed!');
374
+ }
375
+ static async installsDevDependenciesIfEslintConfigNdxNotLatest() {
376
+ this.setShouldInstallDevDeps();
377
+ await this.runTwice();
378
+ const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
379
+ assert.isEqualDeep(calls[0], {
380
+ command: this.yarnInstallDevDepsCommand,
381
+ options: { cwd: this.packageDir },
382
+ }, 'Should install default devDependencies if not already installed!');
383
+ }
384
+ static async installsDevDependenciesIfPrettierConfigNdxNotLatest() {
385
+ this.setShouldInstallDevDeps();
386
+ await this.runTwice();
293
387
  const calls = callsToExec.filter((call) => call?.command === this.yarnInstallDevDepsCommand);
294
388
  assert.isEqualDeep(calls[0], {
295
389
  command: this.yarnInstallDevDepsCommand,
@@ -305,87 +399,122 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
305
399
  assert.doesInclude(callsToWriteFile[0]?.data, `"name": "${this.packageName}"`, 'Did not handle missing npmNamespace!');
306
400
  }
307
401
  static async doesNotCreateRepoInGithubOrgIfDone() {
308
- const fakeResponse = new Response(null, {
309
- status: 200,
310
- statusText: 'OK',
311
- });
312
- setFakeFetchResponse(this.reposUrl, fakeResponse);
313
- await this.createAndRunAutopackage();
402
+ await this.runTwice();
314
403
  const numCalls = callsToFetch.filter((call) => call.input === this.orgsUrl).length;
315
- assert.isEqual(numCalls, 0, 'Should not have created repo!');
404
+ assert.isEqual(numCalls, 1, 'Should have created repo once!');
316
405
  }
317
406
  static async doesNotCloneRepoIfDone() {
318
- await this.createAndRunAutopackage();
407
+ await this.runTwice();
319
408
  assert.isEqual(callsToExec.filter((call) => call?.command ===
320
409
  `git clone https://github.com/${this.gitNamespace}/${this.packageName}.git`).length, 1, 'Did not clone repo once!');
321
410
  }
322
411
  static async doesNotSpruceCreateModuleIfDone() {
323
- await this.createAndRunAutopackage();
412
+ await this.runTwice();
324
413
  assert.isEqual(callsToExec.filter((call) => call?.command === this.createModuleCmd)
325
414
  .length, 1, 'Did not call spruce create.module once!');
326
415
  }
327
416
  static async doesNotRunSetupVscodeIfDone() {
328
- await this.createAndRunAutopackage();
417
+ await this.runTwice();
329
418
  assert.isEqual(callsToExec.filter((call) => call?.command === this.setupVscodeCmd)
330
419
  .length, 1, 'Did not call spruce setup.vscode once!');
331
420
  }
332
421
  static async doesNotCommitCreatePackageIfDone() {
333
- await this.createAndRunAutopackage();
422
+ await this.runTwice();
334
423
  assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
335
424
  `patch: create package (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit create package changes once!');
336
425
  }
337
426
  static async doesNotCommitUpdatePackageIfDone() {
338
- await this.createAndRunAutopackage();
427
+ await this.runTwice();
339
428
  assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
340
429
  `patch: update package.json (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit update package changes once!');
341
430
  }
342
431
  static async doesNotCommitUpdateGitignoreIfDone() {
343
- await this.createAndRunAutopackage();
432
+ await this.runTwice();
344
433
  assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
345
434
  `patch: add build dir to gitignore (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit gitignore changes once!');
346
435
  }
436
+ static async doesNotCommitUpdateTsconfigIfDone() {
437
+ await this.runTwice();
438
+ assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
439
+ `patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit tsconfig changes once!');
440
+ }
347
441
  static async doesNotCommitSetupVscodeIfDone() {
348
- await this.createAndRunAutopackage();
442
+ await this.runTwice();
349
443
  assert.isEqual(FakeAutocommit.callsToConstructor.filter((call) => call?.commitMessage ===
350
444
  `patch: setup vscode (@neurodevs/meta-node: ${this.metaNodeVersion})`).length, 1, 'Did not commit vscode changes once!');
351
445
  }
352
446
  static async doesNotOverrideOriginalDependencies() {
353
- await this.createAndRunAutopackage();
447
+ await this.runTwice();
354
448
  assert.isEqualDeep(JSON.parse(callsToWriteFile[0]?.data).dependencies, this.dependencies, 'Did not update package.json as expected!');
355
449
  }
356
450
  static async doesNotUpdateTasksJsonIfAlreadyDone() {
357
- setFakeReadFileResult(this.tasksJsonPath, this.updatedTasksJson);
358
- await this.createAndRunAutopackage();
451
+ await this.runTwice();
359
452
  assert.isEqualDeep(callsToWriteFile.filter((call) => call.file === this.tasksJsonPath)
360
- .length, 0, 'Did not update tasks.json once!');
453
+ .length, 1, 'Did not update tasks.json once!');
361
454
  }
362
455
  static async doesNotOpenVscodeIfNotCloned() {
363
456
  setPathShouldExist(this.packageDir, true);
364
- await this.createAndRunAutopackage();
457
+ await this.run();
365
458
  assert.isFalse(callsToExec.some((call) => call?.command === 'code .'), 'Should not open vscode if not cloned!');
366
459
  }
367
460
  static async doesNotThrowIfGenerateIdNotInPackageJson() {
368
461
  setFakeReadFileResult(this.packageJsonPath, this.originalPackageJson.replace('@neurodevs/generate-id', ''));
369
- await this.createAndRunAutopackage();
462
+ await this.runTwice();
370
463
  }
371
464
  static async doesNotInstallAbstractPackageTestIfTsExists() {
372
465
  setPathShouldExist(this.abstractTestPath, true);
373
- await this.createAndRunAutopackage();
466
+ await this.run();
374
467
  const calls = callsToWriteFile.filter((call) => call.file === this.abstractTestPath);
375
468
  assert.isEqual(calls.length, 0, 'Should not install AbstractPackageTest.ts if already exists!');
376
469
  }
377
470
  static async doesNotInstallAbstractPackageTestIfTsxExists() {
378
471
  setPathShouldExist(`${this.abstractTestPath}x`, true);
379
- await this.createAndRunAutopackage();
472
+ await this.run();
380
473
  const calls = callsToWriteFile.filter((call) => call.file === this.abstractTestPath);
381
474
  assert.isEqual(calls.length, 0, 'Should not install AbstractPackageTest.tsx if already exists!');
382
475
  }
476
+ static async doesNotRemoveEslintConfigMjsIfNotExists() {
477
+ setPathShouldExist(this.eslintConfigMjsPath, false);
478
+ await this.run();
479
+ const calls = callsToExec.filter((call) => call?.command === `git rm eslint.config.mjs`);
480
+ assert.isEqual(calls.length, 0, 'Should not remove eslint.config.mjs if it does not exist!');
481
+ }
482
+ static async doesNotInstallEslintConfigFileIfExists() {
483
+ setPathShouldExist(this.eslintConfigJsPath, true);
484
+ await this.run();
485
+ const calls = callsToWriteFile.filter((call) => call.file === this.eslintConfigJsPath);
486
+ assert.isEqual(calls.length, 0, 'Should not install eslint.config.js if already exists!');
487
+ }
488
+ static async doesNotInstallPrettierConfigFileIfExists() {
489
+ setPathShouldExist(this.prettierConfigPath, true);
490
+ await this.run();
491
+ const calls = callsToWriteFile.filter((call) => call.file === this.prettierConfigPath);
492
+ assert.isEqual(calls.length, 0, 'Should not install prettier.config.js if already exists!');
493
+ }
383
494
  static async run() {
384
495
  await this.instance.run();
385
496
  }
386
- static async createAndRunAutopackage() {
387
- const instance = this.NpmAutopackage();
388
- await instance.run();
497
+ static async runTwice() {
498
+ await this.run();
499
+ setPathShouldExist(this.packageDir, true);
500
+ setPathShouldExist(this.packageJsonPath, true);
501
+ setPathShouldExist(this.abstractTestPath, true);
502
+ setPathShouldExist(this.tasksJsonPath, true);
503
+ setFakeReadFileResult(this.packageJsonPath, this.updatedPackageJson);
504
+ setFakeReadFileResult(this.gitignorePath, this.updatedGitignore);
505
+ setFakeReadFileResult(this.tasksJsonPath, this.updatedTasksJson);
506
+ setFakeReadFileResult(this.tsconfigPath, JSON.stringify(this.updatedTsconfig));
507
+ const fakeResponse = new Response(null, {
508
+ status: 200,
509
+ statusText: 'OK',
510
+ });
511
+ setFakeFetchResponse(this.reposUrl, fakeResponse);
512
+ await this.run();
513
+ }
514
+ static setShouldInstallDevDeps() {
515
+ setFakeExecResult(this.checkGenerateIdVersionCmd, {
516
+ stdout: '0.0.1',
517
+ });
389
518
  }
390
519
  static get scopedPackageName() {
391
520
  return `@${this.npmNamespace}/${this.packageName}`;
@@ -412,6 +541,18 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
412
541
  NpmAutopackage.exec = fakeExec;
413
542
  resetCallsToExec();
414
543
  this.setFakeMetaNodeVersion();
544
+ setFakeExecResult(this.checkGenerateIdVersionCmd, {
545
+ stdout: '1.0.0',
546
+ });
547
+ setFakeExecResult(this.checkNodeTddVersionCmd, {
548
+ stdout: '1.0.0',
549
+ });
550
+ setFakeExecResult(this.checkEslintConfigNdxVersionCmd, {
551
+ stdout: '1.0.0',
552
+ });
553
+ setFakeExecResult(this.checkPrettierConfigNdxVersionCmd, {
554
+ stdout: '1.0.0',
555
+ });
415
556
  }
416
557
  static fakeFetch() {
417
558
  NpmAutopackage.fetch = fakeFetch;
@@ -424,6 +565,9 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
424
565
  static fakePathExists() {
425
566
  NpmAutopackage.pathExists = fakePathExists;
426
567
  resetCallsToPathExists();
568
+ setPathShouldExist(this.packageDir, false);
569
+ setPathShouldExist(this.packageJsonPath, false);
570
+ setPathShouldExist(this.tasksJsonPath, false);
427
571
  setPathShouldExist(this.abstractTestPath, false);
428
572
  }
429
573
  static fakeReadFile() {
@@ -431,6 +575,8 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
431
575
  resetCallsToReadFile();
432
576
  setFakeReadFileResult(this.packageJsonPath, this.originalPackageJson);
433
577
  setFakeReadFileResult(this.tasksJsonPath, JSON.stringify(this.originalTasksJson));
578
+ setFakeReadFileResult(this.tsconfigPath, JSON.stringify(this.originalTsconfig));
579
+ setFakeReadFileResult(this.gitignorePath, this.originalGitignore);
434
580
  }
435
581
  static fakeWriteFile() {
436
582
  NpmAutopackage.writeFile = fakeWriteFile;
@@ -461,6 +607,8 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
461
607
  devDependencies: {
462
608
  '@neurodevs/generate-id': '^1.0.0',
463
609
  '@neurodevs/node-tdd': '^1.0.0',
610
+ '@neurodevs/eslint-config-ndx': '^1.0.0',
611
+ '@neurodevs/prettier-config-ndx': '^1.0.0',
464
612
  },
465
613
  });
466
614
  }
@@ -469,6 +617,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
469
617
  ...JSON.parse(this.originalPackageJson),
470
618
  name: this.scopedPackageName,
471
619
  description: this.description,
620
+ type: 'module',
472
621
  keywords: this.keywords,
473
622
  license: this.license,
474
623
  author: this.author,
@@ -484,6 +633,44 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
484
633
  dependencies: this.dependencies,
485
634
  });
486
635
  }
636
+ static get originalTsconfig() {
637
+ return {
638
+ compilerOptions: {
639
+ lib: [this.customLib],
640
+ types: [this.customType],
641
+ },
642
+ include: [this.customInclude],
643
+ customOption: this.customOption,
644
+ };
645
+ }
646
+ static get updatedTsconfig() {
647
+ return {
648
+ ...this.originalTsconfig,
649
+ compilerOptions: {
650
+ module: 'nodenext',
651
+ moduleResolution: 'nodenext',
652
+ target: 'ES2022',
653
+ lib: [this.customLib, 'ES2022'],
654
+ types: [this.customType, 'node'],
655
+ baseUrl: 'src',
656
+ outDir: 'build',
657
+ sourceMap: false,
658
+ strict: true,
659
+ noImplicitAny: true,
660
+ noImplicitReturns: true,
661
+ noUnusedLocals: true,
662
+ forceConsistentCasingInFileNames: true,
663
+ declaration: true,
664
+ skipLibCheck: true,
665
+ esModuleInterop: true,
666
+ moduleDetection: 'force',
667
+ allowJs: true,
668
+ resolveJsonModule: true,
669
+ experimentalDecorators: true,
670
+ },
671
+ include: [this.customInclude, './src/*.ts', './src/**/*.ts'],
672
+ };
673
+ }
487
674
  static originalTasksJson = {
488
675
  [this.randomId]: this.randomId,
489
676
  tasks: [
@@ -569,6 +756,12 @@ __decorate([
569
756
  __decorate([
570
757
  test()
571
758
  ], NpmAutopackageTest, "thenCommitUpdateGitignore", null);
759
+ __decorate([
760
+ test()
761
+ ], NpmAutopackageTest, "thenUpdatesTsconfig", null);
762
+ __decorate([
763
+ test()
764
+ ], NpmAutopackageTest, "thenCommitsUpdateTsconfig", null);
572
765
  __decorate([
573
766
  test()
574
767
  ], NpmAutopackageTest, "thenSpruceSetupVscode", null);
@@ -596,6 +789,21 @@ __decorate([
596
789
  __decorate([
597
790
  test()
598
791
  ], NpmAutopackageTest, "thenCommitsInstallAbstractPackageTest", null);
792
+ __decorate([
793
+ test()
794
+ ], NpmAutopackageTest, "thenDeletesOldEslintConfigMjs", null);
795
+ __decorate([
796
+ test()
797
+ ], NpmAutopackageTest, "thenInstallsNewEslintConfigJs", null);
798
+ __decorate([
799
+ test()
800
+ ], NpmAutopackageTest, "thenCommitsInstallEslintConfigFile", null);
801
+ __decorate([
802
+ test()
803
+ ], NpmAutopackageTest, "thenInstallsPrettierConfigFile", null);
804
+ __decorate([
805
+ test()
806
+ ], NpmAutopackageTest, "thenCommitsInstallPrettierConfigFile", null);
599
807
  __decorate([
600
808
  test()
601
809
  ], NpmAutopackageTest, "lastlyOpensVscodeAtEnd", null);
@@ -605,6 +813,12 @@ __decorate([
605
813
  __decorate([
606
814
  test()
607
815
  ], NpmAutopackageTest, "installsDevDependenciesIfNodeTddNotLatest", null);
816
+ __decorate([
817
+ test()
818
+ ], NpmAutopackageTest, "installsDevDependenciesIfEslintConfigNdxNotLatest", null);
819
+ __decorate([
820
+ test()
821
+ ], NpmAutopackageTest, "installsDevDependenciesIfPrettierConfigNdxNotLatest", null);
608
822
  __decorate([
609
823
  test()
610
824
  ], NpmAutopackageTest, "makeNpmNamespaceOptional", null);
@@ -629,6 +843,9 @@ __decorate([
629
843
  __decorate([
630
844
  test()
631
845
  ], NpmAutopackageTest, "doesNotCommitUpdateGitignoreIfDone", null);
846
+ __decorate([
847
+ test()
848
+ ], NpmAutopackageTest, "doesNotCommitUpdateTsconfigIfDone", null);
632
849
  __decorate([
633
850
  test()
634
851
  ], NpmAutopackageTest, "doesNotCommitSetupVscodeIfDone", null);
@@ -650,4 +867,13 @@ __decorate([
650
867
  __decorate([
651
868
  test()
652
869
  ], NpmAutopackageTest, "doesNotInstallAbstractPackageTestIfTsxExists", null);
870
+ __decorate([
871
+ test()
872
+ ], NpmAutopackageTest, "doesNotRemoveEslintConfigMjsIfNotExists", null);
873
+ __decorate([
874
+ test()
875
+ ], NpmAutopackageTest, "doesNotInstallEslintConfigFileIfExists", null);
876
+ __decorate([
877
+ test()
878
+ ], NpmAutopackageTest, "doesNotInstallPrettierConfigFileIfExists", null);
653
879
  //# sourceMappingURL=NpmAutopackage.test.js.map