@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.
- package/.vscode/launch.json +1 -0
- package/build/__tests__/impl/NpmAutopackage.test.d.ts +31 -2
- package/build/__tests__/impl/NpmAutopackage.test.js +270 -44
- package/build/__tests__/impl/NpmAutopackage.test.js.map +1 -1
- package/build/impl/NpmAutopackage.d.ts +30 -5
- package/build/impl/NpmAutopackage.js +141 -14
- package/build/impl/NpmAutopackage.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/impl/NpmAutopackage.test.ts +387 -47
- package/src/impl/NpmAutopackage.ts +214 -19
|
@@ -32,6 +32,7 @@ import GitAutocommit from '../../impl/GitAutocommit.js'
|
|
|
32
32
|
import NpmAutopackage, {
|
|
33
33
|
Autopackage,
|
|
34
34
|
AutopackageOptions,
|
|
35
|
+
TsConfig,
|
|
35
36
|
} from '../../impl/NpmAutopackage.js'
|
|
36
37
|
import FakeAutocommit from '../../testDoubles/Autocommit/FakeAutocommit.js'
|
|
37
38
|
import AbstractPackageTest from '../AbstractPackageTest.js'
|
|
@@ -65,7 +66,15 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
65
66
|
this.packageDir,
|
|
66
67
|
'.gitignore'
|
|
67
68
|
)
|
|
68
|
-
|
|
69
|
+
|
|
70
|
+
private static readonly originalGitignore = this.generateId()
|
|
71
|
+
|
|
72
|
+
private static readonly updatedGitignore = `${this.originalGitignore}\nbuild/`
|
|
73
|
+
|
|
74
|
+
private static readonly tsconfigPath = path.join(
|
|
75
|
+
this.packageDir,
|
|
76
|
+
'tsconfig.json'
|
|
77
|
+
)
|
|
69
78
|
|
|
70
79
|
private static readonly tasksJsonPath = path.join(
|
|
71
80
|
this.packageDir,
|
|
@@ -84,10 +93,32 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
84
93
|
'AbstractPackageTest.ts'
|
|
85
94
|
)
|
|
86
95
|
|
|
96
|
+
private static readonly eslintConfigMjsPath = path.join(
|
|
97
|
+
this.packageDir,
|
|
98
|
+
'eslint.config.mjs'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
private static readonly eslintConfigJsPath = path.join(
|
|
102
|
+
this.packageDir,
|
|
103
|
+
'eslint.config.js'
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
private static readonly prettierConfigPath = path.join(
|
|
107
|
+
this.packageDir,
|
|
108
|
+
'prettier.config.js'
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
private static readonly customLib = this.generateId()
|
|
112
|
+
private static readonly customType = this.generateId()
|
|
113
|
+
private static readonly customInclude = this.generateId()
|
|
114
|
+
private static readonly customOption = this.generateId()
|
|
115
|
+
|
|
87
116
|
private static readonly setupVscodeCmd = 'spruce setup.vscode --all true'
|
|
88
117
|
|
|
89
118
|
private static readonly checkGenerateIdVersionCmd = `yarn info @neurodevs/generate-id version --silent`
|
|
90
119
|
private static readonly checkNodeTddVersionCmd = `yarn info @neurodevs/node-tdd version --silent`
|
|
120
|
+
private static readonly checkEslintConfigNdxVersionCmd = `yarn info @neurodevs/eslint-config-ndx version --silent`
|
|
121
|
+
private static readonly checkPrettierConfigNdxVersionCmd = `yarn info @neurodevs/prettier-config-ndx version --silent`
|
|
91
122
|
|
|
92
123
|
private static readonly dependencies = {
|
|
93
124
|
[this.generateId()]: this.generateId(),
|
|
@@ -95,7 +126,7 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
95
126
|
}
|
|
96
127
|
|
|
97
128
|
private static readonly yarnInstallDevDepsCommand =
|
|
98
|
-
'yarn add -D @neurodevs/generate-id
|
|
129
|
+
'yarn add -D @neurodevs/generate-id @neurodevs/node-tdd @neurodevs/eslint-config-ndx @neurodevs/prettier-config-ndx'
|
|
99
130
|
|
|
100
131
|
private static readonly abstractTestFile = `import AbstractModuleTest from '@neurodevs/node-tdd'
|
|
101
132
|
|
|
@@ -104,6 +135,16 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
104
135
|
await super.beforeEach()
|
|
105
136
|
}
|
|
106
137
|
}
|
|
138
|
+
`
|
|
139
|
+
|
|
140
|
+
private static readonly eslintConfigFile = `import esConfigNdx from './src/eslint.config.js'
|
|
141
|
+
|
|
142
|
+
export default esConfigNdx
|
|
143
|
+
`
|
|
144
|
+
|
|
145
|
+
private static readonly prettierConfigFile = `import prettierConfigNdx from '@neurodevs/prettier-config-ndx'
|
|
146
|
+
|
|
147
|
+
export default prettierConfigNdx
|
|
107
148
|
`
|
|
108
149
|
|
|
109
150
|
private static readonly defaultOptions = {
|
|
@@ -334,7 +375,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
334
375
|
callsToWriteFile[1],
|
|
335
376
|
{
|
|
336
377
|
file: this.gitignorePath,
|
|
337
|
-
data:
|
|
378
|
+
data: '\nbuild/\n',
|
|
338
379
|
options: { encoding: 'utf-8', flag: 'a' },
|
|
339
380
|
},
|
|
340
381
|
'Did not update .gitignore as expected!'
|
|
@@ -355,6 +396,35 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
355
396
|
)
|
|
356
397
|
}
|
|
357
398
|
|
|
399
|
+
@test()
|
|
400
|
+
protected static async thenUpdatesTsconfig() {
|
|
401
|
+
await this.run()
|
|
402
|
+
|
|
403
|
+
assert.isEqualDeep(
|
|
404
|
+
callsToWriteFile[2],
|
|
405
|
+
{
|
|
406
|
+
file: this.tsconfigPath,
|
|
407
|
+
data: JSON.stringify(this.updatedTsconfig, null, 4) + '\n',
|
|
408
|
+
options: { encoding: 'utf-8', flag: 'a' },
|
|
409
|
+
},
|
|
410
|
+
'Did not update tsconfig as expected!'
|
|
411
|
+
)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
@test()
|
|
415
|
+
protected static async thenCommitsUpdateTsconfig() {
|
|
416
|
+
await this.run()
|
|
417
|
+
|
|
418
|
+
assert.isEqualDeep(
|
|
419
|
+
FakeAutocommit.callsToConstructor[3],
|
|
420
|
+
{
|
|
421
|
+
commitMessage: `patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
422
|
+
cwd: this.packageDir,
|
|
423
|
+
},
|
|
424
|
+
'Did not commit tsconfig changes!'
|
|
425
|
+
)
|
|
426
|
+
}
|
|
427
|
+
|
|
358
428
|
@test()
|
|
359
429
|
protected static async thenSpruceSetupVscode() {
|
|
360
430
|
await this.run()
|
|
@@ -374,7 +444,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
374
444
|
await this.run()
|
|
375
445
|
|
|
376
446
|
assert.isEqualDeep(
|
|
377
|
-
FakeAutocommit.callsToConstructor[
|
|
447
|
+
FakeAutocommit.callsToConstructor[4],
|
|
378
448
|
{
|
|
379
449
|
commitMessage: `patch: setup vscode (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
380
450
|
cwd: this.packageDir,
|
|
@@ -387,7 +457,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
387
457
|
protected static async thenUpdatesVscodeTasksJson() {
|
|
388
458
|
await this.run()
|
|
389
459
|
|
|
390
|
-
assert.isEqualDeep(callsToWriteFile[
|
|
460
|
+
assert.isEqualDeep(callsToWriteFile[3], {
|
|
391
461
|
file: this.tasksJsonPath,
|
|
392
462
|
data: this.updatedTasksJson,
|
|
393
463
|
options: { encoding: 'utf-8' },
|
|
@@ -399,7 +469,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
399
469
|
await this.run()
|
|
400
470
|
|
|
401
471
|
assert.isEqualDeep(
|
|
402
|
-
FakeAutocommit.callsToConstructor[
|
|
472
|
+
FakeAutocommit.callsToConstructor[5],
|
|
403
473
|
{
|
|
404
474
|
commitMessage: `patch: update vscode tasks.json (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
405
475
|
cwd: this.packageDir,
|
|
@@ -410,10 +480,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
410
480
|
|
|
411
481
|
@test()
|
|
412
482
|
protected static async thenInstallsDefaultDevDependencies() {
|
|
483
|
+
this.setShouldInstallDevDeps()
|
|
413
484
|
await this.run()
|
|
414
485
|
|
|
415
486
|
assert.isEqualDeep(
|
|
416
|
-
callsToExec[
|
|
487
|
+
callsToExec[10],
|
|
417
488
|
{
|
|
418
489
|
command: this.yarnInstallDevDepsCommand,
|
|
419
490
|
options: { cwd: this.packageDir },
|
|
@@ -424,10 +495,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
424
495
|
|
|
425
496
|
@test()
|
|
426
497
|
protected static async thenCommitsInstallDefaultDevDependencies() {
|
|
498
|
+
this.setShouldInstallDevDeps()
|
|
427
499
|
await this.run()
|
|
428
500
|
|
|
429
501
|
assert.isEqualDeep(
|
|
430
|
-
FakeAutocommit.callsToConstructor[
|
|
502
|
+
FakeAutocommit.callsToConstructor[6],
|
|
431
503
|
{
|
|
432
504
|
commitMessage: `patch: install default devDependencies (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
433
505
|
cwd: this.packageDir,
|
|
@@ -452,10 +524,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
452
524
|
|
|
453
525
|
@test()
|
|
454
526
|
protected static async thenInstallsAbstractPackageTest() {
|
|
527
|
+
this.setShouldInstallDevDeps()
|
|
455
528
|
await this.run()
|
|
456
529
|
|
|
457
530
|
assert.isEqualDeep(
|
|
458
|
-
callsToWriteFile[
|
|
531
|
+
callsToWriteFile[4],
|
|
459
532
|
{
|
|
460
533
|
file: this.abstractTestPath,
|
|
461
534
|
data: this.abstractTestFile,
|
|
@@ -467,10 +540,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
467
540
|
|
|
468
541
|
@test()
|
|
469
542
|
protected static async thenCommitsInstallAbstractPackageTest() {
|
|
543
|
+
this.setShouldInstallDevDeps()
|
|
470
544
|
await this.run()
|
|
471
545
|
|
|
472
546
|
assert.isEqualDeep(
|
|
473
|
-
FakeAutocommit.callsToConstructor[
|
|
547
|
+
FakeAutocommit.callsToConstructor[7],
|
|
474
548
|
{
|
|
475
549
|
commitMessage: `patch: install AbstractPackageTest (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
476
550
|
cwd: this.packageDir,
|
|
@@ -479,12 +553,94 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
479
553
|
)
|
|
480
554
|
}
|
|
481
555
|
|
|
556
|
+
@test()
|
|
557
|
+
protected static async thenDeletesOldEslintConfigMjs() {
|
|
558
|
+
setPathShouldExist(
|
|
559
|
+
path.join(this.packageDir, 'eslint.config.mjs'),
|
|
560
|
+
true
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
this.setShouldInstallDevDeps()
|
|
564
|
+
await this.run()
|
|
565
|
+
|
|
566
|
+
assert.isEqualDeep(
|
|
567
|
+
callsToExec[11],
|
|
568
|
+
{
|
|
569
|
+
command: `git rm eslint.config.mjs`,
|
|
570
|
+
options: { cwd: this.packageDir },
|
|
571
|
+
},
|
|
572
|
+
'Did not delete old eslint.config.mjs!'
|
|
573
|
+
)
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
@test()
|
|
577
|
+
protected static async thenInstallsNewEslintConfigJs() {
|
|
578
|
+
this.setShouldInstallDevDeps()
|
|
579
|
+
await this.run()
|
|
580
|
+
|
|
581
|
+
assert.isEqualDeep(
|
|
582
|
+
callsToWriteFile[5],
|
|
583
|
+
{
|
|
584
|
+
file: this.eslintConfigJsPath,
|
|
585
|
+
data: this.eslintConfigFile,
|
|
586
|
+
options: { encoding: 'utf-8' },
|
|
587
|
+
},
|
|
588
|
+
'Did not install eslint.config.js!'
|
|
589
|
+
)
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
@test()
|
|
593
|
+
protected static async thenCommitsInstallEslintConfigFile() {
|
|
594
|
+
this.setShouldInstallDevDeps()
|
|
595
|
+
await this.run()
|
|
596
|
+
|
|
597
|
+
assert.isEqualDeep(
|
|
598
|
+
FakeAutocommit.callsToConstructor[8],
|
|
599
|
+
{
|
|
600
|
+
commitMessage: `patch: install eslint.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
601
|
+
cwd: this.packageDir,
|
|
602
|
+
},
|
|
603
|
+
'Did not commit install eslint.config.js changes!'
|
|
604
|
+
)
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
@test()
|
|
608
|
+
protected static async thenInstallsPrettierConfigFile() {
|
|
609
|
+
this.setShouldInstallDevDeps()
|
|
610
|
+
await this.run()
|
|
611
|
+
|
|
612
|
+
assert.isEqualDeep(
|
|
613
|
+
callsToWriteFile[6],
|
|
614
|
+
{
|
|
615
|
+
file: this.prettierConfigPath,
|
|
616
|
+
data: this.prettierConfigFile,
|
|
617
|
+
options: { encoding: 'utf-8' },
|
|
618
|
+
},
|
|
619
|
+
'Did not install prettier.config.js!'
|
|
620
|
+
)
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
@test()
|
|
624
|
+
protected static async thenCommitsInstallPrettierConfigFile() {
|
|
625
|
+
this.setShouldInstallDevDeps()
|
|
626
|
+
await this.run()
|
|
627
|
+
|
|
628
|
+
assert.isEqualDeep(
|
|
629
|
+
FakeAutocommit.callsToConstructor[9],
|
|
630
|
+
{
|
|
631
|
+
commitMessage: `patch: install prettier.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
632
|
+
cwd: this.packageDir,
|
|
633
|
+
},
|
|
634
|
+
'Did not commit install prettier.config.js changes!'
|
|
635
|
+
)
|
|
636
|
+
}
|
|
637
|
+
|
|
482
638
|
@test()
|
|
483
639
|
protected static async lastlyOpensVscodeAtEnd() {
|
|
484
640
|
await this.run()
|
|
485
641
|
|
|
486
642
|
assert.isEqualDeep(
|
|
487
|
-
callsToExec[
|
|
643
|
+
callsToExec[11],
|
|
488
644
|
{ command: 'code .', options: { cwd: this.packageDir } },
|
|
489
645
|
'Did not open vscode at end!'
|
|
490
646
|
)
|
|
@@ -496,7 +652,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
496
652
|
stdout: '0.0.1',
|
|
497
653
|
} as unknown as ChildProcess)
|
|
498
654
|
|
|
499
|
-
await this.
|
|
655
|
+
await this.runTwice()
|
|
500
656
|
|
|
501
657
|
const calls = callsToExec.filter(
|
|
502
658
|
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
@@ -514,15 +670,46 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
514
670
|
|
|
515
671
|
@test()
|
|
516
672
|
protected static async installsDevDependenciesIfNodeTddNotLatest() {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
} as unknown as ChildProcess)
|
|
673
|
+
this.setShouldInstallDevDeps()
|
|
674
|
+
await this.runTwice()
|
|
520
675
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
676
|
+
const calls = callsToExec.filter(
|
|
677
|
+
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
678
|
+
)
|
|
679
|
+
|
|
680
|
+
assert.isEqualDeep(
|
|
681
|
+
calls[0],
|
|
682
|
+
{
|
|
683
|
+
command: this.yarnInstallDevDepsCommand,
|
|
684
|
+
options: { cwd: this.packageDir },
|
|
685
|
+
},
|
|
686
|
+
'Should install default devDependencies if not already installed!'
|
|
687
|
+
)
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
@test()
|
|
691
|
+
protected static async installsDevDependenciesIfEslintConfigNdxNotLatest() {
|
|
692
|
+
this.setShouldInstallDevDeps()
|
|
693
|
+
await this.runTwice()
|
|
694
|
+
|
|
695
|
+
const calls = callsToExec.filter(
|
|
696
|
+
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
697
|
+
)
|
|
698
|
+
|
|
699
|
+
assert.isEqualDeep(
|
|
700
|
+
calls[0],
|
|
701
|
+
{
|
|
702
|
+
command: this.yarnInstallDevDepsCommand,
|
|
703
|
+
options: { cwd: this.packageDir },
|
|
704
|
+
},
|
|
705
|
+
'Should install default devDependencies if not already installed!'
|
|
706
|
+
)
|
|
707
|
+
}
|
|
524
708
|
|
|
525
|
-
|
|
709
|
+
@test()
|
|
710
|
+
protected static async installsDevDependenciesIfPrettierConfigNdxNotLatest() {
|
|
711
|
+
this.setShouldInstallDevDeps()
|
|
712
|
+
await this.runTwice()
|
|
526
713
|
|
|
527
714
|
const calls = callsToExec.filter(
|
|
528
715
|
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
@@ -557,25 +744,18 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
557
744
|
|
|
558
745
|
@test()
|
|
559
746
|
protected static async doesNotCreateRepoInGithubOrgIfDone() {
|
|
560
|
-
|
|
561
|
-
status: 200,
|
|
562
|
-
statusText: 'OK',
|
|
563
|
-
})
|
|
564
|
-
|
|
565
|
-
setFakeFetchResponse(this.reposUrl, fakeResponse)
|
|
566
|
-
|
|
567
|
-
await this.createAndRunAutopackage()
|
|
747
|
+
await this.runTwice()
|
|
568
748
|
|
|
569
749
|
const numCalls = callsToFetch.filter(
|
|
570
750
|
(call) => call.input === this.orgsUrl
|
|
571
751
|
).length
|
|
572
752
|
|
|
573
|
-
assert.isEqual(numCalls,
|
|
753
|
+
assert.isEqual(numCalls, 1, 'Should have created repo once!')
|
|
574
754
|
}
|
|
575
755
|
|
|
576
756
|
@test()
|
|
577
757
|
protected static async doesNotCloneRepoIfDone() {
|
|
578
|
-
await this.
|
|
758
|
+
await this.runTwice()
|
|
579
759
|
|
|
580
760
|
assert.isEqual(
|
|
581
761
|
callsToExec.filter(
|
|
@@ -590,7 +770,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
590
770
|
|
|
591
771
|
@test()
|
|
592
772
|
protected static async doesNotSpruceCreateModuleIfDone() {
|
|
593
|
-
await this.
|
|
773
|
+
await this.runTwice()
|
|
594
774
|
|
|
595
775
|
assert.isEqual(
|
|
596
776
|
callsToExec.filter((call) => call?.command === this.createModuleCmd)
|
|
@@ -602,7 +782,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
602
782
|
|
|
603
783
|
@test()
|
|
604
784
|
protected static async doesNotRunSetupVscodeIfDone() {
|
|
605
|
-
await this.
|
|
785
|
+
await this.runTwice()
|
|
606
786
|
|
|
607
787
|
assert.isEqual(
|
|
608
788
|
callsToExec.filter((call) => call?.command === this.setupVscodeCmd)
|
|
@@ -614,7 +794,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
614
794
|
|
|
615
795
|
@test()
|
|
616
796
|
protected static async doesNotCommitCreatePackageIfDone() {
|
|
617
|
-
await this.
|
|
797
|
+
await this.runTwice()
|
|
618
798
|
|
|
619
799
|
assert.isEqual(
|
|
620
800
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -629,7 +809,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
629
809
|
|
|
630
810
|
@test()
|
|
631
811
|
protected static async doesNotCommitUpdatePackageIfDone() {
|
|
632
|
-
await this.
|
|
812
|
+
await this.runTwice()
|
|
633
813
|
|
|
634
814
|
assert.isEqual(
|
|
635
815
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -644,7 +824,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
644
824
|
|
|
645
825
|
@test()
|
|
646
826
|
protected static async doesNotCommitUpdateGitignoreIfDone() {
|
|
647
|
-
await this.
|
|
827
|
+
await this.runTwice()
|
|
648
828
|
|
|
649
829
|
assert.isEqual(
|
|
650
830
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -657,9 +837,24 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
657
837
|
)
|
|
658
838
|
}
|
|
659
839
|
|
|
840
|
+
@test()
|
|
841
|
+
protected static async doesNotCommitUpdateTsconfigIfDone() {
|
|
842
|
+
await this.runTwice()
|
|
843
|
+
|
|
844
|
+
assert.isEqual(
|
|
845
|
+
FakeAutocommit.callsToConstructor.filter(
|
|
846
|
+
(call) =>
|
|
847
|
+
call?.commitMessage ===
|
|
848
|
+
`patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`
|
|
849
|
+
).length,
|
|
850
|
+
1,
|
|
851
|
+
'Did not commit tsconfig changes once!'
|
|
852
|
+
)
|
|
853
|
+
}
|
|
854
|
+
|
|
660
855
|
@test()
|
|
661
856
|
protected static async doesNotCommitSetupVscodeIfDone() {
|
|
662
|
-
await this.
|
|
857
|
+
await this.runTwice()
|
|
663
858
|
|
|
664
859
|
assert.isEqual(
|
|
665
860
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -674,7 +869,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
674
869
|
|
|
675
870
|
@test()
|
|
676
871
|
protected static async doesNotOverrideOriginalDependencies() {
|
|
677
|
-
await this.
|
|
872
|
+
await this.runTwice()
|
|
678
873
|
|
|
679
874
|
assert.isEqualDeep(
|
|
680
875
|
JSON.parse(callsToWriteFile[0]?.data).dependencies,
|
|
@@ -685,14 +880,12 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
685
880
|
|
|
686
881
|
@test()
|
|
687
882
|
protected static async doesNotUpdateTasksJsonIfAlreadyDone() {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
await this.createAndRunAutopackage()
|
|
883
|
+
await this.runTwice()
|
|
691
884
|
|
|
692
885
|
assert.isEqualDeep(
|
|
693
886
|
callsToWriteFile.filter((call) => call.file === this.tasksJsonPath)
|
|
694
887
|
.length,
|
|
695
|
-
|
|
888
|
+
1,
|
|
696
889
|
'Did not update tasks.json once!'
|
|
697
890
|
)
|
|
698
891
|
}
|
|
@@ -701,7 +894,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
701
894
|
protected static async doesNotOpenVscodeIfNotCloned() {
|
|
702
895
|
setPathShouldExist(this.packageDir, true)
|
|
703
896
|
|
|
704
|
-
await this.
|
|
897
|
+
await this.run()
|
|
705
898
|
|
|
706
899
|
assert.isFalse(
|
|
707
900
|
callsToExec.some((call) => call?.command === 'code .'),
|
|
@@ -716,14 +909,14 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
716
909
|
this.originalPackageJson.replace('@neurodevs/generate-id', '')
|
|
717
910
|
)
|
|
718
911
|
|
|
719
|
-
await this.
|
|
912
|
+
await this.runTwice()
|
|
720
913
|
}
|
|
721
914
|
|
|
722
915
|
@test()
|
|
723
916
|
protected static async doesNotInstallAbstractPackageTestIfTsExists() {
|
|
724
917
|
setPathShouldExist(this.abstractTestPath, true)
|
|
725
918
|
|
|
726
|
-
await this.
|
|
919
|
+
await this.run()
|
|
727
920
|
|
|
728
921
|
const calls = callsToWriteFile.filter(
|
|
729
922
|
(call) => call.file === this.abstractTestPath
|
|
@@ -740,7 +933,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
740
933
|
protected static async doesNotInstallAbstractPackageTestIfTsxExists() {
|
|
741
934
|
setPathShouldExist(`${this.abstractTestPath}x`, true)
|
|
742
935
|
|
|
743
|
-
await this.
|
|
936
|
+
await this.run()
|
|
744
937
|
|
|
745
938
|
const calls = callsToWriteFile.filter(
|
|
746
939
|
(call) => call.file === this.abstractTestPath
|
|
@@ -753,13 +946,91 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
753
946
|
)
|
|
754
947
|
}
|
|
755
948
|
|
|
949
|
+
@test()
|
|
950
|
+
protected static async doesNotRemoveEslintConfigMjsIfNotExists() {
|
|
951
|
+
setPathShouldExist(this.eslintConfigMjsPath, false)
|
|
952
|
+
await this.run()
|
|
953
|
+
|
|
954
|
+
const calls = callsToExec.filter(
|
|
955
|
+
(call) => call?.command === `git rm eslint.config.mjs`
|
|
956
|
+
)
|
|
957
|
+
|
|
958
|
+
assert.isEqual(
|
|
959
|
+
calls.length,
|
|
960
|
+
0,
|
|
961
|
+
'Should not remove eslint.config.mjs if it does not exist!'
|
|
962
|
+
)
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
@test()
|
|
966
|
+
protected static async doesNotInstallEslintConfigFileIfExists() {
|
|
967
|
+
setPathShouldExist(this.eslintConfigJsPath, true)
|
|
968
|
+
|
|
969
|
+
await this.run()
|
|
970
|
+
|
|
971
|
+
const calls = callsToWriteFile.filter(
|
|
972
|
+
(call) => call.file === this.eslintConfigJsPath
|
|
973
|
+
)
|
|
974
|
+
|
|
975
|
+
assert.isEqual(
|
|
976
|
+
calls.length,
|
|
977
|
+
0,
|
|
978
|
+
'Should not install eslint.config.js if already exists!'
|
|
979
|
+
)
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
@test()
|
|
983
|
+
protected static async doesNotInstallPrettierConfigFileIfExists() {
|
|
984
|
+
setPathShouldExist(this.prettierConfigPath, true)
|
|
985
|
+
|
|
986
|
+
await this.run()
|
|
987
|
+
|
|
988
|
+
const calls = callsToWriteFile.filter(
|
|
989
|
+
(call) => call.file === this.prettierConfigPath
|
|
990
|
+
)
|
|
991
|
+
|
|
992
|
+
assert.isEqual(
|
|
993
|
+
calls.length,
|
|
994
|
+
0,
|
|
995
|
+
'Should not install prettier.config.js if already exists!'
|
|
996
|
+
)
|
|
997
|
+
}
|
|
998
|
+
|
|
756
999
|
private static async run() {
|
|
757
1000
|
await this.instance.run()
|
|
758
1001
|
}
|
|
759
1002
|
|
|
760
|
-
private static async
|
|
761
|
-
|
|
762
|
-
|
|
1003
|
+
private static async runTwice() {
|
|
1004
|
+
await this.run()
|
|
1005
|
+
|
|
1006
|
+
setPathShouldExist(this.packageDir, true)
|
|
1007
|
+
setPathShouldExist(this.packageJsonPath, true)
|
|
1008
|
+
setPathShouldExist(this.abstractTestPath, true)
|
|
1009
|
+
setPathShouldExist(this.tasksJsonPath, true)
|
|
1010
|
+
|
|
1011
|
+
setFakeReadFileResult(this.packageJsonPath, this.updatedPackageJson)
|
|
1012
|
+
setFakeReadFileResult(this.gitignorePath, this.updatedGitignore)
|
|
1013
|
+
setFakeReadFileResult(this.tasksJsonPath, this.updatedTasksJson)
|
|
1014
|
+
|
|
1015
|
+
setFakeReadFileResult(
|
|
1016
|
+
this.tsconfigPath,
|
|
1017
|
+
JSON.stringify(this.updatedTsconfig)
|
|
1018
|
+
)
|
|
1019
|
+
|
|
1020
|
+
const fakeResponse = new Response(null, {
|
|
1021
|
+
status: 200,
|
|
1022
|
+
statusText: 'OK',
|
|
1023
|
+
})
|
|
1024
|
+
|
|
1025
|
+
setFakeFetchResponse(this.reposUrl, fakeResponse)
|
|
1026
|
+
|
|
1027
|
+
await this.run()
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
private static setShouldInstallDevDeps() {
|
|
1031
|
+
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
1032
|
+
stdout: '0.0.1',
|
|
1033
|
+
} as unknown as ChildProcess)
|
|
763
1034
|
}
|
|
764
1035
|
|
|
765
1036
|
private static get scopedPackageName() {
|
|
@@ -798,6 +1069,22 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
798
1069
|
resetCallsToExec()
|
|
799
1070
|
|
|
800
1071
|
this.setFakeMetaNodeVersion()
|
|
1072
|
+
|
|
1073
|
+
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
1074
|
+
stdout: '1.0.0',
|
|
1075
|
+
} as unknown as ChildProcess)
|
|
1076
|
+
|
|
1077
|
+
setFakeExecResult(this.checkNodeTddVersionCmd, {
|
|
1078
|
+
stdout: '1.0.0',
|
|
1079
|
+
} as unknown as ChildProcess)
|
|
1080
|
+
|
|
1081
|
+
setFakeExecResult(this.checkEslintConfigNdxVersionCmd, {
|
|
1082
|
+
stdout: '1.0.0',
|
|
1083
|
+
} as unknown as ChildProcess)
|
|
1084
|
+
|
|
1085
|
+
setFakeExecResult(this.checkPrettierConfigNdxVersionCmd, {
|
|
1086
|
+
stdout: '1.0.0',
|
|
1087
|
+
} as unknown as ChildProcess)
|
|
801
1088
|
}
|
|
802
1089
|
|
|
803
1090
|
private static fakeFetch() {
|
|
@@ -814,6 +1101,9 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
814
1101
|
NpmAutopackage.pathExists = fakePathExists
|
|
815
1102
|
resetCallsToPathExists()
|
|
816
1103
|
|
|
1104
|
+
setPathShouldExist(this.packageDir, false)
|
|
1105
|
+
setPathShouldExist(this.packageJsonPath, false)
|
|
1106
|
+
setPathShouldExist(this.tasksJsonPath, false)
|
|
817
1107
|
setPathShouldExist(this.abstractTestPath, false)
|
|
818
1108
|
}
|
|
819
1109
|
|
|
@@ -827,6 +1117,13 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
827
1117
|
this.tasksJsonPath,
|
|
828
1118
|
JSON.stringify(this.originalTasksJson)
|
|
829
1119
|
)
|
|
1120
|
+
|
|
1121
|
+
setFakeReadFileResult(
|
|
1122
|
+
this.tsconfigPath,
|
|
1123
|
+
JSON.stringify(this.originalTsconfig)
|
|
1124
|
+
)
|
|
1125
|
+
|
|
1126
|
+
setFakeReadFileResult(this.gitignorePath, this.originalGitignore)
|
|
830
1127
|
}
|
|
831
1128
|
|
|
832
1129
|
private static fakeWriteFile() {
|
|
@@ -864,6 +1161,8 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
864
1161
|
devDependencies: {
|
|
865
1162
|
'@neurodevs/generate-id': '^1.0.0',
|
|
866
1163
|
'@neurodevs/node-tdd': '^1.0.0',
|
|
1164
|
+
'@neurodevs/eslint-config-ndx': '^1.0.0',
|
|
1165
|
+
'@neurodevs/prettier-config-ndx': '^1.0.0',
|
|
867
1166
|
},
|
|
868
1167
|
})
|
|
869
1168
|
}
|
|
@@ -873,6 +1172,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
873
1172
|
...JSON.parse(this.originalPackageJson),
|
|
874
1173
|
name: this.scopedPackageName,
|
|
875
1174
|
description: this.description,
|
|
1175
|
+
type: 'module',
|
|
876
1176
|
keywords: this.keywords,
|
|
877
1177
|
license: this.license,
|
|
878
1178
|
author: this.author,
|
|
@@ -889,6 +1189,46 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
889
1189
|
})
|
|
890
1190
|
}
|
|
891
1191
|
|
|
1192
|
+
private static get originalTsconfig(): TsConfig {
|
|
1193
|
+
return {
|
|
1194
|
+
compilerOptions: {
|
|
1195
|
+
lib: [this.customLib],
|
|
1196
|
+
types: [this.customType],
|
|
1197
|
+
},
|
|
1198
|
+
include: [this.customInclude],
|
|
1199
|
+
customOption: this.customOption,
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
private static get updatedTsconfig() {
|
|
1204
|
+
return {
|
|
1205
|
+
...this.originalTsconfig,
|
|
1206
|
+
compilerOptions: {
|
|
1207
|
+
module: 'nodenext',
|
|
1208
|
+
moduleResolution: 'nodenext',
|
|
1209
|
+
target: 'ES2022',
|
|
1210
|
+
lib: [this.customLib, 'ES2022'],
|
|
1211
|
+
types: [this.customType, 'node'],
|
|
1212
|
+
baseUrl: 'src',
|
|
1213
|
+
outDir: 'build',
|
|
1214
|
+
sourceMap: false,
|
|
1215
|
+
strict: true,
|
|
1216
|
+
noImplicitAny: true,
|
|
1217
|
+
noImplicitReturns: true,
|
|
1218
|
+
noUnusedLocals: true,
|
|
1219
|
+
forceConsistentCasingInFileNames: true,
|
|
1220
|
+
declaration: true,
|
|
1221
|
+
skipLibCheck: true,
|
|
1222
|
+
esModuleInterop: true,
|
|
1223
|
+
moduleDetection: 'force',
|
|
1224
|
+
allowJs: true,
|
|
1225
|
+
resolveJsonModule: true,
|
|
1226
|
+
experimentalDecorators: true,
|
|
1227
|
+
},
|
|
1228
|
+
include: [this.customInclude, './src/*.ts', './src/**/*.ts'],
|
|
1229
|
+
}
|
|
1230
|
+
}
|
|
1231
|
+
|
|
892
1232
|
private static originalTasksJson = {
|
|
893
1233
|
[this.randomId]: this.randomId,
|
|
894
1234
|
tasks: [
|