@flux-lang/flux 0.1.9 → 0.1.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin/flux.js +31 -8
  2. package/package.json +1 -1
package/dist/bin/flux.js CHANGED
@@ -178,14 +178,25 @@ async function ensureInstalled(version) {
178
178
  await withLock(async () => {
179
179
  await fs.mkdir(installDir, { recursive: true });
180
180
  const packages = SELF_UPDATE_PACKAGES.map((name) => `${name}@${version}`);
181
- const args = ["install", ...packages, "--no-audit", "--no-fund", "--prefix", installDir];
182
- const { exitCode, stdout, stderr } = await spawnAsync("npm", args, { env: npmEnv() });
183
- if (exitCode !== 0) {
184
- const details = [stdout, stderr].map((chunk) => chunk.trim()).filter(Boolean).join("\n");
185
- throw new Error(`Failed to install ${packages.join(", ")}.\n` +
186
- `Command: npm ${args.join(" ")}\n` +
187
- `${details || "No npm output captured."}`);
188
- }
181
+ await withTempNpmUserConfig(async (userConfigPath) => {
182
+ const args = [
183
+ "install",
184
+ ...packages,
185
+ "--no-audit",
186
+ "--no-fund",
187
+ "--prefix",
188
+ installDir,
189
+ "--userconfig",
190
+ userConfigPath,
191
+ ];
192
+ const { exitCode, stdout, stderr } = await spawnAsync("npm", args, { env: npmEnv() });
193
+ if (exitCode !== 0) {
194
+ const details = [stdout, stderr].map((chunk) => chunk.trim()).filter(Boolean).join("\n");
195
+ throw new Error(`Failed to install ${packages.join(", ")}.\n` +
196
+ `Command: npm ${args.join(" ")}\n` +
197
+ `${details || "No npm output captured."}`);
198
+ }
199
+ });
189
200
  });
190
201
  const installedPkg = await loadPackageJsonFrom(cliPackageDir(installDir));
191
202
  if (!installedPkg?.bin?.flux) {
@@ -255,6 +266,18 @@ async function resolveTargetVersions(cfg, overrides, verbose) {
255
266
  function npmEnv() {
256
267
  return { ...process.env, npm_config_update_notifier: "false" };
257
268
  }
269
+ async function withTempNpmUserConfig(fn) {
270
+ await fs.mkdir(paths.cache, { recursive: true });
271
+ const tempDir = await fs.mkdtemp(path.join(paths.cache, "npm-"));
272
+ const userConfigPath = path.join(tempDir, "npmrc");
273
+ await fs.writeFile(userConfigPath, "always-auth=false\nregistry=https://registry.npmjs.org/\n");
274
+ try {
275
+ return await fn(userConfigPath);
276
+ }
277
+ finally {
278
+ await fs.rm(tempDir, { recursive: true, force: true });
279
+ }
280
+ }
258
281
  async function withLock(fn) {
259
282
  await fs.mkdir(path.dirname(LOCK_PATH), { recursive: true });
260
283
  let handle = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flux-lang/flux",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "description": "Global Flux launcher that keeps @flux-lang/cli up to date and cached",
5
5
  "license": "MIT",
6
6
  "author": "Sebastian Suarez-Solis",