Update AGENTS.md. Start fixing old weird errors
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { execSync } from "node:child_process";
|
||||
import type { PlopTypes } from "@turbo/gen";
|
||||
import { execSync } from 'node:child_process';
|
||||
import type { PlopTypes } from '@turbo/gen';
|
||||
|
||||
interface PackageJson {
|
||||
name: string;
|
||||
@@ -9,58 +9,58 @@ interface PackageJson {
|
||||
}
|
||||
|
||||
export default function generator(plop: PlopTypes.NodePlopAPI): void {
|
||||
plop.setGenerator("init", {
|
||||
description: "Generate a new package for the Acme Monorepo",
|
||||
plop.setGenerator('init', {
|
||||
description: 'Generate a new package for the Monorepo',
|
||||
prompts: [
|
||||
{
|
||||
type: "input",
|
||||
name: "name",
|
||||
type: 'input',
|
||||
name: 'name',
|
||||
message:
|
||||
"What is the name of the package? (You can skip the `@gib/` prefix)",
|
||||
'What is the name of the package? (You can skip the `@gib/` prefix)',
|
||||
},
|
||||
{
|
||||
type: "input",
|
||||
name: "deps",
|
||||
type: 'input',
|
||||
name: 'deps',
|
||||
message:
|
||||
"Enter a space separated list of dependencies you would like to install",
|
||||
'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("@gib/")) {
|
||||
answers.name = answers.name.replace("@gib/", "");
|
||||
if ('name' in answers && typeof answers.name === 'string') {
|
||||
if (answers.name.startsWith('@gib/')) {
|
||||
answers.name = answers.name.replace('@gib/', '');
|
||||
}
|
||||
}
|
||||
return "Config sanitized";
|
||||
return 'Config sanitized';
|
||||
},
|
||||
{
|
||||
type: "add",
|
||||
path: "packages/{{ name }}/eslint.config.ts",
|
||||
templateFile: "templates/eslint.config.ts.hbs",
|
||||
type: 'add',
|
||||
path: 'packages/{{ name }}/eslint.config.ts',
|
||||
templateFile: 'templates/eslint.config.ts.hbs',
|
||||
},
|
||||
{
|
||||
type: "add",
|
||||
path: "packages/{{ name }}/package.json",
|
||||
templateFile: "templates/package.json.hbs",
|
||||
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 }}/tsconfig.json',
|
||||
templateFile: 'templates/tsconfig.json.hbs',
|
||||
},
|
||||
{
|
||||
type: "add",
|
||||
path: "packages/{{ name }}/src/index.ts",
|
||||
type: 'add',
|
||||
path: 'packages/{{ name }}/src/index.ts',
|
||||
template: "export const name = '{{ name }}';",
|
||||
},
|
||||
{
|
||||
type: "modify",
|
||||
path: "packages/{{ name }}/package.json",
|
||||
type: 'modify',
|
||||
path: 'packages/{{ name }}/package.json',
|
||||
async transform(content, answers) {
|
||||
if ("deps" in answers && typeof answers.deps === "string") {
|
||||
if ('deps' in answers && typeof answers.deps === 'string') {
|
||||
const pkg = JSON.parse(content) as PackageJson;
|
||||
for (const dep of answers.deps.split(" ").filter(Boolean)) {
|
||||
for (const dep of answers.deps.split(' ').filter(Boolean)) {
|
||||
const version = await fetch(
|
||||
`https://registry.npmjs.org/-/package/${dep}/dist-tags`,
|
||||
)
|
||||
@@ -78,17 +78,15 @@ export default function generator(plop: PlopTypes.NodePlopAPI): void {
|
||||
/**
|
||||
* Install deps and format everything
|
||||
*/
|
||||
if ("name" in answers && typeof answers.name === "string") {
|
||||
// execSync("pnpm dlx sherif@latest --fix", {
|
||||
// stdio: "inherit",
|
||||
// });
|
||||
execSync("pnpm i", { stdio: "inherit" });
|
||||
if ('name' in answers && typeof answers.name === 'string') {
|
||||
execSync('bun install', { stdio: 'inherit' });
|
||||
execSync(
|
||||
`pnpm prettier --write packages/${answers.name}/** --list-different`,
|
||||
`bun prettier --write packages/${answers.name}/** --list-different`,
|
||||
{ stdio: 'inherit' },
|
||||
);
|
||||
return "Package scaffolded";
|
||||
return 'Package scaffolded';
|
||||
}
|
||||
return "Package not scaffolded";
|
||||
return 'Package not scaffolded';
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user