@widget-js/cli 1.2.8 → 1.2.9
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/{chunk-YHUBPHJK.js → chunk-PCGVPLNI.js} +5 -5
- package/lib/{createWidget-SD5E5C5P.js → createWidget-MZL6DPP2.js} +5 -5
- package/lib/index.js +2 -2
- package/lib/{init-AO2J5DEO.js → init-FUMP334Y.js} +4 -4
- package/package.json +4 -5
- package/src/createWidget.ts +4 -4
- package/src/init/init.ts +3 -3
- package/src/utils/EJSUtils.ts +2 -2
- package/src/utils/PrettierUtils.ts +3 -3
- package/vite.config.ts +1 -2
- package/widget.package.ts +0 -20
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/utils/PrettierUtils.ts
|
|
2
|
-
import
|
|
2
|
+
import { format } from "prettier";
|
|
3
3
|
var PrettierUtils = class {
|
|
4
|
-
static format(code, parser) {
|
|
5
|
-
return
|
|
4
|
+
static async format(code, parser) {
|
|
5
|
+
return format(code, {
|
|
6
6
|
parser,
|
|
7
7
|
tabWidth: 2,
|
|
8
8
|
singleQuote: true
|
|
@@ -16,11 +16,11 @@ import fs from "fs";
|
|
|
16
16
|
import ejs from "ejs";
|
|
17
17
|
import { dirname } from "dirname-filename-esm";
|
|
18
18
|
var EJSUtils = class {
|
|
19
|
-
static renderToFile(templateFile, outputFile, parser, renderOptions) {
|
|
19
|
+
static async renderToFile(templateFile, outputFile, parser, renderOptions) {
|
|
20
20
|
const defineTemplatePath = path.join(dirname(import.meta), "../template", templateFile);
|
|
21
21
|
let defineTemplate = fs.readFileSync(defineTemplatePath, "utf8");
|
|
22
22
|
let code = ejs.render(defineTemplate, renderOptions);
|
|
23
|
-
const formattedEJSCode = PrettierUtils.format(code, parser);
|
|
23
|
+
const formattedEJSCode = await PrettierUtils.format(code, parser);
|
|
24
24
|
fs.writeFileSync(outputFile, formattedEJSCode);
|
|
25
25
|
}
|
|
26
26
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EJSUtils
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PCGVPLNI.js";
|
|
4
4
|
import {
|
|
5
5
|
promptChecker_default
|
|
6
6
|
} from "./chunk-3GPAHQ6O.js";
|
|
@@ -164,12 +164,12 @@ async function createWidget() {
|
|
|
164
164
|
const widgetFile = path.resolve(widgetDir, `${name}Widget.vue`);
|
|
165
165
|
const widgetViewFile = path.resolve(widgetDir, `${name}WidgetView.vue`);
|
|
166
166
|
const widgetRoutesFile = path.resolve(widgetDir, `${name}WidgetRoutes.ts`);
|
|
167
|
-
EJSUtils.renderToFile("WidgetDefine.ejs", widgetDefineFile, "typescript", renderOptions);
|
|
168
|
-
EJSUtils.renderToFile("WidgetView.ejs", widgetViewFile, "vue", renderOptions);
|
|
169
|
-
EJSUtils.renderToFile("WidgetRoutes.ejs", widgetRoutesFile, "typescript", renderOptions);
|
|
167
|
+
await EJSUtils.renderToFile("WidgetDefine.ejs", widgetDefineFile, "typescript", renderOptions);
|
|
168
|
+
await EJSUtils.renderToFile("WidgetView.ejs", widgetViewFile, "vue", renderOptions);
|
|
169
|
+
await EJSUtils.renderToFile("WidgetRoutes.ejs", widgetRoutesFile, "typescript", renderOptions);
|
|
170
170
|
if (configurable) {
|
|
171
171
|
const configFile = path.resolve(widgetDir, `${name}ConfigView.vue`);
|
|
172
|
-
EJSUtils.renderToFile("WidgetConfig.ejs", configFile, "vue", renderOptions);
|
|
172
|
+
await EJSUtils.renderToFile("WidgetConfig.ejs", configFile, "vue", renderOptions);
|
|
173
173
|
}
|
|
174
174
|
const routeFile = path.join(widgetFolder, "widget-router.ts");
|
|
175
175
|
let routeContent;
|
package/lib/index.js
CHANGED
|
@@ -11,7 +11,7 @@ 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-MZL6DPP2.js");
|
|
15
15
|
await createWidget.default();
|
|
16
16
|
});
|
|
17
17
|
var dependenciesOption = new Option("-t, --type <type>").choices(["remote", "local"]);
|
|
@@ -20,7 +20,7 @@ program.command("dependencies").description("Set @widget-js dependencies to loca
|
|
|
20
20
|
await dependencies.default(options);
|
|
21
21
|
});
|
|
22
22
|
program.command("init").description("Initialize widget-js project").action(async () => {
|
|
23
|
-
const init = await import("./init-
|
|
23
|
+
const init = await import("./init-FUMP334Y.js");
|
|
24
24
|
await init.init();
|
|
25
25
|
});
|
|
26
26
|
var typeOption = new Option("-t, --type <type>").choices(["ftp", "oss"]);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
EJSUtils,
|
|
3
3
|
PrettierUtils
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-PCGVPLNI.js";
|
|
5
5
|
import {
|
|
6
6
|
promptChecker_default
|
|
7
7
|
} from "./chunk-3GPAHQ6O.js";
|
|
@@ -40,9 +40,9 @@ async function addWidgetTs() {
|
|
|
40
40
|
let widgetTs = path.join(process.cwd(), "widget.package.ts");
|
|
41
41
|
if (!fs.existsSync(widgetTs)) {
|
|
42
42
|
spinner.info("creating widget.package.ts");
|
|
43
|
-
EJSUtils.renderToFile("WidgetPackage.ejs", widgetTs, "typescript", { name });
|
|
43
|
+
await EJSUtils.renderToFile("WidgetPackage.ejs", widgetTs, "typescript", { name });
|
|
44
44
|
}
|
|
45
|
-
addVitePlugin();
|
|
45
|
+
await addVitePlugin();
|
|
46
46
|
spinner.succeed("Done! Be sure to replace the contents of widget.package.ts with your own.");
|
|
47
47
|
}
|
|
48
48
|
async function addDependencies() {
|
|
@@ -74,7 +74,7 @@ async function addVitePlugin() {
|
|
|
74
74
|
viteConfig = viteConfig.replace("import", `import widget from '@widget-js/vite-plugin-widget'
|
|
75
75
|
import`);
|
|
76
76
|
viteConfig = viteConfig.replace("vue()", `vue(),widget()`);
|
|
77
|
-
fs.writeFileSync(viteConfigPath, PrettierUtils.format(viteConfig, "typescript"));
|
|
77
|
+
fs.writeFileSync(viteConfigPath, await PrettierUtils.format(viteConfig, "typescript"));
|
|
78
78
|
}
|
|
79
79
|
async function addDependency(packageName, dependencies) {
|
|
80
80
|
spinner.info(`Adding dependencies ${packageName}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@widget-js/cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.9",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"author": "Neo Fu",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"minimatch": "^9.0.3",
|
|
35
35
|
"ora": "^6.2.0",
|
|
36
36
|
"package-json": "^8.1.0",
|
|
37
|
-
"prettier": "^
|
|
37
|
+
"prettier": "^3.1.1",
|
|
38
38
|
"semver": "^7.3.8",
|
|
39
39
|
"shelljs": "^0.8.5",
|
|
40
40
|
"ssh2-sftp-client": "^9.1.0",
|
|
@@ -64,9 +64,8 @@
|
|
|
64
64
|
"vue-router": "^4.2.5",
|
|
65
65
|
"webpack": "^5.75.0",
|
|
66
66
|
"webpack-cli": "^5.0.0",
|
|
67
|
-
"@widget-js/
|
|
68
|
-
"@widget-js/core": "0.11.21"
|
|
69
|
-
"@widget-js/vue3": "^0.11.20"
|
|
67
|
+
"@widget-js/vue3": "^0.11.20",
|
|
68
|
+
"@widget-js/core": "0.11.21"
|
|
70
69
|
},
|
|
71
70
|
"scripts": {
|
|
72
71
|
"build": "rimraf ./lib/ && tsup-node src/index.ts --format esm",
|
package/src/createWidget.ts
CHANGED
|
@@ -192,13 +192,13 @@ export default async function createWidget() {
|
|
|
192
192
|
const widgetViewFile = path.resolve(widgetDir, `${name}WidgetView.vue`)
|
|
193
193
|
const widgetRoutesFile = path.resolve(widgetDir, `${name}WidgetRoutes.ts`)
|
|
194
194
|
|
|
195
|
-
EJSUtils.renderToFile('WidgetDefine.ejs', widgetDefineFile, 'typescript', renderOptions)
|
|
195
|
+
await EJSUtils.renderToFile('WidgetDefine.ejs', widgetDefineFile, 'typescript', renderOptions)
|
|
196
196
|
// EJSUtils.renderToFile('Widget.ejs', widgetFile, 'vue', renderOptions)
|
|
197
|
-
EJSUtils.renderToFile('WidgetView.ejs', widgetViewFile, 'vue', renderOptions)
|
|
198
|
-
EJSUtils.renderToFile('WidgetRoutes.ejs', widgetRoutesFile, 'typescript', renderOptions)
|
|
197
|
+
await EJSUtils.renderToFile('WidgetView.ejs', widgetViewFile, 'vue', renderOptions)
|
|
198
|
+
await EJSUtils.renderToFile('WidgetRoutes.ejs', widgetRoutesFile, 'typescript', renderOptions)
|
|
199
199
|
if (configurable) {
|
|
200
200
|
const configFile = path.resolve(widgetDir, `${name}ConfigView.vue`)
|
|
201
|
-
EJSUtils.renderToFile('WidgetConfig.ejs', configFile, 'vue', renderOptions)
|
|
201
|
+
await EJSUtils.renderToFile('WidgetConfig.ejs', configFile, 'vue', renderOptions)
|
|
202
202
|
}
|
|
203
203
|
// 注册路由
|
|
204
204
|
const routeFile = path.join(widgetFolder, 'widget-router.ts')
|
package/src/init/init.ts
CHANGED
|
@@ -37,10 +37,10 @@ async function addWidgetTs() {
|
|
|
37
37
|
let widgetTs = path.join(process.cwd(), 'widget.package.ts')
|
|
38
38
|
if (!fs.existsSync(widgetTs)) {
|
|
39
39
|
spinner.info('creating widget.package.ts')
|
|
40
|
-
EJSUtils.renderToFile('WidgetPackage.ejs', widgetTs, 'typescript', {name})
|
|
40
|
+
await EJSUtils.renderToFile('WidgetPackage.ejs', widgetTs, 'typescript', {name})
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
addVitePlugin()
|
|
43
|
+
await addVitePlugin()
|
|
44
44
|
|
|
45
45
|
spinner.succeed('Done! Be sure to replace the contents of widget.package.ts with your own.')
|
|
46
46
|
}
|
|
@@ -80,7 +80,7 @@ async function addVitePlugin() {
|
|
|
80
80
|
let viteConfig = fs.readFileSync(viteConfigPath).toString()
|
|
81
81
|
viteConfig = viteConfig.replace('import', `import widget from '@widget-js/vite-plugin-widget'\nimport`)
|
|
82
82
|
viteConfig = viteConfig.replace('vue()', `vue(),widget()`)
|
|
83
|
-
fs.writeFileSync(viteConfigPath, PrettierUtils.format(viteConfig, 'typescript'))
|
|
83
|
+
fs.writeFileSync(viteConfigPath,await PrettierUtils.format(viteConfig, 'typescript'))
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async function addDependency(packageName: string, dependencies: any) {
|
package/src/utils/EJSUtils.ts
CHANGED
|
@@ -6,12 +6,12 @@ import {dirname} from 'dirname-filename-esm'
|
|
|
6
6
|
import {PrettierUtils} from './PrettierUtils'
|
|
7
7
|
|
|
8
8
|
export class EJSUtils {
|
|
9
|
-
static renderToFile(templateFile: string, outputFile: string, parser: BuiltInParserName, renderOptions: Data) {
|
|
9
|
+
static async renderToFile(templateFile: string, outputFile: string, parser: BuiltInParserName, renderOptions: Data) {
|
|
10
10
|
const defineTemplatePath = path.join(dirname(import.meta), '../template', templateFile)
|
|
11
11
|
let defineTemplate = fs.readFileSync(defineTemplatePath, 'utf8')
|
|
12
12
|
// Format the EJS code using Prettier
|
|
13
13
|
let code = ejs.render(defineTemplate, renderOptions)
|
|
14
|
-
const formattedEJSCode = PrettierUtils.format(code,parser)
|
|
14
|
+
const formattedEJSCode =await PrettierUtils.format(code,parser)
|
|
15
15
|
fs.writeFileSync(outputFile, formattedEJSCode)
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {BuiltInParserName, format} from 'prettier'
|
|
2
2
|
|
|
3
3
|
export class PrettierUtils {
|
|
4
|
-
static format(code:string,parser:
|
|
5
|
-
|
|
4
|
+
static async format(code: string, parser: BuiltInParserName) {
|
|
5
|
+
return format(code, {
|
|
6
6
|
parser: parser,
|
|
7
7
|
tabWidth: 2,
|
|
8
8
|
singleQuote: true,
|
package/vite.config.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import widget from '@widget-js/vite-plugin-widget';
|
|
2
1
|
import { fileURLToPath, URL } from 'node:url';
|
|
3
2
|
|
|
4
3
|
import { defineConfig } from 'vite';
|
|
@@ -6,7 +5,7 @@ import vue from '@vitejs/plugin-vue';
|
|
|
6
5
|
|
|
7
6
|
// https://vitejs.dev/config/
|
|
8
7
|
export default defineConfig({
|
|
9
|
-
plugins: [vue()
|
|
8
|
+
plugins: [vue()],
|
|
10
9
|
resolve: {
|
|
11
10
|
alias: {
|
|
12
11
|
'@': fileURLToPath(new URL('./src', import.meta.url)),
|
package/widget.package.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { WidgetPackage } from '@widget-js/core';
|
|
2
|
-
|
|
3
|
-
//TODO 完善组件包信息
|
|
4
|
-
export default new WidgetPackage({
|
|
5
|
-
author: '修改成你的信息',
|
|
6
|
-
description: {
|
|
7
|
-
'zh-CN': '修改成你的组件描述',
|
|
8
|
-
},
|
|
9
|
-
entry: 'index.html',
|
|
10
|
-
hash: true,
|
|
11
|
-
homepage: '',
|
|
12
|
-
name: 'cn.te',
|
|
13
|
-
title: {
|
|
14
|
-
'zh-CN': '修改成你的组件标题',
|
|
15
|
-
},
|
|
16
|
-
version: '1.0.0',
|
|
17
|
-
devOptions: {
|
|
18
|
-
folder: './src/widgets/',
|
|
19
|
-
},
|
|
20
|
-
});
|