@geekmidas/cli 0.36.0 → 0.37.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/dist/index.cjs +84 -29
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +84 -29
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/dev/__tests__/entry-integration.spec.ts +262 -0
- package/src/dev/index.ts +76 -37
- package/src/init/generators/monorepo.ts +58 -1
package/dist/index.cjs
CHANGED
|
@@ -27,7 +27,7 @@ const node_module = require_chunk.__toESM(require("node:module"));
|
|
|
27
27
|
|
|
28
28
|
//#region package.json
|
|
29
29
|
var name = "@geekmidas/cli";
|
|
30
|
-
var version = "0.
|
|
30
|
+
var version = "0.37.0";
|
|
31
31
|
var description = "CLI tools for building Lambda handlers, server applications, and generating OpenAPI specs";
|
|
32
32
|
var private$1 = false;
|
|
33
33
|
var type = "module";
|
|
@@ -1566,6 +1566,40 @@ await import('${entryPath}');
|
|
|
1566
1566
|
await (0, node_fs_promises.writeFile)(wrapperPath, content);
|
|
1567
1567
|
}
|
|
1568
1568
|
/**
|
|
1569
|
+
* Prepare credentials for entry dev mode.
|
|
1570
|
+
* Loads workspace config, secrets, and injects PORT.
|
|
1571
|
+
* @internal Exported for testing
|
|
1572
|
+
*/
|
|
1573
|
+
async function prepareEntryCredentials(options) {
|
|
1574
|
+
const cwd = options.cwd ?? process.cwd();
|
|
1575
|
+
let workspaceAppPort;
|
|
1576
|
+
let secretsRoot = cwd;
|
|
1577
|
+
let appName;
|
|
1578
|
+
try {
|
|
1579
|
+
const appConfig = await require_config.loadAppConfig(cwd);
|
|
1580
|
+
workspaceAppPort = appConfig.app.port;
|
|
1581
|
+
secretsRoot = appConfig.workspaceRoot;
|
|
1582
|
+
appName = appConfig.appName;
|
|
1583
|
+
} catch {
|
|
1584
|
+
secretsRoot = findSecretsRoot(cwd);
|
|
1585
|
+
appName = require_config.getAppNameFromCwd(cwd) ?? void 0;
|
|
1586
|
+
}
|
|
1587
|
+
const resolvedPort = options.explicitPort ?? workspaceAppPort ?? 3e3;
|
|
1588
|
+
const credentials = await loadSecretsForApp(secretsRoot, appName);
|
|
1589
|
+
credentials.PORT = String(resolvedPort);
|
|
1590
|
+
const secretsDir = (0, node_path.join)(secretsRoot, ".gkm");
|
|
1591
|
+
await (0, node_fs_promises.mkdir)(secretsDir, { recursive: true });
|
|
1592
|
+
const secretsJsonPath = (0, node_path.join)(secretsDir, "dev-secrets.json");
|
|
1593
|
+
await (0, node_fs_promises.writeFile)(secretsJsonPath, JSON.stringify(credentials, null, 2));
|
|
1594
|
+
return {
|
|
1595
|
+
credentials,
|
|
1596
|
+
resolvedPort,
|
|
1597
|
+
secretsJsonPath,
|
|
1598
|
+
appName,
|
|
1599
|
+
secretsRoot
|
|
1600
|
+
};
|
|
1601
|
+
}
|
|
1602
|
+
/**
|
|
1569
1603
|
* Run any TypeScript file with secret injection.
|
|
1570
1604
|
* Does not require gkm.config.ts.
|
|
1571
1605
|
*/
|
|
@@ -1576,37 +1610,15 @@ async function entryDevCommand(options) {
|
|
|
1576
1610
|
if (!(0, node_fs.existsSync)(entryPath)) throw new Error(`Entry file not found: ${entryPath}`);
|
|
1577
1611
|
const defaultEnv = loadEnvFiles(".env");
|
|
1578
1612
|
if (defaultEnv.loaded.length > 0) logger$8.log(`📦 Loaded env: ${defaultEnv.loaded.join(", ")}`);
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
const appConfig = await require_config.loadAppConfig();
|
|
1584
|
-
workspaceAppPort = appConfig.app.port;
|
|
1585
|
-
secretsRoot = appConfig.workspaceRoot;
|
|
1586
|
-
appName = appConfig.appName;
|
|
1587
|
-
logger$8.log(`📦 App: ${appName} (port ${workspaceAppPort})`);
|
|
1588
|
-
} catch {
|
|
1589
|
-
secretsRoot = findSecretsRoot(process.cwd());
|
|
1590
|
-
appName = require_config.getAppNameFromCwd() ?? void 0;
|
|
1591
|
-
if (appName) logger$8.log(`📦 App name: ${appName}`);
|
|
1592
|
-
}
|
|
1593
|
-
const port = options.port ?? workspaceAppPort ?? 3e3;
|
|
1594
|
-
logger$8.log(`🚀 Starting entry file: ${entry} on port ${port}`);
|
|
1595
|
-
const appSecrets = await loadSecretsForApp(secretsRoot, appName);
|
|
1596
|
-
if (Object.keys(appSecrets).length > 0) logger$8.log(`🔐 Loaded ${Object.keys(appSecrets).length} secret(s)`);
|
|
1597
|
-
else logger$8.log(`⚠️ No secrets found in ${secretsRoot}/.gkm/secrets/`);
|
|
1598
|
-
let secretsJsonPath;
|
|
1599
|
-
if (Object.keys(appSecrets).length > 0) {
|
|
1600
|
-
const secretsDir = (0, node_path.join)(secretsRoot, ".gkm");
|
|
1601
|
-
await (0, node_fs_promises.mkdir)(secretsDir, { recursive: true });
|
|
1602
|
-
secretsJsonPath = (0, node_path.join)(secretsDir, "dev-secrets.json");
|
|
1603
|
-
await (0, node_fs_promises.writeFile)(secretsJsonPath, JSON.stringify(appSecrets, null, 2));
|
|
1604
|
-
}
|
|
1613
|
+
const { credentials, resolvedPort, secretsJsonPath, appName } = await prepareEntryCredentials({ explicitPort: options.port });
|
|
1614
|
+
if (appName) logger$8.log(`📦 App: ${appName} (port ${resolvedPort})`);
|
|
1615
|
+
logger$8.log(`🚀 Starting entry file: ${entry} on port ${resolvedPort}`);
|
|
1616
|
+
if (Object.keys(credentials).length > 1) logger$8.log(`🔐 Loaded ${Object.keys(credentials).length - 1} secret(s) + PORT`);
|
|
1605
1617
|
const wrapperDir = (0, node_path.join)(process.cwd(), ".gkm");
|
|
1606
1618
|
await (0, node_fs_promises.mkdir)(wrapperDir, { recursive: true });
|
|
1607
1619
|
const wrapperPath = (0, node_path.join)(wrapperDir, "entry-wrapper.ts");
|
|
1608
1620
|
await createEntryWrapper(wrapperPath, entryPath, secretsJsonPath);
|
|
1609
|
-
const runner = new EntryRunner(wrapperPath, entryPath, watch,
|
|
1621
|
+
const runner = new EntryRunner(wrapperPath, entryPath, watch, resolvedPort);
|
|
1610
1622
|
await runner.start();
|
|
1611
1623
|
let isShuttingDown = false;
|
|
1612
1624
|
const shutdown = () => {
|
|
@@ -5408,7 +5420,6 @@ docker/.env
|
|
|
5408
5420
|
|
|
5409
5421
|
# IDE
|
|
5410
5422
|
.idea/
|
|
5411
|
-
.vscode/
|
|
5412
5423
|
*.swp
|
|
5413
5424
|
*.swo
|
|
5414
5425
|
|
|
@@ -5461,6 +5472,42 @@ export default defineConfig({
|
|
|
5461
5472
|
},
|
|
5462
5473
|
});
|
|
5463
5474
|
`;
|
|
5475
|
+
const vscodeSettings = {
|
|
5476
|
+
"search.exclude": {
|
|
5477
|
+
"**/.sst": true,
|
|
5478
|
+
"**/.gkm": true,
|
|
5479
|
+
"**/.turbo": true
|
|
5480
|
+
},
|
|
5481
|
+
"editor.formatOnSave": true,
|
|
5482
|
+
"editor.defaultFormatter": "biomejs.biome",
|
|
5483
|
+
"editor.codeActionsOnSave": {
|
|
5484
|
+
"source.fixAll.biome": "always",
|
|
5485
|
+
"source.organizeImports.biome": "always",
|
|
5486
|
+
"source.organizeImports": "always"
|
|
5487
|
+
},
|
|
5488
|
+
"[typescriptreact]": { "editor.defaultFormatter": "biomejs.biome" },
|
|
5489
|
+
"[typescript]": { "editor.defaultFormatter": "biomejs.biome" },
|
|
5490
|
+
"[javascript]": { "editor.defaultFormatter": "biomejs.biome" },
|
|
5491
|
+
"[json]": { "editor.defaultFormatter": "biomejs.biome" },
|
|
5492
|
+
"cSpell.words": [
|
|
5493
|
+
"betterauth",
|
|
5494
|
+
"dokploy",
|
|
5495
|
+
"envkit",
|
|
5496
|
+
"geekmidas",
|
|
5497
|
+
"healthcheck",
|
|
5498
|
+
"kysely",
|
|
5499
|
+
"testkit",
|
|
5500
|
+
"timestamptz",
|
|
5501
|
+
"turborepo",
|
|
5502
|
+
options.name
|
|
5503
|
+
]
|
|
5504
|
+
};
|
|
5505
|
+
const vscodeExtensions = { recommendations: [
|
|
5506
|
+
"biomejs.biome",
|
|
5507
|
+
"streetsidesoftware.code-spell-checker",
|
|
5508
|
+
"dbaeumer.vscode-eslint",
|
|
5509
|
+
"ms-azuretools.vscode-docker"
|
|
5510
|
+
] };
|
|
5464
5511
|
const files = [
|
|
5465
5512
|
{
|
|
5466
5513
|
path: "package.json",
|
|
@@ -5489,6 +5536,14 @@ export default defineConfig({
|
|
|
5489
5536
|
{
|
|
5490
5537
|
path: ".gitignore",
|
|
5491
5538
|
content: gitignore
|
|
5539
|
+
},
|
|
5540
|
+
{
|
|
5541
|
+
path: ".vscode/settings.json",
|
|
5542
|
+
content: `${JSON.stringify(vscodeSettings, null, " ")}\n`
|
|
5543
|
+
},
|
|
5544
|
+
{
|
|
5545
|
+
path: ".vscode/extensions.json",
|
|
5546
|
+
content: `${JSON.stringify(vscodeExtensions, null, " ")}\n`
|
|
5492
5547
|
}
|
|
5493
5548
|
];
|
|
5494
5549
|
if (isFullstack) files.push({
|