mikser-io 10.0.3 → 10.0.4
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/docs/configuration.md +1 -1
- package/package.json +1 -1
- package/src/config.js +12 -0
- package/src/engine.js +16 -0
package/docs/configuration.md
CHANGED
|
@@ -47,7 +47,7 @@ These options are part of `runtime.options` and apply to the engine itself.
|
|
|
47
47
|
| `outputFolder` | `-o, --output-folder` | string | `out` | Folder where rendered output is written. |
|
|
48
48
|
| `runtimeFolder` | `-e, --runtime-folder` | string | `runtime` | Folder for temporary files. The engine's sqlite substrate lives at `runtime/mikser.sqlite` (entities, refs, snapshots, journal, schema-version meta all in one file). |
|
|
49
49
|
| `plugins` | — | factory-call[] | `[]` | Array of factory returns. Import the factory by name and call it: `plugins: [documents(), layouts({ cleanUrls: true })]`. Config-only — there's no `--plugins` CLI flag under v9 because identifiers can't be passed via the command line (ADR-0010). |
|
|
50
|
-
| `config` | `-c, --config` | string | `./mikser.config.js` | Path to the config file. |
|
|
50
|
+
| `config` | `-c, --config` | string | `./mikser.config.js` | Path to the config file, relative to `workingFolder` like every other path — so `-c prod.config.js` means the one in the folder you pointed at, and repeating the working folder in the path doubles it. A project with no config file at the default location runs on defaults; a path given here that does not exist is an error, because the alternative is a green build with an empty output folder. |
|
|
51
51
|
| `mode` | `-m, --mode` | string | `development` | Runtime mode, accessible as `runtime.options.mode`. |
|
|
52
52
|
| `clear` | `-r, --clear` | boolean | `false` | Delete `outputFolder` and `runtimeFolder` before each run. |
|
|
53
53
|
| `watch` | `-w, --watch` | boolean | `false` | Watch source folders for changes and rebuild incrementally. |
|
package/package.json
CHANGED
package/src/config.js
CHANGED
|
@@ -103,6 +103,18 @@ onLoad(async () => {
|
|
|
103
103
|
// during evaluation both exit 1. Module resolution is the only one that
|
|
104
104
|
// needs this to stay in line with them.
|
|
105
105
|
if (!existsSync(configFile)) {
|
|
106
|
+
// Absent by DEFAULT is a project without a config, which is allowed.
|
|
107
|
+
// Absent after the caller named it is a typo, and continuing on
|
|
108
|
+
// defaults answers a question nobody asked: the build prints the path
|
|
109
|
+
// it did not find, reports "No plugins loaded", writes nothing and
|
|
110
|
+
// exits 0. That is the same green-build-empty-output failure the
|
|
111
|
+
// module-resolution note above exists to prevent, reached by the
|
|
112
|
+
// shorter route of getting the path wrong.
|
|
113
|
+
if (runtime.options.configExplicit) {
|
|
114
|
+
throw new Error(`No config file at ${configFile} — it was named with --config, so this is a wrong `
|
|
115
|
+
+ 'path rather than a project without a config. A relative --config resolves against the '
|
|
116
|
+
+ `working folder (${runtime.options.workingFolder}), so it does not repeat it.`)
|
|
117
|
+
}
|
|
106
118
|
logger.debug('No config file at %s — using defaults', configFile)
|
|
107
119
|
} else {
|
|
108
120
|
// No catch: any failure loading a config that EXISTS is fatal.
|
package/src/engine.js
CHANGED
|
@@ -683,6 +683,22 @@ The full version, with what each code means: docs/diagnostics.md`)
|
|
|
683
683
|
// deliberate: engine's onInitialize does setup that the rest of
|
|
684
684
|
// the engine infrastructure depends on; onInitialized does
|
|
685
685
|
// things plugins may need.
|
|
686
|
+
// Whether --config was TYPED, for config.js.
|
|
687
|
+
//
|
|
688
|
+
// Relative config paths resolve against the working folder, not the
|
|
689
|
+
// folder the command was run in — that is what makes the default
|
|
690
|
+
// './mikser.config.js' follow --working-folder, and `-c prod.js`
|
|
691
|
+
// reads as "the prod config of the site I am pointing at", which is
|
|
692
|
+
// how it is used. Deliberately unchanged.
|
|
693
|
+
//
|
|
694
|
+
// What was missing is what happens when the path is wrong. Nothing
|
|
695
|
+
// distinguished "this project has no config" from "the config you
|
|
696
|
+
// named is not there", so a mistyped path printed the path, reported
|
|
697
|
+
// no plugins, and exited 0 over an empty output folder. config.js
|
|
698
|
+
// needs to know which case it is in, and only commander can say.
|
|
699
|
+
runtime.options.configExplicit =
|
|
700
|
+
runtime.engine?.commander?.getOptionValueSource?.('config') === 'cli'
|
|
701
|
+
|
|
686
702
|
runtime.options.workingFolder = path.resolve(runtime.options.workingFolder)
|
|
687
703
|
process.chdir(runtime.options.workingFolder)
|
|
688
704
|
|