Skip to content

Commit

Permalink
Corrected npm collaborators detection
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanBluefox committed Aug 19, 2022
1 parent 2ffc3ca commit ee81eae
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Branch (`master/main/dev`) is optional.
-->

## Changelog
### 2.1.3 (2022-08-19)
### **WORK IN PROGRESS**
* (bluefox) Added check for adapter name: it may not start with '_'

### 2.1.2 (2022-07-14)
Expand Down
44 changes: 21 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1156,7 +1156,7 @@ function checkNpm(context) {
// bug in NPM some modules could be accessed via normal web page, but not by API
if (!body) {
try {
const _response = await axios('https://www.npmjs.com/package/iobroker.' + context.adapterName);
const _response = await axios(`https://www.npmjs.com/package/iobroker.${context.adapterName}`);
if (!_response.data) {
context.errors.push('[E200] Not found on npm. Please publish');
return context;
Expand All @@ -1174,30 +1174,28 @@ function checkNpm(context) {
context.errors.push('[E200] Not found on npm. Please publish');
return context;
}
}
context.checks.push('Adapter found on npm');

if (!body ||
!body.collected ||
!body.collected.metadata ||
!body.collected.metadata.maintainers ||
!body.collected.metadata.maintainers.length ||
!body.collected.metadata.maintainers.find(user => user.username === 'bluefox' || user.username === 'iobluefox')) {
context.errors.push(`[E201] Bluefox was not found in the collaborators on NPM!. Please execute in adapter directory: "npm owner add bluefox iobroker.${context.adapterName}"`);
} else {
context.checks.push('Bluefox found in collaborators on NPM');
}
context.checks.push('Adapter found on npm');
if (!body.collected ||
!body.collected.metadata ||
!body.collected.metadata.maintainers ||
!body.collected.metadata.maintainers.length ||
!body.collected.metadata.maintainers.find(user => user.username === 'bluefox' || user.username === 'iobluefox')) {
context.errors.push(`[E201] Bluefox was not found in the collaborators on NPM!. Please execute in adapter directory: "npm owner add bluefox iobroker.${context.adapterName}"`);
} else {
context.checks.push('Bluefox found in collaborators on NPM');
}

if (!body ||
!body.collected ||
!body.collected.metadata ||
!body.collected.metadata.version ||
context.packageJson.version !== body.collected.metadata.version
) {
context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
(body && body.collected && body.collected.metadata && body.collected.metadata.version) || JSON.stringify(body)})`);
} else {
context.checks.push('Version of package.json matches latest version on NPM');
if (!body.collected ||
!body.collected.metadata ||
!body.collected.metadata.version ||
context.packageJson.version !== body.collected.metadata.version
) {
context.warnings.push(`[W202] Version of package.json (${context.packageJson.version}) doesn't match latest version on NPM (${
(body && body.collected && body.collected.metadata && body.collected.metadata.version) || JSON.stringify(body)})`);
} else {
context.checks.push('Version of package.json matches latest version on NPM');
}
}

return context;
Expand Down

0 comments on commit ee81eae

Please sign in to comment.