expo-updates 0.27.2 → 0.27.3

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/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 0.27.3 — 2025-03-11
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Pass through the package version to config plugin sync utilities ([#35372](https://github.com/expo/expo/pull/35372) by [@brentvatne](https://github.com/brentvatne))
18
+
13
19
  ## 0.27.2 — 2025-02-26
14
20
 
15
21
  ### 💡 Others
@@ -16,7 +16,7 @@ apply plugin: 'com.android.library'
16
16
  apply plugin: 'com.google.devtools.ksp'
17
17
 
18
18
  group = 'host.exp.exponent'
19
- version = '0.27.2'
19
+ version = '0.27.3'
20
20
 
21
21
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
22
22
  apply from: expoModulesCorePlugin
@@ -63,7 +63,7 @@ android {
63
63
  namespace "expo.modules.updates"
64
64
  defaultConfig {
65
65
  versionCode 31
66
- versionName '0.27.2'
66
+ versionName '0.27.3'
67
67
  consumerProguardFiles("proguard-rules.pro")
68
68
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
69
69
 
@@ -31,13 +31,14 @@ async function syncConfigurationToNativeAndroidAsync(options) {
31
31
  isPublicConfig: false,
32
32
  skipSDKVersionRequirement: true,
33
33
  });
34
+ const packageVersion = require('../../package.json').version;
34
35
  // sync AndroidManifest.xml
35
36
  const androidManifestPath = await config_plugins_1.AndroidConfig.Paths.getAndroidManifestAsync(options.projectRoot);
36
37
  if (!androidManifestPath) {
37
38
  throw new Error(`Could not find AndroidManifest.xml in project directory: "${options.projectRoot}"`);
38
39
  }
39
40
  const androidManifest = await config_plugins_1.AndroidConfig.Manifest.readAndroidManifestAsync(androidManifestPath);
40
- const updatedAndroidManifest = await config_plugins_1.AndroidConfig.Updates.setUpdatesConfigAsync(options.projectRoot, exp, androidManifest);
41
+ const updatedAndroidManifest = await config_plugins_1.AndroidConfig.Updates.setUpdatesConfigAsync(options.projectRoot, exp, androidManifest, packageVersion);
41
42
  await config_plugins_1.AndroidConfig.Manifest.writeAndroidManifestAsync(androidManifestPath, updatedAndroidManifest);
42
43
  // sync strings.xml
43
44
  const stringsJSONPath = await config_plugins_1.AndroidConfig.Strings.getProjectStringsXMLPathAsync(options.projectRoot);
@@ -52,8 +53,9 @@ async function syncConfigurationToNativeIosAsync(options) {
52
53
  isPublicConfig: false,
53
54
  skipSDKVersionRequirement: true,
54
55
  });
56
+ const packageVersion = require('../../package.json').version;
55
57
  const expoPlist = await readExpoPlistAsync(options.projectRoot);
56
- const updatedExpoPlist = await config_plugins_1.IOSConfig.Updates.setUpdatesConfigAsync(options.projectRoot, exp, expoPlist);
58
+ const updatedExpoPlist = await config_plugins_1.IOSConfig.Updates.setUpdatesConfigAsync(options.projectRoot, exp, expoPlist, packageVersion);
57
59
  await writeExpoPlistAsync(options.projectRoot, updatedExpoPlist);
58
60
  }
59
61
  async function readExpoPlistAsync(projectDir) {
@@ -40,6 +40,8 @@ async function syncConfigurationToNativeAndroidAsync(
40
40
  skipSDKVersionRequirement: true,
41
41
  });
42
42
 
43
+ const packageVersion = require('../../package.json').version;
44
+
43
45
  // sync AndroidManifest.xml
44
46
  const androidManifestPath = await AndroidConfig.Paths.getAndroidManifestAsync(
45
47
  options.projectRoot
@@ -55,7 +57,8 @@ async function syncConfigurationToNativeAndroidAsync(
55
57
  const updatedAndroidManifest = await AndroidConfig.Updates.setUpdatesConfigAsync(
56
58
  options.projectRoot,
57
59
  exp,
58
- androidManifest
60
+ androidManifest,
61
+ packageVersion
59
62
  );
60
63
  await AndroidConfig.Manifest.writeAndroidManifestAsync(
61
64
  androidManifestPath,
@@ -87,11 +90,14 @@ async function syncConfigurationToNativeIosAsync(
87
90
  skipSDKVersionRequirement: true,
88
91
  });
89
92
 
93
+ const packageVersion = require('../../package.json').version;
94
+
90
95
  const expoPlist = await readExpoPlistAsync(options.projectRoot);
91
96
  const updatedExpoPlist = await IOSConfig.Updates.setUpdatesConfigAsync(
92
97
  options.projectRoot,
93
98
  exp,
94
- expoPlist
99
+ expoPlist,
100
+ packageVersion
95
101
  );
96
102
  await writeExpoPlistAsync(options.projectRoot, updatedExpoPlist);
97
103
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-updates",
3
- "version": "0.27.2",
3
+ "version": "0.27.3",
4
4
  "description": "Fetches and manages remotely-hosted assets and updates to your app's JS bundle.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@expo/code-signing-certificates": "0.0.5",
41
- "@expo/config": "~10.0.10",
42
- "@expo/config-plugins": "~9.0.16",
41
+ "@expo/config": "~10.0.11",
42
+ "@expo/config-plugins": "~9.0.17",
43
43
  "@expo/spawn-async": "^1.7.2",
44
44
  "arg": "4.1.0",
45
45
  "chalk": "^4.1.2",
@@ -67,5 +67,5 @@
67
67
  "expo": "*",
68
68
  "react": "*"
69
69
  },
70
- "gitHead": "4f3b834d475d0de0d26cc6b1d39019c8bf11aca6"
70
+ "gitHead": "bf63b042785a27b713485db0171eb0500abfa582"
71
71
  }
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export type Command = (argv?: string[]) => void;
package/build-cli/cli.js DELETED
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- const tslib_1 = require("tslib");
5
- const arg_1 = tslib_1.__importDefault(require("arg"));
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const Log = tslib_1.__importStar(require("./utils/log"));
8
- const commands = {
9
- // Add a new command here
10
- 'codesigning:generate': () => import('./generateCodeSigning.js').then((i) => i.generateCodeSigning),
11
- 'codesigning:configure': () => import('./configureCodeSigning.js').then((i) => i.configureCodeSigning),
12
- };
13
- const args = (0, arg_1.default)({
14
- // Types
15
- '--help': Boolean,
16
- // Aliases
17
- '-h': '--help',
18
- }, {
19
- permissive: true,
20
- });
21
- const command = args._[0];
22
- const commandArgs = args._.slice(1);
23
- // Handle `--help` flag
24
- if ((args['--help'] && !command) || !command) {
25
- Log.exit((0, chalk_1.default) `
26
- {bold Usage}
27
- {dim $} npx expo-updates <command>
28
-
29
- {bold Commands}
30
- ${Object.keys(commands).sort().join(', ')}
31
-
32
- {bold Options}
33
- --help, -h Displays this message
34
-
35
- For more information run a command with the --help flag
36
- {dim $} npx expo-updates codesigning:generate --help
37
- `, 0);
38
- }
39
- // Push the help flag to the subcommand args.
40
- if (args['--help']) {
41
- commandArgs.push('--help');
42
- }
43
- // Install exit hooks
44
- process.on('SIGINT', () => process.exit(0));
45
- process.on('SIGTERM', () => process.exit(0));
46
- commands[command]().then((exec) => exec(commandArgs));
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from './cli';
3
- export declare const configureCodeSigning: Command;
@@ -1,43 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.configureCodeSigning = void 0;
5
- const tslib_1 = require("tslib");
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const args_1 = require("./utils/args");
8
- const Log = tslib_1.__importStar(require("./utils/log"));
9
- const configureCodeSigning = async (argv) => {
10
- const args = (0, args_1.assertArgs)({
11
- // Types
12
- '--help': Boolean,
13
- '--certificate-input-directory': String,
14
- '--key-input-directory': String,
15
- '--keyid': String,
16
- // Aliases
17
- '-h': '--help',
18
- }, argv !== null && argv !== void 0 ? argv : []);
19
- if (args['--help']) {
20
- Log.exit((0, chalk_1.default) `
21
- {bold Description}
22
- Configure expo-updates code signing for this project and verify setup
23
-
24
- {bold Usage}
25
- {dim $} npx expo-updates codesigning:configure --certificate-input-directory <dir> --key-input-directory <dir>
26
-
27
- Options
28
- --certificate-input-directory <string> Directory containing code signing certificate
29
- --key-input-directory <string> Directory containing private and public keys
30
- -h, --help Output usage information
31
- `, 0);
32
- }
33
- const { configureCodeSigningAsync } = await import('./configureCodeSigningAsync.js');
34
- const certificateInput = (0, args_1.requireArg)(args, '--certificate-input-directory');
35
- const keyInput = (0, args_1.requireArg)(args, '--key-input-directory');
36
- const keyid = args['--keyid'];
37
- return await configureCodeSigningAsync((0, args_1.getProjectRoot)(args), {
38
- certificateInput,
39
- keyInput,
40
- keyid,
41
- });
42
- };
43
- exports.configureCodeSigning = configureCodeSigning;
@@ -1,7 +0,0 @@
1
- type Options = {
2
- certificateInput: string;
3
- keyInput: string;
4
- keyid: string | undefined;
5
- };
6
- export declare function configureCodeSigningAsync(projectRoot: string, { certificateInput, keyInput, keyid }: Options): Promise<void>;
7
- export {};
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.configureCodeSigningAsync = void 0;
4
- const tslib_1 = require("tslib");
5
- const code_signing_certificates_1 = require("@expo/code-signing-certificates");
6
- const config_1 = require("@expo/config");
7
- const fs_1 = require("fs");
8
- const path_1 = tslib_1.__importDefault(require("path"));
9
- const log_1 = require("./utils/log");
10
- const modifyConfigAsync_1 = require("./utils/modifyConfigAsync");
11
- async function configureCodeSigningAsync(projectRoot, { certificateInput, keyInput, keyid }) {
12
- const certificateInputDir = path_1.default.resolve(projectRoot, certificateInput);
13
- const keyInputDir = path_1.default.resolve(projectRoot, keyInput);
14
- const [certificatePEM, privateKeyPEM, publicKeyPEM] = await Promise.all([
15
- fs_1.promises.readFile(path_1.default.join(certificateInputDir, 'certificate.pem'), 'utf8'),
16
- fs_1.promises.readFile(path_1.default.join(keyInputDir, 'private-key.pem'), 'utf8'),
17
- fs_1.promises.readFile(path_1.default.join(keyInputDir, 'public-key.pem'), 'utf8'),
18
- ]);
19
- const certificate = (0, code_signing_certificates_1.convertCertificatePEMToCertificate)(certificatePEM);
20
- const keyPair = (0, code_signing_certificates_1.convertKeyPairPEMToKeyPair)({ privateKeyPEM, publicKeyPEM });
21
- (0, code_signing_certificates_1.validateSelfSignedCertificate)(certificate, keyPair);
22
- const { exp } = (0, config_1.getConfig)(projectRoot, { skipSDKVersionRequirement: true });
23
- const fields = {
24
- codeSigningCertificate: `./${path_1.default.relative(projectRoot, certificateInputDir)}/certificate.pem`,
25
- codeSigningMetadata: {
26
- keyid: keyid !== null && keyid !== void 0 ? keyid : 'main',
27
- alg: 'rsa-v1_5-sha256',
28
- },
29
- };
30
- await (0, modifyConfigAsync_1.attemptModification)(projectRoot, {
31
- updates: {
32
- ...exp.updates,
33
- ...fields,
34
- },
35
- }, {
36
- updates: {
37
- ...fields,
38
- },
39
- });
40
- (0, log_1.log)(`Code signing configuration written to app configuration.`);
41
- }
42
- exports.configureCodeSigningAsync = configureCodeSigningAsync;
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command } from './cli';
3
- export declare const generateCodeSigning: Command;
@@ -1,48 +0,0 @@
1
- #!/usr/bin/env node
2
- "use strict";
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.generateCodeSigning = void 0;
5
- const tslib_1 = require("tslib");
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const args_1 = require("./utils/args");
8
- const Log = tslib_1.__importStar(require("./utils/log"));
9
- const generateCodeSigning = async (argv) => {
10
- const args = (0, args_1.assertArgs)({
11
- // Types
12
- '--help': Boolean,
13
- '--key-output-directory': String,
14
- '--certificate-output-directory': String,
15
- '--certificate-validity-duration-years': Number,
16
- '--certificate-common-name': String,
17
- // Aliases
18
- '-h': '--help',
19
- }, argv !== null && argv !== void 0 ? argv : []);
20
- if (args['--help']) {
21
- Log.exit((0, chalk_1.default) `
22
- {bold Description}
23
- Generate expo-updates private key, public key, and code signing certificate using that public key (self-signed by the private key)
24
-
25
- {bold Usage}
26
- {dim $} npx expo-updates codesigning:generate --key-output-directory <dir> --certificate-output-directory <dir> --certificate-validity-duration-years <num years> --certificate-common-name <name>
27
-
28
- Options
29
- --key-output-directory <string> Directory in which to put the generated private and public keys
30
- --certificate-output-directory <string> Directory in which to put the generated certificate
31
- --certificate-validity-duration-years <number> Certificate validity duration in years (number of years before certificate needs rotation)
32
- --certificate-common-name <string> Common name attribute for certificate (generally the human readable name of the organization owning this application)
33
- -h, --help Output usage information
34
- `, 0);
35
- }
36
- const { generateCodeSigningAsync } = await import('./generateCodeSigningAsync.js');
37
- const keyOutput = (0, args_1.requireArg)(args, '--key-output-directory');
38
- const certificateOutput = (0, args_1.requireArg)(args, '--certificate-output-directory');
39
- const certificateValidityDurationYears = (0, args_1.requireArg)(args, '--certificate-validity-duration-years');
40
- const certificateCommonName = (0, args_1.requireArg)(args, '--certificate-common-name');
41
- return await generateCodeSigningAsync((0, args_1.getProjectRoot)(args), {
42
- certificateValidityDurationYears,
43
- keyOutput,
44
- certificateOutput,
45
- certificateCommonName,
46
- });
47
- };
48
- exports.generateCodeSigning = generateCodeSigning;
@@ -1,8 +0,0 @@
1
- type Options = {
2
- certificateValidityDurationYears: number;
3
- keyOutput: string;
4
- certificateOutput: string;
5
- certificateCommonName: string;
6
- };
7
- export declare function generateCodeSigningAsync(projectRoot: string, { certificateValidityDurationYears, keyOutput, certificateOutput, certificateCommonName }: Options): Promise<void>;
8
- export {};
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateCodeSigningAsync = void 0;
4
- const tslib_1 = require("tslib");
5
- const code_signing_certificates_1 = require("@expo/code-signing-certificates");
6
- const assert_1 = tslib_1.__importDefault(require("assert"));
7
- const fs_1 = require("fs");
8
- const path_1 = tslib_1.__importDefault(require("path"));
9
- const dir_1 = require("./utils/dir");
10
- const log_1 = require("./utils/log");
11
- async function generateCodeSigningAsync(projectRoot, { certificateValidityDurationYears, keyOutput, certificateOutput, certificateCommonName }) {
12
- const validityDurationYears = Math.floor(certificateValidityDurationYears);
13
- const certificateOutputDir = path_1.default.resolve(projectRoot, certificateOutput);
14
- const keyOutputDir = path_1.default.resolve(projectRoot, keyOutput);
15
- await Promise.all([(0, dir_1.ensureDirAsync)(certificateOutputDir), (0, dir_1.ensureDirAsync)(keyOutputDir)]);
16
- const [certificateOutputDirContents, keyOutputDirContents] = await Promise.all([
17
- fs_1.promises.readdir(certificateOutputDir),
18
- fs_1.promises.readdir(keyOutputDir),
19
- ]);
20
- (0, assert_1.default)(certificateOutputDirContents.length === 0, 'Certificate output directory must be empty');
21
- (0, assert_1.default)(keyOutputDirContents.length === 0, 'Key output directory must be empty');
22
- const keyPair = (0, code_signing_certificates_1.generateKeyPair)();
23
- const validityNotBefore = new Date();
24
- const validityNotAfter = new Date();
25
- validityNotAfter.setFullYear(validityNotAfter.getFullYear() + validityDurationYears);
26
- const certificate = (0, code_signing_certificates_1.generateSelfSignedCodeSigningCertificate)({
27
- keyPair,
28
- validityNotBefore,
29
- validityNotAfter,
30
- commonName: certificateCommonName,
31
- });
32
- const keyPairPEM = (0, code_signing_certificates_1.convertKeyPairToPEM)(keyPair);
33
- const certificatePEM = (0, code_signing_certificates_1.convertCertificateToCertificatePEM)(certificate);
34
- await Promise.all([
35
- fs_1.promises.writeFile(path_1.default.join(keyOutputDir, 'public-key.pem'), keyPairPEM.publicKeyPEM),
36
- fs_1.promises.writeFile(path_1.default.join(keyOutputDir, 'private-key.pem'), keyPairPEM.privateKeyPEM),
37
- fs_1.promises.writeFile(path_1.default.join(certificateOutputDir, 'certificate.pem'), certificatePEM),
38
- ]);
39
- (0, log_1.log)(`Generated public and private keys output in ${keyOutputDir}. Remember to add them to .gitignore or to encrypt them. (e.g. with git-crypt)`);
40
- (0, log_1.log)(`Generated code signing certificate output in ${certificateOutputDir}.`);
41
- (0, log_1.log)(`To automatically configure this project for code signing, run \`yarn expo-updates codesigning:configure --certificate-input-directory=${certificateOutput} --key-input-directory=${keyOutput}\`.`);
42
- }
43
- exports.generateCodeSigningAsync = generateCodeSigningAsync;
@@ -1,16 +0,0 @@
1
- import arg from 'arg';
2
- /**
3
- * Parse the first argument as a project directory.
4
- *
5
- * @returns valid project directory.
6
- */
7
- export declare function getProjectRoot(args: arg.Result<arg.Spec>): string;
8
- /**
9
- * Parse args and assert unknown options.
10
- *
11
- * @param schema the `args` schema for parsing the command line arguments.
12
- * @param argv extra strings
13
- * @returns processed args object.
14
- */
15
- export declare function assertArgs(schema: arg.Spec, argv: string[]): arg.Result<arg.Spec>;
16
- export declare function requireArg(args: arg.Result<arg.Spec>, name: any): any;
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requireArg = exports.assertArgs = exports.getProjectRoot = void 0;
4
- const tslib_1 = require("tslib");
5
- // Common utilities for interacting with `args` library.
6
- // These functions should be used by every command.
7
- const arg_1 = tslib_1.__importDefault(require("arg"));
8
- const fs_1 = require("fs");
9
- const path_1 = require("path");
10
- const Log = tslib_1.__importStar(require("./log"));
11
- /**
12
- * Parse the first argument as a project directory.
13
- *
14
- * @returns valid project directory.
15
- */
16
- function getProjectRoot(args) {
17
- const projectRoot = (0, path_1.resolve)(args._[0] || '.');
18
- if (!(0, fs_1.existsSync)(projectRoot)) {
19
- Log.exit(`Invalid project root: ${projectRoot}`);
20
- }
21
- return projectRoot;
22
- }
23
- exports.getProjectRoot = getProjectRoot;
24
- /**
25
- * Parse args and assert unknown options.
26
- *
27
- * @param schema the `args` schema for parsing the command line arguments.
28
- * @param argv extra strings
29
- * @returns processed args object.
30
- */
31
- function assertArgs(schema, argv) {
32
- try {
33
- return (0, arg_1.default)(schema, { argv });
34
- }
35
- catch (error) {
36
- // Ensure unknown options are handled the same way.
37
- if (error.code === 'ARG_UNKNOWN_OPTION') {
38
- Log.exit(error.message, 1);
39
- }
40
- // Otherwise rethrow the error.
41
- throw error;
42
- }
43
- }
44
- exports.assertArgs = assertArgs;
45
- function requireArg(args, name) {
46
- const value = args[name];
47
- if (value === undefined || value === null) {
48
- Log.exit(`${name} must be provided`, 1);
49
- }
50
- return value;
51
- }
52
- exports.requireArg = requireArg;
@@ -1 +0,0 @@
1
- export declare function ensureDirAsync(path: string): Promise<string | undefined>;
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ensureDirAsync = void 0;
4
- const fs_1 = require("fs");
5
- function ensureDirAsync(path) {
6
- return fs_1.promises.mkdir(path, { recursive: true });
7
- }
8
- exports.ensureDirAsync = ensureDirAsync;
@@ -1,7 +0,0 @@
1
- export declare function time(label?: string): void;
2
- export declare function timeEnd(label?: string): void;
3
- export declare function error(...message: string[]): void;
4
- export declare function warn(...message: string[]): void;
5
- export declare function log(...message: string[]): void;
6
- /** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */
7
- export declare function exit(message: string, code?: number): never;
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.exit = exports.log = exports.warn = exports.error = exports.timeEnd = exports.time = void 0;
4
- function time(label) {
5
- console.time(label);
6
- }
7
- exports.time = time;
8
- function timeEnd(label) {
9
- console.timeEnd(label);
10
- }
11
- exports.timeEnd = timeEnd;
12
- function error(...message) {
13
- console.error(...message);
14
- }
15
- exports.error = error;
16
- function warn(...message) {
17
- console.warn(...message);
18
- }
19
- exports.warn = warn;
20
- function log(...message) {
21
- console.log(...message);
22
- }
23
- exports.log = log;
24
- /** Log a message and exit the current process. If the `code` is non-zero then `console.error` will be used instead of `console.log`. */
25
- function exit(message, code = 1) {
26
- if (code === 0) {
27
- log(message);
28
- }
29
- else {
30
- error(message);
31
- }
32
- process.exit(code);
33
- }
34
- exports.exit = exit;
@@ -1,3 +0,0 @@
1
- import { ExpoConfig } from '@expo/config';
2
- /** Wraps `[@expo/config] modifyConfigAsync()` and adds additional logging. */
3
- export declare function attemptModification(projectRoot: string, edits: Partial<ExpoConfig>, exactEdits: Partial<ExpoConfig>): Promise<void>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.attemptModification = void 0;
4
- const tslib_1 = require("tslib");
5
- const config_1 = require("@expo/config");
6
- const chalk_1 = tslib_1.__importDefault(require("chalk"));
7
- const Log = tslib_1.__importStar(require("./log"));
8
- /** Wraps `[@expo/config] modifyConfigAsync()` and adds additional logging. */
9
- async function attemptModification(projectRoot, edits, exactEdits) {
10
- const modification = await (0, config_1.modifyConfigAsync)(projectRoot, edits, {
11
- skipSDKVersionRequirement: true,
12
- });
13
- if (modification.type === 'success') {
14
- Log.log();
15
- }
16
- else {
17
- warnAboutConfigAndThrow(modification.type, modification.message, exactEdits);
18
- }
19
- }
20
- exports.attemptModification = attemptModification;
21
- function logNoConfig() {
22
- Log.log(chalk_1.default.yellow(`No Expo config was found. Please create an Expo config (${chalk_1.default.bold `app.json`} or ${chalk_1.default.bold `app.config.js`}) in your project root.`));
23
- }
24
- function warnAboutConfigAndThrow(type, message, edits) {
25
- Log.log();
26
- if (type === 'warn') {
27
- // The project is using a dynamic config, give the user a helpful log and bail out.
28
- Log.log(chalk_1.default.yellow(message));
29
- }
30
- else {
31
- logNoConfig();
32
- }
33
- notifyAboutManualConfigEdits(edits);
34
- throw new Error();
35
- }
36
- function notifyAboutManualConfigEdits(edits) {
37
- Log.log(chalk_1.default.cyan(`Please add the following to your Expo config`));
38
- Log.log();
39
- Log.log(JSON.stringify(edits, null, 2));
40
- Log.log();
41
- }