easc 0.0.6 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.6",
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,7 +17,7 @@
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": {
@@ -31,7 +31,7 @@
31
31
  "@types/node": "^24.8.0",
32
32
  "@types/yargs": "^17.0.33",
33
33
  "@vitest/ui": "^3.0.0",
34
- "typescript": "^5.3.3",
34
+ "@typescript/native-preview": "^7.0.0-dev.20250601",
35
35
  "vitest": "^3.2.4"
36
36
  },
37
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
  }
@@ -1,5 +1,4 @@
1
1
  import fs from "fs";
2
- import { readFile } from "fs/promises";
3
2
  import { IAppJson } from "./runtime";
4
3
  import { IMetadata } from "./files";
5
4
  import { IConfig } from "./schema";
@@ -21,7 +20,6 @@ export interface IUploadOptions {
21
20
  * Upload a bundle and assets for a platform
22
21
  */
23
22
  export async function uploadBundle(options: IUploadOptions): Promise<void> {
24
- const startTime = Date.now();
25
23
  const {
26
24
  config,
27
25
  channel,
@@ -46,8 +44,7 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
46
44
  }
47
45
 
48
46
  // Add bundle
49
- const fileReadStartTime = Date.now();
50
- const bundleBuffer = await readFile(bundlePath);
47
+ const bundleBuffer = fs.readFileSync(bundlePath);
51
48
  const bundleBlob = new Blob([bundleBuffer]);
52
49
  const bundleFileName = bundlePath.split("/").pop();
53
50
  if (!bundleFileName) {
@@ -55,17 +52,9 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
55
52
  }
56
53
  form.append("bundle", bundleBlob, bundleFileName);
57
54
 
58
- // Add assets in parallel
59
- const assetBuffers = await Promise.all(
60
- assetPaths.map((assetPath) => readFile(assetPath))
61
- );
62
- console.log(`⏱️ Files read in ${Date.now() - fileReadStartTime}ms`);
63
-
55
+ // Add assets
64
56
  assetPaths.forEach((assetPath, index) => {
65
- const assetBuffer = assetBuffers[index];
66
- if (!assetBuffer) {
67
- throw new Error(`Failed to read asset: ${assetPath}`);
68
- }
57
+ const assetBuffer = fs.readFileSync(assetPath);
69
58
  const assetBlob = new Blob([assetBuffer]);
70
59
  const assetFileName = assetPath.split("/").pop();
71
60
  if (!assetFileName) {
@@ -77,8 +66,6 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
77
66
  // Upload
78
67
  const url = new URL("/upload", config.otaServer);
79
68
 
80
- console.log(`⏱️ Uploading ${assetPaths.length + 1} files...`);
81
- const uploadStartTime = Date.now();
82
69
  const response = await fetch(url.toString(), {
83
70
  method: "POST",
84
71
  headers: {
@@ -86,7 +73,6 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
86
73
  },
87
74
  body: form,
88
75
  });
89
- console.log(`⏱️ Network upload completed in ${Date.now() - uploadStartTime}ms`);
90
76
 
91
77
  if (!response.ok) {
92
78
  let errorText = "";
@@ -97,9 +83,6 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
97
83
  }
98
84
  throw new Error(`Upload failed: ${response.status} ${errorText}`);
99
85
  }
100
-
101
- const totalTime = Date.now() - startTime;
102
- console.log(`⏱️ Total upload time: ${totalTime}ms (${(totalTime / 1000).toFixed(1)}s)`);
103
86
  }
104
87
 
105
88
  /**