aberlaas-init 2.12.0 → 2.14.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 (67) hide show
  1. package/lib/helper.js +34 -27
  2. package/lib/layouts/__tests__/libdocs.js +222 -0
  3. package/lib/layouts/__tests__/module.js +130 -0
  4. package/lib/layouts/__tests__/monorepo.js +226 -0
  5. package/lib/{monorepo.js → layouts/libdocs.js} +50 -86
  6. package/lib/{module.js → layouts/module.js} +16 -21
  7. package/lib/layouts/monorepo.js +240 -0
  8. package/lib/main.js +37 -6
  9. package/package.json +9 -7
  10. package/templates/scripts/__libdocs/local/build +5 -0
  11. package/templates/scripts/__libdocs/local/build-prod +5 -0
  12. package/templates/scripts/__libdocs/local/ci +5 -0
  13. package/templates/scripts/__libdocs/local/cms +4 -0
  14. package/templates/scripts/__libdocs/local/compress +5 -0
  15. package/templates/scripts/__libdocs/local/lint +5 -0
  16. package/templates/scripts/__libdocs/local/lint-fix +5 -0
  17. package/templates/scripts/__libdocs/local/release +5 -0
  18. package/templates/scripts/__libdocs/local/serve +5 -0
  19. package/templates/scripts/__libdocs/local/test +5 -0
  20. package/templates/scripts/__libdocs/local/test-watch +6 -0
  21. package/templates/scripts/__libdocs/meta/build +4 -0
  22. package/templates/scripts/__libdocs/meta/build-prod +4 -0
  23. package/templates/scripts/__libdocs/meta/ci +4 -0
  24. package/templates/scripts/__libdocs/meta/cms +4 -0
  25. package/templates/scripts/__libdocs/meta/compress +4 -0
  26. package/templates/scripts/__libdocs/meta/lint +4 -0
  27. package/templates/scripts/__libdocs/meta/lint-fix +4 -0
  28. package/templates/scripts/__libdocs/meta/serve +4 -0
  29. package/templates/scripts/__libdocs/meta/test +4 -0
  30. package/templates/scripts/__libdocs/meta/test-watch +4 -0
  31. package/templates/scripts/__module/hooks/pre-commit +11 -0
  32. package/templates/scripts/__module/release +4 -0
  33. package/templates/scripts/__monorepo/hooks/pre-commit +11 -0
  34. package/templates/scripts/__monorepo/local/build +5 -0
  35. package/templates/scripts/__monorepo/local/build-prod +5 -0
  36. package/templates/scripts/__monorepo/local/ci +5 -0
  37. package/templates/scripts/__monorepo/local/cms +5 -0
  38. package/templates/scripts/__monorepo/local/compress +5 -0
  39. package/templates/scripts/__monorepo/local/lint +5 -0
  40. package/templates/scripts/__monorepo/local/lint-fix +5 -0
  41. package/templates/scripts/__monorepo/local/release +5 -0
  42. package/templates/scripts/__monorepo/local/serve +5 -0
  43. package/templates/scripts/__monorepo/local/test +5 -0
  44. package/templates/scripts/__monorepo/local/test-watch +6 -0
  45. package/templates/scripts/__monorepo/meta/build +4 -0
  46. package/templates/scripts/__monorepo/meta/build-prod +4 -0
  47. package/templates/scripts/__monorepo/meta/ci +4 -0
  48. package/templates/scripts/__monorepo/meta/cms +4 -0
  49. package/templates/scripts/__monorepo/meta/compress +4 -0
  50. package/templates/scripts/__monorepo/meta/lint +4 -0
  51. package/templates/scripts/__monorepo/meta/lint-fix +4 -0
  52. package/templates/scripts/__monorepo/meta/release +5 -0
  53. package/templates/scripts/__monorepo/meta/serve +4 -0
  54. package/templates/scripts/__monorepo/meta/test +4 -0
  55. package/templates/scripts/__monorepo/meta/test-watch +4 -0
  56. package/templates/scripts/docs/build +0 -4
  57. package/templates/scripts/docs/build-prod +0 -4
  58. package/templates/scripts/docs/cms +0 -4
  59. package/templates/scripts/docs/serve +0 -4
  60. /package/templates/scripts/{hooks → __libdocs/hooks}/pre-commit +0 -0
  61. /package/templates/scripts/{lib → __libdocs/meta}/release +0 -0
  62. /package/templates/scripts/{ci → __module/ci} +0 -0
  63. /package/templates/scripts/{compress → __module/compress} +0 -0
  64. /package/templates/scripts/{lint → __module/lint} +0 -0
  65. /package/templates/scripts/{lint-fix → __module/lint-fix} +0 -0
  66. /package/templates/scripts/{lib → __module}/test +0 -0
  67. /package/templates/scripts/{lib → __module}/test-watch +0 -0
@@ -2,44 +2,45 @@ import { writeJson } from 'firost';
2
2
 
3
3
  import helper from 'aberlaas-helper';
4
4
  import {
5
- aberlaasVersion,
6
5
  lernaVersion,
7
6
  nodeVersion,
8
7
  norskaThemeDocsVersion,
9
8
  norskaVersion,
10
9
  yarnVersion,
11
10
  } from 'aberlaas-versions';
12
- import initHelper from './helper.js';
11
+ import initHelper from '../helper.js';
13
12
 
14
13
  export default {
15
14
  /**
16
- * Create the top-level monorepo root workspace
15
+ * Create the top-level workspace
17
16
  */
18
17
  async createRootWorkspace() {
18
+ const aberlaasVersion = this.__getAberlaasVersion();
19
19
  const sharedProjectData = await this.getSharedProjectData();
20
+ const engines = {
21
+ node: `>=${nodeVersion}`,
22
+ };
20
23
 
21
24
  const packageContent = {
25
+ // Name and version
26
+ name: `${sharedProjectData.name}-root`,
27
+
22
28
  // Visibility
23
29
  private: true,
24
30
  workspaces: ['docs', 'lib'],
25
31
 
26
- // Name and version
27
- name: `${sharedProjectData.name}-monorepo`,
28
- version: '0.0.1',
29
-
30
32
  // Metadata
31
33
  author: sharedProjectData.author,
32
- description: `${sharedProjectData.name} monorepo`,
34
+ description: `${sharedProjectData.name} root workspace`,
33
35
  repository: sharedProjectData.repository,
34
36
  homepage: sharedProjectData.homepage,
35
37
 
36
38
  // Compatibility
37
39
  type: 'module',
38
40
  license: sharedProjectData.license,
41
+ engines,
39
42
  packageManager: `yarn@${yarnVersion}`,
40
43
 
41
- // Exports
42
-
43
44
  // Dependencies
44
45
  dependencies: {},
45
46
  devDependencies: {
@@ -49,35 +50,23 @@ export default {
49
50
 
50
51
  // Scripts
51
52
  scripts: {
52
- // ==> Docs-specific
53
- build: './scripts/docs/build',
54
- 'build:prod': './scripts/docs/build-prod',
55
- cms: './scripts/docs/cms',
56
- serve: './scripts/docs/serve',
57
- // ==> Lib-specific
58
- release: './scripts/lib/release',
59
- test: './scripts/lib/test',
60
- 'test:watch': './scripts/lib/test-watch',
61
- // Common
62
- ci: './scripts/ci',
63
- compress: './scripts/compress',
64
- lint: './scripts/lint',
65
- 'lint:fix': './scripts/lint-fix',
66
-
67
- // Global (called as aliases from any workspace)
68
- // ==> Docs-specific
69
- 'g:build': './scripts/docs/build',
70
- 'g:build:prod': './scripts/docs/build-prod',
71
- 'g:cms': './scripts/docs/cms',
72
- 'g:serve': './scripts/docs/serve',
73
- // ==> Lib-specific
74
- 'g:release': './scripts/lib/release',
75
- 'g:test': './scripts/lib/test',
76
- 'g:test:watch': './scripts/lib/test-watch',
77
- // Common
78
- 'g:compress': './scripts/compress',
79
- 'g:lint': './scripts/lint',
80
- 'g:lint:fix': './scripts/lint-fix',
53
+ // Docs
54
+ build: './scripts/meta/build',
55
+ 'build:prod': './scripts/meta/build-prod',
56
+ cms: './scripts/meta/cms',
57
+ serve: './scripts/meta/serve',
58
+
59
+ // Lib
60
+ release: './scripts/meta/release',
61
+ test: './scripts/meta/test',
62
+ 'test:watch': './scripts/meta/test-watch',
63
+ ci: './scripts/meta/ci',
64
+ compress: './scripts/meta/compress',
65
+ lint: './scripts/meta/lint',
66
+ 'lint:fix': './scripts/meta/lint-fix',
67
+
68
+ // Typo
69
+ learn: 'lerna',
81
70
  },
82
71
  };
83
72
  await writeJson(packageContent, helper.hostPath('./package.json'), {
@@ -91,13 +80,13 @@ export default {
91
80
  const sharedProjectData = await this.getSharedProjectData();
92
81
 
93
82
  const packageContent = {
94
- // Visibility
95
- private: true,
96
-
97
83
  // Name & Version
98
84
  name: `${sharedProjectData.name}-docs`,
99
85
  version: '0.0.1',
100
86
 
87
+ // Visibility
88
+ private: true,
89
+
101
90
  // Metadata
102
91
  author: sharedProjectData.author,
103
92
  description: `${sharedProjectData.name} docs`,
@@ -107,8 +96,6 @@ export default {
107
96
  // Compatibility
108
97
  license: sharedProjectData.license,
109
98
 
110
- // Exports
111
-
112
99
  // Dependencies
113
100
  dependencies: {
114
101
  norska: norskaVersion,
@@ -133,13 +120,13 @@ export default {
133
120
  };
134
121
 
135
122
  const packageContent = {
136
- // Visibility
137
- private: false,
138
-
139
123
  // Name and version
140
124
  name: sharedProjectData.name,
141
125
  version: '0.0.1',
142
126
 
127
+ // Visibility
128
+ private: false,
129
+
143
130
  // Metadata
144
131
  author: sharedProjectData.author,
145
132
  description: '',
@@ -189,28 +176,6 @@ export default {
189
176
  // Lerna
190
177
  await initHelper.copyTemplateToHost('lerna.json', 'lerna.json');
191
178
  },
192
- /**
193
- * Add scripts to the repo
194
- */
195
- async addScripts() {
196
- // Common scripts
197
- await initHelper.addScripts('LICENSE');
198
-
199
- // Docs scripts
200
- await initHelper.copyTemplateToHost(
201
- 'scripts/docs/build',
202
- 'scripts/docs/build',
203
- );
204
- await initHelper.copyTemplateToHost(
205
- 'scripts/docs/build-prod',
206
- 'scripts/docs/build-prod',
207
- );
208
- await initHelper.copyTemplateToHost('scripts/docs/cms', 'scripts/docs/cms');
209
- await initHelper.copyTemplateToHost(
210
- 'scripts/docs/serve',
211
- 'scripts/docs/serve',
212
- );
213
- },
214
179
  /**
215
180
  * Returns shared project data, like name, author, scripts, etc
216
181
  * @returns {object} Object of common keys
@@ -222,21 +187,17 @@ export default {
222
187
  const repository = `${author}/${name}`;
223
188
  const license = 'MIT';
224
189
  const scripts = {
225
- // Docs
226
- build: 'ABERLAAS_CWD=$INIT_CWD yarn g:build',
227
- 'build:prod': 'ABERLAAS_CWD=$INIT_CWD yarn g:build:prod',
228
- cms: 'ABERLAAS_CWD=$INIT_CWD yarn g:cms',
229
- serve: 'ABERLAAS_CWD=$INIT_CWD yarn g:serve',
230
-
231
- // Lib
232
- release: 'ABERLAAS_CWD=$INIT_CWD yarn g:release',
233
- test: 'ABERLAAS_CWD=$INIT_CWD yarn g:test',
234
- 'test:watch': 'ABERLAAS_CWD=$INIT_CWD yarn g:test:watch',
235
-
236
- // Common
237
- compress: 'ABERLAAS_CWD=$INIT_CWD yarn g:compress',
238
- lint: 'ABERLAAS_CWD=$INIT_CWD yarn g:lint',
239
- 'lint:fix': 'ABERLAAS_CWD=$INIT_CWD yarn g:lint:fix',
190
+ build: '../scripts/local/build',
191
+ 'build:prod': '../scripts/local/build-prod',
192
+ cms: '../scripts/local/cms',
193
+ serve: '../scripts/local/serve',
194
+ ci: '../scripts/local/ci',
195
+ release: '../scripts/local/release',
196
+ test: '../scripts/local/test',
197
+ 'test:watch': '../scripts/local/test-watch',
198
+ compress: '../scripts/local/compress',
199
+ lint: '../scripts/local/lint',
200
+ 'lint:fix': '../scripts/local/lint-fix',
240
201
  };
241
202
  return {
242
203
  author,
@@ -248,7 +209,9 @@ export default {
248
209
  };
249
210
  },
250
211
  /**
251
- * Scaffold a repo for use in a monorepo module contexte
212
+ * Scaffold a repo:
213
+ * - As a monorepo
214
+ * - With ./libs and ./docs subfolders
252
215
  */
253
216
  async run() {
254
217
  await this.createRootWorkspace();
@@ -256,10 +219,11 @@ export default {
256
219
  await this.createLibWorkspace();
257
220
 
258
221
  await this.addLicenseFiles();
259
- await this.addScripts();
260
222
  await this.addConfigFiles();
223
+ await initHelper.addScripts('__libdocs');
261
224
  await initHelper.addLibFiles();
262
225
  },
263
226
  __getProjectName: initHelper.getProjectName,
264
227
  __getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
228
+ __getAberlaasVersion: initHelper.getAberlaasVersion,
265
229
  };
@@ -1,14 +1,14 @@
1
1
  import { writeJson } from 'firost';
2
-
3
- import { aberlaasVersion, nodeVersion, yarnVersion } from 'aberlaas-versions';
2
+ import { nodeVersion, yarnVersion } from 'aberlaas-versions';
4
3
  import helper from 'aberlaas-helper';
5
- import initHelper from './helper.js';
4
+ import initHelper from '../helper.js';
6
5
 
7
6
  export default {
8
7
  /**
9
- * Create the top-level package.json
8
+ * Create the package.json
10
9
  */
11
10
  async createPackageJson() {
11
+ const aberlaasVersion = this.__getAberlaasVersion();
12
12
  const name = await this.__getProjectName();
13
13
  const version = '0.0.1';
14
14
 
@@ -16,7 +16,7 @@ export default {
16
16
  const description = '';
17
17
  const keywords = [];
18
18
  const repository = `${author}/${name}`;
19
- const homepage = `https://projects.pixelastic.com/${name}`;
19
+ const homepage = `https://github.com/${repository}`;
20
20
 
21
21
  const type = 'module';
22
22
  const sideEffects = false;
@@ -26,11 +26,11 @@ export default {
26
26
  };
27
27
  const packageManager = `yarn@${yarnVersion}`;
28
28
 
29
- const files = ['*.js'];
29
+ const files = ['lib/*.js'];
30
30
  const exports = {
31
- '.': './main.js',
31
+ '.': './lib/main.js',
32
32
  };
33
- const main = './main.js';
33
+ const main = './lib/main.js';
34
34
 
35
35
  const dependencies = {};
36
36
  const devDependencies = {
@@ -38,20 +38,13 @@ export default {
38
38
  };
39
39
 
40
40
  const scripts = {
41
- // Docs
42
- build: './scripts/docs/build',
43
- 'build:prod': './scripts/docs/build-prod',
44
- cms: './scripts/docs/cms',
45
- serve: './scripts/docs/serve',
46
- // Lib
47
- release: './scripts/lib/release',
48
- test: './scripts/lib/test',
49
- 'test:watch': './scripts/lib/test-watch',
50
- // Common
51
41
  ci: './scripts/ci',
52
42
  compress: './scripts/compress',
53
43
  lint: './scripts/lint',
54
44
  'lint:fix': './scripts/lint-fix',
45
+ test: './scripts/test',
46
+ 'test:watch': './scripts/test-watch',
47
+ release: './scripts/release',
55
48
  };
56
49
 
57
50
  const packageContent = {
@@ -92,16 +85,18 @@ export default {
92
85
  },
93
86
 
94
87
  /**
95
- * Scaffold a repo for use in a simple module contexte
88
+ * Scaffold a repo:
89
+ * - With ./lib holding the code
96
90
  */
97
91
  async run() {
98
92
  await this.createPackageJson();
99
93
 
100
94
  await initHelper.addLicenseFile('LICENSE');
101
95
  await initHelper.addConfigFiles();
102
- await initHelper.addScripts();
96
+ await initHelper.addScripts('__module');
103
97
  await initHelper.addLibFiles();
104
98
  },
105
- __getProjectName: initHelper.getProjectName.bind(initHelper),
99
+ __getProjectName: initHelper.getProjectName,
106
100
  __getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
101
+ __getAberlaasVersion: initHelper.getAberlaasVersion,
107
102
  };
@@ -0,0 +1,240 @@
1
+ import { writeJson } from 'firost';
2
+
3
+ import helper from 'aberlaas-helper';
4
+ import {
5
+ lernaVersion,
6
+ nodeVersion,
7
+ norskaThemeDocsVersion,
8
+ norskaVersion,
9
+ yarnVersion,
10
+ } from 'aberlaas-versions';
11
+ import initHelper from '../helper.js';
12
+
13
+ export default {
14
+ /**
15
+ * Scaffold a repo:
16
+ * - As a monorepo
17
+ * - With ./modules holding all modules, including ./lib and ./docs
18
+ */
19
+ async createRootWorkspace() {
20
+ const aberlaasVersion = this.__getAberlaasVersion();
21
+ const sharedProjectData = await this.getSharedProjectData();
22
+ const engines = {
23
+ node: `>=${nodeVersion}`,
24
+ };
25
+
26
+ const packageContent = {
27
+ // Name and version
28
+ name: `${sharedProjectData.name}-monorepo`,
29
+
30
+ // Visibility
31
+ private: true,
32
+ workspaces: ['modules/*'],
33
+
34
+ // Metadata
35
+ author: sharedProjectData.author,
36
+ description: `${sharedProjectData.name} monorepo`,
37
+ repository: sharedProjectData.repository,
38
+ homepage: sharedProjectData.homepage,
39
+
40
+ // Compatibility
41
+ type: 'module',
42
+ license: sharedProjectData.license,
43
+ engines,
44
+ packageManager: `yarn@${yarnVersion}`,
45
+
46
+ // Dependencies
47
+ dependencies: {},
48
+ devDependencies: {
49
+ aberlaas: aberlaasVersion,
50
+ lerna: lernaVersion,
51
+ },
52
+
53
+ // Scripts
54
+ scripts: {
55
+ // Docs
56
+ build: './scripts/meta/build',
57
+ 'build:prod': './scripts/meta/build-prod',
58
+ cms: './scripts/meta/cms',
59
+ serve: './scripts/meta/serve',
60
+
61
+ // Lib
62
+ release: './scripts/meta/release',
63
+ test: './scripts/meta/test',
64
+ 'test:watch': './scripts/meta/test-watch',
65
+ ci: './scripts/meta/ci',
66
+ compress: './scripts/meta/compress',
67
+ lint: './scripts/meta/lint',
68
+ 'lint:fix': './scripts/meta/lint-fix',
69
+
70
+ // Typo
71
+ learn: 'lerna',
72
+ },
73
+ };
74
+ await writeJson(packageContent, helper.hostPath('./package.json'), {
75
+ sort: false,
76
+ });
77
+ },
78
+ /**
79
+ * Create the docs workspace
80
+ */
81
+ async createDocsWorkspace() {
82
+ const sharedProjectData = await this.getSharedProjectData();
83
+
84
+ const packageContent = {
85
+ // Name & Version
86
+ name: `${sharedProjectData.name}-docs`,
87
+ version: '0.0.1',
88
+
89
+ // Visibility
90
+ private: true,
91
+
92
+ // Metadata
93
+ author: sharedProjectData.author,
94
+ description: `${sharedProjectData.name} docs`,
95
+ repository: sharedProjectData.repository,
96
+ homepage: sharedProjectData.homepage,
97
+
98
+ // Compatibility
99
+ // "type": "module", // TODO: Uncomment once norska is ESM-compliant
100
+ license: sharedProjectData.license,
101
+
102
+ // Dependencies
103
+ dependencies: {
104
+ norska: norskaVersion,
105
+ 'norska-theme-docs': norskaThemeDocsVersion,
106
+ },
107
+ devDependencies: {},
108
+
109
+ // Scripts
110
+ scripts: sharedProjectData.scripts,
111
+ };
112
+ await writeJson(
113
+ packageContent,
114
+ helper.hostPath('./modules/docs/package.json'),
115
+ {
116
+ sort: false,
117
+ },
118
+ );
119
+ },
120
+ /**
121
+ * Create the lib workspace
122
+ */
123
+ async createLibWorkspace() {
124
+ const sharedProjectData = await this.getSharedProjectData();
125
+ const engines = {
126
+ node: `>=${nodeVersion}`,
127
+ };
128
+
129
+ const packageContent = {
130
+ // Name and version
131
+ name: sharedProjectData.name,
132
+ version: '0.0.1',
133
+
134
+ // Visibility
135
+ private: false,
136
+
137
+ // Metadata
138
+ author: sharedProjectData.author,
139
+ description: '',
140
+ keywords: [],
141
+ repository: sharedProjectData.repository,
142
+ homepage: sharedProjectData.homepage,
143
+
144
+ // Compatibility
145
+ type: 'module',
146
+ sideEffects: false,
147
+ license: sharedProjectData.license,
148
+ engines,
149
+
150
+ // Exports
151
+ files: ['*.js'],
152
+ exports: {
153
+ '.': './main.js',
154
+ },
155
+ main: './main.js',
156
+
157
+ // Dependencies
158
+ dependencies: {},
159
+ devDependencies: {},
160
+
161
+ // Scripts
162
+ scripts: sharedProjectData.scripts,
163
+ };
164
+ await writeJson(
165
+ packageContent,
166
+ helper.hostPath('./modules/lib/package.json'),
167
+ {
168
+ sort: false,
169
+ },
170
+ );
171
+ },
172
+ /**
173
+ * Add MIT license files to the repository
174
+ */
175
+ async addLicenseFiles() {
176
+ // One at the repo root, for GitHub
177
+ await initHelper.addLicenseFile('LICENSE');
178
+ // One in ./lib to be released with the module
179
+ await initHelper.addLicenseFile('modules/lib/LICENSE');
180
+ },
181
+ /**
182
+ * Add config files
183
+ */
184
+ async addConfigFiles() {
185
+ await initHelper.addConfigFiles();
186
+
187
+ // Lerna
188
+ await initHelper.copyTemplateToHost('lerna.json', 'lerna.json');
189
+ },
190
+ /**
191
+ * Returns shared project data, like name, author, scripts, etc
192
+ * @returns {object} Object of common keys
193
+ */
194
+ async getSharedProjectData() {
195
+ const name = await this.__getProjectName();
196
+ const author = await this.__getProjectAuthor();
197
+ const homepage = `https://projects.pixelastic.com/${name}`;
198
+ const repository = `${author}/${name}`;
199
+ const license = 'MIT';
200
+ const scripts = {
201
+ build: '../../scripts/local/build',
202
+ 'build:prod': '../../scripts/local/build-prod',
203
+ cms: '../../scripts/local/cms',
204
+ serve: '../../scripts/local/serve',
205
+ ci: '../../scripts/local/ci',
206
+ release: '../../scripts/local/release',
207
+ test: '../../scripts/local/test',
208
+ 'test:watch': '../../scripts/local/test-watch',
209
+ compress: '../../scripts/local/compress',
210
+ lint: '../../scripts/local/lint',
211
+ 'lint:fix': '../../scripts/local/lint-fix',
212
+ };
213
+ return {
214
+ author,
215
+ homepage,
216
+ license,
217
+ name,
218
+ repository,
219
+ scripts,
220
+ };
221
+ },
222
+ /**
223
+ * Scaffold a repo:
224
+ * - As a monorepo
225
+ * - With ./libs and ./docs subfolders
226
+ */
227
+ async run() {
228
+ await this.createRootWorkspace();
229
+ await this.createDocsWorkspace();
230
+ await this.createLibWorkspace();
231
+
232
+ await this.addLicenseFiles();
233
+ await this.addConfigFiles();
234
+ await initHelper.addScripts('__monorepo');
235
+ await initHelper.addLibFiles('./modules/lib');
236
+ },
237
+ __getProjectName: initHelper.getProjectName,
238
+ __getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
239
+ __getAberlaasVersion: initHelper.getAberlaasVersion,
240
+ };
package/lib/main.js CHANGED
@@ -1,10 +1,11 @@
1
- import { consoleInfo, run, spinner, write } from 'firost';
1
+ import { consoleInfo, firostError, run, spinner, write } from 'firost';
2
2
 
3
3
  import Gilmore from 'gilmore';
4
4
  import helper from 'aberlaas-helper';
5
5
  import { nodeVersion } from 'aberlaas-versions';
6
- import initMonorepo from './monorepo.js';
7
- import initModule from './module.js';
6
+ import moduleLayout from './layouts/module.js';
7
+ import libdocsLayout from './layouts/libdocs.js';
8
+ import monorepoLayout from './layouts/monorepo.js';
8
9
 
9
10
  export default {
10
11
  /**
@@ -27,13 +28,32 @@ export default {
27
28
  async yarnInstall() {
28
29
  await run('yarn install');
29
30
  },
31
+ /**
32
+ * Returns the correct layout object, based on args
33
+ * @param {object} args Arguments, as passed by minimist
34
+ * @returns {object} Object with a .run() method
35
+ **/
36
+ getLayout(args) {
37
+ if (args.monorepo && args.libdocs) {
38
+ throw firostError(
39
+ 'ABERLAAS_INIT_LAYOUT_INCOMPATIBLE',
40
+ "You can't specific both --monorepo and --libdocs",
41
+ );
42
+ }
43
+
44
+ if (args.monorepo) {
45
+ return this.__monorepoLayout();
46
+ }
47
+ if (args.libdocs) {
48
+ return this.__libdocsLayout();
49
+ }
50
+ return this.__moduleLayout();
51
+ },
30
52
  /**
31
53
  * Copy all config files and configure the scripts
32
54
  * @param {object} args Argument object, as passed by minimist
33
55
  */
34
56
  async run(args = {}) {
35
- const isMonorepo = args.monorepo;
36
-
37
57
  const progress = this.__spinner();
38
58
 
39
59
  progress.tick('Configuring Git & Node');
@@ -43,7 +63,8 @@ export default {
43
63
  progress.tick('Adding default files ');
44
64
 
45
65
  // Create a different scaffolding based on if creating a monorepo or not
46
- isMonorepo ? await initMonorepo.run() : await initModule.run();
66
+ const layout = this.getLayout(args);
67
+ await layout.run();
47
68
 
48
69
  progress.success('aberlaas project initialized');
49
70
 
@@ -56,4 +77,14 @@ export default {
56
77
  },
57
78
  __consoleInfo: consoleInfo,
58
79
  __spinner: spinner,
80
+ // Why the old-school getters? So we can mock which layout is returned
81
+ __moduleLayout() {
82
+ return moduleLayout;
83
+ },
84
+ __libdocsLayout() {
85
+ return libdocsLayout;
86
+ },
87
+ __monorepoLayout() {
88
+ return monorepoLayout;
89
+ },
59
90
  };
package/package.json CHANGED
@@ -2,13 +2,14 @@
2
2
  "name": "aberlaas-init",
3
3
  "type": "module",
4
4
  "description": "aberlaas init command: Setup the repository with all needed config",
5
- "version": "2.12.0",
5
+ "version": "2.14.0",
6
6
  "repository": "pixelastic/aberlaas",
7
7
  "homepage": "https://projects.pixelastic.com/aberlaas/",
8
8
  "author": "Tim Carry (@pixelastic)",
9
9
  "license": "MIT",
10
10
  "files": [
11
11
  "lib/*.js",
12
+ "lib/layouts/",
12
13
  "templates/"
13
14
  ],
14
15
  "exports": {
@@ -25,7 +26,7 @@
25
26
  "serve": "../../scripts/local/serve",
26
27
  "ci": "../../scripts/local/ci",
27
28
  "release": "../../scripts/local/release",
28
- "update": "node ../../scripts/meta/update.js",
29
+ "update-dependencies": "node ../../scripts/meta/update-dependencies.js",
29
30
  "test:meta": "../../scripts/local/test-meta",
30
31
  "test": "../../scripts/local/test",
31
32
  "test:watch": "../../scripts/local/test-watch",
@@ -34,10 +35,11 @@
34
35
  "lint:fix": "../../scripts/local/lint-fix"
35
36
  },
36
37
  "dependencies": {
37
- "aberlaas-helper": "^2.10.0",
38
- "aberlaas-versions": "^2.10.0",
39
- "firost": "4.3.0",
40
- "gilmore": "1.0.0"
38
+ "aberlaas-helper": "^2.14.0",
39
+ "aberlaas-versions": "^2.14.0",
40
+ "firost": "5.0.0",
41
+ "gilmore": "1.0.0",
42
+ "golgoth": "3.0.0"
41
43
  },
42
- "gitHead": "208f1d76e2843fbe54c2bfb442d28675b217dccf"
44
+ "gitHead": "b11b18726a6b600b33161e5d3fee313565a2a214"
43
45
  }
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ cd ..
5
+ ./scripts/meta/build "$@"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ cd ..
5
+ ./scripts/meta/build-prod "$@"