@webqit/webflo 0.11.34 → 0.11.36

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.34",
15
+ "version": "0.11.36",
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.3",
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,17 +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
- name: 'host',
47
+ name: 'path',
50
48
  type: 'text',
51
- message: 'Enter Host name',
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
- name: 'path',
56
- type: 'text',
57
- message: 'Enter local path',
52
+ name: 'hostnames',
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",
55
+ },
56
+ {
57
+ name: 'port',
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),
58
67
  validation: ['important'],
59
68
  },
60
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,25 +18,25 @@ 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,
23
+ domains: [],
24
+ force_www: '',
24
25
  https: {
25
26
  port: 0,
26
27
  keyfile: '',
27
28
  certfile: '',
28
- certdoms: ['*'],
29
+ domains: [],
29
30
  force: false,
30
31
  },
31
- force_www: '',
32
32
  oohtml_support: 'full',
33
- shared: false,
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
  {
@@ -60,13 +59,26 @@ export default class Server extends Dotfile {
60
59
  initial: config.port,
61
60
  validation: ['important'],
62
61
  },
62
+ {
63
+ name: 'domains',
64
+ type: 'list',
65
+ message: '[domains]: Enter a list of allowed domains if necessary (comma-separated)',
66
+ validation: ['important'],
67
+ },
68
+ {
69
+ name: 'force_www',
70
+ type: 'select',
71
+ message: '[force_www]: Force add/remove "www" on hostname?',
72
+ choices: CHOICES.force_www,
73
+ initial: this.indexOfInitial(CHOICES.force_www, config.force_www),
74
+ },
63
75
  {
64
76
  name: 'https',
65
77
  controls: {
66
78
  name: 'https',
67
79
  },
68
80
  initial: config.https,
69
- questions: [
81
+ schema: [
70
82
  {
71
83
  name: 'port',
72
84
  type: 'number',
@@ -86,9 +98,9 @@ export default class Server extends Dotfile {
86
98
  validation: ['important'],
87
99
  },
88
100
  {
89
- name: 'certdoms',
101
+ name: 'domains',
90
102
  type: 'list',
91
- message: '[certdoms]: Enter the CERT domains (comma-separated)',
103
+ message: '[domains]: Enter the CERT domains (comma-separated)',
92
104
  validation: ['important'],
93
105
  },
94
106
  {
@@ -100,13 +112,6 @@ export default class Server extends Dotfile {
100
112
  },
101
113
  ],
102
114
  },
103
- {
104
- name: 'force_www',
105
- type: 'select',
106
- message: '[force_www]: Force add/remove "www" on hostname?',
107
- choices: CHOICES.force_www,
108
- initial: this.indexOfInitial(CHOICES.force_www, config.force_www),
109
- },
110
115
  {
111
116
  name: 'oohtml_support',
112
117
  type: 'select',
@@ -115,14 +120,6 @@ export default class Server extends Dotfile {
115
120
  initial: this.indexOfInitial(CHOICES.oohtml_support, config.oohtml_support),
116
121
  validation: ['important'],
117
122
  },
118
- {
119
- name: 'shared',
120
- type: 'toggle',
121
- message: '[shared]: Shared server?',
122
- active: 'YES',
123
- inactive: 'NO',
124
- initial: config.shared,
125
- },
126
123
  ];
127
124
  }
128
125
  }
@@ -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',
@@ -22,13 +22,13 @@ export default class Router {
22
22
  *
23
23
  * @return void
24
24
  */
25
- constructor(cx, path) {
25
+ constructor(cx, path = []) {
26
26
  this.cx = cx;
27
27
  this.path = _isArray(path) ? path : (path + '').split('/').filter(a => a);
28
28
  }
29
29
 
30
30
  /**
31
- * Performs dynamic routing.
31
+ * Performs dynamic routing
32
32
  *
33
33
  * @param array|string method
34
34
  * @param Object event
@@ -59,7 +59,7 @@ export default class Router {
59
59
  // Broadcast any hints exported by handler
60
60
  if (thisTick.exports.hints) { await event.port.post({ ...thisTick.exports.hints, $type: 'handler:hints' }); }
61
61
  const methods = _arrFrom(thisTick.method);
62
- const handler = _isFunction(thisTick.exports) && methods.includes('default') ? thisTick.exports : methods.reduce((_handler, name) => _handler || thisTick.exports[name.toLowerCase()], null);
62
+ const handler = _isFunction(thisTick.exports) && methods.includes('default') ? thisTick.exports : methods.reduce((_handler, name) => _handler || thisTick.exports[name], null);
63
63
  if (handler) {
64
64
  // -------------
65
65
  // Dynamic response
@@ -0,0 +1,21 @@
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+
6
+ import { _isFunction } from "@webqit/util/js/index.js";
7
+
8
+ /**
9
+ * ---------------------------
10
+ * The base Runtime class
11
+ * ---------------------------
12
+ */
13
+
14
+ export default class Runtime {
15
+ constructor(cx, client) {
16
+ this.cx = cx;
17
+ this.cx.runtime = this;
18
+ this.client = _isFunction(client) ? client(this.cx) : client;
19
+ if (!this.client || !this.client.handle) throw new Error(`Application instance must define a ".handle()" method.`);
20
+ }
21
+ }