Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return doc
}
// load the config
var env = process.env.NODE_ENV || 'development'
var defaultCfg = load('defaults')
var envCfg = load(env)
module.exports = extend(defaultCfg, envCfg, { env })
// some warnings
if (!module.exports.csrf) {
console.log(figures.warning, 'WARNING: CSRF is DISABLED')
}
if (!module.exports.stripe) {
console.log(figures.warning, 'WARNING: Stripe payments are DISABLED')
}
// Check if types are already installed
if (alreadyInstalledTypes.includes('@types/' + dependency)) {
console.log(chalk.yellow(figures.play, `Types for ${dependencyString} already installed. Skipping...`));
continue;
}
// Check for included types
let pkgPath = path.join(cwd, 'node_modules', dependency, 'package.json');
if (fs.existsSync(pkgPath)) {
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
if (pkg.types || pkg.typings) {
console.log(chalk.yellow(figures.warning, `Module ${dependencyString} includes own types. Skipping...`));
continue;
}
}
// Check if types are available
((dependency) => {
request('https://www.npmjs.com/package/@types/' + dependency, (err, res, body) => {
if (res.statusCode == 200) {
exec(`${tool.command} @types/${dependency}`, (err, stdout, stderr) => {
if (!err) {
console.log(chalk.green(figures.tick, `@types/${dependencyString} installed successfully!`));
}
});
} else {
/* eslint-disable */
const chalk = require('chalk');
const inquirer = require('inquirer');
const slateEnv = require('@shopify/slate-env');
const {event} = require('@shopify/slate-analytics');
const {fetchMainThemeId} = require('@shopify/slate-sync');
const figures = require('figures');
const {argv} = require('yargs');
const question = {
type: 'confirm',
name: 'continueWithDeploy',
message: 'You are about to deploy to the published theme. Continue?',
default: true,
prefix: chalk.yellow(`${figures.warning} `),
};
/**
* Prompt the user to confirm if they are about to deploy to the main theme
*
* @param env String The environment to check against
* @return Promise Reason for abort or empty resolve
*/
module.exports = async function continueIfPublishedTheme(env) {
if (argv.skipPrompts) {
return question.default;
}
const publishedThemeId = await fetchMainThemeId();
const currentThemeId = slateEnv.getThemeIdValue();
function onrun(error, code) {
st.deepEqual(
[error, code, stderr()],
[
null,
0,
'two.txt\n 1:1 warning Warning\n\n' +
figures.warning +
' 1 warning\n'
],
'should report'
)
}
}
try {
process.stdout.clearLine()
process.stdout.cursorTo(0)
} catch {}
const existed = results.filter(({ isExisted }) => isExisted)
const overwritten = results.filter(({ isOverwritten }) => isOverwritten)
const cleanlyInitialized = results.filter(({ isExisted, isOverwritten }) => !isOverwritten && !isExisted)
if (cleanlyInitialized.length || overwritten.length) {
console.log(`\nInitialized ${cleanlyInitialized.length + overwritten.length} config(s) successfully:\n`)
for (const { filename, isOverwritten } of [...cleanlyInitialized, ...overwritten]) {
console.log(
` ${chalk.green(figures.tick)} ${filename}${
isOverwritten ? ` ${chalk.yellow(`${figures.warning} overwritten`)}` : ''
}`
)
}
}
if (!overwrite && existed.length) {
console.log('\n')
process.stdout.write(`\rSkipped ${existed.length} already existing config(s):\n`)
for (const { filename } of existed) {
console.log(` ${chalk.blue(figures.line)} ${filename}`)
}
console.log('\nUse -o/--overwrite to force re-initialization of an already existing file.')
}
}
const warn = (msg, ...args) => {
console.warn(
chalk.yellowBright(`\n ${figures.warning} ${msg}\n`),
...args
);
};
console.log();
console.log('Photo added to the collection.');
} catch (error) {
errorHandler(error);
}
}
});
}
/**
* Log utilty
*/
export const logger = {
info: console.log.bind(console, chalk.cyan(figures.info)),
warn: console.log.bind(console, chalk.yellow(figures.warning)),
error: console.log.bind(console, chalk.red(figures.cross)),
};
/**
* @description Highlight json
* @param {Object} data
*/
export function highlightJSON(data) {
let jsonString = JSON.stringify(data, null, 2);
jsonString = jsonString.replace(/[\{|\}|\,|\:|\[|\]]+/g, chalk`{dim $&}`);
jsonString = jsonString.replace(/\".*?\"/g, chalk`{yellow $&}`);
jsonString = jsonString.replace(/(\s+)(\d+)/g, chalk`$1{cyan $2}`);
jsonString = jsonString.replace(/null|undefined/gi, chalk`{dim $&}`);
jsonString = jsonString.replace(/true|false/gi, chalk`{magenta $&}`);
.then(valid => {
if (valid !== undefined && valid !== true) {
this._question.default = new Error(`${figures.warning} ${valid}`);
return this.render();
}
return result;
});
});
level: Level;
color: Chalk;
icon: string;
verbose?: boolean;
}
const levelOptions: LevelOptions[] = [
{
level: Level.Debug,
color: chalk.gray,
icon: figures.bullet,
verbose: true
},
{ level: Level.Info, color: chalk.blue, icon: figures.info },
{ level: Level.Success, color: chalk.green, icon: figures.tick },
{ level: Level.Warn, color: chalk.yellow, icon: figures.warning },
{ level: Level.Error, color: chalk.red, icon: figures.cross }
];
const maxLevelLength = Math.max(
...levelOptions.map(getPrefix).map(stringWidth)
);
function getPrefix(opt: LevelOptions) {
return `${opt.icon} ${opt.level}`;
}
function buildLogFunc(writer: Writable, opt: LevelOptions) {
let prefix = getPrefix(opt);
for (let i = prefix.length; i <= maxLevelLength; i++) {
prefix += " ";
() => this.pushLog( `${unicode.warning } stderr` )
)