@zeplin/cli
Advanced tools
Comparing version 1.1.4 to 1.1.5
{ | ||
"name": "@zeplin/cli", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Zeplin CLI", | ||
@@ -68,3 +68,2 @@ "main": "./dist/src/index.js", | ||
"@hapi/joi": "^17.1.1", | ||
"argparse": "^1.0.10", | ||
"axios": "^0.21.1", | ||
@@ -76,3 +75,2 @@ "chalk": "^3.0.0", | ||
"cosmiconfig": "^7.0.0", | ||
"endent": "^1.3.0", | ||
"execa": "^5.0.0", | ||
@@ -79,0 +77,0 @@ "express": "^4.17.1", |
@@ -9,3 +9,3 @@ "use strict"; | ||
const semver_1 = require("semver"); | ||
const argparse_1 = require("argparse"); | ||
const commander_1 = require("commander"); | ||
const logger_1 = __importDefault(require("../../../util/logger")); | ||
@@ -26,15 +26,22 @@ const dependency_1 = require("../../../util/js/dependency"); | ||
if (packageJson.scripts) { | ||
const argparser = new argparse_1.ArgumentParser({ prog: "start-storybook", addHelp: false }); | ||
argparser.addArgument(["-h", "--host"]); | ||
argparser.addArgument(["-p", "--port"]); | ||
argparser.addArgument(["--https"], { type: Boolean }); | ||
const foundScript = Object.entries(packageJson.scripts).find(([, v]) => v.startsWith("start-storybook")); | ||
const program = new commander_1.Command() | ||
.option("-p, --port <port>") | ||
.option("-h, --host <host>") | ||
.option("--https") | ||
.allowUnknownOption(); | ||
const foundScript = Object.entries(packageJson.scripts) | ||
.find(([, v]) => v.indexOf("start-storybook") !== -1); | ||
if (foundScript) { | ||
const [scriptName, scriptValue] = foundScript; | ||
logger_1.default.debug(`Found storybook script "${scriptName}": "${scriptValue}"`); | ||
const scriptArgs = scriptValue.split(" ").map(a => a.trim()); | ||
const [{ host, port, https }] = argparser.parseKnownArgs(scriptArgs); | ||
const protocol = https ? "https" : "http"; | ||
config.url = `${protocol}://${host || defaultHost}:${port || defaultPort}/`; | ||
config.startScript = scriptName; | ||
const sbCommand = (scriptValue.split("&&") | ||
.reduce((prev, curr) => prev.concat(curr.split("||")), []) | ||
.find(v => v.trim().startsWith("start-storybook"))) || ""; | ||
if (sbCommand) { | ||
const sbArgs = sbCommand.split(" ").map(a => a.trim()); | ||
const { host, port, https } = program.parse(sbArgs, { from: "user" }); | ||
const protocol = https ? "https" : "http"; | ||
config.url = `${protocol}://${host || defaultHost}:${port || defaultPort}/`; | ||
config.startScript = scriptName; | ||
} | ||
} | ||
@@ -41,0 +48,0 @@ } |
{ | ||
"name": "@zeplin/cli", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "Zeplin CLI", | ||
@@ -68,3 +68,2 @@ "main": "./dist/src/index.js", | ||
"@hapi/joi": "^17.1.1", | ||
"argparse": "^1.0.10", | ||
"axios": "^0.21.1", | ||
@@ -76,3 +75,2 @@ "chalk": "^3.0.0", | ||
"cosmiconfig": "^7.0.0", | ||
"endent": "^1.3.0", | ||
"execa": "^5.0.0", | ||
@@ -79,0 +77,0 @@ "express": "^4.17.1", |
244544
34
5499
- Removedargparse@^1.0.10
- Removedendent@^1.3.0
- Removedargparse@1.0.10(transitive)
- Removeddedent@0.7.0(transitive)
- Removedendent@1.4.1(transitive)
- Removedfast-json-parse@1.0.3(transitive)
- Removedobjectorarray@1.0.5(transitive)
- Removedsprintf-js@1.0.3(transitive)