@lisang233/pi-sync 0.1.0 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lisang233/pi-sync",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Personal Pi extension that syncs Pi configuration through Git with background auto-sync and git-style fetch/merge conflict handling.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/extension.ts CHANGED
@@ -130,8 +130,15 @@ async function handleCommand(rawArgs: string, ctx: ExtensionCommandContext): Pro
130
130
  return;
131
131
  }
132
132
 
133
+ // init re-creates the config from scratch: it must work even when the
134
+ // existing pi-sync.json is broken or in an old format.
135
+ if (subcommand === "init") {
136
+ await runSetupWizard(ctx.ui);
137
+ return;
138
+ }
139
+
133
140
  const config = await loadConfig();
134
- if (subcommand !== "init" && config.remote.length === 0) {
141
+ if (config.remote.length === 0) {
135
142
  ctx.ui.notify(
136
143
  "pi-sync is not configured. Run /sync init to set up the git remote, or edit pi-sync.json.",
137
144
  "warning",
@@ -142,9 +149,6 @@ async function handleCommand(rawArgs: string, ctx: ExtensionCommandContext): Pro
142
149
  const force = restTokens.some((token) => token === "--force");
143
150
 
144
151
  switch (subcommand) {
145
- case "init":
146
- await runSetupWizard(ctx.ui);
147
- return;
148
152
  case "status":
149
153
  await operations.status(ctx, config, {
150
154
  diff: restTokens.some((token) => token === "--diff"),
package/src/wizard.ts CHANGED
@@ -18,7 +18,14 @@ const INCLUDE_CHOICES = [
18
18
  * automatic-sync switch, then persist a single config file.
19
19
  */
20
20
  export async function runSetupWizard(ui: ExtensionUIContext): Promise<SyncConfig | undefined> {
21
- const existing = await loadConfig();
21
+ let existing: SyncConfig;
22
+ try {
23
+ existing = await loadConfig();
24
+ } catch {
25
+ // A broken or old-format config must not block re-initialization;
26
+ // fall back to a fresh setup.
27
+ existing = { ...DEFAULT_CONFIG };
28
+ }
22
29
  const hasConfig = existing.remote.length > 0;
23
30
 
24
31
  const remote = await ui.input("Git remote URL", "git@github.com:you/pi-sync.git or https://…");