Template will likely not be worked on for now Signed-off-by: Alix von Schirp <github@avonschirp.bootmedia.de>
80 lines
2.0 KiB
TypeScript
80 lines
2.0 KiB
TypeScript
// THIS IS FOR NOW UNLIKELY TO BE CONTINUED TO BE WORKED ON
|
|
|
|
import type { PlopTypes } from "@turbo/gen";
|
|
import * as fs from "node:fs";
|
|
import { simpleGit } from "simple-git";
|
|
|
|
export default function generator(plop: PlopTypes.NodePlopAPI): void {
|
|
const git = simpleGit();
|
|
const metaPackages = fs.readdirSync("meta").map((value) => {
|
|
const packageJson = JSON.parse(
|
|
fs.readFileSync(`meta/${value}/package.json`, "utf-8"),
|
|
);
|
|
return {
|
|
name: packageJson.name,
|
|
value: value,
|
|
};
|
|
});
|
|
// get git author info
|
|
const gitAuthor = {
|
|
name: git
|
|
.getConfig("user.name")
|
|
.then((res) => res.value)
|
|
.catch(() => ""),
|
|
email: git
|
|
.getConfig("user.email")
|
|
.then((res) => res.value)
|
|
.catch(() => ""),
|
|
};
|
|
// const gitAuthor = {
|
|
// name: (await git.getConfig("user.name")).value,
|
|
// email: (await git.getConfig("user.email")).value,
|
|
// };
|
|
|
|
// create a generator
|
|
plop.setGenerator("package", {
|
|
description: "Create a new notify package",
|
|
// gather information from the user
|
|
prompts: [
|
|
{
|
|
type: "input",
|
|
name: "name",
|
|
message: "Package name",
|
|
},
|
|
{
|
|
type: "input",
|
|
name: "description",
|
|
message: "Package description",
|
|
},
|
|
{
|
|
type: "input",
|
|
name: "author.name",
|
|
default: gitAuthor.name,
|
|
message: "Author name",
|
|
},
|
|
{
|
|
type: "input",
|
|
name: "author.email",
|
|
default: gitAuthor.email,
|
|
message: "Author email",
|
|
},
|
|
{
|
|
type: "checkbox",
|
|
name: "import.meta",
|
|
message: "In which meta packages should this package be included?",
|
|
choices: metaPackages,
|
|
},
|
|
],
|
|
// perform actions based on the prompts
|
|
actions: [
|
|
{
|
|
type: "addMany",
|
|
destination: "packages/{{name}}",
|
|
base: "templates/package",
|
|
templateFiles: "templates/package/**/*",
|
|
abortOnFail: true,
|
|
},
|
|
],
|
|
});
|
|
}
|