diff --git a/package-lock.json b/package-lock.json index c17bfaa..e403bc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23638,7 +23638,7 @@ "dependencies": { "@badisi/latest-version": "^7.0.6", "@colors/colors": "^1.6.0", - "ora": "5.4.1", + "ora": "^8.0.1", "semver": "^7.6.2" }, "engines": { @@ -23651,6 +23651,154 @@ "@schematics/angular": ">= 17" } }, + "projects/lib/node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "projects/lib/node_modules/chalk": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz", + "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "projects/lib/node_modules/cli-cursor": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-4.0.0.tgz", + "integrity": "sha512-VGtlMu3x/4DOtIUwEkRezxUZ2lBacNJCHash0N0WeZDBS+7Ux1dm3XWAgWYxLJFMMdOeXMHXorshEFhbMSGelg==", + "license": "MIT", + "dependencies": { + "restore-cursor": "^4.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/cli-spinners": { + "version": "2.9.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz", + "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==", + "license": "MIT", + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/emoji-regex": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.3.0.tgz", + "integrity": "sha512-QpLs9D9v9kArv4lfDEgg1X/gN5XLnf/A6l9cs8SPZLRZR3ZkY9+kwIQTxm+fsSej5UMYGE8fdoaZVIBlqG0XTw==", + "license": "MIT" + }, + "projects/lib/node_modules/is-interactive": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", + "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/is-unicode-supported": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.0.0.tgz", + "integrity": "sha512-FRdAyx5lusK1iHG0TWpVtk9+1i+GjrzRffhDg4ovQ7mcidMQ6mj+MhKPmvh7Xwyv5gIS06ns49CA7Sqg7lC22Q==", + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/log-symbols": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", + "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "is-unicode-supported": "^1.3.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/log-symbols/node_modules/is-unicode-supported": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", + "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/ora": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/ora/-/ora-8.0.1.tgz", + "integrity": "sha512-ANIvzobt1rls2BDny5fWZ3ZVKyD6nscLvfFRpQgfWsythlcsVUC9kL0zq6j2Z5z9wwp1kd7wpsD/T9qNPVLCaQ==", + "license": "MIT", + "dependencies": { + "chalk": "^5.3.0", + "cli-cursor": "^4.0.0", + "cli-spinners": "^2.9.2", + "is-interactive": "^2.0.0", + "is-unicode-supported": "^2.0.0", + "log-symbols": "^6.0.0", + "stdin-discarder": "^0.2.1", + "string-width": "^7.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/restore-cursor": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-4.0.0.tgz", + "integrity": "sha512-I9fPXU9geO9bHOt9pHHOhOkYerIMsmVaWB0rA2AI9ERh/+x/i7MV5HKBNrg+ljO5eoPVgCcnFuRjJ9uH6I/3eg==", + "license": "MIT", + "dependencies": { + "onetime": "^5.1.0", + "signal-exit": "^3.0.2" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "projects/lib/node_modules/semver": { "version": "7.6.2", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.2.tgz", @@ -23662,6 +23810,38 @@ "engines": { "node": ">=10" } + }, + "projects/lib/node_modules/string-width": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", + "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", + "license": "MIT", + "dependencies": { + "emoji-regex": "^10.3.0", + "get-east-asian-width": "^1.0.0", + "strip-ansi": "^7.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "projects/lib/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } } } } diff --git a/projects/lib/package.json b/projects/lib/package.json index 4fa74c5..53ccd0a 100644 --- a/projects/lib/package.json +++ b/projects/lib/package.json @@ -59,7 +59,7 @@ "dependencies": { "@badisi/latest-version": "^7.0.6", "@colors/colors": "^1.6.0", - "ora": "5.4.1", + "ora": "^8.0.1", "semver": "^7.6.2" }, "engines": { diff --git a/projects/lib/src/rules.ts b/projects/lib/src/rules.ts index cdddd72..9864299 100644 --- a/projects/lib/src/rules.ts +++ b/projects/lib/src/rules.ts @@ -3,7 +3,6 @@ import { bgBlue, bgGreen, bgMagenta, bgRed, bgYellow, black, blue, cyan, gray, green, magenta, red, white, yellow } from '@colors/colors/safe'; import { spawn as childProcessSpawn } from 'child_process'; -import ora from 'ora'; interface BufferOutput { stream: NodeJS.WriteStream; @@ -89,43 +88,46 @@ export const logAction = (message: string): Rule => * @returns {Rule} */ export const spawn = (command: string, args: string[], showOutput = false): Rule => - async (): Promise => new Promise((resolve, reject) => { - const bufferedOutput: BufferOutput[] = []; - const verbose = showOutput || process.argv.includes('--verbose'); - const cmdText = `${command} ${args.join(' ')}`; + async (): Promise => { + const ora = (await import('ora')).default; + return new Promise((resolve, reject) => { + const bufferedOutput: BufferOutput[] = []; + const verbose = showOutput || process.argv.includes('--verbose'); + const cmdText = `${command} ${args.join(' ')}`; - const spinner = ora({ text: cyan(cmdText) }); - if (!verbose) { - spinner.start(); - } + const spinner = ora({ text: cyan(cmdText) }); + if (!verbose) { + spinner.start(); + } - const childProcess = childProcessSpawn(command, args, { - stdio: (verbose) ? 'inherit' : 'pipe', - shell: true - }); - childProcess.once('disconnect', resolve); - childProcess.once('error', error => reject(error)); - childProcess.on('close', (code: number) => { - if (code === 0) { - if (!verbose) { - spinner.succeed(cyan(cmdText)); - spinner.stop(); - } - return resolve(); - } else { - if (!verbose) { - spinner.fail(red(`${cmdText}\n`)); - bufferedOutput.forEach(({ stream, data }) => stream.write(data)); + const childProcess = childProcessSpawn(command, args, { + stdio: (verbose) ? 'inherit' : 'pipe', + shell: true + }); + childProcess.once('disconnect', resolve); + childProcess.once('error', error => reject(error)); + childProcess.on('close', (code: number) => { + if (code === 0) { + if (!verbose) { + spinner.succeed(cyan(cmdText)); + spinner.stop(); + } + return resolve(); + } else { + if (!verbose) { + spinner.fail(red(`${cmdText}\n`)); + bufferedOutput.forEach(({ stream, data }) => stream.write(data)); + } + return reject(new UnsuccessfulWorkflowExecution()); } - return reject(new UnsuccessfulWorkflowExecution()); + }); + if (!verbose) { + childProcess.stdout?.on('data', (data: Buffer) => + bufferedOutput.push({ stream: process.stdout, data: data }) + ); + childProcess.stderr?.on('data', (data: Buffer) => + bufferedOutput.push({ stream: process.stderr, data: data }) + ); } }); - if (!verbose) { - childProcess.stdout?.on('data', (data: Buffer) => - bufferedOutput.push({ stream: process.stdout, data: data }) - ); - childProcess.stderr?.on('data', (data: Buffer) => - bufferedOutput.push({ stream: process.stderr, data: data }) - ); - } - }); + };