@w5s/mrm-preset 1.0.0-alpha.4 → 1.0.0-alpha.7

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 65d77d6fca114214
@@ -0,0 +1,43 @@
1
+ @w5s/mrm-preset:docs: cache hit, replaying output f34cf75e082653a5
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,20 @@
1
+ @w5s/mrm-preset:test: cache hit, replaying output 6b4f5273625c6ddf
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...
package/CHANGELOG.md CHANGED
@@ -3,6 +3,56 @@
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.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)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * correct bootstrap step ([da7f539](https://github.com/w5s/project-config/commit/da7f539560ba143f830c9ea824b0d79c6a50522c))
12
+ * correct is-ci script that fails in some yarn berry ([4e4707d](https://github.com/w5s/project-config/commit/4e4707d7e8c0cd2c88e1dc6bc94705317dcf9e98))
13
+ * improve yarn check ([3af241a](https://github.com/w5s/project-config/commit/3af241af004d747518733983260eb295aa75e5cb))
14
+
15
+
16
+
17
+
18
+
19
+ # [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)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * correct gitignore task ([b4f0903](https://github.com/w5s/project-config/commit/b4f0903561c97500aef65488ef06ccd7eae0db80))
25
+ * remove jest on lint-staged ([2fbc851](https://github.com/w5s/project-config/commit/2fbc85132ab380429d6966bff47b176bcfb51f6d))
26
+ * shorten eslint extensions ([aecc870](https://github.com/w5s/project-config/commit/aecc870ce0b288436208757376bc05504bff3331))
27
+
28
+
29
+ ### Features
30
+
31
+ * use es-jest as default jest preset ([61535d9](https://github.com/w5s/project-config/commit/61535d9c47c25150becc564a5dd273d7cc14b579))
32
+
33
+
34
+
35
+
36
+
37
+ # [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)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * change bootstrap behavior ([497c83a](https://github.com/w5s/project-config/commit/497c83a4082f7fd4e3b8b6913802ebcb21caa65a))
43
+ * remove lint-staged + cspell integration ([6747c83](https://github.com/w5s/project-config/commit/6747c83ec997034d25d136bc5aa008ed108ceb96))
44
+ * use UNLICENSED for default license ([608ee8f](https://github.com/w5s/project-config/commit/608ee8f0bf57fec94636587b116d5bda0fb4ee3f))
45
+
46
+
47
+ ### Features
48
+
49
+ * add gitignore for yarn v2 ([06c547a](https://github.com/w5s/project-config/commit/06c547a6b7813f935678c29b410aee62da5b3866))
50
+ * add support for yarn berry ([2b77669](https://github.com/w5s/project-config/commit/2b77669a29316825a38470c80a48aff8ab068f7f))
51
+
52
+
53
+
54
+
55
+
6
56
  # [1.0.0-alpha.4](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.3...@w5s/mrm-preset@1.0.0-alpha.4) (2022-02-16)
7
57
 
8
58
 
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
@@ -3,13 +3,14 @@ const path = require('path');
3
3
  const { packageJson, file } = require('mrm-core');
4
4
  const npm = require('../core/npm');
5
5
  const pkg = require('../core/pkg');
6
+ const { gitIgnoreTemplate } = require('../core/git');
6
7
 
7
8
  /**
8
9
  * @param {{
9
10
  * mrmPreset: string,
10
11
  * mrmTask: string,
11
12
  * packageArchetype: 'application'|'library'|'workspace',
12
- * packageManager: 'npm'|'yarn'
13
+ * packageManager: 'npm'|'yarn@classic'|'yarn@berry'
13
14
  * }} config
14
15
  * @returns {void}
15
16
  */
@@ -18,53 +19,53 @@ function task({ mrmPreset, mrmTask, packageArchetype, packageManager }) {
18
19
  * setup package.json from following object
19
20
  */
20
21
 
21
- const packageFile = packageJson({
22
+ packageJson({
22
23
  name: path.basename(process.cwd()),
23
24
  version: '1.0.0-alpha.0',
24
25
  private: true,
25
- license: 'PRIVATE',
26
+ license: 'UNLICENSED',
26
27
  description: '',
27
- });
28
-
29
- packageFile.merge({
30
- scripts: {
31
- configure: `npm run mrm -- ${mrmTask}`,
32
- mrm: `mrm --preset ${mrmPreset}`,
33
- },
34
- });
35
- pkg.value(packageFile, {
36
- path: 'packageManager',
37
- state: 'present',
38
- update: packageManager,
39
- default: () => {
40
- if (file('yarn.lock').exists()) {
41
- return 'yarn';
42
- }
43
-
44
- // return 'npm';
45
- return undefined;
46
- },
47
- });
48
- pkg.value(packageFile, {
49
- path: 'mrmConfig.packageArchetype',
50
- state: 'present',
51
- update: packageArchetype,
52
- default: () => {
53
- if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) {
54
- return 'workspace';
55
- }
28
+ }).save();
29
+ gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
56
30
 
57
- return 'library';
58
- },
59
- });
60
- packageFile.save();
31
+ npm.bootstrap(packageManager);
61
32
 
62
33
  npm.dependency({
63
34
  dev: true,
64
35
  name: ['mrm', mrmPreset],
65
- yarn: packageManager === 'yarn',
66
36
  state: 'present',
67
37
  });
38
+
39
+ pkg.withPackageJson((packageFile) => {
40
+ const currentPackageManager = pkg.manager(packageFile);
41
+
42
+ // Add MRM default scripts
43
+ pkg.script(packageFile, {
44
+ name: 'configure',
45
+ state: 'default',
46
+ script: currentPackageManager === 'npm' ? `npm run mrm -- ${mrmTask}` : `yarn mrm ${mrmTask}`,
47
+ });
48
+ pkg.script(packageFile, {
49
+ name: 'mrm',
50
+ state: 'default',
51
+ script: `${currentPackageManager} --preset ${mrmPreset}`,
52
+ });
53
+ });
54
+
55
+ pkg.withPackageJson((packageFile) => {
56
+ pkg.value(packageFile, {
57
+ path: 'mrmConfig.packageArchetype',
58
+ state: 'present',
59
+ update: packageArchetype,
60
+ default: () => {
61
+ if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) {
62
+ return 'workspace';
63
+ }
64
+
65
+ return 'library';
66
+ },
67
+ });
68
+ });
68
69
  }
69
70
 
70
71
  task.description = 'Bootstrap a new project.';
@@ -87,8 +88,8 @@ task.parameters = {
87
88
  type: 'input',
88
89
  },
89
90
  packageManager: {
90
- default: 'yarn',
91
- choices: ['yarn', 'npm'],
91
+ default: 'yarn@berry',
92
+ choices: ['yarn@berry', 'yarn@classic', 'npm'],
92
93
  message: 'Which default package manager ?',
93
94
  name: 'packageManager',
94
95
  type: 'input',
@@ -11,6 +11,7 @@ module.exports = {
11
11
  yarn-debug.log*
12
12
  yarn-error.log*
13
13
  lerna-debug.log*
14
+ .pnpm-debug.log*
14
15
 
15
16
  # Diagnostic reports (https://nodejs.org/api/report.html)
16
17
  report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
@@ -47,8 +48,8 @@ module.exports = {
47
48
  node_modules/
48
49
  jspm_packages/
49
50
 
50
- # TypeScript v1 declaration files
51
- typings/
51
+ # Snowpack dependency directory (https://snowpack.dev/)
52
+ web_modules/
52
53
 
53
54
  # TypeScript cache
54
55
  *.tsbuildinfo
@@ -59,6 +60,9 @@ module.exports = {
59
60
  # Optional eslint cache
60
61
  .eslintcache
61
62
 
63
+ # Optional stylelint cache
64
+ .stylelintcache
65
+
62
66
  # Microbundle cache
63
67
  .rpt2_cache/
64
68
  .rts2_cache_cjs/
@@ -74,15 +78,20 @@ module.exports = {
74
78
  # Yarn Integrity file
75
79
  .yarn-integrity
76
80
 
77
- # dotenv environment variables file
81
+ # dotenv environment variable files
78
82
  .env
79
- .env.test
83
+ .env.development.local
84
+ .env.test.local
85
+ .env.production.local
86
+ .env.local
80
87
 
81
88
  # parcel-bundler cache (https://parceljs.org/)
82
89
  .cache
90
+ .parcel-cache
83
91
 
84
92
  # Next.js build output
85
93
  .next
94
+ out
86
95
 
87
96
  # Nuxt.js build / generate output
88
97
  .nuxt
@@ -92,11 +101,18 @@ module.exports = {
92
101
  .cache/
93
102
  # Comment in the public line in if your project uses Gatsby and not Next.js
94
103
  # https://nextjs.org/blog/next-9-1#public-directory-support
95
- public/
104
+ # public
96
105
 
97
106
  # vuepress build output
98
107
  .vuepress/dist
99
108
 
109
+ # vuepress v2.x temp and cache directory
110
+ .temp
111
+ .cache
112
+
113
+ # Docusaurus cache and generated files
114
+ .docusaurus
115
+
100
116
  # Serverless directories
101
117
  .serverless/
102
118
 
@@ -107,7 +123,17 @@ module.exports = {
107
123
  .dynamodb/
108
124
 
109
125
  # TernJS port file
110
- .tern-port`,
126
+ .tern-port
127
+
128
+ # Stores VSCode versions used for testing VSCode extensions
129
+ .vscode-test
130
+
131
+ # yarn v2
132
+ .yarn/cache
133
+ .yarn/unplugged
134
+ .yarn/build-state.yml
135
+ .yarn/install-state.gz
136
+ .pnp.*`,
111
137
  VisualStudioCode: `
112
138
  .vscode/*
113
139
  !.vscode/settings.json
package/core/git.js CHANGED
@@ -61,3 +61,20 @@ function gitIgnore(section, sectionContent) {
61
61
  });
62
62
  }
63
63
  exports.gitIgnore = gitIgnore;
64
+
65
+ /**
66
+ * @param {string[]} flags
67
+ */
68
+ function gitIgnoreTemplate(flags) {
69
+ // eslint-disable-next-line global-require, import/no-dynamic-require
70
+ const templateMap = require('./git.ignore');
71
+
72
+ flags.forEach((flag) => {
73
+ // @ts-ignore
74
+ if (templateMap[flag]) {
75
+ // @ts-ignore
76
+ gitIgnore(flag, templateMap[flag]);
77
+ }
78
+ });
79
+ }
80
+ exports.gitIgnoreTemplate = gitIgnoreTemplate;
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
@@ -134,7 +133,7 @@ function runNpm(deps, options = {}, exec) {
134
133
  function runYarn(deps, options = {}, exec) {
135
134
  const add = options.dev ? ['add', '--dev'] : ['add'];
136
135
  const remove = ['remove'];
137
- const args = (options.remove ? remove : add).concat(isUsingWorkspaces() ? ['-W'] : []).concat(deps);
136
+ const args = (options.remove ? remove : add).concat(isUsingWorkspaces() && !isYarnBerry() ? ['-W'] : []).concat(deps);
138
137
 
139
138
  return execCommand(exec, 'yarn', args, {
140
139
  cwd: options.cwd,
@@ -248,6 +247,41 @@ function isUsingWorkspaces() {
248
247
  return Boolean(packageJson().get('workspaces'));
249
248
  }
250
249
 
250
+ function isYarnBerry() {
251
+ const yamlRC = yaml('.yarnrc.yml');
252
+ return yamlRC.exists() && (yamlRC.get('yarnPath') || '').indexOf('.yarn/releases/yarn-1.') < 0;
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')) {
262
+ if (isYarn) {
263
+ execCommand(undefined, 'yarn', ['set', 'version', 'berry']);
264
+ yaml('.yarnrc.yml')
265
+ .merge({
266
+ nodeLinker: 'node-modules',
267
+ })
268
+ .save();
269
+ // Downgrade
270
+ if (defaultPackageManager.endsWith('@classic')) {
271
+ execCommand(undefined, 'yarn', ['set', 'version', 'classic']);
272
+ }
273
+ }
274
+ }
275
+
276
+ // lock files
277
+ if (isYarn && !fs.existsSync('yarn.lock')) {
278
+ execCommand(undefined, 'yarn', ['install']);
279
+ }
280
+ if (!isYarn && !fs.existsSync('package-lock.json')) {
281
+ execCommand(undefined, 'npm', ['install']);
282
+ }
283
+ }
284
+
251
285
  /**
252
286
  * @param {{
253
287
  * name: string|string[]|Record<string, string>,
@@ -265,5 +299,6 @@ function dependency({ name, state, ...options }) {
265
299
  }
266
300
 
267
301
  module.exports = {
302
+ bootstrap,
268
303
  dependency,
269
304
  };
package/cspell/index.js CHANGED
@@ -1,9 +1,6 @@
1
1
  const { cspell } = require('../core/cspell');
2
- const { lintStaged } = require('../core/lintStaged');
3
- const { hasGit } = require('../core/git');
4
2
 
5
3
  function task() {
6
- const gitSupported = hasGit();
7
4
  cspell({
8
5
  state: 'present',
9
6
  update: (_) => ({
@@ -23,14 +20,6 @@ function task() {
23
20
  ),
24
21
  }),
25
22
  });
26
-
27
- lintStaged({
28
- state: gitSupported ? 'present' : 'absent',
29
- update: (config) => ({
30
- ...config,
31
- '*.*': ['cspell --no-must-find-files'],
32
- }),
33
- });
34
23
  }
35
24
 
36
25
  task.description = 'Adds CSpell support';
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
@@ -12,7 +12,6 @@ function createGitHooks() {
12
12
  const gitSupported = hasGit();
13
13
  const packageFile = packageJson();
14
14
  const hasESLint = pkg.hasDependency(packageFile, 'eslint', 'dev');
15
- const hasJest = pkg.hasDependency(packageFile, 'jest', 'dev');
16
15
  const hasTsc = pkg.hasDependency(packageFile, 'typescript', 'dev');
17
16
 
18
17
  husky({
@@ -23,16 +22,8 @@ function createGitHooks() {
23
22
  update: (config) => ({
24
23
  ...config,
25
24
  '*.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
- ],
25
+ '*.js?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
26
+ '*.ts?(x)': [...(hasTsc ? ["bash -c 'tsc --noEmit'"] : []), ...(hasESLint ? ['eslint'] : [])],
36
27
  }),
37
28
  });
38
29
  gitHook({
@@ -1,25 +1,8 @@
1
- const { gitIgnore } = require('../core/git');
1
+ const { gitIgnoreTemplate } = require('../core/git');
2
2
 
3
- /**
4
- *
5
- * @param {string} templatePath
6
- * @param {Array<string>} flags
7
- */
8
- function createGitIgnore(templatePath, flags) {
9
- function task() {
10
- // eslint-disable-next-line global-require, import/no-dynamic-require
11
- const templateMap = require(templatePath);
12
-
13
- flags.forEach((flag) => {
14
- if (templateMap[flag]) {
15
- gitIgnore(flag, templateMap[flag]);
16
- }
17
- });
18
- }
19
-
20
- task.description = 'Adds Gitignore file';
21
-
22
- return task;
3
+ function task() {
4
+ gitIgnoreTemplate(['macOS', 'NodeJS', 'VisualStudioCode']);
23
5
  }
6
+ task.description = 'Adds Gitignore file';
24
7
 
25
- module.exports = createGitIgnore(require.resolve('./template'), ['macOS', 'NodeJS', 'VisualStudioCode']);
8
+ module.exports = task;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/mrm-preset",
3
- "version": "1.0.0-alpha.4",
3
+ "version": "1.0.0-alpha.7",
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": "cd7eb2b021bb3c9dbc91375cece5349173a7c81a"
48
+ "gitHead": "791ae3e63ac1278f1299c4e8af2a88786b2b6683"
49
49
  }
package/project/index.js CHANGED
@@ -29,7 +29,7 @@ function task() {
29
29
  *
30
30
  * @param {string} script
31
31
  */
32
- const lernaRun = (script) => `lerna run ${script}`;
32
+ const turboRun = (script) => `turbo run ${script}`;
33
33
 
34
34
  /**
35
35
  *
@@ -67,12 +67,12 @@ function task() {
67
67
  });
68
68
  pkg.script(packageFile, {
69
69
  name: `${project.build}:packages`,
70
- script: lernaRun(project.build),
70
+ script: turboRun(project.build),
71
71
  state: useWorkspace ? 'present' : 'absent',
72
72
  });
73
73
  pkg.script(packageFile, {
74
74
  name: project.clean,
75
- script: useWorkspace ? lernaRun(project.clean) : pkg.emptyScript,
75
+ script: useWorkspace ? turboRun(project.clean) : pkg.emptyScript,
76
76
  state: useWorkspace ? 'present' : 'default',
77
77
  });
78
78
 
@@ -103,8 +103,18 @@ function task() {
103
103
  });
104
104
  pkg.script(packageFile, {
105
105
  name: project.test,
106
- script: useWorkspace ? lernaRun(project.test) : pkg.emptyScript,
107
- state: useWorkspace ? 'present' : 'default',
106
+ script: npmRunAll(project.test),
107
+ state: 'present',
108
+ });
109
+ pkg.script(packageFile, {
110
+ name: `${project.prepare}:empty`,
111
+ script: pkg.emptyScript,
112
+ state: 'default',
113
+ });
114
+ pkg.script(packageFile, {
115
+ name: `${project.prepare}:packages`,
116
+ script: turboRun(project.test),
117
+ state: useWorkspace ? 'present' : 'absent',
108
118
  });
109
119
  pkg.script(packageFile, {
110
120
  name: project.validate,
@@ -151,6 +161,25 @@ function task() {
151
161
  });
152
162
 
153
163
  // workspace
164
+ const turboConfig = json('turbo.json', {
165
+ $schema: 'https://turborepo.org/schema.json',
166
+ pipeline: {
167
+ [project.build]: {
168
+ dependsOn: ['^build'],
169
+ outputs: ['lib/**', 'dist/**', '.next/**'],
170
+ },
171
+ [project.test]: {},
172
+ [project.lint]: {},
173
+ [project.format]: {},
174
+ [project.clean]: {
175
+ cache: false,
176
+ },
177
+ [project.develop]: {
178
+ cache: false,
179
+ },
180
+ },
181
+ globalDependencies: ['tsconfig.settings.json'],
182
+ });
154
183
  const lernaConfig = json('lerna.json', {
155
184
  version: packageFile.get('version'),
156
185
  });
@@ -172,10 +201,12 @@ function task() {
172
201
  useWorkspaces: useWorkspace,
173
202
  });
174
203
  lernaConfig.save();
204
+ turboConfig.save();
175
205
  makeDirs('packages');
176
206
  } else {
177
207
  packageFile.unset('workspaces');
178
208
  lernaConfig.delete();
209
+ turboConfig.delete();
179
210
  }
180
211
 
181
212
  // Engine
@@ -200,7 +231,7 @@ function task() {
200
231
  });
201
232
  npm.dependency({
202
233
  dev: true,
203
- name: ['lerna'],
234
+ name: ['lerna', 'turbo'],
204
235
  state: useWorkspace ? 'present' : 'absent',
205
236
  });
206
237
 
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
  });