@utoo/pack-cli 1.0.5 → 1.0.7

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.
@@ -5,6 +5,7 @@ export default class Build extends Command {
5
5
  static flags: {
6
6
  project: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
7
7
  root: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ webpack: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
9
  };
9
10
  run(): Promise<void>;
10
11
  }
@@ -32,39 +32,22 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  const core_1 = require("@oclif/core");
40
37
  const utooPack = __importStar(require("@utoo/pack"));
41
- const fs_1 = __importDefault(require("fs"));
42
- const path_1 = __importDefault(require("path"));
38
+ const common_1 = require("../utils/common");
43
39
  class Build extends core_1.Command {
44
- static description = "Utoo pack build";
40
+ static description = "utoopack build";
45
41
  static examples = [
46
42
  `<%= config.bin %> <%= command.id %> build --project .`,
47
43
  `<%= config.bin %> <%= command.id %> build --project . --root ../..`,
44
+ `<%= config.bin %> <%= command.id %> build --webpack`,
48
45
  ];
49
- static flags = {
50
- project: core_1.Flags.string({
51
- char: "p",
52
- description: "Set the project path",
53
- required: false,
54
- }),
55
- root: core_1.Flags.string({
56
- char: "r",
57
- description: "Set the root path",
58
- required: false,
59
- }),
60
- };
46
+ static flags = common_1.commonFlags;
61
47
  async run() {
62
- const { flags: { project, root }, } = await this.parse(Build);
63
- const cwd = process.cwd();
64
- const projectOptions = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(cwd, project || "", "project_options.json"), {
65
- encoding: "utf-8",
66
- }));
67
- await utooPack.build(projectOptions, path_1.default.resolve(cwd, project || cwd), root && path_1.default.resolve(cwd, root));
48
+ const { flags } = await this.parse(Build);
49
+ const { projectOptions, projectPath, rootPath } = (0, common_1.resolveBuildOptions)(flags);
50
+ await utooPack.build(projectOptions, projectPath, rootPath);
68
51
  }
69
52
  }
70
53
  exports.default = Build;
@@ -5,6 +5,7 @@ export default class Dev extends Command {
5
5
  static flags: {
6
6
  project: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
7
7
  root: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
8
+ webpack: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
8
9
  };
9
10
  run(): Promise<void>;
10
11
  }
@@ -32,39 +32,22 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
35
  Object.defineProperty(exports, "__esModule", { value: true });
39
36
  const core_1 = require("@oclif/core");
40
37
  const utooPack = __importStar(require("@utoo/pack"));
41
- const fs_1 = __importDefault(require("fs"));
42
- const path_1 = __importDefault(require("path"));
38
+ const common_1 = require("../utils/common");
43
39
  class Dev extends core_1.Command {
44
- static description = "Utoo pack dev";
40
+ static description = "utoopack dev";
45
41
  static examples = [
46
42
  `<%= config.bin %> <%= command.id %> dev --project .`,
47
43
  `<%= config.bin %> <%= command.id %> dev --project . --root ../..`,
44
+ `<%= config.bin %> <%= command.id %> dev --webpack`,
48
45
  ];
49
- static flags = {
50
- project: core_1.Flags.string({
51
- char: "p",
52
- description: "Set the project path",
53
- required: false,
54
- }),
55
- root: core_1.Flags.string({
56
- char: "r",
57
- description: "Set the root path",
58
- required: false,
59
- }),
60
- };
46
+ static flags = common_1.commonFlags;
61
47
  async run() {
62
- const { flags: { project, root }, } = await this.parse(Dev);
63
- const cwd = process.cwd();
64
- const projectOptions = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(cwd, project || "", "project_options.json"), {
65
- encoding: "utf-8",
66
- }));
67
- await utooPack.serve(projectOptions, path_1.default.resolve(cwd, project || cwd), root && path_1.default.resolve(cwd, root));
48
+ const { flags } = await this.parse(Dev);
49
+ const { projectOptions, projectPath, rootPath } = (0, common_1.resolveBuildOptions)(flags);
50
+ await utooPack.serve(projectOptions, projectPath, rootPath);
68
51
  }
69
52
  }
70
53
  exports.default = Dev;
@@ -0,0 +1,16 @@
1
+ import * as utooPack from "@utoo/pack";
2
+ export declare const commonFlags: {
3
+ project: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
4
+ root: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
5
+ webpack: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
6
+ };
7
+ export interface BuildOptions {
8
+ projectPath: string;
9
+ rootPath: string | undefined;
10
+ projectOptions: utooPack.WebpackConfig | utooPack.BundleOptions;
11
+ }
12
+ export declare function resolveBuildOptions(flags: {
13
+ project?: string;
14
+ root?: string;
15
+ webpack?: boolean;
16
+ }): BuildOptions;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.commonFlags = void 0;
7
+ exports.resolveBuildOptions = resolveBuildOptions;
8
+ const core_1 = require("@oclif/core");
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const path_1 = __importDefault(require("path"));
11
+ exports.commonFlags = {
12
+ project: core_1.Flags.string({
13
+ char: "p",
14
+ description: "Set the project path",
15
+ required: false,
16
+ }),
17
+ root: core_1.Flags.string({
18
+ char: "r",
19
+ description: "Set the root path",
20
+ required: false,
21
+ }),
22
+ webpack: core_1.Flags.boolean({
23
+ name: "webpack",
24
+ description: "Enable webpack mode",
25
+ required: false,
26
+ }),
27
+ };
28
+ function resolveBuildOptions(flags) {
29
+ const { project, root, webpack } = flags;
30
+ const cwd = process.cwd();
31
+ let projectPath = path_1.default.resolve(cwd, project || cwd);
32
+ let rootPath = root ? path_1.default.resolve(cwd, root) : undefined;
33
+ let projectOptions;
34
+ if (webpack) {
35
+ projectOptions = { webpackMode: true };
36
+ }
37
+ else {
38
+ projectOptions = JSON.parse(fs_1.default.readFileSync(path_1.default.resolve(cwd, project || "", "project_options.json"), {
39
+ encoding: "utf-8",
40
+ }));
41
+ }
42
+ return { projectPath, rootPath, projectOptions };
43
+ }
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@utoo/pack-cli",
3
3
  "description": "Utoo pack cli",
4
- "version": "1.0.5",
4
+ "version": "1.0.7",
5
5
  "author": "xusd320",
6
6
  "bin": {
7
- "utoo-pack": "./bin/run.js"
7
+ "utoopack": "./bin/run.js"
8
8
  },
9
9
  "dependencies": {
10
10
  "@oclif/core": "^4",
11
- "@utoo/pack": "1.0.5"
11
+ "@utoo/pack": "1.0.7"
12
12
  },
13
13
  "devDependencies": {
14
14
  "@types/node": "^20.3.0",
@@ -26,7 +26,7 @@
26
26
  "license": "MIT",
27
27
  "main": "dist/index.js",
28
28
  "oclif": {
29
- "bin": "utoo-pack",
29
+ "bin": "utoopack",
30
30
  "commands": "./dist/commands",
31
31
  "topicSeparator": " ",
32
32
  "topics": {