@widget-js/cli 24.1.1-beta.40 → 24.1.1-beta.43

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/dist/index.js CHANGED
@@ -35,7 +35,7 @@ program.command("publish").description("Publish widget package with developer ke
35
35
  var typeOption = new Option("-t, --type <type>").choices(["ftp", "oss"]);
36
36
  var fileOption = new Option("-f, --file <file>");
37
37
  program.command("release").description("\u901A\u8FC7FTP/OSS\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").addOption(typeOption).addOption(fileOption).action(async (options) => {
38
- const release = await import("./release-5GS34BAJ.js");
38
+ const release = await import("./release-MBNSS6M2.js");
39
39
  await release.default(options);
40
40
  });
41
41
  program.parse(process.argv);
@@ -35,46 +35,52 @@ import fs2 from "node:fs";
35
35
  import OSS from "ali-oss";
36
36
  import chalk from "chalk";
37
37
  import consola from "consola";
38
- var packageData = JSON.parse(fs2.readFileSync("./package.json").toString());
39
- var AccessKeyID = packageData.oss?.id ?? "default";
40
- var AccessKeySecret = packageData.oss?.secret ?? "default";
41
- var headers = {
42
- // 指定Object的存储类型。
43
- "x-oss-storage-class": "Standard",
44
- // 指定Object的访问权限。
45
- "x-oss-object-acl": "public-read",
46
- "x-oss-forbid-overwrite": "false",
47
- "Cache-Control": "no-cache"
48
- };
49
- var clinet = new OSS({
50
- // yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
51
- region: "oss-cn-hangzhou",
52
- // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
53
- accessKeyId: AccessKeyID,
54
- accessKeySecret: AccessKeySecret,
55
- bucket: "widget-fun"
56
- });
57
- async function put(ossPath, file) {
58
- try {
59
- await clinet.put(ossPath, file, { headers });
60
- consola.log(chalk.green(`\u4E0A\u4F20\u6210\u529F\uFF1A${file}->${ossPath}`));
61
- } catch (e) {
62
- consola.log(e);
38
+ var OssClient = class {
39
+ headers = {
40
+ // 指定Object的存储类型。
41
+ "x-oss-storage-class": "Standard",
42
+ // 指定Object的访问权限。
43
+ "x-oss-object-acl": "public-read",
44
+ "x-oss-forbid-overwrite": "false",
45
+ "Cache-Control": "no-cache"
46
+ };
47
+ client;
48
+ constructor() {
49
+ const packageData = JSON.parse(fs2.readFileSync("./package.json").toString());
50
+ const AccessKeyID = packageData.oss?.id ?? "default";
51
+ const AccessKeySecret = packageData.oss?.secret ?? "default";
52
+ this.client = new OSS({
53
+ // yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
54
+ region: "oss-cn-hangzhou",
55
+ // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
56
+ accessKeyId: AccessKeyID,
57
+ accessKeySecret: AccessKeySecret,
58
+ bucket: "widget-fun"
59
+ });
63
60
  }
64
- }
65
- async function copy(dist, src) {
66
- try {
67
- await clinet.copy(dist, src, { headers });
68
- consola.log(chalk.green(`\u590D\u5236\u6210\u529F\uFF1A${src}->${dist}`));
69
- } catch (e) {
70
- console.error(e);
61
+ async put(ossPath, file) {
62
+ try {
63
+ await this.client.put(ossPath, file, { headers: this.headers });
64
+ consola.log(chalk.green(`\u4E0A\u4F20\u6210\u529F\uFF1A${file}->${ossPath}`));
65
+ } catch (e) {
66
+ consola.log(e);
67
+ }
71
68
  }
72
- }
69
+ async copy(dist, src) {
70
+ try {
71
+ await this.client.copy(dist, src, { headers: this.headers });
72
+ consola.log(chalk.green(`\u590D\u5236\u6210\u529F\uFF1A${src}->${dist}`));
73
+ } catch (e) {
74
+ console.error(e);
75
+ }
76
+ }
77
+ };
73
78
 
74
79
  // src/release/ftp.ts
75
80
  import path from "node:path";
76
81
  import fs3 from "node:fs";
77
82
  import os from "node:os";
83
+ import Buffer from "node:buffer";
78
84
  import * as process from "node:process";
79
85
  import SSHConfig from "@widget-js/ssh-config";
80
86
  import Client from "ssh2-sftp-client";
@@ -163,9 +169,13 @@ async function runSSH(sshConfig, releaseConfig) {
163
169
  }
164
170
  async function ftpUpload(releaseFile = "release.json") {
165
171
  const releaseJsonFilePath = path.join(process.cwd(), releaseFile);
166
- const packageVersion = Utils.getPackageVersion();
167
- consola2.info("Package Version:", packageVersion);
168
- const releaseJson = fs3.readFileSync(releaseJsonFilePath).toString().replaceAll("${version}", packageVersion);
172
+ let releaseJson = fs3.readFileSync(releaseJsonFilePath).toString();
173
+ const hasPackageJson = fs3.existsSync(Utils.getPackagePath());
174
+ if (hasPackageJson) {
175
+ const packageVersion = Utils.getPackageVersion();
176
+ consola2.info("Package Version:", packageVersion);
177
+ releaseJson = releaseJson.replaceAll(`\${version}`, packageVersion);
178
+ }
169
179
  const releaseConfig = JSON.parse(releaseJson);
170
180
  const sshConfigFile = path.resolve(os.homedir(), ".ssh/config");
171
181
  consola2.info("SSH Config File Path:", sshConfigFile);
@@ -212,16 +222,17 @@ async function release(options) {
212
222
  }
213
223
  const updateZipPath = path2.join(`./dist/update.zip`);
214
224
  consola3.log(chalk2.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
225
+ const ossClient = new OssClient();
215
226
  await update_zip_default("./release", updateZipPath);
216
227
  consola3.log(chalk2.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
217
- await put("version/installer.exe", installerPath);
228
+ await ossClient.put("version/installer.exe", installerPath);
218
229
  consola3.log(chalk2.blue("\u4E0A\u4F20update.zip\u5230OSS"));
219
- await put("version/update.zip", updateZipPath);
230
+ await ossClient.put("version/update.zip", updateZipPath);
220
231
  consola3.log(chalk2.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
221
232
  versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
222
233
  const versionJSON = JSON.stringify(versionInfo, null, 2);
223
- await put("version/version.json", Buffer2.from(versionJSON));
224
- await Promise.all([copy(`version/history/${version}.exe`, "version/installer.exe"), copy(`version/history/update-${version}.zip`, "version/update.zip")]);
234
+ await ossClient.put("version/version.json", Buffer2.from(versionJSON));
235
+ await Promise.all([ossClient.copy(`version/history/${version}.exe`, "version/installer.exe"), ossClient.copy(`version/history/update-${version}.zip`, "version/update.zip")]);
225
236
  consola3.log(chalk2.yellow(versionJSON));
226
237
  }
227
238
  var release_default = release;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@widget-js/cli",
3
3
  "type": "module",
4
- "version": "24.1.1-beta.40",
4
+ "version": "24.1.1-beta.43",
5
5
  "private": false,
6
6
  "author": "Neo Fu",
7
7
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "fast-glob": "^3.3.2",
36
36
  "figlet": "^1.5.2",
37
37
  "gradient-string": "^2.0.2",
38
- "inquirer": "^8.0.0",
38
+ "inquirer": "^8.2.6",
39
39
  "minimatch": "^9.0.3",
40
40
  "ora": "^6.2.0",
41
41
  "package-json": "^10.0.1",
@@ -44,8 +44,8 @@
44
44
  "shelljs": "^0.8.5",
45
45
  "ssh2-sftp-client": "^9.1.0",
46
46
  "ws": "^8.11.0",
47
- "@widget-js/core": "24.1.1-beta.40",
48
- "@widget-js/vue3": "24.1.1-beta.40",
47
+ "@widget-js/core": "24.1.1-beta.49",
48
+ "@widget-js/vue3": "24.1.1-beta.48",
49
49
  "@widget-js/utils": "24.1.1-beta.40"
50
50
  },
51
51
  "devDependencies": {
@@ -72,11 +72,9 @@
72
72
  "typescript": "^5.2.2",
73
73
  "vitest": "^0.34.6",
74
74
  "vue-router": "^4.2.5",
75
- "webpack": "^5.75.0",
76
- "webpack-cli": "^5.0.0",
77
- "@widget-js/core": "24.1.1-beta.40",
78
- "@widget-js/vue3": "24.1.1-beta.40",
79
- "@widget-js/vite-plugin-widget": "24.1.1-beta.40"
75
+ "@widget-js/core": "24.1.1-beta.49",
76
+ "@widget-js/vite-plugin-widget": "24.1.1-beta.41",
77
+ "@widget-js/vue3": "24.1.1-beta.48"
80
78
  },
81
79
  "scripts": {
82
80
  "build": "tsup-node src/index.ts",
package/readme.md CHANGED
@@ -10,3 +10,34 @@ pnpm add -D @widget-js/cli
10
10
  ```shell
11
11
  npx widget
12
12
  ```
13
+
14
+ ### Release
15
+
16
+ ```shell
17
+ # 通过ftp发布
18
+ widget release -t ftp
19
+ # 通过oss发布
20
+ widget release -t oss
21
+ ```
22
+ #### example
23
+ create `release.json` at project root dir
24
+ ```json
25
+ {
26
+ "fileMap": [
27
+ {
28
+ "src": "./dist/",
29
+ "dest": "/www/wwwroot/test/root/"
30
+ },
31
+ {
32
+ "src": "package.json",
33
+ "dest": "/www/wwwroot/test/package.json"
34
+ }
35
+ ],
36
+ "ftpConfig": {
37
+ "host": [
38
+ "itime" 👈~/.ssh/config 里的host名
39
+ ]
40
+ }
41
+ }
42
+ ```
43
+ this will upload `dist` and `package.json` to ftp server
@@ -10,12 +10,12 @@ const <%= name %>WidgetRoutes: RouteRecordRaw[] = [
10
10
  {
11
11
  path: path,
12
12
  name: `${name}`,
13
- component: () => import(/* webpackChunkName: "<%= widgetName %>" */ './<%= name %>WidgetView.vue')
13
+ component: () => import('./<%= name %>WidgetView.vue')
14
14
  },
15
15
  {
16
16
  path: configPagePath,
17
17
  name: `${name}.config`,
18
- component: () => import(/* webpackChunkName: "<%= widgetName %>.config" */ './<%= name %>ConfigView.vue')
18
+ component: () => import('./<%= name %>ConfigView.vue')
19
19
  }
20
20
  ]
21
21
  <% } else { %>
@@ -23,7 +23,7 @@ const <%= name %>WidgetRoutes: RouteRecordRaw[] = [
23
23
  {
24
24
  path: path,
25
25
  name: `${name}`,
26
- component: () => import(/* webpackChunkName: "<%= widgetName %>" */ './<%= name %>WidgetView.vue')
26
+ component: () => import('./<%= name %>WidgetView.vue')
27
27
  }
28
28
  ]
29
29
  <% } %>
@@ -1,6 +1,8 @@
1
1
  <template>
2
2
  <widget-wrapper>
3
- <span>Hello World!</span>
3
+ <div class="content">
4
+ Hello World!
5
+ </div>
4
6
  </widget-wrapper>
5
7
  </template>
6
8
 
@@ -11,5 +13,8 @@ const {widgetParams} = useWidget();
11
13
  </script>
12
14
 
13
15
  <style scoped>
14
-
16
+ .content{
17
+ padding: 1rem;
18
+ color: var(--widget-color)
19
+ }
15
20
  </style>