Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"camelcase": "off",
"@typescript-eslint/consistent-type-assertions": "error",
"@typescript-eslint/explicit-function-return-type": ["error", {"allowExpressions": true}],
"@typescript-eslint/func-call-spacing": ["error", "never"],
"@typescript-eslint/no-array-constructor": "error",
"@typescript-eslint/no-empty-interface": "error",
"@typescript-eslint/no-explicit-any": "error",
Expand All @@ -42,8 +41,6 @@
"@typescript-eslint/require-array-sort-compare": "error",
"@typescript-eslint/restrict-plus-operands": "error",
"semi": "off",
"@typescript-eslint/semi": ["error", "never"],
"@typescript-eslint/type-annotation-spacing": "error",
"@typescript-eslint/unbound-method": "error",
"@typescript-eslint/ban-ts-comment": [
"error",
Expand All @@ -58,4 +55,4 @@
"es6": true,
"jest/globals": true
}
}
}
6 changes: 3 additions & 3 deletions .github/workflows/check-dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set Node.js 12.x
uses: actions/setup-node@v4
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 20
node-version: 24

- name: Install dependencies
run: npm ci
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

- uses: actions/setup-node@v6
with:
node-version: '20'
node-version: 24
cache: 'npm'

- name: Install dependencies
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.10.0
v24
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ outputs:
architecture:
description: 'Architecture that was used to install V'
runs:
using: 'node20'
using: 'node24'
main: 'dist/index.js'
post: 'dist/index.js'
147 changes: 71 additions & 76 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,26 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
}) : 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());
});
};
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.cleanup = exports.execer = void 0;
exports.execer = void 0;
exports.cleanup = cleanup;
const core = __importStar(require("@actions/core"));
const cp = __importStar(require("child_process"));
const fs = __importStar(require("fs"));
Expand All @@ -43,56 +45,51 @@ const tc = __importStar(require("@actions/tool-cache"));
const util = __importStar(require("util"));
const state_helper_1 = require("./state-helper");
exports.execer = util.promisify(cp.exec);
function run() {
return __awaiter(this, void 0, void 0, function* () {
try {
//
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc...
//
const version = resolveVersionInput();
let arch = core.getInput('architecture');
// if architecture supplied but version is not
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
if (arch && !version) {
core.warning('`architecture` is provided but `version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `version`');
}
if (!arch) {
arch = os.arch();
}
const token = core.getInput('token', { required: true });
const stable = strToBoolean(core.getInput('stable') || 'false');
const checkLatest = strToBoolean(core.getInput('check-latest') || 'false');
const binPath = yield installer.getVlang({
authToken: token,
version,
checkLatest,
stable,
arch
});
core.info('Adding v to the cache...');
const installedVersion = yield getVersion(binPath);
const cachedPath = yield tc.cacheDir(binPath, 'v', installedVersion);
core.info(`Cached v to: ${cachedPath}`);
core.addPath(cachedPath);
const vBinPath = path.join(binPath, 'v');
core.setOutput('bin-path', binPath);
core.setOutput('v-bin-path', vBinPath);
core.setOutput('version', installedVersion);
core.setOutput('architecture', arch);
async function run() {
try {
//
// Version is optional. If supplied, install / use from the tool cache
// If not supplied then task is still used to setup proxy, auth, etc...
//
const version = resolveVersionInput();
let arch = core.getInput('architecture');
// if architecture supplied but version is not
// if we don't throw a warning, the already installed x64 node will be used which is not probably what user meant.
if (arch && !version) {
core.warning('`architecture` is provided but `version` is missing. In this configuration, the version/architecture of Node will not be changed. To fix this, provide `architecture` in combination with `version`');
}
catch (error) {
if (error instanceof Error)
core.setFailed(error.message);
if (!arch) {
arch = os.arch();
}
});
const token = core.getInput('token', { required: true });
const stable = strToBoolean(core.getInput('stable') || 'false');
const checkLatest = strToBoolean(core.getInput('check-latest') || 'false');
const binPath = await installer.getVlang({
authToken: token,
version,
checkLatest,
stable,
arch
});
core.info('Adding v to the cache...');
const installedVersion = await getVersion(binPath);
const cachedPath = await tc.cacheDir(binPath, 'v', installedVersion);
core.info(`Cached v to: ${cachedPath}`);
core.addPath(cachedPath);
const vBinPath = path.join(binPath, 'v');
core.setOutput('bin-path', binPath);
core.setOutput('v-bin-path', vBinPath);
core.setOutput('version', installedVersion);
core.setOutput('architecture', arch);
}
catch (error) {
if (error instanceof Error)
core.setFailed(error.message);
}
}
function cleanup() {
return __awaiter(this, void 0, void 0, function* () {
// @todo: implement
});
async function cleanup() {
// @todo: implement
}
exports.cleanup = cleanup;
function resolveVersionInput() {
let version = core.getInput('version');
const versionFileInput = core.getInput('version-file');
Expand Down Expand Up @@ -121,19 +118,17 @@ function strToBoolean(str) {
const falsyValues = ['false', 'no', '0', '', 'undefined', 'null'];
return !falsyValues.includes(str.toLowerCase());
}
function getVersion(binPath) {
return __awaiter(this, void 0, void 0, function* () {
const vBinPath = path.join(binPath, 'v');
const { stdout, stderr } = yield (0, exports.execer)(`${vBinPath} version`);
if (stderr !== '') {
throw new Error(`Unable to get version from ${vBinPath}`);
}
if (stdout !== '') {
return stdout.trim().split(' ')[1];
}
core.warning('Unable to get version from v executable.');
return '0.0.0';
});
async function getVersion(binPath) {
const vBinPath = path.join(binPath, 'v');
const { stdout, stderr } = await (0, exports.execer)(`${vBinPath} version`);
if (stderr !== '') {
throw new Error(`Unable to get version from ${vBinPath}`);
}
if (stdout !== '') {
return stdout.trim().split(' ')[1];
}
core.warning('Unable to get version from v executable.');
return '0.0.0';
}
if (state_helper_1.IS_POST) {
cleanup();
Expand Down
26 changes: 7 additions & 19 deletions lib/wait.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,11 @@
"use strict";
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 });
exports.wait = void 0;
function wait(milliseconds) {
return __awaiter(this, void 0, void 0, function* () {
return new Promise(resolve => {
if (isNaN(milliseconds)) {
throw new Error('milliseconds not a number');
}
setTimeout(() => resolve('done!'), milliseconds);
});
exports.wait = wait;
async function wait(milliseconds) {
return new Promise(resolve => {
if (isNaN(milliseconds)) {
throw new Error('milliseconds not a number');
}
setTimeout(() => resolve('done!'), milliseconds);
});
}
exports.wait = wait;
Loading
Loading