@redocly/cli 1.29.0 → 1.30.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/CHANGELOG.md +11 -0
- package/lib/__tests__/commands/push-region.test.js +3 -3
- package/lib/auth/__tests__/device-flow.test.js +62 -0
- package/lib/auth/__tests__/oauth-client.test.js +93 -0
- package/lib/auth/device-flow.d.ts +26 -0
- package/lib/auth/device-flow.js +133 -0
- package/lib/auth/oauth-client.d.ts +14 -0
- package/lib/auth/oauth-client.js +93 -0
- package/lib/commands/auth.d.ts +13 -0
- package/lib/commands/auth.js +51 -0
- package/lib/commands/push.d.ts +1 -1
- package/lib/commands/push.js +4 -4
- package/lib/index.js +14 -15
- package/lib/otel.d.ts +10 -0
- package/lib/otel.js +47 -0
- package/lib/reunite/api/__tests__/domains.test.js +32 -0
- package/lib/{cms → reunite}/api/api-client.d.ts +9 -0
- package/lib/{cms → reunite}/api/api-client.js +2 -1
- package/lib/reunite/api/domains.d.ts +4 -0
- package/lib/reunite/api/domains.js +22 -0
- package/lib/reunite/commands/__tests__/push.test.d.ts +1 -0
- package/lib/reunite/commands/__tests__/utils.test.d.ts +1 -0
- package/lib/types.d.ts +4 -4
- package/lib/utils/miscellaneous.d.ts +5 -4
- package/lib/utils/miscellaneous.js +14 -14
- package/package.json +7 -2
- package/src/__tests__/commands/push-region.test.ts +2 -2
- package/src/auth/__tests__/device-flow.test.ts +73 -0
- package/src/auth/__tests__/oauth-client.test.ts +117 -0
- package/src/auth/device-flow.ts +175 -0
- package/src/auth/oauth-client.ts +111 -0
- package/src/commands/auth.ts +66 -0
- package/src/commands/push.ts +3 -3
- package/src/index.ts +14 -15
- package/src/otel.ts +59 -0
- package/src/reunite/api/__tests__/domains.test.ts +41 -0
- package/src/{cms → reunite}/api/api-client.ts +1 -1
- package/src/reunite/api/domains.ts +23 -0
- package/src/types.ts +4 -3
- package/src/utils/miscellaneous.ts +20 -18
- package/tsconfig.tsbuildinfo +1 -1
- package/lib/cms/api/__tests__/domains.test.js +0 -13
- package/lib/cms/api/domains.d.ts +0 -1
- package/lib/cms/api/domains.js +0 -11
- package/lib/commands/login.d.ts +0 -9
- package/lib/commands/login.js +0 -23
- package/src/cms/api/__tests__/domains.test.ts +0 -15
- package/src/cms/api/domains.ts +0 -11
- package/src/commands/login.ts +0 -34
- /package/lib/{cms/api/__tests__/api-keys.test.d.ts → auth/__tests__/device-flow.test.d.ts} +0 -0
- /package/lib/{cms/api/__tests__/api.client.test.d.ts → auth/__tests__/oauth-client.test.d.ts} +0 -0
- /package/lib/{cms/api/__tests__/domains.test.d.ts → reunite/api/__tests__/api-keys.test.d.ts} +0 -0
- /package/lib/{cms → reunite}/api/__tests__/api-keys.test.js +0 -0
- /package/lib/{cms/commands/__tests__/push-status.test.d.ts → reunite/api/__tests__/api.client.test.d.ts} +0 -0
- /package/lib/{cms → reunite}/api/__tests__/api.client.test.js +0 -0
- /package/lib/{cms/commands/__tests__/push.test.d.ts → reunite/api/__tests__/domains.test.d.ts} +0 -0
- /package/lib/{cms → reunite}/api/api-keys.d.ts +0 -0
- /package/lib/{cms → reunite}/api/api-keys.js +0 -0
- /package/lib/{cms → reunite}/api/index.d.ts +0 -0
- /package/lib/{cms → reunite}/api/index.js +0 -0
- /package/lib/{cms → reunite}/api/types.d.ts +0 -0
- /package/lib/{cms → reunite}/api/types.js +0 -0
- /package/lib/{cms/commands/__tests__/utils.test.d.ts → reunite/commands/__tests__/push-status.test.d.ts} +0 -0
- /package/lib/{cms → reunite}/commands/__tests__/push-status.test.js +0 -0
- /package/lib/{cms → reunite}/commands/__tests__/push.test.js +0 -0
- /package/lib/{cms → reunite}/commands/__tests__/utils.test.js +0 -0
- /package/lib/{cms → reunite}/commands/push-status.d.ts +0 -0
- /package/lib/{cms → reunite}/commands/push-status.js +0 -0
- /package/lib/{cms → reunite}/commands/push.d.ts +0 -0
- /package/lib/{cms → reunite}/commands/push.js +0 -0
- /package/lib/{cms → reunite}/commands/utils.d.ts +0 -0
- /package/lib/{cms → reunite}/commands/utils.js +0 -0
- /package/lib/{cms → reunite}/utils.d.ts +0 -0
- /package/lib/{cms → reunite}/utils.js +0 -0
- /package/src/{cms → reunite}/api/__tests__/api-keys.test.ts +0 -0
- /package/src/{cms → reunite}/api/__tests__/api.client.test.ts +0 -0
- /package/src/{cms → reunite}/api/api-keys.ts +0 -0
- /package/src/{cms → reunite}/api/index.ts +0 -0
- /package/src/{cms → reunite}/api/types.ts +0 -0
- /package/src/{cms → reunite}/commands/__tests__/push-status.test.ts +0 -0
- /package/src/{cms → reunite}/commands/__tests__/push.test.ts +0 -0
- /package/src/{cms → reunite}/commands/__tests__/utils.test.ts +0 -0
- /package/src/{cms → reunite}/commands/push-status.ts +0 -0
- /package/src/{cms → reunite}/commands/push.ts +0 -0
- /package/src/{cms → reunite}/commands/utils.ts +0 -0
- /package/src/{cms → reunite}/utils.ts +0 -0
|
@@ -3,6 +3,7 @@ import { blue, gray, green, red, yellow } from 'colorette';
|
|
|
3
3
|
import { performance } from 'perf_hooks';
|
|
4
4
|
import * as glob from 'glob';
|
|
5
5
|
import * as fs from 'fs';
|
|
6
|
+
import * as os from 'os';
|
|
6
7
|
import * as readline from 'readline';
|
|
7
8
|
import { Writable } from 'stream';
|
|
8
9
|
import { execSync } from 'child_process';
|
|
@@ -28,7 +29,9 @@ import { deprecatedRefDocsSchema } from '@redocly/config/lib/reference-docs-conf
|
|
|
28
29
|
import { outputExtensions } from '../types';
|
|
29
30
|
import { version } from './update-version-notifier';
|
|
30
31
|
import { DESTINATION_REGEX } from '../commands/push';
|
|
31
|
-
import
|
|
32
|
+
import { RedoclyOAuthClient } from '../auth/oauth-client';
|
|
33
|
+
import { getReuniteUrl } from '../reunite/api';
|
|
34
|
+
import { otelTelemetry } from '../otel';
|
|
32
35
|
|
|
33
36
|
import type { Arguments } from 'yargs';
|
|
34
37
|
import type {
|
|
@@ -546,6 +549,8 @@ export function cleanColors(input: string): string {
|
|
|
546
549
|
return input.replace(/\x1b\[\d+m/g, '');
|
|
547
550
|
}
|
|
548
551
|
|
|
552
|
+
otelTelemetry.init();
|
|
553
|
+
|
|
549
554
|
export async function sendTelemetry(
|
|
550
555
|
argv: Arguments | undefined,
|
|
551
556
|
exit_code: ExitCode,
|
|
@@ -565,33 +570,29 @@ export async function sendTelemetry(
|
|
|
565
570
|
} = argv;
|
|
566
571
|
const event_time = new Date().toISOString();
|
|
567
572
|
const redoclyClient = new RedoclyClient();
|
|
568
|
-
const
|
|
573
|
+
const oauthClient = new RedoclyOAuthClient('redocly-cli', version);
|
|
574
|
+
const reuniteUrl = getReuniteUrl(argv.residency as string | undefined);
|
|
575
|
+
const logged_in = redoclyClient.hasTokens() || (await oauthClient.isAuthorized(reuniteUrl));
|
|
569
576
|
const data: Analytics = {
|
|
570
577
|
event: 'cli_command',
|
|
571
578
|
event_time,
|
|
572
|
-
logged_in,
|
|
573
|
-
command
|
|
574
|
-
arguments: cleanArgs(args),
|
|
579
|
+
logged_in: logged_in ? 'yes' : 'no',
|
|
580
|
+
command: `${command}`,
|
|
581
|
+
arguments: JSON.stringify(cleanArgs(args)),
|
|
575
582
|
node_version: process.version,
|
|
576
583
|
npm_version: execSync('npm -v').toString().replace('\n', ''),
|
|
584
|
+
os_platform: os.platform(),
|
|
577
585
|
version,
|
|
578
586
|
exit_code,
|
|
579
587
|
environment: process.env.REDOCLY_ENVIRONMENT,
|
|
580
588
|
environment_ci: process.env.CI,
|
|
581
589
|
raw_input: cleanRawInput(process.argv.slice(2)),
|
|
582
|
-
has_config,
|
|
590
|
+
has_config: has_config ? 'yes' : 'no',
|
|
583
591
|
spec_version,
|
|
584
592
|
spec_keyword,
|
|
585
593
|
spec_full_version,
|
|
586
594
|
};
|
|
587
|
-
|
|
588
|
-
timeout: DEFAULT_FETCH_TIMEOUT,
|
|
589
|
-
method: 'POST',
|
|
590
|
-
headers: {
|
|
591
|
-
'content-type': 'application/json',
|
|
592
|
-
},
|
|
593
|
-
body: JSON.stringify(data),
|
|
594
|
-
});
|
|
595
|
+
otelTelemetry.send(data.command, data);
|
|
595
596
|
} catch (err) {
|
|
596
597
|
// Do nothing.
|
|
597
598
|
}
|
|
@@ -602,17 +603,18 @@ export type ExitCode = 0 | 1 | 2;
|
|
|
602
603
|
export type Analytics = {
|
|
603
604
|
event: string;
|
|
604
605
|
event_time: string;
|
|
605
|
-
logged_in:
|
|
606
|
-
command: string
|
|
607
|
-
arguments:
|
|
606
|
+
logged_in: 'yes' | 'no';
|
|
607
|
+
command: string;
|
|
608
|
+
arguments: string;
|
|
608
609
|
node_version: string;
|
|
609
610
|
npm_version: string;
|
|
611
|
+
os_platform: string;
|
|
610
612
|
version: string;
|
|
611
613
|
exit_code: ExitCode;
|
|
612
614
|
environment?: string;
|
|
613
615
|
environment_ci?: string;
|
|
614
616
|
raw_input: string;
|
|
615
|
-
has_config?:
|
|
617
|
+
has_config?: 'yes' | 'no';
|
|
616
618
|
spec_version?: string;
|
|
617
619
|
spec_keyword?: string;
|
|
618
620
|
spec_full_version?: string;
|