all-hands-cli 0.1.10 → 0.1.11
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/bin/sync-cli.js +29 -11
- package/package.json +1 -1
- package/src/commands/push.ts +33 -13
package/bin/sync-cli.js
CHANGED
|
@@ -7245,6 +7245,16 @@ function collectFilesToPush(cwd, finalIncludes, finalExcludes) {
|
|
|
7245
7245
|
const upstreamFiles = manifest.getDistributableFiles();
|
|
7246
7246
|
const filesToPush = [];
|
|
7247
7247
|
const localGitFiles = new Set(getGitFiles(cwd));
|
|
7248
|
+
const deletedFiles = /* @__PURE__ */ new Set();
|
|
7249
|
+
for (const args of [
|
|
7250
|
+
["diff", "--name-only", "--diff-filter=D"],
|
|
7251
|
+
["diff", "--cached", "--name-only", "--diff-filter=D"]
|
|
7252
|
+
]) {
|
|
7253
|
+
const result = git(args, cwd);
|
|
7254
|
+
if (result.success && result.stdout) {
|
|
7255
|
+
result.stdout.split("\n").filter(Boolean).forEach((f) => deletedFiles.add(f));
|
|
7256
|
+
}
|
|
7257
|
+
}
|
|
7248
7258
|
for (const relPath of upstreamFiles) {
|
|
7249
7259
|
if (manifest.isInitOnly(relPath)) {
|
|
7250
7260
|
continue;
|
|
@@ -7255,15 +7265,19 @@ function collectFilesToPush(cwd, finalIncludes, finalExcludes) {
|
|
|
7255
7265
|
if (finalExcludes.some((pattern) => minimatch(relPath, pattern, { dot: true }))) {
|
|
7256
7266
|
continue;
|
|
7257
7267
|
}
|
|
7258
|
-
if (!localGitFiles.has(relPath)) {
|
|
7268
|
+
if (!localGitFiles.has(relPath) && !deletedFiles.has(relPath)) {
|
|
7259
7269
|
continue;
|
|
7260
7270
|
}
|
|
7261
7271
|
const localFile = join9(cwd, relPath);
|
|
7262
7272
|
const upstreamFile = join9(allhandsRoot, relPath);
|
|
7263
|
-
if (existsSync11(localFile)
|
|
7264
|
-
if (
|
|
7265
|
-
|
|
7273
|
+
if (existsSync11(localFile)) {
|
|
7274
|
+
if (filesAreDifferent(localFile, upstreamFile)) {
|
|
7275
|
+
if (wasModifiedByTargetRepo(cwd, relPath, allhandsRoot)) {
|
|
7276
|
+
filesToPush.push({ path: relPath, type: "M" });
|
|
7277
|
+
}
|
|
7266
7278
|
}
|
|
7279
|
+
} else if (deletedFiles.has(relPath)) {
|
|
7280
|
+
filesToPush.push({ path: relPath, type: "D" });
|
|
7267
7281
|
}
|
|
7268
7282
|
}
|
|
7269
7283
|
for (const pattern of finalIncludes) {
|
|
@@ -7335,12 +7349,16 @@ async function createPullRequest(cwd, ghUser, filesToPush, title, body) {
|
|
|
7335
7349
|
console.error("Error creating branch:", checkoutResult.stderr);
|
|
7336
7350
|
return 1;
|
|
7337
7351
|
}
|
|
7338
|
-
console.log("
|
|
7352
|
+
console.log("Applying changes...");
|
|
7339
7353
|
for (const file of filesToPush) {
|
|
7340
|
-
|
|
7341
|
-
|
|
7342
|
-
|
|
7343
|
-
|
|
7354
|
+
if (file.type === "D") {
|
|
7355
|
+
git(["rm", "--ignore-unmatch", file.path], tempDir);
|
|
7356
|
+
} else {
|
|
7357
|
+
const src = join9(cwd, file.path);
|
|
7358
|
+
const dest = join9(tempDir, file.path);
|
|
7359
|
+
mkdirSync2(dirname8(dest), { recursive: true });
|
|
7360
|
+
copyFileSync2(src, dest);
|
|
7361
|
+
}
|
|
7344
7362
|
}
|
|
7345
7363
|
const addResult = git(["add", "."], tempDir);
|
|
7346
7364
|
if (!addResult.success) {
|
|
@@ -7409,8 +7427,8 @@ async function cmdPush(include, exclude, dryRun, titleArg, bodyArg) {
|
|
|
7409
7427
|
}
|
|
7410
7428
|
console.log("\nFiles to be included in PR:");
|
|
7411
7429
|
for (const file of filesToPush.sort((a, b) => a.path.localeCompare(b.path))) {
|
|
7412
|
-
const marker = file.type
|
|
7413
|
-
const label =
|
|
7430
|
+
const marker = file.type;
|
|
7431
|
+
const label = { D: "deleted", M: "modified", A: "included" }[file.type];
|
|
7414
7432
|
console.log(` ${marker} ${file.path} (${label})`);
|
|
7415
7433
|
}
|
|
7416
7434
|
console.log();
|
package/package.json
CHANGED
package/src/commands/push.ts
CHANGED
|
@@ -17,7 +17,7 @@ interface SyncConfig {
|
|
|
17
17
|
|
|
18
18
|
interface FileEntry {
|
|
19
19
|
path: string;
|
|
20
|
-
type: 'M' | 'A';
|
|
20
|
+
type: 'M' | 'A' | 'D';
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
interface PrerequisiteResult {
|
|
@@ -124,6 +124,18 @@ function collectFilesToPush(
|
|
|
124
124
|
// Get non-ignored files in user's repo (respects .gitignore)
|
|
125
125
|
const localGitFiles = new Set(getGitFiles(cwd));
|
|
126
126
|
|
|
127
|
+
// Get files deleted locally (both staged and unstaged deletions)
|
|
128
|
+
const deletedFiles = new Set<string>();
|
|
129
|
+
for (const args of [
|
|
130
|
+
['diff', '--name-only', '--diff-filter=D'],
|
|
131
|
+
['diff', '--cached', '--name-only', '--diff-filter=D'],
|
|
132
|
+
]) {
|
|
133
|
+
const result = git(args, cwd);
|
|
134
|
+
if (result.success && result.stdout) {
|
|
135
|
+
result.stdout.split('\n').filter(Boolean).forEach((f) => deletedFiles.add(f));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
127
139
|
for (const relPath of upstreamFiles) {
|
|
128
140
|
if (manifest.isInitOnly(relPath)) {
|
|
129
141
|
continue;
|
|
@@ -134,18 +146,22 @@ function collectFilesToPush(
|
|
|
134
146
|
if (finalExcludes.some((pattern) => minimatch(relPath, pattern, { dot: true }))) {
|
|
135
147
|
continue;
|
|
136
148
|
}
|
|
137
|
-
// Skip files that are gitignored in user's repo
|
|
138
|
-
if (!localGitFiles.has(relPath)) {
|
|
149
|
+
// Skip files that are gitignored in user's repo (but allow deleted files through)
|
|
150
|
+
if (!localGitFiles.has(relPath) && !deletedFiles.has(relPath)) {
|
|
139
151
|
continue;
|
|
140
152
|
}
|
|
141
153
|
|
|
142
154
|
const localFile = join(cwd, relPath);
|
|
143
155
|
const upstreamFile = join(allhandsRoot, relPath);
|
|
144
156
|
|
|
145
|
-
if (existsSync(localFile)
|
|
146
|
-
if (
|
|
147
|
-
|
|
157
|
+
if (existsSync(localFile)) {
|
|
158
|
+
if (filesAreDifferent(localFile, upstreamFile)) {
|
|
159
|
+
if (wasModifiedByTargetRepo(cwd, relPath, allhandsRoot)) {
|
|
160
|
+
filesToPush.push({ path: relPath, type: 'M' });
|
|
161
|
+
}
|
|
148
162
|
}
|
|
163
|
+
} else if (deletedFiles.has(relPath)) {
|
|
164
|
+
filesToPush.push({ path: relPath, type: 'D' });
|
|
149
165
|
}
|
|
150
166
|
}
|
|
151
167
|
|
|
@@ -239,12 +255,16 @@ async function createPullRequest(
|
|
|
239
255
|
return 1;
|
|
240
256
|
}
|
|
241
257
|
|
|
242
|
-
console.log('
|
|
258
|
+
console.log('Applying changes...');
|
|
243
259
|
for (const file of filesToPush) {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
260
|
+
if (file.type === 'D') {
|
|
261
|
+
git(['rm', '--ignore-unmatch', file.path], tempDir);
|
|
262
|
+
} else {
|
|
263
|
+
const src = join(cwd, file.path);
|
|
264
|
+
const dest = join(tempDir, file.path);
|
|
265
|
+
mkdirSync(dirname(dest), { recursive: true });
|
|
266
|
+
copyFileSync(src, dest);
|
|
267
|
+
}
|
|
248
268
|
}
|
|
249
269
|
|
|
250
270
|
const addResult = git(['add', '.'], tempDir);
|
|
@@ -328,8 +348,8 @@ export async function cmdPush(
|
|
|
328
348
|
|
|
329
349
|
console.log('\nFiles to be included in PR:');
|
|
330
350
|
for (const file of filesToPush.sort((a, b) => a.path.localeCompare(b.path))) {
|
|
331
|
-
const marker = file.type
|
|
332
|
-
const label =
|
|
351
|
+
const marker = file.type;
|
|
352
|
+
const label = { D: 'deleted', M: 'modified', A: 'included' }[file.type];
|
|
333
353
|
console.log(` ${marker} ${file.path} (${label})`);
|
|
334
354
|
}
|
|
335
355
|
console.log();
|