From e51f9ea290c4707d58e86b3a32b34d40bded0bf7 Mon Sep 17 00:00:00 2001 From: Joel Mut Date: Fri, 1 Nov 2024 11:18:42 -0300 Subject: [PATCH 1/2] Fix workspaces for update-versions script --- libraries/botbuilder-repo-utils/src/package.ts | 2 +- libraries/botbuilder-repo-utils/src/updateVersions.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/botbuilder-repo-utils/src/package.ts b/libraries/botbuilder-repo-utils/src/package.ts index 089f632cd1..afcbdc1913 100644 --- a/libraries/botbuilder-repo-utils/src/package.ts +++ b/libraries/botbuilder-repo-utils/src/package.ts @@ -11,7 +11,7 @@ export interface Package { deprecated?: boolean; internal?: boolean; - workspaces?: string[]; + workspaces?: { packages: string[] }; dependencies?: Record; devDependencies?: Record; diff --git a/libraries/botbuilder-repo-utils/src/updateVersions.ts b/libraries/botbuilder-repo-utils/src/updateVersions.ts index 5687a765cc..8b5eddb247 100644 --- a/libraries/botbuilder-repo-utils/src/updateVersions.ts +++ b/libraries/botbuilder-repo-utils/src/updateVersions.ts @@ -95,7 +95,7 @@ export const command = (argv: string[], quiet = false) => async (): Promise>( From 4e6edad318e97760be488a1f2fe9ee8600d5ead1 Mon Sep 17 00:00:00 2001 From: Joel Mut Date: Fri, 1 Nov 2024 13:00:12 -0300 Subject: [PATCH 2/2] Add unit test --- .../tests/updateVersions.test.ts | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/libraries/botbuilder-repo-utils/tests/updateVersions.test.ts b/libraries/botbuilder-repo-utils/tests/updateVersions.test.ts index 7a18656108..6121beefca 100644 --- a/libraries/botbuilder-repo-utils/tests/updateVersions.test.ts +++ b/libraries/botbuilder-repo-utils/tests/updateVersions.test.ts @@ -169,7 +169,7 @@ describe('updateVersions', function () { dependsOn?: string[]; }>, args: string[] = [], - { commitSha = '' } = {} + { commitSha = '' } = {}, ) => { const root = 'root'; @@ -200,7 +200,7 @@ describe('updateVersions', function () { .withArgs(path.join(root, 'package.json')) .resolves({ version: packageVersion, - workspaces: workspacePaths.map((workspace) => path.posix.join(...workspace.relPath)), + workspaces: { packages: workspacePaths.map((workspace) => path.posix.join(...workspace.relPath)) }, }); sandbox @@ -219,14 +219,14 @@ describe('updateVersions', function () { deprecated: workspace.deprecated, dependencies: (workspace.dependsOn ?? []).reduce( (acc, name) => ({ ...acc, [name]: dummyVersion }), - {} + {}, ), }); let packageMatch = sinon.match.hasOwn('version', workspace.expectedVersion); if (workspace.expectedDependencies) { packageMatch = packageMatch.and( - sinon.match.hasOwn('dependencies', sinon.match(workspace.expectedDependencies)) + sinon.match.hasOwn('dependencies', sinon.match(workspace.expectedDependencies)), ); } @@ -300,7 +300,7 @@ describe('updateVersions', function () { }, }, ], - [expectedVersion] + [expectedVersion], ); }); @@ -339,8 +339,37 @@ describe('updateVersions', function () { }, ], ['--buildLabel', 'dev', '--git', 'true', '--date', dateFormat], - { commitSha: 'COMMIT' } + { commitSha: 'COMMIT' }, ); }); + + it('runs properly', async function () { + const writeFileStub = sandbox.stub(file, 'writeJsonFile').returns(Promise.resolve()); + const version = '4.24.0'; + await command( + [ + version, + '--buildLabel', + 'dev', + '--internal', + 'internal', + '--preview', + 'preview', + '--deprecated', + 'deprecated', + '--date', + 'YYYYMMDD', + '--git', + 'false', + ], + true, + )(); + + assert.ok(writeFileStub.called); + const packagesAssertion = (writeFileStub.args as [string, Package][]) + .filter(([, pkg]) => !pkg.private) + .every(([, pkg]) => pkg.version.startsWith(version)); + assert.ok(packagesAssertion); + }); }); });