fix(sdk): parse JSONC comments in version sync
This commit is contained in:
parent
1f789095a9
commit
bb905db75c
|
|
@ -148,7 +148,15 @@ function skipJsoncValue(source, start) {
|
|||
}
|
||||
|
||||
let index = valueStart;
|
||||
while (index < source.length && !',}]'.includes(source[index])) {
|
||||
while (index < source.length) {
|
||||
const afterTrivia = skipTrivia(source, index);
|
||||
if (afterTrivia !== index) {
|
||||
index = afterTrivia;
|
||||
continue;
|
||||
}
|
||||
if (',}]'.includes(source[index])) {
|
||||
break;
|
||||
}
|
||||
index += 1;
|
||||
}
|
||||
return index;
|
||||
|
|
|
|||
|
|
@ -98,6 +98,42 @@ test('Bun lock inspection finds every versioned SDK workspace and ignores the ro
|
|||
});
|
||||
});
|
||||
|
||||
test('Bun lock inspection ignores structural delimiters in block comments after primitive values', () => {
|
||||
const lockfile = `{
|
||||
"lockfileVersion": 1 /* comma, brace }, bracket ] */,
|
||||
"workspaces": {
|
||||
"op-web-sdk": { "version": "1.0.0" },
|
||||
},
|
||||
}`;
|
||||
|
||||
assert.deepEqual(inspectBunLockWorkspaceVersions(lockfile), {
|
||||
'op-web-sdk': '1.0.0',
|
||||
});
|
||||
});
|
||||
|
||||
test('Bun lock inspection ignores structural delimiters in line comments after primitive values', () => {
|
||||
const lockfile = `{
|
||||
"lockfileVersion": 1 // comma, brace }, bracket ]
|
||||
,
|
||||
"workspaces": {
|
||||
"op-web-sdk": { "version": "1.0.0" },
|
||||
},
|
||||
}`;
|
||||
|
||||
assert.deepEqual(inspectBunLockWorkspaceVersions(lockfile), {
|
||||
'op-web-sdk': '1.0.0',
|
||||
});
|
||||
});
|
||||
|
||||
test('Bun lock inspection still rejects unterminated block comments after primitive values', () => {
|
||||
const lockfile = `{
|
||||
"lockfileVersion": 1 /* unterminated }, ],
|
||||
"workspaces": {},
|
||||
}`;
|
||||
|
||||
assert.throws(() => inspectBunLockWorkspaceVersions(lockfile), /unterminated block comment/i);
|
||||
});
|
||||
|
||||
test('drift collection reports each stale path with expected and actual versions', () => {
|
||||
assert.deepEqual(
|
||||
collectVersionDrift('2.3.4', [
|
||||
|
|
|
|||
Loading…
Reference in a new issue