@neurodevs/meta-node 0.0.1 → 0.2.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.
Files changed (53) hide show
  1. package/.vscode/tasks.json +18 -0
  2. package/build/__tests__/modules/NodeAutomodule.test.d.ts +20 -0
  3. package/build/__tests__/modules/NodeAutomodule.test.js +166 -0
  4. package/build/__tests__/modules/NodeAutomodule.test.js.map +1 -0
  5. package/build/__tests__/modules/NpmAutopackage.test.d.ts +47 -12
  6. package/build/__tests__/modules/NpmAutopackage.test.js +314 -34
  7. package/build/__tests__/modules/NpmAutopackage.test.js.map +1 -1
  8. package/build/index.d.ts +12 -2
  9. package/build/index.js +23 -6
  10. package/build/index.js.map +1 -1
  11. package/build/modules/GitAutocloner.d.ts +5 -6
  12. package/build/modules/GitAutocloner.js +14 -17
  13. package/build/modules/GitAutocloner.js.map +1 -1
  14. package/build/modules/NodeAutomodule.d.ts +34 -0
  15. package/build/modules/NodeAutomodule.js +102 -0
  16. package/build/modules/NodeAutomodule.js.map +1 -0
  17. package/build/modules/NpmAutopackage.d.ts +49 -16
  18. package/build/modules/NpmAutopackage.js +221 -41
  19. package/build/modules/NpmAutopackage.js.map +1 -1
  20. package/build/modules/pathExists.d.ts +1 -0
  21. package/build/modules/pathExists.js +14 -0
  22. package/build/modules/pathExists.js.map +1 -0
  23. package/build/scripts/runAutomodule.d.ts +1 -0
  24. package/build/scripts/runAutomodule.js +22 -0
  25. package/build/scripts/runAutomodule.js.map +1 -0
  26. package/build/scripts/runAutopackage.js +7 -5
  27. package/build/scripts/runAutopackage.js.map +1 -1
  28. package/build/testDoubles/Automodule/FakeAutomodule.d.ts +8 -0
  29. package/build/testDoubles/Automodule/FakeAutomodule.js +18 -0
  30. package/build/testDoubles/Automodule/FakeAutomodule.js.map +1 -0
  31. package/build/testDoubles/Autopackage/FakeAutopackage.d.ts +8 -0
  32. package/build/testDoubles/Autopackage/FakeAutopackage.js +18 -0
  33. package/build/testDoubles/Autopackage/FakeAutopackage.js.map +1 -0
  34. package/build/testDoubles/fs/fakePathExists.d.ts +3 -0
  35. package/build/testDoubles/fs/fakePathExists.js +13 -0
  36. package/build/testDoubles/fs/fakePathExists.js.map +1 -0
  37. package/build/testDoubles/fs/fakeWriteFile.d.ts +6 -0
  38. package/build/testDoubles/fs/fakeWriteFile.js +13 -0
  39. package/build/testDoubles/fs/fakeWriteFile.js.map +1 -0
  40. package/package.json +5 -1
  41. package/src/__tests__/modules/NodeAutomodule.test.ts +160 -0
  42. package/src/__tests__/modules/NpmAutopackage.test.ts +415 -33
  43. package/src/index.ts +24 -5
  44. package/src/modules/GitAutocloner.ts +18 -22
  45. package/src/modules/NodeAutomodule.ts +136 -0
  46. package/src/modules/NpmAutopackage.ts +272 -42
  47. package/src/modules/pathExists.ts +10 -0
  48. package/src/scripts/runAutomodule.ts +22 -0
  49. package/src/scripts/runAutopackage.ts +7 -5
  50. package/src/testDoubles/Automodule/FakeAutomodule.ts +19 -0
  51. package/src/testDoubles/Autopackage/FakeAutopackage.ts +19 -0
  52. package/src/testDoubles/fs/fakePathExists.ts +9 -0
  53. package/src/testDoubles/fs/fakeWriteFile.ts +9 -0
@@ -11,80 +11,376 @@ import NpmAutopackage, {
11
11
  export default class NpmAutopackageTest extends AbstractSpruceTest {
12
12
  private static instance: Autopackage
13
13
 
14
+ private static callsToChdir: string[] = []
15
+ private static callsToExecSync: string[] = []
16
+ private static callsToExistsSync: string[] = []
17
+ private static callsToFetch: { url: string; init: RequestInit }[] = []
18
+ private static callsToReadFileSync: { path: string; options: any }[] = []
19
+ private static callsToWriteFileSync: {
20
+ path: string
21
+ data: any
22
+ options: any
23
+ }[] = []
24
+
14
25
  protected static async beforeEach() {
15
26
  await super.beforeEach()
16
27
 
17
- this.fakeExecToPreventActual()
18
- this.fakeChdirToPreventActual()
28
+ this.fakeChdir()
29
+ this.fakeExecSync()
30
+ this.fakeExistsSync()
31
+ this.fakeFetch()
32
+ this.fakeReadFileSync()
33
+ this.fakeWriteFileSync()
34
+
35
+ process.env.GITHUB_TOKEN = this.githubToken
19
36
 
20
37
  this.instance = await this.NpmAutopackage()
21
38
  }
22
39
 
23
40
  @test()
24
- protected static async createsNpmAutopackageInstance() {
25
- assert.isTruthy(this.instance, 'Should create an instance!')
41
+ protected static async createsInstance() {
42
+ assert.isTruthy(this.instance, 'Failed to create instance!')
43
+ }
44
+
45
+ @test()
46
+ protected static async throwsIfGithubTokenNotSet() {
47
+ delete process.env.GITHUB_TOKEN
48
+
49
+ await assert.doesThrowAsync(
50
+ async () => {
51
+ await this.NpmAutopackage()
52
+ },
53
+ 'Please set process.env.GITHUB_TOKEN!',
54
+ 'Did not throw with missing process.env.GITHUB_TOKEN!'
55
+ )
56
+ }
57
+
58
+ @test()
59
+ protected static async firstCreateRepoInGithubOrg() {
60
+ assert.isEqualDeep(
61
+ {
62
+ passedUrl: this.callsToFetch[0]?.url,
63
+ passedInit: this.callsToFetch[0]?.init,
64
+ },
65
+ {
66
+ passedUrl: `https://api.github.com/orgs/${this.gitNamespace}/repos`,
67
+ passedInit: {
68
+ method: 'POST',
69
+ headers: {
70
+ Authorization: `token ${this.githubToken}`,
71
+ Accept: 'application/vnd.github+json',
72
+ 'Content-Type': 'application/json',
73
+ },
74
+ body: JSON.stringify({
75
+ name: this.packageName,
76
+ private: false,
77
+ description: this.packageDescription,
78
+ auto_init: true,
79
+ gitignore_template: 'Node',
80
+ license_template: 'mit',
81
+ }),
82
+ },
83
+ },
84
+ 'Did not call fetch as expected!'
85
+ )
26
86
  }
27
87
 
28
88
  @test()
29
- protected static async firstCallsChdirToInstallDir() {
89
+ protected static async secondChdirToInstallDir() {
30
90
  assert.isEqual(
31
91
  this.callsToChdir[0],
32
92
  this.installDir,
33
- 'Should have changed dir!'
93
+ 'Did not change to installDir!'
34
94
  )
35
95
  }
36
96
 
37
97
  @test()
38
- protected static async thenCallsSpruceCreateModule() {
98
+ protected static async thirdGitClone() {
39
99
  assert.isEqual(
40
100
  this.callsToExecSync[0],
101
+ `git clone https://github.com/${this.gitNamespace}/${this.packageName}.git`,
102
+ 'Did not call git clone!'
103
+ )
104
+ }
105
+
106
+ @test()
107
+ protected static async fourthSpruceCreateModule() {
108
+ assert.isEqual(
109
+ this.callsToExecSync[1],
41
110
  this.createModuleCmd,
42
- 'Should have called "spruce create.module"!'
111
+ 'Did not call "spruce create.module"!'
43
112
  )
44
113
  }
45
114
 
46
115
  @test()
47
- protected static async thenCallsChdirToNewlyCreatedDir() {
116
+ protected static async fifthCommitCreatePackage() {
117
+ assert.isEqualDeep(
118
+ this.callsToExecSync.slice(2, 5),
119
+ ['git add .', 'git commit -m "patch: create package"', 'git push'],
120
+ 'Did not commit create package changes!'
121
+ )
122
+ }
123
+
124
+ @test()
125
+ protected static async sixthChdirToPackageDir() {
48
126
  assert.isEqual(
49
127
  this.callsToChdir[1],
50
- `${this.installDir}/${this.packageName}`,
51
- 'Should have changed dir!'
128
+ this.packageDir,
129
+ 'Did not change to packageDir!'
52
130
  )
53
131
  }
54
132
 
55
133
  @test()
56
- protected static async thenSetsUpNewGitRepo() {
134
+ protected static async seventhReadPackageJson() {
135
+ assert.isEqualDeep(this.callsToReadFileSync[0], {
136
+ path: this.packageJsonPath,
137
+ options: { encoding: 'utf-8' },
138
+ })
139
+ }
140
+
141
+ @test()
142
+ protected static async eighthUpdatePackageJson() {
143
+ const actual = this.callsToWriteFileSync[0]
144
+
145
+ const expected = {
146
+ path: this.packageJsonPath,
147
+ data: this.orderJsonKeys(JSON.parse(this.updatedPackageJson), [
148
+ 'name',
149
+ 'version',
150
+ 'description',
151
+ 'keywords',
152
+ 'license',
153
+ 'author',
154
+ 'homepage',
155
+ 'repository',
156
+ 'bugs',
157
+ 'main',
158
+ 'scripts',
159
+ 'dependencies',
160
+ 'devDependencies',
161
+ 'jest',
162
+ 'skill',
163
+ ]),
164
+ options: { encoding: 'utf-8' },
165
+ }
166
+
167
+ const normalize = (s: string) => s.replace(/\s+/g, '').trim()
168
+
57
169
  assert.isEqualDeep(
58
- this.callsToExecSync.slice(1, 5),
170
+ {
171
+ ...actual,
172
+ data: normalize(actual.data),
173
+ },
174
+ {
175
+ ...expected,
176
+ data: normalize(expected.data),
177
+ },
178
+ 'Did not update package.json as expected!'
179
+ )
180
+ }
181
+
182
+ @test()
183
+ protected static async ninthCommitUpdatePackage() {
184
+ assert.isEqualDeep(
185
+ this.callsToExecSync.slice(5, 8),
186
+ ['git add .', 'git commit -m "patch: update package"', 'git push'],
187
+ 'Did not commit update package changes!'
188
+ )
189
+ }
190
+
191
+ @test()
192
+ protected static async tenthAddBuildDirToGitignore() {
193
+ const actual = this.callsToWriteFileSync[1]
194
+
195
+ const expected = {
196
+ path: this.gitignorePath,
197
+ data: '\nbuild/\n',
198
+ options: { encoding: 'utf-8', flag: 'a' },
199
+ }
200
+
201
+ assert.isEqualDeep(
202
+ actual,
203
+ expected,
204
+ 'Did not update .gitignore as expected!'
205
+ )
206
+ }
207
+
208
+ @test()
209
+ protected static async eleventhCommitUpdateGitignore() {
210
+ assert.isEqualDeep(
211
+ this.callsToExecSync.slice(8, 11),
59
212
  [
60
- 'git init',
61
213
  'git add .',
62
- 'git commit -m "patch: create module"',
63
- `git remote add origin "https://github.com/${this.gitNamespace}/${this.packageName}.git"`,
214
+ 'git commit -m "patch: add build dir to gitignore"',
215
+ 'git push',
64
216
  ],
65
- 'Should have called "git init"!'
217
+ 'Did not commit .gitignore changes!'
66
218
  )
67
219
  }
68
220
 
69
221
  @test()
70
- protected static async thenCallsSpruceSetupVscode() {
222
+ protected static async twelfthSpruceSetupVscode() {
71
223
  assert.isEqual(
72
- this.callsToExecSync[5],
73
- 'spruce setup.vscode --all true',
74
- 'Should have called "spruce setup.vscode"!'
224
+ this.callsToExecSync[11],
225
+ NpmAutopackageTest.setupVscodeCmd,
226
+ 'Did not call "spruce setup.vscode"!'
75
227
  )
76
228
  }
77
229
 
78
230
  @test()
79
- protected static async thenGitCommitsVscodeChanges() {
231
+ protected static async lastlyCommitVscodeChanges() {
80
232
  assert.isEqualDeep(
81
- this.callsToExecSync.slice(6, 8),
82
- ['git add .', 'git commit -m "patch: setup vscode"'],
83
- 'Should have committed vscode changes!'
233
+ this.callsToExecSync.slice(12, 15),
234
+ ['git add .', 'git commit -m "patch: setup vscode"', 'git push'],
235
+ 'Did not commit vscode changes!'
236
+ )
237
+ }
238
+
239
+ @test()
240
+ protected static async doesNotCloneRepoIfDone() {
241
+ await this.NpmAutopackage()
242
+
243
+ assert.isEqual(
244
+ this.callsToExecSync.filter(
245
+ (cmd) =>
246
+ cmd ===
247
+ `git clone https://github.com/${this.gitNamespace}/${this.packageName}.git`
248
+ ).length,
249
+ 1,
250
+ 'Did not clone repo once!'
251
+ )
252
+ }
253
+
254
+ @test()
255
+ protected static async doesNotSpruceCreateModuleIfDone() {
256
+ await this.NpmAutopackage()
257
+
258
+ assert.isEqual(
259
+ this.callsToExecSync.filter((cmd) => cmd === this.createModuleCmd)
260
+ .length,
261
+ 1,
262
+ 'Did not call spruce create.module once!'
263
+ )
264
+ }
265
+
266
+ @test()
267
+ protected static async doesNotRunSetupVscodeIfDone() {
268
+ await this.NpmAutopackage()
269
+
270
+ assert.isEqual(
271
+ this.callsToExecSync.filter((cmd) => cmd === this.setupVscodeCmd)
272
+ .length,
273
+ 1,
274
+ 'Did not call spruce setup.vscode once!'
275
+ )
276
+ }
277
+
278
+ @test()
279
+ protected static async doesNotCommitCreatePackageIfDone() {
280
+ await this.NpmAutopackage()
281
+
282
+ assert.isEqual(
283
+ this.callsToExecSync.filter(
284
+ (cmd) => cmd === 'git commit -m "patch: create package"'
285
+ ).length,
286
+ 1,
287
+ 'Did not commit create package changes once!'
288
+ )
289
+ }
290
+
291
+ @test()
292
+ protected static async doesNotCommitUpdatePackageIfDone() {
293
+ await this.NpmAutopackage()
294
+
295
+ assert.isEqual(
296
+ this.callsToExecSync.filter(
297
+ (cmd) => cmd === 'git commit -m "patch: update package"'
298
+ ).length,
299
+ 1,
300
+ 'Did not commit update package changes once!'
84
301
  )
85
302
  }
86
303
 
87
- private static fakeExecToPreventActual() {
304
+ @test()
305
+ protected static async doesNotCommitUpdateGitignoreIfDone() {
306
+ await this.NpmAutopackage()
307
+
308
+ assert.isEqual(
309
+ this.callsToExecSync.filter(
310
+ (cmd) =>
311
+ cmd === 'git commit -m "patch: add build dir to gitignore"'
312
+ ).length,
313
+ 1,
314
+ 'Did not commit gitignore changes once!'
315
+ )
316
+ }
317
+
318
+ @test()
319
+ protected static async doesNotCommitVscodeIfDone() {
320
+ await this.NpmAutopackage()
321
+
322
+ assert.isEqual(
323
+ this.callsToExecSync.filter(
324
+ (cmd) => cmd === 'git commit -m "patch: setup vscode"'
325
+ ).length,
326
+ 1,
327
+ 'Did not commit vscode changes once!'
328
+ )
329
+ }
330
+
331
+ private static get scopedPackage() {
332
+ return `${this.gitNamespace}/${this.packageName}`
333
+ }
334
+
335
+ private static get packageDir() {
336
+ return `${this.installDir}/${this.packageName}`
337
+ }
338
+
339
+ private static get packageJsonPath() {
340
+ return `${this.packageDir}/package.json`
341
+ }
342
+
343
+ private static get gitignorePath() {
344
+ return `${this.packageDir}/.gitignore`
345
+ }
346
+
347
+ private static get createModuleCmd() {
348
+ return `spruce create.module --name "${this.packageName}" --destination "${this.packageDir}" --description "${this.packageDescription}"`
349
+ }
350
+
351
+ private static readonly setupVscodeCmd = 'spruce setup.vscode --all true'
352
+
353
+ private static orderJsonKeys(
354
+ json: Record<string, unknown>,
355
+ keyOrder: string[]
356
+ ) {
357
+ const ordered: Record<string, any> = {}
358
+
359
+ for (const key of keyOrder) {
360
+ if (key in json) {
361
+ ordered[key] = json[key]
362
+ }
363
+ }
364
+
365
+ const remainingKeys = Object.keys(json)
366
+ .filter((k) => !keyOrder.includes(k))
367
+ .sort()
368
+
369
+ for (const key of remainingKeys) {
370
+ ordered[key] = json[key]
371
+ }
372
+
373
+ return JSON.stringify(ordered)
374
+ }
375
+
376
+ private static fakeChdir() {
377
+ NpmAutopackage.chdir = (dir: string) => {
378
+ this.callsToChdir.push(dir)
379
+ }
380
+ this.callsToChdir = []
381
+ }
382
+
383
+ private static fakeExecSync() {
88
384
  // @ts-ignore
89
385
  NpmAutopackage.execSync = (cmd: string) => {
90
386
  this.callsToExecSync.push(cmd)
@@ -92,23 +388,106 @@ export default class NpmAutopackageTest extends AbstractSpruceTest {
92
388
  this.callsToExecSync = []
93
389
  }
94
390
 
95
- private static fakeChdirToPreventActual() {
96
- NpmAutopackage.chdir = (dir: string) => {
97
- this.callsToChdir.push(dir)
391
+ private static fakeExistsSync() {
392
+ // @ts-ignore
393
+ NpmAutopackage.existsSync = (path: string) => {
394
+ if (this.callsToExistsSync.includes(path)) {
395
+ this.callsToExistsSync.push(path)
396
+ return true
397
+ } else {
398
+ this.callsToExistsSync.push(path)
399
+ return false
400
+ }
98
401
  }
99
- this.callsToChdir = []
402
+ this.callsToExistsSync = []
100
403
  }
101
404
 
102
- private static callsToExecSync: string[] = []
103
- private static callsToChdir: string[] = []
405
+ private static fakeFetch() {
406
+ // @ts-ignore
407
+ NpmAutopackage.fetch = async (url: string, init: RequestInit) => {
408
+ this.callsToFetch.push({ url, init })
409
+ }
410
+ this.callsToFetch = []
411
+ }
412
+
413
+ private static fakeReadFileSync() {
414
+ // @ts-ignore
415
+ NpmAutopackage.readFileSync = (path: string, options: any) => {
416
+ this.callsToReadFileSync.push({ path, options })
417
+
418
+ if (path === this.packageJsonPath) {
419
+ if (
420
+ this.callsToReadFileSync.filter(
421
+ ({ path }) => path === this.packageJsonPath
422
+ ).length > 1
423
+ ) {
424
+ return this.updatedPackageJson
425
+ }
426
+ return this.oldPackageJson
427
+ } else if (path === this.gitignorePath) {
428
+ if (
429
+ this.callsToReadFileSync.filter(
430
+ ({ path }) => path === this.gitignorePath
431
+ ).length > 1
432
+ ) {
433
+ return 'node_modules/\n\nbuild/\n'
434
+ }
435
+ return 'node_modules/\n'
436
+ }
437
+ return ''
438
+ }
439
+ this.callsToReadFileSync = []
440
+ }
441
+
442
+ private static get oldPackageJson() {
443
+ return JSON.stringify({
444
+ name: this.packageName,
445
+ description: 'Old description',
446
+ })
447
+ }
448
+
449
+ private static get updatedPackageJson() {
450
+ return JSON.stringify({
451
+ ...JSON.parse(this.oldPackageJson),
452
+ name: `@${this.scopedPackage}`,
453
+ keywords: this.keywords,
454
+ license: this.license,
455
+ author: this.author,
456
+ main: 'build/index.js',
457
+ homepage: `https://github.com/${this.scopedPackage}`,
458
+ repository: {
459
+ type: 'git',
460
+ url: `git+https://github.com/${this.scopedPackage}.git`,
461
+ },
462
+ bugs: {
463
+ url: `https://github.com/${this.scopedPackage}/issues`,
464
+ },
465
+ dependencies: {},
466
+ })
467
+ }
468
+
469
+ private static fakeWriteFileSync() {
470
+ // @ts-ignore
471
+ NpmAutopackage.writeFileSync = (
472
+ path: string,
473
+ data: any,
474
+ options: any
475
+ ) => {
476
+ this.callsToWriteFileSync.push({ path, data, options })
477
+ }
478
+ this.callsToWriteFileSync = []
479
+ }
104
480
 
105
481
  private static readonly packageName = generateId()
106
482
  private static readonly packageDescription = generateId()
107
483
  private static readonly gitNamespace = generateId()
108
484
  private static readonly npmNamespace = generateId()
109
485
  private static readonly installDir = generateId()
486
+ private static readonly keywords = [generateId(), generateId()]
487
+ private static readonly license = generateId()
488
+ private static readonly author = generateId()
110
489
 
111
- private static readonly createModuleCmd = `spruce create.module --name "${this.packageName}" --destination "${this.installDir}/${this.packageName}" --description "${this.packageDescription}"`
490
+ private static readonly githubToken = generateId()
112
491
 
113
492
  private static readonly defaultOptions = {
114
493
  name: this.packageName,
@@ -116,6 +495,9 @@ export default class NpmAutopackageTest extends AbstractSpruceTest {
116
495
  gitNamespace: this.gitNamespace,
117
496
  npmNamespace: this.npmNamespace,
118
497
  installDir: this.installDir,
498
+ keywords: this.keywords,
499
+ license: this.license,
500
+ author: this.author,
119
501
  }
120
502
 
121
503
  private static NpmAutopackage(options?: Partial<AutopackageOptions>) {
package/src/index.ts CHANGED
@@ -1,8 +1,3 @@
1
- // Autopackage
2
-
3
- export { default as NpmAutopackage } from './modules/NpmAutopackage'
4
- export * from './modules/NpmAutopackage'
5
-
6
1
  // Autocloner
7
2
 
8
3
  export { default as GitAutocloner } from './modules/GitAutocloner'
@@ -10,3 +5,27 @@ export * from './modules/GitAutocloner'
10
5
 
11
6
  export { default as FakeAutocloner } from './testDoubles/Autocloner/FakeAutocloner'
12
7
  export * from './testDoubles/Autocloner/FakeAutocloner'
8
+
9
+ // Automodule
10
+
11
+ export { default as NodeAutomodule } from './modules/NodeAutomodule'
12
+ export * from './modules/NodeAutomodule'
13
+
14
+ export { default as FakeAutomodule } from './testDoubles/Automodule/FakeAutomodule'
15
+ export * from './testDoubles/Automodule/FakeAutomodule'
16
+
17
+ // Autopackage
18
+
19
+ export { default as NpmAutopackage } from './modules/NpmAutopackage'
20
+ export * from './modules/NpmAutopackage'
21
+
22
+ export { default as FakeAutopackage } from './testDoubles/Autopackage/FakeAutopackage'
23
+ export * from './testDoubles/Autopackage/FakeAutopackage'
24
+
25
+ // fs
26
+
27
+ export { default as fakePathExists } from './testDoubles/fs/fakePathExists'
28
+ export * from './testDoubles/fs/fakePathExists'
29
+
30
+ export { default as fakeWriteFile } from './testDoubles/fs/fakeWriteFile'
31
+ export * from './testDoubles/fs/fakeWriteFile'
@@ -32,12 +32,16 @@ export default class GitAutocloner implements Autocloner {
32
32
 
33
33
  private throwIfDirPathDoesNotExist() {
34
34
  if (!this.dirPathExists) {
35
- throw new Error(this.dirPathDoesNotExistMessage)
35
+ this.throwDirPathDoesNotExist()
36
36
  }
37
37
  }
38
38
 
39
- private get dirPathDoesNotExistMessage() {
40
- return `dirPath does not exist: ${this.dirPath}!`
39
+ private get dirPathExists() {
40
+ return this.existsSync(this.dirPath)
41
+ }
42
+
43
+ private throwDirPathDoesNotExist() {
44
+ throw new Error(`dirPath does not exist: ${this.dirPath}!`)
41
45
  }
42
46
 
43
47
  private changeDirectoryToDirPath() {
@@ -55,10 +59,20 @@ export default class GitAutocloner implements Autocloner {
55
59
  if (!this.currentRepoExists) {
56
60
  this.tryToCloneRepo()
57
61
  } else {
58
- this.log.info(this.repoExistsMessage)
62
+ this.log.info(`Repo exists, skipping: ${this.currentRepoName}!`)
59
63
  }
60
64
  }
61
65
 
66
+ private get currentRepoExists() {
67
+ return this.existsSync(this.currentRepoName)
68
+ }
69
+
70
+ private get currentRepoName() {
71
+ return this.currentUrl.match(this.regexForRepoName)![1]
72
+ }
73
+
74
+ private readonly regexForRepoName = /\/([a-zA-Z0-9_.-]+)\.git/
75
+
62
76
  private tryToCloneRepo() {
63
77
  try {
64
78
  this.execSync(`git clone ${this.currentUrl}`)
@@ -76,22 +90,6 @@ export default class GitAutocloner implements Autocloner {
76
90
  return `Git clone failed for repo: ${this.currentUrl}!\n\n${this.currentError}\n\n`
77
91
  }
78
92
 
79
- private get dirPathExists() {
80
- return this.existsSync(this.dirPath)
81
- }
82
-
83
- private get currentRepoName() {
84
- return this.currentUrl.match(this.regex)![1]
85
- }
86
-
87
- private get currentRepoExists() {
88
- return this.existsSync(this.currentRepoName)
89
- }
90
-
91
- private get repoExistsMessage() {
92
- return `Repo already exists, skipping: ${this.currentRepoName}!`
93
- }
94
-
95
93
  private get existsSync() {
96
94
  return GitAutocloner.existsSync
97
95
  }
@@ -99,8 +97,6 @@ export default class GitAutocloner implements Autocloner {
99
97
  private get execSync() {
100
98
  return GitAutocloner.execSync
101
99
  }
102
-
103
- private readonly regex = /\/([a-zA-Z0-9_.-]+)\.git/
104
100
  }
105
101
 
106
102
  export interface Autocloner {