@xo-code/cli 0.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 (3) hide show
  1. package/README.md +192 -0
  2. package/dist/index.js +316609 -0
  3. package/package.json +38 -0
package/README.md ADDED
@@ -0,0 +1,192 @@
1
+ <div align="center">
2
+ <img src="https://raw.githubusercontent.com/betaversionio/xocode/main/apps/web/public/android-chrome-512x512.png" width="96" alt="xo logo" />
3
+ <h1>xo — Local Workflow Engine for Developers</h1>
4
+ <p>GitHub Actions for your local machine.</p>
5
+ </div>
6
+
7
+ ---
8
+
9
+ `xo` is a local workflow engine for project scaffolding, feature addition, and task automation. Think of it as GitHub Actions — but running on your machine, against your project.
10
+
11
+ Define reusable **actions**, compose them into **workflows**, share them through the xo registry — all in plain YAML.
12
+
13
+ ---
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -g @xo-code/cli
19
+ ```
20
+
21
+ Then use it as `xo`:
22
+
23
+ ```bash
24
+ xo --version
25
+ xo add ui/button
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ # From the registry (registered name)
34
+ xo add payment/stripe
35
+ xo add ui/button
36
+
37
+ # Directly from GitHub — no registration needed
38
+ xo add @github/my-org/xo-stripe
39
+ xo add @github/my-org/xo-ui/button # subpath (multi-component repo)
40
+ xo add @github/my-org/xo-ui/button@v1.2.0 # pinned to tag
41
+ xo add @github/my-org/xo-ui/button#dev # pinned to branch
42
+ ```
43
+
44
+ | Command | What it does |
45
+ |---|---|
46
+ | `xo create <template>` | Scaffold a new project |
47
+ | `xo add <feature>` | Add a feature to an existing project |
48
+ | `xo run <task>` | Run a named task |
49
+ | `xo undo` | Revert the last operation |
50
+
51
+ ---
52
+
53
+ ## How It Works
54
+
55
+ xo has two core concepts: **actions** and **workflows**.
56
+
57
+ **Actions** are atomic, reusable units of work. They accept `with:` inputs and produce `outputs`. Built-in actions are prefixed `xo/`. You can also write custom actions as YAML composites or Node.js scripts.
58
+
59
+ **Workflows** compose actions into jobs with inputs, conditionals, and dependency ordering — exactly like GitHub Actions workflow files.
60
+
61
+ ```yaml
62
+ # workflow.yaml (lives in a generator repo on GitHub)
63
+ name: payment/stripe
64
+ on: [add]
65
+
66
+ inputs:
67
+ secretKey:
68
+ prompt: "Stripe secret key?"
69
+ required: true
70
+
71
+ jobs:
72
+ detect:
73
+ steps:
74
+ - uses: xo/detect-pm # outputs: { value: "pnpm" }
75
+ id: pm
76
+ - uses: xo/pkg-installed # outputs: { installed: true }
77
+ id: hasNext
78
+ with:
79
+ pkg: next
80
+
81
+ install:
82
+ needs: [detect]
83
+ steps:
84
+ - uses: xo/install-pkg
85
+ with:
86
+ pkg: stripe
87
+
88
+ - uses: xo/env
89
+ with:
90
+ file: .env.example
91
+ variables:
92
+ STRIPE_SECRET_KEY: ""
93
+
94
+ - if: "steps.hasNext.outputs.installed == true"
95
+ uses: xo/copy
96
+ with:
97
+ from: templates/stripe-route.ts
98
+ to: app/api/stripe/route.ts
99
+
100
+ - run: "{{steps.pm.outputs.value}} db:push"
101
+ ```
102
+
103
+ ---
104
+
105
+ ## Custom Actions
106
+
107
+ Package reusable logic as YAML composites or Node.js scripts and reference them from any workflow.
108
+
109
+ **Composite action** (`./actions/add-barrel.yaml`):
110
+ ```yaml
111
+ name: add-barrel-export
112
+ inputs:
113
+ exportName:
114
+ prompt: "Export name?"
115
+ outputs:
116
+ exportLine:
117
+ value: "export { default as {{inputs.exportName}} } from './{{inputs.exportName}}';"
118
+ steps:
119
+ - uses: xo/append
120
+ with:
121
+ file: src/components/index.ts
122
+ content: "export { default as {{inputs.exportName}} } from './{{inputs.exportName}}';"
123
+ ```
124
+
125
+ **Script action** (`./actions/validate.js`):
126
+ ```js
127
+ export default async function run({ inputs, cwd, dryRun }) {
128
+ // full Node.js — call APIs, read files, anything
129
+ return { valid: true };
130
+ }
131
+ ```
132
+
133
+ **Published action** (shared via GitHub):
134
+ ```yaml
135
+ - uses: @github/my-org/xo-ensure-ts@v1.0.0
136
+ with:
137
+ strict: "true"
138
+ ```
139
+
140
+ ---
141
+
142
+ ## Local Generator Development
143
+
144
+ Test a generator locally without publishing using `xo link`:
145
+
146
+ ```bash
147
+ cd ~/projects/xo-button
148
+ xo link # links ui/button → this directory
149
+
150
+ # from any project:
151
+ xo add ui/button # resolves to your local directory
152
+ ```
153
+
154
+ ---
155
+
156
+ ## CLI Output
157
+
158
+ ```
159
+ $ xo add payment/stripe
160
+
161
+ Running workflow: payment/stripe
162
+
163
+ job: detect
164
+ ✔ xo/detect-pm → pnpm
165
+ ✔ xo/pkg-installed(next) → true (^14.0.0)
166
+ job: install
167
+ ✔ xo/install-pkg → stripe
168
+ ✔ xo/env → STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET
169
+ ✔ xo/copy → app/api/stripe/route.ts
170
+ ✔ run: pnpm db:push
171
+
172
+ ✔ payment/stripe added successfully
173
+ Operation ID: a3f1c2d4
174
+ Run xo undo to revert.
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Documentation
180
+
181
+ | Doc | Description |
182
+ |---|---|
183
+ | [CLI Reference](https://github.com/betaversionio/xocode/blob/main/docs/cli.md) | All commands and flags |
184
+ | [Workflow Reference](https://github.com/betaversionio/xocode/blob/main/docs/workflows.md) | `workflow.yaml` full schema |
185
+ | [Action Reference](https://github.com/betaversionio/xocode/blob/main/docs/actions.md) | Built-in + custom actions |
186
+ | [Generator Reference](https://github.com/betaversionio/xocode/blob/main/docs/generators.md) | Repo structure, registry, writing generators |
187
+
188
+ ---
189
+
190
+ ## Requirements
191
+
192
+ - Node.js >= 18