function buildRoute()

in packages/build-tools/console-toolkit-plugin-xconsole-fs-route/src/index.ts [73:94]


function buildRoute(api: PluginAPI, options: PluginOptions) {
  const tmpPath = resolve(api.getCwd(), `src/${TMP_DIR}`);
  const directory = resolve(api.getCwd(), 'src/pages');
  const [routes, globalRoutes] = getRouteMeta(directory, tmpPath);

  const global = getGlobalMeta(api.getCwd(), {
    indexRoute: `${get(options, 'routes.index', null)}`,
    mode: `${get(options, 'routes.mode', '')}`,
    prefix: `${get(options, 'routes.prefix', '')}`,
    appId: options.appId,
  });

  const generator = new Generator(tmpPath);

  api.emit('onBuildRoutes');

  generator.generate({
    routes,
    globalRoutes,
    global
  });
}