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.
@@ -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
- initializePostHog() {
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
- return this.config.enabled;
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
- program.parse();
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.9",
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.7",
49
- "@pr-pm/types": "^0.2.8",
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",