Skip to content

Commit a1890b4

Browse files
committed
feat(enterprise): add shortcut for registering
1 parent 0f70de7 commit a1890b4

File tree

3 files changed

+80
-0
lines changed

3 files changed

+80
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { NamespaceGroup } from '@ionic/cli-framework';
2+
3+
import { CommandMap, Namespace } from '../../lib/namespace';
4+
5+
export class EnterpriseNamespace extends Namespace {
6+
async getMetadata() {
7+
return {
8+
name: 'enterprise',
9+
summary: 'Manage Ionic Enterprise features',
10+
description: `
11+
Commands to help manage Ionic Enterprise[^enterprise-edition] subscriptions.
12+
`,
13+
footnotes: [
14+
{
15+
id: 'enterprise-edition',
16+
url: 'https://ionicframework.com/enterprise-edition',
17+
shortUrl: 'https://ion.link/enterprise',
18+
},
19+
],
20+
groups: [NamespaceGroup.Paid],
21+
};
22+
}
23+
24+
async getCommands(): Promise<CommandMap> {
25+
return new CommandMap([
26+
['register', async () => { const { RegisterCommand } = await import('./register'); return new RegisterCommand(this); }],
27+
]);
28+
}
29+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import chalk from 'chalk';
2+
3+
import { CommandInstanceInfo, CommandLineInputs, CommandLineOptions, CommandMetadata } from '../../definitions';
4+
import { Command } from '../../lib/command';
5+
import { FatalException } from '../../lib/errors';
6+
import { runCommand } from '../../lib/executor';
7+
8+
export class RegisterCommand extends Command {
9+
async getMetadata(): Promise<CommandMetadata> {
10+
return {
11+
name: 'register',
12+
type: 'project',
13+
summary: 'Register your Product Key with this app',
14+
options: [
15+
{
16+
name: 'app-id',
17+
summary: 'The Ionic App ID',
18+
spec: {
19+
value: 'id',
20+
},
21+
},
22+
{
23+
name: 'key',
24+
summary: 'The Product Key',
25+
},
26+
],
27+
};
28+
}
29+
30+
async run(inputs: CommandLineInputs, options: CommandLineOptions, runinfo: CommandInstanceInfo): Promise<void> {
31+
if (!this.project) {
32+
throw new FatalException(`Cannot run ${chalk.green('ionic enterprise register')} outside a project directory.`);
33+
}
34+
35+
const appId = options['app-id'] ? String(options['app-id']) : undefined;
36+
const key = options['key'] ? String(options['key']) : undefined;
37+
38+
const extra = ['--'];
39+
40+
if (key) {
41+
extra.push('--key', key);
42+
}
43+
44+
if (appId) {
45+
extra.push('--app-id', appId);
46+
}
47+
48+
await runCommand(runinfo, ['integrations', 'enable', 'enterprise', ...extra.length > 1 ? extra : [] ]);
49+
}
50+
}

packages/ionic/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export class IonicNamespace extends Namespace {
5252
['monitoring', async () => { const { MonitoringNamespace } = await import('./monitoring/index'); return new MonitoringNamespace(this); }],
5353
['doctor', async () => { const { DoctorNamespace } = await import('./doctor/index'); return new DoctorNamespace(this); }],
5454
['integrations', async () => { const { IntegrationsNamespace } = await import('./integrations/index'); return new IntegrationsNamespace(this); }],
55+
['enterprise', async () => { const { EnterpriseNamespace } = await import('./enterprise/index'); return new EnterpriseNamespace(this); }],
5556
['cap', 'capacitor'],
5657
['i', 'integrations'],
5758
]);

0 commit comments

Comments
 (0)