Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit aafb1d4

Browse files
committed
feat(plugins/plugin-core-support): add minimum version check to IBM CodeEngine prereq checker
part of #8216
1 parent 341235a commit aafb1d4

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

plugins/plugin-core-support/up/src/Checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export type CheckerArgs<O extends ParsedOptions = ParsedOptions> = Pick<
2626
>
2727

2828
export type CheckResultSuccess = true | string
29-
export type CheckResult = CheckResultSuccess | false
29+
export type CheckResult = CheckResultSuccess | { ok: boolean; message: string } | false
3030

3131
export type Stdout = NodeJS.WriteStream & NodeJS.WritableStream
3232

plugins/plugin-core-support/up/src/ibm/cli/ce.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,16 @@ async function check(args: Arguments) {
2828
Object.assign({}, args, { command: 'ibmcloud plugin show code-engine --output json' })
2929
)
3030
)
31-
return `v${Version.Major}.${Version.Minor}.${Version.Build}`
31+
32+
const version = `v${Version.Major}.${Version.Minor}.${Version.Build}`
33+
if (Version.Major < 1 || Version.Minor < 6) {
34+
return {
35+
ok: false,
36+
message: `Your IBM Cloud CodeEngine CLI plugin is too old. Got ${version}. Expected >= 1.6.0`
37+
}
38+
} else {
39+
return version
40+
}
3241
} catch (err) {
3342
return false
3443
}

plugins/plugin-core-support/up/src/ui.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ type Status = { ok: boolean; message: string }
5353

5454
async function toStatus(checker: Checker, checkResultP: ReturnType<Checker['check']>): Promise<Status> {
5555
const checkResult = await checkResultP
56-
return {
57-
ok: typeof checkResult === 'string' || checkResult === true,
58-
message: formatLabel(checker, checkResult)
59-
}
56+
return typeof checkResult === 'object'
57+
? checkResult
58+
: {
59+
ok: typeof checkResult === 'string' || checkResult === true,
60+
message: formatLabel(checker, checkResult)
61+
}
6062
}
6163

6264
export default async function doCheck<T extends CheckResult>(
@@ -127,7 +129,7 @@ function listrTaskForChecker(
127129
}
128130
})
129131
.catch(err => {
130-
ctx[idx] = { ok: false }
132+
ctx[idx] = { ok: false, message: err.message }
131133
obs.error(err)
132134
})
133135
.finally(() => obs.complete())

0 commit comments

Comments
 (0)