pgpm 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 (121) hide show
  1. package/README.md +416 -0
  2. package/commands/add.d.ts +7 -0
  3. package/commands/add.js +86 -0
  4. package/commands/admin-users/add.d.ts +4 -0
  5. package/commands/admin-users/add.js +89 -0
  6. package/commands/admin-users/bootstrap.d.ts +4 -0
  7. package/commands/admin-users/bootstrap.js +50 -0
  8. package/commands/admin-users/remove.d.ts +4 -0
  9. package/commands/admin-users/remove.js +82 -0
  10. package/commands/admin-users.d.ts +4 -0
  11. package/commands/admin-users.js +68 -0
  12. package/commands/analyze.d.ts +4 -0
  13. package/commands/analyze.js +21 -0
  14. package/commands/clear.d.ts +3 -0
  15. package/commands/clear.js +59 -0
  16. package/commands/deploy.d.ts +4 -0
  17. package/commands/deploy.js +146 -0
  18. package/commands/explorer.d.ts +3 -0
  19. package/commands/explorer.js +94 -0
  20. package/commands/export.d.ts +3 -0
  21. package/commands/export.js +129 -0
  22. package/commands/extension.d.ts +4 -0
  23. package/commands/extension.js +48 -0
  24. package/commands/init/index.d.ts +7 -0
  25. package/commands/init/index.js +47 -0
  26. package/commands/init/module.d.ts +4 -0
  27. package/commands/init/module.js +71 -0
  28. package/commands/init/workspace.d.ts +4 -0
  29. package/commands/init/workspace.js +52 -0
  30. package/commands/install.d.ts +4 -0
  31. package/commands/install.js +37 -0
  32. package/commands/kill.d.ts +3 -0
  33. package/commands/kill.js +107 -0
  34. package/commands/migrate/deps.d.ts +4 -0
  35. package/commands/migrate/deps.js +186 -0
  36. package/commands/migrate/init.d.ts +4 -0
  37. package/commands/migrate/init.js +65 -0
  38. package/commands/migrate/list.d.ts +4 -0
  39. package/commands/migrate/list.js +85 -0
  40. package/commands/migrate/status.d.ts +4 -0
  41. package/commands/migrate/status.js +94 -0
  42. package/commands/migrate.d.ts +4 -0
  43. package/commands/migrate.js +69 -0
  44. package/commands/package.d.ts +3 -0
  45. package/commands/package.js +65 -0
  46. package/commands/plan.d.ts +3 -0
  47. package/commands/plan.js +62 -0
  48. package/commands/remove.d.ts +3 -0
  49. package/commands/remove.js +42 -0
  50. package/commands/rename.d.ts +4 -0
  51. package/commands/rename.js +35 -0
  52. package/commands/revert.d.ts +3 -0
  53. package/commands/revert.js +107 -0
  54. package/commands/server.d.ts +3 -0
  55. package/commands/server.js +187 -0
  56. package/commands/tag.d.ts +6 -0
  57. package/commands/tag.js +168 -0
  58. package/commands/verify.d.ts +3 -0
  59. package/commands/verify.js +85 -0
  60. package/commands.d.ts +5 -0
  61. package/commands.js +118 -0
  62. package/dist/README.md +416 -0
  63. package/dist/package.json +77 -0
  64. package/esm/commands/add.js +51 -0
  65. package/esm/commands/admin-users/add.js +87 -0
  66. package/esm/commands/admin-users/bootstrap.js +48 -0
  67. package/esm/commands/admin-users/remove.js +80 -0
  68. package/esm/commands/admin-users.js +63 -0
  69. package/esm/commands/analyze.js +16 -0
  70. package/esm/commands/clear.js +54 -0
  71. package/esm/commands/deploy.js +144 -0
  72. package/esm/commands/explorer.js +92 -0
  73. package/esm/commands/export.js +127 -0
  74. package/esm/commands/extension.js +46 -0
  75. package/esm/commands/init/index.js +42 -0
  76. package/esm/commands/init/module.js +68 -0
  77. package/esm/commands/init/workspace.js +46 -0
  78. package/esm/commands/install.js +35 -0
  79. package/esm/commands/kill.js +105 -0
  80. package/esm/commands/migrate/deps.js +184 -0
  81. package/esm/commands/migrate/init.js +63 -0
  82. package/esm/commands/migrate/list.js +83 -0
  83. package/esm/commands/migrate/status.js +92 -0
  84. package/esm/commands/migrate.js +64 -0
  85. package/esm/commands/package.js +63 -0
  86. package/esm/commands/plan.js +60 -0
  87. package/esm/commands/remove.js +40 -0
  88. package/esm/commands/rename.js +30 -0
  89. package/esm/commands/revert.js +105 -0
  90. package/esm/commands/server.js +185 -0
  91. package/esm/commands/tag.js +133 -0
  92. package/esm/commands/verify.js +83 -0
  93. package/esm/commands.js +111 -0
  94. package/esm/index.js +20 -0
  95. package/esm/package.js +26 -0
  96. package/esm/utils/argv.js +92 -0
  97. package/esm/utils/cli-error.js +48 -0
  98. package/esm/utils/database.js +78 -0
  99. package/esm/utils/deployed-changes.js +68 -0
  100. package/esm/utils/display.js +58 -0
  101. package/esm/utils/index.js +3 -0
  102. package/esm/utils/module-utils.js +51 -0
  103. package/index.d.ts +3 -0
  104. package/index.js +23 -0
  105. package/package.d.ts +1 -0
  106. package/package.js +29 -0
  107. package/package.json +77 -0
  108. package/utils/argv.d.ts +46 -0
  109. package/utils/argv.js +100 -0
  110. package/utils/cli-error.d.ts +8 -0
  111. package/utils/cli-error.js +52 -0
  112. package/utils/database.d.ts +21 -0
  113. package/utils/database.js +83 -0
  114. package/utils/deployed-changes.d.ts +4 -0
  115. package/utils/deployed-changes.js +72 -0
  116. package/utils/display.d.ts +3 -0
  117. package/utils/display.js +66 -0
  118. package/utils/index.d.ts +3 -0
  119. package/utils/index.js +19 -0
  120. package/utils/module-utils.d.ts +8 -0
  121. package/utils/module-utils.js +54 -0
package/dist/README.md ADDED
@@ -0,0 +1,416 @@
1
+ # LaunchQL CLI
2
+
3
+ > Build secure, role-aware GraphQL backends powered by PostgreSQL with database-first development
4
+
5
+ LaunchQL CLI is a comprehensive command-line tool that transforms your PostgreSQL database into a powerful GraphQL API. With automated schema generation, sophisticated migration management, and robust deployment capabilities, you can focus on building great applications instead of boilerplate code.
6
+
7
+ ## ✨ Features
8
+
9
+ - 🚀 **Database-First Development** - Design your database, get your GraphQL API automatically
10
+ - 🔐 **Built-in Security** - Role-based access control and security policies
11
+ - 📦 **Module System** - Reusable database modules with dependency management
12
+ - 🔄 **Smart Migrations** - Automated migration generation and deployment
13
+ - 🛠️ **Developer Experience** - Hot-reload development server with GraphiQL explorer
14
+ - 🏗️ **Production Ready** - Deployment plans, versioning, and rollback support
15
+
16
+ ## 🚀 Quick Start
17
+
18
+ ### Installation
19
+
20
+ ```bash
21
+ npm install -g @launchql/cli
22
+ ```
23
+
24
+ ### Create Your First Project
25
+
26
+ ```bash
27
+ # Initialize a new workspace
28
+ lql init --workspace
29
+ cd my-project
30
+
31
+ # Create your first module
32
+ lql init
33
+
34
+ # Deploy to your database
35
+ lql deploy --createdb
36
+
37
+ # Start the development server
38
+ lql server
39
+ ```
40
+
41
+ Visit `http://localhost:5555` to explore your GraphQL API!
42
+
43
+ ## 📖 Core Concepts
44
+
45
+ ### Workspaces and Modules
46
+
47
+ - **Workspace**: A collection of related database modules
48
+ - **Module**: A self-contained database package with migrations, functions, and types
49
+ - **Dependencies**: Modules can depend on other modules, creating reusable building blocks
50
+
51
+ ### Database-First Workflow
52
+
53
+ 1. **Design** your database schema using SQL migrations
54
+ 2. **Deploy** changes with `lql deploy`
55
+ 3. **Develop** against the auto-generated GraphQL API
56
+ 4. **Version** and **package** your modules for distribution
57
+
58
+ ## 🛠️ Commands
59
+
60
+ ### Getting Started
61
+
62
+ #### `lql init`
63
+
64
+ Initialize a new LaunchQL workspace or module.
65
+
66
+ ```bash
67
+ # Create a new workspace
68
+ lql init --workspace
69
+
70
+ # Create a new module (run inside workspace)
71
+ lql init
72
+
73
+ # Use templates from GitHub repository
74
+ lql init --workspace --repo owner/repo
75
+ lql init --repo owner/repo --from-branch develop
76
+
77
+ # Use templates from local path
78
+ lql init --workspace --template-path ./custom-templates
79
+ lql init --template-path ./custom-templates/module
80
+ ```
81
+
82
+ **Options:**
83
+
84
+ - `--workspace` - Initialize workspace instead of module
85
+ - `--repo <repo>` - Use templates from GitHub repository (e.g., `owner/repo`)
86
+ - `--template-path <path>` - Use templates from local path
87
+ - `--from-branch <branch>` - Specify branch when using `--repo` (default: `main`)
88
+
89
+ ### Development
90
+
91
+ #### `lql server`
92
+
93
+ Start the GraphQL development server with hot-reload.
94
+
95
+ ```bash
96
+ # Start with defaults (port 5555)
97
+ lql server
98
+
99
+ # Custom port and options
100
+ lql server --port 8080 --no-postgis
101
+ ```
102
+
103
+ #### `lql explorer`
104
+
105
+ Launch GraphiQL explorer for your API.
106
+
107
+ ```bash
108
+ # Launch explorer
109
+ lql explorer
110
+
111
+ # With custom CORS origin
112
+ lql explorer --origin http://localhost:3000
113
+ ```
114
+
115
+ ### Database Operations
116
+
117
+ #### `lql deploy`
118
+
119
+ Deploy your database changes and migrations.
120
+
121
+ ```bash
122
+ # Deploy to selected database
123
+ lql deploy
124
+
125
+ # Create database if it doesn't exist
126
+ lql deploy --createdb
127
+
128
+ # Deploy specific package to a tag
129
+ lql deploy --package mypackage --to @v1.0.0
130
+
131
+ # Fast deployment without transactions
132
+ lql deploy --fast --no-tx
133
+ ```
134
+
135
+ #### `lql verify`
136
+
137
+ Verify your database state matches expected migrations.
138
+
139
+ ```bash
140
+ # Verify current state
141
+ lql verify
142
+
143
+ # Verify specific package
144
+ lql verify --package mypackage
145
+ ```
146
+
147
+ #### `lql revert`
148
+
149
+ Safely revert database changes.
150
+
151
+ ```bash
152
+ # Revert latest changes
153
+ lql revert
154
+
155
+ # Revert to specific tag
156
+ lql revert --to @v1.0.0
157
+ ```
158
+
159
+ ### Migration Management
160
+
161
+ #### `lql migrate`
162
+
163
+ Comprehensive migration management.
164
+
165
+ ```bash
166
+ # Initialize migration tracking
167
+ lql migrate init
168
+
169
+ # Check migration status
170
+ lql migrate status
171
+
172
+ # List all changes
173
+ lql migrate list
174
+
175
+ # Show change dependencies
176
+ lql migrate deps
177
+ ```
178
+
179
+ ### Module Management
180
+
181
+ #### `lql install`
182
+
183
+ Install LaunchQL modules as dependencies.
184
+
185
+ ```bash
186
+ # Install single package
187
+ lql install @launchql/auth
188
+
189
+ # Install multiple packages
190
+ lql install @launchql/auth @launchql/utils
191
+ ```
192
+
193
+ #### `lql extension`
194
+
195
+ Interactively manage module dependencies.
196
+
197
+ ```bash
198
+ lql extension
199
+ ```
200
+
201
+ #### `lql tag`
202
+
203
+ Version your changes with tags.
204
+
205
+ ```bash
206
+ # Tag latest change
207
+ lql tag v1.0.0
208
+
209
+ # Tag with comment
210
+ lql tag v1.0.0 --comment "Initial release"
211
+
212
+ # Tag specific change
213
+ lql tag v1.1.0 --package mypackage --changeName my-change
214
+ ```
215
+
216
+ ### Packaging and Distribution
217
+
218
+ #### `lql plan`
219
+
220
+ Generate deployment plans for your modules.
221
+
222
+ ```bash
223
+ lql plan
224
+ ```
225
+
226
+ #### `lql package`
227
+
228
+ Package your module for distribution.
229
+
230
+ ```bash
231
+ # Package with defaults
232
+ lql package
233
+
234
+ # Package without deployment plan
235
+ lql package --no-plan
236
+ ```
237
+
238
+ ### Utilities
239
+
240
+ #### `lql export`
241
+
242
+ Export migrations from existing databases.
243
+
244
+ ```bash
245
+ lql export
246
+ ```
247
+
248
+ #### `lql kill`
249
+
250
+ Clean up database connections and optionally drop databases.
251
+
252
+ ```bash
253
+ # Kill connections and drop databases
254
+ lql kill
255
+
256
+ # Only kill connections
257
+ lql kill --no-drop
258
+ ```
259
+
260
+ ## 💡 Common Workflows
261
+
262
+ ### Starting a New Project
263
+
264
+ ```bash
265
+ # 1. Create workspace
266
+ mkdir my-app && cd my-app
267
+ lql init --workspace
268
+
269
+ # 2. Create your first module
270
+ lql init
271
+
272
+ # 3. Add some SQL migrations to sql/ directory
273
+ # 4. Deploy to database
274
+ lql deploy --createdb
275
+
276
+ # 5. Start developing
277
+ lql server
278
+ ```
279
+
280
+ ### Using Custom Templates
281
+
282
+ You can use custom templates from GitHub repositories or local paths:
283
+
284
+ ```bash
285
+ # Initialize workspace with templates from GitHub
286
+ lql init --workspace --repo owner/repo
287
+
288
+ # Initialize workspace with templates from local path
289
+ lql init --workspace --template-path ./my-custom-templates
290
+
291
+ # Initialize module with custom templates
292
+ lql init --template-path ./my-custom-templates
293
+
294
+ # Use specific branch from GitHub repository
295
+ lql init --workspace --repo owner/repo --from-branch develop
296
+ ```
297
+
298
+ **Template Structure:**
299
+ Custom templates should follow the same structure as the default templates:
300
+
301
+ - For workspace: `boilerplates/workspace/` directory
302
+ - For module: `boilerplates/module/` directory
303
+ - Or provide direct path to `workspace/` or `module/` directory
304
+
305
+ ### Working with Existing Projects
306
+
307
+ ```bash
308
+ # 1. Clone and enter project
309
+ git clone <repo> && cd <project>
310
+
311
+ # 2. Install dependencies
312
+ lql install
313
+
314
+ # 3. Deploy to local database
315
+ lql deploy --createdb
316
+
317
+ # 4. Start development server
318
+ lql server
319
+ ```
320
+
321
+ ### Production Deployment
322
+
323
+ ```bash
324
+ # 1. Create deployment plan
325
+ lql plan
326
+
327
+ # 2. Package module
328
+ lql package
329
+
330
+ # 3. Deploy to production
331
+ lql deploy --package myapp --to @production
332
+
333
+ # 4. Verify deployment
334
+ lql verify --package myapp
335
+ ```
336
+
337
+ ## ⚙️ Configuration
338
+
339
+ ### Environment Variables
340
+
341
+ LaunchQL respects standard PostgreSQL environment variables:
342
+
343
+ ```bash
344
+ export PGHOST=localhost
345
+ export PGPORT=5432
346
+ export PGDATABASE=myapp
347
+ export PGUSER=postgres
348
+ export PGPASSWORD=password
349
+ ```
350
+
351
+ ## 🆘 Getting Help
352
+
353
+ ### Command Help
354
+
355
+ ```bash
356
+ # Global help
357
+ lql --help
358
+
359
+ # Command-specific help
360
+ lql deploy --help
361
+ lql server -h
362
+ ```
363
+
364
+ ### Common Options
365
+
366
+ Most commands support these global options:
367
+
368
+ - `--help, -h` - Show help information
369
+ - `--version, -v` - Show version information
370
+ - `--cwd <dir>` - Set working directory
371
+
372
+ ## Related LaunchQL Tooling
373
+
374
+ ### 🧪 Testing
375
+
376
+ * [launchql/pgsql-test](https://github.com/launchql/launchql/tree/main/packages/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
377
+ * [launchql/supabase-test](https://github.com/launchql/launchql/tree/main/packages/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
378
+ * [launchql/graphile-test](https://github.com/launchql/launchql/tree/main/packages/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
379
+ * [launchql/pg-query-context](https://github.com/launchql/launchql/tree/main/packages/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
380
+
381
+ ### 🧠 Parsing & AST
382
+
383
+ * [launchql/pgsql-parser](https://github.com/launchql/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
384
+ * [launchql/libpg-query-node](https://github.com/launchql/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
385
+ * [launchql/pg-proto-parser](https://github.com/launchql/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
386
+ * [@pgsql/enums](https://github.com/launchql/pgsql-parser/tree/main/packages/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
387
+ * [@pgsql/types](https://github.com/launchql/pgsql-parser/tree/main/packages/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
388
+ * [@pgsql/utils](https://github.com/launchql/pgsql-parser/tree/main/packages/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
389
+ * [launchql/pg-ast](https://github.com/launchql/launchql/tree/main/packages/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
390
+
391
+ ### 🚀 API & Dev Tools
392
+
393
+ * [launchql/server](https://github.com/launchql/launchql/tree/main/packages/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
394
+ * [launchql/explorer](https://github.com/launchql/launchql/tree/main/packages/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
395
+
396
+ ### 🔁 Streaming & Uploads
397
+
398
+ * [launchql/s3-streamer](https://github.com/launchql/launchql/tree/main/packages/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
399
+ * [launchql/etag-hash](https://github.com/launchql/launchql/tree/main/packages/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
400
+ * [launchql/etag-stream](https://github.com/launchql/launchql/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
401
+ * [launchql/uuid-hash](https://github.com/launchql/launchql/tree/main/packages/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
402
+ * [launchql/uuid-stream](https://github.com/launchql/launchql/tree/main/packages/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
403
+ * [launchql/upload-names](https://github.com/launchql/launchql/tree/main/packages/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
404
+
405
+ ### 🧰 CLI & Codegen
406
+
407
+ * [@launchql/cli](https://github.com/launchql/launchql/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing LaunchQL projects—supports database scaffolding, migrations, seeding, code generation, and automation.
408
+ * [launchql/launchql-gen](https://github.com/launchql/launchql/tree/main/packages/launchql-gen): **✨ Auto-generated GraphQL** mutations and queries dynamically built from introspected schema data.
409
+ * [@launchql/query-builder](https://github.com/launchql/launchql/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
410
+ * [@launchql/query](https://github.com/launchql/launchql/tree/main/packages/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
411
+
412
+ ## Disclaimer
413
+
414
+ AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
415
+
416
+ No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "pgpm",
3
+ "version": "0.0.1",
4
+ "author": "Dan Lynch <pyramation@gmail.com>",
5
+ "description": "LaunchQL CLI",
6
+ "main": "index.js",
7
+ "module": "esm/index.js",
8
+ "types": "index.d.ts",
9
+ "homepage": "https://github.com/launchql/launchql",
10
+ "license": "SEE LICENSE IN LICENSE",
11
+ "publishConfig": {
12
+ "access": "public",
13
+ "directory": "dist"
14
+ },
15
+ "bin": {
16
+ "lql": "index.js",
17
+ "launchql": "index.js"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/launchql/launchql"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/launchql/launchql/issues"
25
+ },
26
+ "scripts": {
27
+ "copy": "copyfiles -f ../../LICENSE README.md package.json dist",
28
+ "clean": "rimraf dist/**",
29
+ "prepare": "npm run build",
30
+ "build": "npm run clean; tsc -p tsconfig.json; tsc -p tsconfig.esm.json; npm run copy",
31
+ "build:dev": "npm run clean; tsc -p tsconfig.json --declarationMap; tsc -p tsconfig.esm.json; npm run copy",
32
+ "dev": "ts-node ./src/index.ts",
33
+ "lint": "eslint . --fix",
34
+ "test": "jest",
35
+ "test:watch": "jest --watch"
36
+ },
37
+ "devDependencies": {
38
+ "@types/glob": "^8.1.0",
39
+ "@types/js-yaml": "^4.0.9",
40
+ "@types/minimist": "^1.2.5",
41
+ "@types/node": "^20.12.7",
42
+ "@types/pg": "^8.15.2",
43
+ "@types/shelljs": "^0.8.16",
44
+ "glob": "^11.0.2",
45
+ "pg": "^8.16.0",
46
+ "ts-node": "^10.9.2"
47
+ },
48
+ "dependencies": {
49
+ "@launchql/core": "^2.14.3",
50
+ "@launchql/env": "^2.4.5",
51
+ "@launchql/explorer": "^2.6.1",
52
+ "@launchql/logger": "^1.1.3",
53
+ "@launchql/server": "^2.6.1",
54
+ "@launchql/server-utils": "^2.5.1",
55
+ "@launchql/templatizer": "^2.4.5",
56
+ "@launchql/types": "^2.7.0",
57
+ "chalk": "^4.1.0",
58
+ "inquirerer": "^2.0.8",
59
+ "js-yaml": "^4.1.0",
60
+ "minimist": "^1.2.8",
61
+ "pg-cache": "^1.3.8",
62
+ "pg-env": "^1.1.1",
63
+ "shelljs": "^0.9.2"
64
+ },
65
+ "keywords": [
66
+ "cli",
67
+ "command-line",
68
+ "tool",
69
+ "launchql",
70
+ "utilities",
71
+ "pg",
72
+ "pgsql",
73
+ "postgres",
74
+ "graphile"
75
+ ],
76
+ "gitHead": "2e8a123c53d33ee10377b0f034392b0dff1e8a88"
77
+ }
@@ -0,0 +1,51 @@
1
+ import { LaunchQLPackage } from '@launchql/core';
2
+ import { extractFirst } from '../utils/argv';
3
+ import * as path from 'path';
4
+ const addUsageText = `
5
+ LaunchQL Add Command:
6
+
7
+ lql add [change] [OPTIONS]
8
+
9
+ Add a database change to plans and create deploy/revert/verify SQL files.
10
+
11
+ Arguments:
12
+ change Name of the change to create
13
+
14
+ Options:
15
+ --help, -h Show this help message
16
+ --requires <dependency> Required change (can be used multiple times)
17
+ --note <text> Brief note describing the purpose of the change
18
+ --cwd <directory> Working directory (default: current directory)
19
+
20
+ Examples:
21
+ lql add organizations Add change named 'organizations'
22
+ lql add brands --note "Adds the brands table" Add change with note
23
+ lql add contacts --requires users --note "Adds contacts table" Add with dependency
24
+ lql add be/a/path/like/this Add change with nested path
25
+ `;
26
+ export default async (argv, prompter, _options) => {
27
+ // Show usage if explicitly requested
28
+ if (argv.help || argv.h) {
29
+ console.log(addUsageText);
30
+ process.exit(0);
31
+ }
32
+ const cwd = argv.cwd || process.cwd();
33
+ const { first: change, newArgv } = extractFirst(argv);
34
+ let finalChange = change;
35
+ if (!change) {
36
+ const answers = await prompter.prompt(newArgv, [{
37
+ type: 'text',
38
+ name: 'change',
39
+ message: 'Change name',
40
+ required: true
41
+ }]);
42
+ finalChange = answers.change;
43
+ }
44
+ let dependencies = [];
45
+ if (argv.requires) {
46
+ dependencies = Array.isArray(argv.requires) ? argv.requires : [argv.requires];
47
+ }
48
+ const pkg = new LaunchQLPackage(path.resolve(cwd));
49
+ pkg.addChange(finalChange, dependencies.length > 0 ? dependencies : undefined, argv.note);
50
+ return newArgv;
51
+ };
@@ -0,0 +1,87 @@
1
+ import { LaunchQLInit } from '@launchql/core';
2
+ import { Logger } from '@launchql/logger';
3
+ import { getPgEnvOptions } from 'pg-env';
4
+ const log = new Logger('admin-users-add');
5
+ const addUsageText = `
6
+ LaunchQL Admin Users Add Command:
7
+
8
+ lql admin-users add [OPTIONS]
9
+
10
+ Add database users with LaunchQL roles.
11
+ Note: You must run 'lql admin-users bootstrap' first to initialize roles.
12
+
13
+ Options:
14
+ --help, -h Show this help message
15
+ --username <username> Username for the database user
16
+ --password <password> Password for the database user
17
+ --test Add test users (app_user, app_admin) with default passwords
18
+ --cwd <directory> Working directory (default: current directory)
19
+
20
+ Examples:
21
+ lql admin-users add --username myuser --password mypass
22
+ lql admin-users add --test # Add test users (requires bootstrap first)
23
+ lql admin-users add # Will prompt for username and password
24
+ `;
25
+ export default async (argv, prompter, _options) => {
26
+ // Show usage if explicitly requested
27
+ if (argv.help || argv.h) {
28
+ console.log(addUsageText);
29
+ process.exit(0);
30
+ }
31
+ const pgEnv = getPgEnvOptions();
32
+ const isTest = argv.test;
33
+ const init = new LaunchQLInit(pgEnv);
34
+ try {
35
+ if (isTest) {
36
+ const { yes: confirmTest } = await prompter.prompt(argv, [
37
+ {
38
+ type: 'confirm',
39
+ name: 'yes',
40
+ message: 'Are you sure you want to add LaunchQL test users? (WARNING: Should NEVER be run on production!)',
41
+ default: false
42
+ }
43
+ ]);
44
+ if (!confirmTest) {
45
+ log.info('Operation cancelled.');
46
+ return;
47
+ }
48
+ await init.bootstrapTestRoles();
49
+ log.success('Test users added successfully.');
50
+ }
51
+ else {
52
+ const prompts = [
53
+ {
54
+ type: 'text',
55
+ name: 'username',
56
+ message: 'Enter username for database user:',
57
+ validate: (input) => input && input.trim().length > 0
58
+ },
59
+ {
60
+ type: 'text',
61
+ name: 'password',
62
+ message: 'Enter password for database user:',
63
+ validate: (input) => input && input.trim().length > 0
64
+ }
65
+ ];
66
+ const { username, password } = await prompter.prompt(argv, prompts);
67
+ const { yes } = await prompter.prompt(argv, [
68
+ {
69
+ type: 'confirm',
70
+ name: 'yes',
71
+ message: `Are you sure you want to add database user "${username}"?`,
72
+ default: false
73
+ }
74
+ ]);
75
+ if (!yes) {
76
+ log.info('Operation cancelled.');
77
+ return;
78
+ }
79
+ await init.bootstrapDbRoles(username, password);
80
+ log.success(`Database user "${username}" added successfully.`);
81
+ }
82
+ }
83
+ finally {
84
+ await init.close();
85
+ }
86
+ return argv;
87
+ };
@@ -0,0 +1,48 @@
1
+ import { LaunchQLInit } from '@launchql/core';
2
+ import { Logger } from '@launchql/logger';
3
+ import { getPgEnvOptions } from 'pg-env';
4
+ const log = new Logger('admin-users-bootstrap');
5
+ const bootstrapUsageText = `
6
+ LaunchQL Admin Users Bootstrap Command:
7
+
8
+ lql admin-users bootstrap [OPTIONS]
9
+
10
+ Initialize LaunchQL roles and permissions. This command must be run before adding users.
11
+ Creates the standard LaunchQL roles: anonymous, authenticated, administrator.
12
+
13
+ Options:
14
+ --help, -h Show this help message
15
+ --cwd <directory> Working directory (default: current directory)
16
+
17
+ Examples:
18
+ lql admin-users bootstrap # Initialize LaunchQL roles
19
+ `;
20
+ export default async (argv, prompter, _options) => {
21
+ // Show usage if explicitly requested
22
+ if (argv.help || argv.h) {
23
+ console.log(bootstrapUsageText);
24
+ process.exit(0);
25
+ }
26
+ const pgEnv = getPgEnvOptions();
27
+ const { yes } = await prompter.prompt(argv, [
28
+ {
29
+ type: 'confirm',
30
+ name: 'yes',
31
+ message: 'Are you sure you want to initialize LaunchQL roles and permissions?',
32
+ default: false
33
+ }
34
+ ]);
35
+ if (!yes) {
36
+ log.info('Operation cancelled.');
37
+ return;
38
+ }
39
+ const init = new LaunchQLInit(pgEnv);
40
+ try {
41
+ await init.bootstrapRoles();
42
+ log.success('LaunchQL roles and permissions initialized successfully.');
43
+ }
44
+ finally {
45
+ await init.close();
46
+ }
47
+ return argv;
48
+ };