Skip to content

Commit ad7dc0b

Browse files
committed
feat: add staging environment support to CLI commands and validation
- Introduced new commands for staging environment: `apply:stg`, `push:stg`, `pull:stg`, `call:stg`, and `cleanup:stg`. - Updated validation to include "stg" as a valid environment option, enhancing user guidance in error messages. - Adjusted environment references in the codebase to use "stg" instead of "staging" for consistency.
1 parent 22a20b7 commit ad7dc0b

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,25 @@
66
"private": true,
77
"scripts": {
88
"apply:dev": "tsx src/apply.ts dev",
9+
"apply:stg": "tsx src/apply.ts stg",
910
"apply:prod": "tsx src/apply.ts prod",
1011
"push:dev": "tsx src/push.ts dev",
12+
"push:stg": "tsx src/push.ts stg",
1113
"push:prod": "tsx src/push.ts prod",
1214
"push:dev:force": "tsx src/push.ts dev --force",
15+
"push:stg:force": "tsx src/push.ts stg --force",
1316
"push:prod:force": "tsx src/push.ts prod --force",
1417
"pull:dev": "tsx src/pull.ts dev",
18+
"pull:stg": "tsx src/pull.ts stg",
1519
"pull:dev:force": "tsx src/pull.ts dev --force",
20+
"pull:stg:force": "tsx src/pull.ts stg --force",
1621
"pull:prod": "tsx src/pull.ts prod",
1722
"pull:prod:force": "tsx src/pull.ts prod --force",
1823
"call:dev": "tsx src/call.ts dev",
24+
"call:stg": "tsx src/call.ts stg",
1925
"call:prod": "tsx src/call.ts prod",
2026
"cleanup:dev": "tsx src/cleanup.ts dev",
27+
"cleanup:stg": "tsx src/cleanup.ts stg",
2128
"cleanup:prod": "tsx src/cleanup.ts prod",
2229
"build": "tsc --noEmit"
2330
},

src/apply.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { fileURLToPath } from "url";
1313
const __dirname = dirname(fileURLToPath(import.meta.url));
1414
const BASE_DIR = join(__dirname, "..");
1515

16-
const VALID_ENVIRONMENTS = ["dev", "staging", "prod"] as const;
16+
const VALID_ENVIRONMENTS = ["dev", "stg", "prod"] as const;
1717

1818
function runPassthrough(cmd: string): number {
1919
try {
@@ -29,7 +29,7 @@ async function main(): Promise<void> {
2929
const extraArgs = process.argv.slice(3).join(" ");
3030

3131
if (!env || !VALID_ENVIRONMENTS.includes(env as typeof VALID_ENVIRONMENTS[number])) {
32-
console.error("Usage: npm run apply:dev | apply:prod");
32+
console.error("Usage: npm run apply:dev | apply:stg | apply:prod");
3333
console.error("");
3434
console.error(" Pull → Merge → Push (safe bidirectional sync)");
3535
console.error("");

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function parseEnvironment(): Environment {
3131

3232
if (!envArg) {
3333
console.error("❌ Environment argument is required");
34-
console.error(" Usage: npm run apply:dev | apply:prod");
34+
console.error(" Usage: npm run apply:dev | apply:stg | apply:prod");
3535
console.error(" Flags: --force (enable deletions)");
3636
console.error(" --type <type> (apply only specific resource type)");
3737
console.error(" -- <file...> (apply only specific files)");
@@ -127,7 +127,7 @@ function parseFlags(): { forceDelete: boolean; applyFilter: ApplyFilter } {
127127

128128
function loadEnvFile(env: string, baseDir: string): void {
129129
const envFiles = [
130-
join(baseDir, `.env.${env}`), // .env.dev, .env.staging, .env.prod
130+
join(baseDir, `.env.${env}`), // .env.dev, .env.stg, .env.prod
131131
join(baseDir, `.env.${env}.local`), // .env.dev.local (for local overrides)
132132
join(baseDir, ".env.local"), // .env.local (always loaded last)
133133
];

src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export type ResourceType =
3434
| "simulations"
3535
| "simulationSuites";
3636

37-
export type Environment = "dev" | "staging" | "prod";
37+
export type Environment = "dev" | "stg" | "prod";
3838

39-
export const VALID_ENVIRONMENTS: readonly Environment[] = ["dev", "staging", "prod"];
39+
export const VALID_ENVIRONMENTS: readonly Environment[] = ["dev", "stg", "prod"];
4040

4141
export const VALID_RESOURCE_TYPES: readonly ResourceType[] = [
4242
"tools",

0 commit comments

Comments
 (0)