@ideascol/cli-maker
Version:
A simple library to help create CLIs
12 lines (11 loc) • 4.99 kB
TypeScript
export declare const templateIndex = "export * from './lib';\n";
export declare const template = "import { CLI } from '@ideascol/cli-maker';\n\nimport CommandGreet from './commands/greetCommand';\n\nconst cli = new CLI('{{cliName}}', '{{cliDescription}}', {\n interactive: true,\n version: '1.0.0',\n introAnimation: {\n enabled: true,\n preset: 'retro-space', // Change to other presets or override fields below\n title: '{{cliName}}',\n subtitle: '{{cliDescription}}',\n },\n});\n\ncli.command(CommandGreet);\n\ncli.parse(process.argv);\n\nexport { cli };\n";
export declare const templateReadme = "# {{cliName}}\n\n{{cliDescription}}\n\n## Quick start\n```bash\n# Using npm\nnpx {{cliName}}\n\n# Using bun\nbunx {{cliName}}\n```\n\n## Installation\n\n```bash\n# Using npm\nnpm install -g {{cliName}}\n\n# Using bun\nbun install -g {{cliName}}\n```\n\n## Usage as cli\n```bash\n# Using npm\nnpm link # to test the cli locally\n\n# Using bun\nbun link # to test the cli locally\n\n{{binName}} greet --name=John\n```\n\n## Usage as library\n\n```ts\nimport { Greet } from '{{cliName}}';\n\nGreet('John'); // should print 'Hello, John!'\n\n```\n\n";
export declare const templateGreet = "// Greet example\nconst Greet = (name: string) => {\n const message = `Hello, ${name}!`;\n console.log(message);\n return message;\n}\n\nexport { Greet };\n";
export declare const templateBin = "#!/usr/bin/env node\nrequire('../cli.js');\n";
export declare const templateCommand = "import { Command, ParamType } from '@ideascol/cli-maker';\nimport { Greet } from '../lib';\n\nlet commandGreet: Command = {\n name: 'greet',\n description: 'Greet the user',\n params: [\n {\n name: 'name',\n description: 'The name of the user to greet',\n required: true,\n type: ParamType.Text\n }],\n action: (args) => {\n const name = args.name;\n Greet(name);\n }\n}\n\nexport default commandGreet;\n";
export declare const githubactionNpmTemplate = "on:\n push:\n branches: main\n pull_request:\n branches: main\n\njobs:\n test:\n if: github.event_name == 'push' || github.event_name == 'pull_request'\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v6\n - uses: actions/setup-node@v4\n with:\n node-version: \"24\"\n - run: npm ci\n - run: npm test\n publish:\n if: github.ref == 'refs/heads/main' && github.event_name == 'push'\n runs-on: ubuntu-latest\n needs: test\n steps:\n - uses: actions/checkout@v6\n - uses: actions/setup-node@v4\n with:\n node-version: \"24\"\n - run: npm ci\n - run: npm run build\n - name: Update version in cli.ts\n run: |\n VERSION=$(node -p \"require('./package.json').version\")\n sed -i \"s/version: '[^']*'/version: '$VERSION'/\" src/bin/cli.ts\n - uses: JS-DevTools/npm-publish@v3\n with:\n token: ${{ secrets.NPM_TOKEN }}\n access: public\n\n";
export declare const githubactionBunTemplate = "on:\n push:\n branches: main\n pull_request:\n branches: main\n\njobs:\n test:\n if: github.event_name == 'push' || github.event_name == 'pull_request'\n runs-on: ubuntu-slim\n steps:\n - uses: actions/checkout@v6\n - uses: oven-sh/setup-bun@v2\n with:\n bun-version: 1.3.3\n - run: bun install\n - run: bun test\n publish:\n if: github.ref == 'refs/heads/main' && github.event_name == 'push'\n runs-on: ubuntu-slim\n needs: test\n steps:\n - uses: actions/checkout@v6\n - uses: oven-sh/setup-bun@v2\n with:\n bun-version: 1.3.3\n - run: bun install\n - name: Update version in cli.ts\n run: |\n VERSION=$(node -p \"require('./package.json').version\")\n sed -i \"s/version: '[^']*'/version: '$VERSION'/\" src/bin/cli.ts\n - run: bun run build\n - uses: JS-DevTools/npm-publish@v3\n with:\n token: ${{ secrets.NPM_TOKEN }}\n access: public\n\n";
export declare const tsconfigTemplate = "{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"rootDir\": \"./src\",\n \"declaration\": true,\n \"declarationMap\": false\n },\n \"include\": [\"src/**/*.ts\"],\n \"exclude\": [\n \"src/tests/**/*\"\n ]\n}\n";
export declare const tsconfigBaseTemplate = "{\n \"compilerOptions\": {\n \"target\": \"ES2020\",\n \"module\": \"commonjs\",\n \"strict\": true,\n \"esModuleInterop\": true,\n \"skipLibCheck\": true,\n \"forceConsistentCasingInFileNames\": true,\n \"outDir\": \"./dist\",\n \"declaration\": true,\n \"declarationMap\": true,\n \"declarationDir\": \"./dist\"\n },\n \"exclude\": [\"node_modules\"]\n}\n";
export declare const tsconfigTestTemplate = "{\n \"extends\": \"./tsconfig.base.json\",\n \"compilerOptions\": {\n \"rootDir\": \"./src\"\n },\n \"include\": [\"tests/**/*.ts\", \"src/**/*.ts\"]\n}\n";