├── .circleci └── config.yml ├── .eslintrc.js ├── .gitignore ├── .gitkeep ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── babel.config.js ├── banner.jpg ├── dist └── src │ ├── config.d.ts │ ├── config.js │ ├── config.js.map │ ├── converter.d.ts │ ├── converter.js │ ├── converter.js.map │ ├── generators │ ├── api.d.ts │ ├── api.js │ ├── api.js.map │ ├── component.d.ts │ ├── component.js │ ├── component.js.map │ ├── crud.d.ts │ ├── crud.js │ ├── crud.js.map │ ├── error.d.ts │ ├── error.js │ ├── error.js.map │ ├── inject.d.ts │ ├── inject.js │ ├── inject.js.map │ ├── layout.d.ts │ ├── layout.js │ ├── layout.js.map │ ├── loading.d.ts │ ├── loading.js │ ├── loading.js.map │ ├── new.d.ts │ ├── new.js │ ├── new.js.map │ ├── page.d.ts │ ├── page.js │ ├── page.js.map │ ├── prisma.d.ts │ ├── prisma.js │ ├── prisma.js.map │ ├── scss.d.ts │ ├── scss.js │ ├── scss.js.map │ ├── slice.d.ts │ ├── slice.js │ ├── slice.js.map │ ├── superagent.d.ts │ ├── superagent.js │ ├── superagent.js.map │ ├── type.d.ts │ ├── type.js │ └── type.js.map │ ├── helpers │ ├── log.d.ts │ ├── log.js │ ├── log.js.map │ ├── match.d.ts │ ├── match.js │ ├── match.js.map │ ├── nomenclature.d.ts │ ├── nomenclature.js │ └── nomenclature.js.map │ ├── printer.d.ts │ ├── printer.js │ ├── printer.js.map │ └── templates │ ├── api.template │ ├── component │ ├── component.nostyle.template │ ├── component.template │ ├── index.nostyle.template │ ├── index.template │ ├── style.template │ └── test.template │ ├── crud.template │ ├── error.template │ ├── layout.template │ ├── loading.template │ ├── new │ ├── .env.dev.local.template │ ├── .eslintrc.js.template │ ├── .gitignore.template │ ├── README.md.template │ ├── _app.template │ ├── _document.template │ ├── app │ │ ├── layout.tsx.template │ │ └── page.tsx.template │ ├── babelrc.template │ ├── components │ │ └── counter.tsx.template │ ├── env.dev.template │ ├── eslintrc.template │ ├── gitignore.template │ ├── index.template │ ├── middleware.tsx.template │ ├── next.config.js.template │ ├── package.json.template │ ├── package.template │ ├── precommit.template │ ├── printer.config.json.template │ ├── printer.config.template │ ├── printer.template │ ├── prisma.client.template │ ├── prisma │ │ ├── client.ts.template │ │ └── schema.prisma.template │ ├── readme.template │ ├── reducer.template │ ├── redux │ │ ├── hooks.tsx.template │ │ ├── provider.tsx.template │ │ ├── reducer.tsx.template │ │ ├── reducers.json.template │ │ ├── slice │ │ │ └── counter.tsx.template │ │ └── store.tsx.template │ ├── reset.template │ ├── schema.prisma.template │ ├── scss │ │ ├── index.scss.template │ │ ├── printer.scss.template │ │ ├── reset.scss.template │ │ ├── theme.scss.template │ │ └── ui.scss.template │ ├── session.template │ ├── theme.template │ ├── tsconfig.json.template │ ├── tsconfig.template │ ├── types │ │ └── counter.tsx.template │ ├── ui.template │ ├── util │ │ └── session.ts.template │ └── wrapper.template │ ├── page.template │ ├── page.url.template │ ├── scss.template │ ├── slice │ ├── reducer.template │ ├── slice.d.ts │ ├── slice.js │ ├── slice.js.map │ ├── slice.template │ └── slice.ts │ ├── superagent.template │ └── type.template ├── jest.config.ts ├── package.json ├── prepend.ts ├── src ├── config.ts ├── converter.ts ├── generators │ ├── api.ts │ ├── component.ts │ ├── crud.ts │ ├── error.ts │ ├── inject.ts │ ├── layout.ts │ ├── loading.ts │ ├── new.ts │ ├── page.ts │ ├── prisma.ts │ ├── scss.ts │ ├── slice.ts │ ├── superagent.ts │ └── type.ts ├── helpers │ ├── log.ts │ ├── match.ts │ └── nomenclature.ts ├── printer.ts └── templates │ ├── api.template │ ├── component │ ├── component.nostyle.template │ ├── component.template │ ├── index.nostyle.template │ ├── index.template │ ├── style.template │ └── test.template │ ├── crud.template │ ├── error.template │ ├── layout.template │ ├── loading.template │ ├── new │ ├── .env.dev.local.template │ ├── .eslintrc.js.template │ ├── .gitignore.template │ ├── README.md.template │ ├── app │ │ ├── layout.tsx.template │ │ └── page.tsx.template │ ├── components │ │ └── counter.tsx.template │ ├── middleware.tsx.template │ ├── next.config.js.template │ ├── package.json.template │ ├── printer.config.json.template │ ├── prisma │ │ ├── client.ts.template │ │ └── schema.prisma.template │ ├── redux │ │ ├── provider.tsx.template │ │ ├── reducer.tsx.template │ │ ├── reducers.json.template │ │ ├── slice │ │ │ └── counter.tsx.template │ │ └── store.tsx.template │ ├── scss │ │ ├── index.scss.template │ │ ├── printer.scss.template │ │ ├── reset.scss.template │ │ ├── theme.scss.template │ │ └── ui.scss.template │ ├── tsconfig.json.template │ ├── types │ │ └── counter.tsx.template │ └── util │ │ └── session.ts.template │ ├── page.template │ ├── page.url.template │ ├── scss.template │ ├── slice │ ├── reducer.template │ ├── slice.template │ └── slice.ts │ ├── superagent.template │ └── type.template ├── test ├── .gitkeep └── printer.test.ts ├── tsconfig.json └── yarn.lock /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | node: circleci/node@4.7 5 | 6 | workflows: 7 | basic: 8 | jobs: 9 | - node/test: 10 | version: "18.17.1" 11 | pkg-manager: yarn 12 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: false, 4 | es2021: true 5 | }, 6 | extends: [ 7 | 'standard' 8 | ], 9 | parser: '@typescript-eslint/parser', 10 | parserOptions: { 11 | ecmaVersion: 'latest', 12 | sourceType: 'module' 13 | }, 14 | plugins: [ 15 | '@typescript-eslint' 16 | ], 17 | rules: { 18 | 'no-tabs': 0, 19 | 'prefer-regex-literals': 0 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-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 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Gatsby files 91 | .cache/ 92 | # Comment in the public line in if your project uses Gatsby and not Next.js 93 | # https://nextjs.org/blog/next-9-1#public-directory-support 94 | # public 95 | 96 | # vuepress build output 97 | .vuepress/dist 98 | 99 | # vuepress v2.x temp and cache directory 100 | .temp 101 | .cache 102 | 103 | # Serverless directories 104 | .serverless/ 105 | 106 | # FuseBox cache 107 | .fusebox/ 108 | 109 | # DynamoDB Local files 110 | .dynamodb/ 111 | 112 | # TernJS port file 113 | .tern-port 114 | 115 | # Stores VSCode versions used for testing VSCode extensions 116 | .vscode-test 117 | 118 | # yarn v2 119 | .yarn/cache 120 | .yarn/unplugged 121 | .yarn/build-state.yml 122 | .yarn/install-state.gz 123 | .pnp.* 124 | 125 | # Print 126 | dist/test 127 | home -------------------------------------------------------------------------------- /.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrinterFramework/CLI/58a0938f1765a8fb0f412020787bd2f021ae9b67/.gitkeep -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .circleci 2 | .husky 3 | example 4 | test 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 🛠️ CHANGELOG 2 | 3 | ## 2.2.5(-1) 4 | 5 | - Updated package.json to Next 14 6 | 7 | - Switched to static semantic versioning in package.json 8 | 9 | - Updated to iron-session 8.0.1 10 | 11 | - Improved and cleaned up api macro 12 | 13 | - Updated middleware.tsx session provider 14 | 15 | ## 2.2.4 16 | 17 | - Fix default `layout.tsx` suspense boundary. 18 | 19 | - Update default counter slice to reset properly. 20 | 21 | ## 2.2.3 22 | 23 | - Make sure to add `eslint-plugin-n` to `package.json` 24 | 25 | - Remove `redux/hooks.tsx` since it's now deprecated in the 13.5.3 to Printer. 26 | 27 | ## 2.2.2 28 | 29 | - Updated `app/layout.tsx` to use suspense boundaries. 30 | 31 | - `printer layout` now uses a suspense boundary. 32 | 33 | - `printer loading` now uses a suspense boundary. 34 | 35 | ## 2.2.1 36 | 37 | - In `printer new`, forgot to add `components/counter.tsx` to build list. 38 | 39 | - Make sure example redux slice `reset()` works as intended with 13.5.3. 40 | 41 | ## 2.2.0 42 | 43 | - Relationships fixed for prisma 44 | 45 | - Deprecate experimental decorations 46 | 47 | - Update `package.json` versioning 48 | 49 | - Fix prisma client management in development 50 | 51 | - Fix redux bug with Next.js 13.5.3 52 | 53 | ## 2.1.2 54 | 55 | - Fix `prisma` import definitions to cover all types 56 | 57 | ## 2.1.1 58 | 59 | - Fix for `prisma` circular import definitions 60 | 61 | ## 2.1.0 62 | 63 | - Updated how metadata is handled 64 | 65 | - Added 3 new commands 66 | 67 | ```bash 68 | printer layout [path] 69 | printer loading [path] 70 | printer error [path] 71 | ``` 72 | 73 | These commands behave similar to the `page` command. But instead generate layout, loading and error components for pages. 74 | 75 | ## v2.0.2 76 | 77 | - Ensure API routes have `application/json` header 78 | 79 | - Fix `printer prisma` `?` error 80 | 81 | ## v2.0.1 82 | 83 | - Fix injectable formatting issues 84 | 85 | ## v2.0.0 86 | 87 | - Complete refactor to Next App Directories, review new documentation 88 | 89 | ### Notice 90 | 91 | **Printer v1.x.x** is compatible with the old Next patterns. You can review the documentation on the v1 website: [v1.prntr.click/docs](https://v1.prntr.click/docs) 92 | 93 | **Printer v2.x.x** leverages the Next App Directory pattern. This will be on the main documentation website: [prntr.click/docs](https://prntr.click/docs) 94 | 95 | ## v1.3.40 96 | 97 | - Hotfix to type inference 98 | 99 | ## v1.3.3 100 | 101 | - Dynamic type inference for prisma type generators 102 | 103 | - `path` refactoring to support all formats (`.ts`, `.tsx` and no suffix). 104 | 105 | ## v1.3.2 106 | 107 | - Updates prisma type generation nomenclature (hotfix) 108 | 109 | ## v1.3.1 110 | 111 | - `superagent` command hotfix 112 | 113 | ## v1.3.0 114 | 115 | - Added the `scss` command 116 | 117 | - Improved `public/assets/scss` structure and moved files to `/scss` 118 | 119 | - Added the `prisma` command 120 | 121 | - Added the `superagent` command 122 | 123 | - Restructured base project structure 124 | 125 | - Component, Pages and Injections now support `.tsx` suffixes 126 | 127 | - Added a `README.md` file with command list and documentation reference 128 | 129 | - Updated `package.json` dependencies 130 | 131 | ## v1.2.1 132 | 133 | - Added `sass` to dependencies 134 | 135 | - Removed `fonts.css` (redundant) 136 | 137 | - Moved `css/reset.css` to `scss/reset.scss` 138 | 139 | - Updated `printer.scss` structure 140 | 141 | ## v1.2.0 142 | 143 | - Added `--no-state` and `--no-action` flags for the `inject` command. 144 | 145 | ## v1.1.3 146 | 147 | - Made sure single variable injections work properly 148 | 149 | - Made sure that injection mapping properly identifies between a single variable, an array and an object 150 | 151 | ## v1.1.2 152 | 153 | - Array Typed injections were patched to use [...] instead of {...} for spread assignment. 154 | 155 | ## v1.1.1 156 | 157 | - Made sure type injections support array namespaces 158 | 159 | - Made sure component folder test files inputted paths properly 160 | 161 | - Fixed a console error where type injections with no types displayed "null" after output. 162 | 163 | - Printer Config is now dynamic and doesn't need to be full to preserve default options. 164 | 165 | ## v1.1.0 166 | 167 | - Made sure component generation checks both types of component structures for overwrite confirmation 168 | 169 | - Updated Component namespaces for better formatted code completion 170 | 171 | - Made sure that SCSS dynamically reloads with website 172 | 173 | - Updated scss command to compile static CSS for SSG/SSR 174 | 175 | ## v1.0.0 176 | 177 | #### Official API starts with the spec 178 | 179 | ```bash 180 | printer new [path] 181 | printer component 182 | printer type 183 | printer inject 184 | printer slice 185 | printer page 186 | printer api 187 | crud 188 | ``` 189 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Printer is licensed under the terms of the GNU AGPLv3 with additional terms and 2 | linking exceptions. The AGPLv3 license text can be found in the AGPLv3.txt file, the 3 | additional terms are given below this paragraph. 4 | 5 | Linking exceptions 6 | ------------------ 7 | 8 | In addition to the terms in the AGPLv3 the following linking exceptions apply: 9 | 10 | The authors of this work grant the rights to dynamically link against the below 11 | listed external sources or binaries during runtime, as an exception to the terms of 12 | the GNU AGPLv3, under the terms that none of that linked code shall be deemed part of 13 | this work, or a derivative work of this work, and as such are not required to meet 14 | the license terms of the AGPLv3 and as such are not covered by the terms of the AGPLv3 15 | when conveying this work. 16 | 17 | The full and exhaustive list of those sources excepted from the AGPLv3 are: 18 | 19 | * The Google Maps API v3 located at: 20 | * The twitter "follow button" widget located at 21 | * The GitHub Gist API located at . This applies only to 22 | the javascript coded issues by GitHub Inc. and explicitly does not apply to the 23 | content of any GitHub gist. 24 | * The disqus API located at .disqus.com/embed.js> where is the 25 | userid of the forum. 26 | 27 | Additional terms to AGPLv3 28 | ------------------------- 29 | 30 | In compliance with section 7 of the GNU AGPLv3 the following additional terms apply: 31 | 32 | a) The contained and displayed copyright attribution footer notice may not be removed, 33 | modified, altered or styled, or being removed, modified, altered or styled by 34 | external software (scripts, stylesheets, filters) in a way that would considerably 35 | affect visibility or readability of the notice to the user or any third party that 36 | uses the software locally or over the network; this especially includes resizing, 37 | overlaying, hiding or similar techniques. 38 | 39 | b) You may adjust or style the copyright footer to suit the appearance or layout of 40 | your website, as long as this does not violate the terms given in section (a) 41 | 42 | c) Attribution hyperlinks in the footer have to be kept unaltered. 43 | 44 | d) You may add your name to the list of copyright holder(s) in the footer if you make 45 | changes to the work, keeping intact all other copyright holder names 46 | 47 | e) Changes to these terms require written permission by the copyright holder(s). 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 🖨️ Printer 2 | 3 | ![Printer Banner](./banner.jpg "Printer Banner") 4 | 5 | ## Automation Tooling for Next, Redux and Prisma 6 | 7 | ![license](https://img.shields.io/badge/license-AGPLv3-blue.svg) 8 | ![version](https://img.shields.io/badge/version-2.2.5-blue.svg) 9 | [![CircleCI](https://circleci.com/gh/PrinterFramework/CLI.svg?style=svg)](https://circleci.com/gh/PrinterFramework/CLI) 10 | 11 | **Printer v1.x.x** is compatible with the old Next patterns. You can review the documentation on the v1 website: [v1.prntr.click/docs](https://v1.prntr.click/docs) 12 | 13 | **Printer v2.x.x** leverages the Next App Directory pattern. This will be on the main documentation website: [prntr.click/docs](https://prntr.click/docs) 14 | 15 | Review the [CHANGELOG](./CHANGELOG.md) for any updates made to the project. 16 | 17 | ## How it works 18 | 19 | 1. Install printer: 20 | 21 | ```bash 22 | # npm 23 | npm install -g @printerframework/cli 24 | # yarn 25 | yarn global add @printerframework/cli 26 | ``` 27 | 28 | 2. Create a new project: 29 | 30 | ```bash 31 | printer new printer-sample 32 | cd printer-sample 33 | ``` 34 | 35 | 3. Start developing: 36 | 37 | ```bash 38 | # Create a new component 39 | printer component components/component 40 | ``` 41 | 42 | ## Comments and Feedback 43 | 44 | Very open to comments and feedback. Very welcoming to people who open issues with reasonable constructive feedback. Please do not open PRs unless you're willing to commit code that matches the conventions and styles of the repository. 45 | 46 | ## Licensing 47 | 48 | [AGPLv3](./LICENSE) - This applies to hard forking printer. Not to Next.js projects generated with Printer. 49 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | '@babel/preset-env', 5 | { 6 | targets: { 7 | node: 'current' 8 | } 9 | } 10 | ], 11 | '@babel/preset-typescript' 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrinterFramework/CLI/58a0938f1765a8fb0f412020787bd2f021ae9b67/banner.jpg -------------------------------------------------------------------------------- /dist/src/config.d.ts: -------------------------------------------------------------------------------- 1 | export interface PrinterConfig { 2 | crud?: { 3 | create: boolean; 4 | update: boolean; 5 | delete: boolean; 6 | list: boolean; 7 | get: boolean; 8 | }; 9 | } 10 | export declare let Config: PrinterConfig; 11 | export declare function registerConfig(): void; 12 | -------------------------------------------------------------------------------- /dist/src/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __assign = (this && this.__assign) || function () { 3 | __assign = Object.assign || function(t) { 4 | for (var s, i = 1, n = arguments.length; i < n; i++) { 5 | s = arguments[i]; 6 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 7 | t[p] = s[p]; 8 | } 9 | return t; 10 | }; 11 | return __assign.apply(this, arguments); 12 | }; 13 | Object.defineProperty(exports, "__esModule", { value: true }); 14 | exports.registerConfig = exports.Config = void 0; 15 | var fs_jetpack_1 = require("fs-jetpack"); 16 | var path_1 = require("path"); 17 | var log_1 = require("./helpers/log"); 18 | exports.Config = { 19 | crud: { 20 | create: true, 21 | update: true, 22 | delete: true, 23 | list: true, 24 | get: true 25 | } 26 | }; 27 | function registerConfig() { 28 | try { 29 | var config = (0, fs_jetpack_1.read)((0, path_1.join)(process.cwd(), 'printer.config.json')) || ''; 30 | var data = JSON.parse(config); 31 | exports.Config = Object.assign(exports.Config, __assign({}, data)); 32 | } 33 | catch (error) { 34 | (0, log_1.Log)('👷 Could not load Printer config'.yellow); 35 | } 36 | } 37 | exports.registerConfig = registerConfig; 38 | //# sourceMappingURL=config.js.map -------------------------------------------------------------------------------- /dist/src/config.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,6BAA2B;AAC3B,qCAAmC;AAYxB,QAAA,MAAM,GAAkB;IACjC,IAAI,EAAE;QACJ,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,IAAI;QACV,GAAG,EAAE,IAAI;KACV;CACF,CAAA;AAED,SAAgB,cAAc;IAC5B,IAAI;QACF,IAAM,MAAM,GAAG,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,qBAAqB,CAAC,CAAC,IAAI,EAAE,CAAA;QACrE,IAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAA;QAC/B,cAAM,GAAG,MAAM,CAAC,MAAM,CAAC,cAAM,eAAO,IAAI,EAAG,CAAA;KAC5C;IAAC,OAAO,KAAK,EAAE;QACd,IAAA,SAAG,EAAC,mCAAmC,CAAC,MAAM,CAAC,CAAA;KAChD;AACH,CAAC;AARD,wCAQC"} -------------------------------------------------------------------------------- /dist/src/converter.d.ts: -------------------------------------------------------------------------------- 1 | export declare function Converter(): Promise; 2 | export declare function RecurseConverter(path: string): Promise; 3 | export declare function ConvertTemplate(path: string, filename: string): Promise; 4 | -------------------------------------------------------------------------------- /dist/src/converter.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"converter.js","sourceRoot":"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AE,CAAA"} -------------------------------------------------------------------------------- /dist/src/generators/api.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateApi(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/api.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateApi = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | function generateApi(path) { 48 | return __awaiter(this, void 0, void 0, function () { 49 | var apiPath, result, apiTemplate; 50 | return __generator(this, function (_a) { 51 | switch (_a.label) { 52 | case 0: 53 | apiPath = (0, path_1.join)(process.cwd(), 'app', 'api', "".concat(path, "/route.tsx")); 54 | if (!((0, fs_jetpack_1.exists)(apiPath) !== false)) return [3 /*break*/, 2]; 55 | return [4 /*yield*/, (0, prompts_1.default)({ 56 | type: 'confirm', 57 | name: 'overwrite', 58 | message: 'This api already exists, overwrite it?' 59 | })]; 60 | case 1: 61 | result = _a.sent(); 62 | if (result.overwrite === false) { 63 | return [2 /*return*/]; 64 | } 65 | _a.label = 2; 66 | case 2: 67 | apiTemplate = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'api.template')); 68 | (0, fs_jetpack_1.write)(apiPath, apiTemplate || ''); 69 | (0, log_1.Log)(" \u2705 Created app/api/".concat(path, "/route.tsx").green); 70 | return [2 /*return*/]; 71 | } 72 | }); 73 | }); 74 | } 75 | exports.generateApi = generateApi; 76 | //# sourceMappingURL=api.js.map -------------------------------------------------------------------------------- /dist/src/generators/api.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/generators/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AAEpC,SAAsB,WAAW,CAAE,IAAY;;;;;;oBACvC,OAAO,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,UAAG,IAAI,eAAY,CAAC,CAAA;yBAElE,CAAA,IAAA,mBAAM,EAAC,OAAO,CAAC,KAAK,KAAK,CAAA,EAAzB,wBAAyB;oBACZ,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,wCAAwC;yBAClD,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,WAAW,GAAG,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC,CAAA;oBAC5E,IAAA,kBAAK,EAAC,OAAO,EAAE,WAAW,IAAI,EAAE,CAAC,CAAA;oBACjC,IAAA,SAAG,EAAC,sCAA0B,IAAI,eAAY,CAAC,KAAK,CAAC,CAAA;;;;;CACtD;AAlBD,kCAkBC"} -------------------------------------------------------------------------------- /dist/src/generators/component.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateComponent(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/component.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateComponent = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | var nomenclature_1 = require("../helpers/nomenclature"); 48 | function generateComponent(path) { 49 | var _a; 50 | return __awaiter(this, void 0, void 0, function () { 51 | var result, pathArray, fileName, name, component, componentPath; 52 | return __generator(this, function (_b) { 53 | switch (_b.label) { 54 | case 0: 55 | if (!((0, fs_jetpack_1.exists)((0, path_1.join)(process.cwd(), path)) || (0, fs_jetpack_1.exists)((0, path_1.join)(process.cwd(), "".concat(path.replace('.tsx', ''), ".tsx"))))) return [3 /*break*/, 2]; 56 | return [4 /*yield*/, (0, prompts_1.default)({ 57 | type: 'confirm', 58 | name: 'overwrite', 59 | message: 'This component already exists, overwrite it?' 60 | })]; 61 | case 1: 62 | result = _b.sent(); 63 | if (result.overwrite === false) { 64 | return [2 /*return*/]; 65 | } 66 | _b.label = 2; 67 | case 2: 68 | pathArray = path.replace('.tsx', '').split('/'); 69 | fileName = pathArray[pathArray.length - 1]; 70 | name = (0, nomenclature_1.formatName)(fileName); 71 | component = (_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'component.nostyle.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path); 72 | componentPath = (0, path_1.join)(process.cwd(), "".concat(path.replace('.tsx', ''), ".tsx")); 73 | (0, fs_jetpack_1.write)(componentPath, component || ''); 74 | (0, log_1.Log)(" \u2705 Created ".concat(path.replace('.tsx', ''), ".tsx").green); 75 | return [2 /*return*/]; 76 | } 77 | }); 78 | }); 79 | } 80 | exports.generateComponent = generateComponent; 81 | //# sourceMappingURL=component.js.map -------------------------------------------------------------------------------- /dist/src/generators/component.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/generators/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,wDAAoD;AAEpD,SAAsB,iBAAiB,CAAE,IAAY;;;;;;;yBAC/C,CAAA,IAAA,mBAAM,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC,IAAI,IAAA,mBAAM,EAAC,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAM,CAAC,CAAC,CAAA,EAAnG,wBAAmG;oBACtF,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,8CAA8C;yBACxD,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;oBAC/C,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;oBAC1C,IAAI,GAAG,IAAA,yBAAU,EAAC,QAAQ,CAAC,CAAA;oBAE3B,SAAS,GAAG,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,4BAA4B,CAAC,CAAC,0CAAE,UAAU,CAAC,UAAU,EAAE,IAAI,EAAE,UAAU,CAAC,YAAY,EAAE,QAAQ,EAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;oBAC7L,aAAa,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,UAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAM,CAAC,CAAA;oBAE5E,IAAA,kBAAK,EAAC,aAAa,EAAE,SAAS,IAAI,EAAE,CAAC,CAAA;oBACrC,IAAA,SAAG,EAAC,8BAAkB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAM,CAAC,KAAK,CAAC,CAAA;;;;;CAC5D;AAtBD,8CAsBC"} -------------------------------------------------------------------------------- /dist/src/generators/crud.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateCrud(model: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/crud.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateCrud = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | function generateCrud(model) { 48 | var _a; 49 | return __awaiter(this, void 0, void 0, function () { 50 | var basePath, result, routePath, routeTemplate; 51 | return __generator(this, function (_b) { 52 | switch (_b.label) { 53 | case 0: 54 | basePath = (0, path_1.join)(process.cwd(), 'app', 'api', model); 55 | if (!((0, fs_jetpack_1.exists)(basePath) !== false)) return [3 /*break*/, 2]; 56 | return [4 /*yield*/, (0, prompts_1.default)({ 57 | type: 'confirm', 58 | name: 'overwrite', 59 | message: 'Routes already exist in this folder, overwrite it?' 60 | })]; 61 | case 1: 62 | result = _b.sent(); 63 | if (result.overwrite === false) { 64 | return [2 /*return*/]; 65 | } 66 | _b.label = 2; 67 | case 2: 68 | routePath = (0, path_1.join)(basePath, 'route.tsx'); 69 | routeTemplate = (_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'crud.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{model}}', model); 70 | (0, fs_jetpack_1.write)(routePath, routeTemplate || ''); 71 | (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/route.tsx").green); 72 | return [2 /*return*/]; 73 | } 74 | }); 75 | }); 76 | } 77 | exports.generateCrud = generateCrud; 78 | //# sourceMappingURL=crud.js.map -------------------------------------------------------------------------------- /dist/src/generators/crud.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"crud.js","sourceRoot":"","sources":["../../../src/generators/crud.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AAEpC,SAAsB,YAAY,CAAE,KAAa;;;;;;;oBACzC,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;yBAErD,CAAA,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,CAAA,EAA1B,wBAA0B;oBACb,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,oDAAoD;yBAC9D,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,SAAS,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,WAAW,CAAC,CAAA;oBACvC,aAAa,GAAG,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,0CAAE,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;oBAC/G,IAAA,kBAAK,EAAC,SAAS,EAAE,aAAa,IAAI,EAAE,CAAC,CAAA;oBACrC,IAAA,SAAG,EAAC,wCAA4B,KAAK,eAAY,CAAC,KAAK,CAAC,CAAA;;;;;CACzD;AAnBD,oCAmBC"} -------------------------------------------------------------------------------- /dist/src/generators/error.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateError(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/error.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateError = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | var nomenclature_1 = require("../helpers/nomenclature"); 48 | function generateError(path) { 49 | var _a; 50 | return __awaiter(this, void 0, void 0, function () { 51 | var errorPath, result, pathArray, fileName, name, errorTemplate; 52 | return __generator(this, function (_b) { 53 | switch (_b.label) { 54 | case 0: 55 | errorPath = (0, path_1.join)(process.cwd(), 'app', "".concat(path.replace('.tsx', ''), "/error.tsx")); 56 | if (!((0, fs_jetpack_1.exists)(errorPath) !== false)) return [3 /*break*/, 2]; 57 | return [4 /*yield*/, (0, prompts_1.default)({ 58 | type: 'confirm', 59 | name: 'overwrite', 60 | message: 'A error component already exists, overwrite it?' 61 | })]; 62 | case 1: 63 | result = _b.sent(); 64 | if (result.overwrite === false) { 65 | return [2 /*return*/]; 66 | } 67 | _b.label = 2; 68 | case 2: 69 | pathArray = path.replace('.tsx', '').split('/'); 70 | fileName = pathArray[pathArray.length - 1]; 71 | name = (0, nomenclature_1.formatName)(fileName); 72 | errorTemplate = ((_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'error.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name)) || ''; 73 | (0, fs_jetpack_1.write)(errorPath, errorTemplate); 74 | (0, log_1.Log)(" \u2705 Created app/".concat(path, "/error.tsx").green); 75 | return [2 /*return*/]; 76 | } 77 | }); 78 | }); 79 | } 80 | exports.generateError = generateError; 81 | //# sourceMappingURL=error.js.map -------------------------------------------------------------------------------- /dist/src/generators/error.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/generators/error.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,wDAAoD;AAEpD,SAAsB,aAAa,CAAE,IAAY;;;;;;;oBACzC,SAAS,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,UAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,eAAY,CAAC,CAAA;yBAEjF,CAAA,IAAA,mBAAM,EAAC,SAAS,CAAC,KAAK,KAAK,CAAA,EAA3B,wBAA2B;oBACd,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,iDAAiD;yBAC3D,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;oBAC/C,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;oBAC1C,IAAI,GAAG,IAAA,yBAAU,EAAC,QAAQ,CAAC,CAAA;oBAC3B,aAAa,GAAG,CAAA,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,gBAAgB,CAAC,CAAC,0CAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,KAAI,EAAE,CAAA;oBAEpH,IAAA,kBAAK,EAAC,SAAS,EAAE,aAAa,CAAC,CAAA;oBAC/B,IAAA,SAAG,EAAC,kCAAsB,IAAI,eAAY,CAAC,KAAK,CAAC,CAAA;;;;;CAClD;AAtBD,sCAsBC"} -------------------------------------------------------------------------------- /dist/src/generators/inject.d.ts: -------------------------------------------------------------------------------- 1 | export interface OptsType { 2 | state: boolean; 3 | action: boolean; 4 | } 5 | export declare function inject(slice: string, component: string, opts: OptsType): Promise; 6 | -------------------------------------------------------------------------------- /dist/src/generators/layout.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateLayout(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/layout.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateLayout = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | var nomenclature_1 = require("../helpers/nomenclature"); 48 | function generateLayout(path) { 49 | var _a; 50 | return __awaiter(this, void 0, void 0, function () { 51 | var layoutPath, result, pathArray, fileName, name, layoutTemplate; 52 | return __generator(this, function (_b) { 53 | switch (_b.label) { 54 | case 0: 55 | layoutPath = (0, path_1.join)(process.cwd(), 'app', "".concat(path.replace('.tsx', ''), "/layout.tsx")); 56 | if (!((0, fs_jetpack_1.exists)(layoutPath) !== false)) return [3 /*break*/, 2]; 57 | return [4 /*yield*/, (0, prompts_1.default)({ 58 | type: 'confirm', 59 | name: 'overwrite', 60 | message: 'A layout component already exists, overwrite it?' 61 | })]; 62 | case 1: 63 | result = _b.sent(); 64 | if (result.overwrite === false) { 65 | return [2 /*return*/]; 66 | } 67 | _b.label = 2; 68 | case 2: 69 | pathArray = path.replace('.tsx', '').split('/'); 70 | fileName = pathArray[pathArray.length - 1]; 71 | name = (0, nomenclature_1.formatName)(fileName); 72 | layoutTemplate = ((_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'layout.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name)) || ''; 73 | (0, fs_jetpack_1.write)(layoutPath, layoutTemplate); 74 | (0, log_1.Log)(" \u2705 Created app/".concat(path, "/layout.tsx").green); 75 | return [2 /*return*/]; 76 | } 77 | }); 78 | }); 79 | } 80 | exports.generateLayout = generateLayout; 81 | //# sourceMappingURL=layout.js.map -------------------------------------------------------------------------------- /dist/src/generators/layout.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"layout.js","sourceRoot":"","sources":["../../../src/generators/layout.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,wDAAoD;AAEpD,SAAsB,cAAc,CAAE,IAAY;;;;;;;oBAC1C,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,UAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,gBAAa,CAAC,CAAA;yBAEnF,CAAA,IAAA,mBAAM,EAAC,UAAU,CAAC,KAAK,KAAK,CAAA,EAA5B,wBAA4B;oBACf,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,kDAAkD;yBAC5D,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;oBAC/C,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;oBAC1C,IAAI,GAAG,IAAA,yBAAU,EAAC,QAAQ,CAAC,CAAA;oBAC3B,cAAc,GAAG,CAAA,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,iBAAiB,CAAC,CAAC,0CAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,KAAI,EAAE,CAAA;oBAEtH,IAAA,kBAAK,EAAC,UAAU,EAAE,cAAc,CAAC,CAAA;oBACjC,IAAA,SAAG,EAAC,kCAAsB,IAAI,gBAAa,CAAC,KAAK,CAAC,CAAA;;;;;CACnD;AAtBD,wCAsBC"} -------------------------------------------------------------------------------- /dist/src/generators/loading.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateLoading(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/loading.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateLoading = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | var nomenclature_1 = require("../helpers/nomenclature"); 48 | function generateLoading(path) { 49 | var _a; 50 | return __awaiter(this, void 0, void 0, function () { 51 | var loadingPath, result, pathArray, fileName, name, loadingTemplate; 52 | return __generator(this, function (_b) { 53 | switch (_b.label) { 54 | case 0: 55 | loadingPath = (0, path_1.join)(process.cwd(), 'app', "".concat(path.replace('.tsx', ''), "/loading.tsx")); 56 | if (!((0, fs_jetpack_1.exists)(loadingPath) !== false)) return [3 /*break*/, 2]; 57 | return [4 /*yield*/, (0, prompts_1.default)({ 58 | type: 'confirm', 59 | name: 'overwrite', 60 | message: 'A loading component already exists, overwrite it?' 61 | })]; 62 | case 1: 63 | result = _b.sent(); 64 | if (result.overwrite === false) { 65 | return [2 /*return*/]; 66 | } 67 | _b.label = 2; 68 | case 2: 69 | pathArray = path.replace('.tsx', '').split('/'); 70 | fileName = pathArray[pathArray.length - 1]; 71 | name = (0, nomenclature_1.formatName)(fileName); 72 | loadingTemplate = ((_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'loading.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name)) || ''; 73 | (0, fs_jetpack_1.write)(loadingPath, loadingTemplate); 74 | (0, log_1.Log)(" \u2705 Created app/".concat(path, "/loading.tsx").green); 75 | return [2 /*return*/]; 76 | } 77 | }); 78 | }); 79 | } 80 | exports.generateLoading = generateLoading; 81 | //# sourceMappingURL=loading.js.map -------------------------------------------------------------------------------- /dist/src/generators/loading.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"loading.js","sourceRoot":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AtBD,0CAsBC"} -------------------------------------------------------------------------------- /dist/src/generators/new.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateNewProject(path?: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/new.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"new.js","sourceRoot":"","sources":["../../../src/generators/new.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,iCAAoC;AAEpC,SAAsB,kBAAkB,CAAE,IAAkB;IAAlB,qBAAA,EAAA,UAAkB;;;;;;;oBACpD,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,qBAAqB,CAAC,CAAA;yBAC/D,CAAA,IAAA,mBAAM,EAAC,UAAU,CAAC,KAAK,KAAK,CAAA,EAA5B,wBAA4B;oBACf,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,8CAA8C;yBACxD,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,IAAI,GAAG;wBACX,qBAAqB;wBACrB,gBAAgB;wBAChB,cAAc;wBACd,YAAY;wBACZ,gBAAgB;wBAChB,gBAAgB;wBAChB,cAAc;wBACd,WAAW;wBACX,eAAe;qBAChB,CAAA;;wBAED,KAAmB,SAAA,SAAA,IAAI,CAAA,sEAAE;4BAAd,IAAI;4BACP,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;4BAC5C,QAAQ,GAAG,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI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K,EAAE,IAAI,CAAC,CAAA;4BACjD,QAAQ,GAAG,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK,EAAE,UAAG,IAAI,cAAW,CAAC,CAAC,IAAI,EAAE,CAAA;4BAEjG,IAAA,kBAAK,EACH,QAAQ,EACR,QAAQ,CACT,CAAA;4BACD,IAAA,SAAG,EAAC,kCAAsB,IAAI,CAAE,CAAC,KAAK,CAAC,CAAA;yBACxC;;;;;;;;;oBAEK,UAAU,GAAG;wBACjB,aAAa;qBACd,CAAA;;wBAED,KAAmB,eAAA,SAAA,UAAU,CAAA,oGAAE;4BAApB,IAAI;4BACP,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,CAAA;4BACxD,QAAQ,GAAG,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,UAAG,IAAI,cAAW,CAAC,CAAC,IAAI,EAAE,CAAA;4BAExG,IAAA,kBAAK,EACH,QAAQ,EACR,QAAQ,CACT,CAAA;4BACD,IAAA,SAAG,EAAC,yCAA6B,IAAI,CAAE,CAAC,KAAK,CAAC,CAAA;yBAC/C;;;;;;;;;;;;;CACF;AAzJD,gDAyJC"} -------------------------------------------------------------------------------- /dist/src/generators/page.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generatePage(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/page.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"page.js","sourceRoot":"","sources":["../../../src/generators/page.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,wDAAoD;AAEpD,SAAsB,YAAY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iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,mBAAmB,CAAC,CAAC,IAAI,EAAE,CAAC;6BACjF,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC;6BAC5B,UAAU,CAAC,mBAAmB,EAAE,QAAQ,CAAC;6BACzC,UAAU,CAAC,mBAAmB,EAAE,yBAAkB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,UAAO,CAAC,CAAA;qBACrF;yBAAM;wBACL,YAAY,GAAG,CAAA,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,0CAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,KAAI,EAAE,CAAA;qBAC7G;oBAED,IAAA,kBAAK,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;oBAC7B,IAAA,SAAG,EAAC,kCAAsB,IAAI,cAAW,CAAC,KAAK,CAAC,CAAA;;;;;CACjD;AArCD,oCAqCC"} -------------------------------------------------------------------------------- /dist/src/generators/prisma.d.ts: -------------------------------------------------------------------------------- 1 | interface ModelType { 2 | original: string; 3 | name: string; 4 | type: string; 5 | imported: boolean; 6 | } 7 | export declare function generateImports(name: string, models: ModelType[]): string; 8 | export declare function generatePrismaTypes(): Promise; 9 | export {}; 10 | -------------------------------------------------------------------------------- /dist/src/generators/prisma.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"prisma.js","sourceRoot":"","sources":["../../../src/generators/prisma.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA2B;AAC3B,yCAAwC;AACxC,sCAAoC;AAcpC,IAAM,WAAW,GAAG;IAClB;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,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,CAAA;oCAE9C,IAAI,MAAI,IAAI,IAAI,EAAE;wCAChB,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,IAAI,QAAA,EAAE,IAAI,MAAA,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAA;qCAC5E;iCACF;;;;;;;;;yBACF;wBAEK,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,CAAA;wBAC7B,SAAS,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;wBAE5C,QAAQ,GAAG,aAAa,GAAG,2BAAoB,IAAI,yBAAsB,GAAG,MAAM,GAAG,yBAAkB,IAAI,SAAM,GAAG,IAAI,CAAA;wBACxH,UAAU,GAAG,EAAE,CAAA;;4BAEnB,KAAmB,2BAAA,SAAA,OAAO,CAAA,CAAA,qFAAE;gCAAjB,IAAI;gCACb,UAAU,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;6BAC1D;;;;;;;;;wBAED,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,EAAE,IAAI,GAAG,UAAU,CAAC,CAAA;wBAC/D,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,SAAS,CAAC,CAAA;wBAC/C,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAG,IAAI,SAAM,CAAC,CAAA;wBAEtE,IAAA,SAAG,EAAC,6CAAiC,IAAI,SAAM,CAAC,KAAK,CAAC,CAAA;wBACtD,IAAA,kBAAK,EAAC,QAAQ,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAA;qBAChC;iBACF;;;;;;;;;;;;CACF;AArDD,kDAqDC"} -------------------------------------------------------------------------------- /dist/src/generators/scss.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateScss(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/scss.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateScss = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | function generateScss(path) { 48 | return __awaiter(this, void 0, void 0, function () { 49 | var scssPath, result, scssTemplate, printerPath, printerFile; 50 | return __generator(this, function (_a) { 51 | switch (_a.label) { 52 | case 0: 53 | scssPath = (0, path_1.join)(process.cwd(), 'scss', "".concat(path, ".scss")); 54 | if (!((0, fs_jetpack_1.exists)(scssPath) !== false)) return [3 /*break*/, 2]; 55 | return [4 /*yield*/, (0, prompts_1.default)({ 56 | type: 'confirm', 57 | name: 'overwrite', 58 | message: 'This scss file already exists, overwrite it?' 59 | })]; 60 | case 1: 61 | result = _a.sent(); 62 | if (result.overwrite === false) { 63 | return [2 /*return*/]; 64 | } 65 | _a.label = 2; 66 | case 2: 67 | scssTemplate = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'scss.template')) || ''; 68 | (0, fs_jetpack_1.write)(scssPath, scssTemplate); 69 | (0, log_1.Log)(" \u2705 Created scss/".concat(path, ".scss").green); 70 | printerPath = (0, path_1.join)(process.cwd(), 'scss', 'printer.scss'); 71 | printerFile = (0, fs_jetpack_1.read)(printerPath); 72 | printerFile += "\n@import \"/scss/".concat(path, ".scss\";"); 73 | (0, fs_jetpack_1.write)(printerPath, printerFile || ''); 74 | (0, log_1.Log)(' ✅ Updated scss/printer.scss'.green); 75 | return [2 /*return*/]; 76 | } 77 | }); 78 | }); 79 | } 80 | exports.generateScss = generateScss; 81 | //# sourceMappingURL=scss.js.map -------------------------------------------------------------------------------- /dist/src/generators/scss.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"scss.js","sourceRoot":"","sources":["../../../src/generators/scss.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AAEpC,SAAsB,YAAY,CAAE,IAAY;;;;;;oBACxC,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,UAAG,IAAI,UAAO,CAAC,CAAA;yBAExD,CAAA,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,CAAA,EAA1B,wBAA0B;oBACb,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,8CAA8C;yBACxD,CAAC,EAAA;;oBAJI,MAAM,GAAG,SAIb;oBAEF,IAAI,MAAM,CAAC,SAAS,KAAK,KAAK,EAAE;wBAC9B,sBAAM;qBACP;;;oBAGG,YAAY,GAAG,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,IAAI,EAAE,CAAA;oBACpF,IAAA,kBAAK,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;oBAC7B,IAAA,SAAG,EAAC,mCAAuB,IAAI,UAAO,CAAC,KAAK,CAAC,CAAA;oBAEvC,WAAW,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,cAAc,CAAC,CAAA;oBAC3D,WAAW,GAAG,IAAA,iBAAI,EAAC,WAAW,CAAC,CAAA;oBACnC,WAAW,IAAI,4BAAoB,IAAI,aAAS,CAAA;oBAEhD,IAAA,kBAAK,EAAC,WAAW,EAAE,WAAW,IAAI,EAAE,CAAC,CAAA;oBACrC,IAAA,SAAG,EAAC,kCAAkC,CAAC,KAAK,CAAC,CAAA;;;;;CAC9C;AAzBD,oCAyBC"} -------------------------------------------------------------------------------- /dist/src/generators/slice.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateSlice(name: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/slice.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"slice.js","sourceRoot":"","sources":["../../../src/generators/slice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAwC;AACxC,sCAAoC;AAEpC,SAAsB,aAAa,CAAE,IAAY;;;;;;;oBACzC,SAAS,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,UAAG,IAAI,SAAM,CAAC,CAAA;oBAChE,WAAW,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,aAAa,CAAC,CAAA;oBACzD,YAAY,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,eAAe,CAAC,CAAA;oBAE9D,QAAQ,GAAG,EAAE,CAAA;;;;oBAGf,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAA,iBAAI,EAAC,YAAY,CAAW,CAAa,CAAA;yBAE3D,CAAA,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA,EAA7B,wBAA6B;oBAChB,qBAAM,IAAA,iBAAO,EAAC;4BAC3B,IAAI,EAAE,SAAS;4BACf,IAAI,EAAE,WAAW;4BACjB,OAAO,EAAE,0CAA0C;yBACpD,CAAC,EAAA;;oBAJI,MAAM,GA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BACD,IAAA,SAAG,EAAC,kCAAkC,CAAC,KAAK,CAAC,CAAA;;;;;CAC9C;AA3CD,sCA2CC"} -------------------------------------------------------------------------------- /dist/src/generators/superagent.d.ts: -------------------------------------------------------------------------------- 1 | export type SuperagentTypes = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE'; 2 | export declare function injectSupergent(type: SuperagentTypes, component: string): Promise; 3 | -------------------------------------------------------------------------------- /dist/src/generators/superagent.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"superagent.js","sourceRoot":"","sources":["../../../src/generators/superagent.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,0CAA+G;AAI/G,SAAsB,eAAe,CAAE,IAAqB,EAAE,SAAiB;;;;;YACvE,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAA;YACzC,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;YAChC,QAAQ,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;YAC5C,YAAY,GAAG,EAAE,CAAA;YAErB,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBACnC,YAAY,GAAG,IAAA,iBAAI,EAAC,UAAG,QAAQ,SAAM,CAAC,IAAI,EAAE,CAAA;aAC7C;iBAAM;gBACL,YAAY,GAAG,IAAA,iBAAI,EAAC,UAAG,QAAQ,CAAE,CAAC,IAAI,EAAE,CAAA;aACzC;YAED,IAAI,IAAA,mBAAW,EAAC,YAAY,EAAE,IAAA,oBAAY,GAAE,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,IAAA,mBAAW,EAAC,YAAY,EAAE,IAAA,qBAAa,GAAE,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE;gBACrH,Y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,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,UAAG,QAAQ,mBAAgB,CAAC,CAAA;gBACrF,IAAA,kBAAK,EAAC,iBAAiB,EAAE,WAAW,CAAC,CAAA;gBACrC,IAAA,SAAG,EAAC,8BAAkB,iBAAiB,CAAE,CAAC,KAAK,CAAC,CAAA;aACjD;iBAAM;gBACL,IAAA,kBAAK,EAAC,UAAG,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAM,EAAE,WAAW,CAAC,CAAA;gBAC1D,IAAA,SAAG,EAAC,8BAAkB,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAM,CAAC,KAAK,CAAC,CAAA;aACjE;;;;CACF;AA5CD,0CA4CC"} -------------------------------------------------------------------------------- /dist/src/generators/type.d.ts: -------------------------------------------------------------------------------- 1 | export declare function generateType(path: string): Promise; 2 | -------------------------------------------------------------------------------- /dist/src/generators/type.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 3 | function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 4 | return new (P || (P = Promise))(function (resolve, reject) { 5 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 6 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 7 | function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } 8 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 9 | }); 10 | }; 11 | var __generator = (this && this.__generator) || function (thisArg, body) { 12 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 13 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 14 | function verb(n) { return function (v) { return step([n, v]); }; } 15 | function step(op) { 16 | if (f) throw new TypeError("Generator is already executing."); 17 | while (g && (g = 0, op[0] && (_ = 0)), _) try { 18 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 19 | if (y = 0, t) op = [op[0] & 2, t.value]; 20 | switch (op[0]) { 21 | case 0: case 1: t = op; break; 22 | case 4: _.label++; return { value: op[1], done: false }; 23 | case 5: _.label++; y = op[1]; op = [0]; continue; 24 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 25 | default: 26 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 27 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 28 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 29 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 30 | if (t[2]) _.ops.pop(); 31 | _.trys.pop(); continue; 32 | } 33 | op = body.call(thisArg, _); 34 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 35 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 36 | } 37 | }; 38 | var __importDefault = (this && this.__importDefault) || function (mod) { 39 | return (mod && mod.__esModule) ? mod : { "default": mod }; 40 | }; 41 | Object.defineProperty(exports, "__esModule", { value: true }); 42 | exports.generateType = void 0; 43 | var prompts_1 = __importDefault(require("prompts")); 44 | var path_1 = require("path"); 45 | var fs_jetpack_1 = require("fs-jetpack"); 46 | var log_1 = require("../helpers/log"); 47 | function generateType(path) { 48 | var _a; 49 | return __awaiter(this, void 0, void 0, function () { 50 | var typePath, result, pathArray, fileName, name, typeTemplate; 51 | return __generator(this, function (_b) { 52 | switch (_b.label) { 53 | case 0: 54 | typePath = (0, path_1.join)(process.cwd(), 'types', "".concat(path, ".tsx")); 55 | if (!((0, fs_jetpack_1.exists)(typePath) !== false)) return [3 /*break*/, 2]; 56 | return [4 /*yield*/, (0, prompts_1.default)({ 57 | type: 'confirm', 58 | name: 'overwrite', 59 | message: 'This api already exists, overwrite it?' 60 | })]; 61 | case 1: 62 | result = _b.sent(); 63 | if (result.overwrite === false) { 64 | return [2 /*return*/]; 65 | } 66 | _b.label = 2; 67 | case 2: 68 | pathArray = path.split('/'); 69 | fileName = pathArray[pathArray.length - 1]; 70 | name = fileName.replace(/[^\w\s]/gi, ''); 71 | if (fileName.indexOf('.') !== -1) { 72 | name = fileName.split('.').map(function (word) { return word[0].toUpperCase() + word.substring(1); }).join(''); 73 | } 74 | else if (fileName.indexOf('-') !== -1) { 75 | name = fileName.split('-').map(function (word) { return word[0].toUpperCase() + word.substring(1); }).join(''); 76 | } 77 | else { 78 | name = name[0].toUpperCase() + name.substring(1); 79 | } 80 | typeTemplate = (_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'type.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name); 81 | (0, fs_jetpack_1.write)(typePath, typeTemplate || ''); 82 | (0, log_1.Log)(" \u2705 Created types/".concat(path, ".tsx").green); 83 | return [2 /*return*/]; 84 | } 85 | }); 86 | }); 87 | } 88 | exports.generateType = generateType; 89 | //# sourceMappingURL=type.js.map -------------------------------------------------------------------------------- /dist/src/generators/type.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"type.js","sourceRoot":"","sources":["../../../src/generators/type.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AAEpC,SAAsB,YAAY,CAAE,IAAY;;;;;;;oBACxC,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,UAAG,IAAI,SAAM,CAAC,CAAA;yBAExD,CAAA,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,CA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BAEK,YAAY,GAAG,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC,0CAAE,UAAU,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;oBAE5G,IAAA,kBAAK,EAAC,QAAQ,EAAE,YAAY,IAAI,EAAE,CAAC,CAAA;oBACnC,IAAA,SAAG,EAAC,oCAAwB,IAAI,SAAM,CAAC,KAAK,CAAC,CAAA;;;;;CAC9C;AA/BD,oCA+BC"} -------------------------------------------------------------------------------- /dist/src/helpers/log.d.ts: -------------------------------------------------------------------------------- 1 | export declare function Log(...output: string[]): void; 2 | -------------------------------------------------------------------------------- /dist/src/helpers/log.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | var __read = (this && this.__read) || function (o, n) { 3 | var m = typeof Symbol === "function" && o[Symbol.iterator]; 4 | if (!m) return o; 5 | var i = m.call(o), r, ar = [], e; 6 | try { 7 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); 8 | } 9 | catch (error) { e = { error: error }; } 10 | finally { 11 | try { 12 | if (r && !r.done && (m = i["return"])) m.call(i); 13 | } 14 | finally { if (e) throw e.error; } 15 | } 16 | return ar; 17 | }; 18 | var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { 19 | if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { 20 | if (ar || !(i in from)) { 21 | if (!ar) ar = Array.prototype.slice.call(from, 0, i); 22 | ar[i] = from[i]; 23 | } 24 | } 25 | return to.concat(ar || Array.prototype.slice.call(from)); 26 | }; 27 | Object.defineProperty(exports, "__esModule", { value: true }); 28 | exports.Log = void 0; 29 | function Log() { 30 | var output = []; 31 | for (var _i = 0; _i < arguments.length; _i++) { 32 | output[_i] = arguments[_i]; 33 | } 34 | if (process.env.NODE_ENV !== 'test') { 35 | console.log.apply(console, __spreadArray([], __read(output), false)); 36 | } 37 | } 38 | exports.Log = Log; 39 | //# sourceMappingURL=log.js.map -------------------------------------------------------------------------------- /dist/src/helpers/log.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"log.js","sourceRoot":"","sources":["../../../src/helpers/log.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAgB,GAAG;IAAE,gBAAmB;SAAnB,UAAmB,EAAnB,qBAAmB,EAAnB,IAAmB;QAAnB,2BAAmB;;IACtC,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;QACnC,OAAO,CAAC,GAAG,OAAX,OAAO,2BAAQ,MAAM,WAAC;KACvB;AACH,CAAC;AAJD,kBAIC"} -------------------------------------------------------------------------------- /dist/src/helpers/match.d.ts: -------------------------------------------------------------------------------- 1 | export declare const SliceMatcher: RegExp; 2 | export declare const ImportMatcher: RegExp; 3 | export declare const ReduxMatcher: RegExp; 4 | export declare const ReduxOptionalMatcher: RegExp; 5 | export declare const DispatchMatcher: RegExp; 6 | export declare const BraceMatcher: RegExp; 7 | export declare const BraceMatcher2: RegExp; 8 | export declare function superagentMatcher(type: string): RegExp; 9 | export declare function stateMatcher(): RegExp; 10 | export declare function effectMatcher(): RegExp; 11 | export declare function functionMatcher(name: string): RegExp; 12 | export declare function selectorMatcher(name: string): RegExp; 13 | export declare function actionMatcher(name: string[]): RegExp; 14 | export declare function typeMatcher(name: string): RegExp; 15 | export declare function findMatches(text: any, pattern: any): number[]; 16 | -------------------------------------------------------------------------------- /dist/src/helpers/match.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.findMatches = exports.typeMatcher = exports.actionMatcher = exports.selectorMatcher = exports.functionMatcher = exports.effectMatcher = exports.stateMatcher = exports.superagentMatcher = exports.BraceMatcher2 = exports.BraceMatcher = exports.DispatchMatcher = exports.ReduxOptionalMatcher = exports.ReduxMatcher = exports.ImportMatcher = exports.SliceMatcher = void 0; 4 | exports.SliceMatcher = /^(?=.*export)(?=.*createSlice).*$/gmi; 5 | exports.ImportMatcher = /^(?=.*import)(?=.*from).*$/gmi; 6 | exports.ReduxMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector)(?=.*useAppDispatch).*$/gmi; 7 | exports.ReduxOptionalMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector|useAppDispatch).*$/gmi; 8 | exports.DispatchMatcher = /^(?=.*const)(?=.*dispatch)(?=.*useAppDispatch).*$/gmi; 9 | exports.BraceMatcher = /^(?=.*\[).*$/gmi; 10 | exports.BraceMatcher2 = /^(?=.*{).*$/gmi; 11 | function superagentMatcher(type) { 12 | return new RegExp("^(?=.*import)(?=.*".concat(type, ")(?=.*from).*$"), 'gmi'); 13 | } 14 | exports.superagentMatcher = superagentMatcher; 15 | function stateMatcher() { 16 | return new RegExp('^(?=.*import)(?=.*useState)(?=.*from).*$', 'gmi'); 17 | } 18 | exports.stateMatcher = stateMatcher; 19 | function effectMatcher() { 20 | return new RegExp('^(?=.*import)(?=.*useEffect)(?=.*from).*$', 'gmi'); 21 | } 22 | exports.effectMatcher = effectMatcher; 23 | function functionMatcher(name) { 24 | return new RegExp("^(?=.*function)(?=.*".concat(name, ").*$"), 'gmi'); 25 | } 26 | exports.functionMatcher = functionMatcher; 27 | function selectorMatcher(name) { 28 | return new RegExp("^(?=.*".concat(name, " =)(?=.*useSelector).*$"), 'gmi'); 29 | } 30 | exports.selectorMatcher = selectorMatcher; 31 | function actionMatcher(name) { 32 | return new RegExp("^(?=.*import)(?=.*".concat(name.join('|'), ")(?=.*from).*$"), 'gmi'); 33 | } 34 | exports.actionMatcher = actionMatcher; 35 | function typeMatcher(name) { 36 | return new RegExp("^(?=.*import)(?=.*".concat(name, ")(?=.*from).*$"), 'gmi'); 37 | } 38 | exports.typeMatcher = typeMatcher; 39 | function findMatches(text, pattern) { 40 | var matchingLines = []; 41 | var allLines = text.split('\n'); 42 | for (var i = 0; i < allLines.length; i++) { 43 | if (allLines[i].match(pattern)) { 44 | matchingLines.push(i); 45 | } 46 | } 47 | return matchingLines; 48 | } 49 | exports.findMatches = findMatches; 50 | //# sourceMappingURL=match.js.map -------------------------------------------------------------------------------- /dist/src/helpers/match.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"match.js","sourceRoot":"","sources":["../../../src/helpers/match.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG,sCAAsC,CAAA;AACrD,QAAA,aAAa,GAAG,+BAA+B,CAAA;AAC/C,QAAA,YAAY,GAAG,uEAAuE,CAAA;AACtF,QAAA,oBAAoB,GAAG,kEAAkE,CAAA;AACzF,QAAA,eAAe,GAAG,sDAAsD,CAAA;AACxE,QAAA,YAAY,GAAG,iBAAiB,CAAA;AAChC,QAAA,aAAa,GAAG,gBAAgB,CAAA;AAE7C,SAAgB,iBAAiB,CAAE,IAAY;IAC7C,OAAO,IAAI,MAAM,CAAC,4BAAqB,IAAI,mBAAgB,EAAE,KAAK,CAAC,CAAA;AACrE,CAAC;AAFD,8CAEC;AAED,SAAgB,YAAY;IAC1B,OAAO,IAAI,MAAM,CAAC,0CAA0C,EAAE,KAAK,CAAC,CAAA;AACtE,CAAC;AAFD,oCAEC;AAED,SAAgB,aAAa;IAC3B,OAAO,IAAI,MAAM,CAAC,2CAA2C,EAAE,KAAK,CAAC,CAAA;AACvE,CAAC;AAFD,sCAEC;AAED,SAAgB,eAAe,CAAE,IAAY;IAC3C,OAAO,IAAI,MAAM,CAAC,8BAAuB,IAAI,SAAM,EAAE,KAAK,CAAC,CAAA;AAC7D,CAAC;AAFD,0CAEC;AAED,SAAgB,eAAe,CAAE,IAAY;IAC3C,OAAO,IAAI,MAAM,CAAC,gBAAS,IAAI,4BAAyB,EAAE,KAAK,CAAC,CAAA;AAClE,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAE,IAAc;IAC3C,OAAO,IAAI,MAAM,CAAC,4BAAqB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,mBAAgB,EAAE,KAAK,CAAC,CAAA;AAC/E,CAAC;AAFD,sCAEC;AAED,SAAgB,WAAW,CAAE,IAAY;IACvC,OAAO,IAAI,MAAM,CAAC,4BAAqB,IAAI,mBAAgB,EAAE,KAAK,CAAC,CAAA;AACrE,CAAC;AAFD,kCAEC;AAED,SAAgB,WAAW,CAAE,IAAS,EAAE,OAAY;IAClD,IAAM,aAAa,GAAG,EAAE,CAAA;IACxB,IAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEjC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACxC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;YAC9B,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;SACtB;KACF;IAED,OAAO,aAAa,CAAA;AACtB,CAAC;AAXD,kCAWC"} -------------------------------------------------------------------------------- /dist/src/helpers/nomenclature.d.ts: -------------------------------------------------------------------------------- 1 | export declare function formatName(_fileName: string): string; 2 | -------------------------------------------------------------------------------- /dist/src/helpers/nomenclature.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.formatName = void 0; 4 | function formatName(_fileName) { 5 | var fileName = _fileName.replaceAll('.ts', '').replaceAll('.tsx', '').replaceAll('[', '').replaceAll(']', ''); 6 | var name = fileName; 7 | if (fileName.indexOf('.') !== -1) { 8 | name = fileName.split('.').map(function (word) { return word[0].toUpperCase() + word.substring(1); }).join(''); 9 | } 10 | else if (fileName.indexOf('-') !== -1) { 11 | name = fileName.split('-').map(function (word) { return word[0].toUpperCase() + word.substring(1); }).join(''); 12 | } 13 | else { 14 | name = name[0].toUpperCase() + name.substring(1); 15 | } 16 | return name; 17 | } 18 | exports.formatName = formatName; 19 | //# sourceMappingURL=nomenclature.js.map -------------------------------------------------------------------------------- /dist/src/helpers/nomenclature.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"nomenclature.js","sourceRoot":"","sources":["../../../src/helpers/nomenclature.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAE,SAAiB;IAC3C,IAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;IAC/G,IAAI,IAAI,GAAG,QAAQ,CAAA;IAEnB,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QAChC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAzC,CAAyC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KAC3F;SAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE;QACvC,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAA,IAAI,IAAI,OAAA,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAzC,CAAyC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;KAC3F;SAAM;QACL,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;KACjD;IAED,OAAO,IAAI,CAAA;AACb,CAAC;AAbD,gCAaC"} -------------------------------------------------------------------------------- /dist/src/printer.d.ts: -------------------------------------------------------------------------------- 1 | import 'colors'; 2 | import { Command } from 'commander'; 3 | export declare const Printer: Command; 4 | -------------------------------------------------------------------------------- /dist/src/printer.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"printer.js","sourceRoot":"","sources":["../../src/printer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAe;AACf,uCAAmC;AACnC,qCAAmC;AACnC,mCAAyC;AACzC,wCAAqD;AACrD,oDAA0D;AAC1D,4CAAkD;AAClD,0CAAgD;AAChD,0CAAgD;AAChD,8CAAoD;AACpD,gDAAsD;AACtD,4CAAkD;AAClD,wCAA8C;AAC9C,0CAAgD;AAChD,0CAAgD;AAChD,8CAA4C;AAC5C,8CAAyD;AACzD,sDAA0E;AAE7D,QAAA,OAAO,GAAG,IAAI,mBAAO,CAAC,aAAa,CAAC,CAAA;AAEjD,eAAO;KACJ,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,6DAA6D,CAAC;KAC1E,MAAM,CAAC,iBAAiB,EAAE,uBAAuB,EAAE,KAAK,CAAC;KACzD,MAAM,CAAC,gBAAgB,EAAE,qBAAqB,EAAE,KAAK,CAAC,CAAA;AAEzD,eAAO;KACJ,OAAO,CAAC,YAAY,CAAC;KACrB,WAAW,CAAC,gCAAgC,CAAC;KAC7C,MAAM,CAAC,UAAM,IAAI;;;;gBAChB,IAAA,uBAAc,GAAE,CAAA;gBAChB,IAAA,SAAG,EAAC,oCAAoC,CAAC,KAAK,CAAC,CAAA;gBAC/C,qBAAM,IAAA,wBAAkB,EAAC,IAAI,IAAI,GAAG,CAAC,EAAA;;gBAArC,SAAqC,CAAA;;;;KACtC,CAAC,CAAA;AAEJ,eAAO;KACJ,OAAO,CAAC,kBAAkB,CAAC;KAC3B,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,UAAM,IAAI;;;;gBAChB,IAAA,uBAAc,GAAE,CAAA;gBAChB,IAAA,SAAG,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AgD,CAAC;KAC7D,MAAM,CAAC,UAAM,KAAK;;;;gBACjB,IAAA,uBAAc,GAAE,CAAA;gBAChB,IAAA,SAAG,EAAC,4DAA2C,KAAK,CAAE,CAAC,KAAK,CAAC,CAAA;gBAC7D,qBAAM,IAAA,mBAAY,EAAC,KAAK,CAAC,EAAA;;gBAAzB,SAAyB,CAAA;;;;KAC1B,CAAC,CAAA;AAEJ,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE;IACnC,eAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;CAC5B"} -------------------------------------------------------------------------------- /dist/src/templates/api.template: -------------------------------------------------------------------------------- 1 | import { NextRequest } from 'next/server' 2 | import { getSession } from 'util/session' 3 | 4 | export async function GET(req: NextRequest) { 5 | const session = await getSession() 6 | const { searchParams } = new URL(req.url) 7 | 8 | try { 9 | return Response.json( 10 | { 11 | status: 'OK', 12 | result: null 13 | }, 14 | { status: 200 } 15 | ) 16 | } catch (error) { 17 | console.error(error) 18 | return Response.json( 19 | { 20 | status: 'ERROR', 21 | error 22 | }, 23 | { status: 500 } 24 | ) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /dist/src/templates/component/component.nostyle.template: -------------------------------------------------------------------------------- 1 | export interface {{name}}I {} 2 | 3 | export function {{name}}({}: {{name}}I) { 4 | return ( 5 |
6 |

Component {{name}}

7 |
8 | ) 9 | } 10 | 11 | export default {{name}} 12 | -------------------------------------------------------------------------------- /dist/src/templates/component/component.template: -------------------------------------------------------------------------------- 1 | import { {{name}}Style } from '{{path}}/{{prefix}}.style' 2 | 3 | export interface {{name}}I {} 4 | 5 | export function {{name}}({}: {{name}}I) { 6 | return ( 7 | <{{name}}Style> 8 |

Component {{name}}

9 | 10 | ) 11 | } 12 | 13 | export default {{name}} 14 | -------------------------------------------------------------------------------- /dist/src/templates/component/index.nostyle.template: -------------------------------------------------------------------------------- 1 | export * from '{{path}}/{{prefix}}.component' 2 | -------------------------------------------------------------------------------- /dist/src/templates/component/index.template: -------------------------------------------------------------------------------- 1 | export * from '{{path}}/{{prefix}}.component' 2 | export * from '{{path}}/{{prefix}}.style' 3 | -------------------------------------------------------------------------------- /dist/src/templates/component/style.template: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | export const {{name}}Style = styled.div`` 4 | -------------------------------------------------------------------------------- /dist/src/templates/component/test.template: -------------------------------------------------------------------------------- 1 | import { {{name}}Component } from '{{path}}/{{prefix}}.component' 2 | import { {{name}} } from '{{path}}/{{prefix}}.connect' 3 | -------------------------------------------------------------------------------- /dist/src/templates/crud.template: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from 'next/server' 2 | import { getSession, createResponse } from 'util/session' 3 | import prisma from 'prisma/client' 4 | 5 | // Creates a new record 6 | export async function POST(req: NextRequest) { 7 | const res = new NextResponse() 8 | const session = await getSession(req, res) 9 | try { 10 | const data = await req.json() 11 | const {{model}} = await prisma.{{model}}.create({ data }) 12 | 13 | return createResponse( 14 | res, 15 | JSON.stringify({ 16 | status: 'OK', 17 | {{model}} 18 | }), 19 | { status: 200 } 20 | ) 21 | } catch (error) { 22 | console.error(error) 23 | return createResponse( 24 | res, 25 | JSON.stringify({ status: 'ERROR', error }), 26 | { status: 500 } 27 | ) 28 | } 29 | } 30 | 31 | // Updates an existing record by its @id 32 | export async function PATCH(req: NextRequest) { 33 | const res = new NextResponse() 34 | const session = await getSession(req, res) 35 | try { 36 | const data = await req.json() 37 | const id = data.id 38 | delete data.id 39 | 40 | const {{model}} = await prisma.{{model}}.update({ 41 | where: { id }, 42 | data, 43 | }) 44 | 45 | return createResponse( 46 | res, 47 | JSON.stringify({ 48 | status: 'OK', 49 | {{model}} 50 | }), 51 | { status: 200 } 52 | ) 53 | } catch (error) { 54 | console.error(error) 55 | return createResponse( 56 | res, 57 | JSON.stringify({ status: 'ERROR', error }), 58 | { status: 500 } 59 | ) 60 | } 61 | } 62 | 63 | // Deletes a record by its @id 64 | export async function DELETE(req: NextRequest) { 65 | const res = new NextResponse() 66 | const session = await getSession(req, res) 67 | try { 68 | const { searchParams } = new URL(req.url) 69 | const id = searchParams.get('id') 70 | 71 | const {{model}} = await prisma.{{model}}.delete({ 72 | where: { id } 73 | }) 74 | 75 | return createResponse( 76 | res, 77 | JSON.stringify({ 78 | status: 'OK', 79 | {{model}} 80 | }), 81 | { status: 200 } 82 | ) 83 | } catch (error) { 84 | console.error(error) 85 | return createResponse( 86 | res, 87 | JSON.stringify({ status: 'ERROR', error }), 88 | { status: 500 } 89 | ) 90 | } 91 | } 92 | 93 | // Lists results or gets a specific ID 94 | export async function GET(req: NextRequest) { 95 | const res = new NextResponse() 96 | const session = await getSession(req, res) 97 | try { 98 | const { searchParams } = new URL(req.url) 99 | const id = searchParams.get('id') 100 | const skip = searchParams.get('skip') 101 | 102 | if (id) { 103 | const {{model}} = await prisma.{{model}}.findUnique({ 104 | where: { id } 105 | }) 106 | 107 | return createResponse( 108 | res, 109 | JSON.stringify({ 110 | status: 'OK', 111 | result: {{model}} 112 | }), 113 | { status: 200 } 114 | ) 115 | } else { 116 | const results = await prisma.{{model}}.findMany({ 117 | take: 10, 118 | skip: Number(skip || '0') 119 | }) 120 | 121 | return createResponse( 122 | res, 123 | JSON.stringify({ 124 | status: 'OK', 125 | results 126 | }), 127 | { status: 200 } 128 | ) 129 | } 130 | } catch (error) { 131 | console.error(error) 132 | return createResponse( 133 | res, 134 | JSON.stringify({ status: 'ERROR', error }), 135 | { status: 500 } 136 | ) 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /dist/src/templates/error.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { useEffect } from 'react' 4 | 5 | export interface ErrorI { 6 | error: Error 7 | reset: () => void 8 | } 9 | 10 | export default function ErrorComponent({ error, reset }: ErrorI) { 11 | useEffect(() => { 12 | console.error(error) 13 | }, [error]) 14 | 15 | return ( 16 |
17 |

Something Went Wrong!

18 | reset()}> 19 | Reload Page 20 | 21 |
22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /dist/src/templates/layout.template: -------------------------------------------------------------------------------- 1 | import { ReactNode, Suspense } from 'react' 2 | 3 | export const metadata = { 4 | 5 | } 6 | 7 | export interface LayoutI { 8 | children: ReactNode 9 | } 10 | 11 | export default function LayoutComponent({ children }: LayoutI) { 12 | return ( 13 | 14 | {children} 15 | 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /dist/src/templates/loading.template: -------------------------------------------------------------------------------- 1 | import { Suspense } from 'react' 2 | 3 | export default function LoadingComponent() { 4 | return ( 5 | 6 |

Loading...

7 |
8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /dist/src/templates/new/.env.dev.local.template: -------------------------------------------------------------------------------- 1 | DATABASE_URL="http://localhost:1906" 2 | SESSION_SECRET="{{password}}" -------------------------------------------------------------------------------- /dist/src/templates/new/.eslintrc.js.template: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es2021: true, 5 | node: true 6 | }, 7 | extends: [ 8 | 'next/core-web-vitals', 9 | 'plugin:react/recommended', 10 | 'standard', 11 | 'prettier', 12 | 'plugin:prettier/recommended' 13 | ], 14 | parser: '@typescript-eslint/parser', 15 | parserOptions: { 16 | ecmaFeatures: { 17 | jsx: true 18 | }, 19 | ecmaVersion: 'latest', 20 | sourceType: 'module' 21 | }, 22 | plugins: ['react', '@typescript-eslint'], 23 | rules: { 24 | 'prettier/prettier': [ 25 | 'warn', 26 | { 27 | singleQuote: true, 28 | semi: false, 29 | trailingComma: 'none' 30 | } 31 | ], 32 | 'react/react-in-jsx-scope': 0, 33 | 'no-empty-pattern': 0, 34 | 'no-unused-vars': 0, 35 | 'max-statements-per-line': 0, 36 | 'new-cap': 0 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /dist/src/templates/new/.gitignore.template: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-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 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.local 78 | .env.test.local 79 | .env.production.local 80 | 81 | # parcel-bundler cache (https://parceljs.org/) 82 | .cache 83 | .parcel-cache 84 | 85 | # Next.js build output 86 | .next 87 | out 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # vuepress v2.x temp and cache directory 99 | .temp 100 | .cache 101 | 102 | # Serverless directories 103 | .serverless/ 104 | 105 | # FuseBox cache 106 | .fusebox/ 107 | 108 | # DynamoDB Local files 109 | .dynamodb/ 110 | 111 | # TernJS port file 112 | .tern-port 113 | 114 | # Stores VSCode versions used for testing VSCode extensions 115 | .vscode-test 116 | 117 | # yarn v2 118 | .yarn/cache 119 | .yarn/unplugged 120 | .yarn/build-state.yml 121 | .yarn/install-state.gz 122 | .pnp.* 123 | -------------------------------------------------------------------------------- /dist/src/templates/new/README.md.template: -------------------------------------------------------------------------------- 1 | # Printer Template 2 | 3 | ## Commands 4 | 5 | ### `yarn dev` 6 | 7 | Start the dev server on `http://localhost:4200`. 8 | 9 | ### `yarn build` 10 | 11 | Build the Next.js output in `dist`. 12 | 13 | ### `yarn start` 14 | 15 | Start a production server on `http://localhost:3000`. 16 | 17 | ### `yarn lint` | `yarn lint --fix` 18 | 19 | Runs `eslint` on the project and cleans up any style issues. 20 | 21 | ### `yarn scss` 22 | 23 | Creates a debug `printer.css` file to review build outputs. 24 | 25 | ### `yarn prisma` 26 | 27 | Creates the `prisma` client. 28 | 29 | ### `yarn prisma:update` 30 | 31 | Creates the `prisma` client and then pushes schema updates to the database. 32 | 33 | ## Documentation 34 | 35 | Review the documentation on [prntr.click/docs](https://prntr.click/docs). 36 | 37 | Review the [CHANGELOG](https://github.com/PrinterFramework/CLI/blob/master/CHANGELOG.md) for any updates made to the project. -------------------------------------------------------------------------------- /dist/src/templates/new/_app.template: -------------------------------------------------------------------------------- 1 | import 'scss/printer.scss' 2 | import App, { AppContext, AppInitialProps } from 'next/app' 3 | import { wrapper } from 'redux/wrapper' 4 | import Head from 'next/head' 5 | 6 | export class AppComponent extends App { 7 | public static getInitialProps = async ({ Component, ctx }: AppContext) => { 8 | return { 9 | pageProps: { 10 | ...(Component.getInitialProps 11 | ? await Component.getInitialProps(ctx) 12 | : {}) 13 | }, 14 | appProp: ctx.pathname 15 | } 16 | } 17 | 18 | public render() { 19 | const { Component, pageProps } = this.props 20 | return ( 21 | <> 22 | 23 | Printer 24 | 25 | 26 | 27 | ) 28 | } 29 | } 30 | 31 | export default wrapper.withRedux(AppComponent) 32 | -------------------------------------------------------------------------------- /dist/src/templates/new/_document.template: -------------------------------------------------------------------------------- 1 | import { Html, Head, Main, NextScript } from 'next/document' 2 | 3 | export default function Document() { 4 | return ( 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | ) 13 | } 14 | -------------------------------------------------------------------------------- /dist/src/templates/new/app/layout.tsx.template: -------------------------------------------------------------------------------- 1 | import 'scss/printer.scss' 2 | import { Metadata } from 'next' 3 | import { ReactNode, Suspense } from 'react' 4 | import { ReduxProvider } from 'redux/provider' 5 | 6 | export const metadata: Metadata = { 7 | title: 'Printer', 8 | description: 'Automation Tooling for Next, Redux and Prisma' 9 | } 10 | 11 | export interface LayoutI { 12 | children: ReactNode 13 | } 14 | 15 | export default function RootLayout({ children }: LayoutI) { 16 | return ( 17 | 18 | 19 | 20 | {children} 21 | 22 | 23 | 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /dist/src/templates/new/app/page.tsx.template: -------------------------------------------------------------------------------- 1 | import Counter from 'components/counter' 2 | 3 | export default function RootPage() { 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /dist/src/templates/new/babelrc.template: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ]], 3 | "presets": ["next/babel"] 4 | } 5 | -------------------------------------------------------------------------------- /dist/src/templates/new/components/counter.tsx.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { decrement, increment, reset } from 'redux/slice/counter' 3 | import { useDispatch, useSelector } from 'redux/store' 4 | 5 | export interface CounterI {} 6 | 7 | export function Counter({}: CounterI) { 8 | const count = useSelector((state) => state.counter.data.value) 9 | const dispatch = useDispatch() 10 | 11 | return ( 12 |
13 |

Counter is at {count}

14 | 15 | 26 |
27 | ) 28 | } 29 | 30 | export default Counter 31 | -------------------------------------------------------------------------------- /dist/src/templates/new/env.dev.template: -------------------------------------------------------------------------------- 1 | DATABASE_URL="http://localhost:1906" -------------------------------------------------------------------------------- /dist/src/templates/new/eslintrc.template: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es2021: true, 5 | node: true 6 | }, 7 | extends: [ 8 | 'plugin:react/recommended', 9 | 'standard', 10 | 'prettier', 11 | 'plugin:prettier/recommended' 12 | ], 13 | parser: '@typescript-eslint/parser', 14 | parserOptions: { 15 | ecmaFeatures: { 16 | jsx: true 17 | }, 18 | ecmaVersion: 'latest', 19 | sourceType: 'module' 20 | }, 21 | plugins: ['react', '@typescript-eslint'], 22 | rules: { 23 | 'prettier/prettier': [ 24 | 'warn', 25 | { 26 | singleQuote: true, 27 | semi: false, 28 | trailingComma: 'none' 29 | } 30 | ], 31 | 'react/react-in-jsx-scope': 0, 32 | 'no-empty-pattern': 0, 33 | 'no-unused-vars': 0, 34 | 'max-statements-per-line': 0, 35 | 'new-cap': 0 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /dist/src/templates/new/gitignore.template: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-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 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.development.local 78 | .env.test.local 79 | .env.production.local 80 | .env.local 81 | 82 | # parcel-bundler cache (https://parceljs.org/) 83 | .cache 84 | .parcel-cache 85 | 86 | # Next.js build output 87 | .next 88 | out 89 | 90 | # Gatsby files 91 | .cache/ 92 | # Comment in the public line in if your project uses Gatsby and not Next.js 93 | # https://nextjs.org/blog/next-9-1#public-directory-support 94 | # public 95 | 96 | # vuepress build output 97 | .vuepress/dist 98 | 99 | # vuepress v2.x temp and cache directory 100 | .temp 101 | .cache 102 | 103 | # Serverless directories 104 | .serverless/ 105 | 106 | # FuseBox cache 107 | .fusebox/ 108 | 109 | # DynamoDB Local files 110 | .dynamodb/ 111 | 112 | # TernJS port file 113 | .tern-port 114 | 115 | # Stores VSCode versions used for testing VSCode extensions 116 | .vscode-test 117 | 118 | # yarn v2 119 | .yarn/cache 120 | .yarn/unplugged 121 | .yarn/build-state.yml 122 | .yarn/install-state.gz 123 | .pnp.* 124 | -------------------------------------------------------------------------------- /dist/src/templates/new/index.template: -------------------------------------------------------------------------------- 1 | export interface IndexI {} 2 | 3 | export default function Index({}: IndexI) { 4 | return

Page Index

5 | } 6 | -------------------------------------------------------------------------------- /dist/src/templates/new/middleware.tsx.template: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from 'next/server' 2 | import { getSession } from 'util/session' 3 | 4 | // See https://nextjs.org/docs/app/building-your-application/routing/middleware to manage client side routing with session states. 5 | export async function middleware(req: NextRequest) { 6 | const res = new NextResponse() 7 | const session = await getSession() 8 | } 9 | 10 | export const config = {} 11 | -------------------------------------------------------------------------------- /dist/src/templates/new/next.config.js.template: -------------------------------------------------------------------------------- 1 | module.exports = {} 2 | -------------------------------------------------------------------------------- /dist/src/templates/new/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@printerframework/template", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next dev --port 4200", 6 | "build": "npm run prisma && next build", 7 | "start": "next start", 8 | "lint": "eslint . --ext ts,tsx --resolve-plugins-relative-to .", 9 | "scss": "node-sass -r scss/printer.scss -o scss/debug", 10 | "prisma": "npx prisma generate", 11 | "prisma:update": "npx prisma generate && npx prisma db push" 12 | }, 13 | "dependencies": { 14 | "@prisma/client": "5.6.0", 15 | "@reduxjs/toolkit": "1.9.7", 16 | "iron-session": "8.0.1", 17 | "next": "14.0.3", 18 | "prisma": "5.6.0", 19 | "react": "18.2.0", 20 | "react-dom": "18.2.0", 21 | "react-redux": "8.1.3", 22 | "sass": "1.69.5", 23 | "superagent": "8.1.2" 24 | }, 25 | "devDependencies": { 26 | "@types/node": "20.9.5", 27 | "@types/superagent": "4.1.22", 28 | "@typescript-eslint/eslint-plugin": "6.12.0", 29 | "@typescript-eslint/parser": "6.12.0", 30 | "eslint": "8.54.0", 31 | "eslint-config-next": "14.0.3", 32 | "eslint-config-prettier": "9.0.0", 33 | "eslint-config-standard": "17.1.0", 34 | "eslint-plugin-import": "2.29.0", 35 | "eslint-plugin-n": "16.3.1", 36 | "eslint-plugin-node": "11.1.0", 37 | "eslint-plugin-prettier": "5.0.1", 38 | "eslint-plugin-promise": "6.1.1", 39 | "eslint-plugin-react": "7.33.2", 40 | "node-sass": "9.0.0", 41 | "prettier": "3.1.0", 42 | "typescript": "5.3.2" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /dist/src/templates/new/package.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "print-template", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "prepare": "husky install", 6 | "dev": "next dev --port 4200", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "eslint . --ext ts,tsx --resolve-plugins-relative-to .", 10 | "scss": "node-sass -r scss/printer.scss -o scss/debug", 11 | "prisma": "npx prisma generate", 12 | "prisma:update": "npx prisma generate && npx prisma db push" 13 | }, 14 | "dependencies": { 15 | "@prisma/client": "^4.1.0", 16 | "@reduxjs/toolkit": "^1.7.1", 17 | "iron-session": "^6.1.2", 18 | "next": "^12.0.7", 19 | "next-redux-wrapper": "^7.0.5", 20 | "prisma": "^4.1.0", 21 | "react": "^17.0.2", 22 | "react-dom": "^17.0.2", 23 | "react-redux": "^7.2.6", 24 | "sass": "^1.54.3", 25 | "styled-components": "^5.3.3", 26 | "superagent": "^8.0.9" 27 | }, 28 | "devDependencies": { 29 | "@types/node": "^17.0.13", 30 | "@types/superagent": "^4.1.16", 31 | "@typescript-eslint/eslint-plugin": "^5.14.0", 32 | "@typescript-eslint/parser": "^5.14.0", 33 | "babel-plugin-styled-components": "^2.0.2", 34 | "eslint": "^8.10.0", 35 | "eslint-config-prettier": "^8.5.0", 36 | "eslint-config-standard": "^16.0.3", 37 | "eslint-plugin-import": "^2.25.4", 38 | "eslint-plugin-node": "^11.1.0", 39 | "eslint-plugin-prettier": "^4.0.0", 40 | "eslint-plugin-promise": "^5.2.0", 41 | "eslint-plugin-react": "^7.29.3", 42 | "husky": "^7.0.4", 43 | "node-sass": "^7.0.1", 44 | "prettier": "^2.5.1", 45 | "typescript": "^4.5.4" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /dist/src/templates/new/precommit.template: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . "$(dirname "$0")/_/husky.sh" 3 | 4 | npm run lint --fix 5 | npm run scss 6 | npm run build 7 | -------------------------------------------------------------------------------- /dist/src/templates/new/printer.config.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "crud": { 3 | "create": true, 4 | "update": true, 5 | "delete": true, 6 | "list": true, 7 | "get": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /dist/src/templates/new/printer.config.template: -------------------------------------------------------------------------------- 1 | { 2 | "componentFolder": false, 3 | "component": { 4 | "index": true, 5 | "component": true, 6 | "style": true, 7 | "test": false 8 | }, 9 | "crud": { 10 | "create": true, 11 | "update": true, 12 | "delete": true, 13 | "list": true, 14 | "get": true 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /dist/src/templates/new/printer.template: -------------------------------------------------------------------------------- 1 | @import "/scss/reset.scss"; 2 | @import "/scss/theme.scss"; 3 | @import "/scss/ui.scss"; -------------------------------------------------------------------------------- /dist/src/templates/new/prisma.client.template: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from '@prisma/client' 2 | 3 | let prisma: PrismaClient 4 | 5 | if (process.env.NODE_ENV === 'production') { 6 | prisma = new PrismaClient() 7 | } else { 8 | if (!global.prisma) { 9 | global.prisma = new PrismaClient() 10 | } 11 | 12 | prisma = global.prisma 13 | } 14 | 15 | export default prisma 16 | -------------------------------------------------------------------------------- /dist/src/templates/new/prisma/client.ts.template: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from '@prisma/client' 2 | 3 | let prisma: PrismaClient 4 | 5 | if (process.env.NODE_ENV === 'production') { 6 | prisma = new PrismaClient({ log: [] }) 7 | } else { 8 | if (!global.prisma) { 9 | global.prisma = new PrismaClient({ log: [] }) 10 | } 11 | 12 | prisma = global.prisma 13 | } 14 | 15 | export default prisma 16 | -------------------------------------------------------------------------------- /dist/src/templates/new/prisma/schema.prisma.template: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "mysql" 7 | url = env("DATABASE_URL") 8 | relationMode = "prisma" 9 | } 10 | 11 | model Account { 12 | id String @id @default(uuid()) @db.Char(36) 13 | username String @unique @db.VarChar(128) 14 | posts Post[] 15 | dateCreated DateTime @default(now()) 16 | dateUpdated DateTime @updatedAt 17 | 18 | @@index(dateCreated) 19 | } 20 | 21 | model Post { 22 | id String @id @default(uuid()) @db.Char(36) 23 | accountId String @db.VarChar(128) 24 | title String @db.VarChar(256) 25 | content String @db.Text() 26 | account Account @relation(fields: accountId, references: id) 27 | dateCreated DateTime @default(now()) 28 | dateUpdated DateTime @updatedAt 29 | 30 | @@index(accountId) 31 | @@index(dateCreated) 32 | } 33 | -------------------------------------------------------------------------------- /dist/src/templates/new/readme.template: -------------------------------------------------------------------------------- 1 | # Printer Template 2 | 3 | ## Commands 4 | 5 | ### `yarn dev` 6 | 7 | Start the dev server on `http://localhost:4200`. 8 | 9 | ### `yarn build` 10 | 11 | Build the Next.js output in `dist`. 12 | 13 | ### `yarn start` 14 | 15 | Start a production server on `http://localhost:3000`. 16 | 17 | ### `yarn lint` | `yarn lint --fix` 18 | 19 | Runs `eslint` on the project and cleans up any style issues. 20 | 21 | ### `yarn scss` 22 | 23 | Creates a debug `printer.css` file to review build outputs. 24 | 25 | ### `yarn prisma` 26 | 27 | Creates the `prisma` client. 28 | 29 | ### `yarn prisma:update` 30 | 31 | Creates the `prisma` client and then pushes schema updates to the database. 32 | 33 | ## Documentation 34 | 35 | Review the documentation on [prntr.click/docs](https://prntr.click/docs). 36 | 37 | Review the [CHANGELOG](https://github.com/PrinterFramework/CLI/blob/master/CHANGELOG.md) for any updates made to the project. -------------------------------------------------------------------------------- /dist/src/templates/new/reducer.template: -------------------------------------------------------------------------------- 1 | export const reducer = { } 2 | -------------------------------------------------------------------------------- /dist/src/templates/new/redux/hooks.tsx.template: -------------------------------------------------------------------------------- 1 | import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' 2 | import type { RootState, AppDispatch } from 'redux/store' 3 | 4 | export const useAppDispatch = () => useDispatch() 5 | export const useAppSelector: TypedUseSelectorHook = useSelector 6 | -------------------------------------------------------------------------------- /dist/src/templates/new/redux/provider.tsx.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { ReactNode } from 'react' 3 | import { reduxStore } from 'redux/store' 4 | import { Provider } from 'react-redux' 5 | 6 | export interface ReduxProviderI { 7 | children: ReactNode 8 | } 9 | 10 | export function ReduxProvider({ children }: ReduxProviderI) { 11 | return {children} 12 | } 13 | -------------------------------------------------------------------------------- /dist/src/templates/new/redux/reducer.tsx.template: -------------------------------------------------------------------------------- 1 | import { counterSlice } from 'redux/slice/counter' 2 | 3 | export const reducer = { 4 | counter: counterSlice.reducer 5 | } 6 | -------------------------------------------------------------------------------- /dist/src/templates/new/redux/reducers.json.template: -------------------------------------------------------------------------------- 1 | [ 2 | "counter" 3 | ] -------------------------------------------------------------------------------- /dist/src/templates/new/redux/slice/counter.tsx.template: -------------------------------------------------------------------------------- 1 | import { createSlice, PayloadAction } from '@reduxjs/toolkit' 2 | import CounterType from 'types/counter' 3 | 4 | export const counterInitialState = { 5 | // @printer::inject::counter 6 | data: { 7 | value: 0 8 | } as CounterType 9 | } 10 | 11 | export const counterSlice = createSlice({ 12 | name: 'counter', 13 | initialState: counterInitialState, 14 | reducers: { 15 | // @printer::inject 16 | reset: (state) => { 17 | state.data.value = 0 18 | }, 19 | // @printer::inject 20 | increment: (state, action: PayloadAction) => { 21 | state.data.value += action.payload 22 | }, 23 | // @printer::inject 24 | decrement: (state, action: PayloadAction) => { 25 | state.data.value -= action.payload 26 | } 27 | } 28 | }) 29 | 30 | export const { increment, decrement, reset } = counterSlice.actions 31 | -------------------------------------------------------------------------------- /dist/src/templates/new/redux/store.tsx.template: -------------------------------------------------------------------------------- 1 | import { configureStore, type ThunkAction, type Action } from '@reduxjs/toolkit' 2 | import { 3 | useSelector as useReduxSelector, 4 | useDispatch as useReduxDispatch, 5 | type TypedUseSelectorHook 6 | } from 'react-redux' 7 | import { reducer } from 'redux/reducer' 8 | 9 | export const reduxStore = configureStore({ 10 | reducer, 11 | middleware: (getDefaultMiddleware) => 12 | getDefaultMiddleware({ 13 | serializableCheck: false 14 | }) 15 | }) 16 | 17 | export type ReduxStore = typeof reduxStore 18 | export type ReduxState = ReturnType 19 | export type ReduxDispatch = typeof reduxStore.dispatch 20 | export type ReduxThunkAction = ThunkAction< 21 | ReturnType, 22 | ReduxState, 23 | unknown, 24 | Action 25 | > 26 | 27 | export const useDispatch = () => useReduxDispatch() 28 | export const useSelector: TypedUseSelectorHook = useReduxSelector 29 | -------------------------------------------------------------------------------- /dist/src/templates/new/reset.template: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, 2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 3 | a, abbr, acronym, address, big, cite, code, 4 | del, dfn, em, img, ins, kbd, q, s, samp, 5 | small, strike, strong, sub, sup, tt, var, 6 | b, u, i, center, 7 | dl, dt, dd, ol, ul, li, 8 | fieldset, form, label, legend, 9 | table, caption, tbody, tfoot, thead, tr, th, td, 10 | article, aside, canvas, details, embed, 11 | figure, figcaption, footer, header, hgroup, 12 | menu, nav, output, ruby, section, summary, 13 | time, mark, audio, video { 14 | margin: 0; 15 | padding: 0; 16 | border: 0; 17 | font-size: 100%; 18 | font: inherit; 19 | vertical-align: baseline; 20 | } 21 | /* HTML5 display-role reset for older browsers */ 22 | article, aside, details, figcaption, figure, 23 | footer, header, hgroup, menu, nav, section { 24 | display: block; 25 | } 26 | body { 27 | line-height: 1.5; 28 | } 29 | ol, ul { 30 | list-style: none; 31 | } 32 | blockquote, q { 33 | quotes: none; 34 | } 35 | blockquote:before, blockquote:after, 36 | q:before, q:after { 37 | content: ''; 38 | content: none; 39 | } 40 | table { 41 | border-collapse: collapse; 42 | border-spacing: 0; 43 | } 44 | -------------------------------------------------------------------------------- /dist/src/templates/new/schema.prisma.template: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "mysql" 7 | url = env("DATABASE_URL") 8 | relationMode = "prisma" 9 | } 10 | 11 | model Account { 12 | id String @id @default(uuid()) @db.Char(36) 13 | username String @unique @db.VarChar(128) 14 | posts Posts[] 15 | dateCreated DateTime @default(now()) 16 | dateUpdated DateTime @updatedAt 17 | 18 | @@index(dateCreated) 19 | } 20 | 21 | model Posts { 22 | id String @id @default(uuid()) @db.Char(36) 23 | accountId String @db.VarChar(128) 24 | title String @db.VarChar(256) 25 | content String @db.Text() 26 | account Account @relation(fields: accountId, references: id) 27 | dateCreated DateTime @default(now()) 28 | dateUpdated DateTime @updatedAt 29 | 30 | @@index(accountId) 31 | @@index(dateCreated) 32 | } 33 | -------------------------------------------------------------------------------- /dist/src/templates/new/scss/index.scss.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | 3 | section.root-page { 4 | h2 { 5 | font-size: 32px; 6 | padding: 0 0 15px 0; 7 | } 8 | 9 | div.buttons { 10 | display: flex; 11 | align-items: center; 12 | justify-content: center; 13 | 14 | a.button { 15 | margin: 15px; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /dist/src/templates/new/scss/printer.scss.template: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&family=Oswald:wght@300;400;500;600;700&display=swap'); 2 | @import "/scss/reset.scss"; 3 | @import "/scss/theme.scss"; 4 | @import "/scss/ui.scss"; 5 | @import "/scss/index.scss"; -------------------------------------------------------------------------------- /dist/src/templates/new/scss/reset.scss.template: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, 2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 3 | a, abbr, acronym, address, big, cite, code, 4 | del, dfn, em, img, ins, kbd, q, s, samp, 5 | small, strike, strong, sub, sup, tt, var, 6 | b, u, i, center, 7 | dl, dt, dd, ol, ul, li, 8 | fieldset, form, label, legend, 9 | table, caption, tbody, tfoot, thead, tr, th, td, 10 | article, aside, canvas, details, embed, 11 | figure, figcaption, footer, header, hgroup, 12 | menu, nav, output, ruby, section, summary, 13 | time, mark, audio, video { 14 | margin: 0; 15 | padding: 0; 16 | border: 0; 17 | font-size: 100%; 18 | font: inherit; 19 | vertical-align: baseline; 20 | } 21 | /* HTML5 display-role reset for older browsers */ 22 | article, aside, details, figcaption, figure, 23 | footer, header, hgroup, menu, nav, section { 24 | display: block; 25 | } 26 | body { 27 | line-height: 1.5; 28 | } 29 | ol, ul { 30 | list-style: none; 31 | } 32 | blockquote, q { 33 | quotes: none; 34 | } 35 | blockquote:before, blockquote:after, 36 | q:before, q:after { 37 | content: ''; 38 | content: none; 39 | } 40 | table { 41 | border-collapse: collapse; 42 | border-spacing: 0; 43 | } 44 | -------------------------------------------------------------------------------- /dist/src/templates/new/scss/theme.scss.template: -------------------------------------------------------------------------------- 1 | $header-font: 'Oswald'; 2 | $body-font: 'Montserrat'; 3 | 4 | $primary: #C49A0F; 5 | $primary-light: #F2D577; 6 | 7 | $container-width: 1268px; 8 | $page-height: 100vh; 9 | 10 | @mixin bg-gradient() { 11 | background: rgb(41, 41, 41); 12 | background: radial-gradient(circle, rgba(41, 41, 41, 1) 0%, rgba(29, 29, 29, 1) 100%); 13 | } 14 | 15 | @mixin transition($property: all, $duration: 0.25s) { 16 | transition: $property $duration cubic-bezier(0.33, 1, 0.68, 1); 17 | } -------------------------------------------------------------------------------- /dist/src/templates/new/scss/ui.scss.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | 3 | * { 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | font-family: $body-font; 9 | @include bg-gradient(); 10 | color: white; 11 | margin: 0; 12 | padding: 0; 13 | overflow-x: hidden; 14 | } 15 | 16 | h1, h2, h3, h4, h5, h6 { 17 | font-family: $header-font; 18 | } 19 | 20 | h1 { 21 | font-size: 32px; 22 | } 23 | 24 | h2 { 25 | font-size: 24px; 26 | } 27 | 28 | h3 { 29 | font-size: 18px; 30 | } 31 | 32 | h4 { 33 | font-size: 16px; 34 | } 35 | 36 | a { 37 | cursor: pointer; 38 | } 39 | 40 | button, input, textarea { 41 | font-family: inherit; 42 | outline: none; 43 | } 44 | 45 | section.container, div.container { 46 | width: 100%; 47 | max-width: $container-width; 48 | margin: auto; 49 | &.page { 50 | min-height: $page-height; 51 | } 52 | &.flex { 53 | display: flex; 54 | flex-wrap: wrap; 55 | } 56 | &.center { 57 | display: flex; 58 | flex-direction: column; 59 | align-items: center; 60 | justify-content: center; 61 | } 62 | } 63 | 64 | a.button, button { 65 | display: flex; 66 | align-items: center; 67 | justify-content: center; 68 | width: 140px; 69 | height: 35px; 70 | border-radius: 3px; 71 | font-family: $body-font; 72 | font-size: 16px; 73 | font-weight: bold; 74 | background: $primary; 75 | color: white; 76 | text-decoration: none; 77 | margin: 0 15px 0 0; 78 | cursor: pointer; 79 | @include transition(); 80 | 81 | &:hover { 82 | background: $primary-light; 83 | } 84 | 85 | .i, .icon { 86 | margin: 0 8px 0 0; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /dist/src/templates/new/session.template: -------------------------------------------------------------------------------- 1 | export const password = '{{password}}'; 2 | 3 | export const Session = { 4 | cookieName: 'printer', 5 | password, 6 | cookieOptions: { 7 | secure: process.env.NODE_ENV === 'production', 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /dist/src/templates/new/theme.template: -------------------------------------------------------------------------------- 1 | $headerFont: 'Arial'; 2 | $copyFont: 'Arial'; 3 | -------------------------------------------------------------------------------- /dist/src/templates/new/tsconfig.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "lib": [ 5 | "DOM", 6 | "DOM.iterable", 7 | "ESNext" 8 | ], 9 | "baseUrl": "./", 10 | "allowJs": true, 11 | "skipLibCheck": true, 12 | "strict": false, 13 | "forceConsistentCasingInFileNames": true, 14 | "noEmit": true, 15 | "incremental": true, 16 | "esModuleInterop": true, 17 | "module": "CommonJS", 18 | "moduleResolution": "Node", 19 | "resolveJsonModule": true, 20 | "isolatedModules": true, 21 | "jsx": "preserve", 22 | "plugins": [ 23 | { "name": "next" } 24 | ] 25 | }, 26 | "include": [ 27 | "**/*.ts", 28 | "**/*.tsx", 29 | ".next/types/**/*.ts" 30 | ], 31 | "exclude": [ 32 | "node_modules" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /dist/src/templates/new/tsconfig.template: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "baseUrl": "./", 10 | "allowJs": true, 11 | "skipLibCheck": true, 12 | "strict": false, 13 | "forceConsistentCasingInFileNames": true, 14 | "noEmit": true, 15 | "incremental": true, 16 | "esModuleInterop": true, 17 | "module": "esnext", 18 | "moduleResolution": "node", 19 | "resolveJsonModule": true, 20 | "isolatedModules": true, 21 | "jsx": "preserve" 22 | }, 23 | "include": [ 24 | "next-env.d.ts", 25 | "**/*.ts", 26 | "**/*.tsx" 27 | ], 28 | "exclude": [ 29 | "node_modules" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /dist/src/templates/new/types/counter.tsx.template: -------------------------------------------------------------------------------- 1 | export interface CounterType { 2 | value: number 3 | } 4 | 5 | export default CounterType 6 | -------------------------------------------------------------------------------- /dist/src/templates/new/ui.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | 3 | * { 4 | transition: all 0.25s cubic-bezier(0.33, 1, 0.68, 1); 5 | box-sizing: border-box; 6 | } 7 | 8 | body { 9 | margin: 0; 10 | padding: 0; 11 | overflow-x: hidden; 12 | } 13 | 14 | h1, h2, h3, h4, h5, h6 { 15 | font-family: $headerFont; 16 | } 17 | 18 | h1 { 19 | font-size: 32px; 20 | } 21 | 22 | h2 { 23 | font-size: 24px; 24 | } 25 | 26 | h3 { 27 | font-size: 18px; 28 | } 29 | 30 | h4 { 31 | font-size: 16px; 32 | } 33 | 34 | a { 35 | cursor: pointer; 36 | } 37 | 38 | button, input, textarea { 39 | font-family: inherit; 40 | outline: none; 41 | } 42 | -------------------------------------------------------------------------------- /dist/src/templates/new/util/session.ts.template: -------------------------------------------------------------------------------- 1 | import { getIronSession } from 'iron-session' 2 | import { cookies } from 'next/headers' 3 | 4 | export const password = 5 | process.env.SESSION_SECRET || 6 | 'ad75fbbbddbf8005cb60e3089d6f156440f9c8ac1d13ad33a8e4758fdff73ff8' 7 | 8 | export interface SessionI { 9 | counter?: number 10 | } 11 | 12 | export function getSession() { 13 | return getIronSession(cookies(), { 14 | password, 15 | cookieName: 'printer', 16 | cookieOptions: { 17 | secure: process.env.NODE_ENV === 'production', 18 | maxAge: process.env.COOKIE_AGE 19 | ? Number(process.env.COOKIE_AGE) 20 | : undefined 21 | } 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /dist/src/templates/new/wrapper.template: -------------------------------------------------------------------------------- 1 | import { configureStore, ThunkAction } from '@reduxjs/toolkit' 2 | import { Action } from 'redux' 3 | import { createWrapper } from 'next-redux-wrapper' 4 | import { reducer } from 'redux/reducer' 5 | 6 | export function makeStore() { 7 | return configureStore({ reducer }) 8 | } 9 | 10 | export type AppStore = ReturnType 11 | export type AppState = ReturnType 12 | export type AppThunk = ThunkAction< 13 | ReturnType, 14 | AppState, 15 | unknown, 16 | Action 17 | > 18 | 19 | export const wrapper = createWrapper(makeStore) 20 | -------------------------------------------------------------------------------- /dist/src/templates/page.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | export interface {{name}}PageI { 4 | 5 | } 6 | 7 | export default function {{name}}Page({}: {{name}}PageI) { 8 | return ( 9 |
10 |

{{name}} Page

11 |
12 | ) 13 | } -------------------------------------------------------------------------------- /dist/src/templates/page.url.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | export interface {{name}}PageI { 4 | {{url_interface}} 5 | } 6 | 7 | export default function {{name}}Page({ {{url_variables}} }: {{name}}PageI) { 8 | return ( 9 |
10 |

{{name}} Page

11 |
12 | ) 13 | } -------------------------------------------------------------------------------- /dist/src/templates/scss.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | -------------------------------------------------------------------------------- /dist/src/templates/slice/reducer.template: -------------------------------------------------------------------------------- 1 | {{import}} 2 | 3 | export const reducer = { 4 | {{reducer}} 5 | } 6 | -------------------------------------------------------------------------------- /dist/src/templates/slice/slice.d.ts: -------------------------------------------------------------------------------- 1 | export declare function SliceTemplate(name: string): string; 2 | -------------------------------------------------------------------------------- /dist/src/templates/slice/slice.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.SliceTemplate = void 0; 4 | function SliceTemplate(name) { 5 | return "import { createSlice } from \"@reduxjs/toolkit\";\n\nexport const ".concat(name, "InitialState = {\n\n}\n\nexport const ").concat(name, "Slice = createSlice({\n name: '").concat(name, "',\n initialState: ").concat(name, "InitialState,\n reducers: {\n\n },\n});\n\nexport const { } = ").concat(name, "Slice.actions;"); 6 | } 7 | exports.SliceTemplate = SliceTemplate; 8 | //# sourceMappingURL=slice.js.map -------------------------------------------------------------------------------- /dist/src/templates/slice/slice.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"slice.js","sourceRoot":"","sources":["../../../../src/templates/slice/slice.ts"],"names":[],"mappings":";;;AAAA,SAAgB,aAAa,CAAE,IAAY;IACzC,OAAO,4EAEM,IAAI,mDAIJ,IAAI,+CACN,IAAI,mCACG,IAAI,iFAMH,IAAI,mBAAgB,CAAA;AACzC,CAAC;AAhBD,sCAgBC"} -------------------------------------------------------------------------------- /dist/src/templates/slice/slice.template: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit' 2 | 3 | export const {{name}}InitialState = {} 4 | 5 | export const {{name}}Slice = createSlice({ 6 | name: '{{name}}', 7 | initialState: {{name}}InitialState, 8 | reducers: {} 9 | }) 10 | 11 | export const {} = {{name}}Slice.actions 12 | -------------------------------------------------------------------------------- /dist/src/templates/slice/slice.ts: -------------------------------------------------------------------------------- 1 | export function SliceTemplate (name: string) { 2 | return `import { createSlice } from "@reduxjs/toolkit"; 3 | 4 | export const ${name}InitialState = { 5 | 6 | } 7 | 8 | export const ${name}Slice = createSlice({ 9 | name: '${name}', 10 | initialState: ${name}InitialState, 11 | reducers: { 12 | 13 | }, 14 | }); 15 | 16 | export const { } = ${name}Slice.actions;` 17 | } 18 | -------------------------------------------------------------------------------- /dist/src/templates/superagent.template: -------------------------------------------------------------------------------- 1 | const [loading, setLoading] = useState(false) 2 | const [error, setError] = useState(false) 3 | const [errorMessage, setErrorMessage] = useState('') 4 | 5 | async function {{type}}Request() { 6 | setLoading(true) 7 | setError(false) 8 | try { 9 | const payload = await {{type}}('/api/url') 10 | } catch (error) { 11 | console.error(error) 12 | setError(true) 13 | setErrorMessage('Something went wrong...') 14 | } 15 | setLoading(false) 16 | } 17 | 18 | useEffect(() => { 19 | {{type}}Request() 20 | }, [loading]) -------------------------------------------------------------------------------- /dist/src/templates/type.template: -------------------------------------------------------------------------------- 1 | export interface {{name}}Type { 2 | 3 | } 4 | 5 | export default {{name}}Type 6 | -------------------------------------------------------------------------------- /jest.config.ts: -------------------------------------------------------------------------------- 1 | export default { 2 | clearMocks: true, 3 | 4 | collectCoverage: true, 5 | collectCoverageFrom: ['src/**/*.ts'], 6 | coverageDirectory: 'test/coverage', 7 | coveragePathIgnorePatterns: [ 8 | 'node_modules', 9 | 'docs', 10 | 'dist', 11 | 'example', 12 | 'home', 13 | 'temporary', 14 | 'test/temporary' 15 | ], 16 | 17 | coverageProvider: 'v8', 18 | 19 | extensionsToTreatAsEsm: ['.ts'], 20 | globals: { 21 | 'ts-jest': { 22 | useESM: true 23 | } 24 | }, 25 | 26 | rootDir: '.', 27 | 28 | testMatch: [ 29 | '**/?(*.)+(spec|test).[tj]s?(x)' 30 | ], 31 | testPathIgnorePatterns: [ 32 | 'node_modules', 33 | 'docs', 34 | 'dist', 35 | 'example', 36 | 'test/temporary', 37 | 'src' 38 | ] 39 | } 40 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@printerframework/cli", 3 | "description": "🖨️ Automation Tooling for Next, Redux and Prisma.", 4 | "version": "2.2.5-1", 5 | "private": false, 6 | "preferGlobal": true, 7 | "repository": "https://github.com/PrinterFramework/CLI.git", 8 | "author": "Chris Cates ", 9 | "license": "AGPLv3", 10 | "scripts": { 11 | "start": "npm run build && node dist/src/printer.js", 12 | "build": "tsc && npx ts-node prepend.ts && npm run move", 13 | "move": "cp -r src/templates dist/src", 14 | "lint": "eslint src --ext ts", 15 | "test": "jest", 16 | "codecov": "CODECOV_TOKEN='0644b00b-7cc1-4392-9427-1e8387f28ffb' npx codecov", 17 | "convert": "npm run build && node dist/src/converter.js" 18 | }, 19 | "bin": { 20 | "printer": "./dist/src/printer.js" 21 | }, 22 | "devDependencies": { 23 | "@babel/preset-env": "^7.22.20", 24 | "@babel/preset-typescript": "^7.23.0", 25 | "@types/inquirer": "^9.0.3", 26 | "@types/jest": "^29.5.5", 27 | "@types/node": "^20.8.0", 28 | "@types/prompts": "^2.4.5", 29 | "@typescript-eslint/eslint-plugin": "^6.7.3", 30 | "@typescript-eslint/parser": "^6.7.3", 31 | "codecov": "^3.8.3", 32 | "eslint": "^8.50.0", 33 | "eslint-config-standard": "^17.1.0", 34 | "eslint-plugin-import": "^2.28.1", 35 | "eslint-plugin-n": "^16.1.0", 36 | "eslint-plugin-node": "^11.1.0", 37 | "eslint-plugin-promise": "^6.1.1", 38 | "husky": "^8.0.3", 39 | "jest": "^29.7.0", 40 | "ts-node": "^10.9.1", 41 | "typescript": "^5.2.2" 42 | }, 43 | "dependencies": { 44 | "colors": "^1.4.0", 45 | "commander": "^11.0.0", 46 | "fs-jetpack": "^5.1.0", 47 | "prompts": "^2.4.2" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /prepend.ts: -------------------------------------------------------------------------------- 1 | import { read, write } from 'fs-jetpack' 2 | import { join } from 'path' 3 | 4 | const file = read(join('dist', 'src', 'printer.js')) 5 | const prependedFile = '#!/usr/bin/env node\n\n' + file 6 | 7 | write(join('dist', 'src', 'printer.js'), prependedFile) 8 | -------------------------------------------------------------------------------- /src/config.ts: -------------------------------------------------------------------------------- 1 | import { read } from 'fs-jetpack' 2 | import { join } from 'path' 3 | import { Log } from './helpers/log' 4 | 5 | export interface PrinterConfig { 6 | crud?: { 7 | create: boolean 8 | update: boolean 9 | delete: boolean 10 | list: boolean 11 | get: boolean 12 | } 13 | } 14 | 15 | export let Config: PrinterConfig = { 16 | crud: { 17 | create: true, 18 | update: true, 19 | delete: true, 20 | list: true, 21 | get: true 22 | } 23 | } 24 | 25 | export function registerConfig () { 26 | try { 27 | const config = read(join(process.cwd(), 'printer.config.json')) || '' 28 | const data = JSON.parse(config) 29 | Config = Object.assign(Config, { ...data }) 30 | } catch (error) { 31 | Log('👷 Could not load Printer config'.yellow) 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/converter.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path' 2 | import { write, read, list } from 'fs-jetpack' 3 | 4 | export async function Converter () { 5 | const path = join(__dirname, 'templates') 6 | RecurseConverter(path) 7 | } 8 | 9 | export async function RecurseConverter (path: string) { 10 | const files = list(path) 11 | for (const file of files || []) { 12 | const subpath = join(path, file) 13 | if (file.indexOf('.template') !== -1) { 14 | ConvertTemplate(subpath, file) 15 | } else if (file.indexOf('.') === -1) { 16 | RecurseConverter(subpath) 17 | } 18 | } 19 | } 20 | 21 | export async function ConvertTemplate (path: string, filename: string) { 22 | const writePath = join(process.cwd(), 'docs', 'templates', `${filename}.ts`) 23 | const data = `export default \`${read(path)?.toString().replaceAll('`', '\\`')}\`` 24 | write(writePath, data) 25 | } 26 | 27 | (() => Converter())() 28 | -------------------------------------------------------------------------------- /src/generators/api.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | 6 | export async function generateApi (path: string) { 7 | const apiPath = join(process.cwd(), 'app', 'api', `${path}/route.tsx`) 8 | 9 | if (exists(apiPath) !== false) { 10 | const result = await prompts({ 11 | type: 'confirm', 12 | name: 'overwrite', 13 | message: 'This api already exists, overwrite it?' 14 | }) 15 | 16 | if (result.overwrite === false) { 17 | return 18 | } 19 | } 20 | 21 | const apiTemplate = read(join(__dirname, '..', 'templates', 'api.template')) 22 | write(apiPath, apiTemplate || '') 23 | Log(` ✅ Created app/api/${path}/route.tsx`.green) 24 | } 25 | -------------------------------------------------------------------------------- /src/generators/component.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | import { formatName } from '../helpers/nomenclature' 6 | 7 | export async function generateComponent (path: string) { 8 | if (exists(join(process.cwd(), path)) || exists(join(process.cwd(), `${path.replace('.tsx', '')}.tsx`))) { 9 | const result = await prompts({ 10 | type: 'confirm', 11 | name: 'overwrite', 12 | message: 'This component already exists, overwrite it?' 13 | }) 14 | 15 | if (result.overwrite === false) { 16 | return 17 | } 18 | } 19 | 20 | const pathArray = path.replace('.tsx', '').split('/') 21 | const fileName = pathArray[pathArray.length - 1] 22 | const name = formatName(fileName) 23 | 24 | const component = read(join(__dirname, '..', 'templates', 'component', 'component.nostyle.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) 25 | const componentPath = join(process.cwd(), `${path.replace('.tsx', '')}.tsx`) 26 | 27 | write(componentPath, component || '') 28 | Log(` ✅ Created ${path.replace('.tsx', '')}.tsx`.green) 29 | } 30 | -------------------------------------------------------------------------------- /src/generators/crud.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | 6 | export async function generateCrud (model: string) { 7 | const basePath = join(process.cwd(), 'app', 'api', model) 8 | 9 | if (exists(basePath) !== false) { 10 | const result = await prompts({ 11 | type: 'confirm', 12 | name: 'overwrite', 13 | message: 'Routes already exist in this folder, overwrite it?' 14 | }) 15 | 16 | if (result.overwrite === false) { 17 | return 18 | } 19 | } 20 | 21 | const routePath = join(basePath, 'route.tsx') 22 | const routeTemplate = read(join(__dirname, '..', 'templates', 'crud.template'))?.replaceAll('{{model}}', model) 23 | write(routePath, routeTemplate || '') 24 | Log(` ✅ Created pages/api/${model}/route.tsx`.green) 25 | } 26 | -------------------------------------------------------------------------------- /src/generators/error.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | import { formatName } from '../helpers/nomenclature' 6 | 7 | export async function generateError (path: string) { 8 | const errorPath = join(process.cwd(), 'app', `${path.replace('.tsx', '')}/error.tsx`) 9 | 10 | if (exists(errorPath) !== false) { 11 | const result = await prompts({ 12 | type: 'confirm', 13 | name: 'overwrite', 14 | message: 'A error component already exists, overwrite it?' 15 | }) 16 | 17 | if (result.overwrite === false) { 18 | return 19 | } 20 | } 21 | 22 | const pathArray = path.replace('.tsx', '').split('/') 23 | const fileName = pathArray[pathArray.length - 1] 24 | const name = formatName(fileName) 25 | const errorTemplate = read(join(__dirname, '..', 'templates', 'error.template'))?.replaceAll('{{name}}', name) || '' 26 | 27 | write(errorPath, errorTemplate) 28 | Log(` ✅ Created app/${path}/error.tsx`.green) 29 | } 30 | -------------------------------------------------------------------------------- /src/generators/layout.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | import { formatName } from '../helpers/nomenclature' 6 | 7 | export async function generateLayout (path: string) { 8 | const layoutPath = join(process.cwd(), 'app', `${path.replace('.tsx', '')}/layout.tsx`) 9 | 10 | if (exists(layoutPath) !== false) { 11 | const result = await prompts({ 12 | type: 'confirm', 13 | name: 'overwrite', 14 | message: 'A layout component already exists, overwrite it?' 15 | }) 16 | 17 | if (result.overwrite === false) { 18 | return 19 | } 20 | } 21 | 22 | const pathArray = path.replace('.tsx', '').split('/') 23 | const fileName = pathArray[pathArray.length - 1] 24 | const name = formatName(fileName) 25 | const layoutTemplate = read(join(__dirname, '..', 'templates', 'layout.template'))?.replaceAll('{{name}}', name) || '' 26 | 27 | write(layoutPath, layoutTemplate) 28 | Log(` ✅ Created app/${path}/layout.tsx`.green) 29 | } 30 | -------------------------------------------------------------------------------- /src/generators/loading.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | import { formatName } from '../helpers/nomenclature' 6 | 7 | export async function generateLoading (path: string) { 8 | const loadingPath = join(process.cwd(), 'app', `${path.replace('.tsx', '')}/loading.tsx`) 9 | 10 | if (exists(loadingPath) !== false) { 11 | const result = await prompts({ 12 | type: 'confirm', 13 | name: 'overwrite', 14 | message: 'A loading component already exists, overwrite it?' 15 | }) 16 | 17 | if (result.overwrite === false) { 18 | return 19 | } 20 | } 21 | 22 | const pathArray = path.replace('.tsx', '').split('/') 23 | const fileName = pathArray[pathArray.length - 1] 24 | const name = formatName(fileName) 25 | const loadingTemplate = read(join(__dirname, '..', 'templates', 'loading.template'))?.replaceAll('{{name}}', name) || '' 26 | 27 | write(loadingPath, loadingTemplate) 28 | Log(` ✅ Created app/${path}/loading.tsx`.green) 29 | } 30 | -------------------------------------------------------------------------------- /src/generators/new.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | import { randomBytes } from 'crypto' 6 | 7 | export async function generateNewProject (path: string = '.') { 8 | const configPath = join(process.cwd(), path, 'printer.config.json') 9 | if (exists(configPath) !== false) { 10 | const result = await prompts({ 11 | type: 'confirm', 12 | name: 'overwrite', 13 | message: 'A project already exists here, overwrite it?' 14 | }) 15 | 16 | if (result.overwrite === false) { 17 | return 18 | } 19 | } 20 | 21 | const root = [ 22 | 'printer.config.json', 23 | '.env.dev.local', 24 | '.eslintrc.js', 25 | '.gitignore', 26 | 'middleware.tsx', 27 | 'next.config.js', 28 | 'package.json', 29 | 'README.md', 30 | 'tsconfig.json' 31 | ] 32 | 33 | for (const item of root) { 34 | const itemPath = join(process.cwd(), path, item) 35 | let contents = read(join(__dirname, '..', 'templates', 'new', `${item}.template`)) || '' 36 | if (item === '.env.dev.local') { 37 | contents = contents.replaceAll('{{password}}', randomBytes(32).toString('hex')) 38 | } 39 | 40 | write( 41 | itemPath, 42 | contents 43 | ) 44 | Log(` ✅ Created ${item}`.green) 45 | } 46 | 47 | write( 48 | join(process.cwd(), path, 'public', '.gitkeep'), 49 | '' 50 | ) 51 | 52 | const sessionPath = join(process.cwd(), path, 'util', 'session.ts') 53 | let sessionContents = read(join(__dirname, '..', 'templates', 'new', 'util', 'session.ts.template')) || '' 54 | sessionContents = sessionContents.replaceAll('{{password}}', randomBytes(32).toString('hex')) 55 | write( 56 | sessionPath, 57 | sessionContents 58 | ) 59 | Log(' ✅ Created util/session.ts'.green) 60 | 61 | const counterTypePath = join(process.cwd(), path, 'types', 'counter.tsx') 62 | const counterTypeContents = read(join(__dirname, '..', 'templates', 'new', 'types', 'counter.tsx.template')) || '' 63 | write( 64 | counterTypePath, 65 | counterTypeContents 66 | ) 67 | Log(' ✅ Created types/counter.tsx'.green) 68 | 69 | const scss = [ 70 | 'printer.scss', 71 | 'reset.scss', 72 | 'theme.scss', 73 | 'ui.scss', 74 | 'index.scss' 75 | ] 76 | 77 | for (const item of scss) { 78 | const itemPath = join(process.cwd(), path, 'scss', item) 79 | const contents = read(join(__dirname, '..', 'templates', 'new', 'scss', `${item}.template`)) || '' 80 | 81 | write( 82 | itemPath, 83 | contents 84 | ) 85 | Log(` ✅ Created scss/${item}`.green) 86 | } 87 | 88 | const prisma = [ 89 | 'client.ts', 90 | 'schema.prisma' 91 | ] 92 | 93 | for (const item of prisma) { 94 | const itemPath = join(process.cwd(), path, 'prisma', item) 95 | const contents = read(join(__dirname, '..', 'templates', 'new', 'prisma', `${item}.template`)) || '' 96 | 97 | write( 98 | itemPath, 99 | contents 100 | ) 101 | Log(` ✅ Created prisma/${item}`.green) 102 | } 103 | 104 | const redux = [ 105 | 'provider.tsx', 106 | 'reducer.tsx', 107 | 'reducers.json', 108 | 'store.tsx' 109 | ] 110 | 111 | for (const item of redux) { 112 | const itemPath = join(process.cwd(), path, 'redux', item) 113 | const contents = read(join(__dirname, '..', 'templates', 'new', 'redux', `${item}.template`)) || '' 114 | 115 | write( 116 | itemPath, 117 | contents 118 | ) 119 | Log(` ✅ Created redux/${item}`.green) 120 | } 121 | 122 | const reduxSlicePath = join(process.cwd(), path, 'redux', 'slice', 'counter.tsx') 123 | const reduxSliceContents = read(join(__dirname, '..', 'templates', 'new', 'redux', 'slice', 'counter.tsx.template')) || '' 124 | write( 125 | reduxSlicePath, 126 | reduxSliceContents 127 | ) 128 | Log(' ✅ Created redux/slice/counter.tsx'.green) 129 | 130 | const app = [ 131 | 'layout.tsx', 132 | 'page.tsx' 133 | ] 134 | 135 | for (const item of app) { 136 | const itemPath = join(process.cwd(), path, 'app', item) 137 | const contents = read(join(__dirname, '..', 'templates', 'new', 'app', `${item}.template`)) || '' 138 | 139 | write( 140 | itemPath, 141 | contents 142 | ) 143 | Log(` ✅ Created app/${item}`.green) 144 | } 145 | 146 | const components = [ 147 | 'counter.tsx' 148 | ] 149 | 150 | for (const item of components) { 151 | const itemPath = join(process.cwd(), path, 'components', item) 152 | const contents = read(join(__dirname, '..', 'templates', 'new', 'components', `${item}.template`)) || '' 153 | 154 | write( 155 | itemPath, 156 | contents 157 | ) 158 | Log(` ✅ Created components/${item}`.green) 159 | } 160 | } 161 | -------------------------------------------------------------------------------- /src/generators/page.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | import { formatName } from '../helpers/nomenclature' 6 | 7 | export async function generatePage (path: string) { 8 | const pagePath = join(process.cwd(), 'app', `${path.replace('.tsx', '')}/page.tsx`) 9 | 10 | if (exists(pagePath) !== false) { 11 | const result = await prompts({ 12 | type: 'confirm', 13 | name: 'overwrite', 14 | message: 'This page already exists, overwrite it?' 15 | }) 16 | 17 | if (result.overwrite === false) { 18 | return 19 | } 20 | } 21 | 22 | const pathArray = path.replace('.tsx', '').split('/') 23 | const fileName = pathArray[pathArray.length - 1] 24 | let urls = [] 25 | const name = formatName(fileName) 26 | let pageTemplate = '' 27 | 28 | if (path.match(/\[(.*?)\]/g)) { 29 | urls = path.match(/\[(.*?)\]/g) as string[] 30 | urls = urls.map(url => url.replace(/\[/g, '').replace(/\]/g, '')) 31 | 32 | const urlInterface = urls.map((url) => `${url}: string`) 33 | 34 | pageTemplate = (read(join(__dirname, '..', 'templates', 'page.url.template')) || '') 35 | .replaceAll('{{name}}', name) 36 | .replaceAll('{{url_variables}}', 'params') 37 | .replaceAll('{{url_interface}}', `params: {\n ${urlInterface.join('\n')}\n }`) 38 | } else { 39 | pageTemplate = read(join(__dirname, '..', 'templates', 'page.template'))?.replaceAll('{{name}}', name) || '' 40 | } 41 | 42 | write(pagePath, pageTemplate) 43 | Log(` ✅ Created app/${path}/page.tsx`.green) 44 | } 45 | -------------------------------------------------------------------------------- /src/generators/prisma.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path' 2 | import { read, write } from 'fs-jetpack' 3 | import { Log } from '../helpers/log' 4 | 5 | interface ModelType { 6 | original: string 7 | name: string 8 | type: string 9 | imported: boolean 10 | } 11 | 12 | interface TypeMatches { 13 | matches: string[] 14 | type: string 15 | } 16 | 17 | const typeMatches = [ 18 | { 19 | type: 'number', 20 | matches: ['INT', 'TINYINT', 'SMALLINT', 'BIGINT', 'FLOAT', 'DOUBLE', 'DECIMAL'] 21 | }, 22 | { 23 | type: 'string', 24 | matches: ['STRING', 'CHAR', 'VARCHAR', 'TEXT'] 25 | }, 26 | { 27 | type: 'Date', 28 | matches: ['DATE', 'DATETIME', 'TIMESTAMP'] 29 | }, 30 | { 31 | type: 'boolean', 32 | matches: ['BOOLEAN'] 33 | }, 34 | { 35 | type: 'object', 36 | matches: ['JSON'] 37 | } 38 | ] as TypeMatches[] 39 | 40 | function formatModel (models: ModelType[]): ModelType[] { 41 | const formattedModels = [] as ModelType[] 42 | const names = models.map((item) => item.name.toUpperCase()) 43 | 44 | for (const model of models) { 45 | const type = model.type.toUpperCase().trim().replaceAll('?', '') 46 | const tm = type.replaceAll('[]', '') 47 | let imported = false 48 | let newType = 'any' 49 | 50 | for (const typeMatch of typeMatches) { 51 | if (typeMatch.matches.indexOf(tm) !== -1) { 52 | newType = typeMatch.type 53 | } 54 | } 55 | 56 | if (newType === 'any' && names.includes(model.name.toUpperCase())) { 57 | for (const model of models) { 58 | if (type.replaceAll('[]', '').replaceAll('?', '') === model.type.replaceAll('[]', '').replaceAll('?', '').toUpperCase().trim()) { 59 | newType = `${model.original.replaceAll('[', '').replaceAll(']', '').replaceAll('?', '')}Type` 60 | imported = true 61 | } 62 | } 63 | } 64 | 65 | let inputType = newType 66 | if (type.indexOf('[]') !== -1) { 67 | inputType += '[]' 68 | } 69 | formattedModels.push({ 70 | original: model.original, 71 | name: model.name, 72 | type: inputType, 73 | imported 74 | }) 75 | } 76 | 77 | return formattedModels 78 | } 79 | 80 | export function generateImports (name: string, models: ModelType[]): string { 81 | let output = '' 82 | let hasImports = false 83 | for (const model of models) { 84 | const circularCheck = model.original.replaceAll('[]', '').replaceAll('?', '').toUpperCase() 85 | if (model.imported && circularCheck !== name.toUpperCase()) { 86 | const name = (model.original[0].toUpperCase() + model.original.substring(1)).replaceAll('[', '').replaceAll(']', '').replaceAll('?', '') 87 | output += `import ${name}Type from 'types/prisma/${name}'\n` 88 | hasImports = true 89 | } 90 | } 91 | if (hasImports) { 92 | output += '\n' 93 | } 94 | return output 95 | } 96 | 97 | export async function generatePrismaTypes () { 98 | const prismaPath = join(process.cwd(), 'prisma', 'schema.prisma') 99 | const prismaFile = read(prismaPath) || '' 100 | 101 | const matches = [...prismaFile.matchAll(/^.*model.*$/gim)] 102 | 103 | for (const match of matches) { 104 | if (match[0].indexOf('{') !== -1) { 105 | const models = [] as ModelType[] 106 | 107 | const index = match.index 108 | const data = prismaFile.slice(index, prismaFile.length) 109 | let name = '' 110 | 111 | const match2 = [...data.matchAll(/\}/gim)] 112 | if (match2) { 113 | const indexEnd = match2[0].index 114 | const modelContent = data.slice(0, indexEnd).split('{')[1].trim() 115 | name = data.slice(0, indexEnd).split('{')[0].replace('model', '').trim() 116 | const lines = modelContent.split('\n').filter((line) => line.indexOf('@@') === -1) 117 | 118 | for (const line of lines) { 119 | const lineFmt = line.trim() 120 | const tokens = lineFmt.split(' ') 121 | 122 | const tokenFmt = tokens.filter((token) => token !== '') 123 | const name = (tokenFmt[0] || '') 124 | const type = (tokenFmt[1] || '').toLowerCase() 125 | 126 | if (name && type) { 127 | models.push({ original: (tokenFmt[1] || ''), name, type, imported: false }) 128 | } 129 | } 130 | } 131 | 132 | const dataMap = formatModel(models) 133 | const importMap = generateImports(name, dataMap) 134 | 135 | let typeFile = '{{imports}}' + `export interface ${name}Type {{{injection}}}` + '\n\n' + `export default ${name}Type` + '\n' 136 | let typeInject = '' 137 | 138 | for (const item of dataMap) { 139 | typeInject += '\t' + item.name + '?: ' + item.type + '\n' 140 | } 141 | 142 | typeFile = typeFile.replace('{{injection}}', '\n' + typeInject) 143 | typeFile = typeFile.replace('{{imports}}', importMap) 144 | const typePath = join(process.cwd(), 'types', 'prisma', `${name}.tsx`) 145 | 146 | Log(` ✅ Generated types/prisma/${name}.tsx`.green) 147 | write(typePath, typeFile || '') 148 | } 149 | } 150 | } 151 | -------------------------------------------------------------------------------- /src/generators/scss.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | 6 | export async function generateScss (path: string) { 7 | const scssPath = join(process.cwd(), 'scss', `${path}.scss`) 8 | 9 | if (exists(scssPath) !== false) { 10 | const result = await prompts({ 11 | type: 'confirm', 12 | name: 'overwrite', 13 | message: 'This scss file already exists, overwrite it?' 14 | }) 15 | 16 | if (result.overwrite === false) { 17 | return 18 | } 19 | } 20 | 21 | const scssTemplate = read(join(__dirname, '..', 'templates', 'scss.template')) || '' 22 | write(scssPath, scssTemplate) 23 | Log(` ✅ Created scss/${path}.scss`.green) 24 | 25 | const printerPath = join(process.cwd(), 'scss', 'printer.scss') 26 | let printerFile = read(printerPath) 27 | printerFile += `\n@import "/scss/${path}.scss";` 28 | 29 | write(printerPath, printerFile || '') 30 | Log(' ✅ Updated scss/printer.scss'.green) 31 | } 32 | -------------------------------------------------------------------------------- /src/generators/slice.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | 6 | export async function generateSlice (name: string) { 7 | const slicePath = join(process.cwd(), 'redux', 'slice', `${name}.tsx`) 8 | const reducerPath = join(process.cwd(), 'redux', 'reducer.tsx') 9 | const reducersPath = join(process.cwd(), 'redux', 'reducers.json') 10 | 11 | let reducers = [] 12 | 13 | try { 14 | reducers = JSON.parse(read(reducersPath) as string) as string[] 15 | 16 | if (reducers.indexOf(name) !== -1) { 17 | const result = await prompts({ 18 | type: 'confirm', 19 | name: 'overwrite', 20 | message: 'This slice already exists, overwrite it?' 21 | }) 22 | 23 | if (result.overwrite === false) { 24 | return 25 | } 26 | } 27 | 28 | if (reducers.indexOf(name) === -1) { 29 | reducers.push(name) 30 | } 31 | write(reducersPath, JSON.stringify(reducers, null, 2)) 32 | } catch (error) { 33 | Log(' ❗ redux/reducers.json is invalid, please make sure it\'s a JSON Array'.red) 34 | process.exit() 35 | } 36 | 37 | write( 38 | slicePath, 39 | read(join(__dirname, '..', 'templates', 'slice', 'slice.template'))?.replaceAll('{{name}}', name) || '' 40 | ) 41 | Log(` ✅ Created redux/slice/${name}.tsx`.green) 42 | write( 43 | reducerPath, 44 | read(join(__dirname, '..', 'templates', 'slice', 'reducer.template')) 45 | ?.replaceAll('{{import}}', reducers.map(slice => `import { ${slice}Slice } from 'redux/slice/${slice}'`).join('\n')) 46 | .replaceAll('{{reducer}}', reducers.map(slice => ` ${slice}: ${slice}Slice.reducer,`).join('\n')) || '' 47 | ) 48 | Log(' ✅ Updated redux/reducer.tsx'.green) 49 | } 50 | -------------------------------------------------------------------------------- /src/generators/superagent.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path' 2 | import { exists, read, write } from 'fs-jetpack' 3 | import { Log } from '../helpers/log' 4 | import { effectMatcher, findMatches, functionMatcher, stateMatcher, superagentMatcher } from '../helpers/match' 5 | 6 | export type SuperagentTypes = 'POST' | 'GET' | 'PUT' | 'PATCH' | 'DELETE' 7 | 8 | export async function injectSupergent (type: SuperagentTypes, component: string) { 9 | const filePath = join(process.cwd(), component) 10 | const pathArray = component.split('/') 11 | const fileName = pathArray[pathArray.length - 1] 12 | let fileContents = '' 13 | 14 | if (filePath.indexOf('.tsx') === -1) { 15 | fileContents = read(`${filePath}.tsx`) || '' 16 | } else { 17 | fileContents = read(`${filePath}`) || '' 18 | } 19 | 20 | if (findMatches(fileContents, stateMatcher()).length === 0 && findMatches(fileContents, effectMatcher()).length === 0) { 21 | fileContents = 'import { useState, useEffect } from \'react\'' + '\n' + fileContents 22 | } 23 | 24 | if (findMatches(fileContents, stateMatcher()).length === 0) { 25 | fileContents = 'import { useState } from \'react\'' + '\n' + fileContents 26 | } 27 | 28 | if (findMatches(fileContents, effectMatcher()).length === 0) { 29 | fileContents = 'import { useEffect } from \'react\'' + '\n' + fileContents 30 | } 31 | 32 | if (findMatches(fileContents, superagentMatcher(type)).length === 0) { 33 | fileContents = `import { ${type.toLowerCase()} } from 'superagent'` + '\n' + fileContents 34 | } 35 | 36 | const injectionLine = findMatches(fileContents, functionMatcher(fileName.replaceAll('.tsx', '')))[0] 37 | const tempContents = fileContents.split('\n') 38 | 39 | const superAgentFlow = read(join(__dirname, '..', 'templates', 'superagent.template'))?.replaceAll('{{type}}', type.toLowerCase()) || '' 40 | 41 | tempContents[injectionLine] += '\n' + superAgentFlow + '\n' 42 | const newContents = tempContents.join('\n') 43 | 44 | if (exists(filePath) === 'dir') { 45 | const fileComponentPath = join(process.cwd(), component, `${fileName}.component.tsx`) 46 | write(fileComponentPath, newContents) 47 | Log(` ✅ Updated ${fileComponentPath}`.green) 48 | } else { 49 | write(`${component.replace('.tsx', '')}.tsx`, newContents) 50 | Log(` ✅ Updated ${component.replace('.tsx', '')}.tsx`.green) 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/generators/type.ts: -------------------------------------------------------------------------------- 1 | import prompts from 'prompts' 2 | import { join } from 'path' 3 | import { exists, read, write } from 'fs-jetpack' 4 | import { Log } from '../helpers/log' 5 | 6 | export async function generateType (path: string) { 7 | const typePath = join(process.cwd(), 'types', `${path}.tsx`) 8 | 9 | if (exists(typePath) !== false) { 10 | const result = await prompts({ 11 | type: 'confirm', 12 | name: 'overwrite', 13 | message: 'This api already exists, overwrite it?' 14 | }) 15 | 16 | if (result.overwrite === false) { 17 | return 18 | } 19 | } 20 | 21 | const pathArray = path.split('/') 22 | const fileName = pathArray[pathArray.length - 1] 23 | let name = fileName.replace(/[^\w\s]/gi, '') 24 | 25 | if (fileName.indexOf('.') !== -1) { 26 | name = fileName.split('.').map(word => word[0].toUpperCase() + word.substring(1)).join('') 27 | } else if (fileName.indexOf('-') !== -1) { 28 | name = fileName.split('-').map(word => word[0].toUpperCase() + word.substring(1)).join('') 29 | } else { 30 | name = name[0].toUpperCase() + name.substring(1) 31 | } 32 | 33 | const typeTemplate = read(join(__dirname, '..', 'templates', 'type.template'))?.replaceAll('{{name}}', name) 34 | 35 | write(typePath, typeTemplate || '') 36 | Log(` ✅ Created types/${path}.tsx`.green) 37 | } 38 | -------------------------------------------------------------------------------- /src/helpers/log.ts: -------------------------------------------------------------------------------- 1 | export function Log (...output: string[]): void { 2 | if (process.env.NODE_ENV !== 'test') { 3 | console.log(...output) 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /src/helpers/match.ts: -------------------------------------------------------------------------------- 1 | export const SliceMatcher = /^(?=.*export)(?=.*createSlice).*$/gmi 2 | export const ImportMatcher = /^(?=.*import)(?=.*from).*$/gmi 3 | export const ReduxMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector)(?=.*useAppDispatch).*$/gmi 4 | export const ReduxOptionalMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector|useAppDispatch).*$/gmi 5 | export const DispatchMatcher = /^(?=.*const)(?=.*dispatch)(?=.*useAppDispatch).*$/gmi 6 | export const BraceMatcher = /^(?=.*\[).*$/gmi 7 | export const BraceMatcher2 = /^(?=.*{).*$/gmi 8 | 9 | export function superagentMatcher (type: string) { 10 | return new RegExp(`^(?=.*import)(?=.*${type})(?=.*from).*$`, 'gmi') 11 | } 12 | 13 | export function stateMatcher () { 14 | return new RegExp('^(?=.*import)(?=.*useState)(?=.*from).*$', 'gmi') 15 | } 16 | 17 | export function effectMatcher () { 18 | return new RegExp('^(?=.*import)(?=.*useEffect)(?=.*from).*$', 'gmi') 19 | } 20 | 21 | export function functionMatcher (name: string) { 22 | return new RegExp(`^(?=.*function)(?=.*${name}).*$`, 'gmi') 23 | } 24 | 25 | export function selectorMatcher (name: string) { 26 | return new RegExp(`^(?=.*${name} =)(?=.*useSelector).*$`, 'gmi') 27 | } 28 | 29 | export function actionMatcher (name: string[]) { 30 | return new RegExp(`^(?=.*import)(?=.*${name.join('|')})(?=.*from).*$`, 'gmi') 31 | } 32 | 33 | export function typeMatcher (name: string) { 34 | return new RegExp(`^(?=.*import)(?=.*${name})(?=.*from).*$`, 'gmi') 35 | } 36 | 37 | export function findMatches (text: any, pattern: any) { 38 | const matchingLines = [] 39 | const allLines = text.split('\n') 40 | 41 | for (let i = 0; i < allLines.length; i++) { 42 | if (allLines[i].match(pattern)) { 43 | matchingLines.push(i) 44 | } 45 | } 46 | 47 | return matchingLines 48 | } 49 | -------------------------------------------------------------------------------- /src/helpers/nomenclature.ts: -------------------------------------------------------------------------------- 1 | export function formatName (_fileName: string) { 2 | const fileName = _fileName.replaceAll('.ts', '').replaceAll('.tsx', '').replaceAll('[', '').replaceAll(']', '') 3 | let name = fileName 4 | 5 | if (fileName.indexOf('.') !== -1) { 6 | name = fileName.split('.').map(word => word[0].toUpperCase() + word.substring(1)).join('') 7 | } else if (fileName.indexOf('-') !== -1) { 8 | name = fileName.split('-').map(word => word[0].toUpperCase() + word.substring(1)).join('') 9 | } else { 10 | name = name[0].toUpperCase() + name.substring(1) 11 | } 12 | 13 | return name 14 | } 15 | -------------------------------------------------------------------------------- /src/printer.ts: -------------------------------------------------------------------------------- 1 | import 'colors' 2 | import { Command } from 'commander' 3 | import { Log } from './helpers/log' 4 | import { registerConfig } from './config' 5 | import { generateNewProject } from './generators/new' 6 | import { generateComponent } from './generators/component' 7 | import { generateSlice } from './generators/slice' 8 | import { generateType } from './generators/type' 9 | import { generatePage } from './generators/page' 10 | import { generateLayout } from './generators/layout' 11 | import { generateLoading } from './generators/loading' 12 | import { generateError } from './generators/error' 13 | import { generateApi } from './generators/api' 14 | import { generateCrud } from './generators/crud' 15 | import { generateScss } from './generators/scss' 16 | import { inject } from './generators/inject' 17 | import { generatePrismaTypes } from './generators/prisma' 18 | import { SuperagentTypes, injectSupergent } from './generators/superagent' 19 | 20 | export const Printer = new Command('🖨️ Printer') 21 | 22 | Printer 23 | .version('2.2.5') 24 | .description('🖨️ Printer: Automation Tooling for Next, Redux and Prisma.') 25 | .option('-a, --no-action', 'do not inject actions', false) 26 | .option('-s, --no-state', 'do not inject state', false) 27 | 28 | Printer 29 | .command('new [path]') 30 | .description('Generate a new Printer project') 31 | .action(async path => { 32 | registerConfig() 33 | Log('👷 Generating new Printer project'.green) 34 | await generateNewProject(path || '.') 35 | }) 36 | 37 | Printer 38 | .command('component ') 39 | .description('Generate a new Printer component') 40 | .action(async path => { 41 | registerConfig() 42 | Log(`👷 Generating new Printer component ${path}`.green) 43 | await generateComponent(path) 44 | }) 45 | 46 | Printer 47 | .command('type ') 48 | .description('Generate a new Printer type') 49 | .action(async path => { 50 | registerConfig() 51 | Log(`👷 Generating new Printer type ${path}`.green) 52 | await generateType(path) 53 | }) 54 | 55 | Printer 56 | .command('inject ') 57 | .description('Inject a slice into a component or page') 58 | .action(async (slice, component) => { 59 | registerConfig() 60 | Log(`💉 Injecting ${slice} into ${component.replaceAll('.tsx', '')}`.green) 61 | await inject(slice, component, Printer.opts()) 62 | }) 63 | 64 | Printer 65 | .command('slice ') 66 | .description('Generate a new Printer slice') 67 | .action(async name => { 68 | registerConfig() 69 | Log(`👷 Generating new Printer slice ${name}`.green) 70 | await generateSlice(name) 71 | }) 72 | 73 | Printer 74 | .command('page ') 75 | .description('Generate a new Printer page') 76 | .action(async path => { 77 | registerConfig() 78 | Log('👷 Generating new Printer page'.green) 79 | await generatePage(path) 80 | }) 81 | 82 | Printer 83 | .command('layout ') 84 | .description('Generate a new layout component') 85 | .action(async path => { 86 | registerConfig() 87 | Log('👷 Generating new layout component'.green) 88 | await generateLayout(path) 89 | }) 90 | 91 | Printer 92 | .command('loading ') 93 | .description('Generate a new loading component') 94 | .action(async path => { 95 | registerConfig() 96 | Log('👷 Generating new loading component'.green) 97 | await generateLoading(path) 98 | }) 99 | 100 | Printer 101 | .command('error ') 102 | .description('Generate a new error component') 103 | .action(async path => { 104 | registerConfig() 105 | Log('👷 Generating new error component'.green) 106 | await generateError(path) 107 | }) 108 | 109 | Printer 110 | .command('api ') 111 | .description('Generate a new Printer API route') 112 | .action(async path => { 113 | registerConfig() 114 | Log('👷 Generating new Printer API route'.green) 115 | await generateApi(path) 116 | }) 117 | 118 | Printer 119 | .command('scss ') 120 | .description('Generate a new Printer SCSS file') 121 | .action(async path => { 122 | registerConfig() 123 | Log('👷 Generating new Printer SCSS file'.green) 124 | await generateScss(path) 125 | }) 126 | 127 | Printer 128 | .command('superagent ') 129 | .description('Generate a new Superagent request flow') 130 | .action(async (type, path) => { 131 | registerConfig() 132 | Log('👷 Generating new Superagent request flow for'.green, path) 133 | await injectSupergent(String(type).toUpperCase() as SuperagentTypes, path) 134 | }) 135 | 136 | Printer 137 | .command('prisma') 138 | .description('Generate dynamic prisma types based on prisma/schema.prisma') 139 | .action(async () => { 140 | registerConfig() 141 | Log('👷 Generating prisma types'.green) 142 | await generatePrismaTypes() 143 | }) 144 | 145 | Printer 146 | .command('crud ') 147 | .description('Generate a CRUD boilerplate for a Prisma model') 148 | .action(async model => { 149 | registerConfig() 150 | Log(`👷 Generating new CRUD boilerplate for ${model}`.green) 151 | await generateCrud(model) 152 | }) 153 | 154 | if (process.env.NODE_ENV !== 'test') { 155 | Printer.parse(process.argv) 156 | } 157 | -------------------------------------------------------------------------------- /src/templates/api.template: -------------------------------------------------------------------------------- 1 | import { NextRequest } from 'next/server' 2 | import { getSession } from 'util/session' 3 | 4 | export async function GET(req: NextRequest) { 5 | const session = await getSession() 6 | const { searchParams } = new URL(req.url) 7 | 8 | try { 9 | return Response.json( 10 | { 11 | status: 'OK', 12 | result: null 13 | }, 14 | { status: 200 } 15 | ) 16 | } catch (error) { 17 | console.error(error) 18 | return Response.json( 19 | { 20 | status: 'ERROR', 21 | error 22 | }, 23 | { status: 500 } 24 | ) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/templates/component/component.nostyle.template: -------------------------------------------------------------------------------- 1 | export interface {{name}}I {} 2 | 3 | export function {{name}}({}: {{name}}I) { 4 | return ( 5 |
6 |

Component {{name}}

7 |
8 | ) 9 | } 10 | 11 | export default {{name}} 12 | -------------------------------------------------------------------------------- /src/templates/component/component.template: -------------------------------------------------------------------------------- 1 | import { {{name}}Style } from '{{path}}/{{prefix}}.style' 2 | 3 | export interface {{name}}I {} 4 | 5 | export function {{name}}({}: {{name}}I) { 6 | return ( 7 | <{{name}}Style> 8 |

Component {{name}}

9 | 10 | ) 11 | } 12 | 13 | export default {{name}} 14 | -------------------------------------------------------------------------------- /src/templates/component/index.nostyle.template: -------------------------------------------------------------------------------- 1 | export * from '{{path}}/{{prefix}}.component' 2 | -------------------------------------------------------------------------------- /src/templates/component/index.template: -------------------------------------------------------------------------------- 1 | export * from '{{path}}/{{prefix}}.component' 2 | export * from '{{path}}/{{prefix}}.style' 3 | -------------------------------------------------------------------------------- /src/templates/component/style.template: -------------------------------------------------------------------------------- 1 | import styled from 'styled-components' 2 | 3 | export const {{name}}Style = styled.div`` 4 | -------------------------------------------------------------------------------- /src/templates/component/test.template: -------------------------------------------------------------------------------- 1 | import { {{name}}Component } from '{{path}}/{{prefix}}.component' 2 | import { {{name}} } from '{{path}}/{{prefix}}.connect' 3 | -------------------------------------------------------------------------------- /src/templates/crud.template: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from 'next/server' 2 | import { getSession, createResponse } from 'util/session' 3 | import prisma from 'prisma/client' 4 | 5 | // Creates a new record 6 | export async function POST(req: NextRequest) { 7 | const res = new NextResponse() 8 | const session = await getSession(req, res) 9 | try { 10 | const data = await req.json() 11 | const {{model}} = await prisma.{{model}}.create({ data }) 12 | 13 | return createResponse( 14 | res, 15 | JSON.stringify({ 16 | status: 'OK', 17 | {{model}} 18 | }), 19 | { status: 200 } 20 | ) 21 | } catch (error) { 22 | console.error(error) 23 | return createResponse( 24 | res, 25 | JSON.stringify({ status: 'ERROR', error }), 26 | { status: 500 } 27 | ) 28 | } 29 | } 30 | 31 | // Updates an existing record by its @id 32 | export async function PATCH(req: NextRequest) { 33 | const res = new NextResponse() 34 | const session = await getSession(req, res) 35 | try { 36 | const data = await req.json() 37 | const id = data.id 38 | delete data.id 39 | 40 | const {{model}} = await prisma.{{model}}.update({ 41 | where: { id }, 42 | data, 43 | }) 44 | 45 | return createResponse( 46 | res, 47 | JSON.stringify({ 48 | status: 'OK', 49 | {{model}} 50 | }), 51 | { status: 200 } 52 | ) 53 | } catch (error) { 54 | console.error(error) 55 | return createResponse( 56 | res, 57 | JSON.stringify({ status: 'ERROR', error }), 58 | { status: 500 } 59 | ) 60 | } 61 | } 62 | 63 | // Deletes a record by its @id 64 | export async function DELETE(req: NextRequest) { 65 | const res = new NextResponse() 66 | const session = await getSession(req, res) 67 | try { 68 | const { searchParams } = new URL(req.url) 69 | const id = searchParams.get('id') 70 | 71 | const {{model}} = await prisma.{{model}}.delete({ 72 | where: { id } 73 | }) 74 | 75 | return createResponse( 76 | res, 77 | JSON.stringify({ 78 | status: 'OK', 79 | {{model}} 80 | }), 81 | { status: 200 } 82 | ) 83 | } catch (error) { 84 | console.error(error) 85 | return createResponse( 86 | res, 87 | JSON.stringify({ status: 'ERROR', error }), 88 | { status: 500 } 89 | ) 90 | } 91 | } 92 | 93 | // Lists results or gets a specific ID 94 | export async function GET(req: NextRequest) { 95 | const res = new NextResponse() 96 | const session = await getSession(req, res) 97 | try { 98 | const { searchParams } = new URL(req.url) 99 | const id = searchParams.get('id') 100 | const skip = searchParams.get('skip') 101 | 102 | if (id) { 103 | const {{model}} = await prisma.{{model}}.findUnique({ 104 | where: { id } 105 | }) 106 | 107 | return createResponse( 108 | res, 109 | JSON.stringify({ 110 | status: 'OK', 111 | result: {{model}} 112 | }), 113 | { status: 200 } 114 | ) 115 | } else { 116 | const results = await prisma.{{model}}.findMany({ 117 | take: 10, 118 | skip: Number(skip || '0') 119 | }) 120 | 121 | return createResponse( 122 | res, 123 | JSON.stringify({ 124 | status: 'OK', 125 | results 126 | }), 127 | { status: 200 } 128 | ) 129 | } 130 | } catch (error) { 131 | console.error(error) 132 | return createResponse( 133 | res, 134 | JSON.stringify({ status: 'ERROR', error }), 135 | { status: 500 } 136 | ) 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/templates/error.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { useEffect } from 'react' 4 | 5 | export interface ErrorI { 6 | error: Error 7 | reset: () => void 8 | } 9 | 10 | export default function ErrorComponent({ error, reset }: ErrorI) { 11 | useEffect(() => { 12 | console.error(error) 13 | }, [error]) 14 | 15 | return ( 16 |
17 |

Something Went Wrong!

18 | reset()}> 19 | Reload Page 20 | 21 |
22 | ) 23 | } 24 | -------------------------------------------------------------------------------- /src/templates/layout.template: -------------------------------------------------------------------------------- 1 | import { ReactNode, Suspense } from 'react' 2 | 3 | export const metadata = { 4 | 5 | } 6 | 7 | export interface LayoutI { 8 | children: ReactNode 9 | } 10 | 11 | export default function LayoutComponent({ children }: LayoutI) { 12 | return ( 13 | 14 | {children} 15 | 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /src/templates/loading.template: -------------------------------------------------------------------------------- 1 | import { Suspense } from 'react' 2 | 3 | export default function LoadingComponent() { 4 | return ( 5 | 6 |

Loading...

7 |
8 | ) 9 | } 10 | -------------------------------------------------------------------------------- /src/templates/new/.env.dev.local.template: -------------------------------------------------------------------------------- 1 | DATABASE_URL="http://localhost:1906" 2 | SESSION_SECRET="{{password}}" -------------------------------------------------------------------------------- /src/templates/new/.eslintrc.js.template: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | env: { 3 | browser: true, 4 | es2021: true, 5 | node: true 6 | }, 7 | extends: [ 8 | 'next/core-web-vitals', 9 | 'plugin:react/recommended', 10 | 'standard', 11 | 'prettier', 12 | 'plugin:prettier/recommended' 13 | ], 14 | parser: '@typescript-eslint/parser', 15 | parserOptions: { 16 | ecmaFeatures: { 17 | jsx: true 18 | }, 19 | ecmaVersion: 'latest', 20 | sourceType: 'module' 21 | }, 22 | plugins: ['react', '@typescript-eslint'], 23 | rules: { 24 | 'prettier/prettier': [ 25 | 'warn', 26 | { 27 | singleQuote: true, 28 | semi: false, 29 | trailingComma: 'none' 30 | } 31 | ], 32 | 'react/react-in-jsx-scope': 0, 33 | 'no-empty-pattern': 0, 34 | 'no-unused-vars': 0, 35 | 'max-statements-per-line': 0, 36 | 'new-cap': 0 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/templates/new/.gitignore.template: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | .pnpm-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 | # Optional stylelint cache 58 | .stylelintcache 59 | 60 | # Microbundle cache 61 | .rpt2_cache/ 62 | .rts2_cache_cjs/ 63 | .rts2_cache_es/ 64 | .rts2_cache_umd/ 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variable files 76 | .env 77 | .env.local 78 | .env.test.local 79 | .env.production.local 80 | 81 | # parcel-bundler cache (https://parceljs.org/) 82 | .cache 83 | .parcel-cache 84 | 85 | # Next.js build output 86 | .next 87 | out 88 | 89 | # Gatsby files 90 | .cache/ 91 | # Comment in the public line in if your project uses Gatsby and not Next.js 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # public 94 | 95 | # vuepress build output 96 | .vuepress/dist 97 | 98 | # vuepress v2.x temp and cache directory 99 | .temp 100 | .cache 101 | 102 | # Serverless directories 103 | .serverless/ 104 | 105 | # FuseBox cache 106 | .fusebox/ 107 | 108 | # DynamoDB Local files 109 | .dynamodb/ 110 | 111 | # TernJS port file 112 | .tern-port 113 | 114 | # Stores VSCode versions used for testing VSCode extensions 115 | .vscode-test 116 | 117 | # yarn v2 118 | .yarn/cache 119 | .yarn/unplugged 120 | .yarn/build-state.yml 121 | .yarn/install-state.gz 122 | .pnp.* 123 | -------------------------------------------------------------------------------- /src/templates/new/README.md.template: -------------------------------------------------------------------------------- 1 | # Printer Template 2 | 3 | ## Commands 4 | 5 | ### `yarn dev` 6 | 7 | Start the dev server on `http://localhost:4200`. 8 | 9 | ### `yarn build` 10 | 11 | Build the Next.js output in `dist`. 12 | 13 | ### `yarn start` 14 | 15 | Start a production server on `http://localhost:3000`. 16 | 17 | ### `yarn lint` | `yarn lint --fix` 18 | 19 | Runs `eslint` on the project and cleans up any style issues. 20 | 21 | ### `yarn scss` 22 | 23 | Creates a debug `printer.css` file to review build outputs. 24 | 25 | ### `yarn prisma` 26 | 27 | Creates the `prisma` client. 28 | 29 | ### `yarn prisma:update` 30 | 31 | Creates the `prisma` client and then pushes schema updates to the database. 32 | 33 | ## Documentation 34 | 35 | Review the documentation on [prntr.click/docs](https://prntr.click/docs). 36 | 37 | Review the [CHANGELOG](https://github.com/PrinterFramework/CLI/blob/master/CHANGELOG.md) for any updates made to the project. -------------------------------------------------------------------------------- /src/templates/new/app/layout.tsx.template: -------------------------------------------------------------------------------- 1 | import 'scss/printer.scss' 2 | import { Metadata } from 'next' 3 | import { ReactNode, Suspense } from 'react' 4 | import { ReduxProvider } from 'redux/provider' 5 | 6 | export const metadata: Metadata = { 7 | title: 'Printer', 8 | description: 'Automation Tooling for Next, Redux and Prisma' 9 | } 10 | 11 | export interface LayoutI { 12 | children: ReactNode 13 | } 14 | 15 | export default function RootLayout({ children }: LayoutI) { 16 | return ( 17 | 18 | 19 | 20 | {children} 21 | 22 | 23 | 24 | ) 25 | } 26 | -------------------------------------------------------------------------------- /src/templates/new/app/page.tsx.template: -------------------------------------------------------------------------------- 1 | import Counter from 'components/counter' 2 | 3 | export default function RootPage() { 4 | return 5 | } 6 | -------------------------------------------------------------------------------- /src/templates/new/components/counter.tsx.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { decrement, increment, reset } from 'redux/slice/counter' 3 | import { useDispatch, useSelector } from 'redux/store' 4 | 5 | export interface CounterI {} 6 | 7 | export function Counter({}: CounterI) { 8 | const count = useSelector((state) => state.counter.data.value) 9 | const dispatch = useDispatch() 10 | 11 | return ( 12 |
13 |

Counter is at {count}

14 | 15 | 26 |
27 | ) 28 | } 29 | 30 | export default Counter 31 | -------------------------------------------------------------------------------- /src/templates/new/middleware.tsx.template: -------------------------------------------------------------------------------- 1 | import { NextRequest, NextResponse } from 'next/server' 2 | import { getSession } from 'util/session' 3 | 4 | // See https://nextjs.org/docs/app/building-your-application/routing/middleware to manage client side routing with session states. 5 | export async function middleware(req: NextRequest) { 6 | const res = new NextResponse() 7 | const session = await getSession() 8 | } 9 | 10 | export const config = {} 11 | -------------------------------------------------------------------------------- /src/templates/new/next.config.js.template: -------------------------------------------------------------------------------- 1 | module.exports = {} 2 | -------------------------------------------------------------------------------- /src/templates/new/package.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@printerframework/template", 3 | "version": "1.0.0", 4 | "scripts": { 5 | "dev": "next dev --port 4200", 6 | "build": "npm run prisma && next build", 7 | "start": "next start", 8 | "lint": "eslint . --ext ts,tsx --resolve-plugins-relative-to .", 9 | "scss": "node-sass -r scss/printer.scss -o scss/debug", 10 | "prisma": "npx prisma generate", 11 | "prisma:update": "npx prisma generate && npx prisma db push" 12 | }, 13 | "dependencies": { 14 | "@prisma/client": "5.6.0", 15 | "@reduxjs/toolkit": "1.9.7", 16 | "iron-session": "8.0.1", 17 | "next": "14.0.3", 18 | "prisma": "5.6.0", 19 | "react": "18.2.0", 20 | "react-dom": "18.2.0", 21 | "react-redux": "8.1.3", 22 | "sass": "1.69.5", 23 | "superagent": "8.1.2" 24 | }, 25 | "devDependencies": { 26 | "@types/node": "20.9.5", 27 | "@types/superagent": "4.1.22", 28 | "@typescript-eslint/eslint-plugin": "6.12.0", 29 | "@typescript-eslint/parser": "6.12.0", 30 | "eslint": "8.54.0", 31 | "eslint-config-next": "14.0.3", 32 | "eslint-config-prettier": "9.0.0", 33 | "eslint-config-standard": "17.1.0", 34 | "eslint-plugin-import": "2.29.0", 35 | "eslint-plugin-n": "16.3.1", 36 | "eslint-plugin-node": "11.1.0", 37 | "eslint-plugin-prettier": "5.0.1", 38 | "eslint-plugin-promise": "6.1.1", 39 | "eslint-plugin-react": "7.33.2", 40 | "node-sass": "9.0.0", 41 | "prettier": "3.1.0", 42 | "typescript": "5.3.2" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/templates/new/printer.config.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "crud": { 3 | "create": true, 4 | "update": true, 5 | "delete": true, 6 | "list": true, 7 | "get": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/templates/new/prisma/client.ts.template: -------------------------------------------------------------------------------- 1 | import { PrismaClient } from '@prisma/client' 2 | 3 | let prisma: PrismaClient 4 | 5 | if (process.env.NODE_ENV === 'production') { 6 | prisma = new PrismaClient({ log: [] }) 7 | } else { 8 | if (!global.prisma) { 9 | global.prisma = new PrismaClient({ log: [] }) 10 | } 11 | 12 | prisma = global.prisma 13 | } 14 | 15 | export default prisma 16 | -------------------------------------------------------------------------------- /src/templates/new/prisma/schema.prisma.template: -------------------------------------------------------------------------------- 1 | generator client { 2 | provider = "prisma-client-js" 3 | } 4 | 5 | datasource db { 6 | provider = "mysql" 7 | url = env("DATABASE_URL") 8 | relationMode = "prisma" 9 | } 10 | 11 | model Account { 12 | id String @id @default(uuid()) @db.Char(36) 13 | username String @unique @db.VarChar(128) 14 | posts Post[] 15 | dateCreated DateTime @default(now()) 16 | dateUpdated DateTime @updatedAt 17 | 18 | @@index(dateCreated) 19 | } 20 | 21 | model Post { 22 | id String @id @default(uuid()) @db.Char(36) 23 | accountId String @db.VarChar(128) 24 | title String @db.VarChar(256) 25 | content String @db.Text() 26 | account Account @relation(fields: accountId, references: id) 27 | dateCreated DateTime @default(now()) 28 | dateUpdated DateTime @updatedAt 29 | 30 | @@index(accountId) 31 | @@index(dateCreated) 32 | } 33 | -------------------------------------------------------------------------------- /src/templates/new/redux/provider.tsx.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | import { ReactNode } from 'react' 3 | import { reduxStore } from 'redux/store' 4 | import { Provider } from 'react-redux' 5 | 6 | export interface ReduxProviderI { 7 | children: ReactNode 8 | } 9 | 10 | export function ReduxProvider({ children }: ReduxProviderI) { 11 | return {children} 12 | } 13 | -------------------------------------------------------------------------------- /src/templates/new/redux/reducer.tsx.template: -------------------------------------------------------------------------------- 1 | import { counterSlice } from 'redux/slice/counter' 2 | 3 | export const reducer = { 4 | counter: counterSlice.reducer 5 | } 6 | -------------------------------------------------------------------------------- /src/templates/new/redux/reducers.json.template: -------------------------------------------------------------------------------- 1 | [ 2 | "counter" 3 | ] -------------------------------------------------------------------------------- /src/templates/new/redux/slice/counter.tsx.template: -------------------------------------------------------------------------------- 1 | import { createSlice, PayloadAction } from '@reduxjs/toolkit' 2 | import CounterType from 'types/counter' 3 | 4 | export const counterInitialState = { 5 | // @printer::inject::counter 6 | data: { 7 | value: 0 8 | } as CounterType 9 | } 10 | 11 | export const counterSlice = createSlice({ 12 | name: 'counter', 13 | initialState: counterInitialState, 14 | reducers: { 15 | // @printer::inject 16 | reset: (state) => { 17 | state.data.value = 0 18 | }, 19 | // @printer::inject 20 | increment: (state, action: PayloadAction) => { 21 | state.data.value += action.payload 22 | }, 23 | // @printer::inject 24 | decrement: (state, action: PayloadAction) => { 25 | state.data.value -= action.payload 26 | } 27 | } 28 | }) 29 | 30 | export const { increment, decrement, reset } = counterSlice.actions 31 | -------------------------------------------------------------------------------- /src/templates/new/redux/store.tsx.template: -------------------------------------------------------------------------------- 1 | import { configureStore, type ThunkAction, type Action } from '@reduxjs/toolkit' 2 | import { 3 | useSelector as useReduxSelector, 4 | useDispatch as useReduxDispatch, 5 | type TypedUseSelectorHook 6 | } from 'react-redux' 7 | import { reducer } from 'redux/reducer' 8 | 9 | export const reduxStore = configureStore({ 10 | reducer, 11 | middleware: (getDefaultMiddleware) => 12 | getDefaultMiddleware({ 13 | serializableCheck: false 14 | }) 15 | }) 16 | 17 | export type ReduxStore = typeof reduxStore 18 | export type ReduxState = ReturnType 19 | export type ReduxDispatch = typeof reduxStore.dispatch 20 | export type ReduxThunkAction = ThunkAction< 21 | ReturnType, 22 | ReduxState, 23 | unknown, 24 | Action 25 | > 26 | 27 | export const useDispatch = () => useReduxDispatch() 28 | export const useSelector: TypedUseSelectorHook = useReduxSelector 29 | -------------------------------------------------------------------------------- /src/templates/new/scss/index.scss.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | 3 | section.root-page { 4 | h2 { 5 | font-size: 32px; 6 | padding: 0 0 15px 0; 7 | } 8 | 9 | div.buttons { 10 | display: flex; 11 | align-items: center; 12 | justify-content: center; 13 | 14 | a.button { 15 | margin: 15px; 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /src/templates/new/scss/printer.scss.template: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&family=Oswald:wght@300;400;500;600;700&display=swap'); 2 | @import "/scss/reset.scss"; 3 | @import "/scss/theme.scss"; 4 | @import "/scss/ui.scss"; 5 | @import "/scss/index.scss"; -------------------------------------------------------------------------------- /src/templates/new/scss/reset.scss.template: -------------------------------------------------------------------------------- 1 | html, body, div, span, applet, object, iframe, 2 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 3 | a, abbr, acronym, address, big, cite, code, 4 | del, dfn, em, img, ins, kbd, q, s, samp, 5 | small, strike, strong, sub, sup, tt, var, 6 | b, u, i, center, 7 | dl, dt, dd, ol, ul, li, 8 | fieldset, form, label, legend, 9 | table, caption, tbody, tfoot, thead, tr, th, td, 10 | article, aside, canvas, details, embed, 11 | figure, figcaption, footer, header, hgroup, 12 | menu, nav, output, ruby, section, summary, 13 | time, mark, audio, video { 14 | margin: 0; 15 | padding: 0; 16 | border: 0; 17 | font-size: 100%; 18 | font: inherit; 19 | vertical-align: baseline; 20 | } 21 | /* HTML5 display-role reset for older browsers */ 22 | article, aside, details, figcaption, figure, 23 | footer, header, hgroup, menu, nav, section { 24 | display: block; 25 | } 26 | body { 27 | line-height: 1.5; 28 | } 29 | ol, ul { 30 | list-style: none; 31 | } 32 | blockquote, q { 33 | quotes: none; 34 | } 35 | blockquote:before, blockquote:after, 36 | q:before, q:after { 37 | content: ''; 38 | content: none; 39 | } 40 | table { 41 | border-collapse: collapse; 42 | border-spacing: 0; 43 | } 44 | -------------------------------------------------------------------------------- /src/templates/new/scss/theme.scss.template: -------------------------------------------------------------------------------- 1 | $header-font: 'Oswald'; 2 | $body-font: 'Montserrat'; 3 | 4 | $primary: #C49A0F; 5 | $primary-light: #F2D577; 6 | 7 | $container-width: 1268px; 8 | $page-height: 100vh; 9 | 10 | @mixin bg-gradient() { 11 | background: rgb(41, 41, 41); 12 | background: radial-gradient(circle, rgba(41, 41, 41, 1) 0%, rgba(29, 29, 29, 1) 100%); 13 | } 14 | 15 | @mixin transition($property: all, $duration: 0.25s) { 16 | transition: $property $duration cubic-bezier(0.33, 1, 0.68, 1); 17 | } -------------------------------------------------------------------------------- /src/templates/new/scss/ui.scss.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | 3 | * { 4 | box-sizing: border-box; 5 | } 6 | 7 | body { 8 | font-family: $body-font; 9 | @include bg-gradient(); 10 | color: white; 11 | margin: 0; 12 | padding: 0; 13 | overflow-x: hidden; 14 | } 15 | 16 | h1, h2, h3, h4, h5, h6 { 17 | font-family: $header-font; 18 | } 19 | 20 | h1 { 21 | font-size: 32px; 22 | } 23 | 24 | h2 { 25 | font-size: 24px; 26 | } 27 | 28 | h3 { 29 | font-size: 18px; 30 | } 31 | 32 | h4 { 33 | font-size: 16px; 34 | } 35 | 36 | a { 37 | cursor: pointer; 38 | } 39 | 40 | button, input, textarea { 41 | font-family: inherit; 42 | outline: none; 43 | } 44 | 45 | section.container, div.container { 46 | width: 100%; 47 | max-width: $container-width; 48 | margin: auto; 49 | &.page { 50 | min-height: $page-height; 51 | } 52 | &.flex { 53 | display: flex; 54 | flex-wrap: wrap; 55 | } 56 | &.center { 57 | display: flex; 58 | flex-direction: column; 59 | align-items: center; 60 | justify-content: center; 61 | } 62 | } 63 | 64 | a.button, button { 65 | display: flex; 66 | align-items: center; 67 | justify-content: center; 68 | width: 140px; 69 | height: 35px; 70 | border-radius: 3px; 71 | font-family: $body-font; 72 | font-size: 16px; 73 | font-weight: bold; 74 | background: $primary; 75 | color: white; 76 | text-decoration: none; 77 | margin: 0 15px 0 0; 78 | cursor: pointer; 79 | @include transition(); 80 | 81 | &:hover { 82 | background: $primary-light; 83 | } 84 | 85 | .i, .icon { 86 | margin: 0 8px 0 0; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/templates/new/tsconfig.json.template: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES5", 4 | "lib": [ 5 | "DOM", 6 | "DOM.iterable", 7 | "ESNext" 8 | ], 9 | "baseUrl": "./", 10 | "allowJs": true, 11 | "skipLibCheck": true, 12 | "strict": false, 13 | "forceConsistentCasingInFileNames": true, 14 | "noEmit": true, 15 | "incremental": true, 16 | "esModuleInterop": true, 17 | "module": "CommonJS", 18 | "moduleResolution": "Node", 19 | "resolveJsonModule": true, 20 | "isolatedModules": true, 21 | "jsx": "preserve", 22 | "plugins": [ 23 | { "name": "next" } 24 | ] 25 | }, 26 | "include": [ 27 | "**/*.ts", 28 | "**/*.tsx", 29 | ".next/types/**/*.ts" 30 | ], 31 | "exclude": [ 32 | "node_modules" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /src/templates/new/types/counter.tsx.template: -------------------------------------------------------------------------------- 1 | export interface CounterType { 2 | value: number 3 | } 4 | 5 | export default CounterType 6 | -------------------------------------------------------------------------------- /src/templates/new/util/session.ts.template: -------------------------------------------------------------------------------- 1 | import { getIronSession } from 'iron-session' 2 | import { cookies } from 'next/headers' 3 | 4 | export const password = 5 | process.env.SESSION_SECRET || 6 | 'ad75fbbbddbf8005cb60e3089d6f156440f9c8ac1d13ad33a8e4758fdff73ff8' 7 | 8 | export interface SessionI { 9 | counter?: number 10 | } 11 | 12 | export function getSession() { 13 | return getIronSession(cookies(), { 14 | password, 15 | cookieName: 'printer', 16 | cookieOptions: { 17 | secure: process.env.NODE_ENV === 'production', 18 | maxAge: process.env.COOKIE_AGE 19 | ? Number(process.env.COOKIE_AGE) 20 | : undefined 21 | } 22 | }) 23 | } 24 | -------------------------------------------------------------------------------- /src/templates/page.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | export interface {{name}}PageI { 4 | 5 | } 6 | 7 | export default function {{name}}Page({}: {{name}}PageI) { 8 | return ( 9 |
10 |

{{name}} Page

11 |
12 | ) 13 | } -------------------------------------------------------------------------------- /src/templates/page.url.template: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | export interface {{name}}PageI { 4 | {{url_interface}} 5 | } 6 | 7 | export default function {{name}}Page({ {{url_variables}} }: {{name}}PageI) { 8 | return ( 9 |
10 |

{{name}} Page

11 |
12 | ) 13 | } -------------------------------------------------------------------------------- /src/templates/scss.template: -------------------------------------------------------------------------------- 1 | @import "/scss/theme.scss"; 2 | -------------------------------------------------------------------------------- /src/templates/slice/reducer.template: -------------------------------------------------------------------------------- 1 | {{import}} 2 | 3 | export const reducer = { 4 | {{reducer}} 5 | } 6 | -------------------------------------------------------------------------------- /src/templates/slice/slice.template: -------------------------------------------------------------------------------- 1 | import { createSlice } from '@reduxjs/toolkit' 2 | 3 | export const {{name}}InitialState = {} 4 | 5 | export const {{name}}Slice = createSlice({ 6 | name: '{{name}}', 7 | initialState: {{name}}InitialState, 8 | reducers: {} 9 | }) 10 | 11 | export const {} = {{name}}Slice.actions 12 | -------------------------------------------------------------------------------- /src/templates/slice/slice.ts: -------------------------------------------------------------------------------- 1 | export function SliceTemplate (name: string) { 2 | return `import { createSlice } from "@reduxjs/toolkit"; 3 | 4 | export const ${name}InitialState = { 5 | 6 | } 7 | 8 | export const ${name}Slice = createSlice({ 9 | name: '${name}', 10 | initialState: ${name}InitialState, 11 | reducers: { 12 | 13 | }, 14 | }); 15 | 16 | export const { } = ${name}Slice.actions;` 17 | } 18 | -------------------------------------------------------------------------------- /src/templates/superagent.template: -------------------------------------------------------------------------------- 1 | const [loading, setLoading] = useState(false) 2 | const [error, setError] = useState(false) 3 | const [errorMessage, setErrorMessage] = useState('') 4 | 5 | async function {{type}}Request() { 6 | setLoading(true) 7 | setError(false) 8 | try { 9 | const payload = await {{type}}('/api/url') 10 | } catch (error) { 11 | console.error(error) 12 | setError(true) 13 | setErrorMessage('Something went wrong...') 14 | } 15 | setLoading(false) 16 | } 17 | 18 | useEffect(() => { 19 | {{type}}Request() 20 | }, [loading]) -------------------------------------------------------------------------------- /src/templates/type.template: -------------------------------------------------------------------------------- 1 | export interface {{name}}Type { 2 | 3 | } 4 | 5 | export default {{name}}Type 6 | -------------------------------------------------------------------------------- /test/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrinterFramework/CLI/58a0938f1765a8fb0f412020787bd2f021ae9b67/test/.gitkeep -------------------------------------------------------------------------------- /test/printer.test.ts: -------------------------------------------------------------------------------- 1 | import { write, remove } from 'fs-jetpack' 2 | import { Printer } from '../src/printer' 3 | import { Log } from '../src/helpers/log' 4 | import { registerConfig } from '../src/config' 5 | 6 | test('Printer - Ensure CLI can run', () => { 7 | expect(typeof Printer.parse).toBe('function') 8 | }) 9 | 10 | test('Config Registration', () => { 11 | registerConfig() 12 | write('printer.config.json', '{}') 13 | registerConfig() 14 | remove('printer.config.json') 15 | }) 16 | 17 | test('Utility - Log Function', () => { 18 | Log('Log test output') 19 | }) 20 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "dist", 4 | "moduleResolution": "node", 5 | "target": "ES5", 6 | "module": "CommonJS", 7 | "lib": ["ESNext"], 8 | "baseUrl": "src", 9 | "sourceMap": true, 10 | "declaration": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "downlevelIteration": true, 14 | "strict": true 15 | }, 16 | "exclude": [ 17 | "node_modules", 18 | "src/**/*.template" 19 | ], 20 | "include": [ 21 | "src/**/*.ts", 22 | "test/**/*.ts" 23 | ] 24 | } 25 | --------------------------------------------------------------------------------