codingpixel-expo-app 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/patch.js +32 -0
- package/package.json +1 -1
package/dist/patch.js
CHANGED
|
@@ -19,6 +19,28 @@ export function slugify(name) {
|
|
|
19
19
|
.replace(/^-+|-+$/g, "")
|
|
20
20
|
.toLowerCase() || "app");
|
|
21
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Build a reverse-DNS bundle identifier segment from the app name.
|
|
24
|
+
*
|
|
25
|
+
* Android `package` + iOS `bundleIdentifier` constraints:
|
|
26
|
+
* - Lowercase letters / digits only per segment.
|
|
27
|
+
* - No dashes, dots, or other punctuation INSIDE a segment.
|
|
28
|
+
* - Each segment must START with a letter (no leading digits).
|
|
29
|
+
* - At least two segments separated by dots.
|
|
30
|
+
*
|
|
31
|
+
* `my-test-app` → `mytestapp` → final ID `com.codingpixel.mytestapp`.
|
|
32
|
+
* `1pp` → `app1pp` (leading-digit guard).
|
|
33
|
+
*/
|
|
34
|
+
export function bundleIdSegment(name) {
|
|
35
|
+
let seg = slugify(name).replace(/-/g, "");
|
|
36
|
+
if (!/^[a-z]/.test(seg))
|
|
37
|
+
seg = `app${seg}`;
|
|
38
|
+
return seg || "app";
|
|
39
|
+
}
|
|
40
|
+
/** Compose the full bundle identifier with the `com.codingpixel.` namespace prefix. */
|
|
41
|
+
export function bundleIdFor(name) {
|
|
42
|
+
return `com.codingpixel.${bundleIdSegment(name)}`;
|
|
43
|
+
}
|
|
22
44
|
function readJson(p) {
|
|
23
45
|
return JSON.parse(fs.readFileSync(p, "utf8"));
|
|
24
46
|
}
|
|
@@ -46,6 +68,16 @@ export function patchAppJson(target, name, _answers) {
|
|
|
46
68
|
json.expo.name = name;
|
|
47
69
|
json.expo.slug = slugify(name);
|
|
48
70
|
json.expo.scheme = slugify(name);
|
|
71
|
+
// android.package + ios.bundleIdentifier — required to launch the app on
|
|
72
|
+
// either platform (Expo CLI errors with "Required property ... is not found"
|
|
73
|
+
// otherwise). Preserve any user-set value; only fill when missing.
|
|
74
|
+
const bundleId = bundleIdFor(name);
|
|
75
|
+
json.expo.ios ??= {};
|
|
76
|
+
if (!json.expo.ios.bundleIdentifier)
|
|
77
|
+
json.expo.ios.bundleIdentifier = bundleId;
|
|
78
|
+
json.expo.android ??= {};
|
|
79
|
+
if (!json.expo.android.package)
|
|
80
|
+
json.expo.android.package = bundleId;
|
|
49
81
|
json.expo.plugins ??= [];
|
|
50
82
|
if (!json.expo.plugins.some((e) => nameOf(e) === "expo-router")) {
|
|
51
83
|
json.expo.plugins.push("expo-router");
|