Skip to content

runCreation

Applies a Creation to disk by writing files, sending network requests, and executing shell scripts.

runCreation takes in up to two arguments:

  1. creation (required): a Creation object
  2. settings (optional): any of:
    • offline: whether to run in “offline” mode
    • system: virtual APIs to apply via

For example, given this created README.md file, runTemplate would write that file to disk:

import { createTemplate, runTemplate } from "bingo";
await runCreation({
files: {
"README.md": `# Hello, World!`,
},
});

Settings

offline

Whether to skip network requests.

This is equivalent to the --offline CLI flag.

For example, this would only write files to disk, and not send any requests:

import { createTemplate, runTemplate } from "bingo";
import { z } from "zod";
await runCration(
{
files: {
"README.md": `# Hello, World!`,
},
requests: [
{
id: "default-branch",
async send({ octokit }) {
await octokit.rest.repos.update({
default_branch: "main",
owner: options.owner,
repo: options.repository,
});
},
},
],
},
{
offline: true,
},
);

system

File, network, and shell wrapper APIs.

system may contain the following properties, which have the following defaults:

They can be swapped out if you want to change or otherwise intercept system calls.

For example, this adds a log to every shell command:

import { runCreation } from "bingo";
import { createSystemRunner } from "bingo-systems";
const defaultRunner = createSystemRunner();
await runCreation(
{
scripts: ["npm format --write"],
},
{
system: {
runner: async (...args) => {
console.log("Running:", args);
return await defaultRunner(args);
},
},
},
);
Made with 💝 in Boston by Josh Goldberg.