Initial release manifest package

Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
Johan Haals
2022-01-19 10:30:12 +01:00
parent 2c82f6b5dd
commit 476bb94115
13 changed files with 293 additions and 9 deletions
+3 -1
View File
@@ -6,7 +6,9 @@
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": [],
"ignore": [
"@backstage/release-manifest"
],
"___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH": {
"onlyUpdatePeerDependentsWhenOutOfRange": true
}
+5
View File
@@ -341,6 +341,11 @@ export function registerCommands(program: CommanderStatic) {
'--pattern <glob>',
'Override glob for matching packages to upgrade',
)
.option(
'--release-line <main|next>',
'Bump to the latest version of a specific release line',
'main',
)
.description('Bump Backstage packages to the latest versions')
.action(lazy(() => import('./versions/bump').then(m => m.default)));
+20 -7
View File
@@ -60,7 +60,7 @@ export default async (cmd: Command) => {
console.log(`Using custom pattern glob ${pattern}`);
}
const findTargetVersion = createVersionFinder();
const findTargetVersion = createVersionFinder(cmd.releaseLine);
// First we discover all Backstage dependencies within our own repo
const dependencyMap = await mapDependencies(paths.targetDir, pattern);
@@ -284,7 +284,9 @@ export default async (cmd: Command) => {
}
};
function createVersionFinder() {
function createVersionFinder(releaseLine = 'latest') {
// The main release line is just an alias for latest
const distTag = releaseLine === 'main' ? 'latest' : releaseLine;
const found = new Map<string, string>();
return async function findTargetVersion(name: string) {
@@ -295,12 +297,23 @@ function createVersionFinder() {
console.log(`Checking for updates of ${name}`);
const info = await fetchPackageInfo(name);
const latest = info['dist-tags'].latest;
if (!latest) {
throw new Error(`No latest version found for ${name}`);
const latestVersion = info['dist-tags'].latest;
if (!latestVersion) {
throw new Error(`No target 'latest' version found for ${name}`);
}
found.set(name, latest);
return latest;
if (distTag === 'latest') {
found.set(name, latestVersion);
return latestVersion;
}
const taggedVersion = info['dist-tags'][distTag];
if (!taggedVersion) {
found.set(name, latestVersion);
return latestVersion;
}
// Take release from latest of next release is older
found.set(name, targetVersion);
return targetVersion;
};
}
+1 -1
View File
@@ -28,7 +28,7 @@ const DEP_TYPES = [
// Package data as returned by `yarn info`
export type YarnInfoInspectData = {
name: string;
'dist-tags': { latest: string };
'dist-tags': Record<string, string>;
versions: string[];
time: { [version: string]: string };
};
+5
View File
@@ -0,0 +1,5 @@
module.exports = {
extends: [
require.resolve('@backstage/release-manifest/config/eslint.backend'),
],
};
+1
View File
@@ -0,0 +1 @@
# @backstage/release-manifest
+3
View File
@@ -0,0 +1,3 @@
# @backstage/release-manifest
This package provides a mapping between a Backstage release and the packages included in that release.
+12
View File
@@ -0,0 +1,12 @@
## API Report File for "@backstage/release-manifest"
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
```ts
// Warning: (ae-missing-release-tag) "releaseManifest" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
export const releaseManifest: {
'@backstage/cli': string;
};
```
+41
View File
@@ -0,0 +1,41 @@
{
"name": "@backstage/release-manifest",
"description": "Package information for ",
"version": "0.0.0",
"private": false,
"main": "src/index.ts",
"types": "src/index.ts",
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
"types": "dist/index.d.ts"
},
"homepage": "https://backstage.io",
"repository": {
"type": "git",
"url": "https://github.com/backstage/backstage",
"directory": "packages/release-manifest"
},
"keywords": [
"backstage"
],
"license": "Apache-2.0",
"scripts": {
"build": "backstage-cli build --outputs cjs,types",
"lint": "backstage-cli lint",
"test": "backstage-cli test",
"prepack": "backstage-cli prepack",
"postpack": "backstage-cli postpack",
"clean": "backstage-cli clean"
},
"dependencies": {
"fs-extra": "^10.0.0"
},
"devDependencies": {
"@types/jest": "^26.0.7",
"@types/node": "^14.14.32"
},
"files": [
"dist"
]
}
+115
View File
@@ -0,0 +1,115 @@
app-defaults=1.0.0
backend-common=1.0.0
backend-tasks=1.0.0
backend-test-utils=1.0.0
catalog-client=1.0.0
catalog-model=1.0.0
cli-common=1.0.0
cli=1.0.0
codemods=1.0.0
config-loader=1.0.0
config=1.0.0
core-app-api=1.0.0
core-components=1.0.0
core-plugin-api=1.0.0
create-app=1.0.0
dev-utils=1.0.0
errors=1.0.0
integration-react=1.0.0
integration=1.0.0
plugin-airbrake=1.0.0
plugin-allure=1.0.0
plugin-analytics-module-ga=1.0.0
plugin-apache-airflow=1.0.0
plugin-api-docs=1.0.0
plugin-app-backend=1.0.0
plugin-auth-backend=1.0.0
plugin-azure-devops-backend=1.0.0
plugin-azure-devops-common=1.0.0
plugin-azure-devops=1.0.0
plugin-badges-backend=1.0.0
plugin-badges=1.0.0
plugin-bazaar-backend=1.0.0
plugin-bazaar=1.0.0
plugin-bitrise=1.0.0
plugin-catalog-backend-module-ldap=1.0.0
plugin-catalog-backend-module-msgraph=1.0.0
plugin-catalog-backend=1.0.0
plugin-catalog-common=1.0.0
plugin-catalog-graph=1.0.0
plugin-catalog-graphql=1.0.0
plugin-catalog-import=1.0.0
plugin-catalog-react=1.0.0
plugin-catalog=1.0.0
plugin-circleci=1.0.0
plugin-cloudbuild=1.0.0
plugin-code-coverage-backend=1.0.0
plugin-code-coverage=1.0.0
plugin-config-schema=1.0.0
plugin-cost-insights=1.0.0
plugin-explore-react=1.0.0
plugin-explore=1.0.0
plugin-firehydrant=1.0.0
plugin-fossa=1.0.0
plugin-gcp-projects=1.0.0
plugin-git-release-manager=1.0.0
plugin-github-actions=1.0.0
plugin-github-deployments=1.0.0
plugin-gitops-profiles=1.0.0
plugin-gocd=1.0.0
plugin-graphiql=1.0.0
plugin-graphql-backend=1.0.0
plugin-home=1.0.0
plugin-ilert=1.0.0
plugin-jenkins-backend=1.0.0
plugin-jenkins=1.0.0
plugin-kafka-backend=1.0.0
plugin-kafka=1.0.0
plugin-kubernetes-backend=1.0.0
plugin-kubernetes-common=1.0.0
plugin-kubernetes=1.0.0
plugin-lighthouse=1.0.0
plugin-newrelic-dashboard=1.0.0
plugin-newrelic=1.0.0
plugin-org=1.0.0
plugin-pagerduty=1.0.0
plugin-permission-backend=1.0.0
plugin-permission-common=1.0.0
plugin-permission-node=1.0.0
plugin-permission-react=1.0.0
plugin-proxy-backend=1.0.0
plugin-rollbar-backend=1.0.0
plugin-rollbar=1.0.0
plugin-scaffolder-backend-module-cookiecutter=1.0.0
plugin-scaffolder-backend-module-rails=1.0.0
plugin-scaffolder-backend-module-yeoman=1.0.0
plugin-scaffolder-backend=1.0.0
plugin-scaffolder-common=1.0.0
plugin-scaffolder=1.0.0
plugin-search-backend-module-elasticsearch=1.0.0
plugin-search-backend-module-pg=1.0.0
plugin-search-backend-node=1.0.0
plugin-search-backend=1.0.0
plugin-search=1.0.0
plugin-sentry=1.0.0
plugin-shortcuts=1.0.0
plugin-sonarqube=1.0.0
plugin-splunk-on-call=1.0.0
plugin-tech-insights-backend-module-jsonfc=1.0.0
plugin-tech-insights-backend=1.0.0
plugin-tech-insights-common=1.0.0
plugin-tech-insights-node=1.0.0
plugin-tech-insights=1.0.0
plugin-tech-radar=1.0.0
plugin-techdocs-backend=1.0.0
plugin-techdocs=1.0.0
plugin-todo-backend=1.0.0
plugin-todo=1.0.0
plugin-user-settings=1.0.0
plugin-xcmetrics=1.0.0
search-common=1.0.0
techdocs-common=1.0.0
test-utils=1.0.0
theme=1.0.0
types=1.0.0
version-bridge=1.0.0
+21
View File
@@ -0,0 +1,21 @@
/*
* 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.
*/
/**
* Contains mapping between Backstage release and package versions.
*
* @packageDocumentation
*/
@@ -0,0 +1,9 @@
import { getRelease } from './manifest';
describe('Get Packages', () => {
it('should return a list of packages in a release', async () => {
const pkgs = await getRelease('1.0.0');
console.log(pkgs);
expect(pkgs.size).toBe(2);
});
});
+57
View File
@@ -0,0 +1,57 @@
/*
* 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.
*/
/**
* Mapping between a Backstage release and individual package versions.
* @public
*/
import { resolvePackagePath } from '@backstage/backend-common';
import fs from 'fs-extra';
import path from 'path';
const RELEASE_DIR = resolvePackagePath(
'@backstage/release-manifest',
'releases',
);
export type ReleaseManifest = {
packages: Map<string, string>;
};
export async function getRelease(version: string): Promise<ReleaseManifest> {
const pkgs = new Map<string, string>();
try {
const content = await fs.readFile(path.resolve(RELEASE_DIR, `${version}`));
for (const line of content.toString().split('\n')) {
const [pkg, version] = line.split('=');
pkgs.set(pkg, version);
}
} catch (e) {
throw new Error(`No release found for ${version} version`);
}
return { packages: pkgs };
}
export type ReleaseList = {
items: {
version: string;
}[];
};
export async function listReleases(): Promise<ReleaseList> {
const files = await fs.readdir(RELEASE_DIR);
return { items: files.map(file => ({ version: file })) };
}