@indigoai-us/hq-cli 5.3.1 → 5.5.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.
- package/dist/bin/hq-auth-refresh.d.ts +13 -0
- package/dist/bin/hq-auth-refresh.d.ts.map +1 -0
- package/dist/bin/hq-auth-refresh.js +27 -0
- package/dist/bin/hq-auth-refresh.js.map +1 -0
- package/dist/commands/auth.d.ts +17 -13
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +83 -238
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/cloud.d.ts +3 -12
- package/dist/commands/cloud.d.ts.map +1 -1
- package/dist/commands/cloud.js +55 -212
- package/dist/commands/cloud.js.map +1 -1
- package/dist/commands/login.d.ts +6 -0
- package/dist/commands/login.d.ts.map +1 -0
- package/dist/commands/login.js +25 -0
- package/dist/commands/login.js.map +1 -0
- package/dist/commands/logout.d.ts +6 -0
- package/dist/commands/logout.d.ts.map +1 -0
- package/dist/commands/logout.js +21 -0
- package/dist/commands/logout.js.map +1 -0
- package/dist/commands/pkg-install.d.ts +17 -0
- package/dist/commands/pkg-install.d.ts.map +1 -0
- package/dist/commands/pkg-install.js +144 -0
- package/dist/commands/pkg-install.js.map +1 -0
- package/dist/commands/pkg-list.d.ts +8 -0
- package/dist/commands/pkg-list.d.ts.map +1 -0
- package/dist/commands/pkg-list.js +70 -0
- package/dist/commands/pkg-list.js.map +1 -0
- package/dist/commands/pkg-remove.d.ts +10 -0
- package/dist/commands/pkg-remove.d.ts.map +1 -0
- package/dist/commands/pkg-remove.js +53 -0
- package/dist/commands/pkg-remove.js.map +1 -0
- package/dist/commands/pkg-update.d.ts +9 -0
- package/dist/commands/pkg-update.d.ts.map +1 -0
- package/dist/commands/pkg-update.js +124 -0
- package/dist/commands/pkg-update.js.map +1 -0
- package/dist/commands/team-sync.d.ts +14 -0
- package/dist/commands/team-sync.d.ts.map +1 -0
- package/dist/commands/team-sync.js +422 -0
- package/dist/commands/team-sync.js.map +1 -0
- package/dist/commands/whoami.d.ts +6 -0
- package/dist/commands/whoami.d.ts.map +1 -0
- package/dist/commands/whoami.js +29 -0
- package/dist/commands/whoami.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -13
- package/dist/index.js.map +1 -1
- package/dist/strategies/merge.js +2 -2
- package/dist/strategies/merge.js.map +1 -1
- package/dist/utils/auth.d.ts +27 -0
- package/dist/utils/auth.d.ts.map +1 -0
- package/dist/utils/auth.js +155 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/cognito-session.d.ts +35 -0
- package/dist/utils/cognito-session.d.ts.map +1 -0
- package/dist/utils/cognito-session.js +72 -0
- package/dist/utils/cognito-session.js.map +1 -0
- package/dist/utils/git.js +1 -1
- package/dist/utils/git.js.map +1 -1
- package/dist/utils/hq-root.d.ts +10 -0
- package/dist/utils/hq-root.d.ts.map +1 -0
- package/dist/utils/hq-root.js +22 -0
- package/dist/utils/hq-root.js.map +1 -0
- package/dist/utils/integrity.d.ts +14 -0
- package/dist/utils/integrity.d.ts.map +1 -0
- package/dist/utils/integrity.js +40 -0
- package/dist/utils/integrity.js.map +1 -0
- package/dist/utils/manifest.d.ts.map +1 -1
- package/dist/utils/manifest.js +2 -5
- package/dist/utils/manifest.js.map +1 -1
- package/dist/utils/registry-client.d.ts +65 -0
- package/dist/utils/registry-client.d.ts.map +1 -0
- package/dist/utils/registry-client.js +102 -0
- package/dist/utils/registry-client.js.map +1 -0
- package/dist/utils/registry.d.ts +33 -0
- package/dist/utils/registry.d.ts.map +1 -0
- package/dist/utils/registry.js +58 -0
- package/dist/utils/registry.js.map +1 -0
- package/dist/utils/token-store.d.ts +28 -0
- package/dist/utils/token-store.d.ts.map +1 -0
- package/dist/utils/token-store.js +68 -0
- package/dist/utils/token-store.js.map +1 -0
- package/package.json +35 -45
- package/src/bin/hq-auth-refresh.ts +32 -0
- package/src/commands/add.ts +74 -0
- package/src/commands/auth.ts +153 -0
- package/src/commands/cloud.ts +125 -0
- package/src/commands/list.ts +66 -0
- package/src/commands/login.ts +29 -0
- package/src/commands/logout.ts +25 -0
- package/src/commands/pkg-install.ts +181 -0
- package/src/commands/pkg-list.ts +98 -0
- package/src/commands/pkg-remove.ts +71 -0
- package/src/commands/pkg-update.ts +189 -0
- package/src/commands/sync.ts +149 -0
- package/src/commands/team-sync.ts +629 -0
- package/src/commands/update.ts +71 -0
- package/src/commands/whoami.ts +38 -0
- package/src/index.ts +72 -0
- package/src/schemas/hq-package.schema.json +137 -0
- package/src/strategies/link.ts +62 -0
- package/src/strategies/merge.ts +142 -0
- package/src/types.ts +47 -0
- package/src/utils/auth.ts +193 -0
- package/src/utils/cognito-session.ts +94 -0
- package/src/utils/git.ts +74 -0
- package/src/utils/hq-root.ts +27 -0
- package/src/utils/integrity.ts +54 -0
- package/src/utils/manifest.ts +109 -0
- package/src/utils/registry-client.ts +204 -0
- package/src/utils/registry.ts +89 -0
- package/src/utils/token-store.ts +83 -0
- package/tsconfig.json +8 -0
- package/dist/commands/cloud-setup.d.ts +0 -19
- package/dist/commands/cloud-setup.d.ts.map +0 -1
- package/dist/commands/cloud-setup.js +0 -206
- package/dist/commands/cloud-setup.js.map +0 -1
- package/dist/commands/initial-upload.d.ts +0 -67
- package/dist/commands/initial-upload.d.ts.map +0 -1
- package/dist/commands/initial-upload.js +0 -205
- package/dist/commands/initial-upload.js.map +0 -1
- package/dist/sync-worker.d.ts +0 -11
- package/dist/sync-worker.d.ts.map +0 -1
- package/dist/sync-worker.js +0 -77
- package/dist/sync-worker.js.map +0 -1
- package/dist/utils/api-client.d.ts +0 -26
- package/dist/utils/api-client.d.ts.map +0 -1
- package/dist/utils/api-client.js +0 -87
- package/dist/utils/api-client.js.map +0 -1
- package/dist/utils/credentials.d.ts +0 -44
- package/dist/utils/credentials.d.ts.map +0 -1
- package/dist/utils/credentials.js +0 -101
- package/dist/utils/credentials.js.map +0 -1
- package/dist/utils/sync.d.ts +0 -125
- package/dist/utils/sync.d.ts.map +0 -1
- package/dist/utils/sync.js +0 -291
- package/dist/utils/sync.js.map +0 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hq modules sync command (US-004)
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as fs from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import {
|
|
9
|
+
findHqRoot,
|
|
10
|
+
readManifest,
|
|
11
|
+
readLock,
|
|
12
|
+
writeLock,
|
|
13
|
+
getModulesDir,
|
|
14
|
+
} from '../utils/manifest.js';
|
|
15
|
+
import {
|
|
16
|
+
cloneRepo,
|
|
17
|
+
fetchRepo,
|
|
18
|
+
pullRepo,
|
|
19
|
+
getCurrentCommit,
|
|
20
|
+
checkoutCommit,
|
|
21
|
+
isRepo,
|
|
22
|
+
ensureGitignore,
|
|
23
|
+
} from '../utils/git.js';
|
|
24
|
+
import { linkSync } from '../strategies/link.js';
|
|
25
|
+
import { mergeSync } from '../strategies/merge.js';
|
|
26
|
+
import type { ModuleDefinition, ModuleLock, SyncResult } from '../types.js';
|
|
27
|
+
|
|
28
|
+
async function syncModule(
|
|
29
|
+
module: ModuleDefinition,
|
|
30
|
+
moduleDir: string,
|
|
31
|
+
hqRoot: string,
|
|
32
|
+
locked: boolean,
|
|
33
|
+
lockData: ModuleLock | null
|
|
34
|
+
): Promise<SyncResult> {
|
|
35
|
+
const repoExists = await isRepo(moduleDir);
|
|
36
|
+
|
|
37
|
+
// Clone or fetch
|
|
38
|
+
if (!repoExists) {
|
|
39
|
+
console.log(` Cloning ${module.name}...`);
|
|
40
|
+
await cloneRepo(module.repo, moduleDir, module.branch);
|
|
41
|
+
} else {
|
|
42
|
+
console.log(` Fetching ${module.name}...`);
|
|
43
|
+
await fetchRepo(moduleDir);
|
|
44
|
+
|
|
45
|
+
// Checkout locked commit if --locked
|
|
46
|
+
if (locked && lockData?.locked[module.name]) {
|
|
47
|
+
await checkoutCommit(moduleDir, lockData.locked[module.name]);
|
|
48
|
+
} else {
|
|
49
|
+
await pullRepo(moduleDir);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Apply sync strategy
|
|
54
|
+
console.log(` Syncing with strategy: ${module.strategy}`);
|
|
55
|
+
let result: SyncResult;
|
|
56
|
+
|
|
57
|
+
switch (module.strategy) {
|
|
58
|
+
case 'link':
|
|
59
|
+
result = await linkSync(module, moduleDir, hqRoot);
|
|
60
|
+
break;
|
|
61
|
+
case 'merge':
|
|
62
|
+
case 'copy':
|
|
63
|
+
result = await mergeSync(module, moduleDir, hqRoot);
|
|
64
|
+
break;
|
|
65
|
+
default:
|
|
66
|
+
result = {
|
|
67
|
+
module: module.name,
|
|
68
|
+
success: false,
|
|
69
|
+
action: 'skipped',
|
|
70
|
+
message: `Unknown strategy: ${module.strategy}`,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return result;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function registerSyncCommand(program: Command): void {
|
|
78
|
+
program
|
|
79
|
+
.command('sync')
|
|
80
|
+
.description('Sync all modules from manifest')
|
|
81
|
+
.option('--locked', 'Use locked versions from modules.lock')
|
|
82
|
+
.action(async (options: { locked?: boolean }) => {
|
|
83
|
+
try {
|
|
84
|
+
const hqRoot = findHqRoot();
|
|
85
|
+
const manifest = readManifest(hqRoot);
|
|
86
|
+
|
|
87
|
+
if (!manifest || manifest.modules.length === 0) {
|
|
88
|
+
console.log('No modules in manifest. Use "hq modules add" to add modules.');
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const modulesDir = getModulesDir(hqRoot);
|
|
93
|
+
if (!fs.existsSync(modulesDir)) {
|
|
94
|
+
fs.mkdirSync(modulesDir, { recursive: true });
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Ensure modules/ is gitignored
|
|
98
|
+
ensureGitignore(hqRoot, 'modules/');
|
|
99
|
+
|
|
100
|
+
const lockData = options.locked ? readLock(hqRoot) : null;
|
|
101
|
+
const results: SyncResult[] = [];
|
|
102
|
+
const newLock: ModuleLock = { version: '1', locked: {} };
|
|
103
|
+
|
|
104
|
+
console.log(`Syncing ${manifest.modules.length} module(s)...\n`);
|
|
105
|
+
|
|
106
|
+
for (const module of manifest.modules) {
|
|
107
|
+
console.log(`[${module.name}]`);
|
|
108
|
+
const moduleDir = path.join(modulesDir, module.name);
|
|
109
|
+
|
|
110
|
+
const result = await syncModule(
|
|
111
|
+
module,
|
|
112
|
+
moduleDir,
|
|
113
|
+
hqRoot,
|
|
114
|
+
options.locked ?? false,
|
|
115
|
+
lockData
|
|
116
|
+
);
|
|
117
|
+
results.push(result);
|
|
118
|
+
|
|
119
|
+
// Record commit for lock file
|
|
120
|
+
if (result.success) {
|
|
121
|
+
const commit = await getCurrentCommit(moduleDir);
|
|
122
|
+
newLock.locked[module.name] = commit;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const status = result.success ? '✓' : '✗';
|
|
126
|
+
const msg = result.message || `${result.filesChanged ?? 0} files`;
|
|
127
|
+
console.log(` ${status} ${result.action}: ${msg}\n`);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Write lock file (US-008)
|
|
131
|
+
if (!options.locked) {
|
|
132
|
+
writeLock(hqRoot, newLock);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Summary
|
|
136
|
+
const success = results.filter(r => r.success).length;
|
|
137
|
+
const failed = results.filter(r => !r.success).length;
|
|
138
|
+
console.log(`Done: ${success} succeeded, ${failed} failed`);
|
|
139
|
+
|
|
140
|
+
if (failed > 0) {
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error('Error:', error instanceof Error ? error.message : error);
|
|
146
|
+
process.exit(1);
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
}
|