mirror of https://github.com/abpframework/abp.git
29 changed files with 0 additions and 6763 deletions
@ -1 +0,0 @@ |
|||||
/dist |
|
||||
@ -1,5 +0,0 @@ |
|||||
{ |
|
||||
"trailingComma": "all", |
|
||||
"printWidth": 120, |
|
||||
"singleQuote": true |
|
||||
} |
|
||||
@ -1,2 +0,0 @@ |
|||||
import { APIDefination } from './types/api-defination'; |
|
||||
export declare function angular(data: APIDefination.Response, selectedModules: string[]): Promise<void>; |
|
||||
@ -1,57 +0,0 @@ |
|||||
"use strict"; |
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
||||
return new (P || (P = Promise))(function (resolve, reject) { |
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
||||
}); |
|
||||
}; |
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) { |
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
|
||||
function verb(n) { return function (v) { return step([n, v]); }; } |
|
||||
function step(op) { |
|
||||
if (f) throw new TypeError("Generator is already executing."); |
|
||||
while (_) try { |
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
|
||||
if (y = 0, t) op = [op[0] & 2, t.value]; |
|
||||
switch (op[0]) { |
|
||||
case 0: case 1: t = op; break; |
|
||||
case 4: _.label++; return { value: op[1], done: false }; |
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue; |
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
|
||||
default: |
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
|
||||
if (t[2]) _.ops.pop(); |
|
||||
_.trys.pop(); continue; |
|
||||
} |
|
||||
op = body.call(thisArg, _); |
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
|
||||
} |
|
||||
}; |
|
||||
Object.defineProperty(exports, "__esModule", { value: true }); |
|
||||
var service_templates_1 = require("./templates/angular/service-templates"); |
|
||||
function angular(data, selectedModules) { |
|
||||
return __awaiter(this, void 0, void 0, function () { |
|
||||
return __generator(this, function (_a) { |
|
||||
selectedModules.forEach(function (module) { |
|
||||
var element = data.modules[module]; |
|
||||
var contents = []; |
|
||||
(Object.keys(element.controllers) || []).forEach(function (key) { |
|
||||
console.warn(element.controllers[key].controllerName); |
|
||||
contents.push(''); |
|
||||
}); |
|
||||
var service = service_templates_1.ServiceTemplates.classTemplate(element.rootPath, contents); |
|
||||
console.log(service); |
|
||||
}); |
|
||||
return [2 /*return*/]; |
|
||||
}); |
|
||||
}); |
|
||||
} |
|
||||
exports.angular = angular; |
|
||||
@ -1 +0,0 @@ |
|||||
export declare function cli(program: any): Promise<void>; |
|
||||
@ -1,102 +0,0 @@ |
|||||
"use strict"; |
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
||||
return new (P || (P = Promise))(function (resolve, reject) { |
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
||||
}); |
|
||||
}; |
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) { |
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
|
||||
function verb(n) { return function (v) { return step([n, v]); }; } |
|
||||
function step(op) { |
|
||||
if (f) throw new TypeError("Generator is already executing."); |
|
||||
while (_) try { |
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
|
||||
if (y = 0, t) op = [op[0] & 2, t.value]; |
|
||||
switch (op[0]) { |
|
||||
case 0: case 1: t = op; break; |
|
||||
case 4: _.label++; return { value: op[1], done: false }; |
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue; |
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
|
||||
default: |
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
|
||||
if (t[2]) _.ops.pop(); |
|
||||
_.trys.pop(); continue; |
|
||||
} |
|
||||
op = body.call(thisArg, _); |
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
|
||||
} |
|
||||
}; |
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) { |
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod }; |
|
||||
}; |
|
||||
Object.defineProperty(exports, "__esModule", { value: true }); |
|
||||
var prompt_1 = require("./utils/prompt"); |
|
||||
var axios_1 = require("./utils/axios"); |
|
||||
var ora = require("ora"); |
|
||||
var angular_1 = require("./angular"); |
|
||||
var chalk_1 = __importDefault(require("chalk")); |
|
||||
function cli(program) { |
|
||||
return __awaiter(this, void 0, void 0, function () { |
|
||||
var _a, loading, data, selection, modules, _b; |
|
||||
var _this = this; |
|
||||
return __generator(this, function (_c) { |
|
||||
switch (_c.label) { |
|
||||
case 0: |
|
||||
if (!(program.ui !== 'angular')) return [3 /*break*/, 2]; |
|
||||
_a = program; |
|
||||
return [4 /*yield*/, prompt_1.uiSelection(['Angular'])]; |
|
||||
case 1: |
|
||||
_a.ui = (_c.sent()).toLowerCase(); |
|
||||
_c.label = 2; |
|
||||
case 2: |
|
||||
loading = ora('Waiting for the API response... \n'); |
|
||||
loading.start(); |
|
||||
return [4 /*yield*/, axios_1.axiosInstance.get('a')]; |
|
||||
case 3: |
|
||||
data = (_c.sent()); |
|
||||
loading.stop(); |
|
||||
selection = function (modules) { return __awaiter(_this, void 0, void 0, function () { |
|
||||
var selectedModules; |
|
||||
return __generator(this, function (_a) { |
|
||||
switch (_a.label) { |
|
||||
case 0: return [4 /*yield*/, prompt_1.moduleSelection(modules)]; |
|
||||
case 1: |
|
||||
selectedModules = (_a.sent()); |
|
||||
if (!!selectedModules.length) return [3 /*break*/, 3]; |
|
||||
console.log(chalk_1.default.red('Please select module(s)')); |
|
||||
return [4 /*yield*/, selection(modules)]; |
|
||||
case 2: return [2 /*return*/, _a.sent()]; |
|
||||
case 3: return [2 /*return*/, selectedModules]; |
|
||||
} |
|
||||
}); |
|
||||
}); }; |
|
||||
return [4 /*yield*/, selection(Object.keys(data.modules))]; |
|
||||
case 4: |
|
||||
modules = _c.sent(); |
|
||||
_b = program.ui; |
|
||||
switch (_b) { |
|
||||
case 'angular': return [3 /*break*/, 5]; |
|
||||
} |
|
||||
return [3 /*break*/, 7]; |
|
||||
case 5: return [4 /*yield*/, angular_1.angular(data, modules)]; |
|
||||
case 6: |
|
||||
_c.sent(); |
|
||||
return [3 /*break*/, 8]; |
|
||||
case 7: |
|
||||
process.exit(1); |
|
||||
_c.label = 8; |
|
||||
case 8: return [2 /*return*/]; |
|
||||
} |
|
||||
}); |
|
||||
}); |
|
||||
} |
|
||||
exports.cli = cli; |
|
||||
@ -1,2 +0,0 @@ |
|||||
#!/usr/bin/env node |
|
||||
export {}; |
|
||||
@ -1,24 +0,0 @@ |
|||||
#!/usr/bin/env node
|
|
||||
"use strict"; |
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) { |
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod }; |
|
||||
}; |
|
||||
Object.defineProperty(exports, "__esModule", { value: true }); |
|
||||
var chalk_1 = __importDefault(require("chalk")); |
|
||||
var commander_1 = __importDefault(require("commander")); |
|
||||
var cli_1 = require("./cli"); |
|
||||
var clear = require('clear'); |
|
||||
var figlet = require('figlet'); |
|
||||
clear(); |
|
||||
console.log(chalk_1.default.red(figlet.textSync('ABP', { horizontalLayout: 'full' }))); |
|
||||
commander_1.default |
|
||||
.version('0.0.1') |
|
||||
.description('ABP Client Generator') |
|
||||
.option('-u, --ui <type>', 'UI option (Angular)') |
|
||||
.parse(process.argv); |
|
||||
if (!process.argv.slice(2).length || !commander_1.default.ui || typeof commander_1.default.ui !== 'string') { |
|
||||
commander_1.default.outputHelp(); |
|
||||
process.exit(1); |
|
||||
} |
|
||||
commander_1.default.ui = commander_1.default.ui.toLowerCase(); |
|
||||
cli_1.cli(commander_1.default); |
|
||||
@ -1,3 +0,0 @@ |
|||||
export declare namespace ServiceTemplates { |
|
||||
function classTemplate(name: string, content: string[]): string; |
|
||||
} |
|
||||
@ -1,15 +0,0 @@ |
|||||
"use strict"; |
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) { |
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod }; |
|
||||
}; |
|
||||
Object.defineProperty(exports, "__esModule", { value: true }); |
|
||||
var change_case_1 = __importDefault(require("change-case")); |
|
||||
var ServiceTemplates; |
|
||||
(function (ServiceTemplates) { |
|
||||
function classTemplate(name, content) { |
|
||||
return "import { RestService } from '@abp/ng.core';\nimport { Injectable } from '@angular/core';\n\n@Injectable({\n providedIn: 'root',\n})\nexport class " + change_case_1.default.pascalCase(name) + "Service {\n\n constructor(private restService: RestService) { }\n\n " + content.forEach(function (element) { |
|
||||
element + '\n\n'; |
|
||||
}) + "\n}"; |
|
||||
} |
|
||||
ServiceTemplates.classTemplate = classTemplate; |
|
||||
})(ServiceTemplates = exports.ServiceTemplates || (exports.ServiceTemplates = {})); |
|
||||
@ -1,14 +0,0 @@ |
|||||
export declare namespace APIDefination { |
|
||||
interface Response { |
|
||||
modules: Modules; |
|
||||
} |
|
||||
interface Modules { |
|
||||
[key: string]: Module; |
|
||||
} |
|
||||
interface Module { |
|
||||
rootPath: string; |
|
||||
controllers: { |
|
||||
[key: string]: any; |
|
||||
}; |
|
||||
} |
|
||||
} |
|
||||
@ -1,2 +0,0 @@ |
|||||
"use strict"; |
|
||||
Object.defineProperty(exports, "__esModule", { value: true }); |
|
||||
@ -1 +0,0 @@ |
|||||
export declare const axiosInstance: import("axios").AxiosInstance; |
|
||||
File diff suppressed because it is too large
@ -1,2 +0,0 @@ |
|||||
export declare const uiSelection: (uiArray: string[]) => Promise<any>; |
|
||||
export declare const moduleSelection: (modules: string[]) => Promise<any>; |
|
||||
@ -1,56 +0,0 @@ |
|||||
"use strict"; |
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { |
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } |
|
||||
return new (P || (P = Promise))(function (resolve, reject) { |
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } |
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } |
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } |
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next()); |
|
||||
}); |
|
||||
}; |
|
||||
var __generator = (this && this.__generator) || function (thisArg, body) { |
|
||||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; |
|
||||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; |
|
||||
function verb(n) { return function (v) { return step([n, v]); }; } |
|
||||
function step(op) { |
|
||||
if (f) throw new TypeError("Generator is already executing."); |
|
||||
while (_) try { |
|
||||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; |
|
||||
if (y = 0, t) op = [op[0] & 2, t.value]; |
|
||||
switch (op[0]) { |
|
||||
case 0: case 1: t = op; break; |
|
||||
case 4: _.label++; return { value: op[1], done: false }; |
|
||||
case 5: _.label++; y = op[1]; op = [0]; continue; |
|
||||
case 7: op = _.ops.pop(); _.trys.pop(); continue; |
|
||||
default: |
|
||||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } |
|
||||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } |
|
||||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } |
|
||||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } |
|
||||
if (t[2]) _.ops.pop(); |
|
||||
_.trys.pop(); continue; |
|
||||
} |
|
||||
op = body.call(thisArg, _); |
|
||||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } |
|
||||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; |
|
||||
} |
|
||||
}; |
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) { |
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod }; |
|
||||
}; |
|
||||
Object.defineProperty(exports, "__esModule", { value: true }); |
|
||||
var inquirer_1 = __importDefault(require("inquirer")); |
|
||||
exports.uiSelection = function (uiArray) { return __awaiter(void 0, void 0, void 0, function () { |
|
||||
return __generator(this, function (_a) { |
|
||||
return [2 /*return*/, inquirer_1.default |
|
||||
.prompt({ type: 'list', name: 'Please select an UI', choices: uiArray }) |
|
||||
.then(function (res) { return res['Please select an UI']; })]; |
|
||||
}); |
|
||||
}); }; |
|
||||
exports.moduleSelection = function (modules) { return __awaiter(void 0, void 0, void 0, function () { |
|
||||
return __generator(this, function (_a) { |
|
||||
return [2 /*return*/, inquirer_1.default |
|
||||
.prompt({ type: 'checkbox', name: 'Please select module(s)', choices: modules }) |
|
||||
.then(function (res) { return res['Please select module(s)']; })]; |
|
||||
}); |
|
||||
}); }; |
|
||||
@ -1,6 +0,0 @@ |
|||||
{ |
|
||||
"watch": ["src"], |
|
||||
"ext": "ts", |
|
||||
"ignore": ["src/**/*.spec.ts"], |
|
||||
"exec": "ts-node ./src/index.ts" |
|
||||
} |
|
||||
@ -1,39 +0,0 @@ |
|||||
{ |
|
||||
"name": "@abp/client-generator", |
|
||||
"version": "0.0.1", |
|
||||
"description": "", |
|
||||
"main": "./lib/index.js", |
|
||||
"bin": { |
|
||||
"abp-type": "./lib/index.js" |
|
||||
}, |
|
||||
"scripts": { |
|
||||
"start": "ts-node src/index.ts", |
|
||||
"start:watch": "nodemon", |
|
||||
"create": "npm run build && npm run test", |
|
||||
"build": "tsc -p .", |
|
||||
"test": "jest", |
|
||||
"prepublish": "yarn build" |
|
||||
}, |
|
||||
"author": "", |
|
||||
"license": "ISC", |
|
||||
"dependencies": { |
|
||||
"axios": "^0.19.0", |
|
||||
"chalk": "^3.0.0", |
|
||||
"change-case": "^3.1.0", |
|
||||
"clear": "^0.1.0", |
|
||||
"commander": "^4.0.1", |
|
||||
"figlet": "^1.2.4", |
|
||||
"fs-extra": "^8.1.0", |
|
||||
"inquirer": "^7.0.0", |
|
||||
"ora": "^4.0.3", |
|
||||
"path": "^0.12.7" |
|
||||
}, |
|
||||
"devDependencies": { |
|
||||
"@types/fs-extra": "^8.0.1", |
|
||||
"@types/inquirer": "^6.5.0", |
|
||||
"@types/node": "^12.12.8", |
|
||||
"nodemon": "^1.19.4", |
|
||||
"ts-node": "^8.5.2", |
|
||||
"typescript": "^3.7.2" |
|
||||
} |
|
||||
} |
|
||||
@ -1,34 +0,0 @@ |
|||||
import { APIDefination } from './types/api-defination'; |
|
||||
import { ServiceTemplates } from './templates/angular/service-templates'; |
|
||||
import changeCase from 'change-case'; |
|
||||
import fse from 'fs-extra'; |
|
||||
|
|
||||
export async function angular(data: APIDefination.Response, selectedModules: string[]) { |
|
||||
selectedModules.forEach(async module => { |
|
||||
const element = data.modules[module]; |
|
||||
|
|
||||
(Object.keys(element.controllers) || []).forEach(key => { |
|
||||
const controller = element.controllers[key]; |
|
||||
|
|
||||
const actions = element.controllers[key].actions; |
|
||||
|
|
||||
const actionKeys = Object.keys(actions); |
|
||||
let contents = [] as string[]; |
|
||||
actionKeys.forEach(key => { |
|
||||
const element = actions[key]; |
|
||||
console.log(element); |
|
||||
|
|
||||
switch (element.httpMethod) { |
|
||||
case 'GET': |
|
||||
contents.push(ServiceTemplates.getMethodTemplate(element.name, element.url)); |
|
||||
break; |
|
||||
|
|
||||
default: |
|
||||
break; |
|
||||
} |
|
||||
}); |
|
||||
const service = ServiceTemplates.classTemplate(controller.controllerName, contents.join('\n')); |
|
||||
fse.writeFileSync(`dist/${changeCase.kebabCase(controller.controllerName)}.service.ts`, service); |
|
||||
}); |
|
||||
}); |
|
||||
} |
|
||||
@ -1,46 +0,0 @@ |
|||||
import { uiSelection, moduleSelection } from './utils/prompt'; |
|
||||
import { axiosInstance } from './utils/axios'; |
|
||||
import ora = require('ora'); |
|
||||
import { angular } from './angular'; |
|
||||
import chalk from 'chalk'; |
|
||||
import { APIDefination } from './types/api-defination'; |
|
||||
|
|
||||
export async function cli(program: any) { |
|
||||
if (program.ui !== 'angular') { |
|
||||
program.ui = ((await uiSelection(['Angular'])) as string).toLowerCase(); |
|
||||
} |
|
||||
const loading = ora('Waiting for the API response... \n'); |
|
||||
loading.start(); |
|
||||
let data = {} as APIDefination.Response; |
|
||||
try { |
|
||||
data = (await axiosInstance.get('https://localhost:44305/api/abp/api-definition')).data; |
|
||||
} catch (error) { |
|
||||
console.error(error); |
|
||||
process.exit(1); |
|
||||
} |
|
||||
console.log(data); |
|
||||
loading.stop(); |
|
||||
|
|
||||
const selection = async (modules: string[]): Promise<string[]> => { |
|
||||
const selectedModules = (await moduleSelection(modules)) as string[]; |
|
||||
|
|
||||
if (!selectedModules.length) { |
|
||||
console.log(chalk.red('Please select module(s)')); |
|
||||
return await selection(modules); |
|
||||
} |
|
||||
|
|
||||
return selectedModules; |
|
||||
}; |
|
||||
|
|
||||
// const modules = await selection(Object.keys(data.modules));
|
|
||||
const modules = ['saas']; |
|
||||
|
|
||||
switch (program.ui) { |
|
||||
case 'angular': |
|
||||
await angular(data, modules); |
|
||||
break; |
|
||||
|
|
||||
default: |
|
||||
process.exit(1); |
|
||||
} |
|
||||
} |
|
||||
@ -1,25 +0,0 @@ |
|||||
#!/usr/bin/env node |
|
||||
import chalk from 'chalk'; |
|
||||
import program from 'commander'; |
|
||||
import { cli } from './cli'; |
|
||||
const clear = require('clear'); |
|
||||
const figlet = require('figlet'); |
|
||||
|
|
||||
clear(); |
|
||||
|
|
||||
console.log(chalk.red(figlet.textSync('ABP', { horizontalLayout: 'full' }))); |
|
||||
|
|
||||
program |
|
||||
.version('0.0.1') |
|
||||
.description('ABP Client Generator') |
|
||||
.option('-u, --ui <type>', 'UI option (Angular)') |
|
||||
.parse(process.argv); |
|
||||
|
|
||||
if (!process.argv.slice(2).length || !program.ui || typeof program.ui !== 'string') { |
|
||||
program.outputHelp(); |
|
||||
process.exit(1); |
|
||||
} |
|
||||
|
|
||||
program.ui = program.ui.toLowerCase(); |
|
||||
|
|
||||
cli(program); |
|
||||
@ -1,34 +0,0 @@ |
|||||
import changeCase from 'change-case'; |
|
||||
import { replacer } from '../../utils/replacer'; |
|
||||
|
|
||||
export namespace ServiceTemplates { |
|
||||
export function classTemplate(name: string, content: string) { |
|
||||
return `import { RestService } from '@abp/ng.core';
|
|
||||
import { Injectable } from '@angular/core'; |
|
||||
import { Observable } from 'rxjs' |
|
||||
|
|
||||
@Injectable({ |
|
||||
providedIn: 'root', |
|
||||
}) |
|
||||
export class ${changeCase.pascalCase(name)}Service { |
|
||||
constructor(private restService: RestService) {} |
|
||||
${content} |
|
||||
}`;
|
|
||||
} |
|
||||
|
|
||||
export function getMethodTemplate( |
|
||||
name: string, |
|
||||
url: string, |
|
||||
args: string = '', |
|
||||
params: string[] = [], |
|
||||
queryParams?: object, |
|
||||
) { |
|
||||
return ` |
|
||||
${changeCase.camelCase(replacer(name))}(${args}): Observable<any> { |
|
||||
return this.restService.request<void, any>({ |
|
||||
method: 'GET', |
|
||||
url: '/${url}${params.length ? '/' + params.join('/') : ''}', |
|
||||
}); |
|
||||
}`;
|
|
||||
} |
|
||||
} |
|
||||
@ -1,53 +0,0 @@ |
|||||
export namespace APIDefination { |
|
||||
export interface Response { |
|
||||
modules: Modules; |
|
||||
} |
|
||||
|
|
||||
export interface Modules { |
|
||||
[key: string]: Module; |
|
||||
} |
|
||||
|
|
||||
export interface Module { |
|
||||
rootPath: string; |
|
||||
controllers: { [key: string]: Controller }; |
|
||||
} |
|
||||
|
|
||||
export interface Controller { |
|
||||
controllerName: string; |
|
||||
interfaces: { typeAsString: string }[]; |
|
||||
typeAsString: string; |
|
||||
actions: { [key: string]: Action }; |
|
||||
} |
|
||||
|
|
||||
export interface Action { |
|
||||
uniqueName: string; |
|
||||
name: string; |
|
||||
httpMethod: string; |
|
||||
url: string; |
|
||||
supportedVersions: any[]; |
|
||||
parametersOnMethod: ParametersOnMethod[]; |
|
||||
parameters: Parameter[]; |
|
||||
returnValue: ReturnValue; |
|
||||
} |
|
||||
|
|
||||
export interface Parameter { |
|
||||
nameOnMethod: string; |
|
||||
name: string; |
|
||||
typeAsString: string; |
|
||||
isOptional: boolean; |
|
||||
defaultValue: null; |
|
||||
constraintTypes: null; |
|
||||
bindingSourceId: string; |
|
||||
} |
|
||||
|
|
||||
export interface ParametersOnMethod { |
|
||||
name: string; |
|
||||
typeAsString: string; |
|
||||
isOptional: boolean; |
|
||||
defaultValue: null; |
|
||||
} |
|
||||
|
|
||||
export interface ReturnValue { |
|
||||
typeAsString: string; |
|
||||
} |
|
||||
} |
|
||||
File diff suppressed because it is too large
@ -1,13 +0,0 @@ |
|||||
export interface GenerateArgsParam { |
|
||||
key: string; |
|
||||
type: string; |
|
||||
isOptional?: boolean; |
|
||||
} |
|
||||
|
|
||||
export function generateArgs(args: GenerateArgsParam[]): string { |
|
||||
return args.reduce((acc, val) => { |
|
||||
const arg = `${val.key}${val.isOptional ? '?' : ''}: ${val.type}`; |
|
||||
if (acc) return `${acc}, ${arg}`; |
|
||||
else return arg; |
|
||||
}, ''); |
|
||||
} |
|
||||
@ -1,13 +0,0 @@ |
|||||
import inquirer from 'inquirer'; |
|
||||
|
|
||||
export const uiSelection = async (uiArray: string[]) => { |
|
||||
return inquirer |
|
||||
.prompt({ type: 'list', name: 'Please select an UI', choices: uiArray }) |
|
||||
.then(res => res['Please select an UI']); |
|
||||
}; |
|
||||
|
|
||||
export const moduleSelection = async (modules: string[]) => { |
|
||||
return inquirer |
|
||||
.prompt({ type: 'checkbox', name: 'Please select module(s)', choices: modules }) |
|
||||
.then(res => res['Please select module(s)']); |
|
||||
}; |
|
||||
@ -1,3 +0,0 @@ |
|||||
export function replacer(text: string) { |
|
||||
return text.replace(/Async/, ''); |
|
||||
} |
|
||||
@ -1,14 +0,0 @@ |
|||||
{ |
|
||||
"compilerOptions": { |
|
||||
"target": "es5", |
|
||||
"module": "commonjs", |
|
||||
"lib": ["es6", "es2015", "dom"], |
|
||||
"declaration": true, |
|
||||
"outDir": "lib", |
|
||||
"rootDir": "src", |
|
||||
"strict": true, |
|
||||
"types": ["node"], |
|
||||
"esModuleInterop": true, |
|
||||
"resolveJsonModule": true, |
|
||||
}, |
|
||||
} |
|
||||
File diff suppressed because it is too large
Loading…
Reference in new issue