@modern-js/new-action 1.1.0 → 1.1.4
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 +22 -69
- package/dist/js/modern/index.js +1 -0
- package/dist/js/modern/module.js +13 -13
- package/dist/js/modern/monorepo.js +3 -3
- package/dist/js/modern/mwa.js +10 -10
- package/dist/js/modern/utils/index.js +5 -5
- package/dist/js/node/index.js +13 -0
- package/dist/js/node/module.js +13 -13
- package/dist/js/node/monorepo.js +3 -3
- package/dist/js/node/mwa.js +10 -10
- package/dist/js/node/utils/index.js +5 -5
- package/dist/types/index.d.ts +1 -0
- package/dist/types/module.d.ts +1 -1
- package/dist/types/monorepo.d.ts +1 -1
- package/dist/types/mwa.d.ts +1 -1
- package/dist/types/utils/index.d.ts +1 -1
- package/package.json +5 -5
- package/src/index.ts +1 -0
- package/src/module.ts +16 -14
- package/src/monorepo.ts +4 -4
- package/src/mwa.ts +11 -11
- package/src/utils/index.ts +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,85 +1,38 @@
|
|
|
1
1
|
# @modern-js/new-action
|
|
2
2
|
|
|
3
|
-
## 1.1.
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
- 96119db2: Relese v1.1.0
|
|
8
|
-
|
|
9
|
-
1. 全面支持 Windows 平台
|
|
10
|
-
|
|
11
|
-
ISSUE:
|
|
12
|
-
|
|
13
|
-
- [182](https://github.com/modern-js-dev/modern.js/issues/182)
|
|
14
|
-
- [236](https://github.com/modern-js-dev/modern.js/issues/236)
|
|
15
|
-
|
|
16
|
-
PR
|
|
17
|
-
|
|
18
|
-
- [219](https://github.com/modern-js-dev/modern.js/pull/219)
|
|
19
|
-
- [247](https://github.com/modern-js-dev/modern.js/pull/247)
|
|
20
|
-
- [249](https://github.com/modern-js-dev/modern.js/pull/249)
|
|
21
|
-
- [253](https://github.com/modern-js-dev/modern.js/pull/253)
|
|
22
|
-
- [268](https://github.com/modern-js-dev/modern.js/pull/268)
|
|
23
|
-
- [270](https://github.com/modern-js-dev/modern.js/pull/270)
|
|
24
|
-
- [273](https://github.com/modern-js-dev/modern.js/pull/273)
|
|
25
|
-
- [276](https://github.com/modern-js-dev/modern.js/pull/276)
|
|
26
|
-
|
|
27
|
-
2. 修复 Unbundled 模式启用问题
|
|
28
|
-
|
|
29
|
-
ISSUE
|
|
30
|
-
|
|
31
|
-
- [186](https://github.com/modern-js-dev/modern.js/issues/186)
|
|
32
|
-
- [224](https://github.com/modern-js-dev/modern.js/issues/224)
|
|
33
|
-
- [225](https://github.com/modern-js-dev/modern.js/issues/225)
|
|
34
|
-
- [238](https://github.com/modern-js-dev/modern.js/issues/238)
|
|
35
|
-
|
|
36
|
-
PR
|
|
37
|
-
|
|
38
|
-
- [226](https://github.com/modern-js-dev/modern.js/pull/226)
|
|
39
|
-
- [264](https://github.com/modern-js-dev/modern.js/pull/264)
|
|
40
|
-
- [codesmith-12](https://github.com/modern-js-dev/codesmith/pull/12)
|
|
3
|
+
## 1.1.3
|
|
41
4
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
ISSUE
|
|
45
|
-
|
|
46
|
-
- [198](https://github.com/modern-js-dev/modern.js/issues/198)
|
|
47
|
-
|
|
48
|
-
PR
|
|
49
|
-
|
|
50
|
-
- [209](https://github.com/modern-js-dev/modern.js/pull/209)
|
|
51
|
-
|
|
52
|
-
4. 修复 Storybook 使用时浏览器打开页面报错
|
|
53
|
-
|
|
54
|
-
ISSUE
|
|
55
|
-
|
|
56
|
-
- [228](https://github.com/modern-js-dev/modern.js/issues/228)
|
|
57
|
-
|
|
58
|
-
PR
|
|
59
|
-
|
|
60
|
-
- [254](https://github.com/modern-js-dev/modern.js/pull/254)
|
|
5
|
+
### Patch Changes
|
|
61
6
|
|
|
62
|
-
|
|
7
|
+
- c4758365: feat: export action utils
|
|
8
|
+
- Updated dependencies [2c0750e1]
|
|
9
|
+
- @modern-js/generator-common@1.1.3
|
|
63
10
|
|
|
64
|
-
|
|
11
|
+
## 1.1.2
|
|
65
12
|
|
|
66
|
-
|
|
67
|
-
- [257](https://github.com/modern-js-dev/modern.js/issues/257)
|
|
13
|
+
### Patch Changes
|
|
68
14
|
|
|
69
|
-
|
|
15
|
+
- 0fa83663: support more .env files
|
|
16
|
+
- Updated dependencies [0fa83663]
|
|
17
|
+
- Updated dependencies [429aab90]
|
|
18
|
+
- @modern-js/generator-common@1.1.2
|
|
19
|
+
- @modern-js/generator-utils@1.1.1
|
|
70
20
|
|
|
71
|
-
|
|
72
|
-
- [271](https://github.com/modern-js-dev/modern.js/pull/271)
|
|
21
|
+
## 1.1.1
|
|
73
22
|
|
|
74
|
-
|
|
23
|
+
### Patch Changes
|
|
75
24
|
|
|
76
|
-
|
|
25
|
+
- 3b6856b8: fix: typo
|
|
26
|
+
- c7f4cafb: fix: module solution new error without peerDependencies
|
|
27
|
+
- Updated dependencies [687c92c7]
|
|
28
|
+
- Updated dependencies [c0fc0700]
|
|
29
|
+
- @modern-js/generator-common@1.1.1
|
|
77
30
|
|
|
78
|
-
|
|
31
|
+
## 1.1.0
|
|
79
32
|
|
|
80
|
-
|
|
33
|
+
### Minor Changes
|
|
81
34
|
|
|
82
|
-
|
|
35
|
+
- 96119db2: Relese v1.1.0
|
|
83
36
|
|
|
84
37
|
### Patch Changes
|
|
85
38
|
|
package/dist/js/modern/index.js
CHANGED
package/dist/js/modern/module.js
CHANGED
|
@@ -12,7 +12,7 @@ export const ModuleNewAction = async options => {
|
|
|
12
12
|
debug = false,
|
|
13
13
|
registry = '',
|
|
14
14
|
config = '{}',
|
|
15
|
-
|
|
15
|
+
cwd = process.cwd()
|
|
16
16
|
} = options;
|
|
17
17
|
let UserConfig = {};
|
|
18
18
|
|
|
@@ -48,7 +48,7 @@ export const ModuleNewAction = async options => {
|
|
|
48
48
|
let hasOption = false;
|
|
49
49
|
const schema = forEach(ModuleNewActionSchema, schemaItem => {
|
|
50
50
|
if (ModuleActionFunctions.includes(schemaItem.key)) {
|
|
51
|
-
const enable = hasEnabledFunction(schemaItem.key, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies,
|
|
51
|
+
const enable = hasEnabledFunction(schemaItem.key, ModuleActionFunctionsDependencies, ModuleActionFunctionsDevDependencies, ModuleActionFunctionsPeerDependencies, cwd);
|
|
52
52
|
const {
|
|
53
53
|
when
|
|
54
54
|
} = schemaItem;
|
|
@@ -79,22 +79,22 @@ export const ModuleNewAction = async options => {
|
|
|
79
79
|
generator = `${generator}@${distTag}`;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
const
|
|
82
|
+
const devDependency = ModuleActionFunctionsDevDependencies[action];
|
|
83
|
+
const dependency = ModuleActionFunctionsDependencies[action];
|
|
84
|
+
const peerDependency = ModuleActionFunctionsPeerDependencies[action];
|
|
85
85
|
|
|
86
86
|
const finalConfig = _merge(UserConfig, ans, {
|
|
87
87
|
locale: UserConfig.locale || locale,
|
|
88
|
-
packageManager: getPackageManager(
|
|
88
|
+
packageManager: getPackageManager(cwd)
|
|
89
89
|
}, {
|
|
90
|
-
devDependencies:
|
|
91
|
-
[
|
|
90
|
+
devDependencies: devDependency ? {
|
|
91
|
+
[devDependency]: `^${await getPackageVersion(devDependency)}`
|
|
92
92
|
} : {},
|
|
93
|
-
dependencies:
|
|
94
|
-
[
|
|
93
|
+
dependencies: dependency ? {
|
|
94
|
+
[dependency]: `^${await getPackageVersion(dependency)}`
|
|
95
95
|
} : {},
|
|
96
|
-
peerDependencies:
|
|
97
|
-
[
|
|
96
|
+
peerDependencies: peerDependency ? {
|
|
97
|
+
[peerDependency]: `^${await getPackageVersion(peerDependency)}`
|
|
98
98
|
} : {}
|
|
99
99
|
});
|
|
100
100
|
|
|
@@ -107,6 +107,6 @@ export const ModuleNewAction = async options => {
|
|
|
107
107
|
generator: runner.name,
|
|
108
108
|
config: runner.config
|
|
109
109
|
})),
|
|
110
|
-
pwd
|
|
110
|
+
pwd: cwd
|
|
111
111
|
});
|
|
112
112
|
};
|
|
@@ -12,7 +12,7 @@ export const MonorepoNewAction = async options => {
|
|
|
12
12
|
debug = false,
|
|
13
13
|
registry = '',
|
|
14
14
|
config = '{}',
|
|
15
|
-
|
|
15
|
+
cwd = process.cwd()
|
|
16
16
|
} = options;
|
|
17
17
|
let UserConfig = {};
|
|
18
18
|
|
|
@@ -59,7 +59,7 @@ export const MonorepoNewAction = async options => {
|
|
|
59
59
|
|
|
60
60
|
const finalConfig = _merge(UserConfig, ans, MonorepoNewActionConfig[solution], {
|
|
61
61
|
locale: UserConfig.locale || locale,
|
|
62
|
-
packageManager: getPackageManager(
|
|
62
|
+
packageManager: getPackageManager(cwd)
|
|
63
63
|
});
|
|
64
64
|
|
|
65
65
|
const task = [{
|
|
@@ -71,6 +71,6 @@ export const MonorepoNewAction = async options => {
|
|
|
71
71
|
generator: runner.name,
|
|
72
72
|
config: runner.config
|
|
73
73
|
})),
|
|
74
|
-
pwd
|
|
74
|
+
pwd: cwd
|
|
75
75
|
});
|
|
76
76
|
};
|
package/dist/js/modern/mwa.js
CHANGED
|
@@ -12,7 +12,7 @@ export const MWANewAction = async options => {
|
|
|
12
12
|
debug = false,
|
|
13
13
|
registry = '',
|
|
14
14
|
config = '{}',
|
|
15
|
-
|
|
15
|
+
cwd = process.cwd()
|
|
16
16
|
} = options;
|
|
17
17
|
let UserConfig = {};
|
|
18
18
|
|
|
@@ -47,7 +47,7 @@ export const MWANewAction = async options => {
|
|
|
47
47
|
}, mockGeneratorCore);
|
|
48
48
|
const schema = forEach(MWANewActionSchema, schemaItem => {
|
|
49
49
|
if (MWAActionFunctions.includes(schemaItem.key)) {
|
|
50
|
-
const enable = hasEnabledFunction(schemaItem.key, MWAActionFunctionsDependencies, MWAActionFunctionsDevDependencies, {},
|
|
50
|
+
const enable = hasEnabledFunction(schemaItem.key, MWAActionFunctionsDependencies, MWAActionFunctionsDevDependencies, {}, cwd);
|
|
51
51
|
const {
|
|
52
52
|
when
|
|
53
53
|
} = schemaItem;
|
|
@@ -67,18 +67,18 @@ export const MWANewAction = async options => {
|
|
|
67
67
|
generator = `${generator}@${distTag}`;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
const
|
|
70
|
+
const devDependency = MWAActionFunctionsDevDependencies[action];
|
|
71
|
+
const dependency = MWAActionFunctionsDependencies[action];
|
|
72
72
|
|
|
73
73
|
const finalConfig = _merge(UserConfig, ans, {
|
|
74
74
|
locale: UserConfig.locale || locale,
|
|
75
|
-
packageManager: getPackageManager(
|
|
75
|
+
packageManager: getPackageManager(cwd)
|
|
76
76
|
}, {
|
|
77
|
-
devDependencies:
|
|
78
|
-
[
|
|
77
|
+
devDependencies: devDependency ? {
|
|
78
|
+
[devDependency]: `^${await getPackageVersion(devDependency)}`
|
|
79
79
|
} : {},
|
|
80
|
-
dependencies:
|
|
81
|
-
[
|
|
80
|
+
dependencies: dependency ? {
|
|
81
|
+
[dependency]: `^${await getPackageVersion(dependency)}`
|
|
82
82
|
} : {}
|
|
83
83
|
});
|
|
84
84
|
|
|
@@ -91,6 +91,6 @@ export const MWANewAction = async options => {
|
|
|
91
91
|
generator: runner.name,
|
|
92
92
|
config: runner.config
|
|
93
93
|
})),
|
|
94
|
-
pwd
|
|
94
|
+
pwd: cwd
|
|
95
95
|
});
|
|
96
96
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import json5 from 'json5';
|
|
3
3
|
import { fs } from '@modern-js/generator-utils';
|
|
4
|
-
export function alreadyRepo() {
|
|
4
|
+
export function alreadyRepo(cwd = process.cwd()) {
|
|
5
5
|
try {
|
|
6
|
-
return fs.existsSync(path.resolve(
|
|
6
|
+
return fs.existsSync(path.resolve(cwd, 'package.json'));
|
|
7
7
|
} catch (e) {
|
|
8
8
|
return false;
|
|
9
9
|
}
|
|
@@ -33,15 +33,15 @@ export function hasEnabledFunction(action, dependencies, devDependencies, peerDe
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (dependencies[action]) {
|
|
36
|
-
return packageJson.dependencies[dependencies[action]];
|
|
36
|
+
return (packageJson.dependencies || {})[dependencies[action]];
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
if (peerDependencies[action]) {
|
|
40
|
-
return packageJson.peerDependencies[peerDependencies[action]];
|
|
40
|
+
return (packageJson.peerDependencies || {})[peerDependencies[action]];
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (!peerDependencies[action] && devDependencies[action]) {
|
|
44
|
-
return packageJson.devDependencies[devDependencies[action]];
|
|
44
|
+
return (packageJson.devDependencies || {})[devDependencies[action]];
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
return false;
|
package/dist/js/node/index.js
CHANGED
|
@@ -4,6 +4,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
|
|
9
|
+
Object.keys(_utils).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _utils[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _utils[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
7
20
|
var _mwa = require("./mwa");
|
|
8
21
|
|
|
9
22
|
Object.keys(_mwa).forEach(function (key) {
|
package/dist/js/node/module.js
CHANGED
|
@@ -27,7 +27,7 @@ const ModuleNewAction = async options => {
|
|
|
27
27
|
debug = false,
|
|
28
28
|
registry = '',
|
|
29
29
|
config = '{}',
|
|
30
|
-
|
|
30
|
+
cwd = process.cwd()
|
|
31
31
|
} = options;
|
|
32
32
|
let UserConfig = {};
|
|
33
33
|
|
|
@@ -64,7 +64,7 @@ const ModuleNewAction = async options => {
|
|
|
64
64
|
let hasOption = false;
|
|
65
65
|
const schema = (0, _codesmithApiApp.forEach)(_generatorCommon.ModuleNewActionSchema, schemaItem => {
|
|
66
66
|
if (_generatorCommon.ModuleActionFunctions.includes(schemaItem.key)) {
|
|
67
|
-
const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.ModuleActionFunctionsDependencies, _generatorCommon.ModuleActionFunctionsDevDependencies, _generatorCommon.ModuleActionFunctionsPeerDependencies,
|
|
67
|
+
const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.ModuleActionFunctionsDependencies, _generatorCommon.ModuleActionFunctionsDevDependencies, _generatorCommon.ModuleActionFunctionsPeerDependencies, cwd);
|
|
68
68
|
const {
|
|
69
69
|
when
|
|
70
70
|
} = schemaItem;
|
|
@@ -95,21 +95,21 @@ const ModuleNewAction = async options => {
|
|
|
95
95
|
generator = `${generator}@${distTag}`;
|
|
96
96
|
}
|
|
97
97
|
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
const
|
|
98
|
+
const devDependency = _generatorCommon.ModuleActionFunctionsDevDependencies[action];
|
|
99
|
+
const dependency = _generatorCommon.ModuleActionFunctionsDependencies[action];
|
|
100
|
+
const peerDependency = _generatorCommon.ModuleActionFunctionsPeerDependencies[action];
|
|
101
101
|
const finalConfig = (0, _merge2.default)(UserConfig, ans, {
|
|
102
102
|
locale: UserConfig.locale || locale,
|
|
103
|
-
packageManager: (0, _generatorUtils.getPackageManager)(
|
|
103
|
+
packageManager: (0, _generatorUtils.getPackageManager)(cwd)
|
|
104
104
|
}, {
|
|
105
|
-
devDependencies:
|
|
106
|
-
[
|
|
105
|
+
devDependencies: devDependency ? {
|
|
106
|
+
[devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
|
|
107
107
|
} : {},
|
|
108
|
-
dependencies:
|
|
109
|
-
[
|
|
108
|
+
dependencies: dependency ? {
|
|
109
|
+
[dependency]: `^${await (0, _generatorUtils.getPackageVersion)(dependency)}`
|
|
110
110
|
} : {},
|
|
111
|
-
peerDependencies:
|
|
112
|
-
[
|
|
111
|
+
peerDependencies: peerDependency ? {
|
|
112
|
+
[peerDependency]: `^${await (0, _generatorUtils.getPackageVersion)(peerDependency)}`
|
|
113
113
|
} : {}
|
|
114
114
|
});
|
|
115
115
|
const task = [{
|
|
@@ -121,7 +121,7 @@ const ModuleNewAction = async options => {
|
|
|
121
121
|
generator: runner.name,
|
|
122
122
|
config: runner.config
|
|
123
123
|
})),
|
|
124
|
-
pwd
|
|
124
|
+
pwd: cwd
|
|
125
125
|
});
|
|
126
126
|
};
|
|
127
127
|
|
package/dist/js/node/monorepo.js
CHANGED
|
@@ -27,7 +27,7 @@ const MonorepoNewAction = async options => {
|
|
|
27
27
|
debug = false,
|
|
28
28
|
registry = '',
|
|
29
29
|
config = '{}',
|
|
30
|
-
|
|
30
|
+
cwd = process.cwd()
|
|
31
31
|
} = options;
|
|
32
32
|
let UserConfig = {};
|
|
33
33
|
|
|
@@ -75,7 +75,7 @@ const MonorepoNewAction = async options => {
|
|
|
75
75
|
|
|
76
76
|
const finalConfig = (0, _merge2.default)(UserConfig, ans, _generatorCommon.MonorepoNewActionConfig[solution], {
|
|
77
77
|
locale: UserConfig.locale || locale,
|
|
78
|
-
packageManager: (0, _generatorUtils.getPackageManager)(
|
|
78
|
+
packageManager: (0, _generatorUtils.getPackageManager)(cwd)
|
|
79
79
|
});
|
|
80
80
|
const task = [{
|
|
81
81
|
name: generator,
|
|
@@ -86,7 +86,7 @@ const MonorepoNewAction = async options => {
|
|
|
86
86
|
generator: runner.name,
|
|
87
87
|
config: runner.config
|
|
88
88
|
})),
|
|
89
|
-
pwd
|
|
89
|
+
pwd: cwd
|
|
90
90
|
});
|
|
91
91
|
};
|
|
92
92
|
|
package/dist/js/node/mwa.js
CHANGED
|
@@ -27,7 +27,7 @@ const MWANewAction = async options => {
|
|
|
27
27
|
debug = false,
|
|
28
28
|
registry = '',
|
|
29
29
|
config = '{}',
|
|
30
|
-
|
|
30
|
+
cwd = process.cwd()
|
|
31
31
|
} = options;
|
|
32
32
|
let UserConfig = {};
|
|
33
33
|
|
|
@@ -63,7 +63,7 @@ const MWANewAction = async options => {
|
|
|
63
63
|
}, mockGeneratorCore);
|
|
64
64
|
const schema = (0, _codesmithApiApp.forEach)(_generatorCommon.MWANewActionSchema, schemaItem => {
|
|
65
65
|
if (_generatorCommon.MWAActionFunctions.includes(schemaItem.key)) {
|
|
66
|
-
const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.MWAActionFunctionsDependencies, _generatorCommon.MWAActionFunctionsDevDependencies, {},
|
|
66
|
+
const enable = (0, _utils.hasEnabledFunction)(schemaItem.key, _generatorCommon.MWAActionFunctionsDependencies, _generatorCommon.MWAActionFunctionsDevDependencies, {}, cwd);
|
|
67
67
|
const {
|
|
68
68
|
when
|
|
69
69
|
} = schemaItem;
|
|
@@ -83,17 +83,17 @@ const MWANewAction = async options => {
|
|
|
83
83
|
generator = `${generator}@${distTag}`;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
-
const
|
|
87
|
-
const
|
|
86
|
+
const devDependency = _generatorCommon.MWAActionFunctionsDevDependencies[action];
|
|
87
|
+
const dependency = _generatorCommon.MWAActionFunctionsDependencies[action];
|
|
88
88
|
const finalConfig = (0, _merge2.default)(UserConfig, ans, {
|
|
89
89
|
locale: UserConfig.locale || locale,
|
|
90
|
-
packageManager: (0, _generatorUtils.getPackageManager)(
|
|
90
|
+
packageManager: (0, _generatorUtils.getPackageManager)(cwd)
|
|
91
91
|
}, {
|
|
92
|
-
devDependencies:
|
|
93
|
-
[
|
|
92
|
+
devDependencies: devDependency ? {
|
|
93
|
+
[devDependency]: `^${await (0, _generatorUtils.getPackageVersion)(devDependency)}`
|
|
94
94
|
} : {},
|
|
95
|
-
dependencies:
|
|
96
|
-
[
|
|
95
|
+
dependencies: dependency ? {
|
|
96
|
+
[dependency]: `^${await (0, _generatorUtils.getPackageVersion)(dependency)}`
|
|
97
97
|
} : {}
|
|
98
98
|
});
|
|
99
99
|
const task = [{
|
|
@@ -105,7 +105,7 @@ const MWANewAction = async options => {
|
|
|
105
105
|
generator: runner.name,
|
|
106
106
|
config: runner.config
|
|
107
107
|
})),
|
|
108
|
-
pwd
|
|
108
|
+
pwd: cwd
|
|
109
109
|
});
|
|
110
110
|
};
|
|
111
111
|
|
|
@@ -15,9 +15,9 @@ var _generatorUtils = require("@modern-js/generator-utils");
|
|
|
15
15
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
|
|
18
|
-
function alreadyRepo() {
|
|
18
|
+
function alreadyRepo(cwd = process.cwd()) {
|
|
19
19
|
try {
|
|
20
|
-
return _generatorUtils.fs.existsSync(_path.default.resolve(
|
|
20
|
+
return _generatorUtils.fs.existsSync(_path.default.resolve(cwd, 'package.json'));
|
|
21
21
|
} catch (e) {
|
|
22
22
|
return false;
|
|
23
23
|
}
|
|
@@ -52,15 +52,15 @@ function hasEnabledFunction(action, dependencies, devDependencies, peerDependenc
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
if (dependencies[action]) {
|
|
55
|
-
return packageJson.dependencies[dependencies[action]];
|
|
55
|
+
return (packageJson.dependencies || {})[dependencies[action]];
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
if (peerDependencies[action]) {
|
|
59
|
-
return packageJson.peerDependencies[peerDependencies[action]];
|
|
59
|
+
return (packageJson.peerDependencies || {})[peerDependencies[action]];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
if (!peerDependencies[action] && devDependencies[action]) {
|
|
63
|
-
return packageJson.devDependencies[devDependencies[action]];
|
|
63
|
+
return (packageJson.devDependencies || {})[devDependencies[action]];
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
return false;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/module.d.ts
CHANGED
package/dist/types/monorepo.d.ts
CHANGED
package/dist/types/mwa.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ActionFunction } from '@modern-js/generator-common';
|
|
2
|
-
export declare function alreadyRepo(): boolean;
|
|
2
|
+
export declare function alreadyRepo(cwd?: string): boolean;
|
|
3
3
|
export declare const readJson: (jsonPath: string) => any;
|
|
4
4
|
export declare function hasEnabledFunction(action: ActionFunction, dependencies: Record<string, string>, devDependencies: Record<string, string>, peerDependencies: Record<string, string>, cwd: string): any;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.1.
|
|
14
|
+
"version": "1.1.4",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@babel/runtime": "^7",
|
|
31
31
|
"@modern-js/codesmith": "^1.0.0",
|
|
32
32
|
"@modern-js/codesmith-api-app": "^1.0.0",
|
|
33
|
-
"@modern-js/generator-common": "^1.1.
|
|
34
|
-
"@modern-js/generator-utils": "^1.1.
|
|
33
|
+
"@modern-js/generator-common": "^1.1.3",
|
|
34
|
+
"@modern-js/generator-utils": "^1.1.1",
|
|
35
35
|
"json5": "^2.2.0",
|
|
36
36
|
"lodash": "^4.17.21"
|
|
37
37
|
},
|
|
@@ -40,8 +40,8 @@
|
|
|
40
40
|
"@types/lodash": "^4.14.168",
|
|
41
41
|
"@types/node": "^14",
|
|
42
42
|
"typescript": "^4",
|
|
43
|
-
"@modern-js/module-tools": "^1.
|
|
44
|
-
"@modern-js/plugin-testing": "^1.
|
|
43
|
+
"@modern-js/module-tools": "^1.1.1",
|
|
44
|
+
"@modern-js/plugin-testing": "^1.1.1"
|
|
45
45
|
},
|
|
46
46
|
"sideEffects": false,
|
|
47
47
|
"modernConfig": {
|
package/src/index.ts
CHANGED
package/src/module.ts
CHANGED
|
@@ -28,7 +28,7 @@ interface IModuleNewActionOption {
|
|
|
28
28
|
debug?: boolean;
|
|
29
29
|
registry?: string;
|
|
30
30
|
config?: string;
|
|
31
|
-
|
|
31
|
+
cwd?: string;
|
|
32
32
|
}
|
|
33
33
|
// eslint-disable-next-line max-statements
|
|
34
34
|
export const ModuleNewAction = async (options: IModuleNewActionOption) => {
|
|
@@ -38,7 +38,7 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
|
|
|
38
38
|
debug = false,
|
|
39
39
|
registry = '',
|
|
40
40
|
config = '{}',
|
|
41
|
-
|
|
41
|
+
cwd = process.cwd(),
|
|
42
42
|
} = options;
|
|
43
43
|
|
|
44
44
|
let UserConfig: Record<string, unknown> = {};
|
|
@@ -79,7 +79,7 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
|
|
|
79
79
|
ModuleActionFunctionsDependencies,
|
|
80
80
|
ModuleActionFunctionsDevDependencies,
|
|
81
81
|
ModuleActionFunctionsPeerDependencies,
|
|
82
|
-
|
|
82
|
+
cwd,
|
|
83
83
|
);
|
|
84
84
|
const { when } = schemaItem;
|
|
85
85
|
schemaItem.when = enable ? () => false : when;
|
|
@@ -113,11 +113,11 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
|
|
|
113
113
|
generator = `${generator}@${distTag}`;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
const
|
|
116
|
+
const devDependency =
|
|
117
117
|
ModuleActionFunctionsDevDependencies[action as ActionFunction];
|
|
118
|
-
const
|
|
118
|
+
const dependency =
|
|
119
119
|
ModuleActionFunctionsDependencies[action as ActionFunction];
|
|
120
|
-
const
|
|
120
|
+
const peerDependency =
|
|
121
121
|
ModuleActionFunctionsPeerDependencies[action as ActionFunction];
|
|
122
122
|
|
|
123
123
|
const finalConfig = merge(
|
|
@@ -125,17 +125,19 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
|
|
|
125
125
|
ans,
|
|
126
126
|
{
|
|
127
127
|
locale: (UserConfig.locale as string) || locale,
|
|
128
|
-
packageManager: getPackageManager(
|
|
128
|
+
packageManager: getPackageManager(cwd),
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
|
-
devDependencies:
|
|
132
|
-
? { [
|
|
131
|
+
devDependencies: devDependency
|
|
132
|
+
? { [devDependency]: `^${await getPackageVersion(devDependency)}` }
|
|
133
133
|
: {},
|
|
134
|
-
dependencies:
|
|
135
|
-
? { [
|
|
134
|
+
dependencies: dependency
|
|
135
|
+
? { [dependency]: `^${await getPackageVersion(dependency)}` }
|
|
136
136
|
: {},
|
|
137
|
-
peerDependencies:
|
|
138
|
-
? {
|
|
137
|
+
peerDependencies: peerDependency
|
|
138
|
+
? {
|
|
139
|
+
[peerDependency]: `^${await getPackageVersion(peerDependency)}`,
|
|
140
|
+
}
|
|
139
141
|
: {},
|
|
140
142
|
},
|
|
141
143
|
);
|
|
@@ -152,6 +154,6 @@ export const ModuleNewAction = async (options: IModuleNewActionOption) => {
|
|
|
152
154
|
generator: runner.name,
|
|
153
155
|
config: runner.config,
|
|
154
156
|
})),
|
|
155
|
-
pwd,
|
|
157
|
+
pwd: cwd,
|
|
156
158
|
});
|
|
157
159
|
};
|
package/src/monorepo.ts
CHANGED
|
@@ -21,7 +21,7 @@ interface IMonorepoNewActionOption {
|
|
|
21
21
|
debug?: boolean;
|
|
22
22
|
registry?: string;
|
|
23
23
|
config?: string;
|
|
24
|
-
|
|
24
|
+
cwd?: string;
|
|
25
25
|
}
|
|
26
26
|
// eslint-disable-next-line max-statements
|
|
27
27
|
export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
|
|
@@ -31,7 +31,7 @@ export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
|
|
|
31
31
|
debug = false,
|
|
32
32
|
registry = '',
|
|
33
33
|
config = '{}',
|
|
34
|
-
|
|
34
|
+
cwd = process.cwd(),
|
|
35
35
|
} = options;
|
|
36
36
|
|
|
37
37
|
let UserConfig: Record<string, unknown> = {};
|
|
@@ -86,7 +86,7 @@ export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
|
|
|
86
86
|
MonorepoNewActionConfig[solution],
|
|
87
87
|
{
|
|
88
88
|
locale: (UserConfig.locale as string) || locale,
|
|
89
|
-
packageManager: getPackageManager(
|
|
89
|
+
packageManager: getPackageManager(cwd),
|
|
90
90
|
},
|
|
91
91
|
);
|
|
92
92
|
|
|
@@ -102,6 +102,6 @@ export const MonorepoNewAction = async (options: IMonorepoNewActionOption) => {
|
|
|
102
102
|
generator: runner.name,
|
|
103
103
|
config: runner.config,
|
|
104
104
|
})),
|
|
105
|
-
pwd,
|
|
105
|
+
pwd: cwd,
|
|
106
106
|
});
|
|
107
107
|
};
|
package/src/mwa.ts
CHANGED
|
@@ -27,7 +27,7 @@ interface IMWANewActionOption {
|
|
|
27
27
|
debug?: boolean;
|
|
28
28
|
registry?: string;
|
|
29
29
|
config?: string;
|
|
30
|
-
|
|
30
|
+
cwd?: string;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
// eslint-disable-next-line max-statements
|
|
@@ -38,7 +38,7 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
|
|
|
38
38
|
debug = false,
|
|
39
39
|
registry = '',
|
|
40
40
|
config = '{}',
|
|
41
|
-
|
|
41
|
+
cwd = process.cwd(),
|
|
42
42
|
} = options;
|
|
43
43
|
|
|
44
44
|
let UserConfig: Record<string, unknown> = {};
|
|
@@ -77,7 +77,7 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
|
|
|
77
77
|
MWAActionFunctionsDependencies,
|
|
78
78
|
MWAActionFunctionsDevDependencies,
|
|
79
79
|
{},
|
|
80
|
-
|
|
80
|
+
cwd,
|
|
81
81
|
);
|
|
82
82
|
const { when } = schemaItem;
|
|
83
83
|
schemaItem.when = enable ? () => false : when;
|
|
@@ -100,23 +100,23 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
|
|
|
100
100
|
generator = `${generator}@${distTag}`;
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
const
|
|
103
|
+
const devDependency =
|
|
104
104
|
MWAActionFunctionsDevDependencies[action as ActionFunction];
|
|
105
|
-
const
|
|
105
|
+
const dependency = MWAActionFunctionsDependencies[action as ActionFunction];
|
|
106
106
|
|
|
107
107
|
const finalConfig = merge(
|
|
108
108
|
UserConfig,
|
|
109
109
|
ans,
|
|
110
110
|
{
|
|
111
111
|
locale: (UserConfig.locale as string) || locale,
|
|
112
|
-
packageManager: getPackageManager(
|
|
112
|
+
packageManager: getPackageManager(cwd),
|
|
113
113
|
},
|
|
114
114
|
{
|
|
115
|
-
devDependencies:
|
|
116
|
-
? { [
|
|
115
|
+
devDependencies: devDependency
|
|
116
|
+
? { [devDependency]: `^${await getPackageVersion(devDependency)}` }
|
|
117
117
|
: {},
|
|
118
|
-
dependencies:
|
|
119
|
-
? { [
|
|
118
|
+
dependencies: dependency
|
|
119
|
+
? { [dependency]: `^${await getPackageVersion(dependency)}` }
|
|
120
120
|
: {},
|
|
121
121
|
},
|
|
122
122
|
);
|
|
@@ -133,6 +133,6 @@ export const MWANewAction = async (options: IMWANewActionOption) => {
|
|
|
133
133
|
generator: runner.name,
|
|
134
134
|
config: runner.config,
|
|
135
135
|
})),
|
|
136
|
-
pwd,
|
|
136
|
+
pwd: cwd,
|
|
137
137
|
});
|
|
138
138
|
};
|
package/src/utils/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ import json5 from 'json5';
|
|
|
3
3
|
import { ActionFunction } from '@modern-js/generator-common';
|
|
4
4
|
import { fs } from '@modern-js/generator-utils';
|
|
5
5
|
|
|
6
|
-
export function alreadyRepo() {
|
|
6
|
+
export function alreadyRepo(cwd = process.cwd()) {
|
|
7
7
|
try {
|
|
8
|
-
return fs.existsSync(path.resolve(
|
|
8
|
+
return fs.existsSync(path.resolve(cwd, 'package.json'));
|
|
9
9
|
} catch (e) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
@@ -37,13 +37,13 @@ export function hasEnabledFunction(
|
|
|
37
37
|
return false;
|
|
38
38
|
}
|
|
39
39
|
if (dependencies[action]) {
|
|
40
|
-
return packageJson.dependencies[dependencies[action]];
|
|
40
|
+
return (packageJson.dependencies || {})[dependencies[action]];
|
|
41
41
|
}
|
|
42
42
|
if (peerDependencies[action]) {
|
|
43
|
-
return packageJson.peerDependencies[peerDependencies[action]];
|
|
43
|
+
return (packageJson.peerDependencies || {})[peerDependencies[action]];
|
|
44
44
|
}
|
|
45
45
|
if (!peerDependencies[action] && devDependencies[action]) {
|
|
46
|
-
return packageJson.devDependencies[devDependencies[action]];
|
|
46
|
+
return (packageJson.devDependencies || {})[devDependencies[action]];
|
|
47
47
|
}
|
|
48
48
|
return false;
|
|
49
49
|
}
|