@webqit/webflo 0.11.21 → 0.11.24

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 (86) hide show
  1. package/.gitignore +7 -7
  2. package/LICENSE +20 -20
  3. package/README.md +2074 -2071
  4. package/package.json +82 -82
  5. package/src/Context.js +79 -79
  6. package/src/config-pi/deployment/Env.js +69 -69
  7. package/src/config-pi/deployment/Layout.js +65 -65
  8. package/src/config-pi/deployment/Origins.js +133 -133
  9. package/src/config-pi/deployment/Virtualization.js +65 -65
  10. package/src/config-pi/deployment/index.js +17 -17
  11. package/src/config-pi/index.js +15 -15
  12. package/src/config-pi/runtime/Client.js +101 -101
  13. package/src/config-pi/runtime/Server.js +128 -128
  14. package/src/config-pi/runtime/client/Worker.js +135 -135
  15. package/src/config-pi/runtime/client/index.js +11 -11
  16. package/src/config-pi/runtime/index.js +17 -17
  17. package/src/config-pi/runtime/server/Headers.js +77 -77
  18. package/src/config-pi/runtime/server/Redirects.js +73 -73
  19. package/src/config-pi/runtime/server/index.js +13 -13
  20. package/src/config-pi/static/Manifest.js +321 -321
  21. package/src/config-pi/static/Ssg.js +51 -51
  22. package/src/config-pi/static/index.js +13 -13
  23. package/src/deployment-pi/index.js +10 -10
  24. package/src/deployment-pi/origins/index.js +215 -215
  25. package/src/index.js +19 -19
  26. package/src/runtime-pi/Router.js +131 -131
  27. package/src/runtime-pi/client/Context.js +6 -6
  28. package/src/runtime-pi/client/Router.js +47 -47
  29. package/src/runtime-pi/client/Runtime.js +357 -341
  30. package/src/runtime-pi/client/RuntimeClient.js +98 -98
  31. package/src/runtime-pi/client/Storage.js +56 -56
  32. package/src/runtime-pi/client/Url.js +205 -205
  33. package/src/runtime-pi/client/Workport.js +163 -163
  34. package/src/runtime-pi/client/generate.js +467 -467
  35. package/src/runtime-pi/client/index.js +23 -23
  36. package/src/runtime-pi/client/oohtml/full.js +6 -6
  37. package/src/runtime-pi/client/oohtml/namespacing.js +6 -6
  38. package/src/runtime-pi/client/oohtml/scripting.js +7 -7
  39. package/src/runtime-pi/client/oohtml/templating.js +7 -7
  40. package/src/runtime-pi/client/whatwag.js +27 -27
  41. package/src/runtime-pi/client/worker/Context.js +6 -6
  42. package/src/runtime-pi/client/worker/Worker.js +291 -291
  43. package/src/runtime-pi/client/worker/WorkerClient.js +46 -46
  44. package/src/runtime-pi/client/worker/Workport.js +79 -79
  45. package/src/runtime-pi/client/worker/index.js +23 -23
  46. package/src/runtime-pi/index.js +13 -13
  47. package/src/runtime-pi/server/Context.js +15 -15
  48. package/src/runtime-pi/server/Router.js +157 -157
  49. package/src/runtime-pi/server/Runtime.js +547 -547
  50. package/src/runtime-pi/server/RuntimeClient.js +112 -112
  51. package/src/runtime-pi/server/index.js +23 -23
  52. package/src/runtime-pi/server/whatwag.js +35 -35
  53. package/src/runtime-pi/util.js +162 -162
  54. package/src/runtime-pi/xFormData.js +59 -59
  55. package/src/runtime-pi/xHeaders.js +87 -87
  56. package/src/runtime-pi/xHttpEvent.js +92 -92
  57. package/src/runtime-pi/xHttpMessage.js +179 -179
  58. package/src/runtime-pi/xRequest.js +73 -73
  59. package/src/runtime-pi/xRequestHeaders.js +94 -94
  60. package/src/runtime-pi/xResponse.js +68 -68
  61. package/src/runtime-pi/xResponseHeaders.js +109 -109
  62. package/src/runtime-pi/xURL.js +110 -110
  63. package/src/runtime-pi/xfetch.js +6 -6
  64. package/src/services-pi/certbot/http-auth-hook.js +22 -22
  65. package/src/services-pi/certbot/http-cleanup-hook.js +22 -22
  66. package/src/services-pi/certbot/index.js +79 -79
  67. package/src/services-pi/index.js +8 -8
  68. package/src/static-pi/index.js +10 -10
  69. package/src/webflo.js +31 -31
  70. package/test/index.test.js +26 -25
  71. package/test/site/package.json +9 -9
  72. package/test/site/public/bundle.html +5 -5
  73. package/test/site/public/bundle.html.json +3 -3
  74. package/test/site/public/bundle.js +2 -2
  75. package/test/site/public/bundle.webflo.js +15 -15
  76. package/test/site/public/index.html +29 -29
  77. package/test/site/public/index1.html +34 -34
  78. package/test/site/public/page-2/bundle.html +4 -4
  79. package/test/site/public/page-2/bundle.js +2 -2
  80. package/test/site/public/page-2/index.html +45 -45
  81. package/test/site/public/page-2/main.html +2 -2
  82. package/test/site/public/page-4/subpage/bundle.js +2 -2
  83. package/test/site/public/page-4/subpage/index.html +30 -30
  84. package/test/site/public/sparoots.json +4 -4
  85. package/test/site/public/worker.js +3 -3
  86. package/test/site/server/index.js +15 -15
@@ -1,51 +1,51 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
- import { _isObject } from '@webqit/util/js/index.js';
7
- import { Dotfile } from '@webqit/backpack';
8
-
9
- export default class Ssg extends Dotfile {
10
-
11
- // Base name
12
- get name() {
13
- return 'ssg';
14
- }
15
-
16
- // @desc
17
- static get ['@desc']() {
18
- return 'Server-Side Generation (SSG) config.';
19
- }
20
-
21
- // Defaults merger
22
- withDefaults(config) {
23
- return _merge(true, {
24
- entries: [],
25
- }, config);
26
- }
27
-
28
- // Questions generator
29
- questions(config, choices = {}) {
30
- // Questions
31
- return [
32
- {
33
- name: 'entries',
34
- type: 'recursive',
35
- controls: {
36
- name: 'page',
37
- },
38
- initial: config.entries,
39
- questions: [
40
- {
41
- name: 'url',
42
- type: 'text',
43
- message: 'Page URL',
44
- validation: ['important'],
45
- },
46
- ],
47
- },
48
-
49
- ];
50
- }
51
- }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import { _merge } from '@webqit/util/obj/index.js';
6
+ import { _isObject } from '@webqit/util/js/index.js';
7
+ import { Dotfile } from '@webqit/backpack';
8
+
9
+ export default class Ssg extends Dotfile {
10
+
11
+ // Base name
12
+ get name() {
13
+ return 'ssg';
14
+ }
15
+
16
+ // @desc
17
+ static get ['@desc']() {
18
+ return 'Server-Side Generation (SSG) config.';
19
+ }
20
+
21
+ // Defaults merger
22
+ withDefaults(config) {
23
+ return _merge(true, {
24
+ entries: [],
25
+ }, config);
26
+ }
27
+
28
+ // Questions generator
29
+ questions(config, choices = {}) {
30
+ // Questions
31
+ return [
32
+ {
33
+ name: 'entries',
34
+ type: 'recursive',
35
+ controls: {
36
+ name: 'page',
37
+ },
38
+ initial: config.entries,
39
+ questions: [
40
+ {
41
+ name: 'url',
42
+ type: 'text',
43
+ message: 'Page URL',
44
+ validation: ['important'],
45
+ },
46
+ ],
47
+ },
48
+
49
+ ];
50
+ }
51
+ }
@@ -1,14 +1,14 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import Manifest from './Manifest.js';
6
- import Ssg from './Ssg.js';
7
-
8
- /**
9
- * @exports
10
- */
11
- export {
12
- Manifest,
13
- Ssg,
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import Manifest from './Manifest.js';
6
+ import Ssg from './Ssg.js';
7
+
8
+ /**
9
+ * @exports
10
+ */
11
+ export {
12
+ Manifest,
13
+ Ssg,
14
14
  }
@@ -1,10 +1,10 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import * as origins from './origins/index.js';
6
-
7
- /**
8
- * @exports
9
- */
10
- export { origins }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import * as origins from './origins/index.js';
6
+
7
+ /**
8
+ * @exports
9
+ */
10
+ export { origins }
@@ -1,216 +1,216 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import Fs from 'fs';
6
- import Path from 'path';
7
- import SimpleGit from 'simple-git';
8
- import { spawn } from 'child_process';
9
- import { _any } from '@webqit/util/arr/index.js';
10
- import { _beforeLast } from '@webqit/util/str/index.js';
11
- import { _isObject } from '@webqit/util/js/index.js';
12
- import Webhooks from '@octokit/webhooks';
13
-
14
- /**
15
- * @desc
16
- */
17
- export const desc = {
18
- deploy: 'Deploy project from a remote origin.',
19
- };
20
-
21
- /**
22
- * @deploy
23
- */
24
- export async function deploy(origin) {
25
- const cx = this || {};
26
- if (!cx.config.deployment?.Origins) {
27
- throw new Error(`The Origins configurator "config.deployment.Origins" is required in context.`);
28
- }
29
- if (!_isObject(origin)) {
30
- if (!origin) {
31
- throw new Error(`Please provide a repository name.`);
32
- }
33
- if (origin.includes('/')) {
34
- if (!origin.startsWith('https://') || !origin.endsWith('.git')) {
35
- throw new Error(`Cannot deploy ${origin}: A valid https git repository is expected.`);
36
- }
37
- var urlSplit = _beforeLast(origin, '.git').split('/');
38
- var [ repo, branch ] = urlSplit.splice(-2).join('/').split(':');
39
- origin = {
40
- repo,
41
- branch: branch || 'master',
42
- host: urlSplit.pop(),
43
- url: origin,
44
- tag: repo.replace('/', '-'),
45
- };
46
- } else {
47
- const matches = await (new cx.config.deployment.Origins(cx)).match(origin);
48
- if (matches.length > 1) {
49
- throw new Error(`Cannot deploy ${origin}: Multiple deploy settings found.`);
50
- }
51
- if (!matches.length) {
52
- throw new Error(`Cannot deploy ${origin}: No deploy settings found.`);
53
- }
54
- origin = matches[0];
55
- }
56
- }
57
- // ---------------
58
- const isDeployPathSet = origin.deploy_path;
59
- origin.deploy_path = Path.join(cx.CWD || '', origin.deploy_path || '.');
60
- // ---------------
61
- // Instance
62
- const git = SimpleGit();
63
- // Before calling git.init()
64
- var isNewDeployPath = !Fs.existsSync((origin.deploy_path || '') + '/.git');
65
- if (isDeployPathSet) {
66
- if (!Fs.existsSync(origin.deploy_path)) {
67
- Fs.mkdirSync(origin.deploy_path, { recursive: true });
68
- }
69
- }
70
- await git.cwd(origin.deploy_path);
71
- // Must come after git.cwd()
72
- await git.init();
73
-
74
- const hosts = {
75
- github: 'https://github.com',
76
- bitbucket: 'https://bitbucket.org',
77
- };
78
- const url = origin.url || hosts[origin.host] + '/' + origin.repo + '.git';
79
-
80
- // Deployment
81
- const pull = async () => {
82
- let waiting;
83
- if (cx.logger) {
84
- cx.logger.log('');
85
- waiting = cx.logger.waiting(cx.logger.f`Deploying ${origin.tag}`);
86
- waiting.start();
87
- }
88
- await git.reset('hard');
89
- return git.pull(origin.tag, origin.branch)
90
- .then(() => {
91
- if (cx.logger) {
92
- waiting.stop();
93
- cx.logger.log('');
94
- var _date = (new Date).toUTCString();
95
- cx.logger.success(cx.logger.f`[${cx.logger.style.comment(_date)}][AUTODEPLOY] Successfully deployed: ${origin.tag + '@' + origin.branch} - ${url} to ${origin.deploy_path}!`);
96
- cx.logger.success(cx.logger.f`[${cx.logger.style.comment(_date)}][AUTODEPLOY] On-deploy script: ${origin.ondeploy}!`);
97
- cx.logger.log('');
98
- }
99
- if (origin.ondeploy) {
100
- const run = cmd => new Promise((resolve, reject) => {
101
- cmd = cmd.split(' ').map(a => a.trim()).filter(a => a);
102
- const child = spawn(cmd.shift(), cmd, {
103
- cwd: origin.deploy_path,
104
- stdio: [ process.stdin, process.stdout, process.stderr ],
105
- });
106
-
107
- child.on('error', error => {
108
- cx.logger && cx.logger.error(error);
109
- reject(error);
110
- });
111
-
112
- child.on('exit', async exitCode => {
113
- resolve(exitCode);
114
- cx.logger && cx.logger.log('');
115
- });
116
- });
117
- return origin.ondeploy.split('&&').map(cmd => cmd.trim()).reduce(
118
- async (prev, cmd) => (await prev) === 0 ? run(cmd) : prev
119
- , 0);
120
- }
121
- }).catch(err => {
122
- if (cx.logger) {
123
- waiting.stop();
124
- cx.logger.error(err);
125
- }
126
- });
127
- };
128
-
129
- // Remote layout
130
- return git.getRemotes().then(remotes => {
131
- if (!_any(remotes, remote => remote.name === origin.tag)
132
- // But if the folder was deleted and created anew,
133
- // the above would still hold true, so we detect that here
134
- || isNewDeployPath) {
135
- return git.addRemote(origin.tag, url)
136
- .then(() => {
137
- if (cx.logger) {
138
- cx.logger.log('');
139
- cx.logger.info(cx.logger.f`Added new origin - ${origin.tag}: ${url}`);
140
- }
141
- return pull();
142
- })
143
- .catch(err => cx.logger && cx.logger.error(err));
144
- } else {
145
- return pull();
146
- }
147
- });
148
-
149
- }
150
-
151
- /**
152
- * @hook
153
- */
154
- export async function webhook(httpEvent, router, next) {
155
- const cx = this || {};
156
- if (!cx.config.deployment?.Origins) {
157
- throw new Error(`The Origins configurator "config.deployment.Origins" is required in context.`);
158
- }
159
- const webhookEventHandler = Webhooks.createEventHandler();
160
- if (httpEvent.request.headers.has('user-agent') && httpEvent.request.headers.get('user-agent').startsWith('GitHub-Hookshot/')) {
161
- const payload = await httpEvent.request.json();
162
- const matches = (await (new cx.config.deployment.Origins(cx)).match(payload.repository.full_name)).filter(o => o.autodeploy);
163
- var deployParams;
164
- if (!(deployParams = matches[0])) {
165
- return next();
166
- }
167
- if (matches.length > 1) {
168
- throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Multiple deploy settings found.`);
169
- }
170
- if (!deployParams.autodeploy_secret) {
171
- throw new Error(`Failed deploy attempt (${payload.repository.full_name}): The deploy settings do not contain a secret.`);
172
- }
173
- if (!Webhooks.verify(deployParams.autodeploy_secret, payload, httpEvent.request.headers.get('x-hub-signature'))) {
174
- throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Signature mismatch.`);
175
- }
176
- if (payload.repository.disabled || payload.repository.archived) {
177
- throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Repository disabled or archived.`);
178
- }
179
- return new Promise(resolve => {
180
- webhookEventHandler.on('push', async ({ name, payload }) => {
181
- if (cx.logger) {
182
- cx.logger.log('---------------------------');
183
- cx.logger.log('');
184
- }
185
- var exitCode = await router.route('deploy', navigationEvent, payload, _payload => {
186
- return deploy.call(cx, deployParams);
187
- });
188
- if (cx.logger) {
189
- cx.logger.log('');
190
- cx.logger.log('---------------------------');
191
- }
192
- if (exitCode === 0) {
193
- if (cx.logger) {
194
- cx.logger.log('');
195
- var _date = (new Date).toUTCString();
196
- cx.logger.success(cx.logger.f`[${cx.logger.style.comment(_date)}][AUTODEPLOY] Auto-exit: ${true}; exiting...`);
197
- cx.logger.log('');
198
- }
199
- if (deployParams.ondeploy_autoexit) {
200
- process.exit();
201
- }
202
- }
203
- resolve(
204
- new navigationEvent.Response(null, { status: exitCode === 0 ? 200 : 500 })
205
- );
206
- });
207
- webhookEventHandler.receive({
208
- id: httpEvent.request.headers.get('x-github-delivery'),
209
- name: httpEvent.request.headers.get('x-github-httpEvent'),
210
- payload: payload /* JSON object */,
211
- });
212
- });
213
- }
214
-
215
- return next();
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import Fs from 'fs';
6
+ import Path from 'path';
7
+ import SimpleGit from 'simple-git';
8
+ import { spawn } from 'child_process';
9
+ import { _any } from '@webqit/util/arr/index.js';
10
+ import { _beforeLast } from '@webqit/util/str/index.js';
11
+ import { _isObject } from '@webqit/util/js/index.js';
12
+ import Webhooks from '@octokit/webhooks';
13
+
14
+ /**
15
+ * @desc
16
+ */
17
+ export const desc = {
18
+ deploy: 'Deploy project from a remote origin.',
19
+ };
20
+
21
+ /**
22
+ * @deploy
23
+ */
24
+ export async function deploy(origin) {
25
+ const cx = this || {};
26
+ if (!cx.config.deployment?.Origins) {
27
+ throw new Error(`The Origins configurator "config.deployment.Origins" is required in context.`);
28
+ }
29
+ if (!_isObject(origin)) {
30
+ if (!origin) {
31
+ throw new Error(`Please provide a repository name.`);
32
+ }
33
+ if (origin.includes('/')) {
34
+ if (!origin.startsWith('https://') || !origin.endsWith('.git')) {
35
+ throw new Error(`Cannot deploy ${origin}: A valid https git repository is expected.`);
36
+ }
37
+ var urlSplit = _beforeLast(origin, '.git').split('/');
38
+ var [ repo, branch ] = urlSplit.splice(-2).join('/').split(':');
39
+ origin = {
40
+ repo,
41
+ branch: branch || 'master',
42
+ host: urlSplit.pop(),
43
+ url: origin,
44
+ tag: repo.replace('/', '-'),
45
+ };
46
+ } else {
47
+ const matches = await (new cx.config.deployment.Origins(cx)).match(origin);
48
+ if (matches.length > 1) {
49
+ throw new Error(`Cannot deploy ${origin}: Multiple deploy settings found.`);
50
+ }
51
+ if (!matches.length) {
52
+ throw new Error(`Cannot deploy ${origin}: No deploy settings found.`);
53
+ }
54
+ origin = matches[0];
55
+ }
56
+ }
57
+ // ---------------
58
+ const isDeployPathSet = origin.deploy_path;
59
+ origin.deploy_path = Path.join(cx.CWD || '', origin.deploy_path || '.');
60
+ // ---------------
61
+ // Instance
62
+ const git = SimpleGit();
63
+ // Before calling git.init()
64
+ var isNewDeployPath = !Fs.existsSync((origin.deploy_path || '') + '/.git');
65
+ if (isDeployPathSet) {
66
+ if (!Fs.existsSync(origin.deploy_path)) {
67
+ Fs.mkdirSync(origin.deploy_path, { recursive: true });
68
+ }
69
+ }
70
+ await git.cwd(origin.deploy_path);
71
+ // Must come after git.cwd()
72
+ await git.init();
73
+
74
+ const hosts = {
75
+ github: 'https://github.com',
76
+ bitbucket: 'https://bitbucket.org',
77
+ };
78
+ const url = origin.url || hosts[origin.host] + '/' + origin.repo + '.git';
79
+
80
+ // Deployment
81
+ const pull = async () => {
82
+ let waiting;
83
+ if (cx.logger) {
84
+ cx.logger.log('');
85
+ waiting = cx.logger.waiting(cx.logger.f`Deploying ${origin.tag}`);
86
+ waiting.start();
87
+ }
88
+ await git.reset('hard');
89
+ return git.pull(origin.tag, origin.branch)
90
+ .then(() => {
91
+ if (cx.logger) {
92
+ waiting.stop();
93
+ cx.logger.log('');
94
+ var _date = (new Date).toUTCString();
95
+ cx.logger.success(cx.logger.f`[${cx.logger.style.comment(_date)}][AUTODEPLOY] Successfully deployed: ${origin.tag + '@' + origin.branch} - ${url} to ${origin.deploy_path}!`);
96
+ cx.logger.success(cx.logger.f`[${cx.logger.style.comment(_date)}][AUTODEPLOY] On-deploy script: ${origin.ondeploy}!`);
97
+ cx.logger.log('');
98
+ }
99
+ if (origin.ondeploy) {
100
+ const run = cmd => new Promise((resolve, reject) => {
101
+ cmd = cmd.split(' ').map(a => a.trim()).filter(a => a);
102
+ const child = spawn(cmd.shift(), cmd, {
103
+ cwd: origin.deploy_path,
104
+ stdio: [ process.stdin, process.stdout, process.stderr ],
105
+ });
106
+
107
+ child.on('error', error => {
108
+ cx.logger && cx.logger.error(error);
109
+ reject(error);
110
+ });
111
+
112
+ child.on('exit', async exitCode => {
113
+ resolve(exitCode);
114
+ cx.logger && cx.logger.log('');
115
+ });
116
+ });
117
+ return origin.ondeploy.split('&&').map(cmd => cmd.trim()).reduce(
118
+ async (prev, cmd) => (await prev) === 0 ? run(cmd) : prev
119
+ , 0);
120
+ }
121
+ }).catch(err => {
122
+ if (cx.logger) {
123
+ waiting.stop();
124
+ cx.logger.error(err);
125
+ }
126
+ });
127
+ };
128
+
129
+ // Remote layout
130
+ return git.getRemotes().then(remotes => {
131
+ if (!_any(remotes, remote => remote.name === origin.tag)
132
+ // But if the folder was deleted and created anew,
133
+ // the above would still hold true, so we detect that here
134
+ || isNewDeployPath) {
135
+ return git.addRemote(origin.tag, url)
136
+ .then(() => {
137
+ if (cx.logger) {
138
+ cx.logger.log('');
139
+ cx.logger.info(cx.logger.f`Added new origin - ${origin.tag}: ${url}`);
140
+ }
141
+ return pull();
142
+ })
143
+ .catch(err => cx.logger && cx.logger.error(err));
144
+ } else {
145
+ return pull();
146
+ }
147
+ });
148
+
149
+ }
150
+
151
+ /**
152
+ * @hook
153
+ */
154
+ export async function webhook(httpEvent, router, next) {
155
+ const cx = this || {};
156
+ if (!cx.config.deployment?.Origins) {
157
+ throw new Error(`The Origins configurator "config.deployment.Origins" is required in context.`);
158
+ }
159
+ const webhookEventHandler = Webhooks.createEventHandler();
160
+ if (httpEvent.request.headers.has('user-agent') && httpEvent.request.headers.get('user-agent').startsWith('GitHub-Hookshot/')) {
161
+ const payload = await httpEvent.request.json();
162
+ const matches = (await (new cx.config.deployment.Origins(cx)).match(payload.repository.full_name)).filter(o => o.autodeploy);
163
+ var deployParams;
164
+ if (!(deployParams = matches[0])) {
165
+ return next();
166
+ }
167
+ if (matches.length > 1) {
168
+ throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Multiple deploy settings found.`);
169
+ }
170
+ if (!deployParams.autodeploy_secret) {
171
+ throw new Error(`Failed deploy attempt (${payload.repository.full_name}): The deploy settings do not contain a secret.`);
172
+ }
173
+ if (!Webhooks.verify(deployParams.autodeploy_secret, payload, httpEvent.request.headers.get('x-hub-signature'))) {
174
+ throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Signature mismatch.`);
175
+ }
176
+ if (payload.repository.disabled || payload.repository.archived) {
177
+ throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Repository disabled or archived.`);
178
+ }
179
+ return new Promise(resolve => {
180
+ webhookEventHandler.on('push', async ({ name, payload }) => {
181
+ if (cx.logger) {
182
+ cx.logger.log('---------------------------');
183
+ cx.logger.log('');
184
+ }
185
+ var exitCode = await router.route('deploy', navigationEvent, payload, _payload => {
186
+ return deploy.call(cx, deployParams);
187
+ });
188
+ if (cx.logger) {
189
+ cx.logger.log('');
190
+ cx.logger.log('---------------------------');
191
+ }
192
+ if (exitCode === 0) {
193
+ if (cx.logger) {
194
+ cx.logger.log('');
195
+ var _date = (new Date).toUTCString();
196
+ cx.logger.success(cx.logger.f`[${cx.logger.style.comment(_date)}][AUTODEPLOY] Auto-exit: ${true}; exiting...`);
197
+ cx.logger.log('');
198
+ }
199
+ if (deployParams.ondeploy_autoexit) {
200
+ process.exit();
201
+ }
202
+ }
203
+ resolve(
204
+ new navigationEvent.Response(null, { status: exitCode === 0 ? 200 : 500 })
205
+ );
206
+ });
207
+ webhookEventHandler.receive({
208
+ id: httpEvent.request.headers.get('x-github-delivery'),
209
+ name: httpEvent.request.headers.get('x-github-httpEvent'),
210
+ payload: payload /* JSON object */,
211
+ });
212
+ });
213
+ }
214
+
215
+ return next();
216
216
  }
package/src/index.js CHANGED
@@ -1,20 +1,20 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import * as config from './config-pi/index.js';
6
- import * as deployment from './deployment-pi/index.js';
7
- import * as runtime from './runtime-pi/index.js';
8
- import * as services from './services-pi/index.js';
9
- import Context from './Context.js';
10
-
11
- /**
12
- * @exports
13
- */
14
- export {
15
- config,
16
- deployment,
17
- runtime,
18
- services,
19
- Context,
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import * as config from './config-pi/index.js';
6
+ import * as deployment from './deployment-pi/index.js';
7
+ import * as runtime from './runtime-pi/index.js';
8
+ import * as services from './services-pi/index.js';
9
+ import Context from './Context.js';
10
+
11
+ /**
12
+ * @exports
13
+ */
14
+ export {
15
+ config,
16
+ deployment,
17
+ runtime,
18
+ services,
19
+ Context,
20
20
  }