@widget-js/cli 24.1.1-beta.4 → 24.1.1-beta.42

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 (41) hide show
  1. package/{lib/createWidget-4LQ6PVEM.js → dist/createWidget-EFGZUM5G.js} +3 -4
  2. package/{lib/dependencies-AVNHKRF3.js → dist/dependencies-UPIZWTP2.js} +7 -9
  3. package/{lib → dist}/index.js +14 -5
  4. package/dist/publish-C52GHJWG.js +50 -0
  5. package/{lib/release-PIRAQ7A6.js → dist/release-MBNSS6M2.js} +56 -41
  6. package/package.json +36 -21
  7. package/readme.md +31 -0
  8. package/template/WidgetConfig.ejs +2 -6
  9. package/template/WidgetDefine.ejs +2 -1
  10. package/template/WidgetRoutes.ejs +1 -1
  11. package/template/WidgetView.ejs +8 -4
  12. package/template/widget-router.ts +1 -1
  13. package/.editorconfig +0 -16
  14. package/.prettierrc +0 -21
  15. package/jest.config.js +0 -14
  16. package/release.json +0 -9
  17. package/src/build/build.ts +0 -35
  18. package/src/createWidget.ts +0 -232
  19. package/src/dependencies/index.ts +0 -13
  20. package/src/dependencies/localDependencies.ts +0 -29
  21. package/src/dependencies/remoteDependencies.ts +0 -37
  22. package/src/index.ts +0 -56
  23. package/src/init/init.ts +0 -121
  24. package/src/promts/promptChecker.ts +0 -17
  25. package/src/release/ftp.ts +0 -144
  26. package/src/release/oss.ts +0 -50
  27. package/src/release/release.ts +0 -70
  28. package/src/release/update-zip.ts +0 -19
  29. package/src/utils/EJSUtils.ts +0 -18
  30. package/src/utils/PrettierUtils.ts +0 -12
  31. package/src/utils/WidgetPackageUtils.ts +0 -13
  32. package/src/utils.ts +0 -84
  33. package/test/index.test.ts +0 -9
  34. package/tsconfig.json +0 -78
  35. package/tsup.config.ts +0 -6
  36. package/vite.config.ts +0 -15
  37. package/widget.json +0 -14
  38. /package/{lib → dist}/chunk-I4ZBPB2S.js +0 -0
  39. /package/{lib → dist}/chunk-RDJH7Z4C.js +0 -0
  40. /package/{lib → dist}/chunk-XPJ33Y5L.js +0 -0
  41. /package/{lib → dist}/init-HCEGKTNF.js +0 -0
@@ -157,7 +157,6 @@ async function createWidget() {
157
157
  minWidth
158
158
  };
159
159
  const widgetDefineFile = path.resolve(widgetDir, `${name}.widget.ts`);
160
- const widgetFile = path.resolve(widgetDir, `${name}Widget.vue`);
161
160
  const widgetViewFile = path.resolve(widgetDir, `${name}WidgetView.vue`);
162
161
  const widgetRoutesFile = path.resolve(widgetDir, `${name}WidgetRoutes.ts`);
163
162
  await EJSUtils.renderToFile("WidgetDefine.ejs", widgetDefineFile, "typescript", renderOptions);
@@ -178,14 +177,14 @@ async function createWidget() {
178
177
  const routeStr = `...${name}WidgetRoutes,`;
179
178
  if (!routeContent.includes(importRouteStr)) {
180
179
  routeContent = routeContent.replaceAll(
181
- "//FBI WANING! IMPORT PLACE",
180
+ "// FBI WANING! IMPORT PLACE",
182
181
  `${importRouteStr}
183
182
  //FBI WANING! IMPORT PLACE`
184
183
  );
185
184
  }
186
185
  if (!routeContent.includes(routeStr)) {
187
- routeContent = routeContent.replaceAll("//FBI WANING! ROUTE PLACE", `${routeStr}
188
- //FBI WANING! ROUTE PLACE`);
186
+ routeContent = routeContent.replaceAll("// FBI WANING! ROUTE PLACE", `${routeStr}
187
+ // FBI WANING! ROUTE PLACE`);
189
188
  }
190
189
  fs.writeFileSync(routeFile, routeContent);
191
190
  const gitAdd = `git add ${widgetDir}`;
@@ -8,27 +8,25 @@ import {
8
8
  import fs from "node:fs";
9
9
  import ora from "ora";
10
10
  var spinner = ora("Connecting");
11
- var RemoteDependencies;
12
- ((RemoteDependencies2) => {
13
- async function start() {
11
+ var RemoteDependencies = class {
12
+ static async start() {
14
13
  spinner.start();
15
14
  const json = Utils.getPackageJson();
16
15
  const packageNames = Object.keys(widgetPackages);
17
16
  const dependencies = json.dependencies;
18
17
  const devDependencies = json.devDependencies;
19
- await upgradePackage(dependencies, packageNames);
20
- await upgradePackage(devDependencies, packageNames);
18
+ await this.upgradePackage(dependencies, packageNames);
19
+ await this.upgradePackage(devDependencies, packageNames);
21
20
  fs.writeFileSync(getPackagePath(), JSON.stringify(json, null, 2));
22
21
  spinner.succeed("Using remote versions!");
23
22
  }
24
- RemoteDependencies2.start = start;
25
- async function upgradePackage(dependencies, packageNames) {
23
+ static async upgradePackage(dependencies, packageNames) {
26
24
  const localPackages = Object.keys(dependencies);
27
25
  for (const localPackage of localPackages) {
28
26
  if (packageNames.includes(localPackage)) {
29
27
  let packageVersion = widgetPackages[localPackage];
30
28
  if (!packageVersion) {
31
- spinner.info(`Fetching package version:${localPackage}`);
29
+ spinner.start(`Fetching package version:${localPackage}`);
32
30
  packageVersion = await Utils.getRemoteVersion(localPackage);
33
31
  widgetPackages[localPackage] = packageVersion;
34
32
  spinner.info(`version:${packageVersion}`);
@@ -37,7 +35,7 @@ var RemoteDependencies;
37
35
  }
38
36
  }
39
37
  }
40
- })(RemoteDependencies || (RemoteDependencies = {}));
38
+ };
41
39
 
42
40
  // src/dependencies/localDependencies.ts
43
41
  import fs2 from "node:fs";
@@ -11,22 +11,31 @@ 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-4LQ6PVEM.js");
14
+ const createWidget = await import("./createWidget-EFGZUM5G.js");
15
15
  await createWidget.default();
16
16
  });
17
17
  var dependenciesOption = new Option("-t, --type <type>").choices(["remote", "local"]);
18
- program.command("dependencies").description("Set @widget-js dependencies to local(workspace:*) or remote(^1.0.0 etc)").addOption(dependenciesOption).action(async (options) => {
19
- const dependencies = await import("./dependencies-AVNHKRF3.js");
18
+ program.command("dependencies").description("Deprecated!. Set @widget-js dependencies to local(workspace:*) or remote(^1.0.0 etc)").addOption(dependenciesOption).action(async (options) => {
19
+ const dependencies = await import("./dependencies-UPIZWTP2.js");
20
+ await dependencies.default(options);
21
+ });
22
+ program.command("deps").description("Set @widget-js dependencies to local(workspace:*) or remote(^1.0.0 etc)").addOption(dependenciesOption).action(async (options) => {
23
+ const dependencies = await import("./dependencies-UPIZWTP2.js");
20
24
  await dependencies.default(options);
21
25
  });
22
26
  program.command("init").description("Initialize widget-js project").action(async () => {
23
27
  const init = await import("./init-HCEGKTNF.js");
24
28
  await init.init();
25
29
  });
30
+ var keyOption = new Option("-k, --key <key>");
31
+ program.command("publish").description("Publish widget package with developer key").addOption(keyOption).action(async (options) => {
32
+ const publishImport = await import("./publish-C52GHJWG.js");
33
+ await publishImport.publish(options);
34
+ });
26
35
  var typeOption = new Option("-t, --type <type>").choices(["ftp", "oss"]);
27
36
  var fileOption = new Option("-f, --file <file>");
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
- const release = await import("./release-PIRAQ7A6.js");
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-MBNSS6M2.js");
30
39
  await release.default(options);
31
40
  });
32
41
  program.parse(process.argv);
@@ -0,0 +1,50 @@
1
+ // src/publish/index.ts
2
+ import fs from "node:fs";
3
+ import fastGlob from "fast-glob";
4
+ import axios from "axios";
5
+ import consola from "consola";
6
+ import ora from "ora";
7
+ async function publish(options) {
8
+ if (!options.key) {
9
+ consola.error("Please provide a developer key with -k or --key option.");
10
+ return;
11
+ }
12
+ const spinner = ora("Search widget.json").start();
13
+ try {
14
+ const files = await fastGlob("**/widget.json", { onlyFiles: true, ignore: ["node_modules/**"], absolute: true });
15
+ if (files.length === 0) {
16
+ spinner.fail("No widget.json file found.");
17
+ return;
18
+ }
19
+ spinner.succeed(`Widget.json found: ${files[0]}`);
20
+ const widgetPath = files[0];
21
+ const widgetContent = fs.readFileSync(widgetPath, "utf-8");
22
+ const json = JSON.parse(widgetContent);
23
+ consola.info(`Package name:${json.name}`);
24
+ const widgets = json.widgets;
25
+ consola.info(`Widget size:${widgets?.length ?? 0}`);
26
+ spinner.start("Publishing widget package...");
27
+ const response = await axios.post("https://widgetjs.cn/api/v1/widget/package", json, {
28
+ headers: {
29
+ "Content-Type": "application/json",
30
+ "Key": options.key
31
+ }
32
+ });
33
+ if (response.data) {
34
+ if (response.data.code == 200) {
35
+ spinner.succeed("Widget published successfully.");
36
+ } else {
37
+ spinner.fail("Failed to publish widget.");
38
+ consola.error(response.data.msg);
39
+ }
40
+ } else {
41
+ spinner.fail("Empty Response");
42
+ }
43
+ } catch (error) {
44
+ spinner.fail("Failed to publish widget.");
45
+ consola.error(error);
46
+ }
47
+ }
48
+ export {
49
+ publish
50
+ };
@@ -19,7 +19,11 @@ function zipDirectory(sourceDir, outPath, ignoreDir) {
19
19
  const archive = archiver("zip", { zlib: { level: 9 } });
20
20
  const stream = fs.createWriteStream(outPath);
21
21
  return new Promise((resolve, reject) => {
22
- archive.glob("**/*", { cwd: sourceDir, ignore: ["node_modules/**"] }).on("error", (err) => reject(err)).pipe(stream);
22
+ const ignore = ["node_modules/**"];
23
+ if (ignoreDir) {
24
+ ignore.push(...ignoreDir);
25
+ }
26
+ archive.glob("**/*", { cwd: sourceDir, ignore }).on("error", (err) => reject(err)).pipe(stream);
23
27
  stream.on("close", () => resolve());
24
28
  archive.finalize();
25
29
  });
@@ -31,46 +35,52 @@ import fs2 from "node:fs";
31
35
  import OSS from "ali-oss";
32
36
  import chalk from "chalk";
33
37
  import consola from "consola";
34
- var packageData = JSON.parse(fs2.readFileSync("./package.json").toString());
35
- var AccessKeyID = packageData.oss?.id ?? "default";
36
- var AccessKeySecret = packageData.oss?.secret ?? "default";
37
- var headers = {
38
- // 指定Object的存储类型。
39
- "x-oss-storage-class": "Standard",
40
- // 指定Object的访问权限。
41
- "x-oss-object-acl": "public-read",
42
- "x-oss-forbid-overwrite": "false",
43
- "Cache-Control": "no-cache"
44
- };
45
- var clinet = new OSS({
46
- // yourRegion填写Bucket所在地域。以华东1(杭州)为例,Region填写为oss-cn-hangzhou。
47
- region: "oss-cn-hangzhou",
48
- // 阿里云账号AccessKey拥有所有API的访问权限,风险很高。强烈建议您创建并使用RAM用户进行API访问或日常运维,请登录RAM控制台创建RAM用户。
49
- accessKeyId: AccessKeyID,
50
- accessKeySecret: AccessKeySecret,
51
- bucket: "widget-fun"
52
- });
53
- async function put(ossPath, file) {
54
- try {
55
- await clinet.put(ossPath, file, { headers });
56
- consola.log(chalk.green(`\u4E0A\u4F20\u6210\u529F\uFF1A${file}->${ossPath}`));
57
- } catch (e) {
58
- 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
+ });
59
60
  }
60
- }
61
- async function copy(dist, src) {
62
- try {
63
- await clinet.copy(dist, src, { headers });
64
- consola.log(chalk.green(`\u590D\u5236\u6210\u529F\uFF1A${src}->${dist}`));
65
- } catch (e) {
66
- 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
+ }
67
68
  }
68
- }
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
+ };
69
78
 
70
79
  // src/release/ftp.ts
71
80
  import path from "node:path";
72
81
  import fs3 from "node:fs";
73
82
  import os from "node:os";
83
+ import Buffer from "node:buffer";
74
84
  import * as process from "node:process";
75
85
  import SSHConfig from "@widget-js/ssh-config";
76
86
  import Client from "ssh2-sftp-client";
@@ -159,9 +169,13 @@ async function runSSH(sshConfig, releaseConfig) {
159
169
  }
160
170
  async function ftpUpload(releaseFile = "release.json") {
161
171
  const releaseJsonFilePath = path.join(process.cwd(), releaseFile);
162
- const packageVersion = Utils.getPackageVersion();
163
- consola2.info("Package Version:", packageVersion);
164
- 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
+ }
165
179
  const releaseConfig = JSON.parse(releaseJson);
166
180
  const sshConfigFile = path.resolve(os.homedir(), ".ssh/config");
167
181
  consola2.info("SSH Config File Path:", sshConfigFile);
@@ -208,16 +222,17 @@ async function release(options) {
208
222
  }
209
223
  const updateZipPath = path2.join(`./dist/update.zip`);
210
224
  consola3.log(chalk2.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
225
+ const ossClient = new OssClient();
211
226
  await update_zip_default("./release", updateZipPath);
212
227
  consola3.log(chalk2.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
213
- await put("version/installer.exe", installerPath);
228
+ await ossClient.put("version/installer.exe", installerPath);
214
229
  consola3.log(chalk2.blue("\u4E0A\u4F20update.zip\u5230OSS"));
215
- await put("version/update.zip", updateZipPath);
230
+ await ossClient.put("version/update.zip", updateZipPath);
216
231
  consola3.log(chalk2.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
217
232
  versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
218
233
  const versionJSON = JSON.stringify(versionInfo, null, 2);
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")]);
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")]);
221
236
  consola3.log(chalk2.yellow(versionJSON));
222
237
  }
223
238
  var release_default = release;
package/package.json CHANGED
@@ -1,51 +1,59 @@
1
1
  {
2
2
  "name": "@widget-js/cli",
3
3
  "type": "module",
4
- "version": "24.1.1-beta.4",
4
+ "version": "24.1.1-beta.42",
5
5
  "private": false,
6
6
  "author": "Neo Fu",
7
7
  "license": "MIT",
8
- "main": "lib/index.js",
8
+ "main": "dist/index.js",
9
9
  "bin": {
10
- "widget": "lib/index.js"
10
+ "widget": "dist/index.js"
11
11
  },
12
12
  "engines": {
13
13
  "node": "^12.0.0 || >= 14.0.0"
14
14
  },
15
+ "files": [
16
+ "dist",
17
+ "template"
18
+ ],
15
19
  "publishConfig": {
16
20
  "access": "public"
17
21
  },
18
22
  "dependencies": {
19
23
  "@types/archiver": "^5.3.1",
20
- "@types/gradient-string": "^1.1.2",
21
24
  "@vue/cli-shared-utils": "^5.0.8",
22
25
  "@widget-js/ssh-config": "^4.2.1",
23
- "@widget-js/vue3": "^0.11.20",
24
26
  "ali-oss": "^6.17.1",
25
27
  "archiver": "^5.3.1",
28
+ "axios": "^1.7.2",
26
29
  "chalk": "^4.1.2",
27
30
  "change-case": "^4.1.2",
28
31
  "commander": "^9.4.1",
29
32
  "consola": "^2.15.3",
30
33
  "dirname-filename-esm": "^1.1.1",
31
34
  "ejs": "^3.1.8",
35
+ "fast-glob": "^3.3.2",
32
36
  "figlet": "^1.5.2",
33
- "inquirer": "^8.0.0",
37
+ "gradient-string": "^2.0.2",
38
+ "inquirer": "^8.2.6",
34
39
  "minimatch": "^9.0.3",
35
40
  "ora": "^6.2.0",
36
- "package-json": "^8.1.0",
41
+ "package-json": "^10.0.1",
37
42
  "prettier": "^3.1.1",
38
43
  "semver": "^7.5.2",
39
44
  "shelljs": "^0.8.5",
40
45
  "ssh2-sftp-client": "^9.1.0",
41
46
  "ws": "^8.11.0",
42
- "@widget-js/core": "24.1.1-beta.4",
43
- "@widget-js/utils": "24.1.1-beta.4"
47
+ "@widget-js/core": "24.1.1-beta.47",
48
+ "@widget-js/vue3": "24.1.1-beta.48",
49
+ "@widget-js/utils": "24.1.1-beta.40"
44
50
  },
45
51
  "devDependencies": {
52
+ "@antfu/eslint-config": "^2.21.1",
46
53
  "@types/ali-oss": "^6.16.7",
47
54
  "@types/ejs": "latest",
48
55
  "@types/figlet": "^1.5.5",
56
+ "@types/gradient-string": "^1.1.2",
49
57
  "@types/inquirer": "latest",
50
58
  "@types/jest": "^29.2.3",
51
59
  "@types/minimist": "^1.2.5",
@@ -53,8 +61,7 @@
53
61
  "@types/semver": "^7.5.0",
54
62
  "@types/shelljs": "latest",
55
63
  "@types/ssh2-sftp-client": "^9.0.1",
56
- "@widget-js/vite-plugin-widget": "^1.2.8",
57
- "gradient-string": "^2.0.2",
64
+ "eslint": "8.48.0",
58
65
  "jest": "^29.5.0",
59
66
  "pinst": "^3.0.0",
60
67
  "rimraf": "^4.4.1",
@@ -67,19 +74,27 @@
67
74
  "vue-router": "^4.2.5",
68
75
  "webpack": "^5.75.0",
69
76
  "webpack-cli": "^5.0.0",
70
- "@widget-js/core": "24.1.1-beta.4",
71
- "@widget-js/vue3": "^0.11.20"
77
+ "@widget-js/vue3": "24.1.1-beta.48",
78
+ "@widget-js/core": "24.1.1-beta.47",
79
+ "@widget-js/vite-plugin-widget": "24.1.1-beta.41"
72
80
  },
73
81
  "scripts": {
74
- "build": "rimraf ./lib/ && tsup-node src/index.ts --format esm",
75
- "watch": "tsup src/index.ts --format esm --watch",
82
+ "build": "tsup-node src/index.ts",
83
+ "watch": "tsup-node src/index.ts --watch",
76
84
  "build:run": "npm run build && npm run widget",
77
- "widget": "node ./lib/index.js",
78
- "widget:ftp": "node ./lib/index.js release -t ftp",
79
- "widget:init": "node ./lib/index.js init",
80
- "widget:create": "npm run build && node ./lib/index.js create",
81
- "widget:local": "npm run build && node ./lib/index.js dependencies -t local",
85
+ "widget": "node ./dist/index.js",
86
+ "widget:ftp": "node ./dist/index.js release -t ftp",
87
+ "widget:init": "node ./dist/index.js init",
88
+ "widget:publish": "node ./dist/index.js publish -key 123",
89
+ "widget:create": "npm run build && node ./dist/index.js create",
90
+ "widget:local": "npm run build && node ./dist/index.js dependencies -t local",
91
+ "widget:remote": "npm run build && node ./dist/index.js dependencies -t remote",
82
92
  "build:publish": "npm run build && npm run pnpm:publish",
83
- "pnpm:publish": "pnpm publish --no-git-checks"
93
+ "pnpm:publish": "pnpm publish --no-git-checks",
94
+ "remote": "widget dependencies -t remote && pnpm install",
95
+ "local": "widget dependencies -t local && pnpm install",
96
+ "link": "pnpm link --global",
97
+ "lint": "eslint .",
98
+ "lint:fix": "eslint . --fix"
84
99
  }
85
100
  }
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
@@ -1,16 +1,12 @@
1
1
  <template>
2
- <widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption"
3
- v-model="widgetData"
4
- @apply="save()"
5
- @confirm="save({ closeWindow: true })">
2
+ <widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption">
6
3
  </widget-edit-dialog>
7
4
  </template>
8
5
 
9
6
  <script lang="ts" setup>
10
7
  import {useWidget, WidgetConfigOption} from "@widget-js/vue3";
11
- import {WidgetData} from "@widget-js/core";
12
8
 
13
- const {widgetData, widgetParams, save} = useWidget(WidgetData)
9
+ const {widgetParams } = useWidget()
14
10
 
15
11
  //修改成需要设置组件参数配置
16
12
  const widgetConfigOption = new WidgetConfigOption({
@@ -5,6 +5,7 @@ name: "<%= widgetName %>",
5
5
  title: {"zh-CN": "<%= title %>"},
6
6
  description: {"zh-CN": ""},
7
7
  keywords: [WidgetKeyword.RECOMMEND],
8
+ categories: [],
8
9
  lang: "zh-CN",
9
10
  width: <%= width %>,
10
11
  height: <%= height %>,
@@ -14,7 +15,7 @@ minHeight: <%= minHeight %>,
14
15
  maxHeight: <%= maxHeight %>,
15
16
  previewImage: "修改为组件预览图地址",
16
17
  path: "/widget/<%= snakeCaseName %>",
17
- configPagePath: <% if (configurable) { %>"/widget/config/<%= snakeCaseName %>"<% } else { %>undefined<% } %>
18
+ configPagePath: <% if (configurable) { %>"/widget/config/<%= snakeCaseName %>?width=600&height=500&frame=true&transparent=false"<% } else { %>undefined<% } %>
18
19
  })
19
20
 
20
21
  export default <%= name %>Widget;
@@ -4,7 +4,7 @@ import <%= name %>Widget from "./<%= name %>.widget";
4
4
  const path = <%= name %>Widget.path;
5
5
  const name = <%= name %>Widget.name;
6
6
  <% if (configurable) { %>
7
- const configPagePath = <%= name %>Widget.configPagePath!;
7
+ const configPagePath = <%= name %>Widget.configPagePath!.split('?')[0];
8
8
 
9
9
  const <%= name %>WidgetRoutes: RouteRecordRaw[] = [
10
10
  {
@@ -1,16 +1,20 @@
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
 
7
9
  <script lang="ts" setup>
8
- import {WidgetData} from "@widget-js/core";
9
10
  import {useWidget} from "@widget-js/vue3";
10
11
 
11
- const {widgetData, widgetParams} = useWidget(WidgetData);
12
+ const {widgetParams} = useWidget();
12
13
  </script>
13
14
 
14
15
  <style scoped>
15
-
16
+ .content{
17
+ padding: 1rem;
18
+ color: var(--widget-color)
19
+ }
16
20
  </style>
@@ -1,4 +1,4 @@
1
- import type { RouteRecordRaw } from 'vue-router'
1
+ import type { RouteRecordRaw } from 'vue-router'
2
2
 
3
3
  // FBI WANING! IMPORT PLACE, DONT DELETE THIS LINE
4
4
  const WidgetRouter: RouteRecordRaw[] = [
package/.editorconfig DELETED
@@ -1,16 +0,0 @@
1
- [*]
2
- charset = utf-8
3
- end_of_line = crlf
4
- indent_size = 2
5
- indent_style = space
6
- insert_final_newline = true
7
- max_line_length = 120
8
- tab_width = 2
9
- trim_trailing_whitespace = true
10
- ij_continuation_indent_size = 2
11
- ij_formatter_off_tag = @formatter:off
12
- ij_formatter_on_tag = @formatter:on
13
- ij_formatter_tags_enabled = false
14
- ij_smart_tabs = false
15
- ij_visual_guides = none
16
- ij_wrap_on_typing = false
package/.prettierrc DELETED
@@ -1,21 +0,0 @@
1
- {
2
- "printWidth": 120,
3
- "semi": false,
4
- "singleQuote": true,
5
- "overrides": [
6
- {
7
- "files": ["**/*.css", "**/*.scss", "**/*.html"],
8
- "options": {
9
- "singleQuote": false
10
- }
11
- }
12
- ],
13
- "trailingComma": "all",
14
- "bracketSpacing": false,
15
- "arrowParens": "avoid",
16
- "proseWrap": "never",
17
- "htmlWhitespaceSensitivity": "strict",
18
- "vueIndentScriptAndStyle": false,
19
- "endOfLine": "lf",
20
- "singleAttributePerLine": true
21
- }
package/jest.config.js DELETED
@@ -1,14 +0,0 @@
1
- module.exports = {
2
- roots: ['<rootDir>/test'],
3
- testMatch: [
4
- '**/__tests__/**/*.+(ts|tsx|js)',
5
- '**/?(*.)+(spec|test).+(ts|tsx|js)',
6
- ],
7
- transform: {
8
- '^.+\\.(ts|tsx)$': ['ts-jest', {
9
- tsconfig: 'tsconfig.json',
10
- }],
11
- '\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$':
12
- './config/fileTransformer.js',
13
- },
14
- }
package/release.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "fileMap": [
3
- ],
4
- "ftpConfig": {
5
- "host": [
6
- "itime"
7
- ]
8
- }
9
- }
@@ -1,35 +0,0 @@
1
- import { exec } from 'node:child_process'
2
- import ora from 'ora'
3
- import consola from 'consola'
4
-
5
- export function build() {
6
- const preloadSpinner = ora('Preload').start()
7
- const mainSpinner = ora('Main').start()
8
- // @ts-expect-error
9
- const build = exec('npm run build:preload').on('close', () => {
10
- consola.success('done')
11
- })
12
- // @ts-expect-error
13
- build.stdout.on('data', (data) => {
14
- consola.log('data', data)
15
- })
16
-
17
- // @ts-expect-error
18
- exec('npm run build:main', (error, stdout, stderr) => {
19
- if (error) {
20
- consola.error(`error: ${error}`)
21
- return
22
- }
23
- consola.log(`stdout: ${stdout}`)
24
- consola.log(`stderr: ${typeof stderr}`)
25
- })
26
- .on('message', () => {
27
- consola.log('on-message')
28
- })
29
- .on('data', () => {
30
- consola.log('on-data')
31
- })
32
- .on('close', () => {
33
- consola.log('done')
34
- })
35
- }