@amodalai/amodal 0.2.1 → 0.2.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.
- package/CHANGELOG.md +29 -0
- package/dist/src/commands/connect-channel.d.ts +11 -0
- package/dist/src/commands/connect-channel.d.ts.map +1 -0
- package/dist/src/commands/connect-channel.js +169 -0
- package/dist/src/commands/connect-channel.js.map +1 -0
- package/dist/src/commands/connect.d.ts +3 -1
- package/dist/src/commands/connect.d.ts.map +1 -1
- package/dist/src/commands/connect.js +27 -16
- package/dist/src/commands/connect.js.map +1 -1
- package/dist/src/commands/groups/connect.d.ts +8 -0
- package/dist/src/commands/groups/connect.d.ts.map +1 -0
- package/dist/src/commands/groups/connect.js +17 -0
- package/dist/src/commands/groups/connect.js.map +1 -0
- package/dist/src/commands/groups/pkg.d.ts.map +1 -1
- package/dist/src/commands/groups/pkg.js +0 -12
- package/dist/src/commands/groups/pkg.js.map +1 -1
- package/dist/src/commands/index.d.ts +1 -1
- package/dist/src/commands/index.d.ts.map +1 -1
- package/dist/src/commands/index.js +3 -1
- package/dist/src/commands/index.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +4 -1
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/inspect.d.ts.map +1 -1
- package/dist/src/commands/inspect.js +32 -38
- package/dist/src/commands/inspect.js.map +1 -1
- package/dist/src/commands/install-pkg.d.ts +5 -5
- package/dist/src/commands/install-pkg.d.ts.map +1 -1
- package/dist/src/commands/install-pkg.js +35 -77
- package/dist/src/commands/install-pkg.js.map +1 -1
- package/dist/src/commands/uninstall.d.ts +2 -2
- package/dist/src/commands/uninstall.d.ts.map +1 -1
- package/dist/src/commands/uninstall.js +6 -32
- package/dist/src/commands/uninstall.js.map +1 -1
- package/dist/src/commands/validate.d.ts.map +1 -1
- package/dist/src/commands/validate.js +15 -21
- package/dist/src/commands/validate.js.map +1 -1
- package/dist/src/shared/tarball.js +1 -1
- package/dist/src/shared/tarball.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +5 -5
- package/src/commands/command-exports.test.ts +1 -1
- package/src/commands/connect-channel.ts +197 -0
- package/src/commands/connect.test.ts +28 -40
- package/src/commands/connect.ts +30 -24
- package/src/commands/groups/connect.ts +20 -0
- package/src/commands/groups/pkg.ts +0 -12
- package/src/commands/index.ts +5 -1
- package/src/commands/init.test.ts +2 -2
- package/src/commands/init.ts +5 -1
- package/src/commands/inspect.test.ts +1 -18
- package/src/commands/inspect.ts +31 -36
- package/src/commands/install-pkg.test.ts +39 -73
- package/src/commands/install-pkg.ts +38 -87
- package/src/commands/uninstall.test.ts +11 -51
- package/src/commands/uninstall.ts +7 -36
- package/src/commands/validate.test.ts +5 -26
- package/src/commands/validate.ts +15 -20
- package/src/e2e-commands.test.ts +0 -1
- package/src/e2e-plugins.test.ts +0 -1
- package/src/e2e.test.ts +0 -89
- package/src/shared/tarball.ts +1 -1
- package/dist/src/commands/diff.d.ts +0 -17
- package/dist/src/commands/diff.d.ts.map +0 -1
- package/dist/src/commands/diff.js +0 -118
- package/dist/src/commands/diff.js.map +0 -1
- package/dist/src/commands/list.d.ts +0 -18
- package/dist/src/commands/list.d.ts.map +0 -1
- package/dist/src/commands/list.js +0 -82
- package/dist/src/commands/list.js.map +0 -1
- package/dist/src/commands/publish.d.ts +0 -18
- package/dist/src/commands/publish.d.ts.map +0 -1
- package/dist/src/commands/publish.js +0 -121
- package/dist/src/commands/publish.js.map +0 -1
- package/dist/src/commands/search.d.ts +0 -19
- package/dist/src/commands/search.d.ts.map +0 -1
- package/dist/src/commands/search.js +0 -97
- package/dist/src/commands/search.js.map +0 -1
- package/dist/src/commands/update.d.ts +0 -19
- package/dist/src/commands/update.d.ts.map +0 -1
- package/dist/src/commands/update.js +0 -158
- package/dist/src/commands/update.js.map +0 -1
- package/src/commands/diff.test.ts +0 -165
- package/src/commands/diff.ts +0 -141
- package/src/commands/list.test.ts +0 -141
- package/src/commands/list.ts +0 -99
- package/src/commands/publish.test.ts +0 -169
- package/src/commands/publish.ts +0 -141
- package/src/commands/search.test.ts +0 -171
- package/src/commands/search.ts +0 -120
- package/src/commands/update.test.ts +0 -256
- package/src/commands/update.ts +0 -196
package/src/commands/update.ts
DELETED
|
@@ -1,196 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Amodal Labs, Inc.
|
|
4
|
-
* SPDX-License-Identifier: MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import type {CommandModule} from 'yargs';
|
|
8
|
-
import {
|
|
9
|
-
buildLockFile,
|
|
10
|
-
discoverInstalledPackages,
|
|
11
|
-
ensureNpmContext,
|
|
12
|
-
fromNpmName,
|
|
13
|
-
npmInstall,
|
|
14
|
-
npmViewVersions,
|
|
15
|
-
readLockFile,
|
|
16
|
-
} from '@amodalai/core';
|
|
17
|
-
import * as semver from 'semver';
|
|
18
|
-
import {findRepoRoot} from '../shared/repo-discovery.js';
|
|
19
|
-
|
|
20
|
-
export interface UpdateOptions {
|
|
21
|
-
cwd?: string;
|
|
22
|
-
name?: string;
|
|
23
|
-
latest?: boolean;
|
|
24
|
-
dryRun?: boolean;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface UpdateTarget {
|
|
28
|
-
npmName: string;
|
|
29
|
-
shortName: string;
|
|
30
|
-
currentVersion: string;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Update installed packages to newer versions.
|
|
35
|
-
* Returns the number of failures (0 = success).
|
|
36
|
-
*/
|
|
37
|
-
export async function runUpdate(options: UpdateOptions = {}): Promise<number> {
|
|
38
|
-
let repoPath: string;
|
|
39
|
-
try {
|
|
40
|
-
repoPath = findRepoRoot(options.cwd);
|
|
41
|
-
} catch (err) {
|
|
42
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
43
|
-
process.stderr.write(`[update] ${msg}\n`);
|
|
44
|
-
return 1;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const paths = await ensureNpmContext(repoPath);
|
|
48
|
-
|
|
49
|
-
const lockFile = await readLockFile(repoPath);
|
|
50
|
-
if (!lockFile) {
|
|
51
|
-
process.stderr.write('[update] No lock file found. Install packages first.\n');
|
|
52
|
-
return 1;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Build list of targets
|
|
56
|
-
const targets: UpdateTarget[] = [];
|
|
57
|
-
for (const [npmName, entry] of Object.entries(lockFile.packages)) {
|
|
58
|
-
const shortName = fromNpmName(npmName);
|
|
59
|
-
if (options.name && shortName !== options.name && npmName !== options.name) continue;
|
|
60
|
-
targets.push({
|
|
61
|
-
npmName,
|
|
62
|
-
shortName,
|
|
63
|
-
currentVersion: entry.version,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
if (targets.length === 0) {
|
|
68
|
-
if (options.name) {
|
|
69
|
-
process.stderr.write('[update] No matching packages found in lock file.\n');
|
|
70
|
-
} else {
|
|
71
|
-
process.stderr.write('[update] No packages installed.\n');
|
|
72
|
-
}
|
|
73
|
-
return 0;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// Check for updates
|
|
77
|
-
const updates: Array<{target: UpdateTarget; newVersion: string}> = [];
|
|
78
|
-
let failures = 0;
|
|
79
|
-
|
|
80
|
-
for (const target of targets) {
|
|
81
|
-
try {
|
|
82
|
-
const versions = await npmViewVersions(paths, target.npmName);
|
|
83
|
-
|
|
84
|
-
let newVersion: string | null;
|
|
85
|
-
if (options.latest) {
|
|
86
|
-
// Take the absolute latest
|
|
87
|
-
newVersion = semver.maxSatisfying(versions, '*');
|
|
88
|
-
} else {
|
|
89
|
-
// Stay within current major (^current)
|
|
90
|
-
newVersion = semver.maxSatisfying(versions, `^${target.currentVersion}`);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (!newVersion || newVersion === target.currentVersion) {
|
|
94
|
-
process.stderr.write(`[update] ${target.npmName}@${target.currentVersion} is already up to date.\n`);
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
updates.push({target, newVersion});
|
|
99
|
-
} catch (err) {
|
|
100
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
101
|
-
process.stderr.write(`[update] Failed to check ${target.npmName}: ${msg}\n`);
|
|
102
|
-
failures++;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (updates.length === 0) {
|
|
107
|
-
if (failures === 0) {
|
|
108
|
-
process.stderr.write('[update] All packages are up to date.\n');
|
|
109
|
-
}
|
|
110
|
-
return failures;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Print what will be updated
|
|
114
|
-
if (options.dryRun) {
|
|
115
|
-
process.stderr.write('[update] Dry run — the following would be updated:\n');
|
|
116
|
-
for (const {target, newVersion} of updates) {
|
|
117
|
-
process.stderr.write(` ${target.npmName}: ${target.currentVersion} → ${newVersion}\n`);
|
|
118
|
-
}
|
|
119
|
-
return 0;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Perform updates
|
|
123
|
-
for (const {target, newVersion} of updates) {
|
|
124
|
-
process.stderr.write(`[update] Updating ${target.npmName}: ${target.currentVersion} → ${newVersion}...\n`);
|
|
125
|
-
try {
|
|
126
|
-
const result = await npmInstall(paths, target.npmName, newVersion);
|
|
127
|
-
process.stderr.write(`[update] Updated ${target.npmName}@${result.version}\n`);
|
|
128
|
-
} catch (err) {
|
|
129
|
-
const msg = err instanceof Error ? err.message : String(err);
|
|
130
|
-
process.stderr.write(`[update] Failed to update ${target.npmName}: ${msg}\n`);
|
|
131
|
-
failures++;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Rebuild lock file from what's actually installed
|
|
136
|
-
const discovered = await discoverInstalledPackages(paths);
|
|
137
|
-
await buildLockFile(repoPath, discovered);
|
|
138
|
-
|
|
139
|
-
const successCount = updates.length - failures;
|
|
140
|
-
if (failures > 0) {
|
|
141
|
-
process.stderr.write(`[update] ${failures} of ${updates.length} update${updates.length === 1 ? '' : 's'} failed.\n`);
|
|
142
|
-
} else {
|
|
143
|
-
process.stderr.write(`[update] ${successCount} package${successCount === 1 ? '' : 's'} updated.\n`);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
return failures;
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export const updateCommand: CommandModule = {
|
|
150
|
-
command: 'update [name]',
|
|
151
|
-
describe: 'Update packages. Use --all for all packages, --admin-agent for the admin agent, or specify a name.',
|
|
152
|
-
builder: (yargs) =>
|
|
153
|
-
yargs
|
|
154
|
-
.positional('name', {type: 'string', describe: 'Package name to update'})
|
|
155
|
-
.option('all', {type: 'boolean', default: false, describe: 'Update all installed packages'})
|
|
156
|
-
.option('admin-agent', {type: 'boolean', default: false, describe: 'Update the global admin agent cache'})
|
|
157
|
-
.option('latest', {type: 'boolean', default: false, describe: 'Allow major version updates'})
|
|
158
|
-
.option('dry-run', {type: 'boolean', default: false, describe: 'Show what would be updated'}),
|
|
159
|
-
handler: async (argv) => {
|
|
160
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
161
|
-
const name = argv['name'] as string | undefined;
|
|
162
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
163
|
-
const all = argv['all'] as boolean;
|
|
164
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
165
|
-
const adminAgent = argv['adminAgent'] as boolean;
|
|
166
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
167
|
-
const latest = argv['latest'] as boolean;
|
|
168
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
169
|
-
const dryRun = argv['dryRun'] as boolean;
|
|
170
|
-
|
|
171
|
-
// Must specify at least one target
|
|
172
|
-
if (!name && !all && !adminAgent) {
|
|
173
|
-
process.stderr.write('Usage: amodal update <name> | --all | --admin-agent\n');
|
|
174
|
-
process.stderr.write(' <name> Update a specific package\n');
|
|
175
|
-
process.stderr.write(' --all Update all installed packages\n');
|
|
176
|
-
process.stderr.write(' --admin-agent Update the global admin agent\n');
|
|
177
|
-
process.stderr.write(' Flags can be combined: amodal update --all --admin-agent\n');
|
|
178
|
-
process.exit(1);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
let failures = 0;
|
|
182
|
-
|
|
183
|
-
// Update admin agent if requested
|
|
184
|
-
if (adminAgent) {
|
|
185
|
-
const {updateAdminAgentCommand} = await import('./admin.js');
|
|
186
|
-
failures += await updateAdminAgentCommand();
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Update packages if requested
|
|
190
|
-
if (name || all) {
|
|
191
|
-
failures += await runUpdate({name, latest, dryRun});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
process.exit(failures > 0 ? 1 : 0);
|
|
195
|
-
},
|
|
196
|
-
};
|