diff --git a/CHANGELOG.md b/CHANGELOG.md index 2a7aed8..122e430 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # 🛠️ CHANGELOG +## v2.0.0 + +- Complete refactor to Next App Directories, review new documentation + +### Notice + +**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) + +**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) + ## v1.3.40 - Hotfix to type inference diff --git a/README.md b/README.md index 825cbbc..e1dcd16 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,15 @@ ## Automation Tooling for Next, Redux and Prisma ![license](https://img.shields.io/badge/license-AGPLv3-blue.svg) -![version](https://img.shields.io/badge/version-1.3.40-blue.svg) +![version](https://img.shields.io/badge/version-2.0.0-blue.svg) [![CircleCI](https://circleci.com/gh/PrinterFramework/CLI.svg?style=svg)](https://circleci.com/gh/PrinterFramework/CLI) [![codecov](https://codecov.io/gh/PrinterFramework/CLI/branch/master/graph/badge.svg)](https://codecov.io/gh/PrinterFramework/CLI) -Learn how to use Printer at [prntr.click](https://prntr.click). +**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) + +**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) + +Review the [CHANGELOG](./CHANGELOG.md) for any updates made to the project. ## How it works @@ -36,10 +40,6 @@ cd printer-sample printer component components/component ``` -Review the documentation on [prntr.click/docs](https://prntr.click/docs). - -Review the [CHANGELOG](./CHANGELOG.md) for any updates made to the project. - ## Comments and Feedback 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. diff --git a/dist/src/config.d.ts b/dist/src/config.d.ts old mode 100644 new mode 100755 index 8187af6..54758dc --- a/dist/src/config.d.ts +++ b/dist/src/config.d.ts @@ -1,11 +1,4 @@ export interface PrinterConfig { - componentFolder?: boolean; - component?: { - index?: boolean; - component?: boolean; - style?: boolean; - test?: boolean; - }; crud?: { create: boolean; update: boolean; diff --git a/dist/src/config.js b/dist/src/config.js old mode 100644 new mode 100755 index b168c60..089e3da --- a/dist/src/config.js +++ b/dist/src/config.js @@ -16,13 +16,6 @@ var fs_jetpack_1 = require("fs-jetpack"); var path_1 = require("path"); var log_1 = require("./helpers/log"); exports.Config = { - componentFolder: false, - component: { - index: true, - component: true, - style: false, - test: false - }, crud: { create: true, update: true, diff --git a/dist/src/config.js.map b/dist/src/config.js.map old mode 100644 new mode 100755 index 1b9321f..d8ed58a --- a/dist/src/config.js.map +++ b/dist/src/config.js.map @@ -1 +1 @@ -{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,yCAAiC;AACjC,6BAA2B;AAC3B,qCAAmC;AAmBxB,QAAA,MAAM,GAAkB;IACjC,eAAe,EAAE,KAAK;IACtB,SAAS,EAAE;QACT,KAAK,EAAE,IAAI;QACX,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,KAAK;QACZ,IAAI,EAAE,KAAK;KACZ;IACD,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"} \ No newline at end of file +{"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"} \ No newline at end of file diff --git a/dist/src/converter.d.ts b/dist/src/converter.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/converter.js b/dist/src/converter.js old mode 100644 new mode 100755 diff --git a/dist/src/converter.js.map b/dist/src/converter.js.map old mode 100644 new mode 100755 diff --git a/dist/src/generators/api.d.ts b/dist/src/generators/api.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/api.js b/dist/src/generators/api.js old mode 100644 new mode 100755 index ceb7b53..af3b094 --- a/dist/src/generators/api.js +++ b/dist/src/generators/api.js @@ -44,15 +44,13 @@ var prompts_1 = __importDefault(require("prompts")); var path_1 = require("path"); var fs_jetpack_1 = require("fs-jetpack"); var log_1 = require("../helpers/log"); -var nomenclature_1 = require("../helpers/nomenclature"); function generateApi(path) { - var _a; return __awaiter(this, void 0, void 0, function () { - var apiPath, result, pathArray, fileName, name, apiTemplate; - return __generator(this, function (_b) { - switch (_b.label) { + var apiPath, result, apiTemplate; + return __generator(this, function (_a) { + switch (_a.label) { case 0: - apiPath = (0, path_1.join)(process.cwd(), 'pages', 'api', "".concat(path, ".tsx")); + apiPath = (0, path_1.join)(process.cwd(), 'app', 'api', "".concat(path, "/route.tsx")); if (!((0, fs_jetpack_1.exists)(apiPath) !== false)) return [3 /*break*/, 2]; return [4 /*yield*/, (0, prompts_1.default)({ type: 'confirm', @@ -60,18 +58,15 @@ function generateApi(path) { message: 'This api already exists, overwrite it?' })]; case 1: - result = _b.sent(); + result = _a.sent(); if (result.overwrite === false) { return [2 /*return*/]; } - _b.label = 2; + _a.label = 2; case 2: - pathArray = path.split('/'); - fileName = pathArray[pathArray.length - 1]; - name = (0, nomenclature_1.formatName)(fileName); - apiTemplate = (_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'api.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name); + apiTemplate = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'api.template')); (0, fs_jetpack_1.write)(apiPath, apiTemplate || ''); - (0, log_1.Log)(" \u2705 Created pages/api/".concat(path, ".tsx").green); + (0, log_1.Log)(" \u2705 Created app/api/".concat(path, "/route.tsx").green); return [2 /*return*/]; } }); diff --git a/dist/src/generators/api.js.map b/dist/src/generators/api.js.map old mode 100644 new mode 100755 index 2b4fdab..61a8663 --- a/dist/src/generators/api.js.map +++ b/dist/src/generators/api.js.map @@ -1 +1 @@ -{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/generators/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC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C,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"} \ No newline at end of file diff --git a/dist/src/generators/component.d.ts b/dist/src/generators/component.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/component.js b/dist/src/generators/component.js old mode 100644 new mode 100755 index c92e1b9..2e9e8d9 --- a/dist/src/generators/component.js +++ b/dist/src/generators/component.js @@ -44,14 +44,13 @@ var prompts_1 = __importDefault(require("prompts")); var path_1 = require("path"); var fs_jetpack_1 = require("fs-jetpack"); var log_1 = require("../helpers/log"); -var config_1 = require("../config"); var nomenclature_1 = require("../helpers/nomenclature"); function generateComponent(path) { - var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l; + var _a; return __awaiter(this, void 0, void 0, function () { - var result, pathArray, fileName, name, component, componentPath, style, stylePath, test_1, testPath, index, indexPath, component, componentPath; - return __generator(this, function (_m) { - switch (_m.label) { + var result, pathArray, fileName, name, component, componentPath; + return __generator(this, function (_b) { + switch (_b.label) { case 0: 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]; return [4 /*yield*/, (0, prompts_1.default)({ @@ -60,49 +59,19 @@ function generateComponent(path) { message: 'This component already exists, overwrite it?' })]; case 1: - result = _m.sent(); + result = _b.sent(); if (result.overwrite === false) { return [2 /*return*/]; } - _m.label = 2; + _b.label = 2; case 2: pathArray = path.replace('.tsx', '').split('/'); fileName = pathArray[pathArray.length - 1]; name = (0, nomenclature_1.formatName)(fileName); - if (config_1.Config.componentFolder === true) { - 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); - componentPath = (0, path_1.join)(process.cwd(), path, "".concat(fileName, ".component.tsx")); - if (((_b = config_1.Config.component) === null || _b === void 0 ? void 0 : _b.style) === true) { - component = (_c = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'component.template'))) === null || _c === void 0 ? void 0 : _c.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path); - style = (_d = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'style.template'))) === null || _d === void 0 ? void 0 : _d.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path); - stylePath = (0, path_1.join)(process.cwd(), path, "".concat(fileName, ".style.tsx")); - (0, fs_jetpack_1.write)(stylePath, style || ''); - (0, log_1.Log)(" \u2705 Created ".concat(fileName, ".style.tsx").green); - } - (0, fs_jetpack_1.write)(componentPath, component || ''); - (0, log_1.Log)(" \u2705 Created ".concat(fileName, ".component.tsx").green); - if ((_e = config_1.Config.component) === null || _e === void 0 ? void 0 : _e.test) { - test_1 = (_f = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'test.template'))) === null || _f === void 0 ? void 0 : _f.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path); - testPath = (0, path_1.join)(process.cwd(), path, "".concat(fileName, ".test.tsx")); - (0, fs_jetpack_1.write)(testPath, test_1 || ''); - (0, log_1.Log)(" \u2705 Created ".concat(fileName, ".test.tsx").green); - } - if ((_g = config_1.Config.component) === null || _g === void 0 ? void 0 : _g.index) { - index = (_h = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'index.nostyle.template'))) === null || _h === void 0 ? void 0 : _h.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path); - indexPath = (0, path_1.join)(process.cwd(), path, 'index.tsx'); - if (((_j = config_1.Config.component) === null || _j === void 0 ? void 0 : _j.style) === true) { - index = (_k = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'index.template'))) === null || _k === void 0 ? void 0 : _k.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path).replaceAll('{{path}}', path); - } - (0, fs_jetpack_1.write)(indexPath, index || ''); - (0, log_1.Log)(' ✅ Created index.tsx'.green); - } - } - else { - component = (_l = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'component', 'component.nostyle.template'))) === null || _l === void 0 ? void 0 : _l.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path); - componentPath = (0, path_1.join)(process.cwd(), "".concat(path.replace('.tsx', ''), ".tsx")); - (0, fs_jetpack_1.write)(componentPath, component || ''); - (0, log_1.Log)(" \u2705 Created ".concat(path.replace('.tsx', ''), ".tsx").green); - } + 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); + componentPath = (0, path_1.join)(process.cwd(), "".concat(path.replace('.tsx', ''), ".tsx")); + (0, fs_jetpack_1.write)(componentPath, component || ''); + (0, log_1.Log)(" \u2705 Created ".concat(path.replace('.tsx', ''), ".tsx").green); return [2 /*return*/]; } }); diff --git a/dist/src/generators/component.js.map b/dist/src/generators/component.js.map old mode 100644 new mode 100755 index 064dd2a..af63024 --- a/dist/src/generators/component.js.map +++ b/dist/src/generators/component.js.map @@ -1 +1 @@ -{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/generators/component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oDAA6B;AAC7B,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,oCAAkC;AAClC,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,GA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AAO,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"} \ No newline at end of file diff --git a/dist/src/generators/crud.d.ts b/dist/src/generators/crud.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/crud.js b/dist/src/generators/crud.js old mode 100644 new mode 100755 index 0ad73d8..fb142b7 --- a/dist/src/generators/crud.js +++ b/dist/src/generators/crud.js @@ -45,13 +45,13 @@ var path_1 = require("path"); var fs_jetpack_1 = require("fs-jetpack"); var log_1 = require("../helpers/log"); function generateCrud(model) { - var _a, _b, _c, _d, _e; + var _a; return __awaiter(this, void 0, void 0, function () { - var basePath, result, createPath, createTemplate, updatePath, updateTemplate, getPath, getTemplate, listPath, listTemplate, deletePath, deleteTemplate; - return __generator(this, function (_f) { - switch (_f.label) { + var basePath, result, routePath, routeTemplate; + return __generator(this, function (_b) { + switch (_b.label) { case 0: - basePath = (0, path_1.join)(process.cwd(), 'pages', 'api', model); + basePath = (0, path_1.join)(process.cwd(), 'app', 'api', model); if (!((0, fs_jetpack_1.exists)(basePath) !== false)) return [3 /*break*/, 2]; return [4 /*yield*/, (0, prompts_1.default)({ type: 'confirm', @@ -59,32 +59,16 @@ function generateCrud(model) { message: 'Routes already exist in this folder, overwrite it?' })]; case 1: - result = _f.sent(); + result = _b.sent(); if (result.overwrite === false) { return [2 /*return*/]; } - _f.label = 2; + _b.label = 2; case 2: - createPath = (0, path_1.join)(basePath, 'create.tsx'); - createTemplate = (_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'crud', 'create.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{model}}', model); - (0, fs_jetpack_1.write)(createPath, createTemplate || ''); - (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/create.tsx").green); - updatePath = (0, path_1.join)(basePath, 'update.tsx'); - updateTemplate = (_b = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'crud', 'update.template'))) === null || _b === void 0 ? void 0 : _b.replaceAll('{{model}}', model); - (0, fs_jetpack_1.write)(updatePath, updateTemplate || ''); - (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/update.tsx").green); - getPath = (0, path_1.join)(basePath, 'get.tsx'); - getTemplate = (_c = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'crud', 'get.template'))) === null || _c === void 0 ? void 0 : _c.replaceAll('{{model}}', model); - (0, fs_jetpack_1.write)(getPath, getTemplate || ''); - (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/get.tsx").green); - listPath = (0, path_1.join)(basePath, 'list.tsx'); - listTemplate = (_d = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'crud', 'list.template'))) === null || _d === void 0 ? void 0 : _d.replaceAll('{{model}}', model); - (0, fs_jetpack_1.write)(listPath, listTemplate || ''); - (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/list.tsx").green); - deletePath = (0, path_1.join)(basePath, 'delete.tsx'); - deleteTemplate = (_e = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'crud', 'delete.template'))) === null || _e === void 0 ? void 0 : _e.replaceAll('{{model}}', model); - (0, fs_jetpack_1.write)(deletePath, deleteTemplate || ''); - (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/delete.tsx").green); + routePath = (0, path_1.join)(basePath, 'route.tsx'); + 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); + (0, fs_jetpack_1.write)(routePath, routeTemplate || ''); + (0, log_1.Log)(" \u2705 Created pages/api/".concat(model, "/route.tsx").green); return [2 /*return*/]; } }); diff --git a/dist/src/generators/crud.js.map b/dist/src/generators/crud.js.map old mode 100644 new mode 100755 index cc89d9f..038c324 --- a/dist/src/generators/crud.js.map +++ b/dist/src/generators/crud.js.map @@ -1 +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,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;yBAEvD,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,UAAU,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;oBACzC,cAAc,GAAG,MAAA,IAAA,iBAAI,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC,0CAAE,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAA;oBAC1H,IAAA,kBAAK,EAAC,UAAU,EAAE,cAAc,IAAI,EAAE,CAAC,CAAA;oBACvC,IAAA,SAAG,EAAC,wCAA4B,KAAK,gBAAa,CAAC,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AE,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"} \ No newline at end of file diff --git a/dist/src/generators/inject.d.ts b/dist/src/generators/inject.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/inject.js b/dist/src/generators/inject.js old mode 100644 new mode 100755 index eef5f70..818a9f2 --- a/dist/src/generators/inject.js +++ b/dist/src/generators/inject.js @@ -43,7 +43,7 @@ var log_1 = require("../helpers/log"); var match_1 = require("../helpers/match"); function inject(slice, component, opts) { return __awaiter(this, void 0, void 0, function () { - var filePath, pathArray, fileName, fileContents, fileComponentPath, slicePath, sliceContents, matches, splitFile, sliceMatch, newContents, stateInjections, actionInjections, i, index, match, decorator, typeMap, varKey, addDots, varKey, hasExistingImport, i, stateInjection, typeName, i, stateInjection, injectionLine, tempContents, typeMap, value, spreadLeft, spreadRight, typeName, injectionLine, tempContents, tempContents, fileComponentPath; + var filePath, pathArray, fileName, fileContents, fileComponentPath, slicePath, sliceContents, matches, splitFile, sliceMatch, newContents, stateInjections, actionInjections, i, index, match, decorator, typeMap, varKey, addDots, varKey, hasExistingImport, i, stateInjection, typeName, i, stateInjection, injectionLine, tempContents, value, spreadLeft, spreadRight, typeName, injectionLine, tempContents, tempContents, fileComponentPath; return __generator(this, function (_a) { component = component.replaceAll('.tsx', ''); filePath = (0, path_1.join)(process.cwd(), component); @@ -89,10 +89,10 @@ function inject(slice, component, opts) { } hasExistingImport = (0, match_1.findMatches)(newContents, match_1.ReduxOptionalMatcher); if (hasExistingImport.length > 0) { - newContents = newContents.replace(match_1.ReduxOptionalMatcher, 'import { useSelector, useDispatch } from \'react-redux\''); + newContents = newContents.replace(match_1.ReduxOptionalMatcher, 'import { useAppSelector, useAppDispatch } from \'redux/hooks\''); } else { - newContents = "import { useSelector, useDispatch } from 'react-redux'\n\n".concat(newContents); + newContents = "import { useAppSelector, useAppDispatch } from 'redux/hooks'\n\n".concat(newContents); } if (opts.state) { for (i = 0; i < stateInjections.length; i++) { @@ -112,7 +112,6 @@ function inject(slice, component, opts) { if ((0, match_1.findMatches)(newContents, (0, match_1.selectorMatcher)(stateInjection.value)).length === 0) { injectionLine = (0, match_1.findMatches)(newContents, (0, match_1.functionMatcher)(fileName))[0]; tempContents = newContents.split('\n'); - typeMap = 'any'; value = stateInjection.value; spreadLeft = '{'; spreadRight = '}'; @@ -124,9 +123,8 @@ function inject(slice, component, opts) { spreadLeft = '['; spreadRight = ']'; } - typeMap = "{ ".concat(slice, ": { ").concat(value, ": ").concat(typeName, " } }"); } - tempContents[injectionLine] = tempContents[injectionLine] + "\n const ".concat(value, " = useSelector((state: ").concat(typeMap, ") => ").concat(stateInjection.addDots ? '(' + spreadLeft + ' ' : '').concat(stateInjection.addDots ? '...' : '', "state.").concat(slice, ".").concat(value).concat(stateInjection.addDots ? ' ' + spreadRight + ')' : '', ")"); + tempContents[injectionLine] = tempContents[injectionLine] + "\n const ".concat(value, " = useAppSelector((state) => ").concat(stateInjection.addDots ? '(' + spreadLeft + ' ' : '').concat(stateInjection.addDots ? '...' : '', "state.").concat(slice, ".").concat(value).concat(stateInjection.addDots ? ' ' + spreadRight + ')' : '', ")"); if (i === 0) { tempContents[injectionLine] = tempContents[injectionLine] + '\n'; } @@ -154,6 +152,10 @@ function inject(slice, component, opts) { (0, log_1.Log)(" \u2705 ".concat(actionInjections.length, " action").concat(actionInjections.length > 1 ? 's were' : ' was', " injected into the component").green); } } + if (filePath.indexOf('app/') !== -1) { + newContents = newContents.replaceAll('\'use client\'', ''); + newContents = '\'use client\'\n' + newContents; + } if ((0, fs_jetpack_1.exists)(filePath) === 'dir') { fileComponentPath = (0, path_1.join)(process.cwd(), component, "".concat(fileName, ".component.tsx")); (0, fs_jetpack_1.write)(fileComponentPath, newContents); diff --git a/dist/src/generators/inject.js.map b/dist/src/generators/inject.js.map old mode 100644 new mode 100755 index 2b7ef08..2c68162 --- a/dist/src/generators/inject.js.map +++ b/dist/src/generators/inject.js.map @@ -1 +1 @@ -{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../src/generators/inject.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6BAA2B;AAC3B,yCAAgD;AAChD,sCAAoC;AACpC,0CAA8L;AAO9L,SAAsB,MAAM,CAAE,KAAa,EAAE,SAAiB,EAAE,IAAc;;;;YAC5E,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,CAAA;YACtC,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,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,EAAE;gBACxB,iBAAiB,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,UAAG,QAAQ,mBAAgB,CAAC,CAAA;gBACrF,YAAY,GAAG,IAAA,iBAAI,EAAC,iBAAiB,CAAC,IAAI,EAAE,CAAA;aAC7C;iBAAM;gBACL,YAAY,GAAG,IAAA,iBAAI,EAAC,UAAG,QAAQ,SAAM,CAAC,IAAI,EAAE,CAAA;aAC7C;YAEK,SAAS,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,UAAG,KAAK,SAAM,CAAC,CAAA;YACjE,aAAa,GAAG,IAAA,iBAAI,EAAC,SAAS,CAAC,IAAI,EAAE,CAAA;YAErC,OAAO,GAAG,IAAA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,GAAG,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;wBAC5C,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,GAAG,qBAAc,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,kCAAwB,KAAK,MAAG,CAAA;wBAC7G,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;qBACtC;oBAED,IAAA,SAAG,EAAC,sBAAU,gBAAgB,CAAC,MAAM,oBAAU,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,iCAA8B,CAAC,KAAK,CAAC,CAAA;iBACpI;aACF;YAED,IAAI,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE;gBACnC,WAAW,GAAG,WAAW,CAAC,UAAU,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAA;gBAC1D,WAAW,GAAG,kBAAkB,GAAG,WAAW,CAAA;aAC/C;YAED,IAAI,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,EAAE;gBACxB,iBAAiB,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,UAAG,QAAQ,mBAAgB,CAAC,CAAA;gBACrF,IAAA,kBAAK,EAAC,iBAAiB,EAAE,WAAW,CAAC,CAAA;aACtC;iBAAM;gBACL,IAAA,kBAAK,EAAC,UAAG,QAAQ,SAAM,EAAE,WAAW,CAAC,CAAA;aACtC;;;;CACF;AA5ID,wBA4IC"} \ No newline at end of file diff --git a/dist/src/generators/new.d.ts b/dist/src/generators/new.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/new.js b/dist/src/generators/new.js old mode 100644 new mode 100755 index 2276ce0..6f4fc81 --- a/dist/src/generators/new.js +++ b/dist/src/generators/new.js @@ -35,6 +35,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) { if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } }; +var __values = (this && this.__values) || function(o) { + var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { value: o && o[i++], done: !o }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); +}; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; @@ -46,98 +57,157 @@ var fs_jetpack_1 = require("fs-jetpack"); var log_1 = require("../helpers/log"); var crypto_1 = require("crypto"); function generateNewProject(path) { - var _a; if (path === void 0) { path = '.'; } return __awaiter(this, void 0, void 0, function () { - var readmePath, appPath, documentPath, babelPath, gitignorePath, gitkeepPath, envdevPath, gitkeepPublicPath, indexPath, utilSessionPath, resetCssPath, printerScssPath, themeScssPath, uiScssPath, prismaClientPath, prismaSchemaPath, packagePath, wrapperPath, reducerPath, reducersPath, tsconfigPath, precommitPath, eslintrcPath, printerConfigPath, result; - return __generator(this, function (_b) { - switch (_b.label) { + var configPath, result, root, root_1, root_1_1, item, itemPath, contents, sessionPath, sessionContents, counterTypePath, counterTypeContents, scss, scss_1, scss_1_1, item, itemPath, contents, prisma, prisma_1, prisma_1_1, item, itemPath, contents, redux, redux_1, redux_1_1, item, itemPath, contents, reduxSlicePath, reduxSliceContents, app, app_1, app_1_1, item, itemPath, contents; + var e_1, _a, e_2, _b, e_3, _c, e_4, _d, e_5, _e; + return __generator(this, function (_f) { + switch (_f.label) { case 0: - readmePath = (0, path_1.join)(process.cwd(), path, 'README.md'); - appPath = (0, path_1.join)(process.cwd(), path, 'pages', '_app.tsx'); - documentPath = (0, path_1.join)(process.cwd(), path, 'pages', '_document.tsx'); - babelPath = (0, path_1.join)(process.cwd(), path, '.babelrc'); - gitignorePath = (0, path_1.join)(process.cwd(), path, '.gitignore'); - gitkeepPath = (0, path_1.join)(process.cwd(), path, '.gitkeep'); - envdevPath = (0, path_1.join)(process.cwd(), path, '.env.dev'); - gitkeepPublicPath = (0, path_1.join)(process.cwd(), path, 'public', '.gitkeep'); - indexPath = (0, path_1.join)(process.cwd(), path, 'pages', 'index.tsx'); - utilSessionPath = (0, path_1.join)(process.cwd(), path, 'util', 'session.ts'); - resetCssPath = (0, path_1.join)(process.cwd(), path, 'scss', 'reset.scss'); - printerScssPath = (0, path_1.join)(process.cwd(), path, 'scss', 'printer.scss'); - themeScssPath = (0, path_1.join)(process.cwd(), path, 'scss', 'theme.scss'); - uiScssPath = (0, path_1.join)(process.cwd(), path, 'scss', 'ui.scss'); - prismaClientPath = (0, path_1.join)(process.cwd(), path, 'prisma', 'client.ts'); - prismaSchemaPath = (0, path_1.join)(process.cwd(), path, 'prisma', 'schema.prisma'); - packagePath = (0, path_1.join)(process.cwd(), path, 'package.json'); - wrapperPath = (0, path_1.join)(process.cwd(), path, 'redux', 'wrapper.tsx'); - reducerPath = (0, path_1.join)(process.cwd(), path, 'redux', 'reducer.tsx'); - reducersPath = (0, path_1.join)(process.cwd(), path, 'redux', 'reducers.json'); - tsconfigPath = (0, path_1.join)(process.cwd(), path, 'tsconfig.json'); - precommitPath = (0, path_1.join)(process.cwd(), path, '.husky', 'pre-commit'); - eslintrcPath = (0, path_1.join)(process.cwd(), path, '.eslintrc.js'); - printerConfigPath = (0, path_1.join)(process.cwd(), path, 'printer.config.json'); - if (!((0, fs_jetpack_1.exists)(printerConfigPath) !== false)) return [3 /*break*/, 2]; + configPath = (0, path_1.join)(process.cwd(), path, 'printer.config.json'); + if (!((0, fs_jetpack_1.exists)(configPath) !== false)) return [3 /*break*/, 2]; return [4 /*yield*/, (0, prompts_1.default)({ type: 'confirm', name: 'overwrite', message: 'A project already exists here, overwrite it?' })]; case 1: - result = _b.sent(); + result = _f.sent(); if (result.overwrite === false) { return [2 /*return*/]; } - _b.label = 2; + _f.label = 2; case 2: - (0, fs_jetpack_1.write)(readmePath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'readme.template')) || ''); - (0, log_1.Log)(' ✅ Created README.md'.green); - (0, fs_jetpack_1.write)(babelPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'babelrc.template')) || ''); - (0, log_1.Log)(' ✅ Created .babelrc'.green); - (0, fs_jetpack_1.write)(gitignorePath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'gitignore.template')) || ''); - (0, log_1.Log)(' ✅ Created .gitignore'.green); - (0, fs_jetpack_1.write)(gitkeepPath, ''); - (0, log_1.Log)(' ✅ Created .gitkeep'.green); - (0, fs_jetpack_1.write)(envdevPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'env.dev.template')) || ''); - (0, log_1.Log)(' ✅ Created .env.dev'.green); - (0, fs_jetpack_1.write)(gitkeepPublicPath, ''); - (0, log_1.Log)(' ✅ Created public/.gitkeep'.green); - (0, fs_jetpack_1.write)(appPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', '_app.template')) || ''); - (0, log_1.Log)(' ✅ Created pages/_app.tsx'.green); - (0, fs_jetpack_1.write)(documentPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', '_document.template')) || ''); - (0, log_1.Log)(' ✅ Created pages/_document.tsx'.green); - (0, fs_jetpack_1.write)(indexPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'index.template')) || ''); - (0, log_1.Log)(' ✅ Created pages/index.tsx'.green); - (0, fs_jetpack_1.write)(utilSessionPath, ((_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'session.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{password}}', (0, crypto_1.randomBytes)(32).toString('hex'))) || ''); + root = [ + 'printer.config.json', + '.env.dev.local', + '.eslintrc.js', + '.gitignore', + 'middleware.tsx', + 'next.config.js', + 'package.json', + 'README.md', + 'tsconfig.json' + ]; + try { + for (root_1 = __values(root), root_1_1 = root_1.next(); !root_1_1.done; root_1_1 = root_1.next()) { + item = root_1_1.value; + itemPath = (0, path_1.join)(process.cwd(), path, item); + contents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', "".concat(item, ".template"))) || ''; + if (item === '.env.dev.local') { + contents = contents.replaceAll('{{password}}', (0, crypto_1.randomBytes)(32).toString('hex')); + } + (0, fs_jetpack_1.write)(itemPath, contents); + (0, log_1.Log)(" \u2705 Created ".concat(item).green); + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (root_1_1 && !root_1_1.done && (_a = root_1.return)) _a.call(root_1); + } + finally { if (e_1) throw e_1.error; } + } + (0, fs_jetpack_1.write)((0, path_1.join)(process.cwd(), path, 'public', '.gitkeep'), ''); + sessionPath = (0, path_1.join)(process.cwd(), path, 'util', 'session.ts'); + sessionContents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'util', 'session.ts.template')) || ''; + sessionContents = sessionContents.replaceAll('{{password}}', (0, crypto_1.randomBytes)(32).toString('hex')); + (0, fs_jetpack_1.write)(sessionPath, sessionContents); (0, log_1.Log)(' ✅ Created util/session.ts'.green); - (0, fs_jetpack_1.write)(resetCssPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'reset.template')) || ''); - (0, log_1.Log)(' ✅ Created scss/reset.css'.green); - (0, fs_jetpack_1.write)(printerScssPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'printer.template')) || ''); - (0, log_1.Log)(' ✅ Created scss/printer.scss'.green); - (0, fs_jetpack_1.write)(themeScssPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'theme.template')) || ''); - (0, log_1.Log)(' ✅ Created scss/theme.scss'.green); - (0, fs_jetpack_1.write)(uiScssPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'ui.template')) || ''); - (0, log_1.Log)(' ✅ Created scss/ui.scss'.green); - (0, fs_jetpack_1.write)(prismaClientPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'prisma.client.template')) || ''); - (0, log_1.Log)(' ✅ Created prisma/client.ts'.green); - (0, fs_jetpack_1.write)(prismaSchemaPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'schema.prisma.template')) || ''); - (0, log_1.Log)(' ✅ Created prisma/schema.prisma'.green); - (0, fs_jetpack_1.write)(packagePath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'package.template')) || ''); - (0, log_1.Log)(' ✅ Created package.json'.green); - (0, fs_jetpack_1.write)(wrapperPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'wrapper.template')) || ''); - (0, log_1.Log)(' ✅ Created redux/wrapper.tsx'.green); - (0, fs_jetpack_1.write)(reducerPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'reducer.template')) || ''); - (0, log_1.Log)(' ✅ Created redux/reducer.tsx'.green); - (0, fs_jetpack_1.write)(reducersPath, '[]'); - (0, log_1.Log)(' ✅ Created redux/reducers.json'.green); - (0, fs_jetpack_1.write)(tsconfigPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'tsconfig.template')) || ''); - (0, log_1.Log)(' ✅ Created tsconfig.json'.green); - (0, fs_jetpack_1.write)(precommitPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'precommit.template')) || ''); - (0, log_1.Log)(' ✅ Created .husky/pre-commit'.green); - (0, fs_jetpack_1.write)(eslintrcPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'eslintrc.template')) || ''); - (0, log_1.Log)(' ✅ Created printer.config.json'.green); - (0, fs_jetpack_1.write)(printerConfigPath, (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'printer.config.template')) || ''); - (0, log_1.Log)(' ✅ Created .eslintrc.js'.green); + counterTypePath = (0, path_1.join)(process.cwd(), path, 'types', 'counter.tsx'); + counterTypeContents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'types', 'counter.tsx.template')) || ''; + (0, fs_jetpack_1.write)(counterTypePath, counterTypeContents); + (0, log_1.Log)(' ✅ Created types/counter.tsx'.green); + scss = [ + 'printer.scss', + 'reset.scss', + 'theme.scss', + 'ui.scss', + 'index.scss' + ]; + try { + for (scss_1 = __values(scss), scss_1_1 = scss_1.next(); !scss_1_1.done; scss_1_1 = scss_1.next()) { + item = scss_1_1.value; + itemPath = (0, path_1.join)(process.cwd(), path, 'scss', item); + contents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'scss', "".concat(item, ".template"))) || ''; + (0, fs_jetpack_1.write)(itemPath, contents); + (0, log_1.Log)(" \u2705 Created scss/".concat(item).green); + } + } + catch (e_2_1) { e_2 = { error: e_2_1 }; } + finally { + try { + if (scss_1_1 && !scss_1_1.done && (_b = scss_1.return)) _b.call(scss_1); + } + finally { if (e_2) throw e_2.error; } + } + prisma = [ + 'client.ts', + 'schema.prisma' + ]; + try { + for (prisma_1 = __values(prisma), prisma_1_1 = prisma_1.next(); !prisma_1_1.done; prisma_1_1 = prisma_1.next()) { + item = prisma_1_1.value; + itemPath = (0, path_1.join)(process.cwd(), path, 'prisma', item); + contents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'prisma', "".concat(item, ".template"))) || ''; + (0, fs_jetpack_1.write)(itemPath, contents); + (0, log_1.Log)(" \u2705 Created prisma/".concat(item).green); + } + } + catch (e_3_1) { e_3 = { error: e_3_1 }; } + finally { + try { + if (prisma_1_1 && !prisma_1_1.done && (_c = prisma_1.return)) _c.call(prisma_1); + } + finally { if (e_3) throw e_3.error; } + } + redux = [ + 'hooks.tsx', + 'provider.tsx', + 'reducer.tsx', + 'reducers.json', + 'store.tsx' + ]; + try { + for (redux_1 = __values(redux), redux_1_1 = redux_1.next(); !redux_1_1.done; redux_1_1 = redux_1.next()) { + item = redux_1_1.value; + itemPath = (0, path_1.join)(process.cwd(), path, 'redux', item); + contents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'redux', "".concat(item, ".template"))) || ''; + (0, fs_jetpack_1.write)(itemPath, contents); + (0, log_1.Log)(" \u2705 Created redux/".concat(item).green); + } + } + catch (e_4_1) { e_4 = { error: e_4_1 }; } + finally { + try { + if (redux_1_1 && !redux_1_1.done && (_d = redux_1.return)) _d.call(redux_1); + } + finally { if (e_4) throw e_4.error; } + } + reduxSlicePath = (0, path_1.join)(process.cwd(), path, 'redux', 'slice', 'counter.tsx'); + reduxSliceContents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'redux', 'slice', 'counter.tsx.template')) || ''; + (0, fs_jetpack_1.write)(reduxSlicePath, reduxSliceContents); + (0, log_1.Log)(' ✅ Created redux/slice/counter.tsx'.green); + app = [ + 'layout.tsx', + 'page.tsx' + ]; + try { + for (app_1 = __values(app), app_1_1 = app_1.next(); !app_1_1.done; app_1_1 = app_1.next()) { + item = app_1_1.value; + itemPath = (0, path_1.join)(process.cwd(), path, 'app', item); + contents = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'new', 'app', "".concat(item, ".template"))) || ''; + (0, fs_jetpack_1.write)(itemPath, contents); + (0, log_1.Log)(" \u2705 Created app/".concat(item).green); + } + } + catch (e_5_1) { e_5 = { error: e_5_1 }; } + finally { + try { + if (app_1_1 && !app_1_1.done && (_e = app_1.return)) _e.call(app_1); + } + finally { if (e_5) throw e_5.error; } + } return [2 /*return*/]; } }); diff --git a/dist/src/generators/new.js.map b/dist/src/generators/new.js.map old mode 100644 new mode 100755 index d870cad..b066477 --- a/dist/src/generators/new.js.map +++ b/dist/src/generators/new.js.map @@ -1 +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,WAAW,CAAC,CAAA;oBACnD,OAAO,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,UAAU,CAAC,CAAA;oBACxD,YAAY,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,eAAe,CAAC,CAAA;oBAClE,SAAS,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;oBACjD,aAAa,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,YAAY,CAAC,CAAA;oBACvD,WAAW,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;oBACnD,UAAU,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;oBAClD,iBAAiB,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAA;oBACnE,SAAS,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,IAA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 No newline at end of file diff --git a/dist/src/generators/page.d.ts b/dist/src/generators/page.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/page.js b/dist/src/generators/page.js old mode 100644 new mode 100755 index 4b7c0a1..39a59e1 --- a/dist/src/generators/page.js +++ b/dist/src/generators/page.js @@ -46,13 +46,13 @@ var fs_jetpack_1 = require("fs-jetpack"); var log_1 = require("../helpers/log"); var nomenclature_1 = require("../helpers/nomenclature"); function generatePage(path) { - var _a, _b; + var _a; return __awaiter(this, void 0, void 0, function () { - var pagePath, result, pathArray, fileName, urls, name, pageTemplate; - return __generator(this, function (_c) { - switch (_c.label) { + var pagePath, result, pathArray, fileName, urls, name, pageTemplate, urlInterface; + return __generator(this, function (_b) { + switch (_b.label) { case 0: - pagePath = (0, path_1.join)(process.cwd(), 'pages', "".concat(path.replace('.tsx', ''), ".tsx")); + pagePath = (0, path_1.join)(process.cwd(), 'app', "".concat(path.replace('.tsx', ''), "/page.tsx")); if (!((0, fs_jetpack_1.exists)(pagePath) !== false)) return [3 /*break*/, 2]; return [4 /*yield*/, (0, prompts_1.default)({ type: 'confirm', @@ -60,28 +60,31 @@ function generatePage(path) { message: 'This page already exists, overwrite it?' })]; case 1: - result = _c.sent(); + result = _b.sent(); if (result.overwrite === false) { return [2 /*return*/]; } - _c.label = 2; + _b.label = 2; case 2: pathArray = path.replace('.tsx', '').split('/'); fileName = pathArray[pathArray.length - 1]; urls = []; name = (0, nomenclature_1.formatName)(fileName); pageTemplate = ''; - console.log(name, path); if (path.match(/\[(.*?)\]/g)) { urls = path.match(/\[(.*?)\]/g); urls = urls.map(function (url) { return url.replace(/\[/g, '').replace(/\]/g, ''); }); - pageTemplate = ((_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'page.url.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name).replaceAll('{{url}}', urls.join(', '))) || ''; + urlInterface = urls.map(function (url) { return "".concat(url, ": string"); }); + pageTemplate = ((0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'page.url.template')) || '') + .replaceAll('{{name}}', name) + .replaceAll('{{url_variables}}', 'params') + .replaceAll('{{url_interface}}', "params: {\n ".concat(urlInterface.join('\n'), "\n }")); } else { - pageTemplate = ((_b = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'page.template'))) === null || _b === void 0 ? void 0 : _b.replaceAll('{{name}}', name)) || ''; + pageTemplate = ((_a = (0, fs_jetpack_1.read)((0, path_1.join)(__dirname, '..', 'templates', 'page.template'))) === null || _a === void 0 ? void 0 : _a.replaceAll('{{name}}', name)) || ''; } (0, fs_jetpack_1.write)(pagePath, pageTemplate); - (0, log_1.Log)(" \u2705 Created pages/".concat(path, ".tsx").green); + (0, log_1.Log)(" \u2705 Created app/".concat(path, "/page.tsx").green); return [2 /*return*/]; } }); diff --git a/dist/src/generators/page.js.map b/dist/src/generators/page.js.map old mode 100644 new mode 100755 index 9409bae..ad0b37e --- a/dist/src/generators/page.js.map +++ b/dist/src/generators/page.js.map @@ -1 +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,CAAE,IAAY;;;;;;;oBACxC,QAAQ,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,UAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,SAAM,CAAC,CAAA;yBAE5E,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,yCAAy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AC5B,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAa,CAAA;wBAC3C,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAA,GAAG,IAAI,OAAA,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,EAAzC,CAAyC,CAAC,CAAA;wBAE3D,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,UAAC,GAAG,IAAK,OAAA,UAAG,GAAG,aAAU,EAAhB,CAAgB,CAAC,CAAA;wBAExD,YAAY,GAAG,CAAC,IAAA,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"} \ No newline at end of file diff --git a/dist/src/generators/prisma.d.ts b/dist/src/generators/prisma.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/prisma.js b/dist/src/generators/prisma.js old mode 100644 new mode 100755 diff --git a/dist/src/generators/prisma.js.map b/dist/src/generators/prisma.js.map old mode 100644 new mode 100755 diff --git a/dist/src/generators/scss.d.ts b/dist/src/generators/scss.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/scss.js b/dist/src/generators/scss.js old mode 100644 new mode 100755 diff --git a/dist/src/generators/scss.js.map b/dist/src/generators/scss.js.map old mode 100644 new mode 100755 diff --git a/dist/src/generators/slice.d.ts b/dist/src/generators/slice.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/slice.js b/dist/src/generators/slice.js old mode 100644 new mode 100755 diff --git a/dist/src/generators/slice.js.map b/dist/src/generators/slice.js.map old mode 100644 new mode 100755 diff --git a/dist/src/generators/superagent.d.ts b/dist/src/generators/superagent.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/superagent.js b/dist/src/generators/superagent.js old mode 100644 new mode 100755 index c5e36be..7eb2d47 --- a/dist/src/generators/superagent.js +++ b/dist/src/generators/superagent.js @@ -44,24 +44,21 @@ var match_1 = require("../helpers/match"); function injectSupergent(type, component) { var _a; return __awaiter(this, void 0, void 0, function () { - var filePath, pathArray, fileName, fileContents, fileComponentPath, injectionLine, tempContents, superAgentFlow, newContents, fileComponentPath; + var filePath, pathArray, fileName, fileContents, injectionLine, tempContents, superAgentFlow, newContents, fileComponentPath; return __generator(this, function (_b) { filePath = (0, path_1.join)(process.cwd(), component); pathArray = component.split('/'); fileName = pathArray[pathArray.length - 1]; fileContents = ''; if (filePath.indexOf('.tsx') === -1) { - if ((0, fs_jetpack_1.exists)(filePath) === 'dir') { - fileComponentPath = (0, path_1.join)(process.cwd(), component, "".concat(fileName, ".component.tsx")); - fileContents = (0, fs_jetpack_1.read)(fileComponentPath) || ''; - } - else { - fileContents = (0, fs_jetpack_1.read)("".concat(filePath, ".tsx")) || ''; - } + fileContents = (0, fs_jetpack_1.read)("".concat(filePath, ".tsx")) || ''; } else { fileContents = (0, fs_jetpack_1.read)("".concat(filePath)) || ''; } + if ((0, match_1.findMatches)(fileContents, (0, match_1.stateMatcher)()).length === 0 && (0, match_1.findMatches)(fileContents, (0, match_1.effectMatcher)()).length === 0) { + fileContents = 'import { useState, useEffect } from \'react\'' + '\n' + fileContents; + } if ((0, match_1.findMatches)(fileContents, (0, match_1.stateMatcher)()).length === 0) { fileContents = 'import { useState } from \'react\'' + '\n' + fileContents; } diff --git a/dist/src/generators/superagent.js.map b/dist/src/generators/superagent.js.map old mode 100644 new mode 100755 index 527662d..d951888 --- a/dist/src/generators/superagent.js.map +++ b/dist/src/generators/superagent.js.map @@ -1 +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,IAAI,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,EAAE;oBACxB,iBAAiB,GAAG,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,UAAG,QAAQ,mBAAgB,CAAC,CAAA;oBACrF,YAAY,GAAG,IAAA,iBAAI,EAAC,iBAAiB,CAAC,IAAI,EAAE,CAAA;iBAC7C;qBAAM;oBACL,YAAY,GAAG,IAAA,iBAAI,EAAC,UAAG,QAAQ,SAAM,CAAC,IAAI,EAAE,CAAA;iBAC7C;aACF;iBAAM;gBACL,YAAY,GAA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,aAAa,CAAC,IAAI,IAAI,GAAG,cAAc,GAAG,IAAI,CAAA;YACrD,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YAE3C,IAAI,IAAA,mBAAM,EAAC,QAAQ,CAAC,KAAK,KAAK,EAAE;gBACxB,iBAAiB,GAAG,IAAA,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"} \ No newline at end of file diff --git a/dist/src/generators/type.d.ts b/dist/src/generators/type.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/generators/type.js b/dist/src/generators/type.js old mode 100644 new mode 100755 diff --git a/dist/src/generators/type.js.map b/dist/src/generators/type.js.map old mode 100644 new mode 100755 diff --git a/dist/src/helpers/log.d.ts b/dist/src/helpers/log.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/helpers/log.js b/dist/src/helpers/log.js old mode 100644 new mode 100755 diff --git a/dist/src/helpers/log.js.map b/dist/src/helpers/log.js.map old mode 100644 new mode 100755 diff --git a/dist/src/helpers/match.d.ts b/dist/src/helpers/match.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/helpers/match.js b/dist/src/helpers/match.js old mode 100644 new mode 100755 index ead5c94..42970bc --- a/dist/src/helpers/match.js +++ b/dist/src/helpers/match.js @@ -3,9 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); 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; exports.SliceMatcher = /^(?=.*export)(?=.*createSlice).*$/gmi; exports.ImportMatcher = /^(?=.*import)(?=.*from).*$/gmi; -exports.ReduxMatcher = /^(?=.*import)(?=.*from)(?=.*useSelector)(?=.*useDispatch).*$/gmi; -exports.ReduxOptionalMatcher = /^(?=.*import)(?=.*from)(?=.*useSelector|useDispatch).*$/gmi; -exports.DispatchMatcher = /^(?=.*const)(?=.*dispatch)(?=.*useDispatch).*$/gmi; +exports.ReduxMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector)(?=.*useAppDispatch).*$/gmi; +exports.ReduxOptionalMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector|useAppDispatch).*$/gmi; +exports.DispatchMatcher = /^(?=.*const)(?=.*dispatch)(?=.*useAppDispatch).*$/gmi; exports.BraceMatcher = /^(?=.*\[).*$/gmi; exports.BraceMatcher2 = /^(?=.*{).*$/gmi; function superagentMatcher(type) { diff --git a/dist/src/helpers/match.js.map b/dist/src/helpers/match.js.map old mode 100644 new mode 100755 index 90159b0..2616151 --- a/dist/src/helpers/match.js.map +++ b/dist/src/helpers/match.js.map @@ -1 +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,iEAAiE,CAAA;AAChF,QAAA,oBAAoB,GAAG,4DAA4D,CAAA;AACnF,QAAA,eAAe,GAAG,mDAAmD,CAAA;AACrE,QAAA,YAAY,G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AG,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"} \ No newline at end of file diff --git a/dist/src/helpers/nomenclature.d.ts b/dist/src/helpers/nomenclature.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/helpers/nomenclature.js b/dist/src/helpers/nomenclature.js old mode 100644 new mode 100755 diff --git a/dist/src/helpers/nomenclature.js.map b/dist/src/helpers/nomenclature.js.map old mode 100644 new mode 100755 diff --git a/dist/src/printer.d.ts b/dist/src/printer.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/printer.js b/dist/src/printer.js index a67eb4b..7237581 100755 --- a/dist/src/printer.js +++ b/dist/src/printer.js @@ -56,7 +56,7 @@ var prisma_1 = require("./generators/prisma"); var superagent_1 = require("./generators/superagent"); exports.Printer = new commander_1.Command('🖨️ Printer'); exports.Printer - .version('1.3.4') + .version('2.0.0') .description('🖨️ Printer: Automation Tooling for Next, Redux and Prisma.') .option('-a, --no-action', 'do not inject actions', false) .option('-s, --no-state', 'do not inject state', false); diff --git a/dist/src/printer.js.map b/dist/src/printer.js.map old mode 100644 new mode 100755 diff --git a/dist/src/templates/api.template b/dist/src/templates/api.template old mode 100644 new mode 100755 index b57d379..0a83588 --- a/dist/src/templates/api.template +++ b/dist/src/templates/api.template @@ -1,17 +1,26 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' +import { NextRequest, NextResponse } from 'next/server' +import { getSession, createResponse } from 'util/session' -export const {{name}}Route = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - res.status(200).send({ status: 'OK' }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) +export async function GET(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + const { searchParams } = new URL(req.url) -export default {{name}}Route + try { + return createResponse( + res, + JSON.stringify({ + status: 'OK', + session + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} diff --git a/dist/src/templates/component/component.nostyle.template b/dist/src/templates/component/component.nostyle.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/component/component.template b/dist/src/templates/component/component.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/component/index.nostyle.template b/dist/src/templates/component/index.nostyle.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/component/index.template b/dist/src/templates/component/index.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/component/style.template b/dist/src/templates/component/style.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/component/test.template b/dist/src/templates/component/test.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/crud.template b/dist/src/templates/crud.template new file mode 100755 index 0000000..4b2e570 --- /dev/null +++ b/dist/src/templates/crud.template @@ -0,0 +1,138 @@ +import { NextRequest, NextResponse } from 'next/server' +import { getSession, createResponse } from 'util/session' +import prisma from 'prisma/client' + +// Creates a new record +export async function POST(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const data = await req.json() + const {{model}} = await prisma.{{model}}.create({ data }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + {{model}} + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} + +// Updates an existing record by its @id +export async function PATCH(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const data = await req.json() + const id = data.id + delete data.id + + const {{model}} = await prisma.{{model}}.update({ + where: { id }, + data, + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + {{model}} + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} + +// Deletes a record by its @id +export async function DELETE(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const { searchParams } = new URL(req.url) + const id = searchParams.get('id') + + const {{model}} = await prisma.{{model}}.delete({ + where: { id } + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + {{model}} + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} + +// Lists results or gets a specific ID +export async function GET(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const { searchParams } = new URL(req.url) + const id = searchParams.get('id') + const skip = searchParams.get('skip') + + if (id) { + const {{model}} = await prisma.{{model}}.findUnique({ + where: { id } + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + result: {{model}} + }), + { status: 200 } + ) + } else { + const results = await prisma.{{model}}.findMany({ + take: 10, + skip: Number(skip || '0') + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + results + }), + { status: 200 } + ) + } + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} diff --git a/dist/src/templates/crud/create.template b/dist/src/templates/crud/create.template deleted file mode 100644 index 367b425..0000000 --- a/dist/src/templates/crud/create.template +++ /dev/null @@ -1,23 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const CreateRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const {{model}} = await prisma.{{model}}.create({ - data: { - ...req.body - } - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default CreateRoute diff --git a/dist/src/templates/crud/delete.template b/dist/src/templates/crud/delete.template deleted file mode 100644 index 2c8eb11..0000000 --- a/dist/src/templates/crud/delete.template +++ /dev/null @@ -1,23 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const DeleteRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const {{model}} = await prisma.{{model}}.delete({ - where: { - id: req.query.id || req.body.id - } - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default DeleteRoute diff --git a/dist/src/templates/crud/get.template b/dist/src/templates/crud/get.template deleted file mode 100644 index 8798c7d..0000000 --- a/dist/src/templates/crud/get.template +++ /dev/null @@ -1,23 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const GetRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const {{model}} = await prisma.{{model}}.findUnique({ - where: { - id: req.query.id || req.body.id - } - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default GetRoute diff --git a/dist/src/templates/crud/list.template b/dist/src/templates/crud/list.template deleted file mode 100644 index 6afad5a..0000000 --- a/dist/src/templates/crud/list.template +++ /dev/null @@ -1,19 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const ListRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const results = await prisma.{{model}}.findMany() - res.status(200).send({ status: 'OK', results }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default ListRoute diff --git a/dist/src/templates/crud/update.template b/dist/src/templates/crud/update.template deleted file mode 100644 index 1ad606d..0000000 --- a/dist/src/templates/crud/update.template +++ /dev/null @@ -1,26 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const UpdateRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const id = req.body.id - const data = req.body - delete data.id - - const {{model}} = await prisma.{{model}}.update({ - where: { id }, - data, - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default UpdateRoute diff --git a/dist/src/templates/new/.env.dev.local.template b/dist/src/templates/new/.env.dev.local.template new file mode 100755 index 0000000..f61db17 --- /dev/null +++ b/dist/src/templates/new/.env.dev.local.template @@ -0,0 +1,2 @@ +DATABASE_URL="http://localhost:1906" +SESSION_SECRET="{{password}}" \ No newline at end of file diff --git a/src/templates/new/eslintrc.template b/dist/src/templates/new/.eslintrc.js.template old mode 100644 new mode 100755 similarity index 96% rename from src/templates/new/eslintrc.template rename to dist/src/templates/new/.eslintrc.js.template index df21694..0a1e7d6 --- a/src/templates/new/eslintrc.template +++ b/dist/src/templates/new/.eslintrc.js.template @@ -5,6 +5,7 @@ module.exports = { node: true }, extends: [ + 'next/core-web-vitals', 'plugin:react/recommended', 'standard', 'prettier', diff --git a/src/templates/new/gitignore.template b/dist/src/templates/new/.gitignore.template old mode 100644 new mode 100755 similarity index 98% rename from src/templates/new/gitignore.template rename to dist/src/templates/new/.gitignore.template index 9f2da9e..1174f79 --- a/src/templates/new/gitignore.template +++ b/dist/src/templates/new/.gitignore.template @@ -74,10 +74,9 @@ web_modules/ # dotenv environment variable files .env -.env.development.local +.env.local .env.test.local .env.production.local -.env.local # parcel-bundler cache (https://parceljs.org/) .cache diff --git a/src/templates/new/readme.template b/dist/src/templates/new/README.md.template old mode 100644 new mode 100755 similarity index 100% rename from src/templates/new/readme.template rename to dist/src/templates/new/README.md.template diff --git a/dist/src/templates/new/_app.template b/dist/src/templates/new/_app.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/_document.template b/dist/src/templates/new/_document.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/app/layout.tsx.template b/dist/src/templates/new/app/layout.tsx.template new file mode 100755 index 0000000..c5b62c7 --- /dev/null +++ b/dist/src/templates/new/app/layout.tsx.template @@ -0,0 +1,20 @@ +import 'scss/printer.scss' +import { ReactNode } from 'react' +import { ReduxProvider } from 'redux/provider' + +export interface LayoutI { + children: ReactNode +} + +export default function LayoutComponent({ children }: LayoutI) { + return ( + + + Printer + + + {children} + + + ) +} diff --git a/dist/src/templates/new/app/page.tsx.template b/dist/src/templates/new/app/page.tsx.template new file mode 100755 index 0000000..3260b5d --- /dev/null +++ b/dist/src/templates/new/app/page.tsx.template @@ -0,0 +1,26 @@ +'use client' +import { decrement, increment, reset } from 'redux/slice/counter' +import { useAppSelector, useAppDispatch } from 'redux/hooks' + +export default function RootPage() { + const count = useAppSelector((state) => state.counter.data.value) + const dispatch = useAppDispatch() + + return ( +
+

Counter is at {count}

+ +
+ dispatch(increment(1))}> + Increment + + dispatch(decrement(1))}> + Decrement + + dispatch(reset())}> + Reset + +
+
+ ) +} diff --git a/dist/src/templates/new/babelrc.template b/dist/src/templates/new/babelrc.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/env.dev.template b/dist/src/templates/new/env.dev.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/eslintrc.template b/dist/src/templates/new/eslintrc.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/gitignore.template b/dist/src/templates/new/gitignore.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/index.template b/dist/src/templates/new/index.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/middleware.tsx.template b/dist/src/templates/new/middleware.tsx.template new file mode 100755 index 0000000..cfc37a1 --- /dev/null +++ b/dist/src/templates/new/middleware.tsx.template @@ -0,0 +1,10 @@ +import { NextRequest, NextResponse } from 'next/server' +import { getSession } from 'util/session' + +// See https://nextjs.org/docs/app/building-your-application/routing/middleware to manage client side routing with session states. +export async function middleware(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) +} + +export const config = {} diff --git a/dist/src/templates/new/next.config.js.template b/dist/src/templates/new/next.config.js.template new file mode 100755 index 0000000..9a58c08 --- /dev/null +++ b/dist/src/templates/new/next.config.js.template @@ -0,0 +1,5 @@ +module.exports = { + experimental: { + appDir: true + } +} diff --git a/src/templates/new/package.template b/dist/src/templates/new/package.json.template old mode 100644 new mode 100755 similarity index 69% rename from src/templates/new/package.template rename to dist/src/templates/new/package.json.template index a1a8fa6..f42c258 --- a/src/templates/new/package.template +++ b/dist/src/templates/new/package.json.template @@ -1,10 +1,9 @@ { - "name": "print-template", + "name": "@printerframework/template", "version": "1.0.0", "scripts": { - "prepare": "husky install", "dev": "next dev --port 4200", - "build": "next build", + "build": "npm run prisma && next build", "start": "next start", "lint": "eslint . --ext ts,tsx --resolve-plugins-relative-to .", "scss": "node-sass -r scss/printer.scss -o scss/debug", @@ -14,24 +13,22 @@ "dependencies": { "@prisma/client": "^4.1.0", "@reduxjs/toolkit": "^1.7.1", - "iron-session": "^6.1.2", - "next": "^12.0.7", - "next-redux-wrapper": "^7.0.5", + "iron-session": "8.0.0-alpha.0", + "next": "^13.4.7", "prisma": "^4.1.0", - "react": "^17.0.2", - "react-dom": "^17.0.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", "react-redux": "^7.2.6", "sass": "^1.54.3", - "styled-components": "^5.3.3", "superagent": "^8.0.9" }, "devDependencies": { "@types/node": "^17.0.13", "@types/superagent": "^4.1.16", - "@typescript-eslint/eslint-plugin": "^5.14.0", + "@typescript-eslint/eslint-plugin": "^5.60.0", "@typescript-eslint/parser": "^5.14.0", - "babel-plugin-styled-components": "^2.0.2", - "eslint": "^8.10.0", + "eslint": "^8.43.0", + "eslint-config-next": "^13.4.7", "eslint-config-prettier": "^8.5.0", "eslint-config-standard": "^16.0.3", "eslint-plugin-import": "^2.25.4", @@ -39,9 +36,8 @@ "eslint-plugin-prettier": "^4.0.0", "eslint-plugin-promise": "^5.2.0", "eslint-plugin-react": "^7.29.3", - "husky": "^7.0.4", "node-sass": "^7.0.1", "prettier": "^2.5.1", - "typescript": "^4.5.4" + "typescript": "^5.1.3" } } diff --git a/dist/src/templates/new/package.template b/dist/src/templates/new/package.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/precommit.template b/dist/src/templates/new/precommit.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/printer.config.json.template b/dist/src/templates/new/printer.config.json.template new file mode 100755 index 0000000..75419c5 --- /dev/null +++ b/dist/src/templates/new/printer.config.json.template @@ -0,0 +1,9 @@ +{ + "crud": { + "create": true, + "update": true, + "delete": true, + "list": true, + "get": true + } +} diff --git a/dist/src/templates/new/printer.config.template b/dist/src/templates/new/printer.config.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/printer.template b/dist/src/templates/new/printer.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/prisma.client.template b/dist/src/templates/new/prisma.client.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/prisma/client.ts.template b/dist/src/templates/new/prisma/client.ts.template new file mode 100755 index 0000000..a827650 --- /dev/null +++ b/dist/src/templates/new/prisma/client.ts.template @@ -0,0 +1,7 @@ +import { PrismaClient } from '@prisma/client' + +export const prisma = new PrismaClient({ + log: [] +}) + +export default prisma diff --git a/src/templates/new/schema.prisma.template b/dist/src/templates/new/prisma/schema.prisma.template old mode 100644 new mode 100755 similarity index 95% rename from src/templates/new/schema.prisma.template rename to dist/src/templates/new/prisma/schema.prisma.template index 752c605..3cefdf6 --- a/src/templates/new/schema.prisma.template +++ b/dist/src/templates/new/prisma/schema.prisma.template @@ -11,14 +11,14 @@ datasource db { model Account { id String @id @default(uuid()) @db.Char(36) username String @unique @db.VarChar(128) - posts Posts[] + posts Post[] dateCreated DateTime @default(now()) dateUpdated DateTime @updatedAt @@index(dateCreated) } -model Posts { +model Post { id String @id @default(uuid()) @db.Char(36) accountId String @db.VarChar(128) title String @db.VarChar(256) diff --git a/dist/src/templates/new/readme.template b/dist/src/templates/new/readme.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/reducer.template b/dist/src/templates/new/reducer.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/redux/hooks.tsx.template b/dist/src/templates/new/redux/hooks.tsx.template new file mode 100755 index 0000000..0a8c97e --- /dev/null +++ b/dist/src/templates/new/redux/hooks.tsx.template @@ -0,0 +1,5 @@ +import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' +import type { RootState, AppDispatch } from 'redux/store' + +export const useAppDispatch = () => useDispatch() +export const useAppSelector: TypedUseSelectorHook = useSelector diff --git a/dist/src/templates/new/redux/provider.tsx.template b/dist/src/templates/new/redux/provider.tsx.template new file mode 100755 index 0000000..05ed353 --- /dev/null +++ b/dist/src/templates/new/redux/provider.tsx.template @@ -0,0 +1,12 @@ +'use client' +import { ReactNode } from 'react' +import { store } from 'redux/store' +import { Provider } from 'react-redux' + +export interface ReduxProviderI { + children: ReactNode +} + +export function ReduxProvider({ children }: ReduxProviderI) { + return {children} +} diff --git a/dist/src/templates/new/redux/reducer.tsx.template b/dist/src/templates/new/redux/reducer.tsx.template new file mode 100755 index 0000000..5aa5ff6 --- /dev/null +++ b/dist/src/templates/new/redux/reducer.tsx.template @@ -0,0 +1,5 @@ +import { counterSlice } from 'redux/slice/counter' + +export const reducer = { + counter: counterSlice.reducer +} diff --git a/dist/src/templates/new/redux/reducers.json.template b/dist/src/templates/new/redux/reducers.json.template new file mode 100755 index 0000000..3f1fa53 --- /dev/null +++ b/dist/src/templates/new/redux/reducers.json.template @@ -0,0 +1,3 @@ +[ + "counter" +] \ No newline at end of file diff --git a/dist/src/templates/new/redux/slice/counter.tsx.template b/dist/src/templates/new/redux/slice/counter.tsx.template new file mode 100755 index 0000000..49257d8 --- /dev/null +++ b/dist/src/templates/new/redux/slice/counter.tsx.template @@ -0,0 +1,28 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit' +import CounterType from 'types/counter' + +export const counterInitialState = { + // @printer::inject::counter + data: { + value: 0 + } as CounterType +} + +export const counterSlice = createSlice({ + name: 'counter', + initialState: counterInitialState, + reducers: { + // @printer::inject + reset: () => counterInitialState, + // @printer::inject + increment: (state, action: PayloadAction) => { + state.data.value += action.payload + }, + // @printer::inject + decrement: (state, action: PayloadAction) => { + state.data.value -= action.payload + } + } +}) + +export const { increment, decrement, reset } = counterSlice.actions diff --git a/dist/src/templates/new/redux/store.tsx.template b/dist/src/templates/new/redux/store.tsx.template new file mode 100755 index 0000000..05e2d00 --- /dev/null +++ b/dist/src/templates/new/redux/store.tsx.template @@ -0,0 +1,17 @@ +import { configureStore } from '@reduxjs/toolkit' +import { setupListeners } from '@reduxjs/toolkit/dist/query' +import { reducer } from 'redux/reducer' + +export const store = configureStore({ + reducer, + devTools: process.env.NODE_ENV !== 'production', + middleware: (getDefaultMiddleware) => + getDefaultMiddleware({ + serializableCheck: false + }) +}) + +setupListeners(store.dispatch) + +export type RootState = ReturnType +export type AppDispatch = typeof store.dispatch diff --git a/dist/src/templates/new/reset.template b/dist/src/templates/new/reset.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/schema.prisma.template b/dist/src/templates/new/schema.prisma.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/scss/index.scss.template b/dist/src/templates/new/scss/index.scss.template new file mode 100755 index 0000000..2a905c7 --- /dev/null +++ b/dist/src/templates/new/scss/index.scss.template @@ -0,0 +1,18 @@ +@import "/scss/theme.scss"; + +section.root-page { + h2 { + font-size: 32px; + padding: 0 0 15px 0; + } + + div.buttons { + display: flex; + align-items: center; + justify-content: center; + + a.button { + margin: 15px; + } + } +} \ No newline at end of file diff --git a/dist/src/templates/new/scss/printer.scss.template b/dist/src/templates/new/scss/printer.scss.template new file mode 100755 index 0000000..e0dace2 --- /dev/null +++ b/dist/src/templates/new/scss/printer.scss.template @@ -0,0 +1,5 @@ +@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&family=Oswald:wght@300;400;500;600;700&display=swap'); +@import "/scss/reset.scss"; +@import "/scss/theme.scss"; +@import "/scss/ui.scss"; +@import "/scss/index.scss"; \ No newline at end of file diff --git a/src/templates/new/reset.template b/dist/src/templates/new/scss/reset.scss.template old mode 100644 new mode 100755 similarity index 100% rename from src/templates/new/reset.template rename to dist/src/templates/new/scss/reset.scss.template diff --git a/dist/src/templates/new/scss/theme.scss.template b/dist/src/templates/new/scss/theme.scss.template new file mode 100755 index 0000000..bbae09e --- /dev/null +++ b/dist/src/templates/new/scss/theme.scss.template @@ -0,0 +1,17 @@ +$header-font: 'Oswald'; +$body-font: 'Montserrat'; + +$primary: #C49A0F; +$primary-light: #F2D577; + +$container-width: 1268px; +$page-height: 100vh; + +@mixin bg-gradient() { + background: rgb(41, 41, 41); + background: radial-gradient(circle, rgba(41, 41, 41, 1) 0%, rgba(29, 29, 29, 1) 100%); +} + +@mixin transition($property: all, $duration: 0.25s) { + transition: $property $duration cubic-bezier(0.33, 1, 0.68, 1); +} \ No newline at end of file diff --git a/dist/src/templates/new/scss/ui.scss.template b/dist/src/templates/new/scss/ui.scss.template new file mode 100755 index 0000000..430b749 --- /dev/null +++ b/dist/src/templates/new/scss/ui.scss.template @@ -0,0 +1,88 @@ +@import "/scss/theme.scss"; + +* { + box-sizing: border-box; +} + +body { + font-family: $body-font; + @include bg-gradient(); + color: white; + margin: 0; + padding: 0; + overflow-x: hidden; +} + +h1, h2, h3, h4, h5, h6 { + font-family: $header-font; +} + +h1 { + font-size: 32px; +} + +h2 { + font-size: 24px; +} + +h3 { + font-size: 18px; +} + +h4 { + font-size: 16px; +} + +a { + cursor: pointer; +} + +button, input, textarea { + font-family: inherit; + outline: none; +} + +section.container, div.container { + width: 100%; + max-width: $container-width; + margin: auto; + &.page { + min-height: $page-height; + } + &.flex { + display: flex; + flex-wrap: wrap; + } + &.center { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + } +} + +a.button, button { + display: flex; + align-items: center; + justify-content: center; + width: 140px; + height: 35px; + border-radius: 3px; + font-family: $body-font; + font-size: 16px; + font-weight: bold; + background: $primary; + color: white; + text-decoration: none; + margin: 0 15px 0 0; + cursor: pointer; + @include transition(); + + &:hover { + background: $primary-light; + } + + .i, .icon { + margin: 0 8px 0 0; + } +} diff --git a/dist/src/templates/new/session.template b/dist/src/templates/new/session.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/theme.template b/dist/src/templates/new/theme.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/tsconfig.json.template b/dist/src/templates/new/tsconfig.json.template new file mode 100755 index 0000000..5da3021 --- /dev/null +++ b/dist/src/templates/new/tsconfig.json.template @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "ES5", + "lib": [ + "DOM", + "DOM.iterable", + "ESNext" + ], + "baseUrl": "./", + "allowJs": true, + "skipLibCheck": true, + "strict": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "esModuleInterop": true, + "module": "CommonJS", + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "plugins": [ + { "name": "next" } + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/dist/src/templates/new/tsconfig.template b/dist/src/templates/new/tsconfig.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/types/counter.tsx.template b/dist/src/templates/new/types/counter.tsx.template new file mode 100755 index 0000000..ed2851e --- /dev/null +++ b/dist/src/templates/new/types/counter.tsx.template @@ -0,0 +1,5 @@ +export interface CounterType { + value: number +} + +export default CounterType diff --git a/dist/src/templates/new/ui.template b/dist/src/templates/new/ui.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/new/util/session.ts.template b/dist/src/templates/new/util/session.ts.template new file mode 100755 index 0000000..c40eb44 --- /dev/null +++ b/dist/src/templates/new/util/session.ts.template @@ -0,0 +1,25 @@ +import { NextRequest, NextResponse } from 'next/server' +import { getIronSession, createResponse } from 'iron-session' + +export const password = + process.env.SESSION_SECRET || + '{{password}}' + +export interface SessionI { + counter?: number +} + +export function getSession(req: NextRequest, res: NextResponse) { + return getIronSession(req, res, { + password, + cookieName: 'printer', + cookieOptions: { + secure: process.env.NODE_ENV === 'production', + maxAge: process.env.COOKIE_AGE + ? Number(process.env.COOKIE_AGE) + : undefined + } + }) +} + +export { createResponse } diff --git a/dist/src/templates/new/wrapper.template b/dist/src/templates/new/wrapper.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/page.template b/dist/src/templates/page.template old mode 100644 new mode 100755 index 1ba2ffc..2e28305 --- a/dist/src/templates/page.template +++ b/dist/src/templates/page.template @@ -1,5 +1,13 @@ -export interface {{name}}I {} +'use client' + +export interface {{name}}PageI { -export default function {{name}}({}: {{name}}I) { - return

Page {{name}}

} + +export default function {{name}}Page({}: {{name}}PageI) { + return ( +
+

{{name}} Page

+
+ ) +} \ No newline at end of file diff --git a/dist/src/templates/page.url.template b/dist/src/templates/page.url.template old mode 100644 new mode 100755 index 28a7cee..b500715 --- a/dist/src/templates/page.url.template +++ b/dist/src/templates/page.url.template @@ -1,10 +1,13 @@ -import { useRouter } from 'next/router' +'use client' -export interface {{name}}I {} - -export default function {{name}}({}: {{name}}I) { - const router = useRouter() - const { {{url}} } = router.query - - return

Page {{name}}

+export interface {{name}}PageI { + {{url_interface}} } + +export default function {{name}}Page({ {{url_variables}} }: {{name}}PageI) { + return ( +
+

{{name}} Page

+
+ ) +} \ No newline at end of file diff --git a/dist/src/templates/scss.template b/dist/src/templates/scss.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/slice/reducer.template b/dist/src/templates/slice/reducer.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/slice/slice.d.ts b/dist/src/templates/slice/slice.d.ts old mode 100644 new mode 100755 diff --git a/dist/src/templates/slice/slice.js b/dist/src/templates/slice/slice.js old mode 100644 new mode 100755 diff --git a/dist/src/templates/slice/slice.js.map b/dist/src/templates/slice/slice.js.map old mode 100644 new mode 100755 diff --git a/dist/src/templates/slice/slice.template b/dist/src/templates/slice/slice.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/slice/slice.ts b/dist/src/templates/slice/slice.ts old mode 100644 new mode 100755 diff --git a/dist/src/templates/superagent.template b/dist/src/templates/superagent.template old mode 100644 new mode 100755 diff --git a/dist/src/templates/type.template b/dist/src/templates/type.template old mode 100644 new mode 100755 diff --git a/package.json b/package.json index e589e4c..cef5d32 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@printerframework/cli", "description": "🖨️ Automation Tooling for Next, Redux and Prisma.", - "version": "1.3.40", + "version": "2.0.0", "private": false, "preferGlobal": true, "repository": "https://github.com/PrinterFramework/CLI.git", diff --git a/src/config.ts b/src/config.ts index 1a5575c..4e5e2cb 100644 --- a/src/config.ts +++ b/src/config.ts @@ -3,13 +3,6 @@ import { join } from 'path' import { Log } from './helpers/log' export interface PrinterConfig { - componentFolder?: boolean - component?: { - index?: boolean - component?: boolean - style?: boolean - test?: boolean - } crud?: { create: boolean update: boolean @@ -20,13 +13,6 @@ export interface PrinterConfig { } export let Config: PrinterConfig = { - componentFolder: false, - component: { - index: true, - component: true, - style: false, - test: false - }, crud: { create: true, update: true, diff --git a/src/generators/api.ts b/src/generators/api.ts index 6d3c6eb..c0e9c65 100644 --- a/src/generators/api.ts +++ b/src/generators/api.ts @@ -2,10 +2,9 @@ import prompts from 'prompts' import { join } from 'path' import { exists, read, write } from 'fs-jetpack' import { Log } from '../helpers/log' -import { formatName } from '../helpers/nomenclature' export async function generateApi (path: string) { - const apiPath = join(process.cwd(), 'pages', 'api', `${path}.tsx`) + const apiPath = join(process.cwd(), 'app', 'api', `${path}/route.tsx`) if (exists(apiPath) !== false) { const result = await prompts({ @@ -19,12 +18,7 @@ export async function generateApi (path: string) { } } - const pathArray = path.split('/') - const fileName = pathArray[pathArray.length - 1] - const name = formatName(fileName) - - const apiTemplate = read(join(__dirname, '..', 'templates', 'api.template'))?.replaceAll('{{name}}', name) - + const apiTemplate = read(join(__dirname, '..', 'templates', 'api.template')) write(apiPath, apiTemplate || '') - Log(` ✅ Created pages/api/${path}.tsx`.green) + Log(` ✅ Created app/api/${path}/route.tsx`.green) } diff --git a/src/generators/component.ts b/src/generators/component.ts index 75b12de..1d0aca4 100644 --- a/src/generators/component.ts +++ b/src/generators/component.ts @@ -2,7 +2,6 @@ import prompts from 'prompts' import { join } from 'path' import { exists, read, write } from 'fs-jetpack' import { Log } from '../helpers/log' -import { Config } from '../config' import { formatName } from '../helpers/nomenclature' export async function generateComponent (path: string) { @@ -22,46 +21,9 @@ export async function generateComponent (path: string) { const fileName = pathArray[pathArray.length - 1] const name = formatName(fileName) - if (Config.componentFolder === true) { - let component = read(join(__dirname, '..', 'templates', 'component', 'component.nostyle.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) - const componentPath = join(process.cwd(), path, `${fileName}.component.tsx`) + const component = read(join(__dirname, '..', 'templates', 'component', 'component.nostyle.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) + const componentPath = join(process.cwd(), `${path.replace('.tsx', '')}.tsx`) - if (Config.component?.style === true) { - component = read(join(__dirname, '..', 'templates', 'component', 'component.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) - - const style = read(join(__dirname, '..', 'templates', 'component', 'style.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) - const stylePath = join(process.cwd(), path, `${fileName}.style.tsx`) - write(stylePath, style || '') - Log(` ✅ Created ${fileName}.style.tsx`.green) - } - - write(componentPath, component || '') - Log(` ✅ Created ${fileName}.component.tsx`.green) - - if (Config.component?.test) { - const test = read(join(__dirname, '..', 'templates', 'component', 'test.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) - const testPath = join(process.cwd(), path, `${fileName}.test.tsx`) - - write(testPath, test || '') - Log(` ✅ Created ${fileName}.test.tsx`.green) - } - - if (Config.component?.index) { - let index = read(join(__dirname, '..', 'templates', 'component', 'index.nostyle.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) - const indexPath = join(process.cwd(), path, 'index.tsx') - - if (Config.component?.style === true) { - index = read(join(__dirname, '..', 'templates', 'component', 'index.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path).replaceAll('{{path}}', path) - } - - write(indexPath, index || '') - Log(' ✅ Created index.tsx'.green) - } - } else { - const component = read(join(__dirname, '..', 'templates', 'component', 'component.nostyle.template'))?.replaceAll('{{name}}', name).replaceAll('{{prefix}}', fileName).replaceAll('{{path}}', path) - const componentPath = join(process.cwd(), `${path.replace('.tsx', '')}.tsx`) - - write(componentPath, component || '') - Log(` ✅ Created ${path.replace('.tsx', '')}.tsx`.green) - } + write(componentPath, component || '') + Log(` ✅ Created ${path.replace('.tsx', '')}.tsx`.green) } diff --git a/src/generators/crud.ts b/src/generators/crud.ts index 25a3dff..7ce98cf 100644 --- a/src/generators/crud.ts +++ b/src/generators/crud.ts @@ -4,7 +4,7 @@ import { exists, read, write } from 'fs-jetpack' import { Log } from '../helpers/log' export async function generateCrud (model: string) { - const basePath = join(process.cwd(), 'pages', 'api', model) + const basePath = join(process.cwd(), 'app', 'api', model) if (exists(basePath) !== false) { const result = await prompts({ @@ -18,28 +18,8 @@ export async function generateCrud (model: string) { } } - const createPath = join(basePath, 'create.tsx') - const createTemplate = read(join(__dirname, '..', 'templates', 'crud', 'create.template'))?.replaceAll('{{model}}', model) - write(createPath, createTemplate || '') - Log(` ✅ Created pages/api/${model}/create.tsx`.green) - - const updatePath = join(basePath, 'update.tsx') - const updateTemplate = read(join(__dirname, '..', 'templates', 'crud', 'update.template'))?.replaceAll('{{model}}', model) - write(updatePath, updateTemplate || '') - Log(` ✅ Created pages/api/${model}/update.tsx`.green) - - const getPath = join(basePath, 'get.tsx') - const getTemplate = read(join(__dirname, '..', 'templates', 'crud', 'get.template'))?.replaceAll('{{model}}', model) - write(getPath, getTemplate || '') - Log(` ✅ Created pages/api/${model}/get.tsx`.green) - - const listPath = join(basePath, 'list.tsx') - const listTemplate = read(join(__dirname, '..', 'templates', 'crud', 'list.template'))?.replaceAll('{{model}}', model) - write(listPath, listTemplate || '') - Log(` ✅ Created pages/api/${model}/list.tsx`.green) - - const deletePath = join(basePath, 'delete.tsx') - const deleteTemplate = read(join(__dirname, '..', 'templates', 'crud', 'delete.template'))?.replaceAll('{{model}}', model) - write(deletePath, deleteTemplate || '') - Log(` ✅ Created pages/api/${model}/delete.tsx`.green) + const routePath = join(basePath, 'route.tsx') + const routeTemplate = read(join(__dirname, '..', 'templates', 'crud.template'))?.replaceAll('{{model}}', model) + write(routePath, routeTemplate || '') + Log(` ✅ Created pages/api/${model}/route.tsx`.green) } diff --git a/src/generators/inject.ts b/src/generators/inject.ts index 6c9de5d..0c25565 100644 --- a/src/generators/inject.ts +++ b/src/generators/inject.ts @@ -63,9 +63,9 @@ export async function inject (slice: string, component: string, opts: OptsType) const hasExistingImport = findMatches(newContents, ReduxOptionalMatcher) if (hasExistingImport.length > 0) { - newContents = newContents.replace(ReduxOptionalMatcher, 'import { useSelector, useDispatch } from \'react-redux\'') + newContents = newContents.replace(ReduxOptionalMatcher, 'import { useAppSelector, useAppDispatch } from \'redux/hooks\'') } else { - newContents = `import { useSelector, useDispatch } from 'react-redux'\n\n${newContents}` + newContents = `import { useAppSelector, useAppDispatch } from 'redux/hooks'\n\n${newContents}` } if (opts.state) { @@ -89,7 +89,6 @@ export async function inject (slice: string, component: string, opts: OptsType) const injectionLine = findMatches(newContents, functionMatcher(fileName))[0] const tempContents = newContents.split('\n') - let typeMap = 'any' let value = stateInjection.value let spreadLeft = '{' let spreadRight = '}' @@ -102,10 +101,9 @@ export async function inject (slice: string, component: string, opts: OptsType) spreadLeft = '[' spreadRight = ']' } - typeMap = `{ ${slice}: { ${value}: ${typeName} } }` } - tempContents[injectionLine] = tempContents[injectionLine] + `\n const ${value} = useSelector((state: ${typeMap}) => ${stateInjection.addDots ? '(' + spreadLeft + ' ' : ''}${stateInjection.addDots ? '...' : ''}state.${slice}.${value}${stateInjection.addDots ? ' ' + spreadRight + ')' : ''})` + tempContents[injectionLine] = tempContents[injectionLine] + `\n const ${value} = useAppSelector((state) => ${stateInjection.addDots ? '(' + spreadLeft + ' ' : ''}${stateInjection.addDots ? '...' : ''}state.${slice}.${value}${stateInjection.addDots ? ' ' + spreadRight + ')' : ''})` if (i === 0) { tempContents[injectionLine] = tempContents[injectionLine] + '\n' @@ -139,6 +137,11 @@ export async function inject (slice: string, component: string, opts: OptsType) } } + if (filePath.indexOf('app/') !== -1) { + newContents = newContents.replaceAll('\'use client\'', '') + newContents = '\'use client\'\n' + newContents + } + if (exists(filePath) === 'dir') { const fileComponentPath = join(process.cwd(), component, `${fileName}.component.tsx`) write(fileComponentPath, newContents) diff --git a/src/generators/new.ts b/src/generators/new.ts index abf1477..7ff6074 100644 --- a/src/generators/new.ts +++ b/src/generators/new.ts @@ -5,32 +5,8 @@ import { Log } from '../helpers/log' import { randomBytes } from 'crypto' export async function generateNewProject (path: string = '.') { - const readmePath = join(process.cwd(), path, 'README.md') - const appPath = join(process.cwd(), path, 'pages', '_app.tsx') - const documentPath = join(process.cwd(), path, 'pages', '_document.tsx') - const babelPath = join(process.cwd(), path, '.babelrc') - const gitignorePath = join(process.cwd(), path, '.gitignore') - const gitkeepPath = join(process.cwd(), path, '.gitkeep') - const envdevPath = join(process.cwd(), path, '.env.dev') - const gitkeepPublicPath = join(process.cwd(), path, 'public', '.gitkeep') - const indexPath = join(process.cwd(), path, 'pages', 'index.tsx') - const utilSessionPath = join(process.cwd(), path, 'util', 'session.ts') - const resetCssPath = join(process.cwd(), path, 'scss', 'reset.scss') - const printerScssPath = join(process.cwd(), path, 'scss', 'printer.scss') - const themeScssPath = join(process.cwd(), path, 'scss', 'theme.scss') - const uiScssPath = join(process.cwd(), path, 'scss', 'ui.scss') - const prismaClientPath = join(process.cwd(), path, 'prisma', 'client.ts') - const prismaSchemaPath = join(process.cwd(), path, 'prisma', 'schema.prisma') - const packagePath = join(process.cwd(), path, 'package.json') - const wrapperPath = join(process.cwd(), path, 'redux', 'wrapper.tsx') - const reducerPath = join(process.cwd(), path, 'redux', 'reducer.tsx') - const reducersPath = join(process.cwd(), path, 'redux', 'reducers.json') - const tsconfigPath = join(process.cwd(), path, 'tsconfig.json') - const precommitPath = join(process.cwd(), path, '.husky', 'pre-commit') - const eslintrcPath = join(process.cwd(), path, '.eslintrc.js') - const printerConfigPath = join(process.cwd(), path, 'printer.config.json') - - if (exists(printerConfigPath) !== false) { + const configPath = join(process.cwd(), path, 'printer.config.json') + if (exists(configPath) !== false) { const result = await prompts({ type: 'confirm', name: 'overwrite', @@ -42,112 +18,129 @@ export async function generateNewProject (path: string = '.') { } } + const root = [ + 'printer.config.json', + '.env.dev.local', + '.eslintrc.js', + '.gitignore', + 'middleware.tsx', + 'next.config.js', + 'package.json', + 'README.md', + 'tsconfig.json' + ] + + for (const item of root) { + const itemPath = join(process.cwd(), path, item) + let contents = read(join(__dirname, '..', 'templates', 'new', `${item}.template`)) || '' + if (item === '.env.dev.local') { + contents = contents.replaceAll('{{password}}', randomBytes(32).toString('hex')) + } + + write( + itemPath, + contents + ) + Log(` ✅ Created ${item}`.green) + } + write( - readmePath, - read(join(__dirname, '..', 'templates', 'new', 'readme.template')) || '' - ) - Log(' ✅ Created README.md'.green) - write( - babelPath, - read(join(__dirname, '..', 'templates', 'new', 'babelrc.template')) || '' - ) - Log(' ✅ Created .babelrc'.green) - write( - gitignorePath, - read(join(__dirname, '..', 'templates', 'new', 'gitignore.template')) || '' - ) - Log(' ✅ Created .gitignore'.green) - write(gitkeepPath, '') - Log(' ✅ Created .gitkeep'.green) - write(envdevPath, read(join(__dirname, '..', 'templates', 'new', 'env.dev.template')) || '') - Log(' ✅ Created .env.dev'.green) - write(gitkeepPublicPath, '') - Log(' ✅ Created public/.gitkeep'.green) - write( - appPath, - read(join(__dirname, '..', 'templates', 'new', '_app.template')) || '' - ) - Log(' ✅ Created pages/_app.tsx'.green) - write( - documentPath, - read(join(__dirname, '..', 'templates', 'new', '_document.template')) || '' - ) - Log(' ✅ Created pages/_document.tsx'.green) - write( - indexPath, - read(join(__dirname, '..', 'templates', 'new', 'index.template')) || '' + join(process.cwd(), path, 'public', '.gitkeep'), + '' ) - Log(' ✅ Created pages/index.tsx'.green) + + const sessionPath = join(process.cwd(), path, 'util', 'session.ts') + let sessionContents = read(join(__dirname, '..', 'templates', 'new', 'util', 'session.ts.template')) || '' + sessionContents = sessionContents.replaceAll('{{password}}', randomBytes(32).toString('hex')) write( - utilSessionPath, - read(join(__dirname, '..', 'templates', 'new', 'session.template'))?.replaceAll('{{password}}', randomBytes(32).toString('hex')) || '' + sessionPath, + sessionContents ) Log(' ✅ Created util/session.ts'.green) + + const counterTypePath = join(process.cwd(), path, 'types', 'counter.tsx') + const counterTypeContents = read(join(__dirname, '..', 'templates', 'new', 'types', 'counter.tsx.template')) || '' write( - resetCssPath, - read(join(__dirname, '..', 'templates', 'new', 'reset.template')) || '' - ) - Log(' ✅ Created scss/reset.css'.green) - write( - printerScssPath, - read(join(__dirname, '..', 'templates', 'new', 'printer.template')) || '' - ) - Log(' ✅ Created scss/printer.scss'.green) - write( - themeScssPath, - read(join(__dirname, '..', 'templates', 'new', 'theme.template')) || '' - ) - Log(' ✅ Created scss/theme.scss'.green) - write( - uiScssPath, - read(join(__dirname, '..', 'templates', 'new', 'ui.template')) || '' - ) - Log(' ✅ Created scss/ui.scss'.green) - write( - prismaClientPath, - read(join(__dirname, '..', 'templates', 'new', 'prisma.client.template')) || '' - ) - Log(' ✅ Created prisma/client.ts'.green) - write( - prismaSchemaPath, - read(join(__dirname, '..', 'templates', 'new', 'schema.prisma.template')) || '' - ) - Log(' ✅ Created prisma/schema.prisma'.green) - write( - packagePath, - read(join(__dirname, '..', 'templates', 'new', 'package.template')) || '' - ) - Log(' ✅ Created package.json'.green) - write( - wrapperPath, - read(join(__dirname, '..', 'templates', 'new', 'wrapper.template')) || '' - ) - Log(' ✅ Created redux/wrapper.tsx'.green) - write( - reducerPath, - read(join(__dirname, '..', 'templates', 'new', 'reducer.template')) || '' - ) - Log(' ✅ Created redux/reducer.tsx'.green) - write(reducersPath, '[]') - Log(' ✅ Created redux/reducers.json'.green) - write( - tsconfigPath, - read(join(__dirname, '..', 'templates', 'new', 'tsconfig.template')) || '' - ) - Log(' ✅ Created tsconfig.json'.green) - write( - precommitPath, - read(join(__dirname, '..', 'templates', 'new', 'precommit.template')) || '' - ) - Log(' ✅ Created .husky/pre-commit'.green) - write( - eslintrcPath, - read(join(__dirname, '..', 'templates', 'new', 'eslintrc.template')) || '' + counterTypePath, + counterTypeContents ) - Log(' ✅ Created printer.config.json'.green) + Log(' ✅ Created types/counter.tsx'.green) + + const scss = [ + 'printer.scss', + 'reset.scss', + 'theme.scss', + 'ui.scss', + 'index.scss' + ] + + for (const item of scss) { + const itemPath = join(process.cwd(), path, 'scss', item) + const contents = read(join(__dirname, '..', 'templates', 'new', 'scss', `${item}.template`)) || '' + + write( + itemPath, + contents + ) + Log(` ✅ Created scss/${item}`.green) + } + + const prisma = [ + 'client.ts', + 'schema.prisma' + ] + + for (const item of prisma) { + const itemPath = join(process.cwd(), path, 'prisma', item) + const contents = read(join(__dirname, '..', 'templates', 'new', 'prisma', `${item}.template`)) || '' + + write( + itemPath, + contents + ) + Log(` ✅ Created prisma/${item}`.green) + } + + const redux = [ + 'hooks.tsx', + 'provider.tsx', + 'reducer.tsx', + 'reducers.json', + 'store.tsx' + ] + + for (const item of redux) { + const itemPath = join(process.cwd(), path, 'redux', item) + const contents = read(join(__dirname, '..', 'templates', 'new', 'redux', `${item}.template`)) || '' + + write( + itemPath, + contents + ) + Log(` ✅ Created redux/${item}`.green) + } + + const reduxSlicePath = join(process.cwd(), path, 'redux', 'slice', 'counter.tsx') + const reduxSliceContents = read(join(__dirname, '..', 'templates', 'new', 'redux', 'slice', 'counter.tsx.template')) || '' write( - printerConfigPath, - read(join(__dirname, '..', 'templates', 'new', 'printer.config.template')) || '' + reduxSlicePath, + reduxSliceContents ) - Log(' ✅ Created .eslintrc.js'.green) + Log(' ✅ Created redux/slice/counter.tsx'.green) + + const app = [ + 'layout.tsx', + 'page.tsx' + ] + + for (const item of app) { + const itemPath = join(process.cwd(), path, 'app', item) + const contents = read(join(__dirname, '..', 'templates', 'new', 'app', `${item}.template`)) || '' + + write( + itemPath, + contents + ) + Log(` ✅ Created app/${item}`.green) + } } diff --git a/src/generators/page.ts b/src/generators/page.ts index fed29a8..93c1e68 100644 --- a/src/generators/page.ts +++ b/src/generators/page.ts @@ -5,7 +5,7 @@ import { Log } from '../helpers/log' import { formatName } from '../helpers/nomenclature' export async function generatePage (path: string) { - const pagePath = join(process.cwd(), 'pages', `${path.replace('.tsx', '')}.tsx`) + const pagePath = join(process.cwd(), 'app', `${path.replace('.tsx', '')}/page.tsx`) if (exists(pagePath) !== false) { const result = await prompts({ @@ -25,16 +25,20 @@ export async function generatePage (path: string) { const name = formatName(fileName) let pageTemplate = '' - console.log(name, path) - if (path.match(/\[(.*?)\]/g)) { urls = path.match(/\[(.*?)\]/g) as string[] urls = urls.map(url => url.replace(/\[/g, '').replace(/\]/g, '')) - pageTemplate = read(join(__dirname, '..', 'templates', 'page.url.template'))?.replaceAll('{{name}}', name).replaceAll('{{url}}', urls.join(', ')) || '' + + const urlInterface = urls.map((url) => `${url}: string`) + + pageTemplate = (read(join(__dirname, '..', 'templates', 'page.url.template')) || '') + .replaceAll('{{name}}', name) + .replaceAll('{{url_variables}}', 'params') + .replaceAll('{{url_interface}}', `params: {\n ${urlInterface.join('\n')}\n }`) } else { pageTemplate = read(join(__dirname, '..', 'templates', 'page.template'))?.replaceAll('{{name}}', name) || '' } write(pagePath, pageTemplate) - Log(` ✅ Created pages/${path}.tsx`.green) + Log(` ✅ Created app/${path}/page.tsx`.green) } diff --git a/src/generators/superagent.ts b/src/generators/superagent.ts index 0e3bd7c..ebc6fc7 100644 --- a/src/generators/superagent.ts +++ b/src/generators/superagent.ts @@ -12,16 +12,15 @@ export async function injectSupergent (type: SuperagentTypes, component: string) let fileContents = '' if (filePath.indexOf('.tsx') === -1) { - if (exists(filePath) === 'dir') { - const fileComponentPath = join(process.cwd(), component, `${fileName}.component.tsx`) - fileContents = read(fileComponentPath) || '' - } else { - fileContents = read(`${filePath}.tsx`) || '' - } + fileContents = read(`${filePath}.tsx`) || '' } else { fileContents = read(`${filePath}`) || '' } + if (findMatches(fileContents, stateMatcher()).length === 0 && findMatches(fileContents, effectMatcher()).length === 0) { + fileContents = 'import { useState, useEffect } from \'react\'' + '\n' + fileContents + } + if (findMatches(fileContents, stateMatcher()).length === 0) { fileContents = 'import { useState } from \'react\'' + '\n' + fileContents } diff --git a/src/helpers/match.ts b/src/helpers/match.ts index 324944d..ac7861c 100644 --- a/src/helpers/match.ts +++ b/src/helpers/match.ts @@ -1,8 +1,8 @@ export const SliceMatcher = /^(?=.*export)(?=.*createSlice).*$/gmi export const ImportMatcher = /^(?=.*import)(?=.*from).*$/gmi -export const ReduxMatcher = /^(?=.*import)(?=.*from)(?=.*useSelector)(?=.*useDispatch).*$/gmi -export const ReduxOptionalMatcher = /^(?=.*import)(?=.*from)(?=.*useSelector|useDispatch).*$/gmi -export const DispatchMatcher = /^(?=.*const)(?=.*dispatch)(?=.*useDispatch).*$/gmi +export const ReduxMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector)(?=.*useAppDispatch).*$/gmi +export const ReduxOptionalMatcher = /^(?=.*import)(?=.*from)(?=.*useAppSelector|useAppDispatch).*$/gmi +export const DispatchMatcher = /^(?=.*const)(?=.*dispatch)(?=.*useAppDispatch).*$/gmi export const BraceMatcher = /^(?=.*\[).*$/gmi export const BraceMatcher2 = /^(?=.*{).*$/gmi diff --git a/src/printer.ts b/src/printer.ts index 0b6246f..f73992a 100644 --- a/src/printer.ts +++ b/src/printer.ts @@ -17,7 +17,7 @@ import { SuperagentTypes, injectSupergent } from './generators/superagent' export const Printer = new Command('🖨️ Printer') Printer - .version('1.3.40') + .version('2.0.0') .description('🖨️ Printer: Automation Tooling for Next, Redux and Prisma.') .option('-a, --no-action', 'do not inject actions', false) .option('-s, --no-state', 'do not inject state', false) diff --git a/src/templates/api.template b/src/templates/api.template index b57d379..0a83588 100644 --- a/src/templates/api.template +++ b/src/templates/api.template @@ -1,17 +1,26 @@ -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' +import { NextRequest, NextResponse } from 'next/server' +import { getSession, createResponse } from 'util/session' -export const {{name}}Route = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - res.status(200).send({ status: 'OK' }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) +export async function GET(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + const { searchParams } = new URL(req.url) -export default {{name}}Route + try { + return createResponse( + res, + JSON.stringify({ + status: 'OK', + session + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} diff --git a/src/templates/crud.template b/src/templates/crud.template new file mode 100644 index 0000000..4b2e570 --- /dev/null +++ b/src/templates/crud.template @@ -0,0 +1,138 @@ +import { NextRequest, NextResponse } from 'next/server' +import { getSession, createResponse } from 'util/session' +import prisma from 'prisma/client' + +// Creates a new record +export async function POST(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const data = await req.json() + const {{model}} = await prisma.{{model}}.create({ data }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + {{model}} + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} + +// Updates an existing record by its @id +export async function PATCH(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const data = await req.json() + const id = data.id + delete data.id + + const {{model}} = await prisma.{{model}}.update({ + where: { id }, + data, + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + {{model}} + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} + +// Deletes a record by its @id +export async function DELETE(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const { searchParams } = new URL(req.url) + const id = searchParams.get('id') + + const {{model}} = await prisma.{{model}}.delete({ + where: { id } + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + {{model}} + }), + { status: 200 } + ) + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} + +// Lists results or gets a specific ID +export async function GET(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) + try { + const { searchParams } = new URL(req.url) + const id = searchParams.get('id') + const skip = searchParams.get('skip') + + if (id) { + const {{model}} = await prisma.{{model}}.findUnique({ + where: { id } + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + result: {{model}} + }), + { status: 200 } + ) + } else { + const results = await prisma.{{model}}.findMany({ + take: 10, + skip: Number(skip || '0') + }) + + return createResponse( + res, + JSON.stringify({ + status: 'OK', + results + }), + { status: 200 } + ) + } + } catch (error) { + console.error(error) + return createResponse( + res, + JSON.stringify({ status: 'ERROR', error }), + { status: 500 } + ) + } +} diff --git a/src/templates/crud/create.template b/src/templates/crud/create.template deleted file mode 100644 index 367b425..0000000 --- a/src/templates/crud/create.template +++ /dev/null @@ -1,23 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const CreateRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const {{model}} = await prisma.{{model}}.create({ - data: { - ...req.body - } - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default CreateRoute diff --git a/src/templates/crud/delete.template b/src/templates/crud/delete.template deleted file mode 100644 index 2c8eb11..0000000 --- a/src/templates/crud/delete.template +++ /dev/null @@ -1,23 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const DeleteRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const {{model}} = await prisma.{{model}}.delete({ - where: { - id: req.query.id || req.body.id - } - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default DeleteRoute diff --git a/src/templates/crud/get.template b/src/templates/crud/get.template deleted file mode 100644 index 8798c7d..0000000 --- a/src/templates/crud/get.template +++ /dev/null @@ -1,23 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const GetRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const {{model}} = await prisma.{{model}}.findUnique({ - where: { - id: req.query.id || req.body.id - } - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default GetRoute diff --git a/src/templates/crud/list.template b/src/templates/crud/list.template deleted file mode 100644 index 6afad5a..0000000 --- a/src/templates/crud/list.template +++ /dev/null @@ -1,19 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const ListRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const results = await prisma.{{model}}.findMany() - res.status(200).send({ status: 'OK', results }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default ListRoute diff --git a/src/templates/crud/update.template b/src/templates/crud/update.template deleted file mode 100644 index 1ad606d..0000000 --- a/src/templates/crud/update.template +++ /dev/null @@ -1,26 +0,0 @@ -import prisma from 'prisma/client' -import { NextApiRequest, NextApiResponse } from 'next' -import { withIronSessionApiRoute } from 'iron-session/next' -import { Session } from 'util/session' - -export const UpdateRoute = withIronSessionApiRoute( - async (req: NextApiRequest, res: NextApiResponse) => { - try { - const id = req.body.id - const data = req.body - delete data.id - - const {{model}} = await prisma.{{model}}.update({ - where: { id }, - data, - }) - res.status(200).send({ status: 'OK', {{model}} }) - } catch (error) { - console.error(error) - res.status(500).send({ status: 'ERROR', error }) - } - }, - Session -) - -export default UpdateRoute diff --git a/src/templates/new/.env.dev.local.template b/src/templates/new/.env.dev.local.template new file mode 100644 index 0000000..f61db17 --- /dev/null +++ b/src/templates/new/.env.dev.local.template @@ -0,0 +1,2 @@ +DATABASE_URL="http://localhost:1906" +SESSION_SECRET="{{password}}" \ No newline at end of file diff --git a/src/templates/new/.eslintrc.js.template b/src/templates/new/.eslintrc.js.template new file mode 100644 index 0000000..0a1e7d6 --- /dev/null +++ b/src/templates/new/.eslintrc.js.template @@ -0,0 +1,38 @@ +module.exports = { + env: { + browser: true, + es2021: true, + node: true + }, + extends: [ + 'next/core-web-vitals', + 'plugin:react/recommended', + 'standard', + 'prettier', + 'plugin:prettier/recommended' + ], + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaFeatures: { + jsx: true + }, + ecmaVersion: 'latest', + sourceType: 'module' + }, + plugins: ['react', '@typescript-eslint'], + rules: { + 'prettier/prettier': [ + 'warn', + { + singleQuote: true, + semi: false, + trailingComma: 'none' + } + ], + 'react/react-in-jsx-scope': 0, + 'no-empty-pattern': 0, + 'no-unused-vars': 0, + 'max-statements-per-line': 0, + 'new-cap': 0 + } +} diff --git a/src/templates/new/.gitignore.template b/src/templates/new/.gitignore.template new file mode 100644 index 0000000..1174f79 --- /dev/null +++ b/src/templates/new/.gitignore.template @@ -0,0 +1,122 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage +*.lcov + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# Snowpack dependency directory (https://snowpack.dev/) +web_modules/ + +# TypeScript cache +*.tsbuildinfo + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional stylelint cache +.stylelintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variable files +.env +.env.local +.env.test.local +.env.production.local + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next +out + +# Gatsby files +.cache/ +# Comment in the public line in if your project uses Gatsby and not Next.js +# https://nextjs.org/blog/next-9-1#public-directory-support +# public + +# vuepress build output +.vuepress/dist + +# vuepress v2.x temp and cache directory +.temp +.cache + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TernJS port file +.tern-port + +# Stores VSCode versions used for testing VSCode extensions +.vscode-test + +# yarn v2 +.yarn/cache +.yarn/unplugged +.yarn/build-state.yml +.yarn/install-state.gz +.pnp.* diff --git a/src/templates/new/README.md.template b/src/templates/new/README.md.template new file mode 100644 index 0000000..6f96bf9 --- /dev/null +++ b/src/templates/new/README.md.template @@ -0,0 +1,37 @@ +# Printer Template + +## Commands + +### `yarn dev` + +Start the dev server on `http://localhost:4200`. + +### `yarn build` + +Build the Next.js output in `dist`. + +### `yarn start` + +Start a production server on `http://localhost:3000`. + +### `yarn lint` | `yarn lint --fix` + +Runs `eslint` on the project and cleans up any style issues. + +### `yarn scss` + +Creates a debug `printer.css` file to review build outputs. + +### `yarn prisma` + +Creates the `prisma` client. + +### `yarn prisma:update` + +Creates the `prisma` client and then pushes schema updates to the database. + +## Documentation + +Review the documentation on [prntr.click/docs](https://prntr.click/docs). + +Review the [CHANGELOG](https://github.com/PrinterFramework/CLI/blob/master/CHANGELOG.md) for any updates made to the project. \ No newline at end of file diff --git a/src/templates/new/_app.template b/src/templates/new/_app.template deleted file mode 100644 index 87f64b6..0000000 --- a/src/templates/new/_app.template +++ /dev/null @@ -1,31 +0,0 @@ -import 'scss/printer.scss' -import App, { AppContext, AppInitialProps } from 'next/app' -import { wrapper } from 'redux/wrapper' -import Head from 'next/head' - -export class AppComponent extends App { - public static getInitialProps = async ({ Component, ctx }: AppContext) => { - return { - pageProps: { - ...(Component.getInitialProps - ? await Component.getInitialProps(ctx) - : {}) - }, - appProp: ctx.pathname - } - } - - public render() { - const { Component, pageProps } = this.props - return ( - <> - - Printer - - - - ) - } -} - -export default wrapper.withRedux(AppComponent) diff --git a/src/templates/new/_document.template b/src/templates/new/_document.template deleted file mode 100644 index bff2b1b..0000000 --- a/src/templates/new/_document.template +++ /dev/null @@ -1,13 +0,0 @@ -import { Html, Head, Main, NextScript } from 'next/document' - -export default function Document() { - return ( - - - -
- - - - ) -} diff --git a/src/templates/new/app/layout.tsx.template b/src/templates/new/app/layout.tsx.template new file mode 100644 index 0000000..c5b62c7 --- /dev/null +++ b/src/templates/new/app/layout.tsx.template @@ -0,0 +1,20 @@ +import 'scss/printer.scss' +import { ReactNode } from 'react' +import { ReduxProvider } from 'redux/provider' + +export interface LayoutI { + children: ReactNode +} + +export default function LayoutComponent({ children }: LayoutI) { + return ( + + + Printer + + + {children} + + + ) +} diff --git a/src/templates/new/app/page.tsx.template b/src/templates/new/app/page.tsx.template new file mode 100644 index 0000000..3260b5d --- /dev/null +++ b/src/templates/new/app/page.tsx.template @@ -0,0 +1,26 @@ +'use client' +import { decrement, increment, reset } from 'redux/slice/counter' +import { useAppSelector, useAppDispatch } from 'redux/hooks' + +export default function RootPage() { + const count = useAppSelector((state) => state.counter.data.value) + const dispatch = useAppDispatch() + + return ( +
+

Counter is at {count}

+ + +
+ ) +} diff --git a/src/templates/new/babelrc.template b/src/templates/new/babelrc.template deleted file mode 100644 index eef1b55..0000000 --- a/src/templates/new/babelrc.template +++ /dev/null @@ -1,4 +0,0 @@ -{ - "plugins": [["styled-components", { "ssr": true, "displayName": true, "preprocess": false } ]], - "presets": ["next/babel"] -} diff --git a/src/templates/new/env.dev.template b/src/templates/new/env.dev.template deleted file mode 100644 index 24955be..0000000 --- a/src/templates/new/env.dev.template +++ /dev/null @@ -1 +0,0 @@ -DATABASE_URL="http://localhost:1906" \ No newline at end of file diff --git a/src/templates/new/index.template b/src/templates/new/index.template deleted file mode 100644 index 2056f9e..0000000 --- a/src/templates/new/index.template +++ /dev/null @@ -1,5 +0,0 @@ -export interface IndexI {} - -export default function Index({}: IndexI) { - return

Page Index

-} diff --git a/src/templates/new/middleware.tsx.template b/src/templates/new/middleware.tsx.template new file mode 100644 index 0000000..cfc37a1 --- /dev/null +++ b/src/templates/new/middleware.tsx.template @@ -0,0 +1,10 @@ +import { NextRequest, NextResponse } from 'next/server' +import { getSession } from 'util/session' + +// See https://nextjs.org/docs/app/building-your-application/routing/middleware to manage client side routing with session states. +export async function middleware(req: NextRequest) { + const res = new NextResponse() + const session = await getSession(req, res) +} + +export const config = {} diff --git a/src/templates/new/next.config.js.template b/src/templates/new/next.config.js.template new file mode 100644 index 0000000..9a58c08 --- /dev/null +++ b/src/templates/new/next.config.js.template @@ -0,0 +1,5 @@ +module.exports = { + experimental: { + appDir: true + } +} diff --git a/src/templates/new/package.json.template b/src/templates/new/package.json.template new file mode 100644 index 0000000..f42c258 --- /dev/null +++ b/src/templates/new/package.json.template @@ -0,0 +1,43 @@ +{ + "name": "@printerframework/template", + "version": "1.0.0", + "scripts": { + "dev": "next dev --port 4200", + "build": "npm run prisma && next build", + "start": "next start", + "lint": "eslint . --ext ts,tsx --resolve-plugins-relative-to .", + "scss": "node-sass -r scss/printer.scss -o scss/debug", + "prisma": "npx prisma generate", + "prisma:update": "npx prisma generate && npx prisma db push" + }, + "dependencies": { + "@prisma/client": "^4.1.0", + "@reduxjs/toolkit": "^1.7.1", + "iron-session": "8.0.0-alpha.0", + "next": "^13.4.7", + "prisma": "^4.1.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-redux": "^7.2.6", + "sass": "^1.54.3", + "superagent": "^8.0.9" + }, + "devDependencies": { + "@types/node": "^17.0.13", + "@types/superagent": "^4.1.16", + "@typescript-eslint/eslint-plugin": "^5.60.0", + "@typescript-eslint/parser": "^5.14.0", + "eslint": "^8.43.0", + "eslint-config-next": "^13.4.7", + "eslint-config-prettier": "^8.5.0", + "eslint-config-standard": "^16.0.3", + "eslint-plugin-import": "^2.25.4", + "eslint-plugin-node": "^11.1.0", + "eslint-plugin-prettier": "^4.0.0", + "eslint-plugin-promise": "^5.2.0", + "eslint-plugin-react": "^7.29.3", + "node-sass": "^7.0.1", + "prettier": "^2.5.1", + "typescript": "^5.1.3" + } +} diff --git a/src/templates/new/precommit.template b/src/templates/new/precommit.template deleted file mode 100644 index 30d79d7..0000000 --- a/src/templates/new/precommit.template +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npm run lint --fix -npm run scss -npm run build diff --git a/src/templates/new/printer.config.json.template b/src/templates/new/printer.config.json.template new file mode 100644 index 0000000..75419c5 --- /dev/null +++ b/src/templates/new/printer.config.json.template @@ -0,0 +1,9 @@ +{ + "crud": { + "create": true, + "update": true, + "delete": true, + "list": true, + "get": true + } +} diff --git a/src/templates/new/printer.config.template b/src/templates/new/printer.config.template deleted file mode 100644 index b5193dc..0000000 --- a/src/templates/new/printer.config.template +++ /dev/null @@ -1,16 +0,0 @@ -{ - "componentFolder": false, - "component": { - "index": true, - "component": true, - "style": true, - "test": false - }, - "crud": { - "create": true, - "update": true, - "delete": true, - "list": true, - "get": true - } -} diff --git a/src/templates/new/printer.template b/src/templates/new/printer.template deleted file mode 100644 index 53b2154..0000000 --- a/src/templates/new/printer.template +++ /dev/null @@ -1,3 +0,0 @@ -@import "/scss/reset.scss"; -@import "/scss/theme.scss"; -@import "/scss/ui.scss"; \ No newline at end of file diff --git a/src/templates/new/prisma.client.template b/src/templates/new/prisma.client.template deleted file mode 100644 index 06f179a..0000000 --- a/src/templates/new/prisma.client.template +++ /dev/null @@ -1,15 +0,0 @@ -import { PrismaClient } from '@prisma/client' - -let prisma: PrismaClient - -if (process.env.NODE_ENV === 'production') { - prisma = new PrismaClient() -} else { - if (!global.prisma) { - global.prisma = new PrismaClient() - } - - prisma = global.prisma -} - -export default prisma diff --git a/src/templates/new/prisma/client.ts.template b/src/templates/new/prisma/client.ts.template new file mode 100644 index 0000000..a827650 --- /dev/null +++ b/src/templates/new/prisma/client.ts.template @@ -0,0 +1,7 @@ +import { PrismaClient } from '@prisma/client' + +export const prisma = new PrismaClient({ + log: [] +}) + +export default prisma diff --git a/src/templates/new/prisma/schema.prisma.template b/src/templates/new/prisma/schema.prisma.template new file mode 100644 index 0000000..3cefdf6 --- /dev/null +++ b/src/templates/new/prisma/schema.prisma.template @@ -0,0 +1,32 @@ +generator client { + provider = "prisma-client-js" +} + +datasource db { + provider = "mysql" + url = env("DATABASE_URL") + relationMode = "prisma" +} + +model Account { + id String @id @default(uuid()) @db.Char(36) + username String @unique @db.VarChar(128) + posts Post[] + dateCreated DateTime @default(now()) + dateUpdated DateTime @updatedAt + + @@index(dateCreated) +} + +model Post { + id String @id @default(uuid()) @db.Char(36) + accountId String @db.VarChar(128) + title String @db.VarChar(256) + content String @db.Text() + account Account @relation(fields: accountId, references: id) + dateCreated DateTime @default(now()) + dateUpdated DateTime @updatedAt + + @@index(accountId) + @@index(dateCreated) +} diff --git a/src/templates/new/reducer.template b/src/templates/new/reducer.template deleted file mode 100644 index d020248..0000000 --- a/src/templates/new/reducer.template +++ /dev/null @@ -1 +0,0 @@ -export const reducer = { } diff --git a/src/templates/new/redux/hooks.tsx.template b/src/templates/new/redux/hooks.tsx.template new file mode 100644 index 0000000..0a8c97e --- /dev/null +++ b/src/templates/new/redux/hooks.tsx.template @@ -0,0 +1,5 @@ +import { TypedUseSelectorHook, useDispatch, useSelector } from 'react-redux' +import type { RootState, AppDispatch } from 'redux/store' + +export const useAppDispatch = () => useDispatch() +export const useAppSelector: TypedUseSelectorHook = useSelector diff --git a/src/templates/new/redux/provider.tsx.template b/src/templates/new/redux/provider.tsx.template new file mode 100644 index 0000000..05ed353 --- /dev/null +++ b/src/templates/new/redux/provider.tsx.template @@ -0,0 +1,12 @@ +'use client' +import { ReactNode } from 'react' +import { store } from 'redux/store' +import { Provider } from 'react-redux' + +export interface ReduxProviderI { + children: ReactNode +} + +export function ReduxProvider({ children }: ReduxProviderI) { + return {children} +} diff --git a/src/templates/new/redux/reducer.tsx.template b/src/templates/new/redux/reducer.tsx.template new file mode 100644 index 0000000..5aa5ff6 --- /dev/null +++ b/src/templates/new/redux/reducer.tsx.template @@ -0,0 +1,5 @@ +import { counterSlice } from 'redux/slice/counter' + +export const reducer = { + counter: counterSlice.reducer +} diff --git a/src/templates/new/redux/reducers.json.template b/src/templates/new/redux/reducers.json.template new file mode 100644 index 0000000..3f1fa53 --- /dev/null +++ b/src/templates/new/redux/reducers.json.template @@ -0,0 +1,3 @@ +[ + "counter" +] \ No newline at end of file diff --git a/src/templates/new/redux/slice/counter.tsx.template b/src/templates/new/redux/slice/counter.tsx.template new file mode 100644 index 0000000..49257d8 --- /dev/null +++ b/src/templates/new/redux/slice/counter.tsx.template @@ -0,0 +1,28 @@ +import { createSlice, PayloadAction } from '@reduxjs/toolkit' +import CounterType from 'types/counter' + +export const counterInitialState = { + // @printer::inject::counter + data: { + value: 0 + } as CounterType +} + +export const counterSlice = createSlice({ + name: 'counter', + initialState: counterInitialState, + reducers: { + // @printer::inject + reset: () => counterInitialState, + // @printer::inject + increment: (state, action: PayloadAction) => { + state.data.value += action.payload + }, + // @printer::inject + decrement: (state, action: PayloadAction) => { + state.data.value -= action.payload + } + } +}) + +export const { increment, decrement, reset } = counterSlice.actions diff --git a/src/templates/new/redux/store.tsx.template b/src/templates/new/redux/store.tsx.template new file mode 100644 index 0000000..05e2d00 --- /dev/null +++ b/src/templates/new/redux/store.tsx.template @@ -0,0 +1,17 @@ +import { configureStore } from '@reduxjs/toolkit' +import { setupListeners } from '@reduxjs/toolkit/dist/query' +import { reducer } from 'redux/reducer' + +export const store = configureStore({ + reducer, + devTools: process.env.NODE_ENV !== 'production', + middleware: (getDefaultMiddleware) => + getDefaultMiddleware({ + serializableCheck: false + }) +}) + +setupListeners(store.dispatch) + +export type RootState = ReturnType +export type AppDispatch = typeof store.dispatch diff --git a/src/templates/new/scss/index.scss.template b/src/templates/new/scss/index.scss.template new file mode 100644 index 0000000..2a905c7 --- /dev/null +++ b/src/templates/new/scss/index.scss.template @@ -0,0 +1,18 @@ +@import "/scss/theme.scss"; + +section.root-page { + h2 { + font-size: 32px; + padding: 0 0 15px 0; + } + + div.buttons { + display: flex; + align-items: center; + justify-content: center; + + a.button { + margin: 15px; + } + } +} \ No newline at end of file diff --git a/src/templates/new/scss/printer.scss.template b/src/templates/new/scss/printer.scss.template new file mode 100644 index 0000000..e0dace2 --- /dev/null +++ b/src/templates/new/scss/printer.scss.template @@ -0,0 +1,5 @@ +@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600&family=Oswald:wght@300;400;500;600;700&display=swap'); +@import "/scss/reset.scss"; +@import "/scss/theme.scss"; +@import "/scss/ui.scss"; +@import "/scss/index.scss"; \ No newline at end of file diff --git a/src/templates/new/scss/reset.scss.template b/src/templates/new/scss/reset.scss.template new file mode 100644 index 0000000..cc10ae7 --- /dev/null +++ b/src/templates/new/scss/reset.scss.template @@ -0,0 +1,43 @@ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1.5; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} diff --git a/src/templates/new/scss/theme.scss.template b/src/templates/new/scss/theme.scss.template new file mode 100644 index 0000000..bbae09e --- /dev/null +++ b/src/templates/new/scss/theme.scss.template @@ -0,0 +1,17 @@ +$header-font: 'Oswald'; +$body-font: 'Montserrat'; + +$primary: #C49A0F; +$primary-light: #F2D577; + +$container-width: 1268px; +$page-height: 100vh; + +@mixin bg-gradient() { + background: rgb(41, 41, 41); + background: radial-gradient(circle, rgba(41, 41, 41, 1) 0%, rgba(29, 29, 29, 1) 100%); +} + +@mixin transition($property: all, $duration: 0.25s) { + transition: $property $duration cubic-bezier(0.33, 1, 0.68, 1); +} \ No newline at end of file diff --git a/src/templates/new/scss/ui.scss.template b/src/templates/new/scss/ui.scss.template new file mode 100644 index 0000000..430b749 --- /dev/null +++ b/src/templates/new/scss/ui.scss.template @@ -0,0 +1,88 @@ +@import "/scss/theme.scss"; + +* { + box-sizing: border-box; +} + +body { + font-family: $body-font; + @include bg-gradient(); + color: white; + margin: 0; + padding: 0; + overflow-x: hidden; +} + +h1, h2, h3, h4, h5, h6 { + font-family: $header-font; +} + +h1 { + font-size: 32px; +} + +h2 { + font-size: 24px; +} + +h3 { + font-size: 18px; +} + +h4 { + font-size: 16px; +} + +a { + cursor: pointer; +} + +button, input, textarea { + font-family: inherit; + outline: none; +} + +section.container, div.container { + width: 100%; + max-width: $container-width; + margin: auto; + &.page { + min-height: $page-height; + } + &.flex { + display: flex; + flex-wrap: wrap; + } + &.center { + display: flex; + flex-direction: column; + align-items: center; + justify-content: center; + } +} + +a.button, button { + display: flex; + align-items: center; + justify-content: center; + width: 140px; + height: 35px; + border-radius: 3px; + font-family: $body-font; + font-size: 16px; + font-weight: bold; + background: $primary; + color: white; + text-decoration: none; + margin: 0 15px 0 0; + cursor: pointer; + @include transition(); + + &:hover { + background: $primary-light; + } + + .i, .icon { + margin: 0 8px 0 0; + } +} diff --git a/src/templates/new/session.template b/src/templates/new/session.template deleted file mode 100644 index 95c3318..0000000 --- a/src/templates/new/session.template +++ /dev/null @@ -1,9 +0,0 @@ -export const password = '{{password}}'; - -export const Session = { - cookieName: 'printer', - password, - cookieOptions: { - secure: process.env.NODE_ENV === 'production', - }, -} diff --git a/src/templates/new/theme.template b/src/templates/new/theme.template deleted file mode 100644 index 173c72b..0000000 --- a/src/templates/new/theme.template +++ /dev/null @@ -1,2 +0,0 @@ -$headerFont: 'Arial'; -$copyFont: 'Arial'; diff --git a/src/templates/new/tsconfig.json.template b/src/templates/new/tsconfig.json.template new file mode 100644 index 0000000..5da3021 --- /dev/null +++ b/src/templates/new/tsconfig.json.template @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "target": "ES5", + "lib": [ + "DOM", + "DOM.iterable", + "ESNext" + ], + "baseUrl": "./", + "allowJs": true, + "skipLibCheck": true, + "strict": false, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "incremental": true, + "esModuleInterop": true, + "module": "CommonJS", + "moduleResolution": "Node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "plugins": [ + { "name": "next" } + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx", + ".next/types/**/*.ts" + ], + "exclude": [ + "node_modules" + ] +} diff --git a/src/templates/new/tsconfig.template b/src/templates/new/tsconfig.template deleted file mode 100644 index 0a6352a..0000000 --- a/src/templates/new/tsconfig.template +++ /dev/null @@ -1,31 +0,0 @@ -{ - "compilerOptions": { - "target": "es5", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], - "baseUrl": "./", - "allowJs": true, - "skipLibCheck": true, - "strict": false, - "forceConsistentCasingInFileNames": true, - "noEmit": true, - "incremental": true, - "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "node", - "resolveJsonModule": true, - "isolatedModules": true, - "jsx": "preserve" - }, - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ] -} diff --git a/src/templates/new/types/counter.tsx.template b/src/templates/new/types/counter.tsx.template new file mode 100644 index 0000000..ed2851e --- /dev/null +++ b/src/templates/new/types/counter.tsx.template @@ -0,0 +1,5 @@ +export interface CounterType { + value: number +} + +export default CounterType diff --git a/src/templates/new/ui.template b/src/templates/new/ui.template deleted file mode 100644 index 3e63ad2..0000000 --- a/src/templates/new/ui.template +++ /dev/null @@ -1,41 +0,0 @@ -@import "/scss/theme.scss"; - -* { - transition: all 0.25s cubic-bezier(0.33, 1, 0.68, 1); - box-sizing: border-box; -} - -body { - margin: 0; - padding: 0; - overflow-x: hidden; -} - -h1, h2, h3, h4, h5, h6 { - font-family: $headerFont; -} - -h1 { - font-size: 32px; -} - -h2 { - font-size: 24px; -} - -h3 { - font-size: 18px; -} - -h4 { - font-size: 16px; -} - -a { - cursor: pointer; -} - -button, input, textarea { - font-family: inherit; - outline: none; -} diff --git a/src/templates/new/util/session.ts.template b/src/templates/new/util/session.ts.template new file mode 100644 index 0000000..c40eb44 --- /dev/null +++ b/src/templates/new/util/session.ts.template @@ -0,0 +1,25 @@ +import { NextRequest, NextResponse } from 'next/server' +import { getIronSession, createResponse } from 'iron-session' + +export const password = + process.env.SESSION_SECRET || + '{{password}}' + +export interface SessionI { + counter?: number +} + +export function getSession(req: NextRequest, res: NextResponse) { + return getIronSession(req, res, { + password, + cookieName: 'printer', + cookieOptions: { + secure: process.env.NODE_ENV === 'production', + maxAge: process.env.COOKIE_AGE + ? Number(process.env.COOKIE_AGE) + : undefined + } + }) +} + +export { createResponse } diff --git a/src/templates/new/wrapper.template b/src/templates/new/wrapper.template deleted file mode 100644 index b957db4..0000000 --- a/src/templates/new/wrapper.template +++ /dev/null @@ -1,19 +0,0 @@ -import { configureStore, ThunkAction } from '@reduxjs/toolkit' -import { Action } from 'redux' -import { createWrapper } from 'next-redux-wrapper' -import { reducer } from 'redux/reducer' - -export function makeStore() { - return configureStore({ reducer }) -} - -export type AppStore = ReturnType -export type AppState = ReturnType -export type AppThunk = ThunkAction< - ReturnType, - AppState, - unknown, - Action -> - -export const wrapper = createWrapper(makeStore) diff --git a/src/templates/page.template b/src/templates/page.template index 1ba2ffc..2e28305 100644 --- a/src/templates/page.template +++ b/src/templates/page.template @@ -1,5 +1,13 @@ -export interface {{name}}I {} +'use client' + +export interface {{name}}PageI { -export default function {{name}}({}: {{name}}I) { - return

Page {{name}}

} + +export default function {{name}}Page({}: {{name}}PageI) { + return ( +
+

{{name}} Page

+
+ ) +} \ No newline at end of file diff --git a/src/templates/page.url.template b/src/templates/page.url.template index 28a7cee..b500715 100644 --- a/src/templates/page.url.template +++ b/src/templates/page.url.template @@ -1,10 +1,13 @@ -import { useRouter } from 'next/router' +'use client' -export interface {{name}}I {} - -export default function {{name}}({}: {{name}}I) { - const router = useRouter() - const { {{url}} } = router.query - - return

Page {{name}}

+export interface {{name}}PageI { + {{url_interface}} } + +export default function {{name}}Page({ {{url_variables}} }: {{name}}PageI) { + return ( +
+

{{name}} Page

+
+ ) +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 76430be..e9d57d2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,11 +14,11 @@ "strict": true }, "exclude": [ - "node_modules" + "node_modules", + "src/**/*.template" ], "include": [ "src/**/*.ts", - "src/**/*.template", "test/**/*.ts" ] }