@modern-js/monorepo-tools 1.4.0 → 1.4.3
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/.eslintrc.js +8 -0
- package/CHANGELOG.md +68 -0
- package/dist/js/modern/cli/build-watch.js +3 -3
- package/dist/js/modern/cli/build.js +2 -2
- package/dist/js/modern/cli/clear.js +2 -2
- package/dist/js/modern/cli/deploy.js +2 -2
- package/dist/js/modern/cli/install.js +2 -2
- package/dist/js/modern/commands/build-watch.js +2 -4
- package/dist/js/modern/commands/build.js +2 -4
- package/dist/js/modern/commands/clear.js +3 -5
- package/dist/js/modern/commands/deploy.js +5 -6
- package/dist/js/modern/commands/install.js +2 -4
- package/dist/js/modern/dag/utils.js +0 -1
- package/dist/js/modern/features/build/index.js +2 -3
- package/dist/js/modern/features/deploy/index.js +3 -8
- package/dist/js/modern/features/dev/create-task.js +1 -2
- package/dist/js/modern/features/dev/index.js +1 -2
- package/dist/js/modern/features/install/index.js +3 -7
- package/dist/js/modern/hooks/index.js +2 -5
- package/dist/js/modern/index.js +22 -22
- package/dist/js/modern/log/multi-tasks-log.js +1 -1
- package/dist/js/modern/log/time.js +1 -1
- package/dist/js/modern/projects/get-projects-by-workspace-file.js +13 -6
- package/dist/js/modern/utils/install.js +1 -2
- package/dist/js/node/cli/build-watch.js +3 -3
- package/dist/js/node/cli/build.js +2 -2
- package/dist/js/node/cli/clear.js +2 -2
- package/dist/js/node/cli/deploy.js +2 -2
- package/dist/js/node/cli/install.js +2 -2
- package/dist/js/node/commands/build-watch.js +2 -5
- package/dist/js/node/commands/build.js +2 -5
- package/dist/js/node/commands/clear.js +3 -6
- package/dist/js/node/commands/deploy.js +5 -7
- package/dist/js/node/commands/install.js +2 -5
- package/dist/js/node/dag/utils.js +0 -1
- package/dist/js/node/features/build/index.js +5 -7
- package/dist/js/node/features/deploy/index.js +6 -16
- package/dist/js/node/features/dev/create-task.js +2 -6
- package/dist/js/node/features/dev/index.js +3 -5
- package/dist/js/node/features/install/index.js +4 -11
- package/dist/js/node/hooks/index.js +4 -10
- package/dist/js/node/index.js +25 -29
- package/dist/js/node/log/multi-tasks-log.js +4 -4
- package/dist/js/node/log/time.js +2 -2
- package/dist/js/node/projects/get-projects-by-workspace-file.js +16 -9
- package/dist/js/node/utils/install.js +2 -6
- package/dist/types/cli/build-watch.d.ts +3 -2
- package/dist/types/cli/build.d.ts +3 -2
- package/dist/types/cli/clear.d.ts +3 -2
- package/dist/types/cli/deploy.d.ts +3 -2
- package/dist/types/cli/install.d.ts +3 -2
- package/dist/types/cli/new.d.ts +1 -1
- package/dist/types/commands/build-watch.d.ts +2 -1
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/clear.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/install.d.ts +2 -1
- package/dist/types/hooks/index.d.ts +7 -1
- package/dist/types/index.d.ts +2 -3
- package/dist/types/log/time.d.ts +2 -2
- package/jest.config.js +0 -1
- package/package.json +9 -17
- package/tests/index.test.ts +0 -7
- package/tests/tsconfig.json +0 -13
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.deploy = void 0;
|
|
7
7
|
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
9
|
-
|
|
10
8
|
var _utils = require("@modern-js/utils");
|
|
11
9
|
|
|
12
10
|
var _dag = require("../dag");
|
|
@@ -17,14 +15,13 @@ var _getProjects = require("../projects/get-projects");
|
|
|
17
15
|
|
|
18
16
|
var _deploy = require("../features/deploy");
|
|
19
17
|
|
|
20
|
-
const deploy = async (deployProjectNames, option, ignoreMatchs = []) => {
|
|
18
|
+
const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
|
|
21
19
|
const {
|
|
22
20
|
deployPath = 'output'
|
|
23
|
-
} = option;
|
|
24
|
-
|
|
21
|
+
} = option;
|
|
25
22
|
const {
|
|
26
23
|
appDirectory
|
|
27
|
-
} =
|
|
24
|
+
} = api.useAppContext();
|
|
28
25
|
|
|
29
26
|
_utils.logger.info(`start deploy ${deployProjectNames.join(',')}`);
|
|
30
27
|
|
|
@@ -44,7 +41,8 @@ const deploy = async (deployProjectNames, option, ignoreMatchs = []) => {
|
|
|
44
41
|
packageManager,
|
|
45
42
|
deployPath
|
|
46
43
|
});
|
|
47
|
-
|
|
44
|
+
const runners = api.useHookRunners();
|
|
45
|
+
runners.afterMonorepoDeploy({
|
|
48
46
|
operator,
|
|
49
47
|
deployProjectNames
|
|
50
48
|
});
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.install = void 0;
|
|
7
7
|
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
9
|
-
|
|
10
8
|
var _install = require("../features/install");
|
|
11
9
|
|
|
12
10
|
var _monorepo = require("../parse-config/monorepo");
|
|
@@ -15,11 +13,10 @@ var _getProjects = require("../projects/get-projects");
|
|
|
15
13
|
|
|
16
14
|
var _dag = require("../dag");
|
|
17
15
|
|
|
18
|
-
const install = async (projectNames = [], option) => {
|
|
19
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
16
|
+
const install = async (projectNames = [], option, api) => {
|
|
20
17
|
const {
|
|
21
18
|
appDirectory
|
|
22
|
-
} =
|
|
19
|
+
} = api.useAppContext();
|
|
23
20
|
const {
|
|
24
21
|
auto
|
|
25
22
|
} = option;
|
|
@@ -7,9 +7,7 @@ exports.runBuildTask = exports.runAllBuildTask = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _os = _interopRequireDefault(require("os"));
|
|
9
9
|
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var _signale = _interopRequireDefault(require("signale"));
|
|
10
|
+
var _utils = require("@modern-js/utils");
|
|
13
11
|
|
|
14
12
|
var _checkProjectChange = require("../../projects/check-project-change");
|
|
15
13
|
|
|
@@ -25,7 +23,7 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
|
25
23
|
packageManager,
|
|
26
24
|
disableContentHash = false,
|
|
27
25
|
enableGitHash = false
|
|
28
|
-
} = config;
|
|
26
|
+
} = config;
|
|
29
27
|
|
|
30
28
|
const task = async project => {
|
|
31
29
|
console.info('run ', project.name); // const taskTimeLog = timeLog.initTimeLog({ scope: '' });
|
|
@@ -56,10 +54,10 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
|
56
54
|
if (cmd[taskCmd]) {
|
|
57
55
|
const prefix = `run ${project.name} ${taskCmd} script`; // timeLog.startTime(taskTimeLog, prefix);
|
|
58
56
|
|
|
59
|
-
|
|
57
|
+
_utils.signale.time(prefix);
|
|
60
58
|
|
|
61
59
|
try {
|
|
62
|
-
const childProcess = (0,
|
|
60
|
+
const childProcess = (0, _utils.execa)(packageManager, [taskCmd], {
|
|
63
61
|
cwd: project.extra.path,
|
|
64
62
|
stdio: ['pipe', 'pipe', 'pipe']
|
|
65
63
|
});
|
|
@@ -72,7 +70,7 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
|
72
70
|
});
|
|
73
71
|
await childProcess; // timeLog.endTime(taskTimeLog, prefix);
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
_utils.signale.timeEnd(prefix);
|
|
76
74
|
} catch (e) {
|
|
77
75
|
(0, _error.errorLog)(project.name, e.message);
|
|
78
76
|
}
|
|
@@ -9,18 +9,10 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _nodeCoreLibrary = require("@rushstack/node-core-library");
|
|
11
11
|
|
|
12
|
-
var _execa = _interopRequireDefault(require("execa"));
|
|
13
|
-
|
|
14
|
-
var _signale = require("signale");
|
|
15
|
-
|
|
16
|
-
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
17
|
-
|
|
18
12
|
var _utils = require("@modern-js/utils");
|
|
19
13
|
|
|
20
14
|
var _constants = require("../../constants");
|
|
21
15
|
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
16
|
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); }
|
|
25
17
|
|
|
26
18
|
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; }
|
|
@@ -58,15 +50,13 @@ const checkAndUpdatePMWorkspaces = deployDir => {
|
|
|
58
50
|
const pnpmWp = path.join(deployDir, _constants.WORKSPACE_FILE.PNPM);
|
|
59
51
|
|
|
60
52
|
if (_utils.fs.existsSync(pnpmWp)) {
|
|
61
|
-
|
|
62
|
-
const pnpmWorkspace = _jsYaml.default.load(_utils.fs.readFileSync(pnpmWp, 'utf-8'));
|
|
53
|
+
const pnpmWorkspace = _utils.yaml.load(_utils.fs.readFileSync(pnpmWp, 'utf-8'));
|
|
63
54
|
|
|
64
55
|
if (pnpmWorkspace.packages && Array.isArray(pnpmWorkspace.packages)) {
|
|
65
56
|
pnpmWorkspace.packages.push('apps/**');
|
|
66
|
-
}
|
|
67
|
-
|
|
57
|
+
}
|
|
68
58
|
|
|
69
|
-
_utils.fs.writeFileSync(pnpmWp,
|
|
59
|
+
_utils.fs.writeFileSync(pnpmWp, _utils.yaml.dump(pnpmWorkspace));
|
|
70
60
|
}
|
|
71
61
|
|
|
72
62
|
const pkgPath = path.join(deployDir, _constants.WORKSPACE_FILE.YARN);
|
|
@@ -116,7 +106,7 @@ const checkAndRunDeployCommand = async (monorepoPath, targetProject, packageMana
|
|
|
116
106
|
}
|
|
117
107
|
|
|
118
108
|
const cwd = packageManager === 'npm' ? targetProject.extra.path : monorepoPath;
|
|
119
|
-
const childProcess = (0,
|
|
109
|
+
const childProcess = (0, _utils.execa)(packageManager, runDeployCommands, {
|
|
120
110
|
cwd,
|
|
121
111
|
stdio: ['pipe']
|
|
122
112
|
});
|
|
@@ -148,7 +138,7 @@ const installDependency = async (deployDir, packageManager) => {
|
|
|
148
138
|
|
|
149
139
|
_utils.logger.log(_utils.chalk.rgb(218, 152, 92)('Install Log:\n'));
|
|
150
140
|
|
|
151
|
-
const childProcess = (0,
|
|
141
|
+
const childProcess = (0, _utils.execa)(packageManager, commands, {
|
|
152
142
|
stdio: 'inherit',
|
|
153
143
|
cwd: deployDir,
|
|
154
144
|
env: {
|
|
@@ -205,7 +195,7 @@ const deploy = async (deployProjectNames, operator, config) => {
|
|
|
205
195
|
|
|
206
196
|
generatorAndCopyRequiredFiles(rootPath, realDeployPath); // await installDependency(realDeployPath, packageManager);
|
|
207
197
|
|
|
208
|
-
|
|
198
|
+
_utils.signale.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
|
|
209
199
|
};
|
|
210
200
|
|
|
211
201
|
exports.deploy = deploy;
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.createDevTask = exports.createDependenciesTask = void 0;
|
|
7
7
|
|
|
8
|
-
var _execa = _interopRequireDefault(require("execa"));
|
|
9
|
-
|
|
10
8
|
var _utils = require("@modern-js/utils");
|
|
11
9
|
|
|
12
10
|
var _error = require("../../log/error");
|
|
@@ -19,8 +17,6 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
19
17
|
|
|
20
18
|
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; }
|
|
21
19
|
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
20
|
const getFinalTaskCmds = (taskCmds, project) => {
|
|
25
21
|
let finalTaskCmds = []; // case1: ["build"]
|
|
26
22
|
// case2: ["dev", "build"]
|
|
@@ -57,7 +53,7 @@ const createDependenciesTask = (config, taskCmds = _cmds.defaultBuildWatchCmds,
|
|
|
57
53
|
timeLog.startTime(timelogInstance, prefix);
|
|
58
54
|
|
|
59
55
|
try {
|
|
60
|
-
const childProcess = (0,
|
|
56
|
+
const childProcess = (0, _utils.execa)(packageManager, [taskCmd], {
|
|
61
57
|
cwd: project.extra.path,
|
|
62
58
|
stdio: ['pipe', 'pipe', 'pipe']
|
|
63
59
|
});
|
|
@@ -99,7 +95,7 @@ const createDevTask = (config, taskCmds = _cmds.defaultBuildWatchCmds, taskLogge
|
|
|
99
95
|
// const prefix = `run ${project.name} ${taskCmd} script`;
|
|
100
96
|
// log.info(prefix);
|
|
101
97
|
try {
|
|
102
|
-
const childProcess = (0,
|
|
98
|
+
const childProcess = (0, _utils.execa)(packageManager, [taskCmd], {
|
|
103
99
|
cwd: project.extra.path,
|
|
104
100
|
stdio: 'pipe',
|
|
105
101
|
all: true
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.runBuildWatchTask = void 0;
|
|
7
7
|
|
|
8
|
-
var _nodeCoreLibrary = require("@rushstack/node-core-library");
|
|
9
|
-
|
|
10
8
|
var _anymatch = _interopRequireDefault(require("anymatch"));
|
|
11
9
|
|
|
10
|
+
var _utils = require("@modern-js/utils");
|
|
11
|
+
|
|
12
12
|
var _multiTasksLog = require("../../log/multi-tasks-log");
|
|
13
13
|
|
|
14
14
|
var _watchProjectsState = require("./watch-projects-state");
|
|
@@ -19,8 +19,6 @@ var _createTask = require("./create-task");
|
|
|
19
19
|
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
|
|
22
|
-
const chokidar = _nodeCoreLibrary.Import.lazy('chokidar', require);
|
|
23
|
-
|
|
24
22
|
const getIgnored = config => watchFilePath => {
|
|
25
23
|
// 默认忽略 node_modules 的变化和 dist 目录下文件的变化
|
|
26
24
|
const nodeModulesPattern = /(?:^|[\\/])node_modules/g;
|
|
@@ -45,7 +43,7 @@ const runBuildWatchTask = async (projectName, operator, config, taskCmds = _cmds
|
|
|
45
43
|
const devTask = (0, _createTask.createDevTask)(config, taskCmds, taskLogger);
|
|
46
44
|
const fromNodes = operator.getNodeAllDependencyData(projectName);
|
|
47
45
|
const watchedProjectState = new _watchProjectsState.WatchedProjectsState(fromNodes, config);
|
|
48
|
-
const watcher = new chokidar.FSWatcher({
|
|
46
|
+
const watcher = new _utils.chokidar.FSWatcher({
|
|
49
47
|
persistent: true,
|
|
50
48
|
cwd: config.rootPath,
|
|
51
49
|
followSymlinks: false,
|
|
@@ -9,16 +9,12 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
|
11
11
|
|
|
12
|
-
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
13
|
-
|
|
14
12
|
var _nodeCoreLibrary = require("@rushstack/node-core-library");
|
|
15
13
|
|
|
16
14
|
var _constants = require("../../constants");
|
|
17
15
|
|
|
18
16
|
var _install = require("../../utils/install");
|
|
19
17
|
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
18
|
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); }
|
|
23
19
|
|
|
24
20
|
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; }
|
|
@@ -31,19 +27,16 @@ const replaceWorkspaces = ({
|
|
|
31
27
|
const pnpmWsFilePath = path.join(rootPath, _constants.WORKSPACE_FILE.PNPM);
|
|
32
28
|
|
|
33
29
|
if (_utils.fs.existsSync(pnpmWsFilePath)) {
|
|
34
|
-
const pnpmWorkspace = _utils.fs.readFileSync(pnpmWsFilePath, 'utf-8');
|
|
35
|
-
|
|
30
|
+
const pnpmWorkspace = _utils.fs.readFileSync(pnpmWsFilePath, 'utf-8');
|
|
36
31
|
|
|
37
|
-
const orignalPnpmWorkspaces =
|
|
32
|
+
const orignalPnpmWorkspaces = _utils.yaml.load(pnpmWorkspace);
|
|
38
33
|
|
|
39
|
-
_utils.fs.writeFileSync(pnpmWsFilePath,
|
|
40
|
-
_jsYaml.default.dump({
|
|
34
|
+
_utils.fs.writeFileSync(pnpmWsFilePath, _utils.yaml.dump({
|
|
41
35
|
packages: projectsInWorkspacs
|
|
42
36
|
}));
|
|
43
37
|
|
|
44
38
|
return () => {
|
|
45
|
-
|
|
46
|
-
_jsYaml.default.dump(orignalPnpmWorkspaces);
|
|
39
|
+
_utils.yaml.dump(orignalPnpmWorkspaces);
|
|
47
40
|
};
|
|
48
41
|
}
|
|
49
42
|
|
|
@@ -3,18 +3,12 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
6
|
+
exports.hooks = void 0;
|
|
9
7
|
|
|
10
8
|
var _plugin = require("@modern-js/plugin");
|
|
11
9
|
|
|
12
10
|
const afterMonorepoDeploy = (0, _plugin.createAsyncWorkflow)();
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(0, _core.registerHook)({
|
|
16
|
-
afterMonorepoDeploy
|
|
17
|
-
});
|
|
11
|
+
const hooks = {
|
|
12
|
+
afterMonorepoDeploy
|
|
18
13
|
};
|
|
19
|
-
|
|
20
|
-
exports.lifecycle = lifecycle;
|
|
14
|
+
exports.hooks = hooks;
|
package/dist/js/node/index.js
CHANGED
|
@@ -4,14 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
Object.defineProperty(exports, "defineConfig", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _core.defineConfig;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
7
|
|
|
14
|
-
var
|
|
8
|
+
var _pluginChangeset = _interopRequireDefault(require("@modern-js/plugin-changeset"));
|
|
15
9
|
|
|
16
10
|
var _locale = require("./locale");
|
|
17
11
|
|
|
@@ -21,28 +15,30 @@ var _language = require("./utils/language");
|
|
|
21
15
|
|
|
22
16
|
var _hooks = require("./hooks");
|
|
23
17
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
(0,
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
|
|
20
|
+
var _default = () => ({
|
|
21
|
+
name: '@modern-js/monorepo-tools',
|
|
22
|
+
usePlugins: [(0, _pluginChangeset.default)()],
|
|
23
|
+
registerHook: _hooks.hooks,
|
|
24
|
+
setup: api => {
|
|
25
|
+
const locale = (0, _language.getLocaleLanguage)();
|
|
26
|
+
|
|
27
|
+
_locale.i18n.changeLanguage({
|
|
28
|
+
locale
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
commands({
|
|
33
|
+
program
|
|
34
|
+
}) {
|
|
35
|
+
(0, _cli.clearCli)(program, api);
|
|
36
|
+
(0, _cli.deployCli)(program, api);
|
|
37
|
+
(0, _cli.newCli)(program, locale);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
};
|
|
41
|
+
},
|
|
46
42
|
post: ['@modern-js/plugin-changeset']
|
|
47
43
|
});
|
|
48
44
|
|
|
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.MultitasksLogger = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var _utils2 = require("./utils");
|
|
11
11
|
|
|
12
12
|
const createLogger = (name, config) => {
|
|
13
13
|
const options = {
|
|
@@ -20,7 +20,7 @@ const createLogger = (name, config) => {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
-
return new
|
|
23
|
+
return new _utils.Signale(options);
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
const createListenHandler = (name, config) => {
|
|
@@ -29,7 +29,7 @@ const createListenHandler = (name, config) => {
|
|
|
29
29
|
|
|
30
30
|
const stdout = chunk => {
|
|
31
31
|
// console.info(chunk.toString().split(/\r\n|\n\r|\r|\n/g).length);
|
|
32
|
-
logger.info((0,
|
|
32
|
+
logger.info((0, _utils2.formatLog)(chunk.toString()));
|
|
33
33
|
}; // eslint-disable-next-line node/prefer-global/buffer
|
|
34
34
|
|
|
35
35
|
|
package/dist/js/node/log/time.js
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.startTime = exports.initTimeLog = exports.endTime = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
9
|
|
|
10
10
|
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; }
|
|
11
11
|
|
|
@@ -13,7 +13,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
13
13
|
|
|
14
14
|
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; }
|
|
15
15
|
|
|
16
|
-
const initTimeLog = (option = {}) => new
|
|
16
|
+
const initTimeLog = (option = {}) => new _utils.Signale(_objectSpread({
|
|
17
17
|
interactive: true,
|
|
18
18
|
scope: 'time-log'
|
|
19
19
|
}, option));
|
|
@@ -11,16 +11,12 @@ var _nodeCoreLibrary = require("@rushstack/node-core-library");
|
|
|
11
11
|
|
|
12
12
|
var _utils = require("@modern-js/utils");
|
|
13
13
|
|
|
14
|
-
var _jsYaml = _interopRequireDefault(require("js-yaml"));
|
|
15
|
-
|
|
16
14
|
var _monorepo = require("../parse-config/monorepo");
|
|
17
15
|
|
|
18
16
|
var _constants = require("../constants");
|
|
19
17
|
|
|
20
18
|
var _getProjectsByPackagesConfig = require("./get-projects-by-packages-config");
|
|
21
19
|
|
|
22
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
|
-
|
|
24
20
|
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); }
|
|
25
21
|
|
|
26
22
|
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; }
|
|
@@ -43,9 +39,9 @@ const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
|
|
|
43
39
|
let packagesConfig = [];
|
|
44
40
|
|
|
45
41
|
if (workspaceFile === _constants.WORKSPACE_FILE.PNPM) {
|
|
46
|
-
const yamlString = await _nodeCoreLibrary.FileSystem.readFileAsync(path.resolve('/', rootPath, workspaceFile)).then(data => data.toString());
|
|
42
|
+
const yamlString = await _nodeCoreLibrary.FileSystem.readFileAsync(path.resolve('/', rootPath, workspaceFile)).then(data => data.toString());
|
|
47
43
|
|
|
48
|
-
const pnpmWorkspace =
|
|
44
|
+
const pnpmWorkspace = _utils.yaml.load(yamlString);
|
|
49
45
|
|
|
50
46
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
51
47
|
} else if (workspaceFile === _constants.WORKSPACE_FILE.YARN) {
|
|
@@ -54,6 +50,12 @@ const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs) => {
|
|
|
54
50
|
const pkgJson = _nodeCoreLibrary.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
55
51
|
|
|
56
52
|
packagesConfig = (pkgJson === null || pkgJson === void 0 ? void 0 : (_pkgJson$workspaces = pkgJson.workspaces) === null || _pkgJson$workspaces === void 0 ? void 0 : _pkgJson$workspaces.packages) || [];
|
|
53
|
+
} else if (workspaceFile === _constants.WORKSPACE_FILE.LERNA) {
|
|
54
|
+
var _lernaJson$packages;
|
|
55
|
+
|
|
56
|
+
const lernaJson = _nodeCoreLibrary.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
57
|
+
|
|
58
|
+
packagesConfig = (_lernaJson$packages = lernaJson.packages) !== null && _lernaJson$packages !== void 0 ? _lernaJson$packages : [];
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
const projects = await (0, _getProjectsByPackagesConfig.getProjetsByPackageConfig)(rootPath, packagesConfig, ignoreConfigs);
|
|
@@ -80,10 +82,9 @@ const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
|
|
|
80
82
|
let packagesConfig = [];
|
|
81
83
|
|
|
82
84
|
if (workspaceFile === _constants.WORKSPACE_FILE.PNPM) {
|
|
83
|
-
const yamlString = _utils.fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
|
|
85
|
+
const yamlString = _utils.fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
|
|
84
86
|
|
|
85
|
-
|
|
86
|
-
const pnpmWorkspace = _jsYaml.default.load(yamlString);
|
|
87
|
+
const pnpmWorkspace = _utils.yaml.load(yamlString);
|
|
87
88
|
|
|
88
89
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
89
90
|
} else if (workspaceFile === _constants.WORKSPACE_FILE.YARN) {
|
|
@@ -92,6 +93,12 @@ const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
|
|
|
92
93
|
const pkgJson = _nodeCoreLibrary.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
93
94
|
|
|
94
95
|
packagesConfig = (pkgJson === null || pkgJson === void 0 ? void 0 : (_pkgJson$workspaces2 = pkgJson.workspaces) === null || _pkgJson$workspaces2 === void 0 ? void 0 : _pkgJson$workspaces2.packages) || [];
|
|
96
|
+
} else if (workspaceFile === _constants.WORKSPACE_FILE.LERNA) {
|
|
97
|
+
var _lernaJson$packages2;
|
|
98
|
+
|
|
99
|
+
const lernaJson = _nodeCoreLibrary.JsonFile.load(path.resolve(rootPath, workspaceFile));
|
|
100
|
+
|
|
101
|
+
packagesConfig = (_lernaJson$packages2 = lernaJson.packages) !== null && _lernaJson$packages2 !== void 0 ? _lernaJson$packages2 : [];
|
|
95
102
|
}
|
|
96
103
|
|
|
97
104
|
const projects = (0, _getProjectsByPackagesConfig.syncGetProjetsByPackageConfig)(rootPath, packagesConfig, ignoreConfigs);
|
|
@@ -9,12 +9,8 @@ var path = _interopRequireWildcard(require("path"));
|
|
|
9
9
|
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
|
11
11
|
|
|
12
|
-
var _execa = _interopRequireDefault(require("execa"));
|
|
13
|
-
|
|
14
12
|
var _constants = require("../constants");
|
|
15
13
|
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
14
|
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); }
|
|
19
15
|
|
|
20
16
|
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; }
|
|
@@ -40,13 +36,13 @@ const installByPackageManager = async (packageManager, {
|
|
|
40
36
|
}
|
|
41
37
|
|
|
42
38
|
if (packageManager === 'pnpm') {
|
|
43
|
-
await (0,
|
|
39
|
+
await (0, _utils.execa)('pnpm', ['install'], {
|
|
44
40
|
stdio: 'inherit'
|
|
45
41
|
});
|
|
46
42
|
}
|
|
47
43
|
|
|
48
44
|
if (packageManager === 'yarn') {
|
|
49
|
-
await (0,
|
|
45
|
+
await (0, _utils.execa)('yarn', ['install'], {
|
|
50
46
|
stdio: 'inherit'
|
|
51
47
|
});
|
|
52
48
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
2
|
+
import type { Command } from '@modern-js/utils';
|
|
3
|
+
export declare const buildWatchCli: (program: Command, api: PluginAPI) => void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
2
|
+
import type { Command } from '@modern-js/utils';
|
|
3
|
+
export declare const buildCli: (program: Command, api: PluginAPI) => void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Command } from '
|
|
2
|
-
|
|
1
|
+
import type { Command } from '@modern-js/utils';
|
|
2
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
3
|
+
export declare const clearCli: (program: Command, api: PluginAPI) => void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import { Command } from '
|
|
2
|
-
|
|
1
|
+
import type { Command } from '@modern-js/utils';
|
|
2
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
3
|
+
export declare const deployCli: (program: Command, api: PluginAPI) => void;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
2
|
+
import type { Command } from '@modern-js/utils';
|
|
3
|
+
export declare const installCli: (program: Command, api: PluginAPI) => void;
|
package/dist/types/cli/new.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Command } from '
|
|
1
|
+
import type { Command } from '@modern-js/utils';
|
|
2
2
|
export declare const newCli: (program: Command, locale?: string | undefined) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IBuildWatchCommandOption {
|
|
2
3
|
onlySelf?: boolean;
|
|
3
4
|
init?: boolean;
|
|
4
5
|
}
|
|
5
|
-
export declare const buildWatch: (targetProjectName: string, option: IBuildWatchCommandOption) => Promise<void>;
|
|
6
|
+
export declare const buildWatch: (targetProjectName: string, option: IBuildWatchCommandOption, api: PluginAPI) => Promise<void>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IBuildCommandOption {
|
|
2
3
|
self?: boolean;
|
|
3
4
|
dept?: boolean;
|
|
@@ -7,4 +8,4 @@ export interface IBuildCommandOption {
|
|
|
7
8
|
contentHash?: boolean;
|
|
8
9
|
gitHash?: boolean;
|
|
9
10
|
}
|
|
10
|
-
export declare const build: (targetProjectName: string, option: IBuildCommandOption) => Promise<void>;
|
|
11
|
+
export declare const build: (targetProjectName: string, option: IBuildCommandOption, api: PluginAPI) => Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IClearCommandOption {
|
|
2
3
|
removeDirs?: string[];
|
|
3
4
|
}
|
|
4
|
-
export declare const clear: (projectNames: string[], option: IClearCommandOption) => Promise<void>;
|
|
5
|
+
export declare const clear: (projectNames: string[], option: IClearCommandOption, api: PluginAPI) => Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IDeployCommandOption {
|
|
2
3
|
deployPath?: string;
|
|
3
4
|
}
|
|
4
|
-
export declare const deploy: (deployProjectNames: string[], option: IDeployCommandOption, ignoreMatchs?: string[]) => Promise<void>;
|
|
5
|
+
export declare const deploy: (api: PluginAPI, deployProjectNames: string[], option: IDeployCommandOption, ignoreMatchs?: string[]) => Promise<void>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import type { PluginAPI } from '@modern-js/core';
|
|
1
2
|
export interface IInstallCommandOption {
|
|
2
3
|
auto?: boolean;
|
|
3
4
|
}
|
|
4
|
-
export declare const install: (projectNames: string[] | undefined, option: IInstallCommandOption) => Promise<void>;
|
|
5
|
+
export declare const install: (projectNames: string[] | undefined, option: IInstallCommandOption, api: PluginAPI) => Promise<void>;
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DagOperator } from '../dag/operator';
|
|
2
|
+
export declare const hooks: {
|
|
3
|
+
afterMonorepoDeploy: import("@modern-js/plugin").AsyncWorkflow<{
|
|
4
|
+
operator: DagOperator;
|
|
5
|
+
deployProjectNames: string[];
|
|
6
|
+
}, void>;
|
|
7
|
+
};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/log/time.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare const initTimeLog: (option?:
|
|
1
|
+
import { Signale, SignaleOptions } from '@modern-js/utils';
|
|
2
|
+
export declare const initTimeLog: (option?: SignaleOptions) => import("@modern-js/utils/compiled/signale").Signale<import("@modern-js/utils/compiled/signale").DefaultMethods>;
|
|
3
3
|
export declare const startTime: (signaleInstance: Signale, prefix?: string) => void;
|
|
4
4
|
export declare const endTime: (signaleInstance: Signale, prefix?: string) => void;
|