@modern-js/monorepo-tools 1.3.3-beta.3 → 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 +62 -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 +3 -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 +4 -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 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
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
|
+
|
|
22
|
+
## 1.4.1
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- 57419eb4: convert to new plugin
|
|
27
|
+
- Updated dependencies [05ce88a0]
|
|
28
|
+
- Updated dependencies [a8df060e]
|
|
29
|
+
- Updated dependencies [c2046f37]
|
|
30
|
+
- Updated dependencies [dc88abf9]
|
|
31
|
+
- Updated dependencies [0462ff77]
|
|
32
|
+
- Updated dependencies [61e3f623]
|
|
33
|
+
- Updated dependencies [6a7acb81]
|
|
34
|
+
- Updated dependencies [681a1ff9]
|
|
35
|
+
- Updated dependencies [4e2026e4]
|
|
36
|
+
- @modern-js/core@1.6.0
|
|
37
|
+
- @modern-js/utils@1.3.6
|
|
38
|
+
- @modern-js/plugin@1.3.2
|
|
39
|
+
- @modern-js/plugin-changeset@1.2.3
|
|
40
|
+
|
|
41
|
+
## 1.4.0
|
|
42
|
+
|
|
43
|
+
### Minor Changes
|
|
44
|
+
|
|
45
|
+
- e37ea5b2: feat: add afterMonorepoDeploy hook
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
- 55e18278: chore: remove unused dependencies and devDependencies
|
|
50
|
+
- edc3bd3d: fix: @modern-js/core package not found
|
|
51
|
+
- Updated dependencies [969f172f]
|
|
52
|
+
- Updated dependencies [4c792f68]
|
|
53
|
+
- Updated dependencies [83059b93]
|
|
54
|
+
- Updated dependencies [4b5d4bf4]
|
|
55
|
+
- Updated dependencies [62f5b8c8]
|
|
56
|
+
- Updated dependencies [55e18278]
|
|
57
|
+
- Updated dependencies [4499a674]
|
|
58
|
+
- Updated dependencies [403f5169]
|
|
59
|
+
- Updated dependencies [a7f42f48]
|
|
60
|
+
- Updated dependencies [83059b93]
|
|
61
|
+
- @modern-js/core@1.4.4
|
|
62
|
+
- @modern-js/utils@1.3.3
|
|
63
|
+
- @modern-js/new-action@1.3.3
|
|
64
|
+
|
|
3
65
|
## 1.3.2
|
|
4
66
|
|
|
5
67
|
### Patch Changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildWatch } from "../commands";
|
|
2
|
-
export const buildWatchCli = program => {
|
|
3
|
-
program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s
|
|
4
|
-
await buildWatch(targetProjectName, option);
|
|
2
|
+
export const buildWatchCli = (program, api) => {
|
|
3
|
+
program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependencies').action(async (targetProjectName, option) => {
|
|
4
|
+
await buildWatch(targetProjectName, option, api);
|
|
5
5
|
});
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { build } from "../commands";
|
|
2
|
-
export const buildCli = program => {
|
|
2
|
+
export const buildCli = (program, api) => {
|
|
3
3
|
program.command('build [project]').usage('[options]').option('--no-self', 'build without target project').option('-t, --dept', 'build target project with project’s dependent').option('--no-deps', 'build target project without project’s dependences').option('--only-self', 'build target project with nothing').option('-a, --all', 'build target project with project’s dependences and dependent').option('--content-hash', 'build target project use content hash cache').option('--git-hash', 'build target project use git hash cache').description('build target project').action(async (targetProjectName, option) => {
|
|
4
|
-
await build(targetProjectName, option);
|
|
4
|
+
await build(targetProjectName, option, api);
|
|
5
5
|
});
|
|
6
6
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { clear } from "../commands";
|
|
2
|
-
export const clearCli = program => {
|
|
2
|
+
export const clearCli = (program, api) => {
|
|
3
3
|
program.command('clear [projects...]').usage('[options]').option('--remove-dirs [dirs...]', 'remove dirs, default is node_modules').description('clear project dirs').action(async (targetProjectNames, option) => {
|
|
4
|
-
await clear(targetProjectNames, option);
|
|
4
|
+
await clear(targetProjectNames, option, api);
|
|
5
5
|
});
|
|
6
6
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { deploy } from "../commands";
|
|
2
|
-
export const deployCli = program => {
|
|
2
|
+
export const deployCli = (program, api) => {
|
|
3
3
|
program.command('deploy [project...]').usage('[options]').option('-p, --path [path]', 'Specify the path of the product output', 'output').description('deploy project').action(async (deployProjectNames, option) => {
|
|
4
4
|
// 在查找 workspace 下项目时,默认忽略 output 下面的项目
|
|
5
5
|
const ignoreMatchs = ['**/output/**'];
|
|
6
|
-
await deploy(deployProjectNames, option, ignoreMatchs);
|
|
6
|
+
await deploy(api, deployProjectNames, option, ignoreMatchs);
|
|
7
7
|
});
|
|
8
8
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { install } from "../commands";
|
|
2
|
-
export const installCli = program => {
|
|
2
|
+
export const installCli = (program, api) => {
|
|
3
3
|
program.command('install [project...]').usage('[options]').description('install deps for some projects').action(async (installProjectNames, option) => {
|
|
4
|
-
await install(installProjectNames, option);
|
|
4
|
+
await install(installProjectNames, option, api);
|
|
5
5
|
});
|
|
6
6
|
};
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { useAppContext } from '@modern-js/core';
|
|
2
1
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
3
2
|
import { runBuildWatchTask } from "../features/dev";
|
|
4
3
|
import { getProjects } from "../projects/get-projects";
|
|
5
4
|
import { initDAG } from "../dag";
|
|
6
|
-
export const buildWatch = async (targetProjectName, option) => {
|
|
7
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
5
|
+
export const buildWatch = async (targetProjectName, option, api) => {
|
|
8
6
|
const {
|
|
9
7
|
appDirectory
|
|
10
|
-
} = useAppContext();
|
|
8
|
+
} = api.useAppContext();
|
|
11
9
|
const {
|
|
12
10
|
onlySelf = false,
|
|
13
11
|
init = false
|
|
@@ -4,17 +4,15 @@ 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 { useAppContext } from '@modern-js/core';
|
|
8
7
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
9
8
|
import { runBuildTask, runAllBuildTask } from "../features/build";
|
|
10
9
|
import { getProjects } from "../projects/get-projects";
|
|
11
10
|
import { initDAG } from "../dag"; // import { clearProjectsMemoryFile } from './projects/clear-memory-files';
|
|
12
11
|
|
|
13
|
-
export const build = async (targetProjectName, option) => {
|
|
14
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
12
|
+
export const build = async (targetProjectName, option, api) => {
|
|
15
13
|
const {
|
|
16
14
|
appDirectory
|
|
17
|
-
} = useAppContext();
|
|
15
|
+
} = api.useAppContext();
|
|
18
16
|
const {
|
|
19
17
|
self = true,
|
|
20
18
|
dept = false,
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { useAppContext } from '@modern-js/core';
|
|
2
1
|
import { getProjects } from "../projects/get-projects";
|
|
3
2
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
4
3
|
import { runClearTask } from "../features/clear";
|
|
5
|
-
export const clear = async (projectNames, option) => {
|
|
4
|
+
export const clear = async (projectNames, option, api) => {
|
|
6
5
|
const {
|
|
7
6
|
removeDirs
|
|
8
|
-
} = option;
|
|
9
|
-
|
|
7
|
+
} = option;
|
|
10
8
|
const {
|
|
11
9
|
appDirectory
|
|
12
|
-
} = useAppContext();
|
|
10
|
+
} = api.useAppContext();
|
|
13
11
|
const projects = await getProjects({
|
|
14
12
|
packagesMatchs: {
|
|
15
13
|
enableAutoFinder: true
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import { useAppContext, mountHook } from '@modern-js/core';
|
|
2
1
|
import { logger } from '@modern-js/utils';
|
|
3
2
|
import { initDAG } from "../dag";
|
|
4
3
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
5
4
|
import { getProjects } from "../projects/get-projects";
|
|
6
5
|
import { deploy as runDeployTask } from "../features/deploy";
|
|
7
|
-
export const deploy = async (deployProjectNames, option, ignoreMatchs = []) => {
|
|
6
|
+
export const deploy = async (api, deployProjectNames, option, ignoreMatchs = []) => {
|
|
8
7
|
const {
|
|
9
8
|
deployPath = 'output'
|
|
10
|
-
} = option;
|
|
11
|
-
|
|
9
|
+
} = option;
|
|
12
10
|
const {
|
|
13
11
|
appDirectory
|
|
14
|
-
} = useAppContext();
|
|
12
|
+
} = api.useAppContext();
|
|
15
13
|
logger.info(`start deploy ${deployProjectNames.join(',')}`);
|
|
16
14
|
const projects = await getProjects({
|
|
17
15
|
packagesMatchs: {
|
|
@@ -29,7 +27,8 @@ export const deploy = async (deployProjectNames, option, ignoreMatchs = []) => {
|
|
|
29
27
|
packageManager,
|
|
30
28
|
deployPath
|
|
31
29
|
});
|
|
32
|
-
|
|
30
|
+
const runners = api.useHookRunners();
|
|
31
|
+
runners.afterMonorepoDeploy({
|
|
33
32
|
operator,
|
|
34
33
|
deployProjectNames
|
|
35
34
|
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { useAppContext } from '@modern-js/core';
|
|
2
1
|
import { runInstallTask } from "../features/install";
|
|
3
2
|
import { getMonorepoBaseData } from "../parse-config/monorepo";
|
|
4
3
|
import { getProjects } from "../projects/get-projects";
|
|
5
4
|
import { initDAG } from "../dag";
|
|
6
|
-
export const install = async (projectNames = [], option) => {
|
|
7
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
5
|
+
export const install = async (projectNames = [], option, api) => {
|
|
8
6
|
const {
|
|
9
7
|
appDirectory
|
|
10
|
-
} = useAppContext();
|
|
8
|
+
} = api.useAppContext();
|
|
11
9
|
const {
|
|
12
10
|
auto
|
|
13
11
|
} = option;
|
|
@@ -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
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { registerHook } from '@modern-js/core';
|
|
2
1
|
import { createAsyncWorkflow } from '@modern-js/plugin';
|
|
3
2
|
const afterMonorepoDeploy = createAsyncWorkflow();
|
|
4
|
-
export const
|
|
5
|
-
|
|
6
|
-
afterMonorepoDeploy
|
|
7
|
-
});
|
|
3
|
+
export const hooks = {
|
|
4
|
+
afterMonorepoDeploy
|
|
8
5
|
};
|
package/dist/js/modern/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ChangesetPlugin from '@modern-js/plugin-changeset';
|
|
2
2
|
import { i18n } from "./locale";
|
|
3
3
|
import { newCli, deployCli, clearCli } from "./cli";
|
|
4
4
|
import { getLocaleLanguage } from "./utils/language";
|
|
5
|
-
import {
|
|
6
|
-
export
|
|
5
|
+
import { hooks } from "./hooks";
|
|
6
|
+
export default (() => ({
|
|
7
|
+
name: '@modern-js/monorepo-tools',
|
|
8
|
+
usePlugins: [ChangesetPlugin()],
|
|
9
|
+
registerHook: hooks,
|
|
10
|
+
setup: api => {
|
|
11
|
+
const locale = getLocaleLanguage();
|
|
12
|
+
i18n.changeLanguage({
|
|
13
|
+
locale
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
commands({
|
|
17
|
+
program
|
|
18
|
+
}) {
|
|
19
|
+
clearCli(program, api);
|
|
20
|
+
deployCli(program, api);
|
|
21
|
+
newCli(program, locale);
|
|
22
|
+
}
|
|
7
23
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
lifecycle();
|
|
11
|
-
const locale = getLocaleLanguage();
|
|
12
|
-
i18n.changeLanguage({
|
|
13
|
-
locale
|
|
14
|
-
});
|
|
15
|
-
return {
|
|
16
|
-
commands({
|
|
17
|
-
program
|
|
18
|
-
}) {
|
|
19
|
-
clearCli(program);
|
|
20
|
-
deployCli(program);
|
|
21
|
-
newCli(program, locale);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
}, {
|
|
24
|
+
};
|
|
25
|
+
},
|
|
26
26
|
post: ['@modern-js/plugin-changeset']
|
|
27
|
-
});
|
|
27
|
+
}));
|
|
@@ -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,9 @@ exports.buildWatchCli = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _commands = require("../commands");
|
|
9
9
|
|
|
10
|
-
const buildWatchCli = program => {
|
|
11
|
-
program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s
|
|
12
|
-
await (0, _commands.buildWatch)(targetProjectName, option);
|
|
10
|
+
const buildWatchCli = (program, api) => {
|
|
11
|
+
program.command('build-watch [project]').usage('[options]').option('--only-self', 'build target project with nothing').option('-i, --init', 'init build beforebuild watch ').description('watch target project and target project’s dependencies').action(async (targetProjectName, option) => {
|
|
12
|
+
await (0, _commands.buildWatch)(targetProjectName, option, api);
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -7,9 +7,9 @@ exports.buildCli = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _commands = require("../commands");
|
|
9
9
|
|
|
10
|
-
const buildCli = program => {
|
|
10
|
+
const buildCli = (program, api) => {
|
|
11
11
|
program.command('build [project]').usage('[options]').option('--no-self', 'build without target project').option('-t, --dept', 'build target project with project’s dependent').option('--no-deps', 'build target project without project’s dependences').option('--only-self', 'build target project with nothing').option('-a, --all', 'build target project with project’s dependences and dependent').option('--content-hash', 'build target project use content hash cache').option('--git-hash', 'build target project use git hash cache').description('build target project').action(async (targetProjectName, option) => {
|
|
12
|
-
await (0, _commands.build)(targetProjectName, option);
|
|
12
|
+
await (0, _commands.build)(targetProjectName, option, api);
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -7,9 +7,9 @@ exports.clearCli = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _commands = require("../commands");
|
|
9
9
|
|
|
10
|
-
const clearCli = program => {
|
|
10
|
+
const clearCli = (program, api) => {
|
|
11
11
|
program.command('clear [projects...]').usage('[options]').option('--remove-dirs [dirs...]', 'remove dirs, default is node_modules').description('clear project dirs').action(async (targetProjectNames, option) => {
|
|
12
|
-
await (0, _commands.clear)(targetProjectNames, option);
|
|
12
|
+
await (0, _commands.clear)(targetProjectNames, option, api);
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -7,11 +7,11 @@ exports.deployCli = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _commands = require("../commands");
|
|
9
9
|
|
|
10
|
-
const deployCli = program => {
|
|
10
|
+
const deployCli = (program, api) => {
|
|
11
11
|
program.command('deploy [project...]').usage('[options]').option('-p, --path [path]', 'Specify the path of the product output', 'output').description('deploy project').action(async (deployProjectNames, option) => {
|
|
12
12
|
// 在查找 workspace 下项目时,默认忽略 output 下面的项目
|
|
13
13
|
const ignoreMatchs = ['**/output/**'];
|
|
14
|
-
await (0, _commands.deploy)(deployProjectNames, option, ignoreMatchs);
|
|
14
|
+
await (0, _commands.deploy)(api, deployProjectNames, option, ignoreMatchs);
|
|
15
15
|
});
|
|
16
16
|
};
|
|
17
17
|
|
|
@@ -7,9 +7,9 @@ exports.installCli = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _commands = require("../commands");
|
|
9
9
|
|
|
10
|
-
const installCli = program => {
|
|
10
|
+
const installCli = (program, api) => {
|
|
11
11
|
program.command('install [project...]').usage('[options]').description('install deps for some projects').action(async (installProjectNames, option) => {
|
|
12
|
-
await (0, _commands.install)(installProjectNames, option);
|
|
12
|
+
await (0, _commands.install)(installProjectNames, option, api);
|
|
13
13
|
});
|
|
14
14
|
};
|
|
15
15
|
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.buildWatch = void 0;
|
|
7
7
|
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
9
|
-
|
|
10
8
|
var _monorepo = require("../parse-config/monorepo");
|
|
11
9
|
|
|
12
10
|
var _dev = require("../features/dev");
|
|
@@ -15,11 +13,10 @@ var _getProjects = require("../projects/get-projects");
|
|
|
15
13
|
|
|
16
14
|
var _dag = require("../dag");
|
|
17
15
|
|
|
18
|
-
const buildWatch = async (targetProjectName, option) => {
|
|
19
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
16
|
+
const buildWatch = async (targetProjectName, option, api) => {
|
|
20
17
|
const {
|
|
21
18
|
appDirectory
|
|
22
|
-
} =
|
|
19
|
+
} = api.useAppContext();
|
|
23
20
|
const {
|
|
24
21
|
onlySelf = false,
|
|
25
22
|
init = false
|
|
@@ -5,8 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.build = void 0;
|
|
7
7
|
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
9
|
-
|
|
10
8
|
var _monorepo = require("../parse-config/monorepo");
|
|
11
9
|
|
|
12
10
|
var _build = require("../features/build");
|
|
@@ -21,11 +19,10 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
21
19
|
|
|
22
20
|
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; }
|
|
23
21
|
|
|
24
|
-
const build = async (targetProjectName, option) => {
|
|
25
|
-
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
22
|
+
const build = async (targetProjectName, option, api) => {
|
|
26
23
|
const {
|
|
27
24
|
appDirectory
|
|
28
|
-
} =
|
|
25
|
+
} = api.useAppContext();
|
|
29
26
|
const {
|
|
30
27
|
self = true,
|
|
31
28
|
dept = false,
|
|
@@ -5,22 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.clear = void 0;
|
|
7
7
|
|
|
8
|
-
var _core = require("@modern-js/core");
|
|
9
|
-
|
|
10
8
|
var _getProjects = require("../projects/get-projects");
|
|
11
9
|
|
|
12
10
|
var _monorepo = require("../parse-config/monorepo");
|
|
13
11
|
|
|
14
12
|
var _clear = require("../features/clear");
|
|
15
13
|
|
|
16
|
-
const clear = async (projectNames, option) => {
|
|
14
|
+
const clear = async (projectNames, option, api) => {
|
|
17
15
|
const {
|
|
18
16
|
removeDirs
|
|
19
|
-
} = option;
|
|
20
|
-
|
|
17
|
+
} = option;
|
|
21
18
|
const {
|
|
22
19
|
appDirectory
|
|
23
|
-
} =
|
|
20
|
+
} = api.useAppContext();
|
|
24
21
|
const projects = await (0, _getProjects.getProjects)({
|
|
25
22
|
packagesMatchs: {
|
|
26
23
|
enableAutoFinder: true
|
|
@@ -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
|
});
|