├── .babelrc ├── .eslintrc.mjs ├── .gitignore ├── .npmignore ├── .prettierrc ├── CHANGELOG.md ├── LICENSE ├── README.md ├── assets └── vgent-github-cover.png ├── dist ├── index.js ├── index.js.map └── src │ ├── context │ ├── index.js │ └── index.js.map │ ├── modules │ ├── components │ │ ├── index.js │ │ ├── index.js.map │ │ ├── template.js │ │ └── template.js.map │ ├── config │ │ ├── index.js │ │ └── index.js.map │ ├── core │ │ ├── index.js │ │ └── index.js.map │ ├── nuxt │ │ ├── index.js │ │ └── index.js.map │ ├── pages │ │ ├── index.js │ │ └── index.js.map │ ├── settings │ │ ├── index.js │ │ └── index.js.map │ ├── status.js │ ├── status.js.map │ ├── status │ │ ├── index.js │ │ └── index.js.map │ └── templates │ │ ├── component.js │ │ ├── component.js.map │ │ ├── index.js │ │ └── index.js.map │ ├── services │ ├── commands.js │ ├── commands.js.map │ ├── options.js │ ├── options.js.map │ ├── shell.js │ └── shell.js.map │ ├── types │ ├── alerts.js │ ├── alerts.js.map │ ├── commands.js │ ├── commands.js.map │ ├── config.js │ ├── config.js.map │ ├── generator.js │ ├── generator.js.map │ ├── nuxt.js │ ├── nuxt.js.map │ ├── options.js │ ├── options.js.map │ ├── settings.js │ ├── settings.js.map │ ├── shell.js │ ├── shell.js.map │ ├── status.js │ └── status.js.map │ └── utils │ ├── alerts.js │ ├── alerts.js.map │ ├── logs.js │ └── logs.js.map ├── index.ts ├── package.json ├── src ├── context │ └── index.ts ├── modules │ ├── components │ │ └── index.ts │ ├── config │ │ └── index.ts │ ├── core │ │ └── index.ts │ ├── pages │ │ └── index.ts │ ├── settings │ │ └── index.ts │ ├── status │ │ └── index.ts │ └── templates │ │ └── component.ts ├── services │ ├── commands.ts │ ├── options.ts │ └── shell.ts ├── types │ ├── alerts.ts │ ├── commands.ts │ ├── config.ts │ ├── generator.ts │ ├── options.ts │ ├── settings.ts │ ├── shell.ts │ └── status.ts └── utils │ └── alerts.ts ├── tsconfig.json └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "compact": false, 3 | "retainLines": true, 4 | "minified": false, 5 | "inputSourceMap": false, 6 | "sourceMaps": false, 7 | "presets": [ 8 | [ 9 | "@babel/preset-env", { 10 | "targets": { 11 | "node": "14" 12 | }, 13 | "modules": false 14 | } 15 | ] 16 | ], 17 | "plugins": [ 18 | [ 19 | "module-resolver", 20 | { 21 | "root": ["./dist"], 22 | "alias": { 23 | "@": "./dist", 24 | "types": "./dist/src/types", 25 | "context": "./dist/src/context", 26 | "modules": "./dist/src/modules", 27 | "services": "./dist/src/services", 28 | "utils": "./dist/src/utils" 29 | } 30 | } 31 | ] 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /.eslintrc.mjs: -------------------------------------------------------------------------------- 1 | export default { 2 | root: true, 3 | parserOptions: { 4 | sourceType: "module", 5 | ecmaVersion: 2015, 6 | requireConfigFile: false 7 | }, 8 | env: { 9 | node: true 10 | }, 11 | extends: ['prettier'], 12 | plugins: ['prettier'], 13 | exclude: ['./dist/**/*'], 14 | rules: { 15 | "prettier/prettier": "error", 16 | "no-console": 0, 17 | "no-useless-constructor": 0, 18 | "camelcase": "off" 19 | } 20 | } 21 | 22 | // { 23 | // "root": true, 24 | // 25 | // "parserOptions": { 26 | // "sourceType": "module", 27 | // "ecmaVersion": 2015 28 | // }, 29 | // 30 | // "env": { 31 | // "node": true, 32 | // }, 33 | // 34 | // "extends": ["prettier"], 35 | // "plugins": ["prettier"], 36 | // 37 | // "rules": { 38 | // "prettier/prettier": "error", 39 | // "no-console": 0, 40 | // "no-useless-constructor": 0, 41 | // "camelcase": "off" 42 | // } 43 | // } 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### Node template 2 | # Logs 3 | logs 4 | *.log 5 | npm-debug.log* 6 | yarn-debug.log* 7 | yarn-error.log* 8 | lerna-debug.log* 9 | 10 | # Diagnostic reports (https://nodejs.org/api/report.html) 11 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 12 | 13 | # Runtime data 14 | pids 15 | *.pid 16 | *.seed 17 | *.pid.lock 18 | 19 | # Directory for instrumented libs generated by jscoverage/JSCover 20 | lib-cov 21 | 22 | # Coverage directory used by tools like istanbul 23 | coverage 24 | *.lcov 25 | 26 | # nyc test coverage 27 | .nyc_output 28 | 29 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 30 | .grunt 31 | 32 | # Bower dependency directory (https://bower.io/) 33 | bower_components 34 | 35 | # node-waf configuration 36 | .lock-wscript 37 | 38 | # Compiled binary addons (https://nodejs.org/api/addons.html) 39 | build/Release 40 | 41 | # Dependency directories 42 | node_modules/ 43 | jspm_packages/ 44 | 45 | # Snowpack dependency directory (https://snowpack.dev/) 46 | web_modules/ 47 | 48 | # TypeScript cache 49 | *.tsbuildinfo 50 | 51 | # Optional npm cache directory 52 | .npm 53 | 54 | # Optional eslint cache 55 | .eslintcache 56 | 57 | # Microbundle cache 58 | .rpt2_cache/ 59 | .rts2_cache_cjs/ 60 | .rts2_cache_es/ 61 | .rts2_cache_umd/ 62 | 63 | # Optional REPL history 64 | .node_repl_history 65 | 66 | # Output of 'npm pack' 67 | *.tgz 68 | 69 | # Yarn Integrity file 70 | .yarn-integrity 71 | 72 | # dotenv environment variables file 73 | .env 74 | .env.test 75 | 76 | # parcel-bundler cache (https://parceljs.org/) 77 | .cache 78 | .parcel-cache 79 | 80 | # Next.js build output 81 | .next 82 | out 83 | 84 | # Gatsby files 85 | .cache/ 86 | # Comment in the public line in if your project uses Gatsby and not Next.js 87 | # https://nextjs.org/blog/next-9-1#public-directory-support 88 | # public 89 | 90 | # vuepress build output 91 | .vuepress/dist 92 | 93 | # Serverless directories 94 | .serverless/ 95 | 96 | # FuseBox cache 97 | .fusebox/ 98 | 99 | # DynamoDB Local files 100 | .dynamodb/ 101 | 102 | # TernJS port file 103 | .tern-port 104 | 105 | # Stores VSCode versions used for testing VSCode extensions 106 | .vscode-test 107 | 108 | # yarn v2 109 | .yarn/cache 110 | .yarn/unplugged 111 | .yarn/build-state.yml 112 | .yarn/install-state.gz 113 | .pnp.* 114 | 115 | .idea 116 | .DS_Store 117 | 118 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | assets 2 | src 3 | .babelrc 4 | .eslintrc.mjs 5 | .prettierrc 6 | tsconfig.json 7 | yarn.lock -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "tabWidth": 2, 3 | "useTabs": false, 4 | "semi": false, 5 | "singleQuote": true 6 | } 7 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.0.2] 2022-02-20 4 | 5 | ### Fixed 6 | 7 | - Generation Options API components with TypeScript language 8 | 9 | ### Changed 10 | 11 | - Added component type by Atomic Design in successfully generated log 12 | 13 | ## [1.0.1] 2022-02-16 14 | 15 | ### Changed 16 | 17 | - Updated some documentations 18 | 19 | ## [1.0.0] 2022-02-15 20 | 21 | ### Added 22 | 23 | - Generator of configuration file 24 | - Checking Vue.js or Nuxt.js version of project 25 | - Generator of Vue.js components 26 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Arman Kuanysh ([@armankuanysh](https://github.com/armankuanysh)) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![VGENT](/assets/vgent-github-cover.png) 2 | 3 | --- 4 | 5 | VGENT – Vue Agent, that helps you to develop in a more effective way. 6 | 7 | VGENT is a CLI tool that generates boilerplate files for components, pages. You can easily customize the generator for your project and save it in the configuration file: 8 | 9 | - provide directories, where to generate your components 10 | - choose the language of the component: JavaScript or TypeScript 11 | - choose which component API to use such as Options API, Composition API, or Class components 12 | - choose CSS preprocessor 13 | - choose the component saving option: `.vue` or `/index.vue` 14 | - enable Atomic Design methodology structure of the components directory 15 | 16 | ## Installing 17 | 18 | ```bash 19 | npm install --global vgent 20 | 21 | # or 22 | 23 | yarn global add vgent 24 | ``` 25 | 26 | If you want to use VGENT locally in your project, you can install it: 27 | 28 | ```bash 29 | npm install --save-dev vgent 30 | 31 | # or 32 | 33 | yarn add --dev vgent 34 | ``` 35 | 36 | However, to use VGENT locally, you need always execute commands through `npx` or `yarn` 37 | 38 | ```bash 39 | npx vgent init 40 | 41 | # or 42 | 43 | yarn vgent init 44 | ``` 45 | 46 | ## How to use 47 | 48 | **Note**: if your project doesn’t have Nuxt.js or Vue.js you can’t use this tool. 49 | 50 | First of all, you need to initialize VGENT and configure it in your project running the next command: 51 | 52 | ```bash 53 | vgent init 54 | ``` 55 | 56 | Then, you need to provide some information about your project structure, finally, VGENT will create a configuration file: .vgentrc 57 | 58 | ```json 59 | { 60 | "src": "/", 61 | "dir": { 62 | "components": "/components", 63 | "pages": "/pages" 64 | }, 65 | "components": { 66 | "atomicDesign": true, 67 | "styleLang": "scss", 68 | "scriptLang": "ts", 69 | "componentApi": "optionsApi", 70 | "useIndex": true 71 | }, 72 | "pages": { 73 | "useIndex": true 74 | } 75 | } 76 | ``` 77 | 78 | ### Configuration glossary 79 | 80 | - **src** – is a source directory of your project. 81 | - **dir** – is an object where: 82 | - **components** – is a directory of the components 83 | - **pages** – is a directory of the pages or views 84 | - **components** – is an object of the component generation configurations where: 85 | - **atomicDesign** – is a flag to define Atomic Design structure 86 | - **styleLang** – is a name of your CSS preprocessor or just CSS 87 | - **scriptLang** – is the name of programming language to use in the components 88 | - **componentsApi** – is a script block type of your component. It could be `optionsApi`, `compositionApi` or `class`. Class type is available if you are using TypeScript. 89 | - **useIndex** – is a flag to provide format of component saving: `/index.vue` or `.vue`. 90 | - pages – is an object of the pages generation configuration where: 91 | - **useIndex** – is a flag to provide format of component saving: `/index.vue` or `.vue`. 92 | 93 | ### Component generation 94 | 95 | To generate a component you need to run the next command: 96 | 97 | ```bash 98 | vgent make -c 99 | ``` 100 | 101 | This command will generate the component in the components directory provided in the configuration with other options 102 | 103 | If you are using the Atomic Design directory structure you can provide the component type: 104 | 105 | ```bash 106 | # to generate an atom component 107 | vgent make -c -a 108 | 109 | # to generate a molecule component 110 | vgent make -c -m 111 | 112 | # to generate an organism component 113 | vgent make -c -o 114 | 115 | # to generate a template component 116 | vgent make -c -t 117 | ``` 118 | 119 | ### Page component generation 120 | 121 | To generate a page component you need to run the next command: 122 | 123 | ```bash 124 | vgent make -p 125 | ``` 126 | 127 | This command will generate the page component in the pages directory provided in the configuration with other component options 128 | 129 | If you need to generate a dynamic page (slug or id) you can provide the page type: 130 | 131 | ```bash 132 | # to generate a slug page 133 | vgent make -p --slug 134 | 135 | # to generate an id page 136 | vgent make -p --id 137 | ``` 138 | 139 | ## Authors 140 | 141 | Arman Kuanysh – [@armankuanysh](https://github.com/armankuanysh) 142 | 143 | ## License 144 | 145 | This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/armankuanysh/vgent/blob/main/LICENSE) 146 |  file for details 147 | -------------------------------------------------------------------------------- /assets/vgent-github-cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/armankuanysh/vgent/e9de41cbe1ee74663cd65d171007c0ba15f9c9de/assets/vgent-github-cover.png -------------------------------------------------------------------------------- /dist/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import Shell from "./src/context/index.js"; 3 | Shell.bootstrap(); 4 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,kBAAkB,CAAA;AAEpC,KAAK,CAAC,SAAS,EAAE,CAAA"} -------------------------------------------------------------------------------- /dist/src/context/index.js: -------------------------------------------------------------------------------- 1 | /** dependencies */ 2 | import Chalk from 'chalk'; 3 | import Yargs from 'yargs'; 4 | import inquirer from 'inquirer'; 5 | /** modules */ 6 | import Status from "../modules/status/index.js"; 7 | import Components from "../modules/components/index.js"; 8 | import Pages from "../modules/pages/index.js"; 9 | import Settings from "../modules/settings/index.js"; 10 | import Config from "../modules/config/index.js"; 11 | /** services */ 12 | import Commands from "../services/commands.js"; 13 | import Shell from "../services/shell.js"; 14 | /** utils */ 15 | import Alerts from "../utils/alerts.js"; 16 | const chalk = Chalk; 17 | const _inquirer = inquirer; 18 | const logs = new Alerts(chalk); 19 | const status = new Status(chalk, logs); 20 | const settings = new Settings(); 21 | const config = new Config(_inquirer, chalk, settings); 22 | const components = new Components(chalk, _inquirer, settings); 23 | const pages = new Pages(chalk, settings, inquirer); 24 | const commands = new Commands(status, settings, components, pages, config, logs); 25 | const shell = new Shell(Yargs, chalk, commands); 26 | export default shell; 27 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/context/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/context/index.ts"],"names":[],"mappings":"AAAA,mBAAmB;AACnB,OAAO,KAA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.js: -------------------------------------------------------------------------------- 1 | import { join, dirname } from 'path'; 2 | import { writeFile, mkdir } from 'fs/promises'; 3 | import Core from "../core/index.js"; 4 | import { component } from "../templates/component.js"; 5 | export default class Components extends Core { 6 | constructor(chalk, inquirer, settings) { 7 | super(settings, inquirer); 8 | this.chalk = chalk; 9 | } 10 | pathToFile(name) { 11 | return this.componentIndex ? `${name}/index.vue` : `${name}.vue`; 12 | } 13 | async generate(name, type) { 14 | try { 15 | this.prepare(); 16 | const boilerplate = component(name, this.componentApi, this.script, this.style); 17 | const indexed = this.pathToFile(name); 18 | const path = join(process.cwd(), this.src, this.componentDir, this.atomic ? `${type}/${indexed}` : indexed); 19 | const rewriteOrCreate = await this.rewriteModule(path, indexed); 20 | if (rewriteOrCreate) { 21 | const _dirname = dirname(path); 22 | const dirExists = await this.dirExists(_dirname); 23 | if (!dirExists) { 24 | await mkdir(_dirname, { recursive: true }); 25 | } 26 | await writeFile(path, boilerplate, { encoding: 'utf8' }); 27 | console.log(`The component ${this.atomic ? this.chalk.green(`${type}/`) : ''}${this.chalk.green(indexed)} has successfully generated!`); 28 | } else 29 | { 30 | return; 31 | } 32 | } 33 | catch (e) { 34 | console.error(`Something went wrong while generation of the ${this.chalk.redBright(name)} component`, e); 35 | } 36 | }} 37 | 38 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/components/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,IAAI,MAAM,uBAAuB,CAAA;AAKxC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAIrD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,IAAI;IAC1C,YACU,KAAmB,EAC3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C,GAAG,CACT,iBACE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAC/C,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,8BAA8B,CAC3D,CAAA;aACF;iBAAM;gBACL,OAAM;aACP;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CACX,gDAAgD,IAAI,CAAC,KAAK,CAAC,SAAS,CAClE,IAAI,CACL,YAAY,EACb,CAAC,CACF,CAAA;SACF;IACH,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/components/template.js: -------------------------------------------------------------------------------- 1 | export const template = ``; 2 | export const scriptOptionsApi = (lang, name) => ``; 13 | export const scriptClass = (lang, name) => ``; 19 | export const scriptCompositionApi = (lang) => ``; 20 | export const style = (lang) => ``; 21 | export const script = { 22 | compositionApi: (lang, _name) => scriptCompositionApi(lang), 23 | optionsApi: (lang, name) => scriptOptionsApi(lang, name), 24 | class: (lang, name) => scriptClass(lang, name) }; 25 | 26 | export const component = (name, componentApi, scriptLang, styleLang) => `${template} 27 | 28 | ${script[componentApi](scriptLang, name)} 29 | 30 | ${style(styleLang)} 31 | `; 32 | //# sourceMappingURL=template.js.map -------------------------------------------------------------------------------- /dist/src/modules/components/template.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/modules/components/template.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAAA;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAgB,EAChB,IAAY,EACZ,EAAE,CAAC,iBAAiB,IAAI;;WAEf,IAAI;;;;;;;;UAQL,CAAA;AAEV,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAgB,EAChB,IAAY,EACZ,EAAE,CAAC,iBAAiB,IAAI;;;;uBAIH,IAAI;UACjB,CAAA;AAEV,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAgB,EAAE,EAAE,CACvD,iBAAiB,IAAI,mBAAmB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAe,EAAE,EAAE,CACvC,gBAAgB,IAAI,mBAAmB,CAAA;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,cAAc,EAAE,CAAC,IAAgB,EAAE,KAAa,EAAE,EAAE,CAClD,oBAAoB,CAAC,IAAI,CAAC;IAC5B,UAAU,EAAE,CAAC,IAAgB,EAAE,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC;IAC5E,KAAK,EAAE,CAAC,IAAgB,EAAE,IAAY,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;CACnE,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAY,EACZ,YAA0B,EAC1B,UAAsB,EACtB,SAAoB,EACpB,EAAE,CAAC,GAAG,QAAQ;;EAEd,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC;;EAEtC,KAAK,CAAC,SAAS,CAAC;CACjB,CAAA"} -------------------------------------------------------------------------------- /dist/src/modules/config/index.js: -------------------------------------------------------------------------------- 1 | import { writeFile, readFile } from 'fs/promises'; 2 | import { join } from 'path'; 3 | export default class Config { 4 | constructor(inquirer, chalk, config) { 5 | this.inquirer = inquirer; 6 | this.chalk = chalk; 7 | this.config = config; 8 | } 9 | promtQuestions() { 10 | return { 11 | src: { 12 | type: 'input', 13 | name: 'src', 14 | message: 'The root directory of your project?', 15 | default: () => this.config.config.src }, 16 | 17 | componentsDir: (src) => ({ 18 | type: 'input', 19 | name: 'componentsDir', 20 | message: `The root directory of the components: ${src}`, 21 | default: () => this.config.config.dir.components }), 22 | 23 | pagesDir: (src) => ({ 24 | type: 'input', 25 | name: 'pagesDir', 26 | message: `The root directory of the pages: ${src}`, 27 | default: () => this.config.config.dir.pages }), 28 | 29 | scriptLang: { 30 | type: 'list', 31 | name: 'scriptLang', 32 | message: 'The language of scripts?', 33 | choices: [ 34 | { 35 | name: 'JavaScript', 36 | value: 'js' }, 37 | 38 | { 39 | name: 'TypeScript', 40 | value: 'ts' }], 41 | 42 | 43 | default: () => this.config.config.components.scriptLang }, 44 | 45 | componentApi: (lang) => ({ 46 | type: 'list', 47 | name: 'componentApi', 48 | message: 'Choose script configuration:', 49 | choices: [ 50 | { 51 | name: 'Options API', 52 | value: 'optionsApi' }, 53 | 54 | { 55 | name: 'Composition API', 56 | value: 'compositionApi' }, 57 | 58 | { 59 | name: 'Class component', 60 | value: 'class', 61 | [lang === 'js' && 'disabled']: 'Unavailable on JS' }], 62 | 63 | 64 | default: () => this.config.config.components.componentApi }), 65 | 66 | styleLang: { 67 | type: 'list', 68 | name: 'styleLang', 69 | message: 'CSS preprocessor?', 70 | choices: [ 71 | { 72 | name: 'CSS', 73 | value: 'css' }, 74 | 75 | { 76 | name: 'SCSS', 77 | value: 'scss' }, 78 | 79 | { 80 | name: 'SASS', 81 | value: 'sass' }, 82 | 83 | { 84 | name: 'LESS', 85 | value: 'less' }], 86 | 87 | 88 | default: () => this.config.config.components.styleLang }, 89 | 90 | useIndex: { 91 | type: 'confirm', 92 | name: 'useIndex', 93 | message: 'Use Component/index.vue format?', 94 | default: () => this.config.config.components.useIndex }, 95 | 96 | atomicDesign: { 97 | type: 'confirm', 98 | name: 'atomicDesign', 99 | message: 'Use atomic design file structure?', 100 | default: () => this.config.config.components.atomicDesign } }; 101 | 102 | 103 | } 104 | async generateDefaultConfig(content) { 105 | try { 106 | await writeFile(join(process.cwd(), '.vgentrc'), content, { 107 | encoding: 'utf8' }); 108 | 109 | console.log(`${this.chalk.green('.vgentrc')} configuration file has been generated`); 110 | console.log(`Now you can generate your components`); 111 | } 112 | catch (e) { 113 | console.error(`Something went wrong while generating configuration file`, e); 114 | } 115 | } 116 | async setSrc() { 117 | const { src } = await this.inquirer.prompt([this.promtQuestions().src]); 118 | this.config.setSrc(src); 119 | const { componentsDir } = await this.inquirer.prompt([ 120 | this.promtQuestions().componentsDir(src)]); 121 | 122 | const { pagesDir } = await this.inquirer.prompt([ 123 | this.promtQuestions().pagesDir(src)]); 124 | 125 | this.config.setDir({ pages: pagesDir, components: componentsDir }); 126 | } 127 | async setComponents() { 128 | const answers = {}; 129 | const { scriptLang } = await this.inquirer.prompt([ 130 | this.promtQuestions().scriptLang]); 131 | 132 | answers.scriptLang = scriptLang; 133 | const { componentApi } = await this.inquirer.prompt([ 134 | this.promtQuestions().componentApi(scriptLang)]); 135 | 136 | answers.componentApi = componentApi; 137 | // if (answers.scriptLang === 'ts') { 138 | // const { optionsApi } = await this.inquirer.prompt([ 139 | // this.promtQuestions().optionsApi, 140 | // ]) 141 | // answers.optionsApi = optionsApi 142 | // } 143 | const { styleLang } = await this.inquirer.prompt([ 144 | this.promtQuestions().styleLang]); 145 | 146 | answers.styleLang = styleLang; 147 | const { useIndex } = await this.inquirer.prompt([ 148 | this.promtQuestions().useIndex]); 149 | 150 | answers.useIndex = useIndex || false; 151 | this.config.setPages({ useIndex }); 152 | const { atomicDesign } = await this.inquirer.prompt([ 153 | this.promtQuestions().atomicDesign]); 154 | 155 | answers.atomicDesign = atomicDesign || false; 156 | this.config.setComponents(answers); 157 | } 158 | getContent() { 159 | const { ...object } = this.config; 160 | return JSON.stringify(object.config, null, 2); 161 | } 162 | async checkConfig() { 163 | try { 164 | const config = await readFile(join(process.cwd(), '.nxrc'), { 165 | encoding: 'utf8' }); 166 | 167 | if (config) { 168 | const { rewrite } = await this.inquirer.prompt([ 169 | { 170 | type: 'confirm', 171 | name: 'rewrite', 172 | message: 'There is .nxrc configuration file. Do you want to rewrite it?' }]); 173 | 174 | 175 | return rewrite || false; 176 | } 177 | } 178 | catch (e) { 179 | if (e.code === 'ENOENT') { 180 | return true; 181 | } 182 | } 183 | } 184 | async quickstart() { 185 | const allowance = await this.checkConfig(); 186 | if (!allowance) 187 | return; 188 | this.generateDefaultConfig(this.getContent()); 189 | } 190 | async promtUser() { 191 | const allowance = await this.checkConfig(); 192 | if (!allowance) 193 | return; 194 | await this.setSrc(); 195 | await this.setComponents(); 196 | this.generateDefaultConfig(this.getContent()); 197 | }} 198 | 199 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/config/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAM3B,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,YACU,QAA2B,EAC3B,KAAmB,EACnB,MAAiB;QAFjB,aAAQ,GAAR,QAAQ,CAAmB;QAC3B,UAAK,GAAL,KAAK,CAAc;QACnB,WAAM,GAAN,MAAM,CAAW;IACxB,CAAC;IAEI,cAAc;QACpB,OAAO;YACL,GAAG,EAAE;gBACH,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,KAAK;gBACX,OAAO,EAAE,qCAAqC;gBAC9C,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG;aACtC;YACD,aAAa,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC;gBAC/B,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,eAAe;gBACrB,OAAO,EAAE,yCAAyC,GAAG,EAAE;gBACvD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU;aACjD,CAAC;YACF,QAAQ,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,CAAC;gBAC1B,IAAI,EAAE,OAAO;gBACb,IAAI,EAAE,UAAU;gBAChB,OAAO,EAAE,oC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CAAA;aACZ;SACF;IACH,CAAC;IAED,KAAK,CAAC,UAAU;QACd,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;QAC1C,IAAI,CAAC,SAAS;YAAE,OAAM;QACtB,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IAC/C,CAAC;IAED,KAAK,CAAC,SAAS;QACb,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,WAAW,EAAE,CAAA;QAC1C,IAAI,CAAC,SAAS;YAAE,OAAM;QACtB,MAAM,IAAI,CAAC,MAAM,EAAE,CAAA;QACnB,MAAM,IAAI,CAAC,aAAa,EAAE,CAAA;QAE1B,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;IAC/C,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/core/index.js: -------------------------------------------------------------------------------- 1 | import { access } from 'fs/promises'; 2 | import inquirer from 'inquirer'; 3 | export default class Core { 4 | constructor(settings, inquirer) { 5 | this.settings = settings; 6 | this.inquirer = inquirer; 7 | } 8 | prepare() { 9 | this.src = this.settings.config.src; 10 | this.componentDir = this.settings.config.dir.components; 11 | this.pageDir = this.settings.config.dir.pages; 12 | this.script = this.settings.config.components.scriptLang; 13 | this.componentApi = this.settings.config.components.componentApi; 14 | this.style = this.settings.config.components.styleLang; 15 | this.componentIndex = this.settings.config.components.useIndex; 16 | this.pageIndex = this.settings.config.pages.useIndex; 17 | this.atomic = this.settings.config.components.atomicDesign; 18 | } 19 | capitalize(str) { 20 | return str.charAt(0).toUpperCase() + str.slice(1); 21 | } 22 | async dirExists(path) { 23 | try { 24 | await access(path); 25 | return true; 26 | } 27 | catch { 28 | return false; 29 | } 30 | } 31 | async rewriteModule(path, name) { 32 | const exists = await this.dirExists(path); 33 | if (exists) { 34 | const { rewrite } = await inquirer.prompt({ 35 | type: 'confirm', 36 | name: 'rewrite', 37 | message: `File ${name} is exist. Do you want to rewrite file?` }); 38 | 39 | return rewrite; 40 | } 41 | return true; 42 | }} 43 | 44 | Core.isNuxtProject = false; 45 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/core/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,QAAQ,MAAM,UAAU,CAAA;AAK/B,MAAM,CAAC,OAAO,OAAgB,IAAI;IAWhC,YACqB,QAAmB,EAC5B,QAA2B;QADlB,aAAQ,GAAR,QAAQ,CAAW;QAC5B,aAAQ,GAAR,QAAQ,CAAmB;IACpC,CAAC;IAEM,OAAO;QACf,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAA;QACnC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,UAAU,CAAA;QACvD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAA;QAC7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,UAAU,CAAA;QACxD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAA;QAChE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,SAAS,CAAA;QACtD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAA;QAC9D,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAA;QACpD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,YAAY,CAAA;IAC5D,CAAC;IAIS,UAAU,CAAC,GAAW;QAC9B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;IACnD,CAAC;IAES,KAAK,CAAC,SAAS,CAAC,IAAY;QACpC,IAAI;YACF,MAAM,MAAM,CAAC,IAAI,CAAC,CAAA;YAClB,OAAO,IAAI,CAAA;SACZ;QAAC,MAAM;YACN,OAAO,KAAK,CAAA;SACb;IACH,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,IAAY,EAAE,IAAY;QACtD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACzC,IAAI,MAAM,EAAE;YACV,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBACxC,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,SAAS;gBACf,OAAO,EAAE,QAAQ,IAAI,yCAAyC;aAC/D,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;SACf;QACD,OAAO,IAAI,CAAA;IACb,CAAC;;AArDM,kBAAa,GAAG,KAAK,CAAA"} -------------------------------------------------------------------------------- /dist/src/modules/nuxt/index.js: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path'; 2 | export default class Nuxt { 3 | async readNuxtConfig() { 4 | const path = resolve(process.cwd() + '/nuxt.config.js'); 5 | console.log('getting nuxt...'); 6 | // const { default: nuxtConfig } = await import(path) 7 | console.log('got nuxt'); 8 | return ''; 9 | }} 10 | 11 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/nuxt/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/nuxt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAE,MAAM,MAAM,CAAA;AAGpC,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,KAAK,CAAC,cAAc;QAClB,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,iBAAiB,CAAC,CAAA;QACvD,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAA;QAC9B,qDAAqD;QACrD,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;QACvB,OAAO,EAAE,CAAA;IACX,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/pages/index.js: -------------------------------------------------------------------------------- 1 | import { dirname, join } from 'path'; 2 | import { mkdir, writeFile } from 'fs/promises'; 3 | import Core from "../core/index.js"; 4 | import { component } from "../templates/component.js"; 5 | export default class Pages extends Core { 6 | constructor(chalk, settings, inquirer) { 7 | super(settings, inquirer); 8 | this.chalk = chalk; 9 | } 10 | pathToFile(name, type) { 11 | return this.pageIndex ? 12 | `${name}/${type !== 'index' ? `_${type}` : 'index'}.vue` : 13 | type === 'index' ? 14 | `${name}.vue` : 15 | `_${name}${this.capitalize(type)}.vue`; 16 | } 17 | async generate(name, type) { 18 | try { 19 | this.prepare(); 20 | const boilerplate = component(type !== 'index' ? 21 | `${this.capitalize(name)}${this.capitalize(type)}` : 22 | this.capitalize(name), this.componentApi, this.script, this.style); 23 | const indexed = this.pathToFile(name, type); 24 | const path = join(process.cwd(), this.src, this.pageDir, indexed); 25 | const rewriteOrCreate = await this.rewriteModule(path, indexed); 26 | if (rewriteOrCreate) { 27 | const _dirname = dirname(path); 28 | const exists = await this.dirExists(_dirname); 29 | if (!exists) { 30 | await mkdir(_dirname, { recursive: true }); 31 | } 32 | await writeFile(path, boilerplate, { encoding: 'utf8' }); 33 | console.log(`The page ${this.chalk.green(indexed)} has successfully generated!`); 34 | } else 35 | { 36 | return; 37 | } 38 | } 39 | catch (e) { 40 | console.error(`Something went wrong while generation of the ${this.chalk.redBright(name)} page`, e); 41 | } 42 | }} 43 | 44 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/pages/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/pages/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,IAAI,MAAM,uBAAuB,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gCAAgC,CAAA;AAK1D,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,IAAI;IACrC,YACU,KAAmB,EAC3B,QAAmB,EACnB,QAA2B;QAE3B,KAAK,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;QAJjB,UAAK,GAAL,KAAK,CAAc;IAK7B,CAAC;IAED,UAAU,CAAC,IAAY,EAAE,IAAc;QACrC,OAAO,IAAI,CAAC,SAAS;YACnB,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,MAAM;YAC1D,CAAC,CAAC,IAAI,KAAK,OAAO;gBAClB,CAAC,CAAC,GAAG,IAAI,MAAM;gBACf,CAAC,CAAC,IAAI,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAA;IAC5C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAY,EAAE,IAAe;QAC1C,IAAI;YACF,IAAI,CAAC,OAAO,EAAE,CAAA;YACd,MAAM,WAAW,GAAG,SAAS,CAC3B,IAAI,KAAK,OAAO;gBACd,CAAC,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE;gBACpD,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EACzB,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,KAAK,CACX,CAAA;YACD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;YAC3C,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YACjE,MAAM,eAAe,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;YAC/D,IAAI,eAAe,EAAE;gBACnB,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;gBAC9B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;gBAC7C,IAAI,CAAC,MAAM,EAAE;oBACX,MAAM,KAAK,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAA;iBAC3C;gBACD,MAAM,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;gBACxD,OAAO,CAAC,GAAG,CACT,YAAY,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,8BAA8B,CACpE,CAAA;aACF;iBAAM;gBACL,OAAM;aACP;SACF;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CACX,gDAAgD,IAAI,CAAC,KAAK,CAAC,SAAS,CAClE,IAAI,CACL,OAAO,EACR,CAAC,CACF,CAAA;SACF;IACH,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/settings/index.js: -------------------------------------------------------------------------------- 1 | import { resolve, join } from 'path'; 2 | import { readFile } from 'fs/promises'; 3 | export default class Settings { 4 | constructor() { 5 | this.config = { 6 | src: './', 7 | dir: { 8 | components: resolve(process.cwd(), '/components'), 9 | layout: resolve(process.cwd(), '/layout'), 10 | pages: resolve(process.cwd(), '/pages'), 11 | store: resolve(process.cwd(), '/store') }, 12 | 13 | components: { 14 | atomicDesign: false, 15 | styleLang: 'scss', 16 | scriptLang: 'js', 17 | componentApi: 'optionsApi', 18 | detached: false, 19 | useIndex: true }, 20 | 21 | pages: { 22 | useIndex: true } }; 23 | 24 | 25 | } 26 | setSrc(src) { 27 | this.config.src = src; 28 | } 29 | setDir(dir) { 30 | this.config.dir = { ...this.config.dir, ...dir }; 31 | } 32 | setComponents(components) { 33 | this.config.components = { ...this.config.components, ...components }; 34 | } 35 | setPages(pages) { 36 | this.config.pages = { ...this.config.pages, ...pages }; 37 | } 38 | async readLocalConfig() { 39 | try { 40 | const file = await readFile(join(process.cwd(), '/.vgentrc'), { 41 | encoding: 'utf8' }); 42 | 43 | const config = JSON.parse(file); 44 | this.setSrc(config.src); 45 | this.setDir(config.dir); 46 | this.setComponents(config.components); 47 | this.setPages(config.pages); 48 | } 49 | catch (e) { 50 | console.error(e); 51 | } 52 | }} 53 | 54 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/settings/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/settings/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAItC,MAAM,CAAC,OAAO,OAAO,QAAQ;IAA7B;QACE,WAAM,GAAY;YAChB,GAAG,EAAE,IAAI;YACT,GAAG,EAAE;gBACH,UAAU,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC;gBACjD,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC;gBACzC,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAC;gBACv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CAAA;YACvB,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;YACrC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;SAC5B;QAAC,OAAO,CAAC,EAAE;YACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;SACjB;IACH,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/status.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0; 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | var _promises = require("fs/promises");var __awaiter = void 0 && (void 0).__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());});}; 11 | class Status { 12 | constructor(chalk, alerts) { 13 | this.chalk = chalk; 14 | this.alerts = alerts; 15 | } 16 | checkNuxt() { 17 | return __awaiter(this, void 0, void 0, function* () { 18 | try { 19 | const packageJsonText = yield (0, _promises.readFile)(process.cwd() + '/package.json', { 20 | encoding: 'utf8' }); 21 | 22 | const packageJson = JSON.parse(packageJsonText); 23 | if (packageJson && 24 | packageJson.dependencies && 25 | packageJson.dependencies.nuxt) { 26 | console.log(this.chalk.green(`nuxt ${packageJson.dependencies.nuxt}`)); 27 | return true; 28 | } else 29 | { 30 | this.alerts.cantFindNuxt(); 31 | return false; 32 | } 33 | } 34 | catch (e) { 35 | if (e.code === 'ENOENT') { 36 | this.alerts.cantFindNuxt(); 37 | } 38 | } 39 | }); 40 | } 41 | checkConfig() { 42 | return __awaiter(this, void 0, void 0, function* () { 43 | try { 44 | const file = yield (0, _promises.readFile)(process.cwd() + '/.nxrc', { 45 | encoding: 'utf8' }); 46 | 47 | const projectConfig = JSON.parse(file); 48 | if (projectConfig) { 49 | return projectConfig; 50 | } else 51 | { 52 | this.alerts.invalidProjectConfig(); 53 | } 54 | } 55 | catch (e) { 56 | if (e.code === 'ENOENT') { 57 | this.alerts.cantFindProjectConfig(); 58 | } 59 | } 60 | }); 61 | }} 62 | 63 | //# sourceMappingURL=status.js.map 64 | exports.default = Status; -------------------------------------------------------------------------------- /dist/src/modules/status.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/modules/status.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAKtC,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,YAAoB,KAAmB,EAAU,MAAe;QAA5C,UAAK,GAAL,KAAK,CAAc;QAAU,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAE9D,SAAS;;YACb,IAAI;gBACF,MAAM,eAAe,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,eAAe,EAAE;oBACtE,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAA;gBACF,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,CAAA;gBAC/C,IACE,WAAW;oBACX,WAAW,CAAC,YAAY;oBACxB,WAAW,CAAC,YAAY,CAAC,IAAI,EAC7B;oBACA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,WAAW,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;oBACtE,OAAO,IAAI,CAAA;iBACZ;qBAAM;oBACL,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;oBAC1B,OAAO,KAAK,CAAA;iBACb;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACvB,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAA;iBAC3B;aACF;QACH,CAAC;KAAA;IAEK,WAAW;;YACf,IAAI;gBACF,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE;oBACpD,QAAQ,EAAE,MAAM;iBACjB,CAAC,CAAA;gBACF,MAAM,aAAa,GAAY,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;gBAC/C,IAAI,aAAa,EAAE;oBACjB,OAAO,aAAa,CAAA;iBACrB;qBAAM;oBACL,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAA;iBACnC;aACF;YAAC,OAAO,CAAC,EAAE;gBACV,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;oBACvB,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAA;iBACpC;aACF;QACH,CAAC;KAAA;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/status/index.js: -------------------------------------------------------------------------------- 1 | import { readFile } from 'fs/promises'; 2 | export default class Status { 3 | constructor(chalk, alerts) { 4 | this.chalk = chalk; 5 | this.alerts = alerts; 6 | this._isNuxtApp = false; 7 | this._isVueApp = false; 8 | } 9 | get isNuxtApp() { 10 | return this._isNuxtApp; 11 | } 12 | set isNuxtApp(status) { 13 | this._isNuxtApp = status; 14 | } 15 | get isVueApp() { 16 | return this._isVueApp; 17 | } 18 | set isVueApp(status) { 19 | this._isVueApp = status; 20 | } 21 | async checkNuxtOrVue() { 22 | try { 23 | const packageJsonText = await readFile(process.cwd() + '/package.json', { 24 | encoding: 'utf8' }); 25 | 26 | const packageJson = JSON.parse(packageJsonText); 27 | if (packageJson && 28 | packageJson.dependencies && 29 | packageJson.dependencies.nuxt) { 30 | console.log(this.chalk.green(`nuxt ${packageJson.dependencies.nuxt}`)); 31 | this._isNuxtApp = true; 32 | } else 33 | if (packageJson && 34 | packageJson.dependencies && 35 | packageJson.dependencies.vue) { 36 | console.log(this.chalk.green(`vue ${packageJson.dependencies.vue}`)); 37 | this._isVueApp = true; 38 | } else 39 | { 40 | this.alerts.cantFindNuxtOrVue(); 41 | this._isNuxtApp = false; 42 | this._isVueApp = false; 43 | } 44 | } 45 | catch (e) { 46 | if (e.code === 'ENOENT') { 47 | this.alerts.cantFindNuxtOrVue(); 48 | } 49 | } 50 | } 51 | async checkConfig() { 52 | try { 53 | const file = await readFile(process.cwd() + '/.vgentrc', { 54 | encoding: 'utf8' }); 55 | 56 | const projectConfig = JSON.parse(file); 57 | if (projectConfig) { 58 | return projectConfig; 59 | } else 60 | { 61 | this.alerts.invalidProjectConfig(); 62 | } 63 | } 64 | catch (e) { 65 | if (e.code === 'ENOENT') { 66 | this.alerts.cantFindProjectConfig(); 67 | } 68 | } 69 | }} 70 | 71 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/status/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/status/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AAMtC,MAAM,CAAC,OAAO,OAAO,MAAM;IAIzB,YAAoB,KAAmB,EAAU,MAAe;QAA5C,UAAK,GAAL,KAAK,CAAc;QAAU,WAAM,GAAN,MAAM,CAAS;QAHxD,eAAU,GAAG,KAAK,CAAA;QAClB,cAAS,GAAG,KAAK,CAAA;IAE0C,CAAC;IAEpE,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAA;IACxB,CAAC;IAED,IAAI,SAAS,CAAC,MAAe;QAC3B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAA;IAC1B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;IAED,IAAI,QAAQ,CAAC,MAAe;QAC1B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAA;IACzB,CAAC;IAED,KAA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,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC/C,IAAI,aAAa,EAAE;gBACjB,OAAO,aAAa,CAAA;aACrB;iBAAM;gBACL,IAAI,CAAC,MAAM,CAAC,oBAAoB,EAAE,CAAA;aACnC;SACF;QAAC,OAAO,CAAC,EAAE;YACV,IAAI,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;gBACvB,IAAI,CAAC,MAAM,CAAC,qBAAqB,EAAE,CAAA;aACpC;SACF;IACH,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/modules/templates/component.js: -------------------------------------------------------------------------------- 1 | export const template = ``; 2 | export const scriptOptionsApi = (lang, name) => ``; 15 | export const scriptClass = (lang, name) => ``; 21 | export const scriptCompositionApi = (lang) => ``; 22 | export const style = (lang) => ``; 23 | export const script = { 24 | compositionApi: (lang, _name) => scriptCompositionApi(lang), 25 | optionsApi: (lang, name) => scriptOptionsApi(lang, name), 26 | class: (lang, name) => scriptClass(lang, name) }; 27 | 28 | export const component = (name, componentApi, scriptLang, styleLang) => `${template} 29 | 30 | ${script[componentApi](scriptLang, name)} 31 | 32 | ${style(styleLang)} 33 | `; 34 | //# sourceMappingURL=component.js.map -------------------------------------------------------------------------------- /dist/src/modules/templates/component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../../src/modules/templates/component.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAAA;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAgB,EAChB,IAAY,EACZ,EAAE,CAAC,iBAAiB,IAAI;EACxB,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,EAAE;iBAC7B,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE;WACxC,IAAI;;;;;;;;GAQZ,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;UACjB,CAAA;AAEV,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAgB,EAChB,IAAY,EACZ,EAAE,CAAC,iBAAiB,IAAI;;;;uBAIH,IAAI;UACjB,CAAA;AAEV,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAgB,EAAE,EAAE,CACvD,iBAAiB,IAAI,mBAAmB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAe,EAAE,EAAE,CACvC,gBAAgB,IAAI,mBAAmB,CAAA;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,cAAc,EAAE,CAAC,IAAgB,EAAE,KAAa,EAAE,EAAE,CAClD,oBAAoB,CAAC,IAAI,CAAC;IAC5B,UAAU,EAAE,CAAC,IAAgB,EAAE,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC;IAC5E,KAAK,EAAE,CAAC,IAAgB,EAAE,IAAY,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;CACnE,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAY,EACZ,YAA0B,EAC1B,UAAsB,EACtB,SAAoB,EACpB,EAAE,CAAC,GAAG,QAAQ;;EAEd,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC;;EAEtC,KAAK,CAAC,SAAS,CAAC;CACjB,CAAA"} -------------------------------------------------------------------------------- /dist/src/modules/templates/index.js: -------------------------------------------------------------------------------- 1 | export const template = ``; 2 | export const scriptOptionsApi = (lang, name) => ``; 13 | export const scriptClass = (lang, name) => ``; 19 | export const scriptCompositionApi = (lang) => ``; 20 | export const style = (lang) => ``; 21 | export const script = { 22 | compositionApi: (lang, _name) => scriptCompositionApi(lang), 23 | optionsApi: (lang, name) => scriptOptionsApi(lang, name), 24 | class: (lang, name) => scriptClass(lang, name) }; 25 | 26 | export const component = (name, componentApi, scriptLang, styleLang) => `${template} 27 | 28 | ${script[componentApi](scriptLang, name)} 29 | 30 | ${style(styleLang)} 31 | `; 32 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /dist/src/modules/templates/index.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/templates/index.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAAA;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,IAAgB,EAChB,IAAY,EACZ,EAAE,CAAC,iBAAiB,IAAI;;WAEf,IAAI;;;;;;;;UAQL,CAAA;AAEV,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,IAAgB,EAChB,IAAY,EACZ,EAAE,CAAC,iBAAiB,IAAI;;;;uBAIH,IAAI;UACjB,CAAA;AAEV,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAgB,EAAE,EAAE,CACvD,iBAAiB,IAAI,mBAAmB,CAAA;AAE1C,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,IAAe,EAAE,EAAE,CACvC,gBAAgB,IAAI,mBAAmB,CAAA;AAEzC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,cAAc,EAAE,CAAC,IAAgB,EAAE,KAAa,EAAE,EAAE,CAClD,oBAAoB,CAAC,IAAI,CAAC;IAC5B,UAAU,EAAE,CAAC,IAAgB,EAAE,IAAY,EAAE,EAAE,CAAC,gBAAgB,CAAC,IAAI,EAAE,IAAI,CAAC;IAC5E,KAAK,EAAE,CAAC,IAAgB,EAAE,IAAY,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC;CACnE,CAAA;AAED,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,IAAY,EACZ,YAA0B,EAC1B,UAAsB,EACtB,SAAoB,EACpB,EAAE,CAAC,GAAG,QAAQ;;EAEd,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE,IAAI,CAAC;;EAEtC,KAAK,CAAC,SAAS,CAAC;CACjB,CAAA"} -------------------------------------------------------------------------------- /dist/src/services/commands.js: -------------------------------------------------------------------------------- 1 | export default class Commands { 2 | constructor(status, settings, generateComponents, generatePages, configGenerator, alerts) { 3 | this.status = status; 4 | this.settings = settings; 5 | this.generateComponents = generateComponents; 6 | this.generatePages = generatePages; 7 | this.configGenerator = configGenerator; 8 | this.alerts = alerts; 9 | } 10 | async health(init) { 11 | await this.status.checkNuxtOrVue(); 12 | if ((this.status.isNuxtApp || this.status.isVueApp) && !init) { 13 | await this.status.checkConfig(); 14 | } 15 | } 16 | async components(name, type) { 17 | await this.health(); 18 | await this.settings.readLocalConfig(); 19 | await this.generateComponents.generate(name, type); 20 | } 21 | async pages(name, type) { 22 | await this.health(); 23 | await this.settings.readLocalConfig(); 24 | await this.generatePages.generate(name, type); 25 | } 26 | async init(quickstart) { 27 | await this.health(true); 28 | if (quickstart) { 29 | this.configGenerator.quickstart(); 30 | } else 31 | { 32 | await this.configGenerator.promtUser(); 33 | } 34 | } 35 | async placeholder() { 36 | await this.health(); 37 | if (this.status.isNuxtApp || this.status.isVueApp) { 38 | this.alerts.initInstruction(); 39 | } 40 | }} 41 | 42 | //# sourceMappingURL=commands.js.map -------------------------------------------------------------------------------- /dist/src/services/commands.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/services/commands.ts"],"names":[],"mappings":"AAOA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC3B,YACU,MAAe,EACf,QAAmB,EACnB,kBAA8B,EAC9B,aAAyB,EACzB,eAAuB,EACvB,MAAe;QALf,WAAM,GAAN,MAAM,CAAS;QACf,aAAQ,GAAR,QAAQ,CAAW;QACnB,uBAAkB,GAAlB,kBAAkB,CAAY;QAC9B,kBAAa,GAAb,aAAa,CAAY;QACzB,oBAAe,GAAf,eAAe,CAAQ;QACvB,WAAM,GAAN,MAAM,CAA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F"} -------------------------------------------------------------------------------- /dist/src/services/options.js: -------------------------------------------------------------------------------- 1 | export const options = { 2 | q: { 3 | alias: 'quickstart', 4 | describe: 'Generate config file with default configuration', 5 | type: 'boolean', 6 | demandOption: false }, 7 | 8 | c: { 9 | alias: 'component', 10 | describe: 'Generate component', 11 | type: 'string', 12 | demandOption: false }, 13 | 14 | a: { 15 | alias: 'atoms', 16 | describe: 'Generate an atom component. Used when Atomic Design option is enabled', 17 | type: 'boolean', 18 | demandOption: false }, 19 | 20 | m: { 21 | alias: 'molecules', 22 | describe: 'Generate a molecules component. Used when Atomic Design option is enabled', 23 | type: 'boolean', 24 | demandOption: false }, 25 | 26 | o: { 27 | alias: 'organisms', 28 | describe: 'Generate an organism component. Used when Atomic Design option is enabled', 29 | type: 'boolean', 30 | demandOption: false }, 31 | 32 | t: { 33 | alias: 'templates', 34 | describe: 'Generate a templates component. Used when Atomic Design option is enabled', 35 | type: 'boolean', 36 | demandOption: false }, 37 | 38 | p: { 39 | alias: 'page', 40 | describe: 'Generate page component', 41 | type: 'string', 42 | demandOption: false }, 43 | 44 | slug: { 45 | describe: 'Slug type of the page', 46 | type: 'boolean', 47 | demandOption: false }, 48 | 49 | id: { 50 | describe: 'ID type of the page', 51 | type: 'boolean', 52 | demandOption: false }, 53 | 54 | s: { 55 | alias: 'store', 56 | describe: 'Generate store module', 57 | type: 'boolean', 58 | demandOption: false } }; 59 | 60 | 61 | //# sourceMappingURL=options.js.map -------------------------------------------------------------------------------- /dist/src/services/options.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/services/options.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,OAAO,GAAY;IAC9B,CAAC,EAAE;QACD,KAAK,EAAE,YAAY;QACnB,QAAQ,EAAE,iDAAiD;QAC3D,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,oBAAoB;QAC9B,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,OAAO;QACd,QAAQ,EACN,uEAAuE;QACzE,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,WAAW;QAClB,QAAQ,EACN,2EAA2E;QAC7E,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,WAAW;QAClB,QAAQ,EACN,2EAA2E;QAC7E,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,WAAW;QAClB,QAAQ,EACN,2EAA2E;QAC7E,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,MAAM;QACb,QAAQ,EAAE,yBAAyB;QACnC,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;KACpB;IACD,IAAI,EAAE;QACJ,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,qBAAqB;QAC/B,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;IACD,CAAC,EAAE;QACD,KAAK,EAAE,OAAO;QACd,QAAQ,EAAE,uBAAuB;QACjC,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,KAAK;KACpB;CACF,CAAA"} -------------------------------------------------------------------------------- /dist/src/services/shell.js: -------------------------------------------------------------------------------- 1 | import { options } from "./options.js"; 2 | export default class Shell { 3 | constructor(yargs, chalk, commands) { 4 | this.yargs = yargs; 5 | this.chalk = chalk; 6 | this.commands = commands; 7 | } 8 | bootstrap() { 9 | this.yargs(process.argv.slice(2)). 10 | usage(`Info: ${this.chalk.green('vgent')} is boilerplate file generator for Nuxt.js and Vue.js`). 11 | command('$0', '', {}, async () => { 12 | await this.commands.placeholder(); 13 | }). 14 | command('health', 'Check project', () => {}, async () => { 15 | await this.commands.health(); 16 | }). 17 | command('make', 'Used for some generations', () => {}, async (options) => { 18 | if (!options.c && !options.p) { 19 | await this.commands.placeholder(); 20 | } 21 | if (options.c) { 22 | const name = options.c; 23 | const type = options.a && 'atoms' || 24 | options.m && 'molecules' || 25 | options.o && 'organisms' || 26 | options.t && 'templates' || 27 | 'atoms'; 28 | await this.commands.components(name, type); 29 | } 30 | if (options.p) { 31 | const name = options.p; 32 | const type = options.slug && 'slug' || 33 | options.id && 'id' || 34 | 'index'; 35 | await this.commands.pages(name, type); 36 | } 37 | }). 38 | command('init', `Initialize ${this.chalk.green('vgent')} in the project`, () => {}, async (options) => { 39 | await this.commands.init(options.q); 40 | }). 41 | option('q', options['q']). 42 | option('c', options['c']). 43 | option('a', options['a']). 44 | option('m', options['m']). 45 | option('o', options['o']). 46 | option('t', options['t']). 47 | option('p', options['p']). 48 | option('slug', options['slug']). 49 | option('id', options['id']). 50 | option('s', options['s']). 51 | help(true).argv; 52 | }} 53 | 54 | //# sourceMappingURL=shell.js.map -------------------------------------------------------------------------------- /dist/src/services/shell.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../src/services/shell.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAItC,MAAM,CAAC,OAAO,OAAO,KAAK;IACxB,YACU,KAAmB,EACnB,KAAmB,EACnB,QAAmB;QAFnB,UAAK,GAAL,KAAK,CAAc;QACnB,UAAK,GAAL,KAAK,CAAc;QACnB,aAAQ,GAAR,QAAQ,CAAW;IAC1B,CAAC;IAEJ,SAAS;QACP,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aAC9B,KAAK,CACJ,SAAS,IAAI,CAA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,CAAa,CAAA;gBACtB,MAAM,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;aACtC;QACH,CAAC,CACF;aACA,OAAO,CACN,MAAM,EACN,cAAc,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,iBAAiB,EACxD,GAAG,EAAE,GAAE,CAAC,EACR,KAAK,EAAE,OAAO,EAAE,EAAE;YAChB,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAY,CAAC,CAAA;QAChD,CAAC,CACF;aACA,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;aAC/B,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;aAC3B,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC;aACzB,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAA;IACpB,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/types/alerts.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=alerts.js.map -------------------------------------------------------------------------------- /dist/src/types/alerts.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"alerts.js","sourceRoot":"","sources":["../../../src/types/alerts.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/commands.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=commands.js.map -------------------------------------------------------------------------------- /dist/src/types/commands.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../../src/types/commands.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/config.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=config.js.map -------------------------------------------------------------------------------- /dist/src/types/config.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/generator.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=generator.js.map -------------------------------------------------------------------------------- /dist/src/types/generator.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../src/types/generator.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/nuxt.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=nuxt.js.map -------------------------------------------------------------------------------- /dist/src/types/nuxt.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"nuxt.js","sourceRoot":"","sources":["../../../src/types/nuxt.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/options.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=options.js.map -------------------------------------------------------------------------------- /dist/src/types/options.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/types/options.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/settings.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=settings.js.map -------------------------------------------------------------------------------- /dist/src/types/settings.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"settings.js","sourceRoot":"","sources":["../../../src/types/settings.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/shell.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=shell.js.map -------------------------------------------------------------------------------- /dist/src/types/shell.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../../src/types/shell.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/types/status.js: -------------------------------------------------------------------------------- 1 | export {}; 2 | //# sourceMappingURL=status.js.map -------------------------------------------------------------------------------- /dist/src/types/status.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"status.js","sourceRoot":"","sources":["../../../src/types/status.ts"],"names":[],"mappings":""} -------------------------------------------------------------------------------- /dist/src/utils/alerts.js: -------------------------------------------------------------------------------- 1 | export default class Alerts { 2 | constructor(chalk) { 3 | this.chalk = chalk; 4 | } 5 | cantFindNuxtOrVue() { 6 | console.error(`Can't find ${this.chalk.green('nuxt')} nor ${this.chalk.green('vue')} dependencies. Is this project on ${this.chalk.green('Nuxt.js')} or ${this.chalk.green('Vue.js')}?`); 7 | } 8 | cantFindProjectConfig() { 9 | console.error(`Can't find ${this.chalk.green('.vgentrc')} configuration file.\nRun ${this.chalk.green('vgent init')} and provide some configurations.\n`); 10 | } 11 | invalidProjectConfig() { 12 | console.error(`${this.chalk.red('Invalid config')}: seems ${this.chalk.green('.vgentrc')} file has invalid options`); 13 | } 14 | initInstruction() { 15 | console.log(`To generate a component run: ${this.chalk.greenBright('vgent make -c ')}`, `\nTo generate a page run: ${this.chalk.greenBright('vgent make -p ')}`); 16 | }} 17 | 18 | //# sourceMappingURL=alerts.js.map -------------------------------------------------------------------------------- /dist/src/utils/alerts.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"alerts.js","sourceRoot":"","sources":["../../../src/utils/alerts.ts"],"names":[],"mappings":"AAGA,MAAM,CAAC,OAAO,OAAO,MAAM;IACzB,YAAoB,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAE3C,iBAAiB;QACf,OAAO,CAAC,KAAK,CACX,cAAc,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAC5D,KAAK,CACN,qCAAqC,IAAI,CAAC,KAAK,CAAC,KAAK,CACpD,SAAS,CACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CACtC,CAAA;IACH,CAAC;IAED,qBAAqB;QACnB,OAAO,CAAC,KAAK,CACX,cAAc,IAAI,CAAC,KAAK,CAAC,KAAK,CAC5B,UAAU,CACX,6BAA6B,IAAI,CAAC,KAAK,CAAC,KAAK,CAC5C,YAAY,CACb,qCAAqC,CACvC,CAAA;IACH,CAAC;IAED,oBAAoB;QAClB,OAAO,CAAC,KAAK,CACX,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,WAAW,IAAI,CAAC,KAAK,CAAC,KAAK,CAC5D,UAAU,CACX,2BAA2B,CAC7B,CAAA;IACH,CAAC;IAED,eAAe;QACb,OAAO,CAAC,GAAG,CACT,gCAAgC,IAAI,CAAC,KAAK,CAAC,WAAW,CACpD,gCAAgC,CACjC,EAAE,EACH,6BAA6B,IAAI,CAAC,KAAK,CAAC,WAAW,CACjD,2BAA2B,CAC5B,EAAE,CACJ,CAAA;IACH,CAAC;CACF"} -------------------------------------------------------------------------------- /dist/src/utils/logs.js: -------------------------------------------------------------------------------- 1 | "use strict";Object.defineProperty(exports, "__esModule", { value: true });exports.default = void 0;class Logs { 2 | constructor(chalk) { 3 | this.chalk = chalk; 4 | } 5 | cantFindNuxt() { 6 | console.error(`Can't find ${this.chalk.green('nuxt')}. Is this project on Nuxt.js`); 7 | }} 8 | 9 | //# sourceMappingURL=logs.js.map 10 | exports.default = Logs; -------------------------------------------------------------------------------- /dist/src/utils/logs.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"logs.js","sourceRoot":"","sources":["../../../src/utils/logs.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,IAAI;IACvB,YAAoB,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IAAG,CAAC;IAE3C,YAAY;QACV,OAAO,CAAC,KAAK,CACX,cAAc,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,8BAA8B,CACrE,CAAA;IACH,CAAC;CACF"} -------------------------------------------------------------------------------- /index.ts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | import Shell from 'context/index.js' 3 | 4 | Shell.bootstrap() 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vgent", 3 | "version": "1.0.2", 4 | "description": "VGENT is a CLI tool that generates boilerplate files for components, pages in your Nuxt.js or Vue.js project.", 5 | "main": "dist/index.js", 6 | "files": [ 7 | "dist", 8 | "README.md" 9 | ], 10 | "repository": { 11 | "type": "git", 12 | "url": "https://github.com/armankuanysh/vgent" 13 | }, 14 | "bugs": { 15 | "url": "https://github.com/armankuanysh/vgent/issues" 16 | }, 17 | "bin": { 18 | "vgent": "dist/index.js" 19 | }, 20 | "author": "Arman Kuanysh ", 21 | "keywords": [ 22 | "command", 23 | "prompt", 24 | "cli", 25 | "vue", 26 | "vuejs", 27 | "Vue.js", 28 | "nuxt", 29 | "nuxtjs", 30 | "Nuxt.js", 31 | "components", 32 | "components boilerplate", 33 | "vue components" 34 | ], 35 | "license": "MIT", 36 | "type": "module", 37 | "scripts": { 38 | "build": "ttsc && babel dist -d dist", 39 | "test": "echo \"No test specified\"" 40 | }, 41 | "devDependencies": { 42 | "@babel/cli": "^7.17.0", 43 | "@babel/core": "^7.17.2", 44 | "@babel/node": "^7.16.8", 45 | "@babel/preset-env": "^7.16.11", 46 | "@types/inquirer": "^8.2.0", 47 | "@types/node": "^17.0.17", 48 | "@types/yargs": "^17.0.8", 49 | "babel-plugin-module-resolver": "^4.1.0", 50 | "eslint": "^8.8.0", 51 | "eslint-config-prettier": "^8.3.0", 52 | "eslint-plugin-prettier": "^4.0.0", 53 | "prettier": "^2.5.1", 54 | "ttypescript": "^1.5.13", 55 | "typescript": "^4.5.5", 56 | "typescript-transform-paths": "^3.3.1" 57 | }, 58 | "dependencies": { 59 | "chalk": "^5.0.0", 60 | "inquirer": "^8.2.0", 61 | "yargs": "^17.3.1" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/context/index.ts: -------------------------------------------------------------------------------- 1 | /** dependencies */ 2 | import Chalk from 'chalk' 3 | import Yargs from 'yargs' 4 | import inquirer from 'inquirer' 5 | /** modules */ 6 | import Status from 'modules/status/index.js' 7 | import Components from 'modules/components/index.js' 8 | import Pages from 'modules/pages/index.js' 9 | import Settings from 'modules/settings/index.js' 10 | import Config from 'modules/config/index.js' 11 | /** services */ 12 | import Commands from 'services/commands.js' 13 | import Shell from 'services/shell.js' 14 | /** utils */ 15 | import Alerts from 'utils/alerts.js' 16 | 17 | const chalk = Chalk 18 | const _inquirer = inquirer 19 | 20 | const logs = new Alerts(chalk) 21 | const status = new Status(chalk, logs) 22 | const settings = new Settings() 23 | const config = new Config(_inquirer, chalk, settings) 24 | const components = new Components(chalk, _inquirer, settings) 25 | const pages = new Pages(chalk, settings, inquirer) 26 | const commands = new Commands(status, settings, components, pages, config, logs) 27 | const shell = new Shell(Yargs, chalk, commands) 28 | 29 | export default shell 30 | -------------------------------------------------------------------------------- /src/modules/components/index.ts: -------------------------------------------------------------------------------- 1 | import { join, dirname } from 'path' 2 | import { writeFile, mkdir } from 'fs/promises' 3 | import Core from 'modules/core/index.js' 4 | import { IAlerts } from 'types/alerts' 5 | import { IConfig } from 'types/config' 6 | import { componentType, IGenerator } from 'types/generator' 7 | import { ISettings } from 'types/settings' 8 | import { component } from '../templates/component.js' 9 | import Chalk from 'chalk' 10 | import inquirer from 'inquirer' 11 | 12 | export default class Components extends Core implements IGenerator { 13 | constructor( 14 | private chalk: typeof Chalk, 15 | inquirer: inquirer.Inquirer, 16 | settings: ISettings 17 | ) { 18 | super(settings, inquirer) 19 | } 20 | 21 | pathToFile(name: string) { 22 | return this.componentIndex ? `${name}/index.vue` : `${name}.vue` 23 | } 24 | 25 | async generate(name: string, type?: componentType) { 26 | try { 27 | this.prepare() 28 | const boilerplate = component( 29 | name, 30 | this.componentApi, 31 | this.script, 32 | this.style 33 | ) 34 | const indexed = this.pathToFile(name) 35 | const path = join( 36 | process.cwd(), 37 | this.src, 38 | this.componentDir, 39 | this.atomic ? `${type}/${indexed}` : indexed 40 | ) 41 | const rewriteOrCreate = await this.rewriteModule(path, indexed) 42 | if (rewriteOrCreate) { 43 | const _dirname = dirname(path) 44 | const dirExists = await this.dirExists(_dirname) 45 | if (!dirExists) { 46 | await mkdir(_dirname, { recursive: true }) 47 | } 48 | await writeFile(path, boilerplate, { encoding: 'utf8' }) 49 | console.log( 50 | `The component ${ 51 | this.atomic ? this.chalk.green(`${type}/`) : '' 52 | }${this.chalk.green(indexed)} has successfully generated!` 53 | ) 54 | } else { 55 | return 56 | } 57 | } catch (e) { 58 | console.error( 59 | `Something went wrong while generation of the ${this.chalk.redBright( 60 | name 61 | )} component`, 62 | e 63 | ) 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/modules/config/index.ts: -------------------------------------------------------------------------------- 1 | import { writeFile, readFile } from 'fs/promises' 2 | import { join } from 'path' 3 | import Chalk from 'chalk' 4 | import inquirer from 'inquirer' 5 | import { IConfig, scriptLang } from 'types/config' 6 | import { ISettings } from 'types/settings' 7 | 8 | export default class Config { 9 | constructor( 10 | private inquirer: inquirer.Inquirer, 11 | private chalk: typeof Chalk, 12 | private config: ISettings 13 | ) {} 14 | 15 | private promtQuestions() { 16 | return { 17 | src: { 18 | type: 'input', 19 | name: 'src', 20 | message: 'The root directory of your project?', 21 | default: () => this.config.config.src, 22 | }, 23 | componentsDir: (src: string) => ({ 24 | type: 'input', 25 | name: 'componentsDir', 26 | message: `The root directory of the components: ${src}`, 27 | default: () => this.config.config.dir.components, 28 | }), 29 | pagesDir: (src: string) => ({ 30 | type: 'input', 31 | name: 'pagesDir', 32 | message: `The root directory of the pages: ${src}`, 33 | default: () => this.config.config.dir.pages, 34 | }), 35 | scriptLang: { 36 | type: 'list', 37 | name: 'scriptLang', 38 | message: 'The language of scripts?', 39 | choices: [ 40 | { 41 | name: 'JavaScript', 42 | value: 'js', 43 | }, 44 | { 45 | name: 'TypeScript', 46 | value: 'ts', 47 | }, 48 | ], 49 | default: () => this.config.config.components.scriptLang, 50 | }, 51 | componentApi: (lang: scriptLang) => ({ 52 | type: 'list', 53 | name: 'componentApi', 54 | message: 'Choose script configuration:', 55 | choices: [ 56 | { 57 | name: 'Options API', 58 | value: 'optionsApi', 59 | }, 60 | { 61 | name: 'Composition API', 62 | value: 'compositionApi', 63 | }, 64 | { 65 | name: 'Class component', 66 | value: 'class', 67 | [lang === 'js' && 'disabled']: 'Unavailable on JS', 68 | }, 69 | ], 70 | default: () => this.config.config.components.componentApi, 71 | }), 72 | styleLang: { 73 | type: 'list', 74 | name: 'styleLang', 75 | message: 'CSS preprocessor?', 76 | choices: [ 77 | { 78 | name: 'CSS', 79 | value: 'css', 80 | }, 81 | { 82 | name: 'SCSS', 83 | value: 'scss', 84 | }, 85 | { 86 | name: 'SASS', 87 | value: 'sass', 88 | }, 89 | { 90 | name: 'LESS', 91 | value: 'less', 92 | }, 93 | ], 94 | default: () => this.config.config.components.styleLang, 95 | }, 96 | useIndex: { 97 | type: 'confirm', 98 | name: 'useIndex', 99 | message: 'Use Component/index.vue format?', 100 | default: () => this.config.config.components.useIndex, 101 | }, 102 | atomicDesign: { 103 | type: 'confirm', 104 | name: 'atomicDesign', 105 | message: 'Use atomic design file structure?', 106 | default: () => this.config.config.components.atomicDesign, 107 | }, 108 | } 109 | } 110 | 111 | private async generateDefaultConfig(content: string) { 112 | try { 113 | await writeFile(join(process.cwd(), '.vgentrc'), content, { 114 | encoding: 'utf8', 115 | }) 116 | console.log( 117 | `${this.chalk.green('.vgentrc')} configuration file has been generated` 118 | ) 119 | console.log(`Now you can generate your components`) 120 | } catch (e) { 121 | console.error( 122 | `Something went wrong while generating configuration file`, 123 | e 124 | ) 125 | } 126 | } 127 | 128 | private async setSrc() { 129 | const { src } = await this.inquirer.prompt([this.promtQuestions().src]) 130 | this.config.setSrc(src) 131 | 132 | const { componentsDir } = await this.inquirer.prompt([ 133 | this.promtQuestions().componentsDir(src), 134 | ]) 135 | const { pagesDir } = await this.inquirer.prompt([ 136 | this.promtQuestions().pagesDir(src), 137 | ]) 138 | this.config.setDir({ pages: pagesDir, components: componentsDir }) 139 | } 140 | 141 | private async setComponents() { 142 | const answers = {} as IConfig['components'] 143 | const { scriptLang } = await this.inquirer.prompt([ 144 | this.promtQuestions().scriptLang, 145 | ]) 146 | answers.scriptLang = scriptLang 147 | 148 | const { componentApi } = await this.inquirer.prompt([ 149 | this.promtQuestions().componentApi(scriptLang), 150 | ]) 151 | answers.componentApi = componentApi 152 | 153 | // if (answers.scriptLang === 'ts') { 154 | // const { optionsApi } = await this.inquirer.prompt([ 155 | // this.promtQuestions().optionsApi, 156 | // ]) 157 | // answers.optionsApi = optionsApi 158 | // } 159 | 160 | const { styleLang } = await this.inquirer.prompt([ 161 | this.promtQuestions().styleLang, 162 | ]) 163 | answers.styleLang = styleLang 164 | 165 | const { useIndex } = await this.inquirer.prompt([ 166 | this.promtQuestions().useIndex, 167 | ]) 168 | answers.useIndex = useIndex || false 169 | this.config.setPages({ useIndex }) 170 | 171 | const { atomicDesign } = await this.inquirer.prompt([ 172 | this.promtQuestions().atomicDesign, 173 | ]) 174 | answers.atomicDesign = atomicDesign || false 175 | 176 | this.config.setComponents(answers) 177 | } 178 | 179 | private getContent() { 180 | const { ...object } = this.config 181 | return JSON.stringify(object.config as IConfig, null, 2) 182 | } 183 | 184 | private async checkConfig() { 185 | try { 186 | const config = await readFile(join(process.cwd(), '.nxrc'), { 187 | encoding: 'utf8', 188 | }) 189 | if (config) { 190 | const { rewrite } = await this.inquirer.prompt([ 191 | { 192 | type: 'confirm', 193 | name: 'rewrite', 194 | message: 195 | 'There is .nxrc configuration file. Do you want to rewrite it?', 196 | }, 197 | ]) 198 | 199 | return rewrite || false 200 | } 201 | } catch (e) { 202 | if (e.code === 'ENOENT') { 203 | return true 204 | } 205 | } 206 | } 207 | 208 | async quickstart() { 209 | const allowance = await this.checkConfig() 210 | if (!allowance) return 211 | this.generateDefaultConfig(this.getContent()) 212 | } 213 | 214 | async promtUser() { 215 | const allowance = await this.checkConfig() 216 | if (!allowance) return 217 | await this.setSrc() 218 | await this.setComponents() 219 | 220 | this.generateDefaultConfig(this.getContent()) 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /src/modules/core/index.ts: -------------------------------------------------------------------------------- 1 | import { access } from 'fs/promises' 2 | import inquirer from 'inquirer' 3 | import { IConfig } from 'types/config' 4 | import { componentType, pageType } from 'types/generator' 5 | import { ISettings } from 'types/settings' 6 | 7 | export default abstract class Core { 8 | static isNuxtProject = false 9 | protected src: IConfig['src'] 10 | protected componentDir: IConfig['dir']['components'] 11 | protected pageDir: IConfig['dir']['pages'] 12 | protected script: IConfig['components']['scriptLang'] 13 | protected componentApi: IConfig['components']['componentApi'] 14 | protected style: IConfig['components']['styleLang'] 15 | protected componentIndex: IConfig['components']['useIndex'] 16 | protected pageIndex: IConfig['pages']['useIndex'] 17 | protected atomic: IConfig['components']['atomicDesign'] 18 | constructor( 19 | protected readonly settings: ISettings, 20 | protected inquirer: inquirer.Inquirer 21 | ) {} 22 | 23 | protected prepare() { 24 | this.src = this.settings.config.src 25 | this.componentDir = this.settings.config.dir.components 26 | this.pageDir = this.settings.config.dir.pages 27 | this.script = this.settings.config.components.scriptLang 28 | this.componentApi = this.settings.config.components.componentApi 29 | this.style = this.settings.config.components.styleLang 30 | this.componentIndex = this.settings.config.components.useIndex 31 | this.pageIndex = this.settings.config.pages.useIndex 32 | this.atomic = this.settings.config.components.atomicDesign 33 | } 34 | 35 | abstract pathToFile(name: string, type: pageType | componentType): string 36 | 37 | protected capitalize(str: string) { 38 | return str.charAt(0).toUpperCase() + str.slice(1) 39 | } 40 | 41 | protected async dirExists(path: string) { 42 | try { 43 | await access(path) 44 | return true 45 | } catch { 46 | return false 47 | } 48 | } 49 | 50 | protected async rewriteModule(path: string, name: string) { 51 | const exists = await this.dirExists(path) 52 | if (exists) { 53 | const { rewrite } = await inquirer.prompt({ 54 | type: 'confirm', 55 | name: 'rewrite', 56 | message: `File ${name} is exist. Do you want to rewrite file?`, 57 | }) 58 | return rewrite 59 | } 60 | return true 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/modules/pages/index.ts: -------------------------------------------------------------------------------- 1 | import { dirname, join } from 'path' 2 | import { mkdir, writeFile } from 'fs/promises' 3 | import Chalk from 'chalk' 4 | import Core from 'modules/core/index.js' 5 | import { component } from 'modules/templates/component.js' 6 | import { IGenerator, pageType } from 'types/generator' 7 | import { ISettings } from 'types/settings' 8 | import inquirer from 'inquirer' 9 | 10 | export default class Pages extends Core implements IGenerator { 11 | constructor( 12 | private chalk: typeof Chalk, 13 | settings: ISettings, 14 | inquirer: inquirer.Inquirer 15 | ) { 16 | super(settings, inquirer) 17 | } 18 | 19 | pathToFile(name: string, type: pageType) { 20 | return this.pageIndex 21 | ? `${name}/${type !== 'index' ? `_${type}` : 'index'}.vue` 22 | : type === 'index' 23 | ? `${name}.vue` 24 | : `_${name}${this.capitalize(type)}.vue` 25 | } 26 | 27 | async generate(name: string, type?: pageType) { 28 | try { 29 | this.prepare() 30 | const boilerplate = component( 31 | type !== 'index' 32 | ? `${this.capitalize(name)}${this.capitalize(type)}` 33 | : this.capitalize(name), 34 | this.componentApi, 35 | this.script, 36 | this.style 37 | ) 38 | const indexed = this.pathToFile(name, type) 39 | const path = join(process.cwd(), this.src, this.pageDir, indexed) 40 | const rewriteOrCreate = await this.rewriteModule(path, indexed) 41 | if (rewriteOrCreate) { 42 | const _dirname = dirname(path) 43 | const exists = await this.dirExists(_dirname) 44 | if (!exists) { 45 | await mkdir(_dirname, { recursive: true }) 46 | } 47 | await writeFile(path, boilerplate, { encoding: 'utf8' }) 48 | console.log( 49 | `The page ${this.chalk.green(indexed)} has successfully generated!` 50 | ) 51 | } else { 52 | return 53 | } 54 | } catch (e) { 55 | console.error( 56 | `Something went wrong while generation of the ${this.chalk.redBright( 57 | name 58 | )} page`, 59 | e 60 | ) 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/modules/settings/index.ts: -------------------------------------------------------------------------------- 1 | import { resolve, join } from 'path' 2 | import { readFile } from 'fs/promises' 3 | import { IConfig } from 'types/config' 4 | import { ISettings } from 'types/settings' 5 | 6 | export default class Settings implements ISettings { 7 | config: IConfig = { 8 | src: './', 9 | dir: { 10 | components: resolve(process.cwd(), '/components'), 11 | layout: resolve(process.cwd(), '/layout'), 12 | pages: resolve(process.cwd(), '/pages'), 13 | store: resolve(process.cwd(), '/store'), 14 | }, 15 | components: { 16 | atomicDesign: false, 17 | styleLang: 'scss', 18 | scriptLang: 'js', 19 | componentApi: 'optionsApi', 20 | detached: false, 21 | useIndex: true, 22 | }, 23 | pages: { 24 | useIndex: true, 25 | }, 26 | } 27 | 28 | setSrc(src: IConfig['src']) { 29 | this.config.src = src 30 | } 31 | 32 | setDir(dir: IConfig['dir']) { 33 | this.config.dir = { ...this.config.dir, ...dir } 34 | } 35 | 36 | setComponents(components: IConfig['components']) { 37 | this.config.components = { ...this.config.components, ...components } 38 | } 39 | 40 | setPages(pages: IConfig['pages']) { 41 | this.config.pages = { ...this.config.pages, ...pages } 42 | } 43 | 44 | async readLocalConfig() { 45 | try { 46 | const file = await readFile(join(process.cwd(), '/.vgentrc'), { 47 | encoding: 'utf8', 48 | }) 49 | const config = JSON.parse(file) 50 | this.setSrc(config.src) 51 | this.setDir(config.dir) 52 | this.setComponents(config.components) 53 | this.setPages(config.pages) 54 | } catch (e) { 55 | console.error(e) 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/modules/status/index.ts: -------------------------------------------------------------------------------- 1 | import { readFile } from 'fs/promises' 2 | import Chalk from 'chalk' 3 | import { IStatus } from 'types/status' 4 | import { IConfig } from 'types/config' 5 | import { IAlerts } from 'types/alerts' 6 | 7 | export default class Status implements IStatus { 8 | private _isNuxtApp = false 9 | private _isVueApp = false 10 | 11 | constructor(private chalk: typeof Chalk, private alerts: IAlerts) {} 12 | 13 | get isNuxtApp(): boolean { 14 | return this._isNuxtApp 15 | } 16 | 17 | set isNuxtApp(status: boolean) { 18 | this._isNuxtApp = status 19 | } 20 | 21 | get isVueApp(): boolean { 22 | return this._isVueApp 23 | } 24 | 25 | set isVueApp(status: boolean) { 26 | this._isVueApp = status 27 | } 28 | 29 | async checkNuxtOrVue(): Promise { 30 | try { 31 | const packageJsonText = await readFile(process.cwd() + '/package.json', { 32 | encoding: 'utf8', 33 | }) 34 | const packageJson = JSON.parse(packageJsonText) 35 | if ( 36 | packageJson && 37 | packageJson.dependencies && 38 | packageJson.dependencies.nuxt 39 | ) { 40 | console.log(this.chalk.green(`nuxt ${packageJson.dependencies.nuxt}`)) 41 | this._isNuxtApp = true 42 | } else if ( 43 | packageJson && 44 | packageJson.dependencies && 45 | packageJson.dependencies.vue 46 | ) { 47 | console.log(this.chalk.green(`vue ${packageJson.dependencies.vue}`)) 48 | this._isVueApp = true 49 | } else { 50 | this.alerts.cantFindNuxtOrVue() 51 | this._isNuxtApp = false 52 | this._isVueApp = false 53 | } 54 | } catch (e) { 55 | if (e.code === 'ENOENT') { 56 | this.alerts.cantFindNuxtOrVue() 57 | } 58 | } 59 | } 60 | 61 | async checkConfig(): Promise { 62 | try { 63 | const file = await readFile(process.cwd() + '/.vgentrc', { 64 | encoding: 'utf8', 65 | }) 66 | const projectConfig: IConfig = JSON.parse(file) 67 | if (projectConfig) { 68 | return projectConfig 69 | } else { 70 | this.alerts.invalidProjectConfig() 71 | } 72 | } catch (e) { 73 | if (e.code === 'ENOENT') { 74 | this.alerts.cantFindProjectConfig() 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/modules/templates/component.ts: -------------------------------------------------------------------------------- 1 | import { scriptLang, styleLang, componentApi } from 'types/config' 2 | 3 | export const template = `` 4 | 5 | export const scriptOptionsApi = ( 6 | lang: scriptLang, 7 | name: string 8 | ) => `` 21 | 22 | export const scriptClass = ( 23 | lang: scriptLang, 24 | name: string 25 | ) => `` 31 | 32 | export const scriptCompositionApi = (lang: scriptLang) => 33 | `` 34 | 35 | export const style = (lang: styleLang) => 36 | `` 37 | 38 | export const script = { 39 | compositionApi: (lang: scriptLang, _name: string) => 40 | scriptCompositionApi(lang), 41 | optionsApi: (lang: scriptLang, name: string) => scriptOptionsApi(lang, name), 42 | class: (lang: scriptLang, name: string) => scriptClass(lang, name), 43 | } 44 | 45 | export const component = ( 46 | name: string, 47 | componentApi: componentApi, 48 | scriptLang: scriptLang, 49 | styleLang: styleLang 50 | ) => `${template} 51 | 52 | ${script[componentApi](scriptLang, name)} 53 | 54 | ${style(styleLang)} 55 | ` 56 | -------------------------------------------------------------------------------- /src/services/commands.ts: -------------------------------------------------------------------------------- 1 | import Config from 'modules/config' 2 | import { ICommands } from 'types/commands' 3 | import { IStatus } from 'types/status' 4 | import { componentType, IGenerator, pageType } from 'types/generator' 5 | import { ISettings } from 'types/settings' 6 | import { IAlerts } from 'types/alerts' 7 | 8 | export default class Commands implements ICommands { 9 | constructor( 10 | private status: IStatus, 11 | private settings: ISettings, 12 | private generateComponents: IGenerator, 13 | private generatePages: IGenerator, 14 | private configGenerator: Config, 15 | private alerts: IAlerts 16 | ) {} 17 | async health(init?: boolean) { 18 | await this.status.checkNuxtOrVue() 19 | if ((this.status.isNuxtApp || this.status.isVueApp) && !init) { 20 | await this.status.checkConfig() 21 | } 22 | } 23 | async components(name: string, type?: componentType) { 24 | await this.health() 25 | await this.settings.readLocalConfig() 26 | await this.generateComponents.generate(name, type) 27 | } 28 | async pages(name: string, type?: pageType) { 29 | await this.health() 30 | await this.settings.readLocalConfig() 31 | await this.generatePages.generate(name, type) 32 | } 33 | async init(quickstart?: boolean) { 34 | await this.health(true) 35 | if (quickstart) { 36 | this.configGenerator.quickstart() 37 | } else { 38 | await this.configGenerator.promtUser() 39 | } 40 | } 41 | async placeholder() { 42 | await this.health() 43 | 44 | if (this.status.isNuxtApp || this.status.isVueApp) { 45 | this.alerts.initInstruction() 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/services/options.ts: -------------------------------------------------------------------------------- 1 | import { IOption } from 'types/options.js' 2 | 3 | export const options: IOption = { 4 | q: { 5 | alias: 'quickstart', 6 | describe: 'Generate config file with default configuration', 7 | type: 'boolean', 8 | demandOption: false, 9 | }, 10 | c: { 11 | alias: 'component', 12 | describe: 'Generate component', 13 | type: 'string', 14 | demandOption: false, 15 | }, 16 | a: { 17 | alias: 'atoms', 18 | describe: 19 | 'Generate an atom component. Used when Atomic Design option is enabled', 20 | type: 'boolean', 21 | demandOption: false, 22 | }, 23 | m: { 24 | alias: 'molecules', 25 | describe: 26 | 'Generate a molecules component. Used when Atomic Design option is enabled', 27 | type: 'boolean', 28 | demandOption: false, 29 | }, 30 | o: { 31 | alias: 'organisms', 32 | describe: 33 | 'Generate an organism component. Used when Atomic Design option is enabled', 34 | type: 'boolean', 35 | demandOption: false, 36 | }, 37 | t: { 38 | alias: 'templates', 39 | describe: 40 | 'Generate a templates component. Used when Atomic Design option is enabled', 41 | type: 'boolean', 42 | demandOption: false, 43 | }, 44 | p: { 45 | alias: 'page', 46 | describe: 'Generate page component', 47 | type: 'string', 48 | demandOption: false, 49 | }, 50 | slug: { 51 | describe: 'Slug type of the page', 52 | type: 'boolean', 53 | demandOption: false, 54 | }, 55 | id: { 56 | describe: 'ID type of the page', 57 | type: 'boolean', 58 | demandOption: false, 59 | }, 60 | s: { 61 | alias: 'store', 62 | describe: 'Generate store module', 63 | type: 'boolean', 64 | demandOption: false, 65 | }, 66 | } 67 | -------------------------------------------------------------------------------- /src/services/shell.ts: -------------------------------------------------------------------------------- 1 | import Chalk from 'chalk' 2 | import Yargs from 'yargs' 3 | import { ICommands } from 'types/commands' 4 | import { options } from './options.js' 5 | import { IShell } from 'types/shell' 6 | import { componentType, pageType } from 'types/generator.js' 7 | 8 | export default class Shell implements IShell { 9 | constructor( 10 | private yargs: typeof Yargs, 11 | private chalk: typeof Chalk, 12 | private commands: ICommands 13 | ) {} 14 | 15 | bootstrap() { 16 | this.yargs(process.argv.slice(2)) 17 | .usage( 18 | `Info: ${this.chalk.green( 19 | 'vgent' 20 | )} is boilerplate file generator for Nuxt.js and Vue.js` 21 | ) 22 | .command('$0', '', {}, async () => { 23 | await this.commands.placeholder() 24 | }) 25 | .command( 26 | 'health', 27 | 'Check project', 28 | () => {}, 29 | async () => { 30 | await this.commands.health() 31 | } 32 | ) 33 | .command( 34 | 'make', 35 | 'Used for some generations', 36 | () => {}, 37 | async (options) => { 38 | if (!options.c && !options.p) { 39 | await this.commands.placeholder() 40 | } 41 | if (options.c) { 42 | const name = options.c as string 43 | const type = ((options.a && 'atoms') || 44 | (options.m && 'molecules') || 45 | (options.o && 'organisms') || 46 | (options.t && 'templates') || 47 | 'atoms') as componentType 48 | await this.commands.components(name, type) 49 | } 50 | if (options.p) { 51 | const name = options.p as string 52 | const type = ((options.slug && 'slug') || 53 | (options.id && 'id') || 54 | 'index') as pageType 55 | await this.commands.pages(name, type) 56 | } 57 | } 58 | ) 59 | .command( 60 | 'init', 61 | `Initialize ${this.chalk.green('vgent')} in the project`, 62 | () => {}, 63 | async (options) => { 64 | await this.commands.init(options.q as boolean) 65 | } 66 | ) 67 | .option('q', options['q']) 68 | .option('c', options['c']) 69 | .option('a', options['a']) 70 | .option('m', options['m']) 71 | .option('o', options['o']) 72 | .option('t', options['t']) 73 | .option('p', options['p']) 74 | .option('slug', options['slug']) 75 | .option('id', options['id']) 76 | .option('s', options['s']) 77 | .help(true).argv 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/types/alerts.ts: -------------------------------------------------------------------------------- 1 | export interface IAlerts { 2 | cantFindNuxtOrVue(): void 3 | cantFindProjectConfig(): void 4 | invalidProjectConfig(): void 5 | initInstruction(): void 6 | } 7 | -------------------------------------------------------------------------------- /src/types/commands.ts: -------------------------------------------------------------------------------- 1 | import { componentType, pageType } from './generator' 2 | 3 | export interface ICommands { 4 | health(init?: boolean): void 5 | components(name: string, type?: componentType): void 6 | pages(name: string, type?: pageType): void 7 | init(quickstart?: boolean): Promise 8 | placeholder(): Promise 9 | } 10 | -------------------------------------------------------------------------------- /src/types/config.ts: -------------------------------------------------------------------------------- 1 | export type scriptLang = 'js' | 'ts' 2 | export type styleLang = 'css' | 'scss' | 'sass' | 'less' 3 | export type componentApi = 'optionsApi' | 'compositionApi' | 'class' 4 | 5 | export interface IDirOption { 6 | components?: string 7 | layout?: string 8 | pages?: string 9 | store?: string 10 | } 11 | 12 | export interface IComponentsOption { 13 | /** to make atomic design folder structure */ 14 | atomicDesign?: boolean 15 | styleLang?: styleLang 16 | scriptLang?: scriptLang 17 | /** to use options API in components */ 18 | componentApi?: componentApi 19 | /** to detach template, script, styles to separate files */ 20 | detached?: boolean 21 | /** to use index files as component */ 22 | useIndex?: boolean 23 | } 24 | 25 | export interface IPagesOption { 26 | useIndex?: boolean 27 | } 28 | 29 | export interface IConfig { 30 | src?: string 31 | dir?: IDirOption 32 | components?: IComponentsOption 33 | pages?: IPagesOption 34 | } 35 | -------------------------------------------------------------------------------- /src/types/generator.ts: -------------------------------------------------------------------------------- 1 | export type componentType = 'atoms' | 'molecules' | 'organisms' | 'templates' 2 | export type pageType = 'index' | 'slug' | 'id' 3 | export interface IGenerator { 4 | generate(name: string, type?: componentType | pageType): Promise 5 | } 6 | -------------------------------------------------------------------------------- /src/types/options.ts: -------------------------------------------------------------------------------- 1 | import { Options } from 'yargs' 2 | 3 | export interface IOptionDetails extends Options {} 4 | 5 | export interface IOption { 6 | [key: string]: IOptionDetails 7 | } 8 | -------------------------------------------------------------------------------- /src/types/settings.ts: -------------------------------------------------------------------------------- 1 | import { IConfig } from 'types/config' 2 | 3 | export interface ISettings { 4 | config: IConfig 5 | setSrc(src: IConfig['src']): void 6 | setDir(dir: IConfig['dir']): void 7 | setComponents(components: IConfig['components']): void 8 | setPages(pages: IConfig['pages']): void 9 | readLocalConfig(): Promise 10 | } 11 | -------------------------------------------------------------------------------- /src/types/shell.ts: -------------------------------------------------------------------------------- 1 | export interface IShell { 2 | bootstrap(): void 3 | } 4 | -------------------------------------------------------------------------------- /src/types/status.ts: -------------------------------------------------------------------------------- 1 | import { IConfig } from 'types/config' 2 | 3 | export interface IStatus { 4 | isNuxtApp: boolean 5 | isVueApp: boolean 6 | checkNuxtOrVue(): Promise 7 | checkConfig(): Promise 8 | } 9 | -------------------------------------------------------------------------------- /src/utils/alerts.ts: -------------------------------------------------------------------------------- 1 | import Chalk from 'chalk' 2 | import { IAlerts } from 'types/alerts' 3 | 4 | export default class Alerts implements IAlerts { 5 | constructor(private chalk: typeof Chalk) {} 6 | 7 | cantFindNuxtOrVue() { 8 | console.error( 9 | `Can't find ${this.chalk.green('nuxt')} nor ${this.chalk.green( 10 | 'vue' 11 | )} dependencies. Is this project on ${this.chalk.green( 12 | 'Nuxt.js' 13 | )} or ${this.chalk.green('Vue.js')}?` 14 | ) 15 | } 16 | 17 | cantFindProjectConfig() { 18 | console.error( 19 | `Can't find ${this.chalk.green( 20 | '.vgentrc' 21 | )} configuration file.\nRun ${this.chalk.green( 22 | 'vgent init' 23 | )} and provide some configurations.\n` 24 | ) 25 | } 26 | 27 | invalidProjectConfig() { 28 | console.error( 29 | `${this.chalk.red('Invalid config')}: seems ${this.chalk.green( 30 | '.vgentrc' 31 | )} file has invalid options` 32 | ) 33 | } 34 | 35 | initInstruction() { 36 | console.log( 37 | `To generate a component run: ${this.chalk.greenBright( 38 | 'vgent make -c ' 39 | )}`, 40 | `\nTo generate a page run: ${this.chalk.greenBright( 41 | 'vgent make -p ' 42 | )}` 43 | ) 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ESNext", 4 | "esModuleInterop": true, 5 | "allowSyntheticDefaultImports": true, 6 | "target": "es2019", 7 | "noImplicitAny": true, 8 | "moduleResolution": "node", 9 | "sourceMap": true, 10 | "allowJs": true, 11 | "outDir": "./dist", 12 | "baseUrl": ".", 13 | "paths": { 14 | "types/*": ["./src/types/*"], 15 | "context/*": ["./src/context/*"], 16 | "modules/*": ["./src/modules/*"], 17 | "services/*": ["./src/services/*"], 18 | "utils/*": ["./src/utils/*"] 19 | }, 20 | "plugins": [ 21 | { 22 | "transform": "typescript-transform-paths", 23 | "afterDeclarations": true 24 | } 25 | ], 26 | "types": ["@types/node", "@types/yargs"], 27 | "typeRoots": ["./src/types/*"] 28 | }, 29 | "exclude": ["node_modules", "./dist/**/*"] 30 | } 31 | --------------------------------------------------------------------------------