Skip to content

Conversation

@wilsenhc
Copy link
Contributor

@wilsenhc wilsenhc commented Jul 10, 2023

This PR adds a new make:lambda-function command to easily create a new function class!

Still need to start documenting this, but feel free to add any comments now @aarondfrancis !
Much better so I can start doing changes/fixes to this before marking as ready.

Note: This PR depends on #123, so we better finish that first too

Summary by CodeRabbit

  • New Features

    • Added an Artisan command to generate scaffolded Lambda functions with configurable runtimes.
  • Documentation

    • Added instructions and examples for generating Lambda functions and runtime option usage.
    • Expanded deploy/activate workflow guidance with example commands and clarifications.
  • Style

    • Minor formatting and example formatting updates in README and docs.

@wilsenhc wilsenhc marked this pull request as ready for review July 30, 2023 16:57
@wilsenhc
Copy link
Contributor Author

Hey there again @aarondfrancis, I've just marked this as Ready for Review!

Note: Just a reminder that this PR depends on #123.

@wilsenhc
Copy link
Contributor Author

I have updated this PR to reflect changes from #123 @aarondfrancis

@wilsenhc
Copy link
Contributor Author

@owenvoke this other PR might interest you, based on one of your comments in #123 about nodejs 14.x being deprecated

@wilsenhc
Copy link
Contributor Author

This PR has just been updated with all the changes from latest release 🚀

@coderabbitai
Copy link

coderabbitai bot commented Oct 27, 2025

Walkthrough

Adds a new Artisan command make:lambda-function (with a --runtime option defaulting to nodejs20.x) that scaffolds Lambda function classes from a stub; registers the command in the service provider; adds the stub file; updates docs and README examples; removes an unused import in Warm.php.

Changes

Cohort / File(s) Summary
Documentation Updates
README.md, docs/commands.md
README: wraps og:image in inline code and adds an example block demonstrating php artisan make:lambda-function OgImage. docs/commands.md: adds Make command section (php artisan make:lambda-function MyFunction) with --runtime (default nodejs20.x) and example (python3.10); expands Deploy section with deploy vs activate guidance and formatting tweaks.
New Make Command
src/Commands/MakeLambdaFunction.php
New Artisan command MakeLambdaFunction registered as make:lambda-function {name}; supports --runtime (default nodejs20.x) and typical generator options; resolves and uses a stub, replaces {{ namespace }}, {{ class }}, and {{ runtime }} placeholders; default namespace set to <rootNamespace>\Sidecar.
Stub Template
src/Commands/stubs/lambda-function.stub
New stub template providing a namespaced class extending LambdaFunction with handler() and runtime() methods, including {{ runtime }} placeholder for substitution.
Registration & Cleanup
src/Providers/SidecarServiceProvider.php, src/Commands/Warm.php
SidecarServiceProvider now imports and registers MakeLambdaFunction::class in its commands array. Warm.php has an unused Illuminate\Console\Command import removed (no behavior change).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Artisan as Laravel Artisan
    participant Command as MakeLambdaFunction
    participant Stub as lambda-function.stub
    participant FS as File System

    User->>Artisan: php artisan make:lambda-function MyFunc --runtime python3.10
    Artisan->>Command: invoke command
    Command->>Stub: load stub template
    Stub-->>Command: return template with placeholders
    Command->>Command: replace {{ namespace }}, {{ class }}, {{ runtime }}
    Command->>FS: write generated class file to app/Sidecar/...
    FS-->>Command: write success
    Command-->>Artisan: command completes
    Artisan-->>User: "Lambda function class created"
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Verify generator methods: stub resolution, placeholder replacement, namespace handling.
  • Confirm --runtime default and option wiring.
  • Check stub contents for correct namespace/class placeholders and LambdaFunction extension.
  • Ensure service provider command registration is correct.
  • Minor review of docs examples and README insertion.

Poem

🐰 I hopped to the code with a twitch of my nose,
Scaffolding functions where the runtime wind blows.
A stub and a command, a tidy new route—
I made a small class and then jumped about! ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "[Feature] Make function command" directly corresponds to the primary change in this pull request: the addition of a new Laravel Artisan command make:lambda-function that generates Lambda function classes. The changeset includes the command implementation (MakeLambdaFunction.php), the stub template, documentation updates, and provider registration—all unified around this single feature. The title is concise, clear, and sufficiently specific that a teammate reviewing the history would understand the core addition is a new command for generating functions.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7950d4a and 5aeca7e.

📒 Files selected for processing (1)
  • src/Commands/MakeLambdaFunction.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Commands/MakeLambdaFunction.php

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/Commands/stubs/lambda-function.stub (1)

15-18: Consider documenting the placeholder handler path.

The handler returns a hardcoded placeholder path 'sidecar/function.handler'. Users will need to manually update this to match their actual handler location. Consider adding a comment in the stub to make this more explicit, or include an example that aligns with common project structures.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e30df1a and 7950d4a.

📒 Files selected for processing (6)
  • README.md (1 hunks)
  • docs/commands.md (1 hunks)
  • src/Commands/MakeLambdaFunction.php (1 hunks)
  • src/Commands/Warm.php (0 hunks)
  • src/Commands/stubs/lambda-function.stub (1 hunks)
  • src/Providers/SidecarServiceProvider.php (2 hunks)
💤 Files with no reviewable changes (1)
  • src/Commands/Warm.php
🧰 Additional context used
🧬 Code graph analysis (1)
src/Commands/MakeLambdaFunction.php (1)
src/LambdaFunction.php (2)
  • name (100-103)
  • runtime (236-239)
🪛 LanguageTool
README.md

[style] ~51-~51: To sound more natural, try using the present tense here instead of the progressive.
Context: ... deployed to Lambda For example, if we were wanting to use Node on Lambda to generate an `o...

(IS_WANTING_TO)


[style] ~52-~52: Consider a more expressive alternative.
Context: ...imple class in PHP called OgImage. To do this we can run the command: ```bash p...

(DO_ACHIEVE)

🔇 Additional comments (4)
README.md (1)

51-56: Excellent addition to the documentation!

The new command example is clear and well-placed. It helps users discover the make command early in the workflow.

src/Providers/SidecarServiceProvider.php (1)

17-17: LGTM!

The command is properly imported and registered in the service provider.

Also applies to: 60-60

docs/commands.md (1)

22-35: Comprehensive documentation!

The Make section clearly explains both basic usage and runtime customization. The link to the Runtime section is helpful for users wanting more details.

src/Commands/MakeLambdaFunction.php (1)

78-85: Clarify why both replacement patterns are needed.

The str_replace on line 84 replaces both 'nodejs20.x' and '{{ runtime }}'. Since the stub template uses '{{ runtime }}' as the placeholder, why is 'nodejs20.x' also being replaced? This appears redundant and could cause confusion.

If the stub only contains '{{ runtime }}', consider simplifying to:

-        return str_replace(['nodejs20.x', '{{ runtime }}'], $runtime, $stub);
+        return str_replace('{{ runtime }}', $runtime, $stub);

Copilot AI and others added 2 commits October 27, 2025 22:35
Fix MakeLambdaFunction: rename getArguments() to getOptions() with correct option definition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant