From 47055d7e45a3d14a2f809879562bc79b40bbbf33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Gran=C3=A1t?= Date: Fri, 17 May 2024 17:02:05 +0200 Subject: [PATCH] feat: add fileStructureTemplate option --- schema.json | 4 ++++ src/commands/pull.ts | 12 ++++++++++++ src/schema.d.ts | 12 ++++++++++++ test/e2e/pull.test.ts | 28 ++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+) diff --git a/schema.json b/schema.json index 1e914846..efb49678 100644 --- a/schema.json +++ b/schema.json @@ -90,6 +90,10 @@ "description": "Export keys with array syntax (e.g. item[0]) as arrays.", "type": "boolean" }, + "fileStructureTemplate": { + "description": "This is a template that defines the structure of the resulting .zip file content.\n\nThe template is a string that can contain the following placeholders: {namespace}, {languageTag}, {androidLanguageTag}, {snakeLanguageTag}, {extension}.\n\nFor example, when exporting to JSON with the template {namespace}/{languageTag}.{extension}, the English translations of the home namespace will be stored in home/en.json.\n\nThe {snakeLanguageTag} placeholder is the same as {languageTag} but in snake case. (e.g., en_US).\n\nThe Android specific {androidLanguageTag} placeholder is the same as {languageTag} but in Android format. (e.g., en-rUS)", + "type": "string" + }, "emptyDir": { "description": "Empty [path] folder before inserting pulled files.", "type": "boolean" diff --git a/src/commands/pull.ts b/src/commands/pull.ts index ed36ba6e..946e4848 100644 --- a/src/commands/pull.ts +++ b/src/commands/pull.ts @@ -21,6 +21,7 @@ type PullOptions = BaseOptions & { tags?: string[]; supportArrays: boolean; excludeTags?: string[]; + fileStructureTemplate?: string; }; async function fetchZipBlob(opts: PullOptions): Promise { @@ -36,6 +37,7 @@ async function fetchZipBlob(opts: PullOptions): Promise { filterNamespace: opts.namespaces, filterTagIn: opts.tags, filterTagNotIn: opts.excludeTags, + fileStructureTemplate: opts.fileStructureTemplate, }); } @@ -131,4 +133,14 @@ export default (config: Schema) => 'Empty [path] directory before inserting pulled files.' ).default(config.pull?.emptyDir) ) + .addOption( + new Option( + '--file-structure-template