@taskcast/cli 1.4.0 → 1.5.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/auto-migrate.d.ts +27 -0
- package/dist/auto-migrate.d.ts.map +1 -0
- package/dist/auto-migrate.js +66 -0
- package/dist/auto-migrate.js.map +1 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +21 -22
- package/dist/commands/migrate.js.map +1 -1
- package/dist/commands/start.d.ts +45 -0
- package/dist/commands/start.d.ts.map +1 -1
- package/dist/commands/start.js +139 -62
- package/dist/commands/start.js.map +1 -1
- package/dist/generated-migrations.d.ts +10 -0
- package/dist/generated-migrations.d.ts.map +1 -0
- package/dist/generated-migrations.js +15 -0
- package/dist/generated-migrations.js.map +1 -0
- package/dist/helpers.d.ts +11 -0
- package/dist/helpers.d.ts.map +1 -0
- package/dist/helpers.js +17 -0
- package/dist/helpers.js.map +1 -0
- package/dist/migrate-helpers.d.ts +6 -1
- package/dist/migrate-helpers.d.ts.map +1 -1
- package/dist/migrate-helpers.js +7 -2
- package/dist/migrate-helpers.js.map +1 -1
- package/package.json +20 -10
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type postgres from 'postgres';
|
|
2
|
+
/**
|
|
3
|
+
* Automatically run database migrations if enabled.
|
|
4
|
+
*
|
|
5
|
+
* This function checks two conditions:
|
|
6
|
+
* 1. TASKCAST_AUTO_MIGRATE env var is truthy (case-insensitive, parsed via parseBooleanEnv)
|
|
7
|
+
* 2. A Postgres connection was provided (`sql` is not undefined)
|
|
8
|
+
*
|
|
9
|
+
* If both are true, runs migrations and logs the result.
|
|
10
|
+
*
|
|
11
|
+
* Log messages (spec §Error Handling & Log Messages):
|
|
12
|
+
* - Banner (before running): `[taskcast] TASKCAST_AUTO_MIGRATE enabled — running Postgres migrations on <url>`
|
|
13
|
+
* - Skip (no Postgres): `[taskcast] TASKCAST_AUTO_MIGRATE is set but no Postgres configured — skipping`
|
|
14
|
+
* - Up to date: `[taskcast] Database schema up to date (<N> migration(s) already applied)`
|
|
15
|
+
* - Applied: `[taskcast] Applied <N> new migration(s): <filename1>, <filename2>, ...`
|
|
16
|
+
* - Failure: `[taskcast] Auto-migration failed: <error_message>`
|
|
17
|
+
*
|
|
18
|
+
* All messages go to stderr (console.error / eprintln!) to match the Rust
|
|
19
|
+
* implementation's convention and keep stdout clean for machine-readable output.
|
|
20
|
+
*
|
|
21
|
+
* @param sql - Postgres connection instance, or undefined if Postgres is not configured
|
|
22
|
+
* @param postgresUrl - Resolved Postgres URL (for log banner), or undefined
|
|
23
|
+
* @param env - Environment variables (defaults to process.env for testability)
|
|
24
|
+
* @throws Error with message "Auto-migration failed: <original_error>" if migration fails
|
|
25
|
+
*/
|
|
26
|
+
export declare function performAutoMigrateIfEnabled(sql: ReturnType<typeof postgres> | undefined, postgresUrl: string | undefined, env?: Record<string, string | undefined>): Promise<void>;
|
|
27
|
+
//# sourceMappingURL=auto-migrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-migrate.d.ts","sourceRoot":"","sources":["../src/auto-migrate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAA;AAMpC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,GAAG,SAAS,EAC5C,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,OAAO,CAAC,IAAI,CAAC,CA0Cf"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { buildMigrationFiles, runMigrations } from '@taskcast/postgres';
|
|
2
|
+
import { parseBooleanEnv } from './helpers.js';
|
|
3
|
+
import { EMBEDDED_MIGRATIONS } from './generated-migrations.js';
|
|
4
|
+
import { formatDisplayUrl } from './migrate-helpers.js';
|
|
5
|
+
/**
|
|
6
|
+
* Automatically run database migrations if enabled.
|
|
7
|
+
*
|
|
8
|
+
* This function checks two conditions:
|
|
9
|
+
* 1. TASKCAST_AUTO_MIGRATE env var is truthy (case-insensitive, parsed via parseBooleanEnv)
|
|
10
|
+
* 2. A Postgres connection was provided (`sql` is not undefined)
|
|
11
|
+
*
|
|
12
|
+
* If both are true, runs migrations and logs the result.
|
|
13
|
+
*
|
|
14
|
+
* Log messages (spec §Error Handling & Log Messages):
|
|
15
|
+
* - Banner (before running): `[taskcast] TASKCAST_AUTO_MIGRATE enabled — running Postgres migrations on <url>`
|
|
16
|
+
* - Skip (no Postgres): `[taskcast] TASKCAST_AUTO_MIGRATE is set but no Postgres configured — skipping`
|
|
17
|
+
* - Up to date: `[taskcast] Database schema up to date (<N> migration(s) already applied)`
|
|
18
|
+
* - Applied: `[taskcast] Applied <N> new migration(s): <filename1>, <filename2>, ...`
|
|
19
|
+
* - Failure: `[taskcast] Auto-migration failed: <error_message>`
|
|
20
|
+
*
|
|
21
|
+
* All messages go to stderr (console.error / eprintln!) to match the Rust
|
|
22
|
+
* implementation's convention and keep stdout clean for machine-readable output.
|
|
23
|
+
*
|
|
24
|
+
* @param sql - Postgres connection instance, or undefined if Postgres is not configured
|
|
25
|
+
* @param postgresUrl - Resolved Postgres URL (for log banner), or undefined
|
|
26
|
+
* @param env - Environment variables (defaults to process.env for testability)
|
|
27
|
+
* @throws Error with message "Auto-migration failed: <original_error>" if migration fails
|
|
28
|
+
*/
|
|
29
|
+
export async function performAutoMigrateIfEnabled(sql, postgresUrl, env = process.env) {
|
|
30
|
+
// Check if auto-migrate is enabled
|
|
31
|
+
const autoMigrateEnabled = parseBooleanEnv(env['TASKCAST_AUTO_MIGRATE']);
|
|
32
|
+
if (!autoMigrateEnabled) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
// Check if Postgres is actually configured (by the presence of an sql connection).
|
|
36
|
+
// The env var TASKCAST_POSTGRES_URL alone is insufficient because users may
|
|
37
|
+
// configure Postgres via the YAML config file only.
|
|
38
|
+
if (!sql) {
|
|
39
|
+
console.error('[taskcast] TASKCAST_AUTO_MIGRATE is set but no Postgres configured — skipping');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// Log banner with display URL (credentials stripped).
|
|
43
|
+
// The raw postgresUrl may contain a password (e.g. postgres://user:pass@host/db)
|
|
44
|
+
// which must not be emitted to stderr where it could leak into log aggregators.
|
|
45
|
+
const urlDisplay = postgresUrl ? formatDisplayUrl(postgresUrl) : '<postgres>';
|
|
46
|
+
console.error(`[taskcast] TASKCAST_AUTO_MIGRATE enabled — running Postgres migrations on ${urlDisplay}`);
|
|
47
|
+
// Run migrations
|
|
48
|
+
try {
|
|
49
|
+
const result = await runMigrations(sql, buildMigrationFiles(EMBEDDED_MIGRATIONS));
|
|
50
|
+
if (result.applied.length === 0) {
|
|
51
|
+
console.error(`[taskcast] Database schema up to date (${result.skipped.length} migration(s) already applied)`);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.error(`[taskcast] Applied ${result.applied.length} new migration(s): ${result.applied.join(', ')}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
59
|
+
// Do NOT log here — the caller (registerStartCommand's .action() wrapper
|
|
60
|
+
// or the Rust/TS test harness) is responsible for the single user-facing
|
|
61
|
+
// [taskcast] Auto-migration failed: ... line. Logging here would produce
|
|
62
|
+
// a duplicate when the error propagates up.
|
|
63
|
+
throw new Error(`Auto-migration failed: ${errorMessage}`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=auto-migrate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-migrate.js","sourceRoot":"","sources":["../src/auto-migrate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,a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C,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC7F,CAAA;QACH,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,YAAY,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QACrE,yEAAyE;QACzE,yEAAyE;QACzE,yEAAyE;QACzE,4CAA4C;QAC5C,MAAM,IAAI,KAAK,CAAC,0BAA0B,YAAY,EAAE,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAQnC,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAmF7D"}
|
package/dist/commands/migrate.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import postgres from 'postgres';
|
|
2
|
-
import { join, dirname } from 'path';
|
|
3
|
-
import { fileURLToPath } from 'url';
|
|
4
2
|
import { loadConfigFile } from '@taskcast/core';
|
|
5
|
-
import {
|
|
3
|
+
import { buildMigrationFiles, runMigrations } from '@taskcast/postgres';
|
|
4
|
+
import { EMBEDDED_MIGRATIONS } from '../generated-migrations.js';
|
|
6
5
|
import { resolvePostgresUrl, formatDisplayUrl } from '../migrate-helpers.js';
|
|
7
6
|
import { promptConfirm } from '../utils.js';
|
|
8
7
|
export function registerMigrateCommand(program) {
|
|
@@ -25,26 +24,26 @@ export function registerMigrateCommand(program) {
|
|
|
25
24
|
process.exit(1);
|
|
26
25
|
}
|
|
27
26
|
const target = formatDisplayUrl(pgUrl);
|
|
28
|
-
// TODO: This path works in the monorepo only. For npm publishing,
|
|
29
|
-
// migrations would need to be bundled with the package.
|
|
30
|
-
const migrationsDir = join(dirname(fileURLToPath(import.meta.url)), '../../../../migrations/postgres');
|
|
31
27
|
const sql = postgres(pgUrl);
|
|
32
28
|
try {
|
|
33
|
-
//
|
|
34
|
-
const allFiles =
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
29
|
+
// Build migration files from embedded migrations
|
|
30
|
+
const allFiles = buildMigrationFiles(EMBEDDED_MIGRATIONS);
|
|
31
|
+
// Query already-applied versions from the tracking table.
|
|
32
|
+
// If the table does not exist yet, treat all migrations as pending.
|
|
33
|
+
// (runMigrations() below will create the table idempotently — we do
|
|
34
|
+
// not duplicate the CREATE TABLE schema here to avoid drift.)
|
|
35
|
+
let appliedVersions = new Set();
|
|
36
|
+
try {
|
|
37
|
+
const appliedRows = await sql.unsafe('SELECT version FROM _sqlx_migrations WHERE success = true');
|
|
38
|
+
appliedVersions = new Set(appliedRows.map((r) => Number(r['version'])));
|
|
39
|
+
}
|
|
40
|
+
catch (err) {
|
|
41
|
+
const code = err.code;
|
|
42
|
+
// 42P01 = undefined_table (table doesn't exist yet — first-time migration)
|
|
43
|
+
if (code !== '42P01') {
|
|
44
|
+
throw err;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
48
47
|
const pending = allFiles.filter((f) => !appliedVersions.has(f.version));
|
|
49
48
|
if (pending.length === 0) {
|
|
50
49
|
console.log('[taskcast] Database is up to date.');
|
|
@@ -66,7 +65,7 @@ export function registerMigrateCommand(program) {
|
|
|
66
65
|
return;
|
|
67
66
|
}
|
|
68
67
|
}
|
|
69
|
-
const result = await runMigrations(sql,
|
|
68
|
+
const result = await runMigrations(sql, allFiles);
|
|
70
69
|
for (const filename of result.applied) {
|
|
71
70
|
console.log(` Applied ${filename}`);
|
|
72
71
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AACA,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,OAAO;SACJ,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,mCAAmC,CAAC;SAChD,MAAM,CAAC,aAAa,EAAE,4CAA4C,CAAC;SACnE,MAAM,CAAC,qBAAqB,EAAE,kBAAkB,CAAC;SACjD,MAAM,CAAC,WAAW,EAAE,0BAA0B,CAAC;SAC/C,MAAM,CAAC,KAAK,EAAE,OAAyD,EAAE,EAAE;QAC1E,8DAA8D;QAC9D,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,cAAc,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QACnE,MAAM,KAAK,GAAG,kBAAkB,CAAC;YAC/B,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC;YAC5C,SAAS,EAAE,UAAU,CAAC,QAAQ,EAA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C,CAAC,CAAA;AACN,CAAC"}
|
package/dist/commands/start.d.ts
CHANGED
|
@@ -1,3 +1,48 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import postgres from 'postgres';
|
|
3
|
+
import type { BroadcastProvider, ShortTermStore, LongTermStore, TaskcastConfig } from '@taskcast/core';
|
|
4
|
+
/**
|
|
5
|
+
* Options for runStart function.
|
|
6
|
+
* Captures all server startup configuration.
|
|
7
|
+
*/
|
|
8
|
+
export interface RunStartOptions {
|
|
9
|
+
/** Postgres connection instance (optional) */
|
|
10
|
+
postgres?: ReturnType<typeof postgres>;
|
|
11
|
+
/** Resolved Postgres URL (for auto-migrate banner log), required if postgres is set */
|
|
12
|
+
postgresUrl?: string;
|
|
13
|
+
/** Broadcast provider instance */
|
|
14
|
+
broadcast: BroadcastProvider;
|
|
15
|
+
/** Short-term store instance */
|
|
16
|
+
shortTermStore: ShortTermStore;
|
|
17
|
+
/** Long-term store instance (optional) */
|
|
18
|
+
longTermStore?: LongTermStore;
|
|
19
|
+
/** Port to listen on */
|
|
20
|
+
port: number;
|
|
21
|
+
/** Server configuration options */
|
|
22
|
+
config: TaskcastConfig;
|
|
23
|
+
/** Verbose logging flag */
|
|
24
|
+
verbose: boolean;
|
|
25
|
+
/** Playground flag */
|
|
26
|
+
playground: boolean;
|
|
27
|
+
/** File config path for display */
|
|
28
|
+
configPath?: string;
|
|
29
|
+
/** Environment variables for auto-migrate */
|
|
30
|
+
env?: Record<string, string | undefined>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Runs the taskcast server with auto-migrate support.
|
|
34
|
+
*
|
|
35
|
+
* This function:
|
|
36
|
+
* 1. Calls performAutoMigrateIfEnabled() if Postgres is configured
|
|
37
|
+
* 2. Creates and starts the server
|
|
38
|
+
* 3. Sets up SIGTERM/SIGINT handlers
|
|
39
|
+
* 4. Serves playground UI if enabled
|
|
40
|
+
*
|
|
41
|
+
* If auto-migrate fails, the error is re-thrown and server startup is blocked.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Server startup options
|
|
44
|
+
* @throws Error if auto-migrate fails
|
|
45
|
+
*/
|
|
46
|
+
export declare function runStart(options: RunStartOptions): Promise<void>;
|
|
2
47
|
export declare function registerStartCommand(program: Command): void;
|
|
3
48
|
//# sourceMappingURL=start.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAY/B,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AA4BtG;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAA;IACtC,uFAAuF;IACvF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kCAAkC;IAClC,SAAS,EAAE,iBAAiB,CAAA;IAC5B,gCAAgC;IAChC,cAAc,EAAE,cAAc,CAAA;IAC9B,0CAA0C;IAC1C,aAAa,CAAC,EAAE,aAAa,CAAA;IAC7B,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,mCAAmC;IACnC,MAAM,EAAE,cAAc,CAAA;IACtB,2BAA2B;IAC3B,OAAO,EAAE,OAAO,CAAA;IAChB,sBAAsB;IACtB,UAAU,EAAE,OAAO,CAAA;IACnB,mCAAmC;IACnC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,6CAA6C;IAC7C,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAA;CACzC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,QAAQ,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAyEtE;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkH3D"}
|
package/dist/commands/start.js
CHANGED
|
@@ -9,6 +9,113 @@ import { createRedisAdapters } from '@taskcast/redis';
|
|
|
9
9
|
import { PostgresLongTermStore } from '@taskcast/postgres';
|
|
10
10
|
import { createSqliteAdapters } from '@taskcast/sqlite';
|
|
11
11
|
import { promptCreateGlobalConfig, createDefaultGlobalConfig } from '../utils.js';
|
|
12
|
+
import { performAutoMigrateIfEnabled } from '../auto-migrate.js';
|
|
13
|
+
import { formatDisplayUrl } from '../migrate-helpers.js';
|
|
14
|
+
/**
|
|
15
|
+
* Strip credentials from a connection URL (Redis/Postgres/etc.) for logging.
|
|
16
|
+
* Returns `scheme://host:port/path` with no userinfo. Falls back to the raw
|
|
17
|
+
* string only when parsing fails AND the fallback does not contain an `@`
|
|
18
|
+
* (which would indicate embedded credentials). When credentials are present
|
|
19
|
+
* and parsing fails, returns '<redacted>' to avoid leaking secrets.
|
|
20
|
+
*/
|
|
21
|
+
function formatConnectionUrlForLog(url) {
|
|
22
|
+
try {
|
|
23
|
+
const parsed = new URL(url);
|
|
24
|
+
parsed.username = '';
|
|
25
|
+
parsed.password = '';
|
|
26
|
+
return parsed.toString();
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
29
|
+
// Parse failed. Only return the raw string if it clearly contains no creds.
|
|
30
|
+
return url.includes('@') ? '<redacted>' : url;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs the taskcast server with auto-migrate support.
|
|
35
|
+
*
|
|
36
|
+
* This function:
|
|
37
|
+
* 1. Calls performAutoMigrateIfEnabled() if Postgres is configured
|
|
38
|
+
* 2. Creates and starts the server
|
|
39
|
+
* 3. Sets up SIGTERM/SIGINT handlers
|
|
40
|
+
* 4. Serves playground UI if enabled
|
|
41
|
+
*
|
|
42
|
+
* If auto-migrate fails, the error is re-thrown and server startup is blocked.
|
|
43
|
+
*
|
|
44
|
+
* @param options - Server startup options
|
|
45
|
+
* @throws Error if auto-migrate fails
|
|
46
|
+
*/
|
|
47
|
+
export async function runStart(options) {
|
|
48
|
+
// Call auto-migrate (no-op if not enabled or no Postgres).
|
|
49
|
+
// Pass the actual sql connection so the helper can detect "configured via
|
|
50
|
+
// config file" scenarios where TASKCAST_POSTGRES_URL env var is not set.
|
|
51
|
+
await performAutoMigrateIfEnabled(options.postgres, options.postgresUrl, options.env);
|
|
52
|
+
const engineOpts = {
|
|
53
|
+
shortTermStore: options.shortTermStore,
|
|
54
|
+
broadcast: options.broadcast,
|
|
55
|
+
};
|
|
56
|
+
if (options.longTermStore !== undefined)
|
|
57
|
+
engineOpts.longTermStore = options.longTermStore;
|
|
58
|
+
const engine = new TaskEngine(engineOpts);
|
|
59
|
+
const authMode = (process.env['TASKCAST_AUTH_MODE'] ?? options.config.auth?.mode ?? 'none');
|
|
60
|
+
// Worker assignment system
|
|
61
|
+
const workersEnabled = options.config.workers?.enabled ?? false;
|
|
62
|
+
let workerManager;
|
|
63
|
+
if (workersEnabled) {
|
|
64
|
+
console.log('[taskcast] Worker assignment system enabled');
|
|
65
|
+
const wmOpts = {
|
|
66
|
+
engine,
|
|
67
|
+
shortTermStore: options.shortTermStore,
|
|
68
|
+
broadcast: options.broadcast,
|
|
69
|
+
};
|
|
70
|
+
if (options.longTermStore !== undefined)
|
|
71
|
+
wmOpts.longTermStore = options.longTermStore;
|
|
72
|
+
if (options.config.workers?.defaults)
|
|
73
|
+
wmOpts.defaults = options.config.workers.defaults;
|
|
74
|
+
workerManager = new WorkerManager(wmOpts);
|
|
75
|
+
}
|
|
76
|
+
// Resolve admin token (auto-generate + print if adminApi is enabled)
|
|
77
|
+
resolveAdminToken(options.config);
|
|
78
|
+
const serverOpts = {
|
|
79
|
+
engine,
|
|
80
|
+
shortTermStore: options.shortTermStore,
|
|
81
|
+
auth: { mode: authMode },
|
|
82
|
+
config: options.config,
|
|
83
|
+
verbose: options.verbose,
|
|
84
|
+
};
|
|
85
|
+
if (workerManager !== undefined)
|
|
86
|
+
serverOpts.workerManager = workerManager;
|
|
87
|
+
const { app, stop } = createTaskcastApp(serverOpts);
|
|
88
|
+
// Serve playground static files if enabled and dist exists
|
|
89
|
+
if (options.playground) {
|
|
90
|
+
try {
|
|
91
|
+
const require = createRequire(import.meta.url);
|
|
92
|
+
const pkgPath = require.resolve('@taskcast/playground/package.json');
|
|
93
|
+
const distDir = join(dirname(pkgPath), 'dist');
|
|
94
|
+
if (existsSync(distDir)) {
|
|
95
|
+
const { serveStatic } = await import('@hono/node-server/serve-static');
|
|
96
|
+
app.use('/_playground/*', serveStatic({ root: distDir, rewriteRequestPath: (p) => p.replace(/^\/_playground/, '') }));
|
|
97
|
+
// SPA fallback: serve index.html for non-asset paths
|
|
98
|
+
app.get('/_playground/*', serveStatic({ root: distDir, rewriteRequestPath: () => '/index.html' }));
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
console.warn('[taskcast] Playground dist not found. Run `pnpm --filter @taskcast/playground build` first.');
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
console.warn('[taskcast] @taskcast/playground not available, skipping playground UI.');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const { serve } = await import('@hono/node-server');
|
|
109
|
+
const server = serve({ fetch: app.fetch, port: options.port }, () => {
|
|
110
|
+
console.log(`[taskcast] Server started on http://localhost:${options.port}`);
|
|
111
|
+
if (options.playground) {
|
|
112
|
+
console.log(`[taskcast] Playground UI at http://localhost:${options.port}/_playground/`);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
// Clean up scheduler/heartbeat on shutdown
|
|
116
|
+
process.on('SIGTERM', () => { stop(); server.close?.(); });
|
|
117
|
+
process.on('SIGINT', () => { stop(); server.close?.(); });
|
|
118
|
+
}
|
|
12
119
|
export function registerStartCommand(program) {
|
|
13
120
|
program
|
|
14
121
|
.command('start', { isDefault: true })
|
|
@@ -39,6 +146,7 @@ export function registerStartCommand(program) {
|
|
|
39
146
|
let shortTermStore;
|
|
40
147
|
let broadcast;
|
|
41
148
|
let longTermStore;
|
|
149
|
+
let postgres_;
|
|
42
150
|
const storage = options.storage ?? process.env['TASKCAST_STORAGE'] ?? (redisUrl ? 'redis' : 'memory');
|
|
43
151
|
let shortTermLabel;
|
|
44
152
|
let longTermLabel;
|
|
@@ -59,7 +167,9 @@ export function registerStartCommand(program) {
|
|
|
59
167
|
const adapters = createRedisAdapters(pubClient, subClient, storeClient);
|
|
60
168
|
broadcast = adapters.broadcast;
|
|
61
169
|
shortTermStore = adapters.shortTermStore;
|
|
62
|
-
|
|
170
|
+
// Strip any userinfo from the displayed URL so credentials don't land
|
|
171
|
+
// in stdout / log aggregators.
|
|
172
|
+
shortTermLabel = `redis @ ${formatConnectionUrlForLog(redisUrl)}`;
|
|
63
173
|
longTermLabel = '(none)';
|
|
64
174
|
}
|
|
65
175
|
else {
|
|
@@ -69,77 +179,44 @@ export function registerStartCommand(program) {
|
|
|
69
179
|
longTermLabel = '(none)';
|
|
70
180
|
}
|
|
71
181
|
if (storage !== 'sqlite' && postgresUrl) {
|
|
72
|
-
|
|
73
|
-
longTermStore = new PostgresLongTermStore(
|
|
74
|
-
|
|
182
|
+
postgres_ = postgres(postgresUrl);
|
|
183
|
+
longTermStore = new PostgresLongTermStore(postgres_);
|
|
184
|
+
// formatDisplayUrl returns host:port/dbname — credentials stripped.
|
|
185
|
+
longTermLabel = `postgres @ ${formatDisplayUrl(postgresUrl)}`;
|
|
75
186
|
}
|
|
76
187
|
// Print startup configuration summary
|
|
77
188
|
console.log(`[taskcast] Config: ${configPath ?? '(none)'}`);
|
|
78
189
|
console.log(`[taskcast] Short-term store: ${shortTermLabel}`);
|
|
79
190
|
console.log(`[taskcast] Long-term store: ${longTermLabel}`);
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const engine = new TaskEngine(engineOpts);
|
|
84
|
-
const authMode = (process.env['TASKCAST_AUTH_MODE'] ?? fileConfig.auth?.mode ?? 'none');
|
|
85
|
-
// Worker assignment system
|
|
86
|
-
const workersEnabled = fileConfig.workers?.enabled ?? false;
|
|
87
|
-
let workerManager;
|
|
88
|
-
if (workersEnabled) {
|
|
89
|
-
console.log('[taskcast] Worker assignment system enabled');
|
|
90
|
-
const wmOpts = {
|
|
91
|
-
engine,
|
|
92
|
-
shortTermStore,
|
|
93
|
-
broadcast,
|
|
94
|
-
};
|
|
95
|
-
if (longTermStore !== undefined)
|
|
96
|
-
wmOpts.longTermStore = longTermStore;
|
|
97
|
-
if (fileConfig.workers?.defaults)
|
|
98
|
-
wmOpts.defaults = fileConfig.workers.defaults;
|
|
99
|
-
workerManager = new WorkerManager(wmOpts);
|
|
100
|
-
}
|
|
101
|
-
// Resolve admin token (auto-generate + print if adminApi is enabled)
|
|
102
|
-
resolveAdminToken(fileConfig);
|
|
103
|
-
const serverOpts = {
|
|
104
|
-
engine,
|
|
191
|
+
// Call runStart with resolved options
|
|
192
|
+
const runStartOptions = {
|
|
193
|
+
broadcast,
|
|
105
194
|
shortTermStore,
|
|
106
|
-
|
|
195
|
+
port,
|
|
107
196
|
config: fileConfig,
|
|
108
197
|
verbose: options.verbose ?? false,
|
|
198
|
+
playground: options.playground ?? false,
|
|
109
199
|
};
|
|
110
|
-
if (
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
if (
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
catch {
|
|
130
|
-
console.warn('[taskcast] @taskcast/playground not available, skipping playground UI.');
|
|
131
|
-
}
|
|
200
|
+
if (postgres_ !== undefined)
|
|
201
|
+
runStartOptions.postgres = postgres_;
|
|
202
|
+
if (postgresUrl !== undefined)
|
|
203
|
+
runStartOptions.postgresUrl = postgresUrl;
|
|
204
|
+
if (longTermStore !== undefined)
|
|
205
|
+
runStartOptions.longTermStore = longTermStore;
|
|
206
|
+
if (configPath !== undefined)
|
|
207
|
+
runStartOptions.configPath = configPath;
|
|
208
|
+
runStartOptions.env = process.env;
|
|
209
|
+
// Fail-fast: auto-migrate errors (and any other runStart errors) should
|
|
210
|
+
// produce a clean user-facing message and non-zero exit, not an unhandled
|
|
211
|
+
// rejection from Commander.
|
|
212
|
+
try {
|
|
213
|
+
await runStart(runStartOptions);
|
|
214
|
+
}
|
|
215
|
+
catch (err) {
|
|
216
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
217
|
+
console.error(`[taskcast] ${msg}`);
|
|
218
|
+
process.exit(1);
|
|
132
219
|
}
|
|
133
|
-
const { serve } = await import('@hono/node-server');
|
|
134
|
-
const server = serve({ fetch: app.fetch, port }, () => {
|
|
135
|
-
console.log(`[taskcast] Server started on http://localhost:${port}`);
|
|
136
|
-
if (options.playground) {
|
|
137
|
-
console.log(`[taskcast] Playground UI at http://localhost:${port}/_playground/`);
|
|
138
|
-
}
|
|
139
|
-
});
|
|
140
|
-
// Clean up scheduler/heartbeat on shutdown
|
|
141
|
-
process.on('SIGTERM', () => { stop(); server.close?.(); });
|
|
142
|
-
process.on('SIGINT', () => { stop(); server.close?.(); });
|
|
143
220
|
});
|
|
144
221
|
}
|
|
145
222
|
//# sourceMappingURL=start.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,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aAAa,EAAE,CAAC,CAAA;QAE5D,sCAAsC;QACtC,MAAM,eAAe,GASjB;YACF,SAAS;YACT,cAAc;YACd,IAAI;YACJ,MAAM,EAAE,UAAU;YAClB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,KAAK;YACjC,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,KAAK;SACxC,CAAA;QACD,IAAI,SAAS,KAAK,SAAS;YAAE,eAAe,CAAC,QAAQ,GAAG,SAAS,CAAA;QACjE,IAAI,WAAW,KAAK,SAAS;YAAE,eAAe,CAAC,WAAW,GAAG,WAAW,CAAA;QACxE,IAAI,aAAa,KAAK,SAAS;YAAE,eAAe,CAAC,aAAa,GAAG,aAAa,CAAA;QAC9E,IAAI,UAAU,KAAK,SAAS;YAAE,eAAe,CAAC,UAAU,GAAG,UAAU,CAAA;QACrE,eAAe,CAAC,GAAG,GAAG,OAAO,CAAC,GAAyC,CAAA;QAEvE,wEAAwE;QACxE,0EAA0E;QAC1E,4BAA4B;QAC5B,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,eAAkC,CAAC,CAAA;QACpD,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,MAAM,GAAG,GAAG,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YAC5D,OAAO,CAAC,KAAK,CAAC,cAAc,GAAG,EAAE,CAAC,CAAA;YAClC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;QACjB,CAAC;IACH,CAAC,CAAC,CAAA;AACN,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated migration embeddings.
|
|
3
|
+
* Do not edit manually — run: pnpm generate-migrations
|
|
4
|
+
*/
|
|
5
|
+
export interface EmbeddedMigration {
|
|
6
|
+
filename: string;
|
|
7
|
+
sql: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const EMBEDDED_MIGRATIONS: readonly EmbeddedMigration[];
|
|
10
|
+
//# sourceMappingURL=generated-migrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-migrations.d.ts","sourceRoot":"","sources":["../src/generated-migrations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAA;IAChB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,eAAO,MAAM,mBAAmB,EAAE,SAAS,iBAAiB,EAS3D,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Auto-generated migration embeddings.
|
|
3
|
+
* Do not edit manually — run: pnpm generate-migrations
|
|
4
|
+
*/
|
|
5
|
+
export const EMBEDDED_MIGRATIONS = [
|
|
6
|
+
{
|
|
7
|
+
filename: "001_initial.sql",
|
|
8
|
+
sql: "CREATE TABLE IF NOT EXISTS taskcast_tasks (\n id TEXT PRIMARY KEY,\n type TEXT,\n status TEXT NOT NULL,\n params JSONB,\n result JSONB,\n error JSONB,\n metadata JSONB,\n auth_config JSONB,\n webhooks JSONB,\n cleanup JSONB,\n created_at BIGINT NOT NULL,\n updated_at BIGINT NOT NULL,\n completed_at BIGINT,\n ttl INTEGER\n);\n\nCREATE TABLE IF NOT EXISTS taskcast_events (\n id TEXT PRIMARY KEY,\n task_id TEXT NOT NULL REFERENCES taskcast_tasks(id) ON DELETE CASCADE,\n idx INTEGER NOT NULL,\n timestamp BIGINT NOT NULL,\n type TEXT NOT NULL,\n level TEXT NOT NULL,\n data JSONB,\n series_id TEXT,\n series_mode TEXT,\n series_acc_field TEXT,\n UNIQUE(task_id, idx)\n);\n\nCREATE INDEX IF NOT EXISTS taskcast_events_task_id_idx ON taskcast_events(task_id, idx);\nCREATE INDEX IF NOT EXISTS taskcast_events_task_id_timestamp ON taskcast_events(task_id, timestamp);\n",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
filename: "002_workers.sql",
|
|
12
|
+
sql: "-- Worker audit events table\nCREATE TABLE IF NOT EXISTS taskcast_worker_events (\n id TEXT PRIMARY KEY,\n worker_id TEXT NOT NULL,\n timestamp BIGINT NOT NULL,\n action TEXT NOT NULL,\n data JSONB,\n created_at TIMESTAMPTZ DEFAULT now()\n);\n\nCREATE INDEX IF NOT EXISTS idx_taskcast_worker_events_worker_id\n ON taskcast_worker_events (worker_id, timestamp DESC);\n\n-- New Task columns for worker assignment\nALTER TABLE taskcast_tasks ADD COLUMN IF NOT EXISTS tags JSONB;\nALTER TABLE taskcast_tasks ADD COLUMN IF NOT EXISTS assign_mode TEXT;\nALTER TABLE taskcast_tasks ADD COLUMN IF NOT EXISTS cost INTEGER;\nALTER TABLE taskcast_tasks ADD COLUMN IF NOT EXISTS assigned_worker TEXT;\nALTER TABLE taskcast_tasks ADD COLUMN IF NOT EXISTS disconnect_policy TEXT;\n",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=generated-migrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generated-migrations.js","sourceRoot":"","sources":["../src/generated-migrations.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,MAAM,CAAC,MAAM,mBAAmB,GAAiC;IAC/D;QACE,QAAQ,EAAE,iBAAiB;QAC3B,GAAG,EAAE,83BAA83B;KACp4B;IACD;QACE,QAAQ,EAAE,iBAAiB;QAC3B,GAAG,EAAE,wwBAAwwB;KAC9wB;CACF,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a boolean environment variable.
|
|
3
|
+
*
|
|
4
|
+
* Recognizes truthy values: "1", "true", "yes", "on" (case-insensitive, trimmed).
|
|
5
|
+
* Recognizes falsy values: "0", "false", "no", "off", "", and undefined.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The string value to parse, or undefined
|
|
8
|
+
* @returns true if value matches a truthy string, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseBooleanEnv(value: string | undefined): boolean;
|
|
11
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAQlE"}
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a boolean environment variable.
|
|
3
|
+
*
|
|
4
|
+
* Recognizes truthy values: "1", "true", "yes", "on" (case-insensitive, trimmed).
|
|
5
|
+
* Recognizes falsy values: "0", "false", "no", "off", "", and undefined.
|
|
6
|
+
*
|
|
7
|
+
* @param value - The string value to parse, or undefined
|
|
8
|
+
* @returns true if value matches a truthy string, false otherwise
|
|
9
|
+
*/
|
|
10
|
+
export function parseBooleanEnv(value) {
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
14
|
+
const trimmed = value.trim().toLowerCase();
|
|
15
|
+
return trimmed === '1' || trimmed === 'true' || trimmed === 'yes' || trimmed === 'on';
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,KAAyB;IACvD,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;IAE1C,OAAO,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,KAAK,IAAI,OAAO,KAAK,IAAI,CAAA;AACvF,CAAC"}
|
|
@@ -11,7 +11,12 @@ export declare function resolvePostgresUrl(options: {
|
|
|
11
11
|
/**
|
|
12
12
|
* Format a Postgres URL for display, stripping credentials.
|
|
13
13
|
*
|
|
14
|
-
* Returns `host:port/dbname`.
|
|
14
|
+
* Returns `host:port/dbname`. On parse failure:
|
|
15
|
+
* - returns `<redacted>` if the raw string contains `@` (which indicates
|
|
16
|
+
* possible embedded credentials), so a malformed URL can never leak
|
|
17
|
+
* user:pass into a log line;
|
|
18
|
+
* - otherwise returns the raw string unchanged, which is safe because it
|
|
19
|
+
* cannot contain userinfo.
|
|
15
20
|
*/
|
|
16
21
|
export declare function formatDisplayUrl(pgUrl: string): string;
|
|
17
22
|
//# sourceMappingURL=migrate-helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-helpers.d.ts","sourceRoot":"","sources":["../src/migrate-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B,GAAG,MAAM,GAAG,SAAS,CAErB;AAED
|
|
1
|
+
{"version":3,"file":"migrate-helpers.d.ts","sourceRoot":"","sources":["../src/migrate-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE;IAC1C,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IACxB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAC/B,GAAG,MAAM,GAAG,SAAS,CAErB;AAED;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAQtD"}
|
package/dist/migrate-helpers.js
CHANGED
|
@@ -9,7 +9,12 @@ export function resolvePostgresUrl(options) {
|
|
|
9
9
|
/**
|
|
10
10
|
* Format a Postgres URL for display, stripping credentials.
|
|
11
11
|
*
|
|
12
|
-
* Returns `host:port/dbname`.
|
|
12
|
+
* Returns `host:port/dbname`. On parse failure:
|
|
13
|
+
* - returns `<redacted>` if the raw string contains `@` (which indicates
|
|
14
|
+
* possible embedded credentials), so a malformed URL can never leak
|
|
15
|
+
* user:pass into a log line;
|
|
16
|
+
* - otherwise returns the raw string unchanged, which is safe because it
|
|
17
|
+
* cannot contain userinfo.
|
|
13
18
|
*/
|
|
14
19
|
export function formatDisplayUrl(pgUrl) {
|
|
15
20
|
try {
|
|
@@ -18,7 +23,7 @@ export function formatDisplayUrl(pgUrl) {
|
|
|
18
23
|
return `${parsed.hostname}:${parsed.port || '5432'}/${dbname}`;
|
|
19
24
|
}
|
|
20
25
|
catch {
|
|
21
|
-
return pgUrl;
|
|
26
|
+
return pgUrl.includes('@') ? '<redacted>' : pgUrl;
|
|
22
27
|
}
|
|
23
28
|
}
|
|
24
29
|
//# sourceMappingURL=migrate-helpers.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-helpers.js","sourceRoot":"","sources":["../src/migrate-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAIlC;IACC,OAAO,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,CAAA;AAC3D,CAAC;AAED
|
|
1
|
+
{"version":3,"file":"migrate-helpers.js","sourceRoot":"","sources":["../src/migrate-helpers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAIlC;IACC,OAAO,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,SAAS,CAAA;AAC3D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,gBAAgB,CAAC,KAAa;IAC5C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAA;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,UAAU,CAAA;QAC/D,OAAO,GAAG,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,IAAI,MAAM,EAAE,CAAA;IAChE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,KAAK,CAAA;IACnD,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskcast/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "Standalone Taskcast server CLI — run with npx taskcast.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,6 +25,14 @@
|
|
|
25
25
|
".": {
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
27
|
"import": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./helpers": {
|
|
30
|
+
"types": "./dist/helpers.d.ts",
|
|
31
|
+
"import": "./dist/helpers.js"
|
|
32
|
+
},
|
|
33
|
+
"./auto-migrate": {
|
|
34
|
+
"types": "./dist/auto-migrate.d.ts",
|
|
35
|
+
"import": "./dist/auto-migrate.js"
|
|
28
36
|
}
|
|
29
37
|
},
|
|
30
38
|
"publishConfig": {
|
|
@@ -37,16 +45,17 @@
|
|
|
37
45
|
"commander": "^12.1.0",
|
|
38
46
|
"ioredis": "^5.4.0",
|
|
39
47
|
"postgres": "^3.4.5",
|
|
40
|
-
"@taskcast/
|
|
41
|
-
"@taskcast/
|
|
42
|
-
"@taskcast/playground": "0.3.
|
|
43
|
-
"@taskcast/redis": "1.
|
|
44
|
-
"@taskcast/postgres": "1.
|
|
45
|
-
"@taskcast/server
|
|
46
|
-
"@taskcast/server": "1.
|
|
47
|
-
"@taskcast/sqlite": "1.
|
|
48
|
+
"@taskcast/dashboard-web": "0.3.8",
|
|
49
|
+
"@taskcast/core": "1.5.0",
|
|
50
|
+
"@taskcast/playground": "0.3.8",
|
|
51
|
+
"@taskcast/redis": "1.5.0",
|
|
52
|
+
"@taskcast/postgres": "1.5.0",
|
|
53
|
+
"@taskcast/server": "1.5.0",
|
|
54
|
+
"@taskcast/server-sdk": "1.5.0",
|
|
55
|
+
"@taskcast/sqlite": "1.5.0"
|
|
48
56
|
},
|
|
49
57
|
"devDependencies": {
|
|
58
|
+
"testcontainers": "^10.13.0",
|
|
50
59
|
"typescript": "^5.7.0",
|
|
51
60
|
"vitest": "^2.1.0"
|
|
52
61
|
},
|
|
@@ -54,6 +63,7 @@
|
|
|
54
63
|
"build": "tsc",
|
|
55
64
|
"start": "node dist/index.js",
|
|
56
65
|
"test": "vitest run",
|
|
57
|
-
"test:watch": "vitest"
|
|
66
|
+
"test:watch": "vitest",
|
|
67
|
+
"generate-migrations": "node ../../scripts/generate-migrations.mjs"
|
|
58
68
|
}
|
|
59
69
|
}
|