@widget-js/cli 24.1.1-beta.6 → 24.1.1-beta.63
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/{lib/createWidget-4LQ6PVEM.js → dist/createWidget-EFGZUM5G.js} +3 -4
- package/{lib/dependencies-AVNHKRF3.js → dist/dependencies-UPIZWTP2.js} +7 -9
- package/{lib → dist}/index.js +14 -5
- package/dist/publish-C52GHJWG.js +50 -0
- package/{lib/release-PIRAQ7A6.js → dist/release-3DQATEM5.js} +111 -79
- package/package.json +38 -28
- package/readme.md +31 -0
- package/template/WidgetConfig.ejs +2 -6
- package/template/WidgetDefine.ejs +2 -1
- package/template/WidgetRoutes.ejs +4 -4
- package/template/WidgetView.ejs +8 -4
- package/template/widget-router.ts +1 -1
- package/.editorconfig +0 -16
- package/.idea/cli.iml +0 -9
- package/.idea/codeStyles/Project.xml +0 -60
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/vcs.xml +0 -6
- package/.prettierrc +0 -21
- package/jest.config.js +0 -14
- package/release.json +0 -9
- package/src/build/build.ts +0 -35
- package/src/createWidget.ts +0 -232
- package/src/dependencies/index.ts +0 -13
- package/src/dependencies/localDependencies.ts +0 -29
- package/src/dependencies/remoteDependencies.ts +0 -37
- package/src/index.ts +0 -56
- package/src/init/init.ts +0 -121
- package/src/promts/promptChecker.ts +0 -17
- package/src/release/ftp.ts +0 -144
- package/src/release/oss.ts +0 -50
- package/src/release/release.ts +0 -70
- package/src/release/update-zip.ts +0 -19
- package/src/utils/EJSUtils.ts +0 -18
- package/src/utils/PrettierUtils.ts +0 -12
- package/src/utils/WidgetPackageUtils.ts +0 -13
- package/src/utils.ts +0 -84
- package/test/index.test.ts +0 -9
- package/tsconfig.json +0 -78
- package/tsup.config.ts +0 -6
- package/vite.config.ts +0 -15
- package/widget.json +0 -14
- /package/{lib → dist}/chunk-I4ZBPB2S.js +0 -0
- /package/{lib → dist}/chunk-RDJH7Z4C.js +0 -0
- /package/{lib → dist}/chunk-XPJ33Y5L.js +0 -0
- /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
|
-
(
|
|
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
|
-
|
|
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.
|
|
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
|
-
}
|
|
38
|
+
};
|
|
41
39
|
|
|
42
40
|
// src/dependencies/localDependencies.ts
|
|
43
41
|
import fs2 from "node:fs";
|
package/{lib → dist}/index.js
RENAMED
|
@@ -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-
|
|
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-
|
|
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
|
|
29
|
-
const release = await import("./release-
|
|
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-3DQATEM5.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
|
-
|
|
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
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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";
|
|
@@ -78,6 +88,8 @@ import consola2 from "consola";
|
|
|
78
88
|
import inquirer from "inquirer";
|
|
79
89
|
import ora from "ora";
|
|
80
90
|
import { minimatch } from "minimatch";
|
|
91
|
+
import fg from "fast-glob";
|
|
92
|
+
var { globSync } = fg;
|
|
81
93
|
async function checkParentDir(ftpClient, file, onMkdir) {
|
|
82
94
|
const dir = path.dirname(file);
|
|
83
95
|
const dirExists = await ftpClient.exists(dir);
|
|
@@ -106,49 +118,64 @@ async function runSSH(sshConfig, releaseConfig) {
|
|
|
106
118
|
});
|
|
107
119
|
releaseConfig.fileMap.sort((it1, it2) => (it1.order ?? 0) - (it2.order ?? 0));
|
|
108
120
|
for (const item of releaseConfig.fileMap) {
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
if (!item.remoteCopy && !fs3.existsSync(localFile)) {
|
|
124
|
-
spinner.warn(`Skip not exists file:${localFile}`);
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
if (fs3.lstatSync(localFile).isDirectory()) {
|
|
128
|
-
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
129
|
-
await ftpClient.uploadDir(localFile, item.dest, {
|
|
130
|
-
filter: (filePath, isDirectory) => {
|
|
131
|
-
if (item.ignorePattern && !isDirectory) {
|
|
132
|
-
const fileName = path.basename(filePath);
|
|
133
|
-
if (minimatch(fileName, item.ignorePattern)) {
|
|
134
|
-
spinner.warn(`Skip file:${filePath}`);
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return true;
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
} else {
|
|
121
|
+
if (item.pattern) {
|
|
122
|
+
await checkParentDir(ftpClient, item.dest, (dir) => {
|
|
123
|
+
spinner.succeed(`Create Dir: ${dir}`);
|
|
124
|
+
});
|
|
125
|
+
const files = globSync(item.pattern, { absolute: true, ignore: item.ignore, cwd: process.cwd() });
|
|
126
|
+
for (const file of files) {
|
|
127
|
+
spinner.info(`Uploading File: ${file} -> ${item.dest}`);
|
|
128
|
+
await ftpClient.put(file, item.dest);
|
|
129
|
+
}
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (item.src) {
|
|
133
|
+
if (typeof item.src == "string") {
|
|
134
|
+
if (item.remoteCopy) {
|
|
142
135
|
await checkParentDir(ftpClient, item.dest, (dir) => {
|
|
143
|
-
spinner.
|
|
136
|
+
spinner.warn(`Create Dir: ${dir}`);
|
|
144
137
|
});
|
|
145
|
-
|
|
146
|
-
|
|
138
|
+
const destExists = await ftpClient.exists(item.dest);
|
|
139
|
+
if (destExists) {
|
|
140
|
+
spinner.warn(`Delete exists file:${item.dest}`);
|
|
141
|
+
await ftpClient.delete(item.dest);
|
|
142
|
+
}
|
|
143
|
+
spinner.info(`Copying File: ${item.src} -> ${item.dest}`);
|
|
144
|
+
await ftpClient.rcopy(item.src, item.dest);
|
|
145
|
+
} else {
|
|
146
|
+
const localFile = path.resolve(process.cwd(), item.src);
|
|
147
|
+
if (!item.remoteCopy && !fs3.existsSync(localFile)) {
|
|
148
|
+
spinner.warn(`Skip not exists file:${localFile}`);
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
if (fs3.lstatSync(localFile).isDirectory()) {
|
|
152
|
+
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
153
|
+
await ftpClient.uploadDir(localFile, item.dest, {
|
|
154
|
+
filter: (filePath, isDirectory) => {
|
|
155
|
+
if (item.ignore && !isDirectory) {
|
|
156
|
+
const fileName = path.basename(filePath);
|
|
157
|
+
if (item.ignore.some((ignorePattern) => minimatch(fileName, ignorePattern))) {
|
|
158
|
+
spinner.warn(`Skip file:${filePath}`);
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
} else {
|
|
166
|
+
await checkParentDir(ftpClient, item.dest, (dir) => {
|
|
167
|
+
spinner.succeed(`Create Dir: ${dir}`);
|
|
168
|
+
});
|
|
169
|
+
spinner.info(`Uploading File: ${localFile} -> ${item.dest}`);
|
|
170
|
+
await ftpClient.put(localFile, item.dest);
|
|
171
|
+
}
|
|
147
172
|
}
|
|
173
|
+
} else {
|
|
174
|
+
await ftpClient.put(Buffer.from(JSON.stringify(item.src), "utf-8"), item.dest);
|
|
148
175
|
}
|
|
149
|
-
|
|
150
|
-
await ftpClient.put(Buffer.from(JSON.stringify(item.src), "utf-8"), item.dest);
|
|
176
|
+
continue;
|
|
151
177
|
}
|
|
178
|
+
throw new Error("pattern or src is required in fileMap item");
|
|
152
179
|
}
|
|
153
180
|
spinner.succeed("Files uploaded!");
|
|
154
181
|
await ftpClient.end();
|
|
@@ -159,9 +186,13 @@ async function runSSH(sshConfig, releaseConfig) {
|
|
|
159
186
|
}
|
|
160
187
|
async function ftpUpload(releaseFile = "release.json") {
|
|
161
188
|
const releaseJsonFilePath = path.join(process.cwd(), releaseFile);
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
189
|
+
let releaseJson = fs3.readFileSync(releaseJsonFilePath).toString();
|
|
190
|
+
const hasPackageJson = fs3.existsSync(Utils.getPackagePath());
|
|
191
|
+
if (hasPackageJson) {
|
|
192
|
+
const packageVersion = Utils.getPackageVersion();
|
|
193
|
+
consola2.info("Package Version:", packageVersion);
|
|
194
|
+
releaseJson = releaseJson.replaceAll(`\${version}`, packageVersion);
|
|
195
|
+
}
|
|
165
196
|
const releaseConfig = JSON.parse(releaseJson);
|
|
166
197
|
const sshConfigFile = path.resolve(os.homedir(), ".ssh/config");
|
|
167
198
|
consola2.info("SSH Config File Path:", sshConfigFile);
|
|
@@ -208,16 +239,17 @@ async function release(options) {
|
|
|
208
239
|
}
|
|
209
240
|
const updateZipPath = path2.join(`./dist/update.zip`);
|
|
210
241
|
consola3.log(chalk2.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
242
|
+
const ossClient = new OssClient();
|
|
211
243
|
await update_zip_default("./release", updateZipPath);
|
|
212
244
|
consola3.log(chalk2.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
213
|
-
await put("version/installer.exe", installerPath);
|
|
245
|
+
await ossClient.put("version/installer.exe", installerPath);
|
|
214
246
|
consola3.log(chalk2.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
215
|
-
await put("version/update.zip", updateZipPath);
|
|
247
|
+
await ossClient.put("version/update.zip", updateZipPath);
|
|
216
248
|
consola3.log(chalk2.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
217
249
|
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
218
250
|
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")]);
|
|
251
|
+
await ossClient.put("version/version.json", Buffer2.from(versionJSON));
|
|
252
|
+
await Promise.all([ossClient.copy(`version/history/${version}.exe`, "version/installer.exe"), ossClient.copy(`version/history/update-${version}.zip`, "version/update.zip")]);
|
|
221
253
|
consola3.log(chalk2.yellow(versionJSON));
|
|
222
254
|
}
|
|
223
255
|
var release_default = release;
|
package/package.json
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widget-js/cli",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "24.1.1-beta.
|
|
4
|
+
"version": "24.1.1-beta.63",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Neo Fu",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"main": "
|
|
8
|
+
"main": "dist/index.js",
|
|
9
9
|
"bin": {
|
|
10
|
-
"widget": "
|
|
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
|
},
|
|
@@ -19,67 +23,73 @@
|
|
|
19
23
|
"@types/archiver": "^5.3.1",
|
|
20
24
|
"@vue/cli-shared-utils": "^5.0.8",
|
|
21
25
|
"@widget-js/ssh-config": "^4.2.1",
|
|
22
|
-
"@widget-js/vue3": "^0.11.20",
|
|
23
26
|
"ali-oss": "^6.17.1",
|
|
24
27
|
"archiver": "^5.3.1",
|
|
28
|
+
"axios": "^1.7.2",
|
|
25
29
|
"chalk": "^4.1.2",
|
|
26
30
|
"change-case": "^4.1.2",
|
|
27
31
|
"commander": "^9.4.1",
|
|
28
32
|
"consola": "^2.15.3",
|
|
29
33
|
"dirname-filename-esm": "^1.1.1",
|
|
30
34
|
"ejs": "^3.1.8",
|
|
35
|
+
"fast-glob": "^3.3.2",
|
|
31
36
|
"figlet": "^1.5.2",
|
|
32
|
-
"
|
|
37
|
+
"gradient-string": "^2.0.2",
|
|
38
|
+
"inquirer": "^8.2.6",
|
|
33
39
|
"minimatch": "^9.0.3",
|
|
34
40
|
"ora": "^6.2.0",
|
|
35
|
-
"package-json": "^
|
|
41
|
+
"package-json": "^10.0.1",
|
|
36
42
|
"prettier": "^3.1.1",
|
|
37
43
|
"semver": "^7.5.2",
|
|
38
44
|
"shelljs": "^0.8.5",
|
|
39
|
-
"gradient-string": "^2.0.2",
|
|
40
45
|
"ssh2-sftp-client": "^9.1.0",
|
|
41
46
|
"ws": "^8.11.0",
|
|
42
|
-
"@widget-js/
|
|
43
|
-
"@widget-js/
|
|
47
|
+
"@widget-js/utils": "24.1.1-beta.62",
|
|
48
|
+
"@widget-js/vue3": "24.1.1-beta.65",
|
|
49
|
+
"@widget-js/core": "24.1.1-beta.63"
|
|
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
|
-
"@types/jest": "^29.2.3",
|
|
51
58
|
"@types/minimist": "^1.2.5",
|
|
52
59
|
"@types/node": "^18.11.13",
|
|
53
60
|
"@types/semver": "^7.5.0",
|
|
54
|
-
"@types/gradient-string": "^1.1.2",
|
|
55
61
|
"@types/shelljs": "latest",
|
|
56
62
|
"@types/ssh2-sftp-client": "^9.0.1",
|
|
57
|
-
"
|
|
58
|
-
"jest": "^29.5.0",
|
|
59
|
-
"pinst": "^3.0.0",
|
|
63
|
+
"eslint": "8.48.0",
|
|
60
64
|
"rimraf": "^4.4.1",
|
|
61
|
-
"ts-jest": "^29.0.3",
|
|
62
65
|
"ts-loader": "^9.4.1",
|
|
63
66
|
"ts-node": "^10.9.1",
|
|
64
67
|
"tsup": "^6.5.0",
|
|
65
68
|
"typescript": "^5.2.2",
|
|
66
|
-
"
|
|
69
|
+
"vite": "^5.0.5",
|
|
70
|
+
"vitest": "^3.2.4",
|
|
67
71
|
"vue-router": "^4.2.5",
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"@widget-js/
|
|
71
|
-
"@widget-js/vue3": "^0.11.20"
|
|
72
|
+
"@widget-js/vite-plugin-widget": "24.1.1-beta.63",
|
|
73
|
+
"@widget-js/core": "24.1.1-beta.63",
|
|
74
|
+
"@widget-js/vue3": "24.1.1-beta.65"
|
|
72
75
|
},
|
|
73
76
|
"scripts": {
|
|
74
|
-
"build": "
|
|
75
|
-
"watch": "tsup src/index.ts --
|
|
77
|
+
"build": "tsup-node src/index.ts",
|
|
78
|
+
"watch": "tsup-node src/index.ts --watch",
|
|
76
79
|
"build:run": "npm run build && npm run widget",
|
|
77
|
-
"widget": "node ./
|
|
78
|
-
"widget:ftp": "node ./
|
|
79
|
-
"widget:init": "node ./
|
|
80
|
-
"widget:
|
|
81
|
-
"widget:
|
|
80
|
+
"widget": "node ./dist/index.js",
|
|
81
|
+
"widget:ftp": "node ./dist/index.js release -t ftp",
|
|
82
|
+
"widget:init": "node ./dist/index.js init",
|
|
83
|
+
"widget:publish": "node ./dist/index.js publish -key 123",
|
|
84
|
+
"widget:create": "npm run build && node ./dist/index.js create",
|
|
85
|
+
"widget:local": "npm run build && node ./dist/index.js dependencies -t local",
|
|
86
|
+
"widget:remote": "npm run build && node ./dist/index.js dependencies -t remote",
|
|
82
87
|
"build:publish": "npm run build && npm run pnpm:publish",
|
|
83
|
-
"pnpm:publish": "pnpm publish --no-git-checks"
|
|
88
|
+
"pnpm:publish": "pnpm publish --no-git-checks",
|
|
89
|
+
"remote": "widget dependencies -t remote && pnpm install",
|
|
90
|
+
"local": "widget dependencies -t local && pnpm install",
|
|
91
|
+
"link": "pnpm link --global",
|
|
92
|
+
"lint": "eslint .",
|
|
93
|
+
"lint:fix": "eslint . --fix"
|
|
84
94
|
}
|
|
85
95
|
}
|
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 {
|
|
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
|
|
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,18 +4,18 @@ 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
|
{
|
|
11
11
|
path: path,
|
|
12
12
|
name: `${name}`,
|
|
13
|
-
component: () => import(
|
|
13
|
+
component: () => import('./<%= name %>WidgetView.vue')
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
path: configPagePath,
|
|
17
17
|
name: `${name}.config`,
|
|
18
|
-
component: () => import(
|
|
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(
|
|
26
|
+
component: () => import('./<%= name %>WidgetView.vue')
|
|
27
27
|
}
|
|
28
28
|
]
|
|
29
29
|
<% } %>
|