mirror of
https://github.com/bitinflow/bunny-cli.git
synced 2026-03-13 13:45:54 +00:00
Fix init for windows
This commit is contained in:
@@ -59,7 +59,7 @@ With the `bunny deploy` command, you can easily synchronize your `dist` folder w
|
|||||||
- CDN diffing files...
|
- CDN diffing files...
|
||||||
✔ CDN requesting 10875 files
|
✔ CDN requesting 10875 files
|
||||||
- Synchronizing 10875 files
|
- Synchronizing 10875 files
|
||||||
10875/10875 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%
|
10875/10875 [============================] 100%
|
||||||
✔ Finished synchronizing 10875 files
|
✔ Finished synchronizing 10875 files
|
||||||
- Waiting for deploy to go live...
|
- Waiting for deploy to go live...
|
||||||
✔ Deployment is live! (322.96s)
|
✔ Deployment is live! (322.96s)
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class Client
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->client = new \GuzzleHttp\Client([
|
$this->client = new \GuzzleHttp\Client([
|
||||||
|
'http_errors' => false,
|
||||||
'base_uri' => 'https://api.bunny.net/',
|
'base_uri' => 'https://api.bunny.net/',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class EdgeStorageCache
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws FilesystemException
|
* @throws FilesystemException
|
||||||
|
* @throws LockException
|
||||||
*/
|
*/
|
||||||
public function parse(string $path): array
|
public function parse(string $path): array
|
||||||
{
|
{
|
||||||
@@ -28,8 +29,6 @@ class EdgeStorageCache
|
|||||||
File::EMPTY_SHA256,
|
File::EMPTY_SHA256,
|
||||||
));
|
));
|
||||||
|
|
||||||
file_put_contents(base_path(sprintf('%s.bk', basename($this->filename))), $contents);
|
|
||||||
|
|
||||||
return $this->extract($contents);
|
return $this->extract($contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,8 +38,6 @@ class EdgeStorageCache
|
|||||||
$contents = $this->hydrate($files, $local, $edge);
|
$contents = $this->hydrate($files, $local, $edge);
|
||||||
$checksum = strtoupper(hash('sha256', $contents));
|
$checksum = strtoupper(hash('sha256', $contents));
|
||||||
|
|
||||||
file_put_contents(base_path(sprintf('%s', basename($this->filename))), $contents);
|
|
||||||
|
|
||||||
$promise = $this->edgeStorage->put(new LocalFile($filename, $checksum, $contents));
|
$promise = $this->edgeStorage->put(new LocalFile($filename, $checksum, $contents));
|
||||||
|
|
||||||
/** @var ResponseInterface $response */
|
/** @var ResponseInterface $response */
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ class FileCompare
|
|||||||
|
|
||||||
$this->command->info('- Waiting for deploy to go live...');
|
$this->command->info('- Waiting for deploy to go live...');
|
||||||
|
|
||||||
if (!$options[CompareOptions::DRY_RUN]) {
|
if (!$options[CompareOptions::DRY_RUN] && $pullZoneId) {
|
||||||
$flushResult = $this->apiClient->purgeCache($pullZoneId);
|
$flushResult = $this->apiClient->purgeCache($pullZoneId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,38 +46,65 @@ class InitCommand extends Command
|
|||||||
$env = [];
|
$env = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
$env['BUNNY_API_ACCESS_KEY'] = $this->ask(
|
$this->newLine();
|
||||||
'What is your api key?',
|
|
||||||
$this->option('api-key') ?? $env['BUNNY_API_ACCESS_KEY'] ?? null
|
|
||||||
);
|
|
||||||
|
|
||||||
config()->set('bunny.api.access_key', $env['BUNNY_API_ACCESS_KEY']);
|
$this->info('In order for the Bunny CLI to work properly you need to store your Bunny CDN API token.');
|
||||||
|
$this->info('You can find your API Token in your Account Settings (https://panel.bunny.net/account).');
|
||||||
|
|
||||||
$storageZones = new Collection($client->getStorageZones()->getData());
|
do {
|
||||||
|
$env['BUNNY_API_ACCESS_KEY'] = $this->ask(
|
||||||
|
'What is your API Token?',
|
||||||
|
$this->option('api-key') ?? $env['BUNNY_API_ACCESS_KEY'] ?? null
|
||||||
|
);
|
||||||
|
|
||||||
|
config()->set('bunny.api.access_key', $env['BUNNY_API_ACCESS_KEY']);
|
||||||
|
|
||||||
|
$result = $client->getStorageZones();
|
||||||
|
|
||||||
|
if (!$result->success()) {
|
||||||
|
$this->warn('Your API Token is invalid. Please try again.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$storageZones = new Collection($result->getData());
|
||||||
|
} while (!$result->success() || $storageZones->isEmpty());
|
||||||
|
|
||||||
if (!$this->option('no-interaction')) {
|
if (!$this->option('no-interaction')) {
|
||||||
|
$this->info('Please select your default storage zone below. This is used for the deploy command.');
|
||||||
|
|
||||||
|
$this->newLine();
|
||||||
|
|
||||||
$storageZones->each(fn($item) => $this->info(sprintf(' - %s', $item->Name)));
|
$storageZones->each(fn($item) => $this->info(sprintf(' - %s', $item->Name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
$storageZoneName = $this->anticipate(
|
do {
|
||||||
'Which storage zone do you want to use?',
|
$storageZoneName = $this->anticipate(
|
||||||
function ($input) use ($storageZones) {
|
'Which storage zone do you want to use?',
|
||||||
return $storageZones->filter(function ($item) use ($input) {
|
function ($input) use ($storageZones) {
|
||||||
// replace stristr with your choice of matching function
|
return $storageZones->filter(function ($item) use ($input) {
|
||||||
return false !== stristr($item->Name, $input);
|
// replace stristr with your choice of matching function
|
||||||
})->pluck('Name')->toArray();
|
return false !== stristr($item->Name, $input);
|
||||||
},
|
})->pluck('Name')->toArray();
|
||||||
$this->option('storage-zone')
|
},
|
||||||
);
|
$this->option('storage-zone') ?? $env['BUNNY_STORAGE_USERNAME'] ?? null
|
||||||
|
);
|
||||||
|
|
||||||
$storageZone = $storageZones->where('Name', '===', $storageZoneName)->first();
|
$storageZone = $storageZones->where('Name', '===', $storageZoneName)->first();
|
||||||
|
|
||||||
$env['BUNNY_STORAGE_USERNAME'] = $storageZone->Name;
|
if (!$storageZone) {
|
||||||
$env['BUNNY_STORAGE_PASSWORD'] = $storageZone->Password;
|
$this->warn(sprintf('Cannot find storage zone by `%s`. Please check your spelling.', $storageZoneName));
|
||||||
|
} else {
|
||||||
|
$env['BUNNY_STORAGE_USERNAME'] = $storageZone->Name;
|
||||||
|
$env['BUNNY_STORAGE_PASSWORD'] = $storageZone->Password;
|
||||||
|
}
|
||||||
|
} while ($storageZone === null);
|
||||||
|
|
||||||
$pullZones = new Collection($storageZone->PullZones);
|
$pullZones = new Collection($storageZone->PullZones);
|
||||||
|
|
||||||
if (!$this->option('no-interaction')) {
|
if (!$this->option('no-interaction')) {
|
||||||
|
$this->info('Now select your pull zone whose cache you want to flush when the deploy is complete.');
|
||||||
|
|
||||||
|
$this->newLine();
|
||||||
|
|
||||||
$pullZones->each(fn($item) => $this->info(sprintf(' - %s', $item->Name)));
|
$pullZones->each(fn($item) => $this->info(sprintf(' - %s', $item->Name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +131,15 @@ class InitCommand extends Command
|
|||||||
|
|
||||||
Storage::put('.env', EnvSetCommand::updateEnv($env));
|
Storage::put('.env', EnvSetCommand::updateEnv($env));
|
||||||
|
|
||||||
$this->info('The environment file was successfully updated.');
|
$this->info('The environment file was successfully updated!');
|
||||||
|
|
||||||
|
$this->info('You can view these environment variables at any other time using the <comment>bunny env:list</comment> command.');
|
||||||
|
|
||||||
|
$this->info('If you need help, please check out our documentation: <comment>https://github.com/own3d/bunny-cli</comment>');
|
||||||
|
|
||||||
|
$this->newLine();
|
||||||
|
|
||||||
|
$this->info('Thanks for using Bunny CLI!');
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user