-
Notifications
You must be signed in to change notification settings - Fork 72
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 all 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 |
---|---|---|
|
@@ -63,6 +63,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 | ||
cacheTo: | ||
required: false | ||
description: Specify the image to cache the built image to | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import {promisify} from 'util'; | |
import {ExecFunction} from './exec'; | ||
import {findWindowsExecutable} from './windows'; | ||
|
||
const cliVersion = "0"; // Use 'latest' to get latest CLI version, or pin to specific version e.g. '0.14.1' if required | ||
export const MAJOR_VERSION_FALLBACK = '0'; | ||
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. nit: Use camelCase. |
||
|
||
export interface DevContainerCliError { | ||
outcome: 'error'; | ||
|
@@ -26,19 +26,17 @@ function getSpecCliInfo() { | |
}; | ||
} | ||
|
||
async function isCliInstalled(exec: ExecFunction): Promise<boolean> { | ||
async function isCliInstalled(exec: ExecFunction, cliVersion: string): Promise<boolean> { | ||
try { | ||
const command = await findWindowsExecutable(getSpecCliInfo().command); | ||
const {exitCode} = await exec(command, ['--help'], { | ||
silent: true, | ||
}); | ||
return exitCode === 0; | ||
const {exitCode, stdout} = await exec(command, ['--version'], {}); | ||
return exitCode === 0 && stdout.trim() === cliVersion; | ||
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.
|
||
} 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 { | ||
|
@@ -54,7 +52,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.