Create your project files faster using this CLI. You can create file templates and, with one command, create copies of your templates in the folder you want.
-
✅ Faster and easier than code snippets -
✅ You can add the template files in the version control system -
✅ Rename template files and folders -
✅ Replace text inside your template files -
✅ Use this library in JavaScript code
⚡ Installation
Installing Globally
yarn global add create-project-files-cli
npm i -g create-project-files-cli
Installing as Dev Dependency
yarn add -D create-project-files-cli
npm i -D create-project-files-cli
👉 Getting Started
Follow the steps below to learn how to use this library.
- Create a folder called
__file-templates__
in the root folder of your project. - Create a file called
test.txt
in the__file-templates__
folder. - Open a terminal and type
cpf create text.txt .
- Now you should see a file called
text.txt
in your root folder.
📄 Documentation
-
🔵 cpf create <source> <destination> [options]
Creates a file or folder based on the <source> at <destination>
.
Option | Description | Example |
---|---|---|
-n, --name <name>
|
Changes the name of a file or folder. | cpf create text.txt src -n newName.txt |
-t, --templates-folder <path>
|
Path to templates folder. | cpf create text.txt src -t my-templates |
-e, --encoding <encoding>
|
Changes the content encoding of the read files. | cpf create text.txt src -e base64 |
-rn, --replace-names <names...>
|
Replaces the names of a file or folder. | cpf create [fileName].txt src -rn fileName=myFile |
-nb, --no-brackets | Makes brackets not required when using the --replace-names option. | cpf create fileName.txt src -rn fileName=otherFile -nb |
-rc, --replace-content <content...>
|
Replaces parts of the contents of a file or files within a folder. | cpf create text.txt src -rc file=myFile |
-kvs, --key-value-separator <separator>
|
Defines a custom key-value separator for the --replace-names and --replace-content options. | cpf create [fileName].txt src -rn fileName@myFile -kvs "@" |
-
🔵 cpf help [command]
Display the help for a command or all commands.
💻 Using in Code
You can use the library in code if your using the version 1.1.0 or greater. You can install as dev dependency, create a javascript file, and do something like the example below:
const { CreateCommand } = require('create-project-files-cli')
const command = new CreateCommand('text.txt', '.', {
// Options ...
})
const results = command.run()
console.log(results)
⌛ Coming Soon
- Support for multiple template folders.
- Create multiple files and folders with only one command.
- Ignore case when replacing the content of a file.
- Set an alias to a file or folder inside the templates folder.
- Config file to simplify the use of this library.
- --silent option to run the CLI silently.
- Add uuid or timestamp to file names.
- Create destination folder if not exists.
- --force option to delete existing files and folders to create the new ones.
🤝 Contributing
- If you find a bug or have a good idea
🔹 Create a new issue - If you want to contribute with code or documentation
🔹 Read the contributing guide
👨 Author
Created with