generate-ui-cli 2.1.6 → 2.1.7
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/dist/index.js +13 -1
- package/dist/postinstall.js +28 -0
- package/dist/telemetry.js +23 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -6,6 +6,7 @@ const generate_1 = require("./commands/generate");
|
|
|
6
6
|
const angular_1 = require("./commands/angular");
|
|
7
7
|
const login_1 = require("./commands/login");
|
|
8
8
|
const config_1 = require("./runtime/config");
|
|
9
|
+
const telemetry_1 = require("./telemetry");
|
|
9
10
|
const program = new commander_1.Command();
|
|
10
11
|
program
|
|
11
12
|
.name('generate-ui')
|
|
@@ -24,6 +25,7 @@ program
|
|
|
24
25
|
.action(async (options) => {
|
|
25
26
|
const { telemetry } = program.opts();
|
|
26
27
|
try {
|
|
28
|
+
await (0, telemetry_1.trackGenerateCalled)();
|
|
27
29
|
await (0, generate_1.generate)({
|
|
28
30
|
openapi: options.openapi,
|
|
29
31
|
output: options.output,
|
|
@@ -80,4 +82,14 @@ function handleCliError(error) {
|
|
|
80
82
|
}
|
|
81
83
|
process.exit(1);
|
|
82
84
|
}
|
|
83
|
-
|
|
85
|
+
async function run() {
|
|
86
|
+
console.log('[GenerateUI] started');
|
|
87
|
+
await (0, telemetry_1.trackCliStarted)();
|
|
88
|
+
if (process.argv.slice(2).length === 0) {
|
|
89
|
+
await (0, telemetry_1.trackCommandHelp)();
|
|
90
|
+
program.outputHelp();
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
await program.parseAsync();
|
|
94
|
+
}
|
|
95
|
+
void run();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
7
|
+
const TELEMETRY_URL = process.env.GENERATEUI_TELEMETRY_URL?.trim() ||
|
|
8
|
+
'https://generateuibackend-production.up.railway.app/events';
|
|
9
|
+
async function sendInstallEvent() {
|
|
10
|
+
if (typeof fetch !== 'function')
|
|
11
|
+
return;
|
|
12
|
+
const payload = {
|
|
13
|
+
event: 'cli_installed',
|
|
14
|
+
cliVersion: package_json_1.default.version || '0.0.0',
|
|
15
|
+
npmUserAgent: process.env.npm_config_user_agent || ''
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
await fetch(TELEMETRY_URL, {
|
|
19
|
+
method: 'POST',
|
|
20
|
+
headers: { 'Content-Type': 'application/json' },
|
|
21
|
+
body: JSON.stringify(payload)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
// Postinstall must never block installation.
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
void sendInstallEvent();
|
package/dist/telemetry.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trackCliStarted = trackCliStarted;
|
|
4
|
+
exports.trackCommandHelp = trackCommandHelp;
|
|
5
|
+
exports.trackGenerateCalled = trackGenerateCalled;
|
|
3
6
|
exports.trackCommand = trackCommand;
|
|
4
7
|
exports.trackLogin = trackLogin;
|
|
5
8
|
const crypto_1 = require("crypto");
|
|
@@ -89,6 +92,26 @@ async function sendEvent(payload) {
|
|
|
89
92
|
clearTimeout(timeout);
|
|
90
93
|
}
|
|
91
94
|
}
|
|
95
|
+
async function sendMandatoryEvent(event, extra) {
|
|
96
|
+
const { config } = loadOrCreateConfig();
|
|
97
|
+
const device = (0, device_1.loadDeviceIdentity)();
|
|
98
|
+
await sendEvent({
|
|
99
|
+
event,
|
|
100
|
+
installationId: config.installationId,
|
|
101
|
+
deviceId: device.deviceId,
|
|
102
|
+
cliVersion: (0, config_1.getCliVersion)(),
|
|
103
|
+
...extra
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
async function trackCliStarted() {
|
|
107
|
+
await sendMandatoryEvent('cli_started');
|
|
108
|
+
}
|
|
109
|
+
async function trackCommandHelp() {
|
|
110
|
+
await sendMandatoryEvent('command_help');
|
|
111
|
+
}
|
|
112
|
+
async function trackGenerateCalled() {
|
|
113
|
+
await sendMandatoryEvent('generate_called');
|
|
114
|
+
}
|
|
92
115
|
async function trackCommand(command, cliEnabled) {
|
|
93
116
|
const { config, isNew } = loadOrCreateConfig();
|
|
94
117
|
const enabled = isTelemetryEnabled(cliEnabled, config);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "generate-ui-cli",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.7",
|
|
4
4
|
"description": "Generate UI from OpenAPI",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
"scripts": {
|
|
38
38
|
"build": "tsc -p tsconfig.json",
|
|
39
39
|
"dev": "ts-node src/index.ts",
|
|
40
|
+
"postinstall": "node dist/postinstall.js",
|
|
40
41
|
"prepublishOnly": "npm run build"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|