Skip to content

Add validation to ensure i18n directories are included in npm packages#557

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-7dacbfe8-9af0-48a5-99e1-6e2229fbfbe2
Draft

Add validation to ensure i18n directories are included in npm packages#557
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-7dacbfe8-9af0-48a5-99e1-6e2229fbfbe2

Conversation

Copy link
Contributor

Copilot AI commented Sep 30, 2025

Summary

This PR adds validation checks to ensure that adapter translation files (i18n directories) are properly included when publishing to npm. This prevents adapters from being released without their translation files, which would break multilingual support.

Problem

Adapters use admin/i18n/ directories to store translation files in formats like:

  • admin/i18n/en/translations.json (new style)
  • admin/i18n/en.json (old style)

Previously, the repochecker didn't validate whether these directories were properly configured for npm publishing. This could lead to:

  • Adapters using package.json files section but forgetting to include admin/i18n/
  • Adapters using .npmignore but accidentally excluding admin or admin/i18n

Solution

Added two new error checks in lib/M9000_GitNpmIgnore.js:

E9506 - Files Section Check

Triggers when an adapter uses the files section in package.json and has i18n directories, but they are not included in the files array.

Example error:

[E9506] i18n directory found but not included in package.json "files" section. 
Please add "admin/i18n/" to the files array.

Fix: Add "admin/i18n/" (or broader patterns like "admin/") to the files array in package.json.

E9507 - NPM Ignore Check

Triggers when an adapter uses .npmignore and explicitly excludes patterns that would exclude i18n directories.

Example error:

[E9507] i18n directory found but excluded by .npmignore. 
Please remove patterns that exclude admin/i18n from .npmignore.

Fix: Remove or adjust patterns like admin or admin/i18n from .npmignore.

Implementation Details

  • Smart detection: Only checks when i18n directories actually exist in the repository
  • Comprehensive pattern matching: Handles various patterns (admin/, admin/**, admin/i18n/, wildcards, regex patterns)
  • Both i18n formats: Supports both old-style and new-style i18n file structures
  • No false positives: Adapters without i18n directories are not affected

Testing

Thoroughly tested with:

  • ✅ Files section with/without i18n inclusion
  • ✅ .npmignore with/without i18n exclusion
  • ✅ Various file patterns (admin/, admin/**, admin/*)
  • ✅ Real-world adapter configurations
  • ✅ Edge cases and both i18n file formats

All tests pass and linting is clean.

Related to issue about ensuring i18n directories are not excluded from npm packages.

Original prompt

This section details on the original issue you should resolve

<issue_title>Check that i18n is not excluded from npm</issue_title>
<issue_description>If adapter uses .npmignore check that i18n directories are not excluded from npm.

If adapter uses fiels section within package,json and has any i18n directory ensure that those files are included into the package</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #341

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: mcm1957 <28575778+mcm1957@users.noreply.github.com>
Copilot AI changed the title [WIP] Check that i18n is not excluded from npm Add validation to ensure i18n directories are included in npm packages Sep 30, 2025
Copilot AI requested a review from mcm1957 September 30, 2025 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Check that i18n is not excluded from npm

2 participants