pub-server 2.11.2 → 2.12.0
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/LICENSE +1 -1
- package/README.md +2 -1
- package/bin/_pub.js +3 -1
- package/client/_generator.js +1 -1
- package/client/init-opts.js +1 -26
- package/client/pub-sockets.js +1 -1
- package/client/pub-ux.js +1 -1
- package/package.json +23 -23
- package/server/handle-errors.js +1 -1
- package/server/serve-pages.js +1 -1
- package/server/serve-scripts.js +3 -3
- package/server/serve-sockets.js +1 -1
- package/server/serve-statics.js +2 -2
- package/server/watch-sources.js +1 -1
- package/server/watch.js +1 -1
- package/server.js +18 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
(The MIT License)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2015-
|
|
3
|
+
Copyright (c) 2015-2024 Jürgen Leschner -- github.com/jldec
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ npm install -g pub-server
|
|
|
48
48
|
- `pub -h` shows the usage info below:
|
|
49
49
|
|
|
50
50
|
```
|
|
51
|
-
pub-server v2.
|
|
51
|
+
pub-server v2.12.0
|
|
52
52
|
|
|
53
53
|
usage: pub [opts] [dir]
|
|
54
54
|
opts:
|
|
@@ -57,6 +57,7 @@ opts:
|
|
|
57
57
|
-t, --theme <name> theme module-name or dir, repeatable (default: [])
|
|
58
58
|
-o, --output-path <dir> output dir [./out]
|
|
59
59
|
-O, --output-only output html, scripts, static files and exit
|
|
60
|
+
-g, --migrate migrate markdown to output dir in outputs[1]
|
|
60
61
|
-r, --root <prefix> generate /prefix urls, "." means path relative
|
|
61
62
|
-s, --static <dir> static dir, repeatable, supports <dir>,<route> (default: [])
|
|
62
63
|
-S, --static-only <dir> serve only static files from <dir> (default: [])
|
package/bin/_pub.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
* pub command script
|
|
5
|
-
* Copyright (c) 2015-
|
|
5
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
var pkg = require('../package.json');
|
|
@@ -32,6 +32,7 @@ cli
|
|
|
32
32
|
.option('-t, --theme <name>', 'theme module-name or dir, repeatable', collect, [])
|
|
33
33
|
.option('-o, --output-path <dir>', 'output dir [./out]')
|
|
34
34
|
.option('-O, --output-only', 'output html, scripts, static files and exit')
|
|
35
|
+
.option('-g, --migrate', 'migrate markdown to output dir in outputs[1]')
|
|
35
36
|
.option('-r, --root <prefix>', 'generate /prefix urls, "." means path relative')
|
|
36
37
|
.option('-s, --static <dir>', 'static dir, repeatable, supports <dir>,<route>', collectStaticPaths, [])
|
|
37
38
|
.option('-S, --static-only <dir>', 'serve only static files from <dir>', collectStaticPaths, [])
|
|
@@ -61,6 +62,7 @@ if (cli.root === '.') { opts.relPaths = true; }
|
|
|
61
62
|
else if (cli.root) { opts.staticRoot = cli.root; }
|
|
62
63
|
if (cli.outputPath) { opts.outputs = cli.outputPath; }
|
|
63
64
|
if (cli.outputOnly) { opts.outputOnly = true; }
|
|
65
|
+
if (cli.migrate) { opts.migrate = true; }
|
|
64
66
|
if (cli.static.length) { opts.staticPaths = cli.static; }
|
|
65
67
|
if (cli.staticOnly.length) { opts.staticOnly = cli.staticOnly; }
|
|
66
68
|
if (cli.mdFragments) { opts.fragmentDelim = 'md-headings'; }
|
package/client/_generator.js
CHANGED
package/client/init-opts.js
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* possibly by directing browser to gatekeeper for auth roundabout
|
|
8
8
|
* TODO: implement a mechanism to force re-authentication (logout gatekeeper)
|
|
9
9
|
*
|
|
10
|
-
* Copyright (c) 2015-
|
|
10
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
/* global $ */
|
|
@@ -48,31 +48,6 @@ module.exports = function initOpts(cb) {
|
|
|
48
48
|
|
|
49
49
|
opts.sources.forEach(function(source) {
|
|
50
50
|
opts.source$[source.name] = source;
|
|
51
|
-
|
|
52
|
-
// connect to static editor sources: github or dropbox
|
|
53
|
-
if (opts.staticHost && source.staticSrc) {
|
|
54
|
-
if (source.gatekeeper) {
|
|
55
|
-
var append = ab.asyncAppend();
|
|
56
|
-
debug('authenticating ' + source.gatekeeper);
|
|
57
|
-
$.getJSON(source.gatekeeper + '/status' + location.search)
|
|
58
|
-
.fail(function(jqXHR) { append(new Error(jqXHR.responseText)); })
|
|
59
|
-
.done(function(status) {
|
|
60
|
-
|
|
61
|
-
// if not logged in, send browser to gatekeeper for oauth
|
|
62
|
-
if (!status || !status.access_token) {
|
|
63
|
-
location.assign(source.gatekeeper +
|
|
64
|
-
'?ref=' + encodeURIComponent(location.href));
|
|
65
|
-
}
|
|
66
|
-
// finally we can create the source adapter to save to
|
|
67
|
-
else {
|
|
68
|
-
source.auth = status;
|
|
69
|
-
source.src = require(source.staticSrc)(source);
|
|
70
|
-
}
|
|
71
|
-
debug(status);
|
|
72
|
-
append(status);
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
51
|
});
|
|
77
52
|
ab.complete();
|
|
78
53
|
|
package/client/pub-sockets.js
CHANGED
package/client/pub-ux.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pub-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.12.0",
|
|
4
4
|
"description": "markdown site generator, web server, and editor",
|
|
5
5
|
"main": "server.js",
|
|
6
6
|
"preferGlobal": true,
|
|
@@ -8,41 +8,41 @@
|
|
|
8
8
|
"pub": "./bin/pub.js"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"asyncbuilder": "^1.
|
|
12
|
-
"body-parser": "^1.20.
|
|
11
|
+
"asyncbuilder": "^1.1.1",
|
|
12
|
+
"body-parser": "^1.20.2",
|
|
13
13
|
"browserify": "^17.0.0",
|
|
14
|
-
"chokidar": "^3.
|
|
14
|
+
"chokidar": "^3.6.0",
|
|
15
15
|
"commander": "^2.20.0",
|
|
16
16
|
"compression": "^1.7.4",
|
|
17
|
-
"debug": "^4.3.
|
|
18
|
-
"express": "^4.
|
|
19
|
-
"fs-extra": "^11.
|
|
17
|
+
"debug": "^4.3.6",
|
|
18
|
+
"express": "^4.19.2",
|
|
19
|
+
"fs-extra": "^11.2.0",
|
|
20
20
|
"mime": "^3.0.0",
|
|
21
|
-
"pub-generator": "^4.
|
|
22
|
-
"pub-pkg-editor": "^2.0
|
|
21
|
+
"pub-generator": "^4.4.0",
|
|
22
|
+
"pub-pkg-editor": "^2.2.0",
|
|
23
23
|
"pub-pkg-font-awesome": "^3.0.5",
|
|
24
24
|
"pub-pkg-font-open-sans": "^1.5.1",
|
|
25
|
-
"pub-pkg-google-oauth": "^2.
|
|
25
|
+
"pub-pkg-google-oauth": "^2.2.0",
|
|
26
26
|
"pub-pkg-highlight": "^11.4.0",
|
|
27
27
|
"pub-pkg-jquery": "^1.12.4",
|
|
28
28
|
"pub-pkg-prism": "^2.0.5",
|
|
29
|
-
"pub-pkg-seo": "^1.
|
|
30
|
-
"pub-resolve-opts": "^1.
|
|
31
|
-
"pub-serve-sessions": "^
|
|
32
|
-
"pub-src-fs": "^2.
|
|
33
|
-
"pub-src-github": "^2.0
|
|
34
|
-
"pub-src-http": "^
|
|
35
|
-
"pub-src-redis": "^2.
|
|
36
|
-
"pub-theme-doc": "^1.
|
|
37
|
-
"pub-util": "^3.
|
|
29
|
+
"pub-pkg-seo": "^1.3.0",
|
|
30
|
+
"pub-resolve-opts": "^1.10.0",
|
|
31
|
+
"pub-serve-sessions": "^2.0.0",
|
|
32
|
+
"pub-src-fs": "^2.2.0",
|
|
33
|
+
"pub-src-github": "^2.1.0",
|
|
34
|
+
"pub-src-http": "^2.0.0",
|
|
35
|
+
"pub-src-redis": "^2.2.0",
|
|
36
|
+
"pub-theme-doc": "^1.2.0",
|
|
37
|
+
"pub-util": "^3.3.0",
|
|
38
38
|
"send": "^0.18.0",
|
|
39
|
-
"socket.io": "^4.5
|
|
39
|
+
"socket.io": "^4.7.5",
|
|
40
40
|
"through2": "^4.0.2",
|
|
41
|
-
"uglify-
|
|
41
|
+
"uglify-js": "^3.19.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"eslint": "^8.
|
|
45
|
-
"tape": "^5.
|
|
44
|
+
"eslint": "^8.57.0",
|
|
45
|
+
"tape": "^5.8.1"
|
|
46
46
|
},
|
|
47
47
|
"files": [
|
|
48
48
|
"bin/",
|
package/server/handle-errors.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* - this should be the last handler loaded by the server
|
|
5
5
|
* - depends on serve-pages being invoked before this
|
|
6
6
|
*
|
|
7
|
-
* Copyright (c) 2015-
|
|
7
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/*eslint no-unused-vars: "off"*/
|
package/server/serve-pages.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* with page http-headers, checks http methods
|
|
6
6
|
* also serves redirects
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2015-
|
|
8
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
var debug = require('debug')('pub:server:pages');
|
package/server/serve-scripts.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* server optional, if not passed, no routes served
|
|
9
9
|
* serveStatics.outputAll() - copy scripts to outputs[0] (for pub -O)
|
|
10
10
|
*
|
|
11
|
-
* Copyright (c) 2015-
|
|
11
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
/* eslint no-empty: ["error", { "allowEmptyCatch": true }] */
|
|
@@ -17,7 +17,7 @@ var debug = require('debug')('pub:scripts');
|
|
|
17
17
|
var u = require('pub-util');
|
|
18
18
|
var through = require('through2');
|
|
19
19
|
var fspath = require('path'); // for platform specific path.join
|
|
20
|
-
var uglify = require('uglify-
|
|
20
|
+
var uglify = require('uglify-js');
|
|
21
21
|
var asyncbuilder = require('asyncbuilder');
|
|
22
22
|
var browserify = require('browserify');
|
|
23
23
|
|
|
@@ -172,7 +172,7 @@ module.exports = function serveScripts(opts) {
|
|
|
172
172
|
}
|
|
173
173
|
files.push( { path:script.route, text:str } );
|
|
174
174
|
filemap.push( { path:script.route } );
|
|
175
|
-
log('output script: %s (%d bytes, %d ms)', script.route, str
|
|
175
|
+
log('output script: %s (%d bytes, %d ms)', script.route, str?.length || 0, time());
|
|
176
176
|
scriptDone(null, script.route);
|
|
177
177
|
});
|
|
178
178
|
});
|
package/server/serve-sockets.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* primary purpose (for now) is for watchers to trigger page reload
|
|
6
6
|
* does nothing if opts.no-sockets is set (and disabled on production)
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2015-
|
|
8
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
|
package/server/serve-statics.js
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* extend to serve files from remote storage
|
|
19
19
|
* (supports only local files for now)
|
|
20
20
|
*
|
|
21
|
-
* Copyright (c) 2015-
|
|
21
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
var debug = require('debug')('pub:static');
|
|
@@ -194,7 +194,7 @@ module.exports = function serveStatics(opts, cb) {
|
|
|
194
194
|
// try straight match
|
|
195
195
|
var spo = file$[reqPath];
|
|
196
196
|
|
|
197
|
-
if (!spo &&
|
|
197
|
+
if (!spo && !/\/$/.test(reqPath)) {
|
|
198
198
|
|
|
199
199
|
// try adding trailing / and redirect if found
|
|
200
200
|
if (self.trailingSlash) {
|
package/server/watch-sources.js
CHANGED
package/server/watch.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* used by serve-statics and watch-sources
|
|
5
5
|
* TODO: dedup watches and look at aggregating watch paths with single watch
|
|
6
6
|
*
|
|
7
|
-
* Copyright (c) 2015-
|
|
7
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
var debug = require('debug')('pub:watch');
|
package/server.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* invoke directly via node command line, or via require()
|
|
6
6
|
* see: https://nodejs.org/api/modules.html#modules_accessing_the_main_module
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2015-
|
|
8
|
+
* Copyright (c) 2015-2024 Jürgen Leschner - github.com/jldec - MIT license
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
var debug = require('debug')('pub:server');
|
|
@@ -84,6 +84,23 @@ function pubServer(opts) {
|
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
if (opts.migrate) {
|
|
88
|
+
|
|
89
|
+
// only support single output for now
|
|
90
|
+
let output = opts.outputs[1];
|
|
91
|
+
if (!output) return log('No 2nd output (opts.output[1]) configured.');
|
|
92
|
+
|
|
93
|
+
generator.load(function(err) {
|
|
94
|
+
if (err) return log(err);
|
|
95
|
+
generator.migratePages(output, function(err) {
|
|
96
|
+
if (err) { log(err); }
|
|
97
|
+
generator.unload();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
87
104
|
generator.load(function(err) {
|
|
88
105
|
if (err) return log(err);
|
|
89
106
|
|