Skip to content

Commit

Permalink
Update templates.md
Browse files Browse the repository at this point in the history
  • Loading branch information
jshackell-sfdc authored May 31, 2024
1 parent 6d5c21d commit c72fb71
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions docs/templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
title: Templates
---

When you run `oclif generate`, you're prompted whether you want to use either [CommonJS](https://nodejs.org/api/modules.html) or [ESM](https://nodejs.org/api/esm.html) for your CLI. CommonJS modules were the original way to package JavaScript and TypeScript packages for reuse in Node.js; ESM modules are now the official standard format. Both options produce the same CLI, such as the same `tsconfig` file, `bin` scripts, sample commands, and so on.
When you run `oclif generate`, you're prompted whether you want to use either [CommonJS](https://nodejs.org/api/modules.html) or [ESM](https://nodejs.org/api/esm.html) for your CLI. CommonJS modules were the original way to package JavaScript and TypeScript packages for reuse in Node.js; ESM modules are now the official standard format. Both options produce the same CLI, with the same `tsconfig` file, `bin` scripts, sample commands, and so on.

Here's a brief rundown of everything that's included in your newly generated CLI.

## Bin Scripts

The templates contains 4 `bin` scripts that you can use for either production or development.
The generated CLI project contains 4 `bin` scripts that you can use for either production or development.

- `bin/run.js` - Run the CLI in production (macOS and Linux)
- `bin/dev.js` - Run the CLI in development (macOS and Linux)
Expand All @@ -25,28 +25,28 @@ The `dev.js` script uses `ts-node` as the Node.js runtime. However, you can use
- [Bun](https://bun.sh/)
- `node` - If you use `node` and ESM, make sure you're using a loader that allows it to use ESM modules, such as `--loader ts-node/esm`. See [ESM](esm.md) for more information.

For any of these you can point the hashbang in the file to a global install (e.g. `ts-node`) or to a locally installed one (`node_modules/.bin/ts-node`).
For all of these Node.js runtimes, you can point the hashbang (`#!`) in the `dev.js` and `run.js` files to a global installation of the runtime (such as `ts-node`) or to a locally installed one (`node_modules/.bin/ts-node`).

## Configuration

The template also comes with several configuration files that can be easily modified (or removed) to suit your needs.
The generated CLI also comes with several configuration files that you can easily modify, or even remove, to suit your needs.

- `.eslintrc.json` - Our recommended plugins and settings for `eslint`
- `.eslintignore` - Our recommended `.eslintignore` to go with our recommend eslint configuration.
- `.mocharc.json` - Our recommended settings for `mocha`
- `.eslintrc.json` - Our recommended plugins and settings for `eslint`.
- `.eslintignore` - Our recommended `.eslintignore` to go with our recommend `eslint` configuration.
- `.mocharc.json` - Our recommended settings for `mocha`.
- `.prettierrc.json` - Our recommended `prettier` settings - uses [`@oclif/prettier-config`](https://github.com/oclif/prettier-config) as the base.
- `tsconfig.json` - Our recommended compiler options for typescript projects.
- `tsconfig.json` - Our recommended compiler options for TypeScript projects.
- `package.json` - Our recommended scripts, dependencies, and `oclif` settings.

## Example Commands

The templates come with two commands that you can build off of.
The generated CLI project comes with two sample commands that you can use as a base to build your own.

- `hello` - `src/commands/hello/index.ts`
- `hello world` - `src/commands/hello/world.ts`

## Example Tests

Lastly, there are test files for each of those commands under the `tests` folder.
Test files for each of the sample commands are generated under the `tests` folder.

These tests use [`@oclif/test`](https://github.com/oclif/test) and [`mocha`](https://www.npmjs.com/package/mocha). You are, however, free to setup your tests with any testing utilities that best suit your needs.
These tests use [`@oclif/test`](https://github.com/oclif/test) and [`mocha`](https://www.npmjs.com/package/mocha). However, feel free to set up your tests with any testing utilities that better suit your needs.

0 comments on commit c72fb71

Please sign in to comment.