本文整理汇总了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)
});
}
示例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,
},
],
});
示例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);
};
},
},
],
});
示例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}`);
};
},
}
],
});
示例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);
};
},
}
],
});
示例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();
});
};
},
}
],
});
示例7: createApp
import { createApp } from 'frint';
import { providers } from './providers';
export const App = createApp({
name: 'FrintCLI',
providers,
});