Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
fs.writeFileSync(
path.join(root, 'package.json'),
JSON.stringify(packageJson, null, 2) + os.EOL
)
console.log(
`Installing ${chalk.cyan('react')}, ${chalk.cyan(
'react-dom'
)}, and ${chalk.cyan('next')} using ${displayedCommand}...`
)
console.log()
await install(root, ['react', 'react-dom', 'next'], { useYarn, isOnline })
console.log()
await cpy('**', root, {
parents: true,
cwd: path.join(__dirname, 'templates', 'default'),
rename: name => {
switch (name) {
case 'gitignore': {
return '.'.concat(name)
}
default: {
return name
}
}
},
})
}
if (tryGitInit(root)) {
}
const appPath = path.resolve(appName)
if (existsSync(appPath)) {
console.log()
console.log(chalk.red(`Project directory \`${appName}\` already exists`))
console.log(
chalk.red('Please remove it or specify another project-directpry'),
)
console.log()
process.exit(1)
}
await cpy('**', appPath, {
parents: true,
cwd: path.join(__dirname, '../template'),
rename: name => {
if (name === 'gitignore') return '.gitignore'
return name
},
})
const packageJsonPath = path.join(appPath, 'package.json')
const appPackageJson = require(packageJsonPath)
appPackageJson.name = appName
writeFileSync(packageJsonPath, JSON.stringify(appPackageJson, null, ' '))
{
const packageCommands: [string, string[]][] = program.useNpm
? [
const copyImages = () => cpy(bundleImages, assetsDir)
const copyText = () => cpy(bundleText, assetsTextDir)
public async copyFiles (files: string[], outDir: string) {
await copyfiles(files, outDir, { cwd: this.appRoot, parents: true })
}
async function copyStatics() {
return cpy('**/*', '../build', {
cwd: STATIC_PATH,
parents: true
});
}
async function copyStaticAssets(pkgName: string) {
if (pkgName === 'react-cosmos') {
await cpy(`src/${STATIC_PATH}/**`, `dist/${STATIC_PATH}`, {
cwd: path.join(__dirname, `../packages/react-cosmos`),
parents: false
});
}
}
async function copyFlowDefs(pkgName) {
return cpy('**/*.js.flow', `../dist`, {
cwd: join(__dirname, `../packages/${pkgName}/src`),
parents: true
});
}
async function copyFlowDefs(pkg) {
return cpy('**/*.js.flow', '../dist', {
cwd: join(ROOT_PATH, `packages/${pkg}/src`),
parents: true
});
}