com.elestrago.unity.package-tools 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/CAHNGELOG.md +130 -0
  2. package/CAHNGELOG.md.meta +7 -0
  3. package/Documentation~/Inspector.png +0 -0
  4. package/Documentation~/PackageManifestConfigIcon.png +0 -0
  5. package/Editor/CIUtils.cs +247 -0
  6. package/Editor/CIUtils.cs.meta +11 -0
  7. package/Editor/Drawers/AuthorPropertyDrawer.cs +82 -0
  8. package/Editor/Drawers/AuthorPropertyDrawer.cs.meta +11 -0
  9. package/Editor/Drawers/DependencyPropertyDrawer.cs +60 -0
  10. package/Editor/Drawers/DependencyPropertyDrawer.cs.meta +3 -0
  11. package/Editor/Drawers/SamplePropertyDrawer.cs +62 -0
  12. package/Editor/Drawers/SamplePropertyDrawer.cs.meta +3 -0
  13. package/Editor/Drawers.meta +3 -0
  14. package/Editor/EditorConstants.cs +110 -0
  15. package/Editor/EditorConstants.cs.meta +3 -0
  16. package/Editor/IconMap/PackageManifestConfigIcon.png +0 -0
  17. package/Editor/IconMap/PackageManifestConfigIcon.png.meta +127 -0
  18. package/Editor/IconMap.meta +8 -0
  19. package/Editor/Inspectors/PackageManifestConfigInspector.cs +404 -0
  20. package/Editor/Inspectors/PackageManifestConfigInspector.cs.meta +3 -0
  21. package/Editor/Inspectors.meta +3 -0
  22. package/Editor/MenuItems.cs +11 -0
  23. package/Editor/MenuItems.cs.meta +11 -0
  24. package/Editor/PackageManifestConfig.cs +194 -0
  25. package/Editor/PackageManifestConfig.cs.meta +11 -0
  26. package/Editor/Playdarium.PackageTool.Editor.asmdef +16 -0
  27. package/Editor/Playdarium.PackageTool.Editor.asmdef.meta +7 -0
  28. package/Editor/Tools/CodeGenTools.cs +145 -0
  29. package/Editor/Tools/CodeGenTools.cs.meta +11 -0
  30. package/Editor/Tools/CommandLineTools.cs +68 -0
  31. package/Editor/Tools/CommandLineTools.cs.meta +11 -0
  32. package/Editor/Tools/FileTools.cs +328 -0
  33. package/Editor/Tools/FileTools.cs.meta +3 -0
  34. package/Editor/Tools/GUILayoutTools.cs +177 -0
  35. package/Editor/Tools/GUILayoutTools.cs.meta +3 -0
  36. package/Editor/Tools/GitTools.cs +66 -0
  37. package/Editor/Tools/GitTools.cs.meta +11 -0
  38. package/Editor/Tools/PackageJsonModel.cs +149 -0
  39. package/Editor/Tools/PackageJsonModel.cs.meta +3 -0
  40. package/Editor/Tools/PackageManifestTools.cs +77 -0
  41. package/Editor/Tools/PackageManifestTools.cs.meta +3 -0
  42. package/Editor/Tools/UnityFileTools.cs +132 -0
  43. package/Editor/Tools/UnityFileTools.cs.meta +3 -0
  44. package/Editor/Tools.meta +3 -0
  45. package/Editor/Utils/PackageInitialize/PackageInitializeTemplates.cs +171 -0
  46. package/Editor/Utils/PackageInitialize/PackageInitializeTemplates.cs.meta +3 -0
  47. package/Editor/Utils/PackageInitialize/PackageInitializeUtil.cs +111 -0
  48. package/Editor/Utils/PackageInitialize/PackageInitializeUtil.cs.meta +3 -0
  49. package/Editor/Utils/PackageInitialize/PackageInitializeWindow.cs +92 -0
  50. package/Editor/Utils/PackageInitialize/PackageInitializeWindow.cs.meta +3 -0
  51. package/Editor/Utils/PackageInitialize.meta +3 -0
  52. package/Editor/Utils.meta +3 -0
  53. package/Editor.meta +3 -0
  54. package/LICENSE +21 -0
  55. package/LICENSE.meta +7 -0
  56. package/README.md +204 -0
  57. package/README.md.meta +7 -0
  58. package/package.json +41 -0
  59. package/package.json.meta +7 -0
@@ -0,0 +1,92 @@
1
+ using System.IO;
2
+ using UnityEditor;
3
+ using UnityEngine;
4
+
5
+ namespace Playdarium.PackageTool.Utils.PackageInitialize
6
+ {
7
+ public class PackageInitializeWindow : EditorWindow
8
+ {
9
+ private const string DISPLAY_NAME_FIELD = "Display Name";
10
+ private const string PACKAGE_NAME_FIELD = "Package Name";
11
+ private const string SCOPE_FIELD = "Scope";
12
+ private const string AUTHOR_FIELD = "Author";
13
+ private const string GIT_URL_FIELD = "Git URL";
14
+ private const string LICENSE_FIELD = "License";
15
+
16
+ private string _displayName = "Package Name";
17
+ private string _packageName = "com.example.package";
18
+ private string _scope = "com.example";
19
+ private string _author = "Name";
20
+ private string _gitURL = "https://gitlab.com/user/package";
21
+ private string _license = "MIT";
22
+
23
+ public static void Open()
24
+ {
25
+ var window = GetWindow<PackageInitializeWindow>(false, "Init Package");
26
+ window.ShowPopup();
27
+ window.minSize = new Vector2(300, 150);
28
+ }
29
+
30
+ private void OnGUI()
31
+ {
32
+ DrawTextField(DISPLAY_NAME_FIELD, ref _displayName);
33
+ DrawTextField(PACKAGE_NAME_FIELD, ref _packageName);
34
+ DrawTextField(SCOPE_FIELD, ref _scope);
35
+ DrawTextField(AUTHOR_FIELD, ref _author);
36
+ DrawTextField(GIT_URL_FIELD, ref _gitURL);
37
+ DrawTextField(LICENSE_FIELD, ref _license);
38
+
39
+ if (GUILayout.Button("Create"))
40
+ CreatePackageFiles();
41
+ }
42
+
43
+ private void CreatePackageFiles()
44
+ {
45
+ var valid = ValidateField(DISPLAY_NAME_FIELD, _displayName);
46
+ valid &= ValidateField(PACKAGE_NAME_FIELD, _packageName);
47
+ valid &= ValidateField(SCOPE_FIELD, _scope);
48
+ valid &= ValidateField(AUTHOR_FIELD, _author);
49
+ valid &= ValidateField(GIT_URL_FIELD, _gitURL);
50
+ valid &= ValidateField(LICENSE_FIELD, _license);
51
+
52
+ if (!valid)
53
+ {
54
+ EditorUtility.DisplayDialog("Init Package", "All fields must be completed", "Ok");
55
+ return;
56
+ }
57
+
58
+ var config = CreateInstance<PackageManifestConfig>();
59
+ config.displayName = _displayName;
60
+ config.packageName = _packageName;
61
+ config.homepage = _gitURL;
62
+ config.license = _license;
63
+ config.author = new PackageManifestConfig.Author
64
+ {
65
+ name = _author
66
+ };
67
+ config.packageDestinationPath = PackageInitializeUtil.RELEASE_FOLDER_NAME;
68
+ config.sourcePath = Path.Combine(
69
+ PackageInitializeUtil.ASSETS_FOLDER_NAME,
70
+ config.author.name,
71
+ config.displayName.Replace(" ", string.Empty)
72
+ );
73
+
74
+ PackageInitializeUtil.Init(_scope, config);
75
+
76
+ if (EditorUtility.DisplayDialog("Init Package", "Successful created", "Ok"))
77
+ Close();
78
+ }
79
+
80
+ private static bool ValidateField(string name, string value)
81
+ {
82
+ if (!string.IsNullOrWhiteSpace(value))
83
+ return true;
84
+
85
+ Debug.LogError($"[{nameof(PackageInitializeWindow)}] Field with name '{name}' cannot be empty");
86
+ return false;
87
+ }
88
+
89
+ private static void DrawTextField(string label, ref string value)
90
+ => value = EditorGUILayout.TextField(label, value);
91
+ }
92
+ }
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: ad10d8fc899f416dadb1cfa838ce234e
3
+ timeCreated: 1662388832
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: e4ce4c1c72b44784a72207369503a9e2
3
+ timeCreated: 1662377237
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 03966419edf24ae1a3be75fc83721788
3
+ timeCreated: 1662377224
package/Editor.meta ADDED
@@ -0,0 +1,3 @@
1
+ fileFormatVersion: 2
2
+ guid: 2f77ac48c6a44b1dab1bc00aabe75b33
3
+ timeCreated: 1655821530
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Jeff Campbell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/LICENSE.meta ADDED
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: a22c73495e08f7f749a40d57064251e1
3
+ DefaultImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/README.md ADDED
@@ -0,0 +1,204 @@
1
+ # <img src="./Documentation~/PackageManifestConfigIcon.png" alt="" width="35" height="35"/> Package Tool
2
+
3
+ [![NPM package](https://img.shields.io/npm/v/com.elestrago.unity.package-tools?logo=npm&logoColor=fff&label=NPM+package&color=limegreen)](https://www.npmjs.com/package/com.elestrago.unity.package-tools)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ ## Installing
7
+
8
+ Using the native Unity Package Manager introduced in 2017.2, you can add this library as a package by modifying your
9
+ `manifest.json` file found at `/ProjectName/Packages/manifest.json` to include it as a dependency. See the example below
10
+ on how to reference it.
11
+
12
+ ### Install via OpenUPM
13
+
14
+ The package is available on the [npmjs](https://www.npmjs.com/package/com.elestrago.unity.package-tools)
15
+ registry.
16
+
17
+ #### Add registry scope
18
+
19
+ ```
20
+ {
21
+ "dependencies": {
22
+ ...
23
+ "com.elestrago.unity.package-tools": "x.x.x",
24
+ ...
25
+ },
26
+ "scopedRegistries": [
27
+ {
28
+ "name": "eLeSTRaGo",
29
+ "url": "https://registry.npmjs.org",
30
+ "scopes": [
31
+ "com.elestrago.unity"
32
+ ]
33
+ }
34
+ ]
35
+ }
36
+ ```
37
+
38
+ #### Add package in PackageManager
39
+
40
+ Open `Window -> Package Manager` choose `Packages: My Regestries` and install package
41
+
42
+ ## Setting up your first package
43
+
44
+ Creating your first package is a simple process that can be made more complex because information available about Unity
45
+ Package manager is inconsistent right now. This is largely due to it not being widely and officially supported for
46
+ end-users of Unity yet, but starting with 2019.1 will gain more official support.
47
+
48
+ The first step is to create a `PackageManifestConfig` asset that we can use to define the properties and contents of our
49
+ package. This can be done by right-clicking in the `Project` window and
50
+ selecting `Create -> JCMG -> Package Tools -> Package
51
+ Manifest Config`. This will create an asset named `PackageManifestConfig` in that folder.
52
+
53
+ <img src="./Documentation~/Inspector.png" width="500">
54
+
55
+ A `PackageManifestConfig` is broken up into two sections:
56
+
57
+ * **Package Json:** This section contains fields relating to properties of the `package.json` file that we will need to
58
+ have in our package root folder. It describes the minimum Unity version that it is compatible with and the version of
59
+ the package itself [Semantic versioning](https://docs.unity3d.com/Manual/upm-semver.html), a
60
+ description of the package, and any dependencies it
61
+ has on other packages. This last part I have the least information about, but is supposed to gain more widespread
62
+ support in 2019.1.
63
+ * **Package Content and Export:** This section focuses on defining the folders/files that make up the content (including
64
+ code and assets) that make up the package itself and a location that the content will be published to when clicking on
65
+ the button labeled `Export Package Source`.
66
+
67
+ For convenience sake, I have added file and folder pickers as buttons to the right of these fields that make it easier
68
+ to add relative file/folder paths from the Assets folder for package source and export location.
69
+
70
+ There are also options for excluding specific files and/or folders from the package source that might otherwise be
71
+ included. This can be useful for example, if there are unit tests or example content located within your package source
72
+ path that you would not want to include directly or indirectly. Folders and files can be excluded by adding them to
73
+ the **ExcludePaths** list.
74
+
75
+ Recently I have found myself manually creating a `VersionConstants` static class containing versioning information about
76
+ the package itself. This can be useful for displaying to a user or checking for updates outside of the native Unity
77
+ PackageManager window.. Since updating this file by hand can be error-prone or easy to forget, this can now be
78
+ configured on a `PackageManifestConfig` and generated using a new action `Generate VersionConstants.cs` on the config's
79
+ inspector.
80
+
81
+ **Example VersionConstants.cs used in JCMG.PackageTools**
82
+
83
+ ```csharp
84
+ namespace JCMG.PackageTools.Editor
85
+ {
86
+ /// <summary>
87
+ /// Version info for this library.
88
+ /// </summary>
89
+ internal static class VersionConstants
90
+ {
91
+ /// <summary>
92
+ /// The semantic version
93
+ /// </summary>
94
+ public const string VERSION = "1.3.0";
95
+
96
+ /// <summary>
97
+ /// The branch of GIT this package was published from.
98
+ /// </summary>
99
+ public const string GIT_BRANCH = "develop";
100
+
101
+ /// <summary>
102
+ /// The current GIT commit hash this package was published on.
103
+ /// </summary>
104
+ public const string GIT_COMMIT = "57aec574ed19746de42ffa5032358562fb041ebf";
105
+
106
+ /// <summary>
107
+ /// The UTC human-readable date this package was published at.
108
+ /// </summary>
109
+ public const string PUBLISH_DATE = "Friday, May 1, 2020";
110
+
111
+ /// <summary>
112
+ /// The UTC time this package was published at.
113
+ /// </summary>
114
+ public const string PUBLISH_TIME = "05/01/2020 08:26:31";
115
+ }
116
+ }
117
+
118
+ ```
119
+
120
+ The contents of this file can be configured based on the use of a text template. A default one is provided
121
+ at `JCMG\PackageTools\Scripts\Editor\Templates\VersionConstants.txt` and a custom template can be used instead by
122
+ providing it's meta GUID on the `PackageManifestConfig` `versionTemplateGuid` field. There is an example of this in the
123
+ development project
124
+
125
+ Example Template
126
+
127
+ ```csharp
128
+ namespace JCMG.PackageTools.Editor
129
+ {
130
+ /// <summary>
131
+ /// Version info for this library.
132
+ /// </summary>
133
+ internal static class VersionConstants
134
+ {
135
+ /// <summary>
136
+ /// The semantic version
137
+ /// </summary>
138
+ public const string VERSION = "${version}";
139
+
140
+ /// <summary>
141
+ /// The branch of GIT this package was published from.
142
+ /// </summary>
143
+ public const string GIT_BRANCH = "${git_branch}";
144
+
145
+ /// <summary>
146
+ /// The current GIT commit hash this package was published on.
147
+ /// </summary>
148
+ public const string GIT_COMMIT = "${git_commit}";
149
+
150
+ /// <summary>
151
+ /// The UTC human-readable date this package was published at.
152
+ /// </summary>
153
+ public const string PUBLISH_DATE = "${publish_date}";
154
+
155
+ /// <summary>
156
+ /// The UTC time this package was published at.
157
+ /// </summary>
158
+ public const string PUBLISH_TIME = "${publish_utc_time}";
159
+ }
160
+ }
161
+
162
+ ```
163
+
164
+ ## Generating packages from command-line
165
+
166
+ It can be desirable at times to generate legacy Unity packages and/or package source from the command-line so that they
167
+ can be created and distributed as part of a continuous integration (CI) process. For example, you may want to trigger a
168
+ process every time the repository is updated and source files changed so that a new package is created and made
169
+ available to users. This can be done by launching the Unity Editor from the command line and supplying the appropriate
170
+ arguments.
171
+
172
+ **Example Command-Line Call**
173
+
174
+ `"D:\Program Files\2019.4.11f1\Editor\Unity.exe" -quit -batchmode -executeMethod JCMG.PackageTools.Editor.PackageToolsCI.Generate version=1.0.1 GenerateVersionConstants=true`
175
+
176
+ In this case, the `-executeMethod JCMG.PackageTools.Editor.PackageToolsCI.Generate` is the CLI argument that will
177
+ trigger the PackageTools CI process to execute. By default, this will find all `PackageManifestConfig` instances in the
178
+ project and if they have an appropriate output path will generate the legacy Unity package and/or package source.
179
+ Progress will be output to the Unity Editor player log.
180
+
181
+ ### Arguments
182
+
183
+ #### ID
184
+
185
+ An optional `ID` CLI argument (case-insensitive) that can be supplied with one or more `ID` values to limit the package
186
+ generation to a subset of `PackageManifestConfig` instances in the project if so desired. These `ID` values should
187
+ correspond to the `ID` displayed on the `PackageManifestConfig` inspector for that instance. If not supplied, all
188
+
189
+ **Example ID Argument Usage (for three ID values passed)**
190
+
191
+ `id=cb87cda2-0bfa-44dc-b583-ae61ff81efcb,e1725f4a-f9f3-42c0-ac15-756f017c90ed,6a406891-59d5-430a-815d-c252deae5d5b`
192
+
193
+ #### Version
194
+
195
+ An optional `Version` CLI argument (case-insensitive) can be supplied which will both override and set the value of the
196
+ package version used on the `PackageManifestConfig` `packageVersion` field. This can be useful where the semantic
197
+ package version value should be coming from an external source to the Unity project.
198
+
199
+ #### GenerateVersionConstants
200
+
201
+ An optional `GenerateVersionConstants` CLI argument (case-insensitive) can be supplied which will force
202
+ the `VersionConstants` file to be written out prior to generating the package (if a path is specified for it on
203
+ the `PackageManifestConfig`). This can be useful where this file is created as a result of a CI build and has it's
204
+ version number set by the `version` argument.
package/README.md.meta ADDED
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 5048cbafbf03341dfacb2a14477a6e17
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "com.elestrago.unity.package-tools",
3
+ "version": "2.0.7",
4
+ "displayName": "Package Tool",
5
+ "description": "Tool for create unity packages",
6
+ "category": "unity",
7
+ "unity": "2021.3",
8
+ "homepage": "https://gitlab.com/elestrago-pkg/package-tool",
9
+ "documentationUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/main/README.md",
10
+ "changelogUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/main/CHANGELOG.md",
11
+ "licensesUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/main/LICENSE",
12
+ "license": "MIT",
13
+ "keywords": [
14
+ "unity",
15
+ "package",
16
+ "upm",
17
+ "npm"
18
+ ],
19
+ "dependencies": {
20
+ "com.unity.nuget.newtonsoft-json": "3.2.1"
21
+ },
22
+ "samples": [
23
+ {
24
+ "displayName": "Example Project",
25
+ "description": "This is example project for check test samples",
26
+ "path": "Samples~/Example Project"
27
+ }
28
+ ],
29
+ "author": {
30
+ "name": "eLeSTRaGo",
31
+ "email": "elestrago63@gmail.com",
32
+ "url": "https://gitlab.com/elestrago"
33
+ },
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://gitlab.com/elestrago-pkg/package-tool.git"
37
+ },
38
+ "bugs": {
39
+ "url": "https://gitlab.com/elestrago-pkg/package-tool/-/issues"
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: e77d048871975424ab7c0c300147205e
3
+ TextScriptImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant: