message: feat(preset-umi): api.appData.appJSPath
diff: import { getNpmClient } from '@umijs/utils';
  +import { existsSync } from 'fs';
  import { join } from 'path';
  +import { expandJSPaths } from '../../commands/dev/watch';
  import { IApi } from '../../types';
  import { getRoutes } from '../tmpFiles/routes';
  @@ -16,7 +18,27 @@ export default (api: IApi) => {
  memo.react = {
  version: require(join(api.config.alias.react, 'package.json')).version,
  };
  -
  + memo.appJSPath = getAppJsPath();
  return memo;
  });
  +
  + // Execute earliest, so that other onGenerateFiles can get it
  + api.register({
  + key: 'onGenerateFiles',
  + fn(args: any) {
  + if (!args.isFirstTime) {
  + api.appData.appJSPath = getAppJsPath();
  + }
  + },
  + stage: Number.NEGATIVE_INFINITY,
  + });
  +
  + function getAppJsPath() {
  + for (const file of expandJSPaths(join(api.paths.absSrcPath, 'app'))) {
  + if (existsSync(file)) {
  + return file;
  + }
  + }
  + return null;
  + }
  };
  