skillsets 0.4.6 → 0.4.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.
- package/dist/commands/submit.js +27 -31
- package/package.json +1 -1
package/dist/commands/submit.js
CHANGED
|
@@ -204,13 +204,25 @@ export async function submit() {
|
|
|
204
204
|
if (pushResult.status !== 0) {
|
|
205
205
|
throw new Error(pushResult.stderr || 'Failed to push to fork');
|
|
206
206
|
}
|
|
207
|
-
//
|
|
208
|
-
spinner.text = '
|
|
209
|
-
const
|
|
210
|
-
|
|
211
|
-
:
|
|
212
|
-
|
|
213
|
-
|
|
207
|
+
// Check if PR already exists for this branch (force push already updated it)
|
|
208
|
+
spinner.text = 'Checking for existing pull request...';
|
|
209
|
+
const existingPr = spawnSync('gh', ['pr', 'list', '--repo', REGISTRY_REPO, '--head', `${username}:${branchName}`, '--json', 'url', '--jq', '.[0].url', '--state', 'open', '--limit', '1'], {
|
|
210
|
+
cwd: tempDir,
|
|
211
|
+
encoding: 'utf-8',
|
|
212
|
+
});
|
|
213
|
+
let prUrl;
|
|
214
|
+
if (existingPr.status === 0 && existingPr.stdout.trim()) {
|
|
215
|
+
// PR exists — force push already updated the branch, nothing else to do
|
|
216
|
+
prUrl = existingPr.stdout.trim();
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
// Create new PR
|
|
220
|
+
spinner.text = 'Creating pull request...';
|
|
221
|
+
const prTitle = isUpdate
|
|
222
|
+
? `Update ${skillsetId} to v${skillset.version}`
|
|
223
|
+
: `Add ${skillsetId}`;
|
|
224
|
+
const prBody = isUpdate
|
|
225
|
+
? `## Skillset Update
|
|
214
226
|
|
|
215
227
|
**Skillset:** ${skillsetId}
|
|
216
228
|
**Version:** ${existingVersion} → ${skillset.version}
|
|
@@ -230,7 +242,7 @@ _Describe what changed in this version._
|
|
|
230
242
|
---
|
|
231
243
|
Submitted via \`npx skillsets submit\`
|
|
232
244
|
`
|
|
233
|
-
|
|
245
|
+
: `## New Skillset Submission
|
|
234
246
|
|
|
235
247
|
**Skillset:** ${skillsetId}
|
|
236
248
|
**Version:** ${skillset.version}
|
|
@@ -251,36 +263,20 @@ _Add any additional context for reviewers here._
|
|
|
251
263
|
---
|
|
252
264
|
Submitted via \`npx skillsets submit\`
|
|
253
265
|
`;
|
|
254
|
-
|
|
255
|
-
const existingPr = spawnSync('gh', ['pr', 'list', '--repo', REGISTRY_REPO, '--head', `${username}:${branchName}`, '--json', 'url', '--jq', '.[0].url', '--state', 'open', '--limit', '1'], {
|
|
256
|
-
cwd: tempDir,
|
|
257
|
-
encoding: 'utf-8',
|
|
258
|
-
});
|
|
259
|
-
let prResult;
|
|
260
|
-
if (existingPr.status === 0 && existingPr.stdout.trim()) {
|
|
261
|
-
// PR exists — force push already updated it, just edit title/body
|
|
262
|
-
prResult = spawnSync('gh', ['pr', 'edit', '--repo', REGISTRY_REPO, existingPr.stdout.trim(), '--title', prTitle, '--body', prBody], {
|
|
266
|
+
const prResult = spawnSync('gh', ['pr', 'create', '--repo', REGISTRY_REPO, '--head', `${username}:${branchName}`, '--title', prTitle, '--body', prBody], {
|
|
263
267
|
cwd: tempDir,
|
|
264
268
|
encoding: 'utf-8',
|
|
265
269
|
});
|
|
266
|
-
prResult.
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
prResult = spawnSync('gh', ['pr', 'create', '--repo', REGISTRY_REPO, '--head', `${username}:${branchName}`, '--title', prTitle, '--body', prBody], {
|
|
271
|
-
cwd: tempDir,
|
|
272
|
-
encoding: 'utf-8',
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
if (prResult.status !== 0) {
|
|
276
|
-
throw new Error(prResult.stderr || 'Failed to create PR');
|
|
270
|
+
if (prResult.status !== 0) {
|
|
271
|
+
throw new Error(prResult.stderr || 'Failed to create PR');
|
|
272
|
+
}
|
|
273
|
+
prUrl = (prResult.stdout || '').trim();
|
|
277
274
|
}
|
|
278
275
|
// Cleanup
|
|
279
276
|
spinner.text = 'Cleaning up...';
|
|
280
277
|
rmSync(tempDir, { recursive: true, force: true });
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
const prUrl = (prResult.stdout || '').trim();
|
|
278
|
+
const prExisted = existingPr.status === 0 && existingPr.stdout.trim();
|
|
279
|
+
spinner.succeed(prExisted ? 'Pull request updated' : 'Pull request created');
|
|
284
280
|
console.log(chalk.green(`\n✓ ${isUpdate ? 'Update' : 'Submission'} complete!\n`));
|
|
285
281
|
console.log(` Skillset: ${chalk.bold(skillsetId)}`);
|
|
286
282
|
if (isUpdate) {
|