@modern-js/monorepo-tools 1.21.5 → 2.0.0-beta.1
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 +67 -38
- package/dist/js/modern/cli/new.js +0 -3
- package/dist/js/modern/commands/build.js +4 -9
- package/dist/js/modern/dag/create.js +8 -15
- package/dist/js/modern/dag/edge-manager.js +0 -10
- package/dist/js/modern/dag/operator.js +14 -57
- package/dist/js/modern/dag/task.js +0 -18
- package/dist/js/modern/dag/utils.js +13 -31
- package/dist/js/modern/features/build/index.js +8 -19
- package/dist/js/modern/features/clear/index.js +0 -1
- package/dist/js/modern/features/deploy/index.js +7 -35
- package/dist/js/modern/features/dev/cmds.js +1 -0
- package/dist/js/modern/features/dev/create-task.js +2 -13
- package/dist/js/modern/features/dev/index.js +4 -11
- package/dist/js/modern/features/dev/watch-projects-state.js +0 -19
- package/dist/js/modern/features/install/index.js +0 -12
- package/dist/js/modern/index.js +1 -2
- package/dist/js/modern/log/multi-tasks-log.js +8 -31
- package/dist/js/modern/log/time.js +0 -3
- package/dist/js/modern/log/utils.js +0 -2
- package/dist/js/modern/package/index.js +0 -8
- package/dist/js/modern/parse-config/index.js +3 -6
- package/dist/js/modern/parse-config/monorepo.js +0 -23
- package/dist/js/modern/projects/check-project-change.js +4 -16
- package/dist/js/modern/projects/get-projects-by-packages-config.js +12 -29
- package/dist/js/modern/projects/get-projects-by-workspace-file.js +0 -16
- package/dist/js/modern/projects/get-projects.js +4 -29
- package/dist/js/modern/utils/install.js +0 -2
- package/dist/js/node/cli/build-watch.js +0 -3
- package/dist/js/node/cli/build.js +0 -3
- package/dist/js/node/cli/clear.js +0 -3
- package/dist/js/node/cli/deploy.js +0 -3
- package/dist/js/node/cli/index.js +0 -12
- package/dist/js/node/cli/install.js +0 -3
- package/dist/js/node/cli/new.js +0 -7
- package/dist/js/node/commands/build-watch.js +0 -6
- package/dist/js/node/commands/build.js +2 -14
- package/dist/js/node/commands/clear.js +0 -5
- package/dist/js/node/commands/deploy.js +0 -9
- package/dist/js/node/commands/index.js +0 -10
- package/dist/js/node/commands/install.js +0 -6
- package/dist/js/node/dag/create.js +8 -17
- package/dist/js/node/dag/edge-manager.js +0 -12
- package/dist/js/node/dag/index.js +0 -4
- package/dist/js/node/dag/operator.js +14 -65
- package/dist/js/node/dag/task.js +0 -23
- package/dist/js/node/dag/utils.js +12 -39
- package/dist/js/node/features/build/index.js +8 -29
- package/dist/js/node/features/clear/index.js +0 -15
- package/dist/js/node/features/deploy/index.js +7 -53
- package/dist/js/node/features/dev/cmds.js +1 -0
- package/dist/js/node/features/dev/create-task.js +2 -22
- package/dist/js/node/features/dev/index.js +4 -19
- package/dist/js/node/features/dev/watch-projects-state.js +0 -25
- package/dist/js/node/features/install/index.js +0 -25
- package/dist/js/node/hooks/index.js +0 -2
- package/dist/js/node/index.js +2 -16
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/log/error.js +0 -2
- package/dist/js/node/log/multi-tasks-log.js +8 -34
- package/dist/js/node/log/time.js +0 -10
- package/dist/js/node/log/utils.js +0 -4
- package/dist/js/node/package/index.js +0 -10
- package/dist/js/node/parse-config/index.js +3 -14
- package/dist/js/node/parse-config/monorepo.js +0 -34
- package/dist/js/node/projects/check-project-change.js +4 -33
- package/dist/js/node/projects/clear-memory-files.js +0 -8
- package/dist/js/node/projects/get-projects-by-packages-config.js +12 -41
- package/dist/js/node/projects/get-projects-by-workspace-file.js +0 -36
- package/dist/js/node/projects/get-projects.js +4 -37
- package/dist/js/node/utils/install.js +0 -11
- package/dist/js/node/utils/language.js +0 -2
- package/dist/types/dag/operator.d.ts +0 -3
- package/dist/types/dag/utils.d.ts +0 -1
- package/dist/types/features/dev/index.d.ts +0 -1
- package/dist/types/index.d.ts +0 -2
- package/dist/types/projects/get-projects.d.ts +0 -1
- package/package.json +13 -36
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
-
|
|
3
2
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
4
|
-
|
|
5
3
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
|
-
|
|
7
4
|
import { errorLog } from "../log/error";
|
|
8
5
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
9
6
|
import { getProjectsByPackageConfig, syncGetProjectsByPackageConfig } from "./get-projects-by-packages-config";
|
|
10
7
|
import { getProjectsByWorkspaceFile, syncGetProjectsByWorkspaceFile } from "./get-projects-by-workspace-file";
|
|
11
8
|
var FindProjectsMode;
|
|
12
|
-
|
|
13
9
|
(function (FindProjectsMode) {
|
|
14
10
|
FindProjectsMode[FindProjectsMode["Rough"] = 0] = "Rough";
|
|
15
11
|
FindProjectsMode[FindProjectsMode["Precise"] = 1] = "Precise";
|
|
16
12
|
})(FindProjectsMode || (FindProjectsMode = {}));
|
|
17
|
-
|
|
18
13
|
const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
19
14
|
const subProjects = [];
|
|
20
|
-
|
|
21
15
|
for (const config of configs) {
|
|
22
16
|
subProjects.push({
|
|
23
17
|
name: config.name,
|
|
@@ -31,13 +25,10 @@ const getProjectsByProjectsConfig = (rootPath, configs = []) => {
|
|
|
31
25
|
circlePath: []
|
|
32
26
|
});
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
return subProjects;
|
|
36
29
|
};
|
|
37
|
-
|
|
38
30
|
const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
39
31
|
let projects = [];
|
|
40
|
-
|
|
41
32
|
if (Array.isArray(match)) {
|
|
42
33
|
// like lerna`s packages config
|
|
43
34
|
projects = await getProjectsByPackageConfig(rootPath, match, ignore);
|
|
@@ -45,9 +36,7 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
|
45
36
|
// use workspace file
|
|
46
37
|
projects = await getProjectsByWorkspaceFile(rootPath, match, ignore);
|
|
47
38
|
}
|
|
48
|
-
|
|
49
39
|
const subProjects = [];
|
|
50
|
-
|
|
51
40
|
for (const project of projects) {
|
|
52
41
|
subProjects.push({
|
|
53
42
|
name: project.name,
|
|
@@ -61,13 +50,11 @@ const getProjectsByPackagesMatch = async (rootPath, match, ignore) => {
|
|
|
61
50
|
circlePath: []
|
|
62
51
|
});
|
|
63
52
|
}
|
|
64
|
-
|
|
65
53
|
return subProjects;
|
|
66
54
|
};
|
|
67
|
-
|
|
68
55
|
const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
69
|
-
let projects = [];
|
|
70
|
-
|
|
56
|
+
let projects = [];
|
|
57
|
+
// TODO: code start
|
|
71
58
|
if (Array.isArray(match)) {
|
|
72
59
|
// like lerna`s packages config
|
|
73
60
|
projects = syncGetProjectsByPackageConfig(rootPath, match, ignore);
|
|
@@ -75,9 +62,7 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
75
62
|
// use workspace file
|
|
76
63
|
projects = syncGetProjectsByWorkspaceFile(rootPath, match, ignore);
|
|
77
64
|
}
|
|
78
|
-
|
|
79
65
|
const subProjects = [];
|
|
80
|
-
|
|
81
66
|
for (const project of projects) {
|
|
82
67
|
subProjects.push({
|
|
83
68
|
name: project.name,
|
|
@@ -91,44 +76,36 @@ const syncGetProjectsByPackagesMatch = (rootPath, match, ignore) => {
|
|
|
91
76
|
circlePath: []
|
|
92
77
|
});
|
|
93
78
|
}
|
|
94
|
-
|
|
95
79
|
return subProjects;
|
|
96
80
|
};
|
|
97
|
-
|
|
98
|
-
|
|
81
|
+
const checkFindProjectsMode = (config
|
|
82
|
+
// eslint-disable-next-line consistent-return
|
|
99
83
|
) => {
|
|
100
84
|
if (config.packagesMatchs && Array.isArray(config.packagesMatchs)) {
|
|
101
85
|
return FindProjectsMode.Rough;
|
|
102
86
|
}
|
|
103
|
-
|
|
104
87
|
if (config.packagesMatchs && typeof config.packagesMatchs === 'object' && (config.packagesMatchs.workspaceFile || config.packagesMatchs.enableAutoFinder)) {
|
|
105
88
|
return FindProjectsMode.Rough;
|
|
106
89
|
}
|
|
107
|
-
|
|
108
90
|
if (config.projectsConfig && Array.isArray(config.projectsConfig)) {
|
|
109
91
|
return FindProjectsMode.Precise;
|
|
110
92
|
}
|
|
111
|
-
|
|
112
93
|
if (config.projectsConfig && config.packagesMatchs) {
|
|
113
94
|
errorLog('There can not be both `packagesMatchs` and `projectsConfig`');
|
|
114
95
|
}
|
|
115
|
-
|
|
116
96
|
errorLog('No `packagesMatchs` and `projectsConfig` configurations found');
|
|
117
97
|
};
|
|
118
|
-
|
|
119
98
|
export const getProjects = async (config, currentDir = process.cwd()) => {
|
|
120
99
|
const {
|
|
121
100
|
rootPath
|
|
122
101
|
} = getMonorepoBaseData(currentDir);
|
|
123
102
|
const mode = checkFindProjectsMode(config);
|
|
124
103
|
let projects = [];
|
|
125
|
-
|
|
126
104
|
if (mode === FindProjectsMode.Rough) {
|
|
127
105
|
projects = await getProjectsByPackagesMatch(rootPath, config.packagesMatchs, config.packagesIgnoreMatchs || []);
|
|
128
106
|
} else if (mode === FindProjectsMode.Precise) {
|
|
129
107
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
130
108
|
}
|
|
131
|
-
|
|
132
109
|
return projects;
|
|
133
110
|
};
|
|
134
111
|
export const syncGetProjects = (config, currentDir = process.cwd()) => {
|
|
@@ -137,12 +114,10 @@ export const syncGetProjects = (config, currentDir = process.cwd()) => {
|
|
|
137
114
|
} = getMonorepoBaseData(currentDir);
|
|
138
115
|
const mode = checkFindProjectsMode(config);
|
|
139
116
|
let projects = [];
|
|
140
|
-
|
|
141
117
|
if (mode === FindProjectsMode.Rough) {
|
|
142
118
|
projects = syncGetProjectsByPackagesMatch(rootPath, config.packagesMatchs, config.packagesIgnoreMatchs || []);
|
|
143
119
|
} else if (mode === FindProjectsMode.Precise) {
|
|
144
120
|
projects = getProjectsByProjectsConfig(rootPath, config.projectsConfig);
|
|
145
121
|
}
|
|
146
|
-
|
|
147
122
|
return projects;
|
|
148
123
|
};
|
|
@@ -17,13 +17,11 @@ export const installByPackageManager = async (packageManager, {
|
|
|
17
17
|
if (removeLock) {
|
|
18
18
|
removeLockFile(rootPath, packageManager);
|
|
19
19
|
}
|
|
20
|
-
|
|
21
20
|
if (packageManager === 'pnpm') {
|
|
22
21
|
await execa('pnpm', ['install'], {
|
|
23
22
|
stdio: 'inherit'
|
|
24
23
|
});
|
|
25
24
|
}
|
|
26
|
-
|
|
27
25
|
if (packageManager === 'yarn') {
|
|
28
26
|
await execa('yarn', ['install'], {
|
|
29
27
|
stdio: 'inherit'
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.buildWatchCli = void 0;
|
|
7
|
-
|
|
8
7
|
var _commands = require("../commands");
|
|
9
|
-
|
|
10
8
|
const buildWatchCli = (program, api) => {
|
|
11
9
|
program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependencies').action(async (targetProjectName, option) => {
|
|
12
10
|
await (0, _commands.buildWatch)(targetProjectName, option, api);
|
|
13
11
|
});
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
exports.buildWatchCli = buildWatchCli;
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.buildCli = void 0;
|
|
7
|
-
|
|
8
7
|
var _commands = require("../commands");
|
|
9
|
-
|
|
10
8
|
const buildCli = (program, api) => {
|
|
11
9
|
program.command('build [project]').usage('[options]').option('--no-self', 'build without target project').option('-t, --dept', 'build target project with project’s dependent').option('--no-deps', 'build target project without project’s dependencies').option('--only-self', 'build target project with nothing').option('-a, --all', 'build target project with project’s dependencies and dependent').option('--content-hash', 'build target project use content hash cache').option('--git-hash', 'build target project use git hash cache').description('build target project').action(async (targetProjectName, option) => {
|
|
12
10
|
await (0, _commands.build)(targetProjectName, option, api);
|
|
13
11
|
});
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
exports.buildCli = buildCli;
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clearCli = void 0;
|
|
7
|
-
|
|
8
7
|
var _commands = require("../commands");
|
|
9
|
-
|
|
10
8
|
const clearCli = (program, api) => {
|
|
11
9
|
program.command('clear [projects...]').usage('[options]').option('--remove-dirs [dirs...]', 'remove dirs, default is node_modules').description('clear project dirs').action(async (targetProjectNames, option) => {
|
|
12
10
|
await (0, _commands.clear)(targetProjectNames, option, api);
|
|
13
11
|
});
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
exports.clearCli = clearCli;
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.deployCli = void 0;
|
|
7
|
-
|
|
8
7
|
var _commands = require("../commands");
|
|
9
|
-
|
|
10
8
|
const deployCli = (program, api) => {
|
|
11
9
|
program.command('deploy [project...]').usage('[options]').option('-p, --path [path]', 'Specify the path of the product output', 'output').description('deploy project').action(async (deployProjectNames, option) => {
|
|
12
10
|
// 在查找 workspace 下项目时,默认忽略 output 下面的项目
|
|
@@ -14,5 +12,4 @@ const deployCli = (program, api) => {
|
|
|
14
12
|
await (0, _commands.deploy)(api, deployProjectNames, option, ignoreMatchs);
|
|
15
13
|
});
|
|
16
14
|
};
|
|
17
|
-
|
|
18
15
|
exports.deployCli = deployCli;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _new = require("./new");
|
|
8
|
-
|
|
9
7
|
Object.keys(_new).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _new[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_new).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _deploy = require("./deploy");
|
|
21
|
-
|
|
22
18
|
Object.keys(_deploy).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _deploy[key]) return;
|
|
@@ -29,9 +25,7 @@ Object.keys(_deploy).forEach(function (key) {
|
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
var _build = require("./build");
|
|
34
|
-
|
|
35
29
|
Object.keys(_build).forEach(function (key) {
|
|
36
30
|
if (key === "default" || key === "__esModule") return;
|
|
37
31
|
if (key in exports && exports[key] === _build[key]) return;
|
|
@@ -42,9 +36,7 @@ Object.keys(_build).forEach(function (key) {
|
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
});
|
|
45
|
-
|
|
46
39
|
var _buildWatch = require("./build-watch");
|
|
47
|
-
|
|
48
40
|
Object.keys(_buildWatch).forEach(function (key) {
|
|
49
41
|
if (key === "default" || key === "__esModule") return;
|
|
50
42
|
if (key in exports && exports[key] === _buildWatch[key]) return;
|
|
@@ -55,9 +47,7 @@ Object.keys(_buildWatch).forEach(function (key) {
|
|
|
55
47
|
}
|
|
56
48
|
});
|
|
57
49
|
});
|
|
58
|
-
|
|
59
50
|
var _clear = require("./clear");
|
|
60
|
-
|
|
61
51
|
Object.keys(_clear).forEach(function (key) {
|
|
62
52
|
if (key === "default" || key === "__esModule") return;
|
|
63
53
|
if (key in exports && exports[key] === _clear[key]) return;
|
|
@@ -68,9 +58,7 @@ Object.keys(_clear).forEach(function (key) {
|
|
|
68
58
|
}
|
|
69
59
|
});
|
|
70
60
|
});
|
|
71
|
-
|
|
72
61
|
var _install = require("./install");
|
|
73
|
-
|
|
74
62
|
Object.keys(_install).forEach(function (key) {
|
|
75
63
|
if (key === "default" || key === "__esModule") return;
|
|
76
64
|
if (key in exports && exports[key] === _install[key]) return;
|
|
@@ -4,13 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.installCli = void 0;
|
|
7
|
-
|
|
8
7
|
var _commands = require("../commands");
|
|
9
|
-
|
|
10
8
|
const installCli = (program, api) => {
|
|
11
9
|
program.command('install [project...]').usage('[options]').description('install deps for some projects').action(async (installProjectNames, option) => {
|
|
12
10
|
await (0, _commands.install)(installProjectNames, option, api);
|
|
13
11
|
});
|
|
14
12
|
};
|
|
15
|
-
|
|
16
13
|
exports.installCli = installCli;
|
package/dist/js/node/cli/new.js
CHANGED
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.newCli = void 0;
|
|
7
|
-
|
|
8
7
|
var _newAction = require("@modern-js/new-action");
|
|
9
|
-
|
|
10
8
|
var _locale = require("../locale");
|
|
11
|
-
|
|
12
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
|
|
14
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
-
|
|
16
11
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
|
|
18
12
|
const newCli = (program, locale) => {
|
|
19
13
|
program.command('new').usage('[options]').description(_locale.i18n.t(_locale.localeKeys.command.new.describe)).option('-d, --debug', _locale.i18n.t(_locale.localeKeys.command.new.debug), false).option('-c, --config <config>', _locale.i18n.t(_locale.localeKeys.command.new.config)).option('-p, --plugin <plugin>', _locale.i18n.t(_locale.localeKeys.command.new.plugin), (val, memo) => {
|
|
20
14
|
memo.push(val);
|
|
@@ -25,5 +19,4 @@ const newCli = (program, locale) => {
|
|
|
25
19
|
}));
|
|
26
20
|
});
|
|
27
21
|
};
|
|
28
|
-
|
|
29
22
|
exports.newCli = newCli;
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.buildWatch = void 0;
|
|
7
|
-
|
|
8
7
|
var _monorepo = require("../parse-config/monorepo");
|
|
9
|
-
|
|
10
8
|
var _dev = require("../features/dev");
|
|
11
|
-
|
|
12
9
|
var _getProjects = require("../projects/get-projects");
|
|
13
|
-
|
|
14
10
|
var _dag = require("../dag");
|
|
15
|
-
|
|
16
11
|
const buildWatch = async (targetProjectName, option, api) => {
|
|
17
12
|
const {
|
|
18
13
|
appDirectory
|
|
@@ -39,5 +34,4 @@ const buildWatch = async (targetProjectName, option, api) => {
|
|
|
39
34
|
needInit: init
|
|
40
35
|
});
|
|
41
36
|
};
|
|
42
|
-
|
|
43
37
|
exports.buildWatch = buildWatch;
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.build = void 0;
|
|
7
|
-
|
|
8
7
|
var _monorepo = require("../parse-config/monorepo");
|
|
9
|
-
|
|
10
8
|
var _build = require("../features/build");
|
|
11
|
-
|
|
12
9
|
var _getProjects = require("../projects/get-projects");
|
|
13
|
-
|
|
14
10
|
var _dag = require("../dag");
|
|
15
|
-
|
|
16
11
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
|
|
18
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
-
|
|
20
13
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
21
|
-
|
|
22
14
|
const build = async (targetProjectName, option, api) => {
|
|
23
15
|
const {
|
|
24
16
|
appDirectory
|
|
@@ -44,13 +36,11 @@ const build = async (targetProjectName, option, api) => {
|
|
|
44
36
|
packageManager
|
|
45
37
|
} = (0, _monorepo.getMonorepoBaseData)(appDirectory);
|
|
46
38
|
const overrideConfig = {};
|
|
47
|
-
|
|
48
39
|
if (all) {
|
|
49
40
|
overrideConfig.disableWithDeps = false;
|
|
50
41
|
overrideConfig.withSelf = true;
|
|
51
42
|
overrideConfig.withDept = true;
|
|
52
43
|
}
|
|
53
|
-
|
|
54
44
|
if (targetProjectName) {
|
|
55
45
|
(0, _build.runBuildTask)(targetProjectName, operator, _objectSpread({
|
|
56
46
|
rootPath,
|
|
@@ -65,7 +55,6 @@ const build = async (targetProjectName, option, api) => {
|
|
|
65
55
|
}, overrideConfig));
|
|
66
56
|
} else {
|
|
67
57
|
const currentDir = process.cwd();
|
|
68
|
-
|
|
69
58
|
if (currentDir === appDirectory) {
|
|
70
59
|
await (0, _build.runAllBuildTask)(operator, {
|
|
71
60
|
rootPath: currentDir,
|
|
@@ -73,9 +62,8 @@ const build = async (targetProjectName, option, api) => {
|
|
|
73
62
|
disableContentHash: !contentHash,
|
|
74
63
|
enableGitHash: gitHash
|
|
75
64
|
});
|
|
76
|
-
}
|
|
77
|
-
|
|
65
|
+
}
|
|
66
|
+
// TODO: 没有指定项目名称的构建任务如何处理
|
|
78
67
|
}
|
|
79
68
|
};
|
|
80
|
-
|
|
81
69
|
exports.build = build;
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.clear = void 0;
|
|
7
|
-
|
|
8
7
|
var _getProjects = require("../projects/get-projects");
|
|
9
|
-
|
|
10
8
|
var _monorepo = require("../parse-config/monorepo");
|
|
11
|
-
|
|
12
9
|
var _clear = require("../features/clear");
|
|
13
|
-
|
|
14
10
|
const clear = async (projectNames, option, api) => {
|
|
15
11
|
const {
|
|
16
12
|
removeDirs
|
|
@@ -31,5 +27,4 @@ const clear = async (projectNames, option, api) => {
|
|
|
31
27
|
removeDirs
|
|
32
28
|
});
|
|
33
29
|
};
|
|
34
|
-
|
|
35
30
|
exports.clear = clear;
|
|
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.deploy = void 0;
|
|
7
|
-
|
|
8
7
|
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
8
|
var _dag = require("../dag");
|
|
11
|
-
|
|
12
9
|
var _monorepo = require("../parse-config/monorepo");
|
|
13
|
-
|
|
14
10
|
var _getProjects = require("../projects/get-projects");
|
|
15
|
-
|
|
16
11
|
var _deploy = require("../features/deploy");
|
|
17
|
-
|
|
18
12
|
const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
|
|
19
13
|
const {
|
|
20
14
|
deployPath = 'output'
|
|
@@ -22,9 +16,7 @@ const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
|
|
|
22
16
|
const {
|
|
23
17
|
appDirectory
|
|
24
18
|
} = api.useAppContext();
|
|
25
|
-
|
|
26
19
|
_utils.logger.info(`start deploy ${deployProjectNames.join(',')}`);
|
|
27
|
-
|
|
28
20
|
const projects = await (0, _getProjects.getProjects)({
|
|
29
21
|
packagesMatchs: {
|
|
30
22
|
enableAutoFinder: true
|
|
@@ -47,5 +39,4 @@ const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
|
|
|
47
39
|
deployProjectNames
|
|
48
40
|
});
|
|
49
41
|
};
|
|
50
|
-
|
|
51
42
|
exports.deploy = deploy;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
6
|
var _deploy = require("./deploy");
|
|
8
|
-
|
|
9
7
|
Object.keys(_deploy).forEach(function (key) {
|
|
10
8
|
if (key === "default" || key === "__esModule") return;
|
|
11
9
|
if (key in exports && exports[key] === _deploy[key]) return;
|
|
@@ -16,9 +14,7 @@ Object.keys(_deploy).forEach(function (key) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
});
|
|
19
|
-
|
|
20
17
|
var _build = require("./build");
|
|
21
|
-
|
|
22
18
|
Object.keys(_build).forEach(function (key) {
|
|
23
19
|
if (key === "default" || key === "__esModule") return;
|
|
24
20
|
if (key in exports && exports[key] === _build[key]) return;
|
|
@@ -29,9 +25,7 @@ Object.keys(_build).forEach(function (key) {
|
|
|
29
25
|
}
|
|
30
26
|
});
|
|
31
27
|
});
|
|
32
|
-
|
|
33
28
|
var _buildWatch = require("./build-watch");
|
|
34
|
-
|
|
35
29
|
Object.keys(_buildWatch).forEach(function (key) {
|
|
36
30
|
if (key === "default" || key === "__esModule") return;
|
|
37
31
|
if (key in exports && exports[key] === _buildWatch[key]) return;
|
|
@@ -42,9 +36,7 @@ Object.keys(_buildWatch).forEach(function (key) {
|
|
|
42
36
|
}
|
|
43
37
|
});
|
|
44
38
|
});
|
|
45
|
-
|
|
46
39
|
var _clear = require("./clear");
|
|
47
|
-
|
|
48
40
|
Object.keys(_clear).forEach(function (key) {
|
|
49
41
|
if (key === "default" || key === "__esModule") return;
|
|
50
42
|
if (key in exports && exports[key] === _clear[key]) return;
|
|
@@ -55,9 +47,7 @@ Object.keys(_clear).forEach(function (key) {
|
|
|
55
47
|
}
|
|
56
48
|
});
|
|
57
49
|
});
|
|
58
|
-
|
|
59
50
|
var _install = require("./install");
|
|
60
|
-
|
|
61
51
|
Object.keys(_install).forEach(function (key) {
|
|
62
52
|
if (key === "default" || key === "__esModule") return;
|
|
63
53
|
if (key in exports && exports[key] === _install[key]) return;
|
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.install = void 0;
|
|
7
|
-
|
|
8
7
|
var _install = require("../features/install");
|
|
9
|
-
|
|
10
8
|
var _monorepo = require("../parse-config/monorepo");
|
|
11
|
-
|
|
12
9
|
var _getProjects = require("../projects/get-projects");
|
|
13
|
-
|
|
14
10
|
var _dag = require("../dag");
|
|
15
|
-
|
|
16
11
|
const install = async (projectNames = [], option, api) => {
|
|
17
12
|
const {
|
|
18
13
|
appDirectory
|
|
@@ -37,5 +32,4 @@ const install = async (projectNames = [], option, api) => {
|
|
|
37
32
|
auto
|
|
38
33
|
});
|
|
39
34
|
};
|
|
40
|
-
|
|
41
35
|
exports.install = install;
|
|
@@ -4,57 +4,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.create = void 0;
|
|
7
|
-
|
|
8
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
-
|
|
10
8
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
|
|
12
9
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
-
|
|
14
10
|
const initProjectDependencyAndDependent = (project, projectsName, projectsMap) => {
|
|
15
11
|
// dependencies、devDependencies、peerDependencies
|
|
16
12
|
const dependencies = project.extra.dependencies || {};
|
|
17
13
|
const devDependencies = project.extra.devDependencies || {};
|
|
18
14
|
const optionalDependencies = project.extra.optionalDependencies || {};
|
|
19
|
-
const DependencyProjectsName = Object.keys(_objectSpread(_objectSpread(_objectSpread({}, dependencies), devDependencies), optionalDependencies)).filter(depName => projectsName.includes(depName));
|
|
20
|
-
|
|
21
|
-
project.dependent = project.dependent || []; // get dependency ProjectNode
|
|
15
|
+
const DependencyProjectsName = Object.keys(_objectSpread(_objectSpread(_objectSpread({}, dependencies), devDependencies), optionalDependencies)).filter(depName => projectsName.includes(depName));
|
|
22
16
|
|
|
17
|
+
// init dependent key
|
|
18
|
+
project.dependent = project.dependent || [];
|
|
19
|
+
// get dependency ProjectNode
|
|
23
20
|
project.dependency = DependencyProjectsName.map(projectName => {
|
|
24
21
|
// 在遍历该项目的 dependency 的时候,顺便更新这些 dependency 的 dependent
|
|
25
22
|
const dependencyProject = projectsMap.get(projectName);
|
|
26
23
|
const dependent = (dependencyProject === null || dependencyProject === void 0 ? void 0 : dependencyProject.dependent) || [];
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
if (
|
|
25
|
+
// 消除重复添加的情况
|
|
29
26
|
!dependent.some(p => p.name === project.name)) {
|
|
30
27
|
dependencyProject.dependent = [...dependent, project];
|
|
31
28
|
dependencyProject.dependentEdge = dependencyProject.dependent.length;
|
|
32
29
|
}
|
|
33
|
-
|
|
34
30
|
return dependencyProject;
|
|
35
|
-
});
|
|
31
|
+
});
|
|
32
|
+
// NOTE: 一个节点有多少依赖,就代表有多少的入度或者叫指向该节点的边
|
|
36
33
|
// project.dagNodeEdge = project.dependency.length;
|
|
37
|
-
|
|
38
34
|
project.dependencyEdge = project.dependency.length;
|
|
39
35
|
};
|
|
40
|
-
|
|
41
36
|
const create = projects => {
|
|
42
37
|
const projectsName = [];
|
|
43
38
|
const projectsMap = new Map();
|
|
44
|
-
|
|
45
39
|
for (const project of projects) {
|
|
46
40
|
projectsMap.set(project.name, project);
|
|
47
41
|
projectsName.push(project.name);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
43
|
for (const project of projects) {
|
|
51
44
|
initProjectDependencyAndDependent(project, projectsName, projectsMap);
|
|
52
45
|
}
|
|
53
|
-
|
|
54
46
|
return {
|
|
55
47
|
projectsMap,
|
|
56
48
|
projectList: projectsName
|
|
57
49
|
};
|
|
58
50
|
};
|
|
59
|
-
|
|
60
51
|
exports.create = create;
|
|
@@ -4,44 +4,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.EdgeManager = void 0;
|
|
7
|
-
|
|
8
7
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
-
|
|
10
8
|
class EdgeManager {
|
|
11
9
|
constructor() {
|
|
12
10
|
_defineProperty(this, "_dependencyEdgeHash", void 0);
|
|
13
|
-
|
|
14
11
|
this._dependencyEdgeHash = {};
|
|
15
12
|
}
|
|
16
|
-
|
|
17
13
|
reduceOneEdge(project) {
|
|
18
14
|
if (!(project.name in this._dependencyEdgeHash)) {
|
|
19
15
|
this._dependencyEdgeHash[project.name] = project.dependencyEdge;
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
this._dependencyEdgeHash[project.name]--;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
reduceEdges(project, edges) {
|
|
26
20
|
if (!(project.name in this._dependencyEdgeHash)) {
|
|
27
21
|
this._dependencyEdgeHash[project.name] = project.dependencyEdge;
|
|
28
22
|
}
|
|
29
|
-
|
|
30
23
|
this._dependencyEdgeHash[project.name] -= edges;
|
|
31
24
|
}
|
|
32
|
-
|
|
33
25
|
getEdge(project) {
|
|
34
26
|
if (project.name in this._dependencyEdgeHash) {
|
|
35
27
|
return this._dependencyEdgeHash[project.name];
|
|
36
28
|
}
|
|
37
|
-
|
|
38
29
|
return NaN;
|
|
39
30
|
}
|
|
40
|
-
|
|
41
31
|
setEdge(project) {
|
|
42
32
|
this._dependencyEdgeHash[project.name] = project.dependencyEdge;
|
|
43
33
|
}
|
|
44
|
-
|
|
45
34
|
}
|
|
46
|
-
|
|
47
35
|
exports.EdgeManager = EdgeManager;
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.initDAG = void 0;
|
|
7
|
-
|
|
8
7
|
var _create = require("./create");
|
|
9
|
-
|
|
10
8
|
var _operator = require("./operator");
|
|
11
|
-
|
|
12
9
|
const initDAG = projects => {
|
|
13
10
|
const {
|
|
14
11
|
projectsMap
|
|
@@ -16,5 +13,4 @@ const initDAG = projects => {
|
|
|
16
13
|
const operator = new _operator.DagOperator(projects, projectsMap);
|
|
17
14
|
return operator;
|
|
18
15
|
};
|
|
19
|
-
|
|
20
16
|
exports.initDAG = initDAG;
|