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,194 @@
1
+ /*
2
+ MIT License
3
+
4
+ Copyright (c) 2020 Jeff Campbell
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
24
+
25
+ using System;
26
+ using Playdarium.PackageTool.Tools;
27
+ using UnityEngine;
28
+
29
+ namespace Playdarium.PackageTool
30
+ {
31
+ /// <summary>
32
+ /// <see cref="PackageManifestConfig"/> is an asset config representing a Unity Package. It allows for
33
+ /// defining the data used on the package json file, the locations of source files/assets that make up the
34
+ /// package, and a destination for th package source to be distributed at.
35
+ /// </summary>
36
+ [CreateAssetMenu(fileName = "PackageManifestConfig", menuName = "JCMG/PackageTools/PackageManifestConfig")]
37
+ public sealed class PackageManifestConfig : ScriptableObject
38
+ {
39
+ /// <summary>
40
+ /// Describes a dependency that this package requires.
41
+ /// </summary>
42
+ [Serializable]
43
+ public sealed class Dependency
44
+ {
45
+ /// <summary>
46
+ /// The name of the dependent package.
47
+ /// </summary>
48
+ public string packageName;
49
+
50
+ /// <summary>
51
+ /// The semantic version of the dependent package in MAJOR.MINOR.PATCH format.
52
+ /// </summary>
53
+ public string packageVersion;
54
+
55
+ public bool IsEmpty() => string.IsNullOrEmpty(packageName) || string.IsNullOrEmpty(packageVersion);
56
+ }
57
+
58
+ /// <summary>
59
+ /// Describes the author of this package.
60
+ /// </summary>
61
+ [Serializable]
62
+ public sealed class Author
63
+ {
64
+ public string name = "";
65
+ public string email = "";
66
+ public string url = "";
67
+ }
68
+
69
+ /// <summary>
70
+ /// Describes the samples of this package.
71
+ /// </summary>
72
+ [Serializable]
73
+ public sealed class Sample
74
+ {
75
+ public string displayName;
76
+ public string description;
77
+ public string path;
78
+
79
+ public bool IsEmpty() => string.IsNullOrEmpty(displayName)
80
+ || string.IsNullOrEmpty(description)
81
+ || string.IsNullOrEmpty(path);
82
+ }
83
+
84
+ /// <summary>
85
+ /// A unique id for this <see cref="PackageManifestConfig"/> instance.
86
+ /// </summary>
87
+ public string Id => _id;
88
+
89
+ public string homepage = "https://github.com/";
90
+
91
+ /// <summary>
92
+ /// A collection of paths to folders and files for the source for the package.
93
+ /// </summary>
94
+ // public string[] packageSourcePaths;
95
+ public string sourcePath;
96
+
97
+ public string documentationPath = "Documentation~";
98
+ public string readmePath = "README.md";
99
+ public string changelogPath = "CHANGELOG.md";
100
+ public string licensePath = "LICENSE";
101
+ public string license = "MIT";
102
+
103
+ /// <summary>
104
+ /// A collection of file/folder paths to exclude from the package.
105
+ /// </summary>
106
+ public string[] packageIgnorePaths;
107
+
108
+ /// <summary>
109
+ /// A path to the package source distribution contents.
110
+ /// </summary>
111
+ public string packageDestinationPath;
112
+
113
+ /// <summary>
114
+ /// The relative path to the folder where the legacy package will be exported to.
115
+ /// </summary>
116
+ public string legacyPackageDestinationPath;
117
+
118
+ /// <summary>
119
+ /// The fully-qualified package name.
120
+ /// </summary>
121
+ public string packageName = "";
122
+
123
+ /// <summary>
124
+ /// The package name as it appears in the Package Manager window.
125
+ /// </summary>
126
+ public string displayName;
127
+
128
+ /// <summary>
129
+ /// The semantic version of the package in MAJOR.MINOR.PATCH format.
130
+ /// </summary>
131
+ public string packageVersion = "1.0.0";
132
+
133
+ /// <summary>
134
+ /// The version of Unity in semantic version format like 2018.1.
135
+ /// </summary>
136
+ public string unityVersion = "2021.3";
137
+
138
+ /// <summary>
139
+ /// A description of the package.
140
+ /// </summary>
141
+ public string description;
142
+
143
+ /// <summary>
144
+ /// The category the package belongs in.
145
+ /// </summary>
146
+ public string category = "unity";
147
+
148
+ /// <summary>
149
+ /// The author of this package.
150
+ /// </summary>
151
+ public Author author;
152
+
153
+ /// <summary>
154
+ /// A collection of keywords that describe the package.
155
+ /// </summary>
156
+ public string[] keywords;
157
+
158
+ /// <summary>
159
+ /// A collection of packages that this package depends on.
160
+ /// </summary>
161
+ public Dependency[] dependencies;
162
+
163
+ public Sample[] samples;
164
+
165
+ /// <summary>
166
+ /// A path to the where the VersionConstants.cs file should be created/updated
167
+ /// </summary>
168
+ public string versionConstantsPath;
169
+
170
+ /// <summary>
171
+ /// The namespace the generated VersionConstants class will be in. If left blank, this will be
172
+ /// the global namespace.
173
+ /// </summary>
174
+ public string versionConstantsNamespace;
175
+
176
+ [SerializeField] private string _id;
177
+
178
+ /// <summary>
179
+ /// Returns a Json <see cref="string"/> representation.
180
+ /// </summary>
181
+ /// <returns></returns>
182
+ public string GenerateJson()
183
+ {
184
+ return PackageManifestTools.GenerateJson(this);
185
+ }
186
+
187
+ private void Reset()
188
+ {
189
+ packageVersion = EditorConstants.DEFAULT_PACKAGE_VERSION;
190
+ unityVersion = EditorConstants.DEFAULT_UNITY_VERSION;
191
+ _id = Guid.NewGuid().ToString();
192
+ }
193
+ }
194
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: a29f67b488b4458983fd973bbda8c8fa
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {fileID: 2800000, guid: aa27849da66efed40ac33d6d0da5f64f, type: 3}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "Playdarium.PackageTool.Editor",
3
+ "rootNamespace": "",
4
+ "references": [],
5
+ "includePlatforms": [
6
+ "Editor"
7
+ ],
8
+ "excludePlatforms": [],
9
+ "allowUnsafeCode": false,
10
+ "overrideReferences": false,
11
+ "precompiledReferences": [],
12
+ "autoReferenced": true,
13
+ "defineConstraints": [],
14
+ "versionDefines": [],
15
+ "noEngineReferences": false
16
+ }
@@ -0,0 +1,7 @@
1
+ fileFormatVersion: 2
2
+ guid: 85045da2336f0504692a6f7d7dfd12b7
3
+ AssemblyDefinitionImporter:
4
+ externalObjects: {}
5
+ userData:
6
+ assetBundleName:
7
+ assetBundleVariant:
@@ -0,0 +1,145 @@
1
+ /*
2
+ MIT License
3
+
4
+ Copyright (c) 2020 Jeff Campbell
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
24
+
25
+ using System;
26
+ using System.Globalization;
27
+ using System.IO;
28
+ using UnityEditor;
29
+ using UnityEngine;
30
+
31
+ namespace Playdarium.PackageTool.Tools
32
+ {
33
+ /// <summary>
34
+ /// Helper methods for code-gen.
35
+ /// </summary>
36
+ internal static class CodeGenTools
37
+ {
38
+ private const string TEMPLATE =
39
+ @"namespace ${namespace}
40
+ {
41
+ /// <summary>
42
+ /// Version info for this library.
43
+ /// </summary>
44
+ internal static class VersionConstants
45
+ {
46
+ /// <summary>
47
+ /// The semantic version
48
+ /// </summary>
49
+ public const string VERSION = ""${version}"";
50
+
51
+ /// <summary>
52
+ /// The branch of GIT this package was published from.
53
+ /// </summary>
54
+ public const string GIT_BRANCH = ""${git_branch}"";
55
+
56
+ /// <summary>
57
+ /// The current GIT commit hash this package was published on.
58
+ /// </summary>
59
+ public const string GIT_COMMIT = ""${git_commit}"";
60
+
61
+ /// <summary>
62
+ /// The UTC human-readable date this package was published at.
63
+ /// </summary>
64
+ public const string PUBLISH_DATE = ""${publish_date}"";
65
+
66
+ /// <summary>
67
+ /// The UTC time this package was published at.
68
+ /// </summary>
69
+ public const string PUBLISH_TIME = ""${publish_utc_time}"";
70
+ }
71
+ }
72
+ ";
73
+
74
+ private const string GLOBAL_TEMPLATE =
75
+ @"/// <summary>
76
+ /// Version info for this library.
77
+ /// </summary>
78
+ internal static class VersionConstants
79
+ {
80
+ /// <summary>
81
+ /// The semantic version
82
+ /// </summary>
83
+ public const string VERSION = ""${version}"";
84
+
85
+ /// <summary>
86
+ /// The branch of GIT this package was published from.
87
+ /// </summary>
88
+ public const string GIT_BRANCH = ""${git_branch}"";
89
+
90
+ /// <summary>
91
+ /// The current GIT commit hash this package was published on.
92
+ /// </summary>
93
+ public const string GIT_COMMIT = ""${git_commit}"";
94
+
95
+ /// <summary>
96
+ /// The UTC human-readable date this package was published at.
97
+ /// </summary>
98
+ public const string PUBLISH_DATE = ""${publish_date}"";
99
+
100
+ /// <summary>
101
+ /// The UTC time this package was published at.
102
+ /// </summary>
103
+ public const string PUBLISH_TIME = ""${publish_utc_time}"";
104
+ }
105
+ ";
106
+
107
+ // Filename
108
+ private const string FILENAME = "VersionConstants.cs";
109
+
110
+ // Logs
111
+ private const string NO_PATH_SPECIFIED = "A path must be specified for the VersionConstants.cs file to be written " +
112
+ "to, otherwise this file will not be created.";
113
+
114
+ public static void GenerateVersionConstants(PackageManifestConfig config)
115
+ {
116
+ if(string.IsNullOrEmpty(config.versionConstantsPath))
117
+ {
118
+ Debug.LogWarning(NO_PATH_SPECIFIED);
119
+ return;
120
+ }
121
+
122
+ // Create folder/file path info
123
+ var folderPath = Path.GetFullPath(config.versionConstantsPath);
124
+ var filePath = Path.Combine(folderPath, FILENAME);
125
+
126
+ // Create file contents
127
+ var template = string.IsNullOrEmpty(config.versionConstantsNamespace)
128
+ ? GLOBAL_TEMPLATE
129
+ : TEMPLATE;
130
+
131
+ var fileContents = template
132
+ .Replace("${namespace}", config.versionConstantsNamespace)
133
+ .Replace("${version}", config.packageVersion)
134
+ .Replace("${git_branch}", GitTools.GetBranch())
135
+ .Replace("${git_commit}", GitTools.GetLongHeadHash())
136
+ .Replace("${publish_date}", DateTime.UtcNow.ToLongDateString())
137
+ .Replace("${publish_utc_time}", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture));
138
+
139
+ File.WriteAllText(filePath, fileContents);
140
+
141
+ var importPath = Path.Combine(config.versionConstantsPath, FILENAME);
142
+ AssetDatabase.ImportAsset(importPath);
143
+ }
144
+ }
145
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 55647bcc8b6f00c45ad3336e9f952e8d
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -0,0 +1,68 @@
1
+ /*
2
+ MIT License
3
+
4
+ Copyright (c) 2020 Jeff Campbell
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
24
+
25
+ using System;
26
+ using System.Collections.Generic;
27
+
28
+ namespace Playdarium.PackageTool.Tools
29
+ {
30
+ /// <summary>
31
+ /// Helper methods for command-line usage
32
+ /// </summary>
33
+ public static class CommandLineTools
34
+ {
35
+ // Command-Line Delimiters
36
+ private const string ARGUMENT_DELIMITER_STR = "=";
37
+ private const char ARGUMENT_DELIMITER_CHAR = '=';
38
+
39
+ /// <summary>
40
+ /// Returns a more easily-searchable <see cref="Dictionary{TKey,TValue}"/> of command-line arguments.
41
+ /// </summary>
42
+ /// <returns></returns>
43
+ public static Dictionary<string, object> GetKVPCommandLineArguments()
44
+ {
45
+ var dict = new Dictionary<string, object>();
46
+ var arguments = Environment.GetCommandLineArgs();
47
+ foreach (var argument in arguments)
48
+ {
49
+ // If the commandline argument contains a value, parse that and add it
50
+ if (argument.Contains(ARGUMENT_DELIMITER_STR))
51
+ {
52
+ var array = argument.Split(ARGUMENT_DELIMITER_CHAR);
53
+ var key = array[0].ToLower();
54
+ var value = array[1];
55
+
56
+ dict.Add(key, value);
57
+ }
58
+ // Otherwise add the command line argument as a key without a value.
59
+ else if (!dict.ContainsKey(argument))
60
+ {
61
+ dict.Add(argument, null);
62
+ }
63
+ }
64
+
65
+ return dict;
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 6bb959778362eb843bb141f1f1960e92
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: