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.
- package/lib/helper.js +32 -25
- package/lib/layouts/__tests__/libdocs.js +222 -0
- package/lib/layouts/__tests__/module.js +130 -0
- package/lib/layouts/__tests__/monorepo.js +226 -0
- package/lib/{monorepo.js → layouts/libdocs.js} +39 -78
- package/lib/{module.js → layouts/module.js} +18 -21
- package/lib/layouts/monorepo.js +236 -0
- package/lib/main.js +37 -6
- package/package.json +6 -5
- package/templates/_yarnrc.yml +1 -0
- package/templates/scripts/__libdocs/local/build +5 -0
- package/templates/scripts/__libdocs/local/build-prod +5 -0
- package/templates/scripts/__libdocs/local/ci +5 -0
- package/templates/scripts/__libdocs/local/cms +4 -0
- package/templates/scripts/__libdocs/local/compress +5 -0
- package/templates/scripts/__libdocs/local/lint +5 -0
- package/templates/scripts/__libdocs/local/lint-fix +5 -0
- package/templates/scripts/__libdocs/local/release +5 -0
- package/templates/scripts/__libdocs/local/serve +5 -0
- package/templates/scripts/__libdocs/local/test +5 -0
- package/templates/scripts/__libdocs/local/test-watch +6 -0
- package/templates/scripts/__libdocs/meta/build +4 -0
- package/templates/scripts/__libdocs/meta/build-prod +4 -0
- package/templates/scripts/__libdocs/meta/ci +4 -0
- package/templates/scripts/__libdocs/meta/cms +4 -0
- package/templates/scripts/__libdocs/meta/compress +4 -0
- package/templates/scripts/__libdocs/meta/lint +4 -0
- package/templates/scripts/__libdocs/meta/lint-fix +4 -0
- package/templates/scripts/__libdocs/meta/serve +4 -0
- package/templates/scripts/__libdocs/meta/test +4 -0
- package/templates/scripts/__libdocs/meta/test-watch +4 -0
- package/templates/scripts/__module/hooks/pre-commit +11 -0
- package/templates/scripts/__module/release +4 -0
- package/templates/scripts/__monorepo/hooks/pre-commit +11 -0
- package/templates/scripts/__monorepo/local/build +5 -0
- package/templates/scripts/__monorepo/local/build-prod +5 -0
- package/templates/scripts/__monorepo/local/ci +5 -0
- package/templates/scripts/__monorepo/local/cms +5 -0
- package/templates/scripts/__monorepo/local/compress +5 -0
- package/templates/scripts/__monorepo/local/lint +5 -0
- package/templates/scripts/__monorepo/local/lint-fix +5 -0
- package/templates/scripts/__monorepo/local/release +5 -0
- package/templates/scripts/__monorepo/local/serve +5 -0
- package/templates/scripts/__monorepo/local/test +5 -0
- package/templates/scripts/__monorepo/local/test-watch +6 -0
- package/templates/scripts/__monorepo/meta/build +4 -0
- package/templates/scripts/__monorepo/meta/build-prod +4 -0
- package/templates/scripts/__monorepo/meta/ci +4 -0
- package/templates/scripts/__monorepo/meta/cms +4 -0
- package/templates/scripts/__monorepo/meta/compress +4 -0
- package/templates/scripts/__monorepo/meta/lint +4 -0
- package/templates/scripts/__monorepo/meta/lint-fix +4 -0
- package/templates/scripts/__monorepo/meta/release +5 -0
- package/templates/scripts/__monorepo/meta/serve +4 -0
- package/templates/scripts/__monorepo/meta/test +4 -0
- package/templates/scripts/__monorepo/meta/test-watch +4 -0
- package/templates/scripts/docs/build +0 -4
- package/templates/scripts/docs/build-prod +0 -4
- package/templates/scripts/docs/cms +0 -4
- package/templates/scripts/docs/serve +0 -4
- /package/templates/scripts/{hooks → __libdocs/hooks}/pre-commit +0 -0
- /package/templates/scripts/{lib → __libdocs/meta}/release +0 -0
- /package/templates/scripts/{ci → __module/ci} +0 -0
- /package/templates/scripts/{compress → __module/compress} +0 -0
- /package/templates/scripts/{lint → __module/lint} +0 -0
- /package/templates/scripts/{lint-fix → __module/lint-fix} +0 -0
- /package/templates/scripts/{lib → __module}/test +0 -0
- /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 '
|
|
11
|
+
import initHelper from '../helper.js';
|
|
13
12
|
|
|
14
13
|
export default {
|
|
15
14
|
/**
|
|
16
|
-
* Create the top-level
|
|
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}-
|
|
28
|
-
version: '0.0.1',
|
|
27
|
+
name: `${sharedProjectData.name}-root`,
|
|
29
28
|
|
|
30
29
|
// Metadata
|
|
31
30
|
author: sharedProjectData.author,
|
|
32
|
-
description: `${sharedProjectData.name}
|
|
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
|
-
//
|
|
53
|
-
build: './scripts/
|
|
54
|
-
'build:prod': './scripts/
|
|
55
|
-
cms: './scripts/
|
|
56
|
-
serve: './scripts/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
ci: './scripts/ci',
|
|
63
|
-
compress: './scripts/compress',
|
|
64
|
-
lint: './scripts/lint',
|
|
65
|
-
'lint:fix': './scripts/lint-fix',
|
|
66
|
-
|
|
67
|
-
//
|
|
68
|
-
|
|
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
|
-
|
|
225
|
-
build: '
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
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
|
|
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 '
|
|
4
|
+
import initHelper from '../helper.js';
|
|
6
5
|
|
|
7
6
|
export default {
|
|
8
7
|
/**
|
|
9
|
-
* Create the
|
|
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://
|
|
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 = ['
|
|
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
|
|
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
|
|
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
|
|
7
|
-
import
|
|
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
|
-
|
|
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.
|
|
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.
|
|
38
|
-
"aberlaas-versions": "^2.
|
|
39
|
-
"firost": "4.
|
|
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": "
|
|
43
|
+
"gitHead": "a8a1ee486fa1faeac6b7a524e7a6e41d5503dbc0"
|
|
43
44
|
}
|
package/templates/_yarnrc.yml
CHANGED