easc 0.0.7 → 0.0.8

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 CHANGED
@@ -14,12 +14,14 @@ pnpm link --global
14
14
 
15
15
  # Now you can use 'easc' command globally
16
16
  easc --help
17
+ easc update --help
17
18
  ```
18
19
 
19
20
  Or can also run directly with tsx:
20
21
 
21
22
  ```bash
22
23
  tsx index.ts --help
24
+ tsx index.ts update --help
23
25
  ```
24
26
 
25
27
  ## Publishing
package/index.ts CHANGED
@@ -127,9 +127,6 @@ type IDeploymentResult = {
127
127
  expoConfig: appJson.expo,
128
128
  metadata,
129
129
  config,
130
- onProgress: (loaded, total) => {
131
- logger.updateProgress(loaded, total, `Uploading ${platform}`);
132
- },
133
130
  });
134
131
 
135
132
  logger.succeedSpinner(`${platform} uploaded`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Expo App Services for Cloudflare - Deploy tool for Expo OTA updates to Cloudflare Workers",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,11 +17,10 @@
17
17
  "test:watch": "vitest --watch",
18
18
  "test:ui": "vitest --ui",
19
19
  "test:coverage": "vitest --coverage",
20
- "typecheck": "tsc --noEmit",
20
+ "typecheck": "tsgo --noEmit",
21
21
  "prepublishOnly": "pnpm run test"
22
22
  },
23
23
  "dependencies": {
24
- "axios": "^1.12.2",
25
24
  "chalk": "5.6.0",
26
25
  "ora": "^9.0.0",
27
26
  "tsx": "^4.20.6",
@@ -32,7 +31,7 @@
32
31
  "@types/node": "^24.8.0",
33
32
  "@types/yargs": "^17.0.33",
34
33
  "@vitest/ui": "^3.0.0",
35
- "typescript": "^5.3.3",
34
+ "@typescript/native-preview": "^7.0.0-dev.20250601",
36
35
  "vitest": "^3.2.4"
37
36
  },
38
37
  "engines": {
package/src/utils/cli.ts CHANGED
@@ -31,49 +31,65 @@ function mapEnvironmentToChannel(
31
31
  export function parseArguments(argv: string[] = process.argv): ICliOptions {
32
32
  const args = yargs(hideBin(argv))
33
33
  .scriptName("easc")
34
- .usage("$0 [options]")
35
- .usage("$0 --channel <channel>")
36
- .usage("$0 --prod")
37
- .option("channel", {
38
- alias: "c",
39
- type: "string",
40
- description: "Deployment channel (e.g., production, staging)",
41
- })
42
- .option("skip-build", {
43
- type: "boolean",
44
- description: "Skip running 'expo export' (use existing build)",
45
- default: false,
46
- })
47
- .option("dry-run", {
48
- type: "boolean",
49
- description:
50
- "Outputs deployment info instead of uploading (preview what would be deployed)",
51
- default: false,
52
- })
53
- .option("environment", {
54
- type: "string",
55
- choices: ["development", "preview", "production"],
56
- description: "Environment variable's environment",
57
- })
58
- .option("export-dir", {
59
- type: "string",
60
- description: "Directory where the Expo project was exported",
61
- default: "dist",
62
- })
63
- .option("prod", {
64
- type: "boolean",
65
- description:
66
- "Create a new production deployment (shorthand for --channel production)",
67
- default: false,
68
- })
69
- .example("$0 --channel production", "Deploy to production channel")
70
- .example("$0 --prod", "Deploy to production (EAS-style)")
71
- .example("$0 --environment preview", "Deploy to preview environment")
72
- .example("$0 -c staging --skip-build", "Deploy existing build to staging")
73
- .example(
74
- "$0 --dry-run --export-dir ./out",
75
- "Dry run with custom export directory"
34
+ .usage("$0 <command> [options]")
35
+ .command(
36
+ "update",
37
+ "Deploy an OTA update to the specified channel",
38
+ (yargs) => {
39
+ return yargs
40
+ .option("channel", {
41
+ alias: "c",
42
+ type: "string",
43
+ description: "Deployment channel (e.g., production, staging)",
44
+ })
45
+ .option("skip-build", {
46
+ type: "boolean",
47
+ description: "Skip running 'expo export' (use existing build)",
48
+ default: false,
49
+ })
50
+ .option("dry-run", {
51
+ type: "boolean",
52
+ description:
53
+ "Outputs deployment info instead of uploading (preview what would be deployed)",
54
+ default: false,
55
+ })
56
+ .option("environment", {
57
+ type: "string",
58
+ choices: ["development", "preview", "production"],
59
+ description: "Environment variable's environment",
60
+ })
61
+ .option("export-dir", {
62
+ type: "string",
63
+ description: "Directory where the Expo project was exported",
64
+ default: "dist",
65
+ })
66
+ .option("prod", {
67
+ type: "boolean",
68
+ description:
69
+ "Create a new production deployment (shorthand for --channel production)",
70
+ default: false,
71
+ })
72
+ .example(
73
+ "$0 update --channel production",
74
+ "Deploy to production channel"
75
+ )
76
+ .example("$0 update --prod", "Deploy to production (EAS-style)")
77
+ .example(
78
+ "$0 update --environment preview",
79
+ "Deploy to preview environment"
80
+ )
81
+ .example(
82
+ "$0 update -c staging --skip-build",
83
+ "Deploy existing build to staging"
84
+ )
85
+ .example(
86
+ "$0 update --dry-run --export-dir ./out",
87
+ "Dry run with custom export directory"
88
+ );
89
+ }
76
90
  )
91
+ .demandCommand(1, "")
92
+ .showHelpOnFail(true)
77
93
  .help()
78
94
  .alias("help", "h")
79
95
  .alias("version", "V")
@@ -81,36 +97,36 @@ export function parseArguments(argv: string[] = process.argv): ICliOptions {
81
97
  .parseSync();
82
98
 
83
99
  // Map EAS-style flags to our channel system
84
- let channel = args.channel as string | undefined;
100
+ let channel = args["channel"] as string | undefined;
85
101
 
86
102
  // If no channel specified, try to derive from EAS flags
87
103
  if (!channel) {
88
104
  channel = mapEnvironmentToChannel(
89
- args.environment as string,
90
- args.prod as boolean
105
+ args["environment"] as string,
106
+ args["prod"] as boolean
91
107
  );
92
108
  }
93
109
 
94
110
  if (!channel && !args["help"]) {
95
111
  console.error(chalk.red("Error: Channel is required"));
96
112
  console.log("Use one of the following:");
97
- console.log(" easc --channel production");
98
- console.log(" easc --prod");
99
- console.log(" easc --environment production");
113
+ console.log(" easc update --channel production");
114
+ console.log(" easc update --prod");
115
+ console.log(" easc update --environment production");
100
116
  process.exit(1);
101
117
  }
102
118
 
103
119
  return {
104
120
  channel,
105
- skipBuild: args.skipBuild as boolean,
106
- dryRun: args.dryRun as boolean,
107
- environment: args.environment as
121
+ skipBuild: args["skipBuild"] as boolean,
122
+ dryRun: args["dryRun"] as boolean,
123
+ environment: args["environment"] as
108
124
  | "development"
109
125
  | "preview"
110
126
  | "production"
111
127
  | undefined,
112
- exportDir: args.exportDir as string,
113
- prod: args.prod as boolean,
128
+ exportDir: args["exportDir"] as string,
129
+ prod: args["prod"] as boolean,
114
130
  help: args["help"] as boolean | undefined,
115
131
  };
116
132
  }
@@ -50,28 +50,6 @@ export class Logger {
50
50
  }
51
51
  }
52
52
 
53
- /**
54
- * Update spinner with progress bar
55
- */
56
- updateProgress(
57
- loaded: number,
58
- total: number,
59
- prefix: string = "Uploading"
60
- ): void {
61
- const percent = Math.round((loaded / total) * 100);
62
- const loadedMB = (loaded / 1024 / 1024).toFixed(1);
63
- const totalMB = (total / 1024 / 1024).toFixed(1);
64
-
65
- // Create progress bar (20 characters wide)
66
- const barWidth = 20;
67
- const filled = Math.round((loaded / total) * barWidth);
68
- const empty = barWidth - filled;
69
- const bar = "█".repeat(filled) + "░".repeat(empty);
70
-
71
- const message = `${prefix}... [${bar}] ${loadedMB} MB / ${totalMB} MB (${percent}%)`;
72
- this.updateSpinner(message);
73
- }
74
-
75
53
  /**
76
54
  * Stop spinner with success
77
55
  */
@@ -1,5 +1,4 @@
1
1
  import fs from "fs";
2
- import axios from "axios";
3
2
  import { IAppJson } from "./runtime";
4
3
  import { IMetadata } from "./files";
5
4
  import { IConfig } from "./schema";
@@ -15,7 +14,6 @@ export interface IUploadOptions {
15
14
  platform: PlatformType;
16
15
  runtimeVersion: string;
17
16
  expoConfig: IAppJson["expo"];
18
- onProgress?: (loaded: number, total: number) => void;
19
17
  }
20
18
 
21
19
  /**
@@ -32,7 +30,6 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
32
30
  assetPaths,
33
31
  expoConfig,
34
32
  runtimeVersion,
35
- onProgress,
36
33
  } = options;
37
34
 
38
35
  const form = new FormData();
@@ -69,23 +66,22 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
69
66
  // Upload
70
67
  const url = new URL("/upload", config.otaServer);
71
68
 
72
- try {
73
- await axios.post(url.toString(), form, {
74
- headers: {
75
- "x-ota-api-key": config.apiKey,
76
- },
77
- onUploadProgress: (progressEvent) => {
78
- if (progressEvent.total && onProgress) {
79
- onProgress(progressEvent.loaded, progressEvent.total);
80
- }
81
- },
82
- });
83
- } catch (error) {
84
- if (axios.isAxiosError(error)) {
85
- const errorText = error.response?.data || error.message;
86
- throw new Error(`Upload failed: ${error.response?.status || "unknown"} ${errorText}`);
69
+ const response = await fetch(url.toString(), {
70
+ method: "POST",
71
+ headers: {
72
+ "x-ota-api-key": config.apiKey,
73
+ },
74
+ body: form,
75
+ });
76
+
77
+ if (!response.ok) {
78
+ let errorText = "";
79
+ try {
80
+ errorText = await response.text();
81
+ } catch (e) {
82
+ errorText = "Unable to read error response";
87
83
  }
88
- throw error;
84
+ throw new Error(`Upload failed: ${response.status} ${errorText}`);
89
85
  }
90
86
  }
91
87