com.elestrago.unity.package-tools 2.2.0 → 2.2.1

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.
package/CAHNGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ---
4
4
 
5
+ ## [2.2.1](https://gitlab.com/elestrago-pkg/package-tool/-/tags/2.2.1)
6
+
7
+ ### Added
8
+
9
+ - Added cleanup of empty ancestor folders under `Assets/Samples/` after the `Claude Skills` post-import hook finishes, so importing the sample leaves no stub `Assets/Samples/<Package>/<Version>/` directories behind.
10
+
11
+ ---
12
+
5
13
  ## [2.2.0](https://gitlab.com/elestrago-pkg/package-tool/-/tags/2.2.0)
6
14
 
7
15
  ### Added
@@ -152,10 +152,56 @@ namespace PackageTool.Samples.ClaudeSkills
152
152
  "{0} Done. Installed: {1}, Replaced: {2}, Skipped: {3}.",
153
153
  LOG_PREFIX, installed, replaced, skipped);
154
154
 
155
- AssetDatabase.DeleteAsset(sampleRootAssetPath);
155
+ DeleteSampleAndEmptyAncestors(sampleRootAssetPath);
156
+ }
157
+
158
+ private static void DeleteSampleAndEmptyAncestors(string sampleRootAssetPath)
159
+ {
160
+ if (!AssetDatabase.DeleteAsset(sampleRootAssetPath))
161
+ {
162
+ Debug.LogWarningFormat(
163
+ "{0} Could not remove imported sample folder [{1}].",
164
+ LOG_PREFIX,
165
+ sampleRootAssetPath);
166
+ AssetDatabase.Refresh();
167
+ return;
168
+ }
169
+
170
+ // Walk up Assets/Samples/<Package>/<Version>/<Sample>, removing each ancestor that the
171
+ // just-deleted sample left empty. Bounded to the Assets/Samples subtree so we never
172
+ // touch unrelated project folders.
173
+ var current = GetParentAssetPath(sampleRootAssetPath);
174
+ while (!string.IsNullOrEmpty(current) && IsWithinSamplesTree(current))
175
+ {
176
+ var fullPath = Path.GetFullPath(current);
177
+ if (!Directory.Exists(fullPath))
178
+ break;
179
+ if (Directory.GetFileSystemEntries(fullPath).Length > 0)
180
+ break;
181
+ if (!AssetDatabase.DeleteAsset(current))
182
+ break;
183
+
184
+ Debug.LogFormat("{0} Removed empty folder [{1}].", LOG_PREFIX, current);
185
+ current = GetParentAssetPath(current);
186
+ }
187
+
156
188
  AssetDatabase.Refresh();
157
189
  }
158
190
 
191
+ private static string GetParentAssetPath(string assetPath)
192
+ {
193
+ if (string.IsNullOrEmpty(assetPath))
194
+ return null;
195
+ var lastSlash = assetPath.LastIndexOf('/');
196
+ return lastSlash <= 0 ? null : assetPath.Substring(0, lastSlash);
197
+ }
198
+
199
+ private static bool IsWithinSamplesTree(string assetPath)
200
+ {
201
+ return string.Equals(assetPath, "Assets/Samples", StringComparison.Ordinal)
202
+ || assetPath.StartsWith("Assets/Samples/", StringComparison.Ordinal);
203
+ }
204
+
159
205
  private static void CopySkillDirectory(string source, string destination)
160
206
  {
161
207
  Directory.CreateDirectory(destination);
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "com.elestrago.unity.package-tools",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "displayName": "Package Tool",
5
5
  "description": "Tool for create unity packages",
6
6
  "category": "unity",
7
7
  "unity": "2021.3",
8
8
  "homepage": "https://gitlab.com/elestrago-pkg/package-tool",
9
- "documentationUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.0/README.md",
10
- "changelogUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.0/CHANGELOG.md",
11
- "licensesUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.0/LICENSE",
9
+ "documentationUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.1/README.md",
10
+ "changelogUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.1/CHANGELOG.md",
11
+ "licensesUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.1/LICENSE",
12
12
  "license": "MIT",
13
13
  "keywords": [
14
14
  "unity",