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.
This commit is contained in:
Sean Massa
2023-05-17 12:45:28 -05:00
committed by GitHub
parent c879401bbc
commit 5124d431ea
2 changed files with 23 additions and 8 deletions

View File

@@ -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'),

19
utils/pack.ts vendored
View File

@@ -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<string> {
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);