@quatrain/cli 1.1.9 → 1.1.10

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 (2) hide show
  1. package/README.md +86 -43
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,60 +1,103 @@
1
- # @quatrain/core-cli
1
+ # @quatrain/cli
2
2
 
3
- The official Command Line Interface (CLI) for the Quatrain ecosystem.
4
- This CLI provides tools to scaffold projects, generate normalized bootloader configurations, and create migration files.
3
+ The official Command Line Interface (CLI) and script utility library for the Quatrain ecosystem.
5
4
 
6
- ## Installation
5
+ This package serves two distinct purposes:
6
+ 1. **Programmatic Utilities (Library API):** Exported classes and prompt helpers to build interactive scripts and run system subprocesses (e.g. within agent skills).
7
+ 2. **Core Command-Line Executable (`core`):** A global terminal command runner to scaffold projects, generate configurations, and manage deployments.
7
8
 
8
- You can install the CLI globally via NPM or Yarn, or run it on the fly using `npx` or `bunx`.
9
+ ---
9
10
 
10
- ### Global Installation
11
+ ## 1. Programmatic Utilities (Library API)
11
12
 
12
- ```bash
13
- npm install -g @quatrain/core-cli
14
- # or
15
- yarn global add @quatrain/core-cli
16
- # or via Bun
17
- bun add -g @quatrain/core-cli
18
- ```
13
+ Import these utilities directly in your TypeScript/JavaScript scripts to interact with the user or run external processes.
19
14
 
20
- ### On-the-fly Execution
15
+ ### A. Fluent Command Executor (`Command`)
21
16
 
22
- ```bash
23
- npx @quatrain/core-cli <command>
24
- # or
25
- bunx @quatrain/core-cli <command>
17
+ The `Command` class provides a cross-platform, fluent builder-pattern interface to execute system subprocesses. It simplifies spawning commands, passing arguments, setting working directories, extending environment variables, and supports PowerShell routing.
18
+
19
+ ```typescript
20
+ import { Command } from '@quatrain/cli';
21
+
22
+ const result = await Command.create('kubectl')
23
+ .arg('apply')
24
+ .arg('-f')
25
+ .arg('deployment.yaml')
26
+ .cwd('/path/to/project')
27
+ .env({ KUBECONFIG: '/path/to/config' })
28
+ .execute();
29
+
30
+ if (result.success) {
31
+ console.log(`Success: ${result.stdout}`);
32
+ } else {
33
+ console.error(`Exit code: ${result.code}, Error: ${result.stderr}`);
34
+ }
26
35
  ```
27
36
 
28
- ## Commands
37
+ **Fluent Methods:**
38
+ - `Command.create(bin)` / `new Command(bin)`: Start building a command for the given binary.
39
+ - `.arg(value)` / `.args([values])`: Append command-line arguments.
40
+ - `.cwd(dir)`: Set the execution working directory.
41
+ - `.env({ KEY: VALUE })`: Set or extend environment variables.
42
+ - `.inherit()`: Direct stdout and stderr to the parent process terminal.
43
+ - `.usePowerShell(use, type)`: Force process execution through PowerShell (`powershell.exe` or `pwsh`) with safe quote escaping.
44
+ - `.execute()`: Run the process asynchronously and return `{ stdout, stderr, code, success }`.
29
45
 
30
- ### `core generate scaffold <project-name>`
31
- Quickly initializes a new Quatrain project.
32
- - Creates a base directory.
33
- - Sets up the `apps/`, `data/`, `config/`, `packages/`, and `migrations/` folders.
34
- - Generates a monorepo-ready `package.json` utilizing Yarn workspaces.
35
- - Generates a `tsconfig.json` pre-configured with the required path mappings.
46
+ ### B. Interactive Prompt Helpers
36
47
 
37
- ### `core generate config`
38
- Starts an interactive wizard to generate a `quatrain.json` configuration file.
39
- - Prompts for Backend, Auth, Queue, Storage, and Messaging adapters.
40
- - Generates a normalized JSON configuration.
41
- - The generated `env(...)` tokens will be resolved at runtime by the `AppBootloader`.
48
+ Helpers wrapping `inquirer` to prompt user inputs cleanly:
42
49
 
43
- ### `core generate migration <name>`
44
- Scaffolds a new migration file.
45
- - Creates a `migrations/` directory if it does not exist.
46
- - Generates a timestamped TypeScript file (e.g., `20260427184500_init.ts`).
47
- - Provides boilerplate `up()` and `down()` methods.
50
+ ```typescript
51
+ import { askConfirm, askInput, askChoice } from '@quatrain/cli';
48
52
 
49
- ## Language Guidelines
50
- > **Recommendation:** All text contents (such as console logs, commit messages, and comments) within the Quatrain ecosystem must be written in **International English**. This ensures accessibility and maintainability for developers worldwide.
53
+ // Yes/No Confirmations
54
+ const proceed = await askConfirm('Do you want to deploy now?');
55
+
56
+ // String Inputs
57
+ const name = await askInput('Enter your username:', 'default_user');
58
+
59
+ // Multi-choice select lists
60
+ const selected = await askChoice('Select action:', [
61
+ { name: 'Sync Google Calendar', value: 'sync' },
62
+ { name: 'Reset Database', value: 'reset' }
63
+ ]);
64
+ ```
65
+
66
+ ---
67
+
68
+ ## 2. Core Command-Line Executable
51
69
 
52
- ## HOWTO / Usage Examples
70
+ A global CLI tool invoked via the `core` command (or `quatrain` depending on symlinks).
71
+
72
+ ### Installation
73
+
74
+ Install globally or run on-the-fly:
53
75
 
54
76
  ```bash
55
- # Example of scaffolding a new project
56
- yarn global add @quatrain/core-cli
57
- quatrain generate scaffold my-app
58
- cd my-app
59
- yarn install
77
+ # Global
78
+ bun add -g @quatrain/cli
79
+
80
+ # Run on the fly
81
+ bunx @quatrain/cli <command>
60
82
  ```
83
+
84
+ ### Commands Reference
85
+
86
+ #### `core deploy`
87
+ Manage Kubernetes deployments (create, list, modify, promote, delete namespaces and manifests).
88
+
89
+ #### `core generate scaffold <project-name>`
90
+ Initialize a new Quatrain project structure:
91
+ - Sets up directories: `apps/`, `data/`, `config/`, `packages/`, `migrations/`.
92
+ - Generates a monorepo-ready workspace `package.json` and a pre-configured `tsconfig.json`.
93
+
94
+ #### `core generate config`
95
+ Start an interactive wizard to generate the `quatrain.json` bootloader configuration file.
96
+
97
+ #### `core generate migration <name>`
98
+ Scaffold a timestamped TypeScript migration file (e.g., `migrations/20260427_name.ts`) with template `up()` and `down()` blocks.
99
+
100
+ ---
101
+
102
+ ## Language Guidelines
103
+ > **Recommendation:** All text contents (logs, console prints, commit messages, comments) within the Quatrain ecosystem must be written in **International English** to ensure global team maintainability.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quatrain/cli",
3
- "version": "1.1.9",
3
+ "version": "1.1.10",
4
4
  "license": "AGPL-3.0-only",
5
5
  "description": "Quatrain Core CLI for generating configurations and migrations",
6
6
  "main": "dist/index.js",