From c2b95dce66c8bb0316ad09b53f49dfd8c8a37e52 Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Sun, 30 Apr 2023 02:55:57 +0000 Subject: [PATCH] build: change main script dist path --- action.yml | 2 +- dist/{ => setup}/index.js | 14 +++++++------- package.json | 4 ++-- src/installer.ts | 2 +- src/setup-dotnet.ts | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) rename dist/{ => setup}/index.js (99%) diff --git a/action.yml b/action.yml index 128fd2c..5614f00 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,6 @@ outputs: description: 'Contains the installed by action .NET SDK version for reuse.' runs: using: 'node16' - main: 'dist/index.js' + main: 'dist/setup/index.js' post: 'dist/cache-save/index.js' post-if: success() diff --git a/dist/index.js b/dist/setup/index.js similarity index 99% rename from dist/index.js rename to dist/setup/index.js index 10b63ee..7b8a1ed 100644 --- a/dist/index.js +++ b/dist/setup/index.js @@ -70951,11 +70951,10 @@ const core = __importStar(__nccwpck_require__(2186)); const glob = __importStar(__nccwpck_require__(8090)); const cache_utils_1 = __nccwpck_require__(1678); const constants_1 = __nccwpck_require__(9042); -const restoreCache = () => __awaiter(void 0, void 0, void 0, function* () { - const fileHash = yield glob.hashFiles(constants_1.lockFilePattern); +const restoreCache = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { + const fileHash = yield glob.hashFiles(cacheDependencyPath || constants_1.lockFilePattern); if (!fileHash) { - core.warning(`No matches found for glob: ${constants_1.lockFilePattern}`); - return; + throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); } const platform = process.env.RUNNER_OS; const primaryKey = `dotnet-cache-${platform}-${fileHash}`; @@ -71288,7 +71287,7 @@ class DotnetCoreInstaller { ]; const scriptName = utils_1.IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; const escapedScript = path_1.default - .join(__dirname, '..', 'externals', scriptName) + .join(__dirname, '../..', 'externals', scriptName) .replace(/'/g, "''"); let scriptArguments; let scriptPath = ''; @@ -71491,12 +71490,13 @@ function run() { }); core.setOutput(constants_1.Outputs.DotnetVersion, versionToOutput); if (core.getBooleanInput('cache') && (0, cache_utils_1.isCacheFeatureAvailable)()) { - yield (0, cache_restore_1.restoreCache)(); + const cacheDependencyPath = core.getInput('cache-dependency-path'); + yield (0, cache_restore_1.restoreCache)(cacheDependencyPath); } else { core.setOutput(constants_1.Outputs.CacheHit, false); } - const matchersPath = path_1.default.join(__dirname, '..', '.github'); + const matchersPath = path_1.default.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path_1.default.join(matchersPath, 'csc.json')}`); } catch (error) { diff --git a/package.json b/package.json index 049475f..66ab533 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,9 @@ "version": "3.0.2", "private": true, "description": "setup dotnet action", - "main": "dist/index.js", + "main": "dist/setup/index.js", "scripts": { - "build": "ncc build src/setup-dotnet.ts && ncc build -o dist/cache-save src/cache-save.ts", + "build": "ncc build -o dist/setup src/setup-dotnet.ts && ncc build -o dist/cache-save src/cache-save.ts", "format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"", "format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"", "lint": "eslint --config ./.eslintrc.js \"**/*.ts\"", diff --git a/src/installer.ts b/src/installer.ts index ef9e993..0ff6ed4 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -188,7 +188,7 @@ export class DotnetCoreInstaller { ]; const scriptName = IS_WINDOWS ? 'install-dotnet.ps1' : 'install-dotnet.sh'; const escapedScript = path - .join(__dirname, '..', 'externals', scriptName) + .join(__dirname, '../..', 'externals', scriptName) .replace(/'/g, "''"); let scriptArguments: string[]; let scriptPath = ''; diff --git a/src/setup-dotnet.ts b/src/setup-dotnet.ts index 01ca61a..9fc4006 100644 --- a/src/setup-dotnet.ts +++ b/src/setup-dotnet.ts @@ -102,7 +102,7 @@ export async function run() { core.setOutput(Outputs.CacheHit, false); } - const matchersPath = path.join(__dirname, '..', '.github'); + const matchersPath = path.join(__dirname, '../..', '.github'); core.info(`##[add-matcher]${path.join(matchersPath, 'csc.json')}`); } catch (error) { core.setFailed(error.message);