Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as p from '@clack/prompts'
import { defineCommand, runMain } from 'citty'
import { serve } from 'srvx'
import { createConnectorApp, generateToken, CONNECTOR_VERSION } from './server.ts'
import { getNpmUser } from './npm-client.ts'
import { getNpmUser, NPM_REGISTRY_URL } from './npm-client.ts'
import { initLogger, showToken, logInfo, logWarning, logError } from './logger.ts'

const DEFAULT_PORT = 31415
Expand All @@ -15,7 +15,7 @@ const DEV_FRONTEND_URL = 'http://127.0.0.1:3000/'

async function runNpmLogin(): Promise<boolean> {
return new Promise(resolve => {
const child = spawn('npm', ['login'], {
const child = spawn('npm', ['login', `--registry=${NPM_REGISTRY_URL}`], {
stdio: 'inherit',
shell: true,
})
Expand Down
19 changes: 13 additions & 6 deletions cli/src/npm-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ import { PackageNameSchema, UsernameSchema, OrgNameSchema, ScopeTeamSchema } fro
import { logCommand, logSuccess, logError, logDebug } from './logger.ts'

const execFileAsync = promisify(execFile)
export const NPM_REGISTRY_URL = 'https://registry.npmjs.org/'

function createNpmEnv(overrides: Record<string, string> = {}): Record<string, string> {
return {
...(process.env as Record<string, string>),
...overrides,
FORCE_COLOR: '0',
npm_config_registry: NPM_REGISTRY_URL,
}
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

/**
* Validates an npm package name using the official npm validation package
Expand Down Expand Up @@ -191,10 +201,7 @@ async function execNpmInteractive(
let authUrlTimeout: ReturnType<typeof setTimeout> | null = null
let authUrlTimedOut = false

const env: Record<string, string> = {
...(process.env as Record<string, string>),
FORCE_COLOR: '0',
}
const env = createNpmEnv()

// When openUrls is false, tell npm not to open the browser.
// npm still prints the auth URL and polls doneUrl
Expand Down Expand Up @@ -330,7 +337,7 @@ async function execNpm(args: string[], options: ExecNpmOptions = {}): Promise<Np
// On Unix, we keep it false for better security and performance
const { stdout, stderr } = await execFileAsync('npm', npmArgs, {
timeout: 60000,
env: { ...process.env, FORCE_COLOR: '0' },
env: createNpmEnv(),
shell: process.platform === 'win32',
})

Expand Down Expand Up @@ -606,7 +613,7 @@ export async function packageInit(
const { stdout, stderr } = await execFileAsync('npm', npmArgs, {
timeout: 60000,
cwd: tempDir,
env: { ...process.env, FORCE_COLOR: '0' },
env: createNpmEnv(),
shell: process.platform === 'win32',
})

Expand Down
Loading