chore: update @actions/core to v3 and convert to ESM
All checks were successful
Lint / pre-commit Linting (push) Successful in 31s
Test / Run Tests (push) Successful in 39s

This commit updates the @actions/core dependency from v2 to v3.
The primary change in @actions/core v3 is that it is now an ESM-only package.
To maintain compatibility, the following changes were made:
- Added "type": "module" to package.json to switch the project to ESM.
- Converted index.js from CommonJS to ESM, replacing require with import/export.
- Converted __tests__/index.test.js to ESM to support testing the updated index.js.
- Re-built the production bundle in dist/ using ncc to reflect the changes.
- Updated the main entry point check in index.js to use import.meta.url for ESM compatibility.

This ensures the action continues to function correctly with the latest GitHub Actions toolkit library.
This commit is contained in:
2026-02-23 00:46:48 +00:00
parent cbbd0e64e8
commit cebff45aa7
6 changed files with 46 additions and 47 deletions

View File

@@ -1,8 +1,9 @@
const { ScreepsAPI } = require("screeps-api");
const core = require("@actions/core");
const fs = require("fs");
const { glob } = require("glob");
const path = require("path");
import { ScreepsAPI } from "screeps-api";
import * as core from "@actions/core";
import fs from "fs";
import { glob } from "glob";
import path from "path";
import { fileURLToPath } from "url";
/**
* Replaces specific placeholder strings within the provided content with corresponding dynamic values.
@@ -17,7 +18,7 @@ const path = require("path");
* @param {string} content - The string content in which placeholders are to be replaced.
* @returns {string} The content with placeholders replaced by their respective dynamic values.
*/
function replacePlaceholders(content, hostname) {
export function replacePlaceholders(content, hostname) {
const deployTime = new Date().toISOString();
return content
.replace(/{{gitHash}}/g, process.env.GITHUB_SHA)
@@ -37,7 +38,7 @@ function replacePlaceholders(content, hostname) {
* @param {string} [prefix] - An optional directory prefix to prepend to the glob pattern. This allows searching within a specific directory.
* @returns {Promise<string[]>} A promise that resolves with an array of file paths that were processed, or rejects with an error if the process fails.
*/
async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
export async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const files = await glob(globPattern);
@@ -58,7 +59,7 @@ async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
* @param {string} prefix - Directory prefix for file paths.
* @returns {Promise<Object>} - Promise resolving to a dictionary of file contents keyed by filenames.
*/
async function readFilesIntoDict(pattern, prefix) {
export async function readFilesIntoDict(pattern, prefix) {
// Prepend the prefix to the glob pattern
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const files = await glob(globPattern);
@@ -88,7 +89,7 @@ async function readFilesIntoDict(pattern, prefix) {
* @param {string} password - The password.
* @returns {string|null} - Returns an error message if validation fails, otherwise null.
*/
function validateAuthentication(token, username, password) {
export function validateAuthentication(token, username, password) {
if (token) {
if (username || password) {
return "Token is defined along with username and/or password.";
@@ -110,7 +111,7 @@ function validateAuthentication(token, username, password) {
/**
* Posts code to Screeps server.
*/
async function postCode() {
export async function postCode() {
const protocol = core.getInput("protocol") || "https";
const hostname = core.getInput("hostname") || "screeps.com";
const port = core.getInput("port") || "443";
@@ -175,14 +176,7 @@ async function postCode() {
}
}
if (require.main === module) {
const __filename = fileURLToPath(import.meta.url);
if (process.argv[1] === __filename) {
postCode();
}
module.exports = {
validateAuthentication,
replacePlaceholders,
postCode,
readReplaceAndWriteFiles,
readFilesIntoDict,
};