feat(cli): add production workspace command
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import { expect, test } from "bun:test";
|
||||
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { currentCliVersion } from "../src/update-notifier.ts";
|
||||
import { addWorkspaceApp, insertWorkspaceApp, workspaceFiles } from "../src/workspace.ts";
|
||||
import {
|
||||
addWorkspaceApp,
|
||||
insertWorkspaceApp,
|
||||
workspaceFiles,
|
||||
workspaceMigrationTargets,
|
||||
} from "../src/workspace.ts";
|
||||
|
||||
test("workspace templates pin the running framework release", () => {
|
||||
const files = workspaceFiles("acme");
|
||||
@@ -15,6 +20,21 @@ test("workspace templates pin the running framework release", () => {
|
||||
expect(sharedPackage.dependencies["@wrnexus/pubsub"]).toBe(version);
|
||||
expect(files["README.md"]).toContain("http://127.0.0.1:3000");
|
||||
expect(files["README.md"]).toContain("internal gateway targets");
|
||||
expect(JSON.parse(files["package.json"]!).scripts.production).toBe("wrnexus production");
|
||||
});
|
||||
|
||||
test("production workspace detects default and named SQL migrations", () => {
|
||||
const root = mkdtempSync(join(tmpdir(), "wrnexus-production-migrations-"));
|
||||
try {
|
||||
mkdirSync(join(root, "app", "db", "migrations"), { recursive: true });
|
||||
mkdirSync(join(root, "app", "db", "analytics", "migrations"), { recursive: true });
|
||||
mkdirSync(join(root, "app", "db", "empty", "migrations"), { recursive: true });
|
||||
writeFileSync(join(root, "app", "db", "migrations", "0001_init.sql"), "select 1;");
|
||||
writeFileSync(join(root, "app", "db", "analytics", "migrations", "0001_init.sql"), "select 1;");
|
||||
expect(workspaceMigrationTargets(root)).toEqual([null, "analytics"]);
|
||||
} finally {
|
||||
rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test("insertWorkspaceApp handles nested arrays and comments", () => {
|
||||
|
||||
Reference in New Issue
Block a user