d4ccdf7105
* Boilerplate server-only use case * wip: integration suite instrumentation setup * Working poc testing compileProject * Add pnpm script to run e2e tests only * Use vitest globals * Remove commented line * Remove useless export * Add modifier to test only one fixture project * Handle package manager and log level choice * Update server-only example * Setup / teardown + split compile for package manager capabilities * Ignore yarn files * Fix issue with corepack, store version in engines field * Rename test file * Fix npm updates yarn.lock * Move typecheking in a dedicated test * Stop bundling the compile command to allow for more granular testing * Put config resolving in separate test * Add no-config test case and add test case expected errors configuration * Add wantCompilationError option * Add dependencies handling * Use packageManager passed as option to resolve required deps * Remove unused guard clauses * Add postinstall & hash handling step * Add worker start test * Handle yarn.lock copy renaming on sigterm and sigkill * Update vitest and use concurrent option * Add a readme file * Add CI workflow * Fix handle cli deps * Run cli v3 e2e tests on publish action * Increase timeout on deps resolving step * Add changeset * Remove .pnp.cjs as we use yarn with nodeLinker node-modules * Add missing .yarnrc.yml file * No need to build CLI to run E2E tests * Remove bun.lockb files * Update beige-pears-explode.md --------- Co-authored-by: Eric Allam <eallam@icloud.com>
39 lines
1.2 KiB
TypeScript
39 lines
1.2 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { writeFile } from "node:fs/promises";
|
|
import { join, resolve } from "node:path";
|
|
import { cliRootPath } from "../src/utilities/resolveInternalFilePath";
|
|
import { ReadConfigResult } from "../src/utilities/configFiles";
|
|
|
|
type CreateContainerFileOptions = {
|
|
resolvedConfig: ReadConfigResult;
|
|
tempDir: string;
|
|
};
|
|
|
|
export async function createContainerFile(options: CreateContainerFileOptions) {
|
|
if (options.resolvedConfig.status === "error") {
|
|
throw new Error("cannot resolve config");
|
|
}
|
|
const {
|
|
resolvedConfig: { config },
|
|
tempDir,
|
|
} = options;
|
|
|
|
// COPIED FROM compileProject()
|
|
// Write the Containerfile to /mpt / dir / Containerfile;
|
|
// const containerFilePath = join(cliRootPath(), "Containerfile.prod");
|
|
const containerFilePath = resolve("./src/Containerfile.prod");
|
|
|
|
let containerFileContents = readFileSync(containerFilePath, "utf-8");
|
|
|
|
if (config.postInstall) {
|
|
containerFileContents = containerFileContents.replace(
|
|
"__POST_INSTALL__",
|
|
`RUN ${config.postInstall}`
|
|
);
|
|
} else {
|
|
containerFileContents = containerFileContents.replace("__POST_INSTALL__", "");
|
|
}
|
|
|
|
await writeFile(join(tempDir, "Containerfile"), containerFileContents);
|
|
}
|