npm-package-manager.ts — astro Source File
Architecture documentation for npm-package-manager.ts, a typescript file in the astro codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 86018cb3_a9ae_f366_c549_4a3d100bab0f["npm-package-manager.ts"] 7db42c05_e873_0887_a39f_34451c181149["../definitions.js"] 86018cb3_a9ae_f366_c549_4a3d100bab0f --> 7db42c05_e873_0887_a39f_34451c181149 f458772b_5926_6ea0_4412_a27162311db0["../definitions.js"] 86018cb3_a9ae_f366_c549_4a3d100bab0f --> f458772b_5926_6ea0_4412_a27162311db0 style 86018cb3_a9ae_f366_c549_4a3d100bab0f fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type { CommandExecutor } from '../../definitions.js';
import type { PackageManager } from '../definitions.js';
interface BareNpmLikeVersionOutput {
version: string;
dependencies: Record<string, BareNpmLikeVersionOutput>;
}
export class NpmPackageManager implements PackageManager {
readonly name: string = 'npm';
readonly #commandExecutor: CommandExecutor;
constructor({ commandExecutor }: { commandExecutor: CommandExecutor }) {
this.#commandExecutor = commandExecutor;
}
async getPackageVersion(name: string): Promise<string | undefined> {
try {
// https://docs.npmjs.com/cli/v9/commands/npm-ls
const { stdout } = await this.#commandExecutor.execute(
'npm',
['ls', name, '--json', '--depth=1'],
{
shell: true,
},
);
const parsedNpmOutput = JSON.parse(stdout) as BareNpmLikeVersionOutput;
if (!parsedNpmOutput.dependencies) {
return undefined;
}
if (parsedNpmOutput.dependencies[name]) {
return `v${parsedNpmOutput.dependencies[name].version}`;
}
const astro = parsedNpmOutput.dependencies.astro;
return astro ? `v${astro.dependencies[name].version}` : undefined;
} catch {
return undefined;
}
}
}
Domain
Subdomains
Classes
Types
Dependencies
- ../definitions.js
- ../definitions.js
Source
Frequently Asked Questions
What does npm-package-manager.ts do?
npm-package-manager.ts is a source file in the astro codebase, written in typescript. It belongs to the CoreAstro domain, RenderingEngine subdomain.
What does npm-package-manager.ts depend on?
npm-package-manager.ts imports 2 module(s): ../definitions.js, ../definitions.js.
Where is npm-package-manager.ts in the architecture?
npm-package-manager.ts is located at packages/astro/src/cli/info/infra/npm-package-manager.ts (domain: CoreAstro, subdomain: RenderingEngine, directory: packages/astro/src/cli/info/infra).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free