typebox-genx - v0.1.0
    Preparing search index...

    typebox-genx - v0.1.0

    typebox-genx

    GitHub Actions npm en ru

    typebox-genx (TypeBox Generator eXtended) is a code generation tool that extends @sinclair/typebox-codegen package with import functionality

    Install via Bun:

    bun install @toil/typebox-genx
    

    Install via Node:

    npm install @toil/typebox-genx
    

    This lib is very very very very unstable and some parts of planned functionality aren't available.

    Lib work bad with scopes and i mean you have separate files for types

    Supports only 1 type of import by line. Any of these code variants are valid:

    Warning

    Now you can only import with import {...} from "...". Also you can use "type".

    import type { ClientOpts } from "@vot.js/node";
    // or
    // import { ClientOpts as RenamedOpts } from "@vot.js/node";
    // or
    import { Client, type ClientOpts } from "@vot.js/node";
    // or
    // import * as Client from "@vot.js/node";
    // and many more

    These code variants unsupported:

    import Client, { ClientOpts } from "@vot.js/node";
    // or
    import "@vot.js/node";

    Now typeof variable unsupported too

    The library class provides several methods:

    const genx = new GenX({
    root: path.join(__dirname),
    includeNearbyFiles: true,
    });

    // read from input dir and write to output
    await genx.generateByDir(
    path.join(__dirname, "src/types"),
    path.join(__dirname, "dist"),
    );

    // read file and return result to variable
    const codeByFile = await genx.generateByFile(
    path.join(__dirname, "src/types/with.ts"),
    );

    // read string and return result to variable
    const raw = `import type { RequestMethod } from "@toil/translate/types/providers/base";

    export type Test = {
    method: RequestMethod;
    };`;

    const codeByStr = await genx.generateByCode(raw);

    // clear saved imports and depends list if needed
    genx.clearData();

    // create client for enabled workspaces
    const genxw = new GenX({
    root: path.join(__dirname, "packages", "packageA"),
    workspaceRoot: path.join(__dirname),
    });

    await genx.generateByDir(
    path.join(__dirname, "packages", "packageA"),
    path.join(__dirname, "dist"),
    );

    To build, you must have:

    Don't forget to install the dependencies:

    bun install
    

    Start building:

    bun build:all
    

    The library has minimal test coverage to check its performance.

    Run the tests:

    bun test