mirror of
https://github.com/DeLaGuardo/setup-clojure.git
synced 2025-01-14 02:18:07 +08:00
add boot
This commit is contained in:
parent
9c42d0973c
commit
e7af392020
@ -1,6 +1,4 @@
|
||||
import io = require('@actions/io');
|
||||
import exec = require('@actions/exec');
|
||||
import core = require('@actions/core');
|
||||
import os = require('os');
|
||||
import fs = require('fs');
|
||||
import path = require('path');
|
||||
|
71
lib/boot.js
71
lib/boot.js
@ -8,10 +8,79 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
|
||||
result["default"] = mod;
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core = __importStar(require("@actions/core"));
|
||||
const io = __importStar(require("@actions/io"));
|
||||
const tc = __importStar(require("@actions/tool-cache"));
|
||||
const exec = __importStar(require("@actions/exec"));
|
||||
const fs = __importStar(require("fs"));
|
||||
const path = __importStar(require("path"));
|
||||
const os = __importStar(require("os"));
|
||||
const utils = __importStar(require("./utils"));
|
||||
let tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
if (IS_WINDOWS) {
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
}
|
||||
else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
}
|
||||
else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
function setup(version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
throw new Error('Not yet available');
|
||||
let toolPath = tc.find('ClojureBoot', utils.getCacheVersionString(version), os.arch());
|
||||
if (toolPath) {
|
||||
core.info(`Boot found in cache ${toolPath}`);
|
||||
}
|
||||
else {
|
||||
let bootBootstrapFile = yield tc.downloadTool(`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh`);
|
||||
let tempDir = path.join(tempDirectory, 'temp_' + Math.floor(Math.random() * 2000000000));
|
||||
const bootDir = yield installBoot(bootBootstrapFile, tempDir, version);
|
||||
core.debug(`Boot installed to ${bootDir}`);
|
||||
toolPath = yield tc.cacheDir(bootDir, 'ClojureBoot', utils.getCacheVersionString(version));
|
||||
}
|
||||
core.exportVariable('BOOT_HOME', toolPath);
|
||||
core.exportVariable('BOOT_VERSION', version);
|
||||
core.addPath(path.join(toolPath, 'bin'));
|
||||
});
|
||||
}
|
||||
exports.setup = setup;
|
||||
function installBoot(binScript, destinationFolder, version) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
yield io.mkdirP(destinationFolder);
|
||||
const bin = path.normalize(binScript);
|
||||
const binStats = fs.statSync(bin);
|
||||
if (binStats.isFile()) {
|
||||
const binDir = path.join(destinationFolder, 'boot', 'bin');
|
||||
yield io.mkdirP(binDir);
|
||||
yield io.mv(bin, path.join(binDir, `boot`));
|
||||
fs.chmodSync(path.join(binDir, `boot`), '0755');
|
||||
yield exec.exec('./boot -V', [], {
|
||||
cwd: path.join(destinationFolder, 'boot', 'bin'),
|
||||
env: {
|
||||
'BOOT_HOME': path.join(destinationFolder, 'boot'),
|
||||
'BOOT_VERSION': version
|
||||
}
|
||||
});
|
||||
return path.join(destinationFolder, 'boot');
|
||||
}
|
||||
else {
|
||||
throw new Error('Not a file');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
96
src/boot.ts
96
src/boot.ts
@ -1,3 +1,95 @@
|
||||
export async function setup(version: string): Promise<void> {
|
||||
throw new Error('Not yet available');
|
||||
import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import * as exec from '@actions/exec';
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import * as utils from './utils';
|
||||
|
||||
let tempDirectory = process.env['RUNNER_TEMP'] || '';
|
||||
const IS_WINDOWS = process.platform === 'win32';
|
||||
|
||||
if (!tempDirectory) {
|
||||
let baseLocation;
|
||||
if (IS_WINDOWS) {
|
||||
baseLocation = process.env['USERPROFILE'] || 'C:\\';
|
||||
} else {
|
||||
if (process.platform === 'darwin') {
|
||||
baseLocation = '/Users';
|
||||
} else {
|
||||
baseLocation = '/home';
|
||||
}
|
||||
}
|
||||
tempDirectory = path.join(baseLocation, 'actions', 'temp');
|
||||
}
|
||||
|
||||
export async function setup(version: string): Promise<void> {
|
||||
let toolPath = tc.find(
|
||||
'ClojureBoot',
|
||||
utils.getCacheVersionString(version),
|
||||
os.arch()
|
||||
);
|
||||
|
||||
if (toolPath) {
|
||||
core.info(`Boot found in cache ${toolPath}`);
|
||||
} else {
|
||||
let bootBootstrapFile = await tc.downloadTool(
|
||||
`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh`
|
||||
);
|
||||
let tempDir: string = path.join(
|
||||
tempDirectory,
|
||||
'temp_' + Math.floor(Math.random() * 2000000000)
|
||||
);
|
||||
const bootDir = await installBoot(
|
||||
bootBootstrapFile,
|
||||
tempDir,
|
||||
version
|
||||
);
|
||||
core.debug(`Boot installed to ${bootDir}`);
|
||||
toolPath = await tc.cacheDir(
|
||||
bootDir,
|
||||
'ClojureBoot',
|
||||
utils.getCacheVersionString(version)
|
||||
);
|
||||
}
|
||||
|
||||
core.exportVariable('BOOT_HOME', toolPath);
|
||||
core.exportVariable('BOOT_VERSION', version);
|
||||
core.addPath(path.join(toolPath, 'bin'));
|
||||
}
|
||||
|
||||
async function installBoot(
|
||||
binScript: string,
|
||||
destinationFolder: string,
|
||||
version: string
|
||||
): Promise<string> {
|
||||
await io.mkdirP(destinationFolder);
|
||||
|
||||
const bin = path.normalize(binScript);
|
||||
const binStats = fs.statSync(bin);
|
||||
if (binStats.isFile()) {
|
||||
const binDir = path.join(destinationFolder, 'boot', 'bin');
|
||||
|
||||
await io.mkdirP(binDir);
|
||||
|
||||
await io.mv(bin, path.join(binDir, `boot`));
|
||||
fs.chmodSync(path.join(binDir, `boot`), '0755');
|
||||
|
||||
await exec.exec(
|
||||
'./boot -V',
|
||||
[],
|
||||
{
|
||||
cwd: path.join(destinationFolder, 'boot', 'bin'),
|
||||
env: {
|
||||
'BOOT_HOME': path.join(destinationFolder, 'boot'),
|
||||
'BOOT_VERSION': version
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return path.join(destinationFolder, 'boot');
|
||||
} else {
|
||||
throw new Error('Not a file');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user