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

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 (40) 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-5GS34BAJ.js} +5 -1
  6. package/package.json +35 -20
  7. package/template/WidgetConfig.ejs +2 -6
  8. package/template/WidgetDefine.ejs +2 -1
  9. package/template/WidgetRoutes.ejs +1 -1
  10. package/template/WidgetView.ejs +1 -2
  11. package/template/widget-router.ts +1 -1
  12. package/.editorconfig +0 -16
  13. package/.prettierrc +0 -21
  14. package/jest.config.js +0 -14
  15. package/release.json +0 -9
  16. package/src/build/build.ts +0 -35
  17. package/src/createWidget.ts +0 -232
  18. package/src/dependencies/index.ts +0 -13
  19. package/src/dependencies/localDependencies.ts +0 -29
  20. package/src/dependencies/remoteDependencies.ts +0 -37
  21. package/src/index.ts +0 -56
  22. package/src/init/init.ts +0 -121
  23. package/src/promts/promptChecker.ts +0 -17
  24. package/src/release/ftp.ts +0 -144
  25. package/src/release/oss.ts +0 -50
  26. package/src/release/release.ts +0 -70
  27. package/src/release/update-zip.ts +0 -19
  28. package/src/utils/EJSUtils.ts +0 -18
  29. package/src/utils/PrettierUtils.ts +0 -12
  30. package/src/utils/WidgetPackageUtils.ts +0 -13
  31. package/src/utils.ts +0 -84
  32. package/test/index.test.ts +0 -9
  33. package/tsconfig.json +0 -78
  34. package/tsup.config.ts +0 -6
  35. package/vite.config.ts +0 -15
  36. package/widget.json +0 -14
  37. /package/{lib → dist}/chunk-I4ZBPB2S.js +0 -0
  38. /package/{lib → dist}/chunk-RDJH7Z4C.js +0 -0
  39. /package/{lib → dist}/chunk-XPJ33Y5L.js +0 -0
  40. /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-5GS34BAJ.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
  });
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.40",
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",
37
+ "gradient-string": "^2.0.2",
33
38
  "inquirer": "^8.0.0",
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.40",
48
+ "@widget-js/vue3": "24.1.1-beta.40",
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/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"
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
  }
@@ -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
  {
@@ -5,10 +5,9 @@
5
5
  </template>
6
6
 
7
7
  <script lang="ts" setup>
8
- import {WidgetData} from "@widget-js/core";
9
8
  import {useWidget} from "@widget-js/vue3";
10
9
 
11
- const {widgetData, widgetParams} = useWidget(WidgetData);
10
+ const {widgetParams} = useWidget();
12
11
  </script>
13
12
 
14
13
  <style scoped>
@@ -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
- }