Skip to content

Commit 9b337d6

Browse files
authored
Merge pull request #2 from pinanks/DOT-822
2 parents 7a63f81 + 058c5f8 commit 9b337d6

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

commands/utils/constants.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
var constants = {}
22

3-
constants.env = 'prod';
43
constants.stage = {
54
AUTH_URL: "https://stage-api.lambdatestinternal.com/storybook/auth",
65
RENDER_API_URL: "https://stage-api.lambdatestinternal.com/storybook/render"

commands/utils/dom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ async function sendDoM(storybookUrl, stories, storybookConfig, options) {
4848
form.append('browser', storybookConfig.browsers);
4949
form.append('projectToken', process.env.PROJECT_TOKEN);
5050
form.append('buildName', options.buildname);
51-
axios.post(constants[constants.env].RENDER_API_URL, form, {
51+
axios.post(constants[options.env].RENDER_API_URL, form, {
5252
headers: {
5353
...form.getHeaders()
5454
}

commands/utils/validate.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
const axios = require('axios');
22
var { constants } = require('./constants');
33

4-
function validateProjectToken() {
4+
function validateProjectToken(options) {
55
if (process.env.PROJECT_TOKEN) {
6-
return axios.get(constants[constants.env].AUTH_URL, {
6+
return axios.get(constants[options.env].AUTH_URL, {
77
headers: {
88
projectToken: process.env.PROJECT_TOKEN
99
}})

index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /usr/bin/env node
22

3-
const { Command } = require('commander');
3+
const { Command, Option } = require('commander');
44
const program = new Command();
55
const { storybook } = require('./commands/storybook');
66
const { validateProjectToken } = require('./commands/utils/validate');
@@ -9,7 +9,8 @@ const { createConfig } = require('./commands/config');
99
program
1010
.name('smartui')
1111
.description('CLI to help you run your SmartUI tests on LambdaTest platform')
12-
.version('1.0.0');
12+
.version('1.0.0')
13+
.addOption(new Option('--env <prod|stage>', 'Runtime environment option').choices(['prod', 'stage']));
1314

1415
const configCommand = program.command('config')
1516
.description('Manage LambdaTest SmartUI config')
@@ -26,8 +27,10 @@ program.command('storybook')
2627
.argument('<url>', 'Storybook url')
2728
.requiredOption('--buildname <string>', 'Build name')
2829
.option('-c --config <file>', 'Config file path')
30+
// .option('--env <prod|stage>', 'Runtime environment option', 'prod')
2931
.action(async function(url, options) {
30-
await validateProjectToken();
32+
options.env = program.opts().env || 'prod';
33+
await validateProjectToken(options);
3134
storybook(url, options);
3235
});
3336

0 commit comments

Comments
 (0)