@constructive-io/cli 0.0.2 → 5.1.0

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 (130) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +320 -189
  3. package/commands/{analyze.d.ts → codegen.d.ts} +2 -2
  4. package/commands/codegen.js +131 -0
  5. package/commands/explorer.js +94 -0
  6. package/commands/get-graphql-schema.js +73 -0
  7. package/commands/server.js +187 -0
  8. package/commands.d.ts +0 -1
  9. package/commands.js +42 -61
  10. package/esm/commands/codegen.js +126 -0
  11. package/esm/commands/explorer.js +92 -0
  12. package/esm/commands/get-graphql-schema.js +71 -0
  13. package/esm/commands/server.js +185 -0
  14. package/esm/commands.js +41 -59
  15. package/esm/index.js +16 -36
  16. package/esm/utils/display.js +26 -23
  17. package/esm/utils/index.js +3 -6
  18. package/index.d.ts +0 -22
  19. package/index.js +16 -72
  20. package/package.json +44 -29
  21. package/utils/display.d.ts +1 -1
  22. package/utils/display.js +26 -23
  23. package/utils/index.d.ts +3 -6
  24. package/utils/index.js +7 -20
  25. package/commands/add.d.ts +0 -7
  26. package/commands/add.js +0 -86
  27. package/commands/admin-users/add.d.ts +0 -4
  28. package/commands/admin-users/add.js +0 -89
  29. package/commands/admin-users/bootstrap.d.ts +0 -4
  30. package/commands/admin-users/bootstrap.js +0 -50
  31. package/commands/admin-users/remove.d.ts +0 -4
  32. package/commands/admin-users/remove.js +0 -82
  33. package/commands/admin-users.d.ts +0 -4
  34. package/commands/admin-users.js +0 -68
  35. package/commands/analyze.js +0 -21
  36. package/commands/clear.d.ts +0 -3
  37. package/commands/clear.js +0 -59
  38. package/commands/deploy.d.ts +0 -4
  39. package/commands/deploy.js +0 -146
  40. package/commands/docker.d.ts +0 -3
  41. package/commands/docker.js +0 -194
  42. package/commands/env.d.ts +0 -4
  43. package/commands/env.js +0 -124
  44. package/commands/export.js +0 -129
  45. package/commands/extension.js +0 -48
  46. package/commands/init/index.d.ts +0 -7
  47. package/commands/init/index.js +0 -47
  48. package/commands/init/module.d.ts +0 -4
  49. package/commands/init/module.js +0 -71
  50. package/commands/init/workspace.d.ts +0 -4
  51. package/commands/init/workspace.js +0 -52
  52. package/commands/install.d.ts +0 -4
  53. package/commands/install.js +0 -37
  54. package/commands/kill.js +0 -107
  55. package/commands/migrate/deps.d.ts +0 -4
  56. package/commands/migrate/deps.js +0 -186
  57. package/commands/migrate/init.d.ts +0 -4
  58. package/commands/migrate/init.js +0 -65
  59. package/commands/migrate/list.d.ts +0 -4
  60. package/commands/migrate/list.js +0 -85
  61. package/commands/migrate/status.d.ts +0 -4
  62. package/commands/migrate/status.js +0 -94
  63. package/commands/migrate.d.ts +0 -4
  64. package/commands/migrate.js +0 -69
  65. package/commands/package.d.ts +0 -3
  66. package/commands/package.js +0 -65
  67. package/commands/plan.d.ts +0 -3
  68. package/commands/plan.js +0 -62
  69. package/commands/remove.d.ts +0 -3
  70. package/commands/remove.js +0 -42
  71. package/commands/rename.d.ts +0 -4
  72. package/commands/rename.js +0 -35
  73. package/commands/revert.d.ts +0 -3
  74. package/commands/revert.js +0 -107
  75. package/commands/tag.d.ts +0 -6
  76. package/commands/tag.js +0 -168
  77. package/commands/verify.d.ts +0 -3
  78. package/commands/verify.js +0 -85
  79. package/dist/README.md +0 -412
  80. package/dist/package.json +0 -64
  81. package/esm/commands/add.js +0 -51
  82. package/esm/commands/admin-users/add.js +0 -87
  83. package/esm/commands/admin-users/bootstrap.js +0 -48
  84. package/esm/commands/admin-users/remove.js +0 -80
  85. package/esm/commands/admin-users.js +0 -63
  86. package/esm/commands/analyze.js +0 -16
  87. package/esm/commands/clear.js +0 -54
  88. package/esm/commands/deploy.js +0 -144
  89. package/esm/commands/docker.js +0 -192
  90. package/esm/commands/env.js +0 -122
  91. package/esm/commands/export.js +0 -127
  92. package/esm/commands/extension.js +0 -46
  93. package/esm/commands/init/index.js +0 -42
  94. package/esm/commands/init/module.js +0 -68
  95. package/esm/commands/init/workspace.js +0 -46
  96. package/esm/commands/install.js +0 -35
  97. package/esm/commands/kill.js +0 -105
  98. package/esm/commands/migrate/deps.js +0 -184
  99. package/esm/commands/migrate/init.js +0 -63
  100. package/esm/commands/migrate/list.js +0 -83
  101. package/esm/commands/migrate/status.js +0 -92
  102. package/esm/commands/migrate.js +0 -64
  103. package/esm/commands/package.js +0 -63
  104. package/esm/commands/plan.js +0 -60
  105. package/esm/commands/remove.js +0 -40
  106. package/esm/commands/rename.js +0 -30
  107. package/esm/commands/revert.js +0 -105
  108. package/esm/commands/tag.js +0 -133
  109. package/esm/commands/verify.js +0 -83
  110. package/esm/package.js +0 -26
  111. package/esm/utils/argv.js +0 -92
  112. package/esm/utils/cli-error.js +0 -48
  113. package/esm/utils/database.js +0 -78
  114. package/esm/utils/deployed-changes.js +0 -68
  115. package/esm/utils/module-utils.js +0 -51
  116. package/package.d.ts +0 -1
  117. package/package.js +0 -29
  118. package/utils/argv.d.ts +0 -46
  119. package/utils/argv.js +0 -100
  120. package/utils/cli-error.d.ts +0 -8
  121. package/utils/cli-error.js +0 -52
  122. package/utils/database.d.ts +0 -21
  123. package/utils/database.js +0 -83
  124. package/utils/deployed-changes.d.ts +0 -4
  125. package/utils/deployed-changes.js +0 -72
  126. package/utils/module-utils.d.ts +0 -8
  127. package/utils/module-utils.js +0 -54
  128. /package/commands/{export.d.ts → explorer.d.ts} +0 -0
  129. /package/commands/{extension.d.ts → get-graphql-schema.d.ts} +0 -0
  130. /package/commands/{kill.d.ts → server.d.ts} +0 -0
package/dist/README.md DELETED
@@ -1,412 +0,0 @@
1
- # **constructive — Platform for building Schemas, APIs, and Apps**
2
-
3
- **A unified cloud platform for data, APIs, and application development.**
4
-
5
- `constructive` brings together everything teams need to model data, ship APIs, and deploy modern applications. It provides a modular foundation for defining schemas, automating infrastructure, and delivering fast, secure experiences—without the complexity of traditional backend stacks.
6
-
7
- ## ✨ Features
8
-
9
- * 🧱 **Modular Building Blocks** — Compose your app from reusable modules for data, logic, storage, and services. Swap, version, and extend components without rewriting your backend.
10
- * 🔄 **Automated Schema & API Generation** — Define your data and relationships once; get auto-generated APIs, migrations, types, and client code across languages.
11
- * ☁️ **Zero-Config Cloud Deployments** — Push code, get production. Deploy databases, APIs, functions, and frontends with instant environments and built-in rollout safety.
12
- * 🏗️ **Full-Stack Workspaces** — `constructive init` creates a complete workspace with data models, API routes, auth, edge functions, and CI/CD already wired together.
13
- * 📊 **Versioned Infrastructure** — Every schema, API, and service change is tracked and versioned, enabling reproducible deployments and safe rollbacks.
14
- * 🌐 **Portable by Design** — Built on open standards and SQL-first workflows, your app runs anywhere—from the constructive cloud to your own infra.
15
- * 🚀 **Optimized Developer Experience** — Type-safe SDKs, hot reloading for data and APIs, local-first dev, and zero boilerplate to get from idea → production fast.
16
-
17
- ## 🚀 Quick Start
18
-
19
- ### Install & Setup
20
-
21
- ```bash
22
- # Install constructive globally
23
- npm install -g @constructive-io/cli
24
-
25
- # Start local Postgres (via Docker) and export env vars
26
- constructive docker start
27
- eval "$(constructive env)"
28
- ```
29
-
30
- > **Tip:** Already running Postgres? Skip the Docker step and just export your PG* vars.
31
-
32
- ---
33
-
34
- ### Create a Workspace and Install a Package
35
-
36
- ```bash
37
- # 1. Create a workspace
38
- constructive init --workspace
39
- cd my-app
40
-
41
- # 2. Create your first module
42
- constructive init
43
- cd packages/your-module
44
-
45
- # 3. Install a package
46
- constructive install @pgpm/faker
47
-
48
- # 4. Deploy everything
49
- constructive deploy --createdb --database mydb1
50
- psql -d mydb1 -c "SELECT faker.city('MI');"
51
- > Ann Arbor
52
- ```
53
-
54
- ## 🛠️ Commands
55
-
56
- ### Getting Started
57
-
58
- - `constructive init` - Initialize a new module
59
- - `constructive init --workspace` - Initialize a new workspace
60
-
61
- ### Development Setup
62
-
63
- - `constructive docker start` - Start PostgreSQL container (via Docker)
64
- - `constructive docker stop` - Stop PostgreSQL container
65
- - `constructive env` - Print PostgreSQL environment variables for shell export
66
-
67
- ### Database Operations
68
-
69
- - `constructive deploy` - Deploy database changes and migrations
70
- - `constructive verify` - Verify database state matches expected migrations
71
- - `constructive revert` - Safely revert database changes
72
-
73
- ### Migration Management
74
-
75
- - `constructive migrate` - Comprehensive migration management
76
- - `constructive migrate init` - Initialize migration tracking
77
- - `constructive migrate status` - Check migration status
78
- - `constructive migrate list` - List all changes
79
- - `constructive migrate deps` - Show change dependencies
80
-
81
- ### Module Management
82
-
83
- - `constructive install` - Install database modules as dependencies
84
- - `constructive extension` - Interactively manage module dependencies
85
- - `constructive tag` - Version your changes with tags
86
-
87
- ### Packaging and Distribution
88
-
89
- - `constructive plan` - Generate deployment plans for your modules
90
- - `constructive package` - Package your module for distribution
91
-
92
- ### Utilities
93
-
94
- - `constructive add` - Add a new database change
95
- - `constructive remove` - Remove a database change
96
- - `constructive export` - Export migrations from existing databases
97
- - `constructive clear` - Clear database state
98
- - `constructive kill` - Clean up database connections
99
- - `constructive analyze` - Analyze database structure
100
- - `constructive rename` - Rename database changes
101
- - `constructive admin-users` - Manage admin users
102
-
103
- ## 💡 Common Workflows
104
-
105
- ### Starting a New Project and Adding a Change
106
-
107
- ```bash
108
- # 1. Create workspace
109
- constructive init --workspace
110
- cd my-app
111
-
112
- # 2. Create your first module
113
- constructive init
114
- cd packages/new-module
115
-
116
- # 3. Add some SQL migrations to sql/ directory
117
- constructive add some_change
118
-
119
- # 4. Deploy to database
120
- constructive deploy --createdb
121
- ```
122
-
123
- ### Working with Existing Projects
124
-
125
- ```bash
126
- # 1. Navigate to your module
127
- cd packages/your-module
128
-
129
- # 2. Install a package
130
- constructive install @pgpm/faker
131
-
132
- # 3. Deploy all installed modules
133
- constructive deploy --createdb --database mydb1
134
- psql -d mydb1 -c "SELECT faker.city('MI');"
135
- > Ann Arbor
136
- ```
137
-
138
- ### Testing a module in a workspace
139
-
140
- ```bash
141
- # 1. Install workspace dependencies
142
- pnpm install
143
-
144
- # 2. Enter the packages/<yourmodule>
145
- cd packages/yourmodule
146
-
147
- # 3. Test the module in watch mode
148
- pnpm test:watch
149
- ```
150
-
151
- ### Database Operations
152
-
153
- #### `constructive deploy`
154
-
155
- Deploy your database changes and migrations.
156
-
157
- ```bash
158
- # Deploy to selected database
159
- constructive deploy
160
-
161
- # Create database if it doesn't exist
162
- constructive deploy --createdb
163
-
164
- # Deploy specific package to a tag
165
- constructive deploy --package mypackage --to @v1.0.0
166
-
167
- # Fast deployment without transactions
168
- constructive deploy --fast --no-tx
169
- ```
170
-
171
- #### `constructive verify`
172
-
173
- Verify your database state matches expected migrations.
174
-
175
- ```bash
176
- # Verify current state
177
- constructive verify
178
-
179
- # Verify specific package
180
- constructive verify --package mypackage
181
- ```
182
-
183
- #### `constructive revert`
184
-
185
- Safely revert database changes.
186
-
187
- ```bash
188
- # Revert latest changes
189
- constructive revert
190
-
191
- # Revert to specific tag
192
- constructive revert --to @v1.0.0
193
- ```
194
-
195
- ### Migration Management
196
-
197
- #### `constructive migrate`
198
-
199
- Comprehensive migration management.
200
-
201
- ```bash
202
- # Initialize migration tracking
203
- constructive migrate init
204
-
205
- # Check migration status
206
- constructive migrate status
207
-
208
- # List all changes
209
- constructive migrate list
210
-
211
- # Show change dependencies
212
- constructive migrate deps
213
- ```
214
-
215
- ### Module Management
216
-
217
- #### `constructive install`
218
-
219
- Install database modules as dependencies.
220
-
221
- ```bash
222
- # Install single package
223
- constructive install @pgpm/base32
224
-
225
- # Install multiple packages
226
- constructive install @pgpm/base32 @pgpm/faker
227
- ```
228
-
229
- #### `constructive extension`
230
-
231
- Interactively manage module dependencies.
232
-
233
- ```bash
234
- constructive extension
235
- ```
236
-
237
- #### `constructive tag`
238
-
239
- Version your changes with tags.
240
-
241
- ```bash
242
- # Tag latest change
243
- constructive tag v1.0.0
244
-
245
- # Tag with comment
246
- constructive tag v1.0.0 --comment "Initial release"
247
-
248
- # Tag specific change
249
- constructive tag v1.1.0 --package mypackage --changeName my-change
250
- ```
251
-
252
- ### Packaging and Distribution
253
-
254
- #### `constructive plan`
255
-
256
- Generate deployment plans for your modules.
257
-
258
- ```bash
259
- constructive plan
260
- ```
261
-
262
- #### `constructive package`
263
-
264
- Package your module for distribution.
265
-
266
- ```bash
267
- # Package with defaults
268
- constructive package
269
-
270
- # Package without deployment plan
271
- constructive package --no-plan
272
- ```
273
-
274
- ### Utilities
275
-
276
- #### `constructive export`
277
-
278
- Export migrations from existing databases.
279
-
280
- ```bash
281
- constructive export
282
- ```
283
-
284
- #### `constructive kill`
285
-
286
- Clean up database connections and optionally drop databases.
287
-
288
- ```bash
289
- # Kill connections and drop databases
290
- constructive kill
291
-
292
- # Only kill connections
293
- constructive kill --no-drop
294
- ```
295
-
296
- ## ⚙️ Configuration
297
-
298
- ### Environment Variables
299
-
300
- `constructive` uses standard PostgreSQL environment variables (`PGHOST`, `PGPORT`, `PGDATABASE`, `PGUSER`, `PGPASSWORD`).
301
-
302
- **Quick setup** (recommended):
303
- ```bash
304
- eval "$(constructive env)"
305
- ```
306
-
307
- **Manual setup** (if you prefer):
308
- ```bash
309
- export PGHOST=localhost
310
- export PGPORT=5432
311
- export PGDATABASE=myapp
312
- export PGUSER=postgres
313
- export PGPASSWORD=password
314
- ```
315
-
316
- **Supabase local development:**
317
- ```bash
318
- eval "$(constructive env --supabase)"
319
- ```
320
-
321
- ## Getting Help
322
-
323
- ### Command Help
324
-
325
- ```bash
326
- # Global help
327
- constructive --help
328
-
329
- # Command-specific help
330
- constructive deploy --help
331
- constructive tag -h
332
- ```
333
-
334
- ### Common Options
335
-
336
- Most commands support these global options:
337
-
338
- - `--help, -h` - Show help information
339
- - `--version, -v` - Show version information
340
- - `--cwd <dir>` - Set working directory
341
-
342
- ## Education and Tutorials
343
-
344
- 1. 🚀 [Quickstart: Getting Up and Running](https://launchql.com/learn/quickstart)
345
- Get started with modular databases in minutes. Install prerequisites and deploy your first module.
346
-
347
- 2. 📦 [Modular PostgreSQL Development with Database Packages](https://launchql.com/learn/modular-postgres)
348
- Learn to organize PostgreSQL projects with constructive workspaces and reusable database modules.
349
-
350
- 3. ✏️ [Authoring Database Changes](https://launchql.com/learn/authoring-database-changes)
351
- Master the workflow for adding, organizing, and managing database changes with constructive.
352
-
353
- 4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://launchql.com/learn/e2e-postgres-testing)
354
- Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
355
-
356
- 5. ⚡ [Supabase Testing](https://launchql.com/learn/supabase)
357
- TypeScript-native testing for Supabase with modern workflows.
358
-
359
- 6. 🔧 [Troubleshooting](https://launchql.com/learn/troubleshooting)
360
- Common issues and solutions for constructive, PostgreSQL, and testing.
361
-
362
- ## Related LaunchQL Tooling
363
-
364
- ### 🧪 Testing
365
-
366
- * [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.
367
- * [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.
368
- * [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.
369
- * [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.
370
-
371
- ### 🧠 Parsing & AST
372
-
373
- * [launchql/pgsql-parser](https://github.com/launchql/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
374
- * [launchql/libpg-query-node](https://github.com/launchql/libpg-query-node): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
375
- * [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.
376
- * [@pgsql/enums](https://github.com/launchql/pgsql-parser/tree/main/packages/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
377
- * [@pgsql/types](https://github.com/launchql/pgsql-parser/tree/main/packages/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
378
- * [@pgsql/utils](https://github.com/launchql/pgsql-parser/tree/main/packages/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
379
- * [launchql/pg-ast](https://github.com/launchql/launchql/tree/main/packages/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
380
-
381
- ### 🚀 API & Dev Tools
382
-
383
- * [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.
384
- * [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.
385
-
386
- ### 🔁 Streaming & Uploads
387
-
388
- * [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.
389
- * [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.
390
- * [launchql/etag-stream](https://github.com/launchql/launchql/tree/main/packages/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
391
- * [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.
392
- * [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.
393
- * [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.
394
-
395
- ### 🧰 CLI & Codegen
396
-
397
- * [constructive](https://github.com/launchql/launchql/tree/main/packages/pgpm): **🖥️ Backend platform** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
398
- * [@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.
399
- * [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.
400
- * [@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.
401
- * [@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.
402
-
403
- ## Credits
404
-
405
- 🛠 Built by LaunchQL — if you like our tools, please checkout and contribute to [our github ⚛️](https://github.com/launchql)
406
-
407
-
408
- ## Disclaimer
409
-
410
- AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
411
-
412
- 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.
package/dist/package.json DELETED
@@ -1,64 +0,0 @@
1
- {
2
- "name": "@constructive-io/cli",
3
- "version": "0.0.2",
4
- "description": "Platform for schemas, APIs, and application programming",
5
- "main": "index.js",
6
- "module": "esm/index.js",
7
- "types": "index.d.ts",
8
- "license": "SEE LICENSE IN LICENSE",
9
- "publishConfig": {
10
- "access": "public",
11
- "directory": "dist"
12
- },
13
- "bin": {
14
- "constructive": "index.js"
15
- },
16
- "scripts": {
17
- "copy": "copyfiles -f ../../LICENSE README.md package.json dist",
18
- "clean": "rimraf dist/**",
19
- "prepack": "npm run build",
20
- "build": "npm run clean; tsc -p tsconfig.json; tsc -p tsconfig.esm.json; npm run copy",
21
- "build:dev": "npm run clean; tsc -p tsconfig.json --declarationMap; tsc -p tsconfig.esm.json; npm run copy",
22
- "dev": "ts-node ./src/index.ts",
23
- "lint": "eslint . --fix",
24
- "test": "jest",
25
- "test:watch": "jest --watch"
26
- },
27
- "devDependencies": {
28
- "@types/glob": "^8.1.0",
29
- "@types/js-yaml": "^4.0.9",
30
- "@types/minimist": "^1.2.5",
31
- "@types/node": "^20.12.7",
32
- "@types/pg": "^8.15.2",
33
- "@types/shelljs": "^0.8.16",
34
- "glob": "^11.0.2",
35
- "pg": "^8.16.0",
36
- "ts-node": "^10.9.2"
37
- },
38
- "dependencies": {
39
- "@launchql/core": "2.15.4",
40
- "@launchql/env": "2.5.1",
41
- "@launchql/logger": "1.1.6",
42
- "@launchql/templatizer": "2.5.1",
43
- "@launchql/types": "2.8.1",
44
- "chalk": "^4.1.0",
45
- "inquirerer": "^2.0.8",
46
- "js-yaml": "^4.1.0",
47
- "minimist": "^1.2.8",
48
- "pg-cache": "1.4.2",
49
- "pg-env": "1.1.3",
50
- "shelljs": "^0.9.2"
51
- },
52
- "keywords": [
53
- "cli",
54
- "command-line",
55
- "tool",
56
- "postgres",
57
- "postgresql",
58
- "migration",
59
- "package-manager",
60
- "database",
61
- "pg",
62
- "pgsql"
63
- ]
64
- }
@@ -1,51 +0,0 @@
1
- import { LaunchQLPackage } from '@launchql/core';
2
- import * as path from 'path';
3
- import { extractFirst } from '../utils/argv';
4
- const addUsageText = `
5
- Add Command:
6
-
7
- constructive 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
- constructive add organizations Add change named 'organizations'
22
- constructive add brands --note "Adds the brands table" Add change with note
23
- constructive add contacts --requires users --note "Adds contacts table" Add with dependency
24
- constructive 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
- };
@@ -1,87 +0,0 @@
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
- Admin Users Add Command:
7
-
8
- constructive admin-users add [OPTIONS]
9
-
10
- Add database users with postgres roles.
11
- Note: You must run 'constructive 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
- constructive admin-users add --username myuser --password mypass
22
- constructive admin-users add --test # Add test users (requires bootstrap first)
23
- constructive 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 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
- };
@@ -1,48 +0,0 @@
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
- Admin Users Bootstrap Command:
7
-
8
- constructive admin-users bootstrap [OPTIONS]
9
-
10
- Initialize postgres roles and permissions. This command must be run before adding users.
11
- Creates the standard postgres 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
- constructive admin-users bootstrap # Initialize postgres 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 postgres 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('postgres roles and permissions initialized successfully.');
43
- }
44
- finally {
45
- await init.close();
46
- }
47
- return argv;
48
- };