@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.
- 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} +143 -102
- package/src/runtime-pi/client/RuntimeClient.js +114 -0
- package/src/{runtime → runtime-pi}/client/Storage.js +8 -7
- 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 +102 -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 -61
- package/src/runtime/_RequestHeaders.js +0 -72
- package/src/runtime/_Response.js +0 -56
- package/src/runtime/client/Cache.js +0 -38
- package/src/runtime/client/Http.js +0 -225
- package/src/runtime/client/NavigationEvent.js +0 -21
- package/src/runtime/client/Runtime.js +0 -126
- package/src/runtime/client/StdRequest.js +0 -74
- package/src/runtime/client/Worker.js +0 -312
- package/src/runtime/client/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/manifest.js
DELETED
|
@@ -1,341 +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 _all from '@webqit/util/arr/all.js';
|
|
9
|
-
import _isNumeric from '@webqit/util/js/isNumeric.js';
|
|
10
|
-
import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
|
|
11
|
-
import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Reads MANIFEST 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}/manifest${ext}.json`;
|
|
25
|
-
const availableExt = anyExists([ext, '', '.example'], fileName);
|
|
26
|
-
const config = DotJson.read(fileName(availableExt));
|
|
27
|
-
// Package
|
|
28
|
-
const pkg = layout.PKG || {};
|
|
29
|
-
return _merge({
|
|
30
|
-
// -----------------
|
|
31
|
-
name: pkg.value,
|
|
32
|
-
short_name: pkg.value,
|
|
33
|
-
description: pkg.description,
|
|
34
|
-
categories: pkg.keywords,
|
|
35
|
-
theme_color: 'transparent',
|
|
36
|
-
background_color: 'transparent',
|
|
37
|
-
icons: [],
|
|
38
|
-
display: 'browser',
|
|
39
|
-
orientation: 'any',
|
|
40
|
-
// advanced
|
|
41
|
-
screenshots: [],
|
|
42
|
-
shortcuts: [],
|
|
43
|
-
scope: '/',
|
|
44
|
-
start_url: '/',
|
|
45
|
-
lang: 'en-us',
|
|
46
|
-
dir: 'ltr',
|
|
47
|
-
related_applications: '',
|
|
48
|
-
prefer_related_applications: false,
|
|
49
|
-
}, config);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Writes MANIFEST 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 || ``, layout.PUBLIC_DIR || '');
|
|
64
|
-
const fileName = ext => `${configDir}/manifest${ext}.json`;
|
|
65
|
-
DotJson.write(config, fileName(ext));
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Configures MANIFEST.
|
|
70
|
-
*
|
|
71
|
-
* @param object config
|
|
72
|
-
* @param object choices
|
|
73
|
-
* @param object layout
|
|
74
|
-
*
|
|
75
|
-
* @return Array
|
|
76
|
-
*/
|
|
77
|
-
export async function questions(config, choices = {}, layout = {}) {
|
|
78
|
-
|
|
79
|
-
// Choices hash...
|
|
80
|
-
const CHOICES = _merge({
|
|
81
|
-
display: [
|
|
82
|
-
{value: 'browser',},
|
|
83
|
-
{value: 'fullscreen',},
|
|
84
|
-
{value: 'standalone',},
|
|
85
|
-
{value: 'minimal-ui',},
|
|
86
|
-
],
|
|
87
|
-
orientation: [
|
|
88
|
-
{value: 'any',},
|
|
89
|
-
{value: 'natural',},
|
|
90
|
-
{value: '::::::::::::::::', disabled: true,},
|
|
91
|
-
{value: 'landscape',},
|
|
92
|
-
{value: 'landscape-primary',},
|
|
93
|
-
{value: 'landscape-secondary',},
|
|
94
|
-
{value: '::::::::::::::::', disabled: true,},
|
|
95
|
-
{value: 'portrait',},
|
|
96
|
-
{value: 'portrait-primary',},
|
|
97
|
-
{value: 'portrait-secondary',},
|
|
98
|
-
],
|
|
99
|
-
}, choices);
|
|
100
|
-
|
|
101
|
-
// Gets index...
|
|
102
|
-
const getSize = src => Path.basename(src).split(/[_\.\-]/g).reduce((size, chunk) => size || (_all(chunk.split('x'), c => _isNumeric(c)) ? chunk : ''), null);
|
|
103
|
-
const getMime = src => extensions[Path.extname(src)];
|
|
104
|
-
// extensions
|
|
105
|
-
const extensions = {
|
|
106
|
-
'.png': 'image/png',
|
|
107
|
-
'.jpg': 'image/jpg',
|
|
108
|
-
'.jpeg': 'image/jpeg',
|
|
109
|
-
'.ico': 'image/ico',
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// Questions
|
|
113
|
-
return [
|
|
114
|
-
{
|
|
115
|
-
name: 'name',
|
|
116
|
-
type: 'text',
|
|
117
|
-
message: 'Enter the application name',
|
|
118
|
-
initial: config.name,
|
|
119
|
-
validation: ['important'],
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: 'short_name',
|
|
123
|
-
type: 'text',
|
|
124
|
-
message: 'Enter the application short name',
|
|
125
|
-
initial: prev => config.short_name || prev,
|
|
126
|
-
validation: ['important'],
|
|
127
|
-
},
|
|
128
|
-
{
|
|
129
|
-
name: 'description',
|
|
130
|
-
type: 'text',
|
|
131
|
-
message: 'Enter the application description',
|
|
132
|
-
initial: config.description,
|
|
133
|
-
validation: ['important'],
|
|
134
|
-
},
|
|
135
|
-
{
|
|
136
|
-
name: 'categories',
|
|
137
|
-
type: 'list',
|
|
138
|
-
message: 'Specify applications categories (comma-separated)',
|
|
139
|
-
initial: (config.categories || []).join(', '),
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
name: 'theme_color',
|
|
143
|
-
type: 'text',
|
|
144
|
-
message: 'Enter the application theme color',
|
|
145
|
-
initial: config.theme_color,
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
name: 'background_color',
|
|
149
|
-
type: 'text',
|
|
150
|
-
message: 'Enter the application background color',
|
|
151
|
-
initial: config.background_color,
|
|
152
|
-
},
|
|
153
|
-
{
|
|
154
|
-
name: 'icons',
|
|
155
|
-
type: 'recursive',
|
|
156
|
-
initial: config.icons,
|
|
157
|
-
controls: {
|
|
158
|
-
name: 'icon',
|
|
159
|
-
},
|
|
160
|
-
questions: [
|
|
161
|
-
{
|
|
162
|
-
name: 'src',
|
|
163
|
-
type: 'text',
|
|
164
|
-
message: 'Enter icon URL',
|
|
165
|
-
validation: ['important'],
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'type',
|
|
169
|
-
type: 'text',
|
|
170
|
-
message: 'Enter icon MIME type',
|
|
171
|
-
initial: prev => getMime(prev),
|
|
172
|
-
validation: ['important'],
|
|
173
|
-
},
|
|
174
|
-
{
|
|
175
|
-
name: 'sizes',
|
|
176
|
-
type: 'text',
|
|
177
|
-
message: 'Enter icon sizes',
|
|
178
|
-
initial: (prev, answers) => getSize(answers.src),
|
|
179
|
-
validation: ['important'],
|
|
180
|
-
},
|
|
181
|
-
],
|
|
182
|
-
},
|
|
183
|
-
{
|
|
184
|
-
name: 'display',
|
|
185
|
-
type: 'select',
|
|
186
|
-
message: 'Enter the application display mode',
|
|
187
|
-
choices: CHOICES.display,
|
|
188
|
-
initial: initialGetIndex(CHOICES.display, config.display),
|
|
189
|
-
},
|
|
190
|
-
{
|
|
191
|
-
name: 'orientation',
|
|
192
|
-
type: 'select',
|
|
193
|
-
message: 'Enter the application orientation mode',
|
|
194
|
-
choices: CHOICES.orientation,
|
|
195
|
-
initial: initialGetIndex(CHOICES.orientation, config.orientation),
|
|
196
|
-
},
|
|
197
|
-
// ------------- advanced --------------
|
|
198
|
-
{
|
|
199
|
-
name: '__advanced',
|
|
200
|
-
type: 'toggle',
|
|
201
|
-
message: 'Show advanced options?',
|
|
202
|
-
active: 'YES',
|
|
203
|
-
inactive: 'NO',
|
|
204
|
-
initial: config.__advanced,
|
|
205
|
-
exclude: true,
|
|
206
|
-
},
|
|
207
|
-
// ------------- advanced --------------
|
|
208
|
-
{
|
|
209
|
-
name: 'screenshots',
|
|
210
|
-
type: (prev, answers) => answers.__advanced ? 'recursive' : null,
|
|
211
|
-
initial: config.screenshots,
|
|
212
|
-
controls: {
|
|
213
|
-
name: 'screenshot',
|
|
214
|
-
},
|
|
215
|
-
questions: [
|
|
216
|
-
{
|
|
217
|
-
name: 'src',
|
|
218
|
-
type: 'text',
|
|
219
|
-
message: 'Enter screenshot URL',
|
|
220
|
-
validation: ['important'],
|
|
221
|
-
},
|
|
222
|
-
{
|
|
223
|
-
name: 'type',
|
|
224
|
-
type: 'text',
|
|
225
|
-
message: 'Enter screenshot MIME type',
|
|
226
|
-
initial: prev => getMime(prev),
|
|
227
|
-
validation: ['important'],
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: 'sizes',
|
|
231
|
-
type: 'text',
|
|
232
|
-
message: 'Enter screenshot sizes',
|
|
233
|
-
initial: (prev, answers) => getSize(answers.src),
|
|
234
|
-
validation: ['important'],
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
{
|
|
239
|
-
name: 'shortcuts',
|
|
240
|
-
type: (prev, answers) => answers.__advanced ? 'recursive' : null,
|
|
241
|
-
initial: config.shortcuts,
|
|
242
|
-
controls: {
|
|
243
|
-
name: 'shortcut',
|
|
244
|
-
},
|
|
245
|
-
questions: [
|
|
246
|
-
{
|
|
247
|
-
name: 'name',
|
|
248
|
-
type: 'text',
|
|
249
|
-
message: 'Enter shortcut name',
|
|
250
|
-
validation: ['important'],
|
|
251
|
-
},
|
|
252
|
-
{
|
|
253
|
-
name: 'short_name',
|
|
254
|
-
type: 'text',
|
|
255
|
-
message: 'Enter shortcut short name',
|
|
256
|
-
validation: ['important'],
|
|
257
|
-
},
|
|
258
|
-
{
|
|
259
|
-
name: 'description',
|
|
260
|
-
type: 'text',
|
|
261
|
-
message: 'Enter shortcut description',
|
|
262
|
-
validation: ['important'],
|
|
263
|
-
},
|
|
264
|
-
{
|
|
265
|
-
name: 'url',
|
|
266
|
-
type: 'text',
|
|
267
|
-
message: 'Enter shortcut URL',
|
|
268
|
-
validation: ['important'],
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
name: 'icons',
|
|
272
|
-
type: 'recursive',
|
|
273
|
-
controls: {
|
|
274
|
-
name: 'shortcut icon',
|
|
275
|
-
},
|
|
276
|
-
questions: [
|
|
277
|
-
{
|
|
278
|
-
name: 'src',
|
|
279
|
-
type: 'text',
|
|
280
|
-
message: 'Enter icon URL',
|
|
281
|
-
validation: ['important'],
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
name: 'type',
|
|
285
|
-
type: 'text',
|
|
286
|
-
message: 'Enter icon MIME type',
|
|
287
|
-
initial: prev => getMime(prev),
|
|
288
|
-
validation: ['important'],
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
name: 'sizes',
|
|
292
|
-
type: 'text',
|
|
293
|
-
message: 'Enter icon sizes',
|
|
294
|
-
initial: (prev, answers) => getSize(answers.src),
|
|
295
|
-
validation: ['important'],
|
|
296
|
-
},
|
|
297
|
-
],
|
|
298
|
-
},
|
|
299
|
-
],
|
|
300
|
-
},
|
|
301
|
-
{
|
|
302
|
-
name: 'scope',
|
|
303
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
304
|
-
message: 'Specify the manifest scope',
|
|
305
|
-
initial: config.scope,
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
name: 'start_url',
|
|
309
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
310
|
-
message: 'Specify the application start URL',
|
|
311
|
-
initial: config.start_url,
|
|
312
|
-
},
|
|
313
|
-
{
|
|
314
|
-
name: 'lang',
|
|
315
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
316
|
-
message: 'Specify the application language',
|
|
317
|
-
initial: config.lang,
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
name: 'dir',
|
|
321
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
322
|
-
message: 'Specify the application writing mode',
|
|
323
|
-
initial: config.dir,
|
|
324
|
-
},
|
|
325
|
-
{
|
|
326
|
-
name: 'related_applications',
|
|
327
|
-
type: (prev, answers) => answers.__advanced ? 'list' : null,
|
|
328
|
-
message: 'Specify related applications (comma-separated)',
|
|
329
|
-
initial: (config.related_applications || []).join(', '),
|
|
330
|
-
},
|
|
331
|
-
{
|
|
332
|
-
name: 'prefer_related_applications',
|
|
333
|
-
type: (prev, answers) => answers.related_applications ? 'toggle' : null,
|
|
334
|
-
message: 'Specify whether to "prefer" related applications',
|
|
335
|
-
active: 'YES',
|
|
336
|
-
inactive: 'NO',
|
|
337
|
-
initial: config.prefer_related_applications,
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
-
];
|
|
341
|
-
};
|
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
|
-
};
|