Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .agents/skills/verify-source-changes/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ description: >-
`src/index.ts`.
5. Inspect changelog and generated changes. Keep only updates caused by the
source change.
6. Run the relevant focused Jest test, then:
6. Run the relevant focused Vitest test, then:
- `pnpm exec biome check .`
- `pnpm run test:ci`
- `pnpm run build`
Expand Down
65 changes: 58 additions & 7 deletions .github/workflows/publish-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,78 @@ name: Publish Package to npmjs
on:
release:
types: [published]
permissions:
contents: read
jobs:
build:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- uses: pnpm/action-setup@v6
name: Install pnpm
with:
version: 11.2.2

- name: Setup Node
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version-file: .nvmrc
cache: pnpm
cache-dependency-path: pnpm-lock.yaml
package-manager-cache: false

- name: Install dependencies
run: pnpm install --frozen-lockfile

- run: npm publish
- name: Validate
run: |
pnpm exec biome check .
pnpm run typecheck
pnpm test

- name: Verify release tag
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: |
PACKAGE_VERSION=$(node -p "require('./package.json').version")
test "$RELEASE_TAG" = "v$PACKAGE_VERSION"

- name: Pack
run: |
mkdir -p package-artifact
pnpm pack --pack-destination package-artifact

- name: Upload package
uses: actions/upload-artifact@v7
with:
name: npm-package
path: package-artifact/*.tgz
if-no-files-found: error
retention-days: 1

publish:
needs: validate
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
package-manager-cache: false

- name: Verify npm version
run: |
NPM_VERSION=$(npm --version)
node -e 'const [major, minor] = process.argv[1].split(".").map(Number); if (major < 11 || (major === 11 && minor < 5)) process.exit(1)' "$NPM_VERSION"

- name: Download package
uses: actions/download-artifact@v8
with:
name: npm-package
path: package-artifact

- name: Publish
run: npm publish package-artifact/*.tgz --access public
2 changes: 0 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@ coverage/*
docs/*

.babelrc
.eslintignore
.eslintrc.js
.npmignore
webpack.config.js
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@
},
"files.readonlyInclude": {
"**/routeTree.gen.ts": true
},
"files.exclude": {
"**/dist": false
}
}
6 changes: 3 additions & 3 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
`.nvmrc` and pnpm 11.2.2 from `package.json`; do not substitute npm or yarn.
- Install with `pnpm install --frozen-lockfile`. Add dependencies with
`pnpm add -E` so versions remain exact.
- The package builds strict ES2020 TypeScript with tsup into CommonJS, ESM, and
declaration outputs. Tests use Jest with ts-jest; formatting and linting use
- The package builds strict ES2020 TypeScript with esbuild and tsc into CommonJS,
ESM, and declaration outputs. Tests use Vitest; formatting and linting use
Biome. Treat Biome as authoritative over legacy ESLint/Prettier references.

## Source And Generated Files
Expand All @@ -29,7 +29,7 @@

- Match existing structure and reuse existing types and helpers. Keep changes
minimal, localized, and limited to the requested behavior.
- Add or update the smallest focused colocated Jest tests for behavior changes.
- Add or update the smallest focused colocated Vitest tests for behavior changes.
- After adding, updating, moving, or removing source code, use the project
`$verify-source-changes` skill to determine the next SemVer version, update
`docs-md/changelog.md`, regenerate documentation and exports, then inspect
Expand Down
36 changes: 32 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ Read more about the methods available [here](https://iamdevlinph.github.io/commo
- Coverage using [Istanbul](https://github.com/gotwarlost/istanbul) with [nyc](https://github.com/istanbuljs/nyc) and report by [Codecov](https://github.com/codecov/codecov-node)
- Create the bundle using [webpack](https://github.com/webpack/webpack)
- Run tests using [Mocha](https://github.com/mochajs/mocha) and [chai](https://github.com/chaijs/chai)
- Lint stuff using [ESLint](https://github.com/eslint/eslint)
- Build status by [Travis](https://github.com/travis-ci/travis-ci)
- Precommit using [lint-staged](https://github.com/okonet/lint-staged) and [husky](https://github.com/typicode/husky)
- Provides TypeScript type definitions -->
Expand Down Expand Up @@ -113,9 +112,39 @@ src/

# Publishing

### Publish to NPM
Maintainers should validate a release locally before publishing:

To publish version, just create a relase tag and a github workflow will automatically handle the publishing to npm.
```sh
pnpm run typecheck
pnpm test
pnpm run pack:check
```

Configure **Settings → Trusted Publisher** for this package on npmjs.com:

| Setting | Value |
| --- | --- |
| Provider | GitHub Actions |
| Organization / user | `iamdevlinph` |
| Repository | `common-utils-pkg` |
| Workflow filename | `publish-package.yml` |
| Environment | *(blank)* |
| Allowed action | `npm publish` |

Enter only the workflow filename, not its full path. Trusted Publishing uses
OIDC; do not add `NPM_TOKEN`, `NODE_AUTH_TOKEN`, or a package PAT. It requires a
GitHub-hosted runner, Node 22.14 or newer, and npm 11.5.1 or newer. The workflow
uses Node 24 (from `.nvmrc`), verifies npm 11.5.1 or newer, and uses pnpm 11.2.2.

To release, update the version in `package.json`, create and push the matching
tag `v<version>`, then publish a GitHub Release for that tag. The workflow
requires the release tag to equal `v` plus the package version.

If publishing fails only because of external configuration, rerun the failed
job. If code or workflow changes are required, publish a new version unless the
failed tag was never released and is intentionally recreated. After the first
successful OIDC publish, delete the obsolete GitHub `NPM_TOKEN` secret and set
npm publishing access to require two-factor authentication and disallow tokens.

### Publish doc updates

Expand All @@ -132,7 +161,6 @@ Run by `npm run <script>`
* `docu:serve` - Serve the documentation page. Open at `http://localhost:8080/`.
* `docu` - Generated a `.json` documentation file that will be used by the `docs.html` page.
* `lint:install` - Install precommit related tools. It sometimes doesn't install properly.
* `lint` - Runs the ESLint linter on the `src/` folder.
* `precommit` - The precommit hook which runs `lint-staged` to lint staged files on commit.
* `prepare` - Runs `build` before publishing a new version of the package.
* `test:watch` - Re-run tests on file changes.
Expand Down
2 changes: 0 additions & 2 deletions README_NEW.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
Migrating to TypeScript

[x] Install basic deps for now
[x] Configure eslint
[x] Configure husky
[x] Configure lint-staged
[x] Configure prettier
[x] Configure `tsconfig.json`
Configure tests
Configure coverage
1 change: 0 additions & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"**",
"!!**/dist",
"!lint-staged.config.js",
"!jest.config.js",
"!babel.config.js"
]
},
Expand Down
2 changes: 1 addition & 1 deletion docs-md/api/browserDetect.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ Returns **[string][1]** of browser name.
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String


* Source: [browser-detect.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/browser-detect/browser-detect.ts#L17-L52)
* Source: [browser-detect.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/browser-detect/browser-detect.ts#L16-L51)
2 changes: 1 addition & 1 deletion docs-md/api/colorBrightness.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ Returns **[string][1]** of manipulated HEX color.
[2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number


* Source: [color-brightness.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/color-brightness/color-brightness.ts#L23-L52)
* Source: [color-brightness.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/color-brightness/color-brightness.ts#L22-L51)
2 changes: 1 addition & 1 deletion docs-md/api/slugify.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ Returns **[string][1]** slug version of the string.
[1]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String


* Source: [slugify.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/slugify/slugify.ts#L21-L39)
* Source: [slugify.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/slugify/slugify.ts#L21-L37)
5 changes: 5 additions & 0 deletions docs-md/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@ id: changelog

# Changelog


##### 4.4.1

- Add baseline coverage for documentation/index generation and dependency
security remediation
- Keep the dev-only `brace-expansion` advisory open until its unpublished
`5.0.8` fix is available; production dependencies audit clean
- Remove obsolete ESLint suppressions and unused packages
- Configure npm Trusted Publishing with OIDC and strict release tag validation
- Update TypeScript to 7.0.1-rc, align testing/builds with Vitest and esbuild,
and preserve bundled declaration outputs

##### 4.4.0

Expand Down
8 changes: 0 additions & 8 deletions jest.config.js

This file was deleted.

40 changes: 21 additions & 19 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
},
"repository": {
"type": "git",
"url": "git+ssh://git@github.com/iamdevlinph/common-utils-pkg.git"
"url": "git+https://github.com/iamdevlinph/common-utils-pkg.git"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
"access": "public"
},
"license": "ISC",
"author": "iamdevlinph",
Expand All @@ -18,18 +22,25 @@
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.js"
"import": {
"types": "./dist/index.d.mts",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
}
}
},
"files": ["dist/", "!dist/**/*.test.*", "README.md", "LICENSE"],
"scripts": {
"dev": "pnpm docusaurus:start",
"build": "rm -rf dist/; npm run generate-index; tsup",
"build": "pnpm run generate-index && node scripts/build.mjs",
"typecheck": "pnpm exec tsc -p tsconfig.json --noEmit",
"test": "pnpm run build && pnpm run test:ci",
"prepublishOnly": "pnpm run build",
"test:ci": "jest --no-cache",
"test:clear": "jest --clearCache",
"test:ci": "vitest run --globals",
"pack:check": "pnpm pack --dry-run",
"docusaurus": "docusaurus",
"docusaurus:generate": "node scripts/md-generate.mjs && pnpm run generate-index",
"docusaurus:start": "docusaurus start",
Expand All @@ -56,29 +67,20 @@
"devDependencies": {
"@biomejs/biome": "2.5.0",
"@docusaurus/core": "3.10.2",
"@docusaurus/module-type-aliases": "3.10.2",
"@docusaurus/plugin-google-gtag": "3.10.2",
"@docusaurus/preset-classic": "3.10.2",
"@docusaurus/tsconfig": "3.10.2",
"@docusaurus/types": "3.10.2",
"@mdx-js/react": "3.1.1",
"@types/jest": "30.0.0",
"@types/node": "25.6.0",
"clsx": "2.1.1",
"documentation": "13.2.5",
"http-server": "14.1.1",
"esbuild": "0.25.0",
"husky": "9.1.7",
"jest": "30.4.2",
"lint-staged": "16.4.0",
"mock-local-storage": "1.1.24",
"prettier": "3.8.3",
"prism-react-renderer": "2.4.1",
"react": "19.2.5",
"react-dom": "19.2.5",
"shell-quote": "1.9.0",
"ts-jest": "29.4.11",
"tsup": "8.3.5",
"typescript": "6.0.2"
"typescript": "7.0.1-rc",
"vitest": "4.1.10"
},
"browserslist": {
"production": [">0.5%", "not dead", "not op_mini all"],
Expand Down
Loading
Loading