@whook/gcp-functions 9.0.0 → 10.0.1
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/README.md +14 -11
- package/dist/commands/testHTTPFunction.d.ts +1 -1
- package/dist/commands/testHTTPFunction.js +119 -150
- package/dist/commands/testHTTPFunction.js.map +1 -1
- package/dist/index.d.ts +2 -4
- package/dist/index.js +182 -269
- package/dist/index.js.map +1 -1
- package/dist/libs/utils.js +16 -35
- package/dist/libs/utils.js.map +1 -1
- package/dist/services/_autoload.d.ts +3 -3
- package/dist/services/_autoload.js +83 -109
- package/dist/services/_autoload.js.map +1 -1
- package/dist/services/log.js +2 -12
- package/dist/services/log.js.map +1 -1
- package/dist/services/log.test.js +4 -9
- package/dist/services/log.test.js.map +1 -1
- package/dist/wrappers/googleHTTPFunction.js +246 -294
- package/dist/wrappers/googleHTTPFunction.js.map +1 -1
- package/package.json +49 -90
- package/src/commands/testHTTPFunction.ts +6 -13
- package/src/index.ts +28 -48
- package/src/libs/utils.ts +3 -4
- package/src/services/_autoload.ts +4 -3
- package/src/services/log.test.ts +1 -1
- package/src/wrappers/googleHTTPFunction.ts +6 -6
- package/dist/commands/testHTTPFunction.mjs +0 -136
- package/dist/commands/testHTTPFunction.mjs.map +0 -1
- package/dist/index.mjs +0 -265
- package/dist/index.mjs.map +0 -1
- package/dist/libs/utils.mjs +0 -27
- package/dist/libs/utils.mjs.map +0 -1
- package/dist/services/_autoload.mjs +0 -113
- package/dist/services/_autoload.mjs.map +0 -1
- package/dist/services/log.mjs +0 -4
- package/dist/services/log.mjs.map +0 -1
- package/dist/services/log.test.mjs +0 -7
- package/dist/services/log.test.mjs.map +0 -1
- package/dist/wrappers/googleHTTPFunction.mjs +0 -290
- package/dist/wrappers/googleHTTPFunction.mjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,217 +1,153 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DEFAULT_BUILD_PARALLELISM = void 0;
|
|
7
|
-
exports.prepareBuildEnvironment = prepareBuildEnvironment;
|
|
8
|
-
exports.runBuild = runBuild;
|
|
9
|
-
|
|
10
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
11
|
-
|
|
12
|
-
var _util = _interopRequireDefault(require("util"));
|
|
13
|
-
|
|
14
|
-
var _path = _interopRequireDefault(require("path"));
|
|
15
|
-
|
|
16
|
-
var _mkdirp = _interopRequireDefault(require("mkdirp"));
|
|
17
|
-
|
|
18
|
-
var _cpr = _interopRequireDefault(require("cpr"));
|
|
19
|
-
|
|
20
|
-
var _yerror = _interopRequireDefault(require("yerror"));
|
|
21
|
-
|
|
22
|
-
var _knifecycle = _interopRequireWildcard(require("knifecycle"));
|
|
23
|
-
|
|
24
|
-
var _whook = require("@whook/whook");
|
|
25
|
-
|
|
26
|
-
var _autoload = _interopRequireDefault(require("./services/_autoload"));
|
|
27
|
-
|
|
28
|
-
var _httpRouter = require("@whook/http-router");
|
|
29
|
-
|
|
30
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
31
|
-
|
|
32
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
|
|
34
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
35
|
-
|
|
36
1
|
/* eslint global-require:0 */
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import util from 'util';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import mkdirp from 'mkdirp';
|
|
6
|
+
import cpr from 'cpr';
|
|
7
|
+
import { YError } from 'yerror';
|
|
8
|
+
import { createRequire } from 'module';
|
|
9
|
+
import { Knifecycle, SPECIAL_PROPS, constant, initInitializerBuilder, } from 'knifecycle';
|
|
10
|
+
import { initCompiler } from '@whook/whook';
|
|
11
|
+
import initBuildAutoloader from './services/_autoload.js';
|
|
12
|
+
import { dereferenceOpenAPIOperations, getOpenAPIOperations, } from '@whook/http-router';
|
|
13
|
+
export const DEFAULT_BUILD_PARALLELISM = 10;
|
|
14
|
+
const readFileAsync = util.promisify(fs.readFile);
|
|
15
|
+
const writeFileAsync = util.promisify(fs.writeFile);
|
|
16
|
+
const cprAsync = util.promisify(cpr);
|
|
17
|
+
// TODO: Use import.meta when Jest will support it
|
|
18
|
+
const require = createRequire(path.join(process.cwd(), 'src', 'index.ts'));
|
|
46
19
|
const BUILD_DEFINITIONS = {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
20
|
+
http: {
|
|
21
|
+
type: 'HTTP',
|
|
22
|
+
wrapper: {
|
|
23
|
+
name: 'wrapHandlerForGoogleHTTPFunction',
|
|
24
|
+
path: path.join(path.dirname(require.resolve('@whook/gcp-function')), 'wrappers/googleHTTPFunction.js'),
|
|
25
|
+
},
|
|
26
|
+
suffix: 'Wrapped',
|
|
52
27
|
},
|
|
53
|
-
suffix: 'Wrapped'
|
|
54
|
-
}
|
|
55
28
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return $;
|
|
29
|
+
export async function prepareBuildEnvironment($ = new Knifecycle()) {
|
|
30
|
+
$.register(constant('INITIALIZER_PATH_MAP', {
|
|
31
|
+
ENV: '@whook/whook/dist/services/ProxyedENV',
|
|
32
|
+
log: '@whook/gcp-functions/dist/services/log',
|
|
33
|
+
time: 'common-services/dist/time',
|
|
34
|
+
delay: 'common-services/dist/delay',
|
|
35
|
+
}));
|
|
36
|
+
$.register(initInitializerBuilder);
|
|
37
|
+
$.register(initBuildAutoloader);
|
|
38
|
+
$.register(initCompiler);
|
|
39
|
+
$.register(constant('PORT', 1337));
|
|
40
|
+
$.register(constant('HOST', 'localhost'));
|
|
41
|
+
return $;
|
|
70
42
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
43
|
+
export async function runBuild(aPrepareBuildEnvironment) {
|
|
44
|
+
try {
|
|
45
|
+
const handlerName = process.argv[2];
|
|
46
|
+
const $ = await aPrepareBuildEnvironment();
|
|
47
|
+
const { NODE_ENV, BUILD_PARALLELISM, PROJECT_DIR, compiler, log, $autoload, API, buildInitializer, } = await $.run([
|
|
48
|
+
'NODE_ENV',
|
|
49
|
+
'?BUILD_PARALLELISM',
|
|
50
|
+
'PROJECT_DIR',
|
|
51
|
+
'process',
|
|
52
|
+
'compiler',
|
|
53
|
+
'log',
|
|
54
|
+
'$autoload',
|
|
55
|
+
'API',
|
|
56
|
+
'buildInitializer',
|
|
57
|
+
]);
|
|
58
|
+
log('info', 'GCP Functions build Environment initialized 🚀🌕');
|
|
59
|
+
const operations = (await dereferenceOpenAPIOperations(API, getOpenAPIOperations(API))).filter((operation) => {
|
|
60
|
+
if (handlerName) {
|
|
61
|
+
const sourceOperationId = operation['x-whook'] && operation['x-whook'].sourceOperationId;
|
|
62
|
+
return (handlerName === operation.operationId ||
|
|
63
|
+
handlerName === sourceOperationId);
|
|
64
|
+
}
|
|
65
|
+
return true;
|
|
66
|
+
});
|
|
67
|
+
log('warning', `${operations.length} operations to process.`);
|
|
68
|
+
await processOperations({
|
|
69
|
+
NODE_ENV,
|
|
70
|
+
BUILD_PARALLELISM: BUILD_PARALLELISM || DEFAULT_BUILD_PARALLELISM,
|
|
71
|
+
PROJECT_DIR,
|
|
72
|
+
compiler,
|
|
73
|
+
log,
|
|
74
|
+
$autoload,
|
|
75
|
+
buildInitializer,
|
|
76
|
+
}, operations);
|
|
77
|
+
await $.destroy();
|
|
78
|
+
}
|
|
79
|
+
catch (err) {
|
|
80
|
+
// eslint-disable-next-line
|
|
81
|
+
console.error('💀 - Cannot launch the build:', err.stack, JSON.stringify(err.params, null, 2));
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
113
84
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
log('info', operationsLeft.length, ' operations left.');
|
|
138
|
-
return processOperations({
|
|
139
|
-
NODE_ENV,
|
|
140
|
-
BUILD_PARALLELISM,
|
|
141
|
-
BUILD_OPTIONS,
|
|
142
|
-
PROJECT_DIR,
|
|
143
|
-
compiler,
|
|
144
|
-
log,
|
|
145
|
-
$autoload,
|
|
146
|
-
buildInitializer
|
|
147
|
-
}, operationsLeft);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
log('info', 'No more operations.');
|
|
85
|
+
async function processOperations({ NODE_ENV, BUILD_PARALLELISM, PROJECT_DIR, compiler, log, $autoload, buildInitializer, }, operations) {
|
|
86
|
+
const operationsLeft = operations.slice(BUILD_PARALLELISM);
|
|
87
|
+
await Promise.all(operations.slice(0, BUILD_PARALLELISM).map((operation) => buildAnyLambda({
|
|
88
|
+
NODE_ENV,
|
|
89
|
+
PROJECT_DIR,
|
|
90
|
+
compiler,
|
|
91
|
+
log,
|
|
92
|
+
$autoload,
|
|
93
|
+
buildInitializer,
|
|
94
|
+
}, operation)));
|
|
95
|
+
if (operationsLeft.length) {
|
|
96
|
+
log('info', operationsLeft.length, ' operations left.');
|
|
97
|
+
return processOperations({
|
|
98
|
+
NODE_ENV,
|
|
99
|
+
BUILD_PARALLELISM,
|
|
100
|
+
PROJECT_DIR,
|
|
101
|
+
compiler,
|
|
102
|
+
log,
|
|
103
|
+
$autoload,
|
|
104
|
+
buildInitializer,
|
|
105
|
+
}, operationsLeft);
|
|
106
|
+
}
|
|
107
|
+
log('info', 'No more operations.');
|
|
151
108
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
PROJECT_DIR,
|
|
190
|
-
log
|
|
191
|
-
}, lambdaPath, whookConfig.staticFiles || []), ensureFileAsync({
|
|
192
|
-
log
|
|
193
|
-
}, _path.default.join(lambdaPath, 'initialize.js'), initializerContent), ensureFileAsync({
|
|
194
|
-
log
|
|
195
|
-
}, _path.default.join(lambdaPath, 'main.js'), indexContent)]);
|
|
196
|
-
await buildFinalLambda({
|
|
197
|
-
compiler,
|
|
198
|
-
log
|
|
199
|
-
}, lambdaPath, whookConfig);
|
|
200
|
-
} catch (err) {
|
|
201
|
-
log('error', `Error building "${operationId}"...`);
|
|
202
|
-
log('error-stack', err.stack || 'no_stack_trace');
|
|
203
|
-
log('debug', JSON.stringify(err.params, null, 2));
|
|
204
|
-
throw _yerror.default.wrap(err, 'E_LAMBDA_BUILD', operationId);
|
|
205
|
-
}
|
|
109
|
+
async function buildAnyLambda({ NODE_ENV, PROJECT_DIR, compiler, log, $autoload, buildInitializer, }, operation) {
|
|
110
|
+
const { operationId } = operation;
|
|
111
|
+
try {
|
|
112
|
+
const whookConfig = operation['x-whook'] || { type: 'http' };
|
|
113
|
+
const operationType = whookConfig.type || 'http';
|
|
114
|
+
const sourceOperationId = whookConfig.sourceOperationId;
|
|
115
|
+
const entryPoint = operationId;
|
|
116
|
+
const finalEntryPoint = (sourceOperationId ? sourceOperationId : operationId) +
|
|
117
|
+
((operation['x-whook'] || {}).suffix || '');
|
|
118
|
+
log('warning', `Building ${operationType} "${finalEntryPoint}"...`);
|
|
119
|
+
const buildDefinition = BUILD_DEFINITIONS[operationType];
|
|
120
|
+
// eslint-disable-next-line
|
|
121
|
+
const applyWrapper = (await import(buildDefinition.wrapper.path)).default;
|
|
122
|
+
const rootNode = await $autoload(entryPoint + (buildDefinition.suffix || ''));
|
|
123
|
+
const lambdaPath = path.join(PROJECT_DIR, 'builds', NODE_ENV, finalEntryPoint);
|
|
124
|
+
const finalHandlerInitializer = applyWrapper(rootNode.initializer);
|
|
125
|
+
const initializerContent = await buildInitializer(finalHandlerInitializer[SPECIAL_PROPS.INJECT].map((name) => name === 'OPERATION_API'
|
|
126
|
+
? `OPERATION_API>OPERATION_API_${finalEntryPoint}`
|
|
127
|
+
: name));
|
|
128
|
+
const indexContent = await buildLambdaIndex(rootNode, {
|
|
129
|
+
name: buildDefinition.wrapper.name,
|
|
130
|
+
path: buildDefinition.wrapper.path,
|
|
131
|
+
});
|
|
132
|
+
await mkdirp(lambdaPath);
|
|
133
|
+
await Promise.all([
|
|
134
|
+
copyStaticFiles({ PROJECT_DIR, log }, lambdaPath, whookConfig.staticFiles || []),
|
|
135
|
+
ensureFileAsync({ log }, path.join(lambdaPath, 'initialize.js'), initializerContent),
|
|
136
|
+
ensureFileAsync({ log }, path.join(lambdaPath, 'main.js'), indexContent),
|
|
137
|
+
]);
|
|
138
|
+
await buildFinalLambda({ compiler, log }, lambdaPath, whookConfig);
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
log('error', `Error building "${operationId}"...`);
|
|
142
|
+
log('error-stack', err.stack || 'no_stack_trace');
|
|
143
|
+
log('debug', JSON.stringify(err.params, null, 2));
|
|
144
|
+
throw YError.wrap(err, 'E_LAMBDA_BUILD', operationId);
|
|
145
|
+
}
|
|
206
146
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
return `${options.modules === 'commonjs' ? `const pickModule = (m) => { return m && m.default || m; }
|
|
210
|
-
const initHandler = pickModule(require('${rootNode.path}'));
|
|
211
|
-
const ${buildWrapper.name} = pickModule(require('${buildWrapper.path}'));
|
|
212
|
-
const { initialize } = require('./initialize');` : `import initHandler from '${rootNode.path}';
|
|
147
|
+
async function buildLambdaIndex(rootNode, buildWrapper) {
|
|
148
|
+
return `import initHandler from '${rootNode.path}';
|
|
213
149
|
import ${buildWrapper.name} from '${buildWrapper.path}';
|
|
214
|
-
import { initialize } from './initialize'
|
|
150
|
+
import { initialize } from './initialize.js';
|
|
215
151
|
|
|
216
152
|
const handlerInitializer = ${buildWrapper.name}(
|
|
217
153
|
initHandler
|
|
@@ -220,80 +156,57 @@ const handlerInitializer = ${buildWrapper.name}(
|
|
|
220
156
|
const handlerPromise = initialize()
|
|
221
157
|
.then(handlerInitializer);
|
|
222
158
|
|
|
223
|
-
|
|
159
|
+
export default function handler (req, res) {
|
|
224
160
|
return handlerPromise
|
|
225
161
|
.then(handler => handler(req, res));
|
|
226
162
|
};
|
|
227
163
|
`;
|
|
228
164
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}, lambdaPath,
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} = await compiler(entryPoint, whookConfig.compilerOptions);
|
|
239
|
-
await Promise.all([ensureFileAsync({
|
|
240
|
-
log
|
|
241
|
-
}, `${lambdaPath}/index.js`, contents, 'utf-8'), mappings ? ensureFileAsync({
|
|
242
|
-
log
|
|
243
|
-
}, `${lambdaPath}/index.js.map`, mappings, 'utf-8') : Promise.resolve()]);
|
|
165
|
+
async function buildFinalLambda({ compiler, log }, lambdaPath, whookConfig) {
|
|
166
|
+
const entryPoint = `${lambdaPath}/main.js`;
|
|
167
|
+
const { contents, mappings } = await compiler(entryPoint, whookConfig.compilerOptions);
|
|
168
|
+
await Promise.all([
|
|
169
|
+
ensureFileAsync({ log }, `${lambdaPath}/index.js`, contents, 'utf-8'),
|
|
170
|
+
mappings
|
|
171
|
+
? ensureFileAsync({ log }, `${lambdaPath}/index.js.map`, mappings, 'utf-8')
|
|
172
|
+
: Promise.resolve(),
|
|
173
|
+
]);
|
|
244
174
|
}
|
|
245
|
-
|
|
246
|
-
async
|
|
247
|
-
PROJECT_DIR,
|
|
248
|
-
log
|
|
249
|
-
}, lambdaPath, staticFiles = []) {
|
|
250
|
-
await Promise.all(staticFiles.map(async staticFile => await copyFiles({
|
|
251
|
-
log
|
|
252
|
-
}, _path.default.join(PROJECT_DIR, 'node_modules', staticFile), _path.default.join(lambdaPath, 'node_modules', staticFile))));
|
|
175
|
+
async function copyStaticFiles({ PROJECT_DIR, log }, lambdaPath, staticFiles = []) {
|
|
176
|
+
await Promise.all(staticFiles.map(async (staticFile) => await copyFiles({ log }, path.join(PROJECT_DIR, 'node_modules', staticFile), path.join(lambdaPath, 'node_modules', staticFile))));
|
|
253
177
|
}
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if ('EISDIR' !== theError.code) {
|
|
272
|
-
throw theError;
|
|
178
|
+
async function copyFiles({ log }, source, destination) {
|
|
179
|
+
let theError;
|
|
180
|
+
try {
|
|
181
|
+
await mkdirp(destination);
|
|
182
|
+
const data = await readFileAsync(source, 'utf-8');
|
|
183
|
+
await ensureFileAsync({ log }, destination, data, 'utf-8');
|
|
184
|
+
}
|
|
185
|
+
catch (err) {
|
|
186
|
+
theError = err;
|
|
187
|
+
}
|
|
188
|
+
if (theError) {
|
|
189
|
+
if ('EISDIR' !== theError.code) {
|
|
190
|
+
throw theError;
|
|
191
|
+
}
|
|
192
|
+
await cprAsync(source, destination, {
|
|
193
|
+
overwrite: true,
|
|
194
|
+
});
|
|
273
195
|
}
|
|
274
|
-
|
|
275
|
-
await cprAsync(source, destination, {
|
|
276
|
-
overwrite: true
|
|
277
|
-
});
|
|
278
|
-
}
|
|
279
196
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
197
|
+
async function ensureFileAsync({ log }, path, content, encoding = 'utf-8') {
|
|
198
|
+
try {
|
|
199
|
+
const oldContent = await readFileAsync(path, encoding);
|
|
200
|
+
if (oldContent === content) {
|
|
201
|
+
log('debug', `Ignore unchanged file: "${path}".`);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch (err) {
|
|
206
|
+
log('debug', `Write new file: "${path}".`);
|
|
207
|
+
return await writeFileAsync(path, content, encoding);
|
|
290
208
|
}
|
|
291
|
-
|
|
292
|
-
log('debug', `Write new file: "${path}".`);
|
|
209
|
+
log('debug', `Write changed file: "${path}".`);
|
|
293
210
|
return await writeFileAsync(path, content, encoding);
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
log('debug', `Write changed file: "${path}".`);
|
|
297
|
-
return await writeFileAsync(path, content, encoding);
|
|
298
211
|
}
|
|
299
212
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["DEFAULT_BUILD_PARALLELISM","readFileAsync","util","promisify","fs","readFile","writeFileAsync","writeFile","cprAsync","cpr","BUILD_DEFINITIONS","http","type","wrapper","name","path","join","__dirname","suffix","prepareBuildEnvironment","$","Knifecycle","register","constant","ENV","log","time","delay","initInitializerBuilder","initBuildAutoloader","initCompiler","runBuild","aPrepareBuildEnvironment","handlerName","process","argv","NODE_ENV","BUILD_PARALLELISM","BUILD_OPTIONS","PROJECT_DIR","compiler","$autoload","API","buildInitializer","run","operations","dereferenceOpenAPIOperations","getOpenAPIOperations","filter","operation","sourceOperationId","operationId","length","processOperations","DEFAULT_BUILD_OPTIONS","destroy","err","console","error","stack","JSON","stringify","params","exit","operationsLeft","slice","Promise","all","map","buildAnyLambda","whookConfig","operationType","entryPoint","finalEntryPoint","buildDefinition","applyWrapper","require","default","rootNode","lambdaPath","finalHandlerInitializer","initializer","initializerContent","SPECIAL_PROPS","INJECT","indexContent","buildLambdaIndex","mkdirp","copyStaticFiles","staticFiles","ensureFileAsync","buildFinalLambda","YError","wrap","buildWrapper","options","modules","contents","mappings","compilerOptions","resolve","staticFile","copyFiles","source","destination","theError","data","code","overwrite","content","encoding","oldContent"],"sources":["../src/index.ts"],"sourcesContent":["/* eslint global-require:0 */\nimport fs from 'fs';\nimport util from 'util';\nimport path from 'path';\nimport mkdirp from 'mkdirp';\nimport cpr from 'cpr';\nimport YError from 'yerror';\nimport Knifecycle, {\n SPECIAL_PROPS,\n constant,\n initInitializerBuilder,\n} from 'knifecycle';\nimport { DEFAULT_BUILD_OPTIONS, initCompiler } from '@whook/whook';\nimport initBuildAutoloader from './services/_autoload';\nimport {\n dereferenceOpenAPIOperations,\n getOpenAPIOperations,\n} from '@whook/http-router';\nimport type {\n Autoloader,\n Dependencies,\n BuildInitializer,\n Initializer,\n Service,\n} from 'knifecycle';\nimport type {\n WhookOperation,\n WhookCompilerOptions,\n WhookCompilerService,\n} from '@whook/whook';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { LogService } from 'common-services';\nimport type { CprOptions } from 'cpr';\nimport type { BuildOptions } from 'knifecycle/dist/build';\n\nexport const DEFAULT_BUILD_PARALLELISM = 10;\n\nexport type WhookBuildConfig = {\n BUILD_OPTIONS?: BuildOptions;\n BUILD_PARALLELISM?: number;\n};\nexport type WhookAPIOperationGCPFunctionConfig = {\n type?: 'http';\n sourceOperationId?: string;\n staticFiles?: string[];\n compilerOptions?: WhookCompilerOptions;\n suffix?: string;\n};\n\nconst readFileAsync = util.promisify(fs.readFile) as (\n path: string,\n encoding: string,\n) => Promise<string>;\nconst writeFileAsync = util.promisify(fs.writeFile) as (\n path: string,\n content: string,\n encoding: string,\n) => Promise<void>;\nconst cprAsync = util.promisify(cpr) as (\n source: string,\n destination: string,\n options: CprOptions,\n) => Promise<string[]>;\n\nconst BUILD_DEFINITIONS: Record<\n NonNullable<WhookAPIOperationGCPFunctionConfig['type']>,\n {\n type: string;\n wrapper: { name: string; path: string };\n suffix?: string;\n }\n> = {\n http: {\n type: 'HTTP',\n wrapper: {\n name: 'wrapHandlerForGoogleHTTPFunction',\n path: path.join(__dirname, 'wrappers', 'googleHTTPFunction'),\n },\n suffix: 'Wrapped',\n },\n};\n\nexport async function prepareBuildEnvironment<T extends Knifecycle>(\n $: T = new Knifecycle() as T,\n): Promise<T> {\n $.register(\n constant('INITIALIZER_PATH_MAP', {\n ENV: '@whook/whook/dist/services/ProxyedENV',\n log: __dirname + '/services/log',\n time: 'common-services/dist/time',\n delay: 'common-services/dist/delay',\n }),\n );\n $.register(initInitializerBuilder);\n $.register(initBuildAutoloader);\n $.register(initCompiler);\n $.register(constant('PORT', 1337));\n $.register(constant('HOST', 'localhost'));\n\n return $;\n}\n\nexport async function runBuild(\n aPrepareBuildEnvironment: typeof prepareBuildEnvironment,\n): Promise<void> {\n try {\n const handlerName = process.argv[2];\n const $ = await aPrepareBuildEnvironment();\n const {\n NODE_ENV,\n BUILD_PARALLELISM,\n BUILD_OPTIONS,\n PROJECT_DIR,\n compiler,\n log,\n $autoload,\n API,\n buildInitializer,\n }: WhookBuildConfig & {\n NODE_ENV: string;\n PROJECT_DIR: string;\n compiler: WhookCompilerService;\n log: LogService;\n $autoload: Autoloader<Initializer<Dependencies, Service>>;\n API: OpenAPIV3.Document;\n buildInitializer: BuildInitializer;\n } = await $.run([\n 'NODE_ENV',\n '?BUILD_PARALLELISM',\n '?BUILD_OPTIONS',\n 'PROJECT_DIR',\n 'process',\n 'compiler',\n 'log',\n '$autoload',\n 'API',\n 'buildInitializer',\n ]);\n\n log('info', 'GCP Functions build Environment initialized 🚀🌕');\n\n const operations = (\n await dereferenceOpenAPIOperations(\n API,\n getOpenAPIOperations<WhookAPIOperationGCPFunctionConfig>(API),\n )\n ).filter((operation) => {\n if (handlerName) {\n const sourceOperationId =\n operation['x-whook'] && operation['x-whook'].sourceOperationId;\n\n return (\n handlerName === operation.operationId ||\n handlerName === sourceOperationId\n );\n }\n return true;\n });\n\n log('warning', `${operations.length} operations to process.`);\n await processOperations(\n {\n NODE_ENV,\n BUILD_OPTIONS: BUILD_OPTIONS || DEFAULT_BUILD_OPTIONS,\n BUILD_PARALLELISM: BUILD_PARALLELISM || DEFAULT_BUILD_PARALLELISM,\n PROJECT_DIR,\n compiler,\n log,\n $autoload,\n buildInitializer,\n },\n operations,\n );\n await $.destroy();\n } catch (err) {\n // eslint-disable-next-line\n console.error(\n '💀 - Cannot launch the build:',\n (err as YError).stack,\n JSON.stringify((err as YError).params, null, 2),\n );\n process.exit(1);\n }\n}\n\nasync function processOperations(\n {\n NODE_ENV,\n BUILD_PARALLELISM,\n BUILD_OPTIONS,\n PROJECT_DIR,\n compiler,\n log,\n $autoload,\n buildInitializer,\n }: {\n NODE_ENV: string;\n BUILD_PARALLELISM: number;\n BUILD_OPTIONS: BuildOptions;\n PROJECT_DIR: string;\n compiler: WhookCompilerService;\n log: LogService;\n $autoload: Autoloader<Initializer<Dependencies, Service>>;\n buildInitializer: BuildInitializer;\n },\n operations: WhookOperation<WhookAPIOperationGCPFunctionConfig>[],\n): Promise<void> {\n const operationsLeft = operations.slice(BUILD_PARALLELISM);\n\n await Promise.all(\n operations.slice(0, BUILD_PARALLELISM).map((operation) =>\n buildAnyLambda(\n {\n NODE_ENV,\n PROJECT_DIR,\n BUILD_OPTIONS,\n compiler,\n log,\n $autoload,\n buildInitializer,\n },\n operation,\n ),\n ),\n );\n\n if (operationsLeft.length) {\n log('info', operationsLeft.length, ' operations left.');\n return processOperations(\n {\n NODE_ENV,\n BUILD_PARALLELISM,\n BUILD_OPTIONS,\n PROJECT_DIR,\n compiler,\n log,\n $autoload,\n buildInitializer,\n },\n operationsLeft,\n );\n }\n log('info', 'No more operations.');\n}\n\nasync function buildAnyLambda(\n {\n NODE_ENV,\n PROJECT_DIR,\n BUILD_OPTIONS,\n compiler,\n log,\n $autoload,\n buildInitializer,\n }: {\n NODE_ENV: string;\n PROJECT_DIR: string;\n BUILD_OPTIONS: BuildOptions;\n compiler: WhookCompilerService;\n log: LogService;\n $autoload: Autoloader<Initializer<Dependencies, Service>>;\n buildInitializer: BuildInitializer;\n },\n operation: WhookOperation<WhookAPIOperationGCPFunctionConfig>,\n): Promise<void> {\n const { operationId } = operation;\n\n try {\n const whookConfig: WhookAPIOperationGCPFunctionConfig =\n operation['x-whook'] || {};\n const operationType = whookConfig.type || 'http';\n const sourceOperationId = whookConfig.sourceOperationId;\n const entryPoint = operationId;\n const finalEntryPoint =\n (sourceOperationId ? sourceOperationId : operationId) +\n ((operation['x-whook'] || {}).suffix || '');\n log('warning', `Building ${operationType} \"${finalEntryPoint}\"...`);\n const buildDefinition = BUILD_DEFINITIONS[operationType];\n // eslint-disable-next-line\n const applyWrapper = require(buildDefinition.wrapper.path).default;\n const rootNode = await $autoload(\n entryPoint + (buildDefinition.suffix || ''),\n );\n const lambdaPath = path.join(\n PROJECT_DIR,\n 'builds',\n NODE_ENV,\n finalEntryPoint,\n );\n const finalHandlerInitializer = applyWrapper(rootNode.initializer);\n\n const initializerContent = await buildInitializer(\n finalHandlerInitializer[SPECIAL_PROPS.INJECT].map((name) =>\n name === 'OPERATION_API'\n ? `OPERATION_API>OPERATION_API_${finalEntryPoint}`\n : name,\n ),\n BUILD_OPTIONS,\n );\n const indexContent = await buildLambdaIndex(\n rootNode,\n {\n name: buildDefinition.wrapper.name,\n path: buildDefinition.wrapper.path,\n },\n BUILD_OPTIONS,\n );\n\n await mkdirp(lambdaPath);\n await Promise.all([\n copyStaticFiles(\n { PROJECT_DIR, log },\n lambdaPath,\n whookConfig.staticFiles || [],\n ),\n ensureFileAsync(\n { log },\n path.join(lambdaPath, 'initialize.js'),\n initializerContent,\n ),\n ensureFileAsync({ log }, path.join(lambdaPath, 'main.js'), indexContent),\n ]);\n await buildFinalLambda({ compiler, log }, lambdaPath, whookConfig);\n } catch (err) {\n log('error', `Error building \"${operationId}\"...`);\n log('error-stack', (err as Error).stack || 'no_stack_trace');\n log('debug', JSON.stringify((err as YError).params, null, 2));\n throw YError.wrap(err as Error, 'E_LAMBDA_BUILD', operationId);\n }\n}\n\nasync function buildLambdaIndex(\n rootNode: { path: string },\n buildWrapper: { name: string; path: string },\n options: BuildOptions,\n): Promise<string> {\n return `${\n options.modules === 'commonjs'\n ? `const pickModule = (m) => { return m && m.default || m; }\nconst initHandler = pickModule(require('${rootNode.path}'));\nconst ${buildWrapper.name} = pickModule(require('${buildWrapper.path}'));\nconst { initialize } = require('./initialize');`\n : `import initHandler from '${rootNode.path}';\nimport ${buildWrapper.name} from '${buildWrapper.path}';\nimport { initialize } from './initialize';`\n }\n\nconst handlerInitializer = ${buildWrapper.name}(\n initHandler\n);\n\nconst handlerPromise = initialize()\n .then(handlerInitializer);\n\n${\n options.modules === 'commonjs'\n ? 'module.exports = {}; module.exports.default = '\n : 'export default '\n}function handler (req, res) {\n return handlerPromise\n .then(handler => handler(req, res));\n};\n`;\n}\n\nasync function buildFinalLambda(\n { compiler, log }: { compiler: WhookCompilerService; log: LogService },\n lambdaPath: string,\n whookConfig: WhookAPIOperationGCPFunctionConfig,\n): Promise<void> {\n const entryPoint = `${lambdaPath}/main.js`;\n const { contents, mappings } = await compiler(\n entryPoint,\n whookConfig.compilerOptions,\n );\n\n await Promise.all([\n ensureFileAsync({ log }, `${lambdaPath}/index.js`, contents, 'utf-8'),\n mappings\n ? ensureFileAsync(\n { log },\n `${lambdaPath}/index.js.map`,\n mappings,\n 'utf-8',\n )\n : Promise.resolve(),\n ]);\n}\n\nasync function copyStaticFiles(\n { PROJECT_DIR, log }: { PROJECT_DIR: string; log: LogService },\n lambdaPath: string,\n staticFiles: string[] = [],\n): Promise<void> {\n await Promise.all(\n staticFiles.map(\n async (staticFile) =>\n await copyFiles(\n { log },\n path.join(PROJECT_DIR, 'node_modules', staticFile),\n path.join(lambdaPath, 'node_modules', staticFile),\n ),\n ),\n );\n}\n\nasync function copyFiles(\n { log }: { log: LogService },\n source: string,\n destination: string,\n): Promise<void> {\n let theError;\n try {\n await mkdirp(destination);\n const data = await readFileAsync(source, 'utf-8');\n await ensureFileAsync({ log }, destination, data, 'utf-8');\n } catch (err) {\n theError = err;\n }\n if (theError) {\n if ('EISDIR' !== theError.code) {\n throw theError;\n }\n await cprAsync(source, destination, {\n overwrite: true,\n });\n }\n}\n\nasync function ensureFileAsync(\n { log }: { log: LogService },\n path: string,\n content: string,\n encoding = 'utf-8',\n): Promise<void> {\n try {\n const oldContent = await readFileAsync(path, encoding);\n\n if (oldContent === content) {\n log('debug', `Ignore unchanged file: \"${path}\".`);\n return;\n }\n } catch (err) {\n log('debug', `Write new file: \"${path}\".`);\n return await writeFileAsync(path, content, encoding);\n }\n log('debug', `Write changed file: \"${path}\".`);\n return await writeFileAsync(path, content, encoding);\n}\n"],"mappings":";;;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;;;;;;;AAdA;AAmCO,MAAMA,yBAAyB,GAAG,EAAlC;;;AAcP,MAAMC,aAAa,GAAGC,aAAA,CAAKC,SAAL,CAAeC,WAAA,CAAGC,QAAlB,CAAtB;;AAIA,MAAMC,cAAc,GAAGJ,aAAA,CAAKC,SAAL,CAAeC,WAAA,CAAGG,SAAlB,CAAvB;;AAKA,MAAMC,QAAQ,GAAGN,aAAA,CAAKC,SAAL,CAAeM,YAAf,CAAjB;;AAMA,MAAMC,iBAOL,GAAG;EACFC,IAAI,EAAE;IACJC,IAAI,EAAE,MADF;IAEJC,OAAO,EAAE;MACPC,IAAI,EAAE,kCADC;MAEPC,IAAI,EAAEA,aAAA,CAAKC,IAAL,CAAUC,SAAV,EA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
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
PROJECT_DIR,
|
|
16
|
-
log
|
|
17
|
-
}, target, operationId, type) {
|
|
18
|
-
const modulePath = _path.default.join(PROJECT_DIR, 'builds', target, operationId, type);
|
|
19
|
-
|
|
20
|
-
log('debug', `⛏️ - Loading lambda module at path "${modulePath}".`);
|
|
21
|
-
|
|
22
|
-
try {
|
|
23
|
-
// eslint-disable-next-line
|
|
24
|
-
const module = require(modulePath);
|
|
25
|
-
|
|
26
|
-
if (!module) {
|
|
27
|
-
throw new _yerror.default('E_MODULE_NOT_FOUND', module);
|
|
1
|
+
import { YError } from 'yerror';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export async function loadLambda({ PROJECT_DIR, log, }, target, operationId, type) {
|
|
4
|
+
const modulePath = path.join(PROJECT_DIR, 'builds', target, operationId, type + '.js');
|
|
5
|
+
log('debug', `⛏️ - Loading lambda module at path "${modulePath}".`);
|
|
6
|
+
try {
|
|
7
|
+
const module = await import(modulePath);
|
|
8
|
+
if (!module) {
|
|
9
|
+
throw new YError('E_MODULE_NOT_FOUND', module);
|
|
10
|
+
}
|
|
11
|
+
if (!module.default) {
|
|
12
|
+
throw new YError('E_LAMBDA_NOT_FOUND', module, Object.keys(module));
|
|
13
|
+
}
|
|
14
|
+
return module.default;
|
|
28
15
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
throw new _yerror.default('E_LAMBDA_NOT_FOUND', module, Object.keys(module));
|
|
16
|
+
catch (err) {
|
|
17
|
+
throw YError.wrap(err, 'E_LAMBDA_LOAD');
|
|
32
18
|
}
|
|
33
|
-
|
|
34
|
-
return module.default;
|
|
35
|
-
} catch (err) {
|
|
36
|
-
throw _yerror.default.wrap(err, 'E_LAMBDA_LOAD');
|
|
37
|
-
}
|
|
38
19
|
}
|
|
39
20
|
//# sourceMappingURL=utils.js.map
|
package/dist/libs/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/libs/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,IAAI,MAAM,MAAM,CAAC;AAGxB,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,EACE,WAAW,EACX,GAAG,GAIJ,EACD,MAAc,EACd,WAAmB,EACnB,IAAY;IAEZ,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAC1B,WAAW,EACX,QAAQ,EACR,MAAM,EACN,WAAW,EACX,IAAI,GAAG,KAAK,CACb,CAAC;IAEF,GAAG,CAAC,OAAO,EAAE,uCAAuC,UAAU,IAAI,CAAC,CAAC;IAEpE,IAAI;QACF,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;QAExC,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC;SAChD;QAED,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACnB,MAAM,IAAI,MAAM,CAAC,oBAAoB,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;SACrE;QAED,OAAO,MAAM,CAAC,OAAO,CAAC;KACvB;IAAC,OAAO,GAAG,EAAE;QACZ,MAAM,MAAM,CAAC,IAAI,CAAC,GAAY,EAAE,eAAe,CAAC,CAAC;KAClD;AACH,CAAC"}
|