Skip to content
Open
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 .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pnpm-lock.yaml merge=binary
# Merge the documentation reference tables row by row. Every branch adds one
# function to the same alphabetically ordered table, so a line-based merge
# conflicts whenever two branches land between the same pair of neighbours.
# The driver is registered by scripts/setup-merge-driver.sh, which `npm run
# The driver is registered by scripts/setup-merge-driver.sh, which `pnpm run
# prepare` runs.
#
# The four translated projects carry the same generated tables — same headings,
Expand Down
6 changes: 3 additions & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
- [ ] The PR title follows [Conventional Commits](https://www.conventionalcommits.org/).
- [ ] Every commit is signed off (`git commit -s`) under the
[DCO](https://github.com/bootgs/utils/blob/develop/CONTRIBUTING.md#developer-certificate-of-origin).
- [ ] Tests are added or updated and `npm test` passes.
- [ ] `npm run type:check`, `npm run lint` and `npm run format` pass.
- [ ] The generated documentation is up to date (`npm run docs:generate`, then `npm run docs:check` passes).
- [ ] Tests are added or updated and `pnpm test` passes.
- [ ] `pnpm run type:check`, `pnpm run lint` and `pnpm run format` pass.
- [ ] The generated documentation is up to date (`pnpm run docs:generate`, then `pnpm run docs:check` passes).
- [ ] Public API changes are documented (JSDoc, docs, changelog notes in the commit body).
- [ ] No secrets, credentials or personal data are included.
- [ ] AI-assisted commits carry a `Co-Authored-By:` trailer and I have reviewed every line
Expand Down
26 changes: 15 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,30 @@ jobs:
with:
persist-credentials: false

# Reads the version from `packageManager` in package.json.
- name: setup-pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- name: setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
cache: npm
cache: pnpm

- name: install
run: npm ci
run: pnpm install --frozen-lockfile

- name: type-check
run: npm run type:check
run: pnpm run type:check

- name: lint
run: npm run lint
run: pnpm run lint

- name: format
run: npm run format
run: pnpm run format

- name: test
run: npm run test:cov -- --coverage.reporter=text --coverage.reporter=lcov
run: pnpm run test:cov --coverage.reporter=text --coverage.reporter=lcov

# Coverage report to Codecov (OIDC, no token). Never fails the build: forks get no OIDC token.
- name: codecov
Expand All @@ -62,22 +66,22 @@ jobs:
fail_ci_if_error: false

- name: build
run: npm run build
run: pnpm run build

# The reference pages are generated from src/; this fails when they are stale.
- name: docs
run: npm run docs:check
run: pnpm run docs:check

- name: readme-translations
run: npm run docs:check-i18n
run: pnpm run docs:check-i18n

- name: audit
run: npm audit --omit=dev --audit-level=high
run: pnpm audit --prod --audit-level high

# Production dependencies must use a permissive licence compatible with Apache-2.0.
- name: licences
run: >-
npx --yes license-checker-rseidelsohn@5.0.1
pnpm dlx license-checker-rseidelsohn@5.0.1
--production
--excludePrivatePackages
--summary
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,18 @@ jobs:
with:
persist-credentials: false

# Reads the version from `packageManager` in package.json.
- name: Set up pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: npm
cache: pnpm

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

- name: Check that the documentation matches the sources
run: node scripts/docs/generate-topics.mjs --check
Expand Down Expand Up @@ -160,14 +164,18 @@ jobs:
with:
persist-credentials: false

# Reads the version from `packageManager` in package.json.
- name: Set up pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- name: Set up Node.js
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 22
cache: npm
cache: pnpm

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

- name: Download build results
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
Expand Down
18 changes: 13 additions & 5 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,24 @@ jobs:
ref: ${{ env.TAG }}
persist-credentials: false

# Reads the version from `packageManager` in package.json.
- name: setup-pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- name: setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: install
run: npm ci
run: pnpm install --frozen-lockfile

- name: build
run: npm run build
run: pnpm run build

- name: test
run: npm test
run: pnpm test

# The packed tarball is what goes to npm and, signed, to the GitHub release.
- name: pack
Expand Down Expand Up @@ -146,16 +150,20 @@ jobs:
ref: ${{ env.TAG }}
persist-credentials: false

# Reads the version from `packageManager` in package.json.
- name: setup-pnpm
uses: pnpm/action-setup@73e46992e05b19abd31f2f3c20e0e7370d762115 # v6.1.1

- name: setup-node
uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: 24

- name: install
run: npm ci --ignore-scripts
run: pnpm install --frozen-lockfile --ignore-scripts

- name: sbom
run: npm sbom --sbom-format cyclonedx --omit dev > "bootgs-utils-${TAG#v}.cdx.json"
run: pnpm sbom --sbom-format cyclonedx --prod > "bootgs-utils-${TAG#v}.cdx.json"

- name: download-package
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
# Ignore dependency directories and non-essential lock files
node_modules/
yarn.lock
pnpm-lock.yaml
# Note: package-lock.json is NOT ignored to ensure consistent builds
# package-lock.json
package-lock.json
# Note: pnpm-lock.yaml is NOT ignored to ensure consistent builds

# Compilation results, build artifacts, and TypeScript cache
dist/
Expand Down
14 changes: 7 additions & 7 deletions .junie/guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@

This project is a TypeScript-based utility library for Google Apps Script.

- **Prerequisites**: Node.js and npm installed.
- **Installation**: Run `npm install` to install all dependencies.
- **Building**: Use `npm run build` to compile the TypeScript source into the `dist` directory. This script performs
- **Prerequisites**: Node.js and pnpm installed (`corepack enable`, or see <https://pnpm.io/installation>).
- **Installation**: Run `pnpm install` to install all dependencies.
- **Building**: Use `pnpm run build` to compile the TypeScript source into the `dist` directory. This script performs
cleanup of the `dist` folder before running `tsc`.
- **Linting and Formatting**:
- `npm run lint`: Runs ESLint with auto-fix enabled.
- `npm run format`: Runs Prettier to format all files in the project.
- `pnpm run lint`: Runs ESLint with auto-fix enabled.
- `pnpm run format`: Runs Prettier to format all files in the project.

#### 2. Testing

The project uses [Vitest](https://vitest.dev/) for unit testing.

- **Running Tests**:
- `npm test`: Runs all tests once.
- `npm run dev`: Starts Vitest in watch mode for interactive development.
- `pnpm test`: Runs all tests once.
- `pnpm run dev`: Starts Vitest in watch mode for interactive development.
- **Adding New Tests**:
- Tests should be placed in the `test/` directory, mirroring the structure of the `src/` directory.
- Test files must follow the naming convention `*.test.ts`.
Expand Down
46 changes: 24 additions & 22 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pull request. Resolving those conflicts by hand is how the library has twice
shipped functions nobody could import.

The repository answers this with two merge drivers, declared in
[`.gitattributes`](.gitattributes) and registered by `npm run prepare`:
[`.gitattributes`](.gitattributes) and registered by `pnpm run prepare`:
`merge=module-index` for `src/**/index.ts` and `merge=reference-tables` for
`docs/writerside/topics/reference-*.md`. They merge those files entry by entry
instead of line by line, so two branches adding neighbouring functions do not
Expand All @@ -116,7 +116,7 @@ collide at all.
reports as conflicting must be merged locally:

```bash
npm run prepare # once per clone: registers the drivers
pnpm run prepare # once per clone: registers the drivers
scripts/merge-queue.sh # merges the waiting branches, oldest first
git push github develop
```
Expand All @@ -143,7 +143,7 @@ line, as the surrounding entries do.
- `// TODO:` is never a decision to stop exporting something. Removing a member
deletes its file, and its line goes with it.

`npm run test` is what catches a missing export, and it catches it loudly:
`pnpm run test` is what catches a missing export, and it catches it loudly:
`X is not a function` where a test calls it, an assertion failure where another
function does.

Expand All @@ -165,8 +165,8 @@ prose in `docs/content/`, described in the next rule. The JSDoc is a fallback fo
functions whose prose has not been written yet:

```bash
npm run docs:generate # writes the pages, the tree and the table links
npm run docs:check # fails when they are out of date; CI runs this
pnpm run docs:generate # writes the pages, the tree and the table links
pnpm run docs:check # fails when they are out of date; CI runs this
```

Two things the generator will not touch:
Expand All @@ -175,7 +175,7 @@ Two things the generator will not touch:
as it is — improve such a page by editing it, not the generator;
- the examples under `docs/writerside/snippets/` are real TypeScript files,
embedded into pages with `<code-block src="…" include-symbol="…"/>` and
compiled by `npm run type:check`. An example that stops matching its function
compiled by `pnpm run type:check`. An example that stops matching its function
fails the type check instead of quietly going stale.

So: a new function needs its row in the reference table, its example in
Expand All @@ -196,12 +196,12 @@ source; it adds a file beside it.
- A translated guide is a whole Markdown file in `docs/content/<language>/topics/`.
- Only `docs/writerside/` is edited by hand. `docs/writerside-ru|uk|de|fr/` are
generated in full and must never be edited; a change there is lost on the next
`npm run docs:generate`.
`pnpm run docs:generate`.
- A page with no translation is published in English with a notice on it, and is
listed in `docs/content/COVERAGE.md`. That file is generated; read it to see
what still needs writing.

Most of those JSON files are not typed out by hand. `npm run docs:author` runs
Most of those JSON files are not typed out by hand. `pnpm run docs:author` runs
three writers over the text that is:

- `scripts/docs/guards.mjs` — one entry per subject of the `isX`/`nonX`/`requireX`
Expand All @@ -210,17 +210,17 @@ three writers over the text that is:
- `scripts/docs/author-exceptions.mjs` — one sentence per exception class;
- `docs/content/authored/*.mjs` — everything else, one function at a time.

`npm run docs:verify-examples` then executes every documented result of the form
`pnpm run docs:verify-examples` then executes every documented result of the form
`expr; // => value` against the real implementation, so an example cannot quietly
stop being true. CI runs it.

`npm run docs:sync-examples` copies the first example of each symbol into the
`pnpm run docs:sync-examples` copies the first example of each symbol into the
JSDoc above its declaration, because that comment — not the content file — is
what an IDE shows on hover. It never touches a comment that already has an
`@example`: a hand-written one outranks a copied one. CI checks that no symbol
has a documented example its JSDoc is missing.

`npm run docs:sync-links` writes two `@see` links into that same comment: one to
`pnpm run docs:sync-links` writes two `@see` links into that same comment: one to
the symbol's page on the documentation site, and one per `GoogleAppsScript.*`
class its signature names, pointing at Google's reference. It writes nothing that
is already there, so it is safe to run at any time, and CI checks that no comment
Expand All @@ -232,16 +232,16 @@ carries the version from `package.json`, so the header names the release it was
built from. That line ends with an `x-release-please-version` annotation and the
five files are listed as `extra-files` in `release-please-config.json`, because
`release-please` would otherwise bump the version and leave the configurations a
release behind — which fails `npm run docs:check` on `main` and takes the deploy
release behind — which fails `pnpm run docs:check` on `main` and takes the deploy
with it. `buildprofiles.xml` points the switcher at `help-versions.json`
at the site root. The deploy publishes each build twice — at the root as the
current version, and under `/<version>/` as an archive — keeping the zips in a
`docs-archive` branch, because Pages replaces everything it serves on every
deploy and an archive that lives only there disappears with the next one.
`npm run docs:help-versions -- <site-directory> <version>` writes the file the
`pnpm run docs:help-versions -- <site-directory> <version>` writes the file the
switcher reads.

`npm run docs:finalize-site -- <site-directory>` runs against a built site
`pnpm run docs:finalize-site -- <site-directory>` runs against a built site
rather than the sources. It writes into every page what the build profile does
not: the structured data, the canonical link, the `og:image` address, the row of
links to the other languages under the breadcrumbs, and the notice at the end
Expand All @@ -266,11 +266,11 @@ function does on its own terms.
## 8. Verify before you commit, not after you push

```bash
npm run type:check # tsc --noEmit
npm run lint
npm run format # prettier --check .
npm run test
npm run build
pnpm run type:check # tsc --noEmit
pnpm run lint
pnpm run format # prettier --check .
pnpm run test
pnpm run build
```

The `pre-commit` hook runs the first three and an audit; the `pre-push` hook adds
Expand All @@ -279,7 +279,7 @@ after the work is done is a hook that tempts `--no-verify`.

Formatting is Prettier's, not yours. A merge driver that rewrites a table repads
it through Prettier for the same reason — the file must not drift from what
`npm run format` expects.
`pnpm run format` expects.

## 9. `release-please` owns the version and the changelog

Expand All @@ -297,7 +297,9 @@ BREAKING CHANGE: isValidSheetId no longer accepts fractions, Infinity,
or values beyond Number.MAX_SAFE_INTEGER.
```

Publishing to npm is manual; no workflow does it.
Publishing to npm is manual; no workflow does it. Publish with `pnpm publish`
from a clean `main` after a build: pnpm refuses to publish from another branch
or from a dirty tree.

## 10. Licence and attribution hygiene

Expand All @@ -324,7 +326,7 @@ means the repository is broken.
Run it with the sandbox disabled, or ask the user to run `! gh ...`.
- `git fetch github` over SSH fails. Fetching the same refs over HTTPS works:
`git fetch https://github.com/bootgs/utils.git develop`.
- Writes to `.git/config` are denied, so `npm run prepare` cannot register the
- Writes to `.git/config` are denied, so `pnpm run prepare` cannot register the
merge drivers from inside the sandbox. Run that one command outside it.
- `mktemp -t` resolves to a directory the sandbox cannot write to. Use `$TMPDIR`
explicitly.
Loading
Loading