@widget-js/cli 1.0.12 → 1.0.13
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/index.cjs +66 -62
- package/lib/index.js +67 -63
- package/package.json +2 -2
- package/src/index.ts +10 -11
- package/src/{ftp → release/ftp}/ftp.ts +1 -1
- package/src/release/release.ts +75 -69
package/lib/index.cjs
CHANGED
|
@@ -238,8 +238,8 @@ async function createWidget() {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
// src/release/release.ts
|
|
241
|
-
var
|
|
242
|
-
var
|
|
241
|
+
var import_fs5 = __toESM(require("fs"), 1);
|
|
242
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
243
243
|
|
|
244
244
|
// src/release/update-zip.ts
|
|
245
245
|
var import_fs2 = __toESM(require("fs"), 1);
|
|
@@ -293,54 +293,11 @@ async function copy(dist, src) {
|
|
|
293
293
|
|
|
294
294
|
// src/release/release.ts
|
|
295
295
|
var import_chalk3 = __toESM(require("chalk"), 1);
|
|
296
|
-
var release = async () => {
|
|
297
|
-
const packageJSON = JSON.parse(import_fs4.default.readFileSync("package.json", "utf-8"));
|
|
298
|
-
const changelogJSON = JSON.parse(import_fs4.default.readFileSync("changelog.json", "utf-8"));
|
|
299
|
-
const version = packageJSON["version"];
|
|
300
|
-
const changelog = changelogJSON[version];
|
|
301
|
-
let needUpdateElectron = await promptChecker_default({
|
|
302
|
-
type: "confirm",
|
|
303
|
-
name: "electron",
|
|
304
|
-
message: import_chalk3.default.blue("\u7528\u6237\u662F\u5426\u9700\u8981\u66F4\u65B0Electron?")
|
|
305
|
-
});
|
|
306
|
-
const versionInfo = {
|
|
307
|
-
version,
|
|
308
|
-
releaseNote: changelog,
|
|
309
|
-
updateElectron: needUpdateElectron,
|
|
310
|
-
updateNodeModule: false,
|
|
311
|
-
updateWindowsApi: false,
|
|
312
|
-
downloadLink: ""
|
|
313
|
-
};
|
|
314
|
-
let installerPath = import_path2.default.join(`./packaged/widgets-${version}-setup-win-x64.exe`);
|
|
315
|
-
if (!import_fs4.default.existsSync(installerPath)) {
|
|
316
|
-
installerPath = import_path2.default.join(`./packaged/electron-${version}-setup-win-x64.exe`);
|
|
317
|
-
}
|
|
318
|
-
const updateZipPath = import_path2.default.join(`./packaged/update.zip`);
|
|
319
|
-
console.log(import_chalk3.default.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
320
|
-
await update_zip_default("./release", updateZipPath);
|
|
321
|
-
console.log(import_chalk3.default.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
322
|
-
await put("version/installer.exe", installerPath);
|
|
323
|
-
console.log(import_chalk3.default.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
324
|
-
await put("version/update.zip", updateZipPath);
|
|
325
|
-
console.log(import_chalk3.default.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
326
|
-
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
327
|
-
const versionJSON = JSON.stringify(versionInfo, null, 2);
|
|
328
|
-
await put("version/version.json", Buffer.from(versionJSON));
|
|
329
|
-
copy(`version/history/${version}.exe`, "version/installer.exe");
|
|
330
|
-
copy(`version/history/update-${version}.zip`, "version/update.zip");
|
|
331
|
-
console.log(import_chalk3.default.yellow(versionJSON));
|
|
332
|
-
};
|
|
333
|
-
var release_default = release;
|
|
334
|
-
|
|
335
|
-
// src/index.ts
|
|
336
|
-
var import_url2 = require("url");
|
|
337
|
-
var import_figlet = __toESM(require("figlet"), 1);
|
|
338
|
-
var import_gradient_string = __toESM(require("gradient-string"), 1);
|
|
339
296
|
|
|
340
|
-
// src/ftp/ftp.ts
|
|
341
|
-
var
|
|
342
|
-
var
|
|
343
|
-
var import_ssh_config = __toESM(require("ssh-config"), 1);
|
|
297
|
+
// src/release/ftp/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);
|
|
344
301
|
var import_os = __toESM(require("os"), 1);
|
|
345
302
|
var import_ssh2_sftp_client = __toESM(require("ssh2-sftp-client"), 1);
|
|
346
303
|
var import_consola2 = __toESM(require("consola"), 1);
|
|
@@ -349,11 +306,11 @@ var import_ora = __toESM(require("ora"), 1);
|
|
|
349
306
|
var process2 = __toESM(require("process"), 1);
|
|
350
307
|
var console2 = __toESM(require("console"), 1);
|
|
351
308
|
function ftpUpload() {
|
|
352
|
-
const file =
|
|
353
|
-
const releaseConfig = JSON.parse(
|
|
354
|
-
const sshConfigFile =
|
|
309
|
+
const file = import_path2.default.join(process2.cwd(), "release.json");
|
|
310
|
+
const releaseConfig = JSON.parse(import_fs4.default.readFileSync(file).toString());
|
|
311
|
+
const sshConfigFile = import_path2.default.resolve(import_os.default.homedir(), ".ssh/config");
|
|
355
312
|
console2.log("SSH Config file:", sshConfigFile);
|
|
356
|
-
const sshConfigs = import_ssh_config.default.parse(
|
|
313
|
+
const sshConfigs = import_ssh_config.default.parse(import_fs4.default.readFileSync(sshConfigFile).toString());
|
|
357
314
|
let sshConfig = sshConfigs.compute(releaseConfig.ftpConfig.host);
|
|
358
315
|
if (!sshConfig) {
|
|
359
316
|
import_consola2.default.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
|
|
@@ -363,7 +320,7 @@ function ftpUpload() {
|
|
|
363
320
|
import_inquirer3.default.prompt([{ type: "password", name: "password", mask: "*", message: "Enter key pair password" }]).then(async (answer) => {
|
|
364
321
|
let ftpClient = new import_ssh2_sftp_client.default();
|
|
365
322
|
const port = sshConfig["Port"];
|
|
366
|
-
const key =
|
|
323
|
+
const key = import_fs4.default.readFileSync(import_path2.default.resolve(import_os.default.homedir(), ".ssh/id_rsa"));
|
|
367
324
|
const spinner = (0, import_ora.default)("Connecting");
|
|
368
325
|
try {
|
|
369
326
|
spinner.start();
|
|
@@ -376,12 +333,12 @@ function ftpUpload() {
|
|
|
376
333
|
});
|
|
377
334
|
for (let item of releaseConfig.fileMap) {
|
|
378
335
|
if (typeof item.src == "string") {
|
|
379
|
-
const localFile =
|
|
380
|
-
if (!
|
|
336
|
+
const localFile = import_path2.default.resolve(process2.cwd(), item.src);
|
|
337
|
+
if (!import_fs4.default.existsSync(localFile)) {
|
|
381
338
|
spinner.warn(`Skip not exists file:${localFile}`);
|
|
382
339
|
continue;
|
|
383
340
|
}
|
|
384
|
-
if (
|
|
341
|
+
if (import_fs4.default.lstatSync(localFile).isDirectory()) {
|
|
385
342
|
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
386
343
|
await ftpClient.uploadDir(localFile, item.dest);
|
|
387
344
|
} else {
|
|
@@ -401,7 +358,55 @@ function ftpUpload() {
|
|
|
401
358
|
});
|
|
402
359
|
}
|
|
403
360
|
|
|
361
|
+
// src/release/release.ts
|
|
362
|
+
var release = async (options) => {
|
|
363
|
+
console.log();
|
|
364
|
+
if (options.type == "ftp") {
|
|
365
|
+
await ftpUpload();
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const packageJSON = JSON.parse(import_fs5.default.readFileSync("package.json", "utf-8"));
|
|
369
|
+
const changelogJSON = JSON.parse(import_fs5.default.readFileSync("changelog.json", "utf-8"));
|
|
370
|
+
const version = packageJSON["version"];
|
|
371
|
+
const changelog = changelogJSON[version];
|
|
372
|
+
let needUpdateElectron = await promptChecker_default({
|
|
373
|
+
type: "confirm",
|
|
374
|
+
name: "electron",
|
|
375
|
+
message: import_chalk3.default.blue("\u7528\u6237\u662F\u5426\u9700\u8981\u66F4\u65B0Electron?")
|
|
376
|
+
});
|
|
377
|
+
const versionInfo = {
|
|
378
|
+
version,
|
|
379
|
+
releaseNote: changelog,
|
|
380
|
+
updateElectron: needUpdateElectron,
|
|
381
|
+
updateNodeModule: false,
|
|
382
|
+
updateWindowsApi: false,
|
|
383
|
+
downloadLink: ""
|
|
384
|
+
};
|
|
385
|
+
let installerPath = import_path3.default.join(`./packaged/widgets-${version}-setup-win-x64.exe`);
|
|
386
|
+
if (!import_fs5.default.existsSync(installerPath)) {
|
|
387
|
+
installerPath = import_path3.default.join(`./packaged/electron-${version}-setup-win-x64.exe`);
|
|
388
|
+
}
|
|
389
|
+
const updateZipPath = import_path3.default.join(`./packaged/update.zip`);
|
|
390
|
+
console.log(import_chalk3.default.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
391
|
+
await update_zip_default("./release", updateZipPath);
|
|
392
|
+
console.log(import_chalk3.default.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
393
|
+
await put("version/installer.exe", installerPath);
|
|
394
|
+
console.log(import_chalk3.default.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
395
|
+
await put("version/update.zip", updateZipPath);
|
|
396
|
+
console.log(import_chalk3.default.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
397
|
+
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
398
|
+
const versionJSON = JSON.stringify(versionInfo, null, 2);
|
|
399
|
+
await put("version/version.json", Buffer.from(versionJSON));
|
|
400
|
+
copy(`version/history/${version}.exe`, "version/installer.exe");
|
|
401
|
+
copy(`version/history/update-${version}.zip`, "version/update.zip");
|
|
402
|
+
console.log(import_chalk3.default.yellow(versionJSON));
|
|
403
|
+
};
|
|
404
|
+
var release_default = release;
|
|
405
|
+
|
|
404
406
|
// src/index.ts
|
|
407
|
+
var import_url2 = require("url");
|
|
408
|
+
var import_figlet = __toESM(require("figlet"), 1);
|
|
409
|
+
var import_gradient_string = __toESM(require("gradient-string"), 1);
|
|
405
410
|
var import_meta2 = {};
|
|
406
411
|
var __filename = (0, import_url2.fileURLToPath)(import_meta2.url);
|
|
407
412
|
var __dirname = import_path4.default.dirname(__filename);
|
|
@@ -412,10 +417,9 @@ import_commander.program.version(`@widget-js/cli ${cliPackage.version}`).usage("
|
|
|
412
417
|
import_commander.program.command("create").description("\u521B\u5EFA\u65B0\u7684\u7EC4\u4EF6").action(async () => {
|
|
413
418
|
await createWidget();
|
|
414
419
|
});
|
|
415
|
-
import_commander.
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
await ftpUpload();
|
|
420
|
+
var typeOption = new import_commander.Option("-t, --type <type>").choices(["ftp", "oss"]);
|
|
421
|
+
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) => {
|
|
422
|
+
console.log(options);
|
|
423
|
+
await release_default(options);
|
|
420
424
|
});
|
|
421
425
|
import_commander.program.parse(process3.argv);
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { program } from "commander";
|
|
2
|
+
import { Option, program } from "commander";
|
|
3
3
|
import fs6 from "fs";
|
|
4
4
|
import path4 from "path";
|
|
5
5
|
import * as process3 from "process";
|
|
@@ -217,8 +217,8 @@ async function createWidget() {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
// src/release/release.ts
|
|
220
|
-
import
|
|
221
|
-
import
|
|
220
|
+
import fs5 from "fs";
|
|
221
|
+
import path3 from "path";
|
|
222
222
|
|
|
223
223
|
// src/release/update-zip.ts
|
|
224
224
|
import fs2 from "fs";
|
|
@@ -272,54 +272,11 @@ async function copy(dist, src) {
|
|
|
272
272
|
|
|
273
273
|
// src/release/release.ts
|
|
274
274
|
import chalk3 from "chalk";
|
|
275
|
-
var release = async () => {
|
|
276
|
-
const packageJSON = JSON.parse(fs4.readFileSync("package.json", "utf-8"));
|
|
277
|
-
const changelogJSON = JSON.parse(fs4.readFileSync("changelog.json", "utf-8"));
|
|
278
|
-
const version = packageJSON["version"];
|
|
279
|
-
const changelog = changelogJSON[version];
|
|
280
|
-
let needUpdateElectron = await promptChecker_default({
|
|
281
|
-
type: "confirm",
|
|
282
|
-
name: "electron",
|
|
283
|
-
message: chalk3.blue("\u7528\u6237\u662F\u5426\u9700\u8981\u66F4\u65B0Electron?")
|
|
284
|
-
});
|
|
285
|
-
const versionInfo = {
|
|
286
|
-
version,
|
|
287
|
-
releaseNote: changelog,
|
|
288
|
-
updateElectron: needUpdateElectron,
|
|
289
|
-
updateNodeModule: false,
|
|
290
|
-
updateWindowsApi: false,
|
|
291
|
-
downloadLink: ""
|
|
292
|
-
};
|
|
293
|
-
let installerPath = path2.join(`./packaged/widgets-${version}-setup-win-x64.exe`);
|
|
294
|
-
if (!fs4.existsSync(installerPath)) {
|
|
295
|
-
installerPath = path2.join(`./packaged/electron-${version}-setup-win-x64.exe`);
|
|
296
|
-
}
|
|
297
|
-
const updateZipPath = path2.join(`./packaged/update.zip`);
|
|
298
|
-
console.log(chalk3.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
299
|
-
await update_zip_default("./release", updateZipPath);
|
|
300
|
-
console.log(chalk3.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
301
|
-
await put("version/installer.exe", installerPath);
|
|
302
|
-
console.log(chalk3.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
303
|
-
await put("version/update.zip", updateZipPath);
|
|
304
|
-
console.log(chalk3.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
305
|
-
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
306
|
-
const versionJSON = JSON.stringify(versionInfo, null, 2);
|
|
307
|
-
await put("version/version.json", Buffer.from(versionJSON));
|
|
308
|
-
copy(`version/history/${version}.exe`, "version/installer.exe");
|
|
309
|
-
copy(`version/history/update-${version}.zip`, "version/update.zip");
|
|
310
|
-
console.log(chalk3.yellow(versionJSON));
|
|
311
|
-
};
|
|
312
|
-
var release_default = release;
|
|
313
|
-
|
|
314
|
-
// src/index.ts
|
|
315
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
316
|
-
import figlet from "figlet";
|
|
317
|
-
import gradient from "gradient-string";
|
|
318
275
|
|
|
319
|
-
// src/ftp/ftp.ts
|
|
320
|
-
import
|
|
321
|
-
import
|
|
322
|
-
import SSHConfig from "ssh-config";
|
|
276
|
+
// src/release/ftp/ftp.ts
|
|
277
|
+
import path2 from "path";
|
|
278
|
+
import fs4 from "fs";
|
|
279
|
+
import SSHConfig from "@widget-js/ssh-config";
|
|
323
280
|
import os from "os";
|
|
324
281
|
import Client from "ssh2-sftp-client";
|
|
325
282
|
import consola2 from "consola";
|
|
@@ -328,11 +285,11 @@ import ora from "ora";
|
|
|
328
285
|
import * as process2 from "process";
|
|
329
286
|
import * as console2 from "console";
|
|
330
287
|
function ftpUpload() {
|
|
331
|
-
const file =
|
|
332
|
-
const releaseConfig = JSON.parse(
|
|
333
|
-
const sshConfigFile =
|
|
288
|
+
const file = path2.join(process2.cwd(), "release.json");
|
|
289
|
+
const releaseConfig = JSON.parse(fs4.readFileSync(file).toString());
|
|
290
|
+
const sshConfigFile = path2.resolve(os.homedir(), ".ssh/config");
|
|
334
291
|
console2.log("SSH Config file:", sshConfigFile);
|
|
335
|
-
const sshConfigs = SSHConfig.parse(
|
|
292
|
+
const sshConfigs = SSHConfig.parse(fs4.readFileSync(sshConfigFile).toString());
|
|
336
293
|
let sshConfig = sshConfigs.compute(releaseConfig.ftpConfig.host);
|
|
337
294
|
if (!sshConfig) {
|
|
338
295
|
consola2.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
|
|
@@ -342,7 +299,7 @@ function ftpUpload() {
|
|
|
342
299
|
inquirer3.prompt([{ type: "password", name: "password", mask: "*", message: "Enter key pair password" }]).then(async (answer) => {
|
|
343
300
|
let ftpClient = new Client();
|
|
344
301
|
const port = sshConfig["Port"];
|
|
345
|
-
const key =
|
|
302
|
+
const key = fs4.readFileSync(path2.resolve(os.homedir(), ".ssh/id_rsa"));
|
|
346
303
|
const spinner = ora("Connecting");
|
|
347
304
|
try {
|
|
348
305
|
spinner.start();
|
|
@@ -355,12 +312,12 @@ function ftpUpload() {
|
|
|
355
312
|
});
|
|
356
313
|
for (let item of releaseConfig.fileMap) {
|
|
357
314
|
if (typeof item.src == "string") {
|
|
358
|
-
const localFile =
|
|
359
|
-
if (!
|
|
315
|
+
const localFile = path2.resolve(process2.cwd(), item.src);
|
|
316
|
+
if (!fs4.existsSync(localFile)) {
|
|
360
317
|
spinner.warn(`Skip not exists file:${localFile}`);
|
|
361
318
|
continue;
|
|
362
319
|
}
|
|
363
|
-
if (
|
|
320
|
+
if (fs4.lstatSync(localFile).isDirectory()) {
|
|
364
321
|
spinner.info(`Uploading Dir: ${localFile} -> ${item.dest}`);
|
|
365
322
|
await ftpClient.uploadDir(localFile, item.dest);
|
|
366
323
|
} else {
|
|
@@ -380,7 +337,55 @@ function ftpUpload() {
|
|
|
380
337
|
});
|
|
381
338
|
}
|
|
382
339
|
|
|
340
|
+
// src/release/release.ts
|
|
341
|
+
var release = async (options) => {
|
|
342
|
+
console.log();
|
|
343
|
+
if (options.type == "ftp") {
|
|
344
|
+
await ftpUpload();
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const packageJSON = JSON.parse(fs5.readFileSync("package.json", "utf-8"));
|
|
348
|
+
const changelogJSON = JSON.parse(fs5.readFileSync("changelog.json", "utf-8"));
|
|
349
|
+
const version = packageJSON["version"];
|
|
350
|
+
const changelog = changelogJSON[version];
|
|
351
|
+
let needUpdateElectron = await promptChecker_default({
|
|
352
|
+
type: "confirm",
|
|
353
|
+
name: "electron",
|
|
354
|
+
message: chalk3.blue("\u7528\u6237\u662F\u5426\u9700\u8981\u66F4\u65B0Electron?")
|
|
355
|
+
});
|
|
356
|
+
const versionInfo = {
|
|
357
|
+
version,
|
|
358
|
+
releaseNote: changelog,
|
|
359
|
+
updateElectron: needUpdateElectron,
|
|
360
|
+
updateNodeModule: false,
|
|
361
|
+
updateWindowsApi: false,
|
|
362
|
+
downloadLink: ""
|
|
363
|
+
};
|
|
364
|
+
let installerPath = path3.join(`./packaged/widgets-${version}-setup-win-x64.exe`);
|
|
365
|
+
if (!fs5.existsSync(installerPath)) {
|
|
366
|
+
installerPath = path3.join(`./packaged/electron-${version}-setup-win-x64.exe`);
|
|
367
|
+
}
|
|
368
|
+
const updateZipPath = path3.join(`./packaged/update.zip`);
|
|
369
|
+
console.log(chalk3.blue("\u538B\u7F29\u66F4\u65B0\u6587\u4EF6\u4E2D"));
|
|
370
|
+
await update_zip_default("./release", updateZipPath);
|
|
371
|
+
console.log(chalk3.blue("\u4E0A\u4F20installer.exe\u5230OSS"));
|
|
372
|
+
await put("version/installer.exe", installerPath);
|
|
373
|
+
console.log(chalk3.blue("\u4E0A\u4F20update.zip\u5230OSS"));
|
|
374
|
+
await put("version/update.zip", updateZipPath);
|
|
375
|
+
console.log(chalk3.blue("\u66F4\u65B0\u7248\u672C\u4FE1\u606F"));
|
|
376
|
+
versionInfo.downloadLink = "https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip";
|
|
377
|
+
const versionJSON = JSON.stringify(versionInfo, null, 2);
|
|
378
|
+
await put("version/version.json", Buffer.from(versionJSON));
|
|
379
|
+
copy(`version/history/${version}.exe`, "version/installer.exe");
|
|
380
|
+
copy(`version/history/update-${version}.zip`, "version/update.zip");
|
|
381
|
+
console.log(chalk3.yellow(versionJSON));
|
|
382
|
+
};
|
|
383
|
+
var release_default = release;
|
|
384
|
+
|
|
383
385
|
// src/index.ts
|
|
386
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
387
|
+
import figlet from "figlet";
|
|
388
|
+
import gradient from "gradient-string";
|
|
384
389
|
var __filename = fileURLToPath2(import.meta.url);
|
|
385
390
|
var __dirname = path4.dirname(__filename);
|
|
386
391
|
var packageJsonPath = path4.join(__dirname, "../package.json");
|
|
@@ -390,10 +395,9 @@ program.version(`@widget-js/cli ${cliPackage.version}`).usage("<command> [option
|
|
|
390
395
|
program.command("create").description("\u521B\u5EFA\u65B0\u7684\u7EC4\u4EF6").action(async () => {
|
|
391
396
|
await createWidget();
|
|
392
397
|
});
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
await ftpUpload();
|
|
398
|
+
var typeOption = new Option("-t, --type <type>").choices(["ftp", "oss"]);
|
|
399
|
+
program.command("release").description("\u901A\u8FC7FTP/OSS\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").addOption(typeOption).action(async (options, command) => {
|
|
400
|
+
console.log(options);
|
|
401
|
+
await release_default(options);
|
|
398
402
|
});
|
|
399
403
|
program.parse(process3.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widget-js/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "Neo Fu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"@types/gradient-string": "^1.1.2",
|
|
27
27
|
"@vue/cli-shared-utils": "^5.0.8",
|
|
28
28
|
"@widget-js/core": "^0.1.14",
|
|
29
|
+
"@widget-js/ssh-config": "^4.2.1",
|
|
29
30
|
"ali-oss": "^6.17.1",
|
|
30
31
|
"archiver": "^5.3.1",
|
|
31
32
|
"chalk": "^5.2.0",
|
|
@@ -38,7 +39,6 @@
|
|
|
38
39
|
"inquirer": "^9.1.4",
|
|
39
40
|
"ora": "^6.2.0",
|
|
40
41
|
"shelljs": "^0.8.5",
|
|
41
|
-
"ssh-config": "file://D:\\workspace\\ssh-config",
|
|
42
42
|
"ssh2-sftp-client": "^9.0.4",
|
|
43
43
|
"ws": "^8.11.0"
|
|
44
44
|
},
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {program} from 'commander'
|
|
1
|
+
import {Option, program} from 'commander'
|
|
2
2
|
import fs from 'fs'
|
|
3
3
|
import path from 'path'
|
|
4
4
|
import * as process from 'process'
|
|
@@ -8,7 +8,7 @@ import release from './release/release'
|
|
|
8
8
|
import {fileURLToPath} from 'url'
|
|
9
9
|
import figlet from 'figlet'
|
|
10
10
|
import gradient from 'gradient-string'
|
|
11
|
-
import {ftpUpload} from './ftp/ftp'
|
|
11
|
+
import {ftpUpload} from './release/ftp/ftp'
|
|
12
12
|
|
|
13
13
|
const __filename = fileURLToPath(import.meta.url)
|
|
14
14
|
const __dirname = path.dirname(__filename)
|
|
@@ -24,17 +24,16 @@ program
|
|
|
24
24
|
.action(async () => {
|
|
25
25
|
await createWidget()
|
|
26
26
|
})
|
|
27
|
+
|
|
28
|
+
let typeOption = new Option('-t, --type <type>').choices(['ftp', 'oss'])
|
|
27
29
|
program
|
|
28
30
|
.command('release')
|
|
29
|
-
.description('通过OSS发布文件,仅内部使用')
|
|
30
|
-
.
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
.description('通过FTP发布文件,仅内部使用')
|
|
36
|
-
.action(async () => {
|
|
37
|
-
await ftpUpload()
|
|
31
|
+
.description('通过FTP/OSS发布文件,仅内部使用')
|
|
32
|
+
.addOption(typeOption)
|
|
33
|
+
.action(async (options, command) => {
|
|
34
|
+
// @ts-ignore
|
|
35
|
+
console.log(options)
|
|
36
|
+
await release(options)
|
|
38
37
|
})
|
|
39
38
|
|
|
40
39
|
//TODO init 初始化项目
|
package/src/release/release.ts
CHANGED
|
@@ -1,69 +1,75 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import path from
|
|
3
|
-
import promptChecker from
|
|
4
|
-
import zipDirectory from
|
|
5
|
-
import {copy, put} from
|
|
6
|
-
import chalk from
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import promptChecker from '../promts/promptChecker.js'
|
|
4
|
+
import zipDirectory from './update-zip.js'
|
|
5
|
+
import {copy, put} from './oss.js'
|
|
6
|
+
import chalk from 'chalk'
|
|
7
|
+
import {ftpUpload} from './ftp/ftp'
|
|
8
|
+
|
|
9
|
+
async function delay(time: number) {
|
|
10
|
+
return new Promise<void>((resolve, reject) => {
|
|
11
|
+
setTimeout(() => {
|
|
12
|
+
resolve()
|
|
13
|
+
}, time)
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const release = async (options: any) => {
|
|
18
|
+
console.log()
|
|
19
|
+
if (options.type == 'ftp') {
|
|
20
|
+
await ftpUpload()
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
|
|
24
|
+
const changelogJSON = JSON.parse(fs.readFileSync('changelog.json', 'utf-8'))
|
|
25
|
+
const version = packageJSON['version']
|
|
26
|
+
const changelog = changelogJSON[version]
|
|
27
|
+
|
|
28
|
+
let needUpdateElectron = await promptChecker({
|
|
29
|
+
type: 'confirm',
|
|
30
|
+
name: 'electron',
|
|
31
|
+
message: chalk.blue('用户是否需要更新Electron?'),
|
|
32
|
+
})
|
|
33
|
+
//
|
|
34
|
+
// let needUpdateNodeModule = await promptChecker({
|
|
35
|
+
// type: "confirm",
|
|
36
|
+
// name: 'electron',
|
|
37
|
+
// message: chalk.blue("用户是否需要更新node_module?")
|
|
38
|
+
// });
|
|
39
|
+
|
|
40
|
+
const versionInfo = {
|
|
41
|
+
version: version,
|
|
42
|
+
releaseNote: changelog,
|
|
43
|
+
updateElectron: needUpdateElectron,
|
|
44
|
+
updateNodeModule: false,
|
|
45
|
+
updateWindowsApi: false,
|
|
46
|
+
downloadLink: '',
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let installerPath = path.join(`./packaged/widgets-${version}-setup-win-x64.exe`)
|
|
50
|
+
if (!fs.existsSync(installerPath)) {
|
|
51
|
+
installerPath = path.join(`./packaged/electron-${version}-setup-win-x64.exe`)
|
|
52
|
+
}
|
|
53
|
+
const updateZipPath = path.join(`./packaged/update.zip`)
|
|
54
|
+
|
|
55
|
+
console.log(chalk.blue('压缩更新文件中'))
|
|
56
|
+
await zipDirectory('./release', updateZipPath)
|
|
57
|
+
|
|
58
|
+
console.log(chalk.blue('上传installer.exe到OSS'))
|
|
59
|
+
await put('version/installer.exe', installerPath)
|
|
60
|
+
|
|
61
|
+
console.log(chalk.blue('上传update.zip到OSS'))
|
|
62
|
+
await put('version/update.zip', updateZipPath)
|
|
63
|
+
|
|
64
|
+
console.log(chalk.blue('更新版本信息'))
|
|
65
|
+
versionInfo.downloadLink = 'https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip'
|
|
66
|
+
const versionJSON = JSON.stringify(versionInfo, null, 2)
|
|
67
|
+
await put('version/version.json', Buffer.from(versionJSON))
|
|
68
|
+
|
|
69
|
+
copy(`version/history/${version}.exe`, 'version/installer.exe')
|
|
70
|
+
copy(`version/history/update-${version}.zip`, 'version/update.zip')
|
|
71
|
+
|
|
72
|
+
console.log(chalk.yellow(versionJSON))
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default release
|