create-expo 5.1.3 → 5.1.5
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/build/589.index.js +93 -12
- package/build/Examples.d.ts +3 -1
- package/build/Template.d.ts +10 -2
- package/build/__tests__/swiftPMSupport.test.d.ts +1 -0
- package/build/createAsync.d.ts +3 -1
- package/build/error.d.ts +7 -0
- package/build/index.js +5 -5
- package/package.json +9 -10
package/build/589.index.js
CHANGED
|
@@ -14,6 +14,9 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
14
14
|
|
|
15
15
|
// UNUSED EXPORTS: logNodeInstallWarning, setupDependenciesAsync
|
|
16
16
|
|
|
17
|
+
// EXTERNAL MODULE: ../../node_modules/.pnpm/@expo+spawn-async@1.8.0/node_modules/@expo/spawn-async/build/spawnAsync.js
|
|
18
|
+
var spawnAsync = __webpack_require__(3970);
|
|
19
|
+
var spawnAsync_default = /*#__PURE__*/__webpack_require__.n(spawnAsync);
|
|
17
20
|
// EXTERNAL MODULE: ../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js
|
|
18
21
|
var source = __webpack_require__(2314);
|
|
19
22
|
var source_default = /*#__PURE__*/__webpack_require__.n(source);
|
|
@@ -179,6 +182,8 @@ function createGlobFilter(globPattern, options) {
|
|
|
179
182
|
};
|
|
180
183
|
}
|
|
181
184
|
|
|
185
|
+
// EXTERNAL MODULE: ./src/error.ts
|
|
186
|
+
var src_error = __webpack_require__(6725);
|
|
182
187
|
// EXTERNAL MODULE: ./src/resolvePackageManager.ts
|
|
183
188
|
var resolvePackageManager = __webpack_require__(9560);
|
|
184
189
|
// EXTERNAL MODULE: ./src/utils/env.ts
|
|
@@ -205,9 +210,6 @@ function wrapFetchWithAssert(fetchFunction) {
|
|
|
205
210
|
/** Export a fetch method that ensures fetch is available */
|
|
206
211
|
const fetch_fetch = wrapFetchWithAssert(globalThis.fetch);
|
|
207
212
|
|
|
208
|
-
// EXTERNAL MODULE: ../../node_modules/.pnpm/@expo+spawn-async@1.8.0/node_modules/@expo/spawn-async/build/spawnAsync.js
|
|
209
|
-
var spawnAsync = __webpack_require__(3970);
|
|
210
|
-
var spawnAsync_default = /*#__PURE__*/__webpack_require__.n(spawnAsync);
|
|
211
213
|
// EXTERNAL MODULE: external "os"
|
|
212
214
|
var external_os_ = __webpack_require__(857);
|
|
213
215
|
var external_os_default = /*#__PURE__*/__webpack_require__.n(external_os_);
|
|
@@ -694,6 +696,7 @@ async function downloadAndExtractGitHubRepositoryAsync(repoUrl, output, props) {
|
|
|
694
696
|
|
|
695
697
|
|
|
696
698
|
|
|
699
|
+
|
|
697
700
|
const Template_debug = __webpack_require__(6675)('expo:init:template');
|
|
698
701
|
const isMacOS = process.platform === 'darwin';
|
|
699
702
|
// keep this list in sync with the validation helper in WWW: src/utils/experienceParser.ts
|
|
@@ -784,7 +787,7 @@ function resolvePackageModuleId(moduleId) {
|
|
|
784
787
|
* find-and-replace pass. The config file is read once and deleted from disk
|
|
785
788
|
* immediately so it can never leak into the user's project.
|
|
786
789
|
*/
|
|
787
|
-
async function extractAndPrepareTemplateAppAsync(projectRoot, { npmPackage }) {
|
|
790
|
+
async function extractAndPrepareTemplateAppAsync(projectRoot, { npmPackage, swiftpm }) {
|
|
788
791
|
const projectName = external_path_default().basename(projectRoot);
|
|
789
792
|
Template_debug(`Extracting template app (pkg: ${npmPackage}, projectName: ${projectName})`);
|
|
790
793
|
const { type, uri } = resolvePackageModuleId(npmPackage || 'expo-template-default');
|
|
@@ -800,6 +803,9 @@ async function extractAndPrepareTemplateAppAsync(projectRoot, { npmPackage }) {
|
|
|
800
803
|
disableCache: type === 'file',
|
|
801
804
|
});
|
|
802
805
|
}
|
|
806
|
+
if (swiftpm) {
|
|
807
|
+
await assertSwiftPMSupportedAsync(projectRoot, 'template');
|
|
808
|
+
}
|
|
803
809
|
const monorepoConfig = await consumeMonorepoConfigAsync(projectRoot);
|
|
804
810
|
try {
|
|
805
811
|
const files = await getTemplateFilesToRenameAsync({
|
|
@@ -816,7 +822,7 @@ async function extractAndPrepareTemplateAppAsync(projectRoot, { npmPackage }) {
|
|
|
816
822
|
log/* Log */.tG.error('Error renaming app name in template');
|
|
817
823
|
throw error;
|
|
818
824
|
}
|
|
819
|
-
await sanitizeTemplateAsync(projectRoot);
|
|
825
|
+
await sanitizeTemplateAsync(projectRoot, { swiftpm });
|
|
820
826
|
return projectRoot;
|
|
821
827
|
}
|
|
822
828
|
// Android resource XML (strings.xml): aapt2 resolves XML entities before its
|
|
@@ -990,10 +996,28 @@ async function renameTemplateAppNameAsync({ cwd, name, files, }) {
|
|
|
990
996
|
function templateHasNativeCode(root) {
|
|
991
997
|
return [external_path_default().join(root, 'android'), external_path_default().join(root, 'ios')].some((folder) => external_fs_default().existsSync(folder));
|
|
992
998
|
}
|
|
999
|
+
/**
|
|
1000
|
+
* Throw a `SwiftPMUnsupportedError` when the extracted project depends on a React Native version
|
|
1001
|
+
* older than 0.88. Versions that cannot be read here are left for `expo prebuild` to reject.
|
|
1002
|
+
*/
|
|
1003
|
+
async function assertSwiftPMSupportedAsync(projectRoot, source) {
|
|
1004
|
+
const packageJsonPath = external_path_default().join(projectRoot, 'package.json');
|
|
1005
|
+
if (!external_fs_default().existsSync(packageJsonPath)) {
|
|
1006
|
+
return;
|
|
1007
|
+
}
|
|
1008
|
+
const { dependencies } = await JsonFile["default"].readAsync(packageJsonPath);
|
|
1009
|
+
const reactNativeVersion = dependencies?.['react-native'];
|
|
1010
|
+
const [, major, minor] = reactNativeVersion?.match(/(\d+)\.(\d+)/) ?? [];
|
|
1011
|
+
// Nightlies are versioned `0.0.0-<date>-<sha>`, so a minor of 0 is not an old release.
|
|
1012
|
+
if (reactNativeVersion && Number(major) === 0 && Number(minor) >= 1 && Number(minor) < 88) {
|
|
1013
|
+
const projectDir = external_path_default().relative(process.cwd(), projectRoot) || external_path_default().basename(projectRoot);
|
|
1014
|
+
throw new src_error/* SwiftPMUnsupportedError */.u(source, reactNativeVersion, projectDir);
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
993
1017
|
/**
|
|
994
1018
|
* Sanitize a template (or example) with expected `package.json` properties and files.
|
|
995
1019
|
*/
|
|
996
|
-
async function sanitizeTemplateAsync(projectRoot) {
|
|
1020
|
+
async function sanitizeTemplateAsync(projectRoot, { swiftpm = false } = {}) {
|
|
997
1021
|
const projectName = external_path_default().basename(projectRoot);
|
|
998
1022
|
Template_debug(`Sanitizing template or example app (projectName: ${projectName})`);
|
|
999
1023
|
const templatePath = __webpack_require__.ab + "gitignore";
|
|
@@ -1015,9 +1039,11 @@ async function sanitizeTemplateAsync(projectRoot) {
|
|
|
1015
1039
|
nativeFoldersIgnored = false;
|
|
1016
1040
|
}
|
|
1017
1041
|
}
|
|
1042
|
+
// `experiments.swiftPackageManager` is not in the generated ExpoConfig schema yet.
|
|
1018
1043
|
const defaultConfig = {
|
|
1019
1044
|
name: projectName,
|
|
1020
1045
|
slug: projectName,
|
|
1046
|
+
...(swiftpm && { experiments: { swiftPackageManager: true } }),
|
|
1021
1047
|
};
|
|
1022
1048
|
const appFile = new JsonFile["default"](external_path_default().join(projectRoot, 'app.json'), {
|
|
1023
1049
|
default: {},
|
|
@@ -1235,7 +1261,7 @@ async function promptExamplesAsync() {
|
|
|
1235
1261
|
* find-and-replace pass. The config file is read once and deleted from disk
|
|
1236
1262
|
* immediately so it can never leak into the user's project.
|
|
1237
1263
|
*/
|
|
1238
|
-
async function downloadAndExtractExampleAsync(root, name) {
|
|
1264
|
+
async function downloadAndExtractExampleAsync(root, name, { swiftpm } = {}) {
|
|
1239
1265
|
const projectName = external_path_default().basename(root);
|
|
1240
1266
|
const response = await fetch_fetch('https://codeload.github.com/expo/examples/tar.gz/master');
|
|
1241
1267
|
if (!response.ok) {
|
|
@@ -1252,6 +1278,9 @@ async function downloadAndExtractExampleAsync(root, name) {
|
|
|
1252
1278
|
strip: 2,
|
|
1253
1279
|
filter: (entryName) => entryName.startsWith(prefix),
|
|
1254
1280
|
});
|
|
1281
|
+
if (swiftpm) {
|
|
1282
|
+
await assertSwiftPMSupportedAsync(root, 'example');
|
|
1283
|
+
}
|
|
1255
1284
|
const monorepoConfig = await consumeMonorepoConfigAsync(root);
|
|
1256
1285
|
const files = await getTemplateFilesToRenameAsync({
|
|
1257
1286
|
cwd: root,
|
|
@@ -1262,7 +1291,7 @@ async function downloadAndExtractExampleAsync(root, name) {
|
|
|
1262
1291
|
files,
|
|
1263
1292
|
name: projectName,
|
|
1264
1293
|
});
|
|
1265
|
-
await sanitizeTemplateAsync(root);
|
|
1294
|
+
await sanitizeTemplateAsync(root, { swiftpm });
|
|
1266
1295
|
await sanitizeScriptsAsync(root);
|
|
1267
1296
|
}
|
|
1268
1297
|
function exampleHasNativeCode(root) {
|
|
@@ -1902,6 +1931,10 @@ function withSectionLog(action, message) {
|
|
|
1902
1931
|
|
|
1903
1932
|
|
|
1904
1933
|
|
|
1934
|
+
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
const SWIFTPM_PREBUILD_ARGS = ['expo', 'prebuild', '--platform', 'ios'];
|
|
1905
1938
|
const createAsync_debug = __webpack_require__(6675)('expo:init:create');
|
|
1906
1939
|
async function resolveProjectRootArgAsync(inputPath, { yes }) {
|
|
1907
1940
|
if (!inputPath && yes) {
|
|
@@ -1927,12 +1960,18 @@ async function setupDependenciesAsync(projectRoot, props) {
|
|
|
1927
1960
|
// Install dependencies
|
|
1928
1961
|
let podsInstalled = false;
|
|
1929
1962
|
let nodeModulesInstalled = false;
|
|
1930
|
-
const needsPodsInstalled =
|
|
1963
|
+
const needsPodsInstalled = !props.swiftpm && external_fs_default().existsSync(external_path_default().join(projectRoot, 'ios'));
|
|
1964
|
+
let swiftPMSetUp = false;
|
|
1931
1965
|
if (shouldInstall) {
|
|
1932
1966
|
nodeModulesInstalled = await installNodeDependenciesAsync(projectRoot, packageManager);
|
|
1933
1967
|
if (needsPodsInstalled) {
|
|
1934
1968
|
podsInstalled = await installCocoaPodsAsync(projectRoot);
|
|
1935
1969
|
}
|
|
1970
|
+
// Prebuild runs from the project's node modules, and SwiftPM needs Xcode, so like
|
|
1971
|
+
// CocoaPods this is skipped outside macOS.
|
|
1972
|
+
if (props.swiftpm && nodeModulesInstalled && process.platform === 'darwin') {
|
|
1973
|
+
swiftPMSetUp = await runSwiftPMSetupAsync(projectRoot);
|
|
1974
|
+
}
|
|
1936
1975
|
}
|
|
1937
1976
|
const cdPath = getChangeDirectoryPath(projectRoot);
|
|
1938
1977
|
console.log();
|
|
@@ -1941,6 +1980,30 @@ async function setupDependenciesAsync(projectRoot, props) {
|
|
|
1941
1980
|
if (!nodeModulesInstalled) {
|
|
1942
1981
|
logNodeInstallWarning(cdPath, packageManager, needsPodsInstalled && !podsInstalled);
|
|
1943
1982
|
}
|
|
1983
|
+
if (props.swiftpm) {
|
|
1984
|
+
logSwiftPMWarning(cdPath, swiftPMSetUp);
|
|
1985
|
+
}
|
|
1986
|
+
}
|
|
1987
|
+
async function runSwiftPMSetupAsync(projectRoot) {
|
|
1988
|
+
try {
|
|
1989
|
+
await withSectionLog(async () => {
|
|
1990
|
+
await spawnAsync_default()('npx', SWIFTPM_PREBUILD_ARGS, {
|
|
1991
|
+
cwd: projectRoot,
|
|
1992
|
+
stdio: env.env.EXPO_DEBUG ? 'inherit' : 'pipe',
|
|
1993
|
+
});
|
|
1994
|
+
}, {
|
|
1995
|
+
pending: source_default().bold('Setting up Swift Package Manager for iOS.'),
|
|
1996
|
+
success: 'Set up Swift Package Manager for iOS.',
|
|
1997
|
+
error: () => 'Setting up Swift Package Manager for iOS failed. The app is still created. Run the command below to finish the setup.',
|
|
1998
|
+
});
|
|
1999
|
+
return true;
|
|
2000
|
+
}
|
|
2001
|
+
catch (error) {
|
|
2002
|
+
createAsync_debug('Error setting up Swift Package Manager: %O', error);
|
|
2003
|
+
const { stderr } = error;
|
|
2004
|
+
log/* Log */.tG.error(stderr || source_default().red(error.message));
|
|
2005
|
+
return false;
|
|
2006
|
+
}
|
|
1944
2007
|
}
|
|
1945
2008
|
async function createAsync(inputPath, options) {
|
|
1946
2009
|
if (options.example && options.template) {
|
|
@@ -1979,11 +2042,12 @@ async function createTemplateAsync(inputPath, props) {
|
|
|
1979
2042
|
await withSectionLog(async () => {
|
|
1980
2043
|
await extractAndPrepareTemplateAppAsync(projectRoot, {
|
|
1981
2044
|
npmPackage: resolvedTemplate,
|
|
2045
|
+
swiftpm: props.swiftpm,
|
|
1982
2046
|
});
|
|
1983
2047
|
}, {
|
|
1984
2048
|
pending: source_default().bold('Locating project files.'),
|
|
1985
2049
|
success: 'Downloaded and extracted project files.',
|
|
1986
|
-
error: (error) =>
|
|
2050
|
+
error: (error) => formatExtractionError(error, 'project'),
|
|
1987
2051
|
});
|
|
1988
2052
|
await setupDependenciesAsync(projectRoot, props);
|
|
1989
2053
|
if (props.agentsMd) {
|
|
@@ -2055,11 +2119,13 @@ async function createExampleAsync(inputPath, props) {
|
|
|
2055
2119
|
properties: { phase: telemetry.AnalyticsEventPhases.ATTEMPT, example: resolvedExample },
|
|
2056
2120
|
});
|
|
2057
2121
|
await withSectionLog(async () => {
|
|
2058
|
-
await downloadAndExtractExampleAsync(projectRoot, resolvedExample
|
|
2122
|
+
await downloadAndExtractExampleAsync(projectRoot, resolvedExample, {
|
|
2123
|
+
swiftpm: props.swiftpm,
|
|
2124
|
+
});
|
|
2059
2125
|
}, {
|
|
2060
2126
|
pending: source_default().bold('Locating example files...'),
|
|
2061
2127
|
success: 'Downloaded and extracted example files.',
|
|
2062
|
-
error: (error) =>
|
|
2128
|
+
error: (error) => formatExtractionError(error, 'example'),
|
|
2063
2129
|
});
|
|
2064
2130
|
await setupDependenciesAsync(projectRoot, props);
|
|
2065
2131
|
if (props.agentsMd) {
|
|
@@ -2079,6 +2145,12 @@ async function createExampleAsync(inputPath, props) {
|
|
|
2079
2145
|
// todo: check if git is installed, bail out
|
|
2080
2146
|
}
|
|
2081
2147
|
}
|
|
2148
|
+
function formatExtractionError(error, files) {
|
|
2149
|
+
if (error instanceof src_error/* SwiftPMUnsupportedError */.u) {
|
|
2150
|
+
return error.message;
|
|
2151
|
+
}
|
|
2152
|
+
return `Something went wrong in downloading and extracting the ${files} files: ${error.message}`;
|
|
2153
|
+
}
|
|
2082
2154
|
function getChangeDirectoryPath(projectRoot) {
|
|
2083
2155
|
const cdPath = external_path_default().relative(process.cwd(), projectRoot);
|
|
2084
2156
|
if (cdPath.length <= projectRoot.length) {
|
|
@@ -2128,6 +2200,15 @@ function logNodeInstallWarning(cdPath, packageManager, needsPods) {
|
|
|
2128
2200
|
}
|
|
2129
2201
|
console.log();
|
|
2130
2202
|
}
|
|
2203
|
+
function logSwiftPMWarning(cdPath, isSetUp) {
|
|
2204
|
+
console.log(`\n⚠️ This project uses Swift Package Manager for iOS instead of CocoaPods. This is a preview, enabled by \`experiments.swiftPackageManager\` in app.json. Do not run \`pod install\` in this project.\n`);
|
|
2205
|
+
if (!isSetUp) {
|
|
2206
|
+
console.log(`To finish setting up iOS, run:\n`);
|
|
2207
|
+
console.log(` cd ${cdPath || '.'}${(external_path_default()).sep}`);
|
|
2208
|
+
console.log(` npx ${SWIFTPM_PREBUILD_ARGS.join(' ')}`);
|
|
2209
|
+
console.log();
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2131
2212
|
function getDeprecatedExampleErrorMessage(example, metadata) {
|
|
2132
2213
|
const { message, outdatedExampleHref } = metadata.deprecated[example] ?? {};
|
|
2133
2214
|
let output = `${example} is no longer available.`;
|
package/build/Examples.d.ts
CHANGED
|
@@ -34,5 +34,7 @@ export declare function promptExamplesAsync(): Promise<any>;
|
|
|
34
34
|
* find-and-replace pass. The config file is read once and deleted from disk
|
|
35
35
|
* immediately so it can never leak into the user's project.
|
|
36
36
|
*/
|
|
37
|
-
export declare function downloadAndExtractExampleAsync(root: string, name: string
|
|
37
|
+
export declare function downloadAndExtractExampleAsync(root: string, name: string, { swiftpm }?: {
|
|
38
|
+
swiftpm?: boolean;
|
|
39
|
+
}): Promise<void>;
|
|
38
40
|
export declare function sanitizeScriptsAsync(root: string): Promise<void>;
|
package/build/Template.d.ts
CHANGED
|
@@ -20,8 +20,9 @@ export declare function resolvePackageModuleId(moduleId: string): {
|
|
|
20
20
|
* find-and-replace pass. The config file is read once and deleted from disk
|
|
21
21
|
* immediately so it can never leak into the user's project.
|
|
22
22
|
*/
|
|
23
|
-
export declare function extractAndPrepareTemplateAppAsync(projectRoot: string, { npmPackage }: {
|
|
23
|
+
export declare function extractAndPrepareTemplateAppAsync(projectRoot: string, { npmPackage, swiftpm }: {
|
|
24
24
|
npmPackage?: string | null;
|
|
25
|
+
swiftpm?: boolean;
|
|
25
26
|
}): Promise<string>;
|
|
26
27
|
/**
|
|
27
28
|
* # Background
|
|
@@ -96,10 +97,17 @@ export declare function renameTemplateAppNameAsync({ cwd, name, files, }: {
|
|
|
96
97
|
*/
|
|
97
98
|
files: string[];
|
|
98
99
|
}): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Throw a `SwiftPMUnsupportedError` when the extracted project depends on a React Native version
|
|
102
|
+
* older than 0.88. Versions that cannot be read here are left for `expo prebuild` to reject.
|
|
103
|
+
*/
|
|
104
|
+
export declare function assertSwiftPMSupportedAsync(projectRoot: string, source: 'template' | 'example'): Promise<void>;
|
|
99
105
|
/**
|
|
100
106
|
* Sanitize a template (or example) with expected `package.json` properties and files.
|
|
101
107
|
*/
|
|
102
|
-
export declare function sanitizeTemplateAsync(projectRoot: string
|
|
108
|
+
export declare function sanitizeTemplateAsync(projectRoot: string, { swiftpm }?: {
|
|
109
|
+
swiftpm?: boolean;
|
|
110
|
+
}): Promise<void>;
|
|
103
111
|
export declare function validateName(name?: string): string | true;
|
|
104
112
|
export declare function logProjectReady({ cdPath, packageManager, }: {
|
|
105
113
|
cdPath: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/createAsync.d.ts
CHANGED
|
@@ -5,7 +5,9 @@ export type Options = {
|
|
|
5
5
|
example?: string | true;
|
|
6
6
|
yes: boolean;
|
|
7
7
|
agentsMd: boolean;
|
|
8
|
+
/** Set up iOS with Swift Package Manager instead of CocoaPods (preview). */
|
|
9
|
+
swiftpm?: boolean;
|
|
8
10
|
};
|
|
9
|
-
export declare function setupDependenciesAsync(projectRoot: string, props: Pick<Options, 'install'>): Promise<void>;
|
|
11
|
+
export declare function setupDependenciesAsync(projectRoot: string, props: Pick<Options, 'install' | 'swiftpm'>): Promise<void>;
|
|
10
12
|
export declare function createAsync(inputPath: string, options: Options): Promise<void>;
|
|
11
13
|
export declare function logNodeInstallWarning(cdPath: string, packageManager: PackageManagerName, needsPods: boolean): void;
|
package/build/error.d.ts
CHANGED
|
@@ -7,3 +7,10 @@ export declare class ExitError extends Error {
|
|
|
7
7
|
code: number;
|
|
8
8
|
constructor(cause: string | Error, code: number);
|
|
9
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Thrown when `--swiftpm` is used with a template or example whose React Native version cannot
|
|
12
|
+
* build with Swift Package Manager. The section log prints the message, so it is an `ExitError`.
|
|
13
|
+
*/
|
|
14
|
+
export declare class SwiftPMUnsupportedError extends ExitError {
|
|
15
|
+
constructor(source: 'template' | 'example', reactNativeVersion: string, projectDir: string);
|
|
16
|
+
}
|