How to use the codemaker.CodeMaker function in codemaker

To help you get started, we’ve selected a few codemaker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aws / aws-cdk / packages / cdk-dasm / lib / dasm.ts View on Github external
export async function dasmTypeScript(template: Template, options: DisassemblerOptions = {}) {
  const definitions = new Array();

  for (const [ id, resource ] of Object.entries(template.Resources || {})) {
    const type = resource.Type;
    const props = resource.Properties || {};

    definitions.push({
      id,
      ...toCfnClassName(type),
      props: capitalizeKeys(props)
    });
  }

  const code = new CodeMaker();

  const outFile = 'out.ts';

  code.openFile(outFile);

  const timestamp = options.timestamp !== undefined ? options.timestamp : true;
  const suffix = timestamp ?  `at ${new Date().toISOString()}` : '';

  code.line(`// generated by cdk-dasm ${suffix}`);
  code.line();

  //
  // imports
  //

  code.line(`import { Stack, StackProps, Construct, Fn } from '@aws-cdk/core';`);

codemaker

A tiny utility for generating source code

Apache-2.0
Latest version published 1 month ago

Package Health Score

94 / 100
Full package analysis

Popular codemaker functions

Similar packages