@nexical/cli 0.11.23 → 0.12.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 (91) hide show
  1. package/README.md +90 -235
  2. package/dist/{chunk-OYFWMYPG.js → chunk-6DE5Q66O.js} +6 -1
  3. package/dist/{chunk-OYFWMYPG.js.map → chunk-6DE5Q66O.js.map} +1 -1
  4. package/dist/chunk-G66GMEFE.js +31 -0
  5. package/dist/chunk-G66GMEFE.js.map +1 -0
  6. package/dist/{chunk-2FKDEDDE.js → chunk-HOVS7SCD.js} +16 -3
  7. package/dist/chunk-HOVS7SCD.js.map +1 -0
  8. package/dist/{chunk-GUUPSHWC.js → chunk-JEMIKBGX.js} +3 -3
  9. package/dist/chunk-JGAMEJTL.js +4101 -0
  10. package/dist/chunk-JGAMEJTL.js.map +1 -0
  11. package/dist/{chunk-OUGA4CB4.js → chunk-JS6WL5NS.js} +2 -2
  12. package/dist/{chunk-GEESHGE4.js → chunk-L2RUXOL4.js} +2 -2
  13. package/dist/{chunk-54HY52LH.js → chunk-QTJIGPQ3.js} +2 -2
  14. package/dist/{chunk-EKCOW7FM.js → chunk-USP2MI63.js} +41 -23
  15. package/dist/chunk-USP2MI63.js.map +1 -0
  16. package/dist/{chunk-2JW5BYZW.js → chunk-VKE7R2EZ.js} +2 -2
  17. package/dist/{chunk-AC4B3HPJ.js → chunk-XONR27KC.js} +2 -2
  18. package/dist/{chunk-PJIOCW2A.js → chunk-ZWNIZB3Q.js} +2 -2
  19. package/dist/index.js +5 -5
  20. package/dist/index.js.map +1 -1
  21. package/dist/src/commands/deploy.d.ts +3 -3
  22. package/dist/src/commands/deploy.js +148 -78
  23. package/dist/src/commands/deploy.js.map +1 -1
  24. package/dist/src/commands/init.js +5 -5
  25. package/dist/src/commands/module/add.js +4 -4
  26. package/dist/src/commands/module/list.js +2 -2
  27. package/dist/src/commands/module/remove.js +2 -2
  28. package/dist/src/commands/module/update.js +2 -2
  29. package/dist/src/commands/prompt.js +2 -2
  30. package/dist/src/commands/run.js +2 -2
  31. package/dist/src/commands/setup.js +3 -3
  32. package/dist/src/deploy/config-manager.js +3 -2
  33. package/dist/src/deploy/providers/cloudflare.d.ts +13 -8
  34. package/dist/src/deploy/providers/cloudflare.js +161 -52
  35. package/dist/src/deploy/providers/cloudflare.js.map +1 -1
  36. package/dist/src/deploy/providers/dns-cloudflare.d.ts +9 -0
  37. package/dist/src/deploy/providers/dns-cloudflare.js +123 -0
  38. package/dist/src/deploy/providers/dns-cloudflare.js.map +1 -0
  39. package/dist/src/deploy/providers/github.d.ts +6 -2
  40. package/dist/src/deploy/providers/github.js +37 -45
  41. package/dist/src/deploy/providers/github.js.map +1 -1
  42. package/dist/src/deploy/providers/railway.d.ts +17 -8
  43. package/dist/src/deploy/providers/railway.js +106 -45
  44. package/dist/src/deploy/providers/railway.js.map +1 -1
  45. package/dist/src/deploy/registry.d.ts +7 -4
  46. package/dist/src/deploy/registry.js +2 -2
  47. package/dist/src/deploy/schema.d.ts +188 -0
  48. package/dist/src/deploy/schema.js +11 -0
  49. package/dist/src/deploy/schema.js.map +1 -0
  50. package/dist/src/deploy/template-manager.d.ts +12 -0
  51. package/dist/src/deploy/template-manager.js +9 -0
  52. package/dist/src/deploy/template-manager.js.map +1 -0
  53. package/dist/src/deploy/types.d.ts +42 -17
  54. package/dist/src/deploy/types.js +1 -1
  55. package/dist/src/deploy/types.js.map +1 -1
  56. package/dist/src/deploy/utils.js +2 -2
  57. package/dist/src/utils/discovery.js +2 -2
  58. package/dist/src/utils/filter.js +2 -2
  59. package/dist/src/utils/git.js +2 -2
  60. package/dist/src/utils/url-resolver.js +2 -2
  61. package/dist/templates/github-workflow.yaml +23 -0
  62. package/package.json +2 -2
  63. package/src/commands/deploy.ts +169 -88
  64. package/src/deploy/config-manager.ts +14 -1
  65. package/src/deploy/providers/cloudflare.ts +203 -80
  66. package/src/deploy/providers/dns-cloudflare.ts +134 -0
  67. package/src/deploy/providers/github.ts +44 -47
  68. package/src/deploy/providers/railway.ts +135 -55
  69. package/src/deploy/registry.ts +49 -28
  70. package/src/deploy/schema.ts +39 -0
  71. package/src/deploy/template-manager.ts +32 -0
  72. package/src/deploy/templates/github-workflow.yaml +23 -0
  73. package/src/deploy/types.ts +48 -16
  74. package/test/integration/commands/deploy.integration.test.ts +79 -3
  75. package/test/unit/commands/deploy.test.ts +96 -198
  76. package/test/unit/deploy/config-manager.test.ts +9 -5
  77. package/test/unit/deploy/providers/cloudflare.test.ts +95 -96
  78. package/test/unit/deploy/providers/dns-cloudflare.test.ts +148 -0
  79. package/test/unit/deploy/providers/github.test.ts +43 -47
  80. package/test/unit/deploy/providers/railway.test.ts +50 -261
  81. package/test/unit/deploy/registry.test.ts +20 -17
  82. package/tsup.config.ts +3 -0
  83. package/dist/chunk-2FKDEDDE.js.map +0 -1
  84. package/dist/chunk-EKCOW7FM.js.map +0 -1
  85. /package/dist/{chunk-GUUPSHWC.js.map → chunk-JEMIKBGX.js.map} +0 -0
  86. /package/dist/{chunk-OUGA4CB4.js.map → chunk-JS6WL5NS.js.map} +0 -0
  87. /package/dist/{chunk-GEESHGE4.js.map → chunk-L2RUXOL4.js.map} +0 -0
  88. /package/dist/{chunk-54HY52LH.js.map → chunk-QTJIGPQ3.js.map} +0 -0
  89. /package/dist/{chunk-2JW5BYZW.js.map → chunk-VKE7R2EZ.js.map} +0 -0
  90. /package/dist/{chunk-AC4B3HPJ.js.map → chunk-XONR27KC.js.map} +0 -0
  91. /package/dist/{chunk-PJIOCW2A.js.map → chunk-ZWNIZB3Q.js.map} +0 -0
package/README.md CHANGED
@@ -78,238 +78,142 @@ npm run build
78
78
 
79
79
  ```bash
80
80
  # Run the built CLI
81
- npx nexical <command> [options]
81
+ nexical <command> [options]
82
82
 
83
83
  # Example: Initialize a new project
84
- npx nexical init my-new-project
84
+ nexical init my-new-project
85
85
 
86
86
  # Get help
87
- npx nexical help
87
+ nexical help
88
88
 
89
89
  # Get help for a specific command
90
- npx nexical help init
91
- npx nexical help module add
90
+ nexical help init
91
+ nexical help module add
92
92
  ```
93
93
 
94
94
  ### Command Reference
95
95
 
96
96
  #### `init`
97
97
 
98
- Initializes a new Nexical project by cloning a starter repository, setting up dependencies, and preparing a fresh git history.
98
+ Initializes a new Nexical project. It clones a starter repository, sets up submodules, installs dependencies, and resets the Git history to provide a clean starting point.
99
99
 
100
100
  **Usage:**
101
101
 
102
102
  ```bash
103
- npx nexical init <directory> [options]
103
+ nexical init <directory> [options]
104
104
  ```
105
105
 
106
- **Arguments:**
107
-
108
- - `directory` (Required): The directory to initialize the project in. If the directory does not exist, it will be created. If it does exist, it must be empty.
109
-
110
106
  **Options:**
111
107
 
112
- - `--repo <url>` (Default: `https://github.com/nexical/app-core`): The URL of the starter repository to clone.
113
- - Supports standard Git URLs (e.g., `https://github.com/user/repo.git`).
114
- - Supports GitHub short syntax `gh@owner/repo` (e.g., `gh@nexical/app-core`).
115
-
116
- **What it does:**
117
-
118
- 1. **Clones** the specified starter repository (recursively, including submodules) into the target directory.
119
- 2. **Updates** all submodules to their latest `main` branch.
120
- 3. **Installs** dependencies using `npm install`.
121
- 4. **Resets** Git history:
122
- - Creates an orphan branch (`new-main`).
123
- - Commits all files as an "Initial commit".
124
- - Deletes the old history (removes `main`/`master`).
125
- - Renames the branch to `main`.
126
- - Removes the `origin` remote to prevent accidental pushes to the starter repo.
127
-
128
- **Output:**
129
-
130
- - A ready-to-use Nexical project in the specified directory, with fresh git history and installed dependencies.
108
+ - `--repo <url>`: The Git repository URL of the starter template (Default: `https://github.com/nexical/app-core`).
131
109
 
132
110
  ---
133
111
 
134
- #### `dev`
112
+ #### `deploy`
135
113
 
136
- Starts the development server in ephemeral mode. It constructs a temporary build environment in `site` and runs the Astro dev server with Hot Module Replacement (HMR).
114
+ Orchestrates the deployment of your applications by interacting with cloud providers and configuring your repository's CI/CD environment.
137
115
 
138
116
  **Usage:**
139
117
 
140
118
  ```bash
141
- npx nexical dev
119
+ nexical deploy [options]
142
120
  ```
143
121
 
144
- **What it does:** 2. **Starts** the Astro development server (accessible at `http://localhost:4321` by default). 3. **Watches** for changes in your project and updates the ephemeral build automatically.
145
-
146
- ---
147
-
148
- #### `build`
149
-
150
- Compiles the project for production. It assembles the final site structure in `site` and generates static assets.
151
-
152
- **Usage:**
122
+ **Options:**
153
123
 
154
- ```bash
155
- npx nexical build
124
+ - `--env <environment>`: Deployment environment (e.g., `production`, `staging`). Defaults to `production`.
125
+ - `--apps <apps>`: Comma separated list of applications to deploy (e.g., `backend,frontend`). If omitted, all applications are deployed.
126
+ - `--dry-run`: Simulate the deployment process without making API calls to providers or modifying repository secrets.
127
+
128
+ **Process:**
129
+
130
+ 1. **Load Config**: Reads `nexical.yaml` and validates the schema.
131
+ 2. **Provision**: Concurrently calls providers to ensure resources exist.
132
+ 3. **Sync Secrets**: Collects necessary API tokens and credentials, syncing them to the repository (e.g., GitHub Secrets).
133
+ 4. **Generate Workflows**: Renders CI/CD workflow files into `.github/workflows/` using standard templates.
134
+
135
+ **Configuration (`nexical.yaml`):**
136
+
137
+ ```yaml
138
+ deploy:
139
+ repository:
140
+ provider: github
141
+ apps:
142
+ backend:
143
+ provider: railway
144
+ projectName: my-api
145
+ target: apps/backend
146
+ artifactPath: dist
147
+ buildCommand: npm run build --workspace=@app/backend
148
+ secrets:
149
+ DB_PASSWORD: DATABASE_PASSWORD_ENV # Maps provider secret to local ENV var
150
+ env:
151
+ NODE_ENV: production # Literal value
152
+ frontend:
153
+ provider: cloudflare
154
+ projectName: my-web
155
+ target: apps/frontend
156
+ artifactPath: dist
157
+ buildCommand: npm run build --workspace=@app/frontend
156
158
  ```
157
159
 
158
- **What it does:**
159
-
160
- 1. **Cleans** the `site` directory to ensure a fresh build.
161
- 2. **Copies** all necessary source files (`src/`, `modules`, `src/content`, `public`) into `site`.
162
- 3. **Runs** `astro build` to generate the production output in `site/dist`.
163
-
164
- **Output:**
165
-
166
- - A production-ready static site in `site/dist`.
167
-
168
160
  ---
169
161
 
170
- #### `preview`
162
+ #### `prompt`
171
163
 
172
- Previews the locally built production site. This is useful for verifying the output of `nexical build` before deploying.
164
+ Packages the project context using `repomix` and runs AI-powered analysis or generation.
173
165
 
174
166
  **Usage:**
175
167
 
176
168
  ```bash
177
- npx nexical preview
169
+ nexical prompt [options]
178
170
  ```
179
171
 
180
- **Prerequisites:**
181
-
182
- - You must run `nexical build` first.
183
-
184
- **What it does:**
172
+ **Options:**
185
173
 
186
- - Starts a local web server serving the static files from `site/dist`.
174
+ - `--output <path>`: Path to save the packed context file.
175
+ - `--config <path>`: Custom configuration for the prompt runner.
187
176
 
188
177
  ---
189
178
 
190
- #### `clean`
179
+ #### `setup`
191
180
 
192
- Removes generated build artifacts and temporary directories to ensure a clean state.
181
+ Prepares the local development environment, ensuring all necessary tools and configurations are in place.
193
182
 
194
183
  **Usage:**
195
184
 
196
185
  ```bash
197
- npx nexical clean
186
+ nexical setup
198
187
  ```
199
188
 
200
- **What it does:**
201
-
202
- - Deletes `site`, `dist`, and `node_modules/.vite`.
203
-
204
189
  ---
205
190
 
206
191
  #### `run`
207
192
 
208
- Executes a script within the Nexical environment context. This handles path resolution and environment variable setup for you.
193
+ Executes a command or script within the Nexical project context, handling environment variables and path resolution.
209
194
 
210
195
  **Usage:**
211
196
 
212
197
  ```bash
213
- npx nexical run <script> [args...]
214
- ```
215
-
216
- **Arguments:**
217
-
218
- - `script` (Required): The name of the script to run.
219
- - Can be a standard `package.json` script (e.g., `test`).
220
- - Can be a module-specific script using `module:script` syntax (e.g., `blog:sync`).
221
- - `args` (Optional): Additional arguments to pass to the script.
222
-
223
- **Examples:**
224
-
225
- ```bash
226
- # Run a core project script
227
- npx nexical run test
228
-
229
- # Run a script defined in the 'blog' module's package.json
230
- npx nexical run blog:sync --force
198
+ nexical run <script> [args...]
231
199
  ```
232
200
 
233
201
  ---
234
202
 
235
203
  #### `module`
236
204
 
237
- Manages the modular architecture of your Nexical project. Allows you to add, remove, update, and list Git-based modules.
238
-
239
- ##### `module add`
240
-
241
- Adds a new module as a Git submodule.
242
-
243
- **Usage:**
244
-
245
- ```bash
246
- npx nexical module add <url> [name]
247
- ```
248
-
249
- **Arguments:**
250
-
251
- - `url` (Required): The Git repository URL of the module.
252
- - Supports `gh@owner/repo` shorthand.
253
- - `name` (Optional): The folder name for the module. Defaults to the repository name.
254
-
255
- **What it does:**
205
+ Manages the modular components of your project.
256
206
 
257
- 1. Adds the repository as a git submodule in `src/modules/<name>`.
258
- 2. Installs any new dependencies via `npm install`.
207
+ - **`module add <url> [name]`**: Adds a new Git-based module as a submodule.
208
+ - **`module list`**: Displays a table of all installed modules.
209
+ - **`module update [name]`**: Updates a specific module or all modules to their latest remote versions.
210
+ - **`module remove <name>`**: Safely removes a module and cleans up Git metadata.
259
211
 
260
- ##### `module list`
261
-
262
- Lists all installed modules in the project.
263
-
264
- **Usage:**
265
-
266
- ```bash
267
- npx nexical module list
268
- ```
269
-
270
- **Output:**
271
-
272
- - A table showing the name, version, and description of each installed module found in `src/modules`.
273
-
274
- ##### `module update`
275
-
276
- Updates one or all modules to their latest remote commit.
277
-
278
- **Usage:**
279
-
280
- ```bash
281
- npx nexical module update [name]
282
- ```
283
-
284
- **Arguments:**
285
-
286
- - `name` (Optional): The specific module to update. If omitted, all modules are updated.
287
-
288
- **What it does:**
289
-
290
- 1. Runs `git submodule update --remote --merge` for the target(s).
291
- 2. Re-installs dependencies to ensure `package-lock.json` is consistent.
292
-
293
- ##### `module remove`
294
-
295
- Removes an installed module and cleans up references.
296
-
297
- **Usage:**
298
-
299
- ```bash
300
- npx nexical module remove <name>
301
- ```
302
-
303
- **Arguments:**
304
-
305
- - `name` (Required): The name of the module to remove.
212
+ ---
306
213
 
307
- **What it does:**
214
+ #### `dev` / `build` / `preview`
308
215
 
309
- 1. De-initializes the git submodule.
310
- 2. Removes the module directory from `src/modules`.
311
- 3. Cleans up internal git metadata (`.git/modules`).
312
- 4. Updates `npm` dependencies.
216
+ Standard development cycle commands inherited from the underlying app structure (typically Astro).
313
217
 
314
218
  ---
315
219
 
@@ -318,20 +222,21 @@ npx nexical module remove <name>
318
222
  ```mermaid
319
223
  graph TD
320
224
  src-->commands
225
+ src-->deploy
321
226
  src-->core
322
227
  src-->utils
228
+ commands-->deploy.ts
323
229
  commands-->init.ts
324
- core-->CLI.ts
325
- core-->BaseCommand.ts
326
- core-->CommandLoader.ts
327
- utils-->config.ts
328
- utils-->logger.ts
230
+ commands-->module
231
+ deploy-->providers
232
+ deploy-->schema.ts
233
+ deploy-->template-manager.ts
329
234
  ```
330
235
 
331
- - **`src/commands/`**: Contains the implementations of individual CLI commands. File names correspond to command names.
332
- - **`src/core/`**: The framework logic (Command loading, Base class, CLI orchestration).
333
- - **`src/utils/`**: Shared utilities (Logging, Configuration parsing).
334
- - **`test/unit/`**: Co-located unit tests. Mirrors the `src` structure.
236
+ - **`src/commands/`**: Command implementation classes.
237
+ - **`src/deploy/`**: Core logic for the deployment orchestration system.
238
+ - **`src/core/`**: CLI framework (base classes, loader).
239
+ - **`src/utils/`**: Helper utilities.
335
240
 
336
241
  ---
337
242
 
@@ -339,87 +244,37 @@ graph TD
339
244
 
340
245
  ### Prerequisites
341
246
 
342
- - Node.js (v18+ recommended)
343
- - NPM
247
+ - Node.js (v18+)
248
+ - NPM/PNPM
344
249
 
345
250
  ### Setup
346
251
 
347
- 1. **Install Dependencies**:
348
-
349
- ```bash
350
- npm install
351
- ```
352
-
353
- 2. **Build in Watch Mode**:
354
- ```bash
355
- npm run dev
356
- ```
357
- This uses `tsup` to watch for changes and rebuild `dist/`.
358
-
359
- ### Running Tests
360
-
361
- We prioritize **100% Test Coverage**. All logic branches, statements, and lines must be covered.
362
-
363
252
  ```bash
364
- # Run all unit tests (with coverage report)
365
- npm run test
253
+ npm install
254
+ npm run build # Required to generate dist/ for local execution
366
255
  ```
367
256
 
368
- Tests are written using `vitest` and are located in `test/unit/`. When submitting changes, ensure coverage remains at 100%.
369
-
370
- ---
371
-
372
- ## Adding New Commands
373
-
374
- To create a new command, add a TypeScript file to `src/commands/`.
375
-
376
- **Example:** Create `src/commands/hello.ts`
377
-
378
- ```typescript
379
- import { BaseCommand } from '../core/BaseCommand.js';
380
-
381
- export default class HelloCommand extends BaseCommand {
382
- // 1. Define command metadata
383
- static description = 'Say hello to the world';
384
-
385
- static args = {
386
- args: [{ name: 'name', required: false, description: 'User name' }],
387
- options: [{ name: '--shout', description: 'Say it loud', default: false }],
388
- };
257
+ ### Running Tests
389
258
 
390
- // 2. Implement the run method
391
- async run(options: any) {
392
- const name = options.name || 'World';
259
+ We maintain strict **100% test coverage** for all logic.
393
260
 
394
- if (options.shout) {
395
- this.success(`HELLO ${name.toUpperCase()}!`);
396
- } else {
397
- this.log(`Hello ${name}`);
398
- }
399
- }
400
- }
261
+ ```bash
262
+ npm run test # All tests
263
+ npm run test:unit # Unit tests
264
+ npm run test:integration # Integration tests
401
265
  ```
402
266
 
403
- **Key Requirement**: The file MUST default export a class extending `BaseCommand`.
404
-
405
- - **File Naming**:
406
- - `hello.ts` -> Command: `hello`
407
- - `users/create.ts` -> Command: `users create`
408
- - `users/index.ts` -> Command: `users` (Parent command)
409
-
410
267
  ---
411
268
 
412
269
  ## Contributing
413
270
 
414
- Contributions are welcome! Please follow these steps:
415
-
416
- 1. Fork the repository.
417
- 2. Create a feature branch.
418
- 3. Add your changes and **ensure tests pass with 100% coverage**.
419
- 4. Submit a Pull Request.
271
+ 1. Fork the repo and create a branch.
272
+ 2. Implement changes with accompanying tests.
273
+ 3. Ensure 100% coverage: `npm run test:unit`.
274
+ 4. Submit a PR.
420
275
 
421
276
  ---
422
277
 
423
278
  ## License
424
279
 
425
- This project is licensed under the **Apache License 2.0**.
280
+ Apache License 2.0
@@ -17,6 +17,10 @@ var __esm = (fn, res) => function __init() {
17
17
  var __commonJS = (cb, mod) => function __require2() {
18
18
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
19
19
  };
20
+ var __export = (target, all) => {
21
+ for (var name in all)
22
+ __defProp(target, name, { get: all[name], enumerable: true });
23
+ };
20
24
  var __copyProps = (to, from, except, desc) => {
21
25
  if (from && typeof from === "object" || typeof from === "function") {
22
26
  for (let key of __getOwnPropNames(from))
@@ -46,7 +50,8 @@ var init_esm_shims = __esm({
46
50
  export {
47
51
  __require,
48
52
  __commonJS,
53
+ __export,
49
54
  __toESM,
50
55
  init_esm_shims
51
56
  };
52
- //# sourceMappingURL=chunk-OYFWMYPG.js.map
57
+ //# sourceMappingURL=chunk-6DE5Q66O.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../node_modules/tsup/assets/esm_shims.js"],"sourcesContent":["// Shim globals in esm bundle\nimport path from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nconst getFilename = () => fileURLToPath(import.meta.url)\nconst getDirname = () => path.dirname(getFilename())\n\nexport const __dirname = /* @__PURE__ */ getDirname()\nexport const __filename = /* @__PURE__ */ getFilename()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAF9B;AAAA;AAAA;AAAA;AAAA;","names":[]}
@@ -0,0 +1,31 @@
1
+ import { createRequire } from "module"; const require = createRequire(import.meta.url);
2
+ import {
3
+ init_esm_shims
4
+ } from "./chunk-6DE5Q66O.js";
5
+
6
+ // src/deploy/template-manager.ts
7
+ init_esm_shims();
8
+ import fs from "fs/promises";
9
+ import path from "path";
10
+ import YAML from "yaml";
11
+ import { fileURLToPath } from "url";
12
+ var __dirname = path.dirname(fileURLToPath(import.meta.url));
13
+ var TemplateManager = class {
14
+ templatesDir;
15
+ constructor() {
16
+ this.templatesDir = path.join(__dirname, "templates");
17
+ }
18
+ async loadWorkflow(name, data) {
19
+ const templatePath = path.join(this.templatesDir, `${name}.yaml`);
20
+ let content = await fs.readFile(templatePath, "utf-8");
21
+ for (const [key, value] of Object.entries(data)) {
22
+ content = content.split(`\${${key}}`).join(value);
23
+ }
24
+ return YAML.parse(content);
25
+ }
26
+ };
27
+
28
+ export {
29
+ TemplateManager
30
+ };
31
+ //# sourceMappingURL=chunk-G66GMEFE.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/deploy/template-manager.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport YAML from 'yaml';\nimport { fileURLToPath } from 'node:url';\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nexport interface WorkflowTemplateData {\n APP_NAME: string;\n PROVIDER_NAME: string;\n [key: string]: string;\n}\n\nexport class TemplateManager {\n private templatesDir: string;\n\n constructor() {\n this.templatesDir = path.join(__dirname, 'templates');\n }\n\n async loadWorkflow(name: string, data: WorkflowTemplateData): Promise<unknown> {\n const templatePath = path.join(this.templatesDir, `${name}.yaml`);\n let content = await fs.readFile(templatePath, 'utf-8');\n\n // Simple placeholder replacement\n for (const [key, value] of Object.entries(data)) {\n content = content.split(`\\${${key}}`).join(value);\n }\n\n return YAML.parse(content);\n }\n}\n"],"mappings":";;;;;;AAAA;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,YAAY,KAAK,QAAQ,cAAc,YAAY,GAAG,CAAC;AAQtD,IAAM,kBAAN,MAAsB;AAAA,EACnB;AAAA,EAER,cAAc;AACZ,SAAK,eAAe,KAAK,KAAK,WAAW,WAAW;AAAA,EACtD;AAAA,EAEA,MAAM,aAAa,MAAc,MAA8C;AAC7E,UAAM,eAAe,KAAK,KAAK,KAAK,cAAc,GAAG,IAAI,OAAO;AAChE,QAAI,UAAU,MAAM,GAAG,SAAS,cAAc,OAAO;AAGrD,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,IAAI,GAAG;AAC/C,gBAAU,QAAQ,MAAM,MAAM,GAAG,GAAG,EAAE,KAAK,KAAK;AAAA,IAClD;AAEA,WAAO,KAAK,MAAM,OAAO;AAAA,EAC3B;AACF;","names":[]}
@@ -1,13 +1,17 @@
1
1
  import { createRequire } from "module"; const require = createRequire(import.meta.url);
2
+ import {
3
+ DeploymentSchema
4
+ } from "./chunk-JGAMEJTL.js";
2
5
  import {
3
6
  init_esm_shims
4
- } from "./chunk-OYFWMYPG.js";
7
+ } from "./chunk-6DE5Q66O.js";
5
8
 
6
9
  // src/deploy/config-manager.ts
7
10
  init_esm_shims();
8
11
  import fs from "fs/promises";
9
12
  import path from "path";
10
13
  import YAML from "yaml";
14
+ import { logger } from "@nexical/cli-core";
11
15
  var ConfigManager = class {
12
16
  configPath;
13
17
  constructor(cwd) {
@@ -16,7 +20,16 @@ var ConfigManager = class {
16
20
  async load() {
17
21
  try {
18
22
  const content = await fs.readFile(this.configPath, "utf-8");
19
- return YAML.parse(content);
23
+ const parsed = YAML.parse(content);
24
+ const result = DeploymentSchema.safeParse(parsed);
25
+ if (!result.success) {
26
+ logger.error("Invalid nexical.yaml configuration:");
27
+ result.error.issues.forEach((err) => {
28
+ logger.error(` - ${err.path.join(".")}: ${err.message}`);
29
+ });
30
+ throw new Error("Configuration validation failed.");
31
+ }
32
+ return result.data;
20
33
  } catch (error) {
21
34
  if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
22
35
  return {};
@@ -36,4 +49,4 @@ var ConfigManager = class {
36
49
  export {
37
50
  ConfigManager
38
51
  };
39
- //# sourceMappingURL=chunk-2FKDEDDE.js.map
52
+ //# sourceMappingURL=chunk-HOVS7SCD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/deploy/config-manager.ts"],"sourcesContent":["import fs from 'node:fs/promises';\nimport path from 'node:path';\nimport YAML from 'yaml';\nimport { NexicalConfig } from './types';\nimport { DeploymentSchema } from './schema';\nimport { logger } from '@nexical/cli-core';\n\nexport class ConfigManager {\n private configPath: string;\n\n constructor(cwd: string) {\n this.configPath = path.join(cwd, 'nexical.yaml');\n }\n\n async load(): Promise<NexicalConfig> {\n try {\n const content = await fs.readFile(this.configPath, 'utf-8');\n const parsed = YAML.parse(content);\n\n const result = DeploymentSchema.safeParse(parsed);\n if (!result.success) {\n logger.error('Invalid nexical.yaml configuration:');\n result.error.issues.forEach((err) => {\n logger.error(` - ${err.path.join('.')}: ${err.message}`);\n });\n throw new Error('Configuration validation failed.');\n }\n\n return result.data as NexicalConfig;\n } catch (error: unknown) {\n if (\n error &&\n typeof error === 'object' &&\n 'code' in error &&\n (error as { code: unknown }).code === 'ENOENT'\n ) {\n return {};\n }\n throw error;\n }\n }\n\n async save(config: NexicalConfig): Promise<void> {\n const content = YAML.stringify(config);\n await fs.writeFile(this.configPath, content, 'utf-8');\n }\n\n exists(): Promise<boolean> {\n return fs\n .access(this.configPath)\n .then(() => true)\n .catch(() => false);\n }\n}\n"],"mappings":";;;;;;;;;AAAA;AAAA,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,OAAO,UAAU;AAGjB,SAAS,cAAc;AAEhB,IAAM,gBAAN,MAAoB;AAAA,EACjB;AAAA,EAER,YAAY,KAAa;AACvB,SAAK,aAAa,KAAK,KAAK,KAAK,cAAc;AAAA,EACjD;AAAA,EAEA,MAAM,OAA+B;AACnC,QAAI;AACF,YAAM,UAAU,MAAM,GAAG,SAAS,KAAK,YAAY,OAAO;AAC1D,YAAM,SAAS,KAAK,MAAM,OAAO;AAEjC,YAAM,SAAS,iBAAiB,UAAU,MAAM;AAChD,UAAI,CAAC,OAAO,SAAS;AACnB,eAAO,MAAM,qCAAqC;AAClD,eAAO,MAAM,OAAO,QAAQ,CAAC,QAAQ;AACnC,iBAAO,MAAM,OAAO,IAAI,KAAK,KAAK,GAAG,CAAC,KAAK,IAAI,OAAO,EAAE;AAAA,QAC1D,CAAC;AACD,cAAM,IAAI,MAAM,kCAAkC;AAAA,MACpD;AAEA,aAAO,OAAO;AAAA,IAChB,SAAS,OAAgB;AACvB,UACE,SACA,OAAO,UAAU,YACjB,UAAU,SACT,MAA4B,SAAS,UACtC;AACA,eAAO,CAAC;AAAA,MACV;AACA,YAAM;AAAA,IACR;AAAA,EACF;AAAA,EAEA,MAAM,KAAK,QAAsC;AAC/C,UAAM,UAAU,KAAK,UAAU,MAAM;AACrC,UAAM,GAAG,UAAU,KAAK,YAAY,SAAS,OAAO;AAAA,EACtD;AAAA,EAEA,SAA2B;AACzB,WAAO,GACJ,OAAO,KAAK,UAAU,EACtB,KAAK,MAAM,IAAI,EACf,MAAM,MAAM,KAAK;AAAA,EACtB;AACF;","names":[]}
@@ -1,11 +1,11 @@
1
1
  import { createRequire } from "module"; const require = createRequire(import.meta.url);
2
2
  import {
3
3
  require_lib
4
- } from "./chunk-OUGA4CB4.js";
4
+ } from "./chunk-JS6WL5NS.js";
5
5
  import {
6
6
  __toESM,
7
7
  init_esm_shims
8
- } from "./chunk-OYFWMYPG.js";
8
+ } from "./chunk-6DE5Q66O.js";
9
9
 
10
10
  // src/commands/setup.ts
11
11
  init_esm_shims();
@@ -67,4 +67,4 @@ var SetupCommand = class extends BaseCommand {
67
67
  export {
68
68
  SetupCommand
69
69
  };
70
- //# sourceMappingURL=chunk-GUUPSHWC.js.map
70
+ //# sourceMappingURL=chunk-JEMIKBGX.js.map