create-expo 5.0.2 → 5.1.1

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.
Files changed (54) hide show
  1. package/build/{205.index.js → 589.index.js} +392 -91
  2. package/build/601.index.js +20 -11
  3. package/build/{223.index.js → 870.index.js} +2 -10
  4. package/build/Examples.d.ts +38 -0
  5. package/build/Template.d.ts +98 -0
  6. package/build/__mocks__/fs.d.ts +1 -0
  7. package/build/__mocks__/ora.d.ts +1 -0
  8. package/build/__tests__/Examples.test.d.ts +1 -0
  9. package/build/__tests__/Template.test.d.ts +1 -0
  10. package/build/__tests__/configureWorkspaces.test.d.ts +1 -0
  11. package/build/__tests__/createAsync.test.d.ts +1 -0
  12. package/build/__tests__/createExpoConfig.test.d.ts +1 -0
  13. package/build/__tests__/createFileTransformer.test.d.ts +1 -0
  14. package/build/__tests__/generateAgentFiles.test.d.ts +1 -0
  15. package/build/__tests__/promptSdkVersion.test.d.ts +1 -0
  16. package/build/__tests__/resolvePackageManager.test.d.ts +1 -0
  17. package/build/__tests__/sanitizeTemplate.test.d.ts +1 -0
  18. package/build/__tests__/telemetry.test.d.ts +1 -0
  19. package/build/cli.d.ts +1 -0
  20. package/build/configureWorkspaces.d.ts +9 -0
  21. package/build/createAsync.d.ts +11 -0
  22. package/build/createExpoConfig.d.ts +38 -0
  23. package/build/createFileTransform.d.ts +5 -0
  24. package/build/error.d.ts +9 -0
  25. package/build/generateAgentFiles.d.ts +1 -0
  26. package/build/index.d.ts +1 -0
  27. package/build/index.js +38 -10
  28. package/build/legacyTemplates.d.ts +7 -0
  29. package/build/log.d.ts +12 -0
  30. package/build/paths.d.ts +2 -0
  31. package/build/promptSdkVersion.d.ts +23 -0
  32. package/build/resolvePackageManager.d.ts +12 -0
  33. package/build/resolveProjectRoot.d.ts +3 -0
  34. package/build/sessionStorage.d.ts +8 -0
  35. package/build/telemetry.d.ts +29 -0
  36. package/build/utils/__tests__/args.test.d.ts +1 -0
  37. package/build/utils/__tests__/array.test.d.ts +1 -0
  38. package/build/utils/__tests__/log.test.d.ts +1 -0
  39. package/build/utils/__tests__/npm.test.d.ts +1 -0
  40. package/build/utils/__tests__/obj.test.d.ts +1 -0
  41. package/build/utils/args.d.ts +33 -0
  42. package/build/utils/array.d.ts +1 -0
  43. package/build/utils/dir.d.ts +1 -0
  44. package/build/utils/env.d.ts +14 -0
  45. package/build/utils/fetch.d.ts +2 -0
  46. package/build/utils/git.d.ts +1 -0
  47. package/build/utils/github.d.ts +2 -0
  48. package/build/utils/log.d.ts +6 -0
  49. package/build/utils/npm.d.ts +52 -0
  50. package/build/utils/obj.d.ts +1 -0
  51. package/build/utils/tar.d.ts +10 -0
  52. package/build/utils/update-check.d.ts +2 -0
  53. package/package.json +31 -21
  54. package/build/517.index.js +0 -1380
@@ -21,7 +21,6 @@ __webpack_require__.d(__webpack_exports__, {
21
21
 
22
22
  // EXTERNAL MODULE: ../@expo/json-file/build/JsonFile.js
23
23
  var JsonFile = __webpack_require__(3064);
24
- var JsonFile_default = /*#__PURE__*/__webpack_require__.n(JsonFile);
25
24
  // EXTERNAL MODULE: external "crypto"
26
25
  var external_crypto_ = __webpack_require__(6982);
27
26
  var external_crypto_default = /*#__PURE__*/__webpack_require__.n(external_crypto_);
@@ -63,7 +62,7 @@ const getStateJsonPath = () => external_path_default().join(dotExpoHomeDirectory
63
62
 
64
63
  function getSession() {
65
64
  try {
66
- return JsonFile_default().read(getStateJsonPath())?.auth ?? null;
65
+ return JsonFile["default"].read(getStateJsonPath())?.auth ?? null;
67
66
  }
68
67
  catch (error) {
69
68
  if (error.code === 'ENOENT') {
@@ -75,6 +74,8 @@ function getSession() {
75
74
 
76
75
  // EXTERNAL MODULE: ./src/utils/env.ts
77
76
  var utils_env = __webpack_require__(4342);
77
+ // EXTERNAL MODULE: ./src/utils/update-check.ts
78
+ var update_check = __webpack_require__(7517);
78
79
  ;// CONCATENATED MODULE: ./src/telemetry.ts
79
80
 
80
81
 
@@ -83,11 +84,19 @@ var utils_env = __webpack_require__(4342);
83
84
 
84
85
 
85
86
 
86
- const packageJSON = __webpack_require__(8330);
87
+
88
+ const getPackageJson = () => {
89
+ try {
90
+ return __webpack_require__(8330);
91
+ }
92
+ catch {
93
+ return null;
94
+ }
95
+ };
87
96
  const xdlUnifiedWriteKey = '1wabJGd5IiuF9Q8SGlcI90v8WTs';
88
97
  const analyticsEndpoint = 'https://cdp.expo.dev/v1/batch';
89
98
  const version = '1.0.0';
90
- const library = packageJSON.name;
99
+ const library = update_check.PACKAGE_NAME;
91
100
  const messageBatch = [];
92
101
  let analyticsIdentity = null;
93
102
  // jest does not clear global variables inbetween tests so we need this helper
@@ -144,7 +153,7 @@ function enqueue(type, message) {
144
153
  message.originalTimestamp = new Date();
145
154
  }
146
155
  if (!message.messageId) {
147
- // We md5 the messaage to add more randomness. This is primarily meant
156
+ // We md5 the message to add more randomness. This is primarily meant
148
157
  // for use in the browser where the uuid package falls back to Math.random()
149
158
  // which is not a great source of randomness.
150
159
  // Borrowed from analytics.js (https://github.com/segment-integrations/analytics.js-integration-segmentio/blob/a20d2a2d222aeb3ab2a8c7e72280f1df2618440e/lib/index.js#L255-L256).
@@ -154,7 +163,7 @@ function enqueue(type, message) {
154
163
  }
155
164
  messageBatch.push(message);
156
165
  }
157
- // very barebones implemention...
166
+ // very barebones implementation...
158
167
  // does not support multiple concurrent flushes or large numbers of messages
159
168
  async function flushAsync() {
160
169
  if (utils_env.env.EXPO_NO_TELEMETRY)
@@ -180,7 +189,7 @@ async function flushAsync() {
180
189
  await fetch(analyticsEndpoint, request);
181
190
  }
182
191
  catch {
183
- // supress errors - likely due to network connectivity or endpoint health
192
+ // suppress errors - likely due to network connectivity or endpoint health
184
193
  }
185
194
  // clear array so we don't resend events in subsequent flushes
186
195
  messageBatch.splice(0, messageBatch.length);
@@ -197,7 +206,7 @@ function getAnalyticsContext() {
197
206
  return {
198
207
  os: { name: platform, version: external_os_default().release() },
199
208
  device: { type: platform, model: platform },
200
- app: { name: library, version: packageJSON.version },
209
+ app: { name: library, version: getPackageJson()?.version ?? undefined },
201
210
  };
202
211
  }
203
212
  //#endregion
@@ -208,7 +217,7 @@ function uuidv4() {
208
217
  return external_crypto_default().randomUUID();
209
218
  }
210
219
  catch {
211
- // supress errors due to node 13 or less not having randomUUID
220
+ // suppress errors due to node 13 or less not having randomUUID
212
221
  return null;
213
222
  }
214
223
  }
@@ -229,14 +238,14 @@ async function getAnalyticsIdentityAsync() {
229
238
  if (!external_fs_default().existsSync(getStateJsonPath())) {
230
239
  external_fs_default().writeFileSync(getStateJsonPath(), JSON.stringify({}));
231
240
  }
232
- const savedDeviceId = await JsonFile_default().getAsync(getStateJsonPath(), 'analyticsDeviceId', null);
241
+ const savedDeviceId = await JsonFile["default"].getAsync(getStateJsonPath(), 'analyticsDeviceId', null);
233
242
  const deviceId = savedDeviceId ?? uuidv4();
234
243
  if (!deviceId) {
235
244
  // unable to generate an id or load one from disk
236
245
  return null;
237
246
  }
238
247
  if (!savedDeviceId) {
239
- await JsonFile_default().setAsync(getStateJsonPath(), 'analyticsDeviceId', deviceId);
248
+ await JsonFile["default"].setAsync(getStateJsonPath(), 'analyticsDeviceId', deviceId);
240
249
  }
241
250
  const userId = getSession()?.userId ?? null;
242
251
  return userId ? { anonymousId: deviceId, userId } : { anonymousId: deviceId };
@@ -1,5 +1,5 @@
1
- exports.id = 223;
2
- exports.ids = [223];
1
+ exports.id = 870;
2
+ exports.ids = [870];
3
3
  exports.modules = {
4
4
 
5
5
  /***/ 2671:
@@ -11691,14 +11691,6 @@ function bisearch(ucs) {
11691
11691
  }
11692
11692
 
11693
11693
 
11694
- /***/ }),
11695
-
11696
- /***/ 392:
11697
- /***/ ((module) => {
11698
-
11699
- module.exports = eval("require")("../package.json");
11700
-
11701
-
11702
11694
  /***/ }),
11703
11695
 
11704
11696
  /***/ 9337:
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The partial GitHub content type, used to filter out examples.
3
+ * @see https://docs.github.com/en/rest/repos/contents?apiVersion=2022-11-28
4
+ */
5
+ export type GithubContent = {
6
+ name: string;
7
+ path: string;
8
+ type: 'file' | 'dir';
9
+ };
10
+ export type ExamplesMetadata = {
11
+ aliases: {
12
+ [key: string]: string | {
13
+ destination: string;
14
+ message?: string;
15
+ };
16
+ };
17
+ deprecated: {
18
+ [key: string]: {
19
+ outdatedExampleHref: string;
20
+ message?: string;
21
+ };
22
+ };
23
+ };
24
+ /** Fetch the metadata for the examples from https://github.com/expo/examples. This includes aliases and deprecated examples. */
25
+ export declare function fetchMetadataAsync(): Promise<ExamplesMetadata>;
26
+ export declare function ensureExampleExists(name: string): Promise<void>;
27
+ /** Ask the user which example to create */
28
+ export declare function promptExamplesAsync(): Promise<any>;
29
+ /**
30
+ * Download and move the selected example from https://github.com/expo/examples.
31
+ *
32
+ * If the example ships a `.create-expo.json`, its `renamePatterns`
33
+ * field overrides the default rename config used by the HelloWorld
34
+ * find-and-replace pass. The config file is read once and deleted from disk
35
+ * immediately so it can never leak into the user's project.
36
+ */
37
+ export declare function downloadAndExtractExampleAsync(root: string, name: string): Promise<void>;
38
+ export declare function sanitizeScriptsAsync(root: string): Promise<void>;
@@ -0,0 +1,98 @@
1
+ import ora from 'ora';
2
+ import type { PackageManagerName } from './resolvePackageManager';
3
+ export declare function isFolderNameForbidden(folderName: string): boolean;
4
+ export declare function resolvePackageModuleId(moduleId: string): {
5
+ readonly type: "repository";
6
+ readonly uri: import("url").URL;
7
+ } | {
8
+ readonly type: "file";
9
+ readonly uri: string;
10
+ } | {
11
+ readonly type: "npm";
12
+ readonly uri: string;
13
+ };
14
+ /**
15
+ * Extract a template app to a given file path and clean up any properties left over from npm to
16
+ * prepare it for usage.
17
+ *
18
+ * If the template ships a `.create-expo.json`, its `renamePatterns`
19
+ * field overrides the default rename config used by the HelloWorld
20
+ * find-and-replace pass. The config file is read once and deleted from disk
21
+ * immediately so it can never leak into the user's project.
22
+ */
23
+ export declare function extractAndPrepareTemplateAppAsync(projectRoot: string, { npmPackage }: {
24
+ npmPackage?: string | null;
25
+ }): Promise<string>;
26
+ /**
27
+ * # Background
28
+ *
29
+ * `@expo/cli` and `create-expo` extract a template from a tarball (whether from
30
+ * a local npm project or a GitHub repository), but these templates have a
31
+ * static name that needs to be updated to match whatever app name the user
32
+ * specified.
33
+ *
34
+ * By convention, the app name of all templates is "HelloWorld". During
35
+ * extraction, filepaths are transformed via `createEntryRenamer()` in
36
+ * `createFileTransform.ts`, but the contents of files are left untouched.
37
+ * Technically, the contents used to be transformed during extraction as well,
38
+ * but due to poor configurability, we've moved to a post-extraction approach.
39
+ *
40
+ * # The new approach: Renaming the app post-extraction
41
+ *
42
+ * In this new approach, we take a list of file patterns, otherwise known as the
43
+ * "rename config" to determine explicitly which files – relative to the root of
44
+ * the template – to perform find-and-replace on, to update the app name.
45
+ *
46
+ * ## The rename config
47
+ *
48
+ * The rename config can be passed directly as a string array to
49
+ * `getTemplateFilesToRenameAsync()`.
50
+ *
51
+ * The file patterns are formatted as glob expressions to be interpreted by
52
+ * [glob](https://github.com/isaacs/node-glob). Comments are supported with
53
+ * the `#` symbol, both in the plain-text file and string array formats.
54
+ * Whitespace is trimmed and whitespace-only lines are ignored.
55
+ *
56
+ * If no rename config has been passed directly to
57
+ * `getTemplateFilesToRenameAsync()`, then this default
58
+ * rename config will be used instead.
59
+ */
60
+ export declare const defaultRenameConfig: readonly ["!**/node_modules", "app.json", "android/**/*.gradle", "android/app/BUCK", "android/app/src/**/*.java", "android/app/src/**/*.kt", "android/app/src/**/*.xml", "ios/Podfile", "ios/**/*.xcodeproj/project.pbxproj", "ios/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme", "ios/**/*.xcworkspace/contents.xcworkspacedata", "macos/Podfile", "macos/**/*.xcodeproj/project.pbxproj", "macos/**/*.xcodeproj/xcshareddata/xcschemes/*.xcscheme", "macos/**/*.xcworkspace/contents.xcworkspacedata"];
61
+ /**
62
+ * Returns a list of files within a template matched by the resolved rename
63
+ * config.
64
+ *
65
+ * The rename config is resolved in the order of preference:
66
+ * Config provided as function param > defaultRenameConfig
67
+ */
68
+ export declare function getTemplateFilesToRenameAsync({ cwd,
69
+ /**
70
+ * An array of patterns following the rename config format. If omitted, then
71
+ * we fall back to defaultRenameConfig.
72
+ * @see defaultRenameConfig
73
+ */
74
+ renameConfig: userConfig, }: {
75
+ cwd: string;
76
+ renameConfig?: string[];
77
+ }): Promise<string[]>;
78
+ export declare function renameTemplateAppNameAsync({ cwd, name, files, }: {
79
+ cwd: string;
80
+ name: string;
81
+ /**
82
+ * An array of files to transform. Usually provided by calling
83
+ * getTemplateFilesToRenameAsync().
84
+ * @see getTemplateFilesToRenameAsync
85
+ */
86
+ files: string[];
87
+ }): Promise<void>;
88
+ /**
89
+ * Sanitize a template (or example) with expected `package.json` properties and files.
90
+ */
91
+ export declare function sanitizeTemplateAsync(projectRoot: string): Promise<void>;
92
+ export declare function validateName(name?: string): string | true;
93
+ export declare function logProjectReady({ cdPath, packageManager, }: {
94
+ cdPath: string;
95
+ packageManager: PackageManagerName;
96
+ }): void;
97
+ export declare function installPodsAsync(projectRoot: string): Promise<boolean>;
98
+ export declare function logNewSection(title: string): ora.Ora;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const asMock: <T extends (...args: any[]) => any>(fn: T) => jest.MockedFunction<T>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/build/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import type { PackageManagerName } from './resolvePackageManager';
2
+ export declare const PNPM_WORKSPACE_FILENAME = "pnpm-workspace.yaml";
3
+ /**
4
+ * Normalize a monorepo template's workspace-package dependency specs to the
5
+ * chosen package manager's convention, and — for pnpm — write a
6
+ * `pnpm-workspace.yaml` listing the workspace packages so they're picked up
7
+ * regardless of the root `package.json` `workspaces` field.
8
+ */
9
+ export declare function configureWorkspacesAsync(projectRoot: string, packageManager: PackageManagerName): Promise<void>;
@@ -0,0 +1,11 @@
1
+ import type { PackageManagerName } from './resolvePackageManager';
2
+ export type Options = {
3
+ install: boolean;
4
+ template?: string | true;
5
+ example?: string | true;
6
+ yes: boolean;
7
+ agentsMd: boolean;
8
+ };
9
+ export declare function setupDependenciesAsync(projectRoot: string, props: Pick<Options, 'install'>): Promise<void>;
10
+ export declare function createAsync(inputPath: string, options: Options): Promise<void>;
11
+ export declare function logNodeInstallWarning(cdPath: string, packageManager: PackageManagerName, needsPods: boolean): void;
@@ -0,0 +1,38 @@
1
+ export declare const CREATE_EXPO_CONFIG_NAME = ".create-expo.json";
2
+ /**
3
+ * Per-template configuration for customized behavior in `create-expo`.
4
+ * Templates that need any of these knobs can ship a
5
+ * `.create-expo.json` file at the template root; it is read once at
6
+ * project creation time and then deleted from the user's project so it
7
+ * doesn't leak into their repo.
8
+ */
9
+ export interface CreateExpoConfig {
10
+ /**
11
+ * Glob patterns (relative to the project root) listing extra files that
12
+ * should be passed through the `HelloWorld` find-and-replace pass during
13
+ * project creation. When present, this REPLACES the default rename config
14
+ * (see Template.ts `defaultRenameConfig`) — useful for monorepo templates
15
+ * that need to reach inside per-app paths like `apps/*\/android/**\/build.gradle`.
16
+ */
17
+ renamePatterns?: string[];
18
+ }
19
+ /**
20
+ * Read `.create-expo.json` from the project root and immediately
21
+ * delete the file from disk so it doesn't leak into the user's project.
22
+ * Returns the parsed config (or `undefined` if there's no file / it's
23
+ * malformed). This is the "use it once" entry point that template-extraction
24
+ * code paths should call — every downstream consumer takes the parsed
25
+ * object in memory.
26
+ */
27
+ export declare function consumeMonorepoConfigAsync(projectRoot: string): Promise<CreateExpoConfig | undefined>;
28
+ /**
29
+ * Reads `.create-expo.json` from the project root without touching
30
+ * the file. Returns `undefined` if the file is missing, unreadable, or
31
+ * malformed — a missing file is the common case (single-app templates) and
32
+ * shouldn't warn.
33
+ *
34
+ * Prefer `consumeMonorepoConfigAsync` for the create-expo flow so the
35
+ * template-only config doesn't leak into the user's project. This function
36
+ * stays exported for tests and any other read-only callers.
37
+ */
38
+ export declare function loadMonorepoConfigAsync(projectRoot: string): Promise<CreateExpoConfig | undefined>;
@@ -0,0 +1,5 @@
1
+ import { TarTypeFlag } from 'multitars';
2
+ import picomatch from 'picomatch';
3
+ export declare function sanitizedName(name: string): string;
4
+ export declare function createEntryRenamer(name: string): (input: string, typeflag: TarTypeFlag) => string;
5
+ export declare function createGlobFilter(globPattern: picomatch.Glob, options?: picomatch.PicomatchOptions): (path: string) => boolean;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A custom error class that is used to surface a `process.exit` event to a higher
3
+ * level where it can be tracked through telemetry asynchronously, before exiting.
4
+ */
5
+ export declare class ExitError extends Error {
6
+ cause: string | Error;
7
+ code: number;
8
+ constructor(cause: string | Error, code: number);
9
+ }
@@ -0,0 +1 @@
1
+ export declare function generateAgentFiles(root: string): Promise<void>;
@@ -0,0 +1 @@
1
+ export {};