@widget-js/cli 1.0.15 → 1.0.16
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/.idea/codeStyles/Project.xml +58 -0
- package/.idea/codeStyles/codeStyleConfig.xml +1 -1
- package/lib/build-BTARJMCZ.js +31 -0
- package/lib/chunk-VOTZXZ5O.js +36 -0
- package/lib/createWidget-AX4QC5FV.js +191 -0
- package/lib/index.cjs +263 -156
- package/lib/index.js +15 -415
- package/lib/release-CEWJTX3Q.js +200 -0
- package/package.json +4 -2
- package/release.json +5 -0
- package/src/build/build.ts +35 -0
- package/src/index.ts +12 -5
- package/src/release/ftp.ts +9 -3
- package/src/utils.ts +15 -6
package/lib/index.cjs
CHANGED
|
@@ -5,6 +5,13 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __esm = (fn, res) => function __init() {
|
|
9
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
10
|
+
};
|
|
11
|
+
var __export = (target, all) => {
|
|
12
|
+
for (var name in all)
|
|
13
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
14
|
+
};
|
|
8
15
|
var __copyProps = (to, from, except, desc) => {
|
|
9
16
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
17
|
for (let key of __getOwnPropNames(from))
|
|
@@ -18,59 +25,62 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
18
25
|
mod
|
|
19
26
|
));
|
|
20
27
|
|
|
21
|
-
// src/index.ts
|
|
22
|
-
var import_commander = require("commander");
|
|
23
|
-
var import_fs6 = __toESM(require("fs"), 1);
|
|
24
|
-
var import_path4 = __toESM(require("path"), 1);
|
|
25
|
-
var process3 = __toESM(require("process"), 1);
|
|
26
|
-
|
|
27
|
-
// src/createWidget.ts
|
|
28
|
-
var import_path = __toESM(require("path"), 1);
|
|
29
|
-
var import_fs = __toESM(require("fs"), 1);
|
|
30
|
-
var import_consola = __toESM(require("consola"), 1);
|
|
31
|
-
var import_url = require("url");
|
|
32
|
-
|
|
33
28
|
// src/promts/promptChecker.ts
|
|
34
|
-
var import_inquirer
|
|
35
|
-
var
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
var import_inquirer, promptChecker, promptChecker_default;
|
|
30
|
+
var init_promptChecker = __esm({
|
|
31
|
+
"src/promts/promptChecker.ts"() {
|
|
32
|
+
"use strict";
|
|
33
|
+
import_inquirer = __toESM(require("inquirer"), 1);
|
|
34
|
+
promptChecker = async (prompt, checker) => {
|
|
35
|
+
const answer = await import_inquirer.default.prompt([prompt]);
|
|
36
|
+
if (checker) {
|
|
37
|
+
if (checker(answer)) {
|
|
38
|
+
return answer[prompt.name];
|
|
39
|
+
} else {
|
|
40
|
+
return promptChecker(prompt, checker);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
39
43
|
return answer[prompt.name];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
}
|
|
44
|
+
};
|
|
45
|
+
promptChecker_default = promptChecker;
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
};
|
|
46
|
-
var promptChecker_default = promptChecker;
|
|
47
|
-
|
|
48
|
-
// src/createWidget.ts
|
|
49
|
-
var import_change_case = require("change-case");
|
|
50
|
-
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
51
|
-
var import_ejs = __toESM(require("ejs"), 1);
|
|
52
|
-
var import_shelljs = __toESM(require("shelljs"), 1);
|
|
47
|
+
});
|
|
53
48
|
|
|
54
49
|
// src/utils.ts
|
|
55
50
|
function exit(code = 0) {
|
|
56
51
|
if (exports.exitProcess) {
|
|
57
|
-
|
|
52
|
+
import_process.default.exit(code);
|
|
58
53
|
} else if (code > 0) {
|
|
59
54
|
throw new Error(`Process exited with code ${code}`);
|
|
60
55
|
}
|
|
61
56
|
}
|
|
57
|
+
function getPackageVersion() {
|
|
58
|
+
const packagePath = import_path.default.join(import_process.default.cwd(), "package.json");
|
|
59
|
+
return JSON.parse(import_fs.default.readFileSync(packagePath).toString())["version"];
|
|
60
|
+
}
|
|
61
|
+
var import_path, import_process, import_fs;
|
|
62
|
+
var init_utils = __esm({
|
|
63
|
+
"src/utils.ts"() {
|
|
64
|
+
"use strict";
|
|
65
|
+
import_path = __toESM(require("path"), 1);
|
|
66
|
+
import_process = __toESM(require("process"), 1);
|
|
67
|
+
import_fs = __toESM(require("fs"), 1);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
62
70
|
|
|
63
71
|
// src/createWidget.ts
|
|
64
|
-
var
|
|
65
|
-
|
|
72
|
+
var createWidget_exports = {};
|
|
73
|
+
__export(createWidget_exports, {
|
|
74
|
+
default: () => createWidget
|
|
75
|
+
});
|
|
66
76
|
async function createWidget() {
|
|
67
|
-
let widgetJson =
|
|
68
|
-
if (!
|
|
77
|
+
let widgetJson = import_path2.default.join(process.cwd(), "widget.json");
|
|
78
|
+
if (!import_fs2.default.existsSync(widgetJson)) {
|
|
69
79
|
import_consola.default.error("\u6CA1\u6709\u5728\u6839\u76EE\u5F55\u627E\u5230widget.json\u6587\u4EF6");
|
|
70
80
|
exit();
|
|
71
81
|
}
|
|
72
|
-
let widgetPackage = JSON.parse(
|
|
73
|
-
let widgetFolder =
|
|
82
|
+
let widgetPackage = JSON.parse(import_fs2.default.readFileSync(widgetJson).toString());
|
|
83
|
+
let widgetFolder = import_path2.default.join(process.cwd(), "./src/widgets");
|
|
74
84
|
let devOptions = widgetPackage["devOptions"] ?? {};
|
|
75
85
|
if (devOptions["folder"]) {
|
|
76
86
|
widgetFolder = devOptions["folder"];
|
|
@@ -78,11 +88,11 @@ async function createWidget() {
|
|
|
78
88
|
} else {
|
|
79
89
|
import_consola.default.info(`\u6CA1\u6709\u914D\u7F6EdevOptions.folder\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u8DEF\u5F84${widgetFolder}`);
|
|
80
90
|
}
|
|
81
|
-
if (!
|
|
82
|
-
|
|
91
|
+
if (!import_fs2.default.existsSync(widgetFolder)) {
|
|
92
|
+
import_fs2.default.mkdirSync(widgetFolder, { recursive: true });
|
|
83
93
|
}
|
|
84
94
|
const __filename2 = (0, import_url.fileURLToPath)(import_meta.url);
|
|
85
|
-
const __dirname2 =
|
|
95
|
+
const __dirname2 = import_path2.default.dirname(__filename2);
|
|
86
96
|
const getMiddleValue = (arr) => {
|
|
87
97
|
if (arr.length === 1) {
|
|
88
98
|
return arr[0];
|
|
@@ -163,9 +173,9 @@ async function createWidget() {
|
|
|
163
173
|
const snakeCaseName = (0, import_change_case.snakeCase)(name);
|
|
164
174
|
const paramCaseName = (0, import_change_case.paramCase)(name);
|
|
165
175
|
const packageName = "com.wisdom.widgets." + snakeCaseName;
|
|
166
|
-
const widgetDir =
|
|
167
|
-
if (!
|
|
168
|
-
|
|
176
|
+
const widgetDir = import_path2.default.join(widgetFolder, paramCaseName);
|
|
177
|
+
if (!import_fs2.default.existsSync(widgetDir)) {
|
|
178
|
+
import_fs2.default.mkdirSync(widgetDir);
|
|
169
179
|
} else {
|
|
170
180
|
let answer = await import_inquirer2.default.prompt([{
|
|
171
181
|
type: "confirm",
|
|
@@ -191,32 +201,32 @@ async function createWidget() {
|
|
|
191
201
|
minWidth
|
|
192
202
|
};
|
|
193
203
|
function renderToFile(templateFile, outputFile, renderOptions2) {
|
|
194
|
-
const defineTemplatePath =
|
|
195
|
-
let defineTemplate =
|
|
196
|
-
|
|
204
|
+
const defineTemplatePath = import_path2.default.join(__dirname2, "../template", templateFile);
|
|
205
|
+
let defineTemplate = import_fs2.default.readFileSync(defineTemplatePath, "utf8");
|
|
206
|
+
import_fs2.default.writeFileSync(outputFile, import_ejs.default.render(defineTemplate, renderOptions2));
|
|
197
207
|
}
|
|
198
|
-
const widgetDefineFile =
|
|
199
|
-
const widgetFile =
|
|
200
|
-
const widgetViewFile =
|
|
201
|
-
const widgetRoutesFile =
|
|
208
|
+
const widgetDefineFile = import_path2.default.resolve(widgetDir, `${name}.widget.ts`);
|
|
209
|
+
const widgetFile = import_path2.default.resolve(widgetDir, `${name}Widget.vue`);
|
|
210
|
+
const widgetViewFile = import_path2.default.resolve(widgetDir, `${name}WidgetView.vue`);
|
|
211
|
+
const widgetRoutesFile = import_path2.default.resolve(widgetDir, `${name}WidgetRoutes.ts`);
|
|
202
212
|
renderToFile("WidgetDefine.ejs", widgetDefineFile, renderOptions);
|
|
203
213
|
renderToFile("Widget.ejs", widgetFile, renderOptions);
|
|
204
214
|
renderToFile("WidgetView.ejs", widgetViewFile, renderOptions);
|
|
205
215
|
renderToFile("WidgetRoutes.ejs", widgetRoutesFile, renderOptions);
|
|
206
216
|
if (configurable) {
|
|
207
|
-
const configFile =
|
|
217
|
+
const configFile = import_path2.default.resolve(widgetDir, `${name}ConfigView.vue`);
|
|
208
218
|
renderToFile("WidgetConfig.ejs", configFile, renderOptions);
|
|
209
219
|
}
|
|
210
220
|
if (devOptions["useStorybook"]) {
|
|
211
|
-
const storiesFile =
|
|
221
|
+
const storiesFile = import_path2.default.resolve(widgetDir, `${name}Widget.stories.ts`);
|
|
212
222
|
renderToFile("stories.ejs", storiesFile, renderOptions);
|
|
213
223
|
}
|
|
214
|
-
const routeFile =
|
|
224
|
+
const routeFile = import_path2.default.join(widgetFolder, "widget-router.ts");
|
|
215
225
|
let routeContent;
|
|
216
|
-
if (
|
|
217
|
-
routeContent =
|
|
226
|
+
if (import_fs2.default.existsSync(routeFile)) {
|
|
227
|
+
routeContent = import_fs2.default.readFileSync(routeFile, "utf8");
|
|
218
228
|
} else {
|
|
219
|
-
routeContent =
|
|
229
|
+
routeContent = import_fs2.default.readFileSync(import_path2.default.join(__dirname2, "../template/widget-router.ts"), "utf8");
|
|
220
230
|
}
|
|
221
231
|
const importRouteStr = `import ${name}WidgetRoutes from "./${paramCaseName}/${name}WidgetRoutes";`;
|
|
222
232
|
const routeStr = `...${name}WidgetRoutes,`;
|
|
@@ -228,7 +238,7 @@ async function createWidget() {
|
|
|
228
238
|
routeContent = routeContent.replaceAll("//FBI WANING! ROUTE PLACE", `${routeStr}
|
|
229
239
|
//FBI WANING! ROUTE PLACE`);
|
|
230
240
|
}
|
|
231
|
-
|
|
241
|
+
import_fs2.default.writeFileSync(routeFile, routeContent);
|
|
232
242
|
let gitAdd = `git add ${widgetDir}`;
|
|
233
243
|
import_consola.default.info(import_chalk.default.grey(gitAdd));
|
|
234
244
|
import_shelljs.default.exec(gitAdd);
|
|
@@ -236,44 +246,85 @@ async function createWidget() {
|
|
|
236
246
|
import_consola.default.info(`\u5DF2\u521B\u5EFA\u7EC4\u4EF6\uFF1A${widgetDir}`);
|
|
237
247
|
import_consola.default.success("Happy coding!");
|
|
238
248
|
}
|
|
249
|
+
var import_path2, import_fs2, import_consola, import_url, import_change_case, import_inquirer2, import_ejs, import_shelljs, import_chalk, import_meta;
|
|
250
|
+
var init_createWidget = __esm({
|
|
251
|
+
"src/createWidget.ts"() {
|
|
252
|
+
"use strict";
|
|
253
|
+
import_path2 = __toESM(require("path"), 1);
|
|
254
|
+
import_fs2 = __toESM(require("fs"), 1);
|
|
255
|
+
import_consola = __toESM(require("consola"), 1);
|
|
256
|
+
import_url = require("url");
|
|
257
|
+
init_promptChecker();
|
|
258
|
+
import_change_case = require("change-case");
|
|
259
|
+
import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
260
|
+
import_ejs = __toESM(require("ejs"), 1);
|
|
261
|
+
import_shelljs = __toESM(require("shelljs"), 1);
|
|
262
|
+
init_utils();
|
|
263
|
+
import_chalk = __toESM(require("chalk"), 1);
|
|
264
|
+
import_meta = {};
|
|
265
|
+
}
|
|
266
|
+
});
|
|
239
267
|
|
|
240
|
-
// src/
|
|
241
|
-
var
|
|
242
|
-
|
|
268
|
+
// src/build/build.ts
|
|
269
|
+
var build_exports = {};
|
|
270
|
+
__export(build_exports, {
|
|
271
|
+
build: () => build
|
|
272
|
+
});
|
|
273
|
+
function build() {
|
|
274
|
+
const preloadSpinner = (0, import_ora.default)("Preload").start();
|
|
275
|
+
const mainSpinner = (0, import_ora.default)("Main").start();
|
|
276
|
+
const build2 = (0, import_child_process.exec)("npm run build:preload").on("close", () => {
|
|
277
|
+
import_consola2.default.success("done");
|
|
278
|
+
});
|
|
279
|
+
build2.stdout.on("data", (data) => {
|
|
280
|
+
import_consola2.default.log("data", data);
|
|
281
|
+
});
|
|
282
|
+
(0, import_child_process.exec)("npm run build:main", (error, stdout, stderr) => {
|
|
283
|
+
if (error) {
|
|
284
|
+
import_consola2.default.error("error: " + error);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
import_consola2.default.log("stdout: " + stdout);
|
|
288
|
+
import_consola2.default.log("stderr: " + typeof stderr);
|
|
289
|
+
}).on("message", () => {
|
|
290
|
+
import_consola2.default.log("on-message");
|
|
291
|
+
}).on("data", () => {
|
|
292
|
+
import_consola2.default.log("on-data");
|
|
293
|
+
}).on("close", () => {
|
|
294
|
+
import_consola2.default.log("done");
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
var import_ora, import_child_process, import_consola2;
|
|
298
|
+
var init_build = __esm({
|
|
299
|
+
"src/build/build.ts"() {
|
|
300
|
+
"use strict";
|
|
301
|
+
import_ora = __toESM(require("ora"), 1);
|
|
302
|
+
import_child_process = require("child_process");
|
|
303
|
+
import_consola2 = __toESM(require("consola"), 1);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
243
306
|
|
|
244
307
|
// src/release/update-zip.ts
|
|
245
|
-
var import_fs2 = __toESM(require("fs"), 1);
|
|
246
|
-
var import_archiver = __toESM(require("archiver"), 1);
|
|
247
308
|
function zipDirectory(sourceDir, outPath, ignoreDir) {
|
|
248
309
|
const archive = (0, import_archiver.default)("zip", { zlib: { level: 9 } });
|
|
249
|
-
const stream =
|
|
310
|
+
const stream = import_fs3.default.createWriteStream(outPath);
|
|
250
311
|
return new Promise((resolve, reject) => {
|
|
251
312
|
archive.glob("**/*", { cwd: sourceDir, ignore: ["node_modules/**"] }).on("error", (err) => reject(err)).pipe(stream);
|
|
252
313
|
stream.on("close", () => resolve());
|
|
253
314
|
archive.finalize();
|
|
254
315
|
});
|
|
255
316
|
}
|
|
256
|
-
var
|
|
317
|
+
var import_fs3, import_archiver, update_zip_default;
|
|
318
|
+
var init_update_zip = __esm({
|
|
319
|
+
"src/release/update-zip.ts"() {
|
|
320
|
+
"use strict";
|
|
321
|
+
import_fs3 = __toESM(require("fs"), 1);
|
|
322
|
+
import_archiver = __toESM(require("archiver"), 1);
|
|
323
|
+
update_zip_default = zipDirectory;
|
|
324
|
+
}
|
|
325
|
+
});
|
|
257
326
|
|
|
258
327
|
// src/release/oss.ts
|
|
259
|
-
var import_ali_oss = __toESM(require("ali-oss"), 1);
|
|
260
|
-
var import_fs3 = __toESM(require("fs"), 1);
|
|
261
|
-
var import_chalk2 = __toESM(require("chalk"), 1);
|
|
262
|
-
var packageData = JSON.parse(import_fs3.default.readFileSync("./package.json").toString());
|
|
263
|
-
var AccessKeyID = packageData.oss?.id ?? "default";
|
|
264
|
-
var AccessKeySecret = packageData.oss?.secret ?? "default";
|
|
265
|
-
var headers = {
|
|
266
|
-
"x-oss-storage-class": "Standard",
|
|
267
|
-
"x-oss-object-acl": "public-read",
|
|
268
|
-
"x-oss-forbid-overwrite": "false",
|
|
269
|
-
"Cache-Control": "no-cache"
|
|
270
|
-
};
|
|
271
|
-
var clinet = new import_ali_oss.default({
|
|
272
|
-
region: "oss-cn-hangzhou",
|
|
273
|
-
accessKeyId: AccessKeyID,
|
|
274
|
-
accessKeySecret: AccessKeySecret,
|
|
275
|
-
bucket: "widget-fun"
|
|
276
|
-
});
|
|
277
328
|
async function put(ossPath, file) {
|
|
278
329
|
try {
|
|
279
330
|
const result = await clinet.put(ossPath, file, { headers });
|
|
@@ -290,23 +341,34 @@ async function copy(dist, src) {
|
|
|
290
341
|
console.error(e);
|
|
291
342
|
}
|
|
292
343
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
344
|
+
var import_ali_oss, import_fs4, import_chalk2, packageData, AccessKeyID, AccessKeySecret, headers, clinet;
|
|
345
|
+
var init_oss = __esm({
|
|
346
|
+
"src/release/oss.ts"() {
|
|
347
|
+
"use strict";
|
|
348
|
+
import_ali_oss = __toESM(require("ali-oss"), 1);
|
|
349
|
+
import_fs4 = __toESM(require("fs"), 1);
|
|
350
|
+
import_chalk2 = __toESM(require("chalk"), 1);
|
|
351
|
+
packageData = JSON.parse(import_fs4.default.readFileSync("./package.json").toString());
|
|
352
|
+
AccessKeyID = packageData.oss?.id ?? "default";
|
|
353
|
+
AccessKeySecret = packageData.oss?.secret ?? "default";
|
|
354
|
+
headers = {
|
|
355
|
+
"x-oss-storage-class": "Standard",
|
|
356
|
+
"x-oss-object-acl": "public-read",
|
|
357
|
+
"x-oss-forbid-overwrite": "false",
|
|
358
|
+
"Cache-Control": "no-cache"
|
|
359
|
+
};
|
|
360
|
+
clinet = new import_ali_oss.default({
|
|
361
|
+
region: "oss-cn-hangzhou",
|
|
362
|
+
accessKeyId: AccessKeyID,
|
|
363
|
+
accessKeySecret: AccessKeySecret,
|
|
364
|
+
bucket: "widget-fun"
|
|
365
|
+
});
|
|
366
|
+
}
|
|
367
|
+
});
|
|
296
368
|
|
|
297
369
|
// src/release/ftp.ts
|
|
298
|
-
var import_path2 = __toESM(require("path"), 1);
|
|
299
|
-
var import_fs4 = __toESM(require("fs"), 1);
|
|
300
|
-
var import_ssh_config = __toESM(require("@widget-js/ssh-config"), 1);
|
|
301
|
-
var import_os = __toESM(require("os"), 1);
|
|
302
|
-
var import_ssh2_sftp_client = __toESM(require("ssh2-sftp-client"), 1);
|
|
303
|
-
var import_consola2 = __toESM(require("consola"), 1);
|
|
304
|
-
var import_inquirer3 = __toESM(require("inquirer"), 1);
|
|
305
|
-
var import_ora = __toESM(require("ora"), 1);
|
|
306
|
-
var process2 = __toESM(require("process"), 1);
|
|
307
|
-
var console2 = __toESM(require("console"), 1);
|
|
308
370
|
async function checkParentDir(ftpClient, file, onMkdir) {
|
|
309
|
-
let dir =
|
|
371
|
+
let dir = import_path3.default.dirname(file);
|
|
310
372
|
const dirExists = await ftpClient.exists(dir);
|
|
311
373
|
if (!dirExists) {
|
|
312
374
|
onMkdir(dir);
|
|
@@ -314,22 +376,25 @@ async function checkParentDir(ftpClient, file, onMkdir) {
|
|
|
314
376
|
}
|
|
315
377
|
}
|
|
316
378
|
function ftpUpload() {
|
|
317
|
-
const
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
const
|
|
379
|
+
const releaseJsonFilePath = import_path3.default.join(process3.cwd(), "release.json");
|
|
380
|
+
const packageVersion = getPackageVersion();
|
|
381
|
+
import_consola3.default.info("Package Version:", packageVersion);
|
|
382
|
+
let releaseJson = import_fs5.default.readFileSync(releaseJsonFilePath).toString().replaceAll("${version}", packageVersion);
|
|
383
|
+
const releaseConfig = JSON.parse(releaseJson);
|
|
384
|
+
const sshConfigFile = import_path3.default.resolve(import_os.default.homedir(), ".ssh/config");
|
|
385
|
+
import_consola3.default.info("SSH Config File Path:", sshConfigFile);
|
|
386
|
+
const sshConfigs = import_ssh_config.default.parse(import_fs5.default.readFileSync(sshConfigFile).toString());
|
|
322
387
|
let sshConfig = sshConfigs.compute(releaseConfig.ftpConfig.host);
|
|
323
388
|
if (!sshConfig) {
|
|
324
|
-
|
|
389
|
+
import_consola3.default.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
|
|
325
390
|
return;
|
|
326
391
|
}
|
|
327
|
-
|
|
392
|
+
import_consola3.default.info(sshConfig);
|
|
328
393
|
import_inquirer3.default.prompt([{ type: "password", name: "password", mask: "*", message: "Enter key pair password" }]).then(async (answer) => {
|
|
329
394
|
let ftpClient = new import_ssh2_sftp_client.default();
|
|
330
395
|
const port = sshConfig["Port"];
|
|
331
|
-
const key =
|
|
332
|
-
const spinner = (0,
|
|
396
|
+
const key = import_fs5.default.readFileSync(import_path3.default.resolve(import_os.default.homedir(), ".ssh/id_rsa"));
|
|
397
|
+
const spinner = (0, import_ora2.default)("Connecting");
|
|
333
398
|
try {
|
|
334
399
|
spinner.start();
|
|
335
400
|
await ftpClient.connect({
|
|
@@ -354,12 +419,12 @@ function ftpUpload() {
|
|
|
354
419
|
spinner.info(`Copying File: ${item.src} -> ${item.dest}`);
|
|
355
420
|
await ftpClient.rcopy(item.src, item.dest);
|
|
356
421
|
} else {
|
|
357
|
-
const localFile =
|
|
358
|
-
if (!item.remoteCopy && !
|
|
422
|
+
const localFile = import_path3.default.resolve(process3.cwd(), item.src);
|
|
423
|
+
if (!item.remoteCopy && !import_fs5.default.existsSync(localFile)) {
|
|
359
424
|
spinner.warn(`Skip not exists file:${localFile}`);
|
|
360
425
|
continue;
|
|
361
426
|
}
|
|
362
|
-
if (
|
|
427
|
+
if (import_fs5.default.lstatSync(localFile).isDirectory()) {
|
|
363
428
|
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
364
429
|
await ftpClient.uploadDir(localFile, item.dest);
|
|
365
430
|
} else {
|
|
@@ -382,69 +447,111 @@ function ftpUpload() {
|
|
|
382
447
|
}
|
|
383
448
|
});
|
|
384
449
|
}
|
|
450
|
+
var import_path3, import_fs5, import_ssh_config, import_os, import_ssh2_sftp_client, import_consola3, import_inquirer3, import_ora2, process3;
|
|
451
|
+
var init_ftp = __esm({
|
|
452
|
+
"src/release/ftp.ts"() {
|
|
453
|
+
"use strict";
|
|
454
|
+
import_path3 = __toESM(require("path"), 1);
|
|
455
|
+
import_fs5 = __toESM(require("fs"), 1);
|
|
456
|
+
import_ssh_config = __toESM(require("@widget-js/ssh-config"), 1);
|
|
457
|
+
import_os = __toESM(require("os"), 1);
|
|
458
|
+
import_ssh2_sftp_client = __toESM(require("ssh2-sftp-client"), 1);
|
|
459
|
+
import_consola3 = __toESM(require("consola"), 1);
|
|
460
|
+
import_inquirer3 = __toESM(require("inquirer"), 1);
|
|
461
|
+
import_ora2 = __toESM(require("ora"), 1);
|
|
462
|
+
process3 = __toESM(require("process"), 1);
|
|
463
|
+
init_utils();
|
|
464
|
+
}
|
|
465
|
+
});
|
|
385
466
|
|
|
386
467
|
// src/release/release.ts
|
|
387
|
-
var
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
468
|
+
var release_exports = {};
|
|
469
|
+
__export(release_exports, {
|
|
470
|
+
default: () => release_default
|
|
471
|
+
});
|
|
472
|
+
var import_fs6, import_path4, import_chalk3, release, release_default;
|
|
473
|
+
var init_release = __esm({
|
|
474
|
+
"src/release/release.ts"() {
|
|
475
|
+
"use strict";
|
|
476
|
+
import_fs6 = __toESM(require("fs"), 1);
|
|
477
|
+
import_path4 = __toESM(require("path"), 1);
|
|
478
|
+
init_promptChecker();
|
|
479
|
+
init_update_zip();
|
|
480
|
+
init_oss();
|
|
481
|
+
import_chalk3 = __toESM(require("chalk"), 1);
|
|
482
|
+
init_ftp();
|
|
483
|
+
release = async (options) => {
|
|
484
|
+
console.log();
|
|
485
|
+
if (options.type == "ftp") {
|
|
486
|
+
await ftpUpload();
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const packageJSON = JSON.parse(import_fs6.default.readFileSync("package.json", "utf-8"));
|
|
490
|
+
const changelogJSON = JSON.parse(import_fs6.default.readFileSync("changelog.json", "utf-8"));
|
|
491
|
+
const version = packageJSON["version"];
|
|
492
|
+
const changelog = changelogJSON[version];
|
|
493
|
+
let needUpdateElectron = await promptChecker_default({
|
|
494
|
+
type: "confirm",
|
|
495
|
+
name: "electron",
|
|
496
|
+
message: import_chalk3.default.blue("\u7528\u6237\u662F\u5426\u9700\u8981\u66F4\u65B0Electron?")
|
|
497
|
+
});
|
|
498
|
+
const versionInfo = {
|
|
499
|
+
version,
|
|
500
|
+
releaseNote: changelog,
|
|
501
|
+
updateElectron: needUpdateElectron,
|
|
502
|
+
updateNodeModule: false,
|
|
503
|
+
updateWindowsApi: false,
|
|
504
|
+
downloadLink: ""
|
|
505
|
+
};
|
|
506
|
+
let installerPath = import_path4.default.join(`./packaged/widgets-${version}-setup-win-x64.exe`);
|
|
507
|
+
if (!import_fs6.default.existsSync(installerPath)) {
|
|
508
|
+
installerPath = import_path4.default.join(`./packaged/electron-${version}-setup-win-x64.exe`);
|
|
509
|
+
}
|
|
510
|
+
const updateZipPath = import_path4.default.join(`./packaged/update.zip`);
|
|
511
|
+
console.log(import_chalk3.default.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
512
|
+
await update_zip_default("./release", updateZipPath);
|
|
513
|
+
console.log(import_chalk3.default.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
514
|
+
await put("version/installer.exe", installerPath);
|
|
515
|
+
console.log(import_chalk3.default.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
516
|
+
await put("version/update.zip", updateZipPath);
|
|
517
|
+
console.log(import_chalk3.default.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
518
|
+
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
519
|
+
const versionJSON = JSON.stringify(versionInfo, null, 2);
|
|
520
|
+
await put("version/version.json", Buffer.from(versionJSON));
|
|
521
|
+
copy(`version/history/${version}.exe`, "version/installer.exe");
|
|
522
|
+
copy(`version/history/update-${version}.zip`, "version/update.zip");
|
|
523
|
+
console.log(import_chalk3.default.yellow(versionJSON));
|
|
524
|
+
};
|
|
525
|
+
release_default = release;
|
|
413
526
|
}
|
|
414
|
-
|
|
415
|
-
console.log(import_chalk3.default.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
416
|
-
await update_zip_default("./release", updateZipPath);
|
|
417
|
-
console.log(import_chalk3.default.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
418
|
-
await put("version/installer.exe", installerPath);
|
|
419
|
-
console.log(import_chalk3.default.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
420
|
-
await put("version/update.zip", updateZipPath);
|
|
421
|
-
console.log(import_chalk3.default.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
422
|
-
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
423
|
-
const versionJSON = JSON.stringify(versionInfo, null, 2);
|
|
424
|
-
await put("version/version.json", Buffer.from(versionJSON));
|
|
425
|
-
copy(`version/history/${version}.exe`, "version/installer.exe");
|
|
426
|
-
copy(`version/history/update-${version}.zip`, "version/update.zip");
|
|
427
|
-
console.log(import_chalk3.default.yellow(versionJSON));
|
|
428
|
-
};
|
|
429
|
-
var release_default = release;
|
|
527
|
+
});
|
|
430
528
|
|
|
431
529
|
// src/index.ts
|
|
530
|
+
var import_commander = require("commander");
|
|
531
|
+
var import_fs7 = __toESM(require("fs"), 1);
|
|
532
|
+
var import_path5 = __toESM(require("path"), 1);
|
|
533
|
+
var process4 = __toESM(require("process"), 1);
|
|
432
534
|
var import_url2 = require("url");
|
|
433
535
|
var import_figlet = __toESM(require("figlet"), 1);
|
|
434
536
|
var import_gradient_string = __toESM(require("gradient-string"), 1);
|
|
435
537
|
var import_meta2 = {};
|
|
436
538
|
var __filename = (0, import_url2.fileURLToPath)(import_meta2.url);
|
|
437
|
-
var __dirname =
|
|
438
|
-
var packageJsonPath =
|
|
439
|
-
var cliPackage = JSON.parse(
|
|
539
|
+
var __dirname = import_path5.default.dirname(__filename);
|
|
540
|
+
var packageJsonPath = import_path5.default.join(__dirname, "../package.json");
|
|
541
|
+
var cliPackage = JSON.parse(import_fs7.default.readFileSync(packageJsonPath).toString());
|
|
440
542
|
console.log(import_gradient_string.default.pastel.multiline(import_figlet.default.textSync("widget-cli", { horizontalLayout: "full" })));
|
|
441
543
|
import_commander.program.version(`@widget-js/cli ${cliPackage.version}`).usage("<command> [options]");
|
|
442
544
|
import_commander.program.command("create").description("\u521B\u5EFA\u65B0\u7684\u7EC4\u4EF6").action(async () => {
|
|
443
|
-
await
|
|
545
|
+
const createWidget2 = await Promise.resolve().then(() => (init_createWidget(), createWidget_exports));
|
|
546
|
+
await createWidget2.default();
|
|
547
|
+
});
|
|
548
|
+
import_commander.program.command("build").description("\u6267\u884C\u7F16\u8BD1\u4EFB\u52A1").action(async () => {
|
|
549
|
+
const build2 = await Promise.resolve().then(() => (init_build(), build_exports));
|
|
550
|
+
await build2.build();
|
|
444
551
|
});
|
|
445
552
|
var typeOption = new import_commander.Option("-t, --type <type>").choices(["ftp", "oss"]);
|
|
446
553
|
import_commander.program.command("release").description("\u901A\u8FC7FTP/OSS\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").addOption(typeOption).action(async (options, command) => {
|
|
447
|
-
|
|
448
|
-
await
|
|
554
|
+
let release2 = await Promise.resolve().then(() => (init_release(), release_exports));
|
|
555
|
+
await release2.default(options);
|
|
449
556
|
});
|
|
450
|
-
import_commander.program.parse(
|
|
557
|
+
import_commander.program.parse(process4.argv);
|