@sp-packages/copyrc v2.3.3
CopyRC
⨠Features
- š Copies template files to designated locations
 - š Skips existing files to prevent overwrites
 - ā” Works with any project type (WordPress, Node.js, PHP, etc.)
 - š§ Fully configurable via 
copyrc.json - š ļø Can be integrated into CI/CD, Lando, and other automation workflows
 - š Supports programmatic usage in Node.js projects
 
š¦ Installation
Global Installation (For system-wide use)
npm install -g @sp-packages/copyrcThis allows you to use copyrc globally in your terminal.
Local Installation (For project-specific use)
npm install @sp-packages/copyrc --save-devThen, run it via:
npx copyrcāļø Configuration (copyrc.json)
Running the copyrc command will allow you to automatically create the copyrc.json file. Alternatively, you can manually create a copyrc.json or .copyrc.json in your project root or a custom configuration file and pass it using the -c or --config parameter:
{
  "files": [
    { "source": "./templates/.env.template", "destination": "./public/.env" },
    {
      "source": "./templates/wp-config.php.template",
      "destination": "./public/wp-config.php"
    },
    {
      "source": "./templates/.htaccess.template",
      "destination": "./public/.htaccess"
    }
  ]
}If no --config option is provided, copyrc will look for copyrc.json or .copyrc.json in the project root by default.
š CLI Usage
Basic Usage
copyrcThis will use copyrc.json or .copyrc.json from the project root.
Custom Config File Path
copyrc -c ./custom-config.jsonConfiguration Options:
files[]ā Array of file mappingssourceā Path to the template filedestinationā Target path where the file should be copied
š Programmatic Usage (Inside Node.js)
You can also use copyrc inside your JavaScript/TypeScript projects.
Import and Run Directly
import { copyrc } from '@sp-packages/copyrc';
const config = {
  files: [
    { source: './templates/.env.template', destination: './public/.env' },
    {
      source: './templates/wp-config.php.template',
      destination: './public/wp-config.php'
    }
  ]
};
copyrc(config, true); // The second argument enables verbose loggingExample Use Case in a Node.js Script
Create a script setup.js:
import { copyrc } from '@sp-packages/copyrc';
import fs from 'fs';
const configPath = './copyrc.json';
if (fs.existsSync(configPath)) {
  const config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
  copyrc(config, false);
} else {
  console.error('ā Config file not found!');
}Then run:
node setup.jsšÆ Example Outputs
ā  [WARNING] Destination file already exists at ./public/.env. Skipping.
ā [SUCCESS] wp-config.php.template copied successfully to ./public/wp-config.php
ā [SUCCESS] All required files are copied or already exist.š” Use Cases
- WordPress Setup ā Automate 
wp-config.phpand.htaccess - Environment Files ā Ensure 
.envfiles are always present - Project Bootstrapping ā Copy necessary config files on 
composer install - CI/CD Automation ā Automate file setups during deployments
 
1ļøā£ Automating Lando Post-Start Hook
If you're using Lando, you can automatically run copyrc after lando start:
services:
  appserver:
    run_as_root:
      - copyrc2ļøā£ CI/CD Integration
Run it in GitHub Actions, GitLab CI/CD, or other automation scripts:
jobs:
  setup:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Code
        uses: actions/checkout@v3
      - name: Install Dependencies
        run: npm ci
      - name: Install Copyrc
        run: npm install -g @sp-packages/copyrc
      - name: Run Copyrc
        run: copyrcš¤ Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
š License
This project is licensed under the MIT License. See the LICENSE file for details.