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
12 changed files with 338 additions and 57419 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

@@ -10,9 +10,9 @@ jobs:
runs-on: pi
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v4
- uses: actions/setup-node@v6
with:
node-version: '22'
node-version: '24'
- run: npm install
shell: bash
- run: npm test

2
.gitignore vendored
View File

@@ -1075,4 +1075,6 @@ FodyWeavers.xsd
*.vsix
/node_modules/
/node_modules/.cache/
/coverage/
!/dist/

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]

View File

@@ -1,4 +1,9 @@
const { validateAuthentication, replacePlaceholders } = require("../index");
const {
validateAuthentication,
replacePlaceholders,
readReplaceAndWriteFiles,
readFilesIntoDict,
} = require("../index");
const fs = require("fs");
const path = require("path");
const os = require("os");
@@ -67,6 +72,83 @@ describe("replacePlaceholders", () => {
});
});
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;

56802
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

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

807
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,11 +6,11 @@
"scripts": {
"start": "node index.js",
"test": "vitest run --globals --coverage",
"build": "ncc build index.js -o dist --external utf-8-validate --external bufferutil"
"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": {