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.
Files changed (55) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +1 -19
  3. package/commands/ci/index.js +14 -99
  4. package/commands/init/index.js +322 -205
  5. package/commands/lint/css.js +2 -2
  6. package/commands/lint/helpers/prettier.js +2 -2
  7. package/commands/lint/index.js +3 -2
  8. package/commands/lint/js.js +1 -1
  9. package/commands/precommit/index.js +4 -3
  10. package/commands/setup/index.js +0 -12
  11. package/commands/test/index.js +56 -48
  12. package/configs/eslint.cjs +9 -2
  13. package/configs/lintstaged.js +25 -0
  14. package/configs/node.cjs +4 -0
  15. package/configs/{prettier.cjs → prettier.js} +1 -1
  16. package/configs/{stylelint.cjs → stylelint.js} +1 -1
  17. package/configs/vite.js +9 -2
  18. package/main.js +31 -2
  19. package/package.json +24 -23
  20. package/templates/_circleci/config.yml +0 -1
  21. package/templates/_eslintignore.conf +4 -1
  22. package/templates/_gitattributes +4 -0
  23. package/templates/_gitignore +29 -0
  24. package/templates/lerna.json +6 -0
  25. package/templates/lib/__tests__/main.js +7 -5
  26. package/templates/lib/main.js +2 -2
  27. package/templates/lintstaged.config.js +4 -0
  28. package/templates/prettier.config.js +4 -0
  29. package/templates/scripts/ci +3 -1
  30. package/templates/scripts/compress +2 -2
  31. package/templates/scripts/docs/build +4 -0
  32. package/templates/scripts/docs/build-prod +4 -0
  33. package/templates/scripts/docs/cms +4 -0
  34. package/templates/scripts/docs/serve +4 -0
  35. package/templates/scripts/hooks/pre-commit +1 -1
  36. package/templates/scripts/lib/release +5 -0
  37. package/templates/scripts/lib/test +4 -0
  38. package/templates/scripts/lib/test-watch +4 -0
  39. package/templates/scripts/lint +2 -2
  40. package/templates/scripts/lint-fix +2 -2
  41. package/templates/stylelint.config.js +4 -0
  42. package/templates/vite.config.js +2 -2
  43. package/commands/ci/autoRelease.js +0 -143
  44. package/commands/release/index.js +0 -76
  45. package/commands/setup/autoRelease/envVars.js +0 -56
  46. package/commands/setup/autoRelease/index.js +0 -59
  47. package/commands/setup/autoRelease/privateKey.js +0 -41
  48. package/commands/setup/autoRelease/publicKey.js +0 -55
  49. package/configs/lintstaged.cjs +0 -31
  50. package/templates/_lintstagedrc.cjs +0 -4
  51. package/templates/_prettierrc.cjs +0 -4
  52. package/templates/_stylelintrc.cjs +0 -4
  53. package/templates/scripts/release +0 -4
  54. package/templates/scripts/test +0 -4
  55. package/templates/scripts/test-watch +0 -4
@@ -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 exists from 'firost/exists.js';
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
- * Copy a config template to the host
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 copyToHost(source, destination) {
26
- const absoluteSource = helper.aberlaasPath(source);
27
- const absoluteDestination = helper.hostPath(destination);
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
- // Source file does not exist
30
- if (!(await isFile(absoluteSource))) {
31
- return false;
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
- await copy(absoluteSource, absoluteDestination);
44
+ // Name and version
45
+ name: `${sharedProjectData.name}-monorepo`,
46
+ version: '0.0.1',
39
47
 
40
- return true;
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('templates/_lintstagedrc.cjs', '.lintstagedrc.cjs');
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/_prettierrc.cjs', '.prettierrc.cjs');
218
+ await this.copyToHost('templates/prettier.config.js', 'prettier.config.js');
63
219
 
64
220
  // Stylelint
65
- await this.copyToHost('templates/_stylelintrc.cjs', '.stylelintrc.cjs');
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 scripts entry to the host package.json with specified command.
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 addPackageScript(scriptName, scriptPath) {
87
- const packagePath = helper.hostPath('package.json');
88
- const currentPackage = await readJson(packagePath);
89
- const currentScripts = _.get(currentPackage, 'scripts', {});
90
-
91
- if (currentScripts[scriptName]) {
92
- return false;
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
- const newPackage = _.set(
98
- _.clone(currentPackage),
99
- `scripts.${scriptName}`,
100
- `./${scriptPath}`,
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
- const currentFiles = currentPackage.files;
146
- const currentFilesIsEmpty = _.isEmpty(currentFiles);
147
- if (!currentFiles || currentFilesIsEmpty) {
148
- currentPackage.files = ['lib/*.js'];
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
- await writeJson(currentPackage, packagePath);
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 an MIT LICENSE file to the repository
275
+ * Add MIT license files to the repository
155
276
  **/
156
- async addLicenseFile() {
157
- const licensePath = helper.hostPath('LICENSE');
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
- const content = _.replace(template, '{author}', currentPackage.author);
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
- await write(content, licensePath);
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
- * Sets license to MIT in package.json
296
+ * Add default files required to have the minimum lib module
172
297
  **/
173
- async addLicenseField() {
174
- const packagePath = helper.hostPath('package.json');
175
- const currentPackage = await readJson(packagePath);
176
-
177
- if (currentPackage.license) {
178
- return;
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
- * Sets a default 0.0.1 version if none is defined
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 addDefaultVersion() {
192
- const packagePath = helper.hostPath('package.json');
193
- const currentPackage = await readJson(packagePath);
311
+ async copyToHost(source, destination) {
312
+ const absoluteSource = helper.aberlaasPath(source);
313
+ const absoluteDestination = helper.hostPath(destination);
194
314
 
195
- if (currentPackage.version) {
196
- return;
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
- const newPackage = {
200
- ...currentPackage,
201
- version: '0.0.1',
202
- };
203
-
204
- await writeJson(newPackage, packagePath);
205
- },
206
- /**
207
- * Sets the minimum node version to run this module
208
- * Which is the same version it has been tested on
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
- const newPackage = {
219
- ...currentPackage,
220
- engines: {
221
- node: `>=${nodeConfig.nodeVersion}`,
222
- },
223
- };
336
+ await copy(absoluteSource, absoluteDestination);
224
337
 
225
- await writeJson(newPackage, packagePath);
338
+ return true;
226
339
  },
227
340
  /**
228
- * Sets the dirname as package name if none is defined
341
+ * Return name of the current project based on the GitHub project name
342
+ * @returns {string} Name of the project
229
343
  **/
230
- async addDefaultName() {
231
- const packagePath = helper.hostPath('package.json');
232
- const currentPackage = await readJson(packagePath);
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
- * Pin the node version through nvm and yarn through yarnrc
247
- * This allows us to run the same version locally as we do in CI
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 pinNodeAndYarn() {
250
- // Set .nvmrc
251
- const nvmrcPath = helper.hostPath('.nvmrc');
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
- * Configure git hooks to use scripts/hooks instead of .git/hooks
357
+ * Returns shared project data, like name, author, scripts, etc
358
+ * @returns {object} Object of common keys
259
359
  **/
260
- async configureGitHooks() {
261
- // Copy the scripts into ./scripts/hooks
262
- await this.copyToHost(
263
- './templates/scripts/hooks/pre-commit',
264
- './scripts/hooks/pre-commit',
265
- );
266
-
267
- // Configure git to use this directory for hooks
268
- const repo = new Gilmore(helper.hostRoot());
269
- await repo.setConfig('core.hooksPath', 'scripts/hooks');
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('Pinning node and yarn versions');
278
- await this.pinNodeAndYarn();
279
- await this.addEngineNodeVersion();
402
+ progress.tick('Configuring Git & Node');
403
+ await this.configureGit();
404
+ await this.configureNode();
280
405
 
281
- progress.tick('Adding config files');
282
- await this.addConfigFiles();
406
+ progress.tick('Configuring workspaces');
407
+ await this.createRootWorkspace();
408
+ await this.createDocsWorkspace();
409
+ await this.createLibWorkspace();
283
410
 
284
- progress.tick('Adding yarn scripts');
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
  );
@@ -36,8 +36,8 @@ export default {
36
36
  // Config
37
37
  const configFile = await helper.configFile(
38
38
  userConfigFile,
39
- '.stylelintrc.cjs',
40
- 'configs/stylelint.cjs',
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
- '.prettierrc.cjs',
18
- 'lib/configs/prettier.cjs',
17
+ 'prettier.config.js',
18
+ 'configs/prettier.js',
19
19
  );
20
20
  const config = await prettier.resolveConfig(configFile);
21
21
 
@@ -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) {
@@ -34,7 +34,7 @@ export default {
34
34
  const configFile = await helper.configFile(
35
35
  userConfigFile,
36
36
  '.eslintrc.cjs',
37
- 'lib/configs/eslint.cjs',
37
+ 'configs/eslint.cjs',
38
38
  );
39
39
 
40
40
  // Run the actual lint