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

Add support for scriptcs, Cake, and FAKE #1035

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

xt0rted
Copy link
Member

@xt0rted xt0rted commented Sep 24, 2020

Pull Request Badge

Checklist:

  • If this PR is a new feature, please provide at least one example link
  • Make sure all of the significant new logic is covered by tests

Example files:

Comment on lines +2 to +5
#module nuget:?package=Cake.DotNetTool.Module&version=0.4.0

// @OctoLinkerResolve(https://www.nuget.org/packages/Cake.Coveralls)
#addin "nuget:https://api.nuget.org/v3/index.json?package=Cake.Coveralls&version=0.10.1"
Copy link
Member Author

Choose a reason for hiding this comment

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

@stefanbuck I'm having trouble getting these lines to work as I wanted.

I was trying to make everything after #module & #addin the link so you didn't have to search for the package name in the url, but GitHub's parsing the lines with a full url and everything after // is in a span so no link gets injected.

Is there a way to support making that whole value a link or are we stuck with making just the package name the link?

This is the file I was testing against https://github.com/cake-build/cake/blob/develop/build.cake.

Copy link
Member

Choose a reason for hiding this comment

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

This sounds similar to an issue I'm currently facing getting PHP / laravel support in.

<td>
  <span class="pl-k">use</span><span data-rgh-whitespace="space"> </span><span class="pl-v">Illuminate</span>\<span class="pl-v">Contracts</span>\<span class="pl-v">Container</span>\<span class="pl-v">Container</span>;
</td>

Yesterday, I spent two hours try to come up with a solution without luck. It's mainly a lack of support for such markup in https://github.com/padolsey/findAndReplaceDOMText which we use in the insert-link package.

I've noticed that refined-github is able to wrap the url in your case. If we find a solution we should make sure it doesn't conflict with refined-github which is a widely used extension as well.

Is this a blocker for you? Maybe best to ignore it for now and investigate into it separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

No not a blocker. I can have just the package name be the link until we find a better solution.

@xt0rted xt0rted force-pushed the dotnet-scripting branch 2 times, most recently from 95e5994 to 621fa4a Compare September 24, 2020 19:30
@stefanbuck
Copy link
Member

My other PR was failing as well for some odd reason. After rebasing it passed

Copy link
Member

@stefanbuck stefanbuck left a comment

Choose a reason for hiding this comment

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

Overall looks great. I left one comment about a potential optimization

} catch (ex) {
process.stdout.write(
`\n::error file=${file},line=${lineNumber}::${ex.message}\n`,
);
Copy link
Member

Choose a reason for hiding this comment

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

😍

Copy link
Member

Choose a reason for hiding this comment

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

I think a console.log should work here too. That way you can get rid of the newline operator.

resolve(path, [target]) {
// this reference doesn't resolve to anything
if (target === './.fake/build.fsx/intellisense.fsx') {
return [];
Copy link
Member

Choose a reason for hiding this comment

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

Just to share some insights, you can use undefined as a return value as well. Just saying, no need to change it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@stefanbuck I just tried return; and return undefined; and both give me an error. I guess that's why I was using an empty array here.

Uncaught (in promise) TypeError: Cannot read property 'registry' of undefined
    at app.js:41806
    at Array.map (<anonymous>)
    at app.js:41795
    at app.js:40329
    at Array.map (<anonymous>)
    at run (app.js:40322)
    at app.js:40355
    at gitHubInjection (app.js:15027)
    at init (app.js:40350)

The error points back to this line

Copy link
Member

Choose a reason for hiding this comment

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

Ohh sorry for pointing you into the wrong direction. I guess there is some value in having a consistent return type 😉

return [];
}

return [relativeFile({ path, target }), nugetResolver({ target })];
Copy link
Member

Choose a reason for hiding this comment

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

The signature of the resolve handler is resolve(path, target, meta, regExp).

Side note: Meta defaults to an empty object and is used in the context of plugin-npm-manifest.

What I want to talk about is the fourth argument regExp which is the matching RegExp from line 29. In my PHP PR I make use of this to use different resolvers

resolve(path, [target], meta, regExp) {
if (target.includes('\\')) {
return;
}
if (regExp === PHP_FUNC) {
return liveResolverQuery({
maybe we can do something similar here. This allows use to be more specific and does reduce unnecessary look up in the OctoLinker API.

Copy link
Member Author

Choose a reason for hiding this comment

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

That's awesome, I'll have to revisit some of the css & dotnet things I was working on because I'm pretty sure I'll be able to simplify them by checking the regex.

@xt0rted xt0rted mentioned this pull request Oct 2, 2020
2 tasks
@xt0rted
Copy link
Member Author

xt0rted commented Oct 12, 2020

Once this is merged a PR needs to be sent to fsprojects/awesome-fsharp#125 adding OctoLinker to the list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants