graphwork-tools
v2.0.1
Published
Development tools for GraphWork Framework 2.0
Maintainers
Readme
Tools
Development tools for GraphWork Framework 2.0
Overview
The Tools module provides a collection of utilities and development tools that enhance the GraphWork Framework experience. These tools help with project setup, code generation, validation, and other development tasks.
Installation
npm install graphwork-toolsFeatures
- Project Setup Utilities: Tools for initializing and configuring GraphWork projects
- Code Generation Helpers: Utilities for generating boilerplate code
- Validation Tools: Tools for validating project structure and code quality
- File System Operations: Enhanced file system operations for development workflows
- Logging Utilities: Structured logging for development tools
- Configuration Management: Tools for managing project configuration
Usage
Project Setup
import { ProjectSetup } from 'graphwork-tools';
// Initialize a new project
const setup = new ProjectSetup('./my-project');
await setup.initialize({
template: 'fullstack',
technologies: ['react', 'nodejs', 'postgresql'],
domain: 'ecommerce'
});File Operations
import { FileUtils } from 'graphwork-tools';
// Create directory structure
await FileUtils.createDirectoryStructure('./my-project', {
src: {
controllers: {},
services: {},
models: {}
},
tests: {},
docs: {}
});
// Copy template files
await FileUtils.copyTemplateFiles('./templates', './my-project/src');Validation
import { Validator } from 'graphwork-tools';
const validator = new Validator();
// Validate project structure
const structureIssues = await validator.validateProjectStructure('./my-project');
// Validate code quality
const qualityIssues = await validator.validateCodeQuality('./my-project/src');Logging
import { Logger } from 'graphwork-tools';
const logger = new Logger('MyTool');
logger.info('Starting tool execution');
logger.warn('This is a warning message');
logger.error('An error occurred', new Error('Something went wrong'));API
ProjectSetup
Constructor
new ProjectSetup(projectPath: string)Methods
initialize(config: ProjectConfig): Promise<void>- Initialize a new projectsetupDirectories(): Promise<void>- Set up directory structurecopyTemplates(): Promise<void>- Copy template filesinstallDependencies(): Promise<void>- Install project dependencies
FileUtils
Static Methods
createDirectoryStructure(basePath: string, structure: DirectoryStructure): Promise<void>- Create directory structurecopyTemplateFiles(source: string, destination: string): Promise<void>- Copy template filesreadContextFile(filePath: string): Promise<any>- Read and parse context filewriteContextFile(filePath: string, data: any): Promise<void>- Write context file
Validator
Constructor
new Validator()Methods
validateProjectStructure(path: string): Promise<ValidationIssue[]>- Validate project structurevalidateCodeQuality(path: string): Promise<ValidationIssue[]>- Validate code qualityvalidateDependencies(path: string): Promise<ValidationIssue[]>- Validate dependencies
Logger
Constructor
new Logger(component: string)Methods
info(message: string, ...args: any[])- Log info messagewarn(message: string, ...args: any[])- Log warning messageerror(message: string, error?: Error, ...args: any[])- Log error messagedebug(message: string, ...args: any[])- Log debug message
ValidationIssue
interface ValidationIssue {
type: 'error' | 'warning' | 'info';
message: string;
file?: string;
line?: number;
column?: number;
suggestion?: string;
}Project Configuration
ProjectConfig
interface ProjectConfig {
template: string;
technologies: string[];
domain: string;
name?: string;
description?: string;
}DirectoryStructure
interface DirectoryStructure {
[key: string]: DirectoryStructure | {};
}Available Templates
Fullstack
A complete full-stack application template with:
- Frontend (React/Vue/Angular)
- Backend (Node.js/Python/Java)
- Database (PostgreSQL/MySQL/MongoDB)
Backend
Backend-only template with:
- API framework
- Database integration
- Authentication
Frontend
Frontend-only template with:
- Component library
- State management
- Routing
Microservice
Microservice template with:
- Lightweight framework
- API gateway integration
- Container configuration
Contributing
See our Contributing Guide for information on how to contribute to this package.
License
This package is licensed under the MIT License. See the LICENSE file for details.
