bkper 3.8.0 → 4.0.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 +20 -1
- package/README.md +217 -183
- package/lib/auth/auth-page.d.ts +14 -0
- package/lib/auth/auth-page.d.ts.map +1 -0
- package/lib/auth/auth-page.js +110 -0
- package/lib/auth/auth-page.js.map +1 -0
- package/lib/auth/local-auth-service.d.ts.map +1 -1
- package/lib/auth/local-auth-service.js +135 -17
- package/lib/auth/local-auth-service.js.map +1 -1
- package/lib/bkper-factory.d.ts.map +1 -0
- package/lib/{mcp/bkper-factory.js → bkper-factory.js} +5 -2
- package/lib/bkper-factory.js.map +1 -0
- package/lib/cli.d.ts +1 -1
- package/lib/cli.d.ts.map +1 -1
- package/lib/cli.js +839 -67
- package/lib/cli.js.map +1 -1
- package/lib/commands/accounts/create.d.ts +10 -0
- package/lib/commands/accounts/create.d.ts.map +1 -0
- package/lib/commands/accounts/create.js +42 -0
- package/lib/commands/accounts/create.js.map +1 -0
- package/lib/commands/accounts/delete.d.ts +3 -0
- package/lib/commands/accounts/delete.d.ts.map +1 -0
- package/lib/commands/accounts/delete.js +22 -0
- package/lib/commands/accounts/delete.js.map +1 -0
- package/lib/commands/accounts/get.d.ts +3 -0
- package/lib/commands/accounts/get.d.ts.map +1 -0
- package/lib/commands/accounts/get.js +22 -0
- package/lib/commands/accounts/get.js.map +1 -0
- package/lib/commands/accounts/index.d.ts +6 -0
- package/lib/commands/accounts/index.d.ts.map +1 -0
- package/lib/commands/accounts/index.js +6 -0
- package/lib/commands/accounts/index.js.map +1 -0
- package/lib/commands/accounts/list.d.ts +3 -0
- package/lib/commands/accounts/list.d.ts.map +1 -0
- package/lib/commands/accounts/list.js +19 -0
- package/lib/commands/accounts/list.js.map +1 -0
- package/lib/commands/accounts/update.d.ts +9 -0
- package/lib/commands/accounts/update.d.ts.map +1 -0
- package/lib/commands/accounts/update.js +40 -0
- package/lib/commands/accounts/update.js.map +1 -0
- package/lib/commands/apps/build.d.ts +11 -0
- package/lib/commands/apps/build.d.ts.map +1 -0
- package/lib/commands/apps/build.js +144 -0
- package/lib/commands/apps/build.js.map +1 -0
- package/lib/commands/apps/bundler.d.ts +34 -0
- package/lib/commands/apps/bundler.d.ts.map +1 -0
- package/lib/commands/apps/bundler.js +112 -0
- package/lib/commands/apps/bundler.js.map +1 -0
- package/lib/commands/apps/config.d.ts +51 -0
- package/lib/commands/apps/config.d.ts.map +1 -0
- package/lib/commands/apps/config.js +146 -0
- package/lib/commands/apps/config.js.map +1 -0
- package/lib/commands/apps/deploy.d.ts +23 -0
- package/lib/commands/apps/deploy.d.ts.map +1 -0
- package/lib/commands/apps/deploy.js +344 -0
- package/lib/commands/apps/deploy.js.map +1 -0
- package/lib/commands/apps/dev.d.ts +28 -0
- package/lib/commands/apps/dev.d.ts.map +1 -0
- package/lib/commands/apps/dev.js +393 -0
- package/lib/commands/apps/dev.js.map +1 -0
- package/lib/commands/apps/index.d.ts +12 -0
- package/lib/commands/apps/index.d.ts.map +1 -0
- package/lib/commands/apps/index.js +24 -0
- package/lib/commands/apps/index.js.map +1 -0
- package/lib/commands/apps/init.d.ts +7 -0
- package/lib/commands/apps/init.d.ts.map +1 -0
- package/lib/commands/apps/init.js +249 -0
- package/lib/commands/apps/init.js.map +1 -0
- package/lib/commands/apps/install.d.ts +3 -0
- package/lib/commands/apps/install.d.ts.map +1 -0
- package/lib/commands/apps/install.js +18 -0
- package/lib/commands/apps/install.js.map +1 -0
- package/lib/commands/apps/list.d.ts +7 -0
- package/lib/commands/apps/list.d.ts.map +1 -0
- package/lib/commands/apps/list.js +23 -0
- package/lib/commands/apps/list.js.map +1 -0
- package/lib/commands/apps/secrets.d.ts +22 -0
- package/lib/commands/apps/secrets.d.ts.map +1 -0
- package/lib/commands/apps/secrets.js +209 -0
- package/lib/commands/apps/secrets.js.map +1 -0
- package/lib/commands/{apps.d.ts → apps/sync.d.ts} +8 -7
- package/lib/commands/apps/sync.d.ts.map +1 -0
- package/lib/commands/apps/sync.js +76 -0
- package/lib/commands/apps/sync.js.map +1 -0
- package/lib/commands/apps/types.d.ts +54 -0
- package/lib/commands/apps/types.d.ts.map +1 -0
- package/lib/commands/apps/types.js +2 -0
- package/lib/commands/apps/types.js.map +1 -0
- package/lib/commands/apps/uninstall.d.ts +3 -0
- package/lib/commands/apps/uninstall.d.ts.map +1 -0
- package/lib/commands/apps/uninstall.js +23 -0
- package/lib/commands/apps/uninstall.js.map +1 -0
- package/lib/commands/balances/get.d.ts +12 -0
- package/lib/commands/balances/get.d.ts.map +1 -0
- package/lib/commands/balances/get.js +32 -0
- package/lib/commands/balances/get.js.map +1 -0
- package/lib/commands/balances/index.d.ts +2 -0
- package/lib/commands/balances/index.d.ts.map +1 -0
- package/lib/commands/balances/index.js +2 -0
- package/lib/commands/balances/index.js.map +1 -0
- package/lib/commands/books/create.d.ts +12 -0
- package/lib/commands/books/create.d.ts.map +1 -0
- package/lib/commands/books/create.js +37 -0
- package/lib/commands/books/create.js.map +1 -0
- package/lib/commands/books/get.d.ts +3 -0
- package/lib/commands/books/get.d.ts.map +1 -0
- package/lib/commands/books/get.js +17 -0
- package/lib/commands/books/get.js.map +1 -0
- package/lib/commands/books/index.d.ts +5 -0
- package/lib/commands/books/index.d.ts.map +1 -0
- package/lib/commands/books/index.js +5 -0
- package/lib/commands/books/index.js.map +1 -0
- package/lib/commands/books/list.d.ts +3 -0
- package/lib/commands/books/list.d.ts.map +1 -0
- package/lib/commands/books/list.js +17 -0
- package/lib/commands/books/list.js.map +1 -0
- package/lib/commands/books/update.d.ts +14 -0
- package/lib/commands/books/update.d.ts.map +1 -0
- package/lib/commands/books/update.js +46 -0
- package/lib/commands/books/update.js.map +1 -0
- package/lib/commands/collections/add-book.d.ts +3 -0
- package/lib/commands/collections/add-book.d.ts.map +1 -0
- package/lib/commands/collections/add-book.js +27 -0
- package/lib/commands/collections/add-book.js.map +1 -0
- package/lib/commands/collections/create.d.ts +6 -0
- package/lib/commands/collections/create.d.ts.map +1 -0
- package/lib/commands/collections/create.js +19 -0
- package/lib/commands/collections/create.js.map +1 -0
- package/lib/commands/collections/delete.d.ts +3 -0
- package/lib/commands/collections/delete.d.ts.map +1 -0
- package/lib/commands/collections/delete.js +22 -0
- package/lib/commands/collections/delete.js.map +1 -0
- package/lib/commands/collections/get.d.ts +3 -0
- package/lib/commands/collections/get.d.ts.map +1 -0
- package/lib/commands/collections/get.js +22 -0
- package/lib/commands/collections/get.js.map +1 -0
- package/lib/commands/collections/index.d.ts +8 -0
- package/lib/commands/collections/index.d.ts.map +1 -0
- package/lib/commands/collections/index.js +8 -0
- package/lib/commands/collections/index.js.map +1 -0
- package/lib/commands/collections/list.d.ts +3 -0
- package/lib/commands/collections/list.d.ts.map +1 -0
- package/lib/commands/collections/list.js +18 -0
- package/lib/commands/collections/list.js.map +1 -0
- package/lib/commands/collections/remove-book.d.ts +3 -0
- package/lib/commands/collections/remove-book.d.ts.map +1 -0
- package/lib/commands/collections/remove-book.js +27 -0
- package/lib/commands/collections/remove-book.js.map +1 -0
- package/lib/commands/collections/update.d.ts +6 -0
- package/lib/commands/collections/update.d.ts.map +1 -0
- package/lib/commands/collections/update.js +24 -0
- package/lib/commands/collections/update.js.map +1 -0
- package/lib/commands/groups/create.d.ts +9 -0
- package/lib/commands/groups/create.d.ts.map +1 -0
- package/lib/commands/groups/create.js +40 -0
- package/lib/commands/groups/create.js.map +1 -0
- package/lib/commands/groups/delete.d.ts +3 -0
- package/lib/commands/groups/delete.d.ts.map +1 -0
- package/lib/commands/groups/delete.js +22 -0
- package/lib/commands/groups/delete.js.map +1 -0
- package/lib/commands/groups/get.d.ts +3 -0
- package/lib/commands/groups/get.d.ts.map +1 -0
- package/lib/commands/groups/get.js +22 -0
- package/lib/commands/groups/get.js.map +1 -0
- package/lib/commands/groups/index.d.ts +6 -0
- package/lib/commands/groups/index.d.ts.map +1 -0
- package/lib/commands/groups/index.js +6 -0
- package/lib/commands/groups/index.js.map +1 -0
- package/lib/commands/groups/list.d.ts +3 -0
- package/lib/commands/groups/list.d.ts.map +1 -0
- package/lib/commands/groups/list.js +19 -0
- package/lib/commands/groups/list.js.map +1 -0
- package/lib/commands/groups/update.d.ts +8 -0
- package/lib/commands/groups/update.d.ts.map +1 -0
- package/lib/commands/groups/update.js +38 -0
- package/lib/commands/groups/update.js.map +1 -0
- package/lib/commands/skills.d.ts +17 -0
- package/lib/commands/skills.d.ts.map +1 -0
- package/lib/commands/skills.js +248 -0
- package/lib/commands/skills.js.map +1 -0
- package/lib/commands/transactions/check.d.ts +3 -0
- package/lib/commands/transactions/check.d.ts.map +1 -0
- package/lib/commands/transactions/check.js +22 -0
- package/lib/commands/transactions/check.js.map +1 -0
- package/lib/commands/transactions/create.d.ts +13 -0
- package/lib/commands/transactions/create.d.ts.map +1 -0
- package/lib/commands/transactions/create.js +55 -0
- package/lib/commands/transactions/create.js.map +1 -0
- package/lib/commands/transactions/index.d.ts +8 -0
- package/lib/commands/transactions/index.d.ts.map +1 -0
- package/lib/commands/transactions/index.js +8 -0
- package/lib/commands/transactions/index.js.map +1 -0
- package/lib/commands/transactions/list.d.ts +14 -0
- package/lib/commands/transactions/list.d.ts.map +1 -0
- package/lib/commands/transactions/list.js +26 -0
- package/lib/commands/transactions/list.js.map +1 -0
- package/lib/commands/transactions/merge.d.ts +8 -0
- package/lib/commands/transactions/merge.d.ts.map +1 -0
- package/lib/commands/transactions/merge.js +44 -0
- package/lib/commands/transactions/merge.js.map +1 -0
- package/lib/commands/transactions/post.d.ts +3 -0
- package/lib/commands/transactions/post.d.ts.map +1 -0
- package/lib/commands/transactions/post.js +22 -0
- package/lib/commands/transactions/post.js.map +1 -0
- package/lib/commands/transactions/trash.d.ts +3 -0
- package/lib/commands/transactions/trash.d.ts.map +1 -0
- package/lib/commands/transactions/trash.js +22 -0
- package/lib/commands/transactions/trash.js.map +1 -0
- package/lib/commands/transactions/update.d.ts +12 -0
- package/lib/commands/transactions/update.d.ts.map +1 -0
- package/lib/commands/transactions/update.js +53 -0
- package/lib/commands/transactions/update.js.map +1 -0
- package/lib/dev/auth-middleware.d.ts +18 -0
- package/lib/dev/auth-middleware.d.ts.map +1 -0
- package/lib/dev/auth-middleware.js +113 -0
- package/lib/dev/auth-middleware.js.map +1 -0
- package/lib/dev/cleanup.d.ts +10 -0
- package/lib/dev/cleanup.d.ts.map +1 -0
- package/lib/dev/cleanup.js +36 -0
- package/lib/dev/cleanup.js.map +1 -0
- package/lib/dev/cloudflared/constants.d.ts +35 -0
- package/lib/dev/cloudflared/constants.d.ts.map +1 -0
- package/lib/dev/cloudflared/constants.js +48 -0
- package/lib/dev/cloudflared/constants.js.map +1 -0
- package/lib/dev/cloudflared/index.d.ts +11 -0
- package/lib/dev/cloudflared/index.d.ts.map +1 -0
- package/lib/dev/cloudflared/index.js +10 -0
- package/lib/dev/cloudflared/index.js.map +1 -0
- package/lib/dev/cloudflared/install.d.ts +15 -0
- package/lib/dev/cloudflared/install.d.ts.map +1 -0
- package/lib/dev/cloudflared/install.js +140 -0
- package/lib/dev/cloudflared/install.js.map +1 -0
- package/lib/dev/cloudflared/tunnel.d.ts +64 -0
- package/lib/dev/cloudflared/tunnel.d.ts.map +1 -0
- package/lib/dev/cloudflared/tunnel.js +109 -0
- package/lib/dev/cloudflared/tunnel.js.map +1 -0
- package/lib/dev/esbuild.d.ts +28 -0
- package/lib/dev/esbuild.d.ts.map +1 -0
- package/lib/dev/esbuild.js +83 -0
- package/lib/dev/esbuild.js.map +1 -0
- package/lib/dev/logger.d.ts +51 -0
- package/lib/dev/logger.d.ts.map +1 -0
- package/lib/dev/logger.js +102 -0
- package/lib/dev/logger.js.map +1 -0
- package/lib/dev/miniflare.d.ts +32 -0
- package/lib/dev/miniflare.d.ts.map +1 -0
- package/lib/dev/miniflare.js +111 -0
- package/lib/dev/miniflare.js.map +1 -0
- package/lib/dev/preflight.d.ts +7 -0
- package/lib/dev/preflight.d.ts.map +1 -0
- package/lib/dev/preflight.js +61 -0
- package/lib/dev/preflight.js.map +1 -0
- package/lib/dev/shared.d.ts +7 -0
- package/lib/dev/shared.d.ts.map +1 -0
- package/lib/dev/shared.js +99 -0
- package/lib/dev/shared.js.map +1 -0
- package/lib/dev/tunnel.d.ts +31 -0
- package/lib/dev/tunnel.d.ts.map +1 -0
- package/lib/dev/tunnel.js +110 -0
- package/lib/dev/tunnel.js.map +1 -0
- package/lib/dev/types.d.ts +53 -0
- package/lib/dev/types.d.ts.map +1 -0
- package/lib/dev/types.js +223 -0
- package/lib/dev/types.js.map +1 -0
- package/lib/dev/vite.d.ts +50 -0
- package/lib/dev/vite.d.ts.map +1 -0
- package/lib/dev/vite.js +114 -0
- package/lib/dev/vite.js.map +1 -0
- package/lib/dev/webhook-dev.d.ts +9 -0
- package/lib/dev/webhook-dev.d.ts.map +1 -0
- package/lib/dev/webhook-dev.js +28 -0
- package/lib/dev/webhook-dev.js.map +1 -0
- package/lib/domain/transaction/merge-operation.d.ts.map +1 -0
- package/lib/{mcp/domain → domain}/transaction/merge-operation.js +10 -11
- package/lib/domain/transaction/merge-operation.js.map +1 -0
- package/lib/domain/transaction/merge-types.d.ts.map +1 -0
- package/lib/domain/transaction/merge-types.js.map +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/platform/client.d.ts +37 -0
- package/lib/platform/client.d.ts.map +1 -0
- package/lib/platform/client.js +37 -0
- package/lib/platform/client.js.map +1 -0
- package/lib/render/index.d.ts +3 -0
- package/lib/render/index.d.ts.map +1 -0
- package/lib/render/index.js +3 -0
- package/lib/render/index.js.map +1 -0
- package/lib/render/output.d.ts +15 -0
- package/lib/render/output.d.ts.map +1 -0
- package/lib/render/output.js +30 -0
- package/lib/render/output.js.map +1 -0
- package/lib/render/table-formatter.d.ts +34 -0
- package/lib/render/table-formatter.d.ts.map +1 -0
- package/lib/render/table-formatter.js +221 -0
- package/lib/render/table-formatter.js.map +1 -0
- package/lib/utils/properties.d.ts +12 -0
- package/lib/utils/properties.d.ts.map +1 -0
- package/lib/utils/properties.js +23 -0
- package/lib/utils/properties.js.map +1 -0
- package/package.json +23 -22
- package/lib/auth/keys.json +0 -12
- package/lib/commands/apps.d.ts.map +0 -1
- package/lib/commands/apps.js +0 -93
- package/lib/commands/apps.js.map +0 -1
- package/lib/mcp/bkper-factory.d.ts.map +0 -1
- package/lib/mcp/bkper-factory.js.map +0 -1
- package/lib/mcp/domain/transaction/merge-operation.d.ts.map +0 -1
- package/lib/mcp/domain/transaction/merge-operation.js.map +0 -1
- package/lib/mcp/domain/transaction/merge-types.d.ts.map +0 -1
- package/lib/mcp/domain/transaction/merge-types.js.map +0 -1
- package/lib/mcp/server.d.ts +0 -13
- package/lib/mcp/server.d.ts.map +0 -1
- package/lib/mcp/server.js +0 -161
- package/lib/mcp/server.js.map +0 -1
- package/lib/mcp/system-prompt.md +0 -192
- package/lib/mcp/tools/create_transactions.d.ts +0 -59
- package/lib/mcp/tools/create_transactions.d.ts.map +0 -1
- package/lib/mcp/tools/create_transactions.js +0 -163
- package/lib/mcp/tools/create_transactions.js.map +0 -1
- package/lib/mcp/tools/get_balances.d.ts +0 -26
- package/lib/mcp/tools/get_balances.d.ts.map +0 -1
- package/lib/mcp/tools/get_balances.js +0 -106
- package/lib/mcp/tools/get_balances.js.map +0 -1
- package/lib/mcp/tools/get_book.d.ts +0 -21
- package/lib/mcp/tools/get_book.d.ts.map +0 -1
- package/lib/mcp/tools/get_book.js +0 -126
- package/lib/mcp/tools/get_book.js.map +0 -1
- package/lib/mcp/tools/list_books.d.ts +0 -21
- package/lib/mcp/tools/list_books.d.ts.map +0 -1
- package/lib/mcp/tools/list_books.js +0 -67
- package/lib/mcp/tools/list_books.js.map +0 -1
- package/lib/mcp/tools/list_transactions.d.ts +0 -38
- package/lib/mcp/tools/list_transactions.d.ts.map +0 -1
- package/lib/mcp/tools/list_transactions.js +0 -109
- package/lib/mcp/tools/list_transactions.js.map +0 -1
- package/lib/mcp/tools/merge_transactions.d.ts +0 -40
- package/lib/mcp/tools/merge_transactions.d.ts.map +0 -1
- package/lib/mcp/tools/merge_transactions.js +0 -120
- package/lib/mcp/tools/merge_transactions.js.map +0 -1
- /package/lib/{mcp/bkper-factory.d.ts → bkper-factory.d.ts} +0 -0
- /package/lib/{mcp/domain → domain}/transaction/merge-operation.d.ts +0 -0
- /package/lib/{mcp/domain → domain}/transaction/merge-types.d.ts +0 -0
- /package/lib/{mcp/domain → domain}/transaction/merge-types.js +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import path from 'path';
|
|
12
|
+
import { createRequire } from 'module';
|
|
13
|
+
/**
|
|
14
|
+
* Dynamically loads TypeScript from the project's node_modules.
|
|
15
|
+
* Returns undefined if TypeScript is not installed in the project.
|
|
16
|
+
*/
|
|
17
|
+
function loadProjectTypeScript(projectRoot) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
20
|
+
const tsPath = path.join(projectRoot, 'node_modules', 'typescript');
|
|
21
|
+
if (!fs.existsSync(tsPath)) {
|
|
22
|
+
return undefined;
|
|
23
|
+
}
|
|
24
|
+
try {
|
|
25
|
+
// Resolve the actual TypeScript module from the project
|
|
26
|
+
const resolvedPath = require.resolve('typescript', { paths: [projectRoot] });
|
|
27
|
+
const ts = yield import(resolvedPath);
|
|
28
|
+
return ts.default || ts;
|
|
29
|
+
}
|
|
30
|
+
catch (_a) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
function formatDiagnostic(ts, diagnostic) {
|
|
36
|
+
const message = ts.flattenDiagnosticMessageText(diagnostic.messageText, ' ');
|
|
37
|
+
if (diagnostic.file && diagnostic.start !== undefined) {
|
|
38
|
+
const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
|
39
|
+
const filePath = diagnostic.file.fileName;
|
|
40
|
+
return `${filePath}:${line + 1}:${character + 1} - ${message}`;
|
|
41
|
+
}
|
|
42
|
+
return message;
|
|
43
|
+
}
|
|
44
|
+
function findConfigFile(ts, searchPath) {
|
|
45
|
+
const configPath = ts.findConfigFile(searchPath, ts.sys.fileExists, 'tsconfig.json');
|
|
46
|
+
return configPath !== null && configPath !== void 0 ? configPath : undefined;
|
|
47
|
+
}
|
|
48
|
+
export function buildSharedIfPresent(projectRoot) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a;
|
|
51
|
+
const sharedRoot = path.join(projectRoot, 'packages/shared');
|
|
52
|
+
if (!fs.existsSync(sharedRoot)) {
|
|
53
|
+
return { built: false, success: true };
|
|
54
|
+
}
|
|
55
|
+
// Load TypeScript from the project's node_modules
|
|
56
|
+
const ts = yield loadProjectTypeScript(projectRoot);
|
|
57
|
+
if (!ts) {
|
|
58
|
+
return {
|
|
59
|
+
built: false,
|
|
60
|
+
success: false,
|
|
61
|
+
diagnostics: [
|
|
62
|
+
'TypeScript not found. Run bun install at the app root (required for shared package build).',
|
|
63
|
+
],
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
const configPath = findConfigFile(ts, sharedRoot);
|
|
67
|
+
if (!configPath) {
|
|
68
|
+
return {
|
|
69
|
+
built: false,
|
|
70
|
+
success: false,
|
|
71
|
+
diagnostics: ['tsconfig.json not found in packages/shared'],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
75
|
+
if (configFile.error) {
|
|
76
|
+
return {
|
|
77
|
+
built: true,
|
|
78
|
+
success: false,
|
|
79
|
+
diagnostics: [formatDiagnostic(ts, configFile.error)],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
const parsed = ts.parseJsonConfigFileContent(configFile.config, ts.sys, path.dirname(configPath));
|
|
83
|
+
const program = ts.createProgram({
|
|
84
|
+
rootNames: parsed.fileNames,
|
|
85
|
+
options: parsed.options,
|
|
86
|
+
projectReferences: parsed.projectReferences,
|
|
87
|
+
});
|
|
88
|
+
const preEmitDiagnostics = ts.getPreEmitDiagnostics(program);
|
|
89
|
+
const emitResult = program.emit();
|
|
90
|
+
const diagnostics = preEmitDiagnostics.concat((_a = emitResult.diagnostics) !== null && _a !== void 0 ? _a : []);
|
|
91
|
+
const formatted = diagnostics.map(d => formatDiagnostic(ts, d));
|
|
92
|
+
return {
|
|
93
|
+
built: true,
|
|
94
|
+
success: diagnostics.length === 0,
|
|
95
|
+
diagnostics: formatted.length > 0 ? formatted : undefined,
|
|
96
|
+
};
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/dev/shared.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAQvC;;;GAGG;AACH,SAAe,qBAAqB,CAChC,WAAmB;;QAEnB,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,IAA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MAAM,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC;YAC7B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC9C,CAAC,CAAC;QAEH,MAAM,kBAAkB,GAAG,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC;QAC7D,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAClC,MAAM,WAAW,GAAG,kBAAkB,CAAC,MAAM,CAAC,MAAA,UAAU,CAAC,WAAW,mCAAI,EAAE,CAAC,CAAC;QAC5E,MAAM,SAAS,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,gBAAgB,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAEhE,OAAO;YACH,KAAK,EAAE,IAAI;YACX,OAAO,EAAE,WAAW,CAAC,MAAM,KAAK,CAAC;YACjC,WAAW,EAAE,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS;SAC5D,CAAC;IACN,CAAC;CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Logger } from './logger.js';
|
|
2
|
+
/**
|
|
3
|
+
* Handle to a running cloudflared tunnel.
|
|
4
|
+
*/
|
|
5
|
+
export interface TunnelHandle {
|
|
6
|
+
/** The public URL assigned to the tunnel. */
|
|
7
|
+
url: string;
|
|
8
|
+
/** Stops the tunnel process. */
|
|
9
|
+
stop(): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Options for starting a cloudflared tunnel.
|
|
13
|
+
*/
|
|
14
|
+
export interface CloudflaredTunnelOptions {
|
|
15
|
+
/** The local port to tunnel. */
|
|
16
|
+
port: number;
|
|
17
|
+
/** Optional logger for status messages. */
|
|
18
|
+
logger?: Logger;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Starts a cloudflared Quick Tunnel to expose a local port to the internet.
|
|
22
|
+
*
|
|
23
|
+
* On first invocation, downloads the cloudflared binary to ~/.config/bkper/bin/.
|
|
24
|
+
* Subsequent calls use the cached binary.
|
|
25
|
+
*
|
|
26
|
+
* @param options - Tunnel configuration options.
|
|
27
|
+
* @returns A handle to the running tunnel with URL and stop method.
|
|
28
|
+
* @throws If the tunnel fails to start or times out.
|
|
29
|
+
*/
|
|
30
|
+
export declare function startCloudflaredTunnel(options: CloudflaredTunnelOptions): Promise<TunnelHandle>;
|
|
31
|
+
//# sourceMappingURL=tunnel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel.d.ts","sourceRoot":"","sources":["../../src/dev/tunnel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;GAEG;AACH,MAAM,WAAW,YAAY;IACzB,6CAA6C;IAC7C,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAQD;;;;;;;;;GASG;AACH,wBAAsB,sBAAsB,CACxC,OAAO,EAAE,wBAAwB,GAClC,OAAO,CAAC,YAAY,CAAC,CA4FvB"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import fs from 'fs';
|
|
11
|
+
import { Tunnel, bin, install } from './cloudflared/index.js';
|
|
12
|
+
/**
|
|
13
|
+
* Maximum number of output lines to show on tunnel failure.
|
|
14
|
+
* Balances debugging context with avoiding log bloat.
|
|
15
|
+
*/
|
|
16
|
+
const MAX_ERROR_OUTPUT_LINES = 20;
|
|
17
|
+
/**
|
|
18
|
+
* Starts a cloudflared Quick Tunnel to expose a local port to the internet.
|
|
19
|
+
*
|
|
20
|
+
* On first invocation, downloads the cloudflared binary to ~/.config/bkper/bin/.
|
|
21
|
+
* Subsequent calls use the cached binary.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Tunnel configuration options.
|
|
24
|
+
* @returns A handle to the running tunnel with URL and stop method.
|
|
25
|
+
* @throws If the tunnel fails to start or times out.
|
|
26
|
+
*/
|
|
27
|
+
export function startCloudflaredTunnel(options) {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
const { port, logger } = options;
|
|
30
|
+
// Lazy download: only install cloudflared when actually needed
|
|
31
|
+
if (!fs.existsSync(bin)) {
|
|
32
|
+
logger === null || logger === void 0 ? void 0 : logger.info('Downloading cloudflared (first time only)...');
|
|
33
|
+
try {
|
|
34
|
+
yield install(bin);
|
|
35
|
+
logger === null || logger === void 0 ? void 0 : logger.success(`cloudflared installed to ${bin}`);
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
39
|
+
throw new Error(`Failed to install cloudflared: ${message}\n` +
|
|
40
|
+
'You can manually install cloudflared and set CLOUDFLARED_BIN environment variable.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Verify binary is executable
|
|
44
|
+
try {
|
|
45
|
+
fs.accessSync(bin, fs.constants.X_OK);
|
|
46
|
+
}
|
|
47
|
+
catch (_a) {
|
|
48
|
+
throw new Error(`cloudflared binary is not executable: ${bin}\n` + `Try running: chmod +x "${bin}"`);
|
|
49
|
+
}
|
|
50
|
+
logger === null || logger === void 0 ? void 0 : logger.info('Starting tunnel...');
|
|
51
|
+
const tunnel = Tunnel.quick(`http://localhost:${port}`);
|
|
52
|
+
// Collect output for error reporting (cloudflared uses both stdout and stderr)
|
|
53
|
+
const outputLines = [];
|
|
54
|
+
const collectOutput = (data) => {
|
|
55
|
+
const lines = data.split('\n').filter(line => line.trim());
|
|
56
|
+
outputLines.push(...lines);
|
|
57
|
+
};
|
|
58
|
+
tunnel.on('stdout', collectOutput);
|
|
59
|
+
tunnel.on('stderr', collectOutput);
|
|
60
|
+
// Wait for URL assignment with timeout
|
|
61
|
+
const url = yield new Promise((resolve, reject) => {
|
|
62
|
+
const timeout = setTimeout(() => {
|
|
63
|
+
tunnel.stop();
|
|
64
|
+
reject(new Error('Timed out waiting for tunnel URL (15s)'));
|
|
65
|
+
}, 15000);
|
|
66
|
+
tunnel.once('url', (assignedUrl) => {
|
|
67
|
+
clearTimeout(timeout);
|
|
68
|
+
resolve(assignedUrl);
|
|
69
|
+
});
|
|
70
|
+
tunnel.once('error', (err) => {
|
|
71
|
+
clearTimeout(timeout);
|
|
72
|
+
reject(err);
|
|
73
|
+
});
|
|
74
|
+
tunnel.once('exit', (code) => {
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
if (code !== 0 && code !== null) {
|
|
77
|
+
// Log captured output for debugging
|
|
78
|
+
if (outputLines.length > 0) {
|
|
79
|
+
const linesToShow = outputLines.slice(-MAX_ERROR_OUTPUT_LINES);
|
|
80
|
+
if (outputLines.length > MAX_ERROR_OUTPUT_LINES) {
|
|
81
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(`... (${outputLines.length - MAX_ERROR_OUTPUT_LINES} lines omitted)`);
|
|
82
|
+
}
|
|
83
|
+
logger === null || logger === void 0 ? void 0 : logger.warn('cloudflared output:');
|
|
84
|
+
for (const line of linesToShow) {
|
|
85
|
+
logger === null || logger === void 0 ? void 0 : logger.warn(` ${line}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
reject(new Error(`cloudflared exited with code ${code}`));
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return {
|
|
93
|
+
url,
|
|
94
|
+
stop() {
|
|
95
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
96
|
+
tunnel.stop();
|
|
97
|
+
// Wait for graceful shutdown with hard timeout
|
|
98
|
+
yield new Promise(resolve => {
|
|
99
|
+
const hardTimeout = setTimeout(resolve, 2000);
|
|
100
|
+
tunnel.once('exit', () => {
|
|
101
|
+
clearTimeout(hardTimeout);
|
|
102
|
+
resolve();
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=tunnel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel.js","sourceRoot":"","sources":["../../src/dev/tunnel.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AAuB9D;;;GAGG;AACH,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,UAAgB,sBAAsB,CACxC,OAAiC;;QAEjC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;QAEjC,+DAA+D;QAC/D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,8CAA8C,CAAC,CAAC;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AAK,MAAM,IAAI,IAAI,WAAW,EAAE,CAAC;4BAC7B,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;wBAC9B,CAAC;oBACL,CAAC;oBACD,MAAM,CAAC,IAAI,KAAK,CAAC,gCAAgC,IAAI,EAAE,CAAC,CAAC,CAAC;gBAC9D,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;QAEH,OAAO;YACH,GAAG;YACG,IAAI;;oBACN,MAAM,CAAC,IAAI,EAAE,CAAC;oBACd,+CAA+C;oBAC/C,MAAM,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE;wBAC9B,MAAM,WAAW,GAAG,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;wBAC9C,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE;4BACrB,YAAY,CAAC,WAAW,CAAC,CAAC;4BAC1B,OAAO,EAAE,CAAC;wBACd,CAAC,CAAC,CAAC;oBACP,CAAC,CAAC,CAAC;gBACP,CAAC;aAAA;SACJ,CAAC;IACN,CAAC;CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration for deployment services and secrets
|
|
3
|
+
*/
|
|
4
|
+
export interface DeploymentConfig {
|
|
5
|
+
services?: string[];
|
|
6
|
+
secrets?: string[];
|
|
7
|
+
hasStaticAssets?: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Assets binding type comment - no separate interface needed
|
|
11
|
+
* ASSETS uses inline type { fetch: typeof fetch } matching Cloudflare's definition
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Generates env.d.ts content from deployment config
|
|
15
|
+
* - Services become typed bindings (e.g., KV: KVNamespace)
|
|
16
|
+
* - Secrets become string properties
|
|
17
|
+
* - ASSETS binding added when static assets are configured
|
|
18
|
+
* - Includes inline KV and Fetcher types (no @cloudflare/workers-types dependency)
|
|
19
|
+
*
|
|
20
|
+
* @param config - Deployment configuration with services and secrets
|
|
21
|
+
* @returns Generated TypeScript declaration content
|
|
22
|
+
*/
|
|
23
|
+
export declare function generateEnvTypes(config: DeploymentConfig): string;
|
|
24
|
+
/**
|
|
25
|
+
* Generates .dev.vars.example content from secrets list
|
|
26
|
+
* - Creates template with placeholder values
|
|
27
|
+
* - Includes helpful comments
|
|
28
|
+
*
|
|
29
|
+
* @param secrets - List of secret names
|
|
30
|
+
* @returns Generated .dev.vars.example content
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateDevVarsExample(secrets: string[]): string;
|
|
33
|
+
/**
|
|
34
|
+
* Loads .dev.vars file and returns key-value pairs
|
|
35
|
+
* - Warns about missing secrets but doesn't block
|
|
36
|
+
* - Returns empty object if file doesn't exist
|
|
37
|
+
*
|
|
38
|
+
* @param projectRoot - Path to the project root
|
|
39
|
+
* @param requiredSecrets - List of required secret names
|
|
40
|
+
* @returns Record of secret name to value
|
|
41
|
+
*/
|
|
42
|
+
export declare function loadDevVars(projectRoot: string, requiredSecrets: string[]): Record<string, string>;
|
|
43
|
+
/**
|
|
44
|
+
* Ensures types are up to date with bkper.yaml
|
|
45
|
+
* - Compares existing files with generated content
|
|
46
|
+
* - Warns and updates if mismatch detected
|
|
47
|
+
* - Creates files if they don't exist
|
|
48
|
+
*
|
|
49
|
+
* @param config - Deployment configuration
|
|
50
|
+
* @param projectRoot - Path to the project root
|
|
51
|
+
*/
|
|
52
|
+
export declare function ensureTypesUpToDate(config: DeploymentConfig, projectRoot: string): void;
|
|
53
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/dev/types.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC7B;AAoCD;;;GAGG;AAEH;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,CAuDjE;AAcD;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAahE;AAkCD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACvB,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,MAAM,EAAE,GAC1B,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAqBxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAmCvF"}
|
package/lib/dev/types.js
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { writeFileSync, readFileSync, existsSync } from 'fs';
|
|
2
|
+
import { resolve } from 'path';
|
|
3
|
+
/**
|
|
4
|
+
* KV types as a constant for inline generation (no @cloudflare/workers-types dependency)
|
|
5
|
+
*/
|
|
6
|
+
const KV_TYPES = `
|
|
7
|
+
interface KVNamespace {
|
|
8
|
+
get(key: string, options?: { type?: 'text' }): Promise<string | null>;
|
|
9
|
+
get<T = unknown>(key: string, options: { type: 'json' }): Promise<T | null>;
|
|
10
|
+
get(key: string, options: { type: 'arrayBuffer' }): Promise<ArrayBuffer | null>;
|
|
11
|
+
get(key: string, options: { type: 'stream' }): Promise<ReadableStream | null>;
|
|
12
|
+
|
|
13
|
+
put(key: string, value: string | ArrayBuffer | ReadableStream, options?: KVNamespacePutOptions): Promise<void>;
|
|
14
|
+
delete(key: string): Promise<void>;
|
|
15
|
+
list(options?: KVNamespaceListOptions): Promise<KVNamespaceListResult>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface KVNamespacePutOptions {
|
|
19
|
+
expiration?: number;
|
|
20
|
+
expirationTtl?: number;
|
|
21
|
+
metadata?: Record<string, unknown>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface KVNamespaceListOptions {
|
|
25
|
+
prefix?: string;
|
|
26
|
+
limit?: number;
|
|
27
|
+
cursor?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface KVNamespaceListResult {
|
|
31
|
+
keys: { name: string; expiration?: number; metadata?: Record<string, unknown> }[];
|
|
32
|
+
list_complete: boolean;
|
|
33
|
+
cursor?: string;
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
/**
|
|
37
|
+
* Assets binding type comment - no separate interface needed
|
|
38
|
+
* ASSETS uses inline type { fetch: typeof fetch } matching Cloudflare's definition
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Generates env.d.ts content from deployment config
|
|
42
|
+
* - Services become typed bindings (e.g., KV: KVNamespace)
|
|
43
|
+
* - Secrets become string properties
|
|
44
|
+
* - ASSETS binding added when static assets are configured
|
|
45
|
+
* - Includes inline KV and Fetcher types (no @cloudflare/workers-types dependency)
|
|
46
|
+
*
|
|
47
|
+
* @param config - Deployment configuration with services and secrets
|
|
48
|
+
* @returns Generated TypeScript declaration content
|
|
49
|
+
*/
|
|
50
|
+
export function generateEnvTypes(config) {
|
|
51
|
+
var _a;
|
|
52
|
+
const lines = [
|
|
53
|
+
'// env.d.ts',
|
|
54
|
+
'// AUTO-GENERATED by Bkper CLI from bkper.yaml',
|
|
55
|
+
'// Regenerate with: bkper app build',
|
|
56
|
+
'',
|
|
57
|
+
'export interface Env {',
|
|
58
|
+
];
|
|
59
|
+
const hasServices = config.services && config.services.length > 0;
|
|
60
|
+
const hasSecrets = config.secrets && config.secrets.length > 0;
|
|
61
|
+
const hasKV = (_a = config.services) === null || _a === void 0 ? void 0 : _a.includes('KV');
|
|
62
|
+
const hasStaticAssets = config.hasStaticAssets === true;
|
|
63
|
+
// Add services section
|
|
64
|
+
if (hasServices) {
|
|
65
|
+
lines.push(' // Services');
|
|
66
|
+
for (const service of config.services) {
|
|
67
|
+
if (service === 'KV') {
|
|
68
|
+
lines.push(' KV: KVNamespace;');
|
|
69
|
+
}
|
|
70
|
+
// Add more services as needed
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Add static assets binding
|
|
74
|
+
if (hasStaticAssets) {
|
|
75
|
+
if (hasServices) {
|
|
76
|
+
lines.push('');
|
|
77
|
+
}
|
|
78
|
+
lines.push(' // Static assets binding');
|
|
79
|
+
lines.push(' ASSETS: { fetch: typeof fetch };');
|
|
80
|
+
}
|
|
81
|
+
// Add secrets section
|
|
82
|
+
if (hasSecrets) {
|
|
83
|
+
if (hasServices || hasStaticAssets) {
|
|
84
|
+
lines.push('');
|
|
85
|
+
}
|
|
86
|
+
lines.push(' // Secrets');
|
|
87
|
+
for (const secret of config.secrets) {
|
|
88
|
+
lines.push(` ${secret}: string;`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
lines.push('}');
|
|
92
|
+
// Add KV types if KV service is used
|
|
93
|
+
if (hasKV) {
|
|
94
|
+
lines.push('');
|
|
95
|
+
lines.push('// KV types (inline, no external dependency)');
|
|
96
|
+
lines.push(KV_TYPES.trim());
|
|
97
|
+
}
|
|
98
|
+
return lines.join('\n') + '\n';
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Converts a secret name to a placeholder value
|
|
102
|
+
* Example: API_KEY -> your-api-key-here
|
|
103
|
+
*
|
|
104
|
+
* @param secretName - The secret name in SCREAMING_SNAKE_CASE
|
|
105
|
+
* @returns Placeholder value in kebab-case
|
|
106
|
+
*/
|
|
107
|
+
function secretNameToPlaceholder(secretName) {
|
|
108
|
+
const kebab = secretName.toLowerCase().replace(/_/g, '-');
|
|
109
|
+
return `your-${kebab}-here`;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Generates .dev.vars.example content from secrets list
|
|
113
|
+
* - Creates template with placeholder values
|
|
114
|
+
* - Includes helpful comments
|
|
115
|
+
*
|
|
116
|
+
* @param secrets - List of secret names
|
|
117
|
+
* @returns Generated .dev.vars.example content
|
|
118
|
+
*/
|
|
119
|
+
export function generateDevVarsExample(secrets) {
|
|
120
|
+
const lines = [
|
|
121
|
+
'# .dev.vars.example',
|
|
122
|
+
'# Copy this file to .dev.vars and fill in your local development values',
|
|
123
|
+
'# .dev.vars is gitignored and used by the Bkper CLI for local development',
|
|
124
|
+
'',
|
|
125
|
+
];
|
|
126
|
+
for (const secret of secrets) {
|
|
127
|
+
lines.push(`${secret}=${secretNameToPlaceholder(secret)}`);
|
|
128
|
+
}
|
|
129
|
+
return lines.join('\n') + '\n';
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Parses a .dev.vars file content into key-value pairs
|
|
133
|
+
* Handles comments, empty lines, and values with equals signs
|
|
134
|
+
*
|
|
135
|
+
* @param content - The file content to parse
|
|
136
|
+
* @returns Record of key-value pairs
|
|
137
|
+
*/
|
|
138
|
+
function parseDevVars(content) {
|
|
139
|
+
const result = {};
|
|
140
|
+
for (const line of content.split('\n')) {
|
|
141
|
+
const trimmed = line.trim();
|
|
142
|
+
// Skip empty lines and comments
|
|
143
|
+
if (!trimmed || trimmed.startsWith('#')) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
// Split on first equals sign only
|
|
147
|
+
const equalsIndex = trimmed.indexOf('=');
|
|
148
|
+
if (equalsIndex === -1) {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
const key = trimmed.substring(0, equalsIndex);
|
|
152
|
+
const value = trimmed.substring(equalsIndex + 1);
|
|
153
|
+
result[key] = value;
|
|
154
|
+
}
|
|
155
|
+
return result;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Loads .dev.vars file and returns key-value pairs
|
|
159
|
+
* - Warns about missing secrets but doesn't block
|
|
160
|
+
* - Returns empty object if file doesn't exist
|
|
161
|
+
*
|
|
162
|
+
* @param projectRoot - Path to the project root
|
|
163
|
+
* @param requiredSecrets - List of required secret names
|
|
164
|
+
* @returns Record of secret name to value
|
|
165
|
+
*/
|
|
166
|
+
export function loadDevVars(projectRoot, requiredSecrets) {
|
|
167
|
+
const devVarsPath = resolve(projectRoot, '.dev.vars');
|
|
168
|
+
if (!existsSync(devVarsPath)) {
|
|
169
|
+
return {};
|
|
170
|
+
}
|
|
171
|
+
const content = readFileSync(devVarsPath, 'utf8');
|
|
172
|
+
const vars = parseDevVars(content);
|
|
173
|
+
// Check for missing secrets
|
|
174
|
+
for (const secret of requiredSecrets) {
|
|
175
|
+
if (!(secret in vars)) {
|
|
176
|
+
console.warn(`Warning: Missing secret '${secret}' in .dev.vars. ` +
|
|
177
|
+
`Copy .dev.vars.example to .dev.vars and fill in the values.`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return vars;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Ensures types are up to date with bkper.yaml
|
|
184
|
+
* - Compares existing files with generated content
|
|
185
|
+
* - Warns and updates if mismatch detected
|
|
186
|
+
* - Creates files if they don't exist
|
|
187
|
+
*
|
|
188
|
+
* @param config - Deployment configuration
|
|
189
|
+
* @param projectRoot - Path to the project root
|
|
190
|
+
*/
|
|
191
|
+
export function ensureTypesUpToDate(config, projectRoot) {
|
|
192
|
+
const envDtsPath = resolve(projectRoot, 'env.d.ts');
|
|
193
|
+
const devVarsExamplePath = resolve(projectRoot, '.dev.vars.example');
|
|
194
|
+
// Generate expected content
|
|
195
|
+
const expectedEnvTypes = generateEnvTypes(config);
|
|
196
|
+
// Check and update env.d.ts
|
|
197
|
+
if (existsSync(envDtsPath)) {
|
|
198
|
+
const existingContent = readFileSync(envDtsPath, 'utf8');
|
|
199
|
+
if (existingContent !== expectedEnvTypes) {
|
|
200
|
+
console.warn('Warning: env.d.ts is out of sync with bkper.yaml. Updating...');
|
|
201
|
+
writeFileSync(envDtsPath, expectedEnvTypes);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
writeFileSync(envDtsPath, expectedEnvTypes);
|
|
206
|
+
}
|
|
207
|
+
// Only create .dev.vars.example if there are secrets
|
|
208
|
+
const hasSecrets = config.secrets && config.secrets.length > 0;
|
|
209
|
+
if (hasSecrets) {
|
|
210
|
+
const expectedDevVarsExample = generateDevVarsExample(config.secrets);
|
|
211
|
+
if (existsSync(devVarsExamplePath)) {
|
|
212
|
+
const existingContent = readFileSync(devVarsExamplePath, 'utf8');
|
|
213
|
+
if (existingContent !== expectedDevVarsExample) {
|
|
214
|
+
console.warn('Warning: .dev.vars.example is out of sync with bkper.yaml. Updating...');
|
|
215
|
+
writeFileSync(devVarsExamplePath, expectedDevVarsExample);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
writeFileSync(devVarsExamplePath, expectedDevVarsExample);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/dev/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAW/B;;GAEG;AACH,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6BhB,CAAC;AAEF;;;GAGG;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAwB;;IACrD,MAAM,KAAK,GAAa;QACpB,aAAa;QACb,gDAAgD;QAChD,qCAAqC;QACrC,EAAE;QACF,wBAAwB;KAC3B,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC;IAClE,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,C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AAY,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;QACzD,IAAI,eAAe,KAAK,gBAAgB,EAAE,CAAC;YACvC,OAAO,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;YAC9E,aAAa,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;QAChD,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,aAAa,CAAC,UAAU,EAAE,gBAAgB,CAAC,CAAC;IAChD,CAAC;IAED,qDAAqD;IACrD,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAC/D,IAAI,UAAU,EAAE,CAAC;QACb,MAAM,sBAAsB,GAAG,sBAAsB,CAAC,MAAM,CAAC,OAAQ,CAAC,CAAC;QAEvE,IAAI,UAAU,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACjC,MAAM,eAAe,GAAG,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAC;YACjE,IAAI,eAAe,KAAK,sBAAsB,EAAE,CAAC;gBAC7C,OAAO,CAAC,IAAI,CACR,wEAAwE,CAC3E,CAAC;gBACF,aAAa,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;YAC9D,CAAC;QACL,CAAC;aAAM,CAAC;YACJ,aAAa,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC;QAC9D,CAAC;IACL,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { ViteDevServer } from 'vite';
|
|
2
|
+
/**
|
|
3
|
+
* Options for creating a Vite client dev server
|
|
4
|
+
*/
|
|
5
|
+
export interface ClientServerOptions {
|
|
6
|
+
/** Port for the Vite dev server */
|
|
7
|
+
port: number;
|
|
8
|
+
/** Miniflare port for API proxy */
|
|
9
|
+
serverPort: number;
|
|
10
|
+
/** Whether to open browser on startup */
|
|
11
|
+
open?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options for building the client
|
|
15
|
+
*/
|
|
16
|
+
export interface ClientBuildOptions {
|
|
17
|
+
/** Output directory (absolute path recommended) */
|
|
18
|
+
outDir: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates and starts a Vite dev server for the client.
|
|
22
|
+
* Configures proxy to forward /api requests to Miniflare.
|
|
23
|
+
* Adds middleware to handle /auth/refresh for local development auth.
|
|
24
|
+
*
|
|
25
|
+
* @param root - Path to Vite project root (client directory)
|
|
26
|
+
* @param options - Server configuration options
|
|
27
|
+
* @returns Running Vite dev server instance
|
|
28
|
+
*/
|
|
29
|
+
export declare function createClientServer(root: string, options: ClientServerOptions): Promise<ViteDevServer>;
|
|
30
|
+
/**
|
|
31
|
+
* Builds the client for production.
|
|
32
|
+
*
|
|
33
|
+
* @param root - Path to Vite project root (client directory)
|
|
34
|
+
* @param options - Build configuration options
|
|
35
|
+
*/
|
|
36
|
+
export declare function buildClient(root: string, options: ClientBuildOptions): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Stops a Vite dev server.
|
|
39
|
+
*
|
|
40
|
+
* @param server - Vite dev server instance to stop
|
|
41
|
+
*/
|
|
42
|
+
export declare function stopClientServer(server: ViteDevServer): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Gets the resolved URL of a running Vite dev server.
|
|
45
|
+
*
|
|
46
|
+
* @param server - Running Vite dev server instance
|
|
47
|
+
* @returns The server URL (e.g., "http://localhost:5173")
|
|
48
|
+
*/
|
|
49
|
+
export declare function getServerUrl(server: ViteDevServer): string | undefined;
|
|
50
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/dev/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoC,aAAa,EAAU,MAAM,MAAM,CAAC;AAK/E;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,yCAAyC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;;GAQG;AACH,wBAAsB,kBAAkB,CACpC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,mBAAmB,GAC7B,OAAO,CAAC,aAAa,CAAC,CAiDxB;AAED;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAe1F;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAE3E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAGtE"}
|