@gmcb/cli 0.5.5 → 0.6.1

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.
Files changed (45) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +35 -0
  3. package/lib/actions/build.js +181 -45
  4. package/lib/actions/copy.js +2 -2
  5. package/lib/actions/create.js +2 -3
  6. package/lib/actions/publish.js +67 -38
  7. package/lib/actions/skill.js +2 -3
  8. package/lib/apis/http.d.ts +49 -0
  9. package/lib/apis/http.js +133 -0
  10. package/lib/apis/index.d.ts +116 -0
  11. package/lib/apis/index.js +234 -0
  12. package/lib/bin.js +3 -1
  13. package/lib/commands/option.d.ts +2 -0
  14. package/lib/commands/option.js +2 -1
  15. package/lib/commands/platform.js +1 -1
  16. package/lib/index.d.ts +1 -1
  17. package/lib/index.js +1 -1
  18. package/lib/scripts/app-apk.d.ts +1 -0
  19. package/lib/scripts/app-apk.js +15 -0
  20. package/lib/scripts/app-wgt.d.ts +1 -0
  21. package/lib/scripts/app-wgt.js +15 -0
  22. package/lib/scripts/asar-zip.d.ts +1 -0
  23. package/lib/scripts/asar-zip.js +17 -0
  24. package/lib/scripts/h5-exe.d.ts +1 -0
  25. package/lib/scripts/h5-exe.js +17 -0
  26. package/lib/scripts/h5-zip.d.ts +1 -0
  27. package/lib/scripts/h5-zip.js +15 -0
  28. package/lib/scripts/mp-weixin.d.ts +1 -0
  29. package/lib/scripts/mp-weixin.js +37 -0
  30. package/lib/scripts/publish.d.ts +9 -0
  31. package/lib/scripts/publish.js +112 -0
  32. package/lib/scripts/wgt-zip.d.ts +1 -0
  33. package/lib/scripts/wgt-zip.js +15 -0
  34. package/lib/{actions → utils}/config.d.ts +23 -6
  35. package/lib/{actions → utils}/config.js +19 -17
  36. package/lib/utils/const.d.ts +25 -1
  37. package/lib/utils/const.js +31 -2
  38. package/lib/utils/function.d.ts +2 -0
  39. package/lib/utils/function.js +20 -0
  40. package/lib/utils/index.d.ts +2 -0
  41. package/lib/utils/index.js +2 -0
  42. package/lib/utils/png2ico.d.ts +1 -0
  43. package/lib/utils/png2ico.js +48 -0
  44. package/package.json +8 -3
  45. package/schema.json +35 -3
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const path_1 = require("path");
5
+ const miniprogram_ci_1 = require("miniprogram-ci");
6
+ const utils_1 = require("../utils");
7
+ const const_1 = require("../utils/const");
8
+ const config_1 = require("../utils/config");
9
+ async function default_1() {
10
+ const buildEnv = process.env.BUILD_ENV || '';
11
+ const manifest = (0, utils_1.readManifest)();
12
+ const project = new miniprogram_ci_1.Project({
13
+ appid: manifest['mp-weixin']?.appid,
14
+ type: config_1.CONFIG_DATA?.mp?.weixin?.type ?? 'miniProgram',
15
+ projectPath: (0, path_1.join)(process.cwd(), const_1.HAS_SRC ? '' : 'unpackage', 'dist/build/mp-weixin'),
16
+ privateKeyPath: (0, path_1.resolve)(config_1.CONFIG_DATA?.mp?.weixin?.privatekey ?? ''),
17
+ ignores: ['node_modules/**/*'],
18
+ });
19
+ try {
20
+ const options = {
21
+ project,
22
+ version: manifest.versionName,
23
+ desc: buildEnv,
24
+ robot: { dev: 1, sit: 2, uat: 3, pre: 4, prod: 5 }[buildEnv] || 1,
25
+ setting: {
26
+ minify: true,
27
+ },
28
+ };
29
+ const res = await Promise.all([(0, miniprogram_ci_1.upload)(options), (0, miniprogram_ci_1.preview)(options)]);
30
+ console.log('上传成功', res[0]);
31
+ process.exit(0);
32
+ }
33
+ catch (e) {
34
+ console.log('上传失败', e);
35
+ process.exit(1);
36
+ }
37
+ }
@@ -0,0 +1,9 @@
1
+ export type PublishExt = 'wgt' | 'zip' | 'wgt-zip' | 'exe' | 'apk';
2
+ export interface PublishOptions {
3
+ ext: PublishExt | PublishExt[];
4
+ name?: string;
5
+ path?: string;
6
+ versionName?: string;
7
+ versionCode?: string | number;
8
+ }
9
+ export declare function publish(options: PublishOptions): Promise<void>;
@@ -0,0 +1,112 @@
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.publish = publish;
7
+ const fs_1 = require("fs");
8
+ const fs_extra_1 = require("fs-extra");
9
+ const path_1 = require("path");
10
+ const cos_nodejs_sdk_v5_1 = __importDefault(require("cos-nodejs-sdk-v5"));
11
+ const ora_1 = __importDefault(require("ora"));
12
+ const apis_1 = require("../apis");
13
+ const const_1 = require("../utils/const");
14
+ const config_1 = require("../utils/config");
15
+ const function_1 = require("../utils/function");
16
+ const PUBLISH_APP_CFG = {
17
+ wgt: config_1.CONFIG_DATA.app?.wgt,
18
+ zip: config_1.CONFIG_DATA.h5?.zip,
19
+ 'wgt-zip': undefined,
20
+ exe: config_1.CONFIG_DATA.h5?.windows,
21
+ apk: config_1.CONFIG_DATA.app?.android,
22
+ };
23
+ async function publish(options) {
24
+ const exts = Array.isArray(options.ext) ? options.ext : [options.ext];
25
+ const buildEnv = process.env.BUILD_ENV || '';
26
+ const pkg = (0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {};
27
+ const versionName = options.versionName;
28
+ const versionCode = (0, function_1.getEnvVersionCode)() || options.versionCode;
29
+ const bucket = `${buildEnv === 'prod' ? '' : `${buildEnv}-`}${config_1.CONFIG_DATA.cos.bucket ?? ''}`;
30
+ const region = config_1.CONFIG_DATA.cos?.region ?? '';
31
+ const secretId = config_1.CONFIG_DATA.cos?.secretid ?? '';
32
+ const secretKey = config_1.CONFIG_DATA.cos?.secretkey ?? '';
33
+ const remotePath = config_1.CONFIG_DATA.publish?.path || config_1.CONFIG_DATA.pub?.path || `/app/${pkg['appId'] || ''}`;
34
+ const cos = new cos_nodejs_sdk_v5_1.default({
35
+ SecretId: secretId,
36
+ SecretKey: secretKey,
37
+ });
38
+ const remoteUrls = [];
39
+ for (const ext of exts) {
40
+ const appCfg = PUBLISH_APP_CFG[ext];
41
+ const fileName = appCfg?.name ?? `${options.name}.${ext}`;
42
+ const filePath = (0, path_1.join)(const_1.COMMAND_PATH, appCfg?.path ?? options.path);
43
+ const destName = `${versionName}.${versionCode}.${ext}`;
44
+ const path = `${remotePath}/${destName}`;
45
+ await new Promise((res) => {
46
+ const spinner = (0, ora_1.default)(`正在上传${path}...`).start();
47
+ cos.putObject({
48
+ Bucket: bucket,
49
+ Region: region,
50
+ Key: path,
51
+ Body: (0, fs_1.readFileSync)((0, path_1.join)(filePath, fileName)),
52
+ }, (err) => {
53
+ spinner.stop();
54
+ if (err) {
55
+ spinner.fail(`上传失败,${err.message}`);
56
+ process.exit(1);
57
+ }
58
+ else {
59
+ res();
60
+ spinner.succeed(`${path}上传成功`);
61
+ }
62
+ });
63
+ });
64
+ remoteUrls.push(`https://${bucket}.cos.${region}.myqcloud.com${`/${path}`.replace(/\/+/g, '/')}`);
65
+ }
66
+ const spinner = (0, ora_1.default)('正在提交...').start();
67
+ try {
68
+ const { web } = config_1.CONFIG_DATA;
69
+ const { username, password } = web?.[buildEnv] || web || {};
70
+ const isPublish = !!config_1.CONFIG_DATA.publish;
71
+ const cfg = isPublish ? config_1.CONFIG_DATA.publish : config_1.CONFIG_DATA.pub;
72
+ if (isPublish) {
73
+ await (0, apis_1.publishVersion)({
74
+ brandName: cfg?.brandName,
75
+ brandId: cfg?.brandId,
76
+ appId: pkg['appId'],
77
+ username,
78
+ password,
79
+ type: cfg?.type,
80
+ platform: cfg?.platform,
81
+ path: remotePath,
82
+ remoteUrl: remoteUrls.length === 1 ? remoteUrls[0] : remoteUrls,
83
+ versionName: versionName,
84
+ versionCode: versionCode,
85
+ channel: cfg?.channel,
86
+ updateType: cfg?.updateType,
87
+ versionDesc: cfg?.versionDesc,
88
+ publishType: cfg?.publishType,
89
+ });
90
+ }
91
+ else {
92
+ await (0, apis_1.uploadVersion)({
93
+ brand: cfg?.brand,
94
+ username,
95
+ password,
96
+ type: cfg?.type,
97
+ status: cfg?.status,
98
+ platform: cfg?.platform,
99
+ path: remotePath,
100
+ remoteUrl: remoteUrls[0],
101
+ versionName: versionName,
102
+ versionCode: versionCode,
103
+ });
104
+ }
105
+ spinner.succeed('新版本提交成功');
106
+ }
107
+ catch (err) {
108
+ console.error(err);
109
+ spinner.fail('提交失败');
110
+ process.exit(1);
111
+ }
112
+ }
@@ -0,0 +1 @@
1
+ export default function (): Promise<void>;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = default_1;
4
+ const utils_1 = require("../utils");
5
+ const publish_1 = require("./publish");
6
+ async function default_1() {
7
+ const manifest = (0, utils_1.readManifest)();
8
+ await (0, publish_1.publish)({
9
+ ext: ['wgt', 'zip'],
10
+ name: manifest['appid'],
11
+ path: 'unpackage/release',
12
+ versionName: manifest['versionName'],
13
+ versionCode: manifest['versionCode'],
14
+ });
15
+ }
@@ -4,6 +4,8 @@ interface Cli {
4
4
  alipay?: string;
5
5
  }
6
6
  interface Cos {
7
+ secretid?: string;
8
+ secretkey?: string;
7
9
  bucket?: string;
8
10
  region?: string;
9
11
  path?: string;
@@ -18,6 +20,8 @@ interface App {
18
20
  certalias?: string;
19
21
  certfile?: string;
20
22
  certpassword?: string;
23
+ name?: string;
24
+ path?: string;
21
25
  };
22
26
  ios?: {
23
27
  bundle?: string;
@@ -25,6 +29,8 @@ interface App {
25
29
  profile?: string;
26
30
  certfile?: string;
27
31
  certpassword?: string;
32
+ name?: string;
33
+ path?: string;
28
34
  };
29
35
  wgt?: {
30
36
  name?: string;
@@ -34,6 +40,7 @@ interface App {
34
40
  }
35
41
  interface Mp {
36
42
  weixin?: {
43
+ type: string;
37
44
  privatekey?: string;
38
45
  };
39
46
  alipay?: {
@@ -48,15 +55,15 @@ interface Template {
48
55
  }
49
56
  interface Publish {
50
57
  brand: string;
51
- type: string;
58
+ type: number;
52
59
  path: string;
53
60
  name?: string;
54
- status?: string;
55
- platform?: string;
61
+ status?: number;
62
+ platform?: number;
56
63
  }
57
64
  interface PublishConfig {
58
65
  brandName?: string;
59
- brandId?: string | number;
66
+ brandId?: string;
60
67
  channel?: number;
61
68
  updateType?: number;
62
69
  versionDesc?: string;
@@ -67,9 +74,13 @@ interface PublishConfig {
67
74
  interface H5 {
68
75
  windows?: {
69
76
  appid?: string;
77
+ name?: string;
78
+ path?: string;
70
79
  };
71
80
  macos?: {
72
81
  appid?: string;
82
+ name?: string;
83
+ path?: string;
73
84
  };
74
85
  zip?: {
75
86
  name?: string;
@@ -77,12 +88,17 @@ interface H5 {
77
88
  source?: string;
78
89
  };
79
90
  }
91
+ export interface WebCredentials {
92
+ username?: string;
93
+ password?: string;
94
+ }
80
95
  export interface BaseConfig {
81
96
  branch?: string | boolean;
82
97
  cos?: Cos;
83
98
  cli?: Cli;
84
99
  skill?: Skill;
85
100
  template?: Template;
101
+ web?: Record<string, WebCredentials> | WebCredentials;
86
102
  }
87
103
  export interface Config extends BaseConfig {
88
104
  env?: string;
@@ -95,7 +111,8 @@ export interface Config extends BaseConfig {
95
111
  }
96
112
  export declare function getConfig(): BaseConfig;
97
113
  export declare function getLocalConfig(): Config;
98
- export declare function getMergeConfig(): Config;
99
- export declare function setConfig(config: any): void;
114
+ export declare function getMergeConfig(conf?: {}): Config;
115
+ export declare const CONFIG_DATA: Config;
116
+ export declare function setConfig(config: Config): void;
100
117
  export default function (...args: any[]): Promise<void>;
101
118
  export {};
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CONFIG_DATA = void 0;
3
4
  exports.getConfig = getConfig;
4
5
  exports.getLocalConfig = getLocalConfig;
5
6
  exports.getMergeConfig = getMergeConfig;
@@ -10,36 +11,36 @@ const path_1 = require("path");
10
11
  const lodash_1 = require("lodash");
11
12
  const flat_1 = require("flat");
12
13
  const fs_extra_1 = require("fs-extra");
13
- const utils_1 = require("../utils");
14
+ const const_1 = require("./const");
14
15
  function getConfig() {
15
- if (!(0, fs_1.existsSync)(utils_1.CONFIG_PATH)) {
16
+ if (!(0, fs_1.existsSync)(const_1.CONFIG_PATH)) {
16
17
  let hbuilderx = '';
17
- if (utils_1.IS_MAC) {
18
+ if (const_1.IS_MAC) {
18
19
  hbuilderx = '/Applications/HBuilderX.app/Contents/MacOS/cli';
19
20
  }
20
- else if (utils_1.IS_WIN) {
21
- hbuilderx = (0, path_1.join)(utils_1.HOME_PATH, 'AppData/Local/Programs/HBuilderX/cli.exe');
21
+ else if (const_1.IS_WIN) {
22
+ hbuilderx = (0, path_1.join)(const_1.HOME_PATH, 'AppData/Local/Programs/HBuilderX/cli.exe');
22
23
  }
23
- (0, fs_extra_1.writeJsonSync)(utils_1.CONFIG_PATH, {
24
+ (0, fs_extra_1.writeJsonSync)(const_1.CONFIG_PATH, {
24
25
  cli: {
25
26
  hbuilderx,
26
27
  },
27
28
  skill: {
28
- repo: utils_1.DEFAULT_SKILL_REPO,
29
+ repo: const_1.DEFAULT_SKILL_REPO,
29
30
  },
30
31
  template: {
31
- repo: utils_1.DEFAULT_TEMPLATE_REPO,
32
+ repo: const_1.DEFAULT_TEMPLATE_REPO,
32
33
  },
33
34
  }, { spaces: 2 });
34
35
  }
35
- return (0, fs_extra_1.readJsonSync)(utils_1.CONFIG_PATH, { throws: false }) || {};
36
+ return (0, fs_extra_1.readJsonSync)(const_1.CONFIG_PATH, { throws: false }) || {};
36
37
  }
37
38
  function getLocalConfig() {
38
39
  let config = {};
39
- if ((0, fs_1.existsSync)(utils_1.LOCAL_CONFIG_PATH)) {
40
- config = (0, fs_extra_1.readJsonSync)(utils_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
40
+ if ((0, fs_1.existsSync)(const_1.LOCAL_CONFIG_PATH)) {
41
+ config = (0, fs_extra_1.readJsonSync)(const_1.LOCAL_CONFIG_PATH, { throws: false }) || {};
41
42
  }
42
- const pkg = (0, fs_1.existsSync)(utils_1.PACKAGE_PATH) ? ((0, fs_extra_1.readJsonSync)(utils_1.PACKAGE_PATH, { throws: false }) || {}) : {};
43
+ const pkg = (0, fs_1.existsSync)(const_1.PACKAGE_PATH) ? ((0, fs_extra_1.readJsonSync)(const_1.PACKAGE_PATH, { throws: false }) || {}) : {};
43
44
  const appId = pkg.appId;
44
45
  if (appId) {
45
46
  if (!config.app)
@@ -64,22 +65,23 @@ function getLocalConfig() {
64
65
  }
65
66
  return config;
66
67
  }
67
- function getMergeConfig() {
68
- return (0, lodash_1.merge)({}, getConfig(), getLocalConfig());
68
+ function getMergeConfig(conf = {}) {
69
+ return (0, lodash_1.merge)(conf, getConfig(), getLocalConfig());
69
70
  }
71
+ exports.CONFIG_DATA = getMergeConfig();
70
72
  function setConfig(config) {
71
73
  const conf = getConfig();
72
- (0, fs_extra_1.writeJsonSync)(utils_1.CONFIG_PATH, (0, lodash_1.merge)({}, conf, config), { spaces: 2 });
74
+ (0, fs_extra_1.writeJsonSync)(const_1.CONFIG_PATH, (0, lodash_1.merge)({}, conf, config), { spaces: 2 });
73
75
  }
74
76
  async function default_1(...args) {
75
77
  if (args[0] === 'list') {
76
- const obj = (0, flat_1.flatten)(getMergeConfig());
78
+ const obj = (0, flat_1.flatten)(exports.CONFIG_DATA);
77
79
  Object.keys(obj).forEach((key) => {
78
80
  console.log(`${key}=${obj[key]}`);
79
81
  });
80
82
  }
81
83
  else if (args[0]) {
82
- const obj = (0, flat_1.flatten)(getMergeConfig());
84
+ const obj = (0, flat_1.flatten)(exports.CONFIG_DATA);
83
85
  if (obj[args[0]] != null) {
84
86
  console.log(obj[args[0]]);
85
87
  }
@@ -14,6 +14,30 @@ export declare const DIST_PATH: string;
14
14
  export declare const MAINFEST_PATH: string;
15
15
  export { HOME_PATH };
16
16
  export declare const PLATFORM_OPTIONS: readonly ["h5", "mp-alipay", "mp-baidu", "mp-jd", "mp-kuaishou", "mp-qq", "mp-toutiao", "mp-weixin", "app", "app-ios", "app-android", "app-harmony", "windows", "macos", "linux"];
17
- export declare const COMPILER_OPTIONS: readonly ["vite", "uni", "electron-vite"];
17
+ export declare const COMPILER_OPTIONS: readonly ["vite", "uni", "electron-vite", "gradlew"];
18
18
  export declare const DEFAULT_SKILL_REPO = "http://10.10.10.16/caoben/project-template.git";
19
19
  export declare const DEFAULT_TEMPLATE_REPO = "http://10.10.10.16/caoben/project-template.git";
20
+ export declare const BASE_URL: {
21
+ dev: string;
22
+ sit: string;
23
+ uat: string;
24
+ pre: string;
25
+ prod: string;
26
+ };
27
+ export declare enum APP_TYPE {
28
+ '医生端' = 1,
29
+ '门店端' = 2,
30
+ '患者端' = 3
31
+ }
32
+ export declare enum CHANNEL_TYPE {
33
+ '患者端' = 1,
34
+ '医生端' = 2,
35
+ '门店端' = 3
36
+ }
37
+ export declare enum PLATFORM_TYPE {
38
+ 'Android' = 1,
39
+ 'iOS' = 2,
40
+ 'Harmony' = 3,
41
+ 'Windows' = 4,
42
+ 'macOS' = 5
43
+ }
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DEFAULT_TEMPLATE_REPO = exports.DEFAULT_SKILL_REPO = exports.COMPILER_OPTIONS = exports.PLATFORM_OPTIONS = exports.HOME_PATH = exports.MAINFEST_PATH = exports.DIST_PATH = exports.SRC_PATH = exports.HAS_SRC = exports.BUILD_ENV_PATH = exports.LOCAL_CONFIG_PATH = exports.PACKAGE_PATH = exports.COMMAND_PATH = exports.CONFIG_PATH = exports.IS_WIN = exports.IS_MAC = exports.PLATFORM = exports.BIN_NAME = void 0;
6
+ exports.PLATFORM_TYPE = exports.CHANNEL_TYPE = exports.APP_TYPE = exports.BASE_URL = exports.DEFAULT_TEMPLATE_REPO = exports.DEFAULT_SKILL_REPO = exports.COMPILER_OPTIONS = exports.PLATFORM_OPTIONS = exports.HOME_PATH = exports.MAINFEST_PATH = exports.DIST_PATH = exports.SRC_PATH = exports.HAS_SRC = exports.BUILD_ENV_PATH = exports.LOCAL_CONFIG_PATH = exports.PACKAGE_PATH = exports.COMMAND_PATH = exports.CONFIG_PATH = exports.IS_WIN = exports.IS_MAC = exports.PLATFORM = exports.BIN_NAME = void 0;
7
7
  const path_1 = require("path");
8
8
  const os_1 = __importDefault(require("os"));
9
9
  const fs_1 = require("fs");
@@ -40,6 +40,35 @@ exports.PLATFORM_OPTIONS = [
40
40
  'macos',
41
41
  'linux',
42
42
  ];
43
- exports.COMPILER_OPTIONS = ['vite', 'uni', 'electron-vite'];
43
+ exports.COMPILER_OPTIONS = ['vite', 'uni', 'electron-vite', 'gradlew'];
44
44
  exports.DEFAULT_SKILL_REPO = 'http://10.10.10.16/caoben/project-template.git';
45
45
  exports.DEFAULT_TEMPLATE_REPO = 'http://10.10.10.16/caoben/project-template.git';
46
+ exports.BASE_URL = {
47
+ dev: 'https://dev-zfqh.keeprisk.com',
48
+ sit: 'https://sit-zfqh.keeprisk.com',
49
+ uat: 'https://pre-zfqh.keeprisk.com',
50
+ pre: 'https://pre-api.shewenzhongyi.com',
51
+ prod: 'https://api.shewenzhongyi.com',
52
+ };
53
+ // 旧版
54
+ var APP_TYPE;
55
+ (function (APP_TYPE) {
56
+ APP_TYPE[APP_TYPE["\u533B\u751F\u7AEF"] = 1] = "\u533B\u751F\u7AEF";
57
+ APP_TYPE[APP_TYPE["\u95E8\u5E97\u7AEF"] = 2] = "\u95E8\u5E97\u7AEF";
58
+ APP_TYPE[APP_TYPE["\u60A3\u8005\u7AEF"] = 3] = "\u60A3\u8005\u7AEF";
59
+ })(APP_TYPE || (exports.APP_TYPE = APP_TYPE = {}));
60
+ // 新版
61
+ var CHANNEL_TYPE;
62
+ (function (CHANNEL_TYPE) {
63
+ CHANNEL_TYPE[CHANNEL_TYPE["\u60A3\u8005\u7AEF"] = 1] = "\u60A3\u8005\u7AEF";
64
+ CHANNEL_TYPE[CHANNEL_TYPE["\u533B\u751F\u7AEF"] = 2] = "\u533B\u751F\u7AEF";
65
+ CHANNEL_TYPE[CHANNEL_TYPE["\u95E8\u5E97\u7AEF"] = 3] = "\u95E8\u5E97\u7AEF";
66
+ })(CHANNEL_TYPE || (exports.CHANNEL_TYPE = CHANNEL_TYPE = {}));
67
+ var PLATFORM_TYPE;
68
+ (function (PLATFORM_TYPE) {
69
+ PLATFORM_TYPE[PLATFORM_TYPE["Android"] = 1] = "Android";
70
+ PLATFORM_TYPE[PLATFORM_TYPE["iOS"] = 2] = "iOS";
71
+ PLATFORM_TYPE[PLATFORM_TYPE["Harmony"] = 3] = "Harmony";
72
+ PLATFORM_TYPE[PLATFORM_TYPE["Windows"] = 4] = "Windows";
73
+ PLATFORM_TYPE[PLATFORM_TYPE["macOS"] = 5] = "macOS";
74
+ })(PLATFORM_TYPE || (exports.PLATFORM_TYPE = PLATFORM_TYPE = {}));
@@ -4,3 +4,5 @@ export declare function filterToArray(obj?: Record<string, any>): any[];
4
4
  export declare function spawnSync(command?: string): import("child_process").SpawnSyncReturns<Buffer>;
5
5
  export declare function resolvePlaceholder(input: string, data: Record<string, any>): string;
6
6
  export declare function getBinPath(name: string): string;
7
+ export declare function getEnvVersionCode(): string | 0;
8
+ export declare function getEnvApiBaseUrl(): string;
@@ -9,6 +9,8 @@ exports.filterToArray = filterToArray;
9
9
  exports.spawnSync = spawnSync;
10
10
  exports.resolvePlaceholder = resolvePlaceholder;
11
11
  exports.getBinPath = getBinPath;
12
+ exports.getEnvVersionCode = getEnvVersionCode;
13
+ exports.getEnvApiBaseUrl = getEnvApiBaseUrl;
12
14
  const fs_1 = require("fs");
13
15
  const path_1 = require("path");
14
16
  const cross_spawn_1 = __importDefault(require("cross-spawn"));
@@ -59,3 +61,21 @@ function getBinPath(name) {
59
61
  }
60
62
  return name;
61
63
  }
64
+ function readEnvContent() {
65
+ const buildEnv = process.env.BUILD_ENV || '';
66
+ const jsEnvPath = (0, path_1.join)(process.cwd(), `env/.env.${buildEnv}.js`);
67
+ const tsEnvPath = (0, path_1.join)(process.cwd(), `env/.env.${buildEnv}.ts`);
68
+ return (0, fs_1.existsSync)(jsEnvPath)
69
+ ? (0, fs_1.readFileSync)(jsEnvPath).toString()
70
+ : (0, fs_1.existsSync)(tsEnvPath)
71
+ ? (0, fs_1.readFileSync)(tsEnvPath).toString()
72
+ : '';
73
+ }
74
+ function getEnvVersionCode() {
75
+ const match = readEnvContent().match(/code:\s*(\d+)/i);
76
+ return match ? match[1] : 0;
77
+ }
78
+ function getEnvApiBaseUrl() {
79
+ const match = readEnvContent().match(/['"]?api['"]?:\s*\{\s*['"]?baseUrl['"]?:\s*['"]([^'"]+)['"]\s*,?\s*\}/i);
80
+ return match ? match[1] : '';
81
+ }
@@ -1,3 +1,5 @@
1
1
  export * from './const';
2
2
  export * from './function';
3
+ export * from './config';
4
+ export * from './png2ico';
3
5
  export * as log from './log';
@@ -29,4 +29,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.log = void 0;
30
30
  __exportStar(require("./const"), exports);
31
31
  __exportStar(require("./function"), exports);
32
+ __exportStar(require("./config"), exports);
33
+ __exportStar(require("./png2ico"), exports);
32
34
  exports.log = __importStar(require("./log"));
@@ -0,0 +1 @@
1
+ export declare function png2ico(srcPath: string, outPath: string): Promise<void>;
@@ -0,0 +1,48 @@
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.png2ico = png2ico;
7
+ const sharp_1 = __importDefault(require("sharp"));
8
+ const fs_1 = require("fs");
9
+ const sizes = [16, 24, 32, 48, 64, 128, 256];
10
+ const cornerRadiusRatio = 0.18; // 18%
11
+ async function png2ico(srcPath, outPath) {
12
+ const pngBuffers = [];
13
+ for (const size of sizes) {
14
+ const radius = Math.round(size * cornerRadiusRatio);
15
+ const mask = Buffer.from(`<svg><rect x="0" y="0" width="${size}" height="${size}" rx="${radius}" ry="${radius}" fill="white"/></svg>`);
16
+ const buf = await (0, sharp_1.default)(srcPath)
17
+ .resize(size, size)
18
+ .composite([{ input: mask, blend: 'dest-in' }])
19
+ .png()
20
+ .toBuffer();
21
+ pngBuffers.push({ size, data: buf });
22
+ }
23
+ const count = pngBuffers.length;
24
+ const headerSize = 6;
25
+ const dirEntrySize = 16;
26
+ let offset = headerSize + dirEntrySize * count;
27
+ const header = Buffer.alloc(headerSize);
28
+ header.writeUInt16LE(0, 0);
29
+ header.writeUInt16LE(1, 2);
30
+ header.writeUInt16LE(count, 4);
31
+ const dirEntries = pngBuffers.map(({ size, data }) => {
32
+ const entry = Buffer.alloc(dirEntrySize);
33
+ entry.writeUInt8(size >= 256 ? 0 : size, 0);
34
+ entry.writeUInt8(size >= 256 ? 0 : size, 1);
35
+ entry.writeUInt8(0, 2);
36
+ entry.writeUInt8(0, 3);
37
+ entry.writeUInt16LE(1, 4);
38
+ entry.writeUInt16LE(32, 6);
39
+ entry.writeUInt32LE(data.length, 8);
40
+ entry.writeUInt32LE(offset, 12);
41
+ offset += data.length;
42
+ return entry;
43
+ });
44
+ const icoBuffer = Buffer.concat([header, ...dirEntries, ...pngBuffers.map((p) => p.data)]);
45
+ (0, fs_1.writeFileSync)(outPath, icoBuffer);
46
+ const kb = (icoBuffer.length / 1024).toFixed(1);
47
+ console.log(`Done: ${outPath} (${kb} KB, sizes: ${sizes.join(', ')})`);
48
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gmcb/cli",
3
- "version": "0.5.5",
3
+ "version": "0.6.1",
4
4
  "description": "工茂草本前端命令行工具",
5
5
  "author": "yinjiazeng@163.com",
6
6
  "license": "MIT",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "keywords": [
20
20
  "gmcb",
21
- "cli"
21
+ "zfqh"
22
22
  ],
23
23
  "files": [
24
24
  "lib",
@@ -30,16 +30,20 @@
30
30
  "adm-zip": "^0.5.16",
31
31
  "chalk": "^4.1.2",
32
32
  "commander": "^12.1.0",
33
+ "cos-nodejs-sdk-v5": "^2.14.6",
33
34
  "cross-env": "^7.0.3",
34
35
  "cross-spawn": "^7.0.6",
36
+ "dateformat": "^4.6.3",
35
37
  "delay": "^5.0.0",
36
38
  "download": "^8.0.0",
37
39
  "flat": "^5.0.2",
38
40
  "fs-extra": "^10.1.0",
39
41
  "inquirer": "^8.2.6",
40
42
  "lodash": "^4.17.21",
43
+ "miniprogram-ci": "^2.1.14",
41
44
  "ora": "^5.4.1",
42
45
  "rimraf": "^3.0.2",
46
+ "sharp": "^0.33.5",
43
47
  "simple-git": "^3.27.0",
44
48
  "strip-json-comments": "^3.1.1",
45
49
  "user-home": "^3.0.0"
@@ -47,6 +51,7 @@
47
51
  "devDependencies": {
48
52
  "@types/adm-zip": "^0.5.7",
49
53
  "@types/cross-spawn": "^6.0.6",
54
+ "@types/dateformat": "^5.0.3",
50
55
  "@types/download": "^8.0.5",
51
56
  "@types/flat": "^5.0.5",
52
57
  "@types/fs-extra": "^11.0.4",
@@ -54,5 +59,5 @@
54
59
  "@types/rimraf": "^4.0.5",
55
60
  "@types/user-home": "^2.0.2"
56
61
  },
57
- "gitHead": "d1d89a811379dc7049a3920276a2b8845b6c3fd2"
62
+ "gitHead": "7c47fc74419f1ef0f1b3f70148c6dfabb4251f14"
58
63
  }