Compare commits

...

2 Commits

Author SHA1 Message Date
Michael B. Gale
7776325064 Set removeComments to true 2026-10-20 19:00:35 +01:00
Michael B. Gale
9af13e3a4a Use tsc output in build.mjs rather than compiling twice 2026-10-20 19:00:15 +01:00
15 changed files with 31819 additions and 29756 deletions

View File

@@ -11,6 +11,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const SRC_DIR = join(__dirname, "src");
const BUILD_DIR = join(__dirname, "build");
const OUT_DIR = join(__dirname, "lib");
/**
@@ -69,7 +70,7 @@ const SHARED_ENTRYPOINT = "entry-points";
const UPLOAD_LIB_EXPORT = "uploadLib";
/** The relative source path of the `upload-lib` module that we re-export from `entry-points`. */
const UPLOAD_LIB_SRC = "./src/upload-lib";
const UPLOAD_LIB_SRC = "./build/upload-lib.js";
/**
* This plugin finds all source files that contain Action entry points. It then generates the
@@ -95,7 +96,7 @@ const entryPointsPlugin = {
// Find the source files containing Action entry points.
build.onStart(() => {
const actionFiles = globSync("src/*-action{,-post}.ts");
const actionFiles = globSync(join(BUILD_DIR, "*-action{,-post}.js"));
for (const actionFile of actionFiles) {
const match = basename(actionFile).match(/(.*)-action(-post)?/);
@@ -137,7 +138,7 @@ const entryPointsPlugin = {
const imports = actionsSorted
.map(
(action) =>
`import * as ${action.pascalCaseName} from "./src/${basename(action.path)}";`,
`import * as ${action.pascalCaseName} from "./build/${basename(action.path)}";`,
)
.join("\n");
const wrappers = actionsSorted
@@ -153,14 +154,14 @@ const entryPointsPlugin = {
return {
contents: `"use strict";\n${imports}\n\n${uploadLibReExport}\n\n${wrappers}\n`,
resolveDir: ".",
loader: "ts",
loader: "js",
};
});
// Emit entry point stubs for each Action using the entry template.
build.onEnd(async () => {
const makeHeader = (templatePath, sourceFile) =>
`// Automatically generated from '${templatePath}' for 'src/${basename(sourceFile)}'.\n\n`;
`// Automatically generated from '${templatePath}' for 'build/${basename(sourceFile)}'.\n\n`;
// Read the entry point template.
const actionTemplatePath = "action-entry.js.tpl";
@@ -191,7 +192,7 @@ const entryPointsPlugin = {
);
await writeFile(
join(OUT_DIR, "upload-lib.js"),
makeHeader(uploadLibStubTemplatePath, `${UPLOAD_LIB_SRC}.ts`) +
makeHeader(uploadLibStubTemplatePath, `${UPLOAD_LIB_SRC}`) +
uploadLibStubTemplate.replaceAll(
"__UPLOAD_LIB_EXPORT__",
UPLOAD_LIB_EXPORT,

2
lib/analyze-entry.js generated
View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/analyze-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/analyze-action.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/analyze-action-post.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/analyze-action-post.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/autobuild-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/autobuild-action.js'.
"use strict";

61537
lib/entry-points.js generated

File diff suppressed because it is too large Load Diff

2
lib/init-entry.js generated
View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/init-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/init-action.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/init-action-post.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/init-action-post.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/resolve-environment-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/resolve-environment-action.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/setup-codeql-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/setup-codeql-action.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/start-proxy-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/start-proxy-action.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/start-proxy-action-post.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/start-proxy-action-post.js'.
"use strict";

2
lib/upload-lib.js generated
View File

@@ -1,4 +1,4 @@
// Automatically generated from 'upload-lib-stub.js.tpl' for 'src/upload-lib.ts'.
// Automatically generated from 'upload-lib-stub.js.tpl' for 'build/upload-lib.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/upload-sarif-action.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/upload-sarif-action.js'.
"use strict";

View File

@@ -1,4 +1,4 @@
// Automatically generated from 'action-entry.js.tpl' for 'src/upload-sarif-action-post.ts'.
// Automatically generated from 'action-entry.js.tpl' for 'build/upload-sarif-action-post.js'.
"use strict";

View File

@@ -9,6 +9,7 @@
"rootDir": "./src",
"sourceMap": true,
"types": ["node"],
"removeComments": true, /* Remove all comments. */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */