prpm 0.1.9 → 0.1.11
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/__tests__/e2e/test-helpers.js +1 -0
- package/dist/commands/buy-credits.js +4 -4
- package/dist/commands/catalog.js +2 -2
- package/dist/commands/collections.js +17 -9
- package/dist/commands/config.js +18 -24
- package/dist/commands/credits.js +3 -3
- package/dist/commands/index.js +2 -4
- package/dist/commands/info.js +2 -7
- package/dist/commands/init.js +5 -3
- package/dist/commands/install.js +79 -27
- package/dist/commands/list.js +2 -3
- package/dist/commands/login.js +2 -4
- package/dist/commands/outdated.js +2 -3
- package/dist/commands/playground.js +4 -4
- package/dist/commands/popular.js +0 -1
- package/dist/commands/publish.js +66 -35
- package/dist/commands/schema.js +6 -5
- package/dist/commands/search.js +4 -4
- package/dist/commands/subscribe.js +4 -4
- package/dist/commands/telemetry.js +3 -8
- package/dist/commands/trending.js +4 -4
- package/dist/commands/uninstall.js +6 -5
- package/dist/commands/update.js +2 -3
- package/dist/commands/upgrade.js +2 -3
- package/dist/commands/whoami.js +2 -3
- package/dist/core/errors.js +29 -0
- package/dist/core/telemetry.js +36 -4
- package/dist/index.js +23 -2
- package/package.json +3 -3
package/dist/core/telemetry.js
CHANGED
|
@@ -8,16 +8,38 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const os_1 = __importDefault(require("os"));
|
|
10
10
|
const posthog_node_1 = require("posthog-node");
|
|
11
|
+
const user_config_1 = require("./user-config");
|
|
11
12
|
class Telemetry {
|
|
12
13
|
constructor() {
|
|
13
14
|
this.events = [];
|
|
14
15
|
this.maxEvents = 100; // Keep only last 100 events locally
|
|
15
16
|
this.posthog = null;
|
|
17
|
+
this.userConfigChecked = false;
|
|
18
|
+
this.userTelemetryEnabled = true; // Default to true until checked
|
|
16
19
|
this.configPath = path_1.default.join(os_1.default.homedir(), '.prpm', 'telemetry.json');
|
|
17
20
|
this.config = this.loadConfig();
|
|
18
|
-
this.initializePostHog();
|
|
19
21
|
}
|
|
20
|
-
|
|
22
|
+
async checkUserConfig() {
|
|
23
|
+
if (this.userConfigChecked)
|
|
24
|
+
return;
|
|
25
|
+
try {
|
|
26
|
+
const userConfig = await (0, user_config_1.getConfig)();
|
|
27
|
+
this.userTelemetryEnabled = userConfig.telemetryEnabled ?? true;
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
// If we can't load user config, default to enabled
|
|
31
|
+
this.userTelemetryEnabled = true;
|
|
32
|
+
}
|
|
33
|
+
this.userConfigChecked = true;
|
|
34
|
+
}
|
|
35
|
+
async initializePostHog() {
|
|
36
|
+
// Check user config first
|
|
37
|
+
await this.checkUserConfig();
|
|
38
|
+
// Only initialize if telemetry is enabled in user config
|
|
39
|
+
if (!this.userTelemetryEnabled) {
|
|
40
|
+
this.posthog = null;
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
21
43
|
try {
|
|
22
44
|
this.posthog = new posthog_node_1.PostHog('phc_aO5lXLILeylHfb1ynszVwKbQKSzO91UGdXNhN5Q0Snl', {
|
|
23
45
|
host: 'https://app.posthog.com',
|
|
@@ -59,6 +81,11 @@ class Telemetry {
|
|
|
59
81
|
}
|
|
60
82
|
}
|
|
61
83
|
async track(event) {
|
|
84
|
+
// Check user config first
|
|
85
|
+
await this.checkUserConfig();
|
|
86
|
+
// Return early if telemetry is disabled in user config
|
|
87
|
+
if (!this.userTelemetryEnabled)
|
|
88
|
+
return;
|
|
62
89
|
if (!this.config.enabled)
|
|
63
90
|
return;
|
|
64
91
|
const fullEvent = {
|
|
@@ -92,6 +119,10 @@ class Telemetry {
|
|
|
92
119
|
}
|
|
93
120
|
}
|
|
94
121
|
async sendToAnalytics(event) {
|
|
122
|
+
// Initialize PostHog if needed (this will check user config)
|
|
123
|
+
if (!this.posthog && this.userTelemetryEnabled) {
|
|
124
|
+
await this.initializePostHog();
|
|
125
|
+
}
|
|
95
126
|
// Send to PostHog
|
|
96
127
|
await this.sendToPostHog(event);
|
|
97
128
|
}
|
|
@@ -103,8 +134,9 @@ class Telemetry {
|
|
|
103
134
|
this.config.enabled = false;
|
|
104
135
|
await this.saveConfig();
|
|
105
136
|
}
|
|
106
|
-
isEnabled() {
|
|
107
|
-
|
|
137
|
+
async isEnabled() {
|
|
138
|
+
await this.checkUserConfig();
|
|
139
|
+
return this.userTelemetryEnabled && this.config.enabled;
|
|
108
140
|
}
|
|
109
141
|
async getStats() {
|
|
110
142
|
try {
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ const credits_1 = require("./commands/credits");
|
|
|
32
32
|
const subscribe_1 = require("./commands/subscribe");
|
|
33
33
|
const buy_credits_1 = require("./commands/buy-credits");
|
|
34
34
|
const telemetry_2 = require("./core/telemetry");
|
|
35
|
+
const errors_1 = require("./core/errors");
|
|
35
36
|
// Read version from package.json
|
|
36
37
|
function getVersion() {
|
|
37
38
|
try {
|
|
@@ -77,8 +78,28 @@ program.addCommand((0, buy_credits_1.createBuyCreditsCommand)());
|
|
|
77
78
|
// Utility commands
|
|
78
79
|
program.addCommand((0, schema_1.createSchemaCommand)());
|
|
79
80
|
program.addCommand((0, config_1.createConfigCommand)());
|
|
80
|
-
// Parse command line arguments
|
|
81
|
-
|
|
81
|
+
// Parse command line arguments with error handling
|
|
82
|
+
(async () => {
|
|
83
|
+
try {
|
|
84
|
+
await program.parseAsync();
|
|
85
|
+
// Command completed successfully - let Node.js exit naturally
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
if (error instanceof errors_1.CLIError) {
|
|
89
|
+
// Print error message if present
|
|
90
|
+
if (error.message) {
|
|
91
|
+
console.error(error.message);
|
|
92
|
+
}
|
|
93
|
+
// Exit with the error's exit code
|
|
94
|
+
process.exit(error.exitCode);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
// Unexpected error - print and exit with code 1
|
|
98
|
+
console.error('Unexpected error:', error);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
})();
|
|
82
103
|
// Cleanup telemetry on exit
|
|
83
104
|
process.on('exit', () => {
|
|
84
105
|
telemetry_2.telemetry.shutdown().catch(() => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prpm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.11",
|
|
4
4
|
"description": "Prompt Package Manager CLI - Install and manage prompt-based files",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@octokit/rest": "^22.0.0",
|
|
48
|
-
"@pr-pm/registry-client": "^1.3.
|
|
49
|
-
"@pr-pm/types": "^0.2.
|
|
48
|
+
"@pr-pm/registry-client": "^1.3.9",
|
|
49
|
+
"@pr-pm/types": "^0.2.10",
|
|
50
50
|
"ajv": "^8.17.1",
|
|
51
51
|
"ajv-formats": "^3.0.1",
|
|
52
52
|
"commander": "^11.1.0",
|