@w5s/mrm-preset 1.0.0-alpha.4 → 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 +19 -0
- package/bootstrap/index.js +48 -38
- package/{gitignore/template.js → core/git.ignore.js} +32 -6
- package/core/git.js +17 -0
- package/core/npm.js +5 -1
- package/cspell/index.js +0 -11
- package/gitignore/index.js +4 -23
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
26
|
|
|
8
27
|
|
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
|
|
|
@@ -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
|
@@ -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/npm.js
CHANGED
|
@@ -134,7 +134,7 @@ function runNpm(deps, options = {}, exec) {
|
|
|
134
134
|
function runYarn(deps, options = {}, exec) {
|
|
135
135
|
const add = options.dev ? ['add', '--dev'] : ['add'];
|
|
136
136
|
const remove = ['remove'];
|
|
137
|
-
const args = (options.remove ? remove : add).concat(isUsingWorkspaces() ? ['-W'] : []).concat(deps);
|
|
137
|
+
const args = (options.remove ? remove : add).concat(isUsingWorkspaces() && !isYarnBerry() ? ['-W'] : []).concat(deps);
|
|
138
138
|
|
|
139
139
|
return execCommand(exec, 'yarn', args, {
|
|
140
140
|
cwd: options.cwd,
|
|
@@ -248,6 +248,10 @@ function isUsingWorkspaces() {
|
|
|
248
248
|
return Boolean(packageJson().get('workspaces'));
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
function isYarnBerry() {
|
|
252
|
+
return fs.existsSync('.yarnrc.yml');
|
|
253
|
+
}
|
|
254
|
+
|
|
251
255
|
/**
|
|
252
256
|
* @param {{
|
|
253
257
|
* name: string|string[]|Record<string, string>,
|
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/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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "17d00b3e9ba103fd053aed2c06535d0b1526886a"
|
|
49
49
|
}
|