Skip to content

Commit 7de44bb

Browse files
authored
Merge pull request #842 from ioBroker/copilot/update-isnewadapter-setup
Set isNewAdapter before config.updateConfig via new getLatestRepo preprocessing step
2 parents 5fb9991 + 973332e commit 7de44bb

3 files changed

Lines changed: 40 additions & 15 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ Example:
2626
### **WORK IN PROGRESS**
2727
-->
2828
### **WORK IN PROGRESS**
29+
- (@copilot) Fixed adapter detection to ensure the `isNewAdapter` flag is set before configuration logging. Added a new `getLatestRepo` preprocessing step so that the flag is correctly visible in the environment log output.
2930
- (@copilot) Added German translation of OBJECTDUMP.md as OBJECTDUMP_de.md.
3031

3132
### 5.10.4 (2026-04-12)

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ function check(request, ctx, callback) {
148148
.then(context => M0000_PackageJson.getPackageJson(context))
149149
.then(context => M1000_IOPackageJson.getIOPackageJson(context))
150150
.then(context => M2000_Npm.getNpm(context))
151+
.then(context => M4000_Repository.getLatestRepo(context))
151152
.then(context => config.updateConfig(context))
152153
.then(context => config.logEnvironment(context))
153154
.then(context => M0000_PackageJson.checkPackageJson(context))

lib/M4000_Repository.js

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,32 +21,54 @@ const JSON5 = require('json5');
2121
const common = require('./common.js');
2222
const config = require('./config.js');
2323

24+
async function getLatestRepo(context) {
25+
console.log('[init] getting latest repository info');
26+
try {
27+
const response = await axios(
28+
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
29+
);
30+
const body = response.data;
31+
if (body) {
32+
context.latestRepo = body;
33+
if (!context.latestRepo[context.adapterName]) {
34+
context.cfg.isNewAdapter = true;
35+
common.info(
36+
`isNewAdapter is set: adapter "${context.adapterName}" is not listed in the latest repository`,
37+
);
38+
}
39+
}
40+
} catch (e) {
41+
common.error(`Cannot download latest repository info: ${e}`);
42+
}
43+
return context;
44+
}
45+
2446
async function checkRepository(context) {
2547
console.log('\n[E4000 - E4999] checking repository');
2648

2749
if (context.ioPackageJson && context.ioPackageJson.common && context.ioPackageJson.common.type) {
2850
/* TODO: why check type here ? */
29-
// download latest repo
30-
const response = await axios(
31-
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
32-
);
33-
let body = response.data;
34-
if (!body) {
35-
context.errors.push(
36-
'[E4000] Cannot download https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
51+
let body;
52+
// download latest repo (if not already retrieved by preprocessing)
53+
if (!context.latestRepo) {
54+
const response = await axios(
55+
'https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
3756
);
38-
} else {
39-
context.latestRepo = body;
57+
body = response.data;
58+
if (!body) {
59+
context.errors.push(
60+
'[E4000] Cannot download https://raw.githubusercontent.com/ioBroker/ioBroker.repositories/master/sources-dist.json',
61+
);
62+
} else {
63+
context.latestRepo = body;
64+
}
65+
}
66+
if (context.latestRepo) {
4067
if (!context.latestRepo[context.adapterName]) {
4168
context.warnings.push(
4269
`[W4001] Cannot find "${context.adapterName}" in latest repository. Please ignore if PR to add adapter to repositories already exists.`,
4370
);
4471

45-
context.cfg.isNewAdapter = true;
46-
common.info(
47-
`isNewAdapter is set: adapter "${context.adapterName}" is not listed in the latest repository`,
48-
);
49-
5072
if (context.adapterName.includes('_')) {
5173
context.errors.push('[E4021] Adapter name should use "-" instead of "_"');
5274
} else {
@@ -489,6 +511,7 @@ async function checkVSCodeSchemas(context) {
489511
}
490512
}
491513

514+
exports.getLatestRepo = getLatestRepo;
492515
exports.checkRepository = checkRepository;
493516

494517
// List of error and warnings used at this module

0 commit comments

Comments
 (0)