@widget-js/cli 1.1.0 → 1.1.2

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.
@@ -1,75 +1,74 @@
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'
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
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'
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
+ if (options.type == 'ftp') {
19
+ await ftpUpload()
20
+ return
21
+ }
22
+ const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf-8'))
23
+ const changelogJSON = JSON.parse(fs.readFileSync('changelog.json', 'utf-8'))
24
+ const version = packageJSON['version']
25
+ const changelog = changelogJSON[version]
26
+
27
+ let needUpdateElectron = await promptChecker({
28
+ type: 'confirm',
29
+ name: 'electron',
30
+ message: chalk.blue('用户是否需要更新Electron?'),
31
+ })
32
+ //
33
+ // let needUpdateNodeModule = await promptChecker({
34
+ // type: "confirm",
35
+ // name: 'electron',
36
+ // message: chalk.blue("用户是否需要更新node_module?")
37
+ // });
38
+
39
+ const versionInfo = {
40
+ version: version,
41
+ releaseNote: changelog,
42
+ updateElectron: needUpdateElectron,
43
+ updateNodeModule: false,
44
+ updateWindowsApi: false,
45
+ downloadLink: '',
46
+ }
47
+
48
+ let installerPath = path.join(`./packaged/widgets-${version}-setup-win-x64.exe`)
49
+ if (!fs.existsSync(installerPath)) {
50
+ installerPath = path.join(`./packaged/electron-${version}-setup-win-x64.exe`)
51
+ }
52
+ const updateZipPath = path.join(`./packaged/update.zip`)
53
+
54
+ console.log(chalk.blue('压缩更新文件中'))
55
+ await zipDirectory('./release', updateZipPath)
56
+
57
+ console.log(chalk.blue('上传installer.exe到OSS'))
58
+ await put('version/installer.exe', installerPath)
59
+
60
+ console.log(chalk.blue('上传update.zip到OSS'))
61
+ await put('version/update.zip', updateZipPath)
62
+
63
+ console.log(chalk.blue('更新版本信息'))
64
+ versionInfo.downloadLink = 'https://widget-fun.oss-cn-hangzhou.aliyuncs.com/version/update.zip'
65
+ const versionJSON = JSON.stringify(versionInfo, null, 2)
66
+ await put('version/version.json', Buffer.from(versionJSON))
67
+
68
+ copy(`version/history/${version}.exe`, 'version/installer.exe')
69
+ copy(`version/history/update-${version}.zip`, 'version/update.zip')
70
+
71
+ console.log(chalk.yellow(versionJSON))
72
+ }
73
+
74
+ export default release
package/src/utils.ts CHANGED
@@ -2,22 +2,25 @@ import path from "path";
2
2
  import process from "process";
3
3
  import fs from "fs";
4
4
 
5
+ export const widgetPackages: { [key: string]: string } = {
6
+ "@widget-js/core": "", "@widget-js/vue3": "", "@widget-js/cli": "", "@widget-js/vite-plugin-widget": ""
7
+ };
5
8
  export default function exit(code: number = 0) {
6
- if (exports.exitProcess) {
7
- process.exit(code);
8
- } else if (code > 0) {
9
- throw new Error(`Process exited with code ${code}`);
10
- }
9
+ if (exports.exitProcess) {
10
+ process.exit(code);
11
+ } else if (code > 0) {
12
+ throw new Error(`Process exited with code ${code}`);
13
+ }
11
14
  }
12
15
 
13
16
  export function getPackagePath() {
14
- return path.join(process.cwd(), "package.json");
17
+ return path.join(process.cwd(), "package.json");
15
18
  }
16
19
 
17
20
  export function getPackageJson() {
18
- return JSON.parse(fs.readFileSync(getPackagePath()).toString());
21
+ return JSON.parse(fs.readFileSync(getPackagePath()).toString());
19
22
  }
20
23
 
21
24
  export function getPackageVersion() {
22
- return getPackageJson()["version"];
25
+ return getPackageJson()["version"];
23
26
  }
@@ -3,13 +3,6 @@
3
3
  <widget-edit-dialog :widget-params="widgetParams" :option="widgetConfigOption"
4
4
  :widget-data="widgetData"
5
5
  @confirm="onSaveClick()">
6
- <template v-slot:widget>
7
- <!-- 组件配置内容 -->
8
- <<%= paramCaseName %>-widget :style="{
9
- width:`${widgetParams.widthPx}px`,
10
- height:`${widgetParams.heightPx}px`
11
- }" :background-color="widgetData.backgroundColor"></<%= paramCaseName %>-widget>
12
- </template>
13
6
  <template v-slot:form>
14
7
  <!-- TODO 这里写自定义表单内容 -->
15
8
  </template>
@@ -20,7 +13,7 @@
20
13
 
21
14
  import <%= name %>Widget from "./<%= name%>Widget.vue";
22
15
  import {useWidget, WidgetConfigOption, WidgetEditDialog} from "@widget-js/vue3";
23
- import {WidgetData, WidgetDataRepository} from "@widget-js/core";
16
+ import {WidgetData, WidgetDataApi} from "@widget-js/core";
24
17
  import {reactive} from "vue";
25
18
 
26
19
  export default {
@@ -33,14 +26,15 @@ export default {
33
26
  const widgetConfigOption = reactive(new WidgetConfigOption({
34
27
  custom: true,
35
28
  backgroundColor: true,
36
- borderRadius: true
29
+ borderRadius: true,
30
+ preview: false
37
31
  }));
38
32
 
39
33
  return {widgetData, widgetParams, widgetConfigOption}
40
34
  },
41
35
  methods: {
42
36
  async onSaveClick() {
43
- await WidgetDataRepository.save(this.widgetData);
37
+ await WidgetDataApi.save(this.widgetData);
44
38
  window.close();
45
39
  }
46
40
  }
@@ -1,58 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <code_scheme name="Project" version="173">
3
- <HTMLCodeStyleSettings>
4
- <option name="HTML_SPACE_INSIDE_EMPTY_TAG" value="true" />
5
- <option name="HTML_ENFORCE_QUOTES" value="true" />
6
- </HTMLCodeStyleSettings>
7
- <JSCodeStyleSettings version="0">
8
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
9
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
10
- <option name="FORCE_QUOTE_STYlE" value="true" />
11
- <option name="ENFORCE_TRAILING_COMMA" value="Remove" />
12
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
13
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
14
- </JSCodeStyleSettings>
15
- <TypeScriptCodeStyleSettings version="0">
16
- <option name="FORCE_SEMICOLON_STYLE" value="true" />
17
- <option name="SPACE_BEFORE_FUNCTION_LEFT_PARENTH" value="false" />
18
- <option name="FORCE_QUOTE_STYlE" value="true" />
19
- <option name="ENFORCE_TRAILING_COMMA" value="Remove" />
20
- <option name="SPACES_WITHIN_OBJECT_LITERAL_BRACES" value="true" />
21
- <option name="SPACES_WITHIN_IMPORTS" value="true" />
22
- </TypeScriptCodeStyleSettings>
23
- <VueCodeStyleSettings>
24
- <option name="INTERPOLATION_NEW_LINE_AFTER_START_DELIMITER" value="false" />
25
- <option name="INTERPOLATION_NEW_LINE_BEFORE_END_DELIMITER" value="false" />
26
- </VueCodeStyleSettings>
27
- <codeStyleSettings language="HTML">
28
- <option name="SOFT_MARGINS" value="80" />
29
- <indentOptions>
30
- <option name="INDENT_SIZE" value="2" />
31
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
32
- <option name="TAB_SIZE" value="2" />
33
- </indentOptions>
34
- </codeStyleSettings>
35
- <codeStyleSettings language="JavaScript">
36
- <option name="SOFT_MARGINS" value="80" />
37
- <indentOptions>
38
- <option name="INDENT_SIZE" value="2" />
39
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
40
- <option name="TAB_SIZE" value="2" />
41
- </indentOptions>
42
- </codeStyleSettings>
43
- <codeStyleSettings language="TypeScript">
44
- <option name="SOFT_MARGINS" value="80" />
45
- <indentOptions>
46
- <option name="INDENT_SIZE" value="2" />
47
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
48
- <option name="TAB_SIZE" value="2" />
49
- </indentOptions>
50
- </codeStyleSettings>
51
- <codeStyleSettings language="Vue">
52
- <option name="SOFT_MARGINS" value="80" />
53
- <indentOptions>
54
- <option name="CONTINUATION_INDENT_SIZE" value="2" />
55
- </indentOptions>
56
- </codeStyleSettings>
57
- </code_scheme>
58
- </component>
@@ -1,5 +0,0 @@
1
- <component name="ProjectCodeStyleConfiguration">
2
- <state>
3
- <option name="USE_PER_PROJECT_SETTINGS" value="true" />
4
- </state>
5
- </component>
@@ -1,6 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="JavaScriptLibraryMappings">
4
- <includedPredefinedLibrary name="Node.js Core" />
5
- </component>
6
- </project>
@@ -1,52 +0,0 @@
1
- import {
2
- getPackageJson,
3
- getPackagePath
4
- } from "./chunk-SIAOIY3B.js";
5
-
6
- // src/upgrade/upgrade.ts
7
- import packageJson from "package-json";
8
- import ora from "ora";
9
- import fs from "fs";
10
- var packages = {
11
- "@widget-js/core": "",
12
- "@widget-js/vue3": "",
13
- "@widget-js/cli": "",
14
- "@widget-js/vite-plugin-widget": ""
15
- };
16
- var spinner = ora("Connecting");
17
- var Upgrade = class {
18
- async start() {
19
- spinner.start();
20
- let json = getPackageJson();
21
- let packageNames = Object.keys(packages);
22
- let dependencies = json["dependencies"];
23
- let devDependencies = json["devDependencies"];
24
- await this.upgradePackage(dependencies, packageNames);
25
- await this.upgradePackage(devDependencies, packageNames);
26
- fs.writeFileSync(getPackagePath(), JSON.stringify(json, null, 2));
27
- spinner.succeed("Upgraded!");
28
- }
29
- async upgradePackage(dependencies, packageNames) {
30
- let localPackages = Object.keys(dependencies);
31
- for (let localPackage of localPackages) {
32
- if (packageNames.indexOf(localPackage) > -1) {
33
- let packageVersion = packages[localPackage];
34
- if (!packageVersion) {
35
- packageVersion = await this.getRemoteVersion(localPackage);
36
- packages[localPackage] = packageVersion;
37
- }
38
- dependencies[localPackage] = `^${packageVersion}`;
39
- }
40
- }
41
- }
42
- async getRemoteVersion(packageName) {
43
- spinner.info(`Fetching package version:${packageName}`);
44
- const metadata = await packageJson(packageName);
45
- let version = metadata["version"];
46
- spinner.info(`version:${version}`);
47
- return version;
48
- }
49
- };
50
- export {
51
- Upgrade
52
- };