@widget-js/cli 1.2.11 → 24.1.1-beta.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/jest.config.js CHANGED
@@ -5,10 +5,10 @@ module.exports = {
5
5
  '**/?(*.)+(spec|test).+(ts|tsx|js)',
6
6
  ],
7
7
  transform: {
8
- '^.+\\.(ts|tsx)$': ['ts-jest',{
9
- tsconfig: 'tsconfig.json'
8
+ '^.+\\.(ts|tsx)$': ['ts-jest', {
9
+ tsconfig: 'tsconfig.json',
10
10
  }],
11
11
  '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
12
12
  './config/fileTransformer.js',
13
- }
13
+ },
14
14
  }
@@ -11,23 +11,23 @@ var PrettierUtils = class {
11
11
  };
12
12
 
13
13
  // src/utils/EJSUtils.ts
14
- import path from "path";
15
- import fs from "fs";
14
+ import path from "node:path";
15
+ import fs from "node:fs";
16
16
  import ejs from "ejs";
17
17
  import { dirname } from "dirname-filename-esm";
18
18
  var EJSUtils = class {
19
19
  static async renderToFile(templateFile, outputFile, parser, renderOptions) {
20
20
  const defineTemplatePath = path.join(dirname(import.meta), "../template", templateFile);
21
- let defineTemplate = fs.readFileSync(defineTemplatePath, "utf8");
22
- let code = ejs.render(defineTemplate, renderOptions);
21
+ const defineTemplate = fs.readFileSync(defineTemplatePath, "utf8");
22
+ const code = ejs.render(defineTemplate, renderOptions);
23
23
  const formattedEJSCode = await PrettierUtils.format(code, parser);
24
24
  fs.writeFileSync(outputFile, formattedEJSCode);
25
25
  }
26
26
  };
27
27
 
28
28
  // src/utils/WidgetPackageUtils.ts
29
- import path2 from "path";
30
- import fs2 from "fs";
29
+ import path2 from "node:path";
30
+ import fs2 from "node:fs";
31
31
  var WidgetPackageUtils = class {
32
32
  static getRootDir(widgetPackage) {
33
33
  const widgetRootDir = path2.join(process.cwd(), widgetPackage.devOptions?.folder ?? "./src/widgets");
@@ -1,7 +1,7 @@
1
1
  // src/utils.ts
2
- import path from "path";
3
- import process from "process";
4
- import fs from "fs";
2
+ import path from "node:path";
3
+ import process from "node:process";
4
+ import fs from "node:fs";
5
5
  import packageJson from "package-json";
6
6
  var widgetPackages = {
7
7
  "@widget-js/core": "",
@@ -23,7 +23,7 @@ function getPackagePath() {
23
23
  var Utils = class {
24
24
  static async getRemoteVersion(packageName) {
25
25
  const metadata = await packageJson(packageName);
26
- let version = metadata["version"];
26
+ const version = metadata.version;
27
27
  return version;
28
28
  }
29
29
  static getPackagePath() {
@@ -33,7 +33,7 @@ var Utils = class {
33
33
  return JSON.parse(fs.readFileSync(this.getPackagePath()).toString());
34
34
  }
35
35
  static getPackageVersion() {
36
- return this.getPackageJson()["version"];
36
+ return this.getPackageJson().version;
37
37
  }
38
38
  /**
39
39
  * 检查包名是否合法,包名格式一般为 倒置域名与java包类似
@@ -1,6 +1,6 @@
1
1
  // src/promts/promptChecker.ts
2
2
  import inquirer from "inquirer";
3
- var promptChecker = async (prompt, checker) => {
3
+ async function promptChecker(prompt, checker) {
4
4
  const answer = await inquirer.prompt([prompt]);
5
5
  if (checker) {
6
6
  if (checker(answer)) {
@@ -10,7 +10,7 @@ var promptChecker = async (prompt, checker) => {
10
10
  }
11
11
  }
12
12
  return answer[prompt.name];
13
- };
13
+ }
14
14
  var promptChecker_default = promptChecker;
15
15
 
16
16
  export {
@@ -1,33 +1,33 @@
1
1
  import {
2
2
  EJSUtils,
3
3
  WidgetPackageUtils
4
- } from "./chunk-RAXJBANW.js";
4
+ } from "./chunk-I4ZBPB2S.js";
5
5
  import {
6
6
  promptChecker_default
7
- } from "./chunk-3GPAHQ6O.js";
7
+ } from "./chunk-XPJ33Y5L.js";
8
8
  import {
9
9
  exit
10
- } from "./chunk-IJH6LXRT.js";
10
+ } from "./chunk-RDJH7Z4C.js";
11
11
 
12
12
  // src/createWidget.ts
13
- import path from "path";
14
- import fs from "fs";
13
+ import path from "node:path";
14
+ import fs from "node:fs";
15
+ import { fileURLToPath } from "node:url";
15
16
  import consola from "consola";
16
17
  import { paramCase, snakeCase } from "change-case";
17
18
  import inquirer from "inquirer";
18
19
  import shell from "shelljs";
19
20
  import chalk from "chalk";
20
21
  import { scanWidgetPackage } from "@widget-js/utils";
21
- import { fileURLToPath } from "url";
22
22
  var __filename = fileURLToPath(import.meta.url);
23
23
  var __dirname = path.dirname(__filename);
24
24
  async function createWidget() {
25
- let widgetPackage = await scanWidgetPackage();
25
+ const widgetPackage = await scanWidgetPackage();
26
26
  if (!widgetPackage) {
27
27
  consola.error("widget.ts or widget.json not found");
28
28
  return;
29
29
  }
30
- let widgetRootDir = WidgetPackageUtils.getRootDir(widgetPackage);
30
+ const widgetRootDir = WidgetPackageUtils.getRootDir(widgetPackage);
31
31
  if (widgetPackage.devOptions && widgetPackage.devOptions.folder) {
32
32
  consola.info(`\u7EC4\u4EF6\u8DEF\u5F84\uFF1A${widgetRootDir}`);
33
33
  } else {
@@ -45,7 +45,7 @@ async function createWidget() {
45
45
  return sum - max - min;
46
46
  }
47
47
  };
48
- let name = await promptChecker_default(
48
+ const name = await promptChecker_default(
49
49
  {
50
50
  type: "input",
51
51
  name: "name",
@@ -61,13 +61,13 @@ async function createWidget() {
61
61
  }
62
62
  );
63
63
  consola.log(chalk.green(name));
64
- let title = await promptChecker_default({
64
+ const title = await promptChecker_default({
65
65
  type: "input",
66
66
  name: "title",
67
67
  message: chalk.blue("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u6807\u9898\uFF0C\u5982\uFF1A\u5012\u8BA1\u65F6")
68
68
  });
69
69
  consola.log(chalk.green(title));
70
- let answerW = await promptChecker_default(
70
+ const answerW = await promptChecker_default(
71
71
  {
72
72
  type: "checkbox",
73
73
  name: "w",
@@ -89,7 +89,7 @@ async function createWidget() {
89
89
  }
90
90
  );
91
91
  consola.log(chalk.green(answerW));
92
- let answerH = await promptChecker_default(
92
+ const answerH = await promptChecker_default(
93
93
  {
94
94
  type: "checkbox",
95
95
  name: "h",
@@ -111,7 +111,7 @@ async function createWidget() {
111
111
  }
112
112
  );
113
113
  consola.log(chalk.green(answerH));
114
- let configurable = await promptChecker_default({
114
+ const configurable = await promptChecker_default({
115
115
  type: "confirm",
116
116
  name: "configurable",
117
117
  message: chalk.blue("\u7EC4\u4EF6\u662F\u5426\u53EF\u914D\u7F6E\uFF0C\u4F8B\u5982\u4FEE\u6539\u80CC\u666F\u989C\u8272\uFF0C\u5B57\u4F53\u5927\u5C0F\u7B49")
@@ -125,12 +125,12 @@ async function createWidget() {
125
125
  const maxHeight = Math.max(...answerH);
126
126
  const snakeCaseName = snakeCase(name);
127
127
  const paramCaseName = paramCase(name);
128
- const widgetName = widgetPackage.name + "." + snakeCaseName;
128
+ const widgetName = `${widgetPackage.name}.${snakeCaseName}`;
129
129
  const widgetDir = path.join(widgetRootDir, paramCaseName);
130
130
  if (!fs.existsSync(widgetDir)) {
131
131
  fs.mkdirSync(widgetDir);
132
132
  } else {
133
- let answer = await inquirer.prompt([
133
+ const answer = await inquirer.prompt([
134
134
  {
135
135
  type: "confirm",
136
136
  name: "override",
@@ -188,7 +188,7 @@ async function createWidget() {
188
188
  //FBI WANING! ROUTE PLACE`);
189
189
  }
190
190
  fs.writeFileSync(routeFile, routeContent);
191
- let gitAdd = `git add ${widgetDir}`;
191
+ const gitAdd = `git add ${widgetDir}`;
192
192
  consola.info(chalk.grey(gitAdd));
193
193
  shell.exec(gitAdd);
194
194
  consola.log("=================");
@@ -2,20 +2,20 @@ import {
2
2
  Utils,
3
3
  getPackagePath,
4
4
  widgetPackages
5
- } from "./chunk-IJH6LXRT.js";
5
+ } from "./chunk-RDJH7Z4C.js";
6
6
 
7
7
  // src/dependencies/remoteDependencies.ts
8
+ import fs from "node:fs";
8
9
  import ora from "ora";
9
- import fs from "fs";
10
10
  var spinner = ora("Connecting");
11
11
  var RemoteDependencies;
12
12
  ((RemoteDependencies2) => {
13
13
  async function start() {
14
14
  spinner.start();
15
- let json = Utils.getPackageJson();
16
- let packageNames = Object.keys(widgetPackages);
17
- let dependencies = json["dependencies"];
18
- let devDependencies = json["devDependencies"];
15
+ const json = Utils.getPackageJson();
16
+ const packageNames = Object.keys(widgetPackages);
17
+ const dependencies = json.dependencies;
18
+ const devDependencies = json.devDependencies;
19
19
  await upgradePackage(dependencies, packageNames);
20
20
  await upgradePackage(devDependencies, packageNames);
21
21
  fs.writeFileSync(getPackagePath(), JSON.stringify(json, null, 2));
@@ -23,9 +23,9 @@ var RemoteDependencies;
23
23
  }
24
24
  RemoteDependencies2.start = start;
25
25
  async function upgradePackage(dependencies, packageNames) {
26
- let localPackages = Object.keys(dependencies);
27
- for (let localPackage of localPackages) {
28
- if (packageNames.indexOf(localPackage) > -1) {
26
+ const localPackages = Object.keys(dependencies);
27
+ for (const localPackage of localPackages) {
28
+ if (packageNames.includes(localPackage)) {
29
29
  let packageVersion = widgetPackages[localPackage];
30
30
  if (!packageVersion) {
31
31
  spinner.info(`Fetching package version:${localPackage}`);
@@ -40,17 +40,17 @@ var RemoteDependencies;
40
40
  })(RemoteDependencies || (RemoteDependencies = {}));
41
41
 
42
42
  // src/dependencies/localDependencies.ts
43
+ import fs2 from "node:fs";
43
44
  import ora2 from "ora";
44
- import fs2 from "fs";
45
45
  var spinner2 = ora2("Connecting");
46
46
  var LocalDependencies;
47
47
  ((LocalDependencies2) => {
48
48
  async function start() {
49
49
  spinner2.start();
50
- let json = Utils.getPackageJson();
51
- let packageNames = Object.keys(widgetPackages);
52
- let dependencies = json["dependencies"];
53
- let devDependencies = json["devDependencies"];
50
+ const json = Utils.getPackageJson();
51
+ const packageNames = Object.keys(widgetPackages);
52
+ const dependencies = json.dependencies;
53
+ const devDependencies = json.devDependencies;
54
54
  await setWorkspaceVersion(dependencies, packageNames);
55
55
  await setWorkspaceVersion(devDependencies, packageNames);
56
56
  fs2.writeFileSync(getPackagePath(), JSON.stringify(json, null, 2));
@@ -58,9 +58,9 @@ var LocalDependencies;
58
58
  }
59
59
  LocalDependencies2.start = start;
60
60
  async function setWorkspaceVersion(dependencies, packageNames) {
61
- let localPackages = Object.keys(dependencies);
62
- for (let localPackage of localPackages) {
63
- if (packageNames.indexOf(localPackage) > -1) {
61
+ const localPackages = Object.keys(dependencies);
62
+ for (const localPackage of localPackages) {
63
+ if (packageNames.includes(localPackage)) {
64
64
  dependencies[localPackage] = `workspace:*`;
65
65
  }
66
66
  }
@@ -69,7 +69,7 @@ var LocalDependencies;
69
69
 
70
70
  // src/dependencies/index.ts
71
71
  async function dependencies_default(options) {
72
- let type = options.type;
72
+ const type = options.type;
73
73
  if (type == "remote") {
74
74
  await RemoteDependencies.start();
75
75
  } else {
package/lib/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  // src/index.ts
2
+ import fs from "node:fs";
3
+ import path from "node:path";
4
+ import * as process from "node:process";
2
5
  import { Option, program } from "commander";
3
- import fs from "fs";
4
- import path from "path";
5
- import * as process from "process";
6
6
  import figlet from "figlet";
7
7
  import gradient from "gradient-string";
8
8
  import { dirname } from "dirname-filename-esm";
@@ -11,22 +11,22 @@ var cliPackage = JSON.parse(fs.readFileSync(packageJsonPath).toString());
11
11
  console.log(gradient.pastel.multiline(figlet.textSync("widget-cli", { horizontalLayout: "full" })));
12
12
  program.version(`@widget-js/cli ${cliPackage.version}`).usage("<command> [options]");
13
13
  program.command("create").description("Create new widget").action(async () => {
14
- const createWidget = await import("./createWidget-UFW26NP6.js");
14
+ const createWidget = await import("./createWidget-4LQ6PVEM.js");
15
15
  await createWidget.default();
16
16
  });
17
17
  var dependenciesOption = new Option("-t, --type <type>").choices(["remote", "local"]);
18
18
  program.command("dependencies").description("Set @widget-js dependencies to local(workspace:*) or remote(^1.0.0 etc)").addOption(dependenciesOption).action(async (options) => {
19
- let dependencies = await import("./dependencies-MRJDJJ6Q.js");
19
+ const dependencies = await import("./dependencies-AVNHKRF3.js");
20
20
  await dependencies.default(options);
21
21
  });
22
22
  program.command("init").description("Initialize widget-js project").action(async () => {
23
- const init = await import("./init-MQONV3N3.js");
23
+ const init = await import("./init-HCEGKTNF.js");
24
24
  await init.init();
25
25
  });
26
26
  var typeOption = new Option("-t, --type <type>").choices(["ftp", "oss"]);
27
27
  var fileOption = new Option("-f, --file <file>");
28
28
  program.command("release").description("\u901A\u8FC7FTP/OSS\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").addOption(typeOption).addOption(fileOption).action(async (options, command) => {
29
- let release = await import("./release-XUYU5WNC.js");
29
+ const release = await import("./release-PIRAQ7A6.js");
30
30
  await release.default(options);
31
31
  });
32
32
  program.parse(process.argv);
@@ -2,23 +2,23 @@ import {
2
2
  EJSUtils,
3
3
  PrettierUtils,
4
4
  WidgetPackageUtils
5
- } from "./chunk-RAXJBANW.js";
5
+ } from "./chunk-I4ZBPB2S.js";
6
6
  import {
7
7
  promptChecker_default
8
- } from "./chunk-3GPAHQ6O.js";
8
+ } from "./chunk-XPJ33Y5L.js";
9
9
  import {
10
10
  Utils
11
- } from "./chunk-IJH6LXRT.js";
11
+ } from "./chunk-RDJH7Z4C.js";
12
12
 
13
13
  // src/init/init.ts
14
- import path from "path";
15
- import process from "process";
16
- import fs from "fs";
14
+ import path from "node:path";
15
+ import process from "node:process";
16
+ import fs from "node:fs";
17
+ import { fileURLToPath } from "node:url";
17
18
  import consola from "consola";
18
19
  import chalk from "chalk";
19
20
  import ora from "ora";
20
21
  import { scanWidgetPackage } from "@widget-js/utils";
21
- import { fileURLToPath } from "url";
22
22
  var __filename = fileURLToPath(import.meta.url);
23
23
  var __dirname = path.dirname(__filename);
24
24
  var spinner = ora("Loading");
@@ -27,7 +27,7 @@ async function init() {
27
27
  await addWidgetTs();
28
28
  }
29
29
  async function addWidgetTs() {
30
- let name = await promptChecker_default(
30
+ const name = await promptChecker_default(
31
31
  {
32
32
  type: "input",
33
33
  name: "name",
@@ -42,7 +42,7 @@ async function addWidgetTs() {
42
42
  return true;
43
43
  }
44
44
  );
45
- let widgetPackageTs = path.join(process.cwd(), "widget.package.ts");
45
+ const widgetPackageTs = path.join(process.cwd(), "widget.package.ts");
46
46
  if (fs.existsSync(widgetPackageTs)) {
47
47
  spinner.info("widget.package.ts\u5DF2\u5B58\u5728\uFF0C\u8DF3\u8FC7");
48
48
  } else {
@@ -55,19 +55,19 @@ async function addWidgetTs() {
55
55
  }
56
56
  async function addDependencies() {
57
57
  const packageJson = Utils.getPackageJson();
58
- let dependencies = packageJson["dependencies"];
59
- let devDependencies = packageJson["devDependencies"];
58
+ let dependencies = packageJson.dependencies;
59
+ const devDependencies = packageJson.devDependencies;
60
60
  if (!dependencies) {
61
61
  dependencies = {};
62
62
  }
63
63
  if (!devDependencies) {
64
- packageJson["devDependencies"] = {};
64
+ packageJson.devDependencies = {};
65
65
  }
66
66
  await addDependency("@widget-js/core", dependencies);
67
67
  await addDependency("@widget-js/vue3", dependencies);
68
68
  await addDependency("@widget-js/vite-plugin-widget", devDependencies);
69
- packageJson["dependencies"] = dependencies;
70
- packageJson["devDependencies"] = devDependencies;
69
+ packageJson.dependencies = dependencies;
70
+ packageJson.devDependencies = devDependencies;
71
71
  fs.writeFileSync(Utils.getPackagePath(), JSON.stringify(packageJson, null, 2));
72
72
  }
73
73
  async function addVitePlugin() {
@@ -79,7 +79,7 @@ async function addVitePlugin() {
79
79
  }
80
80
  let viteConfig = fs.readFileSync(viteConfigPath).toString();
81
81
  viteConfig = `import widget from '@widget-js/vite-plugin-widget'
82
- ` + viteConfig;
82
+ ${viteConfig}`;
83
83
  viteConfig = viteConfig.replace("vue()", `vue(),widget()`);
84
84
  fs.writeFileSync(viteConfigPath, await PrettierUtils.format(viteConfig, "typescript"));
85
85
  }
@@ -1,16 +1,19 @@
1
1
  import {
2
2
  promptChecker_default
3
- } from "./chunk-3GPAHQ6O.js";
3
+ } from "./chunk-XPJ33Y5L.js";
4
4
  import {
5
5
  Utils
6
- } from "./chunk-IJH6LXRT.js";
6
+ } from "./chunk-RDJH7Z4C.js";
7
7
 
8
8
  // src/release/release.ts
9
- import fs4 from "fs";
10
- import path2 from "path";
9
+ import fs4 from "node:fs";
10
+ import path2 from "node:path";
11
+ import { Buffer as Buffer2 } from "node:buffer";
12
+ import chalk2 from "chalk";
13
+ import consola3 from "consola";
11
14
 
12
15
  // src/release/update-zip.ts
13
- import fs from "fs";
16
+ import fs from "node:fs";
14
17
  import archiver from "archiver";
15
18
  function zipDirectory(sourceDir, outPath, ignoreDir) {
16
19
  const archive = archiver("zip", { zlib: { level: 9 } });
@@ -24,9 +27,10 @@ function zipDirectory(sourceDir, outPath, ignoreDir) {
24
27
  var update_zip_default = zipDirectory;
25
28
 
26
29
  // src/release/oss.ts
30
+ import fs2 from "node:fs";
27
31
  import OSS from "ali-oss";
28
- import fs2 from "fs";
29
32
  import chalk from "chalk";
33
+ import consola from "consola";
30
34
  var packageData = JSON.parse(fs2.readFileSync("./package.json").toString());
31
35
  var AccessKeyID = packageData.oss?.id ?? "default";
32
36
  var AccessKeySecret = packageData.oss?.secret ?? "default";
@@ -48,37 +52,34 @@ var clinet = new OSS({
48
52
  });
49
53
  async function put(ossPath, file) {
50
54
  try {
51
- const result = await clinet.put(ossPath, file, { headers });
52
- console.log(chalk.green(`\u4E0A\u4F20\u6210\u529F\uFF1A${file}->${ossPath}`));
55
+ await clinet.put(ossPath, file, { headers });
56
+ consola.log(chalk.green(`\u4E0A\u4F20\u6210\u529F\uFF1A${file}->${ossPath}`));
53
57
  } catch (e) {
54
- console.log(e);
58
+ consola.log(e);
55
59
  }
56
60
  }
57
61
  async function copy(dist, src) {
58
62
  try {
59
- const result = await clinet.copy(dist, src, { headers });
60
- console.log(chalk.green(`\u590D\u5236\u6210\u529F\uFF1A${src}->${dist}`));
63
+ await clinet.copy(dist, src, { headers });
64
+ consola.log(chalk.green(`\u590D\u5236\u6210\u529F\uFF1A${src}->${dist}`));
61
65
  } catch (e) {
62
66
  console.error(e);
63
67
  }
64
68
  }
65
69
 
66
- // src/release/release.ts
67
- import chalk2 from "chalk";
68
-
69
70
  // src/release/ftp.ts
70
- import path from "path";
71
- import fs3 from "fs";
71
+ import path from "node:path";
72
+ import fs3 from "node:fs";
73
+ import os from "node:os";
74
+ import * as process from "node:process";
72
75
  import SSHConfig from "@widget-js/ssh-config";
73
- import os from "os";
74
76
  import Client from "ssh2-sftp-client";
75
- import consola from "consola";
77
+ import consola2 from "consola";
76
78
  import inquirer from "inquirer";
77
79
  import ora from "ora";
78
- import * as process from "process";
79
80
  import { minimatch } from "minimatch";
80
81
  async function checkParentDir(ftpClient, file, onMkdir) {
81
- let dir = path.dirname(file);
82
+ const dir = path.dirname(file);
82
83
  const dirExists = await ftpClient.exists(dir);
83
84
  if (!dirExists) {
84
85
  onMkdir(dir);
@@ -86,31 +87,31 @@ async function checkParentDir(ftpClient, file, onMkdir) {
86
87
  }
87
88
  }
88
89
  async function runSSH(sshConfig, releaseConfig) {
89
- consola.info("run ssh:", sshConfig);
90
+ consola2.info("run ssh:", sshConfig);
90
91
  const answer = await inquirer.prompt([
91
92
  { type: "password", name: "password", mask: "*", message: "Enter key pair password" }
92
93
  ]);
93
- let ftpClient = new Client();
94
- const port = sshConfig["Port"];
94
+ const ftpClient = new Client();
95
+ const port = sshConfig.Port;
95
96
  const key = fs3.readFileSync(path.resolve(os.homedir(), ".ssh/id_rsa"));
96
97
  const spinner = ora("Connecting");
97
98
  try {
98
99
  spinner.start();
99
100
  await ftpClient.connect({
100
- host: sshConfig["HostName"],
101
- port: port ? parseInt(port) : 22,
102
- username: sshConfig["User"],
101
+ host: sshConfig.HostName,
102
+ port: port ? Number.parseInt(port) : 22,
103
+ username: sshConfig.User,
103
104
  passphrase: answer.password,
104
105
  privateKey: key
105
106
  });
106
107
  releaseConfig.fileMap.sort((it1, it2) => (it1.order ?? 0) - (it2.order ?? 0));
107
- for (let item of releaseConfig.fileMap) {
108
+ for (const item of releaseConfig.fileMap) {
108
109
  if (typeof item.src == "string") {
109
110
  if (item.remoteCopy) {
110
111
  await checkParentDir(ftpClient, item.dest, (dir) => {
111
112
  spinner.warn(`Create Dir: ${dir}`);
112
113
  });
113
- let destExists = await ftpClient.exists(item.dest);
114
+ const destExists = await ftpClient.exists(item.dest);
114
115
  if (destExists) {
115
116
  spinner.warn(`Delete exists file:${item.dest}`);
116
117
  await ftpClient.delete(item.dest);
@@ -128,7 +129,7 @@ async function runSSH(sshConfig, releaseConfig) {
128
129
  await ftpClient.uploadDir(localFile, item.dest, {
129
130
  filter: (filePath, isDirectory) => {
130
131
  if (item.ignorePattern && !isDirectory) {
131
- let fileName = path.basename(filePath);
132
+ const fileName = path.basename(filePath);
132
133
  if (minimatch(fileName, item.ignorePattern)) {
133
134
  spinner.warn(`Skip file:${filePath}`);
134
135
  return false;
@@ -159,16 +160,16 @@ async function runSSH(sshConfig, releaseConfig) {
159
160
  async function ftpUpload(releaseFile = "release.json") {
160
161
  const releaseJsonFilePath = path.join(process.cwd(), releaseFile);
161
162
  const packageVersion = Utils.getPackageVersion();
162
- consola.info("Package Version:", packageVersion);
163
- let releaseJson = fs3.readFileSync(releaseJsonFilePath).toString().replaceAll("${version}", packageVersion);
163
+ consola2.info("Package Version:", packageVersion);
164
+ const releaseJson = fs3.readFileSync(releaseJsonFilePath).toString().replaceAll("${version}", packageVersion);
164
165
  const releaseConfig = JSON.parse(releaseJson);
165
166
  const sshConfigFile = path.resolve(os.homedir(), ".ssh/config");
166
- consola.info("SSH Config File Path:", sshConfigFile);
167
+ consola2.info("SSH Config File Path:", sshConfigFile);
167
168
  const sshConfigs = SSHConfig.parse(fs3.readFileSync(sshConfigFile).toString());
168
- for (let host of releaseConfig.ftpConfig.host) {
169
- let sshConfig = sshConfigs.compute(host);
169
+ for (const host of releaseConfig.ftpConfig.host) {
170
+ const sshConfig = sshConfigs.compute(host);
170
171
  if (!sshConfig) {
171
- consola.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
172
+ consola2.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
172
173
  return;
173
174
  }
174
175
  await runSSH(sshConfig, releaseConfig);
@@ -176,16 +177,16 @@ async function ftpUpload(releaseFile = "release.json") {
176
177
  }
177
178
 
178
179
  // src/release/release.ts
179
- var release = async (options) => {
180
+ async function release(options) {
180
181
  if (options.type == "ftp") {
181
182
  await ftpUpload(options.file);
182
183
  return;
183
184
  }
184
185
  const packageJSON = JSON.parse(fs4.readFileSync("package.json", "utf-8"));
185
186
  const changelogJSON = JSON.parse(fs4.readFileSync("changelog.json", "utf-8"));
186
- const version = packageJSON["version"];
187
+ const version = packageJSON.version;
187
188
  const changelog = changelogJSON[version];
188
- let needUpdateElectron = await promptChecker_default({
189
+ const needUpdateElectron = await promptChecker_default({
189
190
  type: "confirm",
190
191
  name: "electron",
191
192
  message: chalk2.blue("\u7528\u6237\u662F\u5426\u9700\u8981\u66F4\u65B0Electron?")
@@ -206,20 +207,19 @@ var release = async (options) => {
206
207
  installerPath = path2.join(`./dist/app-${version}-setup-win-x64.exe`);
207
208
  }
208
209
  const updateZipPath = path2.join(`./dist/update.zip`);
209
- console.log(chalk2.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
210
+ consola3.log(chalk2.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
210
211
  await update_zip_default("./release", updateZipPath);
211
- console.log(chalk2.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
212
+ consola3.log(chalk2.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
212
213
  await put("version/installer.exe", installerPath);
213
- console.log(chalk2.blue("\u4E0A\u4F20update.zip\u5230OSS"));
214
+ consola3.log(chalk2.blue("\u4E0A\u4F20update.zip\u5230OSS"));
214
215
  await put("version/update.zip", updateZipPath);
215
- console.log(chalk2.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
216
+ consola3.log(chalk2.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
216
217
  versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
217
218
  const versionJSON = JSON.stringify(versionInfo, null, 2);
218
- await put("version/version.json", Buffer.from(versionJSON));
219
- copy(`version/history/${version}.exe`, "version/installer.exe");
220
- copy(`version/history/update-${version}.zip`, "version/update.zip");
221
- console.log(chalk2.yellow(versionJSON));
222
- };
219
+ await put("version/version.json", Buffer2.from(versionJSON));
220
+ await Promise.all([copy(`version/history/${version}.exe`, "version/installer.exe"), copy(`version/history/update-${version}.zip`, "version/update.zip")]);
221
+ consola3.log(chalk2.yellow(versionJSON));
222
+ }
223
223
  var release_default = release;
224
224
  export {
225
225
  release_default as default