create-expo-updates-server 0.1.0 → 0.1.3
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 +12 -3
- package/dist/template/docs/index.md +22 -3
- 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-manifest.json +12 -12
- package/lib/cli.mjs +252 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,11 +8,26 @@ npx create-expo-updates-server@latest my-server
|
|
|
8
8
|
cd my-server
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
To scaffold into an empty current directory instead:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
mkdir my-server
|
|
15
|
+
cd my-server
|
|
16
|
+
npx create-expo-updates-server@latest .
|
|
17
|
+
```
|
|
18
|
+
|
|
11
19
|
The initializer performs no network requests, dependency installation, Git
|
|
12
|
-
initialization, or secret generation while scaffolding.
|
|
13
|
-
remain absent while the command runs
|
|
14
|
-
|
|
15
|
-
|
|
20
|
+
initialization, or secret generation while scaffolding. A named target must
|
|
21
|
+
remain absent while the command runs. The special `.` target is accepted only
|
|
22
|
+
when it resolves to the current directory and that directory starts empty.
|
|
23
|
+
The initializer verifies a private sibling staging snapshot before installing
|
|
24
|
+
it and never merges with an existing entry. If installation into `.` stops
|
|
25
|
+
after creating files, it reports the partial output for manual review rather
|
|
26
|
+
than recursively deleting the current directory.
|
|
27
|
+
|
|
28
|
+
Successful output provides numbered Docker and npm paths. When `.` is used,
|
|
29
|
+
those steps start directly with configuration or installation instead of
|
|
30
|
+
asking you to change into the directory again.
|
|
16
31
|
|
|
17
32
|
See the
|
|
18
33
|
[installer documentation](https://github.com/tonichiga/expo-updates-server/blob/main/docs/npm-installer.md)
|
package/dist/template/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Expo Updates Server
|
|
2
2
|
|
|
3
|
+
## Install with NPX
|
|
4
|
+
|
|
3
5
|
The easiest way to create a standalone server project is the npm initializer:
|
|
4
6
|
|
|
5
7
|
```bash
|
|
@@ -7,9 +9,16 @@ npx create-expo-updates-server@latest my-server
|
|
|
7
9
|
cd my-server
|
|
8
10
|
```
|
|
9
11
|
|
|
12
|
+
To install into the current empty directory:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx create-expo-updates-server@latest .
|
|
16
|
+
```
|
|
17
|
+
|
|
10
18
|
The downloaded initializer uses its bundled, checksum-verified template. It
|
|
11
19
|
does not fetch source code, install project dependencies, initialize Git, or
|
|
12
|
-
create secrets while scaffolding.
|
|
20
|
+
create secrets while scaffolding. A named target path must not already exist;
|
|
21
|
+
`.` is supported only when it resolves to the empty current directory.
|
|
13
22
|
Continue with either Docker:
|
|
14
23
|
|
|
15
24
|
```bash
|
|
@@ -25,8 +34,8 @@ cp .env.example .env.local
|
|
|
25
34
|
npm run dev
|
|
26
35
|
```
|
|
27
36
|
|
|
28
|
-
See the [npm initializer guide](docs/npm-installer.md) for
|
|
29
|
-
complete next steps. Cloning the
|
|
37
|
+
See the [npm initializer guide](docs/npm-installer.md) for supported commands,
|
|
38
|
+
safety behavior, and complete next steps. Cloning the
|
|
30
39
|
[GitHub repository](https://github.com/tonichiga/expo-updates-server) remains
|
|
31
40
|
supported for contributors and manual installations.
|
|
32
41
|
|
|
@@ -7,11 +7,11 @@ hero:
|
|
|
7
7
|
tagline: Self-host signed updates, promote releases deliberately, roll back safely, and recover misconfigured native builds.
|
|
8
8
|
actions:
|
|
9
9
|
- theme: brand
|
|
10
|
+
text: Install with NPX
|
|
11
|
+
link: /npm-installer
|
|
12
|
+
- theme: alt
|
|
10
13
|
text: Quick Start
|
|
11
14
|
link: /getting-started
|
|
12
|
-
- theme: alt
|
|
13
|
-
text: Быстрый старт
|
|
14
|
-
link: /getting-started.ru
|
|
15
15
|
- theme: alt
|
|
16
16
|
text: View on GitHub
|
|
17
17
|
link: https://github.com/tonichiga/expo-updates-server
|
|
@@ -37,6 +37,25 @@ features:
|
|
|
37
37
|
details: Manage role-based access, scoped automation tokens, embedded builds, and release history from the admin panel.
|
|
38
38
|
---
|
|
39
39
|
|
|
40
|
+
## Install in seconds
|
|
41
|
+
|
|
42
|
+
Create a new project directory:
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
npx create-expo-updates-server@latest my-server
|
|
46
|
+
cd my-server
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Or initialize the current empty directory:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
npx create-expo-updates-server@latest .
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The initializer bundles and verifies the complete server template. Continue
|
|
56
|
+
with the [npm initializer guide](/npm-installer) for Docker and local npm
|
|
57
|
+
startup commands.
|
|
58
|
+
|
|
40
59
|
## Choose your path
|
|
41
60
|
|
|
42
61
|
Create a standalone project with the
|
|
@@ -8,36 +8,86 @@ npx create-expo-updates-server@latest my-server
|
|
|
8
8
|
cd my-server
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
You can also initialize an empty current directory:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
mkdir my-server
|
|
15
|
+
cd my-server
|
|
16
|
+
npx create-expo-updates-server@latest .
|
|
17
|
+
```
|
|
18
|
+
|
|
11
19
|
`npx` downloads the published initializer package from npm. After it starts,
|
|
12
20
|
the initializer makes no network requests: the server template and its
|
|
13
21
|
SHA-256 manifest are bundled in the package.
|
|
14
22
|
|
|
23
|
+
For a named target, successful plain-text output looks like this (interactive
|
|
24
|
+
terminals add color):
|
|
25
|
+
|
|
26
|
+
```text
|
|
27
|
+
✓ Expo Updates Server is ready
|
|
28
|
+
Project: /path/to/my-server
|
|
29
|
+
|
|
30
|
+
Next steps (Docker):
|
|
31
|
+
1. cd -- 'my-server'
|
|
32
|
+
2. cp .env.docker.example .env
|
|
33
|
+
3. docker compose up -d --build
|
|
34
|
+
4. docker compose exec app npm run create-admin
|
|
35
|
+
|
|
36
|
+
Next steps (npm):
|
|
37
|
+
1. cd -- 'my-server'
|
|
38
|
+
2. npm ci
|
|
39
|
+
3. cp .env.example .env.local
|
|
40
|
+
4. npm run dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
With `.`, the redundant `cd` step is omitted. Color is disabled when output is
|
|
44
|
+
not a TTY or the `NO_COLOR` environment variable is present.
|
|
45
|
+
|
|
15
46
|
## Safety behavior
|
|
16
47
|
|
|
17
48
|
The initializer:
|
|
18
49
|
|
|
19
50
|
- accepts exactly one destination directory;
|
|
20
|
-
- requires
|
|
21
|
-
non-empty directories, files, and symbolic links;
|
|
51
|
+
- requires a named destination path not to exist and refuses existing empty
|
|
52
|
+
or non-empty directories, files, and symbolic links;
|
|
53
|
+
- accepts an existing destination only when it resolves exactly to the current
|
|
54
|
+
directory and that directory has no visible or hidden entries;
|
|
22
55
|
- creates a unique sibling staging directory with mode `0700`;
|
|
23
56
|
- builds the complete project in staging and verifies its full path set, file
|
|
24
57
|
types, sizes, and SHA-256 digests before installation;
|
|
25
|
-
-
|
|
26
|
-
|
|
27
|
-
-
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
- installs an absent named destination with the existing staging-directory
|
|
59
|
+
rename flow;
|
|
60
|
+
- checks the current directory's device, inode, and emptiness again immediately
|
|
61
|
+
before installing `.`, creates directories exclusively, copies files with
|
|
62
|
+
no-clobber semantics, and verifies the final full path set, sizes, and
|
|
63
|
+
SHA-256 digests;
|
|
64
|
+
- never overwrites an entry encountered while installing `.` and never
|
|
65
|
+
recursively deletes the current directory;
|
|
66
|
+
- once staging has started, leaves the unique staging directory in place after
|
|
67
|
+
a failure and reports its exact path for manual inspection or removal; if `.`
|
|
68
|
+
contains partial installer output, that is also reported for manual review.
|
|
69
|
+
|
|
70
|
+
An absent named destination must remain absent for the entire command. If
|
|
71
|
+
another process creates a file, symbolic link, or non-empty directory before
|
|
72
|
+
the final rename, the initializer fails and leaves it unchanged. Portable
|
|
73
|
+
filesystem APIs do not provide a cross-platform, atomic no-clobber directory
|
|
74
|
+
rename. In the narrow race where another process creates an empty named
|
|
75
|
+
destination directory after the last absence check, the rename may replace
|
|
76
|
+
that empty directory.
|
|
77
|
+
|
|
78
|
+
Installing into `.` necessarily transfers entries rather than replacing the
|
|
79
|
+
current directory itself. Exclusive operations prevent the initializer from
|
|
80
|
+
overwriting an entry that appears at a destination path during normal
|
|
81
|
+
concurrent use. If installation fails after creating some entries, those
|
|
82
|
+
entries are deliberately not removed because they can no longer be safely
|
|
83
|
+
distinguished from user changes. Review the reported current directory and
|
|
84
|
+
staging snapshot manually. These checks are safety measures for normal
|
|
85
|
+
filesystem races, not a security boundary against another process running as
|
|
86
|
+
the same user.
|
|
87
|
+
|
|
88
|
+
Staging contains only public template files. On success, it is consumed by the
|
|
89
|
+
named-target rename or removed after the verified `.` transfer, so no staging
|
|
90
|
+
directory remains.
|
|
41
91
|
|
|
42
92
|
It deliberately does not install dependencies, initialize a Git repository,
|
|
43
93
|
write `.env` files, or generate signing keys and other secrets. There is no
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-updates-server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "expo-updates-server",
|
|
9
|
-
"version": "0.1.
|
|
9
|
+
"version": "0.1.2",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-s3": "^3.888.0",
|
|
@@ -1483,62 +1483,6 @@
|
|
|
1483
1483
|
}
|
|
1484
1484
|
}
|
|
1485
1485
|
},
|
|
1486
|
-
"node_modules/@docsearch/js/node_modules/@types/react": {
|
|
1487
|
-
"version": "18.3.31",
|
|
1488
|
-
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.31.tgz",
|
|
1489
|
-
"integrity": "sha512-vfEqpXTvwT91yhmwdfouStN2hSKwTvyRs8qpLfADyrq/kxDw0hZM7Wk9Ug1FELj8hIby+S/+kQCSRFF32nv2Qw==",
|
|
1490
|
-
"dev": true,
|
|
1491
|
-
"license": "MIT",
|
|
1492
|
-
"optional": true,
|
|
1493
|
-
"peer": true,
|
|
1494
|
-
"dependencies": {
|
|
1495
|
-
"@types/prop-types": "*",
|
|
1496
|
-
"csstype": "^3.2.2"
|
|
1497
|
-
}
|
|
1498
|
-
},
|
|
1499
|
-
"node_modules/@docsearch/js/node_modules/react": {
|
|
1500
|
-
"version": "18.3.1",
|
|
1501
|
-
"resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz",
|
|
1502
|
-
"integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==",
|
|
1503
|
-
"dev": true,
|
|
1504
|
-
"license": "MIT",
|
|
1505
|
-
"optional": true,
|
|
1506
|
-
"peer": true,
|
|
1507
|
-
"dependencies": {
|
|
1508
|
-
"loose-envify": "^1.1.0"
|
|
1509
|
-
},
|
|
1510
|
-
"engines": {
|
|
1511
|
-
"node": ">=0.10.0"
|
|
1512
|
-
}
|
|
1513
|
-
},
|
|
1514
|
-
"node_modules/@docsearch/js/node_modules/react-dom": {
|
|
1515
|
-
"version": "18.3.1",
|
|
1516
|
-
"resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz",
|
|
1517
|
-
"integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==",
|
|
1518
|
-
"dev": true,
|
|
1519
|
-
"license": "MIT",
|
|
1520
|
-
"optional": true,
|
|
1521
|
-
"peer": true,
|
|
1522
|
-
"dependencies": {
|
|
1523
|
-
"loose-envify": "^1.1.0",
|
|
1524
|
-
"scheduler": "^0.23.2"
|
|
1525
|
-
},
|
|
1526
|
-
"peerDependencies": {
|
|
1527
|
-
"react": "^18.3.1"
|
|
1528
|
-
}
|
|
1529
|
-
},
|
|
1530
|
-
"node_modules/@docsearch/js/node_modules/scheduler": {
|
|
1531
|
-
"version": "0.23.2",
|
|
1532
|
-
"resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz",
|
|
1533
|
-
"integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==",
|
|
1534
|
-
"dev": true,
|
|
1535
|
-
"license": "MIT",
|
|
1536
|
-
"optional": true,
|
|
1537
|
-
"peer": true,
|
|
1538
|
-
"dependencies": {
|
|
1539
|
-
"loose-envify": "^1.1.0"
|
|
1540
|
-
}
|
|
1541
|
-
},
|
|
1542
1486
|
"node_modules/@emnapi/core": {
|
|
1543
1487
|
"version": "1.8.1",
|
|
1544
1488
|
"resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.8.1.tgz",
|
|
@@ -4522,15 +4466,6 @@
|
|
|
4522
4466
|
"undici-types": "~6.21.0"
|
|
4523
4467
|
}
|
|
4524
4468
|
},
|
|
4525
|
-
"node_modules/@types/prop-types": {
|
|
4526
|
-
"version": "15.7.15",
|
|
4527
|
-
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.15.tgz",
|
|
4528
|
-
"integrity": "sha512-F6bEyamV9jKGAFBEmlQnesRPGOQqS2+Uwi0Em15xenOxHaf2hv6L8YCVn3rPdPJOiJfPiCnLIRyvwVaqMY3MIw==",
|
|
4529
|
-
"dev": true,
|
|
4530
|
-
"license": "MIT",
|
|
4531
|
-
"optional": true,
|
|
4532
|
-
"peer": true
|
|
4533
|
-
},
|
|
4534
4469
|
"node_modules/@types/react": {
|
|
4535
4470
|
"version": "19.2.14",
|
|
4536
4471
|
"resolved": "https://registry.npmjs.org/@types/react/-/react-19.2.14.tgz",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"installerVersion": "0.1.
|
|
4
|
-
"sourceCommit": "
|
|
5
|
-
"totalSize":
|
|
3
|
+
"installerVersion": "0.1.3",
|
|
4
|
+
"sourceCommit": "380d20e9d8dd8ec52a6e41e3b6a6d7f2b57d752c",
|
|
5
|
+
"totalSize": 905336,
|
|
6
6
|
"files": [
|
|
7
7
|
{
|
|
8
8
|
"path": ".env.docker.example",
|
|
@@ -217,8 +217,8 @@
|
|
|
217
217
|
},
|
|
218
218
|
{
|
|
219
219
|
"path": "docs/index.md",
|
|
220
|
-
"size":
|
|
221
|
-
"sha256": "
|
|
220
|
+
"size": 2684,
|
|
221
|
+
"sha256": "7251091b1835ba1f2804c664791093356ff9bccff689a99405cf64220531260d"
|
|
222
222
|
},
|
|
223
223
|
{
|
|
224
224
|
"path": "docs/migrations/schema.sql",
|
|
@@ -227,8 +227,8 @@
|
|
|
227
227
|
},
|
|
228
228
|
{
|
|
229
229
|
"path": "docs/npm-installer.md",
|
|
230
|
-
"size":
|
|
231
|
-
"sha256": "
|
|
230
|
+
"size": 5139,
|
|
231
|
+
"sha256": "3e424664a94423614ee08c078ae46d3e61565860db5192d9ba23baa1061b5723"
|
|
232
232
|
},
|
|
233
233
|
{
|
|
234
234
|
"path": "docs/operations-guide.md",
|
|
@@ -262,13 +262,13 @@
|
|
|
262
262
|
},
|
|
263
263
|
{
|
|
264
264
|
"path": "package-lock.json",
|
|
265
|
-
"size":
|
|
266
|
-
"sha256": "
|
|
265
|
+
"size": 427507,
|
|
266
|
+
"sha256": "8c2a3e676829deb6475e690d157e82a48bd8ce46d930ff1468874cc7b00aab34"
|
|
267
267
|
},
|
|
268
268
|
{
|
|
269
269
|
"path": "package.json",
|
|
270
270
|
"size": 1465,
|
|
271
|
-
"sha256": "
|
|
271
|
+
"sha256": "0d39c47bd46536a8212b744a0d339ea00ecc88d3746669efe5b5f271192ff6a2"
|
|
272
272
|
},
|
|
273
273
|
{
|
|
274
274
|
"path": "postcss.config.mjs",
|
|
@@ -302,8 +302,8 @@
|
|
|
302
302
|
},
|
|
303
303
|
{
|
|
304
304
|
"path": "README.md",
|
|
305
|
-
"size":
|
|
306
|
-
"sha256": "
|
|
305
|
+
"size": 19799,
|
|
306
|
+
"sha256": "71800fbc6e88fafb254560db73ba222178257467a7328dc46ed5729d6558bf77"
|
|
307
307
|
},
|
|
308
308
|
{
|
|
309
309
|
"path": "scripts/configure-expo-app.mjs",
|
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}`);
|