@pmate/cli 0.21.6 → 0.21.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/index.js +37 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11660,7 +11660,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11660
11660
|
this.renderOpen(result2, args.json);
|
|
11661
11661
|
return result2;
|
|
11662
11662
|
}
|
|
11663
|
-
const result = await this.closeEnvironment(args.repo, args.envIndex, envRoot);
|
|
11663
|
+
const result = await this.closeEnvironment(args.repo, args.envIndex, envRoot, baseRoot);
|
|
11664
11664
|
this.renderClose(result, args.json);
|
|
11665
11665
|
return result;
|
|
11666
11666
|
}
|
|
@@ -11732,9 +11732,10 @@ var PrepareDevCommandHandler = class {
|
|
|
11732
11732
|
}
|
|
11733
11733
|
throw new Error(`No available dev environment found for ${repo} under ${envRoot}`);
|
|
11734
11734
|
}
|
|
11735
|
-
async closeEnvironment(repo, envIndex, envRoot) {
|
|
11735
|
+
async closeEnvironment(repo, envIndex, envRoot, baseRoot) {
|
|
11736
11736
|
const envPath = import_node_path10.default.join(envRoot, `${repo}-${envIndex}`);
|
|
11737
11737
|
const lockPath = import_node_path10.default.join(envPath, LOCK_FILE_NAME);
|
|
11738
|
+
const baseRepoPath = import_node_path10.default.join(baseRoot, repo);
|
|
11738
11739
|
if (!await this.pathExists(envPath) || !await this.pathExists(import_node_path10.default.join(envPath, ".git"))) {
|
|
11739
11740
|
throw new Error(`Dev environment not found: ${envPath}`);
|
|
11740
11741
|
}
|
|
@@ -11744,6 +11745,7 @@ var PrepareDevCommandHandler = class {
|
|
|
11744
11745
|
`Cannot close ${repo}-${envIndex}: local changes detected. Commit or clean the worktree first.`
|
|
11745
11746
|
);
|
|
11746
11747
|
}
|
|
11748
|
+
const baseRepoSync = await this.syncBaseRepo(baseRepoPath);
|
|
11747
11749
|
const removedLock = await this.removeLock(lockPath);
|
|
11748
11750
|
return {
|
|
11749
11751
|
action: "close",
|
|
@@ -11751,7 +11753,9 @@ var PrepareDevCommandHandler = class {
|
|
|
11751
11753
|
envIndex,
|
|
11752
11754
|
envPath,
|
|
11753
11755
|
lockPath,
|
|
11754
|
-
removedLock
|
|
11756
|
+
removedLock,
|
|
11757
|
+
baseRepoPath,
|
|
11758
|
+
baseRepoSync
|
|
11755
11759
|
};
|
|
11756
11760
|
}
|
|
11757
11761
|
resolveRoot(input, fallbackSegments) {
|
|
@@ -11766,6 +11770,33 @@ var PrepareDevCommandHandler = class {
|
|
|
11766
11770
|
throw new Error(`Expected ${cwd} to be on main, got ${branch || "(detached)"}`);
|
|
11767
11771
|
}
|
|
11768
11772
|
}
|
|
11773
|
+
async syncBaseRepo(baseRepoPath) {
|
|
11774
|
+
if (!await this.pathExists(baseRepoPath) || !await this.pathExists(import_node_path10.default.join(baseRepoPath, ".git"))) {
|
|
11775
|
+
throw new Error(`Cannot close dev environment: base repo not found: ${baseRepoPath}`);
|
|
11776
|
+
}
|
|
11777
|
+
const origin = await this.safeGitOutput(baseRepoPath, ["remote", "get-url", "origin"]);
|
|
11778
|
+
if (!origin || this.isLocalOrigin(origin)) {
|
|
11779
|
+
throw new Error(
|
|
11780
|
+
`Cannot close dev environment: base repo has invalid origin: ${baseRepoPath}`
|
|
11781
|
+
);
|
|
11782
|
+
}
|
|
11783
|
+
const branch = await this.safeGitOutput(baseRepoPath, ["branch", "--show-current"]);
|
|
11784
|
+
if (branch !== "main") {
|
|
11785
|
+
throw new Error(
|
|
11786
|
+
`Cannot close dev environment: base repo must be on main before sync, got ${branch || "(detached)"}.`
|
|
11787
|
+
);
|
|
11788
|
+
}
|
|
11789
|
+
if (await this.hasUncommittedChanges(baseRepoPath)) {
|
|
11790
|
+
throw new Error(
|
|
11791
|
+
`Cannot close dev environment: base repo has local changes: ${baseRepoPath}`
|
|
11792
|
+
);
|
|
11793
|
+
}
|
|
11794
|
+
await this.runGit(["pull", "--ff-only"], baseRepoPath);
|
|
11795
|
+
return {
|
|
11796
|
+
attempted: true,
|
|
11797
|
+
updated: true
|
|
11798
|
+
};
|
|
11799
|
+
}
|
|
11769
11800
|
async hasUncommittedChanges(cwd) {
|
|
11770
11801
|
const status = await this.getGitOutput(cwd, ["status", "--porcelain"]);
|
|
11771
11802
|
if (!status) {
|
|
@@ -11851,7 +11882,9 @@ var PrepareDevCommandHandler = class {
|
|
|
11851
11882
|
}
|
|
11852
11883
|
ui.success(`Closed ${result.repo}-${result.envIndex}`, {
|
|
11853
11884
|
path: result.envPath,
|
|
11854
|
-
lockRemoved: result.removedLock
|
|
11885
|
+
lockRemoved: result.removedLock,
|
|
11886
|
+
baseRepo: result.baseRepoPath,
|
|
11887
|
+
baseRepoSynced: result.baseRepoSync.updated
|
|
11855
11888
|
});
|
|
11856
11889
|
}
|
|
11857
11890
|
};
|