1 Commits

Author SHA1 Message Date
Renovate 519d79275e chore(deps): update dependency glob to v13.0.1
Lint / pre-commit Linting (push) Successful in 1m18s
Test / Run Tests (push) Successful in 1m40s
2026-02-08 17:07:25 +00:00
9 changed files with 945 additions and 843 deletions
+3 -3
View File
@@ -9,10 +9,10 @@ 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
run: SKIP=no-commit-to-branch pre-commit run -a --hook-stage pre-commit --hook-stage manual run: SKIP=no-commit-to-branch pre-commit run -a
shell: bash shell: bash
+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
+2 -23
View File
@@ -1,4 +1,3 @@
default_stages: [pre-commit, manual]
exclude: ^(dist|node_modules)/ exclude: ^(dist|node_modules)/
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
@@ -16,7 +15,6 @@ repos:
args: [--autofix, --no-sort-keys, --no-ensure-ascii] args: [--autofix, --no-sort-keys, --no-ensure-ascii]
- id: check-merge-conflict - id: check-merge-conflict
- id: no-commit-to-branch - id: no-commit-to-branch
stages: [pre-commit]
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.16.0 rev: v2.16.0
@@ -31,37 +29,18 @@ 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.2 rev: 0.36.0
hooks: hooks:
- id: check-renovate - id: check-renovate
- id: check-github-actions - id: check-github-actions
stages: [manual]
- id: check-github-workflows - id: check-github-workflows
stages: [manual]
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0 rev: v6.0.0
hooks: hooks:
- id: end-of-file-fixer - id: end-of-file-fixer
exclude: (.txt$|.ipynb$|README.md$) exclude: (.txt$|.ipynb$|README.md$|readme.mde$)
- id: trailing-whitespace - id: trailing-whitespace
exclude: (.txt$|README.md$) exclude: (.txt$|README.md$)
- id: mixed-line-ending - id: mixed-line-ending
args: [--fix=lf] args: [--fix=lf]
- repo: local
hooks:
- id: build
name: rebuild-distribution
entry: npm run build
language: system
files: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$
pass_filenames: false
stages: [pre-commit]
- id: add-dist
name: stage-distribution
entry: git add dist/
language: system
files: ^(index\.js|monitor\.js|package\.json|package-lock\.json)$
pass_filenames: false
stages: [pre-commit]
+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,
};
+907 -785
View File
File diff suppressed because it is too large Load Diff
+1 -2
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",
@@ -10,7 +9,7 @@
"build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil" "build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil"
}, },
"dependencies": { "dependencies": {
"@actions/core": "^3.0.0", "@actions/core": "^2.0.0",
"glob": "^13.0.0", "glob": "^13.0.0",
"screeps-api": "^1.7.2" "screeps-api": "^1.7.2"
}, },