Skip to content

Commit 05efea4

Browse files
Refactor solid init options, fix dataBrowserPath error (nodeSolidServer#472)
* Refactor solid init options, fix dataBrowserPath error Fixes issue nodeSolidServer#465. Also some refactoring of init options: - Move the 'mount' url question to earlier slot - Do not prompt user for various advanced options * Make bin/solid.js executable * Fix init/validPath error handling
1 parent 8046669 commit 05efea4

3 files changed

Lines changed: 47 additions & 36 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Pre-requisites:
7878
- (If you are running locally) Add the line `127.0.0.1 *.localhost` to `/etc/hosts`
7979

8080
```bash
81-
$ solid init
81+
$ solid init
8282
..
8383
? Allow users to register their WebID (y/N) # write `y` here
8484
..
@@ -114,7 +114,7 @@ $ solid start --port 8080 --ssl-key key.pem --ssl-cert cert.pem --no-webid
114114
The command line tool has the following options
115115

116116
```
117-
$ solid
117+
$ solid
118118
119119
Usage: solid [options] [command]
120120
@@ -144,17 +144,17 @@ $ solid start --help
144144
Options:
145145
-h, --help output usage information
146146
--root [value] Root folder to serve (defaut: './')
147-
--port [value] Port to use
148-
--webid Enable WebID+TLS authentication (use `--no-webid` for HTTP instead of HTTPS)
149-
--owner [value] Set the owner of the storage
147+
--port [value] Port to use (default: '8443')
148+
--webid Enable WebID authentication and access control (uses HTTPS. default: true)
149+
--owner [value] Set the owner of the storage (overwrites the root ACL file)
150150
--ssl-key [value] Path to the SSL private key in PEM format
151151
--ssl-cert [value] Path to the SSL certificate key in PEM format
152-
--idp Allow users to register their WebID
153-
--proxy [value] Serve proxy on path
154-
--file-browser [value] App to browse files
152+
--idp Enable multi-user mode (users can sign up for accounts)
153+
--proxy [value] Serve proxy on path (default: '/proxy')
154+
--file-browser [value] Url to file browser app (uses Warp by default)
155155
--data-browser Enable viewing RDF resources using a default data browser application (e.g. mashlib)
156-
--suffix-acl [value] Suffix for acl files
157-
--suffix-meta [value] Suffix for metadata files
156+
--suffix-acl [value] Suffix for acl files (default: '.acl')
157+
--suffix-meta [value] Suffix for metadata files (default: '.meta')
158158
--secret [value] Secret used to sign the session ID cookie (e.g. "your secret phrase")
159159
--error-pages [value] Folder from which to look for custom error pages files (files must be named <error-code>.html -- eg. 500.html)
160160
--mount [value] Serve on a specific URL path (default: '/')

bin/lib/options.js

Lines changed: 37 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,19 @@ module.exports = [
2424
},
2525
{
2626
name: 'webid',
27-
help: 'Enable WebID+TLS authentication (use `--no-webid` for HTTP instead of HTTPS)',
27+
help: 'Enable WebID authentication and access control (uses HTTPS)',
2828
flag: true,
29+
default: true,
2930
question: 'Enable WebID authentication',
3031
prompt: true
3132
},
33+
{
34+
name: 'mount',
35+
help: "Serve on a specific URL path (default: '/')",
36+
question: 'Serve Solid on URL path',
37+
default: '/',
38+
prompt: true
39+
},
3240
{
3341
name: 'auth',
3442
help: 'Pick an authentication strategy for WebID: `tls` or `oidc`',
@@ -57,8 +65,8 @@ module.exports = [
5765
},
5866
{
5967
name: 'owner',
60-
help: 'Set the owner of the storage',
61-
question: 'Your webid',
68+
help: 'Set the owner of the storage (overwrites the root ACL file)',
69+
question: 'Your webid (to overwrite the root ACL with)',
6270
validate: function (value) {
6371
if (value === '' || !value.startsWith('http')) {
6472
return 'Enter a valid Webid'
@@ -83,7 +91,8 @@ module.exports = [
8391
},
8492
{
8593
name: 'idp',
86-
help: 'Allow users to sign up for an account',
94+
help: 'Enable multi-user mode (users can sign up for accounts)',
95+
question: 'Enable multi-user mode (users can sign up for accounts)',
8796
full: 'allow-signup',
8897
flag: true,
8998
default: false,
@@ -101,9 +110,9 @@ module.exports = [
101110
// },
102111
{
103112
name: 'useProxy',
104-
help: 'Do you want to have a proxy?',
113+
help: 'Do you want to have a CORS proxy endpoint?',
105114
flag: true,
106-
prompt: false,
115+
prompt: true,
107116
hide: true
108117
},
109118
{
@@ -126,14 +135,14 @@ module.exports = [
126135
}
127136
return value
128137
},
129-
prompt: true
138+
prompt: false
130139
},
131140

132141
{
133142
name: 'suppress-data-browser',
134-
help: 'Suppres provision of a data browser',
143+
help: 'Suppress provision of a data browser',
135144
flag: true,
136-
prompt: true,
145+
prompt: false,
137146
default: false,
138147
hide: false
139148
},
@@ -144,25 +153,28 @@ module.exports = [
144153
question: 'Path of data viewer page (defaults to using mashlib)',
145154
validate: validPath,
146155
default: 'default',
147-
prompt: true
156+
prompt: false
148157
},
149158
{
150159
name: 'suffix-acl',
151160
full: 'suffix-acl',
152-
help: 'Suffix for acl files',
153-
default: '.acl'
161+
help: "Suffix for acl files (default: '.acl')",
162+
default: '.acl',
163+
prompt: false
154164
},
155165
{
156166
name: 'suffix-meta',
157167
full: 'suffix-meta',
158-
help: 'Suffix for metadata files',
159-
default: '.meta'
168+
help: "Suffix for metadata files (default: '.meta')",
169+
default: '.meta',
170+
prompt: false
160171
},
161172
{
162173
name: 'secret',
163174
help: 'Secret used to sign the session ID cookie (e.g. "your secret phrase")',
164175
question: 'Session secret for cookie',
165176
default: 'random',
177+
prompt: false,
166178
filter: function (value) {
167179
if (value === '' || value === 'random') {
168180
return
@@ -178,13 +190,8 @@ module.exports = [
178190
{
179191
name: 'error-pages',
180192
help: 'Folder from which to look for custom error pages files (files must be named <error-code>.html -- eg. 500.html)',
181-
validate: validPath
182-
},
183-
{
184-
name: 'mount',
185-
help: "Serve on a specific URL path (default: '/')",
186-
question: 'Serve Solid on path',
187-
default: '/'
193+
validate: validPath,
194+
prompt: false
188195
},
189196
{
190197
name: 'force-user',
@@ -194,7 +201,8 @@ module.exports = [
194201
name: 'strict-origin',
195202
help: 'Enforce same origin policy in the ACL',
196203
flag: true,
197-
prompt: true
204+
default: false,
205+
prompt: false
198206
},
199207
{
200208
name: 'useEmail',
@@ -248,7 +256,7 @@ module.exports = [
248256
name: 'useApiApps',
249257
help: 'Do you want to load your default apps on /api/apps?',
250258
flag: true,
251-
prompt: true,
259+
prompt: false,
252260
default: true
253261
},
254262
{
@@ -263,12 +271,15 @@ module.exports = [
263271
]
264272

265273
function validPath (value) {
274+
if (value === 'default') {
275+
return Promise.resolve(true)
276+
}
266277
if (!value || value === '') {
267-
return 'You must enter a valid path'
278+
return Promise.resolve('You must enter a valid path')
268279
}
269-
return new Promise((resolve, reject) => {
280+
return new Promise((resolve) => {
270281
fs.stat(value, function (err) {
271-
if (err) return reject('Nothing found at this path')
282+
if (err) return resolve('Nothing found at this path')
272283
return resolve(true)
273284
})
274285
})

bin/solid.js

100644100755
File mode changed.

0 commit comments

Comments
 (0)