-
Notifications
You must be signed in to change notification settings - Fork 77
[Feature] Make function command #125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
wilsenhc
wants to merge
25
commits into
aarondfrancis:main
Choose a base branch
from
wilsenhc:feature/make-function-command
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+156
−5
Open
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
8f16a38
feat: make lambda function command
wilsenhc 5ca8547
Fix code styling [ci skip]
wilsenhc f3bc3de
feat: add command to service provider
wilsenhc 73b3dc7
feat: update commad + move stubs
wilsenhc d5f19ee
Fix code styling [ci skip]
wilsenhc 25a51e8
fix: fix stubs path
wilsenhc c8da115
docs: finish up documentation for make function command
wilsenhc 71da487
fix: remove creates matching test
wilsenhc c2c8893
feat: update readme
wilsenhc 80d4157
Merge branch 'feature/update-lambda-runtimes' into feature/make-funct…
wilsenhc 960724b
Merge branch 'feature/update-lambda-runtimes' into feature/make-funct…
wilsenhc b2d6ab7
feat: make nodejs20.x the default runtime
wilsenhc d553e36
Merge branch 'feature/update-lambda-runtimes' into feature/make-funct…
wilsenhc 76ad19d
Merge branch 'main' into feature/make-function-command
wilsenhc bfee5b2
fix: missing eol
wilsenhc 8673f26
Merge branch 'hammerstonedev:main' into feature/make-function-command
wilsenhc 7f50d04
Merge branch 'hammerstonedev:main' into feature/make-function-command
wilsenhc b051a5e
Merge branch 'hammerstonedev:main' into feature/make-function-command
wilsenhc e4180a6
Merge branch 'hammerstonedev:main' into feature/make-function-command
wilsenhc a65ec49
Merge branch 'aarondfrancis:main' into feature/make-function-command
wilsenhc 7950d4a
Fix code styling [ci skip]
wilsenhc 8eaf674
Initial plan
Copilot 2f3cd4d
Fix getArguments method - rename to getOptions with correct runtime o…
Copilot 6971c38
Add default value to runtime option in signature for consistency
Copilot 5aeca7e
Merge pull request #1 from wilsenhc/copilot/fix-argument-declaration
wilsenhc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @author Wilsen Hernández <[email protected]|https://github.com/wilsenhc> | ||
| */ | ||
|
|
||
| namespace Hammerstone\Sidecar\Commands; | ||
|
|
||
| use Illuminate\Console\GeneratorCommand; | ||
| use Symfony\Component\Console\Attribute\AsCommand; | ||
| use Symfony\Component\Console\Input\InputOption; | ||
|
|
||
| #[AsCommand(name: 'make:lambda-function')] | ||
| class MakeLambdaFunction extends GeneratorCommand | ||
| { | ||
| /** | ||
| * The name and signature of the console command. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $signature = 'make:lambda-function {name} {--runtime= : The runtime that will be used to create the lambda function}'; | ||
|
|
||
| /** | ||
| * The console command description. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $description = 'Create a new Sidecar Lambda function class'; | ||
|
|
||
| /** | ||
| * The type of class being generated. | ||
| * | ||
| * @var string | ||
| */ | ||
| protected $type = 'Lambda'; | ||
|
|
||
| /** | ||
| * Get the stub file for the generator. | ||
| * | ||
| * @return string | ||
| */ | ||
| protected function getStub() | ||
| { | ||
| return $this->resolveStubPath('/stubs/lambda-function.stub'); | ||
| } | ||
|
|
||
| /** | ||
| * Resolve the fully-qualified path to the stub. | ||
| * | ||
| * @param string $stub | ||
| * @return string | ||
| */ | ||
| protected function resolveStubPath($stub) | ||
| { | ||
| return file_exists($customPath = $this->laravel->basePath(trim($stub, '/'))) | ||
| ? $customPath | ||
| : __DIR__ . $stub; | ||
| } | ||
|
|
||
| /** | ||
| * Get the default namespace for the class. | ||
| * | ||
| * @param string $rootNamespace | ||
| * @return string | ||
| */ | ||
| protected function getDefaultNamespace($rootNamespace) | ||
| { | ||
| return "{$rootNamespace}\Sidecar"; | ||
| } | ||
|
|
||
| /** | ||
| * Replace the class name for the given stub. | ||
| * | ||
| * @param string $stub | ||
| * @param string $name | ||
| * @return string | ||
| */ | ||
| protected function replaceClass($stub, $name) | ||
| { | ||
| $stub = parent::replaceClass($stub, $name); | ||
|
|
||
| $runtime = $this->option('runtime') ?: 'nodejs20.x'; | ||
|
|
||
| return str_replace(['nodejs20.x', '{{ runtime }}'], $runtime, $stub); | ||
| } | ||
|
|
||
| /** | ||
| * Get the console command arguments. | ||
| * | ||
| * @return array | ||
| */ | ||
| protected function getArguments() | ||
| { | ||
| return [ | ||
| ['force', 'f', InputOption::VALUE_NONE, 'Create the class even if the lambda function already exists'], | ||
| ['runtime', null, InputOption::VALUE_OPTIONAL, 'The runtime that will be used to create the lambda function'], | ||
| ]; | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| <?php | ||
|
|
||
| namespace {{ namespace }}; | ||
|
|
||
| use Hammerstone\Sidecar\LambdaFunction; | ||
|
|
||
| class {{ class }} extends LambdaFunction | ||
| { | ||
| /** | ||
| * The function within your code that Lambda calls to begin execution. | ||
| * @inheritDoc | ||
| * | ||
| * @return string | ||
| */ | ||
| public function handler() | ||
| { | ||
| return 'sidecar/function.handler'; | ||
| } | ||
|
|
||
| /** | ||
| * The runtime environment for the Lambda function. | ||
| * | ||
| * @see https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html | ||
| * | ||
| * @return string | ||
| */ | ||
| public function runtime() | ||
| { | ||
| return '{{ runtime }}'; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.