diff --git a/.cargo/.global-cache b/.cargo/.global-cache index 3442a9f..b25d39e 100644 Binary files a/.cargo/.global-cache and b/.cargo/.global-cache differ diff --git a/docs/API-GUIDE.md b/docs/API-GUIDE.md index e69de29..6031b96 100644 --- a/docs/API-GUIDE.md +++ b/docs/API-GUIDE.md @@ -0,0 +1,269 @@ +# ForSure API Guide + +## Table of Contents + +- [Introduction](#introduction) +- [Setup](#setup) +- [Available Endpoints](#available-endpoints) + - [Create Project](#create-project) + - [Validate Structure](#validate-structure) + - [List Projects](#list-projects) + - [Get Project Details](#get-project-details) + - [Delete Project](#delete-project) +- [Request/Response Formats](#requestresponse-formats) +- [Authentication](#authentication) +- [Error Handling](#error-handling) +- [Examples](#examples) + +## Introduction + +The ForSure API allows you to manage and validate project structures programmatically. You can create, validate, list, and delete project structures using RESTful endpoints. + +## Setup + +### Base URL + +The base URL for the API is: +https://api.forsure.com/v1 + +Copy +Insert + +### Authentication + +All API requests require authentication via API key. Include the API key in the headers of your requests: +Authorization: Bearer YOUR_API_KEY + +Copy +Insert + +## Available Endpoints + +### Create Project + +**Endpoint:** `POST /projects` + +**Description:** Create a new project with a specified structure. + +**Request:** +```json +{ + "name": "my-project", + "structure": "root: { 'index.html': [ size: '5KB', type: 'html' ] }" +} +Response: + +JSON +Copy +Insert +{ + "id": "12345", + "name": "my-project", + "structure": "root: { 'index.html': [ size: '5KB', type: 'html' ] }", + "createdAt": "2023-10-01T00:00:00Z" +} +Validate Structure +Endpoint: POST /projects/:id/validate + +Description: Validate the structure of an existing project. + +Request: + +JSON +Copy +Insert +{ + "structure": "root: { 'index.html': [ size: '5KB', type: 'html' ] }" +} +Response: + +JSON +Copy +Insert +{ + "isValid": true, + "errors": [] +} +List Projects +Endpoint: GET /projects + +Description: Retrieve a list of all projects. + +Response: + +JSON +Copy +Insert +{ + "projects": [ + { + "id": "12345", + "name": "my-project", + "createdAt": "2023-10-01T00:00:00Z" + } + ] +} +Get Project Details +Endpoint: GET /projects/:id + +Description: Retrieve the details of a specific project. + +Response: + +JSON +Copy +Insert +{ + "id": "12345", + "name": "my-project", + "structure": "root: { 'index.html': [ size: '5KB', type: 'html' ] }", + "createdAt": "2023-10-01T00:00:00Z" +} +Delete Project +Endpoint: DELETE /projects/:id + +Description: Delete a specific project. + +Response: + +JSON +Copy +Insert +{ + "message": "Project deleted successfully." +} +Request/Response Formats +Content-Type: All requests and responses are in JSON format. +Headers: Include header Content-Type: application/json for all requests. +Authentication +To authenticate with the ForSure API, include your API key in the Authorization header: + +Copy +Insert +Authorization: Bearer YOUR_API_KEY +Error Handling +The API uses standard HTTP status codes to indicate success or failure. Common status codes include: + +200 OK: The request was successful. +201 Created: The resource was created successfully. +400 Bad Request: The request was invalid or cannot be served. +401 Unauthorized: Authentication is required and has failed or has not yet been provided. +404 Not Found: The requested resource could not be found. +500 Internal Server Error: An error occurred on the server. +Example Error Response: + +JSON +Copy +Insert +{ + "error": "Invalid structure format." +} +Examples +Create a Project +Request: + +Shell Script +Copy +Insert +curl -X POST https://api.forsure.com/v1/projects \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "name": "my-project", + "structure": "root: { \'index.html\': [ size: \'5KB\', type: \'html\' ] }" + }' +Response: + +JSON +Copy +Insert +{ + "id": "12345", + "name": "my-project", + "structure": "root: { 'index.html': [ size: '5KB', type: 'html' ] }", + "createdAt": "2023-10-01T00:00:00Z" +} +Validate a Project Structure +Request: + +Shell Script +Copy +Insert +curl -X POST https://api.forsure.com/v1/projects/12345/validate \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{ + "structure": "root: { \'index.html\': [ size: \'5KB\', type: \'html\' ] }" + }' +Response: + +JSON +Copy +Insert +{ + "isValid": true, + "errors": [] +} +List Projects +Request: + +Shell Script +Copy +Insert +curl -X GET https://api.forsure.com/v1/projects \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" +Response: + +JSON +Copy +Insert +{ + "projects": [ + { + "id": "12345", + "name": "my-project", + "createdAt": "2023-10-01T00:00:00Z" + } + ] +} +Get Project Details +Request: + +Shell Script +Copy +Insert +curl -X GET https://api.forsure.com/v1/projects/12345 \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" +Response: + +JSON +Copy +Insert +{ + "id": "12345", + "name": "my-project", + "structure": "root: { 'index.html': [ size: '5KB', type: 'html' ] }", + "createdAt": "2023-10-01T00:00:00Z" +} +Delete a Project +Request: + +Shell Script +Copy +Insert +curl -X DELETE https://api.forsure.com/v1/projects/12345 \ + -H "Authorization: Bearer YOUR_API_KEY" \ + -H "Content-Type: application/json" +Response: + +JSON +Copy +Insert +{ + "message": "Project deleted successfully." +} +This +API-GUIDE.md + provides a comprehensive guide for developers on how to interact with the ForSure API, including setup, available endpoints, request/response formats, authentication, error handling, and practical examples. \ No newline at end of file diff --git a/docs/CLI-GUIDE.md b/docs/CLI-GUIDE.md index e69de29..e0ae22a 100644 --- a/docs/CLI-GUIDE.md +++ b/docs/CLI-GUIDE.md @@ -0,0 +1,145 @@ +# ForSure CLI Guide + +## Table of Contents + +- [Introduction](#introduction) +- [Installation](#installation) +- [Available Commands](#available-commands) + - [`forsure new`](#forsure-new) + - [`forsure run`](#forsure-run) + - [`forsure --help`](#forsure-help) + - [`forsure --version`](#forsure-version) +- [Usage Examples](#usage-examples) + - [Creating a New Project](#creating-a-new-project) + - [Running ForSure](#running-forsure) + - [Listing All Commands](#listing-all-commands) +- [Configuration](#configuration) +- [Best Practices](#best-practices) +- [Troubleshooting](#troubleshooting) +- [Additional Resources](#additional-resources) + +## Introduction + +ForSure is a CLI tool that helps you manage and visualize project structures and metadata. By defining, visualizing, and validating your project's structure with ForSure, you can make project management more predictable and less error-prone. + +## Installation + +To install ForSure globally using npm, run: +```sh +npm install -g forsure-cli +To verify the installation, check the version: + +Shell Script +Copy +Insert +forsure --version +Available Commands +forsure new +Description: Create a new project with a basic template. + +Usage: + +Shell Script +Copy +Insert +forsure new +forsure run +Description: Validate and visualize the project structure defined in a file. + +Usage: + +Shell Script +Copy +Insert +forsure run +forsure --help +Description: Display help information for the ForSure CLI tool. + +Usage: + +Shell Script +Copy +Insert +forsure --help +forsure --version +Description: Display the current version of the ForSure CLI tool. + +Usage: + +Shell Script +Copy +Insert +forsure --version +Usage Examples +Creating a New Project +To create a new project named "my-project", run: + +Shell Script +Copy +Insert +forsure new my-project +Running ForSure +To validate and visualize the project structure defined in +project-structure.forsure +, run: + +Shell Script +Copy +Insert +forsure run project-structure.forsure +Listing All Commands +To see all available commands, run: + +Shell Script +Copy +Insert +forsure --help +Configuration +ForSure can be configured using a configuration file ( +forsure.config.json +). Below is an example configuration: + +JSON +Copy +Insert +{ + "maxFileSize": "10MB", + "allowedFileTypes": ["javascript", "html", "css"] +} +Place the +forsure.config.json + file in the root directory of your project to apply custom configurations. + +Best Practices +Verify Before Committing: Always run forsure to verify your project structure definitions before committing them. +Consistency: Use clear and consistent naming conventions for files and directories. +Modularity: Break down large structures into modular +.forsure + files and use @import directives. +Documentation: Document your +.forsure + files with comments and annotations. +Troubleshooting +Common Issues +Invalid Command: Ensure you are using the correct command syntax. +Missing File: Verify that the file path you provided is correct. +Validation Errors: Review the error messages provided by ForSure and adjust your +.forsure + file accordingly. +Getting Help +If you encounter issues that you cannot resolve, refer to the official documentation or seek help in the community forums. + +Additional Resources +Official Documentation +Community Forums +GitHub Repository +Tutorial Videos +Community Support +This +CLI-GUIDE.md + provides comprehensive instructions for installing, using, and configuring the ForSure CLI tool. By following this guide, you can effectively utilize ForSure to manage and visualize your project structures. + +Copy +Insert + +This `CLI-GUIDE.md` file provides a complete guide for users on how to install, use, and configure the ForSure CLI tool. It includes available commands, usage examples, configuration options, best practices, troubleshooting tips, and additional resources for further assistance. \ No newline at end of file diff --git a/docs/CONVERTER.md b/docs/CONVERTER.md index e69de29..76c102a 100644 --- a/docs/CONVERTER.md +++ b/docs/CONVERTER.md @@ -0,0 +1,174 @@ +# ForSure Converter Guide + +## Table of Contents + +- [Introduction](#introduction) +- [Installation](#installation) +- [Supported Formats](#supported-formats) +- [Usage](#usage) + - [Basic Conversion](#basic-conversion) + - [Conversion Options](#conversion-options) +- [Examples](#examples) + - [Convert JSON to ForSure](#convert-json-to-forsure) + - [Convert ForSure to YAML](#convert-forsure-to-yaml) +- [Configuration](#configuration) +- [Best Practices](#best-practices) +- [Troubleshooting](#troubleshooting) +- [Additional Resources](#additional-resources) + +## Introduction + +The ForSure converter tool allows you to convert project structure definitions between different formats, including ForSure, JSON, and YAML. This can be useful for integrating ForSure with other tools and systems that use different configuration formats. + +## Installation + +To install the ForSure converter globally via npm, use the following command: +```sh +npm install -g forsure-converter +Supported Formats +ForSure ( +.forsure +) +JSON ( +.json +) +YAML ( +.yaml +) +Usage +Basic Conversion +To convert a project structure definition from one format to another, use the following command: + +Shell Script +Copy +Insert +forsure-converter convert +Conversion Options +You can specify additional options to customize the conversion process: + +Shell Script +Copy +Insert +forsure-converter convert [options] +Available Options: + +--pretty: Format the output file with pretty-printing (for JSON and YAML). +--schema : Use a custom schema file for validation during conversion. +--strict: Enable strict mode to enforce strict validation rules. +Examples +Convert JSON to ForSure +Command: + +Shell Script +Copy +Insert +forsure-converter convert structure.json structure.forsure +Input ( +structure.json +): + +JSON +Copy +Insert +{ + "root": { + "index.html": { + "size": "5KB", + "type": "html" + }, + "style.css": { + "size": "2KB", + "type": "css" + }, + "script.js": { + "size": "3KB", + "type": "javascript" + } + } +} +Output ( +structure.forsure +): + +Copy +Insert +root: { + 'index.html': [ size: '5KB', type: 'html' ], + 'style.css': [ size: '2KB', type: 'css' ], + 'script.js': [ size: '3KB', type: 'javascript' ] +} +Convert ForSure to YAML +Command: + +Shell Script +Copy +Insert +forsure-converter convert structure.forsure structure.yaml --pretty +Input ( +structure.forsure +): + +Copy +Insert +root: { + 'index.html': [ size: '5KB', type: 'html' ], + 'style.css': [ size: '2KB', type: 'css' ], + 'script.js': [ size: '3KB', type: 'javascript' ] +} +Output ( +structure.yaml +): + +Copy +Insert +root: + index.html: + size: "5KB" + type: "html" + style.css: + size: "2KB" + type: "css" + script.js: + size: "3KB" + type: "javascript" +Configuration +You can configure the ForSure converter using a configuration file ( +forsure-converter.config.json +). Place the configuration file in the root directory of your project. + +Example Configuration +JSON +Copy +Insert +{ + "defaultFormat": "yaml", + "prettyPrint": true, + "validateSchema": true, + "schemaFile": "custom-schema.json" +} +Best Practices +Keep It Simple: Use the converter to maintain a consistent project structure across different formats. +Validate Schemas: Always validate your project structures using custom schemas to ensure consistency. +Backup Files: Before converting, make sure to backup your original files to prevent data loss. +Troubleshooting +Common Issues +Invalid Format: Ensure that the input file is in a supported format. +Schema Validation Errors: Review the error messages and update your schema or project structure as needed. +Conversion Failures: Check for syntax errors in your input file and ensure the output file’s path is correct. +Getting Help +If you encounter issues that you cannot resolve, refer to the official documentation or seek help in the community forums. + +Additional Resources +Official Documentation +Community Forums +GitHub Repository +Tutorial Videos +Community Support +This +CONVERTER.md + provides a comprehensive guide for using the ForSure converter tool to convert project structure definitions between different formats. By following this guide, you can effectively integrate ForSure with other systems and tools. + +Copy +Insert + +This `CONVERTER.md` file provides a detailed guide on using the ForSure converter, including installation, usage, examples, configuration, best practices, troubleshooting, and additional resources. \ No newline at end of file diff --git a/docs/DAEMON-CLI-GUIDE.md b/docs/DAEMON-CLI-GUIDE.md index e69de29..8faed77 100644 --- a/docs/DAEMON-CLI-GUIDE.md +++ b/docs/DAEMON-CLI-GUIDE.md @@ -0,0 +1,118 @@ +# ForSure Daemon CLI Guide + +## Table of Contents + +- [Introduction](#introduction) +- [Installation](#installation) +- [Running the Daemon](#running-the-daemon) + - [Starting the Daemon](#starting-the-daemon) + - [Stopping the Daemon](#stopping-the-daemon) + - [Restarting the Daemon](#restarting-the-daemon) + - [Viewing Daemon Status](#viewing-daemon-status) +- [Interacting with the Daemon](#interacting-with-the-daemon) + - [Running Commands](#running-commands) + - [Logging](#logging) +- [Configuration](#configuration) +- [Best Practices](#best-practices) +- [Troubleshooting](#troubleshooting) +- [Additional Resources](#additional-resources) + +## Introduction + +The ForSure daemon allows you to run background processes that manage and validate project structures continuously. This guide will help you install, configure, and manage the ForSure daemon using the CLI. + +## Installation + +To install the ForSure daemon globally via npm, use the following command: +```sh +npm install -g forsure-daemon +Running the Daemon +Starting the Daemon +To start the ForSure daemon, use the following command: + +Shell Script +Copy +Insert +forsure-daemon start +Stopping the Daemon +To stop the ForSure daemon, use the following command: + +Shell Script +Copy +Insert +forsure-daemon stop +Restarting the Daemon +To restart the ForSure daemon, use the following command: + +Shell Script +Copy +Insert +forsure-daemon restart +Viewing Daemon Status +To check the status of the ForSure daemon, use the following command: + +Shell Script +Copy +Insert +forsure-daemon status +Interacting with the Daemon +Running Commands +You can interact with the running daemon to execute ForSure commands. For example, to validate a project structure: + +Shell Script +Copy +Insert +forsure-daemon exec forsure run +Logging +To view the logs generated by the ForSure daemon, use the following command: + +Shell Script +Copy +Insert +forsure-daemon logs +For real-time log streaming, use: + +Shell Script +Copy +Insert +forsure-daemon logs -f +Configuration +You can configure the ForSure daemon using a configuration file ( +forsure-daemon.config.json +). Place the configuration file in the root directory of your project. + +Example Configuration +JSON +Copy +Insert +{ + "pollingInterval": "60000", // Time in milliseconds to wait between polling for changes + "logLevel": "info", // Log level (e.g., "info", "debug", "error") + "maxMemoryUsage": "512MB" // Maximum memory usage before restarting the daemon +} +Best Practices +Regular Monitoring: Regularly check the status of the ForSure daemon to ensure it is running smoothly. +Log Management: Monitor and manage logs to avoid excessive disk usage. +Resource Limits: Configure reasonable memory and CPU usage limits to prevent the daemon from affecting other processes. +Troubleshooting +Common Issues +Daemon Fails to Start: Ensure there are no conflicting processes and that the configuration file is correctly formatted. +High Resource Usage: Check and adjust the resource limits in the configuration file. +Command Execution Failures: Ensure the file paths and syntax are correct when using forsure-daemon exec. +Getting Help +If you encounter issues that you cannot resolve, refer to the official documentation or seek help in the community forums. + +Additional Resources +Official Documentation +Community Forums +GitHub Repository +Tutorial Videos +Community Support +This +DAEMON-CLI-GUIDE.md + provides comprehensive instructions for installing, starting, stopping, and configuring the ForSure daemon. By following this guide, you can effectively manage background processes for continuous project structure validation. + +Copy +Insert + +This guide covers all essential aspects of running and managing the ForSure daemon through the CLI, offering clear and concise instructions on installation, configuration, and troubleshooting. \ No newline at end of file diff --git a/docs/DOCUMENTATION.md b/docs/DOCUMENTATION.md index fef5699..6dc17da 100644 --- a/docs/DOCUMENTATION.md +++ b/docs/DOCUMENTATION.md @@ -1,138 +1,175 @@ -# OFFICIAL-LANGUAGE-DOCUMENTATION.md +# ForSure Documentation + +## Table of Contents + +- [Introduction](#introduction) +- [Getting Started](#getting-started) + - [Installation](#installation) + - [Basic Usage](#basic-usage) +- [Understanding the File Structure](#understanding-the-file-structure) +- [Core Features](#core-features) + - [Hierarchical Structure](#hierarchical-structure) + - [Comments and Annotations](#comments-and-annotations) + - [Custom Attributes](#custom-attributes) +- [Advanced Features](#advanced-features) + - [@import Directives](#import-directives) + - [Modularization](#modularization) + - [Error Handling](#error-handling) +- [Configuration](#configuration) +- [Best Practices](#best-practices) +- [Additional Resources](#additional-resources) ## Introduction -The ForSure language provides a user-friendly and readable syntax for managing and manipulating project structures. It is designed to be easy to use, extensible, and reliable, making it suitable for developers and non-developers alike. This document covers the setup process, syntax guide, and a reference for the standard library. +ForSure is a CLI tool designed to manage and visualize project structures and metadata. It enables developers to define, visualize, and validate project structures, ensuring that files and directories conform to a specified format. By maintaining a consistent project structure, ForSure simplifies project management and reduces errors. -## Features - -- **Hierarchical Structure**: Represents file systems as a collection of folders and files. -- **Comments and Annotations**: Allows for descriptive purposes. -- **Import Directives**: Facilitates inclusion of reusable structures. -- **Custom Attributes**: Extends elements with user-defined metadata. -- **Readable Syntax**: Easy to understand and use. - -## Setup - -To start using the ForSure language, follow the setup instructions below: +## Getting Started ### Installation -1. **Install ForSure CLI**: The ForSure command-line interface (CLI) can be installed via npm or another package manager. Run the following command: - ```sh - npm install -g forsure-cli - ``` -2. **Verify Installation**: Ensure the installation was successful by checking the version: - ```sh - forsure --version - ``` -3. **Create a New ForSure Project**: Use the CLI to create a new project: - ```sh - forsure new my-project - ``` -4. **Navigate to Project Directory**: Move to your project directory: - ```sh - cd my-project - ``` -5. **Run ForSure**: Start using the ForSure language in your project: - ```sh - forsure run - ``` -With these steps, you should be ready to define and manage your project structures using ForSure. - -## Syntax Guide - -The ForSure language uses a concise and readable syntax for defining file systems. Below are the core syntax elements: - -### File System Representation - -The root of the file system is defined using the `root` keyword, followed by a hierarchical representation of folders and files enclosed in curly braces `{}`. - -```forsure +To install ForSure globally via npm, use the following command: +```sh +npm install -g forsure-cli +To verify the installation: + +Shell Script +Copy +Insert +forsure --version +Basic Usage +Initialize a New Project: + +Shell Script +Copy +Insert +forsure new +Run ForSure: + +Shell Script +Copy +Insert +forsure run +List All Commands: + +Shell Script +Copy +Insert +forsure --help +Understanding the File Structure +A ForSure file ( +.forsure +) defines the structure of a project using a clean, human-readable syntax. The structure is defined hierarchically, allowing for nested directories and files. Here is an example: + +Copy +Insert root: { - // folder and file definitions + 'src': { + 'index.js': [ size: '2KB', type: 'javascript' ], + 'styles': { + 'main.css': [ size: '1KB', type: 'css' ] + } + }, + 'README.md': [ size: '1KB', type: 'markdown' ] } -``` -## Folder and File Definitions +Core Features +Hierarchical Structure +ForSure uses a hierarchical structure to represent files and directories: -Folders and files are defined within the root. Each folder and file is a key-value pair where the key is the name and the value is either another folder definition or a list of file names. +Copy +Insert +root: { + 'index.html': [ size: '5KB', type: 'html' ], + 'style.css': [ size: '2KB', type: 'css' ], + 'script.js': [ size: '3KB', type: 'javascript' ] +} +Comments and Annotations +You can add comments and annotations in +.forsure + files for documentation purposes: +Copy +Insert root: { - 'folder1': { - 'file1.txt', - 'file2.txt' - }, - 'folder2': { - 'subfolder1': { - 'file3.txt' - }, - 'file4.txt' + 'styles': { + 'main.css': [ size: '3KB', type: 'css', description: 'Main stylesheet' ] # Main stylesheet for the project } } +Custom Attributes +Extend elements with user-defined attributes like permissions, sizes, and types: -## Attributes - -Attributes provide metadata for files and folders such as size, type, and permissions. They are enclosed in square brackets [] and are attached to the file or folder name. - -'file1.txt': [ size: '10KB', type: 'text' ] -Importing External File Systems -For modular project structures, use the @import directive to include files and folders from other ForSure files. - -@import 'external.fs'; +Copy +Insert root: { - // folder and file definitions + 'index.html': [ size: '5KB', type: 'html', permissions: 'rw-r--r--' ] } +Advanced Features +@import Directives +Use @import directives to include reusable structures: -## Comments and Annotations - -ForSure allows inline comments using the // syntax for descriptive purposes. - +Copy +Insert +@import 'common.forsure'; root: { - 'folder1': { // Main folder - 'file1.txt', // Text file - 'file2.txt': [ size: '5KB', type: 'text' ] // Another text file with attributes + 'src': { + 'index.js': [ size: '10KB', type: 'javascript' ] + } } } +Modularization +For large projects, break down your ForSure definitions into modular files: -## Standard Library Reference - -The ForSure standard library includes several built-in attributes and directives for common use cases. - -Attributes -size -Specifies the size of a file. - -'file1.txt': [ size: '10KB' ] -type -Specifies the type of a file. - -'file1.txt': [ type: 'text' ] -permissions -Specifies permissions for a file or folder. - -'file1.txt': [ permissions: 'read-only' ] -Directives -@import -Imports an external file system definition. - -@import 'external.fs'; -Example -Bringing it all together, here’s a final example showcasing various features: +Copy +Insert +common.forsure +root: { + 'common': { + 'config.json': [ size: '2KB', type: 'json' ] + } +} -@import 'common.fs'; +project.forsure +@import 'common.forsure'; root: { 'src': { - 'main': { - 'app.js': [ size: '15KB', type: 'javascript' ], - 'index.html': [ size: '5KB', type: 'html' ] - }, - 'styles': { - 'style.css': [ size: '3KB', type: 'css' ] - } - }, - 'README.md': [ size: '2KB', type: 'markdown' ] + 'main.js': [ size: '3KB', type: 'javascript' ] + } } - -## Conclusion - -With this guide, you should have a comprehensive understanding of the ForSure language's setup, syntax, and standard library. For more advanced topics, refer to the official documentation and community resources. \ No newline at end of file +Error Handling +ForSure provides error handling mechanisms such as customizable error messages and input validation: + +Shell Script +Copy +Insert +# Custom error message for missing file +Error: File 'src/main.js' not found in defined structure. +Configuration +ForSure can be configured via a configuration file ( +forsure.config.json +): + +JSON +Copy +Insert +{ + "maxFileSize": "10MB", + "allowedFileTypes": ["javascript", "html", "css"] +} +Place the +forsure.config.json + file in the root directory of your project to apply custom configurations. + +Best Practices +Verify before committing: Always verify your project structure definitions before committing. +Consistency: Use clear and consistent naming conventions. +Modularity: Modularize structures into separate files for larger projects. +Documentation: Document attributes and their expected values at the beginning of your files. +Additional Resources +Official Documentation +Community Forums +GitHub Repository +Tutorial Videos +Community Support +Copy +Insert + +This `DOCUMENTATION.md` file provides a comprehensive overview of the ForSure project, including core and advanced features, configuration, best practices, and additional resources. Use this guide to get started, understand the ForSure language, and effectively manage your project structures. \ No newline at end of file diff --git a/docs/STYLE-GUIDE.md b/docs/STYLE-GUIDE.md index 6f59740..c47eb36 100644 --- a/docs/STYLE-GUIDE.md +++ b/docs/STYLE-GUIDE.md @@ -1,33 +1,223 @@ # Style Guide for ForSure -1. Naming Conventions: - - **Variables**: Follow camelCase naming convention. - - **Functions**: Follow camelCase naming convention. - - **Constants**: Use all uppercase letters with underscores to separate words. - - **Classes**: Follow PascalCase naming convention. - - **Files**: Use kebab-case (lowercase letters separated by hyphens) for file names. - -2. Formatting Rules: - - Use consistent indentation with 2 or 4 spaces. - - Use meaningful whitespace to enhance readability. - - Limit line length to 80-120 characters to maintain readability. - - Use comments to explain non-obvious code sections or provide additional context. - -3. Code Structure Guidelines: - - Organize code using a hierarchical structure. - - Group related files and directories logically. - - Use objects or dictionaries to represent nested structures with descriptive keys. - - Provide comments or annotations to explain the purpose of each item or directory. - - Avoid deeply nested code structures and refactor complex logic into separate functions or modules when appropriate. - -4. Documentation Guidelines: - - Include header comments or annotations at the beginning of each file to summarize its purpose. - - Use inline comments to explain non-obvious code sections or provide context. - - Document public APIs, functions, or classes using docstrings or comments to describe their purpose, input parameters, return values, and any side effects. - - Keep the documentation up to date and in sync with the code changes. - -These guidelines can serve as a starting point for the ForSure coding style guide. You can customize and expand upon them based on your team's preferences and the specific requirements of your project. +## Naming Conventions +- **Variables**: Use camelCase for variable names. + ```javascript + let fileName = 'example.txt'; +Functions: Use camelCase for function names. +JavaScript +Copy +Insert +function fetchData() { + // function code +} +Constants: Use all uppercase letters with underscores to separate words. +JavaScript +Copy +Insert +const MAX_SIZE = 100; +Classes: Use PascalCase for class names. +JavaScript +Copy +Insert +class DataLoader { + // class code +} +Files: Use kebab-case (lowercase letters separated by hyphens) for file names. +JavaScript +Copy +Insert +config-settings.json +Formatting Rules +Indentation: Use consistent indentation with 2 or 4 spaces (choose one and stick to it). +JavaScript +Copy +Insert +function example() { + const data = { + name: 'ForSure' + }; +} +Line Length: Limit line length to 80-120 characters to maintain readability. +JavaScript +Copy +Insert +// Example of limiting line length +const sampleString = "This is a sample string that is well below the 120 characters limit which helps in maintaining readability."; +Whitespace: Use meaningful whitespace to enhance readability. +Add a single blank line before return statements. +Add a single blank line between logical code blocks. +JavaScript +Copy +Insert +function example() { + const data = fetchData(); + + if (!data) { + return null; + } + + // process data + process(data); + + return data; +} +Comments: Use comments to explain non-obvious code sections or provide additional context. +JavaScript +Copy +Insert +// Fetch data from the API +function fetchData() { + // function code +} +Code Structure Guidelines +Hierarchical Structure: Organize code using a hierarchical structure. +Group related files and directories logically. +Use objects or dictionaries to represent nested structures with descriptive keys. +JavaScript +Copy +Insert +const projectStructure = { + src: { + main: { + 'index.js': '2KB', + 'app.js': '3KB' + }, + utils: { + 'logger.js': '1KB' + } + } +}; +Modularity: Avoid deeply nested code structures and refactor complex logic into separate functions or modules when appropriate. +Separate concerns by placing different responsibilities in different modules. +JavaScript +Copy +Insert +// logger.js +export function log(message) { + console.log(message); +} + +// app.js +import { log } from './logger'; +log('Starting application...'); +Consistent Naming: Use consistent naming conventions across the codebase. +File Headers: Include header comments or annotations at the beginning of each file to summarize its purpose. +JavaScript +Copy +Insert +/** + * logger.js + * Utility functions for logging messages + */ +Documentation Guidelines +File Documentation: Include header comments or annotations at the beginning of each file to summarize its purpose. +JavaScript +Copy +Insert +/** + * config-settings.json + * Configuration settings for the application + */ +Inline Comments: Use inline comments to explain non-obvious code sections or provide context. +JavaScript +Copy +Insert +// Fetch data from the API +function fetchData() { + // function code +} +Function and Class Documentation: Document public APIs, functions, or classes using docstrings or comments to describe their purpose, input parameters, return values, and any side effects. +JavaScript +Copy +Insert +/** + * Fetch data from the API + * @returns {Object} - Retrieved data + */ +function fetchData() { + // function code +} +Keep Documentation Updated: Ensure that the documentation is up to date and in sync with the code changes. +Examples +Naming Conventions +JavaScript +Copy +Insert +// Variables +let fileSize = 1024; + +// Functions +function calculateSize() { + // function code +} + +// Constants +const MAX_LIMIT = 50; + +// Classes +class FileUploader { + // class code +} + +// Files +// config-settings.json +Formatting Rules +JavaScript +Copy +Insert +function processRequest() { + const data = getRequestData(); + + if (!data) { + return null; + } + + // Process the request data + process(data); + + return data; +} +Code Structure Guidelines +JavaScript +Copy +Insert +// Organizing code using a hierarchical structure +const structure = { + src: { + components: { + 'Header.js': 'Component for the header', + 'Footer.js': 'Component for the footer' + }, + utils: { + 'helpers.js': 'Helper functions' + } + } +}; +Documentation Guidelines +JavaScript +Copy +Insert +/** + * FileUploader class + * Handles file upload operations + */ +class FileUploader { + /** + * Upload a file + * @param {File} file - The file to upload + * @returns {Promise} - Promise resolving when the upload is complete + */ + upload(file) { + // method code + } +} Remember, consistency is key when establishing coding standards and guidelines. Ensure that all team members are aware of and adhere to the defined conventions to maintain a clean and readable codebase. If you have any further questions or need additional guidance, feel free to ask! + +Copy +Insert + +This `STYLE-GUIDE.md` provides a comprehensive set of guidelines to maintain a clean, consistent, and readable codebase for the ForSure project. It covers naming conventions, formatting rules, code structure guidelines, and documentation practices to ensure high code quality and maintainability. \ No newline at end of file diff --git a/docs/TUTORIAL.md b/docs/TUTORIAL.md deleted file mode 100644 index e69de29..0000000 diff --git a/docs/USER-GUIDE.md b/docs/USER-GUIDE.md index 2544243..be8bb0e 100644 --- a/docs/USER-GUIDE.md +++ b/docs/USER-GUIDE.md @@ -1,48 +1,53 @@ -Introduction -Installation -Commands/Usage -Examples -Best Practices -Troubleshooting -Here’s an example - to document the tooling for ForSure: +# ForSure User Guide -# ForSure -ForSure is a CLI tool for managing and visualizing project structure and metadata. ## Introduction -ForSure helps you define, visualize, and validate the structure of your projects. It ensures that your project’s files and directories conform to a specified structure, making project management more predictable and less error-prone. + +ForSure is a CLI tool for managing and visualizing project structure and metadata. It helps you define, visualize, and validate the structure of your projects. By ensuring that your project's files and directories conform to a specified structure, ForSure makes project management more predictable and less error-prone. + ## Installation + To install ForSure globally via npm, use the following command: ```sh npm install -g forsure-cli To verify the installation: +Shell Script +Copy forsure --version Commands/Usage Initialize a New Project -Create a new project with a basic template. +Create a new project with a basic template: +Shell Script +Copy forsure new Example: +Shell Script +Copy forsure new my-project Run ForSure -Run ForSure to validate and visualize the project structure defined in a - file. +Run ForSure to validate and visualize the project structure defined in a file: +Shell Script +Copy forsure run Example: +Shell Script +Copy forsure run project-structure.fs List All Commands To see all available commands, use: +Shell Script +Copy forsure --help Examples Basic Example -Create a - file with the following content: +Create a file with the following content: +Copy root: { 'index.html': [ size: '5KB', type: 'html' ], 'style.css': [ size: '2KB', type: 'css' ], @@ -50,11 +55,13 @@ root: { } Run ForSure to validate the structure: +Shell Script +Copy forsure run basic.fs Intermediate Example -Create an - file: +Create a file: +Copy root: { 'src': { 'index.ts': [ size: '10KB', type: 'typescript' ], @@ -71,11 +78,13 @@ root: { } Validate with: +Shell Script +Copy forsure run intermediate.fs Advanced Example -For modular design using imports, create a - file: +For modular design using imports, create a file: +Copy root: { 'common': { 'config.json': [ size: '2KB', type: 'json' ], @@ -84,9 +93,9 @@ root: { } } } -Create -: +Create another file with the following: +Copy @import 'common.fs'; root: { 'src': { @@ -102,21 +111,25 @@ root: { } Validate with: +Shell Script +Copy forsure run advanced.fs Best Practices -Always verify your project structure definitions before committing. -Use clear and consistent naming conventions. -Modularize structures into separate files for larger projects. -Document attributes and their expected values at the beginning of your - files. +Verify before committing: Always verify your project structure definitions before committing. +Consistency: Use clear and consistent naming conventions. +Modularity: Modularize structures into separate files for larger projects. +Documentation: Document attributes and their expected values at the beginning of your files. Troubleshooting Common Issues Invalid Command: Ensure that you are using the correct command syntax. Missing File: Verify that the file path in the command is correct. -Validation Errors: Review the error messages for details on what's incorrect and adjust your - file accordingly. +Validation Errors: Review the error messages for details on what's incorrect and adjust your file accordingly. Getting Help For further assistance, refer to the official documentation or check out the community forums and support channels. Conclusion -ForSure is a powerful tool to manage project structures consistently \ No newline at end of file +ForSure is a powerful tool to manage project structures consistently. By following this user guide, you can effectively utilize ForSure to simplify and standardize your project management process. + +Copy + +This `USER-GUIDE.md` provides a comprehensive guide for users on how to install, use, and troubleshoot the ForSure CLI tool. It includes examples from basic to advanced usage, best practices, and common troubleshooting tips. \ No newline at end of file diff --git a/examples/advanced_example.forsure b/examples/advanced_example.forsure index e69de29..598388a 100644 --- a/examples/advanced_example.forsure +++ b/examples/advanced_example.forsure @@ -0,0 +1,72 @@ +@import 'common-shared-utils.forsure'; +@import 'advanced-shared-modules.forsure'; + +root: { + 'src': { + 'app': { + 'components': { + 'header': { + 'header.js': [ size: '4KB', type: 'javascript', permissions: 'rw-r--r--', author: 'dev1' ], + 'header.module.css': [ size: '2KB', type: 'css', permissions: 'rw-r--r--', author: 'dev1' ] + }, + 'footer': { + 'footer.js': [ size: '3KB', type: 'javascript', permissions: 'rw-r--r--', author: 'dev2' ], + 'footer.module.css': [ size: '1KB', type: 'css', permissions: 'rw-r--r--', author: 'dev2' ] + }, + 'navbar': { + 'navbar.jsx': [ size: '5KB', type: 'javascript', permissions: 'rw-r--r--', author: 'dev3' ], + 'navbar.module.css': [ size: '2KB', type: 'css', permissions: 'rw-r--r--', author: 'dev3' ] + } + }, + 'utils': { + 'helpers.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--', author: 'dev4' ], + 'logger.js': [ size: '3KB', type: 'javascript', permissions: 'rw-r--r--', author: 'dev4' ] + }, + 'config': { + 'app-config.json': [ size: '1KB', type: 'json', permissions: 'rw-r--r--', author: 'dev5' ], + 'db-config.yaml': [ size: '1KB', type: 'yaml', permissions: 'rw-r--r--', author: 'dev5' ] + } + }, + 'styles': { + 'global.css': [ size: '3KB', type: 'css', permissions: 'rw-r--r--', author: 'stylist' ], + 'theme.css': [ size: '3KB', type: 'css', permissions: 'rw-r--r--', author: 'stylist' ] + } + }, + 'docs': { + 'README.md': [ size: '2KB', type: 'markdown', permissions: 'rw-r--r--', author: 'docwriter' ], + 'CONTRIBUTING.md': [ size: '1KB', type: 'markdown', permissions: 'rw-r--r--', author: 'docwriter' ], + 'API': { + 'endpoints.md': [ size: '3KB', type: 'markdown', permissions: 'rw-r--r--', author: 'docwriter' ], + 'authentication.md': [ size: '2KB', type: 'markdown', permissions: 'rw-r--r--', author: 'docwriter' ] + } + }, + 'tests': { + 'unit': { + 'components': { + 'header.test.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--', author: 'tester1' ], + 'footer.test.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--', author: 'tester2' ], + 'navbar.test.js': [ size: '3KB', type: 'javascript', permissions: 'rw-r--r--', author: 'tester3' ] + }, + 'utils': { + 'helpers.test.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--', author: 'tester4' ], + 'logger.test.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--', author: 'tester4' ] + } + }, + 'integration': { + 'app.integration.test.js': [ size: '4KB', type: 'javascript', permissions: 'rw-r--r--', author: 'tester5' ] + } + }, + 'public': { + 'index.html': [ size: '2KB', type: 'html', permissions: 'rw-r--r--', author: 'frontend' ], + 'favicon.ico': [ size: '1KB', type: 'icon', permissions: 'rw-r--r--', author: 'frontend' ], + 'assets': { + 'images': { + 'logo.png': [ size: '10KB', type: 'image/png', permissions: 'rw-r--r--', author: 'designer' ], + 'background.jpg': [ size: '20KB', type: 'image/jpeg', permissions: 'rw-r--r--', author: 'designer' ] + }, + 'fonts': { + 'OpenSans.ttf': [ size: '30KB', type: 'font/ttf', permissions: 'rw-r--r--', author: 'designer' ] + } + } + } +} \ No newline at end of file diff --git a/examples/beginner-example.forsure b/examples/beginner-example.forsure new file mode 100644 index 0000000..c8a7e7e --- /dev/null +++ b/examples/beginner-example.forsure @@ -0,0 +1,19 @@ +// Import external definitions for shared utilities +@import 'shared-utils.forsure'; + +root: { + 'src': { + 'components': { + 'header.js': [ size: '4KB', type: 'javascript' ], + 'footer.js': [ size: '3KB', type: 'javascript' ] + }, + 'utils': { + 'helpers.js': [ size: '2KB', type: 'javascript' ] + }, + 'config.json': [ size: '1KB', type: 'json' ] + }, + 'docs': { + 'readme.md': [ size: '1KB', type: 'markdown' ], + 'shared-utils': @import 'shared-utils.forsure' + } +} \ No newline at end of file diff --git a/examples/hello-world.forsure b/examples/hello-world.forsure deleted file mode 100644 index e69de29..0000000 diff --git a/examples/intermediate-example.forsure b/examples/intermediate-example.forsure new file mode 100644 index 0000000..b072854 --- /dev/null +++ b/examples/intermediate-example.forsure @@ -0,0 +1,41 @@ +@import 'shared-utils.forsure'; + +root: { + 'src': { + 'components': { + 'header.js': [ size: '4KB', type: 'javascript', permissions: 'rw-r--r--' ], + 'footer.js': [ size: '3KB', type: 'javascript', permissions: 'rw-r--r--' ], + 'navbar.jsx': [ size: '5KB', type: 'javascript', permissions: 'rw-r--r--' ] + }, + 'utils': { + 'math.js': [ size: '2KB', type: 'javascript', imported: true ], + 'string.js': [ size: '2KB', type: 'javascript', imported: true ], + 'helpers.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--' ] + }, + 'styles': { + 'main.css': [ size: '1KB', type: 'css', permissions: 'rw-r--r--' ], + 'theme.css': [ size: '1KB', type: 'css', permissions: 'rw-r--r--' ] + }, + 'config': { + 'app-config.json': [ size: '1KB', type: 'json', permissions: 'rw-r--r--' ], + 'db-config.yaml': [ size: '1KB', type: 'yaml', permissions: 'rw-r--r--' ] + } + }, + 'docs': { + 'README.md': [ size: '1KB', type: 'markdown', permissions: 'rw-r--r--' ], + 'API.md': [ size: '2KB', type: 'markdown', permissions: 'rw-r--r--' ] + }, + 'tests': { + 'unit': { + 'test_utils.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--' ], + 'test_helpers.js': [ size: '2KB', type: 'javascript', permissions: 'rw-r--r--' ] + }, + 'integration': { + 'test_integration.js': [ size: '3KB', type: 'javascript', permissions: 'rw-r--r--' ] + } + }, + 'public': { + 'index.html': [ size: '1KB', type: 'html', permissions: 'rw-r--r--' ], + 'favicon.ico': [ size: '1KB', type: 'icon', permissions: 'rw-r--r--' ] + } +} \ No newline at end of file diff --git a/examples/stdlib/advanced-shared-modules.forsure b/examples/stdlib/advanced-shared-modules.forsure new file mode 100644 index 0000000..67e8b7d --- /dev/null +++ b/examples/stdlib/advanced-shared-modules.forsure @@ -0,0 +1,37 @@ +root: { + 'advanced': { + 'modules': { + 'data-structures': { + 'linkedList.js': [ + size: '4KB', + type: 'javascript', + description: 'Implementation of a linked list data structure.' + ], + 'tree.js': [ + size: '5KB', + type: 'javascript', + description: 'Implementation of a binary tree data structure.' + ] + }, + 'algorithms': { + 'sort.js': [ + size: '3KB', + type: 'javascript', + description: 'Sorting algorithms like quicksort, mergesort, bubblesort.' + ], + 'search.js': [ + size: '3KB', + type: 'javascript', + description: 'Search algorithms like binary search, linear search.' + ] + } + }, + 'config': { + 'advanced-settings.json': [ + size: '2KB', + type: 'json', + description: 'Advanced configuration settings for specialized modules.' + ] + } + } +} \ No newline at end of file diff --git a/examples/stdlib/common-shared-utils.forsure b/examples/stdlib/common-shared-utils.forsure new file mode 100644 index 0000000..afb59f2 --- /dev/null +++ b/examples/stdlib/common-shared-utils.forsure @@ -0,0 +1,28 @@ +root: { + 'common': { + 'utils': { + 'math.js': [ + size: '3KB', + type: 'javascript', + description: 'Basic mathematical functions like add, subtract, multiply, and divide.' + ], + 'string.js': [ + size: '2KB', + type: 'javascript', + description: 'String manipulation functions like capitalize, trim, split.' + ], + 'logger.js': [ + size: '3KB', + type: 'javascript', + description: 'Logging utility to log messages with different severity levels.' + ] + }, + 'config': { + 'settings.json': [ + size: '1KB', + type: 'json', + description: 'Common application settings.' + ] + } + } +} \ No newline at end of file diff --git a/examples/stdlib/common-structures.forsure b/examples/stdlib/common-structures.forsure new file mode 100644 index 0000000..75ecd62 --- /dev/null +++ b/examples/stdlib/common-structures.forsure @@ -0,0 +1,31 @@ +root: { + 'common-structures': { + 'web-app': { + 'src': { + 'components': { '_': [] }, + 'assets': { '_': [] }, + 'index.js': [ size: '2KB', type: 'javascript' ], + 'App.js': [ size: '2KB', type: 'javascript' ] + }, + 'public': { + 'index.html': [ size: '2KB', type: 'html' ], + 'favicon.ico': [ size: '1KB', type: 'icon' ] + }, + 'package.json': [ size: '1KB', type: 'json' ], + 'README.md': [ size: '2KB', type: 'markdown' ] + }, + 'api-service': { + 'src': { + 'controllers': { '_': [] }, + 'models': { '_': [] }, + 'routes': { '_': [] }, + 'middlewares': { '_': [] }, + 'index.js': [ size: '2KB', type: 'javascript' ], + 'app.js': [ size: '2KB', type: 'javascript' ] + }, + 'config': { '_': [] }, + 'package.json': [ size: '1KB', type: 'json' ], + 'README.md': [ size: '2KB', type: 'markdown' ] + } + } +} \ No newline at end of file diff --git a/examples/stdlib/config-templates.forsure b/examples/stdlib/config-templates.forsure new file mode 100644 index 0000000..dc19eeb --- /dev/null +++ b/examples/stdlib/config-templates.forsure @@ -0,0 +1,19 @@ +root: { + 'config-templates': { + 'development.json': [ + size: '1KB', + type: 'json', + description: 'Development environment configuration template.' + ], + 'production.json': [ + size: '1KB', + type: 'json', + description: 'Production environment configuration template.' + ], + 'test.json': [ + size: '1KB', + type: 'json', + description: 'Test environment configuration template.' + ] + } +} \ No newline at end of file diff --git a/examples/stdlib/shared-utils.forsure b/examples/stdlib/shared-utils.forsure new file mode 100644 index 0000000..896da25 --- /dev/null +++ b/examples/stdlib/shared-utils.forsure @@ -0,0 +1,11 @@ + `root: { + 'shared': { + 'utils': { + 'math.js': [ size: '3KB', type: 'javascript' ], + 'string.js': [ size: '2KB', type: 'javascript' ], + }, + 'config': { + 'shared-config.json': [ size: '1KB', type: 'json' ] + } + } +} \ No newline at end of file diff --git a/examples/stdlib/utility-modules.forsure b/examples/stdlib/utility-modules.forsure new file mode 100644 index 0000000..2886e5f --- /dev/null +++ b/examples/stdlib/utility-modules.forsure @@ -0,0 +1,14 @@ +root: { + 'utility-modules': { + 'logger.js': [ + size: '2KB', + type: 'javascript', + description: 'Utility for logging messages.' + ], + 'formatter.js': [ + size: '2KB', + type: 'javascript', + description: 'Utility for formatting strings and data.' + ] + } +} \ No newline at end of file diff --git a/examples/stdlib/validation-utils.forsure b/examples/stdlib/validation-utils.forsure new file mode 100644 index 0000000..4f2d304 --- /dev/null +++ b/examples/stdlib/validation-utils.forsure @@ -0,0 +1,19 @@ +root: { + 'validation-utils': { + 'fileTypeValidator.js': [ + size: '2KB', + type: 'javascript', + description: 'Validates the type of files.' + ], + 'sizeValidator.js': [ + size: '2KB', + type: 'javascript', + description: 'Validates the size of files.' + ], + 'permissionValidator.js': [ + size: '2KB', + type: 'javascript', + description: 'Validates the permissions of files and directories.' + ] + } +} \ No newline at end of file diff --git a/examples/templates/backend.forsure b/examples/templates/backend.forsure new file mode 100644 index 0000000..55906bd --- /dev/null +++ b/examples/templates/backend.forsure @@ -0,0 +1,47 @@ +root: { + 'src': { + 'config': { + 'default.json': [ size: '1KB', type: 'json', description: 'Default configuration settings' ], + 'production.json': [ size: '1KB', type: 'json', description: 'Production configuration settings' ], + 'development.json': [ size: '1KB', type: 'json', description: 'Development configuration settings' ], + 'test.json': [ size: '1KB', type: 'json', description: 'Test environment configuration settings' ] + }, + 'controllers': { + 'userController.js': [ size: '2KB', type: 'javascript', description: 'Handles user-related operations' ], + 'authController.js': [ size: '2KB', type: 'javascript', description: 'Handles authentication-related operations' ] + }, + 'models': { + 'user.js': [ size: '3KB', type: 'javascript', description: 'Schema and model for user' ], + 'token.js': [ size: '2KB', type: 'javascript', description: 'Schema and model for authentication tokens' ] + }, + 'routes': { + 'userRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines routes for user-related API endpoints' ], + 'authRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines routes for authentication-related API endpoints' ] + }, + 'middlewares': { + 'authMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for authentication verification' ], + 'errorMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for global error handling' ] + }, + 'utils': { + 'logger.js': [ size: '2KB', type: 'javascript', description: 'Utility for logging' ], + 'validator.js': [ size: '1KB', type: 'javascript', description: 'Utility for validation functions' ] + }, + 'app.js': [ size: '3KB', type: 'javascript', description: 'Main application entry file' ], + 'server.js': [ size: '2KB', type: 'javascript', description: 'Entry file for starting the server' ] + }, + 'tests': { + 'unit': { + 'userController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for user controller' ], + 'authController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for auth controller' ] + }, + 'integration': { + 'userRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for user routes' ], + 'authRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for auth routes' ] + } + }, + 'config': { + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration' ], + '.env': [ size: '1KB', type: 'text', description: 'Environment variables' ] + }, + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide' ] +} \ No newline at end of file diff --git a/examples/templates/container-app/Dockerfile b/examples/templates/container-app/Dockerfile new file mode 100644 index 0000000..afdcba5 --- /dev/null +++ b/examples/templates/container-app/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Node.js image as a base image +FROM node:14 + +# Set the working directory +WORKDIR /usr/src/app + +# Copy package.json and package-lock.json +COPY package*.json ./ + +# Install dependencies +RUN npm install + +# Copy the rest of the application's code +COPY . . + +# Expose the port the app runs on +EXPOSE 3000 + +# Command to run the application +CMD ["node", "server.js"] \ No newline at end of file diff --git a/examples/templates/container-app/containerized-application.forsure b/examples/templates/container-app/containerized-application.forsure new file mode 100644 index 0000000..a9fcfde --- /dev/null +++ b/examples/templates/container-app/containerized-application.forsure @@ -0,0 +1,49 @@ +root: { + 'src': { + 'config': { + 'default.json': [ size: '1KB', type: 'json', description: 'Default configuration settings' ], + 'production.json': [ size: '1KB', type: 'json', description: 'Production configuration settings' ], + 'development.json': [ size: '1KB', type: 'json', description: 'Development configuration settings' ], + 'test.json': [ size: '1KB', type: 'json', description: 'Test environment configuration settings' ] + }, + 'controllers': { + 'userController.js': [ size: '2KB', type: 'javascript', description: 'Handles user-related operations' ], + 'authController.js': [ size: '2KB', type: 'javascript', description: 'Handles authentication-related operations' ] + }, + 'models': { + 'user.js': [ size: '3KB', type: 'javascript', description: 'Schema and model for user' ], + 'token.js': [ size: '2KB', type: 'javascript', description: 'Schema and model for authentication tokens' ] + }, + 'routes': { + 'userRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines routes for user-related API endpoints' ], + 'authRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines routes for authentication-related API endpoints' ] + }, + 'middlewares': { + 'authMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for authentication verification' ], + 'errorMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for global error handling' ] + }, + 'utils': { + 'logger.js': [ size: '2KB', type: 'javascript', description: 'Utility for logging' ], + 'validator.js': [ size: '1KB', type: 'javascript', description: 'Utility for validation functions' ] + }, + 'app.js': [ size: '3KB', type: 'javascript', description: 'Main application entry file' ], + 'server.js': [ size: '2KB', type: 'javascript', description: 'Entry file for starting the server' ] + }, + 'tests': { + 'unit': { + 'userController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for user controller' ], + 'authController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for auth controller' ] + }, + 'integration': { + 'userRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for user routes' ], + 'authRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for auth routes' ] + } + }, + 'config': { + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration' ], + '.env': [ size: '1KB', type: 'text', description: 'Environment variables' ], + 'Dockerfile': [ size: '1KB', type: 'dockerfile', description: 'Dockerfile for building the Docker image' ], + 'docker-compose.yml': [ size: '1KB', type: 'yaml', description: 'Docker Compose file for running multi-container Docker applications' ] + }, + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide' ] +} \ No newline at end of file diff --git a/examples/templates/container-app/docker-compose.yml b/examples/templates/container-app/docker-compose.yml new file mode 100644 index 0000000..cb24c31 --- /dev/null +++ b/examples/templates/container-app/docker-compose.yml @@ -0,0 +1,22 @@ +version: '3.8' +services: + app: + build: . + ports: + - "3000:3000" + environment: + NODE_ENV: development + volumes: + - .:/usr/src/app + depends_on: + - mongo + + mongo: + image: mongo:4.2 + ports: + - "27017:27017" + volumes: + - mongo-data:/data/db + +volumes: + mongo-data: \ No newline at end of file diff --git a/examples/templates/cross-device-app.forsure b/examples/templates/cross-device-app.forsure new file mode 100644 index 0000000..1afbac5 --- /dev/null +++ b/examples/templates/cross-device-app.forsure @@ -0,0 +1,69 @@ +root: { + 'web': { + 'src': { + 'components': { + 'HelloWorld.js': [ size: '2KB', type: 'javascript', description: 'Component that displays a Hello World message' ] + }, + 'App.js': [ size: '2KB', type: 'javascript', description: 'Main application component for the web app' ], + 'index.js': [ size: '2KB', type: 'javascript', description: 'Entry point for the React web application' ], + 'App.css': [ size: '1KB', type: 'css', description: 'CSS for the main application component' ], + 'index.css': [ size: '1KB', type: 'css', description: 'CSS for the index file' ] + }, + 'public': { + 'index.html': [ size: '2KB', type: 'html', description: 'HTML template for the React web application' ], + 'favicon.ico': [ size: '1KB', type: 'icon', description: 'Favicon for the React web application' ] + }, + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration for the React web application' ], + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide for the web application' ] + }, + 'mobile': { + 'App.js': [ size: '2KB', type: 'javascript', description: 'Main application component for the mobile app' ], + 'index.js': [ size: '2KB', type: 'javascript', description: 'Entry point for the React Native application' ], + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration for the React Native application' ], + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide for the mobile application' ] + }, + 'backend': { + 'src': { + 'config': { + 'default.json': [ size: '1KB', type: 'json', description: 'Default configuration settings' ], + 'production.json': [ size: '1KB', type: 'json', description: 'Production configuration settings' ], + 'development.json': [ size: '1KB', type: 'json', description: 'Development configuration settings' ], + 'test.json': [ size: '1KB', type: 'json', description: 'Test environment configuration settings' ] + }, + 'controllers': { + 'apiController.js': [ size: '2KB', type: 'javascript', description: 'Handles API requests' ] + }, + 'models': { + 'dataModel.js': [ size: '3KB', type: 'javascript', description: 'Schema and model for data' ] + }, + 'routes': { + 'apiRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines API routes' ] + }, + 'middlewares': { + 'authMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for authentication verification' ], + 'errorMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for global error handling' ] + }, + 'utils': { + 'logger.js': [ size: '2KB', type: 'javascript', description: 'Utility for logging' ], + 'validator.js': [ size: '1KB', type: 'javascript', description: 'Utility for validation functions' ] + }, + 'app.js': [ size: '3KB', type: 'javascript', description: 'Main application entry file' ], + 'server.js': [ size: '2KB', type: 'javascript', description: 'Entry file for starting the server' ] + }, + 'tests': { + 'unit': { + 'apiController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for API controller' ] + }, + 'integration': { + 'apiRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for API routes' ] + } + }, + 'config': { + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration for the back-end' ], + '.env': [ size: '1KB', type: 'text', description: 'Environment variables' ], + 'Dockerfile': [ size: '1KB', type: 'dockerfile', description: 'Dockerfile for building the Docker image' ], + 'docker-compose.yml': [ size: '1KB', type: 'yaml', description: 'Docker Compose file for running multi-container Docker applications' ] + }, + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide for the back-end' ] + } +} \ No newline at end of file diff --git a/examples/templates/data-pipeline.forsure b/examples/templates/data-pipeline.forsure new file mode 100644 index 0000000..df9ce00 --- /dev/null +++ b/examples/templates/data-pipeline.forsure @@ -0,0 +1,14 @@ +root: { + 'etl': { + 'extract.py': [ size: '2KB', type: 'python', description: 'Data extraction script' ], + 'transform.py': [ size: '3KB', type: 'python', description: 'Data transformation script' ], + 'load.py': [ size: '2KB', type: 'python', description: 'Data loading script' ] + }, + 'configs': { + 'etl_config.yml': [ size: '1KB', type: 'yaml', description: 'ETL configuration file' ] + }, + 'logs': { + 'etl.log': [ size: '1KB', type: 'log', description: 'Log file for ETL process' ] + }, + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation' ] +} \ No newline at end of file diff --git a/examples/templates/hello-world.forsure b/examples/templates/hello-world.forsure new file mode 100644 index 0000000..54a6843 --- /dev/null +++ b/examples/templates/hello-world.forsure @@ -0,0 +1,17 @@ +root: { + 'src': { + 'components': { + 'HelloWorld.js': [ size: '2KB', type: 'javascript', description: 'Component that displays a Hello World message' ] + }, + 'App.js': [ size: '2KB', type: 'javascript', description: 'Main application component' ], + 'index.js': [ size: '2KB', type: 'javascript', description: 'Entry point for the React application' ], + 'App.css': [ size: '1KB', type: 'css', description: 'CSS for the main application component' ], + 'index.css': [ size: '1KB', type: 'css', description: 'CSS for the index file' ] + }, + 'public': { + 'index.html': [ size: '2KB', type: 'html', description: 'HTML template for the React application' ], + 'favicon.ico': [ size: '1KB', type: 'icon', description: 'Favicon for the React application' ] + }, + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration for the React application' ], + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide' ] +} \ No newline at end of file diff --git a/examples/templates/microservice.forsure b/examples/templates/microservice.forsure new file mode 100644 index 0000000..3afc200 --- /dev/null +++ b/examples/templates/microservice.forsure @@ -0,0 +1,23 @@ +root: { + 'src': { + 'controllers': { + 'UserController.js': [ size: '3KB', type: 'javascript', description: 'Handles user-related requests' ] + }, + 'models': { + 'User.js': [ size: '2KB', type: 'javascript', description: 'User model schema' ] + }, + 'routes': { + 'userRoutes.js': [ size: '2KB', type: 'javascript', description: 'User routes' ] + }, + 'middlewares': { + 'auth.js': [ size: '2KB', type: 'javascript', description: 'Authentication middleware' ] + }, + 'index.js': [ size: '2KB', type: 'javascript', description: 'Service entry point' ] + }, + 'config': { + 'default.json': [ size: '1KB', type: 'json', description: 'Default configuration' ], + 'production.json': [ size: '1KB', type: 'json', description: 'Production configuration' ] + }, + 'package.json': [ size: '1KB', type: 'json', description: 'Package configuration' ], + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation' ] +} \ No newline at end of file diff --git a/examples/templates/webapp.forsure b/examples/templates/webapp.forsure new file mode 100644 index 0000000..414a578 --- /dev/null +++ b/examples/templates/webapp.forsure @@ -0,0 +1,68 @@ +root: { + 'frontend': { + 'src': { + 'components': { + 'HelloWorld.js': [ size: '2KB', type: 'javascript', description: 'Component that displays a Hello World message' ] + }, + 'App.js': [ size: '2KB', type: 'javascript', description: 'Main application component' ], + 'index.js': [ size: '2KB', type: 'javascript', description: 'Entry point for the React application' ], + 'App.css': [ size: '1KB', type: 'css', description: 'CSS for the main application component' ], + 'index.css': [ size: '1KB', type: 'css', description: 'CSS for the index file' ] + }, + 'public': { + 'index.html': [ size: '2KB', type: 'html', description: 'HTML template for the React application' ], + 'favicon.ico': [ size: '1KB', type: 'icon', description: 'Favicon for the React application' ] + }, + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration for the React application' ], + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide' ] + }, + 'backend': { + 'src': { + 'config': { + 'default.json': [ size: '1KB', type: 'json', description: 'Default configuration settings' ], + 'production.json': [ size: '1KB', type: 'json', description: 'Production configuration settings' ], + 'development.json': [ size: '1KB', type: 'json', description: 'Development configuration settings' ], + 'test.json': [ size: '1KB', type: 'json', description: 'Test environment configuration settings' ] + }, + 'controllers': { + 'userController.js': [ size: '2KB', type: 'javascript', description: 'Handles user-related operations' ], + 'authController.js': [ size: '2KB', type: 'javascript', description: 'Handles authentication-related operations' ] + }, + 'models': { + 'user.js': [ size: '3KB', type: 'javascript', description: 'Schema and model for user' ], + 'token.js': [ size: '2KB', type: 'javascript', description: 'Schema and model for authentication tokens' ] + }, + 'routes': { + 'userRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines routes for user-related API endpoints' ], + 'authRoutes.js': [ size: '1KB', type: 'javascript', description: 'Defines routes for authentication-related API endpoints' ] + }, + 'middlewares': { + 'authMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for authentication verification' ], + 'errorMiddleware.js': [ size: '1KB', type: 'javascript', description: 'Middleware for global error handling' ] + }, + 'utils': { + 'logger.js': [ size: '2KB', type: 'javascript', description: 'Utility for logging' ], + 'validator.js': [ size: '1KB', type: 'javascript', description: 'Utility for validation functions' ] + }, + 'app.js': [ size: '3KB', type: 'javascript', description: 'Main application entry file' ], + 'server.js': [ size: '2KB', type: 'javascript', description: 'Entry file for starting the server' ] + }, + 'tests': { + 'unit': { + 'userController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for user controller' ], + 'authController.test.js': [ size: '2KB', type: 'javascript', description: 'Unit tests for auth controller' ] + }, + 'integration': { + 'userRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for user routes' ], + 'authRoutes.integration.test.js': [ size: '3KB', type: 'javascript', description: 'Integration tests for auth routes' ] + } + }, + 'config': { + 'package.json': [ size: '1KB', type: 'json', description: 'Node.js project configuration' ], + '.env': [ size: '1KB', type: 'text', description: 'Environment variables' ], + 'Dockerfile': [ size: '1KB', type: 'dockerfile', description: 'Dockerfile for building the Docker image' ], + 'docker-compose.yml': [ size: '1KB', type: 'yaml', description: 'Docker Compose file for running multi-container Docker applications' ] + }, + 'README.md': [ size: '2KB', type: 'markdown', description: 'Project documentation and setup guide' ] + } +} \ No newline at end of file diff --git a/src/stdlib/collections.rs b/src/stdlib/collections.rs index ecbab15..57e1fd2 100644 --- a/src/stdlib/collections.rs +++ b/src/stdlib/collections.rs @@ -1,19 +1,18 @@ -pub fn sum(vec: &[i32]) -> i32 { - vec.iter().sum() +pub fn find_max(list: &[T]) -> Option<&T> { + list.iter().max() } -pub fn product(vec: &[i32]) -> i32 { - vec.iter().product() +pub fn find_min(list: &[T]) -> Option<&T> { + list.iter().min() } -pub fn find_max(vec: &[i32]) -> Option { - vec.iter().copied().max() +pub fn sort_vector(list: &mut [T]) { + list.sort(); } -pub fn find_min(vec: &[i32]) -> Option { - vec.iter().copied().min() -} - -pub fn sort(vec: &mut [i32]) { - vec.sort(); +pub fn unique_elements(list: &[T]) -> Vec { + let mut unique_list = list.to_vec(); + unique_list.sort(); + unique_list.dedup(); + unique_list } \ No newline at end of file diff --git a/src/stdlib/math.rs b/src/stdlib/math.rs index f9dcc0b..ff8de06 100644 --- a/src/stdlib/math.rs +++ b/src/stdlib/math.rs @@ -1,27 +1,27 @@ -pub fn add(a: i32, b: i32) -> i32 { - a + b -} - -pub fn subtract(a: i32, b: i32) -> i32 { - a - b -} - -pub fn multiply(a: i32, b: i32) -> i32 { - a * b +pub fn mean(numbers: &[f64]) -> Option { + let sum: f64 = numbers.iter().sum(); + let count = numbers.len(); + if count > 0 { + Some(sum / count as f64) + } else { + None + } } -pub fn divide(a: i32, b: i32) -> Option { - if b != 0 { - Some(a / b) +pub fn median(numbers: &mut [f64]) -> Option { + numbers.sort_by(|a, b| a.partial_cmp(b).unwrap()); + let len = numbers.len(); + if len > 0 { + if len % 2 == 0 { + Some((numbers[len / 2 - 1] + numbers[len / 2]) / 2.0) + } else { + Some(numbers[len / 2]) + } } else { None } } -pub fn factorial(n: u32) -> u32 { +pub fn factorial(n: u64) -> u64 { (1..=n).product() -} - -pub fn power(base: i32, exp: u32) -> i32 { - (0..exp).fold(1, |acc, _| acc * base) } \ No newline at end of file diff --git a/src/stdlib/mod.rs b/src/stdlib/mod.rs index 3da8554..11c9a42 100644 --- a/src/stdlib/mod.rs +++ b/src/stdlib/mod.rs @@ -1,3 +1,7 @@ +pub mod collections; pub mod math; pub mod string; -pub mod collections; \ No newline at end of file + +pub use collections::*; +pub use math::*; +pub use string::*; \ No newline at end of file diff --git a/src/stdlib/string.rs b/src/stdlib/string.rs index a206a79..4df4676 100644 --- a/src/stdlib/string.rs +++ b/src/stdlib/string.rs @@ -6,11 +6,12 @@ pub fn to_lowercase(s: &str) -> String { s.to_lowercase() } -pub fn reverse(s: &str) -> String { +pub fn reverse_string(s: &str) -> String { s.chars().rev().collect() } pub fn is_palindrome(s: &str) -> bool { - let cleaned: String = s.chars().filter(|c| c.is_alphanumeric()).collect(); - cleaned.eq_ignore_ascii_case(&cleaned.chars().rev().collect::()) + let sanitized: String = s.chars().filter(|c| c.is_alphanumeric()).collect(); + let reversed: String = sanitized.chars().rev().collect(); + sanitized.eq_ignore_ascii_case(&reversed) } \ No newline at end of file diff --git a/src/templates/backend-forsure.forsure b/src/templates/backend-forsure.forsure deleted file mode 100644 index e69de29..0000000 diff --git a/src/templates/containerized-application.forsure b/src/templates/containerized-application.forsure deleted file mode 100644 index e69de29..0000000 diff --git a/src/templates/cross-devce-app.forsure b/src/templates/cross-devce-app.forsure deleted file mode 100644 index e69de29..0000000 diff --git a/src/templates/webapp.forsure b/src/templates/webapp.forsure deleted file mode 100644 index e69de29..0000000