Skip to content

Commit eff8642

Browse files
committed
Update readme and make npm packaging better
1 parent 3a90311 commit eff8642

File tree

10 files changed

+146
-12
lines changed

10 files changed

+146
-12
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22

33
Copyright (c) 2019 Unity Technologies
4-
Copyright (c) 2019 Andreia Gaita
4+
Copyright (c) 2016-2019 Andreia Gaita
55
Copyright (c) 2016-2018 GitHub
66

77
Permission is hereby granted, free of charge, to any person obtaining a copy

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# About the Tasks package
2+
3+
Unity.Editor.Tasks is a TPL-based (Task Parallel Library, or System.Threading.Tasks) task management library.
4+
5+
This repository is a subset of the functionality in [Git for Unity](https://github.com/Unity-Technologies/Git-for-Unity) repository, specifically the `Threading`, `OutputProcessors`, `Tasks`, `Process` and `IO` directories, as well as various helper classes found in [](https://github.com/Unity-Technologies/Git-for-Unity/tree/master/src/com.unity.git.api/Api).
6+
7+
It's been split up for easier testing and consumption by the Git package and any other packages, libraries or apps that wish to use it.
8+
9+
10+
11+
## The History
12+
13+
This library was originally written because Unity's old Mono C# profile/compilers did not support TPL and async/await, the Git client really needs to run on controlled background threads with some sort of exclusive locking mechanism, without the uncertainty of explicit async/await calls, and I really didn't have the time or the inclination to teach modern .NET developers how to code for an ancient Mono version.
14+
15+
The next best thing was to code modern .NET and use a version of the TPL library backported to .NET 3.5 (the highest that Unity's old mono supports) to have it running in Unity 5.6 and up. The nice thing about modern .NET is that it's pretty much all syntactic sugar. Ancient Mono versions can run the code just fine, they just can't compile it.
16+
17+
These days, Unity supports modern .NET and can compile all this code just fine, so this library no longer ships with .NET 3.5 support, but it still maintains its separation from Unity - the projects don't reference Unity, and any Unity integration code in this library is behind a `#if UNITY_EDITOR` define, so you can safely consume the nuget packages in any .NET environment, and Unity-specific functionality will only be available when you consume this library as a package in a Unity project.
18+
19+
## License
20+
21+
**[MIT](LICENSE)**
22+
23+
Copyright (c) 2019 Unity Technologies
24+
Copyright (c) 2016-2019 Andreia Gaita
25+
Copyright (c) 2016-2018 GitHub

common/packaging.targets

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@
5252
Condition=" '$(TargetFramework)' == 'net471' " >
5353

5454
<PropertyGroup>
55-
<NpmVersion Condition=" '$(NpmVersionSuffix)' == '' ">$(NuGetPackageVersion)</NpmVersion>
56-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' != 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
57-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' == 'true'">$(NuGetPackageVersion)$(NpmVersionSuffix)</NpmVersion>
55+
<NeedsSuffix Condition="'$(PublicRelease)' != 'true' and '$(NpmVersionSuffix)' != '' and !$(NuGetPackageVersion.Contains('$(NpmVersionSuffix)'))">true</NeedsSuffix>
56+
<NpmVersion Condition=" '$(NeedsSuffix)' != 'true' ">$(NuGetPackageVersion)</NpmVersion>
57+
<NpmVersion Condition=" '$(NeedsSuffix)' == 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
5858
</PropertyGroup>
5959

6060
<FileUpdate
@@ -151,9 +151,9 @@
151151
Condition="Exists('$(PackageSourceRoot)\Tests') and '$(TargetFramework)' == 'net471' " >
152152

153153
<PropertyGroup>
154-
<NpmVersion Condition=" '$(NpmVersionSuffix)' == '' ">$(NuGetPackageVersion)</NpmVersion>
155-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' != 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
156-
<NpmVersion Condition=" '$(NpmVersionSuffix)' != '' and '$(PublicRelease)' == 'true'">$(NuGetPackageVersion)$(NpmVersionSuffix)</NpmVersion>
154+
<NeedsSuffix Condition="'$(PublicRelease)' != 'true' and '$(NpmVersionSuffix)' != '' and !$(NuGetPackageVersion.Contains('$(NpmVersionSuffix)'))">true</NeedsSuffix>
155+
<NpmVersion Condition=" '$(NeedsSuffix)' != 'true' ">$(NuGetPackageVersion)</NpmVersion>
156+
<NpmVersion Condition=" '$(NeedsSuffix)' == 'true'">$(BuildVersionSimple)$(NpmVersionSuffix)-g$(GitCommitIdShort)</NpmVersion>
157157
</PropertyGroup>
158158

159159
<FileUpdate
@@ -174,6 +174,12 @@
174174
Regex="&quot;directory&quot;: &quot;.*&quot;"
175175
ReplacementText="&quot;directory&quot;: &quot;src/$(PackageName)/Tests&quot;" />
176176

177+
<FileUpdate
178+
Files="$(PublishTo)$(PackageTestName)\package.json"
179+
Regex="&quot;revision&quot;: &quot;.*&quot;"
180+
ReplacementText="&quot;revision&quot;: &quot;$(GitCommitId)&quot;"
181+
Encoding="utf-8-without-bom" />
182+
177183
</Target>
178184

179185
</Project>

extras/com.unity.editor.tasks/Tests/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"repository" : {
1313
"type" : "git",
1414
"url": "ssh://git@github.com/Unity-Technologies/com.unity.editor.tasks.git",
15-
"directory": ""
15+
"directory": "",
16+
"revision": ""
1617
},
1718
"dependencies": {
1819
"com.unity.editor.tasks": "0.0.0-placeholder"

pack.cmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,6 @@ dotnet pack --no-restore --no-build -c %CONFIGURATION% %PUBLIC%
5555

5656
if "x%UPM%"=="x1" (
5757
call powershell scripts/Pack-Upm.ps1
58+
) else (
59+
call powershell scripts/Pack-Npm.ps1
5860
)

pack.sh

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,41 @@ fi
5757
dotnet pack --no-build --no-restore -c $CONFIGURATION $PUBLIC
5858

5959
if [[ x"$UPM" == x"1" ]]; then
60-
powershell scripts/Pack-Upm.ps1
60+
powershell scripts/Pack-Npm.ps1
61+
else
62+
srcdir="$DIR/build/packages"
63+
targetdir="$DIR/upm-ci~/packages"
64+
mkdir -p $targetdir
65+
rm -f $targetdir/*
66+
67+
cat >$targetdir/packages.json <<EOL
68+
{
69+
EOL
70+
71+
pushd $srcdir
72+
count=0
73+
for j in `ls -d *`; do
74+
echo $j
75+
pushd $j
76+
tgz="$(npm pack -q)"
77+
mv -f $tgz $targetdir/$tgz
78+
cp package.json $targetdir/$tgz.json
79+
popd
80+
81+
comma=""
82+
if [[ x"$count" == x"1" ]]; then comma=","; fi
83+
json="$(cat $targetdir/$tgz.json)"
84+
cat >>$targetdir/packages.json <<EOL
85+
${comma}
86+
"${tgz}": ${json}
87+
EOL
88+
89+
count=1
90+
done
91+
popd
92+
93+
cat >>$targetdir/packages.json <<EOL
94+
}
95+
EOL
6196
fi
6297
popd >/dev/null 2>&1

scripts/Pack-Npm.ps1

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[CmdletBinding()]
2+
Param(
3+
[switch]
4+
$Trace = $false
5+
)
6+
7+
Set-StrictMode -Version Latest
8+
if ($Trace) {
9+
Set-PSDebug -Trace 1
10+
}
11+
12+
. $PSScriptRoot\helpers.ps1 | out-null
13+
14+
$srcDir = Join-Path $rootDirectory 'build\packages'
15+
$targetDir = Join-Path $rootDirectory 'upm-ci~\packages'
16+
17+
Remove-Item "$targetDir\*"
18+
New-Item -itemtype Directory -Path $targetDir -Force -ErrorAction SilentlyContinue
19+
20+
Get-ChildItem -Directory $srcDir | % {
21+
Write-Output "Packing $($_.Name)"
22+
23+
try {
24+
Push-Location (Join-Path $srcDir $_.Name)
25+
$package = Invoke-Command -Fatal { & npm pack -qf }
26+
$package = "$package".Trim()
27+
$tgt = Join-Path $targetDir $package
28+
Move-Item $package $tgt -Force
29+
Copy-Item "package.json" (Join-Path $targetDir "$package.json") -Force
30+
} finally {
31+
Pop-Location
32+
}
33+
}
34+
35+
Write-Output "Writing packages.json"
36+
37+
try {
38+
Push-Location $targetDir
39+
40+
$file = "packages.json"
41+
$count = 0
42+
43+
Set-Content $file "{"
44+
45+
Get-ChildItem "*.tgz" | % {
46+
if ($count -gt 0) {
47+
Add-Content $file ","
48+
}
49+
$json = Get-Content "$($_.Name).json"
50+
Add-Content $file """$($_.Name)"": "
51+
Add-Content $file $json
52+
$count = $count + 1
53+
}
54+
55+
Add-Content $file "}"
56+
57+
} finally {
58+
Pop-Location
59+
}

src/com.unity.editor.tasks/LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ com.unity.editor.tasks copyright © 2019 Unity Technologies ApS
33
MIT License
44

55
Copyright (c) 2019 Unity Technologies
6-
Copyright (c) 2019 Andreia Gaita
6+
Copyright (c) 2016-2019 Andreia Gaita
77
Copyright (c) 2016-2018 GitHub
88

99
Permission is hereby granted, free of charge, to any person obtaining a copy

src/com.unity.editor.tasks/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
"repository" : {
1212
"type" : "git",
1313
"url": "ssh://git@github.com/Unity-Technologies/com.unity.editor.tasks.git",
14-
"directory": ""
14+
"directory": "",
15+
"revision": ""
1516
},
16-
"dependencies": {
17+
"relatedPackages": {
18+
"com.unity.editor.tasks.tests": "0.0.0-placeholder"
1719
}
1820
}

tests/Tasks.Tests/copyhelperbinaries.targets

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

4+
<PropertyGroup>
5+
<PackageTestName>$(PackageName).tests</PackageTestName>
6+
</PropertyGroup>
7+
48
<Target Name="CopyHelperBinariesToPackage"
59
DependsOnTargets="AfterBuild;EnumerateHelperBinaries"
610
AfterTargets="AfterBuild"

0 commit comments

Comments
 (0)