@curaious/uno 0.1.12 → 0.1.14
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/bin/cli.js +97 -1
- package/package.json +1 -1
package/bin/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ const fs = require('fs');
|
|
|
6
6
|
|
|
7
7
|
const DEPLOYMENTS_DIR = path.join(__dirname, '..', 'deployments');
|
|
8
8
|
const COMPOSE_FILE = path.join(DEPLOYMENTS_DIR, 'docker-compose.yaml');
|
|
9
|
+
const PACKAGE_JSON = path.join(__dirname, '..', 'package.json');
|
|
9
10
|
|
|
10
11
|
const CYAN = '\x1b[36m';
|
|
11
12
|
const GREEN = '\x1b[32m';
|
|
@@ -54,9 +55,25 @@ function runDockerCompose(args, options = {}) {
|
|
|
54
55
|
|
|
55
56
|
log(`\n${DIM}Running: docker ${composeArgs.join(' ')}${RESET}\n`);
|
|
56
57
|
|
|
58
|
+
// Read version from package.json and construct full image name
|
|
59
|
+
let env = { ...process.env };
|
|
60
|
+
if (fs.existsSync(PACKAGE_JSON)) {
|
|
61
|
+
try {
|
|
62
|
+
const pkg = JSON.parse(fs.readFileSync(PACKAGE_JSON, 'utf8'));
|
|
63
|
+
if (pkg.version && !env.UNO_IMAGE) {
|
|
64
|
+
// Only set UNO_IMAGE if it's not already set (allows manual override)
|
|
65
|
+
env.UNO_IMAGE = `praveenraj9495/uno-gateway:${pkg.version}`;
|
|
66
|
+
log(`${DIM}Using Uno version: ${pkg.version}${RESET}\n`);
|
|
67
|
+
}
|
|
68
|
+
} catch (err) {
|
|
69
|
+
// If we can't read package.json, continue without version
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
57
73
|
const proc = spawn('docker', composeArgs, {
|
|
58
74
|
stdio: 'inherit',
|
|
59
75
|
cwd: DEPLOYMENTS_DIR,
|
|
76
|
+
env: env,
|
|
60
77
|
...options
|
|
61
78
|
});
|
|
62
79
|
|
|
@@ -70,7 +87,68 @@ function runDockerCompose(args, options = {}) {
|
|
|
70
87
|
});
|
|
71
88
|
}
|
|
72
89
|
|
|
90
|
+
function parseArgs() {
|
|
91
|
+
const args = process.argv.slice(2);
|
|
92
|
+
const profiles = [];
|
|
93
|
+
const composeArgs = [];
|
|
94
|
+
let showHelp = false;
|
|
95
|
+
|
|
96
|
+
for (let i = 0; i < args.length; i++) {
|
|
97
|
+
const arg = args[i];
|
|
98
|
+
|
|
99
|
+
if (arg === '--help' || arg === '-h') {
|
|
100
|
+
showHelp = true;
|
|
101
|
+
} else if (arg === '--temporal') {
|
|
102
|
+
profiles.push('temporal');
|
|
103
|
+
} else if (arg === '--restate') {
|
|
104
|
+
profiles.push('restate');
|
|
105
|
+
} else if (arg === '--all') {
|
|
106
|
+
profiles.push('all');
|
|
107
|
+
} else {
|
|
108
|
+
// Pass through other arguments to docker compose
|
|
109
|
+
composeArgs.push(arg);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return { profiles, composeArgs, showHelp };
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function showHelpMessage() {
|
|
117
|
+
console.log(`
|
|
118
|
+
${BOLD}Usage:${RESET} npx @curaious/uno [options] [docker-compose-args]
|
|
119
|
+
|
|
120
|
+
${BOLD}Options:${RESET}
|
|
121
|
+
--temporal Enable temporal worker profile
|
|
122
|
+
--restate Enable restate service profile
|
|
123
|
+
--all Enable all profiles (temporal + restate)
|
|
124
|
+
--help, -h Show this help message
|
|
125
|
+
|
|
126
|
+
${BOLD}Profiles:${RESET}
|
|
127
|
+
temporal Start temporal worker service
|
|
128
|
+
restate Start restate service
|
|
129
|
+
all Start both temporal and restate services
|
|
130
|
+
|
|
131
|
+
${BOLD}Examples:${RESET}
|
|
132
|
+
npx @curaious/uno # Start default services (agent-server)
|
|
133
|
+
npx @curaious/uno --temporal # Start with temporal worker
|
|
134
|
+
npx @curaious/uno --restate # Start with restate service
|
|
135
|
+
npx @curaious/uno --all # Start with both temporal and restate
|
|
136
|
+
npx @curaious/uno --temporal up -d # Start temporal in detached mode
|
|
137
|
+
|
|
138
|
+
${BOLD}Note:${RESET}
|
|
139
|
+
Any additional arguments are passed directly to docker compose.
|
|
140
|
+
Use 'docker compose' commands like: up, down, ps, logs, etc.
|
|
141
|
+
`);
|
|
142
|
+
}
|
|
143
|
+
|
|
73
144
|
async function main() {
|
|
145
|
+
const { profiles, composeArgs, showHelp } = parseArgs();
|
|
146
|
+
|
|
147
|
+
if (showHelp) {
|
|
148
|
+
showHelpMessage();
|
|
149
|
+
process.exit(0);
|
|
150
|
+
}
|
|
151
|
+
|
|
74
152
|
banner();
|
|
75
153
|
|
|
76
154
|
if (!checkDocker()) {
|
|
@@ -82,9 +160,27 @@ async function main() {
|
|
|
82
160
|
process.exit(1);
|
|
83
161
|
}
|
|
84
162
|
|
|
163
|
+
// Build docker compose arguments
|
|
164
|
+
const dockerArgs = [];
|
|
165
|
+
|
|
166
|
+
// Add profile flags if any profiles are specified
|
|
167
|
+
if (profiles.length > 0) {
|
|
168
|
+
for (const profile of profiles) {
|
|
169
|
+
dockerArgs.push('--profile', profile);
|
|
170
|
+
}
|
|
171
|
+
log(`Using profiles: ${profiles.join(', ')}`, CYAN);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// Add compose command (default to 'up' if no command provided)
|
|
175
|
+
if (composeArgs.length === 0) {
|
|
176
|
+
dockerArgs.push('up');
|
|
85
177
|
log('Starting Uno services...', GREEN);
|
|
86
178
|
log(`${DIM}This may take a few minutes on first run to pull images.${RESET}`);
|
|
87
|
-
|
|
179
|
+
} else {
|
|
180
|
+
dockerArgs.push(...composeArgs);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
runDockerCompose(dockerArgs);
|
|
88
184
|
}
|
|
89
185
|
|
|
90
186
|
main().catch((err) => {
|