From 4b4b9b0a507a973648914e19137c695393ca7688 Mon Sep 17 00:00:00 2001 From: Nick Alteen Date: Thu, 29 Aug 2024 16:51:53 -0400 Subject: [PATCH] Upgrade to require Node.js 20.6.0 (#92) This allows the quibble ESM loader to be included automatically when calling the action (preventing it from needing to be installed in the local Node environment). --- .node-version | 2 +- README.md | 10 ++++++-- bin/local-action.js | 50 ++++++++++++++++++++++--------------- docs/debugging-in-vscode.md | 8 +++--- package-lock.json | 12 ++++----- package.json | 2 +- 6 files changed, 50 insertions(+), 34 deletions(-) diff --git a/.node-version b/.node-version index 7cc2069..1cc433a 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -20.5.1 +20.6.0 diff --git a/README.md b/README.md index ddb7e8e..4566f48 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ ![Continuous Integration](https://github.com/github/local-action/actions/workflows/continuous-integration.yml/badge.svg) ![Code Coverage](badges/coverage.svg) -Run custom GitHub Actions locally and test them in VS Code! +Run custom GitHub Actions locally and test them in Visual Studio Code! This command-line tool emulates some **basic** functionality of the [GitHub Actions Toolkit](https://github.com/actions/toolkit) so that custom @@ -14,6 +14,12 @@ actions can be run directly on your workstation. > > This tool currently only supports JavaScript and TypeScript actions! +## v2 Changes + +As of version `2.0.0`, the `local-action` tool has been updated to require +**Node.js v20.6.0** or higher. This is necessary to support ESM loaders to +override dependencies in the GitHub Actions Toolkit. + ## v1 Changes With the release of `v1.0.0`, there was a need to switch from @@ -213,5 +219,5 @@ The following list links to documentation on how to use various features of the `local-action` tool. - [Supported Functionality](./docs//supported-functionality.md) -- [Debugging in VS Code](./docs/debugging-in-vscode.md) +- [Debugging in Visual Studio Code](./docs/debugging-in-vscode.md) - [Create a Job Summary](./docs/create-a-job-summary.md) diff --git a/bin/local-action.js b/bin/local-action.js index 2e6c42b..a859ed5 100755 --- a/bin/local-action.js +++ b/bin/local-action.js @@ -39,29 +39,39 @@ function entrypoint() { ? `${process.env.NODE_OPTIONS} --require ${bootstrapPath}` : `--require ${bootstrapPath}` + // Disable experimental warnings. + process.env.NODE_NO_WARNINGS = 1 + // Start building the command to run local-action. - let command = `npx tsx --loader=quibble "${path.join(packagePath, 'src', 'index.ts')}"` + let command = `npx tsx "${path.join(packagePath, 'src', 'index.ts')}"` + + // If there are no input arguments, or the only argument is the help flag, + // display the help message. + if ( + process.argv.length === 2 || + ['--help', '-h'].includes(process.argv[2]) + ) { + command += ` --help` + + // Run the command. + execSync(command, { stdio: 'inherit' }) + return + } - // Process the input arguments. - if (process.argv.length === 2) { - // No arguments...display the help message. - command += ' --help' - } else { - // Iterate over the arguments and build the command. - for (const arg of process.argv.slice(2)) { - // If the argument is a directory and TARGET_ACTION_PATH is not set, set - // it to the absolute path of the directory. The first directory is the - // target action path. - if ( - !process.env.TARGET_ACTION_PATH && - fs.existsSync(path.resolve(arg)) && - fs.lstatSync(path.resolve(arg)).isDirectory() - ) - process.env.TARGET_ACTION_PATH = path.resolve(arg) + // Iterate over the arguments and build the command. + for (const arg of process.argv.slice(2)) { + // If the argument is a directory and TARGET_ACTION_PATH is not set, set + // it to the absolute path of the directory. The first directory is the + // target action path. + if ( + !process.env.TARGET_ACTION_PATH && + fs.existsSync(path.resolve(arg)) && + fs.lstatSync(path.resolve(arg)).isDirectory() + ) + process.env.TARGET_ACTION_PATH = path.resolve(arg) - // Append the argument to the command. - command += ` ${arg}` - } + // Append the argument to the command. + command += ` ${arg}` } // Run the command. diff --git a/docs/debugging-in-vscode.md b/docs/debugging-in-vscode.md index 2844d5c..479bd88 100644 --- a/docs/debugging-in-vscode.md +++ b/docs/debugging-in-vscode.md @@ -1,8 +1,8 @@ -# Debugging in VS Code +# Debugging in Visual Studio Code -This package can also be used with VS Code's built-in debugging tools. You just -need to add a `launch.json` to the project containing your local action. The -following can be used as an example. +This package can also be used with Visual Studio Code's built-in debugging +tools. You just need to add a `launch.json` to the project containing your local +action. The following can be used as an example. ```json { diff --git a/package-lock.json b/package-lock.json index 126152b..06df170 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@github/local-action", - "version": "2.0.0", + "version": "2.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@github/local-action", - "version": "2.0.0", + "version": "2.1.0", "license": "MIT", "dependencies": { "@actions/core": "^1.10.1", @@ -7213,12 +7213,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": { diff --git a/package.json b/package.json index 69ac40d..5852045 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@github/local-action", "description": "Local Debugging for GitHub Actions", - "version": "2.0.0", + "version": "2.1.0", "type": "module", "author": "Nick Alteen ", "private": false,