An open API service indexing awesome lists of open source software.

https://github.com/aniftyco/skeletor

Summon Skeletor's minion: a Composer companion to unleash extra functionality with every `create-project` command.
https://github.com/aniftyco/skeletor

Last synced: 2 months ago
JSON representation

Summon Skeletor's minion: a Composer companion to unleash extra functionality with every `create-project` command.

Awesome Lists containing this project

README

        

# Skeletor

> Summon Skeletor's minion: a Composer companion to unleash extra functionality with every `create-project` command.

## Installation

```sh
composer install --dev aniftyco/skeletor
```

## Usage

Make sure the following is set in the `scripts` section of `composer.json`:

```json
"post-create-project-cmd": [
"NiftyCo\\Skeletor\\Runner::execute"
],
```

Then just create a `Skeletorfile.php` in the root with this:

```php
workspace
```

### Gathering User Input

#### Text Input

```php
$skeletor->text('Enter your name:', 'John Doe');
```

#### Textarea Input

```php
$skeletor->textarea('Enter a description:');
```

#### Password Input

```php
$skeletor->password('Enter your password:');
```

#### Confirm

```php
$skeletor->confirm('Do you agree?', true);
```

#### Select

```php
$skeletor->select('Choose an option:', ['Option 1', 'Option 2', 'Option 3']);
```

#### Multiselect

```php
$skeletor->multiselect('Choose multiple options:', ['Option 1', 'Option 2', 'Option 3']);
```

#### Suggest

```php
$skeletor->suggest('Start typing:', ['Suggestion 1', 'Suggestion 2', 'Suggestion 3']);
```

#### Search

```php
$skeletor->search('Search for an option:', function ($query) {
return ['Result 1', 'Result 2', 'Result 3'];
});
```

#### Multisearch

```php
$skeletor->multisearch('Search for multiple options:', function ($query) {
return ['Result 1', 'Result 2', 'Result 3'];
});
```

### Displaying Information

#### Spinner

```php
$skeletor->spin('Processing...', function () {
// long running task
return true;
});
```

#### Progress Bar

```php
$skeletor->progress('Processing items...', 100, function ($progress) {
for ($i = 0; $i < 100; $i++) {
$progress->advance();
}
});
```

#### Messages

```php
$skeletor->info('This is an info message.');

$skeletor->alert('This is an alert message.');

$skeletor->warning('This is a warning message.');

$skeletor->error('This is an error message.');

$skeletor->intro('Welcome to the setup wizard.');

$skeletor->outro('Setup complete.');
```

### File Operations

#### Reading a File

```php
$skeletor->readFile('path/to/file.txt');
```

#### Writing to a File

```php
$skeletor->writeFile('path/to/file.txt', 'New content');
```

#### Removing a File

```php
$skeletor->removeFile('path/to/file.txt');
```

#### Removing a Directory

```php
$skeletor->removeDirectory('path/to/directory');
```

#### Checking if a File Exists

```php
$skeletor->exists('path/to/file.txt');
```

#### Updating composer.json

```php
$skeletor->updateComposerJson(['require' => ['new/package' => '^1.0']]);
```

#### Executing a Command

```php
$skeletor->exec(['ls', '-la']);
```

#### Table

```php
$skeletor->table(['Header 1', 'Header 2'], [['Row 1 Col 1', 'Row 1 Col 2'], ['Row 2 Col 1', 'Row 2 Col 2']]);
```

#### Pause

```php
$skeletor->pause(5);
```

#### Replace In File

```php
$skeletor->replaceInFile( 'search string', 'replace string', 'path/to/file.txt')
```

#### Preg Replace In File

```php
$skeletor->pregReplaceInFile('/pattern/', 'replace string', 'path/to/file.txt');
```

### Post-Cleanup Hook

If you return a function from your `SkeletorFile.php` function, Skeletor will execute it after running its cleanup phase to do any additional cleanup or actions you deem necessary. For example:

```php

return function (Skeletor $skeletor) {
// ...

return function() use ($skeletor) {
$skeletor->exec(['git', 'init']);
$skeletor->exec(['git', 'commit', '-am', '"initial commit"']);
};
};
```