@widget-js/cli 1.1.5 → 1.1.7
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.js +155695 -28
- package/package.json +12 -10
- package/src/createWidget.ts +199 -194
- package/src/index.ts +1 -4
- package/template/Widget.ejs +1 -4
- package/template/WidgetConfig.ejs +13 -25
- package/template/WidgetDefine.ejs +26 -27
- package/template/WidgetRoutes.ejs +3 -3
- package/template/WidgetView.ejs +3 -10
- package/widget.ts +24 -0
- package/lib/build-BTARJMCZ.js +0 -31
- package/lib/chunk-3GPAHQ6O.js +0 -18
- package/lib/chunk-NJPDF23X.js +0 -34
- package/lib/createWidget-LWD7JPGR.js +0 -193
- package/lib/dependencies-J3BZI237.js +0 -87
- package/lib/index.cjs +0 -689
- package/lib/index.d.ts +0 -2
- package/lib/release-W3SP4YSR.js +0 -212
package/template/WidgetView.ejs
CHANGED
|
@@ -1,21 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<!-- TODO:组件页面,这里编写组件业务逻辑-->
|
|
3
|
-
<<%= paramCaseName %>-widget
|
|
3
|
+
<<%= paramCaseName %>-widget></<%= paramCaseName %>-widget>
|
|
4
4
|
</template>
|
|
5
5
|
|
|
6
|
-
<script lang="ts">
|
|
6
|
+
<script lang="ts" setup>
|
|
7
7
|
import {WidgetData} from "@widget-js/core";
|
|
8
8
|
import <%= name %>Widget from "./<%= name %>Widget.vue"
|
|
9
9
|
import {useWidget} from "@widget-js/vue3";
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
name:"<%= name %>WidgetView",
|
|
13
|
-
components: {<%= name %>Widget},
|
|
14
|
-
setup(){
|
|
15
|
-
const {widgetData, widgetParams} = useWidget(WidgetData);
|
|
16
|
-
return {widgetData, widgetParams};
|
|
17
|
-
}
|
|
18
|
-
}
|
|
11
|
+
const {widgetData, widgetParams} = useWidget(WidgetData);
|
|
19
12
|
</script>
|
|
20
13
|
|
|
21
14
|
<style scoped>
|
package/widget.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {WidgetPackage} from "@widget-js/core";
|
|
2
|
+
|
|
3
|
+
export default new WidgetPackage({
|
|
4
|
+
author: "Neo Fu",
|
|
5
|
+
description: {
|
|
6
|
+
"zh-CN": "包含知乎、B站、抖音、微博等平台的热搜组件。",
|
|
7
|
+
},
|
|
8
|
+
entry: "index.html",
|
|
9
|
+
hash: true,
|
|
10
|
+
homepage: "https://widgetjs.cn",
|
|
11
|
+
name: "cn.widgetjs.widgets.hotspot",
|
|
12
|
+
remoteEntry: "https://rtugeek.gitee.io/hotspot",
|
|
13
|
+
remotePackage: "https://rtugeek.gitee.io/hotspot/widget.json",
|
|
14
|
+
title: {
|
|
15
|
+
"zh-CN": "全网热点组件",
|
|
16
|
+
},
|
|
17
|
+
url: "",
|
|
18
|
+
version: "1.0.0",
|
|
19
|
+
devOptions: {
|
|
20
|
+
folder: "./src/widgets/",
|
|
21
|
+
route: true,
|
|
22
|
+
devUrl: "http://localhost:5173/hotspot"
|
|
23
|
+
}
|
|
24
|
+
});
|
package/lib/build-BTARJMCZ.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// src/build/build.ts
|
|
2
|
-
import ora from "ora";
|
|
3
|
-
import { exec } from "child_process";
|
|
4
|
-
import consola from "consola";
|
|
5
|
-
function build() {
|
|
6
|
-
const preloadSpinner = ora("Preload").start();
|
|
7
|
-
const mainSpinner = ora("Main").start();
|
|
8
|
-
const build2 = exec("npm run build:preload").on("close", () => {
|
|
9
|
-
consola.success("done");
|
|
10
|
-
});
|
|
11
|
-
build2.stdout.on("data", (data) => {
|
|
12
|
-
consola.log("data", data);
|
|
13
|
-
});
|
|
14
|
-
exec("npm run build:main", (error, stdout, stderr) => {
|
|
15
|
-
if (error) {
|
|
16
|
-
consola.error("error: " + error);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
consola.log("stdout: " + stdout);
|
|
20
|
-
consola.log("stderr: " + typeof stderr);
|
|
21
|
-
}).on("message", () => {
|
|
22
|
-
consola.log("on-message");
|
|
23
|
-
}).on("data", () => {
|
|
24
|
-
consola.log("on-data");
|
|
25
|
-
}).on("close", () => {
|
|
26
|
-
consola.log("done");
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
build
|
|
31
|
-
};
|
package/lib/chunk-3GPAHQ6O.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// src/promts/promptChecker.ts
|
|
2
|
-
import inquirer from "inquirer";
|
|
3
|
-
var promptChecker = async (prompt, checker) => {
|
|
4
|
-
const answer = await inquirer.prompt([prompt]);
|
|
5
|
-
if (checker) {
|
|
6
|
-
if (checker(answer)) {
|
|
7
|
-
return answer[prompt.name];
|
|
8
|
-
} else {
|
|
9
|
-
return promptChecker(prompt, checker);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return answer[prompt.name];
|
|
13
|
-
};
|
|
14
|
-
var promptChecker_default = promptChecker;
|
|
15
|
-
|
|
16
|
-
export {
|
|
17
|
-
promptChecker_default
|
|
18
|
-
};
|
package/lib/chunk-NJPDF23X.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// src/utils.ts
|
|
2
|
-
import path from "path";
|
|
3
|
-
import process from "process";
|
|
4
|
-
import fs from "fs";
|
|
5
|
-
var widgetPackages = {
|
|
6
|
-
"@widget-js/core": "",
|
|
7
|
-
"@widget-js/vue3": "",
|
|
8
|
-
"@widget-js/cli": "",
|
|
9
|
-
"@widget-js/vite-plugin-widget": ""
|
|
10
|
-
};
|
|
11
|
-
function exit(code = 0) {
|
|
12
|
-
if (exports.exitProcess) {
|
|
13
|
-
process.exit(code);
|
|
14
|
-
} else if (code > 0) {
|
|
15
|
-
throw new Error(`Process exited with code ${code}`);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function getPackagePath() {
|
|
19
|
-
return path.join(process.cwd(), "package.json");
|
|
20
|
-
}
|
|
21
|
-
function getPackageJson() {
|
|
22
|
-
return JSON.parse(fs.readFileSync(getPackagePath()).toString());
|
|
23
|
-
}
|
|
24
|
-
function getPackageVersion() {
|
|
25
|
-
return getPackageJson()["version"];
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export {
|
|
29
|
-
widgetPackages,
|
|
30
|
-
exit,
|
|
31
|
-
getPackagePath,
|
|
32
|
-
getPackageJson,
|
|
33
|
-
getPackageVersion
|
|
34
|
-
};
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
promptChecker_default
|
|
3
|
-
} from "./chunk-3GPAHQ6O.js";
|
|
4
|
-
import {
|
|
5
|
-
exit
|
|
6
|
-
} from "./chunk-NJPDF23X.js";
|
|
7
|
-
|
|
8
|
-
// src/createWidget.ts
|
|
9
|
-
import path from "path";
|
|
10
|
-
import fs from "fs";
|
|
11
|
-
import consola from "consola";
|
|
12
|
-
import { fileURLToPath } from "url";
|
|
13
|
-
import { paramCase, snakeCase } from "change-case";
|
|
14
|
-
import inquirer from "inquirer";
|
|
15
|
-
import ejs from "ejs";
|
|
16
|
-
import shell from "shelljs";
|
|
17
|
-
import chalk from "chalk";
|
|
18
|
-
async function createWidget() {
|
|
19
|
-
let widgetJson = path.join(process.cwd(), "widget.json");
|
|
20
|
-
if (!fs.existsSync(widgetJson)) {
|
|
21
|
-
consola.error("\u6CA1\u6709\u5728\u6839\u76EE\u5F55\u627E\u5230widget.json\u6587\u4EF6");
|
|
22
|
-
exit();
|
|
23
|
-
}
|
|
24
|
-
let widgetPackage = JSON.parse(fs.readFileSync(widgetJson).toString());
|
|
25
|
-
let widgetFolder = path.join(process.cwd(), "./src/widgets");
|
|
26
|
-
let devOptions = widgetPackage["devOptions"] ?? {};
|
|
27
|
-
if (devOptions["folder"]) {
|
|
28
|
-
widgetFolder = devOptions["folder"];
|
|
29
|
-
consola.info(`\u7EC4\u4EF6\u8DEF\u5F84\uFF1A${widgetFolder}`);
|
|
30
|
-
} else {
|
|
31
|
-
consola.info(`\u6CA1\u6709\u914D\u7F6EdevOptions.folder\uFF0C\u4F7F\u7528\u9ED8\u8BA4\u8DEF\u5F84${widgetFolder}`);
|
|
32
|
-
}
|
|
33
|
-
if (!fs.existsSync(widgetFolder)) {
|
|
34
|
-
fs.mkdirSync(widgetFolder, { recursive: true });
|
|
35
|
-
}
|
|
36
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
37
|
-
const __dirname = path.dirname(__filename);
|
|
38
|
-
const getMiddleValue = (arr) => {
|
|
39
|
-
if (arr.length === 1) {
|
|
40
|
-
return arr[0];
|
|
41
|
-
} else if (arr.length === 2) {
|
|
42
|
-
return Math.max(...arr);
|
|
43
|
-
} else {
|
|
44
|
-
const max = Math.max(...arr);
|
|
45
|
-
const min = Math.min(...arr);
|
|
46
|
-
const sum = arr[0] + arr[1] + arr[2];
|
|
47
|
-
return sum - max - min;
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
let name = await promptChecker_default({
|
|
51
|
-
type: "input",
|
|
52
|
-
name: "name",
|
|
53
|
-
message: chalk.blue("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u540D(\u5927\u9A7C\u5CF0\u5F0F)\uFF0C\u5982\uFF1ACountdownClock")
|
|
54
|
-
}, (answer) => {
|
|
55
|
-
const name2 = answer.name;
|
|
56
|
-
if (name2 == null || name2 === "") {
|
|
57
|
-
consola.log(chalk.red("\u7EC4\u4EF6\u540D\u4E0D\u80FD\u4E3A\u7A7A"));
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
return true;
|
|
61
|
-
});
|
|
62
|
-
consola.log(chalk.green(name));
|
|
63
|
-
let title = await promptChecker_default({
|
|
64
|
-
type: "input",
|
|
65
|
-
name: "title",
|
|
66
|
-
message: chalk.blue("\u8BF7\u8F93\u5165\u7EC4\u4EF6\u6807\u9898\uFF0C\u5982\uFF1A\u5012\u8BA1\u65F6")
|
|
67
|
-
});
|
|
68
|
-
consola.log(chalk.green(title));
|
|
69
|
-
let answerW = await promptChecker_default({
|
|
70
|
-
type: "checkbox",
|
|
71
|
-
name: "w",
|
|
72
|
-
message: chalk.blue("\u8BF7\u9009\u62E9\u7EC4\u4EF6\u5BBD\u5EA6\uFF0C\u6700\u591A\u90093\u4E2A\uFF0C\u4F8B\u5982\u9009\u4E2D2,4,6\uFF0C\u4EE3\u8868\u7EC4\u4EF6\u6700\u5C0F\u5BBD\u4E3A2\uFF0C\u9ED8\u8BA4\u5BBD\u4E3A4\uFF0C\u6700\u5927\u5BBD\u4E3A6\uFF0C\u5355\u9009\u4EE3\u8868\u4E0D\u53EF\u62C9\u4F38"),
|
|
73
|
-
choices: [1, 2, 3, 4, 5, 6]
|
|
74
|
-
}, (answer) => {
|
|
75
|
-
if (answer.w.length === 0) {
|
|
76
|
-
consola.log(chalk.red("\u5BBD\u5EA6\u5FC5\u987B\u9009\u62E9"));
|
|
77
|
-
return false;
|
|
78
|
-
}
|
|
79
|
-
if (answer.w.length > 3) {
|
|
80
|
-
consola.log(chalk.red("\u5BBD\u5EA6\u6700\u591A\u9009\u62E93\u4E2A"));
|
|
81
|
-
return false;
|
|
82
|
-
}
|
|
83
|
-
return true;
|
|
84
|
-
});
|
|
85
|
-
consola.log(chalk.green(answerW));
|
|
86
|
-
let answerH = await promptChecker_default({
|
|
87
|
-
type: "checkbox",
|
|
88
|
-
name: "h",
|
|
89
|
-
message: chalk.blue("\u8BF7\u9009\u62E9\u7EC4\u4EF6\u9AD8\u5EA6\uFF0C\u6700\u591A\u90093\u4E2A\uFF0C\u4F8B\u5982\u9009\u4E2D1,2\uFF0C\u4EE3\u8868\u7EC4\u4EF6\u6700\u5C0F\u9AD8\u4E3A1\uFF0C\u9ED8\u8BA4\u9AD8\u4E3A2\uFF0C\u6700\u5927\u9AD8\u4E3A2\uFF0C\u5355\u9009\u4EE3\u8868\u4E0D\u53EF\u62C9\u4F38"),
|
|
90
|
-
choices: [1, 2, 3, 4, 5, 6]
|
|
91
|
-
}, (answer) => {
|
|
92
|
-
if (answer.h.length === 0) {
|
|
93
|
-
consola.log(chalk.red("\u9AD8\u5EA6\u5FC5\u987B\u9009\u62E9"));
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
if (answer.h.length > 3) {
|
|
97
|
-
consola.log(chalk.red("\u9AD8\u5EA6\u6700\u591A\u9009\u62E93\u4E2A"));
|
|
98
|
-
return false;
|
|
99
|
-
}
|
|
100
|
-
return true;
|
|
101
|
-
});
|
|
102
|
-
consola.log(chalk.green(answerH));
|
|
103
|
-
let configurable = await promptChecker_default({
|
|
104
|
-
type: "confirm",
|
|
105
|
-
name: "configurable",
|
|
106
|
-
message: chalk.blue("\u7EC4\u4EF6\u662F\u5426\u53EF\u914D\u7F6E\uFF0C\u4F8B\u5982\u4FEE\u6539\u80CC\u666F\u989C\u8272\uFF0C\u5B57\u4F53\u5927\u5C0F\u7B49")
|
|
107
|
-
});
|
|
108
|
-
consola.log(chalk.green(configurable));
|
|
109
|
-
const width = getMiddleValue(answerW);
|
|
110
|
-
const height = getMiddleValue(answerH);
|
|
111
|
-
const minWidth = Math.min(...answerW);
|
|
112
|
-
const maxWidth = Math.max(...answerW);
|
|
113
|
-
const minHeight = Math.min(...answerH);
|
|
114
|
-
const maxHeight = Math.max(...answerH);
|
|
115
|
-
const snakeCaseName = snakeCase(name);
|
|
116
|
-
const paramCaseName = paramCase(name);
|
|
117
|
-
const packageName = "com.wisdom.widgets." + snakeCaseName;
|
|
118
|
-
const widgetDir = path.join(widgetFolder, paramCaseName);
|
|
119
|
-
if (!fs.existsSync(widgetDir)) {
|
|
120
|
-
fs.mkdirSync(widgetDir);
|
|
121
|
-
} else {
|
|
122
|
-
let answer = await inquirer.prompt([{
|
|
123
|
-
type: "confirm",
|
|
124
|
-
name: "override",
|
|
125
|
-
message: chalk.red("\u7EC4\u4EF6\u540D\u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u7EE7\u7EED?")
|
|
126
|
-
}]);
|
|
127
|
-
if (!answer.override) {
|
|
128
|
-
exit();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
const renderOptions = {
|
|
132
|
-
name,
|
|
133
|
-
snakeCaseName,
|
|
134
|
-
paramCaseName,
|
|
135
|
-
packageName,
|
|
136
|
-
title,
|
|
137
|
-
configurable,
|
|
138
|
-
width,
|
|
139
|
-
height,
|
|
140
|
-
maxWidth,
|
|
141
|
-
minHeight,
|
|
142
|
-
maxHeight,
|
|
143
|
-
minWidth
|
|
144
|
-
};
|
|
145
|
-
function renderToFile(templateFile, outputFile, renderOptions2) {
|
|
146
|
-
const defineTemplatePath = path.join(__dirname, "../template", templateFile);
|
|
147
|
-
let defineTemplate = fs.readFileSync(defineTemplatePath, "utf8");
|
|
148
|
-
fs.writeFileSync(outputFile, ejs.render(defineTemplate, renderOptions2));
|
|
149
|
-
}
|
|
150
|
-
const widgetDefineFile = path.resolve(widgetDir, `${name}.widget.ts`);
|
|
151
|
-
const widgetFile = path.resolve(widgetDir, `${name}Widget.vue`);
|
|
152
|
-
const widgetViewFile = path.resolve(widgetDir, `${name}WidgetView.vue`);
|
|
153
|
-
const widgetRoutesFile = path.resolve(widgetDir, `${name}WidgetRoutes.ts`);
|
|
154
|
-
renderToFile("WidgetDefine.ejs", widgetDefineFile, renderOptions);
|
|
155
|
-
renderToFile("Widget.ejs", widgetFile, renderOptions);
|
|
156
|
-
renderToFile("WidgetView.ejs", widgetViewFile, renderOptions);
|
|
157
|
-
renderToFile("WidgetRoutes.ejs", widgetRoutesFile, renderOptions);
|
|
158
|
-
if (configurable) {
|
|
159
|
-
const configFile = path.resolve(widgetDir, `${name}ConfigView.vue`);
|
|
160
|
-
renderToFile("WidgetConfig.ejs", configFile, renderOptions);
|
|
161
|
-
}
|
|
162
|
-
if (devOptions["useStorybook"]) {
|
|
163
|
-
const storiesFile = path.resolve(widgetDir, `${name}Widget.stories.ts`);
|
|
164
|
-
renderToFile("stories.ejs", storiesFile, renderOptions);
|
|
165
|
-
}
|
|
166
|
-
const routeFile = path.join(widgetFolder, "widget-router.ts");
|
|
167
|
-
let routeContent;
|
|
168
|
-
if (fs.existsSync(routeFile)) {
|
|
169
|
-
routeContent = fs.readFileSync(routeFile, "utf8");
|
|
170
|
-
} else {
|
|
171
|
-
routeContent = fs.readFileSync(path.join(__dirname, "../template/widget-router.ts"), "utf8");
|
|
172
|
-
}
|
|
173
|
-
const importRouteStr = `import ${name}WidgetRoutes from "./${paramCaseName}/${name}WidgetRoutes";`;
|
|
174
|
-
const routeStr = `...${name}WidgetRoutes,`;
|
|
175
|
-
if (!routeContent.includes(importRouteStr)) {
|
|
176
|
-
routeContent = routeContent.replaceAll("//FBI WANING! IMPORT PLACE", `${importRouteStr}
|
|
177
|
-
//FBI WANING! IMPORT PLACE`);
|
|
178
|
-
}
|
|
179
|
-
if (!routeContent.includes(routeStr)) {
|
|
180
|
-
routeContent = routeContent.replaceAll("//FBI WANING! ROUTE PLACE", `${routeStr}
|
|
181
|
-
//FBI WANING! ROUTE PLACE`);
|
|
182
|
-
}
|
|
183
|
-
fs.writeFileSync(routeFile, routeContent);
|
|
184
|
-
let gitAdd = `git add ${widgetDir}`;
|
|
185
|
-
consola.info(chalk.grey(gitAdd));
|
|
186
|
-
shell.exec(gitAdd);
|
|
187
|
-
consola.log("=================");
|
|
188
|
-
consola.info(`\u5DF2\u521B\u5EFA\u7EC4\u4EF6\uFF1A${widgetDir}`);
|
|
189
|
-
consola.success("Happy coding!");
|
|
190
|
-
}
|
|
191
|
-
export {
|
|
192
|
-
createWidget as default
|
|
193
|
-
};
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getPackageJson,
|
|
3
|
-
getPackagePath,
|
|
4
|
-
widgetPackages
|
|
5
|
-
} from "./chunk-NJPDF23X.js";
|
|
6
|
-
|
|
7
|
-
// src/dependencies/remoteDependencies.ts
|
|
8
|
-
import packageJson from "package-json";
|
|
9
|
-
import ora from "ora";
|
|
10
|
-
import fs from "fs";
|
|
11
|
-
var spinner = ora("Connecting");
|
|
12
|
-
var RemoteDependencies;
|
|
13
|
-
((RemoteDependencies2) => {
|
|
14
|
-
async function start() {
|
|
15
|
-
spinner.start();
|
|
16
|
-
let json = getPackageJson();
|
|
17
|
-
let packageNames = Object.keys(widgetPackages);
|
|
18
|
-
let dependencies = json["dependencies"];
|
|
19
|
-
let devDependencies = json["devDependencies"];
|
|
20
|
-
await upgradePackage(dependencies, packageNames);
|
|
21
|
-
await upgradePackage(devDependencies, packageNames);
|
|
22
|
-
fs.writeFileSync(getPackagePath(), JSON.stringify(json, null, 2));
|
|
23
|
-
spinner.succeed("Using remote versions!");
|
|
24
|
-
}
|
|
25
|
-
RemoteDependencies2.start = start;
|
|
26
|
-
async function upgradePackage(dependencies, packageNames) {
|
|
27
|
-
let localPackages = Object.keys(dependencies);
|
|
28
|
-
for (let localPackage of localPackages) {
|
|
29
|
-
if (packageNames.indexOf(localPackage) > -1) {
|
|
30
|
-
let packageVersion = widgetPackages[localPackage];
|
|
31
|
-
if (!packageVersion) {
|
|
32
|
-
packageVersion = await getRemoteVersion(localPackage);
|
|
33
|
-
widgetPackages[localPackage] = packageVersion;
|
|
34
|
-
}
|
|
35
|
-
dependencies[localPackage] = `^${packageVersion}`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function getRemoteVersion(packageName) {
|
|
40
|
-
spinner.info(`Fetching package version:${packageName}`);
|
|
41
|
-
const metadata = await packageJson(packageName);
|
|
42
|
-
let version = metadata["version"];
|
|
43
|
-
spinner.info(`version:${version}`);
|
|
44
|
-
return version;
|
|
45
|
-
}
|
|
46
|
-
})(RemoteDependencies || (RemoteDependencies = {}));
|
|
47
|
-
|
|
48
|
-
// src/dependencies/localDependencies.ts
|
|
49
|
-
import ora2 from "ora";
|
|
50
|
-
import fs2 from "fs";
|
|
51
|
-
var spinner2 = ora2("Connecting");
|
|
52
|
-
var LocalDependencies;
|
|
53
|
-
((LocalDependencies2) => {
|
|
54
|
-
async function start() {
|
|
55
|
-
spinner2.start();
|
|
56
|
-
let json = getPackageJson();
|
|
57
|
-
let packageNames = Object.keys(widgetPackages);
|
|
58
|
-
let dependencies = json["dependencies"];
|
|
59
|
-
let devDependencies = json["devDependencies"];
|
|
60
|
-
await setWorkspaceVersion(dependencies, packageNames);
|
|
61
|
-
await setWorkspaceVersion(devDependencies, packageNames);
|
|
62
|
-
fs2.writeFileSync(getPackagePath(), JSON.stringify(json, null, 2));
|
|
63
|
-
spinner2.succeed("Using local versions(workspace:*)!");
|
|
64
|
-
}
|
|
65
|
-
LocalDependencies2.start = start;
|
|
66
|
-
async function setWorkspaceVersion(dependencies, packageNames) {
|
|
67
|
-
let localPackages = Object.keys(dependencies);
|
|
68
|
-
for (let localPackage of localPackages) {
|
|
69
|
-
if (packageNames.indexOf(localPackage) > -1) {
|
|
70
|
-
dependencies[localPackage] = `workspace:*`;
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
})(LocalDependencies || (LocalDependencies = {}));
|
|
75
|
-
|
|
76
|
-
// src/dependencies/index.ts
|
|
77
|
-
async function dependencies_default(options) {
|
|
78
|
-
let type = options.type;
|
|
79
|
-
if (type == "remote") {
|
|
80
|
-
await RemoteDependencies.start();
|
|
81
|
-
} else {
|
|
82
|
-
await LocalDependencies.start();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
export {
|
|
86
|
-
dependencies_default as default
|
|
87
|
-
};
|