create-expo 5.1.4 → 5.1.6
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 → 536.index.js} +194 -210
- 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 +4 -4
- package/build/resolveExpoVersions.d.ts +9 -0
- package/build/resolveTemplate.d.ts +12 -0
- package/package.json +8 -8
- package/build/promptSdkVersion.d.ts +0 -23
- /package/build/__tests__/{promptSdkVersion.test.d.ts → resolveExpoVersions.d.ts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
exports.id =
|
|
3
|
-
exports.ids = [
|
|
2
|
+
exports.id = 536;
|
|
3
|
+
exports.ids = [536,601];
|
|
4
4
|
exports.modules = {
|
|
5
5
|
|
|
6
|
-
/***/
|
|
6
|
+
/***/ 2536:
|
|
7
7
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
8
8
|
|
|
9
9
|
|
|
@@ -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) {
|
|
@@ -1513,175 +1542,6 @@ async function generateAgentFiles(root) {
|
|
|
1513
1542
|
await Promise.all(tasks);
|
|
1514
1543
|
}
|
|
1515
1544
|
|
|
1516
|
-
;// CONCATENATED MODULE: ./src/promptSdkVersion.ts
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
const promptSdkVersion_debug = __webpack_require__(6675)('expo:init:sdk');
|
|
1525
|
-
// SDKs without a `releaseNoteUrl` are canary/in-development. The top-level
|
|
1526
|
-
// `expoGoSdkVersion` reports the SDK currently shipping in store Expo Go and
|
|
1527
|
-
// is treated as optional — when absent, the "For learning with Expo Go" choice
|
|
1528
|
-
// is hidden.
|
|
1529
|
-
const VERSIONS_URL = 'https://api.expo.dev/v2/versions';
|
|
1530
|
-
async function fetchSdkVersionsAsync() {
|
|
1531
|
-
let json;
|
|
1532
|
-
try {
|
|
1533
|
-
const response = await fetch(VERSIONS_URL);
|
|
1534
|
-
if (!response.ok) {
|
|
1535
|
-
promptSdkVersion_debug(`versions endpoint returned ${response.status}`);
|
|
1536
|
-
return null;
|
|
1537
|
-
}
|
|
1538
|
-
json = (await response.json());
|
|
1539
|
-
}
|
|
1540
|
-
catch (error) {
|
|
1541
|
-
promptSdkVersion_debug('Failed to fetch versions endpoint:', error);
|
|
1542
|
-
return null;
|
|
1543
|
-
}
|
|
1544
|
-
const sdkVersions = json.sdkVersions ?? {};
|
|
1545
|
-
const available = Object.entries(sdkVersions)
|
|
1546
|
-
.filter(([, info]) => !!info.releaseNoteUrl && !info.isDeprecated)
|
|
1547
|
-
.map(([version]) => parseSdkMajor(version))
|
|
1548
|
-
.filter((major) => major != null)
|
|
1549
|
-
.sort((a, b) => b - a);
|
|
1550
|
-
const latest = available[0];
|
|
1551
|
-
if (latest == null) {
|
|
1552
|
-
return null;
|
|
1553
|
-
}
|
|
1554
|
-
return {
|
|
1555
|
-
latest,
|
|
1556
|
-
expoGoCompatible: parseSdkMajor(json.expoGoSdkVersion),
|
|
1557
|
-
available,
|
|
1558
|
-
};
|
|
1559
|
-
}
|
|
1560
|
-
function parseSdkMajor(version) {
|
|
1561
|
-
const major = parseInt(version?.split('.')[0] ?? '', 10);
|
|
1562
|
-
return Number.isFinite(major) ? major : null;
|
|
1563
|
-
}
|
|
1564
|
-
/**
|
|
1565
|
-
* If the resolved template is an Expo-published template without an explicit
|
|
1566
|
-
* SDK tag, prompt the user to pick which Expo SDK to use and return the
|
|
1567
|
-
* template name with the chosen SDK tag appended.
|
|
1568
|
-
*
|
|
1569
|
-
* Returns the template unchanged if the user is non-interactive, the template
|
|
1570
|
-
* already targets a specific version, or we can't reach the versions endpoint.
|
|
1571
|
-
*/
|
|
1572
|
-
async function applySdkVersionToTemplateAsync(template, { yes, showAlternatives = true, projectName, }) {
|
|
1573
|
-
if (env.env.EXPO_BETA) {
|
|
1574
|
-
logCreatingProject(template, projectName);
|
|
1575
|
-
return template;
|
|
1576
|
-
}
|
|
1577
|
-
const [name, tag] = splitNpmNameAndTag(template);
|
|
1578
|
-
if (tag) {
|
|
1579
|
-
logCreatingProject(template, projectName);
|
|
1580
|
-
return template;
|
|
1581
|
-
}
|
|
1582
|
-
if (!isKnownExpoTemplate(name)) {
|
|
1583
|
-
logCreatingProject(template, projectName);
|
|
1584
|
-
return template;
|
|
1585
|
-
}
|
|
1586
|
-
const nonInteractive = yes || env.env.CI || !process.stdin.isTTY;
|
|
1587
|
-
// Non-interactive + user explicitly chose a template: fall through to that
|
|
1588
|
-
// template's npm `latest` dist-tag. No need to fetch the versions endpoint.
|
|
1589
|
-
if (nonInteractive && !showAlternatives) {
|
|
1590
|
-
logCreatingProject(template, projectName);
|
|
1591
|
-
return template;
|
|
1592
|
-
}
|
|
1593
|
-
const versions = await fetchSdkVersionsAsync();
|
|
1594
|
-
if (!versions) {
|
|
1595
|
-
logCreatingProject(template, projectName);
|
|
1596
|
-
return template;
|
|
1597
|
-
}
|
|
1598
|
-
// Non-interactive + default template: pin to the actual latest released SDK.
|
|
1599
|
-
if (nonInteractive) {
|
|
1600
|
-
const pinned = `${name}@sdk-${versions.latest}`;
|
|
1601
|
-
logCreatingProject(pinned, projectName);
|
|
1602
|
-
return pinned;
|
|
1603
|
-
}
|
|
1604
|
-
const selectedSdk = await promptSdkVersionAsync(versions, name, showAlternatives, projectName);
|
|
1605
|
-
if (selectedSdk == null) {
|
|
1606
|
-
logCreatingProject(template, projectName);
|
|
1607
|
-
return template;
|
|
1608
|
-
}
|
|
1609
|
-
return `${name}@sdk-${selectedSdk}`;
|
|
1610
|
-
}
|
|
1611
|
-
function logCreatingProject(template, projectName) {
|
|
1612
|
-
const subject = projectName ? source_default().cyan(projectName) : 'a project';
|
|
1613
|
-
console.log(source_default() `Creating ${subject} using the {cyan ${template}} template.\n`);
|
|
1614
|
-
}
|
|
1615
|
-
function isKnownExpoTemplate(name) {
|
|
1616
|
-
if (ALIASES.includes(name)) {
|
|
1617
|
-
return true;
|
|
1618
|
-
}
|
|
1619
|
-
// Short aliases like `default` and `blank` are expanded to `expo-template-*` later.
|
|
1620
|
-
return ALIASES.includes(`expo-template-${name}`);
|
|
1621
|
-
}
|
|
1622
|
-
async function promptSdkVersionAsync(versions, templateName, showAlternatives, projectName) {
|
|
1623
|
-
const { latest, expoGoCompatible, available } = versions;
|
|
1624
|
-
const choices = [
|
|
1625
|
-
{
|
|
1626
|
-
title: `Latest (SDK ${latest})`,
|
|
1627
|
-
value: latest,
|
|
1628
|
-
description: 'Recommended for most projects',
|
|
1629
|
-
},
|
|
1630
|
-
];
|
|
1631
|
-
if (expoGoCompatible != null && expoGoCompatible !== latest) {
|
|
1632
|
-
choices.push({
|
|
1633
|
-
title: `For learning with Expo Go (SDK ${expoGoCompatible})`,
|
|
1634
|
-
value: expoGoCompatible,
|
|
1635
|
-
description: 'Compatible with Expo Go on App Store and Play Store',
|
|
1636
|
-
});
|
|
1637
|
-
}
|
|
1638
|
-
choices.push({ title: 'Other SDK version…', value: 'other' });
|
|
1639
|
-
const { answer } = await prompts_default()({
|
|
1640
|
-
type: 'select',
|
|
1641
|
-
name: 'answer',
|
|
1642
|
-
message: 'Select an Expo SDK version:',
|
|
1643
|
-
choices,
|
|
1644
|
-
});
|
|
1645
|
-
if (answer == null) {
|
|
1646
|
-
log/* Log */.tG.log();
|
|
1647
|
-
log/* Log */.tG.log(source_default() `Specify the SDK version, example: {cyan --template default@${latest}}`);
|
|
1648
|
-
process.exit(1);
|
|
1649
|
-
}
|
|
1650
|
-
let resolved;
|
|
1651
|
-
if (answer !== 'other') {
|
|
1652
|
-
resolved = answer;
|
|
1653
|
-
}
|
|
1654
|
-
else {
|
|
1655
|
-
const { sdkAnswer } = await prompts_default()({
|
|
1656
|
-
type: 'select',
|
|
1657
|
-
name: 'sdkAnswer',
|
|
1658
|
-
message: 'Select an SDK version:',
|
|
1659
|
-
choices: available.slice(0, 4).map((sdk) => ({
|
|
1660
|
-
title: `SDK ${sdk}`,
|
|
1661
|
-
value: sdk,
|
|
1662
|
-
})),
|
|
1663
|
-
});
|
|
1664
|
-
if (sdkAnswer == null) {
|
|
1665
|
-
log/* Log */.tG.log();
|
|
1666
|
-
log/* Log */.tG.log(source_default() `Specify the SDK version, example: {cyan --template default@${latest}}`);
|
|
1667
|
-
process.exit(1);
|
|
1668
|
-
}
|
|
1669
|
-
resolved = sdkAnswer;
|
|
1670
|
-
}
|
|
1671
|
-
const friendly = templateName.replace(/^expo-template-/, '');
|
|
1672
|
-
const subject = projectName ? source_default().cyan(projectName) : 'a project';
|
|
1673
|
-
console.log(source_default() `Creating ${subject} using the {cyan ${friendly}} template.`);
|
|
1674
|
-
if (showAlternatives) {
|
|
1675
|
-
const cmd = (0,resolvePackageManager/* formatSelfCommand */.fZ)();
|
|
1676
|
-
console.log();
|
|
1677
|
-
console.log(source_default().gray('Tip:'));
|
|
1678
|
-
console.log(` ${source_default().gray('•')} ${source_default().gray(cmd)} ${source_default().cyan('--template')} ${source_default().gray('to pick from other templates')}`);
|
|
1679
|
-
console.log(` ${source_default().gray('•')} ${source_default().gray(cmd)} ${source_default().cyan('--example')} ${source_default().gray('to explore')} ${source_default().gray.underline('https://github.com/expo/examples')}`);
|
|
1680
|
-
}
|
|
1681
|
-
console.log();
|
|
1682
|
-
return resolved;
|
|
1683
|
-
}
|
|
1684
|
-
|
|
1685
1545
|
;// CONCATENATED MODULE: ./src/utils/dir.ts
|
|
1686
1546
|
|
|
1687
1547
|
// Any of these files are allowed to exist in the projectRoot
|
|
@@ -1777,6 +1637,98 @@ async function resolveProjectRootAsync(input) {
|
|
|
1777
1637
|
return projectRoot;
|
|
1778
1638
|
}
|
|
1779
1639
|
|
|
1640
|
+
// EXTERNAL MODULE: external "process"
|
|
1641
|
+
var external_process_ = __webpack_require__(932);
|
|
1642
|
+
;// CONCATENATED MODULE: ./src/resolveExpoVersions.ts
|
|
1643
|
+
const resolveExpoVersions_debug = __webpack_require__(6675)('expo:versions');
|
|
1644
|
+
/**
|
|
1645
|
+
* The Expo Go versions endpoint, including the root property `expoGoSdkVersion`.
|
|
1646
|
+
* This `expoGoSdkVersion` property tells us what Expo SDK version is compatible with Expo Go on the store.
|
|
1647
|
+
*/
|
|
1648
|
+
const EXPO_VERSIONS_URL = 'https://api.expo.dev/v2/versions';
|
|
1649
|
+
/** Resolve the Expo SDK version compatible with Expo Go on the app stores */
|
|
1650
|
+
async function fetchExpoSdkVersions() {
|
|
1651
|
+
return await fetch(EXPO_VERSIONS_URL).then((response) => {
|
|
1652
|
+
if (response.ok)
|
|
1653
|
+
return response.json();
|
|
1654
|
+
resolveExpoVersions_debug('Failed to fetch versions endpoint, received status: %d', response.status);
|
|
1655
|
+
return null;
|
|
1656
|
+
}, (error) => {
|
|
1657
|
+
resolveExpoVersions_debug('Failed to fetch versions endpoint: %O', error);
|
|
1658
|
+
return null;
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
/**
|
|
1662
|
+
* Resolve the latest Expo SDK version, and the latest Expo Go-compatible version.
|
|
1663
|
+
* By default, we use the Expo Go-compatible version.
|
|
1664
|
+
* To inform users on how to override this, we need to know both versions.
|
|
1665
|
+
*/
|
|
1666
|
+
async function resolveExpoVersions() {
|
|
1667
|
+
const versions = await fetchExpoSdkVersions();
|
|
1668
|
+
if (!versions)
|
|
1669
|
+
return null;
|
|
1670
|
+
const available = Object.entries(versions.sdkVersions ?? {})
|
|
1671
|
+
.filter(([, info]) => !!info.releaseNoteUrl && !info.isDeprecated)
|
|
1672
|
+
.map(([version]) => parseMajorVersion(version))
|
|
1673
|
+
.filter((major) => major != null)
|
|
1674
|
+
.sort((a, b) => a - b);
|
|
1675
|
+
return {
|
|
1676
|
+
latestVersion: available.pop() ?? null,
|
|
1677
|
+
expoGoVersion: parseMajorVersion(versions.expoGoSdkVersion),
|
|
1678
|
+
};
|
|
1679
|
+
}
|
|
1680
|
+
/** Extract the major number from a semver version or range */
|
|
1681
|
+
function parseMajorVersion(semver) {
|
|
1682
|
+
const major = parseInt(semver.split('.', 1).shift() ?? '', 10);
|
|
1683
|
+
return Number.isFinite(major) ? major : null;
|
|
1684
|
+
}
|
|
1685
|
+
|
|
1686
|
+
;// CONCATENATED MODULE: ./src/resolveTemplate.ts
|
|
1687
|
+
|
|
1688
|
+
|
|
1689
|
+
|
|
1690
|
+
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Resolve the Expo Go compatible template and inform the user.
|
|
1695
|
+
* This only applies to first-party templates, listed in {@link ALIASES}.
|
|
1696
|
+
*/
|
|
1697
|
+
async function resolveTemplate({ template, projectName, }) {
|
|
1698
|
+
const [name, version] = splitNpmNameAndTag(template);
|
|
1699
|
+
if (version || external_process_.env.EXPO_BETA || !isExpoTemplate(name)) {
|
|
1700
|
+
console.log(source_default() `Creating {cyan ${projectName}} using the {cyan ${template}} template.`);
|
|
1701
|
+
return template;
|
|
1702
|
+
}
|
|
1703
|
+
const versions = await resolveExpoVersions();
|
|
1704
|
+
if (!versions?.expoGoVersion) {
|
|
1705
|
+
console.log(source_default() `Creating {cyan ${projectName}} using the {cyan ${template}} template.`);
|
|
1706
|
+
return template;
|
|
1707
|
+
}
|
|
1708
|
+
const expoGoTemplate = `${name}@sdk-${versions.expoGoVersion}`;
|
|
1709
|
+
const isLatestVersion = versions.expoGoVersion === versions.latestVersion;
|
|
1710
|
+
console.log(isLatestVersion
|
|
1711
|
+
? source_default() `Creating {cyan ${projectName}} using the {cyan ${expoGoTemplate}} template.`
|
|
1712
|
+
: source_default() `Creating {cyan ${projectName}} using the Expo Go-compatible {cyan ${expoGoTemplate}} template.`);
|
|
1713
|
+
const cmd = (0,resolvePackageManager/* formatSelfCommand */.fZ)();
|
|
1714
|
+
console.log([
|
|
1715
|
+
'',
|
|
1716
|
+
source_default().dim('Tip:'),
|
|
1717
|
+
isLatestVersion
|
|
1718
|
+
? null
|
|
1719
|
+
: source_default() ` {dim $ ${cmd} {cyan --template ${name}@latest} to use the latest {bold Expo SDK ${versions.latestVersion}}}`,
|
|
1720
|
+
source_default() ` {dim $ ${cmd} {cyan --template} to pick different templates}`,
|
|
1721
|
+
source_default() ` {dim $ ${cmd} {cyan --example} to explore {underline https://github.com/expo/examples}}`,
|
|
1722
|
+
'',
|
|
1723
|
+
]
|
|
1724
|
+
.filter((value) => value !== null)
|
|
1725
|
+
.join('\n'));
|
|
1726
|
+
return template;
|
|
1727
|
+
}
|
|
1728
|
+
function isExpoTemplate(name) {
|
|
1729
|
+
return ALIASES.includes(name.startsWith('expo-template-') ? name : `expo-template-${name}`);
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1780
1732
|
// EXTERNAL MODULE: ./src/telemetry.ts + 2 modules
|
|
1781
1733
|
var telemetry = __webpack_require__(601);
|
|
1782
1734
|
// EXTERNAL MODULE: ./src/utils/update-check.ts
|
|
@@ -1785,8 +1737,6 @@ var update_check = __webpack_require__(7517);
|
|
|
1785
1737
|
|
|
1786
1738
|
|
|
1787
1739
|
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
1740
|
const git_debug = __webpack_require__(6675)('expo:init:git');
|
|
1791
1741
|
const getPackageJson = () => {
|
|
1792
1742
|
try {
|
|
@@ -1819,30 +1769,13 @@ async function isGitInstalledAsync() {
|
|
|
1819
1769
|
async function initGitRepoAsync(root) {
|
|
1820
1770
|
// Check if git is installed
|
|
1821
1771
|
if (!(await isGitInstalledAsync())) {
|
|
1822
|
-
git_debug(
|
|
1772
|
+
git_debug('Unable to initialize Git repo. `git` not in $PATH.');
|
|
1823
1773
|
return false;
|
|
1824
1774
|
}
|
|
1825
1775
|
// Check if already inside a git repository
|
|
1826
1776
|
if (await isInsideGitRepoAsync(root)) {
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
git_debug(source_default().dim('New project is already inside of a Git repo, skipping git init (CI mode).'));
|
|
1830
|
-
return false;
|
|
1831
|
-
}
|
|
1832
|
-
// In interactive mode, prompt the user
|
|
1833
|
-
const { answer } = await prompts_default()({
|
|
1834
|
-
type: 'confirm',
|
|
1835
|
-
name: 'answer',
|
|
1836
|
-
message: 'You are creating a project inside of an existing Git repository. Skip initializing a new git repository?',
|
|
1837
|
-
initial: true,
|
|
1838
|
-
});
|
|
1839
|
-
// If user confirms skip (or cancels/ctrl+c which returns undefined), skip git init
|
|
1840
|
-
if (answer !== false) {
|
|
1841
|
-
git_debug(source_default().dim('User chose to skip git init inside existing repo.'));
|
|
1842
|
-
return false;
|
|
1843
|
-
}
|
|
1844
|
-
// User explicitly chose not to skip, proceed with git init (creates nested repo)
|
|
1845
|
-
git_debug(source_default().dim('User chose to initialize git inside existing repo.'));
|
|
1777
|
+
console.log(source_default().dim('Skipped initializing Git repository, already inside one.'));
|
|
1778
|
+
return false;
|
|
1846
1779
|
}
|
|
1847
1780
|
const packageJSON = getPackageJson();
|
|
1848
1781
|
// not in git tree, so let's init
|
|
@@ -1854,7 +1787,7 @@ async function initGitRepoAsync(root) {
|
|
|
1854
1787
|
stdio: 'ignore',
|
|
1855
1788
|
cwd: root,
|
|
1856
1789
|
});
|
|
1857
|
-
git_debug(
|
|
1790
|
+
git_debug('Initialized a Git repository.');
|
|
1858
1791
|
return true;
|
|
1859
1792
|
}
|
|
1860
1793
|
catch (error) {
|
|
@@ -1902,6 +1835,10 @@ function withSectionLog(action, message) {
|
|
|
1902
1835
|
|
|
1903
1836
|
|
|
1904
1837
|
|
|
1838
|
+
|
|
1839
|
+
|
|
1840
|
+
|
|
1841
|
+
const SWIFTPM_PREBUILD_ARGS = ['expo', 'prebuild', '--platform', 'ios'];
|
|
1905
1842
|
const createAsync_debug = __webpack_require__(6675)('expo:init:create');
|
|
1906
1843
|
async function resolveProjectRootArgAsync(inputPath, { yes }) {
|
|
1907
1844
|
if (!inputPath && yes) {
|
|
@@ -1927,12 +1864,18 @@ async function setupDependenciesAsync(projectRoot, props) {
|
|
|
1927
1864
|
// Install dependencies
|
|
1928
1865
|
let podsInstalled = false;
|
|
1929
1866
|
let nodeModulesInstalled = false;
|
|
1930
|
-
const needsPodsInstalled =
|
|
1867
|
+
const needsPodsInstalled = !props.swiftpm && external_fs_default().existsSync(external_path_default().join(projectRoot, 'ios'));
|
|
1868
|
+
let swiftPMSetUp = false;
|
|
1931
1869
|
if (shouldInstall) {
|
|
1932
1870
|
nodeModulesInstalled = await installNodeDependenciesAsync(projectRoot, packageManager);
|
|
1933
1871
|
if (needsPodsInstalled) {
|
|
1934
1872
|
podsInstalled = await installCocoaPodsAsync(projectRoot);
|
|
1935
1873
|
}
|
|
1874
|
+
// Prebuild runs from the project's node modules, and SwiftPM needs Xcode, so like
|
|
1875
|
+
// CocoaPods this is skipped outside macOS.
|
|
1876
|
+
if (props.swiftpm && nodeModulesInstalled && process.platform === 'darwin') {
|
|
1877
|
+
swiftPMSetUp = await runSwiftPMSetupAsync(projectRoot);
|
|
1878
|
+
}
|
|
1936
1879
|
}
|
|
1937
1880
|
const cdPath = getChangeDirectoryPath(projectRoot);
|
|
1938
1881
|
console.log();
|
|
@@ -1941,6 +1884,30 @@ async function setupDependenciesAsync(projectRoot, props) {
|
|
|
1941
1884
|
if (!nodeModulesInstalled) {
|
|
1942
1885
|
logNodeInstallWarning(cdPath, packageManager, needsPodsInstalled && !podsInstalled);
|
|
1943
1886
|
}
|
|
1887
|
+
if (props.swiftpm) {
|
|
1888
|
+
logSwiftPMWarning(cdPath, swiftPMSetUp);
|
|
1889
|
+
}
|
|
1890
|
+
}
|
|
1891
|
+
async function runSwiftPMSetupAsync(projectRoot) {
|
|
1892
|
+
try {
|
|
1893
|
+
await withSectionLog(async () => {
|
|
1894
|
+
await spawnAsync_default()('npx', SWIFTPM_PREBUILD_ARGS, {
|
|
1895
|
+
cwd: projectRoot,
|
|
1896
|
+
stdio: env.env.EXPO_DEBUG ? 'inherit' : 'pipe',
|
|
1897
|
+
});
|
|
1898
|
+
}, {
|
|
1899
|
+
pending: source_default().bold('Setting up Swift Package Manager for iOS.'),
|
|
1900
|
+
success: 'Set up Swift Package Manager for iOS.',
|
|
1901
|
+
error: () => 'Setting up Swift Package Manager for iOS failed. The app is still created. Run the command below to finish the setup.',
|
|
1902
|
+
});
|
|
1903
|
+
return true;
|
|
1904
|
+
}
|
|
1905
|
+
catch (error) {
|
|
1906
|
+
createAsync_debug('Error setting up Swift Package Manager: %O', error);
|
|
1907
|
+
const { stderr } = error;
|
|
1908
|
+
log/* Log */.tG.error(stderr || source_default().red(error.message));
|
|
1909
|
+
return false;
|
|
1910
|
+
}
|
|
1944
1911
|
}
|
|
1945
1912
|
async function createAsync(inputPath, options) {
|
|
1946
1913
|
if (options.example && options.template) {
|
|
@@ -1961,9 +1928,8 @@ async function createTemplateAsync(inputPath, props) {
|
|
|
1961
1928
|
resolvedTemplate = props.template ?? null;
|
|
1962
1929
|
}
|
|
1963
1930
|
const projectRoot = await resolveProjectRootArgAsync(inputPath, props);
|
|
1964
|
-
resolvedTemplate = await
|
|
1965
|
-
|
|
1966
|
-
showAlternatives: !props.template,
|
|
1931
|
+
resolvedTemplate = await resolveTemplate({
|
|
1932
|
+
template: resolvedTemplate ?? 'default',
|
|
1967
1933
|
projectName: external_path_default().basename(projectRoot),
|
|
1968
1934
|
});
|
|
1969
1935
|
await external_fs_default().promises.mkdir(projectRoot, { recursive: true });
|
|
@@ -1979,11 +1945,12 @@ async function createTemplateAsync(inputPath, props) {
|
|
|
1979
1945
|
await withSectionLog(async () => {
|
|
1980
1946
|
await extractAndPrepareTemplateAppAsync(projectRoot, {
|
|
1981
1947
|
npmPackage: resolvedTemplate,
|
|
1948
|
+
swiftpm: props.swiftpm,
|
|
1982
1949
|
});
|
|
1983
1950
|
}, {
|
|
1984
1951
|
pending: source_default().bold('Locating project files.'),
|
|
1985
1952
|
success: 'Downloaded and extracted project files.',
|
|
1986
|
-
error: (error) =>
|
|
1953
|
+
error: (error) => formatExtractionError(error, 'project'),
|
|
1987
1954
|
});
|
|
1988
1955
|
await setupDependenciesAsync(projectRoot, props);
|
|
1989
1956
|
if (props.agentsMd) {
|
|
@@ -2055,11 +2022,13 @@ async function createExampleAsync(inputPath, props) {
|
|
|
2055
2022
|
properties: { phase: telemetry.AnalyticsEventPhases.ATTEMPT, example: resolvedExample },
|
|
2056
2023
|
});
|
|
2057
2024
|
await withSectionLog(async () => {
|
|
2058
|
-
await downloadAndExtractExampleAsync(projectRoot, resolvedExample
|
|
2025
|
+
await downloadAndExtractExampleAsync(projectRoot, resolvedExample, {
|
|
2026
|
+
swiftpm: props.swiftpm,
|
|
2027
|
+
});
|
|
2059
2028
|
}, {
|
|
2060
2029
|
pending: source_default().bold('Locating example files...'),
|
|
2061
2030
|
success: 'Downloaded and extracted example files.',
|
|
2062
|
-
error: (error) =>
|
|
2031
|
+
error: (error) => formatExtractionError(error, 'example'),
|
|
2063
2032
|
});
|
|
2064
2033
|
await setupDependenciesAsync(projectRoot, props);
|
|
2065
2034
|
if (props.agentsMd) {
|
|
@@ -2079,6 +2048,12 @@ async function createExampleAsync(inputPath, props) {
|
|
|
2079
2048
|
// todo: check if git is installed, bail out
|
|
2080
2049
|
}
|
|
2081
2050
|
}
|
|
2051
|
+
function formatExtractionError(error, files) {
|
|
2052
|
+
if (error instanceof src_error/* SwiftPMUnsupportedError */.u) {
|
|
2053
|
+
return error.message;
|
|
2054
|
+
}
|
|
2055
|
+
return `Something went wrong in downloading and extracting the ${files} files: ${error.message}`;
|
|
2056
|
+
}
|
|
2082
2057
|
function getChangeDirectoryPath(projectRoot) {
|
|
2083
2058
|
const cdPath = external_path_default().relative(process.cwd(), projectRoot);
|
|
2084
2059
|
if (cdPath.length <= projectRoot.length) {
|
|
@@ -2128,6 +2103,15 @@ function logNodeInstallWarning(cdPath, packageManager, needsPods) {
|
|
|
2128
2103
|
}
|
|
2129
2104
|
console.log();
|
|
2130
2105
|
}
|
|
2106
|
+
function logSwiftPMWarning(cdPath, isSetUp) {
|
|
2107
|
+
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`);
|
|
2108
|
+
if (!isSetUp) {
|
|
2109
|
+
console.log(`To finish setting up iOS, run:\n`);
|
|
2110
|
+
console.log(` cd ${cdPath || '.'}${(external_path_default()).sep}`);
|
|
2111
|
+
console.log(` npx ${SWIFTPM_PREBUILD_ARGS.join(' ')}`);
|
|
2112
|
+
console.log();
|
|
2113
|
+
}
|
|
2114
|
+
}
|
|
2131
2115
|
function getDeprecatedExampleErrorMessage(example, metadata) {
|
|
2132
2116
|
const { message, outdatedExampleHref } = metadata.deprecated[example] ?? {};
|
|
2133
2117
|
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
|
+
}
|