omnara 0.6.0 → 0.6.1

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 (73) hide show
  1. package/README.md +23 -10
  2. package/bin/omnara.js +56 -17
  3. package/package.json +24 -55
  4. package/dist/auth/auth-provider.d.ts +0 -26
  5. package/dist/auth/cli-auth-service.d.ts +0 -26
  6. package/dist/auth/credential-manager.d.ts +0 -13
  7. package/dist/auth/credentials-store.d.ts +0 -20
  8. package/dist/auth/ensure-cli-credentials.d.ts +0 -8
  9. package/dist/auth/login-flow.d.ts +0 -11
  10. package/dist/auth/loopback-listener.d.ts +0 -20
  11. package/dist/auth/pkce.d.ts +0 -6
  12. package/dist/cli.d.ts +0 -3
  13. package/dist/cli.js +0 -19479
  14. package/dist/cli.js.map +0 -7
  15. package/dist/commands/agent.d.ts +0 -9
  16. package/dist/commands/auth.d.ts +0 -2
  17. package/dist/commands/daemon.d.ts +0 -2
  18. package/dist/commands/index.d.ts +0 -4
  19. package/dist/commands/kill.d.ts +0 -2
  20. package/dist/config/omnara-config.d.ts +0 -19
  21. package/dist/daemon/config-store.d.ts +0 -37
  22. package/dist/daemon/daemon-client.d.ts +0 -27
  23. package/dist/daemon/daemon-launcher.d.ts +0 -39
  24. package/dist/daemon/daemon-service.d.ts +0 -30
  25. package/dist/daemon/directory-registry.d.ts +0 -17
  26. package/dist/daemon/local-control-server.d.ts +0 -38
  27. package/dist/daemon/machine-supervisor.d.ts +0 -63
  28. package/dist/daemon/paths.d.ts +0 -16
  29. package/dist/daemon/run-daemon.d.ts +0 -1
  30. package/dist/daemon/session-pid-registry.d.ts +0 -11
  31. package/dist/daemon/session-runner.d.ts +0 -38
  32. package/dist/daemon/state-store.d.ts +0 -14
  33. package/dist/env/env-mode.d.ts +0 -2
  34. package/dist/http/api-client.d.ts +0 -19
  35. package/dist/http/machines.d.ts +0 -3
  36. package/dist/http/user-sessions.d.ts +0 -16
  37. package/dist/http/workspaces.d.ts +0 -4
  38. package/dist/index.d.ts +0 -1
  39. package/dist/orchestrator/agent-orchestrator.d.ts +0 -103
  40. package/dist/orchestrator/ai-client.d.ts +0 -33
  41. package/dist/orchestrator/orchestrator-prompt.d.ts +0 -8
  42. package/dist/orchestrator/orchestrator-prompt.md +0 -222
  43. package/dist/orchestrator/orchestrator-types.d.ts +0 -168
  44. package/dist/orchestrator/session.d.ts +0 -83
  45. package/dist/orchestrator/tools/worker-tools.d.ts +0 -10
  46. package/dist/orchestrator/utils/completions-manager.d.ts +0 -8
  47. package/dist/orchestrator/utils/envelope-utils.d.ts +0 -13
  48. package/dist/orchestrator/utils/index.d.ts +0 -2
  49. package/dist/orchestrator/utils/session-logger.d.ts +0 -7
  50. package/dist/orchestrator/utils/worker-events.d.ts +0 -7
  51. package/dist/orchestrator/utils/worktree-manager.d.ts +0 -51
  52. package/dist/orchestrator/worker-manager.d.ts +0 -81
  53. package/dist/orchestrator/worker-types.d.ts +0 -23
  54. package/dist/orchestrator-prompt.md +0 -222
  55. package/dist/package-info.d.ts +0 -12
  56. package/dist/relay/relay-bridge.d.ts +0 -65
  57. package/dist/relay/relay-service.d.ts +0 -19
  58. package/dist/schemas/index.d.ts +0 -2
  59. package/dist/utils/backoff.d.ts +0 -6
  60. package/dist/utils/browser.d.ts +0 -1
  61. package/dist/utils/claude-code-check.d.ts +0 -19
  62. package/dist/utils/executable.d.ts +0 -53
  63. package/dist/utils/logger.d.ts +0 -143
  64. package/dist/utils/prompt.d.ts +0 -1
  65. package/dist/utils/version-check.d.ts +0 -43
  66. package/dist/utils/websocket.d.ts +0 -5
  67. package/instrument.mjs +0 -14
  68. package/scripts/build-executable.ts +0 -244
  69. package/scripts/copy-assets.mjs +0 -41
  70. package/scripts/generate-release-json.ts +0 -136
  71. package/scripts/preinstall.js +0 -141
  72. package/scripts/test-preinstall.js +0 -124
  73. package/scripts/upload-release.ts +0 -388
@@ -1,244 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Build script for creating Bun single-file executables.
4
- *
5
- * This script uses Bun's built-in compile feature to create standalone
6
- * executables that include the Bun runtime and all dependencies.
7
- *
8
- * Usage:
9
- * bun run scripts/build-executable.ts # Build for current platform
10
- * bun run scripts/build-executable.ts --all # Build for all platforms
11
- * bun run scripts/build-executable.ts --target linux-x64 # Build for specific target
12
- *
13
- * Supported targets:
14
- * - darwin-arm64 (macOS Apple Silicon)
15
- * - darwin-x64 (macOS Intel)
16
- * - linux-x64 (Linux x64)
17
- * - linux-arm64 (Linux ARM64)
18
- * - windows-x64 (Windows x64)
19
- */
20
-
21
- import { spawn } from 'bun';
22
- import { existsSync, mkdirSync, statSync } from 'node:fs';
23
- import { dirname, join, resolve } from 'node:path';
24
- import { readFileSync } from 'node:fs';
25
-
26
- // Get the path to the bun executable (handles cases where bun isn't in PATH)
27
- const bunPath = process.execPath;
28
-
29
- const projectRoot = resolve(dirname(import.meta.path), '..');
30
- const distDir = join(projectRoot, 'dist');
31
- const exeDir = join(distDir, 'exe');
32
- const entryPoint = join(projectRoot, 'src', 'cli.ts');
33
-
34
- // Read package.json for version info
35
- const pkgJson = JSON.parse(
36
- readFileSync(join(projectRoot, 'package.json'), 'utf8')
37
- ) as { version?: string; name?: string; description?: string };
38
-
39
- const version = pkgJson.version ?? '0.0.0';
40
- const packageName = pkgJson.name ?? 'omnara';
41
- const packageDescription = pkgJson.description ?? 'Command-line interface for Omnara.';
42
-
43
- // Bun compile targets
44
- type BunTarget =
45
- | 'bun-darwin-arm64'
46
- | 'bun-darwin-x64'
47
- | 'bun-linux-x64'
48
- | 'bun-linux-arm64'
49
- | 'bun-linux-x64-baseline'
50
- | 'bun-linux-arm64-musl'
51
- | 'bun-linux-x64-musl'
52
- | 'bun-windows-x64'
53
- | 'bun-windows-x64-baseline';
54
-
55
- interface TargetConfig {
56
- bunTarget: BunTarget;
57
- outputName: string;
58
- description: string;
59
- }
60
-
61
- const TARGETS: Record<string, TargetConfig> = {
62
- 'darwin-arm64': {
63
- bunTarget: 'bun-darwin-arm64',
64
- outputName: 'omnara-darwin-arm64',
65
- description: 'macOS Apple Silicon',
66
- },
67
- 'darwin-x64': {
68
- bunTarget: 'bun-darwin-x64',
69
- outputName: 'omnara-darwin-x64',
70
- description: 'macOS Intel',
71
- },
72
- 'linux-x64': {
73
- bunTarget: 'bun-linux-x64',
74
- outputName: 'omnara-linux-x64',
75
- description: 'Linux x64',
76
- },
77
- 'linux-arm64': {
78
- bunTarget: 'bun-linux-arm64',
79
- outputName: 'omnara-linux-arm64',
80
- description: 'Linux ARM64',
81
- },
82
- 'linux-x64-musl': {
83
- bunTarget: 'bun-linux-x64-musl',
84
- outputName: 'omnara-linux-x64-musl',
85
- description: 'Linux x64 (musl/Alpine)',
86
- },
87
- 'windows-x64': {
88
- bunTarget: 'bun-windows-x64',
89
- outputName: 'omnara-windows-x64.exe',
90
- description: 'Windows x64',
91
- },
92
- };
93
-
94
- // Map current platform to target name
95
- function getCurrentPlatformTarget(): string {
96
- const platform = process.platform;
97
- const arch = process.arch;
98
-
99
- if (platform === 'darwin' && arch === 'arm64') return 'darwin-arm64';
100
- if (platform === 'darwin' && arch === 'x64') return 'darwin-x64';
101
- if (platform === 'linux' && arch === 'x64') return 'linux-x64';
102
- if (platform === 'linux' && arch === 'arm64') return 'linux-arm64';
103
- if (platform === 'win32' && arch === 'x64') return 'windows-x64';
104
-
105
- throw new Error(`Unsupported platform: ${platform}-${arch}`);
106
- }
107
-
108
- async function buildTarget(targetName: string, config: TargetConfig): Promise<boolean> {
109
- const outputPath = join(exeDir, config.outputName);
110
-
111
- console.log(`\nBuilding ${config.description} (${targetName})...`);
112
- console.log(` Target: ${config.bunTarget}`);
113
- console.log(` Output: ${outputPath}`);
114
- console.log(` Version: ${version}`);
115
-
116
- const args = [
117
- 'build',
118
- entryPoint,
119
- '--compile',
120
- '--target', config.bunTarget,
121
- '--outfile', outputPath,
122
- '--minify',
123
- '--sourcemap',
124
- // Define package info constants at compile time (values must be JSON strings)
125
- '--define', `__PACKAGE_NAME__=${JSON.stringify(packageName)}`,
126
- '--define', `__PACKAGE_VERSION__=${JSON.stringify(version)}`,
127
- '--define', `__PACKAGE_DESCRIPTION__=${JSON.stringify(packageDescription)}`,
128
- ];
129
-
130
- // Debug: print full command
131
- console.log(` Command: ${bunPath} ${args.join(' ')}`);
132
-
133
- const proc = spawn({
134
- cmd: [bunPath, ...args],
135
- cwd: projectRoot,
136
- stdout: 'inherit',
137
- stderr: 'inherit',
138
- });
139
-
140
- const exitCode = await proc.exited;
141
-
142
- if (exitCode !== 0) {
143
- console.error(` Build failed with exit code ${exitCode}`);
144
- return false;
145
- }
146
-
147
- // Get file size
148
- if (existsSync(outputPath)) {
149
- const stats = statSync(outputPath);
150
- const sizeMB = (stats.size / (1024 * 1024)).toFixed(2);
151
- console.log(` Size: ${sizeMB} MB`);
152
- }
153
-
154
- return true;
155
- }
156
-
157
- async function main() {
158
- const args = process.argv.slice(2);
159
-
160
- console.log('='.repeat(60));
161
- console.log(`Omnara CLI Executable Builder (v${version})`);
162
- console.log('='.repeat(60));
163
-
164
- // Create output directory
165
- mkdirSync(exeDir, { recursive: true });
166
-
167
- let targets: string[] = [];
168
-
169
- if (args.includes('--all')) {
170
- // Build all targets
171
- targets = Object.keys(TARGETS);
172
- console.log('\nBuilding for all platforms...');
173
- } else if (args.includes('--target')) {
174
- // Build specific target
175
- const targetIndex = args.indexOf('--target');
176
- const targetName = args[targetIndex + 1];
177
-
178
- if (!targetName || !TARGETS[targetName]) {
179
- console.error(`Invalid target: ${targetName}`);
180
- console.error(`Available targets: ${Object.keys(TARGETS).join(', ')}`);
181
- process.exit(1);
182
- }
183
-
184
- targets = [targetName];
185
- } else {
186
- // Build for current platform
187
- const currentTarget = getCurrentPlatformTarget();
188
- targets = [currentTarget];
189
- console.log(`\nBuilding for current platform: ${currentTarget}`);
190
- }
191
-
192
- const results: { target: string; success: boolean }[] = [];
193
-
194
- for (const targetName of targets) {
195
- const config = TARGETS[targetName];
196
- if (!config) {
197
- console.error(`Unknown target: ${targetName}`);
198
- results.push({ target: targetName, success: false });
199
- continue;
200
- }
201
-
202
- const success = await buildTarget(targetName, config);
203
- results.push({ target: targetName, success });
204
- }
205
-
206
- // Print summary
207
- console.log('\n' + '='.repeat(60));
208
- console.log('Build Summary');
209
- console.log('='.repeat(60));
210
-
211
- let allSuccess = true;
212
- for (const result of results) {
213
- const status = result.success ? 'SUCCESS' : 'FAILED';
214
- const config = TARGETS[result.target];
215
- console.log(` ${result.target}: ${status}`);
216
- if (result.success && config) {
217
- console.log(` -> ${join(exeDir, config.outputName)}`);
218
- }
219
- if (!result.success) allSuccess = false;
220
- }
221
-
222
- console.log('');
223
-
224
- if (!allSuccess) {
225
- process.exit(1);
226
- }
227
-
228
- // Print usage instructions for single target builds
229
- if (targets.length === 1 && results[0]?.success) {
230
- const config = TARGETS[targets[0]];
231
- if (config) {
232
- const binaryPath = join(exeDir, config.outputName);
233
- console.log('To test the executable:');
234
- console.log(` ${binaryPath} --help`);
235
- console.log(` ${binaryPath} --version`);
236
- console.log('');
237
- }
238
- }
239
- }
240
-
241
- main().catch((error) => {
242
- console.error('Build failed:', error);
243
- process.exit(1);
244
- });
@@ -1,41 +0,0 @@
1
- import { mkdir, copyFile } from 'fs/promises';
2
- import { basename, join } from 'path';
3
- import { cwd } from 'process';
4
- import { glob } from 'glob';
5
-
6
- async function main() {
7
- const projectRoot = cwd();
8
- const mdFiles = await glob('src/orchestrator/*.md', {
9
- cwd: projectRoot,
10
- absolute: true,
11
- });
12
-
13
- if (mdFiles.length === 0) {
14
- return;
15
- }
16
-
17
- const distDir = join(projectRoot, 'dist');
18
- const orchestratorDistDir = join(distDir, 'orchestrator');
19
-
20
- await Promise.all([
21
- mkdir(distDir, { recursive: true }),
22
- mkdir(orchestratorDistDir, { recursive: true }),
23
- ]);
24
-
25
- await Promise.all(
26
- mdFiles.flatMap((file) => {
27
- const fileName = basename(file);
28
- const targets = [
29
- join(distDir, fileName),
30
- join(orchestratorDistDir, fileName),
31
- ];
32
-
33
- return targets.map((target) => copyFile(file, target));
34
- }),
35
- );
36
- }
37
-
38
- main().catch((error) => {
39
- console.error('[copy-assets] Failed to copy markdown assets:', error);
40
- process.exit(1);
41
- });
@@ -1,136 +0,0 @@
1
- #!/usr/bin/env bun
2
- /**
3
- * Generates release.json manifest for CLI releases.
4
- *
5
- * This script scans the dist/exe directory for built binaries,
6
- * calculates SHA256 checksums, and generates a release.json file
7
- * that the auto-update system uses to check for new versions.
8
- *
9
- * Usage:
10
- * bun run scripts/generate-release-json.ts
11
- * bun run scripts/generate-release-json.ts --version 0.5.0
12
- * bun run scripts/generate-release-json.ts --base-url https://releases.example.com
13
- */
14
-
15
- import { createHash } from 'node:crypto';
16
- import { existsSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
17
- import { dirname, join, resolve } from 'node:path';
18
-
19
- const projectRoot = resolve(dirname(import.meta.path), '..');
20
- const exeDir = join(projectRoot, 'dist', 'exe');
21
- const pkgJsonPath = join(projectRoot, 'package.json');
22
-
23
- interface PlatformInfo {
24
- url: string;
25
- sha256: string;
26
- }
27
-
28
- interface ReleaseInfo {
29
- version: string;
30
- released_at: string;
31
- platforms: Record<string, PlatformInfo>;
32
- }
33
-
34
- function parseArgs(): { version?: string; baseUrl: string } {
35
- const args = process.argv.slice(2);
36
- let version: string | undefined;
37
- let baseUrl = process.env.RELEASE_BASE_URL ?? 'https://releases.omnara.com';
38
-
39
- for (let i = 0; i < args.length; i++) {
40
- if (args[i] === '--version' && args[i + 1]) {
41
- version = args[i + 1];
42
- i++;
43
- } else if (args[i] === '--base-url' && args[i + 1]) {
44
- baseUrl = args[i + 1];
45
- i++;
46
- }
47
- }
48
-
49
- return { version, baseUrl };
50
- }
51
-
52
- function getPackageVersion(): string {
53
- const pkgJson = JSON.parse(readFileSync(pkgJsonPath, 'utf8')) as { version?: string };
54
- return pkgJson.version ?? '0.0.0';
55
- }
56
-
57
- function calculateSha256(filePath: string): string {
58
- const content = readFileSync(filePath);
59
- return createHash('sha256').update(content).digest('hex');
60
- }
61
-
62
- function extractPlatform(filename: string): string {
63
- // omnara-darwin-arm64 -> darwin-arm64
64
- // omnara-linux-x64-musl -> linux-x64-musl
65
- // omnara-windows-x64.exe -> windows-x64
66
- return filename.replace(/^omnara-/, '').replace(/\.exe$/, '');
67
- }
68
-
69
- function main(): void {
70
- const { version: argVersion, baseUrl } = parseArgs();
71
- const version = argVersion ?? getPackageVersion();
72
-
73
- console.log('='.repeat(60));
74
- console.log('Generating release.json');
75
- console.log('='.repeat(60));
76
- console.log(` Version: ${version}`);
77
- console.log(` Base URL: ${baseUrl}`);
78
- console.log(` Exe Dir: ${exeDir}`);
79
- console.log('');
80
-
81
- if (!existsSync(exeDir)) {
82
- console.error(`Error: Executable directory not found: ${exeDir}`);
83
- console.error('Run "bun run scripts/build-executable.ts --all" first.');
84
- process.exit(1);
85
- }
86
-
87
- const files = readdirSync(exeDir).filter((f) => {
88
- return f.startsWith('omnara-') && !f.endsWith('.sha256') && !f.endsWith('.json');
89
- });
90
-
91
- if (files.length === 0) {
92
- console.error('Error: No executable files found in dist/exe/');
93
- console.error('Run "bun run scripts/build-executable.ts --all" first.');
94
- process.exit(1);
95
- }
96
-
97
- console.log('Found executables:');
98
- const platforms: Record<string, PlatformInfo> = {};
99
-
100
- for (const file of files) {
101
- const filePath = join(exeDir, file);
102
- const platform = extractPlatform(file);
103
- const sha256 = calculateSha256(filePath);
104
-
105
- platforms[platform] = {
106
- url: `${baseUrl}/${version}/${file}`,
107
- sha256,
108
- };
109
-
110
- // Also write individual .sha256 file
111
- const sha256Path = `${filePath}.sha256`;
112
- writeFileSync(sha256Path, sha256);
113
-
114
- console.log(` ${platform}:`);
115
- console.log(` File: ${file}`);
116
- console.log(` SHA256: ${sha256}`);
117
- console.log(` URL: ${platforms[platform].url}`);
118
- }
119
-
120
- const release: ReleaseInfo = {
121
- version,
122
- released_at: new Date().toISOString(),
123
- platforms,
124
- };
125
-
126
- const releasePath = join(exeDir, 'release.json');
127
- writeFileSync(releasePath, JSON.stringify(release, null, 2) + '\n');
128
-
129
- console.log('');
130
- console.log(`Generated: ${releasePath}`);
131
- console.log('');
132
- console.log('Release manifest:');
133
- console.log(JSON.stringify(release, null, 2));
134
- }
135
-
136
- main();
@@ -1,141 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- import { execSync } from 'child_process';
4
-
5
- /**
6
- * Preinstall script to uninstall old omnara packages (pip and brew).
7
- * This ensures a clean migration to the npm package.
8
- */
9
-
10
- function log(message) {
11
- console.log(`[omnara preinstall] ${message}`);
12
- }
13
-
14
- function checkPipCommand() {
15
- const pipCommands = ['pip3', 'pip'];
16
-
17
- for (const cmd of pipCommands) {
18
- try {
19
- execSync(`${cmd} --version`, { stdio: 'ignore' });
20
- return cmd;
21
- } catch {
22
- // Command not found, try next
23
- }
24
- }
25
-
26
- return null;
27
- }
28
-
29
- function isPipPackageInstalled(pipCommand) {
30
- try {
31
- execSync(`${pipCommand} show omnara`, { stdio: 'ignore' });
32
- return true;
33
- } catch {
34
- return false;
35
- }
36
- }
37
-
38
- function uninstallPipPackage(pipCommand) {
39
- try {
40
- log(`Detected old omnara pip package in ${pipCommand}. Uninstalling...`);
41
-
42
- // Try without sudo first
43
- try {
44
- execSync(`${pipCommand} uninstall -y omnara`, { stdio: 'inherit' });
45
- log(`Successfully uninstalled old omnara pip package from ${pipCommand}.`);
46
- return true;
47
- } catch (firstError) {
48
- // If that fails, try with sudo
49
- log('Permission denied. Attempting with sudo...');
50
- try {
51
- execSync(`sudo ${pipCommand} uninstall -y omnara`, { stdio: 'inherit' });
52
- log(`Successfully uninstalled old omnara pip package from ${pipCommand} (with sudo).`);
53
- return true;
54
- } catch (sudoError) {
55
- throw sudoError;
56
- }
57
- }
58
- } catch (error) {
59
- log(`Warning: Failed to uninstall pip package from ${pipCommand}: ${error.message}`);
60
- log('You may need to manually run: sudo ' + pipCommand + ' uninstall omnara');
61
- return false;
62
- }
63
- }
64
-
65
- function checkBrewCommand() {
66
- try {
67
- execSync('brew --version', { stdio: 'ignore' });
68
- return true;
69
- } catch {
70
- return false;
71
- }
72
- }
73
-
74
- function isBrewPackageInstalled() {
75
- try {
76
- execSync('brew list omnara', { stdio: 'ignore' });
77
- return true;
78
- } catch {
79
- return false;
80
- }
81
- }
82
-
83
- function uninstallBrewPackage() {
84
- try {
85
- log('Detected old omnara brew package. Uninstalling...');
86
- execSync('brew uninstall omnara', { stdio: 'inherit' });
87
- log('Successfully uninstalled old omnara brew package.');
88
- return true;
89
- } catch (error) {
90
- log(`Warning: Failed to uninstall brew package: ${error.message}`);
91
- return false;
92
- }
93
- }
94
-
95
- function main() {
96
- log('Checking for old omnara installations...');
97
-
98
- // Check for pip packages - check BOTH pip and pip3
99
- log('Checking for pip packages...');
100
- const pipCommands = ['pip3', 'pip'];
101
- let foundAnyPip = false;
102
-
103
- for (const pipCmd of pipCommands) {
104
- try {
105
- execSync(`${pipCmd} --version`, { stdio: 'ignore' });
106
- foundAnyPip = true;
107
- log(`Found ${pipCmd} command`);
108
-
109
- if (isPipPackageInstalled(pipCmd)) {
110
- uninstallPipPackage(pipCmd);
111
- } else {
112
- log(`No old omnara package found in ${pipCmd}.`);
113
- }
114
- } catch {
115
- // Command not found, skip
116
- }
117
- }
118
-
119
- if (!foundAnyPip) {
120
- log('pip/pip3 not found. Skipping pip package check.');
121
- }
122
-
123
- // Check for brew package
124
- log('Checking for brew package...');
125
- if (!checkBrewCommand()) {
126
- log('brew not found. Skipping brew package check.');
127
- } else {
128
- log('Found brew command');
129
-
130
- if (isBrewPackageInstalled()) {
131
- uninstallBrewPackage();
132
- } else {
133
- log('No old brew package found.');
134
- }
135
- }
136
-
137
- log('Package check complete. Continuing with installation.');
138
- }
139
-
140
- main();
141
-
@@ -1,124 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * Test script for preinstall.js
5
- * This simulates various scenarios to ensure the preinstall script works correctly.
6
- */
7
-
8
- import { execSync } from 'child_process';
9
- import { readFileSync } from 'fs';
10
-
11
- console.log('='.repeat(60));
12
- console.log('Testing preinstall.js');
13
- console.log('='.repeat(60));
14
-
15
- // Test 0: Verify package.json configuration
16
- console.log('\n[TEST 0] Verifying package.json configuration...');
17
- try {
18
- const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
19
-
20
- // Check if preinstall script exists
21
- if (packageJson.scripts?.preinstall) {
22
- console.log('✅ preinstall script found in package.json');
23
- console.log(` Command: ${packageJson.scripts.preinstall}`);
24
- } else {
25
- console.error('❌ preinstall script NOT found in package.json');
26
- process.exit(1);
27
- }
28
-
29
- // Check if scripts directory is included in files
30
- if (packageJson.files?.includes('scripts')) {
31
- console.log('✅ scripts directory included in package files');
32
- } else {
33
- console.error('❌ scripts directory NOT included in package files');
34
- process.exit(1);
35
- }
36
- } catch (error) {
37
- console.error('❌ Failed to read package.json:', error.message);
38
- process.exit(1);
39
- }
40
-
41
- // Test 1: Check if the script runs without errors
42
- console.log('\n[TEST 1] Running preinstall.js...');
43
- try {
44
- execSync('node scripts/preinstall.js', {
45
- stdio: 'inherit',
46
- cwd: process.cwd()
47
- });
48
- console.log('✅ Script executed successfully');
49
- } catch (error) {
50
- console.error('❌ Script failed:', error.message);
51
- process.exit(1);
52
- }
53
-
54
- // Test 2: Check if pip/pip3 is available and check BOTH
55
- console.log('\n[TEST 2] Checking pip availability...');
56
- const pipCommands = ['pip3', 'pip'];
57
- let pipFound = false;
58
- for (const cmd of pipCommands) {
59
- try {
60
- execSync(`${cmd} --version`, { stdio: 'ignore' });
61
- console.log(`✅ Found ${cmd}`);
62
- pipFound = true;
63
-
64
- // Check if omnara pip package is installed
65
- try {
66
- const result = execSync(`${cmd} show omnara`, { encoding: 'utf8', stdio: 'pipe' });
67
- console.log(`⚠️ Warning: omnara pip package IS installed in ${cmd}`);
68
- console.log(' Package info:', result.split('\n')[0]);
69
- } catch {
70
- console.log(`✅ No omnara pip package found in ${cmd} (good)`);
71
- }
72
- } catch {
73
- // Command not found
74
- }
75
- }
76
- if (!pipFound) {
77
- console.log('ℹ️ No pip/pip3 found on system');
78
- }
79
-
80
- // Test 3: Check if brew is available
81
- console.log('\n[TEST 3] Checking brew availability...');
82
- try {
83
- execSync('brew --version', { stdio: 'ignore' });
84
- console.log('✅ Found brew');
85
-
86
- // Check if omnara brew package is installed
87
- try {
88
- execSync('brew list omnara', { stdio: 'ignore' });
89
- console.log('⚠️ Warning: omnara brew package IS installed');
90
- } catch {
91
- console.log('✅ No omnara brew package found (good)');
92
- }
93
- } catch {
94
- console.log('ℹ️ No brew found on system');
95
- }
96
-
97
- // Test 4: Verify script file permissions
98
- console.log('\n[TEST 4] Checking script permissions...');
99
- try {
100
- const fs = await import('fs');
101
- const stats = fs.statSync('scripts/preinstall.js');
102
- const mode = (stats.mode & parseInt('777', 8)).toString(8);
103
- console.log(`✅ Script permissions: ${mode}`);
104
- } catch (error) {
105
- console.error('❌ Could not check permissions:', error.message);
106
- }
107
-
108
- console.log('\n' + '='.repeat(60));
109
- console.log('Test Summary:');
110
- console.log('='.repeat(60));
111
- console.log('✅ All tests passed! The preinstall script is ready to use.');
112
- console.log('\nThe script will automatically run when users install with:');
113
- console.log(' npm install -g omnara');
114
- console.log('\nWhat the preinstall script does:');
115
- console.log(' 1. Checks both pip3 AND pip for old omnara packages');
116
- console.log(' 2. Checks brew for old omnara packages');
117
- console.log(' 3. Uninstalls any found packages (using sudo if needed)');
118
- console.log(' 4. Continues with npm installation');
119
- console.log('\nTo test the full installation flow:');
120
- console.log(' 1. Build: npm run build');
121
- console.log(' 2. Pack: npm pack');
122
- console.log(' 3. Install: npm install -g omnara-0.1.4.tgz');
123
- console.log(' 4. Verify: omnara --version');
124
- console.log('='.repeat(60));