@widget-js/cli 1.0.10 → 1.0.11
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/codeStyleConfig.xml +5 -0
- package/.prettierrc +21 -0
- package/lib/index.cjs +81 -13
- package/lib/index.js +81 -13
- package/package.json +8 -2
- package/release.json +25 -0
- package/src/ftp/ftp.ts +85 -0
- package/src/index.ts +42 -45
package/.prettierrc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
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/lib/index.cjs
CHANGED
|
@@ -20,9 +20,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
20
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var import_commander = require("commander");
|
|
23
|
-
var
|
|
24
|
-
var
|
|
25
|
-
var
|
|
23
|
+
var import_fs6 = __toESM(require("fs"), 1);
|
|
24
|
+
var import_path4 = __toESM(require("path"), 1);
|
|
25
|
+
var process3 = __toESM(require("process"), 1);
|
|
26
26
|
|
|
27
27
|
// src/createWidget.ts
|
|
28
28
|
var import_path = __toESM(require("path"), 1);
|
|
@@ -336,21 +336,89 @@ var release_default = release;
|
|
|
336
336
|
var import_url2 = require("url");
|
|
337
337
|
var import_figlet = __toESM(require("figlet"), 1);
|
|
338
338
|
var import_gradient_string = __toESM(require("gradient-string"), 1);
|
|
339
|
+
|
|
340
|
+
// src/ftp/ftp.ts
|
|
341
|
+
var import_path3 = __toESM(require("path"), 1);
|
|
342
|
+
var import_fs5 = __toESM(require("fs"), 1);
|
|
343
|
+
var import_ssh_config = __toESM(require("ssh-config"), 1);
|
|
344
|
+
var import_os = __toESM(require("os"), 1);
|
|
345
|
+
var import_ssh2_sftp_client = __toESM(require("ssh2-sftp-client"), 1);
|
|
346
|
+
var import_consola2 = __toESM(require("consola"), 1);
|
|
347
|
+
var import_inquirer3 = __toESM(require("inquirer"), 1);
|
|
348
|
+
var import_nanospinner = require("nanospinner");
|
|
349
|
+
var process2 = __toESM(require("process"), 1);
|
|
350
|
+
var console2 = __toESM(require("console"), 1);
|
|
351
|
+
function ftpUpload() {
|
|
352
|
+
const file = import_path3.default.join(process2.cwd(), "release.json");
|
|
353
|
+
const releaseConfig = JSON.parse(import_fs5.default.readFileSync(file).toString());
|
|
354
|
+
const sshConfigFile = import_path3.default.resolve(import_os.default.homedir(), ".ssh/config");
|
|
355
|
+
console2.log("SSH Config file:", sshConfigFile);
|
|
356
|
+
const sshConfigs = import_ssh_config.default.parse(import_fs5.default.readFileSync(sshConfigFile).toString());
|
|
357
|
+
let sshConfig = sshConfigs.compute(releaseConfig.ftpConfig.host);
|
|
358
|
+
if (!sshConfig) {
|
|
359
|
+
import_consola2.default.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
import_consola2.default.info(sshConfig);
|
|
363
|
+
import_inquirer3.default.prompt([{ type: "password", name: "password", mask: "*", message: "Enter key pair password" }]).then(async (answer) => {
|
|
364
|
+
let ftpClient = new import_ssh2_sftp_client.default();
|
|
365
|
+
const port = sshConfig["Port"];
|
|
366
|
+
const key = import_fs5.default.readFileSync(import_path3.default.resolve(import_os.default.homedir(), ".ssh/id_rsa"));
|
|
367
|
+
const spinner = (0, import_nanospinner.createSpinner)("Connecting");
|
|
368
|
+
try {
|
|
369
|
+
spinner.start();
|
|
370
|
+
await ftpClient.connect({
|
|
371
|
+
host: sshConfig["HostName"],
|
|
372
|
+
port: port ? parseInt(port) : 22,
|
|
373
|
+
username: sshConfig["User"],
|
|
374
|
+
passphrase: answer.password,
|
|
375
|
+
privateKey: key
|
|
376
|
+
});
|
|
377
|
+
ftpClient.on("upload", (info) => {
|
|
378
|
+
spinner.update({ text: `Uploading: ${info.source}` });
|
|
379
|
+
});
|
|
380
|
+
for (let item of releaseConfig.fileMap) {
|
|
381
|
+
if (typeof item.src == "string") {
|
|
382
|
+
const localFile = import_path3.default.resolve(process2.cwd(), item.src);
|
|
383
|
+
if (!import_fs5.default.existsSync(localFile)) {
|
|
384
|
+
spinner.warn({ text: `Skip not exists file:${localFile}` });
|
|
385
|
+
continue;
|
|
386
|
+
}
|
|
387
|
+
if (import_fs5.default.lstatSync(localFile).isDirectory()) {
|
|
388
|
+
spinner.update({ text: `Uploading Dir: ${localFile} -> ${item.dest}` });
|
|
389
|
+
await ftpClient.uploadDir(localFile, item.dest);
|
|
390
|
+
} else {
|
|
391
|
+
spinner.update({ text: `Uploading File: ${localFile} -> ${item.dest}` });
|
|
392
|
+
await ftpClient.put(localFile, item.dest);
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
await ftpClient.put(Buffer.from(JSON.stringify(item.src), "utf-8"), item.dest);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
spinner.success({ text: "Files uploaded!" });
|
|
399
|
+
await ftpClient.end();
|
|
400
|
+
} catch (e) {
|
|
401
|
+
spinner.error({ text: `Connection error:${e}` });
|
|
402
|
+
await ftpClient.end();
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// src/index.ts
|
|
339
408
|
var import_meta2 = {};
|
|
340
409
|
var __filename = (0, import_url2.fileURLToPath)(import_meta2.url);
|
|
341
|
-
var __dirname =
|
|
342
|
-
var packageJsonPath =
|
|
343
|
-
var cliPackage = JSON.parse(
|
|
344
|
-
console.log(
|
|
345
|
-
import_gradient_string.default.pastel.multiline(
|
|
346
|
-
import_figlet.default.textSync("widget-cli", { horizontalLayout: "full" })
|
|
347
|
-
)
|
|
348
|
-
);
|
|
410
|
+
var __dirname = import_path4.default.dirname(__filename);
|
|
411
|
+
var packageJsonPath = import_path4.default.join(__dirname, "../package.json");
|
|
412
|
+
var cliPackage = JSON.parse(import_fs6.default.readFileSync(packageJsonPath).toString());
|
|
413
|
+
console.log(import_gradient_string.default.pastel.multiline(import_figlet.default.textSync("widget-cli", { horizontalLayout: "full" })));
|
|
349
414
|
import_commander.program.version(`@widget-js/cli ${cliPackage.version}`).usage("<command> [options]");
|
|
350
415
|
import_commander.program.command("create").description("\u521B\u5EFA\u65B0\u7684\u7EC4\u4EF6").action(async () => {
|
|
351
416
|
await createWidget();
|
|
352
417
|
});
|
|
353
|
-
import_commander.program.command("release").description("\u53D1\u5E03\
|
|
418
|
+
import_commander.program.command("release").description("\u901A\u8FC7OSS\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").action(async () => {
|
|
354
419
|
await release_default();
|
|
355
420
|
});
|
|
356
|
-
import_commander.program.
|
|
421
|
+
import_commander.program.command("ftp").description("\u901A\u8FC7FTP\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").action(async () => {
|
|
422
|
+
await ftpUpload();
|
|
423
|
+
});
|
|
424
|
+
import_commander.program.parse(process3.argv);
|
package/lib/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { program } from "commander";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import * as
|
|
3
|
+
import fs6 from "fs";
|
|
4
|
+
import path4 from "path";
|
|
5
|
+
import * as process3 from "process";
|
|
6
6
|
|
|
7
7
|
// src/createWidget.ts
|
|
8
8
|
import path from "path";
|
|
@@ -315,20 +315,88 @@ var release_default = release;
|
|
|
315
315
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
316
316
|
import figlet from "figlet";
|
|
317
317
|
import gradient from "gradient-string";
|
|
318
|
+
|
|
319
|
+
// src/ftp/ftp.ts
|
|
320
|
+
import path3 from "path";
|
|
321
|
+
import fs5 from "fs";
|
|
322
|
+
import SSHConfig from "ssh-config";
|
|
323
|
+
import os from "os";
|
|
324
|
+
import Client from "ssh2-sftp-client";
|
|
325
|
+
import consola2 from "consola";
|
|
326
|
+
import inquirer3 from "inquirer";
|
|
327
|
+
import { createSpinner } from "nanospinner";
|
|
328
|
+
import * as process2 from "process";
|
|
329
|
+
import * as console2 from "console";
|
|
330
|
+
function ftpUpload() {
|
|
331
|
+
const file = path3.join(process2.cwd(), "release.json");
|
|
332
|
+
const releaseConfig = JSON.parse(fs5.readFileSync(file).toString());
|
|
333
|
+
const sshConfigFile = path3.resolve(os.homedir(), ".ssh/config");
|
|
334
|
+
console2.log("SSH Config file:", sshConfigFile);
|
|
335
|
+
const sshConfigs = SSHConfig.parse(fs5.readFileSync(sshConfigFile).toString());
|
|
336
|
+
let sshConfig = sshConfigs.compute(releaseConfig.ftpConfig.host);
|
|
337
|
+
if (!sshConfig) {
|
|
338
|
+
consola2.error(`SSH config ${releaseConfig.ftpConfig.host} not found`);
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
consola2.info(sshConfig);
|
|
342
|
+
inquirer3.prompt([{ type: "password", name: "password", mask: "*", message: "Enter key pair password" }]).then(async (answer) => {
|
|
343
|
+
let ftpClient = new Client();
|
|
344
|
+
const port = sshConfig["Port"];
|
|
345
|
+
const key = fs5.readFileSync(path3.resolve(os.homedir(), ".ssh/id_rsa"));
|
|
346
|
+
const spinner = createSpinner("Connecting");
|
|
347
|
+
try {
|
|
348
|
+
spinner.start();
|
|
349
|
+
await ftpClient.connect({
|
|
350
|
+
host: sshConfig["HostName"],
|
|
351
|
+
port: port ? parseInt(port) : 22,
|
|
352
|
+
username: sshConfig["User"],
|
|
353
|
+
passphrase: answer.password,
|
|
354
|
+
privateKey: key
|
|
355
|
+
});
|
|
356
|
+
ftpClient.on("upload", (info) => {
|
|
357
|
+
spinner.update({ text: `Uploading: ${info.source}` });
|
|
358
|
+
});
|
|
359
|
+
for (let item of releaseConfig.fileMap) {
|
|
360
|
+
if (typeof item.src == "string") {
|
|
361
|
+
const localFile = path3.resolve(process2.cwd(), item.src);
|
|
362
|
+
if (!fs5.existsSync(localFile)) {
|
|
363
|
+
spinner.warn({ text: `Skip not exists file:${localFile}` });
|
|
364
|
+
continue;
|
|
365
|
+
}
|
|
366
|
+
if (fs5.lstatSync(localFile).isDirectory()) {
|
|
367
|
+
spinner.update({ text: `Uploading Dir: ${localFile} -> ${item.dest}` });
|
|
368
|
+
await ftpClient.uploadDir(localFile, item.dest);
|
|
369
|
+
} else {
|
|
370
|
+
spinner.update({ text: `Uploading File: ${localFile} -> ${item.dest}` });
|
|
371
|
+
await ftpClient.put(localFile, item.dest);
|
|
372
|
+
}
|
|
373
|
+
} else {
|
|
374
|
+
await ftpClient.put(Buffer.from(JSON.stringify(item.src), "utf-8"), item.dest);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
spinner.success({ text: "Files uploaded!" });
|
|
378
|
+
await ftpClient.end();
|
|
379
|
+
} catch (e) {
|
|
380
|
+
spinner.error({ text: `Connection error:${e}` });
|
|
381
|
+
await ftpClient.end();
|
|
382
|
+
}
|
|
383
|
+
});
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
// src/index.ts
|
|
318
387
|
var __filename = fileURLToPath2(import.meta.url);
|
|
319
|
-
var __dirname =
|
|
320
|
-
var packageJsonPath =
|
|
321
|
-
var cliPackage = JSON.parse(
|
|
322
|
-
console.log(
|
|
323
|
-
gradient.pastel.multiline(
|
|
324
|
-
figlet.textSync("widget-cli", { horizontalLayout: "full" })
|
|
325
|
-
)
|
|
326
|
-
);
|
|
388
|
+
var __dirname = path4.dirname(__filename);
|
|
389
|
+
var packageJsonPath = path4.join(__dirname, "../package.json");
|
|
390
|
+
var cliPackage = JSON.parse(fs6.readFileSync(packageJsonPath).toString());
|
|
391
|
+
console.log(gradient.pastel.multiline(figlet.textSync("widget-cli", { horizontalLayout: "full" })));
|
|
327
392
|
program.version(`@widget-js/cli ${cliPackage.version}`).usage("<command> [options]");
|
|
328
393
|
program.command("create").description("\u521B\u5EFA\u65B0\u7684\u7EC4\u4EF6").action(async () => {
|
|
329
394
|
await createWidget();
|
|
330
395
|
});
|
|
331
|
-
program.command("release").description("\u53D1\u5E03\
|
|
396
|
+
program.command("release").description("\u901A\u8FC7OSS\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").action(async () => {
|
|
332
397
|
await release_default();
|
|
333
398
|
});
|
|
334
|
-
program.
|
|
399
|
+
program.command("ftp").description("\u901A\u8FC7FTP\u53D1\u5E03\u6587\u4EF6\uFF0C\u4EC5\u5185\u90E8\u4F7F\u7528").action(async () => {
|
|
400
|
+
await ftpUpload();
|
|
401
|
+
});
|
|
402
|
+
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.11",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "Neo Fu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"scripts": {
|
|
13
|
-
"build": "tsup src/index.ts --dts --format esm,cjs
|
|
13
|
+
"build": "tsup src/index.ts --dts --format esm,cjs",
|
|
14
|
+
"watch": "tsup src/index.ts --dts --format esm,cjs --watch",
|
|
14
15
|
"build:run": "npm run build && npm run widget",
|
|
15
16
|
"widget": "node ./lib/index.js"
|
|
16
17
|
},
|
|
@@ -35,7 +36,10 @@
|
|
|
35
36
|
"figlet": "^1.5.2",
|
|
36
37
|
"gradient-string": "^2.0.2",
|
|
37
38
|
"inquirer": "^9.1.4",
|
|
39
|
+
"nanospinner": "^1.1.0",
|
|
38
40
|
"shelljs": "^0.8.5",
|
|
41
|
+
"ssh-config": "file://D:\\workspace\\ssh-config",
|
|
42
|
+
"ssh2-sftp-client": "^9.0.4",
|
|
39
43
|
"ws": "^8.11.0"
|
|
40
44
|
},
|
|
41
45
|
"devDependencies": {
|
|
@@ -50,7 +54,9 @@
|
|
|
50
54
|
"@types/jest": "^29.2.3",
|
|
51
55
|
"@types/node": "^18.11.13",
|
|
52
56
|
"@types/shelljs": "latest",
|
|
57
|
+
"@types/ssh2-sftp-client": "^9.0.0",
|
|
53
58
|
"pinst": "^3.0.0",
|
|
59
|
+
"prettier": "^2.8.4",
|
|
54
60
|
"ts-jest": "^29.0.3",
|
|
55
61
|
"ts-loader": "^9.4.1",
|
|
56
62
|
"ts-node": "^10.9.1",
|
package/release.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"fileMap": [
|
|
3
|
+
{
|
|
4
|
+
"src": "./template",
|
|
5
|
+
"dest": "/www/wwwroot/template/"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"src": {
|
|
9
|
+
"version": "0.1.0",
|
|
10
|
+
"createdAt": "",
|
|
11
|
+
"releaseNote": "1.增加版本更新",
|
|
12
|
+
"downloadLink": "https://download.tool-vip.com/youlu/update.zip",
|
|
13
|
+
"updateElectron": false
|
|
14
|
+
},
|
|
15
|
+
"dest": "/www/wwwroot/template/version.json"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"src": ".gitignore",
|
|
19
|
+
"dest": "/www/wwwroot/template/.gitignore"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"ftpConfig": {
|
|
23
|
+
"host": "youlu"
|
|
24
|
+
}
|
|
25
|
+
}
|
package/src/ftp/ftp.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import SSHConfig from 'ssh-config'
|
|
4
|
+
import os from 'os'
|
|
5
|
+
import Client from 'ssh2-sftp-client'
|
|
6
|
+
import consola from 'consola'
|
|
7
|
+
import inquirer from 'inquirer'
|
|
8
|
+
import {createSpinner} from 'nanospinner'
|
|
9
|
+
import * as process from 'process'
|
|
10
|
+
import * as console from 'console'
|
|
11
|
+
|
|
12
|
+
interface PasswordAnswer {
|
|
13
|
+
password: string
|
|
14
|
+
}
|
|
15
|
+
export function ftpUpload() {
|
|
16
|
+
// 读取
|
|
17
|
+
const file = path.join(process.cwd(), 'release.json')
|
|
18
|
+
const releaseConfig = JSON.parse(fs.readFileSync(file).toString()) as ReleaseConfig
|
|
19
|
+
const sshConfigFile = path.resolve(os.homedir(), '.ssh/config')
|
|
20
|
+
console.log('SSH Config file:', sshConfigFile)
|
|
21
|
+
const sshConfigs = SSHConfig.parse(fs.readFileSync(sshConfigFile).toString())
|
|
22
|
+
let sshConfig = sshConfigs.compute(releaseConfig.ftpConfig.host)
|
|
23
|
+
if (!sshConfig) {
|
|
24
|
+
consola.error(`SSH config ${releaseConfig.ftpConfig.host} not found`)
|
|
25
|
+
return
|
|
26
|
+
}
|
|
27
|
+
consola.info(sshConfig)
|
|
28
|
+
inquirer
|
|
29
|
+
.prompt<PasswordAnswer>([{type: 'password', name: 'password', mask: '*', message: 'Enter key pair password'}])
|
|
30
|
+
.then(async (answer: PasswordAnswer) => {
|
|
31
|
+
let ftpClient = new Client()
|
|
32
|
+
const port = sshConfig['Port']
|
|
33
|
+
const key = fs.readFileSync(path.resolve(os.homedir(), '.ssh/id_rsa'))
|
|
34
|
+
const spinner = createSpinner('Connecting')
|
|
35
|
+
try {
|
|
36
|
+
spinner.start()
|
|
37
|
+
await ftpClient.connect({
|
|
38
|
+
host: sshConfig['HostName'] as string,
|
|
39
|
+
port: port ? parseInt(port as string) : 22,
|
|
40
|
+
username: sshConfig['User'] as string,
|
|
41
|
+
passphrase: answer.password,
|
|
42
|
+
privateKey: key,
|
|
43
|
+
})
|
|
44
|
+
ftpClient.on('upload', info => {
|
|
45
|
+
spinner.update({text: `Uploading: ${info.source}`})
|
|
46
|
+
})
|
|
47
|
+
// upload files
|
|
48
|
+
for (let item of releaseConfig.fileMap) {
|
|
49
|
+
if (typeof item.src == 'string') {
|
|
50
|
+
const localFile = path.resolve(process.cwd(), item.src as string)
|
|
51
|
+
if (!fs.existsSync(localFile)) {
|
|
52
|
+
spinner.warn({text: `Skip not exists file:${localFile}`})
|
|
53
|
+
continue
|
|
54
|
+
}
|
|
55
|
+
if (fs.lstatSync(localFile).isDirectory()) {
|
|
56
|
+
spinner.update({text: `Uploading Dir: ${localFile} -> ${item.dest}`})
|
|
57
|
+
await ftpClient.uploadDir(localFile, item.dest)
|
|
58
|
+
} else {
|
|
59
|
+
spinner.update({text: `Uploading File: ${localFile} -> ${item.dest}`})
|
|
60
|
+
await ftpClient.put(localFile, item.dest)
|
|
61
|
+
}
|
|
62
|
+
} else {
|
|
63
|
+
await ftpClient.put(Buffer.from(JSON.stringify(item.src), 'utf-8'), item.dest)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
spinner.success({text: 'Files uploaded!'})
|
|
67
|
+
await ftpClient.end()
|
|
68
|
+
} catch (e) {
|
|
69
|
+
spinner.error({text: `Connection error:${e}`})
|
|
70
|
+
await ftpClient.end()
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface ReleaseConfig {
|
|
76
|
+
fileMap: {
|
|
77
|
+
src: string | object
|
|
78
|
+
dest: string
|
|
79
|
+
}[]
|
|
80
|
+
ftpConfig: FTPConfig
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface FTPConfig {
|
|
84
|
+
host: string
|
|
85
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,45 +1,42 @@
|
|
|
1
|
-
import {program} from 'commander'
|
|
2
|
-
import fs from
|
|
3
|
-
import path from
|
|
4
|
-
import * as process from
|
|
5
|
-
import createWidget from
|
|
6
|
-
import release from './release/release'
|
|
7
|
-
|
|
8
|
-
import {fileURLToPath} from 'url'
|
|
9
|
-
import figlet from 'figlet'
|
|
10
|
-
import gradient from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
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
|
-
//TODO
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1
|
+
import {program} from 'commander'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import * as process from 'process'
|
|
5
|
+
import createWidget from './createWidget'
|
|
6
|
+
import release from './release/release'
|
|
7
|
+
|
|
8
|
+
import {fileURLToPath} from 'url'
|
|
9
|
+
import figlet from 'figlet'
|
|
10
|
+
import gradient from 'gradient-string'
|
|
11
|
+
import {ftpUpload} from './ftp/ftp'
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
14
|
+
const __dirname = path.dirname(__filename)
|
|
15
|
+
//
|
|
16
|
+
const packageJsonPath = path.join(__dirname, '../package.json')
|
|
17
|
+
let cliPackage = JSON.parse(fs.readFileSync(packageJsonPath).toString())
|
|
18
|
+
|
|
19
|
+
console.log(gradient.pastel.multiline(figlet.textSync('widget-cli', {horizontalLayout: 'full'})))
|
|
20
|
+
program.version(`@widget-js/cli ${cliPackage.version}`).usage('<command> [options]')
|
|
21
|
+
program
|
|
22
|
+
.command('create')
|
|
23
|
+
.description('创建新的组件')
|
|
24
|
+
.action(async () => {
|
|
25
|
+
await createWidget()
|
|
26
|
+
})
|
|
27
|
+
program
|
|
28
|
+
.command('release')
|
|
29
|
+
.description('通过OSS发布文件,仅内部使用')
|
|
30
|
+
.action(async () => {
|
|
31
|
+
await release()
|
|
32
|
+
})
|
|
33
|
+
program
|
|
34
|
+
.command('ftp')
|
|
35
|
+
.description('通过FTP发布文件,仅内部使用')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
await ftpUpload()
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
//TODO init 初始化项目
|
|
41
|
+
//TODO publish 发布
|
|
42
|
+
program.parse(process.argv)
|