-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresource_pack_workflow.php
More file actions
57 lines (49 loc) · 1.87 KB
/
Copy pathresource_pack_workflow.php
File metadata and controls
57 lines (49 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
use imperazim\assets\AssetManifest;
use imperazim\assets\resource\ResourcePackDefinition;
use imperazim\assets\resource\ResourcePackPrepareResult;
use imperazim\assets\resource\ResourcePackValidator;
use imperazim\assets\resource\ResourcePackWorkflow;
use imperazim\assets\resource\ResourcePackWorkflowReport;
/**
* Example: scan plugin assets and fail early if generated files drift.
*/
function validatePluginAssets(string $assetDirectory): AssetManifest {
$manifest = AssetManifest::fromDirectory($assetDirectory, 'plugin-assets', '1.0.0');
$report = $manifest->validateAgainstDirectory($assetDirectory);
if (!$report->isValid()) {
throw new RuntimeException('Asset validation failed: ' . implode('; ', $report->getProblems()));
}
return $manifest;
}
/**
* Example: prepare a local Bedrock resource pack into a controlled workspace.
*/
function prepareLobbyPack(string $workspace, string $sourceDirectory): ResourcePackPrepareResult {
$validation = ResourcePackValidator::validateDirectory($sourceDirectory);
if (!$validation->isValid()) {
throw new RuntimeException('Invalid resource pack: ' . implode('; ', $validation->getErrors()));
}
$workflow = new ResourcePackWorkflow($workspace, [
new ResourcePackDefinition(
id: 'lobby',
sourceDirectory: $sourceDirectory,
targetArchiveName: 'lobby-pack.zip',
enabled: true
),
]);
return $workflow->prepare('lobby');
}
/**
* Example: expose pack status in an operator command without guessing from
* files on disk.
*
* @return list<string>
*/
function describePacks(ResourcePackWorkflow $workflow): array {
return array_map(
static fn(ResourcePackWorkflowReport $report): string => $report->getDefinition()->getId() . ': ' . $report->getStatus(),
$workflow->inspectAll()
);
}