Skip to content

vNext workflow engine automatically syncs changes in CSX files to JSON files with base64 format in projects.

License

Notifications You must be signed in to change notification settings

burgan-tech/csx-json-sync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CSX-JSON Sync Extension

A VSCode extension that automatically synchronizes changes in CSX files to JSON files in base64 format for VNext Workflow Engine projects.

✨ Features

  • βœ… Dynamic Project Structure: Automatically reads project structure from vnext.config.json
  • βœ… Multi-Component Support: Tasks, Views, Functions, Extensions, Workflows, Schemas
  • βœ… Recursive CSX Scanning: Supports CSX files in all subdirectories under /src
  • βœ… Automatic Synchronization: Automatically updates related JSON files when CSX files change
  • βœ… Base64 Conversion: Automatically converts CSX file content to base64
  • βœ… Smart Mapping: Automatically finds which CSX files are used in which JSON files
  • βœ… Debounce Support: Prevents unnecessary updates during rapid changes
  • βœ… Manual Sync: Manual synchronization available when needed
  • βœ… Base64 Code Preview: Hover over base64 encoded code in JSON files to see decoded C# code with syntax highlighting

πŸ“‹ Requirements

  • βœ… Required: vnext.config.json file must exist in project root
  • βœ… Structure: Component directories must have /src subdirectories
  • βœ… Format: VNext standard project structure

vnext.config.json Example

{
  "domain": "core",
  "paths": {
    "componentsRoot": "core",
    "tasks": "Tasks",
    "views": "Views", 
    "functions": "Functions",
    "extensions": "Extensions",
    "workflows": "Workflows",
    "schemas": "Schemas"
  }
}

πŸ—οΈ Supported Project Structure

project-root/
β”œβ”€β”€ vnext.config.json          ← Required configuration file
└── core/                      ← componentsRoot
    β”œβ”€β”€ Tasks/
    β”‚   β”œβ”€β”€ task1.json
    β”‚   └── src/
    β”‚       β”œβ”€β”€ main.csx                    βœ… Supported
    β”‚       β”œβ”€β”€ helpers/
    β”‚       β”‚   └── validation.csx          βœ… Supported
    β”‚       └── utils/
    β”‚           └── advanced/
    β”‚               └── complex.csx         βœ… Supported
    β”œβ”€β”€ Functions/
    β”‚   β”œβ”€β”€ function1.json
    β”‚   └── src/
    β”‚       β”œβ”€β”€ auth/
    β”‚       β”‚   β”œβ”€β”€ login.csx               βœ… Supported
    β”‚       β”‚   └── logout.csx              βœ… Supported
    β”‚       └── data/
    β”‚           └── processing.csx          βœ… Supported
    β”œβ”€β”€ Workflows/
    β”‚   β”œβ”€β”€ global-workflow.json
    β”‚   └── payments/                       ← Sub-directories supported
    β”‚       β”œβ”€β”€ scheduled-payments-workflow.json  βœ… Supported
    β”‚       └── src/
    β”‚           └── MainWorkflowDeactivatedRule.csx  βœ… Supported
    β”œβ”€β”€ Views/
    β”œβ”€β”€ Extensions/
    └── Schemas/

πŸ“¦ Installation

VSIX Package (Recommended)

  1. Download csx-json-sync.vsix file
  2. In VS Code: Ctrl+Shift+P β†’ "Extensions: Install from VSIX..."
  3. Select the VSIX file and install

Manual Installation

  1. Copy extension files to .vscode-extensions/csx-json-sync/ directory
  2. Navigate to extension directory in terminal:
    cd .vscode-extensions/csx-json-sync
  3. Install dependencies:
    npm install
  4. Compile the extension:
    npm run compile
  5. Press F5 in VSCode to run extension in debug mode

πŸš€ Usage

Automatic Synchronization

When the extension is active, changes made to CSX files in /src subdirectories of all component directories in the project structure are automatically synchronized to JSON files in the same component directory.

Manual Synchronization

  • Sync current file: Ctrl+Shift+P β†’ "Sync Current CSX File to JSON"
  • Sync all CSX files: Ctrl+Shift+P β†’ "Sync All CSX Files to JSON"
  • Right-click menu: Right-click on CSX file and select "Sync Current CSX File to JSON"

Auto-Sync Control

  • Enable Auto Sync: Ctrl+Shift+P β†’ "Enable Auto Sync"
  • Disable Auto Sync: Ctrl+Shift+P β†’ "Disable Auto Sync"

Base64 Code Preview

  • Hover Preview: Hover over base64 encoded values in "code" fields in JSON files
  • Syntax Highlighting: Decoded C# code is displayed with proper syntax highlighting
  • Quick Access: No need to manually decode base64 strings to read the code
  • File Support: Works with all JSON files containing base64 encoded CSX code

βš™οΈ Configuration

You can configure the following settings in VSCode Settings:

{
  "csxJsonSync.enabled": true,        // Enable/disable auto-sync
  "csxJsonSync.debounceMs": 500       // Change detection delay (ms)
}

πŸ”§ How It Works

  1. Config Reading: Extension reads vnext.config.json file
  2. Structure Discovery: Discovers project structure and finds component directories
  3. File Watcher: Monitors all /src/**/*.csx files
  4. Change Detection: When a CSX file change is detected, debounce timer starts
  5. Base64 Conversion: CSX file content is converted to base64 format
  6. JSON Search: Searches for references to this CSX file in JSON files in the same component directory
  7. Update: Updates code fields in JSON files where references are found
  8. Hover Provider: Provides instant preview of decoded C# code when hovering over base64 strings in JSON files

JSON Mapping Format

The extension works with the following format:

{
  "location": "./src/auth/helpers/validation.csx",
  "code": "dXNpbmcgU3lzdGVtLlRocmVhZGluZy5UYXNrczsK..."
}

Base64 Hover Feature

When you hover over the base64 string in the "code" field, the extension will:

  • Detect that your cursor is over a base64 encoded value
  • Automatically decode the base64 string to readable C# code
  • Display the decoded code in a popup with syntax highlighting
  • Show additional information like the base64 string length

Example:

{
  "location": "./src/auth/login.csx",
  "code": "dXNpbmcgU3lzdGVtOwo="  ← Hover here to see: using System;
}

πŸ“Š Debug and Logging

To monitor the extension's operation:

  1. Go to View β†’ Output and select "CSX-JSON Sync" channel
  2. All synchronization operations and errors are displayed here

Log Examples

CSX-JSON Sync extension activated
VNext config loaded: domain=core, componentsRoot=core
Found 6 existing component directories:
  - core/Tasks
  - core/Views
  - core/Functions
  - core/Extensions
  - core/Workflows
  - core/Schemas
Auto-sync enabled for 6 component directories
File changed: core/Functions/src/auth/login.csx
Updated code for ./src/auth/login.csx in workflow.json
Auto-sync: Successfully updated 1 JSON file(s) for login.csx

πŸ” Troubleshooting

Extension not working

  • Ensure the extension is active (check Output channel)
  • Ensure vnext.config.json file exists in project root
  • Verify the configuration file is in valid JSON format

vnext.config.json not found

ERROR: vnext.config.json not found or invalid. This extension requires vnext.config.json to work properly.
  • Create vnext.config.json file in project root
  • Ensure the file is in valid JSON format

Synchronization not working

  • Ensure CSX file is in /src directory under a component directory
  • Ensure JSON files contain correct location references
  • Verify auto-sync is enabled
  • Check that the component directory is defined in vnext.config.json

Base64 encoding errors

  • Ensure CSX file is saved with UTF-8 encoding
  • Check file permissions

πŸ› οΈ Development

For detailed development instructions, see CONTRIBUTING.md.

Quick start:

# Install dependencies
npm install

# Compile TypeScript
npm run compile

# Watch mode (automatic compilation)
npm run watch

# Run in debug mode
F5 (in VSCode)

# Create VSIX package
npx vsce package

VSIX Package Installation

# Create package
npx vsce package

# Install package
code --install-extension csx-json-sync-1.1.0.vsix

πŸ§ͺ Testing

Run the test script to verify your project structure:

node test-extension.js

The test script will:

  • βœ… Check for vnext.config.json
  • βœ… Verify project structure
  • βœ… Find CSX and JSON files
  • βœ… Test CSX-JSON mappings
  • βœ… Verify base64 conversion
  • βœ… Check extension files

πŸ“ Release Notes

v1.1.0 (Latest)

  • βœ… NEW: Base64 Code Preview on Hover
  • βœ… NEW: Syntax highlighting for decoded C# code in hover popup
  • βœ… NEW: Base64 string validation and length display
  • βœ… Enhanced user experience for viewing encoded CSX code in JSON files

v1.0.0

  • βœ… Dynamic project structure support (vnext.config.json)
  • βœ… Multi-component type support
  • βœ… Recursive CSX file scanning
  • βœ… Enhanced file watching
  • βœ… Smart relative path calculation
  • βœ… Automatic project structure discovery

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for detailed guidelines on:

  • πŸš€ Development setup
  • πŸ“ Project structure
  • πŸ”§ Development workflow
  • πŸ§ͺ Testing procedures
  • πŸ“¦ Building and packaging
  • πŸ“ Submitting changes

πŸ“„ License

This project is licensed under the MIT License.

About

vNext workflow engine automatically syncs changes in CSX files to JSON files with base64 format in projects.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published