i18next-typescript
Advanced tools
Comparing version 0.0.1-rc4 to 0.0.1-rc5
{ | ||
"inFolder": "example/locales/en", | ||
"outFile": "example/i18next.keys.d.ts", | ||
"outFile": "example/i18next.keys.ts", | ||
"defaultNs": "translation", | ||
"indent": 2, | ||
"typeName": "TranslationKeys", | ||
"quoteChart": "'" | ||
"quoteChar": "'" | ||
} |
@@ -33,7 +33,14 @@ #!/usr/bin/env node | ||
}); | ||
withOptions(commander.command("generate").alias("g")).action((c) => __awaiter(void 0, void 0, void 0, function* () { | ||
withOptions(commander | ||
.command("generate") | ||
.alias("g") | ||
.description("Generate type definitions for all your translation keys.")).action((c) => __awaiter(void 0, void 0, void 0, function* () { | ||
const options = yield parseOptions(c.opts()); | ||
console.log(options); | ||
yield generate_1.generate(options); | ||
})); | ||
withOptions(commander.command("watch").alias("w")).action((c) => __awaiter(void 0, void 0, void 0, function* () { | ||
withOptions(commander | ||
.command("watch") | ||
.alias("w") | ||
.description("Watch your translation files and generate type definitions for all your translations keys when they change.")).action((c) => __awaiter(void 0, void 0, void 0, function* () { | ||
const options = yield parseOptions(c.opts()); | ||
@@ -40,0 +47,0 @@ watch_1.watch({ inFolder: options.inFolder }, () => generate_1.generate(options)); |
@@ -28,3 +28,3 @@ "use strict"; | ||
}; | ||
const keysToTs = ({ keys, indent, quoteChar, typeName = "TranslationKey", }) => { | ||
const keysToTs = ({ keys, indent, quoteChar, typeName, }) => { | ||
const whitespace = Array(indent) | ||
@@ -39,3 +39,3 @@ .fill(null) | ||
}; | ||
exports.generate = ({ inFolder, outFile, defaultNs = "translation", indent = 2, typeName = "TranslationKey", quoteChar = `'`, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
exports.generate = ({ inFolder, outFile, defaultNs = "translation", indent = 2, typeName = "TranslationKeys", quoteChar = `'`, }) => __awaiter(void 0, void 0, void 0, function* () { | ||
const files = yield util_1.readdir(inFolder); | ||
@@ -42,0 +42,0 @@ const jsonFiles = files.filter((f) => f.endsWith(".json")); |
{ | ||
"name": "i18next-typescript", | ||
"version": "0.0.1-rc4", | ||
"version": "0.0.1-rc5", | ||
"main": "lib/index.js", | ||
@@ -23,3 +23,5 @@ "author": "LFDM <1986gh@gmail.com>", | ||
"dev": "ts-node src/cli.ts", | ||
"prepack": "yarn build" | ||
"prepack": "yarn build", | ||
"example:watch": "yarn dev watch -c example/i18next-typescript.config.json", | ||
"example:generate": "yarn dev generate -c example/i18next-typescript.config.json" | ||
}, | ||
@@ -26,0 +28,0 @@ "bin": { |
@@ -42,2 +42,3 @@ #!/usr/bin/env node | ||
: {}; | ||
return { | ||
@@ -54,8 +55,21 @@ inFolder: opts.in, | ||
withOptions(commander.command("generate").alias("g")).action(async (c) => { | ||
withOptions( | ||
commander | ||
.command("generate") | ||
.alias("g") | ||
.description("Generate type definitions for all your translation keys.") | ||
).action(async (c) => { | ||
const options = await parseOptions(c.opts()); | ||
console.log(options); | ||
await generate(options); | ||
}); | ||
withOptions(commander.command("watch").alias("w")).action(async (c) => { | ||
withOptions( | ||
commander | ||
.command("watch") | ||
.alias("w") | ||
.description( | ||
"Watch your translation files and generate type definitions for all your translations keys when they change." | ||
) | ||
).action(async (c) => { | ||
const options = await parseOptions(c.opts()); | ||
@@ -62,0 +76,0 @@ watch({ inFolder: options.inFolder }, () => generate(options)); |
@@ -24,3 +24,3 @@ import * as path from "path"; | ||
quoteChar, | ||
typeName = "TranslationKey", | ||
typeName, | ||
}: { | ||
@@ -56,3 +56,3 @@ keys: string[]; | ||
indent = 2, | ||
typeName = "TranslationKey", | ||
typeName = "TranslationKeys", | ||
quoteChar = `'`, | ||
@@ -59,0 +59,0 @@ }: Options) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
24973
31
403
1
88