Răsfoiți Sursa

chore(create-pyth-package): responded to PR feedback about removing the yargs helper function

also fixed some of the generated contents
benduran 1 săptămână în urmă
părinte
comite
4282af0cc8

+ 1 - 1
packages/create-pyth-package/src/templates/cli/README.md

@@ -9,5 +9,5 @@ TODO: Fill out readme with more instructions
 From the root of this repo:
 
 ```
-pnpm --dir ./{{relativeFolder}} start
+pnpm --dir ./{{relativeFolder}} start:dev
 ```

+ 1 - 1
packages/create-pyth-package/src/templates/cli/bin.js

@@ -1,3 +1,3 @@
 #!/usr/bin/env node
 
-import "./dist/index.mjs";
+import "./dist/cli.mjs";

+ 1 - 1
packages/create-pyth-package/src/templates/cli/package.json

@@ -23,7 +23,7 @@
     "clean": "rm -rf dist/",
     "fix:lint": "eslint src/ --fix --max-warnings 0",
     "fix:format": "prettier --write \"src/**/*.ts\"",
-    "start:dev": "tsx ./src/index.ts",
+    "start:dev": "tsx ./src/cli.ts",
     "test:lint": "eslint src/ --max-warnings 0",
     "test:format": "prettier --check \"src/**/*.ts\"",
     "test:unit": "jest"

+ 2 - 1
packages/create-pyth-package/src/templates/cli/src/cli.ts

@@ -1,5 +1,6 @@
 import createCLI from "yargs";
 import { hideBin } from "yargs/helpers";
+
 import { setupHelloWorldCommand } from "./commands/hello-world-cmd.js";
 
 async function setupCLI() {
@@ -8,7 +9,7 @@ async function setupCLI() {
 
   const { _ } = await yargs.help().argv;
 
-  if (!_.length) {
+  if (_.length === 0) {
     yargs.showHelp();
     return;
   }

+ 1 - 3
packages/create-pyth-package/src/templates/cli/src/commands/hello-world-cmd.ts

@@ -1,9 +1,7 @@
 import type { Argv } from "yargs";
-import { createCommand } from "../create-command.js";
 
 export function setupHelloWorldCommand(yargs: Argv) {
-  return createCommand(
-    yargs,
+  return yargs.command(
     "hello-world",
     "prints hello world and your name, if provided",
     (y) =>

+ 0 - 1
packages/create-pyth-package/src/templates/cli/src/commands/index.ts

@@ -1 +0,0 @@
-export * from "./hello-world-cmd.js";

+ 0 - 15
packages/create-pyth-package/src/templates/cli/src/create-command.ts

@@ -1,15 +0,0 @@
-import type { ArgumentsCamelCase, Argv } from "yargs";
-
-/**
- * helper for creating a command and registering it
- * to your command line interface with proper typings
- */
-export function createCommand<T extends object>(
-  yargs: Argv,
-  commandName: string,
-  description: string,
-  builder: (y: Argv) => Argv<T>,
-  executor: (args: ArgumentsCamelCase<T>) => Promise<void>,
-) {
-  return yargs.command(commandName, description, builder, executor);
-}

+ 0 - 1
packages/create-pyth-package/src/templates/cli/src/index.ts

@@ -1 +0,0 @@
-export * from "./cli.js";