@intlayer/cli 5.4.1 → 5.5.0-canary.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/dist/cjs/build.cjs +1 -1
- package/dist/cjs/build.cjs.map +1 -1
- package/dist/cjs/cli.cjs +222 -19
- package/dist/cjs/cli.cjs.map +1 -1
- package/dist/cjs/config.cjs +3 -6
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/fill.cjs +360 -0
- package/dist/cjs/fill.cjs.map +1 -0
- package/dist/cjs/index.cjs +6 -6
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/listContentDeclaration.cjs +3 -7
- package/dist/cjs/listContentDeclaration.cjs.map +1 -1
- package/dist/cjs/pull.cjs +3 -3
- package/dist/cjs/pull.cjs.map +1 -1
- package/dist/cjs/push.cjs +24 -54
- package/dist/cjs/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +1 -1
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/esm/build.mjs +1 -1
- package/dist/esm/build.mjs.map +1 -1
- package/dist/esm/cli.mjs +211 -18
- package/dist/esm/cli.mjs.map +1 -1
- package/dist/esm/config.mjs +4 -8
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/fill.mjs +338 -0
- package/dist/esm/fill.mjs.map +1 -0
- package/dist/esm/index.mjs +3 -3
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/listContentDeclaration.mjs +5 -9
- package/dist/esm/listContentDeclaration.mjs.map +1 -1
- package/dist/esm/pull.mjs +5 -5
- package/dist/esm/pull.mjs.map +1 -1
- package/dist/esm/push.mjs +26 -56
- package/dist/esm/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +1 -1
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/types/build.d.ts +2 -1
- package/dist/types/build.d.ts.map +1 -1
- package/dist/types/cli.d.ts.map +1 -1
- package/dist/types/config.d.ts +2 -2
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/fill.d.ts +27 -0
- package/dist/types/fill.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/listContentDeclaration.d.ts +4 -3
- package/dist/types/listContentDeclaration.d.ts.map +1 -1
- package/dist/types/pull.d.ts +2 -1
- package/dist/types/pull.d.ts.map +1 -1
- package/dist/types/push.d.ts +4 -2
- package/dist/types/push.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts +2 -1
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/package.json +12 -11
- package/dist/cjs/audit.cjs +0 -126
- package/dist/cjs/audit.cjs.map +0 -1
- package/dist/esm/audit.mjs +0 -94
- package/dist/esm/audit.mjs.map +0 -1
- package/dist/types/audit.d.ts +0 -38
- package/dist/types/audit.d.ts.map +0 -1
package/dist/cjs/push.cjs
CHANGED
|
@@ -31,13 +31,14 @@ __export(push_exports, {
|
|
|
31
31
|
push: () => push
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(push_exports);
|
|
34
|
-
var fsPromises = __toESM(require("fs/promises"));
|
|
35
|
-
var import_path = require("path");
|
|
36
|
-
var readline = __toESM(require("readline"));
|
|
37
34
|
var import_api = require("@intlayer/api");
|
|
35
|
+
var import_chokidar = require("@intlayer/chokidar");
|
|
38
36
|
var import_config = require("@intlayer/config");
|
|
39
37
|
var import_dictionaries_entry = __toESM(require("@intlayer/dictionaries-entry"));
|
|
38
|
+
var fsPromises = __toESM(require("fs/promises"));
|
|
40
39
|
var import_p_limit = __toESM(require("p-limit"));
|
|
40
|
+
var import_path = require("path");
|
|
41
|
+
var readline = __toESM(require("readline"));
|
|
41
42
|
const spinnerFrames = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
42
43
|
const RESET = "\x1B[0m";
|
|
43
44
|
const GREEN = "\x1B[32m";
|
|
@@ -47,7 +48,7 @@ const GREY = "\x1B[90m";
|
|
|
47
48
|
const GREY_DARK = "\x1B[90m";
|
|
48
49
|
const push = async (options) => {
|
|
49
50
|
try {
|
|
50
|
-
const config = (0, import_config.getConfiguration)(options);
|
|
51
|
+
const config = (0, import_config.getConfiguration)(options?.configOptions);
|
|
51
52
|
const { clientId, clientSecret } = config.editor;
|
|
52
53
|
if (!clientId || !clientSecret) {
|
|
53
54
|
throw new Error(
|
|
@@ -64,15 +65,12 @@ const push = async (options) => {
|
|
|
64
65
|
(dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)
|
|
65
66
|
);
|
|
66
67
|
if (noneExistingDictionariesOption.length > 0) {
|
|
67
|
-
(0, import_config.
|
|
68
|
+
(0, import_config.appLogger)(
|
|
68
69
|
`The following dictionaries do not exist: ${noneExistingDictionariesOption.join(
|
|
69
70
|
", "
|
|
70
71
|
)} and have been ignored.`,
|
|
71
72
|
{
|
|
72
|
-
level: "error"
|
|
73
|
-
config: {
|
|
74
|
-
prefix: options?.logPrefix
|
|
75
|
-
}
|
|
73
|
+
level: "error"
|
|
76
74
|
}
|
|
77
75
|
);
|
|
78
76
|
}
|
|
@@ -80,20 +78,16 @@ const push = async (options) => {
|
|
|
80
78
|
(dictionary) => options.dictionaries.includes(dictionary.key)
|
|
81
79
|
);
|
|
82
80
|
}
|
|
81
|
+
if (options?.gitOptions) {
|
|
82
|
+
const gitFiles = await (0, import_chokidar.listGitFiles)(options.gitOptions);
|
|
83
|
+
}
|
|
83
84
|
if (dictionaries.length === 0) {
|
|
84
|
-
(0, import_config.
|
|
85
|
-
level: "error"
|
|
86
|
-
config: {
|
|
87
|
-
prefix: options?.logPrefix
|
|
88
|
-
}
|
|
85
|
+
(0, import_config.appLogger)("No local dictionaries found", {
|
|
86
|
+
level: "error"
|
|
89
87
|
});
|
|
90
88
|
return;
|
|
91
89
|
}
|
|
92
|
-
(0, import_config.
|
|
93
|
-
config: {
|
|
94
|
-
prefix: options?.logPrefix
|
|
95
|
-
}
|
|
96
|
-
});
|
|
90
|
+
(0, import_config.appLogger)("Pushing dictionaries:", {});
|
|
97
91
|
const dictionariesStatuses = dictionaries.map(
|
|
98
92
|
(dictionary, index) => ({
|
|
99
93
|
dictionary,
|
|
@@ -147,11 +141,8 @@ const push = async (options) => {
|
|
|
147
141
|
updateAllStatusLines(dictionariesStatuses);
|
|
148
142
|
for (const statusObj of dictionariesStatuses) {
|
|
149
143
|
if (statusObj.errorMessage) {
|
|
150
|
-
(0, import_config.
|
|
151
|
-
level: "error"
|
|
152
|
-
config: {
|
|
153
|
-
prefix: options?.logPrefix
|
|
154
|
-
}
|
|
144
|
+
(0, import_config.appLogger)(statusObj.errorMessage, {
|
|
145
|
+
level: "error"
|
|
155
146
|
});
|
|
156
147
|
}
|
|
157
148
|
}
|
|
@@ -174,11 +165,8 @@ const push = async (options) => {
|
|
|
174
165
|
}
|
|
175
166
|
}
|
|
176
167
|
} catch (error) {
|
|
177
|
-
(0, import_config.
|
|
178
|
-
level: "error"
|
|
179
|
-
config: {
|
|
180
|
-
prefix: options?.logPrefix
|
|
181
|
-
}
|
|
168
|
+
(0, import_config.appLogger)(error, {
|
|
169
|
+
level: "error"
|
|
182
170
|
});
|
|
183
171
|
}
|
|
184
172
|
};
|
|
@@ -200,11 +188,8 @@ const deleteLocalDictionaries = async (dictionariesToDelete, options) => {
|
|
|
200
188
|
for (const dictionary of dictionariesToDelete) {
|
|
201
189
|
const { filePath } = dictionary;
|
|
202
190
|
if (!filePath) {
|
|
203
|
-
(0, import_config.
|
|
204
|
-
level: "error"
|
|
205
|
-
config: {
|
|
206
|
-
prefix: options?.logPrefix
|
|
207
|
-
}
|
|
191
|
+
(0, import_config.appLogger)(`Dictionary ${dictionary.key} does not have a file path`, {
|
|
192
|
+
level: "error"
|
|
208
193
|
});
|
|
209
194
|
continue;
|
|
210
195
|
}
|
|
@@ -216,30 +201,15 @@ const deleteLocalDictionaries = async (dictionariesToDelete, options) => {
|
|
|
216
201
|
const stats = await fsPromises.lstat(filePath);
|
|
217
202
|
if (stats.isFile()) {
|
|
218
203
|
await fsPromises.unlink(filePath);
|
|
219
|
-
(0, import_config.
|
|
220
|
-
config: {
|
|
221
|
-
prefix: options?.logPrefix
|
|
222
|
-
}
|
|
223
|
-
});
|
|
204
|
+
(0, import_config.appLogger)(`Deleted file ${relativePath}`, {});
|
|
224
205
|
} else if (stats.isDirectory()) {
|
|
225
|
-
(0, import_config.
|
|
226
|
-
config: {
|
|
227
|
-
prefix: options?.logPrefix
|
|
228
|
-
}
|
|
229
|
-
});
|
|
206
|
+
(0, import_config.appLogger)(`Path is a directory ${relativePath}, skipping.`, {});
|
|
230
207
|
} else {
|
|
231
|
-
(0, import_config.
|
|
232
|
-
config: {
|
|
233
|
-
prefix: options?.logPrefix
|
|
234
|
-
}
|
|
235
|
-
});
|
|
208
|
+
(0, import_config.appLogger)(`Unknown file type for ${relativePath}, skipping.`, {});
|
|
236
209
|
}
|
|
237
210
|
} catch (err) {
|
|
238
|
-
(0, import_config.
|
|
239
|
-
level: "error"
|
|
240
|
-
config: {
|
|
241
|
-
prefix: options?.logPrefix
|
|
242
|
-
}
|
|
211
|
+
(0, import_config.appLogger)(`Error deleting ${relativePath}: ${err}`, {
|
|
212
|
+
level: "error"
|
|
243
213
|
});
|
|
244
214
|
}
|
|
245
215
|
}
|
package/dist/cjs/push.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/push.ts"],"sourcesContent":["import * as fsPromises from 'fs/promises';\nimport { relative } from 'path';\nimport * as readline from 'readline';\nimport { getIntlayerAPI } from '@intlayer/api';\nimport {\n getConfiguration,\n GetConfigurationOptions,\n logger,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport pLimit from 'p-limit';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n logPrefix?: string;\n} & GetConfigurationOptions;\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n icon: string;\n index: number;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nconst spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst GREY_DARK = '\\x1b[90m';\n\n/**\n * Get all locale dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n try {\n const config = getConfiguration(options);\n const { clientId, clientSecret } = config.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, config);\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n let dictionaries: Dictionary[] = Object.values(dictionariesRecord);\n const existingDictionariesKeys: string[] = Object.keys(dictionariesRecord);\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n logger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries!.includes(dictionary.key)\n );\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n logger('No local dictionaries found', {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n });\n return;\n }\n\n logger('Pushing dictionaries:', {\n config: {\n prefix: options?.logPrefix,\n },\n });\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary, index) => ({\n dictionary,\n icon: getStatusIcon('pending'),\n status: 'pending',\n index,\n spinnerFrameIndex: 0,\n })\n );\n\n // Output initial statuses\n for (const statusObj of dictionariesStatuses) {\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n // Start spinner timer\n const spinnerTimer = setInterval(() => {\n updateAllStatusLines(dictionariesStatuses);\n }, 100); // Update every 100ms\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries(\n [statusObj.dictionary],\n {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }\n );\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries || [];\n const newDictionaries = pushResult.data?.newDictionaries || [];\n\n if (updatedDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else if (newDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n const pushPromises = dictionariesStatuses.map((statusObj) =>\n limit(() => processDictionary(statusObj))\n );\n await Promise.all(pushPromises);\n\n // Stop the spinner timer\n clearInterval(spinnerTimer);\n\n // Update statuses one last time\n updateAllStatusLines(dictionariesStatuses);\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n logger(statusObj.errorMessage, {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n }\n }\n } catch (error) {\n logger(error, {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n });\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const { baseDir } = getConfiguration().content;\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n logger(`Dictionary ${dictionary.key} does not have a file path`, {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n });\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n const relativePath = relative(baseDir, filePath);\n\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n logger(`Deleted file ${relativePath}`, {\n config: {\n prefix: options?.logPrefix,\n },\n });\n } else if (stats.isDirectory()) {\n logger(`Path is a directory ${relativePath}, skipping.`, {\n config: {\n prefix: options?.logPrefix,\n },\n });\n } else {\n logger(`Unknown file type for ${relativePath}, skipping.`, {\n config: {\n prefix: options?.logPrefix,\n },\n });\n }\n } catch (err) {\n logger(`Error deleting ${relativePath}: ${err}`, {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n });\n }\n }\n};\n\nconst getStatusIcon = (status: string): string => {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n pushing: '', // Spinner handled separately\n modified: '✔',\n pushed: '✔',\n error: '✖',\n };\n return statusIcons[status] || '';\n};\n\nconst getStatusLine = (statusObj: DictionariesStatus): string => {\n const {\n log: { prefix },\n } = getConfiguration();\n\n let icon = getStatusIcon(statusObj.status);\n let colorStart = '';\n let colorEnd = '';\n\n if (statusObj.status === 'pushing') {\n // Use spinner frame\n icon = spinnerFrames[statusObj.spinnerFrameIndex! % spinnerFrames.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (statusObj.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (statusObj.status === 'pushed' || statusObj.status === 'modified') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n return `- ${statusObj.dictionary.key} ${GREY_DARK}[${colorStart}${icon}${statusObj.status}${GREY_DARK}]${colorEnd}`;\n};\n\nconst updateAllStatusLines = (dictionariesStatuses: DictionariesStatus[]) => {\n // Move cursor up to the first status line\n readline.moveCursor(process.stdout, 0, -dictionariesStatuses.length);\n for (const statusObj of dictionariesStatuses) {\n // Clear the line\n readline.clearLine(process.stdout, 0);\n\n if (statusObj.status === 'pushing') {\n // Update spinner frame\n statusObj.spinnerFrameIndex =\n (statusObj.spinnerFrameIndex! + 1) % spinnerFrames.length;\n }\n\n // Write the status line\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA4B;AAC5B,kBAAyB;AACzB,eAA0B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AAAA,IACV,QAAQ;AAAA,IACR,OAAO;AAAA,EACT;AACA,SAAO,YAAY,MAAM,KAAK;AAChC;AAEA,MAAM,gBAAgB,CAAC,cAA0C;AAC/D,QAAM;AAAA,IACJ,KAAK,EAAE,OAAO;AAAA,EAChB,QAAI,gCAAiB;AAErB,MAAI,OAAO,cAAc,UAAU,MAAM;AACzC,MAAI,aAAa;AACjB,MAAI,WAAW;AAEf,MAAI,UAAU,WAAW,WAAW;AAElC,WAAO,cAAc,UAAU,oBAAqB,cAAc,MAAM;AACxE,iBAAa;AACb,eAAW;AAAA,EACb,WAAW,UAAU,WAAW,SAAS;AACvC,iBAAa;AACb,eAAW;AAAA,EACb,WAAW,UAAU,WAAW,YAAY,UAAU,WAAW,YAAY;AAC3E,iBAAa;AACb,eAAW;AAAA,EACb,OAAO;AACL,iBAAa;AACb,eAAW;AAAA,EACb;AAEA,SAAO,KAAK,UAAU,WAAW,GAAG,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,GAAG,UAAU,MAAM,GAAG,SAAS,IAAI,QAAQ;AACnH;AAEA,MAAM,uBAAuB,CAAC,yBAA+C;AAE3E,WAAS,WAAW,QAAQ,QAAQ,GAAG,CAAC,qBAAqB,MAAM;AACnE,aAAW,aAAa,sBAAsB;AAE5C,aAAS,UAAU,QAAQ,QAAQ,CAAC;AAEpC,QAAI,UAAU,WAAW,WAAW;AAElC,gBAAU,qBACP,UAAU,oBAAqB,KAAK,cAAc;AAAA,IACvD;AAGA,YAAQ,OAAO,MAAM,cAAc,SAAS,IAAI,IAAI;AAAA,EACtD;AACF;","names":["dictionariesRecord","pLimit"]}
|
|
1
|
+
{"version":3,"sources":["../../src/push.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport { listGitFiles } from '@intlayer/chokidar';\nimport {\n appLogger,\n getConfiguration,\n GetConfigurationOptions,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport * as fsPromises from 'fs/promises';\nimport pLimit from 'p-limit';\nimport { relative } from 'path';\nimport * as readline from 'readline';\nimport { ListGitFilesOptions } from '../../chokidar/dist/types/listGitFiles';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n icon: string;\n index: number;\n error?: Error;\n errorMessage?: string;\n spinnerFrameIndex?: number;\n};\n\nconst spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'];\n\nconst RESET = '\\x1b[0m';\nconst GREEN = '\\x1b[32m';\nconst RED = '\\x1b[31m';\nconst BLUE = '\\x1b[34m';\nconst GREY = '\\x1b[90m';\nconst GREY_DARK = '\\x1b[90m';\n\n/**\n * Get all locale dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n try {\n const config = getConfiguration(options?.configOptions);\n const { clientId, clientSecret } = config.editor;\n\n if (!clientId || !clientSecret) {\n throw new Error(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.'\n );\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, config);\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n let dictionaries: Dictionary[] = Object.values(dictionariesRecord);\n const existingDictionariesKeys: string[] = Object.keys(dictionariesRecord);\n\n if (options?.dictionaries) {\n // Check if the provided dictionaries exist\n const noneExistingDictionariesOption = options.dictionaries.filter(\n (dictionaryId) => !existingDictionariesKeys.includes(dictionaryId)\n );\n\n if (noneExistingDictionariesOption.length > 0) {\n appLogger(\n `The following dictionaries do not exist: ${noneExistingDictionariesOption.join(\n ', '\n )} and have been ignored.`,\n {\n level: 'error',\n }\n );\n }\n\n // Filter the dictionaries from the provided list of IDs\n dictionaries = dictionaries.filter((dictionary) =>\n options.dictionaries!.includes(dictionary.key)\n );\n }\n\n if (options?.gitOptions) {\n const gitFiles = await listGitFiles(options.gitOptions);\n }\n\n // Check if the dictionaries list is empty\n if (dictionaries.length === 0) {\n appLogger('No local dictionaries found', {\n level: 'error',\n });\n return;\n }\n\n appLogger('Pushing dictionaries:', {});\n\n // Prepare dictionaries statuses\n const dictionariesStatuses: DictionariesStatus[] = dictionaries.map(\n (dictionary, index) => ({\n dictionary,\n icon: getStatusIcon('pending'),\n status: 'pending',\n index,\n spinnerFrameIndex: 0,\n })\n );\n\n // Output initial statuses\n for (const statusObj of dictionariesStatuses) {\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n // Start spinner timer\n const spinnerTimer = setInterval(() => {\n updateAllStatusLines(dictionariesStatuses);\n }, 100); // Update every 100ms\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries(\n [statusObj.dictionary],\n {\n headers: {\n Authorization: `Bearer ${oAuth2AccessToken}`,\n },\n }\n );\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries || [];\n const newDictionaries = pushResult.data?.newDictionaries || [];\n\n if (updatedDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else if (newDictionaries.includes(statusObj.dictionary.key)) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n } else {\n statusObj.status = 'unknown';\n }\n } catch (error) {\n statusObj.status = 'error';\n statusObj.error = error as Error;\n statusObj.errorMessage = `Error pushing dictionary ${statusObj.dictionary.key}: ${error}`;\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit\n const limit = pLimit(5); // Limit the number of concurrent requests\n const pushPromises = dictionariesStatuses.map((statusObj) =>\n limit(() => processDictionary(statusObj))\n );\n await Promise.all(pushPromises);\n\n // Stop the spinner timer\n clearInterval(spinnerTimer);\n\n // Update statuses one last time\n updateAllStatusLines(dictionariesStatuses);\n\n // Output any error messages\n for (const statusObj of dictionariesStatuses) {\n if (statusObj.errorMessage) {\n appLogger(statusObj.errorMessage, {\n level: 'error',\n });\n }\n }\n\n // Handle delete or keep options\n const deleteOption = options?.deleteLocaleDictionary;\n const keepOption = options?.keepLocaleDictionary;\n\n if (deleteOption && keepOption) {\n throw new Error(\n 'Cannot specify both --deleteLocaleDictionary and --keepLocaleDictionary options.'\n );\n }\n\n if (deleteOption) {\n // Delete only the successfully pushed dictionaries\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n } else if (keepOption) {\n // Do nothing, keep the local dictionaries\n } else {\n // Ask the user\n const answer = await askUser(\n 'Do you want to delete the local dictionaries that were successfully pushed? (yes/no): '\n );\n if (answer.toLowerCase() === 'yes' || answer.toLowerCase() === 'y') {\n await deleteLocalDictionaries(successfullyPushedDictionaries, options);\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst askUser = (question: string): Promise<string> => {\n const rl = readline.createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n return new Promise((resolve) => {\n rl.question(question, (answer: string) => {\n rl.close();\n resolve(answer);\n });\n });\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const { baseDir } = getConfiguration().content;\n\n // Use a Set to collect all unique file paths\n const filePathsSet: Set<string> = new Set();\n\n for (const dictionary of dictionariesToDelete) {\n const { filePath } = dictionary;\n\n if (!filePath) {\n appLogger(`Dictionary ${dictionary.key} does not have a file path`, {\n level: 'error',\n });\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n const relativePath = relative(baseDir, filePath);\n\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${relativePath}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${relativePath}, skipping.`, {});\n } else {\n appLogger(`Unknown file type for ${relativePath}, skipping.`, {});\n }\n } catch (err) {\n appLogger(`Error deleting ${relativePath}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n\nconst getStatusIcon = (status: string): string => {\n const statusIcons: Record<string, string> = {\n pending: '⏲',\n pushing: '', // Spinner handled separately\n modified: '✔',\n pushed: '✔',\n error: '✖',\n };\n return statusIcons[status] || '';\n};\n\nconst getStatusLine = (statusObj: DictionariesStatus): string => {\n const {\n log: { prefix },\n } = getConfiguration();\n\n let icon = getStatusIcon(statusObj.status);\n let colorStart = '';\n let colorEnd = '';\n\n if (statusObj.status === 'pushing') {\n // Use spinner frame\n icon = spinnerFrames[statusObj.spinnerFrameIndex! % spinnerFrames.length];\n colorStart = BLUE;\n colorEnd = RESET;\n } else if (statusObj.status === 'error') {\n colorStart = RED;\n colorEnd = RESET;\n } else if (statusObj.status === 'pushed' || statusObj.status === 'modified') {\n colorStart = GREEN;\n colorEnd = RESET;\n } else {\n colorStart = GREY;\n colorEnd = RESET;\n }\n\n return `- ${statusObj.dictionary.key} ${GREY_DARK}[${colorStart}${icon}${statusObj.status}${GREY_DARK}]${colorEnd}`;\n};\n\nconst updateAllStatusLines = (dictionariesStatuses: DictionariesStatus[]) => {\n // Move cursor up to the first status line\n readline.moveCursor(process.stdout, 0, -dictionariesStatuses.length);\n for (const statusObj of dictionariesStatuses) {\n // Clear the line\n readline.clearLine(process.stdout, 0);\n\n if (statusObj.status === 'pushing') {\n // Update spinner frame\n statusObj.spinnerFrameIndex =\n (statusObj.spinnerFrameIndex! + 1) % spinnerFrames.length;\n }\n\n // Write the status line\n process.stdout.write(getStatusLine(statusObj) + '\\n');\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;A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W;AAAA,EACb,WAAW,UAAU,WAAW,YAAY,UAAU,WAAW,YAAY;AAC3E,iBAAa;AACb,eAAW;AAAA,EACb,OAAO;AACL,iBAAa;AACb,eAAW;AAAA,EACb;AAEA,SAAO,KAAK,UAAU,WAAW,GAAG,IAAI,SAAS,IAAI,UAAU,GAAG,IAAI,GAAG,UAAU,MAAM,GAAG,SAAS,IAAI,QAAQ;AACnH;AAEA,MAAM,uBAAuB,CAAC,yBAA+C;AAE3E,WAAS,WAAW,QAAQ,QAAQ,GAAG,CAAC,qBAAqB,MAAM;AACnE,aAAW,aAAa,sBAAsB;AAE5C,aAAS,UAAU,QAAQ,QAAQ,CAAC;AAEpC,QAAI,UAAU,WAAW,WAAW;AAElC,gBAAU,qBACP,UAAU,oBAAqB,KAAK,cAAc;AAAA,IACvD;AAGA,YAAQ,OAAO,MAAM,cAAc,SAAS,IAAI,IAAI;AAAA,EACtD;AACF;","names":["dictionariesRecord","pLimit"]}
|
package/dist/cjs/pushConfig.cjs
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = __toCommonJS(pushConfig_exports);
|
|
|
24
24
|
var import_api = require("@intlayer/api");
|
|
25
25
|
var import_config = require("@intlayer/config");
|
|
26
26
|
const pushConfig = async (options) => {
|
|
27
|
-
const config = (0, import_config.getConfiguration)(options);
|
|
27
|
+
const config = (0, import_config.getConfiguration)(options?.configOptions);
|
|
28
28
|
const { clientId, clientSecret } = config.editor;
|
|
29
29
|
if (!clientId || !clientSecret) {
|
|
30
30
|
(0, import_config.logger)(
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport {\n getConfiguration,\n logger,\n type GetConfigurationOptions,\n} from '@intlayer/config';\n\ntype PushOptions = {\n logPrefix?: string;\n
|
|
1
|
+
{"version":3,"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { getIntlayerAPI } from '@intlayer/api';\nimport {\n getConfiguration,\n logger,\n type GetConfigurationOptions,\n} from '@intlayer/config';\n\ntype PushOptions = {\n logPrefix?: string;\n configOptions?: GetConfigurationOptions;\n};\n\nexport const pushConfig = async (options?: PushOptions) => {\n const config = getConfiguration(options?.configOptions);\n\n const { clientId, clientSecret } = config.editor;\n\n if (!clientId || !clientSecret) {\n logger(\n 'Missing OAuth2 client ID or client secret. To get access token go to https://intlayer.org/dashboard/project.',\n {\n level: 'error',\n config: {\n prefix: options?.logPrefix,\n },\n }\n );\n return;\n }\n\n const intlayerAPI = getIntlayerAPI(undefined, config);\n\n const oAuth2TokenResult = await intlayerAPI.auth.getOAuth2AccessToken();\n\n const oAuth2AccessToken = oAuth2TokenResult.data?.accessToken;\n\n // Get the list of dictionary keys\n const getDictionariesKeysResult =\n await intlayerAPI.project.pushProjectConfiguration(config, {\n headers: { Authorization: `Bearer ${oAuth2AccessToken}` },\n });\n\n if (!getDictionariesKeysResult.data) {\n throw new Error('Error pushing project configuration');\n }\n\n logger('Project configuration pushed successfully', {\n config: {\n prefix: options?.logPrefix,\n },\n });\n\n logger(JSON.stringify(getDictionariesKeysResult.data, null, 2), {\n config: {\n prefix: options?.logPrefix,\n },\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAA+B;AAC/B,oBAIO;AAOA,MAAM,aAAa,OAAO,YAA0B;AACzD,QAAM,aAAS,gCAAiB,SAAS,aAAa;AAEtD,QAAM,EAAE,UAAU,aAAa,IAAI,OAAO;AAE1C,MAAI,CAAC,YAAY,CAAC,cAAc;AAC9B;AAAA,MACE;AAAA,MACA;AAAA,QACE,OAAO;AAAA,QACP,QAAQ;AAAA,UACN,QAAQ,SAAS;AAAA,QACnB;AAAA,MACF;AAAA,IACF;AACA;AAAA,EACF;AAEA,QAAM,kBAAc,2BAAe,QAAW,MAAM;AAEpD,QAAM,oBAAoB,MAAM,YAAY,KAAK,qBAAqB;AAEtE,QAAM,oBAAoB,kBAAkB,MAAM;AAGlD,QAAM,4BACJ,MAAM,YAAY,QAAQ,yBAAyB,QAAQ;AAAA,IACzD,SAAS,EAAE,eAAe,UAAU,iBAAiB,GAAG;AAAA,EAC1D,CAAC;AAEH,MAAI,CAAC,0BAA0B,MAAM;AACnC,UAAM,IAAI,MAAM,qCAAqC;AAAA,EACvD;AAEA,4BAAO,6CAA6C;AAAA,IAClD,QAAQ;AAAA,MACN,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,CAAC;AAED,4BAAO,KAAK,UAAU,0BAA0B,MAAM,MAAM,CAAC,GAAG;AAAA,IAC9D,QAAQ;AAAA,MACN,QAAQ,SAAS;AAAA,IACnB;AAAA,EACF,CAAC;AACH;","names":[]}
|
package/dist/esm/build.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
getConfiguration
|
|
4
4
|
} from "@intlayer/config";
|
|
5
5
|
const build = async (options) => {
|
|
6
|
-
const config = getConfiguration(options);
|
|
6
|
+
const config = getConfiguration(options?.configOptions);
|
|
7
7
|
await buildAndWatchIntlayer({
|
|
8
8
|
persistent: options?.watch ?? false,
|
|
9
9
|
configuration: config
|
package/dist/esm/build.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/build.ts"],"sourcesContent":["import { buildAndWatchIntlayer } from '@intlayer/chokidar';\nimport {\n getConfiguration,\n type GetConfigurationOptions,\n} from '@intlayer/config';\n\ntype BuildOptions = {
|
|
1
|
+
{"version":3,"sources":["../../src/build.ts"],"sourcesContent":["import { buildAndWatchIntlayer } from '@intlayer/chokidar';\nimport {\n getConfiguration,\n type GetConfigurationOptions,\n} from '@intlayer/config';\n\ntype BuildOptions = {\n watch?: boolean;\n configOptions?: GetConfigurationOptions;\n};\n\n/**\n * Get locales dictionaries .content.{json|ts|tsx|js|jsx|mjs|cjs} and build the JSON dictionaries in the .intlayer directory.\n * Watch mode available to get the change in the .content.{json|ts|tsx|js|jsx|mjs|cjs}\n */\nexport const build = async (options?: BuildOptions) => {\n const config = getConfiguration(options?.configOptions);\n\n await buildAndWatchIntlayer({\n persistent: options?.watch ?? false,\n configuration: config,\n });\n};\n"],"mappings":"AAAA,SAAS,6BAA6B;AACtC;AAAA,EACE;AAAA,OAEK;AAWA,MAAM,QAAQ,OAAO,YAA2B;AACrD,QAAM,SAAS,iBAAiB,SAAS,aAAa;AAEtD,QAAM,sBAAsB;AAAA,IAC1B,YAAY,SAAS,SAAS;AAAA,IAC9B,eAAe;AAAA,EACjB,CAAC;AACH;","names":[]}
|
package/dist/esm/cli.mjs
CHANGED
|
@@ -1,34 +1,227 @@
|
|
|
1
|
+
import configuration from "@intlayer/config/built";
|
|
1
2
|
import { Command } from "commander";
|
|
2
|
-
import { audit } from "./audit.mjs";
|
|
3
3
|
import { build } from "./build.mjs";
|
|
4
4
|
import { getConfig } from "./config.mjs";
|
|
5
|
+
import { fill } from "./fill.mjs";
|
|
5
6
|
import { listContentDeclaration } from "./listContentDeclaration.mjs";
|
|
6
7
|
import { pull } from "./pull.mjs";
|
|
7
8
|
import { push } from "./push.mjs";
|
|
8
9
|
import { pushConfig } from "./pushConfig.mjs";
|
|
10
|
+
const configurationOptions = [
|
|
11
|
+
["--env-file [envFile]", "Environment file"],
|
|
12
|
+
["-e, --env [env]", "Environment"],
|
|
13
|
+
["--base-dir [baseDir]", "Base directory"],
|
|
14
|
+
["--verbose", "Verbose"]
|
|
15
|
+
];
|
|
16
|
+
const aiOptions = [
|
|
17
|
+
["--provider [provider]", "Provider"],
|
|
18
|
+
["--temperature [temperature]", "Temperature"],
|
|
19
|
+
["--model [model]", "Model"],
|
|
20
|
+
["--api-key [apiKey]", "Provider API key"],
|
|
21
|
+
["--custom-prompt [prompt]", "Custom prompt"],
|
|
22
|
+
["--application-context [applicationContext]", "Application context"]
|
|
23
|
+
];
|
|
24
|
+
const gitOptions = [
|
|
25
|
+
["--git-diff [gitDiff]", "Git diff mode - Check git diff between two refs"],
|
|
26
|
+
["--git-diff-base [gitDiffBase]", "Git diff base ref"],
|
|
27
|
+
["--git-diff-current [gitDiffCurrent]", "Git diff current ref"],
|
|
28
|
+
["--uncommitted [uncommitted]", "Uncommitted"],
|
|
29
|
+
["--unpushed [unpushed]", "Unpushed"],
|
|
30
|
+
["--untracked [untracked]", "Untracked"]
|
|
31
|
+
];
|
|
32
|
+
const applyOptions = (command, options) => {
|
|
33
|
+
options.forEach(([flag, description]) => command.option(flag, description));
|
|
34
|
+
return command;
|
|
35
|
+
};
|
|
36
|
+
const applyConfigOptions = (command) => applyOptions(command, configurationOptions);
|
|
37
|
+
const applyAIOptions = (command) => applyOptions(command, aiOptions);
|
|
38
|
+
const applyGitOptions = (command) => applyOptions(command, gitOptions);
|
|
39
|
+
const extractAiOptions = (options) => {
|
|
40
|
+
const isOptionEmpty = !Object.values(options).some(Boolean);
|
|
41
|
+
if (isOptionEmpty) {
|
|
42
|
+
return void 0;
|
|
43
|
+
}
|
|
44
|
+
const { apiKey, provider, model, temperature, applicationContext } = options;
|
|
45
|
+
return {
|
|
46
|
+
apiKey: apiKey ?? configuration.ai?.apiKey,
|
|
47
|
+
provider: provider ?? configuration.ai?.provider,
|
|
48
|
+
model: model ?? configuration.ai?.model,
|
|
49
|
+
temperature: temperature ?? configuration.ai?.temperature,
|
|
50
|
+
applicationContext: applicationContext ?? configuration.ai?.applicationContext
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
const extractGitOptions = (options) => {
|
|
54
|
+
const isOptionEmpty = !Object.values(options).some(Boolean);
|
|
55
|
+
if (isOptionEmpty) {
|
|
56
|
+
return void 0;
|
|
57
|
+
}
|
|
58
|
+
const {
|
|
59
|
+
gitDiff,
|
|
60
|
+
gitDiffBase,
|
|
61
|
+
gitDiffCurrent,
|
|
62
|
+
uncommitted,
|
|
63
|
+
unpushed,
|
|
64
|
+
untracked
|
|
65
|
+
} = options;
|
|
66
|
+
const mode = [
|
|
67
|
+
gitDiff && "gitDiff",
|
|
68
|
+
uncommitted && "uncommitted",
|
|
69
|
+
unpushed && "unpushed",
|
|
70
|
+
untracked && "untracked"
|
|
71
|
+
].filter(Boolean);
|
|
72
|
+
return {
|
|
73
|
+
mode,
|
|
74
|
+
baseRef: gitDiffBase,
|
|
75
|
+
currentRef: gitDiffCurrent,
|
|
76
|
+
absolute: true
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
const extractConfigOptions = (options) => {
|
|
80
|
+
const isOptionEmpty = !Object.values(options).some(Boolean);
|
|
81
|
+
if (isOptionEmpty) {
|
|
82
|
+
return void 0;
|
|
83
|
+
}
|
|
84
|
+
const { baseDir, verbose, env, envFile } = options;
|
|
85
|
+
return {
|
|
86
|
+
baseDir,
|
|
87
|
+
verbose,
|
|
88
|
+
env,
|
|
89
|
+
envFile
|
|
90
|
+
};
|
|
91
|
+
};
|
|
9
92
|
const setAPI = () => {
|
|
10
93
|
const program = new Command();
|
|
11
94
|
program.version("1.0.0").description("Intlayer CLI");
|
|
12
95
|
const dictionariesProgram = program.command("dictionary").alias("dictionaries").alias("dic").description("Dictionaries operations");
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
96
|
+
const buildOptions = {
|
|
97
|
+
description: "Build the dictionaries",
|
|
98
|
+
options: [["-w, --watch", "Watch for changes"]]
|
|
99
|
+
};
|
|
100
|
+
const dictionariesBuildCmd = dictionariesProgram.command("build").description(buildOptions.description);
|
|
101
|
+
applyOptions(dictionariesBuildCmd, buildOptions.options);
|
|
102
|
+
applyConfigOptions(dictionariesBuildCmd);
|
|
103
|
+
dictionariesBuildCmd.action((options) => {
|
|
104
|
+
build({
|
|
105
|
+
...options,
|
|
106
|
+
configOptions: extractConfigOptions(options)
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
const rootBuildCmd = program.command("build").description(buildOptions.description);
|
|
110
|
+
applyOptions(rootBuildCmd, buildOptions.options);
|
|
111
|
+
applyConfigOptions(rootBuildCmd);
|
|
112
|
+
rootBuildCmd.action((options) => {
|
|
113
|
+
build({
|
|
114
|
+
...options,
|
|
115
|
+
configOptions: extractConfigOptions(options)
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
const pullOptions = {
|
|
119
|
+
description: "Pull dictionaries from the server",
|
|
120
|
+
options: [
|
|
121
|
+
["-d, --dictionaries [ids...]", "List of dictionary IDs to pull"],
|
|
122
|
+
["--newDictionariesPath [path]", "Path to save the new dictionaries"]
|
|
123
|
+
]
|
|
124
|
+
};
|
|
125
|
+
const dictionariesPullCmd = dictionariesProgram.command("pull").description(pullOptions.description);
|
|
126
|
+
applyOptions(dictionariesPullCmd, pullOptions.options);
|
|
127
|
+
applyConfigOptions(dictionariesPullCmd);
|
|
128
|
+
dictionariesPullCmd.action((options) => {
|
|
129
|
+
pull({
|
|
130
|
+
...options,
|
|
131
|
+
configOptions: {
|
|
132
|
+
...options.configOptions,
|
|
133
|
+
baseDir: options.baseDir
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
const rootPullCmd = program.command("pull").description(pullOptions.description);
|
|
138
|
+
applyOptions(rootPullCmd, pullOptions.options);
|
|
139
|
+
applyConfigOptions(rootPullCmd);
|
|
140
|
+
rootPullCmd.action((options) => {
|
|
141
|
+
pull({
|
|
142
|
+
...options,
|
|
143
|
+
configOptions: extractConfigOptions(options)
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
const pushOptions = {
|
|
147
|
+
description: "Push all dictionaries. Create or update the pushed dictionaries",
|
|
148
|
+
options: [
|
|
149
|
+
["-d, --dictionaries [ids...]", "List of dictionary IDs to push"],
|
|
150
|
+
[
|
|
151
|
+
"-r, --deleteLocaleDictionary",
|
|
152
|
+
"Delete the local dictionaries after pushing"
|
|
153
|
+
],
|
|
154
|
+
[
|
|
155
|
+
"-k, --keepLocaleDictionary",
|
|
156
|
+
"Keep the local dictionaries after pushing"
|
|
157
|
+
]
|
|
158
|
+
]
|
|
159
|
+
};
|
|
160
|
+
const dictionariesPushCmd = dictionariesProgram.command("push").description(pushOptions.description);
|
|
161
|
+
applyOptions(dictionariesPushCmd, pushOptions.options);
|
|
162
|
+
applyConfigOptions(dictionariesPushCmd);
|
|
163
|
+
applyGitOptions(dictionariesPushCmd);
|
|
164
|
+
dictionariesPushCmd.action(
|
|
165
|
+
(options) => push({
|
|
166
|
+
...options,
|
|
167
|
+
gitOptions: extractGitOptions(options),
|
|
168
|
+
configOptions: extractConfigOptions(options)
|
|
169
|
+
})
|
|
170
|
+
);
|
|
171
|
+
const rootPushCmd = program.command("push").description(pushOptions.description);
|
|
172
|
+
applyOptions(rootPushCmd, pushOptions.options);
|
|
173
|
+
applyConfigOptions(rootPushCmd);
|
|
174
|
+
applyGitOptions(rootPushCmd);
|
|
175
|
+
rootPushCmd.action(
|
|
176
|
+
(options) => push({
|
|
177
|
+
...options,
|
|
178
|
+
gitOptions: extractGitOptions(options),
|
|
179
|
+
configOptions: extractConfigOptions(options)
|
|
180
|
+
})
|
|
181
|
+
);
|
|
24
182
|
const configurationProgram = program.command("configuration").alias("config").alias("conf").description("Configuration operations");
|
|
25
|
-
configurationProgram.command("get").description("Get the configuration")
|
|
26
|
-
|
|
183
|
+
const configGetCmd = configurationProgram.command("get").description("Get the configuration");
|
|
184
|
+
applyConfigOptions(configGetCmd);
|
|
185
|
+
configGetCmd.action((options) => {
|
|
186
|
+
getConfig({
|
|
187
|
+
...options,
|
|
188
|
+
configOptions: extractConfigOptions(options)
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
const configPushCmd = configurationProgram.command("push").description("Push the configuration");
|
|
192
|
+
applyConfigOptions(configPushCmd);
|
|
193
|
+
configPushCmd.action((options) => {
|
|
194
|
+
pushConfig({
|
|
195
|
+
...options,
|
|
196
|
+
configOptions: extractConfigOptions(options)
|
|
197
|
+
});
|
|
198
|
+
});
|
|
27
199
|
program.command("content list").description("List the content declaration files").action(listContentDeclaration);
|
|
28
|
-
program.command("
|
|
29
|
-
"--
|
|
30
|
-
"
|
|
31
|
-
).option(
|
|
200
|
+
const fillProgram = program.command("fill").description("Fill the dictionaries").option("-f, --file [files...]", "List of Dictionary files to fill").option("--source-locale [sourceLocale]", "Source locale to translate from").option(
|
|
201
|
+
"--output-locales [outputLocales...]",
|
|
202
|
+
"Target locales to translate to"
|
|
203
|
+
).option(
|
|
204
|
+
"--mode [mode]",
|
|
205
|
+
"Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys",
|
|
206
|
+
"review"
|
|
207
|
+
).option("--keys [keys...]", "Filter dictionaries based on keys").option(
|
|
208
|
+
"--excluded-keys [excludedKeys...]",
|
|
209
|
+
"Filter out dictionaries based on keys"
|
|
210
|
+
).option(
|
|
211
|
+
"--path-filter [pathFilters...]",
|
|
212
|
+
"Filter dictionaries based on glob pattern"
|
|
213
|
+
);
|
|
214
|
+
applyConfigOptions(fillProgram);
|
|
215
|
+
applyAIOptions(fillProgram);
|
|
216
|
+
applyGitOptions(fillProgram);
|
|
217
|
+
fillProgram.action(
|
|
218
|
+
(options) => fill({
|
|
219
|
+
...options,
|
|
220
|
+
aiOptions: extractAiOptions(options),
|
|
221
|
+
gitOptions: extractGitOptions(options),
|
|
222
|
+
configOptions: extractConfigOptions(options)
|
|
223
|
+
})
|
|
224
|
+
);
|
|
32
225
|
program.parse(process.argv);
|
|
33
226
|
return program;
|
|
34
227
|
};
|
package/dist/esm/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { audit } from './audit';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { pull } from './pull';\nimport { push } from './push';\nimport { pushConfig } from './pushConfig';\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version('1.0.0').description('Intlayer CLI');\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n dictionariesProgram\n .command('build')\n .description('Build the dictionaries')\n .option('-w, --watch', 'Watch for changes')\n .option('-e, --env [env]', 'Environment')\n .action(build);\n\n dictionariesProgram\n .command('pull')\n .option('-d, --dictionaries [ids...]', 'List of dictionary IDs to pull')\n .option('--newDictionariesPath [path]', 'Path to save the new dictionaries')\n .option('-e, --env [env]', 'Environment')\n .action(pull);\n\n // Define the main `push` command\n dictionariesProgram\n .command('push')\n .description(\n 'Push all dictionaries. Create or update the pushed dictionaries'\n )\n .option('-d, --dictionaries [ids...]', 'List of dictionary IDs to push')\n .option(\n '-r, --deleteLocaleDictionary',\n 'Delete the local dictionaries after pushing'\n )\n .option(\n '-k, --keepLocaleDictionary',\n 'Keep the local dictionaries after pushing'\n )\n .option('-e, --env [env]', 'Environment')\n .action(push);\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n configurationProgram\n .command('get')\n .description('Get the configuration')\n .option('--env-file [envFile]', 'Environment file')\n .option('--verbose', 'Verbose')\n .option('-e, --env [env]', 'Environment')\n .action(getConfig);\n\n // Define the `push config` subcommand and add it to the `push` command\n configurationProgram\n .command('push')\n .description('Push the configuration')\n .option('--env-file [envFile]', 'Environment file')\n .option('--verbose', 'Verbose')\n .option('-e, --env [env]', 'Environment')\n .action(pushConfig);\n\n /**\n * CONTENT DECLARATION\n */\n\n program\n .command('content list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n program\n .command('audit')\n .description('Audit the dictionaries')\n .option('-f, --files [files...]', 'List of Dictionary files to audit')\n .option(\n '--exclude [excludedGlobs...]',\n 'Globs pattern to exclude from the audit'\n )\n .option('-m, --model [model]', 'Model')\n .option('-p, --custom-prompt [prompt]', 'Custom prompt')\n .option('-l, --async-limit [asyncLimit]', 'Async limit')\n .option('-k, --open-ai-api-key [openAiApiKey]', 'OpenAI API key')\n .option('-e, --env [env]', 'Environment')\n .action(audit);\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":"AAAA,SAAS,eAAe;AACxB,SAAS,aAAa;AACtB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAUpB,MAAM,SAAS,MAAe;AACnC,QAAM,UAAU,IAAI,QAAQ;AAE5B,UAAQ,QAAQ,OAAO,EAAE,YAAY,cAAc;AAMnD,QAAM,sBAAsB,QACzB,QAAQ,YAAY,EACpB,MAAM,cAAc,EACpB,MAAM,KAAK,EACX,YAAY,yBAAyB;AAExC,sBACG,QAAQ,OAAO,EACf,YAAY,wBAAwB,EACpC,OAAO,eAAe,mBAAmB,EACzC,OAAO,mBAAmB,aAAa,EACvC,OAAO,KAAK;AAEf,sBACG,QAAQ,MAAM,EACd,OAAO,+BAA+B,gCAAgC,EACtE,OAAO,gCAAgC,mCAAmC,EAC1E,OAAO,mBAAmB,aAAa,EACvC,OAAO,IAAI;AAGd,sBACG,QAAQ,MAAM,EACd;AAAA,IACC;AAAA,EACF,EACC,OAAO,+BAA+B,gCAAgC,EACtE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,mBAAmB,aAAa,EACvC,OAAO,IAAI;AAOd,QAAM,uBAAuB,QAC1B,QAAQ,eAAe,EACvB,MAAM,QAAQ,EACd,MAAM,MAAM,EACZ,YAAY,0BAA0B;AAEzC,uBACG,QAAQ,KAAK,EACb,YAAY,uBAAuB,EACnC,OAAO,wBAAwB,kBAAkB,EACjD,OAAO,aAAa,SAAS,EAC7B,OAAO,mBAAmB,aAAa,EACvC,OAAO,SAAS;AAGnB,uBACG,QAAQ,MAAM,EACd,YAAY,wBAAwB,EACpC,OAAO,wBAAwB,kBAAkB,EACjD,OAAO,aAAa,SAAS,EAC7B,OAAO,mBAAmB,aAAa,EACvC,OAAO,UAAU;AAMpB,UACG,QAAQ,cAAc,EACtB,YAAY,oCAAoC,EAChD,OAAO,sBAAsB;AAEhC,UACG,QAAQ,OAAO,EACf,YAAY,wBAAwB,EACpC,OAAO,0BAA0B,mCAAmC,EACpE;AAAA,IACC;AAAA,IACA;AAAA,EACF,EACC,OAAO,uBAAuB,OAAO,EACrC,OAAO,gCAAgC,eAAe,EACtD,OAAO,kCAAkC,aAAa,EACtD,OAAO,wCAAwC,gBAAgB,EAC/D,OAAO,mBAAmB,aAAa,EACvC,OAAO,KAAK;AAEf,UAAQ,MAAM,QAAQ,IAAI;AAE1B,SAAO;AACT;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/cli.ts"],"sourcesContent":["import type { AIOptions } from '@intlayer/api';\nimport { GetConfigurationOptions } from '@intlayer/config';\nimport configuration from '@intlayer/config/built';\nimport { Command } from 'commander';\nimport {\n DiffMode,\n ListGitFilesOptions,\n} from '../../chokidar/dist/types/listGitFiles';\nimport { build } from './build';\nimport { getConfig } from './config';\nimport { fill, FillOptions } from './fill';\nimport { listContentDeclaration } from './listContentDeclaration';\nimport { pull } from './pull';\nimport { push } from './push';\nimport { pushConfig } from './pushConfig';\n\nconst configurationOptions = [\n ['--env-file [envFile]', 'Environment file'],\n ['-e, --env [env]', 'Environment'],\n ['--base-dir [baseDir]', 'Base directory'],\n ['--verbose', 'Verbose'],\n];\n\nconst aiOptions = [\n ['--provider [provider]', 'Provider'],\n ['--temperature [temperature]', 'Temperature'],\n ['--model [model]', 'Model'],\n ['--api-key [apiKey]', 'Provider API key'],\n ['--custom-prompt [prompt]', 'Custom prompt'],\n ['--application-context [applicationContext]', 'Application context'],\n];\n\nconst gitOptions = [\n ['--git-diff [gitDiff]', 'Git diff mode - Check git diff between two refs'],\n ['--git-diff-base [gitDiffBase]', 'Git diff base ref'],\n ['--git-diff-current [gitDiffCurrent]', 'Git diff current ref'],\n ['--uncommitted [uncommitted]', 'Uncommitted'],\n ['--unpushed [unpushed]', 'Unpushed'],\n ['--untracked [untracked]', 'Untracked'],\n];\n\n/**\n * Helper functions to apply common options to commands\n */\nconst applyOptions = (command: Command, options: string[][]) => {\n options.forEach(([flag, description]) => command.option(flag, description));\n return command;\n};\n\nconst applyConfigOptions = (command: Command) =>\n applyOptions(command, configurationOptions);\nconst applyAIOptions = (command: Command) => applyOptions(command, aiOptions);\nconst applyGitOptions = (command: Command) => applyOptions(command, gitOptions);\n\nconst extractAiOptions = (options: AIOptions) => {\n const isOptionEmpty = !Object.values(options).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { apiKey, provider, model, temperature, applicationContext } = options;\n\n return {\n apiKey: apiKey ?? configuration.ai?.apiKey,\n provider: provider ?? configuration.ai?.provider,\n model: model ?? configuration.ai?.model,\n temperature: temperature ?? configuration.ai?.temperature,\n applicationContext:\n applicationContext ?? configuration.ai?.applicationContext,\n };\n};\n\ntype GitOptions = {\n gitDiff?: boolean;\n gitDiffBase?: string;\n gitDiffCurrent?: string;\n uncommitted?: boolean;\n unpushed?: boolean;\n untracked?: boolean;\n};\n\nconst extractGitOptions = (\n options: GitOptions\n): ListGitFilesOptions | undefined => {\n const isOptionEmpty = !Object.values(options).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const {\n gitDiff,\n gitDiffBase,\n gitDiffCurrent,\n uncommitted,\n unpushed,\n untracked,\n } = options;\n\n const mode = [\n gitDiff && 'gitDiff',\n uncommitted && 'uncommitted',\n unpushed && 'unpushed',\n untracked && 'untracked',\n ].filter(Boolean) as DiffMode[];\n\n return {\n mode,\n baseRef: gitDiffBase,\n currentRef: gitDiffCurrent,\n absolute: true,\n };\n};\n\nconst extractConfigOptions = (\n options: GetConfigurationOptions\n): GetConfigurationOptions | undefined => {\n const isOptionEmpty = !Object.values(options).some(Boolean);\n\n if (isOptionEmpty) {\n return undefined;\n }\n\n const { baseDir, verbose, env, envFile } = options;\n\n return {\n baseDir,\n verbose,\n env,\n envFile,\n };\n};\n\n/**\n * Set the API for the CLI\n *\n * Example of commands:\n *\n * npm run intlayer build --watch\n * npm run intlayer push --dictionaries id1 id2 id3 --deleteLocaleDir\n */\nexport const setAPI = (): Command => {\n const program = new Command();\n\n program.version('1.0.0').description('Intlayer CLI');\n\n /**\n * DICTIONARIES\n */\n\n const dictionariesProgram = program\n .command('dictionary')\n .alias('dictionaries')\n .alias('dic')\n .description('Dictionaries operations');\n\n // Dictionary build command\n const buildOptions = {\n description: 'Build the dictionaries',\n options: [['-w, --watch', 'Watch for changes']],\n };\n\n // Add build command to dictionaries program\n const dictionariesBuildCmd = dictionariesProgram\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(dictionariesBuildCmd, buildOptions.options);\n applyConfigOptions(dictionariesBuildCmd);\n dictionariesBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Add build command to root program as well\n const rootBuildCmd = program\n .command('build')\n .description(buildOptions.description);\n\n applyOptions(rootBuildCmd, buildOptions.options);\n applyConfigOptions(rootBuildCmd);\n rootBuildCmd.action((options) => {\n build({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary pull command\n const pullOptions = {\n description: 'Pull dictionaries from the server',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to pull'],\n ['--newDictionariesPath [path]', 'Path to save the new dictionaries'],\n ],\n };\n\n // Add pull command to dictionaries program\n const dictionariesPullCmd = dictionariesProgram\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(dictionariesPullCmd, pullOptions.options);\n applyConfigOptions(dictionariesPullCmd);\n dictionariesPullCmd.action((options) => {\n pull({\n ...options,\n configOptions: {\n ...options.configOptions,\n baseDir: options.baseDir,\n },\n });\n });\n\n // Add pull command to root program as well\n const rootPullCmd = program\n .command('pull')\n .description(pullOptions.description);\n\n applyOptions(rootPullCmd, pullOptions.options);\n applyConfigOptions(rootPullCmd);\n rootPullCmd.action((options) => {\n pull({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Dictionary push command\n const pushOptions = {\n description:\n 'Push all dictionaries. Create or update the pushed dictionaries',\n options: [\n ['-d, --dictionaries [ids...]', 'List of dictionary IDs to push'],\n [\n '-r, --deleteLocaleDictionary',\n 'Delete the local dictionaries after pushing',\n ],\n [\n '-k, --keepLocaleDictionary',\n 'Keep the local dictionaries after pushing',\n ],\n ],\n };\n\n // Add push command to dictionaries program\n const dictionariesPushCmd = dictionariesProgram\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(dictionariesPushCmd, pushOptions.options);\n applyConfigOptions(dictionariesPushCmd);\n applyGitOptions(dictionariesPushCmd);\n\n dictionariesPushCmd.action((options) =>\n push({\n ...options,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n // Add push command to root program as well\n const rootPushCmd = program\n .command('push')\n .description(pushOptions.description);\n\n applyOptions(rootPushCmd, pushOptions.options);\n applyConfigOptions(rootPushCmd);\n applyGitOptions(rootPushCmd);\n\n rootPushCmd.action((options) =>\n push({\n ...options,\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n /**\n * CONFIGURATION\n */\n\n // Define the parent command\n const configurationProgram = program\n .command('configuration')\n .alias('config')\n .alias('conf')\n .description('Configuration operations');\n\n const configGetCmd = configurationProgram\n .command('get')\n .description('Get the configuration');\n\n applyConfigOptions(configGetCmd);\n configGetCmd.action((options) => {\n getConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n // Define the `push config` subcommand and add it to the `push` command\n const configPushCmd = configurationProgram\n .command('push')\n .description('Push the configuration');\n\n applyConfigOptions(configPushCmd);\n configPushCmd.action((options) => {\n pushConfig({\n ...options,\n configOptions: extractConfigOptions(options),\n });\n });\n\n /**\n * CONTENT DECLARATION\n */\n\n program\n .command('content list')\n .description('List the content declaration files')\n .action(listContentDeclaration);\n\n const fillProgram = program\n .command('fill')\n .description('Fill the dictionaries')\n .option('-f, --file [files...]', 'List of Dictionary files to fill')\n .option('--source-locale [sourceLocale]', 'Source locale to translate from')\n .option(\n '--output-locales [outputLocales...]',\n 'Target locales to translate to'\n )\n .option(\n '--mode [mode]',\n 'Fill mode: complete, review. Complete will fill all missing content, review will fill missing content and review existing keys',\n 'review'\n )\n .option('--keys [keys...]', 'Filter dictionaries based on keys')\n .option(\n '--excluded-keys [excludedKeys...]',\n 'Filter out dictionaries based on keys'\n )\n .option(\n '--path-filter [pathFilters...]',\n 'Filter dictionaries based on glob pattern'\n );\n\n applyConfigOptions(fillProgram);\n applyAIOptions(fillProgram);\n applyGitOptions(fillProgram);\n\n fillProgram.action((options) =>\n fill({\n ...options,\n aiOptions: extractAiOptions(options),\n gitOptions: extractGitOptions(options),\n configOptions: extractConfigOptions(options),\n } as FillOptions)\n );\n\n program.parse(process.argv);\n\n return program;\n};\n"],"mappings":"AAEA,OAAO,mBAAmB;AAC1B,SAAS,eAAe;AAKxB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,YAAyB;AAClC,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAE3B,MAAM,uBAAuB;AAAA,EAC3B,CAAC,wBAAwB,kBAAkB;AAAA,EAC3C,CAAC,mBAAmB,aAAa;AAAA,EACjC,CAAC,wBAAwB,gBAAgB;AAAA,EACzC,CAAC,aAAa,SAAS;AACzB;AAEA,MAAM,YAAY;AAAA,EAChB,CAAC,yBAAyB,UAAU;AAAA,EACpC,CAAC,+BAA+B,aAAa;AAAA,EAC7C,CAAC,mBAAmB,OAAO;AAAA,EAC3B,CAAC,sBAAsB,kBAAkB;AAAA,EACzC,CAAC,4BAA4B,eAAe;AAAA,EAC5C,CA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,MACH,GAAG;AAAA,MACH,WAAW,iBAAiB,OAAO;AAAA,MACnC,YAAY,kBAAkB,OAAO;AAAA,MACrC,eAAe,qBAAqB,OAAO;AAAA,IAC7C,CAAgB;AAAA,EAClB;AAEA,UAAQ,MAAM,QAAQ,IAAI;AAE1B,SAAO;AACT;","names":[]}
|
package/dist/esm/config.mjs
CHANGED
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
getConfiguration
|
|
3
|
-
logger
|
|
2
|
+
getConfiguration
|
|
4
3
|
} from "@intlayer/config";
|
|
4
|
+
import { appLogger } from "@intlayer/config/client";
|
|
5
5
|
const getConfig = (options) => {
|
|
6
|
-
const config = getConfiguration(options);
|
|
7
|
-
|
|
8
|
-
config: {
|
|
9
|
-
prefix: options?.logPrefix
|
|
10
|
-
}
|
|
11
|
-
});
|
|
6
|
+
const config = getConfiguration(options?.configOptions);
|
|
7
|
+
appLogger(JSON.stringify(config, null, 2));
|
|
12
8
|
};
|
|
13
9
|
export {
|
|
14
10
|
getConfig
|
package/dist/esm/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config.ts"],"sourcesContent":["import {\n getConfiguration,\n type GetConfigurationOptions,\n
|
|
1
|
+
{"version":3,"sources":["../../src/config.ts"],"sourcesContent":["import {\n getConfiguration,\n type GetConfigurationOptions,\n} from '@intlayer/config';\nimport { appLogger } from '@intlayer/config/client';\n\ntype ConfigOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const getConfig = (options?: ConfigOptions) => {\n const config = getConfiguration(options?.configOptions);\n\n appLogger(JSON.stringify(config, null, 2));\n};\n"],"mappings":"AAAA;AAAA,EACE;AAAA,OAEK;AACP,SAAS,iBAAiB;AAMnB,MAAM,YAAY,CAAC,YAA4B;AACpD,QAAM,SAAS,iBAAiB,SAAS,aAAa;AAEtD,YAAU,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAC3C;","names":[]}
|