fix(cli): make wmill app new respects nonDottedPaths setting from wmill.yaml (#7700)

* update dnt

* fix nondottedpath settings
This commit is contained in:
centdix
2026-01-27 15:14:42 +00:00
committed by GitHub
parent bad86d862f
commit 6899a16efb
5 changed files with 92 additions and 52 deletions
+2 -44
View File
@@ -39,54 +39,12 @@ import { regenerateAgentDocs } from "./generate_agents.ts";
import {
getFolderSuffix,
hasFolderSuffix,
setNonDottedPaths,
loadNonDottedPathsSetting,
} from "../../utils/resource_folders.ts";
const DEFAULT_PORT = 4000;
const DEFAULT_HOST = "localhost";
/**
* Search for wmill.yaml by traversing upward from the current directory.
* Unlike the standard findWmillYaml() in conf.ts, this does not stop at
* the git root - it continues searching until the filesystem root.
* This is needed for `app dev` which runs from inside a raw_app folder
* that may be deeply nested within a larger git repository.
*/
async function findAndLoadNonDottedPathsSetting(): Promise<void> {
let currentDir = process.cwd();
while (true) {
const wmillYamlPath = path.join(currentDir, "wmill.yaml");
if (fs.existsSync(wmillYamlPath)) {
try {
const config = await yamlParseFile(wmillYamlPath) as {
nonDottedPaths?: boolean;
};
setNonDottedPaths(config?.nonDottedPaths ?? false);
log.debug(
`Found wmill.yaml at ${wmillYamlPath}, nonDottedPaths=${
config?.nonDottedPaths ?? false
}`,
);
} catch (e) {
log.debug(`Failed to parse wmill.yaml at ${wmillYamlPath}: ${e}`);
}
return;
}
// Check if we've reached the filesystem root
const parentDir = path.dirname(currentDir);
if (parentDir === currentDir) {
// Reached filesystem root without finding wmill.yaml
log.debug("No wmill.yaml found, using default dotted paths");
return;
}
currentDir = parentDir;
}
}
// HTML template with live reload and SQL migration modal
const createHTML = (jsPath: string, cssPath: string) => `
<!DOCTYPE html>
@@ -353,7 +311,7 @@ async function dev(opts: DevOptions) {
// Search for wmill.yaml by traversing upward (without git root constraint)
// to initialize nonDottedPaths setting before using folder suffix functions
await findAndLoadNonDottedPathsSetting();
await loadNonDottedPathsSetting();
// Validate that we're in a .raw_app folder
const cwd = process.cwd();
+7 -1
View File
@@ -14,7 +14,10 @@ import { resolveWorkspace } from "../../core/context.ts";
import { requireLogin } from "../../core/auth.ts";
import * as wmill from "../../../gen/services.gen.ts";
import path from "node:path";
import { buildFolderPath } from "../../utils/resource_folders.ts";
import {
buildFolderPath,
loadNonDottedPathsSetting,
} from "../../utils/resource_folders.ts";
// Framework templates - adapted from frontend/src/routes/(root)/(logged)/apps_raw/add/templates.ts
const reactIndex = `
@@ -472,6 +475,9 @@ CREATE SCHEMA IF NOT EXISTS ${schemaName};
);
}
// Load nonDottedPaths setting from wmill.yaml before creating folder
await loadNonDottedPathsSetting();
// Create the directory structure - preserve full path (e.g., f/foobar/x/y becomes f/foobar/x/y.raw_app)
const folderName = buildFolderPath(appPath, "raw_app");
const appDir = path.join(Deno.cwd(), folderName);
+47 -1
View File
@@ -8,7 +8,10 @@
* (.flow, .app, .raw_app) or dunder-prefixed names (__flow, __app, __raw_app).
*/
import { log, SEP } from "../../deps.ts";
import { log, SEP, yamlParseFile } from "../../deps.ts";
import * as fs from "node:fs";
import * as path from "node:path";
import process from "node:process";
// Resource types that use folder-based storage
export type FolderResourceType = "flow" | "app" | "raw_app";
@@ -56,6 +59,49 @@ export function getNonDottedPaths(): boolean {
return _nonDottedPaths;
}
/**
* Search for wmill.yaml by traversing upward from the current directory
* and initialize the nonDottedPaths setting.
* Unlike findWmillYaml() in conf.ts, this does not stop at the git root -
* it continues searching until the filesystem root.
* This is needed for commands like `app dev` and `app new` which may run
* from inside folders that are deeply nested within a larger git repository.
*/
export async function loadNonDottedPathsSetting(): Promise<void> {
let currentDir = process.cwd();
while (true) {
const wmillYamlPath = path.join(currentDir, "wmill.yaml");
if (fs.existsSync(wmillYamlPath)) {
try {
const config = (await yamlParseFile(wmillYamlPath)) as {
nonDottedPaths?: boolean;
};
setNonDottedPaths(config?.nonDottedPaths ?? false);
log.debug(
`Found wmill.yaml at ${wmillYamlPath}, nonDottedPaths=${
config?.nonDottedPaths ?? false
}`
);
} catch (e) {
log.debug(`Failed to parse wmill.yaml at ${wmillYamlPath}: ${e}`);
}
return;
}
// Check if we've reached the filesystem root
const parentDir = path.dirname(currentDir);
if (parentDir === currentDir) {
// Reached filesystem root without finding wmill.yaml
log.debug("No wmill.yaml found, using default dotted paths");
return;
}
currentDir = parentDir;
}
}
/**
* Get the folder suffixes based on the global configuration.
*/