TiddlyWiki / TiddlyWiki5

A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
https://tiddlywiki.com/
Other
8.04k stars 1.19k forks source link

[Bug] "tiddlywiki invalid-path --listen" does start a server - IMO it should not #8542

Closed pmario closed 2 months ago

pmario commented 2 months ago

If I run tiddlywiki invalid-path --listen, it does still start a server - IMO it should not

This issue is related to: Add some new scripts to package.json, to make npm run command easier #8294

Proposal

It should produce "Error" instead of "Warning" -- and stop

PS E:\git\tiddly\tiddlywiki\TiddlyWiki5> npm run edition:lazy

> tiddlywiki@5.3.6-prerelease preedition:lazy
> npm run edition:lazy:info -s

"use: npm run edition:lazy --edition=tw5.com [de-AT, es-ES, fr-FR, ko-KR, xlsx-utils]"

> tiddlywiki@5.3.6-prerelease edition:lazy
> node ./tiddlywiki.js ./editions/%npm_config_edition%-server --listen root-tiddler=$:/core/save/lazy-all

Warning: Wiki folder './editions/%npm_config_edition%-server' does not exist or is missing a tiddlywiki.info file
PS E:\git\tiddly\tiddlywiki\TiddlyWiki5>

Command to replicate the problem

node ./tiddlywiki.js ./editions/%npm_config_edition%-server --listen root-tiddler=$:/core/save/lazy-all

It prints this info:

Warning: Wiki folder './editions/%npm_config_edition%-server' does not exist or is missing a tiddlywiki.info file
Warning: Plugin(s) required for client-server operation are missing.
"$:/plugins/tiddlywiki/filesystem", "$:/plugins/tiddlywiki/tiddlyweb"
Serving on http://127.0.0.1:8080
(press ctrl-C to exit)

So it knows, that it will not work. But it still runs a server that will create this:

image

pmario commented 2 months ago

@linonetwo @saqimtiaz -- Can you imagine a configuration, where it would make sense to run a server with an invalid path name?

Jermolene commented 2 months ago

@linonetwo @saqimtiaz -- Can you imagine a configuration, where it would make sense to run a server with an invalid path name?

The canonical example of using an invalid pathname is when initialising a new wiki:

tiddlywiki ./MyWikiFolder --init empty
pmario commented 2 months ago

The canonical example of using an invalid pathname is when initialising a new wiki:

tiddlywiki ./MyWikiFolder --init empty

Yes, but that does not touch the code of the --listen command. The important thing here is --listen

Jermolene commented 2 months ago

Hi @pmario so you are suggesting that the --listen command should check for a valid wiki folder and raise an error if there isn't one.

That's not right. TiddlyWiki can be run without a wiki folder. For example:

tiddlywiki --load <somedata> --listen

It is not necessary for there to be a wiki folder in order for TiddlyWiki to function correctly.

pmario commented 2 months ago

OK. --load is an argument. But if you use tiddlywiki invalid-path --listen there is still a problem

image

Jermolene commented 2 months ago

Hi @pmario the "problem" here is just that there is no theme plugin loaded. If we think that that is confusing then perhaps a better approach would be to make the core display a warning banner if there is no theme plugin loaded. I think that could be done in wikitext as a page template segment.

linonetwo commented 2 months ago

I don't use cli, I only call its JS api, so I have no opinion here.