From 5124d431eaa1a513110a55271558cdf48e1f23e3 Mon Sep 17 00:00:00 2001 From: Sean Massa Date: Wed, 17 May 2023 12:45:28 -0500 Subject: [PATCH] fix deploy from local (#9969) Local deployments of this repo would fail because this repo assumes that it's only ever deployed via git connection. --- packages/node/build.js | 12 +++++++----- utils/pack.ts | 19 ++++++++++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/packages/node/build.js b/packages/node/build.js index f1cebc78d..292159914 100644 --- a/packages/node/build.js +++ b/packages/node/build.js @@ -48,11 +48,13 @@ async function main() { fs.remove(join(outDir, 'serverless-functions/serverless-handler.d.mts')), ]); - // Copy type file for ts test - await fs.copyFile( - join(outDir, 'index.d.ts'), - join(__dirname, 'test/fixtures/15-helpers/ts/types.d.ts') - ); + if (process.env.CI) { + // Copy type file for ts test + await fs.copyFile( + join(outDir, 'index.d.ts'), + join(__dirname, 'test/fixtures/15-helpers/ts/types.d.ts') + ); + } await fs.copyFile( join(__dirname, 'src/edge-functions/edge-handler-template.js'), diff --git a/utils/pack.ts b/utils/pack.ts index 55dcc3bae..8f4cd149c 100644 --- a/utils/pack.ts +++ b/utils/pack.ts @@ -6,9 +6,8 @@ import { TurboDryRun } from './types'; const rootDir = path.join(__dirname, '..'); async function main() { - const { stdout: sha } = await execa('git', ['rev-parse', '--short', 'HEAD'], { - cwd: rootDir, - }); + const sha = await getSha(); + const { stdout: turboStdout } = await execa( 'turbo', ['run', 'build', '--dry=json'], @@ -50,6 +49,20 @@ async function main() { } } +async function getSha(): Promise { + try { + const { stdout } = await execa('git', ['rev-parse', '--short', 'HEAD'], { + cwd: rootDir, + }); + return stdout; + } catch (error) { + console.error(error); + + console.log('Assuming this is not a git repo. Using "local" as the SHA.'); + return 'local'; + } +} + main().catch(err => { console.log('error running pack:', err); process.exit(1);