本文整理匯總了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,
});