@slingr/cli 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/LICENSE.txt +202 -0
  2. package/README.md +490 -319
  3. package/bin/dev.cmd +2 -2
  4. package/bin/dev.js +5 -5
  5. package/bin/run.cmd +2 -2
  6. package/bin/run.js +4 -4
  7. package/bin/slingr +1 -0
  8. package/dist/commands/build.d.ts +20 -0
  9. package/dist/commands/build.d.ts.map +1 -0
  10. package/dist/commands/build.js +206 -0
  11. package/dist/commands/build.js.map +1 -0
  12. package/dist/commands/create-app.d.ts +0 -1
  13. package/dist/commands/create-app.d.ts.map +1 -1
  14. package/dist/commands/create-app.js +38 -57
  15. package/dist/commands/create-app.js.map +1 -1
  16. package/dist/commands/debug.d.ts +28 -0
  17. package/dist/commands/debug.d.ts.map +1 -0
  18. package/dist/commands/debug.js +474 -0
  19. package/dist/commands/debug.js.map +1 -0
  20. package/dist/commands/ds.d.ts +14 -1
  21. package/dist/commands/ds.d.ts.map +1 -1
  22. package/dist/commands/ds.js +450 -121
  23. package/dist/commands/ds.js.map +1 -1
  24. package/dist/commands/gql.d.ts +1 -1
  25. package/dist/commands/gql.d.ts.map +1 -1
  26. package/dist/commands/gql.js +190 -184
  27. package/dist/commands/gql.js.map +1 -1
  28. package/dist/commands/infra/down.d.ts.map +1 -1
  29. package/dist/commands/infra/down.js +8 -7
  30. package/dist/commands/infra/down.js.map +1 -1
  31. package/dist/commands/infra/up.d.ts.map +1 -1
  32. package/dist/commands/infra/up.js +8 -7
  33. package/dist/commands/infra/up.js.map +1 -1
  34. package/dist/commands/infra/update.d.ts +1 -0
  35. package/dist/commands/infra/update.d.ts.map +1 -1
  36. package/dist/commands/infra/update.js +33 -69
  37. package/dist/commands/infra/update.js.map +1 -1
  38. package/dist/commands/run.d.ts +29 -2
  39. package/dist/commands/run.d.ts.map +1 -1
  40. package/dist/commands/run.js +628 -130
  41. package/dist/commands/run.js.map +1 -1
  42. package/dist/commands/setup.d.ts +1 -1
  43. package/dist/commands/setup.d.ts.map +1 -1
  44. package/dist/commands/setup.js +34 -71
  45. package/dist/commands/setup.js.map +1 -1
  46. package/dist/commands/sync-metadata.d.ts +15 -0
  47. package/dist/commands/sync-metadata.d.ts.map +1 -0
  48. package/dist/commands/sync-metadata.js +225 -0
  49. package/dist/commands/sync-metadata.js.map +1 -0
  50. package/dist/commands/users.d.ts +30 -0
  51. package/dist/commands/users.d.ts.map +1 -0
  52. package/dist/commands/users.js +472 -0
  53. package/dist/commands/users.js.map +1 -0
  54. package/dist/commands/views.d.ts +11 -0
  55. package/dist/commands/views.d.ts.map +1 -0
  56. package/dist/commands/views.js +73 -0
  57. package/dist/commands/views.js.map +1 -0
  58. package/dist/projectStructure.d.ts +2 -2
  59. package/dist/projectStructure.d.ts.map +1 -1
  60. package/dist/projectStructure.js +281 -69
  61. package/dist/projectStructure.js.map +1 -1
  62. package/dist/scripts/generate-metadata.d.ts +13 -0
  63. package/dist/scripts/generate-metadata.d.ts.map +1 -0
  64. package/dist/scripts/generate-metadata.js +412 -0
  65. package/dist/scripts/generate-metadata.js.map +1 -0
  66. package/dist/scripts/generate-metadata.ts +498 -0
  67. package/dist/scripts/generate-schema.d.ts +1 -1
  68. package/dist/scripts/generate-schema.js +168 -74
  69. package/dist/scripts/generate-schema.js.map +1 -1
  70. package/dist/scripts/generate-schema.ts +258 -143
  71. package/dist/templates/.env.template +23 -0
  72. package/dist/templates/.firebaserc.template +5 -0
  73. package/dist/templates/.github/copilot-instructions.md.template +652 -17
  74. package/dist/templates/backend/Dockerfile.template +30 -0
  75. package/dist/templates/config/datasource.ts.template +12 -9
  76. package/dist/templates/config/jest.config.ts +30 -30
  77. package/dist/templates/config/jest.setup.ts +1 -1
  78. package/dist/templates/config/tsconfig.json.template +50 -29
  79. package/dist/templates/dataSources/mysql.ts.template +16 -13
  80. package/dist/templates/dataSources/postgres.ts.template +15 -13
  81. package/dist/templates/dataset-generator-script.ts.template +139 -139
  82. package/dist/templates/datasets/mysql-default/.slingr-schema.json.template +5 -0
  83. package/dist/templates/datasets/mysql-default/Address.jsonl.template +3 -3
  84. package/dist/templates/datasets/mysql-default/App.jsonl.template +4 -4
  85. package/dist/templates/datasets/mysql-default/Company.jsonl.template +3 -3
  86. package/dist/templates/datasets/mysql-default/Person.jsonl.template +2 -2
  87. package/dist/templates/datasets/mysql-default/User.jsonl.template +1 -0
  88. package/dist/templates/datasets/mysql-default/instructions.md.template +1 -0
  89. package/dist/templates/datasets/postgres-default/.slingr-schema.json.template +5 -0
  90. package/dist/templates/datasets/postgres-default/Address.jsonl.template +3 -3
  91. package/dist/templates/datasets/postgres-default/App.jsonl.template +4 -4
  92. package/dist/templates/datasets/postgres-default/Company.jsonl.template +3 -3
  93. package/dist/templates/datasets/postgres-default/Person.jsonl.template +2 -2
  94. package/dist/templates/datasets/postgres-default/User.jsonl.template +1 -0
  95. package/dist/templates/datasets/postgres-default/instructions.md.template +1 -0
  96. package/dist/templates/docker-compose.prod-test.yml.template +32 -0
  97. package/dist/templates/docker-compose.yml.template +24 -0
  98. package/dist/templates/docs/app-description.md.template +33 -33
  99. package/dist/templates/firebase.json.template +68 -0
  100. package/dist/templates/frontend/.umirc.ts.template +23 -0
  101. package/dist/templates/frontend/package.json.template +45 -0
  102. package/dist/templates/frontend/public/config.json +6 -0
  103. package/dist/templates/frontend/public/logo.svg +6 -0
  104. package/dist/templates/frontend/src/app.tsx.template +44 -0
  105. package/dist/templates/frontend/src/global.less.template +117 -0
  106. package/dist/templates/frontend/src/layouts/MainLayout.tsx.template +75 -0
  107. package/dist/templates/frontend/src/types/graphql-augmentation.d.ts.template +44 -0
  108. package/dist/templates/frontend/src/views/customViews/user/UserCreateView.tsx.template +18 -0
  109. package/dist/templates/frontend/src/views/customViews/user/UserEditView.tsx.template +29 -0
  110. package/dist/templates/frontend/src/views/customViews/user/UserReadView.tsx.template +24 -0
  111. package/dist/templates/frontend/src/views/customViews/user/UserTableView.tsx.template +38 -0
  112. package/dist/templates/frontend/src/views/customViews/welcome.tsx.template +34 -0
  113. package/dist/templates/frontend/tsconfig.json.template +50 -0
  114. package/dist/templates/gql/codegen.yml.template +25 -25
  115. package/dist/templates/gql/index.ts.template +17 -24
  116. package/dist/templates/gql/operations.graphql.template +30 -30
  117. package/dist/templates/ops/README.md.template +1045 -0
  118. package/dist/templates/ops/cloudbuild.yaml.template +161 -0
  119. package/dist/templates/ops/scripts/_utils.js.template +217 -0
  120. package/dist/templates/ops/scripts/deploy.js.template +145 -0
  121. package/dist/templates/ops/scripts/setup-gcp.js.template +330 -0
  122. package/dist/templates/ops/scripts/setup-secrets.js.template +76 -0
  123. package/dist/templates/ops/scripts/test-prod-local.js.template +49 -0
  124. package/dist/templates/package.json.template +50 -38
  125. package/dist/templates/pnpm-workspace.yaml.template +3 -0
  126. package/dist/templates/prompt-analysis.md.template +110 -110
  127. package/dist/templates/prompt-script-generation.md.template +258 -258
  128. package/dist/templates/src/Address.ts.template +28 -31
  129. package/dist/templates/src/App.ts.template +17 -61
  130. package/dist/templates/src/Company.ts.template +41 -47
  131. package/dist/templates/src/Models.test.ts.template +654 -654
  132. package/dist/templates/src/Person.test.ts.template +289 -289
  133. package/dist/templates/src/Person.ts.template +90 -105
  134. package/dist/templates/src/actions/index.ts.template +11 -11
  135. package/dist/templates/src/auth/permissions.ts.template +34 -0
  136. package/dist/templates/src/data/App.ts.template +48 -0
  137. package/dist/templates/src/data/User.ts.template +35 -0
  138. package/dist/templates/src/types/gql.d.ts.template +17 -17
  139. package/dist/templates/vscode/extensions.json +4 -3
  140. package/dist/templates/vscode/settings.json +17 -11
  141. package/dist/templates/workspace-package.json.template +21 -0
  142. package/dist/utils/buildCache.d.ts +12 -0
  143. package/dist/utils/buildCache.d.ts.map +1 -0
  144. package/dist/utils/buildCache.js +102 -0
  145. package/dist/utils/buildCache.js.map +1 -0
  146. package/dist/utils/checkFramework.d.ts +27 -0
  147. package/dist/utils/checkFramework.d.ts.map +1 -0
  148. package/dist/utils/checkFramework.js +104 -0
  149. package/dist/utils/checkFramework.js.map +1 -0
  150. package/dist/utils/datasourceParser.d.ts +11 -0
  151. package/dist/utils/datasourceParser.d.ts.map +1 -1
  152. package/dist/utils/datasourceParser.js +154 -56
  153. package/dist/utils/datasourceParser.js.map +1 -1
  154. package/dist/utils/dockerManager.d.ts +25 -0
  155. package/dist/utils/dockerManager.d.ts.map +1 -0
  156. package/dist/utils/dockerManager.js +281 -0
  157. package/dist/utils/dockerManager.js.map +1 -0
  158. package/dist/utils/infraFileParser.d.ts +26 -0
  159. package/dist/utils/infraFileParser.d.ts.map +1 -0
  160. package/dist/utils/infraFileParser.js +75 -0
  161. package/dist/utils/infraFileParser.js.map +1 -0
  162. package/dist/utils/jsonlLoader.d.ts +91 -12
  163. package/dist/utils/jsonlLoader.d.ts.map +1 -1
  164. package/dist/utils/jsonlLoader.js +674 -63
  165. package/dist/utils/jsonlLoader.js.map +1 -1
  166. package/dist/utils/model-analyzer.d.ts.map +1 -1
  167. package/dist/utils/model-analyzer.js +67 -13
  168. package/dist/utils/model-analyzer.js.map +1 -1
  169. package/dist/utils/userManagement.d.ts +57 -0
  170. package/dist/utils/userManagement.d.ts.map +1 -0
  171. package/dist/utils/userManagement.js +288 -0
  172. package/dist/utils/userManagement.js.map +1 -0
  173. package/dist/utils/viewsGenerator.d.ts +15 -0
  174. package/dist/utils/viewsGenerator.d.ts.map +1 -0
  175. package/dist/utils/viewsGenerator.js +311 -0
  176. package/dist/utils/viewsGenerator.js.map +1 -0
  177. package/oclif.manifest.json +445 -20
  178. package/package.json +29 -26
  179. package/src/templates/.env.template +23 -0
  180. package/src/templates/.firebaserc.template +5 -0
  181. package/src/templates/.github/copilot-instructions.md.template +652 -17
  182. package/src/templates/backend/Dockerfile.template +30 -0
  183. package/src/templates/config/datasource.ts.template +12 -9
  184. package/src/templates/config/jest.config.ts +30 -30
  185. package/src/templates/config/jest.setup.ts +1 -1
  186. package/src/templates/config/tsconfig.json.template +50 -29
  187. package/src/templates/dataSources/mysql.ts.template +16 -13
  188. package/src/templates/dataSources/postgres.ts.template +15 -13
  189. package/src/templates/dataset-generator-script.ts.template +139 -139
  190. package/src/templates/datasets/mysql-default/.slingr-schema.json.template +5 -0
  191. package/src/templates/datasets/mysql-default/Address.jsonl.template +3 -3
  192. package/src/templates/datasets/mysql-default/App.jsonl.template +4 -4
  193. package/src/templates/datasets/mysql-default/Company.jsonl.template +3 -3
  194. package/src/templates/datasets/mysql-default/Person.jsonl.template +2 -2
  195. package/src/templates/datasets/mysql-default/User.jsonl.template +1 -0
  196. package/src/templates/datasets/mysql-default/instructions.md.template +1 -0
  197. package/src/templates/datasets/postgres-default/.slingr-schema.json.template +5 -0
  198. package/src/templates/datasets/postgres-default/Address.jsonl.template +3 -3
  199. package/src/templates/datasets/postgres-default/App.jsonl.template +4 -4
  200. package/src/templates/datasets/postgres-default/Company.jsonl.template +3 -3
  201. package/src/templates/datasets/postgres-default/Person.jsonl.template +2 -2
  202. package/src/templates/datasets/postgres-default/User.jsonl.template +1 -0
  203. package/src/templates/datasets/postgres-default/instructions.md.template +1 -0
  204. package/src/templates/docker-compose.prod-test.yml.template +32 -0
  205. package/src/templates/docker-compose.yml.template +24 -0
  206. package/src/templates/docs/app-description.md.template +33 -33
  207. package/src/templates/firebase.json.template +68 -0
  208. package/src/templates/frontend/.umirc.ts.template +23 -0
  209. package/src/templates/frontend/package.json.template +45 -0
  210. package/src/templates/frontend/public/config.json +6 -0
  211. package/src/templates/frontend/public/logo.svg +6 -0
  212. package/src/templates/frontend/src/app.tsx.template +44 -0
  213. package/src/templates/frontend/src/global.less.template +117 -0
  214. package/src/templates/frontend/src/layouts/MainLayout.tsx.template +75 -0
  215. package/src/templates/frontend/src/types/graphql-augmentation.d.ts.template +44 -0
  216. package/src/templates/frontend/src/views/customViews/user/UserCreateView.tsx.template +18 -0
  217. package/src/templates/frontend/src/views/customViews/user/UserEditView.tsx.template +29 -0
  218. package/src/templates/frontend/src/views/customViews/user/UserReadView.tsx.template +24 -0
  219. package/src/templates/frontend/src/views/customViews/user/UserTableView.tsx.template +38 -0
  220. package/src/templates/frontend/src/views/customViews/welcome.tsx.template +34 -0
  221. package/src/templates/frontend/tsconfig.json.template +50 -0
  222. package/src/templates/gql/codegen.yml.template +25 -25
  223. package/src/templates/gql/index.ts.template +17 -24
  224. package/src/templates/gql/operations.graphql.template +30 -30
  225. package/src/templates/ops/README.md.template +1045 -0
  226. package/src/templates/ops/cloudbuild.yaml.template +161 -0
  227. package/src/templates/ops/scripts/_utils.js.template +217 -0
  228. package/src/templates/ops/scripts/deploy.js.template +145 -0
  229. package/src/templates/ops/scripts/setup-gcp.js.template +330 -0
  230. package/src/templates/ops/scripts/setup-secrets.js.template +76 -0
  231. package/src/templates/ops/scripts/test-prod-local.js.template +49 -0
  232. package/src/templates/package.json.template +50 -38
  233. package/src/templates/pnpm-workspace.yaml.template +3 -0
  234. package/src/templates/prompt-analysis.md.template +110 -110
  235. package/src/templates/prompt-script-generation.md.template +258 -258
  236. package/src/templates/src/Address.ts.template +28 -31
  237. package/src/templates/src/App.ts.template +17 -61
  238. package/src/templates/src/Company.ts.template +41 -47
  239. package/src/templates/src/Models.test.ts.template +654 -654
  240. package/src/templates/src/Person.test.ts.template +289 -289
  241. package/src/templates/src/Person.ts.template +90 -105
  242. package/src/templates/src/actions/index.ts.template +11 -11
  243. package/src/templates/src/auth/permissions.ts.template +34 -0
  244. package/src/templates/src/data/App.ts.template +48 -0
  245. package/src/templates/src/data/User.ts.template +35 -0
  246. package/src/templates/src/types/gql.d.ts.template +17 -17
  247. package/src/templates/vscode/extensions.json +4 -3
  248. package/src/templates/vscode/settings.json +17 -11
  249. package/src/templates/workspace-package.json.template +21 -0
  250. package/dist/templates/src/index.ts +0 -66
  251. package/src/templates/src/index.ts +0 -66
package/README.md CHANGED
@@ -1,320 +1,491 @@
1
- # Slingr CLI
2
-
3
- A command-line tool for creating and managing Slingr applications.
4
-
5
- ## Getting Started
6
-
7
- ### Quick Installation (Recommended)
8
-
9
- For application developers who want to start using Slingr CLI immediately:
10
-
11
- #### macOS and Linux
12
-
13
- ```bash
14
- # Download and run the installation script
15
- curl -fsSL https://raw.githubusercontent.com/slingr-stack/framework/main/scripts/install.sh | bash
16
- ```
17
-
18
- Or download and run manually:
19
-
20
- ```bash
21
- curl -fsSL https://raw.githubusercontent.com/slingr-stack/framework/main/scripts/install.sh -o install.sh
22
- chmod +x install.sh
23
- ./install.sh
24
- ```
25
-
26
- #### Windows (PowerShell)
27
-
28
- ```powershell
29
- # Download and run the installation script
30
- irm https://raw.githubusercontent.com/slingr-stack/framework/main/scripts/install.ps1 | iex
31
- ```
32
-
33
- Or download and run manually:
34
-
35
- ```powershell
36
- # Run PowerShell as Administrator
37
- Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
38
- Invoke-WebRequest -Uri https://raw.githubusercontent.com/slingr-stack/framework/main/scripts/install.ps1 -OutFile install.ps1
39
- .\install.ps1
40
- ```
41
-
42
- The installation script will:
43
-
44
- - Validate Node.js 18+, npm, and TypeScript 5+
45
- - Check Docker and Docker Compose (optional but recommended)
46
- - Guide you through CLI installation
47
-
48
- ### Manual Installation
49
-
50
- If you prefer to install the CLI manually or are contributing to the framework:
51
-
52
- ```bash
53
- # Clone the repository
54
- git clone https://github.com/slingr-stack/framework.git
55
- cd framework/cli
56
-
57
- # Install dependencies
58
- npm install
59
-
60
- # Build the CLI
61
- npm run build
62
-
63
- # Link globally to use the 'slingr' command
64
- npm link
65
- ```
66
-
67
- You can also build from the repository root:
68
-
69
- ```bash
70
- npm run build:cli
71
- ```
72
-
73
- ## Documentation
74
-
75
- For detailed setup instructions, troubleshooting, and more information:
76
-
77
- | Document | Description |
78
- | ----------------------------------------------------------------- | ------------------------------------- |
79
- | [Repository Overview](../README.md) | Main repository setup and overview |
80
- | [Setup Guide](../docs/setup-guide.md) | Detailed installation and setup guide |
81
- | [Framework Documentation](../framework/README.md) | Core framework usage and examples |
82
- | [VS Code Extension Documentation](../vs-code-extension/README.md) | IDE extension features and setup |
83
-
84
- See the [framework documentation](../framework/docs) for detailed guides on data models, actions, and database configuration.
85
-
86
- ## Testing the CLI
87
-
88
- To test the CLI commands:
89
-
90
- ```bash
91
- # Display help
92
- slingr --help
93
-
94
- # Run tests (from repository root)
95
- npm run test:cli
96
- ```
97
-
98
- ## CLI Development (For Contributors)
99
-
100
- If you're contributing to the CLI itself:
101
-
102
- ```bash
103
- # Rebuild the CLI tool
104
- slingr cli-build
105
-
106
- # Or from repository root
107
- npm run build:cli
108
- ```
109
-
110
- For more information on contributing to the Slingr Framework, see the [Repository Overview](../README.md) and [Setup Guide](../docs/setup-guide.md).
111
-
112
- ## Usage
113
-
114
- ### Create a new application
115
-
116
- ```bash
117
- slingr create-app my-app
118
- ```
119
-
120
- This command will:
121
-
122
- 1. Ask you questions about your application type and requirements
123
- 2. Create a project directory with the specified name
124
- 3. Set up a complete TypeScript project structure with database configuration
125
- 4. Generate sample files and configurations
126
- 5. Configure VS Code settings and recommended extensions
127
- 6. Set up Docker infrastructure files for database management
128
-
129
- #### Create-app flags
130
-
131
- You can skip the interactive prompts by using command flags.
132
-
133
- Available flags:
134
-
135
- - `--type, -t`: Type of application (e.g., CRM, task manager, ERP)
136
- - `--backend, -b`: Include backend for the application (default: true)
137
- - `--frontend, -f`: Include frontend for the application (default: true)
138
- - `--database, -d`: Database to use (postgres or mysql)
139
- - `--description, -D`: Description of what the application needs to do
140
- - `--templates, -T`: Include data models and sample data (default: `false`)
141
- - `--skip-infra, -i`: Skip infrastructure setup and checks
142
-
143
- For example:
144
-
145
- ```bash
146
- # Create app with all flags
147
- slingr create-app my-crm --type="CRM" --backend --frontend --database=postgres --description="A CRM system for managing customers"
148
-
149
- # Create app without frontend
150
- slingr create-app my-api --type="API" --backend --no-frontend --database=mysql --description="A REST API for data management"
151
-
152
- # Create app with sample data models and datasets
153
- slingr create-app my-erp --type="ERP" --backend --frontend --database=postgres --description="An ERP system for business management" --templates
154
- ```
155
-
156
- ### Run your application
157
-
158
- ```bash
159
- slingr run
160
- ```
161
-
162
- This command will:
163
-
164
- 1. Build the slingr-framework if needed
165
- 2. Compile your TypeScript code
166
- 3. Check and start Docker infrastructure services
167
- 4. Run your application with hot reload
168
-
169
- ### Manage datasets
170
-
171
- ```bash
172
- # Load default dataset for a datasource
173
- slingr ds postgres load
174
-
175
- # Load specific dataset
176
- slingr ds postgres load custom-dataset
177
-
178
- # Load dataset for MySQL datasource
179
- slingr ds mysql load default
180
-
181
- # Reset datasource infrastructure (clears container and volume data)
182
- slingr ds postgres reset
183
- ```
184
-
185
- These commands help you load JSONL datasets into your database and reset datasource infrastructure for a clean state when testing and development require it.
186
-
187
- ### Infrastructure management
188
-
189
- ```bash
190
- # Update infrastructure for all datasources
191
- slingr infra update --all
192
-
193
- # Update infrastructure for specific datasource
194
- slingr infra update --file postgres.ts
195
-
196
- # Start infrastructure services
197
- slingr infra up
198
-
199
- # Stop infrastructure services
200
- slingr infra down
201
- ```
202
-
203
- Infrastructure commands help you manage Docker containers for your databases.
204
-
205
- ## Generated Project Structure
206
-
207
- When you create a new app with the `--templates` flag, the following structure is generated:
208
-
209
- ```
210
- your-app/
211
- ├── .vscode/
212
- │ ├── extensions.json # Recommended VS Code extensions
213
- │ └── settings.json # VS Code settings for optimal development
214
- ├── docs/
215
- │ └── app-description.md # Generated app documentation
216
- ├── src/
217
- │ ├── index.ts # Main application entry point
218
- │ ├── data/ # Data models (generated with --templates flag)
219
- │ │ ├── App.ts # Application model
220
- │ │ ├── Address.ts # Address model (shared composition example)
221
- │ │ ├── Company.ts # Company model example
222
- │ │ ├── Person.ts # Person model example
223
- │ │ ├── Models.test.ts # Comprehensive integration tests
224
- │ │ └── Person.test.ts # Person model unit tests
225
- │ ├── dataSources/ # Database configurations
226
- │ │ ├── postgres.ts # PostgreSQL datasource config
227
- │ │ └── mysql.ts # MySQL datasource config (if selected)
228
- │ └── datasets/ # Sample data for development (generated with --templates flag)
229
- │ ├── postgres-default/
230
- │ │ ├── App.jsonl
231
- │ │ ├── Company.jsonl
232
- │ │ └── Person.jsonl
233
- │ └── mysql-default/ # If MySQL was selected
234
- │ ├── App.jsonl
235
- │ ├── Company.jsonl
236
- │ └── Person.jsonl
237
- ├── docker-compose.yml # Database infrastructure (generated on first run)
238
- ├── jest.config.ts # Jest configuration for testing
239
- ├── jest.setup.ts # Jest setup file
240
- ├── package.json # Project configuration with slingr-framework dependency
241
- └── tsconfig.json # TypeScript configuration
242
- ```
243
-
244
- **Note**: Sample data models and tests are only generated when using the `--templates` flag. Without it, you get a minimal project structure with just the basic setup.
245
-
246
- ## Features
247
-
248
- ### Core Development Features
249
-
250
- - **TypeScript Setup**: Pre-configured TypeScript with strict settings
251
- - **Testing**: Jest test framework with comprehensive sample tests (when using `--templates`)
252
- - **Linting**: ESLint with TypeScript support
253
- - **VS Code Integration**: Optimized settings and extension recommendations
254
- - **Sample Code**: Working model examples with validation and relationships (with `--templates` flag)
255
-
256
- ### Database & Infrastructure
257
-
258
- - **Multi-Database Support**: PostgreSQL and MySQL with automatic Docker setup
259
- - **Infrastructure as Code**: Automatic Docker Compose generation for databases
260
- - **Dataset Management**: Load JSONL datasets into your databases for testing
261
- - **Port Conflict Detection**: Automatic detection and resolution of port conflicts
262
- - **Health Checks**: Built-in database health monitoring
263
-
264
- ### Development Workflow
265
-
266
- - **Hot Reload**: Automatic application restart on code changes
267
- - **Docker Integration**: Seamless database container management
268
- - **Framework Building**: Automatic slingr-framework compilation when needed
269
- - **Dependency Management**: Smart dependency installation based on database choice
270
-
271
- ## Database Support
272
-
273
- The CLI supports the following databases with automatic infrastructure setup:
274
-
275
- ### PostgreSQL
276
-
277
- - **Default Port**: 5433
278
- - **Docker Image**: postgres:15-alpine
279
- - **Health Checks**: Built-in pg_isready monitoring
280
- - **Data Persistence**: Automatic volume management
281
-
282
- ### MySQL
283
-
284
- - **Default Port**: 3306
285
- - **Docker Image**: mysql:8.0
286
- - **Health Checks**: Built-in mysqladmin ping monitoring
287
- - **Data Persistence**: Automatic volume management
288
-
289
- ## Dataset Management
290
-
291
- The CLI includes a powerful dataset management system:
292
-
293
- ### JSONL Format
294
-
295
- Datasets are stored in JSONL (JSON Lines) format, with one JSON object per line:
296
-
297
- ```jsonl
298
- {"id": 1, "name": "John Doe", "email": "john@example.com"}
299
- {"id": 2, "name": "Jane Smith", "email": "jane@example.com"}
300
- ```
301
-
302
- ### Loading Datasets
303
-
304
- ```bash
305
- # Load default dataset for PostgreSQL
306
- slingr ds postgres load
307
-
308
- # Load specific dataset
309
- slingr ds postgres load my-custom-dataset
310
- ```
311
-
312
- ### Dataset Structure
313
-
314
- Datasets are organized by datasource and dataset name:
315
-
316
- ```
317
- src/datasets/
318
- ├── postgres-default/ # Default PostgreSQL dataset
319
- └── mysql-custom/ # Custom MySQL dataset
1
+ # Slingr CLI
2
+
3
+ A command-line tool for creating and managing Slingr applications.
4
+
5
+ ## Getting Started
6
+
7
+ ### Installation
8
+
9
+ ```bash
10
+ # Clone the repository
11
+ git clone https://github.com/slingr-stack/framework.git
12
+ cd framework/cli
13
+
14
+ # Install dependencies
15
+ npm install
16
+
17
+ # Build the CLI
18
+ npm run build
19
+
20
+ # Link globally to use the 'slingr' command
21
+ npm link
22
+ ```
23
+
24
+ You can also build from the repository root:
25
+
26
+ ```bash
27
+ npm run build:cli
28
+ ```
29
+
30
+ ## Documentation
31
+
32
+ For detailed CLI documentation and guides:
33
+
34
+ | Document | Description |
35
+ | ----------------------------------------------------------------- | ------------------------------------- |
36
+ | [CLI Introduction](../docs/cli/intro.md) | Getting started with the CLI |
37
+ | [CLI Architecture](../docs/cli/architecture.md) | CLI design and architecture |
38
+ | [Run Command Guide](../docs/cli/run-command.md) | Using the run command |
39
+ | [Repository Overview](../README.md) | Main repository setup and overview |
40
+ | [Setup Guide](../docs/framework/setup-guide.md) | Detailed installation and setup guide |
41
+ | [Framework Documentation](../framework/README.md) | Core framework usage and examples |
42
+ | [VS Code Extension Documentation](../vs-code-extension/README.md) | IDE extension features and setup |
43
+
44
+ See the [framework documentation](../docs/framework/) for detailed guides on data models, actions, and database configuration.
45
+
46
+ ## Testing the CLI
47
+
48
+ To test the CLI commands:
49
+
50
+ ```bash
51
+ # Display help
52
+ slingr --help
53
+
54
+ # Run tests (from repository root)
55
+ npm run test:cli
56
+ ```
57
+
58
+ ## CLI Development (For Contributors)
59
+
60
+ If you're contributing to the CLI itself:
61
+
62
+ ```bash
63
+ # Rebuild the CLI tool
64
+ slingr cli-build
65
+
66
+ # Or from repository root
67
+ npm run build:cli
68
+ ```
69
+
70
+ For more information on contributing to the Slingr Framework, see the [Repository Overview](../README.md) and [Setup Guide](../docs/framework/setup-guide.md).
71
+
72
+ ## Usage
73
+
74
+ ### Create a new application
75
+
76
+ ```bash
77
+ slingr create-app my-app
78
+ ```
79
+
80
+ This command will:
81
+
82
+ 1. Ask you questions about your application type and requirements
83
+ 2. Create a project directory with the specified name
84
+ 3. Set up a complete TypeScript project structure with database configuration
85
+ 4. Generate sample files and configurations
86
+ 5. Configure VS Code settings and recommended extensions
87
+ 6. Set up Docker infrastructure files for database management
88
+
89
+ After creating your app, you can set it up with:
90
+
91
+ ```bash
92
+ cd my-app
93
+ npm run setup
94
+ ```
95
+
96
+ This will install dependencies, generate the GraphQL schema, and generate the TypeScript SDK. Alternatively, you can run each step manually:
97
+
98
+ ```bash
99
+ cd my-app
100
+ npm install
101
+ npx slingr gql generate-schema
102
+ npx slingr gql generate-sdk
103
+ ```
104
+
105
+ #### Create-app flags
106
+
107
+ You can skip the interactive prompts by using command flags.
108
+
109
+ Available flags:
110
+
111
+ - `--type, -t`: Type of application (e.g., CRM, task manager, ERP)
112
+ - `--backend, -b`: Include backend for the application (default: true)
113
+ - `--frontend, -f`: Include frontend for the application (default: true)
114
+ - `--database, -d`: Database to use (postgres or mysql)
115
+ - `--description, -D`: Description of what the application needs to do
116
+ - `--templates, -T`: Include data models and sample data (default: `false`)
117
+ - `--skip-infra, -i`: Skip infrastructure setup and checks
118
+
119
+ For example:
120
+
121
+ ```bash
122
+ # Create app with all flags
123
+ slingr create-app my-crm --type="CRM" --backend --frontend --database=postgres --description="A CRM system for managing customers"
124
+
125
+ # Create app without frontend
126
+ slingr create-app my-api --type="API" --backend --no-frontend --database=mysql --description="A REST API for data management"
127
+
128
+ # Create app with sample data models and datasets
129
+ slingr create-app my-erp --type="ERP" --backend --frontend --database=postgres --description="An ERP system for business management" --templates
130
+ ```
131
+
132
+ ### Run your application
133
+
134
+ ```bash
135
+ slingr run
136
+ ```
137
+
138
+ This command will:
139
+
140
+ 1. Build the @slingr-framework if needed
141
+ 2. Build the UI (if present) with Vite
142
+ 3. Compile your TypeScript code
143
+ 4. Check and start Docker infrastructure services
144
+ 5. Run your application with hot reload
145
+ 6. Serve the UI and GraphQL API on the same port (default: 3000)
146
+
147
+ Access your application:
148
+
149
+ - Frontend UI: `http://localhost:3000/`
150
+ - GraphQL API: `http://localhost:3000/graphql`
151
+
152
+ ### Debug your application
153
+
154
+ ```bash
155
+ slingr debug
156
+ ```
157
+
158
+ This command runs your application with Node.js debugging enabled, allowing you to attach a debugger for troubleshooting and development. The command performs the same setup as `slingr run` but starts the application with the Node.js inspector enabled. The UI is also built and served alongside the backend.
159
+
160
+ #### Debug command options
161
+
162
+ - `--inspect-port, -p`: Port for Node.js debugger (default: 9229)
163
+ - `--inspect-brk, -b`: Break before user code starts (useful for debugging startup issues)
164
+ - `--skip-infra, -i`: Skip infrastructure setup and checks
165
+
166
+ #### Examples
167
+
168
+ ```bash
169
+ # Run with default debug port (9229)
170
+ slingr debug
171
+
172
+ # Run with custom debug port
173
+ slingr debug --inspect-port 9230
174
+
175
+ # Break before user code starts (useful for debugging initialization)
176
+ slingr debug --inspect-brk
177
+
178
+ # Run without starting infrastructure services
179
+ slingr debug --skip-infra
180
+ ```
181
+
182
+ #### Attaching a debugger
183
+
184
+ Once the application is running in debug mode, you can attach a debugger:
185
+
186
+ **VS Code:**
187
+
188
+ 1. Create a debug configuration in `.vscode/launch.json`:
189
+
190
+ ```json
191
+ {
192
+ "type": "node",
193
+ "request": "attach",
194
+ "name": "Attach to Slingr",
195
+ "port": 9229,
196
+ "skipFiles": ["<node_internals>/**"]
197
+ }
198
+ ```
199
+
200
+ 2. Press F5 or use the "Run and Debug" panel to attach
201
+
202
+ **Chrome DevTools:**
203
+
204
+ 1. Open Chrome and navigate to `chrome://inspect`
205
+ 2. Click "Open dedicated DevTools for Node"
206
+ 3. Your application should appear in the list of inspectable targets
207
+
208
+ ### Manage datasets
209
+
210
+ ```bash
211
+ # Load default dataset for a datasource
212
+ slingr ds postgres load
213
+
214
+ # Load specific dataset
215
+ slingr ds postgres load custom-dataset
216
+
217
+ # Load dataset for MySQL datasource
218
+ slingr ds mysql load default
219
+
220
+ # Reset datasource infrastructure (clears container and volume data)
221
+ slingr ds postgres reset
222
+ ```
223
+
224
+ These commands help you load JSONL datasets into your database and reset datasource infrastructure for a clean state when testing and development require it.
225
+
226
+ ### User Management
227
+
228
+ Every new Slingr application comes with built-in authentication and user management. A default System user is created automatically when you load the initial dataset.
229
+
230
+ #### List Users
231
+
232
+ ```bash
233
+ slingr users list
234
+ ```
235
+
236
+ Displays all users in the application with their status and roles.
237
+
238
+ #### Create User
239
+
240
+ ```bash
241
+ # Interactive mode
242
+ slingr users create
243
+
244
+ # With flags
245
+ slingr users create \
246
+ --email john@example.com \
247
+ --first-name John \
248
+ --last-name Doe \
249
+ --password secret123 \
250
+ --roles "Admin,User"
251
+ ```
252
+
253
+ Creates a new user in the application. Passwords are automatically hashed using bcrypt.
254
+
255
+ #### Manage Passwords
256
+
257
+ ```bash
258
+ # Set a new password (interactive)
259
+ slingr users set-password john@example.com
260
+
261
+ # Set a new password (with flag)
262
+ slingr users set-password john@example.com --new-password newpass123
263
+
264
+ # Reset password (generates random password)
265
+ slingr users reset-password john@example.com
266
+ ```
267
+
268
+ The reset-password command generates a secure random password and displays it once.
269
+
270
+ #### Activate/Deactivate Users
271
+
272
+ ```bash
273
+ # Activate a user
274
+ slingr users activate john@example.com
275
+
276
+ # Deactivate a user
277
+ slingr users deactivate john@example.com
278
+ ```
279
+
280
+ Deactivated users cannot log in to the application.
281
+
282
+ #### Delete User
283
+
284
+ ```bash
285
+ # Delete with confirmation
286
+ slingr users delete john@example.com
287
+
288
+ # Delete without confirmation
289
+ slingr users delete john@example.com --force
290
+ ```
291
+
292
+ **Note**: System users cannot be deleted for security reasons.
293
+
294
+ #### User Management Options
295
+
296
+ - `--datasource, -d`: Specify datasource name (auto-discovered from User model if not specified)
297
+ - `--force, -f`: Skip confirmation prompts
298
+ - `--help, -h`: Show command help
299
+
300
+ **Note**: All user commands automatically discover the datasource configured in your User model, so you typically don't need to specify the `--datasource` flag.
301
+
302
+ #### Default System User
303
+
304
+ When you create a new app and load the initial dataset, a System user is created with:
305
+
306
+ - **Email**: sys@app.com
307
+ - **Password**: 12345678 (change this in production!)
308
+ - **Role**: System (full access)
309
+
310
+ To change the System user password:
311
+
312
+ ```bash
313
+ slingr users set-password sys@app.com
314
+ ```
315
+
316
+ ### Infrastructure management
317
+
318
+ ```bash
319
+ # Update infrastructure for all datasources
320
+ slingr infra update --all
321
+
322
+ # Update infrastructure for specific datasource
323
+ slingr infra update --file postgres.ts
324
+
325
+ # Start infrastructure services
326
+ slingr infra up
327
+
328
+ # Stop infrastructure services
329
+ slingr infra down
330
+ ```
331
+
332
+ Infrastructure commands help you manage Docker containers for your databases.
333
+
334
+ ### GraphQL API
335
+
336
+ The Slingr Framework includes built-in GraphQL API support powered by Apollo Server. These commands help you generate GraphQL schemas and SDKs.
337
+
338
+ #### Generate GraphQL schema
339
+
340
+ ```bash
341
+ # Generate schema in generated/gql/schema.graphql
342
+ slingr gql generate-schema
343
+
344
+ # Keep Apollo Server running after generating schema
345
+ slingr gql generate-schema --no-exit
346
+ ```
347
+
348
+ This command generates the GraphQL schema file from your application's actions and models.
349
+
350
+ #### Generate GraphQL SDK
351
+
352
+ ```bash
353
+ # Generate type-safe SDK (automatically generates schema if needed)
354
+ slingr gql generate-sdk
355
+ ```
356
+
357
+ This command generates a type-safe GraphQL SDK in `generated/gql/sdk.ts` that you can use to interact with your API. Use it in your code with:
358
+
359
+ ```typescript
360
+ import gql from '@gql';
361
+
362
+ const result = await gql.yourQuery();
363
+ ```
364
+
365
+ ### CLI development
366
+
367
+ ```bash
368
+ # Rebuild the CLI tool itself (for CLI developers)
369
+ slingr cli-build
370
+ ```
371
+
372
+ ## Generated Project Structure
373
+
374
+ When you create a new app with the `--templates` flag, the following structure is generated:
375
+
376
+ ```
377
+ your-app/
378
+ ├── .vscode/
379
+ │ ├── extensions.json # Recommended VS Code extensions
380
+ │ └── settings.json # VS Code settings for optimal development
381
+ ├── docs/
382
+ │ └── app-description.md # Generated app documentation
383
+ ├── src/
384
+ │ ├── index.ts # Main application entry point
385
+ │ ├── data/ # Data models
386
+ │ │ ├── User.ts # User model with authentication (always generated)
387
+ │ │ ├── App.ts # Application model (with --templates)
388
+ │ │ ├── Address.ts # Address model (with --templates)
389
+ │ │ ├── Company.ts # Company model (with --templates)
390
+ │ │ ├── Person.ts # Person model (with --templates)
391
+ │ │ ├── Models.test.ts # Integration tests (with --templates)
392
+ │ │ └── Person.test.ts # Unit tests (with --templates)
393
+ │ ├── auth/ # Authentication and permissions (always generated)
394
+ │ │ └── permissions.ts # Permission definitions
395
+ │ ├── dataSources/ # Database configurations
396
+ │ │ ├── postgres.ts # PostgreSQL datasource config
397
+ │ │ └── mysql.ts # MySQL datasource config (if selected)
398
+ │ └── datasets/ # Sample data for development
399
+ │ ├── postgres-default/
400
+ │ │ ├── User.jsonl # System user (always generated)
401
+ │ │ ├── App.jsonl # (with --templates)
402
+ │ │ ├── Company.jsonl # (with --templates)
403
+ │ │ └── Person.jsonl # (with --templates)
404
+ │ └── mysql-default/ # If MySQL was selected
405
+ │ ├── User.jsonl
406
+ │ └── ... (same structure)
407
+ ├── .env.example # Environment variables template
408
+ ├── docker-compose.yml # Database infrastructure (generated on first run)
409
+ ├── jest.config.ts # Jest configuration for testing
410
+ ├── jest.setup.ts # Jest setup file
411
+ ├── package.json # Project configuration with @slingr-framework dependency
412
+ └── tsconfig.json # TypeScript configuration
413
+ ```
414
+
415
+ **Note**: Sample data models and tests are only generated when using the `--templates` flag. Without it, you get a minimal project structure with just the basic setup.
416
+
417
+ ## Features
418
+
419
+ ### Core Development Features
420
+
421
+ - **TypeScript Setup**: Pre-configured TypeScript with strict settings
422
+ - **Testing**: Jest test framework with comprehensive sample tests (when using `--templates`)
423
+ - **Linting**: ESLint with TypeScript support
424
+ - **VS Code Integration**: Optimized settings and extension recommendations
425
+ - **Sample Code**: Working model examples with validation and relationships (with `--templates` flag)
426
+
427
+ ### Database & Infrastructure
428
+
429
+ - **Multi-Database Support**: PostgreSQL and MySQL with automatic Docker setup
430
+ - **Infrastructure as Code**: Automatic Docker Compose generation for databases
431
+ - **Dataset Management**: Load JSONL datasets into your databases for testing
432
+ - **Port Conflict Detection**: Automatic detection and resolution of port conflicts
433
+ - **Health Checks**: Built-in database health monitoring
434
+
435
+ ### Development Workflow
436
+
437
+ - **Hot Reload**: Automatic application restart on code changes
438
+ - **Docker Integration**: Seamless database container management
439
+ - **Framework Building**: Automatic @slingr-framework compilation when needed
440
+ - **Dependency Management**: Smart dependency installation based on database choice
441
+
442
+ ## Database Support
443
+
444
+ The CLI supports the following databases with automatic infrastructure setup:
445
+
446
+ ### PostgreSQL
447
+
448
+ - **Default Port**: 5433
449
+ - **Docker Image**: postgres:15-alpine
450
+ - **Health Checks**: Built-in pg_isready monitoring
451
+ - **Data Persistence**: Automatic volume management
452
+
453
+ ### MySQL
454
+
455
+ - **Default Port**: 3306
456
+ - **Docker Image**: mysql:8.0
457
+ - **Health Checks**: Built-in mysqladmin ping monitoring
458
+ - **Data Persistence**: Automatic volume management
459
+
460
+ ## Dataset Management
461
+
462
+ The CLI includes a powerful dataset management system:
463
+
464
+ ### JSONL Format
465
+
466
+ Datasets are stored in JSONL (JSON Lines) format, with one JSON object per line:
467
+
468
+ ```jsonl
469
+ {"id": 1, "name": "John Doe", "email": "john@example.com"}
470
+ {"id": 2, "name": "Jane Smith", "email": "jane@example.com"}
471
+ ```
472
+
473
+ ### Loading Datasets
474
+
475
+ ```bash
476
+ # Load default dataset for PostgreSQL
477
+ slingr ds postgres load
478
+
479
+ # Load specific dataset
480
+ slingr ds postgres load my-custom-dataset
481
+ ```
482
+
483
+ ### Dataset Structure
484
+
485
+ Datasets are organized by datasource and dataset name:
486
+
487
+ ```
488
+ src/datasets/
489
+ ├── postgres-default/ # Default PostgreSQL dataset
490
+ └── mysql-custom/ # Custom MySQL dataset
320
491
  ```