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

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,22 @@
2
2
 
3
3
  ---
4
4
 
5
+ ## [2.2.2](https://gitlab.com/elestrago-pkg/package-tool/-/tags/2.2.2)
6
+
7
+ ### Changed
8
+
9
+ - Simplified the `Claude Skills` post-import hook to rely on self-deletion for deduplication, removing the `SessionState` guards so a re-import within the same Unity session runs again instead of being silently skipped.
10
+
11
+ ---
12
+
13
+ ## [2.2.1](https://gitlab.com/elestrago-pkg/package-tool/-/tags/2.2.1)
14
+
15
+ ### Added
16
+
17
+ - 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.
18
+
19
+ ---
20
+
5
21
  ## [2.2.0](https://gitlab.com/elestrago-pkg/package-tool/-/tags/2.2.0)
6
22
 
7
23
  ### Added
@@ -7,10 +7,12 @@ using UnityEngine;
7
7
  namespace PackageTool.Samples.ClaudeSkills
8
8
  {
9
9
  /// <summary>
10
- /// Runs once after the "Claude Skills" sample is imported into a consumer project. Walks every
11
- /// skill subfolder next to this script, copies it to <c>&lt;project&gt;/.claude/skills/&lt;name&gt;</c>,
12
- /// prompting before overwriting an existing skill, and then deletes the imported sample folder so
13
- /// the operation does not repeat on subsequent domain reloads.
10
+ /// Runs after the "Claude Skills" sample is imported into a consumer project. Walks every skill
11
+ /// subfolder next to this script, copies it to <c>&lt;project&gt;/.claude/skills/&lt;name&gt;</c>,
12
+ /// prompting before overwriting an existing skill, then deletes the imported sample folder
13
+ /// (including this script itself). Self-deletion is the only dedup mechanism: once gone the type
14
+ /// can't trigger again until the consumer re-imports the sample, which is exactly when a fresh
15
+ /// run is wanted.
14
16
  /// </summary>
15
17
  [InitializeOnLoad]
16
18
  internal static class ClaudeSkillsPostImport
@@ -20,8 +22,6 @@ namespace PackageTool.Samples.ClaudeSkills
20
22
  private const string EDITOR_FOLDER_NAME = "Editor";
21
23
  private const string SCRIPT_FILE_NAME = "ClaudeSkillsPostImport.cs";
22
24
  private const string DIALOG_TITLE = "Claude Skills";
23
- private const string SESSION_GUARD_KEY_PREFIX = "PackageTool.ClaudeSkillsPostImport.Processed:";
24
- private const string SESSION_RUNNING_KEY = "PackageTool.ClaudeSkillsPostImport.Running";
25
25
 
26
26
  static ClaudeSkillsPostImport()
27
27
  {
@@ -30,27 +30,15 @@ namespace PackageTool.Samples.ClaudeSkills
30
30
 
31
31
  private static void Run()
32
32
  {
33
- // Re-entrancy guard. Multiple copies of this type (e.g. in side-by-side sample imports
34
- // each shipping their own assembly) would each schedule a delayCall; without this guard
35
- // they would race on the same sample folders and double-prompt the user.
36
- if (SessionState.GetBool(SESSION_RUNNING_KEY, false))
37
- return;
38
- SessionState.SetBool(SESSION_RUNNING_KEY, true);
39
-
40
33
  try
41
34
  {
42
35
  foreach (var sampleRootAssetPath in FindSampleRootAssetPaths())
43
36
  {
44
- // Only run from an imported sample location; never act on the source folder
45
- // inside a package author's project.
37
+ // Only act on imported sample locations; never touch the source folder inside a
38
+ // package author's project.
46
39
  if (!sampleRootAssetPath.StartsWith("Assets/Samples/", StringComparison.Ordinal))
47
40
  continue;
48
41
 
49
- var guardKey = SESSION_GUARD_KEY_PREFIX + sampleRootAssetPath;
50
- if (SessionState.GetBool(guardKey, false))
51
- continue;
52
- SessionState.SetBool(guardKey, true);
53
-
54
42
  ProcessSample(sampleRootAssetPath);
55
43
  }
56
44
  }
@@ -58,10 +46,6 @@ namespace PackageTool.Samples.ClaudeSkills
58
46
  {
59
47
  Debug.LogErrorFormat("{0} Post-import failed: {1}", LOG_PREFIX, e);
60
48
  }
61
- finally
62
- {
63
- SessionState.SetBool(SESSION_RUNNING_KEY, false);
64
- }
65
49
  }
66
50
 
67
51
  private static IEnumerable<string> FindSampleRootAssetPaths()
@@ -152,10 +136,56 @@ namespace PackageTool.Samples.ClaudeSkills
152
136
  "{0} Done. Installed: {1}, Replaced: {2}, Skipped: {3}.",
153
137
  LOG_PREFIX, installed, replaced, skipped);
154
138
 
155
- AssetDatabase.DeleteAsset(sampleRootAssetPath);
139
+ DeleteSampleAndEmptyAncestors(sampleRootAssetPath);
140
+ }
141
+
142
+ private static void DeleteSampleAndEmptyAncestors(string sampleRootAssetPath)
143
+ {
144
+ if (!AssetDatabase.DeleteAsset(sampleRootAssetPath))
145
+ {
146
+ Debug.LogWarningFormat(
147
+ "{0} Could not remove imported sample folder [{1}].",
148
+ LOG_PREFIX,
149
+ sampleRootAssetPath);
150
+ AssetDatabase.Refresh();
151
+ return;
152
+ }
153
+
154
+ // Walk up Assets/Samples/<Package>/<Version>/<Sample>, removing each ancestor that the
155
+ // just-deleted sample left empty. Bounded to the Assets/Samples subtree so we never
156
+ // touch unrelated project folders.
157
+ var current = GetParentAssetPath(sampleRootAssetPath);
158
+ while (!string.IsNullOrEmpty(current) && IsWithinSamplesTree(current))
159
+ {
160
+ var fullPath = Path.GetFullPath(current);
161
+ if (!Directory.Exists(fullPath))
162
+ break;
163
+ if (Directory.GetFileSystemEntries(fullPath).Length > 0)
164
+ break;
165
+ if (!AssetDatabase.DeleteAsset(current))
166
+ break;
167
+
168
+ Debug.LogFormat("{0} Removed empty folder [{1}].", LOG_PREFIX, current);
169
+ current = GetParentAssetPath(current);
170
+ }
171
+
156
172
  AssetDatabase.Refresh();
157
173
  }
158
174
 
175
+ private static string GetParentAssetPath(string assetPath)
176
+ {
177
+ if (string.IsNullOrEmpty(assetPath))
178
+ return null;
179
+ var lastSlash = assetPath.LastIndexOf('/');
180
+ return lastSlash <= 0 ? null : assetPath.Substring(0, lastSlash);
181
+ }
182
+
183
+ private static bool IsWithinSamplesTree(string assetPath)
184
+ {
185
+ return string.Equals(assetPath, "Assets/Samples", StringComparison.Ordinal)
186
+ || assetPath.StartsWith("Assets/Samples/", StringComparison.Ordinal);
187
+ }
188
+
159
189
  private static void CopySkillDirectory(string source, string destination)
160
190
  {
161
191
  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.2",
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.2/README.md",
10
+ "changelogUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.2/CHANGELOG.md",
11
+ "licensesUrl": "https://gitlab.com/elestrago-pkg/package-tool/-/blob/2.2.2/LICENSE",
12
12
  "license": "MIT",
13
13
  "keywords": [
14
14
  "unity",