create-expo-updates-server 0.1.0 → 0.1.4
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/README.md +19 -4
- package/dist/template/README.md +24 -10
- package/dist/template/app/api/admin/embedded-updates/route.test.ts +36 -1
- package/dist/template/app/api/admin/updates/route.test.ts +29 -1
- package/dist/template/app/updates/embedded/page.tsx +6 -2
- package/dist/template/app/updates/page.tsx +6 -2
- package/dist/template/docs/expo-app-setup.md +14 -3
- package/dist/template/docs/getting-started.md +12 -7
- package/dist/template/docs/getting-started.ru.md +13 -6
- package/dist/template/docs/index.md +22 -3
- package/dist/template/docs/migrations/2026-09-01-app-version-columns.sql +23 -0
- package/dist/template/docs/migrations/schema.sql +22 -0
- package/dist/template/docs/npm-installer.md +68 -18
- package/dist/template/package-lock.json +2 -67
- package/dist/template/package.json +1 -1
- package/dist/template/scripts/configure-expo-app.mjs +6 -0
- package/dist/template/scripts/lib/embedded-update-registrar.test.ts +383 -3
- package/dist/template/scripts/lib/expo-app-configurator.mjs +165 -9
- package/dist/template/scripts/lib/expo-app-configurator.test.ts +658 -9
- package/dist/template/src/client/admin-types.ts +2 -0
- package/dist/template/src/server/lib/admin-embedded-updates.test.ts +57 -0
- package/dist/template/src/server/lib/admin-embedded-updates.ts +42 -25
- package/dist/template/src/server/lib/admin-updates.test.ts +61 -0
- package/dist/template/src/server/lib/admin-updates.ts +23 -3
- package/dist/template/templates/expo-app/ci_scripts/ci_post_xcodebuild.sh +23 -1
- package/dist/template/templates/expo-app/plugins/with-ota-embedded-registration.js +13 -4
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/index.mjs +53 -7
- package/dist/template/templates/expo-app/scripts/ota-register-embedded/register-ios.sh +87 -0
- package/dist/template-manifest.json +70 -55
- package/lib/cli.mjs +252 -23
- package/package.json +1 -1
- package/dist/template/templates/expo-app/ci_scripts/register-embedded-update.sh +0 -36
- /package/dist/template/templates/expo-app/scripts/ota-register-embedded/{android-register-embedded-update.sh → register-android.sh} +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"installerVersion": "0.1.
|
|
4
|
-
"sourceCommit": "
|
|
5
|
-
"totalSize":
|
|
3
|
+
"installerVersion": "0.1.4",
|
|
4
|
+
"sourceCommit": "1793479d3a0719441eb39909beb1fde2b35829a7",
|
|
5
|
+
"totalSize": 954054,
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"path": ".env.docker.example",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
},
|
|
43
43
|
{
|
|
44
44
|
"path": "app/api/admin/embedded-updates/route.test.ts",
|
|
45
|
-
"size":
|
|
46
|
-
"sha256": "
|
|
45
|
+
"size": 3925,
|
|
46
|
+
"sha256": "85f52b58200d16bd9be05d31724bb63971da04713d9035d57a820668d225afae"
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
49
|
"path": "app/api/admin/embedded-updates/route.ts",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
},
|
|
108
108
|
{
|
|
109
109
|
"path": "app/api/admin/updates/route.test.ts",
|
|
110
|
-
"size":
|
|
111
|
-
"sha256": "
|
|
110
|
+
"size": 4619,
|
|
111
|
+
"sha256": "197c1583ee537091b0732acf957b1c05569d71efeb6d5072c4e413ab2d4e86fd"
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"path": "app/api/admin/updates/route.ts",
|
|
@@ -172,8 +172,8 @@
|
|
|
172
172
|
},
|
|
173
173
|
{
|
|
174
174
|
"path": "app/updates/embedded/page.tsx",
|
|
175
|
-
"size":
|
|
176
|
-
"sha256": "
|
|
175
|
+
"size": 6334,
|
|
176
|
+
"sha256": "758f1e6dfa35ec741da6a17d83cb33d1bac4ea2345ba8de00c3673ea5110b4ed"
|
|
177
177
|
},
|
|
178
178
|
{
|
|
179
179
|
"path": "app/updates/emergency-redirects/page.tsx",
|
|
@@ -187,8 +187,8 @@
|
|
|
187
187
|
},
|
|
188
188
|
{
|
|
189
189
|
"path": "app/updates/page.tsx",
|
|
190
|
-
"size":
|
|
191
|
-
"sha256": "
|
|
190
|
+
"size": 12099,
|
|
191
|
+
"sha256": "a3fc384cb9c38060d975dee2705f506c4c4387a68d2cee865438044885b9c4ab"
|
|
192
192
|
},
|
|
193
193
|
{
|
|
194
194
|
"path": "docker-compose.yml",
|
|
@@ -202,33 +202,38 @@
|
|
|
202
202
|
},
|
|
203
203
|
{
|
|
204
204
|
"path": "docs/expo-app-setup.md",
|
|
205
|
-
"size":
|
|
206
|
-
"sha256": "
|
|
205
|
+
"size": 15130,
|
|
206
|
+
"sha256": "3fe56c7335ea32f779afe2019da6f1f1b290af0f973d12c0e0ce9df8ee80368a"
|
|
207
207
|
},
|
|
208
208
|
{
|
|
209
209
|
"path": "docs/getting-started.md",
|
|
210
|
-
"size":
|
|
211
|
-
"sha256": "
|
|
210
|
+
"size": 14692,
|
|
211
|
+
"sha256": "9f8c4c8abb2715c4e2c49f89ff7eb9c485c02916083e3ca73f9391657c059d47"
|
|
212
212
|
},
|
|
213
213
|
{
|
|
214
214
|
"path": "docs/getting-started.ru.md",
|
|
215
|
-
"size":
|
|
216
|
-
"sha256": "
|
|
215
|
+
"size": 24702,
|
|
216
|
+
"sha256": "5b986ea1bc59652fa3d819ae1b7ae4f15df1bbc8eedda95501eb4eb90bda2a05"
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
"path": "docs/index.md",
|
|
220
|
-
"size":
|
|
221
|
-
"sha256": "
|
|
220
|
+
"size": 2684,
|
|
221
|
+
"sha256": "7251091b1835ba1f2804c664791093356ff9bccff689a99405cf64220531260d"
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"path": "docs/migrations/2026-09-01-app-version-columns.sql",
|
|
225
|
+
"size": 720,
|
|
226
|
+
"sha256": "73a301595ede6487001f66ff18e12819ce5a587a6f6bb7ab4bd12b8640b65b9c"
|
|
222
227
|
},
|
|
223
228
|
{
|
|
224
229
|
"path": "docs/migrations/schema.sql",
|
|
225
|
-
"size":
|
|
226
|
-
"sha256": "
|
|
230
|
+
"size": 13072,
|
|
231
|
+
"sha256": "8296b11a037056a4133bab08367b1289d45ef8a70fd2b481cab2bc4ffd4fba47"
|
|
227
232
|
},
|
|
228
233
|
{
|
|
229
234
|
"path": "docs/npm-installer.md",
|
|
230
|
-
"size":
|
|
231
|
-
"sha256": "
|
|
235
|
+
"size": 5139,
|
|
236
|
+
"sha256": "3e424664a94423614ee08c078ae46d3e61565860db5192d9ba23baa1061b5723"
|
|
232
237
|
},
|
|
233
238
|
{
|
|
234
239
|
"path": "docs/operations-guide.md",
|
|
@@ -262,13 +267,13 @@
|
|
|
262
267
|
},
|
|
263
268
|
{
|
|
264
269
|
"path": "package-lock.json",
|
|
265
|
-
"size":
|
|
266
|
-
"sha256": "
|
|
270
|
+
"size": 427507,
|
|
271
|
+
"sha256": "db4f4e6254d29174a27371c3e3e69edd5c932fa7e110687af94b6e27e68b0c32"
|
|
267
272
|
},
|
|
268
273
|
{
|
|
269
274
|
"path": "package.json",
|
|
270
275
|
"size": 1465,
|
|
271
|
-
"sha256": "
|
|
276
|
+
"sha256": "7947e4f35c275dab7f5af095dbf2e75c8391c2b56ceda715c8e83a06657c62f7"
|
|
272
277
|
},
|
|
273
278
|
{
|
|
274
279
|
"path": "postcss.config.mjs",
|
|
@@ -302,13 +307,13 @@
|
|
|
302
307
|
},
|
|
303
308
|
{
|
|
304
309
|
"path": "README.md",
|
|
305
|
-
"size":
|
|
306
|
-
"sha256": "
|
|
310
|
+
"size": 20197,
|
|
311
|
+
"sha256": "bcd92d31e9870ba7085e494ee259ace50c863b2e98582a932f575ca9d6345e29"
|
|
307
312
|
},
|
|
308
313
|
{
|
|
309
314
|
"path": "scripts/configure-expo-app.mjs",
|
|
310
|
-
"size":
|
|
311
|
-
"sha256": "
|
|
315
|
+
"size": 4361,
|
|
316
|
+
"sha256": "84a9d437c47fb603fdd01431444a1933d7b63cf501c8a4d2db240d12ae0a6a9d"
|
|
312
317
|
},
|
|
313
318
|
{
|
|
314
319
|
"path": "scripts/create-access-token.mjs",
|
|
@@ -327,18 +332,18 @@
|
|
|
327
332
|
},
|
|
328
333
|
{
|
|
329
334
|
"path": "scripts/lib/embedded-update-registrar.test.ts",
|
|
330
|
-
"size":
|
|
331
|
-
"sha256": "
|
|
335
|
+
"size": 13451,
|
|
336
|
+
"sha256": "5647480e8f6171bc1c22b8ed27f71c5a6fb5b24b6462d3a9a6acd4589b651aaa"
|
|
332
337
|
},
|
|
333
338
|
{
|
|
334
339
|
"path": "scripts/lib/expo-app-configurator.mjs",
|
|
335
|
-
"size":
|
|
336
|
-
"sha256": "
|
|
340
|
+
"size": 22581,
|
|
341
|
+
"sha256": "d92242a75f46f04279467e513df3ff49fecfc6079b29c6f04544eb48c5ebb1e1"
|
|
337
342
|
},
|
|
338
343
|
{
|
|
339
344
|
"path": "scripts/lib/expo-app-configurator.test.ts",
|
|
340
|
-
"size":
|
|
341
|
-
"sha256": "
|
|
345
|
+
"size": 31644,
|
|
346
|
+
"sha256": "70f94f613b3802516fadf0bc98616461311c2068361497f2684b4a0aa15e43e2"
|
|
342
347
|
},
|
|
343
348
|
{
|
|
344
349
|
"path": "scripts/lib/expo-app-prompts.mjs",
|
|
@@ -377,8 +382,8 @@
|
|
|
377
382
|
},
|
|
378
383
|
{
|
|
379
384
|
"path": "src/client/admin-types.ts",
|
|
380
|
-
"size":
|
|
381
|
-
"sha256": "
|
|
385
|
+
"size": 2147,
|
|
386
|
+
"sha256": "fe11f89faac941de81db07b47624e74a08554a05da4e5cb9c7d4c86a65a67cdc"
|
|
382
387
|
},
|
|
383
388
|
{
|
|
384
389
|
"path": "src/client/logout-button.tsx",
|
|
@@ -420,15 +425,25 @@
|
|
|
420
425
|
"size": 5167,
|
|
421
426
|
"sha256": "d5e09c7f0823ac6f95eddc21a63f34bb930ea1f84a4a03735aaabbdf9a929cc8"
|
|
422
427
|
},
|
|
428
|
+
{
|
|
429
|
+
"path": "src/server/lib/admin-embedded-updates.test.ts",
|
|
430
|
+
"size": 1618,
|
|
431
|
+
"sha256": "c3e6e34677a48c978df47c7e1bd890ca5fb3eca958b7d0b0f8486fb2c757a83a"
|
|
432
|
+
},
|
|
423
433
|
{
|
|
424
434
|
"path": "src/server/lib/admin-embedded-updates.ts",
|
|
425
|
-
"size":
|
|
426
|
-
"sha256": "
|
|
435
|
+
"size": 4647,
|
|
436
|
+
"sha256": "edbff82b6ea789d97cae39ed84950eb99d381879061acbd18839ad19e289413c"
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
"path": "src/server/lib/admin-updates.test.ts",
|
|
440
|
+
"size": 1831,
|
|
441
|
+
"sha256": "72b865426c66f363bde665f67106b0f6d52f5cc84dae462907cb8664635a0c99"
|
|
427
442
|
},
|
|
428
443
|
{
|
|
429
444
|
"path": "src/server/lib/admin-updates.ts",
|
|
430
|
-
"size":
|
|
431
|
-
"sha256": "
|
|
445
|
+
"size": 35861,
|
|
446
|
+
"sha256": "767aedc6c6acbac6e7c885d92136605e26d469402f24eb55dd3d707935e7b440"
|
|
432
447
|
},
|
|
433
448
|
{
|
|
434
449
|
"path": "src/server/lib/common.js",
|
|
@@ -492,18 +507,13 @@
|
|
|
492
507
|
},
|
|
493
508
|
{
|
|
494
509
|
"path": "templates/expo-app/ci_scripts/ci_post_xcodebuild.sh",
|
|
495
|
-
"size":
|
|
496
|
-
"sha256": "
|
|
497
|
-
},
|
|
498
|
-
{
|
|
499
|
-
"path": "templates/expo-app/ci_scripts/register-embedded-update.sh",
|
|
500
|
-
"size": 1006,
|
|
501
|
-
"sha256": "21e4a557a49feb40bbc391db5d44c64962fdb7d9db86394c477379861e571116"
|
|
510
|
+
"size": 982,
|
|
511
|
+
"sha256": "6b6cade2dd4f71c3c860e785c99f105e19243f5fd15c462c1de5d0acf98bb808"
|
|
502
512
|
},
|
|
503
513
|
{
|
|
504
514
|
"path": "templates/expo-app/plugins/with-ota-embedded-registration.js",
|
|
505
|
-
"size":
|
|
506
|
-
"sha256": "
|
|
515
|
+
"size": 1259,
|
|
516
|
+
"sha256": "41cbfeca685341bd915040287cceb33b02713eb2ce57f111827333cc6892f01d"
|
|
507
517
|
},
|
|
508
518
|
{
|
|
509
519
|
"path": "templates/expo-app/scripts/ota-publish/api/database-client.mjs",
|
|
@@ -541,14 +551,19 @@
|
|
|
541
551
|
"sha256": "e076ef7cb51f7361794f42480bc1f698581ff62e4c8fd02495a7d1df62fffb4e"
|
|
542
552
|
},
|
|
543
553
|
{
|
|
544
|
-
"path": "templates/expo-app/scripts/ota-register-embedded/
|
|
554
|
+
"path": "templates/expo-app/scripts/ota-register-embedded/index.mjs",
|
|
555
|
+
"size": 8412,
|
|
556
|
+
"sha256": "6d2201f51851d9af41449f8da3653a4792cddb30d411d59e3c161adbc5cf76ff"
|
|
557
|
+
},
|
|
558
|
+
{
|
|
559
|
+
"path": "templates/expo-app/scripts/ota-register-embedded/register-android.sh",
|
|
545
560
|
"size": 595,
|
|
546
561
|
"sha256": "45a0fddd24600d109359e90ea1f347c70b411307ec232beba22dd71d8c369fe4"
|
|
547
562
|
},
|
|
548
563
|
{
|
|
549
|
-
"path": "templates/expo-app/scripts/ota-register-embedded/
|
|
550
|
-
"size":
|
|
551
|
-
"sha256": "
|
|
564
|
+
"path": "templates/expo-app/scripts/ota-register-embedded/register-ios.sh",
|
|
565
|
+
"size": 2579,
|
|
566
|
+
"sha256": "abe5844ea519b322de6e9b57a109da273f0f89b24a81ac6f9767e0780f4ec272"
|
|
552
567
|
},
|
|
553
568
|
{
|
|
554
569
|
"path": "tsconfig.json",
|
package/lib/cli.mjs
CHANGED
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
readFile,
|
|
10
10
|
readdir,
|
|
11
11
|
rename,
|
|
12
|
+
rmdir,
|
|
13
|
+
unlink,
|
|
12
14
|
} from "node:fs/promises";
|
|
13
15
|
import path from "node:path";
|
|
14
16
|
import { fileURLToPath } from "node:url";
|
|
@@ -32,7 +34,8 @@ Options:
|
|
|
32
34
|
-h, --help Show this help
|
|
33
35
|
-v, --version Show the package version
|
|
34
36
|
|
|
35
|
-
The target path must not already exist.
|
|
37
|
+
The target path must not already exist, unless it is "." and the current
|
|
38
|
+
directory is empty.
|
|
36
39
|
`;
|
|
37
40
|
|
|
38
41
|
function cliError(message) {
|
|
@@ -261,6 +264,25 @@ async function assertTargetAbsent(target) {
|
|
|
261
264
|
throw cliError(`Target path already exists: ${target}`);
|
|
262
265
|
}
|
|
263
266
|
|
|
267
|
+
async function captureEmptyCurrentDirectory(target) {
|
|
268
|
+
let identity;
|
|
269
|
+
try {
|
|
270
|
+
identity = await lstat(target);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (error?.code === "ENOENT") {
|
|
273
|
+
throw cliError(`Current directory does not exist: ${target}`);
|
|
274
|
+
}
|
|
275
|
+
throw error;
|
|
276
|
+
}
|
|
277
|
+
if (!identity.isDirectory() || identity.isSymbolicLink()) {
|
|
278
|
+
throw cliError(`Current directory is not a real directory: ${target}`);
|
|
279
|
+
}
|
|
280
|
+
if ((await readdir(target)).length !== 0) {
|
|
281
|
+
throw cliError(`Current directory is not empty: ${target}`);
|
|
282
|
+
}
|
|
283
|
+
return identity;
|
|
284
|
+
}
|
|
285
|
+
|
|
264
286
|
function expectedDirectories(manifest) {
|
|
265
287
|
return new Set(
|
|
266
288
|
manifest.files.flatMap(({ path: file }) => {
|
|
@@ -366,6 +388,34 @@ async function assertOwnedStaging(staging, expected) {
|
|
|
366
388
|
}
|
|
367
389
|
}
|
|
368
390
|
|
|
391
|
+
async function assertCurrentDirectoryIdentity(target, expected) {
|
|
392
|
+
let actual;
|
|
393
|
+
try {
|
|
394
|
+
actual = await lstat(target);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
if (error?.code === "ENOENT") {
|
|
397
|
+
throw cliError(
|
|
398
|
+
`Current directory disappeared before installation: ${target}`,
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
throw error;
|
|
402
|
+
}
|
|
403
|
+
if (!sameIdentity(actual, expected)) {
|
|
404
|
+
throw cliError(
|
|
405
|
+
`Current directory was replaced before installation: ${target}`,
|
|
406
|
+
);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
async function assertEmptyCurrentDirectory(target, expected) {
|
|
411
|
+
await assertCurrentDirectoryIdentity(target, expected);
|
|
412
|
+
if ((await readdir(target)).length !== 0) {
|
|
413
|
+
throw cliError(
|
|
414
|
+
`Current directory is no longer empty; installation was not started: ${target}`,
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
369
419
|
export async function installStagedProject({
|
|
370
420
|
staging,
|
|
371
421
|
target,
|
|
@@ -400,15 +450,136 @@ export async function installStagedProject({
|
|
|
400
450
|
}
|
|
401
451
|
}
|
|
402
452
|
|
|
453
|
+
function sortedDirectories(manifest, deepestFirst = false) {
|
|
454
|
+
return [...expectedDirectories(manifest)].sort((left, right) => {
|
|
455
|
+
const depth =
|
|
456
|
+
left.split("/").length - right.split("/").length;
|
|
457
|
+
return (
|
|
458
|
+
(deepestFirst ? -depth : depth) ||
|
|
459
|
+
left.localeCompare(right, "en")
|
|
460
|
+
);
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function concurrentEntryError(target, relativePath) {
|
|
465
|
+
return cliError(
|
|
466
|
+
`Destination entry appeared during installation and was not overwritten: ${path.join(
|
|
467
|
+
target,
|
|
468
|
+
...relativePath.split("/"),
|
|
469
|
+
)}`,
|
|
470
|
+
);
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
async function copyStagingIntoCurrentDirectory({
|
|
474
|
+
staging,
|
|
475
|
+
target,
|
|
476
|
+
manifest,
|
|
477
|
+
currentDirectoryIdentity,
|
|
478
|
+
beforeTransfer,
|
|
479
|
+
}) {
|
|
480
|
+
let transferStarted = false;
|
|
481
|
+
try {
|
|
482
|
+
if (beforeTransfer) {
|
|
483
|
+
await beforeTransfer({ staging, target, manifest });
|
|
484
|
+
}
|
|
485
|
+
await assertEmptyCurrentDirectory(target, currentDirectoryIdentity);
|
|
486
|
+
|
|
487
|
+
transferStarted = true;
|
|
488
|
+
for (const directory of sortedDirectories(manifest)) {
|
|
489
|
+
await assertCurrentDirectoryIdentity(target, currentDirectoryIdentity);
|
|
490
|
+
const destination = path.join(target, ...directory.split("/"));
|
|
491
|
+
try {
|
|
492
|
+
await mkdir(destination);
|
|
493
|
+
} catch (error) {
|
|
494
|
+
if (error?.code === "EEXIST") {
|
|
495
|
+
throw concurrentEntryError(target, directory);
|
|
496
|
+
}
|
|
497
|
+
throw error;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
for (const entry of manifest.files) {
|
|
502
|
+
await assertCurrentDirectoryIdentity(target, currentDirectoryIdentity);
|
|
503
|
+
const source = path.join(staging, ...entry.path.split("/"));
|
|
504
|
+
const destination = path.join(target, ...entry.path.split("/"));
|
|
505
|
+
try {
|
|
506
|
+
await copyFile(source, destination, constants.COPYFILE_EXCL);
|
|
507
|
+
} catch (error) {
|
|
508
|
+
if (error?.code === "EEXIST") {
|
|
509
|
+
throw concurrentEntryError(target, entry.path);
|
|
510
|
+
}
|
|
511
|
+
throw error;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
await assertCurrentDirectoryIdentity(target, currentDirectoryIdentity);
|
|
516
|
+
await verifyStagedProject(target, manifest);
|
|
517
|
+
await assertCurrentDirectoryIdentity(target, currentDirectoryIdentity);
|
|
518
|
+
} catch (error) {
|
|
519
|
+
if (transferStarted) {
|
|
520
|
+
error.hasPartialCurrentDirectoryInstall = true;
|
|
521
|
+
}
|
|
522
|
+
throw error;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
async function removeStagingSnapshot(staging, manifest, stagingIdentity) {
|
|
527
|
+
await assertOwnedStaging(staging, stagingIdentity);
|
|
528
|
+
for (const entry of manifest.files) {
|
|
529
|
+
await unlink(path.join(staging, ...entry.path.split("/")));
|
|
530
|
+
}
|
|
531
|
+
for (const directory of sortedDirectories(manifest, true)) {
|
|
532
|
+
await rmdir(path.join(staging, ...directory.split("/")));
|
|
533
|
+
}
|
|
534
|
+
await rmdir(staging);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
export async function installStagedProjectIntoCurrentDirectory({
|
|
538
|
+
staging,
|
|
539
|
+
target,
|
|
540
|
+
manifest,
|
|
541
|
+
stagingIdentity,
|
|
542
|
+
currentDirectoryIdentity,
|
|
543
|
+
beforeTransfer,
|
|
544
|
+
}) {
|
|
545
|
+
await assertOwnedStaging(staging, stagingIdentity);
|
|
546
|
+
await verifyStagedProject(staging, manifest);
|
|
547
|
+
await assertOwnedStaging(staging, stagingIdentity);
|
|
548
|
+
await assertEmptyCurrentDirectory(target, currentDirectoryIdentity);
|
|
549
|
+
|
|
550
|
+
await copyStagingIntoCurrentDirectory({
|
|
551
|
+
staging,
|
|
552
|
+
target,
|
|
553
|
+
manifest,
|
|
554
|
+
currentDirectoryIdentity,
|
|
555
|
+
beforeTransfer,
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
try {
|
|
559
|
+
await removeStagingSnapshot(staging, manifest, stagingIdentity);
|
|
560
|
+
} catch (error) {
|
|
561
|
+
throw cliError(
|
|
562
|
+
`The project was installed and verified, but staging cleanup failed: ${error.message}`,
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
403
567
|
function shellQuote(value) {
|
|
404
568
|
return `'${value.replaceAll("'", "'\\''")}'`;
|
|
405
569
|
}
|
|
406
570
|
|
|
407
571
|
export async function scaffold(targetArgument, options = {}) {
|
|
408
572
|
const packageRoot = options.packageRoot ?? defaultPackageRoot;
|
|
573
|
+
const cwd = path.resolve(options.cwd ?? process.cwd());
|
|
574
|
+
const target = path.resolve(cwd, targetArgument);
|
|
575
|
+
const installIntoCurrentDirectory = targetArgument === "." && target === cwd;
|
|
576
|
+
const currentDirectoryIdentity = installIntoCurrentDirectory
|
|
577
|
+
? await captureEmptyCurrentDirectory(target)
|
|
578
|
+
: undefined;
|
|
579
|
+
if (!installIntoCurrentDirectory) {
|
|
580
|
+
await assertTargetAbsent(target);
|
|
581
|
+
}
|
|
409
582
|
const { manifest, templateRoot } = await verifyTemplate(packageRoot);
|
|
410
|
-
const target = path.resolve(options.cwd ?? process.cwd(), targetArgument);
|
|
411
|
-
await assertTargetAbsent(target);
|
|
412
583
|
const parent = path.dirname(target);
|
|
413
584
|
const parentStat = await lstat(parent).catch((error) => {
|
|
414
585
|
if (error?.code === "ENOENT") {
|
|
@@ -449,16 +620,33 @@ export async function scaffold(targetArgument, options = {}) {
|
|
|
449
620
|
if (options.beforeInstall) {
|
|
450
621
|
await options.beforeInstall({ staging, target });
|
|
451
622
|
}
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
623
|
+
if (installIntoCurrentDirectory) {
|
|
624
|
+
await installStagedProjectIntoCurrentDirectory({
|
|
625
|
+
staging,
|
|
626
|
+
target,
|
|
627
|
+
manifest,
|
|
628
|
+
stagingIdentity,
|
|
629
|
+
currentDirectoryIdentity,
|
|
630
|
+
beforeTransfer: options.beforeCurrentDirectoryTransfer,
|
|
631
|
+
});
|
|
632
|
+
} else {
|
|
633
|
+
await installStagedProject({
|
|
634
|
+
staging,
|
|
635
|
+
target,
|
|
636
|
+
manifest,
|
|
637
|
+
stagingIdentity,
|
|
638
|
+
});
|
|
639
|
+
}
|
|
458
640
|
} catch (error) {
|
|
459
641
|
if (stagingCreated) {
|
|
642
|
+
const partialInstallWarning = error.hasPartialCurrentDirectoryInstall
|
|
643
|
+
? `
|
|
644
|
+
Installation into the current directory did not complete and may have left installer-created partial output.
|
|
645
|
+
Nothing was removed because doing so could delete user data.
|
|
646
|
+
Review the current directory and staging snapshot manually.`
|
|
647
|
+
: "";
|
|
460
648
|
throw cliError(
|
|
461
|
-
`${error.message}
|
|
649
|
+
`${error.message}${partialInstallWarning}
|
|
462
650
|
Staging directory retained at: ${staging}
|
|
463
651
|
Inspect or remove it manually.`,
|
|
464
652
|
);
|
|
@@ -468,21 +656,54 @@ Inspect or remove it manually.`,
|
|
|
468
656
|
|
|
469
657
|
return {
|
|
470
658
|
target,
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
Next steps (Docker):
|
|
474
|
-
cd -- ${shellQuote(targetArgument)}
|
|
475
|
-
cp .env.docker.example .env
|
|
476
|
-
docker compose up -d --build
|
|
477
|
-
|
|
478
|
-
Next steps (npm):
|
|
479
|
-
cd -- ${shellQuote(targetArgument)}
|
|
480
|
-
npm ci
|
|
481
|
-
cp .env.example .env.local
|
|
482
|
-
npm run dev`,
|
|
659
|
+
targetArgument,
|
|
660
|
+
installIntoCurrentDirectory,
|
|
483
661
|
};
|
|
484
662
|
}
|
|
485
663
|
|
|
664
|
+
function style(value, code, color) {
|
|
665
|
+
return color ? `\u001B[${code}m${value}\u001B[0m` : value;
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
export function formatSuccess(
|
|
669
|
+
{ target, targetArgument, installIntoCurrentDirectory },
|
|
670
|
+
{ color = false } = {},
|
|
671
|
+
) {
|
|
672
|
+
const commandText = (value) => style(value, "93", color);
|
|
673
|
+
const section = (value) => style(value, "36", color);
|
|
674
|
+
const locationStep = installIntoCurrentDirectory
|
|
675
|
+
? []
|
|
676
|
+
: [`cd -- ${shellQuote(targetArgument)}`];
|
|
677
|
+
const dockerSteps = [
|
|
678
|
+
...locationStep,
|
|
679
|
+
"cp .env.docker.example .env",
|
|
680
|
+
"docker compose up -d --build",
|
|
681
|
+
"docker compose exec app npm run create-admin",
|
|
682
|
+
];
|
|
683
|
+
const npmSteps = [
|
|
684
|
+
...locationStep,
|
|
685
|
+
"npm ci",
|
|
686
|
+
"cp .env.example .env.local",
|
|
687
|
+
"npm run dev",
|
|
688
|
+
];
|
|
689
|
+
const numbered = (steps) =>
|
|
690
|
+
steps
|
|
691
|
+
.map(
|
|
692
|
+
(step, index) =>
|
|
693
|
+
` ${commandText(`${index + 1}.`)} ${commandText(step)}`,
|
|
694
|
+
)
|
|
695
|
+
.join("\n");
|
|
696
|
+
|
|
697
|
+
return `${style("✓ Expo Updates Server is ready", "1;32", color)}
|
|
698
|
+
${section("Project:")} ${target}
|
|
699
|
+
|
|
700
|
+
${section("Next steps (Docker):")}
|
|
701
|
+
${numbered(dockerSteps)}
|
|
702
|
+
|
|
703
|
+
${section("Next steps (npm):")}
|
|
704
|
+
${numbered(npmSteps)}`;
|
|
705
|
+
}
|
|
706
|
+
|
|
486
707
|
function parseArguments(args) {
|
|
487
708
|
const options = args.filter((argument) => argument.startsWith("-"));
|
|
488
709
|
const positionals = args.filter((argument) => !argument.startsWith("-"));
|
|
@@ -507,6 +728,9 @@ function parseArguments(args) {
|
|
|
507
728
|
: "Only one target directory is allowed",
|
|
508
729
|
);
|
|
509
730
|
}
|
|
731
|
+
if (positionals[0].length === 0) {
|
|
732
|
+
throw cliError("Target directory cannot be empty");
|
|
733
|
+
}
|
|
510
734
|
return { action: "scaffold", target: positionals[0] };
|
|
511
735
|
}
|
|
512
736
|
|
|
@@ -539,7 +763,12 @@ export async function main(args, io = console, options = {}) {
|
|
|
539
763
|
...options,
|
|
540
764
|
packageRoot,
|
|
541
765
|
});
|
|
542
|
-
|
|
766
|
+
const color =
|
|
767
|
+
typeof options.color === "boolean"
|
|
768
|
+
? options.color
|
|
769
|
+
: Boolean(process.stdout.isTTY) &&
|
|
770
|
+
!Object.prototype.hasOwnProperty.call(process.env, "NO_COLOR");
|
|
771
|
+
io.log(formatSuccess(result, { color }));
|
|
543
772
|
return 0;
|
|
544
773
|
} catch (error) {
|
|
545
774
|
io.error(`Error: ${error.message}`);
|
package/package.json
CHANGED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
|
|
3
|
-
set -eu
|
|
4
|
-
|
|
5
|
-
if [ "${CONFIGURATION:-Release}" = "Debug" ]; then
|
|
6
|
-
exit 0
|
|
7
|
-
fi
|
|
8
|
-
|
|
9
|
-
PROJECT_ROOT="${CI_PRIMARY_REPOSITORY_PATH:-$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)}"
|
|
10
|
-
MANIFEST_PATH=""
|
|
11
|
-
|
|
12
|
-
for candidate in \
|
|
13
|
-
"${TARGET_BUILD_DIR:-}/${UNLOCALIZED_RESOURCES_FOLDER_PATH:-}/app.manifest" \
|
|
14
|
-
"${CI_ARCHIVE_PATH:-}/Products/Applications/"*.app/app.manifest
|
|
15
|
-
do
|
|
16
|
-
if [ -f "$candidate" ]; then
|
|
17
|
-
MANIFEST_PATH="$candidate"
|
|
18
|
-
break
|
|
19
|
-
fi
|
|
20
|
-
done
|
|
21
|
-
|
|
22
|
-
if [ -z "$MANIFEST_PATH" ] && [ -n "${TARGET_BUILD_DIR:-}" ]; then
|
|
23
|
-
MANIFEST_PATH="$(find "$TARGET_BUILD_DIR" -type f -name app.manifest 2>/dev/null | head -n 1 || true)"
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
if [ -z "$MANIFEST_PATH" ]; then
|
|
27
|
-
echo "Embedded update registration failed: iOS app.manifest was not found." >&2
|
|
28
|
-
[ "${OTA_EMBEDDED_REGISTER_STRICT:-false}" = "true" ] && exit 1
|
|
29
|
-
exit 0
|
|
30
|
-
fi
|
|
31
|
-
|
|
32
|
-
if ! node "$PROJECT_ROOT/scripts/ota-register-embedded/index.mjs" \
|
|
33
|
-
--manifest "$MANIFEST_PATH" \
|
|
34
|
-
--platform ios; then
|
|
35
|
-
[ "${OTA_EMBEDDED_REGISTER_STRICT:-false}" = "true" ] && exit 1
|
|
36
|
-
fi
|