This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
name: Publish UPM package
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.SHRINKSDK_PACKAGE_TOKEN }}
|
||||
steps:
|
||||
- name: Fetch tagged revision
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
ref="${{ gitea.sha }}"
|
||||
test -n "$ref"
|
||||
git init .
|
||||
git remote add origin "https://git.crash.work/ShrinkSDK/ShrinkCommand.Integration.App.git"
|
||||
git fetch --depth=1 origin "$ref"
|
||||
git checkout --detach FETCH_HEAD
|
||||
|
||||
- name: Validate immutable release version
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
tag="$(git describe --exact-match --tags HEAD)"
|
||||
version="$(node -p "require('./package.json').version")"
|
||||
test "$tag" = "v$version"
|
||||
npm pack --dry-run
|
||||
|
||||
- name: Publish to ShrinkSDK registry
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
: "${NODE_AUTH_TOKEN:?SHRINKSDK_PACKAGE_TOKEN is required}"
|
||||
npmrc="$HOME/.npmrc"
|
||||
cleanup() { rm -f "$npmrc"; }
|
||||
trap cleanup EXIT
|
||||
printf '%s\n' \
|
||||
'registry=https://git.crash.work/api/packages/ShrinkSDK/npm/' \
|
||||
'//git.crash.work/api/packages/ShrinkSDK/npm/:_authToken=${NODE_AUTH_TOKEN}' > "$npmrc"
|
||||
npm publish --registry=https://git.crash.work/api/packages/ShrinkSDK/npm/
|
||||
@@ -0,0 +1,39 @@
|
||||
name: Verify standalone Unity package
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
editmode:
|
||||
runs-on: unity-2022.3.62f3
|
||||
container:
|
||||
image: docker.1panel.live/unityci/editor:ubuntu-2022.3.62f3-windows-mono-3
|
||||
volumes:
|
||||
- /www/dk_project/bt-recovery/gitea/runner/seedskey-unity-license:/root/.local/share/unity3d/Unity
|
||||
- /www/dk_project/bt-recovery/gitea/runner/seedskey-unity-entitlements:/root/.config/unity3d/Unity/licenses
|
||||
steps:
|
||||
- name: Fetch selected revision
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
ref="${{ gitea.sha }}"
|
||||
git init .
|
||||
git remote add origin "https://git.crash.work/ShrinkSDK/ShrinkCommand.Integration.App.git"
|
||||
git fetch --depth=1 origin "$ref"
|
||||
git checkout --detach FETCH_HEAD
|
||||
|
||||
- name: Run package EditMode tests
|
||||
shell: bash
|
||||
run: |
|
||||
set -eu
|
||||
unity_bin="$(command -v unity-editor || command -v unity || command -v Unity || true)"
|
||||
test -n "$unity_bin"
|
||||
"$unity_bin" \
|
||||
-batchmode \
|
||||
-nographics \
|
||||
-quit \
|
||||
-projectPath "$PWD/Development~/UnityProject" \
|
||||
-runTests \
|
||||
-testPlatform EditMode \
|
||||
-testResults "$PWD/TestResults/editmode.xml" \
|
||||
-logFile "$PWD/TestResults/unity.log"
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
/Development~/UnityProject/[Ll]ibrary/
|
||||
/Development~/UnityProject/[Tt]emp/
|
||||
/Development~/UnityProject/[Oo]bj/
|
||||
/Development~/UnityProject/[Ll]ogs/
|
||||
/Development~/UnityProject/[Uu]ser[Ss]ettings/
|
||||
/Development~/UnityProject/TestResults/
|
||||
/Tools~/**/[Bb]in/
|
||||
/Tools~/**/[Oo]bj/
|
||||
*.user
|
||||
*.DotSettings.user
|
||||
@@ -0,0 +1,8 @@
|
||||
.git/
|
||||
.gitea/
|
||||
Development~/
|
||||
Tools~/
|
||||
*.csproj
|
||||
*.sln
|
||||
*.user
|
||||
*.DotSettings.user
|
||||
@@ -0,0 +1,11 @@
|
||||
# Changelog
|
||||
|
||||
本文件记录 `ShrinkCommand.Integration.App` 的包内变更。
|
||||
|
||||
## [0.1.0] - 2026-05-18
|
||||
|
||||
### Added
|
||||
|
||||
- 新增 `ShrinkCommand` 与 `ShrinkApp.Core` 的桥接包。
|
||||
- 新增 `ShrinkCommandAppInstaller`,把默认命令服务挂入宿主服务容器。
|
||||
- 新增 `ShrinkCommandAppService` 作为宿主侧命令门面。
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1754b3bc0377768409187131b594bda6
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,6 @@
|
||||
[Ll]ibrary/
|
||||
[Tt]emp/
|
||||
[Oo]bj/
|
||||
[Ll]ogs/
|
||||
[Uu]ser[Ss]ettings/
|
||||
TestResults/
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"scopedRegistries": [
|
||||
{
|
||||
"name": "ShrinkSDK",
|
||||
"url": "https://git.crash.work/api/packages/ShrinkSDK/npm/",
|
||||
"scopes": [
|
||||
"com.cneicy"
|
||||
]
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"com.unity.test-framework": "1.1.33",
|
||||
"com.cneicy.shrink-command-integration-app": "file:../../.."
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
m_EditorVersion: 2022.3.62f3
|
||||
m_EditorVersionWithRevision: 2022.3.62f3 (96770f904ca7)
|
||||
@@ -0,0 +1,23 @@
|
||||
# ShrinkCommand.Integration.App
|
||||
|
||||
`ShrinkCommand.Integration.App` 是 `ShrinkCommand` 与 `ShrinkApp.Core` 的桥接层。它的职责很简单:把默认命令服务挂进 `ShrinkApp` 的服务容器里,让项目在进入统一宿主模式后,仍能用熟悉的命令系统,而不需要到处手动拿 `ShrinkCommandRuntime.Default`。
|
||||
|
||||
## 当前能力
|
||||
|
||||
- 提供原生 `ShrinkCommandAppComponent`,发布 `shrink.service.command`
|
||||
- 把 `ShrinkCommandRuntime.Default` 包装为 `ShrinkCommandAppService`
|
||||
- ContextLoader 下由 Starter 组合根装配,服务门面随组件停用可逆注销
|
||||
- `ShrinkCommandAppInstaller` 仅保留给 ClassicHost 兼容路径,已标记过时
|
||||
|
||||
## 使用示例
|
||||
|
||||
```csharp
|
||||
var command = ShrinkApp.ShrinkApp.Services.GetRequired<ShrinkCommand.Integration.App.ShrinkCommandAppService>();
|
||||
var result = await command.ExecuteAsync(source, "help");
|
||||
```
|
||||
|
||||
## 说明
|
||||
|
||||
- 本包不改变 `ShrinkCommand` 的原有 API。
|
||||
- 静态命令的默认注册仍由 `ShrinkCommandRuntime.Default` 完成。
|
||||
- 运行时实例命令仍然走 `RegisterCommands(object target)`。
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: da6f74ed70ed86e48bc9309983a690b9
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 79640806d61572d44b10ae9bbb0ace79
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"name": "ShrinkCommand.Integration.App",
|
||||
"rootNamespace": "ShrinkCommand.Integration.App",
|
||||
"references": [
|
||||
"ShrinkCommand.Runtime",
|
||||
"ShrinkApp.Core.Runtime",
|
||||
"ShrinkContext.Core.Runtime",
|
||||
"UniTask"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5805c0a2f81e6f47818b1dac7d15e6c
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,49 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using ShrinkApp;
|
||||
using ShrinkContext;
|
||||
using ShrinkCommand;
|
||||
|
||||
namespace ShrinkCommand.Integration.App
|
||||
{
|
||||
/// <summary>
|
||||
/// ShrinkCommand 的原生 Cordis 组件(阶段 3):
|
||||
/// 提供 <c>shrink.service.command</c> 余效应键(默认命令服务),依赖者按键注入;
|
||||
/// 与经典 ShrinkCommandAppInstaller(ModuleId "shrink.command")二选一使用(同键供给冲突保护)。
|
||||
/// </summary>
|
||||
public sealed class ShrinkCommandAppComponent : IShrinkComponent
|
||||
{
|
||||
public const string ServiceKey = "shrink.service.command";
|
||||
public const string ModuleKey = "app.module.shrink.command";
|
||||
|
||||
private static readonly string[] ProvideKeys = { ModuleKey, ServiceKey };
|
||||
|
||||
public string Name => "shrink.command";
|
||||
|
||||
public IReadOnlyList<string> Inject => Array.Empty<string>();
|
||||
|
||||
public IReadOnlyList<string> Provide => ProvideKeys;
|
||||
|
||||
public UniTask ApplyAsync(ShrinkCtx ctx, object? config)
|
||||
{
|
||||
var service = ShrinkCommandRuntime.Default;
|
||||
ctx.Set(ServiceKey, service);
|
||||
ctx.Set(ModuleKey, Name);
|
||||
|
||||
if (config is ShrinkAppServices appServices)
|
||||
{
|
||||
var facade = new ShrinkCommandAppService(service);
|
||||
appServices.Register(facade);
|
||||
ctx.EffectInverse(() =>
|
||||
{
|
||||
appServices.TryUnregister(facade);
|
||||
return UniTask.CompletedTask;
|
||||
});
|
||||
}
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 507e23e02986281488456a63dc8ffdbe
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using ShrinkApp;
|
||||
|
||||
namespace ShrinkCommand.Integration.App
|
||||
{
|
||||
[ShrinkAppModuleInstaller]
|
||||
[Obsolete("ClassicHost compatibility only. ContextLoader projects should use ShrinkCommandAppComponent from a composition root.")]
|
||||
public sealed class ShrinkCommandAppInstaller : IShrinkAppModuleInstaller
|
||||
{
|
||||
public string ModuleId => "shrink.command";
|
||||
public int Order => -1500;
|
||||
public System.Collections.Generic.IReadOnlyList<string> DependsOn => Array.Empty<string>();
|
||||
|
||||
public void RegisterServices(ShrinkAppContext context)
|
||||
{
|
||||
context.Services.Register(new ShrinkCommandAppService(ShrinkCommandRuntime.Default));
|
||||
}
|
||||
|
||||
public UniTask InitializeAsync(ShrinkAppContext context)
|
||||
{
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ShrinkCommandAppService
|
||||
{
|
||||
public ShrinkCommandAppService(ShrinkCommandService service)
|
||||
{
|
||||
Service = service ?? throw new ArgumentNullException(nameof(service));
|
||||
}
|
||||
|
||||
public ShrinkCommandService Service { get; }
|
||||
|
||||
public UniTask<ShrinkCommandExecutionResult> ExecuteAsync(
|
||||
IShrinkCommandSource source,
|
||||
string rawInput,
|
||||
System.Threading.CancellationToken cancellationToken = default)
|
||||
=> Service.ExecuteAsync(source, rawInput, cancellationToken);
|
||||
|
||||
public string BuildHelp(IShrinkCommandSource? source, string? prefix = null)
|
||||
=> Service.BuildHelp(source, prefix);
|
||||
|
||||
public System.Collections.Generic.IReadOnlyList<ShrinkCommandDescriptor> Commands => Service.Commands;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a71473a2ecd04c3459903841fee6da7d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "com.cneicy.shrink-command-integration-app",
|
||||
"version": "0.1.0",
|
||||
"displayName": "ShrinkCommand - App Integration",
|
||||
"description": "ShrinkCommand 与 ShrinkApp 的桥接层,把默认命令服务纳入统一宿主服务容器。",
|
||||
"unity": "2022.3",
|
||||
"dependencies": {
|
||||
"com.cneicy.shrink-command": "0.2.0",
|
||||
"com.cneicy.shrink-app-core": "0.1.1",
|
||||
"com.cysharp.unitask": "2.5.10",
|
||||
"com.cneicy.shrink-context-core": "0.1.0"
|
||||
},
|
||||
"keywords": [
|
||||
"command",
|
||||
"integration",
|
||||
"app",
|
||||
"console"
|
||||
],
|
||||
"author": {
|
||||
"name": "cneicy",
|
||||
"url": "https://git.crash.work/ShrinkSDK"
|
||||
},
|
||||
"documentationUrl": "https://git.crash.work/ShrinkSDK/ShrinkCommand.Integration.App",
|
||||
"changelogUrl": "https://git.crash.work/ShrinkSDK/ShrinkCommand.Integration.App/src/branch/main/CHANGELOG.md"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 126abcc047b44714593c2f94aa587c75
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user