@geekmidas/cli 10.0.0-alpha.86 → 10.0.0-alpha.88
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/databases-BY-pEImp.cjs.map +1 -1
- package/dist/databases-CzszQV0N.mjs.map +1 -1
- package/dist/index.cjs +81 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +81 -28
- package/dist/index.mjs.map +1 -1
- package/dist/ready-BpNbORRB.cjs.map +1 -1
- package/dist/ready-b6vm0-W-.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.mjs
CHANGED
|
@@ -47,7 +47,7 @@ import crypto from "crypto";
|
|
|
47
47
|
import { Function } from "@geekmidas/constructs/functions";
|
|
48
48
|
import { Topic } from "@geekmidas/constructs/topic";
|
|
49
49
|
//#region package.json
|
|
50
|
-
var version = "10.0.0-alpha.
|
|
50
|
+
var version = "10.0.0-alpha.88";
|
|
51
51
|
//#endregion
|
|
52
52
|
//#region src/prompt.ts
|
|
53
53
|
/**
|
|
@@ -493,6 +493,54 @@ var UnsupportedPlatform = class extends Error {
|
|
|
493
493
|
}
|
|
494
494
|
};
|
|
495
495
|
//#endregion
|
|
496
|
+
//#region src/workspace/stageTypes.ts
|
|
497
|
+
/**
|
|
498
|
+
* `.gkm/stages.d.ts`: the declared stages, as types application code can see.
|
|
499
|
+
*
|
|
500
|
+
* Constructs and app code cannot import `gkm.config.ts`, so the stage names it
|
|
501
|
+
* declares were plain strings everywhere else. This writes them into
|
|
502
|
+
* `@geekmidas/constructs`' `Stages` interface, which `LocalStage`,
|
|
503
|
+
* `DeployedStage` and `AnyStage` read — an `ExternalApi` url keyed `prodution`
|
|
504
|
+
* becomes a type error. Without the file those types are `string`.
|
|
505
|
+
*
|
|
506
|
+
* Written by `gkm dev`, `gkm build` and `gkm test --prepare`, beside the
|
|
507
|
+
* generated clients; a project's tsconfig `include`s it.
|
|
508
|
+
*/
|
|
509
|
+
/** Where the declaration is written, relative to the workspace root. */
|
|
510
|
+
const STAGE_TYPES_FILE = ".gkm/stages.d.ts";
|
|
511
|
+
/** A union of string literal types: `'staging' | 'prod'`, or `never`. */
|
|
512
|
+
function union(names) {
|
|
513
|
+
return names.length ? names.map((name) => `'${name}'`).join(" | ") : "never";
|
|
514
|
+
}
|
|
515
|
+
/** The declaration for a stages block. */
|
|
516
|
+
function stageTypesDeclaration(stages) {
|
|
517
|
+
return `// Generated by gkm from the \`stages\` in gkm.config.ts — do not edit.
|
|
518
|
+
// \`gkm dev\`, \`gkm build\` and \`gkm test --prepare\` rewrite it.
|
|
519
|
+
export {};
|
|
520
|
+
|
|
521
|
+
declare module '@geekmidas/constructs' {
|
|
522
|
+
interface Stages {
|
|
523
|
+
local: ${union([stages.local])};
|
|
524
|
+
deployed: ${union(stages.deployed)};
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
`;
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Write `.gkm/stages.d.ts` under the workspace root, and return its path — or
|
|
531
|
+
* nothing when there are no stages to write. Left untouched when unchanged, so
|
|
532
|
+
* an editor's watcher does not re-check the project on every start.
|
|
533
|
+
*/
|
|
534
|
+
async function writeStageTypes(root, stages) {
|
|
535
|
+
if (!stages) return void 0;
|
|
536
|
+
const path = join(root, STAGE_TYPES_FILE);
|
|
537
|
+
const content = stageTypesDeclaration(stages);
|
|
538
|
+
if (await readFile(path, "utf8").catch(() => void 0) === content) return path;
|
|
539
|
+
await mkdir(join(root, ".gkm"), { recursive: true });
|
|
540
|
+
await writeFile(path, content);
|
|
541
|
+
return path;
|
|
542
|
+
}
|
|
543
|
+
//#endregion
|
|
496
544
|
//#region src/dev/credentials.ts
|
|
497
545
|
/**
|
|
498
546
|
* `gkm dev:credentials` — where to sign in to each local service, and as
|
|
@@ -1806,8 +1854,10 @@ async function devCommand(options) {
|
|
|
1806
1854
|
if (!appConfig) {
|
|
1807
1855
|
logger$5.log("🔎 Reading gkm.config.ts and the constructs");
|
|
1808
1856
|
const { workspace: everything } = await loadWorkspaceConfig();
|
|
1857
|
+
await writeStageTypes(everything.root, everything.stages);
|
|
1809
1858
|
return workspaceDevCommand(everything, options);
|
|
1810
1859
|
}
|
|
1860
|
+
await writeStageTypes(appConfig.workspace.root, appConfig.workspace.stages);
|
|
1811
1861
|
const config = appConfig.gkmConfig;
|
|
1812
1862
|
const appRoot = appConfig.appRoot;
|
|
1813
1863
|
const secretsRoot = appConfig.workspaceRoot;
|
|
@@ -3138,6 +3188,7 @@ var UnknownCacheBackend = class extends Error {
|
|
|
3138
3188
|
};
|
|
3139
3189
|
async function buildCommand(options) {
|
|
3140
3190
|
const loadedConfig = await loadWorkspaceConfig();
|
|
3191
|
+
await writeStageTypes(loadedConfig.workspace.root, loadedConfig.workspace.stages);
|
|
3141
3192
|
if (loadedConfig.type === "workspace") {
|
|
3142
3193
|
const cwd = resolve(process.cwd());
|
|
3143
3194
|
const workspaceRoot = resolve(loadedConfig.workspace.root);
|
|
@@ -5219,25 +5270,25 @@ function loadPackageJson() {
|
|
|
5219
5270
|
* Run: pnpm --filter @geekmidas/cli sync-versions
|
|
5220
5271
|
*/
|
|
5221
5272
|
const GEEKMIDAS_VERSIONS = {
|
|
5222
|
-
"@geekmidas/audit": "~10.0.0-alpha.
|
|
5223
|
-
"@geekmidas/auth": "~10.0.0-alpha.
|
|
5224
|
-
"@geekmidas/cache": "~10.0.0-alpha.
|
|
5225
|
-
"@geekmidas/client": "~10.0.0-alpha.
|
|
5226
|
-
"@geekmidas/cloud": "~10.0.0-alpha.
|
|
5227
|
-
"@geekmidas/constructs": "~10.0.0-alpha.
|
|
5228
|
-
"@geekmidas/db": "~10.0.0-alpha.
|
|
5229
|
-
"@geekmidas/emailkit": "~10.0.0-alpha.
|
|
5230
|
-
"@geekmidas/envkit": "~10.0.0-alpha.
|
|
5231
|
-
"@geekmidas/errors": "~10.0.0-alpha.
|
|
5232
|
-
"@geekmidas/events": "~10.0.0-alpha.
|
|
5233
|
-
"@geekmidas/logger": "~10.0.0-alpha.
|
|
5234
|
-
"@geekmidas/manifest": "~10.0.0-alpha.
|
|
5235
|
-
"@geekmidas/rate-limit": "~10.0.0-alpha.
|
|
5236
|
-
"@geekmidas/schema": "~10.0.0-alpha.
|
|
5237
|
-
"@geekmidas/services": "~10.0.0-alpha.
|
|
5238
|
-
"@geekmidas/storage": "~10.0.0-alpha.
|
|
5239
|
-
"@geekmidas/telescope": "~10.0.0-alpha.
|
|
5240
|
-
"@geekmidas/testkit": "~10.0.0-alpha.
|
|
5273
|
+
"@geekmidas/audit": "~10.0.0-alpha.88",
|
|
5274
|
+
"@geekmidas/auth": "~10.0.0-alpha.88",
|
|
5275
|
+
"@geekmidas/cache": "~10.0.0-alpha.88",
|
|
5276
|
+
"@geekmidas/client": "~10.0.0-alpha.88",
|
|
5277
|
+
"@geekmidas/cloud": "~10.0.0-alpha.88",
|
|
5278
|
+
"@geekmidas/constructs": "~10.0.0-alpha.88",
|
|
5279
|
+
"@geekmidas/db": "~10.0.0-alpha.88",
|
|
5280
|
+
"@geekmidas/emailkit": "~10.0.0-alpha.88",
|
|
5281
|
+
"@geekmidas/envkit": "~10.0.0-alpha.88",
|
|
5282
|
+
"@geekmidas/errors": "~10.0.0-alpha.88",
|
|
5283
|
+
"@geekmidas/events": "~10.0.0-alpha.88",
|
|
5284
|
+
"@geekmidas/logger": "~10.0.0-alpha.88",
|
|
5285
|
+
"@geekmidas/manifest": "~10.0.0-alpha.88",
|
|
5286
|
+
"@geekmidas/rate-limit": "~10.0.0-alpha.88",
|
|
5287
|
+
"@geekmidas/schema": "~10.0.0-alpha.88",
|
|
5288
|
+
"@geekmidas/services": "~10.0.0-alpha.88",
|
|
5289
|
+
"@geekmidas/storage": "~10.0.0-alpha.88",
|
|
5290
|
+
"@geekmidas/telescope": "~10.0.0-alpha.88",
|
|
5291
|
+
"@geekmidas/testkit": "~10.0.0-alpha.88",
|
|
5241
5292
|
"@geekmidas/cli": `~${loadPackageJson().version}`
|
|
5242
5293
|
};
|
|
5243
5294
|
//#endregion
|
|
@@ -5288,7 +5339,7 @@ function generateAuthAppFiles(options) {
|
|
|
5288
5339
|
[`@${options.name}/*`]: ["../../packages/*/src"]
|
|
5289
5340
|
}
|
|
5290
5341
|
},
|
|
5291
|
-
include: ["src/**/*.ts"],
|
|
5342
|
+
include: ["src/**/*.ts", "../../.gkm/stages.d.ts"],
|
|
5292
5343
|
exclude: ["node_modules", "dist"]
|
|
5293
5344
|
};
|
|
5294
5345
|
return [
|
|
@@ -5399,7 +5450,7 @@ export default defineConfig({${stagesBlock(options.stages)}${options.monorepo ?
|
|
|
5399
5450
|
gkmConfig += `
|
|
5400
5451
|
});
|
|
5401
5452
|
`;
|
|
5402
|
-
const tsConfig = options.monorepo ? workspaceApiTsConfig(options.name) : {
|
|
5453
|
+
const tsConfig = options.monorepo ? workspaceApiTsConfig(options.name, ".gkm/stages.d.ts") : {
|
|
5403
5454
|
compilerOptions: {
|
|
5404
5455
|
target: "ES2022",
|
|
5405
5456
|
module: "NodeNext",
|
|
@@ -5414,7 +5465,7 @@ export default defineConfig({${stagesBlock(options.stages)}${options.monorepo ?
|
|
|
5414
5465
|
allowImportingTsExtensions: true,
|
|
5415
5466
|
paths: { "~/*": ["./src/*"] }
|
|
5416
5467
|
},
|
|
5417
|
-
include: ["src/**/*.ts"],
|
|
5468
|
+
include: ["src/**/*.ts", ".gkm/stages.d.ts"],
|
|
5418
5469
|
exclude: ["node_modules", "dist"]
|
|
5419
5470
|
};
|
|
5420
5471
|
if (options.monorepo) {
|
|
@@ -5529,7 +5580,7 @@ export default defineConfig({${stagesBlock(options.stages)}${options.monorepo ?
|
|
|
5529
5580
|
* the root constructs, so in the other `@<name>/constructs/api.ts` fell through
|
|
5530
5581
|
* to the `packages/` mapping and nothing could load the surface.
|
|
5531
5582
|
*/
|
|
5532
|
-
function workspaceApiTsConfig(name) {
|
|
5583
|
+
function workspaceApiTsConfig(name, stageTypes) {
|
|
5533
5584
|
return {
|
|
5534
5585
|
extends: "../../tsconfig.json",
|
|
5535
5586
|
compilerOptions: {
|
|
@@ -5541,12 +5592,12 @@ function workspaceApiTsConfig(name) {
|
|
|
5541
5592
|
[`@${name}/*`]: ["../../packages/*/src"]
|
|
5542
5593
|
}
|
|
5543
5594
|
},
|
|
5544
|
-
include: ["src/**/*.ts"],
|
|
5595
|
+
include: ["src/**/*.ts", stageTypes],
|
|
5545
5596
|
exclude: ["node_modules", "dist"]
|
|
5546
5597
|
};
|
|
5547
5598
|
}
|
|
5548
5599
|
function generateSingleAppConfigFiles(options, _template, _helpers) {
|
|
5549
|
-
const tsConfig = workspaceApiTsConfig(options.name);
|
|
5600
|
+
const tsConfig = workspaceApiTsConfig(options.name, "../../.gkm/stages.d.ts");
|
|
5550
5601
|
const files = [{
|
|
5551
5602
|
path: "tsconfig.json",
|
|
5552
5603
|
content: `${JSON.stringify(tsConfig, null, 2)}\n`
|
|
@@ -5638,7 +5689,7 @@ const COMMIT = /^[0-9a-f]{40}$/;
|
|
|
5638
5689
|
* The `uses:` value for the stages action, with a comment saying which CLI
|
|
5639
5690
|
* release the pinned commit is.
|
|
5640
5691
|
*/
|
|
5641
|
-
function stagesActionUses(commit = "
|
|
5692
|
+
function stagesActionUses(commit = "5bd5a7422c74b30cb3c285d0717da882171c103a", version = cliVersion()) {
|
|
5642
5693
|
return commit && COMMIT.test(commit) ? `${STAGES_ACTION}@${commit} # @geekmidas/cli ${version}` : `${STAGES_ACTION}@main # pin to a commit SHA: see the action's README`;
|
|
5643
5694
|
}
|
|
5644
5695
|
//#endregion
|
|
@@ -7398,6 +7449,7 @@ ${isSst ? "\n# SST\n.sst/\n" : ""}`;
|
|
|
7398
7449
|
forceConsistentCasingInFileNames: true,
|
|
7399
7450
|
resolveJsonModule: true
|
|
7400
7451
|
},
|
|
7452
|
+
include: ["**/*", ".gkm/stages.d.ts"],
|
|
7401
7453
|
exclude: [
|
|
7402
7454
|
"node_modules",
|
|
7403
7455
|
"dist",
|
|
@@ -10938,7 +10990,6 @@ const logger$1 = console;
|
|
|
10938
10990
|
* machine, so no container is started for one.
|
|
10939
10991
|
*/
|
|
10940
10992
|
async function setupCommand(options = {}) {
|
|
10941
|
-
logger$1.log("\n🔧 Setting up the local environment...\n");
|
|
10942
10993
|
let loadedConfig;
|
|
10943
10994
|
try {
|
|
10944
10995
|
loadedConfig = await loadWorkspaceConfig();
|
|
@@ -10949,6 +11000,7 @@ async function setupCommand(options = {}) {
|
|
|
10949
11000
|
const stage = options.stage ?? loadedConfig.workspace.stages.local;
|
|
10950
11001
|
const { workspace } = loadedConfig;
|
|
10951
11002
|
const local = stage === workspace.stages.local;
|
|
11003
|
+
logger$1.log(local ? "\n🔧 Setting up the local environment...\n" : `\n☁️ Provisioning the '${stage}' stage${options.dryRun ? " (dry run)" : ""}...\n`);
|
|
10952
11004
|
logger$1.log(`📦 Workspace: ${workspace.name}`);
|
|
10953
11005
|
logger$1.log(`📱 Apps: ${Object.keys(workspace.apps).join(", ")}`);
|
|
10954
11006
|
logger$1.log(`🔑 Stage: ${stage}\n`);
|
|
@@ -11260,6 +11312,7 @@ async function testCommand(options = {}) {
|
|
|
11260
11312
|
const preloadPath = join(gkmDir, "test-credentials-preload.ts");
|
|
11261
11313
|
await createCredentialsPreload(preloadPath, result.secretsJsonPath);
|
|
11262
11314
|
const workspace = await loadWorkspaceConfig(cwd).then((loaded) => loaded.workspace).catch(() => void 0);
|
|
11315
|
+
if (workspace) await writeStageTypes(workspace.root, workspace.stages);
|
|
11263
11316
|
const manifestPath = workspace ? await writeTestHarness({
|
|
11264
11317
|
root: workspace.root,
|
|
11265
11318
|
targets: [workspace.root, ...Object.values(workspace.apps).map((app) => isAbsolute(app.path) ? app.path : join(workspace.root, app.path))],
|