@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
|
@@ -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,27 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
84
93
|
'AbstractPackageTest.ts'
|
|
85
94
|
)
|
|
86
95
|
|
|
96
|
+
private static readonly eslintConfigPath = path.join(
|
|
97
|
+
this.packageDir,
|
|
98
|
+
'eslint.config.js'
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
private static readonly prettierConfigPath = path.join(
|
|
102
|
+
this.packageDir,
|
|
103
|
+
'prettier.config.js'
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
private static readonly customLib = this.generateId()
|
|
107
|
+
private static readonly customType = this.generateId()
|
|
108
|
+
private static readonly customInclude = this.generateId()
|
|
109
|
+
private static readonly customOption = this.generateId()
|
|
110
|
+
|
|
87
111
|
private static readonly setupVscodeCmd = 'spruce setup.vscode --all true'
|
|
88
112
|
|
|
89
113
|
private static readonly checkGenerateIdVersionCmd = `yarn info @neurodevs/generate-id version --silent`
|
|
90
114
|
private static readonly checkNodeTddVersionCmd = `yarn info @neurodevs/node-tdd version --silent`
|
|
115
|
+
private static readonly checkEslintConfigNdxVersionCmd = `yarn info @neurodevs/eslint-config-ndx version --silent`
|
|
116
|
+
private static readonly checkPrettierConfigNdxVersionCmd = `yarn info @neurodevs/prettier-config-ndx version --silent`
|
|
91
117
|
|
|
92
118
|
private static readonly dependencies = {
|
|
93
119
|
[this.generateId()]: this.generateId(),
|
|
@@ -95,7 +121,7 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
95
121
|
}
|
|
96
122
|
|
|
97
123
|
private static readonly yarnInstallDevDepsCommand =
|
|
98
|
-
'yarn add -D @neurodevs/generate-id
|
|
124
|
+
'yarn add -D @neurodevs/generate-id @neurodevs/node-tdd @neurodevs/eslint-config-ndx @neurodevs/prettier-config-ndx'
|
|
99
125
|
|
|
100
126
|
private static readonly abstractTestFile = `import AbstractModuleTest from '@neurodevs/node-tdd'
|
|
101
127
|
|
|
@@ -104,6 +130,16 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
104
130
|
await super.beforeEach()
|
|
105
131
|
}
|
|
106
132
|
}
|
|
133
|
+
`
|
|
134
|
+
|
|
135
|
+
private static readonly eslintConfigFile = `import esConfigNdx from './src/eslint.config.js'
|
|
136
|
+
|
|
137
|
+
export default esConfigNdx
|
|
138
|
+
`
|
|
139
|
+
|
|
140
|
+
private static readonly prettierConfigFile = `import prettierConfigNdx from '@neurodevs/prettier-config-ndx'
|
|
141
|
+
|
|
142
|
+
export default prettierConfigNdx
|
|
107
143
|
`
|
|
108
144
|
|
|
109
145
|
private static readonly defaultOptions = {
|
|
@@ -334,7 +370,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
334
370
|
callsToWriteFile[1],
|
|
335
371
|
{
|
|
336
372
|
file: this.gitignorePath,
|
|
337
|
-
data:
|
|
373
|
+
data: '\nbuild/\n',
|
|
338
374
|
options: { encoding: 'utf-8', flag: 'a' },
|
|
339
375
|
},
|
|
340
376
|
'Did not update .gitignore as expected!'
|
|
@@ -355,6 +391,35 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
355
391
|
)
|
|
356
392
|
}
|
|
357
393
|
|
|
394
|
+
@test()
|
|
395
|
+
protected static async thenUpdatesTsconfig() {
|
|
396
|
+
await this.run()
|
|
397
|
+
|
|
398
|
+
assert.isEqualDeep(
|
|
399
|
+
callsToWriteFile[2],
|
|
400
|
+
{
|
|
401
|
+
file: this.tsconfigPath,
|
|
402
|
+
data: JSON.stringify(this.updatedTsconfig, null, 4) + '\n',
|
|
403
|
+
options: { encoding: 'utf-8', flag: 'a' },
|
|
404
|
+
},
|
|
405
|
+
'Did not update tsconfig as expected!'
|
|
406
|
+
)
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
@test()
|
|
410
|
+
protected static async thenCommitsUpdateTsconfig() {
|
|
411
|
+
await this.run()
|
|
412
|
+
|
|
413
|
+
assert.isEqualDeep(
|
|
414
|
+
FakeAutocommit.callsToConstructor[3],
|
|
415
|
+
{
|
|
416
|
+
commitMessage: `patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
417
|
+
cwd: this.packageDir,
|
|
418
|
+
},
|
|
419
|
+
'Did not commit tsconfig changes!'
|
|
420
|
+
)
|
|
421
|
+
}
|
|
422
|
+
|
|
358
423
|
@test()
|
|
359
424
|
protected static async thenSpruceSetupVscode() {
|
|
360
425
|
await this.run()
|
|
@@ -374,7 +439,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
374
439
|
await this.run()
|
|
375
440
|
|
|
376
441
|
assert.isEqualDeep(
|
|
377
|
-
FakeAutocommit.callsToConstructor[
|
|
442
|
+
FakeAutocommit.callsToConstructor[4],
|
|
378
443
|
{
|
|
379
444
|
commitMessage: `patch: setup vscode (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
380
445
|
cwd: this.packageDir,
|
|
@@ -387,7 +452,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
387
452
|
protected static async thenUpdatesVscodeTasksJson() {
|
|
388
453
|
await this.run()
|
|
389
454
|
|
|
390
|
-
assert.isEqualDeep(callsToWriteFile[
|
|
455
|
+
assert.isEqualDeep(callsToWriteFile[3], {
|
|
391
456
|
file: this.tasksJsonPath,
|
|
392
457
|
data: this.updatedTasksJson,
|
|
393
458
|
options: { encoding: 'utf-8' },
|
|
@@ -399,7 +464,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
399
464
|
await this.run()
|
|
400
465
|
|
|
401
466
|
assert.isEqualDeep(
|
|
402
|
-
FakeAutocommit.callsToConstructor[
|
|
467
|
+
FakeAutocommit.callsToConstructor[5],
|
|
403
468
|
{
|
|
404
469
|
commitMessage: `patch: update vscode tasks.json (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
405
470
|
cwd: this.packageDir,
|
|
@@ -410,10 +475,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
410
475
|
|
|
411
476
|
@test()
|
|
412
477
|
protected static async thenInstallsDefaultDevDependencies() {
|
|
478
|
+
this.setShouldInstallDevDeps()
|
|
413
479
|
await this.run()
|
|
414
480
|
|
|
415
481
|
assert.isEqualDeep(
|
|
416
|
-
callsToExec[
|
|
482
|
+
callsToExec[10],
|
|
417
483
|
{
|
|
418
484
|
command: this.yarnInstallDevDepsCommand,
|
|
419
485
|
options: { cwd: this.packageDir },
|
|
@@ -424,10 +490,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
424
490
|
|
|
425
491
|
@test()
|
|
426
492
|
protected static async thenCommitsInstallDefaultDevDependencies() {
|
|
493
|
+
this.setShouldInstallDevDeps()
|
|
427
494
|
await this.run()
|
|
428
495
|
|
|
429
496
|
assert.isEqualDeep(
|
|
430
|
-
FakeAutocommit.callsToConstructor[
|
|
497
|
+
FakeAutocommit.callsToConstructor[6],
|
|
431
498
|
{
|
|
432
499
|
commitMessage: `patch: install default devDependencies (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
433
500
|
cwd: this.packageDir,
|
|
@@ -452,10 +519,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
452
519
|
|
|
453
520
|
@test()
|
|
454
521
|
protected static async thenInstallsAbstractPackageTest() {
|
|
522
|
+
this.setShouldInstallDevDeps()
|
|
455
523
|
await this.run()
|
|
456
524
|
|
|
457
525
|
assert.isEqualDeep(
|
|
458
|
-
callsToWriteFile[
|
|
526
|
+
callsToWriteFile[4],
|
|
459
527
|
{
|
|
460
528
|
file: this.abstractTestPath,
|
|
461
529
|
data: this.abstractTestFile,
|
|
@@ -467,10 +535,11 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
467
535
|
|
|
468
536
|
@test()
|
|
469
537
|
protected static async thenCommitsInstallAbstractPackageTest() {
|
|
538
|
+
this.setShouldInstallDevDeps()
|
|
470
539
|
await this.run()
|
|
471
540
|
|
|
472
541
|
assert.isEqualDeep(
|
|
473
|
-
FakeAutocommit.callsToConstructor[
|
|
542
|
+
FakeAutocommit.callsToConstructor[7],
|
|
474
543
|
{
|
|
475
544
|
commitMessage: `patch: install AbstractPackageTest (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
476
545
|
cwd: this.packageDir,
|
|
@@ -479,12 +548,74 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
479
548
|
)
|
|
480
549
|
}
|
|
481
550
|
|
|
551
|
+
@test()
|
|
552
|
+
protected static async thenInstallsEslintConfigFile() {
|
|
553
|
+
this.setShouldInstallDevDeps()
|
|
554
|
+
await this.run()
|
|
555
|
+
|
|
556
|
+
assert.isEqualDeep(
|
|
557
|
+
callsToWriteFile[5],
|
|
558
|
+
{
|
|
559
|
+
file: this.eslintConfigPath,
|
|
560
|
+
data: this.eslintConfigFile,
|
|
561
|
+
options: { encoding: 'utf-8' },
|
|
562
|
+
},
|
|
563
|
+
'Did not install eslint.config.js!'
|
|
564
|
+
)
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
@test()
|
|
568
|
+
protected static async thenCommitsInstallEslintConfigFile() {
|
|
569
|
+
this.setShouldInstallDevDeps()
|
|
570
|
+
await this.run()
|
|
571
|
+
|
|
572
|
+
assert.isEqualDeep(
|
|
573
|
+
FakeAutocommit.callsToConstructor[8],
|
|
574
|
+
{
|
|
575
|
+
commitMessage: `patch: install eslint.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
576
|
+
cwd: this.packageDir,
|
|
577
|
+
},
|
|
578
|
+
'Did not commit install eslint.config.js changes!'
|
|
579
|
+
)
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
@test()
|
|
583
|
+
protected static async thenInstallsPrettierConfigFile() {
|
|
584
|
+
this.setShouldInstallDevDeps()
|
|
585
|
+
await this.run()
|
|
586
|
+
|
|
587
|
+
assert.isEqualDeep(
|
|
588
|
+
callsToWriteFile[6],
|
|
589
|
+
{
|
|
590
|
+
file: this.prettierConfigPath,
|
|
591
|
+
data: this.prettierConfigFile,
|
|
592
|
+
options: { encoding: 'utf-8' },
|
|
593
|
+
},
|
|
594
|
+
'Did not install prettier.config.js!'
|
|
595
|
+
)
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
@test()
|
|
599
|
+
protected static async thenCommitsInstallPrettierConfigFile() {
|
|
600
|
+
this.setShouldInstallDevDeps()
|
|
601
|
+
await this.run()
|
|
602
|
+
|
|
603
|
+
assert.isEqualDeep(
|
|
604
|
+
FakeAutocommit.callsToConstructor[9],
|
|
605
|
+
{
|
|
606
|
+
commitMessage: `patch: install prettier.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
607
|
+
cwd: this.packageDir,
|
|
608
|
+
},
|
|
609
|
+
'Did not commit install prettier.config.js changes!'
|
|
610
|
+
)
|
|
611
|
+
}
|
|
612
|
+
|
|
482
613
|
@test()
|
|
483
614
|
protected static async lastlyOpensVscodeAtEnd() {
|
|
484
615
|
await this.run()
|
|
485
616
|
|
|
486
617
|
assert.isEqualDeep(
|
|
487
|
-
callsToExec[
|
|
618
|
+
callsToExec[10],
|
|
488
619
|
{ command: 'code .', options: { cwd: this.packageDir } },
|
|
489
620
|
'Did not open vscode at end!'
|
|
490
621
|
)
|
|
@@ -496,7 +627,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
496
627
|
stdout: '0.0.1',
|
|
497
628
|
} as unknown as ChildProcess)
|
|
498
629
|
|
|
499
|
-
await this.
|
|
630
|
+
await this.runTwice()
|
|
500
631
|
|
|
501
632
|
const calls = callsToExec.filter(
|
|
502
633
|
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
@@ -514,15 +645,46 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
514
645
|
|
|
515
646
|
@test()
|
|
516
647
|
protected static async installsDevDependenciesIfNodeTddNotLatest() {
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
} as unknown as ChildProcess)
|
|
648
|
+
this.setShouldInstallDevDeps()
|
|
649
|
+
await this.runTwice()
|
|
520
650
|
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
651
|
+
const calls = callsToExec.filter(
|
|
652
|
+
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
653
|
+
)
|
|
654
|
+
|
|
655
|
+
assert.isEqualDeep(
|
|
656
|
+
calls[0],
|
|
657
|
+
{
|
|
658
|
+
command: this.yarnInstallDevDepsCommand,
|
|
659
|
+
options: { cwd: this.packageDir },
|
|
660
|
+
},
|
|
661
|
+
'Should install default devDependencies if not already installed!'
|
|
662
|
+
)
|
|
663
|
+
}
|
|
524
664
|
|
|
525
|
-
|
|
665
|
+
@test()
|
|
666
|
+
protected static async installsDevDependenciesIfEslintConfigNdxNotLatest() {
|
|
667
|
+
this.setShouldInstallDevDeps()
|
|
668
|
+
await this.runTwice()
|
|
669
|
+
|
|
670
|
+
const calls = callsToExec.filter(
|
|
671
|
+
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
672
|
+
)
|
|
673
|
+
|
|
674
|
+
assert.isEqualDeep(
|
|
675
|
+
calls[0],
|
|
676
|
+
{
|
|
677
|
+
command: this.yarnInstallDevDepsCommand,
|
|
678
|
+
options: { cwd: this.packageDir },
|
|
679
|
+
},
|
|
680
|
+
'Should install default devDependencies if not already installed!'
|
|
681
|
+
)
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
@test()
|
|
685
|
+
protected static async installsDevDependenciesIfPrettierConfigNdxNotLatest() {
|
|
686
|
+
this.setShouldInstallDevDeps()
|
|
687
|
+
await this.runTwice()
|
|
526
688
|
|
|
527
689
|
const calls = callsToExec.filter(
|
|
528
690
|
(call) => call?.command === this.yarnInstallDevDepsCommand
|
|
@@ -557,25 +719,18 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
557
719
|
|
|
558
720
|
@test()
|
|
559
721
|
protected static async doesNotCreateRepoInGithubOrgIfDone() {
|
|
560
|
-
|
|
561
|
-
status: 200,
|
|
562
|
-
statusText: 'OK',
|
|
563
|
-
})
|
|
564
|
-
|
|
565
|
-
setFakeFetchResponse(this.reposUrl, fakeResponse)
|
|
566
|
-
|
|
567
|
-
await this.createAndRunAutopackage()
|
|
722
|
+
await this.runTwice()
|
|
568
723
|
|
|
569
724
|
const numCalls = callsToFetch.filter(
|
|
570
725
|
(call) => call.input === this.orgsUrl
|
|
571
726
|
).length
|
|
572
727
|
|
|
573
|
-
assert.isEqual(numCalls,
|
|
728
|
+
assert.isEqual(numCalls, 1, 'Should have created repo once!')
|
|
574
729
|
}
|
|
575
730
|
|
|
576
731
|
@test()
|
|
577
732
|
protected static async doesNotCloneRepoIfDone() {
|
|
578
|
-
await this.
|
|
733
|
+
await this.runTwice()
|
|
579
734
|
|
|
580
735
|
assert.isEqual(
|
|
581
736
|
callsToExec.filter(
|
|
@@ -590,7 +745,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
590
745
|
|
|
591
746
|
@test()
|
|
592
747
|
protected static async doesNotSpruceCreateModuleIfDone() {
|
|
593
|
-
await this.
|
|
748
|
+
await this.runTwice()
|
|
594
749
|
|
|
595
750
|
assert.isEqual(
|
|
596
751
|
callsToExec.filter((call) => call?.command === this.createModuleCmd)
|
|
@@ -602,7 +757,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
602
757
|
|
|
603
758
|
@test()
|
|
604
759
|
protected static async doesNotRunSetupVscodeIfDone() {
|
|
605
|
-
await this.
|
|
760
|
+
await this.runTwice()
|
|
606
761
|
|
|
607
762
|
assert.isEqual(
|
|
608
763
|
callsToExec.filter((call) => call?.command === this.setupVscodeCmd)
|
|
@@ -614,7 +769,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
614
769
|
|
|
615
770
|
@test()
|
|
616
771
|
protected static async doesNotCommitCreatePackageIfDone() {
|
|
617
|
-
await this.
|
|
772
|
+
await this.runTwice()
|
|
618
773
|
|
|
619
774
|
assert.isEqual(
|
|
620
775
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -629,7 +784,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
629
784
|
|
|
630
785
|
@test()
|
|
631
786
|
protected static async doesNotCommitUpdatePackageIfDone() {
|
|
632
|
-
await this.
|
|
787
|
+
await this.runTwice()
|
|
633
788
|
|
|
634
789
|
assert.isEqual(
|
|
635
790
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -644,7 +799,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
644
799
|
|
|
645
800
|
@test()
|
|
646
801
|
protected static async doesNotCommitUpdateGitignoreIfDone() {
|
|
647
|
-
await this.
|
|
802
|
+
await this.runTwice()
|
|
648
803
|
|
|
649
804
|
assert.isEqual(
|
|
650
805
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -657,9 +812,24 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
657
812
|
)
|
|
658
813
|
}
|
|
659
814
|
|
|
815
|
+
@test()
|
|
816
|
+
protected static async doesNotCommitUpdateTsconfigIfDone() {
|
|
817
|
+
await this.runTwice()
|
|
818
|
+
|
|
819
|
+
assert.isEqual(
|
|
820
|
+
FakeAutocommit.callsToConstructor.filter(
|
|
821
|
+
(call) =>
|
|
822
|
+
call?.commitMessage ===
|
|
823
|
+
`patch: update tsconfig (@neurodevs/meta-node: ${this.metaNodeVersion})`
|
|
824
|
+
).length,
|
|
825
|
+
1,
|
|
826
|
+
'Did not commit tsconfig changes once!'
|
|
827
|
+
)
|
|
828
|
+
}
|
|
829
|
+
|
|
660
830
|
@test()
|
|
661
831
|
protected static async doesNotCommitSetupVscodeIfDone() {
|
|
662
|
-
await this.
|
|
832
|
+
await this.runTwice()
|
|
663
833
|
|
|
664
834
|
assert.isEqual(
|
|
665
835
|
FakeAutocommit.callsToConstructor.filter(
|
|
@@ -674,7 +844,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
674
844
|
|
|
675
845
|
@test()
|
|
676
846
|
protected static async doesNotOverrideOriginalDependencies() {
|
|
677
|
-
await this.
|
|
847
|
+
await this.runTwice()
|
|
678
848
|
|
|
679
849
|
assert.isEqualDeep(
|
|
680
850
|
JSON.parse(callsToWriteFile[0]?.data).dependencies,
|
|
@@ -685,14 +855,12 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
685
855
|
|
|
686
856
|
@test()
|
|
687
857
|
protected static async doesNotUpdateTasksJsonIfAlreadyDone() {
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
await this.createAndRunAutopackage()
|
|
858
|
+
await this.runTwice()
|
|
691
859
|
|
|
692
860
|
assert.isEqualDeep(
|
|
693
861
|
callsToWriteFile.filter((call) => call.file === this.tasksJsonPath)
|
|
694
862
|
.length,
|
|
695
|
-
|
|
863
|
+
1,
|
|
696
864
|
'Did not update tasks.json once!'
|
|
697
865
|
)
|
|
698
866
|
}
|
|
@@ -701,7 +869,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
701
869
|
protected static async doesNotOpenVscodeIfNotCloned() {
|
|
702
870
|
setPathShouldExist(this.packageDir, true)
|
|
703
871
|
|
|
704
|
-
await this.
|
|
872
|
+
await this.run()
|
|
705
873
|
|
|
706
874
|
assert.isFalse(
|
|
707
875
|
callsToExec.some((call) => call?.command === 'code .'),
|
|
@@ -716,14 +884,14 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
716
884
|
this.originalPackageJson.replace('@neurodevs/generate-id', '')
|
|
717
885
|
)
|
|
718
886
|
|
|
719
|
-
await this.
|
|
887
|
+
await this.runTwice()
|
|
720
888
|
}
|
|
721
889
|
|
|
722
890
|
@test()
|
|
723
891
|
protected static async doesNotInstallAbstractPackageTestIfTsExists() {
|
|
724
892
|
setPathShouldExist(this.abstractTestPath, true)
|
|
725
893
|
|
|
726
|
-
await this.
|
|
894
|
+
await this.run()
|
|
727
895
|
|
|
728
896
|
const calls = callsToWriteFile.filter(
|
|
729
897
|
(call) => call.file === this.abstractTestPath
|
|
@@ -740,7 +908,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
740
908
|
protected static async doesNotInstallAbstractPackageTestIfTsxExists() {
|
|
741
909
|
setPathShouldExist(`${this.abstractTestPath}x`, true)
|
|
742
910
|
|
|
743
|
-
await this.
|
|
911
|
+
await this.run()
|
|
744
912
|
|
|
745
913
|
const calls = callsToWriteFile.filter(
|
|
746
914
|
(call) => call.file === this.abstractTestPath
|
|
@@ -753,13 +921,75 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
753
921
|
)
|
|
754
922
|
}
|
|
755
923
|
|
|
924
|
+
@test()
|
|
925
|
+
protected static async doesNotInstallEslintConfigFileIfExists() {
|
|
926
|
+
setPathShouldExist(this.eslintConfigPath, true)
|
|
927
|
+
|
|
928
|
+
await this.run()
|
|
929
|
+
|
|
930
|
+
const calls = callsToWriteFile.filter(
|
|
931
|
+
(call) => call.file === this.eslintConfigPath
|
|
932
|
+
)
|
|
933
|
+
|
|
934
|
+
assert.isEqual(
|
|
935
|
+
calls.length,
|
|
936
|
+
0,
|
|
937
|
+
'Should not install eslint.config.js if already exists!'
|
|
938
|
+
)
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
@test()
|
|
942
|
+
protected static async doesNotInstallPrettierConfigFileIfExists() {
|
|
943
|
+
setPathShouldExist(this.prettierConfigPath, true)
|
|
944
|
+
|
|
945
|
+
await this.run()
|
|
946
|
+
|
|
947
|
+
const calls = callsToWriteFile.filter(
|
|
948
|
+
(call) => call.file === this.prettierConfigPath
|
|
949
|
+
)
|
|
950
|
+
|
|
951
|
+
assert.isEqual(
|
|
952
|
+
calls.length,
|
|
953
|
+
0,
|
|
954
|
+
'Should not install prettier.config.js if already exists!'
|
|
955
|
+
)
|
|
956
|
+
}
|
|
957
|
+
|
|
756
958
|
private static async run() {
|
|
757
959
|
await this.instance.run()
|
|
758
960
|
}
|
|
759
961
|
|
|
760
|
-
private static async
|
|
761
|
-
|
|
762
|
-
|
|
962
|
+
private static async runTwice() {
|
|
963
|
+
await this.run()
|
|
964
|
+
|
|
965
|
+
setPathShouldExist(this.packageDir, true)
|
|
966
|
+
setPathShouldExist(this.packageJsonPath, true)
|
|
967
|
+
setPathShouldExist(this.abstractTestPath, true)
|
|
968
|
+
setPathShouldExist(this.tasksJsonPath, true)
|
|
969
|
+
|
|
970
|
+
setFakeReadFileResult(this.packageJsonPath, this.updatedPackageJson)
|
|
971
|
+
setFakeReadFileResult(this.gitignorePath, this.updatedGitignore)
|
|
972
|
+
setFakeReadFileResult(this.tasksJsonPath, this.updatedTasksJson)
|
|
973
|
+
|
|
974
|
+
setFakeReadFileResult(
|
|
975
|
+
this.tsconfigPath,
|
|
976
|
+
JSON.stringify(this.updatedTsconfig)
|
|
977
|
+
)
|
|
978
|
+
|
|
979
|
+
const fakeResponse = new Response(null, {
|
|
980
|
+
status: 200,
|
|
981
|
+
statusText: 'OK',
|
|
982
|
+
})
|
|
983
|
+
|
|
984
|
+
setFakeFetchResponse(this.reposUrl, fakeResponse)
|
|
985
|
+
|
|
986
|
+
await this.run()
|
|
987
|
+
}
|
|
988
|
+
|
|
989
|
+
private static setShouldInstallDevDeps() {
|
|
990
|
+
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
991
|
+
stdout: '0.0.1',
|
|
992
|
+
} as unknown as ChildProcess)
|
|
763
993
|
}
|
|
764
994
|
|
|
765
995
|
private static get scopedPackageName() {
|
|
@@ -798,6 +1028,22 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
798
1028
|
resetCallsToExec()
|
|
799
1029
|
|
|
800
1030
|
this.setFakeMetaNodeVersion()
|
|
1031
|
+
|
|
1032
|
+
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
1033
|
+
stdout: '1.0.0',
|
|
1034
|
+
} as unknown as ChildProcess)
|
|
1035
|
+
|
|
1036
|
+
setFakeExecResult(this.checkNodeTddVersionCmd, {
|
|
1037
|
+
stdout: '1.0.0',
|
|
1038
|
+
} as unknown as ChildProcess)
|
|
1039
|
+
|
|
1040
|
+
setFakeExecResult(this.checkEslintConfigNdxVersionCmd, {
|
|
1041
|
+
stdout: '1.0.0',
|
|
1042
|
+
} as unknown as ChildProcess)
|
|
1043
|
+
|
|
1044
|
+
setFakeExecResult(this.checkPrettierConfigNdxVersionCmd, {
|
|
1045
|
+
stdout: '1.0.0',
|
|
1046
|
+
} as unknown as ChildProcess)
|
|
801
1047
|
}
|
|
802
1048
|
|
|
803
1049
|
private static fakeFetch() {
|
|
@@ -814,6 +1060,9 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
814
1060
|
NpmAutopackage.pathExists = fakePathExists
|
|
815
1061
|
resetCallsToPathExists()
|
|
816
1062
|
|
|
1063
|
+
setPathShouldExist(this.packageDir, false)
|
|
1064
|
+
setPathShouldExist(this.packageJsonPath, false)
|
|
1065
|
+
setPathShouldExist(this.tasksJsonPath, false)
|
|
817
1066
|
setPathShouldExist(this.abstractTestPath, false)
|
|
818
1067
|
}
|
|
819
1068
|
|
|
@@ -827,6 +1076,13 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
827
1076
|
this.tasksJsonPath,
|
|
828
1077
|
JSON.stringify(this.originalTasksJson)
|
|
829
1078
|
)
|
|
1079
|
+
|
|
1080
|
+
setFakeReadFileResult(
|
|
1081
|
+
this.tsconfigPath,
|
|
1082
|
+
JSON.stringify(this.originalTsconfig)
|
|
1083
|
+
)
|
|
1084
|
+
|
|
1085
|
+
setFakeReadFileResult(this.gitignorePath, this.originalGitignore)
|
|
830
1086
|
}
|
|
831
1087
|
|
|
832
1088
|
private static fakeWriteFile() {
|
|
@@ -864,6 +1120,8 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
864
1120
|
devDependencies: {
|
|
865
1121
|
'@neurodevs/generate-id': '^1.0.0',
|
|
866
1122
|
'@neurodevs/node-tdd': '^1.0.0',
|
|
1123
|
+
'@neurodevs/eslint-config-ndx': '^1.0.0',
|
|
1124
|
+
'@neurodevs/prettier-config-ndx': '^1.0.0',
|
|
867
1125
|
},
|
|
868
1126
|
})
|
|
869
1127
|
}
|
|
@@ -873,6 +1131,7 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
873
1131
|
...JSON.parse(this.originalPackageJson),
|
|
874
1132
|
name: this.scopedPackageName,
|
|
875
1133
|
description: this.description,
|
|
1134
|
+
type: 'module',
|
|
876
1135
|
keywords: this.keywords,
|
|
877
1136
|
license: this.license,
|
|
878
1137
|
author: this.author,
|
|
@@ -889,6 +1148,46 @@ export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
|
889
1148
|
})
|
|
890
1149
|
}
|
|
891
1150
|
|
|
1151
|
+
private static get originalTsconfig(): TsConfig {
|
|
1152
|
+
return {
|
|
1153
|
+
compilerOptions: {
|
|
1154
|
+
lib: [this.customLib],
|
|
1155
|
+
types: [this.customType],
|
|
1156
|
+
},
|
|
1157
|
+
include: [this.customInclude],
|
|
1158
|
+
customOption: this.customOption,
|
|
1159
|
+
}
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
private static get updatedTsconfig() {
|
|
1163
|
+
return {
|
|
1164
|
+
...this.originalTsconfig,
|
|
1165
|
+
compilerOptions: {
|
|
1166
|
+
module: 'nodenext',
|
|
1167
|
+
moduleResolution: 'nodenext',
|
|
1168
|
+
target: 'ES2022',
|
|
1169
|
+
lib: [this.customLib, 'ES2022'],
|
|
1170
|
+
types: [this.customType, 'node'],
|
|
1171
|
+
baseUrl: 'src',
|
|
1172
|
+
outDir: 'build',
|
|
1173
|
+
sourceMap: false,
|
|
1174
|
+
strict: true,
|
|
1175
|
+
noImplicitAny: true,
|
|
1176
|
+
noImplicitReturns: true,
|
|
1177
|
+
noUnusedLocals: true,
|
|
1178
|
+
forceConsistentCasingInFileNames: true,
|
|
1179
|
+
declaration: true,
|
|
1180
|
+
skipLibCheck: true,
|
|
1181
|
+
esModuleInterop: true,
|
|
1182
|
+
moduleDetection: 'force',
|
|
1183
|
+
allowJs: true,
|
|
1184
|
+
resolveJsonModule: true,
|
|
1185
|
+
experimentalDecorators: true,
|
|
1186
|
+
},
|
|
1187
|
+
include: [this.customInclude, './src/*.ts', './src/**/*.ts'],
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
|
|
892
1191
|
private static originalTasksJson = {
|
|
893
1192
|
[this.randomId]: this.randomId,
|
|
894
1193
|
tasks: [
|