Quick Start
Ensure you have the latest version of NodeJS and a package manager such as NPM. Running one command starts the interactive project creator:
npm init func # or pnpm create func
Development
After you create an initial project, you will see these files:
. |-- src | |-- commands main command files | | |-- hello.ts "<Command> hello" | | |-- major.ts "<Command>" | | +-- index.ts entry file | |-- options options files | | |-- help.ts "<Command> --help" | | |-- version.ts "<Command> --version" | | +-- index.ts entry file | +-- index.ts entry file |-- tests testcases | |-- commands test for commands | +-- utils test utils |-- package.json |-- tsconfig.json +-- README.md
Before editing, install the dependencies and set up the development environment:
npm i npm run dev --
At this point, all preparation is complete.
You can browse the examples in commands and options,
modify them, and run your commands through the local TypeScript entry:
npm run dev -- hello npm run dev -- --version
Bundle
If you use the template to create a project, you only need one command to package it:
npm run build
After running the command, your project is packaged into the configured output directory.
When using func, you do not need to think about bin
files, file updates, or symlink problems. func handles all of that automatically,
so you can publish immediately.
If you need to return to development mode, run npm run dev again.
Publish
Publish your package after the build output has been generated. The template
already points package.json#bin at the generated executable.