From 0aa5a807baf093539488c69cbb6633c24ede6e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Poullain?= Date: Mon, 19 Aug 2024 18:15:01 +0200 Subject: [PATCH 1/2] Remove CLI run-script alias --- docs/docs/cli/shell-scripts.md | 2 +- packages/cli/package.json | 6 +++--- packages/cli/src/index.ts | 3 +-- .../get-command-line-arguments.util.spec.ts | 6 +++--- .../get-command-line-arguments.util.ts | 0 packages/cli/src/{run-script => run}/index.ts | 0 .../cli/src/{run-script => run}/run-script.spec.ts | 10 +++++----- packages/cli/src/{run-script => run}/run-script.ts | 0 8 files changed, 13 insertions(+), 14 deletions(-) rename packages/cli/src/{run-script => run}/get-command-line-arguments.util.spec.ts (90%) rename packages/cli/src/{run-script => run}/get-command-line-arguments.util.ts (100%) rename packages/cli/src/{run-script => run}/index.ts (100%) rename packages/cli/src/{run-script => run}/run-script.spec.ts (98%) rename packages/cli/src/{run-script => run}/run-script.ts (100%) diff --git a/docs/docs/cli/shell-scripts.md b/docs/docs/cli/shell-scripts.md index 28f99c7a2d..e139eef109 100644 --- a/docs/docs/cli/shell-scripts.md +++ b/docs/docs/cli/shell-scripts.md @@ -55,7 +55,7 @@ npm run build Then you can execute it with this command: ```shell -npx foal run my-script # or npx foal run-script my-script +npx foal run my-script ``` > You can also provide additionnal arguments to your script (for example: `npx foal run my-script foo=1 bar='[ 3, 4 ]'`). The default template in the generated scripts shows you how to handle such behavior. diff --git a/packages/cli/package.json b/packages/cli/package.json index 91b6cda7ed..98788259f0 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -5,15 +5,15 @@ "main": "./lib/index.js", "types": "./lib/index.d.ts", "scripts": { - "test": "npm run test:generators && npm run test:run-script && npm run test:create-secret && npm run test:rmdir && npm run test:fs", + "test": "npm run test:generators && npm run test:run && npm run test:create-secret && npm run test:rmdir && npm run test:fs", "test:fs": "mocha --file \"./src/test.ts\" --require ts-node/register \"./src/generate/file-system.spec.ts\"", "dev:test:fs": "mocha --file \"./src/test.ts\" --require ts-node/register --watch --extension ts \"./src/generate/file-system.spec.ts\"", "test:generators": "mocha --file \"./src/test.ts\" --require ts-node/register \"./src/generate/generators/**/*.spec.ts\"", "dev:test:generators": "mocha --file \"./src/test.ts\" --require ts-node/register --watch --extension ts \"./src/generate/generators/**/*.spec.ts\"", "test:rmdir": "mocha --file \"./src/test.ts\" --require ts-node/register \"./src/rmdir/**/*.spec.ts\"", "dev:test:rmdir": "mocha --file \"./src/test.ts\" --require ts-node/register --watch --extension ts \"./src/rmdir/**/*.spec.ts\"", - "test:run-script": "mocha --file \"./src/test.ts\" --require ts-node/register \"./src/run-script/**/*.spec.ts\"", - "dev:test:run-script": "mocha --file \"./src/test.ts\" --require ts-node/register --watch --extension ts \"./src/run-script/**/*.spec.ts\"", + "test:run": "mocha --file \"./src/test.ts\" --require ts-node/register \"./src/run/**/*.spec.ts\"", + "dev:test:run": "mocha --file \"./src/test.ts\" --require ts-node/register --watch --extension ts \"./src/run/**/*.spec.ts\"", "test:create-secret": "mocha --file \"./src/test.ts\" --require ts-node/register \"./src/create-secret/**/*.spec.ts\"", "dev:test:create-secret": "mocha --file \"./src/test.ts\" --require ts-node/register --watch --extension ts \"./src/create-secret/**/*.spec.ts\"", "build": "rimraf lib && tsc -p tsconfig-build.json && copyfiles -a -u 3 \"src/generate/templates/**/*\" lib/generate/templates", diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index 78b9501130..e60872e7d1 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -26,7 +26,7 @@ import { } from './generate'; import { ClientError } from './generate/file-system'; import { rmdir } from './rmdir'; -import { runScript } from './run-script'; +import { runScript } from './run'; function displayError(...lines: string[]): void { console.error(); @@ -67,7 +67,6 @@ program program .command('run') .argument('', 'Name of the script to run') - .alias('run-script') .description('Run a shell script.') .action((name: string) => { runScript({ name }, process.argv); diff --git a/packages/cli/src/run-script/get-command-line-arguments.util.spec.ts b/packages/cli/src/run/get-command-line-arguments.util.spec.ts similarity index 90% rename from packages/cli/src/run-script/get-command-line-arguments.util.spec.ts rename to packages/cli/src/run/get-command-line-arguments.util.spec.ts index 083948cabd..013a7212dc 100644 --- a/packages/cli/src/run-script/get-command-line-arguments.util.spec.ts +++ b/packages/cli/src/run/get-command-line-arguments.util.spec.ts @@ -6,11 +6,11 @@ import { getCommandLineArguments } from './get-command-line-arguments.util'; describe('getCommandLineArguments', () => { it('should convert the arguments to an object.', () => { - // npx foal run-script foo foo=barfoo bar='hello world' + // npx foal run foo foo=barfoo bar='hello world' const argv = [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', 'prod', 'foo=barfoo', @@ -28,7 +28,7 @@ describe('getCommandLineArguments', () => { const argv = [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', 'bar={ "foo": "bar" }', 'foo=3' diff --git a/packages/cli/src/run-script/get-command-line-arguments.util.ts b/packages/cli/src/run/get-command-line-arguments.util.ts similarity index 100% rename from packages/cli/src/run-script/get-command-line-arguments.util.ts rename to packages/cli/src/run/get-command-line-arguments.util.ts diff --git a/packages/cli/src/run-script/index.ts b/packages/cli/src/run/index.ts similarity index 100% rename from packages/cli/src/run-script/index.ts rename to packages/cli/src/run/index.ts diff --git a/packages/cli/src/run-script/run-script.spec.ts b/packages/cli/src/run/run-script.spec.ts similarity index 98% rename from packages/cli/src/run-script/run-script.spec.ts rename to packages/cli/src/run/run-script.spec.ts index e5457f4f10..a135e0574f 100644 --- a/packages/cli/src/run-script/run-script.spec.ts +++ b/packages/cli/src/run/run-script.spec.ts @@ -81,7 +81,7 @@ describe('runScript', () => { await runScript({ name: 'my-script' }, [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', 'email=bar', 'n=11' @@ -111,7 +111,7 @@ describe('runScript', () => { await runScript({ name: 'my-script' }, [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', 'foo=bar', ]); @@ -146,7 +146,7 @@ describe('runScript', () => { await runScript({ name: 'my-script' }, [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', 'foo=bar', ]); @@ -178,7 +178,7 @@ describe('runScript', () => { await runScript({ name: 'my-script' }, [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', ], log); @@ -201,7 +201,7 @@ describe('runScript', () => { await runScript({ name: 'my-script' }, [ '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/node', '/Users/loicpoullain/.nvm/versions/node/v8.11.3/bin/foal', - 'run-script', + 'run', 'my-script', ], log); diff --git a/packages/cli/src/run-script/run-script.ts b/packages/cli/src/run/run-script.ts similarity index 100% rename from packages/cli/src/run-script/run-script.ts rename to packages/cli/src/run/run-script.ts From 5c7864ff5c83ce5a5d8eb5ca84d5bb76e6b767b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Poullain?= Date: Thu, 22 Aug 2024 14:59:00 +0200 Subject: [PATCH 2/2] [Blog] Remove "npx foal run-script" --- docs/blog/version-5.0-release-notes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/blog/version-5.0-release-notes.md b/docs/blog/version-5.0-release-notes.md index b3aecf93e8..01137a7b8e 100644 --- a/docs/blog/version-5.0-release-notes.md +++ b/docs/blog/version-5.0-release-notes.md @@ -16,4 +16,5 @@ Version 5.0 of [Foal](https://foalts.org/) is out! ## Removal of depreacted components -- The deprecated hook `@Log` has been removed. To replace it, you can use the `Logger` service in a custom `@Hook`. \ No newline at end of file +- The deprecated hook `@Log` has been removed. To replace it, you can use the `Logger` service in a custom `@Hook`. +- The command alias `npx foal run-script` has been removed. Use `npx foal run` instead. \ No newline at end of file