@unito/integration-cli 1.0.1 → 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.
|
@@ -1,47 +1,42 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import eslint from '@eslint/js';
|
|
2
|
+
import tseslint from 'typescript-eslint';
|
|
3
3
|
|
|
4
|
-
export default
|
|
4
|
+
export default tseslint.config(
|
|
5
5
|
{
|
|
6
6
|
ignores: ['node_modules/**', 'dist/**', 'eslint.config.mjs'],
|
|
7
7
|
},
|
|
8
|
+
eslint.configs.recommended,
|
|
9
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
8
10
|
{
|
|
9
|
-
files: ['**/*.{js,ts}'],
|
|
10
11
|
languageOptions: {
|
|
11
|
-
parser: tsParser,
|
|
12
12
|
parserOptions: {
|
|
13
13
|
project: './**/tsconfig.json',
|
|
14
14
|
},
|
|
15
|
-
ecmaVersion: 'latest',
|
|
16
|
-
sourceType: 'module',
|
|
17
15
|
globals: {
|
|
18
|
-
// Equivalent to env: { browser: true, node: true, es6: true }
|
|
19
|
-
window: 'readonly',
|
|
20
|
-
document: 'readonly',
|
|
21
|
-
navigator: 'readonly',
|
|
22
16
|
process: 'readonly',
|
|
23
17
|
require: 'readonly',
|
|
24
18
|
module: 'readonly',
|
|
25
19
|
__dirname: 'readonly',
|
|
26
20
|
},
|
|
27
21
|
},
|
|
28
|
-
plugins: {
|
|
29
|
-
'@typescript-eslint': tseslint,
|
|
30
|
-
},
|
|
31
22
|
rules: {
|
|
32
|
-
|
|
33
|
-
'@typescript-eslint/no-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
'@typescript-eslint/no-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
23
|
+
'no-undef': 'off',
|
|
24
|
+
'@typescript-eslint/no-unused-vars': [
|
|
25
|
+
'error',
|
|
26
|
+
{
|
|
27
|
+
argsIgnorePattern: '^_',
|
|
28
|
+
varsIgnorePattern: '^_',
|
|
29
|
+
caughtErrorsIgnorePattern: '^_',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
'@typescript-eslint/no-misused-promises': [
|
|
33
|
+
'error',
|
|
34
|
+
{
|
|
35
|
+
checksVoidReturn: {
|
|
36
|
+
arguments: false,
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
],
|
|
45
40
|
'@typescript-eslint/naming-convention': [
|
|
46
41
|
'warn',
|
|
47
42
|
{
|
|
@@ -59,14 +54,8 @@ export default [
|
|
|
59
54
|
modifiers: ['requiresQuotes'],
|
|
60
55
|
},
|
|
61
56
|
],
|
|
62
|
-
|
|
63
|
-
// JavaScript rules
|
|
64
57
|
'no-whitespace-before-property': 'error',
|
|
65
58
|
'no-trailing-spaces': 'error',
|
|
66
|
-
'no-extra-boolean-cast': 'off',
|
|
67
|
-
'no-inner-declarations': 'off',
|
|
68
|
-
'no-useless-escape': 'off',
|
|
69
|
-
'no-case-declarations': 'off',
|
|
70
59
|
'space-unary-ops': [
|
|
71
60
|
'error',
|
|
72
61
|
{
|
|
@@ -83,13 +72,26 @@ export default [
|
|
|
83
72
|
},
|
|
84
73
|
],
|
|
85
74
|
'object-curly-spacing': ['error', 'always'],
|
|
86
|
-
'no-console':
|
|
75
|
+
'no-console': 'error',
|
|
76
|
+
curly: ['error', 'all'],
|
|
77
|
+
'padding-line-between-statements': ['error', { blankLine: 'always', prev: '*', next: 'return' }],
|
|
78
|
+
eqeqeq: ['error', 'always', { null: 'ignore' }],
|
|
79
|
+
'prefer-const': 'error',
|
|
80
|
+
'no-else-return': 'error',
|
|
87
81
|
},
|
|
88
82
|
},
|
|
89
83
|
{
|
|
90
84
|
files: ['test/**/*.test.ts'],
|
|
91
85
|
rules: {
|
|
92
86
|
'@typescript-eslint/no-floating-promises': 'off',
|
|
87
|
+
'@typescript-eslint/no-explicit-any': 'off',
|
|
88
|
+
'@typescript-eslint/no-unsafe-assignment': 'off',
|
|
89
|
+
'@typescript-eslint/no-unsafe-member-access': 'off',
|
|
90
|
+
'@typescript-eslint/no-unsafe-call': 'off',
|
|
91
|
+
'@typescript-eslint/no-unsafe-argument': 'off',
|
|
92
|
+
'@typescript-eslint/no-unsafe-return': 'off',
|
|
93
|
+
'@typescript-eslint/unbound-method': 'off',
|
|
94
|
+
'@typescript-eslint/require-await': 'off',
|
|
93
95
|
},
|
|
94
96
|
},
|
|
95
|
-
|
|
97
|
+
);
|
|
@@ -1786,9 +1786,9 @@
|
|
|
1786
1786
|
}
|
|
1787
1787
|
},
|
|
1788
1788
|
"node_modules/flatted": {
|
|
1789
|
-
"version": "3.4.
|
|
1790
|
-
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.
|
|
1791
|
-
"integrity": "sha512-
|
|
1789
|
+
"version": "3.4.2",
|
|
1790
|
+
"resolved": "https://registry.npmjs.org/flatted/-/flatted-3.4.2.tgz",
|
|
1791
|
+
"integrity": "sha512-PjDse7RzhcPkIJwy5t7KPWQSZ9cAbzQXcafsetQoD7sOJRQlGikNbx7yZp2OotDnJyrDcbyRq3Ttb18iYOqkxA==",
|
|
1792
1792
|
"dev": true,
|
|
1793
1793
|
"license": "ISC"
|
|
1794
1794
|
},
|
|
@@ -3,9 +3,66 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.performOAuth2Flow = performOAuth2Flow;
|
|
4
4
|
exports.updateToken = updateToken;
|
|
5
5
|
const tslib_1 = require("tslib");
|
|
6
|
+
const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
|
7
|
+
const inquirer_1 = tslib_1.__importDefault(require("inquirer"));
|
|
6
8
|
const oauth2_1 = tslib_1.__importDefault(require("../services/oauth2"));
|
|
7
9
|
const errors_1 = require("../errors");
|
|
8
10
|
const globalConfiguration_1 = require("./globalConfiguration");
|
|
11
|
+
async function isServiceReachable(url) {
|
|
12
|
+
try {
|
|
13
|
+
await fetch(url, { signal: AbortSignal.timeout(3000) });
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async function waitForLegacyRedirectServices(legacyRedirectUrl) {
|
|
21
|
+
const { origin, port } = new URL(legacyRedirectUrl);
|
|
22
|
+
const services = [
|
|
23
|
+
{
|
|
24
|
+
name: 'maestro',
|
|
25
|
+
healthUrl: `${origin}/health`,
|
|
26
|
+
port: port || '3000',
|
|
27
|
+
startCmd: 'cd console/maestro && npm run dev',
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'platformServer',
|
|
31
|
+
healthUrl: 'http://127.0.0.1:9000/health',
|
|
32
|
+
port: '9000',
|
|
33
|
+
startCmd: 'cd connector-service/platformServer && npm run dev',
|
|
34
|
+
},
|
|
35
|
+
];
|
|
36
|
+
console.log(chalk_1.default.yellow('\n This integration uses legacyRedirectUrl — additional services are required.'));
|
|
37
|
+
console.log(chalk_1.default.yellow(' The OAuth callback will be routed through maestro → platformServer → CLI.\n'));
|
|
38
|
+
let allUp = false;
|
|
39
|
+
while (!allUp) {
|
|
40
|
+
const results = await Promise.all(services.map(s => isServiceReachable(s.healthUrl)));
|
|
41
|
+
allUp = results.every(Boolean);
|
|
42
|
+
for (const [i, service] of services.entries()) {
|
|
43
|
+
if (results[i]) {
|
|
44
|
+
console.log(chalk_1.default.green(` ✓ ${service.name} is running`));
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
console.log(chalk_1.default.red(` ✗ ${service.name} not running on port ${service.port}`));
|
|
48
|
+
console.log(` Start it: ${service.startCmd}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (allUp) {
|
|
52
|
+
console.log('');
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
const { retry } = await inquirer_1.default.prompt({
|
|
56
|
+
name: 'retry',
|
|
57
|
+
type: 'confirm',
|
|
58
|
+
message: 'Start the missing services and try again?',
|
|
59
|
+
default: true,
|
|
60
|
+
});
|
|
61
|
+
if (!retry) {
|
|
62
|
+
throw new Error('OAuth2 flow aborted: required services are not running.');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
9
66
|
async function performOAuth2Flow(applicationCredentials, environment = globalConfiguration_1.Environment.Production, credentialPayload) {
|
|
10
67
|
const oauthHelper = new oauth2_1.default(applicationCredentials, environment, credentialPayload);
|
|
11
68
|
const serverUrl = await oauthHelper.startServer();
|
|
@@ -14,6 +71,9 @@ async function performOAuth2Flow(applicationCredentials, environment = globalCon
|
|
|
14
71
|
const error = await healthCheck.text();
|
|
15
72
|
throw new Error(`OAuthServer did not start correctly.\n HealthCheck status: ${healthCheck.status}\n Response: ${error}`);
|
|
16
73
|
}
|
|
74
|
+
if (applicationCredentials.legacyRedirectUrl) {
|
|
75
|
+
await waitForLegacyRedirectServices(applicationCredentials.legacyRedirectUrl);
|
|
76
|
+
}
|
|
17
77
|
await oauthHelper.authorize();
|
|
18
78
|
const oauth2Response = await oauthHelper.callbackIsDone();
|
|
19
79
|
await oauthHelper.stopServer();
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unito/integration-cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Integration CLI",
|
|
5
5
|
"bin": {
|
|
6
6
|
"integration-cli": "./bin/run"
|
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
"!/bin/dev*"
|
|
37
37
|
],
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@ngrok/ngrok": "^1.
|
|
39
|
+
"@ngrok/ngrok": "^1.7.0",
|
|
40
40
|
"@oazapfts/runtime": "1.x",
|
|
41
41
|
"@oclif/core": "3.x",
|
|
42
|
-
"@unito/integration-debugger": "0.29.
|
|
42
|
+
"@unito/integration-debugger": "^0.29.1",
|
|
43
43
|
"ajv": "8.x",
|
|
44
44
|
"ajv-formats": "3.x",
|
|
45
45
|
"better-ajv-errors": "1.x",
|