cli,cli-node: remove support for alphaTypes/betaTypes

Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
Patrik Oldsberg
2023-10-22 11:01:13 +02:00
parent 4e36abef14
commit 8db5c3cd7a
4 changed files with 7 additions and 51 deletions
+6
View File
@@ -0,0 +1,6 @@
---
'@backstage/cli-node': minor
'@backstage/cli': minor
---
Removed support for the `publishConfig.alphaTypes` and `.betaTypes` fields that were used together with `--experimental-type-build` to generate `/alpha` and `/beta` entry points. Use the `exports` field to achieve this instead.
-2
View File
@@ -53,8 +53,6 @@ export interface BackstagePackageJson {
access?: 'public' | 'restricted';
directory?: string;
registry?: string;
alphaTypes?: string;
betaTypes?: string;
};
// (undocumented)
scripts?: {
@@ -56,8 +56,6 @@ export interface BackstagePackageJson {
access?: 'public' | 'restricted';
directory?: string;
registry?: string;
alphaTypes?: string;
betaTypes?: string;
};
dependencies?: {
@@ -23,7 +23,7 @@ import { readEntryPoints } from '../entryPoints';
const PKG_PATH = 'package.json';
const PKG_BACKUP_PATH = 'package.json-prepack';
const SKIPPED_KEYS = ['access', 'registry', 'tag', 'alphaTypes', 'betaTypes'];
const SKIPPED_KEYS = ['access', 'registry', 'tag'];
const SCRIPT_EXTS = ['.js', '.jsx', '.ts', '.tsx'];
interface ProductionPackOptions {
@@ -42,14 +42,6 @@ export async function productionPack(options: ProductionPackOptions) {
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
const writeCompatibilityEntryPoints = await prepareExportsEntryPoints(
pkg,
@@ -99,12 +91,6 @@ export async function productionPack(options: ProductionPackOptions) {
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);
}
if (writeCompatibilityEntryPoints) {
await writeCompatibilityEntryPoints(targetDir ?? packageDir);
}
@@ -118,12 +104,6 @@ export async function revertProductionPack(packageDir: string) {
// 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);
@@ -140,32 +120,6 @@ export async function revertProductionPack(packageDir: string) {
}
}
function resolveEntrypoint(pkg: any, name: string) {
const targetEntry = pkg.publishConfig[name] || pkg[name];
return targetEntry && posixPath.join('..', targetEntry);
}
// Writes e.g. alpha/package.json
async function writeReleaseStageEntrypoint(
pkg: BackstagePackageJson,
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: posixPath.join('..', pkg.publishConfig![`${stage}Types`]!),
},
{ encoding: 'utf8', spaces: 2 },
);
}
const EXPORT_MAP = {
import: '.esm.js',
require: '.cjs.js',