转变demo.module.ts文件
439800
function fixDemoModuleTs(module, demoFolder) {
    // @NgModule()里必须包含一个exports，用于将组件暴露给上级组件
    var comp = findExportsComponent(module.code);
    if (!comp) {
        console.error('ERROR: need a "exports" property in the module code, ' +
                    'and the value of which should contains only one component!');
        console.error(`       module path=${demoFolder}`);
        process.exit(1);
    }

    // 删除 JigsawDemoDescriptionModule 相关的东西
    module.code = module.code.replace(/import\s*{\s*JigsawDemoDescriptionModule\s*}\s*from.*\r?\n/, '');
    module.code = module.code.replace(/\bJigsawDemoDescriptionModule\b\s*,?/g, '');
}
804258
function transpileAot() {
  // https://stackoverflow.com/questions/36897877/gulp-error-the-following-tasks-did-not-complete-did-you-forget-to-signal-async
  return new Promise(function(resolve, reject) {
    // Need to capture the exit code
    exec('node_modules/.bin/ngc -p tsconfig-aot.json', function (err, stdout, stderr) {
      console.log(stdout);
      console.log(stderr);
      if (err !== null) {
        process.exit(1);
      }
    });
    resolve();
  });
}
530901
function Module( type, name, dir){
  this.name = name;
  this.type = type;
  
  
  var _modulePath  = format('%s/%s', dir, type)
    , _view         = format('%s/%s.%s', _modulePath, 'html', 'hbs')
    , _model        = format('%s/%s.%s', _modulePath, type, 'peb')
    , _controller   = format('%s/%s.%s', _modulePath, type, 'js')
  ;
  
  
  /**
   * Load view 
   */
  this.loadView( _view);
  

  /**
   * Load model 
   */
  this.loadModel( _model);
  

  /**
   * Load controller 
   */
  if( !this.loadController( _controller) 
  &&  !this.view){
    console.error( 'unable to load module `%s` with name `%s` from `%s`', type, name, _modulePath);
  }
  
  
  /**
   *
   */
  if( this.controller){
    if( this.controller.helpers){
      
    }
  }
  
  return this;
}
1140833
function embed(sourcePath, relativePaths, name, done) {
  var items = '';
  each(relativePaths, function(relativePath, next) {
    var fullPath = path.join(sourcePath, relativePath);
    fs.readFile(fullPath, 'utf8', function(err, text) {
      if (err) return next(err);
      items += '  $templateCache.put(\'' +
        inline(relativePath) + '\', \'' +
        inline(text.trim()) + '\');\n';
      next();
    });
  }, function(err) {
    if (err) return done(err);
    console.log(
      'angular.module(\'' + inline(name) + '\', []).run([\'$templateCache\', function($templateCache) {\n' +
      items +
      '}]);');
    done();
  });
}
595438
function getTypingNamesFromNodeModuleFolder(nodeModulesPath) {
                // Todo: add support for ModuleResolutionHost too
                if (!host.directoryExists(nodeModulesPath)) {
                    return;
                }
                var typingNames = [];
                var fileNames = host.readDirectory(nodeModulesPath, [".json"], /*excludes*/ undefined, /*includes*/ undefined, /*depth*/ 2);
                for (var _i = 0, fileNames_2 = fileNames; _i < fileNames_2.length; _i++) {
                    var fileName = fileNames_2[_i];
                    var normalizedFileName = ts.normalizePath(fileName);
                    if (ts.getBaseFileName(normalizedFileName) !== "package.json") {
                        continue;
                    }
                    var result = ts.readConfigFile(normalizedFileName, function (path) { return host.readFile(path); });
                    if (!result.config) {
                        continue;
                    }
                    var packageJson = result.config;
                    // npm 3's package.json contains a "_requiredBy" field
                    // we should include all the top level module names for npm 2, and only module names whose
                    // "_requiredBy" field starts with "#" or equals "/" for npm 3.
                    if (packageJson._requiredBy &&
                        ts.filter(packageJson._requiredBy, function (r) { return r[0] === "#" || r === "/"; }).length === 0) {
                        continue;
                    }
                    // If the package has its own d.ts typings, those will take precedence. Otherwise the package name will be used
                    // to download d.ts files from DefinitelyTyped
                    if (!packageJson.name) {
                        continue;
                    }
                    if (packageJson.typings) {
                        var absolutePath = ts.getNormalizedAbsolutePath(packageJson.typings, ts.getDirectoryPath(normalizedFileName));
                        inferredTypings[packageJson.name] = absolutePath;
                    }
                    else {
                        typingNames.push(packageJson.name);
                    }
                }
                mergeTypings(typingNames);
            }
1309444
function createPackage(tutorialName) {

  const tutorialFilePath = `${CONTENTS_PATH}/getting-started/${tutorialName}.md`;
  const tutorialFile = readFileSync(tutorialFilePath, 'utf8');
  const examples = [];
  tutorialFile.replace(/<code-(?:pane|example) [^>]*path="([^"]+)"/g, (_, path) => examples.push('examples/' + path));

  if (examples.length) {
    console.log('The following example files are referenced in this getting-started:');
    console.log(examples.map(example => ' - ' + example).join('\n'));
  }

  return new Package('author-getting-started', [contentPackage])
    .config(function(readFilesProcessor) {
      readFilesProcessor.sourceFiles = [
        {
          basePath: CONTENTS_PATH,
          include: tutorialFilePath,
          fileReader: 'contentFileReader'
        },
        {
          basePath: CONTENTS_PATH,
          include: examples.map(example => resolve(CONTENTS_PATH, example)),
          fileReader: 'exampleFileReader'
        }
      ];
    });
}
1154913
def create_module_page(mod, dest_path, force=False):
    ""
    nb = get_empty_notebook()
    mod_name = mod.__name__
    strip_name = strip_fastai(mod_name)
    init_cell = [get_md_cell(f'## Title for {strip_name} (use plain english, not module name!)'), get_md_cell('Type an introduction of the package here.')]
    cells = [get_code_cell(f'from fastai.gen_doc.nbdoc import *\nfrom {mod_name} import * ', True)]

    gvar_map = get_global_vars(mod)
    if gvar_map: cells.append(get_md_cell('### Global Variable Definitions:'))
    for name in get_exports(mod):
        if name in gvar_map: cells.append(get_md_cell(gvar_map[name]))

    for ft_name in get_ft_names(mod, include_inner=True):
        if not hasattr(mod, ft_name):
            warnings.warn(f"Module {strip_name} doesn't have a function named {ft_name}.")
            continue
        cells += _symbol_skeleton(ft_name)
        elt = getattr(mod, ft_name)
    nb['cells'] = init_cell + cells + [get_md_cell(UNDOC_HEADER)]

    doc_path = get_doc_path(mod, dest_path)
    write_nb(nb, doc_path, 'w' if force else 'x')
    execute_nb(doc_path)
    return doc_path
1200620
function createConfig(pkg, moduleFormat, productive) {
  return {
    input: `src/modules/${pkg}/main/index.ts`, 

    output: {
      file: productive
        ? `dist/js-surface.${pkg}.${moduleFormat}.production.js`
        : `dist/js-surface.${pkg}.${moduleFormat}.development.js`,

      format: moduleFormat,
      
      name: {
        core: 'jsSurface',
        all: 'jsSurface',
        html: 'jsSurface.Html',
        svg: 'jsSurface.Svg'
      }[pkg] || `jsSurface.${pkg}`,
     
      sourcemap: productive ? false : 'inline',

      globals: {
        'js-surface': 'jsSurface',
        'react': 'React',
        'react-dom': 'ReactDOM',
        'dyo': 'Dyo',
        'js-spec': 'jsSpec'
      }
    },

    external: ['js-surface', 'react', 'react-dom', 'dyo'].concat(productive ? 'js-spec' : []), 

    plugins: [
      resolve({
        jsnext: true,
        main: true,
        browser: true,
      }),
      commonjs(),
      // TODO: Configure "tslint.json" properly and fix all errors
      //tslint({
      //  throwOnError: true
      //}),
      replace({
        exclude: 'node_modules/**',
        delimiters: ['', ''],

        values:
          pkg === 'all' ? {
            'process.env.NODE_ENV': productive ? "'production'" : "'development'",
          } : {
            'process.env.NODE_ENV': productive ? "'production'" : "'development'",
            "'../core/main/index'": "'js-surface'",
            "'../../core/main/index'": "'js-surface'",
            "'../../../core/main/index'": "'js-surface'",
            "'../../../../core/main/index'": "'js-surface'",
            "'../../../../../core/main/index'": "'js-surface'",
          }
      }),
      typescript({
        exclude: 'node_modules/**',
      }),
      productive && (moduleFormat === 'esm' ? terser() : uglify()),
      productive && gzip()
    ],
  }
}
221308
function _main() {
  const srcIndexPath = join(DIST_DIR, 'index.html');
  const src404BodyPath = join(SRC_DIR, '404-body.html');
  const dst404PagePath = join(DIST_DIR, '404.html');

  const srcIndexContent = readFileSync(srcIndexPath, 'utf8');
  const src404BodyContent = readFileSync(src404BodyPath, 'utf8');
  const dst404PageContent = srcIndexContent.replace(/<body>[\s\S]+<\/body>/, src404BodyContent);

  if (dst404PageContent === srcIndexContent) {
    throw new Error(
        'Failed to generate \'404.html\'. ' +
        'The content of \'index.html\' does not match the expected pattern.');
  }

  writeFileSync(dst404PagePath, dst404PageContent);
}
705160
function buildJs() {
  const jsFiles = config.jsCoreFiles;
  config.componentPaths.forEach(component => {
    jsFiles.push(path.join(component, '*.js'));
    jsFiles.push(path.join(component, '**/*.js'));
  });

  gutil.log("building js files...");

  const jsBuildStream = gulp.src(jsFiles)
  .pipe(filterNonCodeFiles())
  .pipe(utils.buildNgMaterialDefinition())
  .pipe(plumber())
  .pipe(ngAnnotate())
  .pipe(utils.addJsWrapper(true));

  const jsProcess = series(jsBuildStream, themeBuildStream())
  .pipe(concat('angular-material.js'))
  .pipe(BUILD_MODE.transform())
  .pipe(insert.prepend(config.banner))
  .pipe(insert.append(';window.ngMaterial={version:{full: "' + VERSION + '"}};'))
  .pipe(gulp.dest(config.outputDir))
  .pipe(gulpif(!IS_DEV, uglify({output: {comments: 'some'}})))
  .pipe(rename({extname: '.min.js'}))
  .pipe(gulp.dest(config.outputDir));

  return series(jsProcess, deployMaterialMocks());

  // Deploy the `angular-material-mocks.js` file to the `dist` directory
  function deployMaterialMocks() {
    return gulp.src(config.mockFiles)
    .pipe(gulp.dest(config.outputDir));
  }
}
1088700
function comboContent(options) {
    var contents = '',
        fileMap = options.fileMap,
        newModArr = [];
    options.modArr.forEach(function (item) {
        var base = options.base || path.resolve(item.path, '..');
        var origPath = getorigPath(item.path, base);
        if (!fileMap[origPath]) {
            fileMap[origPath] = true;
            newModArr.push(item);
        }
    });

    if (newModArr.length > 0) console.log(chalk.cyan(PLUGIN_NAME + ': '), 'Module ' + chalk.yellow(newModArr[0].origId + ' starting combo'));
    newModArr.forEach(function (item, index) {
        var newContents = transform(options, item, index);
        if (newContents) {
            var pathStr = path.extname(item.path) ? item.path : item.path + '.js';
            console.log(chalk.green('                     ✔ Module ' + pathStr));
            contents = newContents + '\n' + contents;
        }
    });

    return new Buffer(contents);
}
588197
function updateServicesJS(newFileName) {

  console.log(" 🔰  updating: ".cyan + "components.js".white);

  if (process.cwd().includes('client/app/services') === false) {
    process.chdir(`./client/app/services`);
  }

  if (process.cwd().includes(`client/app/services/${newFileName}`) === true) {
    process.chdir('..');
  }

  componentsArray = [];
  genArr = [];


  // sync with updates
  fs.readdir(process.cwd(), function (err, items) {
    genArr = items;
    generateDirectArray(genArr);
  });


  function generateDirectArray(items) {
    for (var i = 0; i < items.length; i++) {
      if (isDirectory(items[i])) {
      } else {
        componentsArray.push(items[i]);
      }
    }
    importStringGenerator();
  }

  function isDirectory(inputString) {
    var str = inputString;
    var patt = new RegExp("[.]");
    var res = patt.test(str);
    return res;
  }

  function importStringGenerator() {

    genString = "";
    for (var i = 0; i < componentsArray.length; i++) {
      genString = genString + `import ${componentsArray[i]}Service from './${componentsArray[i]}/${componentsArray[i]}';\r`
    }

    listString = "";
    for (var i = 0; i < componentsArray.length; i++) {

      // check if last in list in order to not include comma
      if (i === (componentsArray.length - 1)) {
        listString = listString + `  .service('${componentsArray[i]}Service', ${componentsArray[i]}Service);` + `\r`
      } else {
        listString = listString + `  .service('${componentsArray[i]}Service', ${componentsArray[i]}Service)` + `\r`
      }
    }


    fs.writeFile("services.js", `import angular from 'angular';
${genString}

const ServicesModule = angular.module('app.services', [])
${listString}

export default ServicesModule;`, function (err) {
      if (err) {
        return console.log(` ❌  failed to update due to error:  ${err}`);
      }
      console.log(" 🔰  updated: ".cyan + "services.js".white);
    });
  }
}
140762
function checkModule(pth, cb) {
  checkStrider(pth, function(err, config){
    if (err) return cb(err);
    if (config){
      config.dir = pth;
      return cb(null, config);
    }
    checkPackageJson(pth, function(err, config){
      if (err) return cb(err);
      if (config){
        config.dir = pth;
        return cb(null, config);
      }
      return cb(null, false);
    });
  });
}
1108666
function findConfigFile(filePath) {
		let prev = null
		do {
			const testPath = path.join(filePath, 'tsconfig.json')
			if (fs.existsSync(testPath)) {
				return testPath
			}
			prev = filePath
			filePath = path.dirname(filePath)
		} while (prev !== filePath)
		return undefined
	}
1098175
function demodule(t) {
    t.modules.forEach(function(name,ref) {
        var module = resolveToObject(ref)
        if (t.properties.has(name)) {
            var typ = t.properties.get(name).type
            if (isOnlyFunction(typ)) {
                typ.calls.forEach(function(call) {
                    module.calls.push(call)
                })
            } else {
               throw new TypeError(t.qname + "." + name + " of type " + t.properties.get(name).type + " clashes with name of ref"); 
            }
        }
        if (!module.origin)
            throw new Error("No origin on module: " + module.qname)
        t.properties.put(name, {
            optional: false, 
            type: ref,
            meta: {
                origin: module.origin
            }
        })
        demodule(module)
    })
}
1205924
function configGen() {
  return {
    input: 'src/index.ts',
    moduleContext: {
      [require.resolve('@tweenjs/tween.js')]: 'window'
    },
    output: {
      file: 'dist/web/buttplug.devtools.js',
      format: 'iife',
      name: "ButtplugDevTools",
      globals: { "buttplug": "Buttplug" }
    },
    plugins: [
      nodeResolve({
        jsnext: true,
        main: true,
        extensions: [ '.ts', '.js', '.json' ],
        browser: true
      }),
      postCss(),
      typescript({ tsconfigOverride: { compilerOptions: { module: "ES2015" } } }),
      json(),
      nodeBuiltins(),
      nodeGlobals(),
      commonjs({
        include: ['../../node_modules/**', './node_modules/**', "../buttplug/dist/main/src/**"],
        namedExports: {
          '../buttplug/dist/main/src/index.js': [ 'ButtplugLogger', 'ButtplugLogLevel', 'TestDeviceSubtypeManager' ],
          '../../node_modules/@tweenjs/tween.js/src/Tween.js': [ 'TWEEN', 'Tween' ]
        }
      }),
      autoExternal({
        dependencies: false,
        peerDependencies: true
      }),
      rollupHtml()
    ]
  };
}
1152395
function _main() {
  // Detect path to `tsconfig.app.json`.
  const ngConfig = parse(readFileSync(NG_JSON, 'utf8'));
  const tsConfigPath = join(ROOT_DIR, ngConfig.projects.site.architect.build.options.tsConfig);

  // Enable Ivy in TS config.
  console.log(`\nModifying \`${tsConfigPath}\`...`);
  const oldTsConfigStr = readFileSync(tsConfigPath, 'utf8');
  const oldTsConfigObj = parse(oldTsConfigStr);
  const newTsConfigObj = extend(true, oldTsConfigObj, NG_COMPILER_OPTS);
  const newTsConfigStr = `${JSON.stringify(newTsConfigObj, null, 2)}\n`;
  console.log(`\nNew config: ${newTsConfigStr}`);
  writeFileSync(tsConfigPath, newTsConfigStr);

  // Run ngcc.
  const ngccArgs = '--loglevel debug --properties es2015 module';
  console.log(`\nRunning ngcc (with args: ${ngccArgs})...`);
  exec(`yarn ivy-ngcc ${ngccArgs}`);

  // Done.
  console.log('\nReady to build with Ivy!');
  console.log('(To switch back to ViewEngine (with packages from npm), undo the changes in ' +
              `\`${tsConfigPath}\` and run \`yarn aio-use-npm && yarn example-use-npm\`.)`);
}