@softwareventures/maintain-project
Version:
Automatically create and maintain TypeScript projects with standard settings for Software Ventures Limited
55 lines • 2.07 kB
JavaScript
import { exit } from "process";
import { forEachFn, mapFn } from "@softwareventures/array";
import { chain } from "@softwareventures/chain";
import init from "../project/init.js";
import { bindFailureFn, mapResultFn } from "../result/result.js";
import { createProject } from "../project/create.js";
import { parseAndCorrectSpdxExpression } from "../license/spdx/correct.js";
export function cliInit(path, options) {
void createProject({
npmPackage: {
scope: options.scope,
name: options.name
},
gitHost: {
user: options.githubOwner,
project: options.githubProject
},
target: options.webapp ?? false ? "webapp" : "npm",
path,
author: {
name: options.authorName,
email: options.authorEmail
},
license: {
spdxLicense: parseAndCorrectSpdxExpression(options.license ?? "ISC"),
copyrightHolder: options.copyrightHolder
}
})
.then(init)
.then(mapResultFn(() => exit(0)))
.then(bindFailureFn(reasons => {
chain(reasons)
.map(mapFn((reason) => {
switch (reason.type) {
case "file-exists":
return `File Exists: ${reason.path}`;
case "not-a-directory":
return `Not a Directory: ${reason.path}`;
case "git-init-failed":
return "git init failed";
case "yarn-set-version-failed":
return "yarn set version failed";
case "set-yarn-linker-failed":
return "failed to set yarn linker";
case "yarn-install-failed":
return "yarn install failed";
case "yarn-fix-failed":
return `Failed to apply code style rules: ${reason.path}`;
}
}))
.map(forEachFn(message => void console.error(`Error: ${message}`)));
exit(1);
}));
}
//# sourceMappingURL=init.js.map