Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function modifyContents(config) {
console.log(kleur.underline().white('Modified'))
const files = modifyFiles.map((fileName) => resolve(ROOT, fileName))
const replaceConfig = createTemplateVariablesConfig(files, config, [
[
/Martin\s+Hochel/g, // This is here only for LICENSE.md
`${config.username} <${config.usermail}>`,
],
])
try {
const changedFiles = replace.sync(replaceConfig)
log(kleur.yellow(changedFiles.join('\n')))
} catch (reason) {
error('An error occurred modifying the file: ', reason)
} else {
// Get routes from file structure
let cwd = ctx.options.resolve.alias['@pages'];
if (fs.existsSync(cwd)) {
let fmt = x => x.substring(0, x.indexOf('.')).toLowerCase().replace('index', '');
routes = glob('**/*', { cwd }).map(fmt).map(slashes);
}
}
if (routes) {
routes.sort((a, b) => b.length - a.length); // root is last (TODO)
} else {
routes = ['/'];
let msg = `Exporting the "${colors.bold().yellow('/')}" route only!\nNo other routes found or specified:`;
msg += `\nā Your ${colors.bold().italic('@pages')} directory is empty.`;
if (ctx.PWA_CONFIG) msg += `\nā Your ${colors.underline().magenta('pwa.config.js')} is missing a "${colors.bold('routes')}" key.`;
msg += `\nā Your ${colors.dim('$ pwa export')} is missing the ${colors.cyan('--routes')} argument.`;
msg += `\n Please run ${colors.dim('$ pwa export --help')} for more info\n`;
log.warn(msg);
}
let fn;
let onNoMatch = res => fn({ path:'/' }, res, r => (r.statusCode=404,r.end()));
let server = createServer(fn=sirv(dest, { onNoMatch })).listen();
// Disable sandboxing (on command) for dead-simple CI/CD/Docker integrations
// @see https://developers.google.com/web/updates/2017/04/headless-chrome#faq
let chromeFlags = ['--headless', '--disable-gpu'];
if (opts.insecure) chromeFlags.push('--no-sandbox');
let base = 'http://localhost:' + server.address().port;
log.log(`Started local server on ${ colors.white().bold().underline(base) }`);
const cpFiles = ['copy.js', 'file-size.js', 'build.js', 'tsconfig.json']
/** @type {string[]} */
const rmFiles = []
const rmDirs = ['migrate']
const cpItems = cpFiles.map((file) => join(starterPathDir, file))
const rmItems = [...rmDirs, ...rmFiles].map((file) =>
join(libPackagePathDir, file)
)
sh.cp('-Rf', cpItems, `${libPackagePathDir}/`)
// 'rm' command checks the item type before attempting to remove it
sh.rm('-Rf', rmItems)
log(kleur.underline().white('==š scripts/ updated ā
=='))
log(kleur.red('Removed: \n ' + rmItems.join('\n')))
log(kleur.yellow('Copied: \n ' + cpItems.join('\n')))
}
kernel.flag('version', (value) => {
if (!value) {
return
}
dumpAsciiLogo()
console.log(`CLI version: ${yellow(underline(getCliVersion() || 'NA'))}`)
console.log(`Framework version: ${yellow(underline(getAdonisCoreVersion(process.cwd()) || 'NA'))}`)
process.exit(0)
}, {})
export function commandHelp() {
console.log(
[
kleur.underline('Usage'),
'',
' ' +
kleur.bold('styleguidist') +
' ' +
kleur.cyan('') +
' ' +
kleur.yellow('[]'),
'',
kleur.underline('Commands'),
'',
' ' + kleur.cyan('build') + ' Build style guide',
' ' + kleur.cyan('server') + ' Run development server',
' ' + kleur.cyan('help') + ' Display React Styleguidist help',
'',
kleur.underline('Options'),
'',
' ' + kleur.yellow('--config') + ' Config file path',
' ' + kleur.yellow('--open') + ' Open Styleguidist in the default browser',
' ' + kleur.yellow('--verbose') + ' Print debug information'
].join('\n')
)
}
function printErrorWithLink(message, linkTitle, linkUrl) {
console.error(`${kleur.bold().red(message)}\n\n${linkTitle}\n${kleur.underline(linkUrl)}\n`);
}
function commandHelp() {
console.log(
[
kleur.underline('Usage'),
'',
' ' +
kleur.bold('styleguidist') +
' ' +
kleur.cyan('') +
' ' +
kleur.yellow('[]'),
'',
kleur.underline('Commands'),
'',
' ' + kleur.cyan('build') + ' Build style guide',
' ' + kleur.cyan('server') + ' Run development server',
' ' + kleur.cyan('help') + ' Display React Styleguidist help',
'',
kleur.underline('Options'),
'',
' ' + kleur.yellow('--config') + ' Config file path',
' ' + kleur.yellow('--port') + ' Port to run development server on',
' ' + kleur.yellow('--open') + ' Open Styleguidist in the default browser',
' ' + kleur.yellow('--verbose') + ' Print debug information',
].join('\n')
);
}
function updateConfigDir() {
const starterPathDir = resolve(ROOT, 'config')
const libConfigPathDir = resolve(PACKAGE_ROOT, 'config')
/** @type {string[]} */
const cpFiles = ['global.d.ts']
/** @type {string[]} */
const rmFiles = ['prettier.config.js']
const cpItems = cpFiles.map((file) => join(starterPathDir, file))
const rmItems = rmFiles.map((file) => join(libConfigPathDir, file))
sh.cp('-Rf', cpItems, `${libConfigPathDir}/`)
sh.rm('-Rf', rmItems)
log(kleur.underline().white('==š config/ updated ā
=='))
log(kleur.red('Removed: \n ' + rmItems.join('\n')))
log(kleur.yellow('Copied: \n ' + cpItems.join('\n')))
}
kleur.underline('Usage'),
'',
' ' +
kleur.bold('styleguidist') +
' ' +
kleur.cyan('') +
' ' +
kleur.yellow('[]'),
'',
kleur.underline('Commands'),
'',
' ' + kleur.cyan('build') + ' Build style guide',
' ' + kleur.cyan('server') + ' Run development server',
' ' + kleur.cyan('help') + ' Display React Styleguidist help',
'',
kleur.underline('Options'),
'',
' ' + kleur.yellow('--config') + ' Config file path',
' ' + kleur.yellow('--port') + ' Port to run development server on',
' ' + kleur.yellow('--open') + ' Open Styleguidist in the default browser',
' ' + kleur.yellow('--verbose') + ' Print debug information',
].join('\n')
);
}