@w5s/mrm-preset 1.0.0-alpha.16 → 1.0.0-alpha.19

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,11 @@
1
- @w5s/mrm-preset:build: cache hit, replaying output 3ae6287c6cd39161
1
+ @w5s/mrm-preset:build: cache hit, replaying output b2674e19e9d29ff6
2
+ @w5s/mrm-preset:build: [build:*tsc]
3
+ @w5s/mrm-preset:build: [build:*tsc] > @w5s/mrm-preset@1.0.0-alpha.18 build:tsc
4
+ @w5s/mrm-preset:build: [build:*tsc] > tsc --noEmit --skipLibCheck
5
+ @w5s/mrm-preset:build: [build:*tsc]
6
+ @w5s/mrm-preset:build: [build:*empty]
7
+ @w5s/mrm-preset:build: [build:*empty] > @w5s/mrm-preset@1.0.0-alpha.18 build:empty
8
+ @w5s/mrm-preset:build: [build:*empty] > :
9
+ @w5s/mrm-preset:build: [build:*empty]
10
+ @w5s/mrm-preset:build: [build:*empty] npm run build:empty exited with code 0
11
+ @w5s/mrm-preset:build: [build:*tsc] npm run build:tsc exited with code 0
@@ -1,4 +1,4 @@
1
- @w5s/mrm-preset:docs: cache hit, replaying output a2b095232856b838
1
+ @w5s/mrm-preset:docs: cache hit, replaying output 7929426e31db918c
2
2
  @w5s/mrm-preset:docs: Starting markdown-magic [ '**/*.md', '!node_modules/**' ]
3
3
  @w5s/mrm-preset:docs: ℹ Notice:
4
4
  @w5s/mrm-preset:docs:  Missing transforms "BASIC_RULES","JSX_RULES" in _tester/node_modules/eslint-plugin-react/README.md
@@ -0,0 +1,7 @@
1
+ @w5s/mrm-preset:format: cache hit, replaying output 2ccea371b5ea23ec
2
+ @w5s/mrm-preset:format: [1] : exited with code 0
3
+ @w5s/mrm-preset:format: [format:*src]
4
+ @w5s/mrm-preset:format: [format:*src] > @w5s/mrm-preset@1.0.0-alpha.18 format:src
5
+ @w5s/mrm-preset:format: [format:*src] > eslint . --fix --ext=mjs,cjs,js,jsx,ts,tsx,json
6
+ @w5s/mrm-preset:format: [format:*src]
7
+ @w5s/mrm-preset:format: [format:*src] npm run format:src exited with code 0
@@ -1 +1,7 @@
1
- @w5s/mrm-preset:lint: cache hit, replaying output 4d1dcf5150563fb9
1
+ @w5s/mrm-preset:lint: cache hit, replaying output 22fed320b23e49fa
2
+ @w5s/mrm-preset:lint: [1] : exited with code 0
3
+ @w5s/mrm-preset:lint: [lint:*src]
4
+ @w5s/mrm-preset:lint: [lint:*src] > @w5s/mrm-preset@1.0.0-alpha.18 lint:src
5
+ @w5s/mrm-preset:lint: [lint:*src] > eslint . --ext=mjs,cjs,js,jsx,ts,tsx,json
6
+ @w5s/mrm-preset:lint: [lint:*src]
7
+ @w5s/mrm-preset:lint: [lint:*src] npm run lint:src exited with code 0
@@ -0,0 +1,2 @@
1
+ @w5s/mrm-preset:prepare: cache hit, replaying output 2a953d2da4d297c9
2
+ @w5s/mrm-preset:prepare: [0] : exited with code 0
@@ -1,21 +1,46 @@
1
- @w5s/mrm-preset:test: cache hit, replaying output 51f7d11ddf5ce245
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...
1
+ @w5s/mrm-preset:test: cache hit, replaying output 52d5e4f6637d08e9
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: Uninstalling npm-run-all...
9
+ @w5s/mrm-preset:test: 
10
+ @w5s/mrm-preset:test: removed 19 packages, and audited 1391 packages in 3s
11
+ @w5s/mrm-preset:test: 
12
+ @w5s/mrm-preset:test: 143 packages are looking for funding
13
+ @w5s/mrm-preset:test:  run `npm fund` for details
14
+ @w5s/mrm-preset:test: 
15
+ @w5s/mrm-preset:test: 6 moderate severity vulnerabilities
16
+ @w5s/mrm-preset:test: 
17
+ @w5s/mrm-preset:test: To address all issues (including breaking changes), run:
18
+ @w5s/mrm-preset:test:  npm audit fix --force
19
+ @w5s/mrm-preset:test: 
20
+ @w5s/mrm-preset:test: Run `npm audit` for details.
21
+ @w5s/mrm-preset:test: Installing concurrently...
22
+ @w5s/mrm-preset:test: 
23
+ @w5s/mrm-preset:test: added 12 packages, and audited 1403 packages in 7s
24
+ @w5s/mrm-preset:test: 
25
+ @w5s/mrm-preset:test: 144 packages are looking for funding
26
+ @w5s/mrm-preset:test:  run `npm fund` for details
27
+ @w5s/mrm-preset:test: 
28
+ @w5s/mrm-preset:test: 6 moderate severity vulnerabilities
29
+ @w5s/mrm-preset:test: 
30
+ @w5s/mrm-preset:test: To address all issues (including breaking changes), run:
31
+ @w5s/mrm-preset:test:  npm audit fix --force
32
+ @w5s/mrm-preset:test: 
33
+ @w5s/mrm-preset:test: Run `npm audit` for details.
34
+ @w5s/mrm-preset:test: Running contributing...
35
+ @w5s/mrm-preset:test: Running license...
36
+ @w5s/mrm-preset:test: Running release...
37
+ @w5s/mrm-preset:test: Running ci...
38
+ @w5s/mrm-preset:test: Running lang...
39
+ @w5s/mrm-preset:test: Running commitlint...
40
+ @w5s/mrm-preset:test: Running editorconfig...
41
+ @w5s/mrm-preset:test: Running eslint...
42
+ @w5s/mrm-preset:test: Running cspell...
43
+ @w5s/mrm-preset:test: Running jest...
44
+ @w5s/mrm-preset:test: Running renovate...
45
+ @w5s/mrm-preset:test: Running githooks...
46
+ @w5s/mrm-preset:test: Running postconfigure...
package/CHANGELOG.md CHANGED
@@ -3,6 +3,30 @@
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.19](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.18...@w5s/mrm-preset@1.0.0-alpha.19) (2022-06-28)
7
+
8
+ **Note:** Version bump only for package @w5s/mrm-preset
9
+
10
+
11
+
12
+
13
+
14
+ # [1.0.0-alpha.18](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.17...@w5s/mrm-preset@1.0.0-alpha.18) (2022-06-23)
15
+
16
+ **Note:** Version bump only for package @w5s/mrm-preset
17
+
18
+
19
+
20
+
21
+
22
+ # [1.0.0-alpha.17](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.16...@w5s/mrm-preset@1.0.0-alpha.17) (2022-06-23)
23
+
24
+ **Note:** Version bump only for package @w5s/mrm-preset
25
+
26
+
27
+
28
+
29
+
6
30
  # [1.0.0-alpha.16](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.15...@w5s/mrm-preset@1.0.0-alpha.16) (2022-06-16)
7
31
 
8
32
 
@@ -55,6 +55,8 @@ variables:
55
55
  when: never
56
56
  - if: "$CI_COMMIT_TAG"
57
57
  when: never
58
+ - if: $CI_COMMIT_MESSAGE =~ /🔖 /
59
+ when: never
58
60
  - if: $CI_COMMIT_MESSAGE =~ /chore\(release\):/
59
61
  when: never
60
62
  - if: "$AUTO_DEVOPS_RELEASE_WHEN != 'manual'"
@@ -1,3 +1,4 @@
1
+ const { vscodeRecommendedExtension } = require('../core/vscode.js');
1
2
  const { commitlint } = require('../core/commitlint.js');
2
3
  const { hasGit } = require('../core/git.js');
3
4
 
@@ -21,6 +22,8 @@ function createCommitLint({ commitLintPreset: commitLintPresetDefault }) {
21
22
  preset: commitLintPreset,
22
23
  state: gitPresent ? 'present' : 'absent',
23
24
  });
25
+
26
+ vscodeRecommendedExtension(['seatonjiang.gitmoji-vscode']);
24
27
  }
25
28
 
26
29
  task.description = 'Setup CommitLint';
package/config.json CHANGED
@@ -4,6 +4,7 @@
4
4
  "gitignore",
5
5
  "project",
6
6
  "contributing",
7
+ "license",
7
8
  "release",
8
9
  "ci",
9
10
  "lang",
package/core/eslint.js CHANGED
@@ -13,7 +13,7 @@ function eslintConfig({ state, update }) {
13
13
  const packageFile = packageJson();
14
14
 
15
15
  jsonFile.value(packageFile, {
16
- path: undefined,
16
+ path: 'eslintConfig',
17
17
  state,
18
18
  // @ts-ignore
19
19
  update,
package/core/git.js CHANGED
@@ -7,24 +7,8 @@ const block = require('./block.js');
7
7
  function remoteSync() {
8
8
  try {
9
9
  const gitConfig = ini('.git/config');
10
- const remoteURL = gitConfig.get('[remote "origin"]').url;
11
-
12
- return remoteURL
13
- ? [
14
- /**
15
- * 1. filter github URL
16
- *
17
- * @param {string} returnValue
18
- */
19
- (returnValue) => returnValue.replace(/^git@github.com:/, 'https://github.com/'),
20
- /**
21
- * 2. filter gitlab URL
22
- *
23
- * @param {string} returnValue
24
- */
25
- (returnValue) => returnValue.replace(/^git@gitlab.com:/, 'https://gitlab.com/'),
26
- ].reduce((returnValue, filter) => filter(returnValue), remoteURL)
27
- : remoteURL;
10
+ const remoteURL = gitConfig.get('remote "origin"').url.trim();
11
+ return remoteURL;
28
12
  } catch {
29
13
  // ignore error
30
14
  }
package/core/jsonFile.js CHANGED
@@ -41,16 +41,17 @@ function setValue(jsonFile, path, pathValue) {
41
41
  */
42
42
  function value(jsonFile, { state, path, default: defaultValue, update: nextValue }) {
43
43
  if (state === 'present') {
44
- if (nextValue != null) {
45
- const resolvedValue = typeof nextValue === 'function' ? nextValue(getValue(jsonFile, path)) : nextValue;
46
- if (resolvedValue != null) {
47
- setValue(jsonFile, path, resolvedValue);
44
+ let currentValue = getValue(jsonFile, path);
45
+
46
+ if (currentValue == null) {
47
+ currentValue = typeof defaultValue === 'function' ? defaultValue() : defaultValue;
48
+ if (currentValue != null) {
49
+ setValue(jsonFile, path, currentValue);
48
50
  }
49
51
  }
50
52
 
51
- const currentValue = getValue(jsonFile, path);
52
- if (currentValue == null) {
53
- const resolvedValue = typeof defaultValue === 'function' ? defaultValue() : defaultValue;
53
+ if (nextValue != null) {
54
+ const resolvedValue = typeof nextValue === 'function' ? nextValue(getValue(jsonFile, path)) : nextValue;
54
55
  if (resolvedValue != null) {
55
56
  setValue(jsonFile, path, resolvedValue);
56
57
  }
package/core/pkg.js CHANGED
@@ -13,6 +13,21 @@ const jsonFile = require('./jsonFile.js');
13
13
  */
14
14
  const emptyScript = ':';
15
15
 
16
+ /**
17
+ * @param {import('mrm-core').Json} packageFile
18
+ * @returns {'application'|'library'|'workspace'} the archetype value
19
+ */
20
+ function archetype(packageFile) {
21
+ if (hasWorkspaces(packageFile)) {
22
+ return 'workspace';
23
+ }
24
+ if (packageFile.get('private') === true || (packageFile.get('main') == null && packageFile.get('exports'))) {
25
+ return 'application';
26
+ }
27
+
28
+ return 'library';
29
+ }
30
+
16
31
  /**
17
32
  * @param {(pkg: import('mrm-core').PackageJson) => void} block
18
33
  */
@@ -93,7 +108,7 @@ function manager(packageFile) {
93
108
 
94
109
  /**
95
110
  *
96
- * @param {import('mrm-core').PackageJson} packageFile
111
+ * @param {import('mrm-core').Json} packageFile
97
112
  */
98
113
  function hasWorkspaces(packageFile) {
99
114
  return Boolean(packageFile.get('workspaces'));
@@ -143,11 +158,13 @@ function engineMinVersion(packageFile, engineVersionMap) {
143
158
  Object.keys(engineVersionMap).map((engineName) => [engineName, engineConstraint(engineName)])
144
159
  ),
145
160
  });
161
+ return packageFile.get('engines');
146
162
  }
147
163
 
148
164
  module.exports = {
149
165
  ...jsonFile,
150
166
  emptyScript,
167
+ archetype,
151
168
  script,
152
169
  manager,
153
170
  engineMinVersion,
package/core/turbo.js CHANGED
@@ -6,6 +6,7 @@ const jsonFile = require('./jsonFile.js');
6
6
  /**
7
7
  * @typedef {{
8
8
  * $schema: string,
9
+ * baseBranch?: string,
9
10
  * pipeline?: Record<string, unknown>,
10
11
  * globalDependencies?: Array<string>,
11
12
  * }} TurboConfig
package/eslint/index.js CHANGED
@@ -11,10 +11,9 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
11
11
  *
12
12
  * @param {{
13
13
  * eslintPreset: string,
14
- * eslintRules: Record<string, any>
15
14
  * }} config
16
15
  */
17
- function task({ eslintPreset, eslintRules }) {
16
+ function task({ eslintPreset }) {
18
17
  const packageFileDefault = packageJson();
19
18
  const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
20
19
  const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
@@ -59,7 +58,6 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
59
58
  update: (config) => ({
60
59
  ...config,
61
60
  extends: [eslintPreset],
62
- rules: eslintRules,
63
61
  parserOptions: {
64
62
  project: hasTypescript ? './tsconfig.json' : undefined,
65
63
  ...config.parserOptions,
@@ -121,13 +119,13 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
121
119
  });
122
120
  pkg.forEachWorkspace(({ packageFile }) => {
123
121
  pkg.script(packageFile, {
124
- name: project.lint,
122
+ name: `${project.lint}:src`,
125
123
  script: `eslint .${extOption}`,
126
124
  state: 'default',
127
125
  });
128
126
  pkg.script(packageFile, {
129
- name: project.format,
130
- script: `eslint . -fix${extOption}`,
127
+ name: `${project.format}:src`,
128
+ script: `eslint . --fix${extOption}`,
131
129
  state: 'default',
132
130
  });
133
131
  });
@@ -166,9 +164,6 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
166
164
  message: 'Enter ESLint preset name',
167
165
  type: 'input',
168
166
  },
169
- eslintRules: {
170
- type: 'config',
171
- },
172
167
  };
173
168
 
174
169
  return task;
package/lang/index.js CHANGED
@@ -27,7 +27,7 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
27
27
  task.typescript = () => {
28
28
  const tsConfigPreset = tsConfigDefault;
29
29
  const packageFile = packageJson();
30
- const isApplication = packageFile.get('mrmConfig.packageArchetype') === 'application';
30
+ const isApplication = pkg.archetype(packageFile) === 'application';
31
31
  const hasWorkspaces = pkg.hasWorkspaces(packageFile);
32
32
  const tsConfigSettingsName = 'tsconfig.settings.json';
33
33
  const tsConfigSettings = json(tsConfigSettingsName);
@@ -44,7 +44,7 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
44
44
  .unset('compilerOptions.outDir')
45
45
  .unset('include')
46
46
  .merge({
47
- $schema: 'https://json.schemastore.org/tsconfig',
47
+ $schema: 'https://json.schemastore.org/tsconfig.json',
48
48
  extends: `./${tsConfigSettingsName}`,
49
49
  })
50
50
  .save();
@@ -54,7 +54,7 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
54
54
  } else {
55
55
  tsConfigSettings
56
56
  .merge({
57
- $schema: 'https://json.schemastore.org/tsconfig',
57
+ $schema: 'https://json.schemastore.org/tsconfig.json',
58
58
  compilerOptions: {},
59
59
  extends: tsConfigPreset,
60
60
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@w5s/mrm-preset",
3
- "version": "1.0.0-alpha.16",
3
+ "version": "1.0.0-alpha.19",
4
4
  "description": "Mrm configuration presets",
5
5
  "keywords": [
6
6
  "mrm",
@@ -13,19 +13,23 @@
13
13
  },
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/w5s/project-config.git",
16
+ "url": "git@github.com:w5s/project-config.git",
17
17
  "directory": "packages/mrm-preset"
18
18
  },
19
19
  "license": "MIT",
20
20
  "author": "Julien Polo <julien.polo@gmail.com>",
21
21
  "main": "config.json",
22
22
  "scripts": {
23
- "build": "npm-run-all -p 'build:*'",
23
+ "build": "concurrently \"npm:build:*\" ",
24
24
  "build:empty": ":",
25
25
  "build:tsc": "tsc --noEmit --skipLibCheck",
26
+ "clean": "concurrently \"npm:clean:*\" \":\"",
26
27
  "docs": "md-magic --path '**/*.md' --ignore='node_modules'",
27
- "format": "eslint . --fix --ext=mjs,cjs,js,jsx,ts,tsx,json",
28
- "lint": "eslint . --ext=mjs,cjs,js,jsx,ts,tsx,json",
28
+ "format": "concurrently \"npm:format:*\" \":\"",
29
+ "format:src": "eslint . --fix --ext=mjs,cjs,js,jsx,ts,tsx,json",
30
+ "lint": "concurrently \"npm:lint:*\" \":\"",
31
+ "lint:src": "eslint . --ext=mjs,cjs,js,jsx,ts,tsx,json",
32
+ "prepare": "concurrently \"npm:prepare:*\" \":\"",
29
33
  "spellcheck": "cspell --no-progress '**'",
30
34
  "test": "mkdir _tester; cd _tester; mrm bootstrap --dir ..; mrm configure --dir .."
31
35
  },
@@ -41,11 +45,11 @@
41
45
  "mrm": "4.0.0"
42
46
  },
43
47
  "engines": {
44
- "node": ">=14.x",
48
+ "node": ">=16.x",
45
49
  "yarn": ">=1.x"
46
50
  },
47
51
  "publishConfig": {
48
52
  "access": "public"
49
53
  },
50
- "gitHead": "62fbe27f3993161ce5bfd3a01f5f49cee505b009"
54
+ "gitHead": "f83a12bd102dc01498ec2ea00344a0fef14f9d69"
51
55
  }
package/project/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ const { dirname } = require('node:path');
1
2
  const { packageJson, json, makeDirs } = require('mrm-core');
2
3
  const git = require('../core/git.js');
3
4
  const pkg = require('../core/pkg.js');
@@ -29,185 +30,198 @@ const turboRun = (script) => `turbo run ${script}`;
29
30
  /**
30
31
  *
31
32
  * @param {string} script
33
+ * @param {boolean} allowEmpty
32
34
  */
33
- const npmRunAll = (script) => `npm-run-all -p "${script}:*"`;
35
+ const npmRunAll = (script, allowEmpty) => `concurrently "npm:${script}:*" ${allowEmpty ? `"${pkg.emptyScript}"` : ''}`;
34
36
  function task() {
35
- const packageFile = packageJson();
37
+ const rootPackageFile = packageJson();
38
+ const rootUseWorkspace = pkg.hasWorkspaces(rootPackageFile);
39
+ const rootEngineMinVersion = Object.assign(
40
+ {
41
+ node: '>=12.x',
42
+ yarn: '>=1.x',
43
+ npm: '>=6.x',
44
+ },
45
+ mrmPackageJson.engines
46
+ );
36
47
  const gitSupported = git.hasGit();
37
- const useWorkspace = packageFile.get('mrmConfig.packageArchetype') === 'workspace';
38
- const packageManager = pkg.manager(packageFile);
48
+ const packageManager = pkg.manager(rootPackageFile);
49
+ const gitRepository = git.remoteSync();
39
50
 
40
51
  // Detect git repository
41
- pkg.value(packageFile, {
42
- path: 'repository',
43
- state: 'present',
44
- update: () => {
45
- const gitRepository = git.remoteSync();
46
- if (gitRepository) {
47
- return {
48
- type: 'git',
49
- url: gitRepository,
50
- };
51
- }
52
+ if (rootUseWorkspace) {
53
+ const dirs = pkg.listWorkspaceMatchers(rootPackageFile).map(dirname);
54
+ makeDirs(dirs);
55
+ }
52
56
 
53
- return undefined;
54
- },
55
- });
57
+ const addScripts = (/** @type {import("mrm-core").Json} */ currentPackageFile, /** @type {boolean} */ root) => {
58
+ const useWorkspace = pkg.hasWorkspaces(currentPackageFile);
56
59
 
57
- // build & clean
58
- pkg.script(packageFile, {
59
- name: project.build,
60
- script: npmRunAll(project.build),
61
- state: 'present',
62
- });
63
- pkg.script(packageFile, {
64
- name: `${project.build}:empty`,
65
- script: pkg.emptyScript,
66
- state: !useWorkspace ? 'present' : 'absent',
67
- });
68
- pkg.script(packageFile, {
69
- name: `${project.build}:packages`,
70
- script: turboRun(project.build),
71
- state: useWorkspace ? 'present' : 'absent',
72
- });
73
- pkg.script(packageFile, {
74
- name: project.clean,
75
- script: useWorkspace ? turboRun(project.clean) : pkg.emptyScript,
76
- state: useWorkspace ? 'present' : 'default',
77
- });
60
+ // build
61
+ pkg.script(currentPackageFile, {
62
+ name: project.build,
63
+ script: npmRunAll(project.build, false),
64
+ state: 'present',
65
+ });
66
+ pkg.script(currentPackageFile, {
67
+ name: `${project.build}:packages`,
68
+ script: turboRun(project.build),
69
+ state: useWorkspace ? 'present' : 'absent',
70
+ });
78
71
 
79
- // develop & auto build & load
80
- pkg.script(packageFile, {
81
- name: project.develop,
82
- script: pkg.emptyScript,
83
- state: 'default',
84
- });
72
+ // lint
73
+ pkg.script(currentPackageFile, {
74
+ name: project.lint,
75
+ script: npmRunAll(project.lint, true),
76
+ state: 'present',
77
+ });
78
+ pkg.script(currentPackageFile, {
79
+ name: project.format,
80
+ script: npmRunAll(project.format, true),
81
+ state: 'present',
82
+ });
85
83
 
86
- // lint
87
- pkg.script(packageFile, {
88
- name: project.lint,
89
- script: npmRunAll(project.lint),
90
- state: 'present',
91
- });
92
- pkg.script(packageFile, {
93
- name: `${project.lint}:empty`,
94
- script: pkg.emptyScript,
95
- state: !useWorkspace ? 'present' : 'absent',
96
- });
97
- pkg.script(packageFile, {
98
- name: project.format,
99
- script: npmRunAll(project.format),
100
- state: 'present',
101
- });
102
- pkg.script(packageFile, {
103
- name: `${project.format}:empty`,
104
- script: pkg.emptyScript,
105
- state: !useWorkspace ? 'present' : 'absent',
106
- });
84
+ // test
85
+ // pkg.script(currentPackageFile, {
86
+ // name: project.coverage,
87
+ // script: pkg.emptyScript,
88
+ // state: 'default',
89
+ // });
90
+ pkg.script(currentPackageFile, {
91
+ name: project.test,
92
+ script: useWorkspace ? npmRunAll(project.test, false) : pkg.emptyScript,
93
+ state: useWorkspace ? 'present' : 'default',
94
+ });
107
95
 
108
- // test
109
- pkg.script(packageFile, {
110
- name: project.coverage,
111
- script: pkg.emptyScript,
112
- state: 'default',
113
- });
114
- pkg.script(packageFile, {
115
- name: project.test,
116
- script: npmRunAll(project.test),
117
- state: 'present',
118
- });
119
- pkg.script(packageFile, {
120
- name: project.validate,
121
- script: `${npmRun(project.build)} && ${npmRun(project.lint)} && ${npmRun(project.test)}`,
122
- state: 'present',
123
- });
96
+ // prepare
97
+ pkg.script(currentPackageFile, {
98
+ name: project.prepare,
99
+ script: npmRunAll(project.prepare, true),
100
+ state: 'present',
101
+ });
124
102
 
125
- // code analysis
126
- pkg.script(packageFile, {
127
- name: project.codeAnalysis,
128
- script: pkg.emptyScript,
129
- state: 'default',
130
- });
103
+ // clean
104
+ pkg.script(currentPackageFile, {
105
+ name: project.clean,
106
+ script: npmRunAll(project.clean, true),
107
+ state: 'present',
108
+ });
109
+ pkg.script(currentPackageFile, {
110
+ name: `${project.clean}:packages`,
111
+ script: turboRun(project.clean),
112
+ state: useWorkspace ? 'present' : 'absent',
113
+ });
131
114
 
132
- // prepare
133
- pkg.script(packageFile, {
134
- name: project.prepare,
135
- script: npmRunAll(project.prepare),
136
- state: 'present',
137
- });
138
- pkg.script(packageFile, {
139
- name: `${project.prepare}:empty`,
140
- script: !useWorkspace ? 'present' : 'absent',
141
- state: 'default',
142
- });
143
- pkg.script(packageFile, {
144
- name: `${project.prepare}:packages`,
145
- script: turboRun(project.prepare),
146
- state: useWorkspace ? 'present' : 'absent',
147
- });
115
+ // Root
148
116
 
149
- // rescue
150
- pkg.script(packageFile, {
151
- name: project.rescue,
152
- script: `${gitSupported ? 'git clean -fdx' : ''};${packageManager} install`,
153
- state: 'present',
154
- });
117
+ // rescue
118
+ pkg.script(currentPackageFile, {
119
+ name: project.rescue,
120
+ script: `${gitSupported ? 'git clean -fdx' : ''};${packageManager} install`,
121
+ state: root ? 'present' : 'absent',
122
+ });
123
+
124
+ // release
125
+ pkg.script(currentPackageFile, {
126
+ name: project.release,
127
+ script: pkg.emptyScript,
128
+ state: root ? 'default' : 'absent',
129
+ });
130
+
131
+ // code analysis
132
+ pkg.script(currentPackageFile, {
133
+ name: project.codeAnalysis,
134
+ script: pkg.emptyScript,
135
+ state: root ? 'default' : 'absent',
136
+ });
137
+
138
+ // develop & auto build & load
139
+ pkg.script(currentPackageFile, {
140
+ name: project.develop,
141
+ script: pkg.emptyScript,
142
+ state: root ? 'default' : 'absent',
143
+ });
144
+ };
155
145
 
156
- // release
157
- pkg.script(packageFile, {
158
- name: project.release,
159
- script: pkg.emptyScript,
160
- state: 'default',
146
+ // eslint-disable-next-line no-shadow
147
+ pkg.withPackageJson((packageFile) => {
148
+ pkg.value(packageFile, {
149
+ path: 'repository',
150
+ state: 'present',
151
+ update: () =>
152
+ gitRepository
153
+ ? {
154
+ type: 'git',
155
+ url: gitRepository,
156
+ }
157
+ : undefined,
158
+ });
159
+
160
+ addScripts(packageFile, true);
161
+
162
+ pkg.script(packageFile, {
163
+ name: project.validate,
164
+ script: `${npmRun(project.build)} && ${npmRun(project.lint)} && ${npmRun(project.test)}`,
165
+ state: 'present',
166
+ });
167
+
168
+ // Engine
169
+ pkg.engineMinVersion(packageFile, rootEngineMinVersion);
170
+ });
171
+ pkg.forEachWorkspace((workspace) => {
172
+ pkg.value(workspace.packageFile, {
173
+ path: 'repository',
174
+ state: 'present',
175
+ update: () =>
176
+ gitRepository
177
+ ? {
178
+ type: 'git',
179
+ url: gitRepository,
180
+ directory: workspace.projectDir,
181
+ }
182
+ : undefined,
183
+ });
184
+ addScripts(workspace.packageFile, false);
161
185
  });
162
186
 
163
187
  // workspace
164
-
165
188
  const lernaConfig = json('lerna.json', {
166
- version: packageFile.get('version'),
189
+ version: rootPackageFile.get('version'),
167
190
  });
168
- if (useWorkspace) {
169
- const packages = ['packages/*'];
191
+ if (rootUseWorkspace) {
170
192
  const versionIndependent = lernaConfig.get('version') === 'independent';
171
- packageFile.merge({ workspaces: { packages } });
193
+ const gitmoji = true;
194
+
172
195
  lernaConfig.merge({
196
+ $schema: 'https://json.schemastore.org/lerna.json',
173
197
  command: {
174
198
  publish: {
175
199
  conventionalCommits: true,
176
200
  npmClient: 'npm',
177
201
  },
178
202
  version: {
179
- message: `chore(release): publish${versionIndependent ? '' : ' %s'}`,
203
+ message: gitmoji
204
+ ? `🔖 Publish${versionIndependent ? '' : ' %s'}`
205
+ : `chore(release): publish${versionIndependent ? '' : ' %s'}`,
180
206
  },
181
207
  },
182
208
  npmClient: packageManager,
183
- useWorkspaces: useWorkspace,
209
+ useWorkspaces: rootUseWorkspace,
210
+ changelogPreset: 'gitmoji-config',
184
211
  });
185
212
  lernaConfig.save();
186
- makeDirs('packages');
187
213
  } else {
188
- packageFile.unset('workspaces');
189
214
  lernaConfig.delete();
190
215
  }
191
216
 
192
- // Engine
193
- pkg.engineMinVersion(
194
- packageFile,
195
- Object.assign(
196
- {
197
- node: '>=12.x',
198
- yarn: '>=1.x',
199
- npm: '>=6.x',
200
- },
201
- mrmPackageJson.engines
202
- )
203
- );
204
- packageFile.save();
217
+ rootPackageFile.save();
205
218
 
206
219
  // Turbo config
207
220
  turbo({
208
- state: useWorkspace ? 'present' : 'absent',
221
+ state: rootUseWorkspace ? 'present' : 'absent',
209
222
  update: (_) => ({
210
223
  ..._,
224
+ baseBranch: 'origin/main',
211
225
  pipeline: {
212
226
  [project.build]: {
213
227
  dependsOn: ['^build'],
@@ -231,15 +245,21 @@ function task() {
231
245
  });
232
246
 
233
247
  // Dependencies
248
+ // clean
234
249
  npm.dependency({
235
250
  dev: true,
236
251
  name: ['npm-run-all'],
252
+ state: 'absent',
253
+ });
254
+ npm.dependency({
255
+ dev: true,
256
+ name: ['concurrently'],
237
257
  state: 'present',
238
258
  });
239
259
  npm.dependency({
240
260
  dev: true,
241
- name: ['lerna'],
242
- state: useWorkspace ? 'present' : 'absent',
261
+ name: ['lerna', 'conventional-changelog-gitmoji-config'],
262
+ state: rootUseWorkspace ? 'present' : 'absent',
243
263
  });
244
264
 
245
265
  // VSCode
package/release/index.js CHANGED
@@ -4,7 +4,7 @@ const project = require('../core/project.js');
4
4
  const { semanticRelease } = require('../core/semanticRelease.js');
5
5
 
6
6
  function task() {
7
- const useWorkspace = packageJson().get('mrmConfig.packageArchetype') === 'workspace';
7
+ const useWorkspace = pkg.hasWorkspaces(packageJson());
8
8
 
9
9
  // release
10
10
  pkg.withPackageJson((packageFile) => {
package/renovate/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  const { json, packageJson } = require('mrm-core');
2
2
  const { hasGit } = require('../core/git.js');
3
+ const pkg = require('../core/pkg.js');
3
4
 
4
5
  /**
5
6
  *
@@ -19,7 +20,8 @@ function createRenovate({ renovatePresetApplication, renovatePresetLibrary }) {
19
20
  const gitSupported = hasGit();
20
21
 
21
22
  if (gitSupported) {
22
- const packageArchetype = packageJson().get('mrmConfig.packageArchetype', 'library');
23
+ const packageFile = packageJson();
24
+ const packageArchetype = pkg.archetype(packageFile);
23
25
  const renovatePresetResolved =
24
26
  renovatePreset || (packageArchetype === 'application' ? renovatePresetApplication : renovatePresetLibrary);
25
27
  const renovateFile = json('renovate.json');
package/tsconfig.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "$schema": "https://json.schemastore.org/tsconfig",
3
- "extends": "../../tsconfig.json",
2
+ "$schema": "https://json.schemastore.org/tsconfig.json",
3
+ "extends": "../../tsconfig.settings.json",
4
4
  "compilerOptions": {
5
5
  "allowJs": true,
6
6
  "checkJs": true,
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Julien Polo
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.