ardent-cli-beta 0.0.2 → 0.0.3

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.
@@ -2,6 +2,7 @@ import { type Organization } from '../auth/token.js';
2
2
  import { ArdentCommand } from '../command.js';
3
3
  export default class Login extends ArdentCommand {
4
4
  static description: string;
5
+ static helpGroup: string;
5
6
  static flags: {
6
7
  token: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
7
8
  };
@@ -2,7 +2,8 @@ import { Flags } from '@oclif/core';
2
2
  import { loginWithToken } from '../auth/token.js';
3
3
  import { ArdentCommand } from '../command.js';
4
4
  export default class Login extends ArdentCommand {
5
- static description = 'Log in with an existing Ardent token';
5
+ static description = 'Log in to Ardent';
6
+ static helpGroup = 'Authentication';
6
7
  static flags = {
7
8
  token: Flags.string({ description: 'Existing Ardent API token', env: 'ARDENT_TOKEN', required: true }),
8
9
  };
@@ -1,6 +1,7 @@
1
1
  import { ArdentCommand } from '../command.js';
2
2
  export default class Logout extends ArdentCommand {
3
3
  static description: string;
4
+ static helpGroup: string;
4
5
  run(): Promise<{
5
6
  authenticated: false;
6
7
  }>;
@@ -1,7 +1,8 @@
1
1
  import { clearSession } from '../auth/credentials.js';
2
2
  import { ArdentCommand } from '../command.js';
3
3
  export default class Logout extends ArdentCommand {
4
- static description = 'Remove the locally stored Ardent token';
4
+ static description = 'Log out of Ardent on this device';
5
+ static helpGroup = 'Authentication';
5
6
  async run() {
6
7
  await clearSession(this.config.configDir);
7
8
  if (!this.jsonEnabled())
@@ -1,6 +1,7 @@
1
1
  import { ArdentCommand } from '../command.js';
2
2
  export default class Status extends ArdentCommand {
3
3
  static description: string;
4
+ static helpGroup: string;
4
5
  run(): Promise<{
5
6
  authenticated: boolean;
6
7
  }>;
@@ -1,7 +1,8 @@
1
1
  import { loadSession } from '../auth/credentials.js';
2
2
  import { ArdentCommand } from '../command.js';
3
3
  export default class Status extends ArdentCommand {
4
- static description = 'Show the local Ardent login status';
4
+ static description = 'Show your Ardent login status';
5
+ static helpGroup = 'Authentication';
5
6
  async run() {
6
7
  const session = await loadSession(this.config.configDir);
7
8
  const result = { authenticated: session !== undefined };
package/dist/help.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { Help } from '@oclif/core/help';
2
+ export default class ArdentHelp extends Help {
3
+ showHelp(arguments_: string[]): Promise<void>;
4
+ private authenticated;
5
+ private showArdentHelp;
6
+ }
package/dist/help.js ADDED
@@ -0,0 +1,52 @@
1
+ import { ux } from '@oclif/core';
2
+ import { getHelpFlagAdditions, Help } from '@oclif/core/help';
3
+ import { loadSession } from './auth/credentials.js';
4
+ export default class ArdentHelp extends Help {
5
+ async showHelp(arguments_) {
6
+ const rootHelp = arguments_.every((argument) => getHelpFlagAdditions(this.config).includes(argument));
7
+ if (!rootHelp)
8
+ return super.showHelp(arguments_);
9
+ const authenticated = await this.authenticated();
10
+ if (arguments_.length > 0 || authenticated) {
11
+ this.showArdentHelp(authenticated);
12
+ return;
13
+ }
14
+ this.log('Get started:');
15
+ this.log('');
16
+ this.log(ux.colorize('green', ' ardent login Standard CLI login'));
17
+ this.log(' ardent login --token <token> Non-interactive login (CI and automation)');
18
+ this.log('');
19
+ this.log('For all commands:');
20
+ this.log('');
21
+ this.log(' ardent --help');
22
+ }
23
+ async authenticated() {
24
+ try {
25
+ return (await loadSession(this.config.configDir)) !== undefined;
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ showArdentHelp(authenticated) {
32
+ this.log(`Ardent CLI ${ux.colorize('dim', `v${this.config.version}`)}`);
33
+ this.log('');
34
+ this.log(this.section('USAGE', '$ ardent <command>'));
35
+ const groups = new Map();
36
+ for (const command of this.sortedCommands) {
37
+ if (command.hidden || command.pluginName !== this.config.name || typeof command.helpGroup !== 'string')
38
+ continue;
39
+ const commands = groups.get(command.helpGroup) ?? [];
40
+ commands.push(command);
41
+ groups.set(command.helpGroup, commands);
42
+ }
43
+ for (const [group, commands] of groups) {
44
+ const rows = commands.map((command) => {
45
+ const name = `ardent ${command.id.replaceAll(':', ' ')}`;
46
+ return [!authenticated && command.id === 'login' ? ux.colorize('green', name) : name, this.summary(command)];
47
+ });
48
+ this.log('');
49
+ this.log(this.section(group.toUpperCase(), rows));
50
+ }
51
+ }
52
+ }
@@ -3,7 +3,7 @@
3
3
  "login": {
4
4
  "aliases": [],
5
5
  "args": {},
6
- "description": "Log in with an existing Ardent token",
6
+ "description": "Log in to Ardent",
7
7
  "flags": {
8
8
  "json": {
9
9
  "description": "Format output as json.",
@@ -30,6 +30,7 @@
30
30
  "pluginType": "core",
31
31
  "strict": true,
32
32
  "enableJsonFlag": true,
33
+ "helpGroup": "Authentication",
33
34
  "isESM": true,
34
35
  "relativePath": [
35
36
  "dist",
@@ -40,7 +41,7 @@
40
41
  "logout": {
41
42
  "aliases": [],
42
43
  "args": {},
43
- "description": "Remove the locally stored Ardent token",
44
+ "description": "Log out of Ardent on this device",
44
45
  "flags": {
45
46
  "json": {
46
47
  "description": "Format output as json.",
@@ -58,6 +59,7 @@
58
59
  "pluginType": "core",
59
60
  "strict": true,
60
61
  "enableJsonFlag": true,
62
+ "helpGroup": "Authentication",
61
63
  "isESM": true,
62
64
  "relativePath": [
63
65
  "dist",
@@ -68,7 +70,7 @@
68
70
  "status": {
69
71
  "aliases": [],
70
72
  "args": {},
71
- "description": "Show the local Ardent login status",
73
+ "description": "Show your Ardent login status",
72
74
  "flags": {
73
75
  "json": {
74
76
  "description": "Format output as json.",
@@ -86,6 +88,7 @@
86
88
  "pluginType": "core",
87
89
  "strict": true,
88
90
  "enableJsonFlag": true,
91
+ "helpGroup": "Authentication",
89
92
  "isESM": true,
90
93
  "relativePath": [
91
94
  "dist",
@@ -94,5 +97,5 @@
94
97
  ]
95
98
  }
96
99
  },
97
- "version": "0.0.2"
100
+ "version": "0.0.3"
98
101
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ardent-cli-beta",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "The Ardent command-line interface",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -25,9 +25,9 @@
25
25
  "bin": "ardent",
26
26
  "dirname": "ardent",
27
27
  "commands": "./dist/commands",
28
+ "helpClass": "./dist/help",
28
29
  "plugins": [
29
- "@oclif/plugin-autocomplete",
30
- "@oclif/plugin-help"
30
+ "@oclif/plugin-autocomplete"
31
31
  ],
32
32
  "topicSeparator": " "
33
33
  },
@@ -41,8 +41,7 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@oclif/core": "^5.0.0",
44
- "@oclif/plugin-autocomplete": "^4.0.0",
45
- "@oclif/plugin-help": "^7.0.0"
44
+ "@oclif/plugin-autocomplete": "^4.0.0"
46
45
  },
47
46
  "devDependencies": {
48
47
  "@types/node": "^22.0.0",