From 5f6123b0475c3d11257bd2f6bcb99c2f4311811e Mon Sep 17 00:00:00 2001 From: Alexandre Alves Date: Mon, 25 Nov 2024 18:02:49 +0000 Subject: [PATCH] Fix some issues with extensions creator's package in master (#12638) * 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 --- creators/extension/app/app.package.json | 22 +------ .../workflows/build-extension-charts.yml | 3 +- creators/extension/package.json | 2 +- creators/extension/pkg/init | 62 ------------------- creators/extension/pkg/package.json | 6 ++ 5 files changed, 11 insertions(+), 84 deletions(-) diff --git a/creators/extension/app/app.package.json b/creators/extension/app/app.package.json index 55a54b8cdaf..1ee15706a60 100644 --- a/creators/extension/app/app.package.json +++ b/creators/extension/app/app.package.json @@ -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" } } diff --git a/creators/extension/app/files/.github/workflows/build-extension-charts.yml b/creators/extension/app/files/.github/workflows/build-extension-charts.yml index 73343d8f948..69148f2307d 100644 --- a/creators/extension/app/files/.github/workflows/build-extension-charts.yml +++ b/creators/extension/app/files/.github/workflows/build-extension-charts.yml @@ -2,7 +2,7 @@ name: Build and Release Extension Charts on: workflow_dispatch: - release: + release: types: [released] defaults: @@ -20,3 +20,4 @@ jobs: pages: write with: target_branch: gh-pages + tagged_release: ${{ github.ref_name }} diff --git a/creators/extension/package.json b/creators/extension/package.json index cf18cce5f1a..ebcf7bec11e 100644 --- a/creators/extension/package.json +++ b/creators/extension/package.json @@ -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": "yarn@4.5.0", diff --git a/creators/extension/pkg/init b/creators/extension/pkg/init index a46ee7905fe..e449508d498 100755 --- a/creators/extension/pkg/init +++ b/creators/extension/pkg/init @@ -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() { diff --git a/creators/extension/pkg/package.json b/creators/extension/pkg/package.json index 8b48374aa78..0db1cace8da 100644 --- a/creators/extension/pkg/package.json +++ b/creators/extension/pkg/package.json @@ -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" },