@expo/repack-app 0.0.6 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,8 +3,25 @@ import type { NormalizedOptions } from '../types';
3
3
  /**
4
4
  * Update the Info.plist file.
5
5
  */
6
- export declare function updateInfoPlistAsync(config: ExpoConfig, infoPlistPath: string, options: NormalizedOptions): Promise<void>;
6
+ export declare function updateInfoPlistAsync({ config, infoPlistPath, originalAppId, options, }: {
7
+ config: ExpoConfig;
8
+ infoPlistPath: string;
9
+ originalAppId: string;
10
+ options: NormalizedOptions;
11
+ }): Promise<void>;
7
12
  /**
8
13
  * Update the Expo.plist file.
9
14
  */
10
- export declare function updateExpoPlistAsync(config: ExpoConfig, expoPlistPath: string, runtimeVersion: string, options: NormalizedOptions): Promise<void>;
15
+ export declare function updateExpoPlistAsync(config: ExpoConfig, expoPlistPath: string, runtimeVersion: string | null, options: NormalizedOptions): Promise<void>;
16
+ /**
17
+ * Query the app ID from the Info.plist file.
18
+ */
19
+ export declare function queryAppIdFromPlistAsync(infoPlistPath: string, options: NormalizedOptions): Promise<string>;
20
+ /**
21
+ * Add the bundle assets to the app.
22
+ */
23
+ export declare function addBundleAssetsAsync({ appWorkingDirectory, assetRoot, bundleOutputPath, }: {
24
+ appWorkingDirectory: string;
25
+ assetRoot: string;
26
+ bundleOutputPath: string;
27
+ }): Promise<void>;
@@ -3,16 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.updateExpoPlistAsync = exports.updateInfoPlistAsync = void 0;
6
+ exports.addBundleAssetsAsync = exports.queryAppIdFromPlistAsync = exports.updateExpoPlistAsync = exports.updateInfoPlistAsync = void 0;
7
7
  const plist_1 = __importDefault(require("@expo/plist"));
8
8
  const steps_1 = require("@expo/steps");
9
9
  const node_assert_1 = __importDefault(require("node:assert"));
10
10
  const promises_1 = __importDefault(require("node:fs/promises"));
11
+ const node_path_1 = __importDefault(require("node:path"));
11
12
  const utils_1 = require("../utils");
12
13
  /**
13
14
  * Update the Info.plist file.
14
15
  */
15
- async function updateInfoPlistAsync(config, infoPlistPath, options) {
16
+ async function updateInfoPlistAsync({ config, infoPlistPath, originalAppId, options, }) {
16
17
  const bundleIdentifier = config.ios?.bundleIdentifier;
17
18
  (0, node_assert_1.default)(bundleIdentifier, 'The `bundleIdentifier` must be specified in the `ios` config.');
18
19
  const firstScheme = Array.isArray(config.scheme) ? config.scheme[0] : config.scheme;
@@ -25,14 +26,14 @@ async function updateInfoPlistAsync(config, infoPlistPath, options) {
25
26
  // scheme in app.json
26
27
  .replace(/^myapp$/g, (0, utils_1.requireNotNull)(firstScheme))
27
28
  // ios.bundleIdentifier in app.json
28
- .replace(/^dev.expo.templatedefault$/g, (0, utils_1.requireNotNull)(bundleIdentifier))
29
+ .replace(originalAppId, bundleIdentifier)
29
30
  // default scheme generated from slug in app.json
30
- .replace(/^exp\+expo-template-default$/g, `exp+${(0, utils_1.requireNotNull)(config.slug)}`));
31
+ .replace(/^exp\+.+$/g, `exp+${(0, utils_1.requireNotNull)(config.slug)}`));
31
32
  });
32
33
  urlType.CFBundleURLSchemes = schemes;
33
34
  }
34
35
  }
35
- const userActivityTypes = data.NSUserActivityTypes.map((activityType) => activityType.replace(/^dev.expo.templatedefault/g, bundleIdentifier));
36
+ const userActivityTypes = data.NSUserActivityTypes.map((activityType) => activityType.replace(originalAppId, bundleIdentifier));
36
37
  return {
37
38
  ...data,
38
39
  CFBundleDisplayName: config.name,
@@ -48,6 +49,9 @@ exports.updateInfoPlistAsync = updateInfoPlistAsync;
48
49
  * Update the Expo.plist file.
49
50
  */
50
51
  async function updateExpoPlistAsync(config, expoPlistPath, runtimeVersion, options) {
52
+ if (!runtimeVersion) {
53
+ return;
54
+ }
51
55
  await updateBinaryPlistAsync(expoPlistPath, options, (data) => {
52
56
  const updateUrl = config.updates?.url;
53
57
  (0, node_assert_1.default)(updateUrl);
@@ -60,6 +64,33 @@ async function updateExpoPlistAsync(config, expoPlistPath, runtimeVersion, optio
60
64
  });
61
65
  }
62
66
  exports.updateExpoPlistAsync = updateExpoPlistAsync;
67
+ /**
68
+ * Query the app ID from the Info.plist file.
69
+ */
70
+ async function queryAppIdFromPlistAsync(infoPlistPath, options) {
71
+ let appId;
72
+ await updateBinaryPlistAsync(infoPlistPath, options, (data) => {
73
+ appId = data.CFBundleIdentifier;
74
+ return data;
75
+ });
76
+ (0, node_assert_1.default)(appId, 'Expected `CFBundleIdentifier` to be present in Info.plist');
77
+ return appId;
78
+ }
79
+ exports.queryAppIdFromPlistAsync = queryAppIdFromPlistAsync;
80
+ /**
81
+ * Add the bundle assets to the app.
82
+ */
83
+ async function addBundleAssetsAsync({ appWorkingDirectory, assetRoot, bundleOutputPath, }) {
84
+ await Promise.all([
85
+ promises_1.default.rm(node_path_1.default.join(appWorkingDirectory, 'main.jsbundle'), { force: true }),
86
+ promises_1.default.rm(node_path_1.default.join(appWorkingDirectory, 'assets'), { recursive: true, force: true }),
87
+ ]);
88
+ await promises_1.default.copyFile(bundleOutputPath, node_path_1.default.join(appWorkingDirectory, 'main.jsbundle'));
89
+ // export:embed --assets-dest on iOS uses the app root as target directory,
90
+ // so we just need to copy the assets to the app root.
91
+ await copyDirAsync(assetRoot, appWorkingDirectory);
92
+ }
93
+ exports.addBundleAssetsAsync = addBundleAssetsAsync;
63
94
  //#region Internals
64
95
  async function updateBinaryPlistAsync(plistPath, options, updater) {
65
96
  await (0, steps_1.spawnAsync)('plutil', ['-convert', 'xml1', plistPath], options.verbose ? { logger: options.logger, stdio: 'pipe' } : undefined);
@@ -70,4 +101,18 @@ async function updateBinaryPlistAsync(plistPath, options, updater) {
70
101
  await promises_1.default.writeFile(plistPath, updatedContents);
71
102
  await (0, steps_1.spawnAsync)('plutil', ['-convert', 'binary1', plistPath], options.verbose ? { logger: options.logger, stdio: 'pipe' } : undefined);
72
103
  }
104
+ async function copyDirAsync(src, dst) {
105
+ await promises_1.default.mkdir(dst, { recursive: true });
106
+ const entries = await promises_1.default.readdir(src, { withFileTypes: true });
107
+ for (const entry of entries) {
108
+ const srcPath = node_path_1.default.join(src, entry.name);
109
+ const dstPath = node_path_1.default.join(dst, entry.name);
110
+ if (entry.isDirectory()) {
111
+ await copyDirAsync(srcPath, dstPath);
112
+ }
113
+ else if (entry.isFile()) {
114
+ await promises_1.default.copyFile(srcPath, dstPath);
115
+ }
116
+ }
117
+ }
73
118
  //#endregion
package/build/types.d.ts CHANGED
@@ -30,6 +30,10 @@ export interface Options {
30
30
  * Enable verbose logging.
31
31
  */
32
32
  verbose?: boolean;
33
+ /**
34
+ * Whether to use the `npx export:embed` command to embed the JS bundle.
35
+ */
36
+ exportEmbedOptions?: ExportEmbedOptions;
33
37
  /**
34
38
  * The options for signing the android app.
35
39
  */
@@ -89,11 +93,20 @@ export interface IosSigningOptions {
89
93
  */
90
94
  signingIdentity: string;
91
95
  /**
92
- * Path to your provisioning_profile.
96
+ * Path to provisioning profile files.
93
97
  */
94
- provisioningProfile: string;
98
+ provisioningProfile: string | Record<string, string>;
95
99
  /**
96
100
  * Provide a path to a keychain file that should be used by /usr/bin/codesign
97
101
  */
98
102
  keychainPath?: string;
99
103
  }
104
+ /**
105
+ * The options passed to the `npx export:embed` command.
106
+ */
107
+ export interface ExportEmbedOptions {
108
+ /**
109
+ * The path to the sourcemap output file.
110
+ */
111
+ sourcemapOutput?: string;
112
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/repack-app",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "description": "Repacking tool for Expo apps",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -25,22 +25,34 @@
25
25
  "author": "650 Industries, Inc.",
26
26
  "license": "BUSL-1.1",
27
27
  "dependencies": {
28
- "@expo/config": "^8.5.6",
29
28
  "@expo/logger": "^1.0.57",
30
29
  "@expo/steps": "^1.0.108",
31
30
  "commander": "^11.0.0",
32
31
  "glob": "^10.3.12",
33
32
  "picocolors": "^1.0.0",
34
- "protobufjs": "^7.2.6",
35
33
  "resolve-from": "^5.0.0",
36
- "temp-dir": "^2.0.0"
34
+ "temp-dir": "^2.0.0",
35
+ "xml2js": "^0.6.2"
37
36
  },
38
37
  "devDependencies": {
38
+ "@expo/config": "^8.5.6",
39
39
  "@tsconfig/node20": "^20.1.4",
40
+ "@types/xml2js": "^0.4.14",
40
41
  "eslint": "^8.57.0",
41
42
  "expo-module-scripts": "^3.4.2",
43
+ "jest": "^29.7.0",
44
+ "jest-snapshot-prettier": "npm:prettier@^2",
45
+ "ts-jest": "^29.1.2",
42
46
  "typescript": "^5.4.5"
43
47
  },
48
+ "peerDependencies": {
49
+ "@expo/config": "*"
50
+ },
51
+ "peerDependenciesMeta": {
52
+ "@expo/config": {
53
+ "optional": true
54
+ }
55
+ },
44
56
  "volta": {
45
57
  "node": "22.1.0"
46
58
  }
@@ -1,216 +0,0 @@
1
- /*
2
- * Copyright (C) 2017 The Android Open Source Project
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
-
17
- syntax = "proto3";
18
-
19
- package aapt.pb;
20
-
21
- option java_package = "com.android.aapt";
22
-
23
- // A description of the requirements a device must have in order for a
24
- // resource to be matched and selected.
25
- message Configuration {
26
- enum LayoutDirection {
27
- LAYOUT_DIRECTION_UNSET = 0;
28
- LAYOUT_DIRECTION_LTR = 1;
29
- LAYOUT_DIRECTION_RTL = 2;
30
- }
31
-
32
- enum ScreenLayoutSize {
33
- SCREEN_LAYOUT_SIZE_UNSET = 0;
34
- SCREEN_LAYOUT_SIZE_SMALL = 1;
35
- SCREEN_LAYOUT_SIZE_NORMAL = 2;
36
- SCREEN_LAYOUT_SIZE_LARGE = 3;
37
- SCREEN_LAYOUT_SIZE_XLARGE = 4;
38
- }
39
-
40
- enum ScreenLayoutLong {
41
- SCREEN_LAYOUT_LONG_UNSET = 0;
42
- SCREEN_LAYOUT_LONG_LONG = 1;
43
- SCREEN_LAYOUT_LONG_NOTLONG = 2;
44
- }
45
-
46
- enum ScreenRound {
47
- SCREEN_ROUND_UNSET = 0;
48
- SCREEN_ROUND_ROUND = 1;
49
- SCREEN_ROUND_NOTROUND = 2;
50
- }
51
-
52
- enum WideColorGamut {
53
- WIDE_COLOR_GAMUT_UNSET = 0;
54
- WIDE_COLOR_GAMUT_WIDECG = 1;
55
- WIDE_COLOR_GAMUT_NOWIDECG = 2;
56
- }
57
-
58
- enum Hdr {
59
- HDR_UNSET = 0;
60
- HDR_HIGHDR = 1;
61
- HDR_LOWDR = 2;
62
- }
63
-
64
- enum Orientation {
65
- ORIENTATION_UNSET = 0;
66
- ORIENTATION_PORT = 1;
67
- ORIENTATION_LAND = 2;
68
- ORIENTATION_SQUARE = 3;
69
- }
70
-
71
- enum UiModeType {
72
- UI_MODE_TYPE_UNSET = 0;
73
- UI_MODE_TYPE_NORMAL = 1;
74
- UI_MODE_TYPE_DESK = 2;
75
- UI_MODE_TYPE_CAR = 3;
76
- UI_MODE_TYPE_TELEVISION = 4;
77
- UI_MODE_TYPE_APPLIANCE = 5;
78
- UI_MODE_TYPE_WATCH = 6;
79
- UI_MODE_TYPE_VRHEADSET = 7;
80
- }
81
-
82
- enum UiModeNight {
83
- UI_MODE_NIGHT_UNSET = 0;
84
- UI_MODE_NIGHT_NIGHT = 1;
85
- UI_MODE_NIGHT_NOTNIGHT = 2;
86
- }
87
-
88
- enum Touchscreen {
89
- TOUCHSCREEN_UNSET = 0;
90
- TOUCHSCREEN_NOTOUCH = 1;
91
- TOUCHSCREEN_STYLUS = 2;
92
- TOUCHSCREEN_FINGER = 3;
93
- }
94
-
95
- enum KeysHidden {
96
- KEYS_HIDDEN_UNSET = 0;
97
- KEYS_HIDDEN_KEYSEXPOSED = 1;
98
- KEYS_HIDDEN_KEYSHIDDEN = 2;
99
- KEYS_HIDDEN_KEYSSOFT = 3;
100
- }
101
-
102
- enum Keyboard {
103
- KEYBOARD_UNSET = 0;
104
- KEYBOARD_NOKEYS = 1;
105
- KEYBOARD_QWERTY = 2;
106
- KEYBOARD_TWELVEKEY = 3;
107
- }
108
-
109
- enum NavHidden {
110
- NAV_HIDDEN_UNSET = 0;
111
- NAV_HIDDEN_NAVEXPOSED = 1;
112
- NAV_HIDDEN_NAVHIDDEN = 2;
113
- }
114
-
115
- enum Navigation {
116
- NAVIGATION_UNSET = 0;
117
- NAVIGATION_NONAV = 1;
118
- NAVIGATION_DPAD = 2;
119
- NAVIGATION_TRACKBALL = 3;
120
- NAVIGATION_WHEEL = 4;
121
- }
122
-
123
- enum GrammaticalGender {
124
- GRAM_GENDER_USET = 0;
125
- GRAM_GENDER_NEUTER = 1;
126
- GRAM_GENDER_FEMININE = 2;
127
- GRAM_GENDER_MASCULINE = 3;
128
- }
129
-
130
- //
131
- // Axis/dimensions that are understood by the runtime.
132
- //
133
-
134
- // Mobile country code.
135
- uint32 mcc = 1;
136
-
137
- // Mobile network code.
138
- uint32 mnc = 2;
139
-
140
- // BCP-47 locale tag.
141
- string locale = 3;
142
-
143
- // Left-to-right, right-to-left...
144
- LayoutDirection layout_direction = 4;
145
-
146
- // Screen width in pixels. Prefer screen_width_dp.
147
- uint32 screen_width = 5;
148
-
149
- // Screen height in pixels. Prefer screen_height_dp.
150
- uint32 screen_height = 6;
151
-
152
- // Screen width in density independent pixels (dp).
153
- uint32 screen_width_dp = 7;
154
-
155
- // Screen height in density independent pixels (dp).
156
- uint32 screen_height_dp = 8;
157
-
158
- // The smallest screen dimension, regardless of orientation, in dp.
159
- uint32 smallest_screen_width_dp = 9;
160
-
161
- // Whether the device screen is classified as small, normal, large, xlarge.
162
- ScreenLayoutSize screen_layout_size = 10;
163
-
164
- // Whether the device screen is long.
165
- ScreenLayoutLong screen_layout_long = 11;
166
-
167
- // Whether the screen is round (Android Wear).
168
- ScreenRound screen_round = 12;
169
-
170
- // Whether the screen supports wide color gamut.
171
- WideColorGamut wide_color_gamut = 13;
172
-
173
- // Whether the screen has high dynamic range.
174
- Hdr hdr = 14;
175
-
176
- // Which orientation the device is in (portrait, landscape).
177
- Orientation orientation = 15;
178
-
179
- // Which type of UI mode the device is in (television, car, etc.).
180
- UiModeType ui_mode_type = 16;
181
-
182
- // Whether the device is in night mode.
183
- UiModeNight ui_mode_night = 17;
184
-
185
- // The device's screen density in dots-per-inch (dpi).
186
- uint32 density = 18;
187
-
188
- // Whether a touchscreen exists, supports a stylus, or finger.
189
- Touchscreen touchscreen = 19;
190
-
191
- // Whether the keyboard hardware keys are currently hidden, exposed, or
192
- // if the keyboard is a software keyboard.
193
- KeysHidden keys_hidden = 20;
194
-
195
- // The type of keyboard present (none, QWERTY, 12-key).
196
- Keyboard keyboard = 21;
197
-
198
- // Whether the navigation is exposed or hidden.
199
- NavHidden nav_hidden = 22;
200
-
201
- // The type of navigation present on the device
202
- // (trackball, wheel, dpad, etc.).
203
- Navigation navigation = 23;
204
-
205
- // The minimum SDK version of the device.
206
- uint32 sdk_version = 24;
207
-
208
- // Grammatical gender.
209
- GrammaticalGender grammatical_gender = 26;
210
-
211
- //
212
- // Build-time only dimensions.
213
- //
214
-
215
- string product = 25;
216
- }