@w5s/mrm-preset 1.0.0-alpha.5 → 1.0.0-alpha.8

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.
@@ -0,0 +1 @@
1
+ @w5s/mrm-preset:build: cache hit, replaying output 5afc39bc33a830a1
@@ -0,0 +1,43 @@
1
+ @w5s/mrm-preset:docs: cache hit, replaying output 739feda9201bbfc3
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,52 @@
1
+ @w5s/mrm-preset:lint: cache hit, replaying output dd62d06a650bdfa1
2
+ @w5s/mrm-preset:lint: 
3
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/ci/gitlab.js
4
+ @w5s/mrm-preset:lint:  5:0 warning Syntax error in type: typeof import('sync-directory')['default'] jsdoc/valid-types
5
+ @w5s/mrm-preset:lint: 
6
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/commitlint.js
7
+ @w5s/mrm-preset:lint:  6:0 warning Syntax error in type: {state: 'present'|'absent',preset: string,} jsdoc/valid-types
8
+ @w5s/mrm-preset:lint: 
9
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/cspell.js
10
+ @w5s/mrm-preset:lint:  5:0 warning Syntax error in type: {version: '0.2',language: string,words?: string[],flagWords?: string[],ignorePaths?: string[],ignoreWords?: string[],ignoreRegExpList?: string[],import?: string[]} jsdoc/valid-types
11
+ @w5s/mrm-preset:lint:  17:0 warning Syntax error in type: {state: 'present'|'absent'update?: (config: CSpellConfig) => CSpellConfig} jsdoc/valid-types
12
+ @w5s/mrm-preset:lint: 
13
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/file.js
14
+ @w5s/mrm-preset:lint:  5:0 warning Syntax error in type: {path: string,state: 'file'|'absent',update?: (content: string) => string | undefined,} jsdoc/valid-types
15
+ @w5s/mrm-preset:lint: 
16
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/githooks.js
17
+ @w5s/mrm-preset:lint:  10:0 warning Syntax error in type: {state: 'present'|'absent',} jsdoc/valid-types
18
+ @w5s/mrm-preset:lint: 
19
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/jsonFile.js
20
+ @w5s/mrm-preset:lint:  35:0 warning Syntax error in type: {path: undefined | string | string[],state: 'present'|'absent',update?: T | ((previousValue: T) => T)default?: T | (() => T)} jsdoc/valid-types
21
+ @w5s/mrm-preset:lint: 
22
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/npm.js
23
+ @w5s/mrm-preset:lint:  28:0 warning Missing JSDoc @property "dev" description jsdoc/require-property-description
24
+ @w5s/mrm-preset:lint:  29:0 warning Missing JSDoc @property "yarn" description jsdoc/require-property-description
25
+ @w5s/mrm-preset:lint:  30:0 warning Missing JSDoc @property "versions" description jsdoc/require-property-description
26
+ @w5s/mrm-preset:lint:  35:0 warning Missing JSDoc @property "dev" description jsdoc/require-property-description
27
+ @w5s/mrm-preset:lint:  36:0 warning Missing JSDoc @property "remove" description jsdoc/require-property-description
28
+ @w5s/mrm-preset:lint:  37:0 warning Missing JSDoc @property "stdio" description jsdoc/require-property-description
29
+ @w5s/mrm-preset:lint:  38:0 warning Missing JSDoc @property "cwd" description jsdoc/require-property-description
30
+ @w5s/mrm-preset:lint:  56:0 warning Tag @type must have a type jsdoc/valid-types
31
+ @w5s/mrm-preset:lint:  169:0 warning Missing JSDoc @returns description jsdoc/require-returns-description
32
+ @w5s/mrm-preset:lint:  184:0 warning Missing JSDoc @returns description jsdoc/require-returns-description
33
+ @w5s/mrm-preset:lint:  197:0 warning Missing JSDoc @returns description jsdoc/require-returns-description
34
+ @w5s/mrm-preset:lint:  256:0 warning Syntax error in type: 'npm'|`yarn@${'classic'|'berry'}` jsdoc/valid-types
35
+ @w5s/mrm-preset:lint:  284:0 warning Syntax error in type: {name: string|string[]|Record<string, string>,state: 'present'|'absent',dev?: boolean,yarn?: boolean,} jsdoc/valid-types
36
+ @w5s/mrm-preset:lint: 
37
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/pkg.js
38
+ @w5s/mrm-preset:lint:  25:0 warning Syntax error in type: {name: string,state: 'present'|'absent'|'default',script: string,} jsdoc/valid-types
39
+ @w5s/mrm-preset:lint:  43:0 warning Missing JSDoc @returns description jsdoc/require-returns-description
40
+ @w5s/mrm-preset:lint: 
41
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/typedoc.js
42
+ @w5s/mrm-preset:lint:  7:0 warning Syntax error in type: {out?: string,tsconfig?: string,exclude?: Array<string>,excludePrivate?: boolean,excludeExternals?: boolean,readme?: string,theme?: string,} jsdoc/valid-types
43
+ @w5s/mrm-preset:lint: 
44
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/core/vscode.js
45
+ @w5s/mrm-preset:lint:  47:0 warning Syntax error in type: {name: string,state: 'present'|'absent',snippets: {[key: string]: {scope: string,prefix: string,body: string|string[],description?: string,}}} jsdoc/valid-types
46
+ @w5s/mrm-preset:lint: 
47
+ @w5s/mrm-preset:lint: /Users/jpolo/Workspace/w5s/project-config/packages/mrm-preset/editorconfig/index.js
48
+ @w5s/mrm-preset:lint:  7:0 warning Syntax error in type: Record<string, Partial<{charset: string,continuation_indent_size: number,curly_bracket_next_line: boolean,end_of_line: 'lf'|'crlf',indent_brace_style: 'Stroustrup',indent_size: number,indent_style: 'tab'|'space',insert_final_newline: boolean|'ignore',max_line_length: number,quote_type: 'single'|'double',root: boolean,spaces_around_brackets: 'outside',spaces_around_operators: boolean,trim_trailing_whitespace: boolean,}>> jsdoc/valid-types
49
+ @w5s/mrm-preset:lint:  29:0 warning Missing JSDoc @param "existing" type jsdoc/require-param-type
50
+ @w5s/mrm-preset:lint: 
51
+ @w5s/mrm-preset:lint: ✖ 26 problems (0 errors, 26 warnings)
52
+ @w5s/mrm-preset:lint: 
@@ -0,0 +1,21 @@
1
+ @w5s/mrm-preset:test: cache hit, replaying output b355f87af4d1ba14
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: Update tsconfig.settings.json
13
+ @w5s/mrm-preset:test: Running commitlint...
14
+ @w5s/mrm-preset:test: Running editorconfig...
15
+ @w5s/mrm-preset:test: Running eslint...
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,49 @@
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.8](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.7...@w5s/mrm-preset@1.0.0-alpha.8) (2022-03-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * add missing $schema for tsconfig ([c33c7ae](https://github.com/w5s/project-config/commit/c33c7aeba405d651eba19187436724780dd90aff))
12
+ * remove unused typedoc script ([51238f0](https://github.com/w5s/project-config/commit/51238f04b8f3d95baac7f0a367ba1c07061d2ce4))
13
+
14
+
15
+
16
+
17
+
18
+ # [1.0.0-alpha.7](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.6...@w5s/mrm-preset@1.0.0-alpha.7) (2022-03-01)
19
+
20
+
21
+ ### Bug Fixes
22
+
23
+ * correct bootstrap step ([da7f539](https://github.com/w5s/project-config/commit/da7f539560ba143f830c9ea824b0d79c6a50522c))
24
+ * correct is-ci script that fails in some yarn berry ([4e4707d](https://github.com/w5s/project-config/commit/4e4707d7e8c0cd2c88e1dc6bc94705317dcf9e98))
25
+ * improve yarn check ([3af241a](https://github.com/w5s/project-config/commit/3af241af004d747518733983260eb295aa75e5cb))
26
+
27
+
28
+
29
+
30
+
31
+ # [1.0.0-alpha.6](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.5...@w5s/mrm-preset@1.0.0-alpha.6) (2022-02-23)
32
+
33
+
34
+ ### Bug Fixes
35
+
36
+ * correct gitignore task ([b4f0903](https://github.com/w5s/project-config/commit/b4f0903561c97500aef65488ef06ccd7eae0db80))
37
+ * remove jest on lint-staged ([2fbc851](https://github.com/w5s/project-config/commit/2fbc85132ab380429d6966bff47b176bcfb51f6d))
38
+ * shorten eslint extensions ([aecc870](https://github.com/w5s/project-config/commit/aecc870ce0b288436208757376bc05504bff3331))
39
+
40
+
41
+ ### Features
42
+
43
+ * use es-jest as default jest preset ([61535d9](https://github.com/w5s/project-config/commit/61535d9c47c25150becc564a5dd273d7cc14b579))
44
+
45
+
46
+
47
+
48
+
6
49
  # [1.0.0-alpha.5](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.4...@w5s/mrm-preset@1.0.0-alpha.5) (2022-02-18)
7
50
 
8
51
 
package/README.md CHANGED
@@ -19,7 +19,7 @@ Initialize your project using this command :
19
19
 
20
20
  ```bash
21
21
  # from the root of your project
22
- npm exec -p mrm -p @w5s/mrm-preset -- mrm bootstrap --preset @w5s/mrm-preset
22
+ npm exec --package=@w5s/mrm-preset -- mrm bootstrap --preset @w5s/mrm-preset
23
23
  ```
24
24
 
25
25
  This will install in `package.json` the npm scripts
@@ -1,8 +1,6 @@
1
1
  /* eslint-disable sort-keys-fix/sort-keys-fix */
2
2
  const path = require('path');
3
- const { packageJson, file, yaml } = require('mrm-core');
4
- // @ts-ignore
5
- const execCommand = require('mrm-core/src/util/execCommand');
3
+ const { packageJson, file } = require('mrm-core');
6
4
  const npm = require('../core/npm');
7
5
  const pkg = require('../core/pkg');
8
6
  const { gitIgnoreTemplate } = require('../core/git');
@@ -12,17 +10,11 @@ const { gitIgnoreTemplate } = require('../core/git');
12
10
  * mrmPreset: string,
13
11
  * mrmTask: string,
14
12
  * packageArchetype: 'application'|'library'|'workspace',
15
- * packageManager: 'npm'|'yarn'
13
+ * packageManager: 'npm'|'yarn@classic'|'yarn@berry'
16
14
  * }} config
17
15
  * @returns {void}
18
16
  */
19
17
  function task({ mrmPreset, mrmTask, packageArchetype, packageManager }) {
20
- const isYarn = file('package-lock.json').exists()
21
- ? false
22
- : file('yarn.lock').exists()
23
- ? true
24
- : packageManager === 'yarn';
25
- const isYarnBerry = false;
26
18
  /**
27
19
  * setup package.json from following object
28
20
  */
@@ -35,29 +27,28 @@ function task({ mrmPreset, mrmTask, packageArchetype, packageManager }) {
35
27
  description: '',
36
28
  }).save();
37
29
  gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
38
- if (isYarn && isYarnBerry) {
39
- execCommand(undefined, 'yarn', ['set', 'version', 'berry']);
40
- yaml('.yarnrc.yml').set('nodeLinker', 'node-modules').save();
41
- execCommand(undefined, 'yarn', ['install']);
42
- }
30
+
31
+ npm.bootstrap(packageManager);
32
+
43
33
  npm.dependency({
44
34
  dev: true,
45
35
  name: ['mrm', mrmPreset],
46
- yarn: isYarn,
47
36
  state: 'present',
48
37
  });
49
38
 
50
39
  pkg.withPackageJson((packageFile) => {
40
+ const currentPackageManager = pkg.manager(packageFile);
41
+
51
42
  // Add MRM default scripts
52
43
  pkg.script(packageFile, {
53
44
  name: 'configure',
54
45
  state: 'default',
55
- script: `${packageManager} run mrm -- ${mrmTask}`,
46
+ script: currentPackageManager === 'npm' ? `npm run mrm -- ${mrmTask}` : `yarn mrm ${mrmTask}`,
56
47
  });
57
48
  pkg.script(packageFile, {
58
49
  name: 'mrm',
59
50
  state: 'default',
60
- script: `${packageManager} --preset ${mrmPreset}`,
51
+ script: `${currentPackageManager} --preset ${mrmPreset}`,
61
52
  });
62
53
  });
63
54
 
@@ -97,8 +88,8 @@ task.parameters = {
97
88
  type: 'input',
98
89
  },
99
90
  packageManager: {
100
- default: 'yarn',
101
- choices: ['yarn', 'npm'],
91
+ default: 'yarn@berry',
92
+ choices: ['yarn@berry', 'yarn@classic', 'npm'],
102
93
  message: 'Which default package manager ?',
103
94
  name: 'packageManager',
104
95
  type: 'input',
package/core/block.js CHANGED
@@ -53,7 +53,7 @@ function block({
53
53
  const replaceBlock = beginBlock + EOL + blockContent + EOL + endBlock;
54
54
 
55
55
  if (found.exists) {
56
- return fullContent.substr(0, found.startIndex) + replaceBlock + fullContent.substr(found.endIndex);
56
+ return fullContent.slice(0, Math.max(0, found.startIndex)) + replaceBlock + fullContent.slice(found.endIndex);
57
57
  }
58
58
 
59
59
  // insert
package/core/git.js CHANGED
@@ -13,17 +13,19 @@ function remoteSync() {
13
13
  ? [
14
14
  /**
15
15
  * 1. filter github URL
16
+ *
16
17
  * @param {string} returnValue
17
18
  */
18
19
  (returnValue) => returnValue.replace(/^git@github.com:/, 'https://github.com/'),
19
20
  /**
20
21
  * 2. filter gitlab URL
22
+ *
21
23
  * @param {string} returnValue
22
24
  */
23
25
  (returnValue) => returnValue.replace(/^git@gitlab.com:/, 'https://gitlab.com/'),
24
26
  ].reduce((returnValue, filter) => filter(returnValue), remoteURL)
25
27
  : remoteURL;
26
- } catch (error) {
28
+ } catch {
27
29
  // ignore error
28
30
  }
29
31
 
package/core/jest.js CHANGED
@@ -1,6 +1,5 @@
1
1
  /* eslint-disable no-template-curly-in-string */
2
2
  const { packageJson } = require('mrm-core');
3
- const { vscodeSnippets } = require('./vscode');
4
3
  const pkg = require('./pkg');
5
4
  const npm = require('./npm');
6
5
  const project = require('./project');
@@ -13,34 +12,31 @@ const project = require('./project');
13
12
  function jest({ state }) {
14
13
  const packageFileDefault = packageJson();
15
14
  const hasJest = state === 'present';
16
- const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
17
15
  const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
16
+ const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
18
17
 
19
18
  pkg.withPackageJson((packageFile) => {
20
19
  if (hasJest) {
21
- const ignorePatterns = ['/node_modules/', '/docs/', '/lib/', '/build/', '/.cache/', '/public/'];
22
- packageFile.merge({
23
- jest: {
24
- coveragePathIgnorePatterns: ignorePatterns,
25
- testPathIgnorePatterns: ignorePatterns,
26
- },
27
- });
28
- if (hasTypescript) {
20
+ if (hasWorkspaces) {
21
+ pkg.value(packageFile, {
22
+ path: 'jest',
23
+ state: 'present',
24
+ update: () => ({
25
+ preset: 'es-jest',
26
+ projects: packageFile
27
+ .get('workspaces.packages', packageFile.get('workspaces', []))
28
+ .map((/** @type {string} */ workspace) => `<rootDir>/${workspace}`),
29
+ }),
30
+ });
31
+ } else {
32
+ const ignorePatterns = ['/node_modules/', '/docs/', '/lib/', '/build/', '/.cache/', '/public/'];
29
33
  packageFile.merge({
30
34
  jest: {
31
- globals: {
32
- 'ts-jest': {
33
- tsconfig: hasWorkspaces ? 'tsconfig.settings.json' : 'tsconfig.json',
34
- },
35
- },
36
- roots: hasWorkspaces ? ['<rootDir>/packages'] : null,
37
- transform: {
38
- '^.+\\.tsx?$': 'ts-jest',
39
- },
35
+ preset: 'es-jest',
36
+ coveragePathIgnorePatterns: ignorePatterns,
37
+ testPathIgnorePatterns: ignorePatterns,
40
38
  },
41
39
  });
42
- } else {
43
- packageFile.unset('jest.globals.ts-jest').unset('jest.transform.^.+\\.tsx?$');
44
40
  }
45
41
  } else {
46
42
  packageFile.unset('jest');
@@ -56,48 +52,43 @@ function jest({ state }) {
56
52
  script: hasWorkspaces ? pkg.emptyScript : 'jest',
57
53
  state: !hasJest || hasWorkspaces ? 'default' : 'present',
58
54
  });
59
- pkg.script(packageFile, {
60
- name: `${project.test}:watch`,
61
- script: pkg.emptyScript,
62
- state: 'absent',
63
- });
64
55
  });
65
56
  // Dependencies
66
57
  npm.dependency({
67
58
  dev: true,
68
- name: ['jest', 'babel-jest', '@babel/core'],
59
+ name: ['jest', 'es-jest'],
69
60
  state: hasJest ? 'present' : 'absent',
70
61
  });
71
62
  npm.dependency({
72
63
  dev: true,
73
- name: ['ts-jest', '@types/jest'],
64
+ name: ['@types/jest'],
74
65
  state: hasJest && hasTypescript ? 'present' : 'absent',
75
66
  });
76
67
 
77
- vscodeSnippets({
78
- name: 'jest',
79
- snippets: {
80
- 'Jest Describe Block': {
81
- body: ["describe('${1:description}', () => {", '\t$0', '});'],
82
- description: 'Jest describe block',
83
- prefix: 'describe',
84
- scope: 'javascript,typescript',
85
- },
86
- 'Jest Expect': {
87
- body: 'expect($0)',
88
- description: 'Jest expect assertion',
89
- prefix: 'expect',
90
- scope: 'javascript,typescript',
91
- },
92
- 'Jest Test Block': {
93
- body: ["test('${1:description}', () => {", '\t$0', '});'],
94
- description: 'Jest test block',
95
- prefix: 'test',
96
- scope: 'javascript,typescript',
97
- },
98
- },
99
- state: hasJest ? 'present' : 'absent',
100
- });
68
+ // vscodeSnippets({
69
+ // name: 'jest',
70
+ // snippets: {
71
+ // 'Jest Describe Block': {
72
+ // body: ["describe('${1:description}', () => {", '\t$0', '});'],
73
+ // description: 'Jest describe block',
74
+ // prefix: 'describe',
75
+ // scope: 'javascript,typescript',
76
+ // },
77
+ // 'Jest Expect': {
78
+ // body: 'expect($0)',
79
+ // description: 'Jest expect assertion',
80
+ // prefix: 'expect',
81
+ // scope: 'javascript,typescript',
82
+ // },
83
+ // 'Jest Test Block': {
84
+ // body: ["test('${1:description}', () => {", '\t$0', '});'],
85
+ // description: 'Jest test block',
86
+ // prefix: 'test',
87
+ // scope: 'javascript,typescript',
88
+ // },
89
+ // },
90
+ // state: hasJest ? 'present' : 'absent',
91
+ // });
101
92
  }
102
93
 
103
94
  module.exports = {
package/core/npm.js CHANGED
@@ -18,11 +18,10 @@ const log = require('mrm-core/src/util/log');
18
18
  // @ts-ignore
19
19
  const execCommand = require('mrm-core/src/util/execCommand');
20
20
  // @ts-ignore
21
- const json = require('mrm-core/src/formats/json');
22
- // @ts-ignore
23
21
  const packageJson = require('mrm-core/src/files/packageJson');
24
22
  // @ts-ignore
25
23
  const MrmError = require('mrm-core/src/error');
24
+ const { yaml, json } = require('mrm-core');
26
25
 
27
26
  /**
28
27
  * @typedef Options
@@ -249,7 +248,36 @@ function isUsingWorkspaces() {
249
248
  }
250
249
 
251
250
  function isYarnBerry() {
252
- return fs.existsSync('.yarnrc.yml');
251
+ const yamlRC = yaml('.yarnrc.yml');
252
+ return yamlRC.exists() && !(yamlRC.get('yarnPath') || '').includes('.yarn/releases/yarn-1.');
253
+ }
254
+
255
+ /**
256
+ * @param {'npm'|`yarn@${'classic'|'berry'}`} defaultPackageManager
257
+ */
258
+ function bootstrap(defaultPackageManager) {
259
+ const packageFile = json(`./package.json`);
260
+ const isYarn = isUsingYarn() || defaultPackageManager.startsWith('yarn@');
261
+ if (!packageFile.get('packageManager') && isYarn) {
262
+ execCommand(undefined, 'yarn', ['set', 'version', 'berry']);
263
+ yaml('.yarnrc.yml')
264
+ .merge({
265
+ nodeLinker: 'node-modules',
266
+ })
267
+ .save();
268
+ // Downgrade
269
+ if (defaultPackageManager.endsWith('@classic')) {
270
+ execCommand(undefined, 'yarn', ['set', 'version', 'classic']);
271
+ }
272
+ }
273
+
274
+ // lock files
275
+ if (isYarn && !fs.existsSync('yarn.lock')) {
276
+ execCommand(undefined, 'yarn', ['install']);
277
+ }
278
+ if (!isYarn && !fs.existsSync('package-lock.json')) {
279
+ execCommand(undefined, 'npm', ['install']);
280
+ }
253
281
  }
254
282
 
255
283
  /**
@@ -269,5 +297,6 @@ function dependency({ name, state, ...options }) {
269
297
  }
270
298
 
271
299
  module.exports = {
300
+ bootstrap,
272
301
  dependency,
273
302
  };
package/core/pkg.js CHANGED
@@ -100,18 +100,14 @@ function engineMinVersion(packageFile, engineVersionMap) {
100
100
  const currentVersion = packageFile.get(`engines.${engineName}`, defaultVersion);
101
101
  try {
102
102
  return intersect(currentVersion, defaultVersion);
103
- } catch (_) {
103
+ } catch {
104
104
  return currentVersion; // leave unchanged
105
105
  }
106
106
  };
107
107
 
108
108
  packageFile.merge({
109
- engines: Object.keys(engineVersionMap).reduce(
110
- (acc, engineName) => ({
111
- ...acc,
112
- [engineName]: engineConstraint(engineName),
113
- }),
114
- {}
109
+ engines: Object.fromEntries(
110
+ Object.keys(engineVersionMap).map((engineName) => [engineName, engineConstraint(engineName)])
115
111
  ),
116
112
  });
117
113
  }
package/core/typedoc.js CHANGED
@@ -26,14 +26,6 @@ function typedoc({ state, update }) {
26
26
  const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
27
27
  const hasTypedoc = state === 'present';
28
28
 
29
- pkg.withPackageJson((packageFile) => {
30
- pkg.script(packageFile, {
31
- name: 'typedoc',
32
- script: 'typedoc',
33
- state: !hasTypedoc || hasWorkspaces ? 'absent' : 'present',
34
- });
35
- });
36
-
37
29
  const typedocFile = json('typedoc.json');
38
30
 
39
31
  if (hasTypedoc) {
@@ -44,11 +36,11 @@ function typedoc({ state, update }) {
44
36
  ...update(config),
45
37
  ...(hasWorkspaces
46
38
  ? {
47
- 'external-modulemap': '.*packages/([^/]+)/.*',
48
- entryPoints: ['packages/'],
39
+ entryPointStrategy: 'packages',
40
+ entryPoints: undefined,
49
41
  }
50
42
  : {
51
- 'external-modulemap': undefined,
43
+ entryPointStrategy: undefined,
52
44
  entryPoints: ['src/index.ts'],
53
45
  }),
54
46
  }),
@@ -70,11 +62,6 @@ function typedoc({ state, update }) {
70
62
  name: ['typedoc'],
71
63
  state: hasTypedoc ? 'present' : 'absent',
72
64
  });
73
- npm.dependency({
74
- dev: true,
75
- name: ['@strictsoftware/typedoc-plugin-monorepo'],
76
- state: hasTypedoc && hasWorkspaces ? 'present' : 'absent',
77
- });
78
65
  }
79
66
 
80
67
  module.exports = {
package/core/vscode.js CHANGED
@@ -31,7 +31,7 @@ function vscodeTask(newTask) {
31
31
  * @type {Array<any>}
32
32
  */
33
33
  const tasks = vscodeTaskFile.get('tasks', []);
34
- if (tasks.find((task) => task.script === newTask.script)) {
34
+ if (tasks.some((task) => task.script === newTask.script)) {
35
35
  vscodeTaskFile.set(
36
36
  'tasks',
37
37
  tasks.map((task) => (task.script === newTask.script ? newTask : task))
@@ -26,6 +26,7 @@ function createEditorConfig(defaults) {
26
26
 
27
27
  /**
28
28
  * @param {string} section
29
+ * @param existing
29
30
  */
30
31
  function mergeSection(section, existing = {}) {
31
32
  return Object.assign(existing, defaults[section] || {});
@@ -52,6 +53,7 @@ function createEditorConfig(defaults) {
52
53
 
53
54
  module.exports = createEditorConfig({
54
55
  '*': {
56
+ // eslint-disable-next-line unicorn/text-encoding-identifier-case
55
57
  charset: 'utf-8',
56
58
  continuation_indent_size: 4,
57
59
  curly_bracket_next_line: false,
package/eslint/index.js CHANGED
@@ -70,7 +70,7 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
70
70
  json: hasJSON,
71
71
  };
72
72
  const extList = Object.keys(extsMap).filter((ext) => extsMap[ext]);
73
- const extOption = ` --ext ${extList.map((ext) => `.${ext}`).join(',')}`;
73
+ const extOption = ` --ext=${extList.join(',')}`;
74
74
 
75
75
  pkg.withPackageJson((packageFile) => {
76
76
  pkg.script(packageFile, {
package/githooks/index.js CHANGED
@@ -7,57 +7,44 @@ const { gitHook, husky } = require('../core/githooks');
7
7
  const { lintStaged } = require('../core/lintStaged');
8
8
  const { file } = require('../core/file');
9
9
 
10
- function createGitHooks() {
11
- function task() {
12
- const gitSupported = hasGit();
13
- const packageFile = packageJson();
14
- const hasESLint = pkg.hasDependency(packageFile, 'eslint', 'dev');
15
- const hasJest = pkg.hasDependency(packageFile, 'jest', 'dev');
16
- const hasTsc = pkg.hasDependency(packageFile, 'typescript', 'dev');
10
+ function task() {
11
+ const gitSupported = hasGit();
12
+ const packageFile = packageJson();
13
+ const hasESLint = pkg.hasDependency(packageFile, 'eslint', 'dev');
14
+ const hasTsc = pkg.hasDependency(packageFile, 'typescript', 'dev');
17
15
 
18
- husky({
19
- state: gitSupported ? 'present' : 'absent',
20
- });
21
- lintStaged({
22
- state: gitSupported ? 'present' : 'absent',
23
- update: (config) => ({
24
- ...config,
25
- '*.json': [...(hasESLint ? ['eslint'] : [])],
26
- '*.js?(x)': [
27
- ...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []),
28
- ...(hasESLint ? ['eslint'] : []),
29
- ...(hasJest ? ['jest --ci --bail --findRelatedTests'] : []),
30
- ],
31
- '*.ts?(x)': [
32
- ...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []),
33
- ...(hasESLint ? ['eslint'] : []),
34
- ...(hasJest ? ['jest --ci --bail --findRelatedTests'] : []),
35
- ],
36
- }),
37
- });
38
- gitHook({
39
- name: 'pre-commit',
40
- content: `npm exec --no -- lint-staged`,
41
- state: gitSupported ? 'present' : 'absent',
42
- });
43
- gitHook({
44
- name: 'pre-push',
45
- content: `npm run ${project.validate}`,
46
- state: gitSupported ? 'present' : 'absent',
47
- });
16
+ husky({
17
+ state: gitSupported ? 'present' : 'absent',
18
+ });
19
+ lintStaged({
20
+ state: gitSupported ? 'present' : 'absent',
21
+ update: (config) => ({
22
+ ...config,
23
+ '*.json': [...(hasESLint ? ['eslint'] : [])],
24
+ '*.js?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
25
+ '*.ts?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
26
+ }),
27
+ });
28
+ gitHook({
29
+ name: 'pre-commit',
30
+ content: `npm exec --no -- lint-staged`,
31
+ state: gitSupported ? 'present' : 'absent',
32
+ });
33
+ gitHook({
34
+ name: 'pre-push',
35
+ content: `npm run ${project.validate}`,
36
+ state: gitSupported ? 'present' : 'absent',
37
+ });
48
38
 
49
- file({
50
- path: 'CODEOWNERS',
51
- state: gitSupported ? 'file' : 'absent',
52
- update: (content) =>
53
- content.length === 0 ? template('', path.join(__dirname, 'templates', 'CODEOWNERS')).apply().get() : undefined,
54
- });
55
- }
56
-
57
- task.description = 'Setup Git hooks';
58
- task.parameters = {};
59
-
60
- return task;
39
+ file({
40
+ path: 'CODEOWNERS',
41
+ state: gitSupported ? 'file' : 'absent',
42
+ update: (content) =>
43
+ content.length === 0 ? template('', path.join(__dirname, 'templates', 'CODEOWNERS')).apply().get() : undefined,
44
+ });
61
45
  }
62
46
 
63
- module.exports = createGitHooks();
47
+ task.description = 'Setup Git hooks';
48
+ task.parameters = {};
49
+
50
+ module.exports = task;
@@ -4,3 +4,5 @@ function task() {
4
4
  gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
5
5
  }
6
6
  task.description = 'Adds Gitignore file';
7
+
8
+ module.exports = task;
package/jest/index.js CHANGED
@@ -1,19 +1,15 @@
1
1
  const { jest } = require('../core/jest');
2
2
 
3
- function createJest() {
4
- /**
5
- *
6
- */
7
- function task() {
8
- jest({
9
- state: 'present',
10
- });
11
- }
12
-
13
- task.description = 'Setup Jest';
14
- task.parameters = {};
15
-
16
- return task;
3
+ /**
4
+ *
5
+ */
6
+ function task() {
7
+ jest({
8
+ state: 'present',
9
+ });
17
10
  }
18
11
 
19
- module.exports = createJest();
12
+ task.description = 'Setup Jest';
13
+ task.parameters = {};
14
+
15
+ module.exports = task;
@@ -4,5 +4,8 @@
4
4
  "@typescript-eslint/no-unsafe-call": "off",
5
5
  "@typescript-eslint/no-unsafe-assignment": "off",
6
6
  "@typescript-eslint/no-unsafe-member-access": "off"
7
- }
7
+ },
8
+ "ignorePatterns": [
9
+ "**/templates/*.ts"
10
+ ]
8
11
  }
package/lang/index.js CHANGED
@@ -1,4 +1,4 @@
1
- const { join } = require('path');
1
+ const path = require('path');
2
2
  const { json, file, template, packageJson } = require('mrm-core');
3
3
  const npm = require('../core/npm');
4
4
  const { gitIgnore } = require('../core/git');
@@ -11,14 +11,14 @@ const pkg = require('../core/pkg');
11
11
  *
12
12
  * @param {{
13
13
  * language: 'typescript',
14
- * tsConfig: string,
14
+ * tsConfig: string
15
15
  * }} config
16
16
  */
17
17
  function createLang({ language: languageDefault = 'typescript', tsConfig: tsConfigDefault }) {
18
18
  /**
19
19
  *
20
20
  * @param {{
21
- * language: 'typescript',
21
+ * language: 'typescript'
22
22
  * }} config
23
23
  */
24
24
  function task({ language }) {
@@ -43,6 +43,7 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
43
43
  .unset('compilerOptions.outDir')
44
44
  .unset('include')
45
45
  .merge({
46
+ $schema: 'https://json.schemastore.org/tsconfig',
46
47
  extends: `./${tsConfigSettingsName}`,
47
48
  })
48
49
  .save();
@@ -52,6 +53,7 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
52
53
  } else {
53
54
  tsConfigSettings
54
55
  .merge({
56
+ $schema: 'https://json.schemastore.org/tsconfig',
55
57
  compilerOptions: {},
56
58
  extends: tsConfigPreset,
57
59
  })
@@ -68,12 +70,12 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
68
70
  .save();
69
71
 
70
72
  // Create default index
71
- const templateDir = join(__dirname, 'templates');
73
+ const templateDir = path.join(__dirname, 'templates');
72
74
  if (!file('src/index.ts').exists()) {
73
- template('src/index.ts', join(templateDir, 'index.ts')).apply().save();
75
+ template('src/index.ts', path.join(templateDir, 'index.ts')).apply().save();
74
76
  }
75
77
  if (!file('src/index.spec.ts').exists()) {
76
- template('src/index.spec.ts', join(templateDir, 'index.spec.ts')).apply().save();
78
+ template('src/index.spec.ts', path.join(templateDir, 'index.spec.ts')).apply().save();
77
79
  }
78
80
  }
79
81
  // Application setup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/mrm-preset",
3
- "version": "1.0.0-alpha.5",
3
+ "version": "1.0.0-alpha.8",
4
4
  "description": "Mrm configuration presets",
5
5
  "keywords": [
6
6
  "mrm",
@@ -26,7 +26,7 @@
26
26
  "docs": "md-magic --path '**/*.md' --ignore='node_modules'",
27
27
  "format": "eslint . --fix",
28
28
  "lint": "eslint .",
29
- "test": "mkdir _tester; cd _tester; ../node_modules/.bin/mrm bootstrap --dir ..; ../node_modules/.bin/mrm configure --dir .."
29
+ "test": "mkdir _tester; cd _tester; mrm bootstrap --dir ..; mrm configure --dir .."
30
30
  },
31
31
  "dependencies": {
32
32
  "debug": "^4.3.3",
@@ -45,5 +45,5 @@
45
45
  "publishConfig": {
46
46
  "access": "public"
47
47
  },
48
- "gitHead": "17d00b3e9ba103fd053aed2c06535d0b1526886a"
48
+ "gitHead": "468c38fd7cd2690ee860d222d360cc10b840dcfd"
49
49
  }
package/project/index.js CHANGED
@@ -6,37 +6,36 @@ const { vscodeTask } = require('../core/vscode');
6
6
  const project = require('../core/project');
7
7
  const mrmPackageJson = require('../package.json');
8
8
 
9
+ /**
10
+ *
11
+ * @param {string} script
12
+ */
13
+ const npmRun = (script) => {
14
+ switch (script) {
15
+ case project.install:
16
+ case project.test:
17
+ return `npm ${script}`;
18
+ default:
19
+ return `npm run ${script}`;
20
+ }
21
+ };
22
+ /**
23
+ *
24
+ * @param {string} script
25
+ */
26
+ const turboRun = (script) => `turbo run ${script}`;
27
+
28
+ /**
29
+ *
30
+ * @param {string} script
31
+ */
32
+ const npmRunAll = (script) => `npm-run-all -p "${script}:*"`;
9
33
  function task() {
10
34
  const packageFile = packageJson();
11
35
  const gitSupported = git.hasGit();
12
36
  const useWorkspace = packageFile.get('mrmConfig.packageArchetype') === 'workspace';
13
37
  const packageManager = pkg.manager(packageFile);
14
38
 
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}:*"`;
39
-
40
39
  // Detect git repository
41
40
  pkg.value(packageFile, {
42
41
  path: 'repository',
@@ -67,12 +66,12 @@ function task() {
67
66
  });
68
67
  pkg.script(packageFile, {
69
68
  name: `${project.build}:packages`,
70
- script: lernaRun(project.build),
69
+ script: turboRun(project.build),
71
70
  state: useWorkspace ? 'present' : 'absent',
72
71
  });
73
72
  pkg.script(packageFile, {
74
73
  name: project.clean,
75
- script: useWorkspace ? lernaRun(project.clean) : pkg.emptyScript,
74
+ script: useWorkspace ? turboRun(project.clean) : pkg.emptyScript,
76
75
  state: useWorkspace ? 'present' : 'default',
77
76
  });
78
77
 
@@ -103,8 +102,18 @@ function task() {
103
102
  });
104
103
  pkg.script(packageFile, {
105
104
  name: project.test,
106
- script: useWorkspace ? lernaRun(project.test) : pkg.emptyScript,
107
- state: useWorkspace ? 'present' : 'default',
105
+ script: npmRunAll(project.test),
106
+ state: 'present',
107
+ });
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',
108
117
  });
109
118
  pkg.script(packageFile, {
110
119
  name: project.validate,
@@ -151,6 +160,25 @@ function task() {
151
160
  });
152
161
 
153
162
  // workspace
163
+ const turboConfig = json('turbo.json', {
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
+ });
154
182
  const lernaConfig = json('lerna.json', {
155
183
  version: packageFile.get('version'),
156
184
  });
@@ -172,10 +200,12 @@ function task() {
172
200
  useWorkspaces: useWorkspace,
173
201
  });
174
202
  lernaConfig.save();
203
+ turboConfig.save();
175
204
  makeDirs('packages');
176
205
  } else {
177
206
  packageFile.unset('workspaces');
178
207
  lernaConfig.delete();
208
+ turboConfig.delete();
179
209
  }
180
210
 
181
211
  // Engine
@@ -200,7 +230,7 @@ function task() {
200
230
  });
201
231
  npm.dependency({
202
232
  dev: true,
203
- name: ['lerna'],
233
+ name: ['lerna', 'turbo'],
204
234
  state: useWorkspace ? 'present' : 'absent',
205
235
  });
206
236
 
package/release/index.js CHANGED
@@ -11,7 +11,7 @@ function task() {
11
11
  pkg.script(packageFile, {
12
12
  name: project.release,
13
13
  // eslint-disable-next-line no-template-curly-in-string
14
- script: useWorkspace ? 'CI=$(is-ci) lerna publish ${CI:+"--yes"}' : semanticRelease.command(),
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
@@ -4,7 +4,7 @@ const { hasGit } = require('../core/git');
4
4
  /**
5
5
  *
6
6
  * @param {{
7
- * renovatePresetApplication: string
7
+ * renovatePresetApplication: string,
8
8
  * renovatePresetLibrary: string
9
9
  * }} config
10
10
  */
package/tsconfig.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "$schema": "https://json.schemastore.org/tsconfig",
2
3
  "extends": "../../tsconfig.json",
3
4
  "compilerOptions": {
4
5
  "allowJs": true,