Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env node
/* eslint no-console:0 */
const {serialSpawn} = require('@s-ui/helpers/cli')
const {join} = require('path')
const fs = require('fs-extra')
console.log('\n', process.env.NODE_ENV, '\n')
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const bundlerBuildPath = require.resolve('@s-ui/bundler/bin/sui-bundler-build')
serialSpawn([
[
bundlerBuildPath,
['-C', '--context', join(__dirname, '..', 'src')],
{shell: false, env: process.env}
]
])
.then(() => fs.copy('public/index.html', 'public/200.html'))
.then(code => process.exit(code))
.catch(code => process.exit(code))
#!/usr/bin/env node
const {serialSpawn} = require('@s-ui/helpers/cli')
const BIN_PATH = require.resolve('@s-ui/lint/bin/sui-lint')
serialSpawn([
[BIN_PATH, ['js', '--staged']],
[BIN_PATH, ['sass', '--staged']],
['npm', ['run', 'test']]
])
.then(code => process.exit(code))
.catch(error => {
// eslint-disable-next-line no-console
console.error(error)
process.exit(1)
})
/* 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)
console.log(' Usefull for cross-pacakge refactors.')
console.log('')
console.log(' Examples:')
console.log('')
console.log(
' $ sui-mono commit-all --type=fix -m "bump dependency to major version"'
)
console.log(' $ sui-mono --help')
console.log(' $ sui-mono -h')
console.log('')
})
.parse(process.argv)
// Check mandatory parameters
const {message, type} = program
!message && showError('Commit message is mandatory')
!type && showError('Commit type is mandatory')
const packagesDir = path.join(process.cwd(), config.getPackagesFolder())
/**
* Checks if given path has changes
* @param {String} path Folder to check
* @return {Promise}
*/
const hasChangedFiles = path => {
return new Promise((resolve, reject) => {
exec(`git add . && git status ${path}`, {cwd: path}, (err, output) => {
err ? reject(err) : resolve(!output.includes('nothing to commit'))
})
})
}
console.log('')
console.log(' Examples:')
console.log('')
console.log(
' $ sui-mono commit-all --type=fix -m "bump dependency to major version"'
)
console.log(' $ sui-mono --help')
console.log(' $ sui-mono -h')
console.log('')
})
.parse(process.argv)
// Check mandatory parameters
const {message, type} = program
!message && showError('Commit message is mandatory')
!type && showError('Commit type is mandatory')
const packagesDir = path.join(process.cwd(), config.getPackagesFolder())
/**
* Checks if given path has changes
* @param {String} path Folder to check
* @return {Promise}
*/
const hasChangedFiles = path => {
return new Promise((resolve, reject) => {
exec(`git add . && git status ${path}`, {cwd: path}, (err, output) => {
err ? reject(err) : resolve(!output.includes('nothing to commit'))
})
})
}
const packageInfo = require(PAGE_BASE_PROJECT_JSON_FILE)
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`
const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}
// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
showError(`[${page}] This page already exist in the path:
${PAGE_PATH}`)
}
Promise.all([
writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
writeFile(
PAGE_BASE_PROJECT_JSON_FILE,
JSON.stringify(packageInfo, null, ' ')
)
]).then(() => {
console.log(
colors.green(
`➜ [${page}]: Your page files have been generated successfully.`
)
)
})
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`
const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}
// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
showError(`[${page}] This page already exist in the path:
${PAGE_PATH}`)
}
Promise.all([
writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
writeFile(
PAGE_BASE_PROJECT_JSON_FILE,
JSON.stringify(packageInfo, null, ' ')
)
]).then(() => {
console.log(
colors.green(
`➜ [${page}]: Your page files have been generated successfully.`
)
)
})
const PAGE_BASE_PROJECT_JSON_FILE = path.join(process.cwd(), 'package.json')
const {pageRegExpIdentifier} = program
const packageInfo = require(PAGE_BASE_PROJECT_JSON_FILE)
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`
const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}
// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
showError(`[${page}] This page already exist in the path:
${PAGE_PATH}`)
}
Promise.all([
writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
writeFile(
PAGE_BASE_PROJECT_JSON_FILE,
JSON.stringify(packageInfo, null, ' ')
)
]).then(() => {
console.log(
colors.green(
`➜ [${page}]: Your page files have been generated successfully.`
)
)
})
const areDifferentLintConfig =
JSON.stringify({eslintConfig, prettier, stylelint}) !==
JSON.stringify(LINT_CONFIGS)
// if they're different, we're going to rewrite the package.json
if (areDifferentLintConfig) {
console.log('Adding @s-ui/lint config to package.json...')
// remove deprecated linter config of sasslintConfig
const {sasslintConfig, ...originalPackageJSON} = packageJSON
// create the new package.json object to be written
const newPackageJSON = {
...originalPackageJSON,
...LINT_CONFIGS
}
// write the new package.json with the linter conifg
writeFile(
ACTUAL_PACKAGE_PATH,
JSON.stringify(newPackageJSON, null, 2)
).then(() => console.log('Added @s-ui/lint config successfully'))
} else {
console.log('@s-ui/lint config already in your package.json. Great!')
}
} catch (e) {
console.log("@s-ui/lint can't update package.json file.")
}
const {pageRegExpIdentifier} = program
const packageInfo = require(PAGE_BASE_PROJECT_JSON_FILE)
packageInfo.scripts[`start:${page}`] = `sui-widget-embedder dev -p ${page}`
const {config = {}} = packageInfo
const {sitePrefix = ''} = config['sui-widget-embedder'] || {}
// Check if the page already exist before continuing
if (fs.existsSync(PAGE_PATH)) {
showError(`[${page}] This page already exist in the path:
${PAGE_PATH}`)
}
Promise.all([
writeFile(PAGE_PACKAGE_JSON_FILE, packageJSON(pageRegExpIdentifier)),
writeFile(PAGE_ENTRY_JS_POINT_FILE, indexJS()),
writeFile(PAGE_ENTRY_SCSS_POINT_FILE, indexSCSS(sitePrefix)),
writeFile(
PAGE_BASE_PROJECT_JSON_FILE,
JSON.stringify(packageInfo, null, ' ')
)
]).then(() => {
console.log(
colors.green(
`➜ [${page}]: Your page files have been generated successfully.`
)
)
})