@aopslab/domain-cli-docman 0.1.4
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/LICENSE +202 -0
- package/NOTICE +6 -0
- package/dist/cli-types.d.ts +29 -0
- package/dist/cli-types.js +1 -0
- package/dist/command-surface.d.ts +16 -0
- package/dist/command-surface.js +69 -0
- package/dist/config-host.d.ts +2 -0
- package/dist/config-host.js +1 -0
- package/dist/env-bootstrap.d.ts +1 -0
- package/dist/env-bootstrap.js +96 -0
- package/dist/host-registration.d.ts +39 -0
- package/dist/host-registration.js +101 -0
- package/dist/main.d.ts +2 -0
- package/dist/main.js +1524 -0
- package/dist/manifests/host-registration.json +44 -0
- package/dist/sqlite-bootstrap.d.ts +1 -0
- package/dist/sqlite-bootstrap.js +79 -0
- package/dist/tsconfig.app.tsbuildinfo +1 -0
- package/package.json +52 -0
- package/resources/sqlite-bootstrap.sql +361 -0
- package/src/cli-types.ts +33 -0
- package/src/command-surface.ts +87 -0
- package/src/config-host.ts +24 -0
- package/src/env-bootstrap.ts +111 -0
- package/src/host-registration.ts +155 -0
- package/src/main.ts +1747 -0
- package/src/sqlite-bootstrap.ts +84 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs'
|
|
2
|
+
import path from 'node:path'
|
|
3
|
+
import { fileURLToPath } from 'node:url'
|
|
4
|
+
import { createRequire } from 'node:module'
|
|
5
|
+
import { DEFAULT_DOCMAN_SCOPE_ID } from '@aopslab/domain-runtime-config-docman'
|
|
6
|
+
|
|
7
|
+
export type DocmanHostRegistrationPathMode = 'portable' | 'installed' | 'package'
|
|
8
|
+
|
|
9
|
+
export type DocmanHostRegistrationManifest = {
|
|
10
|
+
kind: 'aops-host-registration'
|
|
11
|
+
registrationVersion: '1'
|
|
12
|
+
domain: 'docman'
|
|
13
|
+
displayName: 'Docman'
|
|
14
|
+
packageName: string
|
|
15
|
+
description: string
|
|
16
|
+
baseDir?: string
|
|
17
|
+
notes?: string[]
|
|
18
|
+
pluginLoader: {
|
|
19
|
+
allowlist: string[]
|
|
20
|
+
strictAllowlist: false
|
|
21
|
+
tolerantBootstrap: false
|
|
22
|
+
}
|
|
23
|
+
manifestProviders: Array<{
|
|
24
|
+
id: 'docman-dcm'
|
|
25
|
+
domain: 'docman'
|
|
26
|
+
enabled: true
|
|
27
|
+
module: string
|
|
28
|
+
exportName: 'buildDocmanDomainCapabilityManifest'
|
|
29
|
+
options: {
|
|
30
|
+
includeDocs: true
|
|
31
|
+
}
|
|
32
|
+
}>
|
|
33
|
+
plugins: Array<{
|
|
34
|
+
domain: 'docman'
|
|
35
|
+
enabled: true
|
|
36
|
+
module: string
|
|
37
|
+
factory: 'createDocmanPlugin'
|
|
38
|
+
options: {
|
|
39
|
+
defaultScopeId: typeof DEFAULT_DOCMAN_SCOPE_ID
|
|
40
|
+
}
|
|
41
|
+
}>
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
type PackageDescriptor = {
|
|
45
|
+
packageName: string
|
|
46
|
+
packageRoot: string
|
|
47
|
+
mainEntry: string
|
|
48
|
+
version: string
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const requireFromHere = createRequire(import.meta.url)
|
|
52
|
+
|
|
53
|
+
function readJsonFile<T>(filePath: string): T {
|
|
54
|
+
return JSON.parse(readFileSync(filePath, 'utf8')) as T
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function getCliPackageDescriptor(): PackageDescriptor {
|
|
58
|
+
const packageJsonPath = fileURLToPath(new URL('../package.json', import.meta.url))
|
|
59
|
+
const packageRoot = path.dirname(packageJsonPath)
|
|
60
|
+
const packageJson = readJsonFile<{ name?: string; main?: string; version?: string }>(packageJsonPath)
|
|
61
|
+
return {
|
|
62
|
+
packageName: packageJson.name?.trim() || '@aopslab/domain-cli-docman',
|
|
63
|
+
packageRoot,
|
|
64
|
+
mainEntry: path.resolve(packageRoot, packageJson.main?.trim() || 'dist/main.js'),
|
|
65
|
+
version: packageJson.version?.trim() || '0.0.0',
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function resolvePackageDescriptor(packageName: string): PackageDescriptor {
|
|
70
|
+
const packageJsonPath = requireFromHere.resolve(`${packageName}/package.json`)
|
|
71
|
+
const packageRoot = path.dirname(packageJsonPath)
|
|
72
|
+
const packageJson = readJsonFile<{ main?: string; version?: string }>(packageJsonPath)
|
|
73
|
+
return {
|
|
74
|
+
packageName,
|
|
75
|
+
packageRoot,
|
|
76
|
+
mainEntry: path.resolve(packageRoot, packageJson.main?.trim() || 'dist/index.js'),
|
|
77
|
+
version: packageJson.version?.trim() || '0.0.0',
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function toPortablePath(fromDir: string, targetPath: string): string {
|
|
82
|
+
const relative = path.relative(fromDir, targetPath).split(path.sep).join('/')
|
|
83
|
+
if (relative.startsWith('.')) return relative
|
|
84
|
+
return `./${relative}`
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function buildDocmanHostRegistrationManifest(
|
|
88
|
+
options: {
|
|
89
|
+
mode?: DocmanHostRegistrationPathMode
|
|
90
|
+
} = {},
|
|
91
|
+
): DocmanHostRegistrationManifest {
|
|
92
|
+
const mode = options.mode ?? 'installed'
|
|
93
|
+
const cli = getCliPackageDescriptor()
|
|
94
|
+
const toolingPackage = mode === 'package' ? '@aopslab/domain-kit-docman/operations' : '@aopslab/domain-tooling-docman'
|
|
95
|
+
const hostPluginPackage = '@aopslab/domain-host-plugin-docman'
|
|
96
|
+
const tooling = mode === 'package' ? null : resolvePackageDescriptor(toolingPackage)
|
|
97
|
+
const hostPlugin = mode === 'package' ? null : resolvePackageDescriptor(hostPluginPackage)
|
|
98
|
+
const portable = mode === 'portable'
|
|
99
|
+
const packageMode = mode === 'package'
|
|
100
|
+
const baseDir = portable ? '../..' : packageMode ? undefined : cli.packageRoot
|
|
101
|
+
const specifierBaseDir = portable ? cli.packageRoot : ''
|
|
102
|
+
const toolingModule = packageMode
|
|
103
|
+
? toolingPackage
|
|
104
|
+
: portable
|
|
105
|
+
? toPortablePath(specifierBaseDir, tooling!.mainEntry)
|
|
106
|
+
: tooling!.mainEntry
|
|
107
|
+
const pluginModule = packageMode
|
|
108
|
+
? hostPluginPackage
|
|
109
|
+
: portable
|
|
110
|
+
? toPortablePath(specifierBaseDir, hostPlugin!.mainEntry)
|
|
111
|
+
: hostPlugin!.mainEntry
|
|
112
|
+
|
|
113
|
+
return {
|
|
114
|
+
kind: 'aops-host-registration',
|
|
115
|
+
registrationVersion: '1',
|
|
116
|
+
domain: 'docman',
|
|
117
|
+
displayName: 'Docman',
|
|
118
|
+
packageName: cli.packageName,
|
|
119
|
+
description: 'Document graph and content-structure tooling for documents, sections, pages, snippets, embeds, rendering, and version workflows.',
|
|
120
|
+
...(baseDir ? { baseDir } : {}),
|
|
121
|
+
notes: [
|
|
122
|
+
'Prefer registering from `docman manifest host-registration` when docman is installed outside the AOPS workspace.',
|
|
123
|
+
'Provide `DOCMAN_REPO_URL`, `DOCMAN_SQLITE_URL`, or `DOCMAN_PG_URL` for explicit host runtime binding; standalone docman without a Docman-specific repo source falls back to `~/.aops/docman.aops.sqlite`.',
|
|
124
|
+
'HRM is runtime registration metadata only. Capability/discovery truth still comes from DCM.',
|
|
125
|
+
],
|
|
126
|
+
pluginLoader: {
|
|
127
|
+
allowlist: [pluginModule],
|
|
128
|
+
strictAllowlist: false,
|
|
129
|
+
tolerantBootstrap: false,
|
|
130
|
+
},
|
|
131
|
+
manifestProviders: [
|
|
132
|
+
{
|
|
133
|
+
id: 'docman-dcm',
|
|
134
|
+
domain: 'docman',
|
|
135
|
+
enabled: true,
|
|
136
|
+
module: toolingModule,
|
|
137
|
+
exportName: 'buildDocmanDomainCapabilityManifest',
|
|
138
|
+
options: {
|
|
139
|
+
includeDocs: true,
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
plugins: [
|
|
144
|
+
{
|
|
145
|
+
domain: 'docman',
|
|
146
|
+
enabled: true,
|
|
147
|
+
module: pluginModule,
|
|
148
|
+
factory: 'createDocmanPlugin',
|
|
149
|
+
options: {
|
|
150
|
+
defaultScopeId: DEFAULT_DOCMAN_SCOPE_ID,
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
],
|
|
154
|
+
}
|
|
155
|
+
}
|