当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript frint.createApp函数代码示例

本文整理汇总了TypeScript中frint.createApp函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createApp函数的具体用法?TypeScript createApp怎么用?TypeScript createApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createApp函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createMockedRootApp

export default function createMockedRootApp(options?: any) {
  const overrideProviders = (options && options.providers) || [];

  return createApp({
    name: 'FrintCLI Mocked',

    providers: overrideProviders.reduce((acc, provider) => {
      const index = providers.findIndex(item => item.name === provider.name);

      if (index > -1) {
        acc[index] = provider;
      }

      return acc;
    }, providers)
  });
}
开发者ID:Travix-International,项目名称:frint,代码行数:17,代码来源:index.mock.ts

示例2: createApp

export default createApp({
  name: "CounterApp",
  providers: [
    {
      name: "component",
      useValue: RootComponent,
    },
    {
      deps: ["app"],
      name: "store",
      useFactory: ({ app }) => {
        const Store = createStore({
          initialState: {
            counter: {
              value: 5,
            },
          },
          reducer: rootReducer,
          deps: { app },
        });

        return new Store();
      },
    },
    {
      name: "region",
      useClass: RegionService,
    },
  ],
});
开发者ID:Travix-International,项目名称:frint,代码行数:30,代码来源:index.ts

示例3: createApp

export default createApp({
  name: 'help',

  providers: [
    {
      name: 'summary',
      useValue: 'Shows help text for commands',
    },
    {
      name: 'description',
      useValue: DESCRIPTION_TEXT,
    },
    {
      name: 'execute',
      deps: [
        'console',
        'params',
        'rootApp',
      ],
      useFactory: function useFactory(deps) {
        return function execute() {
          const commandName = deps.params._[0];

          if (typeof commandName === 'undefined') {
            return deps.console.error('Must provide a command name as argument.');
          }

          const commandApp = deps.rootApp.getAppInstance(commandName);

          if (!commandApp) {
            return deps.console.error(`No command found with name: ${commandName}`);
          }

          const output = [
            commandApp.get('summary'),
            commandApp.get('description'),
          ]
            .filter(text => text)
            .join('\n\n');

          return deps.console.log(output);
        };
      },
    },
  ],
});
开发者ID:Travix-International,项目名称:frint,代码行数:46,代码来源:help.ts

示例4: createApp

import * as path from 'path';

export default createApp({
  name: 'version',

  providers: [
    {
      name: 'summary',
      useValue: 'Shows current version number of frint-cli',
    },
    {
      name: 'execute',
      deps: [
        'console',
        'fs',
      ],
      useFactory: function useFactory(deps) {
        return function execute() {
          const pkg = JSON.parse(
            deps.fs.readFileSync(
              path.resolve(`${__dirname}/../../package.json`)
            )
          );

          deps.console.log(`v${pkg.version}`);
        };
      },
    }
  ],
});
开发者ID:Travix-International,项目名称:frint,代码行数:30,代码来源:version.ts

示例5: createApp

export default createApp({
  name: 'new',
  providers: [
    {
      name: 'summary',
      useValue: 'Scaffolds a new Frint app in specified directory',
    },
    {
      name: 'description',
      useValue: DESCRIPTION_TEXT,
    },
    {
      name: 'execute',
      deps: [
        'console',
        'params',
        'pwd',
      ],
      useFactory: function useFactory(deps) {
        return function execute() {
          deps.console.log('Initializing...');
          Promise.resolve(deps)
            .then(mapDepsToCtx)
            .then(createOutputDir)
            .then(streamExampleToOutputDir)
            .then(ctx => deps.console.log(getCompletionText(ctx)))
            .catch(deps.console.error);
        };
      },
    }
  ],
});
开发者ID:Travix-International,项目名称:frint,代码行数:32,代码来源:new.ts

示例6: createApp

export default createApp({
  name: 'init',
  providers: [
    {
      name: 'summary',
      useValue: 'Scaffolds a new Frint app in current working directory',
    },
    {
      name: 'description',
      useValue: DESCRIPTION_TEXT,
    },
    {
      name: 'execute',
      deps: [
        'console',
        'params',
        'pwd',
      ],
      useFactory: function useFactory(deps) {
        return function execute() {
          const example = deps.params.example || 'counter';
          const dir = deps.pwd;

          function streamFrintExampleToDir() {
            request('https://codeload.github.com/frintjs/frint/tar.gz/master')
              .on('error', deps.console.error)
              .pipe(tar.x({
                C: dir,
                filter: path => path.indexOf(`frint-master/examples/${example}/`) === 0,
                strip: 3,
              }))
              .on('error', deps.console.error)
              .on('finish', () => deps.console.log('Done!'));
          }

          deps.console.log('Initializing...');

          mkdirp(dir, function mkdirpCallback(error) {
            if (error) {
              deps.console.error(error);
              return;
            }
            streamFrintExampleToDir();
          });
        };
      },
    }
  ],
});
开发者ID:Travix-International,项目名称:frint,代码行数:49,代码来源:init.ts

示例7: createApp

import { createApp } from 'frint';
import { providers } from './providers';

export const App = createApp({
  name: 'FrintCLI',
  providers,
});
开发者ID:Travix-International,项目名称:frint,代码行数:7,代码来源:index.ts


注:本文中的frint.createApp函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。