diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ee482e6ed..8db7f379e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ All historical references to "CFWheels" in this changelog have been preserved fo - Use the Adobe-safe 3-argument `mid()` form when stripping the `wheels` prefix in the MCP command executor and its security spec; the prior 2-arg call crashed the entire `security/` test bundle on Adobe ColdFusion (#2613) - Replace Lucee-only `directoryCreate(path, true)` calls in `BrowserTest.$captureFailureArtifacts` and `McpServer` test-file generation with `java.io.File.mkdirs()` so artifact directory creation no longer trips Adobe ColdFusion's `DIRECTORYCREATE` single-argument validator (#2614) - Generated `Application.cfc` (and the in-repo `public/`, `examples/tweet/`, `examples/starter-app/` copies) now assigns the injector directly to `application.wheelsdi` in `onApplicationStart()` and `onError()` instead of an orphan local `injector` variable, matching the documented 4.0 DI container name and the way every other reference in the file reads (#2622) +- `wheels new --no-sqlite` now suppresses the SQLite datasource pair in the scaffolded `lucee.json` so Lucee no longer auto-creates `db/development.sqlite` / `db/test.sqlite` on first connection (#2621) ---- diff --git a/cli/lucli/Module.cfc b/cli/lucli/Module.cfc index f5b63c7e7e..b7ca649f33 100644 --- a/cli/lucli/Module.cfc +++ b/cli/lucli/Module.cfc @@ -4115,14 +4115,15 @@ component extends="modules.BaseModule" { ); } - // Template variable context — all config values flow through here + // datasourcesBlock: SQLite pair by default; "{}" when --no-sqlite (#2621) var context = { "appName": appName, "datasourceName": opts.datasource, "reloadPassword": opts.reloadPassword, "port": opts.port, "shutdownPort": opts.port + 1, - "openBrowser": opts.openBrowser ? "true" : "false" + "openBrowser": opts.openBrowser ? "true" : "false", + "datasourcesBlock": opts.noSQLite ? "{}" : buildSQLiteDatasourcesBlock(opts.datasource) }; // Copy template directory tree to target, processing placeholders. @@ -4309,6 +4310,33 @@ component extends="modules.BaseModule" { } } + private string function buildSQLiteDatasourcesBlock(required string datasourceName) { + var nl = chr(10); + var pad = " "; + var inner = " "; + var block = "{" & nl; + block &= pad & '"#datasourceName#": {' & nl; + block &= inner & '"class": "org.sqlite.JDBC",' & nl; + block &= inner & '"database": "#datasourceName#",' & nl; + block &= inner & '"dbdriver": "Other",' & nl; + block &= inner & '"dsn": "jdbc:sqlite:{project}/db/development.sqlite",' & nl; + block &= inner & '"host": "",' & nl; + block &= inner & '"password": "",' & nl; + block &= inner & '"username": ""' & nl; + block &= pad & "}," & nl; + block &= pad & '"#datasourceName#_test": {' & nl; + block &= inner & '"class": "org.sqlite.JDBC",' & nl; + block &= inner & '"database": "#datasourceName#_test",' & nl; + block &= inner & '"dbdriver": "Other",' & nl; + block &= inner & '"dsn": "jdbc:sqlite:{project}/db/test.sqlite",' & nl; + block &= inner & '"host": "",' & nl; + block &= inner & '"password": "",' & nl; + block &= inner & '"username": ""' & nl; + block &= pad & "}" & nl; + block &= " }"; + return block; + } + /** * Resolve the Wheels framework source or fail fast. Prints a diagnostic * listing every path tried plus a WHEELS_FRAMEWORK_PATH hint, then throws diff --git a/cli/lucli/templates/app/lucee.json b/cli/lucli/templates/app/lucee.json index 1eb80f63a4..ef18d95e1b 100644 --- a/cli/lucli/templates/app/lucee.json +++ b/cli/lucli/templates/app/lucee.json @@ -25,26 +25,7 @@ "enabled": false }, "configuration": { - "datasources": { - "{{datasourceName}}": { - "class": "org.sqlite.JDBC", - "database": "{{datasourceName}}", - "dbdriver": "Other", - "dsn": "jdbc:sqlite:{project}/db/development.sqlite", - "host": "", - "password": "", - "username": "" - }, - "{{datasourceName}}_test": { - "class": "org.sqlite.JDBC", - "database": "{{datasourceName}}_test", - "dbdriver": "Other", - "dsn": "jdbc:sqlite:{project}/db/test.sqlite", - "host": "", - "password": "", - "username": "" - } - }, + "datasources": {{datasourcesBlock}}, "mappings": { "/wheels": "../vendor/wheels", "/app": "../app", diff --git a/vendor/wheels/tests/specs/cli/NoSQLiteScaffoldSpec.cfc b/vendor/wheels/tests/specs/cli/NoSQLiteScaffoldSpec.cfc new file mode 100644 index 0000000000..f5d6ad133d --- /dev/null +++ b/vendor/wheels/tests/specs/cli/NoSQLiteScaffoldSpec.cfc @@ -0,0 +1,42 @@ +component extends="wheels.WheelsTest" { + + function run() { + + describe("wheels new --no-sqlite (issue 2621)", function() { + + it("lucee.json template uses a datasourcesBlock placeholder so --no-sqlite can suppress SQLite", function() { + var templatePath = expandPath("/cli/lucli/templates/app/lucee.json"); + expect(fileExists(templatePath)).toBeTrue( + "Template missing at " & templatePath + ); + + var template = fileRead(templatePath); + var placeholder = "{{" & "datasourcesBlock" & "}}"; + + expect(template contains placeholder).toBeTrue( + "Template should use the " & placeholder & " placeholder so scaffoldNewApp() can substitute either the SQLite datasource pair (default) or an empty block (--no-sqlite). Issue 2621." + ); + + // The template must NOT hardcode the SQLite class — emitting it + // has to go through the placeholder so --no-sqlite can suppress. + expect(template contains "org.sqlite.JDBC").toBeFalse( + "Template should not hardcode 'org.sqlite.JDBC' — emit it via the " & placeholder & " placeholder. Issue 2621." + ); + }); + + it("Module.cfc threads opts.noSQLite into the datasourcesBlock template context", function() { + var modulePath = expandPath("/cli/lucli/Module.cfc"); + expect(fileExists(modulePath)).toBeTrue(); + + var moduleSrc = fileRead(modulePath); + + expect(moduleSrc contains "datasourcesBlock").toBeTrue( + "Module.cfc::scaffoldNewApp() should compute a 'datasourcesBlock' value into the template context based on opts.noSQLite so the rendered lucee.json honors --no-sqlite. Issue 2621." + ); + }); + + }); + + } + +} diff --git a/web/sites/guides/src/content/docs/v4-0-0/command-line-tools/wheels-commands/creating-a-project.mdx b/web/sites/guides/src/content/docs/v4-0-0/command-line-tools/wheels-commands/creating-a-project.mdx index b99a4c84d7..9df362aef1 100644 --- a/web/sites/guides/src/content/docs/v4-0-0/command-line-tools/wheels-commands/creating-a-project.mdx +++ b/web/sites/guides/src/content/docs/v4-0-0/command-line-tools/wheels-commands/creating-a-project.mdx @@ -134,7 +134,7 @@ myblog/ lucee.json ``` -The `.env` file is created from the template's `_env` stub and carries environment-specific values; it is gitignored by the generated `.gitignore`. `lucee.json` pins the server port and shutdown port to the flags you passed. `config/app.cfm` carries the datasource configuration — SQLite by default, H2 under `--setup-h2`, or no datasource block under `--no-sqlite`. +The `.env` file is created from the template's `_env` stub and carries environment-specific values; it is gitignored by the generated `.gitignore`. `lucee.json` pins the server port, shutdown port, and Lucee-level JDBC datasource entries. `config/app.cfm` carries the runtime datasource configuration. Both files honor `--no-sqlite`: the flag emits an empty `datasources` object in `lucee.json` so Lucee never auto-creates `db/development.sqlite` and `db/test.sqlite` on first connection, and omits the datasource block from `config/app.cfm`. ## Common workflows diff --git a/web/sites/guides/src/content/docs/v4-0-1-snapshot/command-line-tools/wheels-commands/creating-a-project.mdx b/web/sites/guides/src/content/docs/v4-0-1-snapshot/command-line-tools/wheels-commands/creating-a-project.mdx index b99a4c84d7..9df362aef1 100644 --- a/web/sites/guides/src/content/docs/v4-0-1-snapshot/command-line-tools/wheels-commands/creating-a-project.mdx +++ b/web/sites/guides/src/content/docs/v4-0-1-snapshot/command-line-tools/wheels-commands/creating-a-project.mdx @@ -134,7 +134,7 @@ myblog/ lucee.json ``` -The `.env` file is created from the template's `_env` stub and carries environment-specific values; it is gitignored by the generated `.gitignore`. `lucee.json` pins the server port and shutdown port to the flags you passed. `config/app.cfm` carries the datasource configuration — SQLite by default, H2 under `--setup-h2`, or no datasource block under `--no-sqlite`. +The `.env` file is created from the template's `_env` stub and carries environment-specific values; it is gitignored by the generated `.gitignore`. `lucee.json` pins the server port, shutdown port, and Lucee-level JDBC datasource entries. `config/app.cfm` carries the runtime datasource configuration. Both files honor `--no-sqlite`: the flag emits an empty `datasources` object in `lucee.json` so Lucee never auto-creates `db/development.sqlite` and `db/test.sqlite` on first connection, and omits the datasource block from `config/app.cfm`. ## Common workflows diff --git a/web/tests/visual-baselines/blog.png b/web/tests/visual-baselines/blog.png index f0a9e79723..af41788dd6 100644 Binary files a/web/tests/visual-baselines/blog.png and b/web/tests/visual-baselines/blog.png differ