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 Paket #1064

Merged
merged 7 commits into from
Oct 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ root = true
indent_style = space
indent_size = 2

[*.js]
end_of_line = lf

[*.json]
indent_size = 2

Expand Down
16 changes: 16 additions & 0 deletions e2e/fixtures/dotnet/paket.dependencies
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
source https://nuget.org/api/v2
content: none

# @OctoLinkerResolve(https://www.nuget.org/packages/FSharp.Core)
nuget FSharp.Core > 4.3 lowest_matching: true, redirects: force

# @OctoLinkerResolve(https://www.nuget.org/packages/Chessie)
nuget Chessie >= 0.6

group Build
framework: net46
# @OctoLinkerResolve(https://github.com/fsharp/FAKE/blob/master/modules/Octokit/Octokit.fsx)
github fsharp/FAKE modules/Octokit/Octokit.fsx

# @OctoLinkerResolve(https://github.com/fable-compiler/fake-helpers/blob/fake_legacy/Fable.FakeHelpers.fs)
github fable-compiler/fake-helpers:fake_legacy Fable.FakeHelpers.fs
11 changes: 11 additions & 0 deletions e2e/fixtures/dotnet/paket.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# @OctoLinkerResolve(https://www.nuget.org/packages/NUnit)
nuget NUnit -> source ./local_source

# @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.EntityFrameworkCore)
nuget Microsoft.EntityFrameworkCore -> source ./local_source

# @OctoLinkerResolve(https://www.nuget.org/packages/NUnit)
nuget NUnit 3.12.0 -> source ./local_source

# @OctoLinkerResolve(https://www.nuget.org/packages/Microsoft.EntityFrameworkCore)
nuget Microsoft.EntityFrameworkCore 5.0.0-rc.1.20451.13-> source ./local_source
5 changes: 5 additions & 0 deletions e2e/fixtures/dotnet/paket.references
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @OctoLinkerResolve(https://www.nuget.org/packages/FSharp.Core)
FSharp.Core

# @OctoLinkerResolve(https://www.nuget.org/packages/Chessie)
Chessie
2 changes: 2 additions & 0 deletions packages/core/load-plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ export { default as DotNetCore } from '@octolinker/plugin-dotnet-core';
export { default as DotNet } from '@octolinker/plugin-dotnet';
export { default as DotNetGlobalTools } from '@octolinker/plugin-dotnet-global-tools';
export { default as DotNetProject } from '@octolinker/plugin-dotnet-project';
export { default as DotNetPaketDependencies } from '@octolinker/plugin-dotnet-paket-dependencies';
export { default as DotNetPaketReferences } from '@octolinker/plugin-dotnet-paket-references';
export { default as Rubygems } from '@octolinker/plugin-gemfile-manifest';
export { default as Go } from '@octolinker/plugin-go';
export { default as Haskell } from '@octolinker/plugin-haskell';
Expand Down
2 changes: 2 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"@octolinker/plugin-dotnet-core": "1.0.0",
"@octolinker/plugin-dotnet-global-tools": "1.0.0",
"@octolinker/plugin-dotnet-project": "1.0.0",
"@octolinker/plugin-dotnet-paket-dependencies": "1.0.0",
"@octolinker/plugin-dotnet-paket-references": "1.0.0",
"@octolinker/plugin-gemfile-manifest": "1.0.0",
"@octolinker/plugin-github-actions": "1.0.0",
"@octolinker/plugin-github-codeowners": "1.0.0",
Expand Down
26 changes: 26 additions & 0 deletions packages/helper-grammar-regex-collection/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,29 @@ export const NET_PROJ_FILE_REFERENCE = regex`
(Include|Update)=${captureSpacedQuotedWord}
.*/?>
`;

export const PAKET_DEPENDENCIES_NUGET = regex`
nuget
\s
(?<$1>[^\s#]+)
`;

export const PAKET_DEPENDENCIES_GITHUB = regex`
github
\s
(?<$1>[^ :]+) # repo
(
:
(?<$2>[\w-]+) # hash/tag
)?
(
\s
(?<$3>[^\n]*) # file path
)?
`;

export const PAKET_REFERENCES = regex`
${diffSigns}
(?![Ff]ile:)
(?<$1>[^# \n]+)
`;
41 changes: 41 additions & 0 deletions packages/helper-grammar-regex-collection/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,47 @@ const fixtures = {
],
invalid: [],
},
PAKET_DEPENDENCIES_NUGET: {
valid: [
['nuget foo', ['foo']],
['nuget foo = 1.0', ['foo']],
['nuget foo >= 5', ['foo']],
[' nuget foo', ['foo']],
[' nuget foo = 1.0', ['foo']],
[' nuget foo >= 5', ['foo']],
['nuget foo 1.2.3 -> source ./local_source', ['foo']],
['nuget foo.bar 1.2.3 -> source ./local_source', ['foo.bar']],
],
invalid: [
'foo',
'nuget',
'# nuget',
'nuget # foo',
'https://nuget.org',
'source https://nuget.org/api/v2',
],
},
PAKET_DEPENDENCIES_GITHUB: {
valid: [
['github foo', ['foo']],
['github foo/bar', ['foo/bar']],
['github foo/bar:abc123', ['foo/bar', 'abc123']],
['github foo/bar:abc123 bar/baz', ['foo/bar', 'abc123', 'bar/baz']],
[' github foo', ['foo']],
[' github foo/bar', ['foo/bar']],
[' github foo/bar:abc123', ['foo/bar', 'abc123']],
[' github foo/bar:abc123 bar/baz', ['foo/bar', 'abc123', 'bar/baz']],
],
invalid: ['foo', 'github', '# github', 'https://github.com'],
},
PAKET_REFERENCES: {
valid: [
['foo', ['foo']],
['foo # bar', ['foo']],
['foo.bar', ['foo.bar']],
],
invalid: ['File:foo', 'file:foo'],
},
};

function fixturesIterator(fixturesList, next) {
Expand Down
48 changes: 48 additions & 0 deletions packages/plugin-dotnet-paket-dependencies/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {
PAKET_DEPENDENCIES_NUGET,
PAKET_DEPENDENCIES_GITHUB,
} from '@octolinker/helper-grammar-regex-collection';
import nugetResolver from '@octolinker/resolver-nuget';

function githubPaths({ target, hash, filePath }) {
const urls = [];

if (filePath) {
if (hash) {
urls.push(`https://github.com/${target}/blob/${hash}/${filePath}`);
}

urls.push(`https://github.com/${target}/blob/master/${filePath}`);
}

if (hash) {
urls.push(`https://github.com/${target}/tree/${hash}`);
}

urls.push(`https://github.com/${target}`);

return urls;
}

export default {
name: 'DotNetPaketDependencies',

resolve(_path, [target, hash, filePath], _meta, regExp) {
if (regExp === PAKET_DEPENDENCIES_GITHUB) {
return githubPaths({ target, hash, filePath });
}

return nugetResolver({ target });
},

getPattern() {
return {
pathRegexes: [/paket\.dependencies$/, /paket\.local$/],
githubClasses: [],
};
},

getLinkRegexes() {
return [PAKET_DEPENDENCIES_NUGET, PAKET_DEPENDENCIES_GITHUB];
},
};
12 changes: 12 additions & 0 deletions packages/plugin-dotnet-paket-dependencies/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@octolinker/plugin-dotnet-paket-dependencies",
"version": "1.0.0",
"description": "",
"repository": "https://github.com/octolinker/octolinker/tree/main/packages/plugin-dotnet-paket-dependencies",
"license": "MIT",
"main": "./index.js",
"dependencies": {
"@octolinker/helper-grammar-regex-collection": "1.0.0",
"@octolinker/resolver-nuget": "1.0.0"
}
}
21 changes: 21 additions & 0 deletions packages/plugin-dotnet-paket-references/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { PAKET_REFERENCES } from '@octolinker/helper-grammar-regex-collection';
import nugetResolver from '@octolinker/resolver-nuget';

export default {
name: 'DotNetPaketReferences',

resolve(_path, [target]) {
return nugetResolver({ target });
},

getPattern() {
return {
pathRegexes: [/paket\.references$/],
githubClasses: [],
};
},

getLinkRegexes() {
return [PAKET_REFERENCES];
},
};
12 changes: 12 additions & 0 deletions packages/plugin-dotnet-paket-references/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "@octolinker/plugin-dotnet-paket-references",
"version": "1.0.0",
"description": "",
"repository": "https://github.com/octolinker/octolinker/tree/main/packages/plugin-dotnet-paket-references",
"license": "MIT",
"main": "./index.js",
"dependencies": {
"@octolinker/helper-grammar-regex-collection": "1.0.0",
"@octolinker/resolver-nuget": "1.0.0"
}
}