From 199652afcc4364539346dc114e63324b50ebe41c Mon Sep 17 00:00:00 2001 From: Michael Kriese <michael.kriese@visualon.de> Date: Tue, 12 Apr 2022 08:39:00 +0200 Subject: [PATCH] chore: fix imports (#15068) --- tools/dispatch-release.mjs | 2 +- tools/docs/config.ts | 2 +- tools/release.mjs | 22 +--------------------- tools/utils.mjs | 35 ----------------------------------- tools/utils/options.mjs | 15 +++++++++++++++ 5 files changed, 18 insertions(+), 58 deletions(-) delete mode 100644 tools/utils.mjs create mode 100644 tools/utils/options.mjs diff --git a/tools/dispatch-release.mjs b/tools/dispatch-release.mjs index 3bdc53a23f..0d0f5545fe 100644 --- a/tools/dispatch-release.mjs +++ b/tools/dispatch-release.mjs @@ -1,6 +1,6 @@ import got from 'got'; import shell from 'shelljs'; -import { options } from './utils.mjs'; +import { options } from './utils/options.mjs'; const version = options.release; const tag = options.tag || 'latest'; diff --git a/tools/docs/config.ts b/tools/docs/config.ts index fe295b2333..ff93ea7ae7 100644 --- a/tools/docs/config.ts +++ b/tools/docs/config.ts @@ -2,7 +2,7 @@ import table from 'markdown-table'; import { getOptions } from '../../lib/config/options'; import { getCliName } from '../../lib/workers/global/config/parse/cli'; import { getEnvName } from '../../lib/workers/global/config/parse/env'; -import { readFile, updateFile } from '../utils/index'; +import { readFile, updateFile } from '../utils'; const options = getOptions(); diff --git a/tools/release.mjs b/tools/release.mjs index eb1d20f3ea..748028a26b 100644 --- a/tools/release.mjs +++ b/tools/release.mjs @@ -1,29 +1,9 @@ import shell from 'shelljs'; -import { options } from './utils.mjs'; +import { options } from './utils/options.mjs'; const version = options.release; -// const sha = program.sha; - -// let err = false; shell.echo(`Publishing version: ${version}`); -// shell.echo('Publishing npm package ...'); -// if ( -// !exec(`npm --no-git-tag-version version ${version}`) || -// !exec(`npm publish`) -// ) { -// err = true; -// } - -// shell.echo('Publishing docker images ...'); -// if (!exec(`./.github/workflows/release-docker.sh ${version} ${sha}`)) { -// err = true; -// } - // eslint-disable-next-line promise/valid-params,@typescript-eslint/no-floating-promises import('./dispatch-release.mjs').catch(); - -// if (err) { -// shell.exit(2); -// } diff --git a/tools/utils.mjs b/tools/utils.mjs deleted file mode 100644 index 6b06b719de..0000000000 --- a/tools/utils.mjs +++ /dev/null @@ -1,35 +0,0 @@ -import { Command } from 'commander'; -import shell from 'shelljs'; - -const program = new Command(); -program - .version('0.0.1') - .requiredOption('-r, --release <type>', 'Version to use') - .option('-s, --sha <type>', 'Git sha to use') - .option('-t, --tag <type>', 'Npm dist-tag to publish to') - .option('-d, --dry-run'); - -program.parse(process.argv); - -export const options = program.opts(); - -export { program }; - -/** - * Executes a shell command - * @param cmd {string} The command to execute - * @returns {boolean} Returns true on zero exit code otherwise false - */ -export function exec(cmd) { - try { - if (!options.dryRun) { - const res = shell.exec(cmd); - return res.code === 0; - } - shell.echo(`DRY-RUN: ${cmd}`); - } catch (e) { - shell.echo(e.toString()); - return false; - } - return true; -} diff --git a/tools/utils/options.mjs b/tools/utils/options.mjs new file mode 100644 index 0000000000..afbadf386b --- /dev/null +++ b/tools/utils/options.mjs @@ -0,0 +1,15 @@ +import { Command } from 'commander'; + +const program = new Command(); +program + .version('0.0.1') + .requiredOption('-r, --release <type>', 'Version to use') + .option('-s, --sha <type>', 'Git sha to use') + .option('-t, --tag <type>', 'Npm dist-tag to publish to') + .option('-d, --dry-run'); + +program.parse(process.argv); + +export const options = program.opts(); + +export { program }; -- GitLab