PackageJsonDetails
sdlc-cdk-lib / modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails
modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails
Classes
PackageJsonDetails
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:60
Class for reading and accessing package.json information.
Remarks
This class provides a typed interface to access essential information from the project's package.json file, including name, version, repository, and other metadata.
Example
const packageDetails = new PackageJsonDetails();
console.log(packageDetails.name); // "baksdev-cdk-lib"
console.log(packageDetails.version); // "1.0.0"
console.log(packageDetails.repoName); // "baksdev-cdk-lib"
Constructors
Constructor
> new PackageJsonDetails(rootPath?): PackageJsonDetails
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:70
Creates a new PackageJsonDetails instance.
Parameters
rootPath?
string
Optional root path to search for package.json. Defaults to project root.
Returns
Throws
Error if package.json cannot be found or parsed
Accessors
author
Get Signature
> get author(): string | { email?: string; name?: string; url?: string; } | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:207
Gets the author information.
Returns
string | { email?: string; name?: string; url?: string; } | undefined
Author as string or object, or undefined if not set
authorName
Get Signature
> get authorName(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:216
Gets the author name.
Returns
string | undefined
Author name or undefined
data
Get Signature
> get data(): PackageJsonData
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:284
Gets the full package.json data.
Returns
Complete package.json object
description
Get Signature
> get description(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:161
Gets the package description.
Returns
string | undefined
Package description or undefined if not set
homepage
Get Signature
> get homepage(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:239
Gets the homepage URL.
Returns
string | undefined
Homepage URL or undefined if not set
isPrivate
Get Signature
> get isPrivate(): boolean
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:275
Checks if the package is marked as private.
Returns
boolean
true if package is private, false otherwise
keywords
Get Signature
> get keywords(): string[] | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:266
Gets package keywords.
Returns
string[] | undefined
Array of keywords or undefined
license
Get Signature
> get license(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:230
Gets the license type.
Returns
string | undefined
License identifier (e.g., "MIT", "Apache-2.0") or undefined
name
Get Signature
> get name(): string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:143
Gets the package name.
Returns
string
Package name from package.json
nodeVersion
Get Signature
> get nodeVersion(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:248
Gets the Node.js engine requirement.
Returns
string | undefined
Node version requirement or undefined
npmVersion
Get Signature
> get npmVersion(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:257
Gets the npm version requirement.
Returns
string | undefined
npm version requirement or undefined
path
Get Signature
> get path(): string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:293
Gets the absolute path to package.json.
Returns
string
Path to package.json file
repoName
Get Signature
> get repoName(): string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:170
Gets the repository name extracted from the package name or repository URL.
Returns
string
Repository name
repositoryUrl
Get Signature
> get repositoryUrl(): string | undefined
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:193
Gets the repository URL.
Returns
string | undefined
Repository URL or undefined if not set
version
Get Signature
> get version(): string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:152
Gets the package version.
Returns
string
Version string (e.g., "1.0.0")
Methods
getSummary()
> getSummary(): object
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:311
Gets a summary object with essential package information.
Returns
object
Object containing name, version, description, and repository
description?
> optional description: string
license?
> optional license: string
name
> name: string
repoName
> repoName: string
repositoryUrl?
> optional repositoryUrl: string
version
> version: string
toString()
> toString(): string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:302
Converts package details to a formatted string.
Returns
string
Formatted string representation
Interfaces
PackageJsonData
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:9
Interface representing the essential fields from package.json
Properties
author?
> optional author: string | { email?: string; name?: string; url?: string; }
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:19
bugs?
> optional bugs: string | { email?: string; url?: string; }
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:28
description?
> optional description: string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:12
engines?
> optional engines: object
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:34
node?
> optional node: string
npm?
> optional npm: string
homepage?
> optional homepage: string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:27
keywords?
> optional keywords: string[]
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:38
license?
> optional license: string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:26
name
> name: string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:10
private?
> optional private: boolean
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:39
repository?
> optional repository: string | { type?: string; url?: string; }
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:13
version
> version: string
Defined in: modules/sdlc-aws-cdk-lib/src/contextStrategy/PackageJsonDetails.ts:11