Skip to content

Commit 679ec42

Browse files
committed
chore: modernize tsconfig and refine release trigger
Update tsconfig.json to target ES2022, matching Node 20's capabilities. This removes the __awaiter polyfill in favor of native async/await. Also restrict release workflow to only trigger on dist/ or action.yml changes.
1 parent 269d5d8 commit 679ec42

File tree

5 files changed

+73
-99
lines changed

5 files changed

+73
-99
lines changed

.github/dependabot.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ updates:
77
day: monday
88
time: "09:55"
99
timezone: Europe/Dublin
10-
open-pull-requests-limit: 1
10+
commit-message:
11+
prefix: "chore(deps)"
1112
groups:
1213
github-actions:
1314
patterns:
@@ -21,7 +22,8 @@ updates:
2122
time: "10:00"
2223
timezone: Europe/Dublin
2324
versioning-strategy: increase-if-necessary
24-
open-pull-requests-limit: 1
25+
commit-message:
26+
prefix: "chore(deps)"
2527
groups:
2628
npm-dependencies:
2729
patterns:

.github/workflows/codeql.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
codeql:
1414
name: 🔍 Code quality
1515
runs-on: ubuntu-latest
16+
if: github.actor != 'dependabot[bot]'
1617

1718
steps:
1819
- name: Checkout

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ on:
44
push:
55
branches:
66
- main
7-
paths-ignore:
8-
- "**.md"
9-
- ".github/**"
7+
paths:
8+
- "dist/**"
9+
- "action.yml"
1010

1111
concurrency:
1212
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}

dist/index.js

Lines changed: 51 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -36709,24 +36709,13 @@ var __importStar = (this && this.__importStar) || (function () {
3670936709
return result;
3671036710
};
3671136711
})();
36712-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36713-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36714-
return new (P || (P = Promise))(function (resolve, reject) {
36715-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36716-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36717-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36718-
step((generator = generator.apply(thisArg, _arguments || [])).next());
36719-
});
36720-
};
3672136712
Object.defineProperty(exports, "__esModule", ({ value: true }));
3672236713
const core = __importStar(__nccwpck_require__(7484));
3672336714
const install_1 = __nccwpck_require__(232);
36724-
function run() {
36725-
return __awaiter(this, void 0, void 0, function* () {
36726-
const binaryFolder = yield (0, install_1.installAndGetFolder)();
36727-
core.addPath(binaryFolder);
36728-
core.info("Added spacectl to PATH: " + binaryFolder);
36729-
});
36715+
async function run() {
36716+
const binaryFolder = await (0, install_1.installAndGetFolder)();
36717+
core.addPath(binaryFolder);
36718+
core.info("Added spacectl to PATH: " + binaryFolder);
3673036719
}
3673136720
run();
3673236721

@@ -36771,15 +36760,6 @@ var __importStar = (this && this.__importStar) || (function () {
3677136760
return result;
3677236761
};
3677336762
})();
36774-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36775-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
36776-
return new (P || (P = Promise))(function (resolve, reject) {
36777-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
36778-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
36779-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
36780-
step((generator = generator.apply(thisArg, _arguments || [])).next());
36781-
});
36782-
};
3678336763
var __importDefault = (this && this.__importDefault) || function (mod) {
3678436764
return (mod && mod.__esModule) ? mod : { "default": mod };
3678536765
};
@@ -36799,88 +36779,78 @@ const downloadURL = "https://github.com/spacelift-io/spacectl/releases/download"
3679936779
* It also caches it, so that subsequent runs of the action can use the cached version.
3680036780
* @returns The path of the extracted binary.
3680136781
*/
36802-
function installAndGetFolder() {
36803-
return __awaiter(this, void 0, void 0, function* () {
36804-
const version = yield getVersion();
36805-
const arch = getArchitecture();
36806-
core.setOutput("version", version);
36807-
const cached = tc.find("spacectl", version, arch);
36808-
if (cached) {
36809-
core.info(`Found cached Spacectl at ${cached}`);
36810-
return cached;
36811-
}
36812-
const assetURL = yield getAssetURL(version, arch);
36813-
core.info(`Downloading Spacectl from ${assetURL}`);
36814-
const zipPath = yield tc.downloadTool(assetURL);
36815-
const extractedFolder = yield tc.extractZip(zipPath, path_1.default.join(os_1.default.homedir(), "spacectl"));
36816-
core.info(`Extracted Spacectl to ${extractedFolder}`);
36817-
yield saveToCache(extractedFolder, version, arch);
36818-
return extractedFolder;
36819-
});
36782+
async function installAndGetFolder() {
36783+
const version = await getVersion();
36784+
const arch = getArchitecture();
36785+
core.setOutput("version", version);
36786+
const cached = tc.find("spacectl", version, arch);
36787+
if (cached) {
36788+
core.info(`Found cached Spacectl at ${cached}`);
36789+
return cached;
36790+
}
36791+
const assetURL = await getAssetURL(version, arch);
36792+
core.info(`Downloading Spacectl from ${assetURL}`);
36793+
const zipPath = await tc.downloadTool(assetURL);
36794+
const extractedFolder = await tc.extractZip(zipPath, path_1.default.join(os_1.default.homedir(), "spacectl"));
36795+
core.info(`Extracted Spacectl to ${extractedFolder}`);
36796+
await saveToCache(extractedFolder, version, arch);
36797+
return extractedFolder;
3682036798
}
3682136799
/**
3682236800
* Saves the extracted binary's parent folder to the cache.
3682336801
*/
36824-
function saveToCache(extractedFolder, version, arch) {
36825-
return __awaiter(this, void 0, void 0, function* () {
36826-
const cachedPath = yield tc.cacheDir(extractedFolder, "spacectl", version, arch);
36827-
core.info(`Cached Spacectl to ${cachedPath}`);
36828-
});
36802+
async function saveToCache(extractedFolder, version, arch) {
36803+
const cachedPath = await tc.cacheDir(extractedFolder, "spacectl", version, arch);
36804+
core.info(`Cached Spacectl to ${cachedPath}`);
3682936805
}
3683036806
/**
3683136807
* Returns the URL of the Spacectl zip file for the given version and architecture.
3683236808
* @returns The URL of the Spacectl zip file.
3683336809
* @example "https://github.com/spacelift-io/spacectl/releases/download/v0.12.0/spacectl_0.12.0_linux_arm64.zip"
3683436810
*/
36835-
function getAssetURL(version, arch) {
36836-
return __awaiter(this, void 0, void 0, function* () {
36837-
const versionWithoutLeadingV = version.substring(1);
36838-
const platform = getPlatform();
36839-
return `${downloadURL}/${version}/spacectl_${versionWithoutLeadingV}_${platform}_${arch}.zip`;
36840-
});
36811+
async function getAssetURL(version, arch) {
36812+
const versionWithoutLeadingV = version.substring(1);
36813+
const platform = getPlatform();
36814+
return `${downloadURL}/${version}/spacectl_${versionWithoutLeadingV}_${platform}_${arch}.zip`;
3684136815
}
3684236816
/**
3684336817
* Determines the version of Spacectl to download.
3684436818
* If the user didn't explicitly provide any, we'll use the latest version.
3684536819
* @returns The version of Spacectl to download.
3684636820
* @example "v0.1.0"
3684736821
*/
36848-
function getVersion() {
36849-
return __awaiter(this, void 0, void 0, function* () {
36850-
let version = core.getInput("version");
36851-
// If version is specified, let's prepend a "v" to it
36852-
if (version && version !== "latest" && version[0] !== "v") {
36853-
version = `v${version}`;
36854-
}
36855-
// If version is not specified, we default to the latest
36856-
if (!version || version === "latest") {
36857-
version = yield getLatestVersion();
36858-
}
36859-
core.info(`Installing version ${version} of Spacectl`);
36860-
return version;
36861-
});
36822+
async function getVersion() {
36823+
let version = core.getInput("version");
36824+
// If version is specified, let's prepend a "v" to it
36825+
if (version && version !== "latest" && version[0] !== "v") {
36826+
version = `v${version}`;
36827+
}
36828+
// If version is not specified, we default to the latest
36829+
if (!version || version === "latest") {
36830+
version = await getLatestVersion();
36831+
}
36832+
core.info(`Installing version ${version} of Spacectl`);
36833+
return version;
3686236834
}
3686336835
/**
3686436836
* Gets the latest version of Spacectl from GitHub.
3686536837
* We filter out drafts and pre-releases.
3686636838
* @returns The latest version of Spacectl with a "v" prefix.
3686736839
* @example "v0.1.0"
3686836840
*/
36869-
function getLatestVersion() {
36870-
return __awaiter(this, void 0, void 0, function* () {
36871-
const releaseResponse = yield octokit.rest.repos.listReleases({
36872-
owner: "spacelift-io",
36873-
repo: "spacectl",
36874-
});
36875-
const releaseList = releaseResponse.data;
36876-
if (!(releaseList === null || releaseList === void 0 ? void 0 : releaseList.length)) {
36877-
const errMsg = "Could not find any releases for Spacectl. GitHub outage perhaps? https://www.githubstatus.com/";
36878-
core.setFailed(errMsg);
36879-
throw new Error(errMsg);
36880-
}
36881-
const filteredReleases = releaseList.filter((release) => !release.draft && !release.prerelease);
36882-
return filteredReleases[0].tag_name;
36841+
async function getLatestVersion() {
36842+
const releaseResponse = await octokit.rest.repos.listReleases({
36843+
owner: "spacelift-io",
36844+
repo: "spacectl",
3688336845
});
36846+
const releaseList = releaseResponse.data;
36847+
if (!releaseList?.length) {
36848+
const errMsg = "Could not find any releases for Spacectl. GitHub outage perhaps? https://www.githubstatus.com/";
36849+
core.setFailed(errMsg);
36850+
throw new Error(errMsg);
36851+
}
36852+
const filteredReleases = releaseList.filter((release) => !release.draft && !release.prerelease);
36853+
return filteredReleases[0].tag_name;
3688436854
}
3688536855
/**
3688636856
* Copy-pasta of:

tsconfig.json

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
{
2-
"compilerOptions": {
3-
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
4-
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
5-
"outDir": "./lib", /* Redirect output structure to the directory. */
6-
"rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
7-
"sourceMap": true,
8-
"strict": true, /* Enable all strict type-checking options. */
9-
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
10-
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
11-
},
12-
"exclude": ["lib", "node_modules"]
13-
}
14-
2+
"compilerOptions": {
3+
"target": "ES2022",
4+
"module": "commonjs",
5+
"moduleResolution": "node",
6+
"outDir": "./lib",
7+
"rootDir": "./src",
8+
"sourceMap": true,
9+
"strict": true,
10+
"esModuleInterop": true,
11+
"skipLibCheck": true,
12+
"forceConsistentCasingInFileNames": true
13+
},
14+
"exclude": ["lib", "node_modules", "dist"]
15+
}

0 commit comments

Comments
 (0)