Browse Source

fix conflicts

pull/4140/head
flisowna 2 years ago
parent
commit
f7c59d987e
  1. 889
      .all-contributorsrc
  2. 0
      .github/PULL_REQUEST_TEMPLATE.md
  3. 0
      .github/SPONSORS.md
  4. 117
      .github/workflows/ci-cd.yml
  5. 11
      .github/workflows/release-executables.yml
  6. 16
      .github/workflows/release-timely-executables.yml
  7. 1
      .gitignore
  8. 4
      .husky/pre-commit
  9. 12
      .run/test-debug.run.xml
  10. 12
      .run/test.run.xml
  11. 20
      README.md
  12. 42
      Run.md
  13. 48
      docker-compose/mssql/docker-compose.yml
  14. 61
      docker-compose/mysql/docker-compose.yml
  15. 98
      docker-compose/nginx-proxy-manager/docker-compose.yml
  16. 126
      docker-compose/nginx/docker-compose.yml
  17. 45
      docker-compose/pg/docker-compose.yml
  18. 203
      docker-compose/traefik/docker-compose.yml
  19. 0
      markdown/plugins/google-auth.md
  20. 0
      markdown/plugins/s3.md
  21. 0
      markdown/readme/languages/README.md
  22. 2
      markdown/readme/languages/chinese.md
  23. 0
      markdown/readme/languages/dutch.md
  24. 0
      markdown/readme/languages/french.md
  25. 2
      markdown/readme/languages/german.md
  26. 0
      markdown/readme/languages/indonesian.md
  27. 0
      markdown/readme/languages/italian.md
  28. 0
      markdown/readme/languages/japanese.md
  29. 0
      markdown/readme/languages/korean.md
  30. 0
      markdown/readme/languages/portuguese.md
  31. 0
      markdown/readme/languages/russian.md
  32. 0
      markdown/readme/languages/spanish.md
  33. 1814
      package-lock.json
  34. 40
      package.json
  35. 682
      packages/nc-cli/LICENSE
  36. 1
      packages/nc-cli/README.md
  37. 1321
      packages/nc-cli/package-lock.json
  38. 24
      packages/nc-cli/package.json
  39. 34
      packages/nc-cli/src/index.ts
  40. 19
      packages/nc-cli/src/lib/CliMgr.ts
  41. 79
      packages/nc-cli/src/lib/mgr/AppMgr.ts
  42. 49
      packages/nc-cli/src/lib/mgr/Client.ts
  43. 38
      packages/nc-cli/src/lib/mgr/ComponentMgr.ts
  44. 26
      packages/nc-cli/src/lib/mgr/DockerMgr.ts
  45. 23
      packages/nc-cli/src/lib/mgr/InstantMgr.ts
  46. 52
      packages/nc-cli/src/lib/mgr/MigrationMgr.ts
  47. 44
      packages/nc-cli/src/lib/mgr/ModelMgr.ts
  48. 782
      packages/nc-cli/src/lib/mgr/NewMgr.ts
  49. 306
      packages/nc-cli/src/lib/mgr/OldNewMgr.ts
  50. 534
      packages/nc-cli/src/lib/mgr/PermissionsMgr.ts
  51. 555
      packages/nc-cli/src/lib/mgr/PermissionsMgrJs.ts
  52. 93
      packages/nc-cli/src/lib/mgr/SocialMgr.ts
  53. 19
      packages/nc-cli/src/lib/mgr/SocialText.ts
  54. 280
      packages/nc-cli/src/lib/mgr/TryMgr.ts
  55. 79
      packages/nc-cli/src/lib/mgr/XcInstantMgr.ts
  56. 55
      packages/nc-cli/src/lib/prompts/Menu.ts
  57. 32
      packages/nc-cli/src/lib/prompts/RunOrDownload.ts
  58. 31
      packages/nc-cli/src/lib/util/Lang.ts
  59. 347
      packages/nc-cli/src/lib/util/Locales.ts
  60. 301
      packages/nc-cli/src/lib/util/Util.ts
  61. 5
      packages/nc-cli/src/lib/util/config.ts
  62. 661
      packages/nc-gui/LICENSE
  63. 1
      packages/nc-gui/components.d.ts
  64. 9
      packages/nc-gui/components/cell/MultiSelect.vue
  65. 9
      packages/nc-gui/components/cell/SingleSelect.vue
  66. 1
      packages/nc-gui/components/cell/attachment/index.vue
  67. 13
      packages/nc-gui/components/dashboard/TreeView.vue
  68. 10
      packages/nc-gui/components/dashboard/settings/AuditTab.vue
  69. 9
      packages/nc-gui/components/dashboard/settings/Modal.vue
  70. 1
      packages/nc-gui/components/dlg/TableCreate.vue
  71. 11
      packages/nc-gui/components/general/JoinCloud.vue
  72. 2
      packages/nc-gui/components/general/TruncateText.vue
  73. 4
      packages/nc-gui/components/smartsheet/Cell.vue
  74. 32
      packages/nc-gui/components/smartsheet/Form.vue
  75. 4
      packages/nc-gui/components/smartsheet/Gallery.vue
  76. 16
      packages/nc-gui/components/smartsheet/Grid.vue
  77. 2
      packages/nc-gui/components/smartsheet/Kanban.vue
  78. 2
      packages/nc-gui/components/smartsheet/Pagination.vue
  79. 2
      packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
  80. 24
      packages/nc-gui/components/smartsheet/column/SelectOptions.vue
  81. 1
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  82. 7
      packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue
  83. 2
      packages/nc-gui/components/smartsheet/sidebar/index.vue
  84. 1
      packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue
  85. 9
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  86. 14
      packages/nc-gui/components/smartsheet/toolbar/ShareView.vue
  87. 5
      packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue
  88. 2
      packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue
  89. 2
      packages/nc-gui/components/tabs/auth/user-management/ShareBase.vue
  90. 2
      packages/nc-gui/components/webhook/Drawer.vue
  91. 264
      packages/nc-gui/lang/zh-Hans.json
  92. 2
      packages/nc-gui/layouts/base.vue
  93. 2
      packages/nc-gui/layouts/shared-view.vue
  94. 3
      packages/nc-gui/lib/constants.ts
  95. 29476
      packages/nc-gui/package-lock.json
  96. 19
      packages/nc-gui/package.json
  97. 1
      packages/nc-gui/pages/[projectType]/[projectId]/index.vue
  98. 6
      packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue
  99. 9
      packages/nc-gui/pages/[projectType]/form/[viewId]/index/index.vue
  100. 27
      packages/nc-gui/pages/[projectType]/form/[viewId]/index/survey.vue
  101. Some files were not shown because too many files have changed in this diff Show More

889
.all-contributorsrc

@ -1,889 +0,0 @@
{
"projectName": "nocodb",
"projectOwner": "nocodb",
"repoType": "github",
"repoHost": "https://github.com",
"files": [
"README.md"
],
"imageSize": 100,
"commit": false,
"commitConvention": "none",
"contributors": [
{
"login": "o1lab",
"name": "o1lab",
"avatar_url": "https://avatars.githubusercontent.com/u/5435402?v=4",
"profile": "https://github.com/o1lab",
"contributions": [
"code"
]
},
{
"login": "pranavxc",
"name": "Pranav C",
"avatar_url": "https://avatars.githubusercontent.com/u/61551451?v=4",
"profile": "https://github.com/pranavxc",
"contributions": [
"code"
]
},
{
"login": "bvkatwijk",
"name": "Boris van Katwijk",
"avatar_url": "https://avatars.githubusercontent.com/u/18490578?v=4",
"profile": "http://bvkatwijk.nl/",
"contributions": [
"code"
]
},
{
"login": "markuman",
"name": "Markus Bergholz",
"avatar_url": "https://avatars.githubusercontent.com/u/3920157?v=4",
"profile": "https://stackshare.io/markuman/my-stack",
"contributions": [
"code"
]
},
{
"login": "DanielRuf",
"name": "Daniel Ruf",
"avatar_url": "https://avatars.githubusercontent.com/u/827205?v=4",
"profile": "https://daniel-ruf.de/",
"contributions": [
"code"
]
},
{
"login": "bertyhell",
"name": "Bert Verhelst",
"avatar_url": "https://avatars.githubusercontent.com/u/1710840?v=4",
"profile": "http://bertverhelst.ga/",
"contributions": [
"code"
]
},
{
"login": "chocholand",
"name": "JaeWon",
"avatar_url": "https://avatars.githubusercontent.com/u/6572227?v=4",
"profile": "https://github.com/chocholand",
"contributions": [
"code"
]
},
{
"login": "0xflotus",
"name": "0xflotus",
"avatar_url": "https://avatars.githubusercontent.com/u/26602940?v=4",
"profile": "https://github.com/0xflotus",
"contributions": [
"code"
]
},
{
"login": "sguionni",
"name": "Simon Guionniere",
"avatar_url": "https://avatars.githubusercontent.com/u/3633017?v=4",
"profile": "http://www.simonguionniere.com/",
"contributions": [
"code"
]
},
{
"login": "extremeshok",
"name": "eXtremeSHOK",
"avatar_url": "https://avatars.githubusercontent.com/u/5957328?v=4",
"profile": "https://clients.extremeshok.com/",
"contributions": [
"code"
]
},
{
"login": "v2io",
"name": "v2io",
"avatar_url": "https://avatars.githubusercontent.com/u/48987429?v=4",
"profile": "https://github.com/v2io",
"contributions": [
"code"
]
},
{
"login": "soaserele",
"name": "Stanislav Oaserele",
"avatar_url": "https://avatars.githubusercontent.com/u/1093368?v=4",
"profile": "https://github.com/soaserele",
"contributions": [
"code"
]
},
{
"login": "ans-4175",
"name": "Ahmad Anshorimuslim Syuhada",
"avatar_url": "https://avatars.githubusercontent.com/u/3961872?v=4",
"profile": "https://ans4175.dev/",
"contributions": [
"code"
]
},
{
"login": "lotas",
"name": "Yaraslau Kurmyza",
"avatar_url": "https://avatars.githubusercontent.com/u/83861?v=4",
"profile": "https://github.com/lotas",
"contributions": [
"code"
]
},
{
"login": "ferrybig",
"name": "Fernando van Loenhout",
"avatar_url": "https://avatars.githubusercontent.com/u/1576684?v=4",
"profile": "http://stackexchange.com/users/1677570/ferrybig",
"contributions": [
"code"
]
},
{
"login": "jrevault",
"name": "jrevault",
"avatar_url": "https://avatars.githubusercontent.com/u/1001585?v=4",
"profile": "http://blog.quidquid.fr/",
"contributions": [
"code"
]
},
{
"login": "atilacamurca",
"name": "Átila Camurça Alves",
"avatar_url": "https://avatars.githubusercontent.com/u/508624?v=4",
"profile": "https://github.com/atilacamurca",
"contributions": [
"code"
]
},
{
"login": "simonbowen",
"name": "Simon Bowen",
"avatar_url": "https://avatars.githubusercontent.com/u/8931?v=4",
"profile": "https://github.com/simonbowen",
"contributions": [
"code"
]
},
{
"login": "wingkwong",
"name": "աɨռɢӄաօռɢ",
"avatar_url": "https://avatars.githubusercontent.com/u/35857179?v=4",
"profile": "https://wingk-wong.blogspot.com/",
"contributions": [
"code"
]
},
{
"login": "ferdiga",
"name": "Ferdinand Gassauer",
"avatar_url": "https://avatars.githubusercontent.com/u/6248560?v=4",
"profile": "https://github.com/ferdiga",
"contributions": [
"code"
]
},
{
"login": "Flatroy",
"name": "George Daneke",
"avatar_url": "https://avatars.githubusercontent.com/u/4980165?v=4",
"profile": "https://daneke.ru/",
"contributions": [
"code"
]
},
{
"login": "jwillmer",
"name": "Jens Willmer",
"avatar_url": "https://avatars.githubusercontent.com/u/1503577?v=4",
"profile": "https://jwillmer.de/",
"contributions": [
"code"
]
},
{
"login": "bhanuc",
"name": "Bhanu Pratap Chaudhary",
"avatar_url": "https://avatars.githubusercontent.com/u/2958857?v=4",
"profile": "http://bhanu.io/",
"contributions": [
"code"
]
},
{
"login": "jwetzell",
"name": "Joel Wetzell",
"avatar_url": "https://avatars.githubusercontent.com/u/18341515?v=4",
"profile": "https://github.com/jwetzell",
"contributions": [
"code"
]
},
{
"login": "SebGTx",
"name": "SebGTx",
"avatar_url": "https://avatars.githubusercontent.com/u/8062146?v=4",
"profile": "https://github.com/SebGTx",
"contributions": [
"code"
]
},
{
"login": "FarazPatankar",
"name": "Faraz Patankar",
"avatar_url": "https://avatars.githubusercontent.com/u/10681116?v=4",
"profile": "https://farazpatankar.com/",
"contributions": [
"code"
]
},
{
"login": "pixplix",
"name": "PixPlix",
"avatar_url": "https://avatars.githubusercontent.com/u/71349937?v=4",
"profile": "https://pixplix.com/",
"contributions": [
"code"
]
},
{
"login": "janrito",
"name": "Alejandro Giacometti",
"avatar_url": "https://avatars.githubusercontent.com/u/31504?v=4",
"profile": "http://alejandro.giacometti.me/",
"contributions": [
"code"
]
},
{
"login": "bmscmoreira",
"name": "Bruno Moreira",
"avatar_url": "https://avatars.githubusercontent.com/u/3017910?v=4",
"profile": "https://brunomoreira.opo.pt",
"contributions": [
"code"
]
},
{
"login": "AztrexDX",
"name": "AztrexDX",
"avatar_url": "https://avatars.githubusercontent.com/u/86340924?v=4",
"profile": "https://github.com/AztrexDX",
"contributions": [
"code"
]
},
{
"login": "ejose19",
"name": "ejose19",
"avatar_url": "https://avatars.githubusercontent.com/u/8742215?v=4",
"profile": "https://github.com/ejose19",
"contributions": [
"code"
]
},
{
"login": "maximeag",
"name": "Maxime",
"avatar_url": "https://avatars.githubusercontent.com/u/3855368?v=4",
"profile": "https://github.com/maximeag",
"contributions": [
"code"
]
},
{
"login": "dstala",
"name": "dstala",
"avatar_url": "https://avatars.githubusercontent.com/u/86527202?v=4",
"profile": "https://github.com/dstala",
"contributions": [
"code"
]
},
{
"login": "loftwah",
"name": "loftwah",
"avatar_url": "https://avatars.githubusercontent.com/u/19922556?v=4",
"profile": "https://github.com/loftwah",
"contributions": [
"code"
]
},
{
"login": "mrtngrsbch",
"name": "Martin Gersbach",
"avatar_url": "https://avatars.githubusercontent.com/u/693328?v=4",
"profile": "https://museosabiertos.org",
"contributions": [
"code"
]
},
{
"login": "ArjenR",
"name": "ArjenR",
"avatar_url": "https://avatars.githubusercontent.com/u/4269186?v=4",
"profile": "https://github.com/ArjenR",
"contributions": [
"code"
]
},
{
"login": "kunggom",
"name": "조진식 (Jo Jinsik)",
"avatar_url": "https://avatars.githubusercontent.com/u/32009637?v=4",
"profile": "https://github.com/kunggom",
"contributions": [
"code"
]
},
{
"login": "tianberg",
"name": "tianchunfeng",
"avatar_url": "https://avatars.githubusercontent.com/u/90968567?v=4",
"profile": "http://www.cuobiezi.net",
"contributions": [
"code"
]
},
{
"login": "cthulberg",
"name": "Andrea",
"avatar_url": "https://avatars.githubusercontent.com/u/5301275?v=4",
"profile": "https://github.com/cthulberg",
"contributions": [
"code"
]
},
{
"login": "eevleevs",
"name": "Giulio Malventi",
"avatar_url": "https://avatars.githubusercontent.com/u/5012744?v=4",
"profile": "https://github.com/eevleevs",
"contributions": [
"code"
]
},
{
"login": "dev-z",
"name": "Md. Ishtiaque Zafar",
"avatar_url": "https://avatars.githubusercontent.com/u/8604312?v=4",
"profile": "https://dev-z.github.io",
"contributions": [
"code"
]
},
{
"login": "ChasLui",
"name": "ChasLui",
"avatar_url": "https://avatars.githubusercontent.com/u/10083758?v=4",
"profile": "http://www.chaslui.com",
"contributions": [
"code"
]
},
{
"login": "ZhansayaM",
"name": "Zhansaya Maksut",
"avatar_url": "https://avatars.githubusercontent.com/u/41486762?v=4",
"profile": "https://www.linkedin.com/in/zhansayam/",
"contributions": [
"code"
]
},
{
"login": "agkfri",
"name": "agkfri",
"avatar_url": "https://avatars.githubusercontent.com/u/37952138?v=4",
"profile": "https://github.com/agkfri",
"contributions": [
"code"
]
},
{
"login": "iqiziqi",
"name": "Ziqi",
"avatar_url": "https://avatars.githubusercontent.com/u/8640316?v=4",
"profile": "https://github.com/iqiziqi",
"contributions": [
"code"
]
},
{
"login": "AllanSiqueira",
"name": "Allan Siqueira",
"avatar_url": "https://avatars.githubusercontent.com/u/14025084?v=4",
"profile": "https://github.com/AllanSiqueira",
"contributions": [
"code"
]
},
{
"login": "ahmadfatihin",
"name": "Fatih",
"avatar_url": "https://avatars.githubusercontent.com/u/54095238?v=4",
"profile": "https://creatify.my.id/",
"contributions": [
"code"
]
},
{
"login": "roman-rezinkin",
"name": "Roman Rezinkin",
"avatar_url": "https://avatars.githubusercontent.com/u/17882264?v=4",
"profile": "https://github.com/roman-rezinkin",
"contributions": [
"code"
]
},
{
"login": "fragalcer",
"name": "Francisco Gallardo",
"avatar_url": "https://avatars.githubusercontent.com/u/31025299?v=4",
"profile": "https://github.com/fragalcer",
"contributions": [
"code"
]
},
{
"login": "sesam",
"name": "Simon B.",
"avatar_url": "https://avatars.githubusercontent.com/u/8921?v=4",
"profile": "https://github.com/sesam",
"contributions": [
"code"
]
},
{
"login": "lielfr",
"name": "Liel Fridman",
"avatar_url": "https://avatars.githubusercontent.com/u/360928?v=4",
"profile": "https://github.com/lielfr",
"contributions": [
"code"
]
},
{
"login": "rubjo",
"name": "rubjo",
"avatar_url": "https://avatars.githubusercontent.com/u/42270947?v=4",
"profile": "https://github.com/rubjo",
"contributions": [
"code"
]
},
{
"login": "kinga-marszalkowska",
"name": "Kinga Marszałkowska",
"avatar_url": "https://avatars.githubusercontent.com/u/64398325?v=4",
"profile": "https://github.com/kinga-marszalkowska",
"contributions": [
"code"
]
},
{
"login": "dahawk",
"name": "Christof Horschitz",
"avatar_url": "https://avatars.githubusercontent.com/u/10920640?v=4",
"profile": "https://nimbusec.com",
"contributions": [
"code"
]
},
{
"login": "bebora",
"name": "Simone",
"avatar_url": "https://avatars.githubusercontent.com/u/32399075?v=4",
"profile": "https://github.com/bebora",
"contributions": [
"code"
]
},
{
"login": "tyonirwansyah",
"name": "Tyo Nirwansyah",
"avatar_url": "https://avatars.githubusercontent.com/u/73389687?v=4",
"profile": "https://github.com/tyonirwansyah",
"contributions": [
"code"
]
},
{
"login": "jiione",
"name": "jiwon",
"avatar_url": "https://avatars.githubusercontent.com/u/83341978?v=4",
"profile": "https://github.com/jiione",
"contributions": [
"code"
]
},
{
"login": "mikepsinn",
"name": "Mike P. Sinn",
"avatar_url": "https://avatars.githubusercontent.com/u/2808553?v=4",
"profile": "http://quantimo.do",
"contributions": [
"code"
]
},
{
"login": "candideu",
"name": "candideu",
"avatar_url": "https://avatars.githubusercontent.com/u/55474996?v=4",
"profile": "https://github.com/candideu",
"contributions": [
"code"
]
},
{
"login": "SiderealArt",
"name": "SiderealArt",
"avatar_url": "https://avatars.githubusercontent.com/u/30827929?v=4",
"profile": "http://siderealart.me",
"contributions": [
"code"
]
},
{
"login": "vijayrathore8492",
"name": "Vijay Rathore",
"avatar_url": "https://avatars.githubusercontent.com/u/17380265?v=4",
"profile": "http://vijayrathore.me",
"contributions": [
"code"
]
},
{
"login": "John-Appleseed",
"name": "John Appleseed",
"avatar_url": "https://avatars.githubusercontent.com/u/7055847?v=4",
"profile": "https://github.com/John-Appleseed",
"contributions": [
"code"
]
},
{
"login": "Korayem",
"name": "Salem Korayem",
"avatar_url": "https://avatars.githubusercontent.com/u/198332?v=4",
"profile": "https://github.com/Korayem",
"contributions": [
"code"
]
},
{
"login": "dubiao",
"name": "标",
"avatar_url": "https://avatars.githubusercontent.com/u/4001793?v=4",
"profile": "https://github.com/dubiao",
"contributions": [
"code"
]
},
{
"login": "willnewii",
"name": "诗人的咸鱼",
"avatar_url": "https://avatars.githubusercontent.com/u/652003?v=4",
"profile": "https://github.com/willnewii",
"contributions": [
"code"
]
},
{
"login": "bitbytejoy",
"name": "bitbytejoy",
"avatar_url": "https://avatars.githubusercontent.com/u/11807034?v=4",
"profile": "https://github.com/bitbytejoy",
"contributions": [
"code"
]
},
{
"login": "pan93412",
"name": "pan93412",
"avatar_url": "https://avatars.githubusercontent.com/u/28441561?v=4",
"profile": "http://blog.pan93.com",
"contributions": [
"code"
]
},
{
"login": "LancerComet",
"name": "LancerComet",
"avatar_url": "https://avatars.githubusercontent.com/u/10321350?v=4",
"profile": "https://github.com/LancerComet",
"contributions": [
"code"
]
},
{
"login": "mertmit",
"name": "mertmit",
"avatar_url": "https://avatars.githubusercontent.com/u/59797957?v=4",
"profile": "https://github.com/mertmit",
"contributions": [
"code"
]
},
{
"login": "atompi",
"name": "Atom Pi",
"avatar_url": "https://avatars.githubusercontent.com/u/6419682?v=4",
"profile": "https://blog.atompi.com",
"contributions": [
"code"
]
},
{
"login": "OskarsPakers",
"name": "Oskars",
"avatar_url": "https://avatars.githubusercontent.com/u/3343347?v=4",
"profile": "https://github.com/OskarsPakers",
"contributions": [
"code"
]
},
{
"login": "dolibit-ut",
"name": "UT from dolibit",
"avatar_url": "https://avatars.githubusercontent.com/u/45215329?v=4",
"profile": "http://dolibit.de",
"contributions": [
"code"
]
},
{
"login": "blucky",
"name": "Blucky",
"avatar_url": "https://avatars.githubusercontent.com/u/42397?v=4",
"profile": "https://github.com/blucky",
"contributions": [
"code"
]
},
{
"login": "TsjipTsjip",
"name": "TsjipTsjip",
"avatar_url": "https://avatars.githubusercontent.com/u/19798667?v=4",
"profile": "https://github.com/TsjipTsjip",
"contributions": [
"code"
]
},
{
"login": "dhrrgn",
"name": "Dan Horrigan",
"avatar_url": "https://avatars.githubusercontent.com/u/149921?v=4",
"profile": "https://github.com/dhrrgn",
"contributions": [
"code"
]
},
{
"login": "AmitJoki",
"name": "Amit Joki",
"avatar_url": "https://avatars.githubusercontent.com/u/5158554?v=4",
"profile": "https://amitjoki.github.io",
"contributions": [
"code"
]
},
{
"login": "tympaniplayer",
"name": "Nate",
"avatar_url": "https://avatars.githubusercontent.com/u/1745731?v=4",
"profile": "https://github.com/tympaniplayer",
"contributions": [
"code"
]
},
{
"login": "RobinFrcd",
"name": "Robin Fourcade",
"avatar_url": "https://avatars.githubusercontent.com/u/29704178?v=4",
"profile": "https://github.com/RobinFrcd",
"contributions": [
"code"
]
},
{
"login": "zprial",
"name": "zprial",
"avatar_url": "https://avatars.githubusercontent.com/u/33095380?v=4",
"profile": "https://github.com/zprial",
"contributions": [
"code"
]
},
{
"login": "nilsreichardt",
"name": "Nils Reichardt",
"avatar_url": "https://avatars.githubusercontent.com/u/24459435?v=4",
"profile": "https://github.com/nilsreichardt",
"contributions": [
"code"
]
},
{
"login": "iamnamananand996",
"name": "Naman Anand",
"avatar_url": "https://avatars.githubusercontent.com/u/31537362?v=4",
"profile": "https://github.com/iamnamananand996",
"contributions": [
"code"
]
},
{
"login": "GeoffMaciolek",
"name": "Geo Maciolek",
"avatar_url": "https://avatars.githubusercontent.com/u/10995633?v=4",
"profile": "https://github.com/GeoffMaciolek",
"contributions": [
"code"
]
},
{
"login": "mudream4869",
"name": "神楽坂帕琪",
"avatar_url": "https://avatars.githubusercontent.com/u/6008539?v=4",
"profile": "http://blog.mukyu.tw/",
"contributions": [
"code"
]
},
{
"login": "titouancreach",
"name": "Titouan CREACH",
"avatar_url": "https://avatars.githubusercontent.com/u/3995719?v=4",
"profile": "https://github.com/titouancreach",
"contributions": [
"code"
]
},
{
"login": "youyiio",
"name": "youyiio",
"avatar_url": "https://avatars.githubusercontent.com/u/49471274?v=4",
"profile": "https://www.youyi.io",
"contributions": [
"code"
]
},
{
"login": "RK311y",
"name": "River Kelly",
"avatar_url": "https://avatars.githubusercontent.com/u/65210753?v=4",
"profile": "https://github.com/RK311y",
"contributions": [
"code"
]
},
{
"login": "LepkoQQ",
"name": "LepkoQQ",
"avatar_url": "https://avatars.githubusercontent.com/u/2662937?v=4",
"profile": "https://github.com/LepkoQQ",
"contributions": [
"code"
]
},
{
"login": "QuentinDstl",
"name": "quentin",
"avatar_url": "https://avatars.githubusercontent.com/u/56829191?v=4",
"profile": "https://cornernewclub.fr",
"contributions": [
"code"
]
},
{
"login": "cande1gut",
"name": "Cande",
"avatar_url": "https://avatars.githubusercontent.com/u/5407915?v=4",
"profile": "http://cande.me",
"contributions": [
"code"
]
},
{
"login": "seokjunjin",
"name": "Seokjun Jin",
"avatar_url": "https://avatars.githubusercontent.com/u/46950889?v=4",
"profile": "https://github.com/seokjunjin",
"contributions": [
"translation"
]
},
{
"login": "systemctls",
"name": "jinxm",
"avatar_url": "https://avatars.githubusercontent.com/u/37177191?v=4",
"profile": "https://github.com/systemctls",
"contributions": [
"code"
]
},
{
"login": "yohanboniface",
"name": "Yohan Boniface",
"avatar_url": "https://avatars.githubusercontent.com/u/146023?v=4",
"profile": "https://yohanboniface.me",
"contributions": [
"translation"
]
},
{
"login": "drsantam",
"name": "Santam Chakraborty",
"avatar_url": "https://avatars.githubusercontent.com/u/10681456?v=4",
"profile": "https://github.com/drsantam",
"contributions": [
"translation"
]
},
{
"login": "eltociear",
"name": "Ikko Ashimine",
"avatar_url": "https://avatars.githubusercontent.com/u/22633385?v=4",
"profile": "https://bandism.net/",
"contributions": [
"code"
]
},
{
"login": "asheerrizvi",
"name": "Asheer Rizvi",
"avatar_url": "https://avatars.githubusercontent.com/u/17976252?v=4",
"profile": "http://asheerrizvi.com",
"contributions": [
"code"
]
},
{
"login": "dolsem",
"name": "Denis Olsem",
"avatar_url": "https://avatars.githubusercontent.com/u/14323955?v=4",
"profile": "https://github.com/dolsem",
"contributions": [
"code"
]
},
{
"login": "chetanverma16",
"name": "Chetan Verma",
"avatar_url": "https://avatars.githubusercontent.com/u/16558205?v=4",
"profile": "http://chetanverma.com/",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
"skipCi": true
}

0
.github/pull_request_template.md → .github/PULL_REQUEST_TEMPLATE.md

0
.github/sponsors.md → .github/SPONSORS.md

117
.github/workflows/ci-cd.yml

@ -59,7 +59,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -105,7 +105,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -151,7 +151,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -197,7 +197,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/restMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -243,7 +243,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restTableOps.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -289,7 +289,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restViews.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -335,7 +335,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restRoles.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -381,7 +381,7 @@ jobs:
start: |
npm run start:xcdb-api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/xcdb-restMisc.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -612,7 +612,7 @@ jobs:
cp ./scripts/cypress/fixtures/quickTest/noco_0_91_7.db ./packages/nocodb/noco.db
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/quickTest.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -707,7 +707,7 @@ jobs:
run: npm install
- name: setup mysql
working-directory: ./
run: docker-compose -f ./scripts/docker-compose-cypress.yml up -d
run: docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
- name: run unit tests
working-directory: ./packages/nocodb
run: npm run test:unit
@ -745,7 +745,7 @@ jobs:
start: |
npm run start:api:cache
npm run start:web
docker-compose -f ./scripts/docker-compose-cypress.yml up -d
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up -d
spec: "./scripts/cypress/integration/test/db-independent.js"
wait-on: "http://localhost:8080, http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png"
wait-on-timeout: 1200
@ -757,3 +757,98 @@ jobs:
name: cypress-restMisc-run-cache-snapshots
path: scripts/cypress/screenshots
retention-days: 2
playwright:
runs-on: ubuntu-20.04
if: ${{ github.event_name == 'push' || contains(github.event.pull_request.labels.*.name, 'trigger-CI') || !github.event.pull_request.draft }}
steps:
# Reference: https://github.com/pierotofy/set-swap-space/blob/master/action.yml
- name: Set 5gb swap
shell: bash
# Delete the swap file, allocate a new one, and activate it
run: |
export SWAP_FILE=$(swapon --show=NAME | tail -n 1)
sudo swapoff $SWAP_FILE
sudo rm $SWAP_FILE
sudo fallocate -l 5G $SWAP_FILE
sudo chmod 600 $SWAP_FILE
sudo mkswap $SWAP_FILE
sudo swapon $SWAP_FILE
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16.15.0
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Cache node modules
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: install dependencies nocodb-sdk
working-directory: ./packages/nocodb-sdk
run: npm install
- name: build nocodb-sdk
working-directory: ./packages/nocodb-sdk
run: npm run build
- name: Install dependencies
working-directory: ./packages/nocodb
run: npm install
- name: setup mysql
working-directory: ./
run: docker-compose -f ./scripts/playwright/scripts/docker-compose-playwright.yml up -d &
- name: run frontend
run: npm run start:web &
- name: Run backend
working-directory: ./packages/nocodb
run: npm run watch:run:playwright > mysql_test_backend.log &
- name: Cache playwright npm modules
uses: actions/cache@v3
id: playwright-cache
with:
path: |
**/playwright/node_modules
key: cache-playwright-${{ hashFiles('**/playwright/package-lock.json') }}
- name: Install dependencies
if: steps.playwright-cache.outputs.cache-hit != 'true'
working-directory: ./scripts/playwright
run: npm install
- name: Install Playwright Browsers
working-directory: ./scripts/playwright
run: npx playwright install chromium --with-deps
- name: Wait for frontend
run: |
while ! curl --output /dev/null --silent --head --fail http://localhost:3000/_nuxt/assets/img/icons/512x512-trans.png; do
printf '.'
sleep 2
done
- name: Wait for backend
run: |
while ! curl --output /dev/null --silent --head --fail http://localhost:8080; do
printf '.'
sleep 2
done
- name: Run Playwright tests
working-directory: ./scripts/playwright
run: npm run ci:test:mysql
- uses: actions/upload-artifact@v3
if: always()
with:
name: playwright-report
path: ./scripts/playwright/playwright-report/
retention-days: 2
- uses: actions/upload-artifact@v3
if: always()
with:
name: backend logs
path: ./packages/nocodb/mysql_test_backend.log
retention-days: 2

11
.github/workflows/release-executables.yml

@ -84,8 +84,15 @@ jobs:
# install npm dependendencies
npm i
# Copy sqlite binaries
rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/
# Build sqlite binaries for all platforms
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=ia32 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=arm64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=musl
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl
# clean up code to optimize size
npx modclean --patterns="default:*" --ignore="nc-lib-gui/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run

16
.github/workflows/release-timely-executables.yml

@ -86,7 +86,21 @@ jobs:
npm i
# Copy sqlite binaries
rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/
# rsync -rvzhP ./binaries/binding/ ./node_modules/sqlite3/lib/binding/
# Build sqlite binaries for all platforms
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --fallback-to-build --target_arch=ia32 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=x64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --fallback-to-build --target_arch=arm64 --target_libc=unknown
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=glibc
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=x64 --target_libc=musl
./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=arm64 --target_libc=musl
# ./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=armv6 --target_libc=unknown
# ./node_modules/.bin/node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --fallback-to-build --target_arch=armv7 --target_libc=unknown
# clean up code to optimize size
npx modclean --patterns="default:*" --ignore="nc-lib-gui-daily/**,dayjs/**,express-status-monitor/**,sqlite3/**" --run

1
.gitignore vendored

@ -93,3 +93,4 @@ shared.json
# NC_DBs
#=========
nc_minimal_dbs/
test_noco.db

4
.husky/pre-commit

@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
npx lint-staged

12
.run/test-debug.run.xml

@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test-debug" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/scripts/playwright/package.json" />
<command value="run" />
<scripts>
<script value="test-debug" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

12
.run/test.run.xml

@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="test" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/scripts/playwright/package.json" />
<command value="run" />
<scripts>
<script value="test" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

20
README.md

@ -45,20 +45,20 @@ Turns any MySQL, PostgreSQL, SQL Server, SQLite & MariaDB into a smart-spreadshe
<div align="center">
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263434-75fe793d-42af-49e4-b964-d70920e41655.png">](scripts/markdown/readme/languages/chinese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263474-787d71e7-3a87-42a8-92a8-be1d1f55413d.png">](scripts/markdown/readme/languages/french.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263531-fae58600-6616-4b43-95a0-5891019dd35d.png">](scripts/markdown/readme/languages/german.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263589-3dbeda9a-0d2e-4bbd-b1fc-691404bb74fb.png">](scripts/markdown/readme/languages/spanish.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263669-f567196a-d4e8-4143-a80a-93d3be32ba90.png">](scripts/markdown/readme/languages/portuguese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263707-ba4e04a4-268a-4626-91b8-048e572fd9f6.png">](scripts/markdown/readme/languages/italian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263770-38e3e79d-11d4-472e-ac27-ae0f17cf65c4.png">](scripts/markdown/readme/languages/japanese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263822-28fce9de-915a-44dc-962d-7a61d340e91d.png">](scripts/markdown/readme/languages/korean.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263888-151d4ad1-7084-4943-97c9-56f28cd40b80.png">](scripts/markdown/readme/languages/russian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263434-75fe793d-42af-49e4-b964-d70920e41655.png">](markdown/readme/languages/chinese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263474-787d71e7-3a87-42a8-92a8-be1d1f55413d.png">](markdown/readme/languages/french.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263531-fae58600-6616-4b43-95a0-5891019dd35d.png">](markdown/readme/languages/german.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263589-3dbeda9a-0d2e-4bbd-b1fc-691404bb74fb.png">](markdown/readme/languages/spanish.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263669-f567196a-d4e8-4143-a80a-93d3be32ba90.png">](markdown/readme/languages/portuguese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263707-ba4e04a4-268a-4626-91b8-048e572fd9f6.png">](markdown/readme/languages/italian.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263770-38e3e79d-11d4-472e-ac27-ae0f17cf65c4.png">](markdown/readme/languages/japanese.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263822-28fce9de-915a-44dc-962d-7a61d340e91d.png">](markdown/readme/languages/korean.md)
[<img height="38" src="https://user-images.githubusercontent.com/61551451/135263888-151d4ad1-7084-4943-97c9-56f28cd40b80.png">](markdown/readme/languages/russian.md)
</div>
<p align="center"><a href="scripts/markdown/readme/languages/README.md"><b>See other languages »</b></a></p>
<p align="center"><a href="markdown/readme/languages/README.md"><b>See other languages »</b></a></p>
<img src="https://static.scarf.sh/a.png?x-pxid=c12a77cc-855e-4602-8a0f-614b2d0da56a" />

42
Run.md

@ -1,42 +0,0 @@
# Setup
#### Setting up dev environment
- Clone `nocodb/nocodb` GitHub repo and checkout to `feat/v2` branch
```sh
git clone https://github.com/nocodb/nocodb
cd nocodb
```
- Navigate to `nocodb-sdk` package folder, install and build the package
```sh
cd packages/nocodb-sdk
npm install
npm run build
```
#### Running backend
```sh
# Navigate to `nocodb` package and install dependencies
cd packages/nocodb
npm install
# requires sqlite3
npm run watch:run
# if you have mysql on localhost (set its password as password)
# npm run watch:run:mysql
```
#### Running frontend
```sh
# Navigate to `nc-gui` package and install dependencies
cd packages/nc-gui
npm install
npm run dev
```

48
docker-compose/mssql/docker-compose.yml

@ -1,33 +1,31 @@
version: '2.4'
services:
root_db:
image: mcr.microsoft.com/mssql/server:2017-latest
version: "2.4"
services:
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "mssql://root_db:1433?u=sa&p=Password123.&d=root_db"
image: "nocodb/nocodb:latest"
ports:
- "8080:8080"
restart: always
volumes:
- db_data:/var/opt/mssql
environment:
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
ACCEPT_EULA: "Y"
SA_PASSWORD: Password123.
ACCEPT_EULA: Y
healthcheck:
test: /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P "$$SA_PASSWORD" -Q "SELECT 1" || exit 1
healthcheck:
interval: 10s
timeout: 3s
retries: 10
start_period: 10s
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
ports:
- "8080:8080"
test: "/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P \"$$SA_PASSWORD\" -Q \"SELECT 1\" || exit 1"
timeout: 3s
image: "mcr.microsoft.com/mssql/server:2017-latest"
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "mssql://root_db:1433?u=sa&p=Password123.&d=root_db"
volumes:
volumes:
- "db_data:/var/opt/mssql"
volumes:
db_data: {}
nc_data: {}

61
docker-compose/mysql/docker-compose.yml

@ -1,36 +1,39 @@
version: '2.1'
services:
root_db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
# below line shows how to change charset and collation
# uncomment it if necessary
# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
version: "2.1"
services:
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
image: "nocodb/nocodb:latest"
ports:
- "8080:8080"
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
MYSQL_DATABASE: root_db
MYSQL_USER: noco
MYSQL_PASSWORD: password
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: noco
healthcheck:
retries: 10
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
ports:
- "8080:8080"
test:
- CMD
- mysqladmin
- ping
- "-h"
- localhost
timeout: 20s
image: "mysql:5.7"
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
volumes:
volumes:
- "db_data:/var/lib/mysql"
# below line shows how to change charset and collation
# uncomment it if necessary
# command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
volumes:
db_data: {}
nc_data: {}

98
docker-compose/nginx-proxy-manager/docker-compose.yml

@ -1,58 +1,58 @@
version: '2.1'
services:
root_db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
MYSQL_DATABASE: root_db
MYSQL_USER: noco
MYSQL_PASSWORD: password
healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
timeout: 20s
retries: 10
networks:
- default
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
networks:
- default
- nginxproxy
nginx-proxy-manager:
image: jlesage/nginx-proxy-manager
restart: always
environment:
PUID: 1000
networks:
default: ~
nginxproxy: ~
services:
nginx-proxy-manager:
environment:
PGID: 1000
PUID: 1000
TZ: Europe/Amsterdam
ports:
image: jlesage/nginx-proxy-manager
networks:
- nginxproxy
ports:
- "8181:8181"
- "80:8080"
- "443:4443"
volumes:
- nginx-proxy-manager:/config:rw
networks:
restart: always
volumes:
- "nginx-proxy-manager:/config:rw"
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "mysql2://root_db:3306?u=noco&p=password&d=root_db"
image: "nocodb/nocodb:latest"
networks:
- default
- nginxproxy
volumes:
nginx-proxy-manager: {}
restart: always
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
MYSQL_DATABASE: root_db
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
MYSQL_USER: noco
healthcheck:
retries: 10
test:
- CMD
- mysqladmin
- ping
- "-h"
- localhost
timeout: 20s
image: "mysql:5.7"
networks:
- default
restart: always
volumes:
- "db_data:/var/lib/mysql"
volumes:
db_data: {}
nc_data: {}
networks:
default:
nginxproxy:
nginx-proxy-manager: {}

126
docker-compose/nginx/docker-compose.yml

@ -1,68 +1,66 @@
version: '3.9'
networks:
frontend:
external: false
backend:
external: false
version: "3.9"
networks:
backend:
external: false
frontend:
external: false
# This is an example setup with an Nginx reverse proxy.
# If you already have an Nginx reverse proxy running,
# then allow the docker-compose.yml to reference an external network that the reverse proxy container is on
# (in lieu of the frontend network in this file) and have the NocoDB container connect to it.
services:
reverse_proxy:
image: nginx:alpine
container_name: reverse_proxy
volumes:
- ./certbot:/etc/letsencrypt:ro # SSL certs
- ./nginx:/etc/nginx # Nginx config file
- path/to/webroot:/usr/share/nginx/html # Mount directory web site files for webroot certificate validation with Certbot
ports:
- 80:80
- 443:443
restart: unless-stopped
networks:
- frontend
certbot:
image: certbot/certbot
container_name: certbot
volumes:
- ./certbot:/etc/letsencrypt
- path/to/webroot:/var/www/html # For webroot certificate validation
depends_on:
- reverse_proxy
command: certonly --webroot --webroot-path=/var/www/html --email user@example.domain --agree-tos --no-eff-email -d example.domain,www.example.domain,nocodb.example.domain
nocodb_app:
image: nocodb/nocodb:latest
container_name: nocodb_app
restart: unless-stopped
volumes:
- ./nocodb/data:/usr/app/data
networks:
- backend
- frontend
environment:
NC_DB: mysql2://nocodb_database:3306?u=root&p=${MYSQL_ROOT_PASSWORD}&d=${MYSQL_DATABASE} # While it is not good practice to use the Root user, there were issues with granting privileges to a new user using the Linuxserver MariaDB image.
NC_PUBLIC_URL: ${NC_PUBLIC_URL}
NC_AUTH_JWT_SECRET: ${NC_AUTH_JWT_SECRET}
depends_on:
- nocodb_database
nocodb_database:
image: ghcr.io/linuxserver/mariadb:alpine # Using the non-official MariaDB image because it is an alpine distro and has a considerably smaller footprint.
container_name: nocodb_database
volumes:
- ./mariadb/config:/config
- ./mariadb/data:/var/lib/mysql
networks:
- backend
restart: always
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
services:
certbot:
command: "certonly --webroot --webroot-path=/var/www/html --email user@example.domain --agree-tos --no-eff-email -d example.domain,www.example.domain,nocodb.example.domain"
container_name: certbot
depends_on:
- reverse_proxy
image: certbot/certbot
volumes:
- "./certbot:/etc/letsencrypt"
- "path/to/webroot:/var/www/html" # For webroot certificate validation
nocodb_app:
container_name: nocodb_app
depends_on:
- nocodb_database
environment:
NC_AUTH_JWT_SECRET: "${NC_AUTH_JWT_SECRET}"
# while it is not good practice to use the Root user,
# there were issues with granting privileges to a new user using the Linux server MariaDB image.
NC_DB: "mysql2://nocodb_database:3306?u=root&p=${MYSQL_ROOT_PASSWORD}&d=${MYSQL_DATABASE}"
NC_PUBLIC_URL: "${NC_PUBLIC_URL}"
image: "nocodb/nocodb:latest"
networks:
- backend
- frontend
restart: unless-stopped
volumes:
- "./nocodb/data:/usr/app/data"
nocodb_database:
container_name: nocodb_database
environment:
- MYSQL_ROOT_PASSWORD
- MYSQL_DATABASE
- MYSQL_USER
- MYSQL_PASSWORD
# using the non-official MariaDB image
# because it is an alpine distro and has a considerably smaller footprint
image: "ghcr.io/linuxserver/mariadb:alpine"
networks:
- backend
restart: always
volumes:
- "./mariadb/config:/config"
- "./mariadb/data:/var/lib/mysql"
reverse_proxy:
container_name: reverse_proxy
image: "nginx:alpine"
networks:
- frontend
ports:
- "80:80"
- "443:443"
restart: unless-stopped
volumes:
- "./certbot:/etc/letsencrypt:ro" # SSL certs
- "./nginx:/etc/nginx" # Nginx config file
- "path/to/webroot:/usr/share/nginx/html" # Mount directory web site files for webroot certificate validation with Certbot

45
docker-compose/pg/docker-compose.yml

@ -1,32 +1,31 @@
version: '2.1'
services:
root_db:
image: postgres
services:
nocodb:
depends_on:
root_db:
condition: service_healthy
environment:
NC_DB: "pg://root_db:5432?u=postgres&p=password&d=root_db"
image: "nocodb/nocodb:latest"
ports:
- "8080:8080"
restart: always
volumes:
- db_data:/var/lib/postgresql/data
environment:
volumes:
- "nc_data:/usr/app/data"
root_db:
environment:
POSTGRES_DB: root_db
POSTGRES_PASSWORD: password
POSTGRES_USER: postgres
POSTGRES_DB: root_db
healthcheck:
test: pg_isready -U "$$POSTGRES_USER" -d "$$POSTGRES_DB"
healthcheck:
interval: 10s
timeout: 2s
retries: 10
nocodb:
depends_on:
root_db:
condition: service_healthy
image: nocodb/nocodb:latest
ports:
- "8080:8080"
test: "pg_isready -U \"$$POSTGRES_USER\" -d \"$$POSTGRES_DB\""
timeout: 2s
image: postgres
restart: always
volumes:
- nc_data:/usr/app/data
environment:
NC_DB: "pg://root_db:5432?u=postgres&p=password&d=root_db"
volumes:
volumes:
- "db_data:/var/lib/postgresql/data"
volumes:
db_data: {}
nc_data: {}

203
docker-compose/traefik/docker-compose.yml

@ -1,107 +1,102 @@
version: "3.7"
networks:
traefik_proxy:
name: traefik_proxy
volumes:
letsencrypt:
networks:
traefik_proxy:
name: traefik_proxy
services:
nocodb:
container_name: nocodb
depends_on:
- nocodb-db
environment:
- "NC_DB=pg://nocodb-db:5432?u=${DATABASE_USER}&p=${DATABASE_PW}&d=${DATABASE_NAME}"
- "NC_PUBLIC_URL=https://nocodb.${DOMAINNAME}"
- NC_DISABLE_TELE=true
image: "nocodb/nocodb:latest"
labels:
- traefik.enable=true
- traefik.http.services.nocodb.loadbalancer.server.port=8080
- "traefik.http.routers.nocodb.rule=Host(`nocodb.${DOMAINNAME}`)"
- traefik.http.routers.nocodb.entrypoints=https
- com.centurylinklabs.watchtower.enable=true
networks:
- traefik_proxy
restart: always
volumes:
- "nocodb-data:/usr/app/data"
nocodb-db:
container_name: nocodb-db
environment:
POSTGRES_DB: "${DATABASE_NAME}"
POSTGRES_PASSWORD: "${DATABASE_PW}"
POSTGRES_USER: "${DATABASE_USER}"
healthcheck:
interval: 10s
retries: 10
test: "pg_isready -U ${DATABASE_USER} -d ${DATABASE_NAME}"
timeout: 2s
image: "postgres:12.1-alpine"
networks:
- traefik_proxy
restart: always
volumes:
- "nocodb-db:/var/lib/postgresql/data"
traefik:
command:
- "--providers.docker=true"
- "--ping=true"
- "--ping.entryPoint=ping"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik_proxy"
- "--entryPoints.ping.address=:8081"
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certresolver=letsencrypt"
- "--entrypoints.https.http.tls.domains[0].main=${DOMAINNAME}"
- "--entrypoints.https.http.tls.domains[0].sans=*.${DOMAINNAME}"
- "--entrypoints.http.http.redirections.entryPoint.to=https"
- "--entrypoints.http.http.redirections.entryPoint.scheme=https"
- "--certificatesresolvers.letsencrypt.acme.dnsChallenge.delayBeforeCheck=15"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare"
- "--certificatesresolvers.letsencrypt.acme.email=info@${DOMAINNAME}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
- "--certificatesResolvers.letsencrypt.acme.dnsChallenge.resolvers=1.1.1.1:53,1.0.0.1:53"
container_name: traefik
environment:
- "CF_DNS_API_TOKEN=${CLOUDFLARE_TOKEN}"
healthcheck:
retries: 3
test:
- CMD
- wget
- "-c"
- "http://localhost:8081/ping"
timeout: 3s
image: "traefik:v2.2"
networks:
- default
- traefik_proxy
ports:
- "80:80"
- "443:443"
restart: always
volumes:
- "letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
watchtower:
command: "--schedule \"0 5 * * *\" --cleanup --label-enable"
container_name: watchtower
image: containrrr/watchtower
labels:
- com.centurylinklabs.watchtower.enable=true
networks:
- traefik_proxy
restart: always
volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro"
volumes:
letsencrypt:
name: traefik-letsencrypt
nocodb-db:
name: nocodb-db
nocodb-data:
nocodb-data:
name: nocodb-data
services:
traefik:
image: traefik:v2.2
container_name: traefik
restart: always
command:
#- "--log.level=DEBUG"
- "--providers.docker=true"
- "--ping=true"
- "--ping.entryPoint=ping"
- "--providers.docker.exposedbydefault=false"
- "--providers.docker.network=traefik_proxy"
- "--entryPoints.ping.address=:8081"
- "--entrypoints.http.address=:80"
- "--entrypoints.https.address=:443"
- "--entrypoints.https.http.tls.certresolver=letsencrypt"
- "--entrypoints.https.http.tls.domains[0].main=${DOMAINNAME}"
- "--entrypoints.https.http.tls.domains[0].sans=*.${DOMAINNAME}"
- "--entrypoints.http.http.redirections.entryPoint.to=https"
- "--entrypoints.http.http.redirections.entryPoint.scheme=https"
- "--certificatesresolvers.letsencrypt.acme.dnsChallenge.delayBeforeCheck=15"
- "--certificatesresolvers.letsencrypt.acme.dnschallenge.provider=cloudflare"
- "--certificatesresolvers.letsencrypt.acme.email=info@${DOMAINNAME}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
- "--certificatesResolvers.letsencrypt.acme.dnsChallenge.resolvers=1.1.1.1:53,1.0.0.1:53"
environment:
- CF_DNS_API_TOKEN=${CLOUDFLARE_TOKEN}
healthcheck:
test: ["CMD", "wget", "-c", "http://localhost:8081/ping"]
timeout: 3s
retries: 3
networks:
- default
- traefik_proxy
ports:
- "80:80"
- "443:443"
volumes:
- "letsencrypt:/letsencrypt"
- /var/run/docker.sock:/var/run/docker.sock:ro
watchtower:
image: containrrr/watchtower
container_name: watchtower
restart: always
networks:
- traefik_proxy
command: --schedule "0 5 * * *" --cleanup --label-enable
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
labels:
- "com.centurylinklabs.watchtower.enable=true"
nocodb:
container_name: nocodb
image: nocodb/nocodb:latest
restart: always
volumes:
- nocodb-data:/usr/app/data
networks:
- traefik_proxy
environment:
- NC_DB=pg://nocodb-db:5432?u=${DATABASE_USER}&p=${DATABASE_PW}&d=${DATABASE_NAME}
- NC_PUBLIC_URL=https://nocodb.${DOMAINNAME}
- NC_DISABLE_TELE=true
labels:
- "traefik.enable=true"
- "traefik.http.services.nocodb.loadbalancer.server.port=8080"
- "traefik.http.routers.nocodb.rule=Host(`nocodb.${DOMAINNAME}`)"
- "traefik.http.routers.nocodb.entrypoints=https"
- "com.centurylinklabs.watchtower.enable=true"
depends_on:
- nocodb-db
nocodb-db:
image: postgres:12.1-alpine
container_name: nocodb-db
restart: always
networks:
- traefik_proxy
environment:
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PW}
POSTGRES_DB: ${DATABASE_NAME}
volumes:
- nocodb-db:/var/lib/postgresql/data
healthcheck:
test: pg_isready -U ${DATABASE_USER} -d ${DATABASE_NAME}
interval: 10s
timeout: 2s
retries: 10
nocodb-db:
name: nocodb-db

0
scripts/markdown/plugins/google-auth.md → markdown/plugins/google-auth.md

0
scripts/markdown/plugins/s3.md → markdown/plugins/s3.md

0
scripts/markdown/readme/languages/README.md → markdown/readme/languages/README.md

2
scripts/markdown/readme/languages/chinese.md → markdown/readme/languages/chinese.md

@ -262,7 +262,7 @@ npm run dev
npm install
# 使用 docker compose 运行带有所需数据库的 mysql 数据库
docker-compose -f ./scripts/docker-compose-cypress.yml up
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up
# 使用以下命令运行后端 api
npm run start:api

0
scripts/markdown/readme/languages/dutch.md → markdown/readme/languages/dutch.md

0
scripts/markdown/readme/languages/french.md → markdown/readme/languages/french.md

2
scripts/markdown/readme/languages/german.md → markdown/readme/languages/german.md

@ -244,7 +244,7 @@ npm run dev
npm install
# MySQL-Datenbank mit der benötigten Datenbank mit Docker Compose ausführen
docker-compose -f ./scripts/docker-compose-cypress.yml up
docker-compose -f ./scripts/cypress/docker-compose-cypress.yml up
# Backend API mit folgendem Befehl ausführen
npm run start:api

0
scripts/markdown/readme/languages/indonesian.md → markdown/readme/languages/indonesian.md

0
scripts/markdown/readme/languages/italian.md → markdown/readme/languages/italian.md

0
scripts/markdown/readme/languages/japanese.md → markdown/readme/languages/japanese.md

0
scripts/markdown/readme/languages/korean.md → markdown/readme/languages/korean.md

0
scripts/markdown/readme/languages/portuguese.md → markdown/readme/languages/portuguese.md

0
scripts/markdown/readme/languages/russian.md → markdown/readme/languages/russian.md

0
scripts/markdown/readme/languages/spanish.md → markdown/readme/languages/spanish.md

1814
package-lock.json generated

File diff suppressed because it is too large Load Diff

40
package.json

@ -1,32 +1,51 @@
{
"name": "root",
"name": "nocodb-root",
"description": "NocoDB Root",
"private": true,
"author": {
"name": "NocoDB Inc",
"url": "https://nocodb.com/"
},
"homepage": "https://github.com/nocodb/nocodb",
"repository": {
"type": "git",
"url": "https://github.com/nocodb/nocodb.git"
},
"bugs": {
"url": "https://github.com/nocodb/nocodb/issues"
},
"license": "AGPL-3.0-or-later",
"devDependencies": {
"@4tw/cypress-drag-drop": "^2.0.0",
"cross-env": "^7.0.3",
"cypress": "^9.2.0",
"cypress-file-upload": "^5.0.8",
"cypress-iframe": "^1.0.1",
"fs": "0.0.1-security",
"jsdoc-to-markdown": "^5.0.3",
"lerna": "^3.20.1",
"scriptjs": "^2.5.9",
"husky": "^8.0.0",
"xlsx": "^0.17.4"
},
"husky": {
"hooks": {
"pre-commit": "npx lint-staged"
}
},
"lint-staged": {
"scripts/playwright/**/*.{ts,tsx,js,json}": [
"npm run lint:staged:playwright"
]
},
"scripts": {
"lint:staged:playwright": "cd scripts/playwright; npx lint-staged; cd ..",
"build:common": "cd ./packages/nocodb-sdk; npm install; npm run build",
"install:common": "cd ./packages/nocodb; npm install ../nocodb-sdk; cd ../nc-gui; npm install ../nocodb-sdk",
"start:api": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true npm run watch:run:cypress",
"start:xcdb-api-v1-backup": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk;npm install; NC_DISABLE_CACHE=true NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:xcdb-api": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk;npm install; NC_EXPORT_MAX_TIMEOUT=60000 NC_DISABLE_CACHE=true NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:api:cache": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk;npm install; NC_EXPORT_MAX_TIMEOUT=60000 NC_DISABLE_TELE=true npm run watch:run:cypress",
"start:api:cache:pg": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_TELE=true npm run watch:run:cypress:pg",
"start:api:cache:pg:cyquick": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_TELE=true npm run watch:run:cypress:pg:cyquick",
"start:xcdb-api:cache-v1-backup": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:xcdb-api:cache": "npm run build:common ; cd ./packages/nocodb; npm install ../nocodb-sdk; npm install; NC_EXPORT_MAX_TIMEOUT=60000 NC_DISABLE_TELE=true NC_INFLECTION=camelize DATABASE_URL=sqlite:../../../scripts/cypress/fixtures/sqlite-sakila/sakila.db npm run watch:run:cypress",
"start:web-v1-backup": "npm run build:common ; cd ./packages/nc-gui; npm install ../nocodb-sdk; npm install; npm run dev",
"start:web": "npm run build:common ; cd ./packages/nc-gui; npm install ../nocodb-sdk; npm install; ANT_MESSAGE_DURATION=0.5 npm run dev",
"cypress-v1-backup:run": "cypress run --config-file ./scripts/cypress/cypress.json",
"cypress-v1-backup:open": "cypress open --config-file ./scripts/cypress/cypress.json",
"cypress:run": "cypress run --config-file ./scripts/cypress/cypress.json",
"cypress:open": "cypress open --config-file ./scripts/cypress/cypress.json",
"cypress:clear": "cypress cache clear",
@ -37,7 +56,8 @@
"install:local:dep": "cd packages/nc-lib-gui;npm uninstall -S xc-lib;rm package-lock.json; npm i ../../../xc-lib-private; cd ../xc-instant;npm uninstall -S xc-lib xc-lib-gui;npm i ../../../xc-lib-private;npm i ../xc-lib-gui",
"install:npm:dep": "cd packages/nc-lib-gui;npm uninstall -S xc-lib; npm i -S xc-lib@latest; cd ../xc-instant;npm uninstall -S xc-lib xc-lib-gui;npm i -S xc-lib@latest xc-lib-gui@latest;npm i ../xc-lib-gui",
"start:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml up -d",
"stop:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml down"
"stop:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml down",
"prepare": "husky install"
},
"dependencies": {
"express": "^4.18.1",

682
packages/nc-cli/LICENSE

@ -1,21 +1,661 @@
MIT License
Copyright (c) 2021 nocodb
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

1
packages/nc-cli/README.md

@ -1,2 +1,3 @@
# nc-cli
Create a NocoDB Application with CLI

1321
packages/nc-cli/package-lock.json generated

File diff suppressed because it is too large Load Diff

24
packages/nc-cli/package.json

@ -1,11 +1,23 @@
{
"name": "create-nocodb-app",
"version": "0.1.28",
"description": "nc-cli",
"description": "Create NocoDB app using CLI",
"private": true,
"author": {
"name": "NocoDB Inc",
"url": "https://nocodb.com/"
},
"homepage": "https://github.com/nocodb/nocodb",
"repository": {
"type": "git",
"url": "https://github.com/nocodb/nocodb.git"
},
"bugs": {
"url": "https://github.com/nocodb/nocodb/issues"
},
"license": "AGPL-3.0-or-later",
"main": "dist/bundle.js",
"module": "dist/bundle.js",
"repository": "https://github.com/nocodb/nocodb/blob/master/packages/nc-cli",
"license": "MIT",
"keywords": [],
"bin": {
"noco": "./dist/bundle.js",
@ -75,7 +87,6 @@
"ora": "^4.0.5",
"os-locale": "^5.0.0",
"pg": "^8.3.2",
"sha.js": "^2.4.11",
"shelljs": "^0.8.4",
"tcp-port-used": "^1.0.1",
"unique-names-generator": "^4.5.0",
@ -84,15 +95,12 @@
"yargs": "^15.4.1"
},
"devDependencies": {
"@bitjson/npm-scripts-info": "^1.0.0",
"@bitjson/typedoc": "^0.15.0-0",
"@istanbuljs/nyc-config-typescript": "^0.1.3",
"ava": "2.2.0",
"codecov": "^3.5.0",
"copy-webpack-plugin": "^7.0.0",
"cz-conventional-changelog": "^2.1.0",
"gh-pages": "^2.0.1",
"javascript-obfuscator": "^2.6.0",
"npm-run-all": "^4.1.5",
"nyc": "^14.1.1",
"open-cli": "^5.0.0",
@ -106,7 +114,7 @@
"tslint-immutable": "^6.0.1",
"typescript": "^3.5.3",
"webpack": "^5.1.0",
"webpack-cli": "^4.0.0",
"webpack-cli": "^4.10.0",
"webpack-node-externals": "^2.5.2"
},
"ava": {

34
packages/nc-cli/src/index.ts

@ -6,48 +6,54 @@ import Util from './lib/util/Util';
import updateNotifier from 'update-notifier';
// tslint:disable-next-line:no-var-requires
const pkg = require('../package.json');
import yargs from 'yargs';
const {uniqueNamesGenerator, starWars, adjectives, animals} = require('unique-names-generator');
const {
uniqueNamesGenerator,
starWars,
adjectives,
animals
} = require('unique-names-generator');
/* get cli args */
const args = yargs
.alias('u', 'url')
.alias('m', 'module')
.alias('n', 'nomodel')
.help('help')
.argv;
.help('help').argv;
/* cwd is reference to all commands */
args.folder = process.cwd();
/* handle command */
(async () => {
// Checks for available update and returns an instance
const notifier = updateNotifier({ pkg });
// Checks for available update and returns an instance
const notifier = updateNotifier({pkg});
// Notify using the built-in convenience method
// Notify using the built-in convenience method
notifier.notify();
if (args._) {
if (!args._.length) {
await SocialMgr.showPrompt();
args._.unshift(uniqueNamesGenerator({
dictionaries: [[starWars], [adjectives, animals]][Math.floor(Math.random() * 2)]
}).toLowerCase().replace(/[ -]/g, '_'));
args._.unshift(
uniqueNamesGenerator({
dictionaries: [[starWars], [adjectives, animals]][
Math.floor(Math.random() * 2)
]
})
.toLowerCase()
.replace(/[ -]/g, '_')
);
}
await CliMgr.process(args);
} else {
Util.showHelp(args);
process.exit(0)
process.exit(0);
}
})().catch(err => {
console.error('\n\nThere was an error processing command:');
console.error(err);
});

19
packages/nc-cli/src/lib/CliMgr.ts

@ -12,14 +12,13 @@ import client from './mgr/Client';
// import PermissionsMgr from './mgr/PermissionsMgr';
// import SocialMgr from './mgr/SocialMgr';
// import DockerMgr from "./mgr/DockerMgr";
import NewMgr from "./mgr/NewMgr";
import NewMgr from './mgr/NewMgr';
// import TryMgr from "./mgr/TryMgr";
let cmdProcessedOnce = 0;
let cmdOriginalArgs = null;
class CliMgr {
public static async runCmd(str) {
shell.echo(`\nNow, executing command : ${str}\n\n`.blue);
if (shell.exec(str).code !== 0) {
@ -30,13 +29,11 @@ class CliMgr {
}
public static async process(args) {
cmdOriginalArgs = cmdOriginalArgs ? cmdOriginalArgs : args;
try {
if (args._ && args._.length) {
switch (args._[0]) {
case 'man':
if (args._.length > 1) {
Util.showHelpForCommand(args);
@ -53,11 +50,11 @@ class CliMgr {
if (await NewMgr.getNewProjectInput(args)) {
if (args._[0] === 'gap') {
console.log('gRPC code generation is not yet supported.');
process.exit(0)
process.exit(0);
}
await client.requestSend(args)
await client.requestSend(args);
} else {
process.exit(0)
process.exit(0);
}
break;
@ -405,7 +402,6 @@ class CliMgr {
// process.exit(0)
// break;
default:
if (!cmdProcessedOnce) {
cmdProcessedOnce = 1;
@ -413,9 +409,11 @@ class CliMgr {
args._.unshift('new');
await this.process(args);
} else {
console.log(`\nUnknown command. ${cmdOriginalArgs._[0]} -- please see help below`);
console.log(
`\nUnknown command. ${cmdOriginalArgs._[0]} -- please see help below`
);
Util.showHelp(cmdOriginalArgs);
process.exit(0)
process.exit(0);
}
break;
}
@ -427,4 +425,3 @@ class CliMgr {
}
export default CliMgr;

79
packages/nc-cli/src/lib/mgr/AppMgr.ts

@ -11,11 +11,14 @@ import('colors');
const PROGRESS_WIDTH = 30;
class AppMgr {
public static async install(args) {
try {
const spinner = ora({text: 'Downloading Desktop App from Github..'.green.bold(), spinner: 'dots2', color: 'green'}).start();
const {src, dest} = await AppMgr.getDownloadLink(args);
const spinner = ora({
text: 'Downloading Desktop App from Github..'.green.bold(),
spinner: 'dots2',
color: 'green'
}).start();
const { src, dest } = await AppMgr.getDownloadLink(args);
console.log(`\t${src}`);
@ -23,20 +26,25 @@ class AppMgr {
// console.log(progress)
// Report download progress
const p = PROGRESS_WIDTH * progress.percent;
spinner.text = `Downloading Desktop App now..\n[${
Array.from({length: PROGRESS_WIDTH}, (_, i) => i <= p ? '=' : ' ').join('')
}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(progress.total / (1024 * 1024)).toFixed(2)}MB\n`.green.bold()
spinner.text = `Downloading Desktop App now..\n[${Array.from(
{ length: PROGRESS_WIDTH },
(_, i) => (i <= p ? '=' : ' ')
).join('')}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(
progress.total /
(1024 * 1024)
).toFixed(2)}MB\n`.green.bold();
});
// spinner.prefixText = '';
spinner.succeed(`Installable downloaded successfully at ./${dest}`.green.bold());
spinner.succeed(
`Installable downloaded successfully at ./${dest}`.green.bold()
);
console.log(`\nInstallable will open automatically now.`.green.bold);
console.log(`If not, please install it manually.`.green.bold);
if (os.type() === 'Windows_NT') {
// open(dest, {wait: true, app: 'explorer.exe'})
} else {
open(dest, {wait: true});
open(dest, { wait: true });
}
} catch (e) {
console.error(`Error in xc app.install`, e);
}
@ -45,7 +53,9 @@ class AppMgr {
public static async open(args) {
try {
const runCommand = AppMgr.getOpenCommand(args);
if (!runCommand) { return }
if (!runCommand) {
return;
}
if (shell.exec(runCommand).code !== 0) {
shell.echo(`\n\nError running command internally`.red);
shell.echo(`\nExiting...`.red);
@ -56,20 +66,27 @@ class AppMgr {
}
}
public static async getDownloadLink(args):Promise<any> {
public static async getDownloadLink(args): Promise<any> {
try {
let src;
let dest;
const urls:any = {};
const urls: any = {};
const res = await axios.get('https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1')
const res = await axios.get(
'https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1'
);
let status = 0;
for (let i = 0; i < res.data.length && status !== 15; i++) {
const assets = res.data[i].assets;
for (const {name, browser_download_url} of assets) {
switch (name.split('.').pop().toLowerCase()) {
for (const { name, browser_download_url } of assets) {
switch (
name
.split('.')
.pop()
.toLowerCase()
) {
case 'dmg':
urls.dmg = urls.dmg || browser_download_url;
status = status | 1;
@ -92,22 +109,24 @@ class AppMgr {
switch (os.type()) {
case 'Linux':
const linuxInfo = osInfo({mode: 'sync'});
if (args.debian) { src = urls.deb; }
else if (args.rpm) { src = urls.rpm; }
else {
const linuxInfo = osInfo({ mode: 'sync' });
if (args.debian) {
src = urls.deb;
} else if (args.rpm) {
src = urls.rpm;
} else {
switch (linuxInfo.id) {
case 'ubuntu':
case 'raspberry':
src = urls.deb
src = urls.deb;
break;
case 'fedora':
src = urls.rpm
src = urls.rpm;
break;
default:
src = urls.rpm
src = urls.rpm;
}
}
}
break;
case 'Darwin':
src = urls.dmg;
@ -120,22 +139,22 @@ class AppMgr {
}
dest = src.split('/').pop();
return {src, dest}
return { src, dest };
} catch (e) {
console.log(e)
console.log(e);
}
}
public static getOpenCommand(_args):any {
public static getOpenCommand(_args): any {
switch (os.type()) {
case 'Linux':
return 'xgenecloud'
return 'xgenecloud';
break;
case 'Darwin':
return 'open -a xgenecloud'
return 'open -a xgenecloud';
break;
case 'Windows_NT':
console.info('Open xgenecloud desktop app from Windows start menu')
console.info('Open xgenecloud desktop app from Windows start menu');
break;
default:
@ -144,6 +163,4 @@ class AppMgr {
}
}
export default AppMgr;

49
packages/nc-cli/src/lib/mgr/Client.ts

@ -9,18 +9,11 @@ import shell from 'shelljs';
// import {CmdSocketServer} from 'nc-help';
// import SocialMgr from './SocialMgr';
class Client {
public static async requestSend(_args) {
try {
// await CmdSocketServer.cmdHandler(null, null, args);
// const portOpen = await tcpPortUsed.check(config.port, 'localhost');
// if (portOpen) {
//
// // client.emit('__REQUEST__', args);
@ -28,7 +21,6 @@ class Client {
// await promprRunOrDownload.handle(args)
// process.exit(0);
// }
} catch (e) {
console.log('Error generating code.', e.message);
throw e;
@ -37,7 +29,6 @@ class Client {
}
public static async runCmd(str): Promise<any> {
shell.echo(`\nNow, executing command : ${str}\n\n`.blue);
const code = shell.exec(str).code;
if (code !== 0) {
@ -45,16 +36,12 @@ class Client {
// shell.echo(`\nExiting...`.red);
shell.exit(1);
}
return 0
return 0;
}
public static async responseHandle(args) {
try {
switch (args._[0]) {
case 'ga':
case 'gar':
case 'gen.apis':
@ -65,19 +52,29 @@ class Client {
if (!args.err) {
// SocialMgr.setCreatedApis(true)
if (os.type() === 'Windows_NT') {
console.log(boxen(`# APIs generated successfully\n\n# Please run the following commands\n${('cd ' + path.dirname(args.folder) + '; npm install ; npm run dev\n').green.bold}`, {
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any));
console.log(
boxen(
`# APIs generated successfully\n\n# Please run the following commands\n${
(
'cd ' +
path.dirname(args.folder) +
'; npm install ; npm run dev\n'
).green.bold
}`,
{
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any
)
);
} else {
await Client.runCmd(`npm install; npm run dev;`);
}
}
break;
case 'gc':
case 'gen.controller':
break;
@ -123,10 +120,10 @@ class Client {
case 'm':
break;
case 'db.migrate.sql.dump' :
case 'dmm' :
case 'dmmd' :
console.log('db.migrate.sql.dump finished')
case 'db.migrate.sql.dump':
case 'dmm':
case 'dmmd':
console.log('db.migrate.sql.dump finished');
break;
default:
@ -136,7 +133,6 @@ class Client {
throw e;
}
}
}
//
@ -162,4 +158,3 @@ class Client {
//
export default Client;

38
packages/nc-cli/src/lib/mgr/ComponentMgr.ts

@ -2,36 +2,30 @@ import inquirer from 'inquirer';
import path from 'path';
class ComponentMgr {
public static async add(_args) {
const components = require(path.join(process.cwd(), './server/app.components.js'))
const answer = await inquirer
.prompt([
{
choices: components.components.map(component => component.title),
message: 'Choose after which component should we insert the new component?',
name: 'compoonent',
type: 'list'
}
])
const components = require(path.join(
process.cwd(),
'./server/app.components.js'
));
const answer = await inquirer.prompt([
{
choices: components.components.map(component => component.title),
message:
'Choose after which component should we insert the new component?',
name: 'compoonent',
type: 'list'
}
]);
return answer.compoonent;
}
// tslint:disable-next-line:no-empty
public static async rename(_args) {
}
public static async rename(_args) {}
// tslint:disable-next-line:no-empty
public static async delete(_args) {
}
public static async delete(_args) {}
}
export default ComponentMgr;

26
packages/nc-cli/src/lib/mgr/DockerMgr.ts

@ -1,23 +1,21 @@
import NewMgr from "./NewMgr";
import NewMgr from './NewMgr';
import('colors');
import fs from 'fs';
import path from 'path';
class DockerMgr extends NewMgr {
public static async genDockerfile(args: any) {
const dockerFilePath = path.join(process.cwd(), 'Dockerfile');
try {
args._.push('placeholder')
if(await this.getNewProjectInput(args)) {
args._.push('placeholder');
if (await this.getNewProjectInput(args)) {
const dockerfileContent = this.getDockerfileContent(args);
fs.writeFileSync(dockerFilePath, dockerfileContent);
console.log(`Docker file created successfully`.green.bold)
console.log(`\tFile location : ${dockerFilePath}`.green)
console.log(`\tdocker build . -t xc`.green.bold)
}else{
console.log(`Docker file created successfully`.green.bold);
console.log(`\tFile location : ${dockerFilePath}`.green);
console.log(`\tdocker build . -t xc`.green.bold);
} else {
// console.log('Database connection failed')
}
} catch (e) {
@ -31,14 +29,12 @@ class DockerMgr extends NewMgr {
ENV PORT 8080
ENV NODE_ENV=dev
ENV TOOL_DIR=/tool
${
args.url.map((url, i) => `ENV DB_URL${i > 0 ? i + 1 : ''}=${url}`).join('\r\n')
}
${args.url
.map((url, i) => `ENV DB_URL${i > 0 ? i + 1 : ''}=${url}`)
.join('\r\n')}
`
`;
}
}
export default DockerMgr;

23
packages/nc-cli/src/lib/mgr/InstantMgr.ts

@ -4,7 +4,7 @@
// import path from 'path';
// import URL from 'url';
import express from 'express';
import {XcApis, XcConfigFactory,} from "xc-instant";
import { XcApis, XcConfigFactory } from 'xc-instant';
import('colors');
@ -42,28 +42,28 @@ import('colors');
// };
class InstantMgr {
public static async getNewProjectInput(args): Promise<any> {
if (args._.length < 2) {
const usage = '\n$ xc instant "mysql://localhost:3306?u=root&p=password&d=database&a=rest"'.green.bold
console.log(`\n\nWarning! missing connection URL\n\nExample Usage:\n${usage}\n`.red.bold);
const usage = '\n$ xc instant "mysql://localhost:3306?u=root&p=password&d=database&a=rest"'
.green.bold;
console.log(
`\n\nWarning! missing connection URL\n\nExample Usage:\n${usage}\n`.red
.bold
);
return false;
}
const config = XcConfigFactory.makeFromUrls(args._.slice(1))
const config = XcConfigFactory.makeFromUrls(args._.slice(1));
const server = express();
server.set('view engine', 'ejs');
const app = new XcApis(config)
const app = new XcApis(config);
server.use(await app.init());
server.listen('8080', () => console.log('App started'));
// /* Construct database URL from prompt */
// const dbTypes = Object.keys(dbDefaults);
// args.url = []
@ -210,10 +210,8 @@ class InstantMgr {
// args._[0] = answers.projectType === 'REST APIs' ? 'gar' : 'gag';
// args.url.push(url);
// return NewMgr.testConnection(args)
}
// public static async testConnection({url}) {
//
// for (const u of url) {
@ -243,7 +241,6 @@ class InstantMgr {
// return true;
// }
// public static async isPortOpen(host, port) {
// try {
// return await tcpPortUsed.check(+port, host)
@ -253,8 +250,6 @@ class InstantMgr {
// return true;
// }
// }
}
export default InstantMgr;

52
packages/nc-cli/src/lib/mgr/MigrationMgr.ts

@ -1,15 +1,14 @@
import {Migrator} from 'xc-migrator-ts';
const migrator = new Migrator()
import { Migrator } from 'xc-migrator-ts';
const migrator = new Migrator();
class MigrationMgr {
public static _getFolder(args) {
args.folder = args.folder || process.cwd();
}
public static async init(args) {
try {
args.type = args.type || "mysql";
args.type = args.type || 'mysql';
await migrator.init(args);
} catch (e) {
console.log('db.migrate.init : Error occured', e);
@ -27,9 +26,9 @@ class MigrationMgr {
public static async create(args) {
try {
this._getFolder(args)
this._getFolder(args);
await migrator.migrationsCreate({
dbAlias: args.dbAlias || "primary",
dbAlias: args.dbAlias || 'primary',
folder: args.folder
});
} catch (e) {
@ -38,10 +37,8 @@ class MigrationMgr {
}
public static async up(args) {
try {
this._getFolder(args)
this._getFolder(args);
let migrationSteps = args.steps || 9999;
@ -49,27 +46,24 @@ class MigrationMgr {
migrationSteps = 0;
}
const migratorInst = new Migrator()
const migratorInst = new Migrator();
await migratorInst.migrationsUp({
dbAlias: args.dbAlias || "primary",
env: args.env || "dev",
dbAlias: args.dbAlias || 'primary',
env: args.env || 'dev',
file: args.file || null,
folder: args.folder,
migrationSteps,
onlyList: args.list,
sqlContentMigrate: (+args.sqlContentMigrate === 0 ? 0 : 1)
sqlContentMigrate: +args.sqlContentMigrate === 0 ? 0 : 1
});
} catch (e) {
console.log('db.migrate.up : Error occured', e);
}
}
public static async down(args) {
try {
this._getFolder(args)
this._getFolder(args);
let migrationSteps = args.steps || 9999;
@ -78,25 +72,22 @@ class MigrationMgr {
}
await migrator.migrationsDown({
dbAlias: args.dbAlias || "primary",
env: args.env || "dev",
dbAlias: args.dbAlias || 'primary',
env: args.env || 'dev',
file: args.file || null,
folder: args.folder,
migrationSteps,
onlyList: args.list,
sqlContentMigrate: (+args.sqlContentMigrate === 0 ? 0 : 1)
sqlContentMigrate: +args.sqlContentMigrate === 0 ? 0 : 1
});
} catch (e) {
console.log('db.migrate.down : Error occured', e);
}
}
public static async list(args) {
try {
this._getFolder(args)
this._getFolder(args);
let migrationSteps = args.steps || 9999;
@ -105,8 +96,8 @@ class MigrationMgr {
}
const data = await migrator.migrationsUp({
dbAlias: args.dbAlias || "primary",
env: args.env || "dev",
dbAlias: args.dbAlias || 'primary',
env: args.env || 'dev',
file: args.file || null,
folder: args.folder,
migrationSteps,
@ -114,25 +105,20 @@ class MigrationMgr {
});
console.log(data.data.object.list);
} catch (e) {
console.log('db.migrate.up : Error occured', e);
}
}
public static async clean(args) {
try {
args.type = args.type || "mysql";
args.type = args.type || 'mysql';
await migrator.clean(args);
} catch (e) {
console.log('db.migrate.clean : Error occured', e);
}
}
}
// expose class
export default MigrationMgr;
export default MigrationMgr;

44
packages/nc-cli/src/lib/mgr/ModelMgr.ts

@ -3,8 +3,6 @@ import glob from 'glob';
import path from 'path';
class ModelMgr {
/***
*
* @param args
@ -18,25 +16,43 @@ class ModelMgr {
args.dbAlias = args.dbAlias || '*';
if (args.models) {
for (const model of args.models.split('.')) {
for (const file of glob.sync(path.join(args.folder, 'server', 'models', args.dbAlias,model, `${model}.meta.*.js`))) {
await fsExtra.remove(file)
console.log(`Removed successfully : ${path.basename(file)}`.green.bold)
for (const file of glob.sync(
path.join(
args.folder,
'server',
'models',
args.dbAlias,
model,
`${model}.meta.*.js`
)
)) {
await fsExtra.remove(file);
console.log(
`Removed successfully : ${path.basename(file)}`.green.bold
);
}
}
} else {
for (const file of glob.sync(path.join(args.folder, 'server', 'models', args.dbAlias, '*', '*.meta.*.js'))) {
await fsExtra.remove(file)
console.log(`Removed successfully : ${path.basename(file)}`.green.bold)
for (const file of glob.sync(
path.join(
args.folder,
'server',
'models',
args.dbAlias,
'*',
'*.meta.*.js'
)
)) {
await fsExtra.remove(file);
console.log(
`Removed successfully : ${path.basename(file)}`.green.bold
);
}
}
}catch (e) {
console.log(`Error while removing backup file`.red.bold)
} catch (e) {
console.log(`Error while removing backup file`.red.bold);
}
}
}
export default ModelMgr;

782
packages/nc-cli/src/lib/mgr/NewMgr.ts

@ -5,14 +5,14 @@ import mkdirp from 'mkdirp';
import path from 'path';
import tcpPortUsed from 'tcp-port-used';
import URL from 'url';
import {promisify} from "util";
import Util from "../util/Util";
import { promisify } from 'util';
import Util from '../util/Util';
import {v4 as uuidv4} from 'uuid';
import * as fs from "fs";
import Lang, {STR} from "../util/Lang";
import boxen from 'boxen';
import * as fs from 'fs';
import os from 'os';
import boxen from "boxen";
import { v4 as uuidv4 } from 'uuid';
import Lang, { STR } from '../util/Lang';
// @ts-ignore
const colors = require('colors');
@ -45,7 +45,7 @@ const dbDefaults = {
username: 'sa',
password: '',
database: ''
},
}
};
// const apiTypeMapping = {
@ -58,9 +58,7 @@ const dbDefaults = {
// 'Typescript': 'ts',
// }
class NewMgr {
/**
*
* Does the below :
@ -73,143 +71,158 @@ class NewMgr {
* @returns {Promise<string|string|boolean|*>}
*/
public static async getNewProjectInput(args): Promise<any> {
if (args._.length < 2) {
const usage = '\n$ xc new project_name'.green.bold
console.log(`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red.bold);
const usage = '\n$ xc new project_name'.green.bold;
console.log(
`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red
.bold
);
return false;
}
/* Construct database URL from prompt */
const dbTypes = Object.keys(dbDefaults);
args.url = []
console.log(`NocoDB requires a database to store metadata of database-spreadsheets.\nPlease enter the database credentials (defaults to SQLite3)`.green.bold)
const answers = await inquirer
.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE),// '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'sqlite3',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
args.url = [];
console.log(
`NocoDB requires a database to store metadata of database-spreadsheets.\nPlease enter the database credentials (defaults to SQLite3)`
.green.bold
);
const answers = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE), // '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'sqlite3',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST), // '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host;
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST),// '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT), // '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port;
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color;
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT),// '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color
}
},
validate(port, answers) {
const done = this.async();
if (answers.host === 'host.docker.internal' || answers.host === 'docker.for.win.localhost') {
done(null, true)
} else {
NewMgr.isPortOpen(answers.host, port).then(isOpen => {
validate(port, answers) {
const done = this.async();
if (
answers.host === 'host.docker.internal' ||
answers.host === 'docker.for.win.localhost'
) {
done(null, true);
} else {
NewMgr.isPortOpen(answers.host, port)
.then(isOpen => {
if (isOpen) {
done(null, true)
done(null, true);
} else {
// done('Port is not open')
console.log(`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`.red.bold)
console.log(
`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`
.red.bold
);
process.exit(0);
}
}).catch(done)
}
},
when({type}) {
return type !== 'sqlite3'
})
.catch(done);
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username;
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('')
},
when({type}) {
return type !== 'sqlite3'
}
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('');
},
{
name: 'projectType',
type: 'list',
message: Lang.getString(STR.PROJECT_TYPE), // '🚀 How do you want to run it\t:',
choices: [ 'As Node.js Project','As Docker', //'Try XC Instant App (Without scaffolding code)'
].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
])
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'projectType',
type: 'list',
message: Lang.getString(STR.PROJECT_TYPE), // '🚀 How do you want to run it\t:',
choices: [
'As Node.js Project',
'As Docker' // 'Try XC Instant App (Without scaffolding code)'
].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
}
]);
/* if not valid retry getting right input */
if (answers.type !== 'sqlite3' && !answers.database) {
console.log('\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold);
console.log(
'\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold
);
this.getNewProjectInput(args);
}
@ -226,230 +239,270 @@ class NewMgr {
}
if (answers.projectType === 'mvc' && !answers.isForExisting) {
/* attach new project name to path and 'cd' to that folder */
args.folder = path.join(args.folder, args._[1]);
mkdirp.sync(args.folder);
process.chdir(args.folder);
await Util.runCmd(`cd ${Util.escapeShellArg(args.folder)}`);
await promisify(download)('direct:https://github.com/nocodb/nocodb-seed/archive/refs/heads/main.zip', args.folder);
await promisify(download)(
'direct:https://github.com/nocodb/nocodb-seed/archive/refs/heads/main.zip',
args.folder
);
if (answers.type !== 'sqlite3') {
fs.appendFileSync(path.join(args.folder, '.env'), `NC_DB=${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}`)
fs.appendFileSync(
path.join(args.folder, '.env'),
`NC_DB=${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}`
);
}
if (os.type() === 'Windows_NT') {
console.log(boxen(`# Project created successfully\n\n# Please run the following commands\n\n${('cd ' + Util.escapeShellArg(args.folder) + '\nnpm install \nnpm start\n').green.bold}`, {
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any));
console.log(
boxen(
`# Project created successfully\n\n# Please run the following commands\n\n${
(
'cd ' +
Util.escapeShellArg(args.folder) +
'\nnpm install \nnpm start\n'
).green.bold
}`,
{
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any
)
);
} else {
await Util.runCmd(`npm install; npm run start;`);
}
} else if (answers.projectType) {
let env = '';
if (answers.type !== 'sqlite3') {
env = `--env NC_DB="${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}"`
env = `--env NC_DB="${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}"`;
}
const linuxHost = os.type() === 'Linux' ? '--net=host' : '';
if (os.type() === 'Windows_NT') {
// tslint:disable-next-line:ban-comma-operator
console.log(boxen(`# Please run the following docker commands\n\n${(`docker run -p 8080:8080 ${linuxHost} -d ${env} nocodb/nocodb:latest`).green.bold}\n`, {
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any));
console.log(
boxen(
`# Please run the following docker commands\n\n${
`docker run -p 8080:8080 ${linuxHost} -d ${env} nocodb/nocodb:latest`
.green.bold
}\n`,
{
borderColor: 'green',
borderStyle: 'round',
margin: 1,
padding: 1
} as any
)
);
} else {
await Util.runCmd(`docker run -p 8080:8080 ${linuxHost} -d ${env} nocodb/nocodb:latest`);
await Util.runCmd(
`docker run -p 8080:8080 ${linuxHost} -d ${env} nocodb/nocodb:latest`
);
}
}
}
public static async getNewProjectInputOld(args): Promise<any> {
if (args._.length < 2) {
const usage = '\n$ xc new project_name'.green.bold
console.log(`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red.bold);
const usage = '\n$ xc new project_name'.green.bold;
console.log(
`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red
.bold
);
return false;
}
/* Construct database URL from prompt */
const dbTypes = Object.keys(dbDefaults);
args.url = []
const answers = await inquirer
.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE),// '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql2',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
args.url = [];
const answers = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE), // '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql2',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST), // '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host;
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT), // '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port;
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST),// '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color;
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT),// '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color
}
},
validate(port, answers) {
const done = this.async();
if (answers.host === 'host.docker.internal' || answers.host === 'docker.for.win.localhost') {
done(null, true)
} else {
NewMgr.isPortOpen(answers.host, port).then(isOpen => {
validate(port, answers) {
const done = this.async();
if (
answers.host === 'host.docker.internal' ||
answers.host === 'docker.for.win.localhost'
) {
done(null, true);
} else {
NewMgr.isPortOpen(answers.host, port)
.then(isOpen => {
if (isOpen) {
done(null, true)
done(null, true);
} else {
// done('Port is not open')
console.log(`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`.red.bold)
console.log(
`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`
.red.bold
);
process.exit(0);
}
}).catch(done)
}
},
when({type}) {
return type !== 'sqlite3'
})
.catch(done);
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username;
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('')
},
when({type}) {
return type !== 'sqlite3'
}
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('');
},
{
name: 'apiType',
type: 'list',
message: Lang.getString(STR.DB_API), // '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs', 'gRPC APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
{
name: 'projectType',
type: 'list',
message: Lang.getString(STR.PROJECT_TYPE), // '🚀 How do you want to run it\t:',
choices: ['Docker', 'New Node.js project', 'Existing Node.js project', 'Try XC Instant App (Without scaffolding code)'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'apiType',
type: 'list',
message: Lang.getString(STR.DB_API), // '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs', 'gRPC APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
// {
// name: 'programmingLanguage',
// type: 'list',
// message: '🚀 Enter preferred programming language\t:',
// choices: ['Javascript', 'Typescript'].map(t => ({
// name: t,
// value: t,
// short: t.green.bold
// })),
// transformer(color) {
// return chalkPipe(color)(color.green.bold);
// },
// when({type}) {
// return type !== 'sqlite3'
// }
// }
])
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'projectType',
type: 'list',
message: Lang.getString(STR.PROJECT_TYPE), // '🚀 How do you want to run it\t:',
choices: [
'Docker',
'New Node.js project',
'Existing Node.js project',
'Try XC Instant App (Without scaffolding code)'
].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
}
// {
// name: 'programmingLanguage',
// type: 'list',
// message: '🚀 Enter preferred programming language\t:',
// choices: ['Javascript', 'Typescript'].map(t => ({
// name: t,
// value: t,
// short: t.green.bold
// })),
// transformer(color) {
// return chalkPipe(color)(color.green.bold);
// },
// when({type}) {
// return type !== 'sqlite3'
// }
// }
]);
// console.log(answers);
if (answers.type === 'sqlite3') {
console.log('Please use desktop app to create Sqlite project'.green.bold)
console.log('Please use desktop app to create Sqlite project'.green.bold);
process.exit(0);
}
/* if not valid retry getting right input */
if (!answers.database) {
console.log('\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold);
console.log(
'\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold
);
this.getNewProjectInput(args);
}
//
/* prepare the args */
// const url = `${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}&api=${apiTypeMapping[answers.projectType]}`;
// args._[0] = answers.projectType === 'REST APIs' ? 'gar' : 'gag';
@ -485,7 +538,6 @@ class NewMgr {
}
if (answers.projectType === 'mvc' && !answers.isForExisting) {
/* attach new project name to path and 'cd' to that folder */
args.folder = path.join(args.folder, args._[1]);
mkdirp.sync(args.folder);
@ -495,72 +547,73 @@ class NewMgr {
await promisify(download)('gitlab:xc-public/test10', args.folder);
const config = {
title: args._[1],
"version": "0.6",
"envs": {
"dev": {
"db": [
version: '0.6',
envs: {
dev: {
db: [
{
"client": answers.type,
"connection": {
"host": answers.host,
"port": answers.port,
"user": answers.username,
"password": answers.password,
"database": answers.database,
"multipleStatements": true
client: answers.type,
connection: {
host: answers.host,
port: answers.port,
user: answers.username,
password: answers.password,
database: answers.database,
multipleStatements: true
},
"meta": {
"tn": "xc_evolutions",
"dbAlias": "db",
"api": {
"type": answers.apiType,
"prefix": "",
"graphqlDepthLimit": 10
meta: {
tn: 'xc_evolutions',
dbAlias: 'db',
api: {
type: answers.apiType,
prefix: '',
graphqlDepthLimit: 10
},
"inflection": {
"tn": "none",
"cn": "none"
inflection: {
tn: 'none',
cn: 'none'
}
}
}
],
"apiClient": {
"data": []
apiClient: {
data: []
}
}
},
"workingEnv": "dev",
"seedsFolder": "seeds",
"queriesFolder": "queries",
"apisFolder": "apis",
"projectType": answers.apiType,
"type": "docker",
"language": "ts",
"apiClient": {
"data": []
workingEnv: 'dev',
seedsFolder: 'seeds',
queriesFolder: 'queries',
apisFolder: 'apis',
projectType: answers.apiType,
type: 'docker',
language: 'ts',
apiClient: {
data: []
},
"auth": {
"jwt": {
"secret": uuidv4(),
"dbAlias": "db"
auth: {
jwt: {
secret: uuidv4(),
dbAlias: 'db'
}
}, "meta": {
"db": {
"client": "sqlite3",
"connection": {
"filename": "xc.db"
},
meta: {
db: {
client: 'sqlite3',
connection: {
filename: 'xc.db'
}
}
}
}
};
fs.writeFileSync(path.join(args.folder, 'config.xc.json'), JSON.stringify(config, null, 2))
fs.writeFileSync(
path.join(args.folder, 'config.xc.json'),
JSON.stringify(config, null, 2)
);
await Util.runCmd(`npm install; npm run start;`);
} else if (answers.projectType === 'mvc') {
console.log(`
1. Install our npm package using following command
@ -568,7 +621,8 @@ class NewMgr {
2. Add the following code in your existing express project
\t${`const {Noco} = require("nocodb");
\t${
`const {Noco} = require("nocodb");
\tnew Noco({
title: "${args._[1]}",
@ -630,7 +684,8 @@ class NewMgr {
}
}
}
}).init().then(mw => app.use(mw))`.green}
}).init().then(mw => app.use(mw))`.green
}
@ -638,38 +693,33 @@ ${`Note: ${'app'.bold} - refers to your express server instance`}
`)
`);
} else if (answers.projectType === 'docker') {
const dbUrl = `${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}`;
// console.log(`
// You can create docker container using following command
//
// \t${`docker run -p 8080:8080 -p 8081:8081 -p 8082:8082 -d --name xc-instant --env DB_URL=${dbUrl} -d xgenecloud/xc:latest`.green}
//
//
// Then visit http://localhost:8080/xc to access the Dashboard
//
// `)
// console.log(`
// You can create docker container using following command
//
// \t${`docker run -p 8080:8080 -p 8081:8081 -p 8082:8082 -d --name xc-instant --env DB_URL=${dbUrl} -d xgenecloud/xc:latest`.green}
//
//
// Then visit http://localhost:8080/xc to access the Dashboard
//
// `)
const linuxHost = os.type() === 'Linux' ? '--net=host' : '';
await Util.runCmd(`docker run -p 8080:8080 -p 8081:8081 -p 8082:8082 ${linuxHost} --name xc-instant --env NC_DB_URL="${dbUrl}" xgenecloud/xc:latest`);
await Util.runCmd(
`docker run -p 8080:8080 -p 8081:8081 -p 8082:8082 ${linuxHost} --name xc-instant --env NC_DB_URL="${dbUrl}" xgenecloud/xc:latest`
);
}
// args.url.push(url);
//
// args.language = languageMapping[answers.programmingLanguage];
// return OldNewMgr.testConnection(args)
}
public static async testConnection({url}) {
public static async testConnection({ url }) {
for (const u of url) {
const parsedUrlData = URL.parse(u, true);
const queryParams = parsedUrlData.query;
@ -681,29 +731,30 @@ ${`Note: ${'app'.bold} - refers to your express server instance`}
port: +parsedUrlData.port,
user: queryParams.u,
password: queryParams.p,
database: client === 'pg' ? 'postgres' : (client === 'mssql' ? undefined : null)
database:
client === 'pg' ? 'postgres' : client === 'mssql' ? undefined : null
}
};
try {
const knex = require('knex')(config)
await knex.raw("SELECT 1+1 as data");
const knex = require('knex')(config);
await knex.raw('SELECT 1+1 as data');
} catch (e) {
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold)
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold);
return false;
}
}
return true;
}
public static async isPortOpen(host, port) {
try {
return await tcpPortUsed.check(+port, host)
return await tcpPortUsed.check(+port, host);
} catch (e) {
console.log(e)
console.log(`\n😩 ${host}:${port} is not reachable please check\n`.red.bold)
console.log(e);
console.log(
`\n😩 ${host}:${port} is not reachable please check\n`.red.bold
);
return true;
}
}
@ -715,4 +766,3 @@ ${`Note: ${'app'.bold} - refers to your express server instance`}
}
export default NewMgr;

306
packages/nc-cli/src/lib/mgr/OldNewMgr.ts

@ -6,7 +6,7 @@ import URL from 'url';
import('colors');
let tcpPortUsed = require('tcp-port-used');
const tcpPortUsed = require('tcp-port-used');
const dbDefaults = {
mysql: {
@ -36,22 +36,20 @@ const dbDefaults = {
username: 'sa',
password: '',
database: ''
},
}
};
const apiTypeMapping = {
'GRAPHQL APIs': 'graphql',
'REST APIs': 'rest',
'gRPC APIs': 'grpc'
}
};
const languageMapping = {
'Javascript': 'js',
'Typescript': 'ts',
}
Javascript: 'js',
Typescript: 'ts'
};
class OldNewMgr {
/**
*
* Does the below :
@ -64,161 +62,169 @@ class OldNewMgr {
* @returns {Promise<string|string|boolean|*>}
*/
public static async getNewProjectInput(args) {
if (args._.length < 2) {
const usage = '\n$ xc new project_name'.green.bold
console.log(`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red.bold);
const usage = '\n$ xc new project_name'.green.bold;
console.log(
`\n\nWarning! missing project name\n\nExample Usage:\n${usage}\n`.red
.bold
);
return false;
}
/* Construct database URL from prompt */
const dbTypes = Object.keys(dbDefaults);
args.url = []
args.url = [];
const answers = await inquirer
.prompt([
{
name: 'type',
type: 'list',
message: '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
const answers = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
},
{
name: 'host',
type: 'input',
message: '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host;
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'port',
type: 'number',
message: '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port;
},
{
name: 'host',
type: 'input',
message: '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color;
}
},
{
name: 'port',
type: 'number',
message: '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color
}
},
validate(port, answers) {
let done = this.async();
OldNewMgr.isPortOpen(answers.host, port).then(isOpen => {
validate(port, answers) {
const done = this.async();
OldNewMgr.isPortOpen(answers.host, port)
.then(isOpen => {
if (isOpen) {
done(null, true)
done(null, true);
} else {
// done('Port is not open')
console.log(`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`.red.bold)
console.log(
`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`
.red.bold
);
process.exit(0);
}
}).catch(done)
},
when({type}) {
return type !== 'sqlite3'
}
})
.catch(done);
},
{
name: 'username',
type: 'input',
message: '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'username',
type: 'input',
message: '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username;
},
{
name: 'password',
type: 'input',
mask: true,
message: '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('')
},
when({type}) {
return type !== 'sqlite3'
}
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
message: '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'password',
type: 'input',
mask: true,
message: '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('');
},
{
name: 'projectType',
type: 'list',
message: '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'database',
type: 'input',
default(_ans) {
return args._[1] + '_dev';
},
{
name: 'programmingLanguage',
type: 'list',
message: '🚀 Enter preferred programming language\t:',
choices: ['Javascript', 'Typescript'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
message: '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'projectType',
type: 'list',
message: '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'programmingLanguage',
type: 'list',
message: '🚀 Enter preferred programming language\t:',
choices: ['Javascript', 'Typescript'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
])
}
]);
// console.log(answers);
if (answers.type === 'sqlite3') {
console.log('Please use desktop app to create Sqlite project'.green.bold)
console.log('Please use desktop app to create Sqlite project'.green.bold);
process.exit(0);
}
/* if not valid retry getting right input */
if (!answers.database) {
console.log('\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold);
console.log(
'\n\tWarning! Database name can NOT be empty. Retry.\n '.red.bold
);
this.getNewProjectInput(args);
}
@ -229,7 +235,11 @@ class OldNewMgr {
// await Util.runCmd(`cd ${args.folder}`);
/* prepare the args */
const url = `${answers.type}://${answers.host}:${answers.port}?u=${answers.username}&p=${answers.password}&d=${answers.database}&api=${apiTypeMapping[answers.projectType]}`;
const url = `${answers.type}://${answers.host}:${answers.port}?u=${
answers.username
}&p=${answers.password}&d=${answers.database}&api=${
apiTypeMapping[answers.projectType]
}`;
args._[0] = answers.projectType === 'REST APIs' ? 'gar' : 'gag';
switch (answers.projectType) {
case 'REST APIs':
@ -249,13 +259,10 @@ class OldNewMgr {
args.language = languageMapping[answers.programmingLanguage];
return OldNewMgr.testConnection(args)
return OldNewMgr.testConnection(args);
}
public static async testConnection({url}) {
public static async testConnection({ url }) {
for (const u of url) {
const parsedUrlData = URL.parse(u, true);
const queryParams = parsedUrlData.query;
@ -267,34 +274,33 @@ class OldNewMgr {
port: +parsedUrlData.port,
user: queryParams.u,
password: queryParams.p,
database: client === 'pg' ? 'postgres' : (client === 'mssql' ? undefined : null)
database:
client === 'pg' ? 'postgres' : client === 'mssql' ? undefined : null
}
};
try {
const knex = require('knex')(config)
await knex.raw("SELECT 1+1 as data");
const knex = require('knex')(config);
await knex.raw('SELECT 1+1 as data');
} catch (e) {
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold)
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold);
return false;
}
}
return true;
}
public static async isPortOpen(host, port) {
try {
return await tcpPortUsed.check(+port, host)
return await tcpPortUsed.check(+port, host);
} catch (e) {
console.log(e)
console.log(`\n😩 ${host}:${port} is not reachable please check\n`.red.bold)
console.log(e);
console.log(
`\n😩 ${host}:${port} is not reachable please check\n`.red.bold
);
return true;
}
}
}
export default OldNewMgr;

534
packages/nc-cli/src/lib/mgr/PermissionsMgr.ts

@ -9,28 +9,29 @@ import Util from '../util/Util';
import Table from 'cli-table3';
class PermissionsMgr {
public static async set(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
// @ts-ignore
let [_, models, users, ...resolvers] = args._;
models = models.split('.');
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
@ -40,73 +41,87 @@ class PermissionsMgr {
if (users[0] === '$') {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
if (resolvers[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else if (resolvers[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
obj[role] = false;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0]) {
const permObj = roles.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} , resolver: ${route}`
);
}
})
});
}
}
} else {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0] || permTuple[0] === '$') {
const permObj = users.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users} , resolver: ${route}`
);
}
})
});
}
}
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
console.error(`Error in xc permissions.set`, e);
}
} else {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
@ -117,72 +132,102 @@ class PermissionsMgr {
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
const routesList: Route[] = require(file);
const roles = this.extractUniqueRoles(routesList);
if (users[0] === '$') {
for (const route of routesList) {
if (permissions[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
return obj;
}, {});
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${route.type}=true, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${route.type}=true, route: ${route.path}`
);
} else if (permissions[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
obj[role] = false;
return obj;
}, {});
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${route.type}=false, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${route.type}=false, route: ${route.path}`
);
} else {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = roles.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (route.type === permTuple[0]) {
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${permTuple[0]}=${val}, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route.path}`
);
}
})
});
}
}
} else {
for (const route of routesList) {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = users.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (route.type === permTuple[0]) {
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${permTuple[0]}=${val}, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route.path}`
);
} else if (permTuple[0] === '*') {
Object.assign(route.acl, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${route.type}=${val}, route: ${route.path}`);
Object.assign(route.acl, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${route.type}=${val}, route: ${route.path}`
);
}
})
});
}
}
const policyFileContent = `module.exports = ${JSON.stringify(routesList, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
routesList,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
@ -192,27 +237,30 @@ class PermissionsMgr {
}
public static async get(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1: models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
// instantiate
let rows: any[] = [];
let roles: any[] = [];
glob.sync(policiesPath).forEach((file) => {
glob.sync(policiesPath).forEach(file => {
// let filePermissions = require(file);
const modelName = path.basename(file).split('.')[0];
@ -220,25 +268,25 @@ class PermissionsMgr {
if (models.includes(modelName)) {
const filePermissions = require(file);
roles = this.extractUniqueGqlPolicyRoles(filePermissions);
rows.push([{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}])
rows.push([
{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [route, methods] of Object.entries(filePermissions)) {
const row: any[] = [{content: route, vAlign: 'center'}];
const row: any[] = [{ content: route, vAlign: 'center' }];
for (const role of roles) {
row.push(methods[role] ? colors.green('✔') : colors.red('x'));
}
rows.push(row)
rows.push(row);
}
}
})
});
const table = new Table({
head: ['Route', ...roles]
@ -246,111 +294,126 @@ class PermissionsMgr {
table.push(...rows);
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1: models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
// instantiate
const table = new Table({
head: ['Route', 'Role', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']
});
glob.sync(policiesPath)
glob
.sync(policiesPath)
.sort(this.sortFiles)
.forEach((file) => {
.forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName)) {
const routesList: Route[] = require(file);
const groupedRoutes = this.groupRoutes(routesList);
// extract unique roles
const roles = this.extractUniqueRoles(routesList);
table.push([{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}])
table.push([
{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [routePath, methods] of Object.entries(groupedRoutes)) {
for (const [routePath, methods] of Object.entries(
groupedRoutes
)) {
let i = 0;
for (const role of roles) {
{
table.push([...(i++ ? [] : [{
content: routePath,
rowSpan: roles.length,
vAlign: 'center'
}]), role,
methods?.get?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.post?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.put?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.delete?.acl?.[role] ? colors.green('✔') : colors.red('x'),
methods?.patch?.acl?.[role] ? colors.green('✔') : colors.red('x'),
] as any)
table.push([
...(i++
? []
: [
{
content: routePath,
rowSpan: roles.length,
vAlign: 'center'
}
]),
role,
methods?.get?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.post?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.put?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.delete?.acl?.[role]
? colors.green('✔')
: colors.red('x'),
methods?.patch?.acl?.[role]
? colors.green('✔')
: colors.red('x')
] as any);
}
}
}
}
})
});
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
}
}
public static async userAdd(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file);
const roles = this.extractUniqueGqlPolicyRoles(filePermissions);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -360,42 +423,45 @@ class PermissionsMgr {
roles1[user] = true;
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const routes: Route[] = require(file);
const roles = this.extractUniqueRoles(routes);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -405,49 +471,49 @@ class PermissionsMgr {
route.acl[user] = true;
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(routes, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
routes,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
}
}
public static async userDelete(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file);
const roles = this.extractUniqueGqlPolicyRoles(filePermissions);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
return;
@ -457,40 +523,44 @@ class PermissionsMgr {
delete roles1[user];
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const routes: Route[] = require(file);
const roles = this.extractUniqueRoles(routes)
const roles = this.extractUniqueRoles(routes);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
@ -501,15 +571,17 @@ class PermissionsMgr {
delete route.acl[user];
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports = ${JSON.stringify(routes, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports = ${JSON.stringify(
routes,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
@ -517,29 +589,31 @@ class PermissionsMgr {
}
public static async userRename(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser, 2: newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file);
const roles = this.extractUniqueGqlPolicyRoles(filePermissions);
if (!roles.includes(oldUser)) {
console.warn(`${oldUser} not exist in ${modelName} policy`);
return;
@ -554,33 +628,40 @@ class PermissionsMgr {
delete roles1[oldUser];
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser, 2: newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.routes.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.routes.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const routes: Route[] = require(file);
const roles = this.extractUniqueRoles(routes);
@ -599,13 +680,16 @@ class PermissionsMgr {
delete route.acl[oldUser];
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports = ${JSON.stringify(routes, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports = ${JSON.stringify(
routes,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
@ -613,8 +697,9 @@ class PermissionsMgr {
}
public static getPolicyPath() {
const projectConfig = jsonfile.readFileSync(path.join(process.cwd(), 'config.xc.json'));
const projectConfig = jsonfile.readFileSync(
path.join(process.cwd(), 'config.xc.json')
);
return projectConfig.meta.projectType === 'rest' ? 'routers' : 'resolvers';
}
@ -626,14 +711,11 @@ class PermissionsMgr {
private static extractUniqueRoles(routesList: Route[]) {
const roles = routesList
.flatMap(
route => Object.keys(route.acl)
)
.flatMap(route => Object.keys(route.acl))
.filter((v, i, arr) => arr.indexOf(v) === i);
return roles;
}
private static groupRoutes(routes: Route[]): GroupedRoutes {
const groupedRoutes: GroupedRoutes = {};
for (const route of routes) {
@ -644,19 +726,22 @@ class PermissionsMgr {
}
private static sortFiles(file1: string, file2: string): number {
return ((file1.indexOf('.bt.') > -1 ? 1 : 0) || (file1.indexOf('.hm.') > -1 ? 2 : 0))
- ((file2.indexOf('.bt.') > -1 ? 1 : 0) || (file2.indexOf('.hm.') > -1 ? 2 : 0));
return (
((file1.indexOf('.bt.') > -1 ? 1 : 0) ||
(file1.indexOf('.hm.') > -1 ? 2 : 0)) -
((file2.indexOf('.bt.') > -1 ? 1 : 0) ||
(file2.indexOf('.hm.') > -1 ? 2 : 0))
);
}
}
export default PermissionsMgr;
export interface Route {
type: string;
path: string;
acl: {
[key: string]: boolean
[key: string]: boolean;
};
}
@ -668,9 +753,8 @@ export interface GroupedRoutes {
type: string;
path: string;
acl: {
[key: string]: boolean
[key: string]: boolean;
};
}
}
};
};
}

555
packages/nc-cli/src/lib/mgr/PermissionsMgrJs.ts

@ -9,28 +9,29 @@ import Util from '../util/Util';
import Table from 'cli-table3';
class PermissionsMgr {
public static async set(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
// @ts-ignore
let [_, models, users, ...resolvers] = args._;
models = models.split('.');
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
@ -42,80 +43,92 @@ class PermissionsMgr {
if (users[0] === '$') {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
if (resolvers[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else if (resolvers[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
obj[role] = false;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} resolver: ${route}`
);
} else {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0]) {
const permObj = roles.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} , resolver: ${route}`
);
}
})
});
}
}
} else {
for (const [route, rolesObj] of Object.entries(filePermissions)) {
resolvers.forEach(permission => {
const permTuple = permission.split('=')
const permTuple = permission.split('=');
if (route === permTuple[0]) {
const permObj = roles.reduce((obj, role) => {
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
obj[role] = val;
return obj;
}, {});
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} , resolver: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} , resolver: ${route}`
);
}
})
});
}
}
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
console.error(`Error in xc permissions.set`, e);
}
} else {
try {
if (args._.length < 4) {
console.warn('Invalid arguments for : xc permissions.set')
console.warn('Invalid arguments for : xc permissions.set');
return;
}
// @ts-ignore
let [_, models, users, ...permissions] = args._;
@ -123,29 +136,28 @@ class PermissionsMgr {
users = users.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName) || models[0] === '$') {
const filePermissions = require(file).permissions;
if (users[0] === '$') {
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
for (const [route, methods] of Object.entries(filePermissions)) {
if (permissions[0] === '$=1') {
const permObj = roles.reduce((obj, role) => {
obj[role] = true;
@ -153,8 +165,12 @@ class PermissionsMgr {
}, {});
for (const [method, rolesObj] of Object.entries(methods)) {
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${method}=true, route: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${method}=true, route: ${route}`
);
}
} else if (permissions[0] === '$=0') {
const permObj = roles.reduce((obj, role) => {
@ -162,59 +178,74 @@ class PermissionsMgr {
return obj;
}, {});
for (const [method, rolesObj] of Object.entries(methods)) {
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${method}=false, route: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${method}=false, route: ${route}`
);
}
} else {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = roles.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (methods[permTuple[0]]) {
Object.assign(methods[permTuple[0]], permObj)
console.log(`Setting Permissions for model:${modelName} roles:${roles.join(', ')} method: ${permTuple[0]}=${val}, route: ${route}`);
Object.assign(methods[permTuple[0]], permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${roles.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route}`
);
}
})
});
}
}
} else {
for (const [route, methods] of Object.entries(filePermissions)) {
permissions.forEach(permission => {
const permTuple = permission.split('=')
const val = !!(permTuple.length === 1 ? 1 : +permTuple[1] || 0);
const permTuple = permission.split('=');
const val = !!(permTuple.length === 1
? 1
: +permTuple[1] || 0);
const permObj = users.reduce((obj, role) => {
obj[role] = val;
return obj;
}, {});
if (methods[permTuple[0]]) {
Object.assign(methods[permTuple[0]], permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${permTuple[0]}=${val}, route: ${route}`);
Object.assign(methods[permTuple[0]], permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${permTuple[0]}=${val}, route: ${route}`
);
} else if (permTuple[0] === '*') {
for (const [method, rolesObj] of Object.entries(methods)) {
Object.assign(rolesObj, permObj)
console.log(`Setting Permissions for model:${modelName} roles:${users.join(', ')} method: ${method}=${val}, route: ${route}`);
Object.assign(rolesObj, permObj);
console.log(
`Setting Permissions for model:${modelName} roles:${users.join(
', '
)} method: ${method}=${val}, route: ${route}`
);
}
}
})
});
}
}
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
}
});
} catch (e) {
console.error(`Error in xc permissions.set`, e);
}
@ -222,27 +253,30 @@ class PermissionsMgr {
}
public static async get(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1: models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
// instantiate
let rows: any[] = [];
let roles: any[] = [];
glob.sync(policiesPath).forEach((file) => {
glob.sync(policiesPath).forEach(file => {
// let filePermissions = require(file).permissions;
const modelName = path.basename(file).split('.')[0];
@ -250,28 +284,27 @@ class PermissionsMgr {
if (models.includes(modelName)) {
const filePermissions = require(file).permissions;
roles = Object.values(filePermissions)
.flatMap(
roles1 => Object.keys(roles1))
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
rows.push([{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}])
rows.push([
{
colSpan: roles.length + 1,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [route, methods] of Object.entries(filePermissions)) {
const row: any[] = [{content: route, vAlign: 'center'}];
const row: any[] = [{ content: route, vAlign: 'center' }];
for (const role of roles) {
row.push(methods[role] ? colors.green('✔') : colors.red('x'));
}
rows.push(row)
rows.push(row);
}
}
})
});
const table = new Table({
head: ['Route', ...roles]
@ -279,84 +312,97 @@ class PermissionsMgr {
table.push(...rows);
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
}
else {
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.get')
console.warn('Invalid arguments for : xc permissions.get');
return;
}
let {1:models} = args._;
let { 1: models } = args._;
models = models.split('.');
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
// instantiate
const table = new Table({
head: ['Route', 'Role', 'GET', 'POST', 'PUT', 'DELETE', 'PATCH']
});
glob.sync(policiesPath).forEach((file) => {
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
if (models.includes(modelName)) {
if (models.includes(modelName)) {
const filePermissions: { readonly [key: string]: any } = require(file).permissions;
const filePermissions: {
readonly [key: string]: any;
} = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
table.push([{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}])
table.push([
{
colSpan: 7,
content: colors.green(file),
hAlign: 'center'
}
]);
for (const [route, methods] of Object.entries(filePermissions)) {
let i = 0;
for (const role of roles) {
{
table.push([...(i++ ? [] : [{
content: route,
rowSpan: roles.length,
vAlign: 'center'
}]), role,
methods.get && methods.get[role] ? colors.green('✔') : colors.red('x'),
methods.post && methods.post[role] ? colors.green('✔') : colors.red('x'),
methods.put && methods.put[role] ? colors.green('✔') : colors.red('x'),
methods.delete && methods.delete[role] ? colors.green('✔') : colors.red('x'),
methods.patch && methods.patch[role] ? colors.green('✔') : colors.red('x'),
] as any)
table.push([
...(i++
? []
: [
{
content: route,
rowSpan: roles.length,
vAlign: 'center'
}
]),
role,
methods.get && methods.get[role]
? colors.green('✔')
: colors.red('x'),
methods.post && methods.post[role]
? colors.green('✔')
: colors.red('x'),
methods.put && methods.put[role]
? colors.green('✔')
: colors.red('x'),
methods.delete && methods.delete[role]
? colors.green('✔')
: colors.red('x'),
methods.patch && methods.patch[role]
? colors.green('✔')
: colors.red('x')
] as any);
}
}
}
}
// console.log(`Model : ${modelName} \n${JSON.stringify(filePermissions, 0, 2)} `)
}
})
});
console.log(table.toString());
} catch (e) {
console.error(`Error in xc permissions.get`, e);
}
@ -364,32 +410,33 @@ class PermissionsMgr {
}
public static async userAdd(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -399,47 +446,49 @@ class PermissionsMgr {
roles1[user] = true;
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (roles.includes(user)) {
console.warn(`${user} already exist in ${modelName} policy`);
return;
@ -451,50 +500,51 @@ class PermissionsMgr {
}
}
console.log(
`Adding new role permission for model:${modelName} roles:${user}`
);
console.log(`Adding new role permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.add`, e);
}
}
}
public static async userDelete(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
return;
@ -504,46 +554,49 @@ class PermissionsMgr {
delete roles1[user];
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 2) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: user} = args._;
const { 1: user } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(user)) {
console.warn(`${user} not exist in ${modelName} policy`);
return;
@ -555,15 +608,17 @@ class PermissionsMgr {
}
}
console.log(
`Deleting user permission for model:${modelName} roles:${user}`
);
console.log(`Deleting user permission for model:${modelName} roles:${user}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
@ -571,31 +626,33 @@ class PermissionsMgr {
}
public static async userRename(args) {
if (Util.isProjectGraphql()) {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser,2: newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(roles1 => Object.keys(roles1))
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(oldUser)) {
console.warn(`${oldUser} not exist in ${modelName} policy`);
return;
@ -610,43 +667,48 @@ class PermissionsMgr {
delete roles1[oldUser];
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
} else {
try {
if (args._.length < 3) {
console.warn('Invalid arguments for : xc permissions.userAdd')
console.warn('Invalid arguments for : xc permissions.userAdd');
return;
}
const {1: oldUser, 2:newUser} = args._;
const { 1: oldUser, 2: newUser } = args._;
/* get all policies */
const policiesPath = path.join(process.cwd(), 'server', PermissionsMgr.getPolicyPath(), '**', '*.policy.js');
glob.sync(policiesPath).forEach((file) => {
const policiesPath = path.join(
process.cwd(),
'server',
PermissionsMgr.getPolicyPath(),
'**',
'*.policy.js'
);
glob.sync(policiesPath).forEach(file => {
const modelName = path.basename(file).split('.')[0];
const filePermissions = require(file).permissions;
const roles = Object.values(filePermissions)
.flatMap(
methods => Object.values(methods)
.flatMap(roles1 => Object.keys(roles1))
.flatMap(methods =>
Object.values(methods).flatMap(roles1 => Object.keys(roles1))
)
.filter((v, i, arr) => arr.indexOf(v) === i);
if (!roles.includes(oldUser)) {
console.warn(`${oldUser} not exist in ${modelName} policy`);
return;
@ -663,27 +725,28 @@ class PermissionsMgr {
}
}
console.log(`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(filePermissions, null, 2)};\n`;
fs.writeFileSync(file, policyFileContent)
console.log(
`Renaming user permission ${oldUser} to ${newUser} for model:${modelName}`
);
const policyFileContent = `module.exports.permissions = ${JSON.stringify(
filePermissions,
null,
2
)};\n`;
fs.writeFileSync(file, policyFileContent);
});
} catch (e) {
console.error(`Error in xc permissions.user.delete`, e);
}
}
}
public static getPolicyPath() {
const projectConfig = jsonfile.readFileSync(path.join(process.cwd(), 'config.xc.json'));
const projectConfig = jsonfile.readFileSync(
path.join(process.cwd(), 'config.xc.json')
);
return projectConfig.meta.projectType === 'rest' ? 'routers' : 'resolvers';
}
}
export default PermissionsMgr;

93
packages/nc-cli/src/lib/mgr/SocialMgr.ts

@ -6,41 +6,34 @@ import Locales from '../util/Locales';
import socialShareRules from './cliRules.json';
import socialText from './SocialText';
class SocialMgr {
public static async share(args) {
try {
const shareUrl = await SocialMgr.getShareUrl({
text: 'A revolutionary API framework with a Desktop App.',
type: args.type,
url: 'https://NocoDB.com'
});
open(shareUrl, {wait: true});
open(shareUrl, { wait: true });
} catch (e) {
console.error(`Error in xc ${args.type}`, e);
}
}
public static async shareSocial(_args = {}) {
try {
const prompt: any = Locales.getPrompt();
const prompt:any = Locales.getPrompt();
const answer = await inquirer
.prompt([
{
choices: prompt.choices,
message: prompt.message,
name: 'media',
type: 'list'
}
])
const answer = await inquirer.prompt([
{
choices: prompt.choices,
message: prompt.message,
name: 'media',
type: 'list'
}
]);
switch (answer.media) {
case 'Next time':
break;
@ -52,10 +45,9 @@ class SocialMgr {
break;
case 'Github - ⭐ or 👀 repo':
open('https://github.com/NocoDB/NocoDB', {wait: true});
open('https://github.com/NocoDB/NocoDB', { wait: true });
break;
default:
const text = SocialMgr.getShareText(answer.media);
// const url = SocialMgr._getShareContentSuffix(answer.media);
@ -65,26 +57,21 @@ class SocialMgr {
url: 'https://NocoDB.com'
});
open(shareUrl, {wait: true});
open(shareUrl, { wait: true });
break;
}
} catch (e) {
console.error(`Error in xc share`, e);
}
}
public static getShareUrl({type, url, text}):any {
const encUrl = encodeURIComponent(url)
const encText = encodeURIComponent(text)
public static getShareUrl({ type, url, text }): any {
const encUrl = encodeURIComponent(url);
const encText = encodeURIComponent(text);
console.log(__dirname, process.cwd());
switch (type) {
case 'Twitter':
return `https://twitter.com/intent/tweet?url=${encUrl}&text=${encText}&hashtags=xgenecloud`;
break;
@ -134,36 +121,43 @@ class SocialMgr {
break;
case 'OKru':
return `https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=${encUrl}`
return `https://connect.ok.ru/dk?st.cmd=WidgetSharePreview&st.shareUrl=${encUrl}`;
break;
case 'WeChat':
return `https://www.addtoany.com/add_to/wechat?linkurl=${encUrl}&linkname=${encText}`;
break;
}
}
public static setShareRules(key, value) {
socialShareRules[key] = value;
fs.writeFileSync(path.join(__dirname, 'cliRules.json'), JSON.stringify(socialShareRules));
fs.writeFileSync(
path.join(__dirname, 'cliRules.json'),
JSON.stringify(socialShareRules)
);
}
public static setCreatedApis(value) {
if (socialShareRules.dontPrompt) { return }
if (socialShareRules.dontPrompt) {
return;
}
socialShareRules.createdApis = value;
socialShareRules.prompt = value;
fs.writeFileSync(path.join(__dirname, 'cliRules.json'), JSON.stringify(socialShareRules));
fs.writeFileSync(
path.join(__dirname, 'cliRules.json'),
JSON.stringify(socialShareRules)
);
}
public static async showPrompt() {
try {
if (socialShareRules.createdApis && socialShareRules.prompt && !socialShareRules.dontPrompt) {
await SocialMgr.shareSocial()
if (
socialShareRules.createdApis &&
socialShareRules.prompt &&
!socialShareRules.dontPrompt
) {
await SocialMgr.shareSocial();
SocialMgr.setShareRules('prompt', false);
}
} catch (e) {
@ -171,15 +165,18 @@ class SocialMgr {
}
}
public static getShareText(socialMediaType) {
return SocialMgr._getShareContentPrefix(socialMediaType) +
SocialMgr._getShareContentMid(socialMediaType) +
SocialMgr._getShareContentSuffix(socialMediaType)
return (
SocialMgr._getShareContentPrefix(socialMediaType) +
SocialMgr._getShareContentMid(socialMediaType) +
SocialMgr._getShareContentSuffix(socialMediaType)
);
}
public static _getShareContentPrefix(_socialMediaType) {
return socialText.prefix[Math.floor(Math.random() * socialText.prefix.length)];
return socialText.prefix[
Math.floor(Math.random() * socialText.prefix.length)
];
}
public static _getShareContentMid(_socialMediaType) {
@ -187,12 +184,10 @@ class SocialMgr {
}
public static _getShareContentSuffix(_socialMediaType) {
return socialText.suffix[Math.floor(Math.random() * socialText.suffix.length)];
return socialText.suffix[
Math.floor(Math.random() * socialText.suffix.length)
];
}
}
export default SocialMgr;

19
packages/nc-cli/src/lib/mgr/SocialText.ts

@ -1,5 +1,7 @@
export default {
mid: ['\n@NocoDB - generates instant REST/GraphQL API on any database.\n+ Has GUI based schema migrations!\n+ Built in API-Client and terminal!\n+ Dark theme and much more!\n'],
mid: [
'\n@NocoDB - generates instant REST/GraphQL API on any database.\n+ Has GUI based schema migrations!\n+ Built in API-Client and terminal!\n+ Dark theme and much more!\n'
],
prefix: [
'Super slick!',
'Very handy!',
@ -64,7 +66,6 @@ export default {
'Woah, Extremely Interesting!',
'Woah, So useful!',
'Super slick API Framework!',
'Very handy API Framework!',
'Impressive API Framework!',
@ -86,17 +87,11 @@ export default {
'Extremely Interesting API Framework!',
'So useful API Framework',
'Cool Stuff!',
'Woha!',
'I\'m amazed by how well this works!',
'I\'m impressed by how well this works!',
"I'm amazed by how well this works!",
"I'm impressed by how well this works!"
],
suffix: [
'https://github.com/nocodb/nocodb',
'www.nocodb.com'
]
}
suffix: ['https://github.com/nocodb/nocodb', 'www.nocodb.com']
};

280
packages/nc-cli/src/lib/mgr/TryMgr.ts

@ -1,10 +1,10 @@
import chalkPipe from 'chalk-pipe';
import inquirer from 'inquirer';
import path from 'path';
import tcpPortUsed from 'tcp-port-used';
import URL from 'url';
import Util from "../util/Util";
import path from 'path';
import Lang, {STR} from "../util/Lang";
import Lang, { STR } from '../util/Lang';
import Util from '../util/Util';
import('colors');
@ -36,12 +36,10 @@ const dbDefaults = {
username: 'sa',
password: '',
database: ''
},
}
};
class TryMgr {
/**
*
* Does the below :
@ -57,139 +55,151 @@ class TryMgr {
let dbUrl;
if (args._[0] !== 't' && args._[0] !== 'try') {
if ( args._[1] === 'rest') {
if (args._[1] === 'rest') {
dbUrl = `sqlite3://sqlite3?d=${path.join(__dirname, 'sakila.db')}`;
} else if (args._[1] === 'gql') {
dbUrl = `sqlite3://sqlite3?d=${path.join(__dirname, 'sakila.db')}&api=graphql`;
dbUrl = `sqlite3://sqlite3?d=${path.join(
__dirname,
'sakila.db'
)}&api=graphql`;
}
} else {
/* Construct database URL from prompt */
const dbTypes = Object.keys(dbDefaults);
args.url = []
args.url = [];
const finalAnswers = await inquirer
.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE),// '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql2',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
const finalAnswers = await inquirer.prompt([
{
name: 'type',
type: 'list',
message: Lang.getString(STR.DB_TYPE), // '🔥 Choose SQL Database type\t:',
choices: dbTypes.map(t => ({
name: t,
value: t,
short: t.green.bold
})),
default: 'mysql2',
transformer(color) {
return chalkPipe(color)(color.green.bold);
}
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST), // '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host;
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT), // '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port;
},
{
name: 'host',
type: 'input',
message: Lang.getString(STR.DB_HOST),// '👉 Enter database host name\t:',
default(ans) {
return dbDefaults[ans.type].host
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color;
}
},
{
name: 'port',
type: 'number',
message: Lang.getString(STR.DB_PORT),// '👉 Enter database port number\t:',
default(ans) {
return dbDefaults[ans.type].port
},
transformer(color) {
try {
return color.green.bold;
} catch (e) {
return color
}
},
validate(port, answers) {
const done = this.async();
if (answers.host === 'host.docker.internal' || answers.host === 'docker.for.win.localhost') {
done(null, true)
} else {
TryMgr.isPortOpen(answers.host, port).then(isOpen => {
validate(port, answers) {
const done = this.async();
if (
answers.host === 'host.docker.internal' ||
answers.host === 'docker.for.win.localhost'
) {
done(null, true);
} else {
TryMgr.isPortOpen(answers.host, port)
.then(isOpen => {
if (isOpen) {
done(null, true)
done(null, true);
} else {
// done('Port is not open')
console.log(`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`.red.bold)
console.log(
`\n\n😩 ${answers.host}:${port} is not open please start the database if you haven't\n`
.red.bold
);
process.exit(0);
}
}).catch(done)
}
},
when({type}) {
return type !== 'sqlite3'
})
.catch(done);
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username
},
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'username',
type: 'input',
message: Lang.getString(STR.DB_USER), // '👉 Enter database username\t:',
default(ans) {
return dbDefaults[ans.type].username;
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('')
},
when({type}) {
return type !== 'sqlite3'
}
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
{
name: 'database',
type: 'input',
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'password',
type: 'input',
mask: true,
message: Lang.getString(STR.DB_PASSWORD), // '🙈 Enter database password\t:',
transformer(color) {
return new Array(color.length).fill('*'.green.bold).join('');
},
{
name: 'apiType',
type: 'list',
message: Lang.getString(STR.DB_API), // '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs', 'gRPC APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({type}) {
return type !== 'sqlite3'
}
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'database',
type: 'input',
message: Lang.getString(STR.DB_SCHEMA), // '👉 Enter database/schema name\t:',
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
when({ type }) {
return type !== 'sqlite3';
}
},
{
name: 'apiType',
type: 'list',
message: Lang.getString(STR.DB_API), // '🚀 Enter API type to generate\t:',
choices: ['REST APIs', 'GRAPHQL APIs', 'gRPC APIs'].map(t => ({
name: t,
value: t,
short: t.green.bold
})),
transformer(color) {
return chalkPipe(color)(color.green.bold);
},
])
when({ type }) {
return type !== 'sqlite3';
}
}
]);
// console.log(finalAnswers);
if (finalAnswers.type === 'sqlite3') {
console.log('Please use desktop app to create Sqlite project'.green.bold)
console.log(
'Please use desktop app to create Sqlite project'.green.bold
);
process.exit(0);
}
@ -200,7 +210,6 @@ class TryMgr {
}*/
//
/* prepare the args */
// const url = `${finalAnswers.type}://${finalAnswers.host}:${finalAnswers.port}?u=${finalAnswers.username}&p=${finalAnswers.password}&d=${finalAnswers.database}&api=${apiTypeMapping[finalAnswers.projectType]}`;
// args._[0] = finalAnswers.projectType === 'REST APIs' ? 'gar' : 'gag';
@ -218,16 +227,19 @@ class TryMgr {
finalAnswers.apiType = 'rest';
break;
}
dbUrl = `${finalAnswers.type}://${finalAnswers.host}:${finalAnswers.port}?u=${finalAnswers.username}&p=${finalAnswers.password}&d=${finalAnswers.database}&api=${finalAnswers.apiType}`
dbUrl = `${finalAnswers.type}://${finalAnswers.host}:${finalAnswers.port}?u=${finalAnswers.username}&p=${finalAnswers.password}&d=${finalAnswers.database}&api=${finalAnswers.apiType}`;
}
// await Util.runCmd(`cd ${__dirname};echo "const {XcTry} = require('xc-instant'); process.env.NC_DB_URL='${finalAnswers.dbUrl}'; XcTry().then(() => console.log('App started'));" | node`);
await Util.runCmd(`echo "const {XcTry} = require('xc-instant'); XcTry('${dbUrl}').then(() => console.log('App started'));" | NODE_PATH=${path.join(__dirname, '..', 'node_modules')} node`);
await Util.runCmd(
`echo "const {XcTry} = require('xc-instant'); XcTry('${dbUrl}').then(() => console.log('App started'));" | NODE_PATH=${path.join(
__dirname,
'..',
'node_modules'
)} node`
);
}
public static async testConnection({url}) {
public static async testConnection({ url }) {
for (const u of url) {
const parsedUrlData = URL.parse(u, true);
const queryParams = parsedUrlData.query;
@ -235,37 +247,41 @@ class TryMgr {
const config = {
client,
connection: {
database: client === 'pg' ? 'postgres' : (client === 'mssql' ? undefined : null),
database:
client === 'pg'
? 'postgres'
: client === 'mssql'
? undefined
: null,
host: parsedUrlData.hostname,
password: queryParams.p,
port: +parsedUrlData.port,
user: queryParams.u,
user: queryParams.u
}
};
try {
const knex = require('knex')(config)
await knex.raw("SELECT 1+1 as data");
const knex = require('knex')(config);
await knex.raw('SELECT 1+1 as data');
} catch (e) {
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold)
console.log(`\n😩 Test connection failed for : ${url}\n`.red.bold);
return false;
}
}
return true;
}
public static async isPortOpen(host, port) {
try {
return await tcpPortUsed.check(+port, host)
return await tcpPortUsed.check(+port, host);
} catch (e) {
console.log(e)
console.log(`\n😩 ${host}:${port} is not reachable please check\n`.red.bold)
console.log(e);
console.log(
`\n😩 ${host}:${port} is not reachable please check\n`.red.bold
);
return true;
}
}
}
export default TryMgr;

79
packages/nc-cli/src/lib/mgr/XcInstantMgr.ts

@ -11,11 +11,14 @@ import('colors');
const PROGRESS_WIDTH = 30;
class AppMgr {
public static async install(args) {
try {
const spinner = ora({text: 'Downloading Desktop App from Github..'.green.bold(), spinner: 'dots2', color: 'green'}).start();
const {src, dest} = await AppMgr.getDownloadLink(args);
const spinner = ora({
text: 'Downloading Desktop App from Github..'.green.bold(),
spinner: 'dots2',
color: 'green'
}).start();
const { src, dest } = await AppMgr.getDownloadLink(args);
console.log(`\t${src}`);
@ -23,20 +26,25 @@ class AppMgr {
// console.log(progress)
// Report download progress
const p = PROGRESS_WIDTH * progress.percent;
spinner.text = `Downloading Desktop App now..\n[${
Array.from({length: PROGRESS_WIDTH}, (_, i) => i <= p ? '=' : ' ').join('')
}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(progress.total / (1024 * 1024)).toFixed(2)}MB\n`.green.bold()
spinner.text = `Downloading Desktop App now..\n[${Array.from(
{ length: PROGRESS_WIDTH },
(_, i) => (i <= p ? '=' : ' ')
).join('')}] ${(progress.transferred / (1024 * 1024)).toFixed(2)}MB/${(
progress.total /
(1024 * 1024)
).toFixed(2)}MB\n`.green.bold();
});
// spinner.prefixText = '';
spinner.succeed(`Installable downloaded successfully at ./${dest}`.green.bold());
spinner.succeed(
`Installable downloaded successfully at ./${dest}`.green.bold()
);
console.log(`\nInstallable will open automatically now.`.green.bold);
console.log(`If not, please install it manually.`.green.bold);
if (os.type() === 'Windows_NT') {
// open(dest, {wait: true, app: 'explorer.exe'})
} else {
open(dest, {wait: true});
open(dest, { wait: true });
}
} catch (e) {
console.error(`Error in xc app.install`, e);
}
@ -45,7 +53,9 @@ class AppMgr {
public static async open(args) {
try {
const runCommand = AppMgr.getOpenCommand(args);
if (!runCommand) { return }
if (!runCommand) {
return;
}
if (shell.exec(runCommand).code !== 0) {
shell.echo(`\n\nError running command internally`.red);
shell.echo(`\nExiting...`.red);
@ -56,20 +66,27 @@ class AppMgr {
}
}
public static async getDownloadLink(args):Promise<any> {
public static async getDownloadLink(args): Promise<any> {
try {
let src;
let dest;
const urls:any = {};
const urls: any = {};
const res = await axios.get('https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1')
const res = await axios.get(
'https://api.github.com/repos/xgenecloud/xc-desktop-app/releases?page=1'
);
let status = 0;
for (let i = 0; i < res.data.length && status !== 15; i++) {
const assets = res.data[i].assets;
for (const {name, browser_download_url} of assets) {
switch (name.split('.').pop().toLowerCase()) {
for (const { name, browser_download_url } of assets) {
switch (
name
.split('.')
.pop()
.toLowerCase()
) {
case 'dmg':
urls.dmg = urls.dmg || browser_download_url;
status = status | 1;
@ -92,22 +109,24 @@ class AppMgr {
switch (os.type()) {
case 'Linux':
const linuxInfo = osInfo({mode: 'sync'});
if (args.debian) { src = urls.deb; }
else if (args.rpm) { src = urls.rpm; }
else {
const linuxInfo = osInfo({ mode: 'sync' });
if (args.debian) {
src = urls.deb;
} else if (args.rpm) {
src = urls.rpm;
} else {
switch (linuxInfo.id) {
case 'ubuntu':
case 'raspberry':
src = urls.deb
src = urls.deb;
break;
case 'fedora':
src = urls.rpm
src = urls.rpm;
break;
default:
src = urls.rpm
src = urls.rpm;
}
}
}
break;
case 'Darwin':
src = urls.dmg;
@ -120,22 +139,22 @@ class AppMgr {
}
dest = src.split('/').pop();
return {src, dest}
return { src, dest };
} catch (e) {
console.log(e)
console.log(e);
}
}
public static getOpenCommand(_args):any {
public static getOpenCommand(_args): any {
switch (os.type()) {
case 'Linux':
return 'xgenecloud'
return 'xgenecloud';
break;
case 'Darwin':
return 'open -a xgenecloud'
return 'open -a xgenecloud';
break;
case 'Windows_NT':
console.info('Open xgenecloud desktop app from Windows start menu')
console.info('Open xgenecloud desktop app from Windows start menu');
break;
default:
@ -144,6 +163,4 @@ class AppMgr {
}
}
export default AppMgr;

55
packages/nc-cli/src/lib/prompts/Menu.ts

@ -3,33 +3,26 @@
*/
'use strict';
import inquirer from 'inquirer';
import inquirer from 'inquirer';
class RunOrDownload {
public static async prepareCmd(ipc, args) {
args._[0] = '';
const answers = await inquirer.prompt([
{
choices: [
'gen',
'add',
'show',
'run',
],
choices: ['gen', 'add', 'show', 'run'],
message: 'What do you want to do?',
name: 'action',
type: 'rawlist'
}]);
}
]);
args._[0] = answers.action;
switch (answers.action) {
case 'gen':
await this.handleGen(ipc,args)
await this.handleGen(ipc, args);
break;
case 'add':
@ -40,13 +33,10 @@ class RunOrDownload {
case 'run':
break;
}
}
public static async handleGen(_ipc,args) {
public static async handleGen(_ipc, args) {
const a1 = await inquirer.prompt([
{
choices: [
@ -59,57 +49,42 @@ class RunOrDownload {
'resolver',
'type',
'schema',
'apis',
'apis'
],
message: 'What do you want to generate ?',
name: 'action',
pageSize: 9,
type: 'rawlist'
}]);
}
]);
args._[0] += `:${a1.action}`;
switch (a1.action) {
case 'apis':
const a2 = await inquirer.prompt([
{
choices: [
'rest',
'graphql'
],
choices: ['rest', 'graphql'],
message: 'Which apis you want to use?',
name: 'action',
type: 'rawlist'
}]);
}
]);
args._[0] += `:${a2.action}`;
break;
}
}
// tslint:disable-next-line:no-empty
public static async handleAdd() {
}
public static async handleAdd() {}
// tslint:disable-next-line:no-empty
public static async handleShow() {
}
public static async handleShow() {}
// tslint:disable-next-line:no-empty
public static async handleRun() {
}
public static async handleRun() {}
}
export default RunOrDownload;

32
packages/nc-cli/src/lib/prompts/RunOrDownload.ts

@ -3,40 +3,30 @@
*/
'use strict';
import inquirer from "inquirer";
import inquirer from 'inquirer';
class RunOrDownload {
public static async handle(_args) {
const answers = await inquirer.prompt([
{
choices: [
'Open the app!',
'Download it for FREE'
],
message: 'Your XGENE desktop app is not open - do you want to ?',
name: 'action',
type: 'rawlist'
}
]);
{
choices: ['Open the app!', 'Download it for FREE'],
message: 'Your XGENE desktop app is not open - do you want to ?',
name: 'action',
type: 'rawlist'
}
]);
switch (answers.action) {
case 'Open app!':
break;
case 'Download it for FREE':
console.log('wget(https://xgene.cloud/download?latest=true) to Downloads');
console.log(
'wget(https://xgene.cloud/download?latest=true) to Downloads'
);
break;
}
}
}
export default RunOrDownload;

31
packages/nc-cli/src/lib/util/Lang.ts

@ -3,15 +3,16 @@ import english from './english.json';
import translated from './translated.json';
/* Converted from : https://smodin.me/translate-one-text-into-multiple-languages
* Enter database host name || Choose SQL Database type || Enter database username || Enter database password || Enter database port number || Enter database/schema name || Enter API type to generate || How do you want to run it
* */
* Enter database host name || Choose SQL Database type || Enter database username || Enter database password || Enter database port number || Enter database/schema name || Enter API type to generate || How do you want to run it
* */
const formattedTranslate: any = {};
for (const {symbol, text} of [english, ...translated].sort((a, b) => a.symbol.localeCompare(b.symbol))) {
formattedTranslate [symbol] = text.split(/\s*\|\|\s*/);
for (const { symbol, text } of [english, ...translated].sort((a, b) =>
a.symbol.localeCompare(b.symbol)
)) {
formattedTranslate[symbol] = text.split(/\s*\|\|\s*/);
}
const dummy: any = new Date();
const offset: any = -dummy.getTimezoneOffset();
const locale: string = offset === 330 ? 'en-IN' : osLocale.sync();
@ -29,14 +30,10 @@ enum STR {
PROJECT_TYPE
}
class Lang {
// @ts-ignore
public static getString(str: STR) {
switch (locale) {
case 'en':
case 'en-GB':
case 'en-AU':
@ -45,7 +42,7 @@ class Lang {
case 'en-US':
default:
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.en?.[str]}\t:`;
case 'zh':
case 'zh-Hans':
case 'zh-CN':
@ -78,7 +75,7 @@ class Lang {
case 'es-US':
case 'es-VE':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.es?.[str]}\t:`;
case 'fi':
case 'fi-FI':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.fi?.[str]}\t:`;
@ -89,7 +86,7 @@ class Lang {
case 'fr-BE':
case 'fr-CH':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.fr?.[str]}\t:`;
case 'it':
case 'it-IT':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.it?.[str]}\t:`;
@ -97,7 +94,7 @@ class Lang {
case 'ja':
case 'ja-JP':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.ja?.[str]}\t:`;
case 'ko':
case 'ko-KR':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.ko?.[str]}\t:`;
@ -121,7 +118,6 @@ class Lang {
case 'sv-SE':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.sv?.[str]}\t:`;
case 'th':
case 'th-TH':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.th?.[str]}\t:`;
@ -142,13 +138,8 @@ class Lang {
case 'vi-VN':
return `${SMILEY_PREFIX[str]} ${formattedTranslate?.vi?.[str]}\t:`;
}
}
}
export default Lang;
export {
STR
};
export { STR };

347
packages/nc-cli/src/lib/util/Locales.ts

@ -1,9 +1,7 @@
import osLocale from 'os-locale';
class Locales {
public static getPrompt() {
const x = new Date();
const offset = -x.getTimezoneOffset();
@ -11,7 +9,6 @@ class Locales {
const locale = offset === 330 ? 'en-IN' : osLocale.sync();
switch (locale) {
case 'en':
case 'en-GB':
case 'en-AU':
@ -20,7 +17,8 @@ class Locales {
case 'en-US':
default:
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
'Facebook',
@ -29,10 +27,12 @@ class Locales {
'Reddit',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "English",
message: '\n\n👋 Hello! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'English',
message: '\n\n👋 Hello! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'zh':
@ -47,17 +47,18 @@ class Locales {
'WeChat',
'Github - ⭐ or 👀 repo',
'豆瓣', // douban
'新浪微博',// weibo
'新浪微博', // weibo
'Renren',
'Line',
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Chinese",
message: '\n\n👋 你好! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Chinese',
message: '\n\n👋 你好! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'en-IN':
@ -71,14 +72,14 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "English (India)",
message: '\n\n👋 Hello / नमस / ನ ಮ ಸ ರ / ന മ സ / வணககம! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'English (India)',
message: '\n\n👋 Hello / नमस / ನ ಮ ಸ ರ / ന മ സ / வணககம! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'de':
case 'de-DE':
case 'de-CH':
@ -94,18 +95,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "German",
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'German',
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'el':
case 'el-GR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -114,11 +116,12 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Greek",
message: '\n\n👋 Γειά σου! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Greek',
message: '\n\n👋 Γειά σου! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'es':
@ -134,7 +137,8 @@ class Locales {
case 'es-US':
case 'es-VE':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -143,17 +147,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Spanish",
message: '\n\n👋 Hola! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Spanish',
message: '\n\n👋 Hola! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'fa':
case 'fa-IR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -162,17 +168,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Persian",
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Persian',
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'fi':
case 'fi-FI':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -181,22 +189,22 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Finnish",
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Finnish',
message: '\n\n👋 سلام! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'fr':
case 'fr-CA':
case 'fr-FR':
case 'fr-BE':
case 'fr-CH':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -205,17 +213,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "French",
message: '\n\n👋 Bonjour! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'French',
message: '\n\n👋 Bonjour! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ga':
case 'ga-IE':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -224,17 +234,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Irish",
message: '\n\n👋 Dia dhuit! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Irish',
message: '\n\n👋 Dia dhuit! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'he':
case 'he-IL':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -243,17 +255,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Hebrew",
message: '\n\n👋 שלום! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Hebrew',
message: '\n\n👋 שלום! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'it':
case 'it-IT':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -262,18 +276,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Italian",
message: '\n\n👋 Ciao! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Italian',
message: '\n\n👋 Ciao! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ja':
case 'ja-JP':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Line',
'Linkedin',
@ -284,17 +299,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Japanese",
message: '\n\n👋 こんにちは! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Japanese',
message: '\n\n👋 こんにちは! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ko':
case 'ko-KR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Line',
'Linkedin',
@ -303,20 +320,22 @@ class Locales {
'WhatsApp',
'WeChat',
'豆瓣', // douban
'新浪微博',// weibo
'新浪微博', // weibo
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Korean",
message: '\n\n👋 여보세요! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Korean',
message: '\n\n👋 여보세요! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'mn-MN':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -324,20 +343,21 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Mongolian",
message: '\n\n👋 Сайн уу! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Mongolian',
message: '\n\n👋 Сайн уу! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'nl':
case 'nl-BE':
case 'nl-NL':
case 'nn-NO':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -345,19 +365,20 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Dutch",
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Dutch',
message: '\n\n👋 Hallo! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'pt':
case 'pt-BR':
case 'pt-PT':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -365,17 +386,19 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Portuguese",
message: '\n\n👋 Olá! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Portuguese',
message: '\n\n👋 Olá! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'ru':
case 'ru-RU':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'OKru',
'Telegram',
@ -386,18 +409,19 @@ class Locales {
'WhatsApp',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Russian",
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Russian',
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'sv':
case 'sv-SE':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -405,18 +429,19 @@ class Locales {
'WhatsApp',
'WeChat',
'Please dont ask me',
'- - - - - - - -'],
language: "Swedish",
message: '\n\n👋 Hej! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Swedish',
message: '\n\n👋 Hej! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'th':
case 'th-TH':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -425,17 +450,19 @@ class Locales {
'Telegram',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Thai",
message: '\n\n👋 สวสด! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Thai',
message: '\n\n👋 สวสด! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'tl':
case 'tl-PH':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -444,18 +471,19 @@ class Locales {
'WeChat',
'Telegram',
'Please dont ask me',
'- - - - - - - -'],
language: "Filipino",
message: '\n\n👋 Kamusta! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Filipino',
message: '\n\n👋 Kamusta! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'tr':
case 'tr-TR':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -463,17 +491,19 @@ class Locales {
'WhatsApp',
'Telegram',
'Please dont ask me',
'- - - - - - - -'],
language: "Turkish",
message: '\n\n👋 Merhaba! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Turkish',
message: '\n\n👋 Merhaba! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'uk':
case 'uk-UA':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'OKru',
// 'Reddit',
@ -485,17 +515,19 @@ class Locales {
'Wykop',
'Next time',
'Please dont ask me',
'- - - - - - - -'],
language: "Ukrainian",
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Ukrainian',
message: '\n\n👋 Здравствуйте! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
case 'vi':
case 'vi-VN':
prompt = {
choices: ['Twitter',
choices: [
'Twitter',
'Github - ⭐ or 👀 repo',
'Linkedin',
// 'Reddit',
@ -504,20 +536,17 @@ class Locales {
'WeChat',
'Telegram',
'Please dont ask me',
'- - - - - - - -'],
language: "Vietnamese",
message: '\n\n👋 xin chào! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'.green
}
'- - - - - - - -'
],
language: 'Vietnamese',
message: '\n\n👋 xin chào! 😀 \n\n🔥 Loving XgenCloud? 🔥\n\n🙏 Please mention a word about us to your friends & followers. 🙏\n\n'
.green
};
break;
}
return prompt;
}
}
export default Locales;

301
packages/nc-cli/src/lib/util/Util.ts

@ -2,19 +2,23 @@ import path from 'path';
import shell from 'shelljs';
class Util {
public static getShortVersion(args) {
const shortVersion = JSON.parse(JSON.stringify(args));
if (shortVersion._.length) {
shortVersion._[0] = shortVersion._[0].split('.').map(a => a[0]).join('')
shortVersion._[0] = shortVersion._[0]
.split('.')
.map(a => a[0])
.join('');
}
return shortVersion;
}
public static isProjectGraphql() {
const currentProjectJson = require(path.join(process.cwd(), 'config.xc.json'))
const currentProjectJson = require(path.join(
process.cwd(),
'config.xc.json'
));
return currentProjectJson.meta.projectType.toLowerCase() === 'graphql';
}
@ -34,7 +38,9 @@ Commands:
public static manNew() {
return `
${'COMMAND : '.bold}
${'xc new'.bold} - Creates new projects and creates APIs instantly for database inputted.
${
'xc new'.bold
} - Creates new projects and creates APIs instantly for database inputted.
${'SYNOPSIS : '.bold}
${'xc new'.bold} ${'<projectName>'.bold}
@ -54,7 +60,7 @@ ${'VARIATIONS :'.bold}
- Takes in database credentials and API type as input
- Database can be new or existing database
- Creates a new folder by name 'airbnb'
`
`;
}
public static manDocker() {
@ -77,13 +83,15 @@ ${'VARIATIONS :'.bold}
- Database can be new or existing database
- Scaffolds REST/GraphQL/gRPC APIs for the database specified
- These database can be already existing or new databases.
`
`;
}
public static manGenApisRest() {
return `
${'COMMAND : '.bold}
${'xc gen.apis.graphql'.bold} - generates REST APIs for an existing/new databases of a project.
${
'xc gen.apis.graphql'.bold
} - generates REST APIs for an existing/new databases of a project.
${'SYNOPSIS : '.bold}
${'xc gen.apis.rest'.bold} [${'-u'.bold} DatabaseURL(s)]
@ -92,38 +100,56 @@ ${'VARIATIONS :'.bold}
The following variations are available:
${'<>'.bold} If ${'no'.bold} option is passed, this generates REST APIs for databases current project
${'<>'.bold} If ${
'no'.bold
} option is passed, this generates REST APIs for databases current project
that are within project file config.xc.json
${'-u'.bold} ${'<Database URLs>'.bold} Creates a new project for an existing/new database
${'-u'.bold} ${
'<Database URLs>'.bold
} Creates a new project for an existing/new database
For mysql : mysql://localhost:3306?u=root&p=password&d=ecommerce
For pg : pg://localhost:5432?u=postgres&p=password&d=ecommerce
For mssql : mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce
${'Examples with notes : '.bold}
${'xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce'.bold}
${
'xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce'
.bold
}
- Generates REST apis for a mysql database 'ecommerce'
- Uses current directory as project name
- If database exists - REST APIs will be created for the tables within it.
- If database doesnt exist - it will be created.
${'xc gen.apis.rest -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'.bold}
${
'xc gen.apis.rest -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'
.bold
}
- Generates REST apis for a postgres database 'ecommerce'
${'xc gen.apis.rest -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'.bold}
${
'xc gen.apis.rest -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'
.bold
}
- Generates REST apis for a mssql database 'ecommerce'
${`xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`.bold}
${
`xc gen.apis.rest -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`
.bold
}
- Generates REST apis for multiple databases 'ecommerce' & 'crm'.
- These database can be already existing or new databases.
`
`;
}
public static manGenApisGraphql() {
return `
${'COMMAND : '.bold}
${'xc gen.apis.graphql'.bold} - generates GraphQL APIs for an existing/new databases of a project.
${
'xc gen.apis.graphql'.bold
} - generates GraphQL APIs for an existing/new databases of a project.
${'SYNOPSIS : '.bold}
${'xc gen.apis.graphql'.bold} [${'-u'.bold} DatabaseURL(s)]
@ -132,56 +158,84 @@ ${'VARIATIONS :'.bold}
The following variations are available:
${'<>'.bold} If ${'no'.bold} option is passed, this generates GraphQL APIs for databases current project
${'<>'.bold} If ${
'no'.bold
} option is passed, this generates GraphQL APIs for databases current project
that are within project file config.xc.json
${'-u'.bold} ${'<Database URLs>'.bold} Creates a new project for an existing/new database
${'-u'.bold} ${
'<Database URLs>'.bold
} Creates a new project for an existing/new database
For mysql : mysql://localhost:3306?u=root&p=password&d=ecommerce
For pg : pg://localhost:5432?u=postgres&p=password&d=ecommerce
For mssql : mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce
${'Examples with notes : '.bold}
${'xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce'.bold}
${
'xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce'
.bold
}
- Generates GraphQL apis for a mysql database 'ecommerce'
- Uses current directory as project name
- If database exists - GraphQL APIs will be created for the tables within it.
- If database doesnt exist - it will be created.
${'xc gen.apis.graphql -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'.bold}
${
'xc gen.apis.graphql -u pg://localhost:5432?u=postgres&p=password&d=ecommerce'
.bold
}
- Generates GraphQL apis for a postgres database 'ecommerce'
${'xc gen.apis.graphql -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'.bold}
${
'xc gen.apis.graphql -u mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce'
.bold
}
- Generates GraphQL apis for a mssql database 'ecommerce'
${`xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`.bold}
${
`xc gen.apis.graphql -u mysql://localhost:3306?u=root&p=password&d=ecommerce
-u pg://localhost:5432?u=postgres&p=password&d=crm`
.bold
}
- Generates GraphQL apis for multiple databases 'ecommerce' & 'crm'.
- These database can be already existing or new databases.
`
`;
}
public static manGenModule() {
return `
${'COMMAND : '.bold}
${'xc gen.module'.bold} - Creates a table and scaffolds the respective module files
${
'xc gen.module'.bold
} - Creates a table and scaffolds the respective module files
In REST project - (router, service, middleware, policy, model, meta)
In GraphQL project - (resolver, service, middleware, policy, model, meta)
${'SYNOPSIS : '.bold}
${'xc gen.module'.bold} ${'module(s)'.bold} [--nomodel] [--router] [--service] [--dbAlias]
${'xc gen.module'.bold} ${
'module(s)'.bold
} [--nomodel] [--router] [--service] [--dbAlias]
${'OPTIONS :'.bold}
The following options are available:
${'--nomodel'.bold} Scaffolds module without creating table and model, meta files.
${
'--nomodel'.bold
} Scaffolds module without creating table and model, meta files.
For mysql : mysql://localhost:3306?u=root&p=password&d=ecommerce
For pg : pg://localhost:5432?u=postgres&p=password&d=ecommerce
For mssql : mssql://localhost:1433?u=sa&p=Password123.&d=ecommerce
${'--dbAlias'.bold} Defaults to 'db'(primary) database if not provided to create the table
${'--router'.bold} Will create router with model - service file will be skipped //todo
${'--service'.bold} Will create service with model - router file will be skipped //todo
${
'--dbAlias'.bold
} Defaults to 'db'(primary) database if not provided to create the table
${
'--router'.bold
} Will create router with model - service file will be skipped //todo
${
'--service'.bold
} Will create service with model - router file will be skipped //todo
${'VARIATIONS :'.bold}
@ -206,13 +260,15 @@ ${'VARIATIONS :'.bold}
- All folder/files in respective components will be created in parent table of primary table
`
`;
}
public static manDbMigrateInit() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.init'.bold} - Initialises a database migration project freshly - only necessary files are created
${
'xc db.migrate.init'.bold
} - Initialises a database migration project freshly - only necessary files are created
- This is a legacy command and will not be required in developer flow
- Instead use ${'xc new'.bold}
- After running this command - edit config.xc.json and run xc db.migrate.sync
@ -228,23 +284,29 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.init --type mysql'.bold}
- Creates migration project of type mysql
- xc db.migrate.sync has to be run after command
`
`;
}
public static manDbMigrateSync() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.sync'.bold} - Initialises migrations in the databases of project
${
'xc db.migrate.sync'.bold
} - Initialises migrations in the databases of project
- Creates _evolutions table for database if it doesn't exists
${'SYNOPSIS : '.bold}
${'xc db.migrate.sync'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>]
${'xc db.migrate.sync'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Defaults to 'dev' environment if not provided
${'--dbAlias'.bold} If not provided all databases within environment are initialised
${
'--dbAlias'.bold
} If not provided all databases within environment are initialised
${'VARIATIONS :'.bold}
@ -259,7 +321,7 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.sync --env production --dbAlias secondary'.bold}
- Initialises migration for 'db2'(secondary) database within 'production' environment
`
`;
}
public static manDbMigrateList() {
@ -268,7 +330,9 @@ ${'COMMAND : '.bold}
${'xc db.migrate.list'.bold} - Lists all the migrations
${'SYNOPSIS : '.bold}
${'xc db.migrate.list'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>]
${'xc db.migrate.list'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
@ -290,16 +354,20 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.list --env production --dbAlias secondary'.bold}
- Lists all migrations within 'production' environment and 'db2'(secondary) database
`
`;
}
public static manDbMigrateCreate() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.create'.bold} - Creates an empty migration for environment and dbAlias
${
'xc db.migrate.create'.bold
} - Creates an empty migration for environment and dbAlias
${'SYNOPSIS : '.bold}
${'xc db.migrate.create'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>]
${'xc db.migrate.create'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
@ -320,7 +388,7 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.create --env production --dbAlias secondary'.bold}
- Creates a migration within 'production' environment and 'db2'(secondary) database
`
`;
}
public static manDbMigrateUp() {
@ -329,7 +397,11 @@ ${'COMMAND : '.bold}
${'xc db.migrate.up'.bold} - Applies all pending migrations
${'SYNOPSIS : '.bold}
${'xc db.migrate.up'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${'--file'.bold} <number>]
${'xc db.migrate.up'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${
'--file'.bold
} <number>]
${'OPTIONS :'.bold}
@ -353,18 +425,26 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.up --env production --steps 1'.bold}
- Applies one pending migrations in 'production' environment
${'xc db.migrate.up --env production --dbAlias secondary --steps 1'.bold}
${
'xc db.migrate.up --env production --dbAlias secondary --steps 1'.bold
}
- Applies one pending migrations in 'production' environment for 'db2'(secondary) database
`
`;
}
public static manDbMigrateDown() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.down'.bold} - Reverses all migrations or by steps or by till the filename
${
'xc db.migrate.down'.bold
} - Reverses all migrations or by steps or by till the filename
${'SYNOPSIS : '.bold}
${'xc db.migrate.down'.bold} [${'--env'.bold} <environment>] [${'--dbAlias'.bold} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${'--file'.bold} <number>]
${'xc db.migrate.down'.bold} [${'--env'.bold} <environment>] [${
'--dbAlias'.bold
} <databaseAlias>] \n\t\t\t[${'--steps'.bold} <number>] [${
'--file'.bold
} <number>]
${'OPTIONS :'.bold}
@ -388,23 +468,29 @@ ${'VARIATIONS :'.bold}
${'xc db.migrate.down --env production --steps 1'.bold}
- Reverses one applied migrations in 'production' environment
${'xc db.migrate.down --env production --dbAlias secondary --steps 1'.bold}
${
'xc db.migrate.down --env production --dbAlias secondary --steps 1'
.bold
}
- Reverses one applied migrations in 'production' environment for 'db2'(secondary) database
`
`;
}
public static manDbMigrateTerm() {
return `
${'COMMAND : '.bold}
${'xc db.migrate.term'.bold} - Deprecated. Terminates all databases in environment.
`
${
'xc db.migrate.term'.bold
} - Deprecated. Terminates all databases in environment.
`;
}
public static manComponentAdd() {
return `
${'COMMAND : '.bold}
${'xc component.add'.bold} - Adds a new component in server/components directory by taking user input
${
'xc component.add'.bold
} - Adds a new component in server/components directory by taking user input
on where to place the component in initialisation order.
${'SYNOPSIS : '.bold}
@ -427,13 +513,15 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc component.add cache'.bold}
- Adds a cache component
`
`;
}
public static manAppInstall() {
return `
${'COMMAND : '.bold}
${'xc app.install'.bold} - Download and starts xgenecloud desktop application installation
${
'xc app.install'.bold
} - Download and starts xgenecloud desktop application installation
${'SYNOPSIS : '.bold}
${'xc app.install'.bold}
@ -449,13 +537,15 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc app.install'.bold}
`
`;
}
public static manAppOpen() {
return `
${'COMMAND : '.bold}
${'xc app.open'.bold} - Opens the xgenecloud desktop application (mac and linux only)
${
'xc app.open'.bold
} - Opens the xgenecloud desktop application (mac and linux only)
${'SYNOPSIS : '.bold}
${'xc app.open'.bold}
@ -471,10 +561,9 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc app.open'.bold}
`
`;
}
public static manPermissionsSet() {
return `
${'COMMAND : '.bold}
@ -482,17 +571,27 @@ ${'COMMAND : '.bold}
${'SYNOPSIS : '.bold}
# For REST API project
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${'userType(s)'.bold} | $] [${'read|write)'.bold} = 1 | 0]
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${
'userType(s)'.bold
} | $] [${'read|write)'.bold} = 1 | 0]
# For GraphQL API project
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${'userType(s)'.bold} | $] [${'read|write|resolverFunction)'.bold} = 1 | 0]
${'xc permissions.set'.bold} [${'model(s)'.bold} | $] [${
'userType(s)'.bold
} | $] [${'read|write|resolverFunction)'.bold} = 1 | 0]
${'ARGS :'.bold}
The following are arguments to function:
${'model(s)'.bold} Model name | Multiple models with dot seperated | $ - means all models
${'userType(s)'.bold}User role name | Multiple user role names with dot separated | $ - means all user models
${'permissions(s)'.bold}Permissions - read | write | get | post | put | delete | patch | resolverFunc | $ - means all permissions
${
'model(s)'.bold
} Model name | Multiple models with dot seperated | $ - means all models
${
'userType(s)'.bold
}User role name | Multiple user role names with dot separated | $ - means all user models
${
'permissions(s)'.bold
}Permissions - read | write | get | post | put | delete | patch | resolverFunc | $ - means all permissions
${'VARIATIONS :'.bold}
None
@ -509,7 +608,7 @@ ${'VARIATIONS :'.bold}
${'xc permissions.set $ $ read=1 write=1'.bold}
- For 'all' models 'all' user types SET 'read' and 'write' permission
`
`;
}
// todo
@ -536,10 +635,9 @@ ${'VARIATIONS :'.bold}
${'Examples with notes : '.bold}
${'xc permissions.get blog'.bold}
- Get all permissions of blog model `
- Get all permissions of blog model `;
}
public static manPermissionsUserAdd() {
return `
${'COMMAND : '.bold}
@ -564,10 +662,9 @@ ${'VARIATIONS :'.bold}
${'xc permissions.role.add manager'.bold}
- Adds user role 'manager' to all the models
`
`;
}
public static manPermissionsUserDelete() {
return `
${'COMMAND : '.bold}
@ -590,10 +687,9 @@ ${'VARIATIONS :'.bold}
${'xc permissions.role.delete manager'.bold}
- deletes user role 'manager' from all the models
`
`;
}
public static manPermissionsUserRename() {
return `
${'COMMAND : '.bold}
@ -617,23 +713,28 @@ ${'VARIATIONS :'.bold}
${'xc permissions.role.rename manager StaffManager'.bold}
- Renames user role from 'manager' to 'StaffManager' in all the models
`
`;
}
public static manProjectMetaExport() {
return `
${'COMMAND : '.bold}
${'xc meta.export'.bold} - Exports all meta table data to project meta directory
${
'xc meta.export'.bold
} - Exports all meta table data to project meta directory
${'SYNOPSIS : '.bold}
${'xc meta.export'.bold} ${'--env'.bold} <environment> [${'--dbAlias'.bold} <databaseAlias>]
${'xc meta.export'.bold} ${'--env'.bold} <environment> [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Environment name to be exported
${'--dbAlias'.bold} dbAlias of database connection. If not provided then it will export metadata for all connections in the environment
${
'--dbAlias'.bold
} dbAlias of database connection. If not provided then it will export metadata for all connections in the environment
${'VARIATIONS :'.bold}
@ -645,8 +746,7 @@ ${'VARIATIONS :'.bold}
${'xc meta.export --env production --dbAlias db2'.bold}
- Exports metadata for 'db2' database in 'production' environment
`
`;
}
public static manProjectMetaReset() {
@ -655,13 +755,17 @@ ${'COMMAND : '.bold}
${'xc meta.reset'.bold} - Clears all meta table data
${'SYNOPSIS : '.bold}
${'xc meta.reset'.bold} ${'--env'.bold} <environment> [${'--dbAlias'.bold} <databaseAlias>]
${'xc meta.reset'.bold} ${'--env'.bold} <environment> [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Environment name to be reset
${'--dbAlias'.bold} dbAlias of database connection. If not provided then it will clear metadata for all connections in the environment
${
'--dbAlias'.bold
} dbAlias of database connection. If not provided then it will clear metadata for all connections in the environment
${'VARIATIONS :'.bold}
@ -673,23 +777,28 @@ ${'VARIATIONS :'.bold}
${'xc meta.reset --env production --dbAlias db2'.bold}
- Clears metadata for 'db2' database in 'production' environment
`
`;
}
public static manProjectMetaImport() {
return `
${'COMMAND : '.bold}
${'xc meta.import'.bold} - Imports data from project meta folder to meta tables
${
'xc meta.import'.bold
} - Imports data from project meta folder to meta tables
${'SYNOPSIS : '.bold}
${'xc meta.import'.bold} ${'--env'.bold} <environment> [${'--dbAlias'.bold} <databaseAlias>]
${'xc meta.import'.bold} ${'--env'.bold} <environment> [${
'--dbAlias'.bold
} <databaseAlias>]
${'OPTIONS :'.bold}
The following options are available:
${'--env'.bold} Environment name to be imported
${'--dbAlias'.bold} dbAlias of database connection. If not provided then it will import metadata to all connections in the environment
${
'--dbAlias'.bold
} dbAlias of database connection. If not provided then it will import metadata to all connections in the environment
${'VARIATIONS :'.bold}
@ -701,18 +810,13 @@ ${'VARIATIONS :'.bold}
${'xc meta.import --env production --dbAlias db2'.bold}
- Imports metadata for 'db2' database in 'production' environment
`
`;
}
public static showHelpForCommand(args) {
try {
switch (args._[1]) {
case 'new' :
case 'new':
console.log(Util.manNew());
break;
@ -870,14 +974,12 @@ ${'VARIATIONS :'.bold}
//
// /**************** END : Docker ****************/
default:
break;
}
} catch (e) {
throw e;
}
}
public static async runCmd(str) {
@ -891,24 +993,17 @@ ${'VARIATIONS :'.bold}
public static escapeShellArg(cmd) {
return '"' + cmd.replace(/(["'$`\\])/g, '\\$1') + '"';
};
}
public async play(sound) {
switch (sound) {
case -1:
break;
case 'fun':
break;
}
}
}
export default Util;

5
packages/nc-cli/src/lib/util/config.ts

@ -1,4 +1,3 @@
export default {
port: 23917,
}
port: 23917
};

661
packages/nc-gui/LICENSE

@ -0,0 +1,661 @@
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU Affero General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Remote Network Interaction; Use with the GNU General Public License.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the work with which it is combined will remain governed by version
3 of the GNU General Public License.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<http://www.gnu.org/licenses/>.

1
packages/nc-gui/components.d.ts vendored

@ -221,6 +221,7 @@ declare module '@vue/runtime-core' {
MdiWhatsapp: typeof import('~icons/mdi/whatsapp')['default']
MdiXml: typeof import('~icons/mdi/xml')['default']
MiCircleWarning: typeof import('~icons/mi/circle-warning')['default']
PhCloudLightningDuotone: typeof import('~icons/ph/cloud-lightning-duotone')['default']
PhFileCsv: typeof import('~icons/ph/file-csv')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']

9
packages/nc-gui/components/cell/MultiSelect.vue

@ -20,6 +20,7 @@ import MdiCloseCircle from '~icons/mdi/close-circle'
interface Props {
modelValue?: string | string[]
rowIndex?: number
}
const { modelValue } = defineProps<Props>()
@ -150,7 +151,13 @@ watch(isOpen, (n, _o) => {
@keydown="handleKeys"
@click="isOpen = !isOpen"
>
<a-select-option v-for="op of options" :key="op.id" :value="op.title" @click.stop>
<a-select-option
v-for="op of options"
:key="op.id"
:value="op.title"
:data-nc="`select-option-${column.title}-${rowIndex}`"
@click.stop
>
<a-tag class="rounded-tag" :color="op.color">
<span
:style="{

9
packages/nc-gui/components/cell/SingleSelect.vue

@ -6,6 +6,7 @@ import { ActiveCellInj, ColumnInj, IsKanbanInj, ReadonlyInj, computed, inject, r
interface Props {
modelValue?: string | undefined
rowIndex?: number
}
const { modelValue } = defineProps<Props>()
@ -81,7 +82,13 @@ watch(isOpen, (n, _o) => {
@keydown="handleKeys"
@click="isOpen = !isOpen"
>
<a-select-option v-for="op of options" :key="op.title" :value="op.title" @click.stop>
<a-select-option
v-for="op of options"
:key="op.title"
:value="op.title"
:data-nc="`select-option-${column.title}-${rowIndex}`"
@click.stop
>
<a-tag class="rounded-tag" :color="op.color">
<span
:style="{

1
packages/nc-gui/components/cell/attachment/index.vue

@ -160,6 +160,7 @@ watch(
v-if="!isReadonly"
:class="{ 'mx-auto px-4': !visibleItems.length }"
class="group cursor-pointer flex gap-1 items-center active:(ring ring-accent ring-opacity-100) rounded border-1 p-1 shadow-sm hover:(bg-primary bg-opacity-10) dark:(!bg-slate-500)"
data-nc="attachment-cell-file-picker-button"
@click.stop="open"
>
<MdiReload v-if="isLoading" :class="{ 'animate-infinite animate-spin': isLoading }" />

13
packages/nc-gui/components/dashboard/TreeView.vue

@ -321,12 +321,13 @@ function openTableCreateDialog() {
class="nc-tree-item text-sm cursor-pointer group"
:data-order="table.order"
:data-id="table.id"
:data-nc="`tree-view-table-${table.title}`"
@click="addTableTab(table)"
>
<GeneralTooltip class="pl-5 pr-3 py-2" modifier-key="Alt">
<template #title>{{ table.table_name }}</template>
<div class="flex items-center gap-2 h-full" @contextmenu="setMenuContext('table', table)">
<div class="flex w-auto">
<div class="flex w-auto" :data-nc="`tree-view-table-draggable-handle-${table.title}`">
<MdiDragVertical
v-if="isUIAllowed('treeview-drag-n-drop')"
:class="`nc-child-draggable-icon-${table.title}`"
@ -355,12 +356,16 @@ function openTableCreateDialog() {
<template #overlay>
<a-menu class="!py-0 rounded text-sm">
<a-menu-item v-if="isUIAllowed('table-rename')" @click="openRenameTableDialog(table)">
<div class="nc-project-menu-item">
<div class="nc-project-menu-item" :data-nc="`sidebar-table-rename-${table.title}`">
{{ $t('general.rename') }}
</div>
</a-menu-item>
<a-menu-item v-if="isUIAllowed('table-delete')" @click="deleteTable(table)">
<a-menu-item
v-if="isUIAllowed('table-delete')"
:data-nc="`sidebar-table-delete-${table.title}`"
@click="deleteTable(table)"
>
<div class="nc-project-menu-item">
{{ $t('general.delete') }}
</div>
@ -416,6 +421,8 @@ function openTableCreateDialog() {
<LazyGeneralHelpAndSupport class="color-transition px-2 text-gray-500 cursor-pointer select-none hover:text-accent" />
<GeneralJoinCloud class="color-transition px-2 text-gray-500 cursor-pointer select-none hover:text-accent" />
<GithubButton
class="ml-2 py-1"
href="https://github.com/nocodb/nocodb"

10
packages/nc-gui/components/dashboard/settings/AuditTab.vue

@ -105,7 +105,15 @@ const columns = [
/>
</div>
<a-table class="w-full" size="small" :data-source="audits ?? []" :columns="columns" :pagination="false" :loading="isLoading">
<a-table
class="w-full"
size="small"
:data-source="audits ?? []"
:columns="columns"
:pagination="false"
:loading="isLoading"
data-nc="audit-tab-table"
>
<template #emptyText>
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" />
</template>

9
packages/nc-gui/components/dashboard/settings/Modal.vue

@ -175,7 +175,12 @@ watch(
{{ $t('activity.settings') }}
</a-typography-title>
<a-button type="text" class="!rounded-md border-none -mt-1.5 -mr-1" @click="vModel = false">
<a-button
type="text"
class="!rounded-md border-none -mt-1.5 -mr-1"
data-nc="settings-modal-close-button"
@click="vModel = false"
>
<template #icon>
<MdiClose class="cursor-pointer mt-1 nc-modal-close" />
</template>
@ -215,7 +220,7 @@ watch(
</a-menu-item>
</a-menu>
<component :is="selectedSubTab?.body" class="px-2 py-6" />
<component :is="selectedSubTab?.body" class="px-2 py-6" :data-nc="`nc-settings-subtab-${selectedSubTab.title}`" />
</a-layout-content>
</a-layout>
</a-modal>

1
packages/nc-gui/components/dlg/TableCreate.vue

@ -105,6 +105,7 @@ onMounted(() => {
v-model:value="table.title"
size="large"
hide-details
data-nc="create-table-title-input"
:placeholder="$t('msg.info.enterTableName')"
/>
</a-form-item>

11
packages/nc-gui/components/general/JoinCloud.vue

@ -0,0 +1,11 @@
<template>
<a
v-e="['c:navbar:join-cloud']"
class="flex items-center space-x-1 w-full cursor-pointer pl-3 py-1.5 !text-current !no-underline !hover:(text-primary bg-primary bg-opacity-5)"
href="https://docs.google.com/forms/d/e/1FAIpQLSfKLe8Rcrq0uo2_jM5W1kbVBbzDiQ3IvlP8Iov61FTekVAvzA/viewform?usp=pp_url"
target="_blank"
>
<PhCloudLightningDuotone class="mr-1" />
Join NocoDB Cloud
</a>
</template>

2
packages/nc-gui/components/general/TruncateText.vue

@ -38,7 +38,7 @@ const shortName = computed(() =>
</template>
<div class="w-full">{{ shortName }}</div>
</a-tooltip>
<div v-else class="w-full">
<div v-else class="w-full" data-nc="truncate-label">
<slot />
</div>
<div ref="text" class="hidden">

4
packages/nc-gui/components/smartsheet/Cell.vue

@ -136,8 +136,8 @@ const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => {
<LazyCellGeoData v-else-if="isGeoData" v-model="vModel" />
<LazyCellCheckbox v-else-if="isBoolean" v-model="vModel" />
<LazyCellAttachment v-else-if="isAttachment" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellSingleSelect v-else-if="isSingleSelect" v-model="vModel" />
<LazyCellMultiSelect v-else-if="isMultiSelect" v-model="vModel" />
<LazyCellSingleSelect v-else-if="isSingleSelect" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellMultiSelect v-else-if="isMultiSelect" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellDatePicker v-else-if="isDate" v-model="vModel" />
<LazyCellYearPicker v-else-if="isYear" v-model="vModel" />
<LazyCellDateTimePicker v-else-if="isDateTime" v-model="vModel" />

32
packages/nc-gui/components/smartsheet/Form.vue

@ -388,7 +388,7 @@ watch(view, (nextView) => {
</script>
<template>
<a-row v-if="submitted" class="h-full">
<a-row v-if="submitted" class="h-full" data-nc="nc-form-wrapper-submit">
<a-col :span="24">
<div v-if="formViewData" class="items-center justify-center text-center mt-2">
<a-alert type="success">
@ -408,7 +408,7 @@ watch(view, (nextView) => {
</a-col>
</a-row>
<a-row v-else class="h-full flex">
<a-row v-else class="h-full flex" data-nc="nc-form-wrapper">
<a-col v-if="isEditable" :span="8" class="shadow p-2 md:p-4 h-full overflow-auto scrollbar-thin-dull nc-form-left-drawer">
<div class="flex flex-wrap gap-2">
<div class="flex-1 text-lg">
@ -420,6 +420,7 @@ watch(view, (nextView) => {
v-if="hiddenColumns.length"
type="button"
class="nc-form-add-all color-transition bg-white transform hover:(text-primary ring ring-accent ring-opacity-100) active:translate-y-[1px] px-2 py-1 shadow-md rounded"
data-nc="nc-form-add-all"
@click="addAllColumns"
>
<!-- Add all -->
@ -430,6 +431,7 @@ watch(view, (nextView) => {
v-if="localColumns.length"
type="button"
class="nc-form-remove-all color-transition bg-white transform hover:(text-primary ring ring-accent ring-opacity-100) active:translate-y-[1px] px-2 py-1 shadow-md rounded"
data-nc="nc-form-remove-all"
@click="removeAllColumns"
>
<!-- Remove all -->
@ -451,6 +453,7 @@ watch(view, (nextView) => {
<a-card
size="small"
class="!border-0 color-transition cursor-pointer item hover:(bg-primary ring-1 ring-accent ring-opacity-100) bg-opacity-10 !rounded !shadow-lg"
:data-nc="`nc-form-hidden-column-${element.label || element.title}`"
@mousedown="moved = false"
@mousemove="moved = false"
@mouseup="handleMouseUp(element, index)"
@ -478,6 +481,7 @@ watch(view, (nextView) => {
<template #footer>
<div
class="my-4 select-none border-dashed border-2 border-gray-400 py-3 text-gray-400 text-center nc-drag-n-drop-to-hide"
data-nc="nc-drag-n-drop-to-hide"
>
<!-- Drag and drop fields here to hide -->
{{ $t('msg.info.dragDropHide') }}
@ -535,6 +539,7 @@ watch(view, (nextView) => {
hide-details
placeholder="Form Title"
:bordered="false"
data-nc="nc-form-heading"
@blur="updateView"
@keydown.enter="updateView"
/>
@ -554,6 +559,7 @@ watch(view, (nextView) => {
:placeholder="$t('msg.info.formDesc')"
:bordered="false"
:disabled="!isEditable"
data-nc="nc-form-sub-heading"
@blur="updateView"
@click="updateView"
/>
@ -583,19 +589,25 @@ watch(view, (nextView) => {
'bg-primary bg-opacity-5 ring-0.5 ring-accent ring-opacity-100': activeRow === element.title,
},
]"
data-nc="nc-form-fields"
@click="activeRow = element.title"
>
<div
v-if="isUIAllowed('editFormView') && !isRequired(element, element.required)"
class="absolute flex top-2 right-2"
>
<MdiEyeOffOutline class="opacity-0 nc-field-remove-icon" @click.stop="hideColumn(index)" />
<MdiEyeOffOutline
class="opacity-0 nc-field-remove-icon"
data-nc="nc-field-remove-icon"
@click.stop="hideColumn(index)"
/>
</div>
<div v-if="activeRow === element.title" class="flex flex-col gap-3 mb-3">
<div class="flex gap-2 items-center">
<span
class="text-gray-500 mr-2 nc-form-input-required"
data-nc="nc-form-input-required"
@click="
() => {
element.required = !element.required
@ -619,6 +631,7 @@ watch(view, (nextView) => {
v-model:value="element.label"
type="text"
class="form-meta-input nc-form-input-label"
data-nc="nc-form-input-label"
:placeholder="$t('msg.info.formInput')"
@change="updateColMeta(element)"
>
@ -630,6 +643,7 @@ watch(view, (nextView) => {
v-model:value="element.description"
type="text"
class="form-meta-input text-sm nc-form-input-help-text"
data-nc="nc-form-input-help-text"
:placeholder="$t('msg.info.formHelpText')"
@change="updateColMeta(element)"
/>
@ -642,6 +656,7 @@ watch(view, (nextView) => {
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
data-nc="nc-form-input-label"
/>
<LazySmartsheetHeaderCell
@ -649,6 +664,7 @@ watch(view, (nextView) => {
:column="{ ...element, title: element.label || element.title }"
:required="isRequired(element, element.required)"
:hide-menu="true"
data-nc="nc-form-input-label"
/>
</div>
@ -663,6 +679,7 @@ watch(view, (nextView) => {
:row="row"
class="nc-input"
:class="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:data-nc="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:column="element"
@click.stop.prevent
/>
@ -678,13 +695,14 @@ watch(view, (nextView) => {
v-model="formState[element.title]"
class="nc-input"
:class="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:data-nc="`nc-form-input-${element.title.replaceAll(' ', '')}`"
:column="element"
:edit-enabled="true"
@click.stop.prevent
/>
</a-form-item>
<div class="text-gray-500 text-xs">{{ element.description }}</div>
<div class="text-gray-500 text-xs" data-nc="nc-form-input-help-text-label">{{ element.description }}</div>
</div>
</template>
@ -699,7 +717,7 @@ watch(view, (nextView) => {
</Draggable>
<div class="justify-center flex mt-6">
<button type="submit" class="uppercase scaling-btn nc-form-submit" @click="submitForm">
<button type="submit" class="uppercase scaling-btn nc-form-submit" data-nc="nc-form-submit" @click="submitForm">
{{ $t('general.submit') }}
</button>
</div>
@ -721,6 +739,7 @@ watch(view, (nextView) => {
:rows="3"
hide-details
class="nc-form-after-submit-msg"
data-nc="nc-form-after-submit-msg"
@change="updateView"
/>
@ -733,6 +752,7 @@ watch(view, (nextView) => {
v-e="[`a:form-view:submit-another-form`]"
size="small"
class="nc-form-checkbox-submit-another-form"
data-nc="nc-form-checkbox-submit-another-form"
@change="updateView"
/>
<span class="ml-4">{{ $t('msg.info.submitAnotherForm') }}</span>
@ -745,6 +765,7 @@ watch(view, (nextView) => {
v-e="[`a:form-view:show-blank-form`]"
size="small"
class="nc-form-checkbox-show-blank-form"
data-nc="nc-form-checkbox-show-blank-form"
@change="updateView"
/>
@ -757,6 +778,7 @@ watch(view, (nextView) => {
v-e="[`a:form-view:email-me`]"
size="small"
class="nc-form-checkbox-send-email"
data-nc="nc-form-checkbox-send-email"
@change="onEmailChange"
/>

4
packages/nc-gui/components/smartsheet/Gallery.vue

@ -163,14 +163,14 @@ watch(view, async (nextView) => {
</script>
<template>
<div class="flex flex-col h-full w-full overflow-auto nc-gallery">
{{ JSON.stringify(data) }}
<div class="flex flex-col h-full w-full overflow-auto nc-gallery" data-nc="nc-gallery-wrapper">
<div class="nc-gallery-container grid gap-2 my-4 px-3">
<div v-for="record in data" :key="`record-${record.row.id}`">
<LazySmartsheetRow :row="record">
<a-card
hoverable
class="!rounded-lg h-full overflow-hidden break-all max-w-[450px]"
:data-nc="`nc-gallery-card-${record.row.id}`"
@click="expandFormClick($event, record)"
>
<template v-if="galleryData?.fk_cover_image_col_id" #cover>

16
packages/nc-gui/components/smartsheet/Grid.vue

@ -460,8 +460,8 @@ watch(
</script>
<template>
<div class="relative flex flex-col h-full min-h-0 w-full">
<general-overlay :model-value="isLoading" inline transition class="!bg-opacity-15">
<div class="relative flex flex-col h-full min-h-0 w-full" data-nc="nc-grid-wrapper">
<general-overlay :model-value="isLoading" inline transition class="!bg-opacity-15" data-nc="grid-load-spinner">
<div class="flex items-center justify-center h-full w-full !bg-white !bg-opacity-85 z-1000">
<a-spin size="large" />
</div>
@ -480,8 +480,8 @@ watch(
>
<thead ref="tableHead">
<tr class="nc-grid-header border-1 bg-gray-100 sticky top[-1px]">
<th>
<div class="w-full h-full bg-gray-100 flex min-w-[70px] pl-5 pr-1 items-center">
<th data-nc="grid-id-column">
<div class="w-full h-full bg-gray-100 flex min-w-[70px] pl-5 pr-1 items-center" data-nc="nc-check-all">
<template v-if="!readOnly">
<div class="nc-no-label text-gray-500" :class="{ hidden: selectedAllRecords }">#</div>
<div
@ -546,8 +546,8 @@ watch(
<tbody ref="tbodyEl" @selectstart.prevent>
<LazySmartsheetRow v-for="(row, rowIndex) of data" ref="rowRefs" :key="rowIndex" :row="row">
<template #default="{ state }">
<tr class="nc-grid-row">
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1">
<tr class="nc-grid-row" :data-nc="`grid-row-${rowIndex}`">
<td key="row-index" class="caption nc-grid-cell pl-5 pr-1" :data-nc="`cell-Id-${rowIndex}`">
<div class="items-center flex gap-1 min-w-[55px]">
<div
v-if="!readOnly || !isLocked"
@ -568,9 +568,10 @@ watch(
<div
v-if="!readOnly || hasRole('commenter', true) || hasRole('viewer', true)"
class="nc-expand"
:data-nc="`nc-expand-${rowIndex}`"
:class="{ 'nc-comment': row.rowMeta?.commentCount }"
>
<a-spin v-if="row.rowMeta.saving" class="!flex items-center" />
<a-spin v-if="row.rowMeta.saving" class="!flex items-center" :data-nc="`row-save-spinner-${rowIndex}`" />
<template v-else>
<span
v-if="row.rowMeta?.commentCount"
@ -604,6 +605,7 @@ watch(
(hasEditPermission && selectedRange(rowIndex, colIndex)),
'nc-required-cell': isColumnRequiredAndNull(columnObj, row.row),
}"
:data-nc="`cell-${columnObj.title}-${rowIndex}`"
:data-key="rowIndex + columnObj.id"
:data-col="columnObj.id"
:data-title="columnObj.title"

2
packages/nc-gui/components/smartsheet/Kanban.vue

@ -312,7 +312,7 @@ watch(view, async (nextView) => {
</script>
<template>
<div class="flex h-full bg-white px-2">
<div class="flex h-full bg-white px-2" data-nc="nc-kanban-wrapper">
<div ref="kanbanContainerRef" class="nc-kanban-container flex my-4 px-3 overflow-x-scroll overflow-y-hidden">
<a-dropdown v-model:visible="contextMenu" :trigger="['contextmenu']" overlay-class-name="nc-dropdown-kanban-context-menu">
<!-- Draggable Stack -->

2
packages/nc-gui/components/smartsheet/Pagination.vue

@ -19,7 +19,7 @@ const page = computed({
<template>
<div class="flex items-center mb-1">
<span v-if="count !== null && count !== Infinity" class="caption ml-5 text-gray-500">
<span v-if="count !== null && count !== Infinity" class="caption ml-5 text-gray-500" data-nc="grid-pagination">
{{ count }} {{ count !== 1 ? $t('objects.records') : $t('objects.record') }}
</span>

2
packages/nc-gui/components/smartsheet/column/EditOrAdd.vue

@ -124,7 +124,7 @@ onMounted(() => {
:class="{ '!w-[600px]': formState.uidt === UITypes.Formula }"
@click.stop
>
<a-form v-model="formState" no-style name="column-create-or-edit" layout="vertical">
<a-form v-model="formState" no-style name="column-create-or-edit" layout="vertical" data-nc="add-or-edit-column">
<div class="flex flex-col gap-2">
<a-form-item :label="$t('labels.columnName')" v-bind="validateInfos.title">
<a-input

24
packages/nc-gui/components/smartsheet/column/SelectOptions.vue

@ -133,7 +133,12 @@ watch(inputs, () => {
<Draggable :list="options" item-key="id" handle=".nc-child-draggable-icon">
<template #item="{ element, index }">
<div class="flex py-1 items-center nc-select-option">
<MdiDragVertical v-if="!isKanban" small class="nc-child-draggable-icon handle" />
<MdiDragVertical
v-if="!isKanban"
small
class="nc-child-draggable-icon handle"
:data-nc="`select-option-column-handle-icon-${element.title}`"
/>
<a-dropdown
v-model:visible="colorMenus[index]"
:trigger="['click']"
@ -153,9 +158,20 @@ watch(inputs, () => {
/>
</a-dropdown>
<a-input ref="inputs" v-model:value="element.title" class="caption" @change="optionChanged(element.id)" />
<MdiClose class="ml-2 hover:!text-black" :style="{ color: 'red' }" @click="removeOption(index)" />
<a-input
ref="inputs"
v-model:value="element.title"
class="caption"
:data-nc="`select-column-option-input-${index}`"
@change="optionChanged(element.id)"
/>
<MdiClose
class="ml-2 hover:!text-black"
:style="{ color: 'red' }"
:data-nc="`select-column-option-remove-${index}`"
@click="removeOption(index)"
/>
</div>
</template>
<template #footer>

1
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -150,6 +150,7 @@ export default {
:key="col.title"
class="mt-2 py-2"
:class="`nc-expand-col-${col.title}`"
:data-nc="`nc-expand-col-${col.title}`"
>
<LazySmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" />

7
packages/nc-gui/components/smartsheet/sidebar/RenameableMenuItem.vue

@ -167,11 +167,12 @@ function onStopEdit() {
<template>
<a-menu-item
class="select-none group !flex !items-center !my-0 hover:(bg-primary !bg-opacity-5)"
:data-nc="`view-sidebar-view-${vModel.alias || vModel.title}`"
@dblclick.stop="onDblClick"
@click.stop="onClick"
>
<div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2">
<div class="flex w-auto">
<div v-e="['a:view:open', { view: vModel.type }]" class="text-xs flex items-center w-full gap-2" data-nc="view-item">
<div class="flex w-auto" :data-nc="`view-sidebar-drag-handle-${vModel.alias || vModel.title}`">
<MdiDrag
class="nc-drag-icon hidden group-hover:block transition-opacity opacity-0 group-hover:opacity-100 text-gray-500 !cursor-move"
@click.stop.prevent
@ -193,7 +194,7 @@ function onStopEdit() {
<div class="flex-1" />
<template v-if="!isEditing && !isLocked && isUIAllowed('virtualViewsCreateOrEdit')">
<div class="flex items-center gap-1">
<div class="flex items-center gap-1" :data-nc="`view-sidebar-view-actions-${vModel.alias || vModel.title}`">
<a-tooltip placement="left">
<template #title>
{{ $t('activity.copyView') }}

2
packages/nc-gui/components/smartsheet/sidebar/index.vue

@ -121,7 +121,7 @@ function onOpenModal({
collapsiple
collapsed-width="0"
width="0"
class="relative shadow h-full w-full !flex-1 !min-w-0 !max-w-[150px] !w-[150px] lg:(!max-w-[250px] !w-[250px])"
class="nc-view-sidebar relative shadow h-full w-full !flex-1 !min-w-0 !max-w-[150px] !w-[150px] lg:(!max-w-[250px] !w-[250px])"
theme="light"
>
<LazySmartsheetSidebarToolbar

1
packages/nc-gui/components/smartsheet/toolbar/ColumnFilterMenu.vue

@ -82,6 +82,7 @@ const filterAutoSaveLoc = computed({
ref="filterComp"
class="nc-table-toolbar-menu shadow-lg"
:auto-save="filterAutoSave"
data-nc="nc-filter-menu"
@update:filters-length="filtersLength = $event"
>
<div v-if="!isPublic" class="flex items-end mt-2 min-h-[30px]" @click.stop>

9
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -139,6 +139,7 @@ const getIcon = (c: ColumnType) =>
<template #overlay>
<div
class="p-3 min-w-[280px] bg-gray-50 shadow-lg nc-table-toolbar-menu max-h-[max(80vh,500px)] overflow-auto !border"
data-nc="nc-fields-menu"
@click.stop
>
<a-card
@ -162,7 +163,13 @@ const getIcon = (c: ColumnType) =>
<div class="nc-fields-list py-1">
<Draggable v-model="fields" item-key="id" @change="onMove($event)">
<template #item="{ element: field, index: index }">
<div v-show="filteredFieldList.includes(field)" :key="field.id" class="px-2 py-1 flex items-center" @click.stop>
<div
v-show="filteredFieldList.includes(field)"
:key="field.id"
class="px-2 py-1 flex items-center"
:data-nc="`nc-fields-menu-${field.title}`"
@click.stop
>
<a-checkbox
v-model:checked="field.show"
v-e="['a:fields:show-hide']"

14
packages/nc-gui/components/smartsheet/toolbar/ShareView.vue

@ -213,6 +213,7 @@ watch(passwordProtected, (value) => {
>
<div
data-cy="nc-modal-share-view__link"
data-nc="nc-modal-share-view__link"
class="share-link-box !bg-primary !bg-opacity-5 ring-1 ring-accent ring-opacity-100"
>
<div class="flex-1 h-min text-xs">{{ sharedViewUrl }}</div>
@ -235,6 +236,7 @@ watch(passwordProtected, (value) => {
v-if="shared.type === ViewTypes.FORM"
v-model:checked="surveyMode"
data-cy="nc-modal-share-view__survey-mode"
data-nc="nc-modal-share-view__survey-mode"
class="!text-sm"
>
Use Survey Mode
@ -265,6 +267,7 @@ watch(passwordProtected, (value) => {
v-if="shared.type === ViewTypes.FORM"
v-model:checked="viewTheme"
data-cy="nc-modal-share-view__with-theme"
data-nc="nc-modal-share-view__with-theme"
class="!text-sm"
>
Use Theme
@ -279,6 +282,7 @@ watch(passwordProtected, (value) => {
:colors="projectThemeColors"
:row-size="9"
:advanced="false"
data-nc="nc-modal-share-view__theme-picker"
@input="onChangeTheme"
/>
</div>
@ -287,7 +291,12 @@ watch(passwordProtected, (value) => {
<div>
<!-- Password Protection -->
<a-checkbox v-model:checked="passwordProtected" data-cy="nc-modal-share-view__with-password" class="!text-sm !my-1">
<a-checkbox
v-model:checked="passwordProtected"
data-cy="nc-modal-share-view__with-password"
class="!text-sm !my-1"
data-nc="nc-modal-share-view__with-password"
>
{{ $t('msg.info.beforeEnablePwd') }}
</a-checkbox>
@ -296,6 +305,7 @@ watch(passwordProtected, (value) => {
<a-input
v-model:value="shared.password"
data-cy="nc-modal-share-view__password"
data-nc="nc-modal-share-view__password"
size="small"
class="!text-xs max-w-[250px]"
type="password"
@ -304,6 +314,7 @@ watch(passwordProtected, (value) => {
<a-button
data-cy="nc-modal-share-view__save-password"
data-nc="nc-modal-share-view__save-password"
size="small"
class="!text-xs"
@click="saveShareLinkPassword"
@ -323,6 +334,7 @@ watch(passwordProtected, (value) => {
"
v-model:checked="allowCSVDownload"
data-cy="nc-modal-share-view__with-csv-download"
data-nc="nc-modal-share-view__with-csv-download"
class="!text-sm"
>
{{ $t('labels.downloadAllowed') }}

5
packages/nc-gui/components/smartsheet/toolbar/SortListMenu.vue

@ -53,7 +53,10 @@ watch(
</a-button>
</div>
<template #overlay>
<div class="bg-gray-50 p-6 shadow-lg menu-filter-dropdown min-w-[400px] max-h-[max(80vh,500px)] overflow-auto !border">
<div
class="bg-gray-50 p-6 shadow-lg menu-filter-dropdown min-w-[400px] max-h-[max(80vh,500px)] overflow-auto !border"
data-nc="nc-sorts-menu"
>
<div v-if="sorts?.length" class="sort-grid mb-2" @click.stop>
<template v-for="(sort, i) in sorts || []" :key="i">
<MdiCloseBox class="nc-sort-item-remove-btn text-grey self-center" small @click.stop="deleteSort(sort, i)" />

2
packages/nc-gui/components/smartsheet/toolbar/ViewActions.vue

@ -103,7 +103,7 @@ const { isSqlView } = useSmartsheetStoreOrThrow()
</a-button>
<template #overlay>
<a-menu class="ml-6 !text-sm !px-0 !py-2 !rounded">
<a-menu class="ml-6 !text-sm !px-0 !py-2 !rounded" data-nc="toolbar-actions">
<a-menu-item-group>
<a-sub-menu
v-if="isUIAllowed('view-type')"

2
packages/nc-gui/components/tabs/auth/user-management/ShareBase.vue

@ -136,7 +136,7 @@ onMounted(() => {
</script>
<template>
<div class="flex flex-col w-full">
<div class="flex flex-col w-full" data-nc="nc-share-base-sub-modal">
<div class="flex flex-row items-center space-x-0.5 pl-2 h-[0.8rem]">
<MdiOpenInNew />

2
packages/nc-gui/components/webhook/Drawer.vue

@ -31,7 +31,7 @@ async function editHook(hook: Record<string, any>) {
class="nc-drawer-webhook"
@keydown.esc="vModel = false"
>
<a-layout>
<a-layout class="nc-drawer-webhook-body">
<a-layout-content class="px-10 py-5 scrollbar-thin-primary">
<LazyWebhookEditor v-if="editOrAdd" :hook="currentHook" @back-to-list="editOrAdd = false" />

264
packages/nc-gui/lang/zh-Hans.json

@ -4,29 +4,29 @@
"load": "加载",
"open": "打开",
"close": "关闭",
"yes": "是",
"yes": "是",
"no": "否",
"ok": "行",
"and": "和",
"or": "或者",
"add": "添加",
"edit": "编辑",
"remove": "除",
"remove": "除",
"save": "保存",
"cancel": "取消",
"submit": "提交",
"create": "建",
"create": "建",
"duplicate": "复制",
"insert": "插入",
"delete": "删除",
"update": "更新",
"rename": "名",
"rename": "重命名",
"reload": "重新加载",
"reset": "重置",
"install": "安装",
"show": "示",
"show": "示",
"hide": "隐藏",
"showAll": "显示所有",
"showAll": "显示全部",
"hideAll": "隐藏全部",
"showMore": "显示更多",
"showOptions": "显示选项",
@ -34,7 +34,7 @@
"showMenu": "显示菜单",
"hideMenu": "隐藏菜单",
"addAll": "全部添加",
"removeAll": "移除所有",
"removeAll": "全部移除",
"signUp": "注册",
"signIn": "登录",
"signOut": "登出",
@ -74,7 +74,7 @@
"objects": {
"project": "项目",
"projects": "项目",
"table": "格",
"table": "格",
"tables": "表格",
"field": "字段",
"fields": "字段",
@ -109,7 +109,7 @@
"sqlVIew": "SQL 视图"
},
"datatype": {
"ID": "编号",
"ID": "ID",
"ForeignKey": "外键",
"SingleLineText": "单行文本",
"LongText": "长文本",
@ -190,14 +190,14 @@
"teamAndSettings": "团队和设置",
"apiDocs": "API 文档",
"importFromAirtable": "从 Airtable 导入",
"generateToken": "Generate Token",
"APIsAndSupport": "APIs & Support",
"helpCenter": "Help center",
"swaggerDocumentation": "Swagger Documentation",
"quickImportFrom": "Quick Import From",
"quickImport": "Quick Import",
"advancedSettings": "Advanced Settings",
"codeSnippet": "Code Snippet"
"generateToken": "生成令牌",
"APIsAndSupport": "API与支持",
"helpCenter": "帮助中心",
"swaggerDocumentation": "Swagger 文档",
"quickImportFrom": "快速导入从",
"quickImport": "快速导入",
"advancedSettings": "高级设置",
"codeSnippet": "代码片段"
},
"labels": {
"notifyVia": "通知通过",
@ -270,33 +270,33 @@
"primaryColor": "主色调",
"accentColor": "强调色",
"customTheme": "定制样式",
"requestDataSource": "Request a data source you need?",
"apiKey": "API Key",
"requestDataSource": "请求您需要的数据源?",
"apiKey": "API 密钥",
"sharedBase": "Shared Base",
"importData": "Import Data",
"importSecondaryViews": "Import Secondary Views",
"importData": "导入数据",
"importSecondaryViews": "导入次要视图",
"importRollupColumns": "Import Rollup Columns",
"importLookupColumns": "Import Lookup Columns",
"importAttachmentColumns": "Import Attachment Columns",
"importFormulaColumns": "Import Formula Columns",
"noData": "No Data",
"goToDashboard": "Go to Dashboard",
"importing": "Importing",
"importAttachmentColumns": "导入附件列",
"importFormulaColumns": "导入公式列",
"noData": "暂无数据",
"goToDashboard": "前往仪表板",
"importing": "导入中",
"flattenNested": "Flatten Nested",
"downloadAllowed": "Download allowed",
"weAreHiring": "We are Hiring!",
"primaryKey": "Primary key",
"hasMany": "has many",
"belongsTo": "belongs to",
"manyToMany": "have many to many relation",
"extraConnectionParameters": "Extra connection parameters",
"commentsOnly": "Comments only",
"documentation": "Documentation",
"subscribeNewsletter": "Subscribe to our weekly newsletter",
"signUpWithGoogle": "Sign up with Google",
"signInWithGoogle": "Sign in with Google",
"agreeToTos": "By signing up, you agree to the Terms of Service",
"welcomeToNc": "Welcome to NocoDB!"
"downloadAllowed": "允许下载",
"weAreHiring": "我们在招募!",
"primaryKey": "主键",
"hasMany": "有很多的",
"belongsTo": "属于",
"manyToMany": "多对多关系",
"extraConnectionParameters": "额外连接参数",
"commentsOnly": "仅注释",
"documentation": "文档",
"subscribeNewsletter": "订阅我们的每周新闻",
"signUpWithGoogle": "使用 Google 注册",
"signInWithGoogle": "使用 Google 登录",
"agreeToTos": "注册即表明您同意服务条款",
"welcomeToNc": "欢迎来到NocoDB!"
},
"activity": {
"createProject": "创建项目",
@ -366,7 +366,7 @@
"deleteRow": "删除行",
"deleteSelectedRow": "删除所选行",
"importExcel": "导入Excel",
"importCSV": "Import CSV",
"importCSV": "导入 CSV",
"downloadCSV": "下载为CSV",
"downloadExcel": "下载为XLSX",
"uploadCSV": "上传CSV",
@ -405,22 +405,22 @@
"editConnJson": "编辑链接JSON",
"sponsorUs": "赞助我们",
"sendEmail": "发送邮件",
"addUserToProject": "Add user to project",
"addUserToProject": "添加用户到项目",
"getApiSnippet": "生成代码",
"clearCell": "清除单元格内容",
"addFilterGroup": "Add Filter Group",
"addFilterGroup": "添加筛选器组",
"linkRecord": "链接记录",
"addNewRecord": "新增记录",
"useConnectionUrl": "Use Connection URL",
"toggleCommentsDraw": "Toggle comments draw",
"expandRecord": "Expand Record",
"deleteRecord": "Delete Record",
"useConnectionUrl": "使用连接 URL",
"toggleCommentsDraw": "切换评论视图",
"expandRecord": "展开记录",
"deleteRecord": "删除记录",
"erd": {
"showColumns": "显示列",
"showPkAndFk": "显示主键和外键",
"showSqlViews": "显示 SQL 视图",
"showMMTables": "Show Many to Many tables",
"showJunctionTableNames": "Show Junction Table Names"
"showMMTables": "显示多到多表",
"showJunctionTableNames": "显示关联表名称"
},
"kanban": {
"collapseStack": "Collapse Stack",
@ -475,8 +475,8 @@
"noItemsFound": "未找到任何项目",
"defaultValue": "默认值",
"filterByEmail": "通过电子邮件过滤",
"filterQuery": "Filter query",
"selectField": "Select field"
"filterQuery": "过滤查询",
"selectField": "选择字段"
},
"msg": {
"info": {
@ -570,28 +570,28 @@
"addDefaultColumns": "添加默认列",
"tableNameInDb": "数据库中保存的表名",
"airtable": {
"credentials": "Where to find this?"
"credentials": "在哪里找到?"
},
"import": {
"clickOrDrag": "Click or drag file to this area to upload"
"clickOrDrag": "点击或拖动文件到此区域上传"
},
"metaDataRecreated": "Table metadata recreated successfully",
"invalidCredentials": "Invalid credentials",
"downloadingMoreFiles": "Downloading more files",
"copiedToClipboard": "Copied to clipboard",
"requriedFieldsCantBeMoved": "Required field can't be moved",
"updateNotAllowedWithoutPK": "Update not allowed for table which doesn't have primary key",
"autoIncFieldNotEditable": "Auto increment field is not editable",
"editingPKnotSupported": "Editing primary key not supported",
"deletedCache": "Deleted cache successfully",
"cacheEmpty": "Cache is empty",
"exportedCache": "Exported Cache Successfully",
"valueAlreadyInList": "This value is already in the list",
"noColumnsToUpdate": "No columns to update",
"tableDeleted": "Deleted table successfully",
"metaDataRecreated": "表元数据重新创建成功",
"invalidCredentials": "无效的凭据",
"downloadingMoreFiles": "下载更多文件",
"copiedToClipboard": "复制到剪贴板",
"requriedFieldsCantBeMoved": "不能移动必填字段",
"updateNotAllowedWithoutPK": "不允许更新没有主键的表",
"autoIncFieldNotEditable": "自动增量字段不可编辑",
"editingPKnotSupported": "不支持编辑主键",
"deletedCache": "删除缓存成功",
"cacheEmpty": "缓存为空",
"exportedCache": "导出缓存成功",
"valueAlreadyInList": "此值已经在列表中",
"noColumnsToUpdate": "没有要更新的列",
"tableDeleted": "已成功删除表",
"generatePublicShareableReadonlyBase": "Generate publicly shareable readonly base",
"deleteViewConfirmation": "Are you sure you want to delete this view?",
"deleteTableConfirmation": "Do you want to delete the table",
"deleteViewConfirmation": "您确定要删除此视图?",
"deleteTableConfirmation": "您想要删除该表吗?",
"showM2mTables": "Show M2M Tables",
"deleteKanbanStackConfirmation": "Deleting this stack will also remove the select option `{stackToBeDeleted}` from the `{groupingField}`. The records will move to the uncategorized stack."
},
@ -609,51 +609,51 @@
"passwdRequired": "密码必填",
"passwdLength": "您的密码必须至少为8个字符",
"passwdMismatch": "密码不匹配",
"completeRuleSet": "At least 8 characters with one Uppercase, one number and one special character",
"atLeast8Char": "At least 8 characters",
"atLeastOneUppercase": "One Uppercase letter",
"atLeastOneNumber": "One Number",
"atLeastOneSpecialChar": "One special character",
"allowedSpecialCharList": "Allowed special character list"
"completeRuleSet": "必须至少包含 8 个字符,其中不少于 1 个大写字母、不少于 1 个数字和 不少于 1 个特殊字符",
"atLeast8Char": "至少 8 个字符",
"atLeastOneUppercase": "一个大写字母",
"atLeastOneNumber": "一个数字",
"atLeastOneSpecialChar": "一个特殊字符",
"allowedSpecialCharList": "允许的特殊字符列表"
},
"invalidURL": "Invalid URL",
"internalError": "Some internal error occurred",
"templateGeneratorNotFound": "Template Generator cannot be found!",
"fileUploadFailed": "Failed to upload file",
"primaryColumnUpdateFailed": "Failed to update primary column",
"formDescriptionTooLong": "Data too long for Form Description",
"columnsRequired": "Following columns are required",
"selectAtleastOneColumn": "At least one column has to be selected",
"columnDescriptionNotFound": "Cannot find the destination column for",
"duplicateMappingFound": "Duplicate mapping found, please remove one of the mapping",
"nullValueViolatesNotNull": "Null value violates not-null constraint",
"sourceHasInvalidNumbers": "Source data contains some invalid numbers",
"sourceHasInvalidBoolean": "Source data contains some invalid boolean values",
"invalidForm": "Invalid Form",
"formValidationFailed": "Form validation failed",
"youHaveBeenSignedOut": "You have been signed out",
"failedToLoadList": "Failed to load list",
"failedToLoadChildrenList": "Failed to load children list",
"deleteFailed": "Delete failed",
"invalidURL": "无效的 URL",
"internalError": "发生了一些内部错误",
"templateGeneratorNotFound": "模板生成器无法找到!",
"fileUploadFailed": "文件上传失败",
"primaryColumnUpdateFailed": "更新主列失败",
"formDescriptionTooLong": "表单描述过长",
"columnsRequired": "以下列是必填列",
"selectAtleastOneColumn": "必须至少选择一列",
"columnDescriptionNotFound": "找不到目标列",
"duplicateMappingFound": "发现重复映射,请删除其中一个映射。",
"nullValueViolatesNotNull": "空值违反非空约束",
"sourceHasInvalidNumbers": "源数据包含一些无效数字",
"sourceHasInvalidBoolean": "源数据包含一些无效的布尔值",
"invalidForm": "无效的表单",
"formValidationFailed": "表单验证失败",
"youHaveBeenSignedOut": "您已注销",
"failedToLoadList": "加载列表失败",
"failedToLoadChildrenList": "加载子列表失败",
"deleteFailed": "删除失败",
"unlinkFailed": "撤消链接失败",
"rowUpdateFailed": "Row update failed",
"deleteRowFailed": "Failed to delete row",
"setFormDataFailed": "Failed to set form data",
"formViewUpdateFailed": "Failed to update form view",
"tableNameRequired": "Table name is required",
"nameShouldStartWithAnAlphabetOr_": "Name should start with an alphabet or _",
"followingCharactersAreNotAllowed": "Following characters are not allowed",
"columnNameRequired": "Column name is required",
"projectNameExceeds50Characters": "Project name exceeds 50 characters",
"projectNameCannotStartWithSpace": "Project name cannot start with space",
"requiredField": "Required field",
"ipNotAllowed": "IP not allowed",
"targetFileIsNotAnAcceptedFileType": "Target file is not an accepted file type",
"theAcceptedFileTypeIsCsv": "The accepted file type is .csv",
"theAcceptedFileTypesAreXlsXlsxXlsmOdsOts": "The accepted file types are .xls, .xlsx, .xlsm, .ods, .ots",
"parameterKeyCannotBeEmpty": "Parameter key cannot be empty",
"duplicateParameterKeysAreNotAllowed": "Duplicate parameter keys are not allowed",
"fieldRequired": "{value} cannot be empty."
"rowUpdateFailed": "行更新失败",
"deleteRowFailed": "删除行失败",
"setFormDataFailed": "设置表单数据失败",
"formViewUpdateFailed": "更新表单视图失败",
"tableNameRequired": "表名是必填项",
"nameShouldStartWithAnAlphabetOr_": "名称应该以字母或 _ 开头",
"followingCharactersAreNotAllowed": "不允许使用以下字符",
"columnNameRequired": "列名是必填项",
"projectNameExceeds50Characters": "项目名称超过 50 个字符",
"projectNameCannotStartWithSpace": "项目名称不能以空格开头",
"requiredField": "必填字段",
"ipNotAllowed": "被禁止的 IP",
"targetFileIsNotAnAcceptedFileType": "目标文件不是可接受的文件类型",
"theAcceptedFileTypeIsCsv": "接受的文件类型是 .csv",
"theAcceptedFileTypesAreXlsXlsxXlsmOdsOts": "可接受的文件类型是 .xls, .xlsx, .xlsm, .ods, .ots",
"parameterKeyCannotBeEmpty": "参数键不能为空",
"duplicateParameterKeysAreNotAllowed": "不允许重复的参数键",
"fieldRequired": "{value} 不能为空。"
},
"toast": {
"exportMetadata": "项目元数据成功导出",
@ -674,32 +674,32 @@
},
"success": {
"updatedUIACL": "已成功更新表的 UI ACL",
"pluginUninstalled": "Plugin uninstalled successfully",
"pluginSettingsSaved": "Plugin settings saved successfully",
"pluginTested": "Successfully tested plugin settings",
"tableRenamed": "Table renamed successfully",
"viewDeleted": "View deleted successfully",
"pluginUninstalled": "插件卸载成功",
"pluginSettingsSaved": "插件设置保存成功",
"pluginTested": "插件设置测试成功",
"tableRenamed": "表重命名成功",
"viewDeleted": "视图删除成功",
"primaryColumnUpdated": "成功更新为主列",
"tableDataExported": "Successfully exported all table data",
"tableDataExported": "成功导出所有表内数据",
"updated": "更新成功",
"sharedViewDeleted": "Deleted shared view successfully",
"viewRenamed": "View renamed successfully",
"tokenGenerated": "Token generated successfully",
"sharedViewDeleted": "共享视图删除成功",
"viewRenamed": "视图重命名成功",
"tokenGenerated": "令牌生成成功",
"tokenDeleted": "Token deleted successfully",
"userAddedToProject": "Successfully added user to project",
"userDeletedFromProject": "Successfully deleted user from project",
"inviteEmailSent": "Invite Email sent successfully",
"inviteURLCopied": "Invite URL copied to clipboard",
"shareableURLCopied": "Copied shareable base URL to clipboard!",
"embeddableHTMLCodeCopied": "Copied embeddable HTML code!",
"userAddedToProject": "添加用户到项目成功",
"userDeletedFromProject": "从项目中删除用户成功",
"inviteEmailSent": "邀请邮件发送成功",
"inviteURLCopied": "邀请URL已复制到剪贴板",
"shareableURLCopied": "已将可共享的基础URL复制到剪贴板!",
"embeddableHTMLCodeCopied": "已复制可嵌入的 HTML 代码!",
"userDetailsUpdated": "成功更新用户详细信息",
"tableDataImported": "Successfully imported table data",
"tableDataImported": "成功导入表数据",
"webhookUpdated": "Webhook 详细信息更新成功",
"webhookDeleted": "Hook deleted successfully",
"webhookTested": "Webhook tested successfully",
"webhookDeleted": "Hook 删除成功",
"webhookTested": "Webhook 测试成功",
"columnUpdated": "列已更新",
"columnCreated": "Column created",
"passwordChanged": "Password changed successfully. Please login again."
"columnCreated": "已创建列",
"passwordChanged": "密码修改成功。请重新登录。"
}
}
}

2
packages/nc-gui/layouts/base.vue

@ -57,7 +57,7 @@ hooks.hook('page:finish', () => {
</div>
<div class="!text-white flex justify-center">
<div v-show="isLoading" class="flex items-center gap-2 ml-3">
<div class="flex items-center gap-2 ml-3" data-nc="nc-loading">
{{ $t('general.loading') }}
<MdiReload :class="{ 'animate-infinite animate-spin': isLoading }" />

2
packages/nc-gui/layouts/shared-view.vue

@ -53,7 +53,7 @@ export default {
<div class="flex justify-center items-center">
<div class="flex items-center gap-2 ml-3 text-white">
<template v-if="isLoading">
<span class="text-white">{{ $t('general.loading') }}</span>
<span class="text-white" data-nc="nc-loading">{{ $t('general.loading') }}</span>
<MdiReload :class="{ 'animate-infinite animate-spin ': isLoading }" />
</template>

3
packages/nc-gui/lib/constants.ts

@ -4,8 +4,7 @@ export const NOCO = 'noco'
export const SYSTEM_COLUMNS = ['id', 'title', 'created_at', 'updated_at']
export const BASE_URL = process.env.NC_BACKEND_URL || (process.env.NODE_ENV === 'production' ? '..' : 'http://localhost:8080')
export const BASE_URL = import.meta.env.NC_BACKEND_URL || (process.env.NODE_ENV === 'production' ? '..' : 'http://localhost:8080')
/**
* Each permission value means the following
* `*` - which is wildcard, means all permissions are allowed

29476
packages/nc-gui/package-lock.json generated

File diff suppressed because it is too large Load Diff

19
packages/nc-gui/package.json

@ -1,5 +1,20 @@
{
"name": "nc-gui",
"description": "NocoDB Frontend",
"private": true,
"author": {
"name": "NocoDB",
"url": "https://nocodb.com/"
},
"homepage": "https://github.com/nocodb/nocodb",
"repository": {
"type": "git",
"url": "https://github.com/nocodb/nocodb.git"
},
"bugs": {
"url": "https://github.com/nocodb/nocodb/issues"
},
"license": "AGPL-3.0-or-later",
"web-types": "web-types.json",
"scripts": {
"build": "nuxi build",
@ -29,7 +44,6 @@
"file-saver": "^2.0.5",
"httpsnippet": "^2.0.0",
"jsep": "^1.3.6",
"json-schema-traverse": "^1.0.0",
"just-clone": "^6.1.1",
"jwt-decode": "^3.1.2",
"leaflet": "^1.9.2",
@ -68,7 +82,6 @@
"@intlify/vite-plugin-vue-i18n": "^6.0.1",
"@nuxt/image-edge": "^1.0.0-27657146.da85542",
"@types/axios": "^0.14.0",
"@types/d3": "^7.4.0",
"@types/dagre": "^0.7.48",
"@types/file-saver": "^2.0.5",
"@types/leaflet": "^1.9.0",
@ -87,7 +100,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"happy-dom": "^6.0.3",
"nuxt": "^3.0.0-rc.11",
"nuxt": "^3.0.0-rc.12",
"nuxt-windicss": "^2.5.0",
"prettier": "^2.7.1",
"sass": "^1.53.0",

1
packages/nc-gui/pages/[projectType]/[projectId]/index.vue

@ -229,6 +229,7 @@ onBeforeUnmount(reset)
<div
:style="{ width: isOpen ? 'calc(100% - 40px) pr-2' : '100%' }"
:class="[isOpen ? '' : 'justify-center']"
data-nc="nc-project-menu"
class="group cursor-pointer flex gap-1 items-center nc-project-menu overflow-hidden"
>
<template v-if="isOpen">

6
packages/nc-gui/pages/[projectType]/[projectId]/index/index.vue

@ -52,14 +52,14 @@ function onEdit(targetKey: number, action: 'add' | 'remove' | string) {
</div>
<a-tooltip v-if="tab.title?.length > 12" placement="bottom">
<div class="truncate">{{ tab.title }}</div>
<div class="truncate" :data-nc="`nc-root-tabs-${tab.title}`">{{ tab.title }}</div>
<template #title>
<div>{{ tab.title }}</div>
</template>
</a-tooltip>
<div v-else>{{ tab.title }}</div>
<div v-else :data-nc="`nc-root-tabs-${tab.title}`">{{ tab.title }}</div>
</div>
</template>
</a-tab-pane>
@ -68,7 +68,7 @@ function onEdit(targetKey: number, action: 'add' | 'remove' | string) {
<span class="flex-1" />
<div class="flex justify-center self-center mr-2 min-w-[115px]">
<div v-show="isLoading" class="flex items-center gap-2 ml-3 text-gray-200">
<div v-show="isLoading" class="flex items-center gap-2 ml-3 text-gray-200" data-nc="nc-loading">
{{ $t('general.loading') }}
<MdiLoading class="animate-infinite animate-spin" />

9
packages/nc-gui/pages/[projectType]/form/[viewId]/index/index.vue

@ -85,6 +85,7 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
<LazySmartsheetVirtualCell
v-if="isVirtualCol(field)"
class="mt-0 nc-input"
:data-nc="`nc-form-input-cell-${field.label || field.title}`"
:class="`nc-form-input-${field.title.replaceAll(' ', '')}`"
:column="field"
/>
@ -93,6 +94,7 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
v-else
v-model="formState[field.title]"
class="nc-input"
:data-nc="`nc-form-input-cell-${field.label || field.title}`"
:class="`nc-form-input-${field.title.replaceAll(' ', '')}`"
:column="field"
:edit-enabled="true"
@ -110,7 +112,12 @@ function isRequired(_columnObj: Record<string, any>, required = false) {
</div>
<div class="text-center mt-4">
<button type="submit" class="uppercase scaling-btn prose-sm" @click="submitForm">
<button
type="submit"
class="uppercase scaling-btn prose-sm"
data-nc="shared-form-submit-button"
@click="submitForm"
>
{{ $t('general.submit') }}
</button>
</div>

27
packages/nc-gui/pages/[projectType]/form/[viewId]/index/survey.vue

@ -208,12 +208,15 @@ onMounted(() => {
class="max-w-[max(33%,600px)] mx-auto flex flex-col justify-end"
>
<div class="px-4 md:px-0 flex flex-col justify-end">
<h1 class="prose-2xl font-bold self-center my-4" data-cy="nc-survey-form__heading">{{ sharedFormView.heading }}</h1>
<h1 class="prose-2xl font-bold self-center my-4" data-cy="nc-survey-form__heading" data-nc="nc-survey-form__heading">
{{ sharedFormView.heading }}
</h1>
<h2
v-if="sharedFormView.subheading && sharedFormView.subheading !== ''"
class="prose-lg text-slate-500 dark:text-slate-300 self-center mb-4 leading-6"
data-cy="nc-survey-form__sub-heading"
data-nc="nc-survey-form__sub-heading"
>
{{ sharedFormView?.subheading }}
</h2>
@ -228,7 +231,7 @@ onMounted(() => {
class="color-transition h-full flex flex-col mt-6 gap-4 w-full max-w-[max(33%,600px)] m-auto"
>
<div v-if="field && !submitted" class="flex flex-col gap-2">
<div class="flex nc-form-column-label">
<div class="flex nc-form-column-label" data-nc="nc-form-column-label">
<LazySmartsheetHeaderVirtualCell
v-if="isVirtualCol(field)"
:column="{ ...field, title: field.label || field.title }"
@ -252,6 +255,7 @@ onMounted(() => {
class="mt-0 nc-input"
:row="{ row: {}, oldRow: {}, rowMeta: {} }"
:data-cy="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`"
:data-nc="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`"
:column="field"
/>
@ -260,6 +264,7 @@ onMounted(() => {
v-model="formState[field.title]"
class="nc-input"
:data-cy="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`"
:data-nc="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`"
:column="field"
:edit-enabled="true"
/>
@ -272,6 +277,7 @@ onMounted(() => {
<div
class="block text-[14px]"
:class="field.uidt === UITypes.Checkbox ? 'text-center' : ''"
data-nc="nc-survey-form__field-description"
data-cy="nc-survey-form__field-description"
>
{{ field.description }}
@ -297,6 +303,7 @@ onMounted(() => {
type="submit"
class="uppercase scaling-btn prose-sm"
data-cy="nc-survey-form__btn-submit"
data-nc="nc-survey-form__btn-submit"
@click="submit"
>
{{ $t('general.submit') }}
@ -312,6 +319,7 @@ onMounted(() => {
<button
class="bg-opacity-100 scaling-btn flex items-center gap-1"
data-cy="nc-survey-form__btn-next"
data-nc="nc-survey-form__btn-next"
:class="[
v$.localState[field.title]?.$error ? 'after:!bg-gray-100 after:!ring-red-500' : '',
animationTarget === AnimationTarget.OkButton && isAnimating
@ -341,7 +349,11 @@ onMounted(() => {
<Transition name="slide-left">
<div v-if="submitted" class="flex flex-col justify-center items-center text-center">
<div class="text-lg px-6 py-3 bg-green-300 text-gray-700 rounded" data-cy="nc-survey-form__success-msg">
<div
class="text-lg px-6 py-3 bg-green-300 text-gray-700 rounded"
data-cy="nc-survey-form__success-msg"
data-nc="nc-survey-form__success-msg"
>
<template v-if="sharedFormView?.success_msg">
{{ sharedFormView?.success_msg }}
</template>
@ -365,6 +377,7 @@ onMounted(() => {
type="button"
class="scaling-btn bg-opacity-100"
data-cy="nc-survey-form__btn-submit-another-form"
data-nc="nc-survey-form__btn-submit-another-form"
@click="resetForm"
>
Submit Another Form
@ -378,7 +391,11 @@ onMounted(() => {
</div>
<template v-if="!submitted">
<div class="mb-24 md:my-4 select-none text-center text-gray-500 dark:text-slate-200" data-cy="nc-survey-form__footer">
<div
class="mb-24 md:my-4 select-none text-center text-gray-500 dark:text-slate-200"
data-cy="nc-survey-form__footer"
data-nc="nc-survey-form__footer"
>
{{ index + 1 }} / {{ formColumns?.length }}
</div>
</template>
@ -398,6 +415,7 @@ onMounted(() => {
"
class="p-0.5 flex items-center group color-transition"
data-cy="nc-survey-form__icon-prev"
data-nc="nc-survey-form__icon-prev"
@click="goPrevious()"
>
<MdiChevronLeft :class="isFirst ? 'text-gray-300' : 'group-hover:text-accent'" class="text-2xl md:text-md" />
@ -417,6 +435,7 @@ onMounted(() => {
"
class="p-0.5 flex items-center group color-transition"
data-cy="nc-survey-form__icon-next"
data-nc="nc-survey-form__icon-next"
@click="goNext()"
>
<MdiChevronRight

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save