1 Commits

Author SHA1 Message Date
Renovate 7577dcc9ad fix(deps): update dependency @actions/core to v3
renovate/artifacts Artifact file update failure
Lint / pre-commit Linting (push) Successful in 1m11s
Test / Run Tests (push) Failing after 1m9s
2026-02-08 17:08:16 +00:00
9 changed files with 926 additions and 803 deletions
+2 -2
View File
@@ -9,8 +9,8 @@ jobs:
name: pre-commit Linting name: pre-commit Linting
runs-on: pi runs-on: pi
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/checkout@v6
- uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 - uses: actions/setup-python@v6
- run: pip install pre-commit - run: pip install pre-commit
shell: bash shell: bash
- name: Pre Commit - name: Pre Commit
+2 -2
View File
@@ -9,8 +9,8 @@ jobs:
name: Run Tests name: Run Tests
runs-on: pi runs-on: pi
steps: steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 - uses: actions/checkout@v6
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 - uses: actions/setup-node@v6
with: with:
node-version: '24' node-version: '24'
- run: npm install - run: npm install
+1 -1
View File
@@ -29,7 +29,7 @@ repos:
types_or: [css, javascript] types_or: [css, javascript]
- repo: https://github.com/python-jsonschema/check-jsonschema - repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.1 rev: 0.36.0
hooks: hooks:
- id: check-renovate - id: check-renovate
- id: check-github-actions - id: check-github-actions
+6 -6
View File
@@ -1,13 +1,13 @@
import { const {
validateAuthentication, validateAuthentication,
replacePlaceholders, replacePlaceholders,
readReplaceAndWriteFiles, readReplaceAndWriteFiles,
readFilesIntoDict, readFilesIntoDict,
} from "../index.js"; } = require("../index");
import fs from "fs"; const fs = require("fs");
import path from "path"; const path = require("path");
import os from "os"; const os = require("os");
import { glob } from "glob"; const { glob } = require("glob");
describe("validateAuthentication", () => { describe("validateAuthentication", () => {
it("should return null when only token is provided", () => { it("should return null when only token is provided", () => {
+5 -6
View File
File diff suppressed because one or more lines are too long
-3
View File
@@ -1,3 +0,0 @@
{
"type": "module"
}
+19 -13
View File
@@ -1,9 +1,8 @@
import { ScreepsAPI } from "screeps-api"; const { ScreepsAPI } = require("screeps-api");
import * as core from "@actions/core"; const core = require("@actions/core");
import fs from "fs"; const fs = require("fs");
import { glob } from "glob"; const { glob } = require("glob");
import path from "path"; const path = require("path");
import { fileURLToPath } from "url";
/** /**
* Replaces specific placeholder strings within the provided content with corresponding dynamic values. * Replaces specific placeholder strings within the provided content with corresponding dynamic values.
@@ -18,7 +17,7 @@ import { fileURLToPath } from "url";
* @param {string} content - The string content in which placeholders are to be replaced. * @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. * @returns {string} The content with placeholders replaced by their respective dynamic values.
*/ */
export function replacePlaceholders(content, hostname) { function replacePlaceholders(content, hostname) {
const deployTime = new Date().toISOString(); const deployTime = new Date().toISOString();
return content return content
.replace(/{{gitHash}}/g, process.env.GITHUB_SHA) .replace(/{{gitHash}}/g, process.env.GITHUB_SHA)
@@ -38,7 +37,7 @@ export function replacePlaceholders(content, hostname) {
* @param {string} [prefix] - An optional directory prefix to prepend to the glob pattern. This allows searching within a specific directory. * @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. * @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.
*/ */
export async function readReplaceAndWriteFiles(pattern, prefix, hostname) { async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
const globPattern = prefix ? path.join(prefix, pattern) : pattern; const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const files = await glob(globPattern); const files = await glob(globPattern);
@@ -59,7 +58,7 @@ export async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
* @param {string} prefix - Directory prefix for file paths. * @param {string} prefix - Directory prefix for file paths.
* @returns {Promise<Object>} - Promise resolving to a dictionary of file contents keyed by filenames. * @returns {Promise<Object>} - Promise resolving to a dictionary of file contents keyed by filenames.
*/ */
export async function readFilesIntoDict(pattern, prefix) { async function readFilesIntoDict(pattern, prefix) {
// Prepend the prefix to the glob pattern // Prepend the prefix to the glob pattern
const globPattern = prefix ? path.join(prefix, pattern) : pattern; const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const files = await glob(globPattern); const files = await glob(globPattern);
@@ -89,7 +88,7 @@ export async function readFilesIntoDict(pattern, prefix) {
* @param {string} password - The password. * @param {string} password - The password.
* @returns {string|null} - Returns an error message if validation fails, otherwise null. * @returns {string|null} - Returns an error message if validation fails, otherwise null.
*/ */
export function validateAuthentication(token, username, password) { function validateAuthentication(token, username, password) {
if (token) { if (token) {
if (username || password) { if (username || password) {
return "Token is defined along with username and/or password."; return "Token is defined along with username and/or password.";
@@ -111,7 +110,7 @@ export function validateAuthentication(token, username, password) {
/** /**
* Posts code to Screeps server. * Posts code to Screeps server.
*/ */
export async function postCode() { async function postCode() {
const protocol = core.getInput("protocol") || "https"; const protocol = core.getInput("protocol") || "https";
const hostname = core.getInput("hostname") || "screeps.com"; const hostname = core.getInput("hostname") || "screeps.com";
const port = core.getInput("port") || "443"; const port = core.getInput("port") || "443";
@@ -176,7 +175,14 @@ export async function postCode() {
} }
} }
const __filename = fileURLToPath(import.meta.url); if (require.main === module) {
if (process.argv[1] === __filename) {
postCode(); postCode();
} }
module.exports = {
validateAuthentication,
replacePlaceholders,
postCode,
readReplaceAndWriteFiles,
readFilesIntoDict,
};
+891 -769
View File
File diff suppressed because it is too large Load Diff
-1
View File
@@ -2,7 +2,6 @@
"name": "screeps-deploy-action", "name": "screeps-deploy-action",
"version": "0.1.1", "version": "0.1.1",
"description": "Deploys screeps code to the official game or an pirvate server.", "description": "Deploys screeps code to the official game or an pirvate server.",
"type": "module",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
"start": "node index.js", "start": "node index.js",