[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:
Steven
2020-08-10 17:20:13 -04:00
committed by GitHub
parent 2f0ea24552
commit edb31fb412
6 changed files with 68 additions and 16 deletions

View File

@@ -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,
};