-
Notifications
You must be signed in to change notification settings - Fork 86
Feature: Allow for cli version specification #253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,10 @@ inputs: | |
| required: false | ||
| default: false | ||
| description: Builds the image with `--no-cache` (takes precedence over `cacheFrom`) | ||
| cliVersion: | ||
| required: false | ||
| default: latest | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the default now 0? |
||
| description: The version of the devcontainer CLI to use | ||
| outputs: | ||
| runCmdOutput: | ||
| description: The output of the command specified in the runCmd input | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,8 +5,6 @@ import {env} from 'process'; | |
| import {promisify} from 'util'; | ||
| import {ExecFunction} from './exec'; | ||
|
|
||
| const cliVersion = "0"; // Use 'latest' to get latest CLI version, or pin to specific version e.g. '0.14.1' if required | ||
|
|
||
| export interface DevContainerCliError { | ||
| outcome: 'error'; | ||
| code: number; | ||
|
|
@@ -25,18 +23,16 @@ function getSpecCliInfo() { | |
| }; | ||
| } | ||
|
|
||
| async function isCliInstalled(exec: ExecFunction): Promise<boolean> { | ||
| async function isCliInstalled(exec: ExecFunction, cliVersion: string): Promise<boolean> { | ||
| try { | ||
| const {exitCode} = await exec(getSpecCliInfo().command, ['--help'], { | ||
| silent: true, | ||
| }); | ||
| return exitCode === 0; | ||
| const {exitCode, stdout} = await exec(getSpecCliInfo().command, ['--version'], {}); | ||
| return exitCode === 0 && stdout === cliVersion; | ||
|
||
| } catch (error) { | ||
| return false; | ||
| } | ||
| } | ||
| const fstat = promisify(fs.stat); | ||
| async function installCli(exec: ExecFunction): Promise<boolean> { | ||
| async function installCli(exec: ExecFunction, cliVersion: string): Promise<boolean> { | ||
| // if we have a local 'cli' folder, then use that as we're testing a private cli build | ||
| let cliStat = null; | ||
| try { | ||
|
|
@@ -52,7 +48,7 @@ async function installCli(exec: ExecFunction): Promise<boolean> { | |
| } | ||
| return exitCode === 0; | ||
| } | ||
| console.log('** Installing @devcontainers/cli'); | ||
| console.log(`** Installing @devcontainers/cli@${cliVersion}`); | ||
| const {exitCode, stdout, stderr} = await exec('bash', ['-c', `npm install -g @devcontainers/cli@${cliVersion}`], {}); | ||
| if (exitCode != 0) { | ||
| console.log(stdout); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.