-
Notifications
You must be signed in to change notification settings - Fork 0
Add comprehensive GitHub Copilot instructions, merge main branch updates, and bump version to 4.0.2 #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add comprehensive GitHub Copilot instructions, merge main branch updates, and bump version to 4.0.2 #30
Changes from all commits
dfce2ac
407a681
e6436d1
14bf4a5
b284e3a
51ad559
4127941
a62a1f6
636e340
17f4042
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,228 @@ | ||||||||
| # Hash Library | ||||||||
|
|
||||||||
| Hash is a small TypeScript utility library for Check Digit services that creates UUIDs derived from hashes generated from given values. The library uses Node.js experimental features and requires specific setup. | ||||||||
|
|
||||||||
| Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. | ||||||||
|
|
||||||||
| ## Critical Requirements | ||||||||
|
|
||||||||
| **REQUIRED NODE.JS VERSION**: This project requires Node.js 22.11 or higher for the `--experimental-strip-types` feature. The CI pipeline runs on Node.js 22.x and 24.x. | ||||||||
|
|
||||||||
| **MANDATORY MULTI-RUNTIME TESTING**: All validation and testing (manual, CI, and distribution) must be performed with both Node.js 22.x and Node.js 24.x runtimes to ensure compatibility and reliability across supported versions. | ||||||||
|
|
||||||||
| ## Working Effectively | ||||||||
|
|
||||||||
| ### Bootstrap and Setup | ||||||||
|
|
||||||||
| - **Install Node.js 22.12.0 or later**: | ||||||||
| ```bash | ||||||||
| curl -fsSL https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.xz -o node.tar.xz | ||||||||
| tar -xJf node.tar.xz | ||||||||
| export PATH=$PWD/node-v22.12.0-linux-x64/bin:$PATH | ||||||||
| node --version # Should show v22.12.0 or higher | ||||||||
| ``` | ||||||||
| - **Install Node.js 22.12.0 or later**: | ||||||||
|
|
||||||||
| > **Note:** The following instructions are for Linux x64. For other platforms (Windows, macOS, ARM), please refer to the [official Node.js installation guide](https://nodejs.org/en/download/) for platform-specific instructions. | ||||||||
|
|
||||||||
| **Linux x64 example:** | ||||||||
|
|
||||||||
| ```bash | ||||||||
| curl -fsSL https://nodejs.org/dist/v22.12.0/node-v22.12.0-linux-x64.tar.xz -o node.tar.xz | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should tell it to test with both 22 and 24 somewhere explicitly |
||||||||
| tar -xJf node.tar.xz | ||||||||
| export PATH=$PWD/node-v22.12.0-linux-x64/bin:$PATH | ||||||||
| node --version # Should show v22.12.0 or higher | ||||||||
| ``` | ||||||||
|
|
||||||||
| - **Install dependencies**: | ||||||||
| ```bash | ||||||||
| npm ci --ignore-scripts | ||||||||
| ``` | ||||||||
| Takes ~7 seconds. Clean install without running scripts for security. | ||||||||
|
|
||||||||
| ### Build and Test Commands | ||||||||
|
|
||||||||
| - **Type check compilation**: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run ci:compile | ||||||||
| ``` | ||||||||
|
|
||||||||
| Takes ~3 seconds. Runs `tsc --noEmit` for type checking only. | ||||||||
|
|
||||||||
| - **Run tests**: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run ci:test | ||||||||
| ``` | ||||||||
|
|
||||||||
| Takes <1 second. Runs 5 tests using Node.js built-in test runner with experimental TypeScript support. | ||||||||
|
|
||||||||
| - **Run tests with coverage**: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run coverage | ||||||||
| ``` | ||||||||
|
|
||||||||
| Takes <1 second. NEVER CANCEL - Set timeout to 60+ seconds just in case. | ||||||||
|
|
||||||||
| - **Lint source code**: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run ci:lint | ||||||||
| ``` | ||||||||
|
|
||||||||
| Takes ~4-6 seconds. IMPORTANT: Ensure no extra files are in repo root (like downloaded Node.js) as ESLint scans everything. | ||||||||
|
|
||||||||
| - **Check code style**: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run ci:style | ||||||||
| ``` | ||||||||
|
|
||||||||
| Takes ~7 seconds. Runs prettier to check formatting. | ||||||||
|
|
||||||||
| - **Build distribution packages**: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run prepublishOnly | ||||||||
| ``` | ||||||||
|
|
||||||||
| Takes ~4 seconds. NEVER CANCEL - Set timeout to 120+ seconds. Creates `dist-types/` and `dist-mjs/` directories. | ||||||||
|
|
||||||||
| - **Run all CI checks**: | ||||||||
| ```bash | ||||||||
| npm test | ||||||||
| ``` | ||||||||
| Takes ~15 seconds total. NEVER CANCEL - Set timeout to 180+ seconds. Runs compile + test + lint + style checks. | ||||||||
|
|
||||||||
| ## Validation Scenarios | ||||||||
|
|
||||||||
| ### Manual Testing | ||||||||
|
|
||||||||
| Always test the hash function after making changes: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| node --experimental-strip-types -e " | ||||||||
| import hash from './src/hash.ts'; | ||||||||
| const result1 = hash('test string'); | ||||||||
| const result2 = hash('test string'); | ||||||||
| const result3 = hash('different string'); | ||||||||
| console.log('Consistent results:', result1 === result2); | ||||||||
| console.log('Different inputs differ:', result1 !== result3); | ||||||||
| console.log('Result format:', result1); | ||||||||
| " | ||||||||
| ``` | ||||||||
|
|
||||||||
| ### Built Distribution Testing | ||||||||
|
|
||||||||
| Always verify the built distribution works: | ||||||||
|
|
||||||||
| ```bash | ||||||||
| npm run prepublishOnly | ||||||||
| node -e " | ||||||||
| import hash from './dist-mjs/index.mjs'; | ||||||||
| console.log('Built dist result:', hash('test')); | ||||||||
| " | ||||||||
| ``` | ||||||||
|
|
||||||||
| ### Pre-commit Validation | ||||||||
|
|
||||||||
| Always run these commands before committing changes or the CI will fail: | ||||||||
|
|
||||||||
| 1. `npm run ci:compile` - Type checking | ||||||||
| 2. `npm run ci:test` - Unit tests | ||||||||
| 3. `npm run ci:lint` - Linting (ensure clean repo directory) | ||||||||
| 4. `npm run ci:style` - Code formatting | ||||||||
|
|
||||||||
| ## Key Architecture | ||||||||
|
|
||||||||
| ### Source Structure | ||||||||
|
|
||||||||
| ```text | ||||||||
| src/ | ||||||||
| ├── index.ts # Main export file | ||||||||
| ├── hash.ts # Core hash function implementation | ||||||||
| ├── hash.spec.ts # Hash function tests | ||||||||
| ├── uuid-v5.ts # UUID v5 implementation | ||||||||
| └── uuid-v5.spec.ts # UUID v5 tests | ||||||||
| ``` | ||||||||
|
|
||||||||
| ### Core Functionality | ||||||||
|
|
||||||||
| - `hash(value: string): string` - Generates UUID from SHA-512 hash of input | ||||||||
| - Uses custom UUID v5 implementation with namespace `f25d4515-fea7-44c7-8baf-f3ca50865e66` | ||||||||
|
||||||||
| - Uses custom UUID v5 implementation with namespace `f25d4515-fea7-44c7-8baf-f3ca50865e66` | |
| - Uses custom UUID v5 implementation with namespace `f25d4515-fea7-44c7-8baf-f3ca50865e66` | |
| - This namespace UUID is project-specific and was randomly generated for this library to ensure deterministic UUID generation. It should not be reused across unrelated projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The installation instructions assume a Linux x64 environment but don't provide alternatives for other operating systems (Windows, macOS, ARM architectures). Consider adding platform-specific installation commands or referencing the official Node.js installation guide.
macOS example (using Homebrew):
brew install node@22 node --version # Should show v22.12.0 or higherWindows example (using Chocolatey):
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
applied