### LFify Configuration: .lfifyrc.json Setup Source: https://context7.com/gyeonghokim/lfify/llms.txt Provides an example of a `.lfifyrc.json` file used for persistent configuration. This file defines default `entry`, `include`, and `exclude` patterns for LFify's file processing. ```json { "entry": "./", "include": [ "**/*.{js,ts,jsx,tsx}", "**/*.{json,md}", "**/*.{css,scss}", "**/*.{html,vue}" ], "exclude": [ "node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**" ] } ``` -------------------------------- ### LFify CLI Usage Source: https://context7.com/gyeonghokim/lfify/llms.txt Examples of how to use the LFify command-line interface with various options and glob patterns. ```APIDOC ## LFify CLI Usage ### Basic Command Execution Run lfify using npx with glob patterns to specify which files to process and which to exclude. ```bash # Process all JavaScript files, exclude node_modules npx lfify --include "**/*.js" --exclude "node_modules/**" # Process multiple file types npx lfify --include "**/*.js" --include "**/*.ts" --exclude "node_modules/**" --exclude ".git/**" # Process files in a specific directory npx lfify --entry ./src --include "**/*.js" # Use a custom config file npx lfify --config ./custom-config.json # Run with defaults (processes all files except node_modules, .git, dist, build, coverage) npx lfify ``` ### CLI Options #### `--config` Specify a custom path for the configuration file instead of the default `.lfifyrc.json`. ```bash # Use configuration from a custom location npx lfify --config ./configs/lfify-production.json # Use configuration from parent directory npx lfify --config ../shared/.lfifyrc.json ``` #### `--entry` Specify the entry directory to begin processing files. All file matching is relative to this directory. ```bash # Process only the src directory npx lfify --entry ./src --include "**/*.js" # Process a nested directory npx lfify --entry ./packages/core --include "**/*.ts" --exclude "**/*.test.ts" ``` #### `--include` Define glob patterns for files to include in processing. Can be used multiple times to specify multiple patterns. ```bash # Include only JavaScript files npx lfify --include "**/*.js" # Include multiple file types npx lfify --include "**/*.js" --include "**/*.ts" --include "**/*.json" # Include files with brace expansion npx lfify --include "**/*.{js,ts,jsx,tsx}" ``` #### `--exclude` Define glob patterns for files to exclude from processing. Can be used multiple times to specify multiple patterns. ```bash # Exclude node_modules npx lfify --include "**/*.js" --exclude "node_modules/**" # Exclude multiple directories npx lfify --include "**/*" --exclude "node_modules/**" --exclude ".git/**" --exclude "dist/**" # Exclude test files npx lfify --include "**/*.js" --exclude "**/*.test.js" --exclude "**/*.spec.js" ``` ``` -------------------------------- ### LFify CLI: --entry Option Usage Source: https://context7.com/gyeonghokim/lfify/llms.txt Shows how to use the `--entry` CLI option to define the starting directory for file processing. All subsequent file matching is relative to this specified entry point. ```bash # Process only the src directory npx lfify --entry ./src --include "**/*.js" # Process a nested directory npx lfify --entry ./packages/core --include "**/*.ts" --exclude "**/*.test.ts" ``` -------------------------------- ### LFify CLI: Basic Command Execution with Glob Patterns Source: https://context7.com/gyeonghokim/lfify/llms.txt Demonstrates basic command-line usage of LFify using npx. It shows how to specify files for processing and exclusion using glob patterns, including handling multiple file types and specific directories. ```bash # Process all JavaScript files, exclude node_modules npx lfify --include "**/*.js" --exclude "node_modules/**" # Process multiple file types npx lfify --include "**/*.js" --include "**/*.ts" --exclude "node_modules/**" --exclude ".git/**" # Process files in a specific directory npx lfify --entry ./src --include "**/*.js" # Use a custom config file npx lfify --config ./custom-config.json # Run with defaults (processes all files except node_modules, .git, dist, build, coverage) npx lfify ``` -------------------------------- ### Read Configuration File (JavaScript) Source: https://context7.com/gyeonghokim/lfify/llms.txt Reads and validates a configuration file from a specified path. Returns a promise that resolves to a validated configuration object. Dependencies: 'lfify'. ```javascript const { readConfig } = require('lfify'); // Read configuration from default location readConfig('.lfifyrc.json') .then((config) => { console.log('Entry:', config.entry); console.log('Include patterns:', config.include); console.log('Exclude patterns:', config.exclude); }) .catch((err) => { console.error('Failed to read config:', err.message); }); // Read from custom location const config = await readConfig('./configs/custom-lfify.json'); ``` -------------------------------- ### parseArgs() Source: https://context7.com/gyeonghokim/lfify/llms.txt Parses command-line arguments and returns an options object. Supports `--config`, `--entry`, `--include`, and `--exclude` flags. ```APIDOC ## parseArgs() ### Description Parses command-line arguments and returns an options object. Supports `--config`, `--entry`, `--include`, and `--exclude` flags. ### Method `sync` ### Endpoint N/A (Function) ### Parameters None ### Request Example ```javascript const { parseArgs } = require('lfify'); // When called with: node script.js --include "**/*.js" --exclude "node_modules/**" const options1 = parseArgs(); // Returns: { configPath: '.lfifyrc.json', include: ['**/*.js'], exclude: ['node_modules/**'] } // When called with: node script.js --entry ./src --config custom.json const options2 = parseArgs(); // Returns: { configPath: 'custom.json', entry: './src' } ``` ### Response #### Success Response (object) - **configPath** (string) - Optional - Path to a configuration file. - **entry** (string) - Optional - The entry point for processing. - **include** (array of strings) - Optional - Patterns for files to include. - **exclude** (array of strings) - Optional - Patterns for files to exclude. #### Response Example ```json { "configPath": ".lfifyrc.json", "include": [ "**/*.js" ], "exclude": [ "node_modules/**" ] } ``` ``` -------------------------------- ### LFify Programmatic API Source: https://context7.com/gyeonghokim/lfify/llms.txt Documentation for the programmatic API of LFify, including functions for directory-wide and single-file conversions. ```APIDOC ## Programmatic API ### `convertCRLFtoLF(dirPath, config)` Recursively traverses a directory and converts CRLF line endings to LF in all matching files based on the provided configuration. #### Parameters ##### Path Parameters - **dirPath** (string) - Required - The root directory path to start the conversion from. ##### Request Body - **config** (object) - Optional - Configuration object for the conversion process. - **entry** (string) - Optional - The entry directory relative to `dirPath`. - **include** (array of strings) - Optional - Glob patterns for files to include. - **exclude** (array of strings) - Optional - Glob patterns for files to exclude. ### Request Example ```javascript const { convertCRLFtoLF } = require('lfify'); const config = { entry: '/path/to/project', include: ['**/*.js', '**/*.ts'], exclude: ['node_modules/**', 'dist/**'] }; // Convert all matching files in the directory convertCRLFtoLF('/path/to/project', config) .then(() => { console.log('Conversion completed successfully'); }) .catch((err) => { console.error('Conversion failed:', err.message); }); ``` ### `processFile(filePath)` Processes a single file, converting any CRLF line endings to LF. The file is only written if changes are detected. #### Parameters ##### Path Parameters - **filePath** (string) - Required - The path to the file to process. ### Request Example ```javascript const { processFile } = require('lfify'); // Process a single file processFile('./src/index.js') .then(() => { console.log('File processed successfully'); }) .catch((err) => { console.error('Error processing file:', err.message); }); // Process multiple files sequentially const files = ['./src/app.js', './src/utils.js', './config.json']; for (const file of files) { await processFile(file); } ``` ``` -------------------------------- ### LFify CLI: --include Option Usage Source: https://context7.com/gyeonghokim/lfify/llms.txt Demonstrates the use of the `--include` CLI option to specify glob patterns for files that should be processed. This option can be used multiple times to include various file types or patterns. ```bash # Include only JavaScript files npx lfify --include "**/*.js" # Include multiple file types npx lfify --include "**/*.js" --include "**/*.ts" --include "**/*.json" # Include files with brace expansion npx lfify --include "**/*.{js,ts,jsx,tsx}" ``` -------------------------------- ### readConfig(configPath) Source: https://context7.com/gyeonghokim/lfify/llms.txt Reads and validates a configuration file from the specified path. Returns a promise that resolves to a validated configuration object. ```APIDOC ## readConfig(configPath) ### Description Reads and validates a configuration file from the specified path. Returns a promise that resolves to a validated configuration object. ### Method `async` ### Endpoint N/A (Function) ### Parameters #### Path Parameters - **configPath** (string) - Required - The path to the configuration file. ### Request Example ```javascript const { readConfig } = require('lfify'); // Read configuration from default location readConfig('.lfifyrc.json') .then((config) => { console.log('Entry:', config.entry); console.log('Include patterns:', config.include); console.log('Exclude patterns:', config.exclude); }) .catch((err) => { console.error('Failed to read config:', err.message); }); // Read from custom location (using await) // const config = await readConfig('./configs/custom-lfify.json'); ``` ### Response #### Success Response (object) - **entry** (string) - The entry point for processing. - **include** (array of strings) - Patterns for files to include. - **exclude** (array of strings) - Patterns for files to exclude. #### Response Example ```json { "entry": "./src", "include": ["**/*.js"], "exclude": ["node_modules/**"] } ``` ``` -------------------------------- ### Parse Command-Line Arguments (JavaScript) Source: https://context7.com/gyeonghokim/lfify/llms.txt Parses command-line arguments and returns an options object. Supports `--config`, `--entry`, `--include`, and `--exclude` flags. Dependencies: 'lfify'. ```javascript const { parseArgs } = require('lfify'); // When called with: node script.js --include "**/*.js" --exclude "node_modules/**" const options = parseArgs(); // Returns: { configPath: '.lfifyrc.json', include: ['**/*.js'], exclude: ['node_modules/**'] } // When called with: node script.js --entry ./src --config custom.json const options2 = parseArgs(); // Returns: { configPath: 'custom.json', entry: './src' } ``` -------------------------------- ### SENSIBLE_DEFAULTS Source: https://context7.com/gyeonghokim/lfify/llms.txt The default configuration object used when no config file is found and no CLI options are provided. ```APIDOC ## SENSIBLE_DEFAULTS ### Description The default configuration object used when no config file is found and no CLI options are provided. ### Method Constant ### Endpoint N/A (Constant) ### Parameters None ### Request Example ```javascript const { SENSIBLE_DEFAULTS } = require('lfify'); console.log(SENSIBLE_DEFAULTS); ``` ### Response #### Success Response (object) - **entry** (string) - The default entry point. - **include** (array of strings) - The default include patterns. - **exclude** (array of strings) - The default exclude patterns. #### Response Example ```json { "entry": "./", "include": ["**/*"], "exclude": [ "node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**" ] } ``` ``` -------------------------------- ### resolveConfig(cliOptions) Source: https://context7.com/gyeonghokim/lfify/llms.txt Resolves the final configuration by merging CLI options, config file values, and defaults. CLI options take highest precedence, followed by config file values, then sensible defaults. ```APIDOC ## resolveConfig(cliOptions) ### Description Resolves the final configuration by merging CLI options, config file values, and defaults. CLI options take highest precedence, followed by config file values, then sensible defaults. ### Method `async` ### Endpoint N/A (Function) ### Parameters #### Path Parameters - **cliOptions** (object) - Optional - An object containing CLI options to merge. - **configPath** (string) - Optional - Path to a configuration file. - **entry** (string) - Optional - The entry point for processing. - **include** (array of strings) - Optional - Patterns for files to include. - **exclude** (array of strings) - Optional - Patterns for files to exclude. ### Request Example ```javascript const { resolveConfig } = require('lfify'); // Resolve with CLI options only const config1 = await resolveConfig({ include: ['**/*.js'], exclude: ['node_modules/**'], entry: './src' }); // Resolve with config file path const config2 = await resolveConfig({ configPath: '.lfifyrc.json' }); // Resolve with CLI overrides on top of config file const config3 = await resolveConfig({ configPath: '.lfifyrc.json', include: ['**/*.ts'], // Overrides config file include entry: './packages' // Overrides config file entry }); // Resolve with empty options (uses sensible defaults) const config4 = await resolveConfig({}); // Results in: { include: ['**/*'], exclude: ['node_modules/**', '.git/**', 'dist/**', 'build/**', 'coverage/**'] } ``` ### Response #### Success Response (object) - **entry** (string) - The entry point for processing. - **include** (array of strings) - Patterns for files to include. - **exclude** (array of strings) - Patterns for files to exclude. #### Response Example ```json { "entry": "./", "include": ["**/*"], "exclude": [ "node_modules/**", ".git/**", "dist/**", "build/**", "coverage/**" ] } ``` ``` -------------------------------- ### LFify CLI: --config Option Usage Source: https://context7.com/gyeonghokim/lfify/llms.txt Illustrates how to use the `--config` CLI option to specify a custom path for the LFify configuration file, overriding the default `.lfifyrc.json`. ```bash # Use configuration from a custom location npx lfify --config ./configs/lfify-production.json # Use configuration from parent directory npx lfify --config ../shared/.lfifyrc.json ``` -------------------------------- ### shouldProcessFile(filePath, config) Source: https://context7.com/gyeonghokim/lfify/llms.txt Determines if a file should be processed based on include and exclude patterns in the configuration. Returns true if the file matches an include pattern and does not match any exclude pattern. ```APIDOC ## shouldProcessFile(filePath, config) ### Description Determines whether a file should be processed based on the include and exclude patterns in the configuration. Returns true if the file matches an include pattern and does not match any exclude pattern. ### Parameters #### Path Parameters - **filePath** (string) - Required - The path to the file to check. - **config** (object) - Required - The configuration object containing `include` and `exclude` patterns. - **include** (array of strings) - Required - An array of glob patterns for files to include. - **exclude** (array of strings) - Required - An array of glob patterns for files to exclude. ### Request Example ```javascript const { shouldProcessFile } = require('lfify'); const config = { include: ['**/*.js', '**/*.ts'], exclude: ['node_modules/**', '**/*.test.js'] }; console.log(shouldProcessFile('src/index.js', config)); console.log(shouldProcessFile('src/index.test.js', config)); console.log(shouldProcessFile('node_modules/lodash/index.js', config)); console.log(shouldProcessFile('src/utils.ts', config)); console.log(shouldProcessFile('README.md', config)); ``` ### Response #### Success Response (boolean) - **true**: The file should be processed. - **false**: The file should not be processed. #### Response Example ```javascript // For 'src/index.js' with the example config: true ``` ``` -------------------------------- ### Resolve Configuration Object (JavaScript) Source: https://context7.com/gyeonghokim/lfify/llms.txt Resolves the final configuration by merging CLI options, config file values, and defaults. CLI options have the highest precedence, followed by config file values, then sensible defaults. Dependencies: 'lfify'. ```javascript const { resolveConfig } = require('lfify'); // Resolve with CLI options only const config1 = await resolveConfig({ include: ['**/*.js'], exclude: ['node_modules/**'], entry: './src' }); // Resolve with config file path const config2 = await resolveConfig({ configPath: '.lfifyrc.json' }); // Resolve with CLI overrides on top of config file const config3 = await resolveConfig({ configPath: '.lfifyrc.json', include: ['**/*.ts'], // Overrides config file include entry: './packages' // Overrides config file entry }); // Resolve with empty options (uses sensible defaults) const config4 = await resolveConfig({}); // Results in: { include: ['**/*'], exclude: ['node_modules/**', '.git/**', 'dist/**', 'build/**', 'coverage/**'] } ``` -------------------------------- ### Default Configuration Object (JavaScript) Source: https://context7.com/gyeonghokim/lfify/llms.txt The default configuration object used when no config file is found and no CLI options are provided. Accessible via SENSIBLE_DEFAULTS from 'lfify'. ```javascript const { SENSIBLE_DEFAULTS } = require('lfify'); console.log(SENSIBLE_DEFAULTS); // Output: // { // entry: './', // include: ['**/*'], // exclude: [ // 'node_modules/**', // '.git/**', // 'dist/**', // 'build/**', // 'coverage/**' // ] // } ``` -------------------------------- ### LFify CLI: --exclude Option Usage Source: https://context7.com/gyeonghokim/lfify/llms.txt Explains how to use the `--exclude` CLI option to define glob patterns for files or directories that should be ignored during processing. Multiple exclude patterns can be specified. ```bash # Exclude node_modules npx lfify --include "**/*.js" --exclude "node_modules/**" # Exclude multiple directories npx lfify --include "**/*" --exclude "node_modules/**" --exclude ".git/**" --exclude "dist/**" # Exclude test files npx lfify --include "**/*.js" --exclude "**/*.test.js" --exclude "**/*.spec.js" ``` -------------------------------- ### LFify Programmatic API: convertCRLFtoLF Function Source: https://context7.com/gyeonghokim/lfify/llms.txt Shows how to use the `convertCRLFtoLF` function from the LFify programmatic API. This function recursively processes files in a given directory based on provided configuration, converting CRLF to LF line endings. ```javascript const { convertCRLFtoLF } = require('lfify'); const config = { entry: '/path/to/project', include: ['**/*.js', '**/*.ts'], exclude: ['node_modules/**', 'dist/**'] }; // Convert all matching files in the directory convertCRLFtoLF('/path/to/project', config) .then(() => { console.log('Conversion completed successfully'); }) .catch((err) => { console.error('Conversion failed:', err.message); }); ``` -------------------------------- ### Determine if File Should Be Processed (JavaScript) Source: https://context7.com/gyeonghokim/lfify/llms.txt Checks if a file should be processed based on include and exclude patterns in the configuration. Returns true if the file matches an include pattern and does not match any exclude pattern. Dependencies: 'lfify'. ```javascript const { shouldProcessFile } = require('lfify'); const config = { include: ['**/*.js', '**/*.ts'], exclude: ['node_modules/**', '**/*.test.js'] }; // Check if files should be processed console.log(shouldProcessFile('src/index.js', config)); // true console.log(shouldProcessFile('src/index.test.js', config)); // false console.log(shouldProcessFile('node_modules/lodash/index.js', config)); // false console.log(shouldProcessFile('src/utils.ts', config)); // true console.log(shouldProcessFile('README.md', config)); // false ``` -------------------------------- ### LFify Programmatic API: processFile Function Source: https://context7.com/gyeonghokim/lfify/llms.txt Demonstrates the usage of the `processFile` function from the LFify programmatic API. This function converts CRLF line endings to LF for a single specified file, writing changes only if detected. ```javascript const { processFile } = require('lfify'); // Process a single file processFile('./src/index.js') .then(() => { console.log('File processed successfully'); }) .catch((err) => { console.error('Error processing file:', err.message); }); // Process multiple files sequentially const files = ['./src/app.js', './src/utils.js', './config.json']; for (const file of files) { await processFile(file); } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.