Skip to content

Commit 754b02d

Browse files
fix(release): check-pipeline-after-comments (#325)
Co-authored-by: Shreyas Sharma <shreysh2@cisco.com>
1 parent 4b87ffd commit 754b02d

File tree

14 files changed

+75
-120
lines changed

14 files changed

+75
-120
lines changed

.circleci/config.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ jobs:
112112
# execute the jobs in an orderly manner
113113
workflows:
114114
setup_test_release:
115-
# Runs on PRs and pushes to master
116115
jobs:
117116
- install
118117
- linter:
@@ -149,4 +148,4 @@ workflows:
149148
- unit_tests
150149
filters:
151150
branches:
152-
only: eft
151+
only: feat/cc-widgets

.releaserc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
"branches": [
33
"master",
44
{
5-
"name": "eft",
6-
"prerelease": "eft"
5+
"name": "feat/cc-widgets",
6+
"prerelease": "wxcc"
77
}
88
],
99
"plugins": [

CHANGELOG.md

Lines changed: 0 additions & 56 deletions
This file was deleted.

packages/contact-center/CHANGELOG.md

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/contact-center/station-login/package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webex/cc-station-login",
33
"description": "Webex Contact Center Widgets: Station Login",
4-
"version": "1.28.0-eft.7",
4+
"version": "1.0.0",
55
"main": "dist/index.js",
66
"publishConfig": {
77
"access": "public"
@@ -49,8 +49,6 @@
4949
"testMatch": [
5050
"**/tests/**/*.ts",
5151
"**/tests/**/*.tsx"
52-
],
53-
"passWithNoTests": true
54-
},
55-
"stableVersion": "1.28.0-eft.6"
52+
]
53+
}
5654
}
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
/*
2-
* StationLogin helper
3-
*/
41
export const useStationLogin = () => {
52
return {name: 'StationLogin'};
63
};

packages/contact-center/station-login/src/station-login/station-login.types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
export interface IStationLoginProps {
55
/**
66
* The name of the station.
7-
*
87
*/
98
name: string;
109

packages/contact-center/store/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webex/cc-store",
33
"description": "Webex Contact Center Widgets: Widgets Store",
4-
"version": "1.28.0-eft.7",
4+
"version": "1.0.0",
55
"main": "dist/index.js",
66
"license": "MIT",
77
"publishConfig": {
@@ -46,6 +46,5 @@
4646
"jest": {
4747
"testEnvironment": "jsdom",
4848
"passWithNoTests": true
49-
},
50-
"stableVersion": "1.28.0-eft.6"
49+
}
5150
}

packages/contact-center/store/src/store.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import {makeAutoObservable, observable} from 'mobx';
22

33
import sdk from './sdk';
4-
/*
5-
* Store
6-
*/
4+
75
class Store {
86
loginState = '';
97
isAvailable = false;

packages/contact-center/user-state/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@webex/cc-user-state",
33
"description": "Webex Contact Center Widgets: User State",
4-
"version": "1.28.0-eft.7",
4+
"version": "1.0.0",
55
"main": "dist/index.js",
66
"publishConfig": {
77
"access": "public"
@@ -47,6 +47,5 @@
4747
"jest": {
4848
"testEnvironment": "jsdom",
4949
"passWithNoTests": true
50-
},
51-
"stableVersion": "1.28.0-eft.6"
50+
}
5251
}
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*
2-
* UserState helper
3-
*/
4-
51
export const useUserState = () => {
62
return {name: 'UserState'};
73
};

packages/contact-center/user-state/src/user-state/user-state.presentational.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import React from 'react';
22

33
import {IUserState} from './use-state.types';
44

5-
/**
6-
* Presentational component for the User State.
7-
*/
85
const UserStatePresentational: React.FunctionComponent<IUserState> = (props) => {
96
return (
107
<>

tooling/src/publish.js

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@ const fs = require('fs');
33
const path = require('path');
44

55
// Function to remove the 'stableVersion' key
6-
function removeStableVersion(packageJsonPath) {
6+
function removeStableVersion(packageJsonPath, packageData) {
77
try {
8-
const packageJsonContent = fs.readFileSync(packageJsonPath, 'utf-8');
9-
const packageData = JSON.parse(packageJsonContent);
10-
118
if (packageData.hasOwnProperty('stableVersion')) {
129
delete packageData.stableVersion;
1310
fs.writeFileSync(packageJsonPath, JSON.stringify(packageData, null, 2), 'utf-8');
@@ -16,7 +13,7 @@ function removeStableVersion(packageJsonPath) {
1613
console.log("'stableVersion' key does not exist in package.json.");
1714
}
1815
} catch (error) {
19-
console.error("An error occurred while removing 'stableVersion':", error.message);
16+
throw new Error("An error occurred while removing 'stableVersion':", error.message);
2017
}
2118
}
2219

@@ -36,28 +33,42 @@ function versionAndPublish() {
3633
try {
3734
const ccFolder = fs
3835
.readdirSync(contactCenterPath, {withFileTypes: true})
39-
.filter((dirent) => dirent.isDirectory())
40-
.map((dirent) => dirent.name);
36+
.filter((dirent) => {
37+
return dirent.isDirectory();
38+
})
39+
.map((dirent) => {
40+
try {
41+
const packageJsonPath = path.join(contactCenterPath, dirent.name, 'package.json');
42+
const packageData = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
43+
44+
console.log(`Removing stable version from package.json for ${dirent.name}`);
45+
removeStableVersion(packageJsonPath, packageData);
46+
return packageData.name;
47+
} catch (error) {
48+
throw new Error(`Error reading package.json in ${dirent.name}`, error);
49+
}
50+
});
4151
// Separate dependency workspaces and other workspaces
42-
const dependencyWorkspaces = ccFolder.filter((fileName) => dependencies.includes(`@webex/cc-${fileName}`));
52+
const dependencyWorkspaces = ccFolder.filter((fileName) => dependencies.includes(fileName));
4353

44-
const otherWorkspaces = ccFolder.filter((fileName) => !dependencies.includes(`@webex/cc-${fileName}`));
54+
const otherWorkspaces = ccFolder.filter((fileName) => !dependencies.includes(fileName));
4555

46-
const publishWorkspace = (fileName) => {
47-
const workspaceName = `@webex/cc-${fileName}`;
56+
const publishWorkspace = (workspaceName) => {
4857
console.log(`Running publish script for ${workspaceName}: ${newVersion}`);
4958

50-
console.log(`Removing stable version from package.json for ${workspaceName}`);
51-
const packageJsonPath = path.join(contactCenterPath, fileName, 'package.json');
52-
removeStableVersion(packageJsonPath);
59+
// ccFolder has names of all the packages like @webex/cc-store and the actual folder name is just store,
60+
// thats why we need to remove '@webex/cc-' from the workspaceName to ge the path
61+
const packageJsonPath = path.join(contactCenterPath, workspaceName.replace('@webex/cc-', ''), 'package.json');
5362

5463
console.log(`Publishing new version for ${workspaceName}: ${newVersion}`);
5564

5665
// Update version in the workspace
5766
execSync(`yarn workspace ${workspaceName} version ${newVersion}`, {stdio: 'inherit'});
5867

5968
// Publish the package
60-
execSync(`yarn workspace ${workspaceName} npm publish --tag ${branchName}`, {stdio: 'inherit'});
69+
// execSync(`yarn workspace ${workspaceName} npm publish --tag ${branchName}`, {stdio: 'inherit'});
70+
71+
execSync(`yarn workspace ${workspaceName} pack`, {stdio: 'inherit'});
6172
};
6273

6374
// Publish dependencies first

tooling/tests/publish.js

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('versionAndPublish', () => {
3737

3838
test('removes "stableVersion" key from package.json when it exists', () => {
3939
const packageJsonContent = JSON.stringify({
40-
name: 'test-package',
40+
name: 'test-workspace',
4141
version: '1.0.0',
4242
stableVersion: '1.0.0',
4343
});
@@ -49,20 +49,22 @@ describe('versionAndPublish', () => {
4949
process.argv = ['node', 'script.js', 'main', '1.3.3-test.1'];
5050
versionAndPublish();
5151

52-
const expectedPackageJsonContent = JSON.stringify({name: 'test-package', version: '1.0.0'}, null, 2);
52+
const expectedPackageJsonContent = JSON.stringify({name: 'test-workspace', version: '1.0.0'}, null, 2);
5353

5454
expect(mockFs.writeFileSync).toHaveBeenCalledWith(packageJsonPath, expectedPackageJsonContent, 'utf-8');
5555
expect(console.log).toHaveBeenCalledWith("'stableVersion' key removed successfully.");
5656
});
5757

58-
test('error occured while writting "stableVersion" key to', () => {
58+
test('fails to write package.json after removing stableVersion', () => {
5959
const packageJsonContent = JSON.stringify({
60-
name: 'test-package',
60+
name: 'test-workspace',
6161
version: '1.0.0',
6262
stableVersion: '1.0.0',
6363
});
6464
jest.spyOn(fs, 'readdirSync').mockReturnValue([{name: 'test-workspace', isDirectory: () => true}]);
6565
jest.spyOn(fs.Dirent.prototype, 'isDirectory').mockReturnValue(true);
66+
67+
mockFs.readFileSync.mockReturnValue(packageJsonContent);
6668
mockFs.writeFileSync.mockImplementation(() => {
6769
throw new Error('Error while writing to file');
6870
});
@@ -71,14 +73,14 @@ describe('versionAndPublish', () => {
7173
versionAndPublish();
7274

7375
expect(console.error).toHaveBeenCalledWith(
74-
"An error occurred while removing 'stableVersion':",
75-
'"undefined" is not valid JSON'
76+
'Failed to process workspaces:',
77+
'Error reading package.json in test-workspace'
7678
);
7779
});
7880

7981
test('skips removing "stableVersion" if it does not exist', () => {
8082
const packageJsonContent = JSON.stringify({
81-
name: 'test-package',
83+
name: 'test-workspace',
8284
version: '1.0.0',
8385
});
8486
jest.spyOn(fs, 'readdirSync').mockReturnValue([{name: 'test-workspace', isDirectory: () => true}]);
@@ -94,15 +96,21 @@ describe('versionAndPublish', () => {
9496
});
9597

9698
test('publishes dependencies first and other workspaces afterward', () => {
97-
const contactCenterPath = './packages/contact-center';
98-
const dependencies = ['@webex/cc-store'];
99+
const packageJsonContent = JSON.stringify({
100+
name: '@webex/cc-store',
101+
version: '1.0.0',
102+
});
103+
const packageJsonContent2 = JSON.stringify({
104+
name: '@webex/cc-station-login',
105+
version: '1.0.0',
106+
});
99107

100108
mockFs.readdirSync.mockReturnValue([
101109
{name: 'store', isDirectory: () => true},
102110
{name: 'station-login', isDirectory: () => true},
103111
]);
104112

105-
mockFs.readFileSync.mockReturnValue('{}');
113+
mockFs.readFileSync.mockReturnValueOnce(packageJsonContent).mockReturnValueOnce(packageJsonContent2);
106114
mockFs.writeFileSync.mockImplementation(() => {});
107115

108116
const mockExecSync = require('child_process').execSync;
@@ -113,23 +121,39 @@ describe('versionAndPublish', () => {
113121

114122
versionAndPublish();
115123

116-
// Check the dependency workspace was published first
117124
expect(mockExecSync).toHaveBeenNthCalledWith(1, 'yarn workspace @webex/cc-store version 1.0.1', {stdio: 'inherit'});
118-
119125
expect(mockExecSync).toHaveBeenNthCalledWith(2, 'yarn workspace @webex/cc-store npm publish --tag main', {
120126
stdio: 'inherit',
121127
});
122128

123-
// Check the non-dependency workspace was published afterward
124129
expect(mockExecSync).toHaveBeenNthCalledWith(3, 'yarn workspace @webex/cc-station-login version 1.0.1', {
125130
stdio: 'inherit',
126131
});
127-
128132
expect(mockExecSync).toHaveBeenNthCalledWith(4, 'yarn workspace @webex/cc-station-login npm publish --tag main', {
129133
stdio: 'inherit',
130134
});
131135
});
132136

137+
test('error occurred while reading package.json data', () => {
138+
mockFs.readdirSync.mockReturnValue([
139+
{name: 'store', isDirectory: () => true},
140+
{name: 'station-login', isDirectory: () => true},
141+
]);
142+
143+
mockFs.readFileSync.mockImplementation(() => {
144+
throw new Error('Error while reading from file');
145+
});
146+
147+
const mockExecSync = require('child_process').execSync;
148+
149+
const processArgvMock = ['node', 'script.js', 'main', '1.0.1'];
150+
process.argv = processArgvMock;
151+
152+
versionAndPublish();
153+
expect(console.error).toHaveBeenCalledWith('Failed to process workspaces:', 'Error reading package.json in store');
154+
expect(mockExecSync).not.toHaveBeenCalled();
155+
});
156+
133157
it('should export versionAndPublish when required as a module', () => {
134158
jest.resetModules();
135159
// Simulate require.main !== module (require the module as a normal import)

0 commit comments

Comments
 (0)