Skip to content

Commit a21cbe2

Browse files
authored
Merge pull request #22 from LambdaTest/stage
Release 1.1.3
2 parents ad6cd84 + 230792e commit a21cbe2

File tree

6 files changed

+52
-7
lines changed

6 files changed

+52
-7
lines changed

commands/utils/constants.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ constants.stage = {
55
RENDER_API_URL: "https://stage-api.lambdatestinternal.com/storybook/render",
66
BUILD_STATUS_URL: "https://stage-api.lambdatestinternal.com/storybook/status",
77
BASE_URL: "https://stage-api.lambdatestinternal.com",
8-
SB_BUILD_VALIDATE_PATH: "/storybook/validate"
8+
SB_BUILD_VALIDATE_PATH: "/storybook/validate",
9+
CHECK_UPDATE_PATH: "storybook/packageinfo"
910
};
1011
constants.prod = {
1112
AUTH_URL: "https://api.lambdatest.com/storybook/auth",
1213
RENDER_API_URL: "https://api.lambdatest.com/storybook/render",
1314
BUILD_STATUS_URL: "https://api.lambdatest.com/storybook/status",
1415
BASE_URL: "https://api.lambdatest.com",
15-
SB_BUILD_VALIDATE_PATH: "/storybook/validate"
16+
SB_BUILD_VALIDATE_PATH: "/storybook/validate",
17+
CHECK_UPDATE_PATH: "storybook/packageinfo"
1618
};
1719

1820
module.exports = { constants };

commands/utils/dom.js

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ async function sendDoM(storybookUrl, stories, storybookConfig, options) {
6767
// form.append('commitAuthor', commit.author.name);
6868
// form.append('commitMessage', commit.subject);
6969

70+
githubURL = process.env.GITHUB_URL
71+
if (githubURL) {
72+
form.append('githubURL', githubURL);
73+
}
74+
7075
// Send DOM to render API
7176
await axios.post(constants[options.env].RENDER_API_URL, form, {
7277
headers: {

commands/utils/package.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
const axios = require('axios');
2+
var { constants } = require('./constants');
3+
4+
// Check for package updates
5+
function checkUpdate(version, options) {
6+
return axios.get(new URL(constants[options.env].CHECK_UPDATE_PATH, constants[options.env].BASE_URL).href, {
7+
params: {
8+
packageName: 'smartui-storybook',
9+
packageVersion: version
10+
}})
11+
.then(function (response) {
12+
if (response.data.data.deprecated) {
13+
console.log('v' + version + ' is deprecated. Please update to v' + response.data.data.latestVersion);
14+
} else if (response.data.data.latestVersion != version) {
15+
console.log('A newer version v' + response.data.data.latestVersion + ' is available.');
16+
}
17+
})
18+
.catch(function (error) {
19+
if (error.response && error.response.data && error.response.data.error) {
20+
console.log('Cannot check for updates. Error: ' + error.response.data.error.message);
21+
} else {
22+
console.log('Cannot check for updates. Error: ' + error.message);
23+
}
24+
});
25+
};
26+
27+
module.exports = { checkUpdate };

index.js

+13-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ const program = new Command();
55
const { storybook } = require('./commands/storybook');
66
const { validateProjectToken, validateLatestBuild } = require('./commands/utils/validate');
77
const { createConfig } = require('./commands/config');
8+
const { version } = require('./package.json');
9+
const { checkUpdate } = require('./commands/utils/package');
810

911
program
1012
.name('smartui')
1113
.description('CLI to help you run your SmartUI tests on LambdaTest platform')
12-
.version('1.1.2')
14+
.version('v' + version)
1315
.addOption(new Option('--env <prod|stage>', 'Runtime environment option').choices(['prod', 'stage']));
1416

1517
const configCommand = program.command('config')
@@ -18,7 +20,12 @@ const configCommand = program.command('config')
1820
configCommand.command('create')
1921
.description('Create LambdaTest SmartUI config file')
2022
.argument('[filepath]', 'Optional config filepath')
21-
.action(function(filepath) {
23+
.action(async function(filepath, options) {
24+
options.env = program.opts().env || 'prod';
25+
console.log('SmartUI Storybook CLI v' + version);
26+
await checkUpdate(version, options);
27+
console.log('\n');
28+
2229
createConfig(filepath);
2330
});
2431

@@ -29,6 +36,10 @@ program.command('storybook')
2936
// .option('--force-rebuild', 'Force a rebuild of an already existing build.', false)
3037
.action(async function(serve, options) {
3138
options.env = program.opts().env || 'prod';
39+
console.log('SmartUI Storybook CLI v' + version);
40+
await checkUpdate(version, options);
41+
console.log('\n');
42+
3243
await validateProjectToken(options);
3344
// if (!options.forceRebuild) await validateLatestBuild(options);
3445
storybook(serve, options);

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@lambdatest/smartui-storybook",
3-
"version": "1.1.2",
3+
"version": "1.1.3",
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)