46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
![]() |
import * as colors from "kleur/colors";
|
||
|
import { arch, platform } from "node:os";
|
||
|
import whichPm from "which-pm";
|
||
|
import { openConfig } from "../../core/config/index.js";
|
||
|
import { ASTRO_VERSION } from "../../core/constants.js";
|
||
|
async function printInfo({ flags }) {
|
||
|
var _a;
|
||
|
const packageManager = await whichPm(process.cwd());
|
||
|
let adapter = "Couldn't determine.";
|
||
|
let integrations = [];
|
||
|
const MAX_PADDING = 25;
|
||
|
function printRow(label, value) {
|
||
|
const padding = MAX_PADDING - label.length;
|
||
|
console.log(`${colors.bold(label)}` + " ".repeat(padding) + `${colors.green(value)}`);
|
||
|
}
|
||
|
try {
|
||
|
const { userConfig } = await openConfig({
|
||
|
cwd: flags.root,
|
||
|
flags,
|
||
|
cmd: "info"
|
||
|
});
|
||
|
if ((_a = userConfig.adapter) == null ? void 0 : _a.name) {
|
||
|
adapter = userConfig.adapter.name;
|
||
|
}
|
||
|
if (userConfig.integrations) {
|
||
|
integrations = ((userConfig == null ? void 0 : userConfig.integrations) ?? []).filter(Boolean).flat().map((i) => i == null ? void 0 : i.name);
|
||
|
}
|
||
|
} catch (_e) {
|
||
|
}
|
||
|
console.log();
|
||
|
const packageManagerName = (packageManager == null ? void 0 : packageManager.name) ?? "Couldn't determine.";
|
||
|
printRow("Astro version", `v${ASTRO_VERSION}`);
|
||
|
printRow("Package manager", packageManagerName);
|
||
|
printRow("Platform", platform());
|
||
|
printRow("Architecture", arch());
|
||
|
printRow("Adapter", adapter);
|
||
|
let integrationsString = "None or couldn't determine.";
|
||
|
if (integrations.length > 0) {
|
||
|
integrationsString = integrations.join(", ");
|
||
|
}
|
||
|
printRow("Integrations", integrationsString);
|
||
|
}
|
||
|
export {
|
||
|
printInfo
|
||
|
};
|