@flink-app/flink 0.14.3 → 2.0.0-alpha.100
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/CHANGELOG.md +1051 -0
- package/SCHEMA_EXTRACTION_ANALYSIS.md +494 -0
- package/SIMPLE_AST_FEASIBILITY.md +570 -0
- package/bin/flink.ts +13 -2
- package/cli/build.ts +24 -44
- package/cli/clean.ts +13 -25
- package/cli/cli-utils.ts +190 -17
- package/cli/dev.ts +252 -0
- package/cli/loadEnvFiles.ts +116 -0
- package/cli/run.ts +45 -62
- package/dist/bin/flink.js +61 -2
- package/dist/cli/build.js +20 -25
- package/dist/cli/clean.js +12 -10
- package/dist/cli/cli-utils.d.ts +34 -3
- package/dist/cli/cli-utils.js +193 -12
- package/dist/cli/dev.d.ts +2 -0
- package/dist/cli/dev.js +279 -0
- package/dist/cli/loadEnvFiles.d.ts +30 -0
- package/dist/cli/loadEnvFiles.js +113 -0
- package/dist/cli/run.js +47 -46
- package/dist/src/DependencyTracker.d.ts +44 -0
- package/dist/src/DependencyTracker.js +239 -0
- package/dist/src/FlinkApp.d.ts +163 -10
- package/dist/src/FlinkApp.js +847 -184
- package/dist/src/FlinkContext.d.ts +41 -0
- package/dist/src/FlinkErrors.d.ts +19 -6
- package/dist/src/FlinkErrors.js +36 -42
- package/dist/src/FlinkHttpHandler.d.ts +219 -26
- package/dist/src/FlinkHttpHandler.js +37 -1
- package/dist/src/FlinkJob.d.ts +10 -0
- package/dist/src/FlinkLog.d.ts +82 -18
- package/dist/src/FlinkLog.js +165 -13
- package/dist/src/FlinkLogFactory.d.ts +288 -0
- package/dist/src/FlinkLogFactory.js +619 -0
- package/dist/src/FlinkRepo.d.ts +10 -2
- package/dist/src/FlinkRepo.js +11 -1
- package/dist/src/FlinkRequestContext.d.ts +63 -0
- package/dist/src/FlinkRequestContext.js +74 -0
- package/dist/src/FlinkResponse.d.ts +6 -0
- package/dist/src/FlinkService.d.ts +38 -0
- package/dist/src/FlinkService.js +46 -0
- package/dist/src/LeaderElection.d.ts +45 -0
- package/dist/src/LeaderElection.js +269 -0
- package/dist/src/SchemaCache.d.ts +84 -0
- package/dist/src/SchemaCache.js +289 -0
- package/dist/src/TypeScriptCompiler.d.ts +161 -51
- package/dist/src/TypeScriptCompiler.js +1253 -617
- package/dist/src/TypeScriptUtils.js +4 -0
- package/dist/src/ai/AgentRunner.d.ts +39 -0
- package/dist/src/ai/AgentRunner.js +760 -0
- package/dist/src/ai/ConversationAgent.d.ts +279 -0
- package/dist/src/ai/ConversationAgent.js +404 -0
- package/dist/src/ai/ConversationFlinkAgent.d.ts +278 -0
- package/dist/src/ai/ConversationFlinkAgent.js +404 -0
- package/dist/src/ai/FlinkAgent.d.ts +690 -0
- package/dist/src/ai/FlinkAgent.js +729 -0
- package/dist/src/ai/FlinkTool.d.ts +135 -0
- package/dist/src/ai/FlinkTool.js +2 -0
- package/dist/src/ai/InMemoryConversationAgent.d.ts +121 -0
- package/dist/src/ai/InMemoryConversationAgent.js +209 -0
- package/dist/src/ai/LLMAdapter.d.ts +148 -0
- package/dist/src/ai/LLMAdapter.js +2 -0
- package/dist/src/ai/PersistentFlinkAgent.d.ts +278 -0
- package/dist/src/ai/PersistentFlinkAgent.js +403 -0
- package/dist/src/ai/SubAgentExecutor.d.ts +38 -0
- package/dist/src/ai/SubAgentExecutor.js +223 -0
- package/dist/src/ai/ToolExecutor.d.ts +64 -0
- package/dist/src/ai/ToolExecutor.js +497 -0
- package/dist/src/ai/agentInstructions.d.ts +68 -0
- package/dist/src/ai/agentInstructions.js +286 -0
- package/dist/src/ai/index.d.ts +8 -0
- package/dist/src/ai/index.js +26 -0
- package/dist/src/ai/instructionFileLoader.d.ts +44 -0
- package/dist/src/ai/instructionFileLoader.js +179 -0
- package/dist/src/auth/FlinkAuthPlugin.d.ts +1 -1
- package/dist/src/handlers/StreamWriterFactory.d.ts +20 -0
- package/dist/src/handlers/StreamWriterFactory.js +83 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +17 -0
- package/dist/src/loadPluginSchemas.d.ts +45 -0
- package/dist/src/loadPluginSchemas.js +143 -0
- package/dist/src/schema-extraction/ComplexTypeDetection.d.ts +40 -0
- package/dist/src/schema-extraction/ComplexTypeDetection.js +75 -0
- package/dist/src/schema-extraction/TypeScriptSourceParser.d.ts +321 -0
- package/dist/src/schema-extraction/TypeScriptSourceParser.js +925 -0
- package/dist/src/schema-extraction/TypeScriptSourceParser.spec.d.ts +1 -0
- package/dist/src/schema-extraction/TypeScriptSourceParser.spec.js +233 -0
- package/dist/src/schema-extraction/TypeScriptTokenizer.d.ts +57 -0
- package/dist/src/schema-extraction/TypeScriptTokenizer.js +177 -0
- package/dist/src/schema-extraction/index.d.ts +2 -0
- package/dist/src/schema-extraction/index.js +20 -0
- package/dist/src/schema-extraction/types.d.ts +31 -0
- package/dist/src/schema-extraction/types.js +2 -0
- package/dist/src/utils/loadFlinkConfig.d.ts +53 -0
- package/dist/src/utils/loadFlinkConfig.js +77 -0
- package/dist/src/utils.d.ts +30 -0
- package/dist/src/utils.js +52 -0
- package/dist/src/workers/SchemaGeneratorWorker.d.ts +1 -0
- package/dist/src/workers/SchemaGeneratorWorker.js +49 -0
- package/dist/src/workers/WorkerPool.d.ts +60 -0
- package/dist/src/workers/WorkerPool.js +306 -0
- package/examples/logging-hierarchical-example.ts +125 -0
- package/package.json +29 -4
- package/readme.md +499 -0
- package/spec/AgentDescendantDetection.spec.ts +335 -0
- package/spec/AgentDuplicateDetection.spec.ts +112 -0
- package/spec/AgentObserver.spec.ts +266 -0
- package/spec/AgentRunner.spec.ts +1062 -0
- package/spec/AsyncLocalStorageContext.spec.ts +223 -0
- package/spec/ConversationHooks.spec.ts +257 -0
- package/spec/FlinkAgent.spec.ts +681 -0
- package/spec/FlinkApp.htmlResponse.spec.ts +260 -0
- package/spec/FlinkApp.onError.invocation.spec.ts +151 -0
- package/spec/FlinkApp.onError.spec.ts +1 -2
- package/spec/FlinkApp.query.spec.ts +107 -0
- package/spec/FlinkApp.routeOrdering.spec.ts +61 -0
- package/spec/FlinkApp.undefinedResponse.spec.ts +123 -0
- package/spec/FlinkApp.validationMode.spec.ts +155 -0
- package/spec/FlinkJob.spec.ts +171 -0
- package/spec/FlinkLogFactory.spec.ts +337 -0
- package/spec/FlinkRepo.spec.ts +1 -1
- package/spec/LeaderElection.spec.ts +174 -0
- package/spec/StreamingIntegration.spec.ts +139 -0
- package/spec/ToolExecutor.spec.ts +465 -0
- package/spec/TypeScriptCompiler.spec.ts +1 -1
- package/spec/TypeScriptSourceParser.spec.ts +1215 -0
- package/spec/TypeScriptTokenizer.spec.ts +366 -0
- package/spec/ai/ContextCompaction.spec.ts +405 -0
- package/spec/ai/ConversationAgent.spec.ts +520 -0
- package/spec/ai/InMemoryConversationAgent.spec.ts +144 -0
- package/spec/ai/agentInstructions.spec.ts +358 -0
- package/spec/fixtures/agent-instructions/TestAgent.ts +24 -0
- package/spec/fixtures/agent-instructions/simple.md +3 -0
- package/spec/fixtures/agent-instructions/template.md +18 -0
- package/spec/fixtures/agent-instructions/yaml-format.yaml +9 -0
- package/spec/mock-project/dist/.tsbuildinfo +1 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar.js +56 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCar2.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema.js +52 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema2.js +52 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithArraySchema3.js +52 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema.js +54 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithLiteralSchema2.js +54 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile.js +57 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/GetCarWithSchemaInFile2.js +57 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler.js +53 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/ManuallyAddedHandler2.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchCar.js +57 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOnboardingSession.js +75 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchOrderWithComplexTypes.js +57 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchProductWithIntersection.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PatchUserWithUnion.js +58 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PostCar.js +54 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogin.js +55 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PostLogout.js +54 -0
- package/spec/mock-project/dist/spec/mock-project/src/handlers/PutCar.js +54 -0
- package/spec/mock-project/dist/spec/mock-project/src/index.js +83 -0
- package/spec/mock-project/dist/spec/mock-project/src/repos/CarRepo.js +26 -0
- package/spec/mock-project/dist/spec/mock-project/src/schemas/Car.js +2 -0
- package/spec/mock-project/dist/spec/mock-project/src/schemas/DefaultExportSchema.js +2 -0
- package/spec/mock-project/dist/spec/mock-project/src/schemas/FileWithTwoSchemas.js +2 -0
- package/spec/mock-project/dist/src/FlinkApp.js +1000 -0
- package/spec/mock-project/dist/src/FlinkContext.js +2 -0
- package/spec/mock-project/dist/src/FlinkErrors.js +143 -0
- package/spec/mock-project/dist/src/FlinkHttpHandler.js +47 -0
- package/spec/mock-project/dist/src/FlinkJob.js +2 -0
- package/spec/mock-project/dist/src/FlinkLog.js +119 -0
- package/spec/mock-project/dist/src/FlinkLogFactory.js +617 -0
- package/spec/mock-project/dist/src/FlinkPlugin.js +2 -0
- package/spec/mock-project/dist/src/FlinkRepo.js +224 -0
- package/spec/mock-project/dist/src/FlinkRequestContext.js +74 -0
- package/spec/mock-project/dist/src/FlinkResponse.js +2 -0
- package/spec/mock-project/dist/src/ai/AgentExecutor.js +279 -0
- package/spec/mock-project/dist/src/ai/AgentRunner.js +632 -0
- package/spec/mock-project/dist/src/ai/ConversationAgent.js +402 -0
- package/spec/mock-project/dist/src/ai/ConversationFlinkAgent.js +422 -0
- package/spec/mock-project/dist/src/ai/FlinkAgent.js +699 -0
- package/spec/mock-project/dist/src/ai/FlinkTool.js +2 -0
- package/spec/mock-project/dist/src/ai/InMemoryConversationAgent.js +209 -0
- package/spec/mock-project/dist/src/ai/LLMAdapter.js +2 -0
- package/spec/mock-project/dist/src/ai/SubAgentExecutor.js +223 -0
- package/spec/mock-project/dist/src/ai/ToolExecutor.js +412 -0
- package/spec/mock-project/dist/src/ai/agentInstructions.js +246 -0
- package/spec/mock-project/dist/src/auth/FlinkAuthPlugin.js +2 -0
- package/spec/mock-project/dist/src/auth/FlinkAuthUser.js +2 -0
- package/spec/mock-project/dist/src/handlers/GetCar.js +26 -52
- package/spec/mock-project/dist/src/handlers/GetCar.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCar2.js +32 -54
- package/spec/mock-project/dist/src/handlers/GetCar2.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema.js +26 -48
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema2.js +28 -48
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema2.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema3.js +29 -48
- package/spec/mock-project/dist/src/handlers/GetCarWithArraySchema3.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema.js +26 -50
- package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema2.js +28 -50
- package/spec/mock-project/dist/src/handlers/GetCarWithLiteralSchema2.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile.js +27 -53
- package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile2.js +29 -53
- package/spec/mock-project/dist/src/handlers/GetCarWithSchemaInFile2.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler.js +16 -49
- package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler2.js +25 -50
- package/spec/mock-project/dist/src/handlers/ManuallyAddedHandler2.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PatchCar.js +27 -53
- package/spec/mock-project/dist/src/handlers/PatchCar.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PatchOnboardingSession.js +44 -70
- package/spec/mock-project/dist/src/handlers/PatchOnboardingSession.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PatchOrderWithComplexTypes.js +27 -53
- package/spec/mock-project/dist/src/handlers/PatchOrderWithComplexTypes.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PatchProductWithIntersection.js +28 -54
- package/spec/mock-project/dist/src/handlers/PatchProductWithIntersection.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PatchUserWithUnion.js +28 -54
- package/spec/mock-project/dist/src/handlers/PatchUserWithUnion.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PostCar.js +24 -50
- package/spec/mock-project/dist/src/handlers/PostCar.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PostLogin.js +25 -51
- package/spec/mock-project/dist/src/handlers/PostLogin.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PostLogout.js +24 -50
- package/spec/mock-project/dist/src/handlers/PostLogout.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/PutCar.js +24 -50
- package/spec/mock-project/dist/src/handlers/PutCar.js.map +1 -0
- package/spec/mock-project/dist/src/handlers/StreamWriterFactory.js +83 -0
- package/spec/mock-project/dist/src/index.js +52 -76
- package/spec/mock-project/dist/src/index.js.map +1 -0
- package/spec/mock-project/dist/src/mock-data-generator.js +9 -0
- package/spec/mock-project/dist/src/repos/CarRepo.js +12 -24
- package/spec/mock-project/dist/src/repos/CarRepo.js.map +1 -0
- package/spec/mock-project/dist/src/schemas/Car.js +3 -1
- package/spec/mock-project/dist/src/schemas/Car.js.map +1 -0
- package/spec/mock-project/dist/src/schemas/DefaultExportSchema.js +3 -1
- package/spec/mock-project/dist/src/schemas/DefaultExportSchema.js.map +1 -0
- package/spec/mock-project/dist/src/schemas/FileWithTwoSchemas.js +3 -1
- package/spec/mock-project/dist/src/schemas/FileWithTwoSchemas.js.map +1 -0
- package/spec/mock-project/dist/src/utils.js +290 -0
- package/spec/mock-project/tsconfig.json +6 -1
- package/spec/schema-generation-nested-objects.spec.ts +97 -0
- package/spec/testHelpers.ts +49 -0
- package/spec/utils.caseConversion.spec.ts +78 -0
- package/spec/utils.spec.ts +13 -13
- package/src/DependencyTracker.ts +166 -0
- package/src/FlinkApp.ts +919 -155
- package/src/FlinkContext.ts +43 -0
- package/src/FlinkErrors.ts +32 -12
- package/src/FlinkHttpHandler.ts +246 -28
- package/src/FlinkJob.ts +11 -0
- package/src/FlinkLog.ts +119 -12
- package/src/FlinkLogFactory.ts +699 -0
- package/src/FlinkRepo.ts +10 -3
- package/src/FlinkRequestContext.ts +95 -0
- package/src/FlinkResponse.ts +6 -0
- package/src/FlinkService.ts +49 -0
- package/src/LeaderElection.ts +203 -0
- package/src/SchemaCache.ts +232 -0
- package/src/TypeScriptCompiler.ts +1347 -610
- package/src/TypeScriptUtils.ts +5 -0
- package/src/ai/AgentRunner.ts +646 -0
- package/src/ai/ConversationAgent.ts +413 -0
- package/src/ai/FlinkAgent.ts +1069 -0
- package/src/ai/FlinkTool.ts +165 -0
- package/src/ai/InMemoryConversationAgent.ts +149 -0
- package/src/ai/LLMAdapter.ts +126 -0
- package/src/ai/ToolExecutor.ts +485 -0
- package/src/ai/agentInstructions.ts +245 -0
- package/src/ai/index.ts +8 -0
- package/src/ai/instructionFileLoader.ts +156 -0
- package/src/auth/FlinkAuthPlugin.ts +2 -1
- package/src/handlers/StreamWriterFactory.ts +84 -0
- package/src/index.ts +14 -0
- package/src/loadPluginSchemas.ts +141 -0
- package/src/schema-extraction/TypeScriptSourceParser.ts +1058 -0
- package/src/schema-extraction/TypeScriptTokenizer.ts +205 -0
- package/src/schema-extraction/index.ts +2 -0
- package/src/schema-extraction/types.ts +34 -0
- package/src/utils/loadFlinkConfig.ts +89 -0
- package/src/utils.ts +52 -0
- package/tsconfig.json +6 -1
package/cli/run.ts
CHANGED
|
@@ -1,83 +1,66 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import
|
|
2
|
+
import { parseArgs, hasFlag, getOption, normalizeEntry, printHelp, compile, forkApp } from "./cli-utils";
|
|
3
|
+
import { FlinkLogFactory } from "../src/FlinkLogFactory";
|
|
4
|
+
import { loadFlinkConfig } from "../src/utils/loadFlinkConfig";
|
|
5
|
+
import { loadEnvFiles } from "./loadEnvFiles";
|
|
3
6
|
|
|
4
|
-
|
|
5
|
-
|
|
7
|
+
// Load config BEFORE creating logger
|
|
8
|
+
const flinkConfig = loadFlinkConfig();
|
|
9
|
+
FlinkLogFactory.configure(flinkConfig?.logging);
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Description
|
|
10
|
-
Compiles and starts the application.
|
|
11
|
+
module.exports = async function run(args: string[]) {
|
|
12
|
+
const parsed = parseArgs(args);
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
// Load .env files before anything else so all env vars are available at startup.
|
|
15
|
+
// NODE_ENV defaults to "production" when not explicitly set.
|
|
16
|
+
if (!process.env.NODE_ENV) {
|
|
17
|
+
process.env.NODE_ENV = "production";
|
|
18
|
+
}
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Options
|
|
19
|
-
--entry Entry script for app, default "/src/index.ts"
|
|
20
|
-
--help Displays this message
|
|
21
|
-
--precompiled Will run a precompiled app, default false
|
|
22
|
-
`);
|
|
20
|
+
const initLogger = FlinkLogFactory.createLogger("flink.init");
|
|
21
|
+
const { loaded, injected } = loadEnvFiles(parsed.dir, "production");
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
if (loaded.length > 0) {
|
|
24
|
+
initLogger.info(`Loaded env files: ${loaded.join(", ")} (${injected} vars injected)`);
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
if (hasFlag(parsed, "help")) {
|
|
28
|
+
printHelp({
|
|
29
|
+
description: "Compiles and starts the application.",
|
|
30
|
+
usage: "$ flink run <dir>",
|
|
31
|
+
options: [
|
|
32
|
+
{ name: "entry", description: 'Entry script for app, default "/src/index.ts"' },
|
|
33
|
+
{ name: "help", description: "Displays this message" },
|
|
34
|
+
{ name: "precompiled", description: "Will run a precompiled app, default false" },
|
|
35
|
+
],
|
|
36
|
+
});
|
|
37
|
+
return;
|
|
30
38
|
}
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
if (args.includes("--entry")) {
|
|
34
|
-
entry = args[args.indexOf("--entry") + 1];
|
|
35
|
-
entry = entry.startsWith("/") ? entry : "/" + entry;
|
|
36
|
-
}
|
|
40
|
+
const entry = normalizeEntry(getOption(parsed, "entry", "/src/index.ts"));
|
|
37
41
|
|
|
38
|
-
if (
|
|
39
|
-
if (
|
|
42
|
+
if (hasFlag(parsed, "precompiled")) {
|
|
43
|
+
if (parsed.options.has("entry")) {
|
|
40
44
|
console.warn("WARNING: --entry is ignored when using --precompiled");
|
|
41
45
|
}
|
|
42
46
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
arg !== args[args.indexOf("--entry") + 1]
|
|
48
|
-
).filter(arg => arg !== args[0] || args[0].startsWith("--"));
|
|
49
|
-
|
|
50
|
-
const forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs);
|
|
51
|
-
|
|
52
|
-
forkedProcess.on("exit", (code: any) => {
|
|
53
|
-
process.exit(code);
|
|
47
|
+
forkApp({
|
|
48
|
+
dir: parsed.dir,
|
|
49
|
+
args,
|
|
50
|
+
cliFlags: ["precompiled", "entry"],
|
|
54
51
|
});
|
|
55
52
|
return;
|
|
56
53
|
}
|
|
57
54
|
|
|
58
|
-
await
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
process.exit(1);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
await Promise.all([compiler.parseRepos(), compiler.parseHandlers(), compiler.parseJobs(), compiler.generateStartScript(entry)]);
|
|
67
|
-
|
|
68
|
-
console.log(`Compilation done, took ${Date.now() - startTime}ms`);
|
|
69
|
-
|
|
70
|
-
compiler.emit();
|
|
71
|
-
|
|
72
|
-
// Collect extra arguments to pass through to the forked process
|
|
73
|
-
const extraArgs = args.filter(arg =>
|
|
74
|
-
!arg.startsWith("--entry") &&
|
|
75
|
-
arg !== args[args.indexOf("--entry") + 1]
|
|
76
|
-
).filter(arg => arg !== args[0] || args[0].startsWith("--"));
|
|
77
|
-
|
|
78
|
-
const forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs);
|
|
55
|
+
await compile({
|
|
56
|
+
dir: parsed.dir,
|
|
57
|
+
entry,
|
|
58
|
+
typeCheck: true,
|
|
59
|
+
});
|
|
79
60
|
|
|
80
|
-
|
|
81
|
-
|
|
61
|
+
forkApp({
|
|
62
|
+
dir: parsed.dir,
|
|
63
|
+
args,
|
|
64
|
+
cliFlags: ["entry"],
|
|
82
65
|
});
|
|
83
66
|
};
|
package/dist/bin/flink.js
CHANGED
|
@@ -1,7 +1,43 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
13
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
14
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
15
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
16
|
+
function step(op) {
|
|
17
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
18
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
19
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
20
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
21
|
+
switch (op[0]) {
|
|
22
|
+
case 0: case 1: t = op; break;
|
|
23
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
24
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
25
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
26
|
+
default:
|
|
27
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
28
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
29
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
30
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
31
|
+
if (t[2]) _.ops.pop();
|
|
32
|
+
_.trys.pop(); continue;
|
|
33
|
+
}
|
|
34
|
+
op = body.call(thisArg, _);
|
|
35
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
36
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
|
+
}
|
|
38
|
+
};
|
|
3
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
var commands = ["build", "generate" /* 'generate' is alias for 'build'
|
|
40
|
+
var commands = ["build", "generate" /* 'generate' is alias for 'build' */, "run", "dev", "clean", "help"];
|
|
5
41
|
var argv = process.argv.slice(2);
|
|
6
42
|
var argCommand = argv[0];
|
|
7
43
|
if (!argCommand || argv[0] === "help") {
|
|
@@ -16,5 +52,28 @@ if (argCommand === "generate") {
|
|
|
16
52
|
argCommand = "build";
|
|
17
53
|
}
|
|
18
54
|
var cmd = require("../cli/" + argCommand);
|
|
19
|
-
|
|
55
|
+
(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var error_1;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
_a.trys.push([0, 2, , 3]);
|
|
61
|
+
return [4 /*yield*/, cmd(argv.slice(1))];
|
|
62
|
+
case 1:
|
|
63
|
+
_a.sent();
|
|
64
|
+
return [3 /*break*/, 3];
|
|
65
|
+
case 2:
|
|
66
|
+
error_1 = _a.sent();
|
|
67
|
+
if (process.env.DEBUG === "true") {
|
|
68
|
+
console.error(error_1);
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
console.error("Error: ".concat(error_1.message));
|
|
72
|
+
}
|
|
73
|
+
process.exit(1);
|
|
74
|
+
return [3 /*break*/, 3];
|
|
75
|
+
case 3: return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); })();
|
|
20
79
|
exports.default = (function () { });
|
package/dist/cli/build.js
CHANGED
|
@@ -36,40 +36,35 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
var TypeScriptCompiler_1 = __importDefault(require("../src/TypeScriptCompiler"));
|
|
44
40
|
var cli_utils_1 = require("./cli-utils");
|
|
45
|
-
|
|
41
|
+
var FlinkLogFactory_1 = require("../src/FlinkLogFactory");
|
|
42
|
+
var loadFlinkConfig_1 = require("../src/utils/loadFlinkConfig");
|
|
43
|
+
// Load config BEFORE creating logger
|
|
44
|
+
var flinkConfig = (0, loadFlinkConfig_1.loadFlinkConfig)();
|
|
45
|
+
FlinkLogFactory_1.FlinkLogFactory.configure(flinkConfig === null || flinkConfig === void 0 ? void 0 : flinkConfig.logging);
|
|
46
|
+
module.exports = function build(args) {
|
|
46
47
|
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
-
var
|
|
48
|
+
var parsed;
|
|
48
49
|
return __generator(this, function (_a) {
|
|
49
50
|
switch (_a.label) {
|
|
50
51
|
case 0:
|
|
51
|
-
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
parsed = (0, cli_utils_1.parseArgs)(args);
|
|
53
|
+
if ((0, cli_utils_1.hasFlag)(parsed, "help")) {
|
|
54
|
+
(0, cli_utils_1.printHelp)({
|
|
55
|
+
description: "Builds the application.\n Will generate intermediates files in .flink and compile/transpile\n javascript bundle in /dist folder",
|
|
56
|
+
usage: "$ flink build <dir>",
|
|
57
|
+
options: [{ name: "help", description: "Displays this message" }],
|
|
58
|
+
});
|
|
59
|
+
return [2 /*return*/];
|
|
59
60
|
}
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
return [4 /*yield*/, (0, cli_utils_1.compile)({
|
|
62
|
+
dir: parsed.dir,
|
|
63
|
+
typeCheck: true,
|
|
64
|
+
timingLogs: true,
|
|
65
|
+
})];
|
|
62
66
|
case 1:
|
|
63
67
|
_a.sent();
|
|
64
|
-
compiler = new TypeScriptCompiler_1.default(dir);
|
|
65
|
-
if (!compiler.getPreEmitDiagnostics()) {
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
return [4 /*yield*/, Promise.all([compiler.parseRepos(), compiler.parseHandlers(exclude.split(",")), compiler.parseJobs(), compiler.generateStartScript()])];
|
|
69
|
-
case 2:
|
|
70
|
-
_a.sent();
|
|
71
|
-
console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
|
|
72
|
-
compiler.emit();
|
|
73
68
|
return [2 /*return*/];
|
|
74
69
|
}
|
|
75
70
|
});
|
package/dist/cli/clean.js
CHANGED
|
@@ -41,21 +41,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
43
|
var TypeScriptCompiler_1 = __importDefault(require("../src/TypeScriptCompiler"));
|
|
44
|
-
|
|
44
|
+
var cli_utils_1 = require("./cli-utils");
|
|
45
|
+
module.exports = function clean(args) {
|
|
45
46
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var
|
|
47
|
+
var parsed, cleanedFolder;
|
|
47
48
|
return __generator(this, function (_a) {
|
|
48
49
|
switch (_a.label) {
|
|
49
50
|
case 0:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
parsed = (0, cli_utils_1.parseArgs)(args);
|
|
52
|
+
if ((0, cli_utils_1.hasFlag)(parsed, "help")) {
|
|
53
|
+
(0, cli_utils_1.printHelp)({
|
|
54
|
+
description: "Removes all generated files.",
|
|
55
|
+
usage: "$ flink clean <dir>",
|
|
56
|
+
options: [{ name: "help", description: "Displays this message" }],
|
|
57
|
+
});
|
|
58
|
+
return [2 /*return*/];
|
|
53
59
|
}
|
|
54
|
-
|
|
55
|
-
if (args[0] && !args[0].startsWith("--")) {
|
|
56
|
-
dir = args[0];
|
|
57
|
-
}
|
|
58
|
-
return [4 /*yield*/, TypeScriptCompiler_1.default.clean(dir)];
|
|
60
|
+
return [4 /*yield*/, TypeScriptCompiler_1.default.clean(parsed.dir)];
|
|
59
61
|
case 1:
|
|
60
62
|
cleanedFolder = _a.sent();
|
|
61
63
|
console.log("Cleaned directory ".concat(cleanedFolder));
|
package/dist/cli/cli-utils.d.ts
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export interface ParsedArgs {
|
|
2
|
+
dir: string;
|
|
3
|
+
flags: Set<string>;
|
|
4
|
+
options: Map<string, string>;
|
|
5
|
+
}
|
|
6
|
+
export declare function parseArgs(args: string[]): ParsedArgs;
|
|
7
|
+
export declare function hasFlag(parsed: ParsedArgs, name: string): boolean;
|
|
8
|
+
export declare function getOption(parsed: ParsedArgs, name: string, defaultValue: string): string;
|
|
9
|
+
export declare function normalizeEntry(entry: string): string;
|
|
10
|
+
interface HelpOption {
|
|
11
|
+
name: string;
|
|
12
|
+
description: string;
|
|
13
|
+
}
|
|
14
|
+
interface HelpConfig {
|
|
15
|
+
description: string;
|
|
16
|
+
usage: string;
|
|
17
|
+
options: HelpOption[];
|
|
18
|
+
}
|
|
19
|
+
export declare function printHelp(config: HelpConfig): void;
|
|
20
|
+
export interface CompileOptions {
|
|
21
|
+
dir: string;
|
|
22
|
+
entry?: string;
|
|
23
|
+
typeCheck?: boolean;
|
|
24
|
+
timingLogs?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function compile(opts: CompileOptions): Promise<void>;
|
|
27
|
+
export interface ForkOptions {
|
|
28
|
+
dir: string;
|
|
29
|
+
args: string[];
|
|
30
|
+
cliFlags: string[];
|
|
31
|
+
stdio?: "inherit" | "pipe" | "ignore";
|
|
32
|
+
}
|
|
33
|
+
export declare function forkApp(opts: ForkOptions): ReturnType<typeof require>;
|
|
34
|
+
export {};
|
package/dist/cli/cli-utils.js
CHANGED
|
@@ -1,19 +1,200 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
2
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.parseArgs = parseArgs;
|
|
43
|
+
exports.hasFlag = hasFlag;
|
|
3
44
|
exports.getOption = getOption;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
45
|
+
exports.normalizeEntry = normalizeEntry;
|
|
46
|
+
exports.printHelp = printHelp;
|
|
47
|
+
exports.compile = compile;
|
|
48
|
+
exports.forkApp = forkApp;
|
|
49
|
+
var TypeScriptCompiler_1 = __importDefault(require("../src/TypeScriptCompiler"));
|
|
50
|
+
function parseArgs(args) {
|
|
51
|
+
var flags = new Set();
|
|
52
|
+
var options = new Map();
|
|
53
|
+
var dir = "./";
|
|
54
|
+
var i = 0;
|
|
55
|
+
// First non-flag arg is the directory
|
|
56
|
+
if (args[0] && !args[0].startsWith("--")) {
|
|
57
|
+
dir = args[0];
|
|
58
|
+
i = 1;
|
|
59
|
+
}
|
|
60
|
+
while (i < args.length) {
|
|
61
|
+
var arg = args[i];
|
|
62
|
+
if (arg.startsWith("--")) {
|
|
63
|
+
var name = arg.slice(2);
|
|
64
|
+
var next = args[i + 1];
|
|
65
|
+
if (next && !next.startsWith("--")) {
|
|
66
|
+
options.set(name, next);
|
|
67
|
+
i += 2;
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
flags.add(name);
|
|
71
|
+
i += 1;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
i += 1;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return { dir: dir, flags: flags, options: options };
|
|
79
|
+
}
|
|
80
|
+
function hasFlag(parsed, name) {
|
|
81
|
+
return parsed.flags.has(name);
|
|
82
|
+
}
|
|
83
|
+
function getOption(parsed, name, defaultValue) {
|
|
84
|
+
var _a;
|
|
85
|
+
return (_a = parsed.options.get(name)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
86
|
+
}
|
|
87
|
+
function normalizeEntry(entry) {
|
|
88
|
+
return entry.startsWith("/") ? entry : "/" + entry;
|
|
89
|
+
}
|
|
90
|
+
function printHelp(config) {
|
|
91
|
+
var optionLines = config.options
|
|
92
|
+
.map(function (opt) { return " --".concat(opt.name.padEnd(14), " ").concat(opt.description); })
|
|
93
|
+
.join("\n");
|
|
94
|
+
console.log("\n Description\n ".concat(config.description, "\n\n Usage\n ").concat(config.usage, "\n\n <dir> represents the directory of the Flink application.\n If no directory is provided, the current directory will be used.\n\n Options\n").concat(optionLines, "\n"));
|
|
95
|
+
}
|
|
96
|
+
function compile(opts) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var dir, entry, _a, typeCheck, _b, timingLogs, start, time, stepStart, compiler;
|
|
99
|
+
return __generator(this, function (_c) {
|
|
100
|
+
switch (_c.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
dir = opts.dir, entry = opts.entry, _a = opts.typeCheck, typeCheck = _a === void 0 ? true : _a, _b = opts.timingLogs, timingLogs = _b === void 0 ? false : _b;
|
|
103
|
+
start = timingLogs ? Date.now() : 0;
|
|
104
|
+
time = function (label, stepStart) {
|
|
105
|
+
if (timingLogs) {
|
|
106
|
+
console.log("\u23F1\uFE0F ".concat(label, ": ").concat(Date.now() - stepStart, "ms"));
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return [4 /*yield*/, TypeScriptCompiler_1.default.clean(dir)];
|
|
110
|
+
case 1:
|
|
111
|
+
_c.sent();
|
|
112
|
+
stepStart = Date.now();
|
|
113
|
+
compiler = new TypeScriptCompiler_1.default(dir);
|
|
114
|
+
time("Compiler initialization", stepStart);
|
|
115
|
+
stepStart = Date.now();
|
|
116
|
+
return [4 /*yield*/, compiler.parseRepos()];
|
|
117
|
+
case 2:
|
|
118
|
+
_c.sent();
|
|
119
|
+
return [4 /*yield*/, compiler.parseTools()];
|
|
120
|
+
case 3:
|
|
121
|
+
_c.sent();
|
|
122
|
+
return [4 /*yield*/, compiler.parseAgents()];
|
|
123
|
+
case 4:
|
|
124
|
+
_c.sent();
|
|
125
|
+
return [4 /*yield*/, compiler.parseJobs()];
|
|
126
|
+
case 5:
|
|
127
|
+
_c.sent();
|
|
128
|
+
return [4 /*yield*/, compiler.parseServices()];
|
|
129
|
+
case 6:
|
|
130
|
+
_c.sent();
|
|
131
|
+
return [4 /*yield*/, compiler.parseAllExtensionDirs()];
|
|
132
|
+
case 7:
|
|
133
|
+
_c.sent();
|
|
134
|
+
return [4 /*yield*/, compiler.parseHandlers()];
|
|
135
|
+
case 8:
|
|
136
|
+
_c.sent();
|
|
137
|
+
return [4 /*yield*/, compiler.generateStartScript(entry)];
|
|
138
|
+
case 9:
|
|
139
|
+
_c.sent();
|
|
140
|
+
return [4 /*yield*/, compiler.generateAllSchemas()];
|
|
141
|
+
case 10:
|
|
142
|
+
_c.sent();
|
|
143
|
+
return [4 /*yield*/, compiler.saveAllModifiedFiles()];
|
|
144
|
+
case 11:
|
|
145
|
+
_c.sent();
|
|
146
|
+
if (typeCheck) {
|
|
147
|
+
stepStart = Date.now();
|
|
148
|
+
if (!compiler.getPreEmitDiagnostics()) {
|
|
149
|
+
throw new Error("Type checking failed");
|
|
150
|
+
}
|
|
151
|
+
time("Type checking (getPreEmitDiagnostics)", stepStart);
|
|
152
|
+
}
|
|
153
|
+
stepStart = Date.now();
|
|
154
|
+
if (!(process.env.FLINK_USE_TSC === "true")) return [3 /*break*/, 12];
|
|
155
|
+
compiler.emitWithTsc();
|
|
156
|
+
return [3 /*break*/, 14];
|
|
157
|
+
case 12: return [4 /*yield*/, compiler.emit()];
|
|
158
|
+
case 13:
|
|
159
|
+
_c.sent();
|
|
160
|
+
_c.label = 14;
|
|
161
|
+
case 14:
|
|
162
|
+
time("Transpilation (".concat(process.env.FLINK_USE_TSC === "true" ? "tsc" : "swc", ")"), stepStart);
|
|
163
|
+
if (timingLogs) {
|
|
164
|
+
console.log("Compilation done in ".concat(Date.now() - start, "ms"));
|
|
165
|
+
}
|
|
166
|
+
return [2 /*return*/];
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function forkApp(opts) {
|
|
172
|
+
var dir = opts.dir, args = opts.args, cliFlags = opts.cliFlags, stdio = opts.stdio;
|
|
173
|
+
// Filter out CLI-specific flags and their values from args passed to child process
|
|
174
|
+
var cliSet = new Set(cliFlags.map(function (f) { return "--".concat(f); }));
|
|
175
|
+
var extraArgs = [];
|
|
176
|
+
for (var i = 0; i < args.length; i++) {
|
|
177
|
+
if (cliSet.has(args[i])) {
|
|
178
|
+
// Skip this flag and its value (if the next arg is not a flag)
|
|
179
|
+
var next = args[i + 1];
|
|
180
|
+
if (next && !next.startsWith("--")) {
|
|
181
|
+
i++; // skip value too
|
|
182
|
+
}
|
|
183
|
+
continue;
|
|
10
184
|
}
|
|
11
|
-
|
|
12
|
-
if (
|
|
13
|
-
|
|
14
|
-
process.exit(1);
|
|
185
|
+
// Skip the dir argument (first non-flag arg)
|
|
186
|
+
if (i === 0 && !args[i].startsWith("--")) {
|
|
187
|
+
continue;
|
|
15
188
|
}
|
|
16
|
-
|
|
189
|
+
extraArgs.push(args[i]);
|
|
190
|
+
}
|
|
191
|
+
var forkOpts = {};
|
|
192
|
+
if (stdio) {
|
|
193
|
+
forkOpts.stdio = stdio;
|
|
17
194
|
}
|
|
18
|
-
|
|
195
|
+
var forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs, forkOpts);
|
|
196
|
+
forkedProcess.on("exit", function (code) {
|
|
197
|
+
process.exit(code);
|
|
198
|
+
});
|
|
199
|
+
return forkedProcess;
|
|
19
200
|
}
|