-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce subcommands in a backwards-compatible way (#1073)
Co-authored-by: Casper da Costa-Luis <[email protected]> Co-authored-by: Daniel Barnes <[email protected]>
- Loading branch information
1 parent
4ade9a5
commit 341f32e
Showing
48 changed files
with
1,462 additions
and
1,398 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
node_modules/ | ||
runner/ | ||
.terraform/ | ||
.cml/ | ||
.DS_Store | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
exports.command = 'asset'; | ||
exports.description = false; | ||
exports.builder = (yargs) => | ||
yargs | ||
.commandDir('./asset', { exclude: /\.test\.js$/ }) | ||
.recommendCommands() | ||
.demandCommand() | ||
.strict(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
const fs = require('fs').promises; | ||
const kebabcaseKeys = require('kebabcase-keys'); | ||
const winston = require('winston'); | ||
|
||
const { CML } = require('../../../src/cml'); | ||
|
||
exports.command = 'publish <asset>'; | ||
exports.description = 'Publish an asset'; | ||
|
||
exports.handler = async (opts) => { | ||
if (opts.gitlabUploads) { | ||
winston.warn( | ||
'--gitlab-uploads will be deprecated soon, use --native instead' | ||
); | ||
opts.native = true; | ||
} | ||
|
||
const { file, repo, native, asset: path } = opts; | ||
const cml = new CML({ ...opts, repo: native ? repo : 'cml' }); | ||
const output = await cml.publish({ ...opts, path }); | ||
|
||
if (!file) console.log(output); | ||
else await fs.writeFile(file, output); | ||
}; | ||
|
||
exports.builder = (yargs) => yargs.env('CML_ASSET').options(exports.options); | ||
|
||
exports.options = kebabcaseKeys({ | ||
url: { | ||
type: 'string', | ||
description: 'Self-Hosted URL', | ||
hidden: true | ||
}, | ||
md: { | ||
type: 'boolean', | ||
description: 'Output in markdown format [title || name](url)' | ||
}, | ||
title: { | ||
type: 'string', | ||
alias: 't', | ||
description: 'Markdown title [title](url) or ![](url title)' | ||
}, | ||
native: { | ||
type: 'boolean', | ||
description: | ||
"Uses driver's native capabilities to upload assets instead of CML's storage; not available on GitHub" | ||
}, | ||
gitlabUploads: { | ||
type: 'boolean', | ||
hidden: true | ||
}, | ||
rmWatermark: { | ||
type: 'boolean', | ||
description: 'Avoid CML watermark.' | ||
}, | ||
mimeType: { | ||
type: 'string', | ||
defaultDescription: 'infer from the file contents', | ||
description: 'MIME type' | ||
}, | ||
file: { | ||
type: 'string', | ||
alias: 'f', | ||
description: | ||
'Append the output to the given file or create it if does not exist', | ||
hidden: true | ||
}, | ||
repo: { | ||
type: 'string', | ||
description: | ||
'Specifies the repo to be used. If not specified is extracted from the CI ENV.' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
exports.command = 'check'; | ||
exports.description = 'Manage CI checks'; | ||
exports.builder = (yargs) => | ||
yargs | ||
.commandDir('./check', { exclude: /\.test\.js$/ }) | ||
.recommendCommands() | ||
.demandCommand() | ||
.strict(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
const fs = require('fs').promises; | ||
const kebabcaseKeys = require('kebabcase-keys'); | ||
|
||
exports.command = 'create <markdown file>'; | ||
exports.description = 'Create a check report'; | ||
|
||
exports.handler = async (opts) => { | ||
const { cml, markdownfile } = opts; | ||
const report = await fs.readFile(markdownfile, 'utf-8'); | ||
await cml.checkCreate({ ...opts, report }); | ||
}; | ||
|
||
exports.builder = (yargs) => yargs.env('CML_CHECK').options(exports.options); | ||
|
||
exports.options = kebabcaseKeys({ | ||
token: { | ||
type: 'string', | ||
description: | ||
"GITHUB_TOKEN or Github App token. Personal access token won't work" | ||
}, | ||
commitSha: { | ||
type: 'string', | ||
alias: 'head-sha', | ||
defaultDescription: 'HEAD', | ||
description: 'Commit SHA linked to this comment' | ||
}, | ||
conclusion: { | ||
type: 'string', | ||
choices: [ | ||
'success', | ||
'failure', | ||
'neutral', | ||
'cancelled', | ||
'skipped', | ||
'timed_out' | ||
], | ||
default: 'success', | ||
description: 'Conclusion status of the check' | ||
}, | ||
status: { | ||
type: 'string', | ||
choices: ['queued', 'in_progress', 'completed'], | ||
default: 'completed', | ||
description: 'Status of the check' | ||
}, | ||
title: { | ||
type: 'string', | ||
default: 'CML Report', | ||
description: 'Title of the check' | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.