oclif 2.1.4 → 2.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.oclif.manifest.json +1 -1
- package/CHANGELOG.md +23 -0
- package/README.md +102 -58
- package/bin/dev +2 -3
- package/lib/commands/generate/command.d.ts +13 -0
- package/lib/commands/generate/command.js +21 -0
- package/lib/commands/generate/hook.d.ts +14 -0
- package/lib/commands/generate/hook.js +23 -0
- package/lib/generators/cli.d.ts +1 -2
- package/lib/generators/cli.js +9 -12
- package/lib/generators/command.d.ts +10 -0
- package/lib/generators/command.js +43 -0
- package/lib/generators/hook.d.ts +13 -0
- package/lib/generators/hook.js +44 -0
- package/lib/types/index.d.ts +16 -0
- package/lib/types/index.js +2 -0
- package/package.json +2 -4
- package/templates/src/command.ts.ejs +29 -0
- package/templates/src/hook.ts.ejs +7 -0
- package/templates/test/command.test.ts.ejs +17 -0
- package/templates/test/hook.test.ts.ejs +9 -0
package/.oclif.manifest.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":"2.1.
|
|
1
|
+
{"version":"2.1.8","commands":{"generate":{"id":"generate","description":"generate a new CLI\nThis will clone the template repo 'oclif/hello-world' and update package properties","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"name","description":"directory name of new project","required":true}]},"manifest":{"id":"manifest","description":"generates plugin manifest json","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"path","description":"path to plugin","default":"."}]},"promote":{"id":"promote","description":"promote CLI builds to a S3 release channel","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to the oclif CLI project root","required":true,"multiple":false,"default":"."},"version":{"name":"version","type":"option","description":"semantic version of the CLI to promote","required":true,"multiple":false},"sha":{"name":"sha","type":"option","description":"7-digit short git commit SHA of the CLI to promote","required":true,"multiple":false},"channel":{"name":"channel","type":"option","description":"which channel to promote to","required":true,"multiple":false,"default":"stable"},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to promote (e.g.: linux-arm,win32-x64)","multiple":false,"default":"linux-x64,linux-arm,win32-x64,win32-x86,darwin-x64,darwin-arm64"},"deb":{"name":"deb","type":"boolean","char":"d","description":"promote debian artifacts","allowNo":false},"macos":{"name":"macos","type":"boolean","char":"m","description":"promote macOS pkg","allowNo":false},"win":{"name":"win","type":"boolean","char":"w","description":"promote Windows exe","allowNo":false},"max-age":{"name":"max-age","type":"option","char":"a","description":"cache control max-age in seconds","multiple":false,"default":"86400"},"xz":{"name":"xz","type":"boolean","description":"also upload xz","allowNo":true},"indexes":{"name":"indexes","type":"boolean","description":"append the promoted urls into the index files","allowNo":false}},"args":[]},"readme":{"id":"readme","description":"adds commands to README.md in current directory\nThe readme must have any of the following tags inside of it for it to be replaced or else it will do nothing:\n# Usage\n<!-- usage -->\n# Commands\n<!-- commands -->\n\nCustomize the code URL prefix by setting oclif.repositoryPrefix in package.json.\n","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"dir":{"name":"dir","type":"option","description":"output directory for multi docs","required":true,"multiple":false,"default":"docs"},"multi":{"name":"multi","type":"boolean","description":"create a different markdown page for each topic","allowNo":false}},"args":[]},"generate:command":{"id":"generate:command","description":"add a command to an existing CLI or plugin","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","description":"overwrite existing files","allowNo":false}},"args":[{"name":"name","description":"name of command","required":true}]},"generate:hook":{"id":"generate:hook","description":"add a hook to an existing CLI or plugin","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"force":{"name":"force","type":"boolean","description":"overwrite existing files","allowNo":false},"event":{"name":"event","type":"option","description":"event to run hook on","multiple":false,"default":"init"}},"args":[{"name":"name","description":"name of hook (snake_case)","required":true}]},"pack:deb":{"id":"pack:deb","description":"pack CLI into debian package","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."}},"args":[]},"pack:macos":{"id":"pack:macos","description":"pack CLI into macOS .pkg","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"additional-cli":{"name":"additional-cli","type":"option","description":"an Oclif CLI other than the one listed in config.bin that should be made available to the user\nthe CLI should already exist in a directory named after the CLI that is the root of the tarball produced by \"oclif pack:tarballs\"","hidden":true,"multiple":false}},"args":[]},"pack:tarballs":{"id":"pack:tarballs","description":"packages oclif CLI into tarballs\n\nThis can be used to create oclif CLIs that use the system node or that come preloaded with a node binary.\n","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to pack (e.g.: linux-arm,win32-x64)","multiple":false,"default":"linux-x64,linux-arm,win32-x64,win32-x86,darwin-x64,darwin-arm64"},"xz":{"name":"xz","type":"boolean","description":"also build xz","allowNo":true}},"args":[]},"pack:win":{"id":"pack:win","description":"create windows installer from oclif CLI\n\n This command requires WINDOWS_SIGNING (prefixed with the name of your executable, e.g. OCLIF_WINDOWS_SIGNING_PASS) to be set in the environment","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"additional-cli":{"name":"additional-cli","type":"option","description":"an Oclif CLI other than the one listed in config.bin that should be made available to the user\nthe CLI should already exist in a directory named after the CLI that is the root of the tarball produced by \"oclif pack:tarballs\"","hidden":true,"multiple":false}},"args":[]},"upload:deb":{"id":"upload:deb","description":"upload deb package built with pack:deb","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."}},"args":[]},"upload:macos":{"id":"upload:macos","description":"upload macos installers built with pack:macos","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."}},"args":[]},"upload:tarballs":{"id":"upload:tarballs","description":"upload an oclif CLI to S3\n\n\"aws-sdk\" will need to be installed as a devDependency to upload.\n","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."},"targets":{"name":"targets","type":"option","char":"t","description":"comma-separated targets to upload (e.g.: linux-arm,win32-x64)","multiple":false,"default":"linux-x64,linux-arm,win32-x64,win32-x86,darwin-x64,darwin-arm64"},"xz":{"name":"xz","type":"boolean","description":"also upload xz","allowNo":true}},"args":[]},"upload:win":{"id":"upload:win","description":"upload windows installers built with pack:win","strict":true,"pluginName":"oclif","pluginAlias":"oclif","pluginType":"core","aliases":[],"flags":{"root":{"name":"root","type":"option","char":"r","description":"path to oclif CLI root","required":true,"multiple":false,"default":"."}},"args":[]}}}
|
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.1.8](https://github.com/oclif/oclif/compare/v2.1.7...v2.1.8) (2022-01-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* remove unnecessary dependency ([#794](https://github.com/oclif/oclif/issues/794)) ([f814f00](https://github.com/oclif/oclif/commit/f814f009b9b203c8917e265c16015a08af911537))
|
|
11
|
+
|
|
12
|
+
### [2.1.7](https://github.com/oclif/oclif/compare/v2.1.6...v2.1.7) (2022-01-11)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* correct package name ([#792](https://github.com/oclif/oclif/issues/792)) ([7197f98](https://github.com/oclif/oclif/commit/7197f98233d4391e4f322d16ff4a0cc92f7a4a6f))
|
|
18
|
+
|
|
19
|
+
### [2.1.6](https://github.com/oclif/oclif/compare/v2.1.5...v2.1.6) (2022-01-11)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* remove fixpack dependency ([#791](https://github.com/oclif/oclif/issues/791)) ([823300e](https://github.com/oclif/oclif/commit/823300e103bac560fd1e9e8748b33be59a80b066))
|
|
25
|
+
|
|
26
|
+
### [2.1.5](https://github.com/oclif/oclif/compare/v2.1.4...v2.1.5) (2022-01-10)
|
|
27
|
+
|
|
5
28
|
### [2.1.4](https://github.com/oclif/oclif/compare/v2.1.3...v2.1.4) (2022-01-10)
|
|
6
29
|
|
|
7
30
|
|
package/README.md
CHANGED
|
@@ -5,10 +5,8 @@
|
|
|
5
5
|
oclif: Node.JS Open CLI Framework
|
|
6
6
|
=================================
|
|
7
7
|
|
|
8
|
-
[](https://spectrum.chat/oclif)
|
|
9
8
|
[](https://npmjs.org/package/oclif)
|
|
10
9
|
[](https://circleci.com/gh/oclif/oclif/tree/main)
|
|
11
|
-
[](https://ci.appveyor.com/project/heroku/oclif/branch/main)
|
|
12
10
|
[](https://npmjs.org/package/@oclif/core)
|
|
13
11
|
[](https://github.com/oclif/oclif/blob/main/package.json)
|
|
14
12
|
|
|
@@ -17,6 +15,7 @@ oclif: Node.JS Open CLI Framework
|
|
|
17
15
|
* [🚀 Getting Started Tutorial](#-getting-started-tutorial)
|
|
18
16
|
* [✨ Features](#-features)
|
|
19
17
|
* [📌 Requirements](#-requirements)
|
|
18
|
+
* [📌 Migrating from V1](#-migrating-from-v1)
|
|
20
19
|
* [🏗 Usage](#-usage)
|
|
21
20
|
* [📚 Examples](#-examples)
|
|
22
21
|
* [🔨 Commands](#-commands)
|
|
@@ -40,15 +39,14 @@ The [Getting Started tutorial](http://oclif.io/docs/introduction) is a step-by-s
|
|
|
40
39
|
* **Flag/Argument parsing** - No CLI framework would be complete without a flag parser. We've built a custom one from years of experimentation that we feel consistently handles user input flexible enough for the user to be able to use the CLI in ways they expect, but without compromising strictness guarantees to the developer.
|
|
41
40
|
* **Super Speed** - The overhead for running an oclif CLI command is almost nothing. [It requires very few dependencies](https://www.npmjs.com/package/@oclif/command?activeTab=dependencies) (only 35 dependencies in a minimal setup—including all transitive dependencies). Also, only the command to be executed will be required with node. So large CLIs with many commands will load equally as fast as a small one with a single command.
|
|
42
41
|
* **CLI Generator** - Run a single command to scaffold out a fully functional CLI and get started quickly. See [Usage](#-usage) below.
|
|
43
|
-
* **Testing Helpers** - We've put a lot of work into making commands easier to test and mock out stdout/stderr. The generator will automatically create [scaffolded tests](https://github.com/oclif/
|
|
42
|
+
* **Testing Helpers** - We've put a lot of work into making commands easier to test and mock out stdout/stderr. The generator will automatically create [scaffolded tests](https://github.com/oclif/hello-world/blob/main/test/commands/hello.test.ts).
|
|
44
43
|
* **Auto-documentation** - By default you can pass `--help` to the CLI to get help such as flag options and argument information. This information is also automatically placed in the README whenever the npm package of the CLI is published. See the [multi-command CLI example](https://github.com/oclif/example-multi-ts)
|
|
45
44
|
* **Plugins** - Using [plugins](https://oclif.io/docs/plugins), users of the CLI can extend it with new functionality, a CLI can be split into modular components, and functionality can be shared amongst multiple CLIs. See [Building your own plugin](https://oclif.io/docs/plugins#building-your-own-plugin).
|
|
46
45
|
* **Hooks** - Use lifecycle hooks to run functionality any time a CLI starts, or on custom triggers. Use this whenever custom functionality needs to be shared between various components of the CLI.
|
|
47
|
-
* **TypeScript
|
|
46
|
+
* **TypeScript** - Everything in the core of oclif is written in TypeScript and the generator will build fully configured TypeScript CLIs. If you use plugins support, the CLI will automatically use `ts-node` to run the plugins enabling you to use TypeScript with minimal-to-no boilerplate needed for any oclif CLI.
|
|
48
47
|
* **Auto-updating Installers** - oclif can package your CLI into [different installers](https://oclif.io/docs/releasing) that will not require the user to already have node installed on the machine. These can be made auto-updatable by using [plugin-update](https://github.com/oclif/plugin-update).
|
|
49
48
|
* **Everything is Customizable** - Pretty much anything can be swapped out and replaced inside oclif if needed—including the arg/flag parser.
|
|
50
49
|
* **Autocomplete** - Automatically include autocomplete for your CLI. This includes not only command names and flag names, but flag values as well. For example, it's possible to configure the Heroku CLI to have completions for Heroku app names:
|
|
51
|
-
<!--* **Coming soon: man pages** - In addition to in-CLI help through `-help` and the README markdown help generation, the CLI can also automatically create man pages for all of its commands.-->
|
|
52
50
|
|
|
53
51
|
```
|
|
54
52
|
$ heroku info --app=<tab><tab> # will complete with all the Heroku apps a user has in their account
|
|
@@ -56,7 +54,33 @@ $ heroku info --app=<tab><tab> # will complete with all the Heroku apps a user h
|
|
|
56
54
|
|
|
57
55
|
# 📌 Requirements
|
|
58
56
|
|
|
59
|
-
Currently, Node
|
|
57
|
+
Currently, Node 12+ is supported. We support the [LTS versions](https://nodejs.org/en/about/releases) of Node. You can add the [node](https://www.npmjs.com/package/node) package to your CLI to ensure users are running a specific version of Node.
|
|
58
|
+
|
|
59
|
+
# 📌 Migrating from V1
|
|
60
|
+
|
|
61
|
+
If you have been using version 1 of the [`oclif` CLI](https://github.com/oclif/oclif/tree/v1.18.4) there are some important differences to note when using the latest version.
|
|
62
|
+
|
|
63
|
+
## Breaking Changes
|
|
64
|
+
|
|
65
|
+
- `oclif multi`, `oclif plugin`, and `oclif single` have all been removed in favor of `oclif generate`, which generates an oclif based CLI using the [hello-world example repo](https://github.com/oclif/hello-world).
|
|
66
|
+
- The reason is that there's not enough of a meaningful difference between a "multi command cli", a "single command cli", and a "plugin" to justify the maintenance cost. The generated CLI can be easily used for any of those use cases.
|
|
67
|
+
- `oclif hook` is now `oclif generate:hook`
|
|
68
|
+
- `oclif command` is now `oclif generate:command`
|
|
69
|
+
|
|
70
|
+
## New Commands
|
|
71
|
+
|
|
72
|
+
Version 2 now includes all the commands from the [`oclif-dev` CLI](https://github.com/oclif/dev-cli). This means that you can now use a single CLI for all your oclif needs. These commands include:
|
|
73
|
+
- `oclif manifest`
|
|
74
|
+
- `oclif pack`
|
|
75
|
+
- `oclif pack:deb`
|
|
76
|
+
- `oclif pack:macos`
|
|
77
|
+
- `oclif pack:win`
|
|
78
|
+
- `oclif upload` (formerly known as `oclif-dev publish`)
|
|
79
|
+
- `oclif upload:deb` (formerly known as `oclif-dev publish:deb`)
|
|
80
|
+
- `oclif upload:macos` (formerly known as `oclif-dev publish:macos`)
|
|
81
|
+
- `oclif upload:win` (formerly known as `oclif-dev publish:win`)
|
|
82
|
+
- `oclif readme`
|
|
83
|
+
|
|
60
84
|
|
|
61
85
|
# 🏗 Usage
|
|
62
86
|
|
|
@@ -82,27 +106,28 @@ hello world from ./src/hello.js!
|
|
|
82
106
|
|
|
83
107
|
# 📚 Examples
|
|
84
108
|
|
|
85
|
-
*
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
* [Multi-command CLI Plugin](https://github.com/oclif/example-plugin-ts)
|
|
109
|
+
* [Hello-World](https://github.com/oclif/hello-world)
|
|
110
|
+
* [Salesforce CLI](https://github.com/salesforcecli/cli)
|
|
111
|
+
* [Heroku CLI](https://github.com/heroku/cli)
|
|
89
112
|
|
|
90
113
|
# 🔨 Commands
|
|
91
114
|
|
|
92
115
|
<!-- commands -->
|
|
93
116
|
* [`oclif generate NAME`](#oclif-generate-name)
|
|
117
|
+
* [`oclif generate command NAME`](#oclif-generate-command-name)
|
|
118
|
+
* [`oclif generate hook NAME`](#oclif-generate-hook-name)
|
|
94
119
|
* [`oclif help [COMMAND]`](#oclif-help-command)
|
|
95
120
|
* [`oclif manifest [PATH]`](#oclif-manifest-path)
|
|
96
|
-
* [`oclif pack
|
|
97
|
-
* [`oclif pack
|
|
98
|
-
* [`oclif pack
|
|
99
|
-
* [`oclif pack
|
|
121
|
+
* [`oclif pack deb`](#oclif-pack-deb)
|
|
122
|
+
* [`oclif pack macos`](#oclif-pack-macos)
|
|
123
|
+
* [`oclif pack tarballs`](#oclif-pack-tarballs)
|
|
124
|
+
* [`oclif pack win`](#oclif-pack-win)
|
|
100
125
|
* [`oclif promote`](#oclif-promote)
|
|
101
126
|
* [`oclif readme`](#oclif-readme)
|
|
102
|
-
* [`oclif upload
|
|
103
|
-
* [`oclif upload
|
|
104
|
-
* [`oclif upload
|
|
105
|
-
* [`oclif upload
|
|
127
|
+
* [`oclif upload deb`](#oclif-upload-deb)
|
|
128
|
+
* [`oclif upload macos`](#oclif-upload-macos)
|
|
129
|
+
* [`oclif upload tarballs`](#oclif-upload-tarballs)
|
|
130
|
+
* [`oclif upload win`](#oclif-upload-win)
|
|
106
131
|
|
|
107
132
|
## `oclif generate NAME`
|
|
108
133
|
|
|
@@ -121,7 +146,44 @@ DESCRIPTION
|
|
|
121
146
|
This will clone the template repo 'oclif/hello-world' and update package properties
|
|
122
147
|
```
|
|
123
148
|
|
|
124
|
-
_See code: [src/commands/generate.ts](https://github.com/oclif/oclif/blob/v2.1.
|
|
149
|
+
_See code: [src/commands/generate.ts](https://github.com/oclif/oclif/blob/v2.1.7/src/commands/generate.ts)_
|
|
150
|
+
|
|
151
|
+
## `oclif generate command NAME`
|
|
152
|
+
|
|
153
|
+
add a command to an existing CLI or plugin
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
USAGE
|
|
157
|
+
$ oclif generate command [NAME] [--force]
|
|
158
|
+
|
|
159
|
+
ARGUMENTS
|
|
160
|
+
NAME name of command
|
|
161
|
+
|
|
162
|
+
FLAGS
|
|
163
|
+
--force overwrite existing files
|
|
164
|
+
|
|
165
|
+
DESCRIPTION
|
|
166
|
+
add a command to an existing CLI or plugin
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
## `oclif generate hook NAME`
|
|
170
|
+
|
|
171
|
+
add a hook to an existing CLI or plugin
|
|
172
|
+
|
|
173
|
+
```
|
|
174
|
+
USAGE
|
|
175
|
+
$ oclif generate hook [NAME] [--force] [--event <value>]
|
|
176
|
+
|
|
177
|
+
ARGUMENTS
|
|
178
|
+
NAME name of hook (snake_case)
|
|
179
|
+
|
|
180
|
+
FLAGS
|
|
181
|
+
--event=<value> [default: init] event to run hook on
|
|
182
|
+
--force overwrite existing files
|
|
183
|
+
|
|
184
|
+
DESCRIPTION
|
|
185
|
+
add a hook to an existing CLI or plugin
|
|
186
|
+
```
|
|
125
187
|
|
|
126
188
|
## `oclif help [COMMAND]`
|
|
127
189
|
|
|
@@ -158,15 +220,15 @@ DESCRIPTION
|
|
|
158
220
|
generates plugin manifest json
|
|
159
221
|
```
|
|
160
222
|
|
|
161
|
-
_See code: [src/commands/manifest.ts](https://github.com/oclif/oclif/blob/v2.1.
|
|
223
|
+
_See code: [src/commands/manifest.ts](https://github.com/oclif/oclif/blob/v2.1.7/src/commands/manifest.ts)_
|
|
162
224
|
|
|
163
|
-
## `oclif pack
|
|
225
|
+
## `oclif pack deb`
|
|
164
226
|
|
|
165
227
|
pack CLI into debian package
|
|
166
228
|
|
|
167
229
|
```
|
|
168
230
|
USAGE
|
|
169
|
-
$ oclif pack
|
|
231
|
+
$ oclif pack deb -r <value>
|
|
170
232
|
|
|
171
233
|
FLAGS
|
|
172
234
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -175,15 +237,13 @@ DESCRIPTION
|
|
|
175
237
|
pack CLI into debian package
|
|
176
238
|
```
|
|
177
239
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
## `oclif pack:macos`
|
|
240
|
+
## `oclif pack macos`
|
|
181
241
|
|
|
182
242
|
pack CLI into macOS .pkg
|
|
183
243
|
|
|
184
244
|
```
|
|
185
245
|
USAGE
|
|
186
|
-
$ oclif pack
|
|
246
|
+
$ oclif pack macos -r <value>
|
|
187
247
|
|
|
188
248
|
FLAGS
|
|
189
249
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -192,15 +252,13 @@ DESCRIPTION
|
|
|
192
252
|
pack CLI into macOS .pkg
|
|
193
253
|
```
|
|
194
254
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
## `oclif pack:tarballs`
|
|
255
|
+
## `oclif pack tarballs`
|
|
198
256
|
|
|
199
257
|
packages oclif CLI into tarballs
|
|
200
258
|
|
|
201
259
|
```
|
|
202
260
|
USAGE
|
|
203
|
-
$ oclif pack
|
|
261
|
+
$ oclif pack tarballs -r <value> [-t <value>] [--xz]
|
|
204
262
|
|
|
205
263
|
FLAGS
|
|
206
264
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -214,15 +272,13 @@ DESCRIPTION
|
|
|
214
272
|
This can be used to create oclif CLIs that use the system node or that come preloaded with a node binary.
|
|
215
273
|
```
|
|
216
274
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
## `oclif pack:win`
|
|
275
|
+
## `oclif pack win`
|
|
220
276
|
|
|
221
277
|
create windows installer from oclif CLI
|
|
222
278
|
|
|
223
279
|
```
|
|
224
280
|
USAGE
|
|
225
|
-
$ oclif pack
|
|
281
|
+
$ oclif pack win -r <value>
|
|
226
282
|
|
|
227
283
|
FLAGS
|
|
228
284
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -234,8 +290,6 @@ DESCRIPTION
|
|
|
234
290
|
be set in the environment
|
|
235
291
|
```
|
|
236
292
|
|
|
237
|
-
_See code: [src/commands/pack/win.ts](https://github.com/oclif/oclif/blob/v2.1.3/src/commands/pack/win.ts)_
|
|
238
|
-
|
|
239
293
|
## `oclif promote`
|
|
240
294
|
|
|
241
295
|
promote CLI builds to a S3 release channel
|
|
@@ -263,7 +317,7 @@ DESCRIPTION
|
|
|
263
317
|
promote CLI builds to a S3 release channel
|
|
264
318
|
```
|
|
265
319
|
|
|
266
|
-
_See code: [src/commands/promote.ts](https://github.com/oclif/oclif/blob/v2.1.
|
|
320
|
+
_See code: [src/commands/promote.ts](https://github.com/oclif/oclif/blob/v2.1.7/src/commands/promote.ts)_
|
|
267
321
|
|
|
268
322
|
## `oclif readme`
|
|
269
323
|
|
|
@@ -293,15 +347,15 @@ DESCRIPTION
|
|
|
293
347
|
Customize the code URL prefix by setting oclif.repositoryPrefix in package.json.
|
|
294
348
|
```
|
|
295
349
|
|
|
296
|
-
_See code: [src/commands/readme.ts](https://github.com/oclif/oclif/blob/v2.1.
|
|
350
|
+
_See code: [src/commands/readme.ts](https://github.com/oclif/oclif/blob/v2.1.7/src/commands/readme.ts)_
|
|
297
351
|
|
|
298
|
-
## `oclif upload
|
|
352
|
+
## `oclif upload deb`
|
|
299
353
|
|
|
300
354
|
upload deb package built with pack:deb
|
|
301
355
|
|
|
302
356
|
```
|
|
303
357
|
USAGE
|
|
304
|
-
$ oclif upload
|
|
358
|
+
$ oclif upload deb -r <value>
|
|
305
359
|
|
|
306
360
|
FLAGS
|
|
307
361
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -310,15 +364,13 @@ DESCRIPTION
|
|
|
310
364
|
upload deb package built with pack:deb
|
|
311
365
|
```
|
|
312
366
|
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
## `oclif upload:macos`
|
|
367
|
+
## `oclif upload macos`
|
|
316
368
|
|
|
317
369
|
upload macos installers built with pack:macos
|
|
318
370
|
|
|
319
371
|
```
|
|
320
372
|
USAGE
|
|
321
|
-
$ oclif upload
|
|
373
|
+
$ oclif upload macos -r <value>
|
|
322
374
|
|
|
323
375
|
FLAGS
|
|
324
376
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -327,15 +379,13 @@ DESCRIPTION
|
|
|
327
379
|
upload macos installers built with pack:macos
|
|
328
380
|
```
|
|
329
381
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
## `oclif upload:tarballs`
|
|
382
|
+
## `oclif upload tarballs`
|
|
333
383
|
|
|
334
384
|
upload an oclif CLI to S3
|
|
335
385
|
|
|
336
386
|
```
|
|
337
387
|
USAGE
|
|
338
|
-
$ oclif upload
|
|
388
|
+
$ oclif upload tarballs -r <value> [-t <value>] [--xz]
|
|
339
389
|
|
|
340
390
|
FLAGS
|
|
341
391
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -349,15 +399,13 @@ DESCRIPTION
|
|
|
349
399
|
"aws-sdk" will need to be installed as a devDependency to upload.
|
|
350
400
|
```
|
|
351
401
|
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
## `oclif upload:win`
|
|
402
|
+
## `oclif upload win`
|
|
355
403
|
|
|
356
404
|
upload windows installers built with pack:win
|
|
357
405
|
|
|
358
406
|
```
|
|
359
407
|
USAGE
|
|
360
|
-
$ oclif upload
|
|
408
|
+
$ oclif upload win -r <value>
|
|
361
409
|
|
|
362
410
|
FLAGS
|
|
363
411
|
-r, --root=<value> (required) [default: .] path to oclif CLI root
|
|
@@ -365,15 +413,11 @@ FLAGS
|
|
|
365
413
|
DESCRIPTION
|
|
366
414
|
upload windows installers built with pack:win
|
|
367
415
|
```
|
|
368
|
-
|
|
369
|
-
_See code: [src/commands/upload/win.ts](https://github.com/oclif/oclif/blob/v2.1.3/src/commands/upload/win.ts)_
|
|
370
416
|
<!-- commandsstop -->
|
|
371
417
|
|
|
372
418
|
# 🏭 Related Repositories
|
|
373
419
|
|
|
374
|
-
* [@oclif/
|
|
375
|
-
* [@oclif/config](https://github.com/oclif/config) - Most of the core setup for oclif lives here.
|
|
376
|
-
* [@oclif/errors](https://github.com/oclif/errors) - Renders and logs errors from commands.
|
|
420
|
+
* [@oclif/core](https://github.com/oclif/core) - Base library for oclif. This can be used directly without the generator.
|
|
377
421
|
* [@oclif/cli-ux](https://github.com/oclif/cli-ux) - Library for common CLI UI utilities.
|
|
378
422
|
* [@oclif/test](https://github.com/oclif/test) - Test helper for oclif.
|
|
379
423
|
|
|
@@ -384,4 +428,4 @@ _See code: [src/commands/upload/win.ts](https://github.com/oclif/oclif/blob/v2.1
|
|
|
384
428
|
|
|
385
429
|
# 📣 Feedback
|
|
386
430
|
|
|
387
|
-
If you have any suggestions or want to let us know what you think of oclif, send us a message at <
|
|
431
|
+
If you have any suggestions or want to let us know what you think of oclif, send us a message at <alm-cli@salesforce.com>
|
package/bin/dev
CHANGED
|
@@ -11,9 +11,8 @@ process.env.NODE_ENV = 'development'
|
|
|
11
11
|
require('ts-node').register({project})
|
|
12
12
|
|
|
13
13
|
// In dev mode, always show stack traces
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
oclif.settings.disableJsonFlag = true
|
|
14
|
+
oclif.settings.debug = true;
|
|
15
|
+
|
|
17
16
|
|
|
18
17
|
// Start the CLI
|
|
19
18
|
oclif.run().then(oclif.flush).catch(oclif.Errors.handle)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import CommandBase from './../../command-base';
|
|
2
|
+
export default class GenerateCommand extends CommandBase {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
};
|
|
7
|
+
static args: {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
required: boolean;
|
|
11
|
+
}[];
|
|
12
|
+
run(): Promise<void>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_base_1 = require("./../../command-base");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
class GenerateCommand extends command_base_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
const { args, flags } = await this.parse(GenerateCommand);
|
|
8
|
+
await super.generate('command', {
|
|
9
|
+
name: args.name,
|
|
10
|
+
force: flags.force,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.default = GenerateCommand;
|
|
15
|
+
GenerateCommand.description = 'add a command to an existing CLI or plugin';
|
|
16
|
+
GenerateCommand.flags = {
|
|
17
|
+
force: core_1.Flags.boolean({ description: 'overwrite existing files' }),
|
|
18
|
+
};
|
|
19
|
+
GenerateCommand.args = [
|
|
20
|
+
{ name: 'name', description: 'name of command', required: true },
|
|
21
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import CommandBase from './../../command-base';
|
|
2
|
+
export default class GenerateHook extends CommandBase {
|
|
3
|
+
static description: string;
|
|
4
|
+
static flags: {
|
|
5
|
+
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
6
|
+
event: import("@oclif/core/lib/interfaces").OptionFlag<string>;
|
|
7
|
+
};
|
|
8
|
+
static args: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
required: boolean;
|
|
12
|
+
}[];
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const command_base_1 = require("./../../command-base");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
class GenerateHook extends command_base_1.default {
|
|
6
|
+
async run() {
|
|
7
|
+
const { args, flags } = await this.parse(GenerateHook);
|
|
8
|
+
await super.generate('hook', {
|
|
9
|
+
name: args.name,
|
|
10
|
+
event: flags.event,
|
|
11
|
+
force: flags.force,
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.default = GenerateHook;
|
|
16
|
+
GenerateHook.description = 'add a hook to an existing CLI or plugin';
|
|
17
|
+
GenerateHook.flags = {
|
|
18
|
+
force: core_1.Flags.boolean({ description: 'overwrite existing files' }),
|
|
19
|
+
event: core_1.Flags.string({ description: 'event to run hook on', default: 'init' }),
|
|
20
|
+
};
|
|
21
|
+
GenerateHook.args = [
|
|
22
|
+
{ name: 'name', description: 'name of hook (snake_case)', required: true },
|
|
23
|
+
];
|
package/lib/generators/cli.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as Generator from 'yeoman-generator';
|
|
2
|
-
|
|
2
|
+
export default class CLI extends Generator {
|
|
3
3
|
options: {
|
|
4
4
|
defaults?: boolean;
|
|
5
5
|
yarn: boolean;
|
|
@@ -41,4 +41,3 @@ declare class App extends Generator {
|
|
|
41
41
|
end(): void;
|
|
42
42
|
private _gitignore;
|
|
43
43
|
}
|
|
44
|
-
export = App;
|
package/lib/generators/cli.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2
3
|
const child_process_1 = require("child_process");
|
|
3
4
|
const fs = require("fs");
|
|
4
5
|
const _ = require("lodash");
|
|
5
6
|
const path = require("path");
|
|
6
7
|
const Generator = require("yeoman-generator");
|
|
7
8
|
const yosay = require("yosay");
|
|
8
|
-
const sortPjson = require('sort-pjson');
|
|
9
|
-
const fixpack = require('@oclif/fixpack');
|
|
10
9
|
const debug = require('debug')('generator-oclif');
|
|
11
10
|
const { version } = require('../../package.json');
|
|
12
11
|
const isWindows = process.platform === 'win32';
|
|
@@ -16,7 +15,7 @@ try {
|
|
|
16
15
|
hasYarn = true;
|
|
17
16
|
}
|
|
18
17
|
catch (_a) { }
|
|
19
|
-
class
|
|
18
|
+
class CLI extends Generator {
|
|
20
19
|
constructor(args, opts) {
|
|
21
20
|
super(args, opts);
|
|
22
21
|
this.name = opts.name;
|
|
@@ -28,16 +27,17 @@ class App extends Generator {
|
|
|
28
27
|
async prompting() {
|
|
29
28
|
const msg = 'Time to build an oclif CLI!';
|
|
30
29
|
this.log(yosay(`${msg} Version: ${version}`));
|
|
31
|
-
(0, child_process_1.execSync)(`git clone https://github.com/oclif/hello-world.git ${path.resolve(this.name)}`);
|
|
32
|
-
fs.
|
|
30
|
+
(0, child_process_1.execSync)(`git clone https://github.com/oclif/hello-world.git "${path.resolve(this.name)}"`);
|
|
31
|
+
fs.rmSync(`${path.resolve(this.name, '.git')}`, { recursive: true });
|
|
33
32
|
this.destinationRoot(path.resolve(this.name));
|
|
34
33
|
process.chdir(this.destinationRoot());
|
|
35
34
|
this.githubUser = await this.user.github.username().catch(debug);
|
|
36
|
-
|
|
35
|
+
// establish order of properties in the resulting package.json
|
|
36
|
+
this.pjson = Object.assign({ name: '', version: '', description: '', author: '', bin: {}, homepage: '', license: '', main: '', repository: '', files: [], dependencies: {}, devDependencies: {}, oclif: {}, scripts: {}, engines: {} }, this.fs.readJSON('package.json', {}));
|
|
37
37
|
let repository = this.destinationRoot().split(path.sep).slice(-2).join('/');
|
|
38
38
|
if (this.githubUser)
|
|
39
39
|
repository = `${this.githubUser}/${repository.split('/')[1]}`;
|
|
40
|
-
const defaults = Object.assign(Object.assign({ name: this.determineAppname().replace(/ /g, '-'), version: '0.0.0', license: 'MIT', author: this.githubUser ? `${this.user.git.name()} @${this.githubUser}` : this.user.git.name(), dependencies: {}, repository
|
|
40
|
+
const defaults = Object.assign(Object.assign({}, this.pjson), { name: this.name ? this.name.replace(/ /g, '-') : this.determineAppname().replace(/ /g, '-'), version: '0.0.0', license: 'MIT', author: this.githubUser ? `${this.user.git.name()} @${this.githubUser}` : this.user.git.name(), dependencies: {}, repository, engines: Object.assign({ node: '>=12.0.0' }, this.pjson.engines), options: this.options });
|
|
41
41
|
this.repository = defaults.repository;
|
|
42
42
|
if (this.repository && this.repository.url) {
|
|
43
43
|
this.repository = this.repository.url;
|
|
@@ -132,13 +132,10 @@ class App extends Generator {
|
|
|
132
132
|
if (this.pjson.oclif && Array.isArray(this.pjson.oclif.plugins)) {
|
|
133
133
|
this.pjson.oclif.plugins.sort();
|
|
134
134
|
}
|
|
135
|
-
if (this.fs.exists(this.destinationPath('./package.json'))) {
|
|
136
|
-
fixpack(this.destinationPath('./package.json'), require('@oclif/fixpack/config.json'));
|
|
137
|
-
}
|
|
138
135
|
if (_.isEmpty(this.pjson.oclif))
|
|
139
136
|
delete this.pjson.oclif;
|
|
140
137
|
this.pjson.files = _.uniq((this.pjson.files || []).sort());
|
|
141
|
-
this.fs.writeJSON(this.destinationPath('./package.json'),
|
|
138
|
+
this.fs.writeJSON(this.destinationPath('./package.json'), this.pjson);
|
|
142
139
|
this.fs.write(this.destinationPath('.gitignore'), this._gitignore());
|
|
143
140
|
}
|
|
144
141
|
async install() {
|
|
@@ -179,4 +176,4 @@ class App extends Generator {
|
|
|
179
176
|
.join('\n') + '\n';
|
|
180
177
|
}
|
|
181
178
|
}
|
|
182
|
-
|
|
179
|
+
exports.default = CLI;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as Generator from 'yeoman-generator';
|
|
2
|
+
import { GeneratorOptions, PackageJson } from '../types';
|
|
3
|
+
export default class Command extends Generator {
|
|
4
|
+
options: GeneratorOptions;
|
|
5
|
+
pjson: PackageJson;
|
|
6
|
+
constructor(args: string | string[], opts: GeneratorOptions);
|
|
7
|
+
private hasMocha;
|
|
8
|
+
prompting(): Promise<void>;
|
|
9
|
+
writing(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _ = require("lodash");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const Generator = require("yeoman-generator");
|
|
6
|
+
const yosay = require("yosay");
|
|
7
|
+
const { version } = require('../../package.json');
|
|
8
|
+
class Command extends Generator {
|
|
9
|
+
constructor(args, opts) {
|
|
10
|
+
super(args, opts);
|
|
11
|
+
this.options = {
|
|
12
|
+
name: opts.name,
|
|
13
|
+
defaults: opts.defaults,
|
|
14
|
+
force: opts.force,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
hasMocha() {
|
|
18
|
+
var _a;
|
|
19
|
+
return Boolean((_a = this.pjson.devDependencies) === null || _a === void 0 ? void 0 : _a.mocha);
|
|
20
|
+
}
|
|
21
|
+
async prompting() {
|
|
22
|
+
this.pjson = this.fs.readJSON('package.json');
|
|
23
|
+
if (!this.pjson)
|
|
24
|
+
throw new Error('not in a project directory');
|
|
25
|
+
this.pjson.oclif = this.pjson.oclif || {};
|
|
26
|
+
this.log(yosay(`Adding a command to ${this.pjson.name} Version: ${version}`));
|
|
27
|
+
}
|
|
28
|
+
writing() {
|
|
29
|
+
const cmdPath = this.options.name.split(':').join('/');
|
|
30
|
+
this.sourceRoot(path.join(__dirname, '../../templates'));
|
|
31
|
+
let bin = this.pjson.oclif.bin || this.pjson.oclif.dirname || this.pjson.name;
|
|
32
|
+
if (bin.includes('/'))
|
|
33
|
+
bin = bin.split('/').pop();
|
|
34
|
+
const cmd = `${bin} ${this.options.name}`;
|
|
35
|
+
const commandPath = this.destinationPath(`src/commands/${cmdPath}.ts`);
|
|
36
|
+
const opts = Object.assign(Object.assign({}, this.options), { bin, cmd, _, type: 'command', path: commandPath });
|
|
37
|
+
this.fs.copyTpl(this.templatePath('src/command.ts.ejs'), commandPath, opts);
|
|
38
|
+
if (this.hasMocha()) {
|
|
39
|
+
this.fs.copyTpl(this.templatePath('test/command.test.ts.ejs'), this.destinationPath(`test/commands/${cmdPath}.test.ts`), opts);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.default = Command;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as Generator from 'yeoman-generator';
|
|
2
|
+
import { GeneratorOptions, PackageJson } from '../types';
|
|
3
|
+
export interface Options extends GeneratorOptions {
|
|
4
|
+
event: string;
|
|
5
|
+
}
|
|
6
|
+
export default class Hook extends Generator {
|
|
7
|
+
options: Options;
|
|
8
|
+
pjson: PackageJson;
|
|
9
|
+
constructor(args: string | string[], options: Options);
|
|
10
|
+
private hasMocha;
|
|
11
|
+
prompting(): Promise<void>;
|
|
12
|
+
writing(): void;
|
|
13
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const _ = require("lodash");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const Generator = require("yeoman-generator");
|
|
6
|
+
const yosay = require("yosay");
|
|
7
|
+
const { version } = require('../../package.json');
|
|
8
|
+
class Hook extends Generator {
|
|
9
|
+
constructor(args, options) {
|
|
10
|
+
super(args, options);
|
|
11
|
+
this.options = options;
|
|
12
|
+
}
|
|
13
|
+
hasMocha() {
|
|
14
|
+
var _a;
|
|
15
|
+
return Boolean((_a = this.pjson.devDependencies) === null || _a === void 0 ? void 0 : _a.mocha);
|
|
16
|
+
}
|
|
17
|
+
async prompting() {
|
|
18
|
+
this.pjson = this.fs.readJSON('package.json');
|
|
19
|
+
this.pjson.oclif = this.pjson.oclif || {};
|
|
20
|
+
if (!this.pjson)
|
|
21
|
+
throw new Error('not in a project directory');
|
|
22
|
+
this.log(yosay(`Adding a ${this.options.event} hook to ${this.pjson.name} Version: ${version}`));
|
|
23
|
+
}
|
|
24
|
+
writing() {
|
|
25
|
+
this.sourceRoot(path.join(__dirname, '../../templates'));
|
|
26
|
+
this.fs.copyTpl(this.templatePath('src/hook.ts.ejs'), this.destinationPath(`src/hooks/${this.options.event}/${this.options.name}.ts`), this);
|
|
27
|
+
if (this.hasMocha()) {
|
|
28
|
+
this.fs.copyTpl(this.templatePath('test/hook.test.ts.ejs'), this.destinationPath(`test/hooks/${this.options.event}/${this.options.name}.test.ts`), this);
|
|
29
|
+
}
|
|
30
|
+
this.pjson.oclif = this.pjson.oclif || {};
|
|
31
|
+
this.pjson.oclif.hooks = this.pjson.oclif.hooks || {};
|
|
32
|
+
const hooks = this.pjson.oclif.hooks;
|
|
33
|
+
const p = `./src/hooks/${this.options.event}/${this.options.name}`;
|
|
34
|
+
if (hooks[this.options.event]) {
|
|
35
|
+
hooks[this.options.event] = _.castArray(hooks[this.options.event]);
|
|
36
|
+
hooks[this.options.event] = hooks[this.options.event].concat(p);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
this.pjson.oclif.hooks[this.options.event] = p;
|
|
40
|
+
}
|
|
41
|
+
this.fs.writeJSON(this.destinationPath('./package.json'), this.pjson);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.default = Hook;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as Generator from 'yeoman-generator';
|
|
2
|
+
export interface PackageJson {
|
|
3
|
+
name: string;
|
|
4
|
+
devDependencies: Record<string, string>;
|
|
5
|
+
dependencies: Record<string, string>;
|
|
6
|
+
oclif: {
|
|
7
|
+
bin: string;
|
|
8
|
+
dirname: string;
|
|
9
|
+
hooks: Record<string, string | string[]>;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export interface GeneratorOptions extends Generator.GeneratorOptions {
|
|
13
|
+
name: string;
|
|
14
|
+
defaults?: boolean;
|
|
15
|
+
force?: boolean;
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oclif",
|
|
3
3
|
"description": "oclif: create your own CLI",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.8",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"bin": {
|
|
7
7
|
"oclif": "bin/run"
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
"bugs": "https://github.com/oclif/oclif/issues",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"@oclif/core": "^1.0.11",
|
|
12
|
-
"@oclif/fixpack": "^2.3.1",
|
|
13
12
|
"@oclif/plugin-help": "^5.1.10",
|
|
14
13
|
"@oclif/plugin-not-found": "^2.2.3",
|
|
15
14
|
"@oclif/plugin-warn-if-update-available": "^2.0.3",
|
|
@@ -22,10 +21,8 @@
|
|
|
22
21
|
"lodash": "^4.17.11",
|
|
23
22
|
"normalize-package-data": "^3.0.3",
|
|
24
23
|
"nps-utils": "^1.7.0",
|
|
25
|
-
"oclif": "^2.1.1",
|
|
26
24
|
"qqjs": "^0.3.10",
|
|
27
25
|
"semver": "^7.3.5",
|
|
28
|
-
"sort-pjson": "^1.0.3",
|
|
29
26
|
"tslib": "^2.3.1",
|
|
30
27
|
"yeoman-environment": "^2.3.4",
|
|
31
28
|
"yeoman-generator": "3",
|
|
@@ -96,6 +93,7 @@
|
|
|
96
93
|
],
|
|
97
94
|
"bin": "oclif",
|
|
98
95
|
"dirname": "oclif",
|
|
96
|
+
"topicSeparator": " ",
|
|
99
97
|
"macos": {
|
|
100
98
|
"identifier": "com.oclif.cli",
|
|
101
99
|
"sign": "Developer ID Installer: Heroku INC"
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {Command, Flags} from '@oclif/core'
|
|
2
|
+
<%_ const klass = _.upperFirst(_.camelCase(name)) _%>
|
|
3
|
+
|
|
4
|
+
export default class <%- klass %> extends Command {
|
|
5
|
+
static description = 'describe the command here'
|
|
6
|
+
|
|
7
|
+
static examples = [
|
|
8
|
+
'<%%= config.bin %> <%%= command.id %>',
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
static flags = {
|
|
12
|
+
// flag with a value (-n, --name=VALUE)
|
|
13
|
+
name: Flags.string({char: 'n', description: 'name to print'}),
|
|
14
|
+
// flag with no value (-f, --force)
|
|
15
|
+
force: Flags.boolean({char: 'f'}),
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
static args = [{name: 'file'}]
|
|
19
|
+
|
|
20
|
+
public async run(): Promise<void> {
|
|
21
|
+
const {args, flags} = await this.parse(<%- klass %>)
|
|
22
|
+
|
|
23
|
+
const name = flags.name ?? 'world'
|
|
24
|
+
this.log(`hello ${name} from <%- path.replace(/\\/g, '\\\\') %>`)
|
|
25
|
+
if (args.file && flags.force) {
|
|
26
|
+
this.log(`you input --force and --file: ${args.file}`)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {expect, test} from '@oclif/test'
|
|
2
|
+
|
|
3
|
+
describe('<%- name %>', () => {
|
|
4
|
+
test
|
|
5
|
+
.stdout()
|
|
6
|
+
.command(['<%- name %>'])
|
|
7
|
+
.it('runs hello', ctx => {
|
|
8
|
+
expect(ctx.stdout).to.contain('hello world')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
test
|
|
12
|
+
.stdout()
|
|
13
|
+
.command(['<%- name %>', '--name', 'jeff'])
|
|
14
|
+
.it('runs hello --name jeff', ctx => {
|
|
15
|
+
expect(ctx.stdout).to.contain('hello jeff')
|
|
16
|
+
})
|
|
17
|
+
})
|