mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-06 12:57:46 +00:00
In a previous release, we pinned the node version to the project so that we could upgrade new projects to a newer version of Node.js while maintaining backwards compatibility with existing projects. This puts some burden on the user when they're deployment is a year old and their pinned version of Node reaches EOL. Because we currently force the user to add a package.json. This PR changes the behavior so projects are no longer pinned. Instead, newer deployments get the latest Node unless they opt-in and pin via package.json.
63 lines
1.5 KiB
JavaScript
63 lines
1.5 KiB
JavaScript
const {
|
|
getLatestNodeVersion,
|
|
glob,
|
|
getWriteableDirectory,
|
|
} = require('@now/build-utils');
|
|
|
|
function runAnalyze(wrapper, context) {
|
|
if (wrapper.analyze) {
|
|
return wrapper.analyze(context);
|
|
}
|
|
|
|
return 'this-is-a-fake-analyze-result-from-default-analyze';
|
|
}
|
|
|
|
async function runBuildLambda(inputPath) {
|
|
const inputFiles = await glob('**', inputPath);
|
|
const nowJsonRef = inputFiles['now.json'];
|
|
expect(nowJsonRef).toBeDefined();
|
|
const nowJson = require(nowJsonRef.fsPath);
|
|
expect(nowJson.builds.length).toBe(1);
|
|
const build = nowJson.builds[0];
|
|
expect(build.src.includes('*')).toBeFalsy();
|
|
const entrypoint = build.src.replace(/^\//, ''); // strip leftmost slash
|
|
expect(inputFiles[entrypoint]).toBeDefined();
|
|
inputFiles[entrypoint].digest =
|
|
'this-is-a-fake-digest-for-non-default-analyze';
|
|
const wrapper = require(build.use);
|
|
|
|
const analyzeResult = runAnalyze(wrapper, {
|
|
files: inputFiles,
|
|
entrypoint,
|
|
config: build.config,
|
|
});
|
|
|
|
const workPath = await getWriteableDirectory();
|
|
const buildResult = await wrapper.build({
|
|
files: inputFiles,
|
|
entrypoint,
|
|
config: build.config,
|
|
workPath,
|
|
});
|
|
const { output } = buildResult;
|
|
|
|
// Windows support
|
|
if (output) {
|
|
buildResult.output = Object.keys(output).reduce(
|
|
(result, path) => ({
|
|
...result,
|
|
[path.replace(/\\/g, '/')]: output[path],
|
|
}),
|
|
{}
|
|
);
|
|
}
|
|
|
|
return {
|
|
analyzeResult,
|
|
buildResult,
|
|
workPath,
|
|
};
|
|
}
|
|
|
|
module.exports = runBuildLambda;
|