-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11899be
commit 8c6b0fd
Showing
15 changed files
with
130 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { readFileSync } from "node:fs"; | ||
import { dirname, join } from "node:path"; | ||
import process from "node:process"; | ||
|
||
import type { PackageJson } from "type-fest"; | ||
|
||
import type AppMap from "./AppMap"; | ||
import { root } from "./config"; | ||
|
||
// cannot use import because it's outside src | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const pkg = require("../package.json") as PackageJson; | ||
|
||
export const version = pkg.version!; | ||
|
||
export const defaultMetadata: Partial<AppMap.Metadata> & { client: AppMap.ClientMetadata } = { | ||
client: { | ||
name: pkg.name!, | ||
version, | ||
url: pkg.homepage!, | ||
}, | ||
language: { | ||
name: "ECMAScript", | ||
engine: "Node.js", | ||
version: process.version, | ||
}, | ||
}; | ||
|
||
function readPkgUp(dir: string): PackageJson | undefined { | ||
try { | ||
return JSON.parse(readFileSync(join(dir, "package.json"), "utf-8")) as PackageJson; | ||
} catch { | ||
const parent = dirname(dir); | ||
if (parent === dir) return; | ||
else return readPkgUp(parent); | ||
} | ||
} | ||
|
||
const targetPackage = readPkgUp(root); | ||
|
||
if (targetPackage?.name) defaultMetadata.app = targetPackage.name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters