@geekmidas/cli 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/{CachedStateProvider-DVyKfaMm.mjs → CachedStateProvider-BDq5WqSy.mjs} +1 -1
- package/dist/{CachedStateProvider-DVyKfaMm.mjs.map → CachedStateProvider-BDq5WqSy.mjs.map} +1 -1
- package/dist/CachedStateProvider-CI61keQ1.mjs +3 -0
- package/dist/{HostingerProvider-DqUq6e9i.mjs → HostingerProvider-B9N-TKbp.mjs} +2 -2
- package/dist/{HostingerProvider-DqUq6e9i.mjs.map → HostingerProvider-B9N-TKbp.mjs.map} +1 -1
- package/dist/{LocalStateProvider-DxoSaWUV.mjs → LocalStateProvider-BDm7ZqJo.mjs} +1 -1
- package/dist/{LocalStateProvider-DxoSaWUV.mjs.map → LocalStateProvider-BDm7ZqJo.mjs.map} +1 -1
- package/dist/{Route53Provider-KUAX3vz9.mjs → Route53Provider-DOWmFnwN.mjs} +2 -2
- package/dist/{Route53Provider-KUAX3vz9.mjs.map → Route53Provider-DOWmFnwN.mjs.map} +1 -1
- package/dist/{Route53Provider-CpRIqu69.cjs → Route53Provider-xrWuBXih.cjs} +2 -2
- package/dist/{Route53Provider-CpRIqu69.cjs.map → Route53Provider-xrWuBXih.cjs.map} +1 -1
- package/dist/{SSMStateProvider-D79o_JjM.cjs → SSMStateProvider-DGrqYll0.cjs} +8 -4
- package/dist/SSMStateProvider-DGrqYll0.cjs.map +1 -0
- package/dist/{SSMStateProvider-BjCi_58g.mjs → SSMStateProvider-DT0WV-E_.mjs} +9 -4
- package/dist/SSMStateProvider-DT0WV-E_.mjs.map +1 -0
- package/dist/{bundler-BqTN5Dj5.mjs → bundler-DgXsOSxc.mjs} +3 -3
- package/dist/{bundler-BqTN5Dj5.mjs.map → bundler-DgXsOSxc.mjs.map} +1 -1
- package/dist/chunk-Duj1WY3L.mjs +7 -0
- package/dist/{config-BQ4a36Rq.mjs → config-C1bidhvG.mjs} +2 -2
- package/dist/{config-BQ4a36Rq.mjs.map → config-C1bidhvG.mjs.map} +1 -1
- package/dist/{config-Bayob8pB.cjs → config-C1dM7aZb.cjs} +2 -2
- package/dist/{config-Bayob8pB.cjs.map → config-C1dM7aZb.cjs.map} +1 -1
- package/dist/config.cjs +2 -2
- package/dist/config.d.cts +1 -1
- package/dist/config.d.mts +2 -2
- package/dist/config.mjs +2 -2
- package/dist/{credentials-DT1dSxIx.mjs → credentials-s1kLcIzK.mjs} +1 -1
- package/dist/{credentials-DT1dSxIx.mjs.map → credentials-s1kLcIzK.mjs.map} +1 -1
- package/dist/deploy/sniffer-routes-worker.cjs +65 -0
- package/dist/deploy/sniffer-routes-worker.cjs.map +1 -0
- package/dist/deploy/sniffer-routes-worker.d.cts +1 -0
- package/dist/deploy/sniffer-routes-worker.d.mts +1 -0
- package/dist/deploy/sniffer-routes-worker.mjs +64 -0
- package/dist/deploy/sniffer-routes-worker.mjs.map +1 -0
- package/dist/dokploy-api-DSJYNx88.mjs +3 -0
- package/dist/{dokploy-api-7k3t7_zd.mjs → dokploy-api-z0833e7r.mjs} +1 -1
- package/dist/{dokploy-api-7k3t7_zd.mjs.map → dokploy-api-z0833e7r.mjs.map} +1 -1
- package/dist/{encryption-JtMsiGNp.mjs → encryption-BOH5M-f-.mjs} +1 -1
- package/dist/{encryption-JtMsiGNp.mjs.map → encryption-BOH5M-f-.mjs.map} +1 -1
- package/dist/encryption-a9TNMWav.mjs +3 -0
- package/dist/{index-Bi9vGQJy.d.mts → index-DvpWzLD7.d.mts} +5 -2
- package/dist/index-DvpWzLD7.d.mts.map +1 -0
- package/dist/{index-CufAAnge.d.cts → index-DzmZ6SUW.d.cts} +4 -1
- package/dist/index-DzmZ6SUW.d.cts.map +1 -0
- package/dist/index.cjs +100 -170
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +116 -185
- package/dist/index.mjs.map +1 -1
- package/dist/{openapi-BZ4Qik9w.mjs → openapi-9k6a6VA4.mjs} +3 -3
- package/dist/{openapi-BZ4Qik9w.mjs.map → openapi-9k6a6VA4.mjs.map} +1 -1
- package/dist/{openapi-CzfnHlhG.cjs → openapi-Dcja4e1C.cjs} +2 -8
- package/dist/{openapi-CzfnHlhG.cjs.map → openapi-Dcja4e1C.cjs.map} +1 -1
- package/dist/{openapi-react-query-DGEkD39r.mjs → openapi-react-query-DaTMSPD5.mjs} +1 -1
- package/dist/{openapi-react-query-DGEkD39r.mjs.map → openapi-react-query-DaTMSPD5.mjs.map} +1 -1
- package/dist/openapi-react-query.mjs +1 -1
- package/dist/openapi.cjs +3 -3
- package/dist/openapi.d.mts +1 -1
- package/dist/openapi.mjs +3 -3
- package/dist/{storage-BMW6yLu3.mjs → storage-DmCbr6DI.mjs} +1 -1
- package/dist/{storage-BMW6yLu3.mjs.map → storage-DmCbr6DI.mjs.map} +1 -1
- package/dist/{storage-D8XzjVaO.mjs → storage-Dx_jZbq6.mjs} +1 -1
- package/dist/{types-BldpmqQX.d.mts → types-B9UZ7fOG.d.mts} +1 -1
- package/dist/{types-BldpmqQX.d.mts.map → types-B9UZ7fOG.d.mts.map} +1 -1
- package/dist/workspace/index.cjs +1 -1
- package/dist/workspace/index.d.cts +1 -1
- package/dist/workspace/index.d.mts +2 -2
- package/dist/workspace/index.mjs +1 -1
- package/dist/{workspace-CASoZOjs.mjs → workspace-Cb_I7oCJ.mjs} +5 -8
- package/dist/{workspace-CASoZOjs.mjs.map → workspace-Cb_I7oCJ.mjs.map} +1 -1
- package/dist/{workspace-BMJE18LV.cjs → workspace-CeFgIDC-.cjs} +3 -2
- package/dist/{workspace-BMJE18LV.cjs.map → workspace-CeFgIDC-.cjs.map} +1 -1
- package/package.json +2 -2
- package/src/deploy/SSMStateProvider.ts +14 -3
- package/src/deploy/StateProvider.ts +5 -1
- package/src/deploy/__tests__/SSMStateProvider.spec.ts +12 -0
- package/src/deploy/__tests__/createStateProvider.spec.ts +10 -0
- package/src/dev/index.ts +69 -106
- package/src/init/generators/web.ts +6 -2
- package/src/workspace/__tests__/client-generator.spec.ts +330 -301
- package/src/workspace/client-generator.ts +139 -199
- package/src/workspace/schema.ts +2 -0
- package/tsdown.config.ts +1 -0
- package/dist/CachedStateProvider-OiFUGr7p.mjs +0 -3
- package/dist/SSMStateProvider-BjCi_58g.mjs.map +0 -1
- package/dist/SSMStateProvider-D79o_JjM.cjs.map +0 -1
- package/dist/dokploy-api-CHa8G51l.mjs +0 -3
- package/dist/encryption-UUmaWAmz.mjs +0 -3
- package/dist/index-Bi9vGQJy.d.mts.map +0 -1
- package/dist/index-CufAAnge.d.cts.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env -S npx tsx
|
|
2
|
-
import { __require
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
2
|
+
import { __require } from "./chunk-Duj1WY3L.mjs";
|
|
3
|
+
import { getAppBuildOrder, getDependencyEnvVars, getDeployTargetError, isDeployTargetSupported } from "./workspace-Cb_I7oCJ.mjs";
|
|
4
|
+
import { getAppNameFromCwd, loadAppConfig, loadConfig, loadWorkspaceConfig, parseModuleConfig } from "./config-C1bidhvG.mjs";
|
|
5
|
+
import { getCredentialsPath, getDokployCredentials, getDokployRegistryId, getDokployToken, removeDokployCredentials, storeDokployCredentials, storeDokployRegistryId } from "./credentials-s1kLcIzK.mjs";
|
|
6
|
+
import { ConstructGenerator, EndpointGenerator, OPENAPI_OUTPUT_PATH, generateOpenApi, openapiCommand, resolveOpenApiConfig } from "./openapi-9k6a6VA4.mjs";
|
|
7
|
+
import { getKeyPath, maskPassword, readStageSecrets, secretsExist, setCustomSecret, toEmbeddableSecrets, writeStageSecrets } from "./storage-DmCbr6DI.mjs";
|
|
8
|
+
import { DokployApi } from "./dokploy-api-z0833e7r.mjs";
|
|
9
|
+
import { encryptSecrets } from "./encryption-BOH5M-f-.mjs";
|
|
10
|
+
import { CachedStateProvider } from "./CachedStateProvider-BDq5WqSy.mjs";
|
|
11
|
+
import { generateReactQueryCommand } from "./openapi-react-query-DaTMSPD5.mjs";
|
|
11
12
|
import { createRequire } from "node:module";
|
|
12
13
|
import { copyFileSync, existsSync, readFileSync, unlinkSync } from "node:fs";
|
|
13
14
|
import { basename, dirname, join, parse, relative, resolve } from "node:path";
|
|
@@ -23,7 +24,7 @@ import fg from "fast-glob";
|
|
|
23
24
|
import { Cron } from "@geekmidas/constructs/crons";
|
|
24
25
|
import { Function } from "@geekmidas/constructs/functions";
|
|
25
26
|
import { Subscriber } from "@geekmidas/constructs/subscribers";
|
|
26
|
-
import {
|
|
27
|
+
import { randomBytes } from "node:crypto";
|
|
27
28
|
import { Client } from "pg";
|
|
28
29
|
import { lookup } from "node:dns/promises";
|
|
29
30
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
@@ -31,7 +32,7 @@ import prompts from "prompts";
|
|
|
31
32
|
|
|
32
33
|
//#region package.json
|
|
33
34
|
var name = "@geekmidas/cli";
|
|
34
|
-
var version = "1.2.
|
|
35
|
+
var version = "1.2.3";
|
|
35
36
|
var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
|
|
36
37
|
var private$1 = false;
|
|
37
38
|
var type = "module";
|
|
@@ -131,7 +132,7 @@ const logger$11 = console;
|
|
|
131
132
|
* Validate Dokploy token by making a test API call
|
|
132
133
|
*/
|
|
133
134
|
async function validateDokployToken(endpoint, token) {
|
|
134
|
-
const { DokployApi: DokployApi$1 } = await import("./dokploy-api-
|
|
135
|
+
const { DokployApi: DokployApi$1 } = await import("./dokploy-api-DSJYNx88.mjs");
|
|
135
136
|
const api = new DokployApi$1({
|
|
136
137
|
baseUrl: endpoint,
|
|
137
138
|
token
|
|
@@ -627,99 +628,61 @@ export async function setupSubscribers(
|
|
|
627
628
|
//#region src/workspace/client-generator.ts
|
|
628
629
|
const logger$10 = console;
|
|
629
630
|
/**
|
|
630
|
-
*
|
|
631
|
-
*/
|
|
632
|
-
const specHashCache = /* @__PURE__ */ new Map();
|
|
633
|
-
/**
|
|
634
|
-
* Calculate hash of content for change detection.
|
|
631
|
+
* Get frontend apps that depend on a backend app.
|
|
635
632
|
*/
|
|
636
|
-
function
|
|
637
|
-
|
|
633
|
+
function getDependentFrontends(workspace, backendAppName) {
|
|
634
|
+
const dependentApps = [];
|
|
635
|
+
for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "frontend" && app.dependencies.includes(backendAppName)) dependentApps.push(appName);
|
|
636
|
+
return dependentApps;
|
|
638
637
|
}
|
|
639
638
|
/**
|
|
640
|
-
*
|
|
641
|
-
* @internal Exported for use in dev command
|
|
639
|
+
* Get the path to a backend's OpenAPI spec file.
|
|
642
640
|
*/
|
|
643
|
-
function
|
|
644
|
-
|
|
645
|
-
|
|
641
|
+
function getBackendOpenApiPath(workspace, backendAppName) {
|
|
642
|
+
const app = workspace.apps[backendAppName];
|
|
643
|
+
if (!app || app.type !== "backend") return null;
|
|
644
|
+
return join(workspace.root, app.path, ".gkm", "openapi.ts");
|
|
646
645
|
}
|
|
647
646
|
/**
|
|
648
|
-
*
|
|
649
|
-
* Returns the spec content and endpoint count.
|
|
647
|
+
* Count endpoints in an OpenAPI spec content.
|
|
650
648
|
*/
|
|
651
|
-
|
|
652
|
-
const
|
|
653
|
-
|
|
654
|
-
const appPath = join(workspace.root, app.path);
|
|
655
|
-
const routesPatterns = normalizeRoutes(app.routes);
|
|
656
|
-
if (routesPatterns.length === 0) return null;
|
|
657
|
-
const endpointGenerator = new EndpointGenerator();
|
|
658
|
-
const allLoadedEndpoints = [];
|
|
659
|
-
for (const pattern of routesPatterns) {
|
|
660
|
-
const fullPattern = join(appPath, pattern);
|
|
661
|
-
const loaded = await endpointGenerator.load(fullPattern);
|
|
662
|
-
allLoadedEndpoints.push(...loaded);
|
|
663
|
-
}
|
|
664
|
-
const loadedEndpoints = allLoadedEndpoints;
|
|
665
|
-
if (loadedEndpoints.length === 0) return null;
|
|
666
|
-
const endpoints = loadedEndpoints.map(({ construct }) => construct);
|
|
667
|
-
const tsGenerator = new OpenApiTsGenerator();
|
|
668
|
-
const content = await tsGenerator.generate(endpoints, {
|
|
669
|
-
title: `${appName} API`,
|
|
670
|
-
version: "1.0.0",
|
|
671
|
-
description: `Auto-generated API client for ${appName}`
|
|
672
|
-
});
|
|
673
|
-
return {
|
|
674
|
-
content,
|
|
675
|
-
endpointCount: loadedEndpoints.length
|
|
676
|
-
};
|
|
649
|
+
function countEndpoints(content) {
|
|
650
|
+
const endpointMatches = content.match(/'(GET|POST|PUT|PATCH|DELETE)\s+\/[^']+'/g);
|
|
651
|
+
return endpointMatches?.length ?? 0;
|
|
677
652
|
}
|
|
678
653
|
/**
|
|
679
|
-
*
|
|
680
|
-
*
|
|
654
|
+
* Copy the OpenAPI client from a backend to all dependent frontend apps.
|
|
655
|
+
* Called when the backend's .gkm/openapi.ts file changes.
|
|
681
656
|
*/
|
|
682
|
-
async function
|
|
657
|
+
async function copyClientToFrontends(workspace, backendAppName, options = {}) {
|
|
658
|
+
const log = options.silent ? () => {} : logger$10.log.bind(logger$10);
|
|
683
659
|
const results = [];
|
|
684
|
-
const
|
|
685
|
-
if (!
|
|
686
|
-
const
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
660
|
+
const backendApp = workspace.apps[backendAppName];
|
|
661
|
+
if (!backendApp || backendApp.type !== "backend") return results;
|
|
662
|
+
const openApiPath = join(workspace.root, backendApp.path, ".gkm", "openapi.ts");
|
|
663
|
+
if (!existsSync(openApiPath)) return results;
|
|
664
|
+
const content = await readFile(openApiPath, "utf-8");
|
|
665
|
+
const endpointCount = countEndpoints(content);
|
|
666
|
+
const dependentFrontends = getDependentFrontends(workspace, backendAppName);
|
|
667
|
+
for (const frontendAppName of dependentFrontends) {
|
|
668
|
+
const frontendApp = workspace.apps[frontendAppName];
|
|
669
|
+
if (!frontendApp || frontendApp.type !== "frontend") continue;
|
|
670
|
+
const clientOutput = frontendApp.client?.output;
|
|
671
|
+
if (!clientOutput) continue;
|
|
696
672
|
const result = {
|
|
697
673
|
frontendApp: frontendAppName,
|
|
698
674
|
backendApp: backendAppName,
|
|
699
675
|
outputPath: "",
|
|
700
|
-
endpointCount
|
|
701
|
-
|
|
676
|
+
endpointCount,
|
|
677
|
+
success: false
|
|
702
678
|
};
|
|
703
679
|
try {
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
result.reason = "No endpoints found in backend";
|
|
707
|
-
results.push(result);
|
|
708
|
-
continue;
|
|
709
|
-
}
|
|
710
|
-
result.endpointCount = spec.endpointCount;
|
|
711
|
-
const cacheKey = `${backendAppName}:${frontendAppName}`;
|
|
712
|
-
const newHash = hashContent(spec.content);
|
|
713
|
-
const oldHash = specHashCache.get(cacheKey);
|
|
714
|
-
if (!options.force && oldHash === newHash) {
|
|
715
|
-
result.reason = "No schema changes detected";
|
|
716
|
-
results.push(result);
|
|
717
|
-
continue;
|
|
718
|
-
}
|
|
680
|
+
const frontendPath = join(workspace.root, frontendApp.path);
|
|
681
|
+
const outputDir = join(frontendPath, clientOutput);
|
|
719
682
|
await mkdir(outputDir, { recursive: true });
|
|
720
|
-
const fileName =
|
|
683
|
+
const fileName = `${backendAppName}.ts`;
|
|
721
684
|
const outputPath = join(outputDir, fileName);
|
|
722
|
-
const backendRelPath = relative(dirname(outputPath), join(workspace.root,
|
|
685
|
+
const backendRelPath = relative(dirname(outputPath), join(workspace.root, backendApp.path));
|
|
723
686
|
const clientContent = `/**
|
|
724
687
|
* Auto-generated API client for ${backendAppName}
|
|
725
688
|
* Generated from: ${backendRelPath}
|
|
@@ -727,43 +690,31 @@ async function generateClientForFrontend(workspace, frontendAppName, options = {
|
|
|
727
690
|
* DO NOT EDIT - This file is automatically regenerated when backend schemas change.
|
|
728
691
|
*/
|
|
729
692
|
|
|
730
|
-
${
|
|
693
|
+
${content}
|
|
731
694
|
`;
|
|
732
695
|
await writeFile(outputPath, clientContent);
|
|
733
|
-
specHashCache.set(cacheKey, newHash);
|
|
734
696
|
result.outputPath = outputPath;
|
|
735
|
-
result.
|
|
736
|
-
|
|
697
|
+
result.success = true;
|
|
698
|
+
log(`📦 Copied client to ${frontendAppName} from ${backendAppName} (${endpointCount} endpoints)`);
|
|
737
699
|
} catch (error) {
|
|
738
|
-
result.
|
|
739
|
-
results.push(result);
|
|
700
|
+
result.error = error.message;
|
|
740
701
|
}
|
|
702
|
+
results.push(result);
|
|
741
703
|
}
|
|
742
704
|
return results;
|
|
743
705
|
}
|
|
744
706
|
/**
|
|
745
|
-
*
|
|
707
|
+
* Copy clients from all backends to their dependent frontends.
|
|
708
|
+
* Useful for initial setup or force refresh.
|
|
746
709
|
*/
|
|
747
|
-
async function
|
|
748
|
-
const log = options.silent ? () => {} : logger$10.log.bind(logger$10);
|
|
710
|
+
async function copyAllClients(workspace, options = {}) {
|
|
749
711
|
const allResults = [];
|
|
750
|
-
for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "
|
|
751
|
-
const results = await
|
|
752
|
-
|
|
753
|
-
if (result.generated) log(`📦 Generated client for ${result.frontendApp} from ${result.backendApp} (${result.endpointCount} endpoints)`);
|
|
754
|
-
allResults.push(result);
|
|
755
|
-
}
|
|
712
|
+
for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "backend" && app.routes) {
|
|
713
|
+
const results = await copyClientToFrontends(workspace, appName, options);
|
|
714
|
+
allResults.push(...results);
|
|
756
715
|
}
|
|
757
716
|
return allResults;
|
|
758
717
|
}
|
|
759
|
-
/**
|
|
760
|
-
* Get frontend apps that depend on a backend app.
|
|
761
|
-
*/
|
|
762
|
-
function getDependentFrontends(workspace, backendAppName) {
|
|
763
|
-
const dependentApps = [];
|
|
764
|
-
for (const [appName, app] of Object.entries(workspace.apps)) if (app.type === "frontend" && app.dependencies.includes(backendAppName)) dependentApps.push(appName);
|
|
765
|
-
return dependentApps;
|
|
766
|
-
}
|
|
767
718
|
|
|
768
719
|
//#endregion
|
|
769
720
|
//#region src/dev/index.ts
|
|
@@ -1263,10 +1214,10 @@ async function workspaceDevCommand(workspace, options) {
|
|
|
1263
1214
|
if (hasErrors) throw new Error("Frontend app validation failed. Fix the issues above and try again.");
|
|
1264
1215
|
logger$9.log("✅ Frontend apps validated");
|
|
1265
1216
|
}
|
|
1266
|
-
if (frontendApps.length > 0) {
|
|
1267
|
-
const clientResults = await
|
|
1268
|
-
const
|
|
1269
|
-
if (
|
|
1217
|
+
if (frontendApps.length > 0 && backendApps.length > 0) {
|
|
1218
|
+
const clientResults = await copyAllClients(workspace);
|
|
1219
|
+
const copiedCount = clientResults.filter((r) => r.success).length;
|
|
1220
|
+
if (copiedCount > 0) logger$9.log(`\n📦 Copied ${copiedCount} API client(s)`);
|
|
1270
1221
|
}
|
|
1271
1222
|
await startWorkspaceServices(workspace);
|
|
1272
1223
|
const secretsEnv = await loadDevSecrets(workspace);
|
|
@@ -1327,65 +1278,42 @@ async function workspaceDevCommand(workspace, options) {
|
|
|
1327
1278
|
stdio: "inherit",
|
|
1328
1279
|
env: turboEnv
|
|
1329
1280
|
});
|
|
1330
|
-
let
|
|
1281
|
+
let openApiWatcher = null;
|
|
1331
1282
|
if (frontendApps.length > 0 && backendApps.length > 0) {
|
|
1332
|
-
const
|
|
1333
|
-
const
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
const patternKey = join(app.path, routePattern);
|
|
1340
|
-
const existing = backendRouteMap.get(patternKey) || [];
|
|
1341
|
-
backendRouteMap.set(patternKey, [...existing, appName]);
|
|
1342
|
-
}
|
|
1283
|
+
const openApiPaths = [];
|
|
1284
|
+
for (const [appName] of backendApps) {
|
|
1285
|
+
const openApiPath = getBackendOpenApiPath(workspace, appName);
|
|
1286
|
+
if (openApiPath) openApiPaths.push({
|
|
1287
|
+
path: openApiPath,
|
|
1288
|
+
appName
|
|
1289
|
+
});
|
|
1343
1290
|
}
|
|
1344
|
-
if (
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1291
|
+
if (openApiPaths.length > 0) {
|
|
1292
|
+
logger$9.log(`\n👀 Watching ${openApiPaths.length} backend OpenAPI spec(s) for changes`);
|
|
1293
|
+
const pathToApp = new Map(openApiPaths.map((p) => [p.path, p.appName]));
|
|
1294
|
+
openApiWatcher = chokidar.watch(openApiPaths.map((p) => p.path), {
|
|
1295
|
+
persistent: true,
|
|
1296
|
+
ignoreInitial: true,
|
|
1297
|
+
depth: 0
|
|
1349
1298
|
});
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
break;
|
|
1369
|
-
}
|
|
1370
|
-
}
|
|
1371
|
-
}
|
|
1372
|
-
if (changedBackends.length === 0) return;
|
|
1373
|
-
const affectedFrontends = /* @__PURE__ */ new Set();
|
|
1374
|
-
for (const backend of changedBackends) {
|
|
1375
|
-
const dependents = getDependentFrontends(workspace, backend);
|
|
1376
|
-
for (const frontend of dependents) affectedFrontends.add(frontend);
|
|
1377
|
-
}
|
|
1378
|
-
if (affectedFrontends.size === 0) return;
|
|
1379
|
-
logger$9.log(`\n🔄 Detected schema change in ${changedBackends.join(", ")}`);
|
|
1380
|
-
for (const frontend of affectedFrontends) try {
|
|
1381
|
-
const results = await generateClientForFrontend(workspace, frontend);
|
|
1382
|
-
for (const result of results) if (result.generated) logger$9.log(` 📦 Regenerated client for ${result.frontendApp} (${result.endpointCount} endpoints)`);
|
|
1383
|
-
} catch (error) {
|
|
1384
|
-
logger$9.error(` ❌ Failed to regenerate client for ${frontend}: ${error.message}`);
|
|
1385
|
-
}
|
|
1386
|
-
}, 500);
|
|
1387
|
-
});
|
|
1388
|
-
}
|
|
1299
|
+
let copyTimeout = null;
|
|
1300
|
+
const handleChange = async (changedPath) => {
|
|
1301
|
+
if (copyTimeout) clearTimeout(copyTimeout);
|
|
1302
|
+
copyTimeout = setTimeout(async () => {
|
|
1303
|
+
const backendAppName = pathToApp.get(changedPath);
|
|
1304
|
+
if (!backendAppName) return;
|
|
1305
|
+
logger$9.log(`\n🔄 OpenAPI spec changed for ${backendAppName}`);
|
|
1306
|
+
try {
|
|
1307
|
+
const results = await copyClientToFrontends(workspace, backendAppName, { silent: true });
|
|
1308
|
+
for (const result of results) if (result.success) logger$9.log(` 📦 Copied client to ${result.frontendApp} (${result.endpointCount} endpoints)`);
|
|
1309
|
+
else if (result.error) logger$9.error(` ❌ Failed to copy client to ${result.frontendApp}: ${result.error}`);
|
|
1310
|
+
} catch (error) {
|
|
1311
|
+
logger$9.error(` ❌ Failed to copy clients: ${error.message}`);
|
|
1312
|
+
}
|
|
1313
|
+
}, 200);
|
|
1314
|
+
};
|
|
1315
|
+
openApiWatcher.on("change", handleChange);
|
|
1316
|
+
openApiWatcher.on("add", handleChange);
|
|
1389
1317
|
}
|
|
1390
1318
|
}
|
|
1391
1319
|
let isShuttingDown = false;
|
|
@@ -1393,7 +1321,7 @@ async function workspaceDevCommand(workspace, options) {
|
|
|
1393
1321
|
if (isShuttingDown) return;
|
|
1394
1322
|
isShuttingDown = true;
|
|
1395
1323
|
logger$9.log("\n🛑 Shutting down workspace...");
|
|
1396
|
-
if (
|
|
1324
|
+
if (openApiWatcher) openApiWatcher.close().catch(() => {});
|
|
1397
1325
|
if (turboProcess.pid) try {
|
|
1398
1326
|
process.kill(-turboProcess.pid, "SIGTERM");
|
|
1399
1327
|
} catch {
|
|
@@ -1411,7 +1339,7 @@ async function workspaceDevCommand(workspace, options) {
|
|
|
1411
1339
|
reject(error);
|
|
1412
1340
|
});
|
|
1413
1341
|
turboProcess.on("exit", (code) => {
|
|
1414
|
-
if (
|
|
1342
|
+
if (openApiWatcher) openApiWatcher.close().catch(() => {});
|
|
1415
1343
|
if (code !== null && code !== 0) reject(new Error(`Turbo exited with code ${code}`));
|
|
1416
1344
|
else resolve$1();
|
|
1417
1345
|
});
|
|
@@ -2027,7 +1955,7 @@ async function buildForProvider(provider, context, rootOutputDir, endpointGenera
|
|
|
2027
1955
|
let masterKey;
|
|
2028
1956
|
if (context.production?.bundle && !skipBundle) {
|
|
2029
1957
|
logger$7.log(`\n📦 Bundling production server...`);
|
|
2030
|
-
const { bundleServer } = await import("./bundler-
|
|
1958
|
+
const { bundleServer } = await import("./bundler-DgXsOSxc.mjs");
|
|
2031
1959
|
const allConstructs = [
|
|
2032
1960
|
...endpoints.map((e) => e.construct),
|
|
2033
1961
|
...functions.map((f) => f.construct),
|
|
@@ -2271,11 +2199,11 @@ async function createDnsProvider(options) {
|
|
|
2271
2199
|
if (isDnsProvider(config$1.provider)) return config$1.provider;
|
|
2272
2200
|
const provider = config$1.provider;
|
|
2273
2201
|
if (provider === "hostinger") {
|
|
2274
|
-
const { HostingerProvider } = await import("./HostingerProvider-
|
|
2202
|
+
const { HostingerProvider } = await import("./HostingerProvider-B9N-TKbp.mjs");
|
|
2275
2203
|
return new HostingerProvider();
|
|
2276
2204
|
}
|
|
2277
2205
|
if (provider === "route53") {
|
|
2278
|
-
const { Route53Provider } = await import("./Route53Provider-
|
|
2206
|
+
const { Route53Provider } = await import("./Route53Provider-DOWmFnwN.mjs");
|
|
2279
2207
|
const route53Config = config$1;
|
|
2280
2208
|
return new Route53Provider({
|
|
2281
2209
|
region: route53Config.region,
|
|
@@ -4530,24 +4458,26 @@ function isStateProvider(value) {
|
|
|
4530
4458
|
async function createStateProvider(options) {
|
|
4531
4459
|
const { config: config$1, workspaceRoot, workspaceName } = options;
|
|
4532
4460
|
if (!config$1) {
|
|
4533
|
-
const { LocalStateProvider } = await import("./LocalStateProvider-
|
|
4461
|
+
const { LocalStateProvider } = await import("./LocalStateProvider-BDm7ZqJo.mjs");
|
|
4534
4462
|
return new LocalStateProvider(workspaceRoot);
|
|
4535
4463
|
}
|
|
4536
4464
|
if (isStateProvider(config$1.provider)) return config$1.provider;
|
|
4537
4465
|
const provider = config$1.provider;
|
|
4538
4466
|
if (provider === "local") {
|
|
4539
|
-
const { LocalStateProvider } = await import("./LocalStateProvider-
|
|
4467
|
+
const { LocalStateProvider } = await import("./LocalStateProvider-BDm7ZqJo.mjs");
|
|
4540
4468
|
return new LocalStateProvider(workspaceRoot);
|
|
4541
4469
|
}
|
|
4542
4470
|
if (provider === "ssm") {
|
|
4543
4471
|
if (!workspaceName) throw new Error("Workspace name is required for SSM state provider. Set \"name\" in gkm.config.ts.");
|
|
4544
|
-
const { LocalStateProvider } = await import("./LocalStateProvider-
|
|
4545
|
-
const { SSMStateProvider } = await import("./SSMStateProvider-
|
|
4546
|
-
const { CachedStateProvider: CachedStateProvider$1 } = await import("./CachedStateProvider-
|
|
4472
|
+
const { LocalStateProvider } = await import("./LocalStateProvider-BDm7ZqJo.mjs");
|
|
4473
|
+
const { SSMStateProvider } = await import("./SSMStateProvider-DT0WV-E_.mjs");
|
|
4474
|
+
const { CachedStateProvider: CachedStateProvider$1 } = await import("./CachedStateProvider-CI61keQ1.mjs");
|
|
4475
|
+
const ssmConfig = config$1;
|
|
4547
4476
|
const local = new LocalStateProvider(workspaceRoot);
|
|
4548
4477
|
const ssm = SSMStateProvider.create({
|
|
4549
4478
|
workspaceName,
|
|
4550
|
-
region:
|
|
4479
|
+
region: ssmConfig.region,
|
|
4480
|
+
profile: ssmConfig.profile
|
|
4551
4481
|
});
|
|
4552
4482
|
return new CachedStateProvider$1(ssm, local);
|
|
4553
4483
|
}
|
|
@@ -5921,7 +5851,7 @@ async function deployCommand(options) {
|
|
|
5921
5851
|
dokployConfig = setupResult.config;
|
|
5922
5852
|
finalRegistry = dokployConfig.registry ?? dockerConfig.registry;
|
|
5923
5853
|
if (setupResult.serviceUrls) {
|
|
5924
|
-
const { readStageSecrets: readStageSecrets$1, writeStageSecrets: writeStageSecrets$1, initStageSecrets } = await import("./storage-
|
|
5854
|
+
const { readStageSecrets: readStageSecrets$1, writeStageSecrets: writeStageSecrets$1, initStageSecrets } = await import("./storage-Dx_jZbq6.mjs");
|
|
5925
5855
|
let secrets = await readStageSecrets$1(stage);
|
|
5926
5856
|
if (!secrets) {
|
|
5927
5857
|
logger$1.log(` Creating secrets file for stage "${stage}"...`);
|
|
@@ -9977,14 +9907,14 @@ export default nextConfig;
|
|
|
9977
9907
|
jsx: "preserve",
|
|
9978
9908
|
incremental: true,
|
|
9979
9909
|
plugins: [{ name: "next" }],
|
|
9910
|
+
baseUrl: ".",
|
|
9980
9911
|
paths: {
|
|
9981
|
-
"~/*": ["./src/*"],
|
|
9912
|
+
"~/*": ["./src/*", "../../packages/ui/src/*"],
|
|
9982
9913
|
[`${modelsPackage}`]: ["../../packages/models/src"],
|
|
9983
9914
|
[`${modelsPackage}/*`]: ["../../packages/models/src/*"],
|
|
9984
9915
|
[`${uiPackage}`]: ["../../packages/ui/src"],
|
|
9985
9916
|
[`${uiPackage}/*`]: ["../../packages/ui/src/*"]
|
|
9986
|
-
}
|
|
9987
|
-
baseUrl: "."
|
|
9917
|
+
}
|
|
9988
9918
|
},
|
|
9989
9919
|
include: [
|
|
9990
9920
|
"next-env.d.ts",
|
|
@@ -9992,7 +9922,8 @@ export default nextConfig;
|
|
|
9992
9922
|
"**/*.tsx",
|
|
9993
9923
|
".next/types/**/*.ts"
|
|
9994
9924
|
],
|
|
9995
|
-
exclude: ["node_modules"]
|
|
9925
|
+
exclude: ["node_modules"],
|
|
9926
|
+
references: [{ path: "../../packages/ui" }, { path: "../../packages/models" }]
|
|
9996
9927
|
};
|
|
9997
9928
|
const queryClientTs = `import { QueryClient } from '@tanstack/react-query';
|
|
9998
9929
|
|