@modern-js/monorepo-tools 2.0.0-beta.3 → 2.0.0-beta.6
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 +103 -0
- package/bin/modern.js +3 -1
- package/dist/js/modern/cli/build-watch.js +30 -5
- package/dist/js/modern/cli/build.js +31 -5
- package/dist/js/modern/cli/clear.js +30 -5
- package/dist/js/modern/cli/deploy.js +35 -7
- package/dist/js/modern/cli/index.js +1 -1
- package/dist/js/modern/cli/install.js +30 -5
- package/dist/js/modern/cli/new.js +56 -14
- package/dist/js/modern/commands/build-watch.js +32 -18
- package/dist/js/modern/commands/build.js +49 -23
- package/dist/js/modern/commands/clear.js +31 -15
- package/dist/js/modern/commands/deploy.js +38 -24
- package/dist/js/modern/commands/index.js +1 -1
- package/dist/js/modern/commands/install.js +32 -17
- package/dist/js/modern/constants.js +13 -9
- package/dist/js/modern/dag/create.js +27 -23
- package/dist/js/modern/dag/edge-manager.js +5 -4
- package/dist/js/modern/dag/index.js +6 -5
- package/dist/js/modern/dag/operator.js +174 -156
- package/dist/js/modern/dag/task.js +64 -39
- package/dist/js/modern/dag/utils.js +32 -38
- package/dist/js/modern/features/build/index.js +47 -28
- package/dist/js/modern/features/clear/index.js +16 -15
- package/dist/js/modern/features/deploy/index.js +107 -82
- package/dist/js/modern/features/dev/cmds.js +4 -3
- package/dist/js/modern/features/dev/create-task.js +43 -34
- package/dist/js/modern/features/dev/index.js +60 -41
- package/dist/js/modern/features/dev/watch-projects-state.js +47 -24
- package/dist/js/modern/features/install/index.js +43 -22
- package/dist/js/modern/hooks/index.js +6 -3
- package/dist/js/modern/index.js +18 -16
- package/dist/js/modern/locale/en.js +10 -7
- package/dist/js/modern/locale/index.js +6 -6
- package/dist/js/modern/locale/zh.js +11 -8
- package/dist/js/modern/log/error.js +6 -3
- package/dist/js/modern/log/multi-tasks-log.js +25 -34
- package/dist/js/modern/log/time.js +26 -11
- package/dist/js/modern/log/utils.js +9 -5
- package/dist/js/modern/package/index.js +5 -6
- package/dist/js/modern/parse-config/index.js +49 -22
- package/dist/js/modern/parse-config/monorepo.js +41 -26
- package/dist/js/modern/projects/check-project-change.js +59 -30
- package/dist/js/modern/projects/clear-memory-files.js +17 -7
- package/dist/js/modern/projects/get-projects-by-packages-config.js +89 -52
- package/dist/js/modern/projects/get-projects-by-workspace-file.js +68 -32
- package/dist/js/modern/projects/get-projects.js +96 -53
- package/dist/js/modern/type.js +0 -1
- package/dist/js/modern/utils/install.js +36 -19
- package/dist/js/modern/utils/language.js +6 -3
- package/dist/js/node/cli/build-watch.js +51 -10
- package/dist/js/node/cli/build.js +52 -10
- package/dist/js/node/cli/clear.js +51 -10
- package/dist/js/node/cli/deploy.js +56 -12
- package/dist/js/node/cli/index.js +22 -71
- package/dist/js/node/cli/install.js +51 -10
- package/dist/js/node/cli/new.js +75 -19
- package/dist/js/node/commands/build-watch.js +59 -29
- package/dist/js/node/commands/build.js +74 -32
- package/dist/js/node/commands/clear.js +57 -25
- package/dist/js/node/commands/deploy.js +65 -35
- package/dist/js/node/commands/index.js +21 -60
- package/dist/js/node/commands/install.js +59 -28
- package/dist/js/node/constants.js +33 -13
- package/dist/js/node/dag/create.js +46 -28
- package/dist/js/node/dag/edge-manager.js +25 -8
- package/dist/js/node/dag/index.js +30 -13
- package/dist/js/node/dag/operator.js +211 -174
- package/dist/js/node/dag/task.js +92 -46
- package/dist/js/node/dag/utils.js +58 -47
- package/dist/js/node/features/build/index.js +84 -47
- package/dist/js/node/features/clear/index.js +49 -28
- package/dist/js/node/features/deploy/index.js +139 -104
- package/dist/js/node/features/dev/cmds.js +26 -9
- package/dist/js/node/features/dev/create-task.js +80 -51
- package/dist/js/node/features/dev/index.js +98 -58
- package/dist/js/node/features/dev/watch-projects-state.js +71 -30
- package/dist/js/node/features/install/index.js +82 -41
- package/dist/js/node/hooks/index.js +27 -8
- package/dist/js/node/index.js +53 -32
- package/dist/js/node/locale/en.js +30 -11
- package/dist/js/node/locale/index.js +31 -14
- package/dist/js/node/locale/zh.js +31 -12
- package/dist/js/node/log/error.js +26 -7
- package/dist/js/node/log/multi-tasks-log.js +48 -41
- package/dist/js/node/log/time.js +47 -18
- package/dist/js/node/log/utils.js +30 -10
- package/dist/js/node/package/index.js +25 -10
- package/dist/js/node/parse-config/index.js +76 -31
- package/dist/js/node/parse-config/monorepo.js +79 -44
- package/dist/js/node/projects/check-project-change.js +104 -56
- package/dist/js/node/projects/clear-memory-files.js +42 -15
- package/dist/js/node/projects/get-projects-by-packages-config.js +119 -65
- package/dist/js/node/projects/get-projects-by-workspace-file.js +108 -55
- package/dist/js/node/projects/get-projects.js +112 -61
- package/dist/js/node/type.js +15 -5
- package/dist/js/node/utils/install.js +68 -31
- package/dist/js/node/utils/language.js +28 -8
- package/dist/js/node/utils/types.js +15 -0
- package/dist/types/dag/operator.d.ts +3 -0
- package/dist/types/dag/utils.d.ts +1 -0
- package/dist/types/features/dev/index.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/projects/get-projects.d.ts +1 -0
- package/package.json +12 -19
|
@@ -1,152 +1,186 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var deploy_exports = {};
|
|
45
|
+
__export(deploy_exports, {
|
|
46
|
+
deploy: () => deploy
|
|
5
47
|
});
|
|
6
|
-
exports
|
|
7
|
-
var path =
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
48
|
+
module.exports = __toCommonJS(deploy_exports);
|
|
49
|
+
var path = __toESM(require("path"));
|
|
50
|
+
var import_node_core_library = require("@rushstack/node-core-library");
|
|
51
|
+
var import_utils = require("@modern-js/utils");
|
|
52
|
+
var import_constants = require("../../constants");
|
|
13
53
|
const createCopyMap = (rootPath, targetProject, copyProjects, deployDir) => {
|
|
14
|
-
const map = new Map();
|
|
54
|
+
const map = /* @__PURE__ */ new Map();
|
|
15
55
|
for (const project of copyProjects) {
|
|
16
56
|
const relativePath = path.relative(rootPath, project.extra.path);
|
|
17
57
|
const targetPath = path.join(deployDir, relativePath);
|
|
18
58
|
map.set(project.extra.path, targetPath);
|
|
19
59
|
}
|
|
20
|
-
const targetProjectDeployPath = path.join(deployDir,
|
|
60
|
+
const targetProjectDeployPath = path.join(deployDir, "apps/app");
|
|
21
61
|
map.set(targetProject.extra.path, targetProjectDeployPath);
|
|
22
62
|
return map;
|
|
23
63
|
};
|
|
24
|
-
const createCopyFromMonorepoToDeployDirFn = (monorepoDir, deployDir) => filename => {
|
|
64
|
+
const createCopyFromMonorepoToDeployDirFn = (monorepoDir, deployDir) => (filename) => {
|
|
25
65
|
const sourcePath = path.join(monorepoDir, filename);
|
|
26
66
|
const destinationPath = path.join(deployDir, filename);
|
|
27
|
-
if (
|
|
28
|
-
|
|
67
|
+
if (import_node_core_library.FileSystem.exists(sourcePath)) {
|
|
68
|
+
import_node_core_library.FileSystem.copyFile({
|
|
29
69
|
sourcePath,
|
|
30
70
|
destinationPath
|
|
31
71
|
});
|
|
32
72
|
}
|
|
33
73
|
};
|
|
34
|
-
const checkAndUpdatePMWorkspaces = deployDir => {
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
74
|
+
const checkAndUpdatePMWorkspaces = (deployDir) => {
|
|
75
|
+
var _a;
|
|
76
|
+
const pnpmWp = path.join(deployDir, import_constants.WORKSPACE_FILE.PNPM);
|
|
77
|
+
if (import_utils.fs.existsSync(pnpmWp)) {
|
|
78
|
+
const pnpmWorkspace = import_utils.yaml.load(
|
|
79
|
+
import_utils.fs.readFileSync(pnpmWp, "utf-8")
|
|
80
|
+
);
|
|
40
81
|
if (pnpmWorkspace.packages && Array.isArray(pnpmWorkspace.packages)) {
|
|
41
|
-
pnpmWorkspace.packages.push(
|
|
82
|
+
pnpmWorkspace.packages.push("apps/**");
|
|
42
83
|
}
|
|
43
|
-
|
|
84
|
+
import_utils.fs.writeFileSync(pnpmWp, import_utils.yaml.dump(pnpmWorkspace));
|
|
44
85
|
}
|
|
45
|
-
const pkgPath = path.join(deployDir,
|
|
46
|
-
const pkg =
|
|
47
|
-
if ((
|
|
48
|
-
pkg.workspaces.packages.push(
|
|
86
|
+
const pkgPath = path.join(deployDir, import_constants.WORKSPACE_FILE.YARN);
|
|
87
|
+
const pkg = import_node_core_library.JsonFile.load(pkgPath);
|
|
88
|
+
if (((_a = pkg.workspaces) == null ? void 0 : _a.packages) && Array.isArray(pkg.workspaces.packages)) {
|
|
89
|
+
pkg.workspaces.packages.push("app/**");
|
|
49
90
|
}
|
|
50
91
|
};
|
|
51
92
|
const generatorAndCopyRequiredFiles = (rootPath, deployDir) => {
|
|
52
|
-
// copy .npmrc
|
|
53
93
|
const copy = createCopyFromMonorepoToDeployDirFn(rootPath, deployDir);
|
|
54
|
-
copy(
|
|
55
|
-
copy(
|
|
56
|
-
copy(
|
|
57
|
-
copy(
|
|
58
|
-
copy(
|
|
59
|
-
copy(
|
|
60
|
-
copy(
|
|
61
|
-
|
|
62
|
-
copy(
|
|
63
|
-
copy(
|
|
64
|
-
copy('package-lock.json');
|
|
65
|
-
|
|
66
|
-
// check workspaces config and add 'apps/**',
|
|
67
|
-
// because we deploy project to 'apps' dir
|
|
94
|
+
copy(".npmrc");
|
|
95
|
+
copy("package.json");
|
|
96
|
+
copy("pnpm-workspace.yaml");
|
|
97
|
+
copy("lerna.json");
|
|
98
|
+
copy(".pnpmfile.cjs");
|
|
99
|
+
copy("tsconfig.json");
|
|
100
|
+
copy("modern.config.js");
|
|
101
|
+
copy("pnpm-lock.yaml");
|
|
102
|
+
copy("yarn.lock");
|
|
103
|
+
copy("package-lock.json");
|
|
68
104
|
checkAndUpdatePMWorkspaces(deployDir);
|
|
69
105
|
};
|
|
70
|
-
const checkAndRunDeployCommand =
|
|
71
|
-
var
|
|
72
|
-
const scripts = ((
|
|
106
|
+
const checkAndRunDeployCommand = (monorepoPath, targetProject, packageManager) => __async(void 0, null, function* () {
|
|
107
|
+
var _a, _b, _c;
|
|
108
|
+
const scripts = ((_a = targetProject.extra) == null ? void 0 : _a.scripts) || {};
|
|
73
109
|
if (scripts.deploy) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
110
|
+
import_utils.logger.info(
|
|
111
|
+
`The 'deploy' command for the ${targetProject.name} is detected, so 'deploy' will be executed`
|
|
112
|
+
);
|
|
113
|
+
let runDeployCommands = ["run", "deploy"];
|
|
114
|
+
if (packageManager === "pnpm") {
|
|
115
|
+
const pnpmVersion = yield (0, import_utils.getPnpmVersion)();
|
|
116
|
+
if (pnpmVersion.startsWith("6")) {
|
|
117
|
+
runDeployCommands = ["run", "deploy", "--filter", targetProject.name];
|
|
81
118
|
} else {
|
|
82
|
-
runDeployCommands = [
|
|
119
|
+
runDeployCommands = ["run", "--filter", targetProject.name, "deploy"];
|
|
83
120
|
}
|
|
84
|
-
} else if (packageManager ===
|
|
85
|
-
runDeployCommands = [
|
|
121
|
+
} else if (packageManager === "yarn") {
|
|
122
|
+
runDeployCommands = ["workspace", targetProject.name, "run", "deploy"];
|
|
86
123
|
}
|
|
87
|
-
const cwd = packageManager ===
|
|
88
|
-
const childProcess = (0,
|
|
124
|
+
const cwd = packageManager === "npm" ? targetProject.extra.path : monorepoPath;
|
|
125
|
+
const childProcess = (0, import_utils.execa)(packageManager, runDeployCommands, {
|
|
89
126
|
cwd,
|
|
90
|
-
stdio: [
|
|
127
|
+
stdio: ["pipe"]
|
|
91
128
|
});
|
|
92
|
-
(
|
|
93
|
-
(
|
|
94
|
-
|
|
129
|
+
(_b = childProcess.stdout) == null ? void 0 : _b.pipe(process.stdout);
|
|
130
|
+
(_c = childProcess.stderr) == null ? void 0 : _c.pipe(process.stderr);
|
|
131
|
+
yield childProcess;
|
|
95
132
|
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const packageJsonPath = path.join(deployDir, 'package.json');
|
|
102
|
-
const packageJson = _nodeCoreLibrary.JsonFile.load(packageJsonPath);
|
|
103
|
-
const scripts = (packageJson === null || packageJson === void 0 ? void 0 : packageJson.scripts) || {};
|
|
133
|
+
});
|
|
134
|
+
const installDependency = (deployDir, packageManager) => __async(void 0, null, function* () {
|
|
135
|
+
const packageJsonPath = path.join(deployDir, "package.json");
|
|
136
|
+
const packageJson = import_node_core_library.JsonFile.load(packageJsonPath);
|
|
137
|
+
const scripts = (packageJson == null ? void 0 : packageJson.scripts) || {};
|
|
104
138
|
let commands = [];
|
|
105
139
|
if (scripts.setup) {
|
|
106
|
-
|
|
107
|
-
|
|
140
|
+
import_utils.logger.info(
|
|
141
|
+
`The 'setup' command is detected, execute '${packageManager} run setup' to start installing the dependencies`
|
|
142
|
+
);
|
|
143
|
+
commands = ["run", "setup"];
|
|
108
144
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
145
|
+
import_utils.logger.info(
|
|
146
|
+
`No 'setup' command detected, execute '${packageManager} install' to start installing dependencies`
|
|
147
|
+
);
|
|
148
|
+
commands = ["install"];
|
|
111
149
|
}
|
|
112
|
-
|
|
113
|
-
const childProcess = (0,
|
|
114
|
-
stdio:
|
|
150
|
+
import_utils.logger.log(import_utils.chalk.rgb(218, 152, 92)("Install Log:\n"));
|
|
151
|
+
const childProcess = (0, import_utils.execa)(packageManager, commands, {
|
|
152
|
+
stdio: "inherit",
|
|
115
153
|
cwd: deployDir,
|
|
116
|
-
env: {
|
|
117
|
-
NODE_ENV: undefined
|
|
118
|
-
}
|
|
154
|
+
env: { NODE_ENV: void 0 }
|
|
119
155
|
});
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
const excludeDirs = (filePath, dirs) => dirs.some(dir => filePath.includes(dir));
|
|
123
|
-
const defaultDeployPath =
|
|
124
|
-
const deploy =
|
|
125
|
-
const {
|
|
126
|
-
rootPath,
|
|
127
|
-
packageManager,
|
|
128
|
-
deployPath = defaultDeployPath
|
|
129
|
-
} = config;
|
|
156
|
+
yield childProcess;
|
|
157
|
+
});
|
|
158
|
+
const excludeDirs = (filePath, dirs) => dirs.some((dir) => filePath.includes(dir));
|
|
159
|
+
const defaultDeployPath = "output";
|
|
160
|
+
const deploy = (deployProjectNames, operator, config) => __async(void 0, null, function* () {
|
|
161
|
+
const { rootPath, packageManager, deployPath = defaultDeployPath } = config;
|
|
130
162
|
const realDeployPath = path.isAbsolute(deployPath) ? deployPath : path.join(rootPath, deployPath);
|
|
131
|
-
|
|
132
|
-
|
|
163
|
+
import_node_core_library.FileSystem.deleteFolder(realDeployPath);
|
|
133
164
|
for (const deployProjectName of deployProjectNames) {
|
|
134
165
|
const currentProject = operator.getNodeData(deployProjectName, {
|
|
135
166
|
checkExist: true
|
|
136
167
|
});
|
|
137
168
|
const alldeps = operator.getNodeAllDependencyData(deployProjectName);
|
|
138
|
-
const copyMap = createCopyMap(
|
|
139
|
-
|
|
140
|
-
|
|
169
|
+
const copyMap = createCopyMap(
|
|
170
|
+
rootPath,
|
|
171
|
+
currentProject,
|
|
172
|
+
alldeps,
|
|
173
|
+
realDeployPath
|
|
174
|
+
);
|
|
175
|
+
yield checkAndRunDeployCommand(rootPath, currentProject, packageManager);
|
|
176
|
+
import_node_core_library.FileSystem.ensureFolder(realDeployPath);
|
|
141
177
|
for (const [from, to] of copyMap) {
|
|
142
|
-
|
|
143
|
-
_nodeCoreLibrary.FileSystem.copyFiles({
|
|
178
|
+
import_node_core_library.FileSystem.copyFiles({
|
|
144
179
|
sourcePath: from,
|
|
145
180
|
destinationPath: to,
|
|
146
|
-
// If true, then when copying symlinks, copy the target object instead of copying the link.
|
|
147
181
|
dereferenceSymlinks: false,
|
|
148
182
|
filter(filePath) {
|
|
149
|
-
if (excludeDirs(filePath, [
|
|
183
|
+
if (excludeDirs(filePath, ["node_modules", "dist"])) {
|
|
150
184
|
return false;
|
|
151
185
|
}
|
|
152
186
|
return true;
|
|
@@ -155,8 +189,9 @@ const deploy = async (deployProjectNames, operator, config) => {
|
|
|
155
189
|
}
|
|
156
190
|
}
|
|
157
191
|
generatorAndCopyRequiredFiles(rootPath, realDeployPath);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
192
|
+
import_utils.logger.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
|
|
193
|
+
});
|
|
194
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
195
|
+
0 && (module.exports = {
|
|
196
|
+
deploy
|
|
197
|
+
});
|
|
@@ -1,10 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var cmds_exports = {};
|
|
19
|
+
__export(cmds_exports, {
|
|
20
|
+
defaultBuildWatchCmds: () => defaultBuildWatchCmds
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(cmds_exports);
|
|
23
|
+
const defaultBuildWatchCmds = ["dev", "build"];
|
|
24
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
25
|
+
0 && (module.exports = {
|
|
26
|
+
defaultBuildWatchCmds
|
|
5
27
|
});
|
|
6
|
-
exports.defaultBuildWatchCmds = void 0;
|
|
7
|
-
// TODO: 第一个参数是否也需要为一个string[]
|
|
8
|
-
|
|
9
|
-
const defaultBuildWatchCmds = ['dev', 'build'];
|
|
10
|
-
exports.defaultBuildWatchCmds = defaultBuildWatchCmds;
|
|
@@ -1,39 +1,73 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
+
var __async = (__this, __arguments, generator) => {
|
|
25
|
+
return new Promise((resolve, reject) => {
|
|
26
|
+
var fulfilled = (value) => {
|
|
27
|
+
try {
|
|
28
|
+
step(generator.next(value));
|
|
29
|
+
} catch (e) {
|
|
30
|
+
reject(e);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
var rejected = (value) => {
|
|
34
|
+
try {
|
|
35
|
+
step(generator.throw(value));
|
|
36
|
+
} catch (e) {
|
|
37
|
+
reject(e);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
41
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var create_task_exports = {};
|
|
45
|
+
__export(create_task_exports, {
|
|
46
|
+
createDependenciesTask: () => createDependenciesTask,
|
|
47
|
+
createDevTask: () => createDevTask
|
|
5
48
|
});
|
|
6
|
-
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var timeLog =
|
|
10
|
-
var
|
|
11
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
12
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
49
|
+
module.exports = __toCommonJS(create_task_exports);
|
|
50
|
+
var import_utils = require("@modern-js/utils");
|
|
51
|
+
var import_error = require("../../log/error");
|
|
52
|
+
var timeLog = __toESM(require("../../log/time"));
|
|
53
|
+
var import_cmds = require("./cmds");
|
|
13
54
|
const getFinalTaskCmds = (taskCmds, project) => {
|
|
14
55
|
let finalTaskCmds = [];
|
|
15
|
-
// case1: ["build"]
|
|
16
|
-
// case2: ["dev", "build"]
|
|
17
|
-
// case3: ["dev", () => []]
|
|
18
|
-
// default: ['dev', 'build']
|
|
19
56
|
if (taskCmds.length === 1) {
|
|
20
57
|
finalTaskCmds = [taskCmds[0]];
|
|
21
|
-
} else if (taskCmds.length === 2 && typeof taskCmds[0] ===
|
|
58
|
+
} else if (taskCmds.length === 2 && typeof taskCmds[0] === "string" && typeof taskCmds[1] === "string") {
|
|
22
59
|
finalTaskCmds = [taskCmds[1]];
|
|
23
|
-
} else if (taskCmds.length === 2 && typeof taskCmds[0] ===
|
|
60
|
+
} else if (taskCmds.length === 2 && typeof taskCmds[0] === "string" && typeof taskCmds[1] === "function") {
|
|
24
61
|
finalTaskCmds = taskCmds[1](project);
|
|
25
62
|
} else {
|
|
26
|
-
|
|
27
|
-
finalTaskCmds = ['build'];
|
|
63
|
+
finalTaskCmds = ["build"];
|
|
28
64
|
}
|
|
29
65
|
return finalTaskCmds;
|
|
30
66
|
};
|
|
31
|
-
const createDependenciesTask = (config, taskCmds =
|
|
32
|
-
const {
|
|
33
|
-
packageManager
|
|
34
|
-
} = config;
|
|
67
|
+
const createDependenciesTask = (config, taskCmds = import_cmds.defaultBuildWatchCmds, taskLogger) => {
|
|
68
|
+
const { packageManager } = config;
|
|
35
69
|
const timelogInstance = timeLog.initTimeLog();
|
|
36
|
-
const task =
|
|
70
|
+
const task = (project) => __async(void 0, null, function* () {
|
|
37
71
|
const finalTaskCmds = getFinalTaskCmds(taskCmds, project);
|
|
38
72
|
const cmd = project.extra.scripts || {};
|
|
39
73
|
for (const taskCmd of finalTaskCmds) {
|
|
@@ -41,64 +75,59 @@ const createDependenciesTask = (config, taskCmds = _cmds.defaultBuildWatchCmds,
|
|
|
41
75
|
const prefix = `run ${project.name} ${taskCmd} script`;
|
|
42
76
|
timeLog.startTime(timelogInstance, prefix);
|
|
43
77
|
try {
|
|
44
|
-
const childProcess = (0,
|
|
78
|
+
const childProcess = (0, import_utils.execa)(packageManager, [taskCmd], {
|
|
45
79
|
cwd: project.extra.path,
|
|
46
|
-
stdio: [
|
|
80
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
47
81
|
});
|
|
48
82
|
taskLogger.addLogProvider(project.name, {
|
|
49
83
|
stdout: childProcess.stdout,
|
|
50
84
|
stderr: childProcess.stderr,
|
|
51
|
-
logConfig: {
|
|
52
|
-
label: 'WATCH: '
|
|
53
|
-
}
|
|
85
|
+
logConfig: { label: "WATCH: " }
|
|
54
86
|
});
|
|
55
|
-
|
|
87
|
+
yield childProcess;
|
|
56
88
|
} catch (e) {
|
|
57
|
-
(0,
|
|
89
|
+
(0, import_error.errorLog)(project.name, e);
|
|
58
90
|
}
|
|
59
91
|
timeLog.endTime(timelogInstance, prefix);
|
|
60
92
|
} else {
|
|
61
|
-
|
|
93
|
+
import_utils.logger.info(`${project.name} not have ${taskCmd}, skip it.`);
|
|
62
94
|
}
|
|
63
95
|
}
|
|
64
|
-
};
|
|
96
|
+
});
|
|
65
97
|
return task;
|
|
66
98
|
};
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const {
|
|
70
|
-
packageManager
|
|
71
|
-
} = config;
|
|
72
|
-
const task = async project => {
|
|
99
|
+
const createDevTask = (config, taskCmds = import_cmds.defaultBuildWatchCmds, taskLogger) => {
|
|
100
|
+
const { packageManager } = config;
|
|
101
|
+
const task = (project) => __async(void 0, null, function* () {
|
|
73
102
|
const devCmds = [taskCmds[0]];
|
|
74
103
|
const cmd = project.extra.scripts || {};
|
|
75
104
|
for (const taskCmd of devCmds) {
|
|
76
105
|
if (cmd[taskCmd]) {
|
|
77
|
-
// const prefix = `run ${project.name} ${taskCmd} script`;
|
|
78
|
-
// log.info(prefix);
|
|
79
106
|
try {
|
|
80
|
-
const childProcess = (0,
|
|
107
|
+
const childProcess = (0, import_utils.execa)(packageManager, [taskCmd], {
|
|
81
108
|
cwd: project.extra.path,
|
|
82
|
-
stdio:
|
|
109
|
+
stdio: "pipe",
|
|
83
110
|
all: true
|
|
84
111
|
});
|
|
85
112
|
taskLogger.addLogProvider(project.name, {
|
|
86
113
|
stdout: childProcess.stdout,
|
|
87
114
|
stderr: childProcess.stderr,
|
|
88
|
-
logConfig: {
|
|
89
|
-
label: `${taskCmd.toUpperCase()}: `
|
|
90
|
-
}
|
|
115
|
+
logConfig: { label: `${taskCmd.toUpperCase()}: ` }
|
|
91
116
|
});
|
|
92
|
-
const ret =
|
|
117
|
+
const ret = yield childProcess;
|
|
93
118
|
console.info(ret);
|
|
94
119
|
} catch (e) {
|
|
95
|
-
(0,
|
|
120
|
+
(0, import_error.errorLog)(project.name, e);
|
|
96
121
|
}
|
|
97
122
|
} else {
|
|
98
|
-
|
|
123
|
+
import_utils.logger.info(`${project.name} not have ${taskCmd}, skip it.`);
|
|
99
124
|
}
|
|
100
125
|
}
|
|
101
|
-
};
|
|
126
|
+
});
|
|
102
127
|
return task;
|
|
103
128
|
};
|
|
104
|
-
|
|
129
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
130
|
+
0 && (module.exports = {
|
|
131
|
+
createDependenciesTask,
|
|
132
|
+
createDevTask
|
|
133
|
+
});
|