aberlaas-init 2.10.0 → 2.13.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 (68) hide show
  1. package/lib/helper.js +32 -25
  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} +39 -78
  6. package/lib/{module.js → layouts/module.js} +18 -21
  7. package/lib/layouts/monorepo.js +236 -0
  8. package/lib/main.js +37 -6
  9. package/package.json +6 -5
  10. package/templates/_yarnrc.yml +1 -0
  11. package/templates/scripts/__libdocs/local/build +5 -0
  12. package/templates/scripts/__libdocs/local/build-prod +5 -0
  13. package/templates/scripts/__libdocs/local/ci +5 -0
  14. package/templates/scripts/__libdocs/local/cms +4 -0
  15. package/templates/scripts/__libdocs/local/compress +5 -0
  16. package/templates/scripts/__libdocs/local/lint +5 -0
  17. package/templates/scripts/__libdocs/local/lint-fix +5 -0
  18. package/templates/scripts/__libdocs/local/release +5 -0
  19. package/templates/scripts/__libdocs/local/serve +5 -0
  20. package/templates/scripts/__libdocs/local/test +5 -0
  21. package/templates/scripts/__libdocs/local/test-watch +6 -0
  22. package/templates/scripts/__libdocs/meta/build +4 -0
  23. package/templates/scripts/__libdocs/meta/build-prod +4 -0
  24. package/templates/scripts/__libdocs/meta/ci +4 -0
  25. package/templates/scripts/__libdocs/meta/cms +4 -0
  26. package/templates/scripts/__libdocs/meta/compress +4 -0
  27. package/templates/scripts/__libdocs/meta/lint +4 -0
  28. package/templates/scripts/__libdocs/meta/lint-fix +4 -0
  29. package/templates/scripts/__libdocs/meta/serve +4 -0
  30. package/templates/scripts/__libdocs/meta/test +4 -0
  31. package/templates/scripts/__libdocs/meta/test-watch +4 -0
  32. package/templates/scripts/__module/hooks/pre-commit +11 -0
  33. package/templates/scripts/__module/release +4 -0
  34. package/templates/scripts/__monorepo/hooks/pre-commit +11 -0
  35. package/templates/scripts/__monorepo/local/build +5 -0
  36. package/templates/scripts/__monorepo/local/build-prod +5 -0
  37. package/templates/scripts/__monorepo/local/ci +5 -0
  38. package/templates/scripts/__monorepo/local/cms +5 -0
  39. package/templates/scripts/__monorepo/local/compress +5 -0
  40. package/templates/scripts/__monorepo/local/lint +5 -0
  41. package/templates/scripts/__monorepo/local/lint-fix +5 -0
  42. package/templates/scripts/__monorepo/local/release +5 -0
  43. package/templates/scripts/__monorepo/local/serve +5 -0
  44. package/templates/scripts/__monorepo/local/test +5 -0
  45. package/templates/scripts/__monorepo/local/test-watch +6 -0
  46. package/templates/scripts/__monorepo/meta/build +4 -0
  47. package/templates/scripts/__monorepo/meta/build-prod +4 -0
  48. package/templates/scripts/__monorepo/meta/ci +4 -0
  49. package/templates/scripts/__monorepo/meta/cms +4 -0
  50. package/templates/scripts/__monorepo/meta/compress +4 -0
  51. package/templates/scripts/__monorepo/meta/lint +4 -0
  52. package/templates/scripts/__monorepo/meta/lint-fix +4 -0
  53. package/templates/scripts/__monorepo/meta/release +5 -0
  54. package/templates/scripts/__monorepo/meta/serve +4 -0
  55. package/templates/scripts/__monorepo/meta/test +4 -0
  56. package/templates/scripts/__monorepo/meta/test-watch +4 -0
  57. package/templates/scripts/docs/build +0 -4
  58. package/templates/scripts/docs/build-prod +0 -4
  59. package/templates/scripts/docs/cms +0 -4
  60. package/templates/scripts/docs/serve +0 -4
  61. /package/templates/scripts/{hooks → __libdocs/hooks}/pre-commit +0 -0
  62. /package/templates/scripts/{lib → __libdocs/meta}/release +0 -0
  63. /package/templates/scripts/{ci → __module/ci} +0 -0
  64. /package/templates/scripts/{compress → __module/compress} +0 -0
  65. /package/templates/scripts/{lint → __module/lint} +0 -0
  66. /package/templates/scripts/{lint-fix → __module/lint-fix} +0 -0
  67. /package/templates/scripts/{lib → __module}/test +0 -0
  68. /package/templates/scripts/{lib → __module}/test-watch +0 -0
@@ -2,20 +2,20 @@ 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
20
 
21
21
  const packageContent = {
@@ -24,12 +24,11 @@ export default {
24
24
  workspaces: ['docs', 'lib'],
25
25
 
26
26
  // Name and version
27
- name: `${sharedProjectData.name}-monorepo`,
28
- version: '0.0.1',
27
+ name: `${sharedProjectData.name}-root`,
29
28
 
30
29
  // Metadata
31
30
  author: sharedProjectData.author,
32
- description: `${sharedProjectData.name} monorepo`,
31
+ description: `${sharedProjectData.name} root workspace`,
33
32
  repository: sharedProjectData.repository,
34
33
  homepage: sharedProjectData.homepage,
35
34
 
@@ -38,8 +37,6 @@ export default {
38
37
  license: sharedProjectData.license,
39
38
  packageManager: `yarn@${yarnVersion}`,
40
39
 
41
- // Exports
42
-
43
40
  // Dependencies
44
41
  dependencies: {},
45
42
  devDependencies: {
@@ -49,35 +46,23 @@ export default {
49
46
 
50
47
  // Scripts
51
48
  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',
49
+ // Docs
50
+ build: './scripts/meta/build',
51
+ 'build:prod': './scripts/meta/build-prod',
52
+ cms: './scripts/meta/cms',
53
+ serve: './scripts/meta/serve',
54
+
55
+ // Lib
56
+ release: './scripts/meta/release',
57
+ test: './scripts/meta/test',
58
+ 'test:watch': './scripts/meta/test-watch',
59
+ ci: './scripts/meta/ci',
60
+ compress: './scripts/meta/compress',
61
+ lint: './scripts/meta/lint',
62
+ 'lint:fix': './scripts/meta/lint-fix',
63
+
64
+ // Typo
65
+ learn: 'lerna',
81
66
  },
82
67
  };
83
68
  await writeJson(packageContent, helper.hostPath('./package.json'), {
@@ -107,8 +92,6 @@ export default {
107
92
  // Compatibility
108
93
  license: sharedProjectData.license,
109
94
 
110
- // Exports
111
-
112
95
  // Dependencies
113
96
  dependencies: {
114
97
  norska: norskaVersion,
@@ -149,6 +132,7 @@ export default {
149
132
 
150
133
  // Compatibility
151
134
  type: 'module',
135
+ sideEffects: false,
152
136
  license: sharedProjectData.license,
153
137
  engines,
154
138
 
@@ -188,28 +172,6 @@ export default {
188
172
  // Lerna
189
173
  await initHelper.copyTemplateToHost('lerna.json', 'lerna.json');
190
174
  },
191
- /**
192
- * Add scripts to the repo
193
- */
194
- async addScripts() {
195
- // Common scripts
196
- await initHelper.addScripts('LICENSE');
197
-
198
- // Docs scripts
199
- await initHelper.copyTemplateToHost(
200
- 'scripts/docs/build',
201
- 'scripts/docs/build',
202
- );
203
- await initHelper.copyTemplateToHost(
204
- 'scripts/docs/build-prod',
205
- 'scripts/docs/build-prod',
206
- );
207
- await initHelper.copyTemplateToHost('scripts/docs/cms', 'scripts/docs/cms');
208
- await initHelper.copyTemplateToHost(
209
- 'scripts/docs/serve',
210
- 'scripts/docs/serve',
211
- );
212
- },
213
175
  /**
214
176
  * Returns shared project data, like name, author, scripts, etc
215
177
  * @returns {object} Object of common keys
@@ -221,21 +183,17 @@ export default {
221
183
  const repository = `${author}/${name}`;
222
184
  const license = 'MIT';
223
185
  const scripts = {
224
- // Docs
225
- build: 'ABERLAAS_CWD=$INIT_CWD yarn g:build',
226
- 'build:prod': 'ABERLAAS_CWD=$INIT_CWD yarn g:build:prod',
227
- cms: 'ABERLAAS_CWD=$INIT_CWD yarn g:cms',
228
- serve: 'ABERLAAS_CWD=$INIT_CWD yarn g:serve',
229
-
230
- // Lib
231
- release: 'ABERLAAS_CWD=$INIT_CWD yarn g:release',
232
- test: 'ABERLAAS_CWD=$INIT_CWD yarn g:test',
233
- 'test:watch': 'ABERLAAS_CWD=$INIT_CWD yarn g:test:watch',
234
-
235
- // Common
236
- compress: 'ABERLAAS_CWD=$INIT_CWD yarn g:compress',
237
- lint: 'ABERLAAS_CWD=$INIT_CWD yarn g:lint',
238
- 'lint:fix': 'ABERLAAS_CWD=$INIT_CWD yarn g:lint:fix',
186
+ build: '../scripts/local/build',
187
+ 'build:prod': '../scripts/local/build-prod',
188
+ cms: '../scripts/local/cms',
189
+ serve: '../scripts/local/serve',
190
+ ci: '../scripts/local/ci',
191
+ release: '../scripts/local/release',
192
+ test: '../scripts/local/test',
193
+ 'test:watch': '../scripts/local/test-watch',
194
+ compress: '../scripts/local/compress',
195
+ lint: '../scripts/local/lint',
196
+ 'lint:fix': '../scripts/local/lint-fix',
239
197
  };
240
198
  return {
241
199
  author,
@@ -247,7 +205,9 @@ export default {
247
205
  };
248
206
  },
249
207
  /**
250
- * Scaffold a repo for use in a monorepo module contexte
208
+ * Scaffold a repo:
209
+ * - As a monorepo
210
+ * - With ./libs and ./docs subfolders
251
211
  */
252
212
  async run() {
253
213
  await this.createRootWorkspace();
@@ -255,10 +215,11 @@ export default {
255
215
  await this.createLibWorkspace();
256
216
 
257
217
  await this.addLicenseFiles();
258
- await this.addScripts();
259
218
  await this.addConfigFiles();
219
+ await initHelper.addScripts('__libdocs');
260
220
  await initHelper.addLibFiles();
261
221
  },
262
222
  __getProjectName: initHelper.getProjectName,
263
223
  __getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
224
+ __getAberlaasVersion: initHelper.getAberlaasVersion,
264
225
  };
@@ -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,20 +16,21 @@ 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
+ const sideEffects = false;
22
23
  const license = 'MIT';
23
24
  const engines = {
24
25
  node: `>=${nodeVersion}`,
25
26
  };
26
27
  const packageManager = `yarn@${yarnVersion}`;
27
28
 
28
- const files = ['*.js'];
29
+ const files = ['lib/*.js'];
29
30
  const exports = {
30
- '.': './main.js',
31
+ '.': './lib/main.js',
31
32
  };
32
- const main = './main.js';
33
+ const main = './lib/main.js';
33
34
 
34
35
  const dependencies = {};
35
36
  const devDependencies = {
@@ -37,20 +38,13 @@ export default {
37
38
  };
38
39
 
39
40
  const scripts = {
40
- // Docs
41
- build: './scripts/docs/build',
42
- 'build:prod': './scripts/docs/build-prod',
43
- cms: './scripts/docs/cms',
44
- serve: './scripts/docs/serve',
45
- // Lib
46
- release: './scripts/lib/release',
47
- test: './scripts/lib/test',
48
- 'test:watch': './scripts/lib/test-watch',
49
- // Common
50
41
  ci: './scripts/ci',
51
42
  compress: './scripts/compress',
52
43
  lint: './scripts/lint',
53
44
  'lint:fix': './scripts/lint-fix',
45
+ test: './scripts/test',
46
+ 'test:watch': './scripts/test-watch',
47
+ release: './scripts/release',
54
48
  };
55
49
 
56
50
  const packageContent = {
@@ -67,6 +61,7 @@ export default {
67
61
 
68
62
  // Compatibility
69
63
  type,
64
+ sideEffects,
70
65
  license,
71
66
  engines,
72
67
  packageManager,
@@ -90,16 +85,18 @@ export default {
90
85
  },
91
86
 
92
87
  /**
93
- * Scaffold a repo for use in a simple module contexte
88
+ * Scaffold a repo:
89
+ * - With ./lib holding the code
94
90
  */
95
91
  async run() {
96
92
  await this.createPackageJson();
97
93
 
98
94
  await initHelper.addLicenseFile('LICENSE');
99
95
  await initHelper.addConfigFiles();
100
- await initHelper.addScripts();
96
+ await initHelper.addScripts('__module');
101
97
  await initHelper.addLibFiles();
102
98
  },
103
- __getProjectName: initHelper.getProjectName.bind(initHelper),
99
+ __getProjectName: initHelper.getProjectName,
104
100
  __getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
101
+ __getAberlaasVersion: initHelper.getAberlaasVersion,
105
102
  };
@@ -0,0 +1,236 @@
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
+
23
+ const packageContent = {
24
+ // Visibility
25
+ private: true,
26
+ workspaces: ['modules/*'],
27
+
28
+ // Name and version
29
+ name: `${sharedProjectData.name}-monorepo`,
30
+
31
+ // Metadata
32
+ author: sharedProjectData.author,
33
+ description: `${sharedProjectData.name} monorepo`,
34
+ repository: sharedProjectData.repository,
35
+ homepage: sharedProjectData.homepage,
36
+
37
+ // Compatibility
38
+ type: 'module',
39
+ license: sharedProjectData.license,
40
+ packageManager: `yarn@${yarnVersion}`,
41
+
42
+ // Dependencies
43
+ dependencies: {},
44
+ devDependencies: {
45
+ aberlaas: aberlaasVersion,
46
+ lerna: lernaVersion,
47
+ },
48
+
49
+ // Scripts
50
+ scripts: {
51
+ // Docs
52
+ build: './scripts/meta/build',
53
+ 'build:prod': './scripts/meta/build-prod',
54
+ cms: './scripts/meta/cms',
55
+ serve: './scripts/meta/serve',
56
+
57
+ // Lib
58
+ release: './scripts/meta/release',
59
+ test: './scripts/meta/test',
60
+ 'test:watch': './scripts/meta/test-watch',
61
+ ci: './scripts/meta/ci',
62
+ compress: './scripts/meta/compress',
63
+ lint: './scripts/meta/lint',
64
+ 'lint:fix': './scripts/meta/lint-fix',
65
+
66
+ // Typo
67
+ learn: 'lerna',
68
+ },
69
+ };
70
+ await writeJson(packageContent, helper.hostPath('./package.json'), {
71
+ sort: false,
72
+ });
73
+ },
74
+ /**
75
+ * Create the docs workspace
76
+ */
77
+ async createDocsWorkspace() {
78
+ const sharedProjectData = await this.getSharedProjectData();
79
+
80
+ const packageContent = {
81
+ // Visibility
82
+ private: true,
83
+
84
+ // Name & Version
85
+ name: `${sharedProjectData.name}-docs`,
86
+ version: '0.0.1',
87
+
88
+ // Metadata
89
+ author: sharedProjectData.author,
90
+ description: `${sharedProjectData.name} docs`,
91
+ repository: sharedProjectData.repository,
92
+ homepage: sharedProjectData.homepage,
93
+
94
+ // Compatibility
95
+ // "type": "module", // TODO: Uncomment once norska is ESM-compliant
96
+ license: sharedProjectData.license,
97
+
98
+ // Dependencies
99
+ dependencies: {
100
+ norska: norskaVersion,
101
+ 'norska-theme-docs': norskaThemeDocsVersion,
102
+ },
103
+ devDependencies: {},
104
+
105
+ // Scripts
106
+ scripts: sharedProjectData.scripts,
107
+ };
108
+ await writeJson(
109
+ packageContent,
110
+ helper.hostPath('./modules/docs/package.json'),
111
+ {
112
+ sort: false,
113
+ },
114
+ );
115
+ },
116
+ /**
117
+ * Create the lib workspace
118
+ */
119
+ async createLibWorkspace() {
120
+ const sharedProjectData = await this.getSharedProjectData();
121
+ const engines = {
122
+ node: `>=${nodeVersion}`,
123
+ };
124
+
125
+ const packageContent = {
126
+ // Visibility
127
+ private: false,
128
+
129
+ // Name and version
130
+ name: sharedProjectData.name,
131
+ version: '0.0.1',
132
+
133
+ // Metadata
134
+ author: sharedProjectData.author,
135
+ description: '',
136
+ keywords: [],
137
+ repository: sharedProjectData.repository,
138
+ homepage: sharedProjectData.homepage,
139
+
140
+ // Compatibility
141
+ type: 'module',
142
+ sideEffects: false,
143
+ license: sharedProjectData.license,
144
+ engines,
145
+
146
+ // Exports
147
+ files: ['*.js'],
148
+ exports: {
149
+ '.': './main.js',
150
+ },
151
+ main: './main.js',
152
+
153
+ // Dependencies
154
+ dependencies: {},
155
+ devDependencies: {},
156
+
157
+ // Scripts
158
+ scripts: sharedProjectData.scripts,
159
+ };
160
+ await writeJson(
161
+ packageContent,
162
+ helper.hostPath('./modules/lib/package.json'),
163
+ {
164
+ sort: false,
165
+ },
166
+ );
167
+ },
168
+ /**
169
+ * Add MIT license files to the repository
170
+ */
171
+ async addLicenseFiles() {
172
+ // One at the repo root, for GitHub
173
+ await initHelper.addLicenseFile('LICENSE');
174
+ // One in ./lib to be released with the module
175
+ await initHelper.addLicenseFile('modules/lib/LICENSE');
176
+ },
177
+ /**
178
+ * Add config files
179
+ */
180
+ async addConfigFiles() {
181
+ await initHelper.addConfigFiles();
182
+
183
+ // Lerna
184
+ await initHelper.copyTemplateToHost('lerna.json', 'lerna.json');
185
+ },
186
+ /**
187
+ * Returns shared project data, like name, author, scripts, etc
188
+ * @returns {object} Object of common keys
189
+ */
190
+ async getSharedProjectData() {
191
+ const name = await this.__getProjectName();
192
+ const author = await this.__getProjectAuthor();
193
+ const homepage = `https://projects.pixelastic.com/${name}`;
194
+ const repository = `${author}/${name}`;
195
+ const license = 'MIT';
196
+ const scripts = {
197
+ build: '../../scripts/local/build',
198
+ 'build:prod': '../../scripts/local/build-prod',
199
+ cms: '../../scripts/local/cms',
200
+ serve: '../../scripts/local/serve',
201
+ ci: '../../scripts/local/ci',
202
+ release: '../../scripts/local/release',
203
+ test: '../../scripts/local/test',
204
+ 'test:watch': '../../scripts/local/test-watch',
205
+ compress: '../../scripts/local/compress',
206
+ lint: '../../scripts/local/lint',
207
+ 'lint:fix': '../../scripts/local/lint-fix',
208
+ };
209
+ return {
210
+ author,
211
+ homepage,
212
+ license,
213
+ name,
214
+ repository,
215
+ scripts,
216
+ };
217
+ },
218
+ /**
219
+ * Scaffold a repo:
220
+ * - As a monorepo
221
+ * - With ./libs and ./docs subfolders
222
+ */
223
+ async run() {
224
+ await this.createRootWorkspace();
225
+ await this.createDocsWorkspace();
226
+ await this.createLibWorkspace();
227
+
228
+ await this.addLicenseFiles();
229
+ await this.addConfigFiles();
230
+ await initHelper.addScripts('__monorepo');
231
+ await initHelper.addLibFiles('./modules/lib');
232
+ },
233
+ __getProjectName: initHelper.getProjectName,
234
+ __getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
235
+ __getAberlaasVersion: initHelper.getAberlaasVersion,
236
+ };
package/lib/main.js CHANGED
@@ -1,10 +1,11 @@
1
- import { consoleInfo, run, spinner, write } from 'firost';
1
+ import { consoleInfo, error as 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.10.0",
5
+ "version": "2.13.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": {
@@ -34,10 +35,10 @@
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",
38
+ "aberlaas-helper": "^2.13.0",
39
+ "aberlaas-versions": "^2.13.0",
40
+ "firost": "4.8.0",
40
41
  "gilmore": "1.0.0"
41
42
  },
42
- "gitHead": "bcdaf87c198a588e02b5539c222f611e356d3079"
43
+ "gitHead": "a8a1ee486fa1faeac6b7a524e7a6e41d5503dbc0"
43
44
  }
@@ -12,4 +12,5 @@ nodeLinker: node-modules
12
12
  nmMode: hardlinks-local
13
13
 
14
14
  # Make sure each workspace has its own local node_modules
15
+ # This greatly limit dependency leaking between modules
15
16
  nmHoistingLimits: workspaces
@@ -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 "$@"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ cd ..
5
+ ./scripts/meta/ci "$@"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ echo "TODO: Should load the CMS UI"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ cd ..
5
+ ./scripts/meta/compress "$@"
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env bash
2
+ set -e
3
+
4
+ cd ..
5
+ ./scripts/meta/lint "$@"