bundo-appgen 0.0.1-beta.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 +253 -0
- package/bin.mjs +21 -0
- package/lib/bin/bin.mjs +1141 -0
- package/lib/bin/plugin-sandbox-runner.mjs +105 -0
- package/lib/commonjs/index.js +125 -0
- package/lib/module/chunk-bhc5nymd.js +12 -0
- package/lib/module/chunk-dvyy3g4j.js +25 -0
- package/lib/module/chunk-ynqw05p0.js +70 -0
- package/lib/module/config/apple/create-osx-appiconset.js +6 -0
- package/lib/module/config/apple/index.js +7 -0
- package/lib/module/config/index.js +8 -0
- package/lib/module/index.js +8 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/index.d.ts +3 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/set-type.d.ts +42 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/set-type.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/size.d.ts +21 -0
- package/lib/typescript/config/apple/asset-catalog-format/app-icon/size.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/appearances.d.ts +13 -0
- package/lib/typescript/config/apple/asset-catalog-format/appearances.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/idiom.d.ts +5 -0
- package/lib/typescript/config/apple/asset-catalog-format/idiom.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/color-space.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/color-space.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/compression-type.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/compression-type.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/display-gamut.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/display-gamut.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/index.d.ts +6 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/language-direction.d.ts +2 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/language-direction.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/scale.d.ts +9 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/scale.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/set-type.d.ts +58 -0
- package/lib/typescript/config/apple/asset-catalog-format/image/set-type.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalog-format/index.d.ts +5 -0
- package/lib/typescript/config/apple/asset-catalog-format/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts +5 -0
- package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts.map +1 -0
- package/lib/typescript/config/apple/asset-catalogs.d.ts +73 -0
- package/lib/typescript/config/apple/asset-catalogs.d.ts.map +1 -0
- package/lib/typescript/config/apple/create-osx-appiconset.d.mts +72 -0
- package/lib/typescript/config/apple/create-osx-appiconset.d.mts.map +1 -0
- package/lib/typescript/config/apple/data.d.ts +103 -0
- package/lib/typescript/config/apple/data.d.ts.map +1 -0
- package/lib/typescript/config/apple/index.d.mts +8 -0
- package/lib/typescript/config/apple/index.d.mts.map +1 -0
- package/lib/typescript/config/apple/info-plist-value.d.ts +8 -0
- package/lib/typescript/config/apple/info-plist-value.d.ts.map +1 -0
- package/lib/typescript/config/apple/info-plist.d.ts +4 -0
- package/lib/typescript/config/apple/info-plist.d.ts.map +1 -0
- package/lib/typescript/config/apple/string-catalog.d.ts +2 -0
- package/lib/typescript/config/apple/string-catalog.d.ts.map +1 -0
- package/lib/typescript/config/data.d.ts +50 -0
- package/lib/typescript/config/data.d.ts.map +1 -0
- package/lib/typescript/config/index.d.mts +5 -0
- package/lib/typescript/config/index.d.mts.map +1 -0
- package/lib/typescript/config/plugin-item.d.ts +2 -0
- package/lib/typescript/config/plugin-item.d.ts.map +1 -0
- package/lib/typescript/config/plugin-registry.d.ts +3 -0
- package/lib/typescript/config/plugin-registry.d.ts.map +1 -0
- package/lib/typescript/index.d.mts +3 -0
- package/lib/typescript/index.d.mts.map +1 -0
- package/lib/typescript/plugin/apple/context.d.ts +28 -0
- package/lib/typescript/plugin/apple/context.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/files.d.ts +7 -0
- package/lib/typescript/plugin/apple/files.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/index.d.ts +6 -0
- package/lib/typescript/plugin/apple/index.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts +5 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts +11 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts +7 -0
- package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts.map +1 -0
- package/lib/typescript/plugin/context.d.ts +9 -0
- package/lib/typescript/plugin/context.d.ts.map +1 -0
- package/lib/typescript/plugin/index.d.ts +3 -0
- package/lib/typescript/plugin/index.d.ts.map +1 -0
- package/package.json +49 -0
- package/src/_bin/_global-vars/_global-vars.mts +47 -0
- package/src/_bin/_global-vars/index.mts +30 -0
- package/src/_bin/_main/_check-config-validity.mts +94 -0
- package/src/_bin/_main/_evaluate-plugin-registry.mts +181 -0
- package/src/_bin/_main/_exec-plugin-runner/_spawn-plugin-sandbox-runner.mts +149 -0
- package/src/_bin/_main/_exec-plugin-runner/exec-plugin-runner.mts +92 -0
- package/src/_bin/_main/_exec-plugin-runner/index.mts +1 -0
- package/src/_bin/_main/_get-config.mts +64 -0
- package/src/_bin/_main/_helpers/config/get-name.mts +24 -0
- package/src/_bin/_main/_helpers/config/get-project-name.mts +27 -0
- package/src/_bin/_main/_helpers/config/index.mts +2 -0
- package/src/_bin/_main/_helpers/index.mts +2 -0
- package/src/_bin/_main/_helpers/platform/compatibility-error.mts +7 -0
- package/src/_bin/_main/_helpers/platform/data.ts +9 -0
- package/src/_bin/_main/_helpers/platform/get-data.mts +48 -0
- package/src/_bin/_main/_helpers/platform/index.mts +4 -0
- package/src/_bin/_main/_helpers/platform/is-compatible.mts +30 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts +223 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts +241 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/appearances.mts +24 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/idiom.mts +22 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/compression-type.mts +15 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/display-gamut.mts +12 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/index.mts +3 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/language-direction.mts +12 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/index.mts +3 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts +54 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts +134 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts +62 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile.mts +31 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts +17 -0
- package/src/_bin/_main/_init-template/_init-apple/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/init-apple.mts +81 -0
- package/src/_bin/_main/_init-template/index.mts +1 -0
- package/src/_bin/_main/_init-template/init-template.mts +39 -0
- package/src/_bin/_main/_mod-plugin/index.mts +1 -0
- package/src/_bin/_main/_mod-plugin/mod-plugin.mts +77 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts +86 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts +216 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/index.mts +1 -0
- package/src/_bin/_main/_xcodegen/_mod-known-regions/index.ts +1 -0
- package/src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts +52 -0
- package/src/_bin/_main/_xcodegen/index.mts +1 -0
- package/src/_bin/_main/_xcodegen/xcodegen.mts +46 -0
- package/src/_bin/_main/index.mts +1 -0
- package/src/_bin/_main/main.mts +160 -0
- package/src/_bin/bin.mts +68 -0
- package/src/_bin/plugin-sandbox-runner/_exec-plugins.mts +135 -0
- package/src/_bin/plugin-sandbox-runner/argv-json.ts +20 -0
- package/src/_bin/plugin-sandbox-runner/evaluated-plugin-registry.ts +12 -0
- package/src/_bin/plugin-sandbox-runner/index.ts +3 -0
- package/src/_bin/plugin-sandbox-runner/plugin-runner-context-result.ts +33 -0
- package/src/_bin/plugin-sandbox-runner/plugin-sandbox-runner.mts +68 -0
- package/src/config/apple/asset-catalog-format/app-icon/index.ts +2 -0
- package/src/config/apple/asset-catalog-format/app-icon/set-type.ts +59 -0
- package/src/config/apple/asset-catalog-format/app-icon/size.ts +37 -0
- package/src/config/apple/asset-catalog-format/appearances.ts +10 -0
- package/src/config/apple/asset-catalog-format/idiom.ts +16 -0
- package/src/config/apple/asset-catalog-format/image/color-space.ts +3 -0
- package/src/config/apple/asset-catalog-format/image/compression-type.ts +6 -0
- package/src/config/apple/asset-catalog-format/image/display-gamut.ts +3 -0
- package/src/config/apple/asset-catalog-format/image/index.ts +6 -0
- package/src/config/apple/asset-catalog-format/image/language-direction.ts +3 -0
- package/src/config/apple/asset-catalog-format/image/scale.ts +11 -0
- package/src/config/apple/asset-catalog-format/image/set-type.ts +85 -0
- package/src/config/apple/asset-catalog-format/index.ts +4 -0
- package/src/config/apple/asset-catalogs-namespaced.ts +13 -0
- package/src/config/apple/asset-catalogs.ts +76 -0
- package/src/config/apple/create-osx-appiconset.mts +135 -0
- package/src/config/apple/data.ts +123 -0
- package/src/config/apple/index.mts +7 -0
- package/src/config/apple/info-plist-value.ts +16 -0
- package/src/config/apple/info-plist.ts +6 -0
- package/src/config/apple/string-catalog.ts +0 -0
- package/src/config/data.ts +59 -0
- package/src/config/index.mts +4 -0
- package/src/config/plugin-item.ts +4 -0
- package/src/config/plugin-registry.ts +5 -0
- package/src/index.mts +2 -0
- package/src/plugin/apple/context.ts +68 -0
- package/src/plugin/apple/files.ts +14 -0
- package/src/plugin/apple/index.ts +5 -0
- package/src/plugin/apple/pod-spec-source-from-cocoapods.ts +9 -0
- package/src/plugin/apple/pod-spec-source-from-git.ts +13 -0
- package/src/plugin/apple/pod-spec-source-from-local.ts +6 -0
- package/src/plugin/context.ts +12 -0
- package/src/plugin/index.ts +2 -0
package/lib/bin/bin.mjs
ADDED
|
@@ -0,0 +1,1141 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/_bin/bin.mts
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
import * as YargsHelper from "yargs/helpers";
|
|
6
|
+
|
|
7
|
+
// src/_bin/_global-vars/_global-vars.mts
|
|
8
|
+
var prefixName = `__bundo_appgen_${Math.random()}_`;
|
|
9
|
+
var postfixSetCount = "_setcount";
|
|
10
|
+
var postfixSetCountMax = "_setcountmax";
|
|
11
|
+
function globalVars(name, initialValue, maxSetCount) {
|
|
12
|
+
globalThis[prefixName + name] = initialValue;
|
|
13
|
+
globalThis[prefixName + name + postfixSetCount] = 0;
|
|
14
|
+
globalThis[prefixName + name + postfixSetCountMax] = maxSetCount ?? 1;
|
|
15
|
+
return {
|
|
16
|
+
get() {
|
|
17
|
+
return globalThis[prefixName + name];
|
|
18
|
+
},
|
|
19
|
+
set(value) {
|
|
20
|
+
globalThis[prefixName + name + postfixSetCount] += 1;
|
|
21
|
+
if (globalThis[prefixName + name + postfixSetCount] > globalThis[prefixName + name + postfixSetCountMax]) {
|
|
22
|
+
throw new Error("Exceeded amount of modifying.");
|
|
23
|
+
}
|
|
24
|
+
globalThis[prefixName + name] = value;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/_bin/_global-vars/index.mts
|
|
30
|
+
var GlobalVars;
|
|
31
|
+
((GlobalVars) => {
|
|
32
|
+
GlobalVars.appConfig = globalVars("app_config", {});
|
|
33
|
+
GlobalVars.argv = globalVars("argv", {
|
|
34
|
+
clean: false,
|
|
35
|
+
forceCrossPlatform: false,
|
|
36
|
+
path: "",
|
|
37
|
+
xcodegenPath: ""
|
|
38
|
+
});
|
|
39
|
+
GlobalVars.appgenRoot = globalVars("appgen_root", "");
|
|
40
|
+
GlobalVars.configFilePath = globalVars("config_file_path", "");
|
|
41
|
+
})(GlobalVars ||= {});
|
|
42
|
+
|
|
43
|
+
// src/_bin/_main/main.mts
|
|
44
|
+
import * as node_fs14 from "node:fs";
|
|
45
|
+
import * as node_path17 from "node:path";
|
|
46
|
+
|
|
47
|
+
// src/_bin/_main/_helpers/config/get-name.mts
|
|
48
|
+
function getName(config, platform) {
|
|
49
|
+
if (platform == "macos") {
|
|
50
|
+
return config.macos?.name || config.name;
|
|
51
|
+
}
|
|
52
|
+
return config.name;
|
|
53
|
+
}
|
|
54
|
+
// src/_bin/_main/_helpers/config/get-project-name.mts
|
|
55
|
+
var cache;
|
|
56
|
+
function getProjectName(...params) {
|
|
57
|
+
if (cache) {
|
|
58
|
+
return cache;
|
|
59
|
+
}
|
|
60
|
+
const name = getName(...params);
|
|
61
|
+
if (!name) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
cache = name.replace(/[^a-zA-Z0-9]/g, "");
|
|
65
|
+
return cache;
|
|
66
|
+
}
|
|
67
|
+
// src/_bin/_main/_helpers/platform/compatibility-error.mts
|
|
68
|
+
var CompatibilityError = new Error(`
|
|
69
|
+
Cannot run bundo.rn appgen CLI in non compatible platform or JavaScript development runtime.
|
|
70
|
+
|
|
71
|
+
bundo.rn CLIs are compatible for
|
|
72
|
+
Platforms: macOS, Windows, Linux
|
|
73
|
+
Development Runtime: Bun, Node.js
|
|
74
|
+
`);
|
|
75
|
+
// src/_bin/_main/_helpers/platform/is-compatible.mts
|
|
76
|
+
function isCompatible() {
|
|
77
|
+
const supportdRNPlatforms = [
|
|
78
|
+
"darwin",
|
|
79
|
+
"win32"
|
|
80
|
+
], osCompatible = supportdRNPlatforms.indexOf(process.platform) > -1;
|
|
81
|
+
if (!osCompatible) {
|
|
82
|
+
return GlobalVars.argv.get().forceCrossPlatform;
|
|
83
|
+
}
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// src/_bin/_main/_helpers/platform/get-data.mts
|
|
88
|
+
var cache2;
|
|
89
|
+
function getData() {
|
|
90
|
+
if (cache2) {
|
|
91
|
+
return cache2;
|
|
92
|
+
}
|
|
93
|
+
if (!isCompatible()) {
|
|
94
|
+
throw CompatibilityError;
|
|
95
|
+
}
|
|
96
|
+
const isBun = typeof Bun !== "undefined" || !!process.versions.bun;
|
|
97
|
+
let developmentRuntime;
|
|
98
|
+
if (isBun) {
|
|
99
|
+
developmentRuntime = {
|
|
100
|
+
type: "bun",
|
|
101
|
+
version: process.versions.bun
|
|
102
|
+
};
|
|
103
|
+
} else {
|
|
104
|
+
developmentRuntime = {
|
|
105
|
+
type: "node",
|
|
106
|
+
version: process.versions.node
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
cache2 = {
|
|
110
|
+
developmentRuntime
|
|
111
|
+
};
|
|
112
|
+
return cache2;
|
|
113
|
+
}
|
|
114
|
+
// src/_bin/_main/_check-config-validity.mts
|
|
115
|
+
function checkConfigValidity(config) {
|
|
116
|
+
if (!config.macos) {
|
|
117
|
+
throw new Error("No platforms configuration.");
|
|
118
|
+
}
|
|
119
|
+
const isCrossPlatform = GlobalVars.argv.get().forceCrossPlatform;
|
|
120
|
+
if (isCrossPlatform) {
|
|
121
|
+
checkMacosConfig(config);
|
|
122
|
+
} else if (process.platform == "darwin") {
|
|
123
|
+
checkMacosConfig(config);
|
|
124
|
+
} else if (process.platform == "win32") {}
|
|
125
|
+
if (config.plugins) {
|
|
126
|
+
if (Array.isArray(config.plugins)) {
|
|
127
|
+
config.plugins.forEach((plugin) => {
|
|
128
|
+
let isValid = true;
|
|
129
|
+
if (Array.isArray(plugin) && plugin.length) {
|
|
130
|
+
isValid = typeof plugin[0] === "string";
|
|
131
|
+
if (plugin.length > 2) {
|
|
132
|
+
isValid = false;
|
|
133
|
+
} else if (plugin[1]) {
|
|
134
|
+
isValid = typeof plugin[1] === "object" && plugin[1].constructor === Object;
|
|
135
|
+
}
|
|
136
|
+
} else if (typeof plugin === "string" && !plugin.length) {
|
|
137
|
+
isValid = false;
|
|
138
|
+
}
|
|
139
|
+
if (!isValid) {
|
|
140
|
+
throw new Error("Plugin item needs to be an string of the plugin name, or an array of the plugin name and its parameter.");
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
throw new Error("Expected an Array in the plugin registry.");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
class OSFieldError extends Error {
|
|
150
|
+
constructor(prop, os) {
|
|
151
|
+
super(`\`${prop}\` is required for ${os} app.`);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
function checkMacosConfig(config) {
|
|
155
|
+
if (!getName(config, "macos")) {
|
|
156
|
+
throw new Error("`name` or `macos.name` is required in the config.");
|
|
157
|
+
}
|
|
158
|
+
if (!config.macos) {
|
|
159
|
+
throw new Error(`Missing macos property in the config.`);
|
|
160
|
+
}
|
|
161
|
+
if (!config.macos.buildVersion) {
|
|
162
|
+
throw new OSFieldError("buildVersion", "macos");
|
|
163
|
+
}
|
|
164
|
+
if (!config.macos.bundleIdentifier) {
|
|
165
|
+
throw new OSFieldError("bundleIdentifier", "macos");
|
|
166
|
+
}
|
|
167
|
+
if (!config.macos.version) {
|
|
168
|
+
throw new OSFieldError("version", "macos");
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/_bin/_main/_evaluate-plugin-registry.mts
|
|
173
|
+
import * as node_fs from "node:fs";
|
|
174
|
+
import * as node_module from "node:module";
|
|
175
|
+
import * as node_path from "node:path";
|
|
176
|
+
function evaluatePluginRegistry(plugins) {
|
|
177
|
+
if (!plugins?.length) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const registry = [];
|
|
181
|
+
for (const plugin of plugins) {
|
|
182
|
+
let nameOrPath, parameter = undefined;
|
|
183
|
+
if (typeof plugin === "string" && plugin) {
|
|
184
|
+
nameOrPath = plugin;
|
|
185
|
+
} else if (Array.isArray(plugin) && plugin.length && typeof plugin[0] === "string" && plugin[0]) {
|
|
186
|
+
nameOrPath = plugin[0];
|
|
187
|
+
if (plugin[1]) {
|
|
188
|
+
if (typeof plugin[1] === "object" && plugin[1].constructor === Object) {
|
|
189
|
+
parameter = plugin[1];
|
|
190
|
+
} else {
|
|
191
|
+
throw new Error(`The plugin parameter is only supported in plain object. Caused by "${nameOrPath}".`);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
} else {
|
|
195
|
+
throw new Error("The plugin registry is not a valid schema in the config.");
|
|
196
|
+
}
|
|
197
|
+
const mainPathFromNodeModule = getPluginMainPathFromNodeModules(nameOrPath);
|
|
198
|
+
if (mainPathFromNodeModule) {
|
|
199
|
+
registry.push({
|
|
200
|
+
name: nameOrPath,
|
|
201
|
+
mainPath: mainPathFromNodeModule,
|
|
202
|
+
parameter
|
|
203
|
+
});
|
|
204
|
+
continue;
|
|
205
|
+
}
|
|
206
|
+
const filePath = node_path.join(node_path.dirname(GlobalVars.configFilePath.get()), nameOrPath);
|
|
207
|
+
if (node_fs.existsSync(filePath)) {
|
|
208
|
+
const lstat = node_fs.lstatSync(filePath);
|
|
209
|
+
if (lstat.isFile()) {
|
|
210
|
+
registry.push({
|
|
211
|
+
name: nameOrPath,
|
|
212
|
+
mainPath: filePath,
|
|
213
|
+
parameter
|
|
214
|
+
});
|
|
215
|
+
continue;
|
|
216
|
+
} else {
|
|
217
|
+
throw new Error(`${filePath} is not a file.`);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
throw new Error(`"${nameOrPath}" plugin cannot be found.`);
|
|
221
|
+
}
|
|
222
|
+
return registry;
|
|
223
|
+
}
|
|
224
|
+
function getPluginMainPathFromNodeModules(name) {
|
|
225
|
+
let modulePath;
|
|
226
|
+
let isDirectory = true;
|
|
227
|
+
try {
|
|
228
|
+
const __require = node_module.createRequire(node_path.join(process.cwd(), "package.json"));
|
|
229
|
+
const nodeModulePaths = __require.resolve.paths("bundo-appgen");
|
|
230
|
+
if (nodeModulePaths?.length) {
|
|
231
|
+
for (const nodeModulePath of nodeModulePaths) {
|
|
232
|
+
const __modulePath = node_path.join(nodeModulePath, name);
|
|
233
|
+
if (node_fs.existsSync(__modulePath)) {
|
|
234
|
+
const modulePathStat = node_fs.lstatSync(__modulePath);
|
|
235
|
+
if (modulePathStat.isFile()) {
|
|
236
|
+
isDirectory = false;
|
|
237
|
+
}
|
|
238
|
+
if (modulePathStat.isSymbolicLink()) {
|
|
239
|
+
modulePath = node_fs.realpathSync(__modulePath);
|
|
240
|
+
} else {
|
|
241
|
+
modulePath = __modulePath;
|
|
242
|
+
}
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (!modulePath) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
} catch {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
if (!isDirectory) {
|
|
254
|
+
return modulePath;
|
|
255
|
+
}
|
|
256
|
+
let mainPath;
|
|
257
|
+
for (const pluginMainFileExt of pluginMainFileExts) {
|
|
258
|
+
const path = node_path.join(modulePath, `bundo.plugin.${pluginMainFileExt}`);
|
|
259
|
+
if (node_fs.existsSync(path)) {
|
|
260
|
+
const lstat = node_fs.lstatSync(path);
|
|
261
|
+
if (lstat.isSymbolicLink()) {
|
|
262
|
+
mainPath = node_fs.realpathSync(path);
|
|
263
|
+
} else {
|
|
264
|
+
mainPath = path;
|
|
265
|
+
}
|
|
266
|
+
break;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
return mainPath;
|
|
270
|
+
}
|
|
271
|
+
var pluginMainFileExts = [
|
|
272
|
+
"mjs",
|
|
273
|
+
"js"
|
|
274
|
+
];
|
|
275
|
+
|
|
276
|
+
// src/_bin/_main/_exec-plugin-runner/exec-plugin-runner.mts
|
|
277
|
+
import * as node_path3 from "node:path";
|
|
278
|
+
|
|
279
|
+
// src/_bin/_main/_exec-plugin-runner/_spawn-plugin-sandbox-runner.mts
|
|
280
|
+
import * as node_childProcess from "node:child_process";
|
|
281
|
+
import * as node_fs2 from "node:fs";
|
|
282
|
+
import * as node_module2 from "node:module";
|
|
283
|
+
import * as node_path2 from "node:path";
|
|
284
|
+
async function spawnPluginSandboxRunner(registry, permissions, metadata) {
|
|
285
|
+
const requireModule = node_module2.createRequire(process.cwd()), messageID = Math.random().toString();
|
|
286
|
+
return new Promise((resolve) => {
|
|
287
|
+
const nodeArgs = [
|
|
288
|
+
"--permission"
|
|
289
|
+
];
|
|
290
|
+
permissions["--allow-fs-read"]?.forEach((path) => {
|
|
291
|
+
nodeArgs.push(`--allow-fs-read=${path}`);
|
|
292
|
+
});
|
|
293
|
+
permissions["--allow-fs-write"]?.forEach((path) => {
|
|
294
|
+
nodeArgs.push(`--allow-fs-write=${path}`);
|
|
295
|
+
});
|
|
296
|
+
if (permissions["--allow-net"]) {
|
|
297
|
+
nodeArgs.push("--allow-net");
|
|
298
|
+
}
|
|
299
|
+
requireModule.resolve.paths("bundo-appgen")?.forEach((nodeModulePath) => {
|
|
300
|
+
if (nodeModulePath.slice(-"/node".length) != "/node") {
|
|
301
|
+
nodeArgs.push(`--allow-fs-read=${nodeModulePath}`);
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
registry.forEach((plugin) => {
|
|
305
|
+
const pluginDirectory = node_path2.dirname(plugin.mainPath);
|
|
306
|
+
const lstat = node_fs2.lstatSync(pluginDirectory);
|
|
307
|
+
if (lstat.isSymbolicLink()) {
|
|
308
|
+
nodeArgs.push(`--allow-fs-read=${node_fs2.realpathSync(pluginDirectory)}`);
|
|
309
|
+
}
|
|
310
|
+
nodeArgs.push(`--allow-fs-read=${pluginDirectory}`);
|
|
311
|
+
});
|
|
312
|
+
nodeArgs.push(node_path2.join(GlobalVars.appgenRoot.get(), "lib", "bin", "plugin-sandbox-runner.mjs"));
|
|
313
|
+
nodeArgs.push(`--json=${JSON.stringify({
|
|
314
|
+
projectDirectory: metadata.projectDirectory,
|
|
315
|
+
projectName: metadata.projectName,
|
|
316
|
+
evaluatedPluginRegistry: registry,
|
|
317
|
+
messageID
|
|
318
|
+
})}`);
|
|
319
|
+
const pluginRunner = node_childProcess.spawn("node", nodeArgs, {
|
|
320
|
+
stdio: [
|
|
321
|
+
"pipe",
|
|
322
|
+
"pipe",
|
|
323
|
+
"inherit",
|
|
324
|
+
"ipc"
|
|
325
|
+
]
|
|
326
|
+
});
|
|
327
|
+
let message;
|
|
328
|
+
pluginRunner.on("message", (clientMessage) => {
|
|
329
|
+
if (typeof clientMessage === "string") {
|
|
330
|
+
message = clientMessage;
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
pluginRunner.on("exit", (code) => {
|
|
334
|
+
if (code == 0) {
|
|
335
|
+
if (message) {
|
|
336
|
+
const json = JSON.parse(message);
|
|
337
|
+
if (json.messageID === messageID && json.macos && typeof json.macos === "object") {
|
|
338
|
+
delete json.messageID;
|
|
339
|
+
resolve(json);
|
|
340
|
+
} else {
|
|
341
|
+
throw new Error("Plugin Sandbox Runner was not sending a valid result.");
|
|
342
|
+
}
|
|
343
|
+
} else {
|
|
344
|
+
throw new Error("Plugin Sandbox Runner was not sending a valid result.");
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
throw new Error(`Plugin Sandbox Runner exited with ${code} code`);
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// src/_bin/_main/_exec-plugin-runner/exec-plugin-runner.mts
|
|
354
|
+
async function execPluginRunner(registry, options) {
|
|
355
|
+
if (!registry?.length) {
|
|
356
|
+
return;
|
|
357
|
+
}
|
|
358
|
+
const projectDirectory = node_path3.dirname(GlobalVars.configFilePath.get()), projectName = getProjectName(GlobalVars.appConfig.get(), "macos");
|
|
359
|
+
if (options?.mode === "restricted") {
|
|
360
|
+
console.log(`Executing ${registry.length} plugin${registry.length == 1 ? "" : "s"}`);
|
|
361
|
+
return await spawnPluginSandboxRunner(registry, {
|
|
362
|
+
"--allow-fs-read": [
|
|
363
|
+
node_path3.join(projectDirectory, "macos", projectName, "AppDelegate.swift"),
|
|
364
|
+
node_path3.join(projectDirectory, "macos", "Podfile")
|
|
365
|
+
],
|
|
366
|
+
"--allow-fs-write": null,
|
|
367
|
+
"--allow-net": false
|
|
368
|
+
}, {
|
|
369
|
+
projectDirectory,
|
|
370
|
+
projectName
|
|
371
|
+
});
|
|
372
|
+
} else {
|
|
373
|
+
console.log(`Executing ${registry.length} less restrictive plugin${registry.length == 1 ? "" : "s"}`);
|
|
374
|
+
const projectDirectoryMacos = node_path3.join(projectDirectory, "macos");
|
|
375
|
+
return await spawnPluginSandboxRunner(registry, {
|
|
376
|
+
"--allow-fs-read": [
|
|
377
|
+
projectDirectoryMacos
|
|
378
|
+
],
|
|
379
|
+
"--allow-fs-write": [
|
|
380
|
+
projectDirectoryMacos
|
|
381
|
+
],
|
|
382
|
+
"--allow-net": true
|
|
383
|
+
}, {
|
|
384
|
+
projectDirectory,
|
|
385
|
+
projectName
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
// src/_bin/_main/_get-config.mts
|
|
390
|
+
import * as node_module3 from "node:module";
|
|
391
|
+
import * as node_path4 from "node:path";
|
|
392
|
+
var __filename = "/home/runner/work/bundo.rn/bundo.rn/packages/bundo-appgen/src/_bin/_main/_get-config.mts";
|
|
393
|
+
async function getConfig(configFilePath) {
|
|
394
|
+
const ext = node_path4.extname(configFilePath);
|
|
395
|
+
if (ext == ".ts" || ext == ".mts") {
|
|
396
|
+
if (typeof Bun !== "undefined" || process.versions.bun) {
|
|
397
|
+
return import(configFilePath).then((c) => c.default);
|
|
398
|
+
}
|
|
399
|
+
console.log("Resolving your TypeScript file config…");
|
|
400
|
+
try {
|
|
401
|
+
return import("tsx/cjs/api").then(async (tsx) => {
|
|
402
|
+
const result = await tsx.require(configFilePath, __filename);
|
|
403
|
+
return result.default;
|
|
404
|
+
});
|
|
405
|
+
} catch (err) {
|
|
406
|
+
if (err instanceof Error && "code" in err && err.code === "ERR_MODULE_NOT_FOUND") {
|
|
407
|
+
throw new Error(`
|
|
408
|
+
For TypeScript config file, please install \`tsx\` as your dev dependency,
|
|
409
|
+
or you can use Bun, or just use the JavaScript config file.
|
|
410
|
+
`);
|
|
411
|
+
}
|
|
412
|
+
throw err;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
if (ext == ".mjs") {
|
|
416
|
+
return import(configFilePath).then((c) => c.default);
|
|
417
|
+
}
|
|
418
|
+
const requireModule = node_module3.createRequire(configFilePath);
|
|
419
|
+
return requireModule(configFilePath);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// src/_bin/_main/_init-template/init-template.mts
|
|
423
|
+
import * as node_fs9 from "node:fs";
|
|
424
|
+
import * as node_path11 from "node:path";
|
|
425
|
+
|
|
426
|
+
// src/_bin/_main/_init-template/_init-apple/init-apple.mts
|
|
427
|
+
import * as node_fs8 from "node:fs";
|
|
428
|
+
import * as node_path10 from "node:path";
|
|
429
|
+
|
|
430
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts
|
|
431
|
+
import * as node_fs3 from "node:fs";
|
|
432
|
+
import * as node_path5 from "node:path";
|
|
433
|
+
|
|
434
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/appearances.mts
|
|
435
|
+
function appearances(value) {
|
|
436
|
+
if (!Array.isArray(value) || value.length != 1 || !value[0] || typeof value[0] != "object") {
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
const it = value[0];
|
|
440
|
+
return !!__appearance[it.appearance] && !!__value[it.value];
|
|
441
|
+
}
|
|
442
|
+
var __appearance = {
|
|
443
|
+
contrast: 1,
|
|
444
|
+
luminosity: 1
|
|
445
|
+
};
|
|
446
|
+
var __value = {
|
|
447
|
+
dark: 1,
|
|
448
|
+
light: 1
|
|
449
|
+
};
|
|
450
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/idiom.mts
|
|
451
|
+
function idiom(value) {
|
|
452
|
+
return !!value && !!__idiom[value];
|
|
453
|
+
}
|
|
454
|
+
var __idiom = {
|
|
455
|
+
"ios-marketing": 1,
|
|
456
|
+
"watch-marketing": 1,
|
|
457
|
+
appLauncher: 1,
|
|
458
|
+
companionSettings: 1,
|
|
459
|
+
ipad: 1,
|
|
460
|
+
iphone: 1,
|
|
461
|
+
mac: 1,
|
|
462
|
+
notificationCenter: 1,
|
|
463
|
+
quickLook: 1,
|
|
464
|
+
tv: 1,
|
|
465
|
+
universal: 1,
|
|
466
|
+
watch: 1
|
|
467
|
+
};
|
|
468
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/compression-type.mts
|
|
469
|
+
function compressionType(value) {
|
|
470
|
+
return !!value && !!__compressionType[value];
|
|
471
|
+
}
|
|
472
|
+
var __compressionType = {
|
|
473
|
+
"gpu-optimized-best": 1,
|
|
474
|
+
"gpu-optimized-smallest": 1,
|
|
475
|
+
automatic: 1,
|
|
476
|
+
lossless: 1,
|
|
477
|
+
lossy: 1
|
|
478
|
+
};
|
|
479
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/display-gamut.mts
|
|
480
|
+
function displayGamut(value) {
|
|
481
|
+
return !!value && !!displayGamuts[value];
|
|
482
|
+
}
|
|
483
|
+
var displayGamuts = {
|
|
484
|
+
"display-P3": 1,
|
|
485
|
+
sRGB: 1
|
|
486
|
+
};
|
|
487
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/image/language-direction.mts
|
|
488
|
+
function languageDirection(value) {
|
|
489
|
+
return !!value && !!__languageDirection[value];
|
|
490
|
+
}
|
|
491
|
+
var __languageDirection = {
|
|
492
|
+
"left-to-right": 1,
|
|
493
|
+
"right-to-left": 1
|
|
494
|
+
};
|
|
495
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts
|
|
496
|
+
function initAppiconsets(appiconsets, metadata) {
|
|
497
|
+
if (!appiconsets?.length) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
const projectDirectory = node_path5.dirname(GlobalVars.configFilePath.get());
|
|
501
|
+
const targetDirectory = node_path5.join(projectDirectory, "macos", metadata.projectName, "Assets.xcassets");
|
|
502
|
+
let appiconset_index = -1;
|
|
503
|
+
for (const appiconset of appiconsets) {
|
|
504
|
+
if (!appiconset.images.length) {
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
appiconset_index++;
|
|
508
|
+
const _appiconset_directory = node_path5.join(targetDirectory, `${appiconset.name}.appiconset`);
|
|
509
|
+
if (!node_fs3.existsSync(_appiconset_directory)) {
|
|
510
|
+
node_fs3.mkdirSync(_appiconset_directory);
|
|
511
|
+
}
|
|
512
|
+
const contentsJson = {
|
|
513
|
+
images: [],
|
|
514
|
+
info: {
|
|
515
|
+
version: 1,
|
|
516
|
+
author: metadata.bundleIdentifier
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
let image_index = -1;
|
|
520
|
+
for (const { path: imagePath, ...image } of appiconset.images) {
|
|
521
|
+
image_index++;
|
|
522
|
+
const imageFilePath = node_path5.resolve(projectDirectory, imagePath), imageMetadata = {
|
|
523
|
+
appearances: image.appearances?.[0] ? [{
|
|
524
|
+
appearance: image.appearances[0].appearance,
|
|
525
|
+
value: image.appearances[0].value
|
|
526
|
+
}] : undefined,
|
|
527
|
+
"display-gamut": image["display-gamut"] || undefined,
|
|
528
|
+
filename: node_path5.basename(imageFilePath),
|
|
529
|
+
size: image.size,
|
|
530
|
+
idiom: image.idiom || "universal",
|
|
531
|
+
scale: image.scale || "1x"
|
|
532
|
+
};
|
|
533
|
+
{
|
|
534
|
+
const traceStr = `\`appiconsets[${appiconset_index}].images[${image_index}]\``;
|
|
535
|
+
if (!imagePath) {
|
|
536
|
+
throw new Error(`Not a valid image path in the ${traceStr}.`);
|
|
537
|
+
}
|
|
538
|
+
if (image.appearances?.length && !appearances(image.appearances)) {
|
|
539
|
+
throw new Error(`Not a valid appearances in the ${traceStr}.`);
|
|
540
|
+
}
|
|
541
|
+
if (image["display-gamut"] && !displayGamut(image["display-gamut"])) {
|
|
542
|
+
throw new Error(`Not a valid image "display-gamut" in the ${traceStr}.`);
|
|
543
|
+
}
|
|
544
|
+
if (!mapImageSize[image.size]) {
|
|
545
|
+
throw new Error(`Not a valid image size in the ${traceStr}.`);
|
|
546
|
+
}
|
|
547
|
+
if (image["idiom"] && !idiom(image.idiom)) {
|
|
548
|
+
throw new Error(`Not a valid idiom in the ${traceStr}.`);
|
|
549
|
+
}
|
|
550
|
+
if (!node_fs3.existsSync(imageFilePath)) {
|
|
551
|
+
throw new Error(`Cannot find ${imagePath} relatively from your project directory.`);
|
|
552
|
+
}
|
|
553
|
+
const imageExtname = node_path5.extname(imageFilePath);
|
|
554
|
+
if (imageExtname !== ".png") {
|
|
555
|
+
throw new Error(`${imageExtname} file is not supported in Asset Catalogs.`);
|
|
556
|
+
}
|
|
557
|
+
if (contentsJson.images.length) {
|
|
558
|
+
for (const existingImageMetadata of contentsJson.images) {
|
|
559
|
+
const isSimilar = JSON.stringify(existingImageMetadata) === JSON.stringify(imageMetadata);
|
|
560
|
+
if (isSimilar) {
|
|
561
|
+
throw new Error("Cannot use multiple images with same variant.");
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
node_fs3.copyFileSync(imageFilePath, node_path5.join(_appiconset_directory, imageMetadata.filename));
|
|
567
|
+
contentsJson.images.push({ ...imageMetadata });
|
|
568
|
+
}
|
|
569
|
+
node_fs3.writeFileSync(node_path5.join(_appiconset_directory, "Contents.json"), JSON.stringify(contentsJson, null, 2), "utf8");
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
var mapImageSize = {
|
|
573
|
+
"16x16": 1,
|
|
574
|
+
"20x20": 1,
|
|
575
|
+
"24x24": 1,
|
|
576
|
+
"27.5x27.5": 1,
|
|
577
|
+
"29x29": 1,
|
|
578
|
+
"32x32": 1,
|
|
579
|
+
"40x40": 1,
|
|
580
|
+
"44x44": 1,
|
|
581
|
+
"60x60": 1,
|
|
582
|
+
"76x76": 1,
|
|
583
|
+
"83.5x83.5": 1,
|
|
584
|
+
"86x86": 1,
|
|
585
|
+
"98x98": 1,
|
|
586
|
+
"128x128": 1,
|
|
587
|
+
"256x256": 1,
|
|
588
|
+
"512x512": 1,
|
|
589
|
+
"1024x1024": 1
|
|
590
|
+
};
|
|
591
|
+
|
|
592
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts
|
|
593
|
+
import * as node_fs4 from "node:fs";
|
|
594
|
+
import * as node_path6 from "node:path";
|
|
595
|
+
function initImagesets(imagesets, metadata) {
|
|
596
|
+
if (!imagesets?.length) {
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
599
|
+
const projectDirectory = node_path6.dirname(GlobalVars.configFilePath.get());
|
|
600
|
+
let targetDirectory = node_path6.join(projectDirectory, "macos", metadata.projectName, "Assets.xcassets");
|
|
601
|
+
if (metadata.namespace) {
|
|
602
|
+
targetDirectory = node_path6.join(targetDirectory, metadata.namespace);
|
|
603
|
+
node_fs4.mkdirSync(targetDirectory, {
|
|
604
|
+
recursive: true
|
|
605
|
+
});
|
|
606
|
+
node_fs4.writeFileSync(node_path6.join(targetDirectory, "Contents.json"), JSON.stringify({
|
|
607
|
+
info: {
|
|
608
|
+
version: 1,
|
|
609
|
+
author: metadata.bundleIdentifier
|
|
610
|
+
},
|
|
611
|
+
properties: {
|
|
612
|
+
"provides-namespace": true
|
|
613
|
+
}
|
|
614
|
+
}, null, 2), "utf8");
|
|
615
|
+
}
|
|
616
|
+
let imageset_index = -1;
|
|
617
|
+
for (const imageset of imagesets) {
|
|
618
|
+
if (!imageset.images.length) {
|
|
619
|
+
break;
|
|
620
|
+
}
|
|
621
|
+
imageset_index++;
|
|
622
|
+
const _imageset_directory = node_path6.join(targetDirectory, `${imageset.name}.imageset`);
|
|
623
|
+
if (!node_fs4.existsSync(_imageset_directory)) {
|
|
624
|
+
node_fs4.mkdirSync(_imageset_directory);
|
|
625
|
+
}
|
|
626
|
+
const existingImageFilenames = [];
|
|
627
|
+
const contentsJson = {
|
|
628
|
+
images: [],
|
|
629
|
+
info: {
|
|
630
|
+
version: 1,
|
|
631
|
+
author: metadata.bundleIdentifier
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
let image_index = -1;
|
|
635
|
+
for (const { path: imagePath, ...image } of imageset.images) {
|
|
636
|
+
image_index++;
|
|
637
|
+
if (!imagePath) {
|
|
638
|
+
throw new Error("Not a valid image metadata object in the `imagesets[number].images[number]`");
|
|
639
|
+
}
|
|
640
|
+
const imageFilePath = node_path6.resolve(projectDirectory, imagePath), imageMetadata = {
|
|
641
|
+
appearances: image.appearances?.[0] ? [{
|
|
642
|
+
appearance: image.appearances[0].appearance,
|
|
643
|
+
value: image.appearances[0].value
|
|
644
|
+
}] : undefined,
|
|
645
|
+
"compression-type": image["compression-type"] || undefined,
|
|
646
|
+
"display-gamut": image["display-gamut"] || undefined,
|
|
647
|
+
filename: node_path6.basename(imageFilePath),
|
|
648
|
+
idiom: image.idiom || "universal",
|
|
649
|
+
languageDirection: image.languageDirection,
|
|
650
|
+
scale: image.scale || "1x"
|
|
651
|
+
};
|
|
652
|
+
{
|
|
653
|
+
const traceStr = `\`appiconsets[${imageset_index}].images[${image_index}]\``;
|
|
654
|
+
if (!imagePath) {
|
|
655
|
+
throw new Error(`Not a valid image path in the ${traceStr}.`);
|
|
656
|
+
}
|
|
657
|
+
if (image.appearances?.length && !appearances(image.appearances)) {
|
|
658
|
+
throw new Error(`Not a valid appearances in the ${traceStr}.`);
|
|
659
|
+
}
|
|
660
|
+
if (image["compression-type"] && !compressionType(image["compression-type"])) {
|
|
661
|
+
throw new Error(`Not a valid image compression-type in the ${traceStr}.`);
|
|
662
|
+
}
|
|
663
|
+
if (image["display-gamut"] && !displayGamut(image["display-gamut"])) {
|
|
664
|
+
throw new Error(`Not a valid image "display-gamut" in the ${traceStr}.`);
|
|
665
|
+
}
|
|
666
|
+
if (image["idiom"] && !idiom(image.idiom)) {
|
|
667
|
+
throw new Error(`Not a valid idiom in the ${traceStr}.`);
|
|
668
|
+
}
|
|
669
|
+
if (image.languageDirection && !languageDirection(image.languageDirection)) {
|
|
670
|
+
throw new Error(`Not a valid image language direction in the ${traceStr}.`);
|
|
671
|
+
}
|
|
672
|
+
if (!node_fs4.existsSync(imageFilePath)) {
|
|
673
|
+
throw new Error(`Cannot find ${imagePath} relatively from your project directory.`);
|
|
674
|
+
}
|
|
675
|
+
const imageExtname = node_path6.extname(imageFilePath);
|
|
676
|
+
if (supportedImageExts.indexOf(imageExtname) == -1) {
|
|
677
|
+
throw new Error(`${imageExtname} file is not supported in Asset Catalogs.`);
|
|
678
|
+
}
|
|
679
|
+
if (existingImageFilenames.indexOf(imageMetadata.filename) > -1) {
|
|
680
|
+
throw new Error("Cannot use the same image file for different variant.");
|
|
681
|
+
}
|
|
682
|
+
if (contentsJson.images.length) {
|
|
683
|
+
for (const existingImageMetadata of contentsJson.images) {
|
|
684
|
+
const isSimilar = JSON.stringify(existingImageMetadata) === JSON.stringify(imageMetadata);
|
|
685
|
+
if (isSimilar) {
|
|
686
|
+
throw new Error("Cannot use multiple images with same variant.");
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
node_fs4.copyFileSync(imageFilePath, node_path6.join(_imageset_directory, imageMetadata.filename));
|
|
692
|
+
contentsJson.images.push({ ...imageMetadata });
|
|
693
|
+
}
|
|
694
|
+
node_fs4.writeFileSync(node_path6.join(_imageset_directory, "Contents.json"), JSON.stringify(contentsJson, null, 2), "utf8");
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
var supportedImageExts = [
|
|
698
|
+
".heic",
|
|
699
|
+
".heif",
|
|
700
|
+
".jpg",
|
|
701
|
+
".jpeg",
|
|
702
|
+
".png"
|
|
703
|
+
];
|
|
704
|
+
|
|
705
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts
|
|
706
|
+
function createAssetCatalogs(assetCatalogs, metadata) {
|
|
707
|
+
if (!assetCatalogs) {
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
for (const _key of Object.keys(assetCatalogs)) {
|
|
711
|
+
const key = _key;
|
|
712
|
+
if (key == "imagesets") {
|
|
713
|
+
initImagesets(assetCatalogs.imagesets, metadata);
|
|
714
|
+
} else if (key == "appiconsets") {
|
|
715
|
+
initAppiconsets(assetCatalogs.appiconsets, metadata);
|
|
716
|
+
} else {
|
|
717
|
+
const namespacedCatalogs = assetCatalogs[key];
|
|
718
|
+
if (namespacedCatalogs && Object.keys(namespacedCatalogs).length) {
|
|
719
|
+
createAssetCatalogs(namespacedCatalogs, {
|
|
720
|
+
...metadata,
|
|
721
|
+
namespace: key
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
// src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts
|
|
728
|
+
import * as node_fs5 from "node:fs";
|
|
729
|
+
import * as node_path7 from "node:path";
|
|
730
|
+
function createStringCatalogs(stringCatalogs, locales = ["en"], metadata) {
|
|
731
|
+
const config = GlobalVars.appConfig.get(), nativeProjectDir = node_path7.join(node_path7.dirname(GlobalVars.configFilePath.get()), metadata.platform, getProjectName(config, metadata.platform)), catalogs = stringCatalogs ? Object.entries(stringCatalogs) : null;
|
|
732
|
+
if (catalogs?.length) {
|
|
733
|
+
for (const [catalogName, data] of catalogs) {
|
|
734
|
+
const json = {
|
|
735
|
+
sourceLanguage: locales[0],
|
|
736
|
+
strings: {},
|
|
737
|
+
version: "1.2"
|
|
738
|
+
}, keys = Object.keys(data);
|
|
739
|
+
for (const key of keys) {
|
|
740
|
+
const localizedValue = data[key];
|
|
741
|
+
if (!localizedValue) {
|
|
742
|
+
throw new Error(`String catalog of ${catalogName} has invalid configuration.`);
|
|
743
|
+
}
|
|
744
|
+
const localesOfValue = Object.keys(localizedValue);
|
|
745
|
+
{
|
|
746
|
+
for (const localeOfValue of localesOfValue) {
|
|
747
|
+
if (locales.indexOf(localeOfValue) == -1) {
|
|
748
|
+
throw new Error(`"${localeOfValue}" was not found from your \`locales\` config. Add "${localeOfValue}" to the \`locales\` array.`);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
localesOfValue.forEach((locale) => {
|
|
753
|
+
const value = localizedValue[locale];
|
|
754
|
+
if (!value) {
|
|
755
|
+
throw new Error(`\`stringCatalogs.${key}.${locale}\` is empty.`);
|
|
756
|
+
}
|
|
757
|
+
if (!json.strings[key]) {
|
|
758
|
+
json.strings[key] = {
|
|
759
|
+
extractionState: "manual",
|
|
760
|
+
localizations: {
|
|
761
|
+
[locale]: {
|
|
762
|
+
stringUnit: {
|
|
763
|
+
state: "translated",
|
|
764
|
+
value
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
};
|
|
769
|
+
} else {
|
|
770
|
+
json.strings[key].localizations[locale] = {
|
|
771
|
+
stringUnit: {
|
|
772
|
+
state: "translated",
|
|
773
|
+
value
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
}
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
node_fs5.writeFileSync(node_path7.join(nativeProjectDir, `${catalogName}.xcstrings`), JSON.stringify(json, null, 2), "utf8");
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts
|
|
785
|
+
import * as node_fs6 from "node:fs";
|
|
786
|
+
import * as node_path8 from "node:path";
|
|
787
|
+
function appDelegateSwift(platform) {
|
|
788
|
+
const appConfig = GlobalVars.appConfig.get(), projectName = getProjectName(appConfig, platform), appName = getName(appConfig, platform), appDelegateSwiftFilePath = node_path8.join(node_path8.dirname(GlobalVars.configFilePath.get()), platform, getProjectName(GlobalVars.appConfig.get(), platform), "AppDelegate.swift");
|
|
789
|
+
let appDelegateSwiftText = node_fs6.readFileSync(appDelegateSwiftFilePath, "utf8");
|
|
790
|
+
appDelegateSwiftText = appDelegateSwiftText.replace(/Window\("HelloWorld"/, `Window("${appName}"`);
|
|
791
|
+
appDelegateSwiftText = appDelegateSwiftText.replace(/factory.rootViewFactory.view\(withModuleName: "HelloWorld"/, `factory.rootViewFactory.view(withModuleName: "${projectName}"`);
|
|
792
|
+
node_fs6.writeFileSync(appDelegateSwiftFilePath, appDelegateSwiftText, "utf8");
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile.mts
|
|
796
|
+
import * as node_fs7 from "node:fs";
|
|
797
|
+
import * as node_path9 from "node:path";
|
|
798
|
+
function podfile(platform) {
|
|
799
|
+
const projectName = getProjectName(GlobalVars.appConfig.get(), platform), podfilePath = node_path9.join(node_path9.dirname(GlobalVars.configFilePath.get()), platform, "Podfile");
|
|
800
|
+
let podfileText = node_fs7.readFileSync(podfilePath, "utf8");
|
|
801
|
+
podfileText = podfileText.replace(/(target) 'HelloWorld' (do)/, `$1 '${projectName}' $2`);
|
|
802
|
+
node_fs7.writeFileSync(podfilePath, podfileText, "utf8");
|
|
803
|
+
}
|
|
804
|
+
|
|
805
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts
|
|
806
|
+
function modFiles(platform) {
|
|
807
|
+
appDelegateSwift(platform);
|
|
808
|
+
podfile(platform);
|
|
809
|
+
}
|
|
810
|
+
// src/_bin/_main/_init-template/_init-apple/init-apple.mts
|
|
811
|
+
function initApple(platform) {
|
|
812
|
+
const config = GlobalVars.appConfig.get(), projectDirectory = node_path10.dirname(GlobalVars.configFilePath.get()), nativeProjectDirectory = node_path10.join(projectDirectory, platform), templateDir = node_path10.join(GlobalVars.appgenRoot.get(), "template", platform), projectName = getProjectName(config, platform);
|
|
813
|
+
if (!node_fs8.existsSync(nativeProjectDirectory)) {
|
|
814
|
+
node_fs8.cpSync(templateDir, nativeProjectDirectory, { recursive: true });
|
|
815
|
+
node_fs8.renameSync(node_path10.join(nativeProjectDirectory, "HelloWorld"), node_path10.join(nativeProjectDirectory, projectName));
|
|
816
|
+
modFiles(platform);
|
|
817
|
+
}
|
|
818
|
+
const appleData = config[platform];
|
|
819
|
+
createAssetCatalogs(appleData.assetCatalogs, {
|
|
820
|
+
bundleIdentifier: appleData.bundleIdentifier,
|
|
821
|
+
platform,
|
|
822
|
+
projectName
|
|
823
|
+
});
|
|
824
|
+
createStringCatalogs(appleData.stringCatalogs, appleData.locales, {
|
|
825
|
+
platform
|
|
826
|
+
});
|
|
827
|
+
}
|
|
828
|
+
// src/_bin/_main/_init-template/init-template.mts
|
|
829
|
+
function initTemplate() {
|
|
830
|
+
try {
|
|
831
|
+
if (process.platform == "darwin") {
|
|
832
|
+
initApple("macos");
|
|
833
|
+
} else if (process.platform == "win32") {} else {
|
|
834
|
+
initApple("macos");
|
|
835
|
+
}
|
|
836
|
+
} catch (err) {
|
|
837
|
+
const projectDirectory = node_path11.dirname(GlobalVars.configFilePath.get()), projectMacosDir = node_path11.join(projectDirectory, "macos");
|
|
838
|
+
if (node_fs9.existsSync(projectMacosDir)) {
|
|
839
|
+
node_fs9.rmSync(projectMacosDir, { recursive: true, force: true });
|
|
840
|
+
}
|
|
841
|
+
throw err;
|
|
842
|
+
}
|
|
843
|
+
}
|
|
844
|
+
// src/_bin/_main/_mod-plugin/mod-plugin.mts
|
|
845
|
+
import * as node_fs10 from "node:fs";
|
|
846
|
+
import * as node_path12 from "node:path";
|
|
847
|
+
function modPlugin(contextResult) {
|
|
848
|
+
const config = GlobalVars.appConfig.get(), projectDirectory = node_path12.dirname(GlobalVars.configFilePath.get());
|
|
849
|
+
{
|
|
850
|
+
const projectName = getProjectName(config, "macos"), nativeProjectDir = node_path12.join(projectDirectory, "macos");
|
|
851
|
+
node_fs10.writeFileSync(node_path12.join(nativeProjectDir, projectName, "AppDelegate.swift"), contextResult.macos.files.Project["AppDelegate.swift"], "utf8");
|
|
852
|
+
node_fs10.writeFileSync(node_path12.join(nativeProjectDir, "Podfile"), contextResult.macos.files.Podfile, "utf8");
|
|
853
|
+
}
|
|
854
|
+
}
|
|
855
|
+
// src/_bin/_main/_xcodegen/xcodegen.mts
|
|
856
|
+
import * as node_childProcess2 from "node:child_process";
|
|
857
|
+
import * as node_path16 from "node:path";
|
|
858
|
+
|
|
859
|
+
// src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts
|
|
860
|
+
import * as node_fs12 from "node:fs";
|
|
861
|
+
import * as node_module4 from "node:module";
|
|
862
|
+
import * as node_path14 from "node:path";
|
|
863
|
+
|
|
864
|
+
// src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts
|
|
865
|
+
import * as node_fs11 from "node:fs";
|
|
866
|
+
import * as node_path13 from "node:path";
|
|
867
|
+
function initResources(resources, metadata) {
|
|
868
|
+
if (!resources?.length) {
|
|
869
|
+
return null;
|
|
870
|
+
}
|
|
871
|
+
const projectDirectory = node_path13.dirname(GlobalVars.configFilePath.get()), resourcesDirectory = node_path13.join(projectDirectory, metadata.platform, "Resources"), data = [];
|
|
872
|
+
node_fs11.rmSync(resourcesDirectory, { recursive: true, force: true });
|
|
873
|
+
node_fs11.mkdirSync(resourcesDirectory);
|
|
874
|
+
try {
|
|
875
|
+
for (const resource of resources) {
|
|
876
|
+
let path = node_path13.resolve(projectDirectory, resource);
|
|
877
|
+
if (!node_fs11.existsSync(path)) {
|
|
878
|
+
throw new Error(`The ${path} was not found.`);
|
|
879
|
+
}
|
|
880
|
+
const lstat = node_fs11.lstatSync(path);
|
|
881
|
+
if (lstat.isSymbolicLink()) {
|
|
882
|
+
path = node_fs11.realpathSync(path);
|
|
883
|
+
}
|
|
884
|
+
console.log(`\x1B[32mCopying resource\x1B[0m \x1B[36m${path}\x1B[0m`);
|
|
885
|
+
node_fs11.cpSync(path, node_path13.join(resourcesDirectory, node_path13.basename(path)), {
|
|
886
|
+
recursive: true,
|
|
887
|
+
force: true
|
|
888
|
+
});
|
|
889
|
+
data.push({
|
|
890
|
+
basename: node_path13.basename(path),
|
|
891
|
+
isDirectory: lstat.isDirectory()
|
|
892
|
+
});
|
|
893
|
+
}
|
|
894
|
+
} catch (err) {
|
|
895
|
+
node_fs11.rmSync(resourcesDirectory, { force: true, recursive: true });
|
|
896
|
+
throw err;
|
|
897
|
+
}
|
|
898
|
+
return data;
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
// src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts
|
|
902
|
+
function createProjectSpec(platform, overrideConfig) {
|
|
903
|
+
const projectDirectory = node_path14.dirname(GlobalVars.configFilePath.get()), nativeProjectDir = node_path14.join(projectDirectory, platform);
|
|
904
|
+
if (!node_fs12.existsSync(projectDirectory)) {
|
|
905
|
+
throw new Error(`An unexpected happened. ${projectDirectory} was not found.`);
|
|
906
|
+
}
|
|
907
|
+
const config = GlobalVars.appConfig.get();
|
|
908
|
+
if (config.macos?.appicon && (!config.macos.assetCatalogs?.appiconsets?.length || !config.macos.assetCatalogs.appiconsets.some((set) => set.name == config.macos?.appicon))) {
|
|
909
|
+
throw new Error(`No appicon with the name "${config.macos.appicon}" was found in the appiconsets in Asset Catalogs.`);
|
|
910
|
+
}
|
|
911
|
+
if (platform == "macos" && !config.macos) {
|
|
912
|
+
throw new Error(`${platform} configuration was not found.`);
|
|
913
|
+
}
|
|
914
|
+
const requireFromNativeDirectory = node_module4.createRequire(nativeProjectDir), reactNativeXcodeScriptRelativePath = node_path14.relative(nativeProjectDir, platform == "macos" ? requireFromNativeDirectory.resolve("react-native-macos/scripts/react-native-xcode.sh") : requireFromNativeDirectory.resolve("react-native/scripts/react-native-xcode.sh")), appleData = {
|
|
915
|
+
...config[platform],
|
|
916
|
+
infoPlist: {
|
|
917
|
+
...overrideConfig?.infoPlist,
|
|
918
|
+
...config[platform].infoPlist
|
|
919
|
+
}
|
|
920
|
+
}, projectName = getProjectName(config, platform), resourcesData = initResources(config.macos?.resources, {
|
|
921
|
+
platform
|
|
922
|
+
}), json = {
|
|
923
|
+
name: projectName,
|
|
924
|
+
targets: {
|
|
925
|
+
[projectName]: {
|
|
926
|
+
type: "application",
|
|
927
|
+
platform: platform == "macos" ? "macOS" : "iOS",
|
|
928
|
+
deploymentTarget: appleData.minimumDeployment || "15.6",
|
|
929
|
+
sources: [
|
|
930
|
+
{
|
|
931
|
+
path: projectName,
|
|
932
|
+
type: "syncedFolder"
|
|
933
|
+
},
|
|
934
|
+
...resourcesData?.map((resource) => {
|
|
935
|
+
return {
|
|
936
|
+
path: "Resources",
|
|
937
|
+
buildPhase: {
|
|
938
|
+
copyFiles: {
|
|
939
|
+
destination: "resources",
|
|
940
|
+
subpath: resource.isDirectory ? resource.basename : undefined
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
};
|
|
944
|
+
}) ?? []
|
|
945
|
+
],
|
|
946
|
+
info: {
|
|
947
|
+
path: `${projectName}/Info.plist`,
|
|
948
|
+
properties: {
|
|
949
|
+
CFBundleDisplayName: getName(config, platform),
|
|
950
|
+
CFBundleShortVersionString: "$(MARKETING_VERSION)",
|
|
951
|
+
CFBundleVersion: "$(CURRENT_PROJECT_VERSION)",
|
|
952
|
+
NSAppTransportSecurity: {
|
|
953
|
+
NSAllowsArbitraryLoads: true,
|
|
954
|
+
NSExceptionDomains: {
|
|
955
|
+
localhost: {
|
|
956
|
+
NSExceptionAllowsInsecureHTTPLoads: true
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
},
|
|
960
|
+
NSPrincipalClass: "NSApplication",
|
|
961
|
+
NSSupportsAutomaticTermination: true,
|
|
962
|
+
NSSupportsSuddenTermination: true,
|
|
963
|
+
...appleData.infoPlist
|
|
964
|
+
}
|
|
965
|
+
},
|
|
966
|
+
postBuildScripts: [
|
|
967
|
+
{
|
|
968
|
+
name: "Bundle React Native code and images",
|
|
969
|
+
script: `export NODE_BINARY=node
|
|
970
|
+
${reactNativeXcodeScriptRelativePath}`
|
|
971
|
+
}
|
|
972
|
+
],
|
|
973
|
+
scheme: {},
|
|
974
|
+
settings: {
|
|
975
|
+
ASSETCATALOG_COMPILER_APPICON_NAME: appleData.appicon
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
},
|
|
979
|
+
settings: {
|
|
980
|
+
base: {
|
|
981
|
+
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS: true,
|
|
982
|
+
CODE_SIGN_STYLE: "Automatic",
|
|
983
|
+
CURRENT_PROJECT_VERSION: appleData.buildVersion || "1",
|
|
984
|
+
GENERATE_INFOPLIST_FILE: true,
|
|
985
|
+
LD_RUNPATH_SEARCH_PATHS: "$(inherited) @executable_path/Frameworks",
|
|
986
|
+
MARKETING_VERSION: appleData.version || "1.0.0",
|
|
987
|
+
OTHER_LDFLAGS: "$(inherited) -ObjC -lc++",
|
|
988
|
+
PRODUCT_BUNDLE_IDENTIFIER: appleData.bundleIdentifier
|
|
989
|
+
}
|
|
990
|
+
},
|
|
991
|
+
options: {
|
|
992
|
+
useBaseInternationalization: false
|
|
993
|
+
}
|
|
994
|
+
};
|
|
995
|
+
node_fs12.writeFileSync(node_path14.join(nativeProjectDir, "project.json"), JSON.stringify(json, null, 2), "utf8");
|
|
996
|
+
}
|
|
997
|
+
// src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts
|
|
998
|
+
import * as node_fs13 from "node:fs";
|
|
999
|
+
import * as node_path15 from "node:path";
|
|
1000
|
+
function modKnownRegions(platform) {
|
|
1001
|
+
const config = GlobalVars.appConfig.get(), appleData = config[platform];
|
|
1002
|
+
if (!appleData?.locales?.length) {
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const projectName = getProjectName(config, platform), pbxprojPath = node_path15.join(node_path15.dirname(GlobalVars.configFilePath.get()), platform, `${projectName}.xcodeproj`, "project.pbxproj");
|
|
1006
|
+
let file = node_fs13.readFileSync(pbxprojPath, "utf8");
|
|
1007
|
+
let strReplacer = "knownRegions = (";
|
|
1008
|
+
appleData.locales.forEach((locale) => {
|
|
1009
|
+
strReplacer += `
|
|
1010
|
+
$2${locale},`;
|
|
1011
|
+
});
|
|
1012
|
+
strReplacer += "$3";
|
|
1013
|
+
file = file.replace(/knownRegions = \((\n(\t+)\w+,)+(\n\t+\);)/, strReplacer);
|
|
1014
|
+
node_fs13.writeFileSync(pbxprojPath, file, "utf8");
|
|
1015
|
+
}
|
|
1016
|
+
|
|
1017
|
+
// src/_bin/_main/_xcodegen/xcodegen.mts
|
|
1018
|
+
function xcodegen(platform, overrideConfig) {
|
|
1019
|
+
createProjectSpec(platform, overrideConfig);
|
|
1020
|
+
const xcodegenPath = GlobalVars.argv.get().xcodegenPath, nativeProjectDir = node_path16.join(node_path16.dirname(GlobalVars.configFilePath.get()), platform);
|
|
1021
|
+
node_childProcess2.execSync(`${xcodegenPath} --spec project.json`, {
|
|
1022
|
+
cwd: nativeProjectDir,
|
|
1023
|
+
stdio: "inherit"
|
|
1024
|
+
});
|
|
1025
|
+
modKnownRegions(platform);
|
|
1026
|
+
node_childProcess2.execSync(`pod install`, {
|
|
1027
|
+
cwd: nativeProjectDir,
|
|
1028
|
+
stdio: "inherit"
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
// src/_bin/_main/main.mts
|
|
1032
|
+
async function main() {
|
|
1033
|
+
getData();
|
|
1034
|
+
let configFilePath = "";
|
|
1035
|
+
const argv = GlobalVars.argv.get();
|
|
1036
|
+
if (argv.path) {
|
|
1037
|
+
const isValidExt = isValidConfigFileExt(argv.path);
|
|
1038
|
+
if (!isValidExt) {
|
|
1039
|
+
throw new Error(`App config file only compatible with ${configFileExts.join(" | ")}`);
|
|
1040
|
+
}
|
|
1041
|
+
const targetConfigFilePath = node_path17.resolve(process.cwd(), argv.path);
|
|
1042
|
+
if (!node_fs14.existsSync(targetConfigFilePath)) {
|
|
1043
|
+
throw new Error(`${targetConfigFilePath} file doesn't exist.`);
|
|
1044
|
+
}
|
|
1045
|
+
configFilePath = node_path17.resolve(process.cwd(), argv.path);
|
|
1046
|
+
} else {
|
|
1047
|
+
for (let i = 0;i < configFileExts.length; i++) {
|
|
1048
|
+
const targetConfigFilePath = node_path17.join(process.cwd(), `bundo.config.${configFileExts[i]}`);
|
|
1049
|
+
if (node_fs14.existsSync(targetConfigFilePath)) {
|
|
1050
|
+
configFilePath = targetConfigFilePath;
|
|
1051
|
+
break;
|
|
1052
|
+
} else if (i == configFileExts.length - 1) {
|
|
1053
|
+
throw new Error("Cannot found bundo config file.");
|
|
1054
|
+
}
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
GlobalVars.configFilePath.set(configFilePath);
|
|
1058
|
+
console.log("Retrieving config");
|
|
1059
|
+
const config = await getConfig(configFilePath);
|
|
1060
|
+
console.log("Validating config");
|
|
1061
|
+
checkConfigValidity(config);
|
|
1062
|
+
GlobalVars.appConfig.set(config);
|
|
1063
|
+
console.log("Evaluating the plugin registry if any");
|
|
1064
|
+
const pluginRegistry = evaluatePluginRegistry(config.plugins);
|
|
1065
|
+
const unrestrictedPluginRegistry = evaluatePluginRegistry(config.lessRestrictivePlugins);
|
|
1066
|
+
initTemplate();
|
|
1067
|
+
const pluginSandboxedContextResult = await execPluginRunner(pluginRegistry, {
|
|
1068
|
+
mode: "restricted"
|
|
1069
|
+
});
|
|
1070
|
+
const pluginContextResult = await execPluginRunner(unrestrictedPluginRegistry, {
|
|
1071
|
+
mode: "lessRestrictive"
|
|
1072
|
+
});
|
|
1073
|
+
if (pluginSandboxedContextResult) {
|
|
1074
|
+
modPlugin(pluginSandboxedContextResult);
|
|
1075
|
+
}
|
|
1076
|
+
if (pluginContextResult) {
|
|
1077
|
+
modPlugin(pluginContextResult);
|
|
1078
|
+
}
|
|
1079
|
+
xcodegen("macos", {
|
|
1080
|
+
infoPlist: {
|
|
1081
|
+
...pluginSandboxedContextResult?.macos.infoPlist,
|
|
1082
|
+
...pluginContextResult?.macos.infoPlist
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
var configFileExts = [
|
|
1087
|
+
"ts",
|
|
1088
|
+
"mts",
|
|
1089
|
+
"mjs",
|
|
1090
|
+
"js"
|
|
1091
|
+
];
|
|
1092
|
+
function isValidConfigFileExt(filePath) {
|
|
1093
|
+
const ext = node_path17.extname(filePath);
|
|
1094
|
+
if (!ext) {
|
|
1095
|
+
return false;
|
|
1096
|
+
}
|
|
1097
|
+
return configFileExts.indexOf(ext.slice(1)) > -1;
|
|
1098
|
+
}
|
|
1099
|
+
// src/_bin/bin.mts
|
|
1100
|
+
async function bin(bundoAppgenRoot) {
|
|
1101
|
+
GlobalVars.appgenRoot.set(bundoAppgenRoot);
|
|
1102
|
+
try {
|
|
1103
|
+
const argv = yargs(YargsHelper.hideBin(process.argv)).options({
|
|
1104
|
+
clean: {
|
|
1105
|
+
type: "boolean",
|
|
1106
|
+
description: "Perform clean app generation."
|
|
1107
|
+
},
|
|
1108
|
+
"force-cross-platform": {
|
|
1109
|
+
type: "boolean",
|
|
1110
|
+
description: "Experimentally force the script to init native app in non compatible OS."
|
|
1111
|
+
},
|
|
1112
|
+
path: {
|
|
1113
|
+
alias: "p",
|
|
1114
|
+
type: "string",
|
|
1115
|
+
description: "Use specific configuration file target."
|
|
1116
|
+
},
|
|
1117
|
+
"xcodegen-path": {
|
|
1118
|
+
type: "string",
|
|
1119
|
+
description: "Use specific XcodeGen binary."
|
|
1120
|
+
}
|
|
1121
|
+
}).parseSync();
|
|
1122
|
+
GlobalVars.argv.set({
|
|
1123
|
+
clean: !!argv.clean,
|
|
1124
|
+
forceCrossPlatform: !!argv["force-cross-platform"],
|
|
1125
|
+
path: argv.path || "",
|
|
1126
|
+
xcodegenPath: argv["xcodegen-path"] || "xcodegen"
|
|
1127
|
+
});
|
|
1128
|
+
await main();
|
|
1129
|
+
} catch (err) {
|
|
1130
|
+
if (err instanceof Error && err.message) {
|
|
1131
|
+
console.error("\x1B[31mError\x1B[0m: " + err.message);
|
|
1132
|
+
process.exitCode = 1;
|
|
1133
|
+
} else {
|
|
1134
|
+
console.error("Unknown error. Please report it to https://github.com/RakaDoank/bundo.rn", { cause: err });
|
|
1135
|
+
process.exitCode = 1;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
}
|
|
1139
|
+
export {
|
|
1140
|
+
bin
|
|
1141
|
+
};
|