mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-10 12:57:47 +00:00
[redwood] Fix file permissions and add support for build script (#4999)
Some files require execution privileges, such as Prisma, so we must preserve the file mode. We also want redwood to behave the same as other frameworks and use `yarn build` if available.
This commit is contained in:
@@ -3,6 +3,7 @@ const { createHash } = require('crypto');
|
||||
const path = require('path');
|
||||
const _fetch = require('node-fetch');
|
||||
const fetch = require('./fetch-retry.js');
|
||||
const fileModeSymbol = Symbol('fileMode');
|
||||
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
|
||||
|
||||
async function nowDeploy(bodies, randomness, uploadNowJson) {
|
||||
@@ -14,7 +15,9 @@ async function nowDeploy(bodies, randomness, uploadNowJson) {
|
||||
sha: digestOfFile(bodies[n]),
|
||||
size: bodies[n].length,
|
||||
file: n,
|
||||
mode: path.extname(n) === '.sh' ? 0o100755 : 0o100644,
|
||||
mode:
|
||||
bodies[n][fileModeSymbol] ||
|
||||
(path.extname(n) === '.sh' ? 0o100755 : 0o100644),
|
||||
}));
|
||||
|
||||
const { FORCE_BUILD_IN_REGION, NOW_DEBUG, VERCEL_DEBUG } = process.env;
|
||||
@@ -80,9 +83,7 @@ async function nowDeploy(bodies, randomness, uploadNowJson) {
|
||||
}
|
||||
|
||||
function digestOfFile(body) {
|
||||
return createHash('sha1')
|
||||
.update(body)
|
||||
.digest('hex');
|
||||
return createHash('sha1').update(body).digest('hex');
|
||||
}
|
||||
|
||||
async function filePost(body, digest) {
|
||||
@@ -247,4 +248,5 @@ module.exports = {
|
||||
fetchWithAuth,
|
||||
nowDeploy,
|
||||
fetchTokenWithRetry,
|
||||
fileModeSymbol,
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ const glob = require('util').promisify(require('glob'));
|
||||
const path = require('path');
|
||||
const { spawn } = require('child_process');
|
||||
const fetch = require('./fetch-retry.js');
|
||||
const { nowDeploy } = require('./now-deploy.js');
|
||||
const { nowDeploy, fileModeSymbol } = require('./now-deploy.js');
|
||||
|
||||
async function packAndDeploy(builderPath) {
|
||||
await spawnAsync('npm', ['--loglevel', 'warn', 'pack'], {
|
||||
@@ -37,6 +37,7 @@ async function testDeployment(
|
||||
const bodies = globResult.reduce((b, f) => {
|
||||
const r = path.relative(fixturePath, f);
|
||||
b[r] = fs.readFileSync(f);
|
||||
b[r][fileModeSymbol] = fs.statSync(f).mode;
|
||||
return b;
|
||||
}, {});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user