@oclif/plugin-search 0.0.24 → 1.0.2

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/README.md CHANGED
@@ -1,5 +1,4 @@
1
- @oclif/plugin-search
2
- =================
1
+ # @oclif/plugin-search
3
2
 
4
3
  A `search` command for your oclif CLI
5
4
 
@@ -10,24 +9,29 @@ A `search` command for your oclif CLI
10
9
  [![License](https://img.shields.io/npm/l/oclif-plugin-search.svg)](https://github.com/oclif/plugin-search/blob/main/package.json)
11
10
 
12
11
  <!-- toc -->
12
+ * [@oclif/plugin-search](#oclifplugin-search)
13
13
  * [Usage](#usage)
14
14
  * [Commands](#commands)
15
15
  <!-- tocstop -->
16
+
16
17
  # Usage
18
+
17
19
  <!-- usage -->
18
20
  ```sh-session
19
21
  $ npm install -g @oclif/plugin-search
20
22
  $ @oclif/plugin-search COMMAND
21
23
  running command...
22
24
  $ @oclif/plugin-search (--version)
23
- @oclif/plugin-search/0.0.24 linux-x64 node-v18.18.0
25
+ @oclif/plugin-search/1.0.2 linux-x64 node-v18.18.0
24
26
  $ @oclif/plugin-search --help [COMMAND]
25
27
  USAGE
26
28
  $ @oclif/plugin-search COMMAND
27
29
  ...
28
30
  ```
29
31
  <!-- usagestop -->
32
+
30
33
  # Commands
34
+
31
35
  <!-- commands -->
32
36
  * [`@oclif/plugin-search search`](#oclifplugin-search-search)
33
37
 
@@ -45,5 +49,5 @@ DESCRIPTION
45
49
  Once you select a command, hit enter and it will show the help for that command.
46
50
  ```
47
51
 
48
- _See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v0.0.24/src/commands/search.ts)_
52
+ _See code: [src/commands/search.ts](https://github.com/oclif/plugin-search/blob/v1.0.2/src/commands/search.ts)_
49
53
  <!-- commandsstop -->
package/bin/dev.js ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning
2
+ // eslint-disable-next-line node/shebang
3
+ async function main() {
4
+ const {execute} = await import('@oclif/core')
5
+ await execute({development: true, dir: import.meta.url})
6
+ }
7
+
8
+ await main()
package/bin/run.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ // eslint-disable-next-line node/shebang
4
+ async function main() {
5
+ const {execute} = await import('@oclif/core')
6
+ await execute({dir: import.meta.url})
7
+ }
8
+
9
+ await main()
@@ -1,6 +1,6 @@
1
1
  import { Command } from '@oclif/core';
2
2
  export default class Search extends Command {
3
- static summary: string;
4
3
  static description: string;
4
+ static summary: string;
5
5
  run(): Promise<unknown>;
6
6
  }
@@ -1,52 +1,34 @@
1
- "use strict";
2
1
  /*
3
2
  * Copyright (c) 2022, salesforce.com, inc.
4
3
  * All rights reserved.
5
4
  * Licensed under the BSD 3-Clause license.
6
5
  * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
7
6
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const inquirer_1 = require("inquirer");
10
- const core_1 = require("@oclif/core");
11
- const autocomplete_1 = require("../util/autocomplete");
12
- class Search extends core_1.Command {
7
+ import { Command, toConfiguredId, toStandardizedId } from '@oclif/core';
8
+ import autocomplete from 'inquirer-autocomplete-standalone';
9
+ export default class Search extends Command {
10
+ static description = 'Once you select a command, hit enter and it will show the help for that command.';
11
+ static summary = 'Search for a command.';
13
12
  async run() {
14
- const commands = this.config.commands.filter(c => !c.hidden);
15
- for (const command of commands) {
16
- command.readableId = (0, core_1.toConfiguredId)(command.id, this.config);
17
- }
18
- (0, inquirer_1.registerPrompt)('autocomplete-search', autocomplete_1.AutocompleteSearch);
19
- const { command } = await (0, inquirer_1.prompt)([
20
- {
21
- type: 'autocomplete-search',
22
- name: 'command',
23
- message: 'Search for a command',
24
- emptyText: 'Nothing found!',
25
- pageSize: 10,
26
- validate: (val) => {
27
- return val ? true : 'Type something!';
28
- },
29
- searchOpts: {
30
- keys: ['readableId'],
31
- shouldSort: true,
32
- threshold: 0.25,
33
- ignoreLocation: true,
34
- },
35
- displayKey: 'readableId',
36
- options: commands,
37
- footer: (currentChoices, index) => {
38
- const cmd = commands.find(c => c.readableId === currentChoices.getChoice(index).value);
39
- if (cmd && cmd.summary)
40
- return cmd.summary;
41
- },
13
+ const commandChoices = this.config.commands
14
+ .filter((c) => !c.hidden && !c.aliases.includes(c.id))
15
+ .sort((a, b) => a.id.localeCompare(b.id))
16
+ .map((c) => {
17
+ const name = toConfiguredId(c.id, this.config);
18
+ return {
19
+ description: c.summary,
20
+ name,
21
+ value: name,
22
+ };
23
+ });
24
+ const command = await autocomplete({
25
+ emptyText: 'Nothing found!',
26
+ message: 'Search for a command',
27
+ pageSize: 10,
28
+ async source(input) {
29
+ return input ? commandChoices.filter((c) => c.name.includes(input)) : commandChoices;
42
30
  },
43
- ]);
44
- if (command === 'help') {
45
- return this.config.runCommand((0, core_1.toStandardizedId)(command, this.config), []);
46
- }
47
- return this.config.runCommand('help', [(0, core_1.toStandardizedId)(command, this.config)]);
31
+ });
32
+ return this.config.runCommand('help', [toStandardizedId(command, this.config)]);
48
33
  }
49
34
  }
50
- exports.default = Search;
51
- Search.summary = 'Search for a command.';
52
- Search.description = 'Once you select a command, hit enter and it will show the help for that command.';
package/dist/index.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- var core_1 = require("@oclif/core");
5
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
1
+ export { run } from '@oclif/core';