Skip to content

Commit

Permalink
Merge master into develop
Browse files Browse the repository at this point in the history
# Conflicts:
#	apps/package-manager/packages/generic/src/packageManager.ts
  • Loading branch information
nytamin committed Oct 12, 2023
2 parents 35bce1f + 8d35782 commit ed7ae3e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 11 deletions.
27 changes: 17 additions & 10 deletions apps/package-manager/packages/generic/src/packageManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export class PackageManagerHandler {
expectedPackages: [],
}
private _triggerUpdatedExpectedPackagesTimeout: NodeJS.Timeout | null = null
public monitoredPackages: Map<MonitorId, ExpectedPackageWrap[]> = new Map()
public monitoredPackages: Map<PackageContainerId, Map<MonitorId, ExpectedPackageWrap[]>> = new Map()
settings: PackageManagerSettings = {
delayRemoval: 0,
useTemporaryFilePath: false,
Expand Down Expand Up @@ -289,11 +289,13 @@ export class PackageManagerHandler {

// Add from Monitors:
{
for (const [monitorId, monitorExpectedPackages] of this.monitoredPackages.entries()) {
expectedPackageSources.push({
sourceName: `monitor_${monitorId}`,
expectedPackages: monitorExpectedPackages,
})
for (const monitors of this.monitoredPackages.values()) {
for (const [monitorId, monitorExpectedPackages] of monitors.entries()) {
expectedPackageSources.push({
sourceName: `monitor_${monitorId}`,
expectedPackages: monitorExpectedPackages,
})
}
}
}

Expand Down Expand Up @@ -676,7 +678,7 @@ class ExpectationManagerCallbacksHandler implements ExpectationManagerCallbacks
)
}
case 'reportFromMonitorPackages':
this.reportMonitoredPackages(...message.arguments)
this.onReportMonitoredPackages(...message.arguments)
break

default:
Expand Down Expand Up @@ -992,8 +994,8 @@ class ExpectationManagerCallbacksHandler implements ExpectationManagerCallbacks
.catch((e) => this.logger.error(`Error in updateCoreStatus : ${stringifyError(e)}`))
}

private reportMonitoredPackages(
_containerId: PackageContainerId,
private onReportMonitoredPackages(
containerId: PackageContainerId,
monitorId: MonitorId,
expectedPackages: ExpectedPackage.Any[]
) {
Expand All @@ -1010,7 +1012,12 @@ class ExpectationManagerCallbacksHandler implements ExpectationManagerCallbacks
`reportMonitoredPackages: ${expectedPackages.length} packages, ${expectedPackagesWraps.length} wraps`
)

this.packageManager.monitoredPackages.set(monitorId, expectedPackagesWraps)
let monitors = this.packageManager.monitoredPackages.get(containerId)
if (!monitors) {
monitors = new Map()
this.packageManager.monitoredPackages.set(containerId, monitors)
}
monitors.set(monitorId, expectedPackagesWraps)

this.packageManager.triggerUpdatedExpectedPackages()
}
Expand Down
5 changes: 4 additions & 1 deletion shared/packages/api/src/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ export function setupLogger(
transports: [transportConsole],
})
}
if (handleProcess) logger.info('Logging to Console')
if (handleProcess && process.env.JEST_WORKER_ID === undefined) {
// Is not running in Jest
logger.info('Logging to Console')
}
if (initialLogLevel) setLogLevel(initialLogLevel, true)
}
// Somewhat of a hack, inject the category method:
Expand Down
33 changes: 33 additions & 0 deletions tests/internal-tests/src/__mocks__/@parcel/watcher.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
export async function getEventsSince(_dir: FilePath, _snapshot: FilePath, _opts?: Options): Promise<Event[]> {
// not implemented
return []
}
export async function subscribe(_dir: FilePath, _fn: SubscribeCallback, _opts?: Options): Promise<AsyncSubscription> {
return new AsyncSubscription()
}
export async function unsubscribe(_dir: FilePath, _fn: SubscribeCallback, _opts?: Options): Promise<void> {
// not implemented
}
export async function writeSnapshot(_dir: FilePath, _snapshot: FilePath, _opts?: Options): Promise<FilePath> {
// not implemented
return './mock-snapshot'
}

type FilePath = string
type GlobPattern = string
type BackendType = 'fs-events' | 'watchman' | 'inotify' | 'windows' | 'brute-force'
type EventType = 'create' | 'update' | 'delete'
interface Options {
ignore?: (FilePath | GlobPattern)[]
backend?: BackendType
}
type SubscribeCallback = (err: Error | null, events: Event[]) => unknown
interface Event {
path: FilePath
type: EventType
}
class AsyncSubscription {
async unsubscribe(): Promise<void> {
// not implemented
}
}
1 change: 1 addition & 0 deletions tests/internal-tests/src/__tests__/basic.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jest.mock('mkdirp')
jest.mock('child_process')
jest.mock('windows-network-drive')
jest.mock('tv-automation-quantel-gateway-client')
jest.mock('@parcel/watcher')

const fs = fsOrg as any as typeof fsMockType
const WND = WNDOrg as any as typeof WNDType
Expand Down
1 change: 1 addition & 0 deletions tests/internal-tests/src/__tests__/issues.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jest.mock('mkdirp')
jest.mock('child_process')
jest.mock('windows-network-drive')
jest.mock('tv-automation-quantel-gateway-client')
jest.mock('@parcel/watcher')

const fs = fsOrg as any as typeof fsMockType

Expand Down
1 change: 1 addition & 0 deletions tests/internal-tests/src/__tests__/quantel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { describeForAllPlatforms, waitUntil } from './lib/lib'
import { getQuantelSource, getQuantelTarget } from './lib/containers'
jest.mock('child_process')
jest.mock('tv-automation-quantel-gateway-client')
jest.mock('@parcel/watcher')

const QGatewayClient = QGatewayClientOrg as any as typeof QGatewayClientType

Expand Down

0 comments on commit ed7ae3e

Please sign in to comment.