@expo/build-tools 1.0.28 → 1.0.29
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/steps/easFunctions.js +2 -0
- package/dist/steps/easFunctions.js.map +1 -1
- package/dist/steps/functions/eas/configureExpoUpdatesIfInstalled.d.ts +2 -0
- package/dist/steps/functions/eas/configureExpoUpdatesIfInstalled.js +56 -0
- package/dist/steps/functions/eas/configureExpoUpdatesIfInstalled.js.map +1 -0
- package/dist/steps/utils/android/expoUpdates.d.ts +8 -0
- package/dist/steps/utils/android/expoUpdates.js +58 -0
- package/dist/steps/utils/android/expoUpdates.js.map +1 -0
- package/dist/steps/utils/expoUpdates.d.ts +15 -0
- package/dist/steps/utils/expoUpdates.js +104 -0
- package/dist/steps/utils/expoUpdates.js.map +1 -0
- package/dist/steps/utils/ios/expoUpdates.d.ts +8 -0
- package/dist/steps/utils/ios/expoUpdates.js +61 -0
- package/dist/steps/utils/ios/expoUpdates.js.map +1 -0
- package/package.json +4 -4
|
@@ -9,6 +9,7 @@ const runGradle_1 = require("./functions/utils/runGradle");
|
|
|
9
9
|
const prebuild_1 = require("./functions/eas/prebuild");
|
|
10
10
|
const buildReactNativeApp_1 = require("./functions/eas/buildReactNativeApp");
|
|
11
11
|
const findAndUploadBuildArtifacts_1 = require("./functions/eas/findAndUploadBuildArtifacts");
|
|
12
|
+
const configureExpoUpdatesIfInstalled_1 = require("./functions/eas/configureExpoUpdatesIfInstalled");
|
|
12
13
|
function getEasFunctions(ctx, oldCtx // TODO: remove
|
|
13
14
|
) {
|
|
14
15
|
return [
|
|
@@ -20,6 +21,7 @@ function getEasFunctions(ctx, oldCtx // TODO: remove
|
|
|
20
21
|
(0, runGradle_1.createRunGradleBuildFunction)(oldCtx),
|
|
21
22
|
(0, buildReactNativeApp_1.createBuildReactNativeAppBuildFunction)(oldCtx),
|
|
22
23
|
(0, findAndUploadBuildArtifacts_1.createFindAndUploadBuildArtifactsBuildFunction)(ctx),
|
|
24
|
+
(0, configureExpoUpdatesIfInstalled_1.configureEASUpdateIfInstalledFunction)(),
|
|
23
25
|
];
|
|
24
26
|
}
|
|
25
27
|
exports.getEasFunctions = getEasFunctions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"easFunctions.js","sourceRoot":"","sources":["../../src/steps/easFunctions.ts"],"names":[],"mappings":";;;AAMA,qEAAqF;AACrF,uDAAuE;AACvE,2DAA2E;AAC3E,2EAA2F;AAC3F,2DAA2E;AAC3E,uDAAuE;AACvE,6EAA6F;AAC7F,6FAA6G;
|
|
1
|
+
{"version":3,"file":"easFunctions.js","sourceRoot":"","sources":["../../src/steps/easFunctions.ts"],"names":[],"mappings":";;;AAMA,qEAAqF;AACrF,uDAAuE;AACvE,2DAA2E;AAC3E,2EAA2F;AAC3F,2DAA2E;AAC3E,uDAAuE;AACvE,6EAA6F;AAC7F,6FAA6G;AAC7G,qGAAwG;AAExG,SAAgB,eAAe,CAC7B,GAAuB,EACvB,MAAyB,CAAC,eAAe;;IAEzC,OAAO;QACL,IAAA,sCAA2B,GAAE;QAC7B,IAAA,kDAAiC,EAAC,GAAG,CAAC;QACtC,IAAA,0CAA6B,EAAC,GAAG,CAAC;QAClC,IAAA,0DAAqC,EAAC,GAAG,CAAC;QAC1C,IAAA,sCAA2B,EAAC,GAAG,CAAC;QAChC,IAAA,wCAA4B,EAAC,MAAM,CAAC;QACpC,IAAA,4DAAsC,EAAC,MAAM,CAAC;QAC9C,IAAA,4EAA8C,EAAC,GAAG,CAAC;QACnD,IAAA,uEAAqC,GAAE;KACxC,CAAC;AACJ,CAAC;AAfD,0CAeC","sourcesContent":["import { Job } from '@expo/eas-build-job';\nimport { BuildFunction } from '@expo/steps';\n\nimport { BuildContext } from '../context';\nimport { CustomBuildContext } from '../customBuildContext';\n\nimport { createUploadArtifactBuildFunction } from './functions/utils/uploadArtifact';\nimport { createCheckoutBuildFunction } from './functions/eas/checkout';\nimport { createSetUpNpmrcBuildFunction } from './functions/eas/setUpNpmrc';\nimport { createInstallNodeModulesBuildFunction } from './functions/eas/installNodeModules';\nimport { createRunGradleBuildFunction } from './functions/utils/runGradle';\nimport { createPrebuildBuildFunction } from './functions/eas/prebuild';\nimport { createBuildReactNativeAppBuildFunction } from './functions/eas/buildReactNativeApp';\nimport { createFindAndUploadBuildArtifactsBuildFunction } from './functions/eas/findAndUploadBuildArtifacts';\nimport { configureEASUpdateIfInstalledFunction } from './functions/eas/configureExpoUpdatesIfInstalled';\n\nexport function getEasFunctions(\n ctx: CustomBuildContext,\n oldCtx: BuildContext<Job> // TODO: remove\n): BuildFunction[] {\n return [\n createCheckoutBuildFunction(),\n createUploadArtifactBuildFunction(ctx),\n createSetUpNpmrcBuildFunction(ctx),\n createInstallNodeModulesBuildFunction(ctx),\n createPrebuildBuildFunction(ctx),\n createRunGradleBuildFunction(oldCtx),\n createBuildReactNativeAppBuildFunction(oldCtx),\n createFindAndUploadBuildArtifactsBuildFunction(ctx),\n configureEASUpdateIfInstalledFunction(),\n ];\n}\n"]}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.configureEASUpdateIfInstalledFunction = void 0;
|
|
7
|
+
const assert_1 = __importDefault(require("assert"));
|
|
8
|
+
const steps_1 = require("@expo/steps");
|
|
9
|
+
const semver_1 = __importDefault(require("semver"));
|
|
10
|
+
const appConfig_1 = require("../../../utils/appConfig");
|
|
11
|
+
const expoUpdates_1 = require("../../utils/expoUpdates");
|
|
12
|
+
function configureEASUpdateIfInstalledFunction() {
|
|
13
|
+
return new steps_1.BuildFunction({
|
|
14
|
+
namespace: 'eas',
|
|
15
|
+
id: 'configure_eas_update_if_installed',
|
|
16
|
+
name: 'Configure EAS Update if installed',
|
|
17
|
+
inputProviders: [
|
|
18
|
+
steps_1.BuildStepInput.createProvider({
|
|
19
|
+
id: 'runtime_version',
|
|
20
|
+
required: false,
|
|
21
|
+
allowedValueTypeName: steps_1.BuildStepInputValueTypeName.STRING,
|
|
22
|
+
}),
|
|
23
|
+
steps_1.BuildStepInput.createProvider({
|
|
24
|
+
id: 'channel',
|
|
25
|
+
required: false,
|
|
26
|
+
allowedValueTypeName: steps_1.BuildStepInputValueTypeName.STRING,
|
|
27
|
+
}),
|
|
28
|
+
],
|
|
29
|
+
fn: async (stepCtx, { env, inputs }) => {
|
|
30
|
+
(0, assert_1.default)(stepCtx.global.staticContext.job, 'Job is not defined');
|
|
31
|
+
const job = stepCtx.global.staticContext.job;
|
|
32
|
+
const appConfig = (0, appConfig_1.readAppConfig)(stepCtx.workingDirectory, Object.keys(env).reduce((acc, key) => {
|
|
33
|
+
var _a;
|
|
34
|
+
acc[key] = (_a = env[key]) !== null && _a !== void 0 ? _a : '';
|
|
35
|
+
return acc;
|
|
36
|
+
}, {}), stepCtx.logger).exp;
|
|
37
|
+
const releaseChannelInput = inputs.channel.value;
|
|
38
|
+
const runtimeVersionInput = inputs.runtime_version.value;
|
|
39
|
+
if (runtimeVersionInput && !semver_1.default.valid(runtimeVersionInput)) {
|
|
40
|
+
throw new Error(`Runtime version provided by the "runtime_version" input is not a valid semver version: ${releaseChannelInput}`);
|
|
41
|
+
}
|
|
42
|
+
await (0, expoUpdates_1.configureEASUpdateIfInstalledAsync)({
|
|
43
|
+
job,
|
|
44
|
+
workingDirectory: stepCtx.workingDirectory,
|
|
45
|
+
logger: stepCtx.logger,
|
|
46
|
+
appConfig,
|
|
47
|
+
inputs: {
|
|
48
|
+
runtimeVersion: runtimeVersionInput,
|
|
49
|
+
channel: releaseChannelInput,
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
exports.configureEASUpdateIfInstalledFunction = configureEASUpdateIfInstalledFunction;
|
|
56
|
+
//# sourceMappingURL=configureExpoUpdatesIfInstalled.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configureExpoUpdatesIfInstalled.js","sourceRoot":"","sources":["../../../../src/steps/functions/eas/configureExpoUpdatesIfInstalled.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B,uCAAyF;AAEzF,oDAA4B;AAE5B,wDAAyD;AACzD,yDAA6E;AAE7E,SAAgB,qCAAqC;IACnD,OAAO,IAAI,qBAAa,CAAC;QACvB,SAAS,EAAE,KAAK;QAChB,EAAE,EAAE,mCAAmC;QACvC,IAAI,EAAE,mCAAmC;QACzC,cAAc,EAAE;YACd,sBAAc,CAAC,cAAc,CAAC;gBAC5B,EAAE,EAAE,iBAAiB;gBACrB,QAAQ,EAAE,KAAK;gBACf,oBAAoB,EAAE,mCAA2B,CAAC,MAAM;aACzD,CAAC;YACF,sBAAc,CAAC,cAAc,CAAC;gBAC5B,EAAE,EAAE,SAAS;gBACb,QAAQ,EAAE,KAAK;gBACf,oBAAoB,EAAE,mCAA2B,CAAC,MAAM;aACzD,CAAC;SACH;QACD,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE;YACrC,IAAA,gBAAM,EAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC;YAC/D,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,GAAU,CAAC;YAEpD,MAAM,SAAS,GAAG,IAAA,yBAAa,EAC7B,OAAO,CAAC,gBAAgB,EACxB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE;;gBACnC,GAAG,CAAC,GAAG,CAAC,GAAG,MAAA,GAAG,CAAC,GAAG,CAAC,mCAAI,EAAE,CAAC;gBAC1B,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAA4B,CAAC,EAChC,OAAO,CAAC,MAAM,CACf,CAAC,GAAG,CAAC;YAEN,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,CAAC,KAA2B,CAAC;YACvE,MAAM,mBAAmB,GAAG,MAAM,CAAC,eAAe,CAAC,KAA2B,CAAC;YAC/E,IAAI,mBAAmB,IAAI,CAAC,gBAAM,CAAC,KAAK,CAAC,mBAAmB,CAAC,EAAE;gBAC7D,MAAM,IAAI,KAAK,CACb,0FAA0F,mBAAmB,EAAE,CAChH,CAAC;aACH;YAED,MAAM,IAAA,gDAAkC,EAAC;gBACvC,GAAG;gBACH,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;gBAC1C,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,SAAS;gBACT,MAAM,EAAE;oBACN,cAAc,EAAE,mBAAmB;oBACnC,OAAO,EAAE,mBAAmB;iBAC7B;aACF,CAAC,CAAC;QACL,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAlDD,sFAkDC","sourcesContent":["import assert from 'assert';\n\nimport { BuildFunction, BuildStepInput, BuildStepInputValueTypeName } from '@expo/steps';\nimport { Job } from '@expo/eas-build-job';\nimport semver from 'semver';\n\nimport { readAppConfig } from '../../../utils/appConfig';\nimport { configureEASUpdateIfInstalledAsync } from '../../utils/expoUpdates';\n\nexport function configureEASUpdateIfInstalledFunction(): BuildFunction {\n return new BuildFunction({\n namespace: 'eas',\n id: 'configure_eas_update_if_installed',\n name: 'Configure EAS Update if installed',\n inputProviders: [\n BuildStepInput.createProvider({\n id: 'runtime_version',\n required: false,\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n }),\n BuildStepInput.createProvider({\n id: 'channel',\n required: false,\n allowedValueTypeName: BuildStepInputValueTypeName.STRING,\n }),\n ],\n fn: async (stepCtx, { env, inputs }) => {\n assert(stepCtx.global.staticContext.job, 'Job is not defined');\n const job = stepCtx.global.staticContext.job as Job;\n\n const appConfig = readAppConfig(\n stepCtx.workingDirectory,\n Object.keys(env).reduce((acc, key) => {\n acc[key] = env[key] ?? '';\n return acc;\n }, {} as Record<string, string>),\n stepCtx.logger\n ).exp;\n\n const releaseChannelInput = inputs.channel.value as string | undefined;\n const runtimeVersionInput = inputs.runtime_version.value as string | undefined;\n if (runtimeVersionInput && !semver.valid(runtimeVersionInput)) {\n throw new Error(\n `Runtime version provided by the \"runtime_version\" input is not a valid semver version: ${releaseChannelInput}`\n );\n }\n\n await configureEASUpdateIfInstalledAsync({\n job,\n workingDirectory: stepCtx.workingDirectory,\n logger: stepCtx.logger,\n appConfig,\n inputs: {\n runtimeVersion: runtimeVersionInput,\n channel: releaseChannelInput,\n },\n });\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare enum AndroidMetadataName {
|
|
2
|
+
UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = "expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY",
|
|
3
|
+
RELEASE_CHANNEL = "expo.modules.updates.EXPO_RELEASE_CHANNEL",
|
|
4
|
+
RUNTIME_VERSION = "expo.modules.updates.EXPO_RUNTIME_VERSION"
|
|
5
|
+
}
|
|
6
|
+
export declare function androidSetChannelNativelyAsync(channel: string, workingDirectory: string): Promise<void>;
|
|
7
|
+
export declare function androidSetRuntimeVersionNativelyAsync(runtimeVersion: string, workingDirectory: string): Promise<void>;
|
|
8
|
+
export declare function androidGetNativelyDefinedChannelAsync(workingDirectory: string): Promise<string | null>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.androidGetNativelyDefinedChannelAsync = exports.androidSetRuntimeVersionNativelyAsync = exports.androidSetChannelNativelyAsync = exports.AndroidMetadataName = void 0;
|
|
7
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
var AndroidMetadataName;
|
|
10
|
+
(function (AndroidMetadataName) {
|
|
11
|
+
AndroidMetadataName["UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY"] = "expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY";
|
|
12
|
+
AndroidMetadataName["RELEASE_CHANNEL"] = "expo.modules.updates.EXPO_RELEASE_CHANNEL";
|
|
13
|
+
AndroidMetadataName["RUNTIME_VERSION"] = "expo.modules.updates.EXPO_RUNTIME_VERSION";
|
|
14
|
+
})(AndroidMetadataName = exports.AndroidMetadataName || (exports.AndroidMetadataName = {}));
|
|
15
|
+
async function androidSetChannelNativelyAsync(channel, workingDirectory) {
|
|
16
|
+
const manifestPath = await config_plugins_1.AndroidConfig.Paths.getAndroidManifestAsync(workingDirectory);
|
|
17
|
+
if (!(await fs_extra_1.default.pathExists(manifestPath))) {
|
|
18
|
+
throw new Error(`Couldn't find Android manifest at ${manifestPath}`);
|
|
19
|
+
}
|
|
20
|
+
const androidManifest = await config_plugins_1.AndroidConfig.Manifest.readAndroidManifestAsync(manifestPath);
|
|
21
|
+
const mainApp = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);
|
|
22
|
+
const stringifiedUpdatesRequestHeaders = config_plugins_1.AndroidConfig.Manifest.getMainApplicationMetaDataValue(androidManifest, AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY);
|
|
23
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApp, AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY, JSON.stringify({
|
|
24
|
+
...JSON.parse(stringifiedUpdatesRequestHeaders !== null && stringifiedUpdatesRequestHeaders !== void 0 ? stringifiedUpdatesRequestHeaders : '{}'),
|
|
25
|
+
'expo-channel-name': channel,
|
|
26
|
+
}), 'value');
|
|
27
|
+
await config_plugins_1.AndroidConfig.Manifest.writeAndroidManifestAsync(manifestPath, androidManifest);
|
|
28
|
+
}
|
|
29
|
+
exports.androidSetChannelNativelyAsync = androidSetChannelNativelyAsync;
|
|
30
|
+
async function androidSetRuntimeVersionNativelyAsync(runtimeVersion, workingDirectory) {
|
|
31
|
+
const manifestPath = await config_plugins_1.AndroidConfig.Paths.getAndroidManifestAsync(workingDirectory);
|
|
32
|
+
if (!(await fs_extra_1.default.pathExists(manifestPath))) {
|
|
33
|
+
throw new Error(`Couldn't find Android manifest at ${manifestPath}`);
|
|
34
|
+
}
|
|
35
|
+
const androidManifest = await config_plugins_1.AndroidConfig.Manifest.readAndroidManifestAsync(manifestPath);
|
|
36
|
+
const mainApp = config_plugins_1.AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);
|
|
37
|
+
config_plugins_1.AndroidConfig.Manifest.addMetaDataItemToMainApplication(mainApp, AndroidMetadataName.RUNTIME_VERSION, runtimeVersion, 'value');
|
|
38
|
+
await config_plugins_1.AndroidConfig.Manifest.writeAndroidManifestAsync(manifestPath, androidManifest);
|
|
39
|
+
}
|
|
40
|
+
exports.androidSetRuntimeVersionNativelyAsync = androidSetRuntimeVersionNativelyAsync;
|
|
41
|
+
async function androidGetNativelyDefinedChannelAsync(workingDirectory) {
|
|
42
|
+
var _a;
|
|
43
|
+
const manifestPath = await config_plugins_1.AndroidConfig.Paths.getAndroidManifestAsync(workingDirectory);
|
|
44
|
+
if (!(await fs_extra_1.default.pathExists(manifestPath))) {
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
const androidManifest = await config_plugins_1.AndroidConfig.Manifest.readAndroidManifestAsync(manifestPath);
|
|
48
|
+
const stringifiedUpdatesRequestHeaders = config_plugins_1.AndroidConfig.Manifest.getMainApplicationMetaDataValue(androidManifest, AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY);
|
|
49
|
+
try {
|
|
50
|
+
const updatesRequestHeaders = JSON.parse(stringifiedUpdatesRequestHeaders !== null && stringifiedUpdatesRequestHeaders !== void 0 ? stringifiedUpdatesRequestHeaders : '{}');
|
|
51
|
+
return (_a = updatesRequestHeaders['expo-channel-name']) !== null && _a !== void 0 ? _a : null;
|
|
52
|
+
}
|
|
53
|
+
catch (err) {
|
|
54
|
+
throw new Error(`Failed to parse ${AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY} from AndroidManifest.xml: ${err.message}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
exports.androidGetNativelyDefinedChannelAsync = androidGetNativelyDefinedChannelAsync;
|
|
58
|
+
//# sourceMappingURL=expoUpdates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoUpdates.js","sourceRoot":"","sources":["../../../../src/steps/utils/android/expoUpdates.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAqD;AACrD,wDAA0B;AAE1B,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,mIAA4G,CAAA;IAC5G,oFAA6D,CAAA;IAC7D,oFAA6D,CAAA;AAC/D,CAAC,EAJW,mBAAmB,GAAnB,2BAAmB,KAAnB,2BAAmB,QAI9B;AAEM,KAAK,UAAU,8BAA8B,CAClD,OAAe,EACf,gBAAwB;IAExB,MAAM,YAAY,GAAG,MAAM,8BAAa,CAAC,KAAK,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAEzF,IAAI,CAAC,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,qCAAqC,YAAY,EAAE,CAAC,CAAC;KACtE;IAED,MAAM,eAAe,GAAG,MAAM,8BAAa,CAAC,QAAQ,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAC;IAC5F,MAAM,OAAO,GAAG,8BAAa,CAAC,QAAQ,CAAC,yBAAyB,CAAC,eAAe,CAAC,CAAC;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AAY,GAAG,MAAM,8BAAa,CAAC,KAAK,CAAC,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAEzF,IAAI,CAAC,CAAC,MAAM,kBAAE,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE;QACxC,OAAO,IAAI,CAAC;KACb;IAED,MAAM,eAAe,GAAG,MAAM,8BAAa,CAAC,QAAQ,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAC;IAC5F,MAAM,gCAAgC,GAAG,8BAAa,CAAC,QAAQ,CAAC,+BAA+B,CAC7F,eAAe,EACf,mBAAmB,CAAC,yCAAyC,CAC9D,CAAC;IACF,IAAI;QACF,MAAM,qBAAqB,GAAG,IAAI,CAAC,KAAK,CAAC,gCAAgC,aAAhC,gCAAgC,cAAhC,gCAAgC,GAAI,IAAI,CAAC,CAAC;QACnF,OAAO,MAAA,qBAAqB,CAAC,mBAAmB,CAAC,mCAAI,IAAI,CAAC;KAC3D;IAAC,OAAO,GAAQ,EAAE;QACjB,MAAM,IAAI,KAAK,CACb,mBAAmB,mBAAmB,CAAC,yCAAyC,8BAA8B,GAAG,CAAC,OAAO,EAAE,CAC5H,CAAC;KACH;AACH,CAAC;AAtBD,sFAsBC","sourcesContent":["import { AndroidConfig } from '@expo/config-plugins';\nimport fs from 'fs-extra';\n\nexport enum AndroidMetadataName {\n UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = 'expo.modules.updates.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY',\n RELEASE_CHANNEL = 'expo.modules.updates.EXPO_RELEASE_CHANNEL',\n RUNTIME_VERSION = 'expo.modules.updates.EXPO_RUNTIME_VERSION',\n}\n\nexport async function androidSetChannelNativelyAsync(\n channel: string,\n workingDirectory: string\n): Promise<void> {\n const manifestPath = await AndroidConfig.Paths.getAndroidManifestAsync(workingDirectory);\n\n if (!(await fs.pathExists(manifestPath))) {\n throw new Error(`Couldn't find Android manifest at ${manifestPath}`);\n }\n\n const androidManifest = await AndroidConfig.Manifest.readAndroidManifestAsync(manifestPath);\n const mainApp = AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);\n const stringifiedUpdatesRequestHeaders = AndroidConfig.Manifest.getMainApplicationMetaDataValue(\n androidManifest,\n AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY\n );\n AndroidConfig.Manifest.addMetaDataItemToMainApplication(\n mainApp,\n AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY,\n JSON.stringify({\n ...JSON.parse(stringifiedUpdatesRequestHeaders ?? '{}'),\n 'expo-channel-name': channel,\n }),\n 'value'\n );\n await AndroidConfig.Manifest.writeAndroidManifestAsync(manifestPath, androidManifest);\n}\n\nexport async function androidSetRuntimeVersionNativelyAsync(\n runtimeVersion: string,\n workingDirectory: string\n): Promise<void> {\n const manifestPath = await AndroidConfig.Paths.getAndroidManifestAsync(workingDirectory);\n\n if (!(await fs.pathExists(manifestPath))) {\n throw new Error(`Couldn't find Android manifest at ${manifestPath}`);\n }\n\n const androidManifest = await AndroidConfig.Manifest.readAndroidManifestAsync(manifestPath);\n const mainApp = AndroidConfig.Manifest.getMainApplicationOrThrow(androidManifest);\n AndroidConfig.Manifest.addMetaDataItemToMainApplication(\n mainApp,\n AndroidMetadataName.RUNTIME_VERSION,\n runtimeVersion,\n 'value'\n );\n await AndroidConfig.Manifest.writeAndroidManifestAsync(manifestPath, androidManifest);\n}\n\nexport async function androidGetNativelyDefinedChannelAsync(\n workingDirectory: string\n): Promise<string | null> {\n const manifestPath = await AndroidConfig.Paths.getAndroidManifestAsync(workingDirectory);\n\n if (!(await fs.pathExists(manifestPath))) {\n return null;\n }\n\n const androidManifest = await AndroidConfig.Manifest.readAndroidManifestAsync(manifestPath);\n const stringifiedUpdatesRequestHeaders = AndroidConfig.Manifest.getMainApplicationMetaDataValue(\n androidManifest,\n AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY\n );\n try {\n const updatesRequestHeaders = JSON.parse(stringifiedUpdatesRequestHeaders ?? '{}');\n return updatesRequestHeaders['expo-channel-name'] ?? null;\n } catch (err: any) {\n throw new Error(\n `Failed to parse ${AndroidMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY} from AndroidManifest.xml: ${err.message}`\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/// <reference types="bunyan" />
|
|
2
|
+
import { Job } from '@expo/eas-build-job';
|
|
3
|
+
import { bunyan } from '@expo/logger';
|
|
4
|
+
import { ExpoConfig } from '@expo/config';
|
|
5
|
+
export declare function configureEASUpdateIfInstalledAsync({ job, workingDirectory, logger, inputs, appConfig, }: {
|
|
6
|
+
job: Job;
|
|
7
|
+
workingDirectory: string;
|
|
8
|
+
logger: bunyan;
|
|
9
|
+
inputs: {
|
|
10
|
+
runtimeVersion?: string;
|
|
11
|
+
channel?: string;
|
|
12
|
+
};
|
|
13
|
+
appConfig: ExpoConfig;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
export declare function isEASUpdateConfigured(appConfig: ExpoConfig, logger: bunyan): boolean;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.isEASUpdateConfigured = exports.configureEASUpdateIfInstalledAsync = void 0;
|
|
7
|
+
const eas_build_job_1 = require("@expo/eas-build-job");
|
|
8
|
+
const Updates_1 = require("@expo/config-plugins/build/utils/Updates");
|
|
9
|
+
const isExpoUpdatesInstalled_1 = __importDefault(require("../../utils/isExpoUpdatesInstalled"));
|
|
10
|
+
const expoUpdates_1 = require("./ios/expoUpdates");
|
|
11
|
+
const expoUpdates_2 = require("./android/expoUpdates");
|
|
12
|
+
async function configureEASUpdateIfInstalledAsync({ job, workingDirectory, logger, inputs, appConfig, }) {
|
|
13
|
+
var _a, _b, _c, _d, _e;
|
|
14
|
+
if (!(await (0, isExpoUpdatesInstalled_1.default)(workingDirectory))) {
|
|
15
|
+
logger.info('Expo Updates is not installed, skipping configuring Expo Updates.');
|
|
16
|
+
}
|
|
17
|
+
const runtimeVersion = (_c = (_a = inputs.channel) !== null && _a !== void 0 ? _a : (_b = job.version) === null || _b === void 0 ? void 0 : _b.runtimeVersion) !== null && _c !== void 0 ? _c : (0, Updates_1.getRuntimeVersionNullable)(appConfig, job.platform);
|
|
18
|
+
const jobOrInputChannel = (_d = inputs.runtimeVersion) !== null && _d !== void 0 ? _d : (_e = job.updates) === null || _e === void 0 ? void 0 : _e.channel;
|
|
19
|
+
if (isEASUpdateConfigured(appConfig, logger)) {
|
|
20
|
+
const channel = jobOrInputChannel !== null && jobOrInputChannel !== void 0 ? jobOrInputChannel : (await getChannelAsync(job, workingDirectory));
|
|
21
|
+
if (channel) {
|
|
22
|
+
await configureEASUpdate(job, logger, channel, workingDirectory);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (job.releaseChannel !== undefined) {
|
|
26
|
+
logger.warn(`This build is configured with EAS Update however has a Classic Updates releaseChannel set instead of having an EAS Update channel.`);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
logger.warn(`This build is configured to query EAS Update for updates, however no channel is set.`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
logger.info(`Expo Updates is not configured, skipping configuring Expo Updates.`);
|
|
35
|
+
}
|
|
36
|
+
if (runtimeVersion) {
|
|
37
|
+
logger.info('Updating runtimeVersion in Expo.plist');
|
|
38
|
+
await setRuntimeVersionNativelyAsync(job, runtimeVersion, workingDirectory);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.configureEASUpdateIfInstalledAsync = configureEASUpdateIfInstalledAsync;
|
|
42
|
+
function isEASUpdateConfigured(appConfig, logger) {
|
|
43
|
+
var _a;
|
|
44
|
+
const rawUrl = (_a = appConfig.updates) === null || _a === void 0 ? void 0 : _a.url;
|
|
45
|
+
if (!rawUrl) {
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
try {
|
|
49
|
+
const url = new URL(rawUrl);
|
|
50
|
+
return ['u.expo.dev', 'staging-u.expo.dev'].includes(url.hostname);
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
logger.error({ err }, `Cannot parse expo.updates.url = ${rawUrl} as URL`);
|
|
54
|
+
logger.error(`Assuming EAS Update is not configured`);
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.isEASUpdateConfigured = isEASUpdateConfigured;
|
|
59
|
+
async function configureEASUpdate(job, logger, channel, workingDirectory) {
|
|
60
|
+
const newUpdateRequestHeaders = {
|
|
61
|
+
'expo-channel-name': channel,
|
|
62
|
+
};
|
|
63
|
+
const configFile = job.platform === eas_build_job_1.Platform.ANDROID ? 'AndroidManifest.xml' : 'Expo.plist';
|
|
64
|
+
logger.info(`Setting the update request headers in '${configFile}' to '${JSON.stringify(newUpdateRequestHeaders)}'`);
|
|
65
|
+
switch (job.platform) {
|
|
66
|
+
case eas_build_job_1.Platform.ANDROID: {
|
|
67
|
+
await (0, expoUpdates_2.androidSetChannelNativelyAsync)(channel, workingDirectory);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
case eas_build_job_1.Platform.IOS: {
|
|
71
|
+
await (0, expoUpdates_1.iosSetChannelNativelyAsync)(channel, workingDirectory);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`Platform is not supported.`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
async function getChannelAsync(job, workingDirectory) {
|
|
79
|
+
switch (job.platform) {
|
|
80
|
+
case eas_build_job_1.Platform.ANDROID: {
|
|
81
|
+
return await (0, expoUpdates_2.androidGetNativelyDefinedChannelAsync)(workingDirectory);
|
|
82
|
+
}
|
|
83
|
+
case eas_build_job_1.Platform.IOS: {
|
|
84
|
+
return await (0, expoUpdates_1.iosGetNativelyDefinedChannelAsync)(workingDirectory);
|
|
85
|
+
}
|
|
86
|
+
default:
|
|
87
|
+
throw new Error(`Platform is not supported.`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async function setRuntimeVersionNativelyAsync(job, runtimeVersion, workingDirectory) {
|
|
91
|
+
switch (job.platform) {
|
|
92
|
+
case eas_build_job_1.Platform.ANDROID: {
|
|
93
|
+
await (0, expoUpdates_2.androidSetRuntimeVersionNativelyAsync)(runtimeVersion, workingDirectory);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
case eas_build_job_1.Platform.IOS: {
|
|
97
|
+
await (0, expoUpdates_1.iosSetRuntimeVersionNativelyAsync)(runtimeVersion, workingDirectory);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
default:
|
|
101
|
+
throw new Error(`Platform is not supported.`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=expoUpdates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoUpdates.js","sourceRoot":"","sources":["../../../src/steps/utils/expoUpdates.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAoD;AAGpD,sEAAqF;AAErF,gGAA6E;AAE7E,mDAI2B;AAC3B,uDAI+B;AAExB,KAAK,UAAU,kCAAkC,CAAC,EACvD,GAAG,EACH,gBAAgB,EAChB,MAAM,EACN,MAAM,EACN,SAAS,GAUV;;IACC,IAAI,CAAC,CAAC,MAAM,IAAA,gCAA2B,EAAC,gBAAgB,CAAC,CAAC,EAAE;QAC1D,MAAM,CAAC,IAAI,CAAC,mEAAmE,CAAC,CAAC;KAClF;IAED,MAAM,cAAc,GAClB,MAAA,MAAA,MAAM,CAAC,OAAO,mCACd,MAAA,GAAG,CAAC,OAAO,0CAAE,cAAc,mCAC3B,IAAA,mCAAyB,EAAC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SAClE;QACD;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KACjD;AACH,CAAC;AAED,KAAK,UAAU,8BAA8B,CAC3C,GAAQ,EACR,cAAsB,EACtB,gBAAwB;IAExB,QAAQ,GAAG,CAAC,QAAQ,EAAE;QACpB,KAAK,wBAAQ,CAAC,OAAO,CAAC,CAAC;YACrB,MAAM,IAAA,mDAAqC,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;YAC9E,OAAO;SACR;QACD,KAAK,wBAAQ,CAAC,GAAG,CAAC,CAAC;YACjB,MAAM,IAAA,+CAAiC,EAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;YAC1E,OAAO;SACR;QACD;YACE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;KACjD;AACH,CAAC","sourcesContent":["import { Job, Platform } from '@expo/eas-build-job';\nimport { bunyan } from '@expo/logger';\nimport { ExpoConfig } from '@expo/config';\nimport { getRuntimeVersionNullable } from '@expo/config-plugins/build/utils/Updates';\n\nimport isExpoUpdatesInstalledAsync from '../../utils/isExpoUpdatesInstalled';\n\nimport {\n iosGetNativelyDefinedChannelAsync,\n iosSetChannelNativelyAsync,\n iosSetRuntimeVersionNativelyAsync,\n} from './ios/expoUpdates';\nimport {\n androidGetNativelyDefinedChannelAsync,\n androidSetChannelNativelyAsync,\n androidSetRuntimeVersionNativelyAsync,\n} from './android/expoUpdates';\n\nexport async function configureEASUpdateIfInstalledAsync({\n job,\n workingDirectory,\n logger,\n inputs,\n appConfig,\n}: {\n job: Job;\n workingDirectory: string;\n logger: bunyan;\n inputs: {\n runtimeVersion?: string;\n channel?: string;\n };\n appConfig: ExpoConfig;\n}): Promise<void> {\n if (!(await isExpoUpdatesInstalledAsync(workingDirectory))) {\n logger.info('Expo Updates is not installed, skipping configuring Expo Updates.');\n }\n\n const runtimeVersion =\n inputs.channel ??\n job.version?.runtimeVersion ??\n getRuntimeVersionNullable(appConfig, job.platform);\n\n const jobOrInputChannel = inputs.runtimeVersion ?? job.updates?.channel;\n\n if (isEASUpdateConfigured(appConfig, logger)) {\n const channel = jobOrInputChannel ?? (await getChannelAsync(job, workingDirectory));\n if (channel) {\n await configureEASUpdate(job, logger, channel, workingDirectory);\n } else {\n if (job.releaseChannel !== undefined) {\n logger.warn(\n `This build is configured with EAS Update however has a Classic Updates releaseChannel set instead of having an EAS Update channel.`\n );\n } else {\n logger.warn(\n `This build is configured to query EAS Update for updates, however no channel is set.`\n );\n }\n }\n } else {\n logger.info(`Expo Updates is not configured, skipping configuring Expo Updates.`);\n }\n\n if (runtimeVersion) {\n logger.info('Updating runtimeVersion in Expo.plist');\n await setRuntimeVersionNativelyAsync(job, runtimeVersion, workingDirectory);\n }\n}\n\nexport function isEASUpdateConfigured(appConfig: ExpoConfig, logger: bunyan): boolean {\n const rawUrl = appConfig.updates?.url;\n if (!rawUrl) {\n return false;\n }\n try {\n const url = new URL(rawUrl);\n return ['u.expo.dev', 'staging-u.expo.dev'].includes(url.hostname);\n } catch (err) {\n logger.error({ err }, `Cannot parse expo.updates.url = ${rawUrl} as URL`);\n logger.error(`Assuming EAS Update is not configured`);\n return false;\n }\n}\n\nasync function configureEASUpdate(\n job: Job,\n logger: bunyan,\n channel: string,\n workingDirectory: string\n): Promise<void> {\n const newUpdateRequestHeaders: Record<string, string> = {\n 'expo-channel-name': channel,\n };\n\n const configFile = job.platform === Platform.ANDROID ? 'AndroidManifest.xml' : 'Expo.plist';\n logger.info(\n `Setting the update request headers in '${configFile}' to '${JSON.stringify(\n newUpdateRequestHeaders\n )}'`\n );\n\n switch (job.platform) {\n case Platform.ANDROID: {\n await androidSetChannelNativelyAsync(channel, workingDirectory);\n return;\n }\n case Platform.IOS: {\n await iosSetChannelNativelyAsync(channel, workingDirectory);\n return;\n }\n default:\n throw new Error(`Platform is not supported.`);\n }\n}\n\nasync function getChannelAsync(job: Job, workingDirectory: string): Promise<string | null> {\n switch (job.platform) {\n case Platform.ANDROID: {\n return await androidGetNativelyDefinedChannelAsync(workingDirectory);\n }\n case Platform.IOS: {\n return await iosGetNativelyDefinedChannelAsync(workingDirectory);\n }\n default:\n throw new Error(`Platform is not supported.`);\n }\n}\n\nasync function setRuntimeVersionNativelyAsync(\n job: Job,\n runtimeVersion: string,\n workingDirectory: string\n): Promise<void> {\n switch (job.platform) {\n case Platform.ANDROID: {\n await androidSetRuntimeVersionNativelyAsync(runtimeVersion, workingDirectory);\n return;\n }\n case Platform.IOS: {\n await iosSetRuntimeVersionNativelyAsync(runtimeVersion, workingDirectory);\n return;\n }\n default:\n throw new Error(`Platform is not supported.`);\n }\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare enum IosMetadataName {
|
|
2
|
+
UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = "EXUpdatesRequestHeaders",
|
|
3
|
+
RELEASE_CHANNEL = "EXUpdatesReleaseChannel",
|
|
4
|
+
RUNTIME_VERSION = "EXUpdatesRuntimeVersion"
|
|
5
|
+
}
|
|
6
|
+
export declare function iosSetChannelNativelyAsync(channel: string, workingDirectory: string): Promise<void>;
|
|
7
|
+
export declare function iosSetRuntimeVersionNativelyAsync(runtimeVersion: string, workingDirectory: string): Promise<void>;
|
|
8
|
+
export declare function iosGetNativelyDefinedChannelAsync(workingDirectory: string): Promise<string | null>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.iosGetNativelyDefinedChannelAsync = exports.iosSetRuntimeVersionNativelyAsync = exports.iosSetChannelNativelyAsync = exports.IosMetadataName = void 0;
|
|
7
|
+
const config_plugins_1 = require("@expo/config-plugins");
|
|
8
|
+
const fs_extra_1 = __importDefault(require("fs-extra"));
|
|
9
|
+
const plist_1 = __importDefault(require("@expo/plist"));
|
|
10
|
+
var IosMetadataName;
|
|
11
|
+
(function (IosMetadataName) {
|
|
12
|
+
IosMetadataName["UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY"] = "EXUpdatesRequestHeaders";
|
|
13
|
+
IosMetadataName["RELEASE_CHANNEL"] = "EXUpdatesReleaseChannel";
|
|
14
|
+
IosMetadataName["RUNTIME_VERSION"] = "EXUpdatesRuntimeVersion";
|
|
15
|
+
})(IosMetadataName = exports.IosMetadataName || (exports.IosMetadataName = {}));
|
|
16
|
+
async function iosSetChannelNativelyAsync(channel, workingDirectory) {
|
|
17
|
+
var _a;
|
|
18
|
+
const expoPlistPath = config_plugins_1.IOSConfig.Paths.getExpoPlistPath(workingDirectory);
|
|
19
|
+
if (!(await fs_extra_1.default.pathExists(expoPlistPath))) {
|
|
20
|
+
throw new Error(`${expoPlistPath} does not exist`);
|
|
21
|
+
}
|
|
22
|
+
const expoPlistContents = await fs_extra_1.default.readFile(expoPlistPath, 'utf8');
|
|
23
|
+
const items = plist_1.default.parse(expoPlistContents);
|
|
24
|
+
items[IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY] = {
|
|
25
|
+
...((_a = items[IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY]) !== null && _a !== void 0 ? _a : {}),
|
|
26
|
+
'expo-channel-name': channel,
|
|
27
|
+
};
|
|
28
|
+
const updatedExpoPlistContents = plist_1.default.build(items);
|
|
29
|
+
await fs_extra_1.default.writeFile(expoPlistPath, updatedExpoPlistContents);
|
|
30
|
+
}
|
|
31
|
+
exports.iosSetChannelNativelyAsync = iosSetChannelNativelyAsync;
|
|
32
|
+
async function iosSetRuntimeVersionNativelyAsync(runtimeVersion, workingDirectory) {
|
|
33
|
+
const expoPlistPath = config_plugins_1.IOSConfig.Paths.getExpoPlistPath(workingDirectory);
|
|
34
|
+
if (!(await fs_extra_1.default.pathExists(expoPlistPath))) {
|
|
35
|
+
throw new Error(`${expoPlistPath} does not exist`);
|
|
36
|
+
}
|
|
37
|
+
const expoPlistContents = await fs_extra_1.default.readFile(expoPlistPath, 'utf8');
|
|
38
|
+
const items = plist_1.default.parse(expoPlistContents);
|
|
39
|
+
items[IosMetadataName.RUNTIME_VERSION] = runtimeVersion;
|
|
40
|
+
const updatedExpoPlistContents = plist_1.default.build(items);
|
|
41
|
+
await fs_extra_1.default.writeFile(expoPlistPath, updatedExpoPlistContents);
|
|
42
|
+
}
|
|
43
|
+
exports.iosSetRuntimeVersionNativelyAsync = iosSetRuntimeVersionNativelyAsync;
|
|
44
|
+
async function iosGetNativelyDefinedChannelAsync(workingDirectory) {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const expoPlistPath = config_plugins_1.IOSConfig.Paths.getExpoPlistPath(workingDirectory);
|
|
47
|
+
if (!(await fs_extra_1.default.pathExists(expoPlistPath))) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
const expoPlistContents = await fs_extra_1.default.readFile(expoPlistPath, 'utf8');
|
|
51
|
+
try {
|
|
52
|
+
const items = plist_1.default.parse(expoPlistContents);
|
|
53
|
+
const updatesRequestHeaders = ((_a = items[IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY]) !== null && _a !== void 0 ? _a : {});
|
|
54
|
+
return (_b = updatesRequestHeaders['expo-channel-name']) !== null && _b !== void 0 ? _b : null;
|
|
55
|
+
}
|
|
56
|
+
catch (err) {
|
|
57
|
+
throw new Error(`Failed to parse ${IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY} from Expo.plist: ${err.message}`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.iosGetNativelyDefinedChannelAsync = iosGetNativelyDefinedChannelAsync;
|
|
61
|
+
//# sourceMappingURL=expoUpdates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"expoUpdates.js","sourceRoot":"","sources":["../../../../src/steps/utils/ios/expoUpdates.ts"],"names":[],"mappings":";;;;;;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ist from '@expo/plist';\n\nexport enum IosMetadataName {\n UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY = 'EXUpdatesRequestHeaders',\n RELEASE_CHANNEL = 'EXUpdatesReleaseChannel',\n RUNTIME_VERSION = 'EXUpdatesRuntimeVersion',\n}\n\nexport async function iosSetChannelNativelyAsync(\n channel: string,\n workingDirectory: string\n): Promise<void> {\n const expoPlistPath = IOSConfig.Paths.getExpoPlistPath(workingDirectory);\n\n if (!(await fs.pathExists(expoPlistPath))) {\n throw new Error(`${expoPlistPath} does not exist`);\n }\n\n const expoPlistContents = await fs.readFile(expoPlistPath, 'utf8');\n const items: Record<string, string | Record<string, string>> = plist.parse(expoPlistContents);\n items[IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY] = {\n ...((items[IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY] as Record<\n string,\n string\n >) ?? {}),\n 'expo-channel-name': channel,\n };\n const updatedExpoPlistContents = plist.build(items);\n\n await fs.writeFile(expoPlistPath, updatedExpoPlistContents);\n}\n\nexport async function iosSetRuntimeVersionNativelyAsync(\n runtimeVersion: string,\n workingDirectory: string\n): Promise<void> {\n const expoPlistPath = IOSConfig.Paths.getExpoPlistPath(workingDirectory);\n\n if (!(await fs.pathExists(expoPlistPath))) {\n throw new Error(`${expoPlistPath} does not exist`);\n }\n\n const expoPlistContents = await fs.readFile(expoPlistPath, 'utf8');\n const items = plist.parse(expoPlistContents);\n items[IosMetadataName.RUNTIME_VERSION] = runtimeVersion;\n const updatedExpoPlistContents = plist.build(items);\n\n await fs.writeFile(expoPlistPath, updatedExpoPlistContents);\n}\n\nexport async function iosGetNativelyDefinedChannelAsync(\n workingDirectory: string\n): Promise<string | null> {\n const expoPlistPath = IOSConfig.Paths.getExpoPlistPath(workingDirectory);\n\n if (!(await fs.pathExists(expoPlistPath))) {\n return null;\n }\n\n const expoPlistContents = await fs.readFile(expoPlistPath, 'utf8');\n try {\n const items: Record<string, string | Record<string, string>> = plist.parse(expoPlistContents);\n const updatesRequestHeaders = (items[\n IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY\n ] ?? {}) as Record<string, string>;\n return updatesRequestHeaders['expo-channel-name'] ?? null;\n } catch (err: any) {\n throw new Error(\n `Failed to parse ${IosMetadataName.UPDATES_CONFIGURATION_REQUEST_HEADERS_KEY} from Expo.plist: ${err.message}`\n );\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@expo/build-tools",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.29",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -24,11 +24,11 @@
|
|
|
24
24
|
"@expo/config": "^7.0.3",
|
|
25
25
|
"@expo/config-plugins": "^5.0.4",
|
|
26
26
|
"@expo/downloader": "1.0.13",
|
|
27
|
-
"@expo/eas-build-job": "1.0.
|
|
27
|
+
"@expo/eas-build-job": "1.0.29",
|
|
28
28
|
"@expo/logger": "1.0.21",
|
|
29
29
|
"@expo/package-manager": "^0.0.57",
|
|
30
30
|
"@expo/plist": "^0.0.20",
|
|
31
|
-
"@expo/steps": "1.0.
|
|
31
|
+
"@expo/steps": "1.0.29",
|
|
32
32
|
"@expo/template-file": "1.0.13",
|
|
33
33
|
"@expo/turtle-spawn": "1.0.21",
|
|
34
34
|
"@expo/xcpretty": "^4.2.2",
|
|
@@ -62,5 +62,5 @@
|
|
|
62
62
|
"node": "18.13.0",
|
|
63
63
|
"yarn": "1.22.19"
|
|
64
64
|
},
|
|
65
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "33a20f9f03da5e7b57faee5f5dde97e6700b6931"
|
|
66
66
|
}
|