aberlaas 2.2.0 → 2.4.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/LICENSE +9 -0
- package/README.md +1 -19
- package/commands/ci/index.js +14 -99
- package/commands/init/index.js +322 -205
- package/commands/lint/css.js +2 -2
- package/commands/lint/helpers/prettier.js +2 -2
- package/commands/lint/index.js +3 -2
- package/commands/lint/js.js +1 -1
- package/commands/precommit/index.js +4 -3
- package/commands/setup/index.js +0 -12
- package/commands/test/index.js +56 -48
- package/configs/eslint.cjs +9 -2
- package/configs/lintstaged.js +25 -0
- package/configs/node.cjs +4 -0
- package/configs/{prettier.cjs → prettier.js} +1 -1
- package/configs/{stylelint.cjs → stylelint.js} +1 -1
- package/configs/vite.js +9 -2
- package/main.js +31 -2
- package/package.json +24 -23
- package/templates/_circleci/config.yml +0 -1
- package/templates/_eslintignore.conf +4 -1
- package/templates/_gitattributes +4 -0
- package/templates/_gitignore +29 -0
- package/templates/lerna.json +6 -0
- package/templates/lib/__tests__/main.js +7 -5
- package/templates/lib/main.js +2 -2
- package/templates/lintstaged.config.js +4 -0
- package/templates/prettier.config.js +4 -0
- package/templates/scripts/ci +3 -1
- package/templates/scripts/compress +2 -2
- package/templates/scripts/docs/build +4 -0
- package/templates/scripts/docs/build-prod +4 -0
- package/templates/scripts/docs/cms +4 -0
- package/templates/scripts/docs/serve +4 -0
- package/templates/scripts/hooks/pre-commit +1 -1
- package/templates/scripts/lib/release +5 -0
- package/templates/scripts/lib/test +4 -0
- package/templates/scripts/lib/test-watch +4 -0
- package/templates/scripts/lint +2 -2
- package/templates/scripts/lint-fix +2 -2
- package/templates/stylelint.config.js +4 -0
- package/templates/vite.config.js +2 -2
- package/commands/ci/autoRelease.js +0 -143
- package/commands/release/index.js +0 -76
- package/commands/setup/autoRelease/envVars.js +0 -56
- package/commands/setup/autoRelease/index.js +0 -59
- package/commands/setup/autoRelease/privateKey.js +0 -41
- package/commands/setup/autoRelease/publicKey.js +0 -55
- package/configs/lintstaged.cjs +0 -31
- package/templates/_lintstagedrc.cjs +0 -4
- package/templates/_prettierrc.cjs +0 -4
- package/templates/_stylelintrc.cjs +0 -4
- package/templates/scripts/release +0 -4
- package/templates/scripts/test +0 -4
- package/templates/scripts/test-watch +0 -4
package/commands/init/index.js
CHANGED
|
@@ -1,43 +1,189 @@
|
|
|
1
1
|
import _ from 'golgoth/lodash.js';
|
|
2
|
-
import pMapSeries from 'golgoth/pMapSeries.js';
|
|
3
2
|
import isFile from 'firost/isFile.js';
|
|
4
3
|
import copy from 'firost/copy.js';
|
|
4
|
+
import move from 'firost/move.js';
|
|
5
5
|
import readJson from 'firost/readJson.js';
|
|
6
6
|
import writeJson from 'firost/writeJson.js';
|
|
7
|
-
import
|
|
7
|
+
import firostError from 'firost/error.js';
|
|
8
8
|
import read from 'firost/read.js';
|
|
9
9
|
import write from 'firost/write.js';
|
|
10
10
|
import run from 'firost/run.js';
|
|
11
11
|
import spinner from 'firost/spinner.js';
|
|
12
12
|
import helper from '../../helper.js';
|
|
13
|
-
import path from 'path';
|
|
14
13
|
import nodeConfig from '../../configs/node.cjs';
|
|
15
14
|
import consoleInfo from 'firost/consoleInfo.js';
|
|
16
15
|
import Gilmore from 'gilmore';
|
|
17
16
|
|
|
18
17
|
export default {
|
|
19
18
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param {string} source Path to source file, relative to aberlaas
|
|
22
|
-
* @param {string} destination Path to destination file, relative to the host
|
|
23
|
-
* @returns {boolean} False if can't copy file, true otherwise
|
|
19
|
+
* Configure git hooks to use scripts/hooks instead of .git/hooks
|
|
24
20
|
**/
|
|
25
|
-
async
|
|
26
|
-
const
|
|
27
|
-
|
|
21
|
+
async configureGit() {
|
|
22
|
+
const repo = new Gilmore(helper.hostRoot());
|
|
23
|
+
await repo.setConfig('core.hooksPath', 'scripts/hooks');
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* Pin the node version through nvm
|
|
27
|
+
**/
|
|
28
|
+
async configureNode() {
|
|
29
|
+
const nvmrcPath = helper.hostPath('.nvmrc');
|
|
30
|
+
await write(nodeConfig.nodeVersion, nvmrcPath);
|
|
31
|
+
},
|
|
32
|
+
/**
|
|
33
|
+
* Create the top-level monorepo root workspace
|
|
34
|
+
**/
|
|
35
|
+
async createRootWorkspace() {
|
|
36
|
+
const aberlaasData = await readJson(helper.aberlaasPath('./package.json'));
|
|
37
|
+
const sharedProjectData = await this.getSharedProjectData();
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
// Destination file already exist
|
|
34
|
-
if (await isFile(absoluteDestination)) {
|
|
35
|
-
return false;
|
|
36
|
-
}
|
|
39
|
+
const packageContent = {
|
|
40
|
+
// Visibility
|
|
41
|
+
private: true,
|
|
42
|
+
workspaces: ['docs', 'lib'],
|
|
37
43
|
|
|
38
|
-
|
|
44
|
+
// Name and version
|
|
45
|
+
name: `${sharedProjectData.name}-monorepo`,
|
|
46
|
+
version: '0.0.1',
|
|
39
47
|
|
|
40
|
-
|
|
48
|
+
// Metadata
|
|
49
|
+
author: sharedProjectData.author,
|
|
50
|
+
description: `${sharedProjectData.name} monorepo`,
|
|
51
|
+
repository: sharedProjectData.repository,
|
|
52
|
+
homepage: sharedProjectData.homepage,
|
|
53
|
+
|
|
54
|
+
// Compatibility
|
|
55
|
+
type: 'module',
|
|
56
|
+
license: sharedProjectData.license,
|
|
57
|
+
packageManager: `yarn@${nodeConfig.yarnVersion}`,
|
|
58
|
+
|
|
59
|
+
// Exports
|
|
60
|
+
|
|
61
|
+
// Dependencies
|
|
62
|
+
dependencies: {},
|
|
63
|
+
devDependencies: {
|
|
64
|
+
aberlaas: aberlaasData.version,
|
|
65
|
+
lerna: nodeConfig.lernaVersion,
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
// Scripts
|
|
69
|
+
scripts: {
|
|
70
|
+
// ==> Docs-specific
|
|
71
|
+
build: './scripts/docs/build',
|
|
72
|
+
'build:prod': './scripts/docs/build-prod',
|
|
73
|
+
cms: './scripts/docs/cms',
|
|
74
|
+
serve: './scripts/docs/serve',
|
|
75
|
+
// ==> Lib-specific
|
|
76
|
+
release: './scripts/lib/release',
|
|
77
|
+
test: './scripts/lib/test',
|
|
78
|
+
'test:watch': './scripts/lib/test-watch',
|
|
79
|
+
// Common
|
|
80
|
+
ci: './scripts/ci',
|
|
81
|
+
compress: './scripts/compress',
|
|
82
|
+
lint: './scripts/lint',
|
|
83
|
+
'lint:fix': './scripts/lint-fix',
|
|
84
|
+
|
|
85
|
+
// Global (called as aliases from any workspace)
|
|
86
|
+
// ==> Docs-specific
|
|
87
|
+
'g:build': './scripts/docs/build',
|
|
88
|
+
'g:build:prod': './scripts/docs/build-prod',
|
|
89
|
+
'g:cms': './scripts/docs/cms',
|
|
90
|
+
'g:serve': './scripts/docs/serve',
|
|
91
|
+
// ==> Lib-specific
|
|
92
|
+
'g:release': './scripts/lib/release',
|
|
93
|
+
'g:test': './scripts/lib/test',
|
|
94
|
+
'g:test:watch': './scripts/lib/test-watch',
|
|
95
|
+
// Common
|
|
96
|
+
'g:compress': './scripts/compress',
|
|
97
|
+
'g:lint': './scripts/lint',
|
|
98
|
+
'g:lint:fix': './scripts/lint-fix',
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
await writeJson(packageContent, helper.hostPath('./package.json'), {
|
|
102
|
+
sort: false,
|
|
103
|
+
});
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* Create the docs workspace
|
|
107
|
+
**/
|
|
108
|
+
async createDocsWorkspace() {
|
|
109
|
+
const sharedProjectData = await this.getSharedProjectData();
|
|
110
|
+
|
|
111
|
+
const packageContent = {
|
|
112
|
+
// Visibility
|
|
113
|
+
private: true,
|
|
114
|
+
|
|
115
|
+
// Name & Version
|
|
116
|
+
name: `${sharedProjectData.name}-docs`,
|
|
117
|
+
version: '0.0.1',
|
|
118
|
+
|
|
119
|
+
// Metadata
|
|
120
|
+
author: sharedProjectData.author,
|
|
121
|
+
description: `${sharedProjectData.name} docs`,
|
|
122
|
+
repository: sharedProjectData.repository,
|
|
123
|
+
homepage: sharedProjectData.homepage,
|
|
124
|
+
|
|
125
|
+
// Compatibility
|
|
126
|
+
license: sharedProjectData.license,
|
|
127
|
+
|
|
128
|
+
// Exports
|
|
129
|
+
|
|
130
|
+
// Dependencies
|
|
131
|
+
dependencies: {
|
|
132
|
+
norska: nodeConfig.norskaVersion,
|
|
133
|
+
'norska-theme-docs': nodeConfig.norskaThemeDocsVersion,
|
|
134
|
+
},
|
|
135
|
+
devDependencies: {},
|
|
136
|
+
|
|
137
|
+
// Scripts
|
|
138
|
+
scripts: sharedProjectData.scripts,
|
|
139
|
+
};
|
|
140
|
+
await writeJson(packageContent, helper.hostPath('./docs/package.json'), {
|
|
141
|
+
sort: false,
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
/**
|
|
145
|
+
* Create the lib workspace
|
|
146
|
+
**/
|
|
147
|
+
async createLibWorkspace() {
|
|
148
|
+
const sharedProjectData = await this.getSharedProjectData();
|
|
149
|
+
|
|
150
|
+
const packageContent = {
|
|
151
|
+
// Visibility
|
|
152
|
+
private: false,
|
|
153
|
+
|
|
154
|
+
// Name and version
|
|
155
|
+
name: sharedProjectData.name,
|
|
156
|
+
version: '0.0.1',
|
|
157
|
+
|
|
158
|
+
// Metadata
|
|
159
|
+
author: sharedProjectData.author,
|
|
160
|
+
description: '',
|
|
161
|
+
keywords: [],
|
|
162
|
+
repository: sharedProjectData.repository,
|
|
163
|
+
homepage: sharedProjectData.homepage,
|
|
164
|
+
|
|
165
|
+
// Compatibility
|
|
166
|
+
type: 'module',
|
|
167
|
+
license: sharedProjectData.license,
|
|
168
|
+
engines: sharedProjectData.engines,
|
|
169
|
+
|
|
170
|
+
// Exports
|
|
171
|
+
files: ['*.js'],
|
|
172
|
+
exports: {
|
|
173
|
+
'.': './main.js',
|
|
174
|
+
},
|
|
175
|
+
main: './main.js',
|
|
176
|
+
|
|
177
|
+
// Dependencies
|
|
178
|
+
dependencies: {},
|
|
179
|
+
devDependencies: {},
|
|
180
|
+
|
|
181
|
+
// Scripts
|
|
182
|
+
scripts: sharedProjectData.scripts,
|
|
183
|
+
};
|
|
184
|
+
await writeJson(packageContent, helper.hostPath('./lib/package.json'), {
|
|
185
|
+
sort: false,
|
|
186
|
+
});
|
|
41
187
|
},
|
|
42
188
|
/**
|
|
43
189
|
* Add config files to the host. Each config files reference the default
|
|
@@ -45,24 +191,37 @@ export default {
|
|
|
45
191
|
* default rules and overwrite them as they see fit
|
|
46
192
|
**/
|
|
47
193
|
async addConfigFiles() {
|
|
194
|
+
// Git
|
|
195
|
+
await this.copyToHost('./templates/_gitignore', './.gitignore');
|
|
196
|
+
await this.copyToHost('./templates/_gitattributes', './.gitattributes');
|
|
197
|
+
|
|
48
198
|
// Yarn
|
|
49
199
|
await this.copyToHost('templates/_yarnrc.yml', '.yarnrc.yml');
|
|
50
200
|
|
|
201
|
+
// Lerna
|
|
202
|
+
await this.copyToHost('templates/lerna.json', 'lerna.json');
|
|
203
|
+
|
|
51
204
|
// ESLint
|
|
52
205
|
await this.copyToHost('templates/_eslintrc.cjs', '.eslintrc.cjs');
|
|
53
206
|
await this.copyToHost('templates/_eslintignore.conf', '.eslintignore');
|
|
54
207
|
|
|
55
208
|
// Lint-staged
|
|
56
|
-
await this.copyToHost(
|
|
209
|
+
await this.copyToHost(
|
|
210
|
+
'templates/lintstaged.config.js',
|
|
211
|
+
'lintstaged.config.js',
|
|
212
|
+
);
|
|
57
213
|
|
|
58
214
|
// Vite
|
|
59
215
|
await this.copyToHost('templates/vite.config.js', 'vite.config.js');
|
|
60
216
|
|
|
61
217
|
// Prettier
|
|
62
|
-
await this.copyToHost('templates/
|
|
218
|
+
await this.copyToHost('templates/prettier.config.js', 'prettier.config.js');
|
|
63
219
|
|
|
64
220
|
// Stylelint
|
|
65
|
-
await this.copyToHost(
|
|
221
|
+
await this.copyToHost(
|
|
222
|
+
'templates/stylelint.config.js',
|
|
223
|
+
'stylelint.config.js',
|
|
224
|
+
);
|
|
66
225
|
|
|
67
226
|
// Renovate
|
|
68
227
|
await this.copyToHost(
|
|
@@ -77,196 +236,162 @@ export default {
|
|
|
77
236
|
);
|
|
78
237
|
},
|
|
79
238
|
/**
|
|
80
|
-
* Add
|
|
81
|
-
* @param {string} scriptName Script name
|
|
82
|
-
* @param {string} scriptPath Path to the script to run, must be a path
|
|
83
|
-
* relative to the templates/ directory
|
|
84
|
-
* @returns {boolean} False if can't add entry, true otherwise
|
|
239
|
+
* Add default script files
|
|
85
240
|
**/
|
|
86
|
-
async
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
await this.copyToHost(`./templates/${scriptPath}`, scriptPath);
|
|
241
|
+
async addScripts() {
|
|
242
|
+
// Docs
|
|
243
|
+
await this.copyToHost('templates/scripts/docs/build', 'scripts/docs/build');
|
|
244
|
+
await this.copyToHost(
|
|
245
|
+
'templates/scripts/docs/build-prod',
|
|
246
|
+
'scripts/docs/build-prod',
|
|
247
|
+
);
|
|
248
|
+
await this.copyToHost('templates/scripts/docs/cms', 'scripts/docs/cms');
|
|
249
|
+
await this.copyToHost('templates/scripts/docs/serve', 'scripts/docs/serve');
|
|
96
250
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
251
|
+
// Hooks
|
|
252
|
+
await this.copyToHost(
|
|
253
|
+
'./templates/scripts/hooks/pre-commit',
|
|
254
|
+
'./scripts/hooks/pre-commit',
|
|
101
255
|
);
|
|
102
|
-
await writeJson(newPackage, packagePath);
|
|
103
|
-
return true;
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* Add default scripts to the package.json scripts entry and copy scripts to
|
|
107
|
-
* ./scripts if needed
|
|
108
|
-
**/
|
|
109
|
-
async addScripts() {
|
|
110
|
-
const defaultScripts = [
|
|
111
|
-
{ key: 'ci', value: 'scripts/ci' },
|
|
112
|
-
{ key: 'compress', value: 'scripts/compress' },
|
|
113
|
-
{ key: 'lint', value: 'scripts/lint' },
|
|
114
|
-
{ key: 'lint:fix', value: 'scripts/lint-fix' },
|
|
115
|
-
{ key: 'release', value: 'scripts/release' },
|
|
116
|
-
{ key: 'test', value: 'scripts/test' },
|
|
117
|
-
{ key: 'test:watch', value: 'scripts/test-watch' },
|
|
118
|
-
];
|
|
119
|
-
|
|
120
|
-
await pMapSeries(defaultScripts, async (script) => {
|
|
121
|
-
await this.addPackageScript(script.key, script.value);
|
|
122
|
-
});
|
|
123
|
-
},
|
|
124
|
-
/**
|
|
125
|
-
* Update package.json with .main and .files keys to use files in ./lib
|
|
126
|
-
* directory by default
|
|
127
|
-
* TODO: Update this to use exports instead of main
|
|
128
|
-
**/
|
|
129
|
-
async setDefaultReleaseFiles() {
|
|
130
|
-
const packagePath = helper.hostPath('package.json');
|
|
131
|
-
const currentPackage = await readJson(packagePath);
|
|
132
|
-
|
|
133
|
-
// Update .main
|
|
134
|
-
const currentMain = currentPackage.main;
|
|
135
|
-
const currentMainIsDefault = currentMain === 'index.js';
|
|
136
|
-
if (!currentMain || currentMainIsDefault) {
|
|
137
|
-
currentPackage.main = 'lib/main.js';
|
|
138
|
-
await this.copyToHost('templates/lib/main.js', 'lib/main.js');
|
|
139
|
-
await this.copyToHost(
|
|
140
|
-
'templates/lib/__tests__/main.js',
|
|
141
|
-
'lib/__tests__/main.js',
|
|
142
|
-
);
|
|
143
|
-
}
|
|
144
256
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
257
|
+
// Lib
|
|
258
|
+
await this.copyToHost(
|
|
259
|
+
'templates/scripts/lib/release',
|
|
260
|
+
'scripts/lib/release',
|
|
261
|
+
);
|
|
262
|
+
await this.copyToHost('templates/scripts/lib/test', 'scripts/lib/test');
|
|
263
|
+
await this.copyToHost(
|
|
264
|
+
'templates/scripts/lib/test-watch',
|
|
265
|
+
'scripts/lib/test-watch',
|
|
266
|
+
);
|
|
150
267
|
|
|
151
|
-
|
|
268
|
+
// Common
|
|
269
|
+
await this.copyToHost('templates/scripts/ci', 'scripts/ci');
|
|
270
|
+
await this.copyToHost('templates/scripts/compress', 'scripts/compress');
|
|
271
|
+
await this.copyToHost('templates/scripts/lint', 'scripts/lint');
|
|
272
|
+
await this.copyToHost('templates/scripts/lint-fix', 'scripts/lint-fix');
|
|
152
273
|
},
|
|
153
274
|
/**
|
|
154
|
-
* Add
|
|
275
|
+
* Add MIT license files to the repository
|
|
155
276
|
**/
|
|
156
|
-
async
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (await exists(licensePath)) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
const template = await read(helper.aberlaasPath('./templates/LICENSE'));
|
|
164
|
-
const currentPackage = await readJson(helper.hostPath('package.json'));
|
|
277
|
+
async addLicenseFiles() {
|
|
278
|
+
// Add the LICENSE template to the root
|
|
279
|
+
await this.copyToHost('templates/LICENSE', 'LICENSE');
|
|
165
280
|
|
|
166
|
-
|
|
281
|
+
// Replace placeholder with real value
|
|
282
|
+
const sharedProjectData = await this.getSharedProjectData();
|
|
283
|
+
const licensePath = helper.hostPath('LICENSE');
|
|
284
|
+
const templateContent = await read(licensePath);
|
|
285
|
+
const actualContent = _.replace(
|
|
286
|
+
templateContent,
|
|
287
|
+
'{author}',
|
|
288
|
+
sharedProjectData.author,
|
|
289
|
+
);
|
|
167
290
|
|
|
168
|
-
|
|
291
|
+
// Write the LICENSE to root and lib
|
|
292
|
+
await write(actualContent, licensePath);
|
|
293
|
+
await write(actualContent, helper.hostPath('lib/LICENSE'));
|
|
169
294
|
},
|
|
170
295
|
/**
|
|
171
|
-
*
|
|
296
|
+
* Add default files required to have the minimum lib module
|
|
172
297
|
**/
|
|
173
|
-
async
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const newPackage = {
|
|
182
|
-
...currentPackage,
|
|
183
|
-
license: 'MIT',
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
await writeJson(newPackage, packagePath);
|
|
298
|
+
async addLibFiles() {
|
|
299
|
+
await this.copyToHost('templates/lib/main.js', 'lib/main.js');
|
|
300
|
+
await this.copyToHost(
|
|
301
|
+
'templates/lib/__tests__/main.js',
|
|
302
|
+
'lib/__tests__/main.js',
|
|
303
|
+
);
|
|
187
304
|
},
|
|
188
305
|
/**
|
|
189
|
-
*
|
|
306
|
+
* Copy a config template to the host
|
|
307
|
+
* @param {string} source Path to source file, relative to aberlaas
|
|
308
|
+
* @param {string} destination Path to destination file, relative to the host
|
|
309
|
+
* @returns {boolean} False if can't copy file, true otherwise
|
|
190
310
|
**/
|
|
191
|
-
async
|
|
192
|
-
const
|
|
193
|
-
const
|
|
311
|
+
async copyToHost(source, destination) {
|
|
312
|
+
const absoluteSource = helper.aberlaasPath(source);
|
|
313
|
+
const absoluteDestination = helper.hostPath(destination);
|
|
194
314
|
|
|
195
|
-
|
|
196
|
-
|
|
315
|
+
// Source file does not exist
|
|
316
|
+
if (!(await isFile(absoluteSource))) {
|
|
317
|
+
throw firostError(
|
|
318
|
+
'ERROR_INIT_COPY_FILE',
|
|
319
|
+
`Unable to locate ${absoluteSource} file`,
|
|
320
|
+
);
|
|
197
321
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
async addEngineNodeVersion() {
|
|
211
|
-
const packagePath = helper.hostPath('package.json');
|
|
212
|
-
const currentPackage = await readJson(packagePath);
|
|
213
|
-
|
|
214
|
-
if (_.has(currentPackage, 'engines')) {
|
|
215
|
-
return;
|
|
322
|
+
// Destination file already exist
|
|
323
|
+
if (await isFile(absoluteDestination)) {
|
|
324
|
+
// Do nothing if content is already the same
|
|
325
|
+
const sourceContent = await read(absoluteSource);
|
|
326
|
+
const destinationContent = await read(absoluteDestination);
|
|
327
|
+
if (sourceContent === destinationContent) {
|
|
328
|
+
return true;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// Otherwise create a backup
|
|
332
|
+
const backupDestination = `${absoluteDestination}.backup`;
|
|
333
|
+
await move(absoluteDestination, backupDestination);
|
|
216
334
|
}
|
|
217
335
|
|
|
218
|
-
|
|
219
|
-
...currentPackage,
|
|
220
|
-
engines: {
|
|
221
|
-
node: `>=${nodeConfig.nodeVersion}`,
|
|
222
|
-
},
|
|
223
|
-
};
|
|
336
|
+
await copy(absoluteSource, absoluteDestination);
|
|
224
337
|
|
|
225
|
-
|
|
338
|
+
return true;
|
|
226
339
|
},
|
|
227
340
|
/**
|
|
228
|
-
*
|
|
341
|
+
* Return name of the current project based on the GitHub project name
|
|
342
|
+
* @returns {string} Name of the project
|
|
229
343
|
**/
|
|
230
|
-
async
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (currentPackage.name) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
const newPackage = {
|
|
239
|
-
...currentPackage,
|
|
240
|
-
name: path.basename(helper.hostPath()),
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
await writeJson(newPackage, packagePath);
|
|
344
|
+
async getProjectName() {
|
|
345
|
+
const repo = new Gilmore(helper.hostRoot());
|
|
346
|
+
return await repo.githubRepoName();
|
|
244
347
|
},
|
|
245
348
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
349
|
+
* Return the name of the current author based on the GitHub project owner
|
|
350
|
+
* @returns {string} Name of the author
|
|
248
351
|
**/
|
|
249
|
-
async
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
await write(nodeConfig.nodeVersion, nvmrcPath);
|
|
253
|
-
|
|
254
|
-
// Download latest yarn version
|
|
255
|
-
await this.__run('yarn set version', { stdout: false });
|
|
352
|
+
async getProjectAuthor() {
|
|
353
|
+
const repo = new Gilmore(helper.hostRoot());
|
|
354
|
+
return await repo.githubRepoOwner();
|
|
256
355
|
},
|
|
257
356
|
/**
|
|
258
|
-
*
|
|
357
|
+
* Returns shared project data, like name, author, scripts, etc
|
|
358
|
+
* @returns {object} Object of common keys
|
|
259
359
|
**/
|
|
260
|
-
async
|
|
261
|
-
|
|
262
|
-
await this.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
360
|
+
async getSharedProjectData() {
|
|
361
|
+
const name = await this.getProjectName();
|
|
362
|
+
const author = await this.getProjectAuthor();
|
|
363
|
+
const homepage = `https://projects.pixelastic.com/${name}`;
|
|
364
|
+
const repository = `${author}/${name}`;
|
|
365
|
+
const license = 'MIT';
|
|
366
|
+
const engines = {
|
|
367
|
+
node: `>=${nodeConfig.nodeVersion}`,
|
|
368
|
+
};
|
|
369
|
+
const scripts = {
|
|
370
|
+
// Docs
|
|
371
|
+
build: 'ABERLAAS_CWD=$INIT_CWD yarn g:build',
|
|
372
|
+
'build:prod': 'ABERLAAS_CWD=$INIT_CWD yarn g:build:prod',
|
|
373
|
+
cms: 'ABERLAAS_CWD=$INIT_CWD yarn g:cms',
|
|
374
|
+
serve: 'ABERLAAS_CWD=$INIT_CWD yarn g:serve',
|
|
375
|
+
|
|
376
|
+
// Lib
|
|
377
|
+
release: 'ABERLAAS_CWD=$INIT_CWD yarn g:release',
|
|
378
|
+
test: 'ABERLAAS_CWD=$INIT_CWD yarn g:test',
|
|
379
|
+
'test:watch': 'ABERLAAS_CWD=$INIT_CWD yarn g:test:watch',
|
|
380
|
+
|
|
381
|
+
// Common
|
|
382
|
+
compress: 'ABERLAAS_CWD=$INIT_CWD yarn g:compress',
|
|
383
|
+
lint: 'ABERLAAS_CWD=$INIT_CWD yarn g:lint',
|
|
384
|
+
'lint:fix': 'ABERLAAS_CWD=$INIT_CWD yarn g:lint:fix',
|
|
385
|
+
};
|
|
386
|
+
return {
|
|
387
|
+
author,
|
|
388
|
+
engines,
|
|
389
|
+
homepage,
|
|
390
|
+
license,
|
|
391
|
+
name,
|
|
392
|
+
repository,
|
|
393
|
+
scripts,
|
|
394
|
+
};
|
|
270
395
|
},
|
|
271
396
|
/**
|
|
272
397
|
* Copy all config files and configure the scripts
|
|
@@ -274,34 +399,26 @@ export default {
|
|
|
274
399
|
async run() {
|
|
275
400
|
const progress = spinner();
|
|
276
401
|
|
|
277
|
-
progress.tick('
|
|
278
|
-
await this.
|
|
279
|
-
await this.
|
|
402
|
+
progress.tick('Configuring Git & Node');
|
|
403
|
+
await this.configureGit();
|
|
404
|
+
await this.configureNode();
|
|
280
405
|
|
|
281
|
-
progress.tick('
|
|
282
|
-
await this.
|
|
406
|
+
progress.tick('Configuring workspaces');
|
|
407
|
+
await this.createRootWorkspace();
|
|
408
|
+
await this.createDocsWorkspace();
|
|
409
|
+
await this.createLibWorkspace();
|
|
283
410
|
|
|
284
|
-
progress.tick('Adding
|
|
411
|
+
progress.tick('Adding files');
|
|
412
|
+
await this.addLicenseFiles();
|
|
413
|
+
await this.addConfigFiles();
|
|
285
414
|
await this.addScripts();
|
|
286
|
-
|
|
287
|
-
progress.tick('Configuring git hooks');
|
|
288
|
-
await this.configureGitHooks();
|
|
289
|
-
|
|
290
|
-
progress.tick('Updating LICENSE');
|
|
291
|
-
await this.addLicenseFile();
|
|
292
|
-
await this.addLicenseField();
|
|
293
|
-
|
|
294
|
-
progress.tick('Setting default version');
|
|
295
|
-
await this.addDefaultVersion();
|
|
296
|
-
|
|
297
|
-
progress.tick('Setting default name');
|
|
298
|
-
await this.addDefaultName();
|
|
299
|
-
|
|
300
|
-
progress.tick('Setting default release files');
|
|
301
|
-
await this.setDefaultReleaseFiles();
|
|
415
|
+
await this.addLibFiles();
|
|
302
416
|
|
|
303
417
|
progress.success('aberlaas project initialized');
|
|
304
418
|
|
|
419
|
+
this.__consoleInfo('Synchronizing dependencies');
|
|
420
|
+
await run('yarn install');
|
|
421
|
+
|
|
305
422
|
this.__consoleInfo(
|
|
306
423
|
"Don't forget to run aberlaas setup after pushing your repository",
|
|
307
424
|
);
|
package/commands/lint/css.js
CHANGED
|
@@ -36,8 +36,8 @@ export default {
|
|
|
36
36
|
// Config
|
|
37
37
|
const configFile = await helper.configFile(
|
|
38
38
|
userConfigFile,
|
|
39
|
-
'.
|
|
40
|
-
'configs/stylelint.
|
|
39
|
+
'stylelint.config.js',
|
|
40
|
+
'configs/stylelint.js',
|
|
41
41
|
);
|
|
42
42
|
const config = await helper.import(configFile);
|
|
43
43
|
|
|
@@ -14,8 +14,8 @@ export async function fix(inputFiles) {
|
|
|
14
14
|
// Config file
|
|
15
15
|
const configFile = await helper.configFile(
|
|
16
16
|
null,
|
|
17
|
-
'.
|
|
18
|
-
'
|
|
17
|
+
'prettier.config.js',
|
|
18
|
+
'configs/prettier.js',
|
|
19
19
|
);
|
|
20
20
|
const config = await prettier.resolveConfig(configFile);
|
|
21
21
|
|
package/commands/lint/index.js
CHANGED
|
@@ -21,7 +21,7 @@ export default {
|
|
|
21
21
|
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
22
22
|
* @returns {boolean} True on success
|
|
23
23
|
**/
|
|
24
|
-
async run(cliArgs) {
|
|
24
|
+
async run(cliArgs = {}) {
|
|
25
25
|
const allTypesKeys = _.keys(this.linters);
|
|
26
26
|
const userTypes = _.intersection(_.keys(cliArgs), allTypesKeys);
|
|
27
27
|
const typesToLint = _.isEmpty(userTypes) ? allTypesKeys : userTypes;
|
|
@@ -30,9 +30,10 @@ export default {
|
|
|
30
30
|
await pMap(typesToLint, async (type) => {
|
|
31
31
|
const methodName = cliArgs.fix ? 'fix' : 'run';
|
|
32
32
|
try {
|
|
33
|
+
const linter = this.linters[type];
|
|
34
|
+
|
|
33
35
|
const configFile = _.get(cliArgs, `config.${type}`);
|
|
34
36
|
const userPatterns = _.get(cliArgs, '_');
|
|
35
|
-
const linter = this.linters[type];
|
|
36
37
|
|
|
37
38
|
await linter[methodName](userPatterns, configFile);
|
|
38
39
|
} catch (error) {
|