@electron-ohos/electron-builder 26.8.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.
- package/README.md +184 -0
- package/cli.js +4 -0
- package/install-app-deps.js +4 -0
- package/out/builder.d.ts +25 -0
- package/out/builder.js +278 -0
- package/out/builder.js.map +1 -0
- package/out/cli/cli.d.ts +2 -0
- package/out/cli/cli.js +70 -0
- package/out/cli/cli.js.map +1 -0
- package/out/cli/create-self-signed-cert.d.ts +1 -0
- package/out/cli/create-self-signed-cert.js +40 -0
- package/out/cli/create-self-signed-cert.js.map +1 -0
- package/out/cli/install-app-deps.d.ts +2 -0
- package/out/cli/install-app-deps.js +73 -0
- package/out/cli/install-app-deps.js.map +1 -0
- package/out/cli/start.d.ts +1 -0
- package/out/cli/start.js +9 -0
- package/out/cli/start.js.map +1 -0
- package/out/index.d.ts +6 -0
- package/out/index.js +30 -0
- package/out/index.js.map +1 -0
- package/out/publish.d.ts +14 -0
- package/out/publish.js +108 -0
- package/out/publish.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# @electron-ohos/electron-builder
|
|
2
|
+
|
|
3
|
+
### 一、前置条件
|
|
4
|
+
|
|
5
|
+
1. 安装deveco或下载独立打包工具([Command Line Tools工具下载](https://developer.huawei.com/consumer/cn/download/command-line-tools-for-hmos))
|
|
6
|
+
|
|
7
|
+
2. 安装java,并在系统变量中,配置java的路径。
|
|
8
|
+
|
|
9
|
+
3. 在electron工程的./node_modules目录下,创建electron-ohos/template目录,并将编译产物(通过华为账号[下载](https://devcloud.cn-north-4.huaweicloud.com/codehub/project/b19f5ea8ffd4492ea8c06ca2ebf3f858/codehub/2821214/home?ref=main))中的鸿蒙工程放在里面,全路径为:electron工程/node_modules/electron-ohos/template/ohos_hap。如下:
|
|
10
|
+
|
|
11
|
+
### 二、安装鸿蒙版electron-builder
|
|
12
|
+
|
|
13
|
+
在electron工程根目录中,执行如下命令:
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
npm install @electron-ohos/electron-builder --save-dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### 三、在electron工程的package.json中进行配置
|
|
20
|
+
|
|
21
|
+
#### 3.1 添加打包命令
|
|
22
|
+
|
|
23
|
+
在scripts配置项中添加:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
"dist:ohos": "electron-builder-ohos --ohos"
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
可以执行命令npm run dist:ohos进行打包。
|
|
30
|
+
|
|
31
|
+
#### 3.2 添加环境配置项(必须)
|
|
32
|
+
|
|
33
|
+
在build配置项中添加:
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
"ohos": {
|
|
37
|
+
"target": [
|
|
38
|
+
"hap"
|
|
39
|
+
],
|
|
40
|
+
"hvigorwPath": "D:\\software\\DevEco\\deveco-studio-5.1.1.406SP1.win\\deveco-studio\\tools\\hvigor\\bin",
|
|
41
|
+
"ohpmPath": "D:\\software\\DevEco\\deveco-studio-5.1.1.406SP1.win\\deveco-studio\\tools\\ohpm\\bin",
|
|
42
|
+
"sdkPath": "D:\\software\\DevEco\\deveco-studio-5.1.1.406SP1.win\\deveco-studio\\sdk"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
target: 指定打包的类型,默认为hap
|
|
47
|
+
|
|
48
|
+
hvigorwPath:配置hvigorw工具的路径(可以在deveco的安装目录或打包工具目录中找到)
|
|
49
|
+
|
|
50
|
+
ohpmPath:ohpm工具路径(可以在deveco的安装目录或打包工具目录中找到)
|
|
51
|
+
|
|
52
|
+
sdkPath:sdk路径(可以在deveco的安装目录或打包工具目录中找到)
|
|
53
|
+
|
|
54
|
+
#### 3.3 添加签名证书配置(签名包必须)
|
|
55
|
+
|
|
56
|
+
在ohos节点添加:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
"ohos": {
|
|
60
|
+
"certPath": "D:/cert/debug.cer",
|
|
61
|
+
"profile": "D:/cert/helloworld.p7b",
|
|
62
|
+
"keyAlias": "helloworld",
|
|
63
|
+
"keyPassword": "123456",
|
|
64
|
+
"storeFile": "D:/cert/helloworld.p12",
|
|
65
|
+
"storePassword": "123456"
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
certPath: 证书地址。
|
|
70
|
+
|
|
71
|
+
profile: profile地址,格式为.p7b。
|
|
72
|
+
|
|
73
|
+
keyAlias: 必填,别名,用于标识密钥名称。
|
|
74
|
+
|
|
75
|
+
keyPassword: 别名密码(既可以在配置文件中配置,也支持在环境变量设置OH_KEY_PWD="123456")
|
|
76
|
+
|
|
77
|
+
storeFile: 本地秘钥地址
|
|
78
|
+
|
|
79
|
+
storePassword: 本地秘钥密码。(既可以在配置文件中配置,也支持在环境变量设置OH_STORE_PWD="123456")
|
|
80
|
+
|
|
81
|
+
**申请方式:**首先创建storeFile([创建方式链接](https://developer.huawei.com/consumer/cn/doc/harmonyos-guides/ide-signing#section462703710326)),然后申certPath和profile([创建方式链接](https://developer.huawei.com/consumer/cn/doc/app/agc-help-add-debugcert-0000001914263178))
|
|
82
|
+
|
|
83
|
+
#### 3.4 原生模块
|
|
84
|
+
|
|
85
|
+
如果electron工程中使用了原生模块,需要自行进行交叉编译后,将编译后的产物重新放回electron工程的node_modules相应的模块中,electron-builder会在打包时将编译后的产物打包到对应的位置。
|
|
86
|
+
|
|
87
|
+
#### 3.5 权限配置
|
|
88
|
+
|
|
89
|
+
如果electron工程中用到了electron框架不具备的权限,需要在ohos节点添加requestPermissions配置项:
|
|
90
|
+
|
|
91
|
+
```json
|
|
92
|
+
"ohos": {
|
|
93
|
+
"requestPermissions": [
|
|
94
|
+
{
|
|
95
|
+
"name": "ohos.permission.xxx",
|
|
96
|
+
"reason": "xxx",
|
|
97
|
+
"usedScene": {
|
|
98
|
+
"abilities": [
|
|
99
|
+
"FormAbility"
|
|
100
|
+
],
|
|
101
|
+
"when": "always"
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
#### 3.6 基本信息配置
|
|
111
|
+
|
|
112
|
+
appId(必填): 应用ID,会映射到hap包的bundleName,格式xx.xx.xx(必填)。
|
|
113
|
+
|
|
114
|
+
productName:产品名称,映射到hap包的应用名称,如果为空,则取name值。
|
|
115
|
+
|
|
116
|
+
icon:应用图标,如果不设置,将使用electron默认图标。
|
|
117
|
+
|
|
118
|
+
#### 3.7 配置项总结
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
{
|
|
122
|
+
"name": "helloworld",
|
|
123
|
+
"version": "1.0.0",
|
|
124
|
+
"description": "",
|
|
125
|
+
"license": "ISC",
|
|
126
|
+
"author": "",
|
|
127
|
+
"type": "commonjs",
|
|
128
|
+
"main": "index.js",
|
|
129
|
+
"scripts": {
|
|
130
|
+
"app:dir": "electron-builder --dir",
|
|
131
|
+
"app:dist": "electron-builder",
|
|
132
|
+
"build": "npm run build:renderer && npm run build:main",
|
|
133
|
+
"build:renderer": "webpack --config webpack.renderer.config.js",
|
|
134
|
+
"build:main": "webpack --config webpack.main.config.js",
|
|
135
|
+
"dist:ohos": "electron-builder --ohos",
|
|
136
|
+
"start": "electron .",
|
|
137
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
138
|
+
},
|
|
139
|
+
"build": {
|
|
140
|
+
"appId": "com.example.helloworld",
|
|
141
|
+
"productName": "HelloWorld",
|
|
142
|
+
"ohos": {
|
|
143
|
+
"icon": "./heart.png",
|
|
144
|
+
"target": [
|
|
145
|
+
"hap"
|
|
146
|
+
],
|
|
147
|
+
"hvigorwPath": "D:/software/DevEco/deveco-studio-5.1.1.406SP1.win/devecostudio/tools/hvigor/bin",
|
|
148
|
+
"ohpmPath": "D:/software/DevEco/deveco-studio-5.1.1.406SP1.win/devecostudio/tools/ohpm/bin",
|
|
149
|
+
"sdkPath": "D:/software/DevEco/deveco-studio-5.1.1.406SP1.win/deveco-studio/sdk",
|
|
150
|
+
"certPath": "D:/cert/debug.cer",
|
|
151
|
+
"profile": "D:/cert/helloworld.p7b",
|
|
152
|
+
"keyAlias": "helloworld",
|
|
153
|
+
"keyPassword": "123456",
|
|
154
|
+
"storeFile": "D:/cert/helloworld.p12",
|
|
155
|
+
"storePassword": "123456",
|
|
156
|
+
"requestPermissions": [
|
|
157
|
+
{
|
|
158
|
+
"name": "ohos.permission.xxx",
|
|
159
|
+
"reason": "xxx",
|
|
160
|
+
"usedScene": {
|
|
161
|
+
"abilities": [
|
|
162
|
+
"FormAbility"
|
|
163
|
+
],
|
|
164
|
+
"when": "always"
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"devDependencies": {
|
|
171
|
+
|
|
172
|
+
},
|
|
173
|
+
"dependencies": {
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### 四、执行打包
|
|
180
|
+
|
|
181
|
+
```shell
|
|
182
|
+
npm run dist:ohos
|
|
183
|
+
```
|
|
184
|
+
|
package/cli.js
ADDED
package/out/builder.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { PackagerOptions, Platform } from "@electron-ohos/app-builder-lib";
|
|
2
|
+
import { Arch } from "builder-util";
|
|
3
|
+
import { PublishOptions } from "electron-publish";
|
|
4
|
+
import * as yargs from "yargs";
|
|
5
|
+
export declare function createYargs(): yargs.Argv<unknown>;
|
|
6
|
+
export interface BuildOptions extends PackagerOptions, PublishOptions {
|
|
7
|
+
}
|
|
8
|
+
export interface CliOptions extends PackagerOptions, PublishOptions {
|
|
9
|
+
x64?: boolean;
|
|
10
|
+
ia32?: boolean;
|
|
11
|
+
armv7l?: boolean;
|
|
12
|
+
arm64?: boolean;
|
|
13
|
+
universal?: boolean;
|
|
14
|
+
dir?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** @private */
|
|
17
|
+
export declare function normalizeOptions(args: CliOptions): BuildOptions;
|
|
18
|
+
/** @private */
|
|
19
|
+
export declare function coerceTypes(host: any): any;
|
|
20
|
+
export declare function createTargets(platforms: Array<Platform>, type?: string | null, arch?: string | null): Map<Platform, Map<Arch, Array<string>>>;
|
|
21
|
+
export declare function build(rawOptions?: CliOptions): Promise<Array<string>>;
|
|
22
|
+
/**
|
|
23
|
+
* @private
|
|
24
|
+
*/
|
|
25
|
+
export declare function configureBuildCommand(yargs: yargs.Argv): yargs.Argv;
|
package/out/builder.js
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createYargs = createYargs;
|
|
4
|
+
exports.normalizeOptions = normalizeOptions;
|
|
5
|
+
exports.coerceTypes = coerceTypes;
|
|
6
|
+
exports.createTargets = createTargets;
|
|
7
|
+
exports.build = build;
|
|
8
|
+
exports.configureBuildCommand = configureBuildCommand;
|
|
9
|
+
const app_builder_lib_1 = require("@electron-ohos/app-builder-lib");
|
|
10
|
+
const builder_util_1 = require("builder-util");
|
|
11
|
+
const chalk = require("chalk");
|
|
12
|
+
const yargs = require("yargs");
|
|
13
|
+
function createYargs() {
|
|
14
|
+
return yargs.parserConfiguration({
|
|
15
|
+
"camel-case-expansion": false,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/** @private */
|
|
19
|
+
function normalizeOptions(args) {
|
|
20
|
+
if (args.targets != null) {
|
|
21
|
+
return args;
|
|
22
|
+
}
|
|
23
|
+
const targets = new Map();
|
|
24
|
+
function processTargets(platform, types) {
|
|
25
|
+
function commonArch(currentIfNotSpecified) {
|
|
26
|
+
const result = Array();
|
|
27
|
+
if (args.x64) {
|
|
28
|
+
result.push(builder_util_1.Arch.x64);
|
|
29
|
+
}
|
|
30
|
+
if (args.armv7l) {
|
|
31
|
+
result.push(builder_util_1.Arch.armv7l);
|
|
32
|
+
}
|
|
33
|
+
if (args.arm64) {
|
|
34
|
+
result.push(builder_util_1.Arch.arm64);
|
|
35
|
+
}
|
|
36
|
+
if (args.ia32) {
|
|
37
|
+
result.push(builder_util_1.Arch.ia32);
|
|
38
|
+
}
|
|
39
|
+
if (args.universal) {
|
|
40
|
+
result.push(builder_util_1.Arch.universal);
|
|
41
|
+
}
|
|
42
|
+
return result.length === 0 && currentIfNotSpecified ? [(0, builder_util_1.archFromString)(process.arch)] : result;
|
|
43
|
+
}
|
|
44
|
+
let archToType = targets.get(platform);
|
|
45
|
+
if (archToType == null) {
|
|
46
|
+
archToType = new Map();
|
|
47
|
+
targets.set(platform, archToType);
|
|
48
|
+
}
|
|
49
|
+
if (types.length === 0) {
|
|
50
|
+
const defaultTargetValue = args.dir ? [app_builder_lib_1.DIR_TARGET] : [];
|
|
51
|
+
for (const arch of commonArch(args.dir === true)) {
|
|
52
|
+
archToType.set(arch, defaultTargetValue);
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
for (const type of types) {
|
|
57
|
+
const suffixPos = type.lastIndexOf(":");
|
|
58
|
+
if (suffixPos > 0) {
|
|
59
|
+
(0, builder_util_1.addValue)(archToType, (0, builder_util_1.archFromString)(type.substring(suffixPos + 1)), type.substring(0, suffixPos));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
for (const arch of commonArch(true)) {
|
|
63
|
+
(0, builder_util_1.addValue)(archToType, arch, type);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (args.mac != null) {
|
|
69
|
+
processTargets(app_builder_lib_1.Platform.MAC, args.mac);
|
|
70
|
+
}
|
|
71
|
+
if (args.linux != null) {
|
|
72
|
+
processTargets(app_builder_lib_1.Platform.LINUX, args.linux);
|
|
73
|
+
}
|
|
74
|
+
if (args.win != null) {
|
|
75
|
+
processTargets(app_builder_lib_1.Platform.WINDOWS, args.win);
|
|
76
|
+
}
|
|
77
|
+
if (args.ohos != null) {
|
|
78
|
+
processTargets(app_builder_lib_1.Platform.OHOS, args.ohos);
|
|
79
|
+
}
|
|
80
|
+
if (targets.size === 0) {
|
|
81
|
+
processTargets(app_builder_lib_1.Platform.current(), []);
|
|
82
|
+
}
|
|
83
|
+
const result = { ...args };
|
|
84
|
+
result.targets = targets;
|
|
85
|
+
delete result.dir;
|
|
86
|
+
delete result.mac;
|
|
87
|
+
delete result.linux;
|
|
88
|
+
delete result.win;
|
|
89
|
+
const r = result;
|
|
90
|
+
delete r.m;
|
|
91
|
+
delete r.o;
|
|
92
|
+
delete r.l;
|
|
93
|
+
delete r.w;
|
|
94
|
+
delete r.windows;
|
|
95
|
+
delete r.macos;
|
|
96
|
+
delete r.$0;
|
|
97
|
+
delete r._;
|
|
98
|
+
delete r.version;
|
|
99
|
+
delete r.help;
|
|
100
|
+
delete r.c;
|
|
101
|
+
delete r.p;
|
|
102
|
+
delete r.pd;
|
|
103
|
+
delete result.ia32;
|
|
104
|
+
delete result.x64;
|
|
105
|
+
delete result.armv7l;
|
|
106
|
+
delete result.arm64;
|
|
107
|
+
delete result.universal;
|
|
108
|
+
let config = result.config;
|
|
109
|
+
// config is array when combining dot-notation values with a config file value
|
|
110
|
+
// https://github.com/electron-userland/electron-builder/issues/2016
|
|
111
|
+
if (Array.isArray(config)) {
|
|
112
|
+
const newConfig = {};
|
|
113
|
+
for (const configItem of config) {
|
|
114
|
+
if (typeof configItem === "object") {
|
|
115
|
+
(0, builder_util_1.deepAssign)(newConfig, configItem);
|
|
116
|
+
}
|
|
117
|
+
else if (typeof configItem === "string") {
|
|
118
|
+
newConfig.extends = configItem;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
config = newConfig;
|
|
122
|
+
result.config = newConfig;
|
|
123
|
+
}
|
|
124
|
+
// AJV cannot coerce "null" string to null if string is also allowed (because null string is a valid value)
|
|
125
|
+
if (config != null && typeof config !== "string") {
|
|
126
|
+
if (config.extraMetadata != null) {
|
|
127
|
+
coerceTypes(config.extraMetadata);
|
|
128
|
+
}
|
|
129
|
+
// ability to disable code sign using -c.mac.identity=null
|
|
130
|
+
if (config.mac != null) {
|
|
131
|
+
coerceValue(config.mac, "identity");
|
|
132
|
+
}
|
|
133
|
+
// fix Boolean type by coerceTypes
|
|
134
|
+
if (config.nsis != null) {
|
|
135
|
+
coerceTypes(config.nsis);
|
|
136
|
+
}
|
|
137
|
+
if (config.nsisWeb != null) {
|
|
138
|
+
coerceTypes(config.nsisWeb);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if ("project" in r && !("projectDir" in result)) {
|
|
142
|
+
result.projectDir = r.project;
|
|
143
|
+
}
|
|
144
|
+
delete r.project;
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
function coerceValue(host, key) {
|
|
148
|
+
const value = host[key];
|
|
149
|
+
if (value === "true") {
|
|
150
|
+
host[key] = true;
|
|
151
|
+
}
|
|
152
|
+
else if (value === "false") {
|
|
153
|
+
host[key] = false;
|
|
154
|
+
}
|
|
155
|
+
else if (value === "null") {
|
|
156
|
+
host[key] = null;
|
|
157
|
+
}
|
|
158
|
+
else if (key === "version" && typeof value === "number") {
|
|
159
|
+
host[key] = value.toString();
|
|
160
|
+
}
|
|
161
|
+
else if (value != null && typeof value === "object") {
|
|
162
|
+
coerceTypes(value);
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
/** @private */
|
|
166
|
+
function coerceTypes(host) {
|
|
167
|
+
for (const key of Object.getOwnPropertyNames(host)) {
|
|
168
|
+
coerceValue(host, key);
|
|
169
|
+
}
|
|
170
|
+
return host;
|
|
171
|
+
}
|
|
172
|
+
function createTargets(platforms, type, arch) {
|
|
173
|
+
const targets = new Map();
|
|
174
|
+
for (const platform of platforms) {
|
|
175
|
+
const archs = arch === "all" ? (platform === app_builder_lib_1.Platform.MAC ? [builder_util_1.Arch.x64, builder_util_1.Arch.arm64, builder_util_1.Arch.universal] : [builder_util_1.Arch.x64, builder_util_1.Arch.ia32]) : [(0, builder_util_1.archFromString)(arch == null ? process.arch : arch)];
|
|
176
|
+
const archToType = new Map();
|
|
177
|
+
targets.set(platform, archToType);
|
|
178
|
+
for (const arch of archs) {
|
|
179
|
+
archToType.set(arch, type == null ? [] : [type]);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return targets;
|
|
183
|
+
}
|
|
184
|
+
function build(rawOptions) {
|
|
185
|
+
const buildOptions = normalizeOptions(rawOptions || {});
|
|
186
|
+
return (0, app_builder_lib_1.build)(buildOptions, new app_builder_lib_1.Packager(buildOptions));
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* @private
|
|
190
|
+
*/
|
|
191
|
+
function configureBuildCommand(yargs) {
|
|
192
|
+
const publishGroup = "Publishing:";
|
|
193
|
+
const buildGroup = "Building:";
|
|
194
|
+
return yargs
|
|
195
|
+
.option("mac", {
|
|
196
|
+
group: buildGroup,
|
|
197
|
+
alias: ["m", "o", "macos"],
|
|
198
|
+
description: `Build for macOS, accepts target list (see ${chalk.underline("https://www.electron.build/mac")}).`,
|
|
199
|
+
type: "array",
|
|
200
|
+
})
|
|
201
|
+
.option("linux", {
|
|
202
|
+
group: buildGroup,
|
|
203
|
+
alias: "l",
|
|
204
|
+
description: `Build for Linux, accepts target list (see ${chalk.underline("https://www.electron.build/linux")})`,
|
|
205
|
+
type: "array",
|
|
206
|
+
})
|
|
207
|
+
.option("win", {
|
|
208
|
+
group: buildGroup,
|
|
209
|
+
alias: ["w", "windows"],
|
|
210
|
+
description: `Build for Windows, accepts target list (see ${chalk.underline("https://www.electron.build/win")})`,
|
|
211
|
+
type: "array",
|
|
212
|
+
})
|
|
213
|
+
.option("ohos", {
|
|
214
|
+
group: buildGroup,
|
|
215
|
+
alias: "ohos",
|
|
216
|
+
description: `Build for OpenHarmony`,
|
|
217
|
+
type: "array",
|
|
218
|
+
})
|
|
219
|
+
.option("x64", {
|
|
220
|
+
group: buildGroup,
|
|
221
|
+
description: "Build for x64",
|
|
222
|
+
type: "boolean",
|
|
223
|
+
})
|
|
224
|
+
.option("ia32", {
|
|
225
|
+
group: buildGroup,
|
|
226
|
+
description: "Build for ia32",
|
|
227
|
+
type: "boolean",
|
|
228
|
+
})
|
|
229
|
+
.option("armv7l", {
|
|
230
|
+
group: buildGroup,
|
|
231
|
+
description: "Build for armv7l",
|
|
232
|
+
type: "boolean",
|
|
233
|
+
})
|
|
234
|
+
.option("arm64", {
|
|
235
|
+
group: buildGroup,
|
|
236
|
+
description: "Build for arm64",
|
|
237
|
+
type: "boolean",
|
|
238
|
+
})
|
|
239
|
+
.option("universal", {
|
|
240
|
+
group: buildGroup,
|
|
241
|
+
description: "Build for universal",
|
|
242
|
+
type: "boolean",
|
|
243
|
+
})
|
|
244
|
+
.option("dir", {
|
|
245
|
+
group: buildGroup,
|
|
246
|
+
description: "Build unpacked dir. Useful to test.",
|
|
247
|
+
type: "boolean",
|
|
248
|
+
})
|
|
249
|
+
.option("publish", {
|
|
250
|
+
group: publishGroup,
|
|
251
|
+
alias: "p",
|
|
252
|
+
description: `Publish artifacts, see ${chalk.underline("https://www.electron.build/publish")}`,
|
|
253
|
+
choices: ["onTag", "onTagOrDraft", "always", "never", undefined],
|
|
254
|
+
})
|
|
255
|
+
.option("prepackaged", {
|
|
256
|
+
alias: ["pd"],
|
|
257
|
+
group: buildGroup,
|
|
258
|
+
description: "The path to prepackaged app (to pack in a distributable format)",
|
|
259
|
+
})
|
|
260
|
+
.option("projectDir", {
|
|
261
|
+
alias: ["project"],
|
|
262
|
+
group: buildGroup,
|
|
263
|
+
description: "The path to project directory. Defaults to current working directory.",
|
|
264
|
+
})
|
|
265
|
+
.option("config", {
|
|
266
|
+
alias: ["c"],
|
|
267
|
+
group: buildGroup,
|
|
268
|
+
description: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see " +
|
|
269
|
+
chalk.underline("https://www.electron.build/configuration"),
|
|
270
|
+
})
|
|
271
|
+
.group(["help", "version"], "Other:")
|
|
272
|
+
.example("electron-builder -mwl", "build for macOS, Windows and Linux")
|
|
273
|
+
.example("electron-builder --linux deb tar.xz", "build deb and tar.xz for Linux")
|
|
274
|
+
.example("electron-builder --win --ia32", "build for Windows ia32")
|
|
275
|
+
.example("electron-builder -c.extraMetadata.foo=bar", "set package.json property `foo` to `bar`")
|
|
276
|
+
.example("electron-builder --config.nsis.unicode=false", "configure unicode options for NSIS");
|
|
277
|
+
}
|
|
278
|
+
//# sourceMappingURL=builder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../src/builder.ts"],"names":[],"mappings":";;AAMA,kCAIC;AAeD,4CAoJC;AAkBD,kCAKC;AAED,sCAaC;AAED,sBAGC;AAKD,sDAuFC;AApTD,oEAAgI;AAChI,+CAAyE;AACzE,+BAA8B;AAE9B,+BAA8B;AAE9B,SAAgB,WAAW;IACzB,OAAO,KAAK,CAAC,mBAAmB,CAAC;QAC/B,sBAAsB,EAAE,KAAK;KAC9B,CAAC,CAAA;AACJ,CAAC;AAcD,eAAe;AACf,SAAgB,gBAAgB,CAAC,IAAgB;IAC/C,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsC,CAAA;IAE7D,SAAS,cAAc,CAAC,QAAkB,EAAE,KAAoB;QAC9D,SAAS,UAAU,CAAC,qBAA8B;YAChD,MAAM,MAAM,GAAG,KAAK,EAAQ,CAAA;YAC5B,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,CAAC,mBAAI,CAAC,GAAG,CAAC,CAAA;YACvB,CAAC;YACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,MAAM,CAAC,IAAI,CAAC,mBAAI,CAA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C/E,CAAC;SACD,MAAM,CAAC,YAAY,EAAE;QACpB,KAAK,EAAE,CAAC,SAAS,CAAC;QAClB,KAAK,EAAE,UAAU;QACjB,WAAW,EAAE,uEAAuE;KACrF,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,KAAK,EAAE,UAAU;QACjB,WAAW,EACT,4HAA4H;YAC5H,KAAK,CAAC,SAAS,CAAC,0CAA0C,CAAC;KAC9D,CAAC;SACD,KAAK,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,QAAQ,CAAC;SACpC,OAAO,CAAC,uBAAuB,EAAE,oCAAoC,CAAC;SACtE,OAAO,CAAC,qCAAqC,EAAE,gCAAgC,CAAC;SAChF,OAAO,CAAC,+BAA+B,EAAE,wBAAwB,CAAC;SAClE,OAAO,CAAC,2CAA2C,EAAE,0CAA0C,CAAC;SAChG,OAAO,CAAC,8CAA8C,EAAE,oCAAoC,CAAC,CAAA;AAClG,CAAC","sourcesContent":["import { build as _build, Configuration, DIR_TARGET, Packager, PackagerOptions, Platform } from \"@electron-ohos/app-builder-lib\"\r\nimport { addValue, Arch, archFromString, deepAssign } from \"builder-util\"\r\nimport * as chalk from \"chalk\"\r\nimport { PublishOptions } from \"electron-publish\"\r\nimport * as yargs from \"yargs\"\r\n\r\nexport function createYargs(): yargs.Argv<unknown> {\r\n return yargs.parserConfiguration({\r\n \"camel-case-expansion\": false,\r\n })\r\n}\r\n\r\nexport interface BuildOptions extends PackagerOptions, PublishOptions {}\r\n\r\nexport interface CliOptions extends PackagerOptions, PublishOptions {\r\n x64?: boolean\r\n ia32?: boolean\r\n armv7l?: boolean\r\n arm64?: boolean\r\n universal?: boolean\r\n\r\n dir?: boolean\r\n}\r\n\r\n/** @private */\r\nexport function normalizeOptions(args: CliOptions): BuildOptions {\r\n if (args.targets != null) {\r\n return args\r\n }\r\n\r\n const targets = new Map<Platform, Map<Arch, Array<string>>>()\r\n\r\n function processTargets(platform: Platform, types: Array<string>) {\r\n function commonArch(currentIfNotSpecified: boolean): Array<Arch> {\r\n const result = Array<Arch>()\r\n if (args.x64) {\r\n result.push(Arch.x64)\r\n }\r\n if (args.armv7l) {\r\n result.push(Arch.armv7l)\r\n }\r\n if (args.arm64) {\r\n result.push(Arch.arm64)\r\n }\r\n if (args.ia32) {\r\n result.push(Arch.ia32)\r\n }\r\n if (args.universal) {\r\n result.push(Arch.universal)\r\n }\r\n\r\n return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result\r\n }\r\n\r\n let archToType = targets.get(platform)\r\n if (archToType == null) {\r\n archToType = new Map<Arch, Array<string>>()\r\n targets.set(platform, archToType)\r\n }\r\n\r\n if (types.length === 0) {\r\n const defaultTargetValue = args.dir ? [DIR_TARGET] : []\r\n for (const arch of commonArch(args.dir === true)) {\r\n archToType.set(arch, defaultTargetValue)\r\n }\r\n return\r\n }\r\n\r\n for (const type of types) {\r\n const suffixPos = type.lastIndexOf(\":\")\r\n if (suffixPos > 0) {\r\n addValue(archToType, archFromString(type.substring(suffixPos + 1)), type.substring(0, suffixPos))\r\n } else {\r\n for (const arch of commonArch(true)) {\r\n addValue(archToType, arch, type)\r\n }\r\n }\r\n }\r\n }\r\n\r\n if (args.mac != null) {\r\n processTargets(Platform.MAC, args.mac)\r\n }\r\n\r\n if (args.linux != null) {\r\n processTargets(Platform.LINUX, args.linux)\r\n }\r\n\r\n if (args.win != null) {\r\n processTargets(Platform.WINDOWS, args.win)\r\n }\r\n\r\n if (args.ohos != null) {\r\n processTargets(Platform.OHOS, args.ohos)\r\n }\r\n\r\n if (targets.size === 0) {\r\n processTargets(Platform.current(), [])\r\n }\r\n\r\n const result: any = { ...args }\r\n result.targets = targets\r\n\r\n delete result.dir\r\n delete result.mac\r\n delete result.linux\r\n delete result.win\r\n\r\n const r = result\r\n delete r.m\r\n delete r.o\r\n delete r.l\r\n delete r.w\r\n delete r.windows\r\n delete r.macos\r\n delete r.$0\r\n delete r._\r\n delete r.version\r\n delete r.help\r\n delete r.c\r\n delete r.p\r\n delete r.pd\r\n\r\n delete result.ia32\r\n delete result.x64\r\n delete result.armv7l\r\n delete result.arm64\r\n delete result.universal\r\n\r\n let config = result.config\r\n\r\n // config is array when combining dot-notation values with a config file value\r\n // https://github.com/electron-userland/electron-builder/issues/2016\r\n if (Array.isArray(config)) {\r\n const newConfig: Configuration = {}\r\n for (const configItem of config) {\r\n if (typeof configItem === \"object\") {\r\n deepAssign(newConfig, configItem)\r\n } else if (typeof configItem === \"string\") {\r\n newConfig.extends = configItem\r\n }\r\n }\r\n\r\n config = newConfig\r\n result.config = newConfig\r\n }\r\n\r\n // AJV cannot coerce \"null\" string to null if string is also allowed (because null string is a valid value)\r\n if (config != null && typeof config !== \"string\") {\r\n if (config.extraMetadata != null) {\r\n coerceTypes(config.extraMetadata)\r\n }\r\n\r\n // ability to disable code sign using -c.mac.identity=null\r\n if (config.mac != null) {\r\n coerceValue(config.mac, \"identity\")\r\n }\r\n\r\n // fix Boolean type by coerceTypes\r\n if (config.nsis != null) {\r\n coerceTypes(config.nsis)\r\n }\r\n if (config.nsisWeb != null) {\r\n coerceTypes(config.nsisWeb)\r\n }\r\n }\r\n\r\n if (\"project\" in r && !(\"projectDir\" in result)) {\r\n result.projectDir = r.project\r\n }\r\n delete r.project\r\n\r\n return result as BuildOptions\r\n}\r\n\r\nfunction coerceValue(host: any, key: string): void {\r\n const value = host[key]\r\n if (value === \"true\") {\r\n host[key] = true\r\n } else if (value === \"false\") {\r\n host[key] = false\r\n } else if (value === \"null\") {\r\n host[key] = null\r\n } else if (key === \"version\" && typeof value === \"number\") {\r\n host[key] = value.toString()\r\n } else if (value != null && typeof value === \"object\") {\r\n coerceTypes(value)\r\n }\r\n}\r\n\r\n/** @private */\r\nexport function coerceTypes(host: any): any {\r\n for (const key of Object.getOwnPropertyNames(host)) {\r\n coerceValue(host, key)\r\n }\r\n return host\r\n}\r\n\r\nexport function createTargets(platforms: Array<Platform>, type?: string | null, arch?: string | null): Map<Platform, Map<Arch, Array<string>>> {\r\n const targets = new Map<Platform, Map<Arch, Array<string>>>()\r\n for (const platform of platforms) {\r\n const archs =\r\n arch === \"all\" ? (platform === Platform.MAC ? [Arch.x64, Arch.arm64, Arch.universal] : [Arch.x64, Arch.ia32]) : [archFromString(arch == null ? process.arch : arch)]\r\n const archToType = new Map<Arch, Array<string>>()\r\n targets.set(platform, archToType)\r\n\r\n for (const arch of archs) {\r\n archToType.set(arch, type == null ? [] : [type])\r\n }\r\n }\r\n return targets\r\n}\r\n\r\nexport function build(rawOptions?: CliOptions): Promise<Array<string>> {\r\n const buildOptions = normalizeOptions(rawOptions || {})\r\n return _build(buildOptions, new Packager(buildOptions))\r\n}\r\n\r\n/**\r\n * @private\r\n */\r\nexport function configureBuildCommand(yargs: yargs.Argv): yargs.Argv {\r\n const publishGroup = \"Publishing:\"\r\n const buildGroup = \"Building:\"\r\n return yargs\r\n .option(\"mac\", {\r\n group: buildGroup,\r\n alias: [\"m\", \"o\", \"macos\"],\r\n description: `Build for macOS, accepts target list (see ${chalk.underline(\"https://www.electron.build/mac\")}).`,\r\n type: \"array\",\r\n })\r\n .option(\"linux\", {\r\n group: buildGroup,\r\n alias: \"l\",\r\n description: `Build for Linux, accepts target list (see ${chalk.underline(\"https://www.electron.build/linux\")})`,\r\n type: \"array\",\r\n })\r\n .option(\"win\", {\r\n group: buildGroup,\r\n alias: [\"w\", \"windows\"],\r\n description: `Build for Windows, accepts target list (see ${chalk.underline(\"https://www.electron.build/win\")})`,\r\n type: \"array\",\r\n })\r\n .option(\"ohos\", {\r\n group: buildGroup,\r\n alias: \"ohos\",\r\n description: `Build for OpenHarmony`,\r\n type: \"array\",\r\n })\r\n .option(\"x64\", {\r\n group: buildGroup,\r\n description: \"Build for x64\",\r\n type: \"boolean\",\r\n })\r\n .option(\"ia32\", {\r\n group: buildGroup,\r\n description: \"Build for ia32\",\r\n type: \"boolean\",\r\n })\r\n .option(\"armv7l\", {\r\n group: buildGroup,\r\n description: \"Build for armv7l\",\r\n type: \"boolean\",\r\n })\r\n .option(\"arm64\", {\r\n group: buildGroup,\r\n description: \"Build for arm64\",\r\n type: \"boolean\",\r\n })\r\n .option(\"universal\", {\r\n group: buildGroup,\r\n description: \"Build for universal\",\r\n type: \"boolean\",\r\n })\r\n .option(\"dir\", {\r\n group: buildGroup,\r\n description: \"Build unpacked dir. Useful to test.\",\r\n type: \"boolean\",\r\n })\r\n .option(\"publish\", {\r\n group: publishGroup,\r\n alias: \"p\",\r\n description: `Publish artifacts, see ${chalk.underline(\"https://www.electron.build/publish\")}`,\r\n choices: [\"onTag\", \"onTagOrDraft\", \"always\", \"never\", undefined as any],\r\n })\r\n .option(\"prepackaged\", {\r\n alias: [\"pd\"],\r\n group: buildGroup,\r\n description: \"The path to prepackaged app (to pack in a distributable format)\",\r\n })\r\n .option(\"projectDir\", {\r\n alias: [\"project\"],\r\n group: buildGroup,\r\n description: \"The path to project directory. Defaults to current working directory.\",\r\n })\r\n .option(\"config\", {\r\n alias: [\"c\"],\r\n group: buildGroup,\r\n description:\r\n \"The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see \" +\r\n chalk.underline(\"https://www.electron.build/configuration\"),\r\n })\r\n .group([\"help\", \"version\"], \"Other:\")\r\n .example(\"electron-builder -mwl\", \"build for macOS, Windows and Linux\")\r\n .example(\"electron-builder --linux deb tar.xz\", \"build deb and tar.xz for Linux\")\r\n .example(\"electron-builder --win --ia32\", \"build for Windows ia32\")\r\n .example(\"electron-builder -c.extraMetadata.foo=bar\", \"set package.json property `foo` to `bar`\")\r\n .example(\"electron-builder --config.nsis.unicode=false\", \"configure unicode options for NSIS\")\r\n}\r\n"]}
|
package/out/cli/cli.d.ts
ADDED
package/out/cli/cli.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const electronVersion_1 = require("@electron-ohos/app-builder-lib/out/electron/electronVersion");
|
|
5
|
+
const load_1 = require("@electron-ohos/app-builder-lib/out/util/config/load");
|
|
6
|
+
const yarn_1 = require("@electron-ohos/app-builder-lib/out/util/yarn");
|
|
7
|
+
const builder_util_1 = require("builder-util");
|
|
8
|
+
const chalk = require("chalk");
|
|
9
|
+
const fs_extra_1 = require("fs-extra");
|
|
10
|
+
const ci_info_1 = require("ci-info");
|
|
11
|
+
const path = require("path");
|
|
12
|
+
const builder_1 = require("../builder");
|
|
13
|
+
const publish_1 = require("../publish");
|
|
14
|
+
const create_self_signed_cert_1 = require("./create-self-signed-cert");
|
|
15
|
+
const install_app_deps_1 = require("./install-app-deps");
|
|
16
|
+
const start_1 = require("./start");
|
|
17
|
+
// tslint:disable:no-unused-expression
|
|
18
|
+
void (0, builder_1.createYargs)()
|
|
19
|
+
.command(["build", "*"], "Build", builder_1.configureBuildCommand, wrap(builder_1.build))
|
|
20
|
+
.command("install-app-deps", "Install app deps", install_app_deps_1.configureInstallAppDepsCommand, wrap(install_app_deps_1.installAppDeps))
|
|
21
|
+
.command("node-gyp-rebuild", "Rebuild own native code", install_app_deps_1.configureInstallAppDepsCommand /* yes, args the same as for install app deps */, wrap(rebuildAppNativeCode))
|
|
22
|
+
.command("publish", "Publish a list of artifacts", publish_1.configurePublishCommand, wrap(publish_1.publish))
|
|
23
|
+
.command("create-self-signed-cert", "Create self-signed code signing cert for Windows apps", yargs => yargs
|
|
24
|
+
.option("publisher", {
|
|
25
|
+
alias: ["p"],
|
|
26
|
+
type: "string",
|
|
27
|
+
requiresArg: true,
|
|
28
|
+
description: "The publisher name",
|
|
29
|
+
})
|
|
30
|
+
.demandOption("publisher"), wrap(argv => (0, create_self_signed_cert_1.createSelfSignedCert)(argv.publisher)))
|
|
31
|
+
.command("start", "Run application in a development mode using electron-webpack", yargs => yargs, wrap(() => (0, start_1.start)()))
|
|
32
|
+
.help()
|
|
33
|
+
.epilog(`See ${chalk.underline("https://electron.build")} for more documentation.`)
|
|
34
|
+
.strict()
|
|
35
|
+
.recommendCommands().argv;
|
|
36
|
+
function wrap(task) {
|
|
37
|
+
return (args) => {
|
|
38
|
+
checkIsOutdated().catch((e) => builder_util_1.log.warn({ error: e }, "cannot check updates"));
|
|
39
|
+
(0, load_1.loadEnv)(path.join(process.cwd(), "electron-builder.env"))
|
|
40
|
+
.then(() => task(args))
|
|
41
|
+
.catch(error => {
|
|
42
|
+
process.exitCode = 1;
|
|
43
|
+
// https://github.com/electron-userland/electron-builder/issues/2940
|
|
44
|
+
process.on("exit", () => (process.exitCode = 1));
|
|
45
|
+
if (error instanceof builder_util_1.InvalidConfigurationError) {
|
|
46
|
+
builder_util_1.log.error(null, error.message);
|
|
47
|
+
}
|
|
48
|
+
else if (!(error instanceof builder_util_1.ExecError) || !error.alreadyLogged) {
|
|
49
|
+
builder_util_1.log.error({ failedTask: task.name, stackTrace: error.stack }, error.message);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
async function checkIsOutdated() {
|
|
55
|
+
if (ci_info_1.isCI || process.env.NO_UPDATE_NOTIFIER != null) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const pkg = await (0, fs_extra_1.readJson)(path.join(__dirname, "..", "..", "package.json"));
|
|
59
|
+
if (pkg.version === "0.0.0-semantic-release") {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const UpdateNotifier = require("simple-update-notifier");
|
|
63
|
+
await UpdateNotifier({ pkg });
|
|
64
|
+
}
|
|
65
|
+
async function rebuildAppNativeCode(args) {
|
|
66
|
+
const projectDir = process.cwd();
|
|
67
|
+
// this script must be used only for electron
|
|
68
|
+
return (0, yarn_1.nodeGypRebuild)(args.platform, args.arch, { version: await (0, electronVersion_1.getElectronVersion)(projectDir), useCustomDist: true });
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 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AAG,CAAC,kBAAkB,IAAI,IAAI,EAAE,CAAC;QACnD,OAAM;IACR,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAA;IAC5E,IAAI,GAAG,CAAC,OAAO,KAAK,wBAAwB,EAAE,CAAC;QAC7C,OAAM;IACR,CAAC;IACD,MAAM,cAAc,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;IACxD,MAAM,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAA;AAC/B,CAAC;AAED,KAAK,UAAU,oBAAoB,CAAC,IAAS;IAC3C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAChC,6CAA6C;IAC7C,OAAO,IAAA,qBAAc,EAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,MAAM,IAAA,oCAAkB,EAAC,UAAU,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAA;AACzH,CAAC","sourcesContent":["#! /usr/bin/env node\r\n\r\nimport { getElectronVersion } from \"@electron-ohos/app-builder-lib/out/electron/electronVersion\"\r\nimport { loadEnv } from \"@electron-ohos/app-builder-lib/out/util/config/load\"\r\nimport { nodeGypRebuild } from \"@electron-ohos/app-builder-lib/out/util/yarn\"\r\nimport { ExecError, InvalidConfigurationError, log } from \"builder-util\"\r\nimport * as chalk from \"chalk\"\r\nimport { readJson } from \"fs-extra\"\r\nimport { isCI } from \"ci-info\"\r\nimport * as path from \"path\"\r\nimport { build, configureBuildCommand, createYargs } from \"../builder\"\r\nimport { configurePublishCommand, publish } from \"../publish\"\r\nimport { createSelfSignedCert } from \"./create-self-signed-cert\"\r\nimport { configureInstallAppDepsCommand, installAppDeps } from \"./install-app-deps\"\r\nimport { start } from \"./start\"\r\n\r\n// tslint:disable:no-unused-expression\r\nvoid createYargs()\r\n .command([\"build\", \"*\"], \"Build\", configureBuildCommand, wrap(build))\r\n .command(\"install-app-deps\", \"Install app deps\", configureInstallAppDepsCommand, wrap(installAppDeps))\r\n .command(\"node-gyp-rebuild\", \"Rebuild own native code\", configureInstallAppDepsCommand /* yes, args the same as for install app deps */, wrap(rebuildAppNativeCode))\r\n .command(\"publish\", \"Publish a list of artifacts\", configurePublishCommand, wrap(publish))\r\n .command(\r\n \"create-self-signed-cert\",\r\n \"Create self-signed code signing cert for Windows apps\",\r\n yargs =>\r\n yargs\r\n .option(\"publisher\", {\r\n alias: [\"p\"],\r\n type: \"string\",\r\n requiresArg: true,\r\n description: \"The publisher name\",\r\n })\r\n .demandOption(\"publisher\"),\r\n wrap(argv => createSelfSignedCert(argv.publisher))\r\n )\r\n .command(\r\n \"start\",\r\n \"Run application in a development mode using electron-webpack\",\r\n yargs => yargs,\r\n wrap(() => start())\r\n )\r\n .help()\r\n .epilog(`See ${chalk.underline(\"https://electron.build\")} for more documentation.`)\r\n .strict()\r\n .recommendCommands().argv\r\n\r\nfunction wrap(task: (args: any) => Promise<any>) {\r\n return (args: any) => {\r\n checkIsOutdated().catch((e: any) => log.warn({ error: e }, \"cannot check updates\"))\r\n loadEnv(path.join(process.cwd(), \"electron-builder.env\"))\r\n .then(() => task(args))\r\n .catch(error => {\r\n process.exitCode = 1\r\n // https://github.com/electron-userland/electron-builder/issues/2940\r\n process.on(\"exit\", () => (process.exitCode = 1))\r\n if (error instanceof InvalidConfigurationError) {\r\n log.error(null, error.message)\r\n } else if (!(error instanceof ExecError) || !error.alreadyLogged) {\r\n log.error({ failedTask: task.name, stackTrace: error.stack }, error.message)\r\n }\r\n })\r\n }\r\n}\r\n\r\nasync function checkIsOutdated() {\r\n if (isCI || process.env.NO_UPDATE_NOTIFIER != null) {\r\n return\r\n }\r\n\r\n const pkg = await readJson(path.join(__dirname, \"..\", \"..\", \"package.json\"))\r\n if (pkg.version === \"0.0.0-semantic-release\") {\r\n return\r\n }\r\n const UpdateNotifier = require(\"simple-update-notifier\")\r\n await UpdateNotifier({ pkg })\r\n}\r\n\r\nasync function rebuildAppNativeCode(args: any) {\r\n const projectDir = process.cwd()\r\n // this script must be used only for electron\r\n return nodeGypRebuild(args.platform, args.arch, { version: await getElectronVersion(projectDir), useCustomDist: true })\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createSelfSignedCert = createSelfSignedCert;
|
|
4
|
+
const windows_1 = require("@electron-ohos/app-builder-lib/out/toolsets/windows");
|
|
5
|
+
const builder_util_1 = require("builder-util");
|
|
6
|
+
const filename_1 = require("builder-util/out/filename");
|
|
7
|
+
const chalk = require("chalk");
|
|
8
|
+
const promises_1 = require("fs/promises");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
/** @internal */
|
|
11
|
+
async function createSelfSignedCert(publisher) {
|
|
12
|
+
const tmpDir = new builder_util_1.TmpDir("create-self-signed-cert");
|
|
13
|
+
const targetDir = process.cwd();
|
|
14
|
+
const tempPrefix = path.join(await tmpDir.getTempDir({ prefix: "self-signed-cert-creator" }), (0, filename_1.sanitizeFileName)(publisher));
|
|
15
|
+
const cer = `${tempPrefix}.cer`;
|
|
16
|
+
const pvk = `${tempPrefix}.pvk`;
|
|
17
|
+
builder_util_1.log.info(chalk.bold('When asked to enter a password ("Create Private Key Password"), please select "None".'));
|
|
18
|
+
try {
|
|
19
|
+
await (0, promises_1.mkdir)(path.dirname(tempPrefix), { recursive: true });
|
|
20
|
+
const vendorPath = (await (0, windows_1.getWindowsKitsBundle)({ winCodeSign: null, arch: (0, builder_util_1.archFromString)(process.arch) })).kit;
|
|
21
|
+
await (0, builder_util_1.exec)(path.join(vendorPath, "makecert.exe"), ["-r", "-h", "0", "-n", `CN=${quoteString(publisher)}`, "-eku", "1.3.6.1.5.5.7.3.3", "-pe", "-sv", pvk, cer]);
|
|
22
|
+
const pfx = path.join(targetDir, `${(0, filename_1.sanitizeFileName)(publisher)}.pfx`);
|
|
23
|
+
await (0, builder_util_1.unlinkIfExists)(pfx);
|
|
24
|
+
await (0, builder_util_1.exec)(path.join(vendorPath, "pvk2pfx.exe"), ["-pvk", pvk, "-spc", cer, "-pfx", pfx]);
|
|
25
|
+
builder_util_1.log.info({ file: pfx }, `created. Please see https://electron.build/code-signing how to use it to sign.`);
|
|
26
|
+
const certLocation = "Cert:\\LocalMachine\\TrustedPeople";
|
|
27
|
+
builder_util_1.log.info({ file: pfx, certLocation }, `importing. Operation will be succeed only if runned from root. Otherwise import file manually.`);
|
|
28
|
+
await (0, builder_util_1.spawn)("powershell.exe", ["-NoProfile", "-NonInteractive", "-Command", "Import-PfxCertificate", "-FilePath", `"${pfx}"`, "-CertStoreLocation", certLocation]);
|
|
29
|
+
}
|
|
30
|
+
finally {
|
|
31
|
+
await tmpDir.cleanup();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function quoteString(s) {
|
|
35
|
+
if (!s.includes(",") && !s.includes('"')) {
|
|
36
|
+
return s;
|
|
37
|
+
}
|
|
38
|
+
return `"${s.replace(/"/g, '\\"')}"`;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=create-self-signed-cert.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-self-signed-cert.js","sourceRoot":"","sources":["../../src/cli/create-self-signed-cert.ts"],"names":[],"mappings":";;AAQA,oDAyBC;AAjCD,iFAA0F;AAC1F,+CAAuF;AACvF,wDAA4D;AAC5D,+BAA8B;AAC9B,0CAAmC;AACnC,6BAA4B;AAE5B,gBAAgB;AACT,KAAK,UAAU,oBAAoB,CAAC,SAAiB;IAC1D,MAAM,MAAM,GAAG,IAAI,qBAAM,CAAC,yBAAyB,CAAC,CAAA;IACpD,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,EAAE,CAAA;IAC/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E,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;QACzF,kBAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,gFAAgF,CAAC,CAAA;QAEzG,MAAM,YAAY,GAAG,oCAAoC,CAAA;QACzD,kBAAG,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,YAAY,EAAE,EAAE,iGAAiG,CAAC,CAAA;QACxI,MAAM,IAAA,oBAAK,EAAC,gBAAgB,EAAE,CAAC,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,uBAAuB,EAAE,WAAW,EAAE,IAAI,GAAG,GAAG,EAAE,oBAAoB,EAAE,YAAY,CAAC,CAAC,CAAA;IACpK,CAAC;YAAS,CAAC;QACT,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;IACxB,CAAC;AACH,CAAC;AAED,SAAS,WAAW,CAAC,CAAS;IAC5B,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzC,OAAO,CAAC,CAAA;IACV,CAAC;IAED,OAAO,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAA;AACtC,CAAC","sourcesContent":["import { getWindowsKitsBundle } from \"@electron-ohos/app-builder-lib/out/toolsets/windows\"\r\nimport { archFromString, exec, log, spawn, TmpDir, unlinkIfExists } from \"builder-util\"\r\nimport { sanitizeFileName } from \"builder-util/out/filename\"\r\nimport * as chalk from \"chalk\"\r\nimport { mkdir } from \"fs/promises\"\r\nimport * as path from \"path\"\r\n\r\n/** @internal */\r\nexport async function createSelfSignedCert(publisher: string) {\r\n const tmpDir = new TmpDir(\"create-self-signed-cert\")\r\n const targetDir = process.cwd()\r\n const tempPrefix = path.join(await tmpDir.getTempDir({ prefix: \"self-signed-cert-creator\" }), sanitizeFileName(publisher))\r\n const cer = `${tempPrefix}.cer`\r\n const pvk = `${tempPrefix}.pvk`\r\n\r\n log.info(chalk.bold('When asked to enter a password (\"Create Private Key Password\"), please select \"None\".'))\r\n\r\n try {\r\n await mkdir(path.dirname(tempPrefix), { recursive: true })\r\n const vendorPath = (await getWindowsKitsBundle({ winCodeSign: null, arch: archFromString(process.arch) })).kit\r\n await exec(path.join(vendorPath, \"makecert.exe\"), [\"-r\", \"-h\", \"0\", \"-n\", `CN=${quoteString(publisher)}`, \"-eku\", \"1.3.6.1.5.5.7.3.3\", \"-pe\", \"-sv\", pvk, cer])\r\n\r\n const pfx = path.join(targetDir, `${sanitizeFileName(publisher)}.pfx`)\r\n await unlinkIfExists(pfx)\r\n await exec(path.join(vendorPath, \"pvk2pfx.exe\"), [\"-pvk\", pvk, \"-spc\", cer, \"-pfx\", pfx])\r\n log.info({ file: pfx }, `created. Please see https://electron.build/code-signing how to use it to sign.`)\r\n\r\n const certLocation = \"Cert:\\\\LocalMachine\\\\TrustedPeople\"\r\n log.info({ file: pfx, certLocation }, `importing. Operation will be succeed only if runned from root. Otherwise import file manually.`)\r\n await spawn(\"powershell.exe\", [\"-NoProfile\", \"-NonInteractive\", \"-Command\", \"Import-PfxCertificate\", \"-FilePath\", `\"${pfx}\"`, \"-CertStoreLocation\", certLocation])\r\n } finally {\r\n await tmpDir.cleanup()\r\n }\r\n}\r\n\r\nfunction quoteString(s: string): string {\r\n if (!s.includes(\",\") && !s.includes('\"')) {\r\n return s\r\n }\r\n\r\n return `\"${s.replace(/\"/g, '\\\\\"')}\"`\r\n}\r\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.configureInstallAppDepsCommand = configureInstallAppDepsCommand;
|
|
5
|
+
exports.installAppDeps = installAppDeps;
|
|
6
|
+
const electronVersion_1 = require("@electron-ohos/app-builder-lib/out/electron/electronVersion");
|
|
7
|
+
const config_1 = require("@electron-ohos/app-builder-lib/out/util/config/config");
|
|
8
|
+
const load_1 = require("@electron-ohos/app-builder-lib/out/util/config/load");
|
|
9
|
+
const packageDependencies_1 = require("@electron-ohos/app-builder-lib/out/util/packageDependencies");
|
|
10
|
+
const yarn_1 = require("@electron-ohos/app-builder-lib/out/util/yarn");
|
|
11
|
+
const version_1 = require("@electron-ohos/app-builder-lib/out/version");
|
|
12
|
+
const node_module_collector_1 = require("@electron-ohos/app-builder-lib/out/node-module-collector");
|
|
13
|
+
const builder_util_1 = require("builder-util");
|
|
14
|
+
const fs_extra_1 = require("fs-extra");
|
|
15
|
+
const lazy_val_1 = require("lazy-val");
|
|
16
|
+
const path = require("path");
|
|
17
|
+
const yargs = require("yargs");
|
|
18
|
+
/** @internal */
|
|
19
|
+
function configureInstallAppDepsCommand(yargs) {
|
|
20
|
+
// https://github.com/yargs/yargs/issues/760
|
|
21
|
+
// demandOption is required to be set
|
|
22
|
+
return yargs
|
|
23
|
+
.parserConfiguration({
|
|
24
|
+
"camel-case-expansion": false,
|
|
25
|
+
})
|
|
26
|
+
.option("platform", {
|
|
27
|
+
choices: ["linux", "darwin", "win32", "ohos"],
|
|
28
|
+
default: process.platform,
|
|
29
|
+
description: "The target platform",
|
|
30
|
+
})
|
|
31
|
+
.option("arch", {
|
|
32
|
+
choices: (0, builder_util_1.getArchCliNames)().concat("all"),
|
|
33
|
+
default: process.arch === "arm" ? "armv7l" : process.arch,
|
|
34
|
+
description: "The target arch",
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
async function installAppDeps(args) {
|
|
39
|
+
var _a;
|
|
40
|
+
try {
|
|
41
|
+
builder_util_1.log.info({ version: version_1.PACKAGE_VERSION }, "electron-builder");
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
// error in dev mode without babel
|
|
45
|
+
if (!(e instanceof ReferenceError)) {
|
|
46
|
+
throw e;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
const projectDir = process.cwd();
|
|
50
|
+
const packageMetadata = new lazy_val_1.Lazy(() => (0, load_1.orNullIfFileNotExist)((0, fs_extra_1.readJson)(path.join(projectDir, "package.json"))));
|
|
51
|
+
const config = await (0, config_1.getConfig)(projectDir, null, null, packageMetadata);
|
|
52
|
+
const [appDir, version] = await Promise.all([(0, config_1.computeDefaultAppDirectory)(projectDir, (_a = config.directories) === null || _a === void 0 ? void 0 : _a.app), (0, electronVersion_1.getElectronVersion)(projectDir, config)]);
|
|
53
|
+
const packageManagerEnv = (0, node_module_collector_1.determinePackageManagerEnv)({ projectDir, appDir, workspaceRoot: undefined });
|
|
54
|
+
// if two package.json — force full install (user wants to install/update app deps in addition to dev)
|
|
55
|
+
await (0, yarn_1.installOrRebuild)(config, {
|
|
56
|
+
appDir,
|
|
57
|
+
projectDir,
|
|
58
|
+
workspaceRoot: await (await packageManagerEnv.value).workspaceRoot,
|
|
59
|
+
}, {
|
|
60
|
+
frameworkInfo: { version, useCustomDist: true },
|
|
61
|
+
platform: args.platform,
|
|
62
|
+
arch: args.arch,
|
|
63
|
+
productionDeps: (0, packageDependencies_1.createLazyProductionDeps)(appDir, null, false),
|
|
64
|
+
}, appDir !== projectDir, {});
|
|
65
|
+
}
|
|
66
|
+
function main() {
|
|
67
|
+
return installAppDeps(configureInstallAppDepsCommand(yargs).argv);
|
|
68
|
+
}
|
|
69
|
+
if (require.main === module) {
|
|
70
|
+
builder_util_1.log.warn("please use as subcommand: electron-builder install-app-deps");
|
|
71
|
+
main().catch(builder_util_1.printErrorAndExit);
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=install-app-deps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-app-deps.js","sourceRoot":"","sources":["../../src/cli/install-app-deps.ts"],"names":[],"mappings":";;;AAgBA,wEAiBC;AAGD,wCAkCC;AApED,iGAAgG;AAChG,kFAA6G;AAC7G,8EAA0F;AAC1F,qGAAsG;AACtG,uEA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\"@electron-ohos/app-builder-lib/out/electron/electronVersion\"\r\nimport { computeDefaultAppDirectory, getConfig } from \"@electron-ohos/app-builder-lib/out/util/config/config\"\r\nimport { orNullIfFileNotExist } from \"@electron-ohos/app-builder-lib/out/util/config/load\"\r\nimport { createLazyProductionDeps } from \"@electron-ohos/app-builder-lib/out/util/packageDependencies\"\r\nimport { installOrRebuild } from \"@electron-ohos/app-builder-lib/out/util/yarn\"\r\nimport { PACKAGE_VERSION } from \"@electron-ohos/app-builder-lib/out/version\"\r\nimport { determinePackageManagerEnv } from \"@electron-ohos/app-builder-lib/out/node-module-collector\"\r\nimport { getArchCliNames, log, printErrorAndExit } from \"builder-util\"\r\nimport { readJson } from \"fs-extra\"\r\nimport { Lazy } from \"lazy-val\"\r\nimport * as path from \"path\"\r\nimport * as yargs from \"yargs\"\r\n\r\n/** @internal */\r\nexport function configureInstallAppDepsCommand(yargs: yargs.Argv): yargs.Argv {\r\n // https://github.com/yargs/yargs/issues/760\r\n // demandOption is required to be set\r\n return yargs\r\n .parserConfiguration({\r\n \"camel-case-expansion\": false,\r\n })\r\n .option(\"platform\", {\r\n choices: [\"linux\", \"darwin\", \"win32\", \"ohos\"],\r\n default: process.platform,\r\n description: \"The target platform\",\r\n })\r\n .option(\"arch\", {\r\n choices: getArchCliNames().concat(\"all\"),\r\n default: process.arch === \"arm\" ? \"armv7l\" : process.arch,\r\n description: \"The target arch\",\r\n })\r\n}\r\n\r\n/** @internal */\r\nexport async function installAppDeps(args: any) {\r\n try {\r\n log.info({ version: PACKAGE_VERSION }, \"electron-builder\")\r\n } catch (e: any) {\r\n // error in dev mode without babel\r\n if (!(e instanceof ReferenceError)) {\r\n throw e\r\n }\r\n }\r\n\r\n const projectDir = process.cwd()\r\n const packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, \"package.json\"))))\r\n const config = await getConfig(projectDir, null, null, packageMetadata)\r\n const [appDir, version] = await Promise.all<string>([computeDefaultAppDirectory(projectDir, config.directories?.app), getElectronVersion(projectDir, config)])\r\n\r\n const packageManagerEnv = determinePackageManagerEnv({ projectDir, appDir, workspaceRoot: undefined })\r\n\r\n // if two package.json — force full install (user wants to install/update app deps in addition to dev)\r\n await installOrRebuild(\r\n config,\r\n {\r\n appDir,\r\n projectDir,\r\n workspaceRoot: await (await packageManagerEnv.value).workspaceRoot,\r\n },\r\n {\r\n frameworkInfo: { version, useCustomDist: true },\r\n platform: args.platform,\r\n arch: args.arch,\r\n productionDeps: createLazyProductionDeps(appDir, null, false),\r\n },\r\n appDir !== projectDir,\r\n {}\r\n )\r\n}\r\n\r\nfunction main() {\r\n return installAppDeps(configureInstallAppDepsCommand(yargs).argv)\r\n}\r\n\r\nif (require.main === module) {\r\n log.warn(\"please use as subcommand: electron-builder install-app-deps\")\r\n main().catch(printErrorAndExit)\r\n}\r\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/out/cli/start.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/cli/start.ts"],"names":[],"mappings":";;AACA,sBAGC;AAJD,gBAAgB;AAChB,SAAgB,KAAK;IACnB,OAAO,CAAC,6BAA6B,CAAC,CAAA;IACtC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["/** @internal */\r\nexport function start() {\r\n require(\"electron-webpack/dev-runner\")\r\n return Promise.resolve()\r\n}\r\n"]}
|
package/out/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { getArchSuffix, Arch, archFromString, log } from "builder-util";
|
|
2
|
+
export { build, CliOptions, createTargets } from "./builder";
|
|
3
|
+
export { publish, publishArtifactsWithOptions } from "./publish";
|
|
4
|
+
export { TargetConfiguration, Platform, Target, DIR_TARGET, BeforeBuildContext, SourceRepositoryInfo, TargetSpecificOptions, TargetConfigType, DEFAULT_TARGET, CompressionLevel, MacConfiguration, DmgOptions, MasConfiguration, MacOsTargetName, PkgOptions, DmgContent, DmgWindow, PlatformSpecificBuildOptions, AsarOptions, FileSet, LinuxConfiguration, DebOptions, CommonLinuxOptions, LinuxTargetSpecificOptions, AppImageOptions, Configuration, AfterPackContext, MetadataDirectories, Protocol, ReleaseInfo, ElectronBrandingOptions, ElectronDownloadOptions, SnapOptions, CommonWindowsInstallerConfiguration, FileAssociation, MsiOptions, AppXOptions, WindowsConfiguration, OhosConfiguration, OhosTargetOptions, Packager, BuildResult, PackagerOptions, ArtifactCreated, ArtifactBuildStarted, NsisOptions, NsisWebOptions, PortableOptions, CommonNsisOptions, SquirrelWindowsOptions, WindowsSignOptions, CustomWindowsSignTaskConfiguration, WindowsSignTaskConfiguration, CustomWindowsSign, FileCodeSigningInfo, CertificateFromStoreInfo, Metadata, AuthorMetadata, RepositoryInfo, AppInfo, UploadTask, PublishManager, PublishOptions, ProgressInfo, MacPackager, WinPackager, LinuxPackager, } from "@electron-ohos/app-builder-lib";
|
|
5
|
+
export { buildForge, ForgeOptions } from "@electron-ohos/app-builder-lib";
|
|
6
|
+
export { CancellationToken } from "builder-util-runtime";
|
package/out/index.js
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CancellationToken = exports.buildForge = exports.LinuxPackager = exports.WinPackager = exports.MacPackager = exports.PublishManager = exports.AppInfo = exports.Packager = exports.DEFAULT_TARGET = exports.DIR_TARGET = exports.Target = exports.Platform = exports.publishArtifactsWithOptions = exports.publish = exports.createTargets = exports.build = exports.log = exports.archFromString = exports.Arch = exports.getArchSuffix = void 0;
|
|
4
|
+
var builder_util_1 = require("builder-util");
|
|
5
|
+
Object.defineProperty(exports, "getArchSuffix", { enumerable: true, get: function () { return builder_util_1.getArchSuffix; } });
|
|
6
|
+
Object.defineProperty(exports, "Arch", { enumerable: true, get: function () { return builder_util_1.Arch; } });
|
|
7
|
+
Object.defineProperty(exports, "archFromString", { enumerable: true, get: function () { return builder_util_1.archFromString; } });
|
|
8
|
+
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return builder_util_1.log; } });
|
|
9
|
+
var builder_1 = require("./builder");
|
|
10
|
+
Object.defineProperty(exports, "build", { enumerable: true, get: function () { return builder_1.build; } });
|
|
11
|
+
Object.defineProperty(exports, "createTargets", { enumerable: true, get: function () { return builder_1.createTargets; } });
|
|
12
|
+
var publish_1 = require("./publish");
|
|
13
|
+
Object.defineProperty(exports, "publish", { enumerable: true, get: function () { return publish_1.publish; } });
|
|
14
|
+
Object.defineProperty(exports, "publishArtifactsWithOptions", { enumerable: true, get: function () { return publish_1.publishArtifactsWithOptions; } });
|
|
15
|
+
var app_builder_lib_1 = require("@electron-ohos/app-builder-lib");
|
|
16
|
+
Object.defineProperty(exports, "Platform", { enumerable: true, get: function () { return app_builder_lib_1.Platform; } });
|
|
17
|
+
Object.defineProperty(exports, "Target", { enumerable: true, get: function () { return app_builder_lib_1.Target; } });
|
|
18
|
+
Object.defineProperty(exports, "DIR_TARGET", { enumerable: true, get: function () { return app_builder_lib_1.DIR_TARGET; } });
|
|
19
|
+
Object.defineProperty(exports, "DEFAULT_TARGET", { enumerable: true, get: function () { return app_builder_lib_1.DEFAULT_TARGET; } });
|
|
20
|
+
Object.defineProperty(exports, "Packager", { enumerable: true, get: function () { return app_builder_lib_1.Packager; } });
|
|
21
|
+
Object.defineProperty(exports, "AppInfo", { enumerable: true, get: function () { return app_builder_lib_1.AppInfo; } });
|
|
22
|
+
Object.defineProperty(exports, "PublishManager", { enumerable: true, get: function () { return app_builder_lib_1.PublishManager; } });
|
|
23
|
+
Object.defineProperty(exports, "MacPackager", { enumerable: true, get: function () { return app_builder_lib_1.MacPackager; } });
|
|
24
|
+
Object.defineProperty(exports, "WinPackager", { enumerable: true, get: function () { return app_builder_lib_1.WinPackager; } });
|
|
25
|
+
Object.defineProperty(exports, "LinuxPackager", { enumerable: true, get: function () { return app_builder_lib_1.LinuxPackager; } });
|
|
26
|
+
var app_builder_lib_2 = require("@electron-ohos/app-builder-lib");
|
|
27
|
+
Object.defineProperty(exports, "buildForge", { enumerable: true, get: function () { return app_builder_lib_2.buildForge; } });
|
|
28
|
+
var builder_util_runtime_1 = require("builder-util-runtime");
|
|
29
|
+
Object.defineProperty(exports, "CancellationToken", { enumerable: true, get: function () { return builder_util_runtime_1.CancellationToken; } });
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
package/out/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AAA9D,6GAAA,aAAa,OAAA;AAAE,oGAAA,IAAI,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,mGAAA,GAAG,OAAA;AACjD,qCAA4D;AAAnD,gGAAA,KAAK,OAAA;AAAc,wGAAA,aAAa,OAAA;AACzC,qCAAgE;AAAvD,kGAAA,OAAO,OAAA;AAAE,sHAAA,2BAA2B,OAAA;AAC7C,kEAoEuC;AAlErC,2GAAA,QAAQ,OAAA;AACR,yGAAA,MAAM,OAAA;AACN,6GAAA,UAAU,OAAA;AAKV,iHAAA,cAAc,OAAA;AAgCd,2GAAA,QAAQ,OAAA;AAmBR,0GAAA,OAAO,OAAA;AAEP,iHAAA,cAAc,OAAA;AAGd,8GAAA,WAAW,OAAA;AACX,8GAAA,WAAW,OAAA;AACX,gHAAA,aAAa,OAAA;AAEf,kEAAyE;AAAhE,6GAAA,UAAU,OAAA;AACnB,6DAAwD;AAA/C,yHAAA,iBAAiB,OAAA","sourcesContent":["export { getArchSuffix, Arch, archFromString, log } from \"builder-util\"\r\nexport { build, CliOptions, createTargets } from \"./builder\"\r\nexport { publish, publishArtifactsWithOptions } from \"./publish\"\r\nexport {\r\n TargetConfiguration,\r\n Platform,\r\n Target,\r\n DIR_TARGET,\r\n BeforeBuildContext,\r\n SourceRepositoryInfo,\r\n TargetSpecificOptions,\r\n TargetConfigType,\r\n DEFAULT_TARGET,\r\n CompressionLevel,\r\n MacConfiguration,\r\n DmgOptions,\r\n MasConfiguration,\r\n MacOsTargetName,\r\n PkgOptions,\r\n DmgContent,\r\n DmgWindow,\r\n PlatformSpecificBuildOptions,\r\n AsarOptions,\r\n FileSet,\r\n LinuxConfiguration,\r\n DebOptions,\r\n CommonLinuxOptions,\r\n LinuxTargetSpecificOptions,\r\n AppImageOptions,\r\n Configuration,\r\n AfterPackContext,\r\n MetadataDirectories,\r\n Protocol,\r\n ReleaseInfo,\r\n ElectronBrandingOptions,\r\n ElectronDownloadOptions,\r\n SnapOptions,\r\n CommonWindowsInstallerConfiguration,\r\n FileAssociation,\r\n MsiOptions,\r\n AppXOptions,\r\n WindowsConfiguration,\r\n OhosConfiguration,\r\n OhosTargetOptions,\r\n Packager,\r\n BuildResult,\r\n PackagerOptions,\r\n ArtifactCreated,\r\n ArtifactBuildStarted,\r\n NsisOptions,\r\n NsisWebOptions,\r\n PortableOptions,\r\n CommonNsisOptions,\r\n SquirrelWindowsOptions,\r\n WindowsSignOptions,\r\n CustomWindowsSignTaskConfiguration,\r\n WindowsSignTaskConfiguration,\r\n CustomWindowsSign,\r\n FileCodeSigningInfo,\r\n CertificateFromStoreInfo,\r\n Metadata,\r\n AuthorMetadata,\r\n RepositoryInfo,\r\n AppInfo,\r\n UploadTask,\r\n PublishManager,\r\n PublishOptions,\r\n ProgressInfo,\r\n MacPackager,\r\n WinPackager,\r\n LinuxPackager,\r\n} from \"@electron-ohos/app-builder-lib\"\r\nexport { buildForge, ForgeOptions } from \"@electron-ohos/app-builder-lib\"\r\nexport { CancellationToken } from \"builder-util-runtime\"\r\n"]}
|
package/out/publish.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
import { PublishOptions, UploadTask } from "@electron-ohos/app-builder-lib";
|
|
3
|
+
import { Publish } from "@electron-ohos/app-builder-lib/out/core";
|
|
4
|
+
import { PublishPolicy } from "electron-publish";
|
|
5
|
+
export declare function publish(args: {
|
|
6
|
+
files: string[];
|
|
7
|
+
version: string | undefined;
|
|
8
|
+
configurationFilePath: string | undefined;
|
|
9
|
+
policy: PublishPolicy;
|
|
10
|
+
}): Promise<UploadTask[] | null>;
|
|
11
|
+
export declare function publishArtifactsWithOptions(uploadOptions: {
|
|
12
|
+
file: string;
|
|
13
|
+
arch: string | null;
|
|
14
|
+
}[], buildVersion?: string, configurationFilePath?: string, publishConfiguration?: Publish, publishOptions?: PublishOptions): Promise<UploadTask[] | null>;
|
package/out/publish.js
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.configurePublishCommand = configurePublishCommand;
|
|
5
|
+
exports.publish = publish;
|
|
6
|
+
exports.publishArtifactsWithOptions = publishArtifactsWithOptions;
|
|
7
|
+
const app_builder_lib_1 = require("@electron-ohos/app-builder-lib");
|
|
8
|
+
const platformPackager_1 = require("@electron-ohos/app-builder-lib/out/platformPackager");
|
|
9
|
+
const config_1 = require("@electron-ohos/app-builder-lib/out/util/config/config");
|
|
10
|
+
const builder_util_1 = require("builder-util");
|
|
11
|
+
const chalk = require("chalk");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const yargs = require("yargs");
|
|
14
|
+
const builder_1 = require("./builder");
|
|
15
|
+
/** @internal */
|
|
16
|
+
function configurePublishCommand(yargs) {
|
|
17
|
+
// https://github.com/yargs/yargs/issues/760
|
|
18
|
+
// demandOption is required to be set
|
|
19
|
+
return yargs
|
|
20
|
+
.version(false)
|
|
21
|
+
.parserConfiguration({
|
|
22
|
+
"camel-case-expansion": false,
|
|
23
|
+
})
|
|
24
|
+
.option("files", {
|
|
25
|
+
alias: "f",
|
|
26
|
+
string: true,
|
|
27
|
+
type: "array",
|
|
28
|
+
requiresArg: true,
|
|
29
|
+
description: "The file(s) to upload to your publisher",
|
|
30
|
+
})
|
|
31
|
+
.option("version", {
|
|
32
|
+
alias: ["v"],
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "The app/build version used when searching for an upload release (used by some Publishers)",
|
|
35
|
+
})
|
|
36
|
+
.option("config", {
|
|
37
|
+
alias: ["c", "configurationFilePath"],
|
|
38
|
+
type: "string",
|
|
39
|
+
description: "The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see " + chalk.underline("https://goo.gl/YFRJOM"),
|
|
40
|
+
})
|
|
41
|
+
.option("policy", {
|
|
42
|
+
alias: ["p"],
|
|
43
|
+
type: "string",
|
|
44
|
+
description: `Publish trigger policy, see ${chalk.underline("https://www.electron.build/publish")}`,
|
|
45
|
+
choices: ["onTag", "onTagOrDraft", "always", "never", undefined],
|
|
46
|
+
})
|
|
47
|
+
.demandOption("files");
|
|
48
|
+
}
|
|
49
|
+
async function publish(args) {
|
|
50
|
+
const uploadTasks = args.files.map(f => {
|
|
51
|
+
return {
|
|
52
|
+
file: path.resolve(f),
|
|
53
|
+
arch: null,
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
return publishArtifactsWithOptions(uploadTasks, args.version, args.configurationFilePath, undefined, { publish: args.policy });
|
|
57
|
+
}
|
|
58
|
+
async function publishArtifactsWithOptions(uploadOptions, buildVersion, configurationFilePath, publishConfiguration, publishOptions) {
|
|
59
|
+
const projectDir = process.cwd();
|
|
60
|
+
const config = await (0, config_1.getConfig)(projectDir, configurationFilePath || null, { publish: publishConfiguration, detectUpdateChannel: false });
|
|
61
|
+
const buildOptions = (0, builder_1.normalizeOptions)({ config, publish: publishOptions === null || publishOptions === void 0 ? void 0 : publishOptions.publish });
|
|
62
|
+
(0, app_builder_lib_1.checkBuildRequestOptions)(buildOptions);
|
|
63
|
+
const uniqueUploads = Array.from(new Set(uploadOptions));
|
|
64
|
+
const tasks = uniqueUploads.map(({ file, arch }) => {
|
|
65
|
+
const filename = path.basename(file);
|
|
66
|
+
return { file, arch: arch ? (0, builder_util_1.archFromString)(arch) : null, safeArtifactName: (0, platformPackager_1.computeSafeArtifactNameIfNeeded)(filename, () => filename) };
|
|
67
|
+
});
|
|
68
|
+
return publishPackageWithTasks(buildOptions, tasks, buildVersion);
|
|
69
|
+
}
|
|
70
|
+
async function publishPackageWithTasks(options, uploadTasks, buildVersion, cancellationToken = new app_builder_lib_1.CancellationToken(), packager = new app_builder_lib_1.Packager(options, cancellationToken)) {
|
|
71
|
+
await packager.validateConfig();
|
|
72
|
+
const appInfo = new app_builder_lib_1.AppInfo(packager, buildVersion);
|
|
73
|
+
const publishManager = new app_builder_lib_1.PublishManager(packager, options, cancellationToken);
|
|
74
|
+
const sigIntHandler = () => {
|
|
75
|
+
builder_util_1.log.warn("cancelled by SIGINT");
|
|
76
|
+
packager.cancellationToken.cancel();
|
|
77
|
+
publishManager.cancelTasks();
|
|
78
|
+
};
|
|
79
|
+
process.once("SIGINT", sigIntHandler);
|
|
80
|
+
try {
|
|
81
|
+
const publishConfigurations = await publishManager.getGlobalPublishConfigurations();
|
|
82
|
+
if (publishConfigurations == null || publishConfigurations.length === 0) {
|
|
83
|
+
throw new builder_util_1.InvalidConfigurationError("unable to find any publish configuration");
|
|
84
|
+
}
|
|
85
|
+
for (const newArtifact of uploadTasks) {
|
|
86
|
+
for (const publishConfiguration of publishConfigurations) {
|
|
87
|
+
await publishManager.scheduleUpload(publishConfiguration, newArtifact, appInfo);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
await publishManager.awaitTasks();
|
|
91
|
+
return uploadTasks;
|
|
92
|
+
}
|
|
93
|
+
catch (error) {
|
|
94
|
+
packager.cancellationToken.cancel();
|
|
95
|
+
publishManager.cancelTasks();
|
|
96
|
+
process.removeListener("SIGINT", sigIntHandler);
|
|
97
|
+
builder_util_1.log.error({ message: (error.stack || error.message || error).toString() }, "error publishing");
|
|
98
|
+
}
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
function main() {
|
|
102
|
+
return publish(configurePublishCommand(yargs).argv);
|
|
103
|
+
}
|
|
104
|
+
if (require.main === module) {
|
|
105
|
+
builder_util_1.log.warn("please use as subcommand: electron-builder publish");
|
|
106
|
+
main().catch(builder_util_1.printErrorAndExit);
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=publish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"publish.js","sourceRoot":"","sources":["../src/publish.ts"],"names":[],"mappings":";;;AAcA,0DAiCC;AAED,0BAQC;AAED,kEAoBC;AA7ED,oEAA4K;AAE5K,0FAAqG;AACrG,kFAAiF;AACjF,+CAAgG;AAEhG,+BAA8B;AAC9B,6BAA4B;AAC5B,+BAA8B;AAC9B,uCAA0D;AAE1D,gBAAgB;AAChB,SAAgB,uBAAuB,CAAC,KAAiB;IACvD,4CAA4C;IAC5C,qCAAqC;IACrC,OAAO,KAAK;SACT,OAAO,CAAC,KAAK,CAAC;SACd,mBAAmB,CAAC;QACnB,sBAAsB,EAAE,KAAK;KAC9B,CAAC;SACD,MAAM,CAAC,OAAO,EAAE;QACf,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,IAAI;QACjB,WAAW,EAAE,yCAAyC;KACvD,CAAC;SACD,MAAM,CAAC,SAAS,EAAE;QACjB,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,2FAA2F;KACzG,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,KAAK,EAAE,CAAC,GAAG,EAAE,uBAAuB,CAAC;QACrC,IAAI,EAAE,QAAQ;QACd,WAAW,EACT,4HAA4H,GAAG,KAAK,CAAC,SAAS,CAAC,uBAAuB,CAAC;KAC1K,CAAC;SACD,MAAM,CAAC,QAAQ,EAAE;QAChB,KAAK,EAAE,CAAC,GAAG,CAAC;QACZ,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,+B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E,CAAC;YACxE,MAAM,IAAI,wCAAyB,CAAC,0CAA0C,CAAC,CAAA;QACjF,CAAC;QAED,KAAK,MAAM,WAAW,IAAI,WAAW,EAAE,CAAC;YACtC,KAAK,MAAM,oBAAoB,IAAI,qBAAqB,EAAE,CAAC;gBACzD,MAAM,cAAc,CAAC,cAAc,CAAC,oBAAoB,EAAE,WAAW,EAAE,OAAO,CAAC,CAAA;YACjF,CAAC;QACH,CAAC;QAED,MAAM,cAAc,CAAC,UAAU,EAAE,CAAA;QACjC,OAAO,WAAW,CAAA;IACpB,CAAC;IAAC,OAAO,KAAU,EAAE,CAAC;QACpB,QAAQ,CAAC,iBAAiB,CAAC,MAAM,EAAE,CAAA;QACnC,cAAc,CAAC,WAAW,EAAE,CAAA;QAC5B,OAAO,CAAC,cAAc,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;QAC/C,kBAAG,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,CAAC,QAAQ,EAAE,EAAE,EAAE,kBAAkB,CAAC,CAAA;IAChG,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,IAAI;IACX,OAAO,OAAO,CAAC,uBAAuB,CAAC,KAAK,CAAC,CAAC,IAAW,CAAC,CAAA;AAC5D,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;IAC5B,kBAAG,CAAC,IAAI,CAAC,oDAAoD,CAAC,CAAA;IAC9D,IAAI,EAAE,CAAC,KAAK,CAAC,gCAAiB,CAAC,CAAA;AACjC,CAAC","sourcesContent":["#! /usr/bin/env node\r\n\r\nimport { AppInfo, CancellationToken, Packager, PackagerOptions, PublishManager, PublishOptions, UploadTask, checkBuildRequestOptions } from \"@electron-ohos/app-builder-lib\"\r\nimport { Publish } from \"@electron-ohos/app-builder-lib/out/core\"\r\nimport { computeSafeArtifactNameIfNeeded } from \"@electron-ohos/app-builder-lib/out/platformPackager\"\r\nimport { getConfig } from \"@electron-ohos/app-builder-lib/out/util/config/config\"\r\nimport { InvalidConfigurationError, archFromString, log, printErrorAndExit } from \"builder-util\"\r\nimport { PublishPolicy } from \"electron-publish\"\r\nimport * as chalk from \"chalk\"\r\nimport * as path from \"path\"\r\nimport * as yargs from \"yargs\"\r\nimport { BuildOptions, normalizeOptions } from \"./builder\"\r\n\r\n/** @internal */\r\nexport function configurePublishCommand(yargs: yargs.Argv): yargs.Argv {\r\n // https://github.com/yargs/yargs/issues/760\r\n // demandOption is required to be set\r\n return yargs\r\n .version(false)\r\n .parserConfiguration({\r\n \"camel-case-expansion\": false,\r\n })\r\n .option(\"files\", {\r\n alias: \"f\",\r\n string: true,\r\n type: \"array\",\r\n requiresArg: true,\r\n description: \"The file(s) to upload to your publisher\",\r\n })\r\n .option(\"version\", {\r\n alias: [\"v\"],\r\n type: \"string\",\r\n description: \"The app/build version used when searching for an upload release (used by some Publishers)\",\r\n })\r\n .option(\"config\", {\r\n alias: [\"c\", \"configurationFilePath\"],\r\n type: \"string\",\r\n description:\r\n \"The path to an electron-builder config. Defaults to `electron-builder.yml` (or `json`, or `json5`, or `js`, or `ts`), see \" + chalk.underline(\"https://goo.gl/YFRJOM\"),\r\n })\r\n .option(\"policy\", {\r\n alias: [\"p\"],\r\n type: \"string\",\r\n description: `Publish trigger policy, see ${chalk.underline(\"https://www.electron.build/publish\")}`,\r\n choices: [\"onTag\", \"onTagOrDraft\", \"always\", \"never\", undefined as any],\r\n })\r\n .demandOption(\"files\")\r\n}\r\n\r\nexport async function publish(args: { files: string[]; version: string | undefined; configurationFilePath: string | undefined; policy: PublishPolicy }) {\r\n const uploadTasks = args.files.map(f => {\r\n return {\r\n file: path.resolve(f),\r\n arch: null,\r\n }\r\n })\r\n return publishArtifactsWithOptions(uploadTasks, args.version, args.configurationFilePath, undefined, { publish: args.policy })\r\n}\r\n\r\nexport async function publishArtifactsWithOptions(\r\n uploadOptions: { file: string; arch: string | null }[],\r\n buildVersion?: string,\r\n configurationFilePath?: string,\r\n publishConfiguration?: Publish,\r\n publishOptions?: PublishOptions\r\n) {\r\n const projectDir = process.cwd()\r\n const config = await getConfig(projectDir, configurationFilePath || null, { publish: publishConfiguration, detectUpdateChannel: false })\r\n\r\n const buildOptions: BuildOptions = normalizeOptions({ config, publish: publishOptions?.publish })\r\n checkBuildRequestOptions(buildOptions)\r\n\r\n const uniqueUploads = Array.from(new Set(uploadOptions))\r\n const tasks: UploadTask[] = uniqueUploads.map(({ file, arch }) => {\r\n const filename = path.basename(file)\r\n return { file, arch: arch ? archFromString(arch) : null, safeArtifactName: computeSafeArtifactNameIfNeeded(filename, () => filename) }\r\n })\r\n\r\n return publishPackageWithTasks(buildOptions, tasks, buildVersion)\r\n}\r\n\r\nasync function publishPackageWithTasks(\r\n options: PackagerOptions & PublishOptions,\r\n uploadTasks: UploadTask[],\r\n buildVersion?: string,\r\n cancellationToken: CancellationToken = new CancellationToken(),\r\n packager: Packager = new Packager(options, cancellationToken)\r\n) {\r\n await packager.validateConfig()\r\n const appInfo = new AppInfo(packager, buildVersion)\r\n const publishManager = new PublishManager(packager, options, cancellationToken)\r\n\r\n const sigIntHandler = () => {\r\n log.warn(\"cancelled by SIGINT\")\r\n packager.cancellationToken.cancel()\r\n publishManager.cancelTasks()\r\n }\r\n process.once(\"SIGINT\", sigIntHandler)\r\n\r\n try {\r\n const publishConfigurations = await publishManager.getGlobalPublishConfigurations()\r\n if (publishConfigurations == null || publishConfigurations.length === 0) {\r\n throw new InvalidConfigurationError(\"unable to find any publish configuration\")\r\n }\r\n\r\n for (const newArtifact of uploadTasks) {\r\n for (const publishConfiguration of publishConfigurations) {\r\n await publishManager.scheduleUpload(publishConfiguration, newArtifact, appInfo)\r\n }\r\n }\r\n\r\n await publishManager.awaitTasks()\r\n return uploadTasks\r\n } catch (error: any) {\r\n packager.cancellationToken.cancel()\r\n publishManager.cancelTasks()\r\n process.removeListener(\"SIGINT\", sigIntHandler)\r\n log.error({ message: (error.stack || error.message || error).toString() }, \"error publishing\")\r\n }\r\n return null\r\n}\r\n\r\nfunction main() {\r\n return publish(configurePublishCommand(yargs).argv as any)\r\n}\r\n\r\nif (require.main === module) {\r\n log.warn(\"please use as subcommand: electron-builder publish\")\r\n main().catch(printErrorAndExit)\r\n}\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@electron-ohos/electron-builder",
|
|
3
|
+
"description": "A complete solution to package and build a ready for distribution Electron app for MacOS, Windows and Linux with “auto update” support out of the box",
|
|
4
|
+
"version": "26.8.2",
|
|
5
|
+
"main": "out/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"out"
|
|
8
|
+
],
|
|
9
|
+
"bin": {
|
|
10
|
+
"electron-builder-ohos": "./cli.js",
|
|
11
|
+
"install-app-deps-ohos": "./install-app-deps.js"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=14.0.0"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"electron",
|
|
18
|
+
"builder",
|
|
19
|
+
"build",
|
|
20
|
+
"installer",
|
|
21
|
+
"install",
|
|
22
|
+
"packager",
|
|
23
|
+
"pack",
|
|
24
|
+
"nsis",
|
|
25
|
+
"app",
|
|
26
|
+
"dmg",
|
|
27
|
+
"pkg",
|
|
28
|
+
"msi",
|
|
29
|
+
"exe",
|
|
30
|
+
"setup",
|
|
31
|
+
"Windows",
|
|
32
|
+
"OS X",
|
|
33
|
+
"MacOS",
|
|
34
|
+
"Mac",
|
|
35
|
+
"appx",
|
|
36
|
+
"snap",
|
|
37
|
+
"flatpak",
|
|
38
|
+
"portable",
|
|
39
|
+
"ohos",
|
|
40
|
+
"oh",
|
|
41
|
+
"hap"
|
|
42
|
+
],
|
|
43
|
+
"author": "Vladimir Krivosheev",
|
|
44
|
+
"contributors": [
|
|
45
|
+
"Stefan Judis",
|
|
46
|
+
"Mike Maietta"
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@electron-ohos/app-builder-lib": "^26.8.3",
|
|
51
|
+
"builder-util": "^26.8.1",
|
|
52
|
+
"builder-util-runtime": "^9.5.1",
|
|
53
|
+
"chalk": "^4.1.2",
|
|
54
|
+
"ci-info": "^4.2.0",
|
|
55
|
+
"dmg-builder": "^26.8.2",
|
|
56
|
+
"fs-extra": "^10.1.0",
|
|
57
|
+
"lazy-val": "^1.0.5",
|
|
58
|
+
"simple-update-notifier": "2.0.0",
|
|
59
|
+
"yargs": "^17.6.2"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/fs-extra": "9.0.13",
|
|
63
|
+
"@types/yargs": "^17.0.16"
|
|
64
|
+
},
|
|
65
|
+
"typings": "./out/index.d.ts",
|
|
66
|
+
"publishConfig": {
|
|
67
|
+
"tag": "next"
|
|
68
|
+
}
|
|
69
|
+
}
|