prpm 0.0.1
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/README.md +928 -0
- package/dist/commands/add.js +107 -0
- package/dist/commands/collections.js +409 -0
- package/dist/commands/deps.js +92 -0
- package/dist/commands/index.js +124 -0
- package/dist/commands/info.js +81 -0
- package/dist/commands/install.js +252 -0
- package/dist/commands/list.js +89 -0
- package/dist/commands/login.js +219 -0
- package/dist/commands/outdated.js +127 -0
- package/dist/commands/popular.js +27 -0
- package/dist/commands/publish.js +217 -0
- package/dist/commands/remove.js +43 -0
- package/dist/commands/search.js +179 -0
- package/dist/commands/telemetry.js +103 -0
- package/dist/commands/trending.js +75 -0
- package/dist/commands/update.js +120 -0
- package/dist/commands/upgrade.js +120 -0
- package/dist/commands/whoami.js +51 -0
- package/dist/core/config.js +91 -0
- package/dist/core/downloader.js +64 -0
- package/dist/core/filesystem.js +94 -0
- package/dist/core/lockfile.js +182 -0
- package/dist/core/registry-client.js +265 -0
- package/dist/core/telemetry.js +170 -0
- package/dist/core/user-config.js +79 -0
- package/dist/index.js +69 -0
- package/dist/types.js +5 -0
- package/package.json +67 -0
|
@@ -0,0 +1,170 @@
|
|
|
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
|
+
exports.telemetry = void 0;
|
|
7
|
+
const fs_1 = require("fs");
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const posthog_node_1 = require("posthog-node");
|
|
11
|
+
class Telemetry {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.events = [];
|
|
14
|
+
this.maxEvents = 100; // Keep only last 100 events locally
|
|
15
|
+
this.posthog = null;
|
|
16
|
+
this.configPath = path_1.default.join(os_1.default.homedir(), '.prpm', 'telemetry.json');
|
|
17
|
+
this.config = this.loadConfig();
|
|
18
|
+
this.initializePostHog();
|
|
19
|
+
}
|
|
20
|
+
initializePostHog() {
|
|
21
|
+
try {
|
|
22
|
+
this.posthog = new posthog_node_1.PostHog('phc_aO5lXLILeylHfb1ynszVwKbQKSzO91UGdXNhN5Q0Snl', {
|
|
23
|
+
host: 'https://app.posthog.com',
|
|
24
|
+
flushAt: 1, // Send events immediately
|
|
25
|
+
flushInterval: 0, // No batching
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
this.posthog = null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
loadConfig() {
|
|
33
|
+
try {
|
|
34
|
+
const data = require(this.configPath);
|
|
35
|
+
return {
|
|
36
|
+
enabled: data.enabled ?? true, // Default to enabled
|
|
37
|
+
userId: data.userId,
|
|
38
|
+
sessionId: data.sessionId || this.generateSessionId(),
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return {
|
|
43
|
+
enabled: true,
|
|
44
|
+
sessionId: this.generateSessionId(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
generateSessionId() {
|
|
49
|
+
return Math.random().toString(36).substring(2, 15) +
|
|
50
|
+
Math.random().toString(36).substring(2, 15);
|
|
51
|
+
}
|
|
52
|
+
async saveConfig() {
|
|
53
|
+
try {
|
|
54
|
+
await fs_1.promises.mkdir(path_1.default.dirname(this.configPath), { recursive: true });
|
|
55
|
+
await fs_1.promises.writeFile(this.configPath, JSON.stringify(this.config, null, 2));
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
// Silently fail - telemetry shouldn't break the CLI
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
async track(event) {
|
|
62
|
+
if (!this.config.enabled)
|
|
63
|
+
return;
|
|
64
|
+
const fullEvent = {
|
|
65
|
+
...event,
|
|
66
|
+
timestamp: new Date().toISOString(),
|
|
67
|
+
version: process.env.npm_package_version || '0.1.0',
|
|
68
|
+
platform: os_1.default.platform(),
|
|
69
|
+
arch: os_1.default.arch(),
|
|
70
|
+
nodeVersion: process.version,
|
|
71
|
+
};
|
|
72
|
+
this.events.push(fullEvent);
|
|
73
|
+
// Keep only the last maxEvents
|
|
74
|
+
if (this.events.length > this.maxEvents) {
|
|
75
|
+
this.events = this.events.slice(-this.maxEvents);
|
|
76
|
+
}
|
|
77
|
+
// Save events locally
|
|
78
|
+
await this.saveEvents();
|
|
79
|
+
// Send to analytics service (async, non-blocking)
|
|
80
|
+
this.sendToAnalytics(fullEvent).catch(() => {
|
|
81
|
+
// Silently fail - don't break the CLI
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
async saveEvents() {
|
|
85
|
+
try {
|
|
86
|
+
const eventsPath = path_1.default.join(os_1.default.homedir(), '.prpm', 'events.json');
|
|
87
|
+
await fs_1.promises.mkdir(path_1.default.dirname(eventsPath), { recursive: true });
|
|
88
|
+
await fs_1.promises.writeFile(eventsPath, JSON.stringify(this.events, null, 2));
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
// Silently fail
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async sendToAnalytics(event) {
|
|
95
|
+
// Send to PostHog
|
|
96
|
+
await this.sendToPostHog(event);
|
|
97
|
+
}
|
|
98
|
+
async enable() {
|
|
99
|
+
this.config.enabled = true;
|
|
100
|
+
await this.saveConfig();
|
|
101
|
+
}
|
|
102
|
+
async disable() {
|
|
103
|
+
this.config.enabled = false;
|
|
104
|
+
await this.saveConfig();
|
|
105
|
+
}
|
|
106
|
+
isEnabled() {
|
|
107
|
+
return this.config.enabled;
|
|
108
|
+
}
|
|
109
|
+
async getStats() {
|
|
110
|
+
try {
|
|
111
|
+
const eventsPath = path_1.default.join(os_1.default.homedir(), '.prpm', 'events.json');
|
|
112
|
+
const data = await fs_1.promises.readFile(eventsPath, 'utf8');
|
|
113
|
+
const savedEvents = JSON.parse(data);
|
|
114
|
+
return {
|
|
115
|
+
totalEvents: savedEvents.length,
|
|
116
|
+
lastEvent: savedEvents[savedEvents.length - 1]?.timestamp,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
return {
|
|
121
|
+
totalEvents: this.events.length,
|
|
122
|
+
lastEvent: this.events[this.events.length - 1]?.timestamp,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async shutdown() {
|
|
127
|
+
if (this.posthog) {
|
|
128
|
+
try {
|
|
129
|
+
await this.posthog.shutdown();
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
// Silently fail
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
// Send to PostHog
|
|
137
|
+
async sendToPostHog(event) {
|
|
138
|
+
if (!this.posthog)
|
|
139
|
+
return;
|
|
140
|
+
try {
|
|
141
|
+
const distinctId = this.config.userId || this.config.sessionId || 'anonymous';
|
|
142
|
+
this.posthog.capture({
|
|
143
|
+
distinctId,
|
|
144
|
+
event: `prpm_${event.command}`,
|
|
145
|
+
properties: {
|
|
146
|
+
// Core event data
|
|
147
|
+
command: event.command,
|
|
148
|
+
success: event.success,
|
|
149
|
+
duration: event.duration,
|
|
150
|
+
error: event.error,
|
|
151
|
+
// System information
|
|
152
|
+
version: event.version,
|
|
153
|
+
platform: event.platform,
|
|
154
|
+
arch: event.arch,
|
|
155
|
+
nodeVersion: event.nodeVersion,
|
|
156
|
+
// Command-specific data
|
|
157
|
+
...event.data,
|
|
158
|
+
// Metadata
|
|
159
|
+
timestamp: event.timestamp,
|
|
160
|
+
sessionId: this.config.sessionId,
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
// Event sent to PostHog
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
// Silently fail - don't break the CLI
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.telemetry = new Telemetry();
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* User configuration management for ~/.prpmrc
|
|
4
|
+
* Stores global settings like registry URL and authentication token
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.getConfig = getConfig;
|
|
8
|
+
exports.saveConfig = saveConfig;
|
|
9
|
+
exports.updateConfig = updateConfig;
|
|
10
|
+
exports.clearAuth = clearAuth;
|
|
11
|
+
exports.getRegistryUrl = getRegistryUrl;
|
|
12
|
+
const fs_1 = require("fs");
|
|
13
|
+
const path_1 = require("path");
|
|
14
|
+
const os_1 = require("os");
|
|
15
|
+
const CONFIG_FILE = (0, path_1.join)((0, os_1.homedir)(), '.prpmrc');
|
|
16
|
+
const DEFAULT_REGISTRY_URL = 'https://registry.prpm.dev';
|
|
17
|
+
/**
|
|
18
|
+
* Get user configuration
|
|
19
|
+
*/
|
|
20
|
+
async function getConfig() {
|
|
21
|
+
try {
|
|
22
|
+
const data = await fs_1.promises.readFile(CONFIG_FILE, 'utf-8');
|
|
23
|
+
const config = JSON.parse(data);
|
|
24
|
+
// Allow environment variable to override registry URL
|
|
25
|
+
if (process.env.PRPM_REGISTRY_URL) {
|
|
26
|
+
config.registryUrl = process.env.PRPM_REGISTRY_URL;
|
|
27
|
+
}
|
|
28
|
+
else if (!config.registryUrl) {
|
|
29
|
+
config.registryUrl = DEFAULT_REGISTRY_URL;
|
|
30
|
+
}
|
|
31
|
+
return config;
|
|
32
|
+
}
|
|
33
|
+
catch (error) {
|
|
34
|
+
// If file doesn't exist, return default config
|
|
35
|
+
if (error.code === 'ENOENT') {
|
|
36
|
+
return {
|
|
37
|
+
registryUrl: process.env.PRPM_REGISTRY_URL || DEFAULT_REGISTRY_URL,
|
|
38
|
+
telemetryEnabled: true,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
throw new Error(`Failed to read user config: ${error}`);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Save user configuration
|
|
46
|
+
*/
|
|
47
|
+
async function saveConfig(config) {
|
|
48
|
+
try {
|
|
49
|
+
const data = JSON.stringify(config, null, 2);
|
|
50
|
+
await fs_1.promises.writeFile(CONFIG_FILE, data, 'utf-8');
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
throw new Error(`Failed to save user config: ${error}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Update specific config values
|
|
58
|
+
*/
|
|
59
|
+
async function updateConfig(updates) {
|
|
60
|
+
const config = await getConfig();
|
|
61
|
+
const newConfig = { ...config, ...updates };
|
|
62
|
+
await saveConfig(newConfig);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Clear authentication (logout)
|
|
66
|
+
*/
|
|
67
|
+
async function clearAuth() {
|
|
68
|
+
const config = await getConfig();
|
|
69
|
+
delete config.token;
|
|
70
|
+
delete config.username;
|
|
71
|
+
await saveConfig(config);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Get registry URL (with fallback to default)
|
|
75
|
+
*/
|
|
76
|
+
async function getRegistryUrl() {
|
|
77
|
+
const config = await getConfig();
|
|
78
|
+
return config.registryUrl || DEFAULT_REGISTRY_URL;
|
|
79
|
+
}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* Prompt Package Manager CLI entry point
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const commander_1 = require("commander");
|
|
8
|
+
const add_1 = require("./commands/add");
|
|
9
|
+
const list_1 = require("./commands/list");
|
|
10
|
+
const remove_1 = require("./commands/remove");
|
|
11
|
+
const index_1 = require("./commands/index");
|
|
12
|
+
const telemetry_1 = require("./commands/telemetry");
|
|
13
|
+
const search_1 = require("./commands/search");
|
|
14
|
+
const info_1 = require("./commands/info");
|
|
15
|
+
const install_1 = require("./commands/install");
|
|
16
|
+
const trending_1 = require("./commands/trending");
|
|
17
|
+
const publish_1 = require("./commands/publish");
|
|
18
|
+
const login_1 = require("./commands/login");
|
|
19
|
+
const whoami_1 = require("./commands/whoami");
|
|
20
|
+
const collections_1 = require("./commands/collections");
|
|
21
|
+
const deps_1 = require("./commands/deps");
|
|
22
|
+
const outdated_1 = require("./commands/outdated");
|
|
23
|
+
const update_1 = require("./commands/update");
|
|
24
|
+
const upgrade_1 = require("./commands/upgrade");
|
|
25
|
+
const telemetry_2 = require("./core/telemetry");
|
|
26
|
+
const program = new commander_1.Command();
|
|
27
|
+
program
|
|
28
|
+
.name('prpm')
|
|
29
|
+
.description('Prompt Package Manager - Install and manage prompt-based files')
|
|
30
|
+
.version('1.2.0');
|
|
31
|
+
// Registry commands (new)
|
|
32
|
+
program.addCommand((0, search_1.createSearchCommand)());
|
|
33
|
+
program.addCommand((0, install_1.createInstallCommand)());
|
|
34
|
+
program.addCommand((0, info_1.createInfoCommand)());
|
|
35
|
+
program.addCommand((0, trending_1.createTrendingCommand)());
|
|
36
|
+
program.addCommand((0, publish_1.createPublishCommand)());
|
|
37
|
+
program.addCommand((0, login_1.createLoginCommand)());
|
|
38
|
+
program.addCommand((0, whoami_1.createWhoamiCommand)());
|
|
39
|
+
program.addCommand((0, collections_1.createCollectionsCommand)());
|
|
40
|
+
program.addCommand((0, deps_1.createDepsCommand)());
|
|
41
|
+
program.addCommand((0, outdated_1.createOutdatedCommand)());
|
|
42
|
+
program.addCommand((0, update_1.createUpdateCommand)());
|
|
43
|
+
program.addCommand((0, upgrade_1.createUpgradeCommand)());
|
|
44
|
+
// Local file commands (existing)
|
|
45
|
+
program.addCommand((0, add_1.createAddCommand)());
|
|
46
|
+
program.addCommand((0, list_1.createListCommand)());
|
|
47
|
+
program.addCommand((0, remove_1.createRemoveCommand)());
|
|
48
|
+
program.addCommand((0, index_1.createIndexCommand)());
|
|
49
|
+
program.addCommand((0, telemetry_1.createTelemetryCommand)());
|
|
50
|
+
// Parse command line arguments
|
|
51
|
+
program.parse();
|
|
52
|
+
// Cleanup telemetry on exit
|
|
53
|
+
process.on('exit', () => {
|
|
54
|
+
telemetry_2.telemetry.shutdown().catch(() => {
|
|
55
|
+
// Silently fail
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
process.on('SIGINT', () => {
|
|
59
|
+
telemetry_2.telemetry.shutdown().catch(() => {
|
|
60
|
+
// Silently fail
|
|
61
|
+
});
|
|
62
|
+
process.exit(0);
|
|
63
|
+
});
|
|
64
|
+
process.on('SIGTERM', () => {
|
|
65
|
+
telemetry_2.telemetry.shutdown().catch(() => {
|
|
66
|
+
// Silently fail
|
|
67
|
+
});
|
|
68
|
+
process.exit(0);
|
|
69
|
+
});
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "prpm",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Prompt Package Manager CLI - Install and manage prompt-based files",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"prpm": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"dev": "ts-node src/index.ts",
|
|
12
|
+
"start": "node dist/index.js",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"test:watch": "jest --watch",
|
|
15
|
+
"test:coverage": "jest --coverage",
|
|
16
|
+
"test:ci": "jest --ci --coverage --watchAll=false",
|
|
17
|
+
"build:binary": "mkdir -p ../../binaries && pkg dist/index.js --targets node18-macos-x64,node18-macos-arm64,node18-linux-x64,node18-win-x64 --output ../../binaries/prpm",
|
|
18
|
+
"prepublishOnly": "npm run build"
|
|
19
|
+
},
|
|
20
|
+
"keywords": [
|
|
21
|
+
"cursor",
|
|
22
|
+
"claude",
|
|
23
|
+
"prompts",
|
|
24
|
+
"cli",
|
|
25
|
+
"package-manager"
|
|
26
|
+
],
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/khaliqgant/prompt-package-manager.git",
|
|
30
|
+
"directory": "packages/cli"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/khaliqgant/prompt-package-manager/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/khaliqgant/prompt-package-manager#readme",
|
|
36
|
+
"author": "khaliqgant",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@prpm/registry-client": "^1.2.0",
|
|
40
|
+
"@octokit/rest": "^22.0.0",
|
|
41
|
+
"commander": "^11.1.0",
|
|
42
|
+
"posthog-node": "^3.0.0",
|
|
43
|
+
"tar": "^6.2.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/jest": "^29.5.8",
|
|
47
|
+
"@types/node": "^20.10.0",
|
|
48
|
+
"@types/tar": "^6.1.13",
|
|
49
|
+
"jest": "^29.7.0",
|
|
50
|
+
"pkg": "^5.8.1",
|
|
51
|
+
"ts-jest": "^29.1.1",
|
|
52
|
+
"ts-node": "^10.9.1",
|
|
53
|
+
"typescript": "^5.3.2"
|
|
54
|
+
},
|
|
55
|
+
"engines": {
|
|
56
|
+
"node": ">=16.0.0"
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist",
|
|
60
|
+
"README.md",
|
|
61
|
+
"LICENSE"
|
|
62
|
+
],
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public",
|
|
65
|
+
"registry": "https://registry.npmjs.org/"
|
|
66
|
+
}
|
|
67
|
+
}
|