Skip to content

Commit

Permalink
Fix some issues with extensions creator's package in master (#12638)
Browse files Browse the repository at this point in the history
* fix build-extension-charts workflow + update resolutions and dependencies for rancher 2.10 extensions  + bump creators version

* remove fetchLatestVersion function and harcode meaningful annotation to pkg/package.json
  • Loading branch information
aalves08 authored Nov 25, 2024
1 parent a2a8685 commit 5f6123b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 84 deletions.
22 changes: 2 additions & 20 deletions creators/extension/app/app.package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,9 @@
"engines": {
"node": ">=20"
},
"dependencies": {
"cache-loader": "^4.1.0",
"color": "4.2.3",
"ip": "2.0.1",
"node-polyfill-webpack-plugin": "^3.0.0"
},
"dependencies": {},
"resolutions": {
"@types/node": "~20.10.0",
"d3-color": "3.1.0",
"ejs": "3.1.9",
"follow-redirects": "1.15.2",
"glob": "7.2.3",
"glob-parent": "6.0.2",
"json5": "2.2.3",
"@types/lodash": "4.17.5",
"merge": "2.1.1",
"node-forge": "1.3.1",
"nth-check": "2.1.1",
"qs": "6.11.1",
"roarr": "7.0.4",
"semver": "7.5.4",
"@vue/cli-service/html-webpack-plugin": "^5.0.0"
"@types/lodash": "4.17.5"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Release Extension Charts

on:
workflow_dispatch:
release:
release:
types: [released]

defaults:
Expand All @@ -20,3 +20,4 @@ jobs:
pages: write
with:
target_branch: gh-pages
tagged_release: ${{ github.ref_name }}
2 changes: 1 addition & 1 deletion creators/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@rancher/create-extension",
"description": "Rancher UI Extension generator",
"version": "1.0.0",
"version": "3.0.0",
"license": "Apache-2.0",
"author": "SUSE",
"packageManager": "[email protected]",
Expand Down
62 changes: 0 additions & 62 deletions creators/extension/pkg/init
Original file line number Diff line number Diff line change
Expand Up @@ -76,68 +76,6 @@ const pkg = JSON.parse(rawdata);
pkg.name = name;
pkg.description = `${ name } plugin`;

// Add annotation for the latest Rancher version by default
function fetchLatestVersion() {
console.log(' Fetching latest Rancher Version');
const options = { headers: { 'User-Agent': 'nodejs' } };

https.get('https://api.github.com/repos/rancher/rancher/releases/latest', options, (res) => {
const { statusCode } = res;
const contentType = res.headers['content-type'];

let error;

if ( statusCode !== 200 ) {
error = new Error(' Request Failed.\n' +
` Status Code: ${ statusCode }`);
} else if ( !/^application\/json/.test(contentType) ) {
error = new Error(' Invalid content-type.\n' +
` Expected application/json but received ${ contentType }`);
}

if ( error ) {
console.log(error.message);

res.resume();

return;
}

res.setEncoding('utf8');
let rawData = '';

res.on('data', (chunk) => {
rawData += chunk;
});
res.on('end', () => {
try {
const release = JSON.parse(rawData);

if ( release.tag_name ) {
console.log(` Adding rancher-version annotation '>= ${ release.tag_name }' to package.json`);

pkg.rancher = { annotations: { 'catalog.cattle.io/rancher-version': `>= ${ release.tag_name }` } };

if ( !shellVersion ) {
console.log('Could not get a shell version from npm, skipping adding catalog.cattle.io/ui-extensions-version annotation to package.json');
} else {
console.log(` Adding catalog.cattle.io/ui-extensions-version '>= ${ shellVersion }' to package.json`);

pkg.rancher.annotations['catalog.cattle.io/ui-extensions-version'] = `>= ${ shellVersion }`;
}

writePackageJson();
}
} catch (e) {
console.log(' Error parsing release data', e);
}
});
}).on('error', (e) => {
console.log(' Error fetching latest Rancher Version', e);
});
}

fetchLatestVersion();
writePackageJson();

function writePackageJson() {
Expand Down
6 changes: 6 additions & 0 deletions creators/extension/pkg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
"**/*.*",
"init"
],
"rancher": {
"annotations": {
"catalog.cattle.io/rancher-version": ">= 2.10.0",
"catalog.cattle.io/ui-extensions-version": ">= 3.0.0"
}
},
"engines": {
"node": ">=20.0.0"
},
Expand Down

0 comments on commit 5f6123b

Please sign in to comment.