Skip to content
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

feat: add createDeeplink #37

Merged
merged 18 commits into from
Aug 28, 2024
Merged

Conversation

erics118
Copy link
Contributor

Adds a function to create a deeplink. Before, needed to manually write out the deeplink, which was prone to errors.

Copy link

@LitoMore LitoMore left a comment

Choose a reason for hiding this comment

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

Query Parameters feature needs to be added.

src/createDeeplink.ts Outdated Show resolved Hide resolved
src/createDeeplink.ts Outdated Show resolved Hide resolved
@erics118
Copy link
Contributor Author

I currently don't have pro, so I can't test features regarding AI commands. Not sure if they have a special format or not.

Copy link
Contributor

@thomaslombart thomaslombart left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @erics118! Could you add some examples in your GitHub PR to make it easier to visualize the proposed API?

Would it also be possible to add some tests in the Utils Smoke Tests extension? Creating a new createDeeplink command with some examples should be enough.

export function createScriptCommandDeeplink(options: CreateScriptCommandDeeplinkOptions): string {
const protocol = getProtocol();

const params = new URLSearchParams();
Copy link

@LitoMore LitoMore Aug 14, 2024

Choose a reason for hiding this comment

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

Don't use URLSearchParams, please use encodeURIComponent instead. See here for more details: https://raycastcommunity.slack.com/archives/C02HEMAF2SJ/p1716016337748779

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've switched to encodeURIComponent, but it looks a bit more janky now. Please see if you can add some more tests if this is implemented correctly.

@erics118
Copy link
Contributor Author

I've added tests and a markdown file for documentation. I'm not too sure about how the changelog should be added, or how to properly place the markdown file so that gitbook uses it properly.

@thomaslombart
Copy link
Contributor

@erics118 @LitoMore I've made a few changes:

  • If type isn't provided, it'll default to an extension deeplink as they're more common than script commands.
  • I re-ordered the docs to show the extension deeplinks for the same reason as above
  • I updated the examples and tests to use Action.CreateQuicklink as this is the top use-case in extensions
  • I added a changelog entry

Let me know if this looks good to you so we can merge it soon 🙂

@erics118
Copy link
Contributor Author

Looks pretty good. I was just wondering if there were other command types that should be added, ie for pro features such as AI commands or custom window management commands.

@thomaslombart
Copy link
Contributor

Let's keep it as is as they're the most common commands. We can always iterate on it later if needed as these would be additive improvements.

I'll merge that during the day 🙂

}

export function createExtensionDeeplink(options: CreateExtensionDeeplinkOptions): string {
let ownerOrAuthorName = environment.ownerOrAuthorName;
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a hack like https://github.com/raycast/utils/blob/main/src/handle-error-toast-action.ts#L10-L12 instead of bumping the required @raycast/api version? It'd be sort of a breaking change otherwise

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed!

Copy link
Contributor

@thomaslombart thomaslombart left a comment

Choose a reason for hiding this comment

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

🚀

@thomaslombart thomaslombart merged commit a35cdf7 into raycast:main Aug 28, 2024
1 check passed
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.

5 participants