Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function downloadInstallAndBundle(
{ files, entrypoint, workPath },
{ npmArguments = [] } = {}
) {
const userPath = path.join(workPath, 'user')
const nccPath = path.join(workPath, 'ncc')
const ftsPath = path.join(workPath, 'fts')
console.log()
console.log('downloading user files...')
const downloadedFiles = await download(files, userPath)
console.log()
console.log("installing dependencies for user's code...")
const entrypointFsDirname = path.join(userPath, path.dirname(entrypoint))
await runNpmInstall(entrypointFsDirname, npmArguments)
console.log('writing ncc package.json...')
fs.outputJsonSync(path.join(nccPath, 'package.json'), {
dependencies: {
'@zeit/ncc': '0.11.0',
typescript: '3.2.4'
}
})
console.log()
console.log('installing dependencies for ncc...')
}) => {
console.log('entrypoint ', entrypoint);
validateEntrypoint(entrypoint);
console.log('downloading user files...');
const entryDirectory = path.dirname(entrypoint);
const filesOnlyEntryDirectory = includeOnlyEntryDirectory(
files,
entryDirectory,
);
const filesWithEntryDirectoryRoot = moveEntryDirectoryToRoot(
filesOnlyEntryDirectory,
entryDirectory,
);
const filesWithoutLockfiles = excludeLockFiles(filesWithEntryDirectoryRoot);
const downloadedFiles = await download(filesWithoutLockfiles, workPath);
console.log('normalizing package.json');
const packageJson = normalizePackageJson(
await readPackageJson(downloadedFiles),
);
console.log('normalized package.json result: ', packageJson);
await writePackageJson(workPath, packageJson);
if (process.env.NPM_AUTH_TOKEN) {
console.log('found NPM_AUTH_TOKEN in environment, creating .npmrc');
await writeNpmRc(workPath, process.env.NPM_AUTH_TOKEN);
}
console.log('running npm install...');
await runNpmInstall(workPath, ['--prefer-offline']);
console.log('running user script...');
workPath,
}) => {
console.log('downloading user files...');
const entryDirectory = path.dirname(entrypoint);
const filesOnlyEntryDirectory = includeOnlyEntryDirectory(
files,
entryDirectory,
);
const filesWithEntryDirectoryRoot = moveEntryDirectoryToRoot(
filesOnlyEntryDirectory,
entryDirectory,
);
const filesWithoutLockfiles = excludeLockFiles(filesWithEntryDirectoryRoot);
await download(filesWithoutLockfiles, workPath);
await download(await glob('.nuxt/**', workPath), cachePath);
await download(await glob('node_modules/**', workPath), cachePath);
console.log('.nuxt folder contents', await glob('.nuxt/**', cachePath));
console.log(
'.cache folder contents',
await glob('node_modules/.cache/**', cachePath),
);
console.log('running npm install...');
await runNpmInstall(cachePath);
return {
...(await glob('.nuxt/server/index.spa.html', cachePath)),
...(await glob('.nuxt/server/index.ssr.html', cachePath)),
...(await glob('.nuxt/server/vue-ssr-client-manifest.json', cachePath)),
...(await glob('.nuxt/server/server-bundle.json', cachePath)),
...(await glob('node_modules/**', cachePath)),
async function downloadFiles(files, entrypoint, workPath) {
console.log('Downloading files...');
const downloadedFiles = await download(files, workPath);
const entryPath = downloadedFiles[entrypoint].fsPath;
return { files: downloadedFiles, entryPath };
}