prpm 0.0.5 → 0.0.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.
@@ -115,6 +115,7 @@ async function loginWithOAuth(registryUrl) {
115
115
  const userId = `cli_${Date.now()}_${Math.random().toString(36).substr(2, 9)}`;
116
116
  try {
117
117
  // Get the Nango connect session from the registry
118
+ console.log(` Connecting to: ${registryUrl}`);
118
119
  const response = await fetch(`${registryUrl}/api/v1/auth/nango/cli/connect-session`, {
119
120
  method: 'POST',
120
121
  headers: {
@@ -127,7 +128,8 @@ async function loginWithOAuth(registryUrl) {
127
128
  }),
128
129
  });
129
130
  if (!response.ok) {
130
- throw new Error('Failed to get authentication session');
131
+ const errorText = await response.text().catch(() => 'Unable to read error response');
132
+ throw new Error(`Failed to get authentication session (${response.status}): ${errorText}`);
131
133
  }
132
134
  const responseData = await response.json();
133
135
  const { connectSessionToken } = responseData;
@@ -138,7 +140,10 @@ async function loginWithOAuth(registryUrl) {
138
140
  }
139
141
  // Create the CLI auth URL with session token, callback, and userId
140
142
  const callbackUrl = 'http://localhost:8765/callback';
141
- const webappUrl = registryUrl.replace('registry', 'webapp').replace(':3000', ':5173');
143
+ // Determine webapp URL - default to production
144
+ const webappUrl = registryUrl.includes('localhost')
145
+ ? registryUrl.replace(':3000', ':5173') // Local: localhost:3000 → localhost:5173
146
+ : 'https://prpm.dev'; // Production: always use prpm.dev
142
147
  const authUrl = `${webappUrl}/cli-auth?sessionToken=${encodeURIComponent(connectSessionToken)}&cliCallback=${encodeURIComponent(callbackUrl)}&userId=${encodeURIComponent(userId)}`;
143
148
  console.log(` Please open this link in your browser to authenticate:`);
144
149
  console.log(` ${authUrl}\n`);
@@ -156,6 +161,15 @@ async function loginWithOAuth(registryUrl) {
156
161
  return { token: result.token, username: result.username || 'unknown' };
157
162
  }
158
163
  catch (error) {
164
+ if (error instanceof Error) {
165
+ // Check for common network errors
166
+ if (error.message.includes('ECONNREFUSED')) {
167
+ throw new Error(`Cannot connect to registry at ${registryUrl}. Is the registry running?`);
168
+ }
169
+ else if (error.message.includes('ENOTFOUND') || error.message.includes('getaddrinfo')) {
170
+ throw new Error(`Cannot resolve registry hostname: ${registryUrl}. Check your internet connection.`);
171
+ }
172
+ }
159
173
  throw new Error(`Authentication failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
160
174
  }
161
175
  }
@@ -172,22 +186,15 @@ async function pollForAuthentication(registryUrl, userId) {
172
186
  const { authenticated, connectionId } = await response.json();
173
187
  if (authenticated && connectionId) {
174
188
  // Authentication completed, get the JWT token
175
- const callbackResponse = await fetch(`${registryUrl}/api/v1/auth/nango/callback`, {
176
- method: 'POST',
177
- headers: {
178
- 'Content-Type': 'application/json',
179
- },
180
- body: JSON.stringify({
181
- connectionId,
182
- redirectUrl: '/cli-success',
183
- }),
184
- });
185
- if (callbackResponse.ok) {
186
- const result = await callbackResponse.json();
187
- return {
188
- token: result.token,
189
- username: result.username,
190
- };
189
+ const statusResponse = await fetch(`${registryUrl}/api/v1/auth/nango/status/${connectionId}`);
190
+ if (statusResponse.ok) {
191
+ const result = await statusResponse.json();
192
+ if (result.ready && result.token) {
193
+ return {
194
+ token: result.token,
195
+ username: result.username,
196
+ };
197
+ }
191
198
  }
192
199
  }
193
200
  }
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ const program = new commander_1.Command();
26
26
  program
27
27
  .name('prpm')
28
28
  .description('Prompt Package Manager - Install and manage prompt-based files')
29
- .version('0.0.1');
29
+ .version(' run `npm fund` for details');
30
30
  // Registry commands (new)
31
31
  program.addCommand((0, search_1.createSearchCommand)());
32
32
  program.addCommand((0, install_1.createInstallCommand)());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prpm",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "description": "Prompt Package Manager CLI - Install and manage prompt-based files",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -41,8 +41,8 @@
41
41
  "license": "MIT",
42
42
  "dependencies": {
43
43
  "@octokit/rest": "^22.0.0",
44
- "@pr-pm/registry-client": "1.2.1",
45
- "@pr-pm/types": "^0.1.1",
44
+ "@pr-pm/registry-client": "^1.2.2",
45
+ "@pr-pm/types": "^0.1.2",
46
46
  "ajv": "^8.17.1",
47
47
  "ajv-formats": "^3.0.1",
48
48
  "commander": "^11.1.0",