@neurodevs/meta-node 0.19.16 → 0.19.19
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 +53 -58
- package/.vscode/settings.json +62 -66
- package/.vscode/tasks.json +123 -129
- package/README.md +1 -0
- package/build/.spruce/settings.json +3 -7
- package/build/__tests__/AbstractAutomoduleTest.js +2 -1
- package/build/__tests__/AbstractAutomoduleTest.js.map +1 -1
- package/build/__tests__/impl/NpmAutopackage.test.d.ts +10 -2
- package/build/__tests__/impl/NpmAutopackage.test.js +126 -19
- package/build/__tests__/impl/NpmAutopackage.test.js.map +1 -1
- package/build/impl/NpmAutopackage.d.ts +4 -0
- package/build/impl/NpmAutopackage.js +76 -3
- package/build/impl/NpmAutopackage.js.map +1 -1
- package/package.json +2 -2
- package/src/.spruce/settings.json +3 -7
- package/src/__tests__/AbstractAutomoduleTest.ts +2 -1
- package/src/__tests__/impl/NpmAutopackage.test.ts +183 -41
- package/src/impl/NpmAutopackage.ts +114 -15
- package/tsconfig.json +24 -27
|
@@ -365,10 +365,13 @@ export default prettierConfigNdx
|
|
|
365
365
|
}
|
|
366
366
|
|
|
367
367
|
private async updatePackageJsonFile() {
|
|
368
|
+
this.removeOldKeysFromPackageJson()
|
|
369
|
+
|
|
368
370
|
const ordered = this.orderJsonKeys(this.updatedPackageJson, [
|
|
369
371
|
'name',
|
|
370
372
|
'version',
|
|
371
373
|
'description',
|
|
374
|
+
'type',
|
|
372
375
|
'keywords',
|
|
373
376
|
'license',
|
|
374
377
|
'author',
|
|
@@ -382,7 +385,6 @@ export default prettierConfigNdx
|
|
|
382
385
|
'dependencies',
|
|
383
386
|
'devDependencies',
|
|
384
387
|
'jest',
|
|
385
|
-
'skill',
|
|
386
388
|
])
|
|
387
389
|
|
|
388
390
|
await this.writeFile(
|
|
@@ -392,6 +394,42 @@ export default prettierConfigNdx
|
|
|
392
394
|
)
|
|
393
395
|
}
|
|
394
396
|
|
|
397
|
+
private removeOldKeysFromPackageJson() {
|
|
398
|
+
const keysToRemove = [
|
|
399
|
+
'skill',
|
|
400
|
+
'jest.testPathIgnorePatterns',
|
|
401
|
+
'jest.moduleNameMapper',
|
|
402
|
+
'scripts.build.resolve-paths',
|
|
403
|
+
'scripts.lint.tsc',
|
|
404
|
+
'scripts.post.watch.build',
|
|
405
|
+
'scripts.resolve-paths.lint',
|
|
406
|
+
'scripts.watch.rebuild',
|
|
407
|
+
'scripts.watch.tsc',
|
|
408
|
+
]
|
|
409
|
+
|
|
410
|
+
for (const key of keysToRemove) {
|
|
411
|
+
this.deleteByPath(this.originalPackageJson, key)
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
private deleteByPath(obj: any, path: string): void {
|
|
416
|
+
const dot = path.indexOf('.')
|
|
417
|
+
|
|
418
|
+
if (dot === -1) {
|
|
419
|
+
delete obj[path]
|
|
420
|
+
return
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
const parentKey = path.slice(0, dot)
|
|
424
|
+
const childKey = path.slice(dot + 1)
|
|
425
|
+
|
|
426
|
+
const parent = obj[parentKey]
|
|
427
|
+
|
|
428
|
+
if (parent) {
|
|
429
|
+
delete parent[childKey]
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
|
|
395
433
|
private get updatedPackageJson() {
|
|
396
434
|
return {
|
|
397
435
|
...this.originalPackageJson,
|
|
@@ -410,7 +448,38 @@ export default prettierConfigNdx
|
|
|
410
448
|
bugs: {
|
|
411
449
|
url: `https://github.com/${this.gitNamespace}/${this.packageName}/issues`,
|
|
412
450
|
},
|
|
451
|
+
scripts: {
|
|
452
|
+
...(this.originalPackageJson.scripts ?? {}),
|
|
453
|
+
'build.ci': 'yarn run build.tsc && yarn run lint',
|
|
454
|
+
'build.dev':
|
|
455
|
+
'yarn run build.tsc --sourceMap ; yarn run lint ; prettier --write .',
|
|
456
|
+
'build.copy-files':
|
|
457
|
+
"mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
|
|
458
|
+
'build.tsc': 'yarn run build.copy-files && tsc',
|
|
459
|
+
clean: 'yarn run clean.build',
|
|
460
|
+
'clean.all':
|
|
461
|
+
'yarn run clean.dependencies && yarn run clean.build',
|
|
462
|
+
'clean.build': 'rm -rf build/',
|
|
463
|
+
'clean.dependencies':
|
|
464
|
+
'rm -rf node_modules/ package-lock.json yarn.lock',
|
|
465
|
+
'fix.lint': "eslint --fix --cache '**/*.ts'",
|
|
466
|
+
lint: "eslint --cache '**/*.ts'",
|
|
467
|
+
rebuild:
|
|
468
|
+
'yarn run clean.all && yarn install && yarn run build.dev',
|
|
469
|
+
'update.dependencies': 'yarn run clean.dependencies && yarn',
|
|
470
|
+
test: 'NODE_OPTIONS=--experimental-vm-modules jest',
|
|
471
|
+
'watch.build.dev':
|
|
472
|
+
"tsc-watch --sourceMap --onCompilationComplete 'yarn run build.copy-files'",
|
|
473
|
+
},
|
|
413
474
|
dependencies: this.originalPackageJson.dependencies ?? {},
|
|
475
|
+
jest: {
|
|
476
|
+
...(this.originalPackageJson.jest ?? {}),
|
|
477
|
+
testEnvironment: 'node',
|
|
478
|
+
testRunner: 'jest-circus/runner',
|
|
479
|
+
testMatch: ['<rootDir>/build/__tests__/**/*.test.js?(x)'],
|
|
480
|
+
testTimeout: 5000,
|
|
481
|
+
maxWorkers: 4,
|
|
482
|
+
},
|
|
414
483
|
}
|
|
415
484
|
}
|
|
416
485
|
|
|
@@ -681,6 +750,8 @@ export default prettierConfigNdx
|
|
|
681
750
|
}
|
|
682
751
|
|
|
683
752
|
private async installDefaultDevDependencies() {
|
|
753
|
+
await this.removeDefaultDevDependencies()
|
|
754
|
+
|
|
684
755
|
const generateIdVersion = await this.getLatestVersion(
|
|
685
756
|
'@neurodevs/generate-id'
|
|
686
757
|
)
|
|
@@ -706,13 +777,38 @@ export default prettierConfigNdx
|
|
|
706
777
|
console.log('Installing default devDependencies...')
|
|
707
778
|
|
|
708
779
|
await this.exec(
|
|
709
|
-
'yarn add -D @neurodevs/generate-id @neurodevs/node-tdd @neurodevs/eslint-config-ndx @neurodevs/prettier-config-ndx',
|
|
780
|
+
'yarn add -D @neurodevs/generate-id @neurodevs/node-tdd @neurodevs/eslint-config-ndx @neurodevs/prettier-config-ndx prettier',
|
|
710
781
|
{ cwd: this.packageDir }
|
|
711
782
|
)
|
|
712
783
|
await this.commitInstallDevDependencies()
|
|
713
784
|
}
|
|
714
785
|
}
|
|
715
786
|
|
|
787
|
+
private async removeDefaultDevDependencies() {
|
|
788
|
+
if (this.hasOldDevDependency) {
|
|
789
|
+
console.log('Removing default devDependencies...')
|
|
790
|
+
|
|
791
|
+
await this.exec(
|
|
792
|
+
'yarn remove eslint eslint-config-spruce prettier chokidar-cli ts-node @types/node',
|
|
793
|
+
{ cwd: this.packageDir }
|
|
794
|
+
)
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
private get hasOldDevDependency() {
|
|
799
|
+
return Object.keys(this.originalPackageJson.devDependencies!).some(
|
|
800
|
+
(dep) =>
|
|
801
|
+
[
|
|
802
|
+
'eslint',
|
|
803
|
+
'eslint-config-spruce',
|
|
804
|
+
'prettier',
|
|
805
|
+
'chokidar-cli',
|
|
806
|
+
'ts-node',
|
|
807
|
+
'@types/node',
|
|
808
|
+
].includes(dep)
|
|
809
|
+
)
|
|
810
|
+
}
|
|
811
|
+
|
|
716
812
|
private async getLatestVersion(scopedPackageName: string) {
|
|
717
813
|
const { stdout } = await this.exec(
|
|
718
814
|
`yarn info ${scopedPackageName} version --silent`,
|
|
@@ -831,7 +927,7 @@ export default prettierConfigNdx
|
|
|
831
927
|
return ''
|
|
832
928
|
}
|
|
833
929
|
}
|
|
834
|
-
|
|
930
|
+
|
|
835
931
|
private get eslintConfigIsUpToDate() {
|
|
836
932
|
return this.originalEslintConfig.trim() === this.eslintConfigFile.trim()
|
|
837
933
|
}
|
|
@@ -848,9 +944,13 @@ export default prettierConfigNdx
|
|
|
848
944
|
if (!this.prettierConfigIsUpToDate) {
|
|
849
945
|
console.log('Installing prettier.config.js...')
|
|
850
946
|
|
|
851
|
-
await this.writeFile(
|
|
852
|
-
|
|
853
|
-
|
|
947
|
+
await this.writeFile(
|
|
948
|
+
this.prettierConfigPath,
|
|
949
|
+
this.prettierConfigFile,
|
|
950
|
+
{
|
|
951
|
+
encoding: 'utf-8',
|
|
952
|
+
}
|
|
953
|
+
)
|
|
854
954
|
|
|
855
955
|
await this.commitInstallPrettierConfigFile()
|
|
856
956
|
}
|
|
@@ -867,7 +967,10 @@ export default prettierConfigNdx
|
|
|
867
967
|
}
|
|
868
968
|
|
|
869
969
|
private get prettierConfigIsUpToDate() {
|
|
870
|
-
return
|
|
970
|
+
return (
|
|
971
|
+
this.originalPrettierConfig.trim() ===
|
|
972
|
+
this.prettierConfigFile.trim()
|
|
973
|
+
)
|
|
871
974
|
}
|
|
872
975
|
|
|
873
976
|
private async commitInstallPrettierConfigFile() {
|
|
@@ -882,14 +985,10 @@ export default prettierConfigNdx
|
|
|
882
985
|
if (!this.settingsJsonIsUpToDate) {
|
|
883
986
|
console.log('Installing .vscode/settings.json...')
|
|
884
987
|
|
|
885
|
-
await this.writeFile(
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
encoding: 'utf-8',
|
|
890
|
-
}
|
|
891
|
-
)
|
|
892
|
-
|
|
988
|
+
await this.writeFile(this.settingsJsonPath, this.settingsJsonFile, {
|
|
989
|
+
encoding: 'utf-8',
|
|
990
|
+
})
|
|
991
|
+
|
|
893
992
|
await this.commitInstallSettingsJsonFile()
|
|
894
993
|
}
|
|
895
994
|
}
|
package/tsconfig.json
CHANGED
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"./src/**/*.ts"
|
|
27
|
-
]
|
|
28
|
-
}
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"module": "nodenext",
|
|
4
|
+
"moduleResolution": "nodenext",
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"lib": ["ES2022"],
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
"baseUrl": "src",
|
|
9
|
+
"outDir": "build",
|
|
10
|
+
"sourceMap": false,
|
|
11
|
+
"strict": true,
|
|
12
|
+
"noImplicitAny": true,
|
|
13
|
+
"noImplicitReturns": true,
|
|
14
|
+
"noUnusedLocals": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"declaration": true,
|
|
17
|
+
"skipLibCheck": true,
|
|
18
|
+
"esModuleInterop": true,
|
|
19
|
+
"moduleDetection": "force",
|
|
20
|
+
"allowJs": true,
|
|
21
|
+
"resolveJsonModule": true,
|
|
22
|
+
"experimentalDecorators": true
|
|
23
|
+
},
|
|
24
|
+
"include": ["./src/*.ts", "./src/**/*.ts"]
|
|
25
|
+
}
|