Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const prettierConfig = getPrettierConfig();
list.forEach(filePath => {
if (existsSync(filePath)) {
const ext = extname(filePath).replace(/^\./, '');
const text = readFileSync(filePath, 'utf8');
const formatText = format(text, {
parser: PRETTIER_PARSER[ext],
...prettierConfig,
});
writeFileSync(filePath, formatText, 'utf8');
}
});
signale.success(`${chalk.cyan('prettier')} success!`);
}
// eslint
if (preCommitConfig.eslint) {
const eslintConfig = getEsLintConfig();
const eslintBin = require.resolve('eslint/bin/eslint');
const args = [eslintBin, '-c', eslintConfig, ...list, '--fix'];
try {
await runCmd('node', args);
} catch (code) {
process.exit(code);
}
signale.success(`${chalk.cyan('eslint')} success!`);
}
function start(name) {
const contentBase = `examples`;
// Clean
rimraf.sync(`${contentBase}/dist`);
signale.success('Clean success');
// Watch
const watcher = rollup.watch({
input: [`${contentBase}/${name}/index.tsx`],
output: {
file: `${contentBase}/dist/bundle.js`,
format: 'umd',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
antd: 'antd',
},
},
plugins: [
postcss({
modules: {
],
external: makeExternalPredicate([...Object.keys(peerDependencies)]),
});
await umdBundle.write({
name: 'GGEditor',
file: 'dist/index.js',
format: 'umd',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
exports: 'named',
});
signale.success('Build umd success');
} catch (error) {
signale.error(error);
}
// Build cjs
try {
const cjsBundle = await rollup.rollup({
input: 'src/index.tsx',
plugins: [
resolve(),
replace({
'process.env.GG_EDITOR_VERSION': JSON.stringify(version),
}),
commonjs(),
typescript(),
babel({
async function build() {
// Clean
rimraf.sync('dist');
rimraf.sync('lib');
rimraf.sync('es');
signale.success('Clean success');
// Build umd
try {
const umdBundle = await rollup.rollup({
input: 'src/index.tsx',
plugins: [
resolve(),
replace({
'process.env.GG_EDITOR_VERSION': JSON.stringify(version),
}),
commonjs(),
typescript({
tsconfigOverride: {
compilerOptions: {
declaration: false,
},
function build(previousFileSizes) {
signale.success('Creating an optimized production client build...')
let compiler = webpack(config)
return new Promise((resolve, reject) => {
compiler.run((err, stats) => {
if (err) {
return reject(err)
}
const messages = formatWebpackMessages(stats.toJson({}, true))
if (messages.errors.length) {
// Only keep the first error. Others are often indicative
// of the same problem, but confuse the reader with noise.
if (messages.errors.length > 1) {
messages.errors.length = 1
}
return reject(new Error(messages.errors.join('\n\n')))
}
compiler.run((err, stats) => {
console.log(stats.toString(tasks.WEBPACK_STATS_OPTIONS))
if (stats.hasErrors()) {
signale.error('Webpack compilation error')
process.exit(1)
}
signale.success('Webpack compilation done')
buildChrome()
buildFirefox()
tasks.copyIntegrationAssets()
signale.success('Build done')
})
async function release(version) {
try {
await commit(version)
await tag(version)
await push()
await pushTag()
signale.success('release completed!')
} catch (e) {
signale.warn('Fail to commit or push!', e)
return false
}
}
async reloadSiteList() {
signale.await("Reloading sites list")
this.siteList = await this.cmdp("siteList", [])
this.siteAddrs = this.siteList.map(s => s.address)
signale.success(`SiteList: ${this.siteList.length}`)
}
return command().then(output => {
backendAxios({
ciEnv,
flow: 'alias',
state: 'success',
targetUrl: `https://${process.env.DOMAIN}`,
});
signale.success(output);
return output;
});
};
/**
* signale
*
* 美化console
*
* 参考:https://github.com/klauscfhq/signale
*
*/
const signale = require('signale');
signale.success('Operation successful');
signale.debug('Hello', 'from', 'L59');
signale.pending('Write release notes for 1.2.0');
signale.fatal(new Error('Unable to acquire lock'));
signale.watch('Recursively watching build directory...');
signale.complete({prefix: '[task]', message: 'Fix issue #59', suffix: '(@klauscfhq)'});