pmpt-cli 1.10.0 → 1.11.0
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/commands/publish.js +45 -0
- package/dist/index.js +2 -0
- package/package.json +1 -1
package/dist/commands/publish.js
CHANGED
|
@@ -148,6 +148,8 @@ export async function cmdPublish(path, options) {
|
|
|
148
148
|
let description;
|
|
149
149
|
let tags;
|
|
150
150
|
let category;
|
|
151
|
+
let productUrl = '';
|
|
152
|
+
let productUrlType = '';
|
|
151
153
|
if (options?.nonInteractive) {
|
|
152
154
|
let metaFromFile = {};
|
|
153
155
|
if (options.metaFile) {
|
|
@@ -170,6 +172,8 @@ export async function cmdPublish(path, options) {
|
|
|
170
172
|
?? '').trim();
|
|
171
173
|
tags = normalizeTags(options.tags ?? metaFromFile.tags ?? existing?.tags ?? []);
|
|
172
174
|
category = String(options.category ?? metaFromFile.category ?? existing?.category ?? 'other').trim();
|
|
175
|
+
productUrl = String(options.productUrl ?? metaFromFile.productUrl ?? existing?.productUrl ?? '').trim();
|
|
176
|
+
productUrlType = String(options.productUrlType ?? metaFromFile.productUrlType ?? existing?.productUrlType ?? '').trim();
|
|
173
177
|
if (!/^[a-z0-9][a-z0-9-]{1,48}[a-z0-9]$/.test(slug)) {
|
|
174
178
|
p.log.error('Invalid slug. Use 3-50 chars, lowercase letters, numbers, and hyphens only.');
|
|
175
179
|
process.exit(1);
|
|
@@ -230,6 +234,45 @@ export async function cmdPublish(path, options) {
|
|
|
230
234
|
process.exit(0);
|
|
231
235
|
}
|
|
232
236
|
category = categoryInput;
|
|
237
|
+
// Product link (optional)
|
|
238
|
+
const linkTypeInput = await p.select({
|
|
239
|
+
message: 'Product link (optional):',
|
|
240
|
+
initialValue: existing?.productUrlType || 'none',
|
|
241
|
+
options: [
|
|
242
|
+
{ value: 'none', label: 'No link' },
|
|
243
|
+
{ value: 'git', label: 'Git Repository' },
|
|
244
|
+
{ value: 'url', label: 'Website / URL' },
|
|
245
|
+
],
|
|
246
|
+
});
|
|
247
|
+
if (p.isCancel(linkTypeInput)) {
|
|
248
|
+
p.cancel('Cancelled');
|
|
249
|
+
process.exit(0);
|
|
250
|
+
}
|
|
251
|
+
if (linkTypeInput !== 'none') {
|
|
252
|
+
productUrlType = linkTypeInput;
|
|
253
|
+
const productUrlInput = await p.text({
|
|
254
|
+
message: 'Product URL:',
|
|
255
|
+
placeholder: linkTypeInput === 'git'
|
|
256
|
+
? `https://github.com/${auth.username}/${slug}`
|
|
257
|
+
: 'https://...',
|
|
258
|
+
defaultValue: existing?.productUrl || '',
|
|
259
|
+
validate: (v) => {
|
|
260
|
+
if (!v.trim())
|
|
261
|
+
return 'URL is required when link type is selected.';
|
|
262
|
+
try {
|
|
263
|
+
new URL(v);
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
return 'Invalid URL format.';
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
});
|
|
270
|
+
if (p.isCancel(productUrlInput)) {
|
|
271
|
+
p.cancel('Cancelled');
|
|
272
|
+
process.exit(0);
|
|
273
|
+
}
|
|
274
|
+
productUrl = productUrlInput;
|
|
275
|
+
}
|
|
233
276
|
}
|
|
234
277
|
// Build .pmpt content (resolve from optimized snapshots)
|
|
235
278
|
const history = snapshots.map((snapshot, i) => ({
|
|
@@ -265,6 +308,7 @@ export async function cmdPublish(path, options) {
|
|
|
265
308
|
`Author: @${auth.username}`,
|
|
266
309
|
`Category: ${category}`,
|
|
267
310
|
tags.length ? `Tags: ${tags.join(', ')}` : '',
|
|
311
|
+
productUrl ? `Product: ${productUrl} (${productUrlType})` : '',
|
|
268
312
|
].filter(Boolean).join('\n'), 'Publish Preview');
|
|
269
313
|
if (options?.nonInteractive) {
|
|
270
314
|
if (!options.yes) {
|
|
@@ -292,6 +336,7 @@ export async function cmdPublish(path, options) {
|
|
|
292
336
|
description,
|
|
293
337
|
tags,
|
|
294
338
|
category,
|
|
339
|
+
...(productUrl && { productUrl, productUrlType }),
|
|
295
340
|
});
|
|
296
341
|
s.stop('Published!');
|
|
297
342
|
// Update config
|
package/dist/index.js
CHANGED
|
@@ -140,6 +140,8 @@ program
|
|
|
140
140
|
.option('--description <text>', 'Project description')
|
|
141
141
|
.option('--tags <csv>', 'Comma-separated tags')
|
|
142
142
|
.option('--category <id>', 'Project category')
|
|
143
|
+
.option('--product-url <url>', 'Product link URL')
|
|
144
|
+
.option('--product-url-type <type>', 'Product link type: git or url')
|
|
143
145
|
.option('--yes', 'Skip confirmation prompt')
|
|
144
146
|
.action(cmdPublish);
|
|
145
147
|
program
|