Skip to content

Commit 72bec48

Browse files
committed
feat: implement comprehensive project improvements
- Add caching mechanism for API calls with 5-minute TTL to optimize repeated requests - Enhance error handling with detailed messages for GraphQL, network, and HTTP errors - Improve type safety with strict null checks, input validation, and response validation - Refactor code by extracting utility functions (groupBy, searchModeToStreams, sanitizeVersion, validateFilterOptions) to utils.ts - Optimize performance with parallel async processing using Promise.all - Strengthen security with input sanitization for versions and regex validation for filters - Fix lint errors by moving imports to deno.json - Resolve constructor inconsistencies by making stream and entitlements required parameters - Update CI/CD workflows to include linting, formatting, and testing steps - Standardize Node.js version to 18 across workflows and documentation - Dynamically read version from deno.json in build scripts - Update graphql-request dependency to 6.1.0 for compatibility BREAKING CHANGE: Node.js minimum version requirement increased from 16 to 18 BREAKING CHANGE: UnityChangeset constructor now requires 'stream' and 'entitlements' parameters as mandatory BREAKING CHANGE: Input validation for version strings and filter options may reject previously accepted invalid inputs
1 parent a0752f5 commit 72bec48

File tree

15 files changed

+349
-111
lines changed

15 files changed

+349
-111
lines changed

.github/workflows/release.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ jobs:
1919

2020
- run: deno task build
2121

22-
- uses: actions/setup-node@v5
23-
with:
24-
node-version: 16
25-
2622
- uses: cycjimmy/semantic-release-action@v5
2723
with:
2824
working_directory: npm

.github/workflows/test.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,14 @@ jobs:
1616
if: ${{ !contains(github.event.head_commit.message, '[skip ci]') && !contains(github.event.head_commit.message, '[ci skip]') }}
1717
runs-on: ubuntu-latest
1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@v5
2020

21-
- uses: asdf-vm/actions/install@v3
21+
- uses: asdf-vm/actions/install@v4
22+
23+
- run: deno lint src/
24+
25+
- run: deno fmt --check src/
26+
27+
- run: deno task test
2228

2329
- run: deno task build

.tool-versions

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
deno 2.0.4
2-
nodejs 16.19.1
1+
nodejs 18.20.8
2+
deno 2.5.2

.vscode/launch.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"program": "${workspaceFolder}/src/cli.ts",
99
"cwd": "${workspaceFolder}",
1010
"env": {},
11-
"runtimeExecutable": "/Users/takashi.sakai/.asdf/shims/deno",
11+
"runtimeExecutable": "deno",
1212
"runtimeArgs": [
1313
"run",
1414
"--unstable",
@@ -27,7 +27,7 @@
2727
"program": "${workspaceFolder}/src/cli.ts",
2828
"cwd": "${workspaceFolder}",
2929
"env": {},
30-
"runtimeExecutable": "/Users/takashi.sakai/.asdf/shims/deno",
30+
"runtimeExecutable": "deno",
3131
"runtimeArgs": [
3232
"run",
3333
"--unstable",
@@ -49,7 +49,7 @@
4949
"program": "${workspaceFolder}/src/cli.ts",
5050
"cwd": "${workspaceFolder}",
5151
"env": {},
52-
"runtimeExecutable": "/Users/takashi.sakai/.asdf/shims/deno",
52+
"runtimeExecutable": "deno",
5353
"runtimeArgs": [
5454
"run",
5555
"--unstable",
@@ -68,7 +68,7 @@
6868
"program": "${workspaceFolder}/src/cli.ts",
6969
"cwd": "${workspaceFolder}",
7070
"env": {},
71-
"runtimeExecutable": "/Users/takashi.sakai/.asdf/shims/deno",
71+
"runtimeExecutable": "deno",
7272
"runtimeArgs": [
7373
"run",
7474
"--unstable",
@@ -87,7 +87,7 @@
8787
"program": "${workspaceFolder}/src/cli.ts",
8888
"cwd": "${workspaceFolder}",
8989
"env": {},
90-
"runtimeExecutable": "/Users/takashi.sakai/.asdf/shims/deno",
90+
"runtimeExecutable": "deno",
9191
"runtimeArgs": [
9292
"run",
9393
"--unstable",

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Get/List Unity editor changeset
1313

1414
## Usage as a node module
1515

16-
Requirement: NodeJs 14 or later
16+
Requirement: NodeJs 18 or later
1717

1818
### Install
1919

@@ -77,7 +77,7 @@ const { getUnityChangeset, scrapeArchivedChangesets, scrapeBetaChangesets } = fr
7777
### Install
7878

7979
```sh
80-
# Requirement: NodeJs 14 or later
80+
# Requirement: NodeJs 18 or later
8181
npm install -g unity-changeset
8282

8383
# Use without installation

build/build_npm.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ await build({
1717
shims: {
1818
deno: true, // for Deno namespace
1919
},
20+
importMap: "./deno.json",
2021
// package.json properties
2122
package: {
2223
name: "unity-changeset",
@@ -32,7 +33,7 @@ await build({
3233
url: "https://github.com/mob-sakai/unity-changeset/issues",
3334
},
3435
engines: {
35-
node: ">=14",
36+
node: ">=18",
3637
},
3738
},
3839
postBuild() {

copilot-instructions.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copilot Instructions for Unity Changeset Project
2+
3+
## Overview
4+
This project is a TypeScript library and CLI tool for retrieving and listing Unity editor changesets. It supports both Deno and Node.js environments, using Deno for development and building npm packages via dnt. The codebase follows Deno's conventions and uses modern TypeScript features.
5+
6+
## Coding Standards
7+
- **Language**: TypeScript with Deno runtime
8+
- **Style**: Follow Deno's linting rules (`deno lint`) and formatting (`deno fmt`)
9+
- **Imports**: Use Deno-style imports from `deno.land` or npm specifiers
10+
- **Error Handling**: Use explicit error handling with try-catch blocks; prefer throwing errors over returning error objects
11+
- **Naming**: Use camelCase for variables/functions, PascalCase for classes/interfaces
12+
- **Async/Await**: Prefer async/await over promises for asynchronous operations
13+
- **Types**: Use strict TypeScript typing; avoid `any` unless necessary
14+
- **Modules**: Keep modules focused and single-responsible; export only what's needed
15+
16+
## Testing
17+
- Use Deno's built-in testing framework (`deno test`)
18+
- Write tests in `.test.ts` files alongside source files
19+
- Use `std/testing/asserts` for assertions
20+
- Cover both unit tests and integration tests where applicable
21+
- Run tests with `deno task test` before committing
22+
23+
## Build and Deployment
24+
- Build npm packages using dnt (Deno to Node Transform)
25+
- Run `deno task build` to generate npm distribution
26+
- Follow semantic versioning for releases
27+
- Use conventional commit messages for automated releases
28+
29+
## Dependencies
30+
- Core: Deno standard library (`std/path`, `std/testing/asserts`)
31+
- CLI: Cliffy for command-line interface
32+
- GraphQL: graphql-request for Unity API interactions
33+
- Build: dnt for npm package generation
34+
35+
## Communication
36+
- **Ask Questions When Needed**: If user requirements are unclear, ask clarifying questions to ensure accurate implementation
37+
- **Think in English**: All internal reasoning and planning should be conducted in English to maintain consistency and clarity
38+
39+
## Best Practices
40+
- Keep code modular and reusable
41+
- Document complex logic with comments
42+
- Ensure cross-platform compatibility (macOS, Windows, Linux)
43+
- Validate inputs and handle edge cases
44+
- Follow security best practices, especially when handling external data

deno.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
{
2+
"imports": {
3+
"dnt": "https://deno.land/x/dnt@0.40.0/mod.ts",
4+
"graphql-request": "npm:graphql-request@6.1.0",
5+
"cliffy/command": "https://deno.land/x/cliffy@v0.25.7/command/command.ts",
6+
"std/path": "https://deno.land/std@0.181.0/path/mod.ts",
7+
"std/testing/asserts": "https://deno.land/std@0.181.0/testing/asserts.ts"
8+
},
29
"tasks": {
310
"run": "deno run -A src/cli.ts",
411
"build": "deno run -A build/build_npm.ts",
512
"test": "deno test -A src/",
613
"lint": "deno lint src/ && deno fmt src/"
714
}
8-
}
15+
}

deno.lock

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// deno-fmt-ignore-file
2-
import { Command } from "https://deno.land/x/cliffy@v0.25.7/command/command.ts";
3-
import { resolve } from "https://deno.land/std@0.181.0/path/mod.ts";
2+
import { Command } from "cliffy/command";
3+
import { resolve } from "std/path";
44
import {
55
getUnityChangeset,
66
listChangesets,

0 commit comments

Comments
 (0)