mirror of
https://github.com/glitternetwork/pinme.git
synced 2026-08-28 17:42:38 +08:00
2694e3e56c
refactor: skip invalid environment variable identifiers in build.js chore: update dependency specifiers in pnpm-lock.yaml for consistency feat: add pnpm-workspace.yaml to allow esbuild builds
26 lines
858 B
JavaScript
26 lines
858 B
JavaScript
require('dotenv').config();
|
|
const esbuild = require('esbuild');
|
|
|
|
const define = {};
|
|
for (const key in process.env) {
|
|
// Skip env vars with invalid identifier characters (e.g., Windows vars like ProgramFiles(x86))
|
|
if (/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key)) {
|
|
define[`process.env.${key}`] = JSON.stringify(process.env[key]);
|
|
}
|
|
}
|
|
|
|
define['process.env.IPFS_PREVIEW_URL'] = JSON.stringify(process.env.IPFS_PREVIEW_URL);
|
|
define['process.env.SECRET_KEY'] = JSON.stringify(process.env.SECRET_KEY);
|
|
|
|
esbuild.build({
|
|
entryPoints: ['bin/index.ts'],
|
|
outfile: 'dist/index.js',
|
|
bundle: true,
|
|
platform: 'node',
|
|
target: 'node14',
|
|
format: 'cjs',
|
|
external: Object.keys(require('./package.json').dependencies || {}).filter(dep => dep !== 'axios'),
|
|
banner: { js: '#!/usr/bin/env node' },
|
|
logLevel: 'info',
|
|
define,
|
|
}).catch(() => process.exit(1));
|