@unito/integration-cli 0.55.1
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/LICENSE +3 -0
- package/README.md +32 -0
- package/bin/run +11 -0
- package/bin/run.cmd +3 -0
- package/dist/.eslintrc.d.ts +10 -0
- package/dist/.eslintrc.js +20 -0
- package/dist/integrationGenerator/errors.d.ts +2 -0
- package/dist/integrationGenerator/errors.js +6 -0
- package/dist/integrationGenerator/index.d.ts +2 -0
- package/dist/integrationGenerator/index.js +5 -0
- package/dist/integrationGenerator/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.dockerignore +3 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.eslintrc.js +74 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.nvmrc +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierignore +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.prettierrc +7 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/.unito.json +1 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/Dockerfile +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/README.md +21 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/index.ts +94 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/logger.ts +55 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/additionalLoggingContext.ts +22 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/correlationId.ts +13 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/package.json +43 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/index.ts +90 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/logger.ts +37 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/correlationId.ts +18 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/middlewares/credentials.ts +38 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/request.ts +59 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/index.ts +11 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/me.ts +15 -0
- package/dist/integrationGenerator/integrationBoilerplate/src/routes/root.ts +12 -0
- package/dist/integrationGenerator/integrationBoilerplate/tsconfig.json +37 -0
- package/dist/integrationGenerator/src/index.d.ts +1 -0
- package/dist/integrationGenerator/src/index.js +5 -0
- package/dist/integrationGenerator/src/resources/index.d.ts +1 -0
- package/dist/integrationGenerator/src/resources/index.js +5 -0
- package/dist/integrationGenerator/src/resources/integration.d.ts +9 -0
- package/dist/integrationGenerator/src/resources/integration.js +60 -0
- package/dist/integrationGenerator/test/resources/integration.test.d.ts +1 -0
- package/dist/integrationGenerator/test/resources/integration.test.js +51 -0
- package/dist/schemas/authorization.json +204 -0
- package/dist/schemas/automation.json +81 -0
- package/dist/schemas/configuration.json +89 -0
- package/dist/scripts/generateTypes.d.ts +8 -0
- package/dist/scripts/generateTypes.js +44 -0
- package/dist/src/baseCommand.d.ts +14 -0
- package/dist/src/baseCommand.js +39 -0
- package/dist/src/commands/activity.d.ts +12 -0
- package/dist/src/commands/activity.js +75 -0
- package/dist/src/commands/dev.d.ts +15 -0
- package/dist/src/commands/dev.js +123 -0
- package/dist/src/commands/encrypt.d.ts +11 -0
- package/dist/src/commands/encrypt.js +50 -0
- package/dist/src/commands/init.d.ts +10 -0
- package/dist/src/commands/init.js +51 -0
- package/dist/src/commands/invite.d.ts +11 -0
- package/dist/src/commands/invite.js +71 -0
- package/dist/src/commands/login.d.ts +11 -0
- package/dist/src/commands/login.js +76 -0
- package/dist/src/commands/oauth2.d.ts +10 -0
- package/dist/src/commands/oauth2.js +99 -0
- package/dist/src/commands/publish.d.ts +28 -0
- package/dist/src/commands/publish.js +302 -0
- package/dist/src/commands/test.d.ts +9 -0
- package/dist/src/commands/test.js +165 -0
- package/dist/src/commands/upgrade.d.ts +7 -0
- package/dist/src/commands/upgrade.js +88 -0
- package/dist/src/configurationTypes.d.ts +209 -0
- package/dist/src/configurationTypes.js +49 -0
- package/dist/src/errors.d.ts +38 -0
- package/dist/src/errors.js +159 -0
- package/dist/src/hooks/init/displayLogo.d.ts +3 -0
- package/dist/src/hooks/init/displayLogo.js +37 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/oauth2Helper/oauth2Helper.d.ts +63 -0
- package/dist/src/oauth2Helper/oauth2Helper.js +235 -0
- package/dist/src/oauth2Helper/types.d.ts +22 -0
- package/dist/src/oauth2Helper/types.js +2 -0
- package/dist/src/resources/configuration.d.ts +30 -0
- package/dist/src/resources/configuration.js +191 -0
- package/dist/src/resources/decryption.d.ts +5 -0
- package/dist/src/resources/decryption.js +62 -0
- package/dist/src/resources/fileSystem.d.ts +2 -0
- package/dist/src/resources/fileSystem.js +22 -0
- package/dist/src/resources/globalConfiguration.d.ts +13 -0
- package/dist/src/resources/globalConfiguration.js +44 -0
- package/dist/src/resources/integrations.d.ts +2 -0
- package/dist/src/resources/integrations.js +17 -0
- package/dist/src/resources/integrationsPlatform.d.ts +2 -0
- package/dist/src/resources/integrationsPlatform.js +33 -0
- package/dist/src/services/integrationsPlatform.d.ts +36 -0
- package/dist/src/services/integrationsPlatform.js +162 -0
- package/dist/src/services/oauth2Helper.d.ts +3 -0
- package/dist/src/services/oauth2Helper.js +34 -0
- package/dist/test/commands/activity.test.d.ts +1 -0
- package/dist/test/commands/activity.test.js +62 -0
- package/dist/test/commands/dev.test.d.ts +1 -0
- package/dist/test/commands/dev.test.js +139 -0
- package/dist/test/commands/encrypt.test.d.ts +1 -0
- package/dist/test/commands/encrypt.test.js +73 -0
- package/dist/test/commands/init.test.d.ts +1 -0
- package/dist/test/commands/init.test.js +45 -0
- package/dist/test/commands/invite.test.d.ts +1 -0
- package/dist/test/commands/invite.test.js +56 -0
- package/dist/test/commands/login.test.d.ts +1 -0
- package/dist/test/commands/login.test.js +90 -0
- package/dist/test/commands/oauth2.test.d.ts +1 -0
- package/dist/test/commands/oauth2.test.js +104 -0
- package/dist/test/commands/publish.test.d.ts +1 -0
- package/dist/test/commands/publish.test.js +429 -0
- package/dist/test/commands/test.test.d.ts +1 -0
- package/dist/test/commands/test.test.js +171 -0
- package/dist/test/commands/upgrade.test.d.ts +1 -0
- package/dist/test/commands/upgrade.test.js +47 -0
- package/dist/test/errors.test.d.ts +1 -0
- package/dist/test/errors.test.js +96 -0
- package/dist/test/helpers/init.d.ts +1 -0
- package/dist/test/helpers/init.js +6 -0
- package/dist/test/mocha.hooks.d.ts +2 -0
- package/dist/test/mocha.hooks.js +37 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.d.ts +1 -0
- package/dist/test/oauth2Helper/oauth2Helper.test.js +150 -0
- package/dist/test/resources/configuration.test.d.ts +1 -0
- package/dist/test/resources/configuration.test.js +586 -0
- package/dist/test/resources/decryption.test.d.ts +1 -0
- package/dist/test/resources/decryption.test.js +68 -0
- package/dist/test/resources/globalConfiguration.test.d.ts +1 -0
- package/dist/test/resources/globalConfiguration.test.js +32 -0
- package/dist/test/services/integrationsPlatform.test.d.ts +1 -0
- package/dist/test/services/integrationsPlatform.test.js +168 -0
- package/dist/test/services/oauth2Helper.test.d.ts +1 -0
- package/dist/test/services/oauth2Helper.test.js +85 -0
- package/oclif.manifest.json +423 -0
- package/package.json +98 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAuthenticated = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const IntegrationsPlatformClient = tslib_1.__importStar(require("../services/integrationsPlatform"));
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
const GlobalConfiguration = tslib_1.__importStar(require("./globalConfiguration"));
|
|
8
|
+
async function validateAuthenticated(globalConfiguration, environment) {
|
|
9
|
+
let apiKey = undefined;
|
|
10
|
+
if (environment === GlobalConfiguration.Environment.Local) {
|
|
11
|
+
apiKey = globalConfiguration.apiKeyLocal;
|
|
12
|
+
}
|
|
13
|
+
else if (environment === GlobalConfiguration.Environment.Staging) {
|
|
14
|
+
apiKey = globalConfiguration.apiKeyStaging;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
apiKey = globalConfiguration.apiKey;
|
|
18
|
+
}
|
|
19
|
+
// The API key to talk to the platform is missing. Out!
|
|
20
|
+
if (!apiKey) {
|
|
21
|
+
throw new errors_1.MissingApiKey();
|
|
22
|
+
}
|
|
23
|
+
// Setup the platform client.
|
|
24
|
+
IntegrationsPlatformClient.setEnvironment(environment);
|
|
25
|
+
IntegrationsPlatformClient.setApiKey(apiKey);
|
|
26
|
+
try {
|
|
27
|
+
await IntegrationsPlatformClient.getProfile();
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
throw new errors_1.AuthenticationFailed();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.validateAuthenticated = validateAuthenticated;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import IntegrationsPlatform from '@unito/integrations-platform-client';
|
|
2
|
+
import { Environment } from '../resources/globalConfiguration';
|
|
3
|
+
import { Configuration } from '../configurationTypes';
|
|
4
|
+
export type User = IntegrationsPlatform.User;
|
|
5
|
+
export type Credential = IntegrationsPlatform.Credential;
|
|
6
|
+
export type Integration = IntegrationsPlatform.Integration;
|
|
7
|
+
export type IntegrationSummary = IntegrationsPlatform.IntegrationSummary;
|
|
8
|
+
export type IntegrationEvent = IntegrationsPlatform.IntegrationEvent;
|
|
9
|
+
declare const HttpError: typeof IntegrationsPlatform.HttpError;
|
|
10
|
+
export { HttpError };
|
|
11
|
+
export declare const Servers: {
|
|
12
|
+
local: string;
|
|
13
|
+
staging: string;
|
|
14
|
+
production: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function setEnvironment(environment: Environment): void;
|
|
17
|
+
export declare function getApiKey(): string | undefined;
|
|
18
|
+
export declare function setApiKey(apiKey: string | undefined): void;
|
|
19
|
+
export declare function getProfile(): Promise<User>;
|
|
20
|
+
export declare function encryptData(integrationName: string, data: string): Promise<{
|
|
21
|
+
encryptedData: string;
|
|
22
|
+
}>;
|
|
23
|
+
export declare function decryptData(integrationName: string, data: string): Promise<{
|
|
24
|
+
decryptedData: string;
|
|
25
|
+
}>;
|
|
26
|
+
export declare function reencryptData(integrationName: string, encryptedData: string, newIntegrationName: string): Promise<{
|
|
27
|
+
encryptedData: string;
|
|
28
|
+
}>;
|
|
29
|
+
export declare function getIntegration(integrationId: number): Promise<Integration>;
|
|
30
|
+
export declare function getIntegrationByName(integrationName: string): Promise<Integration | null>;
|
|
31
|
+
export declare function getIntegrations(): Promise<IntegrationSummary[]>;
|
|
32
|
+
export declare function publishIntegration(archivePath: string): Promise<Integration>;
|
|
33
|
+
export declare function createIntegration(configuration: Configuration): Promise<Integration>;
|
|
34
|
+
export declare function inviteUserToIntegration(integrationId: number, email: string): Promise<Integration>;
|
|
35
|
+
export declare function getIntegrationEvents(integrationId: number): Promise<IntegrationEvent[]>;
|
|
36
|
+
export declare function updateIntegration(integrationId: number, configuration: Configuration): Promise<Integration>;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateIntegration = exports.getIntegrationEvents = exports.inviteUserToIntegration = exports.createIntegration = exports.publishIntegration = exports.getIntegrations = exports.getIntegrationByName = exports.getIntegration = exports.reencryptData = exports.decryptData = exports.encryptData = exports.getProfile = exports.setApiKey = exports.getApiKey = exports.setEnvironment = exports.Servers = exports.HttpError = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const integrations_platform_client_1 = tslib_1.__importDefault(require("@unito/integrations-platform-client"));
|
|
7
|
+
const globalConfiguration_1 = require("../resources/globalConfiguration");
|
|
8
|
+
const { HttpError } = integrations_platform_client_1.default;
|
|
9
|
+
exports.HttpError = HttpError;
|
|
10
|
+
exports.Servers = {
|
|
11
|
+
[globalConfiguration_1.Environment.Local]: integrations_platform_client_1.default.servers.local,
|
|
12
|
+
[globalConfiguration_1.Environment.Staging]: integrations_platform_client_1.default.servers.staging,
|
|
13
|
+
[globalConfiguration_1.Environment.Production]: integrations_platform_client_1.default.servers.production,
|
|
14
|
+
};
|
|
15
|
+
function setEnvironment(environment) {
|
|
16
|
+
integrations_platform_client_1.default.defaults.fetch = fetch;
|
|
17
|
+
integrations_platform_client_1.default.defaults.baseUrl = exports.Servers[environment];
|
|
18
|
+
}
|
|
19
|
+
exports.setEnvironment = setEnvironment;
|
|
20
|
+
function getApiKey() {
|
|
21
|
+
const header = integrations_platform_client_1.default.defaults.headers?.Authorization?.toString();
|
|
22
|
+
return header?.split(' ')?.at(1);
|
|
23
|
+
}
|
|
24
|
+
exports.getApiKey = getApiKey;
|
|
25
|
+
function setApiKey(apiKey) {
|
|
26
|
+
if (apiKey) {
|
|
27
|
+
integrations_platform_client_1.default.defaults.headers = { Authorization: `Bearer ${apiKey}` };
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
integrations_platform_client_1.default.defaults.headers = undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.setApiKey = setApiKey;
|
|
34
|
+
async function getProfile() {
|
|
35
|
+
return integrations_platform_client_1.default.getProfile();
|
|
36
|
+
}
|
|
37
|
+
exports.getProfile = getProfile;
|
|
38
|
+
async function encryptData(integrationName, data) {
|
|
39
|
+
return integrations_platform_client_1.default.encryptData({
|
|
40
|
+
integrationName,
|
|
41
|
+
data,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.encryptData = encryptData;
|
|
45
|
+
async function decryptData(integrationName, data) {
|
|
46
|
+
return integrations_platform_client_1.default.decryptData({
|
|
47
|
+
integrationName,
|
|
48
|
+
data,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
exports.decryptData = decryptData;
|
|
52
|
+
async function reencryptData(integrationName, encryptedData, newIntegrationName) {
|
|
53
|
+
return integrations_platform_client_1.default.reencryptData({
|
|
54
|
+
integrationName,
|
|
55
|
+
encryptedData,
|
|
56
|
+
newIntegrationName,
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
exports.reencryptData = reencryptData;
|
|
60
|
+
async function getIntegration(integrationId) {
|
|
61
|
+
return integrations_platform_client_1.default.getIntegrationById(integrationId);
|
|
62
|
+
}
|
|
63
|
+
exports.getIntegration = getIntegration;
|
|
64
|
+
async function getIntegrationByName(integrationName) {
|
|
65
|
+
let integration;
|
|
66
|
+
try {
|
|
67
|
+
integration = await integrations_platform_client_1.default.getIntegrationByName(integrationName);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return integration;
|
|
73
|
+
}
|
|
74
|
+
exports.getIntegrationByName = getIntegrationByName;
|
|
75
|
+
async function getIntegrations() {
|
|
76
|
+
const integrations = [];
|
|
77
|
+
let page;
|
|
78
|
+
const limit = 100;
|
|
79
|
+
let nextPageOffset = 0;
|
|
80
|
+
do {
|
|
81
|
+
page = await integrations_platform_client_1.default.getIntegrations({
|
|
82
|
+
pagination: { offset: nextPageOffset, limit },
|
|
83
|
+
});
|
|
84
|
+
nextPageOffset += limit;
|
|
85
|
+
integrations.push(...page.data);
|
|
86
|
+
} while (page.data.length >= limit);
|
|
87
|
+
return integrations;
|
|
88
|
+
}
|
|
89
|
+
exports.getIntegrations = getIntegrations;
|
|
90
|
+
async function publishIntegration(archivePath) {
|
|
91
|
+
const file = fs.readFileSync(archivePath);
|
|
92
|
+
const blob = new Blob([file], { type: 'binary' });
|
|
93
|
+
return await integrations_platform_client_1.default.publishIntegration({ file: blob });
|
|
94
|
+
}
|
|
95
|
+
exports.publishIntegration = publishIntegration;
|
|
96
|
+
async function createIntegration(configuration) {
|
|
97
|
+
// The creation of an integration is kept to its minimal required fields...
|
|
98
|
+
const integration = await integrations_platform_client_1.default.createIntegration({ name: configuration.name });
|
|
99
|
+
// ... as all other non-required fields are updated here.
|
|
100
|
+
return updateIntegration(integration.id, configuration);
|
|
101
|
+
}
|
|
102
|
+
exports.createIntegration = createIntegration;
|
|
103
|
+
async function inviteUserToIntegration(integrationId, email) {
|
|
104
|
+
return await integrations_platform_client_1.default.inviteUser(integrationId, { email });
|
|
105
|
+
}
|
|
106
|
+
exports.inviteUserToIntegration = inviteUserToIntegration;
|
|
107
|
+
async function getIntegrationEvents(integrationId) {
|
|
108
|
+
const { data: events } = await integrations_platform_client_1.default.getIntegrationEvents(integrationId);
|
|
109
|
+
return events;
|
|
110
|
+
}
|
|
111
|
+
exports.getIntegrationEvents = getIntegrationEvents;
|
|
112
|
+
async function updateIntegration(integrationId, configuration) {
|
|
113
|
+
const current = await integrations_platform_client_1.default.getIntegrationById(integrationId);
|
|
114
|
+
// Create authorizations.
|
|
115
|
+
const authorizationsToCreate = configuration.authorizations
|
|
116
|
+
?.filter(configAuthorization => !current.authorizations.some(platformAuthorization => platformAuthorization.name === configAuthorization.name))
|
|
117
|
+
?.map(configAuthorization => {
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
119
|
+
// @ts-ignore schema mismatch between the CLI and the platform (but fine at runtime).
|
|
120
|
+
const authorizationToCreate = {
|
|
121
|
+
...configAuthorization,
|
|
122
|
+
archived: false,
|
|
123
|
+
};
|
|
124
|
+
return authorizationToCreate;
|
|
125
|
+
}) ?? [];
|
|
126
|
+
// Archive authorizations.
|
|
127
|
+
const authorizationsToArchive = current.authorizations
|
|
128
|
+
.filter(platformAuthorization => !configuration.authorizations?.some(configAuthorization => platformAuthorization.name === configAuthorization.name))
|
|
129
|
+
.map(platformAuthorization => {
|
|
130
|
+
const authorizationToArchive = {
|
|
131
|
+
...platformAuthorization,
|
|
132
|
+
archived: true,
|
|
133
|
+
};
|
|
134
|
+
return authorizationToArchive;
|
|
135
|
+
});
|
|
136
|
+
// Update authorizations.
|
|
137
|
+
const authorizationsToUpdate = current.authorizations
|
|
138
|
+
.filter(platformAuthorization => configuration.authorizations?.some(configAuthorization => platformAuthorization.name === configAuthorization.name))
|
|
139
|
+
.map(platformAuthorization => {
|
|
140
|
+
const configAuthorization = configuration.authorizations?.find(authorization => platformAuthorization.name === authorization.name);
|
|
141
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
142
|
+
// @ts-ignore schema mismatch between the CLI and the platform (but fine at runtime).
|
|
143
|
+
const authorizationToUpdate = {
|
|
144
|
+
id: platformAuthorization.id,
|
|
145
|
+
...(configAuthorization ?? {}),
|
|
146
|
+
archived: false,
|
|
147
|
+
};
|
|
148
|
+
return authorizationToUpdate;
|
|
149
|
+
});
|
|
150
|
+
return await integrations_platform_client_1.default.updateIntegration(current.id, {
|
|
151
|
+
baseUrl: configuration.baseUrl,
|
|
152
|
+
graphRelativeUrl: configuration.graphRelativeUrl ?? '/',
|
|
153
|
+
credentialAccountRelativeUrl: configuration.credentialAccountRelativeUrl ?? '/me',
|
|
154
|
+
webhookParsingRelativeUrl: configuration.webhookParsingRelativeUrl,
|
|
155
|
+
webhookSubscriptionsRelativeUrl: configuration.webhookSubscriptionsRelativeUrl,
|
|
156
|
+
webhookAcknowledgeRelativeUrl: configuration.webhookAcknowledgeRelativeUrl,
|
|
157
|
+
authorizations: authorizationsToCreate.concat(authorizationsToArchive).concat(authorizationsToUpdate),
|
|
158
|
+
secrets: configuration.secrets,
|
|
159
|
+
ui: configuration.ui,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
exports.updateIntegration = updateIntegration;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Oauth2Response, Oauth2Payload } from '../oauth2Helper/types';
|
|
2
|
+
export declare function performOAuth2Flow(applicationCredentials: Oauth2Payload): Promise<Oauth2Response>;
|
|
3
|
+
export declare function updateToken(applicationCredentials: Oauth2Payload): Promise<Oauth2Response>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.updateToken = exports.performOAuth2Flow = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const oauth2Helper_1 = tslib_1.__importDefault(require("../oauth2Helper/oauth2Helper"));
|
|
6
|
+
const errors_1 = require("../errors");
|
|
7
|
+
async function performOAuth2Flow(applicationCredentials) {
|
|
8
|
+
const oauthHelper = new oauth2Helper_1.default(applicationCredentials);
|
|
9
|
+
const serverUrl = oauthHelper.startServer();
|
|
10
|
+
const healthCheck = await fetch(`${serverUrl}/health`);
|
|
11
|
+
if (healthCheck.status !== 200) {
|
|
12
|
+
throw new Error('OAuthServer did not start');
|
|
13
|
+
}
|
|
14
|
+
await fetch(`${serverUrl}/credentials/new/oauth2/authorize`);
|
|
15
|
+
await oauthHelper.callbackIsDone();
|
|
16
|
+
const response = await fetch(`${serverUrl}/credentials/new/oauth2/token`);
|
|
17
|
+
if (response.status !== 200) {
|
|
18
|
+
throw new errors_1.FailedToRetrieveAccessTokenError(await response.text());
|
|
19
|
+
}
|
|
20
|
+
const credentials = await response.json();
|
|
21
|
+
oauthHelper.stopServer();
|
|
22
|
+
if (!credentials.accessToken) {
|
|
23
|
+
throw new errors_1.FailedToRetrieveAccessTokenError('Access token was not returned');
|
|
24
|
+
}
|
|
25
|
+
return credentials;
|
|
26
|
+
}
|
|
27
|
+
exports.performOAuth2Flow = performOAuth2Flow;
|
|
28
|
+
/* istanbul ignore next */
|
|
29
|
+
// No point to test this function as it is just a wrapper around OAuth2Helper
|
|
30
|
+
async function updateToken(applicationCredentials) {
|
|
31
|
+
const oauthHelper = new oauth2Helper_1.default(applicationCredentials);
|
|
32
|
+
return oauthHelper.updateToken();
|
|
33
|
+
}
|
|
34
|
+
exports.updateToken = updateToken;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
7
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
8
|
+
const IntegrationConfiguration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
9
|
+
describe('activity', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
12
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
13
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
14
|
+
sinon_1.default
|
|
15
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName')
|
|
16
|
+
.resolves({ name: 'integrationName', id: 'foo' });
|
|
17
|
+
sinon_1.default.stub(IntegrationsPlatform, 'getIntegrationEvents').resolves([
|
|
18
|
+
{ date: '1', text: 'This is a foo', title: 'foo', tags: ['a', 'b', 'c'] },
|
|
19
|
+
{ date: '2', text: 'This is a bar', title: 'bar', tags: ['x', 'y', 'z'] },
|
|
20
|
+
]);
|
|
21
|
+
sinon_1.default.stub(IntegrationConfiguration, 'getConfiguration').resolves({ name: 'integrationName' });
|
|
22
|
+
});
|
|
23
|
+
afterEach(() => {
|
|
24
|
+
sinon_1.default.restore();
|
|
25
|
+
});
|
|
26
|
+
test_1.test
|
|
27
|
+
.stdout()
|
|
28
|
+
.command(['activity'])
|
|
29
|
+
.it('displays activity', ctx => {
|
|
30
|
+
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
31
|
+
(0, test_1.expect)(ctx.stdout).to.contains('bar');
|
|
32
|
+
});
|
|
33
|
+
test_1.test
|
|
34
|
+
.stdout()
|
|
35
|
+
.command(['activity', '--number', '1'])
|
|
36
|
+
.it('displays only specified number of activity entries', ctx => {
|
|
37
|
+
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
38
|
+
(0, test_1.expect)(ctx.stdout).to.not.contains('bar');
|
|
39
|
+
});
|
|
40
|
+
test_1.test
|
|
41
|
+
.stdout()
|
|
42
|
+
.command(['activity', '--environment', 'staging'])
|
|
43
|
+
.it('displays activity - staging', ctx => {
|
|
44
|
+
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
45
|
+
(0, test_1.expect)(ctx.stdout).to.contains('bar');
|
|
46
|
+
});
|
|
47
|
+
test_1.test
|
|
48
|
+
.stdout()
|
|
49
|
+
.command(['activity', '--environment', 'local'])
|
|
50
|
+
.it('displays activity - local', ctx => {
|
|
51
|
+
(0, test_1.expect)(ctx.stdout).to.contains('foo');
|
|
52
|
+
(0, test_1.expect)(ctx.stdout).to.contains('bar');
|
|
53
|
+
});
|
|
54
|
+
test_1.test
|
|
55
|
+
.stdout()
|
|
56
|
+
.stub(IntegrationsPlatform, 'getIntegrationByName', () => undefined)
|
|
57
|
+
.command(['activity'])
|
|
58
|
+
.catch(error => {
|
|
59
|
+
(0, test_1.expect)(error.message).to.equal('EEXIT: -1');
|
|
60
|
+
})
|
|
61
|
+
.it('handles unpublished integration');
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const child_process_1 = tslib_1.__importDefault(require("child_process"));
|
|
7
|
+
const IntegrationDebugger = tslib_1.__importStar(require("@unito/integration-debugger/dist/src/resources/configuration"));
|
|
8
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
9
|
+
const IntegrationsPlatformResource = tslib_1.__importStar(require("../../src/resources/integrationsPlatform"));
|
|
10
|
+
const ConfigurationResource = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
11
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
12
|
+
describe('Dev', () => {
|
|
13
|
+
const debuggerConfiguration = {
|
|
14
|
+
...IntegrationDebugger.getDefaultConfiguration(),
|
|
15
|
+
credentialPayload: {
|
|
16
|
+
key: 'value',
|
|
17
|
+
encryptedToken: `decrypted-me`,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const cliConfiguration = {
|
|
21
|
+
name: 'a',
|
|
22
|
+
baseUrl: 'b',
|
|
23
|
+
testAccounts: {
|
|
24
|
+
development: {
|
|
25
|
+
key: 'value',
|
|
26
|
+
encryptedToken: `${ConfigurationResource.ENCRYPTION_PREFIX}decrypt-me`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
let execSyncStub;
|
|
31
|
+
let spawnStub;
|
|
32
|
+
beforeEach(() => {
|
|
33
|
+
process.env.NODE_MODULES_FOLDER = '/path/to/node_modules';
|
|
34
|
+
sinon_1.default.stub(IntegrationsPlatform, 'decryptData').resolves({ decryptedData: 'decrypted-me' });
|
|
35
|
+
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
36
|
+
sinon_1.default.stub(IntegrationsPlatformResource, 'validateAuthenticated');
|
|
37
|
+
sinon_1.default.stub(ConfigurationResource, 'getConfiguration').resolves(cliConfiguration);
|
|
38
|
+
sinon_1.default.stub(IntegrationDebugger, 'readConfiguration').resolves(debuggerConfiguration);
|
|
39
|
+
execSyncStub = sinon_1.default.stub(child_process_1.default, 'execSync');
|
|
40
|
+
spawnStub = sinon_1.default.stub(child_process_1.default, 'spawn').returns({ on: (..._args) => { } });
|
|
41
|
+
});
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
process.env.NODE_MODULES_FOLDER = undefined;
|
|
44
|
+
sinon_1.default.restore();
|
|
45
|
+
});
|
|
46
|
+
test_1.test
|
|
47
|
+
.stdout()
|
|
48
|
+
.command(['dev'])
|
|
49
|
+
.it('launches the debugger', () => {
|
|
50
|
+
(0, test_1.expect)(execSyncStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['npm', 'install']);
|
|
51
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(0).split(' ').slice(0, 2)).to.deep.equal(['node']);
|
|
52
|
+
});
|
|
53
|
+
test_1.test
|
|
54
|
+
.stdout()
|
|
55
|
+
.command(['dev'])
|
|
56
|
+
.it('decrypts credentials', () => {
|
|
57
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-payload={"key":"value","encryptedToken":"decrypted-me"}');
|
|
58
|
+
});
|
|
59
|
+
test_1.test
|
|
60
|
+
.stdout()
|
|
61
|
+
.stub(IntegrationResource, 'validateIsIntegrationDirectory', () => {
|
|
62
|
+
throw new Error('boom!');
|
|
63
|
+
})
|
|
64
|
+
.command(['dev'])
|
|
65
|
+
.catch(ctx => {
|
|
66
|
+
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
67
|
+
})
|
|
68
|
+
.it('handle exception');
|
|
69
|
+
test_1.test
|
|
70
|
+
.stdout()
|
|
71
|
+
.command(['dev', '--verbose'])
|
|
72
|
+
.it('verbose mode', () => {
|
|
73
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--verbose');
|
|
74
|
+
});
|
|
75
|
+
test_1.test
|
|
76
|
+
.stdout()
|
|
77
|
+
.command(['dev', '--crawlMode=sample'])
|
|
78
|
+
.it('crawlMode - sample', () => {
|
|
79
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=10');
|
|
80
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-follow-next-pages=false');
|
|
81
|
+
});
|
|
82
|
+
test_1.test
|
|
83
|
+
.stdout()
|
|
84
|
+
.command(['dev', '--crawlMode=single'])
|
|
85
|
+
.it('crawlMode - single', () => {
|
|
86
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-items-per-page=1');
|
|
87
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--operation-collection-follow-next-pages=false');
|
|
88
|
+
});
|
|
89
|
+
test_1.test
|
|
90
|
+
.stdout()
|
|
91
|
+
.command(['dev', '--checks', 'foo,bar'])
|
|
92
|
+
.it('checks', () => {
|
|
93
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--checks=foo,bar');
|
|
94
|
+
});
|
|
95
|
+
test_1.test
|
|
96
|
+
.stdout()
|
|
97
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({ ...cliConfiguration, graphRelativeUrl: 'foo' }))
|
|
98
|
+
.command(['dev'])
|
|
99
|
+
.it('overrides --graph-relative-url', () => {
|
|
100
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--graph-relative-url=foo');
|
|
101
|
+
});
|
|
102
|
+
test_1.test
|
|
103
|
+
.stdout()
|
|
104
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({
|
|
105
|
+
...cliConfiguration,
|
|
106
|
+
credentialAccountRelativeUrl: 'foo',
|
|
107
|
+
}))
|
|
108
|
+
.command(['dev'])
|
|
109
|
+
.it('overrides --credential-account-relative-url', () => {
|
|
110
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--credential-account-relative-url=foo');
|
|
111
|
+
});
|
|
112
|
+
test_1.test
|
|
113
|
+
.stdout()
|
|
114
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({ ...cliConfiguration, webhookParsingRelativeUrl: 'foo' }))
|
|
115
|
+
.command(['dev'])
|
|
116
|
+
.it('overrides --webhook-parsing-relative-url', () => {
|
|
117
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-parsing-relative-url=foo');
|
|
118
|
+
});
|
|
119
|
+
test_1.test
|
|
120
|
+
.stdout()
|
|
121
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({
|
|
122
|
+
...cliConfiguration,
|
|
123
|
+
webhookSubscriptionsRelativeUrl: 'foo',
|
|
124
|
+
}))
|
|
125
|
+
.command(['dev'])
|
|
126
|
+
.it('overrides --webhook-subscriptions-relative-url', () => {
|
|
127
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-subscriptions-relative-url=foo');
|
|
128
|
+
});
|
|
129
|
+
test_1.test
|
|
130
|
+
.stdout()
|
|
131
|
+
.stub(ConfigurationResource, 'getConfiguration', () => ({
|
|
132
|
+
...cliConfiguration,
|
|
133
|
+
webhookAcknowledgeRelativeUrl: 'bar',
|
|
134
|
+
}))
|
|
135
|
+
.command(['dev'])
|
|
136
|
+
.it('overrides --webhook-acknowledge-relative-url', () => {
|
|
137
|
+
(0, test_1.expect)(spawnStub.getCall(0).args.at(1)).to.include('--webhook-acknowledge-relative-url=bar');
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const sinon_1 = tslib_1.__importDefault(require("sinon"));
|
|
6
|
+
const GlobalConfiguration = tslib_1.__importStar(require("../../src/resources/globalConfiguration"));
|
|
7
|
+
const IntegrationsPlatform = tslib_1.__importStar(require("../../src/services/integrationsPlatform"));
|
|
8
|
+
const IntegrationResource = tslib_1.__importStar(require("../../src/resources/integrations"));
|
|
9
|
+
const IntegrationConfiguration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
10
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
11
|
+
describe('encrypt', () => {
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
sinon_1.default.stub(IntegrationResource, 'validateIsIntegrationDirectory');
|
|
14
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setEnvironment');
|
|
15
|
+
sinon_1.default.stub(IntegrationsPlatform, 'setApiKey');
|
|
16
|
+
sinon_1.default.stub(IntegrationsPlatform, 'encryptData').resolves({ encryptedData: 'mySuperEncryptedData' });
|
|
17
|
+
sinon_1.default.stub(inquirer_1.default, 'prompt').resolves({ data: 'mySuperData' });
|
|
18
|
+
sinon_1.default.stub(IntegrationConfiguration, 'getConfiguration').resolves({ name: 'integrationName' });
|
|
19
|
+
sinon_1.default.stub(IntegrationsPlatform, 'getProfile').resolves({
|
|
20
|
+
id: 1,
|
|
21
|
+
createdAt: '',
|
|
22
|
+
updatedAt: '',
|
|
23
|
+
archivedAt: null,
|
|
24
|
+
email: 'foo@bar.com',
|
|
25
|
+
defaultUnitoOrganizationId: null,
|
|
26
|
+
role: 'developer',
|
|
27
|
+
apiKey: 'foo',
|
|
28
|
+
termsAcceptedAt: null,
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => {
|
|
32
|
+
sinon_1.default.restore();
|
|
33
|
+
});
|
|
34
|
+
test_1.test
|
|
35
|
+
.stdout()
|
|
36
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKey: 'foo' }))
|
|
37
|
+
.command(['encrypt'])
|
|
38
|
+
.it('encrypts data - default', ctx => {
|
|
39
|
+
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
40
|
+
});
|
|
41
|
+
test_1.test
|
|
42
|
+
.stdout()
|
|
43
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKeyLocal: 'foo' }))
|
|
44
|
+
.command(['encrypt', '--environment=local'])
|
|
45
|
+
.it('encrypts data - local', ctx => {
|
|
46
|
+
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
47
|
+
});
|
|
48
|
+
test_1.test
|
|
49
|
+
.stdout()
|
|
50
|
+
.stub(GlobalConfiguration, 'read', () => ({ apiKeyStaging: 'foo' }))
|
|
51
|
+
.command(['encrypt', '--environment', 'staging'])
|
|
52
|
+
.it('encrypts data - staging', ctx => {
|
|
53
|
+
(0, test_1.expect)(ctx.stdout).to.contains('Encrypted Data:');
|
|
54
|
+
});
|
|
55
|
+
test_1.test
|
|
56
|
+
.stdout()
|
|
57
|
+
.stub(GlobalConfiguration, 'read', () => ({}))
|
|
58
|
+
.command(['encrypt'])
|
|
59
|
+
.exit(-1)
|
|
60
|
+
.it('missing api key', ctx => {
|
|
61
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Your API key is not set!\nMake sure to run the login command first');
|
|
62
|
+
});
|
|
63
|
+
test_1.test
|
|
64
|
+
.stdout()
|
|
65
|
+
.stub(GlobalConfiguration, 'read', () => {
|
|
66
|
+
throw new Error('boom!');
|
|
67
|
+
})
|
|
68
|
+
.command(['encrypt'])
|
|
69
|
+
.catch(ctx => {
|
|
70
|
+
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
71
|
+
})
|
|
72
|
+
.it('handles configuration error');
|
|
73
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
const test_1 = require("@oclif/test");
|
|
5
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
|
+
const sinon = tslib_1.__importStar(require("sinon"));
|
|
7
|
+
const integrationGenerator_1 = require("../../integrationGenerator");
|
|
8
|
+
const Configuration = tslib_1.__importStar(require("../../src/resources/configuration"));
|
|
9
|
+
describe('init', () => {
|
|
10
|
+
beforeEach(() => {
|
|
11
|
+
// eslint-disable-next-line
|
|
12
|
+
sinon.stub(Configuration, 'getConfiguration').returns({});
|
|
13
|
+
sinon.stub(Configuration, 'writeConfiguration');
|
|
14
|
+
});
|
|
15
|
+
afterEach(() => {
|
|
16
|
+
sinon.restore();
|
|
17
|
+
});
|
|
18
|
+
test_1.test
|
|
19
|
+
.stub(inquirer_1.default, 'prompt', () => Promise.resolve({ name: 'myIntegration' }))
|
|
20
|
+
.stub(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton', () => '/my/super/path/myIntegration')
|
|
21
|
+
.stub(process, 'chdir', () => '')
|
|
22
|
+
.stdout()
|
|
23
|
+
.command(['init'])
|
|
24
|
+
.it('runs init', ctx => {
|
|
25
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Your integration is available at');
|
|
26
|
+
});
|
|
27
|
+
test_1.test
|
|
28
|
+
.stub(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton', () => '/my/super/path/myIntegration')
|
|
29
|
+
.stub(process, 'chdir', () => '')
|
|
30
|
+
.stdout()
|
|
31
|
+
.command(['init', '-n', 'myIntegration'])
|
|
32
|
+
.it('runs init with flag', ctx => {
|
|
33
|
+
(0, test_1.expect)(ctx.stdout).to.contain('Your integration is available at');
|
|
34
|
+
});
|
|
35
|
+
test_1.test
|
|
36
|
+
.stub(integrationGenerator_1.Resources.Integration, 'generateIntegrationSkeleton', () => {
|
|
37
|
+
throw new Error('boom!');
|
|
38
|
+
})
|
|
39
|
+
.stdout()
|
|
40
|
+
.command(['init', '-n', 'myIntegration'])
|
|
41
|
+
.catch(ctx => {
|
|
42
|
+
(0, test_1.expect)(ctx.message).to.equal('boom!');
|
|
43
|
+
})
|
|
44
|
+
.it('handle exception');
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|