Skip to content

Commit b53145d

Browse files
Convert @bugsnag/core/lib/path-normalizer to TypeScript (#2448)
* convert normalize path to typescript * Update packages/core/src/lib/path-normalizer.ts * refactor: 🚚 create separate path-normalizer package * add path-normalizer to aws-lambda fixture build script * update dockerfiles with path-normalizer package * change path-normalizer to a direct dependency * add path-normalizer to fixture package json * remove unused import * remove unnecessary node types and rollup config --------- Co-authored-by: Ben Wilson <ben.wilson@smartbear.com>
1 parent 66a7cbb commit b53145d

25 files changed

Lines changed: 257 additions & 42 deletions

File tree

dockerfiles/Dockerfile.node

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ RUN npm run build
1919

2020
RUN npm pack --verbose packages/core/
2121
RUN npm pack --verbose packages/node/
22+
RUN npm pack --verbose packages/path-normalizer/
2223
RUN npm pack --verbose packages/plugin-express/
2324
RUN npm pack --verbose packages/plugin-koa/
2425
RUN npm pack --verbose packages/plugin-restify/

package-lock.json

Lines changed: 95 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/core/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"default": "./dist/index.cjs"
1111
},
1212
"./lib/es-utils/assign": "./src/lib/es-utils/assign.js",
13-
"./lib/es-utils/includes": "./src/lib/es-utils/includes.js",
14-
"./lib/path-normalizer": "./src/lib/path-normalizer.js"
13+
"./lib/es-utils/includes": "./src/lib/es-utils/includes.js"
1514
},
1615
"description": "Core classes and utilities for Bugsnag notifiers",
1716
"homepage": "https://www.bugsnag.com/",

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export { default as extractObject } from './lib/extract-object'
1212
export { default as intRange } from './lib/validators/int-range'
1313
export { default as isError } from './lib/iserror'
1414
export { default as listOfFunctions } from './lib/validators/list-of-functions'
15-
export { default as runCallbacks } from "./lib/callback-runner";
15+
export { default as runCallbacks } from './lib/callback-runner'
1616
export { default as runSyncCallbacks } from './lib/sync-callback-runner'
1717
export { default as stringWithLength } from './lib/validators/string-with-length'
1818

packages/electron/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"@bugsnag/delivery-electron": "^8.4.0",
2626
"@bugsnag/electron-filestore": "^8.0.0",
2727
"@bugsnag/electron-network-status": "^8.4.0",
28+
"@bugsnag/path-normalizer": "^8.4.0",
2829
"@bugsnag/plugin-console-breadcrumbs": "^8.4.0",
2930
"@bugsnag/plugin-electron-app": "^8.4.0",
3031
"@bugsnag/plugin-electron-app-breadcrumbs": "^8.4.0",

packages/electron/src/client/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const createMainClient = (opts) => {
2929
// Normalise the project root upfront so renderers have a fully resolved path
3030
// The renderers can't do this themselves as they cannot access the 'path' module
3131
if (opts.projectRoot) {
32-
const normalizePath = require('@bugsnag/core/lib/path-normalizer')
32+
const normalizePath = require('@bugsnag/path-normalizer')
3333
opts.projectRoot = normalizePath(opts.projectRoot)
3434
}
3535

packages/electron/src/config/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const { schema } = require('./common')
22
const { listOfFunctions, stringWithLength } = require('@bugsnag/core')
33
const { inspect } = require('util')
44
const { app } = require('electron')
5-
const normalizePath = require('@bugsnag/core/lib/path-normalizer')
5+
const normalizePath = require('@bugsnag/path-normalizer')
66

77
module.exports.schema = {
88
...schema,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2017 Bugsnag
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

packages/path-normalizer/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# @bugsnag/path-normalizer
2+
3+
A utility for normalizing file paths by making them absolute and adding trailing slashes for directories.
4+
5+
## Installation
6+
7+
```bash
8+
npm install @bugsnag/path-normalizer
9+
```
10+
11+
## Usage
12+
13+
```javascript
14+
const normalizePath = require('@bugsnag/path-normalizer')
15+
16+
// Normalize a path
17+
const normalizedPath = normalizePath('./some/relative/path')
18+
// Returns: '/absolute/path/to/some/relative/path/'
19+
```
20+
21+
## License
22+
23+
MIT
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"name": "@bugsnag/path-normalizer",
3+
"version": "8.4.0",
4+
"main": "dist/index.js",
5+
"types": "dist/index.d.ts",
6+
"exports": {
7+
".": {
8+
"types": "./dist/index.d.ts",
9+
"import": "./dist/index.mjs",
10+
"default": "./dist/index.js"
11+
}
12+
},
13+
"description": "Path normalization utility for Bugsnag",
14+
"homepage": "https://www.bugsnag.com/",
15+
"repository": {
16+
"type": "git",
17+
"url": "git@github.com:bugsnag/bugsnag-js.git"
18+
},
19+
"publishConfig": {
20+
"access": "public"
21+
},
22+
"files": [
23+
"dist"
24+
],
25+
"scripts": {
26+
"build": "rollup --config rollup.config.js",
27+
"test:types": "tsc -p tsconfig.json"
28+
},
29+
"author": "Bugsnag",
30+
"license": "MIT",
31+
"devDependencies": {
32+
"@rollup/plugin-commonjs": "^28.0.2",
33+
"@rollup/plugin-node-resolve": "^16.0.0",
34+
"@rollup/plugin-typescript": "^12.1.2",
35+
"rollup": "^4.24.0",
36+
"typescript": "^5.7.2"
37+
}
38+
}

0 commit comments

Comments
 (0)