@webqit/webflo 0.8.77 → 0.9.1
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/package.json +5 -12
- package/src/Cli.js +131 -0
- package/src/Configurator.js +97 -0
- package/src/Context.js +76 -0
- package/src/config-pi/deployment/Env.js +69 -0
- package/src/config-pi/deployment/Layout.js +65 -0
- package/src/config-pi/deployment/Origins.js +133 -0
- package/src/config-pi/deployment/Virtualization.js +65 -0
- package/src/config-pi/deployment/index.js +18 -0
- package/src/config-pi/index.js +16 -0
- package/src/config-pi/runtime/Client.js +59 -0
- package/src/config-pi/runtime/Server.js +174 -0
- package/src/config-pi/runtime/client/Worker.js +117 -0
- package/src/config-pi/runtime/client/index.js +12 -0
- package/src/config-pi/runtime/index.js +18 -0
- package/src/config-pi/runtime/server/Headers.js +90 -0
- package/src/config-pi/runtime/server/Redirects.js +108 -0
- package/src/config-pi/runtime/server/index.js +14 -0
- package/src/config-pi/static/Manifest.js +321 -0
- package/src/config-pi/static/Ssg.js +72 -0
- package/src/config-pi/static/index.js +14 -0
- package/src/deployment-pi/index.js +10 -0
- package/src/{services → deployment-pi}/origins/index.js +88 -58
- package/src/index.js +14 -147
- package/src/{runtime → runtime-pi}/Router.js +19 -19
- package/src/runtime-pi/client/Context.js +7 -0
- package/src/{runtime → runtime-pi}/client/Router.js +2 -2
- package/src/{runtime/client/Navigator.js → runtime-pi/client/Runtime.js} +148 -103
- package/src/runtime-pi/client/RuntimeClient.js +114 -0
- package/src/{runtime → runtime-pi}/client/Storage.js +1 -1
- package/src/{runtime → runtime-pi}/client/Url.js +2 -6
- package/src/{runtime/client/WorkerClient.js → runtime-pi/client/WorkerComm.js} +2 -2
- package/src/runtime-pi/client/generate.js +242 -0
- package/src/runtime-pi/client/generate.oohtml.js +7 -0
- package/src/runtime-pi/client/index.js +18 -0
- package/src/runtime-pi/client/whatwag.js +27 -0
- package/src/runtime-pi/client/worker/Context.js +7 -0
- package/src/runtime-pi/client/worker/Worker.js +243 -0
- package/src/runtime-pi/client/worker/WorkerClient.js +46 -0
- package/src/runtime-pi/client/worker/index.js +18 -0
- package/src/runtime-pi/index.js +14 -0
- package/src/runtime-pi/server/Context.js +16 -0
- package/src/{runtime → runtime-pi}/server/Router.js +6 -6
- package/src/runtime-pi/server/Runtime.js +531 -0
- package/src/runtime-pi/server/RuntimeClient.js +103 -0
- package/src/runtime-pi/server/index.js +41 -0
- package/src/runtime-pi/server/whatwag.js +35 -0
- package/src/{runtime → runtime-pi}/util.js +0 -0
- package/src/{runtime/_FormData.js → runtime-pi/xFormData.js} +2 -2
- package/src/{runtime/_Headers.js → runtime-pi/xHeaders.js} +4 -4
- package/src/runtime-pi/xHttpEvent.js +93 -0
- package/src/runtime-pi/xHttpMessage.js +179 -0
- package/src/runtime-pi/xRequest.js +67 -0
- package/src/runtime-pi/xRequestHeaders.js +95 -0
- package/src/runtime-pi/xResponse.js +62 -0
- package/src/{runtime/_ResponseHeaders.js → runtime-pi/xResponseHeaders.js} +38 -18
- package/src/{runtime/_URL.js → runtime-pi/xURL.js} +4 -4
- package/src/runtime-pi/xfetch.js +7 -0
- package/src/{services → services-pi}/certbot/http-auth-hook.js +0 -0
- package/src/{services → services-pi}/certbot/http-cleanup-hook.js +0 -0
- package/src/{services → services-pi}/certbot/index.js +21 -15
- package/src/services-pi/index.js +9 -0
- package/src/static-pi/index.js +11 -0
- package/src/webflo.js +33 -0
- package/test/index.test.js +26 -0
- package/src/build/client/index.js +0 -261
- package/src/build/index.js +0 -5
- package/src/config/client.js +0 -191
- package/src/config/headers.js +0 -121
- package/src/config/index.js +0 -14
- package/src/config/layout.js +0 -83
- package/src/config/manifest.js +0 -341
- package/src/config/origins.js +0 -165
- package/src/config/prerendering.js +0 -100
- package/src/config/redirects.js +0 -137
- package/src/config/server.js +0 -201
- package/src/config/variables.js +0 -102
- package/src/config/vhosts.js +0 -93
- package/src/runtime/_MessageStream.js +0 -195
- package/src/runtime/_NavigationEvent.js +0 -91
- package/src/runtime/_Request.js +0 -59
- package/src/runtime/_RequestHeaders.js +0 -72
- package/src/runtime/_Response.js +0 -56
- package/src/runtime/client/NavigationEvent.js +0 -21
- package/src/runtime/client/Runtime.js +0 -126
- package/src/runtime/client/Worker.js +0 -317
- package/src/runtime/client/archive/Cache.js +0 -38
- package/src/runtime/client/archive/Http.js +0 -225
- package/src/runtime/client/archive/StdRequest.js +0 -74
- package/src/runtime/client/archive/WorkerComm.js +0 -183
- package/src/runtime/client/effects/sounds.js +0 -64
- package/src/runtime/index.js +0 -5
- package/src/runtime/server/NavigationEvent.js +0 -39
- package/src/runtime/server/Runtime.js +0 -593
- package/src/runtime/server/index.js +0 -183
- package/src/runtime/server/index.mjs +0 -10
- package/src/services/index.js +0 -6
package/src/config/origins.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* imports
|
|
4
|
-
*/
|
|
5
|
-
import Fs from 'fs';
|
|
6
|
-
import Url from 'url';
|
|
7
|
-
import Path from 'path';
|
|
8
|
-
import _merge from '@webqit/util/obj/merge.js';
|
|
9
|
-
import _before from '@webqit/util/str/before.js';
|
|
10
|
-
import _isTypeObject from '@webqit/util/js/isTypeObject.js';
|
|
11
|
-
import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Reads entries from file.
|
|
15
|
-
*
|
|
16
|
-
* @param object flags
|
|
17
|
-
* @param object layout
|
|
18
|
-
*
|
|
19
|
-
* @return object
|
|
20
|
-
*/
|
|
21
|
-
export async function read(flags = {}, layout = {}) {
|
|
22
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
23
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
24
|
-
const fileName = ext => `${configDir}/origins${ext}.json`;
|
|
25
|
-
const availableExt = anyExists([ext, '', '.example'], fileName);
|
|
26
|
-
const config = DotJson.read(fileName(availableExt));
|
|
27
|
-
|
|
28
|
-
var hostname = '', origin = '';
|
|
29
|
-
if (layout.PKG && layout.PKG.repository) {
|
|
30
|
-
var inferredRepo = Url.parse(_isTypeObject(layout.PKG.repository) ? layout.PKG.repository.url : layout.PKG.repository);
|
|
31
|
-
hostname = _before(inferredRepo.hostname, '.');
|
|
32
|
-
origin = _before(inferredRepo.pathname, '.');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Params
|
|
36
|
-
return _merge({
|
|
37
|
-
entries: [{
|
|
38
|
-
host: hostname,
|
|
39
|
-
repo: origin,
|
|
40
|
-
branch: 'master',
|
|
41
|
-
tag: 'root',
|
|
42
|
-
deploy_path: '.',
|
|
43
|
-
autodeploy: true,
|
|
44
|
-
autodeploy_secret: '',
|
|
45
|
-
ondeploy: 'npm install',
|
|
46
|
-
ondeploy_autoexit: true,
|
|
47
|
-
}],
|
|
48
|
-
}, config);
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Writes entries to file.
|
|
54
|
-
*
|
|
55
|
-
* @param object config
|
|
56
|
-
* @param object flags
|
|
57
|
-
* @param object layout
|
|
58
|
-
*
|
|
59
|
-
* @return void
|
|
60
|
-
*/
|
|
61
|
-
export async function write(config, flags = {}, layout = {}) {
|
|
62
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
63
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
64
|
-
const fileName = ext => `${configDir}/origins${ext}.json`;
|
|
65
|
-
DotJson.write(config, fileName(ext));
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* @match
|
|
70
|
-
*/
|
|
71
|
-
export async function match(origin, flags = {}, layout = {}) {
|
|
72
|
-
return ((await read(flags, layout)).entries || []).filter(_origin => _origin.tag.toLowerCase() === origin.toLowerCase() || _origin.repo.toLowerCase() === origin.toLowerCase());
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Configures entries.
|
|
77
|
-
*
|
|
78
|
-
* @param object config
|
|
79
|
-
* @param object choices
|
|
80
|
-
* @param object layout
|
|
81
|
-
*
|
|
82
|
-
* @return Array
|
|
83
|
-
*/
|
|
84
|
-
export async function questions(config, choices = {}, layout = {}) {
|
|
85
|
-
|
|
86
|
-
// Choices
|
|
87
|
-
const CHOICES = _merge({
|
|
88
|
-
host: [
|
|
89
|
-
{value: 'github',},
|
|
90
|
-
{value: 'bitbucket',},
|
|
91
|
-
],
|
|
92
|
-
}, choices);
|
|
93
|
-
|
|
94
|
-
// Questions
|
|
95
|
-
return [
|
|
96
|
-
{
|
|
97
|
-
name: 'entries',
|
|
98
|
-
type: 'recursive',
|
|
99
|
-
controls: {
|
|
100
|
-
name: 'repository',
|
|
101
|
-
},
|
|
102
|
-
initial: config.entries,
|
|
103
|
-
questions: [
|
|
104
|
-
{
|
|
105
|
-
name: 'host',
|
|
106
|
-
type: 'select',
|
|
107
|
-
message: 'Host name',
|
|
108
|
-
choices: CHOICES.host,
|
|
109
|
-
validation: ['input', 'important'],
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: 'repo',
|
|
113
|
-
type: 'text',
|
|
114
|
-
message: 'Enter a repository name (in the format: user-or-org/origin)',
|
|
115
|
-
validation: ['input', 'important'],
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
name: 'branch',
|
|
119
|
-
type: 'text',
|
|
120
|
-
message: 'Specifiy the git branch within the given repository',
|
|
121
|
-
validation: ['input', 'important'],
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
name: 'tag',
|
|
125
|
-
type: 'text',
|
|
126
|
-
message: 'Enter a local name for this origin',
|
|
127
|
-
validation: ['input', 'important'],
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: 'deploy_path',
|
|
131
|
-
type: 'text',
|
|
132
|
-
message: 'Enter the relative local path that this origin deploys to',
|
|
133
|
-
validation: ['important'],
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'autodeploy',
|
|
137
|
-
type: 'toggle',
|
|
138
|
-
message: 'Auto-deploy this origin on every push to branch?',
|
|
139
|
-
active: 'YES',
|
|
140
|
-
inactive: 'NO',
|
|
141
|
-
},
|
|
142
|
-
{
|
|
143
|
-
name: 'autodeploy_secret',
|
|
144
|
-
type: (prev, ans) => ans.autodeploy ? 'text' : null,
|
|
145
|
-
message: 'Enter the "secret" for validating the auto-deploy webhook event',
|
|
146
|
-
validation: ['input', 'important'],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
name: 'ondeploy',
|
|
150
|
-
type: 'text',
|
|
151
|
-
message: 'Enter an optional "command" to run on deploy',
|
|
152
|
-
validation: ['input', 'important'],
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
name: 'ondeploy_autoexit',
|
|
156
|
-
type: (prev, ans) => ans.autodeploy ? 'toggle' : null,
|
|
157
|
-
message: 'Auto exit process on deploy?',
|
|
158
|
-
active: 'YES',
|
|
159
|
-
inactive: 'NO',
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
];
|
|
165
|
-
};
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* imports
|
|
4
|
-
*/
|
|
5
|
-
import Fs from 'fs';
|
|
6
|
-
import Path from 'path';
|
|
7
|
-
import _merge from '@webqit/util/obj/merge.js';
|
|
8
|
-
import _isObject from '@webqit/util/js/isObject.js';
|
|
9
|
-
import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
|
|
10
|
-
import Micromatch from 'micromatch';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Reads entries from file.
|
|
14
|
-
*
|
|
15
|
-
* @param object flags
|
|
16
|
-
* @param object layout
|
|
17
|
-
*
|
|
18
|
-
* @return object
|
|
19
|
-
*/
|
|
20
|
-
export async function read(flags = {}, layout = {}) {
|
|
21
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
22
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
23
|
-
const fileName = ext => `${configDir}/prerendering${ext}.json`;
|
|
24
|
-
const availableExt = anyExists([ext, '', '.example'], fileName);
|
|
25
|
-
const config = DotJson.read(fileName(availableExt));
|
|
26
|
-
return _merge({
|
|
27
|
-
entries: [],
|
|
28
|
-
}, config);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Writes entries to file.
|
|
33
|
-
*
|
|
34
|
-
* @param object config
|
|
35
|
-
* @param object flags
|
|
36
|
-
* @param object layout
|
|
37
|
-
*
|
|
38
|
-
* @return void
|
|
39
|
-
*/
|
|
40
|
-
export async function write(config, flags = {}, layout = {}) {
|
|
41
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
42
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
43
|
-
const fileName = ext => `${configDir}/prerendering${ext}.json`;
|
|
44
|
-
DotJson.write(config, fileName(ext));
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* @match
|
|
49
|
-
*/
|
|
50
|
-
export async function match(url, flags = {}, layout = {}) {
|
|
51
|
-
var pathname = url;
|
|
52
|
-
if (_isObject(url)) {
|
|
53
|
-
pathname = url.pathname;
|
|
54
|
-
}
|
|
55
|
-
return ((await read(flags, layout)).entries || []).reduce((match, prerend) => {
|
|
56
|
-
if (match) {
|
|
57
|
-
return match;
|
|
58
|
-
}
|
|
59
|
-
var regex = Micromatch.makeRe(prerend.page, {dot: true});
|
|
60
|
-
var rootMatch = pathname.split('/').filter(seg => seg).map(seg => seg.trim()).reduce((str, seg) => str.endsWith(' ') ? str : ((str = str + '/' + seg) && str.match(regex) ? str + ' ' : str), '');
|
|
61
|
-
if (rootMatch.endsWith(' ')) {
|
|
62
|
-
return {
|
|
63
|
-
url: prerend.page,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
}, null);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Configures entries.
|
|
71
|
-
*
|
|
72
|
-
* @param object config
|
|
73
|
-
* @param object choices
|
|
74
|
-
* @param object layout
|
|
75
|
-
*
|
|
76
|
-
* @return Array
|
|
77
|
-
*/
|
|
78
|
-
export async function questions(config, choices = {}, layout = {}) {
|
|
79
|
-
|
|
80
|
-
// Questions
|
|
81
|
-
return [
|
|
82
|
-
{
|
|
83
|
-
name: 'entries',
|
|
84
|
-
type: 'recursive',
|
|
85
|
-
controls: {
|
|
86
|
-
name: 'page',
|
|
87
|
-
},
|
|
88
|
-
initial: config.entries,
|
|
89
|
-
questions: [
|
|
90
|
-
{
|
|
91
|
-
name: 'page',
|
|
92
|
-
type: 'text',
|
|
93
|
-
message: 'Page URL',
|
|
94
|
-
validation: ['important'],
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
];
|
|
100
|
-
};
|
package/src/config/redirects.js
DELETED
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* imports
|
|
4
|
-
*/
|
|
5
|
-
import Fs from 'fs';
|
|
6
|
-
import Url from 'url';
|
|
7
|
-
import Path from 'path';
|
|
8
|
-
import _merge from '@webqit/util/obj/merge.js';
|
|
9
|
-
import _after from '@webqit/util/str/after.js';
|
|
10
|
-
import _isObject from '@webqit/util/js/isObject.js';
|
|
11
|
-
import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
|
|
12
|
-
import Micromatch from 'micromatch';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Reads entries from file.
|
|
16
|
-
*
|
|
17
|
-
* @param object flags
|
|
18
|
-
* @param object layout
|
|
19
|
-
*
|
|
20
|
-
* @return object
|
|
21
|
-
*/
|
|
22
|
-
export async function read(flags = {}, layout = {}) {
|
|
23
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
24
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
25
|
-
const fileName = ext => `${configDir}/redirects${ext}.json`;
|
|
26
|
-
const availableExt = anyExists([ext, '', '.example'], fileName);
|
|
27
|
-
const config = DotJson.read(fileName(availableExt));
|
|
28
|
-
return _merge({
|
|
29
|
-
entries: [],
|
|
30
|
-
}, config);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Writes entries to file.
|
|
35
|
-
*
|
|
36
|
-
* @param object config
|
|
37
|
-
* @param object flags
|
|
38
|
-
* @param object layout
|
|
39
|
-
*
|
|
40
|
-
* @return void
|
|
41
|
-
*/
|
|
42
|
-
export async function write(config, flags = {}, layout = {}) {
|
|
43
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
44
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
45
|
-
const fileName = ext => `${configDir}/redirects${ext}.json`;
|
|
46
|
-
DotJson.write(config, fileName(ext));
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* @match
|
|
51
|
-
*/
|
|
52
|
-
export async function match(url, flags = {}, layout = {}) {
|
|
53
|
-
if (!_isObject(url)) {
|
|
54
|
-
url = Url.parse(url);
|
|
55
|
-
}
|
|
56
|
-
return ((await read(flags, layout)).entries || []).reduce((match, rdr) => {
|
|
57
|
-
if (match) {
|
|
58
|
-
return match;
|
|
59
|
-
}
|
|
60
|
-
var regex = Micromatch.makeRe(rdr.from, {dot: true});
|
|
61
|
-
var rootMatch = url.pathname.split('/').filter(seg => seg).map(seg => seg.trim()).reduce((str, seg) => str.endsWith(' ') ? str : ((str = str + '/' + seg) && str.match(regex) ? str + ' ' : str), '');
|
|
62
|
-
if (rootMatch.endsWith(' ')) {
|
|
63
|
-
var leaf = _after(url.pathname, rootMatch.trim());
|
|
64
|
-
var [ target, targetQuery ] = rdr.to.split('?');
|
|
65
|
-
if (rdr.reuseQuery) {
|
|
66
|
-
targetQuery = [(url.search || '').substr(1), targetQuery].filter(str => str).join('&');
|
|
67
|
-
}
|
|
68
|
-
// ---------------
|
|
69
|
-
return {
|
|
70
|
-
target: target + leaf + (targetQuery ? (leaf.endsWith('?') || leaf.endsWith('&') ? '' : (leaf.includes('?') ? '&' : '?')) + targetQuery : ''),
|
|
71
|
-
query: targetQuery,
|
|
72
|
-
code: rdr.code,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}, null);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Configures entries.
|
|
80
|
-
*
|
|
81
|
-
* @param object config
|
|
82
|
-
* @param object choices
|
|
83
|
-
* @param object layout
|
|
84
|
-
*
|
|
85
|
-
* @return Array
|
|
86
|
-
*/
|
|
87
|
-
export async function questions(config, choices = {}, layout = {}) {
|
|
88
|
-
|
|
89
|
-
// Choices
|
|
90
|
-
const CHOICES = _merge({
|
|
91
|
-
code: [
|
|
92
|
-
{value: 302,},
|
|
93
|
-
{value: 301,},
|
|
94
|
-
],
|
|
95
|
-
}, choices);
|
|
96
|
-
|
|
97
|
-
// Questions
|
|
98
|
-
return [
|
|
99
|
-
{
|
|
100
|
-
name: 'entries',
|
|
101
|
-
type: 'recursive',
|
|
102
|
-
controls: {
|
|
103
|
-
name: 'redirect',
|
|
104
|
-
},
|
|
105
|
-
initial: config.entries,
|
|
106
|
-
questions: [
|
|
107
|
-
{
|
|
108
|
-
name: 'from',
|
|
109
|
-
type: 'text',
|
|
110
|
-
message: 'Enter "from" URL',
|
|
111
|
-
validation: ['important'],
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
name: 'to',
|
|
115
|
-
type: 'text',
|
|
116
|
-
message: 'Enter "to" URL',
|
|
117
|
-
validation: ['important'],
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: 'reuseQuery',
|
|
121
|
-
type: 'toggle',
|
|
122
|
-
message: 'Reuse query parameters from matched URL in destination URL?',
|
|
123
|
-
active: 'YES',
|
|
124
|
-
inactive: 'NO',
|
|
125
|
-
},
|
|
126
|
-
{
|
|
127
|
-
name: 'code',
|
|
128
|
-
type: 'select',
|
|
129
|
-
choices: CHOICES.code,
|
|
130
|
-
message: 'Enter redirect code',
|
|
131
|
-
validation: ['number', 'important'],
|
|
132
|
-
},
|
|
133
|
-
],
|
|
134
|
-
},
|
|
135
|
-
|
|
136
|
-
];
|
|
137
|
-
};
|
package/src/config/server.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* imports
|
|
4
|
-
*/
|
|
5
|
-
import Fs from 'fs';
|
|
6
|
-
import Path from 'path';
|
|
7
|
-
import _merge from '@webqit/util/obj/merge.js';
|
|
8
|
-
import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
|
|
9
|
-
import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Reads RUNTIME from file.
|
|
13
|
-
*
|
|
14
|
-
* @param object flags
|
|
15
|
-
* @param object layout
|
|
16
|
-
*
|
|
17
|
-
* @return object
|
|
18
|
-
*/
|
|
19
|
-
export async function read(flags = {}, layout = {}) {
|
|
20
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
21
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
22
|
-
const fileName = ext => `${configDir}/server${ext}.json`;
|
|
23
|
-
const availableExt = anyExists([ext, '', '.example'], fileName);
|
|
24
|
-
const config = DotJson.read(fileName(availableExt));
|
|
25
|
-
return _merge({
|
|
26
|
-
port: process.env.port || 3000,
|
|
27
|
-
https: {
|
|
28
|
-
port: 0,
|
|
29
|
-
keyfile: '',
|
|
30
|
-
certfile: '',
|
|
31
|
-
certdoms: ['*'],
|
|
32
|
-
force: false,
|
|
33
|
-
},
|
|
34
|
-
process: {
|
|
35
|
-
name: Path.basename(process.cwd()),
|
|
36
|
-
errfile: '',
|
|
37
|
-
outfile: '',
|
|
38
|
-
exec_mode: 'fork',
|
|
39
|
-
autorestart: true,
|
|
40
|
-
merge_logs: false,
|
|
41
|
-
},
|
|
42
|
-
force_www: '',
|
|
43
|
-
shared: false,
|
|
44
|
-
}, config);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Writes RUNTIME to file.
|
|
49
|
-
*
|
|
50
|
-
* @param object config
|
|
51
|
-
* @param object flags
|
|
52
|
-
* @param object layout
|
|
53
|
-
*
|
|
54
|
-
* @return void
|
|
55
|
-
*/
|
|
56
|
-
export async function write(config, flags = {}, layout = {}) {
|
|
57
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
58
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
59
|
-
const fileName = ext => `${configDir}/server${ext}.json`;
|
|
60
|
-
DotJson.write(config, fileName(ext));
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Configures RUNTIME.
|
|
65
|
-
*
|
|
66
|
-
* @param object config
|
|
67
|
-
* @param object choices
|
|
68
|
-
* @param object layout
|
|
69
|
-
*
|
|
70
|
-
* @return Array
|
|
71
|
-
*/
|
|
72
|
-
export async function questions(config, choices = {}, layout = {}) {
|
|
73
|
-
|
|
74
|
-
// Choices
|
|
75
|
-
const CHOICES = _merge({
|
|
76
|
-
exec_mode: [
|
|
77
|
-
{value: 'fork',},
|
|
78
|
-
{value: 'cluster',},
|
|
79
|
-
],
|
|
80
|
-
force_www: [
|
|
81
|
-
{value: '', title: 'do nothing'},
|
|
82
|
-
{value: 'add',},
|
|
83
|
-
{value: 'remove',},
|
|
84
|
-
],
|
|
85
|
-
}, choices);
|
|
86
|
-
|
|
87
|
-
// Questions
|
|
88
|
-
return [
|
|
89
|
-
{
|
|
90
|
-
name: 'port',
|
|
91
|
-
type: 'number',
|
|
92
|
-
message: 'Enter port number',
|
|
93
|
-
initial: config.port,
|
|
94
|
-
validation: ['important'],
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
name: 'https',
|
|
98
|
-
initial: config.https,
|
|
99
|
-
controls: {
|
|
100
|
-
name: 'https',
|
|
101
|
-
},
|
|
102
|
-
questions: [
|
|
103
|
-
{
|
|
104
|
-
name: 'port',
|
|
105
|
-
type: 'number',
|
|
106
|
-
message: 'Enter HTTPS port number',
|
|
107
|
-
validation: ['important'],
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: 'keyfile',
|
|
111
|
-
type: 'text',
|
|
112
|
-
message: 'Enter SSL KEY file',
|
|
113
|
-
validation: ['important'],
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
name: 'certfile',
|
|
117
|
-
type: 'text',
|
|
118
|
-
message: 'Enter SSL CERT file',
|
|
119
|
-
validation: ['important'],
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'certdoms',
|
|
123
|
-
type: 'list',
|
|
124
|
-
message: 'Enter the CERT domains (comma-separated)',
|
|
125
|
-
validation: ['important'],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
name: 'force',
|
|
129
|
-
type: 'toggle',
|
|
130
|
-
message: 'Force HTTPS?',
|
|
131
|
-
active: 'YES',
|
|
132
|
-
inactive: 'NO',
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
},
|
|
136
|
-
{
|
|
137
|
-
name: 'process',
|
|
138
|
-
initial: config.process,
|
|
139
|
-
controls: {
|
|
140
|
-
name: 'background process',
|
|
141
|
-
},
|
|
142
|
-
questions: [
|
|
143
|
-
{
|
|
144
|
-
name: 'name',
|
|
145
|
-
type: 'text',
|
|
146
|
-
message: 'Enter a name for process',
|
|
147
|
-
validation: ['important'],
|
|
148
|
-
},
|
|
149
|
-
{
|
|
150
|
-
name: 'errfile',
|
|
151
|
-
type: 'text',
|
|
152
|
-
message: 'Enter path to error file',
|
|
153
|
-
validation: ['important'],
|
|
154
|
-
},
|
|
155
|
-
{
|
|
156
|
-
name: 'outfile',
|
|
157
|
-
type: 'text',
|
|
158
|
-
message: 'Enter path to output file',
|
|
159
|
-
validation: ['important'],
|
|
160
|
-
},
|
|
161
|
-
{
|
|
162
|
-
name: 'exec_mode',
|
|
163
|
-
type: 'select',
|
|
164
|
-
message: 'Select exec mode',
|
|
165
|
-
choices: CHOICES.exec_mode,
|
|
166
|
-
validation: ['important'],
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
name: 'autorestart',
|
|
170
|
-
type: 'toggle',
|
|
171
|
-
message: 'Server autorestart on crash?',
|
|
172
|
-
active: 'YES',
|
|
173
|
-
inactive: 'NO',
|
|
174
|
-
initial: config.autorestart,
|
|
175
|
-
},
|
|
176
|
-
{
|
|
177
|
-
name: 'merge_logs',
|
|
178
|
-
type: 'toggle',
|
|
179
|
-
message: 'Server merge logs?',
|
|
180
|
-
active: 'YES',
|
|
181
|
-
inactive: 'NO',
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: 'force_www',
|
|
187
|
-
type: 'select',
|
|
188
|
-
message: 'Force add/remove "www" on hostname?',
|
|
189
|
-
choices: CHOICES.force_www,
|
|
190
|
-
initial: initialGetIndex(CHOICES.force_www, config.force_www),
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
name: 'shared',
|
|
194
|
-
type: 'toggle',
|
|
195
|
-
message: 'Shared server?',
|
|
196
|
-
active: 'YES',
|
|
197
|
-
inactive: 'NO',
|
|
198
|
-
initial: config.shared,
|
|
199
|
-
},
|
|
200
|
-
];
|
|
201
|
-
};
|
package/src/config/variables.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* imports
|
|
4
|
-
*/
|
|
5
|
-
import Fs from 'fs';
|
|
6
|
-
import Path from 'path';
|
|
7
|
-
import _merge from '@webqit/util/obj/merge.js';
|
|
8
|
-
import { DotJson, DotEnv, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Reads entries from file.
|
|
12
|
-
*
|
|
13
|
-
* @param object flags
|
|
14
|
-
* @param object layout
|
|
15
|
-
*
|
|
16
|
-
* @return object
|
|
17
|
-
*/
|
|
18
|
-
export async function read(flags = {}, layout = {}) {
|
|
19
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
20
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
21
|
-
const envDir = Path.resolve(layout.ROOT || '');
|
|
22
|
-
const fileName = ext => `${configDir}/variables${ext}.json`;
|
|
23
|
-
const envFileName = ext => `${envDir}/.env${ext}`;
|
|
24
|
-
const availableExt = anyExists([ext, '', '.example'], fileName);
|
|
25
|
-
const availableEnvExt = anyExists([ext, '', '.example'], envFileName);
|
|
26
|
-
const config = DotJson.read(fileName(availableExt));
|
|
27
|
-
return _merge({
|
|
28
|
-
autoload: true,
|
|
29
|
-
}, config, {
|
|
30
|
-
entries: DotEnv.read(envFileName(availableEnvExt)) || {},
|
|
31
|
-
});
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Writes entries to file.
|
|
36
|
-
*
|
|
37
|
-
* @param object config
|
|
38
|
-
* @param object flags
|
|
39
|
-
* @param object layout
|
|
40
|
-
*
|
|
41
|
-
* @return void
|
|
42
|
-
*/
|
|
43
|
-
export async function write(config, flags = {}, layout = {}) {
|
|
44
|
-
const ext = flags.env ? `.${flags.env}` : '';
|
|
45
|
-
const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
|
|
46
|
-
const envDir = Path.resolve(layout.ROOT || '');
|
|
47
|
-
const fileName = ext => `${configDir}/variables${ext}.json`;
|
|
48
|
-
const envFileName = ext => `${envDir}/.env${ext}`;
|
|
49
|
-
|
|
50
|
-
const _config = {...config};
|
|
51
|
-
DotEnv.write(_config.entries, envFileName(ext));
|
|
52
|
-
|
|
53
|
-
delete _config.entries;
|
|
54
|
-
DotJson.write(_config, fileName(ext));
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Configures entries.
|
|
59
|
-
*
|
|
60
|
-
* @param object config
|
|
61
|
-
* @param object CHOICES
|
|
62
|
-
* @param object layout
|
|
63
|
-
*
|
|
64
|
-
* @return Array
|
|
65
|
-
*/
|
|
66
|
-
export async function questions(config, choices = {}, layout = {}) {
|
|
67
|
-
|
|
68
|
-
// Questions
|
|
69
|
-
return [
|
|
70
|
-
{
|
|
71
|
-
name: 'entries',
|
|
72
|
-
type: 'recursive',
|
|
73
|
-
controls: {
|
|
74
|
-
name: 'variable',
|
|
75
|
-
combomode: true,
|
|
76
|
-
},
|
|
77
|
-
initial: config.entries,
|
|
78
|
-
questions: [
|
|
79
|
-
{
|
|
80
|
-
name: 'name',
|
|
81
|
-
type: 'text',
|
|
82
|
-
message: 'Name',
|
|
83
|
-
validation: ['important'],
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
name: 'value',
|
|
87
|
-
type: 'text',
|
|
88
|
-
message: 'Value',
|
|
89
|
-
validation: ['important'],
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
{
|
|
94
|
-
name: 'autoload',
|
|
95
|
-
type: 'toggle',
|
|
96
|
-
message: 'Choose whether to autoload variables into "process.env"',
|
|
97
|
-
active: 'YES',
|
|
98
|
-
inactive: 'NO',
|
|
99
|
-
initial: config.autoload,
|
|
100
|
-
},
|
|
101
|
-
];
|
|
102
|
-
};
|