create-expo 3.6.11 → 3.6.13

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 = 396;
3
- exports.ids = [396,178];
2
+ exports.id = 303;
3
+ exports.ids = [303,178];
4
4
  exports.modules = {
5
5
 
6
- /***/ 1396:
6
+ /***/ 4303:
7
7
  /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
8
8
 
9
9
 
@@ -29,25 +29,22 @@ var JsonFile_default = /*#__PURE__*/__webpack_require__.n(JsonFile);
29
29
  // EXTERNAL MODULE: ../../node_modules/prompts/index.js
30
30
  var prompts = __webpack_require__(2171);
31
31
  var prompts_default = /*#__PURE__*/__webpack_require__.n(prompts);
32
- // EXTERNAL MODULE: external "stream"
33
- var external_stream_ = __webpack_require__(2203);
34
- // EXTERNAL MODULE: ../../node_modules/tar/dist/esm/index.js + 33 modules
35
- var esm = __webpack_require__(3124);
36
- // EXTERNAL MODULE: external "util"
37
- var external_util_ = __webpack_require__(9023);
38
32
  // EXTERNAL MODULE: ../@expo/package-manager/build/index.js
39
33
  var build = __webpack_require__(54);
40
- // EXTERNAL MODULE: ../../node_modules/glob/dist/esm/index.js + 16 modules
41
- var dist_esm = __webpack_require__(398);
34
+ // EXTERNAL MODULE: ../../node_modules/glob/dist/esm/index.js + 17 modules
35
+ var esm = __webpack_require__(7314);
42
36
  // EXTERNAL MODULE: ../../node_modules/ora/index.js
43
37
  var ora = __webpack_require__(6524);
44
38
  var ora_default = /*#__PURE__*/__webpack_require__.n(ora);
39
+ // EXTERNAL MODULE: ../../node_modules/multitars/dist/multitars.mjs
40
+ var multitars = __webpack_require__(6471);
45
41
  // EXTERNAL MODULE: ./node_modules/picomatch/index.js
46
42
  var picomatch = __webpack_require__(8545);
47
43
  var picomatch_default = /*#__PURE__*/__webpack_require__.n(picomatch);
48
44
  ;// CONCATENATED MODULE: ./src/createFileTransform.ts
49
45
 
50
46
 
47
+
51
48
  const debug = __webpack_require__(7674)('expo:init:fileTransform');
52
49
  function sanitizedName(name) {
53
50
  return name
@@ -58,38 +55,34 @@ function sanitizedName(name) {
58
55
  // Directories that can be added to the template with an underscore instead of a dot, e.g. `.vscode` and be added with `_vscode`.
59
56
  const SUPPORTED_DIRECTORIES = ['eas', 'vscode', 'github', 'cursor'];
60
57
  const SUPPORTED_DIRECTORIES_PATTERN = new RegExp(`(^|/|\\\\)_(${SUPPORTED_DIRECTORIES.join('|')})(/|\\\\|$)`);
61
- function applyNameDuringPipe(entry, name) {
62
- if (name) {
63
- // Rewrite paths for bare workflow
64
- entry.path = entry.path
65
- .replace(/HelloWorld/g, entry.path.includes('android') ? sanitizedName(name.toLowerCase()) : sanitizedName(name))
66
- .replace(/helloworld/g, sanitizedName(name).toLowerCase());
67
- }
68
- return entry;
69
- }
70
- const ENTRY_FILE_PATTERN = /^file$/i;
71
- const ENTRY_FILE_OR_DIRECTORY_PATTERN = /^(file|directory)$/i;
72
- function modifyFileDuringPipe(entry) {
73
- if (!entry.type)
74
- return entry;
75
- if (ENTRY_FILE_PATTERN.test(entry.type) && external_path_default().basename(entry.path) === 'gitignore') {
76
- // Rename `gitignore` because npm ignores files named `.gitignore` when publishing.
77
- // See: https://github.com/npm/npm/issues/1862
78
- entry.path = entry.path.replace(/gitignore$/, '.gitignore');
79
- }
80
- if (ENTRY_FILE_OR_DIRECTORY_PATTERN.test(entry.type)) {
58
+ function renameDirectories(input, typeflag) {
59
+ if (typeflag === multitars/* TarTypeFlag */.Aq.FILE || typeflag === multitars/* TarTypeFlag */.Aq.DIRECTORY) {
81
60
  // Detect if the file contains one of the supported directories
82
61
  // and rename it to the correct format.
83
62
  // For example, if the file is `_vscode`, we want to rename it to `.vscode`.
84
- // Match one instance of the supported directory name, starting with an underscore, and containing slashes on both sides.
85
- entry.path = entry.path.replace(SUPPORTED_DIRECTORIES_PATTERN, (match, p1, p2, p3) => `${p1}.${p2}${p3}`);
63
+ input = input.replace(SUPPORTED_DIRECTORIES_PATTERN, (match, p1, p2, p3) => `${p1}.${p2}${p3}`);
64
+ }
65
+ return input;
66
+ }
67
+ function renameConfigs(input, typeflag) {
68
+ if (typeflag === multitars/* TarTypeFlag */.Aq.FILE && external_path_default().basename(input) === 'gitignore') {
69
+ // Rename `gitignore` because npm ignores files named `.gitignore` when publishing.
70
+ // See: https://github.com/npm/npm/issues/1862
71
+ input = input.replace(/gitignore$/, '.gitignore');
86
72
  }
87
- return entry;
73
+ return input;
88
74
  }
89
- function createEntryResolver(name) {
90
- return (entry) => {
91
- applyNameDuringPipe(entry, name);
92
- modifyFileDuringPipe(entry);
75
+ function createEntryRenamer(name) {
76
+ return (input, typeflag) => {
77
+ if (name) {
78
+ // Rewrite paths for bare workflow
79
+ input = input
80
+ .replace(/HelloWorld/g, input.includes('android') ? sanitizedName(name.toLowerCase()) : sanitizedName(name))
81
+ .replace(/helloworld/g, sanitizedName(name).toLowerCase());
82
+ }
83
+ input = renameConfigs(input, typeflag);
84
+ input = renameDirectories(input, typeflag);
85
+ return input;
93
86
  };
94
87
  }
95
88
  function createGlobFilter(globPattern, options) {
@@ -136,6 +129,139 @@ var spawnAsync_default = /*#__PURE__*/__webpack_require__.n(spawnAsync);
136
129
  // EXTERNAL MODULE: external "os"
137
130
  var external_os_ = __webpack_require__(857);
138
131
  var external_os_default = /*#__PURE__*/__webpack_require__.n(external_os_);
132
+ // EXTERNAL MODULE: external "stream"
133
+ var external_stream_ = __webpack_require__(2203);
134
+ // EXTERNAL MODULE: external "node:crypto"
135
+ var external_node_crypto_ = __webpack_require__(7598);
136
+ var external_node_crypto_default = /*#__PURE__*/__webpack_require__.n(external_node_crypto_);
137
+ // EXTERNAL MODULE: external "node:fs"
138
+ var external_node_fs_ = __webpack_require__(3024);
139
+ var external_node_fs_default = /*#__PURE__*/__webpack_require__.n(external_node_fs_);
140
+ // EXTERNAL MODULE: external "node:path"
141
+ var external_node_path_ = __webpack_require__(6760);
142
+ var external_node_path_default = /*#__PURE__*/__webpack_require__.n(external_node_path_);
143
+ // EXTERNAL MODULE: external "node:stream"
144
+ var external_node_stream_ = __webpack_require__(7075);
145
+ ;// CONCATENATED MODULE: ./src/utils/tar.ts
146
+ // NOTE(@kitten): Based on @expo/cli/src/utils/tar.ts
147
+ // Keep in sync with that version of this module
148
+
149
+
150
+
151
+
152
+
153
+ // Modified:
154
+ const tar_debug = __webpack_require__(7674)('create-expo:tar');
155
+ class ChecksumStream extends TransformStream {
156
+ hash;
157
+ constructor(algorithm) {
158
+ super({
159
+ transform: (chunk, controller) => {
160
+ this.hash.update(chunk);
161
+ controller.enqueue(chunk);
162
+ },
163
+ });
164
+ this.hash = external_node_crypto_default().createHash(algorithm);
165
+ }
166
+ digest(encoding) {
167
+ return this.hash.digest(encoding);
168
+ }
169
+ }
170
+ async function extractStream(input, output, options = {}) {
171
+ output = external_node_path_default().resolve(output);
172
+ await external_node_fs_default().promises.mkdir(output, { recursive: true });
173
+ const { checksumAlgorithm, strip = 0, rename, filter } = options;
174
+ const checksumStream = new ChecksumStream(checksumAlgorithm || 'md5');
175
+ const decompressionStream = new DecompressionStream('gzip');
176
+ const body = input.pipeThrough(checksumStream).pipeThrough(decompressionStream);
177
+ for await (const file of (0,multitars/* untar */.PJ)(body)) {
178
+ let name = external_node_path_default().normalize(file.name);
179
+ if (filter && !filter(name, file.typeflag)) {
180
+ tar_debug(`filtered: ${external_node_path_default().resolve(output, name)}`);
181
+ continue;
182
+ }
183
+ else if (rename) {
184
+ name = rename(name, file.typeflag) ?? name;
185
+ }
186
+ for (let idx = 0; idx < strip; idx++) {
187
+ const sepIdx = name.indexOf((external_node_path_default()).sep);
188
+ if (sepIdx > -1) {
189
+ name = name.slice(sepIdx + 1);
190
+ }
191
+ else {
192
+ break;
193
+ }
194
+ }
195
+ const resolved = external_node_path_default().resolve(output, name);
196
+ if (!resolved.startsWith(output)) {
197
+ tar_debug(`skip: ${resolved}`);
198
+ continue;
199
+ }
200
+ const parent = external_node_path_default().dirname(resolved);
201
+ if (parent !== output) {
202
+ let exists = false;
203
+ try {
204
+ const stat = await external_node_fs_default().promises.lstat(parent);
205
+ if (stat.isSymbolicLink() || (!stat.isDirectory() && !stat.isFile())) {
206
+ tar_debug(`skip: ${resolved}`);
207
+ continue;
208
+ }
209
+ else if (stat.isDirectory()) {
210
+ exists = true;
211
+ }
212
+ }
213
+ catch { }
214
+ if (!exists) {
215
+ tar_debug(`mkdir(p): ${parent}`);
216
+ await external_node_fs_default().promises.mkdir(parent, { recursive: true });
217
+ }
218
+ }
219
+ switch (file.typeflag) {
220
+ case multitars/* TarTypeFlag */.Aq.FILE:
221
+ tar_debug(`write(${file.mode.toString(8)}): ${resolved}`);
222
+ await external_node_fs_default().promises.writeFile(resolved, (0,multitars/* streamToAsyncIterable */.WT)(file.stream()), {
223
+ mode: file.mode,
224
+ });
225
+ break;
226
+ case multitars/* TarTypeFlag */.Aq.DIRECTORY:
227
+ tar_debug(`mkdir(${file.mode.toString(8)}): ${resolved}`);
228
+ try {
229
+ await external_node_fs_default().promises.mkdir(resolved, { mode: file.mode });
230
+ }
231
+ catch (error) {
232
+ if (error.code !== 'EEXIST') {
233
+ throw error;
234
+ }
235
+ }
236
+ break;
237
+ case multitars/* TarTypeFlag */.Aq.SYMLINK:
238
+ case multitars/* TarTypeFlag */.Aq.LINK: {
239
+ const target = external_node_path_default().resolve(parent, file.linkname ?? '');
240
+ if (!target.startsWith(output) || target === parent) {
241
+ tar_debug(`skip: ${resolved} -> ${target}`);
242
+ continue;
243
+ }
244
+ if (file.typeflag === multitars/* TarTypeFlag */.Aq.LINK) {
245
+ tar_debug(`link: ${resolved} -> ${target}`);
246
+ await external_node_fs_default().promises.link(target, resolved);
247
+ }
248
+ else {
249
+ const stat = await external_node_fs_default().promises.lstat(target).catch(() => null);
250
+ const type = stat?.isDirectory() ? 'dir' : 'file';
251
+ tar_debug(`symlink(${type}): ${resolved} -> ${target}`);
252
+ await external_node_fs_default().promises.symlink(target, resolved, type);
253
+ }
254
+ break;
255
+ }
256
+ }
257
+ }
258
+ return checksumStream.digest('hex');
259
+ }
260
+ /** Extract a tar using built-in tools if available and falling back on Node.js. */
261
+ async function extractAsync(input, output, options) {
262
+ await extractStream(Readable.toWeb(fs.createReadStream(input)), output, options);
263
+ }
264
+
139
265
  ;// CONCATENATED MODULE: ./src/legacyTemplates.ts
140
266
 
141
267
 
@@ -198,10 +324,7 @@ async function promptTemplateAsync() {
198
324
 
199
325
 
200
326
 
201
-
202
327
  const npm_debug = __webpack_require__(7674)('expo:init:npm');
203
- // @ts-ignore
204
- const pipeline = (0,external_util_.promisify)(external_stream_.Stream.pipeline);
205
328
  function getTemporaryCacheFilePath(subdir = 'template-cache') {
206
329
  // This is cleared when the device restarts
207
330
  return external_path_default().join(external_os_default().tmpdir(), '.create-expo-app', subdir);
@@ -264,22 +387,18 @@ function applyKnownNpmPackageNameRules(name) {
264
387
  .normalize('NFD')
265
388
  .replace(/[\u0300-\u036f]/g, '') || null);
266
389
  }
267
- async function extractLocalNpmTarballAsync(tarFilePath, props) {
268
- const readStream = external_fs_default().createReadStream(tarFilePath);
269
- await extractNpmTarballAsync(readStream, props);
390
+ /**
391
+ * Extracts a tarball stream to a directory.
392
+ */
393
+ async function extractNpmTarballAsync(stream, output, props) {
394
+ return await extractStream(stream, output, {
395
+ filter: props.filter,
396
+ rename: createEntryRenamer(props.expName),
397
+ strip: props.strip ?? 1,
398
+ });
270
399
  }
271
- async function extractNpmTarballAsync(stream, props) {
272
- if (!stream) {
273
- throw new Error('Missing stream');
274
- }
275
- const { cwd, strip, name, fileList = [], filter } = props;
276
- await external_fs_default().promises.mkdir(cwd, { recursive: true });
277
- await pipeline(stream, (0,esm/* extract */.o6)({
278
- cwd,
279
- filter,
280
- onentry: createEntryResolver(name),
281
- strip: strip ?? 1,
282
- }, fileList));
400
+ async function extractLocalNpmTarballAsync(tarFilePath, output, props) {
401
+ return await extractNpmTarballAsync(external_stream_.Readable.toWeb(external_fs_default().createReadStream(tarFilePath)), output, props);
283
402
  }
284
403
  async function npmPackAsync(packageName, cwd = undefined, ...props) {
285
404
  const npm = getNpmBin();
@@ -354,7 +473,7 @@ async function fileExistsAsync(path) {
354
473
  return false;
355
474
  }
356
475
  }
357
- async function downloadAndExtractNpmModuleAsync(npmName, props) {
476
+ async function downloadAndExtractNpmModuleAsync(npmName, output, props) {
358
477
  const cachePath = getTemporaryCacheFilePath();
359
478
  npm_debug(`Looking for NPM tarball (id: ${npmName}, cache: ${cachePath})`);
360
479
  await external_fs_default().promises.mkdir(cachePath, { recursive: true });
@@ -374,9 +493,8 @@ async function downloadAndExtractNpmModuleAsync(npmName, props) {
374
493
  throw error;
375
494
  }
376
495
  try {
377
- await extractLocalNpmTarballAsync(cacheFilename, {
378
- cwd: props.cwd,
379
- name: props.name,
496
+ return await extractLocalNpmTarballAsync(cacheFilename, output, {
497
+ expName: props.expName,
380
498
  });
381
499
  }
382
500
  catch (error) {
@@ -389,7 +507,6 @@ async function downloadAndExtractNpmModuleAsync(npmName, props) {
389
507
 
390
508
 
391
509
 
392
-
393
510
  const github_debug = __webpack_require__(7674)('expo:init:github');
394
511
  // See: https://github.com/expo/expo/blob/a5a6eecb082b2c7a7fc9956141738231c7df473f/packages/%40expo/cli/src/prebuild/resolveTemplate.ts#L60-L84
395
512
  async function getGitHubRepoAsync(url) {
@@ -423,7 +540,7 @@ async function isValidGitHubRepoAsync(repo) {
423
540
  return response.ok;
424
541
  }
425
542
  // See: https://github.com/expo/expo/blob/a5a6eecb082b2c7a7fc9956141738231c7df473f/packages/%40expo/cli/src/utils/npm.ts#L134-L139
426
- async function extractRemoteGitHubTarballAsync(url, repo, props) {
543
+ async function extractRemoteGitHubTarballAsync(url, repo, output, props) {
427
544
  const response = await fetch(url);
428
545
  if (!response.ok)
429
546
  throw new Error(`Unexpected response: ${response.statusText} (${url})`);
@@ -434,18 +551,20 @@ async function extractRemoteGitHubTarballAsync(url, repo, props) {
434
551
  // Remove the (sub)directory paths, and the root folder added by GitHub
435
552
  const strip = directory.length + 1;
436
553
  // Only extract the relevant (sub)directories, ignoring irrelevant files
437
- // The filder auto-ignores dotfiles, unless explicitly included
554
+ // The filter auto-ignores dotfiles, unless explicitly included
438
555
  const filter = createGlobFilter(!directory.length
439
556
  ? ['*/**', '*/ios/.xcode.env']
440
557
  : [`*/${directory.join('/')}/**`, `*/${directory.join('/')}/ios/.xcode.env`], {
441
558
  // Always ignore the `.xcworkspace` folder
442
559
  ignore: ['**/ios/*.xcworkspace/**'],
443
560
  });
444
- await extractNpmTarballAsync(
445
- // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65542
446
- external_stream_.Readable.fromWeb(response.body), { ...props, filter, strip });
561
+ return await extractNpmTarballAsync(response.body, output, {
562
+ ...props,
563
+ filter,
564
+ strip,
565
+ });
447
566
  }
448
- async function downloadAndExtractGitHubRepositoryAsync(repoUrl, props) {
567
+ async function downloadAndExtractGitHubRepositoryAsync(repoUrl, output, props) {
449
568
  github_debug('Looking for GitHub repository');
450
569
  const info = await getGitHubRepoAsync(repoUrl);
451
570
  const isValid = await isValidGitHubRepoAsync(info);
@@ -455,7 +574,7 @@ async function downloadAndExtractGitHubRepositoryAsync(repoUrl, props) {
455
574
  const url = `https://codeload.github.com/${info.owner}/${info.name}/tar.gz/${info.branch}`;
456
575
  github_debug('Resolved GitHub repository', info);
457
576
  github_debug('Downloading GitHub repository from:', url);
458
- await extractRemoteGitHubTarballAsync(url, info, props);
577
+ return await extractRemoteGitHubTarballAsync(url, info, output, props);
459
578
  }
460
579
 
461
580
  ;// CONCATENATED MODULE: ./src/Template.ts
@@ -562,16 +681,14 @@ async function extractAndPrepareTemplateAppAsync(projectRoot, { npmPackage }) {
562
681
  Template_debug(`Extracting template app (pkg: ${npmPackage}, projectName: ${projectName})`);
563
682
  const { type, uri } = resolvePackageModuleId(npmPackage || 'expo-template-default');
564
683
  if (type === 'repository') {
565
- await downloadAndExtractGitHubRepositoryAsync(uri, {
566
- cwd: projectRoot,
567
- name: projectName,
684
+ await downloadAndExtractGitHubRepositoryAsync(uri, projectRoot, {
685
+ expName: projectName,
568
686
  });
569
687
  }
570
688
  else {
571
689
  const resolvedUri = type === 'file' ? uri : getResolvedTemplateName(applyBetaTag(uri));
572
- await downloadAndExtractNpmModuleAsync(resolvedUri, {
573
- cwd: projectRoot,
574
- name: projectName,
690
+ await downloadAndExtractNpmModuleAsync(resolvedUri, projectRoot, {
691
+ expName: projectName,
575
692
  disableCache: type === 'file',
576
693
  });
577
694
  }
@@ -606,7 +723,7 @@ function escapeXMLCharacters(original) {
606
723
  * specified.
607
724
  *
608
725
  * By convention, the app name of all templates is "HelloWorld". During
609
- * extraction, filepaths are transformed via `createEntryResolver()` in
726
+ * extraction, filepaths are transformed via `createEntryRenamer()` in
610
727
  * `createFileTransform.ts`, but the contents of files are left untouched.
611
728
  * Technically, the contents used to be transformed during extraction as well,
612
729
  * but due to poor configurability, we've moved to a post-extraction approach.
@@ -669,7 +786,7 @@ renameConfig: userConfig, }) {
669
786
  let config = userConfig ?? defaultRenameConfig;
670
787
  // Strip comments, trim whitespace, and remove empty lines.
671
788
  config = config.map((line) => line.split(/(?<!\\)#/, 2)[0].trim()).filter((line) => line !== '');
672
- return await (0,dist_esm/* glob */.TI)(config, {
789
+ return await (0,esm/* glob */.TI)(config, {
673
790
  cwd,
674
791
  // `true` is consistent with .gitignore. Allows `*.xml` to match .xml files
675
792
  // in all subdirs.
@@ -892,11 +1009,7 @@ function logNewSection(title) {
892
1009
 
893
1010
 
894
1011
 
895
-
896
-
897
-
898
1012
  const Examples_debug = __webpack_require__(7674)('expo:init:template');
899
- const Examples_pipeline = (0,external_util_.promisify)(external_stream_.Stream.pipeline);
900
1013
  /** List all existing examples directory from https://github.com/expo/examples. */
901
1014
  async function listExamplesAsync() {
902
1015
  const response = await fetch('https://api.github.com/repos/expo/examples/contents');
@@ -963,13 +1076,12 @@ async function downloadAndExtractExampleAsync(root, name) {
963
1076
  Examples_debug(`Failed to fetch the examples code, Github responded without content, received status "${response.status}"`);
964
1077
  throw new Error('Failed to fetch the examples code from https://github.com/expo/examples');
965
1078
  }
966
- await Examples_pipeline(
967
- // @ts-expect-error see https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/65542
968
- external_stream_.Readable.fromWeb(response.body), (0,esm/* extract */.o6)({
969
- cwd: root,
970
- onentry: createEntryResolver(projectName),
1079
+ const prefix = `examples-master/${name}/`;
1080
+ await extractNpmTarballAsync(response.body, root, {
1081
+ expName: projectName,
971
1082
  strip: 2,
972
- }, [`examples-master/${name}`]));
1083
+ filter: (entryName) => entryName.startsWith(prefix),
1084
+ });
973
1085
  const files = await getTemplateFilesToRenameAsync({ cwd: root });
974
1086
  await renameTemplateAppNameAsync({
975
1087
  cwd: root,