@w5s/mrm-preset 1.0.0-alpha.11 → 1.0.0-alpha.12

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.
@@ -1 +1 @@
1
- @w5s/mrm-preset:build: cache hit, replaying output 3c115708988953a1
1
+ @w5s/mrm-preset:build: cache hit, replaying output 994c85676b160cb0
@@ -1,43 +1,43 @@
1
- @w5s/mrm-preset:docs: cache hit, replaying output 95ec4e4c5dc4e562
2
- @w5s/mrm-preset:docs: Starting markdown-magic [ '**/*.md', '!node_modules/**' ]
3
- @w5s/mrm-preset:docs: ℹ Notice:
4
- @w5s/mrm-preset:docs: Missing transforms "BASIC_RULES","JSX_RULES" in _tester/node_modules/eslint-plugin-react/README.md
5
- @w5s/mrm-preset:docs:
6
- @w5s/mrm-preset:docs: ✔ README.md Updated
7
- @w5s/mrm-preset:docs: Transforms run
8
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=# W5s Mrm Preset _(${name})_
9
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=> ${description}&unknownTxt=
10
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[${license}][license-url] © ${author}
11
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
12
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
13
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
14
- @w5s/mrm-preset:docs:
15
- @w5s/mrm-preset:docs: ✔ _tester/node_modules/@w5s/mrm-preset/README.md Updated
16
- @w5s/mrm-preset:docs: Transforms run
17
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=# W5s Mrm Preset _(${name})_
18
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=> ${description}&unknownTxt=
19
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[${license}][license-url] © ${author}
20
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
21
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
22
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
23
- @w5s/mrm-preset:docs:
24
- @w5s/mrm-preset:docs: ✔ _tester/node_modules/@w5s/eslint-config/README.md Updated
25
- @w5s/mrm-preset:docs: Transforms run
26
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=# W5s ESLint configuration _(${name})_
27
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=> ${description}&unknownTxt=
28
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=```console\nnpm install --save-dev ${name}\n```
29
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[${license}][license-url] © ${author}
30
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
31
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
32
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
33
- @w5s/mrm-preset:docs:
34
- @w5s/mrm-preset:docs: ✔ _tester/node_modules/@w5s/ts-config/README.md Updated
35
- @w5s/mrm-preset:docs: Transforms run
36
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=# W5s Typescript configuration _(${name})_
37
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=> ${description}&unknownTxt=
38
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=```console\nnpm install --save-dev ${name}\n```
39
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[${license}][license-url] © ${author}
40
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
41
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
42
- @w5s/mrm-preset:docs: ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
43
- @w5s/mrm-preset:docs:
1
+ @w5s/mrm-preset:docs: cache hit, replaying output 131c211b32191d83
2
+ @w5s/mrm-preset:docs: Starting markdown-magic [ '**/*.md', '!node_modules/**' ]
3
+ @w5s/mrm-preset:docs: ℹ Notice:
4
+ @w5s/mrm-preset:docs:  Missing transforms "BASIC_RULES","JSX_RULES" in _tester/node_modules/eslint-plugin-react/README.md
5
+ @w5s/mrm-preset:docs: 
6
+ @w5s/mrm-preset:docs: ✔ README.md Updated
7
+ @w5s/mrm-preset:docs:  Transforms run
8
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=# W5s Mrm Preset _(${name})_
9
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=> ${description}&unknownTxt=
10
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[${license}][license-url] © ${author}
11
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
12
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
13
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
14
+ @w5s/mrm-preset:docs: 
15
+ @w5s/mrm-preset:docs: ✔ _tester/node_modules/@w5s/mrm-preset/README.md Updated
16
+ @w5s/mrm-preset:docs:  Transforms run
17
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=# W5s Mrm Preset _(${name})_
18
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=> ${description}&unknownTxt=
19
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[${license}][license-url] © ${author}
20
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
21
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
22
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
23
+ @w5s/mrm-preset:docs: 
24
+ @w5s/mrm-preset:docs: ✔ _tester/node_modules/@w5s/eslint-config/README.md Updated
25
+ @w5s/mrm-preset:docs:  Transforms run
26
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=# W5s ESLint configuration _(${name})_
27
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=> ${description}&unknownTxt=
28
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=```console\nnpm install --save-dev ${name}\n```
29
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[${license}][license-url] © ${author}
30
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
31
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
32
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
33
+ @w5s/mrm-preset:docs: 
34
+ @w5s/mrm-preset:docs: ✔ _tester/node_modules/@w5s/ts-config/README.md Updated
35
+ @w5s/mrm-preset:docs:  Transforms run
36
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=# W5s Typescript configuration _(${name})_
37
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=> ${description}&unknownTxt=
38
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=```console\nnpm install --save-dev ${name}\n```
39
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[${license}][license-url] © ${author}
40
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-version-svg]: https://img.shields.io/npm/v/${name}.svg?style=flat-square
41
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[package-url]: https://www.npmjs.com/package/${name}
42
+ @w5s/mrm-preset:docs:  ⁕ PKGJSON:template=[license-image]: https://img.shields.io/badge/license-${license}-green.svg?style=flat-square
43
+ @w5s/mrm-preset:docs: 
@@ -0,0 +1 @@
1
+ @w5s/mrm-preset:format: cache hit, replaying output d9ab8a49347bb8ce
@@ -1 +1 @@
1
- @w5s/mrm-preset:lint: cache hit, replaying output 7e471593505748d5
1
+ @w5s/mrm-preset:lint: cache hit, replaying output c6d20a5c67e4158c
@@ -0,0 +1 @@
1
+ @w5s/mrm-preset:spellcheck: cache hit, replaying output 5cc5aa314340b1a0
@@ -1,20 +1,21 @@
1
- @w5s/mrm-preset:test: cache hit, replaying output 3972076d5900fa18
2
- @w5s/mrm-preset:test: mkdir: _tester: File exists
3
- @w5s/mrm-preset:test: Running bootstrap...
4
- @w5s/mrm-preset:test: Running alias configure...
5
- @w5s/mrm-preset:test: Running gitignore...
6
- @w5s/mrm-preset:test: Running project...
7
- @w5s/mrm-preset:test: Update package.json
8
- @w5s/mrm-preset:test: Running contributing...
9
- @w5s/mrm-preset:test: Running release...
10
- @w5s/mrm-preset:test: Running ci...
11
- @w5s/mrm-preset:test: Running lang...
12
- @w5s/mrm-preset:test: Running commitlint...
13
- @w5s/mrm-preset:test: Running editorconfig...
14
- @w5s/mrm-preset:test: Running eslint...
15
- @w5s/mrm-preset:test: Running cspell...
16
- @w5s/mrm-preset:test: Running jest...
17
- @w5s/mrm-preset:test: Update package.json
18
- @w5s/mrm-preset:test: Running renovate...
19
- @w5s/mrm-preset:test: Running githooks...
20
- @w5s/mrm-preset:test: Running postconfigure...
1
+ @w5s/mrm-preset:test: cache hit, replaying output c894bb585090cefd
2
+ @w5s/mrm-preset:test: mkdir: _tester: File exists
3
+ @w5s/mrm-preset:test: Running bootstrap...
4
+ @w5s/mrm-preset:test: Running alias configure...
5
+ @w5s/mrm-preset:test: Running gitignore...
6
+ @w5s/mrm-preset:test: Running project...
7
+ @w5s/mrm-preset:test: Update package.json
8
+ @w5s/mrm-preset:test: Running contributing...
9
+ @w5s/mrm-preset:test: Running release...
10
+ @w5s/mrm-preset:test: Running ci...
11
+ @w5s/mrm-preset:test: Running lang...
12
+ @w5s/mrm-preset:test: Running commitlint...
13
+ @w5s/mrm-preset:test: Running editorconfig...
14
+ @w5s/mrm-preset:test: Running eslint...
15
+ @w5s/mrm-preset:test: Update package.json
16
+ @w5s/mrm-preset:test: Running cspell...
17
+ @w5s/mrm-preset:test: Running jest...
18
+ @w5s/mrm-preset:test: Update package.json
19
+ @w5s/mrm-preset:test: Running renovate...
20
+ @w5s/mrm-preset:test: Running githooks...
21
+ @w5s/mrm-preset:test: Running postconfigure...
package/CHANGELOG.md CHANGED
@@ -3,6 +3,28 @@
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.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)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add spellcheck task to turbo config ([1029c2b](https://github.com/w5s/project-config/commit/1029c2b97b12b44618ce741d045b02712f0ebf18))
12
+ * clean non useful empty script when possible ([2e7e60a](https://github.com/w5s/project-config/commit/2e7e60a400506bbca00db653813668fa47f8f065))
13
+ * correct docs task in turbo ([0fca8c9](https://github.com/w5s/project-config/commit/0fca8c9ca0389b090e6aa2a66d47ab63b1cb138e))
14
+ * remove uneeded @types/jest typing ([475f6bb](https://github.com/w5s/project-config/commit/475f6bbdc101d31460cd8ffb7f5deb3b97176d5c))
15
+ * remove uneeded cspell script ([ba8d38b](https://github.com/w5s/project-config/commit/ba8d38b8053a24a7937c24c270f5d61d3dad71c7))
16
+
17
+
18
+ ### Features
19
+
20
+ * configure spellcheck ([4be6a96](https://github.com/w5s/project-config/commit/4be6a96d6d30e1085b73c0befcab1d3fa30475ab))
21
+ * improve eslint mrm support for workspaces ([2dacc2e](https://github.com/w5s/project-config/commit/2dacc2e867ebb74c8de777af2ce9f173426ebc33))
22
+ * improve turbo support for lint and format ([76e19e0](https://github.com/w5s/project-config/commit/76e19e02918aba66a2e6e9c06a7d0bed99500ecc))
23
+
24
+
25
+
26
+
27
+
6
28
  # [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)
7
29
 
8
30
 
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/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('mrm-core').PackageJson} packageFile
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.removeScript(name);
34
- } else if (state === 'present' || (state === 'default' && !packageFile.getScript(name))) {
35
- packageFile.setScript(name, scriptName);
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,22 @@ function task() {
20
22
  ),
21
23
  }),
22
24
  });
25
+
26
+ pkg.withPackageJson((packageFile) => {
27
+ const hasWorkspaces = pkg.hasWorkspaces(packageFile);
28
+ pkg.script(packageFile, {
29
+ name: project.spellcheck,
30
+ script: `cspell ${hasWorkspaces ? `'*' --silent && turbo run spellcheck` : '**'}`,
31
+ state: 'present',
32
+ });
33
+ });
34
+ pkg.forEachWorkspace(({ packageFile }) => {
35
+ pkg.script(packageFile, {
36
+ name: project.spellcheck,
37
+ script: `cspell '**' --silent`,
38
+ state: 'present',
39
+ });
40
+ });
23
41
  }
24
42
 
25
43
  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 . --cache${extOption}`,
79
- state: 'present',
120
+ script: `eslint .${extOption}`,
121
+ state: 'default',
80
122
  });
81
123
  pkg.script(packageFile, {
82
124
  name: project.format,
83
- script: `eslint . --quiet --cache --fix${extOption}`,
84
- state: 'present',
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': extList.map(
97
- (ext) =>
98
- ({
99
- jsx: 'javascriptreact',
100
- js: 'javascript',
101
- tsx: 'typescriptreact',
102
- ts: 'typescript',
103
- }[ext] || ext)
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.11",
3
+ "version": "1.0.0-alpha.12",
4
4
  "description": "Mrm configuration presets",
5
5
  "keywords": [
6
6
  "mrm",
@@ -24,12 +24,14 @@
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 '**' --silent",
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
37
  "sync-directory": "^5.0.0"
@@ -45,5 +47,5 @@
45
47
  "publishConfig": {
46
48
  "access": "public"
47
49
  },
48
- "gitHead": "123632828a2c65c3ca28b515666582b689fb9dea"
50
+ "gitHead": "061ae0ed0c8a92c5e35939374a633a06b0b8e6ba"
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: 'default',
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: 'default',
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.prepare),
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,9 +137,14 @@ function task() {
136
137
  });
137
138
  pkg.script(packageFile, {
138
139
  name: `${project.prepare}:empty`,
139
- script: pkg.emptyScript,
140
+ script: !useWorkspace ? 'present' : 'absent',
140
141
  state: 'default',
141
142
  });
143
+ pkg.script(packageFile, {
144
+ name: `${project.prepare}:packages`,
145
+ script: turboRun(project.prepare),
146
+ state: useWorkspace ? 'present' : 'absent',
147
+ });
142
148
 
143
149
  // rescue
144
150
  pkg.script(packageFile, {
@@ -155,25 +161,7 @@ function task() {
155
161
  });
156
162
 
157
163
  // workspace
158
- const turboConfig = json('turbo.json', {
159
- $schema: 'https://turborepo.org/schema.json',
160
- pipeline: {
161
- [project.build]: {
162
- dependsOn: ['^build'],
163
- outputs: ['lib/**', 'dist/**', '.next/**'],
164
- },
165
- [project.test]: {},
166
- [project.lint]: {},
167
- [project.format]: {},
168
- [project.clean]: {
169
- cache: false,
170
- },
171
- [project.develop]: {
172
- cache: false,
173
- },
174
- },
175
- globalDependencies: ['tsconfig.settings.json'],
176
- });
164
+
177
165
  const lernaConfig = json('lerna.json', {
178
166
  version: packageFile.get('version'),
179
167
  });
@@ -195,12 +183,10 @@ function task() {
195
183
  useWorkspaces: useWorkspace,
196
184
  });
197
185
  lernaConfig.save();
198
- turboConfig.save();
199
186
  makeDirs('packages');
200
187
  } else {
201
188
  packageFile.unset('workspaces');
202
189
  lernaConfig.delete();
203
- turboConfig.delete();
204
190
  }
205
191
 
206
192
  // Engine
@@ -217,6 +203,32 @@ function task() {
217
203
  );
218
204
  packageFile.save();
219
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
+
220
232
  // Dependencies
221
233
  npm.dependency({
222
234
  dev: true,
@@ -225,7 +237,7 @@ function task() {
225
237
  });
226
238
  npm.dependency({
227
239
  dev: true,
228
- name: ['lerna', 'turbo'],
240
+ name: ['lerna'],
229
241
  state: useWorkspace ? 'present' : 'absent',
230
242
  });
231
243