@saykit/config 0.0.0 → 0.2.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 +44 -0
- package/dist/commands/index.cjs +252 -0
- package/dist/commands/index.d.cts +1 -0
- package/dist/commands/index.d.mts +1 -0
- package/dist/commands/index.mjs +252 -0
- package/dist/features/loader/index.cjs +3 -0
- package/dist/features/loader/index.d.cts +6 -0
- package/dist/features/loader/index.d.mts +6 -0
- package/dist/features/loader/index.mjs +2 -0
- package/dist/features/messages/index.cjs +101 -0
- package/dist/features/messages/index.d.cts +63 -0
- package/dist/features/messages/index.d.mts +63 -0
- package/dist/features/messages/index.mjs +92 -0
- package/dist/hash-CDfMT76E.cjs +17 -0
- package/dist/hash-Cs0dRdGf.mjs +11 -0
- package/dist/index.cjs +77 -0
- package/dist/index.d.cts +38 -0
- package/dist/index.d.mts +38 -0
- package/dist/index.mjs +51 -0
- package/dist/loader-CGuahnrc.mjs +115 -0
- package/dist/loader-DnWt_9U2.cjs +121 -0
- package/dist/shapes-CJyTfZXd.d.cts +236 -0
- package/dist/shapes-DETrtvZf.d.mts +236 -0
- package/package.json +86 -3
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
require("./index.cjs");
|
|
2
|
+
let node_path = require("node:path");
|
|
3
|
+
let node_fs = require("node:fs");
|
|
4
|
+
let node_crypto = require("node:crypto");
|
|
5
|
+
let node_module = require("node:module");
|
|
6
|
+
let node_os = require("node:os");
|
|
7
|
+
//#region src/features/loader/files.ts
|
|
8
|
+
const SUPPORTED_CONFIG_FILES = [
|
|
9
|
+
"saykit.config.js",
|
|
10
|
+
"saykit.config.cjs",
|
|
11
|
+
"saykit.config.mjs",
|
|
12
|
+
"saykit.config.ts",
|
|
13
|
+
"saykit.config.mts",
|
|
14
|
+
"saykit.config.cts"
|
|
15
|
+
];
|
|
16
|
+
function getConfigFileCandidates(name) {
|
|
17
|
+
return SUPPORTED_CONFIG_FILES.map((file) => file.replace("saykit", name));
|
|
18
|
+
}
|
|
19
|
+
function findConfigFile(moduleName, projectDir) {
|
|
20
|
+
for (const fileName of getConfigFileCandidates(moduleName)) {
|
|
21
|
+
const id = (0, node_path.join)(projectDir, fileName);
|
|
22
|
+
if ((0, node_fs.existsSync)(id)) return { id };
|
|
23
|
+
}
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
//#region src/features/loader/module.ts
|
|
28
|
+
function findNearestTsConfig(fromPath) {
|
|
29
|
+
let dir = (0, node_path.dirname)(fromPath);
|
|
30
|
+
const { root } = (0, node_path.parse)(dir);
|
|
31
|
+
while (true) {
|
|
32
|
+
const candidate = (0, node_path.join)(dir, "tsconfig.json");
|
|
33
|
+
if ((0, node_fs.existsSync)(candidate)) return candidate;
|
|
34
|
+
if (dir === root) return null;
|
|
35
|
+
dir = (0, node_path.dirname)(dir);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function findCacheDir(fromPath) {
|
|
39
|
+
let dir = (0, node_path.dirname)(fromPath);
|
|
40
|
+
const { root } = (0, node_path.parse)(dir);
|
|
41
|
+
while (true) {
|
|
42
|
+
const nm = (0, node_path.join)(dir, "node_modules");
|
|
43
|
+
if ((0, node_fs.existsSync)(nm)) return (0, node_path.join)(nm, ".cache", "saykit", "config");
|
|
44
|
+
if (dir === root) return (0, node_path.join)((0, node_os.tmpdir)(), "saykit", "config");
|
|
45
|
+
dir = (0, node_path.dirname)(dir);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function transpile(path, tsConfigPath, require) {
|
|
49
|
+
const ts = require("typescript");
|
|
50
|
+
const { config: tsConfig, error } = tsConfigPath ? ts.readConfigFile(tsConfigPath, ts.sys.readFile) : {
|
|
51
|
+
config: {},
|
|
52
|
+
error: null
|
|
53
|
+
};
|
|
54
|
+
if (error) throw error;
|
|
55
|
+
tsConfig.compilerOptions = {
|
|
56
|
+
...tsConfig.compilerOptions,
|
|
57
|
+
allowJs: true,
|
|
58
|
+
esModuleInterop: true,
|
|
59
|
+
module: ts.ModuleKind.CommonJS,
|
|
60
|
+
moduleResolution: ts.ModuleResolutionKind.NodeJs,
|
|
61
|
+
target: ts.ScriptTarget.ES2022,
|
|
62
|
+
noEmit: false
|
|
63
|
+
};
|
|
64
|
+
return ts.transpileModule((0, node_fs.readFileSync)(path, "utf8"), tsConfig).outputText;
|
|
65
|
+
}
|
|
66
|
+
function loadWithCache(path) {
|
|
67
|
+
const require = (0, node_module.createRequire)(path);
|
|
68
|
+
const mtimeMs = (0, node_fs.statSync)(path).mtimeMs;
|
|
69
|
+
const tsConfigPath = findNearestTsConfig(path);
|
|
70
|
+
const tsConfigMtimeMs = tsConfigPath ? (0, node_fs.statSync)(tsConfigPath).mtimeMs : 0;
|
|
71
|
+
const hash = (0, node_crypto.createHash)("sha1").update(`${path}\0${tsConfigPath ?? ""}\0${tsConfigMtimeMs}`).digest("hex").slice(0, 16);
|
|
72
|
+
const cacheDir = findCacheDir(path);
|
|
73
|
+
const cachePath = (0, node_path.join)(cacheDir, `${hash}.${mtimeMs}.cjs`);
|
|
74
|
+
try {
|
|
75
|
+
if (!(0, node_fs.existsSync)(cachePath)) {
|
|
76
|
+
(0, node_fs.mkdirSync)(cacheDir, { recursive: true });
|
|
77
|
+
(0, node_fs.writeFileSync)(cachePath, transpile(path, tsConfigPath, require));
|
|
78
|
+
if ((0, node_fs.existsSync)(cacheDir)) {
|
|
79
|
+
for (const entry of (0, node_fs.readdirSync)(cacheDir)) if (entry.startsWith(`${hash}.`) && entry !== `${hash}.${mtimeMs}.cjs`) try {
|
|
80
|
+
(0, node_fs.unlinkSync)((0, node_path.join)(cacheDir, entry));
|
|
81
|
+
} catch {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const resolved = require.resolve(cachePath);
|
|
85
|
+
delete require.cache[resolved];
|
|
86
|
+
const module = require(cachePath);
|
|
87
|
+
delete require.cache[resolved];
|
|
88
|
+
return module?.default ?? module;
|
|
89
|
+
} catch (error) {
|
|
90
|
+
throw new Error("Failed to import module", { cause: error });
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
const js = (path) => loadWithCache(path);
|
|
94
|
+
const ts = (path) => loadWithCache(path);
|
|
95
|
+
const configLoaders = Object.freeze({
|
|
96
|
+
".js": js,
|
|
97
|
+
".mjs": js,
|
|
98
|
+
".cjs": js,
|
|
99
|
+
".ts": ts,
|
|
100
|
+
".mts": ts,
|
|
101
|
+
".cts": ts
|
|
102
|
+
});
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/features/loader/resolve.ts
|
|
105
|
+
function resolveConfig(name = "saykit") {
|
|
106
|
+
const file = findConfigFile(name, process.cwd());
|
|
107
|
+
if (!file) throw new Error(`Could not find config file for "${name}"`);
|
|
108
|
+
const ext = (0, node_path.extname)(file.id).toLowerCase();
|
|
109
|
+
const load = ext in configLoaders ? configLoaders[ext] : null;
|
|
110
|
+
if (!load) throw new Error(`Unsupported config file type "${ext}" for "${name}"`);
|
|
111
|
+
const config = load(file.id);
|
|
112
|
+
if (!config || typeof config !== "object") throw new Error(`Invalid config file for "${name}"`);
|
|
113
|
+
return config;
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
Object.defineProperty(exports, "resolveConfig", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function() {
|
|
119
|
+
return resolveConfig;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import picomatch from "picomatch";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/shapes.d.ts
|
|
5
|
+
declare const Message: z.ZodObject<{
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
translation: z.ZodOptional<z.ZodString>;
|
|
8
|
+
id: z.ZodOptional<z.ZodString>;
|
|
9
|
+
context: z.ZodOptional<z.ZodString>;
|
|
10
|
+
comments: z.ZodArray<z.ZodString>;
|
|
11
|
+
references: z.ZodArray<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
type Message = z.infer<typeof Message>;
|
|
14
|
+
declare const Formatter: z.ZodObject<{
|
|
15
|
+
extension: z.ZodTemplateLiteral<`.${string}`>;
|
|
16
|
+
parse: z.ZodCustom<(content: string) => Message[], (content: string) => Message[]>;
|
|
17
|
+
stringify: z.ZodCustom<(messages: Message[], context: {
|
|
18
|
+
locale: string;
|
|
19
|
+
existingContent?: string;
|
|
20
|
+
}) => string, (messages: Message[], context: {
|
|
21
|
+
locale: string;
|
|
22
|
+
existingContent?: string;
|
|
23
|
+
}) => string>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
type Formatter = z.infer<typeof Formatter>;
|
|
26
|
+
declare const Transformer: z.ZodObject<{
|
|
27
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
28
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
29
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
type Transformer = z.infer<typeof Transformer>;
|
|
32
|
+
declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
33
|
+
include: z.ZodArray<z.ZodString>;
|
|
34
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
output: z.ZodTemplateLiteral<`${string}{locale}${string}.{extension}`>;
|
|
36
|
+
formatter: z.ZodObject<{
|
|
37
|
+
extension: z.ZodTemplateLiteral<`.${string}`>;
|
|
38
|
+
parse: z.ZodCustom<(content: string) => Message[], (content: string) => Message[]>;
|
|
39
|
+
stringify: z.ZodCustom<(messages: Message[], context: {
|
|
40
|
+
locale: string;
|
|
41
|
+
existingContent?: string;
|
|
42
|
+
}) => string, (messages: Message[], context: {
|
|
43
|
+
locale: string;
|
|
44
|
+
existingContent?: string;
|
|
45
|
+
}) => string>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
transformer: z.ZodPipe<z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
48
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
49
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
50
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
51
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
52
|
+
match: (id: string) => boolean;
|
|
53
|
+
extract: (code: string, id: string) => Message[];
|
|
54
|
+
transform: (code: string, id: string) => string;
|
|
55
|
+
}[], {
|
|
56
|
+
match: (id: string) => boolean;
|
|
57
|
+
extract: (code: string, id: string) => Message[];
|
|
58
|
+
transform: (code: string, id: string) => string;
|
|
59
|
+
}>>, z.ZodArray<z.ZodObject<{
|
|
60
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
61
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
62
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
63
|
+
}, z.core.$strip>>]>, z.ZodTransform<{
|
|
64
|
+
match: (id: string) => boolean;
|
|
65
|
+
extract: (code: string, id: string) => {
|
|
66
|
+
message: string;
|
|
67
|
+
comments: string[];
|
|
68
|
+
references: string[];
|
|
69
|
+
translation?: string | undefined;
|
|
70
|
+
id?: string | undefined;
|
|
71
|
+
context?: string | undefined;
|
|
72
|
+
}[];
|
|
73
|
+
transform: (code: string, id: string) => string;
|
|
74
|
+
}, {
|
|
75
|
+
match: (id: string) => boolean;
|
|
76
|
+
extract: (code: string, id: string) => Message[];
|
|
77
|
+
transform: (code: string, id: string) => string;
|
|
78
|
+
}[]>>;
|
|
79
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
80
|
+
match: (id: string) => boolean;
|
|
81
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
82
|
+
match: picomatch.Matcher;
|
|
83
|
+
};
|
|
84
|
+
include: string[];
|
|
85
|
+
formatter: {
|
|
86
|
+
extension: `.${string}`;
|
|
87
|
+
parse: (content: string) => Message[];
|
|
88
|
+
stringify: (messages: Message[], context: {
|
|
89
|
+
locale: string;
|
|
90
|
+
existingContent?: string;
|
|
91
|
+
}) => string;
|
|
92
|
+
};
|
|
93
|
+
transformer: {
|
|
94
|
+
match: (id: string) => boolean;
|
|
95
|
+
extract: (code: string, id: string) => {
|
|
96
|
+
message: string;
|
|
97
|
+
comments: string[];
|
|
98
|
+
references: string[];
|
|
99
|
+
translation?: string | undefined;
|
|
100
|
+
id?: string | undefined;
|
|
101
|
+
context?: string | undefined;
|
|
102
|
+
}[];
|
|
103
|
+
transform: (code: string, id: string) => string;
|
|
104
|
+
};
|
|
105
|
+
exclude?: string[] | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
include: string[];
|
|
108
|
+
output: `${string}{locale}${string}.{extension}`;
|
|
109
|
+
formatter: {
|
|
110
|
+
extension: `.${string}`;
|
|
111
|
+
parse: (content: string) => Message[];
|
|
112
|
+
stringify: (messages: Message[], context: {
|
|
113
|
+
locale: string;
|
|
114
|
+
existingContent?: string;
|
|
115
|
+
}) => string;
|
|
116
|
+
};
|
|
117
|
+
transformer: {
|
|
118
|
+
match: (id: string) => boolean;
|
|
119
|
+
extract: (code: string, id: string) => {
|
|
120
|
+
message: string;
|
|
121
|
+
comments: string[];
|
|
122
|
+
references: string[];
|
|
123
|
+
translation?: string | undefined;
|
|
124
|
+
id?: string | undefined;
|
|
125
|
+
context?: string | undefined;
|
|
126
|
+
}[];
|
|
127
|
+
transform: (code: string, id: string) => string;
|
|
128
|
+
};
|
|
129
|
+
exclude?: string[] | undefined;
|
|
130
|
+
}>>;
|
|
131
|
+
type Bucket = z.infer<typeof Bucket>;
|
|
132
|
+
declare const Config: z.ZodObject<{
|
|
133
|
+
locales: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
134
|
+
buckets: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
135
|
+
include: z.ZodArray<z.ZodString>;
|
|
136
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
137
|
+
output: z.ZodTemplateLiteral<`${string}{locale}${string}.{extension}`>;
|
|
138
|
+
formatter: z.ZodObject<{
|
|
139
|
+
extension: z.ZodTemplateLiteral<`.${string}`>;
|
|
140
|
+
parse: z.ZodCustom<(content: string) => Message[], (content: string) => Message[]>;
|
|
141
|
+
stringify: z.ZodCustom<(messages: Message[], context: {
|
|
142
|
+
locale: string;
|
|
143
|
+
existingContent?: string;
|
|
144
|
+
}) => string, (messages: Message[], context: {
|
|
145
|
+
locale: string;
|
|
146
|
+
existingContent?: string;
|
|
147
|
+
}) => string>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
transformer: z.ZodPipe<z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
150
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
151
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
152
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
153
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
154
|
+
match: (id: string) => boolean;
|
|
155
|
+
extract: (code: string, id: string) => Message[];
|
|
156
|
+
transform: (code: string, id: string) => string;
|
|
157
|
+
}[], {
|
|
158
|
+
match: (id: string) => boolean;
|
|
159
|
+
extract: (code: string, id: string) => Message[];
|
|
160
|
+
transform: (code: string, id: string) => string;
|
|
161
|
+
}>>, z.ZodArray<z.ZodObject<{
|
|
162
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
163
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
164
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
165
|
+
}, z.core.$strip>>]>, z.ZodTransform<{
|
|
166
|
+
match: (id: string) => boolean;
|
|
167
|
+
extract: (code: string, id: string) => {
|
|
168
|
+
message: string;
|
|
169
|
+
comments: string[];
|
|
170
|
+
references: string[];
|
|
171
|
+
translation?: string | undefined;
|
|
172
|
+
id?: string | undefined;
|
|
173
|
+
context?: string | undefined;
|
|
174
|
+
}[];
|
|
175
|
+
transform: (code: string, id: string) => string;
|
|
176
|
+
}, {
|
|
177
|
+
match: (id: string) => boolean;
|
|
178
|
+
extract: (code: string, id: string) => Message[];
|
|
179
|
+
transform: (code: string, id: string) => string;
|
|
180
|
+
}[]>>;
|
|
181
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
182
|
+
match: (id: string) => boolean;
|
|
183
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
184
|
+
match: picomatch.Matcher;
|
|
185
|
+
};
|
|
186
|
+
include: string[];
|
|
187
|
+
formatter: {
|
|
188
|
+
extension: `.${string}`;
|
|
189
|
+
parse: (content: string) => Message[];
|
|
190
|
+
stringify: (messages: Message[], context: {
|
|
191
|
+
locale: string;
|
|
192
|
+
existingContent?: string;
|
|
193
|
+
}) => string;
|
|
194
|
+
};
|
|
195
|
+
transformer: {
|
|
196
|
+
match: (id: string) => boolean;
|
|
197
|
+
extract: (code: string, id: string) => {
|
|
198
|
+
message: string;
|
|
199
|
+
comments: string[];
|
|
200
|
+
references: string[];
|
|
201
|
+
translation?: string | undefined;
|
|
202
|
+
id?: string | undefined;
|
|
203
|
+
context?: string | undefined;
|
|
204
|
+
}[];
|
|
205
|
+
transform: (code: string, id: string) => string;
|
|
206
|
+
};
|
|
207
|
+
exclude?: string[] | undefined;
|
|
208
|
+
}, {
|
|
209
|
+
include: string[];
|
|
210
|
+
output: `${string}{locale}${string}.{extension}`;
|
|
211
|
+
formatter: {
|
|
212
|
+
extension: `.${string}`;
|
|
213
|
+
parse: (content: string) => Message[];
|
|
214
|
+
stringify: (messages: Message[], context: {
|
|
215
|
+
locale: string;
|
|
216
|
+
existingContent?: string;
|
|
217
|
+
}) => string;
|
|
218
|
+
};
|
|
219
|
+
transformer: {
|
|
220
|
+
match: (id: string) => boolean;
|
|
221
|
+
extract: (code: string, id: string) => {
|
|
222
|
+
message: string;
|
|
223
|
+
comments: string[];
|
|
224
|
+
references: string[];
|
|
225
|
+
translation?: string | undefined;
|
|
226
|
+
id?: string | undefined;
|
|
227
|
+
context?: string | undefined;
|
|
228
|
+
}[];
|
|
229
|
+
transform: (code: string, id: string) => string;
|
|
230
|
+
};
|
|
231
|
+
exclude?: string[] | undefined;
|
|
232
|
+
}>>>;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
type Config = z.infer<typeof Config>;
|
|
235
|
+
//#endregion
|
|
236
|
+
export { Transformer as a, Message as i, Config as n, Formatter as r, Bucket as t };
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import picomatch from "picomatch";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
|
|
4
|
+
//#region src/shapes.d.ts
|
|
5
|
+
declare const Message: z.ZodObject<{
|
|
6
|
+
message: z.ZodString;
|
|
7
|
+
translation: z.ZodOptional<z.ZodString>;
|
|
8
|
+
id: z.ZodOptional<z.ZodString>;
|
|
9
|
+
context: z.ZodOptional<z.ZodString>;
|
|
10
|
+
comments: z.ZodArray<z.ZodString>;
|
|
11
|
+
references: z.ZodArray<z.ZodString>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
type Message = z.infer<typeof Message>;
|
|
14
|
+
declare const Formatter: z.ZodObject<{
|
|
15
|
+
extension: z.ZodTemplateLiteral<`.${string}`>;
|
|
16
|
+
parse: z.ZodCustom<(content: string) => Message[], (content: string) => Message[]>;
|
|
17
|
+
stringify: z.ZodCustom<(messages: Message[], context: {
|
|
18
|
+
locale: string;
|
|
19
|
+
existingContent?: string;
|
|
20
|
+
}) => string, (messages: Message[], context: {
|
|
21
|
+
locale: string;
|
|
22
|
+
existingContent?: string;
|
|
23
|
+
}) => string>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
type Formatter = z.infer<typeof Formatter>;
|
|
26
|
+
declare const Transformer: z.ZodObject<{
|
|
27
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
28
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
29
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
type Transformer = z.infer<typeof Transformer>;
|
|
32
|
+
declare const Bucket: z.ZodPipe<z.ZodObject<{
|
|
33
|
+
include: z.ZodArray<z.ZodString>;
|
|
34
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
output: z.ZodTemplateLiteral<`${string}{locale}${string}.{extension}`>;
|
|
36
|
+
formatter: z.ZodObject<{
|
|
37
|
+
extension: z.ZodTemplateLiteral<`.${string}`>;
|
|
38
|
+
parse: z.ZodCustom<(content: string) => Message[], (content: string) => Message[]>;
|
|
39
|
+
stringify: z.ZodCustom<(messages: Message[], context: {
|
|
40
|
+
locale: string;
|
|
41
|
+
existingContent?: string;
|
|
42
|
+
}) => string, (messages: Message[], context: {
|
|
43
|
+
locale: string;
|
|
44
|
+
existingContent?: string;
|
|
45
|
+
}) => string>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
transformer: z.ZodPipe<z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
48
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
49
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
50
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
51
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
52
|
+
match: (id: string) => boolean;
|
|
53
|
+
extract: (code: string, id: string) => Message[];
|
|
54
|
+
transform: (code: string, id: string) => string;
|
|
55
|
+
}[], {
|
|
56
|
+
match: (id: string) => boolean;
|
|
57
|
+
extract: (code: string, id: string) => Message[];
|
|
58
|
+
transform: (code: string, id: string) => string;
|
|
59
|
+
}>>, z.ZodArray<z.ZodObject<{
|
|
60
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
61
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
62
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
63
|
+
}, z.core.$strip>>]>, z.ZodTransform<{
|
|
64
|
+
match: (id: string) => boolean;
|
|
65
|
+
extract: (code: string, id: string) => {
|
|
66
|
+
message: string;
|
|
67
|
+
comments: string[];
|
|
68
|
+
references: string[];
|
|
69
|
+
translation?: string | undefined;
|
|
70
|
+
id?: string | undefined;
|
|
71
|
+
context?: string | undefined;
|
|
72
|
+
}[];
|
|
73
|
+
transform: (code: string, id: string) => string;
|
|
74
|
+
}, {
|
|
75
|
+
match: (id: string) => boolean;
|
|
76
|
+
extract: (code: string, id: string) => Message[];
|
|
77
|
+
transform: (code: string, id: string) => string;
|
|
78
|
+
}[]>>;
|
|
79
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
80
|
+
match: (id: string) => boolean;
|
|
81
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
82
|
+
match: picomatch.Matcher;
|
|
83
|
+
};
|
|
84
|
+
include: string[];
|
|
85
|
+
formatter: {
|
|
86
|
+
extension: `.${string}`;
|
|
87
|
+
parse: (content: string) => Message[];
|
|
88
|
+
stringify: (messages: Message[], context: {
|
|
89
|
+
locale: string;
|
|
90
|
+
existingContent?: string;
|
|
91
|
+
}) => string;
|
|
92
|
+
};
|
|
93
|
+
transformer: {
|
|
94
|
+
match: (id: string) => boolean;
|
|
95
|
+
extract: (code: string, id: string) => {
|
|
96
|
+
message: string;
|
|
97
|
+
comments: string[];
|
|
98
|
+
references: string[];
|
|
99
|
+
translation?: string | undefined;
|
|
100
|
+
id?: string | undefined;
|
|
101
|
+
context?: string | undefined;
|
|
102
|
+
}[];
|
|
103
|
+
transform: (code: string, id: string) => string;
|
|
104
|
+
};
|
|
105
|
+
exclude?: string[] | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
include: string[];
|
|
108
|
+
output: `${string}{locale}${string}.{extension}`;
|
|
109
|
+
formatter: {
|
|
110
|
+
extension: `.${string}`;
|
|
111
|
+
parse: (content: string) => Message[];
|
|
112
|
+
stringify: (messages: Message[], context: {
|
|
113
|
+
locale: string;
|
|
114
|
+
existingContent?: string;
|
|
115
|
+
}) => string;
|
|
116
|
+
};
|
|
117
|
+
transformer: {
|
|
118
|
+
match: (id: string) => boolean;
|
|
119
|
+
extract: (code: string, id: string) => {
|
|
120
|
+
message: string;
|
|
121
|
+
comments: string[];
|
|
122
|
+
references: string[];
|
|
123
|
+
translation?: string | undefined;
|
|
124
|
+
id?: string | undefined;
|
|
125
|
+
context?: string | undefined;
|
|
126
|
+
}[];
|
|
127
|
+
transform: (code: string, id: string) => string;
|
|
128
|
+
};
|
|
129
|
+
exclude?: string[] | undefined;
|
|
130
|
+
}>>;
|
|
131
|
+
type Bucket = z.infer<typeof Bucket>;
|
|
132
|
+
declare const Config: z.ZodObject<{
|
|
133
|
+
locales: z.ZodTuple<[z.ZodString], z.ZodString>;
|
|
134
|
+
buckets: z.ZodArray<z.ZodPipe<z.ZodObject<{
|
|
135
|
+
include: z.ZodArray<z.ZodString>;
|
|
136
|
+
exclude: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
137
|
+
output: z.ZodTemplateLiteral<`${string}{locale}${string}.{extension}`>;
|
|
138
|
+
formatter: z.ZodObject<{
|
|
139
|
+
extension: z.ZodTemplateLiteral<`.${string}`>;
|
|
140
|
+
parse: z.ZodCustom<(content: string) => Message[], (content: string) => Message[]>;
|
|
141
|
+
stringify: z.ZodCustom<(messages: Message[], context: {
|
|
142
|
+
locale: string;
|
|
143
|
+
existingContent?: string;
|
|
144
|
+
}) => string, (messages: Message[], context: {
|
|
145
|
+
locale: string;
|
|
146
|
+
existingContent?: string;
|
|
147
|
+
}) => string>;
|
|
148
|
+
}, z.core.$strip>;
|
|
149
|
+
transformer: z.ZodPipe<z.ZodUnion<[z.ZodPipe<z.ZodObject<{
|
|
150
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
151
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
152
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
153
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
154
|
+
match: (id: string) => boolean;
|
|
155
|
+
extract: (code: string, id: string) => Message[];
|
|
156
|
+
transform: (code: string, id: string) => string;
|
|
157
|
+
}[], {
|
|
158
|
+
match: (id: string) => boolean;
|
|
159
|
+
extract: (code: string, id: string) => Message[];
|
|
160
|
+
transform: (code: string, id: string) => string;
|
|
161
|
+
}>>, z.ZodArray<z.ZodObject<{
|
|
162
|
+
match: z.ZodCustom<(id: string) => boolean, (id: string) => boolean>;
|
|
163
|
+
extract: z.ZodCustom<(code: string, id: string) => Message[], (code: string, id: string) => Message[]>;
|
|
164
|
+
transform: z.ZodCustom<(code: string, id: string) => string, (code: string, id: string) => string>;
|
|
165
|
+
}, z.core.$strip>>]>, z.ZodTransform<{
|
|
166
|
+
match: (id: string) => boolean;
|
|
167
|
+
extract: (code: string, id: string) => {
|
|
168
|
+
message: string;
|
|
169
|
+
comments: string[];
|
|
170
|
+
references: string[];
|
|
171
|
+
translation?: string | undefined;
|
|
172
|
+
id?: string | undefined;
|
|
173
|
+
context?: string | undefined;
|
|
174
|
+
}[];
|
|
175
|
+
transform: (code: string, id: string) => string;
|
|
176
|
+
}, {
|
|
177
|
+
match: (id: string) => boolean;
|
|
178
|
+
extract: (code: string, id: string) => Message[];
|
|
179
|
+
transform: (code: string, id: string) => string;
|
|
180
|
+
}[]>>;
|
|
181
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
182
|
+
match: (id: string) => boolean;
|
|
183
|
+
output: `${string}{locale}${string}.{extension}` & {
|
|
184
|
+
match: picomatch.Matcher;
|
|
185
|
+
};
|
|
186
|
+
include: string[];
|
|
187
|
+
formatter: {
|
|
188
|
+
extension: `.${string}`;
|
|
189
|
+
parse: (content: string) => Message[];
|
|
190
|
+
stringify: (messages: Message[], context: {
|
|
191
|
+
locale: string;
|
|
192
|
+
existingContent?: string;
|
|
193
|
+
}) => string;
|
|
194
|
+
};
|
|
195
|
+
transformer: {
|
|
196
|
+
match: (id: string) => boolean;
|
|
197
|
+
extract: (code: string, id: string) => {
|
|
198
|
+
message: string;
|
|
199
|
+
comments: string[];
|
|
200
|
+
references: string[];
|
|
201
|
+
translation?: string | undefined;
|
|
202
|
+
id?: string | undefined;
|
|
203
|
+
context?: string | undefined;
|
|
204
|
+
}[];
|
|
205
|
+
transform: (code: string, id: string) => string;
|
|
206
|
+
};
|
|
207
|
+
exclude?: string[] | undefined;
|
|
208
|
+
}, {
|
|
209
|
+
include: string[];
|
|
210
|
+
output: `${string}{locale}${string}.{extension}`;
|
|
211
|
+
formatter: {
|
|
212
|
+
extension: `.${string}`;
|
|
213
|
+
parse: (content: string) => Message[];
|
|
214
|
+
stringify: (messages: Message[], context: {
|
|
215
|
+
locale: string;
|
|
216
|
+
existingContent?: string;
|
|
217
|
+
}) => string;
|
|
218
|
+
};
|
|
219
|
+
transformer: {
|
|
220
|
+
match: (id: string) => boolean;
|
|
221
|
+
extract: (code: string, id: string) => {
|
|
222
|
+
message: string;
|
|
223
|
+
comments: string[];
|
|
224
|
+
references: string[];
|
|
225
|
+
translation?: string | undefined;
|
|
226
|
+
id?: string | undefined;
|
|
227
|
+
context?: string | undefined;
|
|
228
|
+
}[];
|
|
229
|
+
transform: (code: string, id: string) => string;
|
|
230
|
+
};
|
|
231
|
+
exclude?: string[] | undefined;
|
|
232
|
+
}>>>;
|
|
233
|
+
}, z.core.$strip>;
|
|
234
|
+
type Config = z.infer<typeof Config>;
|
|
235
|
+
//#endregion
|
|
236
|
+
export { Transformer as a, Message as i, Config as n, Formatter as r, Bucket as t };
|
package/package.json
CHANGED
|
@@ -1,4 +1,87 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@saykit/config",
|
|
3
|
-
"version": "0.
|
|
1
|
+
{
|
|
2
|
+
"name": "@saykit/config",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "CLI and configuration tooling for saykit",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"cli",
|
|
7
|
+
"config",
|
|
8
|
+
"i18n",
|
|
9
|
+
"saykit"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/k0d13/saykit#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/k0d13/saykit/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/k0d13/saykit.git",
|
|
19
|
+
"directory": "packages/config"
|
|
20
|
+
},
|
|
21
|
+
"bin": {
|
|
22
|
+
"saykit": "./dist/commands/index.mjs"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"dist",
|
|
26
|
+
"!dist/**/*.map"
|
|
27
|
+
],
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": {
|
|
30
|
+
".": {
|
|
31
|
+
"require": {
|
|
32
|
+
"types": "./dist/index.d.cts",
|
|
33
|
+
"default": "./dist/index.cjs"
|
|
34
|
+
},
|
|
35
|
+
"import": {
|
|
36
|
+
"types": "./dist/index.d.mts",
|
|
37
|
+
"default": "./dist/index.mjs"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"./features/loader": {
|
|
41
|
+
"require": {
|
|
42
|
+
"types": "./dist/features/loader/index.d.cts",
|
|
43
|
+
"default": "./dist/features/loader/index.cjs"
|
|
44
|
+
},
|
|
45
|
+
"import": {
|
|
46
|
+
"types": "./dist/features/loader/index.d.mts",
|
|
47
|
+
"default": "./dist/features/loader/index.mjs"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"./features/messages": {
|
|
51
|
+
"require": {
|
|
52
|
+
"types": "./dist/features/messages/index.d.cts",
|
|
53
|
+
"default": "./dist/features/messages/index.cjs"
|
|
54
|
+
},
|
|
55
|
+
"import": {
|
|
56
|
+
"types": "./dist/features/messages/index.d.mts",
|
|
57
|
+
"default": "./dist/features/messages/index.mjs"
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"publishConfig": {
|
|
62
|
+
"access": "public",
|
|
63
|
+
"provenance": true
|
|
64
|
+
},
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"@commander-js/extra-typings": "^14.0.0",
|
|
67
|
+
"commander": "^14.0.3",
|
|
68
|
+
"js-sha256": "^0.11.1",
|
|
69
|
+
"picomatch": "^4.0.5",
|
|
70
|
+
"zod": "^4.4.3"
|
|
71
|
+
},
|
|
72
|
+
"devDependencies": {
|
|
73
|
+
"@types/picomatch": "^4.0.3"
|
|
74
|
+
},
|
|
75
|
+
"peerDependencies": {
|
|
76
|
+
"typescript": "*"
|
|
77
|
+
},
|
|
78
|
+
"peerDependenciesMeta": {
|
|
79
|
+
"typescript": {
|
|
80
|
+
"optional": true
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
"scripts": {
|
|
84
|
+
"check": "tsc --noEmit",
|
|
85
|
+
"build": "tsdown"
|
|
86
|
+
}
|
|
4
87
|
}
|