|
1 | 1 | # `create()` Documentation
|
2 | 2 |
|
3 |
| -> NOTE: `create()` is still under development |
4 |
| -
|
5 |
| -Creates a new library with the specified name set up with infrastructure using `@benmvp/cli`, returning a `Promise` indicating whether the creation succeeded or failed. |
| 3 | +Creates a new library or updates an existing library, to be set up with infrastructure using the latest version of `@benmvp/cli`, returning a `Promise` indicating whether the creation succeeded or failed. |
6 | 4 |
|
7 | 5 | It will:
|
8 | 6 |
|
| 7 | +- Set up git (i.e. `git init`) in the directory |
9 | 8 | - Add `"test"`, `"start"`, `"build"` and `"integrate"` scripts in the `package.json` to call [`benmvp test`](test.md), [`benmvp start`](start.md), [`benmvp build`](build.md), and [`benmvp integrate`](integrate.md), respectively
|
10 |
| -- After the `package.json` is created (or updated), it will install `@benmvp/cli` as a dev dependency, using [Yarn](https://yarnpkg.com/) if available. If Yarn is unavailable, it will fallback to [npm](https://docs.npmjs.com/) |
11 |
| -- Add (or overwrite) `.prettierrc.json`, `.prettierignore` & `.vscode/settings.json` files to format all code |
12 |
| -- Add (or overwrite) a `.github/workflows/ci.yml` [Github workflow](https://help.github.com/en/actions) for testing your code when a branch is pushed to or a PR is updated. |
13 |
| -- Add (or overwrite) a `.github/workflows/format.yml` [Github workflow](https://help.github.com/en/actions) for formatting your files when a non-`master` branch is pushed to. Formatted code will be pushed as a new commit to the branch. |
14 |
| -- Add (or overwrite) a `.github/workflows/release.yml` [Github workflow](https://help.github.com/en/actions) for release a new version of your package with new commits to `master`. |
15 |
| -- Add (or overwrite) `.github/pull_request_template.md` & `.github/ISSUE_TEMPLATE/*` for more organized [pull request](https://help.github.com/en/github/building-a-strong-community/creating-a-pull-request-template-for-your-repository) and [issue](https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository) creation. |
16 |
| - |
17 |
| -> NOTE: `create()` can be called multiple times on a repo. It's a good idea to call `create()` every time you bump the version of `@benmvp/cli` so you can get the latest configuration for `package.json`, prettier, Github workflows, and Github PR/Issue templates. |
| 9 | +- After the `package.json` is created (or updated), it will install `@benmvp/cli` as a dev dependency, using [npm](https://docs.npmjs.com/) |
| 10 | +- Add a dummy `src/index.ts` file which is the entry-point to the lib and from where all top-level API functions will be exported |
| 11 | +- Add (or overwrite) [`.prettierrc.json`](https://github.com/benmvp/benmvp-cli/blob/master/.prettierrc.json), [`.prettierignore`](https://github.com/benmvp/benmvp-cli/blob/master/.prettierignore) & [`.vscode/settings.json`](https://github.com/benmvp/benmvp-cli/blob/master/.vscode/settings.json) files to format all code |
| 12 | +- Add (or overwrite) [Github workflows](https://help.github.com/en/actions): |
| 13 | + - [`.github/workflows/ci.yml`](https://github.com/benmvp/benmvp-cli/blob/master/.github/workflows/ci.yml) for testing your code when a branch is pushed to or a PR is updated. |
| 14 | + - [`.github/workflows/format.yml`](https://github.com/benmvp/benmvp-cli/blob/master/.github/workflows/format.yml) for formatting your files when a non-`master` branch is pushed to. Formatted code will be pushed as a new commit to the branch. |
| 15 | + - [`.github/workflows/validate-pr.yml`](https://github.com/benmvp/benmvp-cli/blob/master/.github/workflows/validate-pr.yml) for validating that each PR title follows the [Conventional Commits specification](https://www.conventionalcommits.org/). |
| 16 | + - [`.github/workflows/release.yml`](https://github.com/benmvp/benmvp-cli/blob/master/.github/workflows/release.yml) for releasing a new version of your package upon new commits to `master`. |
| 17 | +- Add (or overwrite) [`.github/pull_request_template.md`](https://github.com/benmvp/benmvp-cli/blob/master/.github/pull_request_template.md) & [`.github/ISSUE_TEMPLATE`](https://github.com/benmvp/benmvp-cli/tree/master/.github/ISSUE_TEMPLATE) for more organized [pull request](https://help.github.com/en/github/building-a-strong-community/creating-a-pull-request-template-for-your-repository) and [issue](https://help.github.com/en/github/building-a-strong-community/configuring-issue-templates-for-your-repository) creation. |
| 18 | +- Add (or overwrite) other miscellaneous config files: |
| 19 | + - [`.gitignore`](https://github.com/benmvp/benmvp-cli/blob/master/.gitignore) |
| 20 | + - [`.nvmrc`](https://github.com/benmvp/benmvp-cli/blob/master/.nvmrc) |
| 21 | + - [`CHANGELOG.md`](https://github.com/benmvp/benmvp-cli/blob/master/CHANGELOG.md) |
| 22 | + - [`CONTRIBUTING.md`](https://github.com/benmvp/benmvp-cli/blob/master/CONTRIBUTING.md) |
| 23 | + - [`CODE_OF_CONDUCT.md`](https://github.com/benmvp/benmvp-cli/blob/master/CODE_OF_CONDUCT.md) |
| 24 | + - [`LICENSE`](https://github.com/benmvp/benmvp-cli/blob/master/LICENSE) |
| 25 | + |
| 26 | +> NOTE: `create()` can be called multiple times on a repo. It's a good idea to call `create()` every time you bump the version of `@benmvp/cli` so you can get the latest configuration for `package.json`, prettier, Github workflows, Github PR/Issue templates, and other miscellaneous config files. |
18 | 27 |
|
19 | 28 | Looking for CLI docs? View companion [`benmvp create` documentation](../cli/create.md).
|
20 | 29 |
|
@@ -75,14 +84,14 @@ The optional `Options` object supports the following properties:
|
75 | 84 |
|
76 | 85 | ### `name`
|
77 | 86 |
|
78 |
| -The name of the library to create or update. |
| 87 | +(Optional) The name of the library to create or update. |
79 | 88 |
|
80 |
| -When `name` is unspecified: |
| 89 | +When `name` is unspecified, it assumes the current working directory is the root of the library. Also: |
81 | 90 |
|
82 | 91 | - If a `package.json` does not already exist, it creates a new `package.json` with the name matching the directory it's within.
|
83 | 92 | - If a `package.json` does exist, it does nothing to the existing `package.json`.
|
84 | 93 |
|
85 |
| -When `name` is specified: |
| 94 | +When `name` is specified, it will create a directory of `name` within the current working directory. Also: |
86 | 95 |
|
87 | 96 | - If a `package.json` does not already exist, it creates a new `package.json` with the specified name.
|
88 | 97 | - If a `package.json` does exist, it updates the `"name"` property of the `package.json` with specified name.
|
|
0 commit comments