From bbbefbd7a534844ee35533a62e4b626bd5b8eb4f Mon Sep 17 00:00:00 2001 From: Tom Coufal <7453394+tumido@users.noreply.github.com> Date: Wed, 24 Jan 2024 16:45:20 +0100 Subject: [PATCH] feat(cli): switch to @janus-idp/cli for new plugins and populate them with the basics (#782) * feat(cli): switch to @janus-idp/cli for new plugins and populate them with the basics Signed-off-by: Tomas Coufal * feat: update new plugin templates to include scaffolding for dynamic plugins Signed-off-by: Tomas Coufal * Update dependencies in frontend plugin templates Signed-off-by: Philipp Hugenroth * cli: bump react version in templates Signed-off-by: Patrik Oldsberg --------- Signed-off-by: Tomas Coufal Signed-off-by: Philipp Hugenroth Signed-off-by: Patrik Oldsberg Co-authored-by: Philipp Hugenroth Co-authored-by: Patrik Oldsberg --- package.json | 2 +- packages/cli/package.json | 1 + packages/cli/src/commands/index.ts | 5 +- packages/cli/src/commands/new/new.ts | 2 +- .../lib/new/factories/backendModule.test.ts | 10 ++- .../src/lib/new/factories/backendModule.ts | 9 +-- .../lib/new/factories/backendPlugin.test.ts | 14 ++-- .../src/lib/new/factories/backendPlugin.ts | 9 +-- .../lib/new/factories/common/tasks.test.ts | 4 +- .../lib/new/factories/frontendPlugin.test.ts | 15 +++-- .../src/lib/new/factories/frontendPlugin.ts | 9 +-- .../lib/new/factories/pluginCommon.test.ts | 6 +- .../cli/src/lib/new/factories/pluginCommon.ts | 4 +- .../src/lib/new/factories/pluginNode.test.ts | 6 +- .../cli/src/lib/new/factories/pluginNode.ts | 4 +- .../src/lib/new/factories/pluginWeb.test.ts | 6 +- .../cli/src/lib/new/factories/pluginWeb.ts | 4 +- .../new/factories/scaffolderModule.test.ts | 10 ++- .../src/lib/new/factories/scaffolderModule.ts | 9 +-- .../new/factories/webLibraryPackage.test.ts | 7 +- .../lib/new/factories/webLibraryPackage.ts | 2 +- packages/cli/src/lib/new/types.ts | 5 +- packages/cli/src/lib/version.test.ts | 18 ++--- packages/cli/src/lib/version.ts | 21 +++--- .../app-config.janus-idp.yaml | 0 .../default-backend-module/config.d.ts | 1 + .../default-backend-module/package.json.hbs | 55 +++++++++++++--- .../src/dynamic/alpha.ts.hbs | 8 +++ .../src/dynamic/index.ts.hbs | 5 ++ .../default-backend-module/src/index.ts.hbs | 4 +- .../default-backend-module/tsconfig.json.hbs | 9 +++ .../default-backend-module/turbo.json.hbs | 9 +++ .../app-config.janus-idp.yaml | 0 .../default-backend-plugin/config.d.ts | 1 + .../default-backend-plugin/package.json.hbs | 66 +++++++++++++++---- .../src/dynamic/alpha.ts.hbs | 8 +++ .../src/dynamic/index.ts.hbs | 10 +++ .../default-backend-plugin/src/index.ts | 1 - .../default-backend-plugin/src/index.ts.hbs | 8 +++ .../src/service/router.ts | 24 ------- .../src/service/router.ts.hbs | 40 +++++++++++ .../{tsconfig.json => tsconfig.json.hbs} | 8 +-- .../default-backend-plugin/turbo.json.hbs | 9 +++ .../package.json.hbs | 21 ++++-- .../tsconfig.json.hbs} | 2 +- .../turbo.json.hbs | 9 +++ .../package.json.hbs | 21 ++++-- .../tsconfig.json.hbs} | 2 +- .../turbo.json.hbs | 9 +++ .../app-config.janus-idp.yaml.hbs | 8 +++ .../cli/templates/default-plugin/config.d.ts | 1 + .../templates/default-plugin/package.json.hbs | 51 +++++++++----- .../{tsconfig.json => tsconfig.json.hbs} | 7 +- .../templates/default-plugin/turbo.json.hbs | 9 +++ .../package.json.hbs | 32 ++++++--- .../tsconfig.json | 11 ---- .../tsconfig.json.hbs} | 2 +- .../turbo.json.hbs | 9 +++ .../app-config.janus-idp.yaml | 0 .../templates/scaffolder-module/config.d.ts | 1 + .../scaffolder-module/package.json.hbs | 54 ++++++++++++--- .../src/dynamic/alpha.ts.hbs | 27 ++++++++ .../src/dynamic/index.ts.hbs | 7 ++ .../scaffolder-module/src/index.ts.hbs | 1 + .../{tsconfig.json => tsconfig.json.hbs} | 2 +- .../scaffolder-module/turbo.json.hbs | 9 +++ .../web-library-package/package.json.hbs | 24 +++++-- .../web-library-package/tsconfig.json | 11 ---- .../web-library-package/tsconfig.json.hbs | 9 +++ .../web-library-package/turbo.json.hbs | 9 +++ yarn.lock | 2 +- 71 files changed, 583 insertions(+), 215 deletions(-) create mode 100644 packages/cli/templates/default-backend-module/app-config.janus-idp.yaml create mode 100644 packages/cli/templates/default-backend-module/config.d.ts create mode 100644 packages/cli/templates/default-backend-module/src/dynamic/alpha.ts.hbs create mode 100644 packages/cli/templates/default-backend-module/src/dynamic/index.ts.hbs create mode 100644 packages/cli/templates/default-backend-module/tsconfig.json.hbs create mode 100644 packages/cli/templates/default-backend-module/turbo.json.hbs create mode 100644 packages/cli/templates/default-backend-plugin/app-config.janus-idp.yaml create mode 100644 packages/cli/templates/default-backend-plugin/config.d.ts create mode 100644 packages/cli/templates/default-backend-plugin/src/dynamic/alpha.ts.hbs create mode 100644 packages/cli/templates/default-backend-plugin/src/dynamic/index.ts.hbs delete mode 100644 packages/cli/templates/default-backend-plugin/src/index.ts create mode 100644 packages/cli/templates/default-backend-plugin/src/index.ts.hbs delete mode 100644 packages/cli/templates/default-backend-plugin/src/service/router.ts create mode 100644 packages/cli/templates/default-backend-plugin/src/service/router.ts.hbs rename packages/cli/templates/default-backend-plugin/{tsconfig.json => tsconfig.json.hbs} (59%) create mode 100644 packages/cli/templates/default-backend-plugin/turbo.json.hbs rename packages/cli/templates/{default-backend-module/tsconfig.json => default-common-plugin-package/tsconfig.json.hbs} (75%) create mode 100644 packages/cli/templates/default-common-plugin-package/turbo.json.hbs rename packages/cli/templates/{default-common-plugin-package/tsconfig.json => default-node-plugin-package/tsconfig.json.hbs} (75%) create mode 100644 packages/cli/templates/default-node-plugin-package/turbo.json.hbs create mode 100644 packages/cli/templates/default-plugin/app-config.janus-idp.yaml.hbs create mode 100644 packages/cli/templates/default-plugin/config.d.ts rename packages/cli/templates/default-plugin/{tsconfig.json => tsconfig.json.hbs} (63%) create mode 100644 packages/cli/templates/default-plugin/turbo.json.hbs delete mode 100644 packages/cli/templates/default-react-plugin-package/tsconfig.json rename packages/cli/templates/{default-node-plugin-package/tsconfig.json => default-react-plugin-package/tsconfig.json.hbs} (75%) create mode 100644 packages/cli/templates/default-react-plugin-package/turbo.json.hbs create mode 100644 packages/cli/templates/scaffolder-module/app-config.janus-idp.yaml create mode 100644 packages/cli/templates/scaffolder-module/config.d.ts create mode 100644 packages/cli/templates/scaffolder-module/src/dynamic/alpha.ts.hbs create mode 100644 packages/cli/templates/scaffolder-module/src/dynamic/index.ts.hbs rename packages/cli/templates/scaffolder-module/{tsconfig.json => tsconfig.json.hbs} (75%) create mode 100644 packages/cli/templates/scaffolder-module/turbo.json.hbs delete mode 100644 packages/cli/templates/web-library-package/tsconfig.json create mode 100644 packages/cli/templates/web-library-package/tsconfig.json.hbs create mode 100644 packages/cli/templates/web-library-package/turbo.json.hbs diff --git a/package.json b/package.json index 7a2437ac6b..20bb879dbf 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "lint-staged": "lint-staged", "prettier:check": "prettier --ignore-unknown --check .", "prettier:fix": "prettier --ignore-unknown --write .", - "new": "backstage-cli new --scope @janus-idp", + "new": "janus-cli new --do-not-edit-packages", "release": "multi-semantic-release", "prepare": "husky install", "versions:bump": "backstage-cli versions:bump && find . -name 'package.json' ! -path '*/node_modules/*' -exec sed -i '' -e '/devDependencies/,/\\}/{ s/\"\\^/\"/; }' {} \\;" diff --git a/packages/cli/package.json b/packages/cli/package.json index a5561a05a4..80fe0ee789 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -99,6 +99,7 @@ "@backstage/core-plugin-api": "1.7.0", "@backstage/dev-utils": "1.0.22", "@backstage/plugin-scaffolder-backend": "1.18.0", + "@backstage/plugin-scaffolder-node": "0.2.6", "@backstage/test-utils": "1.4.4", "@backstage/theme": "0.4.3", "@types/express": "4.17.20", diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index fe3b50b9af..1e3e941a5d 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -138,7 +138,6 @@ export function registerCommands(program: Command) { (opt, arr: string[]) => [...arr, opt], [], ) - .option('--scope ', 'The scope to use for new packages') .option( '--npm-registry ', 'The package registry to use for new packages', @@ -148,6 +147,10 @@ export function registerCommands(program: Command) { 'The version to use for any new packages (default: 0.1.0)', ) .option('--no-private', 'Do not mark new packages as private') + .option( + '--do-not-edit-packages', + 'Do not edit packages/app and packages/backend', + ) .action(lazy(() => import('./new/new').then(m => m.default))); registerScriptCommand(program); diff --git a/packages/cli/src/commands/new/new.ts b/packages/cli/src/commands/new/new.ts index d44901114e..67ff1350ee 100644 --- a/packages/cli/src/commands/new/new.ts +++ b/packages/cli/src/commands/new/new.ts @@ -78,13 +78,13 @@ export default async (opts: OptionValues) => { await factory.create(options, { isMonoRepo: await isMonoRepo(), defaultVersion, - scope: opts.scope?.replace(/^@/, ''), npmRegistry: opts.npmRegistry, private: Boolean(opts.private), createTemporaryDirectory, markAsModified() { modified = true; }, + doNotEditPackages: Boolean(opts.doNotEditPackages), }); Task.log(); diff --git a/packages/cli/src/lib/new/factories/backendModule.test.ts b/packages/cli/src/lib/new/factories/backendModule.test.ts index 50ace0fa95..ce2fb09e97 100644 --- a/packages/cli/src/lib/new/factories/backendModule.test.ts +++ b/packages/cli/src/lib/new/factories/backendModule.test.ts @@ -77,16 +77,22 @@ describe('backendModule factory', () => { expect(output).toEqual([ '', - 'Creating backend module backstage-plugin-test-backend-module-tester-two', + 'Creating backend module @janus-idp/backstage-plugin-test-backend-module-tester-two', 'Checking Prerequisites:', `availability plugins${sep}test-backend-module-tester-two`, 'creating temp dir', 'Executing Template:', 'copying .eslintrc.js', 'templating README.md.hbs', + 'copying app-config.janus-idp.yaml', + 'copying config.d.ts', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', 'templating index.ts.hbs', 'templating module.ts.hbs', + 'templating alpha.ts.hbs', + 'templating index.ts.hbs', 'Installing:', `moving plugins${sep}test-backend-module-tester-two`, 'backend adding dependency', @@ -96,7 +102,7 @@ describe('backendModule factory', () => { fs.readJson('/root/packages/backend/package.json'), ).resolves.toEqual({ dependencies: { - 'backstage-plugin-test-backend-module-tester-two': '^1.0.0', + '@janus-idp/backstage-plugin-test-backend-module-tester-two': '^1.0.0', }, }); const moduleFile = await fs.readFile( diff --git a/packages/cli/src/lib/new/factories/backendModule.ts b/packages/cli/src/lib/new/factories/backendModule.ts index 96c9082618..49479ac087 100644 --- a/packages/cli/src/lib/new/factories/backendModule.ts +++ b/packages/cli/src/lib/new/factories/backendModule.ts @@ -46,9 +46,7 @@ export const backendModule = createFactory({ async create(options: Options, ctx: CreateContext) { const { id: pluginId, moduleId } = options; const dirName = `${pluginId}-backend-module-${moduleId}`; - const name = ctx.scope - ? `@${ctx.scope}/plugin-${dirName}` - : `backstage-plugin-${dirName}`; + const name = `@janus-idp/backstage-plugin-${dirName}`; Task.log(); Task.log(`Creating backend module ${chalk.cyan(name)}`); @@ -75,7 +73,10 @@ export const backendModule = createFactory({ }, }); - if (await fs.pathExists(paths.resolveTargetRoot('packages/backend'))) { + if ( + !ctx.doNotEditPackages && + (await fs.pathExists(paths.resolveTargetRoot('packages/backend'))) + ) { await Task.forItem('backend', 'adding dependency', async () => { await addPackageDependency( paths.resolveTargetRoot('packages/backend/package.json'), diff --git a/packages/cli/src/lib/new/factories/backendPlugin.test.ts b/packages/cli/src/lib/new/factories/backendPlugin.test.ts index 671f085d56..8eec54f216 100644 --- a/packages/cli/src/lib/new/factories/backendPlugin.test.ts +++ b/packages/cli/src/lib/new/factories/backendPlugin.test.ts @@ -76,19 +76,25 @@ describe('backendPlugin factory', () => { expect(output).toEqual([ '', - 'Creating backend plugin backstage-plugin-test-backend', + 'Creating backend plugin @janus-idp/backstage-plugin-test-backend', 'Checking Prerequisites:', `availability plugins${sep}test-backend`, 'creating temp dir', 'Executing Template:', 'copying .eslintrc.js', 'templating README.md.hbs', + 'copying app-config.janus-idp.yaml', + 'copying config.d.ts', 'templating package.json.hbs', - 'copying index.ts', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', + 'templating index.ts.hbs', 'templating run.ts.hbs', 'copying setupTests.ts', + 'templating alpha.ts.hbs', + 'templating index.ts.hbs', 'copying router.test.ts', - 'copying router.ts', + 'templating router.ts.hbs', 'templating standaloneServer.ts.hbs', 'Installing:', `moving plugins${sep}test-backend`, @@ -99,7 +105,7 @@ describe('backendPlugin factory', () => { fs.readJson('/root/packages/backend/package.json'), ).resolves.toEqual({ dependencies: { - 'backstage-plugin-test-backend': '^1.0.0', + '@janus-idp/backstage-plugin-test-backend': '^1.0.0', }, }); const standaloneServerFile = await fs.readFile( diff --git a/packages/cli/src/lib/new/factories/backendPlugin.ts b/packages/cli/src/lib/new/factories/backendPlugin.ts index 1e4b7eba07..e78c769d89 100644 --- a/packages/cli/src/lib/new/factories/backendPlugin.ts +++ b/packages/cli/src/lib/new/factories/backendPlugin.ts @@ -41,9 +41,7 @@ export const backendPlugin = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; const pluginId = `${id}-backend`; - const name = ctx.scope - ? `@${ctx.scope}/plugin-${pluginId}` - : `backstage-plugin-${pluginId}`; + const name = `@janus-idp/backstage-plugin-${pluginId}`; Task.log(); Task.log(`Creating backend plugin ${chalk.cyan(name)}`); @@ -65,7 +63,10 @@ export const backendPlugin = createFactory({ }, }); - if (await fs.pathExists(paths.resolveTargetRoot('packages/backend'))) { + if ( + !ctx.doNotEditPackages && + (await fs.pathExists(paths.resolveTargetRoot('packages/backend'))) + ) { await Task.forItem('backend', 'adding dependency', async () => { await addPackageDependency( paths.resolveTargetRoot('packages/backend/package.json'), diff --git a/packages/cli/src/lib/new/factories/common/tasks.test.ts b/packages/cli/src/lib/new/factories/common/tasks.test.ts index 5c57b83da9..5047be6aeb 100644 --- a/packages/cli/src/lib/new/factories/common/tasks.test.ts +++ b/packages/cli/src/lib/new/factories/common/tasks.test.ts @@ -53,8 +53,8 @@ some-package@^1.1.0: {{/if}} "description": "testing", "dependencies": { - "some-package": "{{ versionQuery 'some-package' '1.3.0' }}", - "other-package": "{{ versionQuery 'other-package' '2.3.0' }}" + "some-package": "^{{ versionQuery 'some-package' '1.3.0' }}", + "other-package": "^{{ versionQuery 'other-package' '2.3.0' }}" } } `, diff --git a/packages/cli/src/lib/new/factories/frontendPlugin.test.ts b/packages/cli/src/lib/new/factories/frontendPlugin.test.ts index c5d35c1b3f..9d6fca0a98 100644 --- a/packages/cli/src/lib/new/factories/frontendPlugin.test.ts +++ b/packages/cli/src/lib/new/factories/frontendPlugin.test.ts @@ -89,14 +89,18 @@ describe('frontendPlugin factory', () => { expect(output).toEqual([ '', - 'Creating frontend plugin backstage-plugin-test', + 'Creating frontend plugin @janus-idp/backstage-plugin-test', 'Checking Prerequisites:', `availability plugins${sep}test`, 'creating temp dir', 'Executing Template:', 'copying .eslintrc.js', 'templating README.md.hbs', + 'templating app-config.janus-idp.yaml.hbs', + 'copying config.d.ts', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', 'templating index.tsx.hbs', 'templating index.ts.hbs', 'templating plugin.test.ts.hbs', @@ -119,14 +123,14 @@ describe('frontendPlugin factory', () => { fs.readJson('/root/packages/app/package.json'), ).resolves.toEqual({ dependencies: { - 'backstage-plugin-test': '^1.0.0', + '@janus-idp/backstage-plugin-test': '^1.0.0', }, }); await expect(fs.readFile('/root/packages/app/src/App.tsx', 'utf8')).resolves .toBe(` import { createApp } from '@backstage/app-defaults'; -import { TestPage } from 'backstage-plugin-test'; +import { TestPage } from '@janus-idp/backstage-plugin-test'; const router = ( @@ -176,7 +180,6 @@ const router = ( jest.spyOn(Task, 'forCommand').mockResolvedValue(); await frontendPlugin.create(options, { - scope: 'internal', private: true, isMonoRepo: true, defaultVersion: '1.0.0', @@ -188,14 +191,14 @@ const router = ( fs.readJson('/root/packages/app/package.json'), ).resolves.toEqual({ dependencies: { - '@internal/plugin-test': '^1.0.0', + '@janus-idp/backstage-plugin-test': '^1.0.0', }, }); await expect(fs.readFile('/root/packages/app/src/App.tsx', 'utf8')).resolves .toBe(` import { createApp } from '@backstage/app-defaults'; -import { TestPage } from '@internal/plugin-test'; +import { TestPage } from '@janus-idp/backstage-plugin-test'; const router = ( diff --git a/packages/cli/src/lib/new/factories/frontendPlugin.ts b/packages/cli/src/lib/new/factories/frontendPlugin.ts index 1a292526b0..664c12ff3a 100644 --- a/packages/cli/src/lib/new/factories/frontendPlugin.ts +++ b/packages/cli/src/lib/new/factories/frontendPlugin.ts @@ -42,9 +42,7 @@ export const frontendPlugin = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; - const name = ctx.scope - ? `@${ctx.scope}/plugin-${id}` - : `backstage-plugin-${id}`; + const name = `@janus-idp/backstage-plugin-${id}`; const extensionName = `${upperFirst(camelCase(id))}Page`; Task.log(); @@ -68,7 +66,10 @@ export const frontendPlugin = createFactory({ }, }); - if (await fs.pathExists(paths.resolveTargetRoot('packages/app'))) { + if ( + !ctx.doNotEditPackages && + (await fs.pathExists(paths.resolveTargetRoot('packages/app'))) + ) { await Task.forItem('app', 'adding dependency', async () => { await addPackageDependency( paths.resolveTargetRoot('packages/app/package.json'), diff --git a/packages/cli/src/lib/new/factories/pluginCommon.test.ts b/packages/cli/src/lib/new/factories/pluginCommon.test.ts index f6eb8228ab..7c45e57259 100644 --- a/packages/cli/src/lib/new/factories/pluginCommon.test.ts +++ b/packages/cli/src/lib/new/factories/pluginCommon.test.ts @@ -71,7 +71,7 @@ describe('pluginCommon factory', () => { expect(output).toEqual([ '', - 'Creating backend plugin backstage-plugin-test-common', + 'Creating backend plugin @janus-idp/backstage-plugin-test-common', 'Checking Prerequisites:', `availability plugins${sep}test-common`, 'creating temp dir', @@ -79,6 +79,8 @@ describe('pluginCommon factory', () => { 'copying .eslintrc.js', 'templating README.md.hbs', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', 'templating index.ts.hbs', 'copying setupTests.ts', 'Installing:', @@ -89,7 +91,7 @@ describe('pluginCommon factory', () => { fs.readJson('/root/plugins/test-common/package.json'), ).resolves.toEqual( expect.objectContaining({ - name: 'backstage-plugin-test-common', + name: '@janus-idp/backstage-plugin-test-common', description: 'Common functionalities for the test plugin', private: true, version: '1.0.0', diff --git a/packages/cli/src/lib/new/factories/pluginCommon.ts b/packages/cli/src/lib/new/factories/pluginCommon.ts index 16026d5591..c2b71b9db8 100644 --- a/packages/cli/src/lib/new/factories/pluginCommon.ts +++ b/packages/cli/src/lib/new/factories/pluginCommon.ts @@ -39,9 +39,7 @@ export const pluginCommon = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; const suffix = `${id}-common`; - const name = ctx.scope - ? `@${ctx.scope}/plugin-${suffix}` - : `backstage-plugin-${suffix}`; + const name = `@janus-idp/backstage-plugin-${suffix}`; Task.log(); Task.log(`Creating backend plugin ${chalk.cyan(name)}`); diff --git a/packages/cli/src/lib/new/factories/pluginNode.test.ts b/packages/cli/src/lib/new/factories/pluginNode.test.ts index 1ac741a726..62178a1287 100644 --- a/packages/cli/src/lib/new/factories/pluginNode.test.ts +++ b/packages/cli/src/lib/new/factories/pluginNode.test.ts @@ -71,7 +71,7 @@ describe('pluginNode factory', () => { expect(output).toEqual([ '', - 'Creating Node.js plugin library backstage-plugin-test-node', + 'Creating Node.js plugin library @janus-idp/backstage-plugin-test-node', 'Checking Prerequisites:', `availability plugins${sep}test-node`, 'creating temp dir', @@ -79,6 +79,8 @@ describe('pluginNode factory', () => { 'copying .eslintrc.js', 'templating README.md.hbs', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', 'templating index.ts.hbs', 'copying setupTests.ts', 'Installing:', @@ -89,7 +91,7 @@ describe('pluginNode factory', () => { fs.readJson('/root/plugins/test-node/package.json'), ).resolves.toEqual( expect.objectContaining({ - name: 'backstage-plugin-test-node', + name: '@janus-idp/backstage-plugin-test-node', description: 'Node.js library for the test plugin', private: true, version: '1.0.0', diff --git a/packages/cli/src/lib/new/factories/pluginNode.ts b/packages/cli/src/lib/new/factories/pluginNode.ts index 0f92591d85..7474349b62 100644 --- a/packages/cli/src/lib/new/factories/pluginNode.ts +++ b/packages/cli/src/lib/new/factories/pluginNode.ts @@ -39,9 +39,7 @@ export const pluginNode = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; const suffix = `${id}-node`; - const name = ctx.scope - ? `@${ctx.scope}/plugin-${suffix}` - : `backstage-plugin-${suffix}`; + const name = `@janus-idp/backstage-plugin-${suffix}`; Task.log(); Task.log(`Creating Node.js plugin library ${chalk.cyan(name)}`); diff --git a/packages/cli/src/lib/new/factories/pluginWeb.test.ts b/packages/cli/src/lib/new/factories/pluginWeb.test.ts index a8d8584885..1a2d2ccb97 100644 --- a/packages/cli/src/lib/new/factories/pluginWeb.test.ts +++ b/packages/cli/src/lib/new/factories/pluginWeb.test.ts @@ -71,7 +71,7 @@ describe('pluginWeb factory', () => { expect(output).toEqual([ '', - 'Creating web plugin library backstage-plugin-test-react', + 'Creating web plugin library @janus-idp/backstage-plugin-test-react', 'Checking Prerequisites:', `availability plugins${sep}test-react`, 'creating temp dir', @@ -79,6 +79,8 @@ describe('pluginWeb factory', () => { 'copying .eslintrc.js', 'templating README.md.hbs', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', 'templating index.ts.hbs', 'copying setupTests.ts', 'copying index.ts', @@ -96,7 +98,7 @@ describe('pluginWeb factory', () => { fs.readJson('/root/plugins/test-react/package.json'), ).resolves.toEqual( expect.objectContaining({ - name: 'backstage-plugin-test-react', + name: '@janus-idp/backstage-plugin-test-react', description: 'Web library for the test plugin', private: true, version: '1.0.0', diff --git a/packages/cli/src/lib/new/factories/pluginWeb.ts b/packages/cli/src/lib/new/factories/pluginWeb.ts index be1acb9299..134b10fd0c 100644 --- a/packages/cli/src/lib/new/factories/pluginWeb.ts +++ b/packages/cli/src/lib/new/factories/pluginWeb.ts @@ -39,9 +39,7 @@ export const pluginWeb = createFactory({ async create(options: Options, ctx: CreateContext) { const { id } = options; const suffix = `${id}-react`; - const name = ctx.scope - ? `@${ctx.scope}/plugin-${suffix}` - : `backstage-plugin-${suffix}`; + const name = `@janus-idp/backstage-plugin-${suffix}`; Task.log(); Task.log(`Creating web plugin library ${chalk.cyan(name)}`); diff --git a/packages/cli/src/lib/new/factories/scaffolderModule.test.ts b/packages/cli/src/lib/new/factories/scaffolderModule.test.ts index db30e4ebc6..11af2463a4 100644 --- a/packages/cli/src/lib/new/factories/scaffolderModule.test.ts +++ b/packages/cli/src/lib/new/factories/scaffolderModule.test.ts @@ -71,14 +71,20 @@ describe('scaffolderModule factory', () => { expect(output).toEqual([ '', - 'Creating module backstage-plugin-scaffolder-backend-module-test', + 'Creating module @janus-idp/backstage-plugin-scaffolder-backend-module-test', 'Checking Prerequisites:', `availability plugins${sep}scaffolder-backend-module-test`, 'creating temp dir', 'Executing Template:', 'copying .eslintrc.js', 'templating README.md.hbs', + 'copying app-config.janus-idp.yaml', + 'copying config.d.ts', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', + 'templating index.ts.hbs', + 'templating alpha.ts.hbs', 'templating index.ts.hbs', 'copying index.ts', 'copying example.test.ts', @@ -92,7 +98,7 @@ describe('scaffolderModule factory', () => { fs.readJson('/root/plugins/scaffolder-backend-module-test/package.json'), ).resolves.toEqual( expect.objectContaining({ - name: 'backstage-plugin-scaffolder-backend-module-test', + name: '@janus-idp/backstage-plugin-scaffolder-backend-module-test', description: 'The test module for @backstage/plugin-scaffolder-backend', private: true, version: '1.0.0', diff --git a/packages/cli/src/lib/new/factories/scaffolderModule.ts b/packages/cli/src/lib/new/factories/scaffolderModule.ts index eeee845f57..56cef4b142 100644 --- a/packages/cli/src/lib/new/factories/scaffolderModule.ts +++ b/packages/cli/src/lib/new/factories/scaffolderModule.ts @@ -56,14 +56,7 @@ export const scaffolderModule = createFactory({ const { id } = options; const slug = `scaffolder-backend-module-${id}`; - let name = `backstage-plugin-${slug}`; - if (ctx.scope) { - if (ctx.scope === 'backstage') { - name = `@backstage/plugin-${slug}`; - } else { - name = `@${ctx.scope}/backstage-plugin-${slug}`; - } - } + const name = `@janus-idp/backstage-plugin-${slug}`; Task.log(); Task.log(`Creating module ${chalk.cyan(name)}`); diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts index cf06f4322a..0f8bbf304d 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.test.ts @@ -73,7 +73,7 @@ describe('webLibraryPackage factory', () => { expect(output).toEqual([ '', - `Creating web-library package ${expectedwebLibraryPackageName}`, + `Creating web-library package @janus-idp/backstage-${expectedwebLibraryPackageName}`, 'Checking Prerequisites:', `availability ${joinPath('packages', expectedwebLibraryPackageName)}`, 'creating temp dir', @@ -81,6 +81,8 @@ describe('webLibraryPackage factory', () => { 'copying .eslintrc.js', 'templating README.md.hbs', 'templating package.json.hbs', + 'templating tsconfig.json.hbs', + 'templating turbo.json.hbs', 'templating index.ts.hbs', 'copying setupTests.ts', 'Installing:', @@ -93,7 +95,7 @@ describe('webLibraryPackage factory', () => { ), ).resolves.toEqual( expect.objectContaining({ - name: expectedwebLibraryPackageName, + name: `@janus-idp/backstage-${expectedwebLibraryPackageName}`, private: true, version: '1.0.0', }), @@ -133,7 +135,6 @@ describe('webLibraryPackage factory', () => { jest.spyOn(Task, 'forCommand').mockResolvedValue(); await webLibraryPackage.create(options, { - scope: 'internal', private: true, isMonoRepo: false, defaultVersion: '1.0.0', diff --git a/packages/cli/src/lib/new/factories/webLibraryPackage.ts b/packages/cli/src/lib/new/factories/webLibraryPackage.ts index 61fe6a3bee..7f0a66711e 100644 --- a/packages/cli/src/lib/new/factories/webLibraryPackage.ts +++ b/packages/cli/src/lib/new/factories/webLibraryPackage.ts @@ -38,7 +38,7 @@ export const webLibraryPackage = createFactory({ optionsPrompts: [pluginIdPrompt(), ownerPrompt()], async create(options: Options, ctx: CreateContext) { const { id } = options; - const name = ctx.scope ? `@${ctx.scope}/${id}` : `${id}`; + const name = `@janus-idp/backstage-${id}`; Task.log(); Task.log(`Creating web-library package ${chalk.cyan(name)}`); diff --git a/packages/cli/src/lib/new/types.ts b/packages/cli/src/lib/new/types.ts index 6a894bf9ef..c2d2618d80 100644 --- a/packages/cli/src/lib/new/types.ts +++ b/packages/cli/src/lib/new/types.ts @@ -17,8 +17,6 @@ import { Answers, DistinctQuestion } from 'inquirer'; export interface CreateContext { - /** The package scope to use for new packages */ - scope?: string; /** The NPM registry to use for new packages */ npmRegistry?: string; /** Whether new packages should be marked as private */ @@ -33,6 +31,9 @@ export interface CreateContext { /** Signal that the creation process got to a point where permanent modifications were made */ markAsModified(): void; + + /** Specify if the processing should edit packages/app and packages/backend or if the plugin should be created as standalone */ + doNotEditPackages?: boolean; } export type AnyOptions = Record; diff --git a/packages/cli/src/lib/version.test.ts b/packages/cli/src/lib/version.test.ts index 8f752691ea..7815a5fbc5 100644 --- a/packages/cli/src/lib/version.test.ts +++ b/packages/cli/src/lib/version.test.ts @@ -60,22 +60,22 @@ describe('createPackageVersionProvider', () => { const lockfile = await Lockfile.load('yarn.lock'); const provider = createPackageVersionProvider(lockfile); - expect(provider('a', '0.1.5')).toBe('^0.1.0'); + expect(provider('a', '0.1.5')).toBe('0.1.0'); expect(provider('b', '1.0.0')).toBe('*'); - expect(provider('c', '0.1.0')).toBe('^0.1.0'); - expect(provider('c', '0.1.6')).toBe('^0.1.4'); - expect(provider('c', '0.2.0')).toBe('^0.2.0'); - expect(provider('c', '0.2.6')).toBe('^0.2.4'); + expect(provider('c', '0.1.0')).toBe('0.1.0'); + expect(provider('c', '0.1.6')).toBe('0.1.4'); + expect(provider('c', '0.2.0')).toBe('0.2.0'); + expect(provider('c', '0.2.6')).toBe('0.2.4'); expect(provider('c', '0.3.0-rc1')).toBe('0.3.0-rc1'); - expect(provider('c', '0.3.0')).toBe('^0.3.0'); - expect(provider('c', '0.3.6')).toBe('^0.3.4'); + expect(provider('c', '0.3.0')).toBe('0.3.0'); + expect(provider('c', '0.3.6')).toBe('0.3.4'); const cliVersion = packageVersions['@backstage/cli']; expect(provider('@backstage/cli')).toBe( // If we're currently in pre-release we expect that to be picked instead - cliVersion.includes('-') ? `^${cliVersion}` : '*', + cliVersion.includes('-') ? `${cliVersion}` : '*', ); expect(provider('@backstage/core-plugin-api')).toBe( - `^${corePluginApiPkg.version}`, + `${corePluginApiPkg.version}`, ); expect(provider('@types/t', '1.4.2')).toBe('*'); }); diff --git a/packages/cli/src/lib/version.ts b/packages/cli/src/lib/version.ts index db68ad53b3..81dd8b0562 100644 --- a/packages/cli/src/lib/version.ts +++ b/packages/cli/src/lib/version.ts @@ -36,6 +36,13 @@ import Manifest from '../../package.json'; import { paths } from './paths'; import { Lockfile } from './versioning'; +export function findVersion() { + const pkgContent = fs.readFileSync(paths.resolveOwn('package.json'), 'utf8'); + return JSON.parse(pkgContent).version; +} + +export const version = findVersion(); + export const packageVersions: Record = { ...Object.fromEntries( Object.entries(Manifest.devDependencies as Record).filter( @@ -47,15 +54,9 @@ export const packageVersions: Record = { ([k, _v]) => k.startsWith('@backstage/'), ), ), + '@janus-idp/cli': version, }; -export function findVersion() { - const pkgContent = fs.readFileSync(paths.resolveOwn('package.json'), 'utf8'); - return JSON.parse(pkgContent).version; -} - -export const version = findVersion(); - export function createPackageVersionProvider(lockfile?: Lockfile) { return (name: string, versionHint?: string): string => { const packageVersion = packageVersions[name]; @@ -85,14 +86,14 @@ export function createPackageVersionProvider(lockfile?: Lockfile) { const highestRange = validRanges?.slice(-1)[0]; if (highestRange?.range) { - return highestRange?.range; + return highestRange?.range.replace(/^\^/, ''); } if (packageVersion) { - return `^${packageVersion}`; + return packageVersion.replace(/^\^/, ''); } if (semver.parse(versionHint)?.prerelease.length) { return versionHint!; } - return versionHint?.match(/^[\d\.]+$/) ? `^${versionHint}` : versionHint!; + return versionHint!.replace(/^\^/, ''); }; } diff --git a/packages/cli/templates/default-backend-module/app-config.janus-idp.yaml b/packages/cli/templates/default-backend-module/app-config.janus-idp.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/cli/templates/default-backend-module/config.d.ts b/packages/cli/templates/default-backend-module/config.d.ts new file mode 100644 index 0000000000..5728ccd9e1 --- /dev/null +++ b/packages/cli/templates/default-backend-module/config.d.ts @@ -0,0 +1 @@ +export interface Config {} diff --git a/packages/cli/templates/default-backend-module/package.json.hbs b/packages/cli/templates/default-backend-module/package.json.hbs index 07eee73d50..fe2a00f9f2 100644 --- a/packages/cli/templates/default-backend-module/package.json.hbs +++ b/packages/cli/templates/default-backend-module/package.json.hbs @@ -19,24 +19,61 @@ "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-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/backend-plugin-manager@0.0.2-janus.5'}}" }, "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", + "directory": "plugins/{{pluginId}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/default-backend-module/src/dynamic/alpha.ts.hbs b/packages/cli/templates/default-backend-module/src/dynamic/alpha.ts.hbs new file mode 100644 index 0000000000..49751f95b8 --- /dev/null +++ b/packages/cli/templates/default-backend-module/src/dynamic/alpha.ts.hbs @@ -0,0 +1,8 @@ +import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; + +import { {{moduleVar}} } from '../module'; + +export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { + kind: 'new', + install: {{moduleVar}}, +}; diff --git a/packages/cli/templates/default-backend-module/src/dynamic/index.ts.hbs b/packages/cli/templates/default-backend-module/src/dynamic/index.ts.hbs new file mode 100644 index 0000000000..78e10158fe --- /dev/null +++ b/packages/cli/templates/default-backend-module/src/dynamic/index.ts.hbs @@ -0,0 +1,5 @@ +import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; + +export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { + kind: 'legacy' +}; diff --git a/packages/cli/templates/default-backend-module/src/index.ts.hbs b/packages/cli/templates/default-backend-module/src/index.ts.hbs index 0cf1f00d42..ab57d913b6 100644 --- a/packages/cli/templates/default-backend-module/src/index.ts.hbs +++ b/packages/cli/templates/default-backend-module/src/index.ts.hbs @@ -1,8 +1,8 @@ -/***/ /** * The {{moduleId}} backend module for the {{pluginId}} plugin. * * @packageDocumentation */ -export { {{moduleVar}} } from './module'; +export * from './dynamic/index'; +export * from './module'; diff --git a/packages/cli/templates/default-backend-module/tsconfig.json.hbs b/packages/cli/templates/default-backend-module/tsconfig.json.hbs new file mode 100644 index 0000000000..0c73db7944 --- /dev/null +++ b/packages/cli/templates/default-backend-module/tsconfig.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": "@backstage/cli/config/tsconfig.json", + "include": ["src"], + "exclude": ["node_modules"], + "compilerOptions": { + "outDir": "../../dist-types/plugins/{{pluginId}}", + "rootDir": "." + } +} diff --git a/packages/cli/templates/default-backend-module/turbo.json.hbs b/packages/cli/templates/default-backend-module/turbo.json.hbs new file mode 100644 index 0000000000..28551b0622 --- /dev/null +++ b/packages/cli/templates/default-backend-module/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{pluginId}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/default-backend-plugin/app-config.janus-idp.yaml b/packages/cli/templates/default-backend-plugin/app-config.janus-idp.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/cli/templates/default-backend-plugin/config.d.ts b/packages/cli/templates/default-backend-plugin/config.d.ts new file mode 100644 index 0000000000..5728ccd9e1 --- /dev/null +++ b/packages/cli/templates/default-backend-plugin/config.d.ts @@ -0,0 +1 @@ +export interface Config {} diff --git a/packages/cli/templates/default-backend-plugin/package.json.hbs b/packages/cli/templates/default-backend-plugin/package.json.hbs index 2b860260ac..b51b724eb4 100644 --- a/packages/cli/templates/default-backend-plugin/package.json.hbs +++ b/packages/cli/templates/default-backend-plugin/package.json.hbs @@ -18,32 +18,70 @@ "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/config": "{{versionQuery '@backstage/config'}}", - "@types/express": "{{versionQuery '@types/express' '4.17.6'}}", - "express": "{{versionQuery 'express' '4.17.1'}}", - "express-promise-router": "{{versionQuery 'express-promise-router' '4.1.0'}}", - "winston": "{{versionQuery 'winston' '3.2.1'}}", - "node-fetch": "{{versionQuery 'node-fetch' '2.6.7'}}", - "yn": "{{versionQuery 'yn' '4.0.0'}}" + "@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/backend-plugin-manager@0.0.2-janus.5'}}", + "@backstage/config": "^{{versionQuery '@backstage/config'}}", + "@types/express": "^{{versionQuery '@types/express' '4.17.6'}}", + "express": "^{{versionQuery 'express' '4.17.1'}}", + "express-promise-router": "^{{versionQuery 'express-promise-router' '4.1.0'}}", + "winston": "^{{versionQuery 'winston' '3.2.1'}}", + "node-fetch": "^{{versionQuery 'node-fetch' '2.6.7'}}", + "yn": "^{{versionQuery 'yn' '4.0.0'}}" }, "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", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/default-backend-plugin/src/dynamic/alpha.ts.hbs b/packages/cli/templates/default-backend-plugin/src/dynamic/alpha.ts.hbs new file mode 100644 index 0000000000..6e1ee58f39 --- /dev/null +++ b/packages/cli/templates/default-backend-plugin/src/dynamic/alpha.ts.hbs @@ -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()], +}; diff --git a/packages/cli/templates/default-backend-plugin/src/dynamic/index.ts.hbs b/packages/cli/templates/default-backend-plugin/src/dynamic/index.ts.hbs new file mode 100644 index 0000000000..118e8d0a22 --- /dev/null +++ b/packages/cli/templates/default-backend-plugin/src/dynamic/index.ts.hbs @@ -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, + }, +}; diff --git a/packages/cli/templates/default-backend-plugin/src/index.ts b/packages/cli/templates/default-backend-plugin/src/index.ts deleted file mode 100644 index 47af95cb35..0000000000 --- a/packages/cli/templates/default-backend-plugin/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './service/router'; diff --git a/packages/cli/templates/default-backend-plugin/src/index.ts.hbs b/packages/cli/templates/default-backend-plugin/src/index.ts.hbs new file mode 100644 index 0000000000..b1c735bca6 --- /dev/null +++ b/packages/cli/templates/default-backend-plugin/src/index.ts.hbs @@ -0,0 +1,8 @@ +/** + * The {{id}} backend plugin. + * + * @packageDocumentation + */ + +export * from './dynamic/index'; +export * from './service/router'; diff --git a/packages/cli/templates/default-backend-plugin/src/service/router.ts b/packages/cli/templates/default-backend-plugin/src/service/router.ts deleted file mode 100644 index c15bac5892..0000000000 --- a/packages/cli/templates/default-backend-plugin/src/service/router.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { errorHandler } from '@backstage/backend-common'; -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 { - 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; -} diff --git a/packages/cli/templates/default-backend-plugin/src/service/router.ts.hbs b/packages/cli/templates/default-backend-plugin/src/service/router.ts.hbs new file mode 100644 index 0000000000..aac2a0049c --- /dev/null +++ b/packages/cli/templates/default-backend-plugin/src/service/router.ts.hbs @@ -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 { + 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)})); + }, + }); + }, +}); diff --git a/packages/cli/templates/default-backend-plugin/tsconfig.json b/packages/cli/templates/default-backend-plugin/tsconfig.json.hbs similarity index 59% rename from packages/cli/templates/default-backend-plugin/tsconfig.json rename to packages/cli/templates/default-backend-plugin/tsconfig.json.hbs index d77f0fe3b4..a05b388c2b 100644 --- a/packages/cli/templates/default-backend-plugin/tsconfig.json +++ b/packages/cli/templates/default-backend-plugin/tsconfig.json.hbs @@ -1,13 +1,9 @@ { "extends": "@backstage/cli/config/tsconfig.json", - "include": [ - "src", - "dev", - "migrations" - ], + "include": ["src", "dev", "migrations"], "exclude": ["node_modules"], "compilerOptions": { - "outDir": "dist-types", + "outDir": "../../dist-types/plugins/{{id}}", "rootDir": "." } } diff --git a/packages/cli/templates/default-backend-plugin/turbo.json.hbs b/packages/cli/templates/default-backend-plugin/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/default-backend-plugin/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/default-common-plugin-package/package.json.hbs b/packages/cli/templates/default-common-plugin-package/package.json.hbs index 992599ef6d..0555f24f26 100644 --- a/packages/cli/templates/default-common-plugin-package/package.json.hbs +++ b/packages/cli/templates/default-common-plugin-package/package.json.hbs @@ -23,16 +23,29 @@ "sideEffects": false, "scripts": { "build": "backstage-cli package build", - "lint": "backstage-cli package lint", - "test": "backstage-cli package test", "clean": "backstage-cli package clean", + "lint": "backstage-cli package lint", + "postpack": "backstage-cli package postpack", "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" + "start": "backstage-cli package start", + "test": "backstage-cli package test --passWithNoTests --coverage", + "tsc": "tsc" }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}" }, "files": [ "dist" - ] + ], + "repository": { + "type": "git", + "url": "https://github.com/janus-idp/backstage-plugins", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/default-backend-module/tsconfig.json b/packages/cli/templates/default-common-plugin-package/tsconfig.json.hbs similarity index 75% rename from packages/cli/templates/default-backend-module/tsconfig.json rename to packages/cli/templates/default-common-plugin-package/tsconfig.json.hbs index 5ae9aeb62d..76ad8cc243 100644 --- a/packages/cli/templates/default-backend-module/tsconfig.json +++ b/packages/cli/templates/default-common-plugin-package/tsconfig.json.hbs @@ -3,7 +3,7 @@ "include": ["src"], "exclude": ["node_modules"], "compilerOptions": { - "outDir": "dist-types", + "outDir": "../../dist-types/plugins/{{id}}", "rootDir": "." } } diff --git a/packages/cli/templates/default-common-plugin-package/turbo.json.hbs b/packages/cli/templates/default-common-plugin-package/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/default-common-plugin-package/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/default-node-plugin-package/package.json.hbs b/packages/cli/templates/default-node-plugin-package/package.json.hbs index 45becd1bea..177003768b 100644 --- a/packages/cli/templates/default-node-plugin-package/package.json.hbs +++ b/packages/cli/templates/default-node-plugin-package/package.json.hbs @@ -21,16 +21,29 @@ }, "scripts": { "build": "backstage-cli package build", - "lint": "backstage-cli package lint", - "test": "backstage-cli package test", "clean": "backstage-cli package clean", + "lint": "backstage-cli package lint", + "postpack": "backstage-cli package postpack", "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" + "start": "backstage-cli package start", + "test": "backstage-cli package test --passWithNoTests --coverage", + "tsc": "tsc" }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}" }, "files": [ "dist" - ] + ], + "repository": { + "type": "git", + "url": "https://github.com/janus-idp/backstage-plugins", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/default-common-plugin-package/tsconfig.json b/packages/cli/templates/default-node-plugin-package/tsconfig.json.hbs similarity index 75% rename from packages/cli/templates/default-common-plugin-package/tsconfig.json rename to packages/cli/templates/default-node-plugin-package/tsconfig.json.hbs index 5ae9aeb62d..76ad8cc243 100644 --- a/packages/cli/templates/default-common-plugin-package/tsconfig.json +++ b/packages/cli/templates/default-node-plugin-package/tsconfig.json.hbs @@ -3,7 +3,7 @@ "include": ["src"], "exclude": ["node_modules"], "compilerOptions": { - "outDir": "dist-types", + "outDir": "../../dist-types/plugins/{{id}}", "rootDir": "." } } diff --git a/packages/cli/templates/default-node-plugin-package/turbo.json.hbs b/packages/cli/templates/default-node-plugin-package/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/default-node-plugin-package/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/default-plugin/app-config.janus-idp.yaml.hbs b/packages/cli/templates/default-plugin/app-config.janus-idp.yaml.hbs new file mode 100644 index 0000000000..5ff6dcb6b8 --- /dev/null +++ b/packages/cli/templates/default-plugin/app-config.janus-idp.yaml.hbs @@ -0,0 +1,8 @@ +dynamicPlugins: + frontend: + janus-idp.backstage-plugin-{{id}}: + apiFactories: [] + appIcons: [] + dynamicRoutes: [] + mountPoints: [] + routeBindings: [] diff --git a/packages/cli/templates/default-plugin/config.d.ts b/packages/cli/templates/default-plugin/config.d.ts new file mode 100644 index 0000000000..5728ccd9e1 --- /dev/null +++ b/packages/cli/templates/default-plugin/config.d.ts @@ -0,0 +1 @@ +export interface Config {} diff --git a/packages/cli/templates/default-plugin/package.json.hbs b/packages/cli/templates/default-plugin/package.json.hbs index 011a50ba37..256aa600c9 100644 --- a/packages/cli/templates/default-plugin/package.json.hbs +++ b/packages/cli/templates/default-plugin/package.json.hbs @@ -20,37 +20,56 @@ }, "sideEffects": false, "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/core-components": "{{versionQuery '@backstage/core-components'}}", - "@backstage/core-plugin-api": "{{versionQuery '@backstage/core-plugin-api'}}", - "@backstage/theme": "{{versionQuery '@backstage/theme'}}", - "@material-ui/core": "{{versionQuery '@material-ui/core' '4.12.2'}}", - "@material-ui/icons": "{{versionQuery '@material-ui/icons' '4.9.1'}}", - "@material-ui/lab": "{{versionQuery '@material-ui/lab' '4.0.0-alpha.61'}}", - "react-use": "{{versionQuery 'react-use' '17.2.4'}}" + "@backstage/core-components": "^{{versionQuery '@backstage/core-components'}}", + "@backstage/core-plugin-api": "^{{versionQuery '@backstage/core-plugin-api'}}", + "@backstage/theme": "^{{versionQuery '@backstage/theme'}}", + "@material-ui/core": "^{{versionQuery '@material-ui/core' '4.12.2'}}", + "@material-ui/icons": "^{{versionQuery '@material-ui/icons' '4.9.1'}}", + "@material-ui/lab": "^{{versionQuery '@material-ui/lab' '4.0.0-alpha.61'}}", + "react-use": "^{{versionQuery 'react-use' '17.2.4'}}" }, "peerDependencies": { - "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0'}}" + "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0 || ^18.0.0'}}" }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}", "@backstage/core-app-api": "{{versionQuery '@backstage/core-app-api'}}", "@backstage/dev-utils": "{{versionQuery '@backstage/dev-utils'}}", "@backstage/test-utils": "{{versionQuery '@backstage/test-utils'}}", - "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", - "@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}", + "@janus-idp/cli": "{{versionQuery '@janus-idp/cli'}}", + "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '6.0.0'}}", + "@testing-library/react": "{{versionQuery '@testing-library/react' '14.0.0'}}", "@testing-library/user-event": "{{versionQuery '@testing-library/user-event' '14.0.0'}}", "msw": "{{versionQuery 'msw' '1.0.0'}}" }, "files": [ - "dist" - ] + "dist", + "config.d.ts", + "dist-scalprum", + "app-config.janus-idp.yaml" + ], + "configSchema": "config.d.ts", + "repository": { + "type": "git", + "url": "https://github.com/janus-idp/backstage-plugins", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/default-plugin/tsconfig.json b/packages/cli/templates/default-plugin/tsconfig.json.hbs similarity index 63% rename from packages/cli/templates/default-plugin/tsconfig.json rename to packages/cli/templates/default-plugin/tsconfig.json.hbs index b61e496175..df293ab0ce 100644 --- a/packages/cli/templates/default-plugin/tsconfig.json +++ b/packages/cli/templates/default-plugin/tsconfig.json.hbs @@ -1,12 +1,9 @@ { "extends": "@backstage/cli/config/tsconfig.json", - "include": [ - "src", - "dev" - ], + "include": ["src", "dev"], "exclude": ["node_modules"], "compilerOptions": { - "outDir": "dist-types", + "outDir": "../../dist-types/plugins/{{id}}", "rootDir": "." } } diff --git a/packages/cli/templates/default-plugin/turbo.json.hbs b/packages/cli/templates/default-plugin/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/default-plugin/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/default-react-plugin-package/package.json.hbs b/packages/cli/templates/default-react-plugin-package/package.json.hbs index 230ecc5f03..35afbcb2e3 100644 --- a/packages/cli/templates/default-react-plugin-package/package.json.hbs +++ b/packages/cli/templates/default-react-plugin-package/package.json.hbs @@ -21,28 +21,40 @@ }, "sideEffects": false, "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", + "lint": "backstage-cli package lint", + "postpack": "backstage-cli package postpack", "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/core-plugin-api": "{{versionQuery '@backstage/core-plugin-api'}}", - "@material-ui/core": "{{versionQuery '@material-ui/core' '4.12.2'}}" + "@backstage/core-plugin-api": "^{{versionQuery '@backstage/core-plugin-api'}}", + "@material-ui/core": "^{{versionQuery '@material-ui/core' '4.12.2'}}" }, "peerDependencies": { - "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0'}}" + "react": "{{versionQuery 'react' '^16.13.1 || ^17.0.0 || ^18.0.0'}}" }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}", "@backstage/test-utils": "{{versionQuery '@backstage/test-utils'}}", - "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}", - "@testing-library/react": "{{versionQuery '@testing-library/react' '12.1.3'}}" + "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '6.0.0'}}", + "@testing-library/react": "{{versionQuery '@testing-library/react' '14.0.0'}}" }, "files": [ "dist" - ] + ], + "repository": { + "type": "git", + "url": "https://github.com/janus-idp/backstage-plugins", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/default-react-plugin-package/tsconfig.json b/packages/cli/templates/default-react-plugin-package/tsconfig.json deleted file mode 100644 index ce3409d31f..0000000000 --- a/packages/cli/templates/default-react-plugin-package/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "@backstage/cli/config/tsconfig.json", - "include": [ - "src", - ], - "exclude": ["node_modules"], - "compilerOptions": { - "outDir": "dist-types", - "rootDir": "." - } -} diff --git a/packages/cli/templates/default-node-plugin-package/tsconfig.json b/packages/cli/templates/default-react-plugin-package/tsconfig.json.hbs similarity index 75% rename from packages/cli/templates/default-node-plugin-package/tsconfig.json rename to packages/cli/templates/default-react-plugin-package/tsconfig.json.hbs index 5ae9aeb62d..76ad8cc243 100644 --- a/packages/cli/templates/default-node-plugin-package/tsconfig.json +++ b/packages/cli/templates/default-react-plugin-package/tsconfig.json.hbs @@ -3,7 +3,7 @@ "include": ["src"], "exclude": ["node_modules"], "compilerOptions": { - "outDir": "dist-types", + "outDir": "../../dist-types/plugins/{{id}}", "rootDir": "." } } diff --git a/packages/cli/templates/default-react-plugin-package/turbo.json.hbs b/packages/cli/templates/default-react-plugin-package/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/default-react-plugin-package/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/scaffolder-module/app-config.janus-idp.yaml b/packages/cli/templates/scaffolder-module/app-config.janus-idp.yaml new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/cli/templates/scaffolder-module/config.d.ts b/packages/cli/templates/scaffolder-module/config.d.ts new file mode 100644 index 0000000000..5728ccd9e1 --- /dev/null +++ b/packages/cli/templates/scaffolder-module/config.d.ts @@ -0,0 +1 @@ +export interface Config {} diff --git a/packages/cli/templates/scaffolder-module/package.json.hbs b/packages/cli/templates/scaffolder-module/package.json.hbs index 618e953b74..fcad533e21 100644 --- a/packages/cli/templates/scaffolder-module/package.json.hbs +++ b/packages/cli/templates/scaffolder-module/package.json.hbs @@ -19,23 +19,61 @@ "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/plugin-scaffolder-backend": "{{versionQuery '@backstage/plugin-scaffolder-backend'}}" + "@backstage/plugin-scaffolder-backend": "^{{versionQuery '@backstage/plugin-scaffolder-backend'}}", + "@backstage/backend-plugin-api": "^{{versionQuery '@backstage/backend-plugin-api'}}", + "@backstage/backend-plugin-manager": "{{versionQuery '@backstage/backend-plugin-manager' 'npm:@janus-idp/backend-plugin-manager@0.0.2-janus.5'}}", + "@backstage/plugin-scaffolder-node": "^{{versionQuery '@backstage/plugin-scaffolder-node'}}" }, "devDependencies": { "@backstage/backend-common": "{{versionQuery '@backstage/backend-common'}}", - "@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", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/" } diff --git a/packages/cli/templates/scaffolder-module/src/dynamic/alpha.ts.hbs b/packages/cli/templates/scaffolder-module/src/dynamic/alpha.ts.hbs new file mode 100644 index 0000000000..c9681aa11f --- /dev/null +++ b/packages/cli/templates/scaffolder-module/src/dynamic/alpha.ts.hbs @@ -0,0 +1,27 @@ +import { + coreServices, + createBackendModule, +} from '@backstage/backend-plugin-api'; +import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; +import { scaffolderActionsExtensionPoint } from '@backstage/plugin-scaffolder-node/alpha'; + +import { createAcmeExampleAction } from '../actions'; + +export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { + kind: 'new', + install: createBackendModule({ + moduleId: 'scaffolder-backend-{{id}}', + pluginId: 'scaffolder', + register(env) { + env.registerInit({ + deps: { + scaffolder: scaffolderActionsExtensionPoint, + config: coreServices.rootConfig, + }, + async init({ scaffolder }) { + scaffolder.addActions(createAcmeExampleAction()); + }, + }); + }, + }), +}; diff --git a/packages/cli/templates/scaffolder-module/src/dynamic/index.ts.hbs b/packages/cli/templates/scaffolder-module/src/dynamic/index.ts.hbs new file mode 100644 index 0000000000..cf1b6aabd9 --- /dev/null +++ b/packages/cli/templates/scaffolder-module/src/dynamic/index.ts.hbs @@ -0,0 +1,7 @@ +import { BackendDynamicPluginInstaller } from '@backstage/backend-plugin-manager'; +import { createAcmeExampleAction } from '../actions'; + +export const dynamicPluginInstaller: BackendDynamicPluginInstaller = { + kind: 'legacy', + scaffolder: () => [createAcmeExampleAction()], +}; diff --git a/packages/cli/templates/scaffolder-module/src/index.ts.hbs b/packages/cli/templates/scaffolder-module/src/index.ts.hbs index 3690e43b8e..674dd7ade4 100644 --- a/packages/cli/templates/scaffolder-module/src/index.ts.hbs +++ b/packages/cli/templates/scaffolder-module/src/index.ts.hbs @@ -6,3 +6,4 @@ */ export * from './actions'; +export * from './dynamic/index'; diff --git a/packages/cli/templates/scaffolder-module/tsconfig.json b/packages/cli/templates/scaffolder-module/tsconfig.json.hbs similarity index 75% rename from packages/cli/templates/scaffolder-module/tsconfig.json rename to packages/cli/templates/scaffolder-module/tsconfig.json.hbs index 5ae9aeb62d..76ad8cc243 100644 --- a/packages/cli/templates/scaffolder-module/tsconfig.json +++ b/packages/cli/templates/scaffolder-module/tsconfig.json.hbs @@ -3,7 +3,7 @@ "include": ["src"], "exclude": ["node_modules"], "compilerOptions": { - "outDir": "dist-types", + "outDir": "../../dist-types/plugins/{{id}}", "rootDir": "." } } diff --git a/packages/cli/templates/scaffolder-module/turbo.json.hbs b/packages/cli/templates/scaffolder-module/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/scaffolder-module/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/packages/cli/templates/web-library-package/package.json.hbs b/packages/cli/templates/web-library-package/package.json.hbs index f9f703f523..8b477f336b 100644 --- a/packages/cli/templates/web-library-package/package.json.hbs +++ b/packages/cli/templates/web-library-package/package.json.hbs @@ -20,19 +20,31 @@ }, "sideEffects": false, "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", + "lint": "backstage-cli package lint", + "postpack": "backstage-cli package postpack", "prepack": "backstage-cli package prepack", - "postpack": "backstage-cli package postpack" + "start": "backstage-cli package start", + "test": "backstage-cli package test --passWithNoTests --coverage", + "tsc": "tsc" }, "devDependencies": { "@backstage/cli": "{{versionQuery '@backstage/cli'}}", - "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '5.10.1'}}" + "@testing-library/jest-dom": "{{versionQuery '@testing-library/jest-dom' '6.0.0'}}" }, "files": [ "dist" - ] + ], + "repository": { + "type": "git", + "url": "https://github.com/janus-idp/backstage-plugins", + "directory": "plugins/{{id}}" + }, + "keywords": [ + "backstage", + "plugin" + ], + "homepage": "https://janus-idp.io/", + "bugs": "https://github.com/janus-idp/backstage-plugins/issues" } diff --git a/packages/cli/templates/web-library-package/tsconfig.json b/packages/cli/templates/web-library-package/tsconfig.json deleted file mode 100644 index ce3409d31f..0000000000 --- a/packages/cli/templates/web-library-package/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "@backstage/cli/config/tsconfig.json", - "include": [ - "src", - ], - "exclude": ["node_modules"], - "compilerOptions": { - "outDir": "dist-types", - "rootDir": "." - } -} diff --git a/packages/cli/templates/web-library-package/tsconfig.json.hbs b/packages/cli/templates/web-library-package/tsconfig.json.hbs new file mode 100644 index 0000000000..76ad8cc243 --- /dev/null +++ b/packages/cli/templates/web-library-package/tsconfig.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": "@backstage/cli/config/tsconfig.json", + "include": ["src"], + "exclude": ["node_modules"], + "compilerOptions": { + "outDir": "../../dist-types/plugins/{{id}}", + "rootDir": "." + } +} diff --git a/packages/cli/templates/web-library-package/turbo.json.hbs b/packages/cli/templates/web-library-package/turbo.json.hbs new file mode 100644 index 0000000000..974f0a85ba --- /dev/null +++ b/packages/cli/templates/web-library-package/turbo.json.hbs @@ -0,0 +1,9 @@ +{ + "extends": ["//"], + "pipeline": { + "tsc": { + "outputs": ["../../dist-types/plugins/{{id}}/**"], + "dependsOn": ["^tsc"] + } + } +} diff --git a/yarn.lock b/yarn.lock index a233795650..f8dc44bace 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5621,7 +5621,7 @@ "@backstage/plugin-permission-common" "^0.7.12" "@backstage/types" "^1.1.1" -"@backstage/plugin-scaffolder-node@^0.2.6": +"@backstage/plugin-scaffolder-node@0.2.6", "@backstage/plugin-scaffolder-node@^0.2.6": version "0.2.6" resolved "https://registry.yarnpkg.com/@backstage/plugin-scaffolder-node/-/plugin-scaffolder-node-0.2.6.tgz#fca73dfb6548522f9f4c4313e4e3b1470b5c5744" integrity sha512-elFe0NTj/jstFHEma3yZ7Br5SvhMnOjFzRRXilg+qdD0byMlA4QtFgWsTzOsCLfxOC14GDrZA4NZU1vqgXLGug==