@wzyjs/cli 0.0.33 → 0.0.35

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.
@@ -3,9 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const path_1 = require("path");
5
5
  const fs = tslib_1.__importStar(require("fs-extra"));
6
- // import { run } from 'umi'
7
- // @ts-ignore
8
- const internal_1 = require("@midwayjs/hooks/internal");
6
+ const umi_1 = require("umi");
7
+ const hooks_internal_1 = require("@midwayjs/hooks-internal");
9
8
  const utils_1 = require("./utils");
10
9
  exports.default = (cli) => {
11
10
  cli.command('build', 'cli工具')
@@ -17,7 +16,7 @@ exports.default = (cli) => {
17
16
  })
18
17
  .action(async (options) => {
19
18
  const { outDir, clean } = options;
20
- const root = (0, internal_1.getProjectRoot)();
19
+ const root = (0, hooks_internal_1.getProjectRoot)();
21
20
  if (clean && fs.existsSync(outDir)) {
22
21
  console.info('正在清理之前的 build 产物...');
23
22
  await fs.promises.rm(outDir, { recursive: true });
@@ -26,14 +25,14 @@ exports.default = (cli) => {
26
25
  // const removeConfig = writeConfig(root, {})
27
26
  // 合并用户配置
28
27
  const productionConfig = (0, utils_1.getProductionConfig)(root);
29
- // console.info('正在打包前端代码...')
30
- // const feBuild = await executePromise(run({
31
- // presets: [require.resolve('../../plugins/preset')],
32
- // }).catch((e: any) => {
33
- // console.error(e)
34
- // process.exit(1)
35
- // }))
36
- // console.info('打包前端代码成功~ 耗时:' + feBuild.time / 1000 + 's')
28
+ console.info('正在打包前端代码...');
29
+ const feBuild = await (0, utils_1.executePromise)((0, umi_1.run)({
30
+ presets: [require.resolve('../../plugins/preset')],
31
+ }).catch((e) => {
32
+ console.error(e);
33
+ process.exit(1);
34
+ }));
35
+ console.info('打包前端代码成功~ 耗时:' + feBuild.time / 1000 + 's');
37
36
  // 创建服务端渲染前端页面的 render 函数
38
37
  (0, utils_1.createRender)((0, path_1.join)(root, outDir));
39
38
  // 写 midway.config.js 到 dist 目录
@@ -41,13 +40,11 @@ exports.default = (cli) => {
41
40
  // 写 package.json 到 dist 目录
42
41
  // fs.cpSync(join(root, 'package.json'), join(outDir, 'package.json'))
43
42
  console.info('正在打包后端代码...', root);
44
- // let rdBuild
45
43
  try {
46
- console.log(666, root, outDir);
47
- await (0, utils_1.buildServer)(root, outDir);
44
+ const rdBuild = await (0, utils_1.executePromise)((0, utils_1.buildServer)(root, outDir));
48
45
  // 删除 midway.config.js
49
46
  // removeConfig()
50
- // console.info(`打包后端代码成功~ 耗时:` + rdBuild.time / 1000 + 's')
47
+ console.info(`打包后端代码成功~ 耗时:` + rdBuild.time / 1000 + 's');
51
48
  }
52
49
  catch (err) {
53
50
  console.error('打包后端代码失败', err);
@@ -2,7 +2,7 @@ export declare const createRender: (dist: string) => void;
2
2
  export declare const buildServer: (cwd: string, outDir: string) => Promise<void>;
3
3
  export declare const writeConfig: (outDir: string, productionConfig: any) => () => void;
4
4
  export declare const getProductionConfig: (root: string) => {
5
- routes: import("@midwayjs/hooks/internal").MidwayRoute[] | undefined;
5
+ routes: import("@midwayjs/hooks-internal").MidwayRoute[] | undefined;
6
6
  };
7
7
  export declare const executePromise: (promise: Promise<any>) => Promise<{
8
8
  result: any;
@@ -6,8 +6,7 @@ const path_1 = require("path");
6
6
  const fs = tslib_1.__importStar(require("fs-extra"));
7
7
  const command_core_1 = require("@midwayjs/command-core");
8
8
  const cli_plugin_build_1 = require("@midwayjs/cli-plugin-build");
9
- // @ts-ignore
10
- const internal_1 = require("@midwayjs/hooks/internal");
9
+ const hooks_internal_1 = require("@midwayjs/hooks-internal");
11
10
  const createRender = (dist) => {
12
11
  const code = `exports.default = require('@midwayjs/serve').Serve('/*', { dir: '_client', isKit: true });`;
13
12
  const file = (0, path_1.join)(dist, '_serve/index.js');
@@ -40,7 +39,7 @@ const writeConfig = (outDir, productionConfig) => {
40
39
  };
41
40
  exports.writeConfig = writeConfig;
42
41
  const getProductionConfig = (root) => {
43
- const userConfig = Object.assign({ static: true }, (0, internal_1.getConfig)(root));
42
+ const userConfig = Object.assign({ static: true }, (0, hooks_internal_1.getConfig)(root));
44
43
  if (Array.isArray(userConfig.routes)) {
45
44
  userConfig.routes.push({
46
45
  baseDir: '_serve',
@@ -23,10 +23,11 @@ const replaceContentInFile = (filePath, targetContent, replacement) => {
23
23
  exports.default = (cli) => {
24
24
  cli.command('hack', 'cli工具')
25
25
  .action(() => {
26
- console.log(666, path.resolve(__dirname), process.cwd());
27
- replaceContentInFile('/Users/wangzhenyu/Code/work/libs/cli/node_modules/@umijs/preset-umi/dist/libs/scan.js', 'exportsFields: []', `exportsFields: ['exports'],
26
+ const pwd = process.cwd();
27
+ console.log(666, path.resolve(__dirname), pwd);
28
+ replaceContentInFile(`${pwd}/node_modules/@umijs/preset-umi/dist/libs/scan.js`, 'exportsFields: []', `exportsFields: ['exports'],
28
29
  conditionNames: ["import", "require"]`);
29
- replaceContentInFile('/Users/wangzhenyu/Code/work/libs/cli/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js', 'paths = fieldProcessor(remainingRequest, this.conditionNames);', `paths = fieldProcessor(remainingRequest, this.conditionNames);
30
+ replaceContentInFile(`${pwd}/node_modules/enhanced-resolve/lib/ExportsFieldPlugin.js`, 'paths = fieldProcessor(remainingRequest, this.conditionNames);', `paths = fieldProcessor(remainingRequest, this.conditionNames);
30
31
  if (paths.length === 0 && remainingRequest === '.' && request.descriptionFileData.name === 'typeorm') {
31
32
  paths = ['./index.mjs']
32
33
  }
@@ -4,8 +4,7 @@ const tslib_1 = require("tslib");
4
4
  const path_1 = require("path");
5
5
  const fs = tslib_1.__importStar(require("fs-extra"));
6
6
  const bootstrap_1 = require("@midwayjs/bootstrap");
7
- // @ts-ignore
8
- const internal_1 = require("@midwayjs/hooks/internal");
7
+ const hooks_internal_1 = require("@midwayjs/hooks-internal");
9
8
  exports.default = (cli) => {
10
9
  cli.command('start', 'start')
11
10
  .option('-p, --port <port>', '[number] specify port', { default: 3000 })
@@ -17,13 +16,13 @@ exports.default = (cli) => {
17
16
  return;
18
17
  }
19
18
  const config = {
20
- ...Object.assign({ static: true }, (0, internal_1.getConfig)(root)),
19
+ ...Object.assign({ static: true }, (0, hooks_internal_1.getConfig)(root)),
21
20
  build: {
22
21
  outDir: './',
23
22
  },
24
23
  };
25
- (0, internal_1.setProjectRoot)(root);
26
- (0, internal_1.setConfig)(config);
24
+ (0, hooks_internal_1.setProjectRoot)(root);
25
+ (0, hooks_internal_1.setConfig)(config);
27
26
  process.env.MIDWAY_HTTP_PORT = options.port.toString();
28
27
  const server = bootstrap_1.Bootstrap.configure({
29
28
  baseDir: root,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wzyjs/cli",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
6
  "license": "ISC",
@@ -20,7 +20,8 @@
20
20
  "@midwayjs/bootstrap": "^3.7.1",
21
21
  "@midwayjs/cli-plugin-build": "^1.3.14",
22
22
  "@midwayjs/command-core": "^1.3.14",
23
- "@midwayjs/hooks": "^3.1.6",
23
+ "@midwayjs/core": "^3.12.3",
24
+ "@midwayjs/hooks-internal": "^3.1.6",
24
25
  "@midwayjs/rpc": "^3.1.6",
25
26
  "@umijs/plugins": "^4.0.28",
26
27
  "cac": "^6.7.14",
@@ -36,10 +37,6 @@
36
37
  "@types/node": "^18.11.9",
37
38
  "@types/react-router-dom": "^4.3.1"
38
39
  },
39
- "peerDependencies": {
40
- "@midwayjs/hooks": "^3.1.6",
41
- "@midwayjs/rpc": "^3.1.6"
42
- },
43
40
  "publishConfig": {
44
41
  "access": "public"
45
42
  },