Renamed several components related to account settings and updated corresponding data-test selectors for more clarity. Adjusted e2e tests to reflect these changes and added tests for new functionalities, like changing password and deleting account. In addition, generator description in monorepo configuration was simplified. Minor changes were also made to e2e test utilities for better error handling.
84 lines
2.4 KiB
TypeScript
84 lines
2.4 KiB
TypeScript
import { execSync } from "node:child_process";
|
|
import type { PlopTypes } from "@turbo/gen";
|
|
|
|
export default function generator(plop: PlopTypes.NodePlopAPI): void {
|
|
plop.setGenerator("init", {
|
|
description: "Generate a new package for the Monorepo",
|
|
prompts: [
|
|
{
|
|
type: "input",
|
|
name: "name",
|
|
message:
|
|
"What is the name of the package? (You can skip the `@kit/` prefix)",
|
|
},
|
|
{
|
|
type: "input",
|
|
name: "deps",
|
|
message:
|
|
"Enter a space separated list of dependencies you would like to install",
|
|
},
|
|
],
|
|
actions: [
|
|
(answers) => {
|
|
if ("name" in answers && typeof answers.name === "string") {
|
|
if (answers.name.startsWith("@kit/")) {
|
|
answers.name = answers.name.replace("@kit/", "");
|
|
}
|
|
}
|
|
return "Config sanitized";
|
|
},
|
|
{
|
|
type: "add",
|
|
path: "packages/{{ name }}/package.json",
|
|
templateFile: "templates/package.json.hbs",
|
|
},
|
|
{
|
|
type: "add",
|
|
path: "packages/{{ name }}/tsconfig.json",
|
|
templateFile: "templates/tsconfig.json.hbs",
|
|
},
|
|
{
|
|
type: "add",
|
|
path: "packages/{{ name }}/index.ts",
|
|
template: "export * from './src';",
|
|
},
|
|
{
|
|
type: "add",
|
|
path: "packages/{{ name }}/src/index.ts",
|
|
template: "export const name = '{{ name }}';",
|
|
},
|
|
{
|
|
type: "modify",
|
|
path: "packages/{{ name }}/package.json",
|
|
async transform(content, answers) {
|
|
const pkg = JSON.parse(content);
|
|
|
|
for (const dep of answers.deps.split(" ").filter(Boolean)) {
|
|
const version = await fetch(
|
|
`https://registry.npmjs.org/-/package/${dep}/dist-tags`,
|
|
)
|
|
.then((res) => res.json())
|
|
.then((json) => json.latest);
|
|
pkg.dependencies![dep] = `^${version}`;
|
|
}
|
|
return JSON.stringify(pkg, null, 2);
|
|
},
|
|
},
|
|
async (answers) => {
|
|
/**
|
|
* Install deps and format everything
|
|
*/
|
|
execSync("pnpm manypkg fix", {
|
|
stdio: "inherit",
|
|
});
|
|
execSync(
|
|
`pnpm prettier --write packages/${
|
|
(answers as { name: string }).name
|
|
}/** --list-different`,
|
|
);
|
|
return "Package scaffolded";
|
|
},
|
|
],
|
|
});
|
|
}
|