@webqit/webflo 0.8.76 → 0.9.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.
Files changed (97) hide show
  1. package/package.json +5 -12
  2. package/src/Cli.js +131 -0
  3. package/src/Configurator.js +97 -0
  4. package/src/Context.js +76 -0
  5. package/src/config-pi/deployment/Env.js +69 -0
  6. package/src/config-pi/deployment/Layout.js +65 -0
  7. package/src/config-pi/deployment/Origins.js +133 -0
  8. package/src/config-pi/deployment/Virtualization.js +65 -0
  9. package/src/config-pi/deployment/index.js +18 -0
  10. package/src/config-pi/index.js +16 -0
  11. package/src/config-pi/runtime/Client.js +59 -0
  12. package/src/config-pi/runtime/Server.js +174 -0
  13. package/src/config-pi/runtime/client/Worker.js +117 -0
  14. package/src/config-pi/runtime/client/index.js +12 -0
  15. package/src/config-pi/runtime/index.js +18 -0
  16. package/src/config-pi/runtime/server/Headers.js +90 -0
  17. package/src/config-pi/runtime/server/Redirects.js +108 -0
  18. package/src/config-pi/runtime/server/index.js +14 -0
  19. package/src/config-pi/static/Manifest.js +321 -0
  20. package/src/config-pi/static/Ssg.js +72 -0
  21. package/src/config-pi/static/index.js +14 -0
  22. package/src/deployment-pi/index.js +10 -0
  23. package/src/{services → deployment-pi}/origins/index.js +88 -58
  24. package/src/index.js +14 -147
  25. package/src/{runtime → runtime-pi}/Router.js +19 -19
  26. package/src/runtime-pi/client/Context.js +7 -0
  27. package/src/{runtime → runtime-pi}/client/Router.js +2 -2
  28. package/src/{runtime/client/Navigator.js → runtime-pi/client/Runtime.js} +143 -102
  29. package/src/runtime-pi/client/RuntimeClient.js +114 -0
  30. package/src/{runtime → runtime-pi}/client/Storage.js +8 -7
  31. package/src/{runtime → runtime-pi}/client/Url.js +2 -6
  32. package/src/{runtime/client/WorkerClient.js → runtime-pi/client/WorkerComm.js} +2 -2
  33. package/src/runtime-pi/client/generate.js +242 -0
  34. package/src/runtime-pi/client/generate.oohtml.js +7 -0
  35. package/src/runtime-pi/client/index.js +18 -0
  36. package/src/runtime-pi/client/whatwag.js +27 -0
  37. package/src/runtime-pi/client/worker/Context.js +7 -0
  38. package/src/runtime-pi/client/worker/Worker.js +243 -0
  39. package/src/runtime-pi/client/worker/WorkerClient.js +46 -0
  40. package/src/runtime-pi/client/worker/index.js +18 -0
  41. package/src/runtime-pi/index.js +14 -0
  42. package/src/runtime-pi/server/Context.js +16 -0
  43. package/src/{runtime → runtime-pi}/server/Router.js +6 -6
  44. package/src/runtime-pi/server/Runtime.js +531 -0
  45. package/src/runtime-pi/server/RuntimeClient.js +102 -0
  46. package/src/runtime-pi/server/index.js +41 -0
  47. package/src/runtime-pi/server/whatwag.js +35 -0
  48. package/src/{runtime → runtime-pi}/util.js +0 -0
  49. package/src/{runtime/_FormData.js → runtime-pi/xFormData.js} +2 -2
  50. package/src/{runtime/_Headers.js → runtime-pi/xHeaders.js} +4 -4
  51. package/src/runtime-pi/xHttpEvent.js +93 -0
  52. package/src/runtime-pi/xHttpMessage.js +179 -0
  53. package/src/runtime-pi/xRequest.js +67 -0
  54. package/src/runtime-pi/xRequestHeaders.js +95 -0
  55. package/src/runtime-pi/xResponse.js +62 -0
  56. package/src/{runtime/_ResponseHeaders.js → runtime-pi/xResponseHeaders.js} +38 -18
  57. package/src/{runtime/_URL.js → runtime-pi/xURL.js} +4 -4
  58. package/src/runtime-pi/xfetch.js +7 -0
  59. package/src/{services → services-pi}/certbot/http-auth-hook.js +0 -0
  60. package/src/{services → services-pi}/certbot/http-cleanup-hook.js +0 -0
  61. package/src/{services → services-pi}/certbot/index.js +21 -15
  62. package/src/services-pi/index.js +9 -0
  63. package/src/static-pi/index.js +11 -0
  64. package/src/webflo.js +33 -0
  65. package/test/index.test.js +26 -0
  66. package/src/build/client/index.js +0 -261
  67. package/src/build/index.js +0 -5
  68. package/src/config/client.js +0 -191
  69. package/src/config/headers.js +0 -121
  70. package/src/config/index.js +0 -14
  71. package/src/config/layout.js +0 -83
  72. package/src/config/manifest.js +0 -341
  73. package/src/config/origins.js +0 -165
  74. package/src/config/prerendering.js +0 -100
  75. package/src/config/redirects.js +0 -137
  76. package/src/config/server.js +0 -201
  77. package/src/config/variables.js +0 -102
  78. package/src/config/vhosts.js +0 -93
  79. package/src/runtime/_MessageStream.js +0 -195
  80. package/src/runtime/_NavigationEvent.js +0 -91
  81. package/src/runtime/_Request.js +0 -61
  82. package/src/runtime/_RequestHeaders.js +0 -72
  83. package/src/runtime/_Response.js +0 -56
  84. package/src/runtime/client/Cache.js +0 -38
  85. package/src/runtime/client/Http.js +0 -225
  86. package/src/runtime/client/NavigationEvent.js +0 -21
  87. package/src/runtime/client/Runtime.js +0 -126
  88. package/src/runtime/client/StdRequest.js +0 -74
  89. package/src/runtime/client/Worker.js +0 -312
  90. package/src/runtime/client/WorkerComm.js +0 -183
  91. package/src/runtime/client/effects/sounds.js +0 -64
  92. package/src/runtime/index.js +0 -5
  93. package/src/runtime/server/NavigationEvent.js +0 -39
  94. package/src/runtime/server/Runtime.js +0 -593
  95. package/src/runtime/server/index.js +0 -183
  96. package/src/runtime/server/index.mjs +0 -10
  97. package/src/services/index.js +0 -6
@@ -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
- };
@@ -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
- };
@@ -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
- };
@@ -1,93 +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
-
11
- /**
12
- * Reads entries 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}/vhosts${ext}.json`;
23
- const availableExt = anyExists([ext, '', '.example'], fileName);
24
- const config = DotJson.read(fileName(availableExt));
25
- return _merge({
26
- entries: [],
27
- }, config);
28
- };
29
-
30
- /**
31
- * Writes entries to file.
32
- *
33
- * @param object config
34
- * @param object flags
35
- * @param object layout
36
- *
37
- * @return void
38
- */
39
- export async function write(config, flags = {}, layout = {}) {
40
- const ext = flags.env ? `.${flags.env}` : '';
41
- const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
42
- const fileName = ext => `${configDir}/vhosts${ext}.json`;
43
- DotJson.write(config, fileName(ext));
44
- };
45
-
46
- /**
47
- * @match
48
- */
49
- export async function match(hostname, flags = {}, layout = {}) {
50
- if (_isObject(hostname)) {
51
- hostname = hostname.hostname;
52
- }
53
- return ((await read(flags, layout)).entries || []).filter(vh => vh.host === hostname);
54
- };
55
-
56
- /**
57
- * Configures entries.
58
- *
59
- * @param object config
60
- * @param object choices
61
- * @param object layout
62
- *
63
- * @return Array
64
- */
65
- export async function questions(config, choices = {}, layout = {}) {
66
-
67
- // Questions
68
- return [
69
- {
70
- name: 'entries',
71
- type: 'recursive',
72
- controls: {
73
- name: 'vhost',
74
- },
75
- initial: config.entries,
76
- questions: [
77
- {
78
- name: 'host',
79
- type: 'text',
80
- message: 'Enter Host name',
81
- validation: ['important'],
82
- },
83
- {
84
- name: 'path',
85
- type: 'text',
86
- message: 'Enter local path',
87
- validation: ['important'],
88
- },
89
- ],
90
- },
91
-
92
- ];
93
- };