@aipt/idp-deploy 0.1.2

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 (52) hide show
  1. package/README.md +471 -0
  2. package/bin/idpctl.mjs +8 -0
  3. package/compose/edge.yaml +61 -0
  4. package/compose/flow.yaml +34 -0
  5. package/compose/portal.yaml +38 -0
  6. package/compose/postgresql.yaml +62 -0
  7. package/compose/registry.yaml +35 -0
  8. package/compose/smartgo.yaml +271 -0
  9. package/compose/tech.yaml +64 -0
  10. package/contracts/active-profile.schema.json +19 -0
  11. package/contracts/asset-lifecycle.schema.json +49 -0
  12. package/contracts/backup-generation.schema.json +60 -0
  13. package/contracts/component-runtime.schema.json +32 -0
  14. package/contracts/config-release.schema.json +33 -0
  15. package/contracts/deployment-evidence.schema.json +43 -0
  16. package/contracts/deployment-plan.schema.json +67 -0
  17. package/contracts/release-candidate.schema.json +33 -0
  18. package/contracts/release-defaults.schema.json +56 -0
  19. package/contracts/restore-candidate.schema.json +63 -0
  20. package/contracts/smartgo-component-config.schema.json +79 -0
  21. package/contracts/tech-backup-boundary.schema.json +61 -0
  22. package/contracts/tech-source-credentials.schema.json +17 -0
  23. package/deploy.sh +5 -0
  24. package/docs/restore-runbook.md +56 -0
  25. package/governance/asset-lifecycle.v1.json +79 -0
  26. package/package.json +42 -0
  27. package/release/defaults.v1.json +64 -0
  28. package/src/acceptance.mjs +127 -0
  29. package/src/bindings.mjs +518 -0
  30. package/src/cli.mjs +360 -0
  31. package/src/compose.mjs +19 -0
  32. package/src/config.mjs +903 -0
  33. package/src/delivery.mjs +123 -0
  34. package/src/errors.mjs +12 -0
  35. package/src/foundation-contracts.mjs +128 -0
  36. package/src/foundation.mjs +107 -0
  37. package/src/gitops.mjs +285 -0
  38. package/src/hash.mjs +47 -0
  39. package/src/image-lock.mjs +160 -0
  40. package/src/images.mjs +215 -0
  41. package/src/lifecycle.mjs +58 -0
  42. package/src/local-source.mjs +354 -0
  43. package/src/oci-mirror.mjs +10 -0
  44. package/src/operations.mjs +1484 -0
  45. package/src/process.mjs +46 -0
  46. package/src/profiles.mjs +41 -0
  47. package/src/release.mjs +1760 -0
  48. package/src/render.mjs +330 -0
  49. package/src/security.mjs +156 -0
  50. package/src/source-contracts.mjs +106 -0
  51. package/src/sources.mjs +78 -0
  52. package/src/workbench-projects.mjs +118 -0
@@ -0,0 +1,46 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ import fs from 'node:fs';
3
+ import { IdpError } from './errors.mjs';
4
+
5
+ export function run(command, args, options = {}) {
6
+ const { capture = false, ...spawnOptions } = options;
7
+ const result = spawnSync(command, args, { encoding: 'utf8', stdio: capture ? 'pipe' : 'inherit', ...spawnOptions });
8
+ if (result.error) throw new IdpError('IDP_PROCESS_START_FAILED', `${command}启动失败:${result.error.message}`);
9
+ if (result.status !== 0) throw new IdpError('IDP_PROCESS_FAILED', `${command}退出码${result.status}`, { stderr: result.stderr });
10
+ return result;
11
+ }
12
+
13
+ function assertProcessResult(command, result) {
14
+ if (result.error) throw new IdpError('IDP_PROCESS_START_FAILED', `${command}启动失败:${result.error.message}`);
15
+ if (result.status !== 0) throw new IdpError('IDP_PROCESS_FAILED', `${command}退出码${result.status}`, { stderr: Buffer.isBuffer(result.stderr) ? result.stderr.toString('utf8') : result.stderr });
16
+ }
17
+
18
+ export function runToFile(command, args, target, options = {}) {
19
+ const { capture: _capture, ...spawnOptions } = options;
20
+ const handle = fs.openSync(target, 'wx', 0o600);
21
+ let succeeded = false;
22
+ try {
23
+ const result = spawnSync(command, args, { encoding: null, stdio: ['ignore', handle, 'pipe'], maxBuffer: 16 * 1024 * 1024, ...spawnOptions });
24
+ assertProcessResult(command, result);
25
+ fs.fsyncSync(handle);
26
+ succeeded = true;
27
+ return result;
28
+ } finally {
29
+ fs.closeSync(handle);
30
+ if (!succeeded) {
31
+ try { fs.unlinkSync(target); } catch {}
32
+ }
33
+ }
34
+ }
35
+
36
+ export function runFromFile(command, args, source, options = {}) {
37
+ const { capture = false, ...spawnOptions } = options;
38
+ const handle = fs.openSync(source, 'r');
39
+ try {
40
+ const result = spawnSync(command, args, { encoding: 'utf8', stdio: [handle, capture ? 'pipe' : 'inherit', capture ? 'pipe' : 'inherit'], maxBuffer: 16 * 1024 * 1024, ...spawnOptions });
41
+ assertProcessResult(command, result);
42
+ return result;
43
+ } finally {
44
+ fs.closeSync(handle);
45
+ }
46
+ }
@@ -0,0 +1,41 @@
1
+ export const PROFILES = Object.freeze({
2
+ 'tech-only': ['postgresql', 'tech', 'edge'],
3
+ foundation: ['postgresql', 'registry', 'tech', 'edge'],
4
+ core: ['postgresql', 'registry', 'tech', 'flow', 'portal', 'edge'],
5
+ portal: ['postgresql', 'portal', 'edge'],
6
+ flow: ['flow', 'edge'],
7
+ registry: ['registry'],
8
+ full: ['postgresql', 'registry', 'tech', 'flow', 'portal', 'edge'],
9
+ 'business-smartgo': ['postgresql', 'smartgo', 'edge'],
10
+ 'core-smartgo': ['postgresql', 'registry', 'tech', 'flow', 'portal', 'smartgo', 'edge'],
11
+ });
12
+
13
+ const PROFILE_SERVICES = Object.freeze({
14
+ 'business-smartgo': [
15
+ 'postgresql',
16
+ 'smartgo-object-store',
17
+ 'smartgo-api',
18
+ 'smartgo-agent-runtime',
19
+ 'smartgo-worker',
20
+ 'smartgo-gotology',
21
+ 'smartgo-operations',
22
+ 'smartgo-studio',
23
+ 'edge',
24
+ ],
25
+ 'core-smartgo': [
26
+ 'postgresql', 'registry', 'tech', 'flow', 'portal',
27
+ 'smartgo-object-store', 'smartgo-api', 'smartgo-agent-runtime', 'smartgo-worker',
28
+ 'smartgo-gotology', 'smartgo-operations', 'smartgo-studio', 'edge',
29
+ ],
30
+ });
31
+
32
+ export function resolveProfile(name) {
33
+ const components = PROFILES[name];
34
+ if (!components) throw Object.assign(new Error(`未知Profile:${name}`), { code: 'IDP_PROFILE_UNKNOWN' });
35
+ return [...components];
36
+ }
37
+
38
+ export function resolveProfileServices(name) {
39
+ const components = resolveProfile(name);
40
+ return [...(PROFILE_SERVICES[name] ?? components)];
41
+ }