Switch to tsup-based build

This commit is contained in:
Luc Perkins 2024-04-21 13:54:57 -03:00
parent c1c09e0135
commit 650a00ab83
No known key found for this signature in database
GPG key ID: 16DB1108FB591835
10 changed files with 1783 additions and 96820 deletions

2
dist/index.d.ts generated vendored Normal file
View file

@ -0,0 +1,2 @@
export { }

94733
dist/index.js generated vendored

File diff suppressed because one or more lines are too long

1
dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/main.d.ts generated vendored
View file

@ -1 +0,0 @@
export {};

83
dist/main.js generated vendored
View file

@ -1,83 +0,0 @@
import * as actionsCore from "@actions/core";
import * as actionsExec from "@actions/exec";
import { IdsToolbox } from "detsys-ts";
class FlakeCheckerAction {
constructor() {
this.idslib = new IdsToolbox({
name: "flake-checker",
fetchStyle: "gh-env-style",
diagnosticsUrl: new URL("https://install.determinate.systems/flake-checker/telemetry"),
});
this.flakeLockPath =
actionInputStringOrNull("flake-lock-path") || "flake.lock";
this.nixpkgsKeys = actionInputStringOrNull("nixpkgs-keys") || "nixpkgs";
this.checkOutdated = actionInputBool("check-outdated");
this.checkOwner = actionInputBool("check-owner");
this.checkSupported = actionInputBool("check-supported");
this.ignoreMissingFlakeLock = actionInputBool("ignore-missing-flake-lock");
this.failMode = actionInputBool("fail-mode");
this.sendStatistics = actionInputBool("send-statistics");
}
async executionEnvironment() {
const executionEnv = {};
executionEnv.NIX_FLAKE_CHECKER_FLAKE_LOCK_PATH = this.flakeLockPath;
executionEnv.NIX_FLAKE_CHECKER_NIXPKGS_KEYS = this.nixpkgsKeys;
if (!this.sendStatistics) {
executionEnv.NIX_FLAKE_CHECKER_NO_TELEMETRY = "false";
}
if (!this.checkOutdated) {
executionEnv.NIX_FLAKE_CHECKER_CHECK_OUTDATED = "false";
}
if (!this.checkOwner) {
executionEnv.NIX_FLAKE_CHECKER_CHECK_OWNER = "false";
}
if (!this.checkSupported) {
executionEnv.NIX_FLAKE_CHECKER_CHECK_SUPPORTED = "false";
}
if (!this.ignoreMissingFlakeLock) {
executionEnv.NIX_FLAKE_CHECKER_IGNORE_MISSING_FLAKE_LOCK = "false";
}
if (this.failMode) {
executionEnv.NIX_FLAKE_CHECKER_FAIL_MODE = "true";
}
return executionEnv;
}
async check() {
const binaryPath = await this.idslib.fetchExecutable();
const executionEnv = await this.executionEnvironment();
actionsCore.debug(`Execution environment: ${JSON.stringify(executionEnv, null, 4)}`);
const exitCode = await actionsExec.exec(binaryPath, [], {
env: {
...executionEnv,
...process.env, // To get $PATH, etc
},
});
if (exitCode !== 0) {
this.idslib.recordEvent("execution_failure", {
exitCode,
});
throw new Error(`Non-zero exit code of \`${exitCode}\` detected`);
}
return exitCode;
}
}
function actionInputStringOrNull(name) {
const value = actionsCore.getInput(name);
if (value === "") {
return null;
}
else {
return value;
}
}
function actionInputBool(name) {
return actionsCore.getBooleanInput(name);
}
function main() {
const checker = new FlakeCheckerAction();
checker.idslib.onMain(async () => {
await checker.check();
});
checker.idslib.execute();
}
main();

3
dist/package.json generated vendored
View file

@ -1,3 +0,0 @@
{
"type": "module"
}

View file

@ -2,11 +2,11 @@
"name": "flake-checker-action",
"version": "1.0.0",
"description": "",
"main": "./dist/main.js",
"types": "./dist/main.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"type": "module",
"scripts": {
"build": "tsc",
"build": "tsup",
"format": "prettier --write .",
"lint": "eslint src/**/*.ts",
"package": "ncc build",
@ -44,6 +44,7 @@
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"tsup": "^8.0.2",
"typescript": "^5.4.5"
}
}

3757
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

16
tsup.config.ts Normal file
View file

@ -0,0 +1,16 @@
import { defineConfig } from "tsup";
import { name } from "./package.json";
export default defineConfig({
name,
entry: ["src/index.ts"],
format: ["esm"],
target: "node20",
bundle: true,
splitting: false,
sourcemap: true,
clean: true,
dts: {
resolve: true,
},
});