Compare commits
195 Commits
Author | SHA1 | Date |
---|---|---|
Paul Schneider | 9aa3140a11 | 2 years ago |
Paul Schneider | 7f9344d437 | 2 years ago |
Paul Schneider | f46ca00de9 | 2 years ago |
Paul Schneider | fcea41f8c1 | 2 years ago |
Paul Schneider | 58f49af5f0 | 2 years ago |
Paul Schneider | fececb327e | 2 years ago |
Paul Schneider | 14206ac477 | 2 years ago |
Paul Schneider | fa9a12ad49 | 2 years ago |
Paul Schneider | 7f9984b059 | 2 years ago |
Paul Schneider | 2dcf1a2806 | 2 years ago |
Paul Schneider | a84e1d9750 | 2 years ago |
Paul Schneider | 97eba2390e | 2 years ago |
Paul Schneider | 6c9f29bc56 | 2 years ago |
Paul Schneider | 2d5438c943 | 2 years ago |
Paul Schneider | 519a4fbd46 | 2 years ago |
Paul Schneider | a11bab759e | 2 years ago |
Paul Schneider | d7f0a5db36 | 2 years ago |
Paul Schneider | 5d59760a77 | 2 years ago |
Paul Schneider | 3e09afcbfe | 2 years ago |
Paul Schneider | 8fa4c04367 | 2 years ago |
Paul Schneider | 60e4ca8c54 | 2 years ago |
Paul Schneider | da92b9dbec | 2 years ago |
Paul Schneider | 6194e185b9 | 2 years ago |
Paul Schneider | 5c1a49811a | 2 years ago |
Paul Schneider | 328f6f166a | 2 years ago |
Paul Schneider | 4191513eef | 2 years ago |
Paul Schneider | 217cc49019 | 2 years ago |
Paul Schneider | a4a1c6e271 | 2 years ago |
Paul Schneider | c06f518836 | 2 years ago |
Paul Schneider | edc9628b67 | 2 years ago |
Paul Schneider | 4bb43877c7 | 2 years ago |
Paul Schneider | ce8b7bcdb3 | 2 years ago |
Paul Schneider | 67ec19184b | 2 years ago |
Paul Schneider | 57609e6ed3 | 2 years ago |
Paul Schneider | b46e786ace | 2 years ago |
Paul Schneider | 423f9c15b3 | 2 years ago |
Paul Schneider | 6d21d7370c | 2 years ago |
Paul Schneider | ee07affbbd | 2 years ago |
Paul Schneider | cba0720150 | 2 years ago |
Paul Schneider | a2d91e072f | 2 years ago |
Paul Schneider | 1befc2e053 | 2 years ago |
Paul Schneider | df55836c58 | 3 years ago |
Paul Schneider | cd3629a5a0 | 3 years ago |
Paul Schneider | 51a08dec9a | 3 years ago |
Paul Schneider | 386eec262d | 3 years ago |
Paul Schneider | 45d6c22d1e | 3 years ago |
Paul Schneider | 225c8ef588 | 3 years ago |
Paul Schneider | 290a3047b5 | 3 years ago |
Paul Schneider | ec70927830 | 3 years ago |
Paul Schneider | 9f338ca09f | 3 years ago |
Paul Schneider | cfd63fe68d | 3 years ago |
Paul Schneider | f33ca22255 | 3 years ago |
Paul Schneider | e6f4349621 | 3 years ago |
Paul Schneider | 903f5157d2 | 3 years ago |
Paul Schneider | 066c038e4d | 3 years ago |
Paul Schneider | 95aae91156 | 3 years ago |
Paul Schneider | 6dd76ac1a5 | 3 years ago |
Paul Schneider | 459f8ea422 | 3 years ago |
Paul Schneider | 5607c53329 | 3 years ago |
Paul Schneider | 71de903f13 | 3 years ago |
Paul Schneider | a92bee32e1 | 3 years ago |
Paul Schneider | 7a835c5c95 | 3 years ago |
Paul Schneider | f918d26273 | 3 years ago |
Paul Schneider | 25d545e327 | 3 years ago |
Paul Schneider | 57feb53e82 | 3 years ago |
Paul Schneider | b7dae240cd | 3 years ago |
Paul Schneider | d8bfdc293d | 3 years ago |
Paul Schneider | f6fa7a0ec9 | 3 years ago |
Paul Schneider | 55e407d951 | 3 years ago |
Paul Schneider | cdb9a26d2c | 3 years ago |
Paul Schneider | 504f431937 | 3 years ago |
Paul Schneider | 7da74b0dfb | 3 years ago |
Paul Schneider | 6520d8e4cc | 3 years ago |
Paul Schneider | 55b74a584a | 3 years ago |
Paul Schneider | 0ec9889e96 | 3 years ago |
Paul Schneider | b17ee8be75 | 3 years ago |
Paul Schneider | f6f3473346 | 3 years ago |
Paul Schneider | ae114c68db | 3 years ago |
Paul Schneider | 5f0dfee768 | 3 years ago |
Paul Schneider | 9ee058e1c8 | 3 years ago |
Paul Schneider | 30d81c06df | 3 years ago |
Paul Schneider | 3845e2c9c4 | 3 years ago |
Paul Schneider | 74427cc15e | 3 years ago |
Paul Schneider | 5c188b57fc | 3 years ago |
Paul Schneider | 74ffc8e83e | 3 years ago |
Paul Schneider | 7f0518ec82 | 3 years ago |
Paul Schneider | 58750587d0 | 3 years ago |
Paul Schneider | bd1c47e7c6 | 3 years ago |
Paul Schneider | f7b375ad50 | 3 years ago |
Paul Schneider | 558d5fc8ae | 3 years ago |
Paul Schneider | fff4599ff4 | 3 years ago |
Paul Schneider | e356636539 | 3 years ago |
Paul Schneider | 1aef7ce614 | 3 years ago |
Paul Schneider | 82cec8eece | 3 years ago |
Paul Schneider | cd7c0be03d | 3 years ago |
Paul Schneider | a345992351 | 3 years ago |
Paul Schneider | 5e74b24439 | 3 years ago |
Paul Schneider | 451d810ade | 3 years ago |
Paul Schneider | 6f82a0a00f | 3 years ago |
Paul Schneider | 48ca2df19e | 3 years ago |
Paul Schneider | 355b2d4c7c | 3 years ago |
Paul Schneider | d33a19d35f | 3 years ago |
Paul Schneider | 5a783edac2 | 3 years ago |
Paul Schneider | 32d25733af | 3 years ago |
Paul Schneider | 709e1433bb | 3 years ago |
Paul Schneider | 476d35ae8a | 3 years ago |
Paul Schneider | 5de53a3cba | 3 years ago |
Paul Schneider | ae6abc104a | 3 years ago |
Paul Schneider | eba75d0db4 | 3 years ago |
Paul Schneider | aaa49788dc | 3 years ago |
Paul Schneider | b8809deaa1 | 3 years ago |
Paul Schneider | 6fcad7c252 | 3 years ago |
Paul Schneider | 2c31ffb7c4 | 3 years ago |
Paul Schneider | 58501329ac | 3 years ago |
Paul Schneider | 8c25889e88 | 3 years ago |
Paul Schneider | 90b8913e98 | 3 years ago |
Paul Schneider | c88dccd950 | 3 years ago |
Paul Schneider | 963ce8579c | 3 years ago |
Paul Schneider | 1c1964eb2c | 3 years ago |
Paul Schneider | a5d6e08945 | 3 years ago |
Paul Schneider | 21b51d4cbd | 3 years ago |
Paul Schneider | 27634c3159 | 3 years ago |
Paul Schneider | a11c30e782 | 3 years ago |
Paul Schneider | 5cb35f54d5 | 3 years ago |
Paul Schneider | 981f3209e0 | 3 years ago |
Paul Schneider | 3fa1241ea2 | 3 years ago |
Paul Schneider | c14adcdd80 | 3 years ago |
Paul Schneider | 25069e5aa2 | 3 years ago |
Paul Schneider | b341fdfa4d | 3 years ago |
Paul Schneider | e88763df09 | 3 years ago |
Paul Schneider | c456a28282 | 3 years ago |
Paul Schneider | f7cfeeba8d | 3 years ago |
Paul Schneider | 7752620bef | 3 years ago |
Paul Schneider | 4fa03c5a1d | 3 years ago |
Paul Schneider | 61ba3b2bf8 | 3 years ago |
Paul Schneider | 1266dd54db | 3 years ago |
Paul Schneider | be30ef3c25 | 3 years ago |
Paul Schneider | 41fbe54638 | 3 years ago |
Paul Schneider | d80271dcbf | 3 years ago |
Paul Schneider | 3a59b8304a | 3 years ago |
Paul Schneider | f6a27fa919 | 3 years ago |
Paul Schneider | e51da7f359 | 3 years ago |
Paul Schneider | e4511a8aaa | 3 years ago |
Paul Schneider | 9575dd2754 | 3 years ago |
Paul Schneider | 54a900c361 | 3 years ago |
Paul Schneider | efb004ee08 | 3 years ago |
Paul Schneider | e0a3ec0bd5 | 3 years ago |
Paul Schneider | d7cabaad8b | 3 years ago |
Paul Schneider | 9adad9a327 | 3 years ago |
Paul Schneider | 3d3a6cf017 | 3 years ago |
Paul Schneider | 2f4ff1e774 | 3 years ago |
Paul Schneider | 9289b3af91 | 3 years ago |
Paul Schneider | 90cfc29492 | 3 years ago |
Paul Schneider | c83ff84370 | 3 years ago |
Paul Schneider | d117f26c77 | 3 years ago |
Paul Schneider | c2f38800aa | 3 years ago |
Paul Schneider | a8c9b7619f | 3 years ago |
Paul Schneider | 97dec15153 | 3 years ago |
Paul Schneider | 512495d10b | 3 years ago |
Paul Schneider | 5bbcf9cb29 | 3 years ago |
Paul Schneider | b6098c28a6 | 3 years ago |
Paul Schneider | 36e1137e50 | 3 years ago |
Paul Schneider | 3086cc65c4 | 3 years ago |
Paul Schneider | 4cec5d0229 | 3 years ago |
Paul Schneider | 61dc82df5b | 3 years ago |
Paul Schneider | db6f514fb5 | 3 years ago |
Paul Schneider | cc675844b6 | 3 years ago |
Paul Schneider | f95765f541 | 3 years ago |
Paul Schneider | e5d3ba36cc | 3 years ago |
Paul Schneider | ffb7cad00a | 3 years ago |
Paul Schneider | 6a59f776d5 | 3 years ago |
Paul Schneider | 93394b3e82 | 3 years ago |
Paul Schneider | d063f10da5 | 3 years ago |
Paul Schneider | bb02706773 | 3 years ago |
Paul Schneider | 915736c4e2 | 3 years ago |
Paul Schneider | b550f05c4f | 3 years ago |
Paul Schneider | dd4dd9321b | 3 years ago |
Paul Schneider | a238bd8cbf | 3 years ago |
Paul Schneider | fb822b6aaf | 3 years ago |
Paul Schneider | ffd1dca16e | 3 years ago |
Paul Schneider | 198189ab09 | 3 years ago |
Paul Schneider | ccbdd155f3 | 3 years ago |
Paul Schneider | 445ea24dd2 | 3 years ago |
Paul Schneider | 48df937b7f | 3 years ago |
Paul Schneider | 10b1fd0748 | 3 years ago |
Paul Schneider | 15fa91138d | 3 years ago |
Paul Schneider | dd6d83cf06 | 3 years ago |
Paul Schneider | 749eb645d5 | 3 years ago |
Paul Schneider | 838de379fd | 3 years ago |
Paul Schneider | dc37c9a9f0 | 3 years ago |
Paul Schneider | a2f26f1e8e | 3 years ago |
Paul Schneider | 1b2d850522 | 3 years ago |
Paul Schneider | ec5bd7ca1f | 3 years ago |
Paul Schneider | cede04a33e | 3 years ago |
Paul Schneider | 5b6d74d8ee | 4 years ago |
@ -0,0 +1,48 @@
|
||||
{
|
||||
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
|
||||
// Pointez pour afficher la description des attributs existants.
|
||||
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": ".NET Core Attach",
|
||||
"type": "coreclr",
|
||||
"request": "attach"
|
||||
},
|
||||
{
|
||||
"name": "push",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/src/isn/bin/Debug/netcoreapp2.1/isn.dll",
|
||||
"requireExactSource": false,
|
||||
"args": [
|
||||
"push", "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/src/isn",
|
||||
"stopAtEntry": false,
|
||||
"console": "internalConsole"
|
||||
},
|
||||
{
|
||||
"name": "web",
|
||||
"type": "coreclr",
|
||||
"request": "launch",
|
||||
"preLaunchTask": "build",
|
||||
"program": "${workspaceFolder}/src/isnd/bin/Debug/netcoreapp2.1/isnd.dll",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}/src/isnd",
|
||||
"stopAtEntry": false,
|
||||
"requireExactSource": false,
|
||||
"serverReadyAction": {
|
||||
"action": "openExternally",
|
||||
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
|
||||
},
|
||||
"env": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"sourceFileMap": {
|
||||
"/Views": "${workspaceFolder}/Views"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
{
|
||||
"omnisharp.msbuild": true,
|
||||
"dotnet-test-explorer.testProjectPath": "**/*tests.csproj",
|
||||
"dotnet-test-explorer.runInParallel": false,
|
||||
"dotnet-test-explorer.showCodeLens": true,
|
||||
"dotnet-test-explorer.testArguments": "",
|
||||
"nxunitExplorer.modules": [
|
||||
"test/i*/bin/Debug/*/*.tests.dll"
|
||||
],
|
||||
"nxunitExplorer.skippattern": "",
|
||||
"dotnetCoreExplorer.runEnvVars": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Testing"
|
||||
},
|
||||
"dotnetCoreExplorer.searchpatterns": "test/**/bin/**/*.tests.{dll,exe}",
|
||||
"sqltools.connections": [
|
||||
{
|
||||
"previewLimit": 50,
|
||||
"server": "localhost",
|
||||
"port": 5432,
|
||||
"driver": "PostgreSQL",
|
||||
"name": "isndev",
|
||||
"group": "isn",
|
||||
"database": "dotnetmvc",
|
||||
"username": "dotnetmvc",
|
||||
"password": "RvJa=y#b/tfg"
|
||||
},
|
||||
{
|
||||
"previewLimit": 50,
|
||||
"server": "localhost",
|
||||
"port": 5432,
|
||||
"askForPassword": true,
|
||||
"driver": "PostgreSQL",
|
||||
"name": "isnd",
|
||||
"group": "isn",
|
||||
"database": "webid",
|
||||
"username": "webid"
|
||||
},
|
||||
{
|
||||
"previewLimit": 50,
|
||||
"server": "localhost",
|
||||
"port": 5432,
|
||||
"askForPassword": true,
|
||||
"driver": "PostgreSQL",
|
||||
"name": "isnddev",
|
||||
"group": "isn",
|
||||
"database": "isnd",
|
||||
"username": "paul"
|
||||
}
|
||||
],
|
||||
"omnisharp.disableMSBuildDiagnosticWarning": true,
|
||||
"omnisharp.enableRoslynAnalyzers": false
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace {{namespace}}
|
||||
{
|
||||
public class {{name}}
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export class {{name}} {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
Imports System
|
||||
|
||||
Namespace {{namespace}}
|
||||
|
||||
Public Class {{name}}
|
||||
|
||||
End Class
|
||||
|
||||
End Namespace
|
@ -0,0 +1,3 @@
|
||||
export default {{name}} {
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace {{namespace}}
|
||||
{
|
||||
public enum {{name}}
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace {{namespace}}
|
||||
{
|
||||
public interface {{name}}
|
||||
{
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
export interface {{name}} {
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
{
|
||||
"templates": [
|
||||
{
|
||||
"name": "Class",
|
||||
"extension": "cs",
|
||||
"file": "./class.cs-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
},
|
||||
{
|
||||
"name": "Interface",
|
||||
"extension": "cs",
|
||||
"file": "./interface.cs-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
},
|
||||
{
|
||||
"name": "Enum",
|
||||
"extension": "cs",
|
||||
"file": "./enum.cs-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
},
|
||||
{
|
||||
"name": "Class",
|
||||
"extension": "ts",
|
||||
"file": "./class.ts-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
},
|
||||
{
|
||||
"name": "Interface",
|
||||
"extension": "ts",
|
||||
"file": "./interface.ts-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
},
|
||||
{
|
||||
"name": "Default",
|
||||
"extension": "ts",
|
||||
"file": "./default.ts-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
},
|
||||
{
|
||||
"name": "Class",
|
||||
"extension": "vb",
|
||||
"file": "./class.vb-template",
|
||||
"parameters": "./template-parameters.js"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
var path = require("path");
|
||||
|
||||
module.exports = function(filename, projectPath, folderPath) {
|
||||
var namespace = "Unknown";
|
||||
if (projectPath) {
|
||||
namespace = path.basename(projectPath, path.extname(projectPath));
|
||||
if (folderPath) {
|
||||
namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, ".");
|
||||
}
|
||||
namespace = namespace.replace(/[\\\-]/g, "_");
|
||||
}
|
||||
|
||||
return {
|
||||
namespace: namespace,
|
||||
name: path.basename(filename, path.extname(filename))
|
||||
}
|
||||
};
|
@ -1,46 +0,0 @@
|
||||
|
||||
CONFIGURATION=Debug
|
||||
TARGETFV=net7.0
|
||||
|
||||
all: build-isn build-isnd
|
||||
|
||||
build-%: src/%
|
||||
dotnet build -p:Configuration=$(CONFIGURATION) $^
|
||||
|
||||
pack-%: src/%
|
||||
dotnet pack $^
|
||||
|
||||
watch:
|
||||
dotnet watch --project=src/isnd
|
||||
|
||||
test-push:
|
||||
isn push src/isn/bin/Debug/isn.*.nupkg
|
||||
|
||||
clean-%: src/%
|
||||
rm -rf $^/bin $^/obj
|
||||
|
||||
packs: pack-isn pack-isnd pack-isn.abst
|
||||
|
||||
clean: clean-isnd clean-isn clean-isn.abst
|
||||
|
||||
TARGETFRAMEWORK=net8.0
|
||||
|
||||
server-update:
|
||||
dotnet build -c Release src/isnd
|
||||
dotnet publish -c Release -f $(TARGETFRAMEWORK) src/isnd
|
||||
sudo systemctl stop isnd
|
||||
sudo cp -a src/isnd/bin/Release/$(TARGETFRAMEWORK)/publish/* /srv/www/isnd
|
||||
sudo systemctl start isnd
|
||||
|
||||
client-update:
|
||||
dotnet build -c Release src/isn
|
||||
# MAJ du client
|
||||
sudo cp -a src/isn/bin/Release/$(TARGETFRAMEWORK)/* /usr/local/lib/isn
|
||||
sudo chown -R root:root /usr/local/lib/isn
|
||||
|
||||
src/isn.abst/bin/Release/isn.abst.1.0.24.nupkg:
|
||||
dotnet pack src/isn.abst -c Release
|
||||
|
||||
push-test: src/isn.abst/bin/Release/isn.abst.1.0.24.nupkg
|
||||
isn push -s "http://localhost:3002/v3/index.json" src/isn.abst/bin/Release/isn.abst.1.0.24.nupkg
|
||||
|
@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/mono /usr/local/lib/isn/isn.exe $*
|
@ -0,0 +1,110 @@
|
||||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: isnd
|
||||
# Required-Start: $local_fs $network $named $time $syslog $postgresql
|
||||
# Required-Stop: $local_fs $network $named $time $syslog $postgresql
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Description: Script to run asp.net 5 application in background
|
||||
### END INIT INFO
|
||||
|
||||
# Author: Ivan Derevianko aka druss <drussilla7@gmail.com>
|
||||
# Modified by: Paul Schneider <redienhcs.luap@gmail.com>
|
||||
|
||||
. /lib/init/vars.sh
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
NAME=isnd
|
||||
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||
|
||||
TMP_SAVE_runlevel_VAR=$runlevel
|
||||
unset runlevel
|
||||
|
||||
running() {
|
||||
if [ -f $PIDFILE ]
|
||||
then
|
||||
PID=$(cat $PIDFILE)
|
||||
if kill -0 $PID 2>/dev/null
|
||||
then
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
export WWW_USER=www-data
|
||||
export ROOT=/srv/www/${NAME}
|
||||
export DESC="$NAME"
|
||||
export PIDFILE=/var/run/kestrel-${NAME}.pid
|
||||
export LOGDIR=/var/log
|
||||
export DOTNET_CLI_HOME=$ROOT
|
||||
export ASPDOTNETCORE_ENVIRONMENT=Production
|
||||
export ASPDOTNETCORE_LOGLEVEL=Information
|
||||
status() {
|
||||
if running;
|
||||
then
|
||||
echo "Service running $DESC ($NAME; pid: $PID)"
|
||||
else
|
||||
echo "Service stopped $DESC ($NAME)"
|
||||
fi
|
||||
echo WWW_USER: $WWW_USER ROOT:$ROOT DESC: $DESC NAME: $NAME PIDFILE: $PIDFILE LOGDIR=$LOGDIR
|
||||
}
|
||||
|
||||
|
||||
start() {
|
||||
if running; then
|
||||
echo "Service already running $DESC" "$NAME"
|
||||
log_end_msg 0
|
||||
else
|
||||
cd $ROOT
|
||||
log_daemon_msg "Starting service $NAME for user $WWW_USER"
|
||||
if ! start-stop-daemon -SbmCv -u $WWW_USER -p $PIDFILE -d $ROOT -g www-data -x /usr/bin/dotnet isnd.dll run > "${LOGDIR}/kestrel-${NAME}.log"
|
||||
then
|
||||
log_daemon_msg "Could not start $NAME : $?, see ${LOGDIR}/kestrel-${NAME}.log"
|
||||
log_end_msg 2
|
||||
else
|
||||
log_daemon_msg "Service $DESC started ($NAME), logs: ${LOGDIR}/kestrel-${NAME}.log"
|
||||
log_end_msg 0
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
stop() {
|
||||
if running
|
||||
then
|
||||
log_daemon_msg "Stopping service $NAME"
|
||||
start-stop-daemon -K -p "$PIDFILE"
|
||||
log_daemon_msg "$DESC stopped"
|
||||
log_end_msg 0
|
||||
else
|
||||
log_daemon_msg "$DESC Service not running"
|
||||
log_end_msg 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
esac
|
||||
|
||||
export runlevel=$TMP_SAVE_runlevel_VAR
|
||||
|
||||
|
@ -1,28 +0,0 @@
|
||||
[Unit]
|
||||
Description=isnd - a Nuget package repository daemon
|
||||
After=syslog.target
|
||||
After=network.target
|
||||
|
||||
Wants=postgresql.service
|
||||
After=postgresql.service
|
||||
|
||||
[Service]
|
||||
RestartSec=5s
|
||||
Type=simple
|
||||
User=isn
|
||||
Group=isn
|
||||
WorkingDirectory=/srv/www/isnd/
|
||||
ExecStart=/srv/www/isnd/isnd
|
||||
Restart=always
|
||||
Environment="HOME=/srv/www/isnd"
|
||||
Environment="ASPNETCORE_ENVIRONMENT=Production"
|
||||
Environment="ASPNETCORE_ConnectionStrings__DefaultConnection=Server=localhost;Port=5432;Database=isnd;Username=paul;Password=RvJa=y#b/tfg;"
|
||||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
StandardOutput=syslog
|
||||
StandardError=syslog
|
||||
SyslogIdentifier=isnd
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
# compiler tout
|
||||
dotnet build -c Release
|
||||
dotnet publish -c Release -f netcoreapp2.1 src/isnd
|
||||
# MAJ du serveur
|
||||
sudo systemctl stop isnd
|
||||
sudo cp -a src/isnd/bin/Release/netcoreapp2.1/publish/* /srv/www/isnd
|
||||
sudo systemctl start isnd
|
||||
# MAJ du client
|
||||
sudo cp -a src/isn/bin/Release/netcoreapp2.1/* /usr/local/lib/isn
|
||||
sudo chown -R root.root /usr/local/lib/isn
|
@ -1,41 +1,30 @@
|
||||
{
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"codecov.tool": {
|
||||
"version": "1.13.0",
|
||||
"commands": [
|
||||
"codecov"
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"gitversion.tool": {
|
||||
"version": "5.10.1",
|
||||
"commands": [
|
||||
"dotnet-gitversion"
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"gitreleasemanager.tool": {
|
||||
"version": "0.13.0",
|
||||
"commands": [
|
||||
"dotnet-gitreleasemanager"
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"Wyam2.Tool": {
|
||||
"version": "3.0.0-rc3",
|
||||
"commands": [
|
||||
"wyam2"
|
||||
],
|
||||
"rollForward": false
|
||||
},
|
||||
"dotnet-ef": {
|
||||
"version": "8.0.7",
|
||||
"commands": [
|
||||
"dotnet-ef"
|
||||
],
|
||||
"rollForward": false
|
||||
"version": 1,
|
||||
"isRoot": true,
|
||||
"tools": {
|
||||
"codecov.tool": {
|
||||
"version": "1.13.0",
|
||||
"commands": [
|
||||
"codecov"
|
||||
]
|
||||
},
|
||||
"gitversion.tool": {
|
||||
"version": "5.10.1",
|
||||
"commands": [
|
||||
"dotnet-gitversion"
|
||||
]
|
||||
},
|
||||
"gitreleasemanager.tool": {
|
||||
"version": "0.13.0",
|
||||
"commands": [
|
||||
"dotnet-gitreleasemanager"
|
||||
]
|
||||
},
|
||||
"Wyam2.Tool": {
|
||||
"version": "3.0.0-rc3",
|
||||
"commands": [
|
||||
"wyam2"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
drop table "AspNetRoleClaims" ;
|
||||
drop table "AspNetUserRoles" ;
|
||||
drop table "AspNetRoles" ;
|
||||
drop table "AspNetUserClaims" ;
|
||||
drop table "AspNetUserTokens" ;
|
||||
drop table "PackageVersions" ;
|
||||
drop table "Packages" ;
|
||||
drop table "Commits" ;
|
||||
drop table "ApiKeys" ;
|
||||
drop table "AspNetUserLogins" ;
|
||||
drop table "AspNetUsers" ;
|
||||
drop table "__EFMigrationsHistory" ;
|
@ -1,11 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
public class APIKO
|
||||
{
|
||||
public string Context { get; set; }
|
||||
public Dictionary<string, string[]> Errors { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,23 +1,21 @@
|
||||
using System;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Entities
|
||||
{
|
||||
public static class ApiConfig
|
||||
{
|
||||
public const string Index = "/index.json";
|
||||
public const string Catalog = "/catalog";
|
||||
public const string Package = "/package";
|
||||
public const string Search = "/search";
|
||||
public const string AutoComplete = "/autocomplete";
|
||||
public const string Registration = "/registration";
|
||||
|
||||
public const string Nuspec = "/nuspec";
|
||||
public const string Content = "/content";
|
||||
public const string Nuget = "/nuget";
|
||||
|
||||
[Obsolete("use the V3 search")]
|
||||
|
||||
public const string V2Find = "/v2/FindPackagesById()"; // /FindPackagesById()??$filter=IsLatestVersion&$orderby=Version desc&$top=1&id='isn.abst'
|
||||
public const string Publish = "put";
|
||||
public const string Index = "index";
|
||||
public const string IndexDotJson = Index + ".json";
|
||||
public const string Catalog = "catalog";
|
||||
public const string CatalogPage = "catalog-page";
|
||||
public const string GetPackage = Constants.PaquetFileEstension;
|
||||
public const string GetVersion = "version";
|
||||
public const string Search = "search";
|
||||
public const string AutoComplete = "autocomplete";
|
||||
public const string CatalogLeaf = "catalog-leaf";
|
||||
public const string Delete = "delete";
|
||||
public const string Registration = "registration";
|
||||
internal const string GetNuspec = Constants.SpecFileEstension;
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public abstract class Permalink
|
||||
{
|
||||
public Permalink(string id)
|
||||
{
|
||||
Type = GetType().Name;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Permalink(string id, string type)
|
||||
{
|
||||
Type = type;
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
[JsonProperty("@type")]
|
||||
public virtual string Type { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("@id")]
|
||||
public string Id { get => id; }
|
||||
protected string id;
|
||||
|
||||
public string GetId() { return id; }
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj!=null)
|
||||
{
|
||||
if (GetType().IsAssignableFrom(obj.GetType()))
|
||||
{
|
||||
var rpobj = (Permalink) obj;
|
||||
return this.id == rpobj.id;
|
||||
}
|
||||
}
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return id.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
public interface IDataProtector
|
||||
{
|
||||
string Protect(string data);
|
||||
string UnProtect(string data);
|
||||
}
|
||||
|
||||
public class DefaultDataProtector : IDataProtector
|
||||
{
|
||||
private byte delta = 145;
|
||||
|
||||
public DefaultDataProtector()
|
||||
{
|
||||
|
||||
}
|
||||
public string Protect(string data)
|
||||
{
|
||||
List<Byte> protd = new List<byte>();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (byte c in Encoding.UTF8.GetBytes(data))
|
||||
{
|
||||
protd.Add((byte) (c ^ delta));
|
||||
}
|
||||
return System.Convert.ToBase64String(protd.ToArray());
|
||||
}
|
||||
|
||||
public string UnProtect(string data)
|
||||
{
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
List<byte> unps = new List<byte>();
|
||||
|
||||
foreach (byte c in System.Convert.FromBase64CharArray(data.ToCharArray(),0,data.Length))
|
||||
{
|
||||
unps.Add((byte) (c ^ delta));
|
||||
}
|
||||
return Encoding.UTF8.GetString(unps.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace isn
|
||||
{
|
||||
public class IsnSourceSettings
|
||||
{
|
||||
internal string Source { get; set; }
|
||||
|
||||
internal string[] Keys { get; set; }
|
||||
}
|
||||
}
|
@ -1,92 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
public class SourceSettings
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Protected API Key
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string ProtectedApiKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Key alias
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string Url { get; set; }
|
||||
|
||||
public SourceSettings()
|
||||
{
|
||||
}
|
||||
|
||||
public string GetClearApiKey(RSA rsa)
|
||||
{
|
||||
var decrypted = rsa.Decrypt(System.Convert.FromBase64String(ProtectedApiKey), RSAEncryptionPadding.Pkcs1);
|
||||
return Encoding.Default.GetString(decrypted);
|
||||
}
|
||||
|
||||
public void SetApiKey(RSA rsa, string key)
|
||||
{
|
||||
var ciphered =rsa.Encrypt(Encoding.Default.GetBytes(key), RSAEncryptionPadding.Pkcs1);
|
||||
ProtectedApiKey = System.Convert.ToBase64String(ciphered);
|
||||
}
|
||||
public string ApiKey { get; set; }
|
||||
public string Alias { get; set; }
|
||||
}
|
||||
|
||||
public class Settings
|
||||
{
|
||||
private Settings()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public static Settings Create()
|
||||
{
|
||||
var rsaParams = CreateCipheringParameters();
|
||||
return new Settings {
|
||||
RSAParameters = rsaParams,
|
||||
Sources = new Dictionary<string, SourceSettings>()
|
||||
};
|
||||
}
|
||||
|
||||
public RSAParameters RSAParameters { get; set; }
|
||||
public string DataProtectionTitle {get; set; }
|
||||
public Dictionary<string, SourceSettings> Sources { get; set; }
|
||||
|
||||
private string defSourceKey;
|
||||
|
||||
/// <summary>
|
||||
/// Default source by its alias
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string DefaultSourceKey
|
||||
{
|
||||
get => defSourceKey;
|
||||
set
|
||||
{
|
||||
defSourceKey = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[JsonIgnore, NotMapped]
|
||||
public string CurrentSourceKey {get; set;}
|
||||
|
||||
private static RSAParameters CreateCipheringParameters()
|
||||
{
|
||||
var provider = new RSACryptoServiceProvider(2048);
|
||||
return provider.ExportParameters(true);
|
||||
}
|
||||
|
||||
[JsonIgnore, NotMapped]
|
||||
public SourceSettings CurrentSource
|
||||
{
|
||||
get => this.Sources[CurrentSourceKey];
|
||||
}
|
||||
public bool AutoUpdateApiKey { get; set; } = false;
|
||||
public string DefaultSource { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
public class UploadFilesToServerUsingWebRequest
|
||||
{
|
||||
public void UploadFilesToServer(PushReport report, Uri uri, FileInfo fi,
|
||||
string apikey)
|
||||
{
|
||||
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
|
||||
const int TXLEN = 0x1000;
|
||||
/// the form-data file upload, properly formatted
|
||||
string fileheaderTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";
|
||||
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
// "X-NuGet-ApiKey
|
||||
string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
|
||||
string fileheader = string.Format(fileheaderTemplate, "file", fi.Name, "application/octet-stream");
|
||||
byte[] fileheaderbytes = Encoding.ASCII.GetBytes(fileheader);
|
||||
var boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
|
||||
var endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--");
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
|
||||
|
||||
httpWebRequest.Method = "PUT";
|
||||
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||
httpWebRequest.AllowAutoRedirect = false;
|
||||
httpWebRequest.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
|
||||
httpWebRequest.Headers.Add("X-NuGet-ApiKey", apikey);
|
||||
httpWebRequest.ContentLength = boundarybytes.Length +
|
||||
fileheaderbytes.Length + fi.Length + endBoundaryBytes.Length;
|
||||
|
||||
|
||||
httpWebRequest.BeginGetRequestStream(async (result) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
|
||||
|
||||
using (Stream requestStream = request.EndGetRequestStream(result))
|
||||
{
|
||||
await WriteToStream(requestStream, boundarybytes, boundarybytes.Length);
|
||||
await WriteToStream(requestStream, fileheaderbytes, fileheaderbytes.Length);
|
||||
using (var fss = fi.OpenRead())
|
||||
{
|
||||
byte[] buffer = new byte[TXLEN];
|
||||
var form_bytes_read = fss.Read(buffer, 0, TXLEN);
|
||||
while (form_bytes_read > 0)
|
||||
{
|
||||
await WriteToStream(requestStream, buffer, form_bytes_read);
|
||||
form_bytes_read = fss.Read(buffer, 0, TXLEN);
|
||||
}
|
||||
}
|
||||
requestStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
||||
requestStream.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception rex)
|
||||
{
|
||||
report.Executed = false;
|
||||
report.StackTrace = rex.StackTrace;
|
||||
report.Message = rex.Message;
|
||||
Console.Error.WriteLine("Stack trace:");
|
||||
Console.Error.WriteLine(rex.StackTrace);
|
||||
WebResponse eresp = httpWebRequest.GetResponse();
|
||||
if (!CheckResponse(eresp, report))
|
||||
throw new Exception("Invalid server response type");
|
||||
|
||||
}
|
||||
}, httpWebRequest);
|
||||
|
||||
WebResponse resp = httpWebRequest.GetResponse();
|
||||
if (!CheckResponse(resp, report)) throw new Exception("Invalid server response type");
|
||||
if (Program.Settings.AutoUpdateApiKey)
|
||||
Program.EnsureKeyStored();
|
||||
|
||||
}
|
||||
|
||||
static bool CheckResponse(WebResponse resp, PushReport report)
|
||||
{
|
||||
Stream stream = resp.GetResponseStream();
|
||||
StreamReader re = new StreamReader(stream);
|
||||
if (resp is HttpWebResponse)
|
||||
{
|
||||
if (resp.ContentType == "text/json")
|
||||
{
|
||||
String json = re.ReadToEnd();
|
||||
report.Message = json;
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK;
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Creates HTTP POST request & uploads database to server. Author : Farhan Ghumra
|
||||
/// </summary>
|
||||
internal async Task UploadFilesToServerAsync(PushReport report, Uri uri, FileInfo fi,
|
||||
string apikey)
|
||||
{
|
||||
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
|
||||
const int TXLEN = 0x1000;
|
||||
/// the form-data file upload, properly formatted
|
||||
string fileheaderTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";
|
||||
|
||||
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
|
||||
|
||||
// "X-NuGet-ApiKey
|
||||
string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
|
||||
string fileheader = string.Format(fileheaderTemplate, "file", fi.Name, "application/octet-stream");
|
||||
byte[] fileheaderbytes = Encoding.ASCII.GetBytes(fileheader);
|
||||
var boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
|
||||
var endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--");
|
||||
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
|
||||
|
||||
httpWebRequest.Method = "PUT";
|
||||
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
|
||||
httpWebRequest.AllowAutoRedirect = false;
|
||||
httpWebRequest.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
|
||||
httpWebRequest.Headers.Add("X-NuGet-ApiKey", apikey);
|
||||
httpWebRequest.ContentLength = boundarybytes.Length +
|
||||
fileheaderbytes.Length + fi.Length + endBoundaryBytes.Length;
|
||||
|
||||
|
||||
httpWebRequest.BeginGetRequestStream(async (result) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
|
||||
|
||||
using (Stream requestStream = request.EndGetRequestStream(result))
|
||||
{
|
||||
await WriteToStream(requestStream, boundarybytes, boundarybytes.Length);
|
||||
await WriteToStream(requestStream, fileheaderbytes, fileheaderbytes.Length);
|
||||
using (var fss = fi.OpenRead())
|
||||
{
|
||||
byte[] buffer = new byte[TXLEN];
|
||||
var form_bytes_read = fss.Read(buffer, 0, TXLEN);
|
||||
while (form_bytes_read > 0)
|
||||
{
|
||||
await WriteToStream(requestStream, buffer, form_bytes_read);
|
||||
form_bytes_read = fss.Read(buffer, 0, TXLEN);
|
||||
}
|
||||
}
|
||||
requestStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
|
||||
requestStream.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception rex)
|
||||
{
|
||||
report.Message = rex.Message;
|
||||
Console.Error.WriteLine(rex.Message);
|
||||
Console.Error.WriteLine("Stack trace:");
|
||||
Console.Error.WriteLine(rex.StackTrace);
|
||||
throw;
|
||||
}
|
||||
}, httpWebRequest);
|
||||
|
||||
WebResponse resp = await httpWebRequest.GetResponseAsync();
|
||||
|
||||
Stream stream = resp.GetResponseStream();
|
||||
StreamReader re = new StreamReader(stream);
|
||||
if (resp is HttpWebResponse)
|
||||
{
|
||||
String json = await re.ReadToEndAsync();
|
||||
report.Message = json;
|
||||
var hrep = resp as HttpWebResponse;
|
||||
report.StatusCode = hrep.StatusCode.ToString();
|
||||
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|
||||
|| hrep.StatusCode == HttpStatusCode.OK;
|
||||
}
|
||||
else throw new Exception("Invalid server response type");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes byte array to stream. Author : Farhan Ghumra
|
||||
/// </summary>
|
||||
private static async Task WriteToStream(Stream s, byte[] bytes, int len)
|
||||
{
|
||||
await s.WriteAsync(bytes, 0, len);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
|
||||
private static void StoreApiKey(IEnumerable<string> storeArgs)
|
||||
{
|
||||
var args = storeoptions.Parse(storeArgs);
|
||||
if (shouldShowPushHelp)
|
||||
{
|
||||
// output the options
|
||||
Console.Error.WriteLine("Push Options:");
|
||||
storeoptions.WriteOptionDescriptions(Console.Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
apiKey = args[0];
|
||||
EnsureKeyStored();
|
||||
}
|
||||
}
|
||||
|
||||
public static void EnsureKeyStored()
|
||||
{
|
||||
if (currentSource == null)
|
||||
{
|
||||
if (Settings.DefaultSource == null)
|
||||
return;
|
||||
currentSource = Settings.DefaultSource;
|
||||
}
|
||||
|
||||
if (Settings.Sources.ContainsKey(currentSource))
|
||||
{
|
||||
if (apiKey == null)
|
||||
{
|
||||
// Une suppression
|
||||
Settings.Sources.Remove(currentSource);
|
||||
if (Settings.DefaultSource == currentSource) Settings.DefaultSource = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Une mise À jour
|
||||
string ptd = Protector.Protect(apiKey);
|
||||
Settings.Sources[currentSource].ApiKey = ptd;
|
||||
if (Settings.DefaultSource == null) Settings.DefaultSource = currentSource;
|
||||
}
|
||||
}
|
||||
else if (apiKey != null)
|
||||
{
|
||||
// une addition
|
||||
string ptd = Protector.Protect(apiKey);
|
||||
Settings.Sources.Add(currentSource, new SourceSettings { ApiKey = ptd });
|
||||
}
|
||||
SaveConfig();
|
||||
}
|
||||
public static void SaveConfig()
|
||||
{
|
||||
FileInfo cfgSettingIf = new FileInfo(_configFileName);
|
||||
if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create();
|
||||
File.WriteAllText(
|
||||
cfgSettingIf.FullName,
|
||||
JsonConvert.SerializeObject(
|
||||
Settings,
|
||||
Formatting.Indented
|
||||
));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
|
||||
namespace isn
|
||||
{
|
||||
|
||||
partial class Program
|
||||
{
|
||||
private static void StoreApiKey(IEnumerable<string> storeArgs)
|
||||
{
|
||||
var args = storeoptions.Parse(storeArgs);
|
||||
if (args.Count != 1)
|
||||
{
|
||||
Console.Error.WriteLine("StoreApiKey command takes only one argument, the key.");
|
||||
shouldShowPushHelp=true;
|
||||
}
|
||||
if (shouldShowPushHelp)
|
||||
{
|
||||
// output the options
|
||||
Console.Error.WriteLine("StoreApiKey Options:");
|
||||
storeoptions.WriteOptionDescriptions(Console.Out);
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Sources[Settings.CurrentSourceKey].SetApiKey(Program.rsa, args[0]);
|
||||
SaveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public static void SaveConfig()
|
||||
{
|
||||
FileInfo cfgSettingIf = new FileInfo(_configFileName);
|
||||
if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create();
|
||||
File.WriteAllText(
|
||||
cfgSettingIf.FullName,
|
||||
JsonConvert.SerializeObject(
|
||||
Settings,
|
||||
Formatting.Indented
|
||||
));
|
||||
Console.WriteLine("config saved .");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,42 +1,15 @@
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isn
|
||||
{
|
||||
public class PushReport
|
||||
{
|
||||
public PushReport()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string PkgName { get; set; }
|
||||
public bool Executed { get; set; }
|
||||
public bool OK { get; set; }
|
||||
public bool AlreadyPresent { get; set; }
|
||||
public string Message { get; set; }
|
||||
public string StatusCode { get; set; }
|
||||
public string StackTrace { get; set; }
|
||||
public APIKO KO { get; set; }
|
||||
|
||||
public string ToDoc()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder($"= push {PkgName}\n\n");
|
||||
if (Executed) sb.AppendLine("* Executed");
|
||||
if (OK) sb.AppendLine("* OK");
|
||||
if (!string.IsNullOrWhiteSpace(Message))
|
||||
sb.AppendLine("* Message :" + Message);
|
||||
if (!string.IsNullOrWhiteSpace(StatusCode))
|
||||
sb.AppendLine($"* Status Code : ");
|
||||
if (!string.IsNullOrWhiteSpace(StackTrace))
|
||||
sb.AppendLine($"* StackTrace : " + StackTrace);
|
||||
if (KO!=null)
|
||||
sb.AppendLine($"* KO : " + KO.Context);
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
public bool Executed { get; internal set; }
|
||||
public bool OK { get; internal set; }
|
||||
public bool AlreadyPresent { get; internal set; }
|
||||
public string Message { get; internal set; }
|
||||
public string StatusCode { get; internal set; }
|
||||
public string StackTrace { get; internal set; }
|
||||
}
|
||||
}
|
@ -1,39 +1,31 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Data;
|
||||
using isnd.Entities;
|
||||
using Unleash;
|
||||
using isnd.Services;
|
||||
using isnd.ViewModels;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Interfaces;
|
||||
using isn.Abstract;
|
||||
using isn.abst;
|
||||
using isnd.Interfaces;
|
||||
using System.Linq;
|
||||
using isnd.Entities;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
/// <summary>
|
||||
/// Api Controller
|
||||
/// </summary>
|
||||
public class ApiController : Controller
|
||||
public partial class PackagesController : Controller
|
||||
{
|
||||
private readonly IPackageManager packageManager;
|
||||
private readonly Resource[] resources;
|
||||
|
||||
/// <summary>
|
||||
/// Api Controller Constructor
|
||||
/// </summary>
|
||||
/// <param name="pm"></param>
|
||||
public ApiController(IPackageManager pm)
|
||||
{
|
||||
packageManager = pm;
|
||||
resources = packageManager.GetResources().ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// API index
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Index)]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.IndexDotJson)]
|
||||
public IActionResult ApiIndex()
|
||||
{
|
||||
return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl){ Version = PackageManager.BASE_API_LEVEL, Resources = resources });
|
||||
return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = resources });
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,14 @@
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// GET /autocomplete?id=isn.protocol&prerelease=true
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.AutoComplete)]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.AutoComplete)]
|
||||
public IActionResult AutoComplete(
|
||||
string id,
|
||||
string semVerLevel,
|
@ -0,0 +1,69 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Services;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Catalog)]
|
||||
public IActionResult CatalogIndex()
|
||||
{
|
||||
return Ok(PackageManager.CurrentCatalogIndex);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogPage + "-{id}")]
|
||||
public IActionResult Index(string id)
|
||||
{
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/index.json")]
|
||||
public async Task<IActionResult> CatalogRegistrationAsync(string apiVersion, string id)
|
||||
{
|
||||
var pkgs = packageManager.SearchById(id, null, null);
|
||||
if (pkgs == null) return NotFound();
|
||||
return Ok(pkgs);
|
||||
}
|
||||
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{lower}/index.json")]
|
||||
public async Task<IActionResult> CatalogLeafAsync(string id, string pversion, string lower)
|
||||
{
|
||||
|
||||
bool askForindex = lower == null;
|
||||
if (false)
|
||||
{
|
||||
if (!NuGetVersion.TryParse(lower, out NuGetVersion version))
|
||||
return BadRequest(lower);
|
||||
|
||||
var pkgFromname = packageManager.GetVersions(id, version, true);
|
||||
if (pkgFromname == null) return NotFound();
|
||||
return Ok(pkgFromname);
|
||||
}
|
||||
var pkgvs = this.packageManager.GetCatalogLeaf(id, pversion, lower).ToArray();
|
||||
if (pkgvs.Count() == 0) return NotFound();
|
||||
List<string> types = pkgvs.Select(
|
||||
v => v.Type ?? "Dependency"
|
||||
).Distinct().ToList();
|
||||
if (!types.Contains("PackageDelete"))
|
||||
types.Add("PackageDetails");
|
||||
var last = pkgvs.Last();
|
||||
var pub = last.LatestCommit.CommitTimeStamp;
|
||||
return Ok(new Data.Packages.Catalog.CatalogLeaf
|
||||
{
|
||||
CommitId = last.CommitId,
|
||||
Id = id,
|
||||
CommitTimeStamp = pub,
|
||||
Version = last.FullString,
|
||||
Published = pub,
|
||||
RefType = types.ToArray()
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Attributes;
|
||||
using isnd.Entities;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// Web get the paquet
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
|
||||
+ Constants.PaquetFileEstension)]
|
||||
public IActionResult GetPackage(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
[FromRoute] string idf, [FromRoute] string lowerf)
|
||||
{
|
||||
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
id, lower, $"{id}-{lower}." + Constants.PaquetFileEstension
|
||||
);
|
||||
|
||||
FileInfo pkgfi = new FileInfo(pkgpath);
|
||||
|
||||
if (!pkgfi.Exists)
|
||||
{
|
||||
return BadRequest("!pkgfi.Exists");
|
||||
}
|
||||
return File(pkgfi.OpenRead(), "application/zip; charset=binary");
|
||||
}
|
||||
|
||||
// Web get spec
|
||||
[HttpGet(_pkgRootPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
|
||||
+ Constants.SpecFileEstension)]
|
||||
public IActionResult GetNuspec(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
[FromRoute][SafeName][Required] string idf,
|
||||
[FromRoute][SafeName][Required] string lowerf)
|
||||
{
|
||||
var pkgpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
id, lower, $"{id}." + Constants.SpecFileEstension);
|
||||
|
||||
FileInfo pkgfi = new FileInfo(pkgpath);
|
||||
if (!pkgfi.Exists)
|
||||
{
|
||||
return BadRequest("!pkgfi.Exists");
|
||||
}
|
||||
|
||||
return File(pkgfi.OpenRead(), "text/xml; charset=utf-8");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Entities;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
[HttpGet("~" + ApiConfig.V2Find)]
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.IndexDotJson)]
|
||||
public IActionResult GetVersions(
|
||||
string id,
|
||||
string lower,
|
@ -1,42 +0,0 @@
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Catalog)]
|
||||
public async Task<IActionResult> CatalogIndex()
|
||||
{
|
||||
return Ok(await packageManager.GetCatalogIndexAsync());
|
||||
}
|
||||
|
||||
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Content + "/{id}/{version}.json")]
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Registration + "/{id}/{version}.json")]
|
||||
public async Task<IActionResult> CatalogRegistration(string id, string version)
|
||||
{
|
||||
if ("index" == version)
|
||||
{
|
||||
var query = new Data.Catalog.PackageRegistrationQuery
|
||||
{
|
||||
Query = id,
|
||||
Prerelease = true
|
||||
};
|
||||
var index = await packageManager.GetPackageRegistrationIndexAsync(query);
|
||||
if (index == null) return NotFound();
|
||||
|
||||
return Ok(index);
|
||||
}
|
||||
// return a Package
|
||||
var leaf = await packageManager.GetCatalogEntryAsync(id, version, null);
|
||||
|
||||
if (null == leaf) return NotFound(new { id, version });
|
||||
return Ok(leaf);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.IO;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Attributes;
|
||||
using isnd.Entities;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
public partial class PackagesController
|
||||
{
|
||||
// Web get the paquet
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuget + "/{id}/{lower}/{idf}-{lowerFromName}."
|
||||
+ Constants.PacketFileExtension)]
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Content + "/{id}/{lower}/{idf}-{lowerFromName}."
|
||||
+ Constants.PacketFileExtension)]
|
||||
public IActionResult GetPackage(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
[FromRoute] string idf, [FromRoute] string lowerFromName)
|
||||
{
|
||||
var pkgPath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
id, lower, $"{id}-{lower}." + Constants.PacketFileExtension
|
||||
);
|
||||
|
||||
FileInfo pkgFileInfo = new FileInfo(pkgPath);
|
||||
|
||||
if (!pkgFileInfo.Exists)
|
||||
{
|
||||
return BadRequest("!pkgFileInfo.Exists");
|
||||
}
|
||||
return File(pkgFileInfo.OpenRead(), "application/zip; charset=binary");
|
||||
}
|
||||
|
||||
// Web get spec
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuspec + "/{id}/{lower}/{idf}-{lowerFromName}."
|
||||
+ Constants.SpecFileExtension)]
|
||||
public IActionResult GetNuspec(
|
||||
[FromRoute][SafeName][Required] string id,
|
||||
[FromRoute][SafeName][Required] string lower,
|
||||
[FromRoute][SafeName][Required] string idf,
|
||||
[FromRoute][SafeName][Required] string lowerFromName)
|
||||
{
|
||||
var pkgPath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
id, lower, $"{id}." + Constants.SpecFileExtension);
|
||||
|
||||
FileInfo pkgFileInfo = new FileInfo(pkgPath);
|
||||
if (!pkgFileInfo.Exists)
|
||||
{
|
||||
return BadRequest("!pkgFileInfo.Exists");
|
||||
}
|
||||
|
||||
return File(pkgFileInfo.OpenRead(), "text/xml; charset=utf-8");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,54 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using isn.abst;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// TODO [Authorize(Policy = IsndConstants.RequireValidApiKey)]
|
||||
[HttpPut("~" + Constants.ApiVersionPrefix + ApiConfig.Package)]
|
||||
public async Task<IActionResult> Put()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientVersionId = Request.Headers["X-NuGet-Client-Version"];
|
||||
string apiKey = Request.Headers["X-NuGet-ApiKey"][0];
|
||||
ViewData["versionId"] = typeof(PackagesController).Assembly.FullName;
|
||||
var files = new List<string>();
|
||||
ViewData["files"] = files;
|
||||
|
||||
var clearKey = protector.Unprotect(apiKey);
|
||||
var dbApiKey = dbContext.ApiKeys.SingleOrDefault(k => k.Id == clearKey);
|
||||
if (dbApiKey == null)
|
||||
{
|
||||
logger.LogError("403 : no api-key");
|
||||
return Unauthorized();
|
||||
}
|
||||
foreach (IFormFile file in Request.Form.Files)
|
||||
{
|
||||
var version = await packageManager.PutPackageAsync(file.OpenReadStream(), dbApiKey.UserId);
|
||||
logger.LogInformation($"new package : {version.PackageId} {version.NugetLink}");
|
||||
}
|
||||
return Ok();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
var message = $"PUT exception : {ex.Message} ({ex.GetType().Name})";
|
||||
logger.LogError(message);
|
||||
logger.LogError("Stack Trace : " + ex.StackTrace);
|
||||
return new ObjectResult(new { ViewData, message })
|
||||
{ StatusCode = 500 };
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Entities;
|
||||
using isn.abst;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Data.Catalog;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
// TODO /search GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// Web get the paquet
|
||||
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Search)]
|
||||
[HttpHead("~" + Constants.ApiVersionPrefix + ApiConfig.Search)]
|
||||
[HttpHead("~" + ApiConfig.V2Find)]
|
||||
public async Task<IActionResult> Search(
|
||||
string q=null,
|
||||
int skip=0,
|
||||
int take=25,
|
||||
bool prerelease=false,
|
||||
string semVerLevel = "2.0.0",
|
||||
string packageType = "Dependency")
|
||||
{
|
||||
PackageRegistrationQuery query = new PackageRegistrationQuery
|
||||
{
|
||||
Prerelease= prerelease,
|
||||
Query = q,
|
||||
Skip = skip,
|
||||
Take = take
|
||||
};
|
||||
var result = await packageManager.SearchPackageAsync(query);
|
||||
|
||||
return Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isn.abst;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Entities;
|
||||
using isnd.Helpers;
|
||||
using isnd.ViewModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Components.Web.Virtualization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// Web search
|
||||
public async Task<IActionResult> Index(PackageRegistrationQuery model)
|
||||
{
|
||||
var pkgs = await packageManager.SearchPackageAsync(model);
|
||||
var result = new RegistrationPageIndexQueryAndResult
|
||||
{
|
||||
Source = packageManager.CatalogBaseUrl+ApiConfig.Index,
|
||||
Query = model
|
||||
};
|
||||
List<PackageRegistration> registrations = new List<PackageRegistration>();
|
||||
foreach (var pk in pkgs.data.GroupBy(x => x.PackageId))
|
||||
{
|
||||
registrations.Add(new PackageRegistration(apiBase, pk.Key, pkgs.GetResults().Single(p=>p.Id == pk.Key).Versions));
|
||||
}
|
||||
|
||||
return View(new RegistrationPageIndexQueryAndResult
|
||||
{
|
||||
Source = packageManager.CatalogBaseUrl+ApiConfig.Index,
|
||||
Query = model,
|
||||
Result = registrations.ToArray()
|
||||
});
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Details(PackageDetailViewModel model)
|
||||
{
|
||||
if (model.pkgid == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var packageVersion = dbContext.PackageVersions
|
||||
.Include(p=>p.LatestCommit)
|
||||
.Include(p => p.Package)
|
||||
.Where(m => m.PackageId == model.pkgid)
|
||||
.OrderByDescending(p => p)
|
||||
;
|
||||
|
||||
if (packageVersion.Count() == 0)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
bool results = await packageVersion.AnyAsync();
|
||||
model.latest = await packageVersion.FirstAsync();
|
||||
model.totalHits = packageVersion.Count();
|
||||
model.data = packageVersion.Take(MAX_PKG_VERSION_LIST).ToArray();
|
||||
|
||||
return View("Details", model);
|
||||
}
|
||||
const int MAX_PKG_VERSION_LIST = 50;
|
||||
|
||||
[Authorize, HttpGet]
|
||||
public async Task<IActionResult> Delete(string pkgid, string version, string pkgtype)
|
||||
{
|
||||
if (pkgid == null || version == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var packageVersion = await dbContext.PackageVersions.Include(p => p.Package)
|
||||
.FirstOrDefaultAsync(m => m.PackageId == pkgid && m.FullString == version
|
||||
&& (pkgtype!=null && m.Type == pkgtype || m.Type != "Delete" ));
|
||||
if (packageVersion == null) return NotFound();
|
||||
if (!User.IsOwner(packageVersion)) return Unauthorized();
|
||||
var pkg = await packageManager.GetPackageAsync(pkgid, version, pkgtype);
|
||||
return View(pkg);
|
||||
}
|
||||
|
||||
// POST: PackageVersion/Delete/5
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken][Authorize]
|
||||
public async Task<IActionResult> DeleteConfirmed(string pkgid, string version,
|
||||
string type)
|
||||
{
|
||||
var packageVersion = await dbContext.PackageVersions
|
||||
.Include(pv => pv.Package)
|
||||
.Where(m => m.PackageId == pkgid
|
||||
&& m.FullString == version && (type==null || m.Type == type))
|
||||
.ToArrayAsync();
|
||||
if (packageVersion.Length==0) return NotFound();
|
||||
if (!User.IsOwner(packageVersion.First())) return Unauthorized();
|
||||
await packageManager.DeletePackageAsync(pkgid, version, type);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,220 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NuGet.Packaging.Core;
|
||||
using NuGet.Versioning;
|
||||
using isnd.Data;
|
||||
using isnd.Helpers;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using isn.abst;
|
||||
using isnd.Data.Packages;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
|
||||
[HttpPut(_pkgRootPrefix + ApiConfig.Publish)]
|
||||
public async Task<IActionResult> Put()
|
||||
{
|
||||
try
|
||||
{
|
||||
var clientVersionId = Request.Headers["X-NuGet-Client-Version"];
|
||||
string apiKey = Request.Headers["X-NuGet-ApiKey"][0];
|
||||
ViewData["versionId"] = typeof(PackagesController).Assembly.FullName;
|
||||
var files = new List<string>();
|
||||
ViewData["files"] = files;
|
||||
|
||||
var clearkey = protector.Unprotect(apiKey);
|
||||
var apikey = dbContext.ApiKeys.SingleOrDefault(k => k.Id == clearkey);
|
||||
if (apikey == null)
|
||||
{
|
||||
logger.LogError("403 : no api-key");
|
||||
return Unauthorized();
|
||||
}
|
||||
Commit commit = new Commit
|
||||
{
|
||||
Action = PackageAction.PublishPackage,
|
||||
TimeStamp = DateTime.Now
|
||||
};
|
||||
dbContext.Commits.Add(commit);
|
||||
|
||||
foreach (IFormFile file in Request.Form.Files)
|
||||
{
|
||||
string initpath = Path.Combine(Environment.GetEnvironmentVariable("TEMP") ??
|
||||
Environment.GetEnvironmentVariable("TMP") ?? "/tmp",
|
||||
$"isn-{Guid.NewGuid()}."+Constants.PaquetFileEstension);
|
||||
|
||||
using (FileStream fw = new FileStream(initpath, FileMode.Create))
|
||||
{
|
||||
file.CopyTo(fw);
|
||||
}
|
||||
|
||||
using (FileStream fw = new FileStream(initpath, FileMode.Open))
|
||||
{
|
||||
var archive = new ZipArchive(fw);
|
||||
|
||||
var spec = archive.Entries.FirstOrDefault(e => e.FullName.EndsWith("." + Constants.SpecFileEstension));
|
||||
if (spec == null) return BadRequest(new { error = "no " + Constants.SpecFileEstension + " from archive" });
|
||||
string pkgpath;
|
||||
NuGetVersion version;
|
||||
string pkgid;
|
||||
string fullpath;
|
||||
|
||||
using (var specstr = spec.Open())
|
||||
{
|
||||
NuspecCoreReader reader = new NuspecCoreReader(specstr);
|
||||
|
||||
string pkgdesc = reader.GetDescription();
|
||||
var types = reader.GetPackageTypes();
|
||||
pkgid = reader.GetId();
|
||||
version = reader.GetVersion();
|
||||
|
||||
string pkgidpath = Path.Combine(isndSettings.PackagesRootDir,
|
||||
pkgid);
|
||||
pkgpath = Path.Combine(pkgidpath, version.ToFullString());
|
||||
string name = $"{pkgid}-{version}."+Constants.PaquetFileEstension;
|
||||
fullpath = Path.Combine(pkgpath, name);
|
||||
|
||||
var destpkgiddir = new DirectoryInfo(pkgidpath);
|
||||
Package pkg = dbContext.Packages.SingleOrDefault(p => p.Id == pkgid);
|
||||
if (pkg != null)
|
||||
{
|
||||
if (pkg.OwnerId != apikey.UserId)
|
||||
{
|
||||
return new ForbidResult();
|
||||
}
|
||||
pkg.Description = pkgdesc;
|
||||
}
|
||||
else
|
||||
{
|
||||
pkg = new Package
|
||||
{
|
||||
Id = pkgid,
|
||||
Description = pkgdesc,
|
||||
OwnerId = apikey.UserId,
|
||||
LatestVersion = commit,
|
||||
};
|
||||
dbContext.Packages.Add(pkg);
|
||||
}
|
||||
if (!destpkgiddir.Exists) destpkgiddir.Create();
|
||||
|
||||
var source = new FileInfo(initpath);
|
||||
var dest = new FileInfo(fullpath);
|
||||
var destdir = new DirectoryInfo(dest.DirectoryName);
|
||||
if (dest.Exists)
|
||||
{
|
||||
// La version existe sur le disque,
|
||||
// mais si elle ne l'est pas en base de donnéés,
|
||||
// on remplace la version sur disque.
|
||||
var pkgv = dbContext.PackageVersions.Where(
|
||||
v => v.PackageId == pkg.Id
|
||||
);
|
||||
|
||||
if (pkgv !=null && pkgv.Count()==0)
|
||||
{
|
||||
dest.Delete();
|
||||
}
|
||||
else {
|
||||
logger.LogWarning("400 : pkgversion:existant");
|
||||
ModelState.AddModelError("pkgversion", "existant" );
|
||||
return BadRequest(ModelState);
|
||||
}
|
||||
}
|
||||
{
|
||||
if (!destdir.Exists) destdir.Create();
|
||||
source.MoveTo(fullpath);
|
||||
files.Add(name);
|
||||
string fullstringversion = version.ToFullString();
|
||||
var pkgvers = dbContext.PackageVersions.Where
|
||||
(v => v.PackageId == pkg.Id && v.FullString == fullstringversion);
|
||||
if (pkgvers.Count() > 0)
|
||||
{
|
||||
foreach (var v in pkgvers.ToArray())
|
||||
dbContext.PackageVersions.Remove(v);
|
||||
}
|
||||
|
||||
// FIXME default type or null
|
||||
if (types==null || types.Count==0)
|
||||
dbContext.PackageVersions.Add
|
||||
(new PackageVersion{
|
||||
|
||||
Package = pkg,
|
||||
Major = version.Major,
|
||||
Minor = version.Minor,
|
||||
Patch = version.Patch,
|
||||
Revision = version.Revision,
|
||||
IsPrerelease = version.IsPrerelease,
|
||||
FullString = version.ToFullString(),
|
||||
Type = null,
|
||||
LatestCommit = commit
|
||||
});
|
||||
else
|
||||
foreach (var type in types)
|
||||
{
|
||||
var pkgver = new PackageVersion
|
||||
{
|
||||
Package = pkg,
|
||||
Major = version.Major,
|
||||
Minor = version.Minor,
|
||||
Patch = version.Patch,
|
||||
IsPrerelease = version.IsPrerelease,
|
||||
FullString = version.ToFullString(),
|
||||
Type = type.Name,
|
||||
LatestCommit = commit
|
||||
};
|
||||
dbContext.PackageVersions.Add(pkgver);
|
||||
}
|
||||
|
||||
await dbContext.SaveChangesAsync();
|
||||
packageManager.ÛpdateCatalogFor(commit);
|
||||
|
||||
logger.LogInformation($"new paquet : {spec.Name}");
|
||||
}
|
||||
}
|
||||
using (var shacrypto = System.Security.Cryptography.SHA512.Create())
|
||||
{
|
||||
using (var stream = System.IO.File.OpenRead(fullpath))
|
||||
{
|
||||
var hash = shacrypto.ComputeHash(stream);
|
||||
var shafullname = fullpath + ".sha512";
|
||||
var hashtext = Convert.ToBase64String(hash);
|
||||
var hashtextbytes = Encoding.ASCII.GetBytes(hashtext);
|
||||
|
||||
using (var shafile = System.IO.File.OpenWrite(shafullname))
|
||||
{
|
||||
shafile.Write(hashtextbytes, 0, hashtextbytes.Length);
|
||||
}
|
||||
}
|
||||
}
|
||||
string nuspecfullpath = Path.Combine(pkgpath, pkgid + "." + Constants.SpecFileEstension);
|
||||
FileInfo nfpi = new FileInfo(nuspecfullpath);
|
||||
|
||||
if (nfpi.Exists)
|
||||
nfpi.Delete();
|
||||
spec.ExtractToFile(nuspecfullpath);
|
||||
}
|
||||
|
||||
}
|
||||
return Ok(ViewData);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.LogError(ex.Message);
|
||||
logger.LogError("Stack Trace: " + ex.StackTrace);
|
||||
return new ObjectResult(new { ViewData, ex.Message })
|
||||
{ StatusCode = 500 };
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using isnd.Entities;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
|
||||
[HttpGet(_pkgRootPrefix + ApiConfig.Search)]
|
||||
public async Task<IActionResult> Search(
|
||||
string q,
|
||||
int skip = 0,
|
||||
int take = 25,
|
||||
bool prerelease = false,
|
||||
string semVerLevel = null,
|
||||
string packageType = null
|
||||
)
|
||||
{
|
||||
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Helpers;
|
||||
using isnd.ViewModels;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace isnd.Controllers
|
||||
{
|
||||
|
||||
public partial class PackagesController
|
||||
{
|
||||
// Web search
|
||||
public async Task<IActionResult> Index(PackageRegistrationIndexQuery model)
|
||||
{
|
||||
return View(packageManager.GetCatalogIndex());
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Details(string pkgid)
|
||||
{
|
||||
if (pkgid == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var packageVersion = dbContext.PackageVersions
|
||||
.Include(p => p.Package)
|
||||
.Where(m => m.PackageId == pkgid)
|
||||
.OrderByDescending(p => p)
|
||||
;
|
||||
|
||||
if (packageVersion == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
bool results = await packageVersion.AnyAsync();
|
||||
var latest = await packageVersion.FirstAsync();
|
||||
|
||||
return View("Details", new PackageDetailViewModel
|
||||
{
|
||||
latest = latest,
|
||||
pkgid = pkgid,
|
||||
totalHits = packageVersion.Count(),
|
||||
data = packageVersion.Take(MAX_PKG_VERSION_LIST).ToArray()
|
||||
});
|
||||
|
||||
}
|
||||
const int MAX_PKG_VERSION_LIST = 50;
|
||||
|
||||
[Authorize]
|
||||
public async Task<IActionResult> Delete(string pkgid, string version, string pkgtype)
|
||||
{
|
||||
if (pkgid == null || version == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
// var report = await packageManager.DeletePackageAsync(id, lower, type);
|
||||
|
||||
var packageVersion = await dbContext.PackageVersions.Include(p => p.Package)
|
||||
.FirstOrDefaultAsync(m => m.PackageId == pkgid
|
||||
&& m.FullString == version && m.Type == pkgtype);
|
||||
if (packageVersion == null) return NotFound();
|
||||
if (!User.IsOwner(packageVersion)) return Unauthorized();
|
||||
var pkg = await packageManager.GetPackageAsync(pkgid, version, pkgtype);
|
||||
return View(pkg);
|
||||
}
|
||||
|
||||
// POST: PackageVersion/Delete/5
|
||||
[HttpPost, ActionName("Delete")]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> DeleteConfirmed(string PackageId, string FullString,
|
||||
string Type)
|
||||
{
|
||||
PackageVersion packageVersion = await dbContext.PackageVersions
|
||||
.Include(pv => pv.Package)
|
||||
.FirstOrDefaultAsync(m => m.PackageId == PackageId
|
||||
&& m.FullString == FullString && m.Type == Type);
|
||||
if (packageVersion == null) return NotFound();
|
||||
if (!User.IsOwner(packageVersion)) return Unauthorized();
|
||||
|
||||
await packageManager.DeletePackageAsync(PackageId, FullString, Type);
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,82 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class CatalogEntry
|
||||
{
|
||||
/// <summary>
|
||||
/// The URL to the document used to produce this object
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Key][Required,JsonRequired]
|
||||
[StringLength(1024)]
|
||||
[JsonProperty("@id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Authors
|
||||
/// </summary>
|
||||
/// <value>string or array of strings</value>
|
||||
public string authors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The dependencies of the package, grouped by target framework
|
||||
/// </summary>
|
||||
/// <value>array of objects</value>
|
||||
public DependencyGroup[] dependencyGroups { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The deprecation associated with the package
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Deprecation deprecation { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
public string iconUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The ID of the package
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string idp { get; set; }
|
||||
public string licenseUrl { get; set; }
|
||||
public string licenseExpression { get; set; }
|
||||
/// <summary>
|
||||
/// Should be considered as listed if absent
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public bool listed { get; set; }
|
||||
public string minClientVersion { get; set; }
|
||||
public string projectUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string containing a ISO 8601 timestamp of when the package was published
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string published { get; set; }
|
||||
public bool requireLicenseAcceptance { get; set; }
|
||||
public string summary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tags
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public string tags { get; set; }
|
||||
public string title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full version string after normalization
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required,JsonRequired]
|
||||
public string version { get; set; } // string yes
|
||||
/// <summary>
|
||||
/// The security vulnerabilities of the package
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Vulnerabilitie[] vulnerabilities { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,100 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using isnd.Data.Packages;
|
||||
using Newtonsoft.Json;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class RegistrationPage : Permalink
|
||||
{
|
||||
private readonly string pkgid;
|
||||
private readonly List<RegistrationLeaf> items;
|
||||
|
||||
private readonly string apiBase;
|
||||
|
||||
|
||||
public RegistrationPage (string pkgid, string apiBase) : base(apiBase + $"/registration/{pkgid}/index.json")
|
||||
{
|
||||
Parent = apiBase + $"/registration/{pkgid}/index.json";
|
||||
this.items = new List<RegistrationLeaf>();
|
||||
this.pkgid = pkgid;
|
||||
this.apiBase = apiBase;
|
||||
}
|
||||
|
||||
public RegistrationPage(string pkgid, string apiBase, IEnumerable<PackageVersion> versions) : this(pkgid, apiBase)
|
||||
{
|
||||
AddVersionRange(versions);
|
||||
}
|
||||
|
||||
public string GetPackageId()
|
||||
{
|
||||
return pkgid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The array of registration leaves and their associate metadata
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("items")]
|
||||
|
||||
public RegistrationLeaf[] Items { get => items.ToArray(); }
|
||||
|
||||
public void AddVersionRange(IEnumerable<PackageVersion> vitems)
|
||||
{
|
||||
if (vitems.Count() == 0) return;
|
||||
NuGetVersion upper = null;
|
||||
NuGetVersion lower = null;
|
||||
PackageVersion latest = null;
|
||||
if (Lower!=null) lower = new NuGetVersion(Lower);
|
||||
if (Upper!=null) upper = new NuGetVersion(Upper);
|
||||
|
||||
// Assert.True(items.All(p=>p.Id == id));
|
||||
long commitMax = 0;
|
||||
foreach (var p in vitems)
|
||||
{
|
||||
if (p.LatestCommit==null) continue;
|
||||
var pkg = p.ToPackage(apiBase);
|
||||
if (items.Contains(pkg)) continue;
|
||||
|
||||
if (upper == null) upper = p.NugetVersion;
|
||||
else if ( upper < p.NugetVersion) upper = p.NugetVersion;
|
||||
|
||||
if (lower == null) lower = p.NugetVersion;
|
||||
else if (lower > p.NugetVersion) lower = p.NugetVersion;
|
||||
|
||||
if (p.CommitNId > commitMax)
|
||||
{
|
||||
latest = p;
|
||||
}
|
||||
items.Add(pkg);
|
||||
}
|
||||
Upper = upper?.ToFullString() ?? lower?.ToFullString();
|
||||
Lower = lower?.ToFullString() ?? upper?.ToFullString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The highest SemVer 2.0.0 version in the page (inclusive)
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("upper"), JsonRequired]
|
||||
public string Upper { get; private set; }
|
||||
/// <summary>
|
||||
/// The lowest SemVer 2.0.0 version in the page (inclusive)
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("lower"), JsonRequired]
|
||||
public string Lower { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL to the registration index
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("parent")]
|
||||
public string Parent { get; set; }
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int Count { get => items.Count; }
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class DependencyGroup
|
||||
{
|
||||
}
|
||||
}
|
@ -1,237 +0,0 @@
|
||||
using System.ComponentModel;
|
||||
using System.Net.Sockets;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
using isnd.Data.Packages;
|
||||
using NuGet.Versioning;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using isnd.Interfaces;
|
||||
using NuGet.Protocol.Core.Types;
|
||||
using NuGet.Protocol;
|
||||
using NuGet.Packaging;
|
||||
using NuGet.Packaging.Core;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Entities;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class PackageDetails : Permalink, IObject, IPackageSearchMetadata
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a catalog entry
|
||||
/// </summary>
|
||||
/// <param name="pkg">package id</param>
|
||||
/// <param name="apiBase">api Base</param>
|
||||
/// <returns></returns>
|
||||
public PackageDetails(PackageVersion pkg, string apiBase): base( apiBase + ApiConfig.Registration + "/" + pkg.PackageId + "/" + pkg.FullString + ".json")
|
||||
{
|
||||
Title = PackageId = pkg.Package.Id;
|
||||
Version = pkg.FullString;
|
||||
Authors = $"{pkg.Package.Owner.FullName} <${pkg.Package.Owner.Email}>";
|
||||
packageContent = apiBase + pkg.NugetLink;
|
||||
CommitId = pkg.CommitId;
|
||||
Published = CommitTimeStamp = pkg.LatestCommit.CommitTimeStamp;
|
||||
IsListed = !pkg.IsDeleted && pkg.Package.Public;
|
||||
if (pkg.DependencyGroups!=null)
|
||||
{
|
||||
DependencySets = pkg.DependencyGroups.ToDepSetInfo();
|
||||
|
||||
}
|
||||
PackageDetailsUrl = new Uri(this.id);
|
||||
|
||||
// TODO Licence Project Urls, Summary, Title, Owners, etc ...
|
||||
}
|
||||
|
||||
[JsonProperty("@type")]
|
||||
public string[] RefType { get; protected set; } = new string[] { "PackageDetails" };
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="apiBase"></param>
|
||||
/// <param name="pkgId"></param>
|
||||
/// <param name="pkgVersionString"></param>
|
||||
/// <param name="commitId"></param>
|
||||
/// <param name="commitTimeStamp"></param>
|
||||
/// <param name="authors"></param>
|
||||
/// <param name="deprecation"></param>
|
||||
/// <param name="description"></param>
|
||||
/// <param name="iconUrl"></param>
|
||||
/// <param name="language"></param>
|
||||
/// <param name="licenseUrl"></param>
|
||||
/// <param name="licenseExpression"></param>
|
||||
/// <param name="minClientVersion"></param>
|
||||
/// <param name="projectUrl"></param>
|
||||
/// <param name="requireLicenseAcceptance"></param>
|
||||
/// <param name="summary"></param>
|
||||
/// <param name="tags"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="packageContent"></param>
|
||||
/// <param name="version"></param>
|
||||
/// <param name="identity"></param>
|
||||
/// <param name="readmeUrl"></param>
|
||||
/// <param name="reportAbuseUrl"></param>
|
||||
/// <param name="packageDetailsUrl"></param>
|
||||
/// <param name="owners"></param>
|
||||
/// <param name="isListed"></param>
|
||||
/// <param name="prefixReserved"></param>
|
||||
/// <param name="licenseMetadata"></param>
|
||||
public PackageDetails(string apiBase, string pkgId, string pkgVersionString, string commitId, DateTimeOffset commitTimeStamp, string authors, Deprecation deprecation, string description, Uri iconUrl, string language, Uri licenseUrl, string licenseExpression, string minClientVersion, Uri projectUrl, bool requireLicenseAcceptance, string summary, string tags, string title, string packageContent, string version, PackageIdentity identity, Uri readmeUrl, Uri reportAbuseUrl, Uri packageDetailsUrl, string owners, bool isListed, bool prefixReserved, LicenseMetadata licenseMetadata)
|
||||
: base( apiBase + ApiConfig.Registration + "/" + pkgId + "/" + pkgVersionString + ".json")
|
||||
{
|
||||
this.CommitId = commitId;
|
||||
this.CommitTimeStamp = commitTimeStamp;
|
||||
this.Authors = authors;
|
||||
this.deprecation = deprecation;
|
||||
this.Description = description;
|
||||
this.IconUrl = iconUrl;
|
||||
this.language = language;
|
||||
this.LicenseUrl = licenseUrl;
|
||||
this.licenseExpression = licenseExpression;
|
||||
this.minClientVersion = minClientVersion;
|
||||
this.ProjectUrl = projectUrl;
|
||||
this.RequireLicenseAcceptance = requireLicenseAcceptance;
|
||||
this.Summary = summary;
|
||||
this.Tags = tags;
|
||||
this.Title = title;
|
||||
this.packageContent = packageContent;
|
||||
this.Version = version;
|
||||
this.Identity = identity;
|
||||
this.ReadmeUrl = readmeUrl;
|
||||
this.ReportAbuseUrl = reportAbuseUrl;
|
||||
this.PackageDetailsUrl = packageDetailsUrl;
|
||||
this.Owners = owners;
|
||||
this.IsListed = isListed;
|
||||
this.PrefixReserved = prefixReserved;
|
||||
this.LicenseMetadata = licenseMetadata;
|
||||
|
||||
}
|
||||
|
||||
[JsonProperty("commitId")]
|
||||
public string CommitId { get; set; }
|
||||
|
||||
[JsonProperty("commitTimeStamp")]
|
||||
public DateTimeOffset CommitTimeStamp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Authors
|
||||
/// </summary>
|
||||
/// <value>string or array of strings</value>
|
||||
[JsonProperty("authors")]
|
||||
public string Authors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The deprecation associated with the package
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public Deprecation deprecation { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public string Description { get; set; }
|
||||
|
||||
[JsonProperty("iconUrl")]
|
||||
public Uri IconUrl { get; set; }
|
||||
|
||||
public string language { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("licenseUrl")]
|
||||
public Uri LicenseUrl { get; set; }
|
||||
|
||||
public string licenseExpression { get; set; }
|
||||
|
||||
public string minClientVersion { get; set; }
|
||||
|
||||
[JsonProperty("projectUrl")]
|
||||
public Uri ProjectUrl { get; set; }
|
||||
|
||||
|
||||
[JsonProperty("requireLicenseAcceptance")]
|
||||
public bool RequireLicenseAcceptance { get; set; }
|
||||
|
||||
[JsonProperty("summary")]
|
||||
public string Summary { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The tags
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("tags")]
|
||||
public string Tags { get; set; }
|
||||
|
||||
[JsonProperty("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The security vulnerabilities of the package
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
public IEnumerable<PackageVulnerabilityMetadata> Vulnerabilities { get; }
|
||||
|
||||
public string packageContent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// A string containing a ISO 8601 timestamp of when the package was published
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("published")]
|
||||
public DateTimeOffset? Published { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The full version string after normalization
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required,JsonRequired]
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
[Required,JsonRequired]
|
||||
[JsonProperty("id")]
|
||||
public string PackageId { get; set; }
|
||||
|
||||
|
||||
public long? DownloadCount { get; set; }
|
||||
|
||||
public PackageIdentity Identity{ get; set; }
|
||||
|
||||
public Uri ReadmeUrl { get; set; }
|
||||
|
||||
public Uri ReportAbuseUrl { get; set; }
|
||||
|
||||
public Uri PackageDetailsUrl { get; set; }
|
||||
|
||||
public string Owners { get; set; }
|
||||
|
||||
[JsonProperty("isListed")]
|
||||
public bool IsListed { get; set; }
|
||||
|
||||
public bool PrefixReserved { get; set; }
|
||||
|
||||
public LicenseMetadata LicenseMetadata { get; set; }
|
||||
|
||||
public IEnumerable<PackageDependencyGroupInfo> DependencySets {get; set;}
|
||||
|
||||
IEnumerable<NuGet.Packaging.PackageDependencyGroup> IPackageSearchMetadata.DependencySets => throw new NotImplementedException();
|
||||
|
||||
public Task<PackageDeprecationMetadata> GetDeprecationMetadataAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IEnumerable<VersionInfo>> GetVersionsAsync()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public class PackageDependencyGroupInfo
|
||||
{
|
||||
private PackageDependencyGroup group;
|
||||
|
||||
public PackageDependencyGroupInfo(PackageDependencyGroup group)
|
||||
{
|
||||
this.group = group;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Entities;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class PackageRegistration : Permalink
|
||||
{
|
||||
|
||||
public PackageRegistration(string url) : base(url)
|
||||
{
|
||||
Items = new List<RegistrationPage>();
|
||||
}
|
||||
|
||||
public PackageRegistration(string apiBase, string pkgId, IEnumerable<PackageVersion> versions) : base($"{apiBase}{ApiConfig.Registration}/{pkgId}/index.json")
|
||||
{
|
||||
Items = new List<RegistrationPage>
|
||||
{
|
||||
new RegistrationPage(pkgId, apiBase, versions)
|
||||
};
|
||||
}
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int Count { get => Items.Count; }
|
||||
|
||||
[JsonProperty("items")]
|
||||
public List<RegistrationPage> Items { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class PackageRegistrationIndexQuery : RegistrationPageIndex
|
||||
{
|
||||
public PackageRegistrationIndexQuery(string id) : base(id)
|
||||
{
|
||||
}
|
||||
|
||||
[JsonProperty("prerelease")]
|
||||
public bool Prerelease { get; set; }
|
||||
|
||||
[JsonProperty("query")]
|
||||
public string Query { get; set; }
|
||||
|
||||
[JsonProperty("totalHits")]
|
||||
public int TotalHits { get; internal set; }
|
||||
}
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using isnd.Data.Packages;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class PackageRegistrationQuery
|
||||
{
|
||||
public PackageRegistrationQuery()
|
||||
{
|
||||
}
|
||||
|
||||
[JsonProperty("query")]
|
||||
public string Query { get; set; }
|
||||
|
||||
[JsonProperty("prerelease")]
|
||||
public bool Prerelease { get; set; } = true;
|
||||
[JsonProperty("skip")]
|
||||
|
||||
public int Skip { get; set; } = 0;
|
||||
[JsonProperty("take")]
|
||||
|
||||
public int Take { get; set; } = 25;
|
||||
}
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class RegistrationPage
|
||||
{
|
||||
[JsonProperty("@id")]
|
||||
[JsonRequired]
|
||||
public string Id { get; }
|
||||
public RegistrationPage (string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// no The array of registration leaves and their associate metadata
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("items")]
|
||||
|
||||
public List<RegistrationLeaf> Items { get; set; }
|
||||
/// <summary>
|
||||
/// The highest SemVer 2.0.0 version in the page (inclusive)
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("upper"), JsonRequired]
|
||||
public Version Upper { get; set; }
|
||||
/// <summary>
|
||||
/// The lowest SemVer 2.0.0 version in the page (inclusive)
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("lower"), JsonRequired]
|
||||
public Version Lower { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The URL to the registration index
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("parent")]
|
||||
public string Parent { get; set; }
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int Count { get; internal set; }
|
||||
public string CommitId { get; internal set; }
|
||||
public DateTime CommitTimeStamp { get; internal set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace isnd.Data.Catalog
|
||||
{
|
||||
public class RegistrationPageIndex
|
||||
{
|
||||
/// <summary>
|
||||
/// Page Url
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("@id")]
|
||||
public string Id { get; set; }
|
||||
public RegistrationPageIndex(string id)
|
||||
{
|
||||
Id = id;
|
||||
Items = new List<RegistrationPage>();
|
||||
}
|
||||
|
||||
public RegistrationPageIndex(IEnumerable<RegistrationPage> pages)
|
||||
{
|
||||
Items = new List<RegistrationPage>(pages);
|
||||
}
|
||||
|
||||
public RegistrationPageIndex(string id, IEnumerable<RegistrationLeaf> leaves) : this(id)
|
||||
{
|
||||
// leaves;
|
||||
this.Items = new List<RegistrationPage>
|
||||
(
|
||||
|
||||
|
||||
)
|
||||
{
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[JsonProperty("count")]
|
||||
public int Count { get => Items?.Count ?? 0; }
|
||||
|
||||
[JsonProperty("items")]
|
||||
public List<RegistrationPage> Items { get; set; }
|
||||
|
||||
public string CommitId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class CatalogLeaf : IObject
|
||||
{
|
||||
|
||||
[JsonProperty("@type")]
|
||||
public string[] RefType { get; set; }
|
||||
|
||||
[JsonProperty("commitId")]
|
||||
public string CommitId { get; set; }
|
||||
|
||||
[JsonProperty("commitTimeStamp")]
|
||||
public DateTime CommitTimeStamp { get; set; }
|
||||
|
||||
[JsonProperty("published")]
|
||||
public DateTime Published { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("version")]
|
||||
public string Version { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class PackageDetail : CatalogLeaf
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using isnd.Interfaces;
|
||||
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class PackageEntry : IObject
|
||||
{
|
||||
public string CommitId => throw new NotImplementedException();
|
||||
|
||||
public DateTimeOffset CommitTimeStamp => throw new NotImplementedException();
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using isnd.Interfaces;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace isnd.Data.Packages.Catalog
|
||||
{
|
||||
public class Page : IObject
|
||||
{
|
||||
[JsonProperty("@id")]
|
||||
public string Id { get; set; }
|
||||
|
||||
[JsonProperty("parent")]
|
||||
public string Parent { get; set; }
|
||||
|
||||
[JsonProperty("items")]
|
||||
public virtual List<PackageRef> Items { get; set; }
|
||||
public string CommitId { get; set; }
|
||||
public DateTime CommitTimeStamp { get; set; }
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.EntityFrameworkCore.Metadata.Internal;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using isnd.Data.Packages;
|
||||
|
||||
namespace isnd.Data
|
||||
{
|
||||
public class Dependency
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key][DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public string Id { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Dependency Package Identifier
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[JsonProperty("id")]
|
||||
public string PackageId { get;set;}
|
||||
|
||||
/// <summary>
|
||||
/// Dependency Group Id
|
||||
/// </summary>
|
||||
/// <value></value>
|
||||
[Required]
|
||||
[ForeignKey("Group")]
|
||||
[JsonIgnore]
|
||||
public string DependencyGroupId { set ; get ; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual PackageDependencyGroup Group{ get; set; }
|
||||
|
||||
// TODO Version Range
|
||||
[JsonProperty("range")]
|
||||
public string Version { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace isnd.Data.Packages
|
||||
{
|
||||
public interface IPackage
|
||||
{
|
||||
string Id { get; set; }
|
||||
string OwnerId { get; set; }
|
||||
string Description { get; set; }
|
||||
bool Public { get; set; }
|
||||
ApplicationUser Owner { get; set; }
|
||||
List<PackageVersion> Versions { get; set; }
|
||||
long CommitNId { get; set; }
|
||||
string CommitId { get; }
|
||||
Commit LatestCommit { get; set; }
|
||||
DateTimeOffset CommitTimeStamp { get; set; }
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using isnd.Data.Catalog;
|
||||
using Microsoft.DotNet.Scaffolding.Shared.ProjectModel;
|
||||
using Microsoft.Identity.Client;
|
||||
using Newtonsoft.Json;
|
||||
using NuGet.Frameworks;
|
||||
using NuGet.Packaging;
|
||||
using NuGet.Packaging.Core;
|
||||
using NuGet.ProjectModel;
|
||||
using NuGet.Versioning;
|
||||
|
||||
namespace isnd.Data
|
||||
{
|
||||
static class Helpers
|
||||
{
|
||||
public static PackageDependencyGroupInfo[] ToDepSetInfo(this IEnumerable<PackageDependencyGroup> groups)
|
||||
{
|
||||
return groups.Select(group => new PackageDependencyGroupInfo(group)).ToArray();
|
||||
}
|
||||
}
|
||||
public class PackageDependencyGroup
|
||||
{
|
||||
[JsonIgnore]
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public string Id { get ; set;}
|
||||
|
||||
[Required]
|
||||
[JsonProperty("id")]
|
||||
public string PackageId { get ; set;}
|
||||
|
||||
[Required]
|
||||
[JsonIgnore]
|
||||
public string PackageVersionFullString { get ; set;}
|
||||
|
||||
[JsonProperty("targetFramework")]
|
||||
[Required]
|
||||
public string TargetFramework { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ForeignKey("DependencyGroupId")]
|
||||
public virtual List<Dependency> Dependencies { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public virtual PackageVersion PackageVersion { get; set; }
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace isnd.Entities
|
||||
{
|
||||
public class UnleashClientSettings
|
||||
{
|
||||
public string ClientApiKey { get; set; }
|
||||
public string ApiUrl { get; set; }
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using isn;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
namespace isnd.Helpers
|
||||
{
|
||||
public static class ApiHelpers
|
||||
{
|
||||
|
||||
static public APIKO CreateAPIKO(this Controller controller, string context)
|
||||
{
|
||||
Dictionary<string,string[]> errors = new();
|
||||
|
||||
foreach (var elt in controller.ModelState)
|
||||
{
|
||||
errors[elt.Key] = elt.Value.Errors.Select( e => e.ErrorMessage).ToArray();
|
||||
}
|
||||
return new APIKO{ Context = context, Errors = errors };
|
||||
}
|
||||
}
|
||||
}
|
@ -1,17 +1,33 @@
|
||||
namespace isnd.Helpers
|
||||
{
|
||||
/// <summary>
|
||||
/// Package Id Helpers
|
||||
/// </summary>
|
||||
public static class PackageIdHelpers
|
||||
{
|
||||
|
||||
internal static bool SeparatedByMinusMatch(string id, string q)
|
||||
{
|
||||
foreach (var part in id.Split('-'))
|
||||
{
|
||||
if (part.Equals(q, System.StringComparison.InvariantCultureIgnoreCase)) return true;
|
||||
if (part.StartsWith(q, System.StringComparison.OrdinalIgnoreCase)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
internal static bool CamelCaseMatch(string id, string query)
|
||||
{
|
||||
// Assert.False (q==null);
|
||||
if (string.IsNullOrEmpty(query)) return true;
|
||||
|
||||
while (id.Length > 0)
|
||||
{
|
||||
int i = 0;
|
||||
while (id.Length > i && char.IsLower(id[i])) i++;
|
||||
if (i == 0) break;
|
||||
id = id.Substring(i);
|
||||
if (id.StartsWith(query, System.StringComparison.OrdinalIgnoreCase)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using isnd.Entities;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Unleash;
|
||||
using Unleash.ClientFactory;
|
||||
|
||||
namespace isnd.Helpers
|
||||
{
|
||||
public static class UnleashHelpers
|
||||
{
|
||||
|
||||
public static IUnleash CreateUnleahClient(this IHostingEnvironment env,
|
||||
UnleashClientSettings unleashClientSettings)
|
||||
{
|
||||
var unleashSettings = new UnleashSettings
|
||||
{
|
||||
UnleashApi = new Uri(unleashClientSettings.ApiUrl),
|
||||
AppName = "isnd",
|
||||
Environment = env.EnvironmentName,
|
||||
CustomHttpHeaders = new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization", unleashClientSettings.ClientApiKey }
|
||||
}
|
||||
};
|
||||
|
||||
UnleashClientFactory unleashClientFactory = new UnleashClientFactory();
|
||||
return unleashClientFactory.CreateClient(unleashSettings);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using isnd.Data.ApiKeys;
|
||||
|
||||
|
||||
namespace isnd.Interfaces
|
||||
{
|
||||
public interface IApiKeyProvider
|
||||
{
|
||||
Task<ApiKey> CreateApiKeyAsync(CreateModel model);
|
||||
IQueryable<ApiKey> GetUserKeys(string identityName);
|
||||
}
|
||||
}
|
@ -1,36 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using isn.Abstract;
|
||||
using isnd.Controllers;
|
||||
using isnd.Data;
|
||||
using isnd.Data.Catalog;
|
||||
using isnd.Data.Packages;
|
||||
using isnd.Data.Packages.Catalog;
|
||||
using isnd.Services;
|
||||
using isnd.ViewModels;
|
||||
using NuGet.Versioning;
|
||||
using Unleash;
|
||||
|
||||
namespace isnd.Interfaces
|
||||
{
|
||||
public interface IPackageManager
|
||||
{
|
||||
string CatalogBaseUrl { get; }
|
||||
AutoCompleteResult AutoComplete(string pkgid, int skip=0, int take=25, bool prerelease = false, string packageType = null);
|
||||
AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null);
|
||||
|
||||
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
|
||||
IEnumerable<Resource> GetResources();
|
||||
Task<PackageRegistration> UpdateCatalogForAsync(Commit commit);
|
||||
RegistrationPageIndex SearchByName(string query, int skip, int take, bool prerelease = false, string packageType = null);
|
||||
IEnumerable<Resource> GetResources(IUnleash unleashĈlient);
|
||||
void ÛpdateCatalogFor(Commit commit);
|
||||
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
|
||||
Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type);
|
||||
Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type);
|
||||
Task<Data.Catalog.RegistrationLeaf> GetCatalogEntryAsync(string pkgId, string version, string pkgType);
|
||||
IEnumerable<Data.Catalog.RegistrationLeaf> SearchCatalogEntriesById(string pkgId, string semver, string pkgType, bool preRelease);
|
||||
IEnumerable<PackageVersion> GetCatalogLeaf(string pkgId, string semver, string pkgType);
|
||||
IEnumerable<RegistrationLeaf> SearchById(string pkgId, string semver, string pkgType);
|
||||
|
||||
Task<PackageRegistration> GetCatalogIndexAsync();
|
||||
Task<PackageRegistration> GetPackageRegistrationIndexAsync(PackageRegistrationQuery query);
|
||||
|
||||
Task<PackageSearchResult> SearchPackageAsync(PackageRegistrationQuery query);
|
||||
|
||||
Task<PackageVersion> PutPackageAsync(Stream packageStream, string ownerId);
|
||||
RegistrationPageIndex GetCatalogIndex();
|
||||
}
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue