├── .gitignore ├── .npmignore ├── editorconfig ├── tsconfig.json ├── readme.md ├── src ├── initializer │ ├── init-config.ts │ ├── init-prompt.ts │ ├── model-builder.ts │ ├── npm-installer.ts │ └── initializer.ts ├── yellicode-constants.ts ├── path-utility.ts ├── json-file-reader.ts ├── config-store.ts ├── file-search.ts ├── app.d.ts ├── compiler.ts ├── input-watcher.ts ├── reference-path-resolver.ts ├── index.ts ├── model-store.ts ├── template-process.ts ├── template-runner.ts ├── config-reader.ts └── data-interfaces.ts ├── .vscode ├── tasks.json └── launch.json ├── package.json └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | #Npm modules 2 | node_modules/ 3 | npm-debug.log.* 4 | 5 | #Custom generated output 6 | dist/ 7 | *.tgz -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .vscode/* 2 | src 3 | !dist/*/src 4 | tsconfig.json 5 | *.npmignore 6 | *.ts 7 | !*.d.ts 8 | rollup.config.js -------------------------------------------------------------------------------- /editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | 3 | root = true 4 | 5 | [*] 6 | indent_style = tab 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [package.json] 13 | indent_style = space 14 | indent_size = 2 15 | 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "commonjs", 5 | "outDir": "dist/es5", 6 | "inlineSourceMap": true, 7 | "removeComments": true, 8 | "strict": true, 9 | "lib": [ 10 | "es2015", 11 | "dom" 12 | ] 13 | } 14 | } -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | ## Yellicode CLI 2 | 3 | ### CLI for Yellicode 4 | 5 | Yellicode lets you build your own code generation templates with TypeScript. It consists of a Node.js CLI and extensible APIs, making it easy for developers to create, share and re-use code generators for their favorite programming languages and frameworks. 6 | 7 | Check out [our website](https://www.yellicode.com) for more. 8 | 9 | License: MPL-2.0 -------------------------------------------------------------------------------- /src/initializer/init-config.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Yellicode 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | export interface InitConfig { 9 | modelName: string; 10 | templateFileName: string; 11 | outputFileName: string; 12 | } -------------------------------------------------------------------------------- /src/yellicode-constants.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Yellicode 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | export const YELLICODE_SECTION_NAME = 'com_yellicode'; 9 | export const YELLICODE_MODEL_NAME = 'model'; 10 | export const YELLICODE_DOCUMENT_EXTENSION = '.ymn'; 11 | export const YELLICODE_CONFIG_FILE = 'codegenconfig.json'; -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "identifier": "build", 8 | "type": "npm", 9 | "script": "build", 10 | "group": { 11 | "kind": "build", 12 | "isDefault": true 13 | }, 14 | "problemMatcher": [] 15 | }, 16 | { 17 | "identifier": "build-es5", 18 | "type": "npm", 19 | "script": "build:es5", 20 | "group": { 21 | "kind": "build", 22 | "isDefault": true 23 | }, 24 | "problemMatcher": [] 25 | } 26 | ] 27 | } -------------------------------------------------------------------------------- /src/path-utility.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Yellicode 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | export class PathUtility { 9 | public static ensureJsExtension(path: string): string { 10 | if (!path) 11 | return path; 12 | 13 | if (path.endsWith('.js')) { 14 | return path; 15 | } 16 | 17 | if (path.endsWith('.ts')) { 18 | // Remove the .ts extension 19 | path = path.substring(0, path.length - 3); 20 | } 21 | return path + '.js'; 22 | } 23 | 24 | public static removeTsExtension(path: string): string { 25 | if (!path || !path.endsWith('.ts')) 26 | return path; 27 | 28 | return path.substring(0, path.length - 3); 29 | } 30 | } -------------------------------------------------------------------------------- /src/json-file-reader.ts: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 Yellicode 3 | * 4 | * This Source Code Form is subject to the terms of the Mozilla Public 5 | * License, v. 2.0. If a copy of the MPL was not distributed with this 6 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | */ 8 | const fs = require('fs'); 9 | const jsonparser = require('json-parser'); 10 | 11 | export class JsonFileReader { 12 | 13 | public static readFile(fileName: string): Promise { 14 | if (!fs.existsSync(fileName)) { 15 | return Promise.reject(`File '${fileName}' not found.`); 16 | } 17 | 18 | return new Promise((resolve, reject) => { 19 | fs.readFile(fileName, 'utf8', (err: NodeJS.ErrnoException, text: Buffer) => { 20 | try { 21 | const model = jsonparser.parse(text, null, true); // parse... true to remove comments 22 | resolve(model); 23 | } catch (e) { 24 | reject(`Error parsing file '${fileName}': ${e}`); 25 | } 26 | }); 27 | }) 28 | } 29 | } -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "preLaunchTask": "build-es5", 11 | "name": "Build and Launch", 12 | "program": "${workspaceFolder}\\dist\\es5\\index", 13 | "cwd": "", //