Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function clearReactPackagerCache () {
const TMPDIR = process.env['TMPDIR']
if (TMPDIR) {
shell.rm('-rf', `${TMPDIR}/react-*`)
}
}
export function clearReactPackagerCache() {
const TMPDIR = process.env.TMPDIR
if (TMPDIR) {
shell.rm('-rf', path.join(TMPDIR, 'react-*'))
}
}
private updateCauldronRepoInUse({ alias }: { alias?: string } = {}) {
config.set('cauldronRepoInUse', alias)
shell.rm('-rf', Platform.cauldronDirectory)
}
export async function cleanGenerated (outFolder: string = process.cwd()) {
const pkg = await validateApiNameAndGetPackageJson('This is not a properly named API directory. Naming convention is react-native-{name}-api')
shell.rm('-rf', path.join(outFolder, 'javascript'))
shell.rm('-rf', path.join(outFolder, 'swift'))
shell.rm('-rf', path.join(outFolder, 'android'))
shell.rm('-rf', path.join(outFolder, 'IOS'))
shell.rm('-rf', path.join(outFolder, FLOW_CONFIG_FILE))
shell.rm('-rf', path.join(outFolder, PKG_FILE))
return pkg
}
message: `An implementation directory already exists in ${outputDirectoryPath}. Do you want to delete this and regenerate this project?`,
default: false
}
)
if (!shouldRegenerate) {
throw Error('An implementation directory already exists')
} else {
forceGenerate = true
}
}
if (forceGenerate && fs.existsSync(outputDirectoryPath)) {
log.info(`Deleting the existing directory and recreating a new one in ${outputDirectoryPath}`)
fileUtils.chmodr('777', outputDirectoryPath)
shell.rm('-Rf', outputDirectoryPath)
} else {
log.debug(`creating output dir: ${outputDirectoryPath}`)
}
shell.mkdir('-p', outputDirectoryPath)
}
containerPath: string
containerVersion: string
url?: string
}) {
const workingGitDir = createTmpDir()
if (!url) {
throw new Error('url is required')
}
try {
shell.pushd(workingGitDir)
const git = gitCli()
log.debug(`Cloning git repository(${url}) to ${workingGitDir}`)
await gitCli().cloneAsync(url, '.')
shell.rm('-rf', `${workingGitDir}/*`)
shell.cp('-Rf', path.join(containerPath, '{.*,*}'), workingGitDir)
await git.addAsync('./*')
await git.commitAsync(`Container v${containerVersion}`)
await git.tagAsync([`v${containerVersion}`])
await git.pushAsync('origin', 'master')
await git.pushTagsAsync('origin')
log.info('[=== Completed publication of the Container ===]')
log.info(`[Publication url : ${url}]`)
log.info('[Git Branch: master]')
log.info(`[Git Tag: v${containerVersion}]`)
} finally {
shell.popd()
}
}
}
function cleanupMiniAppsCompositeDir (dir: string) {
shell.rm('-rf', [
'.babelrc',
'index.android.js',
'index.ios.js',
'node_modules',
'package.json',
'yarn.lock'
].map(file => path.join(dir, file)))
}
prepareDirectories (config: ContainerGeneratorConfig) {
if (!fs.existsSync(config.outDir)) {
shell.mkdir('-p', config.outDir)
} else {
shell.rm('-rf', path.join(config.outDir, '{.*,*}'))
}
if (!fs.existsSync(config.compositeMiniAppDir)) {
shell.mkdir('-p', config.compositeMiniAppDir)
} else {
shell.rm('-rf', path.join(config.compositeMiniAppDir, '{.*,*}'))
}
if (!fs.existsSync(config.pluginsDownloadDir)) {
shell.mkdir('-p', config.pluginsDownloadDir)
} else {
shell.rm('-rf', path.join(config.pluginsDownloadDir, '{.*,*}'))
}
}