@affinidi/cli 2.1.0 → 2.2.0
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 +6 -4
- package/dist/commands/generate/app.d.ts +5 -3
- package/dist/commands/generate/app.js +123 -83
- package/dist/commands/generate/app.js.map +1 -1
- package/dist/helpers/app.d.ts +14 -6
- package/dist/helpers/app.js +22 -10
- package/dist/helpers/app.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -421,11 +421,13 @@ Generates a reference application that integrates Affinidi Login. Requires git
|
|
|
421
421
|
|
|
422
422
|
```
|
|
423
423
|
USAGE
|
|
424
|
-
$ affinidi generate app [--json] [--no-color] [--no-input] [-
|
|
424
|
+
$ affinidi generate app [--json] [--no-color] [--no-input] [-a <value>] [-f <value>] [-l <value>] [-p <value>]
|
|
425
|
+
[--force]
|
|
425
426
|
|
|
426
427
|
FLAGS
|
|
427
428
|
-a, --provider=<value> Authentication provider for the reference app
|
|
428
429
|
-f, --framework=<value> Framework for the reference app
|
|
430
|
+
-l, --library=<value> Library for the reference app
|
|
429
431
|
-p, --path=<value> Relative or absolute path where reference application should be cloned into
|
|
430
432
|
--force Override destination directory if exists
|
|
431
433
|
|
|
@@ -1128,7 +1130,7 @@ EXAMPLES
|
|
|
1128
1130
|
$ affinidi start
|
|
1129
1131
|
```
|
|
1130
1132
|
|
|
1131
|
-
_See code: [dist/commands/start.ts](https://github.com/affinidi/affinidi-cli/blob/v2.
|
|
1133
|
+
_See code: [dist/commands/start.ts](https://github.com/affinidi/affinidi-cli/blob/v2.1.0/dist/commands/start.ts)_
|
|
1132
1134
|
|
|
1133
1135
|
## `affinidi stop`
|
|
1134
1136
|
|
|
@@ -1147,7 +1149,7 @@ EXAMPLES
|
|
|
1147
1149
|
$ affinidi stop
|
|
1148
1150
|
```
|
|
1149
1151
|
|
|
1150
|
-
_See code: [dist/commands/stop.ts](https://github.com/affinidi/affinidi-cli/blob/v2.
|
|
1152
|
+
_See code: [dist/commands/stop.ts](https://github.com/affinidi/affinidi-cli/blob/v2.1.0/dist/commands/stop.ts)_
|
|
1151
1153
|
|
|
1152
1154
|
## `affinidi token create-token`
|
|
1153
1155
|
|
|
@@ -1282,5 +1284,5 @@ EXAMPLES
|
|
|
1282
1284
|
$ affinidi whoami
|
|
1283
1285
|
```
|
|
1284
1286
|
|
|
1285
|
-
_See code: [dist/commands/whoami.ts](https://github.com/affinidi/affinidi-cli/blob/v2.
|
|
1287
|
+
_See code: [dist/commands/whoami.ts](https://github.com/affinidi/affinidi-cli/blob/v2.1.0/dist/commands/whoami.ts)_
|
|
1286
1288
|
<!-- commandsstop -->
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { BaseCommand } from '../../common';
|
|
2
|
+
import { AppsInformation } from '../../helpers/app';
|
|
2
3
|
export default class GenerateApp extends BaseCommand<typeof GenerateApp> {
|
|
3
|
-
static apps:
|
|
4
|
+
static apps: AppsInformation;
|
|
4
5
|
static providers: string[];
|
|
5
|
-
static frameworks: string[]
|
|
6
|
+
static frameworks: Map<string, string[]>;
|
|
6
7
|
static libraries: Map<string, string[]>;
|
|
7
8
|
static summary: string;
|
|
8
9
|
static examples: string[];
|
|
9
10
|
static flags: {
|
|
10
|
-
framework: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
11
11
|
provider: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
|
+
framework: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
|
+
library: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
12
14
|
path: import("@oclif/core/lib/interfaces/parser").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
|
|
13
15
|
force: import("@oclif/core/lib/interfaces/parser").BooleanFlag<boolean>;
|
|
14
16
|
};
|
|
@@ -24,11 +24,6 @@ class GenerateApp extends common_1.BaseCommand {
|
|
|
24
24
|
GenerateApp.providers = providers;
|
|
25
25
|
GenerateApp.frameworks = frameworks;
|
|
26
26
|
GenerateApp.libraries = libraries;
|
|
27
|
-
GenerateApp.flags.framework = core_1.Flags.string({
|
|
28
|
-
char: 'f',
|
|
29
|
-
summary: 'Framework for the reference app',
|
|
30
|
-
options: frameworks,
|
|
31
|
-
});
|
|
32
27
|
GenerateApp.flags.provider = core_1.Flags.string({
|
|
33
28
|
char: 'a',
|
|
34
29
|
summary: 'Authentication provider for the reference app',
|
|
@@ -36,91 +31,132 @@ class GenerateApp extends common_1.BaseCommand {
|
|
|
36
31
|
});
|
|
37
32
|
}
|
|
38
33
|
async run() {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const framework = flags.framework ??
|
|
55
|
-
(await (0, prompts_1.select)({
|
|
56
|
-
message: 'Select the framework for the reference app.',
|
|
57
|
-
choices: GenerateApp.frameworks.map((value) => ({
|
|
58
|
-
name: value,
|
|
59
|
-
value,
|
|
60
|
-
})),
|
|
61
|
-
}));
|
|
62
|
-
const promptFlags = await (0, prompts_2.promptRequiredParameters)(['path'], flags);
|
|
63
|
-
promptFlags.framework = framework;
|
|
64
|
-
promptFlags.provider = provider;
|
|
65
|
-
const schema = zod_1.default.object({
|
|
66
|
-
path: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
67
|
-
framework: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
68
|
-
provider: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
69
|
-
});
|
|
70
|
-
const validatedFlags = schema.parse(promptFlags);
|
|
71
|
-
const appName = (0, app_1.getAppName)(framework, provider, GenerateApp.libraries);
|
|
72
|
-
core_1.ux.action.start('Generating reference application');
|
|
73
|
-
await (0, degit_1.cloneWithDegit)(`${APPS_GITHUB_LOCATION}/${appName}`, validatedFlags.path, flags.force);
|
|
74
|
-
core_1.ux.action.stop('Generated successfully!');
|
|
75
|
-
if (!flags['no-input']) {
|
|
76
|
-
const configure = await (0, prompts_1.confirm)({
|
|
77
|
-
message: 'Automatically configure reference app environment?',
|
|
78
|
-
});
|
|
79
|
-
if (configure) {
|
|
80
|
-
core_1.ux.action.start('Fetching available login configurations');
|
|
81
|
-
const configs = await vp_adapter_1.vpAdapterService.listLoginConfigurations();
|
|
82
|
-
core_1.ux.action.stop('Fetched successfully!');
|
|
83
|
-
const choices = configs.configurations.map((config) => ({
|
|
84
|
-
value: {
|
|
85
|
-
id: config.configurationId,
|
|
86
|
-
auth: config.auth,
|
|
87
|
-
},
|
|
88
|
-
name: `${config.name} [id: ${config.configurationId}]`,
|
|
34
|
+
try {
|
|
35
|
+
const { flags } = await this.parse(GenerateApp);
|
|
36
|
+
if (flags['no-input']) {
|
|
37
|
+
if (!flags.provider)
|
|
38
|
+
throw new errors_1.CLIError((0, error_messages_1.giveFlagInputErrorMessage)('provider'));
|
|
39
|
+
if (!flags.framework)
|
|
40
|
+
throw new errors_1.CLIError((0, error_messages_1.giveFlagInputErrorMessage)('framework'));
|
|
41
|
+
}
|
|
42
|
+
const provider = flags.provider ??
|
|
43
|
+
(await (0, prompts_1.select)({
|
|
44
|
+
message: 'Select the provider for the reference app.',
|
|
45
|
+
choices: GenerateApp.providers.map((value) => ({
|
|
46
|
+
name: value,
|
|
47
|
+
value,
|
|
48
|
+
})),
|
|
89
49
|
}));
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
50
|
+
const framework = flags.framework ??
|
|
51
|
+
(await (0, prompts_1.select)({
|
|
52
|
+
message: 'Select the framework for the reference app.',
|
|
53
|
+
choices: GenerateApp.frameworks.get(provider).map((value) => ({
|
|
54
|
+
name: value,
|
|
55
|
+
value,
|
|
56
|
+
})),
|
|
57
|
+
}));
|
|
58
|
+
const library = flags.library ??
|
|
59
|
+
(await (0, prompts_1.select)({
|
|
60
|
+
message: 'Select the library for the reference app.',
|
|
61
|
+
choices: GenerateApp.libraries.get(`${provider}-${framework}`).map((value) => ({
|
|
62
|
+
name: value,
|
|
63
|
+
value,
|
|
64
|
+
})),
|
|
65
|
+
}));
|
|
66
|
+
const promptFlags = await (0, prompts_2.promptRequiredParameters)(['path'], flags);
|
|
67
|
+
promptFlags.framework = framework;
|
|
68
|
+
promptFlags.provider = provider;
|
|
69
|
+
promptFlags.library = library;
|
|
70
|
+
const schema = zod_1.default.object({
|
|
71
|
+
path: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
72
|
+
framework: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
73
|
+
provider: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
74
|
+
library: zod_1.default.string().max(validators_1.INPUT_LIMIT),
|
|
75
|
+
});
|
|
76
|
+
const validatedFlags = schema.parse(promptFlags);
|
|
77
|
+
const appName = (0, app_1.getAppName)(framework, provider, library);
|
|
78
|
+
core_1.ux.action.start('Generating reference application');
|
|
79
|
+
await (0, degit_1.cloneWithDegit)(`${APPS_GITHUB_LOCATION}/${appName}`, validatedFlags.path, flags.force);
|
|
80
|
+
core_1.ux.action.stop('Generated successfully!');
|
|
81
|
+
if (!flags['no-input']) {
|
|
82
|
+
const configure = await (0, prompts_1.confirm)({
|
|
83
|
+
message: 'Automatically configure reference app environment?',
|
|
93
84
|
});
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
webOriginUrl: GenerateApp.apps.appName.redirectUris.webOriginUrl,
|
|
85
|
+
if (configure) {
|
|
86
|
+
core_1.ux.action.start('Fetching available login configurations');
|
|
87
|
+
const configs = await vp_adapter_1.vpAdapterService.listLoginConfigurations();
|
|
88
|
+
core_1.ux.action.stop('Fetched successfully!');
|
|
89
|
+
const choices = configs.configurations.map((config) => ({
|
|
90
|
+
value: {
|
|
91
|
+
id: config.configurationId,
|
|
92
|
+
auth: config.auth,
|
|
93
|
+
},
|
|
94
|
+
name: `${config.name} [id: ${config.configurationId}]`,
|
|
95
|
+
}));
|
|
96
|
+
choices.push({
|
|
97
|
+
value: {
|
|
98
|
+
id: 'new-config',
|
|
99
|
+
auth: undefined,
|
|
100
|
+
},
|
|
101
|
+
name: 'Create new login config',
|
|
112
102
|
});
|
|
113
|
-
await (0,
|
|
114
|
-
|
|
103
|
+
const selectedConfig = await (0, prompts_1.select)({
|
|
104
|
+
message: 'Select a login configuration to use in your reference application',
|
|
105
|
+
choices,
|
|
106
|
+
});
|
|
107
|
+
let newConfigClientSecret = undefined;
|
|
108
|
+
// Create a new login config
|
|
109
|
+
if (selectedConfig.id === 'new-config') {
|
|
110
|
+
const newConfigName = (0, validators_1.validateInputLength)(await (0, prompts_1.input)({ message: `Enter a name for the login config` }), validators_1.INPUT_LIMIT);
|
|
111
|
+
const redirectUri = (0, app_1.getRedirectUri)(GenerateApp.apps, appName);
|
|
112
|
+
const createLoginConfigInput = {
|
|
113
|
+
name: newConfigName,
|
|
114
|
+
redirectUris: [redirectUri],
|
|
115
|
+
};
|
|
116
|
+
const createConfigOutput = await vp_adapter_1.vpAdapterService.createLoginConfig(createLoginConfigInput);
|
|
117
|
+
this.warn(this.chalk.red.bold('Please save the clientSecret somewhere safe. You will not be able to view it again.'));
|
|
118
|
+
this.logJson({ loginConfig: createConfigOutput.auth });
|
|
119
|
+
selectedConfig.id = createConfigOutput.configurationId;
|
|
120
|
+
selectedConfig.auth = createConfigOutput.auth;
|
|
121
|
+
newConfigClientSecret = createConfigOutput.auth.clientSecret;
|
|
122
|
+
}
|
|
123
|
+
const clientSecret = newConfigClientSecret ??
|
|
124
|
+
(0, validators_1.validateInputLength)(await (0, password_1.default)({
|
|
125
|
+
message: "What is the login configuration's client secret?",
|
|
126
|
+
mask: true,
|
|
127
|
+
}), validators_1.INPUT_LIMIT);
|
|
128
|
+
if (provider === common_1.RefAppProvider.AFFINIDI) {
|
|
129
|
+
core_1.ux.action.start('Configuring reference application');
|
|
130
|
+
await (0, env_configurer_1.configureAppEnvironment)(validatedFlags.path, selectedConfig.auth.clientId, clientSecret, selectedConfig.auth.issuer);
|
|
131
|
+
core_1.ux.action.stop('Configured successfully!');
|
|
132
|
+
}
|
|
133
|
+
else if (provider === common_1.RefAppProvider.AUTH0) {
|
|
134
|
+
const domain = (0, validators_1.validateInputLength)(await (0, prompts_1.input)({ message: 'What is your Auth0 tenant URL?' }), validators_1.INPUT_LIMIT);
|
|
135
|
+
const accessToken = (0, validators_1.validateInputLength)(await (0, password_1.default)({ message: 'What is your Auth0 access token?' }), validators_1.TOKEN_LIMIT);
|
|
136
|
+
core_1.ux.action.start('Creating Auth0 resources and configuring reference application');
|
|
137
|
+
const socialConnectionName = `Affinidi-${framework}`;
|
|
138
|
+
const { auth0ClientId, auth0ClientSecret, connectionName } = await (0, auth0_1.createAuth0Resources)(accessToken, domain, selectedConfig.auth.clientId, clientSecret, selectedConfig.auth.issuer, socialConnectionName, {
|
|
139
|
+
callbackUrl: GenerateApp.apps.appName.redirectUris.callbackUrl,
|
|
140
|
+
logOutUrl: GenerateApp.apps.appName.redirectUris.logOutUrl,
|
|
141
|
+
webOriginUrl: GenerateApp.apps.appName.redirectUris.webOriginUrl,
|
|
142
|
+
});
|
|
143
|
+
await (0, env_configurer_1.configureAppEnvironment)(validatedFlags.path, auth0ClientId, auth0ClientSecret, domain, connectionName);
|
|
144
|
+
core_1.ux.action.stop('Configured successfully!');
|
|
145
|
+
}
|
|
115
146
|
}
|
|
116
147
|
}
|
|
148
|
+
this.log('Please read the generated README for instructions on how to run your reference application');
|
|
149
|
+
}
|
|
150
|
+
catch (err) {
|
|
151
|
+
if (!err?.oclif)
|
|
152
|
+
throw new errors_1.CLIError('Unexpected error while generating reference app');
|
|
153
|
+
else
|
|
154
|
+
throw new errors_1.CLIError(err);
|
|
117
155
|
}
|
|
118
|
-
this.log('Please read the generated README for instructions on how to run your reference application');
|
|
119
156
|
}
|
|
120
157
|
}
|
|
121
158
|
exports.default = GenerateApp;
|
|
122
159
|
GenerateApp.providers = [];
|
|
123
|
-
GenerateApp.frameworks = [];
|
|
124
160
|
GenerateApp.summary = 'Generates a reference application that integrates Affinidi Login. Requires git';
|
|
125
161
|
GenerateApp.examples = [
|
|
126
162
|
'<%= config.bin %> <%= command.id %>',
|
|
@@ -128,13 +164,17 @@ GenerateApp.examples = [
|
|
|
128
164
|
'<%= config.bin %> <%= command.id %> --path "../my-app" --framework django --provider affinidi --force',
|
|
129
165
|
];
|
|
130
166
|
GenerateApp.flags = {
|
|
167
|
+
provider: core_1.Flags.string({
|
|
168
|
+
char: 'a',
|
|
169
|
+
summary: 'Authentication provider for the reference app',
|
|
170
|
+
}),
|
|
131
171
|
framework: core_1.Flags.string({
|
|
132
172
|
char: 'f',
|
|
133
173
|
summary: 'Framework for the reference app',
|
|
134
174
|
}),
|
|
135
|
-
|
|
136
|
-
char: '
|
|
137
|
-
summary: '
|
|
175
|
+
library: core_1.Flags.string({
|
|
176
|
+
char: 'l',
|
|
177
|
+
summary: 'Library for the reference app',
|
|
138
178
|
}),
|
|
139
179
|
path: core_1.Flags.string({
|
|
140
180
|
char: 'p',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/commands/generate/app.ts"],"names":[],"mappings":";;;AAAA,0EAAyC;AACzC,+CAA0D;AAC1D,sCAAuC;AACvC,mDAAiD;AACjD,sDAAmB;AACnB,yCAA0D;AAC1D,gEAAuE;AACvE,k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AAE,+BAA+B;KACzC,CAAC;IACF,IAAI,EAAE,YAAK,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,GAAG;QACT,OAAO,EAAE,6EAA6E;KACvF,CAAC;IACF,KAAK,EAAE,YAAK,CAAC,OAAO,CAAC;QACnB,OAAO,EAAE,0CAA0C;KACpD,CAAC;CACH,CAAA"}
|
package/dist/helpers/app.d.ts
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export type AppsInformation = {
|
|
2
|
+
[key: string]: {
|
|
3
|
+
[innerKey: string]: {
|
|
4
|
+
[innermostKey: string]: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare function getAppName(framework: string, provider: string, library: string): string;
|
|
9
|
+
export declare function getApps(filePath: string): Promise<AppsInformation>;
|
|
10
|
+
export declare function getSupportedSampleApps(appsInformation: AppsInformation): string[];
|
|
4
11
|
export declare function getSupportedProviders(sampleApps: string[]): string[];
|
|
5
|
-
export declare function getSupportedFrameworks(sampleApps: string[]): string[]
|
|
12
|
+
export declare function getSupportedFrameworks(sampleApps: string[]): Map<string, string[]>;
|
|
6
13
|
export declare function getSupportedLibraries(sampleApps: string[]): Map<string, string[]>;
|
|
7
|
-
export declare function getSupportedAppsInformation(apps:
|
|
14
|
+
export declare function getSupportedAppsInformation(apps: AppsInformation): {
|
|
8
15
|
providers: string[];
|
|
9
|
-
frameworks: string[]
|
|
16
|
+
frameworks: Map<string, string[]>;
|
|
10
17
|
libraries: Map<string, string[]>;
|
|
11
18
|
};
|
|
19
|
+
export declare function getRedirectUri(apps: AppsInformation, appName: string): string;
|
package/dist/helpers/app.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSupportedAppsInformation = exports.getSupportedLibraries = exports.getSupportedFrameworks = exports.getSupportedProviders = exports.getSupportedSampleApps = exports.getApps = exports.getAppName = void 0;
|
|
3
|
+
exports.getRedirectUri = exports.getSupportedAppsInformation = exports.getSupportedLibraries = exports.getSupportedFrameworks = exports.getSupportedProviders = exports.getSupportedSampleApps = exports.getApps = exports.getAppName = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const errors_1 = require("@oclif/core/lib/errors");
|
|
6
6
|
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
-
function getAppName(framework, provider,
|
|
8
|
-
return `${provider}-${framework}-${
|
|
7
|
+
function getAppName(framework, provider, library) {
|
|
8
|
+
return `${provider}-${framework}-${library}`;
|
|
9
9
|
}
|
|
10
10
|
exports.getAppName = getAppName;
|
|
11
11
|
async function getApps(filePath) {
|
|
@@ -46,11 +46,17 @@ function getSupportedProviders(sampleApps) {
|
|
|
46
46
|
exports.getSupportedProviders = getSupportedProviders;
|
|
47
47
|
function getSupportedFrameworks(sampleApps) {
|
|
48
48
|
try {
|
|
49
|
-
const frameworks =
|
|
49
|
+
const frameworks = new Map();
|
|
50
50
|
for (const sampleApp of sampleApps) {
|
|
51
51
|
const nameSplit = sampleApp.split('-');
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
const provider = nameSplit[0];
|
|
53
|
+
const frameworkNames = frameworks.get(provider);
|
|
54
|
+
if (!frameworkNames) {
|
|
55
|
+
frameworks.set(provider, [nameSplit[1]]);
|
|
56
|
+
}
|
|
57
|
+
else if (!frameworkNames.includes(nameSplit[1])) {
|
|
58
|
+
frameworkNames.push(nameSplit[1]);
|
|
59
|
+
frameworks.set(provider, frameworkNames);
|
|
54
60
|
}
|
|
55
61
|
}
|
|
56
62
|
return frameworks;
|
|
@@ -62,19 +68,21 @@ function getSupportedFrameworks(sampleApps) {
|
|
|
62
68
|
exports.getSupportedFrameworks = getSupportedFrameworks;
|
|
63
69
|
function getSupportedLibraries(sampleApps) {
|
|
64
70
|
try {
|
|
65
|
-
const
|
|
71
|
+
const libraries = new Map();
|
|
66
72
|
for (const sampleApp of sampleApps) {
|
|
67
73
|
const nameSplit = sampleApp.split('-');
|
|
74
|
+
const provider = nameSplit[0];
|
|
68
75
|
const framework = nameSplit[1];
|
|
69
|
-
const libNames =
|
|
76
|
+
const libNames = libraries.get(`${provider}-${framework}`);
|
|
70
77
|
if (!libNames) {
|
|
71
|
-
|
|
78
|
+
libraries.set(`${provider}-${framework}`, [nameSplit[2]]);
|
|
72
79
|
}
|
|
73
80
|
else if (!libNames.includes(nameSplit[2])) {
|
|
74
81
|
libNames.push(nameSplit[2]);
|
|
82
|
+
libraries.set(`${provider}-${framework}`, libNames);
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
|
-
return
|
|
85
|
+
return libraries;
|
|
78
86
|
}
|
|
79
87
|
catch (err) {
|
|
80
88
|
throw new errors_1.CLIError('Unable to fetch supported libraries');
|
|
@@ -89,4 +97,8 @@ function getSupportedAppsInformation(apps) {
|
|
|
89
97
|
return { providers, frameworks, libraries };
|
|
90
98
|
}
|
|
91
99
|
exports.getSupportedAppsInformation = getSupportedAppsInformation;
|
|
100
|
+
function getRedirectUri(apps, appName) {
|
|
101
|
+
return apps[appName].redirectUris.callbackUrl;
|
|
102
|
+
}
|
|
103
|
+
exports.getRedirectUri = getRedirectUri;
|
|
92
104
|
//# sourceMappingURL=app.js.map
|
package/dist/helpers/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/helpers/app.ts"],"names":[],"mappings":";;;;AAAA,mDAAiD;AACjD,0DAAyB;
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/helpers/app.ts"],"names":[],"mappings":";;;;AAAA,mDAAiD;AACjD,0DAAyB;AAUzB,SAAgB,UAAU,CAAC,SAAiB,EAAE,QAAgB,EAAE,OAAe;IAC7E,OAAO,GAAG,QAAQ,IAAI,SAAS,IAAI,OAAO,EAAE,CAAA;AAC9C,CAAC;AAFD,gCAEC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