@w5s/mrm-preset 1.0.0-alpha.1 → 1.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/LICENSE +21 -0
- package/bootstrap/index.js +48 -38
- package/ci/gitlab.js +1 -3
- package/contributing/templates/CODE_OF_CONDUCT.md +3 -4
- package/core/block.js +2 -5
- package/{gitignore/template.js → core/git.ignore.js} +32 -6
- package/core/git.js +22 -15
- package/core/githooks.js +2 -1
- package/core/jest.js +2 -2
- package/core/npm.js +9 -7
- package/core/pkg.js +35 -4
- package/core/semanticRelease.js +1 -1
- package/core/typedoc.js +1 -1
- package/core/vscode.js +2 -8
- package/cspell/index.js +0 -11
- package/eslint/index.js +17 -18
- package/githooks/index.js +4 -3
- package/gitignore/index.js +4 -23
- package/lang/index.js +5 -5
- package/package.json +4 -3
- package/project/index.js +3 -6
- package/renovate/index.js +3 -5
- package/core/workspace.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,67 @@
|
|
|
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.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
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* change bootstrap behavior ([497c83a](https://github.com/w5s/project-config/commit/497c83a4082f7fd4e3b8b6913802ebcb21caa65a))
|
|
12
|
+
* remove lint-staged + cspell integration ([6747c83](https://github.com/w5s/project-config/commit/6747c83ec997034d25d136bc5aa008ed108ceb96))
|
|
13
|
+
* use UNLICENSED for default license ([608ee8f](https://github.com/w5s/project-config/commit/608ee8f0bf57fec94636587b116d5bda0fb4ee3f))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
* add gitignore for yarn v2 ([06c547a](https://github.com/w5s/project-config/commit/06c547a6b7813f935678c29b410aee62da5b3866))
|
|
19
|
+
* add support for yarn berry ([2b77669](https://github.com/w5s/project-config/commit/2b77669a29316825a38470c80a48aff8ab068f7f))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [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)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* correct eslint vscode settings ([a32e0fb](https://github.com/w5s/project-config/commit/a32e0fb739cbe349565b26ea412cdf37e3d56bdb))
|
|
31
|
+
* correct mrm preset url ([ad6f030](https://github.com/w5s/project-config/commit/ad6f03091e0a294c043974b564e24c79023e659b))
|
|
32
|
+
* correct typo ([2218859](https://github.com/w5s/project-config/commit/221885997fec37149f7e349b00a58fbcb3bfb8db))
|
|
33
|
+
* rollback to eslint.validate vscode setting ([769a2e1](https://github.com/w5s/project-config/commit/769a2e100083aca4f5e9037fa539fcf1f6002d65))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### Features
|
|
37
|
+
|
|
38
|
+
* improve typescript eslint configuration ([efc6f1c](https://github.com/w5s/project-config/commit/efc6f1cef876e8fc5d4d1d1b94ca90a6805fbbbf))
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
# [1.0.0-alpha.3](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.2...@w5s/mrm-preset@1.0.0-alpha.3) (2022-02-15)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
### Features
|
|
48
|
+
|
|
49
|
+
* use airbnb-base as default presets ([e499fc1](https://github.com/w5s/project-config/commit/e499fc115023571e749072db33d774b443b68bb7))
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
# [1.0.0-alpha.2](https://github.com/w5s/project-config/compare/@w5s/mrm-preset@1.0.0-alpha.1...@w5s/mrm-preset@1.0.0-alpha.2) (2022-02-15)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### Features
|
|
59
|
+
|
|
60
|
+
* enable source.fixAll for vscode ([d484156](https://github.com/w5s/project-config/commit/d484156c063f2bf9f5cb3212878aa07bb4f8fd6f))
|
|
61
|
+
* improve arrow-body-style configuration ([a4ee8a9](https://github.com/w5s/project-config/commit/a4ee8a9f3912285b45287afc4ccae2fa57431c6a))
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
6
67
|
# 1.0.0-alpha.1 (2022-02-12)
|
|
7
68
|
|
|
8
69
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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.
|
package/bootstrap/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/* eslint-disable sort-keys-fix/sort-keys-fix */
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const { packageJson, file } = require('mrm-core');
|
|
3
|
+
const { packageJson, file, yaml } = require('mrm-core');
|
|
4
|
+
// @ts-ignore
|
|
5
|
+
const execCommand = require('mrm-core/src/util/execCommand');
|
|
4
6
|
const npm = require('../core/npm');
|
|
5
7
|
const pkg = require('../core/pkg');
|
|
8
|
+
const { gitIgnoreTemplate } = require('../core/git');
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* @param {{
|
|
@@ -14,56 +17,63 @@ const pkg = require('../core/pkg');
|
|
|
14
17
|
* @returns {void}
|
|
15
18
|
*/
|
|
16
19
|
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;
|
|
17
26
|
/**
|
|
18
27
|
* setup package.json from following object
|
|
19
28
|
*/
|
|
20
29
|
|
|
21
|
-
|
|
30
|
+
packageJson({
|
|
22
31
|
name: path.basename(process.cwd()),
|
|
23
32
|
version: '1.0.0-alpha.0',
|
|
24
33
|
private: true,
|
|
25
|
-
license: '
|
|
34
|
+
license: 'UNLICENSED',
|
|
26
35
|
description: '',
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
}).save();
|
|
37
|
+
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
|
+
}
|
|
43
|
+
npm.dependency({
|
|
44
|
+
dev: true,
|
|
45
|
+
name: ['mrm', mrmPreset],
|
|
46
|
+
yarn: isYarn,
|
|
37
47
|
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
|
});
|
|
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
|
-
}
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
50
|
+
pkg.withPackageJson((packageFile) => {
|
|
51
|
+
// Add MRM default scripts
|
|
52
|
+
pkg.script(packageFile, {
|
|
53
|
+
name: 'configure',
|
|
54
|
+
state: 'default',
|
|
55
|
+
script: `${packageManager} run mrm -- ${mrmTask}`,
|
|
56
|
+
});
|
|
57
|
+
pkg.script(packageFile, {
|
|
58
|
+
name: 'mrm',
|
|
59
|
+
state: 'default',
|
|
60
|
+
script: `${packageManager} --preset ${mrmPreset}`,
|
|
61
|
+
});
|
|
59
62
|
});
|
|
60
|
-
packageFile.save();
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
pkg.withPackageJson((packageFile) => {
|
|
65
|
+
pkg.value(packageFile, {
|
|
66
|
+
path: 'mrmConfig.packageArchetype',
|
|
67
|
+
state: 'present',
|
|
68
|
+
update: packageArchetype,
|
|
69
|
+
default: () => {
|
|
70
|
+
if (file('lerna.json').exists() || Boolean(packageFile.get('workspaces'))) {
|
|
71
|
+
return 'workspace';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return 'library';
|
|
75
|
+
},
|
|
76
|
+
});
|
|
67
77
|
});
|
|
68
78
|
}
|
|
69
79
|
|
package/ci/gitlab.js
CHANGED
|
@@ -21,9 +21,7 @@ function task() {
|
|
|
21
21
|
/**
|
|
22
22
|
* @param {string|{local: string}} include
|
|
23
23
|
*/
|
|
24
|
-
(include) =>
|
|
25
|
-
return (typeof include === 'string' ? include : include.local) === includePath;
|
|
26
|
-
}
|
|
24
|
+
(include) => (typeof include === 'string' ? include : include.local) === includePath
|
|
27
25
|
);
|
|
28
26
|
const addInclude = (/** @type {string} */ includePath) =>
|
|
29
27
|
gitlabCIConfig.set('include', gitlabCIConfig.get('include', []).concat([{ local: includePath }]));
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
We as members, contributors, and leaders pledge to make participation in our
|
|
7
7
|
community a harassment-free experience for everyone, regardless of age, body
|
|
8
8
|
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
9
|
-
identity and expression, level of experience, education,
|
|
9
|
+
identity and expression, level of experience, education, socioeconomic status,
|
|
10
10
|
nationality, personal appearance, race, caste, color, religion, or sexual identity
|
|
11
11
|
and orientation.
|
|
12
12
|
|
|
@@ -119,11 +119,11 @@ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
|
119
119
|
version 2.0, available at
|
|
120
120
|
[https://www.contributor-covenant.org/version/2/0/code_of_conduct.html][v2.0].
|
|
121
121
|
|
|
122
|
-
Community Impact Guidelines were inspired by
|
|
122
|
+
Community Impact Guidelines were inspired by
|
|
123
123
|
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
124
124
|
|
|
125
125
|
For answers to common questions about this code of conduct, see the FAQ at
|
|
126
|
-
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
|
126
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available
|
|
127
127
|
at [https://www.contributor-covenant.org/translations][translations].
|
|
128
128
|
|
|
129
129
|
[homepage]: https://www.contributor-covenant.org
|
|
@@ -131,4 +131,3 @@ at [https://www.contributor-covenant.org/translations][translations].
|
|
|
131
131
|
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
132
132
|
[FAQ]: https://www.contributor-covenant.org/faq
|
|
133
133
|
[translations]: https://www.contributor-covenant.org/translations
|
|
134
|
-
|
package/core/block.js
CHANGED
|
@@ -20,13 +20,10 @@ const { file } = require('mrm-core');
|
|
|
20
20
|
function block({
|
|
21
21
|
markerBegin = 'BEGIN',
|
|
22
22
|
markerEnd = 'END',
|
|
23
|
-
marker = (mark) => {
|
|
24
|
-
return `# ${mark} generated by mrm`;
|
|
25
|
-
},
|
|
23
|
+
marker = (mark) => `# ${mark} generated by mrm`,
|
|
26
24
|
path,
|
|
27
25
|
block: blockName,
|
|
28
|
-
//
|
|
29
|
-
insertBefore = 'begin',
|
|
26
|
+
// insertBefore = 'begin',
|
|
30
27
|
insertAfter,
|
|
31
28
|
}) {
|
|
32
29
|
const EOL = '\n';
|
|
@@ -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
|
-
#
|
|
51
|
-
|
|
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
|
|
81
|
+
# dotenv environment variable files
|
|
78
82
|
.env
|
|
79
|
-
.env.
|
|
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
|
@@ -15,19 +15,13 @@ function remoteSync() {
|
|
|
15
15
|
* 1. filter github URL
|
|
16
16
|
* @param {string} returnValue
|
|
17
17
|
*/
|
|
18
|
-
(returnValue) =>
|
|
19
|
-
return returnValue.replace(/^git@github.com:/, 'https://github.com/');
|
|
20
|
-
},
|
|
18
|
+
(returnValue) => returnValue.replace(/^git@github.com:/, 'https://github.com/'),
|
|
21
19
|
/**
|
|
22
20
|
* 2. filter gitlab URL
|
|
23
21
|
* @param {string} returnValue
|
|
24
22
|
*/
|
|
25
|
-
(returnValue) =>
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
].reduce((returnValue, filter) => {
|
|
29
|
-
return filter(returnValue);
|
|
30
|
-
}, remoteURL)
|
|
23
|
+
(returnValue) => returnValue.replace(/^git@gitlab.com:/, 'https://gitlab.com/'),
|
|
24
|
+
].reduce((returnValue, filter) => filter(returnValue), remoteURL)
|
|
31
25
|
: remoteURL;
|
|
32
26
|
} catch (error) {
|
|
33
27
|
// ignore error
|
|
@@ -48,9 +42,7 @@ exports.hasGit = hasGit;
|
|
|
48
42
|
function trimStartLine(content) {
|
|
49
43
|
return content
|
|
50
44
|
.split(/\n/)
|
|
51
|
-
.map((line) =>
|
|
52
|
-
return line.replace(/^\s+/, '');
|
|
53
|
-
})
|
|
45
|
+
.map((line) => line.replace(/^\s+/, ''))
|
|
54
46
|
.filter((_) => _.length > 0)
|
|
55
47
|
.join('\n');
|
|
56
48
|
}
|
|
@@ -64,10 +56,25 @@ function gitIgnore(section, sectionContent) {
|
|
|
64
56
|
|
|
65
57
|
return block({
|
|
66
58
|
block: Array.isArray(sectionContent) ? sectionContent.join(EOL) : trimStartLine(sectionContent),
|
|
67
|
-
marker: (mark) => {
|
|
68
|
-
return `# ${mark} ### ${section} ###`;
|
|
69
|
-
},
|
|
59
|
+
marker: (mark) => `# ${mark} ### ${section} ###`,
|
|
70
60
|
path: '.gitignore',
|
|
71
61
|
});
|
|
72
62
|
}
|
|
73
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/githooks.js
CHANGED
|
@@ -44,7 +44,8 @@ function husky({ state }) {
|
|
|
44
44
|
* }} options
|
|
45
45
|
*/
|
|
46
46
|
function gitHook({ name, state, content }) {
|
|
47
|
-
const
|
|
47
|
+
const packageFileDefault = packageJson();
|
|
48
|
+
const hasHusky = pkg.hasDependency(packageFileDefault, 'husky', 'dev');
|
|
48
49
|
const hasGitHook = hasHusky && state === 'present';
|
|
49
50
|
const hookDirectory = '.husky';
|
|
50
51
|
const hookFileName = path.join(hookDirectory, name);
|
package/core/jest.js
CHANGED
|
@@ -13,8 +13,8 @@ const project = require('./project');
|
|
|
13
13
|
function jest({ state }) {
|
|
14
14
|
const packageFileDefault = packageJson();
|
|
15
15
|
const hasJest = state === 'present';
|
|
16
|
-
const hasTypescript =
|
|
17
|
-
const hasWorkspaces =
|
|
16
|
+
const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
|
|
17
|
+
const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
|
|
18
18
|
|
|
19
19
|
pkg.withPackageJson((packageFile) => {
|
|
20
20
|
if (hasJest) {
|
package/core/npm.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable default-param-last */
|
|
2
|
+
/* eslint-disable no-use-before-define */
|
|
1
3
|
/* eslint-disable import/no-extraneous-dependencies */
|
|
2
4
|
/* cSpell: disable */
|
|
3
5
|
// @ts-check
|
|
@@ -72,9 +74,7 @@ function install(deps, options = {}, exec) {
|
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
log.info(`Installing ${listify(newDeps)}...`);
|
|
75
|
-
const versionedDeps = newDeps.map((dep) =>
|
|
76
|
-
return getVersionedDep(dep, versions);
|
|
77
|
-
});
|
|
77
|
+
const versionedDeps = newDeps.map((dep) => getVersionedDep(dep, versions));
|
|
78
78
|
|
|
79
79
|
// eslint-disable-next-line consistent-return
|
|
80
80
|
return run(versionedDeps, { dev }, exec);
|
|
@@ -96,9 +96,7 @@ function uninstall(deps, options = {}, exec) {
|
|
|
96
96
|
const installed = getOwnDependencies({ dev });
|
|
97
97
|
|
|
98
98
|
// @ts-ignore
|
|
99
|
-
const newDeps = deps.filter((dep) =>
|
|
100
|
-
return installed[dep];
|
|
101
|
-
});
|
|
99
|
+
const newDeps = deps.filter((dep) => installed[dep]);
|
|
102
100
|
|
|
103
101
|
if (newDeps.length === 0) {
|
|
104
102
|
return;
|
|
@@ -136,7 +134,7 @@ function runNpm(deps, options = {}, exec) {
|
|
|
136
134
|
function runYarn(deps, options = {}, exec) {
|
|
137
135
|
const add = options.dev ? ['add', '--dev'] : ['add'];
|
|
138
136
|
const remove = ['remove'];
|
|
139
|
-
const args = (options.remove ? remove : add).concat(isUsingWorkspaces() ? ['-W'] : []).concat(deps);
|
|
137
|
+
const args = (options.remove ? remove : add).concat(isUsingWorkspaces() && !isYarnBerry() ? ['-W'] : []).concat(deps);
|
|
140
138
|
|
|
141
139
|
return execCommand(exec, 'yarn', args, {
|
|
142
140
|
cwd: options.cwd,
|
|
@@ -250,6 +248,10 @@ function isUsingWorkspaces() {
|
|
|
250
248
|
return Boolean(packageJson().get('workspaces'));
|
|
251
249
|
}
|
|
252
250
|
|
|
251
|
+
function isYarnBerry() {
|
|
252
|
+
return fs.existsSync('.yarnrc.yml');
|
|
253
|
+
}
|
|
254
|
+
|
|
253
255
|
/**
|
|
254
256
|
* @param {{
|
|
255
257
|
* name: string|string[]|Record<string, string>,
|
package/core/pkg.js
CHANGED
|
@@ -58,6 +58,34 @@ function manager(packageFile) {
|
|
|
58
58
|
return defaultManager;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {import('mrm-core').PackageJson} packageFile
|
|
64
|
+
*/
|
|
65
|
+
function hasWorkspaces(packageFile) {
|
|
66
|
+
return Boolean(packageFile.get('workspaces'));
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
*
|
|
71
|
+
* @param {import('mrm-core').PackageJson} packageFile
|
|
72
|
+
* @param {string} packageName
|
|
73
|
+
* @param {'normal'|'dev'|'peer'=} dependencyType
|
|
74
|
+
*/
|
|
75
|
+
function hasDependency(packageFile, packageName, dependencyType) {
|
|
76
|
+
return Boolean(
|
|
77
|
+
packageFile.get(
|
|
78
|
+
`${
|
|
79
|
+
dependencyType == null || dependencyType === 'normal'
|
|
80
|
+
? 'dependencies'
|
|
81
|
+
: dependencyType === 'dev'
|
|
82
|
+
? 'devDependencies'
|
|
83
|
+
: 'peerDependencies'
|
|
84
|
+
}.${packageName}`
|
|
85
|
+
)
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
61
89
|
/**
|
|
62
90
|
*
|
|
63
91
|
* @param {import('mrm-core').PackageJson} packageFile
|
|
@@ -78,12 +106,13 @@ function engineMinVersion(packageFile, engineVersionMap) {
|
|
|
78
106
|
};
|
|
79
107
|
|
|
80
108
|
packageFile.merge({
|
|
81
|
-
engines: Object.keys(engineVersionMap).reduce(
|
|
82
|
-
|
|
109
|
+
engines: Object.keys(engineVersionMap).reduce(
|
|
110
|
+
(acc, engineName) => ({
|
|
83
111
|
...acc,
|
|
84
112
|
[engineName]: engineConstraint(engineName),
|
|
85
|
-
}
|
|
86
|
-
|
|
113
|
+
}),
|
|
114
|
+
{}
|
|
115
|
+
),
|
|
87
116
|
});
|
|
88
117
|
}
|
|
89
118
|
|
|
@@ -93,5 +122,7 @@ module.exports = {
|
|
|
93
122
|
script,
|
|
94
123
|
manager,
|
|
95
124
|
engineMinVersion,
|
|
125
|
+
hasDependency,
|
|
126
|
+
hasWorkspaces,
|
|
96
127
|
withPackageJson,
|
|
97
128
|
};
|
package/core/semanticRelease.js
CHANGED
package/core/typedoc.js
CHANGED
|
@@ -23,7 +23,7 @@ const jsonFile = require('./jsonFile');
|
|
|
23
23
|
*/
|
|
24
24
|
function typedoc({ state, update }) {
|
|
25
25
|
const packageFileDefault = packageJson();
|
|
26
|
-
const hasWorkspaces =
|
|
26
|
+
const hasWorkspaces = pkg.hasWorkspaces(packageFileDefault);
|
|
27
27
|
const hasTypedoc = state === 'present';
|
|
28
28
|
|
|
29
29
|
pkg.withPackageJson((packageFile) => {
|
package/core/vscode.js
CHANGED
|
@@ -31,16 +31,10 @@ function vscodeTask(newTask) {
|
|
|
31
31
|
* @type {Array<any>}
|
|
32
32
|
*/
|
|
33
33
|
const tasks = vscodeTaskFile.get('tasks', []);
|
|
34
|
-
if (
|
|
35
|
-
tasks.find((task) => {
|
|
36
|
-
return task.script === newTask.script;
|
|
37
|
-
})
|
|
38
|
-
) {
|
|
34
|
+
if (tasks.find((task) => task.script === newTask.script)) {
|
|
39
35
|
vscodeTaskFile.set(
|
|
40
36
|
'tasks',
|
|
41
|
-
tasks.map((task) =>
|
|
42
|
-
return task.script === newTask.script ? newTask : task;
|
|
43
|
-
})
|
|
37
|
+
tasks.map((task) => (task.script === newTask.script ? newTask : task))
|
|
44
38
|
);
|
|
45
39
|
} else {
|
|
46
40
|
vscodeTaskFile.set('tasks', [newTask].concat(tasks));
|
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
|
@@ -15,7 +15,8 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
|
|
|
15
15
|
* }} config
|
|
16
16
|
*/
|
|
17
17
|
function task({ eslintPreset, eslintRules }) {
|
|
18
|
-
const
|
|
18
|
+
const packageFileDefault = packageJson();
|
|
19
|
+
const hasTypescript = pkg.hasDependency(packageFileDefault, 'typescript', 'dev');
|
|
19
20
|
const hasJSX = true;
|
|
20
21
|
const hasJSON = true;
|
|
21
22
|
|
|
@@ -87,23 +88,21 @@ function createESLint({ eslintPreset: eslintPresetDefault = 'eslint:recommended'
|
|
|
87
88
|
// VSCode support
|
|
88
89
|
vscodeSettings({
|
|
89
90
|
state: 'present',
|
|
90
|
-
update: (settings) => {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
'
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
106
|
-
},
|
|
91
|
+
update: (settings) => ({
|
|
92
|
+
...settings,
|
|
93
|
+
'editor.codeActionsOnSave': settings['editor.codeActionsOnSave'] || {
|
|
94
|
+
'source.fixAll': true,
|
|
95
|
+
},
|
|
96
|
+
'eslint.validate': extList.map(
|
|
97
|
+
(ext) =>
|
|
98
|
+
({
|
|
99
|
+
jsx: 'javascriptreact',
|
|
100
|
+
js: 'javascript',
|
|
101
|
+
tsx: 'typescriptreact',
|
|
102
|
+
ts: 'typescript',
|
|
103
|
+
}[ext] || ext)
|
|
104
|
+
),
|
|
105
|
+
}),
|
|
107
106
|
});
|
|
108
107
|
}
|
|
109
108
|
|
package/githooks/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const { packageJson, template } = require('mrm-core');
|
|
3
3
|
const project = require('../core/project');
|
|
4
|
+
const pkg = require('../core/pkg');
|
|
4
5
|
const { hasGit } = require('../core/git');
|
|
5
6
|
const { gitHook, husky } = require('../core/githooks');
|
|
6
7
|
const { lintStaged } = require('../core/lintStaged');
|
|
@@ -10,9 +11,9 @@ function createGitHooks() {
|
|
|
10
11
|
function task() {
|
|
11
12
|
const gitSupported = hasGit();
|
|
12
13
|
const packageFile = packageJson();
|
|
13
|
-
const hasESLint =
|
|
14
|
-
const hasJest =
|
|
15
|
-
const hasTsc =
|
|
14
|
+
const hasESLint = pkg.hasDependency(packageFile, 'eslint', 'dev');
|
|
15
|
+
const hasJest = pkg.hasDependency(packageFile, 'jest', 'dev');
|
|
16
|
+
const hasTsc = pkg.hasDependency(packageFile, 'typescript', 'dev');
|
|
16
17
|
|
|
17
18
|
husky({
|
|
18
19
|
state: gitSupported ? 'present' : 'absent',
|
package/gitignore/index.js
CHANGED
|
@@ -1,25 +1,6 @@
|
|
|
1
|
-
const {
|
|
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
|
}
|
|
24
|
-
|
|
25
|
-
module.exports = createGitIgnore(require.resolve('./template'), ['macOS', 'NodeJS', 'VisualStudioCode']);
|
|
6
|
+
task.description = 'Adds Gitignore file';
|
package/lang/index.js
CHANGED
|
@@ -4,7 +4,6 @@ const npm = require('../core/npm');
|
|
|
4
4
|
const { gitIgnore } = require('../core/git');
|
|
5
5
|
const project = require('../core/project');
|
|
6
6
|
const { eslintIgnore } = require('../core/eslint');
|
|
7
|
-
const { useWorkspaces } = require('../core/workspace');
|
|
8
7
|
const { typedoc } = require('../core/typedoc');
|
|
9
8
|
const pkg = require('../core/pkg');
|
|
10
9
|
|
|
@@ -27,8 +26,9 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
|
|
|
27
26
|
}
|
|
28
27
|
task.typescript = () => {
|
|
29
28
|
const tsConfigPreset = tsConfigDefault;
|
|
30
|
-
const
|
|
31
|
-
const
|
|
29
|
+
const packageFile = packageJson();
|
|
30
|
+
const isApplication = packageFile.get('mrmConfig.packageArchetype') === 'application';
|
|
31
|
+
const hasWorkspaces = pkg.hasWorkspaces(packageFile);
|
|
32
32
|
const tsConfigSettingsName = 'tsconfig.settings.json';
|
|
33
33
|
const tsConfigSettings = json(tsConfigSettingsName);
|
|
34
34
|
const tsConfig = json('tsconfig.json');
|
|
@@ -77,9 +77,9 @@ function createLang({ language: languageDefault = 'typescript', tsConfig: tsConf
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
// Application setup
|
|
80
|
-
pkg.withPackageJson((
|
|
80
|
+
pkg.withPackageJson((_packageFile) => {
|
|
81
81
|
if (isApplication) {
|
|
82
|
-
pkg.script(
|
|
82
|
+
pkg.script(_packageFile, {
|
|
83
83
|
name: project.develop,
|
|
84
84
|
script:
|
|
85
85
|
"NODE_ENV=development ts-node-dev --require='tsconfig-paths/register' -r dotenv/config -- ./src/index.ts dotenv_config_path=.env",
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@w5s/mrm-preset",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.5",
|
|
4
4
|
"description": "Mrm configuration presets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mrm",
|
|
7
7
|
"config",
|
|
8
8
|
"bootstrap"
|
|
9
9
|
],
|
|
10
|
-
"homepage": "https://github.com/w5s/project-config/blob/
|
|
10
|
+
"homepage": "https://github.com/w5s/project-config/blob/main/packages/mrm-preset#readme",
|
|
11
11
|
"bugs": {
|
|
12
12
|
"url": "https://github.com/w5s/project-config.git/issues"
|
|
13
13
|
},
|
|
@@ -44,5 +44,6 @@
|
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
|
-
}
|
|
47
|
+
},
|
|
48
|
+
"gitHead": "17d00b3e9ba103fd053aed2c06535d0b1526886a"
|
|
48
49
|
}
|
package/project/index.js
CHANGED
|
@@ -29,16 +29,13 @@ function task() {
|
|
|
29
29
|
*
|
|
30
30
|
* @param {string} script
|
|
31
31
|
*/
|
|
32
|
-
const lernaRun = (script) => {
|
|
33
|
-
|
|
34
|
-
};
|
|
32
|
+
const lernaRun = (script) => `lerna run ${script}`;
|
|
33
|
+
|
|
35
34
|
/**
|
|
36
35
|
*
|
|
37
36
|
* @param {string} script
|
|
38
37
|
*/
|
|
39
|
-
const npmRunAll = (script) => {
|
|
40
|
-
return `npm-run-all -p "${script}:*"`;
|
|
41
|
-
};
|
|
38
|
+
const npmRunAll = (script) => `npm-run-all -p "${script}:*"`;
|
|
42
39
|
|
|
43
40
|
// Detect git repository
|
|
44
41
|
pkg.value(packageFile, {
|
package/renovate/index.js
CHANGED
|
@@ -34,9 +34,7 @@ function createRenovate({ renovatePresetApplication, renovatePresetLibrary }) {
|
|
|
34
34
|
/**
|
|
35
35
|
* @param {string} extension
|
|
36
36
|
*/
|
|
37
|
-
(extension) =>
|
|
38
|
-
return extension !== renovatePresetApplication && extension !== renovatePresetLibrary;
|
|
39
|
-
}
|
|
37
|
+
(extension) => extension !== renovatePresetApplication && extension !== renovatePresetLibrary
|
|
40
38
|
)
|
|
41
39
|
)
|
|
42
40
|
);
|
|
@@ -56,6 +54,6 @@ function createRenovate({ renovatePresetApplication, renovatePresetLibrary }) {
|
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
module.exports = createRenovate({
|
|
59
|
-
renovatePresetApplication: '
|
|
60
|
-
renovatePresetLibrary: '
|
|
57
|
+
renovatePresetApplication: 'github>w5s/renovate-config:application',
|
|
58
|
+
renovatePresetLibrary: 'github>w5s/renovate-config:library',
|
|
61
59
|
});
|