From 67fa29c84bc0d074ffcef92440c846b271412e25 Mon Sep 17 00:00:00 2001 From: Daniel Cousineau Date: Tue, 10 Oct 2023 15:59:51 -0400 Subject: [PATCH] Refactor prerequisite installation - Remove `pre.ts` and merge into `main.ts` - Ensures prerequisite installation happens at the same time that vale-action runs, allowing manual installation of ruby/python - Adds additional debugging outputs --- action.yml | 1 - lib/input.js | 5 +++++ lib/pre.js | 42 ------------------------------------------ src/input.ts | 8 ++++++++ src/pre.ts | 8 -------- 5 files changed, 13 insertions(+), 51 deletions(-) delete mode 100644 lib/pre.js delete mode 100644 src/pre.ts diff --git a/action.yml b/action.yml index 18abeb5f..a04a0d85 100644 --- a/action.yml +++ b/action.yml @@ -62,5 +62,4 @@ inputs: runs: using: "node20" - pre: lib/pre.js main: "lib/main.js" diff --git a/lib/input.js b/lib/input.js index d13638d6..914c2c68 100644 --- a/lib/input.js +++ b/lib/input.js @@ -63,6 +63,11 @@ function logIfDebug(msg) { */ function get(tok, dir) { return __awaiter(this, void 0, void 0, function* () { + logIfDebug('Ensuring core python and ruby dependencies are present'); + yield exec.exec('pip', ['install', 'docutils']); + logIfDebug('`pip install docutils` complete'); + yield exec.exec('gem', ['install', 'asciidoctor', '--user-install']); + logIfDebug('`gem install asciidoctor --user-install` complete'); const localVale = yield (0, install_1.installLint)(core.getInput('version')); const localReviewDog = yield (0, install_1.installReviewDog)("0.15.0"); const valeFlags = core.getInput("vale_flags"); diff --git a/lib/pre.js b/lib/pre.js deleted file mode 100644 index 40dd80fd..00000000 --- a/lib/pre.js +++ /dev/null @@ -1,42 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { - function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } - return new (P || (P = Promise))(function (resolve, reject) { - function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } - function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } - function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } - step((generator = generator.apply(thisArg, _arguments || [])).next()); - }); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const exec = __importStar(require("@actions/exec")); -function main() { - return __awaiter(this, void 0, void 0, function* () { - yield exec.exec('pip', ['install', 'docutils']); - yield exec.exec('gem', ['install', 'asciidoctor', '--user-install']); - }); -} -main(); diff --git a/src/input.ts b/src/input.ts index 0ea0fc82..b61d20e8 100644 --- a/src/input.ts +++ b/src/input.ts @@ -49,6 +49,14 @@ function logIfDebug(msg: string) { * Parse our user input and set up our Vale environment. */ export async function get(tok: string, dir: string): Promise { + logIfDebug('Ensuring core python and ruby dependencies are present'); + + await exec.exec('pip', ['install', 'docutils']); + logIfDebug('`pip install docutils` complete'); + + await exec.exec('gem', ['install', 'asciidoctor', '--user-install']); + logIfDebug('`gem install asciidoctor --user-install` complete'); + const localVale = await installLint(core.getInput('version')); const localReviewDog = await installReviewDog("0.15.0"); const valeFlags = core.getInput("vale_flags"); diff --git a/src/pre.ts b/src/pre.ts deleted file mode 100644 index 548c1d79..00000000 --- a/src/pre.ts +++ /dev/null @@ -1,8 +0,0 @@ -import * as exec from '@actions/exec'; - -async function main(): Promise { - await exec.exec('pip', ['install', 'docutils']); - await exec.exec('gem', ['install', 'asciidoctor', '--user-install']); -} - -main(); \ No newline at end of file