📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
added import-env script
Blue Mouse7698a170a59e
diff --git a/fly_import_env.js b/fly_import_env.jsnew file mode 100644index 000000000..5c5798fc3--- /dev/null+++ b/fly_import_env.js@@ -0,0 +1,64 @@+const fs = require('fs')+const { execSync } = require('child_process')++const args = process.argv.slice(2)++function parseArgs(args) {+ const parsedArgs = {}+ let i = 0+ while (i < args.length) {+ const arg = args[i]+ if (arg.startsWith('--')) {+ const key = arg.slice(2)+ const value = args[i + 1]+ parsedArgs[key] = value+ i += 2+ } else {+ i += 1+ }+ }+ return parsedArgs+}++function getSecretsFromEnvFile(envFile) {+ const kvPairs = {}++ const fileContents = fs.readFileSync(envFile, 'utf8')+ const lines = fileContents.split('\n')+ for (const line of lines) {+ const trimmedLine = line.trim()+ if (!trimmedLine || trimmedLine.startsWith('#')) {+ continue+ }+ const [key, value] = trimmedLine.split('=', 2)+ if (!value) {+ continue+ }+ const strippedValue = value.replace(/["']/g, '')+ kvPairs[key] = strippedValue+ }++ return kvPairs+}++function flyImport(secrets) {+ const buildSecrets = []+ for (const [key, value] of Object.entries(secrets)) {+ buildSecrets.push(`${key}=${value}`)+ console.log(`Set .env variable ${key}`)+ }++ const command = [+ 'flyctl',+ 'secrets',+ 'import',+ ...buildSecrets,+ ]++ console.log(`Running command: ${command.join(' ')}`)+ // execSync(command.join(' '), { stdio: 'inherit' })+}++const parsedArgs = parseArgs(args)+const envValues = getSecretsFromEnvFile(parsedArgs['env-file'])+flyImport(envValues)diff --git a/package.json b/package.jsonindex f30c9a8eb..8c36804db 100644--- a/package.json+++ b/package.json@@ -5,6 +5,7 @@"build": "remix build","dev": "remix dev","deploy": "node fly_deploy_with_env.js --env-file .env --remote-only",+ "import-env": "node fly_import_env.js --env-file .env","dev:staging": "cross-env STAGING=true remix dev","start": "remix-serve build","start:staging": "cross-env STAGING=true remix-serve build",