spfn
Version:
Superfunction CLI - Add SPFN to your Next.js project
61 lines (58 loc) • 1.33 kB
JavaScript
// src/utils/logger.ts
import chalk from "chalk";
var logger = {
info: (message) => {
console.log(chalk.blue("\u2139"), message);
},
success: (message) => {
console.log(chalk.green("\u2713"), message);
},
warn: (message) => {
console.log(chalk.yellow("\u26A0"), message);
},
error: (message) => {
console.log(chalk.red("\u2717"), message);
},
step: (message) => {
console.log(chalk.cyan("\u25B8"), message);
}
};
// src/utils/package-manager.ts
import { existsSync } from "fs";
import { join } from "path";
function detectPackageManager(cwd) {
if (existsSync(join(cwd, "bun.lockb"))) {
return "bun";
}
if (existsSync(join(cwd, "pnpm-lock.yaml"))) {
return "pnpm";
}
if (existsSync(join(cwd, "yarn.lock"))) {
return "yarn";
}
let currentDir = cwd;
let depth = 0;
const maxDepth = 5;
while (depth < maxDepth) {
const parentDir = join(currentDir, "..");
if (parentDir === currentDir) {
break;
}
if (existsSync(join(parentDir, "pnpm-lock.yaml"))) {
return "pnpm";
}
if (existsSync(join(parentDir, "yarn.lock"))) {
return "yarn";
}
if (existsSync(join(parentDir, "bun.lockb"))) {
return "bun";
}
currentDir = parentDir;
depth++;
}
return "npm";
}
export {
logger,
detectPackageManager
};