From e3843673f7e4b0756c2c2c6def26ca45e4c967c0 Mon Sep 17 00:00:00 2001 From: Konrad Dysput Date: Mon, 17 Jun 2024 16:26:03 +0200 Subject: [PATCH] Include windows in CICD pipeline. Use @v4 (#249) * Include windows in CICD pipeline. Use @v4 * Remove strategy * Action name * declare prettierrc path * Correct path to the file * Update prettier and options * Set end of line to auto * Apply default formatting proposed by prettier latest (#252) * Apply default formatting proposed by prettier latest * Force to use prettierrc.json * Print file structure * Escape file name * Auto end of line * Use powershell * Correct YAML * Use win-node-env * Do not require powershell if not needed * Remove changes that dont belong to this pull request * use cross-env for setting NODE_ENV variables * cli: fix test errors on Windows * Apply formatting --------- Co-authored-by: Sebastian Alex --------- Co-authored-by: Sebastian Alex --- .github/workflows/test.yml | 24 +++++++--- .prettierrc => .prettierrc.json | 4 +- examples/sdk/node/package.json | 2 +- package-lock.json | 45 ++++++++++++++++--- package.json | 3 +- packages/browser/package.json | 4 +- packages/electron/package.json | 4 +- .../attributes/WindowAttributeProvider.ts | 5 ++- .../src/main/ipc/ReadableIpcStream.ts | 6 ++- .../modules/BacktraceMainElectronModule.ts | 11 +++-- .../src/main/modules/IpcAttachment.ts | 6 ++- .../src/renderer/ipc/WritableIpcStream.ts | 5 ++- .../renderer/modules/IpcReportSubmission.ts | 5 ++- .../renderer/modules/IpcSummedMetricsQueue.ts | 5 ++- packages/nestjs/package.json | 4 +- packages/node/package.json | 4 +- .../node/src/BacktraceNodeRequestHandler.ts | 4 +- .../attachment/BacktraceBufferAttachment.ts | 5 ++- .../src/attachment/BacktraceFileAttachment.ts | 5 ++- packages/node/tests/_mocks/fileSystem.ts | 4 +- packages/react-native/package.json | 2 +- .../src/attributes/NativeAttributeProvider.ts | 5 ++- .../src/handlers/UnhandledExceptionHandler.ts | 4 +- .../android/AndroidUnhandledException.ts | 6 ++- packages/react/package.json | 4 +- packages/sdk-core/package.json | 2 +- .../sdk-core/src/common/abortInterfaces.ts | 8 ++-- .../OverwritingArrayIterator.ts | 6 ++- .../attachment/BacktraceStringAttachment.ts | 5 ++- .../BacktraceUint8ArrayAttachment.ts | 5 ++- .../model/data/BacktraceSubmissionResult.ts | 5 ++- .../model/http/BacktraceReportSubmission.ts | 5 ++- .../modules/attribute/FileAttributeManager.ts | 5 ++- .../database/BacktraceDatabaseFileRecord.ts | 5 ++- .../BacktraceDatabaseFileStorageProvider.ts | 5 ++- .../src/modules/metrics/BacktraceMetrics.ts | 11 +++-- packages/sdk-core/tests/_mocks/fileSystem.ts | 13 +++--- scripts/gitRelease.ts | 25 ++++++----- scripts/release.ts | 21 +++++---- scripts/syncVersions.ts | 11 +++-- tools/cli/package.json | 4 +- tools/cli/src/sourcemaps/process.ts | 2 +- tools/cli/src/sourcemaps/run.ts | 10 ++--- tools/cli/src/sourcemaps/upload.ts | 6 +-- tools/cli/tests/_helpers/common.ts | 16 +++++++ tools/cli/tests/_helpers/matchers.ts | 6 +++ .../cli/tests/sourcemaps/add-sources.spec.ts | 37 ++++++++------- tools/cli/tests/sourcemaps/process.spec.ts | 28 +++++++----- tools/cli/tests/sourcemaps/run.spec.ts | 19 ++++---- tools/cli/tests/sourcemaps/upload.spec.ts | 14 +++--- tools/rollup-plugin/package.json | 2 +- tools/sourcemap-tools/package.json | 2 +- tools/sourcemap-tools/src/SymbolUploader.ts | 5 ++- tools/vite-plugin/package.json | 2 +- tools/webpack-plugin/package.json | 6 +-- 55 files changed, 316 insertions(+), 151 deletions(-) rename .prettierrc => .prettierrc.json (71%) create mode 100644 tools/cli/tests/_helpers/matchers.ts diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 59a997e0..84925544 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,7 @@ on: pull_request: jobs: - build: + test_linux: runs-on: ubuntu-latest strategy: @@ -14,9 +14,9 @@ jobs: node-version: [16.x, 18.x, 20.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm ci @@ -33,9 +33,9 @@ jobs: node-version: [14.x] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - run: npm i -g npm@8 @@ -44,3 +44,17 @@ jobs: - run: npm run lint - run: npm run format:check - run: npm test + + test_windows: + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js 18.x + uses: actions/setup-node@v4 + with: + node-version: 18.x + - run: npm ci + - run: npm run build + - run: npm run lint + - run: npm run format:check + - run: npm test diff --git a/.prettierrc b/.prettierrc.json similarity index 71% rename from .prettierrc rename to .prettierrc.json index e7629774..9c9858aa 100644 --- a/.prettierrc +++ b/.prettierrc.json @@ -1,8 +1,8 @@ { "printWidth": 120, - "proseWrap": "always", "singleQuote": true, "trailingComma": "all", "arrowParens": "always", - "tabWidth": 4 + "tabWidth": 4, + "endOfLine": "auto" } diff --git a/examples/sdk/node/package.json b/examples/sdk/node/package.json index f8f7d020..444545d1 100644 --- a/examples/sdk/node/package.json +++ b/examples/sdk/node/package.json @@ -12,7 +12,7 @@ "clean": "rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "start": "NODE_ENV=production node ./lib/index.js", + "start": "cross-env NODE_ENV=production node ./lib/index.js", "watch": "tsc -w" }, "repository": { diff --git a/package-lock.json b/package-lock.json index 9a027065..7a5dddc5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,11 +28,12 @@ "@types/semver": "^7.5.3", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", + "cross-env": "^7.0.3", "eslint": "^8.41.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-local-rules": "^1.3.2", - "prettier": "^2.8.8", + "prettier": "^3.3.2", "rimraf": "^5.0.1", "semver": "^7.5.4", "ts-node": "^10.9.1", @@ -7012,6 +7013,24 @@ "dev": true, "license": "MIT" }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "license": "MIT", @@ -14245,14 +14264,15 @@ } }, "node_modules/prettier": { - "version": "2.8.8", + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.3.2.tgz", + "integrity": "sha512-rAVeHYMcv8ATV5d508CFdn+8/pHPpXeIid1DdrPwXnaAdH7cqjVbpJaT5eq4yRAFU/lsbwYwSF/n5iNrdJHPQA==", "dev": true, - "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" @@ -19106,6 +19126,21 @@ "csstype": "^3.0.2" } }, + "packages/react-native/node_modules/prettier": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, "packages/sdk-core": { "name": "@backtrace/sdk-core", "version": "0.3.2", diff --git a/package.json b/package.json index 1a784a83..47248feb 100644 --- a/package.json +++ b/package.json @@ -52,11 +52,12 @@ "@types/semver": "^7.5.3", "@typescript-eslint/eslint-plugin": "^5.59.7", "@typescript-eslint/parser": "^5.59.7", + "cross-env": "^7.0.3", "eslint": "^8.41.0", "eslint-config-prettier": "^8.8.0", "eslint-plugin-import": "^2.27.5", "eslint-plugin-local-rules": "^1.3.2", - "prettier": "^2.8.8", + "prettier": "^3.3.2", "rimraf": "^5.0.1", "semver": "^7.5.4", "ts-node": "^10.9.1", diff --git a/packages/browser/package.json b/packages/browser/package.json index 6ce26f15..82fcc41b 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -10,9 +10,9 @@ "clean": "rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "webpack -w", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "repository": { "type": "git", diff --git a/packages/electron/package.json b/packages/electron/package.json index 95c1f084..9b0727b1 100644 --- a/packages/electron/package.json +++ b/packages/electron/package.json @@ -9,9 +9,9 @@ "clean": "rimraf common main renderer", "format": "prettier --write '**/*.ts'", "lint": "eslint src --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "webpack -w", - "test": "NODE_ENV=test jest --passWithNoTests" + "test": "cross-env NODE_ENV=test jest --passWithNoTests" }, "keywords": [ "Error", diff --git a/packages/electron/src/main/attributes/WindowAttributeProvider.ts b/packages/electron/src/main/attributes/WindowAttributeProvider.ts index 9d2bcf35..9ed8c322 100644 --- a/packages/electron/src/main/attributes/WindowAttributeProvider.ts +++ b/packages/electron/src/main/attributes/WindowAttributeProvider.ts @@ -17,7 +17,10 @@ export interface WindowAttributeProviderOptions { } export class WindowAttributeProvider implements BacktraceAttributeProvider { - constructor(private readonly _window: BrowserWindow, private readonly _options?: WindowAttributeProviderOptions) {} + constructor( + private readonly _window: BrowserWindow, + private readonly _options?: WindowAttributeProviderOptions, + ) {} public readonly type = 'dynamic'; diff --git a/packages/electron/src/main/ipc/ReadableIpcStream.ts b/packages/electron/src/main/ipc/ReadableIpcStream.ts index b1d08ea9..081630c9 100644 --- a/packages/electron/src/main/ipc/ReadableIpcStream.ts +++ b/packages/electron/src/main/ipc/ReadableIpcStream.ts @@ -7,7 +7,11 @@ import { ipcHandshake } from '../../common/ipc/ipcHandshake'; export class ReadableIpcStream extends Readable { private _isConnected = false; - constructor(private readonly _name: string, private readonly _ipc: IpcTransport, opts?: ReadableOptions) { + constructor( + private readonly _name: string, + private readonly _ipc: IpcTransport, + opts?: ReadableOptions, + ) { super(opts); const close = () => this.destroy(); diff --git a/packages/electron/src/main/modules/BacktraceMainElectronModule.ts b/packages/electron/src/main/modules/BacktraceMainElectronModule.ts index 415be21f..eb6d3971 100644 --- a/packages/electron/src/main/modules/BacktraceMainElectronModule.ts +++ b/packages/electron/src/main/modules/BacktraceMainElectronModule.ts @@ -121,8 +121,11 @@ export class BacktraceMainElectronModule implements BacktraceModule { } function toStringDictionary(record: Record): Record { - return Object.keys(record).reduce((obj, key) => { - obj[key] = record[key]?.toString() ?? ''; - return obj; - }, {} as Record); + return Object.keys(record).reduce( + (obj, key) => { + obj[key] = record[key]?.toString() ?? ''; + return obj; + }, + {} as Record, + ); } diff --git a/packages/electron/src/main/modules/IpcAttachment.ts b/packages/electron/src/main/modules/IpcAttachment.ts index 7feeb2d9..68b89219 100644 --- a/packages/electron/src/main/modules/IpcAttachment.ts +++ b/packages/electron/src/main/modules/IpcAttachment.ts @@ -4,7 +4,11 @@ import { IpcTransport } from '../../common'; import { ReadableIpcStream } from '../ipc/ReadableIpcStream'; export class IpcAttachment implements BacktraceAttachment { - constructor(public readonly name: string, private readonly _id: string, private readonly _ipc: IpcTransport) {} + constructor( + public readonly name: string, + private readonly _id: string, + private readonly _ipc: IpcTransport, + ) {} public get(): Readable { return new ReadableIpcStream(this._id, this._ipc); diff --git a/packages/electron/src/renderer/ipc/WritableIpcStream.ts b/packages/electron/src/renderer/ipc/WritableIpcStream.ts index 8662fd98..43c62d4d 100644 --- a/packages/electron/src/renderer/ipc/WritableIpcStream.ts +++ b/packages/electron/src/renderer/ipc/WritableIpcStream.ts @@ -15,7 +15,10 @@ export class WritableIpcStream extends WritableStream { class WritableIpcStreamSink implements UnderlyingSink { private _isPaused = false; - constructor(private readonly _name: string, private readonly _ipc: IpcTransport) { + constructor( + private readonly _name: string, + private readonly _ipc: IpcTransport, + ) { this._ipc.on(IpcEvents.streamEvent(_name, 'pause'), () => (this._isPaused = true)); this._ipc.on(IpcEvents.streamEvent(_name, 'resume'), () => (this._isPaused = false)); } diff --git a/packages/electron/src/renderer/modules/IpcReportSubmission.ts b/packages/electron/src/renderer/modules/IpcReportSubmission.ts index c727e75d..0c294eb7 100644 --- a/packages/electron/src/renderer/modules/IpcReportSubmission.ts +++ b/packages/electron/src/renderer/modules/IpcReportSubmission.ts @@ -14,7 +14,10 @@ import { IpcRpc } from '../../common/ipc/IpcRpc'; import { WritableIpcStream } from '../ipc/WritableIpcStream'; export class IpcReportSubmission implements BacktraceReportSubmission { - constructor(private readonly _ipcRpc: IpcRpc, private readonly _ipcTransport: IpcTransport) {} + constructor( + private readonly _ipcRpc: IpcRpc, + private readonly _ipcTransport: IpcTransport, + ) {} public send( data: BacktraceData, diff --git a/packages/electron/src/renderer/modules/IpcSummedMetricsQueue.ts b/packages/electron/src/renderer/modules/IpcSummedMetricsQueue.ts index 8330c40c..71bf621d 100644 --- a/packages/electron/src/renderer/modules/IpcSummedMetricsQueue.ts +++ b/packages/electron/src/renderer/modules/IpcSummedMetricsQueue.ts @@ -7,7 +7,10 @@ export class IpcSummedMetricsQueue implements MetricsQueue { public readonly submissionUrl = ''; public readonly maximumEvents = -1; - constructor(private readonly _ipcTransport: IpcTransport, private readonly _ipcRpc: IpcRpc) {} + constructor( + private readonly _ipcTransport: IpcTransport, + private readonly _ipcRpc: IpcRpc, + ) {} public add(event: SummedEvent): void { this._ipcTransport.emit(IpcEvents.addSummedMetric, event); diff --git a/packages/nestjs/package.json b/packages/nestjs/package.json index 1eb6344a..cf56409a 100644 --- a/packages/nestjs/package.json +++ b/packages/nestjs/package.json @@ -9,9 +9,9 @@ "clean": "rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "webpack -w", - "test": "NODE_ENV=test jest --passWithNoTests" + "test": "cross-env NODE_ENV=test jest --passWithNoTests" }, "engines": { "node": ">=14" diff --git a/packages/node/package.json b/packages/node/package.json index 8ba226ff..d157ed39 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -9,9 +9,9 @@ "clean": "rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "webpack -w", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "engines": { "node": ">=14" diff --git a/packages/node/src/BacktraceNodeRequestHandler.ts b/packages/node/src/BacktraceNodeRequestHandler.ts index ecb98a54..c3f4b52e 100644 --- a/packages/node/src/BacktraceNodeRequestHandler.ts +++ b/packages/node/src/BacktraceNodeRequestHandler.ts @@ -112,8 +112,8 @@ export class BacktraceNodeRequestHandler implements BacktraceRequestHandler { this.reason instanceof Error ? this.reason : typeof this.reason === 'string' - ? new Error(this.reason) - : new Error('Operation cancelled.'); + ? new Error(this.reason) + : new Error('Operation cancelled.'); request.destroy(reason); } diff --git a/packages/node/src/attachment/BacktraceBufferAttachment.ts b/packages/node/src/attachment/BacktraceBufferAttachment.ts index b9e8de58..fa423fc7 100644 --- a/packages/node/src/attachment/BacktraceBufferAttachment.ts +++ b/packages/node/src/attachment/BacktraceBufferAttachment.ts @@ -1,7 +1,10 @@ import { BacktraceAttachment } from '@backtrace/sdk-core'; export class BacktraceBufferAttachment implements BacktraceAttachment { - constructor(public readonly name: string, public readonly buffer: Buffer) {} + constructor( + public readonly name: string, + public readonly buffer: Buffer, + ) {} public get(): Buffer { return this.buffer; } diff --git a/packages/node/src/attachment/BacktraceFileAttachment.ts b/packages/node/src/attachment/BacktraceFileAttachment.ts index cad54a49..e1cc04ac 100644 --- a/packages/node/src/attachment/BacktraceFileAttachment.ts +++ b/packages/node/src/attachment/BacktraceFileAttachment.ts @@ -6,7 +6,10 @@ import { Readable } from 'stream'; export class BacktraceFileAttachment implements CoreBacktraceFileAttachment { public readonly name: string; - constructor(public readonly filePath: string, name?: string) { + constructor( + public readonly filePath: string, + name?: string, + ) { this.name = name ?? path.basename(this.filePath); } diff --git a/packages/node/tests/_mocks/fileSystem.ts b/packages/node/tests/_mocks/fileSystem.ts index f1c631ae..f7934b96 100644 --- a/packages/node/tests/_mocks/fileSystem.ts +++ b/packages/node/tests/_mocks/fileSystem.ts @@ -27,8 +27,8 @@ export function mockStreamFileSystem(files?: Record): MockedFile const str = Buffer.isBuffer(chunk) ? chunk.toString('utf-8') : typeof chunk === 'string' - ? chunk - : String(chunk).toString(); + ? chunk + : String(chunk).toString(); const fullPath = path.resolve(p); if (!fs.files[fullPath]) { diff --git a/packages/react-native/package.json b/packages/react-native/package.json index ed6d32dd..b428a4fd 100644 --- a/packages/react-native/package.json +++ b/packages/react-native/package.json @@ -31,7 +31,7 @@ "clean": "rimraf \"lib\"", "format:check": "eslint \"**/*.{js,ts,tsx}\"", "prepublishOnly": "bob build", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "keywords": [ "Error", diff --git a/packages/react-native/src/attributes/NativeAttributeProvider.ts b/packages/react-native/src/attributes/NativeAttributeProvider.ts index 8f9dcec7..62e32ec9 100644 --- a/packages/react-native/src/attributes/NativeAttributeProvider.ts +++ b/packages/react-native/src/attributes/NativeAttributeProvider.ts @@ -3,7 +3,10 @@ import { NativeModules } from 'react-native'; export class NativeAttributeProvider implements BacktraceAttributeProvider { private readonly _provider: { get(): Record }; - constructor(private readonly _name: string, public readonly type: 'scoped' | 'dynamic') { + constructor( + private readonly _name: string, + public readonly type: 'scoped' | 'dynamic', + ) { this._provider = NativeModules?.[this._name]; } diff --git a/packages/react-native/src/handlers/UnhandledExceptionHandler.ts b/packages/react-native/src/handlers/UnhandledExceptionHandler.ts index 7143dd48..a631d457 100644 --- a/packages/react-native/src/handlers/UnhandledExceptionHandler.ts +++ b/packages/react-native/src/handlers/UnhandledExceptionHandler.ts @@ -96,8 +96,8 @@ export class UnhandledExceptionHandler implements ExceptionHandler { message = cachedPrettyFormat ? cachedPrettyFormat(rejection) : typeof rejection === 'string' - ? rejection - : JSON.stringify({ ...rejection }); + ? rejection + : JSON.stringify({ ...rejection }); } const warning = diff --git a/packages/react-native/src/handlers/android/AndroidUnhandledException.ts b/packages/react-native/src/handlers/android/AndroidUnhandledException.ts index f6002f1b..32c4f882 100644 --- a/packages/react-native/src/handlers/android/AndroidUnhandledException.ts +++ b/packages/react-native/src/handlers/android/AndroidUnhandledException.ts @@ -1,5 +1,9 @@ export class AndroidUnhandledException extends Error { - constructor(public readonly name: string, public readonly message: string, public readonly stack: string) { + constructor( + public readonly name: string, + public readonly message: string, + public readonly stack: string, + ) { super(message); } } diff --git a/packages/react/package.json b/packages/react/package.json index 2fae1456..0b00c732 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -8,9 +8,9 @@ "clean": "rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "webpack -w", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "repository": { "type": "git", diff --git a/packages/sdk-core/package.json b/packages/sdk-core/package.json index 5cd009cf..4ecd1c20 100644 --- a/packages/sdk-core/package.json +++ b/packages/sdk-core/package.json @@ -10,7 +10,7 @@ "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", "watch": "tsc -w", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "repository": { "type": "git", diff --git a/packages/sdk-core/src/common/abortInterfaces.ts b/packages/sdk-core/src/common/abortInterfaces.ts index ebdb9444..350e8ca1 100644 --- a/packages/sdk-core/src/common/abortInterfaces.ts +++ b/packages/sdk-core/src/common/abortInterfaces.ts @@ -4,10 +4,10 @@ function getGlobal(key: K): (typeof window)[K] | return typeof window !== 'undefined' ? window[key as keyof typeof window] : typeof global !== 'undefined' - ? global[key as keyof typeof global] - : typeof self !== 'undefined' - ? self[key as keyof typeof self] - : undefined; + ? global[key as keyof typeof global] + : typeof self !== 'undefined' + ? self[key as keyof typeof self] + : undefined; } export type OriginalAbortController = AbortController; diff --git a/packages/sdk-core/src/dataStructures/OverwritingArrayIterator.ts b/packages/sdk-core/src/dataStructures/OverwritingArrayIterator.ts index 879656d8..b0f9abc8 100644 --- a/packages/sdk-core/src/dataStructures/OverwritingArrayIterator.ts +++ b/packages/sdk-core/src/dataStructures/OverwritingArrayIterator.ts @@ -1,7 +1,11 @@ export class OverwritingArrayIterator implements IterableIterator { private _index?: number; - constructor(private readonly _source: T[], private readonly _offset: number, private readonly _size: number) {} + constructor( + private readonly _source: T[], + private readonly _offset: number, + private readonly _size: number, + ) {} [Symbol.iterator](): IterableIterator { return new OverwritingArrayIterator(this._source, this._offset, this._size); diff --git a/packages/sdk-core/src/model/attachment/BacktraceStringAttachment.ts b/packages/sdk-core/src/model/attachment/BacktraceStringAttachment.ts index 55df171a..dafaa0ec 100644 --- a/packages/sdk-core/src/model/attachment/BacktraceStringAttachment.ts +++ b/packages/sdk-core/src/model/attachment/BacktraceStringAttachment.ts @@ -1,7 +1,10 @@ import { BacktraceAttachment } from './BacktraceAttachment'; export class BacktraceStringAttachment implements BacktraceAttachment { - constructor(public readonly name: string, public readonly data: string) {} + constructor( + public readonly name: string, + public readonly data: string, + ) {} public get(): string { return this.data; diff --git a/packages/sdk-core/src/model/attachment/BacktraceUint8ArrayAttachment.ts b/packages/sdk-core/src/model/attachment/BacktraceUint8ArrayAttachment.ts index de66c3f9..79561389 100644 --- a/packages/sdk-core/src/model/attachment/BacktraceUint8ArrayAttachment.ts +++ b/packages/sdk-core/src/model/attachment/BacktraceUint8ArrayAttachment.ts @@ -1,7 +1,10 @@ import { BacktraceAttachment } from './BacktraceAttachment'; export class BacktraceUint8ArrayAttachment implements BacktraceAttachment { - constructor(public readonly name: string, public readonly data: Uint8Array) {} + constructor( + public readonly name: string, + public readonly data: Uint8Array, + ) {} public get(): Blob { return new Blob([this.data.buffer]); diff --git a/packages/sdk-core/src/model/data/BacktraceSubmissionResult.ts b/packages/sdk-core/src/model/data/BacktraceSubmissionResult.ts index be3486a8..1ab35fe1 100644 --- a/packages/sdk-core/src/model/data/BacktraceSubmissionResult.ts +++ b/packages/sdk-core/src/model/data/BacktraceSubmissionResult.ts @@ -10,7 +10,10 @@ export class BacktraceReportSubmissionResult { private _result?: T; private constructor(response: T); private constructor(_status: BacktraceSubmissionStatus, _message?: string); - private constructor(statusOrResponse: T | BacktraceSubmissionStatus, public readonly message?: string) { + private constructor( + statusOrResponse: T | BacktraceSubmissionStatus, + public readonly message?: string, + ) { if (this.isSubmissionResponse(statusOrResponse)) { this.status = statusOrResponse; return; diff --git a/packages/sdk-core/src/model/http/BacktraceReportSubmission.ts b/packages/sdk-core/src/model/http/BacktraceReportSubmission.ts index 76ac02cb..5d174915 100644 --- a/packages/sdk-core/src/model/http/BacktraceReportSubmission.ts +++ b/packages/sdk-core/src/model/http/BacktraceReportSubmission.ts @@ -17,7 +17,10 @@ export interface BacktraceReportSubmission { export class RequestBacktraceReportSubmission { private readonly _submissionUrl: string; - constructor(options: BacktraceConfiguration, private readonly _requestHandler: BacktraceRequestHandler) { + constructor( + options: BacktraceConfiguration, + private readonly _requestHandler: BacktraceRequestHandler, + ) { this._submissionUrl = SubmissionUrlInformation.toJsonReportSubmissionUrl(options.url, options.token); } diff --git a/packages/sdk-core/src/modules/attribute/FileAttributeManager.ts b/packages/sdk-core/src/modules/attribute/FileAttributeManager.ts index a38dc8ce..3a97541e 100644 --- a/packages/sdk-core/src/modules/attribute/FileAttributeManager.ts +++ b/packages/sdk-core/src/modules/attribute/FileAttributeManager.ts @@ -9,7 +9,10 @@ const ATTRIBUTE_FILE_NAME = 'bt-attributes'; export class FileAttributeManager implements BacktraceModule { private _attributeManager?: AttributeManager; - constructor(private readonly _fileSystem: FileSystem, private _fileName?: string) {} + constructor( + private readonly _fileSystem: FileSystem, + private _fileName?: string, + ) {} public static create(fileSystem: FileSystem) { return new FileAttributeManager(fileSystem); diff --git a/packages/sdk-core/src/modules/database/BacktraceDatabaseFileRecord.ts b/packages/sdk-core/src/modules/database/BacktraceDatabaseFileRecord.ts index adb896c0..1b9c79e0 100644 --- a/packages/sdk-core/src/modules/database/BacktraceDatabaseFileRecord.ts +++ b/packages/sdk-core/src/modules/database/BacktraceDatabaseFileRecord.ts @@ -11,7 +11,10 @@ export class BacktraceDatabaseFileRecord implements BacktraceDatabaseRecord { public readonly timestamp: number; public locked: boolean; - private constructor(record: BacktraceDatabaseRecord, public readonly attachments: BacktraceAttachment[]) { + private constructor( + record: BacktraceDatabaseRecord, + public readonly attachments: BacktraceAttachment[], + ) { this.data = record.data; this.id = record.id; this.count = record.count; diff --git a/packages/sdk-core/src/modules/database/BacktraceDatabaseFileStorageProvider.ts b/packages/sdk-core/src/modules/database/BacktraceDatabaseFileStorageProvider.ts index be812428..2d0e728e 100644 --- a/packages/sdk-core/src/modules/database/BacktraceDatabaseFileStorageProvider.ts +++ b/packages/sdk-core/src/modules/database/BacktraceDatabaseFileStorageProvider.ts @@ -9,7 +9,10 @@ export class BacktraceDatabaseFileStorageProvider implements BacktraceDatabaseSt private _enabled = true; private readonly RECORD_SUFFIX = '-record.json'; - private constructor(private readonly _fileSystem: FileSystem, private readonly _path: string) {} + private constructor( + private readonly _fileSystem: FileSystem, + private readonly _path: string, + ) {} /** * Create a provider if provided options are valid diff --git a/packages/sdk-core/src/modules/metrics/BacktraceMetrics.ts b/packages/sdk-core/src/modules/metrics/BacktraceMetrics.ts index 2031c9fc..d5959687 100644 --- a/packages/sdk-core/src/modules/metrics/BacktraceMetrics.ts +++ b/packages/sdk-core/src/modules/metrics/BacktraceMetrics.ts @@ -126,10 +126,13 @@ export class BacktraceMetrics implements BacktraceModule { private convertAttributes(attributes: Record) { return Object.keys(attributes) .filter((n) => attributes[n] != null) - .reduce((acc, n) => { - acc[n] = attributes[n]?.toString(); - return acc; - }, {} as Record); + .reduce( + (acc, n) => { + acc[n] = attributes[n]?.toString(); + return acc; + }, + {} as Record, + ); } private async handleAbort(fn: () => Promise): Promise { diff --git a/packages/sdk-core/tests/_mocks/fileSystem.ts b/packages/sdk-core/tests/_mocks/fileSystem.ts index ce50f192..983585ff 100644 --- a/packages/sdk-core/tests/_mocks/fileSystem.ts +++ b/packages/sdk-core/tests/_mocks/fileSystem.ts @@ -10,10 +10,13 @@ export type MockedFileSystem = { export function mockFileSystem(files?: Record): MockedFileSystem { const fs = Object.entries(files ?? {}) .map(([k, v]) => [path.resolve(k), v]) - .reduce((obj, [k, v]) => { - obj[k] = v; - return obj; - }, {} as Record); + .reduce( + (obj, [k, v]) => { + obj[k] = v; + return obj; + }, + {} as Record, + ); function readDir(dir: string) { return Object.keys(fs) @@ -53,7 +56,7 @@ export function mockFileSystem(files?: Record): MockedFileSystem filePath: p, name: path.basename(p), get: jest.fn().mockReturnValue(fs[path.resolve(p)]), - } as BacktraceFileAttachment), + }) as BacktraceFileAttachment, ), }; } diff --git a/scripts/gitRelease.ts b/scripts/gitRelease.ts index ddbc1ea1..a9dac42f 100755 --- a/scripts/gitRelease.ts +++ b/scripts/gitRelease.ts @@ -41,8 +41,8 @@ function updateVersion( rawIdentifierBase === '0' || rawIdentifierBase === '1' ? rawIdentifierBase : rawIdentifierBase === 'false' - ? false - : undefined; + ? false + : undefined; const result = semver.inc(version, versionOrRelease as ReleaseType, identifier, identifierBase); if (result == null) { @@ -73,16 +73,19 @@ async function main() { throw new Error('second argument must be a version or release type'); } - const optionValues = options.reduce((val, k) => { - const opt = argv.find((v) => v.startsWith(`${k}=`)); - if (opt) { - val[k] = opt.replace(`${k}=`, ''); - } else { - val[k] = argv.includes(k); - } + const optionValues = options.reduce( + (val, k) => { + const opt = argv.find((v) => v.startsWith(`${k}=`)); + if (opt) { + val[k] = opt.replace(`${k}=`, ''); + } else { + val[k] = argv.includes(k); + } - return val; - }, {} as Record<(typeof options)[number], boolean | string>); + return val; + }, + {} as Record<(typeof options)[number], boolean | string>, + ); const dryRun = optionValues['--dry-run']; if (dryRun) { diff --git a/scripts/release.ts b/scripts/release.ts index 89878279..526706a4 100755 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -22,16 +22,19 @@ async function main() { throw new Error('first argument must be a package.json path'); } - const optionValues = options.reduce((val, k) => { - const opt = argv.find((v) => v.startsWith(`${k}=`)); - if (opt) { - val[k] = opt.replace(`${k}=`, ''); - } else { - val[k] = argv.includes(k); - } + const optionValues = options.reduce( + (val, k) => { + const opt = argv.find((v) => v.startsWith(`${k}=`)); + if (opt) { + val[k] = opt.replace(`${k}=`, ''); + } else { + val[k] = argv.includes(k); + } - return val; - }, {} as Record<(typeof options)[number], boolean | string>); + return val; + }, + {} as Record<(typeof options)[number], boolean | string>, + ); const dryRun = optionValues['--dry-run']; if (dryRun) { diff --git a/scripts/syncVersions.ts b/scripts/syncVersions.ts index 7ffdef9c..69092e2c 100755 --- a/scripts/syncVersions.ts +++ b/scripts/syncVersions.ts @@ -65,10 +65,13 @@ function updateVersions(packageJson: PackageJson, currentVersions: Record { - obj[pj.name] = pj.version; - return obj; - }, {} as Record); + const currentVersions = workspacePackageJsons.reduce( + (obj, pj) => { + obj[pj.name] = pj.version; + return obj; + }, + {} as Record, + ); for (const packageJsonPath of packageJsonPathsToSync) { const packageJson = await loadPackageJson(packageJsonPath); diff --git a/tools/cli/package.json b/tools/cli/package.json index b644cc5b..cc572d6a 100644 --- a/tools/cli/package.json +++ b/tools/cli/package.json @@ -15,10 +15,10 @@ "clean": "tsc -b --clean && rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "tsc -w", "start": "node lib/index.js", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "repository": { "type": "git", diff --git a/tools/cli/src/sourcemaps/process.ts b/tools/cli/src/sourcemaps/process.ts index 2da49c34..348c1f90 100644 --- a/tools/cli/src/sourcemaps/process.ts +++ b/tools/cli/src/sourcemaps/process.ts @@ -215,7 +215,7 @@ export function processSource(force: boolean) { source: { ...asset.source, content: result.source }, sourceMap: { ...asset.sourceMap, content: result.sourceMap }, debugId: result.debugId, - } as ProcessedSourceAndSourceMap), + }) as ProcessedSourceAndSourceMap, ), ); }; diff --git a/tools/cli/src/sourcemaps/run.ts b/tools/cli/src/sourcemaps/run.ts index b4fbbe14..4766f203 100644 --- a/tools/cli/src/sourcemaps/run.ts +++ b/tools/cli/src/sourcemaps/run.ts @@ -261,7 +261,7 @@ export async function runSourcemapCommands({ opts, logger, getHelpMessage }: Com logTraceAssets('processing source and sourcemap'), processSource(processOptions.force ?? false), logDebugAssets('processed source and sourcemap'), - (result) => ({ ...result, processed: true } as SourceAndSourceMap & AssetResult), + (result) => ({ ...result, processed: true }) as SourceAndSourceMap & AssetResult, ) : pass, addSources @@ -273,9 +273,9 @@ export async function runSourcemapCommands({ opts, logger, getHelpMessage }: Com R.map(logDebugAsset('source added to sourcemap')), R.map( ({ content }) => - ({ ...assets, sourceMap: { ...assets.sourceMap, content } } as SourceAndSourceMap), + ({ ...assets, sourceMap: { ...assets.sourceMap, content } }) as SourceAndSourceMap, ), - R.map((result) => ({ ...result, sourceAdded: true } as SourceAndSourceMap & AssetResult)), + R.map((result) => ({ ...result, sourceAdded: true }) as SourceAndSourceMap & AssetResult), ) : Ok, R.map( @@ -340,8 +340,8 @@ export async function runSourcemapCommands({ opts, logger, getHelpMessage }: Com uploadOptions['dry-run'] ? Ok({ rxid: '' }) : assets.length - ? saveArchiveCommand(assets) - : Ok(null), + ? saveArchiveCommand(assets) + : Ok(null), ), R.map( logInfo((result: UploadResult | null) => diff --git a/tools/cli/src/sourcemaps/upload.ts b/tools/cli/src/sourcemaps/upload.ts index efc2b8ac..0f5dbeec 100644 --- a/tools/cli/src/sourcemaps/upload.ts +++ b/tools/cli/src/sourcemaps/upload.ts @@ -290,8 +290,8 @@ export async function uploadSourcemaps({ opts, logger, getHelpMessage }: Command assets, }) : assets.length - ? saveArchiveCommand(assets) - : Ok({ rxid: '', assets }), + ? saveArchiveCommand(assets) + : Ok({ rxid: '', assets }), ), R.map(output(logger)), ), @@ -340,7 +340,7 @@ export function uploadAssets(uploadUrl: string, options: SymbolUploaderOptions) export function saveAssets(outputPath: string) { return function saveAssets(assets: AssetWithContent[]): Promise { const stream = fs.createWriteStream(outputPath); - return pipe(stream, pipeAssets(assets), () => ({ rxid: outputPath } as UploadResult)); + return pipe(stream, pipeAssets(assets), () => ({ rxid: outputPath }) as UploadResult); }; } diff --git a/tools/cli/tests/_helpers/common.ts b/tools/cli/tests/_helpers/common.ts index f2354c10..67ba14ab 100644 --- a/tools/cli/tests/_helpers/common.ts +++ b/tools/cli/tests/_helpers/common.ts @@ -1,4 +1,5 @@ import { Ok, Result, SymbolUploader, UploadResult } from '@backtrace/sourcemap-tools'; +import path from 'path'; import { Transform } from 'stream'; export function getHelpMessage() { @@ -37,3 +38,18 @@ export function expectAllKeysToChange>(obj1: T expect(value1).not.toEqual(value2); } } + +export function expectSamePaths(actual: string[], expected: string[]) { + const actualAbsolute = actual.map((p) => path.resolve(p)); + const expectedAbsolute = expected.map((p) => path.resolve(p)); + + expect(actualAbsolute).toEqual(expect.arrayContaining(expectedAbsolute)); +} + +export function pathTuple(a: string, b: string) { + if (process.platform === 'win32') { + return `${a}::${b}`; + } else { + return `${a}:${b}`; + } +} diff --git a/tools/cli/tests/_helpers/matchers.ts b/tools/cli/tests/_helpers/matchers.ts new file mode 100644 index 00000000..84027519 --- /dev/null +++ b/tools/cli/tests/_helpers/matchers.ts @@ -0,0 +1,6 @@ +import 'jest-extended'; +import path from 'path'; + +export function expectPath(expected: string) { + return expect.toSatisfy((actual) => path.resolve(expected) === path.resolve(actual)); +} diff --git a/tools/cli/tests/sourcemaps/add-sources.spec.ts b/tools/cli/tests/sourcemaps/add-sources.spec.ts index 49a2a143..d86356d6 100644 --- a/tools/cli/tests/sourcemaps/add-sources.spec.ts +++ b/tools/cli/tests/sourcemaps/add-sources.spec.ts @@ -3,7 +3,8 @@ import assert from 'assert'; import { glob } from 'glob'; import { CliLogger } from '../../src/logger'; import { addSourcesToSourcemaps } from '../../src/sourcemaps/add-sources'; -import { expectAllKeysToChange, filterKeys, getHelpMessage } from '../_helpers/common'; +import { expectAllKeysToChange, expectSamePaths, filterKeys, getHelpMessage, pathTuple } from '../_helpers/common'; +import { expectPath } from '../_helpers/matchers'; import { expectHashesToChange, hashEachFile, hashFiles, withWorkingCopy } from '../_helpers/testFiles'; describe('add-sources', () => { @@ -26,7 +27,10 @@ describe('add-sources', () => { assert(result.isOk(), result.data as string); const expected = await glob(`${workingDir}/*.js.map`); - expect(result.data.map((d) => d.path)).toEqual(expect.arrayContaining(expected)); + expectSamePaths( + result.data.map((d) => d.path), + expected, + ); }), ); @@ -45,7 +49,10 @@ describe('add-sources', () => { assert(result.isOk(), result.data as string); const expected = await glob(`${workingDir}/entry*.js.map`); - expect(result.data.map((d) => d.path)).toEqual(expect.arrayContaining(expected)); + expectSamePaths( + result.data.map((d) => d.path), + expected, + ); }), ); }); @@ -83,7 +90,7 @@ describe('add-sources', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(spy).toBeCalledWith(expect.anything(), file, expect.any(Boolean)); + expect(spy).toBeCalledWith(expect.anything(), expectPath(file), expect.any(Boolean)); } }), ); @@ -171,7 +178,7 @@ describe('add-sources', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(spy).toBeCalledWith(expect.anything(), file, expect.any(Boolean)); + expect(spy).toBeCalledWith(expect.anything(), expectPath(file), expect.any(Boolean)); } }), ); @@ -230,7 +237,7 @@ describe('add-sources', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(spy).toBeCalledWith(expect.anything(), file, expect.any(Boolean)); + expect(spy).toBeCalledWith(expect.anything(), expectPath(file), expect.any(Boolean)); } }), ); @@ -413,7 +420,7 @@ describe('add-sources', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(spy).toBeCalledWith(expect.anything(), file, expect.any(Boolean)); + expect(spy).toBeCalledWith(expect.anything(), expectPath(file), expect.any(Boolean)); } }), ); @@ -472,7 +479,7 @@ describe('add-sources', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(spy).toBeCalledWith(expect.anything(), file, expect.any(Boolean)); + expect(spy).toBeCalledWith(expect.anything(), expectPath(file), expect.any(Boolean)); } }), ); @@ -507,8 +514,8 @@ describe('add-sources', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); @@ -527,8 +534,8 @@ describe('add-sources', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); @@ -537,7 +544,7 @@ describe('add-sources', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(spy).toBeCalledWith(expect.anything(), file, expect.any(Boolean)); + expect(spy).toBeCalledWith(expect.anything(), expectPath(file), expect.any(Boolean)); } }), ); @@ -552,8 +559,8 @@ describe('add-sources', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); diff --git a/tools/cli/tests/sourcemaps/process.spec.ts b/tools/cli/tests/sourcemaps/process.spec.ts index 509b8c0c..bcfbf046 100644 --- a/tools/cli/tests/sourcemaps/process.spec.ts +++ b/tools/cli/tests/sourcemaps/process.spec.ts @@ -4,7 +4,7 @@ import { glob } from 'glob'; import 'jest-extended'; import { CliLogger } from '../../src/logger'; import { processSources } from '../../src/sourcemaps/process'; -import { expectAllKeysToChange, filterKeys, getHelpMessage } from '../_helpers/common'; +import { expectAllKeysToChange, expectSamePaths, filterKeys, getHelpMessage, pathTuple } from '../_helpers/common'; import { expectHashesToChange, hashEachFile, hashFiles, readEachFile, withWorkingCopy } from '../_helpers/testFiles'; export const expectAnythingOrNothing = () => expect.toBeOneOf([expect.anything(), undefined, null]); @@ -25,7 +25,10 @@ describe('process', () => { assert(result.isOk(), result.data as string); const expected = await glob(`${workingDir}/*.js`); - expect(result.data.map((d) => d.source.path)).toEqual(expect.arrayContaining(expected)); + expectSamePaths( + result.data.map((d) => d.source.path), + expected, + ); }), ); @@ -44,7 +47,10 @@ describe('process', () => { assert(result.isOk(), result.data as string); const expected = await glob(`${workingDir}/entry*.js`); - expect(result.data.map((d) => d.source.path)).toEqual(expect.arrayContaining(expected)); + expectSamePaths( + result.data.map((d) => d.source.path), + expected, + ); }), ); }); @@ -686,8 +692,8 @@ describe('process', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); @@ -709,8 +715,8 @@ describe('process', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); @@ -738,8 +744,8 @@ describe('process', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); @@ -761,8 +767,8 @@ describe('process', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], }, }); diff --git a/tools/cli/tests/sourcemaps/run.spec.ts b/tools/cli/tests/sourcemaps/run.spec.ts index 5331e680..05025ac0 100644 --- a/tools/cli/tests/sourcemaps/run.spec.ts +++ b/tools/cli/tests/sourcemaps/run.spec.ts @@ -10,7 +10,8 @@ import * as addSourcesCmd from '../../src/sourcemaps/add-sources'; import * as processCmd from '../../src/sourcemaps/process'; import { runSourcemapCommands } from '../../src/sourcemaps/run'; import * as uploadCmd from '../../src/sourcemaps/upload'; -import { getHelpMessage, mockUploader } from '../_helpers/common'; +import { getHelpMessage, mockUploader, pathTuple } from '../_helpers/common'; +import { expectPath } from '../_helpers/matchers'; import { hashFiles, withWorkingCopy } from '../_helpers/testFiles'; async function mockOptions(workingDir: string, options: CliOptions) { @@ -53,7 +54,7 @@ describe('run', () => { const expected = [...(await glob(`${workingDir}/*.js`)), ...(await glob(`${workingDir}/*.js.map`))]; expect(result.data.flatMap((d) => [d.source.path, d.sourceMap.path])).toEqual( - expect.arrayContaining(expected), + expect.arrayContaining(expected.map(expectPath)), ); }), ); @@ -89,7 +90,7 @@ describe('run', () => { ...(await glob(`${workingDir}/entry*.js.map`)), ]; expect(result.data.flatMap((d) => [d.source.path, d.sourceMap.path])).toEqual( - expect.arrayContaining(expected), + expect.arrayContaining(expected.map(expectPath)), ); }), ); @@ -172,7 +173,7 @@ describe('run', () => { const files = await glob(`${workingDir}/*.js`); for (const file of files) { expect(innerProcess).toBeCalledWith( - expect.objectContaining({ source: expect.objectContaining({ path: file }) }), + expect.objectContaining({ source: expect.objectContaining({ path: expectPath(file) }) }), ); } }), @@ -284,7 +285,7 @@ describe('run', () => { const files = await glob(`${workingDir}/*.js.map`); for (const file of files) { - expect(innerAddSources).toBeCalledWith(expect.objectContaining({ path: file })); + expect(innerAddSources).toBeCalledWith(expect.objectContaining({ path: expectPath(file) })); } }), ); @@ -499,7 +500,7 @@ describe('run', () => { const expected = [...(await glob(`${workingDir}/*.js`)), ...(await glob(`${workingDir}/*.js.map`))]; expect(result.data.flatMap((d) => [d.source.path, d.sourceMap.path])).toEqual( - expect.arrayContaining(expected), + expect.arrayContaining(expected.map(expectPath)), ); }), ); @@ -533,7 +534,7 @@ describe('run', () => { const expected = [...(await glob(`${workingDir}/*.js`)), ...(await glob(`${workingDir}/*.js.map`))]; expect(result.data.flatMap((d) => [d.source.path, d.sourceMap.path])).toEqual( - expect.arrayContaining(expected), + expect.arrayContaining(expected.map((e) => expectPath(e))), ); }), ); @@ -563,7 +564,7 @@ describe('run', () => { logger: new CliLogger({ level: 'output', silent: true }), getHelpMessage, opts: { - path: [`${entry1Path}:${sourcemap1Path}`, `${entry2Path}:${sourcemap2Path}`], + path: [pathTuple(entry1Path, sourcemap1Path), pathTuple(entry2Path, sourcemap2Path)], config, }, }); @@ -572,7 +573,7 @@ describe('run', () => { const expected = [entry1Path, entry2Path, sourcemap1Path, sourcemap2Path]; expect(result.data.flatMap((d) => [d.source.path, d.sourceMap.path])).toEqual( - expect.arrayContaining(expected), + expect.arrayContaining(expected.map(expectPath)), ); }), ); diff --git a/tools/cli/tests/sourcemaps/upload.spec.ts b/tools/cli/tests/sourcemaps/upload.spec.ts index 785bdd57..6f18a718 100644 --- a/tools/cli/tests/sourcemaps/upload.spec.ts +++ b/tools/cli/tests/sourcemaps/upload.spec.ts @@ -6,7 +6,7 @@ import { glob } from 'glob'; import path from 'path'; import { CliLogger } from '../../src/logger'; import { uploadSourcemaps } from '../../src/sourcemaps/upload'; -import { getHelpMessage, mockUploader } from '../_helpers/common'; +import { getHelpMessage, mockUploader, pathTuple } from '../_helpers/common'; import { withWorkingCopy } from '../_helpers/testFiles'; describe('upload', () => { @@ -541,8 +541,8 @@ describe('upload', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], url: 'https://test', }, @@ -563,8 +563,8 @@ describe('upload', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], url: 'https://test', }, @@ -593,8 +593,8 @@ describe('upload', () => { getHelpMessage, opts: { path: [ - `${workingDir}/entry1.js:${workingDir}/sourcemap1.js.map`, - `${workingDir}/entry2.js:${workingDir}/sourcemap2.js.map`, + pathTuple(`${workingDir}/entry1.js`, `${workingDir}/sourcemap1.js.map`), + pathTuple(`${workingDir}/entry2.js`, `${workingDir}/sourcemap2.js.map`), ], url: 'https://test', }, diff --git a/tools/rollup-plugin/package.json b/tools/rollup-plugin/package.json index be50dd38..bfe0cb09 100644 --- a/tools/rollup-plugin/package.json +++ b/tools/rollup-plugin/package.json @@ -12,7 +12,7 @@ "build:rollup": "rollup --config rollup.config.js", "clean": "tsc -b ./tsconfig.build.json --clean && rimraf \"lib\"", "format": "prettier --write '**/*.ts'", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "lint": "eslint . --ext .ts", "watch": "tsc -b ./tsconfig.build.json -w" }, diff --git a/tools/sourcemap-tools/package.json b/tools/sourcemap-tools/package.json index ffcd0e3c..9fedef48 100644 --- a/tools/sourcemap-tools/package.json +++ b/tools/sourcemap-tools/package.json @@ -13,7 +13,7 @@ "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", "watch": "tsc -w", - "test": "NODE_ENV=test jest" + "test": "cross-env NODE_ENV=test jest" }, "repository": { "type": "git", diff --git a/tools/sourcemap-tools/src/SymbolUploader.ts b/tools/sourcemap-tools/src/SymbolUploader.ts index 58ec2302..28e88f5b 100644 --- a/tools/sourcemap-tools/src/SymbolUploader.ts +++ b/tools/sourcemap-tools/src/SymbolUploader.ts @@ -30,7 +30,10 @@ export interface SymbolRequest { export class SymbolUploader { private readonly _url: URL; - constructor(url: string | URL, private readonly _options?: SymbolUploaderOptions) { + constructor( + url: string | URL, + private readonly _options?: SymbolUploaderOptions, + ) { this._url = new URL(url); } diff --git a/tools/vite-plugin/package.json b/tools/vite-plugin/package.json index fb97d93b..d0066625 100644 --- a/tools/vite-plugin/package.json +++ b/tools/vite-plugin/package.json @@ -12,7 +12,7 @@ "build:vite": "vite build --config vite.config.js", "clean": "tsc -b ./tsconfig.build.json --clean && rimraf \"lib\"", "format": "prettier --write '**/*.ts'", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "lint": "eslint . --ext .ts", "watch": "tsc -b ./tsconfig.build.json -w" }, diff --git a/tools/webpack-plugin/package.json b/tools/webpack-plugin/package.json index 7d44b9d3..05b64f57 100644 --- a/tools/webpack-plugin/package.json +++ b/tools/webpack-plugin/package.json @@ -13,11 +13,11 @@ "clean": "tsc -b ./tsconfig.build.json --clean && rimraf \"lib\"", "format": "prettier --write '**/*.ts'", "lint": "eslint . --ext .ts", - "prepublishOnly": "NODE_ENV=production npm run build", + "prepublishOnly": "cross-env NODE_ENV=production npm run build", "watch": "tsc -b ./tsconfig.build.json -w", "test:e2e": "npm run test:e2e:webpackv5 && npm run test:e2e:webpackv4", - "test:e2e:webpackv4": "NODE_ENV=test jest --config ./webpack4.e2e.jest.config.js", - "test:e2e:webpackv5": "NODE_ENV=test jest --config ./e2e.jest.config.js" + "test:e2e:webpackv4": "cross-env NODE_ENV=test jest --config ./webpack4.e2e.jest.config.js", + "test:e2e:webpackv5": "cross-env NODE_ENV=test jest --config ./e2e.jest.config.js" }, "repository": { "type": "git",