-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
feat: update new plugin templates to include scaffolding for dynamic …
…plugins Signed-off-by: Tomas Coufal <[email protected]>
Showing
36 changed files
with
288 additions
and
76 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
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
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
Empty file.
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 @@ | ||
export interface Config {} |
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 |
---|---|---|
|
@@ -19,26 +19,52 @@ | |
"backstage": { | ||
"role": "backend-plugin-module" | ||
}, | ||
"exports": { | ||
".": "./src/index.ts", | ||
"./alpha": "./src/alpha.ts", | ||
"./package.json": "./package.json" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"alpha": [ | ||
"src/alpha.ts" | ||
], | ||
"package.json": [ | ||
"package.json" | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"start": "backstage-cli package start", | ||
"build": "backstage-cli package build", | ||
"lint": "backstage-cli package lint", | ||
"test": "backstage-cli package test", | ||
"clean": "backstage-cli package clean", | ||
"export-dynamic": "janus-cli package export-dynamic-plugin", | ||
"lint": "backstage-cli package lint", | ||
"postpack": "backstage-cli package postpack", | ||
"postversion": "yarn run export-dynamic", | ||
"prepack": "backstage-cli package prepack", | ||
"postpack": "backstage-cli package postpack" | ||
"start": "backstage-cli package start", | ||
"test": "backstage-cli package test --passWithNoTests --coverage", | ||
"tsc": "tsc" | ||
}, | ||
"dependencies": { | ||
"@backstage/backend-common": "^{{versionQuery '@backstage/backend-common'}}", | ||
"@backstage/backend-plugin-api": "^{{versionQuery '@backstage/backend-plugin-api'}}" | ||
"@backstage/backend-plugin-api": "^{{versionQuery '@backstage/backend-plugin-api'}}", | ||
"@backstage/backend-plugin-manager": "{{versionQuery '@backstage/backend-plugin-manager' 'npm:@janus-idp/[email protected]'}}" | ||
}, | ||
"devDependencies": { | ||
"@backstage/backend-test-utils": "{{versionQuery '@backstage/backend-test-utils'}}", | ||
"@backstage/cli": "{{versionQuery '@backstage/cli'}}" | ||
"@backstage/cli": "{{versionQuery '@backstage/cli'}}", | ||
"@janus-idp/cli": "{{versionQuery '@janus-idp/cli'}}" | ||
}, | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"config.d.ts", | ||
"dist-dynamic/*.*", | ||
"dist-dynamic/dist/**", | ||
"dist-dynamic/alpha/*", | ||
"app-config.janus-idp.yaml" | ||
], | ||
"configSchema": "config.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/janus-idp/backstage-plugins", | ||
|
8 changes: 8 additions & 0 deletions
8
packages/cli/templates/default-backend-module/src/dynamic/alpha.ts.hbs
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,8 @@ | ||
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; | ||
|
||
import { {{moduleVar}} } from '../module'; | ||
|
||
export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { | ||
kind: 'new', | ||
install: {{moduleVar}}, | ||
}; |
5 changes: 5 additions & 0 deletions
5
packages/cli/templates/default-backend-module/src/dynamic/index.ts.hbs
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,5 @@ | ||
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; | ||
|
||
export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { | ||
kind: 'legacy' | ||
}; |
4 changes: 2 additions & 2 deletions
4
packages/cli/templates/default-backend-module/src/index.ts.hbs
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,8 +1,8 @@ | ||
/***/ | ||
/** | ||
* The {{moduleId}} backend module for the {{pluginId}} plugin. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
export { {{moduleVar}} } from './module'; | ||
export * from './dynamic/index'; | ||
export * from './module'; |
Empty file.
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 @@ | ||
export interface Config {} |
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 |
---|---|---|
|
@@ -18,17 +18,37 @@ | |
"backstage": { | ||
"role": "backend-plugin" | ||
}, | ||
"exports": { | ||
".": "./src/index.ts", | ||
"./alpha": "./src/alpha.ts", | ||
"./package.json": "./package.json" | ||
}, | ||
"typesVersions": { | ||
"*": { | ||
"alpha": [ | ||
"src/alpha.ts" | ||
], | ||
"package.json": [ | ||
"package.json" | ||
] | ||
} | ||
}, | ||
"scripts": { | ||
"start": "backstage-cli package start", | ||
"build": "backstage-cli package build", | ||
"lint": "backstage-cli package lint", | ||
"test": "backstage-cli package test", | ||
"clean": "backstage-cli package clean", | ||
"export-dynamic": "janus-cli package export-dynamic-plugin", | ||
"lint": "backstage-cli package lint", | ||
"postpack": "backstage-cli package postpack", | ||
"postversion": "yarn run export-dynamic", | ||
"prepack": "backstage-cli package prepack", | ||
"postpack": "backstage-cli package postpack" | ||
"start": "backstage-cli package start", | ||
"test": "backstage-cli package test --passWithNoTests --coverage", | ||
"tsc": "tsc" | ||
}, | ||
"dependencies": { | ||
"@backstage/backend-common": "^{{versionQuery '@backstage/backend-common'}}", | ||
"@backstage/backend-plugin-api": "^{{versionQuery '@backstage/backend-plugin-api'}}", | ||
"@backstage/backend-plugin-manager": "{{versionQuery '@backstage/backend-plugin-manager' 'npm:@janus-idp/[email protected]'}}", | ||
"@backstage/config": "^{{versionQuery '@backstage/config'}}", | ||
"@types/express": "^{{versionQuery '@types/express' '4.17.6'}}", | ||
"express": "^{{versionQuery 'express' '4.17.1'}}", | ||
|
@@ -39,13 +59,20 @@ | |
}, | ||
"devDependencies": { | ||
"@backstage/cli": "{{versionQuery '@backstage/cli'}}", | ||
"@janus-idp/cli": "{{versionQuery '@janus-idp/cli'}}", | ||
"@types/supertest": "{{versionQuery '@types/supertest' '2.0.12'}}", | ||
"supertest": "{{versionQuery 'supertest' '6.2.4'}}", | ||
"msw": "{{versionQuery 'msw' '1.0.0'}}" | ||
}, | ||
"files": [ | ||
"dist" | ||
"dist", | ||
"config.d.ts", | ||
"dist-dynamic/*.*", | ||
"dist-dynamic/dist/**", | ||
"dist-dynamic/alpha/*", | ||
"app-config.janus-idp.yaml" | ||
], | ||
"configSchema": "config.d.ts", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/janus-idp/backstage-plugins", | ||
|
8 changes: 8 additions & 0 deletions
8
packages/cli/templates/default-backend-plugin/src/dynamic/alpha.ts.hbs
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,8 @@ | ||
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; | ||
|
||
import { {{id}}Plugin } from '../service/router'; | ||
|
||
export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { | ||
kind: 'new', | ||
install: () => [{{id}}Plugin()], | ||
}; |
10 changes: 10 additions & 0 deletions
10
packages/cli/templates/default-backend-plugin/src/dynamic/index.ts.hbs
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,10 @@ | ||
import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; | ||
import { createRouter } from '../service/router'; | ||
|
||
export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { | ||
kind: 'legacy', | ||
router: { | ||
pluginID: '{{id}}', | ||
createPlugin: createRouter, | ||
}, | ||
}; |
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
packages/cli/templates/default-backend-plugin/src/index.ts.hbs
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,8 @@ | ||
/** | ||
* The {{id}} backend plugin. | ||
* | ||
* @packageDocumentation | ||
*/ | ||
|
||
export * from './dynamic/index'; | ||
export * from './service/router'; |
24 changes: 0 additions & 24 deletions
24
packages/cli/templates/default-backend-plugin/src/service/router.ts
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
packages/cli/templates/default-backend-plugin/src/service/router.ts.hbs
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,40 @@ | ||
import { errorHandler, loggerToWinstonLogger } from '@backstage/backend-common'; | ||
import { coreServices, createBackendPlugin } from '@backstage/backend-plugin-api'; | ||
import express from 'express'; | ||
import Router from 'express-promise-router'; | ||
import { Logger } from 'winston'; | ||
|
||
export interface RouterOptions { | ||
logger: Logger; | ||
} | ||
|
||
export async function createRouter( | ||
options: RouterOptions, | ||
): Promise<express.Router> { | ||
const { logger } = options; | ||
|
||
const router = Router(); | ||
router.use(express.json()); | ||
|
||
router.get('/health', (_, response) => { | ||
logger.info('PONG!'); | ||
response.json({ status: 'ok' }); | ||
}); | ||
router.use(errorHandler()); | ||
return router; | ||
} | ||
export const {{id}}Plugin = createBackendPlugin({ | ||
pluginId: '{{id}}', | ||
register(env) { | ||
env.registerInit({ | ||
deps: { | ||
logger: coreServices.logger, | ||
config: coreServices.rootConfig, | ||
http: coreServices.httpRouter, | ||
}, | ||
async init({ config, logger, http }) { | ||
http.use(() => createRouter({...config, logger: loggerToWinstonLogger(logger)})); | ||
}, | ||
}); | ||
}, | ||
}); |
2 changes: 1 addition & 1 deletion
2
packages/cli/templates/default-backend-plugin/tsconfig.json.hbs
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
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.