@cedarjs/pg 0.1.0-alpha.1 → 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 +361 -89
- package/dist/cli.cjs +131 -35
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +118 -22
- package/dist/cli.mjs.map +1 -1
- package/dist/dev-env.cjs +12 -0
- package/dist/dev-env.cjs.map +1 -0
- package/dist/dev-env.d.cts +1 -0
- package/dist/dev-env.d.mts +1 -0
- package/dist/dev-env.mjs +14 -0
- package/dist/dev-env.mjs.map +1 -0
- package/dist/index.cjs +51 -10
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +198 -84
- package/dist/index.d.mts +198 -84
- package/dist/index.mjs +32 -2
- package/dist/index.mjs.map +1 -0
- package/dist/jest-teardown.cjs +18 -0
- package/dist/jest-teardown.cjs.map +1 -0
- package/dist/jest-teardown.d.cts +13 -0
- package/dist/jest-teardown.d.mts +14 -0
- package/dist/jest-teardown.mjs +18 -0
- package/dist/jest-teardown.mjs.map +1 -0
- package/dist/jest-template.cjs +44 -0
- package/dist/jest-template.cjs.map +1 -0
- package/dist/jest-template.d.cts +31 -0
- package/dist/jest-template.d.mts +31 -0
- package/dist/jest-template.mjs +38 -0
- package/dist/jest-template.mjs.map +1 -0
- package/dist/jest.cjs +12 -15
- package/dist/jest.cjs.map +1 -1
- package/dist/jest.d.cts +10 -7
- package/dist/jest.d.mts +10 -6
- package/dist/jest.mjs +12 -10
- package/dist/jest.mjs.map +1 -1
- package/dist/lease-B3TuX92y.d.mts +24 -0
- package/dist/lease-DS1SX8U_.mjs +221 -0
- package/dist/lease-DS1SX8U_.mjs.map +1 -0
- package/dist/lease-WlmOnNDi.cjs +310 -0
- package/dist/lease-WlmOnNDi.cjs.map +1 -0
- package/dist/lease-t4I9JahV.d.cts +24 -0
- package/dist/lifecycle-BbrvFQvg.cjs +953 -0
- package/dist/lifecycle-BbrvFQvg.cjs.map +1 -0
- package/dist/lifecycle-BvIx0xqq.mjs +781 -0
- package/dist/lifecycle-BvIx0xqq.mjs.map +1 -0
- package/dist/load-dev-env-BULkXyen.mjs +10 -0
- package/dist/load-dev-env-BULkXyen.mjs.map +1 -0
- package/dist/load-dev-env-Bl6Ddv1U.cjs +15 -0
- package/dist/load-dev-env-Bl6Ddv1U.cjs.map +1 -0
- package/dist/load-mode-env-CX9vd56X.cjs +39 -0
- package/dist/load-mode-env-CX9vd56X.cjs.map +1 -0
- package/dist/load-mode-env-Ce9ujisN.mjs +28 -0
- package/dist/load-mode-env-Ce9ujisN.mjs.map +1 -0
- package/dist/load-test-env-BqtA6V-d.mjs +18 -0
- package/dist/load-test-env-BqtA6V-d.mjs.map +1 -0
- package/dist/load-test-env-Dcgh6YHV.cjs +23 -0
- package/dist/load-test-env-Dcgh6YHV.cjs.map +1 -0
- package/dist/naming-C2nGVxPk.d.cts +39 -0
- package/dist/naming-C2nGVxPk.d.mts +39 -0
- package/dist/nx.cjs +25 -18
- package/dist/nx.cjs.map +1 -1
- package/dist/nx.d.cts +9 -20
- package/dist/nx.d.mts +9 -20
- package/dist/nx.mjs +18 -18
- 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-CNHvvlsN.cjs +67 -0
- package/dist/tasks-CNHvvlsN.cjs.map +1 -0
- package/dist/tasks-CjaZRi_G.d.mts +19 -0
- package/dist/tasks-D5iWIdlo.mjs +38 -0
- package/dist/tasks-D5iWIdlo.mjs.map +1 -0
- package/dist/tasks-DdQoP9We.d.cts +19 -0
- package/dist/template-BiJ-0TIF.mjs +88 -0
- package/dist/template-BiJ-0TIF.mjs.map +1 -0
- package/dist/template-CXMpODzK.cjs +105 -0
- package/dist/template-CXMpODzK.cjs.map +1 -0
- package/dist/template-mode-BTUsdBtA.mjs +94 -0
- package/dist/template-mode-BTUsdBtA.mjs.map +1 -0
- package/dist/template-mode-CzyVwHsi.d.cts +31 -0
- package/dist/template-mode-CzyVwHsi.d.mts +31 -0
- package/dist/template-mode-JTOxrEgE.cjs +105 -0
- package/dist/template-mode-JTOxrEgE.cjs.map +1 -0
- package/dist/test-env.cjs +16 -0
- package/dist/test-env.cjs.map +1 -0
- package/dist/test-env.d.cts +1 -0
- package/dist/test-env.d.mts +1 -0
- package/dist/test-env.mjs +18 -0
- package/dist/test-env.mjs.map +1 -0
- package/dist/vite-plus.cjs +113 -35
- package/dist/vite-plus.cjs.map +1 -1
- package/dist/vite-plus.d.cts +26 -46
- package/dist/vite-plus.d.mts +26 -46
- package/dist/vite-plus.mjs +110 -32
- package/dist/vite-plus.mjs.map +1 -1
- package/dist/vitest-template.cjs +48 -0
- package/dist/vitest-template.cjs.map +1 -0
- package/dist/vitest-template.d.cts +31 -0
- package/dist/vitest-template.d.mts +31 -0
- package/dist/vitest-template.mjs +42 -0
- package/dist/vitest-template.mjs.map +1 -0
- package/dist/vitest.cjs +10 -10
- package/dist/vitest.cjs.map +1 -1
- package/dist/vitest.d.cts +7 -3
- package/dist/vitest.d.mts +7 -2
- package/dist/vitest.mjs +10 -5
- package/dist/vitest.mjs.map +1 -1
- package/package.json +46 -13
- package/scripts/autopg-version +1 -0
- package/scripts/ci-install-autopg.sh +73 -0
- package/scripts/postinstall.js +35 -9
- package/dist/constants-BY97wXjA.mjs +0 -24
- package/dist/constants-BY97wXjA.mjs.map +0 -1
- package/dist/constants-CNZn5Xro.cjs +0 -41
- package/dist/constants-CNZn5Xro.cjs.map +0 -1
- package/dist/lifecycle-BGYtVXtx.cjs +0 -743
- package/dist/lifecycle-BGYtVXtx.cjs.map +0 -1
- package/dist/lifecycle-CT_8AWPv.mjs +0 -577
- package/dist/lifecycle-CT_8AWPv.mjs.map +0 -1
- package/dist/tasks-13P6tMth.mjs +0 -16
- package/dist/tasks-13P6tMth.mjs.map +0 -1
- package/dist/tasks-B8ryV9xo.cjs +0 -21
- package/dist/tasks-B8ryV9xo.cjs.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { i as cloneWorkerDatabase, n as TemplateMigrateContext, r as TemplateMigrateFn, t as SetupTemplateModeOptions } from "./template-mode-CzyVwHsi.mjs";
|
|
2
|
+
//#region src/adapters/vitest-template.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* Vitest globalSetup (template mode). Returns teardown that disposes TEMPLATE + clones.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // vitest.cedar-global.ts
|
|
8
|
+
* import { createGlobalSetup } from "@cedarjs/pg/vitest/template";
|
|
9
|
+
* export default createGlobalSetup({ migrate: async ({ databaseUrl }) => {} });
|
|
10
|
+
*
|
|
11
|
+
* // vitest.config.ts
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* test: {
|
|
14
|
+
* globalSetup: ["./vitest.cedar-global.ts"],
|
|
15
|
+
* setupFiles: ["./vitest.cedar-worker.ts"],
|
|
16
|
+
* },
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* // vitest.cedar-worker.ts — local ESM (pack emits CJS+ESM; top-level await lives here)
|
|
20
|
+
* import { cloneWorkerDatabase } from "@cedarjs/pg/vitest/template";
|
|
21
|
+
* await cloneWorkerDatabase();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Stock `@cedarjs/pg/vitest` is one shared test DB only.
|
|
25
|
+
*/
|
|
26
|
+
declare function createGlobalSetup(options: SetupTemplateModeOptions): () => Promise<() => Promise<void>>;
|
|
27
|
+
/** String path without a migrate hook is unsupported — use `createGlobalSetup`. */
|
|
28
|
+
declare function setup(): Promise<() => Promise<void>>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { type SetupTemplateModeOptions, type TemplateMigrateContext, type TemplateMigrateFn, cloneWorkerDatabase, createGlobalSetup, setup as default };
|
|
31
|
+
//# sourceMappingURL=vitest-template.d.mts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { n as setupTemplateMode, t as cloneWorkerDatabase } from "./template-mode-BTUsdBtA.mjs";
|
|
2
|
+
//#region src/adapters/vitest-template.ts
|
|
3
|
+
/**
|
|
4
|
+
* Vitest globalSetup (template mode). Returns teardown that disposes TEMPLATE + clones.
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* // vitest.cedar-global.ts
|
|
8
|
+
* import { createGlobalSetup } from "@cedarjs/pg/vitest/template";
|
|
9
|
+
* export default createGlobalSetup({ migrate: async ({ databaseUrl }) => {} });
|
|
10
|
+
*
|
|
11
|
+
* // vitest.config.ts
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* test: {
|
|
14
|
+
* globalSetup: ["./vitest.cedar-global.ts"],
|
|
15
|
+
* setupFiles: ["./vitest.cedar-worker.ts"],
|
|
16
|
+
* },
|
|
17
|
+
* })
|
|
18
|
+
*
|
|
19
|
+
* // vitest.cedar-worker.ts — local ESM (pack emits CJS+ESM; top-level await lives here)
|
|
20
|
+
* import { cloneWorkerDatabase } from "@cedarjs/pg/vitest/template";
|
|
21
|
+
* await cloneWorkerDatabase();
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* Stock `@cedarjs/pg/vitest` is one shared test DB only.
|
|
25
|
+
*/
|
|
26
|
+
function createGlobalSetup(options) {
|
|
27
|
+
return async () => {
|
|
28
|
+
const result = await setupTemplateMode(options);
|
|
29
|
+
if (result.status !== "acquired") return async () => {};
|
|
30
|
+
return async () => {
|
|
31
|
+
await result.dispose();
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** String path without a migrate hook is unsupported — use `createGlobalSetup`. */
|
|
36
|
+
async function setup() {
|
|
37
|
+
throw new Error("@cedarjs/pg/vitest/template requires createGlobalSetup({ migrate }). Point globalSetup at a local module that exports createGlobalSetup({ migrate }).");
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { cloneWorkerDatabase, createGlobalSetup, setup as default };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=vitest-template.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest-template.mjs","names":[],"sources":["../src/adapters/vitest-template.ts"],"sourcesContent":["import {\n cloneWorkerDatabase,\n setupTemplateMode,\n type SetupTemplateModeOptions,\n} from \"./template-mode.ts\";\n\nexport { cloneWorkerDatabase };\nexport type {\n SetupTemplateModeOptions,\n TemplateMigrateFn,\n TemplateMigrateContext,\n} from \"./template-mode.ts\";\n\n/**\n * Vitest globalSetup (template mode). Returns teardown that disposes TEMPLATE + clones.\n *\n * ```ts\n * // vitest.cedar-global.ts\n * import { createGlobalSetup } from \"@cedarjs/pg/vitest/template\";\n * export default createGlobalSetup({ migrate: async ({ databaseUrl }) => {} });\n *\n * // vitest.config.ts\n * export default defineConfig({\n * test: {\n * globalSetup: [\"./vitest.cedar-global.ts\"],\n * setupFiles: [\"./vitest.cedar-worker.ts\"],\n * },\n * })\n *\n * // vitest.cedar-worker.ts — local ESM (pack emits CJS+ESM; top-level await lives here)\n * import { cloneWorkerDatabase } from \"@cedarjs/pg/vitest/template\";\n * await cloneWorkerDatabase();\n * ```\n *\n * Stock `@cedarjs/pg/vitest` is one shared test DB only.\n */\nexport function createGlobalSetup(options: SetupTemplateModeOptions) {\n return async () => {\n const result = await setupTemplateMode(options);\n if (result.status !== \"acquired\") {\n return async () => {};\n }\n return async () => {\n await result.dispose();\n };\n };\n}\n\n/** String path without a migrate hook is unsupported — use `createGlobalSetup`. */\nexport default async function setup(): Promise<() => Promise<void>> {\n throw new Error(\n \"@cedarjs/pg/vitest/template requires createGlobalSetup({ migrate }). \" +\n \"Point globalSetup at a local module that exports createGlobalSetup({ migrate }).\",\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAAgB,kBAAkB,SAAmC;CACnE,OAAO,YAAY;EACjB,MAAM,SAAS,MAAM,kBAAkB,OAAO;EAC9C,IAAI,OAAO,WAAW,YACpB,OAAO,YAAY,CAAC;EAEtB,OAAO,YAAY;GACjB,MAAM,OAAO,QAAQ;EACvB;CACF;AACF;;AAGA,eAA8B,QAAsC;CAClE,MAAM,IAAI,MACR,uJAEF;AACF"}
|
package/dist/vitest.cjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
__esModule: { value: true },
|
|
3
|
-
[Symbol.toStringTag]: { value: "Module" }
|
|
4
|
-
});
|
|
5
|
-
const require_lifecycle = require("./lifecycle-BGYtVXtx.cjs");
|
|
1
|
+
const require_lifecycle = require("./lifecycle-BbrvFQvg.cjs");
|
|
6
2
|
//#region src/adapters/vitest.ts
|
|
7
3
|
/**
|
|
8
|
-
* Vitest globalSetup
|
|
4
|
+
* Vitest globalSetup for a single shared test DB.
|
|
5
|
+
* Not a migrate-once / per-worker TEMPLATE runner — use `@cedarjs/pg/vitest/template`.
|
|
6
|
+
*
|
|
7
|
+
* Vitest runs globalSetup in the main process then spawns workers, so
|
|
8
|
+
* `process.env` mutations (via `setEnv`) are inherited. Pair with
|
|
9
|
+
* `setupFiles: ['@cedarjs/pg/test-env']` only if your pool does not inherit env.
|
|
9
10
|
*
|
|
10
11
|
* vitest.config.ts:
|
|
11
12
|
* ```ts
|
|
@@ -17,17 +18,16 @@ const require_lifecycle = require("./lifecycle-BGYtVXtx.cjs");
|
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
20
|
async function setup() {
|
|
20
|
-
const result = await require_lifecycle.
|
|
21
|
+
const result = await require_lifecycle.acquireIfNeeded({
|
|
21
22
|
mode: "test",
|
|
22
23
|
setEnv: true
|
|
23
24
|
});
|
|
24
|
-
if (result.status !== "
|
|
25
|
+
if (result.status !== "acquired") return async () => {};
|
|
25
26
|
return async () => {
|
|
26
27
|
await result.dispose();
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
30
|
//#endregion
|
|
30
|
-
exports
|
|
31
|
-
exports.setup = setup;
|
|
31
|
+
module.exports = setup;
|
|
32
32
|
|
|
33
33
|
//# sourceMappingURL=vitest.cjs.map
|
package/dist/vitest.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":["
|
|
1
|
+
{"version":3,"file":"vitest.cjs","names":["acquireIfNeeded"],"sources":["../src/adapters/vitest.ts"],"sourcesContent":["import { acquireIfNeeded } from \"../core/lifecycle.ts\";\n\n/**\n * Vitest globalSetup for a single shared test DB.\n * Not a migrate-once / per-worker TEMPLATE runner — use `@cedarjs/pg/vitest/template`.\n *\n * Vitest runs globalSetup in the main process then spawns workers, so\n * `process.env` mutations (via `setEnv`) are inherited. Pair with\n * `setupFiles: ['@cedarjs/pg/test-env']` only if your pool does not inherit env.\n *\n * vitest.config.ts:\n * ```ts\n * export default defineConfig({\n * test: {\n * globalSetup: ['@cedarjs/pg/vitest'],\n * },\n * })\n * ```\n */\nexport default async function setup(): Promise<() => Promise<void>> {\n const result = await acquireIfNeeded({\n mode: \"test\",\n setEnv: true,\n });\n if (result.status !== \"acquired\") {\n return async () => {};\n }\n return async () => {\n await result.dispose();\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAA8B,QAAsC;CAClE,MAAM,SAAS,MAAMA,kBAAAA,gBAAgB;EACnC,MAAM;EACN,QAAQ;CACV,CAAC;CACD,IAAI,OAAO,WAAW,YACpB,OAAO,YAAY,CAAC;CAEtB,OAAO,YAAY;EACjB,MAAM,OAAO,QAAQ;CACvB;AACF"}
|
package/dist/vitest.d.cts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
//#region src/adapters/vitest.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Vitest globalSetup
|
|
3
|
+
* Vitest globalSetup for a single shared test DB.
|
|
4
|
+
* Not a migrate-once / per-worker TEMPLATE runner — use `@cedarjs/pg/vitest/template`.
|
|
5
|
+
*
|
|
6
|
+
* Vitest runs globalSetup in the main process then spawns workers, so
|
|
7
|
+
* `process.env` mutations (via `setEnv`) are inherited. Pair with
|
|
8
|
+
* `setupFiles: ['@cedarjs/pg/test-env']` only if your pool does not inherit env.
|
|
4
9
|
*
|
|
5
10
|
* vitest.config.ts:
|
|
6
11
|
* ```ts
|
|
@@ -12,6 +17,5 @@
|
|
|
12
17
|
* ```
|
|
13
18
|
*/
|
|
14
19
|
declare function setup(): Promise<() => Promise<void>>;
|
|
15
|
-
|
|
16
|
-
export { setup as default, setup };
|
|
20
|
+
export = setup;
|
|
17
21
|
//# sourceMappingURL=vitest.d.cts.map
|
package/dist/vitest.d.mts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
//#region src/adapters/vitest.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Vitest globalSetup
|
|
3
|
+
* Vitest globalSetup for a single shared test DB.
|
|
4
|
+
* Not a migrate-once / per-worker TEMPLATE runner — use `@cedarjs/pg/vitest/template`.
|
|
5
|
+
*
|
|
6
|
+
* Vitest runs globalSetup in the main process then spawns workers, so
|
|
7
|
+
* `process.env` mutations (via `setEnv`) are inherited. Pair with
|
|
8
|
+
* `setupFiles: ['@cedarjs/pg/test-env']` only if your pool does not inherit env.
|
|
4
9
|
*
|
|
5
10
|
* vitest.config.ts:
|
|
6
11
|
* ```ts
|
|
@@ -13,5 +18,5 @@
|
|
|
13
18
|
*/
|
|
14
19
|
declare function setup(): Promise<() => Promise<void>>;
|
|
15
20
|
//#endregion
|
|
16
|
-
export { setup as default
|
|
21
|
+
export { setup as default };
|
|
17
22
|
//# sourceMappingURL=vitest.d.mts.map
|
package/dist/vitest.mjs
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as acquireIfNeeded } from "./lifecycle-BvIx0xqq.mjs";
|
|
2
2
|
//#region src/adapters/vitest.ts
|
|
3
3
|
/**
|
|
4
|
-
* Vitest globalSetup
|
|
4
|
+
* Vitest globalSetup for a single shared test DB.
|
|
5
|
+
* Not a migrate-once / per-worker TEMPLATE runner — use `@cedarjs/pg/vitest/template`.
|
|
6
|
+
*
|
|
7
|
+
* Vitest runs globalSetup in the main process then spawns workers, so
|
|
8
|
+
* `process.env` mutations (via `setEnv`) are inherited. Pair with
|
|
9
|
+
* `setupFiles: ['@cedarjs/pg/test-env']` only if your pool does not inherit env.
|
|
5
10
|
*
|
|
6
11
|
* vitest.config.ts:
|
|
7
12
|
* ```ts
|
|
@@ -13,16 +18,16 @@ import { r as ensureIfNeeded } from "./lifecycle-CT_8AWPv.mjs";
|
|
|
13
18
|
* ```
|
|
14
19
|
*/
|
|
15
20
|
async function setup() {
|
|
16
|
-
const result = await
|
|
21
|
+
const result = await acquireIfNeeded({
|
|
17
22
|
mode: "test",
|
|
18
23
|
setEnv: true
|
|
19
24
|
});
|
|
20
|
-
if (result.status !== "
|
|
25
|
+
if (result.status !== "acquired") return async () => {};
|
|
21
26
|
return async () => {
|
|
22
27
|
await result.dispose();
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
30
|
//#endregion
|
|
26
|
-
export { setup as default
|
|
31
|
+
export { setup as default };
|
|
27
32
|
|
|
28
33
|
//# sourceMappingURL=vitest.mjs.map
|
package/dist/vitest.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.mjs","names":[],"sources":["../src/adapters/vitest.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"vitest.mjs","names":[],"sources":["../src/adapters/vitest.ts"],"sourcesContent":["import { acquireIfNeeded } from \"../core/lifecycle.ts\";\n\n/**\n * Vitest globalSetup for a single shared test DB.\n * Not a migrate-once / per-worker TEMPLATE runner — use `@cedarjs/pg/vitest/template`.\n *\n * Vitest runs globalSetup in the main process then spawns workers, so\n * `process.env` mutations (via `setEnv`) are inherited. Pair with\n * `setupFiles: ['@cedarjs/pg/test-env']` only if your pool does not inherit env.\n *\n * vitest.config.ts:\n * ```ts\n * export default defineConfig({\n * test: {\n * globalSetup: ['@cedarjs/pg/vitest'],\n * },\n * })\n * ```\n */\nexport default async function setup(): Promise<() => Promise<void>> {\n const result = await acquireIfNeeded({\n mode: \"test\",\n setEnv: true,\n });\n if (result.status !== \"acquired\") {\n return async () => {};\n }\n return async () => {\n await result.dispose();\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,eAA8B,QAAsC;CAClE,MAAM,SAAS,MAAM,gBAAgB;EACnC,MAAM;EACN,QAAQ;CACV,CAAC;CACD,IAAI,OAAO,WAAW,YACpB,OAAO,YAAY,CAAC;CAEtB,OAAO,YAAY;EACjB,MAAM,OAAO,QAAQ;CACvB;AACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/pg",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0-beta.0",
|
|
4
4
|
"description": "Worktree-isolated local Postgres for Vite+, Nx, and CedarJS (via autopg)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"autopg",
|
|
@@ -29,6 +29,8 @@
|
|
|
29
29
|
},
|
|
30
30
|
"files": [
|
|
31
31
|
"dist",
|
|
32
|
+
"scripts/autopg-version",
|
|
33
|
+
"scripts/ci-install-autopg.sh",
|
|
32
34
|
"scripts/postinstall.js"
|
|
33
35
|
],
|
|
34
36
|
"type": "module",
|
|
@@ -56,25 +58,41 @@
|
|
|
56
58
|
"import": "./dist/vitest.mjs",
|
|
57
59
|
"require": "./dist/vitest.cjs"
|
|
58
60
|
},
|
|
61
|
+
"./vitest/template": {
|
|
62
|
+
"types": "./dist/vitest-template.d.mts",
|
|
63
|
+
"import": "./dist/vitest-template.mjs",
|
|
64
|
+
"require": "./dist/vitest-template.cjs"
|
|
65
|
+
},
|
|
59
66
|
"./jest": {
|
|
60
67
|
"types": "./dist/jest.d.mts",
|
|
61
68
|
"import": "./dist/jest.mjs",
|
|
62
69
|
"require": "./dist/jest.cjs"
|
|
63
70
|
},
|
|
71
|
+
"./jest-teardown": {
|
|
72
|
+
"types": "./dist/jest-teardown.d.mts",
|
|
73
|
+
"import": "./dist/jest-teardown.mjs",
|
|
74
|
+
"require": "./dist/jest-teardown.cjs"
|
|
75
|
+
},
|
|
76
|
+
"./test-env": {
|
|
77
|
+
"types": "./dist/test-env.d.mts",
|
|
78
|
+
"import": "./dist/test-env.mjs",
|
|
79
|
+
"require": "./dist/test-env.cjs"
|
|
80
|
+
},
|
|
81
|
+
"./dev-env": {
|
|
82
|
+
"types": "./dist/dev-env.d.mts",
|
|
83
|
+
"import": "./dist/dev-env.mjs",
|
|
84
|
+
"require": "./dist/dev-env.cjs"
|
|
85
|
+
},
|
|
86
|
+
"./jest/template": {
|
|
87
|
+
"types": "./dist/jest-template.d.mts",
|
|
88
|
+
"import": "./dist/jest-template.mjs",
|
|
89
|
+
"require": "./dist/jest-template.cjs"
|
|
90
|
+
},
|
|
64
91
|
"./package.json": "./package.json"
|
|
65
92
|
},
|
|
66
93
|
"publishConfig": {
|
|
67
94
|
"access": "public",
|
|
68
|
-
"tag": "
|
|
69
|
-
},
|
|
70
|
-
"scripts": {
|
|
71
|
-
"build": "vp pack",
|
|
72
|
-
"dev": "vp pack --watch",
|
|
73
|
-
"test": "vp test",
|
|
74
|
-
"check": "vp check",
|
|
75
|
-
"prepublishOnly": "vp pack",
|
|
76
|
-
"postinstall": "node scripts/postinstall.js",
|
|
77
|
-
"prepare": "vp config || true"
|
|
95
|
+
"tag": "beta"
|
|
78
96
|
},
|
|
79
97
|
"dependencies": {
|
|
80
98
|
"pg": "^8.16.3"
|
|
@@ -83,8 +101,17 @@
|
|
|
83
101
|
"@types/node": "^22.15.0",
|
|
84
102
|
"@types/pg": "^8.15.4",
|
|
85
103
|
"typescript": "^5.8.3",
|
|
104
|
+
"vite": "^8.2.0",
|
|
86
105
|
"vite-plus": "^0.2.4"
|
|
87
106
|
},
|
|
107
|
+
"peerDependencies": {
|
|
108
|
+
"vite": ">=8.0.0"
|
|
109
|
+
},
|
|
110
|
+
"peerDependenciesMeta": {
|
|
111
|
+
"vite": {
|
|
112
|
+
"optional": true
|
|
113
|
+
}
|
|
114
|
+
},
|
|
88
115
|
"overrides": {
|
|
89
116
|
"vite": "npm:@voidzero-dev/vite-plus-core@latest",
|
|
90
117
|
"vitest": "4.1.9"
|
|
@@ -92,5 +119,11 @@
|
|
|
92
119
|
"engines": {
|
|
93
120
|
"node": ">=24"
|
|
94
121
|
},
|
|
95
|
-
"
|
|
96
|
-
|
|
122
|
+
"scripts": {
|
|
123
|
+
"build": "vp pack",
|
|
124
|
+
"dev": "vp pack --watch",
|
|
125
|
+
"test": "vp test",
|
|
126
|
+
"check": "vp check",
|
|
127
|
+
"postinstall": "node scripts/postinstall.js"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
v3.0.7
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Binary-only autopg install for CI (and postinstall when CEDAR_PG_INSTALL_AUTOPG=1).
|
|
3
|
+
# Fetches pinned release, verifies attestation, installs binary — no pm2.
|
|
4
|
+
# Version pin: scripts/autopg-version (override with AUTOPG_VERSION).
|
|
5
|
+
set -euo pipefail
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
if [ -z "${AUTOPG_VERSION:-}" ]; then
|
|
9
|
+
AUTOPG_VERSION="$(tr -d '[:space:]' <"${SCRIPT_DIR}/autopg-version")"
|
|
10
|
+
fi
|
|
11
|
+
VERSION="${AUTOPG_VERSION}"
|
|
12
|
+
REPO="${AUTOPG_REPO:-automagik-dev/autopg}"
|
|
13
|
+
LEGACY_REPO="${AUTOPG_LEGACY_REPO:-namastexlabs/pgserve}"
|
|
14
|
+
|
|
15
|
+
detect_libc() {
|
|
16
|
+
if [ -e /lib/ld-musl-x86_64.so.1 ] || (ldd --version 2>&1 | grep -qi musl); then
|
|
17
|
+
echo musl
|
|
18
|
+
else
|
|
19
|
+
echo glibc
|
|
20
|
+
fi
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
case "$(uname -s)-$(uname -m)" in
|
|
24
|
+
Linux-x86_64) PLATFORM="linux-x64-$(detect_libc)" ;;
|
|
25
|
+
Linux-aarch64) PLATFORM="linux-arm64" ;;
|
|
26
|
+
Darwin-arm64) PLATFORM="darwin-arm64" ;;
|
|
27
|
+
Darwin-x86_64) PLATFORM="darwin-x64" ;;
|
|
28
|
+
*)
|
|
29
|
+
echo "[ci-install-autopg] unsupported platform: $(uname -s)-$(uname -m)" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
;;
|
|
32
|
+
esac
|
|
33
|
+
|
|
34
|
+
if [ -x "${HOME}/.local/bin/autopg" ]; then
|
|
35
|
+
echo "[ci-install-autopg] already present: ${HOME}/.local/bin/autopg"
|
|
36
|
+
exit 0
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
TARBALL="autopg-${VERSION#v}-${PLATFORM}.tar.gz"
|
|
40
|
+
URL="https://github.com/${REPO}/releases/download/${VERSION}/${TARBALL}"
|
|
41
|
+
TMP="$(mktemp -d)"
|
|
42
|
+
trap 'rm -rf "$TMP"' EXIT
|
|
43
|
+
|
|
44
|
+
echo "[ci-install-autopg] fetching ${URL}"
|
|
45
|
+
curl -fsSL --output "${TMP}/${TARBALL}" "${URL}"
|
|
46
|
+
|
|
47
|
+
if ! command -v gh >/dev/null 2>&1; then
|
|
48
|
+
echo "[ci-install-autopg] gh CLI required for attestation verify" >&2
|
|
49
|
+
exit 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
echo "[ci-install-autopg] verifying attestation"
|
|
53
|
+
if ! gh attestation verify "${TMP}/${TARBALL}" --repo "${REPO}" \
|
|
54
|
+
&& ! gh attestation verify "${TMP}/${TARBALL}" --repo "${LEGACY_REPO}"; then
|
|
55
|
+
echo "[ci-install-autopg] attestation verify failed" >&2
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
echo "[ci-install-autopg] extracting binary tree"
|
|
60
|
+
tar -xzf "${TMP}/${TARBALL}" -C "${TMP}"
|
|
61
|
+
SRC="${TMP}/autopg"
|
|
62
|
+
if [ ! -x "${SRC}/autopg" ]; then
|
|
63
|
+
echo "[ci-install-autopg] unexpected tarball layout: ${SRC}/autopg missing" >&2
|
|
64
|
+
exit 1
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
INSTALL_DIR="${HOME}/.local/share/autopg/${VERSION}"
|
|
68
|
+
mkdir -p "${INSTALL_DIR}" "${HOME}/.local/bin"
|
|
69
|
+
cp -a "${SRC}/." "${INSTALL_DIR}/"
|
|
70
|
+
ln -sfn "${INSTALL_DIR}/autopg" "${HOME}/.local/bin/autopg"
|
|
71
|
+
|
|
72
|
+
echo "[ci-install-autopg] ok — $(command -v autopg || echo "${HOME}/.local/bin/autopg")"
|
|
73
|
+
"${HOME}/.local/bin/autopg" --help >/dev/null
|
package/scripts/postinstall.js
CHANGED
|
@@ -4,19 +4,23 @@
|
|
|
4
4
|
* Idempotent across npm / yarn / pnpm. Never fails the parent install hard
|
|
5
5
|
* when network is unavailable; prints a clear warning instead.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* Version pin: scripts/autopg-version (single source of truth).
|
|
8
|
+
*
|
|
9
|
+
* - Local / non-CI: pinned upstream install.sh (may start pm2).
|
|
10
|
+
* - CI + CEDAR_PG_INSTALL_AUTOPG=1: binary-only scripts/ci-install-autopg.sh
|
|
11
|
+
* (attestation via gh; no pm2 — cedar-pg ephemeral host owns startup).
|
|
10
12
|
*/
|
|
11
13
|
|
|
12
14
|
import { spawnSync } from "node:child_process";
|
|
13
|
-
import { existsSync } from "node:fs";
|
|
15
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
14
16
|
import { homedir } from "node:os";
|
|
15
|
-
import { join } from "node:path";
|
|
17
|
+
import { dirname, join } from "node:path";
|
|
18
|
+
import { fileURLToPath } from "node:url";
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
const AUTOPG_VERSION = "
|
|
20
|
+
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
21
|
+
const AUTOPG_VERSION = readFileSync(join(HERE, "autopg-version"), "utf8").trim();
|
|
19
22
|
const INSTALL_URL = `https://raw.githubusercontent.com/automagik-dev/autopg/${AUTOPG_VERSION}/install.sh`;
|
|
23
|
+
const CI_INSTALL = join(HERE, "ci-install-autopg.sh");
|
|
20
24
|
|
|
21
25
|
function hasAutopg() {
|
|
22
26
|
if (process.env.AUTOPG_BIN && existsSync(process.env.AUTOPG_BIN)) return true;
|
|
@@ -34,12 +38,34 @@ function main() {
|
|
|
34
38
|
return;
|
|
35
39
|
}
|
|
36
40
|
|
|
41
|
+
const inCi = process.env.CI === "true";
|
|
42
|
+
const forceCiInstall = process.env.CEDAR_PG_INSTALL_AUTOPG === "1";
|
|
43
|
+
|
|
37
44
|
// Skip in CI unless explicitly requested; CI images often bake autopg
|
|
38
|
-
|
|
45
|
+
// or run scripts/ci-install-autopg.sh from the workflow.
|
|
46
|
+
if (inCi && !forceCiInstall) {
|
|
39
47
|
console.warn(
|
|
40
48
|
"[cedarpg] autopg not found; CI detected, skip auto-install. " +
|
|
41
|
-
"Set CEDAR_PG_INSTALL_AUTOPG=1 or install
|
|
49
|
+
"Set CEDAR_PG_INSTALL_AUTOPG=1 or run scripts/ci-install-autopg.sh.",
|
|
50
|
+
);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (inCi && forceCiInstall) {
|
|
55
|
+
console.log(
|
|
56
|
+
`[cedarpg] autopg not found; CI binary install ${AUTOPG_VERSION} via ci-install-autopg.sh...`,
|
|
42
57
|
);
|
|
58
|
+
const result = spawnSync("bash", [CI_INSTALL], {
|
|
59
|
+
stdio: "inherit",
|
|
60
|
+
env: { ...process.env, AUTOPG_VERSION },
|
|
61
|
+
});
|
|
62
|
+
if (result.status !== 0) {
|
|
63
|
+
console.warn(
|
|
64
|
+
"[cedarpg] CI binary install failed.\n" +
|
|
65
|
+
" Run: bash scripts/ci-install-autopg.sh\n" +
|
|
66
|
+
" (requires gh CLI + GH_TOKEN for attestation verify)",
|
|
67
|
+
);
|
|
68
|
+
}
|
|
43
69
|
return;
|
|
44
70
|
}
|
|
45
71
|
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
//#region src/core/constants.ts
|
|
2
|
-
/**
|
|
3
|
-
* Product identity vs frozen crypto.
|
|
4
|
-
*
|
|
5
|
-
* State dirs follow the CLI name (`.cedarpg`): product-owned, not nested under
|
|
6
|
-
* autopg's `~/.autopg/` (host owns that) and not a generic `.pg` (collision-prone).
|
|
7
|
-
* Password salt is an opaque crypto constant; bump ROLE_PASSWORD_SCHEME to change it.
|
|
8
|
-
*/
|
|
9
|
-
/** User-facing CLI binary (`package.json` bin) and log prefix */
|
|
10
|
-
const CLI_NAME = "cedarpg";
|
|
11
|
-
/**
|
|
12
|
-
* Worktree-local state dir and home-registry parent (`~/.cedarpg/registry`).
|
|
13
|
-
* Frozen for lease/gc discovery after first alpha consumers appear.
|
|
14
|
-
*/
|
|
15
|
-
const STATE_DIRNAME = ".cedarpg";
|
|
16
|
-
/**
|
|
17
|
-
* Password scheme v1 salt prefix: sha256(`${PASSWORD_SALT_PREFIX}\0` + databaseName).
|
|
18
|
-
* Opaque; independent of STATE_DIRNAME / CLI_NAME. Bump ROLE_PASSWORD_SCHEME to change.
|
|
19
|
-
*/
|
|
20
|
-
const PASSWORD_SALT_PREFIX = "cedar-pg";
|
|
21
|
-
//#endregion
|
|
22
|
-
export { PASSWORD_SALT_PREFIX as n, STATE_DIRNAME as r, CLI_NAME as t };
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=constants-BY97wXjA.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants-BY97wXjA.mjs","names":[],"sources":["../src/core/constants.ts"],"sourcesContent":["/**\n * Product identity vs frozen crypto.\n *\n * State dirs follow the CLI name (`.cedarpg`): product-owned, not nested under\n * autopg's `~/.autopg/` (host owns that) and not a generic `.pg` (collision-prone).\n * Password salt is an opaque crypto constant; bump ROLE_PASSWORD_SCHEME to change it.\n */\n\n/** User-facing CLI binary (`package.json` bin) and log prefix */\nexport const CLI_NAME = \"cedarpg\";\n\n/**\n * Worktree-local state dir and home-registry parent (`~/.cedarpg/registry`).\n * Frozen for lease/gc discovery after first alpha consumers appear.\n */\nexport const STATE_DIRNAME = \".cedarpg\";\n\n/**\n * Password scheme v1 salt prefix: sha256(`${PASSWORD_SALT_PREFIX}\\0` + databaseName).\n * Opaque; independent of STATE_DIRNAME / CLI_NAME. Bump ROLE_PASSWORD_SCHEME to change.\n */\nexport const PASSWORD_SALT_PREFIX = \"cedar-pg\";\n"],"mappings":";;;;;;;;;AASA,MAAa,WAAW;;;;;AAMxB,MAAa,gBAAgB;;;;;AAM7B,MAAa,uBAAuB"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
//#region src/core/constants.ts
|
|
2
|
-
/**
|
|
3
|
-
* Product identity vs frozen crypto.
|
|
4
|
-
*
|
|
5
|
-
* State dirs follow the CLI name (`.cedarpg`): product-owned, not nested under
|
|
6
|
-
* autopg's `~/.autopg/` (host owns that) and not a generic `.pg` (collision-prone).
|
|
7
|
-
* Password salt is an opaque crypto constant; bump ROLE_PASSWORD_SCHEME to change it.
|
|
8
|
-
*/
|
|
9
|
-
/** User-facing CLI binary (`package.json` bin) and log prefix */
|
|
10
|
-
const CLI_NAME = "cedarpg";
|
|
11
|
-
/**
|
|
12
|
-
* Worktree-local state dir and home-registry parent (`~/.cedarpg/registry`).
|
|
13
|
-
* Frozen for lease/gc discovery after first alpha consumers appear.
|
|
14
|
-
*/
|
|
15
|
-
const STATE_DIRNAME = ".cedarpg";
|
|
16
|
-
/**
|
|
17
|
-
* Password scheme v1 salt prefix: sha256(`${PASSWORD_SALT_PREFIX}\0` + databaseName).
|
|
18
|
-
* Opaque; independent of STATE_DIRNAME / CLI_NAME. Bump ROLE_PASSWORD_SCHEME to change.
|
|
19
|
-
*/
|
|
20
|
-
const PASSWORD_SALT_PREFIX = "cedar-pg";
|
|
21
|
-
//#endregion
|
|
22
|
-
Object.defineProperty(exports, "CLI_NAME", {
|
|
23
|
-
enumerable: true,
|
|
24
|
-
get: function() {
|
|
25
|
-
return CLI_NAME;
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
Object.defineProperty(exports, "PASSWORD_SALT_PREFIX", {
|
|
29
|
-
enumerable: true,
|
|
30
|
-
get: function() {
|
|
31
|
-
return PASSWORD_SALT_PREFIX;
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
Object.defineProperty(exports, "STATE_DIRNAME", {
|
|
35
|
-
enumerable: true,
|
|
36
|
-
get: function() {
|
|
37
|
-
return STATE_DIRNAME;
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
//# sourceMappingURL=constants-CNZn5Xro.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants-CNZn5Xro.cjs","names":[],"sources":["../src/core/constants.ts"],"sourcesContent":["/**\n * Product identity vs frozen crypto.\n *\n * State dirs follow the CLI name (`.cedarpg`): product-owned, not nested under\n * autopg's `~/.autopg/` (host owns that) and not a generic `.pg` (collision-prone).\n * Password salt is an opaque crypto constant; bump ROLE_PASSWORD_SCHEME to change it.\n */\n\n/** User-facing CLI binary (`package.json` bin) and log prefix */\nexport const CLI_NAME = \"cedarpg\";\n\n/**\n * Worktree-local state dir and home-registry parent (`~/.cedarpg/registry`).\n * Frozen for lease/gc discovery after first alpha consumers appear.\n */\nexport const STATE_DIRNAME = \".cedarpg\";\n\n/**\n * Password scheme v1 salt prefix: sha256(`${PASSWORD_SALT_PREFIX}\\0` + databaseName).\n * Opaque; independent of STATE_DIRNAME / CLI_NAME. Bump ROLE_PASSWORD_SCHEME to change.\n */\nexport const PASSWORD_SALT_PREFIX = \"cedar-pg\";\n"],"mappings":";;;;;;;;;AASA,MAAa,WAAW;;;;;AAMxB,MAAa,gBAAgB;;;;;AAM7B,MAAa,uBAAuB"}
|