13 Commits

Author SHA1 Message Date
d918fd764c chore(deps): update vitest monorepo to v4.0.17 (#63)
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m11s
Test / Run Tests (push) Successful in 1m13s
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@vitest/coverage-v8](https://github.com/vitest-dev/vitest/tree/main/packages/coverage-v8#readme) ([source](https://github.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8)) | [`4.0.16` → `4.0.17`](https://renovatebot.com/diffs/npm/@vitest%2fcoverage-v8/4.0.16/4.0.17) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@vitest%2fcoverage-v8/4.0.17?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@vitest%2fcoverage-v8/4.0.16/4.0.17?slim=true) |
| [vitest](https://vitest.dev) ([source](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest)) | [`4.0.16` → `4.0.17`](https://renovatebot.com/diffs/npm/vitest/4.0.16/4.0.17) | ![age](https://developer.mend.io/api/mc/badges/age/npm/vitest/4.0.17?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/vitest/4.0.16/4.0.17?slim=true) |

---

### Release Notes

<details>
<summary>vitest-dev/vitest (@&#8203;vitest/coverage-v8)</summary>

### [`v4.0.17`](https://github.com/vitest-dev/vitest/releases/tag/v4.0.17)

[Compare Source](https://github.com/vitest-dev/vitest/compare/v4.0.16...v4.0.17)

#####    🚀 Experimental Features

- Support openTelemetry for browser mode  -  by [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9180](https://github.com/vitest-dev/vitest/issues/9180) [<samp>(1ec3a)</samp>](https://github.com/vitest-dev/vitest/commit/1ec3a8b68)
- Support TRACEPARENT and TRACESTATE environment variables for OpenTelemetry context propagation  -  by [@&#8203;Copilot](https://github.com/Copilot), **hi-ogawa** and [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9295](https://github.com/vitest-dev/vitest/issues/9295) [<samp>(876cb)</samp>](https://github.com/vitest-dev/vitest/commit/876cb84c2)

#####    🐞 Bug Fixes

- Improve asymmetric matcher diff readability by unwrapping container matchers  -  by [@&#8203;Copilot](https://github.com/Copilot), **sheremet-va**, **hi-ogawa** and [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9330](https://github.com/vitest-dev/vitest/issues/9330) [<samp>(b2ec7)</samp>](https://github.com/vitest-dev/vitest/commit/b2ec724a8)
- Improve runner error when importing outside of test context  -  by [@&#8203;sheremet-va](https://github.com/sheremet-va) in [#&#8203;9335](https://github.com/vitest-dev/vitest/issues/9335) [<samp>(2dd3d)</samp>](https://github.com/vitest-dev/vitest/commit/2dd3dd839)
- Replace crypto.randomUUID to allow insecure environments (fix [#&#8203;9](https://github.com/vitest-dev/vitest/issues/9)…  -  by [@&#8203;plusgut](https://github.com/plusgut) in [#&#8203;9339](https://github.com/vitest-dev/vitest/issues/9339) and [#&#8203;9](https://github.com/vitest-dev/vitest/issues/9) [<samp>(e6a3f)</samp>](https://github.com/vitest-dev/vitest/commit/e6a3f8cc7)
- Handle null options in `addEventHandler` [#&#8203;9371](https://github.com/vitest-dev/vitest/issues/9371)  -  by [@&#8203;ThibautMarechal](https://github.com/ThibautMarechal) in [#&#8203;9372](https://github.com/vitest-dev/vitest/issues/9372) and [#&#8203;9371](https://github.com/vitest-dev/vitest/issues/9371) [<samp>(40841)</samp>](https://github.com/vitest-dev/vitest/commit/40841ff00)
- Typo in browser.provider error  -  by [@&#8203;deammer](https://github.com/deammer) in [#&#8203;9394](https://github.com/vitest-dev/vitest/issues/9394) [<samp>(4b67f)</samp>](https://github.com/vitest-dev/vitest/commit/4b67fc25a)
- **browser**:
  - Fix `process.env` and `import.meta.env` defines in inline project  -  by [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9239](https://github.com/vitest-dev/vitest/issues/9239) [<samp>(b70c9)</samp>](https://github.com/vitest-dev/vitest/commit/b70c96121)
  - Fix upload File instance  -  by [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9294](https://github.com/vitest-dev/vitest/issues/9294) [<samp>(b6778)</samp>](https://github.com/vitest-dev/vitest/commit/b67788c69)
  - Fix invalid project token for artifacts assets  -  by [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9321](https://github.com/vitest-dev/vitest/issues/9321) [<samp>(caa7d)</samp>](https://github.com/vitest-dev/vitest/commit/caa7d73d4)
  - Log `ErrorEvent.message` when unhandled `ErrorEvent.error` is null  -  by [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9322](https://github.com/vitest-dev/vitest/issues/9322) [<samp>(5d84e)</samp>](https://github.com/vitest-dev/vitest/commit/5d84eeb91)
  - Support `fileParallelism` on an instance  -  by [@&#8203;sheremet-va](https://github.com/sheremet-va) in [#&#8203;9328](https://github.com/vitest-dev/vitest/issues/9328) [<samp>(15006)</samp>](https://github.com/vitest-dev/vitest/commit/150065459)
- **coverage**:
  - Remove unnecessary `istanbul-lib-source-maps` usage  -  by [@&#8203;AriPerkkio](https://github.com/AriPerkkio) in [#&#8203;9344](https://github.com/vitest-dev/vitest/issues/9344) [<samp>(b0940)</samp>](https://github.com/vitest-dev/vitest/commit/b09405375)
  - Apply patch from [istanbuljs/istanbuljs#837](https://github.com/istanbuljs/istanbuljs/issues/837)  -  by [@&#8203;AriPerkkio](https://github.com/AriPerkkio) and **sapphi-red** in [#&#8203;9413](https://github.com/vitest-dev/vitest/issues/9413) and [#&#8203;837](https://github.com/vitest-dev/vitest/issues/837) [<samp>(e05ce)</samp>](https://github.com/vitest-dev/vitest/commit/e05cedbf4)
- **fsModuleCache**:
  - Don't store importers in cache  -  by [@&#8203;sheremet-va](https://github.com/sheremet-va) in [#&#8203;9422](https://github.com/vitest-dev/vitest/issues/9422) [<samp>(75136)</samp>](https://github.com/vitest-dev/vitest/commit/751364eec)
  - Add importers alongside importedModules  -  by [@&#8203;sheremet-va](https://github.com/sheremet-va) in [#&#8203;9423](https://github.com/vitest-dev/vitest/issues/9423) [<samp>(59f92)</samp>](https://github.com/vitest-dev/vitest/commit/59f92d403)
- **mocker**:
  - Fix mock transform with class  -  by [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9421](https://github.com/vitest-dev/vitest/issues/9421) [<samp>(d390e)</samp>](https://github.com/vitest-dev/vitest/commit/d390eb527)
- **pool**:
  - Validate environment options when reusing the worker  -  by [@&#8203;sheremet-va](https://github.com/sheremet-va) in [#&#8203;9349](https://github.com/vitest-dev/vitest/issues/9349) [<samp>(a8a88)</samp>](https://github.com/vitest-dev/vitest/commit/a8a8836e3)
  - Handle worker start failures gracefully  -  by [@&#8203;AriPerkkio](https://github.com/AriPerkkio) in [#&#8203;9337](https://github.com/vitest-dev/vitest/issues/9337) [<samp>(200da)</samp>](https://github.com/vitest-dev/vitest/commit/200dadb32)
- **reporter**:
  - Report test module if it failed to run  -  by [@&#8203;sheremet-va](https://github.com/sheremet-va) in [#&#8203;9272](https://github.com/vitest-dev/vitest/issues/9272) [<samp>(c7888)</samp>](https://github.com/vitest-dev/vitest/commit/c78882985)
- **runner**:
  - Respect nested test.only within describe.only  -  by [@&#8203;Ujjwaljain16](https://github.com/Ujjwaljain16) in [#&#8203;9021](https://github.com/vitest-dev/vitest/issues/9021) and [#&#8203;9213](https://github.com/vitest-dev/vitest/issues/9213) [<samp>(55d5d)</samp>](https://github.com/vitest-dev/vitest/commit/55d5dad69)
- **typecheck**:
  - Improve error message when tsc outputs help text  -  by [@&#8203;Ujjwaljain16](https://github.com/Ujjwaljain16) in [#&#8203;9214](https://github.com/vitest-dev/vitest/issues/9214) [<samp>(7b10a)</samp>](https://github.com/vitest-dev/vitest/commit/7b10ab4cd)
- **ui**:
  - Detect gzip by magic numbers instead of Content-Type header in html reporter  -  by [@&#8203;Copilot](https://github.com/Copilot), **hi-ogawa** and [@&#8203;hi-ogawa](https://github.com/hi-ogawa) in [#&#8203;9278](https://github.com/vitest-dev/vitest/issues/9278) [<samp>(dd033)</samp>](https://github.com/vitest-dev/vitest/commit/dd0331632)
- **webdriverio**:
  - Fall back to WebDriver Classic [#&#8203;9244](https://github.com/vitest-dev/vitest/issues/9244)  -  by [@&#8203;JustasMonkev](https://github.com/JustasMonkev) in [#&#8203;9373](https://github.com/vitest-dev/vitest/issues/9373) and [#&#8203;9244](https://github.com/vitest-dev/vitest/issues/9244) [<samp>(c23dd)</samp>](https://github.com/vitest-dev/vitest/commit/c23dd11bd)

#####     [View changes on GitHub](https://github.com/vitest-dev/vitest/compare/v4.0.16...v4.0.17)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these updates again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43MS40IiwidXBkYXRlZEluVmVyIjoiNDIuNzEuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiQXV0b21hdGlvbiJdfQ==-->

Reviewed-on: https://git.horstenkamp.eu/Screeps/screeps-deploy-action/pulls/63
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2026-01-16 18:10:19 +01:00
4a3dbb707c chore(deps): update dependency @actions/core to v2.0.2 (#62)
Some checks failed
Lint / pre-commit Linting (push) Waiting to run
Test / Run Tests (push) Has been cancelled
This PR contains the following updates:

| Package | Change | [Age](https://docs.renovatebot.com/merge-confidence/) | [Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| [@actions/core](https://github.com/actions/toolkit/tree/main/packages/core) ([source](https://github.com/actions/toolkit/tree/HEAD/packages/core)) | [`2.0.1` → `2.0.2`](https://renovatebot.com/diffs/npm/@actions%2fcore/2.0.1/2.0.2) | ![age](https://developer.mend.io/api/mc/badges/age/npm/@actions%2fcore/2.0.2?slim=true) | ![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@actions%2fcore/2.0.1/2.0.2?slim=true) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0Mi43MS40IiwidXBkYXRlZEluVmVyIjoiNDIuODEuMTYiLCJ0YXJnZXRCcmFuY2giOiJtYWluIiwibGFiZWxzIjpbIkF1dG9tYXRpb24iXX0=-->

Reviewed-on: #62
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2026-01-16 18:09:35 +01:00
bfa059df07 chore(deps): update pre-commit hook macisamuele/language-formatters-pre-commit-hooks to v2.16.0 (#64)
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m11s
Test / Run Tests (push) Successful in 1m16s
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2026-01-16 01:28:56 +01:00
c5a58026fa Remove unused pre-commit hooks (#61)
All checks were successful
Test / Run Tests (push) Successful in 9m59s
Lint / pre-commit Linting (push) Successful in 10m6s
### **PR Type**
Enhancement

___

### **Description**
- Remove unused pre-commit hooks

- Delete `pretty-format-ini` and `pretty-format-toml`

___

<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Configuration changes</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>.pre-commit-config.yaml</strong><dd><code>Clean up pre-commit hook configuration</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

.pre-commit-config.yaml

<ul><li>Removed <code>pretty-format-ini</code> hook entry<br> <li> Removed <code>pretty-format-toml</code> hook entry</ul>

</details>

  </td>
  <td><a href="https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/chore/pre-commit-cleanup/.pre-commit-config.yaml">+0/-8</a>&nbsp; &nbsp; &nbsp; </td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Reviewed-on: #61
2026-01-04 23:47:59 +01:00
c05341c0a7 Enable minification for build artifact (#60)
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m29s
Test / Run Tests (push) Successful in 6m9s
### **PR Type**
Enhancement

___

### **Description**
- Enable minification in build script.

- Produce minified `dist/index.js` bundle.

___

<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Configuration changes</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>package.json</strong><dd><code>Add minification flag to build script</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

package.json

- Added `-m` flag to build script.

</details>

  </td>
  <td><a href="https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/build/minify/package.json">+1/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Build artifact</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>index.js</strong><dd><code>Provide minified distribution bundle</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

dist/index.js

- Updated output to minified bundle.

</details>

  </td>
  <td><a href="https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/build/minify/dist/index.js">+5/-51912</a></td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Reviewed-on: #60
2026-01-04 07:17:33 +01:00
6a098d425e Enable minification for build artifact (#60)
### **PR Type**
Enhancement

___

### **Description**
- Enable minification in build script.

- Produce minified `dist/index.js` bundle.

___

<details> <summary><h3> File Walkthrough</h3></summary>

<table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Configuration changes</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>package.json</strong><dd><code>Add minification flag to build script</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

package.json

- Added `-m` flag to build script.

</details>

  </td>
  <td><a href="https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/build/minify/package.json">+1/-1</a>&nbsp; &nbsp; &nbsp; </td>

</tr>
</table></td></tr><tr><td><strong>Build artifact</strong></td><td><table>
<tr>
  <td>
    <details>
      <summary><strong>index.js</strong><dd><code>Provide minified distribution bundle</code>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dd></summary>
<hr>

dist/index.js

- Updated output to minified bundle.

</details>

  </td>
  <td><a href="https://git.horstenkamp.eu/Screeps/screeps-deploy-action/src/branch/build/minify/dist/index.js">+5/-51912</a></td>

</tr>
</table></td></tr></tr></tbody></table>

</details>

___

Reviewed-on: #60
2026-01-04 07:17:05 +01:00
4a77ba188a chore(deps): update dependency node to v24 (#59)
All checks were successful
Lint / pre-commit Linting (push) Successful in 2m38s
Test / Run Tests (push) Successful in 3m24s
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2026-01-04 07:05:42 +01:00
6c7a0961a7 chore(deps): update actions/setup-node action to v6 (#58)
Some checks failed
Lint / pre-commit Linting (push) Has been cancelled
Test / Run Tests (push) Has been cancelled
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2026-01-04 07:05:31 +01:00
3ff19001a7 chore: Add a unit testing framework (#49)
Some checks are pending
Lint / pre-commit Linting (push) Waiting to run
Test / Run Tests (push) Successful in 1m12s
Add vitest as a unit testing framework

Reviewed-on: #49
2026-01-04 07:02:20 +01:00
a14206d32c chore: enforce linux line endings (#57)
All checks were successful
Lint / pre-commit Linting (push) Successful in 54s
Add .gitattributes and .editorconfig to enforce LF line endings. Update devcontainer settings.

Reviewed-on: #57
2026-01-03 21:57:34 +01:00
8e305f9126 fix(deps): update dependency glob to v13 (#40)
All checks were successful
Lint / pre-commit Linting (push) Successful in 45s
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2025-12-31 19:12:17 +01:00
a7552f74fa fix(deps): update dependency @actions/core to v2 (#41)
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m3s
Co-authored-by: Renovate Bot <renovate@horstenkamp.eu>
Co-committed-by: Renovate Bot <renovate@horstenkamp.eu>
2025-12-31 19:05:31 +01:00
3f19a64809 fix: pre-commit hooks should now be installable in dev containers (#56)
All checks were successful
Lint / pre-commit Linting (push) Successful in 51s
Reviewed-on: #56
2025-12-31 18:55:42 +01:00
16 changed files with 3079 additions and 57257 deletions

View File

@@ -20,7 +20,8 @@
],
"settings": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
"editor.defaultFormatter": "esbenp.prettier-vscode",
"files.eol": "\n"
}
}
},

View File

@@ -5,7 +5,7 @@ git config --global --add safe.directory $(pwd)
# In your setup.sh or postCreateCommand
sudo chown -R node:node /home/node/.cache/
sudo chown -R node:node /workspaces/screeps-deploy-action/.git/hooks
# 2. Re-connect Git Hooks
pre-commit install
pre-commit install-hooks

8
.editorconfig Normal file
View File

@@ -0,0 +1,8 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 2

1
.gitattributes vendored Normal file
View File

@@ -0,0 +1 @@
* text=auto eol=lf

View File

@@ -0,0 +1,19 @@
name: Test
on:
push:
workflow_dispatch:
jobs:
test:
name: Run Tests
runs-on: pi
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
- run: npm install
shell: bash
- run: npm test
shell: bash

1078
.gitignore vendored

File diff suppressed because it is too large Load Diff

View File

@@ -5,28 +5,20 @@ repos:
hooks:
- id: check-yaml
- id: check-json
- id: check-toml
- id: check-xml
- id: check-added-large-files
args: [--enforce-all]
exclude: ^dist/index\.js$
- id: name-tests-test
- id: detect-private-key
- id: check-case-conflict
- id: check-symlinks
- id: check-docstring-first
- id: pretty-format-json
args: [--autofix, --no-sort-keys, --no-ensure-ascii]
- id: check-merge-conflict
- id: no-commit-to-branch
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.15.0
rev: v2.16.0
hooks:
- id: pretty-format-ini
args: [--autofix]
- id: pretty-format-toml
args: [--autofix]
- id: pretty-format-yaml
args: [--autofix]

13
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,13 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "test",
"group": "test",
"problemMatcher": [],
"label": "npm: test",
"detail": "jest"
}
]
}

View File

@@ -1,79 +1,33 @@
# Gemini Code Assistant Guide: `screeps-deploy-action`
# Gemini Actions
This document provides a guide for Large Language Models (LLMs) and developers on understanding and interacting with the `screeps-deploy-action` project.
This repository is maintained by Gemini.
## Project Overview
## Development Guidelines
`screeps-deploy-action` is a GitHub Action designed to automate the deployment of JavaScript code to the online programming game Screeps. This project is aimed at supporting both GitHub and Gitea workflows, allowing developers to push their code from a Git repository directly to either the official `screeps.com` server or a private server. It utilizes **Gitea Workflows** (located in `.gitea/workflows`), which are largely compatible with GitHub Actions with minor syntax changes, for its continuous integration and deployment needs.
* **Test-Driven Development (TDD):** Wherever possible, Test-Driven Development principles should be followed. Write tests before writing the code they are intended to validate.
* **Pre-commit Hooks:** Ensure that `pre-commit` hooks are installed and active before making any commits. This can be done by running `pre-commit install` in your local repository.
The action's core logic is in `index.js`. It uses the `screeps-api` library to communicate with the Screeps server. The action is configured via a workflow file (e.g., `.github/workflows/main.yml`) using inputs defined in `action.yaml`.
## Repository Comparison
### Key Files
* On request, this repository should be compared against the rules and guidelines specified in the `README.md` of the reference repository: `https://git.horstenkamp.eu/Philipp/template-git`.
- **`action.yaml`**: The manifest file for the GitHub Action. It defines the inputs, outputs, and execution environment for the action.
- **`index.js`**: The main entry point for the action. It contains the core logic for reading files, connecting to the Screeps API, and uploading the code.
- **`package.json`**: Defines the project's metadata and dependencies. The key dependency is `screeps-api`.
- **`README.md`**: Provides user-facing documentation, including setup and usage examples.
## Testing
## Core Functionality
This project uses [Vitest](https://vitest.dev/) for testing. The tests are located in the `__tests__` directory.
The action performs the following steps:
To run the tests locally, use the following command:
1. **Reads Inputs**: It reads the configuration provided by the user in their workflow file. This includes server connection details, authentication credentials, and file paths.
2. **Authentication**: It authenticates with the Screeps server using either a token or a username/password.
3. **File Processing**:
* It reads all `.js` files from the repository matching the provided `pattern`.
* It can optionally perform placeholder replacements (e.g., `{{gitHash}}`, `{{deployTime}}`) in a specified file (`replace_file`) before deployment.
4. **Code Deployment**: It uploads the processed files to the specified `branch` on the Screeps server.
## Usage
To use this action, a developer would create a `.yml` file in their `.github/workflows` directory.
**Example Workflow:**
```yaml
name: Deploy to Screeps
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Deploy to screeps.com
uses: ./
with:
token: ${{ secrets.SCREEPS_TOKEN }}
branch: 'default'
pattern: '*.js'
```bash
npm test
```
### Configuration Inputs
### Testing Pipeline
The action is configured using the `with` key in the workflow step. The available inputs are defined in `action.yaml`:
The tests are automatically run on every push and workflow dispatch using a Gitea workflow. The workflow is defined in `.gitea/workflows/test.yaml`. All testing for this repository is done via Gitea workflows, not GitHub workflows.
- **`token`**: (Required) The authentication token for the Screeps API. It is recommended to store this as a secret.
- **`protocol`**: The server protocol (`http` or `https`). Defaults to `https`.
- **`hostname`**: The server hostname. Defaults to `screeps.com`.
- **`port`**: The server port. Defaults to `443`.
- **`path`**: The server path. Defaults to `/`.
- **`username`**: The Screeps username (used if `token` is not provided).
- **`password`**: The Screeps password (used if `token` is not provided).
- **`branch`**: The in-game branch to deploy the code to. Defaults to `default`.
- **`pattern`**: A glob pattern for the files to deploy. Defaults to `*.js`.
- **`replace_file`**: Path to a file where placeholders like `{{gitHash}}` and `{{deployTime}}` should be replaced.
- **`source_map_path`**: Path to a `main.js.map` file for Source Map support.
The Gitea workflow does the following:
## Modifying the Code
When asked to modify the action's behavior, the primary file to edit will almost always be `index.js`.
- For changes to the action's inputs or outputs, `action.yaml` must also be updated.
- The core deployment logic is within the `postCode` function in `index.js`.
- File reading is handled by `readFilesIntoDict`.
- Placeholder replacement is handled by `readReplaceAndWriteFiles`.
Before making changes, always review the existing code and the `screeps-api` documentation to understand how it interacts with the Screeps server. After making changes, ensure that any associated tests are updated or added.
1. Checks out the code.
2. Sets up Node.js.
3. Installs the dependencies using `npm install`.
4. Runs the tests using `npm test`.

199
__tests__/index.test.js Normal file
View File

@@ -0,0 +1,199 @@
const {
validateAuthentication,
replacePlaceholders,
readReplaceAndWriteFiles,
readFilesIntoDict,
} = require("../index");
const fs = require("fs");
const path = require("path");
const os = require("os");
const { glob } = require("glob");
describe("validateAuthentication", () => {
it("should return null when only token is provided", () => {
expect(validateAuthentication("token", null, null)).toBeNull();
});
it("should return an error message when token and username are provided", () => {
expect(validateAuthentication("token", "user", null)).toBe(
"Token is defined along with username and/or password.",
);
});
it("should return an error message when token and password are provided", () => {
expect(validateAuthentication("token", null, "pass")).toBe(
"Token is defined along with username and/or password.",
);
});
it("should return an error message when token, username, and password are provided", () => {
expect(validateAuthentication("token", "user", "pass")).toBe(
"Token is defined along with username and/or password.",
);
});
it("should return an error message when no credentials are provided", () => {
expect(validateAuthentication(null, null, null)).toBe(
"Neither token nor password and username are defined.",
);
});
it("should return an error message when only username is provided", () => {
expect(validateAuthentication(null, "user", null)).toBe(
"Username is defined but no password is provided.",
);
});
it("should return an error message when only password is provided", () => {
expect(validateAuthentication(null, null, "pass")).toBe(
"Password is defined but no username is provided.",
);
});
it("should return null when username and password are provided", () => {
expect(validateAuthentication(null, "user", "pass")).toBeNull();
});
});
describe("replacePlaceholders", () => {
beforeEach(() => {
process.env.GITHUB_SHA = "test-sha";
process.env.GITHUB_REF = "test-ref";
});
it("should replace all placeholders", () => {
const content =
"hash: {{gitHash}}, ref: {{gitRef}}, time: {{deployTime}}, host: {{hostname}}";
const replacedContent = replacePlaceholders(content, "test-host");
expect(replacedContent).toMatch(/hash: test-sha/);
expect(replacedContent).toMatch(/ref: test-ref/);
expect(replacedContent).toMatch(/time: .*/);
expect(replacedContent).toMatch(/host: test-host/);
});
});
describe("readReplaceAndWriteFiles", () => {
let tempDir;
beforeEach(async () => {
tempDir = await fs.promises.mkdtemp(
path.join(os.tmpdir(), "replace-test-"),
);
process.env.GITHUB_SHA = "test-sha";
process.env.GITHUB_REF = "test-ref";
});
afterEach(async () => {
if (tempDir) {
await fs.promises.rm(tempDir, { recursive: true, force: true });
}
});
it("should find files and replace placeholders", async () => {
const fileName = "test.js";
const filePath = path.join(tempDir, fileName);
const content = "hash: {{gitHash}}, ref: {{gitRef}}, host: {{hostname}}";
await fs.promises.writeFile(filePath, content);
const pattern = "*.js";
// We pass tempDir as the prefix so glob searches inside it
await readReplaceAndWriteFiles(pattern, tempDir, "test-host");
const updatedContent = await fs.promises.readFile(filePath, "utf8");
expect(updatedContent).toContain("hash: test-sha");
expect(updatedContent).toContain("ref: test-ref");
expect(updatedContent).toContain("host: test-host");
});
});
describe("readFilesIntoDict", () => {
let tempDir;
beforeEach(async () => {
tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "read-test-"));
await fs.promises.mkdir(path.join(tempDir, "subdir"), { recursive: true });
});
afterEach(async () => {
if (tempDir) {
await fs.promises.rm(tempDir, { recursive: true, force: true });
}
});
it("should read files into a dictionary with correct keys", async () => {
const file1 = "file1.js";
const content1 = "content1";
await fs.promises.writeFile(path.join(tempDir, file1), content1);
const file2 = "subdir/file2.js";
const content2 = "content2";
await fs.promises.writeFile(path.join(tempDir, file2), content2);
const pattern = "**/*.js";
const result = await readFilesIntoDict(pattern, tempDir);
// Keys should be relative paths without extension
// On Windows, the path separator might differ, so we should be careful or just check contents
// Based on implementation:
// key = key.slice(prefix.length);
// key = path.basename(key, path.extname(key)); // Drop the file suffix -> THIS IS BUGGY for subdirs?
// Let's check the implementation of readFilesIntoDict again in index.js
// It does: key = path.basename(key, path.extname(key));
// This removes the directory part! So subdir/file2.js becomes file2
expect(result["file1"]).toBe(content1);
expect(result["file2"]).toBe(content2);
});
});
describe("glob functionality", () => {
let tempDir;
beforeEach(async () => {
tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "glob-test-"));
await fs.promises.mkdir(path.join(tempDir, "lib"), { recursive: true });
await fs.promises.mkdir(path.join(tempDir, "deep", "folder"), {
recursive: true,
});
await fs.promises.writeFile(path.join(tempDir, "main.js"), "content");
await fs.promises.writeFile(path.join(tempDir, "utils.js"), "content");
await fs.promises.writeFile(
path.join(tempDir, "lib", "helper.js"),
"content",
);
await fs.promises.writeFile(
path.join(tempDir, "lib", "data.json"),
"content",
);
await fs.promises.writeFile(
path.join(tempDir, "deep", "folder", "main.js"),
"content",
);
});
afterEach(async () => {
if (tempDir) {
await fs.promises.rm(tempDir, { recursive: true, force: true });
}
});
it("should find all javascript files in the directory", async () => {
// Ensure pattern uses forward slashes for glob
const pattern = path.join(tempDir, "**", "*.js").split(path.sep).join("/");
const files = await glob(pattern);
// Normalize file paths to system separator (backslashes on Windows)
const normalizedFiles = files.map((f) => path.normalize(f));
const expectedFiles = [
path.join(tempDir, "deep", "folder", "main.js"),
path.join(tempDir, "lib", "helper.js"),
path.join(tempDir, "main.js"),
path.join(tempDir, "utils.js"),
].sort();
expect(normalizedFiles.sort()).toEqual(expectedFiles);
});
});

56822
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -174,4 +174,15 @@ async function postCode() {
});
}
}
postCode();
if (require.main === module) {
postCode();
}
module.exports = {
validateAuthentication,
replacePlaceholders,
postCode,
readReplaceAndWriteFiles,
readFilesIntoDict,
};

View File

@@ -1 +0,0 @@
{"8b776b0173f34b8e7d376c35dbd515022335073f":{"files":{"index.js":["ZVPfPRYPn3JntuOZs2WuhZTA+Pg=",true]},"modified":1766795348715}}

View File

@@ -1 +0,0 @@
{"b03bf7d94b68d6efff8cb09552f1880aa62ea1f0":{"files":{"index.js":["Y4JfDP5X7/wr1mlYLpop4yMG/vA=",true],"dist/index.js":["0uW46uAJG8qyUnSoKEh8QWxHJ4A=",true]},"modified":1766842302598}}

2071
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -5,14 +5,17 @@
"main": "index.js",
"scripts": {
"start": "node index.js",
"build": "ncc build index.js -o dist --external utf-8-validate --external bufferutil"
"test": "vitest run --globals --coverage",
"build": "ncc build index.js -o dist -m --external utf-8-validate --external bufferutil"
},
"dependencies": {
"@actions/core": "^1.11.1",
"glob": "^11.0.1",
"@actions/core": "^2.0.0",
"glob": "^13.0.0",
"screeps-api": "^1.7.2"
},
"devDependencies": {
"@vercel/ncc": "^0.38.4"
"@vercel/ncc": "^0.38.4",
"@vitest/coverage-v8": "^4.0.16",
"vitest": "^4.0.16"
}
}