@burgan-tech/vnext-workflow-cli 1.0.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.
@@ -0,0 +1,69 @@
1
+ name: SonarQube Analysis
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - develop
8
+ - 'release-v*'
9
+ pull_request:
10
+ branches:
11
+ - main
12
+ - develop
13
+ - 'release-v*'
14
+
15
+ permissions:
16
+ contents: read
17
+ pull-requests: write
18
+
19
+ jobs:
20
+ sonar:
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ - name: Checkout repository
25
+ uses: actions/checkout@v4
26
+ with:
27
+ fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
28
+
29
+ - name: Set up Node.js
30
+ uses: actions/setup-node@v4
31
+ with:
32
+ node-version: '20.x'
33
+ cache: 'npm'
34
+
35
+ - name: Install dependencies
36
+ run: |
37
+ echo "Installing dependencies..."
38
+ if [ -f "package-lock.json" ]; then
39
+ npm ci
40
+ else
41
+ npm install
42
+ fi
43
+ echo "Dependencies installed successfully"
44
+
45
+ - name: Run tests with coverage
46
+ run: |
47
+ echo "Running tests..."
48
+ if npm run test:coverage --silent > /dev/null 2>&1; then
49
+ npm run test:coverage
50
+ elif npm run test --silent > /dev/null 2>&1; then
51
+ npm test
52
+ else
53
+ echo "No test script found, skipping tests..."
54
+ fi
55
+
56
+ - name: SonarQube Scan
57
+ uses: sonarsource/sonarqube-scan-action@master
58
+ env:
59
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
60
+ SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
61
+
62
+ - name: SonarQube Quality Gate check
63
+ uses: sonarsource/sonarqube-quality-gate-action@master
64
+ timeout-minutes: 5
65
+ env:
66
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
67
+ # Force to fail step after specific time
68
+ continue-on-error: false
69
+
package/README.md ADDED
@@ -0,0 +1,382 @@
1
+ # 🚀 vNext Workflow CLI
2
+
3
+ Cross-platform modern workflow management tool.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/@burgan-tech/vnext-workflow-cli.svg)](https://www.npmjs.com/package/@burgan-tech/vnext-workflow-cli)
6
+ [![npm downloads](https://img.shields.io/npm/dm/@burgan-tech/vnext-workflow-cli.svg)](https://www.npmjs.com/package/@burgan-tech/vnext-workflow-cli)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
+
9
+ A command-line interface (CLI) tool for managing vNext workflows, tasks, schemas, views, functions, and extensions. This tool helps you synchronize your local workflow definitions with the vNext API and database.
10
+
11
+ **Package**: `@burgan-tech/vnext-workflow-cli`
12
+ **NPM**: https://www.npmjs.com/package/@burgan-tech/vnext-workflow-cli
13
+ **GitHub**: https://github.com/burgan-tech/vnext-workflow-cli
14
+
15
+ ## 📦 Installation
16
+
17
+ ### Install from NPM (Recommended)
18
+
19
+ ```bash
20
+ # Install globally
21
+ npm install -g @burgan-tech/vnext-workflow-cli
22
+
23
+ # Or install as a project dependency
24
+ npm install @burgan-tech/vnext-workflow-cli
25
+ ```
26
+
27
+ After installation, you can use the CLI with:
28
+ ```bash
29
+ wf --version
30
+ wf check
31
+ ```
32
+
33
+ ### Install from Source
34
+
35
+ ```bash
36
+ # Clone the repository
37
+ git clone https://github.com/burgan-tech/vnext-workflow-cli.git
38
+ cd vnext-workflow-cli
39
+
40
+ # Install dependencies
41
+ npm install
42
+
43
+ # Link globally (for development)
44
+ npm link
45
+ ```
46
+
47
+ ### Requirements
48
+
49
+ - Node.js >= 14.0.0
50
+ - npm or yarn
51
+ - PostgreSQL (for database operations)
52
+ - Docker (optional, for PostgreSQL container)
53
+
54
+ ---
55
+
56
+ ## ⚡ Quick Start
57
+
58
+ ### Initial Configuration
59
+
60
+ After installation, configure the CLI:
61
+
62
+ ```bash
63
+ # Set project root path (REQUIRED)
64
+ wf config set PROJECT_ROOT /path/to/your/vnext-project
65
+
66
+ # Database settings
67
+ wf config set DB_PASSWORD postgres
68
+ wf config set USE_DOCKER true
69
+ wf config set DOCKER_POSTGRES_CONTAINER vnext-postgres
70
+
71
+ # Verify configuration
72
+ wf check
73
+ ```
74
+
75
+ ### Basic Usage
76
+
77
+ ```bash
78
+ # System status check
79
+ wf check
80
+
81
+ # Update CSX + JSON files (automatically finds changed files)
82
+ wf update
83
+
84
+ # Add missing workflows to database
85
+ wf sync
86
+
87
+ # Reset workflows (delete from DB and re-add)
88
+ wf reset
89
+ ```
90
+
91
+ ---
92
+
93
+ ## 📖 Commands
94
+
95
+ ### `wf check`
96
+ Checks system status (API, DB, folders).
97
+
98
+ ### `wf config <action> [key] [value]`
99
+ Configuration management:
100
+ ```bash
101
+ wf config get # Show all settings
102
+ wf config get PROJECT_ROOT # Show a specific setting
103
+ wf config set DB_PASSWORD pass # Change a setting
104
+ ```
105
+
106
+ ### `wf csx [options]`
107
+ Converts CSX files to Base64 and embeds them in JSON files.
108
+ ```bash
109
+ wf csx # Process changed files in Git
110
+ wf csx --all # Process all CSX files
111
+ wf csx --file x.csx # Process a single file
112
+ ```
113
+
114
+ ### `wf update [options]`
115
+ Updates workflows (CSX is automatically updated!).
116
+ ```bash
117
+ wf update # Process changed files in Git (CSX + JSON)
118
+ wf update --all # Update all (asks for confirmation)
119
+ wf update --file x.json # Process a single file
120
+ ```
121
+
122
+ **Process steps:**
123
+ 1. 📝 Converts changed CSX files to base64 and writes to JSON files
124
+ 2. 🗑️ Deletes existing record from DB
125
+ 3. 📤 POSTs to API
126
+ 4. ✅ Activates the workflow
127
+ 5. 🔄 Restarts the system
128
+
129
+ ### `wf sync`
130
+ Updates all CSX files and adds missing ones to the database.
131
+ ```bash
132
+ wf sync # Update all CSX files + add missing ones
133
+ ```
134
+
135
+ ### `wf reset`
136
+ Resets workflows with an interactive menu (even if there are no changes).
137
+ ```bash
138
+ wf reset # Select folder from menu
139
+ ```
140
+
141
+ **Menu:**
142
+ ```
143
+ ? Which folder should be reset?
144
+ ❯ 🔵 Workflows (sys-flows)
145
+ 📋 Tasks (sys-tasks)
146
+ 📊 Schemas (sys-schemas)
147
+ 👁️ Views (sys-views)
148
+ ⚙️ Functions (sys-functions)
149
+ 🔌 Extensions (sys-extensions)
150
+ ──────────────
151
+ 🔴 ALL (All folders)
152
+ ```
153
+
154
+ ---
155
+
156
+ ## 💡 Usage Scenarios
157
+
158
+ ### 1. Changing and Updating CSX File
159
+ ```bash
160
+ # Edit CSX file
161
+ vim AddToCartMapping.csx
162
+
163
+ # Update in one command (CSX + JSON automatic)
164
+ wf update
165
+ ```
166
+
167
+ ### 2. Updating Only CSX (Without Writing to DB)
168
+ ```bash
169
+ # Convert CSX files to base64 and write to JSON files
170
+ wf csx
171
+ ```
172
+
173
+ ### 3. Initial Setup / Full Sync
174
+ ```bash
175
+ # Update all CSX files + add missing ones
176
+ wf sync
177
+ ```
178
+
179
+ ### 4. Resetting Workflows (Delete from DB and Re-add)
180
+ ```bash
181
+ # With interactive menu (RECOMMENDED)
182
+ wf reset
183
+
184
+ # Reset all
185
+ wf update --all
186
+
187
+ # Single file
188
+ wf update --file /path/to/file.json
189
+ ```
190
+
191
+ ---
192
+
193
+ ## ⚙️ Configuration
194
+
195
+ Config file location: `~/.config/vnext-workflow-cli/config.json`
196
+
197
+ ### Important Settings
198
+ ```bash
199
+ # Project root path (REQUIRED)
200
+ wf config set PROJECT_ROOT /path/to/project
201
+
202
+ # API settings
203
+ wf config set API_BASE_URL http://localhost:4201
204
+ wf config set API_VERSION v1
205
+
206
+ # Database settings
207
+ wf config set DB_HOST localhost
208
+ wf config set DB_PORT 5432
209
+ wf config set DB_NAME vNext_WorkflowDb
210
+ wf config set DB_USER postgres
211
+ wf config set DB_PASSWORD your_password
212
+
213
+ # Docker settings
214
+ wf config set USE_DOCKER true
215
+ wf config set DOCKER_POSTGRES_CONTAINER vnext-postgres
216
+
217
+ # Auto discovery
218
+ wf config set AUTO_DISCOVER true
219
+ ```
220
+
221
+ ---
222
+
223
+ ## 🆘 Troubleshooting
224
+
225
+ ### "Files not found" (When using on another PC)
226
+ ```bash
227
+ # Check current config
228
+ wf config get PROJECT_ROOT
229
+
230
+ # Set new PC's path
231
+ wf config set PROJECT_ROOT /Users/NewUser/path/to/project
232
+
233
+ # Verify
234
+ wf check
235
+ ```
236
+
237
+ ### "Cannot connect to API"
238
+ ```bash
239
+ # Check API
240
+ curl http://localhost:4201/api/v1/health
241
+
242
+ # Check config
243
+ wf config get API_BASE_URL
244
+ ```
245
+
246
+ ### "Database connection failed"
247
+ ```bash
248
+ # Check Docker container
249
+ docker ps | grep postgres
250
+
251
+ # Start container
252
+ docker start vnext-postgres
253
+
254
+ # Check config
255
+ wf config get USE_DOCKER
256
+ wf config get DOCKER_POSTGRES_CONTAINER
257
+ ```
258
+
259
+ ### "npm link not working"
260
+ ```bash
261
+ # Use alias
262
+ echo 'alias wf="node $(pwd)/bin/workflow.js"' >> ~/.bashrc
263
+ source ~/.bashrc
264
+ ```
265
+
266
+ ---
267
+
268
+ ## 🚀 Creating a New Version
269
+
270
+ The project uses automated versioning and publishing via GitHub Actions. Follow these steps to create and publish a new version:
271
+
272
+ ### Method 1: Using Release Branches (Recommended)
273
+
274
+ 1. **Create a release branch** following the pattern `release-vX.Y`:
275
+ ```bash
276
+ git checkout -b release-v1.0
277
+ git push origin release-v1.0
278
+ ```
279
+
280
+ 2. **Push to the release branch** - The workflow will automatically:
281
+ - Calculate the next patch version (e.g., `1.0.0`, `1.0.1`, `1.0.2`)
282
+ - Build and validate the package
283
+ - Publish to NPM and/or GitHub Packages
284
+ - Create a Git tag (e.g., `v1.0.0`)
285
+ - Create a GitHub release
286
+
287
+ ### Method 2: Manual Workflow Dispatch
288
+
289
+ 1. **Go to GitHub Actions** in your repository
290
+ 2. **Select "Build and Publish to NPM"** workflow
291
+ 3. **Click "Run workflow"**
292
+ 4. **Configure options**:
293
+ - **Version Override**: Optional. Leave empty for auto-calculation (e.g., `1.0.6`)
294
+ - **Force Publish**: Set to `true` if you want to republish an existing version
295
+ - **Target Registry**: Choose `npmjs`, `github`, or `both`
296
+ 5. **Click "Run workflow"**
297
+
298
+ ### Version Calculation
299
+
300
+ The workflow automatically calculates versions:
301
+
302
+ - **From branch name**: If branch is `release-v1.0`, it will find the next available patch version (e.g., `1.0.0`, `1.0.1`, `1.0.2`)
303
+ - **From package.json**: If branch doesn't match the pattern, it increments the patch version from `package.json`
304
+
305
+ ### After Publishing
306
+
307
+ Once published, the new version will be:
308
+ - ✅ Available on NPM: `npm install -g @burgan-tech/vnext-workflow-cli@1.0.0`
309
+ - ✅ Tagged in Git: `v1.0.0`
310
+ - ✅ Released on GitHub with release notes
311
+
312
+ ### Workflow Requirements
313
+
314
+ The workflow requires these secrets to be configured in GitHub repository settings:
315
+
316
+ - **NPM_TOKEN** (optional): For publishing to NPM. If not set, only GitHub Packages will be used.
317
+ - **SONAR_TOKEN** (optional): For code quality analysis
318
+ - **SONAR_HOST_URL** (optional): SonarQube server URL
319
+
320
+ ### Workflow Steps
321
+
322
+ The build and publish workflow performs these steps:
323
+
324
+ 1. ✅ **Checkout code** with full Git history
325
+ 2. ✅ **Calculate version** from branch or package.json
326
+ 3. ✅ **Validate syntax** - Checks all JavaScript files
327
+ 4. ✅ **Run linting** (if available)
328
+ 5. ✅ **Run tests** (if available)
329
+ 6. ✅ **Build package** (if build script exists)
330
+ 7. ✅ **Publish to registry** (NPM and/or GitHub Packages)
331
+ 8. ✅ **Create Git tag** (e.g., `v1.0.0`)
332
+ 9. ✅ **Create GitHub release** with release notes
333
+
334
+ ---
335
+
336
+ ## 📋 Development
337
+
338
+ ### Project Structure
339
+
340
+ ```
341
+ vnext-workflow-cli/
342
+ ├── bin/
343
+ │ └── workflow.js # CLI entry point
344
+ ├── src/
345
+ │ ├── commands/ # Command implementations
346
+ │ │ ├── check.js
347
+ │ │ ├── config.js
348
+ │ │ ├── csx.js
349
+ │ │ ├── reset.js
350
+ │ │ ├── sync.js
351
+ │ │ └── update.js
352
+ │ └── lib/ # Library modules
353
+ │ ├── api.js
354
+ │ ├── config.js
355
+ │ ├── csx.js
356
+ │ ├── db.js
357
+ │ ├── discover.js
358
+ │ └── workflow.js
359
+ ├── .github/
360
+ │ └── workflows/ # GitHub Actions workflows
361
+ │ ├── build-and-publish.yml
362
+ │ └── check-sonar.yml
363
+ ├── package.json
364
+ └── README.md
365
+ ```
366
+
367
+ ### Local Development
368
+
369
+ ```bash
370
+ # Clone and install
371
+ git clone https://github.com/burgan-tech/vnext-workflow-cli.git
372
+ cd vnext-workflow-cli
373
+ npm install
374
+ npm link
375
+
376
+ # Test the CLI
377
+ wf --version
378
+ wf check
379
+
380
+ # Run development
381
+ npm run dev
382
+ ```
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { program } = require('commander');
4
+ const chalk = require('chalk');
5
+ const pkg = require('../package.json');
6
+
7
+ // Commands
8
+ const checkCommand = require('../src/commands/check');
9
+ const csxCommand = require('../src/commands/csx');
10
+ const updateCommand = require('../src/commands/update');
11
+ const syncCommand = require('../src/commands/sync');
12
+ const resetCommand = require('../src/commands/reset');
13
+ const configCommand = require('../src/commands/config');
14
+
15
+ program
16
+ .name('workflow')
17
+ .description('vNext Workflow Manager CLI')
18
+ .version(pkg.version);
19
+
20
+ // Check command
21
+ program
22
+ .command('check')
23
+ .description('Sistem kontrolü (API, DB, klasörler)')
24
+ .action(checkCommand);
25
+
26
+ // CSX command
27
+ program
28
+ .command('csx')
29
+ .description('CSX dosyalarını güncelle')
30
+ .option('-a, --all', 'Tüm CSX dosyalarını güncelle')
31
+ .option('-f, --file <path>', 'Belirli bir CSX dosyasını güncelle')
32
+ .action(csxCommand);
33
+
34
+ // Update command
35
+ program
36
+ .command('update')
37
+ .description('Workflow\'ları güncelle')
38
+ .option('-a, --all', 'Tüm workflow\'ları güncelle')
39
+ .option('-f, --file <path>', 'Belirli bir workflow\'u güncelle')
40
+ .action(updateCommand);
41
+
42
+ // Sync command
43
+ program
44
+ .command('sync')
45
+ .description('DB\'de eksik olanları ekle')
46
+ .action(syncCommand);
47
+
48
+ // Reset command
49
+ program
50
+ .command('reset')
51
+ .description('Workflow\'ları resetle (force update)')
52
+ .action(resetCommand);
53
+
54
+ // Config command
55
+ program
56
+ .command('config')
57
+ .description('Konfigürasyon yönetimi')
58
+ .argument('<action>', 'set veya get')
59
+ .argument('[key]', 'Config key')
60
+ .argument('[value]', 'Config value')
61
+ .action(configCommand);
62
+
63
+ // Parse arguments
64
+ program.parse(process.argv);
65
+
66
+ // No command provided
67
+ if (!process.argv.slice(2).length) {
68
+ program.outputHelp();
69
+ }
70
+
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@burgan-tech/vnext-workflow-cli",
3
+ "version": "1.0.0",
4
+ "description": "vNext Workflow Manager - CLI tool for managing workflows, tasks, schemas and more",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "workflow": "./bin/workflow.js",
8
+ "wf": "./bin/workflow.js"
9
+ },
10
+ "scripts": {
11
+ "dev": "node bin/workflow.js",
12
+ "build": "echo 'Build not needed for now'",
13
+ "start": "node bin/workflow.js"
14
+ },
15
+ "keywords": [
16
+ "workflow",
17
+ "vnext",
18
+ "cli",
19
+ "automation"
20
+ ],
21
+ "author": "Burgan Tech",
22
+ "license": "MIT",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/burgan-tech/vnext-workflow-cli.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/burgan-tech/vnext-workflow-cli/issues"
29
+ },
30
+ "homepage": "https://github.com/burgan-tech/vnext-workflow-cli#readme",
31
+ "engines": {
32
+ "node": ">=14.0.0"
33
+ },
34
+ "dependencies": {
35
+ "commander": "^11.1.0",
36
+ "chalk": "^4.1.2",
37
+ "axios": "^1.6.2",
38
+ "pg": "^8.11.3",
39
+ "glob": "^10.3.10",
40
+ "inquirer": "^8.2.6",
41
+ "ora": "^5.4.1",
42
+ "conf": "^10.2.0"
43
+ }
44
+ }
@@ -0,0 +1,74 @@
1
+ const chalk = require('chalk');
2
+ const ora = require('ora');
3
+ const config = require('../lib/config');
4
+ const { discoverComponents, listDiscovered } = require('../lib/discover');
5
+ const { testApiConnection } = require('../lib/api');
6
+ const { testDbConnection } = require('../lib/db');
7
+
8
+ async function checkCommand() {
9
+ console.log(chalk.cyan.bold('\n🔄 Workflow Yönetim Sistemi - Sistem Kontrolü\n'));
10
+
11
+ const projectRoot = config.get('PROJECT_ROOT');
12
+ const autoDiscover = config.get('AUTO_DISCOVER');
13
+
14
+ // API kontrolü
15
+ let apiSpinner = ora('API kontrolü...').start();
16
+ try {
17
+ const apiUrl = config.get('API_BASE_URL');
18
+ const isApiOk = await testApiConnection(apiUrl);
19
+ if (isApiOk) {
20
+ apiSpinner.succeed(chalk.green('API: ✓ Erişilebilir'));
21
+ } else {
22
+ apiSpinner.fail(chalk.red('API: ✗ Erişilemiyor'));
23
+ }
24
+ } catch (error) {
25
+ apiSpinner.fail(chalk.red(`API: ✗ Hata - ${error.message}`));
26
+ }
27
+
28
+ // DB kontrolü
29
+ let dbSpinner = ora('Veritabanı kontrolü...').start();
30
+ try {
31
+ const isDbOk = await testDbConnection({
32
+ host: config.get('DB_HOST'),
33
+ port: config.get('DB_PORT'),
34
+ database: config.get('DB_NAME'),
35
+ user: config.get('DB_USER'),
36
+ password: config.get('DB_PASSWORD'),
37
+ useDocker: config.get('USE_DOCKER'),
38
+ dockerContainer: config.get('DOCKER_POSTGRES_CONTAINER')
39
+ });
40
+ if (isDbOk) {
41
+ dbSpinner.succeed(chalk.green('DB: ✓ Bağlı'));
42
+ } else {
43
+ dbSpinner.fail(chalk.red('DB: ✗ Bağlanamıyor'));
44
+ }
45
+ } catch (error) {
46
+ dbSpinner.fail(chalk.red(`DB: ✗ Hata - ${error.message}`));
47
+ }
48
+
49
+ // Klasör tarama
50
+ if (autoDiscover) {
51
+ console.log(chalk.cyan('\n📁 Bulunan Klasörler:\n'));
52
+ let discoverSpinner = ora('Klasörler taranıyor...').start();
53
+ try {
54
+ const discovered = await discoverComponents(projectRoot);
55
+ discoverSpinner.stop();
56
+
57
+ const list = listDiscovered(discovered);
58
+ for (const item of list) {
59
+ if (item.found) {
60
+ console.log(chalk.green(` ✓ ${item.name}`));
61
+ } else {
62
+ console.log(chalk.yellow(` ○ ${item.name} ${chalk.dim('(bulunamadı)')}`));
63
+ }
64
+ }
65
+ } catch (error) {
66
+ discoverSpinner.fail(chalk.red(`Klasör tarama hatası: ${error.message}`));
67
+ }
68
+ }
69
+
70
+ console.log(chalk.green.bold('\n✓ Kontrol tamamlandı\n'));
71
+ }
72
+
73
+ module.exports = checkCommand;
74
+
@@ -0,0 +1,31 @@
1
+ const chalk = require('chalk');
2
+ const config = require('../lib/config');
3
+
4
+ async function configCommand(action, key, value) {
5
+ if (action === 'get') {
6
+ if (key) {
7
+ const val = config.get(key);
8
+ console.log(chalk.cyan(`${key}:`), val);
9
+ } else {
10
+ // Tüm config'i göster
11
+ console.log(chalk.cyan.bold('\n📝 Mevcut Konfigürasyon:\n'));
12
+ const all = config.getAll();
13
+ for (const [k, v] of Object.entries(all)) {
14
+ console.log(chalk.cyan(`${k}:`), chalk.white(v));
15
+ }
16
+ console.log(chalk.dim(`\nKonfig dosyası: ${config.path}\n`));
17
+ }
18
+ } else if (action === 'set') {
19
+ if (!key || value === undefined) {
20
+ console.log(chalk.red('Kullanım: workflow config set <key> <value>'));
21
+ return;
22
+ }
23
+ config.set(key, value);
24
+ console.log(chalk.green(`✓ ${key} = ${value}`));
25
+ } else {
26
+ console.log(chalk.red('Geçersiz action. Kullanın: get veya set'));
27
+ }
28
+ }
29
+
30
+ module.exports = configCommand;
31
+