fix: preserve path separators in create command argument#526
Conversation
The display_information.name and bot_user.display_name fields in manifest files were set to the kebab-case directory name (e.g. "my-app") instead of a human-readable title case name (e.g. "My App").
…ebab Addresses review feedback — instead of converting the kebab-case directory name to title case (which mangles names like "TIM" or "Translator - Translate Languages"), pass the original user-provided app name through to manifest display fields. This preserves the user's exact casing and formatting.
Co-authored-by: Eden Zimbelman <eden.zimbelman@salesforce.com>
The getAppDirName function was normalizing the entire input including path separators, so `slack create path/to/my-app` produced a flat directory `path-to-my-app` instead of preserving the path structure. Adds parseAppPath which splits user input into path prefix and basename, only kebab-casing the basename. The display name for manifests is derived from the raw basename (preserving original casing). Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #526 +/- ##
==========================================
+ Coverage 71.30% 71.31% +0.01%
==========================================
Files 222 222
Lines 18706 18725 +19
==========================================
+ Hits 13338 13354 +16
- Misses 4188 4190 +2
- Partials 1180 1181 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| // Verify that the parent directory path exists (we will not create missing directories) | ||
| if exists, err := parentDirExists(dirPath); err != nil { | ||
| return "", err | ||
| } else if !exists { | ||
| return "", slackerror.New(slackerror.ErrAppDirectoryAccess) | ||
| } |
There was a problem hiding this comment.
🔬 thought: So curious! I thought creating missing directories was supported but I am wrong!
There was a problem hiding this comment.
yes very curious! i thought so too but i think it would be nice to have 🤔 perhaps in followups 🚀
| // Get the app selection and accompanying app directory name (this may change when we find the unique directory name) | ||
| appDirName, err := getAppDirName(createArgs.AppName) | ||
| // Parse the app name input into a directory path and display name | ||
| appPath, displayName, err := parseAppPath(createArgs.AppName) |
There was a problem hiding this comment.
🐛 issue: I'm finding the app path can be changed with the "--name" flag which is unexpected as:
$ slack create path/to/my-app --name "APPPP"
📂 Created a new Slack project
Cloning template slack-samples/bolt-js-starter-template
To path ~/programming/tools/slack-cli/apppp
🔍 thought: I'd instead expect the argument path to be preferred here with the name being applied to the app itself? I'm unsure if separating these functions makes this more clear but think this case is good to test too!
There was a problem hiding this comment.
hmmm i thought the --name flag was always preferred? this was introduced with the name flag in #327
but thanks for catching this because i would also expect --name to override the display name and leave the path alone
There was a problem hiding this comment.
@srtaalej Ahh we might be finding nuance of this command 😓 I recall these discussion too and didn't account for these edges...
The --name flag now only sets the manifest display name, preserving any path provided via the positional argument for directory placement.
Changelog
The
createcommand preserves separators once again if direction to a nested path is provided.Summary
slack create path/to/my-appregression where path separators were being replaced with dashes, creating a flatpath-to-my-appdirectory instead of preserving thepath/to/my-appstructureparseAppPathhelper that splits user input into path prefix + basename, only kebab-casing the basenameBehavior
Stacks on #521 which handles the display name vs dir name separation.
Test plan
TestParseAppPath— 12 cases covering simple names, paths, absolute paths, dot-prefixed, trailing slashes, and error casesTestGetProjectDirectoryNamestill passes (single-component names)go test ./...) passesslack create path/to/my-appwith existingpath/to/directory → verify nested structure created and manifest hasmy-appslack create "My App"→ verify dir ismy-app, manifest display isMy App