skild 0.3.0 → 0.3.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/dist/index.js +25 -18
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -87,9 +87,12 @@ async function install(source, options = {}) {
|
|
|
87
87
|
const auth = loadRegistryAuth();
|
|
88
88
|
const registryUrlForDeps = options.registry || auth?.registryUrl;
|
|
89
89
|
const all = Boolean(options.all);
|
|
90
|
+
const jsonOnly = Boolean(options.json);
|
|
90
91
|
const platform = options.target || "claude";
|
|
91
92
|
if (all && options.target) {
|
|
92
|
-
|
|
93
|
+
const message = "Invalid options: use either --all or --target, not both.";
|
|
94
|
+
if (jsonOnly) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
|
|
95
|
+
else console.error(chalk2.red(message));
|
|
93
96
|
process.exitCode = 1;
|
|
94
97
|
return;
|
|
95
98
|
}
|
|
@@ -98,24 +101,25 @@ async function install(source, options = {}) {
|
|
|
98
101
|
if (looksLikeAlias(resolvedSource)) {
|
|
99
102
|
const registryUrl = resolveRegistryUrl(registryUrlForDeps);
|
|
100
103
|
const resolved = await resolveRegistryAlias(registryUrl, resolvedSource);
|
|
101
|
-
if (!
|
|
104
|
+
if (!jsonOnly) logger.info(`Resolved ${chalk2.cyan(resolvedSource)} \u2192 ${chalk2.cyan(resolved.spec)} (${resolved.type})`);
|
|
102
105
|
resolvedSource = resolved.spec;
|
|
103
106
|
}
|
|
104
107
|
} catch (error) {
|
|
105
108
|
const message = error instanceof SkildError ? error.message : error instanceof Error ? error.message : String(error);
|
|
106
|
-
console.
|
|
109
|
+
if (jsonOnly) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
|
|
110
|
+
else console.error(chalk2.red(message));
|
|
107
111
|
process.exitCode = 1;
|
|
108
112
|
return;
|
|
109
113
|
}
|
|
110
114
|
const targets = all ? [...PLATFORMS] : [platform];
|
|
111
115
|
const results = [];
|
|
112
116
|
const errors = [];
|
|
113
|
-
const spinner = createSpinner(
|
|
114
|
-
all ? `Installing ${chalk2.cyan(source)} to ${chalk2.dim("all platforms")} (${scope})...` : `Installing ${chalk2.cyan(source)} to ${chalk2.dim(platform)} (${scope})...`
|
|
115
|
-
);
|
|
116
117
|
try {
|
|
118
|
+
const spinner = jsonOnly ? null : createSpinner(
|
|
119
|
+
all ? `Installing ${chalk2.cyan(source)} to ${chalk2.dim("all platforms")} (${scope})...` : `Installing ${chalk2.cyan(source)} to ${chalk2.dim(platform)} (${scope})...`
|
|
120
|
+
);
|
|
117
121
|
for (const targetPlatform of targets) {
|
|
118
|
-
spinner.text = `Installing ${chalk2.cyan(source)} to ${chalk2.dim(targetPlatform)} (${scope})...`;
|
|
122
|
+
if (spinner) spinner.text = `Installing ${chalk2.cyan(source)} to ${chalk2.dim(targetPlatform)} (${scope})...`;
|
|
119
123
|
try {
|
|
120
124
|
const record = resolvedSource.startsWith("@") && resolvedSource.includes("/") ? await installRegistrySkill(
|
|
121
125
|
{ spec: resolvedSource, registryUrl: registryUrlForDeps },
|
|
@@ -131,6 +135,16 @@ async function install(source, options = {}) {
|
|
|
131
135
|
errors.push({ platform: targetPlatform, error: message });
|
|
132
136
|
}
|
|
133
137
|
}
|
|
138
|
+
if (jsonOnly) {
|
|
139
|
+
if (!all) {
|
|
140
|
+
if (errors.length) console.log(JSON.stringify({ ok: false, error: errors[0]?.error || "Install failed." }, null, 2));
|
|
141
|
+
else console.log(JSON.stringify(results[0] ?? null, null, 2));
|
|
142
|
+
} else {
|
|
143
|
+
console.log(JSON.stringify({ ok: errors.length === 0, source, resolvedSource, scope, results, errors }, null, 2));
|
|
144
|
+
}
|
|
145
|
+
process.exitCode = errors.length ? 1 : 0;
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
134
148
|
if (errors.length === 0) {
|
|
135
149
|
const displayName = results[0]?.canonicalName || results[0]?.name || source;
|
|
136
150
|
spinner.succeed(
|
|
@@ -138,15 +152,8 @@ async function install(source, options = {}) {
|
|
|
138
152
|
);
|
|
139
153
|
} else {
|
|
140
154
|
spinner.fail(`Failed to install ${chalk2.red(source)} to ${errors.length}/${targets.length} platforms`);
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
if (!all) {
|
|
144
|
-
console.log(JSON.stringify(results[0] ?? null, null, 2));
|
|
145
|
-
} else {
|
|
146
|
-
console.log(JSON.stringify({ ok: errors.length === 0, source, resolvedSource, scope, results, errors }, null, 2));
|
|
147
|
-
}
|
|
148
|
-
process.exitCode = errors.length ? 1 : 0;
|
|
149
|
-
return;
|
|
155
|
+
process.exitCode = 1;
|
|
156
|
+
if (!all && errors[0]) console.error(chalk2.red(errors[0].error));
|
|
150
157
|
}
|
|
151
158
|
if (!all && results[0]) {
|
|
152
159
|
const record = results[0];
|
|
@@ -170,9 +177,9 @@ async function install(source, options = {}) {
|
|
|
170
177
|
process.exitCode = errors.length ? 1 : 0;
|
|
171
178
|
}
|
|
172
179
|
} catch (error) {
|
|
173
|
-
spinner.fail(`Failed to install ${chalk2.red(source)}`);
|
|
174
180
|
const message = error instanceof SkildError ? error.message : error instanceof Error ? error.message : String(error);
|
|
175
|
-
console.
|
|
181
|
+
if (jsonOnly) console.log(JSON.stringify({ ok: false, error: message }, null, 2));
|
|
182
|
+
else console.error(chalk2.red(message));
|
|
176
183
|
process.exitCode = 1;
|
|
177
184
|
}
|
|
178
185
|
}
|