@vocoder/cli 0.1.4 → 0.1.7
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 +173 -45
- package/dist/bin.mjs +1803 -1679
- package/dist/bin.mjs.map +1 -1
- package/dist/chunk-OC5N5C5X.mjs +546 -0
- package/dist/chunk-OC5N5C5X.mjs.map +1 -0
- package/dist/lib.d.mts +175 -0
- package/dist/lib.mjs +15 -0
- package/dist/lib.mjs.map +1 -0
- package/package.json +8 -2
package/dist/lib.d.mts
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
type EffectiveSyncMode = 'required' | 'best-effort';
|
|
2
|
+
interface SyncPolicyConfig {
|
|
3
|
+
blockingBranches: string[];
|
|
4
|
+
blockingMode: EffectiveSyncMode;
|
|
5
|
+
nonBlockingMode: EffectiveSyncMode;
|
|
6
|
+
defaultMaxWaitMs: number;
|
|
7
|
+
}
|
|
8
|
+
interface APIProjectConfig {
|
|
9
|
+
projectName: string;
|
|
10
|
+
organizationName: string;
|
|
11
|
+
sourceLocale: string;
|
|
12
|
+
targetLocales: string[];
|
|
13
|
+
targetBranches: string[];
|
|
14
|
+
syncPolicy: SyncPolicyConfig;
|
|
15
|
+
}
|
|
16
|
+
interface ExtractedString {
|
|
17
|
+
key: string;
|
|
18
|
+
text: string;
|
|
19
|
+
file: string;
|
|
20
|
+
line: number;
|
|
21
|
+
context?: string;
|
|
22
|
+
formality?: 'formal' | 'informal' | 'neutral' | 'auto';
|
|
23
|
+
}
|
|
24
|
+
interface TranslationBatchResponse {
|
|
25
|
+
batchId: string;
|
|
26
|
+
newStrings: number;
|
|
27
|
+
deletedStrings?: number;
|
|
28
|
+
totalStrings: number;
|
|
29
|
+
status: 'PENDING' | 'TRANSLATING' | 'COMPLETED' | 'FAILED' | 'UP_TO_DATE';
|
|
30
|
+
noChanges?: boolean;
|
|
31
|
+
estimatedTime?: number;
|
|
32
|
+
effectiveMode?: EffectiveSyncMode;
|
|
33
|
+
queueStatus?: 'QUEUED' | 'PROCESSING' | 'COMPLETED' | 'FAILED';
|
|
34
|
+
snapshotAvailable?: boolean;
|
|
35
|
+
latestCompletedBatchId?: string;
|
|
36
|
+
translations?: Record<string, Record<string, string>>;
|
|
37
|
+
}
|
|
38
|
+
interface TranslationStatusResponse {
|
|
39
|
+
status: 'PENDING' | 'TRANSLATING' | 'COMPLETED' | 'FAILED';
|
|
40
|
+
progress: number;
|
|
41
|
+
jobs?: Array<{
|
|
42
|
+
locale: string;
|
|
43
|
+
status: string;
|
|
44
|
+
progress: number;
|
|
45
|
+
}>;
|
|
46
|
+
translations?: Record<string, Record<string, string>>;
|
|
47
|
+
localeMetadata?: Record<string, {
|
|
48
|
+
nativeName: string;
|
|
49
|
+
dir?: 'rtl';
|
|
50
|
+
}>;
|
|
51
|
+
errorMessage?: string;
|
|
52
|
+
}
|
|
53
|
+
interface TranslationSnapshotResponse {
|
|
54
|
+
status: 'FOUND' | 'NOT_FOUND';
|
|
55
|
+
branch: string;
|
|
56
|
+
sourceLocale?: string;
|
|
57
|
+
targetLocales?: string[];
|
|
58
|
+
snapshotBatchId?: string;
|
|
59
|
+
completedAt?: string | null;
|
|
60
|
+
translations?: Record<string, Record<string, string>>;
|
|
61
|
+
localeMetadata?: Record<string, {
|
|
62
|
+
nativeName: string;
|
|
63
|
+
dir?: 'rtl';
|
|
64
|
+
}>;
|
|
65
|
+
}
|
|
66
|
+
interface LimitErrorResponse {
|
|
67
|
+
errorCode: 'LIMIT_EXCEEDED' | 'INSUFFICIENT_CREDITS';
|
|
68
|
+
limitType: 'organizations' | 'projects' | 'git_connections' | 'members' | 'providers' | 'translation_chars' | 'source_strings' | 'credits';
|
|
69
|
+
planId: string;
|
|
70
|
+
current: number;
|
|
71
|
+
required: number;
|
|
72
|
+
upgradeUrl: string;
|
|
73
|
+
message: string;
|
|
74
|
+
}
|
|
75
|
+
interface SyncPolicyErrorResponse {
|
|
76
|
+
errorCode: 'BRANCH_NOT_ALLOWED' | 'PROJECT_REPOSITORY_MISMATCH';
|
|
77
|
+
message: string;
|
|
78
|
+
branch?: string;
|
|
79
|
+
targetBranches?: string[];
|
|
80
|
+
boundRepoLabel?: string | null;
|
|
81
|
+
boundScopePath?: string | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Extract translatable strings from source files
|
|
86
|
+
*
|
|
87
|
+
* NOTE: This is a simplified version for the CLI MVP.
|
|
88
|
+
* Eventually this logic should be moved to a shared @vocoder/extraction package
|
|
89
|
+
* that can be used by both the CLI and the backend.
|
|
90
|
+
*/
|
|
91
|
+
declare class StringExtractor {
|
|
92
|
+
/**
|
|
93
|
+
* Extract strings from all files matching the pattern(s)
|
|
94
|
+
*
|
|
95
|
+
* @param pattern - Glob pattern(s) to include
|
|
96
|
+
* @param projectRoot - Project root directory
|
|
97
|
+
* @param excludePattern - Glob pattern(s) to exclude (optional)
|
|
98
|
+
*/
|
|
99
|
+
extractFromProject(pattern: string | string[], projectRoot?: string, excludePattern?: string | string[]): Promise<ExtractedString[]>;
|
|
100
|
+
/**
|
|
101
|
+
* Extract strings from a single file
|
|
102
|
+
*/
|
|
103
|
+
private extractFromFile;
|
|
104
|
+
/**
|
|
105
|
+
* Extract text from template literal
|
|
106
|
+
* Converts template literals like `Hello ${name}` to `Hello {name}`
|
|
107
|
+
*/
|
|
108
|
+
private extractTemplateText;
|
|
109
|
+
/**
|
|
110
|
+
* Extract text content from JSX children
|
|
111
|
+
*/
|
|
112
|
+
private extractTextContent;
|
|
113
|
+
/**
|
|
114
|
+
* Get string value from JSX attribute
|
|
115
|
+
* Handles both string literals and template literals
|
|
116
|
+
*/
|
|
117
|
+
private getStringAttribute;
|
|
118
|
+
/**
|
|
119
|
+
* Deduplicate strings (keep first occurrence)
|
|
120
|
+
*/
|
|
121
|
+
private deduplicateStrings;
|
|
122
|
+
private generateStableKey;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun';
|
|
126
|
+
type DetectedFramework = 'nextjs' | 'vite' | 'remix' | 'nuxt' | 'sveltekit' | 'gatsby' | 'angular' | null;
|
|
127
|
+
type DetectedEcosystem = 'react' | 'vue' | 'svelte' | 'angular' | null;
|
|
128
|
+
interface LocalDetectionResult {
|
|
129
|
+
ecosystem: DetectedEcosystem;
|
|
130
|
+
framework: DetectedFramework;
|
|
131
|
+
packageManager: PackageManager;
|
|
132
|
+
uiPackage: string | null;
|
|
133
|
+
hasUnplugin: boolean;
|
|
134
|
+
hasUiPackage: boolean;
|
|
135
|
+
sourceLocale: string | null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Detect the local project's ecosystem, framework, and package manager
|
|
139
|
+
* by inspecting filesystem artifacts. No network calls.
|
|
140
|
+
*/
|
|
141
|
+
declare function detectLocalEcosystem(cwd?: string): LocalDetectionResult;
|
|
142
|
+
/**
|
|
143
|
+
* Build the install command for packages that aren't already installed.
|
|
144
|
+
*/
|
|
145
|
+
declare function buildInstallCommand(packageManager: PackageManager, packages: string[]): string;
|
|
146
|
+
/**
|
|
147
|
+
* Get the list of packages that need to be installed.
|
|
148
|
+
*/
|
|
149
|
+
declare function getPackagesToInstall(detection: LocalDetectionResult): string[];
|
|
150
|
+
|
|
151
|
+
interface SetupSnippets {
|
|
152
|
+
pluginStep: {
|
|
153
|
+
file: string;
|
|
154
|
+
code: string;
|
|
155
|
+
} | null;
|
|
156
|
+
providerStep: {
|
|
157
|
+
file: string;
|
|
158
|
+
code: string;
|
|
159
|
+
} | null;
|
|
160
|
+
wrapStep: {
|
|
161
|
+
code: string;
|
|
162
|
+
};
|
|
163
|
+
whatsNext: string;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Generate framework-specific setup snippets.
|
|
167
|
+
*/
|
|
168
|
+
declare function getSetupSnippets(params: {
|
|
169
|
+
framework: DetectedFramework;
|
|
170
|
+
ecosystem: DetectedEcosystem;
|
|
171
|
+
sourceLocale: string;
|
|
172
|
+
translationTriggers: string[];
|
|
173
|
+
}): SetupSnippets;
|
|
174
|
+
|
|
175
|
+
export { type APIProjectConfig, type DetectedEcosystem, type DetectedFramework, type ExtractedString, type LimitErrorResponse, type LocalDetectionResult, type PackageManager, type SetupSnippets, StringExtractor, type SyncPolicyConfig, type SyncPolicyErrorResponse, type TranslationBatchResponse, type TranslationSnapshotResponse, type TranslationStatusResponse, buildInstallCommand, detectLocalEcosystem, getPackagesToInstall, getSetupSnippets };
|
package/dist/lib.mjs
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
StringExtractor,
|
|
3
|
+
buildInstallCommand,
|
|
4
|
+
detectLocalEcosystem,
|
|
5
|
+
getPackagesToInstall,
|
|
6
|
+
getSetupSnippets
|
|
7
|
+
} from "./chunk-OC5N5C5X.mjs";
|
|
8
|
+
export {
|
|
9
|
+
StringExtractor,
|
|
10
|
+
buildInstallCommand,
|
|
11
|
+
detectLocalEcosystem,
|
|
12
|
+
getPackagesToInstall,
|
|
13
|
+
getSetupSnippets
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=lib.mjs.map
|
package/dist/lib.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vocoder/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "CLI tool for Vocoder translation workflow",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
"bin": {
|
|
9
9
|
"vocoder": "dist/bin.mjs"
|
|
10
10
|
},
|
|
11
|
+
"exports": {
|
|
12
|
+
"./lib": {
|
|
13
|
+
"types": "./dist/lib.d.ts",
|
|
14
|
+
"import": "./dist/lib.mjs"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
11
17
|
"publishConfig": {
|
|
12
18
|
"access": "public"
|
|
13
19
|
},
|
|
@@ -47,12 +53,12 @@
|
|
|
47
53
|
"@babel/parser": "^7.26.0",
|
|
48
54
|
"@babel/traverse": "^7.26.0",
|
|
49
55
|
"@babel/types": "^7.26.0",
|
|
56
|
+
"@clack/core": "0.4.1",
|
|
50
57
|
"@clack/prompts": "^0.9.1",
|
|
51
58
|
"chalk": "^5.3.0",
|
|
52
59
|
"commander": "^11.1.0",
|
|
53
60
|
"dotenv": "^16.3.1",
|
|
54
61
|
"glob": "^10.3.10",
|
|
55
|
-
"recast": "^0.23.11",
|
|
56
62
|
"tsx": "^4.7.0"
|
|
57
63
|
},
|
|
58
64
|
"devDependencies": {
|