Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions tools/js-sdk-release-tools/src/common/migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { logger } from "../utils/logger";
import { runCommand, runCommandOptions } from "./utils";
import { getNpmPackageInfo } from "./npmUtils";
import { ensureDir } from "fs-extra";
import { posix } from "path";

// TODO: remove when emitter is ready
export async function migratePackage(packageDirectory: string): Promise<void> {
const info = await getNpmPackageInfo(packageDirectory);
// Note: bug in migration tool: failed to create review directory
await ensureDir(posix.join(packageDirectory, 'review'));
await runCommand(
"pnpm",
`exec dev-tool admin migrate-package --package-name=${info.name}`.split(
" "
),
{
...runCommandOptions,
cwd: packageDirectory,
}
);

logger.info(`Start to rush update after migration.`);
await runCommand(`node`, ['common/scripts/install-run-rush.js', 'update'], runCommandOptions, false);
logger.info(`Rush update successfully.`);

logger.info(`Migrated package '${info.name}' successfully`);
}
5 changes: 4 additions & 1 deletion tools/js-sdk-release-tools/src/common/rushUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { runCommand, runCommandOptions } from './utils';
import { glob } from 'glob';
import { logger } from '../utils/logger';
import unixify from 'unixify';
import { migratePackage } from './migration';

interface ProjectItem {
packageName: string;
Expand Down Expand Up @@ -65,7 +66,7 @@ export async function buildPackage(
rushxScript: string
) {
const relativePackageDirectoryToSdkRoot = relative(normalize(options.sdkRepoRoot), normalize(packageDirectory));
logger.info(`Start building package in '${relativePackageDirectoryToSdkRoot}'.`);
logger.info(`Start to build package in '${relativePackageDirectoryToSdkRoot}'.`);

const { name } = await getNpmPackageInfo(relativePackageDirectoryToSdkRoot);
await updateRushJson({
Expand All @@ -78,6 +79,8 @@ export async function buildPackage(
await runCommand(`node`, [rushScript, 'update'], runCommandOptions, false);
logger.info(`Rush update successfully.`);

await migratePackage(packageDirectory);

logger.info(`Start to build package '${name}'.`);
await runCommand('node', [rushScript, 'build', '-t', name, '--verbose'], runCommandOptions);
const apiViewContext = await addApiViewInfo(packageDirectory, options.sdkRepoRoot, packageResult);
Expand Down
4 changes: 4 additions & 0 deletions tools/js-sdk-release-tools/src/hlc/generateMgmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {getOutputPackageInfo} from "../utils/getOutputPackageInfo";
import {getReleaseTool} from "./utils/getReleaseTool";
import { addApiViewInfo } from "../utils/addApiViewInfo";
import { defaultChildProcessTimeout } from '../common/utils'
import { migratePackage } from "../common/migration";

export async function generateMgmt(options: {
sdkRepo: string,
Expand Down Expand Up @@ -106,6 +107,9 @@ export async function generateMgmt(options: {

logger.info(`Start to run command: 'rush update'.`);
execSync('node common/scripts/install-run-rush.js update', {stdio: 'inherit'});

await migratePackage(packagePath);

logger.info(`Start to run command: 'rush build -t ${packageName}', that builds generated codes, except test and sample, which may be written manually.`);
execSync(`node common/scripts/install-run-rush.js build -t ${packageName}`, {stdio: 'inherit'});
logger.info('Start to generate changelog and bump version...');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { defaultChildProcessTimeout, getGeneratedPackageDirectory } from "../../
import { remove } from 'fs-extra';
import { generateChangelogAndBumpVersion } from "../../common/changlog/automaticGenerateChangeLogAndBumpVersion";
import { updateChangelogResult } from "../../common/packageResultUtils";
import { migratePackage } from "../../common/migration";

export async function generateRLCInPipeline(options: {
sdkRepo: string;
Expand Down Expand Up @@ -234,9 +235,12 @@ export async function generateRLCInPipeline(options: {
outputPackageInfo.packageFolder = relativePackagePath;
}
}

logger.info(`Start to update rush.`);
execSync('node common/scripts/install-run-rush.js update', {stdio: 'inherit'});

await migratePackage(packagePath);

logger.info(`Start to build '${packageName}', except for tests and samples, which may be written manually.`);
// To build generated codes except test and sample, we need to change tsconfig.json.
execSync(`node common/scripts/install-run-rush.js build -t ${packageName} --verbose`, {stdio: 'inherit'});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { load } from '@npmcli/package-json';
export async function updatePackageVersion(packageDirectory: string, version: string): Promise<void> {
const packageJson = await load(packageDirectory);
packageJson.content.version = version;
packageJson.save();
await packageJson.save();
}

export async function generateTypeScriptCodeFromTypeSpec(
Expand Down
Loading