Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
Added Repository Support
Browse files Browse the repository at this point in the history
  • Loading branch information
RhysLees committed Jun 21, 2022
1 parent 3513da4 commit 8ffc20c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,56 @@ Leaving this option as an empty string will use the current directory.

---

## Repositories

If you need to require a private package, first add the package to the `packages->composer` array. You can add the repository to the `repositories` array.

> NOTE: currently only suppor
```json
"repositories": [
{
"key": "",
"name": "",
"type": "",
"url": ""
}
],
```

`key` must match the package key.
`name` is the name of the package (see example below).
`type` is the type of repository.
`url` is the url of the repository.

With VCS:
```json
"repositories": [
{
"key": "spatie-laravel-ray",
"name": "laravel-ray",
"type": "vcs",
"url": "https://github.com/spatie/laravel-ray"
}
],
```

With Path (symlink):
```json
"repositories": [
{
"key": "spatie-laravel-ray",
"name": "laravel-ray",
"type": "path",
"url": "../../Packages/spatie/laravel-ray"
}
],
```

> NOTE: when using path ensure the url is relative to your project directory.
---

## Commands
- The commands are executed in the order you specify.
- You can execute commands with composer and npm.
Expand Down
24 changes: 24 additions & 0 deletions app/Commands/NewCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class NewCommand extends Command

public $name;
public $config;
public $packages;
public $laravelOptions;
public $installLocation;
public $applicationLocation;
Expand Down Expand Up @@ -95,6 +96,8 @@ public function handle()
|___/ |___/
" . PHP_EOL . PHP_EOL);

$this->installRepositories();

$this->installPackages('composer');
$this->installPackages('npm');

Expand Down Expand Up @@ -143,6 +146,27 @@ public function installPackages($manager)
}
}

/**
* Install Repositories.
*
*
* @return void
*/
public function installRepositories()
{
if (count($this->packages['repositories']) > 0) {
$this->info("Installing package repositories...");
$this->packages['repositories']->each(function ($repo) {
$name = $this->packages['composer']->firstWhere('key', $this->packages['repositories']->first()['key'])['name'];
$this->task("Install {$name} Repository", function () use ($repo) {
$this->executeCommand('composer config repositories.' . $repo['name'] . ' ' . $repo['type'] . ' ' . $repo['url']);

return true;
});
});
}
}

/**
* Run Commands.
*
Expand Down
5 changes: 5 additions & 0 deletions app/Traits/Packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ public function collectPackages()
{
$this->info('Collecting packages...');

// Get composer repositories.
$repositories = Collection::wrap($this->config['repositories'])
->whereInStrict('key', $this->config['packages-to-install']['composer']);

// Get composer packages.
$packagesComposer = Collection::wrap($this->config['packages']['composer'])
->whereInStrict('key', $this->config['packages-to-install']['composer']);
Expand All @@ -34,6 +38,7 @@ public function collectPackages()
}

$this->packages = Collection::wrap([
'repositories' => $repositories,
'composer' => $packagesComposer,
'npm' => $packagesNpm,
]);
Expand Down
Binary file modified builds/laravel-installer-plus
Binary file not shown.

0 comments on commit 8ffc20c

Please sign in to comment.