@notadd/cli
Version:
notadd core none dependence
38 lines (37 loc) • 1.42 kB
text/typescript
import { Command } from '@notadd/cli-core';
import { join, dirname } from 'path';
import { ensureDirSync, writeFileSync } from 'fs-extra';
import { Injector, MAIN_PATH, Controller, Param } from '@notadd/core';
import { toGraphql } from '@notadd/ast.ts-graphql'
()
export class GraphqlCommand {
constructor(public injector: Injector) { }
('grpc/?:main')
createGrpc('main') main: string) {
(try {
const root = process.cwd()
const output = join(root, main || 'notadd.graphql');
ensureDirSync(dirname(output))
const graphql =toGraphql(this.injector.get<string>(MAIN_PATH, 'main.ts') || 'main.ts');
if(graphql){
writeFileSync(output, graphql.graphql)
}
} catch (e) {
console.log(`${e.message}`, e)
}
}
('graphql/?:main')
createGraphql('main') main: string) {
(try {
const root = process.cwd()
const output = join(root, main || 'notadd.graphql');
ensureDirSync(dirname(output))
const graphql =toGraphql(this.injector.get<string>(MAIN_PATH, 'main.ts') || 'main.ts');
if(graphql){
writeFileSync(output, graphql.graphql)
}
} catch (e) {
console.log(`${e.message}`, e)
}
}
}