@cedarjs/pg 0.2.0-alpha.0 → 0.2.0-beta.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/README.md +250 -229
- package/dist/cli.cjs +89 -39
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +73 -23
- package/dist/cli.mjs.map +1 -1
- package/dist/dev-env.cjs +1 -1
- package/dist/dev-env.mjs +1 -1
- package/dist/index.cjs +9 -8
- package/dist/index.d.cts +31 -3
- package/dist/index.d.mts +31 -3
- package/dist/index.mjs +7 -7
- package/dist/jest-teardown.cjs +1 -1
- package/dist/jest-teardown.mjs +1 -1
- package/dist/jest-template.cjs +4 -1
- package/dist/jest-template.cjs.map +1 -1
- package/dist/jest-template.d.cts +4 -1
- package/dist/jest-template.d.mts +4 -1
- package/dist/jest-template.mjs +4 -1
- package/dist/jest-template.mjs.map +1 -1
- package/dist/jest.cjs +1 -1
- package/dist/jest.mjs +1 -1
- package/dist/{lease-BSBBpaR4.mjs → lease-DS1SX8U_.mjs} +23 -3
- package/dist/lease-DS1SX8U_.mjs.map +1 -0
- package/dist/{lease-Bq9wKwQa.cjs → lease-WlmOnNDi.cjs} +41 -3
- package/dist/lease-WlmOnNDi.cjs.map +1 -0
- package/dist/{lifecycle-DEJ4GgWV.cjs → lifecycle-BbrvFQvg.cjs} +175 -78
- package/dist/lifecycle-BbrvFQvg.cjs.map +1 -0
- package/dist/{lifecycle-BOo6xBjD.mjs → lifecycle-BvIx0xqq.mjs} +175 -78
- package/dist/lifecycle-BvIx0xqq.mjs.map +1 -0
- package/dist/{load-dev-env-7UjMHhw7.mjs → load-dev-env-BULkXyen.mjs} +2 -2
- package/dist/{load-dev-env-7UjMHhw7.mjs.map → load-dev-env-BULkXyen.mjs.map} +1 -1
- package/dist/{load-dev-env-cII6N4ZP.cjs → load-dev-env-Bl6Ddv1U.cjs} +2 -2
- package/dist/{load-dev-env-cII6N4ZP.cjs.map → load-dev-env-Bl6Ddv1U.cjs.map} +1 -1
- package/dist/{load-mode-env-B0qO9DZx.cjs → load-mode-env-CX9vd56X.cjs} +2 -2
- package/dist/{load-mode-env-B0qO9DZx.cjs.map → load-mode-env-CX9vd56X.cjs.map} +1 -1
- package/dist/{load-mode-env-C8gy4v9V.mjs → load-mode-env-Ce9ujisN.mjs} +2 -2
- package/dist/{load-mode-env-C8gy4v9V.mjs.map → load-mode-env-Ce9ujisN.mjs.map} +1 -1
- package/dist/{load-test-env-C34wpkIX.mjs → load-test-env-BqtA6V-d.mjs} +2 -2
- package/dist/{load-test-env-C34wpkIX.mjs.map → load-test-env-BqtA6V-d.mjs.map} +1 -1
- package/dist/{load-test-env-CkdUjTpV.cjs → load-test-env-Dcgh6YHV.cjs} +2 -2
- package/dist/{load-test-env-CkdUjTpV.cjs.map → load-test-env-Dcgh6YHV.cjs.map} +1 -1
- package/dist/nx.cjs +12 -14
- package/dist/nx.cjs.map +1 -1
- package/dist/nx.mjs +10 -12
- package/dist/nx.mjs.map +1 -1
- package/dist/status-4Uz6A3LB.cjs +31 -0
- package/dist/status-4Uz6A3LB.cjs.map +1 -0
- package/dist/status-Dcnpgnlz.mjs +26 -0
- package/dist/status-Dcnpgnlz.mjs.map +1 -0
- package/dist/studio-DIFw1qWC.mjs +173 -0
- package/dist/studio-DIFw1qWC.mjs.map +1 -0
- package/dist/studio-oJE30_PO.cjs +208 -0
- package/dist/studio-oJE30_PO.cjs.map +1 -0
- package/dist/{tasks-Caud9yHr.cjs → tasks-CNHvvlsN.cjs} +4 -4
- package/dist/{tasks-Caud9yHr.cjs.map → tasks-CNHvvlsN.cjs.map} +1 -1
- package/dist/{tasks-KherHLac.mjs → tasks-D5iWIdlo.mjs} +2 -2
- package/dist/{tasks-KherHLac.mjs.map → tasks-D5iWIdlo.mjs.map} +1 -1
- package/dist/{template-CGw3C1Ob.mjs → template-BiJ-0TIF.mjs} +3 -3
- package/dist/{template-CGw3C1Ob.mjs.map → template-BiJ-0TIF.mjs.map} +1 -1
- package/dist/{template-D0gJ_MS2.cjs → template-CXMpODzK.cjs} +3 -3
- package/dist/{template-D0gJ_MS2.cjs.map → template-CXMpODzK.cjs.map} +1 -1
- package/dist/{template-mode-IjlFOG4O.mjs → template-mode-BTUsdBtA.mjs} +27 -13
- package/dist/template-mode-BTUsdBtA.mjs.map +1 -0
- package/dist/{template-mode-CcxV_Iju.d.cts → template-mode-CzyVwHsi.d.cts} +4 -1
- package/dist/{template-mode-CcxV_Iju.d.mts → template-mode-CzyVwHsi.d.mts} +4 -1
- package/dist/{template-mode-BkEs9LnY.cjs → template-mode-JTOxrEgE.cjs} +27 -13
- package/dist/template-mode-JTOxrEgE.cjs.map +1 -0
- package/dist/test-env.cjs +1 -1
- package/dist/test-env.mjs +1 -1
- package/dist/vite-plus.cjs +107 -4
- package/dist/vite-plus.cjs.map +1 -1
- package/dist/vite-plus.d.cts +25 -1
- package/dist/vite-plus.d.mts +25 -1
- package/dist/vite-plus.mjs +108 -5
- package/dist/vite-plus.mjs.map +1 -1
- package/dist/vitest-template.cjs +1 -1
- package/dist/vitest-template.d.cts +1 -1
- package/dist/vitest-template.d.mts +1 -1
- package/dist/vitest-template.mjs +1 -1
- package/dist/vitest.cjs +1 -1
- package/dist/vitest.mjs +1 -1
- package/package.json +11 -2
- package/dist/constants-Ct8myrEn.cjs +0 -41
- package/dist/constants-Ct8myrEn.cjs.map +0 -1
- package/dist/constants-NLR0U4NR.mjs +0 -24
- package/dist/constants-NLR0U4NR.mjs.map +0 -1
- package/dist/lease-BSBBpaR4.mjs.map +0 -1
- package/dist/lease-Bq9wKwQa.cjs.map +0 -1
- package/dist/lifecycle-BOo6xBjD.mjs.map +0 -1
- package/dist/lifecycle-DEJ4GgWV.cjs.map +0 -1
- package/dist/template-mode-BkEs9LnY.cjs.map +0 -1
- package/dist/template-mode-IjlFOG4O.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load-test-env-
|
|
1
|
+
{"version":3,"file":"load-test-env-Dcgh6YHV.cjs","names":["normalizeLoadOptions"],"sources":["../src/adapters/load-test-env.ts"],"sourcesContent":["import { loadModeEnv, normalizeLoadOptions, type LoadModeEnvOptions } from \"./load-mode-env.ts\";\n\nexport type LoadTestEnvOptions = LoadModeEnvOptions;\n\n/**\n * Load `.cedarpg/test.env` into `process.env` (worker-side).\n *\n * Jest (and optional Vitest `setupFiles`) run tests in a different process than\n * `globalSetup`, so `setEnv` in acquire does not reach workers — the env file does.\n *\n * No-ops unless a matching `test.json` lease exists, so a leftover env after dispose\n * cannot inject a dropped DATABASE_URL.\n */\nexport function loadTestEnv(rootOrOptions?: string | LoadTestEnvOptions): void {\n loadModeEnv(\"test\", normalizeLoadOptions(rootOrOptions));\n}\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,YAAY,eAAmD;CAC7E,sBAAA,YAAY,QAAQA,sBAAAA,qBAAqB,aAAa,CAAC;AACzD"}
|
package/dist/nx.cjs
CHANGED
|
@@ -1,23 +1,21 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const require_tasks = require("./tasks-Caud9yHr.cjs");
|
|
2
|
+
const require_lease = require("./lease-WlmOnNDi.cjs");
|
|
3
|
+
const require_tasks = require("./tasks-CNHvvlsN.cjs");
|
|
5
4
|
//#region src/adapters/nx.ts
|
|
6
5
|
/**
|
|
7
|
-
* Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`)
|
|
8
|
-
*
|
|
6
|
+
* Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`).
|
|
7
|
+
* Canonical shape: `createAcquireTask` / `db:ready`, then wrap children with
|
|
8
|
+
* `cedarpg run --mode=dev --force -- <cmd>`. Avoid concurrent acquire/run on the
|
|
9
|
+
* same worktree. Secondary: `envFile` → `.cedarpg/<mode>.env` (still loses to
|
|
10
|
+
* ambient `.env` without force/overwrite).
|
|
9
11
|
*
|
|
10
12
|
* ```json
|
|
11
13
|
* {
|
|
12
14
|
* "targets": {
|
|
15
|
+
* "db:ready": { "command": "tsx tools/db-ready.ts", "cache": false },
|
|
13
16
|
* "dev": {
|
|
14
|
-
* "
|
|
15
|
-
*
|
|
16
|
-
* "db:acquire": { "command": "cedarpg acquire --mode=dev" },
|
|
17
|
-
* "serve": {
|
|
18
|
-
* "dependsOn": ["db:acquire"],
|
|
19
|
-
* "command": "node dist/server.js",
|
|
20
|
-
* "options": { "envFile": ".cedarpg/dev.env" }
|
|
17
|
+
* "dependsOn": ["db:ready"],
|
|
18
|
+
* "command": "cedarpg run --mode=dev --force -- yarn tsx scripts/apiServer/dev.ts"
|
|
21
19
|
* }
|
|
22
20
|
* }
|
|
23
21
|
* }
|
|
@@ -25,10 +23,10 @@ const require_tasks = require("./tasks-Caud9yHr.cjs");
|
|
|
25
23
|
*/
|
|
26
24
|
/** Relative path for Nx `envFile` / dotenv. */
|
|
27
25
|
function relativeEnvFile(mode) {
|
|
28
|
-
return `${
|
|
26
|
+
return `${require_lease.STATE_DIRNAME}/${mode}.env`;
|
|
29
27
|
}
|
|
30
28
|
/** @deprecated Prefer `cedarPgNxTargets()`. */
|
|
31
|
-
function nxTargetHints(bin =
|
|
29
|
+
function nxTargetHints(bin = require_lease.CLI_NAME) {
|
|
32
30
|
return Object.fromEntries(Object.entries(require_tasks.cedarPgLifecycleTargets({ bin })).map(([name, def]) => [name, { command: def.command }]));
|
|
33
31
|
}
|
|
34
32
|
//#endregion
|
package/dist/nx.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx.cjs","names":["STATE_DIRNAME","CLI_NAME","cedarPgLifecycleTargets"],"sources":["../src/adapters/nx.ts"],"sourcesContent":["/**\n * Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`)
|
|
1
|
+
{"version":3,"file":"nx.cjs","names":["STATE_DIRNAME","CLI_NAME","cedarPgLifecycleTargets"],"sources":["../src/adapters/nx.ts"],"sourcesContent":["/**\n * Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`).\n * Canonical shape: `createAcquireTask` / `db:ready`, then wrap children with\n * `cedarpg run --mode=dev --force -- <cmd>`. Avoid concurrent acquire/run on the\n * same worktree. Secondary: `envFile` → `.cedarpg/<mode>.env` (still loses to\n * ambient `.env` without force/overwrite).\n *\n * ```json\n * {\n * \"targets\": {\n * \"db:ready\": { \"command\": \"tsx tools/db-ready.ts\", \"cache\": false },\n * \"dev\": {\n * \"dependsOn\": [\"db:ready\"],\n * \"command\": \"cedarpg run --mode=dev --force -- yarn tsx scripts/apiServer/dev.ts\"\n * }\n * }\n * }\n * ```\n */\n\nimport { CLI_NAME, STATE_DIRNAME } from \"../core/constants.ts\";\nimport { envFilePath } from \"../core/lease.ts\";\nimport type { DbMode } from \"../core/naming.ts\";\nimport {\n cedarPgLifecycleTargets,\n cedarPgRunCommand,\n type CedarPgLifecycleTarget,\n type CedarPgLifecycleTargetsOptions,\n CEDAR_PG_TASK_DISPOSE_TEST,\n CEDAR_PG_TASK_ACQUIRE_DEV,\n CEDAR_PG_TASK_ACQUIRE_TEST,\n} from \"./tasks.ts\";\n\nexport {\n CEDAR_PG_TASK_ACQUIRE_DEV as CEDAR_PG_NX_ACQUIRE_DEV,\n CEDAR_PG_TASK_ACQUIRE_TEST as CEDAR_PG_NX_ACQUIRE_TEST,\n CEDAR_PG_TASK_DISPOSE_TEST as CEDAR_PG_NX_DISPOSE_TEST,\n cedarPgLifecycleTargets as cedarPgNxTargets,\n cedarPgRunCommand,\n envFilePath,\n};\n\n/** Relative path for Nx `envFile` / dotenv. */\nexport function relativeEnvFile(mode: DbMode): string {\n return `${STATE_DIRNAME}/${mode}.env`;\n}\n\nexport type NxTargetHint = CedarPgLifecycleTarget;\nexport type CedarPgNxTargetsOptions = CedarPgLifecycleTargetsOptions;\n\n/** @deprecated Prefer `cedarPgNxTargets()`. */\nexport function nxTargetHints(bin = CLI_NAME): Record<string, { command: string }> {\n return Object.fromEntries(\n Object.entries(cedarPgLifecycleTargets({ bin })).map(([name, def]) => [\n name,\n { command: def.command },\n ]),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,gBAAgB,MAAsB;CACpD,OAAO,GAAGA,cAAAA,cAAc,GAAG,KAAK;AAClC;;AAMA,SAAgB,cAAc,MAAMC,cAAAA,UAA+C;CACjF,OAAO,OAAO,YACZ,OAAO,QAAQC,cAAAA,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,SAAS,CACpE,MACA,EAAE,SAAS,IAAI,QAAQ,CACzB,CAAC,CACH;AACF"}
|
package/dist/nx.mjs
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import { a as cedarPgRunCommand, i as cedarPgLifecycleTargets, n as CEDAR_PG_TASK_ACQUIRE_TEST, r as CEDAR_PG_TASK_DISPOSE_TEST, t as CEDAR_PG_TASK_ACQUIRE_DEV } from "./tasks-KherHLac.mjs";
|
|
1
|
+
import { h as STATE_DIRNAME, p as CLI_NAME, t as envFilePath } from "./lease-DS1SX8U_.mjs";
|
|
2
|
+
import { a as cedarPgRunCommand, i as cedarPgLifecycleTargets, n as CEDAR_PG_TASK_ACQUIRE_TEST, r as CEDAR_PG_TASK_DISPOSE_TEST, t as CEDAR_PG_TASK_ACQUIRE_DEV } from "./tasks-D5iWIdlo.mjs";
|
|
4
3
|
//#region src/adapters/nx.ts
|
|
5
4
|
/**
|
|
6
|
-
* Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`)
|
|
7
|
-
*
|
|
5
|
+
* Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`).
|
|
6
|
+
* Canonical shape: `createAcquireTask` / `db:ready`, then wrap children with
|
|
7
|
+
* `cedarpg run --mode=dev --force -- <cmd>`. Avoid concurrent acquire/run on the
|
|
8
|
+
* same worktree. Secondary: `envFile` → `.cedarpg/<mode>.env` (still loses to
|
|
9
|
+
* ambient `.env` without force/overwrite).
|
|
8
10
|
*
|
|
9
11
|
* ```json
|
|
10
12
|
* {
|
|
11
13
|
* "targets": {
|
|
14
|
+
* "db:ready": { "command": "tsx tools/db-ready.ts", "cache": false },
|
|
12
15
|
* "dev": {
|
|
13
|
-
* "
|
|
14
|
-
*
|
|
15
|
-
* "db:acquire": { "command": "cedarpg acquire --mode=dev" },
|
|
16
|
-
* "serve": {
|
|
17
|
-
* "dependsOn": ["db:acquire"],
|
|
18
|
-
* "command": "node dist/server.js",
|
|
19
|
-
* "options": { "envFile": ".cedarpg/dev.env" }
|
|
16
|
+
* "dependsOn": ["db:ready"],
|
|
17
|
+
* "command": "cedarpg run --mode=dev --force -- yarn tsx scripts/apiServer/dev.ts"
|
|
20
18
|
* }
|
|
21
19
|
* }
|
|
22
20
|
* }
|
package/dist/nx.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nx.mjs","names":[],"sources":["../src/adapters/nx.ts"],"sourcesContent":["/**\n * Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`)
|
|
1
|
+
{"version":3,"file":"nx.mjs","names":[],"sources":["../src/adapters/nx.ts"],"sourcesContent":["/**\n * Nx targets. `dependsOn` does not forward acquire env (unlike Vite+ `env: [...]`).\n * Canonical shape: `createAcquireTask` / `db:ready`, then wrap children with\n * `cedarpg run --mode=dev --force -- <cmd>`. Avoid concurrent acquire/run on the\n * same worktree. Secondary: `envFile` → `.cedarpg/<mode>.env` (still loses to\n * ambient `.env` without force/overwrite).\n *\n * ```json\n * {\n * \"targets\": {\n * \"db:ready\": { \"command\": \"tsx tools/db-ready.ts\", \"cache\": false },\n * \"dev\": {\n * \"dependsOn\": [\"db:ready\"],\n * \"command\": \"cedarpg run --mode=dev --force -- yarn tsx scripts/apiServer/dev.ts\"\n * }\n * }\n * }\n * ```\n */\n\nimport { CLI_NAME, STATE_DIRNAME } from \"../core/constants.ts\";\nimport { envFilePath } from \"../core/lease.ts\";\nimport type { DbMode } from \"../core/naming.ts\";\nimport {\n cedarPgLifecycleTargets,\n cedarPgRunCommand,\n type CedarPgLifecycleTarget,\n type CedarPgLifecycleTargetsOptions,\n CEDAR_PG_TASK_DISPOSE_TEST,\n CEDAR_PG_TASK_ACQUIRE_DEV,\n CEDAR_PG_TASK_ACQUIRE_TEST,\n} from \"./tasks.ts\";\n\nexport {\n CEDAR_PG_TASK_ACQUIRE_DEV as CEDAR_PG_NX_ACQUIRE_DEV,\n CEDAR_PG_TASK_ACQUIRE_TEST as CEDAR_PG_NX_ACQUIRE_TEST,\n CEDAR_PG_TASK_DISPOSE_TEST as CEDAR_PG_NX_DISPOSE_TEST,\n cedarPgLifecycleTargets as cedarPgNxTargets,\n cedarPgRunCommand,\n envFilePath,\n};\n\n/** Relative path for Nx `envFile` / dotenv. */\nexport function relativeEnvFile(mode: DbMode): string {\n return `${STATE_DIRNAME}/${mode}.env`;\n}\n\nexport type NxTargetHint = CedarPgLifecycleTarget;\nexport type CedarPgNxTargetsOptions = CedarPgLifecycleTargetsOptions;\n\n/** @deprecated Prefer `cedarPgNxTargets()`. */\nexport function nxTargetHints(bin = CLI_NAME): Record<string, { command: string }> {\n return Object.fromEntries(\n Object.entries(cedarPgLifecycleTargets({ bin })).map(([name, def]) => [\n name,\n { command: def.command },\n ]),\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA2CA,SAAgB,gBAAgB,MAAsB;CACpD,OAAO,GAAG,cAAc,GAAG,KAAK;AAClC;;AAMA,SAAgB,cAAc,MAAM,UAA+C;CACjF,OAAO,OAAO,YACZ,OAAO,QAAQ,wBAAwB,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,SAAS,CACpE,MACA,EAAE,SAAS,IAAI,QAAQ,CACzB,CAAC,CACH;AACF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const require_lifecycle = require("./lifecycle-BbrvFQvg.cjs");
|
|
2
|
+
const require_lease = require("./lease-WlmOnNDi.cjs");
|
|
3
|
+
//#region src/core/status.ts
|
|
4
|
+
/** Read-only lease snapshot for CLI / Vite panel (no acquire, no host). */
|
|
5
|
+
function resolveDevStatus(options = {}) {
|
|
6
|
+
const mode = options.mode ?? "dev";
|
|
7
|
+
const root = require_lease.resolveRoot(options.root);
|
|
8
|
+
const lease = require_lease.readLease(root, mode);
|
|
9
|
+
if (!lease) return {
|
|
10
|
+
ok: false,
|
|
11
|
+
mode,
|
|
12
|
+
root
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
ok: true,
|
|
16
|
+
mode,
|
|
17
|
+
root,
|
|
18
|
+
lease,
|
|
19
|
+
databaseUrl: require_lifecycle.urlFromLease(lease),
|
|
20
|
+
envPath: require_lease.envPath(root, mode)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
Object.defineProperty(exports, "resolveDevStatus", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function() {
|
|
27
|
+
return resolveDevStatus;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=status-4Uz6A3LB.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-4Uz6A3LB.cjs","names":["resolveRoot","readLease","urlFromLease","envPath"],"sources":["../src/core/status.ts"],"sourcesContent":["import { envPath, readLease, type Lease } from \"./lease.ts\";\nimport { urlFromLease } from \"./lifecycle.ts\";\nimport type { DbMode } from \"./naming.ts\";\nimport { resolveRoot } from \"./worktree.ts\";\n\nexport type ResolveDevStatusOptions = {\n root?: string;\n mode?: DbMode;\n};\n\nexport type DevStatus =\n | {\n ok: true;\n mode: DbMode;\n root: string;\n lease: Lease;\n databaseUrl: string;\n envPath: string;\n }\n | {\n ok: false;\n mode: DbMode;\n root: string;\n };\n\n/** Read-only lease snapshot for CLI / Vite panel (no acquire, no host). */\nexport function resolveDevStatus(options: ResolveDevStatusOptions = {}): DevStatus {\n const mode = options.mode ?? \"dev\";\n const root = resolveRoot(options.root);\n const lease = readLease(root, mode);\n if (!lease) {\n return { ok: false, mode, root };\n }\n return {\n ok: true,\n mode,\n root,\n lease,\n databaseUrl: urlFromLease(lease),\n envPath: envPath(root, mode),\n };\n}\n"],"mappings":";;;;AA0BA,SAAgB,iBAAiB,UAAmC,CAAC,GAAc;CACjF,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,OAAOA,cAAAA,YAAY,QAAQ,IAAI;CACrC,MAAM,QAAQC,cAAAA,UAAU,MAAM,IAAI;CAClC,IAAI,CAAC,OACH,OAAO;EAAE,IAAI;EAAO;EAAM;CAAK;CAEjC,OAAO;EACL,IAAI;EACJ;EACA;EACA;EACA,aAAaC,kBAAAA,aAAa,KAAK;EAC/B,SAASC,cAAAA,QAAQ,MAAM,IAAI;CAC7B;AACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { a as urlFromLease } from "./lifecycle-BvIx0xqq.mjs";
|
|
2
|
+
import { d as resolveRoot, l as readLease, n as envPath } from "./lease-DS1SX8U_.mjs";
|
|
3
|
+
//#region src/core/status.ts
|
|
4
|
+
/** Read-only lease snapshot for CLI / Vite panel (no acquire, no host). */
|
|
5
|
+
function resolveDevStatus(options = {}) {
|
|
6
|
+
const mode = options.mode ?? "dev";
|
|
7
|
+
const root = resolveRoot(options.root);
|
|
8
|
+
const lease = readLease(root, mode);
|
|
9
|
+
if (!lease) return {
|
|
10
|
+
ok: false,
|
|
11
|
+
mode,
|
|
12
|
+
root
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
ok: true,
|
|
16
|
+
mode,
|
|
17
|
+
root,
|
|
18
|
+
lease,
|
|
19
|
+
databaseUrl: urlFromLease(lease),
|
|
20
|
+
envPath: envPath(root, mode)
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { resolveDevStatus as t };
|
|
25
|
+
|
|
26
|
+
//# sourceMappingURL=status-Dcnpgnlz.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status-Dcnpgnlz.mjs","names":[],"sources":["../src/core/status.ts"],"sourcesContent":["import { envPath, readLease, type Lease } from \"./lease.ts\";\nimport { urlFromLease } from \"./lifecycle.ts\";\nimport type { DbMode } from \"./naming.ts\";\nimport { resolveRoot } from \"./worktree.ts\";\n\nexport type ResolveDevStatusOptions = {\n root?: string;\n mode?: DbMode;\n};\n\nexport type DevStatus =\n | {\n ok: true;\n mode: DbMode;\n root: string;\n lease: Lease;\n databaseUrl: string;\n envPath: string;\n }\n | {\n ok: false;\n mode: DbMode;\n root: string;\n };\n\n/** Read-only lease snapshot for CLI / Vite panel (no acquire, no host). */\nexport function resolveDevStatus(options: ResolveDevStatusOptions = {}): DevStatus {\n const mode = options.mode ?? \"dev\";\n const root = resolveRoot(options.root);\n const lease = readLease(root, mode);\n if (!lease) {\n return { ok: false, mode, root };\n }\n return {\n ok: true,\n mode,\n root,\n lease,\n databaseUrl: urlFromLease(lease),\n envPath: envPath(root, mode),\n };\n}\n"],"mappings":";;;;AA0BA,SAAgB,iBAAiB,UAAmC,CAAC,GAAc;CACjF,MAAM,OAAO,QAAQ,QAAQ;CAC7B,MAAM,OAAO,YAAY,QAAQ,IAAI;CACrC,MAAM,QAAQ,UAAU,MAAM,IAAI;CAClC,IAAI,CAAC,OACH,OAAO;EAAE,IAAI;EAAO;EAAM;CAAK;CAEjC,OAAO;EACL,IAAI;EACJ;EACA;EACA;EACA,aAAa,aAAa,KAAK;EAC/B,SAAS,QAAQ,MAAM,IAAI;CAC7B;AACF"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { p as CLI_NAME } from "./lease-DS1SX8U_.mjs";
|
|
2
|
+
import { n as CEDAR_PG_TASK_ACQUIRE_TEST, t as CEDAR_PG_TASK_ACQUIRE_DEV } from "./tasks-D5iWIdlo.mjs";
|
|
3
|
+
import { createRequire } from "node:module";
|
|
4
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
5
|
+
import { dirname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
|
+
import { spawn } from "node:child_process";
|
|
7
|
+
import { pathToFileURL } from "node:url";
|
|
8
|
+
//#region src/adapters/child.ts
|
|
9
|
+
/** Attached child: inherit stdio, resolve with exit code (signal → 1). */
|
|
10
|
+
function runAttached(command, args, options = {}) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const child = spawn(command, args, {
|
|
13
|
+
stdio: "inherit",
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
env: options.env,
|
|
16
|
+
shell: options.shell
|
|
17
|
+
});
|
|
18
|
+
child.once("error", reject);
|
|
19
|
+
child.once("exit", (code, signal) => {
|
|
20
|
+
resolve(signal ? 1 : code ?? 1);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/adapters/status-format.ts
|
|
26
|
+
/** Human-readable lines for the Vite panel / `cedarpg status`. */
|
|
27
|
+
function formatDevStatus(status) {
|
|
28
|
+
if (!status.ok) {
|
|
29
|
+
const task = status.mode === "test" ? CEDAR_PG_TASK_ACQUIRE_TEST : CEDAR_PG_TASK_ACQUIRE_DEV;
|
|
30
|
+
return [`${CLI_NAME}: no ${status.mode} lease at ${status.root}`, ` run \`${CLI_NAME} acquire --mode=${status.mode}\` (or depend on ${task})`];
|
|
31
|
+
}
|
|
32
|
+
const { lease, databaseUrl, envPath } = status;
|
|
33
|
+
return [
|
|
34
|
+
`${CLI_NAME}: ${lease.databaseName} (${lease.repoSlug}/${lease.worktreeSlug} ${lease.mode})`,
|
|
35
|
+
` port ${lease.port}`,
|
|
36
|
+
` DATABASE_URL ${databaseUrl}`,
|
|
37
|
+
` env ${envPath}`
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/adapters/studio.ts
|
|
42
|
+
const STUDIO_PACKAGE = {
|
|
43
|
+
prisma: "prisma",
|
|
44
|
+
drizzle: "drizzle-kit"
|
|
45
|
+
};
|
|
46
|
+
const AUTO_ORDER = ["prisma", "drizzle"];
|
|
47
|
+
function readPackageJson(dir) {
|
|
48
|
+
const file = join(dir, "package.json");
|
|
49
|
+
if (!existsSync(file)) return null;
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse(readFileSync(file, "utf8"));
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function hasDep(pkg, name) {
|
|
57
|
+
if (!pkg) return false;
|
|
58
|
+
return Boolean(pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.optionalDependencies?.[name]);
|
|
59
|
+
}
|
|
60
|
+
function tryResolveBin(dir, packageName) {
|
|
61
|
+
try {
|
|
62
|
+
const pkgJsonPath = createRequire(pathToFileURL(join(dir, "package.json")).href).resolve(`${packageName}/package.json`);
|
|
63
|
+
const binField = JSON.parse(readFileSync(pkgJsonPath, "utf8")).bin;
|
|
64
|
+
let rel;
|
|
65
|
+
if (typeof binField === "string") rel = binField;
|
|
66
|
+
else if (binField && typeof binField === "object") rel = binField[packageName] ?? Object.values(binField)[0];
|
|
67
|
+
if (!rel) return null;
|
|
68
|
+
const abs = join(dirname(pkgJsonPath), rel);
|
|
69
|
+
return existsSync(abs) ? abs : null;
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function npxStudio(kind, cwd) {
|
|
75
|
+
return {
|
|
76
|
+
kind,
|
|
77
|
+
command: "npx",
|
|
78
|
+
args: [STUDIO_PACKAGE[kind], "studio"],
|
|
79
|
+
cwd,
|
|
80
|
+
shell: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Local bin, else declared dep → npx, else null. Resolves the bin at most once. */
|
|
84
|
+
function studioAt(kind, dir) {
|
|
85
|
+
const pkg = STUDIO_PACKAGE[kind];
|
|
86
|
+
const bin = tryResolveBin(dir, pkg);
|
|
87
|
+
if (bin) return {
|
|
88
|
+
kind,
|
|
89
|
+
command: bin,
|
|
90
|
+
args: ["studio"],
|
|
91
|
+
cwd: dir,
|
|
92
|
+
shell: false
|
|
93
|
+
};
|
|
94
|
+
if (hasDep(readPackageJson(dir), pkg)) return npxStudio(kind, dir);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function isInside(dir, ancestor) {
|
|
98
|
+
const rel = relative(ancestor, dir);
|
|
99
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute(rel);
|
|
100
|
+
}
|
|
101
|
+
/** `start` up to `stop` (inclusive) when `start` is inside the worktree; otherwise only `start`. */
|
|
102
|
+
function searchDirs(start, stop) {
|
|
103
|
+
if (!isInside(start, stop)) return [start];
|
|
104
|
+
const dirs = [];
|
|
105
|
+
let dir = start;
|
|
106
|
+
for (;;) {
|
|
107
|
+
dirs.push(dir);
|
|
108
|
+
if (dir === stop) return dirs;
|
|
109
|
+
const parent = dirname(dir);
|
|
110
|
+
if (parent === dir) return dirs;
|
|
111
|
+
dir = parent;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Detect Prisma Studio or Drizzle Kit Studio, walking from `cwd` up to the worktree `root`.
|
|
116
|
+
*
|
|
117
|
+
* Auto: nearest directory wins, prisma before drizzle in that directory; no npx fallback.
|
|
118
|
+
* Forced `prefer`: same nearest walk for that kind only, then npx at `cwd`.
|
|
119
|
+
*/
|
|
120
|
+
function detectStudio(options) {
|
|
121
|
+
const stop = resolve(options.root);
|
|
122
|
+
const start = resolve(options.cwd ?? options.root);
|
|
123
|
+
const dirs = searchDirs(start, stop);
|
|
124
|
+
const kinds = options.prefer ? [options.prefer] : AUTO_ORDER;
|
|
125
|
+
for (const dir of dirs) for (const kind of kinds) {
|
|
126
|
+
const hit = studioAt(kind, dir);
|
|
127
|
+
if (hit) return hit;
|
|
128
|
+
}
|
|
129
|
+
return options.prefer ? npxStudio(options.prefer, start) : null;
|
|
130
|
+
}
|
|
131
|
+
function spawnStudio(options, spawnOpts) {
|
|
132
|
+
const { databaseUrl, studio } = options;
|
|
133
|
+
return spawn(studio.command, studio.args, {
|
|
134
|
+
cwd: studio.cwd,
|
|
135
|
+
env: {
|
|
136
|
+
...process.env,
|
|
137
|
+
DATABASE_URL: databaseUrl
|
|
138
|
+
},
|
|
139
|
+
...spawnOpts,
|
|
140
|
+
shell: studio.shell
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Detached Studio for the Vite shortcut. Caller attaches `error` / `exit` on the
|
|
145
|
+
* returned process (spawn failures emit on a later tick).
|
|
146
|
+
*/
|
|
147
|
+
function openStudio(options) {
|
|
148
|
+
const child = spawnStudio(options, {
|
|
149
|
+
detached: true,
|
|
150
|
+
stdio: "ignore"
|
|
151
|
+
});
|
|
152
|
+
child.unref();
|
|
153
|
+
return child;
|
|
154
|
+
}
|
|
155
|
+
/** Attached Studio for `cedarpg studio`: inherit stdio, resolve with the child's exit code. */
|
|
156
|
+
function runStudio(options) {
|
|
157
|
+
const { databaseUrl, studio } = options;
|
|
158
|
+
return runAttached(studio.command, studio.args, {
|
|
159
|
+
cwd: studio.cwd,
|
|
160
|
+
env: {
|
|
161
|
+
...process.env,
|
|
162
|
+
DATABASE_URL: databaseUrl
|
|
163
|
+
},
|
|
164
|
+
shell: studio.shell
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function studioChildRunning(child) {
|
|
168
|
+
return Boolean(child && child.exitCode === null && !child.killed);
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
export { formatDevStatus as a, studioChildRunning as i, openStudio as n, runAttached as o, runStudio as r, detectStudio as t };
|
|
172
|
+
|
|
173
|
+
//# sourceMappingURL=studio-DIFw1qWC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio-DIFw1qWC.mjs","names":[],"sources":["../src/adapters/child.ts","../src/adapters/status-format.ts","../src/adapters/studio.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\n\nexport type RunAttachedOptions = {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n shell?: boolean;\n};\n\n/** Attached child: inherit stdio, resolve with exit code (signal → 1). */\nexport function runAttached(\n command: string,\n args: string[],\n options: RunAttachedOptions = {},\n): Promise<number> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n stdio: \"inherit\",\n cwd: options.cwd,\n env: options.env,\n shell: options.shell,\n });\n child.once(\"error\", reject);\n child.once(\"exit\", (code, signal) => {\n resolve(signal ? 1 : (code ?? 1));\n });\n });\n}\n","import { CLI_NAME } from \"../core/constants.ts\";\nimport type { DevStatus } from \"../core/status.ts\";\nimport { CEDAR_PG_TASK_ACQUIRE_DEV, CEDAR_PG_TASK_ACQUIRE_TEST } from \"./tasks.ts\";\n\n/** Human-readable lines for the Vite panel / `cedarpg status`. */\nexport function formatDevStatus(status: DevStatus): string[] {\n if (!status.ok) {\n const task = status.mode === \"test\" ? CEDAR_PG_TASK_ACQUIRE_TEST : CEDAR_PG_TASK_ACQUIRE_DEV;\n return [\n `${CLI_NAME}: no ${status.mode} lease at ${status.root}`,\n ` run \\`${CLI_NAME} acquire --mode=${status.mode}\\` (or depend on ${task})`,\n ];\n }\n const { lease, databaseUrl, envPath } = status;\n return [\n `${CLI_NAME}: ${lease.databaseName} (${lease.repoSlug}/${lease.worktreeSlug} ${lease.mode})`,\n ` port ${lease.port}`,\n ` DATABASE_URL ${databaseUrl}`,\n ` env ${envPath}`,\n ];\n}\n","import { createRequire } from \"node:module\";\nimport { spawn, type ChildProcess, type SpawnOptions } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { runAttached } from \"./child.ts\";\n\nexport type StudioKind = \"prisma\" | \"drizzle\";\n\nconst STUDIO_PACKAGE: Record<StudioKind, string> = {\n prisma: \"prisma\",\n drizzle: \"drizzle-kit\",\n};\n\nconst AUTO_ORDER: StudioKind[] = [\"prisma\", \"drizzle\"];\n\nexport type DetectStudioOptions = {\n /** Worktree / lease root — directory walk stops here. */\n root: string;\n /** App package to start the walk (Nx `apps/…`). Defaults to `root`. */\n cwd?: string;\n /** Force a kind. Omit to auto-detect (nearest package; prisma if both). */\n prefer?: StudioKind;\n};\n\nexport type DetectedStudio = {\n kind: StudioKind;\n command: string;\n args: string[];\n /** Directory to spawn in (where the ORM package / config was found). */\n cwd: string;\n /** True when falling back to `npx`. */\n shell: boolean;\n};\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n};\n\nfunction readPackageJson(dir: string): PkgJson | null {\n const file = join(dir, \"package.json\");\n if (!existsSync(file)) return null;\n try {\n return JSON.parse(readFileSync(file, \"utf8\")) as PkgJson;\n } catch {\n return null;\n }\n}\n\nfunction hasDep(pkg: PkgJson | null, name: string): boolean {\n if (!pkg) return false;\n return Boolean(\n pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.optionalDependencies?.[name],\n );\n}\n\nfunction tryResolveBin(dir: string, packageName: string): string | null {\n try {\n const require = createRequire(pathToFileURL(join(dir, \"package.json\")).href);\n const pkgJsonPath = require.resolve(`${packageName}/package.json`);\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf8\")) as {\n bin?: string | Record<string, string>;\n };\n const binField = pkg.bin;\n let rel: string | undefined;\n if (typeof binField === \"string\") rel = binField;\n else if (binField && typeof binField === \"object\") {\n rel = binField[packageName] ?? Object.values(binField)[0];\n }\n if (!rel) return null;\n const abs = join(dirname(pkgJsonPath), rel);\n return existsSync(abs) ? abs : null;\n } catch {\n return null;\n }\n}\n\nfunction npxStudio(kind: StudioKind, cwd: string): DetectedStudio {\n return {\n kind,\n command: \"npx\",\n args: [STUDIO_PACKAGE[kind], \"studio\"],\n cwd,\n shell: true,\n };\n}\n\n/** Local bin, else declared dep → npx, else null. Resolves the bin at most once. */\nfunction studioAt(kind: StudioKind, dir: string): DetectedStudio | null {\n const pkg = STUDIO_PACKAGE[kind];\n const bin = tryResolveBin(dir, pkg);\n if (bin) return { kind, command: bin, args: [\"studio\"], cwd: dir, shell: false };\n if (hasDep(readPackageJson(dir), pkg)) return npxStudio(kind, dir);\n return null;\n}\n\nfunction isInside(dir: string, ancestor: string): boolean {\n const rel = relative(ancestor, dir);\n return rel === \"\" || (!rel.startsWith(\"..\") && !isAbsolute(rel));\n}\n\n/** `start` up to `stop` (inclusive) when `start` is inside the worktree; otherwise only `start`. */\nfunction searchDirs(start: string, stop: string): string[] {\n if (!isInside(start, stop)) return [start];\n const dirs: string[] = [];\n let dir = start;\n for (;;) {\n dirs.push(dir);\n if (dir === stop) return dirs;\n const parent = dirname(dir);\n if (parent === dir) return dirs;\n dir = parent;\n }\n}\n\n/**\n * Detect Prisma Studio or Drizzle Kit Studio, walking from `cwd` up to the worktree `root`.\n *\n * Auto: nearest directory wins, prisma before drizzle in that directory; no npx fallback.\n * Forced `prefer`: same nearest walk for that kind only, then npx at `cwd`.\n */\nexport function detectStudio(options: DetectStudioOptions): DetectedStudio | null {\n const stop = resolve(options.root);\n const start = resolve(options.cwd ?? options.root);\n const dirs = searchDirs(start, stop);\n const kinds = options.prefer ? [options.prefer] : AUTO_ORDER;\n\n for (const dir of dirs) {\n for (const kind of kinds) {\n const hit = studioAt(kind, dir);\n if (hit) return hit;\n }\n }\n return options.prefer ? npxStudio(options.prefer, start) : null;\n}\n\nexport type SpawnStudioOptions = {\n databaseUrl: string;\n studio: DetectedStudio;\n};\n\nfunction spawnStudio(options: SpawnStudioOptions, spawnOpts: SpawnOptions): ChildProcess {\n const { databaseUrl, studio } = options;\n return spawn(studio.command, studio.args, {\n cwd: studio.cwd,\n env: { ...process.env, DATABASE_URL: databaseUrl },\n ...spawnOpts,\n shell: studio.shell,\n });\n}\n\n/**\n * Detached Studio for the Vite shortcut. Caller attaches `error` / `exit` on the\n * returned process (spawn failures emit on a later tick).\n */\nexport function openStudio(options: SpawnStudioOptions): ChildProcess {\n const child = spawnStudio(options, { detached: true, stdio: \"ignore\" });\n child.unref();\n return child;\n}\n\n/** Attached Studio for `cedarpg studio`: inherit stdio, resolve with the child's exit code. */\nexport function runStudio(options: SpawnStudioOptions): Promise<number> {\n const { databaseUrl, studio } = options;\n return runAttached(studio.command, studio.args, {\n cwd: studio.cwd,\n env: { ...process.env, DATABASE_URL: databaseUrl },\n shell: studio.shell,\n });\n}\n\nexport function studioChildRunning(child: ChildProcess | undefined): boolean {\n return Boolean(child && child.exitCode === null && !child.killed);\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,YACd,SACA,MACA,UAA8B,CAAC,GACd;CACjB,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,QAAQ,MAAM,SAAS,MAAM;GACjC,OAAO;GACP,KAAK,QAAQ;GACb,KAAK,QAAQ;GACb,OAAO,QAAQ;EACjB,CAAC;EACD,MAAM,KAAK,SAAS,MAAM;EAC1B,MAAM,KAAK,SAAS,MAAM,WAAW;GACnC,QAAQ,SAAS,IAAK,QAAQ,CAAE;EAClC,CAAC;CACH,CAAC;AACH;;;;ACrBA,SAAgB,gBAAgB,QAA6B;CAC3D,IAAI,CAAC,OAAO,IAAI;EACd,MAAM,OAAO,OAAO,SAAS,SAAS,6BAA6B;EACnE,OAAO,CACL,GAAG,SAAS,OAAO,OAAO,KAAK,YAAY,OAAO,QAClD,WAAW,SAAS,kBAAkB,OAAO,KAAK,mBAAmB,KAAK,EAC5E;CACF;CACA,MAAM,EAAE,OAAO,aAAa,YAAY;CACxC,OAAO;EACL,GAAG,SAAS,IAAI,MAAM,aAAa,IAAI,MAAM,SAAS,GAAG,MAAM,aAAa,GAAG,MAAM,KAAK;EAC1F,mBAAmB,MAAM;EACzB,mBAAmB;EACnB,mBAAmB;C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AAQ,YAAY,SAAS;EAAE,UAAU;EAAM,OAAO;CAAS,CAAC;CACtE,MAAM,MAAM;CACZ,OAAO;AACT;;AAGA,SAAgB,UAAU,SAA8C;CACtE,MAAM,EAAE,aAAa,WAAW;CAChC,OAAO,YAAY,OAAO,SAAS,OAAO,MAAM;EAC9C,KAAK,OAAO;EACZ,KAAK;GAAE,GAAG,QAAQ;GAAK,cAAc;EAAY;EACjD,OAAO,OAAO;CAChB,CAAC;AACH;AAEA,SAAgB,mBAAmB,OAA0C;CAC3E,OAAO,QAAQ,SAAS,MAAM,aAAa,QAAQ,CAAC,MAAM,MAAM;AAClE"}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
const require_lease = require("./lease-WlmOnNDi.cjs");
|
|
2
|
+
const require_tasks = require("./tasks-CNHvvlsN.cjs");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
let node_child_process = require("node:child_process");
|
|
6
|
+
let node_module = require("node:module");
|
|
7
|
+
let node_url = require("node:url");
|
|
8
|
+
//#region src/adapters/child.ts
|
|
9
|
+
/** Attached child: inherit stdio, resolve with exit code (signal → 1). */
|
|
10
|
+
function runAttached(command, args, options = {}) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const child = (0, node_child_process.spawn)(command, args, {
|
|
13
|
+
stdio: "inherit",
|
|
14
|
+
cwd: options.cwd,
|
|
15
|
+
env: options.env,
|
|
16
|
+
shell: options.shell
|
|
17
|
+
});
|
|
18
|
+
child.once("error", reject);
|
|
19
|
+
child.once("exit", (code, signal) => {
|
|
20
|
+
resolve(signal ? 1 : code ?? 1);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/adapters/status-format.ts
|
|
26
|
+
/** Human-readable lines for the Vite panel / `cedarpg status`. */
|
|
27
|
+
function formatDevStatus(status) {
|
|
28
|
+
if (!status.ok) {
|
|
29
|
+
const task = status.mode === "test" ? require_tasks.CEDAR_PG_TASK_ACQUIRE_TEST : require_tasks.CEDAR_PG_TASK_ACQUIRE_DEV;
|
|
30
|
+
return [`${require_lease.CLI_NAME}: no ${status.mode} lease at ${status.root}`, ` run \`${require_lease.CLI_NAME} acquire --mode=${status.mode}\` (or depend on ${task})`];
|
|
31
|
+
}
|
|
32
|
+
const { lease, databaseUrl, envPath } = status;
|
|
33
|
+
return [
|
|
34
|
+
`${require_lease.CLI_NAME}: ${lease.databaseName} (${lease.repoSlug}/${lease.worktreeSlug} ${lease.mode})`,
|
|
35
|
+
` port ${lease.port}`,
|
|
36
|
+
` DATABASE_URL ${databaseUrl}`,
|
|
37
|
+
` env ${envPath}`
|
|
38
|
+
];
|
|
39
|
+
}
|
|
40
|
+
//#endregion
|
|
41
|
+
//#region src/adapters/studio.ts
|
|
42
|
+
const STUDIO_PACKAGE = {
|
|
43
|
+
prisma: "prisma",
|
|
44
|
+
drizzle: "drizzle-kit"
|
|
45
|
+
};
|
|
46
|
+
const AUTO_ORDER = ["prisma", "drizzle"];
|
|
47
|
+
function readPackageJson(dir) {
|
|
48
|
+
const file = (0, node_path.join)(dir, "package.json");
|
|
49
|
+
if (!(0, node_fs.existsSync)(file)) return null;
|
|
50
|
+
try {
|
|
51
|
+
return JSON.parse((0, node_fs.readFileSync)(file, "utf8"));
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function hasDep(pkg, name) {
|
|
57
|
+
if (!pkg) return false;
|
|
58
|
+
return Boolean(pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.optionalDependencies?.[name]);
|
|
59
|
+
}
|
|
60
|
+
function tryResolveBin(dir, packageName) {
|
|
61
|
+
try {
|
|
62
|
+
const pkgJsonPath = (0, node_module.createRequire)((0, node_url.pathToFileURL)((0, node_path.join)(dir, "package.json")).href).resolve(`${packageName}/package.json`);
|
|
63
|
+
const binField = JSON.parse((0, node_fs.readFileSync)(pkgJsonPath, "utf8")).bin;
|
|
64
|
+
let rel;
|
|
65
|
+
if (typeof binField === "string") rel = binField;
|
|
66
|
+
else if (binField && typeof binField === "object") rel = binField[packageName] ?? Object.values(binField)[0];
|
|
67
|
+
if (!rel) return null;
|
|
68
|
+
const abs = (0, node_path.join)((0, node_path.dirname)(pkgJsonPath), rel);
|
|
69
|
+
return (0, node_fs.existsSync)(abs) ? abs : null;
|
|
70
|
+
} catch {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function npxStudio(kind, cwd) {
|
|
75
|
+
return {
|
|
76
|
+
kind,
|
|
77
|
+
command: "npx",
|
|
78
|
+
args: [STUDIO_PACKAGE[kind], "studio"],
|
|
79
|
+
cwd,
|
|
80
|
+
shell: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/** Local bin, else declared dep → npx, else null. Resolves the bin at most once. */
|
|
84
|
+
function studioAt(kind, dir) {
|
|
85
|
+
const pkg = STUDIO_PACKAGE[kind];
|
|
86
|
+
const bin = tryResolveBin(dir, pkg);
|
|
87
|
+
if (bin) return {
|
|
88
|
+
kind,
|
|
89
|
+
command: bin,
|
|
90
|
+
args: ["studio"],
|
|
91
|
+
cwd: dir,
|
|
92
|
+
shell: false
|
|
93
|
+
};
|
|
94
|
+
if (hasDep(readPackageJson(dir), pkg)) return npxStudio(kind, dir);
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
function isInside(dir, ancestor) {
|
|
98
|
+
const rel = (0, node_path.relative)(ancestor, dir);
|
|
99
|
+
return rel === "" || !rel.startsWith("..") && !(0, node_path.isAbsolute)(rel);
|
|
100
|
+
}
|
|
101
|
+
/** `start` up to `stop` (inclusive) when `start` is inside the worktree; otherwise only `start`. */
|
|
102
|
+
function searchDirs(start, stop) {
|
|
103
|
+
if (!isInside(start, stop)) return [start];
|
|
104
|
+
const dirs = [];
|
|
105
|
+
let dir = start;
|
|
106
|
+
for (;;) {
|
|
107
|
+
dirs.push(dir);
|
|
108
|
+
if (dir === stop) return dirs;
|
|
109
|
+
const parent = (0, node_path.dirname)(dir);
|
|
110
|
+
if (parent === dir) return dirs;
|
|
111
|
+
dir = parent;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Detect Prisma Studio or Drizzle Kit Studio, walking from `cwd` up to the worktree `root`.
|
|
116
|
+
*
|
|
117
|
+
* Auto: nearest directory wins, prisma before drizzle in that directory; no npx fallback.
|
|
118
|
+
* Forced `prefer`: same nearest walk for that kind only, then npx at `cwd`.
|
|
119
|
+
*/
|
|
120
|
+
function detectStudio(options) {
|
|
121
|
+
const stop = (0, node_path.resolve)(options.root);
|
|
122
|
+
const start = (0, node_path.resolve)(options.cwd ?? options.root);
|
|
123
|
+
const dirs = searchDirs(start, stop);
|
|
124
|
+
const kinds = options.prefer ? [options.prefer] : AUTO_ORDER;
|
|
125
|
+
for (const dir of dirs) for (const kind of kinds) {
|
|
126
|
+
const hit = studioAt(kind, dir);
|
|
127
|
+
if (hit) return hit;
|
|
128
|
+
}
|
|
129
|
+
return options.prefer ? npxStudio(options.prefer, start) : null;
|
|
130
|
+
}
|
|
131
|
+
function spawnStudio(options, spawnOpts) {
|
|
132
|
+
const { databaseUrl, studio } = options;
|
|
133
|
+
return (0, node_child_process.spawn)(studio.command, studio.args, {
|
|
134
|
+
cwd: studio.cwd,
|
|
135
|
+
env: {
|
|
136
|
+
...process.env,
|
|
137
|
+
DATABASE_URL: databaseUrl
|
|
138
|
+
},
|
|
139
|
+
...spawnOpts,
|
|
140
|
+
shell: studio.shell
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Detached Studio for the Vite shortcut. Caller attaches `error` / `exit` on the
|
|
145
|
+
* returned process (spawn failures emit on a later tick).
|
|
146
|
+
*/
|
|
147
|
+
function openStudio(options) {
|
|
148
|
+
const child = spawnStudio(options, {
|
|
149
|
+
detached: true,
|
|
150
|
+
stdio: "ignore"
|
|
151
|
+
});
|
|
152
|
+
child.unref();
|
|
153
|
+
return child;
|
|
154
|
+
}
|
|
155
|
+
/** Attached Studio for `cedarpg studio`: inherit stdio, resolve with the child's exit code. */
|
|
156
|
+
function runStudio(options) {
|
|
157
|
+
const { databaseUrl, studio } = options;
|
|
158
|
+
return runAttached(studio.command, studio.args, {
|
|
159
|
+
cwd: studio.cwd,
|
|
160
|
+
env: {
|
|
161
|
+
...process.env,
|
|
162
|
+
DATABASE_URL: databaseUrl
|
|
163
|
+
},
|
|
164
|
+
shell: studio.shell
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function studioChildRunning(child) {
|
|
168
|
+
return Boolean(child && child.exitCode === null && !child.killed);
|
|
169
|
+
}
|
|
170
|
+
//#endregion
|
|
171
|
+
Object.defineProperty(exports, "detectStudio", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
get: function() {
|
|
174
|
+
return detectStudio;
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
Object.defineProperty(exports, "formatDevStatus", {
|
|
178
|
+
enumerable: true,
|
|
179
|
+
get: function() {
|
|
180
|
+
return formatDevStatus;
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
Object.defineProperty(exports, "openStudio", {
|
|
184
|
+
enumerable: true,
|
|
185
|
+
get: function() {
|
|
186
|
+
return openStudio;
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
Object.defineProperty(exports, "runAttached", {
|
|
190
|
+
enumerable: true,
|
|
191
|
+
get: function() {
|
|
192
|
+
return runAttached;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
Object.defineProperty(exports, "runStudio", {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function() {
|
|
198
|
+
return runStudio;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperty(exports, "studioChildRunning", {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get: function() {
|
|
204
|
+
return studioChildRunning;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
//# sourceMappingURL=studio-oJE30_PO.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"studio-oJE30_PO.cjs","names":["CEDAR_PG_TASK_ACQUIRE_TEST","CEDAR_PG_TASK_ACQUIRE_DEV","CLI_NAME"],"sources":["../src/adapters/child.ts","../src/adapters/status-format.ts","../src/adapters/studio.ts"],"sourcesContent":["import { spawn } from \"node:child_process\";\n\nexport type RunAttachedOptions = {\n cwd?: string;\n env?: NodeJS.ProcessEnv;\n shell?: boolean;\n};\n\n/** Attached child: inherit stdio, resolve with exit code (signal → 1). */\nexport function runAttached(\n command: string,\n args: string[],\n options: RunAttachedOptions = {},\n): Promise<number> {\n return new Promise((resolve, reject) => {\n const child = spawn(command, args, {\n stdio: \"inherit\",\n cwd: options.cwd,\n env: options.env,\n shell: options.shell,\n });\n child.once(\"error\", reject);\n child.once(\"exit\", (code, signal) => {\n resolve(signal ? 1 : (code ?? 1));\n });\n });\n}\n","import { CLI_NAME } from \"../core/constants.ts\";\nimport type { DevStatus } from \"../core/status.ts\";\nimport { CEDAR_PG_TASK_ACQUIRE_DEV, CEDAR_PG_TASK_ACQUIRE_TEST } from \"./tasks.ts\";\n\n/** Human-readable lines for the Vite panel / `cedarpg status`. */\nexport function formatDevStatus(status: DevStatus): string[] {\n if (!status.ok) {\n const task = status.mode === \"test\" ? CEDAR_PG_TASK_ACQUIRE_TEST : CEDAR_PG_TASK_ACQUIRE_DEV;\n return [\n `${CLI_NAME}: no ${status.mode} lease at ${status.root}`,\n ` run \\`${CLI_NAME} acquire --mode=${status.mode}\\` (or depend on ${task})`,\n ];\n }\n const { lease, databaseUrl, envPath } = status;\n return [\n `${CLI_NAME}: ${lease.databaseName} (${lease.repoSlug}/${lease.worktreeSlug} ${lease.mode})`,\n ` port ${lease.port}`,\n ` DATABASE_URL ${databaseUrl}`,\n ` env ${envPath}`,\n ];\n}\n","import { createRequire } from \"node:module\";\nimport { spawn, type ChildProcess, type SpawnOptions } from \"node:child_process\";\nimport { existsSync, readFileSync } from \"node:fs\";\nimport { dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { runAttached } from \"./child.ts\";\n\nexport type StudioKind = \"prisma\" | \"drizzle\";\n\nconst STUDIO_PACKAGE: Record<StudioKind, string> = {\n prisma: \"prisma\",\n drizzle: \"drizzle-kit\",\n};\n\nconst AUTO_ORDER: StudioKind[] = [\"prisma\", \"drizzle\"];\n\nexport type DetectStudioOptions = {\n /** Worktree / lease root — directory walk stops here. */\n root: string;\n /** App package to start the walk (Nx `apps/…`). Defaults to `root`. */\n cwd?: string;\n /** Force a kind. Omit to auto-detect (nearest package; prisma if both). */\n prefer?: StudioKind;\n};\n\nexport type DetectedStudio = {\n kind: StudioKind;\n command: string;\n args: string[];\n /** Directory to spawn in (where the ORM package / config was found). */\n cwd: string;\n /** True when falling back to `npx`. */\n shell: boolean;\n};\n\ntype PkgJson = {\n dependencies?: Record<string, string>;\n devDependencies?: Record<string, string>;\n optionalDependencies?: Record<string, string>;\n};\n\nfunction readPackageJson(dir: string): PkgJson | null {\n const file = join(dir, \"package.json\");\n if (!existsSync(file)) return null;\n try {\n return JSON.parse(readFileSync(file, \"utf8\")) as PkgJson;\n } catch {\n return null;\n }\n}\n\nfunction hasDep(pkg: PkgJson | null, name: string): boolean {\n if (!pkg) return false;\n return Boolean(\n pkg.dependencies?.[name] || pkg.devDependencies?.[name] || pkg.optionalDependencies?.[name],\n );\n}\n\nfunction tryResolveBin(dir: string, packageName: string): string | null {\n try {\n const require = createRequire(pathToFileURL(join(dir, \"package.json\")).href);\n const pkgJsonPath = require.resolve(`${packageName}/package.json`);\n const pkg = JSON.parse(readFileSync(pkgJsonPath, \"utf8\")) as {\n bin?: string | Record<string, string>;\n };\n const binField = pkg.bin;\n let rel: string | undefined;\n if (typeof binField === \"string\") rel = binField;\n else if (binField && typeof binField === \"object\") {\n rel = binField[packageName] ?? Object.values(binField)[0];\n }\n if (!rel) return null;\n const abs = join(dirname(pkgJsonPath), rel);\n return existsSync(abs) ? abs : null;\n } catch {\n return null;\n }\n}\n\nfunction npxStudio(kind: StudioKind, cwd: string): DetectedStudio {\n return {\n kind,\n command: \"npx\",\n args: [STUDIO_PACKAGE[kind], \"studio\"],\n cwd,\n shell: true,\n };\n}\n\n/** Local bin, else declared dep → npx, else null. Resolves the bin at most once. */\nfunction studioAt(kind: StudioKind, dir: string): DetectedStudio | null {\n const pkg = STUDIO_PACKAGE[kind];\n const bin = tryResolveBin(dir, pkg);\n if (bin) return { kind, command: bin, args: [\"studio\"], cwd: dir, shell: false };\n if (hasDep(readPackageJson(dir), pkg)) return npxStudio(kind, dir);\n return null;\n}\n\nfunction isInside(dir: string, ancestor: string): boolean {\n const rel = relative(ancestor, dir);\n return rel === \"\" || (!rel.startsWith(\"..\") && !isAbsolute(rel));\n}\n\n/** `start` up to `stop` (inclusive) when `start` is inside the worktree; otherwise only `start`. */\nfunction searchDirs(start: string, stop: string): string[] {\n if (!isInside(start, stop)) return [start];\n const dirs: string[] = [];\n let dir = start;\n for (;;) {\n dirs.push(dir);\n if (dir === stop) return dirs;\n const parent = dirname(dir);\n if (parent === dir) return dirs;\n dir = parent;\n }\n}\n\n/**\n * Detect Prisma Studio or Drizzle Kit Studio, walking from `cwd` up to the worktree `root`.\n *\n * Auto: nearest directory wins, prisma before drizzle in that directory; no npx fallback.\n * Forced `prefer`: same nearest walk for that kind only, then npx at `cwd`.\n */\nexport function detectStudio(options: DetectStudioOptions): DetectedStudio | null {\n const stop = resolve(options.root);\n const start = resolve(options.cwd ?? options.root);\n const dirs = searchDirs(start, stop);\n const kinds = options.prefer ? [options.prefer] : AUTO_ORDER;\n\n for (const dir of dirs) {\n for (const kind of kinds) {\n const hit = studioAt(kind, dir);\n if (hit) return hit;\n }\n }\n return options.prefer ? npxStudio(options.prefer, start) : null;\n}\n\nexport type SpawnStudioOptions = {\n databaseUrl: string;\n studio: DetectedStudio;\n};\n\nfunction spawnStudio(options: SpawnStudioOptions, spawnOpts: SpawnOptions): ChildProcess {\n const { databaseUrl, studio } = options;\n return spawn(studio.command, studio.args, {\n cwd: studio.cwd,\n env: { ...process.env, DATABASE_URL: databaseUrl },\n ...spawnOpts,\n shell: studio.shell,\n });\n}\n\n/**\n * Detached Studio for the Vite shortcut. Caller attaches `error` / `exit` on the\n * returned process (spawn failures emit on a later tick).\n */\nexport function openStudio(options: SpawnStudioOptions): ChildProcess {\n const child = spawnStudio(options, { detached: true, stdio: \"ignore\" });\n child.unref();\n return child;\n}\n\n/** Attached Studio for `cedarpg studio`: inherit stdio, resolve with the child's exit code. */\nexport function runStudio(options: SpawnStudioOptions): Promise<number> {\n const { databaseUrl, studio } = options;\n return runAttached(studio.command, studio.args, {\n cwd: studio.cwd,\n env: { ...process.env, DATABASE_URL: databaseUrl },\n shell: studio.shell,\n });\n}\n\nexport function studioChildRunning(child: ChildProcess | undefined): boolean {\n return Boolean(child && child.exitCode === null && !child.killed);\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,YACd,SACA,MACA,UAA8B,CAAC,GACd;CACjB,OAAO,IAAI,SAAS,SAAS,WAAW;EACtC,MAAM,SAAA,GAAA,mBAAA,MAAA,CAAc,SAAS,MAAM;GACjC,OAAO;GACP,KAAK,QAAQ;GACb,KAAK,QAAQ;GACb,OAAO,QAAQ;EACjB,CAAC;EACD,MAAM,KAAK,SAAS,MAAM;EAC1B,MAAM,KAAK,SAAS,MAAM,WAAW;GACnC,QAAQ,SAAS,IAAK,QAAQ,CAAE;EAClC,CAAC;CACH,CAAC;AACH;;;;ACrBA,SAAgB,gBAAgB,QAA6B;CAC3D,IAAI,CAAC,OAAO,IAAI;EACd,MAAM,OAAO,OAAO,SAAS,SAASA,cAAAA,6BAA6BC,cAAAA;EACnE,OAAO,CACL,GAAGC,cAAAA,SAAS,OAAO,OAAO,KAAK,YAAY,OAAO,QAClD,WAAWA,cAAAA,SA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,OAAO,IAAI;CACnC,MAAM,QAAQ,QAAQ,SAAS,CAAC,QAAQ,MAAM,IAAI;CAElD,KAAK,MAAM,OAAO,MAChB,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,MAAM,SAAS,MAAM,GAAG;EAC9B,IAAI,KAAK,OAAO;CAClB;CAEF,OAAO,QAAQ,SAAS,UAAU,QAAQ,QAAQ,KAAK,IAAI;AAC7D;AAOA,SAAS,YAAY,SAA6B,WAAuC;CACvF,MAAM,EAAE,aAAa,WAAW;CAChC,QAAA,GAAA,mBAAA,MAAA,CAAa,OAAO,SAAS,OAAO,MAAM;EACxC,KAAK,OAAO;EACZ,KAAK;GAAE,GAAG,QAAQ;GAAK,cAAc;EAAY;EACjD,GAAG;EACH,OAAO,OAAO;CAChB,CAAC;AACH;;;;;AAMA,SAAgB,WAAW,SAA2C;CACpE,MAAM,QAAQ,YAAY,SAAS;EAAE,UAAU;EAAM,OAAO;CAAS,CAAC;CACtE,MAAM,MAAM;CACZ,OAAO;AACT;;AAGA,SAAgB,UAAU,SAA8C;CACtE,MAAM,EAAE,aAAa,WAAW;CAChC,OAAO,YAAY,OAAO,SAAS,OAAO,MAAM;EAC9C,KAAK,OAAO;EACZ,KAAK;GAAE,GAAG,QAAQ;GAAK,cAAc;EAAY;EACjD,OAAO,OAAO;CAChB,CAAC;AACH;AAEA,SAAgB,mBAAmB,OAA0C;CAC3E,OAAO,QAAQ,SAAS,MAAM,aAAa,QAAQ,CAAC,MAAM,MAAM;AAClE"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_lease = require("./lease-WlmOnNDi.cjs");
|
|
2
2
|
//#region src/adapters/tasks.ts
|
|
3
3
|
/** Shared CLI command strings and lifecycle target defs for Vite+ / Nx. */
|
|
4
4
|
const CEDAR_PG_TASK_ACQUIRE_DEV = "db:acquire";
|
|
5
5
|
const CEDAR_PG_TASK_ACQUIRE_TEST = "db:acquire-test";
|
|
6
6
|
const CEDAR_PG_TASK_DISPOSE_TEST = "db:dispose-test";
|
|
7
|
-
function cedarPgCommands(bin =
|
|
7
|
+
function cedarPgCommands(bin = require_lease.CLI_NAME) {
|
|
8
8
|
return {
|
|
9
9
|
acquireDev: `${bin} acquire --mode=dev`,
|
|
10
10
|
acquireTest: `${bin} acquire --mode=test --print-env`,
|
|
@@ -29,7 +29,7 @@ function cedarPgLifecycleTargets(options = {}) {
|
|
|
29
29
|
};
|
|
30
30
|
return targets;
|
|
31
31
|
}
|
|
32
|
-
function cedarPgRunCommand(mode, command, bin =
|
|
32
|
+
function cedarPgRunCommand(mode, command, bin = require_lease.CLI_NAME) {
|
|
33
33
|
return `${bin} run --mode=${mode} -- ${command}`;
|
|
34
34
|
}
|
|
35
35
|
//#endregion
|
|
@@ -64,4 +64,4 @@ Object.defineProperty(exports, "cedarPgRunCommand", {
|
|
|
64
64
|
}
|
|
65
65
|
});
|
|
66
66
|
|
|
67
|
-
//# sourceMappingURL=tasks-
|
|
67
|
+
//# sourceMappingURL=tasks-CNHvvlsN.cjs.map
|