com.elestrago.unity.package-tools 2.5.1 → 2.5.3

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 (29) hide show
  1. package/CAHNGELOG.md +29 -0
  2. package/Documentation~/api.md +156 -66
  3. package/Documentation~/examples/ciutils-exportlegacypackage.md +32 -0
  4. package/Documentation~/examples/ciutils-exportpackagesource.md +38 -0
  5. package/Documentation~/examples/ciutils-generate.md +13 -8
  6. package/Documentation~/examples/ciutils-listconfigs.md +36 -0
  7. package/Documentation~/examples/packagetoolapi-exportlegacypackage.md +39 -0
  8. package/Documentation~/examples/packagetoolapi-exportpackagesource.md +40 -0
  9. package/Documentation~/examples/packagetoolapi-findconfig.md +46 -0
  10. package/Documentation~/examples/packagetoolapi-generateversionconstants.md +42 -0
  11. package/Documentation~/examples/packagetoolapi-getconfig.md +37 -0
  12. package/Documentation~/examples/packagetoolapi-getconfigs.md +36 -0
  13. package/Documentation~/examples/preparedll.md +1 -1
  14. package/Documentation~/examples.md +12 -1
  15. package/Documentation~/manual.md +39 -23
  16. package/Editor/CIUtils.cs +273 -74
  17. package/Editor/EditorConstants.cs +21 -1
  18. package/Editor/Inspectors/PackageManifestConfigInspector.cs +16 -3
  19. package/Editor/PackageToolApi.cs +141 -0
  20. package/Editor/PackageToolApi.cs.meta +11 -0
  21. package/Editor/Tools/CIResultModel.cs +107 -0
  22. package/Editor/Tools/CIResultModel.cs.meta +11 -0
  23. package/Editor/Tools/CodeGenTools.cs +8 -2
  24. package/Editor/Tools/FileTools.cs +76 -46
  25. package/Editor/Tools/UnityFileTools.cs +16 -2
  26. package/README.md +17 -8
  27. package/Samples~/ClaudeSkills/unity-package-docs/SKILL.md +6 -1
  28. package/Samples~/ClaudeSkills/unity-package-docs/scripts/scan_package.py +1 -1
  29. package/package.json +4 -4
@@ -0,0 +1,40 @@
1
+ <!-- generated by unity-package-docs; safe to regenerate -->
2
+
3
+ # Package Tool — Example: PackageToolApi.ExportPackageSource
4
+
5
+ **Kind:** static-method
6
+
7
+ **Entry point:** [PackageToolApi](../api.md#packagetoolapi)
8
+
9
+ **Declared at:** `Assets/Package/PackageTool/Editor/PackageToolApi.cs:94`
10
+
11
+ ## What it does
12
+
13
+ Exports a package's source layout to the config's `packageDestinationPath` and returns the path of the written `package.json`. This is the programmatic equivalent of the **Export Package Source** inspector button, and the method the button itself calls. Pass `version` to stamp a new `packageVersion` onto the config asset before exporting; leave it null to keep the version already on the asset. Failures throw — wrap the call when the surrounding flow should continue.
14
+
15
+ ## Snippet
16
+
17
+ ```csharp
18
+ using PackageTool;
19
+ using UnityEditor;
20
+ using UnityEngine;
21
+
22
+ internal static class ExportExample
23
+ {
24
+ [MenuItem("Tools/Examples/Export Package Source")]
25
+ private static void Export()
26
+ {
27
+ var config = PackageToolApi.GetConfig("com.elestrago.unity.package-tools");
28
+ var packageJsonPath = PackageToolApi.ExportPackageSource(config, version: "2.6.0");
29
+
30
+ Debug.Log($"Exported package manifest to {packageJsonPath}");
31
+ }
32
+ }
33
+ ```
34
+
35
+ ## Observable effect
36
+
37
+ - `Release/` (the config's `packageDestinationPath`) is wiped and rebuilt with the exported package layout: sources, `package.json`, README, CHANGELOG, LICENSE, `Documentation~/`, `Samples~/`.
38
+ - `Assets/Package/PackageTool/package.json` is rewritten from the config and imported so Unity creates its meta file.
39
+ - The config asset is marked dirty when a `version` is passed, so the new version is saved with the project.
40
+ - The console prints `[Package Tools] Successfully updated package source for [<packageName>].`
@@ -0,0 +1,46 @@
1
+ <!-- generated by unity-package-docs; safe to regenerate -->
2
+
3
+ # Package Tool — Example: PackageToolApi.FindConfig
4
+
5
+ **Kind:** static-method
6
+
7
+ **Entry point:** [PackageToolApi](../api.md#packagetoolapi)
8
+
9
+ **Declared at:** `Assets/Package/PackageTool/Editor/PackageToolApi.cs:26` (and the array overload at `Assets/Package/PackageTool/Editor/PackageToolApi.cs:35`)
10
+
11
+ ## What it does
12
+
13
+ Resolves a selector to a single [PackageManifestConfig](../api.md#packagemanifestconfig), returning null when nothing matches. The selector is compared case-insensitively against the config id (the guid), then the `packageName`, then the config asset name — first match wins — so a caller that knows the package name from `package.json` never has to look up the guid first. A selector matching more than one config throws rather than picking one. The second overload takes a pre-fetched config array, so resolving many selectors costs a single AssetDatabase lookup.
14
+
15
+ ## Snippet
16
+
17
+ ```csharp
18
+ using PackageTool;
19
+ using UnityEditor;
20
+ using UnityEngine;
21
+
22
+ internal static class FindConfigExample
23
+ {
24
+ [MenuItem("Tools/Examples/Find Package Config")]
25
+ private static void Find()
26
+ {
27
+ var config = PackageToolApi.FindConfig("com.elestrago.unity.package-tools");
28
+ if (config == null)
29
+ {
30
+ Debug.LogWarning("No config matched the selector.");
31
+ return;
32
+ }
33
+
34
+ // Resolve several selectors against one lookup of the project.
35
+ var all = PackageToolApi.GetConfigs();
36
+ var byAssetName = PackageToolApi.FindConfig("PackageManifestConfig", all);
37
+
38
+ Debug.Log($"{config.packageName} / {byAssetName?.name}", config);
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## Observable effect
44
+
45
+ - The console prints the resolved package name, or a warning when the selector matches nothing.
46
+ - An ambiguous selector throws an `InvalidOperationException` naming every candidate config and its id.
@@ -0,0 +1,42 @@
1
+ <!-- generated by unity-package-docs; safe to regenerate -->
2
+
3
+ # Package Tool — Example: PackageToolApi.GenerateVersionConstants
4
+
5
+ **Kind:** static-method
6
+
7
+ **Entry point:** [PackageToolApi](../api.md#packagetoolapi)
8
+
9
+ **Declared at:** `Assets/Package/PackageTool/Editor/PackageToolApi.cs:78`
10
+
11
+ ## What it does
12
+
13
+ Writes a `VersionConstants.cs` file at the config's `versionConstantsPath`, stamped with the package version, the current git branch and commit, and the UTC publish time, and returns the path it wrote. Returns null (and logs a warning) when the config has no `versionConstantsPath` set, so a caller can treat "not configured" differently from a failure. Run it before an export when the shipped code needs to report its own version.
14
+
15
+ ## Snippet
16
+
17
+ ```csharp
18
+ using PackageTool;
19
+ using UnityEditor;
20
+ using UnityEngine;
21
+
22
+ internal static class VersionConstantsExample
23
+ {
24
+ [MenuItem("Tools/Examples/Generate Version Constants")]
25
+ private static void Generate()
26
+ {
27
+ var config = PackageToolApi.GetConfig("com.elestrago.unity.package-tools");
28
+ var path = PackageToolApi.GenerateVersionConstants(config);
29
+
30
+ if (string.IsNullOrEmpty(path))
31
+ Debug.LogWarning("No versionConstantsPath is set on the config.");
32
+ else
33
+ Debug.Log($"Wrote {path}");
34
+ }
35
+ }
36
+ ```
37
+
38
+ ## Observable effect
39
+
40
+ - `<versionConstantsPath>/VersionConstants.cs` is created or overwritten with `VERSION`, `GIT_BRANCH`, `GIT_COMMIT` and `PUBLISH_TIME` constants.
41
+ - The file is imported into the AssetDatabase, so Unity recompiles the assembly that contains it.
42
+ - Nothing happens beyond a console warning when the config leaves `versionConstantsPath` blank.
@@ -0,0 +1,37 @@
1
+ <!-- generated by unity-package-docs; safe to regenerate -->
2
+
3
+ # Package Tool — Example: PackageToolApi.GetConfig
4
+
5
+ **Kind:** static-method
6
+
7
+ **Entry point:** [PackageToolApi](../api.md#packagetoolapi)
8
+
9
+ **Declared at:** `Assets/Package/PackageTool/Editor/PackageToolApi.cs:63`
10
+
11
+ ## What it does
12
+
13
+ The throwing counterpart of [PackageToolApi.FindConfig](../api.md#packagetoolapi): resolves a selector the same way (config id, then `packageName`, then asset name) but raises an `InvalidOperationException` instead of returning null when nothing matches. Use it in scripted flows where a missing package is a bug and a null check would only push the failure further down.
14
+
15
+ ## Snippet
16
+
17
+ ```csharp
18
+ using PackageTool;
19
+ using UnityEditor;
20
+
21
+ internal static class GetConfigExample
22
+ {
23
+ [MenuItem("Tools/Examples/Export By Package Name")]
24
+ private static void Export()
25
+ {
26
+ // Throws with a readable message when no config matches the selector.
27
+ var config = PackageToolApi.GetConfig("com.elestrago.unity.package-tools");
28
+
29
+ PackageToolApi.ExportPackageSource(config);
30
+ }
31
+ }
32
+ ```
33
+
34
+ ## Observable effect
35
+
36
+ - The package source is exported when the selector resolves.
37
+ - An unmatched selector throws `[Package Tools] No PackageManifestConfig matches [<selector>]. Selectors match the config id, the package name or the asset name.`
@@ -0,0 +1,36 @@
1
+ <!-- generated by unity-package-docs; safe to regenerate -->
2
+
3
+ # Package Tool — Example: PackageToolApi.GetConfigs
4
+
5
+ **Kind:** static-method
6
+
7
+ **Entry point:** [PackageToolApi](../api.md#packagetoolapi)
8
+
9
+ **Declared at:** `Assets/Package/PackageTool/Editor/PackageToolApi.cs:18`
10
+
11
+ ## What it does
12
+
13
+ Returns every [PackageManifestConfig](../api.md#packagemanifestconfig) asset in the project. Use it to enumerate the packages a project can export — for a custom editor window, a batch action across a multi-package repo, or to resolve several selectors against a single lookup by passing the array to the [PackageToolApi.FindConfig](../api.md#packagetoolapi) overload that accepts one.
14
+
15
+ ## Snippet
16
+
17
+ ```csharp
18
+ using PackageTool;
19
+ using UnityEditor;
20
+ using UnityEngine;
21
+
22
+ internal static class ListConfigsExample
23
+ {
24
+ [MenuItem("Tools/Examples/Log Package Configs")]
25
+ private static void LogConfigs()
26
+ {
27
+ foreach (var config in PackageToolApi.GetConfigs())
28
+ Debug.Log($"{config.packageName} {config.packageVersion} -> {config.packageDestinationPath}", config);
29
+ }
30
+ }
31
+ ```
32
+
33
+ ## Observable effect
34
+
35
+ - The console lists one line per config asset in the project, each pingable back to the asset it came from.
36
+ - Nothing is written to disk — this is a pure lookup over the AssetDatabase.
@@ -6,7 +6,7 @@
6
6
 
7
7
  **Entry point:** [CIUtils](../api.md#ciutils)
8
8
 
9
- **Declared at:** `Assets/Package/PackageTool/Editor/CIUtils.cs:197`
9
+ **Declared at:** `Assets/Package/PackageTool/Editor/CIUtils.cs:319`
10
10
 
11
11
  **Menu path:** `Tools/PackageTools/PrepareDll`
12
12
 
@@ -6,7 +6,7 @@ Short, focused usage examples that exercise this package's public API. Each exam
6
6
 
7
7
  ## Quick start
8
8
 
9
- Start with **Create a PackageManifestConfig** to produce the config asset that drives every other entry point, then run **Tools > PackageTools > Init Package** (`init-package`) to scaffold a new package skeleton against it. For automated builds, **CIUtils.Generate** is the batch-mode entry point and **Tools > PackageTools > PrepareDll** (`preparedll`) is the DLL platform-flag fix-up step that typically runs immediately before it.
9
+ Start with **Create a PackageManifestConfig** to produce the config asset that drives every other entry point, then run **Tools > PackageTools > Init Package** (`init-package`) to scaffold a new package skeleton against it. To export from your own editor code, call [PackageToolApi](api.md#packagetoolapi) — it is the supported in-process surface and every inspector button routes through it. For automated builds, the [CIUtils](api.md#ciutils) methods are the batch-mode entry points (`Generate` for both outputs, `ExportPackageSource` / `ExportLegacyPackage` for one of them, `ListConfigs` for discovery) and **Tools > PackageTools > PrepareDll** (`preparedll`) is the DLL platform-flag fix-up step that typically runs immediately before them.
10
10
 
11
11
  ## Contents
12
12
 
@@ -15,7 +15,16 @@ Start with **Create a PackageManifestConfig** to produce the config asset that d
15
15
  | [Create a PackageManifestConfig](examples/create-packagemanifestconfig.md) | create-asset | [PackageManifestConfig](api.md#packagemanifestconfig) |
16
16
  | [Init Package](examples/init-package.md) | menu-item | [MenuItems](api.md#menuitems) |
17
17
  | [PrepareDll](examples/preparedll.md) | menu-item | [CIUtils](api.md#ciutils) |
18
+ | [PackageToolApi.GetConfigs](examples/packagetoolapi-getconfigs.md) | static-method | [PackageToolApi](api.md#packagetoolapi) |
19
+ | [PackageToolApi.FindConfig](examples/packagetoolapi-findconfig.md) | static-method | [PackageToolApi](api.md#packagetoolapi) |
20
+ | [PackageToolApi.GetConfig](examples/packagetoolapi-getconfig.md) | static-method | [PackageToolApi](api.md#packagetoolapi) |
21
+ | [PackageToolApi.GenerateVersionConstants](examples/packagetoolapi-generateversionconstants.md) | static-method | [PackageToolApi](api.md#packagetoolapi) |
22
+ | [PackageToolApi.ExportPackageSource](examples/packagetoolapi-exportpackagesource.md) | static-method | [PackageToolApi](api.md#packagetoolapi) |
23
+ | [PackageToolApi.ExportLegacyPackage](examples/packagetoolapi-exportlegacypackage.md) | static-method | [PackageToolApi](api.md#packagetoolapi) |
18
24
  | [CIUtils.Generate](examples/ciutils-generate.md) | static-method | [CIUtils](api.md#ciutils) |
25
+ | [CIUtils.ExportPackageSource](examples/ciutils-exportpackagesource.md) | static-method | [CIUtils](api.md#ciutils) |
26
+ | [CIUtils.ExportLegacyPackage](examples/ciutils-exportlegacypackage.md) | static-method | [CIUtils](api.md#ciutils) |
27
+ | [CIUtils.ListConfigs](examples/ciutils-listconfigs.md) | static-method | [CIUtils](api.md#ciutils) |
19
28
 
20
29
  This package also ships Unity samples importable from Package Manager → Package Tool → Samples → `Example Sample`, `Claude Skills`. Those samples are not duplicated here — import them via Package Manager if you want the full asset content.
21
30
 
@@ -23,3 +32,5 @@ This package also ships Unity samples importable from Package Manager → Packag
23
32
 
24
33
  - The `PackageTool.Tools.*` (`CommandLineTools`, `GitTools`) and `PackageTool.Utils.PackageInitialize.*` (`PackageInitializeTemplates`, `PackageInitializeUtil`) helpers were public in earlier revisions and dropped to `internal` to make the public surface intentional. They still exist and are used by `CIUtils.Generate`/`Init Package` internally; they're just no longer documented as consumer-facing entry points.
25
34
  - All entry points listed here are editor-only (single asmdef `Playdarium.PackageTool.Editor`, `includePlatforms: ["Editor"]`); call them from editor scripts or batch mode, not from runtime code.
35
+ - Both `FindConfig` overloads share one example chunk; the array overload exists so several selectors can be resolved against a single AssetDatabase lookup.
36
+ - The `id=` selector on every `CIUtils` entry point accepts a config guid, a `packageName`, or a config asset name, so a caller that only knows the published package name does not have to discover the guid first.
@@ -24,13 +24,13 @@ PackageTool
24
24
  └── PackageInitialize
25
25
  ```
26
26
 
27
- `PackageTool` (root) holds the configuration ScriptableObject [`PackageManifestConfig`](api.md#packagemanifestconfig) at `Assets/Package/PackageTool/Editor/PackageManifestConfig.cs:37`, the user-facing string table [`EditorConstants`](api.md#editorconstants) at `Assets/Package/PackageTool/Editor/EditorConstants.cs:32`, the CI batch entry point [`CIUtils`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:14`, and [`MenuItems`](api.md#menuitems) at `Assets/Package/PackageTool/Editor/MenuItems.cs:6`.
27
+ `PackageTool` (root) holds the configuration ScriptableObject [`PackageManifestConfig`](api.md#packagemanifestconfig) at `Assets/Package/PackageTool/Editor/PackageManifestConfig.cs:37`, the user-facing string table [`EditorConstants`](api.md#editorconstants) at `Assets/Package/PackageTool/Editor/EditorConstants.cs:32`, the CI batch entry point [`CIUtils`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:16`, the public export facade [`PackageToolApi`](api.md#packagetoolapi) at `Assets/Package/PackageTool/Editor/PackageToolApi.cs:13`, and [`MenuItems`](api.md#menuitems) at `Assets/Package/PackageTool/Editor/MenuItems.cs:6`.
28
28
 
29
29
  `PackageTool.Drawers` contains `PropertyDrawer` subclasses for the nested data types on `PackageManifestConfig`: [`AuthorPropertyDrawer`](api.md#authorpropertydrawer) (`Assets/Package/PackageTool/Editor/Drawers/AuthorPropertyDrawer.cs:34`), [`DependencyPropertyDrawer`](api.md#dependencypropertydrawer), [`SamplePropertyDrawer`](api.md#samplepropertydrawer), and [`CopyEntryPropertyDrawer`](api.md#copyentrypropertydrawer). All four are IMGUI drawers with manual `Rect` math.
30
30
 
31
31
  `PackageTool.Inspectors` has a single class, [`PackageManifestConfigInspector`](api.md#packagemanifestconfiginspector) at `Assets/Package/PackageTool/Editor/Inspectors/PackageManifestConfigInspector.cs:33` — a tab-based `UnityEditor.Editor` that drives every export button and renders the reorderable lists (keywords, dependencies, samples, copy entries).
32
32
 
33
- `PackageTool.Tools` is the helpers layer. [`FileTools`](api.md#filetools) owns the export pipeline (`CreateOrUpdatePackageSource`); [`CodeGenTools`](api.md#codegentools) emits `VersionConstants.cs`; [`PackageManifestTools`](api.md#packagemanifesttools) discovers configs and serializes `package.json`; [`GitTools`](api.md#gittools) probes branch/HEAD for the version token chain; [`CommandLineTools`](api.md#commandlinetools) parses CI key/value args; [`GUILayoutTools`](api.md#guilayouttools) provides reusable file/folder picker drawers; [`UnityFileTools`](api.md#unityfiletools) handles legacy `.unitypackage` compilation; and [`PackageJsonModel`](api.md#packagejsonmodel) is the JSON DTO with its `Author`/`Repository`/`Bugs`/`Sample` sub-models.
33
+ `PackageTool.Tools` is the helpers layer. [`FileTools`](api.md#filetools) owns the export pipeline (`CreateOrUpdatePackageSource`); [`CodeGenTools`](api.md#codegentools) emits `VersionConstants.cs`; [`PackageManifestTools`](api.md#packagemanifesttools) discovers configs and serializes `package.json`; [`GitTools`](api.md#gittools) probes branch/HEAD for the version token chain; [`CommandLineTools`](api.md#commandlinetools) parses CI key/value args; [`GUILayoutTools`](api.md#guilayouttools) provides reusable file/folder picker drawers; [`UnityFileTools`](api.md#unityfiletools) handles legacy `.unitypackage` compilation; [`PackageJsonModel`](api.md#packagejsonmodel) is the JSON DTO with its `Author`/`Repository`/`Bugs`/`Sample` sub-models; and [`CIResultModel`](api.md#ciresultmodel)/[`CIConfigModel`](api.md#ciconfigmodel)/[`CIResultTools`](api.md#ciresulttools) serialize the result file written by the command-line entry points.
34
34
 
35
35
  `PackageTool.Utils.PackageInitialize` is the Init Package flow: [`PackageInitializeWindow`](api.md#packageinitializewindow) is the `EditorWindow`, [`PackageInitializeUtil`](api.md#packageinitializeutil) creates folders and the config asset, and [`PackageInitializeTemplates`](api.md#packageinitializetemplates) holds the README/CHANGELOG/LICENSE string templates.
36
36
 
@@ -42,18 +42,22 @@ PackageTool
42
42
 
43
43
  ## Entry Points
44
44
 
45
- - `[MenuItem("Tools/PackageTools/PrepareDll")]` -> [`CIUtils.PrepareDll`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:197`. Maps to the **Tools/PackageTools/PrepareDll** entry in the Unity menu bar.
45
+ - `[MenuItem("Tools/PackageTools/PrepareDll")]` -> [`CIUtils.PrepareDll`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:319`. Maps to the **Tools/PackageTools/PrepareDll** entry in the Unity menu bar.
46
46
  - `[MenuItem("Tools/PackageTools/Init Package")]` -> [`PackageInitializeWindow.Open`](api.md#packageinitializewindow) (declared inline in `Assets/Package/PackageTool/Editor/MenuItems.cs`); opens the scaffolder window.
47
47
  - `[CreateAssetMenu(menuName = "JCMG/PackageTools/PackageManifestConfig")]` -> [`PackageManifestConfig`](api.md#packagemanifestconfig) at `Assets/Package/PackageTool/Editor/PackageManifestConfig.cs:37`. Available under **Assets > Create > JCMG/PackageTools/PackageManifestConfig**.
48
- - [`CIUtils.Generate`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:65` — batch-mode entry point invoked via `unity -batchmode -executeMethod PackageTool.CIUtils.Generate <key>=<value>`. Reads keys parsed by [`CommandLineTools.GetKVPCommandLineArguments`](api.md#commandlinetools); see **CI command-line keys** below for the supported keys.
49
- - [`CIUtils.PrepareDll`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:197` — exits the Editor when run under CI (`CI` env var set); fixes DLL plugin platform flags first. Also available as `Tools/PackageTools/PrepareDll` for interactive use.
48
+ - [`CIUtils.Generate`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:73` — batch-mode entry point invoked via `unity -batchmode -executeMethod PackageTool.CIUtils.Generate <key>=<value>`. Exports both the package source and the legacy package for every selected config. Reads keys parsed by [`CommandLineTools.GetKVPCommandLineArguments`](api.md#commandlinetools); see **CI command-line keys** below for the supported keys.
49
+ - [`CIUtils.ExportPackageSource`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:213` — batch-mode entry point that exports only the package source of the selected configs.
50
+ - [`CIUtils.ExportLegacyPackage`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:218` — batch-mode entry point that exports only the legacy `.unitypackage` of the selected configs.
51
+ - [`CIUtils.ListConfigs`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:196` — batch-mode entry point that writes every config in the project to the `resultpath` file so a caller can discover which selectors are valid.
52
+ - [`CIUtils.PrepareDll`](api.md#ciutils) at `Assets/Package/PackageTool/Editor/CIUtils.cs:319` — exits the Editor when run under CI (`CI` env var set); fixes DLL plugin platform flags first. Also available as `Tools/PackageTools/PrepareDll` for interactive use.
53
+ - [`PackageToolApi`](api.md#packagetoolapi) at `Assets/Package/PackageTool/Editor/PackageToolApi.cs:13` — the in-process facade every other entry point (Inspector buttons and command-line methods alike) is built on: `GetConfigs`, `FindConfig`/`GetConfig`, `GenerateVersionConstants`, `ExportPackageSource`, `ExportLegacyPackage`. Call these from your own editor code instead of the `internal` helpers in `PackageTool.Tools`.
50
54
  - [`PackageInitializeWindow.Open`](api.md#packageinitializewindow) at `Assets/Package/PackageTool/Editor/Utils/PackageInitialize/PackageInitializeWindow.cs:7` — opens the scaffolder via `Tools/PackageTools/Init Package`.
51
55
 
52
56
  Inspector buttons on `PackageManifestConfig` assets (drawn by `PackageManifestConfigInspector.OnInspectorGUI`):
53
57
 
54
- - **Generate VersionConstants.cs** -> [`CodeGenTools.GenerateVersionConstants`](api.md#codegentools)`(config)` at `Assets/Package/PackageTool/Editor/Tools/CodeGenTools.cs:36`.
55
- - **Export Package Source** -> [`FileTools.CreateOrUpdatePackageSource`](api.md#filetools)`(config)` at `Assets/Package/PackageTool/Editor/Tools/FileTools.cs:59`.
56
- - **Export as Legacy Package** -> [`UnityFileTools.CompileLegacyPackage`](api.md#unityfiletools)`(config)` at `Assets/Package/PackageTool/Editor/Tools/UnityFileTools.cs:36`.
58
+ - **Generate VersionConstants.cs** -> [`PackageToolApi.GenerateVersionConstants`](api.md#packagetoolapi)`(config)` at `Assets/Package/PackageTool/Editor/PackageToolApi.cs:78`.
59
+ - **Export Package Source** -> [`PackageToolApi.ExportPackageSource`](api.md#packagetoolapi)`(config)` at `Assets/Package/PackageTool/Editor/PackageToolApi.cs:94`.
60
+ - **Export as Legacy Package** -> [`PackageToolApi.ExportLegacyPackage`](api.md#packagetoolapi)`(config)` at `Assets/Package/PackageTool/Editor/PackageToolApi.cs:112`.
57
61
 
58
62
  ## Data Model
59
63
 
@@ -64,32 +68,33 @@ Defined at `Assets/Package/PackageTool/Editor/PackageManifestConfig.cs:37`. Crea
64
68
  - **Package json metadata:** `homepage`, `packageName`, `displayName`, `packageVersion`, `unityVersion`, `description`, `category`, `license`, `keywords` (`string[]`), `author` (`Author`), `dependencies` (`Dependency[]`).
65
69
  - **Package content paths:** `sourcePath`, `documentationPath` (default `Documentation~`), `readmePath` (default `README.md`), `changelogPath` (default `CHANGELOG.md`), `licensePath` (default `LICENSE`), `packageIgnorePaths` (`string[]`).
66
70
  - **Export targets:** `packageDestinationPath`, `legacyPackageDestinationPath`.
67
- - **Staging:** `samples` ([`Sample[]`](api.md#sample)), `copyEntries` ([`CopyEntry[]`](api.md#packagemanifestconfig-copyentry)).
71
+ - **Staging:** `samples` ([`Sample[]`](api.md#sample)), `copyEntries` ([`CopyEntry[]`](api.md#packagemanifestconfigcopyentry)).
68
72
  - **Code generation:** `versionConstantsPath`, `versionConstantsNamespace`.
69
73
  - **Hidden:** `_id` (Guid; surfaced via `Id` property; used by `CIUtils.Generate id=<guid>` filtering).
70
74
 
71
75
  Nested `[Serializable]` types, each with a `PropertyDrawer` in `PackageTool.Drawers`:
72
76
 
73
77
  - [`Author`](api.md#author) — `name`, `email`, `url` (`string`).
74
- - [`Dependency`](api.md#packagemanifestconfig-dependency) — `packageName`, `packageVersion` (`string`); `IsEmpty()` is true when either is blank.
78
+ - [`Dependency`](api.md#packagemanifestconfigdependency) — `packageName`, `packageVersion` (`string`); `IsEmpty()` is true when either is blank.
75
79
  - [`Sample`](api.md#sample) — `sourcePath`, `displayName`, `description`, `folderName` (`string`); `IsEmpty()` is true when any of `displayName`/`sourcePath`/`folderName` is blank. Resulting on-disk path is `{packageDestinationPath}/Samples~/{folderName}`.
76
- - [`CopyEntry`](api.md#packagemanifestconfig-copyentry) — `sourcePath`, `destinationPath` (`string`); `IsEmpty()` is true when `sourcePath` is blank. See **Copy Entries staging** below.
80
+ - [`CopyEntry`](api.md#packagemanifestconfigcopyentry) — `sourcePath`, `destinationPath` (`string`); `IsEmpty()` is true when `sourcePath` is blank. See **Copy Entries staging** below.
77
81
 
78
82
  ### Export pipeline
79
83
 
80
- [`FileTools.CreateOrUpdatePackageSource`](api.md#filetools)`(config)` at `Assets/Package/PackageTool/Editor/Tools/FileTools.cs:59` runs the steps below in order:
84
+ [`FileTools.CreateOrUpdatePackageSource`](api.md#filetools)`(config)` at `Assets/Package/PackageTool/Editor/Tools/FileTools.cs:60` (and its throwing twin `CreateOrUpdatePackageSourceOrThrow` at line 79, which is what [`PackageToolApi.ExportPackageSource`](api.md#packagetoolapi) calls) runs the steps below in order:
81
85
 
82
- 1. Write `package.json` to `Assets/PackageManifest/Generated/<id>/package.json` (Unity needs a meta file to copy the meta downstream).
86
+ 1. **`WritePackageJsonToSource(config)`** — write `package.json` into `sourcePath` (e.g. `Assets/Package/PackageTool/package.json`) and import it so Unity creates its meta file. The manifest lives in the package source folder so that both this export and the legacy `.unitypackage` export pick it up along with the rest of the source.
83
87
  2. Wipe and recreate `packageDestinationPath` (e.g. `Release/`).
84
- 3. Copy `package.json` and its meta into `packageDestinationPath`.
85
- 4. **`CopyEntriesToProject(config)`** — stage external content into the project; see below.
86
- 5. **`CopyDocumentationToDirectory(config)`** — copy `readmePath`, `changelogPath`, `licensePath` into `sourcePath`; rebuild `sourcePath/Documentation~/` from `documentationPath`.
87
- 6. **`RecursivelyCopyDirectoriesAndFiles(config, sourcePath, packageDestinationPath)`** — copy the package source tree, honoring `packageIgnorePaths`.
88
- 7. **`CopySamplesToDirectory(config)`** — wipe `packageDestinationPath/Samples~/` and copy each [`Sample`](api.md#sample)'s `sourcePath` to `Samples~/{folderName}`, skipping `.meta` files.
88
+ 3. **`CopyEntriesToProject(config)`** stage external content into the project; see below.
89
+ 4. **`CopyDocumentationToDirectory(config)`** — copy `readmePath`, `changelogPath`, `licensePath` into `sourcePath`; rebuild `sourcePath/Documentation~/` from `documentationPath`.
90
+ 5. **`RecursivelyCopyDirectoriesAndFiles(config, sourcePath, packageDestinationPath)`** — copy the package source tree (`package.json` and its meta included), honoring `packageIgnorePaths`.
91
+ 6. **`CopySamplesToDirectory(config)`** — wipe `packageDestinationPath/Samples~/` and copy each [`Sample`](api.md#sample)'s `sourcePath` to `Samples~/{folderName}`, skipping `.meta` files.
92
+
93
+ [`UnityFileTools.CompileLegacyPackage`](api.md#unityfiletools)`(config)` at `Assets/Package/PackageTool/Editor/Tools/UnityFileTools.cs:45` calls the same `WritePackageJsonToSource` before gathering asset paths, so the exported `.unitypackage` ships the manifest too.
89
94
 
90
95
  ### Copy Entries staging
91
96
 
92
- `copyEntries` is a `PackageManifestConfig` field added in 2.0.12. Each [`CopyEntry`](api.md#packagemanifestconfig-copyentry) names a source path and a destination folder; entries run **first** in the export pipeline (step 4 above) so downstream steps — including the recursive source copy and the `CopySamplesToDirectory` step — can pick up the staged content and ship it into `packageDestinationPath`.
97
+ `copyEntries` is a `PackageManifestConfig` field added in 2.0.12. Each [`CopyEntry`](api.md#packagemanifestconfigcopyentry) names a source path and a destination folder; entries run **first** in the export pipeline (step 4 above) so downstream steps — including the recursive source copy and the `CopySamplesToDirectory` step — can pick up the staged content and ship it into `packageDestinationPath`.
93
98
 
94
99
  **Folder source.** The folder's *content* is merged directly into `destinationPath` (no `destinationPath/{sourceName}` wrapper). Same-named files are overwritten via `File.Copy(..., overwrite: true)`; unrelated files already in the destination are left in place. This is the merge semantics needed to chain into a `Sample` whose `sourcePath` is the same folder.
95
100
 
@@ -116,14 +121,24 @@ IMGUI throughout — no UI Toolkit. There are no `.uxml` or `.uss` files in the
116
121
 
117
122
  ### CI command-line keys
118
123
 
119
- [`CIUtils.Generate`](api.md#ciutils) reads keys parsed by [`CommandLineTools.GetKVPCommandLineArguments`](api.md#commandlinetools). Keys are case-insensitive (lowercased on parse) and values are passed as `<key>=<value>` pairs after `-executeMethod PackageTool.CIUtils.Generate`:
124
+ Every [`CIUtils`](api.md#ciutils) entry point (`Generate`, `ExportPackageSource`, `ExportLegacyPackage`, `ListConfigs`) reads keys parsed by [`CommandLineTools.GetKVPCommandLineArguments`](api.md#commandlinetools). Keys are case-insensitive (lowercased on parse) and values are passed as `<key>=<value>` pairs after `-executeMethod PackageTool.CIUtils.<Method>`:
120
125
 
121
- - `id=<guid>[,<guid>...]` — restrict to specific `PackageManifestConfig._id`s. Omit to process all configs found by `PackageManifestTools.GetAllConfigs`.
126
+ - `id=<selector>[,<selector>...]` — restrict to specific configs. Each selector is matched case-insensitively against `PackageManifestConfig.Id` (the guid), then `packageName` (e.g. `com.elestrago.unity.package-tools`), then the config asset name — first match wins, and a selector matching more than one config is an error. Omit the key to process all configs found by `PackageManifestTools.GetAllConfigs`.
122
127
  - `version=<semver>` — overrides `packageVersion` on every processed config (and marks the asset dirty).
123
- - `preview=<bool>` — parsed but not currently applied.
128
+ - `preview=<bool>` — parsed by `Generate` but not currently applied.
124
129
  - `generateversionconstants=<bool>` — when true, runs `CodeGenTools.GenerateVersionConstants` before export.
130
+ - `resultpath=<file>` — writes a JSON report of the run to that path so callers do not have to scrape the Unity log. `Generate`, `ExportPackageSource` and `ExportLegacyPackage` write an array of [`CIResultModel`](api.md#ciresultmodel) entries (`selector`, `configId`, `configName`, `packageName`, `packageVersion`, `success`, `packageSourcePath`, `legacyPackagePath`, `versionConstantsPath`, `error`); `ListConfigs` writes an array of [`CIConfigModel`](api.md#ciconfigmodel) entries. The file is always written before the editor exits.
131
+ - `exitonfinish=<bool>` — when true, exits the editor with `0` on success and `1` on failure. Exiting is automatic when the `CI` environment variable is set.
132
+
133
+ An unresolved selector is a warning in `Generate` (which keeps its historical warn-and-continue behavior) and a failure in `ExportPackageSource`/`ExportLegacyPackage`, where a caller asking for a specific package and getting nothing is an error.
134
+
135
+ ```bash
136
+ Unity -batchmode -quit -projectPath . \
137
+ -executeMethod PackageTool.CIUtils.ExportPackageSource \
138
+ id=com.elestrago.unity.package-tools version=2.6.0 resultpath=/tmp/result.json
139
+ ```
125
140
 
126
- To add a new key, edit `Assets/Package/PackageTool/Editor/CIUtils.cs` (constants block at lines 1720, parsing pattern in `Generate()` lines 91113); do **not** touch `CommandLineTools.cs` — its parsing already handles arbitrary keys.
141
+ To add a new key, edit `Assets/Package/PackageTool/Editor/CIUtils.cs` (constants block at lines 1924, argument helpers `GetStringArgument`/`GetBoolArgument` at lines 419427); do **not** touch `CommandLineTools.cs` — its parsing already handles arbitrary keys.
127
142
 
128
143
  ### VersionConstants template tokens
129
144
 
@@ -138,3 +153,4 @@ To add a new key, edit `Assets/Package/PackageTool/Editor/CIUtils.cs` (constants
138
153
  - New `PropertyDrawer`: add `Assets/Package/PackageTool/Editor/Drawers/{Type}PropertyDrawer.cs`, mark `internal sealed class : PropertyDrawer`, override `OnGUI(Rect, ...)` + `GetPropertyHeight`.
139
154
  - New `MenuItem`: add to `Editor/MenuItems.cs` (or alongside the class that owns the action, as `CIUtils.PrepareDll` does).
140
155
  - New helper: add `Editor/Tools/{Name}.cs`, mark `internal static class`, namespace `PackageTool.Tools`. Mirror [`FileTools`](api.md#filetools) or [`GitTools`](api.md#gittools) for shape.
156
+ - New public entry point: add it to [`PackageToolApi`](api.md#packagetoolapi) rather than widening a `PackageTool.Tools` helper to `public` — the helpers stay `internal` on purpose and the facade is the package's supported surface.