easc 0.0.4 → 0.0.6

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/bin/easc.js CHANGED
@@ -3,12 +3,15 @@ import { spawn } from "child_process";
3
3
  import { fileURLToPath } from "url";
4
4
  import { dirname, join } from "path";
5
5
  import { existsSync } from "fs";
6
+ import { createRequire } from "module";
6
7
 
7
8
  const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const require = createRequire(import.meta.url);
10
+ const tsxPath = require.resolve("tsx/esm");
8
11
  const indexPath = join(__dirname, "..", "index.ts");
9
12
 
10
13
  const envPath = join(process.cwd(), ".env");
11
- const nodeArgs = ["--experimental-strip-types"];
14
+ const nodeArgs = ["--import", tsxPath];
12
15
 
13
16
  if (existsSync(envPath)) {
14
17
  nodeArgs.push("--env-file", envPath);
package/index.ts CHANGED
@@ -2,24 +2,20 @@
2
2
  import { execSync } from "child_process";
3
3
  import fs from "fs";
4
4
  import chalk from "chalk";
5
- import { parseArguments } from "./src/utils/cli.ts";
6
- import { validateConfig, getConfig } from "./src/utils/schema.ts";
7
- import { resolveRuntimeVersion, getPlatforms } from "./src/utils/runtime.ts";
8
- import {
9
- getCommitHash,
10
- getShortCommitHash,
11
- isGitClean,
12
- } from "./src/utils/git.ts";
5
+ import { parseArguments } from "./src/utils/cli";
6
+ import { validateConfig, getConfig } from "./src/utils/schema";
7
+ import { resolveRuntimeVersion, getPlatforms } from "./src/utils/runtime";
8
+ import { getCommitHash, getShortCommitHash, isGitClean } from "./src/utils/git";
13
9
  import {
14
10
  readAppJson,
15
11
  readMetadata,
16
12
  findBundleFile,
17
13
  getAssetFiles,
18
14
  checkExportDirectory,
19
- } from "./src/utils/files.ts";
20
- import { uploadBundle, createDryRunSummary } from "./src/utils/upload.ts";
21
- import { Logger } from "./src/utils/logger.ts";
22
- import type { PlatformType } from "./src/enums/platform.ts";
15
+ } from "./src/utils/files";
16
+ import { uploadBundle, createDryRunSummary } from "./src/utils/upload";
17
+ import { Logger } from "./src/utils/logger";
18
+ import { PlatformType } from "./src/enums/platform";
23
19
 
24
20
  type IDeploymentResult = {
25
21
  platform: PlatformType;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
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",
@@ -12,9 +12,18 @@
12
12
  "index.ts",
13
13
  "src"
14
14
  ],
15
+ "scripts": {
16
+ "test": "vitest",
17
+ "test:watch": "vitest --watch",
18
+ "test:ui": "vitest --ui",
19
+ "test:coverage": "vitest --coverage",
20
+ "typecheck": "tsc --noEmit",
21
+ "prepublishOnly": "pnpm run test"
22
+ },
15
23
  "dependencies": {
16
24
  "chalk": "5.6.0",
17
25
  "ora": "^9.0.0",
26
+ "tsx": "^4.20.6",
18
27
  "yargs": "^18.0.0",
19
28
  "zod": "^4.1.12"
20
29
  },
@@ -26,7 +35,7 @@
26
35
  "vitest": "^3.2.4"
27
36
  },
28
37
  "engines": {
29
- "node": ">=22.6.0"
38
+ "node": ">=18.0.0"
30
39
  },
31
40
  "repository": {
32
41
  "type": "git",
@@ -43,12 +52,5 @@
43
52
  ],
44
53
  "publishConfig": {
45
54
  "access": "public"
46
- },
47
- "scripts": {
48
- "test": "vitest",
49
- "test:watch": "vitest --watch",
50
- "test:ui": "vitest --ui",
51
- "test:coverage": "vitest --coverage",
52
- "typecheck": "tsc --noEmit"
53
55
  }
54
- }
56
+ }
@@ -1,3 +1,6 @@
1
- export type Platform = "ios" | "android";
1
+ export enum Platform {
2
+ iOS = "ios",
3
+ Android = "android",
4
+ }
2
5
 
3
- export type PlatformType = Platform;
6
+ export type PlatformType = Platform.iOS | Platform.Android;
@@ -1,14 +1,14 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import type { IAppJson } from "./runtime.ts";
4
- import type { PlatformType } from "../enums/platform.ts";
3
+ import { IAppJson } from "./runtime";
4
+ import { Platform, PlatformType } from "../enums/platform";
5
5
 
6
6
  export interface IMetadata {
7
7
  fileMetadata?: {
8
- ios?: {
8
+ [Platform.iOS]?: {
9
9
  assets: Array<{ path: string }>;
10
10
  };
11
- android?: {
11
+ [Platform.Android]?: {
12
12
  assets: Array<{ path: string }>;
13
13
  };
14
14
  };
@@ -96,9 +96,9 @@ export function getAssetFiles(
96
96
  }
97
97
 
98
98
  const platformMetadata =
99
- platform === "ios"
100
- ? metadata.fileMetadata?.ios
101
- : metadata.fileMetadata?.android;
99
+ platform === Platform.iOS
100
+ ? metadata.fileMetadata?.[Platform.iOS]
101
+ : metadata.fileMetadata?.[Platform.Android];
102
102
  const platformAssets = platformMetadata?.assets || [];
103
103
 
104
104
  if (platformAssets.length === 0) {
@@ -1,6 +1,5 @@
1
1
  import chalk from "chalk";
2
- import ora from "ora";
3
- import type { Ora } from "ora";
2
+ import ora, { Ora } from "ora";
4
3
 
5
4
  export class Logger {
6
5
  private spinner: Ora | null = null;
@@ -2,7 +2,7 @@
2
2
  * Utilities for handling Expo runtime versions
3
3
  */
4
4
 
5
- import type { PlatformType } from "../enums/platform.ts";
5
+ import { PlatformType } from "../enums/platform";
6
6
 
7
7
  export interface IAppJson {
8
8
  expo: {
@@ -1,8 +1,9 @@
1
1
  import fs from "fs";
2
- import type { IAppJson } from "./runtime.ts";
3
- import type { IMetadata } from "./files.ts";
4
- import type { IConfig } from "./schema.ts";
5
- import type { PlatformType } from "../enums/platform.ts";
2
+ import { readFile } from "fs/promises";
3
+ import { IAppJson } from "./runtime";
4
+ import { IMetadata } from "./files";
5
+ import { IConfig } from "./schema";
6
+ import { PlatformType } from "../enums/platform";
6
7
 
7
8
  export interface IUploadOptions {
8
9
  config: IConfig;
@@ -20,6 +21,7 @@ export interface IUploadOptions {
20
21
  * Upload a bundle and assets for a platform
21
22
  */
22
23
  export async function uploadBundle(options: IUploadOptions): Promise<void> {
24
+ const startTime = Date.now();
23
25
  const {
24
26
  config,
25
27
  channel,
@@ -44,7 +46,8 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
44
46
  }
45
47
 
46
48
  // Add bundle
47
- const bundleBuffer = fs.readFileSync(bundlePath);
49
+ const fileReadStartTime = Date.now();
50
+ const bundleBuffer = await readFile(bundlePath);
48
51
  const bundleBlob = new Blob([bundleBuffer]);
49
52
  const bundleFileName = bundlePath.split("/").pop();
50
53
  if (!bundleFileName) {
@@ -52,9 +55,17 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
52
55
  }
53
56
  form.append("bundle", bundleBlob, bundleFileName);
54
57
 
55
- // Add assets
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
+
56
64
  assetPaths.forEach((assetPath, index) => {
57
- const assetBuffer = fs.readFileSync(assetPath);
65
+ const assetBuffer = assetBuffers[index];
66
+ if (!assetBuffer) {
67
+ throw new Error(`Failed to read asset: ${assetPath}`);
68
+ }
58
69
  const assetBlob = new Blob([assetBuffer]);
59
70
  const assetFileName = assetPath.split("/").pop();
60
71
  if (!assetFileName) {
@@ -66,6 +77,8 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
66
77
  // Upload
67
78
  const url = new URL("/upload", config.otaServer);
68
79
 
80
+ console.log(`⏱️ Uploading ${assetPaths.length + 1} files...`);
81
+ const uploadStartTime = Date.now();
69
82
  const response = await fetch(url.toString(), {
70
83
  method: "POST",
71
84
  headers: {
@@ -73,6 +86,7 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
73
86
  },
74
87
  body: form,
75
88
  });
89
+ console.log(`⏱️ Network upload completed in ${Date.now() - uploadStartTime}ms`);
76
90
 
77
91
  if (!response.ok) {
78
92
  let errorText = "";
@@ -83,6 +97,9 @@ export async function uploadBundle(options: IUploadOptions): Promise<void> {
83
97
  }
84
98
  throw new Error(`Upload failed: ${response.status} ${errorText}`);
85
99
  }
100
+
101
+ const totalTime = Date.now() - startTime;
102
+ console.log(`⏱️ Total upload time: ${totalTime}ms (${(totalTime / 1000).toFixed(1)}s)`);
86
103
  }
87
104
 
88
105
  /**