easc 0.0.20 → 0.0.23

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
@@ -2,26 +2,25 @@
2
2
 
3
3
  **E**xpo **A**pp **S**ervices for **C**loudflare - CLI tool for deploying Expo OTA updates to Cloudflare Workers.
4
4
 
5
- ## Getting Started
5
+ ## Usage
6
6
 
7
- ### 1. Link for Local Testing
8
-
9
- To test the easc locally, you link the package to replace the published package with your local copy.
7
+ Run without arguments to enter interactive mode:
10
8
 
11
9
  ```bash
12
- # From this directory
13
- pnpm link --global
10
+ easc
11
+ ```
14
12
 
15
- # Now you can use 'easc' command globally
16
- easc --help
17
- easc update --help
13
+ Or run commands directly:
14
+
15
+ ```bash
16
+ easc build --platform ios --profile development
17
+ easc update --channel production
18
18
  ```
19
19
 
20
- Or can also run directly with tsx:
20
+ Use `--non-interactive` flag for CI environments:
21
21
 
22
22
  ```bash
23
- tsx index.ts --help
24
- tsx index.ts update --help
23
+ easc build --platform ios --profile production --non-interactive
25
24
  ```
26
25
 
27
26
  ## Commands
@@ -62,13 +61,28 @@ easc build:run --platform ios --profile preview # Use specific build profile
62
61
  easc build:run --platform ios --path ./build.tar.gz # Run existing artifact (skip build)
63
62
  ```
64
63
 
65
- ## Publishing
64
+ ## Development
66
65
 
67
- To publish this package to npm:
66
+ ### Local Testing
67
+
68
+ To test easc locally, link the package:
68
69
 
69
70
  ```bash
70
- cd apps/easc
71
- npm publish
71
+ # From this directory
72
+ pnpm link --global
73
+
74
+ # Now you can use 'easc' command globally
75
+ easc --help
72
76
  ```
73
77
 
74
- Keep in mind that you'll have to change the name to somthing other than easc if you are not a admin on this project. You may wish to publish your own custom version for extra security.
78
+ Or run directly with tsx:
79
+
80
+ ```bash
81
+ tsx index.ts --help
82
+ ```
83
+
84
+ ### Publishing
85
+
86
+ ```bash
87
+ pnpm version patch && pnpm publish
88
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "easc",
3
- "version": "0.0.20",
3
+ "version": "0.0.23",
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,6 +12,14 @@
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": "tsgo --noEmit",
21
+ "prepublishOnly": "pnpm run test"
22
+ },
15
23
  "dependencies": {
16
24
  "@inquirer/prompts": "^7.8.6",
17
25
  "chalk": "5.6.0",
@@ -45,12 +53,5 @@
45
53
  ],
46
54
  "publishConfig": {
47
55
  "access": "public"
48
- },
49
- "scripts": {
50
- "test": "vitest",
51
- "test:watch": "vitest --watch",
52
- "test:ui": "vitest --ui",
53
- "test:coverage": "vitest --coverage",
54
- "typecheck": "tsgo --noEmit"
55
56
  }
56
- }
57
+ }
@@ -1,6 +1,5 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import chalk from "chalk";
4
3
  import type { CommandModule } from "yargs";
5
4
  import { Logger } from "../utils/logger";
6
5
  import { Platform, PlatformType } from "../enums/platform";
@@ -86,6 +85,13 @@ export const buildRun: CommandModule = {
86
85
  const args = argv as unknown as IArgs;
87
86
  const logger = new Logger();
88
87
 
88
+ if (!args.profile) {
89
+ logger.error(
90
+ "eas.json not found or has no build profiles. Run 'eas build:configure' to create one.",
91
+ );
92
+ process.exit(1);
93
+ }
94
+
89
95
  try {
90
96
  const platform = args.platform;
91
97
  const platformName = platform === Platform.iOS ? "iOS" : "Android";
@@ -163,7 +169,7 @@ export const buildRun: CommandModule = {
163
169
  logger.success("Done! App is running on simulator/emulator.");
164
170
  } catch (error) {
165
171
  const message = error instanceof Error ? error.message : String(error);
166
- console.error(chalk.red(`Build:run failed: ${message}`));
172
+ logger.error(`Build:run failed: ${message}`);
167
173
  process.exit(1);
168
174
  }
169
175
  },
@@ -1,6 +1,5 @@
1
1
  import fs from "fs";
2
2
  import path from "path";
3
- import chalk from "chalk";
4
3
  import type { CommandModule } from "yargs";
5
4
  import { Logger } from "../utils/logger";
6
5
  import { Platform, PlatformType } from "../enums/platform";
@@ -34,7 +33,7 @@ function findBuildArtifact(pattern: string): string | null {
34
33
 
35
34
  export const build: CommandModule = {
36
35
  command: "build",
37
- describe: "Build the app locally",
36
+ describe: "Build the app locally and submit to the stores",
38
37
  builder: (yargs) =>
39
38
  yargs
40
39
  .option("platform", {
@@ -53,7 +52,7 @@ export const build: CommandModule = {
53
52
  alias: "s",
54
53
  type: "boolean",
55
54
  description: "Submit to app stores after building",
56
- default: false,
55
+ default: true,
57
56
  })
58
57
  .option("clear-cache", {
59
58
  type: "boolean",
@@ -76,6 +75,13 @@ export const build: CommandModule = {
76
75
  const args = argv as unknown as IArgs;
77
76
  const logger = new Logger();
78
77
 
78
+ if (!args.profile) {
79
+ logger.error(
80
+ "eas.json not found or has no build profiles. Run 'eas build:configure' to create one.",
81
+ );
82
+ process.exit(1);
83
+ }
84
+
79
85
  try {
80
86
  const platforms: PlatformType[] =
81
87
  args.platform === "all"
@@ -151,7 +157,7 @@ export const build: CommandModule = {
151
157
  logger.success("Build completed!");
152
158
  } catch (error) {
153
159
  const message = error instanceof Error ? error.message : String(error);
154
- console.error(chalk.red(`Build failed: ${message}`));
160
+ logger.error(`Build failed: ${message}`);
155
161
  process.exit(1);
156
162
  }
157
163
  },
@@ -99,7 +99,7 @@ export const update: CommandModule = {
99
99
  const commitHash = getCommitHash();
100
100
  const shortCommit = getShortCommitHash();
101
101
 
102
- logger.section("Deployment Info");
102
+ logger.section("📤 Deployment Info");
103
103
  logger.table([
104
104
  ["Server", config.otaServer],
105
105
  ["Runtime", runtimeVersion],
@@ -184,7 +184,7 @@ export const update: CommandModule = {
184
184
  logger.success("Dry run completed successfully!");
185
185
  logger.info("Run without --dry-run to perform actual upload");
186
186
  } else {
187
- logger.success("Updates published successfully!");
187
+ logger.success("✨ Updates published successfully!");
188
188
  }
189
189
  },
190
190
  };
package/src/utils/cli.ts CHANGED
@@ -19,41 +19,6 @@ class InteractiveCLI {
19
19
  this.yargsInstance = yargs(args);
20
20
  }
21
21
 
22
- private showWelcome() {
23
- console.clear();
24
- console.log();
25
- console.log(chalk.cyan(" ___ __ _ ___ ___ "));
26
- console.log(chalk.cyan(" / _ \\/ _` / __|/ __|"));
27
- console.log(chalk.blue("| __/ (_| \\__ \\ (__ "));
28
- console.log(chalk.blue(" \\___|\\__,_|___/\\___|"));
29
- console.log();
30
- console.log(chalk.gray(" Expo App Services for Cloudflare"));
31
- console.log(chalk.yellow("════════════════════════════════════"));
32
- console.log();
33
- }
34
-
35
- private async promptForMissingArgs(
36
- argv: any,
37
- options: Record<string, Options>,
38
- ) {
39
- if (argv.nonInteractive || argv["non-interactive"]) return;
40
-
41
- for (const [key, opt] of Object.entries(options)) {
42
- const camelKey = key.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
43
- const value = argv[key] ?? argv[camelKey];
44
-
45
- if (value !== undefined) continue;
46
- if (opt.default !== undefined) continue;
47
- if (!opt.choices || !Array.isArray(opt.choices)) continue;
48
-
49
- argv[key] = await select({
50
- message: `Select ${key.replace(/-/g, " ")}:`,
51
- choices: opt.choices.map((c: string) => ({ name: c, value: c })),
52
- });
53
- argv[camelKey] = argv[key];
54
- }
55
- }
56
-
57
22
  scriptName(name: string): this {
58
23
  this.yargsInstance.scriptName(name);
59
24
  return this;
@@ -65,9 +30,8 @@ class InteractiveCLI {
65
30
  }
66
31
 
67
32
  command(cmd: CommandModule): this {
68
- const commandStr = typeof cmd.command === "string"
69
- ? cmd.command
70
- : cmd.command?.[0] ?? "";
33
+ const commandStr =
34
+ typeof cmd.command === "string" ? cmd.command : (cmd.command?.[0] ?? "");
71
35
  const commandName = commandStr.split(" ")[0] || "";
72
36
 
73
37
  let options: Record<string, Options> = {};
@@ -98,7 +62,7 @@ class InteractiveCLI {
98
62
  const wrappedCmd: CommandModule = {
99
63
  ...cmd,
100
64
  handler: async (argv: any) => {
101
- await this.promptForMissingArgs(argv, options);
65
+ await this._promptForMissingArgs(argv, options);
102
66
  return cmd.handler(argv);
103
67
  },
104
68
  };
@@ -132,7 +96,8 @@ class InteractiveCLI {
132
96
  }
133
97
 
134
98
  async parse(): Promise<void> {
135
- const needsCommandPrompt = this.args.length === 0 ||
99
+ const needsCommandPrompt =
100
+ this.args.length === 0 ||
136
101
  (this.args.length === 1 && this.args[0]?.startsWith("-"));
137
102
 
138
103
  if (!needsCommandPrompt) {
@@ -140,7 +105,7 @@ class InteractiveCLI {
140
105
  return;
141
106
  }
142
107
 
143
- this.showWelcome();
108
+ this._showWelcome();
144
109
 
145
110
  const command = await select({
146
111
  message: "Select a command:",
@@ -172,7 +137,7 @@ class InteractiveCLI {
172
137
  return y;
173
138
  },
174
139
  handler: async (argv: any) => {
175
- await this.promptForMissingArgs(argv, cmd.options);
140
+ await this._promptForMissingArgs(argv, cmd.options);
176
141
  return cmd.handler(argv);
177
142
  },
178
143
  });
@@ -180,6 +145,41 @@ class InteractiveCLI {
180
145
 
181
146
  this.yargsInstance.demandCommand(1, "").parse();
182
147
  }
148
+
149
+ private _showWelcome() {
150
+ console.clear();
151
+ console.log();
152
+ console.log(chalk.cyan(" ___ __ _ ___ ___ "));
153
+ console.log(chalk.cyan(" / _ \\/ _` / __|/ __|"));
154
+ console.log(chalk.blue("| __/ (_| \\__ \\ (__ "));
155
+ console.log(chalk.blue(" \\___|\\__,_|___/\\___|"));
156
+ console.log();
157
+ console.log(chalk.gray(" Expo App Services for Cloudflare"));
158
+ console.log(chalk.yellow("════════════════════════════════════"));
159
+ console.log();
160
+ }
161
+
162
+ private async _promptForMissingArgs(
163
+ argv: any,
164
+ options: Record<string, Options>,
165
+ ) {
166
+ if (argv.nonInteractive || argv["non-interactive"]) return;
167
+
168
+ for (const [key, opt] of Object.entries(options)) {
169
+ const camelKey = key.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
170
+ const value = argv[key] ?? argv[camelKey];
171
+
172
+ if (value !== undefined) continue;
173
+ if (opt.default !== undefined) continue;
174
+ if (!opt.choices || !Array.isArray(opt.choices)) continue;
175
+
176
+ argv[key] = await select({
177
+ message: `Select ${key.replace(/-/g, " ")}:`,
178
+ choices: opt.choices.map((c: string) => ({ name: c, value: c })),
179
+ });
180
+ argv[camelKey] = argv[key];
181
+ }
182
+ }
183
183
  }
184
184
 
185
185
  export function cli(args: string[]): InteractiveCLI {
package/src/utils/eas.ts CHANGED
@@ -5,28 +5,27 @@ interface EasConfig {
5
5
  build?: Record<string, unknown>;
6
6
  }
7
7
 
8
+ /**
9
+ * Get EAS build profiles from eas.json
10
+ * Returns an empty array if eas.json is not found, invalid, or has no build profiles.
11
+ */
8
12
  export function getEasProfiles(): string[] {
9
13
  const easJsonPath = path.join(process.cwd(), "eas.json");
10
14
 
11
15
  if (!fs.existsSync(easJsonPath)) {
12
- throw new Error("eas.json not found. Run 'eas build:configure' to create one.");
16
+ return [];
13
17
  }
14
18
 
15
19
  let easConfig: EasConfig;
16
20
  try {
17
21
  easConfig = JSON.parse(fs.readFileSync(easJsonPath, "utf-8"));
18
- } catch (error) {
19
- throw new Error(`Failed to parse eas.json: ${error instanceof Error ? error.message : String(error)}`);
22
+ } catch {
23
+ return [];
20
24
  }
21
25
 
22
26
  if (!easConfig.build || typeof easConfig.build !== "object") {
23
- throw new Error("No build profiles found in eas.json");
27
+ return [];
24
28
  }
25
29
 
26
- const profiles = Object.keys(easConfig.build);
27
- if (profiles.length === 0) {
28
- throw new Error("No build profiles found in eas.json");
29
- }
30
-
31
- return profiles;
30
+ return Object.keys(easConfig.build);
32
31
  }