Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(`using default ${tsconfig}`)
fs.outputJsonSync(ftsTsConfigPath, {
compilerOptions: {
target: 'es2015',
moduleResolution: 'node'
}
})
}
// TODO: for local testing purposes
// console.log('linking dependencies for fts...')
// execa.shellSync('yarn link fts fts-http', { cwd: ftsPath, stdio: 'inherit' })
console.log()
console.log('installing dependencies for fts...')
await runNpmInstall(ftsPath, npmArguments)
return [downloadedFiles, nccPath, ftsPath, entrypointFsDirname]
}
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...');
await runPackageJsonScript(workPath, 'now-build');
console.log('running npm install --production...');
await runNpmInstall(workPath, ['--prefer-offline', '--production']);
if (process.env.NPM_AUTH_TOKEN) {
await unlink(path.join(workPath, '.npmrc'));
}
const filesAfterBuild = await glob('**', workPath);
console.log('preparing lambda files...');
const dotNuxtServerRootFiles = await glob('.nuxt/dist/*', workPath);
const nodeModules = excludeFiles(
await glob('node_modules/**', workPath),
file => file.startsWith('node_modules/.cache'),
);
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...')
await runNpmInstall(nccPath, npmArguments)
console.log('writing fts package.json...')
fs.outputJsonSync(path.join(ftsPath, 'package.json'), {
dependencies: {
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)),
...(await glob('yarn.lock', cachePath)),
};
};
async function installDependencies(files, workPath) {
const hasPkgJSON = Boolean(files['package.json']);
if (hasPkgJSON) {
console.log('Installing dependencies...');
await runNpmInstall(workPath, ['--prefer-offline']);
} else {
throw new Error('Missing package.json');
}
}
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...')
await runNpmInstall(nccPath, npmArguments)
console.log('writing fts package.json...')
fs.outputJsonSync(path.join(ftsPath, 'package.json'), {
dependencies: {
fts: 'latest',
'fts-http': 'latest'
}
})
const ftsTsConfigPath = path.join(ftsPath, tsconfig)
if (downloadedFiles[tsconfig]) {
console.log(`copying ${tsconfig}`)
fs.copySync(downloadedFiles[tsconfig].fsPath, ftsTsConfigPath)
} else {
console.log(`using default ${tsconfig}`)
fs.outputJsonSync(ftsTsConfigPath, {