@neurodevs/meta-node 0.6.1 → 0.7.0
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__/modules/GitAutocloner.test.d.ts +4 -7
- package/build/__tests__/modules/GitAutocloner.test.js +31 -27
- package/build/__tests__/modules/GitAutocloner.test.js.map +1 -1
- package/build/__tests__/modules/ImplAutomodule.test.d.ts +2 -0
- package/build/__tests__/modules/ImplAutomodule.test.js +38 -56
- package/build/__tests__/modules/ImplAutomodule.test.js.map +1 -1
- package/build/__tests__/modules/NpmAutopackage.test.d.ts +6 -10
- package/build/__tests__/modules/NpmAutopackage.test.js +96 -120
- package/build/__tests__/modules/NpmAutopackage.test.js.map +1 -1
- package/build/index.d.ts +0 -6
- package/build/index.js +1 -11
- package/build/index.js.map +1 -1
- package/build/modules/GitAutocloner.d.ts +10 -8
- package/build/modules/GitAutocloner.js +32 -25
- package/build/modules/GitAutocloner.js.map +1 -1
- package/build/modules/ImplAutomodule.d.ts +7 -2
- package/build/modules/ImplAutomodule.js +30 -17
- package/build/modules/ImplAutomodule.js.map +1 -1
- package/build/modules/NpmAutopackage.d.ts +18 -14
- package/build/modules/NpmAutopackage.js +99 -89
- package/build/modules/NpmAutopackage.js.map +1 -1
- package/build/scripts/runAutomodule.js +3 -3
- package/build/scripts/runAutomodule.js.map +1 -1
- package/build/scripts/runAutopackage.js +1 -1
- package/build/scripts/runAutopackage.js.map +1 -1
- package/package.json +4 -1
- package/src/__tests__/modules/GitAutocloner.test.ts +44 -29
- package/src/__tests__/modules/ImplAutomodule.test.ts +34 -10
- package/src/__tests__/modules/NpmAutopackage.test.ts +140 -143
- package/src/index.ts +0 -11
- package/src/modules/GitAutocloner.ts +37 -26
- package/src/modules/ImplAutomodule.ts +35 -19
- package/src/modules/NpmAutopackage.ts +110 -87
- package/src/scripts/runAutomodule.ts +3 -3
- package/src/scripts/runAutopackage.ts +1 -1
- package/build/modules/pathExists.d.ts +0 -1
- package/build/modules/pathExists.js +0 -14
- package/build/modules/pathExists.js.map +0 -1
- package/build/testDoubles/fs/fakePathExists.d.ts +0 -3
- package/build/testDoubles/fs/fakePathExists.js +0 -13
- package/build/testDoubles/fs/fakePathExists.js.map +0 -1
- package/build/testDoubles/fs/fakeReadFile.d.ts +0 -5
- package/build/testDoubles/fs/fakeReadFile.js +0 -20
- package/build/testDoubles/fs/fakeReadFile.js.map +0 -1
- package/build/testDoubles/fs/fakeWriteFile.d.ts +0 -6
- package/build/testDoubles/fs/fakeWriteFile.js +0 -13
- package/build/testDoubles/fs/fakeWriteFile.js.map +0 -1
- package/src/modules/pathExists.ts +0 -10
- package/src/testDoubles/fs/fakePathExists.ts +0 -9
- package/src/testDoubles/fs/fakeReadFile.ts +0 -18
- package/src/testDoubles/fs/fakeWriteFile.ts +0 -12
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { exec as execSync } from 'child_process'
|
|
1
2
|
import { readFile, writeFile } from 'fs/promises'
|
|
2
3
|
import path from 'path'
|
|
3
|
-
import
|
|
4
|
+
import { promisify } from 'util'
|
|
5
|
+
import { pathExists } from 'fs-extra'
|
|
4
6
|
|
|
5
7
|
export default class ImplAutomodule implements Automodule {
|
|
6
8
|
public static Class?: AutomoduleConstructor
|
|
9
|
+
public static exec = promisify(execSync)
|
|
7
10
|
public static pathExists = pathExists
|
|
8
11
|
public static readFile = readFile
|
|
9
12
|
public static writeFile = writeFile
|
|
@@ -37,15 +40,20 @@ export default class ImplAutomodule implements Automodule {
|
|
|
37
40
|
}
|
|
38
41
|
|
|
39
42
|
public async run() {
|
|
40
|
-
await this.
|
|
41
|
-
await this.throwIfModuleDirDoesNotExist()
|
|
42
|
-
await this.throwIfFakeDirDoesNotExist()
|
|
43
|
+
await this.throwIfDirectoriesDoNotExist()
|
|
43
44
|
|
|
44
45
|
await this.createTestFile()
|
|
45
46
|
await this.createModuleFile()
|
|
46
47
|
await this.createFakeFile()
|
|
47
48
|
|
|
48
49
|
await this.updateIndexFileExports()
|
|
50
|
+
await this.bumpMinorVersion()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private async throwIfDirectoriesDoNotExist() {
|
|
54
|
+
await this.throwIfTestDirDoesNotExist()
|
|
55
|
+
await this.throwIfModuleDirDoesNotExist()
|
|
56
|
+
await this.throwIfFakeDirDoesNotExist()
|
|
49
57
|
}
|
|
50
58
|
|
|
51
59
|
private async throwIfTestDirDoesNotExist() {
|
|
@@ -111,6 +119,29 @@ export default class ImplAutomodule implements Automodule {
|
|
|
111
119
|
|
|
112
120
|
private readonly indexFilePath = './src/index.ts'
|
|
113
121
|
|
|
122
|
+
private get sortedIndexFile() {
|
|
123
|
+
const blocks = this.indexFilePattern
|
|
124
|
+
.split(/(?=\/\/)/)
|
|
125
|
+
.map((s) => s.trim())
|
|
126
|
+
.filter(Boolean)
|
|
127
|
+
|
|
128
|
+
blocks.sort((a, b) => {
|
|
129
|
+
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
130
|
+
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
131
|
+
return aKey.localeCompare(bKey)
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
return blocks.join('\n\n')
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
private async bumpMinorVersion() {
|
|
138
|
+
await this.exec('yarn version --minor --no-git-tag-version')
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
private get exec() {
|
|
142
|
+
return ImplAutomodule.exec
|
|
143
|
+
}
|
|
144
|
+
|
|
114
145
|
private get pathExists() {
|
|
115
146
|
return ImplAutomodule.pathExists
|
|
116
147
|
}
|
|
@@ -198,21 +229,6 @@ export default class ImplAutomodule implements Automodule {
|
|
|
198
229
|
export * from './testDoubles/${this.interfaceName}/Fake${this.interfaceName}'
|
|
199
230
|
`
|
|
200
231
|
}
|
|
201
|
-
|
|
202
|
-
private get sortedIndexFile() {
|
|
203
|
-
const blocks = this.indexFilePattern
|
|
204
|
-
.split(/(?=\/\/)/)
|
|
205
|
-
.map((s) => s.trim())
|
|
206
|
-
.filter(Boolean)
|
|
207
|
-
|
|
208
|
-
blocks.sort((a, b) => {
|
|
209
|
-
const aKey = a.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
210
|
-
const bKey = b.match(/^\/\/\s*([^\n]*)/)?.[1]?.trim() ?? ''
|
|
211
|
-
return aKey.localeCompare(bKey)
|
|
212
|
-
})
|
|
213
|
-
|
|
214
|
-
return blocks.join('\n\n')
|
|
215
|
-
}
|
|
216
232
|
}
|
|
217
233
|
|
|
218
234
|
export interface Automodule {
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import { execSync } from 'child_process'
|
|
2
|
-
import
|
|
1
|
+
import { exec as execSync } from 'child_process'
|
|
2
|
+
import { readFile, writeFile } from 'fs/promises'
|
|
3
|
+
import { promisify } from 'util'
|
|
4
|
+
import { pathExists } from 'fs-extra'
|
|
3
5
|
|
|
4
6
|
export default class NpmAutopackage implements Autopackage {
|
|
5
7
|
public static Class?: AutopackageConstructor
|
|
6
8
|
public static chdir = process.chdir
|
|
7
|
-
public static
|
|
8
|
-
public static
|
|
9
|
-
public static
|
|
10
|
-
public static
|
|
11
|
-
public static
|
|
9
|
+
public static exec = promisify(execSync)
|
|
10
|
+
public static fetch = fetch
|
|
11
|
+
public static pathExists = pathExists
|
|
12
|
+
public static readFile = readFile
|
|
13
|
+
public static writeFile = writeFile
|
|
12
14
|
|
|
13
15
|
private packageName: string
|
|
14
16
|
private description: string
|
|
@@ -19,6 +21,7 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
19
21
|
private author?: string
|
|
20
22
|
|
|
21
23
|
private originalJsonFile!: Record<string, unknown>
|
|
24
|
+
private originalGitignoreFile!: string
|
|
22
25
|
|
|
23
26
|
protected constructor(options: AutopackageOptions) {
|
|
24
27
|
const {
|
|
@@ -50,12 +53,13 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
50
53
|
await this.createRepoInGithubOrg()
|
|
51
54
|
|
|
52
55
|
this.chdirToInstallDir()
|
|
53
|
-
this.cloneGitRepo()
|
|
56
|
+
await this.cloneGitRepo()
|
|
57
|
+
|
|
54
58
|
this.chdirToPackageDir()
|
|
55
|
-
this.spruceCreateModule()
|
|
56
|
-
this.updatePackage()
|
|
57
|
-
this.updateGitignore()
|
|
58
|
-
this.setupVscode()
|
|
59
|
+
await this.spruceCreateModule()
|
|
60
|
+
await this.updatePackage()
|
|
61
|
+
await this.updateGitignore()
|
|
62
|
+
await this.setupVscode()
|
|
59
63
|
}
|
|
60
64
|
|
|
61
65
|
private throwIfGithubTokenNotInEnv() {
|
|
@@ -94,15 +98,17 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
94
98
|
this.chdir(this.installDir)
|
|
95
99
|
}
|
|
96
100
|
|
|
97
|
-
private cloneGitRepo() {
|
|
98
|
-
|
|
101
|
+
private async cloneGitRepo() {
|
|
102
|
+
const packageDirExists = await this.checkIfPackageDirExists()
|
|
103
|
+
|
|
104
|
+
if (!packageDirExists) {
|
|
99
105
|
console.log('Cloning git repository...')
|
|
100
|
-
this.exec(`git clone ${this.gitUrl}`)
|
|
106
|
+
await this.exec(`git clone ${this.gitUrl}`)
|
|
101
107
|
}
|
|
102
108
|
}
|
|
103
109
|
|
|
104
|
-
private
|
|
105
|
-
return this.
|
|
110
|
+
private async checkIfPackageDirExists() {
|
|
111
|
+
return this.pathExists(this.packageDir)
|
|
106
112
|
}
|
|
107
113
|
|
|
108
114
|
private get packageDir() {
|
|
@@ -117,58 +123,60 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
117
123
|
this.chdir(this.packageDir)
|
|
118
124
|
}
|
|
119
125
|
|
|
120
|
-
private spruceCreateModule() {
|
|
121
|
-
|
|
126
|
+
private async spruceCreateModule() {
|
|
127
|
+
const packageJsonExists = await this.checkIfPackageJsonExists()
|
|
128
|
+
|
|
129
|
+
if (!packageJsonExists) {
|
|
122
130
|
console.log('Running spruce create.module...')
|
|
123
|
-
this.execSpruceCreateModule()
|
|
124
|
-
this.commitCreatePackage()
|
|
131
|
+
await this.execSpruceCreateModule()
|
|
132
|
+
await this.commitCreatePackage()
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
135
|
|
|
128
|
-
private
|
|
129
|
-
return this.
|
|
136
|
+
private async checkIfPackageJsonExists() {
|
|
137
|
+
return this.pathExists(this.packageJsonPath)
|
|
130
138
|
}
|
|
131
139
|
|
|
132
140
|
private get packageJsonPath() {
|
|
133
141
|
return `${this.packageDir}/package.json`
|
|
134
142
|
}
|
|
135
143
|
|
|
136
|
-
private execSpruceCreateModule() {
|
|
137
|
-
this.exec(
|
|
144
|
+
private async execSpruceCreateModule() {
|
|
145
|
+
await this.exec(
|
|
138
146
|
`spruce create.module --name "${this.packageName}" --destination "${this.installDir}/${this.packageName}" --description "${this.description}"`
|
|
139
147
|
)
|
|
140
148
|
}
|
|
141
149
|
|
|
142
|
-
private commitCreatePackage() {
|
|
143
|
-
this.gitAddAll()
|
|
144
|
-
this.gitCommitCreatePackage()
|
|
145
|
-
this.gitPush()
|
|
150
|
+
private async commitCreatePackage() {
|
|
151
|
+
await this.gitAddAll()
|
|
152
|
+
await this.gitCommitCreatePackage()
|
|
153
|
+
await this.gitPush()
|
|
146
154
|
}
|
|
147
155
|
|
|
148
|
-
private gitAddAll() {
|
|
149
|
-
this.exec('git add .')
|
|
156
|
+
private async gitAddAll() {
|
|
157
|
+
await this.exec('git add .')
|
|
150
158
|
}
|
|
151
159
|
|
|
152
|
-
private gitCommitCreatePackage() {
|
|
153
|
-
this.exec('git commit -m "patch: create package"')
|
|
160
|
+
private async gitCommitCreatePackage() {
|
|
161
|
+
await this.exec('git commit -m "patch: create package"')
|
|
154
162
|
}
|
|
155
163
|
|
|
156
|
-
private gitPush() {
|
|
157
|
-
this.exec('git push')
|
|
164
|
+
private async gitPush() {
|
|
165
|
+
await this.exec('git push')
|
|
158
166
|
}
|
|
159
167
|
|
|
160
|
-
private updatePackage() {
|
|
161
|
-
this.originalJsonFile = this.
|
|
168
|
+
private async updatePackage() {
|
|
169
|
+
this.originalJsonFile = await this.loadPackageJsonFile()
|
|
162
170
|
|
|
163
171
|
if (!this.isPackageUpToDate) {
|
|
164
172
|
console.log('Updating package.json...')
|
|
165
|
-
this.updatePackageJson()
|
|
166
|
-
this.commitUpdatePackage()
|
|
173
|
+
await this.updatePackageJson()
|
|
174
|
+
await this.commitUpdatePackage()
|
|
167
175
|
}
|
|
168
176
|
}
|
|
169
177
|
|
|
170
|
-
private
|
|
171
|
-
const raw = this.
|
|
178
|
+
private async loadPackageJsonFile() {
|
|
179
|
+
const raw = await this.readFile(this.packageJsonPath, {
|
|
172
180
|
encoding: 'utf-8',
|
|
173
181
|
})
|
|
174
182
|
return JSON.parse(raw)
|
|
@@ -181,7 +189,7 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
181
189
|
)
|
|
182
190
|
}
|
|
183
191
|
|
|
184
|
-
private updatePackageJson() {
|
|
192
|
+
private async updatePackageJson() {
|
|
185
193
|
const ordered = this.orderJsonKeys(this.updatedJsonFile, [
|
|
186
194
|
'name',
|
|
187
195
|
'version',
|
|
@@ -202,7 +210,7 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
202
210
|
'skill',
|
|
203
211
|
])
|
|
204
212
|
|
|
205
|
-
this.
|
|
213
|
+
await this.writeFile(
|
|
206
214
|
this.packageJsonPath,
|
|
207
215
|
JSON.stringify(ordered, null, 2) + '\n',
|
|
208
216
|
{ encoding: 'utf-8' }
|
|
@@ -254,73 +262,88 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
254
262
|
return ordered
|
|
255
263
|
}
|
|
256
264
|
|
|
257
|
-
private commitUpdatePackage() {
|
|
258
|
-
this.gitAddAll()
|
|
259
|
-
this.gitCommitUpdatePackage()
|
|
260
|
-
this.gitPush()
|
|
265
|
+
private async commitUpdatePackage() {
|
|
266
|
+
await this.gitAddAll()
|
|
267
|
+
await this.gitCommitUpdatePackage()
|
|
268
|
+
await this.gitPush()
|
|
261
269
|
}
|
|
262
270
|
|
|
263
|
-
private gitCommitUpdatePackage() {
|
|
264
|
-
this.exec('git commit -m "patch: update package"')
|
|
271
|
+
private async gitCommitUpdatePackage() {
|
|
272
|
+
await this.exec('git commit -m "patch: update package"')
|
|
265
273
|
}
|
|
266
274
|
|
|
267
|
-
private updateGitignore() {
|
|
268
|
-
|
|
275
|
+
private async updateGitignore() {
|
|
276
|
+
this.originalGitignoreFile = await this.loadGitignoreFile()
|
|
277
|
+
|
|
278
|
+
if (!this.isGitignoreUpdated) {
|
|
269
279
|
console.log('Updating .gitignore...')
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
})
|
|
274
|
-
this.commitUpdateGitignore()
|
|
280
|
+
|
|
281
|
+
await this.addBuildDirToGitignore()
|
|
282
|
+
await this.commitUpdateGitignore()
|
|
275
283
|
}
|
|
276
284
|
}
|
|
277
285
|
|
|
278
|
-
private
|
|
279
|
-
|
|
286
|
+
private async loadGitignoreFile() {
|
|
287
|
+
return await this.readFile(this.gitignorePath, {
|
|
280
288
|
encoding: 'utf-8',
|
|
281
289
|
})
|
|
282
|
-
const lines = content.split(/\r?\n/).map((line) => line.trim())
|
|
283
|
-
return lines.includes('build/')
|
|
284
290
|
}
|
|
285
291
|
|
|
286
292
|
private get gitignorePath() {
|
|
287
293
|
return `${this.packageDir}/.gitignore`
|
|
288
294
|
}
|
|
289
295
|
|
|
290
|
-
private
|
|
291
|
-
this.
|
|
292
|
-
|
|
293
|
-
|
|
296
|
+
private get isGitignoreUpdated() {
|
|
297
|
+
const lines = this.originalGitignoreFile
|
|
298
|
+
.split(/\r?\n/)
|
|
299
|
+
.map((line) => line.trim())
|
|
300
|
+
|
|
301
|
+
return lines.includes('build/')
|
|
294
302
|
}
|
|
295
303
|
|
|
296
|
-
private
|
|
297
|
-
this.
|
|
304
|
+
private async addBuildDirToGitignore() {
|
|
305
|
+
await this.writeFile(this.gitignorePath, '\nbuild/\n', {
|
|
306
|
+
encoding: 'utf-8',
|
|
307
|
+
flag: 'a',
|
|
308
|
+
})
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
private async commitUpdateGitignore() {
|
|
312
|
+
await this.gitAddAll()
|
|
313
|
+
await this.gitCommitUpdateGitignore()
|
|
314
|
+
await this.gitPush()
|
|
298
315
|
}
|
|
299
316
|
|
|
300
|
-
private
|
|
301
|
-
|
|
317
|
+
private async gitCommitUpdateGitignore() {
|
|
318
|
+
await this.exec('git commit -m "patch: add build dir to gitignore"')
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
private async setupVscode() {
|
|
322
|
+
const vscodeSettingsExist = await this.checkIfVscodeSettingsExist()
|
|
323
|
+
|
|
324
|
+
if (!vscodeSettingsExist) {
|
|
302
325
|
console.log('Setting up VSCode...')
|
|
303
|
-
this.spruceSetupVscode()
|
|
304
|
-
this.commitSetupVscode()
|
|
326
|
+
await this.spruceSetupVscode()
|
|
327
|
+
await this.commitSetupVscode()
|
|
305
328
|
}
|
|
306
329
|
}
|
|
307
330
|
|
|
308
|
-
private
|
|
309
|
-
return this.
|
|
331
|
+
private async checkIfVscodeSettingsExist() {
|
|
332
|
+
return this.pathExists(`${this.packageDir}/.vscode/settings.json`)
|
|
310
333
|
}
|
|
311
334
|
|
|
312
|
-
private spruceSetupVscode() {
|
|
313
|
-
this.exec('spruce setup.vscode --all true')
|
|
335
|
+
private async spruceSetupVscode() {
|
|
336
|
+
await this.exec('spruce setup.vscode --all true')
|
|
314
337
|
}
|
|
315
338
|
|
|
316
|
-
private commitSetupVscode() {
|
|
317
|
-
this.gitAddAll()
|
|
318
|
-
this.gitCommitSetup()
|
|
319
|
-
this.gitPush()
|
|
339
|
+
private async commitSetupVscode() {
|
|
340
|
+
await this.gitAddAll()
|
|
341
|
+
await this.gitCommitSetup()
|
|
342
|
+
await this.gitPush()
|
|
320
343
|
}
|
|
321
344
|
|
|
322
|
-
private gitCommitSetup() {
|
|
323
|
-
this.exec('git commit -m "patch: setup vscode"')
|
|
345
|
+
private async gitCommitSetup() {
|
|
346
|
+
await this.exec('git commit -m "patch: setup vscode"')
|
|
324
347
|
}
|
|
325
348
|
|
|
326
349
|
private get chdir() {
|
|
@@ -328,23 +351,23 @@ export default class NpmAutopackage implements Autopackage {
|
|
|
328
351
|
}
|
|
329
352
|
|
|
330
353
|
private get exec() {
|
|
331
|
-
return NpmAutopackage.
|
|
354
|
+
return NpmAutopackage.exec
|
|
332
355
|
}
|
|
333
356
|
|
|
334
|
-
private get
|
|
335
|
-
return NpmAutopackage.
|
|
357
|
+
private get pathExists() {
|
|
358
|
+
return NpmAutopackage.pathExists
|
|
336
359
|
}
|
|
337
360
|
|
|
338
361
|
private get fetch() {
|
|
339
362
|
return NpmAutopackage.fetch
|
|
340
363
|
}
|
|
341
364
|
|
|
342
|
-
private get
|
|
343
|
-
return NpmAutopackage.
|
|
365
|
+
private get readFile() {
|
|
366
|
+
return NpmAutopackage.readFile
|
|
344
367
|
}
|
|
345
368
|
|
|
346
|
-
private get
|
|
347
|
-
return NpmAutopackage.
|
|
369
|
+
private get writeFile() {
|
|
370
|
+
return NpmAutopackage.writeFile
|
|
348
371
|
}
|
|
349
372
|
}
|
|
350
373
|
|
|
@@ -8,9 +8,9 @@ async function main() {
|
|
|
8
8
|
'/Users/ericthecurious/dev/meta-node/src/__tests__/modules',
|
|
9
9
|
moduleSaveDir: '/Users/ericthecurious/dev/meta-node/src/modules',
|
|
10
10
|
fakeSaveDir:
|
|
11
|
-
'/Users/ericthecurious/dev/meta-node/src/testDoubles/
|
|
12
|
-
interfaceName: '
|
|
13
|
-
implName: '
|
|
11
|
+
'/Users/ericthecurious/dev/meta-node/src/testDoubles/Autothingy',
|
|
12
|
+
interfaceName: 'Autothingy',
|
|
13
|
+
implName: 'PackageAutothingy',
|
|
14
14
|
})
|
|
15
15
|
|
|
16
16
|
await instance.run()
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function pathExists(path: string): Promise<boolean>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = pathExists;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
async function pathExists(path) {
|
|
6
|
-
try {
|
|
7
|
-
await (0, promises_1.access)(path);
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=pathExists.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pathExists.js","sourceRoot":"","sources":["../../src/modules/pathExists.ts"],"names":[],"mappings":";;AAEA,6BAOC;AATD,0CAAoC;AAErB,KAAK,UAAU,UAAU,CAAC,IAAY;IACjD,IAAI,CAAC;QACD,MAAM,IAAA,iBAAM,EAAC,IAAI,CAAC,CAAA;QAClB,OAAO,IAAI,CAAA;IACf,CAAC;IAAC,MAAM,CAAC;QACL,OAAO,KAAK,CAAA;IAChB,CAAC;AACL,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.pathShouldExist = void 0;
|
|
4
|
-
exports.setPathShouldExist = setPathShouldExist;
|
|
5
|
-
exports.default = fakePathExists;
|
|
6
|
-
exports.pathShouldExist = {};
|
|
7
|
-
function setPathShouldExist(path, shouldExist) {
|
|
8
|
-
exports.pathShouldExist[path] = shouldExist;
|
|
9
|
-
}
|
|
10
|
-
async function fakePathExists(path) {
|
|
11
|
-
return exports.pathShouldExist[path];
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=fakePathExists.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakePathExists.js","sourceRoot":"","sources":["../../../src/testDoubles/fs/fakePathExists.ts"],"names":[],"mappings":";;;AAEA,gDAEC;AAED,iCAEC;AARU,QAAA,eAAe,GAA4B,EAAE,CAAA;AAExD,SAAgB,kBAAkB,CAAC,IAAY,EAAE,WAAoB;IACjE,uBAAe,CAAC,IAAI,CAAC,GAAG,WAAW,CAAA;AACvC,CAAC;AAEc,KAAK,UAAU,cAAc,CAAC,IAAY;IACrD,OAAO,uBAAe,CAAC,IAAI,CAAC,CAAA;AAChC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare let callsToReadFile: string[];
|
|
2
|
-
export declare function resetCallsToReadFile(): void;
|
|
3
|
-
export declare let fakeReadFileResult: string;
|
|
4
|
-
export declare function setFakeReadFileResult(result: string): void;
|
|
5
|
-
export default function fakeReadFile(file: string): Promise<string>;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fakeReadFileResult = exports.callsToReadFile = void 0;
|
|
4
|
-
exports.resetCallsToReadFile = resetCallsToReadFile;
|
|
5
|
-
exports.setFakeReadFileResult = setFakeReadFileResult;
|
|
6
|
-
exports.default = fakeReadFile;
|
|
7
|
-
const test_utils_1 = require("@sprucelabs/test-utils");
|
|
8
|
-
exports.callsToReadFile = [];
|
|
9
|
-
function resetCallsToReadFile() {
|
|
10
|
-
exports.callsToReadFile = [];
|
|
11
|
-
}
|
|
12
|
-
exports.fakeReadFileResult = (0, test_utils_1.generateId)();
|
|
13
|
-
function setFakeReadFileResult(result) {
|
|
14
|
-
exports.fakeReadFileResult = result;
|
|
15
|
-
}
|
|
16
|
-
async function fakeReadFile(file) {
|
|
17
|
-
exports.callsToReadFile.push(file);
|
|
18
|
-
return exports.fakeReadFileResult;
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=fakeReadFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakeReadFile.js","sourceRoot":"","sources":["../../../src/testDoubles/fs/fakeReadFile.ts"],"names":[],"mappings":";;;AAIA,oDAEC;AAID,sDAEC;AAED,+BAGC;AAjBD,uDAAmD;AAExC,QAAA,eAAe,GAAa,EAAE,CAAA;AAEzC,SAAgB,oBAAoB;IAChC,uBAAe,GAAG,EAAE,CAAA;AACxB,CAAC;AAEU,QAAA,kBAAkB,GAAG,IAAA,uBAAU,GAAE,CAAA;AAE5C,SAAgB,qBAAqB,CAAC,MAAc;IAChD,0BAAkB,GAAG,MAAM,CAAA;AAC/B,CAAC;AAEc,KAAK,UAAU,YAAY,CAAC,IAAY;IACnD,uBAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC1B,OAAO,0BAAkB,CAAA;AAC7B,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.callsToWriteFile = void 0;
|
|
4
|
-
exports.resetCallsToWriteFile = resetCallsToWriteFile;
|
|
5
|
-
exports.default = fakeWriteFile;
|
|
6
|
-
exports.callsToWriteFile = [];
|
|
7
|
-
function resetCallsToWriteFile() {
|
|
8
|
-
exports.callsToWriteFile = [];
|
|
9
|
-
}
|
|
10
|
-
async function fakeWriteFile(file, data) {
|
|
11
|
-
exports.callsToWriteFile.push({ file, data });
|
|
12
|
-
}
|
|
13
|
-
//# sourceMappingURL=fakeWriteFile.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fakeWriteFile.js","sourceRoot":"","sources":["../../../src/testDoubles/fs/fakeWriteFile.ts"],"names":[],"mappings":";;;AAKA,sDAEC;AAED,gCAEC;AAXU,QAAA,gBAAgB,GAGrB,EAAE,CAAA;AAER,SAAgB,qBAAqB;IACjC,wBAAgB,GAAG,EAAE,CAAA;AACzB,CAAC;AAEc,KAAK,UAAU,aAAa,CAAC,IAAY,EAAE,IAAY;IAClE,wBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export let pathShouldExist: Record<string, boolean> = {}
|
|
2
|
-
|
|
3
|
-
export function setPathShouldExist(path: string, shouldExist: boolean) {
|
|
4
|
-
pathShouldExist[path] = shouldExist
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default async function fakePathExists(path: string) {
|
|
8
|
-
return pathShouldExist[path]
|
|
9
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { generateId } from '@sprucelabs/test-utils'
|
|
2
|
-
|
|
3
|
-
export let callsToReadFile: string[] = []
|
|
4
|
-
|
|
5
|
-
export function resetCallsToReadFile() {
|
|
6
|
-
callsToReadFile = []
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export let fakeReadFileResult = generateId()
|
|
10
|
-
|
|
11
|
-
export function setFakeReadFileResult(result: string) {
|
|
12
|
-
fakeReadFileResult = result
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default async function fakeReadFile(file: string) {
|
|
16
|
-
callsToReadFile.push(file)
|
|
17
|
-
return fakeReadFileResult
|
|
18
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export let callsToWriteFile: {
|
|
2
|
-
file: string
|
|
3
|
-
data: string
|
|
4
|
-
}[] = []
|
|
5
|
-
|
|
6
|
-
export function resetCallsToWriteFile() {
|
|
7
|
-
callsToWriteFile = []
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export default async function fakeWriteFile(file: string, data: string) {
|
|
11
|
-
callsToWriteFile.push({ file, data })
|
|
12
|
-
}
|