zdev 0.2.0 ā 0.2.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/dist/index.js +35 -6
- package/package.json +1 -1
- package/src/commands/pr.ts +43 -10
package/dist/index.js
CHANGED
|
@@ -3139,25 +3139,54 @@ async function pr(featureName, projectPath = ".", options = {}) {
|
|
|
3139
3139
|
} else {
|
|
3140
3140
|
console.log(` Pushed to origin/${branch}`);
|
|
3141
3141
|
}
|
|
3142
|
+
const defaultBranch = run("git", ["symbolic-ref", "refs/remotes/origin/HEAD", "--short"], { cwd: worktreePath });
|
|
3143
|
+
const baseBranch = defaultBranch.success ? defaultBranch.stdout.trim().replace("origin/", "") : "main";
|
|
3144
|
+
const commitsResult = run("git", ["log", `origin/${baseBranch}..HEAD`, "--pretty=format:%s"], { cwd: worktreePath });
|
|
3145
|
+
const commits = commitsResult.success ? commitsResult.stdout.trim().split(`
|
|
3146
|
+
`).filter(Boolean) : [];
|
|
3147
|
+
const filesResult = run("git", ["diff", `origin/${baseBranch}..HEAD`, "--stat", "--stat-width=60"], { cwd: worktreePath });
|
|
3148
|
+
const filesSummary = filesResult.success ? filesResult.stdout.trim() : "";
|
|
3149
|
+
const diffStatResult = run("git", ["diff", `origin/${baseBranch}..HEAD`, "--shortstat"], { cwd: worktreePath });
|
|
3150
|
+
const diffStat = diffStatResult.success ? diffStatResult.stdout.trim() : "";
|
|
3142
3151
|
let title = options.title;
|
|
3143
3152
|
if (!title) {
|
|
3144
|
-
|
|
3145
|
-
|
|
3153
|
+
if (commits.length > 0) {
|
|
3154
|
+
title = commits[0];
|
|
3155
|
+
} else {
|
|
3156
|
+
const featureForTitle = featureName || branch.replace(/^feature\//, "");
|
|
3157
|
+
title = featureForTitle.split(/[-_]/).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
3158
|
+
}
|
|
3146
3159
|
}
|
|
3147
3160
|
let body = options.body || "";
|
|
3148
3161
|
if (allocation && allocation.publicUrl) {
|
|
3149
|
-
|
|
3162
|
+
body += `## Preview
|
|
3150
3163
|
\uD83D\uDD17 ${allocation.publicUrl}
|
|
3151
3164
|
|
|
3152
3165
|
`;
|
|
3153
|
-
body = previewSection + body;
|
|
3154
3166
|
} else if (config.devDomain && featureName && projectName) {
|
|
3155
3167
|
const previewUrl = `https://${projectName}-${featureName}.${config.devDomain}`;
|
|
3156
|
-
|
|
3168
|
+
body += `## Preview
|
|
3157
3169
|
\uD83D\uDD17 ${previewUrl}
|
|
3158
3170
|
|
|
3159
3171
|
`;
|
|
3160
|
-
|
|
3172
|
+
}
|
|
3173
|
+
if (commits.length > 0) {
|
|
3174
|
+
body += `## Changes
|
|
3175
|
+
`;
|
|
3176
|
+
commits.forEach((commit) => {
|
|
3177
|
+
body += `- ${commit}
|
|
3178
|
+
`;
|
|
3179
|
+
});
|
|
3180
|
+
body += `
|
|
3181
|
+
`;
|
|
3182
|
+
}
|
|
3183
|
+
if (diffStat) {
|
|
3184
|
+
body += `## Summary
|
|
3185
|
+
\`\`\`
|
|
3186
|
+
${diffStat}
|
|
3187
|
+
\`\`\`
|
|
3188
|
+
|
|
3189
|
+
`;
|
|
3161
3190
|
}
|
|
3162
3191
|
if (!body.includes("Created with zdev")) {
|
|
3163
3192
|
body = body.trim() + `
|
package/package.json
CHANGED
package/src/commands/pr.ts
CHANGED
|
@@ -104,15 +104,36 @@ export async function pr(
|
|
|
104
104
|
console.log(` Pushed to origin/${branch}`);
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
// Get base branch for comparison
|
|
108
|
+
const defaultBranch = run("git", ["symbolic-ref", "refs/remotes/origin/HEAD", "--short"], { cwd: worktreePath });
|
|
109
|
+
const baseBranch = defaultBranch.success ? defaultBranch.stdout.trim().replace("origin/", "") : "main";
|
|
110
|
+
|
|
111
|
+
// Get commits since base branch
|
|
112
|
+
const commitsResult = run("git", ["log", `origin/${baseBranch}..HEAD`, "--pretty=format:%s"], { cwd: worktreePath });
|
|
113
|
+
const commits = commitsResult.success ? commitsResult.stdout.trim().split("\n").filter(Boolean) : [];
|
|
114
|
+
|
|
115
|
+
// Get files changed
|
|
116
|
+
const filesResult = run("git", ["diff", `origin/${baseBranch}..HEAD`, "--stat", "--stat-width=60"], { cwd: worktreePath });
|
|
117
|
+
const filesSummary = filesResult.success ? filesResult.stdout.trim() : "";
|
|
118
|
+
|
|
119
|
+
// Get short diff summary
|
|
120
|
+
const diffStatResult = run("git", ["diff", `origin/${baseBranch}..HEAD`, "--shortstat"], { cwd: worktreePath });
|
|
121
|
+
const diffStat = diffStatResult.success ? diffStatResult.stdout.trim() : "";
|
|
122
|
+
|
|
107
123
|
// Build PR title
|
|
108
124
|
let title = options.title;
|
|
109
125
|
if (!title) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.
|
|
126
|
+
if (commits.length > 0) {
|
|
127
|
+
// Use first commit message as title
|
|
128
|
+
title = commits[0];
|
|
129
|
+
} else {
|
|
130
|
+
// Fallback to feature name
|
|
131
|
+
const featureForTitle = featureName || branch.replace(/^feature\//, "");
|
|
132
|
+
title = featureForTitle
|
|
133
|
+
.split(/[-_]/)
|
|
134
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
135
|
+
.join(" ");
|
|
136
|
+
}
|
|
116
137
|
}
|
|
117
138
|
|
|
118
139
|
// Build PR body
|
|
@@ -120,13 +141,25 @@ export async function pr(
|
|
|
120
141
|
|
|
121
142
|
// Add preview URL if we have allocation
|
|
122
143
|
if (allocation && allocation.publicUrl) {
|
|
123
|
-
|
|
124
|
-
body = previewSection + body;
|
|
144
|
+
body += `## Preview\nš ${allocation.publicUrl}\n\n`;
|
|
125
145
|
} else if (config.devDomain && featureName && projectName) {
|
|
126
146
|
// Try to construct preview URL
|
|
127
147
|
const previewUrl = `https://${projectName}-${featureName}.${config.devDomain}`;
|
|
128
|
-
|
|
129
|
-
|
|
148
|
+
body += `## Preview\nš ${previewUrl}\n\n`;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// Add commits section if we have commits
|
|
152
|
+
if (commits.length > 0) {
|
|
153
|
+
body += `## Changes\n`;
|
|
154
|
+
commits.forEach((commit) => {
|
|
155
|
+
body += `- ${commit}\n`;
|
|
156
|
+
});
|
|
157
|
+
body += "\n";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// Add files changed
|
|
161
|
+
if (diffStat) {
|
|
162
|
+
body += `## Summary\n\`\`\`\n${diffStat}\n\`\`\`\n\n`;
|
|
130
163
|
}
|
|
131
164
|
|
|
132
165
|
// Add footer
|