@upsoft/electroy-app-runtime-bundles-package-dev-tools 1.0.0-alpha.0
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/build-electroy-app-runtime-bundle.js +54 -0
- package/build-electroy-app-runtime-bundles-package-main.js +20 -0
- package/electroy-app-runtime-linux-bundle-webpack-config.js +8 -0
- package/electroy-app-runtime-macos-bundle-webpack-config.js +8 -0
- package/electroy-app-runtime-windows-bundle-webpack-config.js +8 -0
- package/gen-electroy-app-runtime-bundles-package-index-script-file.js +59 -0
- package/get-electroy-app-electron-version.js +23 -0
- package/get-electroy-app-runtime-bundle-dir-path.js +13 -0
- package/get-electroy-app-runtime-bundle-webpack-config.js +81 -0
- package/package.json +25 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
const $spawnasync = require('@expo/spawn-async');
|
|
2
|
+
|
|
3
|
+
exports.buildElectroyAppRuntimeBundle = async (
|
|
4
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
5
|
+
electroyAppTargetOperatingSystemPlatform,
|
|
6
|
+
) => {
|
|
7
|
+
|
|
8
|
+
let npmConfigPlatform;
|
|
9
|
+
|
|
10
|
+
if (electroyAppTargetOperatingSystemPlatform === `windows`) {
|
|
11
|
+
|
|
12
|
+
npmConfigPlatform = `win32`;
|
|
13
|
+
|
|
14
|
+
} else if (electroyAppTargetOperatingSystemPlatform === `macos`) {
|
|
15
|
+
|
|
16
|
+
npmConfigPlatform = `darwin`;
|
|
17
|
+
|
|
18
|
+
} else if (electroyAppTargetOperatingSystemPlatform === `linux`) {
|
|
19
|
+
|
|
20
|
+
npmConfigPlatform = `linux`;
|
|
21
|
+
|
|
22
|
+
} else {
|
|
23
|
+
|
|
24
|
+
throw new Error();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const electroyAppRuntimeBundleWebpackConfigFilePath =
|
|
28
|
+
require.resolve(`./electroy-app-runtime-${electroyAppTargetOperatingSystemPlatform}-bundle-webpack-config.js`);
|
|
29
|
+
|
|
30
|
+
const webpackProcessResult = await $spawnasync(
|
|
31
|
+
`node`,
|
|
32
|
+
[
|
|
33
|
+
require.resolve(`webpack/bin/webpack.js`),
|
|
34
|
+
`build`,
|
|
35
|
+
`--config`,
|
|
36
|
+
electroyAppRuntimeBundleWebpackConfigFilePath,
|
|
37
|
+
],
|
|
38
|
+
{
|
|
39
|
+
stdio: `inherit`,
|
|
40
|
+
cwd: electroyAppRuntimeBundlesPackageDirPath,
|
|
41
|
+
env: {
|
|
42
|
+
...process.env,
|
|
43
|
+
PREBUILDS_ONLY: `true`,
|
|
44
|
+
npm_config_arch: `x64`,
|
|
45
|
+
npm_config_platform: npmConfigPlatform,
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
if (webpackProcessResult.status !== 0) {
|
|
51
|
+
|
|
52
|
+
throw new Error();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const $path = require(`path`);
|
|
4
|
+
|
|
5
|
+
const { buildElectroyAppRuntimeBundle } = require('./build-electroy-app-runtime-bundle');
|
|
6
|
+
const { genElectroyAppRuntimeBundlesPackageIndexScriptFile } = require('./gen-electroy-app-runtime-bundles-package-index-script-file');
|
|
7
|
+
|
|
8
|
+
(async () => {
|
|
9
|
+
|
|
10
|
+
const electroyAppRuntimeBundlesPackageDirPath = $path.resolve(`.`);
|
|
11
|
+
|
|
12
|
+
await Promise.all([
|
|
13
|
+
buildElectroyAppRuntimeBundle(electroyAppRuntimeBundlesPackageDirPath, `windows`),
|
|
14
|
+
buildElectroyAppRuntimeBundle(electroyAppRuntimeBundlesPackageDirPath, `macos`),
|
|
15
|
+
buildElectroyAppRuntimeBundle(electroyAppRuntimeBundlesPackageDirPath, `linux`),
|
|
16
|
+
]);
|
|
17
|
+
|
|
18
|
+
genElectroyAppRuntimeBundlesPackageIndexScriptFile(electroyAppRuntimeBundlesPackageDirPath);
|
|
19
|
+
|
|
20
|
+
})().catch(() => process.exit(1));
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const $fs = require(`fs`);
|
|
2
|
+
const $path = require(`path`);
|
|
3
|
+
|
|
4
|
+
const { getElectroyAppElectronVersion } = require("./get-electroy-app-electron-version");
|
|
5
|
+
|
|
6
|
+
exports.genElectroyAppRuntimeBundlesPackageIndexScriptFile = (
|
|
7
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
8
|
+
) => {
|
|
9
|
+
|
|
10
|
+
const electroyAppElectronVersion = getElectroyAppElectronVersion(
|
|
11
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
let electroyAppRuntimeBundlesPackageIndexScript = ``;
|
|
15
|
+
let electroyAppRuntimeBundlesPackageIndexScriptTypes = ``;
|
|
16
|
+
|
|
17
|
+
electroyAppRuntimeBundlesPackageIndexScript += `exports.electronVersion = "${electroyAppElectronVersion}";\n`;
|
|
18
|
+
electroyAppRuntimeBundlesPackageIndexScriptTypes += `export declare const electronVersion: string;\n`;
|
|
19
|
+
|
|
20
|
+
electroyAppRuntimeBundlesPackageIndexScript += `exports.RUNTIME_WINDOWS_BUNDLE_DIR_PATH = { value: require("path").resolve(__dirname, "../dist/runtime-windows-bundle") };\n`;
|
|
21
|
+
electroyAppRuntimeBundlesPackageIndexScriptTypes += `export declare const RUNTIME_WINDOWS_BUNDLE_DIR_PATH: { value: string; };\n`;
|
|
22
|
+
|
|
23
|
+
electroyAppRuntimeBundlesPackageIndexScript += `exports.RUNTIME_MACOS_BUNDLE_DIR_PATH = { value: require("path").resolve(__dirname, "../dist/runtime-macos-bundle") };\n`;
|
|
24
|
+
electroyAppRuntimeBundlesPackageIndexScriptTypes += `export declare const RUNTIME_MACOS_BUNDLE_DIR_PATH: { value: string; };\n`;
|
|
25
|
+
|
|
26
|
+
electroyAppRuntimeBundlesPackageIndexScript += `exports.RUNTIME_LINUX_BUNDLE_DIR_PATH = { value: require("path").resolve(__dirname, "../dist/runtime-linux-bundle") };\n`;
|
|
27
|
+
electroyAppRuntimeBundlesPackageIndexScriptTypes += `export declare const RUNTIME_LINUX_BUNDLE_DIR_PATH: { value: string; };\n`;
|
|
28
|
+
|
|
29
|
+
electroyAppRuntimeBundlesPackageIndexScript += `exports.RUNTIME_DEV_BUNDLE_DIR_PATH = { value: require("path").resolve(__dirname, "../src") };\n`;
|
|
30
|
+
electroyAppRuntimeBundlesPackageIndexScriptTypes += `export declare const RUNTIME_DEV_BUNDLE_DIR_PATH: { value: string; };\n`;
|
|
31
|
+
|
|
32
|
+
$fs.mkdirSync(
|
|
33
|
+
$path.resolve(
|
|
34
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
35
|
+
`dist`,
|
|
36
|
+
),
|
|
37
|
+
{
|
|
38
|
+
recursive: true,
|
|
39
|
+
},
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
$fs.writeFileSync(
|
|
43
|
+
$path.resolve(
|
|
44
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
45
|
+
`dist`,
|
|
46
|
+
`$index.js`,
|
|
47
|
+
),
|
|
48
|
+
electroyAppRuntimeBundlesPackageIndexScript,
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
$fs.writeFileSync(
|
|
52
|
+
$path.resolve(
|
|
53
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
54
|
+
`dist`,
|
|
55
|
+
`$index.d.ts`,
|
|
56
|
+
),
|
|
57
|
+
electroyAppRuntimeBundlesPackageIndexScriptTypes,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const $fs = require(`fs`);
|
|
2
|
+
const $path = require(`path`);
|
|
3
|
+
|
|
4
|
+
exports.getElectroyAppElectronVersion = (
|
|
5
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
6
|
+
) => {
|
|
7
|
+
|
|
8
|
+
const electroyAppElectronPackageInfoFilePath = $path.resolve(
|
|
9
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
10
|
+
`node_modules`,
|
|
11
|
+
`electron`,
|
|
12
|
+
`package.json`,
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const electroyAppElectronPackageInfo = JSON.parse(
|
|
16
|
+
$fs.readFileSync(
|
|
17
|
+
electroyAppElectronPackageInfoFilePath,
|
|
18
|
+
`utf8`,
|
|
19
|
+
),
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
return electroyAppElectronPackageInfo.version;
|
|
23
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const $path = require(`path`);
|
|
2
|
+
|
|
3
|
+
exports.getElectroyAppRuntimeBundleDirPath = (
|
|
4
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
5
|
+
electroyAppTargetOperatingSystemPlatform,
|
|
6
|
+
) => {
|
|
7
|
+
|
|
8
|
+
return $path.resolve(
|
|
9
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
10
|
+
`dist`,
|
|
11
|
+
`runtime-${electroyAppTargetOperatingSystemPlatform}-bundle`,
|
|
12
|
+
)
|
|
13
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const $path = require(`path`);
|
|
2
|
+
|
|
3
|
+
const { getElectroyAppRuntimeBundleDirPath } = require("./get-electroy-app-runtime-bundle-dir-path");
|
|
4
|
+
|
|
5
|
+
exports.getElectroyAppRuntimeBundleWebpackConfig = (
|
|
6
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
7
|
+
electroyAppTargetOperatingSystemPlatform
|
|
8
|
+
) => {
|
|
9
|
+
|
|
10
|
+
let isElectroyAppRuntimeBundleMinimizerEnabled = true;
|
|
11
|
+
|
|
12
|
+
const electroyAppRuntimeBundlesPackageInfo = require($path.resolve(electroyAppRuntimeBundlesPackageDirPath, `package.json`));
|
|
13
|
+
|
|
14
|
+
if (typeof electroyAppRuntimeBundlesPackageInfo.electroyConfig === `object`) {
|
|
15
|
+
|
|
16
|
+
if (typeof electroyAppRuntimeBundlesPackageInfo.electroyConfig.isRuntimeBundleMinimizerEnabled === `boolean`) {
|
|
17
|
+
|
|
18
|
+
isElectroyAppRuntimeBundleMinimizerEnabled = electroyAppRuntimeBundlesPackageInfo.electroyConfig.isRuntimeBundleMinimizerEnabled;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const electroyAppRuntimeBundleDirPath = getElectroyAppRuntimeBundleDirPath(
|
|
23
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
24
|
+
electroyAppTargetOperatingSystemPlatform,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
mode: `production`,
|
|
29
|
+
devtool: `source-map`,
|
|
30
|
+
entry: {
|
|
31
|
+
main: $path.resolve(
|
|
32
|
+
electroyAppRuntimeBundlesPackageDirPath,
|
|
33
|
+
`src`,
|
|
34
|
+
`main.js`,
|
|
35
|
+
),
|
|
36
|
+
},
|
|
37
|
+
resolve: {
|
|
38
|
+
symlinks: true,
|
|
39
|
+
extensions: [`.js`],
|
|
40
|
+
},
|
|
41
|
+
resolveLoader: {
|
|
42
|
+
modules: [
|
|
43
|
+
// HACK: Since we are delivering the loader as a dependency, we need to help webpack with finding it.
|
|
44
|
+
// require.resolve(`@witcher112/webpack-asset-relocator-loader`) points to @witcher112/webpack-asset-relocator-loader/dist/index.js.
|
|
45
|
+
// By going up 4 levels, we get to the root node_modules where package is located.
|
|
46
|
+
$path.resolve(
|
|
47
|
+
require.resolve(`@witcher112/webpack-asset-relocator-loader`),
|
|
48
|
+
`..`,
|
|
49
|
+
`..`,
|
|
50
|
+
`..`,
|
|
51
|
+
`..`,
|
|
52
|
+
),
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
module: {
|
|
56
|
+
rules: [
|
|
57
|
+
{
|
|
58
|
+
test: /\.(m?js|node)$/,
|
|
59
|
+
parser: {
|
|
60
|
+
amd: false,
|
|
61
|
+
},
|
|
62
|
+
use: {
|
|
63
|
+
loader: `@witcher112/webpack-asset-relocator-loader`,
|
|
64
|
+
options: {
|
|
65
|
+
outputLibraryPackageNameDir: true,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
],
|
|
70
|
+
},
|
|
71
|
+
optimization: {
|
|
72
|
+
minimize: isElectroyAppRuntimeBundleMinimizerEnabled,
|
|
73
|
+
},
|
|
74
|
+
output: {
|
|
75
|
+
filename: `[name].js`,
|
|
76
|
+
path: electroyAppRuntimeBundleDirPath,
|
|
77
|
+
clean: true,
|
|
78
|
+
},
|
|
79
|
+
target: `electron-main`,
|
|
80
|
+
};
|
|
81
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@upsoft/electroy-app-runtime-bundles-package-dev-tools",
|
|
3
|
+
"version": "1.0.0-alpha.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"build-electroy-app-runtime-bundle.js",
|
|
6
|
+
"build-electroy-app-runtime-bundles-package-main.js",
|
|
7
|
+
"electroy-app-runtime-linux-bundle-webpack-config.js",
|
|
8
|
+
"electroy-app-runtime-macos-bundle-webpack-config.js",
|
|
9
|
+
"electroy-app-runtime-windows-bundle-webpack-config.js",
|
|
10
|
+
"gen-electroy-app-runtime-bundles-package-index-script-file.js",
|
|
11
|
+
"get-electroy-app-runtime-bundle-dir-path.js",
|
|
12
|
+
"get-electroy-app-runtime-bundle-webpack-config.js",
|
|
13
|
+
"get-electroy-app-electron-version.js"
|
|
14
|
+
],
|
|
15
|
+
"bin": {
|
|
16
|
+
"build-electroy-app-runtime-bundles-package": "./build-electroy-app-runtime-bundles-package-main.js"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@expo/spawn-async": "^1.0.0",
|
|
20
|
+
"@witcher112/webpack-asset-relocator-loader": "1.8.0-alpha.3",
|
|
21
|
+
"webpack": "5.95.0",
|
|
22
|
+
"webpack-cli": "5.1.4",
|
|
23
|
+
"@upsoft/troy-ts-standard-package-dev-tools": "1.0.0-alpha.0"
|
|
24
|
+
}
|
|
25
|
+
}
|