Skip to content
Merged
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
6 changes: 3 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@
# These paths are either relative to html_static_path
# or fully qualified paths (eg. https://...)
html_css_files = [
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.314.32913/dist/crowdin-furo-css.css',
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.811.210538/dist/crowdin-furo-css.css',
]
html_js_files = [
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.314.32913/dist/crowdin.js',
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.314.32913/dist/ranking-sorter.js',
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.811.210538/dist/crowdin.js',
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.811.210538/dist/ranking-sorter.js',
'js/crowdin.js', # crowdin language selector
'js/projects.js', # load projects with readthedocs documentation
]
Expand Down
60 changes: 46 additions & 14 deletions tests/renovate-config.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,40 @@ function extractNpmDependencies(manager, fileName, content) {
return extractRegexPackageFile(content, fileName, manager)?.deps ?? [];
}

function nextTestVersion(currentValue) {
const match = /^(.*?)(\d+)$/.exec(currentValue);
assert.ok(match, `Expected a version ending in a number: ${currentValue}`);

return `${match[1]}${BigInt(match[2]) + 1n}`;
}

function applyExtractedUpdate(content, dependency, newValue) {
assert.ok(dependency.replaceString, 'Expected Renovate to provide a replaceString');
const updatedReplaceString = dependency.replaceString.replace(dependency.currentValue, newValue);
assert.notEqual(updatedReplaceString, dependency.replaceString);

return content.replaceAll(dependency.replaceString, updatedReplaceString);
}

test('extracts versioned npm CDN URLs from supported file types', () => {
const cases = [
{
fileName: 'docs/source/conf.py',
content: `
html_css_files = [
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@2026.314.32913/dist/styles.css',
'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@1.2.3/dist/styles.css',
]
`,
expected: [['@lizardbyte/shared-web', '2026.314.32913']],
expected: [['@lizardbyte/shared-web', '1.2.3']],
},
{
fileName: 'assets/js/projects.js',
content: `
const sharedWeb = 'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@v2026.726.204939';
const sharedWeb = 'https://cdn.jsdelivr.net/npm/@lizardbyte/shared-web@v2.3.4';
const icon = 'https://cdn.jsdelivr.net/npm/simple-icons@v15/icons/readthedocs.svg';
`,
expected: [
['@lizardbyte/shared-web', 'v2026.726.204939'],
['@lizardbyte/shared-web', 'v2.3.4'],
['simple-icons', 'v15'],
],
},
Expand All @@ -80,21 +95,38 @@ const icon = 'https://cdn.jsdelivr.net/npm/simple-icons@v15/icons/readthedocs.sv
}
});

test('extracts every shared-web pin from this repository Sphinx config', () => {
test('extracts and can update every shared-web pin in this repository Sphinx config', () => {
const fileName = 'docs/source/conf.py';
const content = fs.readFileSync(fileName, 'utf8');
const dependencies = extractNpmDependencies(
sourceNpmCdnManager,
'docs/source/conf.py',
fs.readFileSync('docs/source/conf.py', 'utf8'),
fileName,
content,
).filter(dependency => dependency.depName === '@lizardbyte/shared-web');

const sourcePins = [...content.matchAll(
/https:\/\/(?:cdn\.jsdelivr\.net\/npm|unpkg\.com)\/@lizardbyte\/shared-web@(?<version>v?\d[^/"'\s?#]*)/g,
)];
assert.ok(sourcePins.length > 0, 'Expected at least one shared-web pin');
assert.equal(dependencies.length, sourcePins.length, 'Expected Renovate to extract every shared-web pin');
assert.deepEqual(
dependencies.map(dependency => dependency.currentValue),
sourcePins.map(pin => pin.groups.version),
);

assert.deepEqual(
dependencies.map(dependency => [dependency.depName, dependency.currentValue]),
[
['@lizardbyte/shared-web', '2026.314.32913'],
['@lizardbyte/shared-web', '2026.314.32913'],
['@lizardbyte/shared-web', '2026.314.32913'],
],
const currentVersions = new Set(dependencies.map(dependency => dependency.currentValue));
assert.equal(currentVersions.size, 1, 'Expected every shared-web URL to use the same version');
const currentValue = dependencies[0].currentValue;
const newValue = nextTestVersion(currentValue);
const updatedContent = applyExtractedUpdate(content, dependencies[0], newValue);
const updatedDependencies = extractNpmDependencies(
sourceNpmCdnManager,
fileName,
updatedContent,
);

assert.equal(updatedDependencies.length, dependencies.length);
assert.ok(updatedDependencies.every(dependency => dependency.currentValue === newValue));
});

test('ignores moving tags and interpolated npm CDN versions', () => {
Expand Down