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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect } from "
|
|
1
|
+
import { describe, it, expect } from "vite-plus/test";
|
|
2
2
|
import { resolveRuntimeVersion, getPlatforms, type IAppJson } from "./runtime";
|
|
3
3
|
|
|
4
4
|
describe("resolveRuntimeVersion", () => {
|
|
@@ -28,7 +28,7 @@ describe("resolveRuntimeVersion", () => {
|
|
|
28
28
|
},
|
|
29
29
|
};
|
|
30
30
|
expect(() => resolveRuntimeVersion(appJson)).toThrow(
|
|
31
|
-
'runtimeVersion policy is "appVersion" but no version field found in app.json'
|
|
31
|
+
'runtimeVersion policy is "appVersion" but no version field found in app.json',
|
|
32
32
|
);
|
|
33
33
|
});
|
|
34
34
|
|
|
@@ -36,9 +36,7 @@ describe("resolveRuntimeVersion", () => {
|
|
|
36
36
|
const appJson: IAppJson = {
|
|
37
37
|
expo: {},
|
|
38
38
|
};
|
|
39
|
-
expect(() => resolveRuntimeVersion(appJson)).toThrow(
|
|
40
|
-
"Invalid runtimeVersion configuration"
|
|
41
|
-
);
|
|
39
|
+
expect(() => resolveRuntimeVersion(appJson)).toThrow("Invalid runtimeVersion configuration");
|
|
42
40
|
});
|
|
43
41
|
|
|
44
42
|
it("should throw error for unsupported policy", () => {
|
|
@@ -47,9 +45,7 @@ describe("resolveRuntimeVersion", () => {
|
|
|
47
45
|
runtimeVersion: { policy: "unsupported" } as any,
|
|
48
46
|
},
|
|
49
47
|
};
|
|
50
|
-
expect(() => resolveRuntimeVersion(appJson)).toThrow(
|
|
51
|
-
"Invalid runtimeVersion configuration"
|
|
52
|
-
);
|
|
48
|
+
expect(() => resolveRuntimeVersion(appJson)).toThrow("Invalid runtimeVersion configuration");
|
|
53
49
|
});
|
|
54
50
|
});
|
|
55
51
|
|
|
@@ -96,4 +92,4 @@ describe("getPlatforms", () => {
|
|
|
96
92
|
};
|
|
97
93
|
expect(getPlatforms(appJson)).toEqual(["android"]);
|
|
98
94
|
});
|
|
99
|
-
});
|
|
95
|
+
});
|
package/src/utils/runtime.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { PlatformType } from "../enums/platform";
|
|
|
6
6
|
|
|
7
7
|
export interface IAppJson {
|
|
8
8
|
expo: {
|
|
9
|
+
name?: string;
|
|
9
10
|
runtimeVersion?: string | { policy: string };
|
|
10
11
|
version?: string;
|
|
11
12
|
platforms?: string[];
|
|
@@ -26,14 +27,11 @@ export function resolveRuntimeVersion(appJson: IAppJson): string {
|
|
|
26
27
|
return runtimeVersionConfig;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
if (
|
|
30
|
-
typeof runtimeVersionConfig === "object" &&
|
|
31
|
-
runtimeVersionConfig?.policy === "appVersion"
|
|
32
|
-
) {
|
|
30
|
+
if (typeof runtimeVersionConfig === "object" && runtimeVersionConfig?.policy === "appVersion") {
|
|
33
31
|
const version = appJson.expo.version;
|
|
34
32
|
if (!version) {
|
|
35
33
|
throw new Error(
|
|
36
|
-
'runtimeVersion policy is "appVersion" but no version field found in app.json'
|
|
34
|
+
'runtimeVersion policy is "appVersion" but no version field found in app.json',
|
|
37
35
|
);
|
|
38
36
|
}
|
|
39
37
|
return version;
|
|
@@ -42,7 +40,7 @@ export function resolveRuntimeVersion(appJson: IAppJson): string {
|
|
|
42
40
|
throw new Error(
|
|
43
41
|
"Invalid runtimeVersion configuration in app.json. Must be either:\n" +
|
|
44
42
|
' - A string: "runtimeVersion": "1.0.0"\n' +
|
|
45
|
-
' - Policy object: "runtimeVersion": { "policy": "appVersion" }'
|
|
43
|
+
' - Policy object: "runtimeVersion": { "policy": "appVersion" }',
|
|
46
44
|
);
|
|
47
45
|
}
|
|
48
46
|
|
|
@@ -51,7 +49,5 @@ export function resolveRuntimeVersion(appJson: IAppJson): string {
|
|
|
51
49
|
*/
|
|
52
50
|
export function getPlatforms(appJson: IAppJson): PlatformType[] {
|
|
53
51
|
const platforms = appJson.expo.platforms || ["ios", "android"];
|
|
54
|
-
return platforms.filter(
|
|
55
|
-
(p) => p === "ios" || p === "android"
|
|
56
|
-
) as PlatformType[];
|
|
52
|
+
return platforms.filter((p) => p === "ios" || p === "android") as PlatformType[];
|
|
57
53
|
}
|
package/src/utils/runx.ts
CHANGED
|
@@ -4,11 +4,8 @@ import { execSync, ExecSyncOptions } from "child_process";
|
|
|
4
4
|
* Execute a command using the appropriate package runner (bunx or npx)
|
|
5
5
|
* based on the current runtime environment.
|
|
6
6
|
*/
|
|
7
|
-
export function runx(
|
|
8
|
-
|
|
9
|
-
options?: ExecSyncOptions
|
|
10
|
-
): Buffer | string {
|
|
11
|
-
const packageRunner = !!process.versions["bun"] ? "bunx" : "npx";
|
|
7
|
+
export function runx(command: string, options?: ExecSyncOptions): Buffer | string {
|
|
8
|
+
const packageRunner = process.versions["bun"] ? "bunx" : "npx";
|
|
12
9
|
|
|
13
10
|
return execSync(`${packageRunner} ${command}`, options);
|
|
14
11
|
}
|
package/src/utils/schema.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach, afterEach } from "
|
|
1
|
+
import { describe, it, expect, beforeEach, afterEach } from "vite-plus/test";
|
|
2
2
|
import {
|
|
3
3
|
validateEnvironment,
|
|
4
4
|
validateChannel,
|
|
@@ -70,13 +70,7 @@ describe("Schema utilities", () => {
|
|
|
70
70
|
|
|
71
71
|
describe("validateChannel", () => {
|
|
72
72
|
it("should pass for valid channel names", () => {
|
|
73
|
-
const validChannels = [
|
|
74
|
-
"production",
|
|
75
|
-
"staging",
|
|
76
|
-
"dev",
|
|
77
|
-
"test-123",
|
|
78
|
-
"feature_branch",
|
|
79
|
-
];
|
|
73
|
+
const validChannels = ["production", "staging", "dev", "test-123", "feature_branch"];
|
|
80
74
|
|
|
81
75
|
for (const channel of validChannels) {
|
|
82
76
|
const result = validateChannel(channel);
|
package/src/utils/schema.ts
CHANGED
|
@@ -11,7 +11,7 @@ const channelSchema = z
|
|
|
11
11
|
.min(1, "Channel name is required")
|
|
12
12
|
.regex(
|
|
13
13
|
/^[a-zA-Z0-9-_]+$/,
|
|
14
|
-
"Channel names can only contain letters, numbers, hyphens, and underscores"
|
|
14
|
+
"Channel names can only contain letters, numbers, hyphens, and underscores",
|
|
15
15
|
);
|
|
16
16
|
|
|
17
17
|
const configSchema = z.object({
|
|
@@ -38,9 +38,7 @@ function formatZodError(error: z.ZodError, context?: string): string[] {
|
|
|
38
38
|
if (context === "environment") {
|
|
39
39
|
if (path === "OTA_SERVER") {
|
|
40
40
|
return (
|
|
41
|
-
`${chalk.red(
|
|
42
|
-
"OTA_SERVER"
|
|
43
|
-
)} environment variable is required or invalid\n` +
|
|
41
|
+
`${chalk.red("OTA_SERVER")} environment variable is required or invalid\n` +
|
|
44
42
|
` Set it in your .env file or export it:\n` +
|
|
45
43
|
` export OTA_SERVER="https://your-ota-server.com"`
|
|
46
44
|
);
|
|
@@ -89,9 +87,7 @@ export function validateEnvironment(): IValidationResult {
|
|
|
89
87
|
/**
|
|
90
88
|
* Validate a channel name using zod
|
|
91
89
|
*/
|
|
92
|
-
export function validateChannel(
|
|
93
|
-
channel: string | undefined
|
|
94
|
-
): IValidationResult {
|
|
90
|
+
export function validateChannel(channel: string | undefined): IValidationResult {
|
|
95
91
|
if (!channel) {
|
|
96
92
|
return {
|
|
97
93
|
valid: false,
|
package/src/utils/upload.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface IUploadOptions {
|
|
|
14
14
|
platform: PlatformType;
|
|
15
15
|
runtimeVersion: string;
|
|
16
16
|
expoConfig: IAppJson["expo"];
|
|
17
|
+
fingerprint?: string | undefined;
|
|
18
|
+
ignoreFingerprintCheck?: boolean | undefined;
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
/**
|
|
@@ -30,6 +32,8 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
|
|
|
30
32
|
assetPaths,
|
|
31
33
|
expoConfig,
|
|
32
34
|
runtimeVersion,
|
|
35
|
+
fingerprint,
|
|
36
|
+
ignoreFingerprintCheck,
|
|
33
37
|
} = options;
|
|
34
38
|
|
|
35
39
|
const form = new FormData();
|
|
@@ -43,6 +47,14 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
|
|
|
43
47
|
form.append("commitHash", commitHash);
|
|
44
48
|
}
|
|
45
49
|
|
|
50
|
+
if (fingerprint) {
|
|
51
|
+
form.append("fingerprint", fingerprint);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (ignoreFingerprintCheck) {
|
|
55
|
+
form.append("ignoreFingerprintCheck", "true");
|
|
56
|
+
}
|
|
57
|
+
|
|
46
58
|
// Add bundle
|
|
47
59
|
const bundleBuffer = fs.readFileSync(bundlePath);
|
|
48
60
|
const bundleBlob = new Blob([bundleBuffer]);
|
|
@@ -63,7 +75,6 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
|
|
|
63
75
|
form.append(`asset-${index}`, assetBlob, assetFileName);
|
|
64
76
|
});
|
|
65
77
|
|
|
66
|
-
// Upload
|
|
67
78
|
const url = new URL("/upload", config.otaServer);
|
|
68
79
|
|
|
69
80
|
const response = await fetch(url.toString(), {
|
|
@@ -75,10 +86,18 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
|
|
|
75
86
|
});
|
|
76
87
|
|
|
77
88
|
if (!response.ok) {
|
|
89
|
+
if (response.status === 409) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
"Fingerprint mismatch: the native fingerprint of this update does not match the latest deployed update. " +
|
|
92
|
+
"This usually means native dependencies have changed and a new native build is required. " +
|
|
93
|
+
"Use --dangerously-ignore-fingerprint-check to bypass this check.",
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
78
97
|
let errorText = "";
|
|
79
98
|
try {
|
|
80
99
|
errorText = await response.text();
|
|
81
|
-
} catch
|
|
100
|
+
} catch {
|
|
82
101
|
errorText = "Unable to read error response";
|
|
83
102
|
}
|
|
84
103
|
throw new Error(`Upload failed: ${response.status} ${errorText}`);
|
|
@@ -96,14 +115,7 @@ export function createDryRunSummary(options: {
|
|
|
96
115
|
platform: PlatformType;
|
|
97
116
|
runtimeVersion: string;
|
|
98
117
|
}): string {
|
|
99
|
-
const {
|
|
100
|
-
channel,
|
|
101
|
-
platform,
|
|
102
|
-
bundlePath,
|
|
103
|
-
assetPaths,
|
|
104
|
-
commitHash,
|
|
105
|
-
runtimeVersion,
|
|
106
|
-
} = options;
|
|
118
|
+
const { channel, platform, bundlePath, assetPaths, commitHash, runtimeVersion } = options;
|
|
107
119
|
|
|
108
120
|
const bundleSize = fs.statSync(bundlePath).size;
|
|
109
121
|
const totalAssetSize = assetPaths.reduce((sum, path) => {
|
|
@@ -122,7 +134,7 @@ export function createDryRunSummary(options: {
|
|
|
122
134
|
|
|
123
135
|
lines.push(
|
|
124
136
|
`Bundle: ${formatBytes(bundleSize)}`,
|
|
125
|
-
`Assets: ${assetPaths.length} files (${formatBytes(totalAssetSize)})
|
|
137
|
+
`Assets: ${assetPaths.length} files (${formatBytes(totalAssetSize)})`,
|
|
126
138
|
);
|
|
127
139
|
|
|
128
140
|
return lines.join("\n");
|