@modern-js/monorepo-tools 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/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/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 +3 -6
- package/dist/js/modern/utils/install.js +1 -2
- 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/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 +4 -9
- package/dist/js/node/utils/install.js +2 -6
- package/dist/types/cli/build-watch.d.ts +1 -1
- package/dist/types/cli/build.d.ts +1 -1
- package/dist/types/cli/clear.d.ts +1 -1
- package/dist/types/cli/deploy.d.ts +1 -1
- package/dist/types/cli/install.d.ts +1 -1
- package/dist/types/cli/new.d.ts +1 -1
- package/dist/types/log/time.d.ts +2 -2
- package/jest.config.js +0 -1
- package/package.json +7 -15
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @modern-js/monorepo-tools
|
|
2
2
|
|
|
3
|
+
## 1.4.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 07a4887e: feat: prebundle commander and signale to @modern-js/utils
|
|
8
|
+
- Updated dependencies [60855eb2]
|
|
9
|
+
- Updated dependencies [ec1b7367]
|
|
10
|
+
- Updated dependencies [77ff9754]
|
|
11
|
+
- Updated dependencies [d2d1d6b2]
|
|
12
|
+
- Updated dependencies [07a4887e]
|
|
13
|
+
- Updated dependencies [ea2ae711]
|
|
14
|
+
- Updated dependencies [17d0cc46]
|
|
15
|
+
- Updated dependencies [d2d1d6b2]
|
|
16
|
+
- @modern-js/core@1.7.0
|
|
17
|
+
- @modern-js/utils@1.4.0
|
|
18
|
+
- @modern-js/plugin-i18n@1.2.3
|
|
19
|
+
- @modern-js/new-action@1.3.5
|
|
20
|
+
- @modern-js/plugin-changeset@1.2.4
|
|
21
|
+
|
|
3
22
|
## 1.4.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import os from 'os';
|
|
2
|
-
import execa from '
|
|
3
|
-
import signale from 'signale';
|
|
2
|
+
import { execa, signale } from '@modern-js/utils';
|
|
4
3
|
import { checkProjectChangeByGit, checkProjectChangeByContent } from "../../projects/check-project-change";
|
|
5
4
|
import { errorLog } from "../../log/error";
|
|
6
5
|
import { MultitasksLogger } from "../../log/multi-tasks-log";
|
|
@@ -11,7 +10,7 @@ const createTask = (config, taskCmds = defaultBuildCmds, taskLogger) => {
|
|
|
11
10
|
packageManager,
|
|
12
11
|
disableContentHash = false,
|
|
13
12
|
enableGitHash = false
|
|
14
|
-
} = config;
|
|
13
|
+
} = config;
|
|
15
14
|
|
|
16
15
|
const task = async project => {
|
|
17
16
|
console.info('run ', project.name); // const taskTimeLog = timeLog.initTimeLog({ scope: '' });
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import { FileSystem, JsonFile } from '@rushstack/node-core-library';
|
|
3
|
-
import execa from '
|
|
4
|
-
import { success } from 'signale';
|
|
5
|
-
import yaml from 'js-yaml';
|
|
6
|
-
import { fs, logger, chalk } from '@modern-js/utils';
|
|
3
|
+
import { fs, yaml, execa, logger, chalk, signale } from '@modern-js/utils';
|
|
7
4
|
import { WORKSPACE_FILE } from "../../constants";
|
|
8
5
|
|
|
9
6
|
const createCopyMap = (rootPath, targetProject, copyProjects, deployDir) => {
|
|
@@ -39,13 +36,11 @@ const checkAndUpdatePMWorkspaces = deployDir => {
|
|
|
39
36
|
const pnpmWp = path.join(deployDir, WORKSPACE_FILE.PNPM);
|
|
40
37
|
|
|
41
38
|
if (fs.existsSync(pnpmWp)) {
|
|
42
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
43
39
|
const pnpmWorkspace = yaml.load(fs.readFileSync(pnpmWp, 'utf-8'));
|
|
44
40
|
|
|
45
41
|
if (pnpmWorkspace.packages && Array.isArray(pnpmWorkspace.packages)) {
|
|
46
42
|
pnpmWorkspace.packages.push('apps/**');
|
|
47
|
-
}
|
|
48
|
-
|
|
43
|
+
}
|
|
49
44
|
|
|
50
45
|
fs.writeFileSync(pnpmWp, yaml.dump(pnpmWorkspace));
|
|
51
46
|
}
|
|
@@ -175,5 +170,5 @@ export const deploy = async (deployProjectNames, operator, config) => {
|
|
|
175
170
|
|
|
176
171
|
generatorAndCopyRequiredFiles(rootPath, realDeployPath); // await installDependency(realDeployPath, packageManager);
|
|
177
172
|
|
|
178
|
-
success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
|
|
173
|
+
signale.success(`Deploy success. The deploy dir is in '${rootPath}/output'`);
|
|
179
174
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { Import } from '@rushstack/node-core-library';
|
|
2
1
|
import anymatch from 'anymatch';
|
|
2
|
+
import { chokidar } from '@modern-js/utils';
|
|
3
3
|
import { MultitasksLogger } from "../../log/multi-tasks-log";
|
|
4
4
|
import { WatchedProjectsState } from "./watch-projects-state";
|
|
5
5
|
import { defaultBuildWatchCmds } from "./cmds";
|
|
6
6
|
import { createDependenciesTask, createDevTask } from "./create-task";
|
|
7
|
-
const chokidar = Import.lazy('chokidar', require);
|
|
8
7
|
|
|
9
8
|
const getIgnored = config => watchFilePath => {
|
|
10
9
|
// 默认忽略 node_modules 的变化和 dist 目录下文件的变化
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { fs } from '@modern-js/utils';
|
|
3
|
-
import yaml from 'js-yaml';
|
|
2
|
+
import { fs, yaml } from '@modern-js/utils';
|
|
4
3
|
import { JsonFile } from '@rushstack/node-core-library';
|
|
5
4
|
import { WORKSPACE_FILE } from "../../constants";
|
|
6
5
|
import { installByPackageManager } from "../../utils/install";
|
|
@@ -13,15 +12,12 @@ const replaceWorkspaces = ({
|
|
|
13
12
|
const pnpmWsFilePath = path.join(rootPath, WORKSPACE_FILE.PNPM);
|
|
14
13
|
|
|
15
14
|
if (fs.existsSync(pnpmWsFilePath)) {
|
|
16
|
-
const pnpmWorkspace = fs.readFileSync(pnpmWsFilePath, 'utf-8');
|
|
17
|
-
|
|
15
|
+
const pnpmWorkspace = fs.readFileSync(pnpmWsFilePath, 'utf-8');
|
|
18
16
|
const orignalPnpmWorkspaces = yaml.load(pnpmWorkspace);
|
|
19
|
-
fs.writeFileSync(pnpmWsFilePath,
|
|
20
|
-
yaml.dump({
|
|
17
|
+
fs.writeFileSync(pnpmWsFilePath, yaml.dump({
|
|
21
18
|
packages: projectsInWorkspacs
|
|
22
19
|
}));
|
|
23
20
|
return () => {
|
|
24
|
-
// eslint-disable-next-line import/no-named-as-default-member
|
|
25
21
|
yaml.dump(orignalPnpmWorkspaces);
|
|
26
22
|
};
|
|
27
23
|
}
|
|
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
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
6
|
|
|
7
|
-
import { Signale } from '
|
|
7
|
+
import { Signale } from '@modern-js/utils';
|
|
8
8
|
export const initTimeLog = (option = {}) => new Signale(_objectSpread({
|
|
9
9
|
interactive: true,
|
|
10
10
|
scope: 'time-log'
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
2
|
import { FileSystem, JsonFile } from '@rushstack/node-core-library';
|
|
3
|
-
import { fs } from '@modern-js/utils';
|
|
4
|
-
import yaml from 'js-yaml';
|
|
3
|
+
import { fs, yaml } from '@modern-js/utils';
|
|
5
4
|
import { getWorkspaceFile } from "../parse-config/monorepo";
|
|
6
5
|
import { WORKSPACE_FILE } from "../constants";
|
|
7
6
|
import { getProjetsByPackageConfig, syncGetProjetsByPackageConfig } from "./get-projects-by-packages-config";
|
|
@@ -23,8 +22,7 @@ export const getProjectsByWorkspaceFile = async (rootPath, config, ignoreConfigs
|
|
|
23
22
|
let packagesConfig = [];
|
|
24
23
|
|
|
25
24
|
if (workspaceFile === WORKSPACE_FILE.PNPM) {
|
|
26
|
-
const yamlString = await FileSystem.readFileAsync(path.resolve('/', rootPath, workspaceFile)).then(data => data.toString());
|
|
27
|
-
|
|
25
|
+
const yamlString = await FileSystem.readFileAsync(path.resolve('/', rootPath, workspaceFile)).then(data => data.toString());
|
|
28
26
|
const pnpmWorkspace = yaml.load(yamlString);
|
|
29
27
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
30
28
|
} else if (workspaceFile === WORKSPACE_FILE.YARN) {
|
|
@@ -55,8 +53,7 @@ export const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs)
|
|
|
55
53
|
let packagesConfig = [];
|
|
56
54
|
|
|
57
55
|
if (workspaceFile === WORKSPACE_FILE.PNPM) {
|
|
58
|
-
const yamlString = fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
|
|
59
|
-
|
|
56
|
+
const yamlString = fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
|
|
60
57
|
const pnpmWorkspace = yaml.load(yamlString);
|
|
61
58
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
62
59
|
} else if (workspaceFile === WORKSPACE_FILE.YARN) {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import * as path from 'path';
|
|
2
|
-
import { fs } from '@modern-js/utils';
|
|
3
|
-
import execa from 'execa';
|
|
2
|
+
import { fs, execa } from '@modern-js/utils';
|
|
4
3
|
import { LOCK_FILE } from "../constants";
|
|
5
4
|
export const removeLockFile = (rootPath, packageManager) => {
|
|
6
5
|
if (packageManager === 'pnpm') {
|
|
@@ -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
|
|
|
@@ -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) {
|
|
@@ -80,10 +76,9 @@ const syncGetProjectsByWorkspaceFile = (rootPath, config, ignoreConfigs) => {
|
|
|
80
76
|
let packagesConfig = [];
|
|
81
77
|
|
|
82
78
|
if (workspaceFile === _constants.WORKSPACE_FILE.PNPM) {
|
|
83
|
-
const yamlString = _utils.fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
|
|
84
|
-
|
|
79
|
+
const yamlString = _utils.fs.readFileSync(path.resolve('/', rootPath, workspaceFile), 'utf-8');
|
|
85
80
|
|
|
86
|
-
const pnpmWorkspace =
|
|
81
|
+
const pnpmWorkspace = _utils.yaml.load(yamlString);
|
|
87
82
|
|
|
88
83
|
packagesConfig = pnpmWorkspace.packages || [];
|
|
89
84
|
} else if (workspaceFile === _constants.WORKSPACE_FILE.YARN) {
|
|
@@ -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
|
}
|
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;
|
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;
|
package/jest.config.js
CHANGED
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.4.
|
|
14
|
+
"version": "1.4.2",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -35,37 +35,29 @@
|
|
|
35
35
|
"modern": "./bin/modern.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@modern-js/core": "^1.
|
|
38
|
+
"@modern-js/core": "^1.7.0",
|
|
39
39
|
"@babel/runtime": "^7",
|
|
40
40
|
"@modern-js/i18n-cli-language-detector": "^1.2.1",
|
|
41
|
-
"@modern-js/new-action": "^1.3.
|
|
41
|
+
"@modern-js/new-action": "^1.3.5",
|
|
42
42
|
"@modern-js/plugin": "^1.3.2",
|
|
43
|
-
"@modern-js/plugin-changeset": "^1.2.
|
|
44
|
-
"@modern-js/plugin-i18n": "^1.2.
|
|
45
|
-
"@modern-js/utils": "^1.
|
|
43
|
+
"@modern-js/plugin-changeset": "^1.2.4",
|
|
44
|
+
"@modern-js/plugin-i18n": "^1.2.3",
|
|
45
|
+
"@modern-js/utils": "^1.4.0",
|
|
46
46
|
"@rushstack/node-core-library": "^3.39.1",
|
|
47
47
|
"@rushstack/package-deps-hash": "^3.0.54",
|
|
48
48
|
"anymatch": "^3.1.2",
|
|
49
|
-
"chalk": "^4.1.1",
|
|
50
|
-
"chokidar": "^3.5.2",
|
|
51
|
-
"commander": "^8.1.0",
|
|
52
49
|
"globby": "^11.0.0",
|
|
53
|
-
"js-yaml": "^4.1.0",
|
|
54
50
|
"md5": "^2.3.0",
|
|
55
|
-
"p-map": "^4.0.0"
|
|
56
|
-
"signale": "^1.4.0"
|
|
51
|
+
"p-map": "^4.0.0"
|
|
57
52
|
},
|
|
58
53
|
"devDependencies": {
|
|
59
54
|
"@scripts/build": "0.0.0",
|
|
60
55
|
"@scripts/jest-config": "0.0.0",
|
|
61
56
|
"@types/jest": "^26",
|
|
62
|
-
"@types/js-yaml": "^4.0.2",
|
|
63
57
|
"@types/md5": "^2.3.1",
|
|
64
58
|
"@types/node": "^14",
|
|
65
59
|
"@types/react": "^17",
|
|
66
60
|
"@types/react-dom": "^17",
|
|
67
|
-
"@types/signale": "^1.4.2",
|
|
68
|
-
"execa": "^5.1.1",
|
|
69
61
|
"jest": "^27",
|
|
70
62
|
"typescript": "^4"
|
|
71
63
|
},
|