Skip to content

Commit

Permalink
privatize symb-message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico Ramirez committed Nov 19, 2023
1 parent 482a81a commit 921bc77
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ yarn-error.log*
next-env.d.ts

# other
.idea/
.idea/

src/modules/aifn/bigquery/symb-message.ts
34 changes: 34 additions & 0 deletions generate-private-msg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// generate-config.js
const fs = require('fs');
const path = require('path');
const fetch = require('node-fetch');

const outputPath = path.join('src', 'modules', 'aifn', 'bigquery', 'symb-message.ts');

async function fetchGistContent(gistUrl) {
const response = await fetch(gistUrl);
if (!response.ok) {
throw new Error(`Gist fetch failed: ${response.statusText}`);
}
return response.text();
}

async function generateConfig() {
let content;

// When running on Netlify, fetch the content from the Gist
const gistUrl = process.env.SYMB_MESSAGE_GIST_URL;
if (!gistUrl) {
console.warn('\nWARNING: Environment variable SYMB_MESSAGE_GIST_URL is not set. Skipping generation of symb-message.ts.\n');
return;
}
content = await fetchGistContent(gistUrl);

// Write the content to the file used in the build
fs.writeFileSync(outputPath, content);
}

generateConfig().catch((error) => {
console.error(error);
process.exit(1); // Exit with a failure code
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"build": "node generate-private-msg.js && next build",
"start": "next start",
"lint": "next lint",
"env:pull": "npx vercel env pull .env.development.local",
Expand Down

0 comments on commit 921bc77

Please sign in to comment.