easc 0.0.29 → 0.0.31
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 +2 -2
- package/bin/easc.js +1 -1
- package/index.ts +1 -1
- package/package.json +33 -34
- package/src/commands/build.ts +4 -14
- package/src/commands/submit.ts +6 -9
- package/src/commands/update.ts +60 -66
- package/src/utils/cli.ts +5 -10
- package/src/utils/files.test.ts +175 -47
- package/src/utils/files.ts +96 -53
- package/src/utils/git.test.ts +2 -2
- package/src/utils/git.ts +2 -6
- package/src/utils/logger.ts +52 -29
- package/src/utils/runtime.test.ts +5 -9
- package/src/utils/runtime.ts +5 -9
- package/src/utils/runx.ts +2 -5
- package/src/utils/schema.test.ts +2 -8
- package/src/utils/schema.ts +3 -7
- package/src/utils/upload.ts +23 -11
package/README.md
CHANGED
|
@@ -69,7 +69,7 @@ To test easc locally, link the package:
|
|
|
69
69
|
|
|
70
70
|
```bash
|
|
71
71
|
# From this directory
|
|
72
|
-
|
|
72
|
+
bun link
|
|
73
73
|
|
|
74
74
|
# Now you can use 'easc' command globally
|
|
75
75
|
easc --help
|
|
@@ -84,5 +84,5 @@ tsx index.ts --help
|
|
|
84
84
|
### Publishing
|
|
85
85
|
|
|
86
86
|
```bash
|
|
87
|
-
|
|
87
|
+
bun version patch && bun publish
|
|
88
88
|
```
|
package/bin/easc.js
CHANGED
|
@@ -17,7 +17,7 @@ const envArgs = existsSync(envPath) ? ["--env-file", envPath] : [];
|
|
|
17
17
|
const scriptArgs = [indexPath, ...process.argv.slice(2)];
|
|
18
18
|
|
|
19
19
|
function getRuntime() {
|
|
20
|
-
const runtime =
|
|
20
|
+
const runtime = process.versions["bun"] ? Runtime.BUN : Runtime.NODE;
|
|
21
21
|
|
|
22
22
|
switch (runtime) {
|
|
23
23
|
case Runtime.BUN:
|
package/index.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { build } from "./src/commands/build";
|
|
|
5
5
|
import { submit } from "./src/commands/submit";
|
|
6
6
|
import { update } from "./src/commands/update";
|
|
7
7
|
|
|
8
|
-
cli(hideBin(process.argv))
|
|
8
|
+
void cli(hideBin(process.argv))
|
|
9
9
|
.scriptName("easc")
|
|
10
10
|
.usage("$0 <command> [options]")
|
|
11
11
|
.command(update)
|
package/package.json
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "easc",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"description": "Expo App Services for Cloudflare - Deploy tool for Expo OTA updates to Cloudflare Workers",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cloudflare",
|
|
7
|
+
"deploy",
|
|
8
|
+
"expo",
|
|
9
|
+
"ota",
|
|
10
|
+
"updates",
|
|
11
|
+
"workers"
|
|
12
|
+
],
|
|
6
13
|
"license": "MIT",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/Daniel-Griffiths/cloudflare-expo-ota-updates.git",
|
|
17
|
+
"directory": "apps/easc"
|
|
18
|
+
},
|
|
7
19
|
"bin": {
|
|
8
20
|
"easc": "./bin/easc.js"
|
|
9
21
|
},
|
|
@@ -12,45 +24,32 @@
|
|
|
12
24
|
"index.ts",
|
|
13
25
|
"src"
|
|
14
26
|
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
15
31
|
"scripts": {
|
|
16
|
-
"test": "
|
|
17
|
-
"test:watch": "
|
|
18
|
-
"test:ui": "
|
|
19
|
-
"test:coverage": "
|
|
20
|
-
"typecheck": "tsgo --noEmit"
|
|
32
|
+
"test": "vp test",
|
|
33
|
+
"test:watch": "vp test --watch",
|
|
34
|
+
"test:ui": "vp test --ui",
|
|
35
|
+
"test:coverage": "vp test --coverage"
|
|
21
36
|
},
|
|
22
37
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"tsx": "^4.
|
|
38
|
+
"@expo/fingerprint": "^0.11.0",
|
|
39
|
+
"@inquirer/prompts": "^8.3.2",
|
|
40
|
+
"chalk": "5.6.2",
|
|
41
|
+
"tsx": "^4.21.0",
|
|
27
42
|
"yargs": "^18.0.0",
|
|
28
|
-
"zod": "^4.
|
|
43
|
+
"zod": "^4.3.6"
|
|
29
44
|
},
|
|
30
45
|
"devDependencies": {
|
|
31
|
-
"@types/node": "^
|
|
32
|
-
"@types/yargs": "^17.0.
|
|
33
|
-
"@
|
|
34
|
-
"
|
|
35
|
-
"vitest": "
|
|
46
|
+
"@types/node": "^25.5.0",
|
|
47
|
+
"@types/yargs": "^17.0.35",
|
|
48
|
+
"@vitest/ui": "^4.1.0",
|
|
49
|
+
"vite-plus": "latest",
|
|
50
|
+
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
36
51
|
},
|
|
37
52
|
"engines": {
|
|
38
|
-
"node": ">=
|
|
39
|
-
},
|
|
40
|
-
"repository": {
|
|
41
|
-
"type": "git",
|
|
42
|
-
"url": "git+https://github.com/Daniel-Griffiths/cloudflare-expo-ota-updates.git",
|
|
43
|
-
"directory": "apps/easc"
|
|
44
|
-
},
|
|
45
|
-
"keywords": [
|
|
46
|
-
"expo",
|
|
47
|
-
"ota",
|
|
48
|
-
"cloudflare",
|
|
49
|
-
"workers",
|
|
50
|
-
"deploy",
|
|
51
|
-
"updates"
|
|
52
|
-
],
|
|
53
|
-
"publishConfig": {
|
|
54
|
-
"access": "public"
|
|
53
|
+
"node": ">=20.12.0"
|
|
55
54
|
}
|
|
56
55
|
}
|
package/src/commands/build.ts
CHANGED
|
@@ -61,26 +61,16 @@ export const build: CommandModule = {
|
|
|
61
61
|
})
|
|
62
62
|
.option("path", {
|
|
63
63
|
type: "string",
|
|
64
|
-
description:
|
|
65
|
-
"Path to the simulator/emulator build archive or app (skips build)",
|
|
64
|
+
description: "Path to the simulator/emulator build archive or app (skips build)",
|
|
66
65
|
})
|
|
67
66
|
.option("non-interactive", {
|
|
68
67
|
type: "boolean",
|
|
69
68
|
description: "Never prompt for user input",
|
|
70
69
|
default: false,
|
|
71
70
|
})
|
|
72
|
-
.example(
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
76
|
-
.example(
|
|
77
|
-
"$0 build -p android",
|
|
78
|
-
"Build with default profile and run on Android Emulator",
|
|
79
|
-
)
|
|
80
|
-
.example(
|
|
81
|
-
"$0 build -p ios --path ./build.tar.gz",
|
|
82
|
-
"Run existing build artifact",
|
|
83
|
-
),
|
|
71
|
+
.example("$0 build -p ios -e preview", "Build with preview profile and run on iOS Simulator")
|
|
72
|
+
.example("$0 build -p android", "Build with default profile and run on Android Emulator")
|
|
73
|
+
.example("$0 build -p ios --path ./build.tar.gz", "Run existing build artifact"),
|
|
84
74
|
async handler(argv) {
|
|
85
75
|
const args = argv as unknown as IArgs;
|
|
86
76
|
const logger = new Logger();
|
package/src/commands/submit.ts
CHANGED
|
@@ -84,9 +84,7 @@ export const submit: CommandModule = {
|
|
|
84
84
|
|
|
85
85
|
try {
|
|
86
86
|
const platforms: PlatformType[] =
|
|
87
|
-
args.platform === "all"
|
|
88
|
-
? [Platform.iOS, Platform.Android]
|
|
89
|
-
: [args.platform];
|
|
87
|
+
args.platform === "all" ? [Platform.iOS, Platform.Android] : [args.platform];
|
|
90
88
|
|
|
91
89
|
for (const platform of platforms) {
|
|
92
90
|
const platformName = platform === Platform.iOS ? "iOS" : "Android";
|
|
@@ -129,8 +127,7 @@ export const submit: CommandModule = {
|
|
|
129
127
|
const artifactPath =
|
|
130
128
|
platform === Platform.iOS
|
|
131
129
|
? findBuildArtifact("build-*.ipa")
|
|
132
|
-
: findBuildArtifact("build-*.aab") ||
|
|
133
|
-
findBuildArtifact("build-*.apk");
|
|
130
|
+
: findBuildArtifact("build-*.aab") || findBuildArtifact("build-*.apk");
|
|
134
131
|
|
|
135
132
|
if (!artifactPath) {
|
|
136
133
|
logger.error(`No ${platformName} build artifact found`);
|
|
@@ -139,10 +136,10 @@ export const submit: CommandModule = {
|
|
|
139
136
|
|
|
140
137
|
logger.info(`Found artifact: ${artifactPath}`);
|
|
141
138
|
|
|
142
|
-
runx(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
);
|
|
139
|
+
runx(`eas submit --platform ${platform} --path "${artifactPath}" --non-interactive`, {
|
|
140
|
+
cwd: process.cwd(),
|
|
141
|
+
stdio: "inherit",
|
|
142
|
+
});
|
|
146
143
|
|
|
147
144
|
logger.success(`${platformName} submitted`);
|
|
148
145
|
|
package/src/commands/update.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
1
|
import type { CommandModule } from "yargs";
|
|
3
2
|
import { validateConfig, getConfig } from "../utils/schema";
|
|
4
3
|
import { resolveRuntimeVersion, getPlatforms } from "../utils/runtime";
|
|
@@ -11,8 +10,8 @@ import {
|
|
|
11
10
|
checkExportDirectory,
|
|
12
11
|
} from "../utils/files";
|
|
13
12
|
import { uploadBundle, createDryRunSummary } from "../utils/upload";
|
|
13
|
+
import { createFingerprintAsync } from "@expo/fingerprint";
|
|
14
14
|
import { Logger } from "../utils/logger";
|
|
15
|
-
import { PlatformType } from "../enums/platform";
|
|
16
15
|
import { runx } from "../utils/runx";
|
|
17
16
|
|
|
18
17
|
interface IArgs {
|
|
@@ -21,6 +20,7 @@ interface IArgs {
|
|
|
21
20
|
dryRun: boolean;
|
|
22
21
|
exportDir: string;
|
|
23
22
|
nonInteractive: boolean;
|
|
23
|
+
dangerouslyIgnoreFingerprintCheck: boolean;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export const update: CommandModule = {
|
|
@@ -54,6 +54,11 @@ export const update: CommandModule = {
|
|
|
54
54
|
description: "Never prompt for user input",
|
|
55
55
|
default: false,
|
|
56
56
|
})
|
|
57
|
+
.option("dangerously-ignore-fingerprint-check", {
|
|
58
|
+
type: "boolean",
|
|
59
|
+
description: "Skip fingerprint validation when native dependencies have changed",
|
|
60
|
+
default: false,
|
|
61
|
+
})
|
|
57
62
|
.example("$0 update --channel production", "Deploy to production")
|
|
58
63
|
.example("$0 update -c staging --skip-build", "Deploy existing build"),
|
|
59
64
|
async handler(argv) {
|
|
@@ -79,16 +84,14 @@ export const update: CommandModule = {
|
|
|
79
84
|
|
|
80
85
|
runx(
|
|
81
86
|
args.exportDir !== "dist"
|
|
82
|
-
? `expo export --output-dir ${args.exportDir}`
|
|
83
|
-
: `expo export`,
|
|
87
|
+
? `expo export --dump-sourcemap --output-dir ${args.exportDir}`
|
|
88
|
+
: `expo export --dump-sourcemap`,
|
|
84
89
|
{ cwd: process.cwd(), stdio: "inherit" },
|
|
85
90
|
);
|
|
86
91
|
|
|
87
92
|
logger.success("Build completed");
|
|
88
93
|
} else {
|
|
89
|
-
logger.info(
|
|
90
|
-
`Skipping build (using existing export from ${args.exportDir})`,
|
|
91
|
-
);
|
|
94
|
+
logger.info(`Skipping build (using existing export from ${args.exportDir})`);
|
|
92
95
|
}
|
|
93
96
|
|
|
94
97
|
const exportDir = checkExportDirectory(args.exportDir);
|
|
@@ -99,83 +102,74 @@ export const update: CommandModule = {
|
|
|
99
102
|
const commitHash = getCommitHash();
|
|
100
103
|
const shortCommit = getShortCommitHash();
|
|
101
104
|
|
|
105
|
+
logger.info("Generating native fingerprint...");
|
|
106
|
+
const { hash: fingerprint } = await createFingerprintAsync(process.cwd());
|
|
107
|
+
logger.success(`Fingerprint: ${fingerprint}`);
|
|
108
|
+
|
|
102
109
|
logger.section("📤 Deployment Info");
|
|
103
110
|
logger.table([
|
|
104
111
|
["Server", config.otaServer],
|
|
105
112
|
["Runtime", runtimeVersion],
|
|
106
113
|
["Commit", shortCommit || ""],
|
|
114
|
+
["Fingerprint", fingerprint || ""],
|
|
107
115
|
["Export Dir", args.exportDir],
|
|
108
116
|
["Channel", channel],
|
|
109
117
|
]);
|
|
110
118
|
|
|
111
|
-
const
|
|
112
|
-
platform
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
error?: string;
|
|
117
|
-
}[] = [];
|
|
118
|
-
|
|
119
|
-
for (const platform of platforms) {
|
|
120
|
-
logger.section(platform.toUpperCase());
|
|
119
|
+
const platformUploads = platforms.map((platform) => ({
|
|
120
|
+
platform,
|
|
121
|
+
bundlePath: findBundleFile(exportDir, metadata, platform),
|
|
122
|
+
assetPaths: getAssetFiles(exportDir, metadata, platform),
|
|
123
|
+
}));
|
|
121
124
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
const summary = createDryRunSummary({
|
|
125
|
+
if (args.dryRun) {
|
|
126
|
+
for (const { platform, bundlePath, assetPaths } of platformUploads) {
|
|
127
|
+
logger.section(platform.toUpperCase());
|
|
128
|
+
logger.box(
|
|
129
|
+
createDryRunSummary({
|
|
128
130
|
platform,
|
|
129
131
|
bundlePath,
|
|
130
132
|
assetPaths,
|
|
131
133
|
channel,
|
|
132
134
|
runtimeVersion,
|
|
133
135
|
commitHash,
|
|
134
|
-
})
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
136
|
+
}),
|
|
137
|
+
);
|
|
138
|
+
logger.success(`${platform} (dry run)`);
|
|
139
|
+
}
|
|
140
|
+
} else {
|
|
141
|
+
logger.startSpinner(platformUploads.map(({ platform }) => `Uploading ${platform}...`));
|
|
142
|
+
|
|
143
|
+
const results = await Promise.allSettled(
|
|
144
|
+
platformUploads.map(async ({ platform, bundlePath, assetPaths }) => {
|
|
145
|
+
const label = `Uploading ${platform}...`;
|
|
146
|
+
try {
|
|
147
|
+
await uploadBundle({
|
|
148
|
+
platform,
|
|
149
|
+
channel,
|
|
150
|
+
runtimeVersion,
|
|
151
|
+
commitHash,
|
|
152
|
+
bundlePath,
|
|
153
|
+
assetPaths,
|
|
154
|
+
expoConfig: appJson.expo,
|
|
155
|
+
metadata,
|
|
156
|
+
config,
|
|
157
|
+
fingerprint,
|
|
158
|
+
ignoreFingerprintCheck: args.dangerouslyIgnoreFingerprintCheck,
|
|
159
|
+
});
|
|
160
|
+
logger.updateSpinner(label, "done");
|
|
161
|
+
} catch (error) {
|
|
162
|
+
logger.updateSpinner(label, "failed");
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}),
|
|
166
|
+
);
|
|
159
167
|
|
|
160
|
-
|
|
168
|
+
logger.stopSpinner();
|
|
161
169
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
bundle_size: fs.statSync(bundlePath).size,
|
|
166
|
-
asset_count: assetPaths.length,
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
} catch (error) {
|
|
170
|
-
logger.failSpinner(`${platform} failed`);
|
|
171
|
-
results.push({
|
|
172
|
-
platform,
|
|
173
|
-
status: "failed",
|
|
174
|
-
bundle_size: 0,
|
|
175
|
-
asset_count: 0,
|
|
176
|
-
error: error instanceof Error ? error.message : String(error),
|
|
177
|
-
});
|
|
178
|
-
throw error;
|
|
170
|
+
const failed = results.filter((r) => r.status === "rejected");
|
|
171
|
+
if (failed.length > 0) {
|
|
172
|
+
throw (failed[0] as PromiseRejectedResult).reason;
|
|
179
173
|
}
|
|
180
174
|
}
|
|
181
175
|
|
package/src/utils/cli.ts
CHANGED
|
@@ -37,8 +37,7 @@ class InteractiveCLI {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
command(cmd: CommandModule): this {
|
|
40
|
-
const commandStr =
|
|
41
|
-
typeof cmd.command === "string" ? cmd.command : (cmd.command?.[0] ?? "");
|
|
40
|
+
const commandStr = typeof cmd.command === "string" ? cmd.command : (cmd.command?.[0] ?? "");
|
|
42
41
|
const commandName = commandStr.split(" ")[0] || "";
|
|
43
42
|
|
|
44
43
|
let options: Record<string, Options> = {};
|
|
@@ -104,11 +103,10 @@ class InteractiveCLI {
|
|
|
104
103
|
|
|
105
104
|
async parse(): Promise<void> {
|
|
106
105
|
const needsCommandPrompt =
|
|
107
|
-
this.args.length === 0 ||
|
|
108
|
-
(this.args.length === 1 && this.args[0]?.startsWith("-"));
|
|
106
|
+
this.args.length === 0 || (this.args.length === 1 && this.args[0]?.startsWith("-"));
|
|
109
107
|
|
|
110
108
|
if (!needsCommandPrompt) {
|
|
111
|
-
this.yargsInstance.demandCommand(1, "").parse();
|
|
109
|
+
void this.yargsInstance.demandCommand(1, "").parse();
|
|
112
110
|
return;
|
|
113
111
|
}
|
|
114
112
|
|
|
@@ -158,7 +156,7 @@ class InteractiveCLI {
|
|
|
158
156
|
});
|
|
159
157
|
}
|
|
160
158
|
|
|
161
|
-
this.yargsInstance.demandCommand(1, "").parse();
|
|
159
|
+
void this.yargsInstance.demandCommand(1, "").parse();
|
|
162
160
|
}
|
|
163
161
|
|
|
164
162
|
private _showWelcome() {
|
|
@@ -174,10 +172,7 @@ class InteractiveCLI {
|
|
|
174
172
|
console.log();
|
|
175
173
|
}
|
|
176
174
|
|
|
177
|
-
private async _promptForMissingArgs(
|
|
178
|
-
argv: any,
|
|
179
|
-
options: Record<string, Options>,
|
|
180
|
-
) {
|
|
175
|
+
private async _promptForMissingArgs(argv: any, options: Record<string, Options>) {
|
|
181
176
|
if (argv.nonInteractive || argv["non-interactive"]) return;
|
|
182
177
|
|
|
183
178
|
for (const [key, opt] of Object.entries(options)) {
|