message: feat(plugin/model): support add extra models
diff: import * as t from '@umijs/bundler-utils/compiled/babel/types';
  +import assert from 'assert';
  import { readFileSync } from 'fs';
  import { join } from 'path';
  import { IApi } from 'umi';
  -import { winPath } from 'umi/plugin-utils';
  -import { ModelUtils } from './utils/modelUtils';
  +import { lodash, winPath } from 'umi/plugin-utils';
  +import { Model, ModelUtils } from './utils/modelUtils';
  import { withTmpPath } from './utils/withTmpPath';
  export default (api: IApi) => {
  @@ -24,15 +25,29 @@ export default (api: IApi) => {
  return memo;
  });
  - api.onGenerateFiles((args) => {
  + api.onGenerateFiles(async (args) => {
  const models = args.isFirstTime
  ? api.appData.pluginModel.models
  : getAllModels(api);
  + const extraModels = (
  + await api.applyPlugins({
  + key: 'addExtraModels',
  + type: api.ApplyPluginsType.add,
  + initialValue: [],
  + })
  + ).map((opts: any) => {
  + assert(
  + lodash.isPlainObject(opts) && opts.file && opts.id,
  + `extra model should be plain object with file and id property, but got ${opts}`,
  + );
  + return new Model(opts.file, opts.id);
  + });
  +
  // model.ts
  api.writeTmpFile({
  path: 'model.ts',
  - content: ModelUtils.getModelsContent(models),
  + content: ModelUtils.getModelsContent([...models, ...extraModels]),
  });
  // index.tsx
  