Skip to content

Commit

Permalink
Added support for installing tsserver (#67)
Browse files Browse the repository at this point in the history
* Added support for installing tsserver

* Added debug logging

* Compiled required files

* Updated upload-artifact version

* Removed unneeded logging

* Updated built files
  • Loading branch information
dannykim-endor authored Nov 5, 2024
1 parent a8ad74e commit f7fea20
Show file tree
Hide file tree
Showing 10 changed files with 129 additions and 17 deletions.
25 changes: 24 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24876,7 +24876,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.createHashFromFile = void 0;
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.commandExists = exports.createHashFromFile = void 0;
const artifact = __importStar(__nccwpck_require__(2605));
const core = __importStar(__nccwpck_require__(2186));
const crypto = __importStar(__nccwpck_require__(6113));
Expand All @@ -24887,6 +24887,7 @@ const httpm = __importStar(__nccwpck_require__(6255));
const io = __importStar(__nccwpck_require__(7436));
const tc = __importStar(__nccwpck_require__(7784));
const path = __importStar(__nccwpck_require__(1017));
const child_process_1 = __nccwpck_require__(2081);
const constants_1 = __nccwpck_require__(9042);
const execOptionSilent = {
silent: true,
Expand All @@ -24898,6 +24899,20 @@ const createHashFromFile = (filePath) => new Promise((resolve) => {
.on("end", () => resolve(hash.digest("hex")));
});
exports.createHashFromFile = createHashFromFile;
const commandExists = (command) => {
try {
const platform = (0, exports.getPlatformInfo)();
const cmd = platform.os === constants_1.EndorctlAvailableOS.Windows
? `where ${command}`
: `which ${command}`;
(0, child_process_1.execSync)(cmd, { stdio: "ignore" });
return true;
}
catch (error) {
return false;
}
};
exports.commandExists = commandExists;
/**
* Returns the OS and Architecture to be used for downloading endorctl binary,
* based on the current runner OS and Architecture. Returns the error if runner
Expand Down Expand Up @@ -25039,6 +25054,14 @@ const setupEndorctl = ({ version, checksum, api }) => __awaiter(void 0, void 0,
yield io.cp(downloadPath, endorctlPath);
core.addPath(binPath);
core.info(`Endorctl downloaded and added to the path`);
// Check to see if tsserver is installed -- if not install it (needed for javascript callgraphs)
const command = "tsserver";
core.info(`Checking for tsserver`);
if (!(0, exports.commandExists)(command)) {
// Install it
core.info(`Installing tsserver`);
yield exec.exec("npm", ["install", "-g", "typescript"]);
}
}
catch (error) {
core.setFailed(error);
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17874,7 +17874,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.createHashFromFile = void 0;
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.commandExists = exports.createHashFromFile = void 0;
const artifact = __importStar(__nccwpck_require__(2605));
const core = __importStar(__nccwpck_require__(2186));
const crypto = __importStar(__nccwpck_require__(6113));
Expand All @@ -17885,6 +17885,7 @@ const httpm = __importStar(__nccwpck_require__(6255));
const io = __importStar(__nccwpck_require__(7436));
const tc = __importStar(__nccwpck_require__(7784));
const path = __importStar(__nccwpck_require__(1017));
const child_process_1 = __nccwpck_require__(2081);
const constants_1 = __nccwpck_require__(9042);
const execOptionSilent = {
silent: true,
Expand All @@ -17896,6 +17897,20 @@ const createHashFromFile = (filePath) => new Promise((resolve) => {
.on("end", () => resolve(hash.digest("hex")));
});
exports.createHashFromFile = createHashFromFile;
const commandExists = (command) => {
try {
const platform = (0, exports.getPlatformInfo)();
const cmd = platform.os === constants_1.EndorctlAvailableOS.Windows
? `where ${command}`
: `which ${command}`;
(0, child_process_1.execSync)(cmd, { stdio: "ignore" });
return true;
}
catch (error) {
return false;
}
};
exports.commandExists = commandExists;
/**
* Returns the OS and Architecture to be used for downloading endorctl binary,
* based on the current runner OS and Architecture. Returns the error if runner
Expand Down Expand Up @@ -18037,6 +18052,14 @@ const setupEndorctl = ({ version, checksum, api }) => __awaiter(void 0, void 0,
yield io.cp(downloadPath, endorctlPath);
core.addPath(binPath);
core.info(`Endorctl downloaded and added to the path`);
// Check to see if tsserver is installed -- if not install it (needed for javascript callgraphs)
const command = "tsserver";
core.info(`Checking for tsserver`);
if (!(0, exports.commandExists)(command)) {
// Install it
core.info(`Installing tsserver`);
yield exec.exec("npm", ["install", "-g", "typescript"]);
}
}
catch (error) {
core.setFailed(error);
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js.map

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion dist/sign/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17871,7 +17871,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.createHashFromFile = void 0;
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.commandExists = exports.createHashFromFile = void 0;
const artifact = __importStar(__nccwpck_require__(2605));
const core = __importStar(__nccwpck_require__(2186));
const crypto = __importStar(__nccwpck_require__(6113));
Expand All @@ -17882,6 +17882,7 @@ const httpm = __importStar(__nccwpck_require__(6255));
const io = __importStar(__nccwpck_require__(7436));
const tc = __importStar(__nccwpck_require__(7784));
const path = __importStar(__nccwpck_require__(1017));
const child_process_1 = __nccwpck_require__(2081);
const constants_1 = __nccwpck_require__(9042);
const execOptionSilent = {
silent: true,
Expand All @@ -17893,6 +17894,20 @@ const createHashFromFile = (filePath) => new Promise((resolve) => {
.on("end", () => resolve(hash.digest("hex")));
});
exports.createHashFromFile = createHashFromFile;
const commandExists = (command) => {
try {
const platform = (0, exports.getPlatformInfo)();
const cmd = platform.os === constants_1.EndorctlAvailableOS.Windows
? `where ${command}`
: `which ${command}`;
(0, child_process_1.execSync)(cmd, { stdio: "ignore" });
return true;
}
catch (error) {
return false;
}
};
exports.commandExists = commandExists;
/**
* Returns the OS and Architecture to be used for downloading endorctl binary,
* based on the current runner OS and Architecture. Returns the error if runner
Expand Down Expand Up @@ -18034,6 +18049,14 @@ const setupEndorctl = ({ version, checksum, api }) => __awaiter(void 0, void 0,
yield io.cp(downloadPath, endorctlPath);
core.addPath(binPath);
core.info(`Endorctl downloaded and added to the path`);
// Check to see if tsserver is installed -- if not install it (needed for javascript callgraphs)
const command = "tsserver";
core.info(`Checking for tsserver`);
if (!(0, exports.commandExists)(command)) {
// Install it
core.info(`Installing tsserver`);
yield exec.exec("npm", ["install", "-g", "typescript"]);
}
}
catch (error) {
core.setFailed(error);
Expand Down
2 changes: 1 addition & 1 deletion dist/sign/index.js.map

Large diffs are not rendered by default.

25 changes: 24 additions & 1 deletion dist/verify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17714,7 +17714,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.createHashFromFile = void 0;
exports.doYouHaveTheTime = exports.uploadArtifact = exports.setupEndorctl = exports.fetchLatestEndorctlVersion = exports.isVersionResponse = exports.isObject = exports.writeJsonToFile = exports.getEndorctlChecksum = exports.getPlatformInfo = exports.commandExists = exports.createHashFromFile = void 0;
const artifact = __importStar(__nccwpck_require__(2605));
const core = __importStar(__nccwpck_require__(2186));
const crypto = __importStar(__nccwpck_require__(6113));
Expand All @@ -17725,6 +17725,7 @@ const httpm = __importStar(__nccwpck_require__(6255));
const io = __importStar(__nccwpck_require__(7436));
const tc = __importStar(__nccwpck_require__(7784));
const path = __importStar(__nccwpck_require__(1017));
const child_process_1 = __nccwpck_require__(2081);
const constants_1 = __nccwpck_require__(9042);
const execOptionSilent = {
silent: true,
Expand All @@ -17736,6 +17737,20 @@ const createHashFromFile = (filePath) => new Promise((resolve) => {
.on("end", () => resolve(hash.digest("hex")));
});
exports.createHashFromFile = createHashFromFile;
const commandExists = (command) => {
try {
const platform = (0, exports.getPlatformInfo)();
const cmd = platform.os === constants_1.EndorctlAvailableOS.Windows
? `where ${command}`
: `which ${command}`;
(0, child_process_1.execSync)(cmd, { stdio: "ignore" });
return true;
}
catch (error) {
return false;
}
};
exports.commandExists = commandExists;
/**
* Returns the OS and Architecture to be used for downloading endorctl binary,
* based on the current runner OS and Architecture. Returns the error if runner
Expand Down Expand Up @@ -17877,6 +17892,14 @@ const setupEndorctl = ({ version, checksum, api }) => __awaiter(void 0, void 0,
yield io.cp(downloadPath, endorctlPath);
core.addPath(binPath);
core.info(`Endorctl downloaded and added to the path`);
// Check to see if tsserver is installed -- if not install it (needed for javascript callgraphs)
const command = "tsserver";
core.info(`Checking for tsserver`);
if (!(0, exports.commandExists)(command)) {
// Install it
core.info(`Installing tsserver`);
yield exec.exec("npm", ["install", "-g", "typescript"]);
}
}
catch (error) {
core.setFailed(error);
Expand Down
2 changes: 1 addition & 1 deletion dist/verify/index.js.map

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as httpm from "@actions/http-client";
import * as io from "@actions/io";
import * as tc from "@actions/tool-cache";
import * as path from "path";
import { execSync } from "child_process";

import {
EndorctlAvailableArch,
Expand Down Expand Up @@ -36,6 +37,21 @@ export const createHashFromFile = (filePath: string) =>
.on("end", () => resolve(hash.digest("hex")));
});

export const commandExists = (command: string) => {
try {
const platform = getPlatformInfo();
const cmd =
platform.os === EndorctlAvailableOS.Windows
? `where ${command}`
: `which ${command}`;

execSync(cmd, { stdio: "ignore" });
return true;
} catch (error) {
return false;
}
};

/**
* Returns the OS and Architecture to be used for downloading endorctl binary,
* based on the current runner OS and Architecture. Returns the error if runner
Expand Down Expand Up @@ -223,6 +239,15 @@ export const setupEndorctl = async ({ version, checksum, api }: SetupProps) => {
core.addPath(binPath);

core.info(`Endorctl downloaded and added to the path`);

// Check to see if tsserver is installed -- if not install it (needed for javascript callgraphs)
const command = "tsserver";
core.info(`Checking for tsserver`);
if (!commandExists(command)) {
// Install it
core.info(`Installing tsserver`);
await exec.exec("npm", ["install", "-g", "typescript"]);
}
} catch (error: any) {
core.setFailed(error);
}
Expand Down
13 changes: 4 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1452,15 +1452,10 @@ camelcase@^6.2.0:
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==

caniuse-lite@^1.0.30001400:
version "1.0.30001447"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001447.tgz#ef1f39ae38d839d7176713735a8e467a0a2523bd"
integrity sha512-bdKU1BQDPeEXe9A39xJnGtY0uRq/z5osrnXUw0TcK+EYno45Y+U7QU9HhHEyzvMDffpYadFXi3idnSNkcwLkTw==

caniuse-lite@^1.0.30001503:
version "1.0.30001512"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001512.tgz#7450843fb581c39f290305a83523c7a9ef0d4cb4"
integrity sha512-2S9nK0G/mE+jasCUsMPlARhRCts1ebcp2Ji8Y8PWi4NDE1iRdLCnEPHkEfeBrGC45L4isBx5ur3IQ6yTE2mRZw==
caniuse-lite@^1.0.30001400, caniuse-lite@^1.0.30001503:
version "1.0.30001669"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001669.tgz"
integrity sha512-DlWzFDJqstqtIVx1zeSpIMLjunf5SmwOw0N2Ck/QSQdS8PLS4+9HrLaYei4w8BIAL7IB/UEDu889d8vhCTPA0w==

chalk@^2.0.0, chalk@^2.4.2:
version "2.4.2"
Expand Down

0 comments on commit f7fea20

Please sign in to comment.