Skip to content

Commit 49b2ea6

Browse files
committed
fix(git-sync): initialize repo with gitBranches set
1 parent 003f362 commit 49b2ea6

File tree

6 files changed

+158
-106
lines changed

6 files changed

+158
-106
lines changed

cli/src/commands/app/bundle.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,13 @@ export async function createFrameworkPlugins(appDir: string): Promise<any[]> {
116116

117117
if (frameworks.vue) {
118118
log.info(colors.blue("🔧 Vue detected, adding vue plugin..."));
119-
try {
120-
const esbuildPluginVue = await import("npm:[email protected]");
121-
plugins.push(esbuildPluginVue.default());
122-
} catch (error: any) {
123-
log.warn(colors.yellow(`Failed to load vue plugin: ${error.message}`));
124-
}
119+
throw new Error("Vue plugin not supported yet");
120+
// try {
121+
// const esbuildPluginVue = await import("npm:[email protected]");
122+
// plugins.push(esbuildPluginVue.default());
123+
// } catch (error: any) {
124+
// log.warn(colors.yellow(`Failed to load vue plugin: ${error.message}`));
125+
// }
125126
}
126127

127128
return plugins;

cli/src/commands/init/init.ts

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import {
2-
colors,
3-
Command,
4-
log,
5-
yamlStringify,
6-
Confirm,
7-
} from "../../../deps.ts";
1+
import { colors, Command, log, yamlStringify, Confirm } from "../../../deps.ts";
82
import { GlobalOptions } from "../../types.ts";
93
import { readLockfile } from "../../utils/metadata.ts";
104
import { SCRIPT_GUIDANCE } from "../../guidance/script_guidance.ts";
115
import { FLOW_GUIDANCE } from "../../guidance/flow_guidance.ts";
6+
import { getActiveWorkspaceOrFallback } from "../workspace/workspace.ts";
127

138
export interface InitOptions {
149
useDefault?: boolean;
@@ -61,23 +56,21 @@ async function initAction(opts: InitOptions) {
6156

6257
// Offer to bind workspace profile to current branch
6358
if (isGitRepository()) {
64-
const { getActiveWorkspace } = await import("../workspace/workspace.ts");
65-
const activeWorkspace = await getActiveWorkspace(
59+
const activeWorkspace = await getActiveWorkspaceOrFallback(
6660
opts as GlobalOptions
6761
);
6862
const currentBranch = getCurrentGitBranch();
69-
7063
if (activeWorkspace && currentBranch) {
7164
// Determine binding behavior based on flags
7265
const shouldBind = opts.bindProfile === true;
7366
const shouldPrompt =
7467
opts.bindProfile === undefined &&
7568
Deno.stdin.isTerminal() &&
7669
!opts.useDefault;
70+
7771
const shouldSkip =
78-
opts.bindProfile === false ||
79-
opts.useDefault ||
80-
(!Deno.stdin.isTerminal() && opts.bindProfile === undefined);
72+
opts.bindProfile != true &&
73+
(opts.useDefault || !Deno.stdin.isTerminal());
8174

8275
if (shouldSkip) {
8376
return;
@@ -86,15 +79,11 @@ async function initAction(opts: InitOptions) {
8679
// Show workspace info if we're binding or prompting
8780
if (shouldBind || shouldPrompt) {
8881
log.info(
89-
colors.yellow(
90-
`\nCurrent Git branch: ${colors.bold(currentBranch)}`
91-
)
82+
colors.yellow(`\nCurrent Git branch: ${colors.bold(currentBranch)}`)
9283
);
9384
log.info(
9485
colors.yellow(
95-
`Active workspace profile: ${colors.bold(
96-
activeWorkspace.name
97-
)}`
86+
`Active workspace profile: ${colors.bold(activeWorkspace.name)}`
9887
)
9988
);
10089
log.info(
@@ -123,15 +112,15 @@ async function initAction(opts: InitOptions) {
123112
currentConfig.gitBranches[currentBranch] = { overrides: {} };
124113
}
125114

115+
log.info(
116+
`binding branch ${currentBranch} to workspace ${activeWorkspace.name} on ${activeWorkspace.remote}`
117+
);
126118
currentConfig.gitBranches[currentBranch].baseUrl =
127119
activeWorkspace.remote;
128120
currentConfig.gitBranches[currentBranch].workspaceId =
129121
activeWorkspace.workspaceId;
130122

131-
await Deno.writeTextFile(
132-
"wmill.yaml",
133-
yamlStringify(currentConfig)
134-
);
123+
await Deno.writeTextFile("wmill.yaml", yamlStringify(currentConfig));
135124

136125
log.info(
137126
colors.green(
@@ -149,10 +138,10 @@ async function initAction(opts: InitOptions) {
149138
const { resolveWorkspace } = await import("../../core/context.ts");
150139

151140
// Check if user has workspace configured
152-
const { getActiveWorkspace } = await import("../workspace/workspace.ts");
153-
const activeWorkspace = await getActiveWorkspace(
154-
opts as GlobalOptions
141+
const { getActiveWorkspace } = await import(
142+
"../workspace/workspace.ts"
155143
);
144+
const activeWorkspace = await getActiveWorkspace(opts as GlobalOptions);
156145

157146
if (!activeWorkspace) {
158147
log.info("No workspace configured. Using default settings.");
@@ -233,9 +222,7 @@ async function initAction(opts: InitOptions) {
233222
replace: true, // Auto-replace when using backend settings during init
234223
});
235224

236-
log.info(
237-
colors.green("Git-sync settings applied from backend")
238-
);
225+
log.info(colors.green("Git-sync settings applied from backend"));
239226
}
240227
}
241228
} catch (error) {
@@ -266,10 +253,7 @@ async function initAction(opts: InitOptions) {
266253
}
267254

268255
if (!(await Deno.stat(".cursor/rules/flow.mdc").catch(() => null))) {
269-
await Deno.writeTextFile(
270-
".cursor/rules/flow.mdc",
271-
flowGuidanceContent
272-
);
256+
await Deno.writeTextFile(".cursor/rules/flow.mdc", flowGuidanceContent);
273257
log.info(colors.green("Created .cursor/rules/flow.mdc"));
274258
}
275259

cli/src/commands/workspace/workspace.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,6 +397,18 @@ async function whoami(_opts: GlobalOptions) {
397397
log.info("Active: " + colors.green.bold(activeName || "none"));
398398
}
399399

400+
export async function getActiveWorkspaceOrFallback(opts: GlobalOptions) {
401+
let activeWorkspace = await getActiveWorkspace(opts);
402+
if (!activeWorkspace && opts.baseUrl && opts.workspace) {
403+
activeWorkspace = {
404+
name: opts.workspace,
405+
remote: opts.baseUrl,
406+
workspaceId: opts.workspace,
407+
token: "",
408+
};
409+
}
410+
return activeWorkspace;
411+
}
400412
async function bind(
401413
opts: GlobalOptions & { branch?: string },
402414
bindWorkspace?: boolean
@@ -419,7 +431,7 @@ async function bind(
419431
const { readConfigFile } = await import("../../core/conf.ts");
420432
const config = await readConfigFile();
421433

422-
const activeWorkspace = await getActiveWorkspace(opts);
434+
const activeWorkspace = await getActiveWorkspaceOrFallback(opts);
423435
if (!activeWorkspace && bindWorkspace) {
424436
log.error(
425437
colors.red(

0 commit comments

Comments
 (0)