@ticatec/omniflow 0.1.5

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 (55) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +476 -0
  3. package/dist/cli/commands/run.d.ts +7 -0
  4. package/dist/cli/commands/run.d.ts.map +1 -0
  5. package/dist/cli/commands/run.js +242 -0
  6. package/dist/cli/commands/run.js.map +1 -0
  7. package/dist/cli/index.d.ts +3 -0
  8. package/dist/cli/index.d.ts.map +1 -0
  9. package/dist/cli/index.js +211 -0
  10. package/dist/cli/index.js.map +1 -0
  11. package/dist/config/index.d.ts +2 -0
  12. package/dist/config/index.d.ts.map +1 -0
  13. package/dist/config/index.js +3 -0
  14. package/dist/config/index.js.map +1 -0
  15. package/dist/config/omniflow.d.ts +115 -0
  16. package/dist/config/omniflow.d.ts.map +1 -0
  17. package/dist/config/omniflow.js +451 -0
  18. package/dist/config/omniflow.js.map +1 -0
  19. package/dist/core/git.d.ts +22 -0
  20. package/dist/core/git.d.ts.map +1 -0
  21. package/dist/core/git.js +164 -0
  22. package/dist/core/git.js.map +1 -0
  23. package/dist/core/strategies/BaseMergeRequest.d.ts +58 -0
  24. package/dist/core/strategies/BaseMergeRequest.d.ts.map +1 -0
  25. package/dist/core/strategies/BaseMergeRequest.js +57 -0
  26. package/dist/core/strategies/BaseMergeRequest.js.map +1 -0
  27. package/dist/core/strategies/ForgejoRequest.d.ts +35 -0
  28. package/dist/core/strategies/ForgejoRequest.d.ts.map +1 -0
  29. package/dist/core/strategies/ForgejoRequest.js +82 -0
  30. package/dist/core/strategies/ForgejoRequest.js.map +1 -0
  31. package/dist/core/strategies/GitHubRequest.d.ts +34 -0
  32. package/dist/core/strategies/GitHubRequest.d.ts.map +1 -0
  33. package/dist/core/strategies/GitHubRequest.js +84 -0
  34. package/dist/core/strategies/GitHubRequest.js.map +1 -0
  35. package/dist/core/strategies/GitLabRequest.d.ts +25 -0
  36. package/dist/core/strategies/GitLabRequest.d.ts.map +1 -0
  37. package/dist/core/strategies/GitLabRequest.js +70 -0
  38. package/dist/core/strategies/GitLabRequest.js.map +1 -0
  39. package/dist/core/strategies/index.d.ts +36 -0
  40. package/dist/core/strategies/index.d.ts.map +1 -0
  41. package/dist/core/strategies/index.js +50 -0
  42. package/dist/core/strategies/index.js.map +1 -0
  43. package/dist/core/strategies/types.d.ts +22 -0
  44. package/dist/core/strategies/types.d.ts.map +1 -0
  45. package/dist/core/strategies/types.js +5 -0
  46. package/dist/core/strategies/types.js.map +1 -0
  47. package/dist/index.d.ts +2 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +3 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/types/config.d.ts +63 -0
  52. package/dist/types/config.d.ts.map +1 -0
  53. package/dist/types/config.js +3 -0
  54. package/dist/types/config.js.map +1 -0
  55. package/package.json +88 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Ticatc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,476 @@
1
+ # Omniflow - CI/CD Pipeline Manager
2
+
3
+ [![npm version](https://badge.fury.io/js/%40ticatec%2Fomniflow.svg)](https://www.npmjs.com/package/@ticatec/omniflow)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ [中文文档](./README_CN.md)
7
+
8
+ A unified CI/CD project scheduling and management tool with **unified scheduling entry + project self-managed pipeline** architecture.
9
+
10
+ ## Core Design
11
+
12
+ ```
13
+ OMNIFLOW_CONFIG_REPO (env var) → Configuration repository URL
14
+
15
+ Fetch config.yaml from git on each run → Unified scheduling entry, defines all projects and environments
16
+
17
+ Project repo/omniflow/deploy.js → Deployment script, managed by project itself
18
+ ```
19
+
20
+ ## Features
21
+
22
+ - **Unified Scheduling Entry** - Manage all CI/CD projects in one config file
23
+ - **Configuration from Git** - Fetch config.yaml and commands.js from git repository
24
+ - **Project Self-managed Pipeline** - Deployment scripts in project repos with version control
25
+ - **JavaScript Scripts** - Write pipelines in code, flexible and powerful
26
+ - **Folder Nesting** - Support project grouping with arbitrary nesting
27
+ - **Environment Separation** - Multi-environment configuration support
28
+ - **Branch Merge Flow** - Define merge strategies between environments
29
+ - **Simple Actions** - git, shell, log three core operations
30
+ - **Command List** - Define available deployment commands in config
31
+
32
+ ## Installation
33
+
34
+ ```bash
35
+ npm install -g @ticatec/omniflow
36
+ ```
37
+
38
+ Or for local development:
39
+
40
+ ```bash
41
+ npm install
42
+ npm run build
43
+ npm link
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ ### 1. Set Environment Variables
49
+
50
+ **Required environment variable**:
51
+
52
+ ```bash
53
+ # Configuration repository address (required)
54
+ export OMNIFLOW_CONFIG_REPO=https://git.example.com/omniflow/config.git
55
+ ```
56
+
57
+ **Optional environment variables**:
58
+
59
+ ```bash
60
+ # Omniflow working directory (default: ~/.omniflow)
61
+ export OMNIFLOW_HOME=/opt/omniflow
62
+
63
+ # Configuration repository branch (default: main)
64
+ export OMNIFLOW_CONFIG_BRANCH=main
65
+
66
+ # Git authentication (if repository requires auth)
67
+ export GIT_USERNAME=your-username
68
+ export GIT_PASSWORD=your-token
69
+
70
+ # Git authentication token
71
+ export GIT_TOKEN=your-token
72
+ ```
73
+
74
+ **Add to config file**:
75
+
76
+ ```bash
77
+ # Method 1: Add to ~/.zshrc or ~/.bashrc
78
+ cat >> ~/.zshrc << 'EOF'
79
+ # Omniflow configuration
80
+ export OMNIFLOW_CONFIG_REPO=https://git.example.com/omniflow/config.git
81
+ export GIT_USERNAME=your-username
82
+ export GIT_TOKEN=your-token
83
+ EOF
84
+
85
+ # Method 2: Use .env file
86
+ mkdir -p ~/.omniflow
87
+ cat > ~/.omniflow/.env << EOF
88
+ OMNIFLOW_CONFIG_REPO=https://git.example.com/omniflow/config.git
89
+ GIT_USERNAME=your-username
90
+ GIT_TOKEN=your-token
91
+ EOF
92
+ ```
93
+
94
+ The configuration repository should contain a `config.yaml` file.
95
+
96
+ ### 2. Workspace Directory Structure
97
+
98
+ Omniflow uses `OMNIFLOW_HOME` as the working directory (defaults to `~/.omniflow`):
99
+
100
+ ```
101
+ ~/.omniflow/
102
+ ├── config/
103
+ │ ├── config.yaml # Unified scheduling config (from git)
104
+ │ └── commands.js # Shared commands library (from git, optional)
105
+ └── data/ # Projects root
106
+ └── <project-key>/ # Project path matches config.yaml structure
107
+ └── <cloned-repo>/ # Cloned from project git repository
108
+ ```
109
+
110
+
111
+ Example:
112
+ ```
113
+ ~/.omniflow/
114
+ ├── config/
115
+ │ ├── config.yaml # Fetched from OMNIFLOW_CONFIG_REPO
116
+ │ └── commands.js # Fetched from OMNIFLOW_CONFIG_REPO
117
+ └── data/
118
+ ├── my-app/platform/ # Platform project
119
+ └── my-app/micro-services/ # Micro-services group
120
+ └── user/
121
+ └── auth/ # Auth service project
122
+ ```
123
+
124
+ **Project path mapping rules:**
125
+ - The `projects` structure in config.yaml directly maps to the `data/` directory
126
+ - `folder` type items create directories
127
+ - `project` type items clone code from their git repository to the corresponding path
128
+
129
+ ### 3. Create Configuration Repository
130
+
131
+ The configuration repository should contain:
132
+
133
+ ```
134
+ config.git/
135
+ ├── config.yaml # Required: Unified scheduling config
136
+ └── commands.js # Optional: Shared commands library
137
+ ```
138
+
139
+ ### 4. Edit Configuration File
140
+
141
+ Edit `config.yaml` in the configuration repository to add projects:
142
+
143
+ ```yaml
144
+ omniflow:
145
+ # Global environment variables - passed to all projects
146
+ env:
147
+ REGISTRY: docker.aliyun.com
148
+ NAMESPACE: company
149
+ DEPLOY_USER: deploy
150
+
151
+ # Global Git configuration
152
+ git:
153
+ repos: https://git.example.com
154
+ username: ${GIT_USERNAME}
155
+ password: ${GIT_PASSWORD}
156
+
157
+ # SSH server configuration (for deployment)
158
+ ssh:
159
+ test:
160
+ server: test.example.com
161
+ user: deploy
162
+ private_key_file: ~/.ssh/id_rsa
163
+ port: 22
164
+ prod:
165
+ server: prod.example.com
166
+ user: deploy
167
+ private_key_file: ~/.ssh/id_rsa
168
+ port: 22
169
+
170
+ # Project directory organization - supports nested folders
171
+ projects:
172
+ # Group: Application Platform
173
+ - name: my-app
174
+ description: My Application Platform
175
+ type: folder
176
+ vars: # Group variables, inherited by child projects
177
+ DEPLOY_REGION: us-east-1
178
+ items:
179
+ # Project: Platform Service
180
+ - name: platform
181
+ description: Platform Service
182
+ repos: # Required for projects
183
+ git: ${GIT_REPOS}/my-app/platform.git
184
+ # merge_strategy: github # Optional (uses GIT_MERGE_STRATEGY env var if not set)
185
+ vars: # Project variables (override group)
186
+ APP_NAME: platform
187
+ IMAGE_PREFIX: company/platform
188
+ DEPLOY_HOST: platform.example.com
189
+ environments: # Required for projects
190
+ - name: test
191
+ description: Test Environment
192
+ branch: main-test
193
+ merge_from: dev-main
194
+ vars: # Environment variables (override project)
195
+ DEPLOY_HOST: test.platform.example.com
196
+ commands:
197
+ - name: frontend-deploy
198
+ description: Deploy frontend application
199
+ - name: backend-build
200
+ description: Build docker image
201
+ - name: prod
202
+ description: Production Environment
203
+ branch: main
204
+ merge_from: main-test
205
+ commands:
206
+ - name: frontend-deploy
207
+ - name: backend-build
208
+
209
+ # Project: User Service
210
+ - name: user-service
211
+ description: User Service
212
+ vars:
213
+ REPLICAS: "3"
214
+ repos:
215
+ git: ${GIT_REPOS}/my-app/user-service.git
216
+ environments:
217
+ - name: test
218
+ branch: main-test
219
+ - name: prod
220
+ branch: main
221
+ ```
222
+
223
+ ### 3. Create Deployment Script
224
+
225
+ Create `omniflow/deploy.js` in the project repository:
226
+
227
+ ```javascript
228
+ export default async function pipeline(ctx) {
229
+ const { git, shell, log } = ctx.actions
230
+ const { env, project, environment } = ctx
231
+
232
+ await log.info(`Deploying ${project.name} to ${environment.name}`)
233
+
234
+ await shell.script({
235
+ script: `
236
+ cd ${ctx.env.WORKSPACE}
237
+ npm install
238
+ npm run build
239
+ # ... deployment steps
240
+ `
241
+ })
242
+
243
+ await log.success('Deployment complete!')
244
+ }
245
+ ```
246
+
247
+ ### 4. Execute Deployment
248
+
249
+ ```bash
250
+ # Deploy platform service to test environment
251
+ omniflow run -e test my-app/platform frontend-deploy
252
+
253
+ # Run multiple commands in one environment
254
+ omniflow run -e test my-app/platform frontend-deploy backend-build
255
+
256
+ # Deploy micro-service to production
257
+ omniflow run -e prod my-app/micro-services deploy
258
+ ```
259
+
260
+ ## CLI Commands
261
+
262
+ ```bash
263
+ # Run deployment (using cached config)
264
+ omniflow run -e <environment> <project-path> <command> [command...]
265
+ # project-path supports nested paths, e.g.: my-app/platform
266
+ # Multiple commands can be specified, executed sequentially
267
+
268
+ # List all projects
269
+ omniflow list projects
270
+
271
+ # List project environments
272
+ omniflow list environments <project-path>
273
+
274
+ # List available commands for environment
275
+ omniflow list commands <project-path> <environment>
276
+
277
+ # Show project details
278
+ omniflow show <project-path> [environment]
279
+
280
+ # Clean workspace
281
+ omniflow clean [project-path]
282
+
283
+ # Reload configuration (fetch latest config from git and update config/)
284
+ omniflow reload
285
+ ```
286
+
287
+ ## Script Context
288
+
289
+ Objects available in deployment scripts:
290
+
291
+ ```javascript
292
+ export default async function pipeline(ctx) {
293
+ // Actions
294
+ ctx.actions.git.clone({ url, branch, path })
295
+ ctx.actions.shell.script({ script: '...' })
296
+ ctx.actions.log.info('message')
297
+
298
+ // Variables
299
+ ctx.env // Merged environment variables
300
+ ctx.globals // Vars defined in project config
301
+ ctx.system // System variables (VERSION, WORKSPACE, etc.)
302
+
303
+ // Project info
304
+ ctx.project.key // 'my-app/platform'
305
+ ctx.project.name // 'Platform Service'
306
+ ctx.environment.name // 'test'
307
+ ctx.environment.description // 'Test Environment'
308
+ ctx.git.branch // 'main-test'
309
+ ctx.git.mergeFrom // 'dev-main'
310
+ ctx.git.commit // commit hash
311
+ ctx.command.name // 'frontend-deploy' (if command specified)
312
+ }
313
+ ```
314
+
315
+ ## Variable Priority
316
+
317
+ Variable merge order (latter overrides former):
318
+
319
+ ```
320
+ omniflow.env (global)
321
+
322
+ folder.vars (optional)
323
+
324
+ project.vars (optional)
325
+
326
+ environments[].vars (environment)
327
+ ```
328
+
329
+ Example: `omniflow run app-platform/user-service test`
330
+
331
+ ```yaml
332
+ omniflow:
333
+ env:
334
+ REGISTRY: docker.example.com # Global
335
+ NAMESPACE: company
336
+
337
+ projects:
338
+ - name: app-platform
339
+ type: folder
340
+ vars:
341
+ NAMESPACE: company/app # Override global
342
+ DEPLOY_REGION: us-east-1
343
+ items:
344
+ - name: user-service
345
+ vars:
346
+ DEPLOY_REGION: us-west-2 # Override folder
347
+ REPLICAS: "3"
348
+ environments:
349
+ - name: test
350
+ vars:
351
+ REPLICAS: "1" # Override project
352
+ ```
353
+
354
+ ## Project Structure
355
+
356
+ ```
357
+ Configuration Repository (specified by OMNIFLOW_CONFIG_REPO):
358
+ └── config.yaml # Unified scheduling entry
359
+
360
+ Project Repository:
361
+ my-app.git/
362
+ ├── omniflow/
363
+ │ └── deploy.js # Deployment script
364
+ ├── src/
365
+ └── package.json
366
+
367
+ Configuration structure example:
368
+ projects:
369
+ - name: omni-gate # Folder
370
+ items:
371
+ - name: platform # Project
372
+ environments: [...]
373
+ - name: micro-services # Nested folder
374
+ type: folder
375
+ items:
376
+ - name: test # Environment
377
+ - name: prod # Environment
378
+ ```
379
+
380
+ ## Configuration Reference
381
+
382
+ ### Project Types
383
+
384
+ **folder (group)** - For organizing projects, variables are inherited by children:
385
+ ```yaml
386
+ - name: app-platform
387
+ type: folder
388
+ vars: # Optional, inherited by children
389
+ NAMESPACE: company/app
390
+ items: # Required, child items
391
+ - name: user-service
392
+ ```
393
+
394
+ **project (project)** - Actual project with repository and environments:
395
+ ```yaml
396
+ - name: user-service
397
+ type: project # Optional, defaults to project
398
+ vars: # Optional, project variables
399
+ REPLICAS: "3"
400
+ repos: # Required
401
+ git: https://...
402
+ merge_strategy: github # MR/PR strategy: github, gitlab, forgejo (optional)
403
+ environments: # Required
404
+ - name: test
405
+ ```
406
+
407
+ **Note:** `merge_strategy` can also be set globally via the `GIT_MERGE_STRATEGY` environment variable. If not specified in the project config, the env var value is used.
408
+
409
+ ### Environment Configuration
410
+
411
+ ```yaml
412
+ environments:
413
+ - name: test # Environment name
414
+ description: Test Environment
415
+ branch: main-test # Target branch
416
+ merge_from: dev-main # Source branch for merge (optional)
417
+ vars: # Environment variables (optional)
418
+ API_URL: https://test.api.com
419
+ commands: # Available command list (optional)
420
+ - name: deploy
421
+ description: Deploy application
422
+ - name: rollback
423
+ description: Rollback version
424
+ ```
425
+
426
+ ### Global Configuration
427
+
428
+ ```yaml
429
+ omniflow:
430
+ env: # Global environment variables
431
+ REGISTRY: docker.aliyun.com
432
+ git: # Git configuration
433
+ repos: https://git.example.com
434
+ username: ${GIT_USERNAME}
435
+ ssh: # SSH server configuration
436
+ test:
437
+ server: test.example.com
438
+ user: deploy
439
+ private_key_file: ~/.ssh/id_rsa
440
+ ```
441
+
442
+ ## Workspace Structure
443
+
444
+ ```
445
+ ~/.omniflow/
446
+ ├── config/
447
+ │ ├── config.yaml # From OMNIFLOW_CONFIG_REPO
448
+ │ └── commands.js # From OMNIFLOW_CONFIG_REPO (optional)
449
+ └── data/
450
+ └── <project-key>/ # Path matches config.yaml projects structure
451
+ └── <cloned-repo>/
452
+ ```
453
+
454
+ Example:
455
+ ```
456
+ ~/.omniflow/
457
+ ├── config/
458
+ │ ├── config.yaml
459
+ │ └── commands.js
460
+ └── data/
461
+ ├── my-app/platform/ # Cloned from my-app/platform.git
462
+ ├── my-app/micro-services/
463
+ │ └── user/
464
+ │ └── auth/ # Cloned from my-app/user/auth.git
465
+ └── supply-nexus/platform/ # Cloned from supply-nexus/platform.git
466
+ ```
467
+
468
+ ## More Documentation
469
+
470
+ - [Architecture Design](docs/architecture.md)
471
+ - [Configuration Example](examples/config.yaml)
472
+ - [Deployment Script Examples](examples/scripts/deploy.js)
473
+
474
+ ## License
475
+
476
+ MIT
@@ -0,0 +1,7 @@
1
+ interface RunOptions {
2
+ dryRun: boolean;
3
+ verbose: boolean;
4
+ }
5
+ export declare function runCommand(projectKey: string, envName: string, commands: string[], options: RunOptions): Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/run.ts"],"names":[],"mappings":"AAQA,UAAU,UAAU;IAClB,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;CACjB;AAKD,wBAAsB,UAAU,CAC9B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAoQf"}