@webqit/webflo 0.11.35 → 0.11.37

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 CHANGED
@@ -12,7 +12,7 @@
12
12
  "vanila-javascript"
13
13
  ],
14
14
  "homepage": "https://webqit.io/tooling/webflo",
15
- "version": "0.11.35",
15
+ "version": "0.11.37",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@octokit/webhooks": "^7.15.1",
39
- "@webqit/backpack": "^0.1.2",
39
+ "@webqit/backpack": "^0.1.6",
40
40
  "@webqit/oohtml-ssr": "^1.1.0",
41
41
  "@webqit/util": "^0.8.9",
42
42
  "client-sessions": "^0.8.0",
@@ -2,7 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
5
  import { Dotfile } from '@webqit/backpack';
7
6
 
8
7
  export default class Env extends Dotfile {
@@ -24,13 +23,13 @@ export default class Env extends Dotfile {
24
23
 
25
24
  // Defaults merger
26
25
  withDefaults(config) {
27
- return _merge({
26
+ return this.merge({
28
27
  autoload: true,
29
- }, config);
28
+ }, config, 'patch');
30
29
  }
31
30
 
32
31
  // Questions generator
33
- questions(config, choices = {}) {
32
+ getSchema(config, choices = {}) {
34
33
  // Questions
35
34
  return [
36
35
  {
@@ -41,7 +40,7 @@ export default class Env extends Dotfile {
41
40
  combomode: true,
42
41
  },
43
42
  initial: config.entries,
44
- questions: [
43
+ schema: [
45
44
  {
46
45
  name: 'name',
47
46
  type: 'text',
@@ -2,7 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
5
  import { Dotfile } from '@webqit/backpack';
7
6
 
8
7
  export default class Layout extends Dotfile {
@@ -19,17 +18,17 @@ export default class Layout extends Dotfile {
19
18
 
20
19
  // Defaults merger
21
20
  withDefaults(config) {
22
- return _merge({
21
+ return this.merge({
23
22
  ROOT: process.cwd(),
24
23
  PUBLIC_DIR: './public',
25
24
  SERVER_DIR: './server',
26
25
  CLIENT_DIR: './client',
27
26
  WORKER_DIR: './worker',
28
- }, config);
27
+ }, config, 'patch');
29
28
  }
30
29
 
31
30
  // Questions generator
32
- questions(config, choices = {}) {
31
+ getSchema(config, choices = {}) {
33
32
  // Questions
34
33
  return [
35
34
  {
@@ -3,9 +3,8 @@
3
3
  * imports
4
4
  */
5
5
  import Url from 'url';
6
- import { _merge } from '@webqit/util/obj/index.js';
7
6
  import { _before } from '@webqit/util/str/index.js';
8
- import { _isObject, _isTypeObject } from '@webqit/util/js/index.js';
7
+ import { _isTypeObject } from '@webqit/util/js/index.js';
9
8
  import { Dotfile } from '@webqit/backpack';
10
9
 
11
10
  export default class Origins extends Dotfile {
@@ -29,7 +28,7 @@ export default class Origins extends Dotfile {
29
28
  origin = _before(inferredRepo.pathname, '.');
30
29
  }
31
30
  // Params
32
- return _merge({
31
+ return this.merge({
33
32
  entries: [{
34
33
  host: hostname,
35
34
  repo: origin,
@@ -41,7 +40,7 @@ export default class Origins extends Dotfile {
41
40
  ondeploy: 'npm install',
42
41
  ondeploy_autoexit: true,
43
42
  }],
44
- }, config);
43
+ }, config, 'patch');
45
44
  }
46
45
 
47
46
  // Match
@@ -50,14 +49,14 @@ export default class Origins extends Dotfile {
50
49
  }
51
50
 
52
51
  // Questions generator
53
- questions(config, choices = {}) {
52
+ getSchema(config, choices = {}) {
54
53
  // Choices
55
- const CHOICES = _merge({
54
+ const CHOICES = this.merge({
56
55
  host: [
57
56
  {value: 'github',},
58
57
  {value: 'bitbucket',},
59
58
  ],
60
- }, choices);
59
+ }, choices, 'patch');
61
60
  // Questions
62
61
  return [
63
62
  {
@@ -67,7 +66,7 @@ export default class Origins extends Dotfile {
67
66
  name: 'repository',
68
67
  },
69
68
  initial: config.entries,
70
- questions: [
69
+ schema: [
71
70
  {
72
71
  name: 'host',
73
72
  type: 'select',
@@ -2,8 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
- import { _isObject } from '@webqit/util/js/index.js';
7
5
  import { Dotfile } from '@webqit/backpack';
8
6
 
9
7
  export default class Virtualization extends Dotfile {
@@ -20,21 +18,21 @@ export default class Virtualization extends Dotfile {
20
18
 
21
19
  // Defaults merger
22
20
  withDefaults(config) {
23
- return _merge(true, {
21
+ return this.merge({
24
22
  entries: [],
25
- }, config);
26
- }
27
-
28
- // Match
29
- async match(hostname) {
30
- if (_isObject(hostname)) {
31
- hostname = hostname.hostname;
32
- }
33
- return ((await this.read()).entries || []).filter(vh => vh.host === hostname);
23
+ }, config, 'patch');
34
24
  }
35
25
 
36
26
  // Questions generator
37
- questions(config, choices = {}) {
27
+ getSchema(config, choices = {}) {
28
+ // Choices
29
+ const CHOICES = this.merge({
30
+ proto: [
31
+ {value: '', title: '(Auto)'},
32
+ {value: 'http', title: 'HTTP'},
33
+ {value: 'https', title: 'HTTPS'},
34
+ ],
35
+ }, choices, 'patch');
38
36
  // Questions
39
37
  return [
40
38
  {
@@ -44,23 +42,28 @@ export default class Virtualization extends Dotfile {
44
42
  name: 'vhost',
45
43
  },
46
44
  initial: config.entries,
47
- questions: [
45
+ schema: [
48
46
  {
49
47
  name: 'path',
50
48
  type: 'text',
51
- message: 'Enter local pathname to target server if exists. (Leave empty to explicitly specify hostnames and port number.)',
52
- validation: ['important'],
49
+ message: '[path]: Enter local pathname to target server if exists.' + "\r\n" + '(Leave empty to explicitly specify hostnames and port number.)' + "\r\n",
53
50
  },
54
51
  {
55
52
  name: 'hostnames',
56
- type: 'text',
57
- message: 'Enter host names. (Leave empty to automatically derive hostnames from the config of the target server specified above.)',
58
- validation: ['important'],
53
+ type: 'list',
54
+ message: '[hostnames]: Enter host names.' + "\r\n" + '(Leave empty to automatically derive hostnames from the config of the target server specified above.)' + "\r\n",
59
55
  },
60
56
  {
61
57
  name: 'port',
62
- type: 'text',
63
- message: 'Enter target port. (Leave empty to automatically derive port number from the config of the target server specified above.)',
58
+ type: 'number',
59
+ message: '[port]: Enter the target port number.' + "\r\n" + '(Leave empty to automatically derive target port number from the config of the target server specified above.)' + "\r\n",
60
+ },
61
+ {
62
+ name: 'proto',
63
+ type: 'select',
64
+ message: '[protocol]: Enter the target protocol: https/http.' + "\r\n" + '(Leave empty to automatically derive target protocol from the config of the target server specified above.)' + "\r\n",
65
+ choices: CHOICES.proto,
66
+ initial: this.indexOfInitial(CHOICES.proto, config.proto),
64
67
  validation: ['important'],
65
68
  },
66
69
  ],
@@ -2,9 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
- import { _isNumeric } from '@webqit/util/js/index.js';
7
- import { _before, _after } from '@webqit/util/str/index.js';
8
5
  import { Dotfile } from '@webqit/backpack';
9
6
 
10
7
  export default class Client extends Dotfile {
@@ -21,7 +18,7 @@ export default class Client extends Dotfile {
21
18
 
22
19
  // Defaults merger
23
20
  withDefaults(config) {
24
- return _merge(true, {
21
+ return this.merge({
25
22
  bundle_filename: 'bundle.js',
26
23
  public_base_url: '/',
27
24
  spa_routing: true,
@@ -29,13 +26,13 @@ export default class Client extends Dotfile {
29
26
  service_worker_support: true,
30
27
  worker_scope: '/',
31
28
  worker_filename: 'worker.js',
32
- }, config);
29
+ }, config, 'patch');
33
30
  }
34
31
 
35
32
  // Questions generator
36
- questions(config, choices = {}) {
33
+ getSchema(config, choices = {}) {
37
34
  // Choices
38
- const CHOICES = _merge({
35
+ const CHOICES = this.merge({
39
36
  oohtml_support: [
40
37
  {value: 'full', title: 'Full'},
41
38
  {value: 'namespacing', title: 'namespacing'},
@@ -43,7 +40,7 @@ export default class Client extends Dotfile {
43
40
  {value: 'templating', title: 'templating'},
44
41
  {value: 'none', title: 'none'},
45
42
  ],
46
- }, choices);
43
+ }, choices, 'patch');
47
44
  // Questions
48
45
  return [
49
46
  {
@@ -2,7 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
5
  import { Dotfile } from '@webqit/backpack';
7
6
 
8
7
  export default class Server extends Dotfile {
@@ -19,7 +18,7 @@ export default class Server extends Dotfile {
19
18
 
20
19
  // Defaults merger
21
20
  withDefaults(config) {
22
- return _merge(true, {
21
+ return this.merge({
23
22
  port: process.env.port || 3000,
24
23
  domains: [],
25
24
  force_www: '',
@@ -31,13 +30,13 @@ export default class Server extends Dotfile {
31
30
  force: false,
32
31
  },
33
32
  oohtml_support: 'full',
34
- }, config);
33
+ }, config, 'patch');
35
34
  }
36
35
 
37
36
  // Questions generator
38
- questions(config, choices = {}) {
37
+ getSchema(config, choices = {}) {
39
38
  // Choices
40
- const CHOICES = _merge({
39
+ const CHOICES = this.merge({
41
40
  force_www: [
42
41
  {value: '', title: 'do nothing'},
43
42
  {value: 'add',},
@@ -50,7 +49,7 @@ export default class Server extends Dotfile {
50
49
  {value: 'templating', title: 'templating'},
51
50
  {value: 'none', title: 'none'},
52
51
  ],
53
- }, choices);
52
+ }, choices, 'patch');
54
53
  // Questions
55
54
  return [
56
55
  {
@@ -79,7 +78,7 @@ export default class Server extends Dotfile {
79
78
  name: 'https',
80
79
  },
81
80
  initial: config.https,
82
- questions: [
81
+ schema: [
83
82
  {
84
83
  name: 'port',
85
84
  type: 'number',
@@ -2,7 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
5
  import { _isNumeric } from '@webqit/util/js/index.js';
7
6
  import { _before, _after } from '@webqit/util/str/index.js';
8
7
  import { Dotfile } from '@webqit/backpack';
@@ -21,7 +20,7 @@ export default class Worker extends Dotfile {
21
20
 
22
21
  // Defaults merger
23
22
  withDefaults(config) {
24
- return _merge(true, {
23
+ return this.merge({
25
24
  cache_name: 'cache_v0',
26
25
  default_fetching_strategy: 'network-first',
27
26
  network_first_urls: [],
@@ -34,24 +33,24 @@ export default class Worker extends Dotfile {
34
33
  push_registration_url: '',
35
34
  push_deregistration_url: '',
36
35
  push_public_key: '',
37
- }, config);
36
+ }, config, 'patch');
38
37
  }
39
38
 
40
39
  // Questions generator
41
- questions(config, choices = {}) {
40
+ getSchema(config, choices = {}) {
42
41
  // Increment cache
43
42
  if (config.cache_name && config.cache_name.indexOf('_v') > -1 && _isNumeric(_after(config.cache_name, '_v'))) {
44
43
  config.cache_name = _before(config.cache_name, '_v') + '_v' + (parseInt(_after(config.cache_name, '_v')) + 1);
45
44
  }
46
45
  // Choices
47
- const CHOICES = _merge({
46
+ const CHOICES = this.merge({
48
47
  default_fetching_strategy: [
49
48
  {value: 'network-first', title: 'Network-first (Webflo default)'},
50
49
  {value: 'cache-first', title: 'Cache-first'},
51
50
  {value: 'network-only', title: 'Network-only'},
52
51
  {value: 'cache-only', title: 'Cache-only'},
53
52
  ],
54
- }, choices);
53
+ }, choices, 'patch');
55
54
  // Questions
56
55
  return [
57
56
  {
@@ -2,9 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import Url from 'url';
6
- import { _merge } from '@webqit/util/obj/index.js';
7
- import { _isObject } from '@webqit/util/js/index.js';
8
5
  import { Dotfile } from '@webqit/backpack';
9
6
 
10
7
  export default class Headers extends Dotfile {
@@ -21,19 +18,19 @@ export default class Headers extends Dotfile {
21
18
 
22
19
  // Defaults merger
23
20
  withDefaults(config) {
24
- return _merge(true, {
21
+ return this.merge({
25
22
  entries: [],
26
- }, config);
23
+ }, config, 'patch');
27
24
  }
28
25
 
29
26
  // Questions generator
30
- questions(config, choices = {}) {
31
- const CHOICES = _merge({
27
+ getSchema(config, choices = {}) {
28
+ const CHOICES = this.merge({
32
29
  type: [
33
30
  {value: 'request', title: 'Request Header'},
34
31
  {value: 'response', title: 'Response Header'},
35
32
  ]
36
- }, choices);
33
+ }, choices, 'patch');
37
34
  // Questions
38
35
  return [
39
36
  {
@@ -43,7 +40,7 @@ export default class Headers extends Dotfile {
43
40
  name: 'header',
44
41
  },
45
42
  initial: config.entries,
46
- questions: [
43
+ schema: [
47
44
  {
48
45
  name: 'type',
49
46
  type: 'text',
@@ -2,10 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import Url from 'url';
6
- import { _merge } from '@webqit/util/obj/index.js';
7
- import { _after } from '@webqit/util/str/index.js';
8
- import { _isObject, _isNumeric } from '@webqit/util/js/index.js';
9
5
  import { Dotfile } from '@webqit/backpack';
10
6
 
11
7
  export default class Redirects extends Dotfile {
@@ -22,20 +18,20 @@ export default class Redirects extends Dotfile {
22
18
 
23
19
  // Defaults merger
24
20
  withDefaults(config) {
25
- return _merge(true, {
21
+ return this.merge({
26
22
  entries: [],
27
- }, config);
23
+ }, config, 'patch');
28
24
  }
29
25
 
30
26
  // Questions generator
31
- questions(config, choices = {}) {
27
+ getSchema(config, choices = {}) {
32
28
  // Choices
33
- const CHOICES = _merge({
29
+ const CHOICES = this.merge({
34
30
  code: [
35
31
  {value: 302,},
36
32
  {value: 301,},
37
33
  ],
38
- }, choices);
34
+ }, choices, 'patch');
39
35
  // Questions
40
36
  return [
41
37
  {
@@ -45,7 +41,7 @@ export default class Redirects extends Dotfile {
45
41
  name: 'redirect',
46
42
  },
47
43
  initial: config.entries,
48
- questions: [
44
+ schema: [
49
45
  {
50
46
  name: 'from',
51
47
  type: 'text',
@@ -4,9 +4,7 @@
4
4
  */
5
5
  import Path from 'path';
6
6
  import { _all } from '@webqit/util/arr/index.js';
7
- import { _merge } from '@webqit/util/obj/index.js';
8
7
  import { _isNumeric } from '@webqit/util/js/index.js';
9
- import { _before, _after } from '@webqit/util/str/index.js';
10
8
  import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
11
9
  import { Dotfile } from '@webqit/backpack';
12
10
 
@@ -30,7 +28,7 @@ export default class Manifest extends Dotfile {
30
28
  // Defaults merger
31
29
  withDefaults(config) {
32
30
  const pkg = this.cx.PKG || {};
33
- return _merge(true, {
31
+ return this.merge({
34
32
  // -----------------
35
33
  name: pkg.value,
36
34
  short_name: pkg.value,
@@ -50,13 +48,13 @@ export default class Manifest extends Dotfile {
50
48
  dir: 'ltr',
51
49
  related_applications: '',
52
50
  prefer_related_applications: false,
53
- }, config);
51
+ }, config, 'patch');
54
52
  }
55
53
 
56
54
  // Questions generator
57
- questions(config, choices = {}) {
55
+ getSchema(config, choices = {}) {
58
56
  // Choices hash...
59
- const CHOICES = _merge({
57
+ const CHOICES = this.merge({
60
58
  display: [
61
59
  {value: 'browser',},
62
60
  {value: 'fullscreen',},
@@ -75,7 +73,7 @@ export default class Manifest extends Dotfile {
75
73
  {value: 'portrait-primary',},
76
74
  {value: 'portrait-secondary',},
77
75
  ],
78
- }, choices);
76
+ }, choices, 'patch');
79
77
 
80
78
  // Gets index...
81
79
  const getSize = src => Path.basename(src).split(/[_\.\-]/g).reduce((size, chunk) => size || (_all(chunk.split('x'), c => _isNumeric(c)) ? chunk : ''), null);
@@ -136,7 +134,7 @@ export default class Manifest extends Dotfile {
136
134
  controls: {
137
135
  name: 'icon',
138
136
  },
139
- questions: [
137
+ schema: [
140
138
  {
141
139
  name: 'src',
142
140
  type: 'text',
@@ -191,7 +189,7 @@ export default class Manifest extends Dotfile {
191
189
  controls: {
192
190
  name: 'screenshot',
193
191
  },
194
- questions: [
192
+ schema: [
195
193
  {
196
194
  name: 'src',
197
195
  type: 'text',
@@ -221,7 +219,7 @@ export default class Manifest extends Dotfile {
221
219
  controls: {
222
220
  name: 'shortcut',
223
221
  },
224
- questions: [
222
+ schema: [
225
223
  {
226
224
  name: 'name',
227
225
  type: 'text',
@@ -252,7 +250,7 @@ export default class Manifest extends Dotfile {
252
250
  controls: {
253
251
  name: 'shortcut icon',
254
252
  },
255
- questions: [
253
+ schema: [
256
254
  {
257
255
  name: 'src',
258
256
  type: 'text',
@@ -2,8 +2,6 @@
2
2
  /**
3
3
  * imports
4
4
  */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
- import { _isObject } from '@webqit/util/js/index.js';
7
5
  import { Dotfile } from '@webqit/backpack';
8
6
 
9
7
  export default class Ssg extends Dotfile {
@@ -20,13 +18,13 @@ export default class Ssg extends Dotfile {
20
18
 
21
19
  // Defaults merger
22
20
  withDefaults(config) {
23
- return _merge(true, {
21
+ return this.merge({
24
22
  entries: [],
25
- }, config);
23
+ }, config, 'patch');
26
24
  }
27
25
 
28
26
  // Questions generator
29
- questions(config, choices = {}) {
27
+ getSchema(config, choices = {}) {
30
28
  // Questions
31
29
  return [
32
30
  {
@@ -36,7 +34,7 @@ export default class Ssg extends Dotfile {
36
34
  name: 'page',
37
35
  },
38
36
  initial: config.entries,
39
- questions: [
37
+ schema: [
40
38
  {
41
39
  name: 'url',
42
40
  type: 'text',
@@ -84,19 +84,21 @@ export default class Runtime extends _Runtime {
84
84
  if (this.cx.config.deployment.Virtualization) {
85
85
  const vhosts = await (new this.cx.config.deployment.Virtualization(this.cx)).read();
86
86
  await Promise.all((vhosts.entries || []).map(async vhost => {
87
- let cx, hostnames = parseDomains(vhost.hostnames), port = parseInt(vhost.port);
87
+ let cx, hostnames = parseDomains(vhost.hostnames), port = vhost.port, proto = vhost.proto;
88
88
  if (vhost.path) {
89
89
  cx = this.cx.constructor.create(this.cx, Path.join(this.cx.CWD, vhost.path));
90
90
  await resolveContextObj(cx, true);
91
91
  // From the server that's most likely to be active
92
- port || (port = parseInt(cx.server.port || cx.server.https.port));
92
+ port || (port = cx.server.https.port || cx.server.port);
93
93
  // The domain list that corresponds to the specified resolved port
94
- hostnames.length || (hostnames = selectDomains([cx.server, cx.server.https], port));
94
+ hostnames.length || (hostnames = selectDomains([cx.server.https, cx.server], port));
95
95
  // Or anyone available... hoping that the remote configs can eventually be in sync
96
- hostnames.length || (hostnames = selectDomains([cx.server, cx.server.https]));
96
+ hostnames.length || (hostnames = selectDomains([cx.server.https, cx.server]));
97
+ // The corresponding proto
98
+ proto || (proto = port === cx.server.https.port ? 'https' : 'http');
97
99
  }
98
- hostnames.length || (hostnames = ['*']);
99
- this.vhosts.set(hostnames.sort().join('|'), { cx, hostnames, port });
100
+ hostnames.length || (hostnames = ['*']);
101
+ this.vhosts.set(hostnames.sort().join('|'), { cx, hostnames, port, proto });
100
102
  }));
101
103
  }
102
104
  // ---------------
@@ -287,7 +289,7 @@ export default class Runtime extends _Runtime {
287
289
  // ------------
288
290
  for (const [ /*id*/, vhost ] of this.vhosts) {
289
291
  if (vhost.hostnames.includes(url.hostname) || (vhost.hostnames.includes('*') && !hosts.includes('*'))) {
290
- return this.proxyFetch(vhost, url, init);
292
+ return this.proxyGo(vhost, url, init);
291
293
  }
292
294
  }
293
295
  // ------------
@@ -344,12 +346,16 @@ export default class Runtime extends _Runtime {
344
346
  }
345
347
 
346
348
  // Fetch from proxied host
347
- async proxyFetch(vhost, url, init) {
349
+ async proxyGo(vhost, url, init) {
350
+ // ---------
348
351
  const url2 = new whatwag.URL(url);
349
352
  url2.port = vhost.port;
353
+ if (vhost.proto) { url2.protocol = vhost.proto; }
354
+ // ---------
350
355
  const init2 = { ...init, compress: false };
351
356
  if (!init2.headers) init2.headers = {};
352
357
  init2.headers.host = url2.host;
358
+ // ---------
353
359
  let response;
354
360
  try {
355
361
  response = await this.remoteFetch(url2, init2);