refactor: remove core-realtime from main (scaffoldable via gen core-package realtime)
This commit is contained in:
@@ -1,15 +1,19 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mkdtempSync, cpSync, readFileSync } from "node:fs";
|
||||
import { mkdtempSync, cpSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { execSync } from "node:child_process";
|
||||
import { join } from "node:path";
|
||||
import { join, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { computeSnapshot } from "../lib/snapshot";
|
||||
import expectedSnapshot from "../__snapshots__/core-package/realtime.snapshot.json";
|
||||
|
||||
// Repo root is 2 levels up from turbo/generators/__tests__
|
||||
const REPO_ROOT = resolve(fileURLToPath(import.meta.url), "..", "..", "..", "..");
|
||||
|
||||
describe("e2e: core-package realtime", () => {
|
||||
it("byte-identical reconstruction matches snapshot", { timeout: 120_000 }, () => {
|
||||
const tmp = mkdtempSync(join(tmpdir(), "e2e-"));
|
||||
cpSync(process.cwd(), tmp, {
|
||||
cpSync(REPO_ROOT, tmp, {
|
||||
recursive: true,
|
||||
filter: (src) =>
|
||||
!src.includes("node_modules") &&
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import { existsSync, readFileSync, writeFileSync, readdirSync, statSync } from "node:fs";
|
||||
import { join, relative, dirname } from "node:path";
|
||||
import { join, relative } from "node:path";
|
||||
import type { PlopTypes } from "@turbo/gen";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = dirname(__filename);
|
||||
|
||||
/**
|
||||
* Throws if a core package directory already exists. Used as the first action
|
||||
@@ -116,8 +112,18 @@ export function emitTemplateTree(
|
||||
destPrefix: string,
|
||||
opts: { templatesRoot?: string } = {},
|
||||
): PlopTypes.AddActionConfig[] {
|
||||
const root =
|
||||
opts.templatesRoot ?? join(__dirname, "..", "templates");
|
||||
// The templates directory is resolved in priority order:
|
||||
// 1. opts.templatesRoot — test injection (temp directory)
|
||||
// 2. cwd/turbo/generators/templates — turbo gen context (cwd = repo root)
|
||||
// 3. cwd/templates — vitest context (cwd = turbo/generators)
|
||||
let root: string;
|
||||
if (opts.templatesRoot) {
|
||||
root = opts.templatesRoot;
|
||||
} else {
|
||||
const fromRepoRoot = join(process.cwd(), "turbo", "generators", "templates");
|
||||
const fromGeneratorsDir = join(process.cwd(), "templates");
|
||||
root = existsSync(fromRepoRoot) ? fromRepoRoot : fromGeneratorsDir;
|
||||
}
|
||||
const srcRoot = join(root, srcPrefix);
|
||||
const out: PlopTypes.AddActionConfig[] = [];
|
||||
walkHbs(srcRoot, srcRoot, srcPrefix, destPrefix, out);
|
||||
|
||||
Reference in New Issue
Block a user