UNPKG

@softwareventures/maintain-project

Version:

Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited

37 lines 1.66 kB
import { exit } from "process"; import { chain } from "@softwareventures/chain"; import { forEachFn, mapFn } from "@softwareventures/array"; import { readProject } from "../project/read.js"; import { bindAsyncResultFn, bindFailureFn } from "../result/result.js"; import { updateProject } from "../project/update.js"; export function cliUpdate(path, { breaking }) { void readProject(path) .then(bindAsyncResultFn(async (project) => updateProject({ project, breaking }))) .then(bindFailureFn(reasons => { chain(reasons) .map(mapFn(reason => { switch (reason.type) { case "file-not-found": return `File Not Found: ${reason.path}`; case "file-is-directory": return `File Is A Directory: ${reason.path}`; case "not-a-directory": return `Not a Directory: ${reason.path}`; case "file-exists": return `File Exists: ${reason.path}`; case "invalid-json": return `Invalid JSON: ${reason.path}`; case "invalid-yaml": return `Invalid YAML: ${reason.path}`; case "git-not-clean": return `Git working copy not clean: ${reason.path}`; case "yarn-fix-failed": case "prettier-fix-failed": return `Failed to apply code style rules: ${reason.path}`; } })) .map(forEachFn(message => void console.error(`Error: ${message}`))); exit(1); })); } //# sourceMappingURL=update.js.map