Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add downgrade logic for branch in DocLinkService #3483

Merged
Next Next commit
feature: patch pkg.branch when needed
Signed-off-by: suzhou <suzhou@amazon.com>
  • Loading branch information
SuZhou-Joe committed Feb 22, 2023
commit 9df87a56d846d677032d6e56eb0db3820d2db0a0
13 changes: 12 additions & 1 deletion src/dev/build/tasks/create_package_json_task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

import { copyWorkspacePackages } from '@osd/pm';
import { parse } from 'semver';

import { read, write, Task } from '../lib';

Expand All @@ -37,14 +38,24 @@ export const CreatePackageJson: Task = {

async run(config, log, build) {
const pkg = config.getOpenSearchDashboardsPkg();
/**
* OpenSearch server has a logic that if the pkg.branch is "main",
* set the docVersion to latest. So here we exclude main.
*/
const semverResult = parse(pkg.version);
const shouldPatch = semverResult && pkg.branch !== 'main';
const branch = shouldPatch ? `${semverResult.major}.${semverResult.minor}` : pkg.branch;
if (shouldPatch) {
log.info(`Patch branch property: ${branch}`);
}

const newPkg = {
name: pkg.name,
private: true,
description: pkg.description,
keywords: pkg.keywords,
version: config.getBuildVersion(),
branch: pkg.branch,
branch,
build: {
number: config.getBuildNumber(),
sha: config.getBuildSha(),
Expand Down