@slingr/cli 0.0.1

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 (144) hide show
  1. package/README.md +320 -0
  2. package/bin/dev.cmd +3 -0
  3. package/bin/dev.js +5 -0
  4. package/bin/run.cmd +3 -0
  5. package/bin/run.js +5 -0
  6. package/dist/commands/cli-build.d.ts +9 -0
  7. package/dist/commands/cli-build.d.ts.map +1 -0
  8. package/dist/commands/cli-build.js +36 -0
  9. package/dist/commands/cli-build.js.map +1 -0
  10. package/dist/commands/create-app.d.ts +20 -0
  11. package/dist/commands/create-app.d.ts.map +1 -0
  12. package/dist/commands/create-app.js +246 -0
  13. package/dist/commands/create-app.js.map +1 -0
  14. package/dist/commands/ds.d.ts +28 -0
  15. package/dist/commands/ds.d.ts.map +1 -0
  16. package/dist/commands/ds.js +529 -0
  17. package/dist/commands/ds.js.map +1 -0
  18. package/dist/commands/gql.d.ts +22 -0
  19. package/dist/commands/gql.d.ts.map +1 -0
  20. package/dist/commands/gql.js +340 -0
  21. package/dist/commands/gql.js.map +1 -0
  22. package/dist/commands/infra/down.d.ts +13 -0
  23. package/dist/commands/infra/down.d.ts.map +1 -0
  24. package/dist/commands/infra/down.js +80 -0
  25. package/dist/commands/infra/down.js.map +1 -0
  26. package/dist/commands/infra/up.d.ts +13 -0
  27. package/dist/commands/infra/up.d.ts.map +1 -0
  28. package/dist/commands/infra/up.js +69 -0
  29. package/dist/commands/infra/up.js.map +1 -0
  30. package/dist/commands/infra/update.d.ts +14 -0
  31. package/dist/commands/infra/update.d.ts.map +1 -0
  32. package/dist/commands/infra/update.js +321 -0
  33. package/dist/commands/infra/update.js.map +1 -0
  34. package/dist/commands/run.d.ts +19 -0
  35. package/dist/commands/run.d.ts.map +1 -0
  36. package/dist/commands/run.js +315 -0
  37. package/dist/commands/run.js.map +1 -0
  38. package/dist/commands/setup.d.ts +18 -0
  39. package/dist/commands/setup.d.ts.map +1 -0
  40. package/dist/commands/setup.js +189 -0
  41. package/dist/commands/setup.js.map +1 -0
  42. package/dist/index.d.ts +2 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +8 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/projectStructure.d.ts +10 -0
  47. package/dist/projectStructure.d.ts.map +1 -0
  48. package/dist/projectStructure.js +153 -0
  49. package/dist/projectStructure.js.map +1 -0
  50. package/dist/scripts/generate-schema.d.ts +10 -0
  51. package/dist/scripts/generate-schema.d.ts.map +1 -0
  52. package/dist/scripts/generate-schema.js +130 -0
  53. package/dist/scripts/generate-schema.js.map +1 -0
  54. package/dist/scripts/generate-schema.ts +143 -0
  55. package/dist/templates/.github/copilot-instructions.md.template +17 -0
  56. package/dist/templates/config/datasource.ts.template +9 -0
  57. package/dist/templates/config/jest.config.ts +30 -0
  58. package/dist/templates/config/jest.setup.ts +1 -0
  59. package/dist/templates/config/tsconfig.json.template +30 -0
  60. package/dist/templates/dataSources/mysql.ts.template +13 -0
  61. package/dist/templates/dataSources/postgres.ts.template +13 -0
  62. package/dist/templates/dataset-generator-script.ts.template +140 -0
  63. package/dist/templates/datasets/mysql-default/Address.jsonl.template +4 -0
  64. package/dist/templates/datasets/mysql-default/App.jsonl.template +5 -0
  65. package/dist/templates/datasets/mysql-default/Company.jsonl.template +4 -0
  66. package/dist/templates/datasets/mysql-default/Person.jsonl.template +3 -0
  67. package/dist/templates/datasets/postgres-default/Address.jsonl.template +4 -0
  68. package/dist/templates/datasets/postgres-default/App.jsonl.template +5 -0
  69. package/dist/templates/datasets/postgres-default/Company.jsonl.template +4 -0
  70. package/dist/templates/datasets/postgres-default/Person.jsonl.template +3 -0
  71. package/dist/templates/docs/app-description.md.template +34 -0
  72. package/dist/templates/gql/codegen.yml.template +25 -0
  73. package/dist/templates/gql/index.ts.template +24 -0
  74. package/dist/templates/gql/operations.graphql.template +30 -0
  75. package/dist/templates/package.json.template +38 -0
  76. package/dist/templates/prompt-analysis.md.template +111 -0
  77. package/dist/templates/prompt-script-generation.md.template +259 -0
  78. package/dist/templates/src/Address.ts.template +31 -0
  79. package/dist/templates/src/App.ts.template +61 -0
  80. package/dist/templates/src/Company.ts.template +48 -0
  81. package/dist/templates/src/Models.test.ts.template +655 -0
  82. package/dist/templates/src/Person.test.ts.template +289 -0
  83. package/dist/templates/src/Person.ts.template +105 -0
  84. package/dist/templates/src/actions/index.ts.template +12 -0
  85. package/dist/templates/src/index.ts +66 -0
  86. package/dist/templates/src/types/gql.d.ts.template +18 -0
  87. package/dist/templates/vscode/extensions.json +3 -0
  88. package/dist/templates/vscode/settings.json +11 -0
  89. package/dist/utils/datasourceParser.d.ts +12 -0
  90. package/dist/utils/datasourceParser.d.ts.map +1 -0
  91. package/dist/utils/datasourceParser.js +91 -0
  92. package/dist/utils/datasourceParser.js.map +1 -0
  93. package/dist/utils/jsonlLoader.d.ts +140 -0
  94. package/dist/utils/jsonlLoader.d.ts.map +1 -0
  95. package/dist/utils/jsonlLoader.js +583 -0
  96. package/dist/utils/jsonlLoader.js.map +1 -0
  97. package/dist/utils/model-analyzer.d.ts +86 -0
  98. package/dist/utils/model-analyzer.d.ts.map +1 -0
  99. package/dist/utils/model-analyzer.js +458 -0
  100. package/dist/utils/model-analyzer.js.map +1 -0
  101. package/dist/utils/portChecker.d.ts +36 -0
  102. package/dist/utils/portChecker.d.ts.map +1 -0
  103. package/dist/utils/portChecker.js +308 -0
  104. package/dist/utils/portChecker.js.map +1 -0
  105. package/dist/utils/synthetic-data-generator.d.ts +74 -0
  106. package/dist/utils/synthetic-data-generator.d.ts.map +1 -0
  107. package/dist/utils/synthetic-data-generator.js +443 -0
  108. package/dist/utils/synthetic-data-generator.js.map +1 -0
  109. package/oclif.manifest.json +435 -0
  110. package/package.json +118 -0
  111. package/src/templates/.github/copilot-instructions.md.template +17 -0
  112. package/src/templates/config/datasource.ts.template +9 -0
  113. package/src/templates/config/jest.config.ts +30 -0
  114. package/src/templates/config/jest.setup.ts +1 -0
  115. package/src/templates/config/tsconfig.json.template +30 -0
  116. package/src/templates/dataSources/mysql.ts.template +13 -0
  117. package/src/templates/dataSources/postgres.ts.template +13 -0
  118. package/src/templates/dataset-generator-script.ts.template +140 -0
  119. package/src/templates/datasets/mysql-default/Address.jsonl.template +4 -0
  120. package/src/templates/datasets/mysql-default/App.jsonl.template +5 -0
  121. package/src/templates/datasets/mysql-default/Company.jsonl.template +4 -0
  122. package/src/templates/datasets/mysql-default/Person.jsonl.template +3 -0
  123. package/src/templates/datasets/postgres-default/Address.jsonl.template +4 -0
  124. package/src/templates/datasets/postgres-default/App.jsonl.template +5 -0
  125. package/src/templates/datasets/postgres-default/Company.jsonl.template +4 -0
  126. package/src/templates/datasets/postgres-default/Person.jsonl.template +3 -0
  127. package/src/templates/docs/app-description.md.template +34 -0
  128. package/src/templates/gql/codegen.yml.template +25 -0
  129. package/src/templates/gql/index.ts.template +24 -0
  130. package/src/templates/gql/operations.graphql.template +30 -0
  131. package/src/templates/package.json.template +38 -0
  132. package/src/templates/prompt-analysis.md.template +111 -0
  133. package/src/templates/prompt-script-generation.md.template +259 -0
  134. package/src/templates/src/Address.ts.template +31 -0
  135. package/src/templates/src/App.ts.template +61 -0
  136. package/src/templates/src/Company.ts.template +48 -0
  137. package/src/templates/src/Models.test.ts.template +655 -0
  138. package/src/templates/src/Person.test.ts.template +289 -0
  139. package/src/templates/src/Person.ts.template +105 -0
  140. package/src/templates/src/actions/index.ts.template +12 -0
  141. package/src/templates/src/index.ts +66 -0
  142. package/src/templates/src/types/gql.d.ts.template +18 -0
  143. package/src/templates/vscode/extensions.json +3 -0
  144. package/src/templates/vscode/settings.json +11 -0
package/README.md ADDED
@@ -0,0 +1,320 @@
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
320
+ ```
package/bin/dev.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node --loader ts-node/esm --no-warnings=ExperimentalWarning "%~dp0\dev" %*
package/bin/dev.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execute } = require('@oclif/core');
4
+
5
+ execute({ development: true, dir: __dirname });
package/bin/run.cmd ADDED
@@ -0,0 +1,3 @@
1
+ @echo off
2
+
3
+ node "%~dp0\run" %*
package/bin/run.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { execute } = require('@oclif/core');
4
+
5
+ execute({ dir: __dirname });
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class CliBuild extends Command {
3
+ static aliases: string[];
4
+ static description: string;
5
+ static examples: string[];
6
+ static strict: boolean;
7
+ run(): Promise<void>;
8
+ }
9
+ //# sourceMappingURL=cli-build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-build.d.ts","sourceRoot":"","sources":["../../src/commands/cli-build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAItC,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,OAAO;IAC3C,MAAM,CAAC,OAAO,WAAiB;IAC/B,MAAM,CAAC,WAAW,SACsH;IACxI,MAAM,CAAC,QAAQ,WAGb;IACF,MAAM,CAAC,MAAM,UAAS;IAET,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAsBlC"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const node_child_process_1 = require("node:child_process");
5
+ const node_path_1 = require("node:path");
6
+ class CliBuild extends core_1.Command {
7
+ static aliases = ['cli-build'];
8
+ static description = 'Rebuild the Slingr CLI tool itself. This command is used for CLI development and maintenance, not for building Slingr applications.';
9
+ static examples = [
10
+ '<%= config.bin %> <%= command.id %>',
11
+ 'Description: Use this command when you need to rebuild the Slingr CLI after making changes to the CLI codebase.',
12
+ ];
13
+ static strict = false;
14
+ async run() {
15
+ const cliRootPath = (0, node_path_1.join)(__dirname, '..', '..');
16
+ try {
17
+ this.log('Rebuilding Slingr CLI tool...');
18
+ (0, node_child_process_1.execSync)('npm run build', {
19
+ cwd: cliRootPath,
20
+ stdio: 'inherit',
21
+ });
22
+ this.log('Updating OCLIF manifest and documentation...');
23
+ (0, node_child_process_1.execSync)('npm run prepack', {
24
+ cwd: cliRootPath,
25
+ stdio: 'inherit',
26
+ });
27
+ this.log('Slingr CLI rebuild completed successfully!');
28
+ }
29
+ catch (error) {
30
+ this.error('Failed to rebuild Slingr CLI');
31
+ throw error;
32
+ }
33
+ }
34
+ }
35
+ exports.default = CliBuild;
36
+ //# sourceMappingURL=cli-build.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-build.js","sourceRoot":"","sources":["../../src/commands/cli-build.ts"],"names":[],"mappings":";;AAAA,sCAAsC;AACtC,2DAA8C;AAC9C,yCAAiC;AAEjC,MAAqB,QAAS,SAAQ,cAAO;IAC3C,MAAM,CAAC,OAAO,GAAG,CAAC,WAAW,CAAC,CAAC;IAC/B,MAAM,CAAC,WAAW,GAChB,qIAAqI,CAAC;IACxI,MAAM,CAAC,QAAQ,GAAG;QAChB,qCAAqC;QACrC,iHAAiH;KAClH,CAAC;IACF,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC;IAEf,KAAK,CAAC,GAAG;QACd,MAAM,WAAW,GAAG,IAAA,gBAAI,EAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;QAEhD,IAAI,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,+BAA+B,CAAC,CAAC;YAC1C,IAAA,6BAAQ,EAAC,eAAe,EAAE;gBACxB,GAAG,EAAE,WAAW;gBAChB,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;YACzD,IAAA,6BAAQ,EAAC,iBAAiB,EAAE;gBAC1B,GAAG,EAAE,WAAW;gBAChB,KAAK,EAAE,SAAS;aACjB,CAAC,CAAC;YAEH,IAAI,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;QACzD,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;YAC3C,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;;AA/BH,2BAgCC"}
@@ -0,0 +1,20 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class CreateApp extends Command {
3
+ static args: {
4
+ name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ static flags: {
9
+ backend: import("@oclif/core/interfaces").BooleanFlag<boolean>;
10
+ database: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
11
+ description: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
12
+ frontend: import("@oclif/core/interfaces").BooleanFlag<boolean>;
13
+ help: import("@oclif/core/interfaces").BooleanFlag<void>;
14
+ 'skip-setup': import("@oclif/core/interfaces").BooleanFlag<boolean>;
15
+ templates: import("@oclif/core/interfaces").BooleanFlag<boolean>;
16
+ type: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
17
+ };
18
+ run(): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=create-app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-app.d.ts","sourceRoot":"","sources":["../../src/commands/create-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,OAAO,EAAS,MAAM,aAAa,CAAC;AAQnD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,OAAO;IAC5C,OAAgB,IAAI;;MAKlB;IACF,OAAgB,WAAW,SAA6B;IACxD,OAAgB,QAAQ,WAMtB;IACF,OAAgB,KAAK;;;;;;;;;MAsCnB;IAEW,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;CAqMlC"}
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const core_1 = require("@oclif/core");
7
+ const fs_extra_1 = __importDefault(require("fs-extra"));
8
+ const inquirer_1 = __importDefault(require("inquirer"));
9
+ const node_path_1 = __importDefault(require("node:path"));
10
+ const child_process_1 = require("child_process");
11
+ const projectStructure_js_1 = require("../projectStructure.js");
12
+ class CreateApp extends core_1.Command {
13
+ static args = {
14
+ name: core_1.Args.string({
15
+ description: 'Name of the app to create',
16
+ required: false,
17
+ }),
18
+ };
19
+ static description = 'Create a new Slingr app';
20
+ static examples = [
21
+ '<%= config.bin %> <%= command.id %>',
22
+ '<%= config.bin %> <%= command.id %> my-app',
23
+ '<%= config.bin %> <%= command.id %> task-manager',
24
+ '<%= config.bin %> <%= command.id %> my-crm --type="CRM" --database=postgres --description="A CRM system for managing customers"',
25
+ '<%= config.bin %> <%= command.id %> my-crm --type="CRM" --database=postgres --description="A CRM system for managing customers" -T',
26
+ ];
27
+ static flags = {
28
+ backend: core_1.Flags.boolean({
29
+ allowNo: true,
30
+ char: 'b',
31
+ default: true,
32
+ description: 'Include backend for the app (default: true)',
33
+ hidden: true,
34
+ }),
35
+ database: core_1.Flags.string({
36
+ char: 'd',
37
+ description: 'Database to use (postgres or mysql)',
38
+ options: ['postgres', 'mysql'],
39
+ }),
40
+ description: core_1.Flags.string({
41
+ char: 'D',
42
+ description: 'Description of what the app needs to do',
43
+ }),
44
+ frontend: core_1.Flags.boolean({
45
+ allowNo: true,
46
+ char: 'f',
47
+ default: true,
48
+ description: 'Include frontend for the app (default: true)',
49
+ hidden: true,
50
+ }),
51
+ help: core_1.Flags.help({ char: 'h' }),
52
+ 'skip-setup': core_1.Flags.boolean({
53
+ default: false,
54
+ description: 'Skip the final setup prompt for non-interactive usage',
55
+ }),
56
+ templates: core_1.Flags.boolean({
57
+ char: 'T',
58
+ default: false,
59
+ description: 'Include template models and tests in the project',
60
+ }),
61
+ type: core_1.Flags.string({
62
+ char: 't',
63
+ description: 'Type of app (e.g., CRM, task manager, ERP)',
64
+ }),
65
+ };
66
+ async run() {
67
+ const { args, flags } = await this.parse(CreateApp);
68
+ let appName = args.name;
69
+ // Display Slingr branding
70
+ this.log('');
71
+ this.log('╔═══════════════════════════════════════╗');
72
+ this.log('║ ║');
73
+ this.log('║ Slingr App Builder ║');
74
+ this.log('║ ║');
75
+ this.log('╚═══════════════════════════════════════╝');
76
+ this.log('');
77
+ // If no name is provided, ask for it
78
+ if (appName) {
79
+ // Check if directory already exists when name is provided as argument
80
+ const targetDir = node_path_1.default.join(process.cwd(), appName);
81
+ if (await fs_extra_1.default.pathExists(targetDir)) {
82
+ this.error(`Directory ${appName} already exists!`);
83
+ }
84
+ }
85
+ else {
86
+ const response = await inquirer_1.default.prompt([
87
+ {
88
+ message: 'What is the name of your app?',
89
+ name: 'name',
90
+ prefix: '\u001B[36m›\u001B[0m',
91
+ type: 'input',
92
+ async validate(input) {
93
+ if (input.length === 0) {
94
+ return 'Please provide a name for your app';
95
+ }
96
+ const targetDir = node_path_1.default.join(process.cwd(), input);
97
+ if (await fs_extra_1.default.pathExists(targetDir)) {
98
+ return `Directory ${input} already exists!`;
99
+ }
100
+ return true;
101
+ },
102
+ },
103
+ ]);
104
+ appName = response.name;
105
+ // Clear the question line and show with checkmark
106
+ process.stdout.write('\u001B[1A\u001B[2K');
107
+ this.log(`\u001B[32m✓\u001B[0m What is the name of your app? ${appName}`);
108
+ }
109
+ let answers;
110
+ // Check if all required flags are provided (backend/frontend are now always true by default)
111
+ // Database defaults to postgres
112
+ const hasAllFlags = flags.type && flags.description;
113
+ if (hasAllFlags) {
114
+ // Use provided flags, backend and frontend default to true, database defaults to postgres
115
+ answers = {
116
+ appType: flags.type,
117
+ database: flags.database || 'postgres',
118
+ description: flags.description,
119
+ hasBackend: flags.backend ?? true,
120
+ hasFrontend: flags.frontend ?? true,
121
+ includeTemplates: flags.templates ?? false,
122
+ };
123
+ }
124
+ else {
125
+ // Ask questions one by one to show checkmarks after each answer
126
+ const appTypeAnswer = await inquirer_1.default.prompt([
127
+ {
128
+ default: flags.type,
129
+ message: 'What type of app are you creating?',
130
+ name: 'appType',
131
+ prefix: '\u001B[36m›\u001B[0m',
132
+ suffix: ' (e.g., CRM, task manager, ERP)',
133
+ type: 'input',
134
+ validate: (input) => input.length > 0 || 'Please provide an app type',
135
+ },
136
+ ]);
137
+ // Clear the question line and show with checkmark
138
+ process.stdout.write('\u001B[1A\u001B[2K');
139
+ this.log(`\u001B[32m✓\u001B[0m What type of app are you creating? ${appTypeAnswer.appType}`);
140
+ const descriptionAnswer = await inquirer_1.default.prompt([
141
+ {
142
+ default: flags.description,
143
+ message: 'Please describe what your app needs to do:',
144
+ name: 'description',
145
+ prefix: '\u001B[36m›\u001B[0m',
146
+ type: 'input',
147
+ validate: (input) => input.length > 0 || 'Please provide a description',
148
+ },
149
+ ]);
150
+ // Clear the question line and show with checkmark
151
+ process.stdout.write('\u001B[1A\u001B[2K');
152
+ this.log(`\u001B[32m✓\u001B[0m Please describe what your app needs to do: ${descriptionAnswer.description}`);
153
+ const templatesAnswer = await inquirer_1.default.prompt([
154
+ {
155
+ default: flags.templates ?? false,
156
+ message: 'Include template models and tests?',
157
+ name: 'includeTemplates',
158
+ prefix: '\u001B[36m›\u001B[0m',
159
+ type: 'confirm',
160
+ },
161
+ ]);
162
+ // Clear the question line and show with checkmark
163
+ process.stdout.write('\u001B[1A\u001B[2K');
164
+ this.log(`\u001B[32m✓\u001B[0m Include template models and tests? ${templatesAnswer.includeTemplates ? 'Yes' : 'No'}`);
165
+ // Show database default
166
+ this.log(`\u001B[32m✓\u001B[0m Database: PostgreSQL (default)`);
167
+ // Set backend, frontend to true and database to postgres as they're no longer asked
168
+ answers = {
169
+ appType: appTypeAnswer.appType,
170
+ database: flags.database || 'postgres',
171
+ description: descriptionAnswer.description,
172
+ hasBackend: true,
173
+ hasFrontend: true,
174
+ includeTemplates: templatesAnswer.includeTemplates,
175
+ };
176
+ }
177
+ this.log('');
178
+ this.log(`✨ Creating the app ${appName}...`);
179
+ this.log('');
180
+ // Create the project structure
181
+ const targetDir = node_path_1.default.resolve(process.cwd(), appName);
182
+ await (0, projectStructure_js_1.createProjectStructure)(appName, answers);
183
+ this.log('✅ Project created successfully!');
184
+ this.log('');
185
+ this.log(`📁 Location: ${targetDir}`);
186
+ this.log('');
187
+ this.log('🏁 All done! Your Slingr app is ready.');
188
+ this.log('');
189
+ this.log('To get started:');
190
+ this.log(` cd ${appName}`);
191
+ this.log(` npm install`);
192
+ this.log(` npx slingr gql generate-schema`);
193
+ this.log(` npx slingr gql generate-sdk`);
194
+ this.log('');
195
+ this.log('Or run the complete setup automatically:');
196
+ this.log(` cd ${appName} && npx slingr setup`);
197
+ // Ask if user wants to run setup automatically (unless skip-setup flag is used)
198
+ if (!flags['skip-setup']) {
199
+ const { runSetup } = await inquirer_1.default.prompt([
200
+ {
201
+ type: 'confirm',
202
+ name: 'runSetup',
203
+ message: '🚀 Would you like to run the complete setup now? (recommended)',
204
+ default: true,
205
+ },
206
+ ]);
207
+ if (runSetup) {
208
+ this.log('');
209
+ this.log('Running complete setup...');
210
+ this.log('This will install dependencies, generate schema and SDK, and build the application.');
211
+ this.log('');
212
+ try {
213
+ // Change to project directory and run setup
214
+ const projectPath = node_path_1.default.resolve(appName);
215
+ process.chdir(projectPath);
216
+ (0, child_process_1.execSync)('npx slingr setup', {
217
+ stdio: 'inherit',
218
+ cwd: projectPath,
219
+ });
220
+ this.log('');
221
+ this.log('🎉 Your Slingr application is ready!');
222
+ this.log('');
223
+ this.log('To start developing:');
224
+ this.log(` cd ${appName}`);
225
+ this.log(' npm run dev');
226
+ this.log('');
227
+ this.log('Or to run with infrastructure:');
228
+ this.log(` cd ${appName}`);
229
+ this.log(' npx slingr run');
230
+ }
231
+ catch (error) {
232
+ this.log('');
233
+ this.warn('Setup encountered an issue, but your application was created successfully.');
234
+ this.log('You can run the setup manually:');
235
+ this.log(` cd ${appName}`);
236
+ this.log(' npx slingr setup');
237
+ }
238
+ }
239
+ }
240
+ this.log('');
241
+ this.log('Happy coding! 🚀');
242
+ this.log('');
243
+ }
244
+ }
245
+ exports.default = CreateApp;
246
+ //# sourceMappingURL=create-app.js.map