mirror of
https://github.com/glitternetwork/pinme.git
synced 2026-08-28 17:42:38 +08:00
fix: improve npm command handling and error reporting in installProjectDependencies
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
This commit is contained in:
@@ -2,16 +2,26 @@ import fs from 'fs-extra';
|
||||
import os from 'os';
|
||||
import path from 'path';
|
||||
import chalk from 'chalk';
|
||||
import { execFileSync } from 'child_process';
|
||||
import { execFileSync, spawnSync } from 'child_process';
|
||||
|
||||
function makeTempCacheDir(): string {
|
||||
return fs.mkdtempSync(path.join(os.tmpdir(), 'pinme-npm-cache-'));
|
||||
}
|
||||
|
||||
function getNpmCommand(): string {
|
||||
// On Windows, npm is often installed as npm.cmd
|
||||
if (process.platform === 'win32') {
|
||||
return 'npm.cmd';
|
||||
}
|
||||
return 'npm';
|
||||
}
|
||||
|
||||
function runInstall(cwd: string, cacheDir: string): void {
|
||||
execFileSync('npm', ['install', '--cache', cacheDir, '--no-audit', '--no-fund'], {
|
||||
const npm = getNpmCommand();
|
||||
const result = spawnSync(npm, ['install', '--cache', cacheDir, '--no-audit', '--no-fund'], {
|
||||
cwd,
|
||||
stdio: 'inherit',
|
||||
shell: true,
|
||||
env: {
|
||||
...process.env,
|
||||
npm_config_cache: cacheDir,
|
||||
@@ -19,6 +29,14 @@ function runInstall(cwd: string, cacheDir: string): void {
|
||||
npm_config_fund: 'false',
|
||||
},
|
||||
});
|
||||
|
||||
if (result.error) {
|
||||
throw result.error;
|
||||
}
|
||||
|
||||
if (result.status !== 0) {
|
||||
throw new Error(`npm install failed with exit code ${result.status}`);
|
||||
}
|
||||
}
|
||||
|
||||
export function installProjectDependencies(cwd: string): void {
|
||||
|
||||
@@ -3,7 +3,10 @@ const esbuild = require('esbuild');
|
||||
|
||||
const define = {};
|
||||
for (const key in process.env) {
|
||||
define[`process.env.${key}`] = JSON.stringify(process.env[key]);
|
||||
// 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);
|
||||
|
||||
Generated
+38
-40
@@ -9,95 +9,95 @@ importers:
|
||||
.:
|
||||
dependencies:
|
||||
archiver:
|
||||
specifier: ^7.0.1
|
||||
specifier: 7.0.1
|
||||
version: 7.0.1
|
||||
axios:
|
||||
specifier: ^1.3.2
|
||||
specifier: 1.3.2
|
||||
version: 1.3.2
|
||||
base-x:
|
||||
specifier: ^5.0.1
|
||||
specifier: 5.0.1
|
||||
version: 5.0.1
|
||||
bip39:
|
||||
specifier: ^3.1.0
|
||||
specifier: 3.1.0
|
||||
version: 3.1.0
|
||||
chalk:
|
||||
specifier: ^2.4.2
|
||||
specifier: 2.4.2
|
||||
version: 2.4.2
|
||||
commander:
|
||||
specifier: ^11.1.0
|
||||
specifier: 11.1.0
|
||||
version: 11.1.0
|
||||
crypto-js:
|
||||
specifier: ^4.2.0
|
||||
specifier: 4.2.0
|
||||
version: 4.2.0
|
||||
dayjs:
|
||||
specifier: ^1.11.7
|
||||
specifier: 1.11.7
|
||||
version: 1.11.7
|
||||
ethers:
|
||||
specifier: 5.7.2
|
||||
version: 5.7.2
|
||||
figlet:
|
||||
specifier: ^1.7.0
|
||||
specifier: 1.7.0
|
||||
version: 1.7.0
|
||||
form-data:
|
||||
specifier: ^4.0.0
|
||||
specifier: 4.0.0
|
||||
version: 4.0.0
|
||||
formdata-node:
|
||||
specifier: ^6.0.3
|
||||
specifier: 6.0.3
|
||||
version: 6.0.3
|
||||
fs-extra:
|
||||
specifier: ^11.2.0
|
||||
specifier: 11.2.0
|
||||
version: 11.2.0
|
||||
inquirer:
|
||||
specifier: ^8.2.5
|
||||
specifier: 8.2.6
|
||||
version: 8.2.6
|
||||
ora:
|
||||
specifier: ^3.2.0
|
||||
specifier: 3.4.0
|
||||
version: 3.4.0
|
||||
uuid:
|
||||
specifier: ^9.0.0
|
||||
specifier: 9.0.1
|
||||
version: 9.0.1
|
||||
devDependencies:
|
||||
'@rollup/plugin-commonjs':
|
||||
specifier: ^22.0.2
|
||||
specifier: 22.0.2
|
||||
version: 22.0.2(rollup@2.79.2)
|
||||
'@rollup/plugin-json':
|
||||
specifier: ^4.1.0
|
||||
specifier: 4.1.0
|
||||
version: 4.1.0(rollup@2.79.2)
|
||||
'@rollup/plugin-node-resolve':
|
||||
specifier: ^14.1.0
|
||||
specifier: 14.1.0
|
||||
version: 14.1.0(rollup@2.79.2)
|
||||
dotenv:
|
||||
specifier: ^16.5.0
|
||||
specifier: 16.5.0
|
||||
version: 16.5.0
|
||||
esbuild:
|
||||
specifier: ^0.25.2
|
||||
specifier: 0.25.2
|
||||
version: 0.25.2
|
||||
eslint:
|
||||
specifier: ^8.33.0
|
||||
specifier: 8.33.0
|
||||
version: 8.33.0
|
||||
eslint-config-airbnb-base:
|
||||
specifier: ^15.0.0
|
||||
specifier: 15.0.0
|
||||
version: 15.0.0(eslint-plugin-import@2.27.5(eslint@8.33.0))(eslint@8.33.0)
|
||||
eslint-config-prettier:
|
||||
specifier: ^8.6.0
|
||||
specifier: 8.6.0
|
||||
version: 8.6.0(eslint@8.33.0)
|
||||
eslint-plugin-import:
|
||||
specifier: ^2.27.5
|
||||
specifier: 2.27.5
|
||||
version: 2.27.5(eslint@8.33.0)
|
||||
eslint-plugin-prettier:
|
||||
specifier: ^4.2.1
|
||||
specifier: 4.2.1
|
||||
version: 4.2.1(eslint-config-prettier@8.6.0(eslint@8.33.0))(eslint@8.33.0)(prettier@2.8.3)
|
||||
prettier:
|
||||
specifier: ^2.8.3
|
||||
specifier: 2.8.3
|
||||
version: 2.8.3
|
||||
rollup:
|
||||
specifier: ^2.79.1
|
||||
specifier: 2.79.2
|
||||
version: 2.79.2
|
||||
rollup-plugin-copy:
|
||||
specifier: ^3.5.0
|
||||
specifier: 3.5.0
|
||||
version: 3.5.0
|
||||
rollup-plugin-terser:
|
||||
specifier: ^7.0.2
|
||||
specifier: 7.0.2
|
||||
version: 7.0.2(rollup@2.79.2)
|
||||
|
||||
packages:
|
||||
@@ -361,6 +361,7 @@ packages:
|
||||
'@humanwhocodes/config-array@0.11.8':
|
||||
resolution: {integrity: sha512-UybHIJzJnR5Qc/MsD9Kr+RpO2h+/P1GhOwdiLPXK5TWk5sgTdu88bTD9UP+CKbPPh5Rni1u0GjAdYQLemG8g+g==}
|
||||
engines: {node: '>=10.10.0'}
|
||||
deprecated: Use @eslint/config-array instead
|
||||
|
||||
'@humanwhocodes/module-importer@1.0.1':
|
||||
resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==}
|
||||
@@ -368,6 +369,7 @@ packages:
|
||||
|
||||
'@humanwhocodes/object-schema@1.2.1':
|
||||
resolution: {integrity: sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA==}
|
||||
deprecated: Use @eslint/object-schema instead
|
||||
|
||||
'@isaacs/cliui@8.0.2':
|
||||
resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==}
|
||||
@@ -699,10 +701,6 @@ packages:
|
||||
resolution: {integrity: sha512-piICUB6ei4IlTv1+653yq5+KoqfBYmj9bw6LqXoOneTMDXk5nM1qt12mFW1caG3LlJXEKW1Bp0WggEmIfQB34g==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
cross-spawn@7.0.3:
|
||||
resolution: {integrity: sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==}
|
||||
engines: {node: '>= 8'}
|
||||
@@ -883,6 +881,7 @@ packages:
|
||||
eslint@8.33.0:
|
||||
resolution: {integrity: sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
deprecated: This version is no longer supported. Please see https://eslint.org/version-support for other options.
|
||||
hasBin: true
|
||||
|
||||
espree@9.4.1:
|
||||
@@ -1043,10 +1042,12 @@ packages:
|
||||
|
||||
glob@10.4.5:
|
||||
resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
hasBin: true
|
||||
|
||||
glob@7.2.3:
|
||||
resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==}
|
||||
deprecated: Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me
|
||||
|
||||
globals@13.20.0:
|
||||
resolution: {integrity: sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==}
|
||||
@@ -1126,6 +1127,7 @@ packages:
|
||||
|
||||
inflight@1.0.6:
|
||||
resolution: {integrity: sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==}
|
||||
deprecated: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
|
||||
|
||||
inherits@2.0.4:
|
||||
resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==}
|
||||
@@ -1538,6 +1540,7 @@ packages:
|
||||
|
||||
rimraf@3.0.2:
|
||||
resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==}
|
||||
deprecated: Rimraf versions prior to v4 are no longer supported
|
||||
hasBin: true
|
||||
|
||||
rollup-plugin-copy@3.5.0:
|
||||
@@ -1740,6 +1743,7 @@ packages:
|
||||
|
||||
uuid@9.0.1:
|
||||
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
||||
deprecated: uuid@10 and below is no longer supported. For ESM codebases, update to uuid@latest. For CommonJS codebases, use uuid@11 (but be aware this version will likely be deprecated in 2028).
|
||||
hasBin: true
|
||||
|
||||
wcwidth@1.0.1:
|
||||
@@ -2507,12 +2511,6 @@ snapshots:
|
||||
crc-32: 1.2.2
|
||||
readable-stream: 4.7.0
|
||||
|
||||
cross-spawn@7.0.3:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
shebang-command: 2.0.0
|
||||
which: 2.0.2
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
dependencies:
|
||||
path-key: 3.1.1
|
||||
@@ -2743,7 +2741,7 @@ snapshots:
|
||||
'@nodelib/fs.walk': 1.2.8
|
||||
ajv: 6.12.6
|
||||
chalk: 4.1.2
|
||||
cross-spawn: 7.0.3
|
||||
cross-spawn: 7.0.6
|
||||
debug: 4.3.4
|
||||
doctrine: 3.0.0
|
||||
escape-string-regexp: 4.0.0
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
allowBuilds:
|
||||
esbuild: true
|
||||
Reference in New Issue
Block a user