aberlaas 2.8.0 → 2.10.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/bin/aberlaas.js +1 -1
- package/configs/eslint.js +3 -0
- package/configs/lintstaged.js +2 -24
- package/configs/prettier.js +3 -4
- package/configs/stylelint.js +3 -41
- package/configs/vite.js +2 -41
- package/{main.js → lib/main.js} +26 -30
- package/package.json +37 -45
- package/commands/ci/index.js +0 -47
- package/commands/compress/dummy.js +0 -11
- package/commands/compress/index.js +0 -41
- package/commands/compress/png.js +0 -49
- package/commands/init/helper.js +0 -171
- package/commands/init/index.js +0 -59
- package/commands/init/module.js +0 -111
- package/commands/init/monorepo.js +0 -261
- package/commands/lint/circleci.js +0 -81
- package/commands/lint/css.js +0 -73
- package/commands/lint/helpers/prettier.js +0 -54
- package/commands/lint/index.js +0 -50
- package/commands/lint/js.js +0 -73
- package/commands/lint/json.js +0 -60
- package/commands/lint/yml.js +0 -62
- package/commands/precommit/index.js +0 -33
- package/commands/readme/index.js +0 -181
- package/commands/setup/circleci.js +0 -60
- package/commands/setup/github.js +0 -42
- package/commands/setup/helpers/circleci.js +0 -43
- package/commands/setup/helpers/github.js +0 -72
- package/commands/setup/helpers/npm.js +0 -16
- package/commands/setup/helpers/ssh.js +0 -77
- package/commands/setup/index.js +0 -52
- package/commands/setup/renovate.js +0 -54
- package/commands/test/index.js +0 -124
- package/configs/eslint.cjs +0 -154
- package/configs/node.cjs +0 -9
- package/configs/vite/test/setupFiles/captureOutput.js +0 -4
- package/configs/vite/test/setupFiles/dedent.js +0 -4
- package/configs/vite/test/setupFiles/fit-xit-fdescribe-xdescribe.js +0 -13
- package/configs/vite/test/setupFiles/jest-extended.js +0 -10
- package/configs/vite/test/setupFiles/testName.js +0 -9
- package/helper.js +0 -115
- package/templates/LICENSE +0 -9
- package/templates/_circleci/config.yml +0 -33
- package/templates/_eslintignore.conf +0 -12
- package/templates/_eslintrc.cjs +0 -3
- package/templates/_gitattributes +0 -4
- package/templates/_github/README.template.md +0 -7
- package/templates/_github/renovate.json +0 -3
- package/templates/_gitignore +0 -29
- package/templates/_yarnrc.yml +0 -15
- package/templates/lerna.json +0 -6
- package/templates/lib/__tests__/main.js +0 -13
- package/templates/lib/main.js +0 -5
- package/templates/lintstaged.config.js +0 -5
- package/templates/prettier.config.js +0 -5
- package/templates/scripts/ci +0 -6
- package/templates/scripts/compress +0 -4
- 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/pre-commit +0 -11
- package/templates/scripts/lib/release +0 -5
- package/templates/scripts/lib/test +0 -5
- package/templates/scripts/lib/test-watch +0 -5
- package/templates/scripts/lint +0 -4
- package/templates/scripts/lint-fix +0 -4
- package/templates/stylelint.config.js +0 -5
- package/templates/vite.config.js +0 -5
package/commands/init/index.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { consoleInfo, run, spinner, write } from 'firost';
|
|
2
|
-
|
|
3
|
-
import Gilmore from 'gilmore';
|
|
4
|
-
import helper from '../../helper.js';
|
|
5
|
-
import nodeConfig from '../../configs/node.cjs';
|
|
6
|
-
import initMonorepo from './monorepo.js';
|
|
7
|
-
import initModule from './module.js';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
/**
|
|
11
|
-
* Configure git hooks to use scripts/hooks instead of .git/hooks
|
|
12
|
-
**/
|
|
13
|
-
async configureGit() {
|
|
14
|
-
const repo = new Gilmore(helper.hostRoot());
|
|
15
|
-
await repo.setConfig('core.hooksPath', 'scripts/hooks');
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* Pin the node version through nvm
|
|
19
|
-
**/
|
|
20
|
-
async configureNode() {
|
|
21
|
-
const nvmrcPath = helper.hostPath('.nvmrc');
|
|
22
|
-
await write(nodeConfig.nodeVersion, nvmrcPath);
|
|
23
|
-
},
|
|
24
|
-
/**
|
|
25
|
-
* Run yarn install to install all deps
|
|
26
|
-
**/
|
|
27
|
-
async yarnInstall() {
|
|
28
|
-
await run('yarn install');
|
|
29
|
-
},
|
|
30
|
-
/**
|
|
31
|
-
* Copy all config files and configure the scripts
|
|
32
|
-
* @param {object} args Argument object, as passed by minimist
|
|
33
|
-
**/
|
|
34
|
-
async run(args = {}) {
|
|
35
|
-
const isMonorepo = args.monorepo;
|
|
36
|
-
|
|
37
|
-
const progress = this.__spinner();
|
|
38
|
-
|
|
39
|
-
progress.tick('Configuring Git & Node');
|
|
40
|
-
await this.configureGit();
|
|
41
|
-
await this.configureNode();
|
|
42
|
-
|
|
43
|
-
progress.tick('Adding default files ');
|
|
44
|
-
|
|
45
|
-
// Create a different scaffolding based on if creating a monorepo or not
|
|
46
|
-
isMonorepo ? await initMonorepo.run() : await initModule.run();
|
|
47
|
-
|
|
48
|
-
progress.success('aberlaas project initialized');
|
|
49
|
-
|
|
50
|
-
this.__consoleInfo('Synchronizing dependencies');
|
|
51
|
-
await this.yarnInstall();
|
|
52
|
-
|
|
53
|
-
this.__consoleInfo(
|
|
54
|
-
"Don't forget to run aberlaas setup after pushing your repository",
|
|
55
|
-
);
|
|
56
|
-
},
|
|
57
|
-
__consoleInfo: consoleInfo,
|
|
58
|
-
__spinner: spinner,
|
|
59
|
-
};
|
package/commands/init/module.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { readJson, writeJson } from 'firost';
|
|
2
|
-
|
|
3
|
-
import helper from '../../helper.js';
|
|
4
|
-
import nodeConfig from '../../configs/node.cjs';
|
|
5
|
-
import initHelper from './helper.js';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
/**
|
|
9
|
-
* Create the top-level package.json
|
|
10
|
-
**/
|
|
11
|
-
async createPackageJson() {
|
|
12
|
-
// Get language and dependency version
|
|
13
|
-
const { version: aberlaasVersion } = await readJson(
|
|
14
|
-
helper.aberlaasPath('./package.json'),
|
|
15
|
-
);
|
|
16
|
-
const { nodeVersion, yarnVersion } = nodeConfig;
|
|
17
|
-
|
|
18
|
-
const name = await this.__getProjectName();
|
|
19
|
-
const version = '0.0.1';
|
|
20
|
-
|
|
21
|
-
const author = await this.__getProjectAuthor();
|
|
22
|
-
const description = '';
|
|
23
|
-
const keywords = [];
|
|
24
|
-
const repository = `${author}/${name}`;
|
|
25
|
-
const homepage = `https://projects.pixelastic.com/${name}`;
|
|
26
|
-
|
|
27
|
-
const type = 'module';
|
|
28
|
-
const license = 'MIT';
|
|
29
|
-
const engines = {
|
|
30
|
-
node: `>=${nodeVersion}`,
|
|
31
|
-
};
|
|
32
|
-
const packageManager = `yarn@${yarnVersion}`;
|
|
33
|
-
|
|
34
|
-
const files = ['*.js'];
|
|
35
|
-
const exports = {
|
|
36
|
-
'.': './main.js',
|
|
37
|
-
};
|
|
38
|
-
const main = './main.js';
|
|
39
|
-
|
|
40
|
-
const dependencies = {};
|
|
41
|
-
const devDependencies = {
|
|
42
|
-
aberlaas: aberlaasVersion,
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
const scripts = {
|
|
46
|
-
// Docs
|
|
47
|
-
build: './scripts/docs/build',
|
|
48
|
-
'build:prod': './scripts/docs/build-prod',
|
|
49
|
-
cms: './scripts/docs/cms',
|
|
50
|
-
serve: './scripts/docs/serve',
|
|
51
|
-
// Lib
|
|
52
|
-
release: './scripts/lib/release',
|
|
53
|
-
test: './scripts/lib/test',
|
|
54
|
-
'test:watch': './scripts/lib/test-watch',
|
|
55
|
-
// Common
|
|
56
|
-
ci: './scripts/ci',
|
|
57
|
-
compress: './scripts/compress',
|
|
58
|
-
lint: './scripts/lint',
|
|
59
|
-
'lint:fix': './scripts/lint-fix',
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
const packageContent = {
|
|
63
|
-
// Name and version
|
|
64
|
-
name,
|
|
65
|
-
version,
|
|
66
|
-
|
|
67
|
-
// Metadata
|
|
68
|
-
author,
|
|
69
|
-
description,
|
|
70
|
-
keywords,
|
|
71
|
-
repository,
|
|
72
|
-
homepage,
|
|
73
|
-
|
|
74
|
-
// Compatibility
|
|
75
|
-
type,
|
|
76
|
-
license,
|
|
77
|
-
engines,
|
|
78
|
-
packageManager,
|
|
79
|
-
|
|
80
|
-
// Exports
|
|
81
|
-
files,
|
|
82
|
-
exports,
|
|
83
|
-
main,
|
|
84
|
-
|
|
85
|
-
// Dependencies
|
|
86
|
-
dependencies,
|
|
87
|
-
devDependencies,
|
|
88
|
-
|
|
89
|
-
// Scripts
|
|
90
|
-
scripts,
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
await writeJson(packageContent, helper.hostPath('./package.json'), {
|
|
94
|
-
sort: false,
|
|
95
|
-
});
|
|
96
|
-
},
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Scaffold a repo for use in a simple module contexte
|
|
100
|
-
**/
|
|
101
|
-
async run() {
|
|
102
|
-
await this.createPackageJson();
|
|
103
|
-
|
|
104
|
-
await initHelper.addLicenseFile('LICENSE');
|
|
105
|
-
await initHelper.addConfigFiles();
|
|
106
|
-
await initHelper.addScripts();
|
|
107
|
-
await initHelper.addLibFiles();
|
|
108
|
-
},
|
|
109
|
-
__getProjectName: initHelper.getProjectName.bind(initHelper),
|
|
110
|
-
__getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
|
|
111
|
-
};
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { readJson, writeJson } from 'firost';
|
|
2
|
-
|
|
3
|
-
import helper from '../../helper.js';
|
|
4
|
-
import nodeConfig from '../../configs/node.cjs';
|
|
5
|
-
import initHelper from './helper.js';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
/**
|
|
9
|
-
* Create the top-level monorepo root workspace
|
|
10
|
-
**/
|
|
11
|
-
async createRootWorkspace() {
|
|
12
|
-
const aberlaasData = await readJson(helper.aberlaasPath('./package.json'));
|
|
13
|
-
const sharedProjectData = await this.getSharedProjectData();
|
|
14
|
-
|
|
15
|
-
const packageContent = {
|
|
16
|
-
// Visibility
|
|
17
|
-
private: true,
|
|
18
|
-
workspaces: ['docs', 'lib'],
|
|
19
|
-
|
|
20
|
-
// Name and version
|
|
21
|
-
name: `${sharedProjectData.name}-monorepo`,
|
|
22
|
-
version: '0.0.1',
|
|
23
|
-
|
|
24
|
-
// Metadata
|
|
25
|
-
author: sharedProjectData.author,
|
|
26
|
-
description: `${sharedProjectData.name} monorepo`,
|
|
27
|
-
repository: sharedProjectData.repository,
|
|
28
|
-
homepage: sharedProjectData.homepage,
|
|
29
|
-
|
|
30
|
-
// Compatibility
|
|
31
|
-
type: 'module',
|
|
32
|
-
license: sharedProjectData.license,
|
|
33
|
-
packageManager: `yarn@${nodeConfig.yarnVersion}`,
|
|
34
|
-
|
|
35
|
-
// Exports
|
|
36
|
-
|
|
37
|
-
// Dependencies
|
|
38
|
-
dependencies: {},
|
|
39
|
-
devDependencies: {
|
|
40
|
-
aberlaas: aberlaasData.version,
|
|
41
|
-
lerna: nodeConfig.lernaVersion,
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
// Scripts
|
|
45
|
-
scripts: {
|
|
46
|
-
// ==> Docs-specific
|
|
47
|
-
build: './scripts/docs/build',
|
|
48
|
-
'build:prod': './scripts/docs/build-prod',
|
|
49
|
-
cms: './scripts/docs/cms',
|
|
50
|
-
serve: './scripts/docs/serve',
|
|
51
|
-
// ==> Lib-specific
|
|
52
|
-
release: './scripts/lib/release',
|
|
53
|
-
test: './scripts/lib/test',
|
|
54
|
-
'test:watch': './scripts/lib/test-watch',
|
|
55
|
-
// Common
|
|
56
|
-
ci: './scripts/ci',
|
|
57
|
-
compress: './scripts/compress',
|
|
58
|
-
lint: './scripts/lint',
|
|
59
|
-
'lint:fix': './scripts/lint-fix',
|
|
60
|
-
|
|
61
|
-
// Global (called as aliases from any workspace)
|
|
62
|
-
// ==> Docs-specific
|
|
63
|
-
'g:build': './scripts/docs/build',
|
|
64
|
-
'g:build:prod': './scripts/docs/build-prod',
|
|
65
|
-
'g:cms': './scripts/docs/cms',
|
|
66
|
-
'g:serve': './scripts/docs/serve',
|
|
67
|
-
// ==> Lib-specific
|
|
68
|
-
'g:release': './scripts/lib/release',
|
|
69
|
-
'g:test': './scripts/lib/test',
|
|
70
|
-
'g:test:watch': './scripts/lib/test-watch',
|
|
71
|
-
// Common
|
|
72
|
-
'g:compress': './scripts/compress',
|
|
73
|
-
'g:lint': './scripts/lint',
|
|
74
|
-
'g:lint:fix': './scripts/lint-fix',
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
await writeJson(packageContent, helper.hostPath('./package.json'), {
|
|
78
|
-
sort: false,
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
/**
|
|
82
|
-
* Create the docs workspace
|
|
83
|
-
**/
|
|
84
|
-
async createDocsWorkspace() {
|
|
85
|
-
const sharedProjectData = await this.getSharedProjectData();
|
|
86
|
-
|
|
87
|
-
const packageContent = {
|
|
88
|
-
// Visibility
|
|
89
|
-
private: true,
|
|
90
|
-
|
|
91
|
-
// Name & Version
|
|
92
|
-
name: `${sharedProjectData.name}-docs`,
|
|
93
|
-
version: '0.0.1',
|
|
94
|
-
|
|
95
|
-
// Metadata
|
|
96
|
-
author: sharedProjectData.author,
|
|
97
|
-
description: `${sharedProjectData.name} docs`,
|
|
98
|
-
repository: sharedProjectData.repository,
|
|
99
|
-
homepage: sharedProjectData.homepage,
|
|
100
|
-
|
|
101
|
-
// Compatibility
|
|
102
|
-
license: sharedProjectData.license,
|
|
103
|
-
|
|
104
|
-
// Exports
|
|
105
|
-
|
|
106
|
-
// Dependencies
|
|
107
|
-
dependencies: {
|
|
108
|
-
norska: nodeConfig.norskaVersion,
|
|
109
|
-
'norska-theme-docs': nodeConfig.norskaThemeDocsVersion,
|
|
110
|
-
},
|
|
111
|
-
devDependencies: {},
|
|
112
|
-
|
|
113
|
-
// Scripts
|
|
114
|
-
scripts: sharedProjectData.scripts,
|
|
115
|
-
};
|
|
116
|
-
await writeJson(packageContent, helper.hostPath('./docs/package.json'), {
|
|
117
|
-
sort: false,
|
|
118
|
-
});
|
|
119
|
-
},
|
|
120
|
-
/**
|
|
121
|
-
* Create the lib workspace
|
|
122
|
-
**/
|
|
123
|
-
async createLibWorkspace() {
|
|
124
|
-
const sharedProjectData = await this.getSharedProjectData();
|
|
125
|
-
const engines = {
|
|
126
|
-
node: `>=${nodeConfig.nodeVersion}`,
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
const packageContent = {
|
|
130
|
-
// Visibility
|
|
131
|
-
private: false,
|
|
132
|
-
|
|
133
|
-
// Name and version
|
|
134
|
-
name: sharedProjectData.name,
|
|
135
|
-
version: '0.0.1',
|
|
136
|
-
|
|
137
|
-
// Metadata
|
|
138
|
-
author: sharedProjectData.author,
|
|
139
|
-
description: '',
|
|
140
|
-
keywords: [],
|
|
141
|
-
repository: sharedProjectData.repository,
|
|
142
|
-
homepage: sharedProjectData.homepage,
|
|
143
|
-
|
|
144
|
-
// Compatibility
|
|
145
|
-
type: 'module',
|
|
146
|
-
license: sharedProjectData.license,
|
|
147
|
-
engines,
|
|
148
|
-
|
|
149
|
-
// Exports
|
|
150
|
-
files: ['*.js'],
|
|
151
|
-
exports: {
|
|
152
|
-
'.': './main.js',
|
|
153
|
-
},
|
|
154
|
-
main: './main.js',
|
|
155
|
-
|
|
156
|
-
// Dependencies
|
|
157
|
-
dependencies: {},
|
|
158
|
-
devDependencies: {},
|
|
159
|
-
|
|
160
|
-
// Scripts
|
|
161
|
-
scripts: sharedProjectData.scripts,
|
|
162
|
-
};
|
|
163
|
-
await writeJson(packageContent, helper.hostPath('./lib/package.json'), {
|
|
164
|
-
sort: false,
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
/**
|
|
168
|
-
* Add MIT license files to the repository
|
|
169
|
-
**/
|
|
170
|
-
async addLicenseFiles() {
|
|
171
|
-
// One at the repo root, for GitHub
|
|
172
|
-
await initHelper.addLicenseFile('LICENSE');
|
|
173
|
-
// One in ./lib to be released with the module
|
|
174
|
-
await initHelper.addLicenseFile('lib/LICENSE');
|
|
175
|
-
},
|
|
176
|
-
/**
|
|
177
|
-
* Add config files
|
|
178
|
-
**/
|
|
179
|
-
async addConfigFiles() {
|
|
180
|
-
await initHelper.addConfigFiles();
|
|
181
|
-
|
|
182
|
-
// Lerna
|
|
183
|
-
await initHelper.copyToHost('templates/lerna.json', 'lerna.json');
|
|
184
|
-
},
|
|
185
|
-
/**
|
|
186
|
-
* Add scripts to the repo
|
|
187
|
-
**/
|
|
188
|
-
async addScripts() {
|
|
189
|
-
// Common scripts
|
|
190
|
-
await initHelper.addScripts('LICENSE');
|
|
191
|
-
|
|
192
|
-
// Docs scripts
|
|
193
|
-
await initHelper.copyToHost(
|
|
194
|
-
'templates/scripts/docs/build',
|
|
195
|
-
'scripts/docs/build',
|
|
196
|
-
);
|
|
197
|
-
await initHelper.copyToHost(
|
|
198
|
-
'templates/scripts/docs/build-prod',
|
|
199
|
-
'scripts/docs/build-prod',
|
|
200
|
-
);
|
|
201
|
-
await initHelper.copyToHost(
|
|
202
|
-
'templates/scripts/docs/cms',
|
|
203
|
-
'scripts/docs/cms',
|
|
204
|
-
);
|
|
205
|
-
await initHelper.copyToHost(
|
|
206
|
-
'templates/scripts/docs/serve',
|
|
207
|
-
'scripts/docs/serve',
|
|
208
|
-
);
|
|
209
|
-
},
|
|
210
|
-
/**
|
|
211
|
-
* Returns shared project data, like name, author, scripts, etc
|
|
212
|
-
* @returns {object} Object of common keys
|
|
213
|
-
**/
|
|
214
|
-
async getSharedProjectData() {
|
|
215
|
-
const name = await this.__getProjectName();
|
|
216
|
-
const author = await this.__getProjectAuthor();
|
|
217
|
-
const homepage = `https://projects.pixelastic.com/${name}`;
|
|
218
|
-
const repository = `${author}/${name}`;
|
|
219
|
-
const license = 'MIT';
|
|
220
|
-
const scripts = {
|
|
221
|
-
// Docs
|
|
222
|
-
build: 'ABERLAAS_CWD=$INIT_CWD yarn g:build',
|
|
223
|
-
'build:prod': 'ABERLAAS_CWD=$INIT_CWD yarn g:build:prod',
|
|
224
|
-
cms: 'ABERLAAS_CWD=$INIT_CWD yarn g:cms',
|
|
225
|
-
serve: 'ABERLAAS_CWD=$INIT_CWD yarn g:serve',
|
|
226
|
-
|
|
227
|
-
// Lib
|
|
228
|
-
release: 'ABERLAAS_CWD=$INIT_CWD yarn g:release',
|
|
229
|
-
test: 'ABERLAAS_CWD=$INIT_CWD yarn g:test',
|
|
230
|
-
'test:watch': 'ABERLAAS_CWD=$INIT_CWD yarn g:test:watch',
|
|
231
|
-
|
|
232
|
-
// Common
|
|
233
|
-
compress: 'ABERLAAS_CWD=$INIT_CWD yarn g:compress',
|
|
234
|
-
lint: 'ABERLAAS_CWD=$INIT_CWD yarn g:lint',
|
|
235
|
-
'lint:fix': 'ABERLAAS_CWD=$INIT_CWD yarn g:lint:fix',
|
|
236
|
-
};
|
|
237
|
-
return {
|
|
238
|
-
author,
|
|
239
|
-
homepage,
|
|
240
|
-
license,
|
|
241
|
-
name,
|
|
242
|
-
repository,
|
|
243
|
-
scripts,
|
|
244
|
-
};
|
|
245
|
-
},
|
|
246
|
-
/**
|
|
247
|
-
* Scaffold a repo for use in a monorepo module contexte
|
|
248
|
-
**/
|
|
249
|
-
async run() {
|
|
250
|
-
await this.createRootWorkspace();
|
|
251
|
-
await this.createDocsWorkspace();
|
|
252
|
-
await this.createLibWorkspace();
|
|
253
|
-
|
|
254
|
-
await this.addLicenseFiles();
|
|
255
|
-
await this.addScripts();
|
|
256
|
-
await this.addConfigFiles();
|
|
257
|
-
await initHelper.addLibFiles();
|
|
258
|
-
},
|
|
259
|
-
__getProjectName: initHelper.getProjectName,
|
|
260
|
-
__getProjectAuthor: initHelper.getProjectAuthor.bind(initHelper),
|
|
261
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import ciInfo from 'ci-info';
|
|
2
|
-
import { exists, firostError, run, which } from 'firost';
|
|
3
|
-
import helper from '../../helper.js';
|
|
4
|
-
import lintYml from './yml.js';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
configPath: '.circleci/config.yml',
|
|
8
|
-
/**
|
|
9
|
-
* Find all relevant files
|
|
10
|
-
* @returns {Array} Array of files
|
|
11
|
-
**/
|
|
12
|
-
async getInputFiles() {
|
|
13
|
-
return await helper.findHostFiles([this.configPath]);
|
|
14
|
-
},
|
|
15
|
-
/**
|
|
16
|
-
* Check if the code is currently running on CircleCI
|
|
17
|
-
* @returns {boolean} True if running on CircleCI, false otherwise
|
|
18
|
-
**/
|
|
19
|
-
isRunningOnCircleCi() {
|
|
20
|
-
return ciInfo.CIRCLE;
|
|
21
|
-
},
|
|
22
|
-
/**
|
|
23
|
-
* Check if the circleci binary is available in the $PATH
|
|
24
|
-
* @returns {boolean} True if available, false otherwise
|
|
25
|
-
**/
|
|
26
|
-
async hasCircleCiBin() {
|
|
27
|
-
const binary = await which('circleci');
|
|
28
|
-
return !!binary;
|
|
29
|
-
},
|
|
30
|
-
/**
|
|
31
|
-
* Validate the CircleCI config file.
|
|
32
|
-
* @returns {boolean} True if valid, throws an error if not
|
|
33
|
-
**/
|
|
34
|
-
async validateConfig() {
|
|
35
|
-
await run('circleci config validate', { stdout: false });
|
|
36
|
-
},
|
|
37
|
-
/**
|
|
38
|
-
* Lint the file, both for yml issues and if possible circleci specifics
|
|
39
|
-
* @returns {boolean} True on success
|
|
40
|
-
**/
|
|
41
|
-
async run() {
|
|
42
|
-
const absoluteConfigPath = helper.hostPath(this.configPath);
|
|
43
|
-
const hasConfigFile = await exists(absoluteConfigPath);
|
|
44
|
-
const isRunningOnCircleCi = this.isRunningOnCircleCi();
|
|
45
|
-
|
|
46
|
-
// Stop early if no config file, or if running on CircleCI
|
|
47
|
-
if (!hasConfigFile || isRunningOnCircleCi) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Lint as yml first
|
|
52
|
-
await lintYml.run([absoluteConfigPath]);
|
|
53
|
-
|
|
54
|
-
// Stop early if no circleci bin available
|
|
55
|
-
if (!(await this.hasCircleCiBin())) {
|
|
56
|
-
return true;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Validate the config
|
|
60
|
-
try {
|
|
61
|
-
await this.validateConfig();
|
|
62
|
-
} catch (error) {
|
|
63
|
-
const errorMessage = `CircleCI config error on ${this.configPath}\n${error.message}`;
|
|
64
|
-
throw firostError('CircleCiLintError', errorMessage);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return true;
|
|
68
|
-
},
|
|
69
|
-
/**
|
|
70
|
-
* Autofix yml issues in file
|
|
71
|
-
* @returns {boolean} True on success
|
|
72
|
-
**/
|
|
73
|
-
async fix() {
|
|
74
|
-
const absoluteConfigPath = helper.hostPath(this.configPath);
|
|
75
|
-
// Fix yml issues
|
|
76
|
-
await lintYml.fix([absoluteConfigPath]);
|
|
77
|
-
|
|
78
|
-
// Check for file errors so it still fails if file is invalid
|
|
79
|
-
await this.run();
|
|
80
|
-
},
|
|
81
|
-
};
|
package/commands/lint/css.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import stylelint from 'stylelint';
|
|
2
|
-
import { _ } from 'golgoth';
|
|
3
|
-
import { firostError, firostImport } from 'firost';
|
|
4
|
-
import helper from '../../helper.js';
|
|
5
|
-
import { fix as prettierFix } from './helpers/prettier.js';
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
/**
|
|
9
|
-
* Find all relevant files
|
|
10
|
-
* @param {Array} userPatterns Patterns to narrow the search down
|
|
11
|
-
* @returns {Array} Array of files
|
|
12
|
-
**/
|
|
13
|
-
async getInputFiles(userPatterns) {
|
|
14
|
-
const filePatterns = _.isEmpty(userPatterns)
|
|
15
|
-
? ['./**/*.css']
|
|
16
|
-
: userPatterns;
|
|
17
|
-
return await helper.findHostFiles(filePatterns, ['.css']);
|
|
18
|
-
},
|
|
19
|
-
/**
|
|
20
|
-
* Lint all files and display results.
|
|
21
|
-
* @param {Array} userPatterns Patterns to narrow the search down
|
|
22
|
-
* @param {string} userConfigFile Custom config file to use
|
|
23
|
-
* @param {object} userOptions Options to pass to ESLint, including fix
|
|
24
|
-
* @returns {boolean} True on success
|
|
25
|
-
**/
|
|
26
|
-
async run(userPatterns, userConfigFile, userOptions = {}) {
|
|
27
|
-
// Options
|
|
28
|
-
const options = { fix: false, ...userOptions };
|
|
29
|
-
|
|
30
|
-
// Files
|
|
31
|
-
const files = await this.getInputFiles(userPatterns);
|
|
32
|
-
if (_.isEmpty(files)) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Config
|
|
37
|
-
const configFile = await helper.configFile(
|
|
38
|
-
userConfigFile,
|
|
39
|
-
'stylelint.config.js',
|
|
40
|
-
'configs/stylelint.js',
|
|
41
|
-
);
|
|
42
|
-
const config = await firostImport(configFile);
|
|
43
|
-
|
|
44
|
-
const result = await stylelint.lint({
|
|
45
|
-
config,
|
|
46
|
-
files,
|
|
47
|
-
formatter: 'string',
|
|
48
|
-
...options,
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
if (result.errored) {
|
|
52
|
-
throw firostError('ERROR_CSS_LINT', result.output);
|
|
53
|
-
}
|
|
54
|
-
return true;
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* Autofix files in place
|
|
58
|
-
* @param {Array} userPatterns Patterns to narrow the search down
|
|
59
|
-
* @param {string} userConfigFile Custom config file to use
|
|
60
|
-
* @returns {boolean} True on success
|
|
61
|
-
**/
|
|
62
|
-
async fix(userPatterns, userConfigFile) {
|
|
63
|
-
const files = await this.getInputFiles(userPatterns);
|
|
64
|
-
if (_.isEmpty(files)) {
|
|
65
|
-
return true;
|
|
66
|
-
}
|
|
67
|
-
// Try to pretiffy as much as we can
|
|
68
|
-
await prettierFix(files);
|
|
69
|
-
// Still run a lint on it so it can fail if not everything is fixed
|
|
70
|
-
await this.run(userPatterns, userConfigFile, { fix: true });
|
|
71
|
-
return true;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import * as prettier from 'prettier';
|
|
2
|
-
import { firostError, read, write } from 'firost';
|
|
3
|
-
import { _, pMap } from 'golgoth';
|
|
4
|
-
import helper from '../../../helper.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Fix all files using prettier
|
|
8
|
-
* @param {Array} inputFiles Files to auto-fix
|
|
9
|
-
**/
|
|
10
|
-
export async function fix(inputFiles) {
|
|
11
|
-
// Config file
|
|
12
|
-
const configFile = await helper.configFile(
|
|
13
|
-
null,
|
|
14
|
-
'prettier.config.js',
|
|
15
|
-
'configs/prettier.js',
|
|
16
|
-
);
|
|
17
|
-
const config = await prettier.resolveConfig(configFile);
|
|
18
|
-
|
|
19
|
-
const errors = [];
|
|
20
|
-
|
|
21
|
-
// Read all files, run them through the formatter and save them back to disk
|
|
22
|
-
// If any emits error, store the errors and display them all in one output
|
|
23
|
-
await pMap(
|
|
24
|
-
inputFiles,
|
|
25
|
-
async (filepath) => {
|
|
26
|
-
try {
|
|
27
|
-
const content = await read(filepath);
|
|
28
|
-
const options = { ...config, filepath };
|
|
29
|
-
const result = await prettier.format(content, options);
|
|
30
|
-
await write(result, filepath);
|
|
31
|
-
} catch (error) {
|
|
32
|
-
const message = error.toString();
|
|
33
|
-
errors.push({ filepath, message });
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{ concurrency: 10 },
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (!_.isEmpty(errors)) {
|
|
40
|
-
let formattedErrors = '';
|
|
41
|
-
_.each(errors, (error) => {
|
|
42
|
-
formattedErrors = `${formattedErrors}${error.filepath}\n\n${error.message}\n\n`;
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
throw firostError(
|
|
46
|
-
'LINT_ERROR_FIX_PRETTIER',
|
|
47
|
-
`Some files could not be automatically fixed:\n\n${formattedErrors}`,
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default {
|
|
53
|
-
fix,
|
|
54
|
-
};
|
package/commands/lint/index.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { _, pMap } from 'golgoth';
|
|
2
|
-
import { consoleError, firostError } from 'firost';
|
|
3
|
-
import linterCircleCI from './circleci.js';
|
|
4
|
-
import linterCss from './css.js';
|
|
5
|
-
import linterJson from './json.js';
|
|
6
|
-
import linterJs from './js.js';
|
|
7
|
-
import linterYml from './yml.js';
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
linters: {
|
|
11
|
-
circleci: linterCircleCI,
|
|
12
|
-
css: linterCss,
|
|
13
|
-
json: linterJson,
|
|
14
|
-
js: linterJs,
|
|
15
|
-
yml: linterYml,
|
|
16
|
-
},
|
|
17
|
-
/**
|
|
18
|
-
* Wrapper to lint all supported formats
|
|
19
|
-
* @param {object} cliArgs CLI Argument object, as created by minimist
|
|
20
|
-
* @returns {boolean} True on success
|
|
21
|
-
**/
|
|
22
|
-
async run(cliArgs = {}) {
|
|
23
|
-
const allTypesKeys = _.keys(this.linters);
|
|
24
|
-
const userTypes = _.intersection(_.keys(cliArgs), allTypesKeys);
|
|
25
|
-
const typesToLint = _.isEmpty(userTypes) ? allTypesKeys : userTypes;
|
|
26
|
-
|
|
27
|
-
let hasErrors = false;
|
|
28
|
-
await pMap(typesToLint, async (type) => {
|
|
29
|
-
const methodName = cliArgs.fix ? 'fix' : 'run';
|
|
30
|
-
try {
|
|
31
|
-
const linter = this.linters[type];
|
|
32
|
-
|
|
33
|
-
const configFile = _.get(cliArgs, `config.${type}`);
|
|
34
|
-
const userPatterns = _.get(cliArgs, '_');
|
|
35
|
-
|
|
36
|
-
await linter[methodName](userPatterns, configFile);
|
|
37
|
-
} catch (error) {
|
|
38
|
-
this.__consoleError(error.message);
|
|
39
|
-
hasErrors = true;
|
|
40
|
-
}
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
if (hasErrors) {
|
|
44
|
-
throw firostError('ERROR_LINT', 'Error while linting files');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return true;
|
|
48
|
-
},
|
|
49
|
-
__consoleError: consoleError,
|
|
50
|
-
};
|