Skip to content

Commit

Permalink
Improved err msg for invalid NuGet pkgs ⋄ Template cfg file handling …
Browse files Browse the repository at this point in the history
…improved
  • Loading branch information
aplteam committed Oct 1, 2023
1 parent a625d56 commit 5bcf131
Show file tree
Hide file tree
Showing 40 changed files with 181 additions and 113 deletions.
5 changes: 4 additions & 1 deletion APLSource/Cider/AddNuGetDependencies.aplf
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
listAddNuGetDependencies(packages projectFolder);NuGet;msg;cfg;nuGetFolder;package;buff;targetNamespace
listAddNuGetDependencies(packages projectFolder);NuGet;msg;cfg;nuGetFolder;package;buff;targetNamespace;b
Add one or more NuGet packages to the NuGet-folder define in the config file of `projectFolder`.
* `packages` must be either a nested vector with package names or a comma-separated list of package names
* `projectFolder` must carry a Cider config files used to establish the NuGet folder.\\
Returns a list with the names that got installed or at least updated.
:If 1=packages
packages','()packages
:EndIf
:If 0b(⎕NS''){0=.⎕NC }¨packages
('Invalid package name(s): ',{',',}/'"',¨'"',¨(~b)/packages)Assert 0
:EndIf
:If IsAlias projectFolder
projectFolderGetFolderFromAlias2 projectFolder
:EndIf
Expand Down
2 changes: 1 addition & 1 deletion APLSource/Cider/Version.aplf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
rVersion
See als History
r'0.36.1+594'
r'0.36.1+595'
14 changes: 10 additions & 4 deletions APLSource/Cider_uc.dyalog
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
:Class Cider_UC
:Class Cider_UC
User Command class for the project manager "Cider"

⎕IO1 ⎕ML1 ⎕WX3
Expand Down Expand Up @@ -793,7 +793,10 @@
CreateConfigFile filename namespace
:EndIf
:If ~noEditFlag
P.ProjectConfig filename
:If ¯1=P.ProjectConfig filename
1 ⎕NDELETE filename
r'Cancelled by user' 0
:EndIf
config⎕NGET filename 1
:If success0<(config)~' '
config⎕JSON('Dialect' 'JSON5')¯1config,¨⎕UCS 10
Expand Down Expand Up @@ -855,6 +858,10 @@
('The folder already hosts a file "',configFilename,'"')Assert~⎕NEXISTS filename
globalCiderConfigFilenameP.GetCiderGlobalConfigHomeFolder,'cider.config.template'
:If 0=⎕NEXISTS globalCiderConfigFilename
First attempt
globalCiderConfigFilename(⎕NCOPY P.##.F.ExecNfunction)P.##.TatinVars.HOME,'/cider.config.template'
:ElseIf /{⎕NGET }¨globalCiderConfigFilename(P.##.TatinVars.HOME,'/cider.config.template')
Replace by the template if changed
globalCiderConfigFilename(⎕NCOPY P.##.F.ExecNfunction)P.##.TatinVars.HOME,'/cider.config.template'
:EndIf
config⎕JSON('Dialect' 'JSON5')P.##.F.NGET globalCiderConfigFilename
Expand All @@ -864,8 +871,7 @@
:EndIf
((~name⎕D,⎕A,'_∆⍙',⎕C ⎕A)/name)'_'
config.CIDER.projectSpacename
config⎕JSON('Dialect' 'JSON5')('Compact' 0)config
(config)P.##.F.NPUT filename
config P.##.Put_JSON5 filename

rGetUserConfigFileTemplate;folder;filename
Expand Down
42 changes: 42 additions & 0 deletions APLSource/TestCases/Test_NuGet_020.aplf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
RTest_NuGet_020(stopFlag batchFlag);⎕TRAP;folder;parms;res;log;cals;success;tempDir;config;qdmx;expected
Open a project and add some NuGet dependencies wrongly separated by a space
⎕TRAP(999 'C' '∘∘∘ ⍝ Deliberate error')(0 'N')
RT._Failed

#.⎕SHADOW'TEMP' 'TEMP'#.⎕NS''
folder∆GetTestPath⎕SI
tempDir∆GetFolderInTempDir⎕SI
tempDir ⎕NCOPY1folder,'/*'

config##.Cider.ReadProjectConfigFile tempDir
config.CIDER.dependencies.nuget'MyNugetPkgs'
config ##.Cider.WriteProjectConfigFile tempDir

parms##.Cider.CreateOpenParms''
parms.foldertempDir
parms.noPkgLoad0
parms.batch1
parms.ignoreUserExec1

(success log)##.Cider.OpenProject parms
T.GoToTidyUp~success
T.GoToTidyUp/'ERROR'log

:Trap 11
{}##.Cider.AddNuGetDependencies'Clock NodaTime,SMTP'tempDir
T.GoToTidyUp 1
:Else
qdmx⎕DMX
expected'Invalid package name(s): "Clock NodaTime"'
T.GoToTidyUp expectedqdmx.EM
:EndTrap

res##.Cider.CloseProject tempDir
T.GoToTidyUp res1

RT._OK

∆TidyUp:
res∆LINK'Break' '#.TEMP'
FilesAndDirs.RmDir tempDir,'/..'
Done
8 changes: 5 additions & 3 deletions Tests/Test_NuGet_010/nuget-packages/Class1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace nuget_packages;
using System;

public class Class1
namespace MyNugetPkgs
{

public class Class1
{
}
}
4 changes: 4 additions & 0 deletions Tests/Test_NuGet_010/nuget-packages/MyNugetPkgs.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>net5.0</TargetFramework> <LangVersion>Latest</LangVersion> </PropertyGroup> <ItemGroup>
<PackageReference Include="Clock" Version="1.0.3" />
<PackageReference Include="NodaTime" Version="3.1.9" />
</ItemGroup></Project>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v6.0",
"name": ".NETCoreApp,Version=v5.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v6.0": {
"nuget-packages/1.0.0": {
".NETCoreApp,Version=v5.0": {
"MyNugetPkgs/1.0.0": {
"dependencies": {
"Clock": "1.0.3",
"NodaTime": "3.1.9"
},
"runtime": {
"nuget-packages.dll": {}
"MyNugetPkgs.dll": {}
}
},
"Clock/1.0.3": {
Expand All @@ -32,7 +32,7 @@
"System.Runtime.CompilerServices.Unsafe": "4.7.1"
},
"runtime": {
"lib/net6.0/NodaTime.dll": {
"lib/netstandard2.0/NodaTime.dll": {
"assemblyVersion": "3.1.9.0",
"fileVersion": "3.1.9.0"
}
Expand All @@ -42,7 +42,7 @@
}
},
"libraries": {
"nuget-packages/1.0.0": {
"MyNugetPkgs/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
Expand Down
Binary file not shown.
Binary file not shown.
4 changes: 0 additions & 4 deletions Tests/Test_NuGet_010/nuget-packages/nuget-packages.csproj

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v5.0", FrameworkDisplayName = "")]
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("nuget-packages")]
[assembly: System.Reflection.AssemblyCompanyAttribute("MyNugetPkgs")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("nuget-packages")]
[assembly: System.Reflection.AssemblyTitleAttribute("nuget-packages")]
[assembly: System.Reflection.AssemblyProductAttribute("MyNugetPkgs")]
[assembly: System.Reflection.AssemblyTitleAttribute("MyNugetPkgs")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
is_global = true
build_property.TargetFramework = net5.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.PublishSingleFile =
build_property.IncludeAllContentForSelfExtract =
build_property._SupportedPlatformList = Android,iOS,Linux,macOS,Windows
build_property.RootNamespace = MyNugetPkgs
build_property.ProjectDir = C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\bin\Debug\net5.0\MyNugetPkgs.deps.json
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\bin\Debug\net5.0\MyNugetPkgs.dll
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\bin\Debug\net5.0\ref\MyNugetPkgs.dll
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\bin\Debug\net5.0\MyNugetPkgs.pdb
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.csproj.AssemblyReference.cache
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.AssemblyInfoInputs.cache
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.AssemblyInfo.cs
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.csproj.CoreCompileInputs.cache
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.dll
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\ref\MyNugetPkgs.dll
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\obj\Debug\net5.0\MyNugetPkgs.pdb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\published\MyNugetPkgs.dll
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\published\MyNugetPkgs.deps.json
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\published\MyNugetPkgs.pdb
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\published\Clock.dll
C:\Users\kai\AppData\Local\Temp\Cider-Tests_19474297_0\Test_NuGet_004\MyNugetPkgs\published\NodaTime.dll

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.

This file was deleted.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
"C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_194200686_0\\Test_NuGet_002\\nuget-packages\\nuget-packages.csproj": {}
"C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_19474297_0\\Test_NuGet_004\\MyNugetPkgs\\MyNugetPkgs.csproj": {}
},
"projects": {
"C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_194200686_0\\Test_NuGet_002\\nuget-packages\\nuget-packages.csproj": {
"C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_19474297_0\\Test_NuGet_004\\MyNugetPkgs\\MyNugetPkgs.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_194200686_0\\Test_NuGet_002\\nuget-packages\\nuget-packages.csproj",
"projectName": "nuget-packages",
"projectPath": "C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_194200686_0\\Test_NuGet_002\\nuget-packages\\nuget-packages.csproj",
"projectUniqueName": "C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_19474297_0\\Test_NuGet_004\\MyNugetPkgs\\MyNugetPkgs.csproj",
"projectName": "MyNugetPkgs",
"projectPath": "C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_19474297_0\\Test_NuGet_004\\MyNugetPkgs\\MyNugetPkgs.csproj",
"packagesPath": "C:\\Users\\kai\\.nuget\\packages\\",
"outputPath": "C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_194200686_0\\Test_NuGet_002\\nuget-packages\\obj\\",
"outputPath": "C:\\Users\\kai\\AppData\\Local\\Temp\\Cider-Tests_19474297_0\\Test_NuGet_004\\MyNugetPkgs\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
Expand All @@ -22,15 +22,15 @@
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
],
"originalTargetFrameworks": [
"net6.0"
"net5.0"
],
"sources": {
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"net5.0": {
"targetAlias": "net5.0",
"projectReferences": {}
}
},
Expand All @@ -41,8 +41,8 @@
}
},
"frameworks": {
"net6.0": {
"targetAlias": "net6.0",
"net5.0": {
"targetAlias": "net5.0",
"dependencies": {
"Clock": {
"target": "Package",
Expand All @@ -59,8 +59,7 @@
"net47",
"net471",
"net472",
"net48",
"net481"
"net48"
],
"assetTargetFallback": true,
"warn": true,
Expand All @@ -69,7 +68,7 @@
"privateAssets": "all"
}
},
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.401\\RuntimeIdentifierGraph.json"
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\5.0.416\\RuntimeIdentifierGraph.json"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\kai\.nuget\packages\;C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.7.0</NuGetToolVersion>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.11.2</NuGetToolVersion>
</PropertyGroup>
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<SourceRoot Include="C:\Users\kai\.nuget\packages\" />
<SourceRoot Include="C:\Program Files (x86)\Microsoft Visual Studio\Shared\NuGetPackages\" />
</ItemGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<PkgClockAnalyser Condition=" '$(PkgClockAnalyser)' == '' ">C:\Users\kai\.nuget\packages\clockanalyser\1.0.99</PkgClockAnalyser>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>

This file was deleted.

Loading

0 comments on commit 5bcf131

Please sign in to comment.