create-expo 5.1.5 → 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.
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- exports.id = 589;
3
- exports.ids = [589,601];
2
+ exports.id = 536;
3
+ exports.ids = [536,601];
4
4
  exports.modules = {
5
5
 
6
- /***/ 589:
6
+ /***/ 2536:
7
7
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
8
 
9
9
 
@@ -1542,175 +1542,6 @@ async function generateAgentFiles(root) {
1542
1542
  await Promise.all(tasks);
1543
1543
  }
1544
1544
 
1545
- ;// CONCATENATED MODULE: ./src/promptSdkVersion.ts
1546
-
1547
-
1548
-
1549
-
1550
-
1551
-
1552
-
1553
- const promptSdkVersion_debug = __webpack_require__(6675)('expo:init:sdk');
1554
- // SDKs without a `releaseNoteUrl` are canary/in-development. The top-level
1555
- // `expoGoSdkVersion` reports the SDK currently shipping in store Expo Go and
1556
- // is treated as optional — when absent, the "For learning with Expo Go" choice
1557
- // is hidden.
1558
- const VERSIONS_URL = 'https://api.expo.dev/v2/versions';
1559
- async function fetchSdkVersionsAsync() {
1560
- let json;
1561
- try {
1562
- const response = await fetch(VERSIONS_URL);
1563
- if (!response.ok) {
1564
- promptSdkVersion_debug(`versions endpoint returned ${response.status}`);
1565
- return null;
1566
- }
1567
- json = (await response.json());
1568
- }
1569
- catch (error) {
1570
- promptSdkVersion_debug('Failed to fetch versions endpoint:', error);
1571
- return null;
1572
- }
1573
- const sdkVersions = json.sdkVersions ?? {};
1574
- const available = Object.entries(sdkVersions)
1575
- .filter(([, info]) => !!info.releaseNoteUrl && !info.isDeprecated)
1576
- .map(([version]) => parseSdkMajor(version))
1577
- .filter((major) => major != null)
1578
- .sort((a, b) => b - a);
1579
- const latest = available[0];
1580
- if (latest == null) {
1581
- return null;
1582
- }
1583
- return {
1584
- latest,
1585
- expoGoCompatible: parseSdkMajor(json.expoGoSdkVersion),
1586
- available,
1587
- };
1588
- }
1589
- function parseSdkMajor(version) {
1590
- const major = parseInt(version?.split('.')[0] ?? '', 10);
1591
- return Number.isFinite(major) ? major : null;
1592
- }
1593
- /**
1594
- * If the resolved template is an Expo-published template without an explicit
1595
- * SDK tag, prompt the user to pick which Expo SDK to use and return the
1596
- * template name with the chosen SDK tag appended.
1597
- *
1598
- * Returns the template unchanged if the user is non-interactive, the template
1599
- * already targets a specific version, or we can't reach the versions endpoint.
1600
- */
1601
- async function applySdkVersionToTemplateAsync(template, { yes, showAlternatives = true, projectName, }) {
1602
- if (env.env.EXPO_BETA) {
1603
- logCreatingProject(template, projectName);
1604
- return template;
1605
- }
1606
- const [name, tag] = splitNpmNameAndTag(template);
1607
- if (tag) {
1608
- logCreatingProject(template, projectName);
1609
- return template;
1610
- }
1611
- if (!isKnownExpoTemplate(name)) {
1612
- logCreatingProject(template, projectName);
1613
- return template;
1614
- }
1615
- const nonInteractive = yes || env.env.CI || !process.stdin.isTTY;
1616
- // Non-interactive + user explicitly chose a template: fall through to that
1617
- // template's npm `latest` dist-tag. No need to fetch the versions endpoint.
1618
- if (nonInteractive && !showAlternatives) {
1619
- logCreatingProject(template, projectName);
1620
- return template;
1621
- }
1622
- const versions = await fetchSdkVersionsAsync();
1623
- if (!versions) {
1624
- logCreatingProject(template, projectName);
1625
- return template;
1626
- }
1627
- // Non-interactive + default template: pin to the actual latest released SDK.
1628
- if (nonInteractive) {
1629
- const pinned = `${name}@sdk-${versions.latest}`;
1630
- logCreatingProject(pinned, projectName);
1631
- return pinned;
1632
- }
1633
- const selectedSdk = await promptSdkVersionAsync(versions, name, showAlternatives, projectName);
1634
- if (selectedSdk == null) {
1635
- logCreatingProject(template, projectName);
1636
- return template;
1637
- }
1638
- return `${name}@sdk-${selectedSdk}`;
1639
- }
1640
- function logCreatingProject(template, projectName) {
1641
- const subject = projectName ? source_default().cyan(projectName) : 'a project';
1642
- console.log(source_default() `Creating ${subject} using the {cyan ${template}} template.\n`);
1643
- }
1644
- function isKnownExpoTemplate(name) {
1645
- if (ALIASES.includes(name)) {
1646
- return true;
1647
- }
1648
- // Short aliases like `default` and `blank` are expanded to `expo-template-*` later.
1649
- return ALIASES.includes(`expo-template-${name}`);
1650
- }
1651
- async function promptSdkVersionAsync(versions, templateName, showAlternatives, projectName) {
1652
- const { latest, expoGoCompatible, available } = versions;
1653
- const choices = [
1654
- {
1655
- title: `Latest (SDK ${latest})`,
1656
- value: latest,
1657
- description: 'Recommended for most projects',
1658
- },
1659
- ];
1660
- if (expoGoCompatible != null && expoGoCompatible !== latest) {
1661
- choices.push({
1662
- title: `For learning with Expo Go (SDK ${expoGoCompatible})`,
1663
- value: expoGoCompatible,
1664
- description: 'Compatible with Expo Go on App Store and Play Store',
1665
- });
1666
- }
1667
- choices.push({ title: 'Other SDK version…', value: 'other' });
1668
- const { answer } = await prompts_default()({
1669
- type: 'select',
1670
- name: 'answer',
1671
- message: 'Select an Expo SDK version:',
1672
- choices,
1673
- });
1674
- if (answer == null) {
1675
- log/* Log */.tG.log();
1676
- log/* Log */.tG.log(source_default() `Specify the SDK version, example: {cyan --template default@${latest}}`);
1677
- process.exit(1);
1678
- }
1679
- let resolved;
1680
- if (answer !== 'other') {
1681
- resolved = answer;
1682
- }
1683
- else {
1684
- const { sdkAnswer } = await prompts_default()({
1685
- type: 'select',
1686
- name: 'sdkAnswer',
1687
- message: 'Select an SDK version:',
1688
- choices: available.slice(0, 4).map((sdk) => ({
1689
- title: `SDK ${sdk}`,
1690
- value: sdk,
1691
- })),
1692
- });
1693
- if (sdkAnswer == null) {
1694
- log/* Log */.tG.log();
1695
- log/* Log */.tG.log(source_default() `Specify the SDK version, example: {cyan --template default@${latest}}`);
1696
- process.exit(1);
1697
- }
1698
- resolved = sdkAnswer;
1699
- }
1700
- const friendly = templateName.replace(/^expo-template-/, '');
1701
- const subject = projectName ? source_default().cyan(projectName) : 'a project';
1702
- console.log(source_default() `Creating ${subject} using the {cyan ${friendly}} template.`);
1703
- if (showAlternatives) {
1704
- const cmd = (0,resolvePackageManager/* formatSelfCommand */.fZ)();
1705
- console.log();
1706
- console.log(source_default().gray('Tip:'));
1707
- console.log(` ${source_default().gray('•')} ${source_default().gray(cmd)} ${source_default().cyan('--template')} ${source_default().gray('to pick from other templates')}`);
1708
- 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')}`);
1709
- }
1710
- console.log();
1711
- return resolved;
1712
- }
1713
-
1714
1545
  ;// CONCATENATED MODULE: ./src/utils/dir.ts
1715
1546
 
1716
1547
  // Any of these files are allowed to exist in the projectRoot
@@ -1806,6 +1637,98 @@ async function resolveProjectRootAsync(input) {
1806
1637
  return projectRoot;
1807
1638
  }
1808
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
+
1809
1732
  // EXTERNAL MODULE: ./src/telemetry.ts + 2 modules
1810
1733
  var telemetry = __webpack_require__(601);
1811
1734
  // EXTERNAL MODULE: ./src/utils/update-check.ts
@@ -1814,8 +1737,6 @@ var update_check = __webpack_require__(7517);
1814
1737
 
1815
1738
 
1816
1739
 
1817
-
1818
-
1819
1740
  const git_debug = __webpack_require__(6675)('expo:init:git');
1820
1741
  const getPackageJson = () => {
1821
1742
  try {
@@ -1848,30 +1769,13 @@ async function isGitInstalledAsync() {
1848
1769
  async function initGitRepoAsync(root) {
1849
1770
  // Check if git is installed
1850
1771
  if (!(await isGitInstalledAsync())) {
1851
- git_debug(source_default().dim('Unable to initialize Git repo. `git` not in $PATH.'));
1772
+ git_debug('Unable to initialize Git repo. `git` not in $PATH.');
1852
1773
  return false;
1853
1774
  }
1854
1775
  // Check if already inside a git repository
1855
1776
  if (await isInsideGitRepoAsync(root)) {
1856
- // In headless/CI mode, skip by default
1857
- if (env.env.CI) {
1858
- git_debug(source_default().dim('New project is already inside of a Git repo, skipping git init (CI mode).'));
1859
- return false;
1860
- }
1861
- // In interactive mode, prompt the user
1862
- const { answer } = await prompts_default()({
1863
- type: 'confirm',
1864
- name: 'answer',
1865
- message: 'You are creating a project inside of an existing Git repository. Skip initializing a new git repository?',
1866
- initial: true,
1867
- });
1868
- // If user confirms skip (or cancels/ctrl+c which returns undefined), skip git init
1869
- if (answer !== false) {
1870
- git_debug(source_default().dim('User chose to skip git init inside existing repo.'));
1871
- return false;
1872
- }
1873
- // User explicitly chose not to skip, proceed with git init (creates nested repo)
1874
- 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;
1875
1779
  }
1876
1780
  const packageJSON = getPackageJson();
1877
1781
  // not in git tree, so let's init
@@ -1883,7 +1787,7 @@ async function initGitRepoAsync(root) {
1883
1787
  stdio: 'ignore',
1884
1788
  cwd: root,
1885
1789
  });
1886
- git_debug(source_default().dim('Initialized a Git repository.'));
1790
+ git_debug('Initialized a Git repository.');
1887
1791
  return true;
1888
1792
  }
1889
1793
  catch (error) {
@@ -2024,9 +1928,8 @@ async function createTemplateAsync(inputPath, props) {
2024
1928
  resolvedTemplate = props.template ?? null;
2025
1929
  }
2026
1930
  const projectRoot = await resolveProjectRootArgAsync(inputPath, props);
2027
- resolvedTemplate = await applySdkVersionToTemplateAsync(resolvedTemplate ?? 'expo-template-default', {
2028
- yes: props.yes,
2029
- showAlternatives: !props.template,
1931
+ resolvedTemplate = await resolveTemplate({
1932
+ template: resolvedTemplate ?? 'default',
2030
1933
  projectName: external_path_default().basename(projectRoot),
2031
1934
  });
2032
1935
  await external_fs_default().promises.mkdir(projectRoot, { recursive: true });