@uapkg/cli 1.1.7 → 1.1.9
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/dist/app/CompositionRoot.d.ts +47 -0
- package/dist/app/CompositionRoot.d.ts.map +1 -0
- package/dist/app/CompositionRoot.js +95 -0
- package/dist/app/CompositionRoot.js.map +1 -0
- package/dist/app/UAPKGApplication.d.ts +14 -0
- package/dist/app/UAPKGApplication.d.ts.map +1 -0
- package/dist/app/UAPKGApplication.js +111 -0
- package/dist/app/UAPKGApplication.js.map +1 -0
- package/dist/cli/UAPKGCommandLine.d.ts +166 -0
- package/dist/cli/UAPKGCommandLine.d.ts.map +1 -0
- package/dist/cli/UAPKGCommandLine.js +172 -0
- package/dist/cli/UAPKGCommandLine.js.map +1 -0
- package/dist/cli/parseCommandLine.d.ts +2 -0
- package/dist/cli/parseCommandLine.d.ts.map +1 -0
- package/dist/cli/parseCommandLine.js +6 -0
- package/dist/cli/parseCommandLine.js.map +1 -0
- package/dist/cli/parsing/UAPKGCommandLineParser.d.ts +8 -0
- package/dist/cli/parsing/UAPKGCommandLineParser.d.ts.map +1 -0
- package/dist/cli/parsing/UAPKGCommandLineParser.js +25 -0
- package/dist/cli/parsing/UAPKGCommandLineParser.js.map +1 -0
- package/dist/cli/parsing/UAPKGParserRegistry.d.ts +11 -0
- package/dist/cli/parsing/UAPKGParserRegistry.d.ts.map +1 -0
- package/dist/cli/parsing/UAPKGParserRegistry.js +39 -0
- package/dist/cli/parsing/UAPKGParserRegistry.js.map +1 -0
- package/dist/cli/parsing/contracts/UAPKGCommandModule.d.ts +9 -0
- package/dist/cli/parsing/contracts/UAPKGCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/contracts/UAPKGCommandModule.js +2 -0
- package/dist/cli/parsing/contracts/UAPKGCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/AddCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/AddCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/AddCommandModule.js +37 -0
- package/dist/cli/parsing/modules/AddCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/ConfigCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/ConfigCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/ConfigCommandModule.js +84 -0
- package/dist/cli/parsing/modules/ConfigCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/InitCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/InitCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/InitCommandModule.js +23 -0
- package/dist/cli/parsing/modules/InitCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/InstallCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/InstallCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/InstallCommandModule.js +29 -0
- package/dist/cli/parsing/modules/InstallCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/ListCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/ListCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/ListCommandModule.js +16 -0
- package/dist/cli/parsing/modules/ListCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/OutdatedCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/OutdatedCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/OutdatedCommandModule.js +17 -0
- package/dist/cli/parsing/modules/OutdatedCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/PackCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/PackCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/PackCommandModule.js +29 -0
- package/dist/cli/parsing/modules/PackCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/ProjectGetNameCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/ProjectGetNameCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/ProjectGetNameCommandModule.js +12 -0
- package/dist/cli/parsing/modules/ProjectGetNameCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/RegistryCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/RegistryCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/RegistryCommandModule.js +92 -0
- package/dist/cli/parsing/modules/RegistryCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/RemoveCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/RemoveCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/RemoveCommandModule.js +15 -0
- package/dist/cli/parsing/modules/RemoveCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/UpdateCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/UpdateCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/UpdateCommandModule.js +26 -0
- package/dist/cli/parsing/modules/UpdateCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/WhyCommandModule.d.ts +7 -0
- package/dist/cli/parsing/modules/WhyCommandModule.d.ts.map +1 -0
- package/dist/cli/parsing/modules/WhyCommandModule.js +15 -0
- package/dist/cli/parsing/modules/WhyCommandModule.js.map +1 -0
- package/dist/cli/parsing/modules/sharedOptions.d.ts +8 -0
- package/dist/cli/parsing/modules/sharedOptions.d.ts.map +1 -0
- package/dist/cli/parsing/modules/sharedOptions.js +26 -0
- package/dist/cli/parsing/modules/sharedOptions.js.map +1 -0
- package/dist/cli/runUAPKGCLI.d.ts +2 -0
- package/dist/cli/runUAPKGCLI.d.ts.map +1 -0
- package/dist/cli/runUAPKGCLI.js +7 -0
- package/dist/cli/runUAPKGCLI.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +18 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/AddCommand.d.ts +26 -0
- package/dist/commands/AddCommand.d.ts.map +1 -0
- package/dist/commands/AddCommand.js +55 -0
- package/dist/commands/AddCommand.js.map +1 -0
- package/dist/commands/Command.d.ts +4 -0
- package/dist/commands/Command.d.ts.map +1 -0
- package/dist/commands/Command.js +2 -0
- package/dist/commands/Command.js.map +1 -0
- package/dist/commands/ConfigCommand.d.ts +28 -0
- package/dist/commands/ConfigCommand.d.ts.map +1 -0
- package/dist/commands/ConfigCommand.js +187 -0
- package/dist/commands/ConfigCommand.js.map +1 -0
- package/dist/commands/InitCommand.d.ts +19 -0
- package/dist/commands/InitCommand.d.ts.map +1 -0
- package/dist/commands/InitCommand.js +61 -0
- package/dist/commands/InitCommand.js.map +1 -0
- package/dist/commands/InstallCommand.d.ts +30 -0
- package/dist/commands/InstallCommand.d.ts.map +1 -0
- package/dist/commands/InstallCommand.js +97 -0
- package/dist/commands/InstallCommand.js.map +1 -0
- package/dist/commands/ListCommand.d.ts +20 -0
- package/dist/commands/ListCommand.d.ts.map +1 -0
- package/dist/commands/ListCommand.js +83 -0
- package/dist/commands/ListCommand.js.map +1 -0
- package/dist/commands/OutdatedCommand.d.ts +20 -0
- package/dist/commands/OutdatedCommand.d.ts.map +1 -0
- package/dist/commands/OutdatedCommand.js +42 -0
- package/dist/commands/OutdatedCommand.js.map +1 -0
- package/dist/commands/PackCommand.d.ts +13 -0
- package/dist/commands/PackCommand.d.ts.map +1 -0
- package/dist/commands/PackCommand.js +22 -0
- package/dist/commands/PackCommand.js.map +1 -0
- package/dist/commands/PostinstallCandidateBuilder.d.ts +25 -0
- package/dist/commands/PostinstallCandidateBuilder.d.ts.map +1 -0
- package/dist/commands/PostinstallCandidateBuilder.js +41 -0
- package/dist/commands/PostinstallCandidateBuilder.js.map +1 -0
- package/dist/commands/ProjectGetNameCommand.d.ts +14 -0
- package/dist/commands/ProjectGetNameCommand.d.ts.map +1 -0
- package/dist/commands/ProjectGetNameCommand.js +26 -0
- package/dist/commands/ProjectGetNameCommand.js.map +1 -0
- package/dist/commands/RegistryCommand.d.ts +29 -0
- package/dist/commands/RegistryCommand.d.ts.map +1 -0
- package/dist/commands/RegistryCommand.js +121 -0
- package/dist/commands/RegistryCommand.js.map +1 -0
- package/dist/commands/RemoveCommand.d.ts +14 -0
- package/dist/commands/RemoveCommand.d.ts.map +1 -0
- package/dist/commands/RemoveCommand.js +55 -0
- package/dist/commands/RemoveCommand.js.map +1 -0
- package/dist/commands/UpdateCommand.d.ts +45 -0
- package/dist/commands/UpdateCommand.d.ts.map +1 -0
- package/dist/commands/UpdateCommand.js +113 -0
- package/dist/commands/UpdateCommand.js.map +1 -0
- package/dist/commands/WhyCommand.d.ts +21 -0
- package/dist/commands/WhyCommand.d.ts.map +1 -0
- package/dist/commands/WhyCommand.js +46 -0
- package/dist/commands/WhyCommand.js.map +1 -0
- package/dist/commands/add/DependencyAddResolver.d.ts +18 -0
- package/dist/commands/add/DependencyAddResolver.d.ts.map +1 -0
- package/dist/commands/add/DependencyAddResolver.js +36 -0
- package/dist/commands/add/DependencyAddResolver.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/postinstall/api/PostinstallDsl.d.ts +44 -0
- package/dist/postinstall/api/PostinstallDsl.d.ts.map +1 -0
- package/dist/postinstall/api/PostinstallDsl.js +39 -0
- package/dist/postinstall/api/PostinstallDsl.js.map +1 -0
- package/dist/postinstall/api/definePostinstall.d.ts +18 -0
- package/dist/postinstall/api/definePostinstall.d.ts.map +1 -0
- package/dist/postinstall/api/definePostinstall.js +19 -0
- package/dist/postinstall/api/definePostinstall.js.map +1 -0
- package/dist/postinstall/index.d.ts +26 -0
- package/dist/postinstall/index.d.ts.map +1 -0
- package/dist/postinstall/index.js +37 -0
- package/dist/postinstall/index.js.map +1 -0
- package/dist/postinstall/loader/EntryResolver.d.ts +20 -0
- package/dist/postinstall/loader/EntryResolver.d.ts.map +1 -0
- package/dist/postinstall/loader/EntryResolver.js +35 -0
- package/dist/postinstall/loader/EntryResolver.js.map +1 -0
- package/dist/postinstall/loader/EsbuildTranspiler.d.ts +18 -0
- package/dist/postinstall/loader/EsbuildTranspiler.d.ts.map +1 -0
- package/dist/postinstall/loader/EsbuildTranspiler.js +58 -0
- package/dist/postinstall/loader/EsbuildTranspiler.js.map +1 -0
- package/dist/postinstall/loader/ExportValidator.d.ts +15 -0
- package/dist/postinstall/loader/ExportValidator.d.ts.map +1 -0
- package/dist/postinstall/loader/ExportValidator.js +34 -0
- package/dist/postinstall/loader/ExportValidator.js.map +1 -0
- package/dist/postinstall/loader/ModuleImporter.d.ts +29 -0
- package/dist/postinstall/loader/ModuleImporter.d.ts.map +1 -0
- package/dist/postinstall/loader/ModuleImporter.js +60 -0
- package/dist/postinstall/loader/ModuleImporter.js.map +1 -0
- package/dist/postinstall/loader/PostinstallLoader.d.ts +32 -0
- package/dist/postinstall/loader/PostinstallLoader.d.ts.map +1 -0
- package/dist/postinstall/loader/PostinstallLoader.js +60 -0
- package/dist/postinstall/loader/PostinstallLoader.js.map +1 -0
- package/dist/postinstall/markers/MarkerBlockEditor.d.ts +30 -0
- package/dist/postinstall/markers/MarkerBlockEditor.d.ts.map +1 -0
- package/dist/postinstall/markers/MarkerBlockEditor.js +46 -0
- package/dist/postinstall/markers/MarkerBlockEditor.js.map +1 -0
- package/dist/postinstall/markers/MarkerBlockService.d.ts +24 -0
- package/dist/postinstall/markers/MarkerBlockService.d.ts.map +1 -0
- package/dist/postinstall/markers/MarkerBlockService.js +46 -0
- package/dist/postinstall/markers/MarkerBlockService.js.map +1 -0
- package/dist/postinstall/markers/MarkerIntegrityValidator.d.ts +29 -0
- package/dist/postinstall/markers/MarkerIntegrityValidator.d.ts.map +1 -0
- package/dist/postinstall/markers/MarkerIntegrityValidator.js +53 -0
- package/dist/postinstall/markers/MarkerIntegrityValidator.js.map +1 -0
- package/dist/postinstall/policy/PostinstallPolicyGate.d.ts +36 -0
- package/dist/postinstall/policy/PostinstallPolicyGate.d.ts.map +1 -0
- package/dist/postinstall/policy/PostinstallPolicyGate.js +57 -0
- package/dist/postinstall/policy/PostinstallPolicyGate.js.map +1 -0
- package/dist/postinstall/runner/PostinstallOrchestrator.d.ts +71 -0
- package/dist/postinstall/runner/PostinstallOrchestrator.d.ts.map +1 -0
- package/dist/postinstall/runner/PostinstallOrchestrator.js +172 -0
- package/dist/postinstall/runner/PostinstallOrchestrator.js.map +1 -0
- package/dist/postinstall/unreal/BuildCsInjector.d.ts +23 -0
- package/dist/postinstall/unreal/BuildCsInjector.d.ts.map +1 -0
- package/dist/postinstall/unreal/BuildCsInjector.js +55 -0
- package/dist/postinstall/unreal/BuildCsInjector.js.map +1 -0
- package/dist/postinstall/unreal/CSharpInjectionEngine.d.ts +22 -0
- package/dist/postinstall/unreal/CSharpInjectionEngine.d.ts.map +1 -0
- package/dist/postinstall/unreal/CSharpInjectionEngine.js +61 -0
- package/dist/postinstall/unreal/CSharpInjectionEngine.js.map +1 -0
- package/dist/postinstall/unreal/CSharpStructureAnalyzer.d.ts +22 -0
- package/dist/postinstall/unreal/CSharpStructureAnalyzer.d.ts.map +1 -0
- package/dist/postinstall/unreal/CSharpStructureAnalyzer.js +130 -0
- package/dist/postinstall/unreal/CSharpStructureAnalyzer.js.map +1 -0
- package/dist/postinstall/unreal/CSharpStructures.d.ts +19 -0
- package/dist/postinstall/unreal/CSharpStructures.d.ts.map +1 -0
- package/dist/postinstall/unreal/CSharpStructures.js +2 -0
- package/dist/postinstall/unreal/CSharpStructures.js.map +1 -0
- package/dist/postinstall/unreal/CSharpWrapperFactory.d.ts +26 -0
- package/dist/postinstall/unreal/CSharpWrapperFactory.d.ts.map +1 -0
- package/dist/postinstall/unreal/CSharpWrapperFactory.js +60 -0
- package/dist/postinstall/unreal/CSharpWrapperFactory.js.map +1 -0
- package/dist/postinstall/unreal/PluginHash.d.ts +8 -0
- package/dist/postinstall/unreal/PluginHash.d.ts.map +1 -0
- package/dist/postinstall/unreal/PluginHash.js +13 -0
- package/dist/postinstall/unreal/PluginHash.js.map +1 -0
- package/dist/postinstall/unreal/PrettyParseError.d.ts +15 -0
- package/dist/postinstall/unreal/PrettyParseError.d.ts.map +1 -0
- package/dist/postinstall/unreal/PrettyParseError.js +43 -0
- package/dist/postinstall/unreal/PrettyParseError.js.map +1 -0
- package/dist/postinstall/unreal/ProjectFileLocator.d.ts +20 -0
- package/dist/postinstall/unreal/ProjectFileLocator.d.ts.map +1 -0
- package/dist/postinstall/unreal/ProjectFileLocator.js +53 -0
- package/dist/postinstall/unreal/ProjectFileLocator.js.map +1 -0
- package/dist/postinstall/unreal/TargetCsInjector.d.ts +23 -0
- package/dist/postinstall/unreal/TargetCsInjector.d.ts.map +1 -0
- package/dist/postinstall/unreal/TargetCsInjector.js +55 -0
- package/dist/postinstall/unreal/TargetCsInjector.js.map +1 -0
- package/dist/postinstall/unreal/UProjectInjector.d.ts +12 -0
- package/dist/postinstall/unreal/UProjectInjector.d.ts.map +1 -0
- package/dist/postinstall/unreal/UProjectInjector.js +54 -0
- package/dist/postinstall/unreal/UProjectInjector.js.map +1 -0
- package/dist/postinstall/unreal/UProjectMetadataReader.d.ts +9 -0
- package/dist/postinstall/unreal/UProjectMetadataReader.d.ts.map +1 -0
- package/dist/postinstall/unreal/UProjectMetadataReader.js +20 -0
- package/dist/postinstall/unreal/UProjectMetadataReader.js.map +1 -0
- package/dist/postinstall/unreal/UnrealSourceCatalog.d.ts +23 -0
- package/dist/postinstall/unreal/UnrealSourceCatalog.d.ts.map +1 -0
- package/dist/postinstall/unreal/UnrealSourceCatalog.js +52 -0
- package/dist/postinstall/unreal/UnrealSourceCatalog.js.map +1 -0
- package/dist/prompts/InkPromptService.d.ts +8 -0
- package/dist/prompts/InkPromptService.d.ts.map +1 -0
- package/dist/prompts/InkPromptService.js +56 -0
- package/dist/prompts/InkPromptService.js.map +1 -0
- package/dist/prompts/ProjectContextDetector.d.ts +10 -0
- package/dist/prompts/ProjectContextDetector.d.ts.map +1 -0
- package/dist/prompts/ProjectContextDetector.js +27 -0
- package/dist/prompts/ProjectContextDetector.js.map +1 -0
- package/dist/prompts/PromptService.d.ts +9 -0
- package/dist/prompts/PromptService.d.ts.map +1 -0
- package/dist/prompts/PromptService.js +8 -0
- package/dist/prompts/PromptService.js.map +1 -0
- package/dist/reporting/DiagnosticDeduplicator.d.ts +11 -0
- package/dist/reporting/DiagnosticDeduplicator.d.ts.map +1 -0
- package/dist/reporting/DiagnosticDeduplicator.js +37 -0
- package/dist/reporting/DiagnosticDeduplicator.js.map +1 -0
- package/dist/reporting/DiagnosticRenderer.d.ts +18 -0
- package/dist/reporting/DiagnosticRenderer.d.ts.map +1 -0
- package/dist/reporting/DiagnosticRenderer.js +2 -0
- package/dist/reporting/DiagnosticRenderer.js.map +1 -0
- package/dist/reporting/DiagnosticReporter.d.ts +23 -0
- package/dist/reporting/DiagnosticReporter.d.ts.map +1 -0
- package/dist/reporting/DiagnosticReporter.js +41 -0
- package/dist/reporting/DiagnosticReporter.js.map +1 -0
- package/dist/reporting/InkDiagnosticRenderer.d.ts +21 -0
- package/dist/reporting/InkDiagnosticRenderer.d.ts.map +1 -0
- package/dist/reporting/InkDiagnosticRenderer.js +44 -0
- package/dist/reporting/InkDiagnosticRenderer.js.map +1 -0
- package/dist/reporting/InstallProgressReporter.d.ts +34 -0
- package/dist/reporting/InstallProgressReporter.d.ts.map +1 -0
- package/dist/reporting/InstallProgressReporter.js +49 -0
- package/dist/reporting/InstallProgressReporter.js.map +1 -0
- package/dist/reporting/JsonReporter.d.ts +26 -0
- package/dist/reporting/JsonReporter.d.ts.map +1 -0
- package/dist/reporting/JsonReporter.js +16 -0
- package/dist/reporting/JsonReporter.js.map +1 -0
- package/dist/reporting/TextDiagnosticRenderer.d.ts +20 -0
- package/dist/reporting/TextDiagnosticRenderer.d.ts.map +1 -0
- package/dist/reporting/TextDiagnosticRenderer.js +30 -0
- package/dist/reporting/TextDiagnosticRenderer.js.map +1 -0
- package/dist/reporting/TextSink.d.ts +21 -0
- package/dist/reporting/TextSink.d.ts.map +1 -0
- package/dist/reporting/TextSink.js +25 -0
- package/dist/reporting/TextSink.js.map +1 -0
- package/package.json +12 -12
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import * as os from 'node:os';
|
|
3
|
+
import * as path from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { createPostinstallLoadFailedDiagnostic, fail, ok } from '@uapkg/diagnostics';
|
|
6
|
+
/**
|
|
7
|
+
* Imports a postinstall module.
|
|
8
|
+
*
|
|
9
|
+
* For `.js`/`.mjs` files we use the file URL directly so relative imports and
|
|
10
|
+
* `node_modules` resolution work.
|
|
11
|
+
*
|
|
12
|
+
* For transpiled `.ts` code we write to a sibling temp file next to the
|
|
13
|
+
* original entry — data: URLs cannot resolve relative specifiers — and delete
|
|
14
|
+
* it on best-effort basis after import. The file lives in the OS tmp dir
|
|
15
|
+
* keyed by a timestamp+pid, avoiding collisions across concurrent installs.
|
|
16
|
+
*/
|
|
17
|
+
export class ModuleImporter {
|
|
18
|
+
async import(packageName, source) {
|
|
19
|
+
if (source.kind === 'file') {
|
|
20
|
+
return this.importFileUrl(packageName, source.path, source.path);
|
|
21
|
+
}
|
|
22
|
+
const tmpFile = this.createTempFile(source.originalPath, source.code);
|
|
23
|
+
try {
|
|
24
|
+
return await this.importFileUrl(packageName, tmpFile, source.originalPath);
|
|
25
|
+
}
|
|
26
|
+
finally {
|
|
27
|
+
this.safeUnlink(tmpFile);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async importFileUrl(packageName, filePath, reportedPath) {
|
|
31
|
+
try {
|
|
32
|
+
// Cache-bust with a query parameter so repeated postinstall runs in the
|
|
33
|
+
// same process (e.g. tests) always reload the latest bytes on disk.
|
|
34
|
+
const url = `${pathToFileURL(filePath).href}?t=${Date.now()}`;
|
|
35
|
+
const moduleValue = await import(url);
|
|
36
|
+
return ok(moduleValue);
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
return fail([
|
|
40
|
+
createPostinstallLoadFailedDiagnostic(packageName, reportedPath, error instanceof Error ? error.message : String(error)),
|
|
41
|
+
]);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
createTempFile(originalPath, code) {
|
|
45
|
+
const base = path.basename(originalPath, path.extname(originalPath));
|
|
46
|
+
const fileName = `uapkg-postinstall-${base}-${process.pid}-${Date.now()}.mjs`;
|
|
47
|
+
const tmpFile = path.join(os.tmpdir(), fileName);
|
|
48
|
+
fs.writeFileSync(tmpFile, code, 'utf-8');
|
|
49
|
+
return tmpFile;
|
|
50
|
+
}
|
|
51
|
+
safeUnlink(filePath) {
|
|
52
|
+
try {
|
|
53
|
+
fs.unlinkSync(filePath);
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
// Best-effort cleanup; OS tmp dir is rotated anyway.
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=ModuleImporter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleImporter.js","sourceRoot":"","sources":["../../../src/postinstall/loader/ModuleImporter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,qCAAqC,EAAE,IAAI,EAAE,EAAE,EAAe,MAAM,oBAAoB,CAAC;AAOlG;;;;;;;;;;GAUG;AACH,MAAM,OAAO,cAAc;IAClB,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,MAAoB;QAC3D,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;YAC3B,OAAO,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QACnE,CAAC;QACD,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,MAA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EAAE,OAAO,CAAC,CAAC;QACzC,OAAO,OAAO,CAAC;IACjB,CAAC;IAEO,UAAU,CAAC,QAAgB;QACjC,IAAI,CAAC;YACH,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,qDAAqD;QACvD,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type Result } from '@uapkg/diagnostics';
|
|
2
|
+
import type { PostinstallDefinition } from '../api/PostinstallDsl.js';
|
|
3
|
+
import { EntryResolver } from './EntryResolver.js';
|
|
4
|
+
import { EsbuildTranspiler } from './EsbuildTranspiler.js';
|
|
5
|
+
import { ExportValidator } from './ExportValidator.js';
|
|
6
|
+
import { ModuleImporter } from './ModuleImporter.js';
|
|
7
|
+
export interface LoadedPostinstall {
|
|
8
|
+
readonly packageName: string;
|
|
9
|
+
readonly pluginRoot: string;
|
|
10
|
+
readonly entryFile: string;
|
|
11
|
+
readonly definition: PostinstallDefinition;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Facade that composes the four loader stages:
|
|
15
|
+
* 1. {@link EntryResolver} locate `.uapkg/postinstall.<ext>`
|
|
16
|
+
* 2. {@link EsbuildTranspiler} if `.ts`, transpile to ESM
|
|
17
|
+
* 3. {@link ModuleImporter} dynamic import → raw module value
|
|
18
|
+
* 4. {@link ExportValidator} Zod-validate default export
|
|
19
|
+
*
|
|
20
|
+
* Returns `ok(null)` when a plugin has no postinstall — a valid, silent state.
|
|
21
|
+
* Never throws: every stage returns `Result`.
|
|
22
|
+
*/
|
|
23
|
+
export declare class PostinstallLoader {
|
|
24
|
+
private readonly entryResolver;
|
|
25
|
+
private readonly transpiler;
|
|
26
|
+
private readonly importer;
|
|
27
|
+
private readonly validator;
|
|
28
|
+
constructor(entryResolver?: EntryResolver, transpiler?: EsbuildTranspiler, importer?: ModuleImporter, validator?: ExportValidator);
|
|
29
|
+
load(packageName: string, pluginRoot: string): Promise<Result<LoadedPostinstall | null>>;
|
|
30
|
+
private buildModuleSource;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=PostinstallLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostinstallLoader.d.ts","sourceRoot":"","sources":["../../../src/postinstall/loader/PostinstallLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;CAC5C;AAED;;;;;;;;;GASG;AACH,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBAHT,aAAa,GAAE,aAAmC,EAClD,UAAU,GAAE,iBAA2C,EACvD,QAAQ,GAAE,cAAqC,EAC/C,SAAS,GAAE,eAAuC;IAGxD,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;YAuBvF,iBAAiB;CAQhC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { fail, ok } from '@uapkg/diagnostics';
|
|
2
|
+
import { EntryResolver } from './EntryResolver.js';
|
|
3
|
+
import { EsbuildTranspiler } from './EsbuildTranspiler.js';
|
|
4
|
+
import { ExportValidator } from './ExportValidator.js';
|
|
5
|
+
import { ModuleImporter } from './ModuleImporter.js';
|
|
6
|
+
/**
|
|
7
|
+
* Facade that composes the four loader stages:
|
|
8
|
+
* 1. {@link EntryResolver} locate `.uapkg/postinstall.<ext>`
|
|
9
|
+
* 2. {@link EsbuildTranspiler} if `.ts`, transpile to ESM
|
|
10
|
+
* 3. {@link ModuleImporter} dynamic import → raw module value
|
|
11
|
+
* 4. {@link ExportValidator} Zod-validate default export
|
|
12
|
+
*
|
|
13
|
+
* Returns `ok(null)` when a plugin has no postinstall — a valid, silent state.
|
|
14
|
+
* Never throws: every stage returns `Result`.
|
|
15
|
+
*/
|
|
16
|
+
export class PostinstallLoader {
|
|
17
|
+
entryResolver;
|
|
18
|
+
transpiler;
|
|
19
|
+
importer;
|
|
20
|
+
validator;
|
|
21
|
+
constructor(entryResolver = new EntryResolver(), transpiler = new EsbuildTranspiler(), importer = new ModuleImporter(), validator = new ExportValidator()) {
|
|
22
|
+
this.entryResolver = entryResolver;
|
|
23
|
+
this.transpiler = transpiler;
|
|
24
|
+
this.importer = importer;
|
|
25
|
+
this.validator = validator;
|
|
26
|
+
}
|
|
27
|
+
async load(packageName, pluginRoot) {
|
|
28
|
+
const entryResult = this.entryResolver.resolve(packageName, pluginRoot);
|
|
29
|
+
if (!entryResult.ok)
|
|
30
|
+
return entryResult;
|
|
31
|
+
const entry = entryResult.value;
|
|
32
|
+
if (entry === null)
|
|
33
|
+
return ok(null);
|
|
34
|
+
const sourceResult = await this.buildModuleSource(packageName, entry);
|
|
35
|
+
if (!sourceResult.ok)
|
|
36
|
+
return sourceResult;
|
|
37
|
+
const importResult = await this.importer.import(packageName, sourceResult.value);
|
|
38
|
+
if (!importResult.ok)
|
|
39
|
+
return importResult;
|
|
40
|
+
const validated = this.validator.validate(packageName, entry.path, importResult.value);
|
|
41
|
+
if (!validated.ok)
|
|
42
|
+
return validated;
|
|
43
|
+
return ok({
|
|
44
|
+
packageName,
|
|
45
|
+
pluginRoot,
|
|
46
|
+
entryFile: entry.path,
|
|
47
|
+
definition: validated.value,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async buildModuleSource(packageName, entry) {
|
|
51
|
+
if (entry.kind !== 'ts') {
|
|
52
|
+
return ok({ kind: 'file', path: entry.path });
|
|
53
|
+
}
|
|
54
|
+
const transpiled = await this.transpiler.transpile(packageName, entry.path);
|
|
55
|
+
if (!transpiled.ok)
|
|
56
|
+
return fail(transpiled.diagnostics);
|
|
57
|
+
return ok({ kind: 'transpiled', code: transpiled.value, originalPath: entry.path });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=PostinstallLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostinstallLoader.js","sourceRoot":"","sources":["../../../src/postinstall/loader/PostinstallLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,EAAE,EAAe,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAqB,MAAM,qBAAqB,CAAC;AASxE;;;;;;;;;GASG;AACH,MAAM,OAAO,iBAAiB;IAET;IACA;IACA;IACA;IAJnB,YACmB,gBAA+B,IAAI,aAAa,EAAE,EAClD,aAAgC,IAAI,iBAAiB,EAAE,EACvD,WAA2B,IAAI,cAAc,EAAE,EAC/C,YAA6B,IAAI,eAAe,EAAE;QAHlD,kBAAa,GAAb,aAAa,CAAqC;QAClD,eAAU,GAAV,U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I,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5E,IAAI,CAAC,UAAU,CAAC,EAAE;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QACxD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACtF,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Result } from '@uapkg/diagnostics';
|
|
2
|
+
import { MarkerBlockService } from './MarkerBlockService.js';
|
|
3
|
+
import { MarkerIntegrityValidator } from './MarkerIntegrityValidator.js';
|
|
4
|
+
/**
|
|
5
|
+
* Higher-level idempotent wrapper around {@link MarkerBlockService}.
|
|
6
|
+
*
|
|
7
|
+
* - `upsert`: remove any existing owned block and re-insert fresh content.
|
|
8
|
+
* Idempotent: calling twice with the same input yields the same result.
|
|
9
|
+
* - `remove`: strip the owned block if present; no-op otherwise.
|
|
10
|
+
* - `validate`: detect corruption (orphaned/nested markers) in the source for
|
|
11
|
+
* the owning `(pluginName, zone)` pair. Returns a `POSTINSTALL_MARKER_CORRUPT`
|
|
12
|
+
* diagnostic on failure; never throws.
|
|
13
|
+
*
|
|
14
|
+
* Injectors compose this helper to achieve "edit once, safe to re-run" semantics.
|
|
15
|
+
*/
|
|
16
|
+
export declare class MarkerBlockEditor {
|
|
17
|
+
private readonly service;
|
|
18
|
+
private readonly integrity;
|
|
19
|
+
constructor(service?: MarkerBlockService, integrity?: MarkerIntegrityValidator);
|
|
20
|
+
upsert(source: string, pluginName: string, zone: string, content: string, indent?: string): string;
|
|
21
|
+
remove(source: string, pluginName: string, zone: string): string;
|
|
22
|
+
contains(source: string, pluginName: string, zone: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Validates that the source contains a well-formed marker block for the
|
|
25
|
+
* owning `(pluginName, zone)` pair. Returns `Result.ok` when clean; returns
|
|
26
|
+
* `Result.fail` with a `POSTINSTALL_MARKER_CORRUPT` diagnostic otherwise.
|
|
27
|
+
*/
|
|
28
|
+
validate(source: string, pluginName: string, zone: string, filePath: string): Result<void>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=MarkerBlockEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerBlockEditor.d.ts","sourceRoot":"","sources":["../../../src/postinstall/markers/MarkerBlockEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsD,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,qBAAa,iBAAiB;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS;gBADT,OAAO,GAAE,kBAA6C,EACtD,SAAS,GAAE,wBAAyD;IAGhF,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,MAAM;IAM9F,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIhE,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAI1E;;;;OAIG;IACI,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;CAKlG"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createPostinstallMarkerCorruptDiagnostic, fail, ok } from '@uapkg/diagnostics';
|
|
2
|
+
import { MarkerBlockService } from './MarkerBlockService.js';
|
|
3
|
+
import { MarkerIntegrityValidator } from './MarkerIntegrityValidator.js';
|
|
4
|
+
/**
|
|
5
|
+
* Higher-level idempotent wrapper around {@link MarkerBlockService}.
|
|
6
|
+
*
|
|
7
|
+
* - `upsert`: remove any existing owned block and re-insert fresh content.
|
|
8
|
+
* Idempotent: calling twice with the same input yields the same result.
|
|
9
|
+
* - `remove`: strip the owned block if present; no-op otherwise.
|
|
10
|
+
* - `validate`: detect corruption (orphaned/nested markers) in the source for
|
|
11
|
+
* the owning `(pluginName, zone)` pair. Returns a `POSTINSTALL_MARKER_CORRUPT`
|
|
12
|
+
* diagnostic on failure; never throws.
|
|
13
|
+
*
|
|
14
|
+
* Injectors compose this helper to achieve "edit once, safe to re-run" semantics.
|
|
15
|
+
*/
|
|
16
|
+
export class MarkerBlockEditor {
|
|
17
|
+
service;
|
|
18
|
+
integrity;
|
|
19
|
+
constructor(service = new MarkerBlockService(), integrity = new MarkerIntegrityValidator()) {
|
|
20
|
+
this.service = service;
|
|
21
|
+
this.integrity = integrity;
|
|
22
|
+
}
|
|
23
|
+
upsert(source, pluginName, zone, content, indent = '') {
|
|
24
|
+
const stripped = this.service.stripOwnedBlock(source, pluginName, zone);
|
|
25
|
+
const block = this.service.createBlock(pluginName, zone, content, indent);
|
|
26
|
+
return `${stripped.trimEnd()}\n${block}\n`;
|
|
27
|
+
}
|
|
28
|
+
remove(source, pluginName, zone) {
|
|
29
|
+
return this.service.stripOwnedBlock(source, pluginName, zone);
|
|
30
|
+
}
|
|
31
|
+
contains(source, pluginName, zone) {
|
|
32
|
+
return this.service.containsOwnedBlock(source, pluginName, zone);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Validates that the source contains a well-formed marker block for the
|
|
36
|
+
* owning `(pluginName, zone)` pair. Returns `Result.ok` when clean; returns
|
|
37
|
+
* `Result.fail` with a `POSTINSTALL_MARKER_CORRUPT` diagnostic otherwise.
|
|
38
|
+
*/
|
|
39
|
+
validate(source, pluginName, zone, filePath) {
|
|
40
|
+
const result = this.integrity.validate(source, pluginName, zone);
|
|
41
|
+
if (result.ok)
|
|
42
|
+
return ok(undefined);
|
|
43
|
+
return fail([createPostinstallMarkerCorruptDiagnostic(pluginName, filePath, result.reason)]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=MarkerBlockEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerBlockEditor.js","sourceRoot":"","sources":["../../../src/postinstall/markers/MarkerBlockEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wCAAwC,EAAE,IAAI,EAAE,EAAE,EAAe,MAAM,oBAAoB,CAAC;AACrG,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,iBAAiB;IAET;IACA;IAFnB,YACmB,UAA8B,IAAI,kBAAkB,EAAE,EACtD,YAAsC,IAAI,wBAAwB,EAAE;QADpE,YAAO,GAAP,OAAO,CAA+C;QACtD,cAAS,GAAT,SAAS,CAA2D;IACpF,CAAC;IAEG,MAAM,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAY,EAAE,OAAe,EAAE,MAAM,GAAG,EAAE;QAC1F,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QACxE,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1E,OAAO,GAAG,QAAQ,CAAC,OAAO,EAAE,KAAK,KAAK,IAAI,CAAC;IAC7C,CAAC;IAEM,MAAM,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAY;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IAChE,CAAC;IAEM,QAAQ,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAY;QAC9D,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;IACnE,CAAC;IAED;;;;OAIG;IACI,QAAQ,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAY,EAAE,QAAgB;QAChF,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,CAAC;QACjE,IAAI,MAAM,CAAC,EAAE;YAAE,OAAO,EAAE,CAAC,SAAS,CAAC,CAAC;QACpC,OAAO,IAAI,CAAC,CAAC,wCAAwC,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC/F,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level marker-block primitives.
|
|
3
|
+
*
|
|
4
|
+
* A marker block has the form:
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* <indent>// UAPKG-BEGIN <pluginName>:<zone>
|
|
8
|
+
* <indent><content...>
|
|
9
|
+
* <indent>// UAPKG-END <pluginName>:<zone>
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Blocks are *owned* by a `(pluginName, zone)` pair — only the owning pair's
|
|
13
|
+
* blocks are ever rewritten. Behavior mirrors the legacy `MarkerBlockService`
|
|
14
|
+
* so existing host-project files stay stable across the rewrite.
|
|
15
|
+
*/
|
|
16
|
+
export declare class MarkerBlockService {
|
|
17
|
+
makeBegin(pluginName: string, zone: string): string;
|
|
18
|
+
makeEnd(pluginName: string, zone: string): string;
|
|
19
|
+
createBlock(pluginName: string, zone: string, content: string, indent?: string): string;
|
|
20
|
+
stripOwnedBlock(source: string, pluginName: string, zone: string): string;
|
|
21
|
+
containsOwnedBlock(source: string, pluginName: string, zone: string): boolean;
|
|
22
|
+
private escapeForRegex;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=MarkerBlockService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerBlockService.d.ts","sourceRoot":"","sources":["../../../src/postinstall/markers/MarkerBlockService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,qBAAa,kBAAkB;IACtB,SAAS,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAInD,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAIjD,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,SAAK,GAAG,MAAM;IAUnF,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAOzE,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IAKpF,OAAO,CAAC,cAAc;CAGvB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level marker-block primitives.
|
|
3
|
+
*
|
|
4
|
+
* A marker block has the form:
|
|
5
|
+
*
|
|
6
|
+
* ```
|
|
7
|
+
* <indent>// UAPKG-BEGIN <pluginName>:<zone>
|
|
8
|
+
* <indent><content...>
|
|
9
|
+
* <indent>// UAPKG-END <pluginName>:<zone>
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Blocks are *owned* by a `(pluginName, zone)` pair — only the owning pair's
|
|
13
|
+
* blocks are ever rewritten. Behavior mirrors the legacy `MarkerBlockService`
|
|
14
|
+
* so existing host-project files stay stable across the rewrite.
|
|
15
|
+
*/
|
|
16
|
+
export class MarkerBlockService {
|
|
17
|
+
makeBegin(pluginName, zone) {
|
|
18
|
+
return `// UAPKG-BEGIN ${pluginName}:${zone}`;
|
|
19
|
+
}
|
|
20
|
+
makeEnd(pluginName, zone) {
|
|
21
|
+
return `// UAPKG-END ${pluginName}:${zone}`;
|
|
22
|
+
}
|
|
23
|
+
createBlock(pluginName, zone, content, indent = '') {
|
|
24
|
+
const begin = `${indent}${this.makeBegin(pluginName, zone)}`;
|
|
25
|
+
const end = `${indent}${this.makeEnd(pluginName, zone)}`;
|
|
26
|
+
const lines = content
|
|
27
|
+
.trim()
|
|
28
|
+
.split(/\r?\n/)
|
|
29
|
+
.map((line) => `${indent}${line}`.replace(/[ \t]+$/g, ''));
|
|
30
|
+
return `${begin}\n${lines.join('\n')}\n${end}`;
|
|
31
|
+
}
|
|
32
|
+
stripOwnedBlock(source, pluginName, zone) {
|
|
33
|
+
const begin = this.escapeForRegex(this.makeBegin(pluginName, zone));
|
|
34
|
+
const end = this.escapeForRegex(this.makeEnd(pluginName, zone));
|
|
35
|
+
const pattern = new RegExp(`^[ \\t]*${begin}[\\s\\S]*?^[ \\t]*${end}\\s*\\r?\\n?`, 'gm');
|
|
36
|
+
return source.replace(pattern, '');
|
|
37
|
+
}
|
|
38
|
+
containsOwnedBlock(source, pluginName, zone) {
|
|
39
|
+
const begin = this.escapeForRegex(this.makeBegin(pluginName, zone));
|
|
40
|
+
return new RegExp(`^[ \\t]*${begin}$`, 'm').test(source);
|
|
41
|
+
}
|
|
42
|
+
escapeForRegex(value) {
|
|
43
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=MarkerBlockService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerBlockService.js","sourceRoot":"","sources":["../../../src/postinstall/markers/MarkerBlockService.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,MAAM,OAAO,kBAAkB;IACtB,SAAS,CAAC,UAAkB,EAAE,IAAY;QAC/C,OAAO,kBAAkB,UAAU,IAAI,IAAI,EAAE,CAAC;IAChD,CAAC;IAEM,OAAO,CAAC,UAAkB,EAAE,IAAY;QAC7C,OAAO,gBAAgB,UAAU,IAAI,IAAI,EAAE,CAAC;IAC9C,CAAC;IAEM,WAAW,CAAC,UAAkB,EAAE,IAAY,EAAE,OAAe,EAAE,MAAM,GAAG,EAAE;QAC/E,MAAM,KAAK,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;QAC7D,MAAM,GAAG,GAAG,GAAG,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,EAAE,CAAC;QACzD,MAAM,KAAK,GAAG,OAAO;aAClB,IAAI,EAAE;aACN,KAAK,CAAC,OAAO,CAAC;aACd,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,MAAM,GAAG,IAAI,EAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,CAAC;QAC7D,OAAO,GAAG,KAAK,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;IACjD,CAAC;IAEM,eAAe,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAY;QACrE,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QACpE,MAAM,GAAG,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,IAAI,MAAM,CAAC,WAAW,KAAK,qBAAqB,GAAG,cAAc,EAAE,IAAI,CAAC,CAAC;QACzF,OAAO,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IACrC,CAAC;IAEM,kBAAkB,CAAC,MAAc,EAAE,UAAkB,EAAE,IAAY;QACxE,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC,CAAC;QACpE,OAAO,IAAI,MAAM,CAAC,WAAW,KAAK,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;IACtD,CAAC;CACF"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detects corruption in UAPKG marker blocks for a single `(pluginName, zone)`
|
|
3
|
+
* owning pair. Corruption rules (scoped to the owning pair — foreign plugins'
|
|
4
|
+
* blocks are ignored on purpose):
|
|
5
|
+
*
|
|
6
|
+
* 1. `UAPKG-BEGIN X:Z` with no matching `UAPKG-END X:Z` after it
|
|
7
|
+
* → `orphaned-begin`.
|
|
8
|
+
* 2. `UAPKG-END X:Z` with no preceding `UAPKG-BEGIN X:Z`
|
|
9
|
+
* → `orphaned-end`.
|
|
10
|
+
* 3. Two `UAPKG-BEGIN X:Z` before any `UAPKG-END X:Z`
|
|
11
|
+
* → `nested-begin`.
|
|
12
|
+
*
|
|
13
|
+
* The validator is a pure function — no I/O, no mutation, no exceptions. It
|
|
14
|
+
* returns the first violation encountered so callers can surface exactly one
|
|
15
|
+
* diagnostic per file.
|
|
16
|
+
*/
|
|
17
|
+
export interface MarkerIntegrityOk {
|
|
18
|
+
readonly ok: true;
|
|
19
|
+
}
|
|
20
|
+
export interface MarkerIntegrityFail {
|
|
21
|
+
readonly ok: false;
|
|
22
|
+
readonly reason: string;
|
|
23
|
+
readonly line: number;
|
|
24
|
+
}
|
|
25
|
+
export type MarkerIntegrityResult = MarkerIntegrityOk | MarkerIntegrityFail;
|
|
26
|
+
export declare class MarkerIntegrityValidator {
|
|
27
|
+
validate(source: string, pluginName: string, zone: string): MarkerIntegrityResult;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=MarkerIntegrityValidator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerIntegrityValidator.d.ts","sourceRoot":"","sources":["../../../src/postinstall/markers/MarkerIntegrityValidator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAE5E,qBAAa,wBAAwB;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,qBAAqB;CAyDzF"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export class MarkerIntegrityValidator {
|
|
2
|
+
validate(source, pluginName, zone) {
|
|
3
|
+
const beginToken = `UAPKG-BEGIN ${pluginName}:${zone}`;
|
|
4
|
+
const endToken = `UAPKG-END ${pluginName}:${zone}`;
|
|
5
|
+
const lines = source.split(/\r?\n/);
|
|
6
|
+
let depth = 0;
|
|
7
|
+
let lastBeginLine = -1;
|
|
8
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
9
|
+
const line = lines[i];
|
|
10
|
+
const hasBegin = line.includes(beginToken);
|
|
11
|
+
const hasEnd = line.includes(endToken);
|
|
12
|
+
if (hasBegin && hasEnd) {
|
|
13
|
+
// Same-line BEGIN+END is not a shape we emit; treat as malformed.
|
|
14
|
+
return {
|
|
15
|
+
ok: false,
|
|
16
|
+
reason: `BEGIN and END on same line at line ${i + 1}`,
|
|
17
|
+
line: i + 1,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (hasBegin) {
|
|
21
|
+
if (depth >= 1) {
|
|
22
|
+
return {
|
|
23
|
+
ok: false,
|
|
24
|
+
reason: `nested BEGIN at line ${i + 1} (previous BEGIN at line ${lastBeginLine + 1} was not closed)`,
|
|
25
|
+
line: i + 1,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
depth += 1;
|
|
29
|
+
lastBeginLine = i;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (hasEnd) {
|
|
33
|
+
if (depth === 0) {
|
|
34
|
+
return {
|
|
35
|
+
ok: false,
|
|
36
|
+
reason: `orphaned END at line ${i + 1} (no preceding BEGIN)`,
|
|
37
|
+
line: i + 1,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
depth -= 1;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (depth > 0) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
reason: `orphaned BEGIN at line ${lastBeginLine + 1} (missing END)`,
|
|
47
|
+
line: lastBeginLine + 1,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { ok: true };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=MarkerIntegrityValidator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkerIntegrityValidator.js","sourceRoot":"","sources":["../../../src/postinstall/markers/MarkerIntegrityValidator.ts"],"names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C;gBACX,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;oBAChB,OAAO;wBACL,EAAE,EAAE,KAAK;wBACT,MAAM,EAAE,wBAAwB,CAAC,GAAG,CAAC,uBAAuB;wBAC5D,IAAI,EAAE,CAAC,GAAG,CAAC;qBACZ,CAAC;gBACJ,CAAC;gBACD,KAAK,IAAI,CAAC,CAAC;YACb,CAAC;QACH,CAAC;QAED,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACd,OAAO;gBACL,EAAE,EAAE,KAAK;gBACT,MAAM,EAAE,0BAA0B,aAAa,GAAG,CAAC,gBAAgB;gBACnE,IAAI,EAAE,aAAa,GAAG,CAAC;aACxB,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC;IACtB,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type ConfigInstance, PostInstallPolicyResolver, type PostInstallPolicyValue, type ResolvedConfig } from '@uapkg/config';
|
|
2
|
+
import { type PostinstallPolicyDeniedDiagnostic } from '@uapkg/diagnostics';
|
|
3
|
+
/** Minimal config reader surface; defaults to the singleton `@uapkg/config`. */
|
|
4
|
+
export interface PolicyConfigReader {
|
|
5
|
+
getAll(): ResolvedConfig | Record<string, unknown> | null;
|
|
6
|
+
}
|
|
7
|
+
export interface PolicyDecision {
|
|
8
|
+
/** Whether the policy allows running a plugin's postinstall. */
|
|
9
|
+
readonly allowed: boolean;
|
|
10
|
+
/** The effective policy value ("allow"/"deny"). */
|
|
11
|
+
readonly policy: PostInstallPolicyValue;
|
|
12
|
+
/** Where the value was read from. */
|
|
13
|
+
readonly resolvedFrom: 'registry' | 'install';
|
|
14
|
+
/**
|
|
15
|
+
* Populated only when `allowed === false`. Callers attach this to their
|
|
16
|
+
* diagnostic bag and continue with other plugins (skipping is non-fatal).
|
|
17
|
+
*/
|
|
18
|
+
readonly denialDiagnostic?: PostinstallPolicyDeniedDiagnostic;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Consults {@link PostInstallPolicyResolver} to decide whether a given plugin's
|
|
22
|
+
* postinstall script should run. The resolver honors per-registry overrides
|
|
23
|
+
* and falls back to the global `install.postInstallPolicy` default (`deny`).
|
|
24
|
+
*
|
|
25
|
+
* This class is a thin glue layer so the orchestrator stays free of config
|
|
26
|
+
* vocabulary.
|
|
27
|
+
*/
|
|
28
|
+
export declare class PostinstallPolicyGate {
|
|
29
|
+
private readonly reader;
|
|
30
|
+
private readonly resolver;
|
|
31
|
+
constructor(reader?: PolicyConfigReader, resolver?: PostInstallPolicyResolver);
|
|
32
|
+
evaluate(packageName: string, registryName: string): PolicyDecision;
|
|
33
|
+
private readResolved;
|
|
34
|
+
}
|
|
35
|
+
export type { ConfigInstance };
|
|
36
|
+
//# sourceMappingURL=PostinstallPolicyGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostinstallPolicyGate.d.ts","sourceRoot":"","sources":["../../../src/postinstall/policy/PostinstallPolicyGate.ts"],"names":[],"mappings":"AAAA,OAAe,EACb,KAAK,cAAc,EACnB,yBAAyB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAA2C,KAAK,iCAAiC,EAAE,MAAM,oBAAoB,CAAC;AAErH,gFAAgF;AAChF,MAAM,WAAW,kBAAkB;IACjC,MAAM,IAAI,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3D;AAED,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,sBAAsB,CAAC;IACxC,qCAAqC;IACrC,QAAQ,CAAC,YAAY,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9C;;;OAGG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,iCAAiC,CAAC;CAC/D;AAED;;;;;;;GAOG;AACH,qBAAa,qBAAqB;IAE9B,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;gBADR,MAAM,GAAE,kBAA4D,EACpE,QAAQ,GAAE,yBAA2D;IAGjF,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,cAAc;IAc1E,OAAO,CAAC,YAAY;CAQrB;AAoBD,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Config, { PostInstallPolicyResolver, } from '@uapkg/config';
|
|
2
|
+
import { createPostinstallPolicyDeniedDiagnostic } from '@uapkg/diagnostics';
|
|
3
|
+
/**
|
|
4
|
+
* Consults {@link PostInstallPolicyResolver} to decide whether a given plugin's
|
|
5
|
+
* postinstall script should run. The resolver honors per-registry overrides
|
|
6
|
+
* and falls back to the global `install.postInstallPolicy` default (`deny`).
|
|
7
|
+
*
|
|
8
|
+
* This class is a thin glue layer so the orchestrator stays free of config
|
|
9
|
+
* vocabulary.
|
|
10
|
+
*/
|
|
11
|
+
export class PostinstallPolicyGate {
|
|
12
|
+
reader;
|
|
13
|
+
resolver;
|
|
14
|
+
constructor(reader = Config, resolver = new PostInstallPolicyResolver()) {
|
|
15
|
+
this.reader = reader;
|
|
16
|
+
this.resolver = resolver;
|
|
17
|
+
}
|
|
18
|
+
evaluate(packageName, registryName) {
|
|
19
|
+
const resolved = this.readResolved();
|
|
20
|
+
const { policy, resolvedFrom } = this.resolver.resolve(resolved, registryName);
|
|
21
|
+
if (policy === 'allow') {
|
|
22
|
+
return { allowed: true, policy, resolvedFrom };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
allowed: false,
|
|
26
|
+
policy,
|
|
27
|
+
resolvedFrom,
|
|
28
|
+
denialDiagnostic: createPostinstallPolicyDeniedDiagnostic(packageName, registryName, policy, resolvedFrom),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
readResolved() {
|
|
32
|
+
const value = this.reader.getAll();
|
|
33
|
+
if (!value || typeof value !== 'object' || !('install' in value)) {
|
|
34
|
+
// Defensive: if the caller passed an unresolved config, fall back to deny.
|
|
35
|
+
return FALLBACK_RESOLVED_CONFIG;
|
|
36
|
+
}
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Construct-or-else fallback: never used with the real `@uapkg/config`
|
|
42
|
+
* singleton (which always produces a `ResolvedConfig`), but shields the gate
|
|
43
|
+
* from arbitrary callers that might pass a partial config.
|
|
44
|
+
*/
|
|
45
|
+
const FALLBACK_RESOLVED_CONFIG = {
|
|
46
|
+
registry: '',
|
|
47
|
+
registries: {},
|
|
48
|
+
git: 'git',
|
|
49
|
+
editor: '',
|
|
50
|
+
exec: { shell: '' },
|
|
51
|
+
cache: { enabled: true },
|
|
52
|
+
registryCache: { ttlSeconds: 0 },
|
|
53
|
+
network: { retries: 0, timeout: 0, maxConcurrentDownloads: 1 },
|
|
54
|
+
install: { postInstallPolicy: 'deny' },
|
|
55
|
+
term: { quiet: false, verbose: false },
|
|
56
|
+
};
|
|
57
|
+
//# sourceMappingURL=PostinstallPolicyGate.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostinstallPolicyGate.js","sourceRoot":"","sources":["../../../src/postinstall/policy/PostinstallPolicyGate.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,EAAE,EAEb,yBAAyB,GAG1B,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,uCAAuC,EAA0C,MAAM,oBAAoB,CAAC;AAqBrH;;;;;;;GAOG;AACH,MAAM,OAAO,qBAAqB;IAEb;IACA;IAFnB,YACmB,SAA6B,MAAuC,EACpE,WAAsC,IAAI,yBAAyB,EAAE;QADrE,WAAM,GAAN,MAAM,CAA8D;QACpE,aAAQ,GAAR,QAAQ,CAA6D;IACrF,CAAC;IAE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AAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE;CACvC,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Result } from '@uapkg/diagnostics';
|
|
2
|
+
import { PostinstallLoader } from '../loader/PostinstallLoader.js';
|
|
3
|
+
import { PostinstallPolicyGate } from '../policy/PostinstallPolicyGate.js';
|
|
4
|
+
import { BuildCsInjector } from '../unreal/BuildCsInjector.js';
|
|
5
|
+
import { ProjectFileLocator } from '../unreal/ProjectFileLocator.js';
|
|
6
|
+
import { TargetCsInjector } from '../unreal/TargetCsInjector.js';
|
|
7
|
+
import { UnrealSourceCatalogBuilder } from '../unreal/UnrealSourceCatalog.js';
|
|
8
|
+
import { UProjectInjector } from '../unreal/UProjectInjector.js';
|
|
9
|
+
import { UProjectMetadataReader } from '../unreal/UProjectMetadataReader.js';
|
|
10
|
+
/**
|
|
11
|
+
* Projection of an installer action that the orchestrator needs. The CLI
|
|
12
|
+
* (Phase 8) will map `InstallAction` → `PostinstallCandidate` by filtering
|
|
13
|
+
* `type === 'add' | 'update'` and joining with the lockfile for registry
|
|
14
|
+
* metadata.
|
|
15
|
+
*/
|
|
16
|
+
export interface PostinstallCandidate {
|
|
17
|
+
readonly packageName: string;
|
|
18
|
+
readonly registry: string;
|
|
19
|
+
/** Absolute path to the installed plugin root. */
|
|
20
|
+
readonly pluginRoot: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PostinstallReport {
|
|
23
|
+
readonly executed: readonly string[];
|
|
24
|
+
readonly skipped: readonly {
|
|
25
|
+
packageName: string;
|
|
26
|
+
reason: 'no-script' | 'policy-denied';
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
export interface PostinstallOrchestratorInput {
|
|
30
|
+
readonly projectRoot: string;
|
|
31
|
+
readonly manifestType: 'project' | 'plugin';
|
|
32
|
+
readonly candidates: readonly PostinstallCandidate[];
|
|
33
|
+
/**
|
|
34
|
+
* Optional explicit module-name list (from `postinstall.modules` in the
|
|
35
|
+
* project manifest). When provided, overrides the names discovered from
|
|
36
|
+
* `.uproject`'s `Modules[]`. An empty array = override to "no modules".
|
|
37
|
+
*/
|
|
38
|
+
readonly moduleNameOverride?: readonly string[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Top-level postinstall flow:
|
|
42
|
+
*
|
|
43
|
+
* 1. Fast path: if the host is a plugin manifest, nothing runs.
|
|
44
|
+
* 2. For each candidate plugin:
|
|
45
|
+
* a. PolicyGate decides allow/deny. Deny → info diagnostic, skip.
|
|
46
|
+
* b. Loader locates + transpiles + imports + validates the script.
|
|
47
|
+
* c. Accumulate `(plugin, definition)` pairs into a plan.
|
|
48
|
+
* 3. Build a single {@link UnrealSourceCatalog} covering every module
|
|
49
|
+
* any script wants to touch.
|
|
50
|
+
* 4. Apply injectors idempotently per zone.
|
|
51
|
+
*
|
|
52
|
+
* Always returns a {@link Result}; never throws. The caller inspects
|
|
53
|
+
* `diagnostics` to render errors/warnings/info lines.
|
|
54
|
+
*/
|
|
55
|
+
export declare class PostinstallOrchestrator {
|
|
56
|
+
private readonly loader;
|
|
57
|
+
private readonly policy;
|
|
58
|
+
private readonly catalogBuilder;
|
|
59
|
+
private readonly buildInjector;
|
|
60
|
+
private readonly targetInjector;
|
|
61
|
+
private readonly projectInjector;
|
|
62
|
+
private readonly projectFileLocator;
|
|
63
|
+
private readonly uprojectReader;
|
|
64
|
+
constructor(loader?: PostinstallLoader, policy?: PostinstallPolicyGate, catalogBuilder?: UnrealSourceCatalogBuilder, buildInjector?: BuildCsInjector, targetInjector?: TargetCsInjector, projectInjector?: UProjectInjector, projectFileLocator?: ProjectFileLocator, uprojectReader?: UProjectMetadataReader);
|
|
65
|
+
run(input: PostinstallOrchestratorInput): Promise<Result<PostinstallReport>>;
|
|
66
|
+
private buildPlan;
|
|
67
|
+
private buildCatalog;
|
|
68
|
+
private applyScript;
|
|
69
|
+
private absorb;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMapping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