Skip to content

Commit b98d98e

Browse files
authored
Merge pull request #99 from LambdaTest/stage
Added storybook cli changes for adding buildName flag
2 parents bd28adb + 015b355 commit b98d98e

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

commands/storybook.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const { shortPolling } = require('./utils/polling');
1212
async function storybook(serve, options) {
1313
let type = /^https?:\/\//.test(serve) ? 'url' : 'dir';
1414
let storybookConfig = options.config ? options.config : defaultSmartUIConfig.storybook;
15+
const buildName = options.buildName? options.buildName : "";
1516

1617
if (type === 'url') {
1718
await validateStorybookUrl(serve);
@@ -113,6 +114,29 @@ async function storybook(serve, options) {
113114
}
114115

115116
let commit = await getLastCommit();
117+
let baseLine = process.env.BASELINE_BRANCH;
118+
let currentBranch = process.env.CURRENT_BRANCH;
119+
if (baseLine !== null && baseLine !== undefined){
120+
if(baseLine === ''){
121+
const error = {
122+
"error": "MISSING_BRANCH_NAME",
123+
"message": "Error : The baseline branch name environment variable cannot be empty."
124+
};
125+
console.log(JSON.stringify(error, null, 2));
126+
process.exit(1);
127+
}
128+
}
129+
130+
if(currentBranch !== null && currentBranch !==undefined){
131+
if(currentBranch === ''){
132+
const error = {
133+
"error": "MISSING_BRANCH_NAME",
134+
"message": "Error : The current branch name environment variable cannot be empty."
135+
};
136+
console.log(JSON.stringify(error, null, 2));
137+
process.exit(1);
138+
}
139+
}
116140
let payload = {
117141
downloadURL: url.substring(url.search(/.com/)+5, url.search(/.zip/)+4),
118142
uploadId: uploadId,
@@ -125,12 +149,14 @@ async function storybook(serve, options) {
125149
customViewports: storybookConfig.customViewports
126150
},
127151
git: {
128-
branch: commit.branch,
129-
commitId: commit.shortHash,
130-
commitAuthor: commit.author.name,
131-
commitMessage: commit.subject,
152+
branch: currentBranch || commit.branch|| '',
153+
baselineBranch: baseLine || '',
154+
commitId: commit.shortHash,
155+
commitAuthor: commit.author.name,
156+
commitMessage: commit.subject,
132157
githubURL: process.env.GITHUB_URL || '',
133-
}
158+
},
159+
buildName: buildName,
134160
}
135161

136162
// Call static render API

index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,22 @@ program.command('storybook')
3434
.argument('<url|directory>', 'Storybook url or static build directory')
3535
.option('-c --config <file>', 'Config file path')
3636
.option('--force-rebuild', 'Force a rebuild of an already existing build.', false)
37+
.option('--buildName <string>', 'Specify the build name for the pipeline')
3738
.action(async function(serve, options) {
3839
options.env = program.opts().env || 'prod';
3940

4041
console.log('SmartUI Storybook CLI v' + version);
4142
await checkUpdate(version, options);
4243
console.log('\n');
43-
44+
// Check if buildName is undefined or empty string
45+
if (options.buildName === '') {
46+
const error = {
47+
"error": "MISSING_BUILD_NAME",
48+
"message": "The --buildName flag requires a value."
49+
};
50+
console.log(JSON.stringify(error, null, 2));
51+
process.exit(1);
52+
}
4453
if (options.config) {
4554
options.config = validateConfig(options.config);
4655
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-storybook",
3-
"version": "1.1.20",
3+
"version": "1.1.21",
44
"description": "LambdaTest's command-line interface (CLI) aimed to help you run your SmartUI tests on LambdaTest platform",
55
"main": "index.js",
66
"repository": {

0 commit comments

Comments
 (0)