easc 0.0.7 → 0.0.9
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 -0
- package/bin/easc.js +22 -9
- package/index.ts +0 -3
- package/package.json +3 -4
- package/src/utils/cli.ts +69 -53
- package/src/utils/logger.ts +0 -22
- package/src/utils/upload.ts +15 -19
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/bin/easc.js
CHANGED
|
@@ -6,20 +6,33 @@ import { existsSync } from "fs";
|
|
|
6
6
|
import { createRequire } from "module";
|
|
7
7
|
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
9
|
-
const require = createRequire(import.meta.url);
|
|
10
|
-
const tsxPath = require.resolve("tsx/esm");
|
|
11
9
|
const indexPath = join(__dirname, "..", "index.ts");
|
|
12
|
-
|
|
13
10
|
const envPath = join(process.cwd(), ".env");
|
|
14
|
-
const nodeArgs = ["--import", tsxPath];
|
|
15
11
|
|
|
16
|
-
if
|
|
17
|
-
|
|
18
|
-
}
|
|
12
|
+
// Detect if running under Bun
|
|
13
|
+
const isBun = typeof Bun !== "undefined";
|
|
19
14
|
|
|
20
|
-
|
|
15
|
+
let runtime, args;
|
|
16
|
+
|
|
17
|
+
if (isBun) {
|
|
18
|
+
runtime = "bun";
|
|
19
|
+
args = [];
|
|
20
|
+
if (existsSync(envPath)) {
|
|
21
|
+
args.push("--env-file", envPath);
|
|
22
|
+
}
|
|
23
|
+
args.push(indexPath, ...process.argv.slice(2));
|
|
24
|
+
} else {
|
|
25
|
+
runtime = "node";
|
|
26
|
+
const require = createRequire(import.meta.url);
|
|
27
|
+
const tsxPath = require.resolve("tsx/esm");
|
|
28
|
+
args = ["--import", tsxPath];
|
|
29
|
+
if (existsSync(envPath)) {
|
|
30
|
+
args.push("--env-file", envPath);
|
|
31
|
+
}
|
|
32
|
+
args.push(indexPath, ...process.argv.slice(2));
|
|
33
|
+
}
|
|
21
34
|
|
|
22
|
-
const child = spawn(
|
|
35
|
+
const child = spawn(runtime, args, { stdio: "inherit" });
|
|
23
36
|
|
|
24
37
|
child.on("exit", (code) => {
|
|
25
38
|
process.exit(code || 0);
|
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.
|
|
3
|
+
"version": "0.0.9",
|
|
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": "
|
|
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": "^
|
|
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
|
-
.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
|
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
|
|
90
|
-
args
|
|
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
|
|
106
|
-
dryRun: args
|
|
107
|
-
environment: args
|
|
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
|
|
113
|
-
prod: args
|
|
128
|
+
exportDir: args["exportDir"] as string,
|
|
129
|
+
prod: args["prod"] as boolean,
|
|
114
130
|
help: args["help"] as boolean | undefined,
|
|
115
131
|
};
|
|
116
132
|
}
|
package/src/utils/logger.ts
CHANGED
|
@@ -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
|
*/
|
package/src/utils/upload.ts
CHANGED
|
@@ -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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
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
|
|
84
|
+
throw new Error(`Upload failed: ${response.status} ${errorText}`);
|
|
89
85
|
}
|
|
90
86
|
}
|
|
91
87
|
|