unitup 0.1.5 → 0.3.0

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 (55) hide show
  1. package/.agents/AGENTS.md +35 -0
  2. package/.agents/skills/multi-runtime-management/SKILL.md +80 -0
  3. package/.agents/skills/platform-service-adapters/SKILL.md +108 -0
  4. package/.agents/skills/unitup-development-and-qa/SKILL.md +88 -0
  5. package/.agents/skills/zero-downtime-deployment/SKILL.md +135 -0
  6. package/CHANGELOG.md +5 -3
  7. package/README.md +89 -8
  8. package/biome.json +0 -1
  9. package/docs/index.html +188 -234
  10. package/index.d.ts +467 -440
  11. package/package.json +9 -3
  12. package/src/cli.js +561 -103
  13. package/src/core/drain-manager.js +70 -0
  14. package/src/core/generation-manager.js +414 -0
  15. package/src/core/index.js +8 -0
  16. package/src/core/ipc.js +236 -0
  17. package/src/core/lock.js +133 -0
  18. package/src/core/process-manager.js +313 -0
  19. package/src/core/readiness.js +243 -0
  20. package/src/core/router.js +390 -0
  21. package/src/core/supervisor.js +222 -0
  22. package/src/deploy/deployment-manager.js +407 -0
  23. package/src/deploy/index.js +9 -0
  24. package/src/deploy/rollback-manager.js +186 -0
  25. package/src/doctor.js +123 -56
  26. package/src/errors.js +131 -0
  27. package/src/index.js +186 -59
  28. package/src/logs.js +148 -0
  29. package/src/platform/base.js +211 -0
  30. package/src/platform/index.js +43 -0
  31. package/src/platform/linux.js +155 -0
  32. package/src/platform/macos.js +726 -0
  33. package/src/platform/windows-host.js +246 -0
  34. package/src/platform/windows.js +498 -0
  35. package/src/runtimes/bun.js +1 -1
  36. package/src/runtimes/common.js +24 -6
  37. package/src/runtimes/deno.js +1 -1
  38. package/src/runtimes/elixir.js +1 -1
  39. package/src/runtimes/go.js +1 -1
  40. package/src/runtimes/index.js +7 -7
  41. package/src/runtimes/native.js +2 -4
  42. package/src/runtimes/node.js +1 -1
  43. package/src/runtimes/php.js +1 -1
  44. package/src/runtimes/python.js +1 -1
  45. package/src/runtimes/ruby.js +1 -1
  46. package/src/runtimes/shell.js +1 -1
  47. package/src/schedule.js +31 -24
  48. package/src/service/config.js +63 -0
  49. package/src/service/manager.js +233 -0
  50. package/src/service/normalize.js +245 -0
  51. package/src/systemd.js +84 -38
  52. package/src/unit.js +17 -19
  53. package/src/utils.js +112 -18
  54. package/tsconfig.json +1 -1
  55. package/types-test/index.ts +158 -0
@@ -0,0 +1,155 @@
1
+ import {
2
+ addService,
3
+ getServiceFailures,
4
+ getServiceShow,
5
+ getServiceStatus,
6
+ inspectService,
7
+ listServices,
8
+ removeService,
9
+ restartService,
10
+ runJournalctlLogs,
11
+ startService,
12
+ stopService
13
+ } from '../systemd.js';
14
+ import { generateUnitContent, getUnitPath, unitFileExists } from '../unit.js';
15
+ import { getUnitFilename, sanitizeServiceName } from '../utils.js';
16
+ import { ServiceAdapter } from './base.js';
17
+
18
+ /**
19
+ * Linux platform service adapter using systemd and journald.
20
+ */
21
+ export class LinuxAdapter extends ServiceAdapter {
22
+ get name() {
23
+ return 'linux';
24
+ }
25
+
26
+ get capabilities() {
27
+ return {
28
+ serviceManager: 'systemd',
29
+ supports: {
30
+ install: true,
31
+ uninstall: true,
32
+ start: true,
33
+ stop: true,
34
+ restart: true,
35
+ enable: true,
36
+ disable: true,
37
+ status: true,
38
+ logs: true,
39
+ restartPolicy: true,
40
+ userServices: true,
41
+ systemServices: true,
42
+ memoryLimits: true,
43
+ schedule: true
44
+ }
45
+ };
46
+ }
47
+
48
+ generateService(config) {
49
+ return generateUnitContent({
50
+ name: config.name,
51
+ command: config.command,
52
+ args: config.args,
53
+ script: config.script,
54
+ cwd: config.cwd,
55
+ env: config.env,
56
+ envFile: config.envFile,
57
+ restart: config.restart?.policy || 'on-failure',
58
+ memoryHigh: config.resources?.memoryHigh,
59
+ memoryMax: config.resources?.memoryMax,
60
+ memorySwapMax: config.resources?.memorySwapMax
61
+ });
62
+ }
63
+
64
+ async install(config, options = {}) {
65
+ return addService({
66
+ ...config,
67
+ ...options,
68
+ name: config.name,
69
+ command: config.command,
70
+ args: config.args,
71
+ cwd: config.cwd,
72
+ env: config.env,
73
+ envFile: config.envFile,
74
+ restart: config.restart?.policy || 'on-failure',
75
+ memoryHigh: config.resources?.memoryHigh,
76
+ memoryMax: config.resources?.memoryMax,
77
+ memorySwapMax: config.resources?.memorySwapMax,
78
+ force: options.force || config.raw?.force
79
+ });
80
+ }
81
+
82
+ async uninstall(name, options = {}) {
83
+ return removeService(name, options);
84
+ }
85
+
86
+ async start(name, options = {}) {
87
+ return startService(name, options.enable || false);
88
+ }
89
+
90
+ async stop(name, options = {}) {
91
+ return stopService(name);
92
+ }
93
+
94
+ async restart(name, options = {}) {
95
+ return restartService(name);
96
+ }
97
+
98
+ async enable(name, options = {}) {
99
+ const safeName = sanitizeServiceName(name);
100
+ const unitFilename = getUnitFilename(safeName);
101
+ const res = await this.run('systemctl', ['--user', 'enable', unitFilename]);
102
+ if (res.code !== 0) {
103
+ throw new Error(`Failed to enable service "${safeName}": ${res.stderr || res.stdout}`);
104
+ }
105
+ return true;
106
+ }
107
+
108
+ async disable(name, options = {}) {
109
+ const safeName = sanitizeServiceName(name);
110
+ const unitFilename = getUnitFilename(safeName);
111
+ const res = await this.run('systemctl', ['--user', 'disable', unitFilename]);
112
+ if (res.code !== 0) {
113
+ throw new Error(`Failed to disable service "${safeName}": ${res.stderr || res.stdout}`);
114
+ }
115
+ return true;
116
+ }
117
+
118
+ async status(name, options = {}) {
119
+ const statusObj = await getServiceStatus(name);
120
+ return {
121
+ ...statusObj,
122
+ installed: true,
123
+ state: statusObj.status,
124
+ enabled: statusObj.enabled !== undefined ? statusObj.enabled : true,
125
+ platform: 'linux',
126
+ manager: 'systemd'
127
+ };
128
+ }
129
+
130
+ async inspect(name, options = {}) {
131
+ return inspectService(name);
132
+ }
133
+
134
+ async logs(name, options = {}) {
135
+ return runJournalctlLogs(name, options);
136
+ }
137
+
138
+ async list(options = {}) {
139
+ const list = await listServices(options);
140
+ return list.map((item) => ({
141
+ ...item,
142
+ platform: 'linux',
143
+ manager: 'systemd'
144
+ }));
145
+ }
146
+
147
+ isInstalled(name, options = {}) {
148
+ const safeName = sanitizeServiceName(name);
149
+ return unitFileExists(safeName);
150
+ }
151
+
152
+ async failures(options = {}) {
153
+ return getServiceFailures();
154
+ }
155
+ }