@w5s/mrm-preset 1.0.0-alpha.10 → 1.0.0-alpha.13
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 +1 -1
- package/.turbo/turbo-docs.log +1 -1
- package/.turbo/turbo-format.log +1 -0
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-spellcheck.log +2 -0
- package/.turbo/turbo-test.log +2 -1
- package/CHANGELOG.md +49 -0
- package/ci/github.js +47 -0
- package/ci/index.js +5 -0
- package/core/cspell.js +0 -9
- package/core/githubCI.js +56 -0
- package/core/jest.js +1 -6
- package/core/pkg.js +40 -5
- package/core/project.js +6 -0
- package/core/turbo.js +56 -0
- package/cspell/index.js +21 -0
- package/eslint/index.js +60 -12
- package/package.json +7 -5
- package/project/index.js +44 -37
package/.turbo/turbo-build.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@w5s/mrm-preset:build: cache hit, replaying output
|
|
1
|
+
@w5s/mrm-preset:build: cache hit, replaying output f00c77759cb37454
|
package/.turbo/turbo-docs.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@w5s/mrm-preset:docs: cache hit, replaying output
|
|
1
|
+
@w5s/mrm-preset:docs: cache hit, replaying output bf59b36291ca9782
|
|
2
2
|
@w5s/mrm-preset:docs: Starting markdown-magic [ '**/*.md', '!node_modules/**' ]
|
|
3
3
|
@w5s/mrm-preset:docs: ℹ Notice:
|
|
4
4
|
@w5s/mrm-preset:docs: Missing transforms "BASIC_RULES","JSX_RULES" in _tester/node_modules/eslint-plugin-react/README.md
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@w5s/mrm-preset:format: cache hit, replaying output [2md9ab8a49347bb8ce[0m
|
package/.turbo/turbo-lint.log
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@w5s/mrm-preset:lint: cache hit, replaying output
|
|
1
|
+
@w5s/mrm-preset:lint: cache hit, replaying output b854c5088325daff
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@w5s/mrm-preset:test: cache hit, replaying output
|
|
1
|
+
@w5s/mrm-preset:test: cache hit, replaying output 4a4cf62937c5212f
|
|
2
2
|
@w5s/mrm-preset:test: mkdir: _tester: File exists
|
|
3
3
|
@w5s/mrm-preset:test: [36mRunning bootstrap...[39m
|
|
4
4
|
@w5s/mrm-preset:test: [33mRunning alias configure...[39m
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
@w5s/mrm-preset:test: [36mRunning editorconfig...[39m
|
|
14
14
|
@w5s/mrm-preset:test: [36mRunning eslint...[39m
|
|
15
15
|
@w5s/mrm-preset:test: [36mRunning cspell...[39m
|
|
16
|
+
@w5s/mrm-preset:test: [32mUpdate package.json[39m
|
|
16
17
|
@w5s/mrm-preset:test: [36mRunning jest...[39m
|
|
17
18
|
@w5s/mrm-preset:test: [32mUpdate package.json[39m
|
|
18
19
|
@w5s/mrm-preset:test: [36mRunning renovate...[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,55 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.13](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.12...@w5s/mrm-preset@1.0.0-alpha.13) (2022-06-07)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* improve cspell output ([a5721b5](https://github.com/w5s/project-config/commit/a5721b5c8e97817dc68e9444f4443d3cb7893a27))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.0.0-alpha.12](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.11...@w5s/mrm-preset@1.0.0-alpha.12) (2022-06-07)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Bug Fixes
|
|
21
|
+
|
|
22
|
+
* add spellcheck task to turbo config ([1029c2b](https://github.com/w5s/project-config/commit/1029c2b97b12b44618ce741d045b02712f0ebf18))
|
|
23
|
+
* clean non useful empty script when possible ([2e7e60a](https://github.com/w5s/project-config/commit/2e7e60a400506bbca00db653813668fa47f8f065))
|
|
24
|
+
* correct docs task in turbo ([0fca8c9](https://github.com/w5s/project-config/commit/0fca8c9ca0389b090e6aa2a66d47ab63b1cb138e))
|
|
25
|
+
* remove uneeded @types/jest typing ([475f6bb](https://github.com/w5s/project-config/commit/475f6bbdc101d31460cd8ffb7f5deb3b97176d5c))
|
|
26
|
+
* remove uneeded cspell script ([ba8d38b](https://github.com/w5s/project-config/commit/ba8d38b8053a24a7937c24c270f5d61d3dad71c7))
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
### Features
|
|
30
|
+
|
|
31
|
+
* configure spellcheck ([4be6a96](https://github.com/w5s/project-config/commit/4be6a96d6d30e1085b73c0befcab1d3fa30475ab))
|
|
32
|
+
* improve eslint mrm support for workspaces ([2dacc2e](https://github.com/w5s/project-config/commit/2dacc2e867ebb74c8de777af2ce9f173426ebc33))
|
|
33
|
+
* improve turbo support for lint and format ([76e19e0](https://github.com/w5s/project-config/commit/76e19e02918aba66a2e6e9c06a7d0bed99500ecc))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
# [1.0.0-alpha.11](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.10...@w5s/mrm-preset@1.0.0-alpha.11) (2022-05-20)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Bug Fixes
|
|
43
|
+
|
|
44
|
+
* correct prepare package script ([f2d5fbf](https://github.com/w5s/project-config/commit/f2d5fbfc4e7b66dece1d1139e2ba3835bcf524a1))
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Features
|
|
48
|
+
|
|
49
|
+
* add minimal support for yarn + github ci ([b9ae537](https://github.com/w5s/project-config/commit/b9ae53746fa9a3f92a1ca0e3600e20cdda583a45))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
6
55
|
# [1.0.0-alpha.10](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.9...@w5s/mrm-preset@1.0.0-alpha.10) (2022-05-13)
|
|
7
56
|
|
|
8
57
|
|
package/ci/github.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable global-require, sort-keys-fix/sort-keys-fix */
|
|
2
|
+
const { packageJson } = require('mrm-core');
|
|
3
|
+
const githubCI = require('../core/githubCI');
|
|
4
|
+
const pkg = require('../core/pkg');
|
|
5
|
+
|
|
6
|
+
function task() {
|
|
7
|
+
const state = 'present';
|
|
8
|
+
const packageManager = pkg.manager(packageJson());
|
|
9
|
+
githubCI.workflow({
|
|
10
|
+
name: 'node.js.yml',
|
|
11
|
+
state,
|
|
12
|
+
update: (config) => ({
|
|
13
|
+
name: 'Node.js CI',
|
|
14
|
+
...config,
|
|
15
|
+
on: {
|
|
16
|
+
push: {
|
|
17
|
+
branches: ['main'],
|
|
18
|
+
},
|
|
19
|
+
pull_request: {
|
|
20
|
+
branches: ['main'],
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
jobs: {
|
|
24
|
+
...config.jobs,
|
|
25
|
+
build: {
|
|
26
|
+
'runs-on': 'ubuntu-latest',
|
|
27
|
+
steps: [
|
|
28
|
+
{ uses: 'actions/checkout@v3' },
|
|
29
|
+
{
|
|
30
|
+
name: 'Use Node.js',
|
|
31
|
+
uses: 'actions/setup-node@v3',
|
|
32
|
+
with: {
|
|
33
|
+
'node-version': 'lts/*',
|
|
34
|
+
cache: packageManager,
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{ run: `${packageManager} install` },
|
|
38
|
+
{ run: `${packageManager} run build` },
|
|
39
|
+
{ run: `${packageManager} validate` },
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports = task;
|
package/ci/index.js
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
const gitlabCI = require('../core/gitlabCI');
|
|
2
|
+
const githubCI = require('../core/githubCI');
|
|
2
3
|
const gitlab = require('./gitlab');
|
|
4
|
+
const github = require('./github');
|
|
3
5
|
|
|
4
6
|
function task() {
|
|
5
7
|
// check gitlab support
|
|
6
8
|
if (gitlabCI.isSupported()) {
|
|
7
9
|
gitlab();
|
|
8
10
|
}
|
|
11
|
+
if (githubCI.isSupported()) {
|
|
12
|
+
github();
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
|
|
11
16
|
task.description = 'Setup Continuous Integration';
|
package/core/cspell.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const { json } = require('mrm-core');
|
|
2
|
-
const pkg = require('./pkg');
|
|
3
2
|
const npm = require('./npm');
|
|
4
3
|
/**
|
|
5
4
|
* @typedef {{
|
|
@@ -22,14 +21,6 @@ const npm = require('./npm');
|
|
|
22
21
|
function cspell({ state, update }) {
|
|
23
22
|
const hasCSpell = state === 'present';
|
|
24
23
|
|
|
25
|
-
pkg.withPackageJson((packageFile) => {
|
|
26
|
-
pkg.script(packageFile, {
|
|
27
|
-
name: 'cspell',
|
|
28
|
-
script: 'cspell',
|
|
29
|
-
state,
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
24
|
const cSpellFile = json('cSpell.json', {
|
|
34
25
|
version: '0.2',
|
|
35
26
|
language: 'en',
|
package/core/githubCI.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { yaml } = require('mrm-core');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
|
|
5
|
+
const FILE_PATH = '.github/workflows';
|
|
6
|
+
|
|
7
|
+
function isSupported() {
|
|
8
|
+
return fs.existsSync(FILE_PATH);
|
|
9
|
+
}
|
|
10
|
+
exports.isSupported = isSupported;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef { string | {
|
|
14
|
+
* group: string,
|
|
15
|
+
* 'cancel-in-progress': boolean,
|
|
16
|
+
* }} GithubWorkflowConcurrency
|
|
17
|
+
*/
|
|
18
|
+
// TODO: add strict typing
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {{
|
|
21
|
+
* name?: string,
|
|
22
|
+
* jobs?: Record<string, any>
|
|
23
|
+
* on?: any,
|
|
24
|
+
* env?: Record<string, string>,
|
|
25
|
+
* permissions?: any,
|
|
26
|
+
* defaults?: Record<string, any>,
|
|
27
|
+
* concurrency?: GithubWorkflowConcurrency,
|
|
28
|
+
* }} GithubWorkflowConfig
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @param {{
|
|
33
|
+
* state: 'present'|'absent',
|
|
34
|
+
* name: string,
|
|
35
|
+
* update?: (config: GithubWorkflowConfig) => GithubWorkflowConfig
|
|
36
|
+
* }} options
|
|
37
|
+
*/
|
|
38
|
+
function workflow({ name, state, update }) {
|
|
39
|
+
const workflowFile = yaml(path.join(FILE_PATH, name));
|
|
40
|
+
if (state === 'present') {
|
|
41
|
+
/** @type {GithubWorkflowConfig} */
|
|
42
|
+
let value = workflowFile.get() || {
|
|
43
|
+
jobs: {},
|
|
44
|
+
};
|
|
45
|
+
if (update) {
|
|
46
|
+
value = update(value);
|
|
47
|
+
// @ts-ignore
|
|
48
|
+
workflowFile.set(value);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
workflowFile.save();
|
|
52
|
+
} else {
|
|
53
|
+
workflowFile.delete();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.workflow = workflow;
|
package/core/jest.js
CHANGED
|
@@ -13,7 +13,6 @@ function jest({ state }) {
|
|
|
13
13
|
const packageFileDefault = packageJson();
|
|
14
14
|
const hasJest = state === 'present';
|
|
15
15
|
const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
|
|
16
|
-
const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
|
|
17
16
|
|
|
18
17
|
pkg.withPackageJson((packageFile) => {
|
|
19
18
|
if (hasJest) {
|
|
@@ -53,17 +52,13 @@ function jest({ state }) {
|
|
|
53
52
|
state: !hasJest || hasWorkspaces ? 'default' : 'present',
|
|
54
53
|
});
|
|
55
54
|
});
|
|
55
|
+
|
|
56
56
|
// Dependencies
|
|
57
57
|
npm.dependency({
|
|
58
58
|
dev: true,
|
|
59
59
|
name: ['jest', 'es-jest'],
|
|
60
60
|
state: hasJest ? 'present' : 'absent',
|
|
61
61
|
});
|
|
62
|
-
npm.dependency({
|
|
63
|
-
dev: true,
|
|
64
|
-
name: ['@types/jest'],
|
|
65
|
-
state: hasJest && hasTypescript ? 'present' : 'absent',
|
|
66
|
-
});
|
|
67
62
|
|
|
68
63
|
// vscodeSnippets({
|
|
69
64
|
// name: 'jest',
|
package/core/pkg.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
// @ts-ignore
|
|
5
5
|
const { intersect } = require('semver-intersect');
|
|
6
|
-
const { packageJson, file } = require('mrm-core');
|
|
6
|
+
const { packageJson, file, json } = require('mrm-core');
|
|
7
|
+
const glob = require('glob');
|
|
8
|
+
const path = require('path');
|
|
7
9
|
const jsonFile = require('./jsonFile');
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -21,7 +23,38 @@ function withPackageJson(block) {
|
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/**
|
|
24
|
-
* @param {import(
|
|
26
|
+
* @param {import("mrm-core").Json} packageFile
|
|
27
|
+
* @returns {string[]} - The list of workspace matchers
|
|
28
|
+
*/
|
|
29
|
+
function listWorkspaceMatchers(packageFile) {
|
|
30
|
+
return packageFile.get('workspaces.packages', packageFile.get('workspaces', []));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @param {(workspace: {
|
|
35
|
+
* projectDir: string;
|
|
36
|
+
* packageFile: import("mrm-core").Json;
|
|
37
|
+
* }) => void} fn
|
|
38
|
+
*/
|
|
39
|
+
function forEachWorkspace(fn) {
|
|
40
|
+
const packageRoot = packageJson();
|
|
41
|
+
const workspacesMatchers = listWorkspaceMatchers(packageRoot);
|
|
42
|
+
|
|
43
|
+
for (const workspaceMatcher of workspacesMatchers) {
|
|
44
|
+
const directories = glob.sync(workspaceMatcher);
|
|
45
|
+
directories.forEach((directory) => {
|
|
46
|
+
const packageFile = json(path.join(directory, 'package.json'));
|
|
47
|
+
fn({
|
|
48
|
+
projectDir: directory,
|
|
49
|
+
packageFile,
|
|
50
|
+
});
|
|
51
|
+
packageFile.save();
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* @param {import('mrm-core').Json} packageFile
|
|
25
58
|
* @param {{
|
|
26
59
|
* name: string,
|
|
27
60
|
* state: 'present'|'absent'|'default',
|
|
@@ -30,9 +63,9 @@ function withPackageJson(block) {
|
|
|
30
63
|
*/
|
|
31
64
|
function script(packageFile, { name, state, script: scriptName }) {
|
|
32
65
|
if (state === 'absent') {
|
|
33
|
-
packageFile.
|
|
34
|
-
} else if (state === 'present' || (state === 'default' && !packageFile.
|
|
35
|
-
packageFile.
|
|
66
|
+
packageFile.unset(['scripts', name]);
|
|
67
|
+
} else if (state === 'present' || (state === 'default' && !packageFile.get(['scripts', name]))) {
|
|
68
|
+
packageFile.set(['scripts', name], scriptName);
|
|
36
69
|
}
|
|
37
70
|
}
|
|
38
71
|
|
|
@@ -121,4 +154,6 @@ module.exports = {
|
|
|
121
154
|
hasDependency,
|
|
122
155
|
hasWorkspaces,
|
|
123
156
|
withPackageJson,
|
|
157
|
+
forEachWorkspace,
|
|
158
|
+
listWorkspaceMatchers,
|
|
124
159
|
};
|
package/core/project.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** @type {'docs'} */
|
|
2
|
+
const docs = 'docs';
|
|
1
3
|
/** @type {'install'} */
|
|
2
4
|
const install = 'install';
|
|
3
5
|
/** @type {'prepare'} */
|
|
@@ -24,6 +26,8 @@ const validate = 'validate';
|
|
|
24
26
|
const release = 'release';
|
|
25
27
|
/** @type {'rescue'} */
|
|
26
28
|
const rescue = 'rescue';
|
|
29
|
+
/** @type {'spellcheck'} */
|
|
30
|
+
const spellcheck = 'spellcheck';
|
|
27
31
|
|
|
28
32
|
/**
|
|
29
33
|
* @param {string} taskName
|
|
@@ -41,6 +45,7 @@ function post(taskName) {
|
|
|
41
45
|
|
|
42
46
|
module.exports = {
|
|
43
47
|
build,
|
|
48
|
+
docs,
|
|
44
49
|
prepare,
|
|
45
50
|
develop,
|
|
46
51
|
clean,
|
|
@@ -55,4 +60,5 @@ module.exports = {
|
|
|
55
60
|
rescue,
|
|
56
61
|
test,
|
|
57
62
|
validate,
|
|
63
|
+
spellcheck,
|
|
58
64
|
};
|
package/core/turbo.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const { packageJson, json } = require('mrm-core');
|
|
2
|
+
const pkg = require('./pkg');
|
|
3
|
+
const npm = require('./npm');
|
|
4
|
+
const jsonFile = require('./jsonFile');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @typedef {{
|
|
8
|
+
* $schema: string,
|
|
9
|
+
* pipeline?: Record<string, unknown>,
|
|
10
|
+
* globalDependencies?: Array<string>,
|
|
11
|
+
* }} TurboConfig
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @param {{
|
|
16
|
+
* state: 'present'|'absent',
|
|
17
|
+
* update: (config: TurboConfig) => TurboConfig
|
|
18
|
+
* }} options
|
|
19
|
+
*/
|
|
20
|
+
function turbo({ state, update }) {
|
|
21
|
+
const packageFileDefault = packageJson();
|
|
22
|
+
const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
|
|
23
|
+
const hasTurbo = state === 'present' && hasWorkspaces;
|
|
24
|
+
|
|
25
|
+
const turboFile = json('turbo.json');
|
|
26
|
+
|
|
27
|
+
if (hasTurbo) {
|
|
28
|
+
jsonFile.value(turboFile, {
|
|
29
|
+
path: undefined,
|
|
30
|
+
state,
|
|
31
|
+
update,
|
|
32
|
+
/** @type {TurboConfig} */
|
|
33
|
+
default: {
|
|
34
|
+
$schema: 'https://turborepo.org/schema.json',
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Otherwise save the file with content
|
|
40
|
+
*/
|
|
41
|
+
turboFile.save();
|
|
42
|
+
} else {
|
|
43
|
+
turboFile.delete();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Dependencies
|
|
47
|
+
npm.dependency({
|
|
48
|
+
dev: true,
|
|
49
|
+
name: ['turbo'],
|
|
50
|
+
state: hasTurbo ? 'present' : 'absent',
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = {
|
|
55
|
+
turbo,
|
|
56
|
+
};
|
package/cspell/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
const { cspell } = require('../core/cspell');
|
|
2
|
+
const project = require('../core/project');
|
|
3
|
+
const pkg = require('../core/pkg');
|
|
2
4
|
|
|
3
5
|
function task() {
|
|
4
6
|
cspell({
|
|
@@ -20,6 +22,25 @@ function task() {
|
|
|
20
22
|
),
|
|
21
23
|
}),
|
|
22
24
|
});
|
|
25
|
+
|
|
26
|
+
pkg.withPackageJson((packageFile) => {
|
|
27
|
+
const hasWorkspaces = pkg.hasWorkspaces(packageFile);
|
|
28
|
+
const workspaceMatchers = pkg.listWorkspaceMatchers(packageFile);
|
|
29
|
+
pkg.script(packageFile, {
|
|
30
|
+
name: project.spellcheck,
|
|
31
|
+
script: `cspell --no-progress '**' ${
|
|
32
|
+
hasWorkspaces ? `${workspaceMatchers.map((_) => `--exclude='${_}/**'`).join(' ')} && turbo run spellcheck` : ''
|
|
33
|
+
}`,
|
|
34
|
+
state: 'present',
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
pkg.forEachWorkspace(({ packageFile }) => {
|
|
38
|
+
pkg.script(packageFile, {
|
|
39
|
+
name: project.spellcheck,
|
|
40
|
+
script: `cspell --no-progress '**'`,
|
|
41
|
+
state: 'present',
|
|
42
|
+
});
|
|
43
|
+
});
|
|
23
44
|
}
|
|
24
45
|
|
|
25
46
|
task.description = 'Adds CSpell support';
|
package/eslint/index.js
CHANGED
|
@@ -16,6 +16,7 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
|
|
|
16
16
|
*/
|
|
17
17
|
function task({ eslintPreset, eslintRules }) {
|
|
18
18
|
const packageFileDefault = packageJson();
|
|
19
|
+
const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
|
|
19
20
|
const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
|
|
20
21
|
const hasJSX = true;
|
|
21
22
|
const hasJSON = true;
|
|
@@ -63,6 +64,8 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
|
|
|
63
64
|
|
|
64
65
|
/** @type {Record<string, boolean>} */
|
|
65
66
|
const extsMap = {
|
|
67
|
+
mjs: true,
|
|
68
|
+
cjs: true,
|
|
66
69
|
js: true,
|
|
67
70
|
jsx: hasJSX,
|
|
68
71
|
ts: hasTypescript,
|
|
@@ -73,15 +76,54 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
|
|
|
73
76
|
const extOption = ` --ext=${extList.join(',')}`;
|
|
74
77
|
|
|
75
78
|
pkg.withPackageJson((packageFile) => {
|
|
79
|
+
const ignorePatterns = pkg
|
|
80
|
+
.listWorkspaceMatchers(packageFile)
|
|
81
|
+
.map((_) => ` --ignore-pattern='${_}/**'`)
|
|
82
|
+
.join('');
|
|
83
|
+
|
|
84
|
+
// workspaces
|
|
85
|
+
pkg.script(packageFile, {
|
|
86
|
+
name: `${project.lint}:root`,
|
|
87
|
+
script: `eslint .${extOption}${ignorePatterns}`,
|
|
88
|
+
state: hasWorkspaces ? 'present' : 'absent',
|
|
89
|
+
});
|
|
90
|
+
pkg.script(packageFile, {
|
|
91
|
+
name: `${project.format}:root`,
|
|
92
|
+
script: `eslint .${extOption}${ignorePatterns} --fix`,
|
|
93
|
+
state: hasWorkspaces ? 'present' : 'absent',
|
|
94
|
+
});
|
|
95
|
+
pkg.script(packageFile, {
|
|
96
|
+
name: `${project.lint}:packages`,
|
|
97
|
+
script: `turbo run ${project.lint}`,
|
|
98
|
+
state: hasWorkspaces ? 'present' : 'absent',
|
|
99
|
+
});
|
|
100
|
+
pkg.script(packageFile, {
|
|
101
|
+
name: `${project.format}:packages`,
|
|
102
|
+
script: `turbo run ${project.format}`,
|
|
103
|
+
state: hasWorkspaces ? 'present' : 'absent',
|
|
104
|
+
});
|
|
105
|
+
// regular package
|
|
106
|
+
pkg.script(packageFile, {
|
|
107
|
+
name: `${project.lint}:src`,
|
|
108
|
+
script: `eslint .${extOption}`,
|
|
109
|
+
state: !hasWorkspaces ? 'present' : 'absent',
|
|
110
|
+
});
|
|
111
|
+
pkg.script(packageFile, {
|
|
112
|
+
name: `${project.format}:src`,
|
|
113
|
+
script: `eslint . --quiet --fix${extOption}`,
|
|
114
|
+
state: !hasWorkspaces ? 'present' : 'absent',
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
pkg.forEachWorkspace(({ packageFile }) => {
|
|
76
118
|
pkg.script(packageFile, {
|
|
77
119
|
name: project.lint,
|
|
78
|
-
script: `eslint
|
|
79
|
-
state: '
|
|
120
|
+
script: `eslint .${extOption}`,
|
|
121
|
+
state: 'default',
|
|
80
122
|
});
|
|
81
123
|
pkg.script(packageFile, {
|
|
82
124
|
name: project.format,
|
|
83
|
-
script: `eslint . --quiet --
|
|
84
|
-
state: '
|
|
125
|
+
script: `eslint . --quiet --fix${extOption}`,
|
|
126
|
+
state: 'default',
|
|
85
127
|
});
|
|
86
128
|
});
|
|
87
129
|
|
|
@@ -93,14 +135,20 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
|
|
|
93
135
|
'editor.codeActionsOnSave': settings['editor.codeActionsOnSave'] || {
|
|
94
136
|
'source.fixAll': true,
|
|
95
137
|
},
|
|
96
|
-
'eslint.validate':
|
|
97
|
-
(
|
|
98
|
-
(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
138
|
+
'eslint.validate': Array.from(
|
|
139
|
+
new Set(
|
|
140
|
+
extList.map(
|
|
141
|
+
(ext) =>
|
|
142
|
+
({
|
|
143
|
+
cjs: 'javascript',
|
|
144
|
+
mjs: 'javascript',
|
|
145
|
+
jsx: 'javascriptreact',
|
|
146
|
+
js: 'javascript',
|
|
147
|
+
tsx: 'typescriptreact',
|
|
148
|
+
ts: 'typescript',
|
|
149
|
+
}[ext] || ext)
|
|
150
|
+
)
|
|
151
|
+
)
|
|
104
152
|
),
|
|
105
153
|
}),
|
|
106
154
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/mrm-preset",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.13",
|
|
4
4
|
"description": "Mrm configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mrm",
|
|
@@ -24,15 +24,17 @@
|
|
|
24
24
|
"build:empty": ":",
|
|
25
25
|
"build:tsc": "tsc --noEmit --skipLibCheck",
|
|
26
26
|
"docs": "md-magic --path '**/*.md' --ignore='node_modules'",
|
|
27
|
-
"format": "eslint . --fix",
|
|
28
|
-
"lint": "eslint .",
|
|
27
|
+
"format": "eslint . --quiet --fix --ext=mjs,cjs,js,jsx,ts,tsx,json",
|
|
28
|
+
"lint": "eslint . --ext=mjs,cjs,js,jsx,ts,tsx,json",
|
|
29
|
+
"spellcheck": "cspell --no-progress '**'",
|
|
29
30
|
"test": "mkdir _tester; cd _tester; mrm bootstrap --dir ..; mrm configure --dir .."
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
33
|
"debug": "^4.3.3",
|
|
34
|
+
"glob": "^8.0.3",
|
|
33
35
|
"mrm-core": "^7.0.0",
|
|
34
36
|
"semver-intersect": "^1.4.0",
|
|
35
|
-
"sync-directory": "^
|
|
37
|
+
"sync-directory": "^5.0.0"
|
|
36
38
|
},
|
|
37
39
|
"devDependencies": {
|
|
38
40
|
"@types/debug": "^4.1.7",
|
|
@@ -45,5 +47,5 @@
|
|
|
45
47
|
"publishConfig": {
|
|
46
48
|
"access": "public"
|
|
47
49
|
},
|
|
48
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "b05bfbed614927b6b50c0709d95e7e45c842b165"
|
|
49
51
|
}
|
package/project/index.js
CHANGED
|
@@ -5,6 +5,7 @@ const npm = require('../core/npm');
|
|
|
5
5
|
const { vscodeTask } = require('../core/vscode');
|
|
6
6
|
const project = require('../core/project');
|
|
7
7
|
const mrmPackageJson = require('../package.json');
|
|
8
|
+
const { turbo } = require('../core/turbo');
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
*
|
|
@@ -62,7 +63,7 @@ function task() {
|
|
|
62
63
|
pkg.script(packageFile, {
|
|
63
64
|
name: `${project.build}:empty`,
|
|
64
65
|
script: pkg.emptyScript,
|
|
65
|
-
state: 'present',
|
|
66
|
+
state: !useWorkspace ? 'present' : 'absent',
|
|
66
67
|
});
|
|
67
68
|
pkg.script(packageFile, {
|
|
68
69
|
name: `${project.build}:packages`,
|
|
@@ -85,13 +86,23 @@ function task() {
|
|
|
85
86
|
// lint
|
|
86
87
|
pkg.script(packageFile, {
|
|
87
88
|
name: project.lint,
|
|
89
|
+
script: npmRunAll(project.lint),
|
|
90
|
+
state: 'present',
|
|
91
|
+
});
|
|
92
|
+
pkg.script(packageFile, {
|
|
93
|
+
name: `${project.lint}:empty`,
|
|
88
94
|
script: pkg.emptyScript,
|
|
89
|
-
state: '
|
|
95
|
+
state: !useWorkspace ? 'present' : 'absent',
|
|
90
96
|
});
|
|
91
97
|
pkg.script(packageFile, {
|
|
92
98
|
name: project.format,
|
|
99
|
+
script: npmRunAll(project.format),
|
|
100
|
+
state: 'present',
|
|
101
|
+
});
|
|
102
|
+
pkg.script(packageFile, {
|
|
103
|
+
name: `${project.format}:empty`,
|
|
93
104
|
script: pkg.emptyScript,
|
|
94
|
-
state: '
|
|
105
|
+
state: !useWorkspace ? 'present' : 'absent',
|
|
95
106
|
});
|
|
96
107
|
|
|
97
108
|
// test
|
|
@@ -105,16 +116,6 @@ function task() {
|
|
|
105
116
|
script: npmRunAll(project.test),
|
|
106
117
|
state: 'present',
|
|
107
118
|
});
|
|
108
|
-
pkg.script(packageFile, {
|
|
109
|
-
name: `${project.prepare}:empty`,
|
|
110
|
-
script: pkg.emptyScript,
|
|
111
|
-
state: 'default',
|
|
112
|
-
});
|
|
113
|
-
pkg.script(packageFile, {
|
|
114
|
-
name: `${project.prepare}:packages`,
|
|
115
|
-
script: turboRun(project.test),
|
|
116
|
-
state: useWorkspace ? 'present' : 'absent',
|
|
117
|
-
});
|
|
118
119
|
pkg.script(packageFile, {
|
|
119
120
|
name: project.validate,
|
|
120
121
|
script: `${npmRun(project.build)} && ${npmRun(project.lint)} && ${npmRun(project.test)}`,
|
|
@@ -136,12 +137,12 @@ function task() {
|
|
|
136
137
|
});
|
|
137
138
|
pkg.script(packageFile, {
|
|
138
139
|
name: `${project.prepare}:empty`,
|
|
139
|
-
script:
|
|
140
|
+
script: !useWorkspace ? 'present' : 'absent',
|
|
140
141
|
state: 'default',
|
|
141
142
|
});
|
|
142
143
|
pkg.script(packageFile, {
|
|
143
144
|
name: `${project.prepare}:packages`,
|
|
144
|
-
script:
|
|
145
|
+
script: turboRun(project.prepare),
|
|
145
146
|
state: useWorkspace ? 'present' : 'absent',
|
|
146
147
|
});
|
|
147
148
|
|
|
@@ -160,25 +161,7 @@ function task() {
|
|
|
160
161
|
});
|
|
161
162
|
|
|
162
163
|
// workspace
|
|
163
|
-
|
|
164
|
-
$schema: 'https://turborepo.org/schema.json',
|
|
165
|
-
pipeline: {
|
|
166
|
-
[project.build]: {
|
|
167
|
-
dependsOn: ['^build'],
|
|
168
|
-
outputs: ['lib/**', 'dist/**', '.next/**'],
|
|
169
|
-
},
|
|
170
|
-
[project.test]: {},
|
|
171
|
-
[project.lint]: {},
|
|
172
|
-
[project.format]: {},
|
|
173
|
-
[project.clean]: {
|
|
174
|
-
cache: false,
|
|
175
|
-
},
|
|
176
|
-
[project.develop]: {
|
|
177
|
-
cache: false,
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
globalDependencies: ['tsconfig.settings.json'],
|
|
181
|
-
});
|
|
164
|
+
|
|
182
165
|
const lernaConfig = json('lerna.json', {
|
|
183
166
|
version: packageFile.get('version'),
|
|
184
167
|
});
|
|
@@ -200,12 +183,10 @@ function task() {
|
|
|
200
183
|
useWorkspaces: useWorkspace,
|
|
201
184
|
});
|
|
202
185
|
lernaConfig.save();
|
|
203
|
-
turboConfig.save();
|
|
204
186
|
makeDirs('packages');
|
|
205
187
|
} else {
|
|
206
188
|
packageFile.unset('workspaces');
|
|
207
189
|
lernaConfig.delete();
|
|
208
|
-
turboConfig.delete();
|
|
209
190
|
}
|
|
210
191
|
|
|
211
192
|
// Engine
|
|
@@ -222,6 +203,32 @@ function task() {
|
|
|
222
203
|
);
|
|
223
204
|
packageFile.save();
|
|
224
205
|
|
|
206
|
+
// Turbo config
|
|
207
|
+
turbo({
|
|
208
|
+
state: useWorkspace ? 'present' : 'absent',
|
|
209
|
+
update: (_) => ({
|
|
210
|
+
..._,
|
|
211
|
+
pipeline: {
|
|
212
|
+
[project.build]: {
|
|
213
|
+
dependsOn: ['^build'],
|
|
214
|
+
outputs: ['lib/**', 'dist/**', '.next/**'],
|
|
215
|
+
},
|
|
216
|
+
[project.test]: {},
|
|
217
|
+
[project.lint]: {},
|
|
218
|
+
[project.format]: {},
|
|
219
|
+
[project.docs]: {},
|
|
220
|
+
[project.spellcheck]: {},
|
|
221
|
+
[project.clean]: {
|
|
222
|
+
cache: false,
|
|
223
|
+
},
|
|
224
|
+
[project.develop]: {
|
|
225
|
+
cache: false,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
globalDependencies: ['tsconfig.settings.json'],
|
|
229
|
+
}),
|
|
230
|
+
});
|
|
231
|
+
|
|
225
232
|
// Dependencies
|
|
226
233
|
npm.dependency({
|
|
227
234
|
dev: true,
|
|
@@ -230,7 +237,7 @@ function task() {
|
|
|
230
237
|
});
|
|
231
238
|
npm.dependency({
|
|
232
239
|
dev: true,
|
|
233
|
-
name: ['lerna'
|
|
240
|
+
name: ['lerna'],
|
|
234
241
|
state: useWorkspace ? 'present' : 'absent',
|
|
235
242
|
});
|
|
236
243
|
|