Compare commits
1 Commits
| Author | SHA1 | Date |
|---|---|---|
|
|
36b5abfb3b |
|
|
@ -28,6 +28,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"@typescript-eslint/consistent-indexed-object-style": "off",
|
||||||
"@typescript-eslint/naming-convention": "error",
|
"@typescript-eslint/naming-convention": "error",
|
||||||
"@typescript-eslint/explicit-function-return-type": "off",
|
"@typescript-eslint/explicit-function-return-type": "off",
|
||||||
"@typescript-eslint/no-explicit-any": "error",
|
"@typescript-eslint/no-explicit-any": "error",
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,9 @@ export function initDefaultReporter (
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const log$ = Rx.fromEvent<logs.Log>(opts.streamParser as any, 'data')
|
const log$ = Rx.fromEvent<logs.Log>(opts.streamParser as any, 'data')
|
||||||
const subscription = reporterForServer(log$, opts.context.config)
|
const subscription = reporterForServer(log$, opts.context.config)
|
||||||
return () => subscription.unsubscribe()
|
return () => {
|
||||||
|
subscription.unsubscribe()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const outputMaxWidth = opts.reportingOptions?.outputMaxWidth ?? (process.stdout.columns && process.stdout.columns - 2) ?? 80
|
const outputMaxWidth = opts.reportingOptions?.outputMaxWidth ?? (process.stdout.columns && process.stdout.columns - 2) ?? 80
|
||||||
const output$ = toOutput$({
|
const output$ = toOutput$({
|
||||||
|
|
@ -53,10 +55,14 @@ export function initDefaultReporter (
|
||||||
const subscription = output$
|
const subscription = output$
|
||||||
.subscribe({
|
.subscribe({
|
||||||
complete () {}, // eslint-disable-line:no-empty
|
complete () {}, // eslint-disable-line:no-empty
|
||||||
error: (err) => console.error(err.message),
|
error: (err) => {
|
||||||
|
console.error(err.message)
|
||||||
|
},
|
||||||
next: writeNext,
|
next: writeNext,
|
||||||
})
|
})
|
||||||
return () => subscription.unsubscribe()
|
return () => {
|
||||||
|
subscription.unsubscribe()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
const diff = createDiffer({
|
const diff = createDiffer({
|
||||||
height: process.stdout.rows,
|
height: process.stdout.rows,
|
||||||
|
|
@ -65,7 +71,7 @@ export function initDefaultReporter (
|
||||||
const subscription = output$
|
const subscription = output$
|
||||||
.subscribe({
|
.subscribe({
|
||||||
complete () {}, // eslint-disable-line:no-empty
|
complete () {}, // eslint-disable-line:no-empty
|
||||||
error: (err) => logUpdate(err.message),
|
error: (err) => { logUpdate(err.message) },
|
||||||
next: logUpdate,
|
next: logUpdate,
|
||||||
})
|
})
|
||||||
const write = opts.useStderr
|
const write = opts.useStderr
|
||||||
|
|
@ -78,7 +84,9 @@ export function initDefaultReporter (
|
||||||
if (!view.endsWith(EOL)) view += EOL
|
if (!view.endsWith(EOL)) view += EOL
|
||||||
write(diff.update(view))
|
write(diff.update(view))
|
||||||
}
|
}
|
||||||
return () => subscription.unsubscribe()
|
return () => {
|
||||||
|
subscription.unsubscribe()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toOutput$ (
|
export function toOutput$ (
|
||||||
|
|
|
||||||
|
|
@ -79,10 +79,14 @@ function makeWarningReporter (
|
||||||
collapsedWarnings = new Rx.Subject()
|
collapsedWarnings = new Rx.Subject()
|
||||||
// For some reason, without using setTimeout, the warning summary is printed above the rest of the warnings
|
// For some reason, without using setTimeout, the warning summary is printed above the rest of the warnings
|
||||||
// Even though the summary event happens last. Probably a bug in "most".
|
// Even though the summary event happens last. Probably a bug in "most".
|
||||||
setTimeout(() => collapsedWarnings.next({ msg: warningMsg }), 0)
|
setTimeout(() => {
|
||||||
|
collapsedWarnings.next({ msg: warningMsg })
|
||||||
|
}, 0)
|
||||||
return Rx.from(collapsedWarnings)
|
return Rx.from(collapsedWarnings)
|
||||||
}
|
}
|
||||||
setTimeout(() => collapsedWarnings!.next({ msg: warningMsg }), 0)
|
setTimeout(() => {
|
||||||
|
collapsedWarnings!.next({ msg: warningMsg })
|
||||||
|
}, 0)
|
||||||
return Rx.NEVER
|
return Rx.NEVER
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,9 @@ export async function buildModules (
|
||||||
hoistedLocations?: Record<string, string[]>
|
hoistedLocations?: Record<string, string[]>
|
||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
const warn = (message: string) => logger.warn({ message, prefix: opts.lockfileDir })
|
const warn = (message: string) => {
|
||||||
|
logger.warn({ message, prefix: opts.lockfileDir })
|
||||||
|
}
|
||||||
// postinstall hooks
|
// postinstall hooks
|
||||||
|
|
||||||
const buildDepOpts = { ...opts, warn }
|
const buildDepOpts = { ...opts, warn }
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,9 @@ export async function runLifecycleHook (
|
||||||
showProgress: noop,
|
showProgress: noop,
|
||||||
silly: npmLog,
|
silly: npmLog,
|
||||||
verbose: npmLog,
|
verbose: npmLog,
|
||||||
warn: (...msg: string[]) => globalWarn(msg.join(' ')),
|
warn: (...msg: string[]) => {
|
||||||
|
globalWarn(msg.join(' '))
|
||||||
|
},
|
||||||
},
|
},
|
||||||
runConcurrently: true,
|
runConcurrently: true,
|
||||||
scriptsPrependNodePath: opts.scriptsPrependNodePath,
|
scriptsPrependNodePath: opts.scriptsPrependNodePath,
|
||||||
|
|
|
||||||
|
|
@ -269,7 +269,9 @@ async function _rebuild (
|
||||||
groups: [nodesToBuildAndTransitiveArray],
|
groups: [nodesToBuildAndTransitiveArray],
|
||||||
})
|
})
|
||||||
const chunks = graphSequencerResult.chunks as string[][]
|
const chunks = graphSequencerResult.chunks as string[][]
|
||||||
const warn = (message: string) => logger.info({ message, prefix: opts.dir })
|
const warn = (message: string) => {
|
||||||
|
logger.info({ message, prefix: opts.dir })
|
||||||
|
}
|
||||||
const groups = chunks.map((chunk) => chunk.filter((depPath) => ctx.pkgsToRebuild.has(depPath)).map((depPath) =>
|
const groups = chunks.map((chunk) => chunk.filter((depPath) => ctx.pkgsToRebuild.has(depPath)).map((depPath) =>
|
||||||
async () => {
|
async () => {
|
||||||
const pkgSnapshot = pkgSnapshots[depPath]
|
const pkgSnapshot = pkgSnapshots[depPath]
|
||||||
|
|
|
||||||
|
|
@ -96,12 +96,14 @@ export function requireHooks (
|
||||||
|
|
||||||
function createReadPackageHookContext (calledFrom: string, prefix: string, hook: string): HookContext {
|
function createReadPackageHookContext (calledFrom: string, prefix: string, hook: string): HookContext {
|
||||||
return {
|
return {
|
||||||
log: (message: string) => hookLogger.debug({
|
log: (message: string) => {
|
||||||
from: calledFrom,
|
hookLogger.debug({
|
||||||
hook,
|
from: calledFrom,
|
||||||
message,
|
hook,
|
||||||
prefix,
|
message,
|
||||||
}),
|
prefix,
|
||||||
|
})
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,11 @@ import { getWantedLockfileName } from './lockfileName'
|
||||||
import { convertToInlineSpecifiersFormat } from './experiments/inlineSpecifiersLockfileConverters'
|
import { convertToInlineSpecifiersFormat } from './experiments/inlineSpecifiersLockfileConverters'
|
||||||
|
|
||||||
async function writeFileAtomic (filename: string, data: string) {
|
async function writeFileAtomic (filename: string, data: string) {
|
||||||
return new Promise<void>((resolve, reject) => writeFileAtomicCB(filename, data, {}, (err?: Error) => (err != null) ? reject(err) : resolve()))
|
return new Promise<void>((resolve, reject) => {
|
||||||
|
writeFileAtomicCB(filename, data, {}, (err?: Error) => {
|
||||||
|
(err != null) ? reject(err) : resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const LOCKFILE_YAML_FORMAT = {
|
const LOCKFILE_YAML_FORMAT = {
|
||||||
|
|
|
||||||
|
|
@ -35,36 +35,38 @@ export async function fetch (url: RequestInfo, opts: RequestInit = {}): Promise<
|
||||||
})
|
})
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return await new Promise((resolve, reject) => op.attempt(async (attempt) => {
|
return await new Promise((resolve, reject) => {
|
||||||
try {
|
op.attempt(async (attempt) => {
|
||||||
// this will be retried
|
try {
|
||||||
const res = await nodeFetch(url as any, opts) // eslint-disable-line
|
// this will be retried
|
||||||
// A retry on 409 sometimes helps when making requests to the Bit registry.
|
const res = await nodeFetch(url as any, opts) // eslint-disable-line
|
||||||
if ((res.status >= 500 && res.status < 600) || [408, 409, 420, 429].includes(res.status)) {
|
// A retry on 409 sometimes helps when making requests to the Bit registry.
|
||||||
throw new ResponseError(res)
|
if ((res.status >= 500 && res.status < 600) || [408, 409, 420, 429].includes(res.status)) {
|
||||||
} else {
|
throw new ResponseError(res)
|
||||||
resolve(res)
|
} else {
|
||||||
return
|
resolve(res)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} catch (error: any) { // eslint-disable-line
|
||||||
|
if (error.code && NO_RETRY_ERROR_CODES.has(error.code)) {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
const timeout = op.retry(error)
|
||||||
|
if (timeout === false) {
|
||||||
|
reject(op.mainError())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
requestRetryLogger.debug({
|
||||||
|
attempt,
|
||||||
|
error,
|
||||||
|
maxRetries,
|
||||||
|
method: opts.method ?? 'GET',
|
||||||
|
timeout,
|
||||||
|
url: url.toString(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} catch (error: any) { // eslint-disable-line
|
})
|
||||||
if (error.code && NO_RETRY_ERROR_CODES.has(error.code)) {
|
})
|
||||||
throw error
|
|
||||||
}
|
|
||||||
const timeout = op.retry(error)
|
|
||||||
if (timeout === false) {
|
|
||||||
reject(op.mainError())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
requestRetryLogger.debug({
|
|
||||||
attempt,
|
|
||||||
error,
|
|
||||||
maxRetries,
|
|
||||||
method: opts.method ?? 'GET',
|
|
||||||
timeout,
|
|
||||||
url: url.toString(),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}))
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (err instanceof ResponseError) {
|
if (err instanceof ResponseError) {
|
||||||
return err.res
|
return err.res
|
||||||
|
|
|
||||||
|
|
@ -996,7 +996,9 @@ const _installInContext: InstallFunction = async (projects, ctx, opts) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const binWarn = (prefix: string, message: string) => logger.info({ message, prefix })
|
const binWarn = (prefix: string, message: string) => {
|
||||||
|
logger.info({ message, prefix })
|
||||||
|
}
|
||||||
if (result.newDepPaths?.length) {
|
if (result.newDepPaths?.length) {
|
||||||
const newPkgs = props<string, DependenciesGraphNode>(result.newDepPaths, dependenciesGraph)
|
const newPkgs = props<string, DependenciesGraphNode>(result.newDepPaths, dependenciesGraph)
|
||||||
await linkAllBins(newPkgs, dependenciesGraph, {
|
await linkAllBins(newPkgs, dependenciesGraph, {
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,9 @@ export async function link (
|
||||||
|
|
||||||
const updatedCurrentLockfile = pruneSharedLockfile(ctx.currentLockfile)
|
const updatedCurrentLockfile = pruneSharedLockfile(ctx.currentLockfile)
|
||||||
|
|
||||||
const warn = (message: string) => logger.warn({ message, prefix: opts.dir })
|
const warn = (message: string) => {
|
||||||
|
logger.warn({ message, prefix: opts.dir })
|
||||||
|
}
|
||||||
const updatedWantedLockfile = pruneSharedLockfile(ctx.wantedLockfile, { warn })
|
const updatedWantedLockfile = pruneSharedLockfile(ctx.wantedLockfile, { warn })
|
||||||
|
|
||||||
// Linking should happen after removing orphans
|
// Linking should happen after removing orphans
|
||||||
|
|
|
||||||
|
|
@ -622,7 +622,9 @@ async function linkBinsOfImporter (
|
||||||
},
|
},
|
||||||
{ extraNodePaths, preferSymlinkedExecutables }: { extraNodePaths?: string[], preferSymlinkedExecutables?: boolean } = {}
|
{ extraNodePaths, preferSymlinkedExecutables }: { extraNodePaths?: string[], preferSymlinkedExecutables?: boolean } = {}
|
||||||
) {
|
) {
|
||||||
const warn = (message: string) => logger.info({ message, prefix: rootDir })
|
const warn = (message: string) => {
|
||||||
|
logger.info({ message, prefix: rootDir })
|
||||||
|
}
|
||||||
return linkBins(modulesDir, binsDir, {
|
return linkBins(modulesDir, binsDir, {
|
||||||
extraNodePaths,
|
extraNodePaths,
|
||||||
allowExoticManifests: true,
|
allowExoticManifests: true,
|
||||||
|
|
|
||||||
|
|
@ -505,7 +505,9 @@ Actual package in the store by the given integrity: ${pkgFilesIndex.name}@${pkgF
|
||||||
})
|
})
|
||||||
if (manifest != null) {
|
if (manifest != null) {
|
||||||
manifest()
|
manifest()
|
||||||
.then((manifest) => bundledManifest.resolve(manifest == null ? manifest : normalizeBundledManifest(manifest)))
|
.then((manifest) => {
|
||||||
|
bundledManifest.resolve(manifest == null ? manifest : normalizeBundledManifest(manifest))
|
||||||
|
})
|
||||||
.catch(bundledManifest.reject)
|
.catch(bundledManifest.reject)
|
||||||
}
|
}
|
||||||
finishing.resolve(undefined)
|
finishing.resolve(undefined)
|
||||||
|
|
@ -532,7 +534,9 @@ Actual package in the store by the given integrity: ${pkgFilesIndex.name}@${pkgF
|
||||||
: undefined
|
: undefined
|
||||||
if (fetchManifest != null) {
|
if (fetchManifest != null) {
|
||||||
fetchManifest()
|
fetchManifest()
|
||||||
.then((manifest) => bundledManifest.resolve(manifest == null ? manifest : normalizeBundledManifest(manifest)))
|
.then((manifest) => {
|
||||||
|
bundledManifest.resolve(manifest == null ? manifest : normalizeBundledManifest(manifest))
|
||||||
|
})
|
||||||
.catch(bundledManifest.reject)
|
.catch(bundledManifest.reject)
|
||||||
}
|
}
|
||||||
const fetchedPackage = await ctx.requestsQueue.add(async () => ctx.fetch(
|
const fetchedPackage = await ctx.requestsQueue.add(async () => ctx.fetch(
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,9 @@ test('link global bin', async function () {
|
||||||
})
|
})
|
||||||
process.env[PATH] = oldPath
|
process.env[PATH] = oldPath
|
||||||
|
|
||||||
await isExecutable((value) => expect(value).toBeTruthy(), path.join(globalBin, 'package-with-bin'))
|
await isExecutable((value) => {
|
||||||
|
expect(value).toBeTruthy()
|
||||||
|
}, path.join(globalBin, 'package-with-bin'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('link to global bin from the specified directory', async function () {
|
test('link to global bin from the specified directory', async function () {
|
||||||
|
|
@ -99,7 +101,9 @@ test('link to global bin from the specified directory', async function () {
|
||||||
})
|
})
|
||||||
process.env[PATH] = oldPath
|
process.env[PATH] = oldPath
|
||||||
|
|
||||||
await isExecutable((value) => expect(value).toBeTruthy(), path.join(globalBin, 'package-with-bin-in-dir'))
|
await isExecutable((value) => {
|
||||||
|
expect(value).toBeTruthy()
|
||||||
|
}, path.join(globalBin, 'package-with-bin-in-dir'))
|
||||||
})
|
})
|
||||||
|
|
||||||
test('link a global package to the specified directory', async function () {
|
test('link a global package to the specified directory', async function () {
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,9 @@ export function updateLockfile (
|
||||||
lockfileIncludeTarballUrl,
|
lockfileIncludeTarballUrl,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const warn = (message: string) => logger.warn({ message, prefix })
|
const warn = (message: string) => {
|
||||||
|
logger.warn({ message, prefix })
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
newLockfile: pruneSharedLockfile(lockfile, { warn }),
|
newLockfile: pruneSharedLockfile(lockfile, { warn }),
|
||||||
pendingRequiresBuilds,
|
pendingRequiresBuilds,
|
||||||
|
|
|
||||||
|
|
@ -165,6 +165,8 @@ async function packPkg (opts: {
|
||||||
pack.pipe(createGzip()).pipe(tarball)
|
pack.pipe(createGzip()).pipe(tarball)
|
||||||
pack.finalize()
|
pack.finalize()
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
tarball.on('close', () => resolve()).on('error', reject)
|
tarball.on('close', () => {
|
||||||
|
resolve()
|
||||||
|
}).on('error', reject)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ export async function fromRegistry (
|
||||||
): Promise<PackageMeta> {
|
): Promise<PackageMeta> {
|
||||||
const uri = toUri(pkgName, registry)
|
const uri = toUri(pkgName, registry)
|
||||||
const op = retry.operation(fetchOpts.retry)
|
const op = retry.operation(fetchOpts.retry)
|
||||||
return new Promise((resolve, reject) =>
|
return new Promise((resolve, reject) => {
|
||||||
op.attempt(async (attempt) => {
|
op.attempt(async (attempt) => {
|
||||||
let response: RegistryResponse
|
let response: RegistryResponse
|
||||||
try {
|
try {
|
||||||
|
|
@ -94,7 +94,7 @@ export async function fromRegistry (
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
)
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toUri (pkgName: string, registry: string) {
|
function toUri (pkgName: string, registry: string) {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,9 @@ const brokenIntegrity = loadJsonFile.sync<any>(f.find('broken-integrity.json'))
|
||||||
|
|
||||||
const registry = 'https://registry.npmjs.org/'
|
const registry = 'https://registry.npmjs.org/'
|
||||||
|
|
||||||
const delay = async (time: number) => new Promise<void>((resolve) => setTimeout(() => resolve(), time))
|
const delay = async (time: number) => new Promise<void>((resolve) => setTimeout(() => {
|
||||||
|
resolve()
|
||||||
|
}, time))
|
||||||
|
|
||||||
const fetch = createFetchFromRegistry({})
|
const fetch = createFetchFromRegistry({})
|
||||||
const getAuthHeader = () => undefined
|
const getAuthHeader = () => undefined
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,9 @@ export async function addFilesFromTarball (
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
// listener
|
// listener
|
||||||
extract.on('finish', () => resolve())
|
extract.on('finish', () => {
|
||||||
|
resolve()
|
||||||
|
})
|
||||||
extract.on('error', reject)
|
extract.on('error', reject)
|
||||||
|
|
||||||
// pipe through extractor
|
// pipe through extractor
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ export function parseJsonStream (
|
||||||
deferred: DeferredManifestPromise
|
deferred: DeferredManifestPromise
|
||||||
) {
|
) {
|
||||||
stream.pipe(
|
stream.pipe(
|
||||||
concatStream((buffer) => parseJsonBuffer(buffer, deferred))
|
concatStream((buffer) => {
|
||||||
|
parseJsonBuffer(buffer, deferred)
|
||||||
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,9 @@ test('keep dependencies used by others', async () => {
|
||||||
const lockfile = await project.readLockfile() as Lockfile
|
const lockfile = await project.readLockfile() as Lockfile
|
||||||
expect(isEmpty(lockfile.packages)).toBeFalsy()
|
expect(isEmpty(lockfile.packages)).toBeFalsy()
|
||||||
|
|
||||||
Object.entries(lockfile.packages ?? {}).forEach(([depPath, dep]) => expect(dep.dev).toBeTruthy())
|
Object.entries(lockfile.packages ?? {}).forEach(([_, dep]) => {
|
||||||
|
expect(dep.dev).toBeTruthy()
|
||||||
|
})
|
||||||
|
|
||||||
await store.handler({
|
await store.handler({
|
||||||
cacheDir,
|
cacheDir,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue