cpsit / setup-helper
Helps setting up a project bundle. This is a composer plugin. It performs predefined tasks on composer after update or install command.
Installs: 2 257
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 8
Forks: 1
Open Issues: 3
Type:composer-plugin
Requires
- php: ^7.3 || ^8.0
- composer-plugin-api: ^1.1 || ^2.0
- naucon/file: ^1.0
- symfony/filesystem: ^5.0
- webmozart/glob: ^4.3
Requires (Dev)
- composer/composer: ^1.6.3 || ^2.1
- mikey179/vfsstream: ^1.6
- phpunit/phpunit: ^8.5 || ^9.5
- roave/security-advisories: dev-latest
This package is auto-updated.
Last update: 2024-10-17 18:05:49 UTC
README
Setup Helper
Helps setting up project bundles based on configuration and templates.
This is a composer plugin. It performs predefined tasks on composer after update
or install
command.
Usage
composer require cpsit/setup-helper
Configuration
Add a key setup-helper
to to the extra
section of your composer.json
.
Note: Paths must be relative to your composer root directory or absolute.
Copy files or folder
{ "extra": { "setup-helper": [ { "copy": { "path/to/file/or/folder": "path/to/target", "other/file": "other/target" } } ] } }
Unlink files or folders
{ "extra": { "setup-helper": [ { "unlink": [ "path/to/file/or/folder", "other file" ] } ] } }
- there is no confirmation request. Any existing file or folder will be removed!
Move files or folders
{ "extra": { "setup-helper": [ { "move": { "path/to/old/file/or/folder": "path/to/new/folder", "other/file": "new/path" } } ] } }
Note: Move does not rename a file or folder. If required combine it with a Rename task.
Rename files or folders
{ "extra": { "setup-helper": [ { "rename": { "path/to/old/file/or/folder": "newName", "other/file": "otherName" } } ] } }
The source path is relative to the current working directory. This should always be the composer root directory, if the Installer is called via composer plugin API as expected.
Make directory
{ "extra": { "setup-helper": [ { "makeDirectory": [ "path/to/new/folder" ] } ] } }
The directory path is relative to the current working directory. This should always be the composer root directory, if the Installer is called via composer plugin API as expected. Any missing directory will be created recursively.
Symlink from source to target
{ "extra": { "setup-helper": [ { "symlink": { "path/to/source/file": "target", "file": "even/deeper/path/to/target" } } ] } }
The source path is relative to the current working directory. This should always be the composer root directory, if the Installer is called via composer plugin API as expected. On existing source or target no symlink is created.
Replace
- Replace a string with another string:
{ "extra": { "setup-helper": [ { "replace": [ { "path": "path/to/file", "search": "string-to-replace", "replace": "replacement string" } ] } ] } }
- Replace a string with a string given as answer to a question (interactively)
{ "extra": { "setup-helper": [ { "replace": [ { "path": "path/to/file", "search": "string-or-pattern-to-replace", "ask": "Question to ask for (Answer replaces pattern)" } ] } ] } }
The path
key respects Ant-like globbing.
Syntax:
?
matches any character*
matches zero or more characters, except/
/**/
matches zero or more directory names[abc]
matches a single charactera
,b
orc
[a-c]
matches a single charactera
,b
orc
[^abc]
matches any character buta
,b
orc
[^a-c]
matches any character buta
,b
orc
{ab,cd}
matchesab
orcd
E.g. "path": /path/to/dir/*.css
will select all files ending in .css
in that directory.
See documentation of glob library for details.
Caveats
Currently we rely on a the fork cpsit/glob of webmozart/glob
since the original doesn't allow
recent PHP versions.