Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Make sure the sub folders are created
await fsExtra.mkdirp(path.dirname(page.path))
await fsExtra.writeFile(page.path, page.html, 'utf8')
await this.nuxt.callHook('generate:routeCreated', {
route,
path: page.path,
errors: pageErrors
})
if (pageErrors.length) {
consola.error('Error generating ' + route)
errors.push(...pageErrors)
} else {
consola.success('Generated ' + route)
}
return true
}
// Wait for nuxt ready
await this.nuxt.ready()
// Call before hook
await this.nuxt.callHook('build:before', this, this.options.build)
await this.validatePages()
// Validate template
try {
this.validateTemplate()
} catch (err) {
consola.fatal(err)
}
consola.success('Builder initialized')
consola.debug(`App root: ${this.options.srcDir}`)
// Create .nuxt/, .nuxt/components and .nuxt/dist folders
await fsExtra.remove(r(this.options.buildDir))
const buildDirs = [r(this.options.buildDir, 'components')]
if (!this.options.dev) {
buildDirs.push(
r(this.options.buildDir, 'dist', 'client'),
r(this.options.buildDir, 'dist', 'server')
)
}
await Promise.all(buildDirs.map(dir => fsExtra.mkdirp(dir)))
// Call ready hook
await this.nuxt.callHook('builder:prepared', this, this.options.build)
for (const error of data.errors) {
console.log('\n', error.stack || error.message || error)
}
onError(`Build failed with errors.`)
return
}
const targetDirShort = path.relative(
api.service.cwd,
targetDir,
)
if (!args.silent) {
consola.log(formatStats(stats, targetDirShort, api))
consola.success(chalk.green('Build complete!'))
if (args.watch) {
consola.info(chalk.blue(`Watching for file changes...`))
}
}
resolve()
}
}
result = this.fixPluginVueOption(result, 'router');
if (api.hasPlugin('vuex')) {
result = this.fixPluginVueOption(result, 'store');
}
if (api.hasPlugin('i18n')) {
result = this.fixPluginVueOption(result, 'i18n');
}
if (code !== result) {
await fs.writeFile(mainPath, result);
}
if (!this.options.silent)
consola.success(`Main: ${path.relative(api.resolve('.'), mainPath)} OK`);
}
}
objectsToDelete.forEach(({ key }) => consola.success(`Deleted: ${key}`));
};
}: {
cloudFrontId: string;
items?: string[];
}): Promise => {
consola.info('Start purging CDN');
await createInvalidation({
DistributionId: cloudFrontId,
InvalidationBatch: {
CallerReference: String(new Date().getTime()),
Paths: {
Quantity: 1,
Items: items,
},
},
});
consola.success('Succeeded in purging CDN');
};
clinicApi.visualize(filepath, `${filepath}.html`, async err => {
if (err) return reject(err);
await fs.move(`./${filepath}`, `.devtools/${filepath}`);
await fs.move(`./${filepath}.html`, `.devtools/${filepath}.html`);
consola.success('Opening report...');
await opn(`.devtools/${filepath}.html`);
resolve();
});
});