Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* eslint no-console:0 */
const program = require('commander')
const path = require('path')
const {getSpawnPromise} = require('@s-ui/helpers/cli')
program
.on('--help', () => {
console.log(' Description:')
console.log('')
console.log(' Shows a demo of your SVG library')
console.log('')
})
.parse(process.argv)
const devServerExec = require.resolve('@s-ui/bundler/bin/sui-bundler-dev')
getSpawnPromise(
devServerExec,
['-c', path.join(__dirname, '..', 'src'), '--no-pre-loader'],
{
shell: false,
env: process.env
}
).then(process.exit, process.exit)
* Functions that executes the commit for each package
* @type {Array}
*/
const checkStageFuncs = config.getScopes().map(pkg => {
const pkgPath = path.join(packagesDir, pkg)
return () =>
hasChangedFiles(pkgPath).then(hasChanges => {
if (hasChanges) {
let args = ['commit', `-m "${type}(${pkg}): ${message}"`]
commitsCount++ && args.push('--no-verify') // precommit only once
return getSpawnPromise('git', args)
}
})
})
getSpawnPromise('git', ['reset']) // Unstage all prossible staged files
.then(() =>
checkStageFuncs.reduce(
(promise, func) => promise.then(func),
Promise.resolve()
)
)
.catch(showError)
.then(cypressBinPath =>
getSpawnPromise(cypressBinPath, [
gui ? 'open' : 'run',
'--config=' + objectToCommaString(cypressConfig),
'--project=' + CYPRESS_FOLDER_PATH
])
)
console.log(' $ NOW_TOKEN=my-token sui-studio deploy --name=my-domain')
console.log('')
})
.parse(process.argv)
if (typeof program.name !== 'string') {
console.log('ERR: --name flag is mandatory')
process.exit(1)
}
if (!process.env.NOW_TOKEN) {
console.log('ERR: NOW_TOKEN env variable is missing')
process.exit(1)
}
getSpawnPromise(DEPLOY_PATH, ['spa', program.name, BUILD_FOLDER]).catch(err => {
showError(err.message)
})
const writeThemesInDemoFolders = async themes => {
await getSpawnPromise('rm', ['-Rf', './demo/**/**/themes'], {
cwd: process.cwd()
})
const paths = await globby(
[path.join(process.cwd(), 'demo', '**', '**'), '!**/node_modules/**'],
{onlyDirectories: true, cwd: process.cwd()}
)
paths
.filter(p => p.match(/\/demo\/\w+\/\w+$/))
.forEach(async demo => {
try {
const [, component] = demo.split('/demo/')
await createDir(`${demo}/themes`)
await Promise.all(
themes.map(theme =>
writeFile(
`${demo}/themes/${theme}.scss`,
.then(() => {
const lintArgs = ['js', '--fix']
isOptionSet(staged) && lintArgs.push(staged)
isOptionSet(addFixes) && lintArgs.push(addFixes)
return getSpawnPromise('sui-lint', lintArgs)
})
.catch(showError)) ||
.then(() => getSpawnPromise('npm', ['i'], {cwd: PROJECT_PATH}))
.then(process.exit)
const stageFilesIfRequired = async extensions => {
const {argv} = process
if (argv.includes(OPTIONS.staged) && argv.includes(OPTIONS.addFixes)) {
const {getSpawnPromise} = require('@s-ui/helpers/cli')
const files = await getGitStatusFiles(extensions)
return getSpawnPromise('git', ['add', ...files])
}
}
function installHuskyIfNotInstalled() {
if (!isHuskyInstalled()) {
log('husky will be installed to allow git hook integration with node')
return getSpawnPromise('npm', [
'install',
'husky@0.13.4',
'--save-dev',
'--save-exact'
])
} else {
return Promise.resolve(0)
}
}
setTimeout(() => {
const devServerExec = require.resolve('@s-ui/bundler/bin/sui-bundler-dev')
getSpawnPromise(
devServerExec,
['-c', path.join(__dirname, '..', 'src')],
{
shell: false,
env: process.env
}
).then(process.exit, process.exit)
}, 3000)
})