@w5s/mrm-preset 1.0.0-alpha.2 → 1.0.0-alpha.21
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/.turbo/turbo-build.log +11 -0
- package/.turbo/turbo-docs.log +43 -0
- package/.turbo/turbo-format.log +7 -0
- package/.turbo/turbo-lint.log +7 -0
- package/.turbo/turbo-prepare.log +2 -0
- package/.turbo/turbo-test.log +19 -0
- package/CHANGELOG.md +237 -0
- package/README.md +1 -1
- package/bootstrap/index.js +43 -42
- package/ci/_gitlab/AutoDevopsInclude.gitlab-ci.yml +2 -0
- package/ci/github.js +47 -0
- package/ci/gitlab.js +1 -1
- package/ci/index.js +7 -2
- package/commitlint/index.js +5 -2
- package/config.json +1 -0
- package/contributing/index.js +1 -1
- package/contributing/templates/CODE_OF_CONDUCT.md +3 -4
- package/core/block.js +2 -3
- package/core/commitlint.js +3 -3
- package/core/cspell.js +1 -10
- package/core/eslint.js +25 -6
- package/{gitignore/template.js → core/git.ignore.js} +32 -6
- package/core/git.js +21 -18
- package/core/githooks.js +8 -7
- package/core/githubCI.js +56 -0
- package/core/jest.js +50 -69
- package/core/jsonFile.js +8 -7
- package/core/lintStaged.js +3 -3
- package/core/npm.js +52 -15
- package/core/pkg.js +92 -14
- package/core/project.js +6 -0
- package/core/semanticRelease.js +4 -4
- package/core/turbo.js +57 -0
- package/core/typedoc.js +7 -20
- package/core/vscode.js +1 -1
- package/cspell/index.js +20 -10
- package/editorconfig/index.js +3 -1
- package/eslint/index.js +81 -32
- package/githooks/index.js +47 -56
- package/gitignore/index.js +5 -22
- package/jest/index.js +13 -17
- package/lang/.eslintrc.json +4 -1
- package/lang/index.js +22 -19
- package/licenses/index.js +26 -0
- package/package.json +17 -12
- package/postconfigure/index.js +3 -3
- package/project/index.js +217 -156
- package/release/index.js +5 -5
- package/renovate/index.js +7 -5
- package/tsconfig.json +2 -1
- package/core/workspace.js +0 -6
package/project/index.js
CHANGED
|
@@ -1,207 +1,268 @@
|
|
|
1
|
+
const { dirname } = require('node:path');
|
|
1
2
|
const { packageJson, json, makeDirs } = require('mrm-core');
|
|
2
|
-
const git = require('../core/git');
|
|
3
|
-
const pkg = require('../core/pkg');
|
|
4
|
-
const npm = require('../core/npm');
|
|
5
|
-
const { vscodeTask } = require('../core/vscode');
|
|
6
|
-
const project = require('../core/project');
|
|
3
|
+
const git = require('../core/git.js');
|
|
4
|
+
const pkg = require('../core/pkg.js');
|
|
5
|
+
const npm = require('../core/npm.js');
|
|
6
|
+
const { vscodeTask } = require('../core/vscode.js');
|
|
7
|
+
const project = require('../core/project.js');
|
|
7
8
|
const mrmPackageJson = require('../package.json');
|
|
9
|
+
const { turbo } = require('../core/turbo.js');
|
|
8
10
|
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param {string} script
|
|
14
|
+
*/
|
|
15
|
+
const npmRun = (script) => {
|
|
16
|
+
switch (script) {
|
|
17
|
+
case project.install:
|
|
18
|
+
case project.test:
|
|
19
|
+
return `npm ${script}`;
|
|
20
|
+
default:
|
|
21
|
+
return `npm run ${script}`;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @param {string} script
|
|
27
|
+
*/
|
|
28
|
+
const turboRun = (script) => `turbo run ${script}`;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {string} script
|
|
33
|
+
* @param {boolean} allowEmpty
|
|
34
|
+
*/
|
|
35
|
+
const npmRunAll = (script, allowEmpty) => `concurrently "npm:${script}:*" ${allowEmpty ? `"${pkg.emptyScript}"` : ''}`;
|
|
9
36
|
function task() {
|
|
10
|
-
const
|
|
37
|
+
const rootPackageFile = packageJson();
|
|
38
|
+
const rootUseWorkspace = pkg.hasWorkspaces(rootPackageFile);
|
|
39
|
+
const rootEngineMinVersion = Object.assign(
|
|
40
|
+
{
|
|
41
|
+
node: '>=12.x',
|
|
42
|
+
yarn: '>=1.x',
|
|
43
|
+
npm: '>=6.x',
|
|
44
|
+
},
|
|
45
|
+
mrmPackageJson.engines
|
|
46
|
+
);
|
|
11
47
|
const gitSupported = git.hasGit();
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
*
|
|
17
|
-
* @param {string} script
|
|
18
|
-
*/
|
|
19
|
-
const npmRun = (script) => {
|
|
20
|
-
switch (script) {
|
|
21
|
-
case project.install:
|
|
22
|
-
case project.test:
|
|
23
|
-
return `npm ${script}`;
|
|
24
|
-
default:
|
|
25
|
-
return `npm run ${script}`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
*
|
|
30
|
-
* @param {string} script
|
|
31
|
-
*/
|
|
32
|
-
const lernaRun = (script) => `lerna run ${script}`;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
*
|
|
36
|
-
* @param {string} script
|
|
37
|
-
*/
|
|
38
|
-
const npmRunAll = (script) => `npm-run-all -p "${script}:*"`;
|
|
48
|
+
const packageManager = pkg.manager(rootPackageFile);
|
|
49
|
+
const gitRepository = git.remoteSync();
|
|
39
50
|
|
|
40
51
|
// Detect git repository
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const gitRepository = git.remoteSync();
|
|
46
|
-
if (gitRepository) {
|
|
47
|
-
return {
|
|
48
|
-
type: 'git',
|
|
49
|
-
url: gitRepository,
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return undefined;
|
|
54
|
-
},
|
|
55
|
-
});
|
|
52
|
+
if (rootUseWorkspace) {
|
|
53
|
+
const dirs = pkg.listWorkspaceMatchers(rootPackageFile).map(dirname);
|
|
54
|
+
makeDirs(dirs);
|
|
55
|
+
}
|
|
56
56
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
name: project.build,
|
|
60
|
-
script: npmRunAll(project.build),
|
|
61
|
-
state: 'present',
|
|
62
|
-
});
|
|
63
|
-
pkg.script(packageFile, {
|
|
64
|
-
name: `${project.build}:empty`,
|
|
65
|
-
script: pkg.emptyScript,
|
|
66
|
-
state: 'present',
|
|
67
|
-
});
|
|
68
|
-
pkg.script(packageFile, {
|
|
69
|
-
name: `${project.build}:packages`,
|
|
70
|
-
script: lernaRun(project.build),
|
|
71
|
-
state: useWorkspace ? 'present' : 'absent',
|
|
72
|
-
});
|
|
73
|
-
pkg.script(packageFile, {
|
|
74
|
-
name: project.clean,
|
|
75
|
-
script: useWorkspace ? lernaRun(project.clean) : pkg.emptyScript,
|
|
76
|
-
state: useWorkspace ? 'present' : 'default',
|
|
77
|
-
});
|
|
57
|
+
const addScripts = (/** @type {import("mrm-core").Json} */ currentPackageFile, /** @type {boolean} */ root) => {
|
|
58
|
+
const useWorkspace = pkg.hasWorkspaces(currentPackageFile);
|
|
78
59
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
60
|
+
// build
|
|
61
|
+
pkg.script(currentPackageFile, {
|
|
62
|
+
name: project.build,
|
|
63
|
+
script: npmRunAll(project.build, false),
|
|
64
|
+
state: 'present',
|
|
65
|
+
});
|
|
66
|
+
pkg.script(currentPackageFile, {
|
|
67
|
+
name: `${project.build}:packages`,
|
|
68
|
+
script: turboRun(project.build),
|
|
69
|
+
state: useWorkspace ? 'present' : 'absent',
|
|
70
|
+
});
|
|
85
71
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
72
|
+
// lint
|
|
73
|
+
pkg.script(currentPackageFile, {
|
|
74
|
+
name: project.lint,
|
|
75
|
+
script: npmRunAll(project.lint, true),
|
|
76
|
+
state: 'present',
|
|
77
|
+
});
|
|
78
|
+
pkg.script(currentPackageFile, {
|
|
79
|
+
name: project.format,
|
|
80
|
+
script: npmRunAll(project.format, true),
|
|
81
|
+
state: 'present',
|
|
82
|
+
});
|
|
97
83
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
name: project.coverage,
|
|
101
|
-
script: pkg.emptyScript,
|
|
102
|
-
state: 'default',
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
pkg.script(packageFile, {
|
|
110
|
-
name: project.validate,
|
|
111
|
-
script: `${npmRun(project.build)} && ${npmRun(project.lint)} && ${npmRun(project.test)}`,
|
|
112
|
-
state: 'present',
|
|
113
|
-
});
|
|
84
|
+
// test
|
|
85
|
+
// pkg.script(currentPackageFile, {
|
|
86
|
+
// name: project.coverage,
|
|
87
|
+
// script: pkg.emptyScript,
|
|
88
|
+
// state: 'default',
|
|
89
|
+
// });
|
|
90
|
+
pkg.script(currentPackageFile, {
|
|
91
|
+
name: project.test,
|
|
92
|
+
script: useWorkspace ? npmRunAll(project.test, false) : pkg.emptyScript,
|
|
93
|
+
state: useWorkspace ? 'present' : 'default',
|
|
94
|
+
});
|
|
114
95
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
96
|
+
// prepare
|
|
97
|
+
pkg.script(currentPackageFile, {
|
|
98
|
+
name: project.prepare,
|
|
99
|
+
script: npmRunAll(project.prepare, true),
|
|
100
|
+
state: 'present',
|
|
101
|
+
});
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
pkg.script(packageFile, {
|
|
134
|
-
name: `${project.prepare}:packages`,
|
|
135
|
-
script: 'lerna bootstrap',
|
|
136
|
-
state: useWorkspace ? 'present' : 'absent',
|
|
137
|
-
});
|
|
103
|
+
// clean
|
|
104
|
+
pkg.script(currentPackageFile, {
|
|
105
|
+
name: project.clean,
|
|
106
|
+
script: npmRunAll(project.clean, true),
|
|
107
|
+
state: 'present',
|
|
108
|
+
});
|
|
109
|
+
pkg.script(currentPackageFile, {
|
|
110
|
+
name: `${project.clean}:packages`,
|
|
111
|
+
script: turboRun(project.clean),
|
|
112
|
+
state: useWorkspace ? 'present' : 'absent',
|
|
113
|
+
});
|
|
138
114
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
script
|
|
143
|
-
|
|
115
|
+
// Root
|
|
116
|
+
|
|
117
|
+
// rescue
|
|
118
|
+
pkg.script(currentPackageFile, {
|
|
119
|
+
name: project.rescue,
|
|
120
|
+
script: `${gitSupported ? 'git clean -fdx' : ''};${packageManager} install`,
|
|
121
|
+
state: root ? 'present' : 'absent',
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// release
|
|
125
|
+
pkg.script(currentPackageFile, {
|
|
126
|
+
name: project.release,
|
|
127
|
+
script: pkg.emptyScript,
|
|
128
|
+
state: root ? 'default' : 'absent',
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// code analysis
|
|
132
|
+
pkg.script(currentPackageFile, {
|
|
133
|
+
name: project.codeAnalysis,
|
|
134
|
+
script: pkg.emptyScript,
|
|
135
|
+
state: root ? 'default' : 'absent',
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// develop & auto build & load
|
|
139
|
+
pkg.script(currentPackageFile, {
|
|
140
|
+
name: project.develop,
|
|
141
|
+
script: pkg.emptyScript,
|
|
142
|
+
state: root ? 'default' : 'absent',
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
// eslint-disable-next-line no-shadow
|
|
147
|
+
pkg.withPackageJson((packageFile) => {
|
|
148
|
+
pkg.value(packageFile, {
|
|
149
|
+
path: 'repository',
|
|
150
|
+
state: 'present',
|
|
151
|
+
update: () =>
|
|
152
|
+
gitRepository
|
|
153
|
+
? {
|
|
154
|
+
type: 'git',
|
|
155
|
+
url: gitRepository,
|
|
156
|
+
}
|
|
157
|
+
: undefined,
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
addScripts(packageFile, true);
|
|
161
|
+
|
|
162
|
+
pkg.script(packageFile, {
|
|
163
|
+
name: project.validate,
|
|
164
|
+
script: `${npmRun(project.build)} && ${npmRun(project.lint)} && ${npmRun(project.test)}`,
|
|
165
|
+
state: 'present',
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
// Engine
|
|
169
|
+
pkg.engineMinVersion(packageFile, rootEngineMinVersion);
|
|
144
170
|
});
|
|
171
|
+
pkg.forEachWorkspace((workspace) => {
|
|
172
|
+
pkg.value(workspace.packageFile, {
|
|
173
|
+
path: 'repository',
|
|
174
|
+
state: 'present',
|
|
175
|
+
update: () =>
|
|
176
|
+
gitRepository
|
|
177
|
+
? {
|
|
178
|
+
type: 'git',
|
|
179
|
+
url: gitRepository,
|
|
180
|
+
directory: workspace.projectDir,
|
|
181
|
+
}
|
|
182
|
+
: undefined,
|
|
183
|
+
});
|
|
184
|
+
addScripts(workspace.packageFile, false);
|
|
145
185
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
name: project.release,
|
|
149
|
-
script: pkg.emptyScript,
|
|
150
|
-
state: 'default',
|
|
186
|
+
// Engine
|
|
187
|
+
pkg.engineMinVersion(workspace.packageFile, { node: rootEngineMinVersion.node });
|
|
151
188
|
});
|
|
152
189
|
|
|
153
190
|
// workspace
|
|
154
191
|
const lernaConfig = json('lerna.json', {
|
|
155
|
-
version:
|
|
192
|
+
version: rootPackageFile.get('version'),
|
|
156
193
|
});
|
|
157
|
-
if (
|
|
158
|
-
const packages = ['packages/*'];
|
|
194
|
+
if (rootUseWorkspace) {
|
|
159
195
|
const versionIndependent = lernaConfig.get('version') === 'independent';
|
|
160
|
-
|
|
196
|
+
const gitmoji = true;
|
|
197
|
+
|
|
161
198
|
lernaConfig.merge({
|
|
199
|
+
$schema: 'https://json.schemastore.org/lerna.json',
|
|
162
200
|
command: {
|
|
163
201
|
publish: {
|
|
164
202
|
conventionalCommits: true,
|
|
165
203
|
npmClient: 'npm',
|
|
166
204
|
},
|
|
167
205
|
version: {
|
|
168
|
-
message:
|
|
206
|
+
message: gitmoji
|
|
207
|
+
? `🔖 Publish${versionIndependent ? '' : ' %s'}`
|
|
208
|
+
: `chore(release): publish${versionIndependent ? '' : ' %s'}`,
|
|
169
209
|
},
|
|
170
210
|
},
|
|
171
211
|
npmClient: packageManager,
|
|
172
|
-
useWorkspaces:
|
|
212
|
+
useWorkspaces: rootUseWorkspace,
|
|
213
|
+
changelogPreset: 'gitmoji-config',
|
|
173
214
|
});
|
|
174
215
|
lernaConfig.save();
|
|
175
|
-
makeDirs('packages');
|
|
176
216
|
} else {
|
|
177
|
-
packageFile.unset('workspaces');
|
|
178
217
|
lernaConfig.delete();
|
|
179
218
|
}
|
|
180
219
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
220
|
+
rootPackageFile.save();
|
|
221
|
+
|
|
222
|
+
// Turbo config
|
|
223
|
+
turbo({
|
|
224
|
+
state: rootUseWorkspace ? 'present' : 'absent',
|
|
225
|
+
update: (_) => ({
|
|
226
|
+
..._,
|
|
227
|
+
baseBranch: 'origin/main',
|
|
228
|
+
pipeline: {
|
|
229
|
+
[project.build]: {
|
|
230
|
+
dependsOn: ['^build'],
|
|
231
|
+
outputs: ['lib/**', 'dist/**', '.next/**'],
|
|
232
|
+
},
|
|
233
|
+
[project.test]: {},
|
|
234
|
+
[project.lint]: {},
|
|
235
|
+
[project.prepare]: {},
|
|
236
|
+
[project.format]: {},
|
|
237
|
+
[project.docs]: {},
|
|
238
|
+
[project.spellcheck]: {},
|
|
239
|
+
[project.clean]: {
|
|
240
|
+
cache: false,
|
|
241
|
+
},
|
|
242
|
+
[project.develop]: {
|
|
243
|
+
cache: false,
|
|
244
|
+
},
|
|
189
245
|
},
|
|
190
|
-
|
|
191
|
-
)
|
|
192
|
-
);
|
|
193
|
-
packageFile.save();
|
|
246
|
+
globalDependencies: ['tsconfig.settings.json'],
|
|
247
|
+
}),
|
|
248
|
+
});
|
|
194
249
|
|
|
195
250
|
// Dependencies
|
|
251
|
+
// clean
|
|
196
252
|
npm.dependency({
|
|
197
253
|
dev: true,
|
|
198
254
|
name: ['npm-run-all'],
|
|
255
|
+
state: 'absent',
|
|
256
|
+
});
|
|
257
|
+
npm.dependency({
|
|
258
|
+
dev: true,
|
|
259
|
+
name: ['concurrently'],
|
|
199
260
|
state: 'present',
|
|
200
261
|
});
|
|
201
262
|
npm.dependency({
|
|
202
263
|
dev: true,
|
|
203
|
-
name: ['lerna'],
|
|
204
|
-
state:
|
|
264
|
+
name: ['lerna', 'conventional-changelog-gitmoji-config'],
|
|
265
|
+
state: rootUseWorkspace ? 'present' : 'absent',
|
|
205
266
|
});
|
|
206
267
|
|
|
207
268
|
// VSCode
|
package/release/index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const { packageJson } = require('mrm-core');
|
|
2
|
-
const pkg = require('../core/pkg');
|
|
3
|
-
const project = require('../core/project');
|
|
4
|
-
const { semanticRelease } = require('../core/semanticRelease');
|
|
2
|
+
const pkg = require('../core/pkg.js');
|
|
3
|
+
const project = require('../core/project.js');
|
|
4
|
+
const { semanticRelease } = require('../core/semanticRelease.js');
|
|
5
5
|
|
|
6
6
|
function task() {
|
|
7
|
-
const useWorkspace = packageJson()
|
|
7
|
+
const useWorkspace = pkg.hasWorkspaces(packageJson());
|
|
8
8
|
|
|
9
9
|
// release
|
|
10
10
|
pkg.withPackageJson((packageFile) => {
|
|
11
11
|
pkg.script(packageFile, {
|
|
12
12
|
name: project.release,
|
|
13
13
|
// eslint-disable-next-line no-template-curly-in-string
|
|
14
|
-
script: useWorkspace ? '
|
|
14
|
+
script: useWorkspace ? 'is-ci && lerna publish --yes || lerna publish' : semanticRelease.command(),
|
|
15
15
|
state: 'present',
|
|
16
16
|
});
|
|
17
17
|
});
|
package/renovate/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
const { json, packageJson } = require('mrm-core');
|
|
2
|
-
const { hasGit } = require('../core/git');
|
|
2
|
+
const { hasGit } = require('../core/git.js');
|
|
3
|
+
const pkg = require('../core/pkg.js');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
*
|
|
6
7
|
* @param {{
|
|
7
|
-
* renovatePresetApplication: string
|
|
8
|
+
* renovatePresetApplication: string,
|
|
8
9
|
* renovatePresetLibrary: string
|
|
9
10
|
* }} config
|
|
10
11
|
*/
|
|
@@ -19,7 +20,8 @@ function createRenovate({ renovatePresetApplication, renovatePresetLibrary }) {
|
|
|
19
20
|
const gitSupported = hasGit();
|
|
20
21
|
|
|
21
22
|
if (gitSupported) {
|
|
22
|
-
const
|
|
23
|
+
const packageFile = packageJson();
|
|
24
|
+
const packageArchetype = pkg.archetype(packageFile);
|
|
23
25
|
const renovatePresetResolved =
|
|
24
26
|
renovatePreset || (packageArchetype === 'application' ? renovatePresetApplication : renovatePresetLibrary);
|
|
25
27
|
const renovateFile = json('renovate.json');
|
|
@@ -54,6 +56,6 @@ function createRenovate({ renovatePresetApplication, renovatePresetLibrary }) {
|
|
|
54
56
|
}
|
|
55
57
|
|
|
56
58
|
module.exports = createRenovate({
|
|
57
|
-
renovatePresetApplication: '
|
|
58
|
-
renovatePresetLibrary: '
|
|
59
|
+
renovatePresetApplication: 'github>w5s/renovate-config:application',
|
|
60
|
+
renovatePresetLibrary: 'github>w5s/renovate-config:library',
|
|
59
61
|
});
|
package/tsconfig.json
CHANGED