expo-desktop 0.1.32 → 0.1.33

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,5 +1,6 @@
1
1
  import { log, tasks } from "@clack/prompts";
2
2
  import { type } from "arktype";
3
+ import { glob } from "glob";
3
4
  import { cyan, green, yellow } from "kleur/colors";
4
5
  import fs from "node:fs/promises";
5
6
  import path from "node:path";
@@ -66,11 +67,13 @@ export async function createExpoDesktopApp({ localDev, name, packageManager, tem
66
67
  if (localDev) {
67
68
  await addApplyConfigPluginsScript({ projectPath });
68
69
  }
70
+ const bundleEntryFileCandidates = await getBundleEntryFileCandidates({ projectPath });
69
71
  await applyConfigPlugins({
70
72
  projectRoot: projectPath,
71
73
  displayName: name.displayName,
72
74
  bundleIdentifier: name.rdns.replaceAll("_", "-"),
73
75
  platforms: ["macos", "windows"],
76
+ bundleEntryFileCandidates,
74
77
  });
75
78
  console.log(`${green("◆")} Applied config plugins.\n`);
76
79
  title("Improving the macOS app's gitignore file…", { spacing: 1 });
@@ -101,6 +104,29 @@ export async function createExpoDesktopApp({ localDev, name, packageManager, tem
101
104
  title("Adding Expo support to the Babel config…", { spacing: 1 });
102
105
  await writeBabelConfig({ projectPath });
103
106
  }
107
+ async function getBundleEntryFileCandidates({ projectPath }) {
108
+ try {
109
+ // Seems to order candidates as:
110
+ // [
111
+ // "index.windows.tsx",
112
+ // "index.windows.ts",
113
+ // "index.windows.jsx",
114
+ // "index.windows.js",
115
+ // "index.tsx",
116
+ // "index.ts",
117
+ // "index.jsx",
118
+ // "index.js",
119
+ // ]
120
+ const candidates = await glob("index?(.windows|.macos|.ios|.android|.native).{ts,tsx,js,jsx}", {
121
+ cwd: projectPath,
122
+ });
123
+ return candidates;
124
+ }
125
+ catch (error) {
126
+ console.warn("Unable to detect an index?(.windows).{ts,tsx,js,jsx} file in the root of the project, so will fall back to a <BundleEntryFile> value to 'index.ts'.", error);
127
+ return ["index.ts"];
128
+ }
129
+ }
104
130
  async function createExpoApp({ localDev, name, packageManager, versions, }) {
105
131
  // `create-expo-app` aggravatingly reconfigures your workspace to use
106
132
  // `nodeLinker: hoisted`, which sucks when creating sample projects inside
@@ -118,7 +144,9 @@ async function createExpoApp({ localDev, name, packageManager, versions, }) {
118
144
  });
119
145
  await gen.next();
120
146
  // `npm create` drops flags meant for create-expo-app unless you add `--`; use
121
- // `npx --yes` instead to forward args correctly and skip prompts.
147
+ // `npx --yes` instead to forward args correctly. Pass `--yes` to
148
+ // create-expo-app for non-interactive template selection; set `CI=true` in the
149
+ // child env so git-init inside an existing repo is skipped too.
122
150
  const command = packageManager === "npm" ? "npx" : packageManager;
123
151
  const args = [
124
152
  ...(packageManager === "npm" ? ["--yes", "create-expo-app"] : ["create", "expo-app"]),
@@ -138,8 +166,15 @@ async function createExpoApp({ localDev, name, packageManager, versions, }) {
138
166
  args,
139
167
  options: {
140
168
  stdio: "inherit",
141
- // Suppresses npx/npm exec "Ok to proceed?" and similar yes/no prompts.
142
- env: { npm_config_yes: "true" },
169
+ env: {
170
+ // Suppresses npx/npm exec "Ok to proceed?" and similar yes/no prompts.
171
+ npm_config_yes: "true",
172
+ // create-expo-app's `--yes` skips template/SDK prompts but not the
173
+ // "Skip initializing a new git repository?" confirm when cwd is
174
+ // inside an existing repo; that path only auto-skips when CI is set.
175
+ // https://github.com/expo/expo/blob/main/packages/create-expo/src/utils/git.ts
176
+ CI: "true",
177
+ },
143
178
  },
144
179
  debugLogDir: projectPath,
145
180
  }),
@@ -558,6 +593,7 @@ module.exports = function (api) {
558
593
  */
559
594
  async function addApplyConfigPluginsScript({ projectPath }) {
560
595
  await fs.writeFile(path.resolve(projectPath, "apply-config-plugins.mjs"), `
596
+ import { globSync } from "node:fs";
561
597
  import { createRequire } from "node:module";
562
598
 
563
599
  const require = createRequire(import.meta.url);
@@ -572,8 +608,24 @@ const info = {
572
608
  bundleIdentifier: "com.example.my-app-123",
573
609
  // @ts-expect-error Normally only accepts ios and android
574
610
  platforms: ["macos", "windows"],
611
+ bundleEntryFileCandidates: getBundleEntryFileCandidates({ projectPath: projectRoot }),
575
612
  };
576
613
 
614
+ function getBundleEntryFileCandidates({ projectPath }) {
615
+ try {
616
+ const candidates = globSync("index{.windows,.macos,.ios,.android,.native,}.{ts,tsx,js,jsx}", {
617
+ cwd: projectPath,
618
+ });
619
+ return candidates;
620
+ } catch (error) {
621
+ console.warn(
622
+ "Unable to detect an index?(.windows).{ts,tsx,js,jsx} file in the root of the project, so will fall back to a <BundleEntryFile> value to 'index.ts'.",
623
+ error,
624
+ );
625
+ return ["index.ts"];
626
+ }
627
+ }
628
+
577
629
  const withInternal = (config, internals) => {
578
630
  config._internal = {
579
631
  isDebug: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-desktop",
3
- "version": "0.1.32",
3
+ "version": "0.1.33",
4
4
  "description": "Best-effort desktop support for Expo",
5
5
  "keywords": [
6
6
  "android",
@@ -37,8 +37,8 @@
37
37
  "@clack/prompts": "^1.2.0",
38
38
  "arktype": "^2.2.0",
39
39
  "citty": "^0.2.2",
40
- "expo-desktop-config-plugins": "^1.1.29",
41
- "expo-desktop-prebuild-config": "^1.0.15",
40
+ "expo-desktop-config-plugins": "^1.1.30",
41
+ "expo-desktop-prebuild-config": "^1.0.16",
42
42
  "glob": "^10.5.0",
43
43
  "kleur": "^4.1.5",
44
44
  "mustache": "^4.2.0",