How to use the jsii-reflect.TypeSystem function in jsii-reflect

To help you get started, we’ve selected a few jsii-reflect 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 / tools / awslint / bin / awslint.ts View on Github external
async function loadModule(dir: string) {
  const ts = new reflect.TypeSystem();
  await ts.load(dir, { validate: false }); // Don't validate to save 66% of execution time (20s vs 1min).
  // We run 'awslint' during build time, assemblies are guaranteed to be ok.

  if (ts.roots.length !== 1) {
    throw new Error(`Expecting only a single root assembly`);
  }

  return ts.roots[0];
}
github aws / jsii / packages / jsii-diff / bin / jsii-diff.ts View on Github external
async function loadFromFilesystem(name: string, options: LoadOptions) {
  const stat = await fs.stat(name);

  const ts = new reflect.TypeSystem();
  if (stat.isDirectory()) {
    return ts.loadModule(name, options);
  }
  return ts.loadFile(name, options);

}
github aws / jsii / packages / jsii-pacmak / lib / packaging.ts View on Github external
import { Scratch, shell } from './util';
import * as logging from '../lib/logging';
import * as reflect from 'jsii-reflect';
import * as os from 'os';
import * as path from 'path';

const SHARED_TS = new reflect.TypeSystem();

export interface JsiiModuleOptions {
  /**
   * Name of the module
   */
  name: string;

  /**
   * The module directory
   */
  moduleDirectory: string;

  /**
   * Identifier of the targets to build
   */
  availableTargets: string[];
github aws / aws-cdk / packages / decdk / lib / util.ts View on Github external
export async function loadTypeSystem(validate = true) {
  const typeSystem = new jsiiReflect.TypeSystem();
  const packageJson = require('../package.json');

  for (const depName of Object.keys(packageJson.dependencies || {})) {
    const jsiiModuleDir = path.dirname(require.resolve(`${depName}/package.json`));
    if (!fs.existsSync(path.resolve(jsiiModuleDir, '.jsii'))) {
      continue;
    }
    await typeSystem.load(jsiiModuleDir, { validate });
  }

  return typeSystem;
}