bundo-appgen 0.0.10 → 0.0.12
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/lib/bin/bin.mjs +550 -191
- package/lib/module/{chunk-dvyy3g4j.js → chunk-mxb4tw3v.js} +0 -1
- package/lib/module/{chunk-bhc5nymd.js → chunk-z47xn1nx.js} +1 -2
- package/lib/module/config/apple/index.js +1 -1
- package/lib/module/config/index.js +2 -2
- package/lib/module/index.js +2 -2
- package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts +5 -1
- package/lib/typescript/config/apple/asset-catalogs-namespaced.d.ts.map +1 -1
- package/lib/typescript/config/apple/data.d.ts +22 -3
- package/lib/typescript/config/apple/data.d.ts.map +1 -1
- package/lib/typescript/config/apple/index.d.mts +3 -2
- package/lib/typescript/config/apple/index.d.mts.map +1 -1
- package/lib/typescript/config/apple/plist-value.d.ts +6 -0
- package/lib/typescript/config/apple/plist-value.d.ts.map +1 -0
- package/lib/typescript/config/apple/plist.d.ts +4 -0
- package/lib/typescript/config/apple/plist.d.ts.map +1 -0
- package/lib/typescript/config/apple/podfile/index.d.ts +5 -0
- package/lib/typescript/config/apple/podfile/index.d.ts.map +1 -0
- package/lib/typescript/config/apple/podfile/pod-dependency-from-cocoapods.d.ts +12 -0
- package/lib/typescript/config/apple/podfile/pod-dependency-from-cocoapods.d.ts.map +1 -0
- package/lib/typescript/config/apple/podfile/pod-dependency-from-git.d.ts +16 -0
- package/lib/typescript/config/apple/podfile/pod-dependency-from-git.d.ts.map +1 -0
- package/lib/typescript/config/apple/podfile/pod-dependency-from-local.d.ts +12 -0
- package/lib/typescript/config/apple/podfile/pod-dependency-from-local.d.ts.map +1 -0
- package/lib/typescript/config/apple/podfile/pod-dependency.d.ts +5 -0
- package/lib/typescript/config/apple/podfile/pod-dependency.d.ts.map +1 -0
- package/lib/typescript/plugin/apple/context.d.ts +1 -1
- package/lib/typescript/plugin/apple/context.d.ts.map +1 -1
- package/lib/typescript/plugin/apple/index.d.ts +0 -3
- package/lib/typescript/plugin/apple/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/_bin/_main/_check-config-validity.mts +10 -2
- package/src/_bin/_main/_helpers/config/cache-paths/asset-catalogs-tracker-file.mts +9 -0
- package/src/_bin/_main/_helpers/config/cache-paths/dir-cache.mts +19 -0
- package/src/_bin/_main/_helpers/config/cache-paths/index.mts +3 -0
- package/src/_bin/_main/_helpers/config/cache-paths/string-catalogs-tracker-file.mts +9 -0
- package/src/_bin/_main/_helpers/config/get-name.mts +1 -3
- package/src/_bin/_main/_helpers/config/get-project-name.mts +10 -5
- package/src/_bin/_main/_helpers/config/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_get-xcassets-path.mts +29 -0
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts +25 -12
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts +32 -13
- package/src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts +214 -9
- package/src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts +159 -81
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts +3 -6
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/_pod-dependencies.mts +78 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/index.mts +1 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/{_podfile.mts → _podfile/podfile.mts} +16 -4
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/_privacy-manifest.mts +119 -0
- package/src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts +8 -2
- package/src/_bin/_main/_init-template/_init-apple/init-apple.mts +13 -8
- package/src/_bin/_main/_init-template/init-template.mts +2 -0
- package/src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts +21 -9
- package/src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts +51 -32
- package/src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts +2 -2
- package/src/_bin/_main/_xcodegen/xcodegen.mts +1 -1
- package/src/_bin/_main/main.mts +1 -1
- package/src/_bin/plugin-sandbox-runner/plugin-runner-context-result.ts +0 -27
- package/src/config/apple/asset-catalogs-namespaced.ts +1 -1
- package/src/config/apple/data.ts +27 -4
- package/src/config/apple/index.mts +3 -2
- package/src/config/apple/{info-plist-value.ts → plist-value.ts} +5 -4
- package/src/config/apple/plist.ts +6 -0
- package/src/config/apple/podfile/index.ts +4 -0
- package/src/config/apple/podfile/pod-dependency-from-cocoapods.ts +15 -0
- package/src/config/apple/podfile/pod-dependency-from-git.ts +23 -0
- package/src/config/apple/podfile/pod-dependency-from-local.ts +15 -0
- package/src/config/apple/podfile/pod-dependency.ts +16 -0
- package/src/plugin/apple/context.ts +1 -35
- package/src/plugin/apple/index.ts +0 -3
- package/template/macos/Podfile +4 -0
- package/template/macos/PrivacyInfo.xcprivacy +5 -0
- package/template/macos/pod_dependencies.rb +2 -0
- package/lib/typescript/config/apple/info-plist-value.d.ts +0 -8
- package/lib/typescript/config/apple/info-plist-value.d.ts.map +0 -1
- package/lib/typescript/config/apple/info-plist.d.ts +0 -4
- package/lib/typescript/config/apple/info-plist.d.ts.map +0 -1
- package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts +0 -5
- package/lib/typescript/plugin/apple/pod-spec-source-from-cocoapods.d.ts.map +0 -1
- package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts +0 -11
- package/lib/typescript/plugin/apple/pod-spec-source-from-git.d.ts.map +0 -1
- package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts +0 -7
- package/lib/typescript/plugin/apple/pod-spec-source-from-local.d.ts.map +0 -1
- package/src/config/apple/info-plist.ts +0 -6
- package/src/plugin/apple/pod-spec-source-from-cocoapods.ts +0 -9
- package/src/plugin/apple/pod-spec-source-from-git.ts +0 -13
- package/src/plugin/apple/pod-spec-source-from-local.ts +0 -6
package/lib/bin/bin.mjs
CHANGED
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __returnValue = (v) => v;
|
|
4
|
+
function __exportSetter(name, newValue) {
|
|
5
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
6
|
+
}
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, {
|
|
10
|
+
get: all[name],
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
set: __exportSetter.bind(all, name)
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// src/_bin/_main/_helpers/config/cache-paths/index.mts
|
|
18
|
+
var exports_cache_paths = {};
|
|
19
|
+
__export(exports_cache_paths, {
|
|
20
|
+
assetCatalogsTrackerFile: () => assetCatalogsTrackerFile,
|
|
21
|
+
dirCache: () => dirCache,
|
|
22
|
+
stringCatalogsTrackerFile: () => stringCatalogsTrackerFile
|
|
23
|
+
});
|
|
2
24
|
|
|
3
25
|
// src/_bin/bin.mts
|
|
4
26
|
import yargs from "yargs";
|
|
@@ -41,9 +63,32 @@ var GlobalVars;
|
|
|
41
63
|
})(GlobalVars ||= {});
|
|
42
64
|
|
|
43
65
|
// src/_bin/_main/main.mts
|
|
44
|
-
import * as
|
|
45
|
-
import * as
|
|
66
|
+
import * as node_fs18 from "node:fs";
|
|
67
|
+
import * as node_path24 from "node:path";
|
|
68
|
+
|
|
69
|
+
// src/_bin/_main/_helpers/config/cache-paths/asset-catalogs-tracker-file.mts
|
|
70
|
+
import * as node_path2 from "node:path";
|
|
71
|
+
|
|
72
|
+
// src/_bin/_main/_helpers/config/cache-paths/dir-cache.mts
|
|
73
|
+
import * as node_fs from "node:fs";
|
|
74
|
+
import * as node_path from "node:path";
|
|
75
|
+
function dirCache() {
|
|
76
|
+
const path = node_path.join(node_path.dirname(GlobalVars.configFilePath.get()), ".bundo.rn");
|
|
77
|
+
if (!node_fs.existsSync(path)) {
|
|
78
|
+
node_fs.mkdirSync(path);
|
|
79
|
+
}
|
|
80
|
+
return path;
|
|
81
|
+
}
|
|
46
82
|
|
|
83
|
+
// src/_bin/_main/_helpers/config/cache-paths/asset-catalogs-tracker-file.mts
|
|
84
|
+
function assetCatalogsTrackerFile() {
|
|
85
|
+
return node_path2.join(dirCache(), "asset-catalogs.json");
|
|
86
|
+
}
|
|
87
|
+
// src/_bin/_main/_helpers/config/cache-paths/string-catalogs-tracker-file.mts
|
|
88
|
+
import * as node_path3 from "node:path";
|
|
89
|
+
function stringCatalogsTrackerFile() {
|
|
90
|
+
return node_path3.join(dirCache(), "string-catalogs.json");
|
|
91
|
+
}
|
|
47
92
|
// src/_bin/_main/_helpers/config/get-name.mts
|
|
48
93
|
function getName(config, platform) {
|
|
49
94
|
if (platform == "macos") {
|
|
@@ -52,17 +97,20 @@ function getName(config, platform) {
|
|
|
52
97
|
return config.name;
|
|
53
98
|
}
|
|
54
99
|
// src/_bin/_main/_helpers/config/get-project-name.mts
|
|
55
|
-
var
|
|
100
|
+
var cacheMacos;
|
|
56
101
|
function getProjectName(...params) {
|
|
57
|
-
if (
|
|
58
|
-
return
|
|
102
|
+
if (params[1] == "macos" && cacheMacos) {
|
|
103
|
+
return cacheMacos;
|
|
59
104
|
}
|
|
60
105
|
const name = getName(...params);
|
|
61
106
|
if (!name) {
|
|
62
107
|
return;
|
|
63
108
|
}
|
|
64
|
-
|
|
65
|
-
|
|
109
|
+
if (params[1] == "macos") {
|
|
110
|
+
cacheMacos = name.replace(/[^a-zA-Z0-9]/g, "");
|
|
111
|
+
return cacheMacos;
|
|
112
|
+
}
|
|
113
|
+
return;
|
|
66
114
|
}
|
|
67
115
|
// src/_bin/_main/_helpers/platform/compatibility-error.mts
|
|
68
116
|
var CompatibilityError = new Error(`
|
|
@@ -85,10 +133,10 @@ function isCompatible() {
|
|
|
85
133
|
}
|
|
86
134
|
|
|
87
135
|
// src/_bin/_main/_helpers/platform/get-data.mts
|
|
88
|
-
var
|
|
136
|
+
var cache;
|
|
89
137
|
function getData() {
|
|
90
|
-
if (
|
|
91
|
-
return
|
|
138
|
+
if (cache) {
|
|
139
|
+
return cache;
|
|
92
140
|
}
|
|
93
141
|
if (!isCompatible()) {
|
|
94
142
|
throw CompatibilityError;
|
|
@@ -106,10 +154,10 @@ function getData() {
|
|
|
106
154
|
version: process.versions.node
|
|
107
155
|
};
|
|
108
156
|
}
|
|
109
|
-
|
|
157
|
+
cache = {
|
|
110
158
|
developmentRuntime
|
|
111
159
|
};
|
|
112
|
-
return
|
|
160
|
+
return cache;
|
|
113
161
|
}
|
|
114
162
|
// src/_bin/_main/_check-config-validity.mts
|
|
115
163
|
function checkConfigValidity(config) {
|
|
@@ -121,7 +169,9 @@ function checkConfigValidity(config) {
|
|
|
121
169
|
checkMacosConfig(config);
|
|
122
170
|
} else if (process.platform == "darwin") {
|
|
123
171
|
checkMacosConfig(config);
|
|
124
|
-
} else
|
|
172
|
+
} else {
|
|
173
|
+
throw new Error(`Cannot support appgen for macOS in ${process.platform} platform.`);
|
|
174
|
+
}
|
|
125
175
|
if (config.plugins) {
|
|
126
176
|
if (Array.isArray(config.plugins)) {
|
|
127
177
|
config.plugins.forEach((plugin) => {
|
|
@@ -170,9 +220,9 @@ function checkMacosConfig(config) {
|
|
|
170
220
|
}
|
|
171
221
|
|
|
172
222
|
// src/_bin/_main/_evaluate-plugin-registry.mts
|
|
173
|
-
import * as
|
|
223
|
+
import * as node_fs2 from "node:fs";
|
|
174
224
|
import * as node_module from "node:module";
|
|
175
|
-
import * as
|
|
225
|
+
import * as node_path4 from "node:path";
|
|
176
226
|
function evaluatePluginRegistry(plugins) {
|
|
177
227
|
if (!plugins?.length) {
|
|
178
228
|
return;
|
|
@@ -203,9 +253,9 @@ function evaluatePluginRegistry(plugins) {
|
|
|
203
253
|
});
|
|
204
254
|
continue;
|
|
205
255
|
}
|
|
206
|
-
const filePath =
|
|
207
|
-
if (
|
|
208
|
-
const lstat =
|
|
256
|
+
const filePath = node_path4.join(node_path4.dirname(GlobalVars.configFilePath.get()), nameOrPath);
|
|
257
|
+
if (node_fs2.existsSync(filePath)) {
|
|
258
|
+
const lstat = node_fs2.lstatSync(filePath);
|
|
209
259
|
if (lstat.isFile()) {
|
|
210
260
|
registry.push({
|
|
211
261
|
name: nameOrPath,
|
|
@@ -225,18 +275,18 @@ function getPluginMainPathFromNodeModules(name) {
|
|
|
225
275
|
let modulePath;
|
|
226
276
|
let isDirectory = true;
|
|
227
277
|
try {
|
|
228
|
-
const __require = node_module.createRequire(
|
|
278
|
+
const __require = node_module.createRequire(node_path4.join(process.cwd(), "package.json"));
|
|
229
279
|
const nodeModulePaths = __require.resolve.paths("bundo-appgen");
|
|
230
280
|
if (nodeModulePaths?.length) {
|
|
231
281
|
for (const nodeModulePath of nodeModulePaths) {
|
|
232
|
-
const __modulePath =
|
|
233
|
-
if (
|
|
234
|
-
const modulePathStat =
|
|
282
|
+
const __modulePath = node_path4.join(nodeModulePath, name);
|
|
283
|
+
if (node_fs2.existsSync(__modulePath)) {
|
|
284
|
+
const modulePathStat = node_fs2.lstatSync(__modulePath);
|
|
235
285
|
if (modulePathStat.isFile()) {
|
|
236
286
|
isDirectory = false;
|
|
237
287
|
}
|
|
238
288
|
if (modulePathStat.isSymbolicLink()) {
|
|
239
|
-
modulePath =
|
|
289
|
+
modulePath = node_fs2.realpathSync(__modulePath);
|
|
240
290
|
} else {
|
|
241
291
|
modulePath = __modulePath;
|
|
242
292
|
}
|
|
@@ -255,11 +305,11 @@ function getPluginMainPathFromNodeModules(name) {
|
|
|
255
305
|
}
|
|
256
306
|
let mainPath;
|
|
257
307
|
for (const pluginMainFileExt of pluginMainFileExts) {
|
|
258
|
-
const path =
|
|
259
|
-
if (
|
|
260
|
-
const lstat =
|
|
308
|
+
const path = node_path4.join(modulePath, `bundo.plugin.${pluginMainFileExt}`);
|
|
309
|
+
if (node_fs2.existsSync(path)) {
|
|
310
|
+
const lstat = node_fs2.lstatSync(path);
|
|
261
311
|
if (lstat.isSymbolicLink()) {
|
|
262
|
-
mainPath =
|
|
312
|
+
mainPath = node_fs2.realpathSync(path);
|
|
263
313
|
} else {
|
|
264
314
|
mainPath = path;
|
|
265
315
|
}
|
|
@@ -274,13 +324,13 @@ var pluginMainFileExts = [
|
|
|
274
324
|
];
|
|
275
325
|
|
|
276
326
|
// src/_bin/_main/_exec-plugin-runner/exec-plugin-runner.mts
|
|
277
|
-
import * as
|
|
327
|
+
import * as node_path6 from "node:path";
|
|
278
328
|
|
|
279
329
|
// src/_bin/_main/_exec-plugin-runner/_spawn-plugin-sandbox-runner.mts
|
|
280
330
|
import * as node_childProcess from "node:child_process";
|
|
281
|
-
import * as
|
|
331
|
+
import * as node_fs3 from "node:fs";
|
|
282
332
|
import * as node_module2 from "node:module";
|
|
283
|
-
import * as
|
|
333
|
+
import * as node_path5 from "node:path";
|
|
284
334
|
async function spawnPluginSandboxRunner(registry, permissions, metadata) {
|
|
285
335
|
const requireModule = node_module2.createRequire(process.cwd()), messageID = Math.random().toString();
|
|
286
336
|
return new Promise((resolve) => {
|
|
@@ -302,15 +352,15 @@ async function spawnPluginSandboxRunner(registry, permissions, metadata) {
|
|
|
302
352
|
}
|
|
303
353
|
});
|
|
304
354
|
registry.forEach((plugin) => {
|
|
305
|
-
const pluginDirectory =
|
|
306
|
-
const lstat =
|
|
355
|
+
const pluginDirectory = node_path5.dirname(plugin.mainPath);
|
|
356
|
+
const lstat = node_fs3.lstatSync(pluginDirectory);
|
|
307
357
|
if (lstat.isSymbolicLink()) {
|
|
308
|
-
nodeArgs.push(`--allow-fs-read=${
|
|
358
|
+
nodeArgs.push(`--allow-fs-read=${node_fs3.realpathSync(pluginDirectory)}`);
|
|
309
359
|
} else {
|
|
310
360
|
nodeArgs.push(`--allow-fs-read=${pluginDirectory}`);
|
|
311
361
|
}
|
|
312
362
|
});
|
|
313
|
-
nodeArgs.push(
|
|
363
|
+
nodeArgs.push(node_path5.join(GlobalVars.appgenRoot.get(), "lib", "bin", "plugin-sandbox-runner.mjs"));
|
|
314
364
|
nodeArgs.push(`--json=${JSON.stringify({
|
|
315
365
|
projectDirectory: metadata.projectDirectory,
|
|
316
366
|
projectName: metadata.projectName,
|
|
@@ -356,13 +406,13 @@ async function execPluginRunner(registry, options) {
|
|
|
356
406
|
if (!registry?.length) {
|
|
357
407
|
return;
|
|
358
408
|
}
|
|
359
|
-
const projectDirectory =
|
|
409
|
+
const projectDirectory = node_path6.dirname(GlobalVars.configFilePath.get()), projectName = getProjectName(GlobalVars.appConfig.get(), "macos");
|
|
360
410
|
if (options?.mode === "restricted") {
|
|
361
411
|
console.log(`Executing ${registry.length} plugin${registry.length == 1 ? "" : "s"}`);
|
|
362
412
|
return await spawnPluginSandboxRunner(registry, {
|
|
363
413
|
"--allow-fs-read": [
|
|
364
|
-
|
|
365
|
-
|
|
414
|
+
node_path6.join(projectDirectory, "macos", projectName, "AppDelegate.swift"),
|
|
415
|
+
node_path6.join(projectDirectory, "macos", "Podfile")
|
|
366
416
|
],
|
|
367
417
|
"--allow-fs-write": null,
|
|
368
418
|
"--allow-net": false
|
|
@@ -372,7 +422,7 @@ async function execPluginRunner(registry, options) {
|
|
|
372
422
|
});
|
|
373
423
|
} else {
|
|
374
424
|
console.log(`Executing ${registry.length} less restrictive plugin${registry.length == 1 ? "" : "s"}`);
|
|
375
|
-
const projectDirectoryMacos =
|
|
425
|
+
const projectDirectoryMacos = node_path6.join(projectDirectory, "macos");
|
|
376
426
|
return await spawnPluginSandboxRunner(registry, {
|
|
377
427
|
"--allow-fs-read": [
|
|
378
428
|
projectDirectoryMacos
|
|
@@ -389,10 +439,10 @@ async function execPluginRunner(registry, options) {
|
|
|
389
439
|
}
|
|
390
440
|
// src/_bin/_main/_get-config.mts
|
|
391
441
|
import * as node_module3 from "node:module";
|
|
392
|
-
import * as
|
|
442
|
+
import * as node_path7 from "node:path";
|
|
393
443
|
var __filename = "/home/runner/work/bundo.rn/bundo.rn/packages/bundo-appgen/src/_bin/_main/_get-config.mts";
|
|
394
444
|
async function getConfig(configFilePath) {
|
|
395
|
-
const ext =
|
|
445
|
+
const ext = node_path7.extname(configFilePath);
|
|
396
446
|
if (ext == ".ts" || ext == ".mts") {
|
|
397
447
|
if (typeof Bun !== "undefined" || process.versions.bun) {
|
|
398
448
|
return import(configFilePath).then((c) => c.default);
|
|
@@ -421,16 +471,27 @@ or you can use Bun, or just use the JavaScript config file.
|
|
|
421
471
|
}
|
|
422
472
|
|
|
423
473
|
// src/_bin/_main/_init-template/init-template.mts
|
|
424
|
-
import * as
|
|
425
|
-
import * as
|
|
474
|
+
import * as node_fs13 from "node:fs";
|
|
475
|
+
import * as node_path18 from "node:path";
|
|
426
476
|
|
|
427
477
|
// src/_bin/_main/_init-template/_init-apple/init-apple.mts
|
|
428
|
-
import * as
|
|
429
|
-
import * as
|
|
478
|
+
import * as node_fs12 from "node:fs";
|
|
479
|
+
import * as node_path17 from "node:path";
|
|
480
|
+
|
|
481
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts
|
|
482
|
+
import * as node_fs6 from "node:fs";
|
|
483
|
+
import * as node_path11 from "node:path";
|
|
484
|
+
|
|
485
|
+
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_get-xcassets-path.mts
|
|
486
|
+
import * as node_path8 from "node:path";
|
|
487
|
+
function getXcassetsPath(platform) {
|
|
488
|
+
const projectDirectory = node_path8.dirname(GlobalVars.configFilePath.get()), projectName = getProjectName(GlobalVars.appConfig.get(), platform);
|
|
489
|
+
return node_path8.join(projectDirectory, platform, projectName, "Assets.xcassets");
|
|
490
|
+
}
|
|
430
491
|
|
|
431
492
|
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-appiconsets.mts
|
|
432
|
-
import * as
|
|
433
|
-
import * as
|
|
493
|
+
import * as node_fs4 from "node:fs";
|
|
494
|
+
import * as node_path9 from "node:path";
|
|
434
495
|
|
|
435
496
|
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_metadata-check/appearances.mts
|
|
436
497
|
function appearances(value) {
|
|
@@ -498,17 +559,17 @@ function initAppiconsets(appiconsets, metadata) {
|
|
|
498
559
|
if (!appiconsets?.length) {
|
|
499
560
|
return;
|
|
500
561
|
}
|
|
501
|
-
const projectDirectory =
|
|
502
|
-
const
|
|
562
|
+
const createdCatalogs = [], projectDirectory = node_path9.dirname(GlobalVars.configFilePath.get());
|
|
563
|
+
const xcassetsPath = getXcassetsPath(metadata.platform);
|
|
503
564
|
let appiconset_index = -1;
|
|
504
565
|
for (const appiconset of appiconsets) {
|
|
505
566
|
if (!appiconset.images.length) {
|
|
506
567
|
break;
|
|
507
568
|
}
|
|
508
569
|
appiconset_index++;
|
|
509
|
-
const _appiconset_directory =
|
|
510
|
-
if (!
|
|
511
|
-
|
|
570
|
+
const _appiconset_directory = node_path9.join(xcassetsPath, `${appiconset.name}.appiconset`);
|
|
571
|
+
if (!node_fs4.existsSync(_appiconset_directory)) {
|
|
572
|
+
node_fs4.mkdirSync(_appiconset_directory);
|
|
512
573
|
}
|
|
513
574
|
const contentsJson = {
|
|
514
575
|
images: [],
|
|
@@ -520,13 +581,13 @@ function initAppiconsets(appiconsets, metadata) {
|
|
|
520
581
|
let image_index = -1;
|
|
521
582
|
for (const { path: imagePath, ...image } of appiconset.images) {
|
|
522
583
|
image_index++;
|
|
523
|
-
const imageFilePath =
|
|
584
|
+
const imageFilePath = node_path9.resolve(projectDirectory, imagePath), imageMetadata = {
|
|
524
585
|
appearances: image.appearances?.[0] ? [{
|
|
525
586
|
appearance: image.appearances[0].appearance,
|
|
526
587
|
value: image.appearances[0].value
|
|
527
588
|
}] : undefined,
|
|
528
589
|
"display-gamut": image["display-gamut"] || undefined,
|
|
529
|
-
filename:
|
|
590
|
+
filename: node_path9.basename(imageFilePath),
|
|
530
591
|
size: image.size,
|
|
531
592
|
idiom: image.idiom || "universal",
|
|
532
593
|
scale: image.scale || "1x"
|
|
@@ -548,10 +609,10 @@ function initAppiconsets(appiconsets, metadata) {
|
|
|
548
609
|
if (image["idiom"] && !idiom(image.idiom)) {
|
|
549
610
|
throw new Error(`Not a valid idiom in the ${traceStr}.`);
|
|
550
611
|
}
|
|
551
|
-
if (!
|
|
612
|
+
if (!node_fs4.existsSync(imageFilePath)) {
|
|
552
613
|
throw new Error(`Cannot find ${imagePath} relatively from your project directory.`);
|
|
553
614
|
}
|
|
554
|
-
const imageExtname =
|
|
615
|
+
const imageExtname = node_path9.extname(imageFilePath);
|
|
555
616
|
if (imageExtname !== ".png") {
|
|
556
617
|
throw new Error(`${imageExtname} file is not supported in Asset Catalogs.`);
|
|
557
618
|
}
|
|
@@ -564,11 +625,13 @@ function initAppiconsets(appiconsets, metadata) {
|
|
|
564
625
|
}
|
|
565
626
|
}
|
|
566
627
|
}
|
|
567
|
-
|
|
628
|
+
node_fs4.copyFileSync(imageFilePath, node_path9.join(_appiconset_directory, imageMetadata.filename));
|
|
568
629
|
contentsJson.images.push({ ...imageMetadata });
|
|
569
630
|
}
|
|
570
|
-
|
|
631
|
+
node_fs4.writeFileSync(node_path9.join(_appiconset_directory, "Contents.json"), JSON.stringify(contentsJson, null, 2), "utf8");
|
|
632
|
+
createdCatalogs.push(appiconset.name);
|
|
571
633
|
}
|
|
634
|
+
return createdCatalogs;
|
|
572
635
|
}
|
|
573
636
|
var mapImageSize = {
|
|
574
637
|
"16x16": 1,
|
|
@@ -591,20 +654,20 @@ var mapImageSize = {
|
|
|
591
654
|
};
|
|
592
655
|
|
|
593
656
|
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/_init-imagesets.mts
|
|
594
|
-
import * as
|
|
595
|
-
import * as
|
|
657
|
+
import * as node_fs5 from "node:fs";
|
|
658
|
+
import * as node_path10 from "node:path";
|
|
596
659
|
function initImagesets(imagesets, metadata) {
|
|
597
660
|
if (!imagesets?.length) {
|
|
598
661
|
return;
|
|
599
662
|
}
|
|
600
|
-
const projectDirectory =
|
|
601
|
-
let
|
|
663
|
+
const createdCatalogs = [], projectDirectory = node_path10.dirname(GlobalVars.configFilePath.get());
|
|
664
|
+
let xcassetsPath = getXcassetsPath(metadata.platform);
|
|
602
665
|
if (metadata.namespace) {
|
|
603
|
-
|
|
604
|
-
|
|
666
|
+
xcassetsPath = node_path10.join(xcassetsPath, metadata.namespace);
|
|
667
|
+
node_fs5.mkdirSync(xcassetsPath, {
|
|
605
668
|
recursive: true
|
|
606
669
|
});
|
|
607
|
-
|
|
670
|
+
node_fs5.writeFileSync(node_path10.join(xcassetsPath, "Contents.json"), JSON.stringify({
|
|
608
671
|
info: {
|
|
609
672
|
version: 1,
|
|
610
673
|
author: metadata.bundleIdentifier
|
|
@@ -620,9 +683,9 @@ function initImagesets(imagesets, metadata) {
|
|
|
620
683
|
break;
|
|
621
684
|
}
|
|
622
685
|
imageset_index++;
|
|
623
|
-
const _imageset_directory =
|
|
624
|
-
if (!
|
|
625
|
-
|
|
686
|
+
const _imageset_directory = node_path10.join(xcassetsPath, `${imageset.name}.imageset`);
|
|
687
|
+
if (!node_fs5.existsSync(_imageset_directory)) {
|
|
688
|
+
node_fs5.mkdirSync(_imageset_directory);
|
|
626
689
|
}
|
|
627
690
|
const existingImageFilenames = [];
|
|
628
691
|
const contentsJson = {
|
|
@@ -638,14 +701,14 @@ function initImagesets(imagesets, metadata) {
|
|
|
638
701
|
if (!imagePath) {
|
|
639
702
|
throw new Error("Not a valid image metadata object in the `imagesets[number].images[number]`");
|
|
640
703
|
}
|
|
641
|
-
const imageFilePath =
|
|
704
|
+
const imageFilePath = node_path10.resolve(projectDirectory, imagePath), imageMetadata = {
|
|
642
705
|
appearances: image.appearances?.[0] ? [{
|
|
643
706
|
appearance: image.appearances[0].appearance,
|
|
644
707
|
value: image.appearances[0].value
|
|
645
708
|
}] : undefined,
|
|
646
709
|
"compression-type": image["compression-type"] || undefined,
|
|
647
710
|
"display-gamut": image["display-gamut"] || undefined,
|
|
648
|
-
filename:
|
|
711
|
+
filename: node_path10.basename(imageFilePath),
|
|
649
712
|
idiom: image.idiom || "universal",
|
|
650
713
|
languageDirection: image.languageDirection,
|
|
651
714
|
scale: image.scale || "1x"
|
|
@@ -670,10 +733,10 @@ function initImagesets(imagesets, metadata) {
|
|
|
670
733
|
if (image.languageDirection && !languageDirection(image.languageDirection)) {
|
|
671
734
|
throw new Error(`Not a valid image language direction in the ${traceStr}.`);
|
|
672
735
|
}
|
|
673
|
-
if (!
|
|
736
|
+
if (!node_fs5.existsSync(imageFilePath)) {
|
|
674
737
|
throw new Error(`Cannot find ${imagePath} relatively from your project directory.`);
|
|
675
738
|
}
|
|
676
|
-
const imageExtname =
|
|
739
|
+
const imageExtname = node_path10.extname(imageFilePath);
|
|
677
740
|
if (supportedImageExts.indexOf(imageExtname) == -1) {
|
|
678
741
|
throw new Error(`${imageExtname} file is not supported in Asset Catalogs.`);
|
|
679
742
|
}
|
|
@@ -689,11 +752,17 @@ function initImagesets(imagesets, metadata) {
|
|
|
689
752
|
}
|
|
690
753
|
}
|
|
691
754
|
}
|
|
692
|
-
|
|
755
|
+
node_fs5.copyFileSync(imageFilePath, node_path10.join(_imageset_directory, imageMetadata.filename));
|
|
693
756
|
contentsJson.images.push({ ...imageMetadata });
|
|
694
757
|
}
|
|
695
|
-
|
|
758
|
+
node_fs5.writeFileSync(node_path10.join(_imageset_directory, "Contents.json"), JSON.stringify(contentsJson, null, 2), "utf8");
|
|
759
|
+
if (metadata.namespace) {
|
|
760
|
+
createdCatalogs.push(`${metadata.namespace}/${imageset.name}`);
|
|
761
|
+
} else {
|
|
762
|
+
createdCatalogs.push(imageset.name);
|
|
763
|
+
}
|
|
696
764
|
}
|
|
765
|
+
return createdCatalogs;
|
|
697
766
|
}
|
|
698
767
|
var supportedImageExts = [
|
|
699
768
|
".heic",
|
|
@@ -705,122 +774,388 @@ var supportedImageExts = [
|
|
|
705
774
|
|
|
706
775
|
// src/_bin/_main/_init-template/_init-apple/_create-asset-catalogs/create-asset-catalogs.mts
|
|
707
776
|
function createAssetCatalogs(assetCatalogs, metadata) {
|
|
777
|
+
const xcassetsPath = getXcassetsPath(metadata.platform), assetCatalogsTrackerFilePath = exports_cache_paths.assetCatalogsTrackerFile();
|
|
778
|
+
let catalogsTracker = {
|
|
779
|
+
appiconsets: undefined,
|
|
780
|
+
imagesets: undefined
|
|
781
|
+
};
|
|
782
|
+
function removeAllCatalogs() {
|
|
783
|
+
if (node_fs6.existsSync(xcassetsPath)) {
|
|
784
|
+
node_fs6.rmSync(xcassetsPath, {
|
|
785
|
+
recursive: true,
|
|
786
|
+
force: true
|
|
787
|
+
});
|
|
788
|
+
node_fs6.cpSync(node_path11.join(GlobalVars.appgenRoot.get(), "template", metadata.platform, "HelloWorld", "Assets.xcassets"), xcassetsPath, {
|
|
789
|
+
recursive: true,
|
|
790
|
+
force: true
|
|
791
|
+
});
|
|
792
|
+
}
|
|
793
|
+
if (node_fs6.existsSync(assetCatalogsTrackerFilePath)) {
|
|
794
|
+
node_fs6.rmSync(assetCatalogsTrackerFilePath);
|
|
795
|
+
}
|
|
796
|
+
}
|
|
708
797
|
if (!assetCatalogs) {
|
|
798
|
+
removeAllCatalogs();
|
|
709
799
|
return;
|
|
710
800
|
}
|
|
801
|
+
try {
|
|
802
|
+
if (node_fs6.existsSync(assetCatalogsTrackerFilePath)) {
|
|
803
|
+
catalogsTracker = JSON.parse(node_fs6.readFileSync(assetCatalogsTrackerFilePath, "utf8"));
|
|
804
|
+
}
|
|
805
|
+
} catch {
|
|
806
|
+
removeAllCatalogs();
|
|
807
|
+
}
|
|
808
|
+
const newCatalogsTracker = createCatalogs(assetCatalogs, {
|
|
809
|
+
bundleIdentifier: metadata.bundleIdentifier,
|
|
810
|
+
platform: metadata.platform,
|
|
811
|
+
namespace: metadata.namespace
|
|
812
|
+
});
|
|
813
|
+
catalogsTracker.appiconsets?.forEach((existingCatalog) => {
|
|
814
|
+
if (newCatalogsTracker.appiconsets?.indexOf(existingCatalog) === -1) {
|
|
815
|
+
const existingPath = node_path11.join(xcassetsPath, existingCatalog + ".appiconset");
|
|
816
|
+
if (node_fs6.existsSync(existingPath)) {
|
|
817
|
+
node_fs6.rmSync(existingPath, {
|
|
818
|
+
recursive: true,
|
|
819
|
+
force: true
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
});
|
|
824
|
+
catalogsTracker.imagesets?.forEach((existingCatalog) => {
|
|
825
|
+
if (newCatalogsTracker.imagesets?.indexOf(existingCatalog) === -1) {
|
|
826
|
+
const existingCatalogBasename = existingCatalog.split("/")[0];
|
|
827
|
+
if (!existingCatalogBasename) {
|
|
828
|
+
return;
|
|
829
|
+
}
|
|
830
|
+
const existingPath = node_path11.join(xcassetsPath, existingCatalogBasename);
|
|
831
|
+
if (node_fs6.existsSync(existingPath)) {
|
|
832
|
+
node_fs6.rmSync(existingPath, {
|
|
833
|
+
recursive: true,
|
|
834
|
+
force: true
|
|
835
|
+
});
|
|
836
|
+
} else {
|
|
837
|
+
const imagesetDir = node_path11.join(existingCatalogBasename, ".imageset");
|
|
838
|
+
if (node_fs6.existsSync(imagesetDir)) {
|
|
839
|
+
node_fs6.rmSync(imagesetDir, {
|
|
840
|
+
recursive: true,
|
|
841
|
+
force: true
|
|
842
|
+
});
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
node_fs6.writeFileSync(assetCatalogsTrackerFilePath, JSON.stringify(newCatalogsTracker, null, 2), "utf8");
|
|
848
|
+
}
|
|
849
|
+
function createCatalogs(assetCatalogs, metadata, nextTracker) {
|
|
850
|
+
const tracker = nextTracker ?? {
|
|
851
|
+
appiconsets: undefined,
|
|
852
|
+
imagesets: undefined
|
|
853
|
+
};
|
|
854
|
+
if (!assetCatalogs) {
|
|
855
|
+
return tracker;
|
|
856
|
+
}
|
|
857
|
+
let isRecursived = false;
|
|
711
858
|
for (const _key of Object.keys(assetCatalogs)) {
|
|
712
859
|
const key = _key;
|
|
713
860
|
if (key == "imagesets") {
|
|
714
|
-
initImagesets(assetCatalogs.imagesets, metadata);
|
|
861
|
+
const trackedCatalogs = initImagesets(assetCatalogs.imagesets, metadata);
|
|
862
|
+
if (trackedCatalogs?.length) {
|
|
863
|
+
if (!tracker.imagesets?.length) {
|
|
864
|
+
tracker.imagesets = trackedCatalogs;
|
|
865
|
+
} else {
|
|
866
|
+
tracker.imagesets = [
|
|
867
|
+
...tracker.imagesets,
|
|
868
|
+
...trackedCatalogs
|
|
869
|
+
];
|
|
870
|
+
}
|
|
871
|
+
}
|
|
715
872
|
} else if (key == "appiconsets") {
|
|
716
|
-
|
|
873
|
+
if (!isRecursived) {
|
|
874
|
+
const trackedCatalogs = initAppiconsets(assetCatalogs.appiconsets, metadata);
|
|
875
|
+
if (trackedCatalogs?.length) {
|
|
876
|
+
if (!tracker.appiconsets?.length) {
|
|
877
|
+
tracker.appiconsets = trackedCatalogs;
|
|
878
|
+
} else {
|
|
879
|
+
tracker.appiconsets = [
|
|
880
|
+
...tracker.appiconsets,
|
|
881
|
+
...trackedCatalogs
|
|
882
|
+
];
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
717
886
|
} else {
|
|
718
887
|
const namespacedCatalogs = assetCatalogs[key];
|
|
719
888
|
if (namespacedCatalogs && Object.keys(namespacedCatalogs).length) {
|
|
720
|
-
|
|
889
|
+
isRecursived = true;
|
|
890
|
+
createCatalogs(namespacedCatalogs, {
|
|
721
891
|
...metadata,
|
|
722
|
-
namespace: key
|
|
723
|
-
});
|
|
892
|
+
namespace: metadata.namespace ? `${metadata.namespace}/${key}` : key
|
|
893
|
+
}, tracker);
|
|
724
894
|
}
|
|
725
895
|
}
|
|
726
896
|
}
|
|
897
|
+
return tracker;
|
|
727
898
|
}
|
|
728
899
|
// src/_bin/_main/_init-template/_init-apple/_create-string-catalogs/create-string-catalog.mts
|
|
729
|
-
import * as
|
|
730
|
-
import * as
|
|
900
|
+
import * as node_fs7 from "node:fs";
|
|
901
|
+
import * as node_path12 from "node:path";
|
|
731
902
|
function createStringCatalogs(stringCatalogs, locales = ["en"], metadata) {
|
|
732
|
-
const config = GlobalVars.appConfig.get(),
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
903
|
+
const config = GlobalVars.appConfig.get(), targetProjectDir = node_path12.join(node_path12.dirname(GlobalVars.configFilePath.get()), metadata.platform, getProjectName(config, metadata.platform)), catalogs = stringCatalogs ? Object.entries(stringCatalogs) : null, stringCatalogsTrackerFilePath = exports_cache_paths.stringCatalogsTrackerFile();
|
|
904
|
+
let catalogsTracker = {
|
|
905
|
+
catalogs: undefined
|
|
906
|
+
};
|
|
907
|
+
if (!catalogs?.length) {
|
|
908
|
+
if (node_fs7.existsSync(stringCatalogsTrackerFilePath)) {
|
|
909
|
+
node_fs7.rmSync(stringCatalogsTrackerFilePath);
|
|
910
|
+
}
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
try {
|
|
914
|
+
catalogsTracker = node_fs7.existsSync(stringCatalogsTrackerFilePath) ? JSON.parse(node_fs7.readFileSync(stringCatalogsTrackerFilePath, "utf8")) : { catalogs: undefined };
|
|
915
|
+
} catch {}
|
|
916
|
+
if (catalogsTracker.catalogs?.length) {
|
|
917
|
+
catalogsTracker.catalogs.slice().forEach((existingCatalog, index) => {
|
|
918
|
+
if (!stringCatalogs?.[existingCatalog]) {
|
|
919
|
+
const existingPath = getCatalogFilePath({
|
|
920
|
+
targetProjectDirectory: targetProjectDir,
|
|
921
|
+
catalogName: existingCatalog
|
|
922
|
+
});
|
|
923
|
+
if (node_fs7.existsSync(existingPath)) {
|
|
924
|
+
node_fs7.rmSync(existingPath, {
|
|
925
|
+
force: true
|
|
926
|
+
});
|
|
744
927
|
}
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
928
|
+
catalogsTracker.catalogs?.splice(index, 1);
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
}
|
|
932
|
+
for (const [catalogName, data] of catalogs) {
|
|
933
|
+
const json = {
|
|
934
|
+
sourceLanguage: locales[0],
|
|
935
|
+
strings: {},
|
|
936
|
+
version: "1.2"
|
|
937
|
+
}, keys = Object.keys(data);
|
|
938
|
+
for (const key of keys) {
|
|
939
|
+
const localizedValue = data[key];
|
|
940
|
+
if (!localizedValue) {
|
|
941
|
+
throw new Error(`String catalog of ${catalogName} has invalid configuration.`);
|
|
942
|
+
}
|
|
943
|
+
const localesOfValue = Object.keys(localizedValue);
|
|
944
|
+
{
|
|
945
|
+
for (const localeOfValue of localesOfValue) {
|
|
946
|
+
if (locales.indexOf(localeOfValue) == -1) {
|
|
947
|
+
throw new Error(`"${localeOfValue}" was not found from your \`locales\` config. Add "${localeOfValue}" to the \`locales\` array.`);
|
|
751
948
|
}
|
|
752
949
|
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
}
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
950
|
+
}
|
|
951
|
+
localesOfValue.forEach((locale) => {
|
|
952
|
+
const value = localizedValue[locale];
|
|
953
|
+
if (!value) {
|
|
954
|
+
throw new Error(`\`stringCatalogs.${key}.${locale}\` is empty.`);
|
|
955
|
+
}
|
|
956
|
+
if (!json.strings[key]) {
|
|
957
|
+
json.strings[key] = {
|
|
958
|
+
extractionState: "manual",
|
|
959
|
+
localizations: {
|
|
960
|
+
[locale]: {
|
|
961
|
+
stringUnit: {
|
|
962
|
+
state: "translated",
|
|
963
|
+
value
|
|
767
964
|
}
|
|
768
965
|
}
|
|
769
|
-
}
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
} else {
|
|
969
|
+
json.strings[key].localizations[locale] = {
|
|
970
|
+
stringUnit: {
|
|
971
|
+
state: "translated",
|
|
972
|
+
value
|
|
973
|
+
}
|
|
974
|
+
};
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
node_fs7.writeFileSync(getCatalogFilePath({
|
|
979
|
+
targetProjectDirectory: targetProjectDir,
|
|
980
|
+
catalogName
|
|
981
|
+
}), JSON.stringify(json, null, 2), "utf8");
|
|
982
|
+
if (!catalogsTracker.catalogs?.length) {
|
|
983
|
+
catalogsTracker.catalogs = [];
|
|
984
|
+
}
|
|
985
|
+
if (catalogsTracker.catalogs.indexOf(catalogName) == -1) {
|
|
986
|
+
catalogsTracker.catalogs.push(catalogName);
|
|
781
987
|
}
|
|
782
988
|
}
|
|
989
|
+
node_fs7.writeFileSync(stringCatalogsTrackerFilePath, JSON.stringify(catalogsTracker, null, 2), "utf8");
|
|
990
|
+
}
|
|
991
|
+
function getCatalogFilePath(data) {
|
|
992
|
+
return node_path12.join(data.targetProjectDirectory, `${data.catalogName}.xcstrings`);
|
|
783
993
|
}
|
|
784
994
|
|
|
785
995
|
// src/_bin/_main/_init-template/_init-apple/_mod-files/_app-delegate-swift.mts
|
|
786
|
-
import * as
|
|
787
|
-
import * as
|
|
996
|
+
import * as node_fs8 from "node:fs";
|
|
997
|
+
import * as node_path13 from "node:path";
|
|
788
998
|
function appDelegateSwift(platform) {
|
|
789
|
-
const appConfig = GlobalVars.appConfig.get(), projectName = getProjectName(appConfig, platform), appName = getName(appConfig, platform), appDelegateSwiftFilePath =
|
|
790
|
-
let appDelegateSwiftText =
|
|
999
|
+
const appConfig = GlobalVars.appConfig.get(), projectName = getProjectName(appConfig, platform), appName = getName(appConfig, platform), appDelegateSwiftFilePath = node_path13.join(node_path13.dirname(GlobalVars.configFilePath.get()), platform, projectName, "AppDelegate.swift");
|
|
1000
|
+
let appDelegateSwiftText = node_fs8.readFileSync(appDelegateSwiftFilePath, "utf8");
|
|
791
1001
|
appDelegateSwiftText = appDelegateSwiftText.replace(/Window\("HelloWorld"/, `Window("${appName}"`);
|
|
792
1002
|
appDelegateSwiftText = appDelegateSwiftText.replace(/factory.rootViewFactory.view\(withModuleName: "HelloWorld"/, `factory.rootViewFactory.view(withModuleName: "${projectName}"`);
|
|
793
|
-
|
|
1003
|
+
node_fs8.writeFileSync(appDelegateSwiftFilePath, appDelegateSwiftText, "utf8");
|
|
794
1004
|
}
|
|
795
1005
|
|
|
796
|
-
// src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile.mts
|
|
797
|
-
import * as
|
|
798
|
-
import * as
|
|
1006
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/podfile.mts
|
|
1007
|
+
import * as node_fs10 from "node:fs";
|
|
1008
|
+
import * as node_path15 from "node:path";
|
|
1009
|
+
|
|
1010
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/_pod-dependencies.mts
|
|
1011
|
+
import * as node_fs9 from "node:fs";
|
|
1012
|
+
import * as node_path14 from "node:path";
|
|
1013
|
+
function podDependencies(platform) {
|
|
1014
|
+
const dependencies = GlobalVars.appConfig.get()[platform]?.Podfile?.dependencies, nativeProjectDir = node_path14.join(node_path14.dirname(GlobalVars.configFilePath.get()), platform);
|
|
1015
|
+
const podDependenciesFilePath = node_path14.join(nativeProjectDir, "pod_dependencies.rb");
|
|
1016
|
+
let podDependenciesFile = "def pod_dependencies";
|
|
1017
|
+
dependencies?.forEach((dependency) => {
|
|
1018
|
+
let tx = `
|
|
1019
|
+
pod '${dependency.name}'`;
|
|
1020
|
+
if (dependency.type == "cocoapods") {
|
|
1021
|
+
if (dependency.version) {
|
|
1022
|
+
tx += `, '${dependency.version}'`;
|
|
1023
|
+
}
|
|
1024
|
+
} else if (dependency.type == "git") {
|
|
1025
|
+
if (!dependency.url || typeof dependency.url != "string") {
|
|
1026
|
+
throw new Error('"gitUrl" is empty or not a valid string for a pod spec source.');
|
|
1027
|
+
}
|
|
1028
|
+
tx += `, :git => '${dependency.url}'`;
|
|
1029
|
+
if (dependency.revision) {
|
|
1030
|
+
if (dependency.revision.type !== "branch" && dependency.revision.type !== "commit" && dependency.revision.type !== "tag") {
|
|
1031
|
+
throw new Error('Expected "branch", or "commit", or "tag" for the revision type.');
|
|
1032
|
+
}
|
|
1033
|
+
if (typeof dependency.revision.ref != "string" || !dependency.revision.ref) {
|
|
1034
|
+
throw new Error("Revision ref is empty or not a valid string.");
|
|
1035
|
+
}
|
|
1036
|
+
tx += `, :${dependency.revision.type} => '${dependency.revision.ref}'`;
|
|
1037
|
+
}
|
|
1038
|
+
} else if (dependency.type == "local") {
|
|
1039
|
+
if (!dependency.path || typeof dependency.path != "string") {
|
|
1040
|
+
throw new Error('"path" is empty or not a valid string for a local pod.');
|
|
1041
|
+
}
|
|
1042
|
+
tx += `, :path => '${dependency.path}'`;
|
|
1043
|
+
}
|
|
1044
|
+
podDependenciesFile += tx;
|
|
1045
|
+
});
|
|
1046
|
+
podDependenciesFile += `
|
|
1047
|
+
end
|
|
1048
|
+
`;
|
|
1049
|
+
node_fs9.writeFileSync(podDependenciesFilePath, podDependenciesFile, "utf8");
|
|
1050
|
+
}
|
|
1051
|
+
|
|
1052
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/_podfile/podfile.mts
|
|
799
1053
|
function podfile(platform) {
|
|
800
|
-
const projectName = getProjectName(GlobalVars.appConfig.get(), platform),
|
|
801
|
-
let podfileText =
|
|
1054
|
+
const projectName = getProjectName(GlobalVars.appConfig.get(), platform), nativeProjectDir = node_path15.join(node_path15.dirname(GlobalVars.configFilePath.get()), platform), podfilePath = node_path15.join(nativeProjectDir, "Podfile");
|
|
1055
|
+
let podfileText = node_fs10.readFileSync(podfilePath, "utf8");
|
|
802
1056
|
podfileText = podfileText.replace(/(target) 'HelloWorld' (do)/, `$1 '${projectName}' $2`);
|
|
803
|
-
|
|
1057
|
+
node_fs10.writeFileSync(podfilePath, podfileText, "utf8");
|
|
1058
|
+
podDependencies(platform);
|
|
1059
|
+
}
|
|
1060
|
+
// src/_bin/_main/_init-template/_init-apple/_mod-files/_privacy-manifest.mts
|
|
1061
|
+
import * as node_fs11 from "node:fs";
|
|
1062
|
+
import * as node_path16 from "node:path";
|
|
1063
|
+
function privacyManifest(platform) {
|
|
1064
|
+
const manifest = GlobalVars.appConfig.get()[platform]?.privacyManifest;
|
|
1065
|
+
if (!manifest) {
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
const nativeProjectDir = node_path16.join(node_path16.dirname(GlobalVars.configFilePath.get()), platform), privacyInfoFilePath = node_path16.join(nativeProjectDir, "PrivacyInfo.xcprivacy");
|
|
1069
|
+
let privacyInfoFile = `<?xml version="1.0" encoding="UTF-8"?>
|
|
1070
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
1071
|
+
<plist version="1.0">
|
|
1072
|
+
<dict>`;
|
|
1073
|
+
for (const [key, plist] of Object.entries(manifest)) {
|
|
1074
|
+
privacyInfoFile += getDictionaryItem(key, plist);
|
|
1075
|
+
}
|
|
1076
|
+
privacyInfoFile += `
|
|
1077
|
+
</dict>
|
|
1078
|
+
</plist>`;
|
|
1079
|
+
node_fs11.writeFileSync(privacyInfoFilePath, privacyInfoFile, "utf8");
|
|
1080
|
+
}
|
|
1081
|
+
function getDictionaryItem(key, plist, startIndentAmount = 1) {
|
|
1082
|
+
const indent = Array(startIndentAmount).fill("\t").join("");
|
|
1083
|
+
let tx = `
|
|
1084
|
+
${indent}<key>${key}</key>`;
|
|
1085
|
+
if (typeof plist == "boolean") {
|
|
1086
|
+
if (plist) {
|
|
1087
|
+
tx += `
|
|
1088
|
+
${indent}<true/>`;
|
|
1089
|
+
} else {
|
|
1090
|
+
tx += `
|
|
1091
|
+
${indent}<false/>`;
|
|
1092
|
+
}
|
|
1093
|
+
} else if (typeof plist == "string") {
|
|
1094
|
+
if (!plist) {
|
|
1095
|
+
throw new Error("A plist item is empty or not a valid string.");
|
|
1096
|
+
}
|
|
1097
|
+
tx += `
|
|
1098
|
+
${indent}<string>${plist}</string>`;
|
|
1099
|
+
} else if (Array.isArray(plist)) {
|
|
1100
|
+
if (plist.length) {
|
|
1101
|
+
tx += `
|
|
1102
|
+
${indent}<array>`;
|
|
1103
|
+
plist.forEach((value, index) => {
|
|
1104
|
+
if (typeof value == "string") {
|
|
1105
|
+
if (!value) {
|
|
1106
|
+
throw new Error(`${key}[${index}] is empty or not a valid string.`);
|
|
1107
|
+
}
|
|
1108
|
+
tx += `
|
|
1109
|
+
${indent} <string>${value}</string>`;
|
|
1110
|
+
} else if (typeof value == "object" && value) {
|
|
1111
|
+
tx += `
|
|
1112
|
+
${indent}<dict>`;
|
|
1113
|
+
for (const [key2, plist2] of Object.entries(value)) {
|
|
1114
|
+
tx += getDictionaryItem(key2, plist2, startIndentAmount + 1);
|
|
1115
|
+
}
|
|
1116
|
+
tx += `
|
|
1117
|
+
${indent}</dict>`;
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1120
|
+
tx += `
|
|
1121
|
+
${indent}</array>`;
|
|
1122
|
+
} else {
|
|
1123
|
+
tx += `
|
|
1124
|
+
<array/>`;
|
|
1125
|
+
}
|
|
1126
|
+
} else if (typeof plist == "object" && plist) {
|
|
1127
|
+
tx += `
|
|
1128
|
+
${indent}<dict>`;
|
|
1129
|
+
for (const [key2, plist2] of Object.entries(plist)) {
|
|
1130
|
+
tx += getDictionaryItem(key2, plist2, startIndentAmount + 1);
|
|
1131
|
+
}
|
|
1132
|
+
tx += `
|
|
1133
|
+
${indent}</dict>`;
|
|
1134
|
+
}
|
|
1135
|
+
return tx;
|
|
804
1136
|
}
|
|
805
1137
|
|
|
806
1138
|
// src/_bin/_main/_init-template/_init-apple/_mod-files/mod-files.mts
|
|
807
1139
|
function modFiles(platform) {
|
|
808
1140
|
appDelegateSwift(platform);
|
|
809
1141
|
podfile(platform);
|
|
1142
|
+
privacyManifest(platform);
|
|
810
1143
|
}
|
|
811
1144
|
// src/_bin/_main/_init-template/_init-apple/init-apple.mts
|
|
812
1145
|
function initApple(platform) {
|
|
813
|
-
const config = GlobalVars.appConfig.get(),
|
|
814
|
-
if (!
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
1146
|
+
const config = GlobalVars.appConfig.get(), appleData = config[platform];
|
|
1147
|
+
if (!appleData) {
|
|
1148
|
+
throw new Error(`"${platform}" config is empty.`);
|
|
1149
|
+
}
|
|
1150
|
+
const projectDirectory = node_path17.dirname(GlobalVars.configFilePath.get()), nativeProjectDirectory = node_path17.join(projectDirectory, platform), templateDir = node_path17.join(GlobalVars.appgenRoot.get(), "template", platform), projectName = getProjectName(config, platform);
|
|
1151
|
+
if (!node_fs12.existsSync(nativeProjectDirectory)) {
|
|
1152
|
+
node_fs12.cpSync(templateDir, nativeProjectDirectory, { recursive: true });
|
|
1153
|
+
node_fs12.renameSync(node_path17.join(nativeProjectDirectory, "HelloWorld"), node_path17.join(nativeProjectDirectory, projectName));
|
|
818
1154
|
}
|
|
819
|
-
|
|
1155
|
+
modFiles(platform);
|
|
820
1156
|
createAssetCatalogs(appleData.assetCatalogs, {
|
|
821
1157
|
bundleIdentifier: appleData.bundleIdentifier,
|
|
822
|
-
platform
|
|
823
|
-
projectName
|
|
1158
|
+
platform
|
|
824
1159
|
});
|
|
825
1160
|
createStringCatalogs(appleData.stringCatalogs, appleData.locales, {
|
|
826
1161
|
platform
|
|
@@ -835,74 +1170,78 @@ function initTemplate() {
|
|
|
835
1170
|
initApple("macos");
|
|
836
1171
|
}
|
|
837
1172
|
} catch (err) {
|
|
838
|
-
const projectDirectory =
|
|
839
|
-
if (
|
|
840
|
-
|
|
1173
|
+
const projectDirectory = node_path18.dirname(GlobalVars.configFilePath.get()), projectMacosDir = node_path18.join(projectDirectory, "macos");
|
|
1174
|
+
if (node_fs13.existsSync(projectMacosDir)) {
|
|
1175
|
+
node_fs13.rmSync(projectMacosDir, { recursive: true, force: true });
|
|
841
1176
|
}
|
|
842
1177
|
throw err;
|
|
843
1178
|
}
|
|
844
1179
|
}
|
|
845
1180
|
// src/_bin/_main/_mod-plugin/mod-plugin.mts
|
|
846
|
-
import * as
|
|
847
|
-
import * as
|
|
1181
|
+
import * as node_fs14 from "node:fs";
|
|
1182
|
+
import * as node_path19 from "node:path";
|
|
848
1183
|
function modPlugin(contextResult) {
|
|
849
|
-
const config = GlobalVars.appConfig.get(), projectDirectory =
|
|
1184
|
+
const config = GlobalVars.appConfig.get(), projectDirectory = node_path19.dirname(GlobalVars.configFilePath.get());
|
|
850
1185
|
{
|
|
851
|
-
const projectName = getProjectName(config, "macos"), nativeProjectDir =
|
|
852
|
-
|
|
853
|
-
|
|
1186
|
+
const projectName = getProjectName(config, "macos"), nativeProjectDir = node_path19.join(projectDirectory, "macos");
|
|
1187
|
+
node_fs14.writeFileSync(node_path19.join(nativeProjectDir, projectName, "AppDelegate.swift"), contextResult.macos.files.Project["AppDelegate.swift"], "utf8");
|
|
1188
|
+
node_fs14.writeFileSync(node_path19.join(nativeProjectDir, "Podfile"), contextResult.macos.files.Podfile, "utf8");
|
|
854
1189
|
}
|
|
855
1190
|
}
|
|
856
1191
|
// src/_bin/_main/_xcodegen/xcodegen.mts
|
|
857
1192
|
import * as node_childProcess2 from "node:child_process";
|
|
858
|
-
import * as
|
|
1193
|
+
import * as node_path23 from "node:path";
|
|
859
1194
|
|
|
860
1195
|
// src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts
|
|
861
|
-
import * as
|
|
1196
|
+
import * as node_fs16 from "node:fs";
|
|
862
1197
|
import * as node_module4 from "node:module";
|
|
863
|
-
import * as
|
|
1198
|
+
import * as node_path21 from "node:path";
|
|
864
1199
|
|
|
865
1200
|
// src/_bin/_main/_xcodegen/_create-project-spec/_init-resources.mts
|
|
866
|
-
import * as
|
|
867
|
-
import * as
|
|
1201
|
+
import * as node_fs15 from "node:fs";
|
|
1202
|
+
import * as node_path20 from "node:path";
|
|
868
1203
|
function initResources(resources, metadata) {
|
|
869
1204
|
if (!resources?.length) {
|
|
870
1205
|
return null;
|
|
871
1206
|
}
|
|
872
|
-
const projectDirectory =
|
|
873
|
-
|
|
874
|
-
|
|
1207
|
+
const projectDirectory = node_path20.dirname(GlobalVars.configFilePath.get()), resourcesDirectory = node_path20.join(projectDirectory, metadata.platform, "Resources"), basenameFiles = [], subpaths = [];
|
|
1208
|
+
node_fs15.rmSync(resourcesDirectory, { recursive: true, force: true });
|
|
1209
|
+
node_fs15.mkdirSync(resourcesDirectory);
|
|
875
1210
|
try {
|
|
876
1211
|
for (const resource of resources) {
|
|
877
|
-
let path =
|
|
878
|
-
if (!
|
|
1212
|
+
let path = node_path20.resolve(projectDirectory, resource);
|
|
1213
|
+
if (!node_fs15.existsSync(path)) {
|
|
879
1214
|
throw new Error(`The ${path} was not found.`);
|
|
880
1215
|
}
|
|
881
|
-
const lstat =
|
|
1216
|
+
const lstat = node_fs15.lstatSync(path);
|
|
882
1217
|
if (lstat.isSymbolicLink()) {
|
|
883
|
-
path =
|
|
1218
|
+
path = node_fs15.realpathSync(path);
|
|
884
1219
|
}
|
|
885
1220
|
console.log(`\x1B[32mCopying resource\x1B[0m \x1B[36m${path}\x1B[0m`);
|
|
886
|
-
|
|
1221
|
+
node_fs15.cpSync(path, node_path20.join(resourcesDirectory, node_path20.basename(path)), {
|
|
887
1222
|
recursive: true,
|
|
888
1223
|
force: true
|
|
889
1224
|
});
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
1225
|
+
if (lstat.isDirectory()) {
|
|
1226
|
+
subpaths.push(node_path20.basename(path));
|
|
1227
|
+
} else {
|
|
1228
|
+
basenameFiles.push(node_path20.basename(path));
|
|
1229
|
+
}
|
|
894
1230
|
}
|
|
895
1231
|
} catch (err) {
|
|
896
|
-
|
|
1232
|
+
node_fs15.rmSync(resourcesDirectory, { force: true, recursive: true });
|
|
897
1233
|
throw err;
|
|
898
1234
|
}
|
|
899
|
-
return
|
|
1235
|
+
return {
|
|
1236
|
+
basenameFiles,
|
|
1237
|
+
subpaths
|
|
1238
|
+
};
|
|
900
1239
|
}
|
|
901
1240
|
|
|
902
1241
|
// src/_bin/_main/_xcodegen/_create-project-spec/create-project-spec.mts
|
|
903
1242
|
function createProjectSpec(platform, overrideConfig) {
|
|
904
|
-
const projectDirectory =
|
|
905
|
-
if (!
|
|
1243
|
+
const projectDirectory = node_path21.dirname(GlobalVars.configFilePath.get()), nativeProjectDir = node_path21.join(projectDirectory, platform);
|
|
1244
|
+
if (!node_fs16.existsSync(projectDirectory)) {
|
|
906
1245
|
throw new Error(`An unexpected happened. ${projectDirectory} was not found.`);
|
|
907
1246
|
}
|
|
908
1247
|
const config = GlobalVars.appConfig.get();
|
|
@@ -912,13 +1251,20 @@ function createProjectSpec(platform, overrideConfig) {
|
|
|
912
1251
|
if (platform == "macos" && !config.macos) {
|
|
913
1252
|
throw new Error(`${platform} configuration was not found.`);
|
|
914
1253
|
}
|
|
915
|
-
const
|
|
1254
|
+
const projectName = getProjectName(config, platform);
|
|
1255
|
+
{
|
|
1256
|
+
const entitlementsFilePath = node_path21.join(nativeProjectDir, projectName, `${projectName}.entitlements`);
|
|
1257
|
+
if (node_fs16.existsSync(entitlementsFilePath)) {
|
|
1258
|
+
node_fs16.rmSync(entitlementsFilePath);
|
|
1259
|
+
}
|
|
1260
|
+
}
|
|
1261
|
+
const requireFromNativeDirectory = node_module4.createRequire(nativeProjectDir), reactNativeXcodeScriptRelativePath = node_path21.relative(nativeProjectDir, platform == "macos" ? requireFromNativeDirectory.resolve("react-native-macos/scripts/react-native-xcode.sh") : requireFromNativeDirectory.resolve("react-native/scripts/react-native-xcode.sh")), appleData = {
|
|
916
1262
|
...config[platform],
|
|
917
1263
|
infoPlist: {
|
|
918
1264
|
...overrideConfig?.infoPlist,
|
|
919
1265
|
...config[platform].infoPlist
|
|
920
1266
|
}
|
|
921
|
-
},
|
|
1267
|
+
}, resourcesData = initResources(config.macos?.resources, {
|
|
922
1268
|
platform
|
|
923
1269
|
}), json = {
|
|
924
1270
|
name: projectName,
|
|
@@ -932,13 +1278,23 @@ function createProjectSpec(platform, overrideConfig) {
|
|
|
932
1278
|
path: projectName,
|
|
933
1279
|
type: "syncedFolder"
|
|
934
1280
|
},
|
|
935
|
-
...resourcesData?.
|
|
1281
|
+
...resourcesData?.basenameFiles.length ? [{
|
|
1282
|
+
path: "Resources",
|
|
1283
|
+
excludes: resourcesData.subpaths,
|
|
1284
|
+
buildPhase: {
|
|
1285
|
+
copyFiles: {
|
|
1286
|
+
destination: "resources"
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
}] : [],
|
|
1290
|
+
...resourcesData?.subpaths?.map((subpath) => {
|
|
936
1291
|
return {
|
|
937
1292
|
path: "Resources",
|
|
1293
|
+
excludes: resourcesData.basenameFiles,
|
|
938
1294
|
buildPhase: {
|
|
939
1295
|
copyFiles: {
|
|
940
1296
|
destination: "resources",
|
|
941
|
-
subpath
|
|
1297
|
+
subpath
|
|
942
1298
|
}
|
|
943
1299
|
}
|
|
944
1300
|
};
|
|
@@ -964,6 +1320,10 @@ function createProjectSpec(platform, overrideConfig) {
|
|
|
964
1320
|
...appleData.infoPlist
|
|
965
1321
|
}
|
|
966
1322
|
},
|
|
1323
|
+
entitlements: appleData.entitlements ? {
|
|
1324
|
+
path: `${projectName}/${projectName}.entitlements`,
|
|
1325
|
+
properties: appleData.entitlements
|
|
1326
|
+
} : undefined,
|
|
967
1327
|
postBuildScripts: [
|
|
968
1328
|
{
|
|
969
1329
|
name: "Bundle React Native code and images",
|
|
@@ -971,7 +1331,6 @@ function createProjectSpec(platform, overrideConfig) {
|
|
|
971
1331
|
${reactNativeXcodeScriptRelativePath}`
|
|
972
1332
|
}
|
|
973
1333
|
],
|
|
974
|
-
scheme: {},
|
|
975
1334
|
settings: {
|
|
976
1335
|
ASSETCATALOG_COMPILER_APPICON_NAME: appleData.appicon
|
|
977
1336
|
}
|
|
@@ -996,18 +1355,18 @@ ${reactNativeXcodeScriptRelativePath}`
|
|
|
996
1355
|
useBaseInternationalization: false
|
|
997
1356
|
}
|
|
998
1357
|
};
|
|
999
|
-
|
|
1358
|
+
node_fs16.writeFileSync(node_path21.join(nativeProjectDir, "project.json"), JSON.stringify(json, null, 2), "utf8");
|
|
1000
1359
|
}
|
|
1001
1360
|
// src/_bin/_main/_xcodegen/_mod-known-regions/mod-known-regions.mts
|
|
1002
|
-
import * as
|
|
1003
|
-
import * as
|
|
1361
|
+
import * as node_fs17 from "node:fs";
|
|
1362
|
+
import * as node_path22 from "node:path";
|
|
1004
1363
|
function modKnownRegions(platform) {
|
|
1005
1364
|
const config = GlobalVars.appConfig.get(), appleData = config[platform];
|
|
1006
1365
|
if (!appleData?.locales?.length) {
|
|
1007
1366
|
return;
|
|
1008
1367
|
}
|
|
1009
|
-
const projectName = getProjectName(config, platform), pbxprojPath =
|
|
1010
|
-
let file =
|
|
1368
|
+
const projectName = getProjectName(config, platform), pbxprojPath = node_path22.join(node_path22.dirname(GlobalVars.configFilePath.get()), platform, `${projectName}.xcodeproj`, "project.pbxproj");
|
|
1369
|
+
let file = node_fs17.readFileSync(pbxprojPath, "utf8");
|
|
1011
1370
|
let strReplacer = "knownRegions = (";
|
|
1012
1371
|
appleData.locales.forEach((locale) => {
|
|
1013
1372
|
strReplacer += `
|
|
@@ -1015,13 +1374,13 @@ $2${locale},`;
|
|
|
1015
1374
|
});
|
|
1016
1375
|
strReplacer += "$3";
|
|
1017
1376
|
file = file.replace(/knownRegions = \((\n(\t+)\w+,)+(\n\t+\);)/, strReplacer);
|
|
1018
|
-
|
|
1377
|
+
node_fs17.writeFileSync(pbxprojPath, file, "utf8");
|
|
1019
1378
|
}
|
|
1020
1379
|
|
|
1021
1380
|
// src/_bin/_main/_xcodegen/xcodegen.mts
|
|
1022
1381
|
function xcodegen(platform, overrideConfig) {
|
|
1023
1382
|
createProjectSpec(platform, overrideConfig);
|
|
1024
|
-
const xcodegenPath = GlobalVars.argv.get().xcodegenPath, nativeProjectDir =
|
|
1383
|
+
const xcodegenPath = GlobalVars.argv.get().xcodegenPath, nativeProjectDir = node_path23.join(node_path23.dirname(GlobalVars.configFilePath.get()), platform);
|
|
1025
1384
|
node_childProcess2.execSync(`${xcodegenPath} --spec project.json`, {
|
|
1026
1385
|
cwd: nativeProjectDir,
|
|
1027
1386
|
stdio: "inherit"
|
|
@@ -1042,15 +1401,15 @@ async function main() {
|
|
|
1042
1401
|
if (!isValidExt) {
|
|
1043
1402
|
throw new Error(`App config file only compatible with ${configFileExts.join(" | ")}`);
|
|
1044
1403
|
}
|
|
1045
|
-
const targetConfigFilePath =
|
|
1046
|
-
if (!
|
|
1404
|
+
const targetConfigFilePath = node_path24.resolve(process.cwd(), argv.path);
|
|
1405
|
+
if (!node_fs18.existsSync(targetConfigFilePath)) {
|
|
1047
1406
|
throw new Error(`${targetConfigFilePath} file doesn't exist.`);
|
|
1048
1407
|
}
|
|
1049
|
-
configFilePath =
|
|
1408
|
+
configFilePath = node_path24.resolve(process.cwd(), argv.path);
|
|
1050
1409
|
} else {
|
|
1051
1410
|
for (let i = 0;i < configFileExts.length; i++) {
|
|
1052
|
-
const targetConfigFilePath =
|
|
1053
|
-
if (
|
|
1411
|
+
const targetConfigFilePath = node_path24.join(process.cwd(), `bundo.config.${configFileExts[i]}`);
|
|
1412
|
+
if (node_fs18.existsSync(targetConfigFilePath)) {
|
|
1054
1413
|
configFilePath = targetConfigFilePath;
|
|
1055
1414
|
break;
|
|
1056
1415
|
} else if (i == configFileExts.length - 1) {
|
|
@@ -1095,7 +1454,7 @@ var configFileExts = [
|
|
|
1095
1454
|
"js"
|
|
1096
1455
|
];
|
|
1097
1456
|
function isValidConfigFileExt(filePath) {
|
|
1098
|
-
const ext =
|
|
1457
|
+
const ext = node_path24.extname(filePath);
|
|
1099
1458
|
if (!ext) {
|
|
1100
1459
|
return false;
|
|
1101
1460
|
}
|