@next2d/builder 0.0.5 → 0.0.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/README.md +2 -1
- package/dist/index.d.ts +1 -138
- package/dist/index.js +63 -56
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -16,8 +16,9 @@ Multi-platform builder for Next2D Framework, export to various platforms includi
|
|
|
16
16
|
|
|
17
17
|
| platform | detail |
|
|
18
18
|
|----------|--------------------------|
|
|
19
|
-
| macOS | Export dmg file |
|
|
20
19
|
| Windows | Export an exe file |
|
|
20
|
+
| macOS | Export dmg, app file |
|
|
21
|
+
| Linux | Export deb file |
|
|
21
22
|
| iOS | Implementing... |
|
|
22
23
|
| Android | Implementing... |
|
|
23
24
|
| web | Export minfy'd JS files |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,139 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
declare const pc: any;
|
|
4
|
-
declare const fs: any;
|
|
5
|
-
declare const cp: any;
|
|
6
|
-
declare const vite: any;
|
|
7
|
-
declare const electronBuilder: any;
|
|
8
|
-
declare const recommendeVersion: number;
|
|
9
|
-
declare const version: string;
|
|
10
|
-
declare let platform: string;
|
|
11
|
-
declare let environment: string;
|
|
12
|
-
declare let hasHelp: boolean;
|
|
13
|
-
declare let preview: boolean;
|
|
14
|
-
/**
|
|
15
|
-
* @description ヘルプを出力して終了
|
|
16
|
-
* Output help and exit
|
|
17
|
-
*
|
|
18
|
-
* @return {void}
|
|
19
|
-
* @method
|
|
20
|
-
* @public
|
|
21
|
-
*/
|
|
22
|
-
declare const echoHelp: () => void;
|
|
23
|
-
/**
|
|
24
|
-
* @type {string}
|
|
25
|
-
* @private
|
|
26
|
-
*/
|
|
27
|
-
declare const platformDir: string;
|
|
28
|
-
/**
|
|
29
|
-
* @type {object}
|
|
30
|
-
* @private
|
|
31
|
-
*/
|
|
32
|
-
declare let $configObject: any | null;
|
|
33
|
-
/**
|
|
34
|
-
* @type {string}
|
|
35
|
-
* @private
|
|
36
|
-
*/
|
|
37
|
-
declare let $buildDir: string;
|
|
38
|
-
/**
|
|
39
|
-
* @type {string}
|
|
40
|
-
* @private
|
|
41
|
-
*/
|
|
42
|
-
declare let $outDir: string;
|
|
43
|
-
/**
|
|
44
|
-
* @type {string}
|
|
45
|
-
* @constant
|
|
46
|
-
*/
|
|
47
|
-
declare const CAPACITOR_CONFIG_NAME: string;
|
|
48
|
-
/**
|
|
49
|
-
* @type {string}
|
|
50
|
-
* @constant
|
|
51
|
-
*/
|
|
52
|
-
declare const ELECTRON_CONFIG_NAME: string;
|
|
53
|
-
/**
|
|
54
|
-
* @return {Promise}
|
|
55
|
-
* @method
|
|
56
|
-
* @public
|
|
57
|
-
*/
|
|
58
|
-
declare const loadConfig: () => Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* @description Web用アプリの書き出し関数
|
|
61
|
-
* Export function for web applications
|
|
62
|
-
*
|
|
63
|
-
* @return {Promise}
|
|
64
|
-
* @method
|
|
65
|
-
* @public
|
|
66
|
-
*/
|
|
67
|
-
declare const buildWeb: () => Promise<void>;
|
|
68
|
-
/**
|
|
69
|
-
* @description Electronの書き出しに必要なconfigを生成
|
|
70
|
-
* Generate config for Electron export
|
|
71
|
-
*
|
|
72
|
-
* @return {object}
|
|
73
|
-
* @method
|
|
74
|
-
* @public
|
|
75
|
-
*/
|
|
76
|
-
declare const generateElectronConfig: () => any;
|
|
77
|
-
/**
|
|
78
|
-
* @description Electronで読み込むindex.htmlのファイルパスをセット
|
|
79
|
-
* Set the file path of index.html to be loaded by Electron
|
|
80
|
-
*
|
|
81
|
-
* @return {void}
|
|
82
|
-
* @method
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
declare const setElectronIndexPath: () => void;
|
|
86
|
-
/**
|
|
87
|
-
* @description Electronで読み込むindex.htmlのファイルパスを初期化
|
|
88
|
-
* Initialize the file path of index.html to be loaded by Electron
|
|
89
|
-
*
|
|
90
|
-
* @return {void}
|
|
91
|
-
* @method
|
|
92
|
-
* @public
|
|
93
|
-
*/
|
|
94
|
-
declare const unlinkElectronIndexPath: () => void;
|
|
95
|
-
/**
|
|
96
|
-
* @description Windows用アプリの書き出し関数
|
|
97
|
-
* Export function for Windows apps
|
|
98
|
-
*
|
|
99
|
-
* @return {void}
|
|
100
|
-
* @method
|
|
101
|
-
* @public
|
|
102
|
-
*/
|
|
103
|
-
declare const buildSteam: () => void;
|
|
104
|
-
/**
|
|
105
|
-
* @description iOSのプロジェクトを生成
|
|
106
|
-
* Generate iOS project
|
|
107
|
-
*
|
|
108
|
-
* @return {Promise<void>}
|
|
109
|
-
* @method
|
|
110
|
-
* @public
|
|
111
|
-
*/
|
|
112
|
-
declare const generateNativeProject: () => Promise<void>;
|
|
113
|
-
/**
|
|
114
|
-
* @description iOS用アプリの書き出し関数
|
|
115
|
-
* Export function for iOS apps
|
|
116
|
-
*
|
|
117
|
-
* @return {Promise}
|
|
118
|
-
* @method
|
|
119
|
-
* @public
|
|
120
|
-
*/
|
|
121
|
-
declare const runNative: () => Promise<void>;
|
|
122
|
-
/**
|
|
123
|
-
* @description ビルドの実行関数
|
|
124
|
-
* Build Execution Functions
|
|
125
|
-
*
|
|
126
|
-
* @return {void}
|
|
127
|
-
* @method
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
|
-
declare const build: () => void;
|
|
131
|
-
/**
|
|
132
|
-
* @description 実行関数
|
|
133
|
-
* function execution
|
|
134
|
-
*
|
|
135
|
-
* @return {Promise}
|
|
136
|
-
* @method
|
|
137
|
-
* @public
|
|
138
|
-
*/
|
|
139
|
-
declare const execute: () => Promise<void>;
|
|
2
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const electronBuilder = require("electron-builder");
|
|
3
|
+
import pc from "picocolors";
|
|
4
|
+
import fs from "fs";
|
|
5
|
+
import cp from "child_process";
|
|
6
|
+
import { loadConfigFromFile } from "vite";
|
|
7
|
+
import { Platform, build as electronBuilder } from "electron-builder";
|
|
9
8
|
const recommendeVersion = 18;
|
|
10
9
|
const version = process.versions.node;
|
|
11
10
|
if (recommendeVersion > parseInt(version.split(".")[0])) {
|
|
@@ -67,6 +66,24 @@ const echoHelp = () => {
|
|
|
67
66
|
if (hasHelp) {
|
|
68
67
|
echoHelp();
|
|
69
68
|
}
|
|
69
|
+
if (!platform || !environment) {
|
|
70
|
+
echoHelp();
|
|
71
|
+
}
|
|
72
|
+
switch (platform) {
|
|
73
|
+
case "windows":
|
|
74
|
+
case "macos":
|
|
75
|
+
case "linux":
|
|
76
|
+
case "steam:windows":
|
|
77
|
+
case "steam:macos":
|
|
78
|
+
case "steam:linux":
|
|
79
|
+
case "ios":
|
|
80
|
+
case "android":
|
|
81
|
+
case "web":
|
|
82
|
+
break;
|
|
83
|
+
default:
|
|
84
|
+
echoHelp();
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
70
87
|
/**
|
|
71
88
|
* @type {string}
|
|
72
89
|
* @private
|
|
@@ -99,7 +116,12 @@ const CAPACITOR_CONFIG_NAME = "capacitor.config.json";
|
|
|
99
116
|
* @type {string}
|
|
100
117
|
* @constant
|
|
101
118
|
*/
|
|
102
|
-
const
|
|
119
|
+
const ELECTRON_BUILD_CONFIG_NAME = "electron.build.json";
|
|
120
|
+
/**
|
|
121
|
+
* @type {string}
|
|
122
|
+
* @constant
|
|
123
|
+
*/
|
|
124
|
+
const ELECTRON_INDEX_CONFIG_NAME = "electron.index.json";
|
|
103
125
|
/**
|
|
104
126
|
* @return {Promise}
|
|
105
127
|
* @method
|
|
@@ -113,10 +135,11 @@ const loadConfig = () => {
|
|
|
113
135
|
// overwride
|
|
114
136
|
fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(packageJson, null, 2));
|
|
115
137
|
}
|
|
116
|
-
const config = await
|
|
138
|
+
const config = await loadConfigFromFile({
|
|
117
139
|
"command": "build",
|
|
118
140
|
"mode": "build"
|
|
119
141
|
}, `${process.cwd()}/vite.config.ts`);
|
|
142
|
+
// update config
|
|
120
143
|
$configObject = config;
|
|
121
144
|
$outDir = $configObject.config?.build?.outDir || "dist";
|
|
122
145
|
$buildDir = `${process.cwd()}/${$outDir}/${platformDir}/${environment}`;
|
|
@@ -138,8 +161,8 @@ const loadConfig = () => {
|
|
|
138
161
|
*/
|
|
139
162
|
const buildWeb = () => {
|
|
140
163
|
return new Promise((resolve, reject) => {
|
|
141
|
-
const
|
|
142
|
-
|
|
164
|
+
const stream = cp.spawn("npx", [
|
|
165
|
+
"vite",
|
|
143
166
|
"--outDir",
|
|
144
167
|
$buildDir,
|
|
145
168
|
"build"
|
|
@@ -164,16 +187,16 @@ const buildWeb = () => {
|
|
|
164
187
|
*/
|
|
165
188
|
const generateElectronConfig = () => {
|
|
166
189
|
let config = {};
|
|
167
|
-
const configPath = `${process.cwd()}/${
|
|
190
|
+
const configPath = `${process.cwd()}/${ELECTRON_BUILD_CONFIG_NAME}`;
|
|
168
191
|
if (!fs.existsSync(configPath)) {
|
|
169
|
-
console.error(pc.red(`The file \`${
|
|
192
|
+
console.error(pc.red(`The file \`${ELECTRON_BUILD_CONFIG_NAME}\` could not be found.`));
|
|
170
193
|
process.exit(1);
|
|
171
194
|
}
|
|
172
195
|
config = Object.assign(config, JSON.parse(fs.readFileSync(configPath, { "encoding": "utf8" })));
|
|
173
196
|
if (!config.appId) {
|
|
174
197
|
console.log();
|
|
175
198
|
console.log(pc.red("`appId` is not set."));
|
|
176
|
-
console.log(`Please set \`appId\` in \`${
|
|
199
|
+
console.log(`Please set \`appId\` in \`${ELECTRON_BUILD_CONFIG_NAME}\`.`);
|
|
177
200
|
console.log();
|
|
178
201
|
process.exit(1);
|
|
179
202
|
}
|
|
@@ -228,14 +251,11 @@ const generateElectronConfig = () => {
|
|
|
228
251
|
"output": "dist"
|
|
229
252
|
};
|
|
230
253
|
}
|
|
231
|
-
if (config.directories.output.slice(-1) !== "/") {
|
|
232
|
-
config.directories.output += "/";
|
|
233
|
-
}
|
|
234
254
|
if (!("files" in config)) {
|
|
235
255
|
config.files = [];
|
|
236
256
|
}
|
|
237
257
|
config.files.push(`${$outDir}/${platformDir}/${environment}/`);
|
|
238
|
-
config.directories.output
|
|
258
|
+
config.directories.output = `${$outDir}/${platformDir}/build`;
|
|
239
259
|
return config;
|
|
240
260
|
};
|
|
241
261
|
/**
|
|
@@ -248,7 +268,7 @@ const generateElectronConfig = () => {
|
|
|
248
268
|
*/
|
|
249
269
|
const setElectronIndexPath = () => {
|
|
250
270
|
const htmlFilePath = `${$buildDir}/index.html`;
|
|
251
|
-
fs.writeFileSync(`${process.cwd()}
|
|
271
|
+
fs.writeFileSync(`${process.cwd()}/${ELECTRON_INDEX_CONFIG_NAME}`, JSON.stringify({
|
|
252
272
|
"path": htmlFilePath.replace(process.cwd(), ".").trim()
|
|
253
273
|
}, null, 2));
|
|
254
274
|
};
|
|
@@ -261,7 +281,7 @@ const setElectronIndexPath = () => {
|
|
|
261
281
|
* @public
|
|
262
282
|
*/
|
|
263
283
|
const unlinkElectronIndexPath = () => {
|
|
264
|
-
const jsonPath = `${process.cwd()}
|
|
284
|
+
const jsonPath = `${process.cwd()}/${ELECTRON_INDEX_CONFIG_NAME}`;
|
|
265
285
|
if (fs.existsSync(jsonPath)) {
|
|
266
286
|
fs.unlinkSync(jsonPath);
|
|
267
287
|
}
|
|
@@ -275,32 +295,26 @@ const unlinkElectronIndexPath = () => {
|
|
|
275
295
|
* @public
|
|
276
296
|
*/
|
|
277
297
|
const buildSteam = () => {
|
|
278
|
-
const packageJson = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`, { "encoding": "utf8" }));
|
|
279
|
-
// edit type
|
|
280
|
-
packageJson.type = "commonjs";
|
|
281
|
-
// overwride
|
|
282
|
-
fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(packageJson, null, 2));
|
|
283
|
-
// revert type
|
|
284
|
-
packageJson.type = "module";
|
|
285
298
|
/**
|
|
286
299
|
* Electronで読み込むindex.htmlのパスをセット
|
|
287
300
|
* Set the path to index.html to load in Electron
|
|
288
301
|
*/
|
|
289
302
|
setElectronIndexPath();
|
|
290
303
|
if (preview) {
|
|
291
|
-
const
|
|
304
|
+
const packageJson = JSON.parse(fs.readFileSync(`${process.cwd()}/package.json`, { "encoding": "utf8" }));
|
|
305
|
+
packageJson.type = "commonjs";
|
|
306
|
+
fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(packageJson, null, 2));
|
|
307
|
+
cp.spawn(`${process.cwd()}/node_modules/.bin/electron`, [
|
|
292
308
|
`${process.cwd()}/electron.js`
|
|
293
309
|
], { "stdio": "inherit" });
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
if (code !== 0) {
|
|
300
|
-
console.log(pc.red("Failed to start Electron."));
|
|
301
|
-
console.log();
|
|
310
|
+
setTimeout(() => {
|
|
311
|
+
if (packageJson.type !== "module") {
|
|
312
|
+
packageJson.type = "module";
|
|
313
|
+
// overwride
|
|
314
|
+
fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(packageJson, null, 2));
|
|
302
315
|
}
|
|
303
|
-
|
|
316
|
+
unlinkElectronIndexPath();
|
|
317
|
+
}, 1000);
|
|
304
318
|
}
|
|
305
319
|
else {
|
|
306
320
|
/**
|
|
@@ -317,34 +331,31 @@ const buildSteam = () => {
|
|
|
317
331
|
switch (platform) {
|
|
318
332
|
case "windows":
|
|
319
333
|
case "steam:windows":
|
|
320
|
-
buildObject.targets =
|
|
334
|
+
buildObject.targets = Platform.WINDOWS.createTarget();
|
|
321
335
|
break;
|
|
322
336
|
case "macos":
|
|
323
337
|
case "steam:macos":
|
|
324
|
-
buildObject.targets =
|
|
338
|
+
buildObject.targets = Platform.MAC.createTarget();
|
|
325
339
|
break;
|
|
326
340
|
case "linux":
|
|
327
341
|
case "steam:linux":
|
|
328
|
-
buildObject.targets =
|
|
342
|
+
buildObject.targets = Platform.LINUX.createTarget();
|
|
329
343
|
break;
|
|
330
344
|
default:
|
|
345
|
+
unlinkElectronIndexPath();
|
|
331
346
|
console.log(pc.red("There is an error in the export platform settings."));
|
|
332
347
|
console.log();
|
|
348
|
+
process.exit(1);
|
|
333
349
|
break;
|
|
334
350
|
}
|
|
335
|
-
electronBuilder
|
|
336
|
-
.build(buildObject)
|
|
351
|
+
electronBuilder(buildObject)
|
|
337
352
|
.then(() => {
|
|
338
353
|
unlinkElectronIndexPath();
|
|
339
|
-
// reset
|
|
340
|
-
fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(packageJson, null, 2));
|
|
341
354
|
console.log(pc.green(`Finished building \`Electron\` for ${platform}.`));
|
|
342
355
|
console.log();
|
|
343
356
|
})
|
|
344
357
|
.catch((error) => {
|
|
345
358
|
unlinkElectronIndexPath();
|
|
346
|
-
// reset
|
|
347
|
-
fs.writeFileSync(`${process.cwd()}/package.json`, JSON.stringify(packageJson, null, 2));
|
|
348
359
|
console.log(pc.red("Export of Electron failed."));
|
|
349
360
|
console.log(pc.red(error));
|
|
350
361
|
});
|
|
@@ -395,15 +406,11 @@ const runNative = async () => {
|
|
|
395
406
|
const config = JSON.parse(fs.readFileSync(`${process.cwd()}/${CAPACITOR_CONFIG_NAME}`, { "encoding": "utf8" }));
|
|
396
407
|
config.webDir = `${$outDir}/${platformDir}/${environment}/`;
|
|
397
408
|
fs.writeFileSync(`${process.cwd()}/${CAPACITOR_CONFIG_NAME}`, JSON.stringify(config, null, 2));
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
const filePath = process.argv[1];
|
|
404
|
-
process.argv = [nodePath, filePath, "run", platform];
|
|
405
|
-
// run simulator
|
|
406
|
-
cli.run();
|
|
409
|
+
cp.spawn("npx", [
|
|
410
|
+
"cap",
|
|
411
|
+
"run",
|
|
412
|
+
platform
|
|
413
|
+
], { "stdio": "inherit" });
|
|
407
414
|
};
|
|
408
415
|
/**
|
|
409
416
|
* @description ビルドの実行関数
|
|
@@ -413,7 +420,7 @@ const runNative = async () => {
|
|
|
413
420
|
* @method
|
|
414
421
|
* @public
|
|
415
422
|
*/
|
|
416
|
-
const
|
|
423
|
+
const multiBuild = () => {
|
|
417
424
|
switch (platform) {
|
|
418
425
|
case "windows":
|
|
419
426
|
case "macos":
|
|
@@ -448,7 +455,7 @@ const build = () => {
|
|
|
448
455
|
const execute = async () => {
|
|
449
456
|
await loadConfig();
|
|
450
457
|
buildWeb()
|
|
451
|
-
.then(
|
|
458
|
+
.then(multiBuild)
|
|
452
459
|
.catch((error) => {
|
|
453
460
|
console.log(pc.red(error));
|
|
454
461
|
process.exit(1);
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next2d/builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.7",
|
|
4
4
|
"description": "Multi-platform builder for Next2d Framework, supporting export to various platforms such as macOS, Windows, iOS, Android and Web(HTML)",
|
|
5
5
|
"author": "Toshiyuki Ienaga <ienaga@next2d.app>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
9
|
+
"type": "module",
|
|
9
10
|
"homepage": "https://next2d.app",
|
|
10
11
|
"bugs": "https://github.com/Next2D/view-generator/issues",
|
|
11
12
|
"keywords": [
|
|
@@ -33,7 +34,6 @@
|
|
|
33
34
|
"@next2d/builder": "dist/index.js"
|
|
34
35
|
},
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@capacitor/cli": "^5.5.1",
|
|
37
37
|
"@types/node": "^20.9.0",
|
|
38
38
|
"electron": "^27.0.4",
|
|
39
39
|
"electron-builder": "^24.6.4",
|