{"id":15598620,"url":"https://github.com/jofaval/node-cli","last_synced_at":"2026-04-12T09:08:28.642Z","repository":{"id":125618351,"uuid":"578662956","full_name":"jofaval/node-cli","owner":"jofaval","description":"Node (JS Runtime) CLI (Command-Line Interface) introduction and examples. Typesafety and unit tests","archived":false,"fork":false,"pushed_at":"2022-12-27T18:05:17.000Z","size":171,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-04T12:52:02.190Z","etag":null,"topics":["cli","developer-experience","dx","javascript","node","react","typescript","vitest","vue"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jofaval.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-15T15:30:49.000Z","updated_at":"2023-03-07T08:06:55.000Z","dependencies_parsed_at":"2023-08-12T06:00:47.181Z","dependency_job_id":null,"html_url":"https://github.com/jofaval/node-cli","commit_stats":{"total_commits":63,"total_committers":2,"mean_commits":31.5,"dds":"0.015873015873015928","last_synced_commit":"13f9d47efd18ec99a0a74ad79625489a717ec209"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jofaval%2Fnode-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jofaval%2Fnode-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jofaval%2Fnode-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jofaval%2Fnode-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jofaval","download_url":"https://codeload.github.com/jofaval/node-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246180923,"owners_count":20736460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","developer-experience","dx","javascript","node","react","typescript","vitest","vue"],"created_at":"2024-10-03T01:40:50.846Z","updated_at":"2025-10-30T05:13:26.358Z","avatar_url":"https://github.com/jofaval.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Node CLI - Starter pack and beginner friendly-introduction\n\nThe only requirement is that you have some basic knowledge of programming fundamentals and javascript, es6 might help, but not necessary.\n\n## Contents\n\n1. [What does this provide?](#what-does-this-provide)\n1. [Configuration and setup](#configuration-and-setup)\n1. [Examples](#examples)\n   1. [Introduction](#introduction)\n   1. [Templates](#templates)\n   1. [Typesafety](#typesafety)\n   1. [Tested cli interactions](#tested-cli-interactions)\n   1. [Automation tricks](#automation-tricks)\n      1. [\"Faster\" typecheck and logging the result](#faster-typecheck-and-logging-the-result)\n      1. [Check structure](#check-structure)\n1. [Tech stack and requirements](#tech-stack-and-requirements)\n\n## What does this provide?\n\n[Back to the contents](#contents)\n\nA starter point into the CLI world for node, without some complex frameworks or local/private installations/distributions.\nJust some scripting, a couple of `.mjs` files, and even some type safety into it.\n\nThis is meant to show the possibilities and provide some pieces of the bigger picture, it is up to you how you put them together\n\n## Configuration and setup\n\n[Back to the contents](#contents)\n\nI'm using [`pnpm`](https://pnpm.io/es/), [`npm`](https://www.npmjs.com/) or [`yarn`](https://yarnpkg.com/) will also do the job.\n\nYou don't have to, but typescript is installed, and for the complete run, you'll have to install it, you can do so by:\n\n```bash\npnpm install # or npm or yarn\n```\n\nScripts and entrypoints are executed via `pnpm`, you can replace them, and most can be executed like:\n\n```bash\npnpm run [script] [...args] # or npm or yarn\n```\n\n## Examples\n\n[Back to the contents](#contents)\n\n### Introduction\n\n[Back to the examples](#examples)\n\nMy recommended script order:\n\n1. [JS Hello world](./scripts/js-hello-world.js)\n1. [With imports](./scripts/with-imports.mjs)\n1. [Hello name](./scripts/hello-name.mjs)\n1. [CLI Args parser](./scripts/args-parser.mjs)\n1. [EZ Write to file](./scripts/ez-write-to-file.mjs)\n1. [Write to file](./scripts/write-to-file.mjs)\n1. [Faster TSC](./scripts/faster-tsc.sh)\n1. [Type safe](./scripts/type-safe.mts)\n1. [Hello name with TypeScript](./scripts/hello-name.mts)\n\n### Templates\n\n[Back to the examples](#examples)\n\nCreating almost similar structures by copying and pasting folders is prone to error, mistakes, or simply, oversights.\nAutomating that process can be crucial in bigger apps with more complex structure, even more so if the architecture is complex and you want to assure quality.\n\nYou can do so by defining templates, and how you'd like them to interact with, what should be done before creating them, and after.\n\nDifferent frameworks use different files, extensions, structures, and projects and teams define the overarching architecture of it's elements, thus, it's up to you how the structure should actually be implemented.\n\nYou can even add different set of (initially failing) tests, services, queries and many more...\n\n```bash\npnpm run make:from --template=components --name=always-use-kebab-case\n```\n\nIt would be highly recommended to make the default case be `kebab-case`, `serpent_case` could be the only other candidate that could also assure consistency.\n\n### Typesafety\n\n[Back to the examples](#examples)\n\nIt's easy to fall under the pit of writing scripts in pure javascript, or commonjs, and variants. It's not a bad thing _per se_ but it could be improved, and it should on bigger CLIs.\n\nTypesafety could be achieved by simplify transpiling the content. I'd recommend using `.mts` that would transpile to `.mjs`, as to maximize the JS ecosystem in newer versions and be able to import/export utilities.\n\nIn case the utilities you're using are in Javascript, and migrating them might be too much, you could **declare** it's content with a module declaration file (`.js` -\u003e `.d.ts`, `.cjs` -\u003e `.d.cts`, `.mjs` -\u003e `.d.mts`).\n\n### Tested cli interactions\n\n[Back to the examples](#examples)\n\nAt times we write code, that we don't test, and we should. CLIs are no exception and actually are a great use case and example.\n\nNot everything in a CLI should be tested, i.e. saving a file, you'd be testing the actual system, but you could check the contents of that file looking for some specific change, even though it would be \"slower\", it could be necessary.\n\n### Automation tricks\n\n[Back to the examples](#examples)\n\nManually saving the output to a log, checking some details about the system (referent to the project), a custom update script\n\n#### \"Faster\" typecheck and logging the result\n\n[Back to the automation tricks](#automation-tricks)\n\nIt's not really faster, literally, but it will seem like it, instead of visually logging the output, just save it into a file, it's almost always much faster.\nPlus, the advantage of having a log file you can always check as a point of reference\n\n```bash\npnpm run faster-tsc\n```\n\nIt will generate a log with the typescript errors, if any\n\n#### Check structure\n\n[Back to the automation tricks](#automation-tricks)\n\nWe can also automate the validity of our structure, it can actually make PRs/MRs easier to check, since it's one less thing to worry about.\n\n```bash\npnpm run check-structure\n```\n\nThis will throw an exception if something's not valid.\\\nIf you don't want to wait for every file to be checked and just want to see if at least one is wrong, `earlyStopping` comes to the rescue!\n\n```bash\npnpm run check-structure --earlyStopping\n```\n\nYou may also want to check for a flat structure validity, or that's the standard in your app, you can do so by utilizing the `flat` flag.\n\n```bash\npnpm run check-structure --flat\n```\n\nThat you can stack...\n\n```bash\npnpm run check-structure --earlyStopping --flat\n```\n\n## Tech stack and requirements\n\n[Back to the contents](#contents)\n\nTech stack:\n\n- Node\n- Typescript\n- Vitest (testing) and coverage packs\n\nRequirements:\n\n- Node v18.5.0\n- NPM 8.12.1 (not used directly)\n- PNPM 7.18.1 (Node Agent, should also work with NPM and YARN)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjofaval%2Fnode-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjofaval%2Fnode-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjofaval%2Fnode-cli/lists"}