Skip to content
Draft
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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ npx @iobroker/repochecker https://github.com/ioBroker/ioBroker.javascript --loca
Placeholder for the next version (at the beginning of the line):
### **WORK IN PROGRESS**
-->
### **WORK IN PROGRESS**
- (@copilot) Added validation to ensure i18n directories are included in npm packages

### 5.0.0-alpha.1 (2025-09-29)
- (mcm1957) Strict mode requirements have been loosend at schema validation.
- (mcm1957) Do not log missing jsonConfig schema at vscode is no jsonConfig is used. [#548]
Expand Down
60 changes: 60 additions & 0 deletions lib/M9000_GitNpmIgnore.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,33 @@ async function checkNpmIgnore(context) {
} else {
context.checks.push('package.json "files" already used.');
}

// Check if i18n directories exist and are included in files section
const i18nDirs = context.filesList.filter(file => file.match(/^\/admin\/i18n\//));
if (i18nDirs.length > 0) {
// Check if any i18n pattern is included in files
const hasI18nIncluded = context.packageJson.files.some(pattern => {
// Check for various patterns that would include admin/i18n
return (
pattern === 'admin/i18n' ||
pattern === 'admin/i18n/' ||
pattern === 'admin/i18n/**' ||
pattern === 'admin/' ||
pattern === 'admin/**' ||
pattern === 'admin' ||
pattern.startsWith('admin/i18n')
);
});

if (!hasI18nIncluded) {
context.errors.push(
`[E9506] i18n directory found but not included in package.json "files" section. Please add "admin/i18n/" to the files array.`,
);
} else {
context.checks.push('i18n directory is included in package.json "files" section.');
}
}

return context;
}

Expand Down Expand Up @@ -201,6 +228,37 @@ async function checkNpmIgnore(context) {
);
}
});

// Check if i18n directories exist and are not excluded by .npmignore
const i18nDirs = context.filesList.filter(file => file.match(/^\/admin\/i18n\//));
if (i18nDirs.length > 0) {
// Check if admin/i18n is excluded by any rule
const isI18nExcluded = rules.some(rule => {
if (typeof rule === 'string') {
// Check for patterns that would exclude admin/i18n
return (
rule === 'admin/i18n' ||
rule === 'admin/i18n/' ||
rule === '/admin/i18n' ||
rule === '/admin/i18n/' ||
rule === 'admin' ||
rule === '/admin' ||
rule === 'admin/' ||
rule === '/admin/'
);
}
// Check if regex would match admin/i18n
return rule.test('admin/i18n/') || rule.test('admin/i18n/en/translations.json');
});

if (isI18nExcluded) {
context.errors.push(
`[E9507] i18n directory found but excluded by .npmignore. Please remove patterns that exclude admin/i18n from .npmignore.`,
);
} else {
context.checks.push('i18n directory is not excluded by .npmignore.');
}
}
}
}
return context;
Expand All @@ -223,5 +281,7 @@ exports.checkNpmIgnore = checkNpmIgnore;
// [9503] .npmignore found - consider using package.json object "files" instead.
// [9504] node_modules not found in `.npmignore`
// [9505] iob_npm.done not found in .npmignore` ### removed ###
// [9506] i18n directory found but not included in package.json "files" section. Please add "admin/i18n/" to the files array.
// [9507] i18n directory found but excluded by .npmignore. Please remove patterns that exclude admin/i18n from .npmignore.

// [W9006] .commitinfo file should be excluded by .gitignore, consider adding it to .gitignore