@neurodevs/meta-node 0.19.15 → 0.19.16
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/build/__tests__/AbstractAutomoduleTest.js +0 -3
- package/build/__tests__/AbstractAutomoduleTest.js.map +1 -1
- package/build/__tests__/AbstractPackageTest.d.ts +2 -0
- package/build/__tests__/AbstractPackageTest.js +4 -1
- package/build/__tests__/AbstractPackageTest.js.map +1 -1
- package/build/__tests__/impl/GitAutocloner.test.js +0 -3
- package/build/__tests__/impl/GitAutocloner.test.js.map +1 -1
- package/build/__tests__/impl/GitAutocommit.test.d.ts +2 -2
- package/build/__tests__/impl/GitAutocommit.test.js +3 -5
- package/build/__tests__/impl/GitAutocommit.test.js.map +1 -1
- package/build/__tests__/impl/NpmAutopackage.test.d.ts +9 -2
- package/build/__tests__/impl/NpmAutopackage.test.js +125 -12
- package/build/__tests__/impl/NpmAutopackage.test.js.map +1 -1
- package/build/__tests__/impl/NpmReleasePropagator.test.js +1 -4
- package/build/__tests__/impl/NpmReleasePropagator.test.js.map +1 -1
- package/build/__tests__/impl/NpmWorkspaceTypeChecker.test.js +0 -3
- package/build/__tests__/impl/NpmWorkspaceTypeChecker.test.js.map +1 -1
- package/build/impl/NpmAutopackage.d.ts +16 -1
- package/build/impl/NpmAutopackage.js +132 -13
- package/build/impl/NpmAutopackage.js.map +1 -1
- package/eslint.config.js +3 -0
- package/package.json +6 -4
- package/prettier.config.js +3 -0
- package/src/__tests__/AbstractAutomoduleTest.ts +1 -5
- package/src/__tests__/AbstractPackageTest.ts +6 -2
- package/src/__tests__/impl/GitAutocloner.test.ts +2 -5
- package/src/__tests__/impl/GitAutocommit.test.ts +4 -8
- package/src/__tests__/impl/NpmAutopackage.test.ts +165 -11
- package/src/__tests__/impl/NpmReleasePropagator.test.ts +3 -6
- package/src/__tests__/impl/NpmWorkspaceTypeChecker.test.ts +1 -5
- package/src/impl/NpmAutopackage.ts +163 -20
- package/eslint.config.mjs +0 -3
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { ChildProcess
|
|
1
|
+
import { ChildProcess } from 'child_process'
|
|
2
2
|
import { readFile, writeFile } from 'fs/promises'
|
|
3
3
|
import { mkdir } from 'fs/promises'
|
|
4
4
|
import path from 'path'
|
|
5
|
-
import { promisify } from 'util'
|
|
6
5
|
import {
|
|
7
6
|
callsToExec,
|
|
8
7
|
callsToFetch,
|
|
@@ -21,9 +20,11 @@ import {
|
|
|
21
20
|
resetCallsToPathExists,
|
|
22
21
|
resetCallsToReadFile,
|
|
23
22
|
resetCallsToWriteFile,
|
|
23
|
+
resetFakeReadFileThrowsFor,
|
|
24
24
|
setFakeExecResult,
|
|
25
25
|
setFakeFetchResponse,
|
|
26
26
|
setFakeReadFileResult,
|
|
27
|
+
setFakeReadFileThrowsFor,
|
|
27
28
|
setPathShouldExist,
|
|
28
29
|
} from '@neurodevs/fake-node-core'
|
|
29
30
|
import { test, assert } from '@neurodevs/node-tdd'
|
|
@@ -37,8 +38,6 @@ import NpmAutopackage, {
|
|
|
37
38
|
import FakeAutocommit from '../../testDoubles/Autocommit/FakeAutocommit.js'
|
|
38
39
|
import AbstractPackageTest from '../AbstractPackageTest.js'
|
|
39
40
|
|
|
40
|
-
const exec = promisify(execSync)
|
|
41
|
-
|
|
42
41
|
export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
43
42
|
private static instance: Autopackage
|
|
44
43
|
|
|
@@ -108,6 +107,12 @@ export default class NpmAutopackageTest extends AbstractPackageTest {
|
|
|
108
107
|
'prettier.config.js'
|
|
109
108
|
)
|
|
110
109
|
|
|
110
|
+
private static readonly settingsJsonPath = path.join(
|
|
111
|
+
this.packageDir,
|
|
112
|
+
'.vscode',
|
|
113
|
+
'settings.json'
|
|
114
|
+
)
|
|
115
|
+
|
|
111
116
|
private static readonly customLib = this.generateId()
|
|
112
117
|
private static readonly customType = this.generateId()
|
|
113
118
|
private static readonly customInclude = this.generateId()
|
|
@@ -145,6 +150,71 @@ export default esConfigNdx
|
|
|
145
150
|
private static readonly prettierConfigFile = `import prettierConfigNdx from '@neurodevs/prettier-config-ndx'
|
|
146
151
|
|
|
147
152
|
export default prettierConfigNdx
|
|
153
|
+
`
|
|
154
|
+
|
|
155
|
+
private static readonly settingsJsonFile = `{
|
|
156
|
+
"debug.node.autoAttach": "on",
|
|
157
|
+
"git.ignoreLimitWarning": true,
|
|
158
|
+
"javascript.validate.enable": false,
|
|
159
|
+
"files.watcherExclude": {
|
|
160
|
+
"**/.git/objects/**": true,
|
|
161
|
+
"**/.git/subtree-cache/**": true,
|
|
162
|
+
"**/build/**": true,
|
|
163
|
+
"**/node_modules/**": true
|
|
164
|
+
},
|
|
165
|
+
"search.exclude": {
|
|
166
|
+
"**/build/**": true,
|
|
167
|
+
"**/node_modules/**": true,
|
|
168
|
+
"**/.next/**": true
|
|
169
|
+
},
|
|
170
|
+
"editor.codeActionsOnSave": {
|
|
171
|
+
"source.fixAll.eslint": "always"
|
|
172
|
+
},
|
|
173
|
+
"editor.formatOnSave": true,
|
|
174
|
+
"editor.formatOnSaveMode": "file",
|
|
175
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
176
|
+
"editor.maxTokenizationLineLength": 20000000,
|
|
177
|
+
"[javascript]": {
|
|
178
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
179
|
+
"editor.formatOnSave": true
|
|
180
|
+
},
|
|
181
|
+
"[javascriptreact]": {
|
|
182
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
183
|
+
"editor.formatOnSave": true
|
|
184
|
+
},
|
|
185
|
+
"[typescript]": {
|
|
186
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
187
|
+
"editor.formatOnSave": true
|
|
188
|
+
},
|
|
189
|
+
"[typescriptreact]": {
|
|
190
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
191
|
+
"editor.formatOnSave": true
|
|
192
|
+
},
|
|
193
|
+
"eslint.enable": true,
|
|
194
|
+
"eslint.useFlatConfig": true,
|
|
195
|
+
"eslint.validate": [
|
|
196
|
+
"javascript",
|
|
197
|
+
"javascriptreact",
|
|
198
|
+
"typescript",
|
|
199
|
+
"typescriptreact"
|
|
200
|
+
],
|
|
201
|
+
"eslint.workingDirectories": ["./"],
|
|
202
|
+
"debug.javascript.unmapMissingSources": true,
|
|
203
|
+
"javascript.preferences.importModuleSpecifier": "relative",
|
|
204
|
+
"typescript.preferences.importModuleSpecifier": "relative",
|
|
205
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
206
|
+
"typescript.validate.enable": true,
|
|
207
|
+
"cSpell.ignorePaths": [
|
|
208
|
+
"**/package-lock.json",
|
|
209
|
+
"**/node_modules/**",
|
|
210
|
+
"**/build/**",
|
|
211
|
+
"**/vscode-extension/**",
|
|
212
|
+
"**/.git/objects/**",
|
|
213
|
+
".vscode",
|
|
214
|
+
".spruce"
|
|
215
|
+
],
|
|
216
|
+
"cSpell.words": ["arkit", "autogenerated", "scrollable", "serializable"]
|
|
217
|
+
}
|
|
148
218
|
`
|
|
149
219
|
|
|
150
220
|
private static readonly defaultOptions = {
|
|
@@ -635,6 +705,37 @@ export default prettierConfigNdx
|
|
|
635
705
|
)
|
|
636
706
|
}
|
|
637
707
|
|
|
708
|
+
@test()
|
|
709
|
+
protected static async thenInstallsSettingsJsonFile() {
|
|
710
|
+
this.setShouldInstallDevDeps()
|
|
711
|
+
await this.run()
|
|
712
|
+
|
|
713
|
+
assert.isEqualDeep(
|
|
714
|
+
callsToWriteFile[7],
|
|
715
|
+
{
|
|
716
|
+
file: this.settingsJsonPath,
|
|
717
|
+
data: this.settingsJsonFile,
|
|
718
|
+
options: { encoding: 'utf-8' },
|
|
719
|
+
},
|
|
720
|
+
'Did not install settings.json!'
|
|
721
|
+
)
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
@test()
|
|
725
|
+
protected static async thenCommitsInstallSettingsJsonFile() {
|
|
726
|
+
this.setShouldInstallDevDeps()
|
|
727
|
+
await this.run()
|
|
728
|
+
|
|
729
|
+
assert.isEqualDeep(
|
|
730
|
+
FakeAutocommit.callsToConstructor[10],
|
|
731
|
+
{
|
|
732
|
+
commitMessage: `patch: install settings.json (@neurodevs/meta-node: ${this.metaNodeVersion})`,
|
|
733
|
+
cwd: this.packageDir,
|
|
734
|
+
},
|
|
735
|
+
'Did not commit install settings.json changes!'
|
|
736
|
+
)
|
|
737
|
+
}
|
|
738
|
+
|
|
638
739
|
@test()
|
|
639
740
|
protected static async lastlyOpensVscodeAtEnd() {
|
|
640
741
|
await this.run()
|
|
@@ -646,6 +747,40 @@ export default prettierConfigNdx
|
|
|
646
747
|
)
|
|
647
748
|
}
|
|
648
749
|
|
|
750
|
+
@test()
|
|
751
|
+
protected static async installsEslintConfigIfNotExists() {
|
|
752
|
+
setFakeReadFileThrowsFor(this.eslintConfigJsPath)
|
|
753
|
+
|
|
754
|
+
await this.run()
|
|
755
|
+
|
|
756
|
+
const calls = callsToWriteFile.filter(
|
|
757
|
+
(call) => call.file === this.eslintConfigJsPath
|
|
758
|
+
)
|
|
759
|
+
|
|
760
|
+
assert.isEqual(
|
|
761
|
+
calls.length,
|
|
762
|
+
1,
|
|
763
|
+
'Should install eslint.config.js if it does not exist!'
|
|
764
|
+
)
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
@test()
|
|
768
|
+
protected static async installsPrettierConfigIfNotExists() {
|
|
769
|
+
setFakeReadFileThrowsFor(this.prettierConfigPath)
|
|
770
|
+
|
|
771
|
+
await this.run()
|
|
772
|
+
|
|
773
|
+
const calls = callsToWriteFile.filter(
|
|
774
|
+
(call) => call.file === this.prettierConfigPath
|
|
775
|
+
)
|
|
776
|
+
|
|
777
|
+
assert.isEqual(
|
|
778
|
+
calls.length,
|
|
779
|
+
1,
|
|
780
|
+
'Should install prettier.config.js if it does not exist!'
|
|
781
|
+
)
|
|
782
|
+
}
|
|
783
|
+
|
|
649
784
|
@test()
|
|
650
785
|
protected static async installsDevDependenciesIfGenerateIdNotLatest() {
|
|
651
786
|
setFakeExecResult(this.checkGenerateIdVersionCmd, {
|
|
@@ -963,8 +1098,8 @@ export default prettierConfigNdx
|
|
|
963
1098
|
}
|
|
964
1099
|
|
|
965
1100
|
@test()
|
|
966
|
-
protected static async
|
|
967
|
-
|
|
1101
|
+
protected static async doesNotInstallEslintConfigFileIfContentsEqual() {
|
|
1102
|
+
setFakeReadFileResult(this.eslintConfigJsPath, this.eslintConfigFile)
|
|
968
1103
|
|
|
969
1104
|
await this.run()
|
|
970
1105
|
|
|
@@ -975,13 +1110,13 @@ export default prettierConfigNdx
|
|
|
975
1110
|
assert.isEqual(
|
|
976
1111
|
calls.length,
|
|
977
1112
|
0,
|
|
978
|
-
'Should not install eslint.config.js if
|
|
1113
|
+
'Should not install eslint.config.js if contents are equal!'
|
|
979
1114
|
)
|
|
980
1115
|
}
|
|
981
1116
|
|
|
982
1117
|
@test()
|
|
983
|
-
protected static async
|
|
984
|
-
|
|
1118
|
+
protected static async doesNotInstallPrettierConfigFileIfContentsEqual() {
|
|
1119
|
+
setFakeReadFileResult(this.prettierConfigPath, this.prettierConfigFile)
|
|
985
1120
|
|
|
986
1121
|
await this.run()
|
|
987
1122
|
|
|
@@ -992,7 +1127,24 @@ export default prettierConfigNdx
|
|
|
992
1127
|
assert.isEqual(
|
|
993
1128
|
calls.length,
|
|
994
1129
|
0,
|
|
995
|
-
'Should not install prettier.config.js if
|
|
1130
|
+
'Should not install prettier.config.js if contents are equal!'
|
|
1131
|
+
)
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
@test()
|
|
1135
|
+
protected static async doesNotInstallSettingsJsonFileIfContentsEqual() {
|
|
1136
|
+
setFakeReadFileResult(this.settingsJsonPath, this.settingsJsonFile)
|
|
1137
|
+
|
|
1138
|
+
await this.run()
|
|
1139
|
+
|
|
1140
|
+
const calls = callsToWriteFile.filter(
|
|
1141
|
+
(call) => call.file === this.settingsJsonPath
|
|
1142
|
+
)
|
|
1143
|
+
|
|
1144
|
+
assert.isEqual(
|
|
1145
|
+
calls.length,
|
|
1146
|
+
0,
|
|
1147
|
+
'Should not install settings.json if contents are equal!'
|
|
996
1148
|
)
|
|
997
1149
|
}
|
|
998
1150
|
|
|
@@ -1065,7 +1217,7 @@ export default prettierConfigNdx
|
|
|
1065
1217
|
}
|
|
1066
1218
|
|
|
1067
1219
|
private static fakeExec() {
|
|
1068
|
-
NpmAutopackage.exec = fakeExec as
|
|
1220
|
+
NpmAutopackage.exec = fakeExec as any
|
|
1069
1221
|
resetCallsToExec()
|
|
1070
1222
|
|
|
1071
1223
|
this.setFakeMetaNodeVersion()
|
|
@@ -1124,6 +1276,8 @@ export default prettierConfigNdx
|
|
|
1124
1276
|
)
|
|
1125
1277
|
|
|
1126
1278
|
setFakeReadFileResult(this.gitignorePath, this.originalGitignore)
|
|
1279
|
+
|
|
1280
|
+
resetFakeReadFileThrowsFor()
|
|
1127
1281
|
}
|
|
1128
1282
|
|
|
1129
1283
|
private static fakeWriteFile() {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { ChildProcess
|
|
1
|
+
import { ChildProcess } from 'node:child_process'
|
|
2
2
|
import { readFile } from 'node:fs/promises'
|
|
3
3
|
import { Readable } from 'node:stream'
|
|
4
|
-
import { promisify } from 'node:util'
|
|
5
4
|
import {
|
|
6
5
|
callsToExec,
|
|
7
6
|
fakeExec,
|
|
@@ -23,8 +22,6 @@ import NpmReleasePropagator, {
|
|
|
23
22
|
import { FakeAutocommit } from '../../index.js'
|
|
24
23
|
import AbstractPackageTest from '../AbstractPackageTest.js'
|
|
25
24
|
|
|
26
|
-
const exec = promisify(execSync)
|
|
27
|
-
|
|
28
25
|
export default class NpmReleasePropagatorTest extends AbstractPackageTest {
|
|
29
26
|
private static instance: ReleasePropagator
|
|
30
27
|
|
|
@@ -119,7 +116,7 @@ export default class NpmReleasePropagatorTest extends AbstractPackageTest {
|
|
|
119
116
|
|
|
120
117
|
try {
|
|
121
118
|
await this.run()
|
|
122
|
-
} catch (
|
|
119
|
+
} catch (_error) {
|
|
123
120
|
// Expected to throw
|
|
124
121
|
}
|
|
125
122
|
|
|
@@ -199,7 +196,7 @@ Please commit or stash these changes before running propagation!
|
|
|
199
196
|
}
|
|
200
197
|
|
|
201
198
|
private static setFakeExec() {
|
|
202
|
-
NpmReleasePropagator.exec = fakeExec as unknown as typeof exec
|
|
199
|
+
NpmReleasePropagator.exec = fakeExec as unknown as typeof this.exec
|
|
203
200
|
resetCallsToExec()
|
|
204
201
|
resetExecThrowsFor()
|
|
205
202
|
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { exec as execSync } from 'node:child_process'
|
|
2
1
|
import { readdir } from 'node:fs/promises'
|
|
3
|
-
import { promisify } from 'node:util'
|
|
4
2
|
|
|
5
3
|
import {
|
|
6
4
|
callsToExec,
|
|
@@ -16,8 +14,6 @@ import {
|
|
|
16
14
|
} from '@neurodevs/fake-node-core'
|
|
17
15
|
import { test, assert } from '@neurodevs/node-tdd'
|
|
18
16
|
|
|
19
|
-
const exec = promisify(execSync)
|
|
20
|
-
|
|
21
17
|
import NpmWorkspaceTypeChecker, {
|
|
22
18
|
WorkspaceTypeChecker,
|
|
23
19
|
} from '../../impl/NpmWorkspaceTypeChecker.js'
|
|
@@ -128,7 +124,7 @@ export default class NpmWorkspaceTypeCheckerTest extends AbstractPackageTest {
|
|
|
128
124
|
}
|
|
129
125
|
|
|
130
126
|
private static setFakeExec() {
|
|
131
|
-
NpmWorkspaceTypeChecker.exec = fakeExec as unknown as typeof exec
|
|
127
|
+
NpmWorkspaceTypeChecker.exec = fakeExec as unknown as typeof this.exec
|
|
132
128
|
resetCallsToExec()
|
|
133
129
|
}
|
|
134
130
|
|
|
@@ -29,6 +29,10 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
29
29
|
private originalTsconfig!: TsConfig
|
|
30
30
|
private metaNodeVersion!: string
|
|
31
31
|
|
|
32
|
+
private originalEslintConfig!: string
|
|
33
|
+
private originalPrettierConfig!: string
|
|
34
|
+
private originalSettingsJson!: string
|
|
35
|
+
|
|
32
36
|
private originalTasksJson!: {
|
|
33
37
|
tasks: unknown[]
|
|
34
38
|
inputs: unknown[]
|
|
@@ -46,6 +50,9 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
46
50
|
private readonly tasksJsonPath: string
|
|
47
51
|
private readonly testDirPath: string
|
|
48
52
|
private readonly abstractTestPath: string
|
|
53
|
+
private readonly eslintConfigPath: string
|
|
54
|
+
private readonly prettierConfigPath: string
|
|
55
|
+
private readonly settingsJsonPath: string
|
|
49
56
|
|
|
50
57
|
private readonly abstractPackageTestFile = `import AbstractModuleTest from '@neurodevs/node-tdd'
|
|
51
58
|
|
|
@@ -64,6 +71,71 @@ export default esConfigNdx
|
|
|
64
71
|
private readonly prettierConfigFile = `import prettierConfigNdx from '@neurodevs/prettier-config-ndx'
|
|
65
72
|
|
|
66
73
|
export default prettierConfigNdx
|
|
74
|
+
`
|
|
75
|
+
|
|
76
|
+
private readonly settingsJsonFile = `{
|
|
77
|
+
"debug.node.autoAttach": "on",
|
|
78
|
+
"git.ignoreLimitWarning": true,
|
|
79
|
+
"javascript.validate.enable": false,
|
|
80
|
+
"files.watcherExclude": {
|
|
81
|
+
"**/.git/objects/**": true,
|
|
82
|
+
"**/.git/subtree-cache/**": true,
|
|
83
|
+
"**/build/**": true,
|
|
84
|
+
"**/node_modules/**": true
|
|
85
|
+
},
|
|
86
|
+
"search.exclude": {
|
|
87
|
+
"**/build/**": true,
|
|
88
|
+
"**/node_modules/**": true,
|
|
89
|
+
"**/.next/**": true
|
|
90
|
+
},
|
|
91
|
+
"editor.codeActionsOnSave": {
|
|
92
|
+
"source.fixAll.eslint": "always"
|
|
93
|
+
},
|
|
94
|
+
"editor.formatOnSave": true,
|
|
95
|
+
"editor.formatOnSaveMode": "file",
|
|
96
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
97
|
+
"editor.maxTokenizationLineLength": 20000000,
|
|
98
|
+
"[javascript]": {
|
|
99
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
100
|
+
"editor.formatOnSave": true
|
|
101
|
+
},
|
|
102
|
+
"[javascriptreact]": {
|
|
103
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
104
|
+
"editor.formatOnSave": true
|
|
105
|
+
},
|
|
106
|
+
"[typescript]": {
|
|
107
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
108
|
+
"editor.formatOnSave": true
|
|
109
|
+
},
|
|
110
|
+
"[typescriptreact]": {
|
|
111
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
112
|
+
"editor.formatOnSave": true
|
|
113
|
+
},
|
|
114
|
+
"eslint.enable": true,
|
|
115
|
+
"eslint.useFlatConfig": true,
|
|
116
|
+
"eslint.validate": [
|
|
117
|
+
"javascript",
|
|
118
|
+
"javascriptreact",
|
|
119
|
+
"typescript",
|
|
120
|
+
"typescriptreact"
|
|
121
|
+
],
|
|
122
|
+
"eslint.workingDirectories": ["./"],
|
|
123
|
+
"debug.javascript.unmapMissingSources": true,
|
|
124
|
+
"javascript.preferences.importModuleSpecifier": "relative",
|
|
125
|
+
"typescript.preferences.importModuleSpecifier": "relative",
|
|
126
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
127
|
+
"typescript.validate.enable": true,
|
|
128
|
+
"cSpell.ignorePaths": [
|
|
129
|
+
"**/package-lock.json",
|
|
130
|
+
"**/node_modules/**",
|
|
131
|
+
"**/build/**",
|
|
132
|
+
"**/vscode-extension/**",
|
|
133
|
+
"**/.git/objects/**",
|
|
134
|
+
".vscode",
|
|
135
|
+
".spruce"
|
|
136
|
+
],
|
|
137
|
+
"cSpell.words": ["arkit", "autogenerated", "scrollable", "serializable"]
|
|
138
|
+
}
|
|
67
139
|
`
|
|
68
140
|
|
|
69
141
|
protected constructor(options: AutopackageOptions) {
|
|
@@ -98,6 +170,19 @@ export default prettierConfigNdx
|
|
|
98
170
|
this.testDirPath,
|
|
99
171
|
'AbstractPackageTest.ts'
|
|
100
172
|
)
|
|
173
|
+
|
|
174
|
+
this.eslintConfigPath = path.join(this.packageDir, 'eslint.config.js')
|
|
175
|
+
|
|
176
|
+
this.prettierConfigPath = path.join(
|
|
177
|
+
this.packageDir,
|
|
178
|
+
'prettier.config.js'
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
this.settingsJsonPath = path.join(
|
|
182
|
+
this.packageDir,
|
|
183
|
+
'.vscode',
|
|
184
|
+
'settings.json'
|
|
185
|
+
)
|
|
101
186
|
}
|
|
102
187
|
|
|
103
188
|
public static Create(options: AutopackageOptions) {
|
|
@@ -119,9 +204,9 @@ export default prettierConfigNdx
|
|
|
119
204
|
await this.updateVscodeTasks()
|
|
120
205
|
await this.installDefaultDevDependencies()
|
|
121
206
|
await this.installAbstractPackageTest()
|
|
122
|
-
await this.
|
|
123
|
-
await this.installNewEslintConfigJs()
|
|
207
|
+
await this.installEslintConfigFile()
|
|
124
208
|
await this.installPrettierConfigFile()
|
|
209
|
+
await this.installSettingsJsonFile()
|
|
125
210
|
await this.openVscode()
|
|
126
211
|
}
|
|
127
212
|
|
|
@@ -707,6 +792,22 @@ export default prettierConfigNdx
|
|
|
707
792
|
)
|
|
708
793
|
}
|
|
709
794
|
|
|
795
|
+
private async installEslintConfigFile() {
|
|
796
|
+
await this.removeOldEslintConfigMjs()
|
|
797
|
+
|
|
798
|
+
this.originalEslintConfig = await this.loadEslintConfigFile()
|
|
799
|
+
|
|
800
|
+
if (!this.eslintConfigIsUpToDate) {
|
|
801
|
+
console.log('Installing eslint.config.js...')
|
|
802
|
+
|
|
803
|
+
await this.writeFile(this.eslintConfigPath, this.eslintConfigFile, {
|
|
804
|
+
encoding: 'utf-8',
|
|
805
|
+
})
|
|
806
|
+
|
|
807
|
+
await this.commitInstallEslintConfigFile()
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
710
811
|
private async removeOldEslintConfigMjs() {
|
|
711
812
|
const fileExists = await this.pathExists(
|
|
712
813
|
path.join(this.packageDir, 'eslint.config.mjs')
|
|
@@ -721,20 +822,19 @@ export default prettierConfigNdx
|
|
|
721
822
|
}
|
|
722
823
|
}
|
|
723
824
|
|
|
724
|
-
private async
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
if (!fileExists) {
|
|
729
|
-
console.log('Installing eslint.config.js...')
|
|
730
|
-
|
|
731
|
-
await this.writeFile(eslintConfigPath, this.eslintConfigFile, {
|
|
825
|
+
private async loadEslintConfigFile() {
|
|
826
|
+
try {
|
|
827
|
+
return await this.readFile(this.eslintConfigPath, {
|
|
732
828
|
encoding: 'utf-8',
|
|
733
829
|
})
|
|
734
|
-
|
|
735
|
-
|
|
830
|
+
} catch {
|
|
831
|
+
return ''
|
|
736
832
|
}
|
|
737
833
|
}
|
|
834
|
+
|
|
835
|
+
private get eslintConfigIsUpToDate() {
|
|
836
|
+
return this.originalEslintConfig.trim() === this.eslintConfigFile.trim()
|
|
837
|
+
}
|
|
738
838
|
|
|
739
839
|
private async commitInstallEslintConfigFile() {
|
|
740
840
|
await this.GitAutocommit(
|
|
@@ -743,17 +843,12 @@ export default prettierConfigNdx
|
|
|
743
843
|
}
|
|
744
844
|
|
|
745
845
|
private async installPrettierConfigFile() {
|
|
746
|
-
|
|
747
|
-
this.packageDir,
|
|
748
|
-
'prettier.config.js'
|
|
749
|
-
)
|
|
750
|
-
|
|
751
|
-
const fileExists = await this.pathExists(prettierConfigPath)
|
|
846
|
+
this.originalPrettierConfig = await this.loadPrettierConfigFile()
|
|
752
847
|
|
|
753
|
-
if (!
|
|
848
|
+
if (!this.prettierConfigIsUpToDate) {
|
|
754
849
|
console.log('Installing prettier.config.js...')
|
|
755
850
|
|
|
756
|
-
await this.writeFile(prettierConfigPath, this.prettierConfigFile, {
|
|
851
|
+
await this.writeFile(this.prettierConfigPath, this.prettierConfigFile, {
|
|
757
852
|
encoding: 'utf-8',
|
|
758
853
|
})
|
|
759
854
|
|
|
@@ -761,12 +856,60 @@ export default prettierConfigNdx
|
|
|
761
856
|
}
|
|
762
857
|
}
|
|
763
858
|
|
|
859
|
+
private async loadPrettierConfigFile() {
|
|
860
|
+
try {
|
|
861
|
+
return await this.readFile(this.prettierConfigPath, {
|
|
862
|
+
encoding: 'utf-8',
|
|
863
|
+
})
|
|
864
|
+
} catch {
|
|
865
|
+
return ''
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
private get prettierConfigIsUpToDate() {
|
|
870
|
+
return this.originalPrettierConfig.trim() === this.prettierConfigFile.trim()
|
|
871
|
+
}
|
|
872
|
+
|
|
764
873
|
private async commitInstallPrettierConfigFile() {
|
|
765
874
|
await this.GitAutocommit(
|
|
766
875
|
`patch: install prettier.config.js (@neurodevs/meta-node: ${this.metaNodeVersion})`
|
|
767
876
|
)
|
|
768
877
|
}
|
|
769
878
|
|
|
879
|
+
private async installSettingsJsonFile() {
|
|
880
|
+
this.originalSettingsJson = await this.loadSettingsJsonFile()
|
|
881
|
+
|
|
882
|
+
if (!this.settingsJsonIsUpToDate) {
|
|
883
|
+
console.log('Installing .vscode/settings.json...')
|
|
884
|
+
|
|
885
|
+
await this.writeFile(
|
|
886
|
+
this.settingsJsonPath,
|
|
887
|
+
this.settingsJsonFile,
|
|
888
|
+
{
|
|
889
|
+
encoding: 'utf-8',
|
|
890
|
+
}
|
|
891
|
+
)
|
|
892
|
+
|
|
893
|
+
await this.commitInstallSettingsJsonFile()
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
|
|
897
|
+
private async loadSettingsJsonFile() {
|
|
898
|
+
return await this.readFile(this.settingsJsonPath, {
|
|
899
|
+
encoding: 'utf-8',
|
|
900
|
+
})
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
private get settingsJsonIsUpToDate() {
|
|
904
|
+
return this.originalSettingsJson.trim() === this.settingsJsonFile.trim()
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
private async commitInstallSettingsJsonFile() {
|
|
908
|
+
await this.GitAutocommit(
|
|
909
|
+
`patch: install settings.json (@neurodevs/meta-node: ${this.metaNodeVersion})`
|
|
910
|
+
)
|
|
911
|
+
}
|
|
912
|
+
|
|
770
913
|
private async openVscode() {
|
|
771
914
|
if (this.shouldOpenVscode) {
|
|
772
915
|
await this.exec('code .', { cwd: this.packageDir })
|
package/eslint.config.mjs
DELETED