當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。