From bdc763a84b3a3ab3a8fb370d4758ecf956a1ff34 Mon Sep 17 00:00:00 2001 From: Karan Raina Date: Fri, 26 Apr 2024 14:40:21 +0530 Subject: [PATCH 1/5] feat(core): support for custom routes --- src/helper/utils.ts | 2 +- src/lib/Theme.ts | 45 +++++++++++++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/helper/utils.ts b/src/helper/utils.ts index a88bc5a4..7a996998 100644 --- a/src/helper/utils.ts +++ b/src/helper/utils.ts @@ -117,7 +117,7 @@ export function sortString(str) { } export const pageNameModifier = (page) => { - let pageArr = page.split('-'); + let pageArr = (page[0] === ':' ? page.substring(1) : page).split('-'); let res = ''; pageArr.forEach((p) => { res += p[0]?.toUpperCase() + p.substring(1) + ' '; diff --git a/src/lib/Theme.ts b/src/lib/Theme.ts index 55123c24..8d079606 100644 --- a/src/lib/Theme.ts +++ b/src/lib/Theme.ts @@ -2381,31 +2381,48 @@ export default class Theme { } const customFiles = {}; - const customRoutes = (ctTemplates, parentKey = null) => { - for (let key in ctTemplates) { + + const customRoutes = (ctTemplates, parentKey = 'c') => { + (Array.isArray(ctTemplates) ? ctTemplates : [ctTemplates]).forEach((customPage) => { + + const { path: _path, handle = {}, children, index } = customPage.props; + + let path = _path; + + if (_path && children) { + return customRoutes(children, `${parentKey}/${_path}`) + } + + if (!_path && index) { + path = '' + } + let settingProps; - const routerPath = - (parentKey && `${parentKey}/${key}`) || `c/${key}`; + const routerPath = `${parentKey}${path ? '/' + path : ''}`; const value = routerPath.replace(/\//g, ':::'); - if (ctTemplates[key].settings) { - settingProps = ctTemplates[key].settings.props; + + if ( + children + ) { + return customRoutes(children, routerPath); + } + + + + if (handle.settings) { + settingProps = handle.settings.props; } customFiles[value] = { fileSetting: settingProps, value, - text: pageNameModifier(key), + text: pageNameModifier(path), path: routerPath, }; - if ( - ctTemplates[key].children && - Object.keys(ctTemplates[key].children).length - ) { - customRoutes(ctTemplates[key].children, routerPath); - } - } + }); }; customRoutes(customTemplates); + console.log(customTemplates, {customFiles}) // Delete custom pages removed from code const pagesToDelete = customPagesDB.filter( (x) => !customFiles[x.value], From aa7715fbc3ce79fb1266179768ea008ec89d8878 Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 2 May 2024 12:23:18 +0530 Subject: [PATCH 2/5] beta release --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 12aeca0f..c4118936 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.6", + "version": "5.0.7-beta.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gofynd/fdk-cli", - "version": "5.0.6", + "version": "5.0.7-beta.1", "license": "MIT", "dependencies": { "@babel/core": "7.14.3", diff --git a/package.json b/package.json index db201c0d..735aca7f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7", + "version": "5.0.7-beta.1", "main": "index.js", "license": "MIT", "bin": { From 1e2d9739724360db08ac4bd397f31e2e4d8506a4 Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 2 May 2024 12:41:40 +0530 Subject: [PATCH 3/5] beta releasee --- package-lock.json | 145 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 4 +- 2 files changed, 146 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index c4118936..fb505a6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.1", + "version": "5.0.7-beta.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.1", + "version": "5.0.7-beta.2", "license": "MIT", "dependencies": { "@babel/core": "7.14.3", @@ -49,7 +49,9 @@ "open": "^8.2.1", "ora": "^5.4.0", "query-string": "^7.1.0", + "react": "^18.3.1", "react-refresh": "^0.14.0", + "react-router-dom": "^6.23.0", "rimraf": "^3.0.2", "semver": "^6.3.0", "simple-git": "^3.15.0", @@ -1320,6 +1322,14 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/@remix-run/router": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.16.0.tgz", + "integrity": "sha512-Quz1KOffeEf/zwkCBM3kBtH4ZoZ+pT3xIXBG4PPW/XFtDP7EGhtTiC2+gpL9GnR7+Qdet5Oa6cYSvwKYg6kN9Q==", + "engines": { + "node": ">=14.0.0" + } + }, "node_modules/@sentry-internal/tracing": { "version": "7.92.0", "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.92.0.tgz", @@ -7606,6 +7616,17 @@ "triple-beam": "^1.3.0" } }, + "node_modules/loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "dependencies": { + "js-tokens": "^3.0.0 || ^4.0.0" + }, + "bin": { + "loose-envify": "cli.js" + } + }, "node_modules/lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", @@ -8884,6 +8905,30 @@ "rc": "cli.js" } }, + "node_modules/react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "dependencies": { + "loose-envify": "^1.1.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + }, + "peerDependencies": { + "react": "^18.3.1" + } + }, "node_modules/react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -8898,6 +8943,36 @@ "node": ">=0.10.0" } }, + "node_modules/react-router": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.23.0.tgz", + "integrity": "sha512-wPMZ8S2TuPadH0sF5irFGjkNLIcRvOSaEe7v+JER8508dyJumm6XZB1u5kztlX0RVq6AzRVndzqcUh6sFIauzA==", + "dependencies": { + "@remix-run/router": "1.16.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8" + } + }, + "node_modules/react-router-dom": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.23.0.tgz", + "integrity": "sha512-Q9YaSYvubwgbal2c9DJKfx6hTNoBp3iJDsl+Duva/DwxoJH+OTXkxGpql4iUK2sla/8z4RpjAm6EWx1qUDuopQ==", + "dependencies": { + "@remix-run/router": "1.16.0", + "react-router": "6.23.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "react": ">=16.8", + "react-dom": ">=16.8" + } + }, "node_modules/read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -9257,6 +9332,15 @@ "node": ">=10" } }, + "node_modules/scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "peer": true, + "dependencies": { + "loose-envify": "^1.1.0" + } + }, "node_modules/schema-utils": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", @@ -11933,6 +12017,11 @@ } } }, + "@remix-run/router": { + "version": "1.16.0", + "resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.16.0.tgz", + "integrity": "sha512-Quz1KOffeEf/zwkCBM3kBtH4ZoZ+pT3xIXBG4PPW/XFtDP7EGhtTiC2+gpL9GnR7+Qdet5Oa6cYSvwKYg6kN9Q==" + }, "@sentry-internal/tracing": { "version": "7.92.0", "resolved": "https://registry.npmjs.org/@sentry-internal/tracing/-/tracing-7.92.0.tgz", @@ -16761,6 +16850,14 @@ "triple-beam": "^1.3.0" } }, + "loose-envify": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/loose-envify/-/loose-envify-1.4.0.tgz", + "integrity": "sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==", + "requires": { + "js-tokens": "^3.0.0 || ^4.0.0" + } + }, "lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", @@ -17669,6 +17766,24 @@ "strip-json-comments": "~2.0.1" } }, + "react": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react/-/react-18.3.1.tgz", + "integrity": "sha512-wS+hAgJShR0KhEvPJArfuPVN1+Hz1t0Y6n5jLrGQbkb4urgPE/0Rve+1kMB1v/oWgHgm4WIcV+i7F2pTVj+2iQ==", + "requires": { + "loose-envify": "^1.1.0" + } + }, + "react-dom": { + "version": "18.3.1", + "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.3.1.tgz", + "integrity": "sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==", + "peer": true, + "requires": { + "loose-envify": "^1.1.0", + "scheduler": "^0.23.2" + } + }, "react-is": { "version": "17.0.2", "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", @@ -17680,6 +17795,23 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.14.0.tgz", "integrity": "sha512-wViHqhAd8OHeLS/IRMJjTSDHF3U9eWi62F/MledQGPdJGDhodXJ9PBLNGr6WWL7qlH12Mt3TyTpbS+hGXMjCzQ==" }, + "react-router": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-6.23.0.tgz", + "integrity": "sha512-wPMZ8S2TuPadH0sF5irFGjkNLIcRvOSaEe7v+JER8508dyJumm6XZB1u5kztlX0RVq6AzRVndzqcUh6sFIauzA==", + "requires": { + "@remix-run/router": "1.16.0" + } + }, + "react-router-dom": { + "version": "6.23.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.23.0.tgz", + "integrity": "sha512-Q9YaSYvubwgbal2c9DJKfx6hTNoBp3iJDsl+Duva/DwxoJH+OTXkxGpql4iUK2sla/8z4RpjAm6EWx1qUDuopQ==", + "requires": { + "@remix-run/router": "1.16.0", + "react-router": "6.23.0" + } + }, "read-pkg": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", @@ -17951,6 +18083,15 @@ "xmlchars": "^2.2.0" } }, + "scheduler": { + "version": "0.23.2", + "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.23.2.tgz", + "integrity": "sha512-UOShsPwz7NrMUqhR6t0hWjFduvOzbtv7toDH1/hIrfRNIDBnnBWd0CwJTGvTpngVlmwGCdP9/Zl/tVrDqcuYzQ==", + "peer": true, + "requires": { + "loose-envify": "^1.1.0" + } + }, "schema-utils": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.3.0.tgz", diff --git a/package.json b/package.json index 735aca7f..df5fc141 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.1", + "version": "5.0.7-beta.2", "main": "index.js", "license": "MIT", "bin": { @@ -106,6 +106,8 @@ "open": "^8.2.1", "ora": "^5.4.0", "query-string": "^7.1.0", + "react": "^18.3.1", + "react-router-dom": "^6.23.0", "react-refresh": "^0.14.0", "rimraf": "^3.0.2", "semver": "^6.3.0", From 8c716309d922a6f1dccc46d32a09fa7fbf51e8de Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 2 May 2024 12:48:16 +0530 Subject: [PATCH 4/5] beta release --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index fb505a6e..0a4a6ba6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.2", + "version": "5.0.7-beta.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.2", + "version": "5.0.7-beta.3", "license": "MIT", "dependencies": { "@babel/core": "7.14.3", diff --git a/package.json b/package.json index df5fc141..aff8d85d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.2", + "version": "5.0.7-beta.3", "main": "index.js", "license": "MIT", "bin": { From 60d4be345b9cd3a2fecbdfedb17c5c2b35ccf322 Mon Sep 17 00:00:00 2001 From: meetdhanani Date: Thu, 2 May 2024 17:45:36 +0530 Subject: [PATCH 5/5] version up --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0a4a6ba6..7816a977 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.3", + "version": "5.0.7-beta.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.3", + "version": "5.0.7-beta.4", "license": "MIT", "dependencies": { "@babel/core": "7.14.3", diff --git a/package.json b/package.json index aff8d85d..eb9a85d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gofynd/fdk-cli", - "version": "5.0.7-beta.3", + "version": "5.0.7-beta.4", "main": "index.js", "license": "MIT", "bin": {