Skip to content

Commit

Permalink
env:pull accepts environment as an argument rather than a flag
Browse files Browse the repository at this point in the history
  • Loading branch information
khamilowicz committed Oct 24, 2024
1 parent a212662 commit 78dc6e4
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/eas-cli/src/commands/env/pull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import * as fs from 'fs-extra';
import path from 'path';

import EasCommand from '../../commandUtils/EasCommand';
import { EASEnvironmentFlag, EASNonInteractiveFlag } from '../../commandUtils/flags';
import { EASNonInteractiveFlag } from '../../commandUtils/flags';
import {
EnvironmentSecretType,
EnvironmentVariableEnvironment,
EnvironmentVariableFragment,
EnvironmentVariableVisibility,
} from '../../graphql/generated';
Expand All @@ -28,8 +29,16 @@ export default class EnvironmentVariablePull extends EasCommand {
...this.ContextOptions.LoggedIn,
};

static override args = [
{
name: 'environment',
description:
"Environment to pull variables from. One of 'production', 'preview', or 'development'.",
required: false,
},
];

static override flags = {
...EASEnvironmentFlag,
...EASNonInteractiveFlag,
path: Flags.string({
description: 'Path to the result `.env` file',
Expand All @@ -39,12 +48,20 @@ export default class EnvironmentVariablePull extends EasCommand {

async runAsync(): Promise<void> {
let {
flags: { environment, path: targetPath, 'non-interactive': nonInteractive },
args: { environment },
flags: { path: targetPath, 'non-interactive': nonInteractive },
} = await this.parse(EnvironmentVariablePull);

environment = environment?.toUpperCase();

if (!environment) {
environment = await promptVariableEnvironmentAsync({ nonInteractive });
}

if (!Object.values(EnvironmentVariableEnvironment).includes(environment)) {
throw new Error("Invalid environment. Use one of 'production', 'preview', or 'development'.");
}

const {
privateProjectConfig: { projectId },
loggedIn: { graphqlClient },
Expand Down

0 comments on commit 78dc6e4

Please sign in to comment.