Skip to content

Commit

Permalink
Rearrange config file. Ignore ! in excluded paths. Add warm command
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondfrancis committed Jul 12, 2021
1 parent d3ba88f commit 00d5ce0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 21 deletions.
43 changes: 22 additions & 21 deletions config/sidecar.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@
*/
'env' => env('SIDECAR_ENV', env('APP_ENV')),

/*
* The default timeout for your functions, in seconds.
* This can be overridden per function.
*/
'timeout' => env('SIDECAR_TIMEOUT', 300),

/*
* The default memory for your functions, in megabytes.
* This can be overridden per function.
*/
'memory' => env('SIDECAR_MEMORY', 512),

/*
* The base path for your package files. If you e.g. keep
* all your Lambda package files in your resource path,
* you may change the base path here.
*/
'package_base_path' => env('SIDECAR_PACKAGE_BASE_PATH', base_path()),

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* You are welcome to edit this configuration directly, or you can run *
Expand All @@ -42,8 +61,9 @@
'aws_region' => env('SIDECAR_REGION'),

/*
* The bucket that temporarily holds your function's ZIP files as they
* are deployed to Lambda. It must be the same region as your Lambdas.
* The bucket that temporarily holds your function's ZIP files
* while they are deployed to Lambda. It must be in the same
* region as your functions.
*/
'aws_bucket' => env('SIDECAR_ARTIFACT_BUCKET_NAME'),

Expand All @@ -53,23 +73,4 @@
* See CreateExecutionRole::policy for the IAM policy.
*/
'execution_role' => env('SIDECAR_EXECUTION_ROLE'),

/*
* The default timeout for your functions, in seconds.
* This can be overridden per function.
*/
'timeout' => env('SIDECAR_TIMEOUT', 300),

/*
* The default memory for your functions, in megabytes.
* This can be overridden per function.
*/
'memory' => env('SIDECAR_MEMORY', 512),

/*
* The base path for your package files. If you e.g. keep
* all your Lambda package files in your resource path,
* you may change the base path here.
*/
'package_base_path' => env('SIDECAR_PACKAGE_BASE_PATH', base_path()),
];
12 changes: 12 additions & 0 deletions src/Package.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ public function include($paths)
*/
public function exclude($paths)
{
// If someone passed e.g. "!ignore.js", we'll just silently
// strip it off here. The array style happily accepts the
// exclamation as a negate flag, and I can see that
// causing unnecessary DX issues.
$paths = array_map(function ($path) {
if (Str::startsWith($path, '!')) {
$path = Str::replaceFirst('!', '', $path);
}

return $path;
}, Arr::wrap($paths));

$this->exclude = array_merge($this->exclude, $this->pathsForMerging($paths));

$this->files = null;
Expand Down
2 changes: 2 additions & 0 deletions src/Providers/SidecarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Hammerstone\Sidecar\Commands\Configure;
use Hammerstone\Sidecar\Commands\Deploy;
use Hammerstone\Sidecar\Commands\Install;
use Hammerstone\Sidecar\Commands\Warm;
use Hammerstone\Sidecar\Manager;
use Illuminate\Support\ServiceProvider;

Expand Down Expand Up @@ -56,6 +57,7 @@ public function boot()
$this->commands([
Activate::class,
Configure::class,
Warm::class,
Deploy::class,
Install::class,
]);
Expand Down
18 changes: 18 additions & 0 deletions tests/Unit/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,24 @@ public function it_excludes_files()
}
}

/** @test */
public function an_exclamation_excludes_is_ignored()
{
$package = Package::make()
->include([
'include',
])
->exclude([
'!exclude',
]);

$this->assertCount(1, $package->getIncludedPaths());
$this->assertStringContainsString('include', $package->getIncludedPaths()[0]);

$this->assertCount(1, $package->getExcludedPaths());
$this->assertStringContainsString('exclude', $package->getExcludedPaths()[0]);
}

/** @test */
public function hashes_are_stable()
{
Expand Down

0 comments on commit 00d5ce0

Please sign in to comment.