Skip to content

chore(copyright): add sync-header-years script and tests#639

Open
SteinGabriel wants to merge 1 commit into
mainfrom
copyright-date-automation
Open

chore(copyright): add sync-header-years script and tests#639
SteinGabriel wants to merge 1 commit into
mainfrom
copyright-date-automation

Conversation

@SteinGabriel
Copy link
Copy Markdown
Contributor

@SteinGabriel SteinGabriel commented May 25, 2026

JIRA Ticket

N/A

Description

Adds automated Ping Identity copyright year management to the ping-javascript-sdk repo. A
pre-commit script rewrites stale headers in staged files and re-stages them; an ESLint rule
surfaces missing headers in-editor during lint runs.

Changes

tools/copyright/

  • sync-header-years.mjs — new script; rewrites stale Ping-owned copyright headers in
    staged files (single-year → range, stale range end → current year); fails commit if a Ping
    header has no valid year; runs in --fix or --check mode
  • sync-header-years.test.mjs — 23 unit tests covering range updates, single-year
    expansion, idempotency, variant matching (©, ©, (c)), and exclusion of
    non-Ping/test/tooling files

eslint.config.mjs

  • Added inline local-rules/ping-copyright rule (warn severity) that checks the first block
    comment of every .ts/.tsx/.js/.jsx/.mjs/.cjs source file for a Copyright … Ping Identity header
  • No external plugin — eslint-plugin-header incompatible with ESLint 9 flat config;
    eslint-plugin-headers lacks regex variable support needed for year-range patterns

lefthook.yml

  • Added copyright-sync pre-commit command (node tools/copyright/sync-header-years.mjs --fix, stage_fixed: true) between nx-sync and nx-check

package.json

  • Added copyright:sync and copyright:check scripts for manual runs

Tests

  • 23 unit tests in tools/copyright/sync-header-years.test.mjs — all pass
  • Covers: range updates, single-year expansion, idempotency, all header variants, exclusion
    patterns

How to test

1. Manual pre-commit trigger

Stage any file with a stale Ping copyright year and run git commit. The copyright-sync
hook should rewrite and re-stage the header automatically.

2. Scripts

pnpm copyright:check # reports stale headers
pnpm copyright:sync # rewrites stale headers in place

3. ESLint

pnpm lint

Files missing a Ping Identity copyright header emit a local-rules/ping-copyright warning.

Summary by CodeRabbit

  • New Features

    • Added automatic copyright header validation to code quality checks
    • Added copyright year synchronization tools and npm scripts for managing header dates
  • API Changes

    • Renamed polling method in davinci-client for improved clarity
  • Tests

    • Added comprehensive test coverage for copyright header management tooling

Review Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 25, 2026

⚠️ No Changeset found

Latest commit: 27deab1

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Warning

Review limit reached

@SteinGabriel, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 55 minutes and 53 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7c74910b-1626-4590-ac3e-0034d33af1d9

📥 Commits

Reviewing files that changed from the base of the PR and between 30dc079 and 27deab1.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • eslint.config.mjs
  • lefthook.yml
  • package.json
  • tools/copyright/sync-header-years.mjs
  • tools/copyright/sync-header-years.test.mjs
📝 Walkthrough

Walkthrough

This PR establishes copyright header enforcement infrastructure across the repository and updates a public API method name. It introduces an ESLint rule and CLI tool to validate and synchronize Ping copyright headers with current years, integrated into the pre-commit workflow. Additionally, the davinci client API rename updates poll to pollStatus in type reports.

Changes

Copyright Header Enforcement

Layer / File(s) Summary
ESLint copyright rule configuration
eslint.config.mjs
New Flat Config entry registers local ping-copyright rule targeting JS/TS files with warn severity and expanded ignore patterns for test/config files.
Copyright sync script and helpers
tools/copyright/sync-header-years.mjs
CLI tool processes staged files, validates Ping copyright headers, normalizes year formatting, updates stale ranges to current year, and exports isExcluded(), updateCopyrightYears(), hasInvalidPingCopyrightHeader(), and hasPingCopyrightHeader() helpers.
Copyright sync test suite
tools/copyright/sync-header-years.test.mjs
Covers year-range transformation, header validation, path exclusion rules, and copyright header detection across single-line and multi-line comment formats.
Pre-commit integration and npm scripts
lefthook.yml, package.json
Adds copyright-sync pre-commit command, copyright:check and copyright:sync npm scripts; removes empty dependencies object; reorders devDependencies.

API Method Rename

Layer / File(s) Summary
davinci client polling method rename
packages/davinci-client/api-report/davinci-client.api.md, packages/davinci-client/api-report/davinci-client.types.api.md
Public API signature updated: poll method renamed to pollStatus in davinci client return type while maintaining parameter and return type signatures.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • ForgeRock/ping-javascript-sdk#622: Implements the pollpollStatus rename across client implementation and e2e wiring that this PR's API report updates reflect.

Suggested reviewers

  • cerebrl

Poem

🐰 Headers need checking, years must align,
So we built a tool to keep copyrights fine!
ESLint now warns when the copyright's gone,
Pre-commit hooks run to keep headers strong,
And pollStatus replaces the name of poll
commit with confidence, our checklist is whole!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main changes: adding a copyright sync script and tests.
Description check ✅ Passed The description provides a comprehensive overview of changes with clear sections for objectives, implementation details, and testing instructions.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch copyright-date-automation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

chore(copyright): wire sync script into lefthook and add package scripts

feat(eslint): add inline ping-copyright rule to eslint.config.mjs
@nx-cloud
Copy link
Copy Markdown
Contributor

nx-cloud Bot commented May 25, 2026

View your CI Pipeline Execution ↗ for commit 27deab1

Command Status Duration Result
nx run-many -t build --no-agents ✅ Succeeded <1s View ↗
nx affected -t build lint test typecheck e2e-ci ✅ Succeeded <1s View ↗

☁️ Nx Cloud last updated this comment at 2026-05-25 23:08:28 UTC

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 25, 2026

Open in StackBlitz

@forgerock/davinci-client

pnpm add https://pkg.pr.new/@forgerock/davinci-client@639

@forgerock/device-client

pnpm add https://pkg.pr.new/@forgerock/device-client@639

@forgerock/journey-client

pnpm add https://pkg.pr.new/@forgerock/journey-client@639

@forgerock/oidc-client

pnpm add https://pkg.pr.new/@forgerock/oidc-client@639

@forgerock/protect

pnpm add https://pkg.pr.new/@forgerock/protect@639

@forgerock/sdk-types

pnpm add https://pkg.pr.new/@forgerock/sdk-types@639

@forgerock/sdk-utilities

pnpm add https://pkg.pr.new/@forgerock/sdk-utilities@639

@forgerock/iframe-manager

pnpm add https://pkg.pr.new/@forgerock/iframe-manager@639

@forgerock/sdk-logger

pnpm add https://pkg.pr.new/@forgerock/sdk-logger@639

@forgerock/sdk-oidc

pnpm add https://pkg.pr.new/@forgerock/sdk-oidc@639

@forgerock/sdk-request-middleware

pnpm add https://pkg.pr.new/@forgerock/sdk-request-middleware@639

@forgerock/storage

pnpm add https://pkg.pr.new/@forgerock/storage@639

commit: 27deab1

@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 18.21%. Comparing base (eafe277) to head (27deab1).
⚠️ Report is 7 commits behind head on main.

❌ Your project status has failed because the head coverage (18.21%) is below the target coverage (40.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #639      +/-   ##
==========================================
+ Coverage   18.07%   18.21%   +0.13%     
==========================================
  Files         155      155              
  Lines       24398    24440      +42     
  Branches     1203     1212       +9     
==========================================
+ Hits         4410     4451      +41     
- Misses      19988    19989       +1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Copy Markdown
Contributor

Deployed 1dae5e5 to https://ForgeRock.github.io/ping-javascript-sdk/pr-639/1dae5e56cd51cf44c052be827f2cfe83199b76a5 branch gh-pages in ForgeRock/ping-javascript-sdk

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tools/copyright/sync-header-years.mjs`:
- Around line 171-178: The hasPingCopyrightHeader function currently scans every
line for MAYBE_PING_COPYRIGHT_LINE_REGEX within any comment line, which lets
matches inside the file pass check mode; change it to only inspect the file's
leading header block (the initial contiguous comment/blank lines) — iterate
lines from the top, stop scanning when you hit the first line that does not
match HEADER_COMMENT_LINE_REGEX or a blank line policy that ends the header, and
only test those header lines with MAYBE_PING_COPYRIGHT_LINE_REGEX; update
hasPingCopyrightHeader to return false if no match is found in that leading
header block.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ad8dd158-9829-45ce-b608-4863322b7f53

📥 Commits

Reviewing files that changed from the base of the PR and between 9f93d5e and 30dc079.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (7)
  • eslint.config.mjs
  • lefthook.yml
  • package.json
  • packages/davinci-client/api-report/davinci-client.api.md
  • packages/davinci-client/api-report/davinci-client.types.api.md
  • tools/copyright/sync-header-years.mjs
  • tools/copyright/sync-header-years.test.mjs

Comment thread tools/copyright/sync-header-years.mjs
@github-actions
Copy link
Copy Markdown
Contributor

📦 Bundle Size Analysis

📦 Bundle Size Analysis

🚨 Significant Changes

🔻 @forgerock/device-client - 0.0 KB (-10.0 KB, -100.0%)
🔻 @forgerock/journey-client - 0.0 KB (-91.9 KB, -100.0%)

➖ No Changes

@forgerock/storage - 1.5 KB
@forgerock/sdk-request-middleware - 4.5 KB
@forgerock/iframe-manager - 2.4 KB
@forgerock/sdk-oidc - 4.8 KB
@forgerock/sdk-logger - 1.6 KB
@forgerock/sdk-types - 7.9 KB
@forgerock/davinci-client - 54.1 KB
@forgerock/protect - 144.6 KB
@forgerock/device-client - 10.0 KB
@forgerock/sdk-utilities - 11.2 KB
@forgerock/oidc-client - 25.2 KB
@forgerock/journey-client - 91.9 KB


14 packages analyzed • Baseline from latest main build

Legend

🆕 New package
🔺 Size increased
🔻 Size decreased
➖ No change

ℹ️ How bundle sizes are calculated
  • Current Size: Total gzipped size of all files in the package's dist directory
  • Baseline: Comparison against the latest build from the main branch
  • Files included: All build outputs except source maps and TypeScript build cache
  • Exclusions: .map, .tsbuildinfo, and .d.ts.map files

🔄 Updated automatically on each push to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants