feat: add optional filepath argument to run command#417
feat: add optional filepath argument to run command#417zimeg wants to merge 1 commit intozimeg-fix-env-quotefrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## zimeg-fix-env-quote #417 +/- ##
=======================================================
- Coverage 68.62% 68.59% -0.04%
=======================================================
Files 218 218
Lines 18164 18177 +13
=======================================================
+ Hits 12465 12468 +3
- Misses 4539 4545 +6
- Partials 1160 1164 +4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
🌚 A few thoughts of these changes shared for kind reviewers!
| var appPath string | ||
| if len(args) > 0 { | ||
| appPath = args[0] | ||
| if _, err := clients.Fs.Stat(appPath); err != nil { | ||
| return slackerror.New(slackerror.ErrNotFound). | ||
| WithMessage("The app path %q could not be found", appPath). | ||
| WithRemediation("Check that the file exists and the path is correct") | ||
| } | ||
| } |
There was a problem hiding this comment.
| var appPath string | |
| if len(args) > 0 { | |
| appPath = args[0] | |
| if _, err := clients.Fs.Stat(appPath); err != nil { | |
| return slackerror.New(slackerror.ErrNotFound). | |
| WithMessage("The app path %q could not be found", appPath). | |
| WithRemediation("Check that the file exists and the path is correct") | |
| } | |
| } |
🪓 note: I'm curious of removing this in favor of leaving errors to the hook implementations. Removing this might let for strange argument parsing as perhaps:
$ slack run localhost
👾 ramble: For now it seems to make a better experience for the intended filepath arguments I think-
There was a problem hiding this comment.
thought: Interesting idea to leave this to the framework. I think for now, we should leave this in the CLI. We can loosen it later if there is a feature request, but this starts with ensuring an error-free experience. If developers are running a build (e.g. TypeScript: dist/index.js) then they'll need to start their watch server or build a dist before starting the Slack CLI.
| Args: cobra.MaximumNArgs(1), | ||
| Example: style.ExampleCommandsf([]style.ExampleCommand{ | ||
| {Command: "platform run", Meaning: "Start a local development server"}, | ||
| {Command: "platform run --activity-level debug", Meaning: "Run a local development server with debug activity"}, |
There was a problem hiding this comment.
🗣️ note: IIRC this activity level flag isn't used often so we might encourage examples that outline another common use case?
There was a problem hiding this comment.
👾 ramble: I'm now curious if this flag updates a LOG_LEVEL environment variable for run command?
There was a problem hiding this comment.
I agree, we can probably remove it as an example since it's Deno/ROSI specific as well.
thought: In the future, we will probably introduce a --log-level flag that the CLI will use and pass into Bolt Frameworks. The same log level should be passed into the Deno SDK and could be inherited by --activity-level for Deno apps.
The end result would be a universal log-level flag that works for all frameworks and ROSI.
| func NewRunCommand(clients *shared.ClientFactory) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "run", | ||
| Use: "run [app-path]", |
There was a problem hiding this comment.
📚 note: I'm not so excited about this placeholder but it's clear to me...
There was a problem hiding this comment.
nit: I'd clarify that it's a filepath (src/app.js) instead of a path (src/). Otherwise, I think it's clear!
You could use run [file-path] if run [app-file-path] reads strange to you.
| Use: "run [app-path]", | |
| Use: "run [app-file-path]", |
mwbrooks
left a comment
There was a problem hiding this comment.
✅ Woohoo! This is an exciting and cool addition, thanks for adding it @zimeg!
🧪 Works beautifully with local tests. 🎉
📝 Left a minor nit about renaming appPath to appFilePath for clarity. Pedantic, but the clarity can avoid confusion for developers reading the code with refresh eyes.
| func NewRunCommand(clients *shared.ClientFactory) *cobra.Command { | ||
| cmd := &cobra.Command{ | ||
| Use: "run", | ||
| Use: "run [app-path]", |
There was a problem hiding this comment.
nit: I'd clarify that it's a filepath (src/app.js) instead of a path (src/). Otherwise, I think it's clear!
You could use run [file-path] if run [app-file-path] reads strange to you.
| Use: "run [app-path]", | |
| Use: "run [app-file-path]", |
| Args: cobra.MaximumNArgs(1), | ||
| Example: style.ExampleCommandsf([]style.ExampleCommand{ | ||
| {Command: "platform run", Meaning: "Start a local development server"}, | ||
| {Command: "platform run --activity-level debug", Meaning: "Run a local development server with debug activity"}, |
There was a problem hiding this comment.
I agree, we can probably remove it as an example since it's Deno/ROSI specific as well.
thought: In the future, we will probably introduce a --log-level flag that the CLI will use and pass into Bolt Frameworks. The same log level should be passed into the Deno SDK and could be inherited by --activity-level for Deno apps.
The end result would be a universal log-level flag that works for all frameworks and ROSI.
| } | ||
| ctx := cmd.Context() | ||
|
|
||
| var appPath string |
There was a problem hiding this comment.
nit: Could I suggest appFilePath? To me appPath implies a path (directory path) while appFilePath implies a file path (path to a specific file).
| appPath = args[0] | ||
| if _, err := clients.Fs.Stat(appPath); err != nil { | ||
| return slackerror.New(slackerror.ErrNotFound). | ||
| WithMessage("The app path %q could not be found", appPath). |
There was a problem hiding this comment.
| WithMessage("The app path %q could not be found", appPath). | |
| WithMessage("The app file path %q could not be found", appPath). |
| var appPath string | ||
| if len(args) > 0 { | ||
| appPath = args[0] | ||
| if _, err := clients.Fs.Stat(appPath); err != nil { | ||
| return slackerror.New(slackerror.ErrNotFound). | ||
| WithMessage("The app path %q could not be found", appPath). | ||
| WithRemediation("Check that the file exists and the path is correct") | ||
| } | ||
| } |
There was a problem hiding this comment.
thought: Interesting idea to leave this to the framework. I think for now, we should leave this in the CLI. We can loosen it later if there is a feature request, but this starts with ensuring an error-free experience. If developers are running a build (e.g. TypeScript: dist/index.js) then they'll need to start their watch server or build a dist before starting the Slack CLI.
| Activity: !runFlags.noActivity, | ||
| ActivityLevel: runFlags.activityLevel, | ||
| App: selection.App, | ||
| AppPath: appPath, |
There was a problem hiding this comment.
nit: You know my nit here, lol.
| AppPath: appPath, | |
| AppFilePath: appFilePath, |
| All Bolt SDKs leverage this `start` hook operating mode. | ||
|
|
||
| A custom start path can be set with the `SLACK_CLI_CUSTOM_FILE_PATH` variable. | ||
| A custom start path can be provided as a positional argument to the `run` command (e.g., `slack run ./src/app.py`), which sets both the `SLACK_APP_PATH` and `SLACK_CLI_CUSTOM_FILE_PATH` environment variables for the hook process. |
There was a problem hiding this comment.
praise: Thank you for updating this and choosing to support both at first. #backwards-compatible
Changelog
Summary
This PR adds an optional filepath argument to the
runcommand.Preview
Current and continued behavior:
With a path argument provided:
When the file doesn't exist:
Reviewers
The following commands shows the optional argument of a filepath for the
runcommand:Requirements