-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(marketplace): add marketplace providers (WIP)
Signed-off-by: Christoph Jerolimov <[email protected]>
- Loading branch information
1 parent
5e4bdd2
commit fcc6415
Showing
29 changed files
with
1,091 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
# Knip report | ||
|
||
## Unused dependencies (11) | ||
## Unused dependencies (12) | ||
|
||
| Name | Location | Severity | | ||
| :---------------------------------------------------------- | :----------- | :------- | | ||
| @red-hat-developer-hub/backstage-plugin-marketplace-backend | package.json | error | | ||
| @backstage/plugin-auth-backend-module-github-provider | package.json | error | | ||
| @backstage/plugin-search-backend-node | package.json | error | | ||
| @backstage/plugin-permission-common | package.json | error | | ||
| @backstage/plugin-permission-node | package.json | error | | ||
| @backstage/plugin-auth-node | package.json | error | | ||
| @backstage/config | package.json | error | | ||
| better-sqlite3 | package.json | error | | ||
| node-gyp | package.json | error | | ||
| app | package.json | error | | ||
| pg | package.json | error | | ||
| Name | Location | Severity | | ||
| :------------------------------------------------------------------------- | :----------- | :------- | | ||
| @red-hat-developer-hub/backstage-plugin-catalog-backend-module-marketplace | package.json | error | | ||
| @red-hat-developer-hub/backstage-plugin-marketplace-backend | package.json | error | | ||
| @backstage/plugin-auth-backend-module-github-provider | package.json | error | | ||
| @backstage/plugin-search-backend-node | package.json | error | | ||
| @backstage/plugin-permission-common | package.json | error | | ||
| @backstage/plugin-permission-node | package.json | error | | ||
| @backstage/plugin-auth-node | package.json | error | | ||
| @backstage/config | package.json | error | | ||
| better-sqlite3 | package.json | error | | ||
| node-gyp | package.json | error | | ||
| app | package.json | error | | ||
| pg | package.json | error | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = require('@backstage/cli/config/eslint-factory')(__dirname); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# @red-hat-developer-hub/marketplace-cli |
29 changes: 29 additions & 0 deletions
29
workspaces/marketplace/packages/marketplace-cli/bin/marketplace-cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env node | ||
/* | ||
* Copyright 2025 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
const path = require('path'); | ||
|
||
// Figure out whether we're running inside the backstage repo | ||
/* eslint-disable-next-line no-restricted-syntax */ | ||
const isLocal = require('fs').existsSync(path.resolve(__dirname, '../src')) && process.env.USE_SRC !== 'false'; | ||
|
||
if (isLocal) { | ||
require('@backstage/cli/config/nodeTransform.cjs'); | ||
require('../src'); | ||
} else { | ||
require('../dist/index.cjs.js'); | ||
} |
9 changes: 9 additions & 0 deletions
9
workspaces/marketplace/packages/marketplace-cli/knip-report.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Knip report | ||
|
||
## Unused dependencies (3) | ||
|
||
| Name | Location | Severity | | ||
| :--------------------------------------------------------- | :----------- | :------- | | ||
| @red-hat-developer-hub/backstage-plugin-marketplace-common | package.json | error | | ||
| @backstage/catalog-model | package.json | error | | ||
| glob | package.json | error | |
45 changes: 45 additions & 0 deletions
45
workspaces/marketplace/packages/marketplace-cli/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "@red-hat-developer-hub/marketplace-cli", | ||
"description": "Marketplace cli", | ||
"version": "0.0.0", | ||
"main": "src/index.ts", | ||
"types": "src/index.ts", | ||
"license": "Apache-2.0", | ||
"private": true, | ||
"publishConfig": { | ||
"access": "public", | ||
"main": "dist/index.cjs.js", | ||
"types": "dist/index.d.ts" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/redhat-developer/rhdh-plugins", | ||
"directory": "workspaces/marketplace/packages/marketplace-cli" | ||
}, | ||
"backstage": { | ||
"role": "cli" | ||
}, | ||
"scripts": { | ||
"build": "backstage-cli package build", | ||
"lint": "backstage-cli package lint", | ||
"test": "backstage-cli package test", | ||
"clean": "backstage-cli package clean", | ||
"prepack": "backstage-cli package prepack", | ||
"postpack": "backstage-cli package postpack" | ||
}, | ||
"dependencies": { | ||
"@backstage/catalog-model": "^1.7.1", | ||
"@red-hat-developer-hub/backstage-plugin-marketplace-common": "workspace:^", | ||
"chalk": "^4.0.0", | ||
"commander": "^12.0.0", | ||
"fs-extra": "^11.2.0", | ||
"glob": "^10.4.5", | ||
"yaml": "^2.6.0" | ||
}, | ||
"devDependencies": { | ||
"@backstage/cli": "^0.28.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
} |
36 changes: 36 additions & 0 deletions
36
workspaces/marketplace/packages/marketplace-cli/src/commands/extract.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2025 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import chalk from 'chalk'; | ||
import yaml from 'yaml'; | ||
|
||
import { | ||
NPM, | ||
OCI, | ||
} from '@red-hat-developer-hub/backstage-plugin-marketplace-common'; | ||
|
||
export default async function extract(uri: string) { | ||
console.log('Extract', chalk.green(uri)); | ||
|
||
if (uri.startsWith('@')) { | ||
const plugin = await NPM.extractPlugin(uri); | ||
console.log(yaml.stringify(plugin)); | ||
} else if (OCI.isOciUri(uri)) { | ||
const plugin = await OCI.extractPlugin(uri); | ||
console.log(yaml.stringify(plugin)); | ||
} else { | ||
throw new Error('Unsupported URI'); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
workspaces/marketplace/packages/marketplace-cli/src/commands/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2025 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import chalk from 'chalk'; | ||
import { Command } from 'commander'; | ||
|
||
export function registerCommands(program: Command) { | ||
program | ||
.command('extract') | ||
.argument('<uri>', 'The URI to extract') | ||
.action(lazy(() => import('./extract').then(m => m.default))); | ||
|
||
program | ||
.command('verify') | ||
.description('Verifty a set of verify files') | ||
.argument('<files...>', 'The files to verify') | ||
// .option('-g, --glob', 'Enable glob pattern matching') | ||
.action(lazy(() => import('./verify').then(m => m.default))); | ||
} | ||
|
||
// Wraps an action function so that it always exits and handles errors | ||
function lazy( | ||
getActionFunc: () => Promise<(...args: any[]) => Promise<void>>, | ||
): (...args: any[]) => Promise<never> { | ||
return async (...args: any[]) => { | ||
try { | ||
const actionFunc = await getActionFunc(); | ||
await actionFunc(...args); | ||
|
||
process.exit(0); | ||
} catch (error) { | ||
process.stderr.write(`\n${chalk.red(`${error}`)}\n\n`); | ||
process.exit(1); | ||
} | ||
}; | ||
} |
39 changes: 39 additions & 0 deletions
39
workspaces/marketplace/packages/marketplace-cli/src/commands/verify.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2025 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
import chalk from 'chalk'; | ||
import fs from 'fs-extra'; | ||
import yaml from 'yaml'; | ||
|
||
interface Options { | ||
// TODO | ||
glob?: boolean; | ||
// TODO | ||
recursive?: boolean; | ||
} | ||
|
||
export default async function verify(files: string[], _options: Options) { | ||
for (const file of files) { | ||
const fileContent = await fs.readFile(file, 'utf8'); | ||
|
||
const data = yaml.parse(fileContent); | ||
|
||
console.log( | ||
'Found', | ||
chalk.blueBright(data.kind), | ||
chalk.green(data.metadata.name), | ||
); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
workspaces/marketplace/packages/marketplace-cli/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright 2025 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/** | ||
* Marketplace CLI | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
import { program } from 'commander'; | ||
import chalk from 'chalk'; | ||
import { version } from '../package.json'; | ||
import { registerCommands } from './commands'; | ||
|
||
const main = (argv: string[]) => { | ||
program.name('marketplace-cli').version(version); | ||
|
||
registerCommands(program); | ||
|
||
program.on('command:*', () => { | ||
console.log(); | ||
console.log(chalk.red(`Invalid command: ${program.args.join(' ')}`)); | ||
console.log(); | ||
program.outputHelp(); | ||
process.exit(1); | ||
}); | ||
|
||
program.parse(argv); | ||
}; | ||
|
||
process.on('unhandledRejection', rejection => { | ||
const error = | ||
rejection instanceof Error | ||
? rejection | ||
: new Error(`Unknown rejection: '${rejection}'`); | ||
process.stderr.write(`\n${chalk.red(`${error}`)}\n\n`); | ||
process.exit(1); | ||
}); | ||
|
||
main(process.argv); |
18 changes: 18 additions & 0 deletions
18
workspaces/marketplace/plugins/catalog-backend-module-marketplace/config.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright 2025 The Backstage Authors | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export interface Config { | ||
marketplace: {}; | ||
} |
15 changes: 15 additions & 0 deletions
15
workspaces/marketplace/plugins/catalog-backend-module-marketplace/knip-report.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Knip report | ||
|
||
## Unused dependencies (3) | ||
|
||
| Name | Location | Severity | | ||
| :--------------------------------------------------------- | :----------- | :------- | | ||
| @red-hat-developer-hub/backstage-plugin-marketplace-common | package.json | error | | ||
| express | package.json | error | | ||
| glob | package.json | error | | ||
|
||
## Unused devDependencies (1) | ||
|
||
| Name | Location | Severity | | ||
| :---------------------------- | :----------- | :------- | | ||
| @backstage/backend-test-utils | package.json | error | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.