@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/dist/cli/dev.js
ADDED
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
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
|
+
};
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
var chokidar_1 = __importDefault(require("chokidar"));
|
|
44
|
+
var child_process_1 = require("child_process");
|
|
45
|
+
var path_1 = require("path");
|
|
46
|
+
var fs_1 = require("fs");
|
|
47
|
+
var cli_utils_1 = require("./cli-utils");
|
|
48
|
+
var FlinkLogFactory_1 = require("../src/FlinkLogFactory");
|
|
49
|
+
var loadFlinkConfig_1 = require("../src/utils/loadFlinkConfig");
|
|
50
|
+
var loadEnvFiles_1 = require("./loadEnvFiles");
|
|
51
|
+
// Load config BEFORE creating logger
|
|
52
|
+
var flinkConfig = (0, loadFlinkConfig_1.loadFlinkConfig)();
|
|
53
|
+
FlinkLogFactory_1.FlinkLogFactory.configure(flinkConfig === null || flinkConfig === void 0 ? void 0 : flinkConfig.logging);
|
|
54
|
+
var logger = FlinkLogFactory_1.FlinkLogFactory.createLogger("flink.dev");
|
|
55
|
+
module.exports = function dev(args) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
var parsed, initLogger, _a, loaded, injected, dir, entry, typecheck, noTypecheck, serverProcess, tscProcess, isRebuilding, pendingRebuild, watcher;
|
|
58
|
+
var _this = this;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
switch (_b.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
parsed = (0, cli_utils_1.parseArgs)(args);
|
|
63
|
+
// Load .env files before anything else so all env vars are available at startup.
|
|
64
|
+
// NODE_ENV defaults to "development" when not explicitly set.
|
|
65
|
+
if (!process.env.NODE_ENV) {
|
|
66
|
+
process.env.NODE_ENV = "development";
|
|
67
|
+
}
|
|
68
|
+
initLogger = FlinkLogFactory_1.FlinkLogFactory.createLogger("flink.init");
|
|
69
|
+
_a = (0, loadEnvFiles_1.loadEnvFiles)(parsed.dir, "development"), loaded = _a.loaded, injected = _a.injected;
|
|
70
|
+
if (loaded.length > 0) {
|
|
71
|
+
initLogger.info("Loaded env files: ".concat(loaded.join(", "), " (").concat(injected, " vars injected)"));
|
|
72
|
+
}
|
|
73
|
+
if ((0, cli_utils_1.hasFlag)(parsed, "help")) {
|
|
74
|
+
(0, cli_utils_1.printHelp)({
|
|
75
|
+
description: "Starts development mode with watch and auto-reload.\n Fast rebuilds with swc (skips type checking by default).\n Runs background tsc --watch for async type error reporting.",
|
|
76
|
+
usage: "$ flink dev <dir>",
|
|
77
|
+
options: [
|
|
78
|
+
{ name: "typecheck", description: "Run type checking on every rebuild (slower, disables background tsc)" },
|
|
79
|
+
{ name: "no-typecheck", description: "Disable background type checking entirely" },
|
|
80
|
+
{ name: "entry", description: 'Entry script for app, default "/src/index.ts"' },
|
|
81
|
+
{ name: "help", description: "Displays this message" },
|
|
82
|
+
],
|
|
83
|
+
});
|
|
84
|
+
return [2 /*return*/];
|
|
85
|
+
}
|
|
86
|
+
dir = parsed.dir;
|
|
87
|
+
entry = (0, cli_utils_1.normalizeEntry)((0, cli_utils_1.getOption)(parsed, "entry", "/src/index.ts"));
|
|
88
|
+
typecheck = (0, cli_utils_1.hasFlag)(parsed, "typecheck");
|
|
89
|
+
noTypecheck = (0, cli_utils_1.hasFlag)(parsed, "no-typecheck");
|
|
90
|
+
console.log("🚀 Flink dev mode starting...\n");
|
|
91
|
+
// Initial build (skip type checking for speed unless --typecheck flag)
|
|
92
|
+
console.log("\uD83D\uDCE6 Initial build ".concat(typecheck ? "(with type checking)" : "(fast mode, skipping type check)", "..."));
|
|
93
|
+
return [4 /*yield*/, (0, cli_utils_1.compile)({ dir: dir, entry: entry, typeCheck: typecheck })];
|
|
94
|
+
case 1:
|
|
95
|
+
_b.sent();
|
|
96
|
+
serverProcess = null;
|
|
97
|
+
tscProcess = null;
|
|
98
|
+
isRebuilding = false;
|
|
99
|
+
pendingRebuild = false;
|
|
100
|
+
// Start server
|
|
101
|
+
serverProcess = startServer(dir);
|
|
102
|
+
// Start background tsc --watch for async type checking (unless --typecheck or --no-typecheck)
|
|
103
|
+
if (!typecheck && !noTypecheck) {
|
|
104
|
+
tscProcess = startTscWatch(dir);
|
|
105
|
+
}
|
|
106
|
+
watcher = chokidar_1.default.watch(["".concat(dir, "/src/**/*.ts"), "".concat(dir, "/src/**/*.json")], {
|
|
107
|
+
ignored: ["**/.flink/**", "**/dist/**", "**/node_modules/**", "**/*.spec.ts", "**/*.test.ts"],
|
|
108
|
+
persistent: true,
|
|
109
|
+
ignoreInitial: true,
|
|
110
|
+
});
|
|
111
|
+
watcher.on("change", function (path) { return __awaiter(_this, void 0, void 0, function () {
|
|
112
|
+
var rebuildStart, rebuildTime, error_1;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
if (isRebuilding) {
|
|
117
|
+
pendingRebuild = true;
|
|
118
|
+
return [2 /*return*/];
|
|
119
|
+
}
|
|
120
|
+
isRebuilding = true;
|
|
121
|
+
logger.info("\n\uD83D\uDCDD File changed: ".concat(path));
|
|
122
|
+
logger.info("🔄 Rebuilding...");
|
|
123
|
+
rebuildStart = Date.now();
|
|
124
|
+
_a.label = 1;
|
|
125
|
+
case 1:
|
|
126
|
+
_a.trys.push([1, 5, , 6]);
|
|
127
|
+
return [4 /*yield*/, (0, cli_utils_1.compile)({ dir: dir, entry: entry, typeCheck: typecheck })];
|
|
128
|
+
case 2:
|
|
129
|
+
_a.sent();
|
|
130
|
+
if (!serverProcess) return [3 /*break*/, 4];
|
|
131
|
+
return [4 /*yield*/, killAndWait(serverProcess)];
|
|
132
|
+
case 3:
|
|
133
|
+
_a.sent();
|
|
134
|
+
serverProcess = null;
|
|
135
|
+
_a.label = 4;
|
|
136
|
+
case 4:
|
|
137
|
+
serverProcess = startServer(dir);
|
|
138
|
+
rebuildTime = Date.now() - rebuildStart;
|
|
139
|
+
logger.info("\u2705 Rebuild complete in ".concat(rebuildTime, "ms\n"));
|
|
140
|
+
return [3 /*break*/, 6];
|
|
141
|
+
case 5:
|
|
142
|
+
error_1 = _a.sent();
|
|
143
|
+
logger.error("\u274C Rebuild failed: ".concat(error_1.message));
|
|
144
|
+
return [3 /*break*/, 6];
|
|
145
|
+
case 6:
|
|
146
|
+
isRebuilding = false;
|
|
147
|
+
// If another change happened during rebuild, trigger again
|
|
148
|
+
if (pendingRebuild) {
|
|
149
|
+
pendingRebuild = false;
|
|
150
|
+
watcher.emit("change", path);
|
|
151
|
+
}
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}); });
|
|
156
|
+
watcher.on("ready", function () {
|
|
157
|
+
console.log("\n👀 Watching for changes...");
|
|
158
|
+
if (tscProcess) {
|
|
159
|
+
console.log(" TypeScript type checking running in background");
|
|
160
|
+
}
|
|
161
|
+
console.log(" Press Ctrl+C to stop\n");
|
|
162
|
+
});
|
|
163
|
+
// Cleanup on exit
|
|
164
|
+
process.on("SIGINT", function () {
|
|
165
|
+
console.log("\n\n🛑 Stopping dev mode...");
|
|
166
|
+
if (serverProcess) {
|
|
167
|
+
serverProcess.kill();
|
|
168
|
+
}
|
|
169
|
+
if (tscProcess) {
|
|
170
|
+
tscProcess.kill();
|
|
171
|
+
}
|
|
172
|
+
watcher.close();
|
|
173
|
+
process.exit(0);
|
|
174
|
+
});
|
|
175
|
+
return [2 /*return*/];
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
function killAndWait(proc) {
|
|
181
|
+
return new Promise(function (resolve) {
|
|
182
|
+
if (proc.exitCode !== null) {
|
|
183
|
+
// Already exited
|
|
184
|
+
resolve();
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
proc.once("exit", function () { return resolve(); });
|
|
188
|
+
proc.kill();
|
|
189
|
+
// Safety timeout: if the process doesn't exit within 5s, force-kill it
|
|
190
|
+
var timeout = setTimeout(function () {
|
|
191
|
+
proc.kill("SIGKILL");
|
|
192
|
+
}, 5000);
|
|
193
|
+
proc.once("exit", function () { return clearTimeout(timeout); });
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
function startServer(dir) {
|
|
197
|
+
console.log("🚀 Starting server...");
|
|
198
|
+
var fork = require("child_process").fork;
|
|
199
|
+
var serverProcess = fork("".concat(dir, "/dist/.flink/start.js"), [], {
|
|
200
|
+
stdio: "inherit",
|
|
201
|
+
});
|
|
202
|
+
serverProcess.on("exit", function (code) {
|
|
203
|
+
if (code !== null && code !== 0) {
|
|
204
|
+
logger.error("\u274C Server exited with code ".concat(code));
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
return serverProcess;
|
|
208
|
+
}
|
|
209
|
+
function findTsc(startDir) {
|
|
210
|
+
var current = startDir;
|
|
211
|
+
while (true) {
|
|
212
|
+
var candidate = (0, path_1.join)(current, "node_modules", ".bin", "tsc");
|
|
213
|
+
if ((0, fs_1.existsSync)(candidate)) {
|
|
214
|
+
return candidate;
|
|
215
|
+
}
|
|
216
|
+
var parent = (0, path_1.dirname)(current);
|
|
217
|
+
if (parent === current)
|
|
218
|
+
break;
|
|
219
|
+
current = parent;
|
|
220
|
+
}
|
|
221
|
+
return null;
|
|
222
|
+
}
|
|
223
|
+
function startTscWatch(dir) {
|
|
224
|
+
var _a, _b;
|
|
225
|
+
var absoluteDir = (0, path_1.resolve)(dir);
|
|
226
|
+
var tscPath = findTsc(absoluteDir);
|
|
227
|
+
if (!tscPath) {
|
|
228
|
+
logger.warn("Background type checking unavailable: typescript not found in node_modules");
|
|
229
|
+
var noop = (0, child_process_1.spawn)("node", ["-e", ""], { stdio: "ignore" });
|
|
230
|
+
return noop;
|
|
231
|
+
}
|
|
232
|
+
var tsBuildInfoPath = (0, path_1.join)(absoluteDir, ".flink", "tsconfig.tsbuildinfo");
|
|
233
|
+
var tsc = (0, child_process_1.spawn)(tscPath, ["--noEmit", "--watch", "--preserveWatchOutput", "--pretty", "--incremental", "--tsBuildInfoFile", tsBuildInfoPath], {
|
|
234
|
+
cwd: absoluteDir,
|
|
235
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
236
|
+
});
|
|
237
|
+
var buffer = "";
|
|
238
|
+
var processOutput = function (data) {
|
|
239
|
+
buffer += data.toString();
|
|
240
|
+
var lines = buffer.split("\n");
|
|
241
|
+
buffer = lines.pop() || "";
|
|
242
|
+
for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
|
|
243
|
+
var line = lines_1[_i];
|
|
244
|
+
var trimmed = line.replace(/\x1Bc/g, "").trim();
|
|
245
|
+
if (!trimmed)
|
|
246
|
+
continue;
|
|
247
|
+
// Filter out noisy watch-mode status lines
|
|
248
|
+
if (trimmed.includes("Starting compilation") ||
|
|
249
|
+
trimmed.includes("File change detected") ||
|
|
250
|
+
trimmed.match(/^\[\d+:\d+:\d+\s+[AP]M\] Watching for file changes/)) {
|
|
251
|
+
continue;
|
|
252
|
+
}
|
|
253
|
+
if (trimmed.includes("Found 0 errors")) {
|
|
254
|
+
console.log("[tsc] \u2713 No type errors");
|
|
255
|
+
}
|
|
256
|
+
else if (trimmed.match(/Found \d+ errors?/)) {
|
|
257
|
+
// Pretty-print the error count summary
|
|
258
|
+
var match = trimmed.match(/Found (\d+) errors?/);
|
|
259
|
+
var count = match === null || match === void 0 ? void 0 : match[1];
|
|
260
|
+
console.log("[tsc] \u274C Found ".concat(count, " type error").concat(count === "1" ? "" : "s", " \u2014 see details above"));
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
// Show everything else: error details, file paths, code context, etc.
|
|
264
|
+
console.log("[tsc] ".concat(trimmed));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
(_a = tsc.stdout) === null || _a === void 0 ? void 0 : _a.on("data", processOutput);
|
|
269
|
+
(_b = tsc.stderr) === null || _b === void 0 ? void 0 : _b.on("data", processOutput);
|
|
270
|
+
tsc.on("error", function (err) {
|
|
271
|
+
logger.warn("Background type checking unavailable: ".concat(err.message));
|
|
272
|
+
});
|
|
273
|
+
tsc.on("exit", function (code) {
|
|
274
|
+
if (code !== null && code !== 0) {
|
|
275
|
+
logger.debug("Background tsc exited with code ".concat(code));
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
return tsc;
|
|
279
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse the contents of a .env file into a key/value map.
|
|
3
|
+
*
|
|
4
|
+
* Rules:
|
|
5
|
+
* - Empty lines and lines starting with # are skipped
|
|
6
|
+
* - "export FOO=bar" is treated the same as "FOO=bar"
|
|
7
|
+
* - Quoted values (single or double) are unquoted, and their content is used as-is
|
|
8
|
+
* - Unquoted values have inline comments stripped: FOO=bar # comment → "bar"
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseEnvContent(content: string): Record<string, string>;
|
|
11
|
+
export interface LoadEnvFilesResult {
|
|
12
|
+
/** Relative filenames that were found and loaded, in load order */
|
|
13
|
+
loaded: string[];
|
|
14
|
+
/** Number of variables injected into process.env (excludes already-set vars) */
|
|
15
|
+
injected: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Load .env files in Next.js-compatible order.
|
|
19
|
+
*
|
|
20
|
+
* Priority (highest wins):
|
|
21
|
+
* 1. process.env (already-set variables are never overridden)
|
|
22
|
+
* 2. .env.[environment].local
|
|
23
|
+
* 3. .env.local (skipped when environment === "test")
|
|
24
|
+
* 4. .env.[environment]
|
|
25
|
+
* 5. .env
|
|
26
|
+
*
|
|
27
|
+
* @param dir Root directory of the Flink app (where .env files live)
|
|
28
|
+
* @param environment "development" | "production" | "test"
|
|
29
|
+
*/
|
|
30
|
+
export declare function loadEnvFiles(dir: string, environment: "development" | "production" | "test"): LoadEnvFilesResult;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parseEnvContent = parseEnvContent;
|
|
13
|
+
exports.loadEnvFiles = loadEnvFiles;
|
|
14
|
+
var fs_1 = require("fs");
|
|
15
|
+
var path_1 = require("path");
|
|
16
|
+
/**
|
|
17
|
+
* Parse the contents of a .env file into a key/value map.
|
|
18
|
+
*
|
|
19
|
+
* Rules:
|
|
20
|
+
* - Empty lines and lines starting with # are skipped
|
|
21
|
+
* - "export FOO=bar" is treated the same as "FOO=bar"
|
|
22
|
+
* - Quoted values (single or double) are unquoted, and their content is used as-is
|
|
23
|
+
* - Unquoted values have inline comments stripped: FOO=bar # comment → "bar"
|
|
24
|
+
*/
|
|
25
|
+
function parseEnvContent(content) {
|
|
26
|
+
var result = {};
|
|
27
|
+
for (var _i = 0, _a = content.split("\n"); _i < _a.length; _i++) {
|
|
28
|
+
var rawLine = _a[_i];
|
|
29
|
+
var line = rawLine.trim();
|
|
30
|
+
// Skip empty lines and full-line comments
|
|
31
|
+
if (!line || line.startsWith("#"))
|
|
32
|
+
continue;
|
|
33
|
+
// Strip "export " prefix
|
|
34
|
+
if (line.startsWith("export ")) {
|
|
35
|
+
line = line.slice(7).trim();
|
|
36
|
+
}
|
|
37
|
+
var eqIdx = line.indexOf("=");
|
|
38
|
+
if (eqIdx === -1)
|
|
39
|
+
continue;
|
|
40
|
+
var key = line.slice(0, eqIdx).trim();
|
|
41
|
+
if (!key)
|
|
42
|
+
continue;
|
|
43
|
+
var value = line.slice(eqIdx + 1);
|
|
44
|
+
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
|
|
45
|
+
// Quoted value — strip quotes, preserve content as-is
|
|
46
|
+
value = value.slice(1, -1);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
// Unquoted — strip inline comments (" # ...") and trim
|
|
50
|
+
var commentIdx = value.search(/ #/);
|
|
51
|
+
if (commentIdx !== -1) {
|
|
52
|
+
value = value.slice(0, commentIdx);
|
|
53
|
+
}
|
|
54
|
+
value = value.trim();
|
|
55
|
+
}
|
|
56
|
+
result[key] = value;
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
function readEnvFile(filepath) {
|
|
61
|
+
if (!(0, fs_1.existsSync)(filepath))
|
|
62
|
+
return null;
|
|
63
|
+
try {
|
|
64
|
+
return parseEnvContent((0, fs_1.readFileSync)(filepath, "utf-8"));
|
|
65
|
+
}
|
|
66
|
+
catch (_a) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Load .env files in Next.js-compatible order.
|
|
72
|
+
*
|
|
73
|
+
* Priority (highest wins):
|
|
74
|
+
* 1. process.env (already-set variables are never overridden)
|
|
75
|
+
* 2. .env.[environment].local
|
|
76
|
+
* 3. .env.local (skipped when environment === "test")
|
|
77
|
+
* 4. .env.[environment]
|
|
78
|
+
* 5. .env
|
|
79
|
+
*
|
|
80
|
+
* @param dir Root directory of the Flink app (where .env files live)
|
|
81
|
+
* @param environment "development" | "production" | "test"
|
|
82
|
+
*/
|
|
83
|
+
function loadEnvFiles(dir, environment) {
|
|
84
|
+
var absoluteDir = (0, path_1.resolve)(dir);
|
|
85
|
+
// Files listed from lowest to highest priority so that Object.assign
|
|
86
|
+
// naturally lets later files override earlier ones.
|
|
87
|
+
var candidates = __spreadArray(__spreadArray([
|
|
88
|
+
".env",
|
|
89
|
+
".env.".concat(environment)
|
|
90
|
+
], (environment !== "test" ? [".env.local"] : []), true), [
|
|
91
|
+
".env.".concat(environment, ".local"),
|
|
92
|
+
], false);
|
|
93
|
+
var loaded = [];
|
|
94
|
+
var merged = {};
|
|
95
|
+
for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
|
|
96
|
+
var filename = candidates_1[_i];
|
|
97
|
+
var parsed = readEnvFile((0, path_1.join)(absoluteDir, filename));
|
|
98
|
+
if (parsed !== null) {
|
|
99
|
+
loaded.push(filename);
|
|
100
|
+
Object.assign(merged, parsed);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
// Inject into process.env — existing values always win
|
|
104
|
+
var injected = 0;
|
|
105
|
+
for (var _a = 0, _b = Object.entries(merged); _a < _b.length; _a++) {
|
|
106
|
+
var _c = _b[_a], key = _c[0], value = _c[1];
|
|
107
|
+
if (!(key in process.env)) {
|
|
108
|
+
process.env[key] = value;
|
|
109
|
+
injected++;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { loaded: loaded, injected: injected };
|
|
113
|
+
}
|
package/dist/cli/run.js
CHANGED
|
@@ -36,65 +36,66 @@ 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
|
|
40
|
+
var cli_utils_1 = require("./cli-utils");
|
|
41
|
+
var FlinkLogFactory_1 = require("../src/FlinkLogFactory");
|
|
42
|
+
var loadFlinkConfig_1 = require("../src/utils/loadFlinkConfig");
|
|
43
|
+
var loadEnvFiles_1 = require("./loadEnvFiles");
|
|
44
|
+
// Load config BEFORE creating logger
|
|
45
|
+
var flinkConfig = (0, loadFlinkConfig_1.loadFlinkConfig)();
|
|
46
|
+
FlinkLogFactory_1.FlinkLogFactory.configure(flinkConfig === null || flinkConfig === void 0 ? void 0 : flinkConfig.logging);
|
|
44
47
|
module.exports = function run(args) {
|
|
45
48
|
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var
|
|
47
|
-
return __generator(this, function (
|
|
48
|
-
switch (
|
|
49
|
+
var parsed, initLogger, _a, loaded, injected, entry;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
49
52
|
case 0:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
parsed = (0, cli_utils_1.parseArgs)(args);
|
|
54
|
+
// Load .env files before anything else so all env vars are available at startup.
|
|
55
|
+
// NODE_ENV defaults to "production" when not explicitly set.
|
|
56
|
+
if (!process.env.NODE_ENV) {
|
|
57
|
+
process.env.NODE_ENV = "production";
|
|
54
58
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
initLogger = FlinkLogFactory_1.FlinkLogFactory.createLogger("flink.init");
|
|
60
|
+
_a = (0, loadEnvFiles_1.loadEnvFiles)(parsed.dir, "production"), loaded = _a.loaded, injected = _a.injected;
|
|
61
|
+
if (loaded.length > 0) {
|
|
62
|
+
initLogger.info("Loaded env files: ".concat(loaded.join(", "), " (").concat(injected, " vars injected)"));
|
|
58
63
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
64
|
+
if ((0, cli_utils_1.hasFlag)(parsed, "help")) {
|
|
65
|
+
(0, cli_utils_1.printHelp)({
|
|
66
|
+
description: "Compiles and starts the application.",
|
|
67
|
+
usage: "$ flink run <dir>",
|
|
68
|
+
options: [
|
|
69
|
+
{ name: "entry", description: 'Entry script for app, default "/src/index.ts"' },
|
|
70
|
+
{ name: "help", description: "Displays this message" },
|
|
71
|
+
{ name: "precompiled", description: "Will run a precompiled app, default false" },
|
|
72
|
+
],
|
|
73
|
+
});
|
|
74
|
+
return [2 /*return*/];
|
|
63
75
|
}
|
|
64
|
-
|
|
65
|
-
|
|
76
|
+
entry = (0, cli_utils_1.normalizeEntry)((0, cli_utils_1.getOption)(parsed, "entry", "/src/index.ts"));
|
|
77
|
+
if ((0, cli_utils_1.hasFlag)(parsed, "precompiled")) {
|
|
78
|
+
if (parsed.options.has("entry")) {
|
|
66
79
|
console.warn("WARNING: --entry is ignored when using --precompiled");
|
|
67
80
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}).filter(function (arg) { return arg !== args[0] || args[0].startsWith("--"); });
|
|
73
|
-
forkedProcess_1 = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs_1);
|
|
74
|
-
forkedProcess_1.on("exit", function (code) {
|
|
75
|
-
process.exit(code);
|
|
81
|
+
(0, cli_utils_1.forkApp)({
|
|
82
|
+
dir: parsed.dir,
|
|
83
|
+
args: args,
|
|
84
|
+
cliFlags: ["precompiled", "entry"],
|
|
76
85
|
});
|
|
77
86
|
return [2 /*return*/];
|
|
78
87
|
}
|
|
79
|
-
return [4 /*yield*/,
|
|
88
|
+
return [4 /*yield*/, (0, cli_utils_1.compile)({
|
|
89
|
+
dir: parsed.dir,
|
|
90
|
+
entry: entry,
|
|
91
|
+
typeCheck: true,
|
|
92
|
+
})];
|
|
80
93
|
case 1:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
return [4 /*yield*/, Promise.all([compiler.parseRepos(), compiler.parseHandlers(), compiler.parseJobs(), compiler.generateStartScript(entry)])];
|
|
87
|
-
case 2:
|
|
88
|
-
_a.sent();
|
|
89
|
-
console.log("Compilation done, took ".concat(Date.now() - startTime, "ms"));
|
|
90
|
-
compiler.emit();
|
|
91
|
-
extraArgs = args.filter(function (arg) {
|
|
92
|
-
return !arg.startsWith("--entry") &&
|
|
93
|
-
arg !== args[args.indexOf("--entry") + 1];
|
|
94
|
-
}).filter(function (arg) { return arg !== args[0] || args[0].startsWith("--"); });
|
|
95
|
-
forkedProcess = require("child_process").fork(dir + "/dist/.flink/start.js", extraArgs);
|
|
96
|
-
forkedProcess.on("exit", function (code) {
|
|
97
|
-
process.exit(code);
|
|
94
|
+
_b.sent();
|
|
95
|
+
(0, cli_utils_1.forkApp)({
|
|
96
|
+
dir: parsed.dir,
|
|
97
|
+
args: args,
|
|
98
|
+
cliFlags: ["entry"],
|
|
98
99
|
});
|
|
99
100
|
return [2 /*return*/];
|
|
100
101
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface CacheTrackingConfig {
|
|
2
|
+
excludeNodeModules?: boolean;
|
|
3
|
+
includePatterns?: string[];
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Tracks dependencies and computes content hashes for schema files
|
|
7
|
+
*/
|
|
8
|
+
export declare class DependencyTracker {
|
|
9
|
+
private projectRoot;
|
|
10
|
+
private dependencyCache;
|
|
11
|
+
private config;
|
|
12
|
+
constructor(projectRoot: string, config?: CacheTrackingConfig);
|
|
13
|
+
/**
|
|
14
|
+
* Check if a file path should be tracked in the cache
|
|
15
|
+
*/
|
|
16
|
+
private shouldTrackFile;
|
|
17
|
+
/**
|
|
18
|
+
* Build dependency graph for a schema file
|
|
19
|
+
* Returns map of absolute file paths to their content hashes
|
|
20
|
+
*/
|
|
21
|
+
buildDependencyGraph(schemaFile: string, resolveImports: (filePath: string) => string[]): Promise<Map<string, string>>;
|
|
22
|
+
/**
|
|
23
|
+
* Recursively collect dependencies and compute hashes
|
|
24
|
+
*/
|
|
25
|
+
private collectDependencies;
|
|
26
|
+
/**
|
|
27
|
+
* Batch compute hashes for multiple files
|
|
28
|
+
* Returns map of file paths to hashes
|
|
29
|
+
*/
|
|
30
|
+
batchHashFiles(filePaths: string[]): Promise<Map<string, string>>;
|
|
31
|
+
/**
|
|
32
|
+
* Check if any dependencies changed
|
|
33
|
+
* Returns list of changed file paths
|
|
34
|
+
*/
|
|
35
|
+
findChangedDependencies(dependencies: Map<string, string>, cachedHashes: Record<string, string>): Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* Get relative path for display purposes
|
|
38
|
+
*/
|
|
39
|
+
getRelativePath(filePath: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Clear dependency cache
|
|
42
|
+
*/
|
|
43
|
+
clearCache(): void;
|
|
44
|
+
}
|