From b4cd145b574f8ac29bd63bdfb00a3cd5fd62bbee Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 9 Jan 2023 22:52:19 +0100 Subject: [PATCH 01/65] cli: added package-exports migration command Signed-off-by: Patrik Oldsberg --- .changeset/long-nails-pump.md | 5 ++ packages/cli/src/commands/index.ts | 7 ++ .../src/commands/migrate/packageExports.ts | 83 +++++++++++++++++++ packages/cli/src/lib/monorepo/PackageGraph.ts | 4 + 4 files changed, 99 insertions(+) create mode 100644 .changeset/long-nails-pump.md create mode 100644 packages/cli/src/commands/migrate/packageExports.ts diff --git a/.changeset/long-nails-pump.md b/.changeset/long-nails-pump.md new file mode 100644 index 0000000000..d9eefc0249 --- /dev/null +++ b/.changeset/long-nails-pump.md @@ -0,0 +1,5 @@ +--- +'@backstage/cli': patch +--- + +Added a new `migrate package-exports` command that synchronizes package exports fields in all `package.json`s. diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 628e46df85..2fdd2442d4 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -191,6 +191,13 @@ export function registerMigrateCommand(program: Command) { lazy(() => import('./migrate/packageScripts').then(m => m.command)), ); + command + .command('package-exports') + .description('Synchronize package sub-path export definitions') + .action( + lazy(() => import('./migrate/packageExports').then(m => m.command)), + ); + command .command('package-lint-configs') .description( diff --git a/packages/cli/src/commands/migrate/packageExports.ts b/packages/cli/src/commands/migrate/packageExports.ts new file mode 100644 index 0000000000..3a59c02375 --- /dev/null +++ b/packages/cli/src/commands/migrate/packageExports.ts @@ -0,0 +1,83 @@ +/* + * Copyright 2020 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 fs from 'fs-extra'; +import { resolve as resolvePath } from 'path'; +import { PackageGraph } from '../../lib/monorepo'; + +function trimRelative(path: string): string { + if (path.startsWith('./')) { + return path.slice(2); + } + return path; +} + +export async function command() { + const packages = await PackageGraph.listTargetPackages(); + + await Promise.all( + packages.map(async ({ dir, packageJson }) => { + const { exports: exp } = packageJson; + if (!exp || typeof exp !== 'object' || Array.isArray(exp)) { + return; + } + + const existingTypesVersions = JSON.stringify(packageJson.typesVersions); + + const typeEntries: Record = {}; + + for (const [path, value] of Object.entries(exp)) { + const newPath = path === '.' ? '*' : trimRelative(path); + + if (typeof value === 'string') { + typeEntries[newPath] = [trimRelative(value)]; + } else if ( + value && + typeof value === 'object' && + !Array.isArray(value) + ) { + if (typeof value.types === 'string') { + typeEntries[newPath] = [trimRelative(value.types)]; + } else if (typeof value.default === 'string') { + typeEntries[newPath] = [trimRelative(value.default)]; + } + } + } + + const typesVersions = { '*': typeEntries }; + + if (existingTypesVersions !== JSON.stringify(typesVersions)) { + console.log(`Synchronizing exports in ${packageJson.name}`); + const newPkgEntries = Object.entries(packageJson).filter( + ([name]) => name !== 'typesVersions', + ); + newPkgEntries.splice( + newPkgEntries.findIndex(([name]) => name === 'exports') + 1, + 0, + ['typesVersions', typesVersions], + ); + + await fs.writeJson( + resolvePath(dir, 'package.json'), + Object.fromEntries(newPkgEntries), + { + spaces: 2, + }, + ); + } + }), + ); +} diff --git a/packages/cli/src/lib/monorepo/PackageGraph.ts b/packages/cli/src/lib/monorepo/PackageGraph.ts index a1fc95e669..d34ede41ae 100644 --- a/packages/cli/src/lib/monorepo/PackageGraph.ts +++ b/packages/cli/src/lib/monorepo/PackageGraph.ts @@ -20,6 +20,7 @@ import { paths } from '../paths'; import { PackageRole } from '../role'; import { listChangedFiles, readFileAtRef } from '../git'; import { Lockfile } from '../versioning'; +import { JsonValue } from '@backstage/types'; type PackageJSON = Package['packageJson']; @@ -34,6 +35,9 @@ export interface ExtendedPackageJSON extends PackageJSON { backstage?: { role?: PackageRole; }; + + exports?: JsonValue; + typesVersions?: Record>; } export type ExtendedPackage = { From a9b88cda173d2d8559eb377553d12d35dcbcd3e0 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 14 Jan 2023 14:16:34 +0100 Subject: [PATCH 02/65] cli: add exports support for package builds Signed-off-by: Patrik Oldsberg --- .../cli/src/commands/build/buildBackend.ts | 1 + packages/cli/src/commands/repo/build.ts | 1 + packages/cli/src/lib/builder/config.test.ts | 5 + packages/cli/src/lib/builder/config.ts | 214 ++++++++++-------- packages/cli/src/lib/builder/types.ts | 3 + packages/cli/src/lib/monorepo/PackageGraph.ts | 3 + packages/cli/src/lib/monorepo/entryPoints.ts | 73 ++++++ .../src/lib/packager/createDistWorkspace.ts | 1 + 8 files changed, 203 insertions(+), 98 deletions(-) create mode 100644 packages/cli/src/lib/monorepo/entryPoints.ts diff --git a/packages/cli/src/commands/build/buildBackend.ts b/packages/cli/src/commands/build/buildBackend.ts index d7c4f72dbe..7e61f9ae85 100644 --- a/packages/cli/src/commands/build/buildBackend.ts +++ b/packages/cli/src/commands/build/buildBackend.ts @@ -37,6 +37,7 @@ export async function buildBackend(options: BuildBackendOptions) { // We build the target package without generating type declarations. await buildPackage({ targetDir: options.targetDir, + packageJson: pkg, outputs: new Set([Output.cjs]), }); diff --git a/packages/cli/src/commands/repo/build.ts b/packages/cli/src/commands/repo/build.ts index a6bf87da82..d5602a4008 100644 --- a/packages/cli/src/commands/repo/build.ts +++ b/packages/cli/src/commands/repo/build.ts @@ -130,6 +130,7 @@ export async function command(opts: OptionValues, cmd: Command): Promise { return { targetDir: pkg.dir, + packageJson: pkg.packageJson, outputs, logPrefix: `${chalk.cyan(relativePath(paths.targetRoot, pkg.dir))}: `, minify: buildOptions.minify, diff --git a/packages/cli/src/lib/builder/config.test.ts b/packages/cli/src/lib/builder/config.test.ts index a2e99da73b..733c35fb55 100644 --- a/packages/cli/src/lib/builder/config.test.ts +++ b/packages/cli/src/lib/builder/config.test.ts @@ -24,6 +24,11 @@ describe('makeRollupConfigs', () => { const [config] = await makeRollupConfigs({ outputs: new Set([Output.cjs]), + packageJson: { + name: 'test', + version: '0.0.0', + main: './src/index.ts', + }, }); const external = config.external as Exclude< ExternalOption, diff --git a/packages/cli/src/lib/builder/config.ts b/packages/cli/src/lib/builder/config.ts index 1cfaf15bfc..ecd755d05b 100644 --- a/packages/cli/src/lib/builder/config.ts +++ b/packages/cli/src/lib/builder/config.ts @@ -31,6 +31,10 @@ import { forwardFileImports } from './plugins'; import { BuildOptions, Output } from './types'; import { paths } from '../paths'; import { svgrTemplate } from '../svgrTemplate'; +import { ExtendedPackageJSON } from '../monorepo'; +import { readEntryPoints } from '../monorepo/entryPoints'; + +const SCRIPT_EXTS = ['.js', '.jsx', '.ts', '.tsx']; function isFileImport(source: string) { if (source.startsWith('.')) { @@ -50,6 +54,13 @@ export async function makeRollupConfigs( ): Promise { const configs = new Array(); const targetDir = options.targetDir ?? paths.targetDir; + + let targetPkg = options.packageJson; + if (!targetPkg) { + const packagePath = resolvePath(targetDir, 'package.json'); + targetPkg = (await fs.readJson(packagePath)) as ExtendedPackageJSON; + } + const onwarn = ({ code, message }: RollupWarning) => { if (code === 'EMPTY_BUNDLE') { return; // We don't care about this one @@ -62,111 +73,118 @@ export async function makeRollupConfigs( }; const distDir = resolvePath(targetDir, 'dist'); + const entryPoints = readEntryPoints(targetPkg); - if (options.outputs.has(Output.cjs) || options.outputs.has(Output.esm)) { - const output = new Array(); - const mainFields = ['module', 'main']; - - if (options.outputs.has(Output.cjs)) { - output.push({ - dir: distDir, - entryFileNames: 'index.cjs.js', - chunkFileNames: 'cjs/[name]-[hash].cjs.js', - format: 'commonjs', - sourcemap: true, - }); - } - if (options.outputs.has(Output.esm)) { - output.push({ - dir: distDir, - entryFileNames: 'index.esm.js', - chunkFileNames: 'esm/[name]-[hash].esm.js', - format: 'module', - sourcemap: true, - }); - // Assume we're building for the browser if ESM output is included - mainFields.unshift('browser'); + for (const { path, name, ext } of entryPoints) { + if (!SCRIPT_EXTS.includes(ext)) { + continue; } - configs.push({ - input: resolvePath(targetDir, 'src/index.ts'), - output, - onwarn, - preserveEntrySignatures: 'strict', - // All module imports are always marked as external - external: (source, importer, isResolved) => - Boolean(importer && !isResolved && !isFileImport(source)), - plugins: [ - resolve({ mainFields }), - commonjs({ - include: /node_modules/, - exclude: [/\/[^/]+\.(?:stories|test)\.[^/]+$/], - }), - postcss(), - forwardFileImports({ - exclude: /\.icon\.svg$/, - include: [ - /\.svg$/, - /\.png$/, - /\.gif$/, - /\.jpg$/, - /\.jpeg$/, - /\.eot$/, - /\.woff$/, - /\.woff2$/, - /\.ttf$/, - ], - }), - json(), - yaml(), - svgr({ - include: /\.icon\.svg$/, - template: svgrTemplate, - }), - esbuild({ - target: 'es2019', - minify: options.minify, - }), - ], - }); - } + if (options.outputs.has(Output.cjs) || options.outputs.has(Output.esm)) { + const output = new Array(); + const mainFields = ['module', 'main']; - if (options.outputs.has(Output.types) && !options.useApiExtractor) { - const typesInput = paths.resolveTargetRoot( - 'dist-types', - relativePath(paths.targetRoot, targetDir), - 'src/index.d.ts', - ); + if (options.outputs.has(Output.cjs)) { + output.push({ + dir: distDir, + entryFileNames: `${name}.cjs.js`, + chunkFileNames: `cjs/${name}/[name]-[hash].cjs.js`, + format: 'commonjs', + sourcemap: true, + }); + } + if (options.outputs.has(Output.esm)) { + output.push({ + dir: distDir, + entryFileNames: `${name}.esm.js`, + chunkFileNames: `esm/${name}/[name]-[hash].esm.js`, + format: 'module', + sourcemap: true, + }); + // Assume we're building for the browser if ESM output is included + mainFields.unshift('browser'); + } - const declarationsExist = await fs.pathExists(typesInput); - if (!declarationsExist) { - const path = relativePath(targetDir, typesInput); - throw new Error( - `No declaration files found at ${path}, be sure to run ${chalk.bgRed.white( - 'yarn tsc', - )} to generate .d.ts files before packaging`, + configs.push({ + input: resolvePath(targetDir, path), + output, + onwarn, + preserveEntrySignatures: 'strict', + // All module imports are always marked as external + external: (source, importer, isResolved) => + Boolean(importer && !isResolved && !isFileImport(source)), + plugins: [ + resolve({ mainFields }), + commonjs({ + include: /node_modules/, + exclude: [/\/[^/]+\.(?:stories|test)\.[^/]+$/], + }), + postcss(), + forwardFileImports({ + exclude: /\.icon\.svg$/, + include: [ + /\.svg$/, + /\.png$/, + /\.gif$/, + /\.jpg$/, + /\.jpeg$/, + /\.eot$/, + /\.woff$/, + /\.woff2$/, + /\.ttf$/, + ], + }), + json(), + yaml(), + svgr({ + include: /\.icon\.svg$/, + template: svgrTemplate, + }), + esbuild({ + target: 'es2019', + minify: options.minify, + }), + ], + }); + } + + if (options.outputs.has(Output.types) && !options.useApiExtractor) { + const typesInput = paths.resolveTargetRoot( + 'dist-types', + relativePath(paths.targetRoot, targetDir), + path.replace(/\.ts$/, '.d.ts'), ); - } - configs.push({ - input: typesInput, - output: { - file: resolvePath(distDir, 'index.d.ts'), - format: 'es', - }, - external: [ - /\.css$/, - /\.scss$/, - /\.sass$/, - /\.svg$/, - /\.eot$/, - /\.woff$/, - /\.woff2$/, - /\.ttf$/, - ], - onwarn, - plugins: [dts()], - }); + const declarationsExist = await fs.pathExists(typesInput); + if (!declarationsExist) { + const declarationPath = relativePath(targetDir, typesInput); + throw new Error( + `No declaration files found at ${declarationPath}, be sure to run ${chalk.bgRed.white( + 'yarn tsc', + )} to generate .d.ts files before packaging`, + ); + } + + configs.push({ + input: typesInput, + output: { + file: resolvePath(distDir, `${name}.d.ts`), + format: 'es', + }, + external: [ + /\.css$/, + /\.scss$/, + /\.sass$/, + /\.svg$/, + /\.eot$/, + /\.woff$/, + /\.woff2$/, + /\.ttf$/, + ], + onwarn, + plugins: [dts()], + }); + } } return configs; diff --git a/packages/cli/src/lib/builder/types.ts b/packages/cli/src/lib/builder/types.ts index f43d84cd92..de7e9b10eb 100644 --- a/packages/cli/src/lib/builder/types.ts +++ b/packages/cli/src/lib/builder/types.ts @@ -14,6 +14,8 @@ * limitations under the License. */ +import { ExtendedPackageJSON } from '../monorepo'; + export enum Output { esm, cjs, @@ -23,6 +25,7 @@ export enum Output { export type BuildOptions = { logPrefix?: string; targetDir?: string; + packageJson?: ExtendedPackageJSON; outputs: Set; minify?: boolean; useApiExtractor?: boolean; diff --git a/packages/cli/src/lib/monorepo/PackageGraph.ts b/packages/cli/src/lib/monorepo/PackageGraph.ts index d34ede41ae..421d9aa25b 100644 --- a/packages/cli/src/lib/monorepo/PackageGraph.ts +++ b/packages/cli/src/lib/monorepo/PackageGraph.ts @@ -25,6 +25,9 @@ import { JsonValue } from '@backstage/types'; type PackageJSON = Package['packageJson']; export interface ExtendedPackageJSON extends PackageJSON { + main?: string; + module?: string; + scripts?: { [key: string]: string; }; diff --git a/packages/cli/src/lib/monorepo/entryPoints.ts b/packages/cli/src/lib/monorepo/entryPoints.ts new file mode 100644 index 0000000000..8a8bbd27f9 --- /dev/null +++ b/packages/cli/src/lib/monorepo/entryPoints.ts @@ -0,0 +1,73 @@ +/* + * Copyright 2023 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 { extname } from 'path'; +import { ExtendedPackageJSON } from './PackageGraph'; + +export interface EntryPoint { + mount: string; + path: string; + name: string; + ext: string; +} + +function parseEntryPoint(mount: string, path: string): EntryPoint { + let name = mount; + if (name === '.') { + name = 'index'; + } else if (name.startsWith('./')) { + name = name.slice(2); + } + if (name.includes('/')) { + throw new Error(`Mount point '${mount}' may not contain multiple slashes`); + } + + return { mount, path, name, ext: extname(path) }; +} + +export function readEntryPoints(pkg: ExtendedPackageJSON): Array { + const exp = pkg.exports; + if (typeof exp === 'string') { + return [parseEntryPoint('.', exp)]; + } else if (exp && typeof exp === 'object' && !Array.isArray(exp)) { + const entryPoints = new Array<{ + mount: string; + path: string; + name: string; + ext: string; + }>(); + + for (const mount of Object.keys(exp)) { + const path = exp[mount]; + if (typeof path !== 'string') { + throw new Error( + `Exports field value must be a string, got '${JSON.stringify(path)}'`, + ); + } + + entryPoints.push(parseEntryPoint(mount, path)); + } + + return entryPoints; + } + + const main = pkg.main || pkg.module; + if (main) { + return [parseEntryPoint('.', main)]; + } + + return []; +} diff --git a/packages/cli/src/lib/packager/createDistWorkspace.ts b/packages/cli/src/lib/packager/createDistWorkspace.ts index 5451a873f7..28b5526fc9 100644 --- a/packages/cli/src/lib/packager/createDistWorkspace.ts +++ b/packages/cli/src/lib/packager/createDistWorkspace.ts @@ -178,6 +178,7 @@ export async function createDistWorkspace( if (outputs.size > 0) { standardBuilds.push({ targetDir: pkg.dir, + packageJson: pkg.packageJson, outputs: outputs, logPrefix: `${chalk.cyan(relativePath(paths.targetRoot, pkg.dir))}: `, // No need to detect these for the backend builds, we assume no minification or types From 3099c54f228bef4508d6fb508e5207954c5c9c3e Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 14 Jan 2023 16:37:33 +0100 Subject: [PATCH 03/65] cli: unify production packing logic and add support for exports field Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/pack.ts | 73 +----- packages/cli/src/lib/monorepo/PackageGraph.ts | 1 + .../cli/src/lib/packager/copyPackageDist.ts | 93 -------- .../src/lib/packager/createDistWorkspace.ts | 7 +- .../cli/src/lib/packager/productionPack.ts | 223 ++++++++++++++++++ 5 files changed, 235 insertions(+), 162 deletions(-) delete mode 100644 packages/cli/src/lib/packager/copyPackageDist.ts create mode 100644 packages/cli/src/lib/packager/productionPack.ts diff --git a/packages/cli/src/commands/pack.ts b/packages/cli/src/commands/pack.ts index 6c88ac055f..9c101e97fe 100644 --- a/packages/cli/src/commands/pack.ts +++ b/packages/cli/src/commands/pack.ts @@ -14,77 +14,16 @@ * limitations under the License. */ -import fs from 'fs-extra'; +import { + productionPack, + revertProductionPack, +} from '../lib/packager/productionPack'; import { paths } from '../lib/paths'; -import { join as joinPath } from 'path'; - -const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; - -const PKG_PATH = 'package.json'; -const PKG_BACKUP_PATH = 'package.json-prepack'; - -function resolveEntrypoint(pkg: any, name: string) { - const targetEntry = pkg.publishConfig[name] || pkg[name]; - return targetEntry && joinPath('..', targetEntry); -} - -// Writes e.g. alpha/package.json -async function writeReleaseStageEntrypoint(pkg: any, stage: 'alpha' | 'beta') { - await fs.ensureDir(paths.resolveTarget(stage)); - await fs.writeJson( - paths.resolveTarget(stage, PKG_PATH), - { - name: pkg.name, - version: pkg.version, - main: resolveEntrypoint(pkg, 'main'), - module: resolveEntrypoint(pkg, 'module'), - browser: resolveEntrypoint(pkg, 'browser'), - types: joinPath('..', pkg.publishConfig[`${stage}Types`]), - }, - { encoding: 'utf8', spaces: 2 }, - ); -} export const pre = async () => { - const pkgPath = paths.resolveTarget(PKG_PATH); - - const pkgContent = await fs.readFile(pkgPath, 'utf8'); - const pkg = JSON.parse(pkgContent); - await fs.writeFile(PKG_BACKUP_PATH, pkgContent); - - const publishConfig = pkg.publishConfig ?? {}; - for (const key of Object.keys(publishConfig)) { - if (!SKIPPED_KEYS.includes(key)) { - pkg[key] = publishConfig[key]; - } - } - await fs.writeJson(pkgPath, pkg, { encoding: 'utf8', spaces: 2 }); - - if (publishConfig.alphaTypes) { - await writeReleaseStageEntrypoint(pkg, 'alpha'); - } - if (publishConfig.betaTypes) { - await writeReleaseStageEntrypoint(pkg, 'beta'); - } + await productionPack({ packageDir: paths.targetDir }); }; export const post = async () => { - // postpack isn't called by yarn right now, so it needs to be called manually - try { - await fs.move(PKG_BACKUP_PATH, PKG_PATH, { overwrite: true }); - - // Check if we're shipping types for other release stages, clean up in that case - const pkg = await fs.readJson(PKG_PATH); - if (pkg.publishConfig?.alphaTypes) { - await fs.remove(paths.resolveTarget('alpha')); - } - if (pkg.publishConfig?.betaTypes) { - await fs.remove(paths.resolveTarget('beta')); - } - } catch (error) { - console.warn( - `Failed to restore package.json during postpack, ${error}. ` + - 'Your package will be fine but you may have ended up with some garbage in the repo.', - ); - } + await revertProductionPack(paths.targetDir); }; diff --git a/packages/cli/src/lib/monorepo/PackageGraph.ts b/packages/cli/src/lib/monorepo/PackageGraph.ts index 421d9aa25b..b6d6d927a6 100644 --- a/packages/cli/src/lib/monorepo/PackageGraph.ts +++ b/packages/cli/src/lib/monorepo/PackageGraph.ts @@ -27,6 +27,7 @@ type PackageJSON = Package['packageJson']; export interface ExtendedPackageJSON extends PackageJSON { main?: string; module?: string; + types?: string; scripts?: { [key: string]: string; diff --git a/packages/cli/src/lib/packager/copyPackageDist.ts b/packages/cli/src/lib/packager/copyPackageDist.ts deleted file mode 100644 index b704148542..0000000000 --- a/packages/cli/src/lib/packager/copyPackageDist.ts +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2022 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 fs from 'fs-extra'; -import npmPackList from 'npm-packlist'; -import { join as joinPath, resolve as resolvePath } from 'path'; - -const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; - -function resolveEntrypoint(pkg: any, name: string) { - const targetEntry = pkg.publishConfig[name] || pkg[name]; - return targetEntry && joinPath('..', targetEntry); -} - -// Writes e.g. alpha/package.json -async function writeReleaseStageEntrypoint( - pkg: any, - stage: 'alpha' | 'beta', - targetDir: string, -) { - await fs.ensureDir(resolvePath(targetDir, stage)); - await fs.writeJson( - resolvePath(targetDir, stage, 'package.json'), - { - name: pkg.name, - version: pkg.version, - main: resolveEntrypoint(pkg, 'main'), - module: resolveEntrypoint(pkg, 'module'), - browser: resolveEntrypoint(pkg, 'browser'), - types: joinPath('..', pkg.publishConfig[`${stage}Types`]), - }, - { encoding: 'utf8', spaces: 2 }, - ); -} - -export async function copyPackageDist(packageDir: string, targetDir: string) { - const pkgPath = resolvePath(packageDir, 'package.json'); - const pkgContent = await fs.readFile(pkgPath, 'utf8'); - const pkg = JSON.parse(pkgContent); - - const publishConfig = pkg.publishConfig ?? {}; - for (const key of Object.keys(publishConfig)) { - if (!SKIPPED_KEYS.includes(key)) { - pkg[key] = publishConfig[key]; - } - } - - // We remove the dependencies from package.json of packages that are marked - // as bundled, so that yarn doesn't try to install them. - if (pkg.bundled) { - delete pkg.dependencies; - delete pkg.devDependencies; - delete pkg.peerDependencies; - delete pkg.optionalDependencies; - } - - // Lists all dist files, respecting .npmignore, files field in package.json, etc. - const filePaths = await npmPackList({ - path: packageDir, - // This makes sure we use the update package.json when listing files - packageJsonCache: new Map([[resolvePath(packageDir, 'package.json'), pkg]]), - }); - - await fs.ensureDir(targetDir); - for (const filePath of filePaths.sort()) { - const target = resolvePath(targetDir, filePath); - if (filePath === 'package.json') { - await fs.writeJson(target, pkg, { encoding: 'utf8', spaces: 2 }); - } else { - await fs.copy(resolvePath(packageDir, filePath), target); - } - } - - if (publishConfig.alphaTypes) { - await writeReleaseStageEntrypoint(pkg, 'alpha', targetDir); - } - if (publishConfig.betaTypes) { - await writeReleaseStageEntrypoint(pkg, 'beta', targetDir); - } -} diff --git a/packages/cli/src/lib/packager/createDistWorkspace.ts b/packages/cli/src/lib/packager/createDistWorkspace.ts index 28b5526fc9..2d2967fc44 100644 --- a/packages/cli/src/lib/packager/createDistWorkspace.ts +++ b/packages/cli/src/lib/packager/createDistWorkspace.ts @@ -37,7 +37,7 @@ import { getOutputsForRole, Output, } from '../builder'; -import { copyPackageDist } from './copyPackageDist'; +import { productionPack } from './productionPack'; import { getRoleInfo } from '../role'; import { runParallelWorkers } from '../parallel'; @@ -258,7 +258,10 @@ async function moveToDistWorkspace( const outputDir = relativePath(paths.targetRoot, target.dir); const absoluteOutputPath = resolvePath(workspaceDir, outputDir); - await copyPackageDist(target.dir, absoluteOutputPath); + await productionPack({ + packageDir: target.dir, + targetDir: absoluteOutputPath, + }); }), ); diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts new file mode 100644 index 0000000000..c58cdab5a0 --- /dev/null +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -0,0 +1,223 @@ +/* + * Copyright 2023 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 fs from 'fs-extra'; +import npmPackList from 'npm-packlist'; +import { join as joinPath, resolve as resolvePath } from 'path'; +import { ExtendedPackageJSON } from '../monorepo'; +import { readEntryPoints } from '../monorepo/entryPoints'; + +const PKG_PATH = 'package.json'; +const PKG_BACKUP_PATH = 'package.json-prepack'; + +const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; + +interface ProductionPackOptions { + packageDir: string; + targetDir?: string; +} + +export async function productionPack(options: ProductionPackOptions) { + const { packageDir, targetDir } = options; + const pkgPath = resolvePath(packageDir, PKG_PATH); + const pkgContent = await fs.readFile(pkgPath, 'utf8'); + const pkg = JSON.parse(pkgContent) as ExtendedPackageJSON; + + // If we're making the update in-line, back up the package.json + if (!targetDir) { + await fs.writeFile(PKG_BACKUP_PATH, pkgContent); + } + + const hasStageEntry = + !!pkg.publishConfig?.alphaTypes || !!pkg.publishConfig?.betaTypes; + if (pkg.exports && hasStageEntry) { + throw new Error( + 'Combining both exports and alpha/beta types is not supported', + ); + } + + // This mutates pkg to fill in index exports, so call it before applying publishConfig + if (pkg.exports) { + await writeExportsEntryPoints(pkg, targetDir ?? packageDir); + } + + // TODO(Rugvip): Once exports are rolled out more broadly we should deprecate and remove this behavior + const publishConfig = pkg.publishConfig ?? {}; + for (const key of Object.keys(publishConfig)) { + if (!SKIPPED_KEYS.includes(key)) { + (pkg as any)[key] = publishConfig[key as keyof typeof publishConfig]; + } + } + + // We remove the dependencies from package.json of packages that are marked + // as bundled, so that yarn doesn't try to install them. + if (pkg.bundled) { + delete pkg.dependencies; + delete pkg.devDependencies; + delete pkg.peerDependencies; + delete pkg.optionalDependencies; + } + + if (targetDir) { + // Lists all dist files, respecting .npmignore, files field in package.json, etc. + const filePaths = await npmPackList({ + path: packageDir, + // This makes sure we use the updated package.json when listing files + packageJsonCache: new Map([ + [resolvePath(packageDir, PKG_PATH), pkg], + ]) as any, // Seems like this parameter type is wrong, + }); + + await fs.ensureDir(targetDir); + for (const filePath of filePaths.sort()) { + const target = resolvePath(targetDir, filePath); + if (filePath === PKG_PATH) { + await fs.writeJson(target, pkg, { encoding: 'utf8', spaces: 2 }); + } else { + await fs.copy(resolvePath(packageDir, filePath), target); + } + } + } else { + await fs.writeJson(pkgPath, pkg, { encoding: 'utf8', spaces: 2 }); + } + + if (publishConfig.alphaTypes) { + await writeReleaseStageEntrypoint(pkg, 'alpha', targetDir ?? packageDir); + } + if (publishConfig.betaTypes) { + await writeReleaseStageEntrypoint(pkg, 'beta', targetDir ?? packageDir); + } +} + +// Reverts the changes made by productionPack when called without a targetDir. +export async function revertProductionPack(packageDir: string) { + // postpack isn't called by yarn right now, so it needs to be called manually + try { + await fs.move(PKG_BACKUP_PATH, PKG_PATH, { overwrite: true }); + + // Check if we're shipping types for other release stages, clean up in that case + const pkg = await fs.readJson(PKG_PATH); + if (pkg.publishConfig?.alphaTypes) { + await fs.remove(resolvePath(packageDir, 'alpha')); + } + if (pkg.publishConfig?.betaTypes) { + await fs.remove(resolvePath(packageDir, 'beta')); + } + + // Remove any extra entrypoint backwards compatibility directories + const entryPoints = readEntryPoints(pkg); + for (const entryPoint of entryPoints) { + if (entryPoint.mount !== '.') { + await fs.remove(resolvePath(packageDir, entryPoint.name)); + } + } + } catch (error) { + console.warn( + `Failed to restore package.json, ${error}. ` + + 'Your package will be fine but you may have ended up with some garbage in the repo.', + ); + } +} + +function resolveEntrypoint(pkg: any, name: string) { + const targetEntry = pkg.publishConfig[name] || pkg[name]; + return targetEntry && joinPath('..', targetEntry); +} + +// Writes e.g. alpha/package.json +async function writeReleaseStageEntrypoint( + pkg: ExtendedPackageJSON, + stage: 'alpha' | 'beta', + targetDir: string, +) { + await fs.ensureDir(resolvePath(targetDir, stage)); + await fs.writeJson( + resolvePath(targetDir, stage, PKG_PATH), + { + name: pkg.name, + version: pkg.version, + main: resolveEntrypoint(pkg, 'main'), + module: resolveEntrypoint(pkg, 'module'), + browser: resolveEntrypoint(pkg, 'browser'), + types: joinPath('..', pkg.publishConfig![`${stage}Types`]!), + }, + { encoding: 'utf8', spaces: 2 }, + ); +} + +const EXPORT_MAP = { + import: '.esm.js', + require: '.cjs.js', + types: '.d.ts', +}; + +/** + * Rewrites the exports field in package.json to point to dist files, as + * well as creating backwards compatibility entry points for importers + * that don't support exports. + */ +async function writeExportsEntryPoints( + pkg: ExtendedPackageJSON, + targetDir: string, +) { + const distFiles = await fs.readdir(resolvePath(targetDir, 'dist')); + const outputExports = {} as Record>; + + const entryPoints = readEntryPoints(pkg); + for (const entryPoint of entryPoints) { + const exp = {} as Record; + for (const [key, ext] of Object.entries(EXPORT_MAP)) { + const name = `${entryPoint.name}${ext}`; + if (distFiles.includes(name)) { + exp[key] = `./${joinPath(`dist`, name)}`; + } + } + exp.default = exp.require ?? exp.import; + + // This creates a directory with a lone package.json for backwards compatibility + if (entryPoint.mount === '.') { + if (exp.default) { + pkg.main = exp.default; + } + if (exp.import) { + pkg.module = exp.import; + } + if (exp.types) { + pkg.types = exp.types; + } + } else { + const entryPointDir = resolvePath(targetDir, entryPoint.name); + await fs.ensureDir(entryPointDir); + await fs.writeJson( + resolvePath(entryPointDir, PKG_PATH), + { + name: pkg.name, + version: pkg.version, + ...(exp.default ? { main: joinPath('..', exp.default) } : {}), + ...(exp.import ? { module: joinPath('..', exp.import) } : {}), + ...(exp.types ? { types: joinPath('..', exp.types) } : {}), + }, + { encoding: 'utf8', spaces: 2 }, + ); + } + + if (Object.keys(exp).length > 0) { + outputExports[entryPoint.mount] = exp; + } + } + + pkg.exports = outputExports; +} From 6ba8faf22ac366dcd502602d15be2f842e9495b2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 14 Jan 2023 17:20:02 +0100 Subject: [PATCH 04/65] repo-tools: add support for API reports for additional entry points Signed-off-by: Patrik Oldsberg --- .changeset/yellow-bananas-yawn.md | 5 ++ .../src/commands/api-reports/api-extractor.ts | 47 ++++++++++++++++--- 2 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 .changeset/yellow-bananas-yawn.md diff --git a/.changeset/yellow-bananas-yawn.md b/.changeset/yellow-bananas-yawn.md new file mode 100644 index 0000000000..d9c522a429 --- /dev/null +++ b/.changeset/yellow-bananas-yawn.md @@ -0,0 +1,5 @@ +--- +'@backstage/repo-tools': patch +--- + +The API report generation process is now able to detect and generate reports for additional entry points declared in the package `"exports"` field. diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index 39df70c21a..c9081255b8 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -300,6 +300,33 @@ function logApiReportInstructions() { console.log(''); } +async function findPackageEntryPoints( + packageDirs: string[], +): Promise> { + return Promise.all( + packageDirs.map(async packageDir => { + const pkg = await fs.readJson( + cliPaths.resolveTargetRoot(packageDir, 'package.json'), + ); + + if (pkg.exports && typeof pkg.exports !== 'string') { + return Object.keys(pkg.exports).map(mount => { + let name = mount; + if (name.startsWith('./')) { + name = name.slice(2); + } + if (!name || name === '.') { + return { packageDir, name: 'index' }; + } + return { packageDir, name }; + }); + } + + return { packageDir, name: 'index' }; + }), + ).then(results => results.flat()); +} + interface ApiExtractionOptions { packageDirs: string[]; outputDir: string; @@ -319,9 +346,11 @@ export async function runApiExtraction({ }: ApiExtractionOptions) { await fs.remove(outputDir); - const entryPoints = packageDirs.map(packageDir => { + const packageEntryPoints = await findPackageEntryPoints(packageDirs); + + const entryPoints = packageEntryPoints.map(({ packageDir, name }) => { return cliPaths.resolveTargetRoot( - `./dist-types/${packageDir}/src/index.d.ts`, + `./dist-types/${packageDir}/src/${name}.d.ts`, ); }); @@ -337,7 +366,7 @@ export async function runApiExtraction({ } const warnings = new Array(); - for (const packageDir of packageDirs) { + for (const { packageDir, name } of packageEntryPoints) { console.log(`## Processing ${packageDir}`); const noBail = Array.isArray(allowWarnings) ? allowWarnings.some(aw => aw === packageDir || minimatch(packageDir, aw)) @@ -351,9 +380,10 @@ export async function runApiExtraction({ const warningCountBefore = await countApiReportWarnings(projectFolder); + const prefix = name === 'index' ? '' : `${name}-`; const extractorConfig = ExtractorConfig.prepare({ configObject: { - mainEntryPointFilePath: resolvePath(packageFolder, 'src/index.d.ts'), + mainEntryPointFilePath: resolvePath(packageFolder, `src/${name}.d.ts`), bundledPackages: [], compiler: { @@ -362,16 +392,19 @@ export async function runApiExtraction({ apiReport: { enabled: true, - reportFileName: 'api-report.md', + reportFileName: `${prefix}api-report.md`, reportFolder: projectFolder, - reportTempFolder: resolvePath(outputDir, ''), + reportTempFolder: resolvePath( + outputDir, + `${prefix}`, + ), }, docModel: { enabled: true, apiJsonFilePath: resolvePath( outputDir, - '.api.json', + `${prefix}.api.json`, ), }, From a5e66e59cb222351dba72dac3ce369574ed22468 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 14 Jan 2023 17:28:49 +0100 Subject: [PATCH 05/65] backend-app-api,backend-plugin-api: removed unused usage of experimental type build Signed-off-by: Patrik Oldsberg --- packages/backend-app-api/package.json | 5 ++--- packages/backend-plugin-api/package.json | 5 ++--- plugins/techdocs-react/package.json | 3 +-- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/backend-app-api/package.json b/packages/backend-app-api/package.json index f6672f1fbb..9c105fb474 100644 --- a/packages/backend-app-api/package.json +++ b/packages/backend-app-api/package.json @@ -7,8 +7,7 @@ "publishConfig": { "access": "public", "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "types": "dist/index.d.ts" }, "backstage": { "role": "node-library" @@ -24,7 +23,7 @@ ], "license": "Apache-2.0", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", diff --git a/packages/backend-plugin-api/package.json b/packages/backend-plugin-api/package.json index f8af9e5bdc..30ea47c520 100644 --- a/packages/backend-plugin-api/package.json +++ b/packages/backend-plugin-api/package.json @@ -7,8 +7,7 @@ "publishConfig": { "access": "public", "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "types": "dist/index.d.ts" }, "backstage": { "role": "node-library" @@ -24,7 +23,7 @@ ], "license": "Apache-2.0", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", diff --git a/plugins/techdocs-react/package.json b/plugins/techdocs-react/package.json index 34f78f9d84..7f7fd06bec 100644 --- a/plugins/techdocs-react/package.json +++ b/plugins/techdocs-react/package.json @@ -4,7 +4,6 @@ "version": "1.1.3", "publishConfig": { "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", "main": "dist/index.esm.js", "types": "dist/index.d.ts" }, @@ -25,7 +24,7 @@ "main": "src/index.ts", "types": "src/index.ts", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", From 1cece753173800c44704d83fb74d37b734e9e97f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 14 Jan 2023 17:41:04 +0100 Subject: [PATCH 06/65] cli: add automatic exports compatibility entry point addition to files field Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/monorepo/PackageGraph.ts | 2 ++ packages/cli/src/lib/packager/productionPack.ts | 3 +++ 2 files changed, 5 insertions(+) diff --git a/packages/cli/src/lib/monorepo/PackageGraph.ts b/packages/cli/src/lib/monorepo/PackageGraph.ts index b6d6d927a6..7bca16a6f7 100644 --- a/packages/cli/src/lib/monorepo/PackageGraph.ts +++ b/packages/cli/src/lib/monorepo/PackageGraph.ts @@ -42,6 +42,8 @@ export interface ExtendedPackageJSON extends PackageJSON { exports?: JsonValue; typesVersions?: Record>; + + files?: string[]; } export type ExtendedPackage = { diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index c58cdab5a0..9f11c10222 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -212,6 +212,9 @@ async function writeExportsEntryPoints( }, { encoding: 'utf8', spaces: 2 }, ); + if (Array.isArray(pkg.files) && !pkg.files.includes(entryPoint.name)) { + pkg.files.push(entryPoint.name); + } } if (Object.keys(exp).length > 0) { From 801b2551e357cea9dd855201a2d99fd3a7caad41 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:17:32 +0100 Subject: [PATCH 07/65] repo-tools: add release tag validation option Signed-off-by: Patrik Oldsberg --- package.json | 2 +- .../src/commands/api-reports/api-extractor.ts | 26 +++++++++++++++++++ .../src/commands/api-reports/api-reports.ts | 2 ++ packages/repo-tools/src/commands/index.ts | 4 +++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 5383ba3d51..c06d353501 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "build:backend": "yarn workspace backend build", "build:all": "backstage-cli repo build --all", "build:api-reports": "yarn build:api-reports:only --tsc", - "build:api-reports:only": "backstage-repo-tools api-reports --allow-warnings 'packages/core-components,plugins/+(catalog|catalog-import|git-release-manager|jenkins|kubernetes)' -o ae-wrong-input-file-type", + "build:api-reports:only": "backstage-repo-tools api-reports --allow-warnings 'packages/core-components,plugins/+(catalog|catalog-import|git-release-manager|jenkins|kubernetes)' -o ae-wrong-input-file-type --validate-release-tags", "build:api-docs": "LANG=en_EN yarn build:api-reports --docs", "tsc": "tsc", "tsc:full": "backstage-cli repo clean && tsc --skipLibCheck false --incremental false", diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index c9081255b8..91df053f22 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -334,6 +334,7 @@ interface ApiExtractionOptions { tsconfigFilePath: string; allowWarnings?: boolean | string[]; omitMessages?: string[]; + validateReleaseTags?: boolean; } export async function runApiExtraction({ @@ -343,6 +344,7 @@ export async function runApiExtraction({ tsconfigFilePath, allowWarnings = false, omitMessages = [], + validateReleaseTags = false, }: ApiExtractionOptions) { await fs.remove(outputDir); @@ -494,6 +496,30 @@ export async function runApiExtraction({ compilerState, }); + // This release tag validation makes sure that the release tag of known entry points match expectations. + // The root index entrypoint is only allowed @public exports, while /alpha and /beta only allow @alpha and @beta. + if (validateReleaseTags) { + if (['index', 'alpha', 'beta'].includes(name)) { + const report = await fs.readFile( + extractorConfig.reportFilePath, + 'utf8', + ); + const lines = report.split(/\r?\n/); + const expectedTag = name === 'index' ? 'public' : name; + for (let i = 0; i < lines.length; i += 1) { + const line = lines[i]; + const match = line.match(/^\/\/ @(alpha|beta|public)/); + if (match && match[1] !== expectedTag) { + throw new Error( + `Unexpected release tag ${match[1]} in ${ + extractorConfig.reportFilePath + } at line ${i + 1}`, + ); + } + } + } + } + if (!extractorResult.succeeded) { if (shouldLogInstructions) { logApiReportInstructions(); diff --git a/packages/repo-tools/src/commands/api-reports/api-reports.ts b/packages/repo-tools/src/commands/api-reports/api-reports.ts index 66436644d2..a917975750 100644 --- a/packages/repo-tools/src/commands/api-reports/api-reports.ts +++ b/packages/repo-tools/src/commands/api-reports/api-reports.ts @@ -33,6 +33,7 @@ type Options = { allowWarnings?: string; allowAllWarnings?: boolean; omitMessages?: string; + validateReleaseTags?: boolean; } & OptionValues; export const buildApiReports = async (paths: string[] = [], opts: Options) => { @@ -90,6 +91,7 @@ export const buildApiReports = async (paths: string[] = [], opts: Options) => { tsconfigFilePath, allowWarnings: allowAllWarnings || allowWarnings, omitMessages: Array.isArray(omitMessages) ? omitMessages : [], + validateReleaseTags: opts.validateReleaseTags, }); } if (cliPackageDirs.length > 0) { diff --git a/packages/repo-tools/src/commands/index.ts b/packages/repo-tools/src/commands/index.ts index f7a16b6d4e..f283e9c743 100644 --- a/packages/repo-tools/src/commands/index.ts +++ b/packages/repo-tools/src/commands/index.ts @@ -37,6 +37,10 @@ export function registerCommands(program: Command) { '-o, --omit-messages ', 'select some message code to be omited on the API Extractor (comma separated values i.e ae-cyclic-inherit-doc,ae-missing-getter )', ) + .option( + '--validate-release-tags', + 'Turn on release tag validation for the public, beta, and alpha APIs', + ) .description('Generate an API report for selected packages') .action( lazy(() => From cae21dc41271773f82c212faa8891b5951f6ac6f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:34:03 +0100 Subject: [PATCH 08/65] catalog-backend-module-github: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 14 ++++++++++++ .../api-report.md | 4 ---- .../package.json | 22 ++++++++++++++----- .../src/alpha.ts | 17 ++++++++++++++ .../src/index.ts | 1 - 5 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 plugins/catalog-backend-module-github/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-github/src/alpha.ts diff --git a/plugins/catalog-backend-module-github/alpha-api-report.md b/plugins/catalog-backend-module-github/alpha-api-report.md new file mode 100644 index 0000000000..8522344433 --- /dev/null +++ b/plugins/catalog-backend-module-github/alpha-api-report.md @@ -0,0 +1,14 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-github" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-catalog-backend-module-github" does not have an export "GithubEntityProvider" +// +// @alpha +export const githubEntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-github/api-report.md b/plugins/catalog-backend-module-github/api-report.md index a66ec712c7..e2b73d267b 100644 --- a/plugins/catalog-backend-module-github/api-report.md +++ b/plugins/catalog-backend-module-github/api-report.md @@ -4,7 +4,6 @@ ```ts import { AnalyzeOptions } from '@backstage/plugin-catalog-backend'; -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { Config } from '@backstage/config'; @@ -100,9 +99,6 @@ export class GithubEntityProvider implements EntityProvider, EventSubscriber { supportsEventTopics(): string[]; } -// @alpha -export const githubEntityProviderCatalogModule: () => BackendFeature; - // @public (undocumented) export class GithubLocationAnalyzer implements ScmLocationAnalyzer { constructor(options: GithubLocationAnalyzerOptions); diff --git a/plugins/catalog-backend-module-github/package.json b/plugins/catalog-backend-module-github/package.json index 5d8c5f3659..6ef4fea0c7 100644 --- a/plugins/catalog-backend-module-github/package.json +++ b/plugins/catalog-backend-module-github/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -24,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -64,7 +75,6 @@ }, "files": [ "dist", - "alpha", "config.d.ts" ], "configSchema": "config.d.ts" diff --git a/plugins/catalog-backend-module-github/src/alpha.ts b/plugins/catalog-backend-module-github/src/alpha.ts new file mode 100644 index 0000000000..1b83eead82 --- /dev/null +++ b/plugins/catalog-backend-module-github/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { githubEntityProviderCatalogModule } from './service/GithubEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-github/src/index.ts b/plugins/catalog-backend-module-github/src/index.ts index b005780758..17c769419f 100644 --- a/plugins/catalog-backend-module-github/src/index.ts +++ b/plugins/catalog-backend-module-github/src/index.ts @@ -28,7 +28,6 @@ export { GithubOrgReaderProcessor } from './processors/GithubOrgReaderProcessor' export { GithubEntityProvider } from './providers/GithubEntityProvider'; export { GithubOrgEntityProvider } from './providers/GithubOrgEntityProvider'; export type { GithubOrgEntityProviderOptions } from './providers/GithubOrgEntityProvider'; -export { githubEntityProviderCatalogModule } from './service/GithubEntityProviderCatalogModule'; export { type GithubMultiOrgConfig, type GithubTeam, From c09421fed85e0ad7d9e635a68f465c9c74042cf8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:34:26 +0100 Subject: [PATCH 09/65] cli: make migrate package-exports remove legacy publishConfig fields Signed-off-by: Patrik Oldsberg --- .../src/commands/migrate/packageExports.ts | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/packages/cli/src/commands/migrate/packageExports.ts b/packages/cli/src/commands/migrate/packageExports.ts index 3a59c02375..754a25e32b 100644 --- a/packages/cli/src/commands/migrate/packageExports.ts +++ b/packages/cli/src/commands/migrate/packageExports.ts @@ -16,7 +16,7 @@ import fs from 'fs-extra'; import { resolve as resolvePath } from 'path'; -import { PackageGraph } from '../../lib/monorepo'; +import { ExtendedPackageJSON, PackageGraph } from '../../lib/monorepo'; function trimRelative(path: string): string { if (path.startsWith('./')) { @@ -35,10 +35,12 @@ export async function command() { return; } + let changed = false; + let newPackageJson = packageJson; + const existingTypesVersions = JSON.stringify(packageJson.typesVersions); const typeEntries: Record = {}; - for (const [path, value] of Object.entries(exp)) { const newPath = path === '.' ? '*' : trimRelative(path); @@ -58,10 +60,9 @@ export async function command() { } const typesVersions = { '*': typeEntries }; - if (existingTypesVersions !== JSON.stringify(typesVersions)) { console.log(`Synchronizing exports in ${packageJson.name}`); - const newPkgEntries = Object.entries(packageJson).filter( + const newPkgEntries = Object.entries(newPackageJson).filter( ([name]) => name !== 'typesVersions', ); newPkgEntries.splice( @@ -70,13 +71,29 @@ export async function command() { ['typesVersions', typesVersions], ); - await fs.writeJson( - resolvePath(dir, 'package.json'), - Object.fromEntries(newPkgEntries), - { - spaces: 2, - }, - ); + newPackageJson = Object.fromEntries( + newPkgEntries, + ) as ExtendedPackageJSON; + changed = true; + } + + // Remove the legacy fields from publishConfig, which are no longer needed + const publishConfig = newPackageJson.publishConfig as + | Record + | undefined; + if (publishConfig) { + for (const field of ['main', 'module', 'browser', 'types']) { + if (publishConfig[field]) { + delete publishConfig[field]; + changed = true; + } + } + } + + if (changed) { + await fs.writeJson(resolvePath(dir, 'package.json'), newPackageJson, { + spaces: 2, + }); } }), ); From 6b9eefae6b98d7c471390262f8848883580df247 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:37:38 +0100 Subject: [PATCH 10/65] backend-common: migrate to use exports Signed-off-by: Patrik Oldsberg --- packages/backend-common/alpha-api-report.md | 32 +++++++++++++++++++++ packages/backend-common/api-report.md | 24 ---------------- packages/backend-common/package.json | 21 ++++++++++---- packages/backend-common/src/alpha.ts | 17 +++++++++++ packages/backend-common/src/index.ts | 1 - 5 files changed, 65 insertions(+), 30 deletions(-) create mode 100644 packages/backend-common/alpha-api-report.md create mode 100644 packages/backend-common/src/alpha.ts diff --git a/packages/backend-common/alpha-api-report.md b/packages/backend-common/alpha-api-report.md new file mode 100644 index 0000000000..9d60b68b6b --- /dev/null +++ b/packages/backend-common/alpha-api-report.md @@ -0,0 +1,32 @@ +## API Report File for "@backstage/backend-common" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Duration } from 'luxon'; + +// @alpha +export interface Context { + readonly abortSignal: AbortSignal; + readonly deadline: Date | undefined; + value(key: string): T | undefined; +} + +// @alpha +export class Contexts { + static root(): Context; + static withAbort( + parentCtx: Context, + source: AbortController | AbortSignal, + ): Context; + static withTimeoutDuration(parentCtx: Context, timeout: Duration): Context; + static withTimeoutMillis(parentCtx: Context, timeout: number): Context; + static withValue( + parentCtx: Context, + key: string, + value: unknown | ((previous: unknown | undefined) => unknown), + ): Context; +} + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/backend-common/api-report.md b/packages/backend-common/api-report.md index d21ef30a0b..1cde27877b 100644 --- a/packages/backend-common/api-report.md +++ b/packages/backend-common/api-report.md @@ -20,7 +20,6 @@ import { Config } from '@backstage/config'; import { ConfigService } from '@backstage/backend-plugin-api'; import cors from 'cors'; import Docker from 'dockerode'; -import { Duration } from 'luxon'; import { ErrorRequestHandler } from 'express'; import express from 'express'; import { GerritIntegration } from '@backstage/integration'; @@ -211,29 +210,6 @@ export interface ContainerRunner { runContainer(opts: RunContainerOptions): Promise; } -// @alpha -export interface Context { - readonly abortSignal: AbortSignal; - readonly deadline: Date | undefined; - value(key: string): T | undefined; -} - -// @alpha -export class Contexts { - static root(): Context; - static withAbort( - parentCtx: Context, - source: AbortController | AbortSignal, - ): Context; - static withTimeoutDuration(parentCtx: Context, timeout: Duration): Context; - static withTimeoutMillis(parentCtx: Context, timeout: number): Context; - static withValue( - parentCtx: Context, - key: string, - value: unknown | ((previous: unknown | undefined) => unknown), - ): Context; -} - // @public export function createDatabaseClient( dbConfig: Config, diff --git a/packages/backend-common/package.json b/packages/backend-common/package.json index d356d67fab..e778e6830c 100644 --- a/packages/backend-common/package.json +++ b/packages/backend-common/package.json @@ -5,10 +5,21 @@ "main": "src/index.ts", "types": "src/index.ts", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "node-library" @@ -24,7 +35,7 @@ ], "license": "Apache-2.0", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", diff --git a/packages/backend-common/src/alpha.ts b/packages/backend-common/src/alpha.ts new file mode 100644 index 0000000000..e0a5b2ddc2 --- /dev/null +++ b/packages/backend-common/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 * from './context'; diff --git a/packages/backend-common/src/index.ts b/packages/backend-common/src/index.ts index 46639a1923..afb12115b2 100644 --- a/packages/backend-common/src/index.ts +++ b/packages/backend-common/src/index.ts @@ -24,7 +24,6 @@ export { legacyPlugin, makeLegacyPlugin } from './legacy'; export type { LegacyCreateRouter } from './legacy'; export * from './cache'; export { loadBackendConfig } from './config'; -export * from './context'; export * from './database'; export * from './discovery'; export * from './hot'; From 817a5cde69cae5c054907465f6fefe538f407f03 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:44:50 +0100 Subject: [PATCH 11/65] sonarcube-react: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/sonarqube-react/alpha-api-report.md | 65 +++++++++++++++++++++ plugins/sonarqube-react/package.json | 17 ++++-- 2 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 plugins/sonarqube-react/alpha-api-report.md diff --git a/plugins/sonarqube-react/alpha-api-report.md b/plugins/sonarqube-react/alpha-api-report.md new file mode 100644 index 0000000000..4fad469d12 --- /dev/null +++ b/plugins/sonarqube-react/alpha-api-report.md @@ -0,0 +1,65 @@ +## API Report File for "@backstage/plugin-sonarqube-react" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { ApiRef } from '@backstage/core-plugin-api'; +import { Entity } from '@backstage/catalog-model'; + +// @public (undocumented) +export interface FindingSummary { + // (undocumented) + getComponentMeasuresUrl: SonarUrlProcessorFunc; + // (undocumented) + getIssuesUrl: SonarUrlProcessorFunc; + // (undocumented) + getSecurityHotspotsUrl: () => string; + // (undocumented) + lastAnalysis: string; + // (undocumented) + metrics: Metrics; + // (undocumented) + projectUrl: string; +} + +// @public (undocumented) +export type MetricKey = + | 'alert_status' + | 'bugs' + | 'reliability_rating' + | 'vulnerabilities' + | 'security_rating' + | 'code_smells' + | 'sqale_rating' + | 'security_hotspots_reviewed' + | 'security_review_rating' + | 'coverage' + | 'duplicated_lines_density'; + +// @public +export type Metrics = { + [key in MetricKey]: string | undefined; +}; + +// @public (undocumented) +export type SonarQubeApi = { + getFindingSummary(options: { + componentKey?: string; + projectInstance?: string; + }): Promise; +}; + +// @public (undocumented) +export const sonarQubeApiRef: ApiRef; + +// @public (undocumented) +export type SonarUrlProcessorFunc = (identifier: string) => string; + +// @public +export const useProjectInfo: (entity: Entity) => { + projectInstance: string | undefined; + projectKey: string | undefined; +}; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/sonarqube-react/package.json b/plugins/sonarqube-react/package.json index 9006d77e84..f473d52f16 100644 --- a/plugins/sonarqube-react/package.json +++ b/plugins/sonarqube-react/package.json @@ -5,10 +5,17 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ] + } }, "backstage": { "role": "web-library" @@ -23,7 +30,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", From 2113984b961f40235ac7a0162c497959d2e56fea Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:46:59 +0100 Subject: [PATCH 12/65] scaffolder-react: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/scaffolder-react/alpha-api-report.md | 225 ++++++++++++++++++ plugins/scaffolder-react/api-report.md | 204 +--------------- plugins/scaffolder-react/package.json | 24 +- plugins/scaffolder-react/src/alpha.ts | 18 ++ plugins/scaffolder-react/src/index.ts | 2 - .../src/next/components/Stepper/Stepper.tsx | 4 +- .../src/next/extensions/index.tsx | 3 +- .../src/next/extensions/types.ts | 2 +- .../next/hooks/useTemplateParameterSchema.ts | 7 +- .../src/next/hooks/useTemplateSchema.test.tsx | 2 +- .../src/next/hooks/useTemplateSchema.ts | 2 +- .../next/hooks/useTransformSchemaToProps.ts | 2 +- plugins/scaffolder-react/src/next/types.ts | 2 +- 13 files changed, 275 insertions(+), 222 deletions(-) create mode 100644 plugins/scaffolder-react/alpha-api-report.md create mode 100644 plugins/scaffolder-react/src/alpha.ts diff --git a/plugins/scaffolder-react/alpha-api-report.md b/plugins/scaffolder-react/alpha-api-report.md new file mode 100644 index 0000000000..75d2e4fd79 --- /dev/null +++ b/plugins/scaffolder-react/alpha-api-report.md @@ -0,0 +1,225 @@ +## API Report File for "@backstage/plugin-scaffolder-react" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +/// + +import { ApiHolder } from '@backstage/core-plugin-api'; +import { ComponentType } from 'react'; +import { CustomFieldExtensionSchema } from '@backstage/plugin-scaffolder-react'; +import { Dispatch } from 'react'; +import { Extension } from '@backstage/core-plugin-api'; +import { FieldExtensionComponent } from '@backstage/plugin-scaffolder-react'; +import { FieldProps } from '@rjsf/utils'; +import { FieldValidation } from '@rjsf/utils'; +import { FormProps as FormProps_2 } from '@rjsf/core-v5'; +import { IconComponent } from '@backstage/core-plugin-api'; +import { JsonObject } from '@backstage/types'; +import { JsonValue } from '@backstage/types'; +import { LayoutOptions } from '@backstage/plugin-scaffolder-react'; +import { PropsWithChildren } from 'react'; +import { default as React_2 } from 'react'; +import { ReactNode } from 'react'; +import { RJSFSchema } from '@rjsf/utils'; +import { SetStateAction } from 'react'; +import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; +import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react'; +import { UIOptionsType } from '@rjsf/utils'; +import { UiSchema } from '@rjsf/utils'; + +// @alpha +export const createFieldValidation: () => FieldValidation; + +// @alpha +export function createNextScaffolderFieldExtension< + TReturnValue = unknown, + TInputProps extends UIOptionsType = {}, +>( + options: NextFieldExtensionOptions, +): Extension>; + +// @alpha +export const DefaultTemplateOutputs: (props: { + output?: ScaffolderTaskOutput; +}) => JSX.Element | null; + +// @alpha (undocumented) +export const EmbeddableWorkflow: (props: WorkflowProps) => JSX.Element; + +// @alpha +export const extractSchemaFromStep: (inputStep: JsonObject) => { + uiSchema: UiSchema; + schema: JsonObject; +}; + +// @alpha (undocumented) +export const Form: ComponentType>; + +// @alpha +export type FormProps = Pick< + FormProps_2, + 'transformErrors' | 'noHtml5Validate' +>; + +// @alpha +export type NextCustomFieldValidator = ( + data: TFieldReturnValue, + field: FieldValidation, + context: { + apiHolder: ApiHolder; + formData: JsonObject; + schema: JsonObject; + }, +) => void | Promise; + +// @alpha +export interface NextFieldExtensionComponentProps< + TFieldReturnValue, + TUiOptions = {}, +> extends PropsWithChildren> { + // (undocumented) + uiSchema?: UiSchema & { + 'ui:options'?: TUiOptions & UIOptionsType; + }; +} + +// @alpha +export type NextFieldExtensionOptions< + TFieldReturnValue = unknown, + TInputProps = unknown, +> = { + name: string; + component: ( + props: NextFieldExtensionComponentProps, + ) => JSX.Element | null; + validation?: NextCustomFieldValidator; + schema?: CustomFieldExtensionSchema; +}; + +// @alpha +export interface ParsedTemplateSchema { + // (undocumented) + description?: string; + // (undocumented) + mergedSchema: JsonObject; + // (undocumented) + schema: JsonObject; + // (undocumented) + title: string; + // (undocumented) + uiSchema: UiSchema; +} + +// @alpha +export const ReviewState: (props: ReviewStateProps) => JSX.Element; + +// @alpha +export type ReviewStateProps = { + schemas: ParsedTemplateSchema[]; + formState: JsonObject; +}; + +// @alpha +export const Stepper: (stepperProps: StepperProps) => JSX.Element; + +// @alpha +export type StepperProps = { + manifest: TemplateParameterSchema; + extensions: NextFieldExtensionOptions[]; + templateName?: string; + FormProps?: FormProps; + initialState?: Record; + onCreate: (values: Record) => Promise; + components?: { + ReviewStateComponent?: (props: ReviewStateProps) => JSX.Element; + createButtonText?: ReactNode; + reviewButtonText?: ReactNode; + }; + layouts?: LayoutOptions[]; +}; + +// @alpha +export const TemplateCard: (props: TemplateCardProps) => JSX.Element; + +// @alpha +export interface TemplateCardProps { + // (undocumented) + additionalLinks?: { + icon: IconComponent; + text: string; + url: string; + }[]; + // (undocumented) + onSelected?: (template: TemplateEntityV1beta3) => void; + // (undocumented) + template: TemplateEntityV1beta3; +} + +// @alpha +export const TemplateGroup: (props: TemplateGroupProps) => JSX.Element; + +// @alpha +export interface TemplateGroupProps { + // (undocumented) + components?: { + CardComponent?: React_2.ComponentType; + }; + // (undocumented) + onSelected: (template: TemplateEntityV1beta3) => void; + // (undocumented) + templates: { + template: TemplateEntityV1beta3; + additionalLinks?: { + icon: IconComponent; + text: string; + url: string; + }[]; + }[]; + // (undocumented) + title: React_2.ReactNode; +} + +// @alpha +export const useFormDataFromQuery: ( + initialState?: Record, +) => [Record, Dispatch>>]; + +// @alpha (undocumented) +export const useTemplateParameterSchema: (templateRef: string) => { + manifest: TemplateParameterSchema; + loading: boolean; + error: Error | undefined; +}; + +// @alpha +export const useTemplateSchema: (manifest: TemplateParameterSchema) => { + steps: ParsedTemplateSchema[]; +}; + +// @alpha (undocumented) +export const Workflow: (workflowProps: WorkflowProps) => JSX.Element | null; + +// @alpha (undocumented) +export type WorkflowProps = { + title?: string; + description?: string; + namespace: string; + templateName: string; + onError(error: Error | undefined): JSX.Element | null; +} & Pick< + StepperProps, + | 'extensions' + | 'FormProps' + | 'components' + | 'onCreate' + | 'initialState' + | 'layouts' +>; + +// Warnings were encountered during analysis: +// +// src/next/components/TemplateOutputs/DefaultTemplateOutputs.d.ts:9:5 - (ae-forgotten-export) The symbol "ScaffolderTaskOutput" needs to be exported by the entry point alpha.d.ts + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-react/api-report.md b/plugins/scaffolder-react/api-report.md index 69bffbf724..9b50eef884 100644 --- a/plugins/scaffolder-react/api-report.md +++ b/plugins/scaffolder-react/api-report.md @@ -7,29 +7,18 @@ import { ApiHolder } from '@backstage/core-plugin-api'; import { ApiRef } from '@backstage/core-plugin-api'; -import { ComponentType } from 'react'; -import { Dispatch } from 'react'; import { Extension } from '@backstage/core-plugin-api'; import { FieldProps } from '@rjsf/core'; -import { FieldProps as FieldProps_2 } from '@rjsf/utils'; import { FieldValidation } from '@rjsf/core'; -import { FieldValidation as FieldValidation_2 } from '@rjsf/utils'; -import { FormProps as FormProps_2 } from '@rjsf/core-v5'; -import { IconComponent } from '@backstage/core-plugin-api'; +import type { FormProps } from '@rjsf/core-v5'; import { JsonObject } from '@backstage/types'; import { JSONSchema7 } from 'json-schema'; import { JsonValue } from '@backstage/types'; import { Observable } from '@backstage/types'; import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; -import { ReactNode } from 'react'; -import { RJSFSchema } from '@rjsf/utils'; -import { SetStateAction } from 'react'; import { TaskSpec } from '@backstage/plugin-scaffolder-common'; import { TaskStep } from '@backstage/plugin-scaffolder-common'; -import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; -import { UIOptionsType } from '@rjsf/utils'; -import { UiSchema } from '@rjsf/utils'; // @public export type Action = { @@ -48,17 +37,6 @@ export type ActionExample = { example: string; }; -// @alpha -export const createFieldValidation: () => FieldValidation_2; - -// @alpha -export function createNextScaffolderFieldExtension< - TReturnValue = unknown, - TInputProps extends UIOptionsType = {}, ->( - options: NextFieldExtensionOptions, -): Extension>; - // @public export function createScaffolderFieldExtension< TReturnValue = unknown, @@ -87,20 +65,6 @@ export type CustomFieldValidator = ( }, ) => void | Promise; -// @alpha -export const DefaultTemplateOutputs: (props: { - output?: ScaffolderTaskOutput; -}) => JSX.Element | null; - -// @alpha (undocumented) -export const EmbeddableWorkflow: (props: WorkflowProps) => JSX.Element; - -// @alpha -export const extractSchemaFromStep: (inputStep: JsonObject) => { - uiSchema: UiSchema; - schema: JsonObject; -}; - // @public export type FieldExtensionComponent<_TReturnValue, _TInputProps> = () => null; @@ -128,15 +92,6 @@ export type FieldExtensionOptions< schema?: CustomFieldExtensionSchema; }; -// @alpha (undocumented) -export const Form: ComponentType>; - -// @public -export type FormProps = Pick< - FormProps_2, - 'transformErrors' | 'noHtml5Validate' ->; - // @public export type LayoutComponent<_TInputProps> = () => null; @@ -150,7 +105,7 @@ export interface LayoutOptions

{ // @public export type LayoutTemplate = NonNullable< - FormProps_2['uiSchema'] + FormProps['uiSchema'] >['ui:ObjectFieldTemplate']; // @public @@ -169,64 +124,6 @@ export type LogEvent = { taskId: string; }; -// @alpha -export type NextCustomFieldValidator = ( - data: TFieldReturnValue, - field: FieldValidation_2, - context: { - apiHolder: ApiHolder; - formData: JsonObject; - schema: JsonObject; - }, -) => void | Promise; - -// @alpha -export interface NextFieldExtensionComponentProps< - TFieldReturnValue, - TUiOptions = {}, -> extends PropsWithChildren> { - // (undocumented) - uiSchema?: UiSchema & { - 'ui:options'?: TUiOptions & UIOptionsType; - }; -} - -// @alpha -export type NextFieldExtensionOptions< - TFieldReturnValue = unknown, - TInputProps = unknown, -> = { - name: string; - component: ( - props: NextFieldExtensionComponentProps, - ) => JSX.Element | null; - validation?: NextCustomFieldValidator; - schema?: CustomFieldExtensionSchema; -}; - -// @alpha -export interface ParsedTemplateSchema { - // (undocumented) - description?: string; - // (undocumented) - mergedSchema: JsonObject; - // (undocumented) - schema: JsonObject; - // (undocumented) - title: string; - // (undocumented) - uiSchema: UiSchema; -} - -// @alpha -export const ReviewState: (props: ReviewStateProps) => JSX.Element; - -// @alpha -export type ReviewStateProps = { - schemas: ParsedTemplateSchema[]; - formState: JsonObject; -}; - // @public export interface ScaffolderApi { // (undocumented) @@ -380,66 +277,6 @@ export const SecretsContextProvider: ({ children, }: PropsWithChildren<{}>) => JSX.Element; -// @alpha -export const Stepper: (stepperProps: StepperProps) => JSX.Element; - -// @alpha -export type StepperProps = { - manifest: TemplateParameterSchema; - extensions: NextFieldExtensionOptions[]; - templateName?: string; - FormProps?: FormProps; - initialState?: Record; - onCreate: (values: Record) => Promise; - components?: { - ReviewStateComponent?: (props: ReviewStateProps) => JSX.Element; - createButtonText?: ReactNode; - reviewButtonText?: ReactNode; - }; - layouts?: LayoutOptions[]; -}; - -// @alpha -export const TemplateCard: (props: TemplateCardProps) => JSX.Element; - -// @alpha -export interface TemplateCardProps { - // (undocumented) - additionalLinks?: { - icon: IconComponent; - text: string; - url: string; - }[]; - // (undocumented) - onSelected?: (template: TemplateEntityV1beta3) => void; - // (undocumented) - template: TemplateEntityV1beta3; -} - -// @alpha -export const TemplateGroup: (props: TemplateGroupProps) => JSX.Element; - -// @alpha -export interface TemplateGroupProps { - // (undocumented) - components?: { - CardComponent?: React_2.ComponentType; - }; - // (undocumented) - onSelected: (template: TemplateEntityV1beta3) => void; - // (undocumented) - templates: { - template: TemplateEntityV1beta3; - additionalLinks?: { - icon: IconComponent; - text: string; - url: string; - }[]; - }[]; - // (undocumented) - title: React_2.ReactNode; -} - // @public export type TemplateParameterSchema = { title: string; @@ -463,45 +300,8 @@ export const useCustomLayouts: >( outlet: React.ReactNode, ) => TComponentDataType[]; -// @alpha -export const useFormDataFromQuery: ( - initialState?: Record, -) => [Record, Dispatch>>]; - -// @alpha (undocumented) -export const useTemplateParameterSchema: (templateRef: string) => { - manifest: TemplateParameterSchema | undefined; - loading: boolean; - error: Error | undefined; -}; - -// @alpha -export const useTemplateSchema: (manifest: TemplateParameterSchema) => { - steps: ParsedTemplateSchema[]; -}; - // @public export const useTemplateSecrets: () => ScaffolderUseTemplateSecrets; -// @alpha (undocumented) -export const Workflow: (workflowProps: WorkflowProps) => JSX.Element | null; - -// @alpha (undocumented) -export type WorkflowProps = { - title?: string; - description?: string; - namespace: string; - templateName: string; - onError(error: Error | undefined): JSX.Element | null; -} & Pick< - StepperProps, - | 'extensions' - | 'FormProps' - | 'components' - | 'onCreate' - | 'initialState' - | 'layouts' ->; - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/scaffolder-react/package.json b/plugins/scaffolder-react/package.json index 043c9d5ee2..4a4d94debf 100644 --- a/plugins/scaffolder-react/package.json +++ b/plugins/scaffolder-react/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "web-library" @@ -24,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -80,7 +91,6 @@ "@testing-library/user-event": "^14.0.0" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/plugins/scaffolder-react/src/alpha.ts b/plugins/scaffolder-react/src/alpha.ts new file mode 100644 index 0000000000..731b8e07d9 --- /dev/null +++ b/plugins/scaffolder-react/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2022 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 * from './next'; +export type { FormProps } from './next'; diff --git a/plugins/scaffolder-react/src/index.ts b/plugins/scaffolder-react/src/index.ts index 67703e3ed1..1b20c19414 100644 --- a/plugins/scaffolder-react/src/index.ts +++ b/plugins/scaffolder-react/src/index.ts @@ -20,5 +20,3 @@ export * from './secrets'; export * from './api'; export * from './hooks'; export * from './layouts'; - -export * from './next'; diff --git a/plugins/scaffolder-react/src/next/components/Stepper/Stepper.tsx b/plugins/scaffolder-react/src/next/components/Stepper/Stepper.tsx index bb2844fd52..444e463064 100644 --- a/plugins/scaffolder-react/src/next/components/Stepper/Stepper.tsx +++ b/plugins/scaffolder-react/src/next/components/Stepper/Stepper.tsx @@ -26,7 +26,7 @@ import { type IChangeEvent } from '@rjsf/core-v5'; import { ErrorSchema } from '@rjsf/utils'; import React, { useCallback, useMemo, useState, type ReactNode } from 'react'; import { NextFieldExtensionOptions } from '../../extensions'; -import { TemplateParameterSchema } from '../../../types'; +import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react'; import { createAsyncValidators, type FormValidation, @@ -36,7 +36,7 @@ import { useTemplateSchema } from '../../hooks/useTemplateSchema'; import validator from '@rjsf/validator-ajv8'; import { useFormDataFromQuery } from '../../hooks'; import { FormProps } from '../../types'; -import { LayoutOptions } from '../../../layouts'; +import { LayoutOptions } from '@backstage/plugin-scaffolder-react'; import { useTransformSchemaToProps } from '../../hooks/useTransformSchemaToProps'; import { hasErrors } from './utils'; import * as FieldOverrides from './FieldOverrides'; diff --git a/plugins/scaffolder-react/src/next/extensions/index.tsx b/plugins/scaffolder-react/src/next/extensions/index.tsx index ee9b1cd326..b2d402c93f 100644 --- a/plugins/scaffolder-react/src/next/extensions/index.tsx +++ b/plugins/scaffolder-react/src/next/extensions/index.tsx @@ -21,7 +21,8 @@ import { } from './types'; import { Extension, attachComponentData } from '@backstage/core-plugin-api'; import { UIOptionsType } from '@rjsf/utils'; -import { FieldExtensionComponent } from '../../extensions'; +// eslint-disable-next-line import/no-extraneous-dependencies +import { FieldExtensionComponent } from '@backstage/plugin-scaffolder-react'; import { FIELD_EXTENSION_KEY } from '../../extensions/keys'; /** diff --git a/plugins/scaffolder-react/src/next/extensions/types.ts b/plugins/scaffolder-react/src/next/extensions/types.ts index 1e4c671511..0917efe85d 100644 --- a/plugins/scaffolder-react/src/next/extensions/types.ts +++ b/plugins/scaffolder-react/src/next/extensions/types.ts @@ -22,7 +22,7 @@ import { } from '@rjsf/utils'; import { PropsWithChildren } from 'react'; import { JsonObject } from '@backstage/types'; -import { CustomFieldExtensionSchema } from '../../extensions'; +import { CustomFieldExtensionSchema } from '@backstage/plugin-scaffolder-react'; /** * Type for Field Extension Props for RJSF v5 diff --git a/plugins/scaffolder-react/src/next/hooks/useTemplateParameterSchema.ts b/plugins/scaffolder-react/src/next/hooks/useTemplateParameterSchema.ts index 36b8b1e0bc..d060b9a09f 100644 --- a/plugins/scaffolder-react/src/next/hooks/useTemplateParameterSchema.ts +++ b/plugins/scaffolder-react/src/next/hooks/useTemplateParameterSchema.ts @@ -1,5 +1,3 @@ -import { useApi } from '@backstage/core-plugin-api'; - /* * Copyright 2023 The Backstage Authors * @@ -15,8 +13,11 @@ import { useApi } from '@backstage/core-plugin-api'; * See the License for the specific language governing permissions and * limitations under the License. */ + import useAsync from 'react-use/lib/useAsync'; import { scaffolderApiRef } from '../../api/ref'; +import { useApi } from '@backstage/core-plugin-api'; +import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react'; /** * @alpha @@ -28,5 +29,5 @@ export const useTemplateParameterSchema = (templateRef: string) => { [scaffolderApi, templateRef], ); - return { manifest: value, loading, error }; + return { manifest: value as TemplateParameterSchema, loading, error }; }; diff --git a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx index 153c48468d..ab33652338 100644 --- a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx +++ b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.test.tsx @@ -18,7 +18,7 @@ import { renderHook } from '@testing-library/react-hooks'; import { TestApiProvider } from '@backstage/test-utils'; import React from 'react'; import { featureFlagsApiRef } from '@backstage/core-plugin-api'; -import { TemplateParameterSchema } from '../../types'; +import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react'; describe('useTemplateSchema', () => { it('should generate the correct schema', () => { diff --git a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts index 2b2e48cf68..26980b15cf 100644 --- a/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts +++ b/plugins/scaffolder-react/src/next/hooks/useTemplateSchema.ts @@ -16,7 +16,7 @@ import { featureFlagsApiRef, useApi } from '@backstage/core-plugin-api'; import { JsonObject } from '@backstage/types'; import { UiSchema } from '@rjsf/utils'; -import { TemplateParameterSchema } from '../../types'; +import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react'; import { extractSchemaFromStep } from '../lib'; /** diff --git a/plugins/scaffolder-react/src/next/hooks/useTransformSchemaToProps.ts b/plugins/scaffolder-react/src/next/hooks/useTransformSchemaToProps.ts index 881c4f90c5..612ad5427b 100644 --- a/plugins/scaffolder-react/src/next/hooks/useTransformSchemaToProps.ts +++ b/plugins/scaffolder-react/src/next/hooks/useTransformSchemaToProps.ts @@ -14,7 +14,7 @@ * limitations under the License. */ import { type ParsedTemplateSchema } from './useTemplateSchema'; -import { type LayoutOptions } from '../../layouts'; +import { type LayoutOptions } from '@backstage/plugin-scaffolder-react'; interface Options { layouts?: LayoutOptions[]; diff --git a/plugins/scaffolder-react/src/next/types.ts b/plugins/scaffolder-react/src/next/types.ts index 54a64a5323..192fdf4146 100644 --- a/plugins/scaffolder-react/src/next/types.ts +++ b/plugins/scaffolder-react/src/next/types.ts @@ -23,7 +23,7 @@ import type { FormProps as SchemaFormProps } from '@rjsf/core-v5'; /** * Any `@rjsf/core` form properties that are publicly exposed to the `NextScaffolderpage` * - * @public + * @alpha */ export type FormProps = Pick< SchemaFormProps, From 8fc53d440f2abbb40ee3338d7a0f190e5d67aeee Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 00:51:27 +0100 Subject: [PATCH 13/65] scaffolder-backend: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../scaffolder-backend/alpha-api-report.md | 30 +++++++++++++++++++ plugins/scaffolder-backend/api-report.md | 18 ----------- plugins/scaffolder-backend/package.json | 22 ++++++++++---- .../src/ScaffolderPlugin.ts | 8 +++-- plugins/scaffolder-backend/src/alpha.ts | 19 ++++++++++++ plugins/scaffolder-backend/src/index.ts | 3 -- 6 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 plugins/scaffolder-backend/alpha-api-report.md create mode 100644 plugins/scaffolder-backend/src/alpha.ts diff --git a/plugins/scaffolder-backend/alpha-api-report.md b/plugins/scaffolder-backend/alpha-api-report.md new file mode 100644 index 0000000000..3199444c6b --- /dev/null +++ b/plugins/scaffolder-backend/alpha-api-report.md @@ -0,0 +1,30 @@ +## API Report File for "@backstage/plugin-scaffolder-backend" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; +import { TaskBroker } from '@backstage/plugin-scaffolder-backend'; +import { TemplateAction } from '@backstage/plugin-scaffolder-node'; +import { TemplateFilter } from '@backstage/plugin-scaffolder-backend'; +import { TemplateGlobal } from '@backstage/plugin-scaffolder-backend'; + +// @alpha +export const catalogModuleTemplateKind: () => BackendFeature; + +// @alpha +export const scaffolderPlugin: ( + options: ScaffolderPluginOptions, +) => BackendFeature; + +// @alpha +export type ScaffolderPluginOptions = { + actions?: TemplateAction[]; + taskWorkers?: number; + taskBroker?: TaskBroker; + additionalTemplateFilters?: Record; + additionalTemplateGlobals?: Record; +}; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder-backend/api-report.md b/plugins/scaffolder-backend/api-report.md index 0d745862a1..293ff7ed29 100644 --- a/plugins/scaffolder-backend/api-report.md +++ b/plugins/scaffolder-backend/api-report.md @@ -6,7 +6,6 @@ /// import { ActionContext as ActionContext_2 } from '@backstage/plugin-scaffolder-node'; -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogApi } from '@backstage/catalog-client'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; @@ -38,9 +37,6 @@ import { Writable } from 'stream'; // @public @deprecated (undocumented) export type ActionContext = ActionContext_2; -// @alpha -export const catalogModuleTemplateKind: () => BackendFeature; - // @public export const createBuiltinActions: ( options: CreateBuiltInActionsOptions, @@ -666,20 +662,6 @@ export class ScaffolderEntitiesProcessor implements CatalogProcessor { validateEntityKind(entity: Entity): Promise; } -// @alpha -export const scaffolderPlugin: ( - options: ScaffolderPluginOptions, -) => BackendFeature; - -// @alpha -export type ScaffolderPluginOptions = { - actions?: TemplateAction_2[]; - taskWorkers?: number; - taskBroker?: TaskBroker; - additionalTemplateFilters?: Record; - additionalTemplateGlobals?: Record; -}; - // @public export type SerializedTask = { id: string; diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index e9c21deeb2..3eda8bd678 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -100,7 +111,6 @@ "yaml": "^2.0.0" }, "files": [ - "alpha", "dist", "migrations", "config.d.ts", diff --git a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts index 3b0d26be21..852c0f73e2 100644 --- a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts +++ b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts @@ -26,8 +26,12 @@ import { ScaffolderActionsExtensionPoint, TemplateAction, } from '@backstage/plugin-scaffolder-node'; -import { TemplateFilter, TemplateGlobal } from './lib'; -import { createBuiltinActions, TaskBroker } from './scaffolder'; +import { + TemplateFilter, + TemplateGlobal, + TaskBroker, +} from '@backstage/plugin-scaffolder-backend'; +import { createBuiltinActions } from './scaffolder'; import { createRouter } from './service/router'; /** diff --git a/plugins/scaffolder-backend/src/alpha.ts b/plugins/scaffolder-backend/src/alpha.ts new file mode 100644 index 0000000000..ac96f081ad --- /dev/null +++ b/plugins/scaffolder-backend/src/alpha.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2020 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 * from './modules'; +export { scaffolderPlugin } from './ScaffolderPlugin'; +export type { ScaffolderPluginOptions } from './ScaffolderPlugin'; diff --git a/plugins/scaffolder-backend/src/index.ts b/plugins/scaffolder-backend/src/index.ts index ba69a55a24..ba2c25f80a 100644 --- a/plugins/scaffolder-backend/src/index.ts +++ b/plugins/scaffolder-backend/src/index.ts @@ -24,8 +24,5 @@ export * from './scaffolder'; export * from './service/router'; export * from './lib'; export * from './processor'; -export * from './modules'; -export { scaffolderPlugin } from './ScaffolderPlugin'; -export type { ScaffolderPluginOptions } from './ScaffolderPlugin'; export * from './deprecated'; From 7543832df1bbf8f02f42b7d482f932b42c318d86 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 01:01:48 +0100 Subject: [PATCH 14/65] scaffolder: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/scaffolder/alpha-api-report.md | 70 +++++++++++++++++++ plugins/scaffolder/api-report.md | 65 ++--------------- plugins/scaffolder/package.json | 24 +++++-- plugins/scaffolder/src/alpha.ts | 25 +++++++ .../MultistepJsonForm/MultistepJsonForm.tsx | 6 +- plugins/scaffolder/src/index.ts | 11 --- .../src/next/OngoingTask/OngoingTask.tsx | 6 +- plugins/scaffolder/src/next/Router/Router.tsx | 4 +- .../CustomFieldExplorer.tsx | 2 +- .../TemplateEditorPage/TemplateEditor.tsx | 6 +- .../TemplateEditorPage/TemplateEditorForm.tsx | 6 +- .../TemplateEditorPage/TemplateEditorPage.tsx | 6 +- .../TemplateFormPreviewer.tsx | 6 +- .../TemplateListPage/TemplateGroups.test.tsx | 2 +- .../next/TemplateListPage/TemplateGroups.tsx | 2 +- .../TemplateWizardPage/TemplateWizardPage.tsx | 6 +- 16 files changed, 141 insertions(+), 106 deletions(-) create mode 100644 plugins/scaffolder/alpha-api-report.md create mode 100644 plugins/scaffolder/src/alpha.ts diff --git a/plugins/scaffolder/alpha-api-report.md b/plugins/scaffolder/alpha-api-report.md new file mode 100644 index 0000000000..bf37acafc3 --- /dev/null +++ b/plugins/scaffolder/alpha-api-report.md @@ -0,0 +1,70 @@ +## API Report File for "@backstage/plugin-scaffolder" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +/// + +import { Entity } from '@backstage/catalog-model'; +import { FormProps as FormProps_2 } from '@backstage/plugin-scaffolder-react/alpha'; +import type { FormProps as FormProps_3 } from '@rjsf/core-v5'; +import { PathParams } from '@backstage/core-plugin-api'; +import { PropsWithChildren } from 'react'; +import { default as React_2 } from 'react'; +import { RouteRef } from '@backstage/core-plugin-api'; +import { ScaffolderTaskOutput } from '@backstage/plugin-scaffolder-react'; +import { SubRouteRef } from '@backstage/core-plugin-api'; +import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; + +// @alpha @deprecated +export type FormProps = Pick< + FormProps_3, + 'transformErrors' | 'noHtml5Validate' +>; + +// @alpha (undocumented) +export const nextRouteRef: RouteRef; + +// @alpha +export type NextRouterProps = { + components?: { + TemplateCardComponent?: React_2.ComponentType<{ + template: TemplateEntityV1beta3; + }>; + TaskPageComponent?: React_2.ComponentType<{}>; + TemplateOutputsComponent?: React_2.ComponentType<{ + output?: ScaffolderTaskOutput; + }>; + }; + groups?: TemplateGroupFilter[]; + FormProps?: FormProps_2; + contextMenu?: { + editor?: boolean; + actions?: boolean; + tasks?: boolean; + }; +}; + +// @alpha +export const NextScaffolderPage: ( + props: PropsWithChildren, +) => JSX.Element; + +// @alpha (undocumented) +export const nextScaffolderTaskRouteRef: SubRouteRef< + PathParams<'/tasks/:taskId'> +>; + +// @alpha (undocumented) +export const nextSelectedTemplateRouteRef: SubRouteRef< + PathParams<'/templates/:namespace/:templateName'> +>; + +// @alpha (undocumented) +export type TemplateGroupFilter = { + title?: React_2.ReactNode; + filter: (entity: Entity) => boolean; +}; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index 43b885b81a..7030affeea 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -21,8 +21,6 @@ import { FieldExtensionComponent as FieldExtensionComponent_2 } from '@backstage import { FieldExtensionComponentProps as FieldExtensionComponentProps_2 } from '@backstage/plugin-scaffolder-react'; import { FieldExtensionOptions as FieldExtensionOptions_2 } from '@backstage/plugin-scaffolder-react'; import { FieldValidation } from '@rjsf/core'; -import { FormProps as FormProps_2 } from '@backstage/plugin-scaffolder-react'; -import type { FormProps as FormProps_3 } from '@rjsf/core-v5'; import { IdentityApi } from '@backstage/core-plugin-api'; import { JsonObject } from '@backstage/types'; import { LayoutOptions as LayoutOptions_2 } from '@backstage/plugin-scaffolder-react'; @@ -31,7 +29,6 @@ import { ListActionsResponse as ListActionsResponse_2 } from '@backstage/plugin- import { LogEvent as LogEvent_2 } from '@backstage/plugin-scaffolder-react'; import { Observable } from '@backstage/types'; import { PathParams } from '@backstage/core-plugin-api'; -import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; @@ -112,9 +109,9 @@ export type EntityPickerUiOptions = export const EntityTagsPickerFieldExtension: FieldExtensionComponent_2< string[], { - showCounts?: boolean | undefined; - kinds?: string[] | undefined; helperText?: string | undefined; + kinds?: string[] | undefined; + showCounts?: boolean | undefined; } >; @@ -122,9 +119,9 @@ export const EntityTagsPickerFieldExtension: FieldExtensionComponent_2< export const EntityTagsPickerFieldSchema: FieldSchema< string[], { - showCounts?: boolean | undefined; - kinds?: string[] | undefined; helperText?: string | undefined; + kinds?: string[] | undefined; + showCounts?: boolean | undefined; } >; @@ -155,12 +152,6 @@ export interface FieldSchema { readonly uiOptionsType: TUiOptions; } -// @alpha @deprecated -export type FormProps = Pick< - FormProps_3, - 'transformErrors' | 'noHtml5Validate' ->; - // @public @deprecated (undocumented) export type LayoutOptions = LayoutOptions_2; @@ -187,44 +178,6 @@ export function makeFieldSchemaFromZod< : never >; -// @alpha (undocumented) -export const nextRouteRef: RouteRef; - -// @alpha -export type NextRouterProps = { - components?: { - TemplateCardComponent?: React_2.ComponentType<{ - template: TemplateEntityV1beta3; - }>; - TaskPageComponent?: React_2.ComponentType<{}>; - TemplateOutputsComponent?: React_2.ComponentType<{ - output?: ScaffolderTaskOutput_2; - }>; - }; - groups?: TemplateGroupFilter[]; - FormProps?: FormProps_2; - contextMenu?: { - editor?: boolean; - actions?: boolean; - tasks?: boolean; - }; -}; - -// @alpha -export const NextScaffolderPage: ( - props: PropsWithChildren, -) => JSX.Element; - -// @alpha (undocumented) -export const nextScaffolderTaskRouteRef: SubRouteRef< - PathParams<'/tasks/:taskId'> ->; - -// @alpha (undocumented) -export const nextSelectedTemplateRouteRef: SubRouteRef< - PathParams<'/templates/:namespace/:templateName'> ->; - // @public export const OwnedEntityPickerFieldExtension: FieldExtensionComponent_2< string, @@ -306,8 +259,8 @@ export const RepoUrlPickerFieldExtension: FieldExtensionComponent_2< | { azure?: string[] | undefined; github?: string[] | undefined; - gitlab?: string[] | undefined; bitbucket?: string[] | undefined; + gitlab?: string[] | undefined; gerrit?: string[] | undefined; } | undefined; @@ -332,8 +285,8 @@ export const RepoUrlPickerFieldSchema: FieldSchema< | { azure?: string[] | undefined; github?: string[] | undefined; - gitlab?: string[] | undefined; bitbucket?: string[] | undefined; + gitlab?: string[] | undefined; gerrit?: string[] | undefined; } | undefined; @@ -514,12 +467,6 @@ export type TaskPageProps = { loadingText?: string; }; -// @alpha (undocumented) -export type TemplateGroupFilter = { - title?: React_2.ReactNode; - filter: (entity: Entity) => boolean; -}; - // @public @deprecated (undocumented) export type TemplateParameterSchema = TemplateParameterSchema_2; diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json index 5eac3c7a0d..b4fb81fb9c 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "frontend-plugin" @@ -24,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "start": "backstage-cli package start", "lint": "backstage-cli package lint", "test": "backstage-cli package test", @@ -99,7 +110,6 @@ "msw": "^0.49.0" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/plugins/scaffolder/src/alpha.ts b/plugins/scaffolder/src/alpha.ts new file mode 100644 index 0000000000..a460b0d7cc --- /dev/null +++ b/plugins/scaffolder/src/alpha.ts @@ -0,0 +1,25 @@ +/* + * Copyright 2023 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 { NextScaffolderPage } from './plugin'; +export { + nextRouteRef, + nextScaffolderTaskRouteRef, + nextSelectedTemplateRouteRef, + type TemplateGroupFilter, + type NextRouterProps, + type FormProps, +} from './next'; diff --git a/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx b/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx index a74b65b885..0924c4f2e6 100644 --- a/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx +++ b/plugins/scaffolder/src/components/MultistepJsonForm/MultistepJsonForm.tsx @@ -37,11 +37,9 @@ import cloneDeep from 'lodash/cloneDeep'; import * as fieldOverrides from './FieldOverrides'; import { ReviewStepProps } from '../types'; import { ReviewStep } from './ReviewStep'; -import { - extractSchemaFromStep, - type LayoutOptions, -} from '@backstage/plugin-scaffolder-react'; +import { extractSchemaFromStep } from '@backstage/plugin-scaffolder-react/alpha'; import { selectedTemplateRouteRef } from '../../routes'; +import { LayoutOptions } from '@backstage/plugin-scaffolder-react'; const Form = withTheme(MuiTheme); diff --git a/plugins/scaffolder/src/index.ts b/plugins/scaffolder/src/index.ts index aa78874f9d..bc56629a2c 100644 --- a/plugins/scaffolder/src/index.ts +++ b/plugins/scaffolder/src/index.ts @@ -34,14 +34,3 @@ export { export * from './components'; export * from './deprecated'; - -/** next exports */ -export { NextScaffolderPage } from './plugin'; -export { - nextRouteRef, - nextScaffolderTaskRouteRef, - nextSelectedTemplateRouteRef, - type TemplateGroupFilter, - type NextRouterProps, - type FormProps, -} from './next'; diff --git a/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx b/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx index a68df01ed5..d0aaf4b838 100644 --- a/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx +++ b/plugins/scaffolder/src/next/OngoingTask/OngoingTask.tsx @@ -25,10 +25,8 @@ import { nextSelectedTemplateRouteRef } from '../routes'; import { useRouteRef } from '@backstage/core-plugin-api'; import qs from 'qs'; import { ContextMenu } from './ContextMenu'; -import { - DefaultTemplateOutputs, - ScaffolderTaskOutput, -} from '@backstage/plugin-scaffolder-react'; +import { ScaffolderTaskOutput } from '@backstage/plugin-scaffolder-react'; +import { DefaultTemplateOutputs } from '@backstage/plugin-scaffolder-react/alpha'; const useStyles = makeStyles({ contentWrapper: { diff --git a/plugins/scaffolder/src/next/Router/Router.tsx b/plugins/scaffolder/src/next/Router/Router.tsx index ded344b048..5e199cae9b 100644 --- a/plugins/scaffolder/src/next/Router/Router.tsx +++ b/plugins/scaffolder/src/next/Router/Router.tsx @@ -19,11 +19,13 @@ import { TemplateListPage } from '../TemplateListPage'; import { TemplateWizardPage } from '../TemplateWizardPage'; import { NextFieldExtensionOptions, + FormProps, +} from '@backstage/plugin-scaffolder-react/alpha'; +import { ScaffolderTaskOutput, SecretsContextProvider, useCustomFieldExtensions, useCustomLayouts, - type FormProps, } from '@backstage/plugin-scaffolder-react'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; diff --git a/plugins/scaffolder/src/next/TemplateEditorPage/CustomFieldExplorer.tsx b/plugins/scaffolder/src/next/TemplateEditorPage/CustomFieldExplorer.tsx index d0852a6a31..823d5b164a 100644 --- a/plugins/scaffolder/src/next/TemplateEditorPage/CustomFieldExplorer.tsx +++ b/plugins/scaffolder/src/next/TemplateEditorPage/CustomFieldExplorer.tsx @@ -34,7 +34,7 @@ import yaml from 'yaml'; import { NextFieldExtensionOptions, Form, -} from '@backstage/plugin-scaffolder-react'; +} from '@backstage/plugin-scaffolder-react/alpha'; import { TemplateEditorForm } from './TemplateEditorForm'; import validator from '@rjsf/validator-ajv8'; diff --git a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditor.tsx b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditor.tsx index 4cdd383f83..16067e8095 100644 --- a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditor.tsx +++ b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditor.tsx @@ -15,10 +15,8 @@ */ import { makeStyles } from '@material-ui/core'; import React, { useState } from 'react'; -import type { - LayoutOptions, - NextFieldExtensionOptions, -} from '@backstage/plugin-scaffolder-react'; +import type { LayoutOptions } from '@backstage/plugin-scaffolder-react'; +import { NextFieldExtensionOptions } from '@backstage/plugin-scaffolder-react/alpha'; import { TemplateDirectoryAccess } from '../../lib/filesystem'; import { DirectoryEditorProvider } from '../../components/TemplateEditorPage/DirectoryEditorContext'; import { DryRunProvider } from '../../components/TemplateEditorPage/DryRunContext'; diff --git a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorForm.tsx b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorForm.tsx index 5dc841cf20..898487e200 100644 --- a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorForm.tsx +++ b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorForm.tsx @@ -21,10 +21,12 @@ import useDebounce from 'react-use/lib/useDebounce'; import yaml from 'yaml'; import { LayoutOptions, - NextFieldExtensionOptions, - Stepper, TemplateParameterSchema, } from '@backstage/plugin-scaffolder-react'; +import { + NextFieldExtensionOptions, + Stepper, +} from '@backstage/plugin-scaffolder-react/alpha'; import { useDryRun } from '../../components/TemplateEditorPage/DryRunContext'; import { useDirectoryEditor } from '../../components/TemplateEditorPage/DirectoryEditorContext'; diff --git a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorPage.tsx b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorPage.tsx index 92387fd69d..9863e99c73 100644 --- a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorPage.tsx +++ b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateEditorPage.tsx @@ -22,10 +22,8 @@ import { import { CustomFieldExplorer } from './CustomFieldExplorer'; import { TemplateEditor } from './TemplateEditor'; import { TemplateFormPreviewer } from './TemplateFormPreviewer'; -import { - NextFieldExtensionOptions, - type LayoutOptions, -} from '@backstage/plugin-scaffolder-react'; +import { type LayoutOptions } from '@backstage/plugin-scaffolder-react'; +import { NextFieldExtensionOptions } from '@backstage/plugin-scaffolder-react/alpha'; import { TemplateEditorIntro } from '../../components/TemplateEditorPage/TemplateEditorIntro'; type Selection = diff --git a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateFormPreviewer.tsx b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateFormPreviewer.tsx index 1476cda2d0..2aa1cc764d 100644 --- a/plugins/scaffolder/src/next/TemplateEditorPage/TemplateFormPreviewer.tsx +++ b/plugins/scaffolder/src/next/TemplateEditorPage/TemplateFormPreviewer.tsx @@ -32,10 +32,8 @@ import CloseIcon from '@material-ui/icons/Close'; import React, { useCallback, useState } from 'react'; import useAsync from 'react-use/lib/useAsync'; import yaml from 'yaml'; -import { - NextFieldExtensionOptions, - type LayoutOptions, -} from '@backstage/plugin-scaffolder-react'; +import { type LayoutOptions } from '@backstage/plugin-scaffolder-react'; +import { NextFieldExtensionOptions } from '@backstage/plugin-scaffolder-react/alpha'; import { TemplateEditorForm } from './TemplateEditorForm'; import { TemplateEditorTextArea } from '../../components/TemplateEditorPage/TemplateEditorTextArea'; diff --git a/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx b/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx index f76c1a4ab6..19a9728f37 100644 --- a/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx +++ b/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx @@ -27,7 +27,7 @@ import { useEntityList } from '@backstage/plugin-catalog-react'; import { TemplateGroups } from './TemplateGroups'; import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import { errorApiRef } from '@backstage/core-plugin-api'; -import { TemplateGroup } from '@backstage/plugin-scaffolder-react'; +import { TemplateGroup } from '@backstage/plugin-scaffolder-react/alpha'; import { nextRouteRef } from '../routes'; describe('TemplateGroups', () => { diff --git a/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.tsx b/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.tsx index 485b0e40cd..590ef802bd 100644 --- a/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.tsx +++ b/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.tsx @@ -30,7 +30,7 @@ import { useApp, useRouteRef, } from '@backstage/core-plugin-api'; -import { TemplateGroup } from '@backstage/plugin-scaffolder-react'; +import { TemplateGroup } from '@backstage/plugin-scaffolder-react/alpha'; import { viewTechDocRouteRef } from '../../routes'; import { nextSelectedTemplateRouteRef } from '../routes'; import { useNavigate } from 'react-router-dom'; diff --git a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx index b71d0bd7a3..4825715fcb 100644 --- a/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx +++ b/plugins/scaffolder/src/next/TemplateWizardPage/TemplateWizardPage.tsx @@ -25,13 +25,13 @@ import { import { scaffolderApiRef, useTemplateSecrets, - Workflow, type LayoutOptions, } from '@backstage/plugin-scaffolder-react'; import { - NextFieldExtensionOptions, FormProps, -} from '@backstage/plugin-scaffolder-react'; + Workflow, + NextFieldExtensionOptions, +} from '@backstage/plugin-scaffolder-react/alpha'; import { JsonValue } from '@backstage/types'; import { Header, Page } from '@backstage/core-components'; import { From 334baa32b092ffece5f6ac505a39ddb0e5ee176f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 01:04:13 +0100 Subject: [PATCH 15/65] events-node: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/events-node/alpha-api-report.md | 36 +++++++++++++++++++++++++ plugins/events-node/api-report.md | 21 --------------- plugins/events-node/package.json | 22 ++++++++++----- plugins/events-node/src/alpha.ts | 18 +++++++++++++ plugins/events-node/src/index.ts | 2 -- 5 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 plugins/events-node/alpha-api-report.md create mode 100644 plugins/events-node/src/alpha.ts diff --git a/plugins/events-node/alpha-api-report.md b/plugins/events-node/alpha-api-report.md new file mode 100644 index 0000000000..161f80ff87 --- /dev/null +++ b/plugins/events-node/alpha-api-report.md @@ -0,0 +1,36 @@ +## API Report File for "@backstage/plugin-events-node" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { ExtensionPoint } from '@backstage/backend-plugin-api'; + +// @alpha (undocumented) +export interface EventsExtensionPoint { + // Warning: (ae-forgotten-export) The symbol "HttpPostIngressOptions" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + addHttpPostIngress(options: HttpPostIngressOptions): void; + // Warning: (ae-forgotten-export) The symbol "EventPublisher" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + addPublishers( + ...publishers: Array> + ): void; + // Warning: (ae-forgotten-export) The symbol "EventSubscriber" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + addSubscribers( + ...subscribers: Array> + ): void; + // Warning: (ae-forgotten-export) The symbol "EventBroker" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + setEventBroker(eventBroker: EventBroker): void; +} + +// @alpha (undocumented) +export const eventsExtensionPoint: ExtensionPoint; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-node/api-report.md b/plugins/events-node/api-report.md index 8428003b85..dfda48d97e 100644 --- a/plugins/events-node/api-report.md +++ b/plugins/events-node/api-report.md @@ -3,8 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { ExtensionPoint } from '@backstage/backend-plugin-api'; - // @public export interface EventBroker { publish(params: EventParams): Promise; @@ -40,25 +38,6 @@ export abstract class EventRouter implements EventPublisher, EventSubscriber { abstract supportsEventTopics(): string[]; } -// @alpha (undocumented) -export interface EventsExtensionPoint { - // (undocumented) - addHttpPostIngress(options: HttpPostIngressOptions): void; - // (undocumented) - addPublishers( - ...publishers: Array> - ): void; - // (undocumented) - addSubscribers( - ...subscribers: Array> - ): void; - // (undocumented) - setEventBroker(eventBroker: EventBroker): void; -} - -// @alpha (undocumented) -export const eventsExtensionPoint: ExtensionPoint; - // @public export interface EventSubscriber { onEvent(params: EventParams): Promise; diff --git a/plugins/events-node/package.json b/plugins/events-node/package.json index 9dffabcaac..060e450289 100644 --- a/plugins/events-node/package.json +++ b/plugins/events-node/package.json @@ -6,17 +6,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "node-library" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -30,7 +41,6 @@ "@backstage/cli": "workspace:^" }, "files": [ - "alpha", "dist" ] } diff --git a/plugins/events-node/src/alpha.ts b/plugins/events-node/src/alpha.ts new file mode 100644 index 0000000000..90666ba2f3 --- /dev/null +++ b/plugins/events-node/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 type { EventsExtensionPoint } from './extensions'; +export { eventsExtensionPoint } from './extensions'; diff --git a/plugins/events-node/src/index.ts b/plugins/events-node/src/index.ts index 422eeb169e..2bdf456f13 100644 --- a/plugins/events-node/src/index.ts +++ b/plugins/events-node/src/index.ts @@ -21,5 +21,3 @@ */ export * from './api'; -export type { EventsExtensionPoint } from './extensions'; -export { eventsExtensionPoint } from './extensions'; From ec7857e390d5643fce8595d03f969c447969f0b8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 01:07:38 +0100 Subject: [PATCH 16/65] events-backend-module-gitlab: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 19 ++++++++++++++++ .../api-report.md | 7 ------ .../events-backend-module-gitlab/package.json | 22 ++++++++++++++----- .../events-backend-module-gitlab/src/alpha.ts | 18 +++++++++++++++ .../events-backend-module-gitlab/src/index.ts | 2 -- .../GitlabEventRouterEventsModule.test.ts | 2 +- .../service/GitlabEventRouterEventsModule.ts | 2 +- .../service/GitlabWebhookEventsModule.test.ts | 2 +- .../src/service/GitlabWebhookEventsModule.ts | 2 +- 9 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 plugins/events-backend-module-gitlab/alpha-api-report.md create mode 100644 plugins/events-backend-module-gitlab/src/alpha.ts diff --git a/plugins/events-backend-module-gitlab/alpha-api-report.md b/plugins/events-backend-module-gitlab/alpha-api-report.md new file mode 100644 index 0000000000..d8b1430df9 --- /dev/null +++ b/plugins/events-backend-module-gitlab/alpha-api-report.md @@ -0,0 +1,19 @@ +## API Report File for "@backstage/plugin-events-backend-module-gitlab" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-gitlab" does not have an export "GitlabEventRouter" +// +// @alpha +export const gitlabEventRouterEventsModule: () => BackendFeature; + +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-gitlab" does not have an export "GitlabEventRouter" +// +// @alpha +export const gitlabWebhookEventsModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend-module-gitlab/api-report.md b/plugins/events-backend-module-gitlab/api-report.md index 2a88295032..8a0c513857 100644 --- a/plugins/events-backend-module-gitlab/api-report.md +++ b/plugins/events-backend-module-gitlab/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { EventParams } from '@backstage/plugin-events-node'; import { RequestValidator } from '@backstage/plugin-events-node'; @@ -18,10 +17,4 @@ export class GitlabEventRouter extends SubTopicEventRouter { // (undocumented) protected determineSubTopic(params: EventParams): string | undefined; } - -// @alpha -export const gitlabEventRouterEventsModule: () => BackendFeature; - -// @alpha -export const gitlabWebhookEventsModule: () => BackendFeature; ``` diff --git a/plugins/events-backend-module-gitlab/package.json b/plugins/events-backend-module-gitlab/package.json index 7e195bc447..be5ffc2318 100644 --- a/plugins/events-backend-module-gitlab/package.json +++ b/plugins/events-backend-module-gitlab/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -35,7 +46,6 @@ "supertest": "^6.1.3" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/events-backend-module-gitlab/src/alpha.ts b/plugins/events-backend-module-gitlab/src/alpha.ts new file mode 100644 index 0000000000..357c9f81ce --- /dev/null +++ b/plugins/events-backend-module-gitlab/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 { gitlabEventRouterEventsModule } from './service/GitlabEventRouterEventsModule'; +export { gitlabWebhookEventsModule } from './service/GitlabWebhookEventsModule'; diff --git a/plugins/events-backend-module-gitlab/src/index.ts b/plugins/events-backend-module-gitlab/src/index.ts index 859a6c69c0..3788e02955 100644 --- a/plugins/events-backend-module-gitlab/src/index.ts +++ b/plugins/events-backend-module-gitlab/src/index.ts @@ -23,5 +23,3 @@ export { createGitlabTokenValidator } from './http/createGitlabTokenValidator'; export { GitlabEventRouter } from './router/GitlabEventRouter'; -export { gitlabEventRouterEventsModule } from './service/GitlabEventRouterEventsModule'; -export { gitlabWebhookEventsModule } from './service/GitlabWebhookEventsModule'; diff --git a/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.test.ts b/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.test.ts index f0ffca3397..f8b03bc0f3 100644 --- a/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.test.ts +++ b/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.test.ts @@ -15,7 +15,7 @@ */ import { startTestBackend } from '@backstage/backend-test-utils'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { gitlabEventRouterEventsModule } from './GitlabEventRouterEventsModule'; import { GitlabEventRouter } from '../router/GitlabEventRouter'; diff --git a/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts b/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts index 9ab2e1263e..45b7f37711 100644 --- a/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts +++ b/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { GitlabEventRouter } from '../router/GitlabEventRouter'; /** diff --git a/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.test.ts b/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.test.ts index b139f46f55..b42f2c474e 100644 --- a/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.test.ts +++ b/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.test.ts @@ -17,8 +17,8 @@ import { coreServices } from '@backstage/backend-plugin-api'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { - eventsExtensionPoint, HttpPostIngressOptions, RequestDetails, } from '@backstage/plugin-events-node'; diff --git a/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts b/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts index 44f13f31ef..2fcee40589 100644 --- a/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts +++ b/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts @@ -18,7 +18,7 @@ import { coreServices, createBackendModule, } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { createGitlabTokenValidator } from '../http/createGitlabTokenValidator'; /** From 27f44f4ad834ec39f37127cb54b34e760291ec1b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 01:09:29 +0100 Subject: [PATCH 17/65] events-backend-module-github: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 17 ++++++++++++++ .../api-report.md | 7 ------ .../events-backend-module-github/package.json | 22 ++++++++++++++----- .../events-backend-module-github/src/alpha.ts | 18 +++++++++++++++ .../events-backend-module-github/src/index.ts | 2 -- .../GithubEventRouterEventsModule.test.ts | 2 +- .../service/GithubEventRouterEventsModule.ts | 2 +- .../service/GithubWebhookEventsModule.test.ts | 2 +- .../src/service/GithubWebhookEventsModule.ts | 2 +- 9 files changed, 55 insertions(+), 19 deletions(-) create mode 100644 plugins/events-backend-module-github/alpha-api-report.md create mode 100644 plugins/events-backend-module-github/src/alpha.ts diff --git a/plugins/events-backend-module-github/alpha-api-report.md b/plugins/events-backend-module-github/alpha-api-report.md new file mode 100644 index 0000000000..aed740ed0d --- /dev/null +++ b/plugins/events-backend-module-github/alpha-api-report.md @@ -0,0 +1,17 @@ +## API Report File for "@backstage/plugin-events-backend-module-github" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-github" does not have an export "GithubEventRouter" +// +// @alpha +export const githubEventRouterEventsModule: () => BackendFeature; + +// @alpha +export const githubWebhookEventsModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend-module-github/api-report.md b/plugins/events-backend-module-github/api-report.md index 4f14bce789..bcf9b8ed74 100644 --- a/plugins/events-backend-module-github/api-report.md +++ b/plugins/events-backend-module-github/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { EventParams } from '@backstage/plugin-events-node'; import { RequestValidator } from '@backstage/plugin-events-node'; @@ -20,10 +19,4 @@ export class GithubEventRouter extends SubTopicEventRouter { // (undocumented) protected determineSubTopic(params: EventParams): string | undefined; } - -// @alpha -export const githubEventRouterEventsModule: () => BackendFeature; - -// @alpha -export const githubWebhookEventsModule: () => BackendFeature; ``` diff --git a/plugins/events-backend-module-github/package.json b/plugins/events-backend-module-github/package.json index 1d266ea562..3145ee9e66 100644 --- a/plugins/events-backend-module-github/package.json +++ b/plugins/events-backend-module-github/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -36,7 +47,6 @@ "supertest": "^6.1.3" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/events-backend-module-github/src/alpha.ts b/plugins/events-backend-module-github/src/alpha.ts new file mode 100644 index 0000000000..8a712cacb1 --- /dev/null +++ b/plugins/events-backend-module-github/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 { githubEventRouterEventsModule } from './service/GithubEventRouterEventsModule'; +export { githubWebhookEventsModule } from './service/GithubWebhookEventsModule'; diff --git a/plugins/events-backend-module-github/src/index.ts b/plugins/events-backend-module-github/src/index.ts index 8e5671d9d8..d02ea1deaf 100644 --- a/plugins/events-backend-module-github/src/index.ts +++ b/plugins/events-backend-module-github/src/index.ts @@ -23,5 +23,3 @@ export { createGithubSignatureValidator } from './http/createGithubSignatureValidator'; export { GithubEventRouter } from './router/GithubEventRouter'; -export { githubEventRouterEventsModule } from './service/GithubEventRouterEventsModule'; -export { githubWebhookEventsModule } from './service/GithubWebhookEventsModule'; diff --git a/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.test.ts b/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.test.ts index 694f5e1dbe..0e2ca69366 100644 --- a/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.test.ts +++ b/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.test.ts @@ -15,7 +15,7 @@ */ import { startTestBackend } from '@backstage/backend-test-utils'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { githubEventRouterEventsModule } from './GithubEventRouterEventsModule'; import { GithubEventRouter } from '../router/GithubEventRouter'; diff --git a/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts b/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts index 8914d07e71..e2e6fab266 100644 --- a/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts +++ b/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { GithubEventRouter } from '../router/GithubEventRouter'; /** diff --git a/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.test.ts b/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.test.ts index 84233eedee..9e33cac6a0 100644 --- a/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.test.ts +++ b/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.test.ts @@ -17,8 +17,8 @@ import { coreServices } from '@backstage/backend-plugin-api'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { - eventsExtensionPoint, HttpPostIngressOptions, RequestDetails, } from '@backstage/plugin-events-node'; diff --git a/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.ts b/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.ts index 9a3202cb97..10cb12e431 100644 --- a/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.ts +++ b/plugins/events-backend-module-github/src/service/GithubWebhookEventsModule.ts @@ -18,7 +18,7 @@ import { coreServices, createBackendModule, } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { createGithubSignatureValidator } from '../http/createGithubSignatureValidator'; /** From 3bc17bd3b612a7d96c41fb5b8981fd9875efa585 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 01:10:51 +0100 Subject: [PATCH 18/65] events-backend-module-gerrit: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../events-backend-module-gerrit/package.json | 22 ++++++++++++++----- .../events-backend-module-gerrit/src/alpha.ts | 17 ++++++++++++++ .../events-backend-module-gerrit/src/index.ts | 1 - .../GerritEventRouterEventsModule.test.ts | 2 +- .../service/GerritEventRouterEventsModule.ts | 2 +- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100644 plugins/events-backend-module-gerrit/src/alpha.ts diff --git a/plugins/events-backend-module-gerrit/package.json b/plugins/events-backend-module-gerrit/package.json index 85e9ac92dc..5fe093893c 100644 --- a/plugins/events-backend-module-gerrit/package.json +++ b/plugins/events-backend-module-gerrit/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -34,7 +45,6 @@ "supertest": "^6.1.3" }, "files": [ - "alpha", "dist" ] } diff --git a/plugins/events-backend-module-gerrit/src/alpha.ts b/plugins/events-backend-module-gerrit/src/alpha.ts new file mode 100644 index 0000000000..26fd89b14d --- /dev/null +++ b/plugins/events-backend-module-gerrit/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { gerritEventRouterEventsModule } from './service/GerritEventRouterEventsModule'; diff --git a/plugins/events-backend-module-gerrit/src/index.ts b/plugins/events-backend-module-gerrit/src/index.ts index 1a9ebb03ee..dfc314667f 100644 --- a/plugins/events-backend-module-gerrit/src/index.ts +++ b/plugins/events-backend-module-gerrit/src/index.ts @@ -22,4 +22,3 @@ */ export { GerritEventRouter } from './router/GerritEventRouter'; -export { gerritEventRouterEventsModule } from './service/GerritEventRouterEventsModule'; diff --git a/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.test.ts b/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.test.ts index b5fd6a80ca..6a8f4f46ff 100644 --- a/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.test.ts +++ b/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.test.ts @@ -15,7 +15,7 @@ */ import { startTestBackend } from '@backstage/backend-test-utils'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { gerritEventRouterEventsModule } from './GerritEventRouterEventsModule'; import { GerritEventRouter } from '../router/GerritEventRouter'; diff --git a/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts b/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts index 734b574edd..6f8889eb2b 100644 --- a/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts +++ b/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { GerritEventRouter } from '../router/GerritEventRouter'; /** From 7a01af72656bdad25bfc12d3f829d8e9b2e1073f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:48:02 +0100 Subject: [PATCH 19/65] events-backend-module-bitbucket-cloud: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 14 ++++++++++++ .../api-report.md | 4 ---- .../package.json | 22 ++++++++++++++----- .../src/alpha.ts | 17 ++++++++++++++ .../src/index.ts | 1 - ...bucketCloudEventRouterEventsModule.test.ts | 2 +- .../BitbucketCloudEventRouterEventsModule.ts | 2 +- 7 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md create mode 100644 plugins/events-backend-module-bitbucket-cloud/src/alpha.ts diff --git a/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md b/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md new file mode 100644 index 0000000000..11b60fd12d --- /dev/null +++ b/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md @@ -0,0 +1,14 @@ +## API Report File for "@backstage/plugin-events-backend-module-bitbucket-cloud" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-bitbucket-cloud" does not have an export "BitbucketCloudEventRouter" +// +// @alpha +export const bitbucketCloudEventRouterEventsModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend-module-bitbucket-cloud/api-report.md b/plugins/events-backend-module-bitbucket-cloud/api-report.md index c47252ce17..4795edd89a 100644 --- a/plugins/events-backend-module-bitbucket-cloud/api-report.md +++ b/plugins/events-backend-module-bitbucket-cloud/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { EventParams } from '@backstage/plugin-events-node'; import { SubTopicEventRouter } from '@backstage/plugin-events-node'; @@ -13,7 +12,4 @@ export class BitbucketCloudEventRouter extends SubTopicEventRouter { // (undocumented) protected determineSubTopic(params: EventParams): string | undefined; } - -// @alpha -export const bitbucketCloudEventRouterEventsModule: () => BackendFeature; ``` diff --git a/plugins/events-backend-module-bitbucket-cloud/package.json b/plugins/events-backend-module-bitbucket-cloud/package.json index 9fc879cfec..c377088b62 100644 --- a/plugins/events-backend-module-bitbucket-cloud/package.json +++ b/plugins/events-backend-module-bitbucket-cloud/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -34,7 +45,6 @@ "supertest": "^6.1.3" }, "files": [ - "alpha", "dist" ] } diff --git a/plugins/events-backend-module-bitbucket-cloud/src/alpha.ts b/plugins/events-backend-module-bitbucket-cloud/src/alpha.ts new file mode 100644 index 0000000000..e19ff9c9b5 --- /dev/null +++ b/plugins/events-backend-module-bitbucket-cloud/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { bitbucketCloudEventRouterEventsModule } from './service/BitbucketCloudEventRouterEventsModule'; diff --git a/plugins/events-backend-module-bitbucket-cloud/src/index.ts b/plugins/events-backend-module-bitbucket-cloud/src/index.ts index 0a58212de2..77aa9798ef 100644 --- a/plugins/events-backend-module-bitbucket-cloud/src/index.ts +++ b/plugins/events-backend-module-bitbucket-cloud/src/index.ts @@ -22,4 +22,3 @@ */ export { BitbucketCloudEventRouter } from './router/BitbucketCloudEventRouter'; -export { bitbucketCloudEventRouterEventsModule } from './service/BitbucketCloudEventRouterEventsModule'; diff --git a/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.test.ts b/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.test.ts index e456607a2b..60ce5b713e 100644 --- a/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.test.ts +++ b/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.test.ts @@ -15,7 +15,7 @@ */ import { startTestBackend } from '@backstage/backend-test-utils'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { bitbucketCloudEventRouterEventsModule } from './BitbucketCloudEventRouterEventsModule'; import { BitbucketCloudEventRouter } from '../router/BitbucketCloudEventRouter'; diff --git a/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts b/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts index 7f755a28f4..1f339a2bd1 100644 --- a/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts +++ b/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { BitbucketCloudEventRouter } from '../router/BitbucketCloudEventRouter'; /** From 70cf02dd6b6100852394334626fddbdea4c38cf7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:48:22 +0100 Subject: [PATCH 20/65] events-backend-module-azure: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 14 ++++++++++++ .../events-backend-module-azure/api-report.md | 4 ---- .../events-backend-module-azure/package.json | 22 ++++++++++++++----- .../events-backend-module-azure/src/alpha.ts | 17 ++++++++++++++ .../events-backend-module-azure/src/index.ts | 1 - ...AzureDevOpsEventRouterEventsModule.test.ts | 2 +- .../AzureDevOpsEventRouterEventsModule.ts | 2 +- 7 files changed, 49 insertions(+), 13 deletions(-) create mode 100644 plugins/events-backend-module-azure/alpha-api-report.md create mode 100644 plugins/events-backend-module-azure/src/alpha.ts diff --git a/plugins/events-backend-module-azure/alpha-api-report.md b/plugins/events-backend-module-azure/alpha-api-report.md new file mode 100644 index 0000000000..ccae207a64 --- /dev/null +++ b/plugins/events-backend-module-azure/alpha-api-report.md @@ -0,0 +1,14 @@ +## API Report File for "@backstage/plugin-events-backend-module-azure" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-azure" does not have an export "AzureDevOpsEventRouter" +// +// @alpha +export const azureDevOpsEventRouterEventsModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend-module-azure/api-report.md b/plugins/events-backend-module-azure/api-report.md index 2e13a7ed4a..4460aeb510 100644 --- a/plugins/events-backend-module-azure/api-report.md +++ b/plugins/events-backend-module-azure/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { EventParams } from '@backstage/plugin-events-node'; import { SubTopicEventRouter } from '@backstage/plugin-events-node'; @@ -13,7 +12,4 @@ export class AzureDevOpsEventRouter extends SubTopicEventRouter { // (undocumented) protected determineSubTopic(params: EventParams): string | undefined; } - -// @alpha -export const azureDevOpsEventRouterEventsModule: () => BackendFeature; ``` diff --git a/plugins/events-backend-module-azure/package.json b/plugins/events-backend-module-azure/package.json index 88c2dcc795..540a2c700f 100644 --- a/plugins/events-backend-module-azure/package.json +++ b/plugins/events-backend-module-azure/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -34,7 +45,6 @@ "supertest": "^6.1.3" }, "files": [ - "alpha", "dist" ] } diff --git a/plugins/events-backend-module-azure/src/alpha.ts b/plugins/events-backend-module-azure/src/alpha.ts new file mode 100644 index 0000000000..8eacbd8270 --- /dev/null +++ b/plugins/events-backend-module-azure/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { azureDevOpsEventRouterEventsModule } from './service/AzureDevOpsEventRouterEventsModule'; diff --git a/plugins/events-backend-module-azure/src/index.ts b/plugins/events-backend-module-azure/src/index.ts index 9a83f751f6..a1d56dc536 100644 --- a/plugins/events-backend-module-azure/src/index.ts +++ b/plugins/events-backend-module-azure/src/index.ts @@ -22,4 +22,3 @@ */ export { AzureDevOpsEventRouter } from './router/AzureDevOpsEventRouter'; -export { azureDevOpsEventRouterEventsModule } from './service/AzureDevOpsEventRouterEventsModule'; diff --git a/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.test.ts b/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.test.ts index 86ab7ea17d..dbd61782ae 100644 --- a/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.test.ts +++ b/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.test.ts @@ -15,7 +15,7 @@ */ import { startTestBackend } from '@backstage/backend-test-utils'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { azureDevOpsEventRouterEventsModule } from './AzureDevOpsEventRouterEventsModule'; import { AzureDevOpsEventRouter } from '../router/AzureDevOpsEventRouter'; diff --git a/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts b/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts index 1219452bd8..1ceefe5c4e 100644 --- a/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts +++ b/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from '@backstage/backend-plugin-api'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { AzureDevOpsEventRouter } from '../router/AzureDevOpsEventRouter'; /** From 888328305e21e1ba120d7dd8e37e2daea630ebc9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:50:14 +0100 Subject: [PATCH 21/65] events-backend-module-aws-sqs: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 12 ++++++++++ .../api-report.md | 4 ---- .../package.json | 22 ++++++++++++++----- .../src/alpha.ts | 17 ++++++++++++++ .../src/index.ts | 1 - ...onsumingEventPublisherEventsModule.test.ts | 2 +- ...sSqsConsumingEventPublisherEventsModule.ts | 2 +- 7 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 plugins/events-backend-module-aws-sqs/alpha-api-report.md create mode 100644 plugins/events-backend-module-aws-sqs/src/alpha.ts diff --git a/plugins/events-backend-module-aws-sqs/alpha-api-report.md b/plugins/events-backend-module-aws-sqs/alpha-api-report.md new file mode 100644 index 0000000000..b9f60c4437 --- /dev/null +++ b/plugins/events-backend-module-aws-sqs/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-events-backend-module-aws-sqs" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +export const awsSqsConsumingEventPublisherEventsModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend-module-aws-sqs/api-report.md b/plugins/events-backend-module-aws-sqs/api-report.md index ede18f2787..ffa9c888d6 100644 --- a/plugins/events-backend-module-aws-sqs/api-report.md +++ b/plugins/events-backend-module-aws-sqs/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { EventBroker } from '@backstage/plugin-events-node'; import { EventPublisher } from '@backstage/plugin-events-node'; @@ -21,7 +20,4 @@ export class AwsSqsConsumingEventPublisher implements EventPublisher { // (undocumented) setEventBroker(eventBroker: EventBroker): Promise; } - -// @alpha -export const awsSqsConsumingEventPublisherEventsModule: () => BackendFeature; ``` diff --git a/plugins/events-backend-module-aws-sqs/package.json b/plugins/events-backend-module-aws-sqs/package.json index a4ec624c91..19aec3108a 100644 --- a/plugins/events-backend-module-aws-sqs/package.json +++ b/plugins/events-backend-module-aws-sqs/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -42,7 +53,6 @@ "aws-sdk-client-mock": "^2.0.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/events-backend-module-aws-sqs/src/alpha.ts b/plugins/events-backend-module-aws-sqs/src/alpha.ts new file mode 100644 index 0000000000..00f08e4417 --- /dev/null +++ b/plugins/events-backend-module-aws-sqs/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { awsSqsConsumingEventPublisherEventsModule } from './service/AwsSqsConsumingEventPublisherEventsModule'; diff --git a/plugins/events-backend-module-aws-sqs/src/index.ts b/plugins/events-backend-module-aws-sqs/src/index.ts index 73b950856b..57f409c044 100644 --- a/plugins/events-backend-module-aws-sqs/src/index.ts +++ b/plugins/events-backend-module-aws-sqs/src/index.ts @@ -24,4 +24,3 @@ */ export { AwsSqsConsumingEventPublisher } from './publisher/AwsSqsConsumingEventPublisher'; -export { awsSqsConsumingEventPublisherEventsModule } from './service/AwsSqsConsumingEventPublisherEventsModule'; diff --git a/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.test.ts b/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.test.ts index 589b8c93fa..3963b9a8b6 100644 --- a/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.test.ts +++ b/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.test.ts @@ -18,7 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common'; import { coreServices } from '@backstage/backend-plugin-api'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { TestEventBroker } from '@backstage/plugin-events-backend-test-utils'; import { awsSqsConsumingEventPublisherEventsModule } from './AwsSqsConsumingEventPublisherEventsModule'; import { AwsSqsConsumingEventPublisher } from '../publisher/AwsSqsConsumingEventPublisher'; diff --git a/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.ts b/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.ts index 50812f321b..4205bd231b 100644 --- a/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.ts +++ b/plugins/events-backend-module-aws-sqs/src/service/AwsSqsConsumingEventPublisherEventsModule.ts @@ -19,7 +19,7 @@ import { createBackendModule, } from '@backstage/backend-plugin-api'; import { loggerToWinstonLogger } from '@backstage/backend-common'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { AwsSqsConsumingEventPublisher } from '../publisher/AwsSqsConsumingEventPublisher'; /** From 28e8d59d58f0fd1be2a459e16b4aac2d4f1ab743 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:52:00 +0100 Subject: [PATCH 22/65] events-backend: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/events-backend/alpha-api-report.md | 12 ++++++++++ plugins/events-backend/api-report.md | 4 ---- plugins/events-backend/package.json | 22 ++++++++++++++----- plugins/events-backend/src/alpha.ts | 17 ++++++++++++++ plugins/events-backend/src/index.ts | 1 - .../src/service/EventsPlugin.test.ts | 2 +- .../src/service/EventsPlugin.ts | 6 +++-- 7 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 plugins/events-backend/alpha-api-report.md create mode 100644 plugins/events-backend/src/alpha.ts diff --git a/plugins/events-backend/alpha-api-report.md b/plugins/events-backend/alpha-api-report.md new file mode 100644 index 0000000000..3e32f769c1 --- /dev/null +++ b/plugins/events-backend/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-events-backend" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +export const eventsPlugin: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend/api-report.md b/plugins/events-backend/api-report.md index 28437772ae..7d8ede1979 100644 --- a/plugins/events-backend/api-report.md +++ b/plugins/events-backend/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { EventBroker } from '@backstage/plugin-events-node'; import { EventPublisher } from '@backstage/plugin-events-node'; @@ -28,9 +27,6 @@ export class EventsBackend { start(): Promise; } -// @alpha -export const eventsPlugin: () => BackendFeature; - // @public export class HttpPostIngressEventPublisher implements EventPublisher { // (undocumented) diff --git a/plugins/events-backend/package.json b/plugins/events-backend/package.json index fce00f668c..4534dac9de 100644 --- a/plugins/events-backend/package.json +++ b/plugins/events-backend/package.json @@ -5,17 +5,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -40,7 +51,6 @@ "supertest": "^6.1.3" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/events-backend/src/alpha.ts b/plugins/events-backend/src/alpha.ts new file mode 100644 index 0000000000..4403da1636 --- /dev/null +++ b/plugins/events-backend/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { eventsPlugin } from './service/EventsPlugin'; diff --git a/plugins/events-backend/src/index.ts b/plugins/events-backend/src/index.ts index 5026729015..4645e9a479 100644 --- a/plugins/events-backend/src/index.ts +++ b/plugins/events-backend/src/index.ts @@ -21,5 +21,4 @@ */ export { EventsBackend } from './service/EventsBackend'; -export { eventsPlugin } from './service/EventsPlugin'; export { HttpPostIngressEventPublisher } from './service/http'; diff --git a/plugins/events-backend/src/service/EventsPlugin.test.ts b/plugins/events-backend/src/service/EventsPlugin.test.ts index 0570b16d01..73578ae222 100644 --- a/plugins/events-backend/src/service/EventsPlugin.test.ts +++ b/plugins/events-backend/src/service/EventsPlugin.test.ts @@ -21,7 +21,7 @@ import { createBackendModule, } from '@backstage/backend-plugin-api'; import { startTestBackend } from '@backstage/backend-test-utils'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { TestEventBroker, TestEventPublisher, diff --git a/plugins/events-backend/src/service/EventsPlugin.ts b/plugins/events-backend/src/service/EventsPlugin.ts index 402104b56c..1ae038a2ac 100644 --- a/plugins/events-backend/src/service/EventsPlugin.ts +++ b/plugins/events-backend/src/service/EventsPlugin.ts @@ -19,12 +19,14 @@ import { coreServices, } from '@backstage/backend-plugin-api'; import { loggerToWinstonLogger } from '@backstage/backend-common'; +import { + eventsExtensionPoint, + EventsExtensionPoint, +} from '@backstage/plugin-events-node/alpha'; import { EventBroker, EventPublisher, EventSubscriber, - eventsExtensionPoint, - EventsExtensionPoint, HttpPostIngressOptions, } from '@backstage/plugin-events-node'; import { InMemoryEventBroker } from './InMemoryEventBroker'; From e1c35fbaab7f60e108db847c9e95714d7d543774 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:55:20 +0100 Subject: [PATCH 23/65] catalog-react: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/catalog-react/alpha-api-report.md | 22 +++++++++++++++++++++ plugins/catalog-react/api-report.md | 13 ------------ plugins/catalog-react/package.json | 24 ++++++++++++++++------- plugins/catalog-react/src/alpha.ts | 18 +++++++++++++++++ plugins/catalog-react/src/hooks/index.ts | 1 - plugins/catalog-react/src/index.ts | 6 +----- 6 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 plugins/catalog-react/alpha-api-report.md create mode 100644 plugins/catalog-react/src/alpha.ts diff --git a/plugins/catalog-react/alpha-api-report.md b/plugins/catalog-react/alpha-api-report.md new file mode 100644 index 0000000000..f9b740c07c --- /dev/null +++ b/plugins/catalog-react/alpha-api-report.md @@ -0,0 +1,22 @@ +## API Report File for "@backstage/plugin-catalog-react" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { Entity } from '@backstage/catalog-model'; +import { ResourcePermission } from '@backstage/plugin-permission-common'; + +// @alpha +export function isOwnerOf(owner: Entity, entity: Entity): boolean; + +// @alpha +export function useEntityPermission( + permission: ResourcePermission<'catalog-entity'>, +): { + loading: boolean; + allowed: boolean; + error?: Error; +}; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-react/api-report.md b/plugins/catalog-react/api-report.md index 4756432857..55c72122f5 100644 --- a/plugins/catalog-react/api-report.md +++ b/plugins/catalog-react/api-report.md @@ -20,7 +20,6 @@ import { Overrides } from '@material-ui/core/styles/overrides'; import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; -import { ResourcePermission } from '@backstage/plugin-permission-common'; import { RouteRef } from '@backstage/core-plugin-api'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { StyleRules } from '@material-ui/core/styles/withStyles'; @@ -474,9 +473,6 @@ export function InspectEntityDialog(props: { onClose: () => void; }): JSX.Element | null; -// @alpha -export function isOwnerOf(owner: Entity, entity: Entity): boolean; - // @public (undocumented) export function MockEntityListContextProvider< T extends DefaultEntityFilters = DefaultEntityFilters, @@ -538,15 +534,6 @@ export function useEntityOwnership(): { isOwnedEntity: (entity: Entity) => boolean; }; -// @alpha -export function useEntityPermission( - permission: ResourcePermission<'catalog-entity'>, -): { - loading: boolean; - allowed: boolean; - error?: Error; -}; - // @public export function useEntityTypeFilter(): { loading: boolean; diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json index e66c2b4bb1..0ca4e3c9e4 100644 --- a/plugins/catalog-react/package.json +++ b/plugins/catalog-react/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "web-library" @@ -24,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -78,7 +89,6 @@ "react-test-renderer": "^16.13.1" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/plugins/catalog-react/src/alpha.ts b/plugins/catalog-react/src/alpha.ts new file mode 100644 index 0000000000..e8ff21609e --- /dev/null +++ b/plugins/catalog-react/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 { isOwnerOf } from './utils'; +export { useEntityPermission } from './hooks/useEntityPermission'; diff --git a/plugins/catalog-react/src/hooks/index.ts b/plugins/catalog-react/src/hooks/index.ts index 3570ed897c..ffd32206ef 100644 --- a/plugins/catalog-react/src/hooks/index.ts +++ b/plugins/catalog-react/src/hooks/index.ts @@ -38,4 +38,3 @@ export { useRelatedEntities } from './useRelatedEntities'; export { useStarredEntities } from './useStarredEntities'; export { useStarredEntity } from './useStarredEntity'; export { useEntityOwnership } from './useEntityOwnership'; -export { useEntityPermission } from './useEntityPermission'; diff --git a/plugins/catalog-react/src/index.ts b/plugins/catalog-react/src/index.ts index 2ca7d67d59..b511116f84 100644 --- a/plugins/catalog-react/src/index.ts +++ b/plugins/catalog-react/src/index.ts @@ -31,9 +31,5 @@ export { entityRouteParams, entityRouteRef } from './routes'; export * from './testUtils'; export * from './types'; export * from './overridableComponents'; -export { - getEntityRelations, - getEntitySourceLocation, - isOwnerOf, -} from './utils'; +export { getEntityRelations, getEntitySourceLocation } from './utils'; export type { EntitySourceLocation } from './utils'; From dac6ddfae808ab1565ae337b129b607f32d458f2 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:57:40 +0100 Subject: [PATCH 24/65] catalog-node: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/catalog-node/alpha-api-report.md | 39 ++++++++++++++++++++++++ plugins/catalog-node/api-report.md | 21 ------------- plugins/catalog-node/package.json | 24 ++++++++++----- plugins/catalog-node/src/alpha.ts | 19 ++++++++++++ plugins/catalog-node/src/index.ts | 3 -- 5 files changed, 75 insertions(+), 31 deletions(-) create mode 100644 plugins/catalog-node/alpha-api-report.md create mode 100644 plugins/catalog-node/src/alpha.ts diff --git a/plugins/catalog-node/alpha-api-report.md b/plugins/catalog-node/alpha-api-report.md new file mode 100644 index 0000000000..1bfb3f3566 --- /dev/null +++ b/plugins/catalog-node/alpha-api-report.md @@ -0,0 +1,39 @@ +## API Report File for "@backstage/plugin-catalog-node" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +/// + +import { CatalogApi } from '@backstage/catalog-client'; +import { CompoundEntityRef } from '@backstage/catalog-model'; +import { Entity } from '@backstage/catalog-model'; +import { ExtensionPoint } from '@backstage/backend-plugin-api'; +import { JsonValue } from '@backstage/types'; +import { LocationSpec } from '@backstage/plugin-catalog-common'; +import { ServiceRef } from '@backstage/backend-plugin-api'; + +// @alpha (undocumented) +export interface CatalogProcessingExtensionPoint { + // Warning: (ae-forgotten-export) The symbol "EntityProvider" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + addEntityProvider( + ...providers: Array> + ): void; + // Warning: (ae-forgotten-export) The symbol "CatalogProcessor" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + addProcessor( + ...processors: Array> + ): void; +} + +// @alpha (undocumented) +export const catalogProcessingExtensionPoint: ExtensionPoint; + +// @alpha +export const catalogServiceRef: ServiceRef; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-node/api-report.md b/plugins/catalog-node/api-report.md index 9e9045db84..87da0b6944 100644 --- a/plugins/catalog-node/api-report.md +++ b/plugins/catalog-node/api-report.md @@ -5,28 +5,10 @@ ```ts /// -import { CatalogApi } from '@backstage/catalog-client'; import { CompoundEntityRef } from '@backstage/catalog-model'; import { Entity } from '@backstage/catalog-model'; -import { ExtensionPoint } from '@backstage/backend-plugin-api'; import { JsonValue } from '@backstage/types'; import { LocationSpec as LocationSpec_2 } from '@backstage/plugin-catalog-common'; -import { ServiceRef } from '@backstage/backend-plugin-api'; - -// @alpha (undocumented) -export interface CatalogProcessingExtensionPoint { - // (undocumented) - addEntityProvider( - ...providers: Array> - ): void; - // (undocumented) - addProcessor( - ...processors: Array> - ): void; -} - -// @alpha (undocumented) -export const catalogProcessingExtensionPoint: ExtensionPoint; // @public (undocumented) export type CatalogProcessor = { @@ -109,9 +91,6 @@ export type CatalogProcessorResult = | CatalogProcessorErrorResult | CatalogProcessorRefreshKeysResult; -// @alpha -export const catalogServiceRef: ServiceRef; - // @public export type DeferredEntity = { entity: Entity; diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index 248b808645..d949bfaabb 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -6,17 +6,28 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "node-library" }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -37,7 +48,6 @@ "@backstage/cli": "workspace:^" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/plugins/catalog-node/src/alpha.ts b/plugins/catalog-node/src/alpha.ts new file mode 100644 index 0000000000..4fb07bbc25 --- /dev/null +++ b/plugins/catalog-node/src/alpha.ts @@ -0,0 +1,19 @@ +/* + * Copyright 2023 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 { catalogServiceRef } from './catalogService'; +export type { CatalogProcessingExtensionPoint } from './extensions'; +export { catalogProcessingExtensionPoint } from './extensions'; diff --git a/plugins/catalog-node/src/index.ts b/plugins/catalog-node/src/index.ts index 6393c55f31..6a1accfcbd 100644 --- a/plugins/catalog-node/src/index.ts +++ b/plugins/catalog-node/src/index.ts @@ -20,8 +20,5 @@ * @packageDocumentation */ -export type { CatalogProcessingExtensionPoint } from './extensions'; -export { catalogProcessingExtensionPoint } from './extensions'; -export { catalogServiceRef } from './catalogService'; export * from './api'; export * from './processing'; From 57d39ea54aa8de51bad8f0c9f1caf212b713cbc4 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 09:59:08 +0100 Subject: [PATCH 25/65] catalog-common: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/catalog-common/alpha-api-report.md | 45 ++++++++++++++++++++++ plugins/catalog-common/api-report.md | 37 ------------------ plugins/catalog-common/package.json | 25 ++++++++---- plugins/catalog-common/src/alpha.ts | 28 ++++++++++++++ plugins/catalog-common/src/index.ts | 13 ------- 5 files changed, 90 insertions(+), 58 deletions(-) create mode 100644 plugins/catalog-common/alpha-api-report.md create mode 100644 plugins/catalog-common/src/alpha.ts diff --git a/plugins/catalog-common/alpha-api-report.md b/plugins/catalog-common/alpha-api-report.md new file mode 100644 index 0000000000..12e0806a9c --- /dev/null +++ b/plugins/catalog-common/alpha-api-report.md @@ -0,0 +1,45 @@ +## API Report File for "@backstage/plugin-catalog-common" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BasicPermission } from '@backstage/plugin-permission-common'; +import { ResourcePermission } from '@backstage/plugin-permission-common'; + +// @alpha +export const catalogEntityCreatePermission: BasicPermission; + +// @alpha +export const catalogEntityDeletePermission: ResourcePermission<'catalog-entity'>; + +// @alpha +export type CatalogEntityPermission = ResourcePermission< + typeof RESOURCE_TYPE_CATALOG_ENTITY +>; + +// @alpha +export const catalogEntityReadPermission: ResourcePermission<'catalog-entity'>; + +// @alpha +export const catalogEntityRefreshPermission: ResourcePermission<'catalog-entity'>; + +// @alpha +export const catalogLocationCreatePermission: BasicPermission; + +// @alpha +export const catalogLocationDeletePermission: BasicPermission; + +// @alpha +export const catalogLocationReadPermission: BasicPermission; + +// @alpha +export const catalogPermissions: ( + | BasicPermission + | ResourcePermission<'catalog-entity'> +)[]; + +// @alpha +export const RESOURCE_TYPE_CATALOG_ENTITY = 'catalog-entity'; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-common/api-report.md b/plugins/catalog-common/api-report.md index 1bef626c79..231c8aac34 100644 --- a/plugins/catalog-common/api-report.md +++ b/plugins/catalog-common/api-report.md @@ -3,10 +3,8 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BasicPermission } from '@backstage/plugin-permission-common'; import { Entity } from '@backstage/catalog-model'; import { IndexableDocument } from '@backstage/plugin-search-common'; -import { ResourcePermission } from '@backstage/plugin-permission-common'; // @public (undocumented) export type AnalyzeLocationEntityField = { @@ -44,12 +42,6 @@ export type AnalyzeLocationResponse = { generateEntities: AnalyzeLocationGenerateEntity[]; }; -// @alpha -export const catalogEntityCreatePermission: BasicPermission; - -// @alpha -export const catalogEntityDeletePermission: ResourcePermission<'catalog-entity'>; - // @public export interface CatalogEntityDocument extends IndexableDocument { // @deprecated (undocumented) @@ -66,39 +58,10 @@ export interface CatalogEntityDocument extends IndexableDocument { type: string; } -// @alpha -export type CatalogEntityPermission = ResourcePermission< - typeof RESOURCE_TYPE_CATALOG_ENTITY ->; - -// @alpha -export const catalogEntityReadPermission: ResourcePermission<'catalog-entity'>; - -// @alpha -export const catalogEntityRefreshPermission: ResourcePermission<'catalog-entity'>; - -// @alpha -export const catalogLocationCreatePermission: BasicPermission; - -// @alpha -export const catalogLocationDeletePermission: BasicPermission; - -// @alpha -export const catalogLocationReadPermission: BasicPermission; - -// @alpha -export const catalogPermissions: ( - | BasicPermission - | ResourcePermission<'catalog-entity'> -)[]; - // @public export type LocationSpec = { type: string; target: string; presence?: 'optional' | 'required'; }; - -// @alpha -export const RESOURCE_TYPE_CATALOG_ENTITY = 'catalog-entity'; ``` diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index 0ffaf3cff7..55680e679c 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -6,11 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "common-library" @@ -25,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -41,7 +51,6 @@ "@backstage/cli": "workspace:^" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/plugins/catalog-common/src/alpha.ts b/plugins/catalog-common/src/alpha.ts new file mode 100644 index 0000000000..2dfc028332 --- /dev/null +++ b/plugins/catalog-common/src/alpha.ts @@ -0,0 +1,28 @@ +/* + * Copyright 2023 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 { + RESOURCE_TYPE_CATALOG_ENTITY, + catalogEntityReadPermission, + catalogEntityCreatePermission, + catalogEntityDeletePermission, + catalogEntityRefreshPermission, + catalogLocationReadPermission, + catalogLocationCreatePermission, + catalogLocationDeletePermission, + catalogPermissions, +} from './permissions'; +export type { CatalogEntityPermission } from './permissions'; diff --git a/plugins/catalog-common/src/index.ts b/plugins/catalog-common/src/index.ts index 95bd65bc92..52860a0e66 100644 --- a/plugins/catalog-common/src/index.ts +++ b/plugins/catalog-common/src/index.ts @@ -21,19 +21,6 @@ * @packageDocumentation */ -export { - RESOURCE_TYPE_CATALOG_ENTITY, - catalogEntityReadPermission, - catalogEntityCreatePermission, - catalogEntityDeletePermission, - catalogEntityRefreshPermission, - catalogLocationReadPermission, - catalogLocationCreatePermission, - catalogLocationDeletePermission, - catalogPermissions, -} from './permissions'; -export type { CatalogEntityPermission } from './permissions'; - export * from './search'; export * from './ingestion'; export type { LocationSpec } from './common'; From 69ffa70600f039f55c42add5e9a58a4da217d1e9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:13:39 +0100 Subject: [PATCH 26/65] catalog-backend-module-*: migrate to use exports Signed-off-by: Patrik Oldsberg --- .../alpha-api-report.md | 12 +++++++++ .../catalog-backend-module-aws/api-report.md | 4 --- .../catalog-backend-module-aws/package.json | 22 ++++++++++----- .../catalog-backend-module-aws/src/alpha.ts | 17 ++++++++++++ .../catalog-backend-module-aws/src/index.ts | 1 - .../AwsS3EntityProviderCatalogModule.test.ts | 2 +- .../AwsS3EntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 12 +++++++++ .../api-report.md | 4 --- .../catalog-backend-module-azure/package.json | 22 ++++++++++----- .../catalog-backend-module-azure/src/alpha.ts | 17 ++++++++++++ .../catalog-backend-module-azure/src/index.ts | 1 - ...eDevOpsEntityProviderCatalogModule.test.ts | 2 +- .../AzureDevOpsEntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 12 +++++++++ .../api-report.md | 4 --- .../package.json | 22 ++++++++++----- .../src/alpha.ts | 17 ++++++++++++ .../src/index.ts | 1 - ...etCloudEntityProviderCatalogModule.test.ts | 4 +-- ...tbucketCloudEntityProviderCatalogModule.ts | 4 +-- .../alpha-api-report.md | 12 +++++++++ .../api-report.md | 4 --- .../package.json | 22 ++++++++++----- .../src/alpha.ts | 17 ++++++++++++ .../src/index.ts | 1 - ...tServerEntityProviderCatalogModule.test.ts | 2 +- ...bucketServerEntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 12 +++++++++ .../api-report.md | 4 --- .../package.json | 21 +++++++++++---- .../src/alpha.ts | 17 ++++++++++++ .../src/index.ts | 1 - .../GerritEntityProviderCatalogModule.test.ts | 2 +- .../GerritEntityProviderCatalogModule.ts | 2 +- .../GithubEntityProviderCatalogModule.test.ts | 2 +- .../GithubEntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 12 +++++++++ .../api-report.md | 4 --- .../package.json | 22 ++++++++++----- .../src/alpha.ts | 17 ++++++++++++ .../src/index.ts | 1 - ...scoveryEntityProviderCatalogModule.test.ts | 2 +- ...labDiscoveryEntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 24 +++++++++++++++++ .../api-report.md | 11 -------- .../package.json | 22 ++++++++++----- .../src/alpha.ts | 17 ++++++++++++ .../src/index.ts | 1 - ...gestionEntityProviderCatalogModule.test.ts | 2 +- ...talIngestionEntityProviderCatalogModule.ts | 2 +- .../src/run.ts | 6 ++--- .../alpha-api-report.md | 27 +++++++++++++++++++ .../api-report.md | 13 --------- .../package.json | 22 ++++++++++----- .../src/alpha.ts | 18 +++++++++++++ .../src/index.ts | 2 -- ...raphOrgEntityProviderCatalogModule.test.ts | 2 +- ...softGraphOrgEntityProviderCatalogModule.ts | 2 +- 59 files changed, 410 insertions(+), 128 deletions(-) create mode 100644 plugins/catalog-backend-module-aws/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-aws/src/alpha.ts create mode 100644 plugins/catalog-backend-module-azure/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-azure/src/alpha.ts create mode 100644 plugins/catalog-backend-module-bitbucket-cloud/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-bitbucket-cloud/src/alpha.ts create mode 100644 plugins/catalog-backend-module-bitbucket-server/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-bitbucket-server/src/alpha.ts create mode 100644 plugins/catalog-backend-module-gerrit/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-gerrit/src/alpha.ts create mode 100644 plugins/catalog-backend-module-gitlab/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-gitlab/src/alpha.ts create mode 100644 plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-incremental-ingestion/src/alpha.ts create mode 100644 plugins/catalog-backend-module-msgraph/alpha-api-report.md create mode 100644 plugins/catalog-backend-module-msgraph/src/alpha.ts diff --git a/plugins/catalog-backend-module-aws/alpha-api-report.md b/plugins/catalog-backend-module-aws/alpha-api-report.md new file mode 100644 index 0000000000..8781975085 --- /dev/null +++ b/plugins/catalog-backend-module-aws/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-aws" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +export const awsS3EntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-aws/api-report.md b/plugins/catalog-backend-module-aws/api-report.md index 1725692cb1..5086ec1ea7 100644 --- a/plugins/catalog-backend-module-aws/api-report.md +++ b/plugins/catalog-backend-module-aws/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorParser } from '@backstage/plugin-catalog-backend'; @@ -88,7 +87,4 @@ export class AwsS3EntityProvider implements EntityProvider { // (undocumented) refresh(logger: Logger): Promise; } - -// @alpha -export const awsS3EntityProviderCatalogModule: () => BackendFeature; ``` diff --git a/plugins/catalog-backend-module-aws/package.json b/plugins/catalog-backend-module-aws/package.json index f583d64792..c309ee995e 100644 --- a/plugins/catalog-backend-module-aws/package.json +++ b/plugins/catalog-backend-module-aws/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -60,7 +71,6 @@ "yaml": "^2.0.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/catalog-backend-module-aws/src/alpha.ts b/plugins/catalog-backend-module-aws/src/alpha.ts new file mode 100644 index 0000000000..3ae30df0cb --- /dev/null +++ b/plugins/catalog-backend-module-aws/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { awsS3EntityProviderCatalogModule } from './service/AwsS3EntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-aws/src/index.ts b/plugins/catalog-backend-module-aws/src/index.ts index 804fd97e91..212308edaa 100644 --- a/plugins/catalog-backend-module-aws/src/index.ts +++ b/plugins/catalog-backend-module-aws/src/index.ts @@ -22,5 +22,4 @@ export * from './processors'; export * from './providers'; -export { awsS3EntityProviderCatalogModule } from './service/AwsS3EntityProviderCatalogModule'; export * from './types'; diff --git a/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.test.ts index c0d36ad3c2..868a9535b4 100644 --- a/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; import { awsS3EntityProviderCatalogModule } from './AwsS3EntityProviderCatalogModule'; import { AwsS3EntityProvider } from '../providers'; diff --git a/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.ts b/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.ts index cbc137ab40..5d4170ec1c 100644 --- a/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-aws/src/service/AwsS3EntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { coreServices, createBackendModule, } from '@backstage/backend-plugin-api'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { AwsS3EntityProvider } from '../providers'; /** diff --git a/plugins/catalog-backend-module-azure/alpha-api-report.md b/plugins/catalog-backend-module-azure/alpha-api-report.md new file mode 100644 index 0000000000..486aac7775 --- /dev/null +++ b/plugins/catalog-backend-module-azure/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-azure" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +export const azureDevOpsEntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-azure/api-report.md b/plugins/catalog-backend-module-azure/api-report.md index 5ffae14b6b..8fb7edeb53 100644 --- a/plugins/catalog-backend-module-azure/api-report.md +++ b/plugins/catalog-backend-module-azure/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { Config } from '@backstage/config'; @@ -56,7 +55,4 @@ export class AzureDevOpsEntityProvider implements EntityProvider { // (undocumented) refresh(logger: Logger): Promise; } - -// @alpha -export const azureDevOpsEntityProviderCatalogModule: () => BackendFeature; ``` diff --git a/plugins/catalog-backend-module-azure/package.json b/plugins/catalog-backend-module-azure/package.json index 518d7b89ad..b68015cb87 100644 --- a/plugins/catalog-backend-module-azure/package.json +++ b/plugins/catalog-backend-module-azure/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -56,7 +67,6 @@ "msw": "^0.49.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/catalog-backend-module-azure/src/alpha.ts b/plugins/catalog-backend-module-azure/src/alpha.ts new file mode 100644 index 0000000000..cc3c4a83af --- /dev/null +++ b/plugins/catalog-backend-module-azure/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { azureDevOpsEntityProviderCatalogModule } from './service/AzureDevOpsEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-azure/src/index.ts b/plugins/catalog-backend-module-azure/src/index.ts index aa3a94fda2..a71c40ee6c 100644 --- a/plugins/catalog-backend-module-azure/src/index.ts +++ b/plugins/catalog-backend-module-azure/src/index.ts @@ -22,4 +22,3 @@ export { AzureDevOpsDiscoveryProcessor } from './processors'; export { AzureDevOpsEntityProvider } from './providers'; -export { azureDevOpsEntityProviderCatalogModule } from './service/AzureDevOpsEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.test.ts index a11e6b14f2..a8e526e871 100644 --- a/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; import { azureDevOpsEntityProviderCatalogModule } from './AzureDevOpsEntityProviderCatalogModule'; import { AzureDevOpsEntityProvider } from '../providers'; diff --git a/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.ts index bd59cec29b..3fc1ddf3a4 100644 --- a/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-azure/src/service/AzureDevOpsEntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { createBackendModule, coreServices, } from '@backstage/backend-plugin-api'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { AzureDevOpsEntityProvider } from '../providers'; /** diff --git a/plugins/catalog-backend-module-bitbucket-cloud/alpha-api-report.md b/plugins/catalog-backend-module-bitbucket-cloud/alpha-api-report.md new file mode 100644 index 0000000000..77b4b77410 --- /dev/null +++ b/plugins/catalog-backend-module-bitbucket-cloud/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-bitbucket-cloud" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha (undocumented) +export const bitbucketCloudEntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-bitbucket-cloud/api-report.md b/plugins/catalog-backend-module-bitbucket-cloud/api-report.md index 7ad6b3b3e0..456ea62dd3 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/api-report.md +++ b/plugins/catalog-backend-module-bitbucket-cloud/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogApi } from '@backstage/catalog-client'; import { Config } from '@backstage/config'; import { EntityProvider } from '@backstage/plugin-catalog-backend'; @@ -46,7 +45,4 @@ export class BitbucketCloudEntityProvider // (undocumented) supportsEventTopics(): string[]; } - -// @alpha (undocumented) -export const bitbucketCloudEntityProviderCatalogModule: () => BackendFeature; ``` diff --git a/plugins/catalog-backend-module-bitbucket-cloud/package.json b/plugins/catalog-backend-module-bitbucket-cloud/package.json index d9b1c6613f..9f2243b0cd 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/package.json +++ b/plugins/catalog-backend-module-bitbucket-cloud/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -56,7 +67,6 @@ "msw": "^0.49.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/alpha.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/alpha.ts new file mode 100644 index 0000000000..e949dcb894 --- /dev/null +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { bitbucketCloudEntityProviderCatalogModule } from './service/BitbucketCloudEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/index.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/index.ts index c1f04b8877..1c15ad4e8f 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/index.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/index.ts @@ -21,4 +21,3 @@ */ export { BitbucketCloudEntityProvider } from './BitbucketCloudEntityProvider'; -export { bitbucketCloudEntityProviderCatalogModule } from './service/BitbucketCloudEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts index 1b18ab0ed9..630c18b134 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts @@ -20,8 +20,8 @@ import { TaskScheduleDefinition, } from '@backstage/backend-tasks'; import { startTestBackend, mockServices } from '@backstage/backend-test-utils'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { Duration } from 'luxon'; import { bitbucketCloudEntityProviderCatalogModule } from './BitbucketCloudEntityProviderCatalogModule'; import { BitbucketCloudEntityProvider } from '../BitbucketCloudEntityProvider'; diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.ts index d17656a473..a95d99ceef 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.ts @@ -22,8 +22,8 @@ import { import { catalogProcessingExtensionPoint, catalogServiceRef, -} from '@backstage/plugin-catalog-node'; -import { eventsExtensionPoint } from '@backstage/plugin-events-node'; +} from '@backstage/plugin-catalog-node/alpha'; +import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { BitbucketCloudEntityProvider } from '../BitbucketCloudEntityProvider'; /** diff --git a/plugins/catalog-backend-module-bitbucket-server/alpha-api-report.md b/plugins/catalog-backend-module-bitbucket-server/alpha-api-report.md new file mode 100644 index 0000000000..3177828f51 --- /dev/null +++ b/plugins/catalog-backend-module-bitbucket-server/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-bitbucket-server" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha (undocumented) +export const bitbucketServerEntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-bitbucket-server/api-report.md b/plugins/catalog-backend-module-bitbucket-server/api-report.md index 213f5d2573..6c840883af 100644 --- a/plugins/catalog-backend-module-bitbucket-server/api-report.md +++ b/plugins/catalog-backend-module-bitbucket-server/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { BitbucketServerIntegrationConfig } from '@backstage/integration'; import { Config } from '@backstage/config'; import { Entity } from '@backstage/catalog-model'; @@ -68,9 +67,6 @@ export class BitbucketServerEntityProvider implements EntityProvider { refresh(logger: Logger): Promise; } -// @alpha (undocumented) -export const bitbucketServerEntityProviderCatalogModule: () => BackendFeature; - // @public (undocumented) export type BitbucketServerListOptions = { [key: string]: number | undefined; diff --git a/plugins/catalog-backend-module-bitbucket-server/package.json b/plugins/catalog-backend-module-bitbucket-server/package.json index fdfc5649a5..d11b9136e6 100644 --- a/plugins/catalog-backend-module-bitbucket-server/package.json +++ b/plugins/catalog-backend-module-bitbucket-server/package.json @@ -5,10 +5,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -24,7 +35,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -53,7 +64,6 @@ "msw": "^0.49.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/catalog-backend-module-bitbucket-server/src/alpha.ts b/plugins/catalog-backend-module-bitbucket-server/src/alpha.ts new file mode 100644 index 0000000000..d6227c29f1 --- /dev/null +++ b/plugins/catalog-backend-module-bitbucket-server/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { bitbucketServerEntityProviderCatalogModule } from './service/BitbucketServerEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-bitbucket-server/src/index.ts b/plugins/catalog-backend-module-bitbucket-server/src/index.ts index f139078cfb..34ac3a9966 100644 --- a/plugins/catalog-backend-module-bitbucket-server/src/index.ts +++ b/plugins/catalog-backend-module-bitbucket-server/src/index.ts @@ -29,4 +29,3 @@ export type { } from './lib'; export { BitbucketServerEntityProvider } from './providers'; export type { BitbucketServerLocationParser } from './providers'; -export { bitbucketServerEntityProviderCatalogModule } from './service/BitbucketServerEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.test.ts index 474431dc7a..bdd7209364 100644 --- a/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { TaskScheduleDefinition, } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { bitbucketServerEntityProviderCatalogModule } from './BitbucketServerEntityProviderCatalogModule'; import { Duration } from 'luxon'; import { BitbucketServerEntityProvider } from '../providers'; diff --git a/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.ts index 46712d29dd..deab47c9e9 100644 --- a/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-bitbucket-server/src/service/BitbucketServerEntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { coreServices, createBackendModule, } from '@backstage/backend-plugin-api'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { BitbucketServerEntityProvider } from '../providers'; /** diff --git a/plugins/catalog-backend-module-gerrit/alpha-api-report.md b/plugins/catalog-backend-module-gerrit/alpha-api-report.md new file mode 100644 index 0000000000..03f5d099b9 --- /dev/null +++ b/plugins/catalog-backend-module-gerrit/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-gerrit" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha (undocumented) +export const gerritEntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-gerrit/api-report.md b/plugins/catalog-backend-module-gerrit/api-report.md index 870937f7ec..1dee786da1 100644 --- a/plugins/catalog-backend-module-gerrit/api-report.md +++ b/plugins/catalog-backend-module-gerrit/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import { EntityProvider } from '@backstage/plugin-catalog-backend'; import { EntityProviderConnection } from '@backstage/plugin-catalog-backend'; @@ -30,8 +29,5 @@ export class GerritEntityProvider implements EntityProvider { refresh(logger: Logger): Promise; } -// @alpha (undocumented) -export const gerritEntityProviderCatalogModule: () => BackendFeature; - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/catalog-backend-module-gerrit/package.json b/plugins/catalog-backend-module-gerrit/package.json index d945fed9fd..23d2db3073 100644 --- a/plugins/catalog-backend-module-gerrit/package.json +++ b/plugins/catalog-backend-module-gerrit/package.json @@ -5,10 +5,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -21,7 +32,7 @@ }, "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", diff --git a/plugins/catalog-backend-module-gerrit/src/alpha.ts b/plugins/catalog-backend-module-gerrit/src/alpha.ts new file mode 100644 index 0000000000..8b03d9312a --- /dev/null +++ b/plugins/catalog-backend-module-gerrit/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { gerritEntityProviderCatalogModule } from './service/GerritEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-gerrit/src/index.ts b/plugins/catalog-backend-module-gerrit/src/index.ts index 38ede69926..133772d4b1 100644 --- a/plugins/catalog-backend-module-gerrit/src/index.ts +++ b/plugins/catalog-backend-module-gerrit/src/index.ts @@ -15,4 +15,3 @@ */ export { GerritEntityProvider } from './providers/GerritEntityProvider'; -export { gerritEntityProviderCatalogModule } from './service/GerritEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.test.ts index 9d61cabdb9..51c1749c66 100644 --- a/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; import { gerritEntityProviderCatalogModule } from './GerritEntityProviderCatalogModule'; import { GerritEntityProvider } from '../providers/GerritEntityProvider'; diff --git a/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.ts index 8c61038c8f..782c724094 100644 --- a/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-gerrit/src/service/GerritEntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { coreServices, createBackendModule, } from '@backstage/backend-plugin-api'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { GerritEntityProvider } from '../providers/GerritEntityProvider'; /** diff --git a/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.test.ts index d8ebc8d0ad..7c08e8947d 100644 --- a/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; import { githubEntityProviderCatalogModule } from './GithubEntityProviderCatalogModule'; import { GithubEntityProvider } from '../providers/GithubEntityProvider'; diff --git a/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts index d9dc0a12aa..fc319534f3 100644 --- a/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { coreServices, } from '@backstage/backend-plugin-api'; import { loggerToWinstonLogger } from '@backstage/backend-common'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { GithubEntityProvider } from '../providers/GithubEntityProvider'; /** diff --git a/plugins/catalog-backend-module-gitlab/alpha-api-report.md b/plugins/catalog-backend-module-gitlab/alpha-api-report.md new file mode 100644 index 0000000000..8912b4a7b2 --- /dev/null +++ b/plugins/catalog-backend-module-gitlab/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-gitlab" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +export const gitlabDiscoveryEntityProviderCatalogModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-gitlab/api-report.md b/plugins/catalog-backend-module-gitlab/api-report.md index 0195975d4b..68ea45169f 100644 --- a/plugins/catalog-backend-module-gitlab/api-report.md +++ b/plugins/catalog-backend-module-gitlab/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { Config } from '@backstage/config'; @@ -33,9 +32,6 @@ export class GitlabDiscoveryEntityProvider implements EntityProvider { refresh(logger: Logger): Promise; } -// @alpha -export const gitlabDiscoveryEntityProviderCatalogModule: () => BackendFeature; - // @public export class GitLabDiscoveryProcessor implements CatalogProcessor { // (undocumented) diff --git a/plugins/catalog-backend-module-gitlab/package.json b/plugins/catalog-backend-module-gitlab/package.json index 4fb26eeb7e..a53da3a97f 100644 --- a/plugins/catalog-backend-module-gitlab/package.json +++ b/plugins/catalog-backend-module-gitlab/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -57,7 +68,6 @@ "msw": "^0.49.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/catalog-backend-module-gitlab/src/alpha.ts b/plugins/catalog-backend-module-gitlab/src/alpha.ts new file mode 100644 index 0000000000..883ffc13c4 --- /dev/null +++ b/plugins/catalog-backend-module-gitlab/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 { gitlabDiscoveryEntityProviderCatalogModule } from './service/GitlabDiscoveryEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-gitlab/src/index.ts b/plugins/catalog-backend-module-gitlab/src/index.ts index 30efac4924..2dd19c041d 100644 --- a/plugins/catalog-backend-module-gitlab/src/index.ts +++ b/plugins/catalog-backend-module-gitlab/src/index.ts @@ -25,4 +25,3 @@ export { GitlabDiscoveryEntityProvider, GitlabOrgDiscoveryEntityProvider, } from './providers'; -export { gitlabDiscoveryEntityProviderCatalogModule } from './service/GitlabDiscoveryEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.test.ts index ca8d86f555..efb86e4223 100644 --- a/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; import { gitlabDiscoveryEntityProviderCatalogModule } from './GitlabDiscoveryEntityProviderCatalogModule'; import { GitlabDiscoveryEntityProvider } from '../providers'; diff --git a/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.ts index bb4fb656a8..0adf5b18f2 100644 --- a/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-gitlab/src/service/GitlabDiscoveryEntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { coreServices, } from '@backstage/backend-plugin-api'; import { loggerToWinstonLogger } from '@backstage/backend-common'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { GitlabDiscoveryEntityProvider } from '../providers'; /** diff --git a/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md b/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md new file mode 100644 index 0000000000..f762503b53 --- /dev/null +++ b/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md @@ -0,0 +1,24 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-incremental-ingestion" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; +import type { DeferredEntity } from '@backstage/plugin-catalog-backend'; +import type { DurationObjectUnits } from 'luxon'; + +// @alpha +export const incrementalIngestionEntityProviderCatalogModule: (options: { + providers: { + provider: IncrementalEntityProvider; + options: IncrementalEntityProviderOptions; + }[]; +}) => BackendFeature; + +// Warnings were encountered during analysis: +// +// src/module/incrementalIngestionEntityProviderCatalogModule.d.ts:9:9 - (ae-forgotten-export) The symbol "IncrementalEntityProvider" needs to be exported by the entry point alpha.d.ts +// src/module/incrementalIngestionEntityProviderCatalogModule.d.ts:10:9 - (ae-forgotten-export) The symbol "IncrementalEntityProviderOptions" needs to be exported by the entry point alpha.d.ts + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-incremental-ingestion/api-report.md b/plugins/catalog-backend-module-incremental-ingestion/api-report.md index fe9ef24777..27ea35a34c 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/api-report.md +++ b/plugins/catalog-backend-module-incremental-ingestion/api-report.md @@ -3,9 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -/// - -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogBuilder } from '@backstage/plugin-catalog-backend'; import type { Config } from '@backstage/config'; import type { DeferredEntity } from '@backstage/plugin-catalog-backend'; @@ -80,14 +77,6 @@ export interface IncrementalEntityProviderOptions { restLength: DurationObjectUnits; } -// @alpha -export const incrementalIngestionEntityProviderCatalogModule: (options: { - providers: { - provider: IncrementalEntityProvider; - options: IncrementalEntityProviderOptions; - }[]; -}) => BackendFeature; - // @public (undocumented) export type PluginEnvironment = { logger: Logger; diff --git a/plugins/catalog-backend-module-incremental-ingestion/package.json b/plugins/catalog-backend-module-incremental-ingestion/package.json index ff8272e29e..8cc1ebbf8e 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/package.json +++ b/plugins/catalog-backend-module-incremental-ingestion/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "clean": "backstage-cli package clean", @@ -61,7 +72,6 @@ "@backstage/plugin-catalog-backend": "workspace:^" }, "files": [ - "alpha", "dist", "migrations/**/*.{js,d.ts}" ] diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/alpha.ts b/plugins/catalog-backend-module-incremental-ingestion/src/alpha.ts new file mode 100644 index 0000000000..c277a0a680 --- /dev/null +++ b/plugins/catalog-backend-module-incremental-ingestion/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 * from './module'; diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/index.ts b/plugins/catalog-backend-module-incremental-ingestion/src/index.ts index 976c91a1ce..ff1ee1faa1 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/index.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/index.ts @@ -20,7 +20,6 @@ * @packageDocumentation */ -export * from './module'; export * from './service'; export { type EntityIteratorResult, diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.test.ts index 06cbcb010e..dbadf573a4 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.test.ts @@ -18,7 +18,7 @@ import { getVoidLogger } from '@backstage/backend-common'; import { coreServices } from '@backstage/backend-plugin-api'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { IncrementalEntityProvider } from '../types'; import { incrementalIngestionEntityProviderCatalogModule } from './incrementalIngestionEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts index b173b2d2ef..52fcef2cc9 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts @@ -18,7 +18,7 @@ import { coreServices, createBackendModule, } from '@backstage/backend-plugin-api'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { IncrementalEntityProvider, IncrementalEntityProviderOptions, diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/run.ts b/plugins/catalog-backend-module-incremental-ingestion/src/run.ts index eb66140fe2..745fc70883 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/run.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/run.ts @@ -20,10 +20,8 @@ import { } from '@backstage/backend-plugin-api'; import { ConfigReader } from '@backstage/config'; import { catalogPlugin } from '@backstage/plugin-catalog-backend'; -import { - IncrementalEntityProvider, - incrementalIngestionEntityProviderCatalogModule, -} from '.'; +import { IncrementalEntityProvider } from '.'; +import { incrementalIngestionEntityProviderCatalogModule } from './alpha'; const provider: IncrementalEntityProvider = { getProviderName: () => 'test-provider', diff --git a/plugins/catalog-backend-module-msgraph/alpha-api-report.md b/plugins/catalog-backend-module-msgraph/alpha-api-report.md new file mode 100644 index 0000000000..c0daedc038 --- /dev/null +++ b/plugins/catalog-backend-module-msgraph/alpha-api-report.md @@ -0,0 +1,27 @@ +## API Report File for "@backstage/plugin-catalog-backend-module-msgraph" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; +import { GroupEntity } from '@backstage/catalog-model'; +import * as MicrosoftGraph from '@microsoft/microsoft-graph-types'; +import { UserEntity } from '@backstage/catalog-model'; + +// @alpha +export const microsoftGraphOrgEntityProviderCatalogModule: () => BackendFeature; + +// @alpha +export interface MicrosoftGraphOrgEntityProviderCatalogModuleOptions { + // Warning: (ae-forgotten-export) The symbol "GroupTransformer" needs to be exported by the entry point alpha.d.ts + groupTransformer?: GroupTransformer | Record; + // Warning: (ae-forgotten-export) The symbol "OrganizationTransformer" needs to be exported by the entry point alpha.d.ts + organizationTransformer?: + | OrganizationTransformer + | Record; + // Warning: (ae-forgotten-export) The symbol "UserTransformer" needs to be exported by the entry point alpha.d.ts + userTransformer?: UserTransformer | Record; +} + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend-module-msgraph/api-report.md b/plugins/catalog-backend-module-msgraph/api-report.md index 09770614b4..10a4f405c0 100644 --- a/plugins/catalog-backend-module-msgraph/api-report.md +++ b/plugins/catalog-backend-module-msgraph/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { Config } from '@backstage/config'; @@ -139,18 +138,6 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider { read(options?: { logger?: Logger }): Promise; } -// @alpha -export const microsoftGraphOrgEntityProviderCatalogModule: () => BackendFeature; - -// @alpha -export interface MicrosoftGraphOrgEntityProviderCatalogModuleOptions { - groupTransformer?: GroupTransformer | Record; - organizationTransformer?: - | OrganizationTransformer - | Record; - userTransformer?: UserTransformer | Record; -} - // @public @deprecated export interface MicrosoftGraphOrgEntityProviderLegacyOptions { groupTransformer?: GroupTransformer; diff --git a/plugins/catalog-backend-module-msgraph/package.json b/plugins/catalog-backend-module-msgraph/package.json index 65a58e2620..e1d0ede5fc 100644 --- a/plugins/catalog-backend-module-msgraph/package.json +++ b/plugins/catalog-backend-module-msgraph/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "alphaTypes": "dist/index.alpha.d.ts", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin-module" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -59,7 +70,6 @@ "msw": "^0.49.0" }, "files": [ - "alpha", "config.d.ts", "dist" ], diff --git a/plugins/catalog-backend-module-msgraph/src/alpha.ts b/plugins/catalog-backend-module-msgraph/src/alpha.ts new file mode 100644 index 0000000000..137808d881 --- /dev/null +++ b/plugins/catalog-backend-module-msgraph/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 { microsoftGraphOrgEntityProviderCatalogModule } from './service/MicrosoftGraphOrgEntityProviderCatalogModule'; +export type { MicrosoftGraphOrgEntityProviderCatalogModuleOptions } from './service/MicrosoftGraphOrgEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-msgraph/src/index.ts b/plugins/catalog-backend-module-msgraph/src/index.ts index b80a0b3863..f98cb907ec 100644 --- a/plugins/catalog-backend-module-msgraph/src/index.ts +++ b/plugins/catalog-backend-module-msgraph/src/index.ts @@ -22,5 +22,3 @@ export * from './microsoftGraph'; export * from './processors'; -export { microsoftGraphOrgEntityProviderCatalogModule } from './service/MicrosoftGraphOrgEntityProviderCatalogModule'; -export type { MicrosoftGraphOrgEntityProviderCatalogModuleOptions } from './service/MicrosoftGraphOrgEntityProviderCatalogModule'; diff --git a/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.test.ts index 27ae5b9dd8..3763553162 100644 --- a/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.test.ts @@ -22,7 +22,7 @@ import { } from '@backstage/backend-tasks'; import { startTestBackend } from '@backstage/backend-test-utils'; import { ConfigReader } from '@backstage/config'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { Duration } from 'luxon'; import { microsoftGraphOrgEntityProviderCatalogModule } from './MicrosoftGraphOrgEntityProviderCatalogModule'; import { MicrosoftGraphOrgEntityProvider } from '../processors'; diff --git a/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts index fc63867a23..5cad504829 100644 --- a/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts @@ -19,7 +19,7 @@ import { createBackendModule, } from '@backstage/backend-plugin-api'; import { loggerToWinstonLogger } from '@backstage/backend-common'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { GroupTransformer, OrganizationTransformer, From c64fcc84437eac065ae3845c4c56518cd3aedbb8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:37:24 +0100 Subject: [PATCH 27/65] catalog-backend: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/catalog-backend/alpha-api-report.md | 154 ++++++++++++++++++ plugins/catalog-backend/api-report.md | 141 +--------------- plugins/catalog-backend/package.json | 22 ++- plugins/catalog-backend/src/alpha.ts | 18 ++ plugins/catalog-backend/src/index.ts | 1 - .../src/permissions/conditionExports.ts | 2 +- .../permissions/rules/createPropertyRule.ts | 2 +- .../src/permissions/rules/hasAnnotation.ts | 2 +- .../src/permissions/rules/hasLabel.ts | 2 +- .../src/permissions/rules/isEntityKind.ts | 2 +- .../src/permissions/rules/isEntityOwner.ts | 2 +- .../src/permissions/rules/util.ts | 2 +- .../src/search/DefaultCatalogCollator.ts | 6 +- .../search/DefaultCatalogCollatorFactory.ts | 6 +- .../src/service/AuthorizedEntitiesCatalog.ts | 2 +- .../src/service/AuthorizedLocationService.ts | 2 +- .../src/service/AuthorizedRefreshService.ts | 2 +- .../src/service/CatalogBuilder.ts | 24 ++- .../src/service/CatalogPlugin.ts | 4 +- .../src/service/createRouter.test.ts | 2 +- plugins/catalog-backend/src/service/index.ts | 6 +- 21 files changed, 229 insertions(+), 175 deletions(-) create mode 100644 plugins/catalog-backend/alpha-api-report.md create mode 100644 plugins/catalog-backend/src/alpha.ts diff --git a/plugins/catalog-backend/alpha-api-report.md b/plugins/catalog-backend/alpha-api-report.md new file mode 100644 index 0000000000..6a40829d64 --- /dev/null +++ b/plugins/catalog-backend/alpha-api-report.md @@ -0,0 +1,154 @@ +## API Report File for "@backstage/plugin-catalog-backend" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; +import { ConditionalPolicyDecision } from '@backstage/plugin-permission-common'; +import { Conditions } from '@backstage/plugin-permission-node'; +import { Entity } from '@backstage/catalog-model'; +import { PermissionCondition } from '@backstage/plugin-permission-common'; +import { PermissionCriteria } from '@backstage/plugin-permission-common'; +import { PermissionRule } from '@backstage/plugin-permission-node'; +import { PermissionRuleParams } from '@backstage/plugin-permission-common'; +import { ResourcePermission } from '@backstage/plugin-permission-common'; + +// @alpha +export const catalogConditions: Conditions<{ + hasAnnotation: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + value?: string | undefined; + annotation: string; + } + >; + hasLabel: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + label: string; + } + >; + hasMetadata: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + value?: string | undefined; + key: string; + } + >; + hasSpec: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + value?: string | undefined; + key: string; + } + >; + isEntityKind: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + kinds: string[]; + } + >; + isEntityOwner: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + claims: string[]; + } + >; +}>; + +// @alpha +export type CatalogPermissionRule< + TParams extends PermissionRuleParams = PermissionRuleParams, +> = PermissionRule; + +// @alpha +export const catalogPlugin: () => BackendFeature; + +// @alpha +export const createCatalogConditionalDecision: ( + permission: ResourcePermission<'catalog-entity'>, + conditions: PermissionCriteria< + PermissionCondition<'catalog-entity', PermissionRuleParams> + >, +) => ConditionalPolicyDecision; + +// @alpha +export const createCatalogPermissionRule: < + TParams extends PermissionRuleParams = undefined, +>( + rule: PermissionRule, +) => PermissionRule; + +// @alpha +export const permissionRules: { + hasAnnotation: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + value?: string | undefined; + annotation: string; + } + >; + hasLabel: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + label: string; + } + >; + hasMetadata: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + value?: string | undefined; + key: string; + } + >; + hasSpec: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + value?: string | undefined; + key: string; + } + >; + isEntityKind: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + kinds: string[]; + } + >; + isEntityOwner: PermissionRule< + Entity, + EntitiesSearchFilter, + 'catalog-entity', + { + claims: string[]; + } + >; +}; + +// Warnings were encountered during analysis: +// +// src/permissions/conditionExports.d.ts:8:5 - (ae-forgotten-export) The symbol "EntitiesSearchFilter" needs to be exported by the entry point alpha.d.ts + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/catalog-backend/api-report.md b/plugins/catalog-backend/api-report.md index f15f6b9ba9..00c13a31ea 100644 --- a/plugins/catalog-backend/api-report.md +++ b/plugins/catalog-backend/api-report.md @@ -10,7 +10,6 @@ import { AnalyzeLocationExistingEntity as AnalyzeLocationExistingEntity_2 } from import { AnalyzeLocationGenerateEntity as AnalyzeLocationGenerateEntity_2 } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationRequest as AnalyzeLocationRequest_2 } from '@backstage/plugin-catalog-common'; import { AnalyzeLocationResponse as AnalyzeLocationResponse_2 } from '@backstage/plugin-catalog-common'; -import { BackendFeature } from '@backstage/backend-plugin-api'; import { CatalogApi } from '@backstage/catalog-client'; import { CatalogEntityDocument } from '@backstage/plugin-catalog-common'; import { CatalogProcessor } from '@backstage/plugin-catalog-node'; @@ -23,8 +22,6 @@ import { CatalogProcessorParser } from '@backstage/plugin-catalog-node'; import { CatalogProcessorRefreshKeysResult } from '@backstage/plugin-catalog-node'; import { CatalogProcessorRelationResult } from '@backstage/plugin-catalog-node'; import { CatalogProcessorResult } from '@backstage/plugin-catalog-node'; -import { ConditionalPolicyDecision } from '@backstage/plugin-permission-common'; -import { Conditions } from '@backstage/plugin-permission-node'; import { Config } from '@backstage/config'; import { DeferredEntity } from '@backstage/plugin-catalog-node'; import { DocumentCollatorFactory } from '@backstage/plugin-search-common'; @@ -41,8 +38,6 @@ import { LocationSpec as LocationSpec_2 } from '@backstage/plugin-catalog-common import { Logger } from 'winston'; import { Permission } from '@backstage/plugin-permission-common'; import { PermissionAuthorizer } from '@backstage/plugin-permission-common'; -import { PermissionCondition } from '@backstage/plugin-permission-common'; -import { PermissionCriteria } from '@backstage/plugin-permission-common'; import { PermissionEvaluator } from '@backstage/plugin-permission-common'; import { PermissionRule } from '@backstage/plugin-permission-node'; import { PermissionRuleParams } from '@backstage/plugin-permission-common'; @@ -50,7 +45,6 @@ import { PluginDatabaseManager } from '@backstage/backend-common'; import { PluginEndpointDiscovery } from '@backstage/backend-common'; import { processingResult } from '@backstage/plugin-catalog-node'; import { Readable } from 'stream'; -import { ResourcePermission } from '@backstage/plugin-permission-common'; import { Router } from 'express'; import { ScmIntegrationRegistry } from '@backstage/integration'; import { TokenManager } from '@backstage/backend-common'; @@ -128,10 +122,9 @@ export class CatalogBuilder { addLocationAnalyzers( ...analyzers: Array> ): CatalogBuilder; - // @alpha addPermissionRules( ...permissionRules: Array< - CatalogPermissionRule | Array + CatalogPermissionRuleInput | Array > ): this; addProcessor( @@ -172,61 +165,6 @@ export type CatalogCollatorEntityTransformer = ( entity: Entity, ) => Omit; -// @alpha -export const catalogConditions: Conditions<{ - hasAnnotation: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - value?: string | undefined; - annotation: string; - } - >; - hasLabel: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - label: string; - } - >; - hasMetadata: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - value?: string | undefined; - key: string; - } - >; - hasSpec: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - value?: string | undefined; - key: string; - } - >; - isEntityKind: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - kinds: string[]; - } - >; - isEntityOwner: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - claims: string[]; - } - >; -}>; - // @public (undocumented) export type CatalogEnvironment = { logger: Logger; @@ -236,14 +174,11 @@ export type CatalogEnvironment = { permissions: PermissionEvaluator | PermissionAuthorizer; }; -// @alpha -export type CatalogPermissionRule< +// @public +export type CatalogPermissionRuleInput< TParams extends PermissionRuleParams = PermissionRuleParams, > = PermissionRule; -// @alpha -export const catalogPlugin: () => BackendFeature; - // @public export interface CatalogProcessingEngine { // (undocumented) @@ -293,21 +228,6 @@ export class CodeOwnersProcessor implements CatalogProcessor { preProcessEntity(entity: Entity, location: LocationSpec_2): Promise; } -// @alpha -export const createCatalogConditionalDecision: ( - permission: ResourcePermission<'catalog-entity'>, - conditions: PermissionCriteria< - PermissionCondition<'catalog-entity', PermissionRuleParams> - >, -) => ConditionalPolicyDecision; - -// @alpha -export const createCatalogPermissionRule: < - TParams extends PermissionRuleParams = undefined, ->( - rule: PermissionRule, -) => PermissionRule; - // @public export function createRandomProcessingInterval(options: { minSeconds: number; @@ -466,61 +386,6 @@ export function parseEntityYaml( location: LocationSpec_2, ): Iterable; -// @alpha -export const permissionRules: { - hasAnnotation: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - value?: string | undefined; - annotation: string; - } - >; - hasLabel: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - label: string; - } - >; - hasMetadata: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - value?: string | undefined; - key: string; - } - >; - hasSpec: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - value?: string | undefined; - key: string; - } - >; - isEntityKind: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - kinds: string[]; - } - >; - isEntityOwner: PermissionRule< - Entity, - EntitiesSearchFilter, - 'catalog-entity', - { - claims: string[]; - } - >; -}; - // @public export class PlaceholderProcessor implements CatalogProcessor { constructor(options: PlaceholderProcessorOptions); diff --git a/plugins/catalog-backend/package.json b/plugins/catalog-backend/package.json index 297242d6e8..468cc13b34 100644 --- a/plugins/catalog-backend/package.json +++ b/plugins/catalog-backend/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -88,7 +99,6 @@ }, "files": [ "dist", - "alpha", "migrations/**/*.{js,d.ts}", "config.d.ts" ], diff --git a/plugins/catalog-backend/src/alpha.ts b/plugins/catalog-backend/src/alpha.ts new file mode 100644 index 0000000000..51a6a72923 --- /dev/null +++ b/plugins/catalog-backend/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 * from './permissions'; +export { catalogPlugin } from './service/CatalogPlugin'; diff --git a/plugins/catalog-backend/src/index.ts b/plugins/catalog-backend/src/index.ts index 000dd94e8b..e52336f036 100644 --- a/plugins/catalog-backend/src/index.ts +++ b/plugins/catalog-backend/src/index.ts @@ -42,7 +42,6 @@ export { processingResult } from '@backstage/plugin-catalog-node'; export * from './catalog'; export * from './ingestion'; export * from './modules'; -export * from './permissions'; export * from './processing'; export * from './search'; export * from './service'; diff --git a/plugins/catalog-backend/src/permissions/conditionExports.ts b/plugins/catalog-backend/src/permissions/conditionExports.ts index 1c1ba70631..c9406cdc0e 100644 --- a/plugins/catalog-backend/src/permissions/conditionExports.ts +++ b/plugins/catalog-backend/src/permissions/conditionExports.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { createConditionExports } from '@backstage/plugin-permission-node'; import { permissionRules } from './rules'; diff --git a/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts b/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts index fd51a1a060..73f40da8c8 100644 --- a/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts +++ b/plugins/catalog-backend/src/permissions/rules/createPropertyRule.ts @@ -15,7 +15,7 @@ */ import { get } from 'lodash'; -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { createCatalogPermissionRule } from './util'; import { z } from 'zod'; diff --git a/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts b/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts index ae9b1c3963..315d7fa8d0 100644 --- a/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts +++ b/plugins/catalog-backend/src/permissions/rules/hasAnnotation.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { z } from 'zod'; import { createCatalogPermissionRule } from './util'; diff --git a/plugins/catalog-backend/src/permissions/rules/hasLabel.ts b/plugins/catalog-backend/src/permissions/rules/hasLabel.ts index 16c5917585..2d6289dd26 100644 --- a/plugins/catalog-backend/src/permissions/rules/hasLabel.ts +++ b/plugins/catalog-backend/src/permissions/rules/hasLabel.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { z } from 'zod'; import { createCatalogPermissionRule } from './util'; diff --git a/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts b/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts index 94aaa63567..8ebad5521c 100644 --- a/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts +++ b/plugins/catalog-backend/src/permissions/rules/isEntityKind.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { z } from 'zod'; import { EntitiesSearchFilter } from '../../catalog/types'; import { createCatalogPermissionRule } from './util'; diff --git a/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts b/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts index d0cc1d9280..86493315dc 100644 --- a/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts +++ b/plugins/catalog-backend/src/permissions/rules/isEntityOwner.ts @@ -15,7 +15,7 @@ */ import { RELATION_OWNED_BY } from '@backstage/catalog-model'; -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { z } from 'zod'; import { createCatalogPermissionRule } from './util'; diff --git a/plugins/catalog-backend/src/permissions/rules/util.ts b/plugins/catalog-backend/src/permissions/rules/util.ts index ea25e115d2..466f5ce70b 100644 --- a/plugins/catalog-backend/src/permissions/rules/util.ts +++ b/plugins/catalog-backend/src/permissions/rules/util.ts @@ -15,7 +15,7 @@ */ import { Entity } from '@backstage/catalog-model'; -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { PermissionRuleParams } from '@backstage/plugin-permission-common'; import { makeCreatePermissionRule, diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts index 70ec0ee948..42c6930422 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollator.ts @@ -29,10 +29,8 @@ import { CatalogClient, GetEntitiesRequest, } from '@backstage/catalog-client'; -import { - catalogEntityReadPermission, - CatalogEntityDocument, -} from '@backstage/plugin-catalog-common'; +import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha'; +import { CatalogEntityDocument } from '@backstage/plugin-catalog-common'; import { Permission } from '@backstage/plugin-permission-common'; /** diff --git a/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts b/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts index 1c03836e51..ed81d39bbb 100644 --- a/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts +++ b/plugins/catalog-backend/src/search/DefaultCatalogCollatorFactory.ts @@ -25,10 +25,8 @@ import { GetEntitiesRequest, } from '@backstage/catalog-client'; import { DocumentCollatorFactory } from '@backstage/plugin-search-common'; -import { - catalogEntityReadPermission, - CatalogEntityDocument, -} from '@backstage/plugin-catalog-common'; +import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha'; +import { CatalogEntityDocument } from '@backstage/plugin-catalog-common'; import { Permission } from '@backstage/plugin-permission-common'; import { Readable } from 'stream'; import { CatalogCollatorEntityTransformer } from './CatalogCollatorEntityTransformer'; diff --git a/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.ts b/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.ts index c62e9f9a84..b5492e21cf 100644 --- a/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.ts +++ b/plugins/catalog-backend/src/service/AuthorizedEntitiesCatalog.ts @@ -18,7 +18,7 @@ import { NotAllowedError } from '@backstage/errors'; import { catalogEntityDeletePermission, catalogEntityReadPermission, -} from '@backstage/plugin-catalog-common'; +} from '@backstage/plugin-catalog-common/alpha'; import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; import { AuthorizeResult, diff --git a/plugins/catalog-backend/src/service/AuthorizedLocationService.ts b/plugins/catalog-backend/src/service/AuthorizedLocationService.ts index a73597649e..68bb1553a8 100644 --- a/plugins/catalog-backend/src/service/AuthorizedLocationService.ts +++ b/plugins/catalog-backend/src/service/AuthorizedLocationService.ts @@ -21,7 +21,7 @@ import { catalogLocationCreatePermission, catalogLocationDeletePermission, catalogLocationReadPermission, -} from '@backstage/plugin-catalog-common'; +} from '@backstage/plugin-catalog-common/alpha'; import { AuthorizeResult, PermissionEvaluator, diff --git a/plugins/catalog-backend/src/service/AuthorizedRefreshService.ts b/plugins/catalog-backend/src/service/AuthorizedRefreshService.ts index 8634fbf86d..cbc728750a 100644 --- a/plugins/catalog-backend/src/service/AuthorizedRefreshService.ts +++ b/plugins/catalog-backend/src/service/AuthorizedRefreshService.ts @@ -15,7 +15,7 @@ */ import { NotAllowedError } from '@backstage/errors'; -import { catalogEntityRefreshPermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityRefreshPermission } from '@backstage/plugin-catalog-common/alpha'; import { AuthorizeResult, PermissionEvaluator, diff --git a/plugins/catalog-backend/src/service/CatalogBuilder.ts b/plugins/catalog-backend/src/service/CatalogBuilder.ts index 48bf6a08ef..b7040796f2 100644 --- a/plugins/catalog-backend/src/service/CatalogBuilder.ts +++ b/plugins/catalog-backend/src/service/CatalogBuilder.ts @@ -76,10 +76,10 @@ import { DefaultCatalogRulesEnforcer } from '../ingestion/CatalogRules'; import { Config } from '@backstage/config'; import { Logger } from 'winston'; import { connectEntityProviders } from '../processing/connectEntityProviders'; -import { - CatalogPermissionRule, - permissionRules as catalogPermissionRules, -} from '../permissions/rules'; +import { PermissionRuleParams } from '@backstage/plugin-permission-common'; +import { EntitiesSearchFilter } from '../catalog/types'; +import { permissionRules as catalogPermissionRules } from '../permissions/rules'; +import { PermissionRule } from '@backstage/plugin-permission-node'; import { PermissionAuthorizer, PermissionEvaluator, @@ -94,11 +94,20 @@ import { basicEntityFilter } from './request/basicEntityFilter'; import { catalogPermissions, RESOURCE_TYPE_CATALOG_ENTITY, -} from '@backstage/plugin-catalog-common'; +} from '@backstage/plugin-catalog-common/alpha'; import { AuthorizedLocationService } from './AuthorizedLocationService'; import { DefaultProviderDatabase } from '../database/DefaultProviderDatabase'; import { DefaultCatalogDatabase } from '../database/DefaultCatalogDatabase'; +/** + * This is a duplicate of the alpha `CatalogPermissionRule` type, for use in the stable API. + * + * @public + */ +export type CatalogPermissionRuleInput< + TParams extends PermissionRuleParams = PermissionRuleParams, +> = PermissionRule; + /** @public */ export type CatalogEnvironment = { logger: Logger; @@ -154,7 +163,7 @@ export class CatalogBuilder { maxSeconds: 150, }); private locationAnalyzer: LocationAnalyzer | undefined = undefined; - private readonly permissionRules: CatalogPermissionRule[]; + private readonly permissionRules: CatalogPermissionRuleInput[]; private allowedLocationType: string[]; private legacySingleProcessorValidation = false; @@ -379,11 +388,10 @@ export class CatalogBuilder { * {@link @backstage/plugin-permission-node#PermissionRule}. * * @param permissionRules - Additional permission rules - * @alpha */ addPermissionRules( ...permissionRules: Array< - CatalogPermissionRule | Array + CatalogPermissionRuleInput | Array > ) { this.permissionRules.push(...permissionRules.flat()); diff --git a/plugins/catalog-backend/src/service/CatalogPlugin.ts b/plugins/catalog-backend/src/service/CatalogPlugin.ts index 5abb630668..a6b164001c 100644 --- a/plugins/catalog-backend/src/service/CatalogPlugin.ts +++ b/plugins/catalog-backend/src/service/CatalogPlugin.ts @@ -19,9 +19,11 @@ import { } from '@backstage/backend-plugin-api'; import { CatalogBuilder } from './CatalogBuilder'; import { - CatalogProcessor, CatalogProcessingExtensionPoint, catalogProcessingExtensionPoint, +} from '@backstage/plugin-catalog-node/alpha'; +import { + CatalogProcessor, EntityProvider, } from '@backstage/plugin-catalog-node'; import { loggerToWinstonLogger } from '@backstage/backend-common'; diff --git a/plugins/catalog-backend/src/service/createRouter.test.ts b/plugins/catalog-backend/src/service/createRouter.test.ts index 6379d65043..2fa06f8694 100644 --- a/plugins/catalog-backend/src/service/createRouter.test.ts +++ b/plugins/catalog-backend/src/service/createRouter.test.ts @@ -34,7 +34,7 @@ import { createPermissionIntegrationRouter, createPermissionRule, } from '@backstage/plugin-permission-node'; -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { CatalogProcessingOrchestrator } from '../processing/types'; import { z } from 'zod'; diff --git a/plugins/catalog-backend/src/service/index.ts b/plugins/catalog-backend/src/service/index.ts index 7e0c6025c3..44645d39fe 100644 --- a/plugins/catalog-backend/src/service/index.ts +++ b/plugins/catalog-backend/src/service/index.ts @@ -14,6 +14,8 @@ * limitations under the License. */ -export type { CatalogEnvironment } from './CatalogBuilder'; +export type { + CatalogEnvironment, + CatalogPermissionRuleInput, +} from './CatalogBuilder'; export { CatalogBuilder } from './CatalogBuilder'; -export { catalogPlugin } from './CatalogPlugin'; From dcc79493bfaa99d26422e0eae0ae870cf7dc20bd Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:41:48 +0100 Subject: [PATCH 28/65] app-backend: migrate to use exports Signed-off-by: Patrik Oldsberg --- plugins/app-backend/alpha-api-report.md | 21 +++++++++++++++++++++ plugins/app-backend/api-report.md | 12 ------------ plugins/app-backend/package.json | 22 ++++++++++++++++------ plugins/app-backend/src/alpha.ts | 18 ++++++++++++++++++ plugins/app-backend/src/index.ts | 2 -- 5 files changed, 55 insertions(+), 20 deletions(-) create mode 100644 plugins/app-backend/alpha-api-report.md create mode 100644 plugins/app-backend/src/alpha.ts diff --git a/plugins/app-backend/alpha-api-report.md b/plugins/app-backend/alpha-api-report.md new file mode 100644 index 0000000000..20a2902557 --- /dev/null +++ b/plugins/app-backend/alpha-api-report.md @@ -0,0 +1,21 @@ +## API Report File for "@backstage/plugin-app-backend" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; +import express from 'express'; + +// @alpha +export const appPlugin: (options: AppPluginOptions) => BackendFeature; + +// @alpha (undocumented) +export type AppPluginOptions = { + appPackageName?: string; + staticFallbackHandler?: express.Handler; + disableConfigInjection?: boolean; + disableStaticFallbackCache?: boolean; +}; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/app-backend/api-report.md b/plugins/app-backend/api-report.md index b52132ef51..0383129823 100644 --- a/plugins/app-backend/api-report.md +++ b/plugins/app-backend/api-report.md @@ -3,23 +3,11 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { Config } from '@backstage/config'; import express from 'express'; import { Logger } from 'winston'; import { PluginDatabaseManager } from '@backstage/backend-common'; -// @alpha -export const appPlugin: (options: AppPluginOptions) => BackendFeature; - -// @alpha (undocumented) -export type AppPluginOptions = { - appPackageName?: string; - staticFallbackHandler?: express.Handler; - disableConfigInjection?: boolean; - disableStaticFallbackCache?: boolean; -}; - // @public (undocumented) export function createRouter(options: RouterOptions): Promise; diff --git a/plugins/app-backend/package.json b/plugins/app-backend/package.json index 4b8f4ece73..d52ab37abe 100644 --- a/plugins/app-backend/package.json +++ b/plugins/app-backend/package.json @@ -6,10 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "backend-plugin" @@ -25,7 +36,7 @@ ], "scripts": { "start": "backstage-cli package start", - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -63,7 +74,6 @@ }, "files": [ "dist", - "alpha", "migrations/**/*.{js,d.ts}", "static" ] diff --git a/plugins/app-backend/src/alpha.ts b/plugins/app-backend/src/alpha.ts new file mode 100644 index 0000000000..cc8276b853 --- /dev/null +++ b/plugins/app-backend/src/alpha.ts @@ -0,0 +1,18 @@ +/* + * Copyright 2023 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 { appPlugin } from './service/appPlugin'; +export type { AppPluginOptions } from './service/appPlugin'; diff --git a/plugins/app-backend/src/index.ts b/plugins/app-backend/src/index.ts index 167dc041fc..c91416eac1 100644 --- a/plugins/app-backend/src/index.ts +++ b/plugins/app-backend/src/index.ts @@ -21,5 +21,3 @@ */ export * from './service/router'; -export { appPlugin } from './service/appPlugin'; -export type { AppPluginOptions } from './service/appPlugin'; From 76a21aad7e7d3aca2975585f267241e028768ec7 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:47:31 +0100 Subject: [PATCH 29/65] test-utils: migrate to use exports Signed-off-by: Patrik Oldsberg --- packages/test-utils/alpha-api-report.md | 14 +++++++++++ packages/test-utils/api-report.md | 6 ----- packages/test-utils/package.json | 24 +++++++++++++------ packages/test-utils/src/alpha.ts | 17 +++++++++++++ .../{providers.tsx => MockPluginProvider.tsx} | 0 packages/test-utils/src/testUtils/index.tsx | 1 - 6 files changed, 48 insertions(+), 14 deletions(-) create mode 100644 packages/test-utils/alpha-api-report.md create mode 100644 packages/test-utils/src/alpha.ts rename packages/test-utils/src/testUtils/{providers.tsx => MockPluginProvider.tsx} (100%) diff --git a/packages/test-utils/alpha-api-report.md b/packages/test-utils/alpha-api-report.md new file mode 100644 index 0000000000..3e0c4aa6c2 --- /dev/null +++ b/packages/test-utils/alpha-api-report.md @@ -0,0 +1,14 @@ +## API Report File for "@backstage/test-utils" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { PropsWithChildren } from 'react'; + +// @alpha +export const MockPluginProvider: ({ + children, +}: PropsWithChildren<{}>) => JSX.Element; + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/test-utils/api-report.md b/packages/test-utils/api-report.md index e11072f5a6..37650ff18a 100644 --- a/packages/test-utils/api-report.md +++ b/packages/test-utils/api-report.md @@ -26,7 +26,6 @@ import { JsonValue } from '@backstage/types'; import { MatcherFunction } from '@testing-library/react'; import { Observable } from '@backstage/types'; import { PermissionApi } from '@backstage/plugin-permission-react'; -import { PropsWithChildren } from 'react'; import { ReactElement } from 'react'; import { ReactNode } from 'react'; import { RenderOptions } from '@testing-library/react'; @@ -167,11 +166,6 @@ export class MockPermissionApi implements PermissionApi { ): Promise; } -// @alpha -export const MockPluginProvider: ({ - children, -}: PropsWithChildren<{}>) => JSX.Element; - // @public export class MockStorageApi implements StorageApi { // (undocumented) diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 9e82ccc1d7..4148f62a3f 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -3,10 +3,21 @@ "description": "Utilities to test Backstage plugins and apps.", "version": "1.2.5", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "web-library" @@ -24,7 +35,7 @@ "main": "src/index.ts", "types": "src/index.ts", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -60,7 +71,6 @@ "msw": "^0.49.0" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/packages/test-utils/src/alpha.ts b/packages/test-utils/src/alpha.ts new file mode 100644 index 0000000000..0b2a6a8d1c --- /dev/null +++ b/packages/test-utils/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 * from './testUtils/MockPluginProvider'; diff --git a/packages/test-utils/src/testUtils/providers.tsx b/packages/test-utils/src/testUtils/MockPluginProvider.tsx similarity index 100% rename from packages/test-utils/src/testUtils/providers.tsx rename to packages/test-utils/src/testUtils/MockPluginProvider.tsx diff --git a/packages/test-utils/src/testUtils/index.tsx b/packages/test-utils/src/testUtils/index.tsx index 8fc1395eb8..1510af106e 100644 --- a/packages/test-utils/src/testUtils/index.tsx +++ b/packages/test-utils/src/testUtils/index.tsx @@ -25,7 +25,6 @@ export { export type { TestAppOptions } from './appWrappers'; export * from './msw'; export * from './logCollector'; -export * from './providers'; export * from './testingLibrary'; export { TestApiProvider, TestApiRegistry } from './TestApiProvider'; export type { TestApiProviderProps } from './TestApiProvider'; From 7b76628a6a03729cb9c48f9cded6495c7fc51653 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:54:24 +0100 Subject: [PATCH 30/65] core-plugin-api: migrate to use exports Signed-off-by: Patrik Oldsberg --- packages/core-plugin-api/alpha-api-report.md | 27 ++++++++++++++++++++ packages/core-plugin-api/api-report.md | 16 ------------ packages/core-plugin-api/package.json | 24 ++++++++++++----- packages/core-plugin-api/src/alpha.ts | 17 ++++++++++++ packages/core-plugin-api/src/index.ts | 1 - 5 files changed, 61 insertions(+), 24 deletions(-) create mode 100644 packages/core-plugin-api/alpha-api-report.md create mode 100644 packages/core-plugin-api/src/alpha.ts diff --git a/packages/core-plugin-api/alpha-api-report.md b/packages/core-plugin-api/alpha-api-report.md new file mode 100644 index 0000000000..b66fee8207 --- /dev/null +++ b/packages/core-plugin-api/alpha-api-report.md @@ -0,0 +1,27 @@ +## API Report File for "@backstage/core-plugin-api" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { ReactNode } from 'react'; + +// @alpha +export interface PluginOptionsProviderProps { + // (undocumented) + children: ReactNode; + // Warning: (ae-forgotten-export) The symbol "BackstagePlugin" needs to be exported by the entry point alpha.d.ts + // + // (undocumented) + plugin?: BackstagePlugin; +} + +// @alpha +export const PluginProvider: (props: PluginOptionsProviderProps) => JSX.Element; + +// @alpha +export function usePluginOptions< + TPluginOptions extends {} = {}, +>(): TPluginOptions; + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/core-plugin-api/api-report.md b/packages/core-plugin-api/api-report.md index 91f05921bf..4887f0b7f2 100644 --- a/packages/core-plugin-api/api-report.md +++ b/packages/core-plugin-api/api-report.md @@ -649,17 +649,6 @@ export type PluginFeatureFlagConfig = { name: string; }; -// @alpha -export interface PluginOptionsProviderProps { - // (undocumented) - children: ReactNode; - // (undocumented) - plugin?: BackstagePlugin; -} - -// @alpha -export const PluginProvider: (props: PluginOptionsProviderProps) => JSX.Element; - // @public export type ProfileInfo = { email?: string; @@ -760,11 +749,6 @@ export function useElementFilter( dependencies?: any[], ): T; -// @alpha -export function usePluginOptions< - TPluginOptions extends {} = {}, ->(): TPluginOptions; - // @public export function useRouteRef( routeRef: ExternalRouteRef, diff --git a/packages/core-plugin-api/package.json b/packages/core-plugin-api/package.json index f1f023eedb..e01c99f384 100644 --- a/packages/core-plugin-api/package.json +++ b/packages/core-plugin-api/package.json @@ -3,10 +3,21 @@ "description": "Core API used by Backstage plugins", "version": "1.4.0", "publishConfig": { - "access": "public", - "main": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "web-library" @@ -24,7 +35,7 @@ "main": "src/index.ts", "types": "src/index.ts", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -60,7 +71,6 @@ "msw": "^0.49.0" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/packages/core-plugin-api/src/alpha.ts b/packages/core-plugin-api/src/alpha.ts new file mode 100644 index 0000000000..09983a48e9 --- /dev/null +++ b/packages/core-plugin-api/src/alpha.ts @@ -0,0 +1,17 @@ +/* + * Copyright 2023 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 * from './plugin-options'; diff --git a/packages/core-plugin-api/src/index.ts b/packages/core-plugin-api/src/index.ts index e8edd38ff3..30fc35b62a 100644 --- a/packages/core-plugin-api/src/index.ts +++ b/packages/core-plugin-api/src/index.ts @@ -22,7 +22,6 @@ export * from './analytics'; export * from './apis'; -export * from './plugin-options'; export * from './app'; export * from './extensions'; export * from './icons'; From 4a12dbbc45794a9a7cf9a1b38ba9f9997662c602 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:57:00 +0100 Subject: [PATCH 31/65] catalog-model: migrate to use exports Signed-off-by: Patrik Oldsberg --- packages/catalog-model/alpha-api-report.md | 34 +++++++++++++++++ packages/catalog-model/api-report.md | 22 ----------- packages/catalog-model/package.json | 25 +++++++++---- packages/catalog-model/src/alpha.ts | 22 +++++++++++ .../catalog-model/src/entity/AlphaEntity.ts | 37 +++++++++++++++++++ packages/catalog-model/src/entity/Entity.ts | 20 ---------- packages/catalog-model/src/entity/index.ts | 13 +------ 7 files changed, 111 insertions(+), 62 deletions(-) create mode 100644 packages/catalog-model/alpha-api-report.md create mode 100644 packages/catalog-model/src/alpha.ts create mode 100644 packages/catalog-model/src/entity/AlphaEntity.ts diff --git a/packages/catalog-model/alpha-api-report.md b/packages/catalog-model/alpha-api-report.md new file mode 100644 index 0000000000..639cba1fef --- /dev/null +++ b/packages/catalog-model/alpha-api-report.md @@ -0,0 +1,34 @@ +## API Report File for "@backstage/catalog-model" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { JsonObject } from '@backstage/types'; +import { SerializedError } from '@backstage/errors'; + +// Warning: (ae-forgotten-export) The symbol "Entity" needs to be exported by the entry point alpha.d.ts +// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/catalog-model" does not have an export "Entity" +// +// @alpha +export interface AlphaEntity extends Entity { + status?: EntityStatus; +} + +// @alpha +export type EntityStatus = { + items?: EntityStatusItem[]; +}; + +// @alpha +export type EntityStatusItem = { + type: string; + level: EntityStatusLevel; + message: string; + error?: SerializedError; +}; + +// @alpha +export type EntityStatusLevel = 'info' | 'warning' | 'error'; + +// (No @packageDocumentation comment for this package) +``` diff --git a/packages/catalog-model/api-report.md b/packages/catalog-model/api-report.md index 15eec90f09..b8eb20c590 100644 --- a/packages/catalog-model/api-report.md +++ b/packages/catalog-model/api-report.md @@ -4,12 +4,6 @@ ```ts import { JsonObject } from '@backstage/types'; -import { SerializedError } from '@backstage/errors'; - -// @alpha -export interface AlphaEntity extends Entity { - status?: EntityStatus; -} // @public export const ANNOTATION_EDIT_URL = 'backstage.io/edit-url'; @@ -209,22 +203,6 @@ export function entitySchemaValidator( schema?: unknown, ): (data: unknown) => T; -// @alpha -export type EntityStatus = { - items?: EntityStatusItem[]; -}; - -// @alpha -export type EntityStatusItem = { - type: string; - level: EntityStatusLevel; - message: string; - error?: SerializedError; -}; - -// @alpha -export type EntityStatusLevel = 'info' | 'warning' | 'error'; - // @public export class FieldFormatEntityPolicy implements EntityPolicy { constructor(validators?: Validators); diff --git a/packages/catalog-model/package.json b/packages/catalog-model/package.json index 00f9543f52..b07e2df915 100644 --- a/packages/catalog-model/package.json +++ b/packages/catalog-model/package.json @@ -6,11 +6,21 @@ "types": "src/index.ts", "license": "Apache-2.0", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "module": "dist/index.esm.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts", + "./alpha": "./src/alpha.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ], + "alpha": [ + "src/alpha.ts" + ] + } }, "backstage": { "role": "common-library" @@ -25,7 +35,7 @@ "backstage" ], "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -48,7 +58,6 @@ "yaml": "^2.0.0" }, "files": [ - "dist", - "alpha" + "dist" ] } diff --git a/packages/catalog-model/src/alpha.ts b/packages/catalog-model/src/alpha.ts new file mode 100644 index 0000000000..1d29c97464 --- /dev/null +++ b/packages/catalog-model/src/alpha.ts @@ -0,0 +1,22 @@ +/* + * Copyright 2023 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 type { + EntityStatus, + EntityStatusItem, + EntityStatusLevel, +} from './entity/EntityStatus'; +export type { AlphaEntity } from './entity/AlphaEntity'; diff --git a/packages/catalog-model/src/entity/AlphaEntity.ts b/packages/catalog-model/src/entity/AlphaEntity.ts new file mode 100644 index 0000000000..57a1954f52 --- /dev/null +++ b/packages/catalog-model/src/entity/AlphaEntity.ts @@ -0,0 +1,37 @@ +/* + * Copyright 2020 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 { Entity } from './Entity'; +import { EntityStatus } from './EntityStatus'; + +/** + * A version of the {@link Entity} type that contains unstable alpha fields. + * + * @remarks + * + * Available via the `@backstage/catalog-model/alpha` import. + * + * @alpha + */ +export interface AlphaEntity extends Entity { + /** + * The current status of the entity, as claimed by various sources. + * + * The keys are implementation defined and the values can be any JSON object + * with semantics that match that implementation. + */ + status?: EntityStatus; +} diff --git a/packages/catalog-model/src/entity/Entity.ts b/packages/catalog-model/src/entity/Entity.ts index 80c9adaffb..8d36fe0134 100644 --- a/packages/catalog-model/src/entity/Entity.ts +++ b/packages/catalog-model/src/entity/Entity.ts @@ -15,7 +15,6 @@ */ import { JsonObject } from '@backstage/types'; -import { EntityStatus } from './EntityStatus'; /** * The parts of the format that's common to all versions/kinds of entity. @@ -54,25 +53,6 @@ export type Entity = { relations?: EntityRelation[]; }; -/** - * A version of the {@link Entity} type that contains unstable alpha fields. - * - * @remarks - * - * Available via the `@backstage/catalog-model/alpha` import. - * - * @alpha - */ -export interface AlphaEntity extends Entity { - /** - * The current status of the entity, as claimed by various sources. - * - * The keys are implementation defined and the values can be any JSON object - * with semantics that match that implementation. - */ - status?: EntityStatus; -} - /** * Metadata fields common to all versions/kinds of entity. * diff --git a/packages/catalog-model/src/entity/index.ts b/packages/catalog-model/src/entity/index.ts index 87f414cc9c..269d56ec86 100644 --- a/packages/catalog-model/src/entity/index.ts +++ b/packages/catalog-model/src/entity/index.ts @@ -16,19 +16,8 @@ export * from './conditions'; export * from './constants'; -export type { - AlphaEntity, - Entity, - EntityLink, - EntityMeta, - EntityRelation, -} from './Entity'; +export type { Entity, EntityLink, EntityMeta, EntityRelation } from './Entity'; export type { EntityEnvelope } from './EntityEnvelope'; -export type { - EntityStatus, - EntityStatusItem, - EntityStatusLevel, -} from './EntityStatus'; export * from './policies'; export { getCompoundEntityRef, From 03104255933339aabc8568788dffb13ee256ef06 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 10:59:35 +0100 Subject: [PATCH 32/65] backend-test-utils: migrate to use exports Signed-off-by: Patrik Oldsberg --- packages/backend-test-utils/package.json | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/backend-test-utils/package.json b/packages/backend-test-utils/package.json index a6f02257d8..6330b161e1 100644 --- a/packages/backend-test-utils/package.json +++ b/packages/backend-test-utils/package.json @@ -5,10 +5,17 @@ "main": "src/index.ts", "types": "src/index.ts", "publishConfig": { - "access": "public", - "main": "dist/index.cjs.js", - "types": "dist/index.d.ts", - "alphaTypes": "dist/index.alpha.d.ts" + "access": "public" + }, + "exports": { + ".": "./src/index.ts" + }, + "typesVersions": { + "*": { + "*": [ + "src/index.ts" + ] + } }, "backstage": { "role": "node-library" @@ -25,7 +32,7 @@ ], "license": "Apache-2.0", "scripts": { - "build": "backstage-cli package build --experimental-type-build", + "build": "backstage-cli package build", "lint": "backstage-cli package lint", "test": "backstage-cli package test", "prepack": "backstage-cli package prepack", @@ -55,7 +62,6 @@ "supertest": "^6.1.3" }, "files": [ - "dist", - "alpha" + "dist" ] } From 8d14fb7a9b8a120b578d2ecec88f3a744c2661da Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 13:03:57 +0100 Subject: [PATCH 33/65] docs: document sub-path exports Signed-off-by: Patrik Oldsberg --- docs/local-dev/cli-build-system.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index cf8ac626b9..a784e0eff9 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -650,8 +650,34 @@ The following is an excerpt of a typical setup of an isomorphic library package: "files": ["dist"], ``` +## Sub-path Exports + +The Backstage CLI supports implementation of sub-path exports through the `"exports"` field in `package.json`. It might for example look like this: + +```json + "name": "@backstage/plugin-foo", + "exports": { + ".": "./src/index.ts", + "./components": "./src/components.ts", + }, +``` + +This in turn would allow you to import anything exported in `src/index.ts` via `@backstage/plugins-foo`, and `src/components.ts` via `@backstage/plugins-foo/components`. Note that patterns are not supported, meaning the exports may not contain `*` wildcards. + +As with the rest of the Backstage CLI build system, the setup is optimized for local development, which is why the `"exports"` targets point directly to source files. The `package build` command will detect the `"exports"` field and automatically generate the corresponding `dist` files, and the `prepublish` command will rewrite the `"exports"` field to point to the `dist` files, as well as generating folder-based entry points for backwards compatibility. + +TypeScript support is currently handled though the `typesVersions` field, as there is not yet a module resolution mode that works well with `"exports"`. You can craft the `typesVersions` yourself, but it will also be automatically generated by the `migrate package-exports` command. + +To add sub-path exports to an existing package, simply add the desired `"exports"` fields and then run the following command: + +```bash +yarn backstage-cli package migrate package-exports +``` + ## Experimental Type Build +> Note: Experimental type builds are deprecated and will be removed in the future. They have been replaced by [sub-path exports](#sub-path-exports). + The Backstage CLI has an experimental feature where multiple different type definition files can be generated for different release stages. The release stages are marked in the [TSDoc](https://tsdoc.org/) for each individual export, using either `@public`, `@alpha`, or `@beta`. Rather than just building a single `index.d.ts` file, the build process will instead output `index.d.ts`, `index.beta.d.ts`, and `index.alpha.d.ts`. Each of these files will have exports from more unstable release stages stripped, meaning that `index.d.ts` will omit all exports marked with `@alpha` or `@beta`, while `index.beta.d.ts` will omit all exports marked with `@alpha`. This feature is aimed at projects that publish to package registries and wish to maintain different levels of API stability within each package. There is no need to use this within a single monorepo, as it has no effect due to only applying to built and published packages. From 55937a25ae24a303cb1811c09b1ba16587079c75 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 13:06:33 +0100 Subject: [PATCH 34/65] prettier: ignore *-api-report.md Signed-off-by: Patrik Oldsberg --- .prettierignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.prettierignore b/.prettierignore index 8f1fae0456..ad2bd355ed 100644 --- a/.prettierignore +++ b/.prettierignore @@ -5,6 +5,7 @@ coverage *.hbs templates api-report.md +*-api-report.md cli-report.md plugins/scaffolder-backend/sample-templates .vscode From 57934df9848f0e211d38e39a1438bff0da7c2dba Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Mon, 16 Jan 2023 23:06:59 +0100 Subject: [PATCH 35/65] repo-tools: fix warning counter for non-index API reports Signed-off-by: Patrik Oldsberg --- .../src/commands/api-reports/api-extractor.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index 91df053f22..c05fd0a01e 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -237,10 +237,9 @@ export async function createTemporaryTsConfig(includedPackageDirs: string[]) { return path; } -export async function countApiReportWarnings(projectFolder: string) { - const path = resolvePath(projectFolder, 'api-report.md'); +export async function countApiReportWarnings(reportPath: string) { try { - const content = await fs.readFile(path, 'utf8'); + const content = await fs.readFile(reportPath, 'utf8'); const lines = content.split('\n'); const lineWarnings = lines.filter(line => @@ -380,9 +379,12 @@ export async function runApiExtraction({ packageDir, ); - const warningCountBefore = await countApiReportWarnings(projectFolder); - const prefix = name === 'index' ? '' : `${name}-`; + const reportFileName = `${prefix}api-report.md`; + const reportPath = resolvePath(projectFolder, reportFileName); + + const warningCountBefore = await countApiReportWarnings(reportPath); + const extractorConfig = ExtractorConfig.prepare({ configObject: { mainEntryPointFilePath: resolvePath(packageFolder, `src/${name}.d.ts`), @@ -394,7 +396,7 @@ export async function runApiExtraction({ apiReport: { enabled: true, - reportFileName: `${prefix}api-report.md`, + reportFileName, reportFolder: projectFolder, reportTempFolder: resolvePath( outputDir, @@ -547,7 +549,7 @@ export async function runApiExtraction({ ); } - const warningCountAfter = await countApiReportWarnings(projectFolder); + const warningCountAfter = await countApiReportWarnings(reportPath); if (noBail) { console.log(`Skipping warnings check for ${packageDir}`); } From 61055f106b011eb1364dfc0df0fc30d4ad0996af Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 09:43:21 +0100 Subject: [PATCH 36/65] update /alpha imports to fix all type issues Signed-off-by: Patrik Oldsberg --- docs/local-dev/cli-commands.md | 1 - packages/app/src/App.tsx | 4 ++-- .../components/scaffolder/customScaffolderExtensions.tsx | 3 ++- packages/backend-defaults/src/CreateBackend.test.ts | 2 +- packages/backend-next/src/index.ts | 6 +++--- packages/cli/src/commands/index.ts | 2 +- packages/test-utils/src/testUtils/MockPluginProvider.tsx | 3 ++- .../BitbucketCloudEntityProviderCatalogModule.test.ts | 5 ++++- .../src/run.ts | 2 +- plugins/catalog-backend/src/stitching/Stitcher.ts | 3 +-- .../InspectEntityDialog/components/OverviewPage.tsx | 2 +- plugins/catalog-react/src/filters.test.ts | 3 ++- plugins/catalog-react/src/filters.ts | 7 ++----- .../catalog-react/src/hooks/useEntityPermission.test.tsx | 2 +- .../components/CatalogPage/DefaultCatalogPage.test.tsx | 2 +- .../components/EntityContextMenu/EntityContextMenu.tsx | 4 ++-- .../EntityProcessingErrorsPanel.test.tsx | 3 ++- .../EntityProcessingErrorsPanel.tsx | 8 ++------ plugins/catalog/src/options.ts | 2 +- .../components/CostOverviewCard/CostOverviewCard.test.tsx | 3 ++- .../src/components/EntityCosts/EntityCost.test.tsx | 7 ++----- plugins/cost-insights/src/options.ts | 2 +- plugins/jenkins-common/src/permissions.ts | 2 +- .../src/components/BuildsPage/lib/CITable/CITable.tsx | 2 +- plugins/scaffolder-backend/src/ScaffolderPlugin.ts | 2 +- .../src/modules/catalogModuleTemplateKind.test.ts | 2 +- .../src/modules/catalogModuleTemplateKind.ts | 2 +- .../src/components/ScaffolderPage/ScaffolderPage.tsx | 2 +- .../src/next/TemplateListPage/RegisterExistingButton.tsx | 2 +- plugins/sonarqube/dev/index.tsx | 4 ++-- plugins/sonarqube/src/api/SonarQubeClient.test.ts | 2 +- plugins/sonarqube/src/api/SonarQubeClient.ts | 2 +- plugins/sonarqube/src/api/types.ts | 6 ++++-- .../src/components/SonarQubeCard/SonarQubeCard.tsx | 4 ++-- .../SonarQubeContentPage/SonarQubeContentPage.test.tsx | 6 ++++-- plugins/sonarqube/src/plugin.ts | 2 +- .../src/search/DefaultTechDocsCollator.ts | 2 +- .../src/search/DefaultTechDocsCollatorFactory.ts | 2 +- 38 files changed, 60 insertions(+), 60 deletions(-) diff --git a/docs/local-dev/cli-commands.md b/docs/local-dev/cli-commands.md index b43825d733..e34dd63295 100644 --- a/docs/local-dev/cli-commands.md +++ b/docs/local-dev/cli-commands.md @@ -120,7 +120,6 @@ Build a package for production deployment or publishing Options: --role <name> Run the command with an explicit package role --minify Minify the generated code. Does not apply to app or backend packages. - --experimental-type-build Enable experimental type build. Does not apply to app or backend packages. --skip-build-dependencies Skip the automatic building of local dependencies. Applies to backend packages only. --stats If bundle stats are available, write them to the output directory. Applies to app packages only. --config <path> Config files to load instead of app-config.yaml. Applies to app packages only. (default: []) diff --git a/packages/app/src/App.tsx b/packages/app/src/App.tsx index dfd2437b6b..4dacbbc007 100644 --- a/packages/app/src/App.tsx +++ b/packages/app/src/App.tsx @@ -59,9 +59,9 @@ import { GraphiQLPage } from '@backstage/plugin-graphiql'; import { HomepageCompositionRoot } from '@backstage/plugin-home'; import { LighthousePage } from '@backstage/plugin-lighthouse'; import { NewRelicPage } from '@backstage/plugin-newrelic'; +import { NextScaffolderPage } from '@backstage/plugin-scaffolder/alpha'; import { ScaffolderPage, - NextScaffolderPage, scaffolderPlugin, ScaffolderLayouts, } from '@backstage/plugin-scaffolder'; @@ -104,7 +104,7 @@ import * as plugins from './plugins'; import { techDocsPage } from './components/techdocs/TechDocsPage'; import { ApacheAirflowPage } from '@backstage/plugin-apache-airflow'; import { RequirePermission } from '@backstage/plugin-permission-react'; -import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha'; import { PlaylistIndexPage } from '@backstage/plugin-playlist'; import { TwoColumnLayout } from './components/scaffolder/customScaffolderLayouts'; import { ScoreBoardPage } from '@oriflame/backstage-plugin-score-card'; diff --git a/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx b/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx index 8a2e7fba53..b15d12979a 100644 --- a/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx +++ b/packages/app/src/components/scaffolder/customScaffolderExtensions.tsx @@ -17,10 +17,11 @@ import React from 'react'; import type { FieldValidation } from '@rjsf/utils'; import { scaffolderPlugin } from '@backstage/plugin-scaffolder'; import { TextField } from '@material-ui/core'; - import { NextFieldExtensionComponentProps, createNextScaffolderFieldExtension, +} from '@backstage/plugin-scaffolder-react/alpha'; +import { createScaffolderFieldExtension, FieldExtensionComponentProps, } from '@backstage/plugin-scaffolder-react'; diff --git a/packages/backend-defaults/src/CreateBackend.test.ts b/packages/backend-defaults/src/CreateBackend.test.ts index 8d56cd0986..cc6c93c0eb 100644 --- a/packages/backend-defaults/src/CreateBackend.test.ts +++ b/packages/backend-defaults/src/CreateBackend.test.ts @@ -21,7 +21,7 @@ import { createServiceRef, createSharedEnvironment, } from '@backstage/backend-plugin-api'; -import { mockServices } from '@backstage/backend-test-utils'; +import { mockServices } from '@backstage/backend-test-utils/alpha'; import { createBackend } from './CreateBackend'; const fooServiceRef = createServiceRef({ id: 'foo', scope: 'root' }); diff --git a/packages/backend-next/src/index.ts b/packages/backend-next/src/index.ts index f4979760cf..8e29244ebf 100644 --- a/packages/backend-next/src/index.ts +++ b/packages/backend-next/src/index.ts @@ -14,10 +14,10 @@ * limitations under the License. */ -import { catalogPlugin } from '@backstage/plugin-catalog-backend'; -import { catalogModuleTemplateKind } from '@backstage/plugin-scaffolder-backend'; +import { catalogPlugin } from '@backstage/plugin-catalog-backend/alpha'; +import { catalogModuleTemplateKind } from '@backstage/plugin-scaffolder-backend/alpha'; import { createBackend } from '@backstage/backend-defaults'; -import { appPlugin } from '@backstage/plugin-app-backend'; +import { appPlugin } from '@backstage/plugin-app-backend/alpha'; import { todoPlugin } from '@backstage/plugin-todo-backend'; const backend = createBackend(); diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 2fdd2442d4..3eb511e06d 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -116,7 +116,7 @@ export function registerScriptCommand(program: Command) { ) .option( '--experimental-type-build', - 'Enable experimental type build. Does not apply to app or backend packages.', + 'Enable experimental type build. Does not apply to app or backend packages. [DEPRECATED]', ) .option( '--skip-build-dependencies', diff --git a/packages/test-utils/src/testUtils/MockPluginProvider.tsx b/packages/test-utils/src/testUtils/MockPluginProvider.tsx index 8bc4b5122d..25442ae267 100644 --- a/packages/test-utils/src/testUtils/MockPluginProvider.tsx +++ b/packages/test-utils/src/testUtils/MockPluginProvider.tsx @@ -15,7 +15,8 @@ */ import React, { PropsWithChildren } from 'react'; -import { createPlugin, PluginProvider } from '@backstage/core-plugin-api'; +import { PluginProvider } from '@backstage/core-plugin-api/alpha'; +import { createPlugin } from '@backstage/core-plugin-api'; /** * Mock for PluginProvider to use in unit tests diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts index 630c18b134..13ad5dbf22 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts @@ -19,7 +19,10 @@ import { PluginTaskScheduler, TaskScheduleDefinition, } from '@backstage/backend-tasks'; -import { startTestBackend, mockServices } from '@backstage/backend-test-utils'; +import { + startTestBackend, + mockServices, +} from '@backstage/backend-test-utils/alpha'; import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { Duration } from 'luxon'; diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/run.ts b/plugins/catalog-backend-module-incremental-ingestion/src/run.ts index 745fc70883..c94af368d1 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/run.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/run.ts @@ -19,7 +19,7 @@ import { createServiceFactory, } from '@backstage/backend-plugin-api'; import { ConfigReader } from '@backstage/config'; -import { catalogPlugin } from '@backstage/plugin-catalog-backend'; +import { catalogPlugin } from '@backstage/plugin-catalog-backend/alpha'; import { IncrementalEntityProvider } from '.'; import { incrementalIngestionEntityProviderCatalogModule } from './alpha'; diff --git a/plugins/catalog-backend/src/stitching/Stitcher.ts b/plugins/catalog-backend/src/stitching/Stitcher.ts index bdf9f8791a..38d0fd263f 100644 --- a/plugins/catalog-backend/src/stitching/Stitcher.ts +++ b/plugins/catalog-backend/src/stitching/Stitcher.ts @@ -15,12 +15,11 @@ */ import { ENTITY_STATUS_CATALOG_PROCESSING_TYPE } from '@backstage/catalog-client'; +import { AlphaEntity, EntityStatusItem } from '@backstage/catalog-model/alpha'; import { - AlphaEntity, ANNOTATION_EDIT_URL, ANNOTATION_VIEW_URL, EntityRelation, - EntityStatusItem, } from '@backstage/catalog-model'; import { SerializedError, stringifyError } from '@backstage/errors'; import { Knex } from 'knex'; diff --git a/plugins/catalog-react/src/components/InspectEntityDialog/components/OverviewPage.tsx b/plugins/catalog-react/src/components/InspectEntityDialog/components/OverviewPage.tsx index f0adb878d6..09b944605f 100644 --- a/plugins/catalog-react/src/components/InspectEntityDialog/components/OverviewPage.tsx +++ b/plugins/catalog-react/src/components/InspectEntityDialog/components/OverviewPage.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { AlphaEntity } from '@backstage/catalog-model'; +import { AlphaEntity } from '@backstage/catalog-model/alpha'; import { Box, DialogContentText, diff --git a/plugins/catalog-react/src/filters.test.ts b/plugins/catalog-react/src/filters.test.ts index c2c92e033e..2a67190633 100644 --- a/plugins/catalog-react/src/filters.test.ts +++ b/plugins/catalog-react/src/filters.test.ts @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AlphaEntity, Entity } from '@backstage/catalog-model'; +import { AlphaEntity } from '@backstage/catalog-model/alpha'; +import { Entity } from '@backstage/catalog-model'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; import { EntityErrorFilter, diff --git a/plugins/catalog-react/src/filters.ts b/plugins/catalog-react/src/filters.ts index 056b3b92c1..5bd81780d6 100644 --- a/plugins/catalog-react/src/filters.ts +++ b/plugins/catalog-react/src/filters.ts @@ -14,11 +14,8 @@ * limitations under the License. */ -import { - AlphaEntity, - Entity, - RELATION_OWNED_BY, -} from '@backstage/catalog-model'; +import { Entity, RELATION_OWNED_BY } from '@backstage/catalog-model'; +import { AlphaEntity } from '@backstage/catalog-model/alpha'; import { humanizeEntityRef } from './components/EntityRefLink'; import { EntityFilter, UserListFilterKind } from './types'; import { getEntityRelations } from './utils'; diff --git a/plugins/catalog-react/src/hooks/useEntityPermission.test.tsx b/plugins/catalog-react/src/hooks/useEntityPermission.test.tsx index 766b587da3..aed6676838 100644 --- a/plugins/catalog-react/src/hooks/useEntityPermission.test.tsx +++ b/plugins/catalog-react/src/hooks/useEntityPermission.test.tsx @@ -14,7 +14,7 @@ * limitations under the License. */ -import { catalogEntityDeletePermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityDeletePermission } from '@backstage/plugin-catalog-common/alpha'; import { renderHook } from '@testing-library/react-hooks'; import { useEntityPermission } from './useEntityPermission'; import { useAsyncEntity } from './useEntity'; diff --git a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx index 10f06ca09e..7b92df5809 100644 --- a/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx +++ b/plugins/catalog/src/components/CatalogPage/DefaultCatalogPage.test.tsx @@ -34,9 +34,9 @@ import { MockStarredEntitiesApi, starredEntitiesApiRef, } from '@backstage/plugin-catalog-react'; +import { MockPluginProvider } from '@backstage/test-utils/alpha'; import { mockBreakpoint, - MockPluginProvider, MockStorageApi, renderWithEffects, TestApiProvider, diff --git a/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx index d22f9bde10..675f74fa8d 100644 --- a/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx +++ b/plugins/catalog/src/components/EntityContextMenu/EntityContextMenu.tsx @@ -30,8 +30,8 @@ import MoreVert from '@material-ui/icons/MoreVert'; import FileCopyTwoToneIcon from '@material-ui/icons/FileCopyTwoTone'; import React, { useCallback, useState } from 'react'; import { IconComponent } from '@backstage/core-plugin-api'; -import { useEntityPermission } from '@backstage/plugin-catalog-react'; -import { catalogEntityDeletePermission } from '@backstage/plugin-catalog-common'; +import { useEntityPermission } from '@backstage/plugin-catalog-react/alpha'; +import { catalogEntityDeletePermission } from '@backstage/plugin-catalog-common/alpha'; import { BackstageTheme } from '@backstage/theme'; import { UnregisterEntity, UnregisterEntityOptions } from './UnregisterEntity'; import { useApi, alertApiRef } from '@backstage/core-plugin-api'; diff --git a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx index 350349fe95..b21c6292ff 100644 --- a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx +++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.test.tsx @@ -14,7 +14,8 @@ * limitations under the License. */ -import { AlphaEntity, stringifyEntityRef } from '@backstage/catalog-model'; +import { AlphaEntity } from '@backstage/catalog-model/alpha'; +import { stringifyEntityRef } from '@backstage/catalog-model'; import { ApiProvider } from '@backstage/core-app-api'; import { CatalogApi, diff --git a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx index 2eaf505ec0..ef91e7b26e 100644 --- a/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx +++ b/plugins/catalog/src/components/EntityProcessingErrorsPanel/EntityProcessingErrorsPanel.tsx @@ -14,12 +14,8 @@ * limitations under the License. */ -import { - Entity, - AlphaEntity, - stringifyEntityRef, - EntityStatusItem, -} from '@backstage/catalog-model'; +import { AlphaEntity, EntityStatusItem } from '@backstage/catalog-model/alpha'; +import { Entity, stringifyEntityRef } from '@backstage/catalog-model'; import { catalogApiRef, EntityRefLink, diff --git a/plugins/catalog/src/options.ts b/plugins/catalog/src/options.ts index bb248c16b6..4ea6449a4b 100644 --- a/plugins/catalog/src/options.ts +++ b/plugins/catalog/src/options.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { usePluginOptions } from '@backstage/core-plugin-api'; +import { usePluginOptions } from '@backstage/core-plugin-api/alpha'; export type CatalogPluginOptions = { createButtonTitle: string; diff --git a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx index 0a9451c794..d4fdc66bdb 100644 --- a/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx +++ b/plugins/cost-insights/src/components/CostOverviewCard/CostOverviewCard.test.tsx @@ -15,7 +15,8 @@ */ import React from 'react'; import { fireEvent } from '@testing-library/react'; -import { MockPluginProvider, renderInTestApp } from '@backstage/test-utils'; +import { MockPluginProvider } from '@backstage/test-utils/alpha'; +import { renderInTestApp } from '@backstage/test-utils'; import { CostOverviewCard } from './CostOverviewCard'; import { Cost } from '@backstage/plugin-cost-insights-common'; import { diff --git a/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx b/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx index f288f54e9b..6eb3369b40 100644 --- a/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx +++ b/plugins/cost-insights/src/components/EntityCosts/EntityCost.test.tsx @@ -14,11 +14,8 @@ * limitations under the License. */ import React from 'react'; -import { - MockPluginProvider, - renderInTestApp, - TestApiProvider, -} from '@backstage/test-utils'; +import { MockPluginProvider } from '@backstage/test-utils/alpha'; +import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import { changeOf, MockAggregatedDailyCosts, diff --git a/plugins/cost-insights/src/options.ts b/plugins/cost-insights/src/options.ts index 287935d703..acc977771d 100644 --- a/plugins/cost-insights/src/options.ts +++ b/plugins/cost-insights/src/options.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { usePluginOptions } from '@backstage/core-plugin-api'; +import { usePluginOptions } from '@backstage/core-plugin-api/alpha'; export type CostInsightsPluginOptions = { hideTrendLine?: boolean; diff --git a/plugins/jenkins-common/src/permissions.ts b/plugins/jenkins-common/src/permissions.ts index 5ca5ec6adf..311bf993cc 100644 --- a/plugins/jenkins-common/src/permissions.ts +++ b/plugins/jenkins-common/src/permissions.ts @@ -13,7 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common'; +import { RESOURCE_TYPE_CATALOG_ENTITY } from '@backstage/plugin-catalog-common/alpha'; import { createPermission } from '@backstage/plugin-permission-common'; /** diff --git a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx index 0217f00513..1bb6dbaefc 100644 --- a/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx +++ b/plugins/jenkins/src/components/BuildsPage/lib/CITable/CITable.tsx @@ -15,7 +15,7 @@ */ import { Link, Progress, Table, TableColumn } from '@backstage/core-components'; import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api'; -import { useEntityPermission } from '@backstage/plugin-catalog-react'; +import { useEntityPermission } from '@backstage/plugin-catalog-react/alpha'; import { Box, IconButton, Tooltip, Typography } from '@material-ui/core'; import RetryIcon from '@material-ui/icons/Replay'; import { default as React, useState } from 'react'; diff --git a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts index 852c0f73e2..182bb60223 100644 --- a/plugins/scaffolder-backend/src/ScaffolderPlugin.ts +++ b/plugins/scaffolder-backend/src/ScaffolderPlugin.ts @@ -20,7 +20,7 @@ import { } from '@backstage/backend-plugin-api'; import { loggerToWinstonLogger } from '@backstage/backend-common'; import { ScmIntegrations } from '@backstage/integration'; -import { catalogServiceRef } from '@backstage/plugin-catalog-node'; +import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha'; import { scaffolderActionsExtensionPoint, ScaffolderActionsExtensionPoint, diff --git a/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.test.ts b/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.test.ts index 7652f60386..7b8b99f5e2 100644 --- a/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.test.ts +++ b/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.test.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { ScaffolderEntitiesProcessor } from '../processor'; import { catalogModuleTemplateKind } from './catalogModuleTemplateKind'; import { startTestBackend } from '@backstage/backend-test-utils'; diff --git a/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.ts b/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.ts index 622e5a003a..3359bd1dba 100644 --- a/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.ts +++ b/plugins/scaffolder-backend/src/modules/catalogModuleTemplateKind.ts @@ -15,7 +15,7 @@ */ import { createBackendModule } from '@backstage/backend-plugin-api'; -import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node'; +import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { ScaffolderEntitiesProcessor } from '../processor'; /** diff --git a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx index 50221f3a83..e153c2e232 100644 --- a/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx +++ b/plugins/scaffolder/src/components/ScaffolderPage/ScaffolderPage.tsx @@ -36,7 +36,7 @@ import { import React, { ComponentType } from 'react'; import { TemplateList } from '../TemplateList'; import { TemplateTypePicker } from '../TemplateTypePicker'; -import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha'; import { usePermission } from '@backstage/plugin-permission-react'; import { ScaffolderPageContextMenu } from './ScaffolderPageContextMenu'; import { registerComponentRouteRef } from '../../routes'; diff --git a/plugins/scaffolder/src/next/TemplateListPage/RegisterExistingButton.tsx b/plugins/scaffolder/src/next/TemplateListPage/RegisterExistingButton.tsx index 16e0a355a3..069a2cc6c5 100644 --- a/plugins/scaffolder/src/next/TemplateListPage/RegisterExistingButton.tsx +++ b/plugins/scaffolder/src/next/TemplateListPage/RegisterExistingButton.tsx @@ -21,7 +21,7 @@ import useMediaQuery from '@material-ui/core/useMediaQuery'; import React from 'react'; import { Link as RouterLink, LinkProps } from 'react-router-dom'; import AddCircleOutline from '@material-ui/icons/AddCircleOutline'; -import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha'; import { usePermission } from '@backstage/plugin-permission-react'; /** diff --git a/plugins/sonarqube/dev/index.tsx b/plugins/sonarqube/dev/index.tsx index a34c4d4e82..98c48c56fc 100644 --- a/plugins/sonarqube/dev/index.tsx +++ b/plugins/sonarqube/dev/index.tsx @@ -22,10 +22,10 @@ import { EntitySonarQubeCard, sonarQubePlugin } from '../src'; import { Content, Header, Page } from '@backstage/core-components'; import { FindingSummary, - SONARQUBE_PROJECT_KEY_ANNOTATION, SonarQubeApi, sonarQubeApiRef, -} from '@backstage/plugin-sonarqube-react'; +} from '@backstage/plugin-sonarqube-react/alpha'; +import { SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage/plugin-sonarqube-react'; const entity = (name?: string) => ({ diff --git a/plugins/sonarqube/src/api/SonarQubeClient.test.ts b/plugins/sonarqube/src/api/SonarQubeClient.test.ts index 592f08457f..441263afc8 100644 --- a/plugins/sonarqube/src/api/SonarQubeClient.test.ts +++ b/plugins/sonarqube/src/api/SonarQubeClient.test.ts @@ -21,7 +21,7 @@ import { SonarQubeClient } from './index'; import { InstanceUrlWrapper, FindingsWrapper } from './types'; import { UrlPatternDiscovery } from '@backstage/core-app-api'; import { IdentityApi } from '@backstage/core-plugin-api'; -import { FindingSummary } from '@backstage/plugin-sonarqube-react'; +import { FindingSummary } from '@backstage/plugin-sonarqube-react/alpha'; const server = setupServer(); diff --git a/plugins/sonarqube/src/api/SonarQubeClient.ts b/plugins/sonarqube/src/api/SonarQubeClient.ts index 14c7936e92..94d7a96243 100644 --- a/plugins/sonarqube/src/api/SonarQubeClient.ts +++ b/plugins/sonarqube/src/api/SonarQubeClient.ts @@ -19,7 +19,7 @@ import { FindingSummary, Metrics, SonarQubeApi, -} from '@backstage/plugin-sonarqube-react'; +} from '@backstage/plugin-sonarqube-react/alpha'; import { InstanceUrlWrapper, FindingsWrapper } from './types'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; diff --git a/plugins/sonarqube/src/api/types.ts b/plugins/sonarqube/src/api/types.ts index 470d05903a..f3ad690261 100644 --- a/plugins/sonarqube/src/api/types.ts +++ b/plugins/sonarqube/src/api/types.ts @@ -14,8 +14,10 @@ * limitations under the License. */ -import { MetricKey as NonDeprecatedMetricKey } from '@backstage/plugin-sonarqube-react'; -import { SonarUrlProcessorFunc as NonDeprecatedSonarUrlProcessorFunc } from '@backstage/plugin-sonarqube-react'; +import { + MetricKey as NonDeprecatedMetricKey, + SonarUrlProcessorFunc as NonDeprecatedSonarUrlProcessorFunc, +} from '@backstage/plugin-sonarqube-react/alpha'; export interface InstanceUrlWrapper { instanceUrl: string; diff --git a/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx b/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx index 5bd1cd8e9f..3965c03b69 100644 --- a/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx +++ b/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx @@ -16,10 +16,10 @@ import { useEntity } from '@backstage/plugin-catalog-react'; import { - SONARQUBE_PROJECT_KEY_ANNOTATION, sonarQubeApiRef, useProjectInfo, -} from '@backstage/plugin-sonarqube-react'; +} from '@backstage/plugin-sonarqube-react/alpha'; +import { SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage/plugin-sonarqube-react'; import { Chip, Grid } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; import BugReport from '@material-ui/icons/BugReport'; diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx index 59258e5312..91e85f9f25 100644 --- a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx @@ -18,10 +18,12 @@ import { EntityProvider } from '@backstage/plugin-catalog-react'; import { renderInTestApp, TestApiProvider } from '@backstage/test-utils'; import React from 'react'; import { - isSonarQubeAvailable, - SONARQUBE_PROJECT_KEY_ANNOTATION, SonarQubeApi, sonarQubeApiRef, +} from '@backstage/plugin-sonarqube-react/alpha'; +import { + isSonarQubeAvailable, + SONARQUBE_PROJECT_KEY_ANNOTATION, } from '@backstage/plugin-sonarqube-react'; const Providers = ({ diff --git a/plugins/sonarqube/src/plugin.ts b/plugins/sonarqube/src/plugin.ts index c66d8c4e96..8da690abbf 100644 --- a/plugins/sonarqube/src/plugin.ts +++ b/plugins/sonarqube/src/plugin.ts @@ -22,7 +22,7 @@ import { discoveryApiRef, identityApiRef, } from '@backstage/core-plugin-api'; -import { sonarQubeApiRef } from '@backstage/plugin-sonarqube-react'; +import { sonarQubeApiRef } from '@backstage/plugin-sonarqube-react/alpha'; /** @public */ export const sonarQubePlugin = createPlugin({ diff --git a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts index a76ea66729..86ab9e6cd8 100644 --- a/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts +++ b/plugins/techdocs-backend/src/search/DefaultTechDocsCollator.ts @@ -29,7 +29,7 @@ import unescape from 'lodash/unescape'; import { Logger } from 'winston'; import pLimit from 'p-limit'; import { Config } from '@backstage/config'; -import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha'; import { Permission } from '@backstage/plugin-permission-common'; import { CatalogApi, diff --git a/plugins/techdocs-backend/src/search/DefaultTechDocsCollatorFactory.ts b/plugins/techdocs-backend/src/search/DefaultTechDocsCollatorFactory.ts index aaddb4fa51..e2c6f5913c 100644 --- a/plugins/techdocs-backend/src/search/DefaultTechDocsCollatorFactory.ts +++ b/plugins/techdocs-backend/src/search/DefaultTechDocsCollatorFactory.ts @@ -30,7 +30,7 @@ import { stringifyEntityRef, } from '@backstage/catalog-model'; import { Config } from '@backstage/config'; -import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common'; +import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha'; import { Permission } from '@backstage/plugin-permission-common'; import { DocumentCollatorFactory } from '@backstage/plugin-search-common'; import { TechDocsDocument } from '@backstage/plugin-techdocs-node'; From 8baa40700e6fc4ab89ae9cca1154b44c912e2853 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 09:44:36 +0100 Subject: [PATCH 37/65] scipts/check-docs-quality: update to ignore all api reports Signed-off-by: Patrik Oldsberg --- scripts/check-docs-quality.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/check-docs-quality.js b/scripts/check-docs-quality.js index 3dcbd6ef81..2890f1cf33 100755 --- a/scripts/check-docs-quality.js +++ b/scripts/check-docs-quality.js @@ -21,7 +21,7 @@ const IGNORED = [ /^ADOPTERS\.md$/, /^OWNERS\.md$/, /^.*[/\\]CHANGELOG\.md$/, - /^.*[/\\]api-report\.md$/, + /^.*[/\\]([^\/]+-)?api-report\.md$/, /^docs[/\\]releases[/\\].*-changelog\.md$/, /^docs[/\\]reference[/\\]/, ]; From e3474e5aaf8bce31808b3bd2bca3d1b93ac17c26 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 23:07:10 +0100 Subject: [PATCH 38/65] cli: hardcode build entry point to src/index.ts for non-exports for compatiblity Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/monorepo/entryPoints.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/cli/src/lib/monorepo/entryPoints.ts b/packages/cli/src/lib/monorepo/entryPoints.ts index 8a8bbd27f9..1e1fd7ed27 100644 --- a/packages/cli/src/lib/monorepo/entryPoints.ts +++ b/packages/cli/src/lib/monorepo/entryPoints.ts @@ -24,6 +24,15 @@ export interface EntryPoint { ext: string; } +// Unless explicitly specified in exports, the index entrypoint is always +// assumed to be at src/index.ts for backwards compatibility. +const defaultIndex = { + mount: '.', + path: 'src/index.ts', + name: 'index', + ext: '.ts', +}; + function parseEntryPoint(mount: string, path: string): EntryPoint { let name = mount; if (name === '.') { @@ -41,7 +50,7 @@ function parseEntryPoint(mount: string, path: string): EntryPoint { export function readEntryPoints(pkg: ExtendedPackageJSON): Array { const exp = pkg.exports; if (typeof exp === 'string') { - return [parseEntryPoint('.', exp)]; + return [defaultIndex]; } else if (exp && typeof exp === 'object' && !Array.isArray(exp)) { const entryPoints = new Array<{ mount: string; @@ -64,10 +73,5 @@ export function readEntryPoints(pkg: ExtendedPackageJSON): Array { return entryPoints; } - const main = pkg.main || pkg.module; - if (main) { - return [parseEntryPoint('.', main)]; - } - - return []; + return [defaultIndex]; } From 8da954740eebc1880fb432555a3798587b8b9bed Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 23:26:01 +0100 Subject: [PATCH 39/65] cli: fix production pack compatibility entry point writing Signed-off-by: Patrik Oldsberg --- .../cli/src/lib/packager/productionPack.ts | 60 ++++++++++++------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index 9f11c10222..4580b5981e 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -50,9 +50,10 @@ export async function productionPack(options: ProductionPackOptions) { } // This mutates pkg to fill in index exports, so call it before applying publishConfig - if (pkg.exports) { - await writeExportsEntryPoints(pkg, targetDir ?? packageDir); - } + const writeCompatibilityEntryPoints = await prepareExportsEntryPoints( + pkg, + packageDir, + ); // TODO(Rugvip): Once exports are rolled out more broadly we should deprecate and remove this behavior const publishConfig = pkg.publishConfig ?? {}; @@ -100,6 +101,9 @@ export async function productionPack(options: ProductionPackOptions) { if (publishConfig.betaTypes) { await writeReleaseStageEntrypoint(pkg, 'beta', targetDir ?? packageDir); } + if (writeCompatibilityEntryPoints) { + await writeCompatibilityEntryPoints(targetDir ?? packageDir); + } } // Reverts the changes made by productionPack when called without a targetDir. @@ -166,16 +170,20 @@ const EXPORT_MAP = { /** * Rewrites the exports field in package.json to point to dist files, as - * well as creating backwards compatibility entry points for importers - * that don't support exports. + * well as returning a function that creates backwards compatibility + * entry points for importers that don't support exports. */ -async function writeExportsEntryPoints( +async function prepareExportsEntryPoints( pkg: ExtendedPackageJSON, - targetDir: string, + packageDir: string, ) { - const distFiles = await fs.readdir(resolvePath(targetDir, 'dist')); + const distFiles = await fs.readdir(resolvePath(packageDir, 'dist')); const outputExports = {} as Record>; + const compatibilityWriters = new Array< + (targetDir: string) => Promise + >(); + const entryPoints = readEntryPoints(pkg); for (const entryPoint of entryPoints) { const exp = {} as Record; @@ -199,19 +207,22 @@ async function writeExportsEntryPoints( pkg.types = exp.types; } } else { - const entryPointDir = resolvePath(targetDir, entryPoint.name); - await fs.ensureDir(entryPointDir); - await fs.writeJson( - resolvePath(entryPointDir, PKG_PATH), - { - name: pkg.name, - version: pkg.version, - ...(exp.default ? { main: joinPath('..', exp.default) } : {}), - ...(exp.import ? { module: joinPath('..', exp.import) } : {}), - ...(exp.types ? { types: joinPath('..', exp.types) } : {}), - }, - { encoding: 'utf8', spaces: 2 }, - ); + // This is deferred until after we have created the target directory + compatibilityWriters.push(async targetDir => { + const entryPointDir = resolvePath(targetDir, entryPoint.name); + await fs.ensureDir(entryPointDir); + await fs.writeJson( + resolvePath(entryPointDir, PKG_PATH), + { + name: pkg.name, + version: pkg.version, + ...(exp.default ? { main: joinPath('..', exp.default) } : {}), + ...(exp.import ? { module: joinPath('..', exp.import) } : {}), + ...(exp.types ? { types: joinPath('..', exp.types) } : {}), + }, + { encoding: 'utf8', spaces: 2 }, + ); + }); if (Array.isArray(pkg.files) && !pkg.files.includes(entryPoint.name)) { pkg.files.push(entryPoint.name); } @@ -223,4 +234,11 @@ async function writeExportsEntryPoints( } pkg.exports = outputExports; + + if (compatibilityWriters.length > 0) { + return async (targetDir: string) => { + await Promise.all(compatibilityWriters.map(writer => writer(targetDir))); + }; + } + return undefined; } From b5c1b48d17f8afce96e471017eee8c29cd7202d8 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 23:26:45 +0100 Subject: [PATCH 40/65] cli: trim typesVersions from published packages Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/packager/productionPack.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index 4580b5981e..d78583d955 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -63,6 +63,9 @@ export async function productionPack(options: ProductionPackOptions) { } } + // For published packages we rely on compatibility entry points rather than this + delete pkg.typesVersions; + // We remove the dependencies from package.json of packages that are marked // as bundled, so that yarn doesn't try to install them. if (pkg.bundled) { From 8a3d8ecde05134782b5b9b4bf1c56a64d5495ee3 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 23:32:20 +0100 Subject: [PATCH 41/65] cli: make migrate package-exports add ./package.json Signed-off-by: Patrik Oldsberg --- .../src/commands/migrate/packageExports.ts | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/commands/migrate/packageExports.ts b/packages/cli/src/commands/migrate/packageExports.ts index 754a25e32b..9d5c6d6339 100644 --- a/packages/cli/src/commands/migrate/packageExports.ts +++ b/packages/cli/src/commands/migrate/packageExports.ts @@ -30,14 +30,31 @@ export async function command() { await Promise.all( packages.map(async ({ dir, packageJson }) => { - const { exports: exp } = packageJson; - if (!exp || typeof exp !== 'object' || Array.isArray(exp)) { + let { exports: exp } = packageJson; + if (!exp) { return; } + if (Array.isArray(exp)) { + throw new Error('Unexpected array in package.json exports field'); + } let changed = false; let newPackageJson = packageJson; + // If exports is a string we rewrite it to an object to add package.json + if (typeof exp === 'string') { + changed = true; + exp = { '.': exp }; + newPackageJson.exports = exp; + } else if (typeof exp !== 'object') { + return; + } + + if (!exp['./package.json']) { + changed = true; + exp['./package.json'] = './package.json'; + } + const existingTypesVersions = JSON.stringify(packageJson.typesVersions); const typeEntries: Record = {}; From c523edfc8819bbb85885e16abe8a2ffddef99a4a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 17 Jan 2023 23:41:42 +0100 Subject: [PATCH 42/65] migrate all packages to export package.json Signed-off-by: Patrik Oldsberg --- packages/backend-common/package.json | 6 +++++- packages/backend-test-utils/package.json | 6 +++++- packages/catalog-model/package.json | 6 +++++- packages/core-plugin-api/package.json | 6 +++++- packages/test-utils/package.json | 6 +++++- plugins/app-backend/package.json | 6 +++++- plugins/catalog-backend-module-aws/package.json | 6 +++++- plugins/catalog-backend-module-azure/package.json | 6 +++++- plugins/catalog-backend-module-bitbucket-cloud/package.json | 6 +++++- .../catalog-backend-module-bitbucket-server/package.json | 6 +++++- plugins/catalog-backend-module-gerrit/package.json | 6 +++++- plugins/catalog-backend-module-github/package.json | 6 +++++- plugins/catalog-backend-module-gitlab/package.json | 6 +++++- .../package.json | 6 +++++- plugins/catalog-backend-module-msgraph/package.json | 6 +++++- plugins/catalog-backend/package.json | 6 +++++- plugins/catalog-common/package.json | 6 +++++- plugins/catalog-node/package.json | 6 +++++- plugins/catalog-react/package.json | 6 +++++- plugins/events-backend-module-aws-sqs/package.json | 6 +++++- plugins/events-backend-module-azure/package.json | 6 +++++- plugins/events-backend-module-bitbucket-cloud/package.json | 6 +++++- plugins/events-backend-module-gerrit/package.json | 6 +++++- plugins/events-backend-module-github/package.json | 6 +++++- plugins/events-backend-module-gitlab/package.json | 6 +++++- plugins/events-backend/package.json | 6 +++++- plugins/events-node/package.json | 6 +++++- plugins/scaffolder-backend/package.json | 6 +++++- plugins/scaffolder-react/package.json | 6 +++++- plugins/scaffolder/package.json | 6 +++++- plugins/sonarqube-react/package.json | 6 +++++- 31 files changed, 155 insertions(+), 31 deletions(-) diff --git a/packages/backend-common/package.json b/packages/backend-common/package.json index e778e6830c..71f800dff8 100644 --- a/packages/backend-common/package.json +++ b/packages/backend-common/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/packages/backend-test-utils/package.json b/packages/backend-test-utils/package.json index 6330b161e1..7e14963aab 100644 --- a/packages/backend-test-utils/package.json +++ b/packages/backend-test-utils/package.json @@ -8,12 +8,16 @@ "access": "public" }, "exports": { - ".": "./src/index.ts" + ".": "./src/index.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { "*": [ "src/index.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/packages/catalog-model/package.json b/packages/catalog-model/package.json index b07e2df915..2d569053b1 100644 --- a/packages/catalog-model/package.json +++ b/packages/catalog-model/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/packages/core-plugin-api/package.json b/packages/core-plugin-api/package.json index e01c99f384..781ebe37e1 100644 --- a/packages/core-plugin-api/package.json +++ b/packages/core-plugin-api/package.json @@ -7,7 +7,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -16,6 +17,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index 4148f62a3f..b278b00c14 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -7,7 +7,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -16,6 +17,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/app-backend/package.json b/plugins/app-backend/package.json index d52ab37abe..78070cbf14 100644 --- a/plugins/app-backend/package.json +++ b/plugins/app-backend/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-aws/package.json b/plugins/catalog-backend-module-aws/package.json index c309ee995e..0273326e36 100644 --- a/plugins/catalog-backend-module-aws/package.json +++ b/plugins/catalog-backend-module-aws/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-azure/package.json b/plugins/catalog-backend-module-azure/package.json index b68015cb87..dd89aec185 100644 --- a/plugins/catalog-backend-module-azure/package.json +++ b/plugins/catalog-backend-module-azure/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-bitbucket-cloud/package.json b/plugins/catalog-backend-module-bitbucket-cloud/package.json index 9f2243b0cd..8fbff7d79b 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/package.json +++ b/plugins/catalog-backend-module-bitbucket-cloud/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-bitbucket-server/package.json b/plugins/catalog-backend-module-bitbucket-server/package.json index d11b9136e6..1a82807288 100644 --- a/plugins/catalog-backend-module-bitbucket-server/package.json +++ b/plugins/catalog-backend-module-bitbucket-server/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-gerrit/package.json b/plugins/catalog-backend-module-gerrit/package.json index 23d2db3073..33fcc4abcb 100644 --- a/plugins/catalog-backend-module-gerrit/package.json +++ b/plugins/catalog-backend-module-gerrit/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-github/package.json b/plugins/catalog-backend-module-github/package.json index 6ef4fea0c7..a5899ced33 100644 --- a/plugins/catalog-backend-module-github/package.json +++ b/plugins/catalog-backend-module-github/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-gitlab/package.json b/plugins/catalog-backend-module-gitlab/package.json index a53da3a97f..8d1ec70123 100644 --- a/plugins/catalog-backend-module-gitlab/package.json +++ b/plugins/catalog-backend-module-gitlab/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-incremental-ingestion/package.json b/plugins/catalog-backend-module-incremental-ingestion/package.json index 8cc1ebbf8e..9479fd88e0 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/package.json +++ b/plugins/catalog-backend-module-incremental-ingestion/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend-module-msgraph/package.json b/plugins/catalog-backend-module-msgraph/package.json index e1d0ede5fc..99e5b0da35 100644 --- a/plugins/catalog-backend-module-msgraph/package.json +++ b/plugins/catalog-backend-module-msgraph/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-backend/package.json b/plugins/catalog-backend/package.json index 468cc13b34..47e678c012 100644 --- a/plugins/catalog-backend/package.json +++ b/plugins/catalog-backend/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index 55680e679c..2c74307f1c 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index d949bfaabb..7d186ad52c 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json index 0ca4e3c9e4..955e63b425 100644 --- a/plugins/catalog-react/package.json +++ b/plugins/catalog-react/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend-module-aws-sqs/package.json b/plugins/events-backend-module-aws-sqs/package.json index 19aec3108a..d68c77bb41 100644 --- a/plugins/events-backend-module-aws-sqs/package.json +++ b/plugins/events-backend-module-aws-sqs/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend-module-azure/package.json b/plugins/events-backend-module-azure/package.json index 540a2c700f..a1314b2db7 100644 --- a/plugins/events-backend-module-azure/package.json +++ b/plugins/events-backend-module-azure/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend-module-bitbucket-cloud/package.json b/plugins/events-backend-module-bitbucket-cloud/package.json index c377088b62..db85c32fad 100644 --- a/plugins/events-backend-module-bitbucket-cloud/package.json +++ b/plugins/events-backend-module-bitbucket-cloud/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend-module-gerrit/package.json b/plugins/events-backend-module-gerrit/package.json index 5fe093893c..35a82b4fc5 100644 --- a/plugins/events-backend-module-gerrit/package.json +++ b/plugins/events-backend-module-gerrit/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend-module-github/package.json b/plugins/events-backend-module-github/package.json index 3145ee9e66..7a7df507b7 100644 --- a/plugins/events-backend-module-github/package.json +++ b/plugins/events-backend-module-github/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend-module-gitlab/package.json b/plugins/events-backend-module-gitlab/package.json index be5ffc2318..f95995473c 100644 --- a/plugins/events-backend-module-gitlab/package.json +++ b/plugins/events-backend-module-gitlab/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-backend/package.json b/plugins/events-backend/package.json index 4534dac9de..a0d4f9bf12 100644 --- a/plugins/events-backend/package.json +++ b/plugins/events-backend/package.json @@ -9,7 +9,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -18,6 +19,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/events-node/package.json b/plugins/events-node/package.json index 060e450289..ef0cce170e 100644 --- a/plugins/events-node/package.json +++ b/plugins/events-node/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index 3eda8bd678..9ee87669ff 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/scaffolder-react/package.json b/plugins/scaffolder-react/package.json index 4a4d94debf..6907f8080e 100644 --- a/plugins/scaffolder-react/package.json +++ b/plugins/scaffolder-react/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json index b4fb81fb9c..46e8f436fd 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -10,7 +10,8 @@ }, "exports": { ".": "./src/index.ts", - "./alpha": "./src/alpha.ts" + "./alpha": "./src/alpha.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { @@ -19,6 +20,9 @@ ], "alpha": [ "src/alpha.ts" + ], + "package.json": [ + "package.json" ] } }, diff --git a/plugins/sonarqube-react/package.json b/plugins/sonarqube-react/package.json index f473d52f16..2f31d37007 100644 --- a/plugins/sonarqube-react/package.json +++ b/plugins/sonarqube-react/package.json @@ -8,12 +8,16 @@ "access": "public" }, "exports": { - ".": "./src/index.ts" + ".": "./src/index.ts", + "./package.json": "./package.json" }, "typesVersions": { "*": { "*": [ "src/index.ts" + ], + "package.json": [ + "package.json" ] } }, From e47f4994036db489a8e955f6f77ee910a94b7f26 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 00:41:55 +0100 Subject: [PATCH 43/65] cli: ignore package.json entry point Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/packager/productionPack.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index d78583d955..adcab2b90c 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -24,6 +24,7 @@ const PKG_PATH = 'package.json'; const PKG_BACKUP_PATH = 'package.json-prepack'; const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes']; +const SCRIPT_EXTS = ['.js', '.jsx', '.ts', '.tsx']; interface ProductionPackOptions { packageDir: string; @@ -189,6 +190,9 @@ async function prepareExportsEntryPoints( const entryPoints = readEntryPoints(pkg); for (const entryPoint of entryPoints) { + if (!SCRIPT_EXTS.includes(entryPoint.ext)) { + continue; + } const exp = {} as Record; for (const [key, ext] of Object.entries(EXPORT_MAP)) { const name = `${entryPoint.name}${ext}`; From 3e63951e49067aed8019487ff0c5c6aa80046043 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 00:43:27 +0100 Subject: [PATCH 44/65] prefer subpath over sub-path Signed-off-by: Patrik Oldsberg --- docs/local-dev/cli-build-system.md | 8 ++++---- packages/cli/src/commands/index.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/local-dev/cli-build-system.md b/docs/local-dev/cli-build-system.md index a784e0eff9..2eb695e3a3 100644 --- a/docs/local-dev/cli-build-system.md +++ b/docs/local-dev/cli-build-system.md @@ -650,9 +650,9 @@ The following is an excerpt of a typical setup of an isomorphic library package: "files": ["dist"], ``` -## Sub-path Exports +## Subpath Exports -The Backstage CLI supports implementation of sub-path exports through the `"exports"` field in `package.json`. It might for example look like this: +The Backstage CLI supports implementation of subpath exports through the `"exports"` field in `package.json`. It might for example look like this: ```json "name": "@backstage/plugin-foo", @@ -668,7 +668,7 @@ As with the rest of the Backstage CLI build system, the setup is optimized for l TypeScript support is currently handled though the `typesVersions` field, as there is not yet a module resolution mode that works well with `"exports"`. You can craft the `typesVersions` yourself, but it will also be automatically generated by the `migrate package-exports` command. -To add sub-path exports to an existing package, simply add the desired `"exports"` fields and then run the following command: +To add subpath exports to an existing package, simply add the desired `"exports"` fields and then run the following command: ```bash yarn backstage-cli package migrate package-exports @@ -676,7 +676,7 @@ yarn backstage-cli package migrate package-exports ## Experimental Type Build -> Note: Experimental type builds are deprecated and will be removed in the future. They have been replaced by [sub-path exports](#sub-path-exports). +> Note: Experimental type builds are deprecated and will be removed in the future. They have been replaced by [subpath exports](#subpath-exports). The Backstage CLI has an experimental feature where multiple different type definition files can be generated for different release stages. The release stages are marked in the [TSDoc](https://tsdoc.org/) for each individual export, using either `@public`, `@alpha`, or `@beta`. Rather than just building a single `index.d.ts` file, the build process will instead output `index.d.ts`, `index.beta.d.ts`, and `index.alpha.d.ts`. Each of these files will have exports from more unstable release stages stripped, meaning that `index.d.ts` will omit all exports marked with `@alpha` or `@beta`, while `index.beta.d.ts` will omit all exports marked with `@alpha`. diff --git a/packages/cli/src/commands/index.ts b/packages/cli/src/commands/index.ts index 3eb511e06d..ddec5c6a4a 100644 --- a/packages/cli/src/commands/index.ts +++ b/packages/cli/src/commands/index.ts @@ -193,7 +193,7 @@ export function registerMigrateCommand(program: Command) { command .command('package-exports') - .description('Synchronize package sub-path export definitions') + .description('Synchronize package subpath export definitions') .action( lazy(() => import('./migrate/packageExports').then(m => m.command)), ); From 32a4a05838c523bd0fb55de9341268d6c9ebe17b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 01:02:06 +0100 Subject: [PATCH 45/65] repo-tools: work around /* type imports Signed-off-by: Patrik Oldsberg --- .changeset/curvy-pets-hang.md | 5 +++++ packages/repo-tools/src/commands/type-deps/type-deps.ts | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/curvy-pets-hang.md diff --git a/.changeset/curvy-pets-hang.md b/.changeset/curvy-pets-hang.md new file mode 100644 index 0000000000..3a2d11ac12 --- /dev/null +++ b/.changeset/curvy-pets-hang.md @@ -0,0 +1,5 @@ +--- +'@backstage/repo-tools': patch +--- + +Tweaked type dependency check to trim wildcard type imports. diff --git a/packages/repo-tools/src/commands/type-deps/type-deps.ts b/packages/repo-tools/src/commands/type-deps/type-deps.ts index 4f8e5e5529..0ad9a5cfc8 100644 --- a/packages/repo-tools/src/commands/type-deps/type-deps.ts +++ b/packages/repo-tools/src/commands/type-deps/type-deps.ts @@ -105,7 +105,10 @@ function checkTypes(pkg: Package) { const errors = []; const typeDeps = []; - for (const dep of deps) { + for (let dep of deps) { + if (dep.endsWith('/*')) { + dep = dep.slice(0, -2); + } try { const typeDep = findTypesPackage(dep, pkg); if (typeDep) { From 928a12a9b3e035c722fa73784507037c21c7bd7a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 01:03:43 +0100 Subject: [PATCH 46/65] changesets: add changeset for alpha exports refactor Signed-off-by: Patrik Oldsberg --- .changeset/rare-grapes-count.md | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 .changeset/rare-grapes-count.md diff --git a/.changeset/rare-grapes-count.md b/.changeset/rare-grapes-count.md new file mode 100644 index 0000000000..fdeb653f3c --- /dev/null +++ b/.changeset/rare-grapes-count.md @@ -0,0 +1,45 @@ +--- +'@backstage/plugin-catalog-backend-module-incremental-ingestion': patch +'@backstage/plugin-catalog-backend-module-bitbucket-server': patch +'@backstage/plugin-catalog-backend-module-bitbucket-cloud': patch +'@backstage/plugin-events-backend-module-bitbucket-cloud': patch +'@backstage/plugin-catalog-backend-module-msgraph': patch +'@backstage/plugin-catalog-backend-module-gerrit': patch +'@backstage/plugin-catalog-backend-module-github': patch +'@backstage/plugin-catalog-backend-module-gitlab': patch +'@backstage/plugin-events-backend-module-aws-sqs': patch +'@backstage/plugin-catalog-backend-module-azure': patch +'@backstage/plugin-events-backend-module-gerrit': patch +'@backstage/plugin-events-backend-module-github': patch +'@backstage/plugin-events-backend-module-gitlab': patch +'@backstage/plugin-events-backend-module-azure': patch +'@backstage/plugin-catalog-backend-module-aws': patch +'@backstage/backend-plugin-api': patch +'@backstage/backend-test-utils': patch +'@backstage/plugin-scaffolder-backend': patch +'@backstage/backend-defaults': patch +'@backstage/backend-app-api': patch +'@backstage/core-plugin-api': patch +'@backstage/plugin-scaffolder-react': patch +'@backstage/plugin-techdocs-backend': patch +'@backstage/backend-common': patch +'@backstage/plugin-catalog-backend': patch +'@backstage/plugin-sonarqube-react': patch +'@backstage/catalog-model': patch +'@backstage/plugin-catalog-common': patch +'@backstage/plugin-events-backend': patch +'@backstage/plugin-jenkins-common': patch +'@backstage/plugin-techdocs-react': patch +'@backstage/plugin-catalog-react': patch +'@backstage/plugin-cost-insights': patch +'@backstage/plugin-catalog-node': patch +'@backstage/test-utils': patch +'@backstage/plugin-app-backend': patch +'@backstage/plugin-events-node': patch +'@backstage/plugin-scaffolder': patch +'@backstage/plugin-sonarqube': patch +'@backstage/plugin-catalog': patch +'@backstage/plugin-jenkins': patch +--- + +Internal refactor of `/alpha` exports. From 69f67093c4c632588b82d1764069ad03d7553e76 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 01:24:09 +0100 Subject: [PATCH 47/65] cli: add missing publishConfig types Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/monorepo/PackageGraph.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/packages/cli/src/lib/monorepo/PackageGraph.ts b/packages/cli/src/lib/monorepo/PackageGraph.ts index 7bca16a6f7..bb203c01a5 100644 --- a/packages/cli/src/lib/monorepo/PackageGraph.ts +++ b/packages/cli/src/lib/monorepo/PackageGraph.ts @@ -44,6 +44,14 @@ export interface ExtendedPackageJSON extends PackageJSON { typesVersions?: Record>; files?: string[]; + + publishConfig?: { + access?: 'public' | 'restricted'; + directory?: string; + registry?: string; + alphaTypes?: string; + betaTypes?: string; + }; } export type ExtendedPackage = { From 5b2ddbc812dc1a77a17e21e551be4e112d48212f Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 11:11:45 +0100 Subject: [PATCH 48/65] scaffolder: fix TemplateGroups mock Signed-off-by: Patrik Oldsberg --- .../src/next/TemplateListPage/TemplateGroups.test.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx b/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx index 19a9728f37..6fe2d6beb9 100644 --- a/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx +++ b/plugins/scaffolder/src/next/TemplateListPage/TemplateGroups.test.tsx @@ -18,7 +18,7 @@ jest.mock('@backstage/plugin-catalog-react', () => ({ useEntityList: jest.fn(), })); -jest.mock('@backstage/plugin-scaffolder-react', () => ({ +jest.mock('@backstage/plugin-scaffolder-react/alpha', () => ({ TemplateGroup: jest.fn(() => null), })); From 258643e6129c436098e88f15f3e55f251a833453 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 11:32:18 +0100 Subject: [PATCH 49/65] repo-tools: ignore non-ts entry points in extractor Signed-off-by: Patrik Oldsberg --- .../src/commands/api-reports/api-extractor.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index c05fd0a01e..6ab712cf5e 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -19,6 +19,7 @@ import { relative as relativePath, basename, join, + extname, } from 'path'; import { execFile } from 'child_process'; import fs from 'fs-extra'; @@ -309,15 +310,19 @@ async function findPackageEntryPoints( ); if (pkg.exports && typeof pkg.exports !== 'string') { - return Object.keys(pkg.exports).map(mount => { + return Object.entries(pkg.exports).flatMap(([mount, path]) => { + const ext = extname(String(path)); + if (!['.ts', '.tsx', '.cts', '.mts'].includes(ext)) { + return []; // Ignore non-TS entry points + } let name = mount; if (name.startsWith('./')) { name = name.slice(2); } if (!name || name === '.') { - return { packageDir, name: 'index' }; + return [{ packageDir, name: 'index' }]; } - return { packageDir, name }; + return [{ packageDir, name }]; }); } From 08d37cf1cc6a8029cbf1632033813884d4bdfec4 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 21:42:28 +0100 Subject: [PATCH 50/65] catalog-model: fix alpha API report warnings Signed-off-by: Patrik Oldsberg --- packages/catalog-model/alpha-api-report.md | 5 +---- packages/catalog-model/src/entity/AlphaEntity.ts | 6 ++++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/catalog-model/alpha-api-report.md b/packages/catalog-model/alpha-api-report.md index 639cba1fef..5b962a7403 100644 --- a/packages/catalog-model/alpha-api-report.md +++ b/packages/catalog-model/alpha-api-report.md @@ -3,12 +3,9 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { JsonObject } from '@backstage/types'; +import { Entity } from '@backstage/catalog-model'; import { SerializedError } from '@backstage/errors'; -// Warning: (ae-forgotten-export) The symbol "Entity" needs to be exported by the entry point alpha.d.ts -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/catalog-model" does not have an export "Entity" -// // @alpha export interface AlphaEntity extends Entity { status?: EntityStatus; diff --git a/packages/catalog-model/src/entity/AlphaEntity.ts b/packages/catalog-model/src/entity/AlphaEntity.ts index 57a1954f52..6f5c9d4fa7 100644 --- a/packages/catalog-model/src/entity/AlphaEntity.ts +++ b/packages/catalog-model/src/entity/AlphaEntity.ts @@ -14,11 +14,13 @@ * limitations under the License. */ -import { Entity } from './Entity'; +// TODO(Rugvip): Figure out best way to allow this import +// eslint-disable-next-line import/no-extraneous-dependencies +import { Entity } from '@backstage/catalog-model'; import { EntityStatus } from './EntityStatus'; /** - * A version of the {@link Entity} type that contains unstable alpha fields. + * A version of the `Entity` type that contains unstable alpha fields. * * @remarks * From ea99ce2c37b0f7af5e1ccac73195248f5d88bd39 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 18 Jan 2023 21:47:46 +0100 Subject: [PATCH 51/65] cli: bit of reafactor for clarity in packageExports Signed-off-by: Patrik Oldsberg --- packages/cli/src/commands/migrate/packageExports.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/cli/src/commands/migrate/packageExports.ts b/packages/cli/src/commands/migrate/packageExports.ts index 9d5c6d6339..51dc5c38bd 100644 --- a/packages/cli/src/commands/migrate/packageExports.ts +++ b/packages/cli/src/commands/migrate/packageExports.ts @@ -30,7 +30,10 @@ export async function command() { await Promise.all( packages.map(async ({ dir, packageJson }) => { - let { exports: exp } = packageJson; + let changed = false; + let newPackageJson = packageJson; + + let { exports: exp } = newPackageJson; if (!exp) { return; } @@ -38,9 +41,6 @@ export async function command() { throw new Error('Unexpected array in package.json exports field'); } - let changed = false; - let newPackageJson = packageJson; - // If exports is a string we rewrite it to an object to add package.json if (typeof exp === 'string') { changed = true; From eb9252186fb5a237eb389df716bc5094e54b9acc Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 2 Feb 2023 14:56:09 +0100 Subject: [PATCH 52/65] permission-node,kubernetes-backend: mark public API as public Signed-off-by: Patrik Oldsberg --- .../AwsIamKubernetesAuthTranslator.ts | 4 +- .../AzureIdentityKubernetesAuthTranslator.ts | 2 +- .../GoogleKubernetesAuthTranslator.ts | 2 +- .../GoogleServiceAccountAuthProvider.ts | 2 +- .../KubernetesAuthTranslatorGenerator.ts | 2 +- .../NoopKubernetesAuthTranslator.ts | 2 +- .../OidcKubernetesAuthTranslator.ts | 2 +- .../src/kubernetes-auth-translator/types.ts | 2 +- .../src/service/KubernetesBuilder.ts | 6 +-- .../src/service/KubernetesFanOutHandler.ts | 2 +- .../src/service/KubernetesProxy.ts | 2 +- .../kubernetes-backend/src/service/router.ts | 4 +- plugins/kubernetes-backend/src/types/types.ts | 40 +++++++++---------- .../permission-node/src/integration/util.ts | 6 +-- 14 files changed, 39 insertions(+), 39 deletions(-) diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/AwsIamKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/AwsIamKubernetesAuthTranslator.ts index ccb0f28109..b89945902d 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/AwsIamKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/AwsIamKubernetesAuthTranslator.ts @@ -20,7 +20,7 @@ import { KubernetesAuthTranslator } from './types'; /** * - * @alpha + * @public */ export type SigningCreds = { accessKeyId: string | undefined; @@ -30,7 +30,7 @@ export type SigningCreds = { /** * - * @alpha + * @public */ export class AwsIamKubernetesAuthTranslator implements KubernetesAuthTranslator diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts index 6b1f2281c4..2633598d6c 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/AzureIdentityKubernetesAuthTranslator.ts @@ -27,7 +27,7 @@ const aksScope = '6dae42f8-4368-4678-94ff-3960e28e3630/.default'; // This scope /** * - * @alpha + * @public */ export class AzureIdentityKubernetesAuthTranslator implements KubernetesAuthTranslator diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts index cabf66b40b..e8dae56997 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleKubernetesAuthTranslator.ts @@ -20,7 +20,7 @@ import { KubernetesRequestAuth } from '@backstage/plugin-kubernetes-common'; /** * - * @alpha + * @public */ export class GoogleKubernetesAuthTranslator implements KubernetesAuthTranslator diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts index 1eca62b363..cca510ad6c 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/GoogleServiceAccountAuthProvider.ts @@ -19,7 +19,7 @@ import * as container from '@google-cloud/container'; /** * - * @alpha + * @public */ export class GoogleServiceAccountAuthTranslator implements KubernetesAuthTranslator diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/KubernetesAuthTranslatorGenerator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/KubernetesAuthTranslatorGenerator.ts index d4eed29653..f54e46efab 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/KubernetesAuthTranslatorGenerator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/KubernetesAuthTranslatorGenerator.ts @@ -25,7 +25,7 @@ import { OidcKubernetesAuthTranslator } from './OidcKubernetesAuthTranslator'; /** * - * @alpha + * @public */ export class KubernetesAuthTranslatorGenerator { static getKubernetesAuthTranslatorInstance( diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/NoopKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/NoopKubernetesAuthTranslator.ts index 2ef78495a1..32aa141e50 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/NoopKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/NoopKubernetesAuthTranslator.ts @@ -19,7 +19,7 @@ import { ServiceAccountClusterDetails } from '../types/types'; /** * - * @alpha + * @public */ export class NoopKubernetesAuthTranslator implements KubernetesAuthTranslator { async decorateClusterDetailsWithAuth( diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/OidcKubernetesAuthTranslator.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/OidcKubernetesAuthTranslator.ts index e5450b2fe1..cee1ec1e0c 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/OidcKubernetesAuthTranslator.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/OidcKubernetesAuthTranslator.ts @@ -20,7 +20,7 @@ import { KubernetesRequestAuth } from '@backstage/plugin-kubernetes-common'; /** * - * @alpha + * @public */ export class OidcKubernetesAuthTranslator implements KubernetesAuthTranslator { async decorateClusterDetailsWithAuth( diff --git a/plugins/kubernetes-backend/src/kubernetes-auth-translator/types.ts b/plugins/kubernetes-backend/src/kubernetes-auth-translator/types.ts index f8417f8468..efbbff8250 100644 --- a/plugins/kubernetes-backend/src/kubernetes-auth-translator/types.ts +++ b/plugins/kubernetes-backend/src/kubernetes-auth-translator/types.ts @@ -19,7 +19,7 @@ import { KubernetesRequestAuth } from '@backstage/plugin-kubernetes-common'; /** * - * @alpha + * @public */ export interface KubernetesAuthTranslator { decorateClusterDetailsWithAuth( diff --git a/plugins/kubernetes-backend/src/service/KubernetesBuilder.ts b/plugins/kubernetes-backend/src/service/KubernetesBuilder.ts index 92773ece6d..74ec9eada2 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesBuilder.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesBuilder.ts @@ -43,7 +43,7 @@ import { KubernetesProxy } from './KubernetesProxy'; /** * - * @alpha + * @public */ export interface KubernetesEnvironment { logger: Logger; @@ -54,7 +54,7 @@ export interface KubernetesEnvironment { /** * The return type of the `KubernetesBuilder.build` method * - * @alpha + * @public */ export type KubernetesBuilderReturn = Promise<{ router: express.Router; @@ -68,7 +68,7 @@ export type KubernetesBuilderReturn = Promise<{ /** * - * @alpha + * @public */ export class KubernetesBuilder { private clusterSupplier?: KubernetesClustersSupplier; diff --git a/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts b/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts index a738c69bcc..63e46a44e3 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts @@ -51,7 +51,7 @@ import { /** * - * @alpha + * @public */ export const DEFAULT_OBJECTS: ObjectToFetch[] = [ { diff --git a/plugins/kubernetes-backend/src/service/KubernetesProxy.ts b/plugins/kubernetes-backend/src/service/KubernetesProxy.ts index cb36c647ac..178105ef79 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesProxy.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesProxy.ts @@ -39,7 +39,7 @@ export const HEADER_KUBERNETES_CLUSTER: string = 'X-Kubernetes-Cluster'; /** * A proxy that routes requests to the Kubernetes API. * - * @alpha + * @public */ export class KubernetesProxy { private readonly middlewareForClusterName = new Map(); diff --git a/plugins/kubernetes-backend/src/service/router.ts b/plugins/kubernetes-backend/src/service/router.ts index ab27a75a18..341956553e 100644 --- a/plugins/kubernetes-backend/src/service/router.ts +++ b/plugins/kubernetes-backend/src/service/router.ts @@ -24,7 +24,7 @@ import { CatalogApi } from '@backstage/catalog-client'; /** * - * @alpha + * @public */ export interface RouterOptions { logger: Logger; @@ -47,7 +47,7 @@ export interface RouterOptions { * }).build(); * ``` * - * @alpha + * @public */ export async function createRouter( options: RouterOptions, diff --git a/plugins/kubernetes-backend/src/types/types.ts b/plugins/kubernetes-backend/src/types/types.ts index d76bfc8149..25c7abfd1f 100644 --- a/plugins/kubernetes-backend/src/types/types.ts +++ b/plugins/kubernetes-backend/src/types/types.ts @@ -28,7 +28,7 @@ import type { /** * - * @alpha + * @public */ export interface ObjectFetchParams { serviceId: string; @@ -46,7 +46,7 @@ export interface ObjectFetchParams { /** * Fetches information from a kubernetes cluster using the cluster details object to target a specific cluster * - * @alpha + * @public */ export interface KubernetesFetcher { fetchObjectsForService( @@ -60,7 +60,7 @@ export interface KubernetesFetcher { /** * - * @alpha + * @public */ export interface FetchResponseWrapper { errors: KubernetesFetchError[]; @@ -69,7 +69,7 @@ export interface FetchResponseWrapper { /** * - * @alpha + * @public */ export interface ObjectToFetch { objectType: KubernetesObjectTypes; @@ -80,7 +80,7 @@ export interface ObjectToFetch { /** * - * @alpha + * @public */ export interface CustomResource extends ObjectToFetch { objectType: 'customresources'; @@ -88,7 +88,7 @@ export interface CustomResource extends ObjectToFetch { /** * - * @alpha + * @public */ export type KubernetesObjectTypes = | 'pods' @@ -107,7 +107,7 @@ export type KubernetesObjectTypes = /** * Used to load cluster details from different sources - * @alpha + * @public */ export interface KubernetesClustersSupplier { /** @@ -120,7 +120,7 @@ export interface KubernetesClustersSupplier { } /** - * @alpha + * @public */ export interface ServiceLocatorRequestContext { objectTypesToFetch: Set; @@ -129,7 +129,7 @@ export interface ServiceLocatorRequestContext { /** * Used to locate which cluster(s) a service is running on - * @alpha + * @public */ export interface KubernetesServiceLocator { getClustersByEntity( @@ -140,13 +140,13 @@ export interface KubernetesServiceLocator { /** * - * @alpha + * @public */ export type ServiceLocatorMethod = 'multiTenant' | 'http'; // TODO implement http /** * - * @alpha + * @public */ export interface ClusterDetails { /** @@ -209,25 +209,25 @@ export interface ClusterDetails { /** * - * @alpha + * @public */ export interface GKEClusterDetails extends ClusterDetails {} /** * - * @alpha + * @public */ export interface AzureClusterDetails extends ClusterDetails {} /** * - * @alpha + * @public */ export interface ServiceAccountClusterDetails extends ClusterDetails {} /** * - * @alpha + * @public */ export interface AWSClusterDetails extends ClusterDetails { assumeRole?: string; @@ -236,7 +236,7 @@ export interface AWSClusterDetails extends ClusterDetails { /** * - * @alpha + * @public */ export interface KubernetesObjectsProviderOptions { logger: Logger; @@ -248,13 +248,13 @@ export interface KubernetesObjectsProviderOptions { /** * - * @alpha + * @public */ export type ObjectsByEntityRequest = KubernetesRequestBody; /** * - * @alpha + * @public */ export interface KubernetesObjectsByEntity { entity: Entity; @@ -263,7 +263,7 @@ export interface KubernetesObjectsByEntity { /** * - * @alpha + * @public */ export interface CustomResourcesByEntity extends KubernetesObjectsByEntity { customResources: CustomResourceMatcher[]; @@ -271,7 +271,7 @@ export interface CustomResourcesByEntity extends KubernetesObjectsByEntity { /** * - * @alpha + * @public */ export interface KubernetesObjectsProvider { getKubernetesObjectsByEntity( diff --git a/plugins/permission-node/src/integration/util.ts b/plugins/permission-node/src/integration/util.ts index e448068e17..9be90e15fc 100644 --- a/plugins/permission-node/src/integration/util.ts +++ b/plugins/permission-node/src/integration/util.ts @@ -33,7 +33,7 @@ export type NoInfer = T extends infer S ? S : never; /** * Utility function used to parse a PermissionCriteria * @param criteria - a PermissionCriteria - * @alpha + * @public * * @returns `true` if the permission criteria is of type allOf, * narrowing down `criteria` to the specific type. @@ -46,7 +46,7 @@ export const isAndCriteria = ( /** * Utility function used to parse a PermissionCriteria of type * @param criteria - a PermissionCriteria - * @alpha + * @public * * @returns `true` if the permission criteria is of type anyOf, * narrowing down `criteria` to the specific type. @@ -59,7 +59,7 @@ export const isOrCriteria = ( /** * Utility function used to parse a PermissionCriteria * @param criteria - a PermissionCriteria - * @alpha + * @public * * @returns `true` if the permission criteria is of type not, * narrowing down `criteria` to the specific type. From 3ab32a709103883c1732745b701e79a082db9d0a Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 2 Feb 2023 19:59:27 +0100 Subject: [PATCH 53/65] repo-tools: detect experimental type builds and allow all release stages in index Signed-off-by: Patrik Oldsberg --- .../src/commands/api-reports/api-extractor.ts | 26 ++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index 6ab712cf5e..fb36d5fe4e 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -300,9 +300,13 @@ function logApiReportInstructions() { console.log(''); } -async function findPackageEntryPoints( - packageDirs: string[], -): Promise> { +async function findPackageEntryPoints(packageDirs: string[]): Promise< + Array<{ + packageDir: string; + name: string; + usesExperimentalTypeBuild?: boolean; + }> +> { return Promise.all( packageDirs.map(async packageDir => { const pkg = await fs.readJson( @@ -326,7 +330,13 @@ async function findPackageEntryPoints( }); } - return { packageDir, name: 'index' }; + return { + packageDir, + name: 'index', + usesExperimentalTypeBuild: pkg.scripts?.build?.includes( + '--experimental-type-build', + ), + }; }), ).then(results => results.flat()); } @@ -372,7 +382,11 @@ export async function runApiExtraction({ } const warnings = new Array(); - for (const { packageDir, name } of packageEntryPoints) { + for (const { + packageDir, + name, + usesExperimentalTypeBuild, + } of packageEntryPoints) { console.log(`## Processing ${packageDir}`); const noBail = Array.isArray(allowWarnings) ? allowWarnings.some(aw => aw === packageDir || minimatch(packageDir, aw)) @@ -505,7 +519,7 @@ export async function runApiExtraction({ // This release tag validation makes sure that the release tag of known entry points match expectations. // The root index entrypoint is only allowed @public exports, while /alpha and /beta only allow @alpha and @beta. - if (validateReleaseTags) { + if (validateReleaseTags && !usesExperimentalTypeBuild) { if (['index', 'alpha', 'beta'].includes(name)) { const report = await fs.readFile( extractorConfig.reportFilePath, From 8ce58b40fb8b71be4222ee42a8470f081b1557a9 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 2 Feb 2023 20:31:51 +0100 Subject: [PATCH 54/65] repo-tools: allow public tags in alpha and beta reports Signed-off-by: Patrik Oldsberg --- .../repo-tools/src/commands/api-reports/api-extractor.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index fb36d5fe4e..dcd0631614 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -531,6 +531,11 @@ export async function runApiExtraction({ const line = lines[i]; const match = line.match(/^\/\/ @(alpha|beta|public)/); if (match && match[1] !== expectedTag) { + // Because of limitations in the type script rollup logic we need to allow public exports from the other release stages + // TODO(Rugvip): Try to work around the need for this exception + if (expectedTag !== 'public' && match[1] === 'public') { + continue; + } throw new Error( `Unexpected release tag ${match[1]} in ${ extractorConfig.reportFilePath From 4c08ac06fc30eafaa9ad7ce19e43dedd9151161d Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 2 Feb 2023 20:32:59 +0100 Subject: [PATCH 55/65] fix remaining alpha exports Signed-off-by: Patrik Oldsberg --- packages/core-plugin-api/alpha-api-report.md | 3 +- .../src/plugin-options/usePluginOptions.tsx | 2 +- .../alpha-api-report.md | 2 - .../api-report.md | 2 +- .../GithubEntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 9 +-- .../api-report.md | 2 + ...talIngestionEntityProviderCatalogModule.ts | 2 +- .../alpha-api-report.md | 9 +-- ...softGraphOrgEntityProviderCatalogModule.ts | 2 +- plugins/catalog-backend/alpha-api-report.md | 24 ++++--- plugins/catalog-backend/src/alpha.ts | 6 ++ plugins/catalog-node/alpha-api-report.md | 12 +--- plugins/catalog-node/src/extensions.ts | 6 +- .../alpha-api-report.md | 2 - .../AzureDevOpsEventRouterEventsModule.ts | 2 +- .../alpha-api-report.md | 2 - .../BitbucketCloudEventRouterEventsModule.ts | 2 +- .../alpha-api-report.md | 12 ++++ .../api-report.md | 4 -- .../service/GerritEventRouterEventsModule.ts | 2 +- .../alpha-api-report.md | 2 - .../service/GithubEventRouterEventsModule.ts | 2 +- .../alpha-api-report.md | 4 -- .../service/GitlabEventRouterEventsModule.ts | 2 +- .../src/service/GitlabWebhookEventsModule.ts | 2 +- plugins/events-node/alpha-api-report.md | 12 ++-- plugins/events-node/src/extensions.ts | 2 +- plugins/kubernetes-backend/api-report.md | 72 +++++++++---------- plugins/kubernetes/api-report.md | 10 +-- .../src/error-detection/error-detection.ts | 2 +- .../kubernetes/src/error-detection/types.ts | 8 +-- plugins/permission-node/api-report.md | 6 +- plugins/scaffolder/api-report.md | 17 ++--- plugins/sonarqube/api-report.md | 6 +- 35 files changed, 125 insertions(+), 131 deletions(-) create mode 100644 plugins/events-backend-module-gerrit/alpha-api-report.md diff --git a/packages/core-plugin-api/alpha-api-report.md b/packages/core-plugin-api/alpha-api-report.md index b66fee8207..379e186df8 100644 --- a/packages/core-plugin-api/alpha-api-report.md +++ b/packages/core-plugin-api/alpha-api-report.md @@ -3,14 +3,13 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { BackstagePlugin } from '@backstage/core-plugin-api'; import { ReactNode } from 'react'; // @alpha export interface PluginOptionsProviderProps { // (undocumented) children: ReactNode; - // Warning: (ae-forgotten-export) The symbol "BackstagePlugin" needs to be exported by the entry point alpha.d.ts - // // (undocumented) plugin?: BackstagePlugin; } diff --git a/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx b/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx index 4fdacc1ace..8b3f7c109c 100644 --- a/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx +++ b/packages/core-plugin-api/src/plugin-options/usePluginOptions.tsx @@ -19,7 +19,7 @@ import { createVersionedValueMap, useVersionedContext, } from '@backstage/version-bridge'; -import { BackstagePlugin } from '../plugin'; +import { BackstagePlugin } from '@backstage/core-plugin-api'; import React, { ReactNode } from 'react'; const contextKey: string = 'plugin-context'; diff --git a/plugins/catalog-backend-module-github/alpha-api-report.md b/plugins/catalog-backend-module-github/alpha-api-report.md index 8522344433..eb13ec4558 100644 --- a/plugins/catalog-backend-module-github/alpha-api-report.md +++ b/plugins/catalog-backend-module-github/alpha-api-report.md @@ -5,8 +5,6 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-catalog-backend-module-github" does not have an export "GithubEntityProvider" -// // @alpha export const githubEntityProviderCatalogModule: () => BackendFeature; diff --git a/plugins/catalog-backend-module-github/api-report.md b/plugins/catalog-backend-module-github/api-report.md index e2b73d267b..0ad377952a 100644 --- a/plugins/catalog-backend-module-github/api-report.md +++ b/plugins/catalog-backend-module-github/api-report.md @@ -7,7 +7,7 @@ import { AnalyzeOptions } from '@backstage/plugin-catalog-backend'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { Config } from '@backstage/config'; -import { Entity } from '@backstage/catalog-model'; +import { Entity } from '@backstage/catalog-model/*'; import { EntityProvider } from '@backstage/plugin-catalog-backend'; import { EntityProviderConnection } from '@backstage/plugin-catalog-backend'; import { EventParams } from '@backstage/plugin-events-node'; diff --git a/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts index fc319534f3..246f700248 100644 --- a/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-github/src/service/GithubEntityProviderCatalogModule.ts @@ -23,7 +23,7 @@ import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/ import { GithubEntityProvider } from '../providers/GithubEntityProvider'; /** - * Registers the {@link GithubEntityProvider} with the catalog processing extension point. + * Registers the `GithubEntityProvider` with the catalog processing extension point. * * @alpha */ diff --git a/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md b/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md index f762503b53..ec9c59a4c4 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md +++ b/plugins/catalog-backend-module-incremental-ingestion/alpha-api-report.md @@ -4,8 +4,8 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -import type { DeferredEntity } from '@backstage/plugin-catalog-backend'; -import type { DurationObjectUnits } from 'luxon'; +import { IncrementalEntityProvider } from '@backstage/plugin-catalog-backend-module-incremental-ingestion'; +import { IncrementalEntityProviderOptions } from '@backstage/plugin-catalog-backend-module-incremental-ingestion'; // @alpha export const incrementalIngestionEntityProviderCatalogModule: (options: { @@ -15,10 +15,5 @@ export const incrementalIngestionEntityProviderCatalogModule: (options: { }[]; }) => BackendFeature; -// Warnings were encountered during analysis: -// -// src/module/incrementalIngestionEntityProviderCatalogModule.d.ts:9:9 - (ae-forgotten-export) The symbol "IncrementalEntityProvider" needs to be exported by the entry point alpha.d.ts -// src/module/incrementalIngestionEntityProviderCatalogModule.d.ts:10:9 - (ae-forgotten-export) The symbol "IncrementalEntityProviderOptions" needs to be exported by the entry point alpha.d.ts - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/catalog-backend-module-incremental-ingestion/api-report.md b/plugins/catalog-backend-module-incremental-ingestion/api-report.md index 27ea35a34c..167c07f70f 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/api-report.md +++ b/plugins/catalog-backend-module-incremental-ingestion/api-report.md @@ -3,6 +3,8 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +/// + import { CatalogBuilder } from '@backstage/plugin-catalog-backend'; import type { Config } from '@backstage/config'; import type { DeferredEntity } from '@backstage/plugin-catalog-backend'; diff --git a/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts index 52fcef2cc9..261768c142 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-incremental-ingestion/src/module/incrementalIngestionEntityProviderCatalogModule.ts @@ -22,7 +22,7 @@ import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/ import { IncrementalEntityProvider, IncrementalEntityProviderOptions, -} from '../types'; +} from '@backstage/plugin-catalog-backend-module-incremental-ingestion'; import { WrapperProviders } from './WrapperProviders'; /** diff --git a/plugins/catalog-backend-module-msgraph/alpha-api-report.md b/plugins/catalog-backend-module-msgraph/alpha-api-report.md index c0daedc038..ed30b83bc8 100644 --- a/plugins/catalog-backend-module-msgraph/alpha-api-report.md +++ b/plugins/catalog-backend-module-msgraph/alpha-api-report.md @@ -4,22 +4,19 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -import { GroupEntity } from '@backstage/catalog-model'; -import * as MicrosoftGraph from '@microsoft/microsoft-graph-types'; -import { UserEntity } from '@backstage/catalog-model'; +import { GroupTransformer } from '@backstage/plugin-catalog-backend-module-msgraph'; +import { OrganizationTransformer } from '@backstage/plugin-catalog-backend-module-msgraph'; +import { UserTransformer } from '@backstage/plugin-catalog-backend-module-msgraph'; // @alpha export const microsoftGraphOrgEntityProviderCatalogModule: () => BackendFeature; // @alpha export interface MicrosoftGraphOrgEntityProviderCatalogModuleOptions { - // Warning: (ae-forgotten-export) The symbol "GroupTransformer" needs to be exported by the entry point alpha.d.ts groupTransformer?: GroupTransformer | Record; - // Warning: (ae-forgotten-export) The symbol "OrganizationTransformer" needs to be exported by the entry point alpha.d.ts organizationTransformer?: | OrganizationTransformer | Record; - // Warning: (ae-forgotten-export) The symbol "UserTransformer" needs to be exported by the entry point alpha.d.ts userTransformer?: UserTransformer | Record; } diff --git a/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts b/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts index 5cad504829..11be567045 100644 --- a/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts +++ b/plugins/catalog-backend-module-msgraph/src/service/MicrosoftGraphOrgEntityProviderCatalogModule.ts @@ -24,7 +24,7 @@ import { GroupTransformer, OrganizationTransformer, UserTransformer, -} from '../microsoftGraph'; +} from '@backstage/plugin-catalog-backend-module-msgraph'; import { MicrosoftGraphOrgEntityProvider } from '../processors'; /** diff --git a/plugins/catalog-backend/alpha-api-report.md b/plugins/catalog-backend/alpha-api-report.md index 6a40829d64..46be9a27df 100644 --- a/plugins/catalog-backend/alpha-api-report.md +++ b/plugins/catalog-backend/alpha-api-report.md @@ -6,7 +6,8 @@ import { BackendFeature } from '@backstage/backend-plugin-api'; import { ConditionalPolicyDecision } from '@backstage/plugin-permission-common'; import { Conditions } from '@backstage/plugin-permission-node'; -import { Entity } from '@backstage/catalog-model'; +import { Entity } from '@backstage/catalog-model/*'; +import { Entity as Entity_2 } from '@backstage/catalog-model'; import { PermissionCondition } from '@backstage/plugin-permission-common'; import { PermissionCriteria } from '@backstage/plugin-permission-common'; import { PermissionRule } from '@backstage/plugin-permission-node'; @@ -71,7 +72,7 @@ export const catalogConditions: Conditions<{ // @alpha export type CatalogPermissionRule< TParams extends PermissionRuleParams = PermissionRuleParams, -> = PermissionRule; +> = PermissionRule; // @alpha export const catalogPlugin: () => BackendFeature; @@ -88,8 +89,19 @@ export const createCatalogConditionalDecision: ( export const createCatalogPermissionRule: < TParams extends PermissionRuleParams = undefined, >( - rule: PermissionRule, -) => PermissionRule; + rule: PermissionRule< + Entity_2, + EntitiesSearchFilter, + 'catalog-entity', + TParams + >, +) => PermissionRule; + +// @public +export type EntitiesSearchFilter = { + key: string; + values?: string[]; +}; // @alpha export const permissionRules: { @@ -146,9 +158,5 @@ export const permissionRules: { >; }; -// Warnings were encountered during analysis: -// -// src/permissions/conditionExports.d.ts:8:5 - (ae-forgotten-export) The symbol "EntitiesSearchFilter" needs to be exported by the entry point alpha.d.ts - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/catalog-backend/src/alpha.ts b/plugins/catalog-backend/src/alpha.ts index 51a6a72923..aa1309aecd 100644 --- a/plugins/catalog-backend/src/alpha.ts +++ b/plugins/catalog-backend/src/alpha.ts @@ -14,5 +14,11 @@ * limitations under the License. */ +// TODO(Rugvip): Re-exported for alpha types as the API report will otherwise +// produce warnings due to the indirect dependency. We be nice to avoid. +import type { EntitiesSearchFilter } from './catalog/types'; + +export type { /** @alpha */ EntitiesSearchFilter }; + export * from './permissions'; export { catalogPlugin } from './service/CatalogPlugin'; diff --git a/plugins/catalog-node/alpha-api-report.md b/plugins/catalog-node/alpha-api-report.md index 1bfb3f3566..ba1bcd47b2 100644 --- a/plugins/catalog-node/alpha-api-report.md +++ b/plugins/catalog-node/alpha-api-report.md @@ -3,26 +3,18 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -/// - import { CatalogApi } from '@backstage/catalog-client'; -import { CompoundEntityRef } from '@backstage/catalog-model'; -import { Entity } from '@backstage/catalog-model'; +import { CatalogProcessor } from '@backstage/plugin-catalog-node'; +import { EntityProvider } from '@backstage/plugin-catalog-node'; import { ExtensionPoint } from '@backstage/backend-plugin-api'; -import { JsonValue } from '@backstage/types'; -import { LocationSpec } from '@backstage/plugin-catalog-common'; import { ServiceRef } from '@backstage/backend-plugin-api'; // @alpha (undocumented) export interface CatalogProcessingExtensionPoint { - // Warning: (ae-forgotten-export) The symbol "EntityProvider" needs to be exported by the entry point alpha.d.ts - // // (undocumented) addEntityProvider( ...providers: Array> ): void; - // Warning: (ae-forgotten-export) The symbol "CatalogProcessor" needs to be exported by the entry point alpha.d.ts - // // (undocumented) addProcessor( ...processors: Array> diff --git a/plugins/catalog-node/src/extensions.ts b/plugins/catalog-node/src/extensions.ts index 8dd9d8579a..0466af36b0 100644 --- a/plugins/catalog-node/src/extensions.ts +++ b/plugins/catalog-node/src/extensions.ts @@ -14,8 +14,10 @@ * limitations under the License. */ import { createExtensionPoint } from '@backstage/backend-plugin-api'; -import { EntityProvider } from './api'; -import { CatalogProcessor } from './api/processor'; +import { + EntityProvider, + CatalogProcessor, +} from '@backstage/plugin-catalog-node'; /** * @alpha diff --git a/plugins/events-backend-module-azure/alpha-api-report.md b/plugins/events-backend-module-azure/alpha-api-report.md index ccae207a64..e3fed2cab0 100644 --- a/plugins/events-backend-module-azure/alpha-api-report.md +++ b/plugins/events-backend-module-azure/alpha-api-report.md @@ -5,8 +5,6 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-azure" does not have an export "AzureDevOpsEventRouter" -// // @alpha export const azureDevOpsEventRouterEventsModule: () => BackendFeature; diff --git a/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts b/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts index 1ceefe5c4e..18851befa4 100644 --- a/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts +++ b/plugins/events-backend-module-azure/src/service/AzureDevOpsEventRouterEventsModule.ts @@ -21,7 +21,7 @@ import { AzureDevOpsEventRouter } from '../router/AzureDevOpsEventRouter'; /** * Module for the events-backend plugin, adding an event router for Azure DevOps. * - * Registers the {@link AzureDevOpsEventRouter}. + * Registers the `AzureDevOpsEventRouter`. * * @alpha */ diff --git a/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md b/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md index 11b60fd12d..f8e550bf98 100644 --- a/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md +++ b/plugins/events-backend-module-bitbucket-cloud/alpha-api-report.md @@ -5,8 +5,6 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-bitbucket-cloud" does not have an export "BitbucketCloudEventRouter" -// // @alpha export const bitbucketCloudEventRouterEventsModule: () => BackendFeature; diff --git a/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts b/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts index 1f339a2bd1..9516651aa3 100644 --- a/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts +++ b/plugins/events-backend-module-bitbucket-cloud/src/service/BitbucketCloudEventRouterEventsModule.ts @@ -21,7 +21,7 @@ import { BitbucketCloudEventRouter } from '../router/BitbucketCloudEventRouter'; /** * Module for the events-backend plugin, adding an event router for Bitbucket Cloud. * - * Registers the {@link BitbucketCloudEventRouter}. + * Registers the `BitbucketCloudEventRouter`. * * @alpha */ diff --git a/plugins/events-backend-module-gerrit/alpha-api-report.md b/plugins/events-backend-module-gerrit/alpha-api-report.md new file mode 100644 index 0000000000..f610d518e7 --- /dev/null +++ b/plugins/events-backend-module-gerrit/alpha-api-report.md @@ -0,0 +1,12 @@ +## API Report File for "@backstage/plugin-events-backend-module-gerrit" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts +import { BackendFeature } from '@backstage/backend-plugin-api'; + +// @alpha +export const gerritEventRouterEventsModule: () => BackendFeature; + +// (No @packageDocumentation comment for this package) +``` diff --git a/plugins/events-backend-module-gerrit/api-report.md b/plugins/events-backend-module-gerrit/api-report.md index c8d4a7c9b6..ba3c4dd29f 100644 --- a/plugins/events-backend-module-gerrit/api-report.md +++ b/plugins/events-backend-module-gerrit/api-report.md @@ -3,7 +3,6 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts -import { BackendFeature } from '@backstage/backend-plugin-api'; import { EventParams } from '@backstage/plugin-events-node'; import { SubTopicEventRouter } from '@backstage/plugin-events-node'; @@ -13,7 +12,4 @@ export class GerritEventRouter extends SubTopicEventRouter { // (undocumented) protected determineSubTopic(params: EventParams): string | undefined; } - -// @alpha -export const gerritEventRouterEventsModule: () => BackendFeature; ``` diff --git a/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts b/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts index 6f8889eb2b..31f5c9b384 100644 --- a/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts +++ b/plugins/events-backend-module-gerrit/src/service/GerritEventRouterEventsModule.ts @@ -21,7 +21,7 @@ import { GerritEventRouter } from '../router/GerritEventRouter'; /** * Module for the events-backend plugin, adding an event router for Gerrit. * - * Registers the {@link GerritEventRouter}. + * Registers the `GerritEventRouter`. * * @alpha */ diff --git a/plugins/events-backend-module-github/alpha-api-report.md b/plugins/events-backend-module-github/alpha-api-report.md index aed740ed0d..cb95928b17 100644 --- a/plugins/events-backend-module-github/alpha-api-report.md +++ b/plugins/events-backend-module-github/alpha-api-report.md @@ -5,8 +5,6 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-github" does not have an export "GithubEventRouter" -// // @alpha export const githubEventRouterEventsModule: () => BackendFeature; diff --git a/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts b/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts index e2e6fab266..56cc571763 100644 --- a/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts +++ b/plugins/events-backend-module-github/src/service/GithubEventRouterEventsModule.ts @@ -21,7 +21,7 @@ import { GithubEventRouter } from '../router/GithubEventRouter'; /** * Module for the events-backend plugin, adding an event router for GitHub. * - * Registers the {@link GithubEventRouter}. + * Registers the `GithubEventRouter`. * * @alpha */ diff --git a/plugins/events-backend-module-gitlab/alpha-api-report.md b/plugins/events-backend-module-gitlab/alpha-api-report.md index d8b1430df9..64727cc844 100644 --- a/plugins/events-backend-module-gitlab/alpha-api-report.md +++ b/plugins/events-backend-module-gitlab/alpha-api-report.md @@ -5,13 +5,9 @@ ```ts import { BackendFeature } from '@backstage/backend-plugin-api'; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-gitlab" does not have an export "GitlabEventRouter" -// // @alpha export const gitlabEventRouterEventsModule: () => BackendFeature; -// Warning: (ae-unresolved-link) The @link reference could not be resolved: The package "@backstage/plugin-events-backend-module-gitlab" does not have an export "GitlabEventRouter" -// // @alpha export const gitlabWebhookEventsModule: () => BackendFeature; diff --git a/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts b/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts index 45b7f37711..39ccd5cd60 100644 --- a/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts +++ b/plugins/events-backend-module-gitlab/src/service/GitlabEventRouterEventsModule.ts @@ -21,7 +21,7 @@ import { GitlabEventRouter } from '../router/GitlabEventRouter'; /** * Module for the events-backend plugin, adding an event router for GitLab. * - * Registers the {@link GitlabEventRouter}. + * Registers the `GitlabEventRouter`. * * @alpha */ diff --git a/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts b/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts index 2fcee40589..c20e55caa9 100644 --- a/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts +++ b/plugins/events-backend-module-gitlab/src/service/GitlabWebhookEventsModule.ts @@ -26,7 +26,7 @@ import { createGitlabTokenValidator } from '../http/createGitlabTokenValidator'; * registering an HTTP POST ingress with request validator * which verifies the webhook token based on a secret. * - * Registers the {@link GitlabEventRouter}. + * Registers the `GitlabEventRouter`. * * @alpha */ diff --git a/plugins/events-node/alpha-api-report.md b/plugins/events-node/alpha-api-report.md index 161f80ff87..fd30f54d45 100644 --- a/plugins/events-node/alpha-api-report.md +++ b/plugins/events-node/alpha-api-report.md @@ -3,28 +3,24 @@ > Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). ```ts +import { EventBroker } from '@backstage/plugin-events-node'; +import { EventPublisher } from '@backstage/plugin-events-node'; +import { EventSubscriber } from '@backstage/plugin-events-node'; import { ExtensionPoint } from '@backstage/backend-plugin-api'; +import { HttpPostIngressOptions } from '@backstage/plugin-events-node'; // @alpha (undocumented) export interface EventsExtensionPoint { - // Warning: (ae-forgotten-export) The symbol "HttpPostIngressOptions" needs to be exported by the entry point alpha.d.ts - // // (undocumented) addHttpPostIngress(options: HttpPostIngressOptions): void; - // Warning: (ae-forgotten-export) The symbol "EventPublisher" needs to be exported by the entry point alpha.d.ts - // // (undocumented) addPublishers( ...publishers: Array> ): void; - // Warning: (ae-forgotten-export) The symbol "EventSubscriber" needs to be exported by the entry point alpha.d.ts - // // (undocumented) addSubscribers( ...subscribers: Array> ): void; - // Warning: (ae-forgotten-export) The symbol "EventBroker" needs to be exported by the entry point alpha.d.ts - // // (undocumented) setEventBroker(eventBroker: EventBroker): void; } diff --git a/plugins/events-node/src/extensions.ts b/plugins/events-node/src/extensions.ts index 945d86b49c..2e44b381af 100644 --- a/plugins/events-node/src/extensions.ts +++ b/plugins/events-node/src/extensions.ts @@ -20,7 +20,7 @@ import { EventPublisher, EventSubscriber, HttpPostIngressOptions, -} from './api'; +} from '@backstage/plugin-events-node'; /** * @alpha diff --git a/plugins/kubernetes-backend/api-report.md b/plugins/kubernetes-backend/api-report.md index 006f980c56..a6a4bcfc58 100644 --- a/plugins/kubernetes-backend/api-report.md +++ b/plugins/kubernetes-backend/api-report.md @@ -21,7 +21,7 @@ import { PluginEndpointDiscovery } from '@backstage/backend-common'; import type { RequestHandler } from 'express'; import { TokenCredential } from '@azure/identity'; -// @alpha (undocumented) +// @public (undocumented) export interface AWSClusterDetails extends ClusterDetails { // (undocumented) assumeRole?: string; @@ -29,7 +29,7 @@ export interface AWSClusterDetails extends ClusterDetails { externalId?: string; } -// @alpha (undocumented) +// @public (undocumented) export class AwsIamKubernetesAuthTranslator implements KubernetesAuthTranslator { @@ -54,10 +54,10 @@ export class AwsIamKubernetesAuthTranslator validCredentials(creds: SigningCreds): boolean; } -// @alpha (undocumented) +// @public (undocumented) export interface AzureClusterDetails extends ClusterDetails {} -// @alpha (undocumented) +// @public (undocumented) export class AzureIdentityKubernetesAuthTranslator implements KubernetesAuthTranslator { @@ -68,7 +68,7 @@ export class AzureIdentityKubernetesAuthTranslator ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export interface ClusterDetails { // (undocumented) authProvider: string; @@ -91,25 +91,25 @@ export interface ClusterDetails { url: string; } -// @alpha @deprecated +// @public @deprecated export function createRouter(options: RouterOptions): Promise; -// @alpha (undocumented) +// @public (undocumented) export interface CustomResource extends ObjectToFetch { // (undocumented) objectType: 'customresources'; } -// @alpha (undocumented) +// @public (undocumented) export interface CustomResourcesByEntity extends KubernetesObjectsByEntity { // (undocumented) customResources: CustomResourceMatcher[]; } -// @alpha (undocumented) +// @public (undocumented) export const DEFAULT_OBJECTS: ObjectToFetch[]; -// @alpha (undocumented) +// @public (undocumented) export interface FetchResponseWrapper { // (undocumented) errors: KubernetesFetchError[]; @@ -117,10 +117,10 @@ export interface FetchResponseWrapper { responses: FetchResponse[]; } -// @alpha (undocumented) +// @public (undocumented) export interface GKEClusterDetails extends ClusterDetails {} -// @alpha (undocumented) +// @public (undocumented) export class GoogleKubernetesAuthTranslator implements KubernetesAuthTranslator { @@ -131,7 +131,7 @@ export class GoogleKubernetesAuthTranslator ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export class GoogleServiceAccountAuthTranslator implements KubernetesAuthTranslator { @@ -144,7 +144,7 @@ export class GoogleServiceAccountAuthTranslator // @public export const HEADER_KUBERNETES_CLUSTER: string; -// @alpha (undocumented) +// @public (undocumented) export interface KubernetesAuthTranslator { // (undocumented) decorateClusterDetailsWithAuth( @@ -153,7 +153,7 @@ export interface KubernetesAuthTranslator { ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export class KubernetesAuthTranslatorGenerator { // (undocumented) static getKubernetesAuthTranslatorInstance( @@ -164,7 +164,7 @@ export class KubernetesAuthTranslatorGenerator { ): KubernetesAuthTranslator; } -// @alpha (undocumented) +// @public (undocumented) export class KubernetesBuilder { constructor(env: KubernetesEnvironment); // (undocumented) @@ -247,7 +247,7 @@ export class KubernetesBuilder { setServiceLocator(serviceLocator?: KubernetesServiceLocator): this; } -// @alpha +// @public export type KubernetesBuilderReturn = Promise<{ router: express.Router; clusterSupplier: KubernetesClustersSupplier; @@ -258,12 +258,12 @@ export type KubernetesBuilderReturn = Promise<{ serviceLocator: KubernetesServiceLocator; }>; -// @alpha +// @public export interface KubernetesClustersSupplier { getClusters(): Promise; } -// @alpha (undocumented) +// @public (undocumented) export interface KubernetesEnvironment { // (undocumented) catalogApi: CatalogApi; @@ -273,7 +273,7 @@ export interface KubernetesEnvironment { logger: Logger; } -// @alpha +// @public export interface KubernetesFetcher { // (undocumented) fetchObjectsForService( @@ -286,7 +286,7 @@ export interface KubernetesFetcher { ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export interface KubernetesObjectsByEntity { // (undocumented) auth: KubernetesRequestAuth; @@ -294,7 +294,7 @@ export interface KubernetesObjectsByEntity { entity: Entity; } -// @alpha (undocumented) +// @public (undocumented) export interface KubernetesObjectsProvider { // (undocumented) getCustomResourcesByEntity( @@ -306,7 +306,7 @@ export interface KubernetesObjectsProvider { ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export interface KubernetesObjectsProviderOptions { // (undocumented) customResources: CustomResource[]; @@ -320,7 +320,7 @@ export interface KubernetesObjectsProviderOptions { serviceLocator: KubernetesServiceLocator; } -// @alpha (undocumented) +// @public (undocumented) export type KubernetesObjectTypes = | 'pods' | 'services' @@ -336,14 +336,14 @@ export type KubernetesObjectTypes = | 'statefulsets' | 'daemonsets'; -// @alpha +// @public export class KubernetesProxy { constructor(logger: Logger, clusterSupplier: KubernetesClustersSupplier); // (undocumented) createRequestHandler(): RequestHandler; } -// @alpha +// @public export interface KubernetesServiceLocator { // (undocumented) getClustersByEntity( @@ -354,7 +354,7 @@ export interface KubernetesServiceLocator { }>; } -// @alpha (undocumented) +// @public (undocumented) export class NoopKubernetesAuthTranslator implements KubernetesAuthTranslator { // (undocumented) decorateClusterDetailsWithAuth( @@ -362,7 +362,7 @@ export class NoopKubernetesAuthTranslator implements KubernetesAuthTranslator { ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export interface ObjectFetchParams { // (undocumented) clusterDetails: @@ -382,10 +382,10 @@ export interface ObjectFetchParams { serviceId: string; } -// @alpha (undocumented) +// @public (undocumented) export type ObjectsByEntityRequest = KubernetesRequestBody; -// @alpha (undocumented) +// @public (undocumented) export interface ObjectToFetch { // (undocumented) apiVersion: string; @@ -397,7 +397,7 @@ export interface ObjectToFetch { plural: string; } -// @alpha (undocumented) +// @public (undocumented) export class OidcKubernetesAuthTranslator implements KubernetesAuthTranslator { // (undocumented) decorateClusterDetailsWithAuth( @@ -406,7 +406,7 @@ export class OidcKubernetesAuthTranslator implements KubernetesAuthTranslator { ): Promise; } -// @alpha (undocumented) +// @public (undocumented) export interface RouterOptions { // (undocumented) catalogApi: CatalogApi; @@ -420,13 +420,13 @@ export interface RouterOptions { logger: Logger; } -// @alpha (undocumented) +// @public (undocumented) export interface ServiceAccountClusterDetails extends ClusterDetails {} -// @alpha (undocumented) +// @public (undocumented) export type ServiceLocatorMethod = 'multiTenant' | 'http'; -// @alpha (undocumented) +// @public (undocumented) export interface ServiceLocatorRequestContext { // (undocumented) customResources: CustomResourceMatcher[]; @@ -434,7 +434,7 @@ export interface ServiceLocatorRequestContext { objectTypesToFetch: Set; } -// @alpha (undocumented) +// @public (undocumented) export type SigningCreds = { accessKeyId: string | undefined; secretAccessKey: string | undefined; diff --git a/plugins/kubernetes/api-report.md b/plugins/kubernetes/api-report.md index 463b4126eb..2cc2674a9e 100644 --- a/plugins/kubernetes/api-report.md +++ b/plugins/kubernetes/api-report.md @@ -101,7 +101,7 @@ export interface DeploymentResources { replicaSets: V1ReplicaSet[]; } -// @alpha +// @public export interface DetectedError { // (undocumented) cluster: string; @@ -117,10 +117,10 @@ export interface DetectedError { severity: ErrorSeverity; } -// @alpha +// @public export type DetectedErrorsByCluster = Map; -// @alpha +// @public export const detectErrors: ( objects: ObjectsByEntityResponse, ) => DetectedErrorsByCluster; @@ -137,7 +137,7 @@ export type EntityKubernetesContentProps = { refreshIntervalMs?: number; }; -// @alpha +// @public export type ErrorDetectableKind = | 'Pod' | 'Deployment' @@ -161,7 +161,7 @@ export const ErrorReporting: ({ detectedErrors, }: ErrorReportingProps) => JSX.Element; -// @alpha +// @public export type ErrorSeverity = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; // Warning: (ae-forgotten-export) The symbol "FormatClusterLinkOptions" needs to be exported by the entry point index.d.ts diff --git a/plugins/kubernetes/src/error-detection/error-detection.ts b/plugins/kubernetes/src/error-detection/error-detection.ts index 3a9f1571e0..fddd4d838a 100644 --- a/plugins/kubernetes/src/error-detection/error-detection.ts +++ b/plugins/kubernetes/src/error-detection/error-detection.ts @@ -25,7 +25,7 @@ import { detectErrorsInHpa } from './hpas'; * For each cluster try to find errors in each of the object types provided * returning a map of cluster names to errors in that cluster * - * @alpha + * @public */ export const detectErrors = ( objects: ObjectsByEntityResponse, diff --git a/plugins/kubernetes/src/error-detection/types.ts b/plugins/kubernetes/src/error-detection/types.ts index 5e35cef8b6..4bc7ae164d 100644 --- a/plugins/kubernetes/src/error-detection/types.ts +++ b/plugins/kubernetes/src/error-detection/types.ts @@ -24,7 +24,7 @@ import { /** * Severity of the error, where 10 is critical and 0 is very low. * - * @alpha + * @public */ export type ErrorSeverity = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10; @@ -33,7 +33,7 @@ export type ErrorDetectable = V1Pod | V1Deployment | V1HorizontalPodAutoscaler; /** * Kubernetes kinds that errors might be reported by the plugin * - * @alpha + * @public */ export type ErrorDetectableKind = | 'Pod' @@ -43,14 +43,14 @@ export type ErrorDetectableKind = /** * A list of errors keyed by Cluster name * - * @alpha + * @public */ export type DetectedErrorsByCluster = Map; /** * Represents an error found on a Kubernetes object * - * @alpha + * @public */ export interface DetectedError { severity: ErrorSeverity; diff --git a/plugins/permission-node/api-report.md b/plugins/permission-node/api-report.md index 3f712fe362..569fb5c6ea 100644 --- a/plugins/permission-node/api-report.md +++ b/plugins/permission-node/api-report.md @@ -137,17 +137,17 @@ export const createPermissionRule: < rule: PermissionRule, ) => PermissionRule; -// @alpha +// @public export const isAndCriteria: ( criteria: PermissionCriteria, ) => criteria is AllOfCriteria; -// @alpha +// @public export const isNotCriteria: ( criteria: PermissionCriteria, ) => criteria is NotCriteria; -// @alpha +// @public export const isOrCriteria: ( criteria: PermissionCriteria, ) => criteria is AnyOfCriteria; diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index 7030affeea..df1670e718 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -6,7 +6,7 @@ /// import { ApiHolder } from '@backstage/core-plugin-api'; -import { ApiRef } from '@backstage/core-plugin-api'; +import { ApiRef } from '@backstage/core-plugin-api/*'; import { BackstagePlugin } from '@backstage/core-plugin-api'; import { ComponentType } from 'react'; import { createScaffolderFieldExtension as createScaffolderFieldExtension_2 } from '@backstage/plugin-scaffolder-react'; @@ -32,6 +32,7 @@ import { PathParams } from '@backstage/core-plugin-api'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; +import { RouteRef as RouteRef_2 } from '@backstage/core-plugin-api/*'; import { ScaffolderApi as ScaffolderApi_2 } from '@backstage/plugin-scaffolder-react'; import { ScaffolderDryRunOptions as ScaffolderDryRunOptions_2 } from '@backstage/plugin-scaffolder-react'; import { ScaffolderDryRunResponse as ScaffolderDryRunResponse_2 } from '@backstage/plugin-scaffolder-react'; @@ -109,9 +110,9 @@ export type EntityPickerUiOptions = export const EntityTagsPickerFieldExtension: FieldExtensionComponent_2< string[], { - helperText?: string | undefined; - kinds?: string[] | undefined; showCounts?: boolean | undefined; + kinds?: string[] | undefined; + helperText?: string | undefined; } >; @@ -119,9 +120,9 @@ export const EntityTagsPickerFieldExtension: FieldExtensionComponent_2< export const EntityTagsPickerFieldSchema: FieldSchema< string[], { - helperText?: string | undefined; - kinds?: string[] | undefined; showCounts?: boolean | undefined; + kinds?: string[] | undefined; + helperText?: string | undefined; } >; @@ -259,8 +260,8 @@ export const RepoUrlPickerFieldExtension: FieldExtensionComponent_2< | { azure?: string[] | undefined; github?: string[] | undefined; - bitbucket?: string[] | undefined; gitlab?: string[] | undefined; + bitbucket?: string[] | undefined; gerrit?: string[] | undefined; } | undefined; @@ -285,8 +286,8 @@ export const RepoUrlPickerFieldSchema: FieldSchema< | { azure?: string[] | undefined; github?: string[] | undefined; - bitbucket?: string[] | undefined; gitlab?: string[] | undefined; + bitbucket?: string[] | undefined; gerrit?: string[] | undefined; } | undefined; @@ -315,7 +316,7 @@ export type ReviewStepProps = { }; // @public @deprecated (undocumented) -export const rootRouteRef: RouteRef; +export const rootRouteRef: RouteRef_2; // @public export type RouterProps = { diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index db3f38e31d..cdbe839543 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -7,11 +7,11 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { DiscoveryApi } from '@backstage/core-plugin-api'; -import { Entity } from '@backstage/catalog-model'; -import { FindingSummary } from '@backstage/plugin-sonarqube-react'; +import { Entity } from '@backstage/catalog-model/*'; +import { FindingSummary } from '@backstage/plugin-sonarqube-react/alpha'; import { IdentityApi } from '@backstage/core-plugin-api'; import { InfoCardVariants } from '@backstage/core-components'; -import { SonarQubeApi } from '@backstage/plugin-sonarqube-react'; +import { SonarQubeApi } from '@backstage/plugin-sonarqube-react/alpha'; // @public (undocumented) export type DuplicationRating = { From a117491a92c69ab106aad49200d694c1db61d8a1 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Thu, 2 Feb 2023 20:33:52 +0100 Subject: [PATCH 56/65] update cli reports Signed-off-by: Patrik Oldsberg --- packages/cli/cli-report.md | 10 ++++++++++ packages/repo-tools/cli-report.md | 1 + 2 files changed, 11 insertions(+) diff --git a/packages/cli/cli-report.md b/packages/cli/cli-report.md index fa9a2aca8d..bad849d283 100644 --- a/packages/cli/cli-report.md +++ b/packages/cli/cli-report.md @@ -127,11 +127,21 @@ Options: Commands: package-roles package-scripts + package-exports package-lint-configs react-router-deps help [command] ``` +### `backstage-cli migrate package-exports` + +``` +Usage: backstage-cli migrate package-exports [options] + +Options: + -h, --help +``` + ### `backstage-cli migrate package-lint-configs` ``` diff --git a/packages/repo-tools/cli-report.md b/packages/repo-tools/cli-report.md index 3378d20ea7..0e1b2d2a4c 100644 --- a/packages/repo-tools/cli-report.md +++ b/packages/repo-tools/cli-report.md @@ -29,6 +29,7 @@ Options: -a, --allow-warnings --allow-all-warnings -o, --omit-messages + --validate-release-tags -h, --help ``` From cab2437a0b5dff956ababd107f3399fe0bfad820 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 4 Feb 2023 15:44:09 +0100 Subject: [PATCH 57/65] repo-tools: skip doc generation for non-index entrypoints Signed-off-by: Patrik Oldsberg --- packages/repo-tools/src/commands/api-reports/api-extractor.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index dcd0631614..0c23d42437 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -424,7 +424,9 @@ export async function runApiExtraction({ }, docModel: { - enabled: true, + // TODO(Rugvip): This skips docs for non-index entry points. We can try to work around it, but + // most likely it makes sense to wait for API Extractor to natively support exports. + enabled: name === 'index', apiJsonFilePath: resolvePath( outputDir, `${prefix}.api.json`, From 3192c96e82aec00f9b88b4e0f257b426d3e3a48d Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 4 Feb 2023 16:50:00 +0100 Subject: [PATCH 58/65] repo-tools: update type-deps to analyze all entry points Signed-off-by: Patrik Oldsberg --- .../src/commands/api-reports/api-extractor.ts | 35 +++++------------ .../src/commands/type-deps/type-deps.ts | 15 ++++--- packages/repo-tools/src/lib/entryPoints.ts | 39 +++++++++++++++++++ 3 files changed, 59 insertions(+), 30 deletions(-) create mode 100644 packages/repo-tools/src/lib/entryPoints.ts diff --git a/packages/repo-tools/src/commands/api-reports/api-extractor.ts b/packages/repo-tools/src/commands/api-reports/api-extractor.ts index 0c23d42437..1fe7602617 100644 --- a/packages/repo-tools/src/commands/api-reports/api-extractor.ts +++ b/packages/repo-tools/src/commands/api-reports/api-extractor.ts @@ -19,7 +19,6 @@ import { relative as relativePath, basename, join, - extname, } from 'path'; import { execFile } from 'child_process'; import fs from 'fs-extra'; @@ -63,6 +62,7 @@ import { IMarkdownEmitterContext } from '@microsoft/api-documenter/lib/markdown/ import { AstDeclaration } from '@microsoft/api-extractor/lib/analyzer/AstDeclaration'; import { paths as cliPaths } from '../../lib/paths'; import minimatch from 'minimatch'; +import { getPackageExportNames } from '../../lib/entryPoints'; const tmpDir = cliPaths.resolveTargetRoot( './node_modules/.cache/api-extractor', @@ -313,30 +313,15 @@ async function findPackageEntryPoints(packageDirs: string[]): Promise< cliPaths.resolveTargetRoot(packageDir, 'package.json'), ); - if (pkg.exports && typeof pkg.exports !== 'string') { - return Object.entries(pkg.exports).flatMap(([mount, path]) => { - const ext = extname(String(path)); - if (!['.ts', '.tsx', '.cts', '.mts'].includes(ext)) { - return []; // Ignore non-TS entry points - } - let name = mount; - if (name.startsWith('./')) { - name = name.slice(2); - } - if (!name || name === '.') { - return [{ packageDir, name: 'index' }]; - } - return [{ packageDir, name }]; - }); - } - - return { - packageDir, - name: 'index', - usesExperimentalTypeBuild: pkg.scripts?.build?.includes( - '--experimental-type-build', - ), - }; + return ( + getPackageExportNames(pkg)?.map(name => ({ packageDir, name })) ?? { + packageDir, + name: 'index', + usesExperimentalTypeBuild: pkg.scripts?.build?.includes( + '--experimental-type-build', + ), + } + ); }), ).then(results => results.flat()); } diff --git a/packages/repo-tools/src/commands/type-deps/type-deps.ts b/packages/repo-tools/src/commands/type-deps/type-deps.ts index 0ad9a5cfc8..17164cea39 100644 --- a/packages/repo-tools/src/commands/type-deps/type-deps.ts +++ b/packages/repo-tools/src/commands/type-deps/type-deps.ts @@ -20,6 +20,7 @@ import { resolve as resolvePath } from 'path'; // eslint-disable-next-line @backstage/no-undeclared-imports import chalk from 'chalk'; import { getPackages, Package } from '@manypkg/get-packages'; +import { getPackageExportNames } from '../../lib/entryPoints'; export default async () => { const { packages } = await getPackages(resolvePath('.')); @@ -96,11 +97,15 @@ function findAllDeps(declSrc: string) { * missing or incorrect in package.json */ function checkTypes(pkg: Package) { - const typeDecl = fs.readFileSync( - resolvePath(pkg.dir, 'dist/index.d.ts'), - 'utf8', - ); - const allDeps = findAllDeps(typeDecl); + const entryPointNames = getPackageExportNames(pkg.packageJson) ?? ['index']; + + const allDeps = entryPointNames.flatMap(name => { + const typeDecl = fs.readFileSync( + resolvePath(pkg.dir, `dist/${name}.d.ts`), + 'utf8', + ); + return findAllDeps(typeDecl); + }); const deps = Array.from(new Set(allDeps)); const errors = []; diff --git a/packages/repo-tools/src/lib/entryPoints.ts b/packages/repo-tools/src/lib/entryPoints.ts new file mode 100644 index 0000000000..df5633c103 --- /dev/null +++ b/packages/repo-tools/src/lib/entryPoints.ts @@ -0,0 +1,39 @@ +/* + * Copyright 2023 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 { extname } from 'path'; +import { JsonObject } from '@backstage/types'; + +export function getPackageExportNames(pkg: JsonObject): string[] | undefined { + if (pkg.exports && typeof pkg.exports !== 'string') { + return Object.entries(pkg.exports).flatMap(([mount, path]) => { + const ext = extname(String(path)); + if (!['.ts', '.tsx', '.cts', '.mts'].includes(ext)) { + return []; // Ignore non-TS entry points + } + let name = mount; + if (name.startsWith('./')) { + name = name.slice(2); + } + if (!name || name === '.') { + return ['index']; + } + return [name]; + }); + } + + return undefined; +} From b6674828e7cd85037f3d82efaec48de241a3bb99 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 4 Feb 2023 17:13:05 +0100 Subject: [PATCH 59/65] cli: avoid error when attempting to production pack packages without dist dir Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/packager/productionPack.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index adcab2b90c..3a74b68257 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -181,7 +181,11 @@ async function prepareExportsEntryPoints( pkg: ExtendedPackageJSON, packageDir: string, ) { - const distFiles = await fs.readdir(resolvePath(packageDir, 'dist')); + const distPath = resolvePath(packageDir, 'dist'); + if (!(await fs.pathExists(distPath))) { + return undefined; + } + const distFiles = await fs.readdir(distPath); const outputExports = {} as Record>; const compatibilityWriters = new Array< From efbd99efd75ee757cb8aebcf4c7dd1af4e82d7f4 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 4 Feb 2023 17:26:47 +0100 Subject: [PATCH 60/65] remove index entry from typesVersions Signed-off-by: Patrik Oldsberg --- packages/backend-common/package.json | 3 --- packages/backend-test-utils/package.json | 3 --- packages/catalog-model/package.json | 3 --- .../cli/src/commands/migrate/packageExports.ts | 6 +++++- packages/core-plugin-api/package.json | 3 --- packages/test-utils/package.json | 3 --- plugins/app-backend/package.json | 3 --- plugins/catalog-backend-module-aws/package.json | 3 --- plugins/catalog-backend-module-azure/package.json | 3 --- .../package.json | 3 --- .../package.json | 3 --- plugins/catalog-backend-module-gerrit/package.json | 3 --- .../catalog-backend-module-github/api-report.md | 2 +- plugins/catalog-backend-module-github/package.json | 3 --- plugins/catalog-backend-module-gitlab/package.json | 3 --- .../package.json | 3 --- .../catalog-backend-module-msgraph/package.json | 3 --- plugins/catalog-backend/alpha-api-report.md | 14 ++++---------- plugins/catalog-backend/package.json | 3 --- plugins/catalog-common/package.json | 3 --- plugins/catalog-node/package.json | 3 --- plugins/catalog-react/package.json | 3 --- plugins/events-backend-module-aws-sqs/package.json | 3 --- plugins/events-backend-module-azure/package.json | 3 --- .../package.json | 3 --- plugins/events-backend-module-gerrit/package.json | 3 --- plugins/events-backend-module-github/package.json | 3 --- plugins/events-backend-module-gitlab/package.json | 3 --- plugins/events-backend/package.json | 3 --- plugins/events-node/package.json | 3 --- plugins/scaffolder-backend/package.json | 3 --- plugins/scaffolder-react/package.json | 3 --- plugins/scaffolder/api-report.md | 5 ++--- plugins/scaffolder/package.json | 3 --- plugins/sonarqube-react/package.json | 3 --- plugins/sonarqube/api-report.md | 2 +- 36 files changed, 13 insertions(+), 109 deletions(-) diff --git a/packages/backend-common/package.json b/packages/backend-common/package.json index 71f800dff8..7973ae6111 100644 --- a/packages/backend-common/package.json +++ b/packages/backend-common/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/packages/backend-test-utils/package.json b/packages/backend-test-utils/package.json index 7e14963aab..7bcb680dfe 100644 --- a/packages/backend-test-utils/package.json +++ b/packages/backend-test-utils/package.json @@ -13,9 +13,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "package.json": [ "package.json" ] diff --git a/packages/catalog-model/package.json b/packages/catalog-model/package.json index 2d569053b1..b391ad79e4 100644 --- a/packages/catalog-model/package.json +++ b/packages/catalog-model/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/packages/cli/src/commands/migrate/packageExports.ts b/packages/cli/src/commands/migrate/packageExports.ts index 51dc5c38bd..ff01f939f9 100644 --- a/packages/cli/src/commands/migrate/packageExports.ts +++ b/packages/cli/src/commands/migrate/packageExports.ts @@ -59,7 +59,11 @@ export async function command() { const typeEntries: Record = {}; for (const [path, value] of Object.entries(exp)) { - const newPath = path === '.' ? '*' : trimRelative(path); + // Main entry point does not need to be listed + if (path === '.') { + continue; + } + const newPath = trimRelative(path); if (typeof value === 'string') { typeEntries[newPath] = [trimRelative(value)]; diff --git a/packages/core-plugin-api/package.json b/packages/core-plugin-api/package.json index 781ebe37e1..d34d13dbe1 100644 --- a/packages/core-plugin-api/package.json +++ b/packages/core-plugin-api/package.json @@ -12,9 +12,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/packages/test-utils/package.json b/packages/test-utils/package.json index b278b00c14..192d58fd14 100644 --- a/packages/test-utils/package.json +++ b/packages/test-utils/package.json @@ -12,9 +12,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/app-backend/package.json b/plugins/app-backend/package.json index 78070cbf14..ae2c61311c 100644 --- a/plugins/app-backend/package.json +++ b/plugins/app-backend/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-aws/package.json b/plugins/catalog-backend-module-aws/package.json index 0273326e36..61cf55d546 100644 --- a/plugins/catalog-backend-module-aws/package.json +++ b/plugins/catalog-backend-module-aws/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-azure/package.json b/plugins/catalog-backend-module-azure/package.json index dd89aec185..ecaf9fb9cc 100644 --- a/plugins/catalog-backend-module-azure/package.json +++ b/plugins/catalog-backend-module-azure/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-bitbucket-cloud/package.json b/plugins/catalog-backend-module-bitbucket-cloud/package.json index 8fbff7d79b..5d6c80a0cb 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/package.json +++ b/plugins/catalog-backend-module-bitbucket-cloud/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-bitbucket-server/package.json b/plugins/catalog-backend-module-bitbucket-server/package.json index 1a82807288..811dfe9f10 100644 --- a/plugins/catalog-backend-module-bitbucket-server/package.json +++ b/plugins/catalog-backend-module-bitbucket-server/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-gerrit/package.json b/plugins/catalog-backend-module-gerrit/package.json index 33fcc4abcb..95978c2502 100644 --- a/plugins/catalog-backend-module-gerrit/package.json +++ b/plugins/catalog-backend-module-gerrit/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-github/api-report.md b/plugins/catalog-backend-module-github/api-report.md index 0ad377952a..e2b73d267b 100644 --- a/plugins/catalog-backend-module-github/api-report.md +++ b/plugins/catalog-backend-module-github/api-report.md @@ -7,7 +7,7 @@ import { AnalyzeOptions } from '@backstage/plugin-catalog-backend'; import { CatalogProcessor } from '@backstage/plugin-catalog-backend'; import { CatalogProcessorEmit } from '@backstage/plugin-catalog-backend'; import { Config } from '@backstage/config'; -import { Entity } from '@backstage/catalog-model/*'; +import { Entity } from '@backstage/catalog-model'; import { EntityProvider } from '@backstage/plugin-catalog-backend'; import { EntityProviderConnection } from '@backstage/plugin-catalog-backend'; import { EventParams } from '@backstage/plugin-events-node'; diff --git a/plugins/catalog-backend-module-github/package.json b/plugins/catalog-backend-module-github/package.json index a5899ced33..ccf1be3b2a 100644 --- a/plugins/catalog-backend-module-github/package.json +++ b/plugins/catalog-backend-module-github/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-gitlab/package.json b/plugins/catalog-backend-module-gitlab/package.json index 8d1ec70123..cbd07944d9 100644 --- a/plugins/catalog-backend-module-gitlab/package.json +++ b/plugins/catalog-backend-module-gitlab/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-incremental-ingestion/package.json b/plugins/catalog-backend-module-incremental-ingestion/package.json index 9479fd88e0..5f49cb8905 100644 --- a/plugins/catalog-backend-module-incremental-ingestion/package.json +++ b/plugins/catalog-backend-module-incremental-ingestion/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend-module-msgraph/package.json b/plugins/catalog-backend-module-msgraph/package.json index 99e5b0da35..1cc3855d77 100644 --- a/plugins/catalog-backend-module-msgraph/package.json +++ b/plugins/catalog-backend-module-msgraph/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-backend/alpha-api-report.md b/plugins/catalog-backend/alpha-api-report.md index 46be9a27df..df2fa3d2e9 100644 --- a/plugins/catalog-backend/alpha-api-report.md +++ b/plugins/catalog-backend/alpha-api-report.md @@ -6,8 +6,7 @@ import { BackendFeature } from '@backstage/backend-plugin-api'; import { ConditionalPolicyDecision } from '@backstage/plugin-permission-common'; import { Conditions } from '@backstage/plugin-permission-node'; -import { Entity } from '@backstage/catalog-model/*'; -import { Entity as Entity_2 } from '@backstage/catalog-model'; +import { Entity } from '@backstage/catalog-model'; import { PermissionCondition } from '@backstage/plugin-permission-common'; import { PermissionCriteria } from '@backstage/plugin-permission-common'; import { PermissionRule } from '@backstage/plugin-permission-node'; @@ -72,7 +71,7 @@ export const catalogConditions: Conditions<{ // @alpha export type CatalogPermissionRule< TParams extends PermissionRuleParams = PermissionRuleParams, -> = PermissionRule; +> = PermissionRule; // @alpha export const catalogPlugin: () => BackendFeature; @@ -89,13 +88,8 @@ export const createCatalogConditionalDecision: ( export const createCatalogPermissionRule: < TParams extends PermissionRuleParams = undefined, >( - rule: PermissionRule< - Entity_2, - EntitiesSearchFilter, - 'catalog-entity', - TParams - >, -) => PermissionRule; + rule: PermissionRule, +) => PermissionRule; // @public export type EntitiesSearchFilter = { diff --git a/plugins/catalog-backend/package.json b/plugins/catalog-backend/package.json index 47e678c012..17e9c9aa7c 100644 --- a/plugins/catalog-backend/package.json +++ b/plugins/catalog-backend/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-common/package.json b/plugins/catalog-common/package.json index 2c74307f1c..27b31d15ea 100644 --- a/plugins/catalog-common/package.json +++ b/plugins/catalog-common/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-node/package.json b/plugins/catalog-node/package.json index 7d186ad52c..6c888f342e 100644 --- a/plugins/catalog-node/package.json +++ b/plugins/catalog-node/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/catalog-react/package.json b/plugins/catalog-react/package.json index 955e63b425..e8f796a725 100644 --- a/plugins/catalog-react/package.json +++ b/plugins/catalog-react/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend-module-aws-sqs/package.json b/plugins/events-backend-module-aws-sqs/package.json index d68c77bb41..2e45015bce 100644 --- a/plugins/events-backend-module-aws-sqs/package.json +++ b/plugins/events-backend-module-aws-sqs/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend-module-azure/package.json b/plugins/events-backend-module-azure/package.json index a1314b2db7..a3acd37263 100644 --- a/plugins/events-backend-module-azure/package.json +++ b/plugins/events-backend-module-azure/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend-module-bitbucket-cloud/package.json b/plugins/events-backend-module-bitbucket-cloud/package.json index db85c32fad..ae006b1bce 100644 --- a/plugins/events-backend-module-bitbucket-cloud/package.json +++ b/plugins/events-backend-module-bitbucket-cloud/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend-module-gerrit/package.json b/plugins/events-backend-module-gerrit/package.json index 35a82b4fc5..a7aadf06dc 100644 --- a/plugins/events-backend-module-gerrit/package.json +++ b/plugins/events-backend-module-gerrit/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend-module-github/package.json b/plugins/events-backend-module-github/package.json index 7a7df507b7..966b7b3592 100644 --- a/plugins/events-backend-module-github/package.json +++ b/plugins/events-backend-module-github/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend-module-gitlab/package.json b/plugins/events-backend-module-gitlab/package.json index f95995473c..4e5e53771d 100644 --- a/plugins/events-backend-module-gitlab/package.json +++ b/plugins/events-backend-module-gitlab/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-backend/package.json b/plugins/events-backend/package.json index a0d4f9bf12..d779869e14 100644 --- a/plugins/events-backend/package.json +++ b/plugins/events-backend/package.json @@ -14,9 +14,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/events-node/package.json b/plugins/events-node/package.json index ef0cce170e..368e567930 100644 --- a/plugins/events-node/package.json +++ b/plugins/events-node/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/scaffolder-backend/package.json b/plugins/scaffolder-backend/package.json index 9ee87669ff..121a5c8ed0 100644 --- a/plugins/scaffolder-backend/package.json +++ b/plugins/scaffolder-backend/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/scaffolder-react/package.json b/plugins/scaffolder-react/package.json index 6907f8080e..14d25136e0 100644 --- a/plugins/scaffolder-react/package.json +++ b/plugins/scaffolder-react/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/scaffolder/api-report.md b/plugins/scaffolder/api-report.md index df1670e718..43cc657a03 100644 --- a/plugins/scaffolder/api-report.md +++ b/plugins/scaffolder/api-report.md @@ -6,7 +6,7 @@ /// import { ApiHolder } from '@backstage/core-plugin-api'; -import { ApiRef } from '@backstage/core-plugin-api/*'; +import { ApiRef } from '@backstage/core-plugin-api'; import { BackstagePlugin } from '@backstage/core-plugin-api'; import { ComponentType } from 'react'; import { createScaffolderFieldExtension as createScaffolderFieldExtension_2 } from '@backstage/plugin-scaffolder-react'; @@ -32,7 +32,6 @@ import { PathParams } from '@backstage/core-plugin-api'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; import { RouteRef } from '@backstage/core-plugin-api'; -import { RouteRef as RouteRef_2 } from '@backstage/core-plugin-api/*'; import { ScaffolderApi as ScaffolderApi_2 } from '@backstage/plugin-scaffolder-react'; import { ScaffolderDryRunOptions as ScaffolderDryRunOptions_2 } from '@backstage/plugin-scaffolder-react'; import { ScaffolderDryRunResponse as ScaffolderDryRunResponse_2 } from '@backstage/plugin-scaffolder-react'; @@ -316,7 +315,7 @@ export type ReviewStepProps = { }; // @public @deprecated (undocumented) -export const rootRouteRef: RouteRef_2; +export const rootRouteRef: RouteRef; // @public export type RouterProps = { diff --git a/plugins/scaffolder/package.json b/plugins/scaffolder/package.json index 46e8f436fd..15893b7ccb 100644 --- a/plugins/scaffolder/package.json +++ b/plugins/scaffolder/package.json @@ -15,9 +15,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "alpha": [ "src/alpha.ts" ], diff --git a/plugins/sonarqube-react/package.json b/plugins/sonarqube-react/package.json index 2f31d37007..80177d9e24 100644 --- a/plugins/sonarqube-react/package.json +++ b/plugins/sonarqube-react/package.json @@ -13,9 +13,6 @@ }, "typesVersions": { "*": { - "*": [ - "src/index.ts" - ], "package.json": [ "package.json" ] diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index cdbe839543..baf796b34c 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -7,7 +7,7 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { DiscoveryApi } from '@backstage/core-plugin-api'; -import { Entity } from '@backstage/catalog-model/*'; +import { Entity } from '@backstage/catalog-model'; import { FindingSummary } from '@backstage/plugin-sonarqube-react/alpha'; import { IdentityApi } from '@backstage/core-plugin-api'; import { InfoCardVariants } from '@backstage/core-components'; From d443f9ebba6b496c90b7fc446d11f5f02c175d22 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Sat, 4 Feb 2023 17:59:02 +0100 Subject: [PATCH 61/65] cli: always make package.json available in exports in published packages Signed-off-by: Patrik Oldsberg --- packages/cli/src/lib/packager/productionPack.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/lib/packager/productionPack.ts b/packages/cli/src/lib/packager/productionPack.ts index 3a74b68257..b91112216a 100644 --- a/packages/cli/src/lib/packager/productionPack.ts +++ b/packages/cli/src/lib/packager/productionPack.ts @@ -128,7 +128,7 @@ export async function revertProductionPack(packageDir: string) { // Remove any extra entrypoint backwards compatibility directories const entryPoints = readEntryPoints(pkg); for (const entryPoint of entryPoints) { - if (entryPoint.mount !== '.') { + if (entryPoint.mount !== '.' && SCRIPT_EXTS.includes(entryPoint.ext)) { await fs.remove(resolvePath(packageDir, entryPoint.name)); } } @@ -244,7 +244,11 @@ async function prepareExportsEntryPoints( } } - pkg.exports = outputExports; + if (pkg.exports) { + pkg.exports = outputExports; + // We treat package.json as a fixed export that is always available in the published package + pkg.exports['./package.json'] = './package.json'; + } if (compatibilityWriters.length > 0) { return async (targetDir: string) => { From 58814d6d4cd6d63462a75d3389fe5f78406e09ac Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Wed, 15 Feb 2023 16:45:49 +0100 Subject: [PATCH 62/65] fix stray imports Signed-off-by: Patrik Oldsberg --- packages/backend-defaults/src/CreateBackend.test.ts | 2 +- .../BitbucketCloudEntityProviderCatalogModule.test.ts | 5 +---- plugins/sonarqube/api-report.md | 4 ++-- plugins/sonarqube/dev/index.tsx | 2 +- plugins/sonarqube/src/api/SonarQubeClient.test.ts | 2 +- plugins/sonarqube/src/api/SonarQubeClient.ts | 2 +- plugins/sonarqube/src/api/types.ts | 2 +- .../sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx | 2 +- .../SonarQubeContentPage/SonarQubeContentPage.test.tsx | 2 -- plugins/sonarqube/src/plugin.ts | 2 +- plugins/todo-backend/src/service/TodoReaderService.ts | 2 +- 11 files changed, 11 insertions(+), 16 deletions(-) diff --git a/packages/backend-defaults/src/CreateBackend.test.ts b/packages/backend-defaults/src/CreateBackend.test.ts index cc6c93c0eb..8d56cd0986 100644 --- a/packages/backend-defaults/src/CreateBackend.test.ts +++ b/packages/backend-defaults/src/CreateBackend.test.ts @@ -21,7 +21,7 @@ import { createServiceRef, createSharedEnvironment, } from '@backstage/backend-plugin-api'; -import { mockServices } from '@backstage/backend-test-utils/alpha'; +import { mockServices } from '@backstage/backend-test-utils'; import { createBackend } from './CreateBackend'; const fooServiceRef = createServiceRef({ id: 'foo', scope: 'root' }); diff --git a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts index 13ad5dbf22..630c18b134 100644 --- a/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts +++ b/plugins/catalog-backend-module-bitbucket-cloud/src/service/BitbucketCloudEntityProviderCatalogModule.test.ts @@ -19,10 +19,7 @@ import { PluginTaskScheduler, TaskScheduleDefinition, } from '@backstage/backend-tasks'; -import { - startTestBackend, - mockServices, -} from '@backstage/backend-test-utils/alpha'; +import { startTestBackend, mockServices } from '@backstage/backend-test-utils'; import { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha'; import { eventsExtensionPoint } from '@backstage/plugin-events-node/alpha'; import { Duration } from 'luxon'; diff --git a/plugins/sonarqube/api-report.md b/plugins/sonarqube/api-report.md index baf796b34c..db3f38e31d 100644 --- a/plugins/sonarqube/api-report.md +++ b/plugins/sonarqube/api-report.md @@ -8,10 +8,10 @@ import { BackstagePlugin } from '@backstage/core-plugin-api'; import { DiscoveryApi } from '@backstage/core-plugin-api'; import { Entity } from '@backstage/catalog-model'; -import { FindingSummary } from '@backstage/plugin-sonarqube-react/alpha'; +import { FindingSummary } from '@backstage/plugin-sonarqube-react'; import { IdentityApi } from '@backstage/core-plugin-api'; import { InfoCardVariants } from '@backstage/core-components'; -import { SonarQubeApi } from '@backstage/plugin-sonarqube-react/alpha'; +import { SonarQubeApi } from '@backstage/plugin-sonarqube-react'; // @public (undocumented) export type DuplicationRating = { diff --git a/plugins/sonarqube/dev/index.tsx b/plugins/sonarqube/dev/index.tsx index 98c48c56fc..8d38c7314a 100644 --- a/plugins/sonarqube/dev/index.tsx +++ b/plugins/sonarqube/dev/index.tsx @@ -24,7 +24,7 @@ import { FindingSummary, SonarQubeApi, sonarQubeApiRef, -} from '@backstage/plugin-sonarqube-react/alpha'; +} from '@backstage/plugin-sonarqube-react'; import { SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage/plugin-sonarqube-react'; const entity = (name?: string) => diff --git a/plugins/sonarqube/src/api/SonarQubeClient.test.ts b/plugins/sonarqube/src/api/SonarQubeClient.test.ts index 441263afc8..592f08457f 100644 --- a/plugins/sonarqube/src/api/SonarQubeClient.test.ts +++ b/plugins/sonarqube/src/api/SonarQubeClient.test.ts @@ -21,7 +21,7 @@ import { SonarQubeClient } from './index'; import { InstanceUrlWrapper, FindingsWrapper } from './types'; import { UrlPatternDiscovery } from '@backstage/core-app-api'; import { IdentityApi } from '@backstage/core-plugin-api'; -import { FindingSummary } from '@backstage/plugin-sonarqube-react/alpha'; +import { FindingSummary } from '@backstage/plugin-sonarqube-react'; const server = setupServer(); diff --git a/plugins/sonarqube/src/api/SonarQubeClient.ts b/plugins/sonarqube/src/api/SonarQubeClient.ts index 94d7a96243..14c7936e92 100644 --- a/plugins/sonarqube/src/api/SonarQubeClient.ts +++ b/plugins/sonarqube/src/api/SonarQubeClient.ts @@ -19,7 +19,7 @@ import { FindingSummary, Metrics, SonarQubeApi, -} from '@backstage/plugin-sonarqube-react/alpha'; +} from '@backstage/plugin-sonarqube-react'; import { InstanceUrlWrapper, FindingsWrapper } from './types'; import { DiscoveryApi, IdentityApi } from '@backstage/core-plugin-api'; diff --git a/plugins/sonarqube/src/api/types.ts b/plugins/sonarqube/src/api/types.ts index f3ad690261..29b7e7ca54 100644 --- a/plugins/sonarqube/src/api/types.ts +++ b/plugins/sonarqube/src/api/types.ts @@ -17,7 +17,7 @@ import { MetricKey as NonDeprecatedMetricKey, SonarUrlProcessorFunc as NonDeprecatedSonarUrlProcessorFunc, -} from '@backstage/plugin-sonarqube-react/alpha'; +} from '@backstage/plugin-sonarqube-react'; export interface InstanceUrlWrapper { instanceUrl: string; diff --git a/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx b/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx index 3965c03b69..932641e48d 100644 --- a/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx +++ b/plugins/sonarqube/src/components/SonarQubeCard/SonarQubeCard.tsx @@ -18,7 +18,7 @@ import { useEntity } from '@backstage/plugin-catalog-react'; import { sonarQubeApiRef, useProjectInfo, -} from '@backstage/plugin-sonarqube-react/alpha'; +} from '@backstage/plugin-sonarqube-react'; import { SONARQUBE_PROJECT_KEY_ANNOTATION } from '@backstage/plugin-sonarqube-react'; import { Chip, Grid } from '@material-ui/core'; import { makeStyles } from '@material-ui/core/styles'; diff --git a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx index 91e85f9f25..0bf5f04640 100644 --- a/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx +++ b/plugins/sonarqube/src/components/SonarQubeContentPage/SonarQubeContentPage.test.tsx @@ -20,8 +20,6 @@ import React from 'react'; import { SonarQubeApi, sonarQubeApiRef, -} from '@backstage/plugin-sonarqube-react/alpha'; -import { isSonarQubeAvailable, SONARQUBE_PROJECT_KEY_ANNOTATION, } from '@backstage/plugin-sonarqube-react'; diff --git a/plugins/sonarqube/src/plugin.ts b/plugins/sonarqube/src/plugin.ts index 8da690abbf..c66d8c4e96 100644 --- a/plugins/sonarqube/src/plugin.ts +++ b/plugins/sonarqube/src/plugin.ts @@ -22,7 +22,7 @@ import { discoveryApiRef, identityApiRef, } from '@backstage/core-plugin-api'; -import { sonarQubeApiRef } from '@backstage/plugin-sonarqube-react/alpha'; +import { sonarQubeApiRef } from '@backstage/plugin-sonarqube-react'; /** @public */ export const sonarQubePlugin = createPlugin({ diff --git a/plugins/todo-backend/src/service/TodoReaderService.ts b/plugins/todo-backend/src/service/TodoReaderService.ts index c5fa0aa70b..6ce38709f1 100644 --- a/plugins/todo-backend/src/service/TodoReaderService.ts +++ b/plugins/todo-backend/src/service/TodoReaderService.ts @@ -25,7 +25,7 @@ import { createServiceRef, ServiceRef, } from '@backstage/backend-plugin-api'; -import { catalogServiceRef } from '@backstage/plugin-catalog-node'; +import { catalogServiceRef } from '@backstage/plugin-catalog-node/alpha'; import { TodoReader, todoReaderServiceRef } from '../lib'; import { ListTodosRequest, ListTodosResponse, TodoService } from './types'; From 9913f61e7a40fe598c6efffc46ab04524c12a2d6 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 21 Feb 2023 14:56:26 +0100 Subject: [PATCH 63/65] todo-backend: mark public API as public Signed-off-by: Patrik Oldsberg --- plugins/todo-backend/api-report.md | 4 ++-- plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts | 2 +- plugins/todo-backend/src/plugin.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugins/todo-backend/api-report.md b/plugins/todo-backend/api-report.md index dabe2fbfd4..6db1e012e9 100644 --- a/plugins/todo-backend/api-report.md +++ b/plugins/todo-backend/api-report.md @@ -90,7 +90,7 @@ export type TodoParserResult = { lineNumber: number; }; -// @alpha +// @public export const todoPlugin: () => BackendFeature; // @public (undocumented) @@ -118,7 +118,7 @@ export type TodoReaderServiceOptions = { defaultPageSize?: number; }; -// @alpha (undocumented) +// @public (undocumented) export const todoReaderServiceRef: ServiceRef; // @public (undocumented) diff --git a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts index 2804da98cc..276d176efb 100644 --- a/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts +++ b/plugins/todo-backend/src/lib/TodoReader/TodoScmReader.ts @@ -174,7 +174,7 @@ export class TodoScmReader implements TodoReader { } /** - * @alpha + * @public */ export const todoReaderServiceRef = createServiceRef({ id: 'todo.todoReader', diff --git a/plugins/todo-backend/src/plugin.ts b/plugins/todo-backend/src/plugin.ts index cbb581f336..b9a73a84ee 100644 --- a/plugins/todo-backend/src/plugin.ts +++ b/plugins/todo-backend/src/plugin.ts @@ -24,7 +24,7 @@ import { createRouter } from './service/router'; /** * The Todos plugin is responsible for aggregating todo comments within source. - * @alpha + * @public */ export const todoPlugin = createBackendPlugin({ pluginId: 'todo-backend', From aa5ed47b3999faea75fc128d1ec5ce200fbbaea4 Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 21 Feb 2023 15:04:15 +0100 Subject: [PATCH 64/65] scaffolder-react: fix API report warning Signed-off-by: Patrik Oldsberg --- plugins/scaffolder-react/alpha-api-report.md | 5 +---- .../components/TemplateOutputs/DefaultTemplateOutputs.tsx | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/scaffolder-react/alpha-api-report.md b/plugins/scaffolder-react/alpha-api-report.md index 75d2e4fd79..ad44cd3707 100644 --- a/plugins/scaffolder-react/alpha-api-report.md +++ b/plugins/scaffolder-react/alpha-api-report.md @@ -22,6 +22,7 @@ import { PropsWithChildren } from 'react'; import { default as React_2 } from 'react'; import { ReactNode } from 'react'; import { RJSFSchema } from '@rjsf/utils'; +import { ScaffolderTaskOutput } from '@backstage/plugin-scaffolder-react'; import { SetStateAction } from 'react'; import { TemplateEntityV1beta3 } from '@backstage/plugin-scaffolder-common'; import { TemplateParameterSchema } from '@backstage/plugin-scaffolder-react'; @@ -217,9 +218,5 @@ export type WorkflowProps = { | 'layouts' >; -// Warnings were encountered during analysis: -// -// src/next/components/TemplateOutputs/DefaultTemplateOutputs.d.ts:9:5 - (ae-forgotten-export) The symbol "ScaffolderTaskOutput" needs to be exported by the entry point alpha.d.ts - // (No @packageDocumentation comment for this package) ``` diff --git a/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx b/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx index 5fbd3a5142..4d908461b0 100644 --- a/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx +++ b/plugins/scaffolder-react/src/next/components/TemplateOutputs/DefaultTemplateOutputs.tsx @@ -16,7 +16,7 @@ import React from 'react'; import { Box, Paper } from '@material-ui/core'; import { LinkOutputs } from './LinkOutputs'; -import { ScaffolderTaskOutput } from '../../../api'; +import { ScaffolderTaskOutput } from '@backstage/plugin-scaffolder-react'; /** * The DefaultOutputs renderer for the scaffolder task output From bf2f2fa90ae51a54a1d9f06cea9face0471c228b Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 21 Feb 2023 15:28:22 +0100 Subject: [PATCH 65/65] repo-tools: add missing types dep Signed-off-by: Patrik Oldsberg --- packages/repo-tools/package.json | 1 + packages/repo-tools/src/lib/entryPoints.ts | 2 +- yarn.lock | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/repo-tools/package.json b/packages/repo-tools/package.json index 5a5683dff9..0fc5cc3554 100644 --- a/packages/repo-tools/package.json +++ b/packages/repo-tools/package.json @@ -45,6 +45,7 @@ }, "devDependencies": { "@backstage/cli": "workspace:^", + "@backstage/types": "workspace:^", "@types/is-glob": "^4.0.2", "@types/mock-fs": "^4.13.0", "mock-fs": "^5.1.0" diff --git a/packages/repo-tools/src/lib/entryPoints.ts b/packages/repo-tools/src/lib/entryPoints.ts index df5633c103..4a412d410b 100644 --- a/packages/repo-tools/src/lib/entryPoints.ts +++ b/packages/repo-tools/src/lib/entryPoints.ts @@ -15,7 +15,7 @@ */ import { extname } from 'path'; -import { JsonObject } from '@backstage/types'; +import type { JsonObject } from '@backstage/types'; export function getPackageExportNames(pkg: JsonObject): string[] | undefined { if (pkg.exports && typeof pkg.exports !== 'string') { diff --git a/yarn.lock b/yarn.lock index aa8558da37..0438503db3 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8618,6 +8618,7 @@ __metadata: "@backstage/cli": "workspace:^" "@backstage/cli-common": "workspace:^" "@backstage/errors": "workspace:^" + "@backstage/types": "workspace:^" "@manypkg/get-packages": ^1.1.3 "@microsoft/api-documenter": ^7.19.27 "@microsoft/api-extractor": ^7.33.7