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 installPhp({ workPath, config }) {
console.log(`🐘 Installing PHP ${configuration.getVersion(config)} lib.`);
// Install defined PHP version on the fly into the tmp folder
const packageJson = {
dependencies: {
[configuration.getPhpNpm(config)]: 'canary',
}
};
const packageJsonPath = path.join(workPath, 'package.json');
await writeFile(packageJsonPath, JSON.stringify(packageJson));
await runNpmInstall(path.dirname(packageJsonPath), [
'--prod',
'--prefer-offline',
]);
console.log(`🐘 Installing PHP ${configuration.getVersion(config)} lib OK.`);
}
workPath,
config,
meta,
}: DownloadOptions) {
const downloadedFiles = await download(files, workPath, meta);
console.log('Installing dependencies...');
const installTime = Date.now();
const entrypointFsDirname = join(workPath, dirname(entrypoint));
const nodeVersion = await getNodeVersion(
entrypointFsDirname,
undefined,
config
);
const spawnOpts = getSpawnOptions(meta, nodeVersion);
await runNpmInstall(
entrypointFsDirname,
['--prefer-offline'],
spawnOpts,
meta
);
debug(`Install complete [${Date.now() - installTime}ms]`);
const entrypointPath = downloadedFiles[entrypoint].fsPath;
return { entrypointPath, entrypointFsDirname, nodeVersion, spawnOpts };
}
);
pkg.scripts = {
'now-build': 'next build',
...(pkg.scripts || {}),
};
shouldRunScript = 'now-build';
await writePackageJson(entryPath, pkg);
}
if (process.env.NPM_AUTH_TOKEN) {
debug('Found NPM_AUTH_TOKEN in environment, creating .npmrc');
await writeNpmRc(entryPath, process.env.NPM_AUTH_TOKEN);
}
console.log('Installing dependencies...');
await runNpmInstall(entryPath, ['--prefer-offline'], spawnOpts, meta);
let realNextVersion: string | undefined;
try {
realNextVersion = require(resolveFrom(entryPath, 'next/package.json'))
.version;
debug(`Detected Next.js version: ${realNextVersion}`);
} catch (_ignored) {
debug(`Could not identify real Next.js version, that's OK!`);
}
if (!isLegacy) {
await createServerlessConfig(workPath, entryPath, realNextVersion);
}
debug('Running user script...');