@vocoder/cli 0.11.0 → 0.12.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.
- package/README.md +140 -4
- package/dist/bin.mjs +519 -207
- package/dist/bin.mjs.map +1 -1
- package/dist/{chunk-XF3KGGYQ.mjs → chunk-SR6SDGUI.mjs} +62 -4
- package/dist/{chunk-XF3KGGYQ.mjs.map → chunk-SR6SDGUI.mjs.map} +1 -1
- package/dist/lib.d.mts +57 -8
- package/dist/lib.mjs +3 -1
- package/dist/lib.mjs.map +1 -1
- package/package.json +3 -3
|
@@ -44132,6 +44132,49 @@ var VocoderAPI = class {
|
|
|
44132
44132
|
return payload;
|
|
44133
44133
|
}
|
|
44134
44134
|
// ── Locales ───────────────────────────────────────────────────────────────────
|
|
44135
|
+
/**
|
|
44136
|
+
* Add a target locale to the project.
|
|
44137
|
+
* Idempotent: returns the current list unchanged if the locale is already configured.
|
|
44138
|
+
* Project determined from API key.
|
|
44139
|
+
*
|
|
44140
|
+
* @throws {VocoderAPIError} status 422 for invalid/unsupported locale code
|
|
44141
|
+
* @throws {VocoderAPIError} status 403 with limitError.limitType "target_locales" when plan limit reached
|
|
44142
|
+
*/
|
|
44143
|
+
async addLocale(locale, repoCanonical) {
|
|
44144
|
+
return this.request(
|
|
44145
|
+
"/api/cli/project/locales",
|
|
44146
|
+
{
|
|
44147
|
+
method: "POST",
|
|
44148
|
+
headers: { "Content-Type": "application/json" },
|
|
44149
|
+
body: JSON.stringify({
|
|
44150
|
+
locale,
|
|
44151
|
+
...repoCanonical ? { repoCanonical } : {}
|
|
44152
|
+
})
|
|
44153
|
+
},
|
|
44154
|
+
"Failed to add locale"
|
|
44155
|
+
);
|
|
44156
|
+
}
|
|
44157
|
+
/**
|
|
44158
|
+
* Remove a target locale from the project.
|
|
44159
|
+
* Idempotent: returns the current list unchanged if the locale is not configured.
|
|
44160
|
+
* Project determined from API key.
|
|
44161
|
+
*
|
|
44162
|
+
* @throws {VocoderAPIError} on auth or server errors
|
|
44163
|
+
*/
|
|
44164
|
+
async removeLocale(locale, repoCanonical) {
|
|
44165
|
+
return this.request(
|
|
44166
|
+
"/api/cli/project/locales",
|
|
44167
|
+
{
|
|
44168
|
+
method: "DELETE",
|
|
44169
|
+
headers: { "Content-Type": "application/json" },
|
|
44170
|
+
body: JSON.stringify({
|
|
44171
|
+
locale,
|
|
44172
|
+
...repoCanonical ? { repoCanonical } : {}
|
|
44173
|
+
})
|
|
44174
|
+
},
|
|
44175
|
+
"Failed to remove locale"
|
|
44176
|
+
);
|
|
44177
|
+
}
|
|
44135
44178
|
async listLocales(userToken) {
|
|
44136
44179
|
const response = await fetch(`${this.apiUrl}/api/cli/locales`, {
|
|
44137
44180
|
headers: { Authorization: `Bearer ${userToken}` }
|
|
@@ -44222,10 +44265,10 @@ var VocoderAPI = class {
|
|
|
44222
44265
|
}
|
|
44223
44266
|
}
|
|
44224
44267
|
/**
|
|
44225
|
-
* Add a new
|
|
44268
|
+
* Add a new App to an existing project (monorepo: new app directory).
|
|
44226
44269
|
* Does not check plan limits — no new project is created.
|
|
44227
44270
|
*/
|
|
44228
|
-
async
|
|
44271
|
+
async createApp(userToken, params) {
|
|
44229
44272
|
const response = await fetch(`${this.apiUrl}/api/cli/project/apps`, {
|
|
44230
44273
|
method: "POST",
|
|
44231
44274
|
headers: {
|
|
@@ -44239,7 +44282,7 @@ var VocoderAPI = class {
|
|
|
44239
44282
|
throw new VocoderAPIError({
|
|
44240
44283
|
message: extractErrorMessage(
|
|
44241
44284
|
payload,
|
|
44242
|
-
`Failed to create
|
|
44285
|
+
`Failed to create app (${response.status})`
|
|
44243
44286
|
),
|
|
44244
44287
|
status: response.status,
|
|
44245
44288
|
payload
|
|
@@ -44394,6 +44437,20 @@ function writeAuthData(data) {
|
|
|
44394
44437
|
mkdirSync(dir, { recursive: true, mode: 448 });
|
|
44395
44438
|
writeFileSync(filePath, JSON.stringify(data, null, 2), { mode: 384 });
|
|
44396
44439
|
}
|
|
44440
|
+
async function verifyStoredAuth(api) {
|
|
44441
|
+
const stored = readAuthData();
|
|
44442
|
+
if (!stored) return { status: "none" };
|
|
44443
|
+
try {
|
|
44444
|
+
const userInfo = await api.getCliUserInfo(stored.token);
|
|
44445
|
+
return { status: "valid", token: stored.token, ...userInfo };
|
|
44446
|
+
} catch (err) {
|
|
44447
|
+
clearAuthData();
|
|
44448
|
+
if (err instanceof VocoderAPIError && err.status === 404) {
|
|
44449
|
+
return { status: "gone" };
|
|
44450
|
+
}
|
|
44451
|
+
return { status: "expired" };
|
|
44452
|
+
}
|
|
44453
|
+
}
|
|
44397
44454
|
function clearAuthData() {
|
|
44398
44455
|
const filePath = getAuthFilePath();
|
|
44399
44456
|
try {
|
|
@@ -51437,9 +51494,10 @@ export {
|
|
|
51437
51494
|
getPackagesToInstall,
|
|
51438
51495
|
readAuthData,
|
|
51439
51496
|
writeAuthData,
|
|
51497
|
+
verifyStoredAuth,
|
|
51440
51498
|
clearAuthData,
|
|
51441
51499
|
getSetupSnippets,
|
|
51442
51500
|
loadVocoderConfig,
|
|
51443
51501
|
StringExtractor
|
|
51444
51502
|
};
|
|
51445
|
-
//# sourceMappingURL=chunk-
|
|
51503
|
+
//# sourceMappingURL=chunk-SR6SDGUI.mjs.map
|