@vocoder/cli 0.11.0 → 0.12.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/README.md +137 -1
- package/dist/bin.mjs +485 -144
- package/dist/bin.mjs.map +1 -1
- package/dist/{chunk-XF3KGGYQ.mjs → chunk-XUCVAFBG.mjs} +59 -1
- package/dist/{chunk-XF3KGGYQ.mjs.map → chunk-XUCVAFBG.mjs.map} +1 -1
- package/dist/lib.d.mts +50 -2
- 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}` }
|
|
@@ -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-XUCVAFBG.mjs.map
|