easc 0.0.32 → 0.0.34

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.32",
3
+ "version": "0.0.34",
4
4
  "description": "Expo App Services for Cloudflare - Deploy tool for Expo OTA updates to Cloudflare Workers",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -35,15 +35,15 @@
35
35
  "test:coverage": "vp test --coverage"
36
36
  },
37
37
  "dependencies": {
38
- "@expo/fingerprint": "^0.11.0",
38
+ "@expo/fingerprint": "^0.20.2",
39
39
  "@inquirer/prompts": "^8.3.2",
40
40
  "chalk": "5.6.2",
41
41
  "tsx": "^4.21.0",
42
- "yargs": "^18.0.0",
43
- "zod": "^4.3.6"
42
+ "valibot": "^1.1.0",
43
+ "yargs": "^18.0.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@types/node": "^25.5.0",
46
+ "@types/node": "^26.1.0",
47
47
  "@types/yargs": "^17.0.35",
48
48
  "@vitest/ui": "^4.1.0",
49
49
  "vite-plus": "latest",
@@ -9,7 +9,7 @@ import {
9
9
  getAssetFiles,
10
10
  checkExportDirectory,
11
11
  } from "../utils/files";
12
- import { uploadBundle, createDryRunSummary } from "../utils/upload";
12
+ import { uploadBundle, createDryRunSummary, getUpdateSize, formatBytes } from "../utils/upload";
13
13
  import { createFingerprintAsync } from "@expo/fingerprint";
14
14
  import { Logger } from "../utils/logger";
15
15
  import { runx } from "../utils/runx";
@@ -106,6 +106,12 @@ export const update: CommandModule = {
106
106
  const { hash: fingerprint } = await createFingerprintAsync(process.cwd());
107
107
  logger.success(`Fingerprint: ${fingerprint}`);
108
108
 
109
+ const platformUploads = platforms.map((platform) => ({
110
+ platform,
111
+ bundlePath: findBundleFile(exportDir, metadata, platform),
112
+ assetPaths: getAssetFiles(exportDir, metadata, platform),
113
+ }));
114
+
109
115
  logger.section("📤 Deployment Info");
110
116
  logger.table([
111
117
  ["Server", config.otaServer],
@@ -114,14 +120,12 @@ export const update: CommandModule = {
114
120
  ["Fingerprint", fingerprint || ""],
115
121
  ["Export Dir", args.exportDir],
116
122
  ["Channel", channel],
123
+ ...platformUploads.map(({ platform, bundlePath, assetPaths }): [string, string] => [
124
+ `Size (${platform})`,
125
+ formatBytes(getUpdateSize(bundlePath, assetPaths)),
126
+ ]),
117
127
  ]);
118
128
 
119
- const platformUploads = platforms.map((platform) => ({
120
- platform,
121
- bundlePath: findBundleFile(exportDir, metadata, platform),
122
- assetPaths: getAssetFiles(exportDir, metadata, platform),
123
- }));
124
-
125
129
  if (args.dryRun) {
126
130
  for (const { platform, bundlePath, assetPaths } of platformUploads) {
127
131
  logger.section(platform.toUpperCase());
@@ -167,9 +171,9 @@ export const update: CommandModule = {
167
171
 
168
172
  logger.stopSpinner();
169
173
 
170
- const failed = results.filter((r) => r.status === "rejected");
171
- if (failed.length > 0) {
172
- throw (failed[0] as PromiseRejectedResult).reason;
174
+ const firstFailure = results.find((r): r is PromiseRejectedResult => r.status === "rejected");
175
+ if (firstFailure) {
176
+ throw firstFailure.reason;
173
177
  }
174
178
  }
175
179
 
@@ -178,7 +182,7 @@ export const update: CommandModule = {
178
182
  logger.success("Dry run completed successfully!");
179
183
  logger.info("Run without --dry-run to perform actual upload");
180
184
  } else {
181
- logger.log("\n✨ Updates published successfully!");
185
+ logger.log("✨ Updates published successfully!");
182
186
  }
183
187
  },
184
188
  };
package/src/utils/cli.ts CHANGED
@@ -60,7 +60,7 @@ class InteractiveCLI {
60
60
 
61
61
  this.commands.push({
62
62
  command: commandName,
63
- describe: (cmd.describe as string) ?? "",
63
+ describe: cmd.describe || "",
64
64
  options,
65
65
  handler: cmd.handler as (argv: any) => void | Promise<void>,
66
66
  });
@@ -168,8 +168,7 @@ function _isAppJson(value: unknown): value is IAppJson {
168
168
  if (typeof value !== "object" || value === null || !("expo" in value)) {
169
169
  return false;
170
170
  }
171
- const record = value as Record<string, unknown>;
172
- return typeof record["expo"] === "object" && record["expo"] !== null;
171
+ return typeof value.expo === "object" && value.expo !== null;
173
172
  }
174
173
 
175
174
  /**
@@ -1,26 +1,27 @@
1
1
  import chalk from "chalk";
2
- import { z } from "zod";
2
+ import * as v from "valibot";
3
3
 
4
- const envSchema = z.object({
5
- OTA_SERVER: z.url("OTA_SERVER must be a valid URL"),
6
- OTA_API_KEY: z.string().min(1, "OTA_API_KEY is required"),
4
+ const envSchema = v.object({
5
+ OTA_SERVER: v.pipe(v.string(), v.url("OTA_SERVER must be a valid URL")),
6
+ OTA_API_KEY: v.pipe(v.string(), v.minLength(1, "OTA_API_KEY is required")),
7
7
  });
8
8
 
9
- const channelSchema = z
10
- .string()
11
- .min(1, "Channel name is required")
12
- .regex(
9
+ const channelSchema = v.pipe(
10
+ v.string(),
11
+ v.minLength(1, "Channel name is required"),
12
+ v.regex(
13
13
  /^[a-zA-Z0-9-_]+$/,
14
14
  "Channel names can only contain letters, numbers, hyphens, and underscores",
15
- );
15
+ ),
16
+ );
16
17
 
17
- const configSchema = z.object({
18
+ const configSchema = v.object({
18
19
  channel: channelSchema,
19
- otaServer: z.url(),
20
- apiKey: z.string().min(1),
20
+ otaServer: v.pipe(v.string(), v.url()),
21
+ apiKey: v.pipe(v.string(), v.minLength(1)),
21
22
  });
22
23
 
23
- export type IConfig = z.infer<typeof configSchema>;
24
+ export type IConfig = v.InferOutput<typeof configSchema>;
24
25
 
25
26
  export interface IValidationResult {
26
27
  valid: boolean;
@@ -28,11 +29,11 @@ export interface IValidationResult {
28
29
  }
29
30
 
30
31
  /**
31
- * Format zod errors into user-friendly messages
32
+ * Format valibot issues into user-friendly messages
32
33
  */
33
- function formatZodError(error: z.ZodError, context?: string): string[] {
34
- return error.issues.map((err) => {
35
- const path = err.path.join(".");
34
+ function formatIssues(issues: v.BaseIssue<unknown>[], context?: string): string[] {
35
+ return issues.map((err) => {
36
+ const path = (err.path ?? []).map((p) => p.key).join(".");
36
37
  const message = err.message;
37
38
 
38
39
  if (context === "environment") {
@@ -66,10 +67,10 @@ function formatZodError(error: z.ZodError, context?: string): string[] {
66
67
  }
67
68
 
68
69
  /**
69
- * Validate environment variables using zod
70
+ * Validate environment variables
70
71
  */
71
72
  export function validateEnvironment(): IValidationResult {
72
- const result = envSchema.safeParse({
73
+ const result = v.safeParse(envSchema, {
73
74
  OTA_SERVER: process.env["OTA_SERVER"],
74
75
  OTA_API_KEY: process.env["OTA_API_KEY"],
75
76
  });
@@ -77,7 +78,7 @@ export function validateEnvironment(): IValidationResult {
77
78
  if (!result.success) {
78
79
  return {
79
80
  valid: false,
80
- errors: formatZodError(result.error, "environment"),
81
+ errors: formatIssues(result.issues, "environment"),
81
82
  };
82
83
  }
83
84
 
@@ -85,7 +86,7 @@ export function validateEnvironment(): IValidationResult {
85
86
  }
86
87
 
87
88
  /**
88
- * Validate a channel name using zod
89
+ * Validate a channel name
89
90
  */
90
91
  export function validateChannel(channel: string | undefined): IValidationResult {
91
92
  if (!channel) {
@@ -100,12 +101,12 @@ export function validateChannel(channel: string | undefined): IValidationResult
100
101
  };
101
102
  }
102
103
 
103
- const result = channelSchema.safeParse(channel);
104
+ const result = v.safeParse(channelSchema, channel);
104
105
 
105
106
  if (!result.success) {
106
107
  return {
107
108
  valid: false,
108
- errors: formatZodError(result.error, "channel"),
109
+ errors: formatIssues(result.issues, "channel"),
109
110
  };
110
111
  }
111
112
 
@@ -118,9 +118,7 @@ export function createDryRunSummary(options: {
118
118
  const { channel, platform, bundlePath, assetPaths, commitHash, runtimeVersion } = options;
119
119
 
120
120
  const bundleSize = fs.statSync(bundlePath).size;
121
- const totalAssetSize = assetPaths.reduce((sum, path) => {
122
- return sum + fs.statSync(path).size;
123
- }, 0);
121
+ const totalAssetSize = getUpdateSize(bundlePath, assetPaths) - bundleSize;
124
122
 
125
123
  const lines = [
126
124
  `Platform: ${platform}`,
@@ -140,10 +138,19 @@ export function createDryRunSummary(options: {
140
138
  return lines.join("\n");
141
139
  }
142
140
 
141
+ /**
142
+ * Total size on disk of a bundle plus its assets
143
+ */
144
+ export function getUpdateSize(bundlePath: string, assetPaths: string[]): number {
145
+ return assetPaths.reduce((sum, path) => {
146
+ return sum + fs.statSync(path).size;
147
+ }, fs.statSync(bundlePath).size);
148
+ }
149
+
143
150
  /**
144
151
  * Format bytes to human readable string
145
152
  */
146
- function formatBytes(bytes: number): string {
153
+ export function formatBytes(bytes: number): string {
147
154
  const sizes = ["Bytes", "KB", "MB", "GB"];
148
155
  if (bytes === 0) return "0 Bytes";
149
156
  const i = Math.floor(Math.log(bytes) / Math.log(1024));