@intlayer/cli 8.10.0-canary.1 → 8.10.1
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/auth/login.cjs +2 -2
- package/dist/cjs/auth/login.cjs.map +1 -1
- package/dist/cjs/config.cjs +7 -1
- package/dist/cjs/config.cjs.map +1 -1
- package/dist/cjs/push/push.cjs +17 -25
- package/dist/cjs/push/push.cjs.map +1 -1
- package/dist/cjs/pushConfig.cjs +5 -2
- package/dist/cjs/pushConfig.cjs.map +1 -1
- package/dist/cjs/pushLog.cjs +5 -2
- package/dist/cjs/pushLog.cjs.map +1 -1
- package/dist/cjs/utils/checkAccess.cjs +32 -25
- package/dist/cjs/utils/checkAccess.cjs.map +1 -1
- package/dist/esm/auth/login.mjs +2 -2
- package/dist/esm/auth/login.mjs.map +1 -1
- package/dist/esm/config.mjs +7 -1
- package/dist/esm/config.mjs.map +1 -1
- package/dist/esm/push/push.mjs +17 -25
- package/dist/esm/push/push.mjs.map +1 -1
- package/dist/esm/pushConfig.mjs +6 -3
- package/dist/esm/pushConfig.mjs.map +1 -1
- package/dist/esm/pushLog.mjs +5 -2
- package/dist/esm/pushLog.mjs.map +1 -1
- package/dist/esm/utils/checkAccess.mjs +32 -25
- package/dist/esm/utils/checkAccess.mjs.map +1 -1
- package/dist/types/auth/login.d.ts +8 -1
- package/dist/types/auth/login.d.ts.map +1 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/listContentDeclaration.d.ts +2 -2
- package/dist/types/push/push.d.ts.map +1 -1
- package/dist/types/pushConfig.d.ts.map +1 -1
- package/dist/types/pushLog.d.ts +1 -1
- package/dist/types/pushLog.d.ts.map +1 -1
- package/dist/types/utils/checkAccess.d.ts +1 -1
- package/dist/types/utils/checkAccess.d.ts.map +1 -1
- package/package.json +13 -13
package/dist/esm/config.mjs
CHANGED
|
@@ -3,10 +3,16 @@ import { colorizeObject, getAppLogger } from "@intlayer/config/logger";
|
|
|
3
3
|
import { getConfiguration } from "@intlayer/config/node";
|
|
4
4
|
|
|
5
5
|
//#region src/config.ts
|
|
6
|
+
const sanitize = (value) => {
|
|
7
|
+
if (typeof value === "function" || typeof value === "undefined") return null;
|
|
8
|
+
if (Array.isArray(value)) return value.map(sanitize);
|
|
9
|
+
if (value !== null && typeof value === "object") return Object.fromEntries(Object.entries(value).filter(([, v]) => typeof v !== "function" && typeof v !== "undefined").map(([k, v]) => [k, sanitize(v)]));
|
|
10
|
+
return value;
|
|
11
|
+
};
|
|
6
12
|
const getConfig = (options) => {
|
|
7
13
|
const config = getConfiguration(options?.configOptions);
|
|
8
14
|
logConfigDetails(options?.configOptions);
|
|
9
|
-
getAppLogger(config)(colorizeObject(config));
|
|
15
|
+
getAppLogger(config)(colorizeObject(sanitize(config)));
|
|
10
16
|
};
|
|
11
17
|
|
|
12
18
|
//#endregion
|
package/dist/esm/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { colorizeObject, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\n\ntype ConfigOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const getConfig = (options?: ConfigOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n appLogger(colorizeObject(config));\n};\n"],"mappings":";;;;;AAWA,MAAa,aAAa,YAA4B;CACpD,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAIvC,AAFkB,aAAa,MAEvB,EAAE,eAAe,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../../src/config.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { colorizeObject, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\n\ntype ConfigOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nconst sanitize = (value: unknown): unknown => {\n if (typeof value === 'function' || typeof value === 'undefined') return null;\n if (Array.isArray(value)) return value.map(sanitize);\n if (value !== null && typeof value === 'object') {\n return Object.fromEntries(\n Object.entries(value as Record<string, unknown>)\n .filter(([, v]) => typeof v !== 'function' && typeof v !== 'undefined')\n .map(([k, v]) => [k, sanitize(v)])\n );\n }\n return value;\n};\n\nexport const getConfig = (options?: ConfigOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n appLogger(colorizeObject(sanitize(config) as typeof config));\n};\n"],"mappings":";;;;;AAWA,MAAM,YAAY,UAA4B;CAC5C,IAAI,OAAO,UAAU,cAAc,OAAO,UAAU,aAAa,OAAO;CACxE,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,QAAQ;CACnD,IAAI,UAAU,QAAQ,OAAO,UAAU,UACrC,OAAO,OAAO,YACZ,OAAO,QAAQ,KAAgC,EAC5C,QAAQ,GAAG,OAAO,OAAO,MAAM,cAAc,OAAO,MAAM,WAAW,EACrE,KAAK,CAAC,GAAG,OAAO,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CACrC;CAEF,OAAO;AACT;AAEA,MAAa,aAAa,YAA4B;CACpD,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAIvC,AAFkB,aAAa,MAEvB,EAAE,eAAe,SAAS,MAAM,CAAkB,CAAC;AAC7D"}
|
package/dist/esm/push/push.mjs
CHANGED
|
@@ -20,6 +20,10 @@ const statusIconsAndColors = {
|
|
|
20
20
|
icon: "✔",
|
|
21
21
|
color: ANSIColors.GREEN
|
|
22
22
|
},
|
|
23
|
+
"up-to-date": {
|
|
24
|
+
icon: "=",
|
|
25
|
+
color: ANSIColors.GREY
|
|
26
|
+
},
|
|
23
27
|
error: {
|
|
24
28
|
icon: "✖",
|
|
25
29
|
color: ANSIColors.RED
|
|
@@ -46,34 +50,11 @@ const push = async (options) => {
|
|
|
46
50
|
const intlayerAPI = await getAuthenticatedAPI(config);
|
|
47
51
|
const unmergedDictionariesRecord = getUnmergedDictionaries(config);
|
|
48
52
|
const allDictionaries = Object.values(unmergedDictionariesRecord).flat();
|
|
49
|
-
const
|
|
53
|
+
const selectedCustomLocations = Array.from(new Set(allDictionaries.map((dictionary) => dictionary.location).filter((location) => location && ![
|
|
50
54
|
"remote",
|
|
51
55
|
"local",
|
|
52
56
|
"hybrid"
|
|
53
57
|
].includes(location))));
|
|
54
|
-
let selectedCustomLocations = [];
|
|
55
|
-
if (customLocations.length > 0) {
|
|
56
|
-
const { multiselect, confirm, isCancel } = await import("@clack/prompts");
|
|
57
|
-
if (customLocations.length === 1) {
|
|
58
|
-
const shouldPush = await confirm({
|
|
59
|
-
message: `Do you want to push dictionaries with custom location ${colorize(customLocations[0], ANSIColors.BLUE, ANSIColors.RESET)}?`,
|
|
60
|
-
initialValue: false
|
|
61
|
-
});
|
|
62
|
-
if (isCancel(shouldPush)) return;
|
|
63
|
-
if (shouldPush) selectedCustomLocations = [customLocations[0]];
|
|
64
|
-
} else {
|
|
65
|
-
const selected = await multiselect({
|
|
66
|
-
message: "Select custom locations to push:",
|
|
67
|
-
options: customLocations.map((location) => ({
|
|
68
|
-
value: location,
|
|
69
|
-
label: location
|
|
70
|
-
})),
|
|
71
|
-
required: false
|
|
72
|
-
});
|
|
73
|
-
if (isCancel(selected)) return;
|
|
74
|
-
selectedCustomLocations = selected;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
58
|
let dictionaries = allDictionaries.filter((dictionary) => {
|
|
78
59
|
const location = dictionary.location ?? config.dictionary?.location ?? "local";
|
|
79
60
|
return location === "remote" || location === "hybrid" || selectedCustomLocations.includes(location);
|
|
@@ -118,7 +99,12 @@ const push = async (options) => {
|
|
|
118
99
|
const pushResult = await intlayerAPI.dictionary.pushDictionaries([statusObj.dictionary]);
|
|
119
100
|
const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];
|
|
120
101
|
const newDictionaries = pushResult.data?.newDictionaries ?? [];
|
|
121
|
-
const
|
|
102
|
+
const upToDateDictionaries = pushResult.data?.upToDateDictionaries ?? [];
|
|
103
|
+
const allDictionaries = [
|
|
104
|
+
...updatedDictionaries,
|
|
105
|
+
...newDictionaries,
|
|
106
|
+
...upToDateDictionaries
|
|
107
|
+
];
|
|
122
108
|
for (const remoteDictionaryData of allDictionaries) {
|
|
123
109
|
const localDictionary = unmergedDictionariesRecord[remoteDictionaryData.key]?.find((dictionary) => dictionary.localId === remoteDictionaryData.localId);
|
|
124
110
|
if (!localDictionary) continue;
|
|
@@ -141,6 +127,12 @@ const push = async (options) => {
|
|
|
141
127
|
dictionaryKey: statusObj.dictionary.key,
|
|
142
128
|
status: "pushed"
|
|
143
129
|
}]);
|
|
130
|
+
} else if (upToDateDictionaries.some((dictionary) => dictionary.key === statusObj.dictionary.key)) {
|
|
131
|
+
statusObj.status = "up-to-date";
|
|
132
|
+
logger.update([{
|
|
133
|
+
dictionaryKey: statusObj.dictionary.key,
|
|
134
|
+
status: "up-to-date"
|
|
135
|
+
}]);
|
|
144
136
|
} else statusObj.status = "unknown";
|
|
145
137
|
} catch (error) {
|
|
146
138
|
statusObj.status = "error";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.mjs","names":[],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport { formatPath, parallelize } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status: 'pending' | 'pushing' | 'modified' | 'pushed' | 'unknown' | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n let selectedCustomLocations: string[] = [];\n\n if (customLocations.length > 0) {\n const { multiselect, confirm, isCancel } = await import('@clack/prompts');\n\n if (customLocations.length === 1) {\n const shouldPush = await confirm({\n message: `Do you want to push dictionaries with custom location ${colorize(customLocations[0], ANSIColors.BLUE, ANSIColors.RESET)}?`,\n initialValue: false,\n });\n\n if (isCancel(shouldPush)) {\n return;\n }\n\n if (shouldPush) {\n selectedCustomLocations = [customLocations[0]];\n }\n } else {\n const selected = await multiselect({\n message: 'Select custom locations to push:',\n options: customLocations.map((location) => ({\n value: location,\n label: location,\n })),\n required: false,\n });\n\n if (isCancel(selected)) {\n return;\n }\n\n selectedCustomLocations = selected as string[];\n }\n }\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\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 dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\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) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n\n const allDictionaries = [...updatedDictionaries, ...newDictionaries];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\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 logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\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 remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await import('@clack/prompts');\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\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(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;AAwCA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC/C,OAAO;EAAE,MAAM;EAAK,OAAO,WAAW;CAAI;C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iBAAiB,SAAS,aACL,CAAC;CAGrC,MAAM,+BAA4B,IAAI,IAAI;CAE1C,KAAK,MAAM,cAAc,sBAAsB;EAC7C,MAAM,EAAE,aAAa;EAErB,IAAI,CAAC,UAAU;GACb,UACE,cAAc,YAAY,WAAW,GAAG,EAAE,6BAC1C,EACE,OAAO,QACT,CACF;GACA;EACF;EAEA,aAAa,IAAI,QAAQ;CAC3B;CAEA,KAAK,MAAM,YAAY,cACrB,IAAI;EACF,MAAM,QAAQ,MAAM,WAAW,MAAM,QAAQ;EAE7C,IAAI,MAAM,OAAO,GAAG;GAClB,MAAM,WAAW,OAAO,QAAQ;GAChC,UAAU,gBAAgB,WAAW,QAAQ,KAAK,CAAC,CAAC;EACtD,OAAO,IAAI,MAAM,YAAY,GAC3B,UAAU,uBAAuB,WAAW,QAAQ,EAAE,cAAc,CAAC,CAAC;OAEtE,UACE,yBAAyB,WAAW,QAAQ,EAAE,cAC9C,CAAC,CACH;CAEJ,SAAS,KAAK;EACZ,UAAU,kBAAkB,WAAW,QAAQ,EAAE,IAAI,OAAO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
|
1
|
+
{"version":3,"file":"push.mjs","names":[],"sources":["../../../src/push/push.ts"],"sourcesContent":["import * as fsPromises from 'node:fs/promises';\nimport { join } from 'node:path';\nimport {\n prepareIntlayer,\n writeContentDeclaration,\n} from '@intlayer/chokidar/build';\nimport {\n type ListGitFilesOptions,\n listGitFiles,\n logConfigDetails,\n} from '@intlayer/chokidar/cli';\nimport { formatPath, parallelize } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, colorizeKey, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport { PushLogger, type PushStatus } from '../pushLog';\nimport { checkCMSAuth, getAuthenticatedAPI } from '../utils/checkAccess';\n\ntype PushOptions = {\n deleteLocaleDictionary?: boolean;\n keepLocaleDictionary?: boolean;\n dictionaries?: string[];\n gitOptions?: ListGitFilesOptions;\n configOptions?: GetConfigurationOptions;\n build?: boolean;\n};\n\ntype DictionariesStatus = {\n dictionary: Dictionary;\n status:\n | 'pending'\n | 'pushing'\n | 'modified'\n | 'pushed'\n | 'up-to-date'\n | 'unknown'\n | 'error';\n error?: Error;\n errorMessage?: string;\n};\n\n// Print per-dictionary summary similar to loadDictionaries\nconst statusIconsAndColors = {\n pushed: { icon: '✔', color: ANSIColors.GREEN },\n modified: { icon: '✔', color: ANSIColors.GREEN },\n 'up-to-date': { icon: '=', color: ANSIColors.GREY },\n error: { icon: '✖', color: ANSIColors.RED },\n default: { icon: '⏲', color: ANSIColors.BLUE },\n};\n\nconst getIconAndColor = (status: DictionariesStatus['status']) => {\n return (\n statusIconsAndColors[status as keyof typeof statusIconsAndColors] ??\n statusIconsAndColors.default\n );\n};\n\n/**\n * Get all local dictionaries and push them simultaneously.\n */\nexport const push = async (options?: PushOptions): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n if (options?.build === true) {\n await prepareIntlayer(config, { forceRun: true });\n } else if (typeof options?.build === 'undefined') {\n await prepareIntlayer(config);\n }\n\n try {\n const hasCMSAuth = await checkCMSAuth(config);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n const unmergedDictionariesRecord = getUnmergedDictionaries(config);\n const allDictionaries = Object.values(unmergedDictionariesRecord).flat();\n\n const customLocations = Array.from(\n new Set(\n allDictionaries\n .map((dictionary) => dictionary.location)\n .filter(\n (location) =>\n location && !['remote', 'local', 'hybrid'].includes(location)\n )\n )\n ) as string[];\n\n // Include all custom locations automatically — no interactive prompt needed.\n const selectedCustomLocations: string[] = customLocations;\n\n let dictionaries: Dictionary[] = allDictionaries.filter((dictionary) => {\n const location =\n dictionary.location ?? config.dictionary?.location ?? 'local';\n\n return (\n location === 'remote' ||\n location === 'hybrid' ||\n selectedCustomLocations.includes(location)\n );\n });\n\n // Check if the dictionaries list is empty after filtering by location\n if (dictionaries.length === 0) {\n appLogger(\n `No dictionaries found to push. Only dictionaries with location ${colorize('remote', ANSIColors.BLUE, ANSIColors.RESET)}, ${colorize('hybrid', ANSIColors.BLUE, ANSIColors.RESET)} or selected custom locations are pushed.`,\n { level: 'warn' }\n );\n appLogger(\n `You can set the location in your dictionary file (e.g. ${colorize(\"{ key: 'my-key', location: 'hybrid', ... }\", ANSIColors.BLUE, ANSIColors.RESET)} or globally in your intlayer.config.ts file (e.g. ${colorize(\"{ dictionary: { location: 'hybrid' } }\", ANSIColors.BLUE, ANSIColors.RESET)}).`,\n { level: 'info' }\n );\n return;\n }\n\n const existingDictionariesKeys: string[] = Object.keys(\n unmergedDictionariesRecord\n );\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 dictionaries = dictionaries.filter((dictionary) =>\n gitFiles.includes(\n join(config.system.baseDir, dictionary.filePath ?? '')\n )\n );\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) => ({\n dictionary,\n status: 'pending',\n })\n );\n\n // Initialize aggregated logger similar to loadDictionaries\n const logger = new PushLogger();\n logger.update(\n dictionariesStatuses.map<PushStatus>((s) => ({\n dictionaryKey: s.dictionary.key,\n status: 'pending',\n }))\n );\n\n const successfullyPushedDictionaries: Dictionary[] = [];\n\n const processDictionary = async (\n statusObj: DictionariesStatus\n ): Promise<void> => {\n statusObj.status = 'pushing';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushing' },\n ]);\n\n try {\n const pushResult = await intlayerAPI.dictionary.pushDictionaries([\n statusObj.dictionary,\n ]);\n\n const updatedDictionaries = pushResult.data?.updatedDictionaries ?? [];\n const newDictionaries = pushResult.data?.newDictionaries ?? [];\n const upToDateDictionaries =\n pushResult.data?.upToDateDictionaries ?? [];\n\n const allDictionaries = [\n ...updatedDictionaries,\n ...newDictionaries,\n ...upToDateDictionaries,\n ];\n\n for (const remoteDictionaryData of allDictionaries) {\n const localDictionary = unmergedDictionariesRecord[\n remoteDictionaryData.key\n ]?.find(\n (dictionary) => dictionary.localId === remoteDictionaryData.localId\n );\n\n if (!localDictionary) continue;\n\n await writeContentDeclaration(\n { ...localDictionary, id: remoteDictionaryData.id },\n config\n );\n }\n\n if (\n updatedDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'modified';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'modified' },\n ]);\n } else if (\n newDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'pushed';\n successfullyPushedDictionaries.push(statusObj.dictionary);\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'pushed' },\n ]);\n } else if (\n upToDateDictionaries.some(\n (dictionary) => dictionary.key === statusObj.dictionary.key\n )\n ) {\n statusObj.status = 'up-to-date';\n logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'up-to-date' },\n ]);\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 logger.update([\n { dictionaryKey: statusObj.dictionary.key, status: 'error' },\n ]);\n }\n };\n\n // Process dictionaries in parallel with a concurrency limit (reuse parallelize)\n await parallelize(dictionariesStatuses, processDictionary, 5);\n\n // Stop the logger and render final state\n logger.finish();\n\n for (const dictionaryStatus of dictionariesStatuses) {\n const { icon, color } = getIconAndColor(dictionaryStatus.status);\n appLogger(\n ` - ${colorizeKey(dictionaryStatus.dictionary.key)} ${ANSIColors.GREY}[${color}${icon} ${dictionaryStatus.status}${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\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 remoteDictionaries = successfullyPushedDictionaries.filter(\n (dictionary) => dictionary.location === 'remote'\n );\n const remoteDictionariesKeys = remoteDictionaries.map(\n (dictionary) => dictionary.key\n );\n\n if (remoteDictionaries.length > 0) {\n const { confirm, isCancel } = await import('@clack/prompts');\n\n const shouldDelete = await confirm({\n message: `Do you want to delete the local dictionaries that were successfully pushed? ${colorize('(Dictionaries:', ANSIColors.GREY, ANSIColors.RESET)} ${colorizeKey(remoteDictionariesKeys)}${colorize(')', ANSIColors.GREY, ANSIColors.RESET)}`,\n initialValue: false,\n });\n\n if (isCancel(shouldDelete)) {\n return;\n }\n\n if (shouldDelete) {\n await deleteLocalDictionaries(remoteDictionaries, options);\n }\n }\n }\n } catch (error) {\n appLogger(error, {\n level: 'error',\n });\n }\n};\n\nconst deleteLocalDictionaries = async (\n dictionariesToDelete: Dictionary[],\n options?: PushOptions\n): Promise<void> => {\n const config = getConfiguration(options?.configOptions);\n const appLogger = getAppLogger(config);\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(\n `Dictionary ${colorizeKey(dictionary.key)} does not have a file path`,\n {\n level: 'error',\n }\n );\n continue;\n }\n\n filePathsSet.add(filePath);\n }\n\n for (const filePath of filePathsSet) {\n try {\n const stats = await fsPromises.lstat(filePath);\n\n if (stats.isFile()) {\n await fsPromises.unlink(filePath);\n appLogger(`Deleted file ${formatPath(filePath)}`, {});\n } else if (stats.isDirectory()) {\n appLogger(`Path is a directory ${formatPath(filePath)}, skipping.`, {});\n } else {\n appLogger(\n `Unknown file type for ${formatPath(filePath)}, skipping.`,\n {}\n );\n }\n } catch (err) {\n appLogger(`Error deleting ${formatPath(filePath)}: ${err}`, {\n level: 'error',\n });\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;AA+CA,MAAM,uBAAuB;CAC3B,QAAQ;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC7C,UAAU;EAAE,MAAM;EAAK,OAAO,WAAW;CAAM;CAC/C,cAAc;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;CAClD,OAAO;EAAE,MAAM;EAAK,OAAO,WAAW;CAAI;CAC1C,SAAS;EAAE,MAAM;EAAK,OAAO,WAAW;CAAK;AAC/C;AAEA,MAAM,mBAAmB,WAAyC;CAChE,OACE,qBAAqB,WACrB,qBAAqB;AAEzB;;;;AAKA,MAAa,OAAO,OAAO,YAAyC;CAClE,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,M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AAE,cAC9C,CAAC,CACH;CAEJ,SAAS,KAAK;EACZ,UAAU,kBAAkB,WAAW,QAAQ,EAAE,IAAI,OAAO,EAC1D,OAAO,QACT,CAAC;CACH;AAEJ"}
|
package/dist/esm/pushConfig.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { checkCMSAuth, getAuthenticatedAPI } from "./utils/checkAccess.mjs";
|
|
2
2
|
import { logConfigDetails } from "@intlayer/chokidar/cli";
|
|
3
|
-
import {
|
|
3
|
+
import { CYAN, GREY_DARK } from "@intlayer/config/colors";
|
|
4
|
+
import { colorize, colorizeObject, getAppLogger } from "@intlayer/config/logger";
|
|
4
5
|
import { getConfiguration } from "@intlayer/config/node";
|
|
5
6
|
|
|
6
7
|
//#region src/pushConfig.ts
|
|
@@ -11,11 +12,13 @@ const pushConfig = async (options) => {
|
|
|
11
12
|
if (!await checkCMSAuth(config, false)) return;
|
|
12
13
|
const getDictionariesKeysResult = await (await getAuthenticatedAPI(config)).project.pushProjectConfiguration(config);
|
|
13
14
|
if (!getDictionariesKeysResult.data) {
|
|
14
|
-
appLogger(`Error pushing project configuration. Run intlayer login command to authenticate.`, { level: "error" });
|
|
15
|
+
appLogger(`Error pushing project configuration. Run ${colorize("npx intlayer login", CYAN)} command to authenticate.`, { level: "error" });
|
|
15
16
|
throw new Error("Error pushing project configuration");
|
|
16
17
|
}
|
|
17
18
|
appLogger("Project configuration pushed successfully");
|
|
18
|
-
appLogger(
|
|
19
|
+
appLogger(colorize("--------------------------------", GREY_DARK));
|
|
20
|
+
appLogger(colorizeObject(getDictionariesKeysResult.data.configuration));
|
|
21
|
+
appLogger(colorize("--------------------------------", GREY_DARK));
|
|
19
22
|
};
|
|
20
23
|
|
|
21
24
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushConfig.mjs","names":[],"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport {
|
|
1
|
+
{"version":3,"file":"pushConfig.mjs","names":[],"sources":["../../src/pushConfig.ts"],"sourcesContent":["import { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { CYAN, GREY_DARK } from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeObject,\n getAppLogger,\n} from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { checkCMSAuth, getAuthenticatedAPI } from './utils/checkAccess';\n\ntype PushOptions = {\n configOptions?: GetConfigurationOptions;\n};\n\nexport const pushConfig = async (options?: PushOptions) => {\n const config = getConfiguration(options?.configOptions);\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(config);\n\n const hasCMSAuth = await checkCMSAuth(config, false);\n\n if (!hasCMSAuth) return;\n\n const intlayerAPI = await getAuthenticatedAPI(config);\n\n // Push the project configuration\n const getDictionariesKeysResult =\n await intlayerAPI.project.pushProjectConfiguration(config);\n\n if (!getDictionariesKeysResult.data) {\n appLogger(\n `Error pushing project configuration. Run ${colorize('npx intlayer login', CYAN)} command to authenticate.`,\n {\n level: 'error',\n }\n );\n throw new Error('Error pushing project configuration');\n }\n\n appLogger('Project configuration pushed successfully');\n\n appLogger(colorize('--------------------------------', GREY_DARK));\n appLogger(colorizeObject(getDictionariesKeysResult.data.configuration));\n appLogger(colorize('--------------------------------', GREY_DARK));\n};\n"],"mappings":";;;;;;;AAiBA,MAAa,aAAa,OAAO,YAA0B;CACzD,MAAM,SAAS,iBAAiB,SAAS,aAAa;CACtD,iBAAiB,SAAS,aAAa;CAEvC,MAAM,YAAY,aAAa,MAAM;CAIrC,IAAI,CAAC,MAFoB,aAAa,QAAQ,KAAK,GAElC;CAKjB,MAAM,4BACJ,OAAM,MAJkB,oBAAoB,MAAM,GAIhC,QAAQ,yBAAyB,MAAM;CAE3D,IAAI,CAAC,0BAA0B,MAAM;EACnC,UACE,4CAA4C,SAAS,sBAAsB,IAAI,EAAE,4BACjF,EACE,OAAO,QACT,CACF;EACA,MAAM,IAAI,MAAM,qCAAqC;CACvD;CAEA,UAAU,2CAA2C;CAErD,UAAU,SAAS,oCAAoC,SAAS,CAAC;CACjE,UAAU,eAAe,0BAA0B,KAAK,aAAa,CAAC;CACtE,UAAU,SAAS,oCAAoC,SAAS,CAAC;AACnE"}
|
package/dist/esm/pushLog.mjs
CHANGED
|
@@ -38,7 +38,7 @@ var PushLogger = class {
|
|
|
38
38
|
this.spinnerTimer = null;
|
|
39
39
|
}
|
|
40
40
|
render() {
|
|
41
|
-
const { total, done, pushed, modified, errors } = this.computeProgress();
|
|
41
|
+
const { total, done, pushed, modified, upToDate, errors } = this.computeProgress();
|
|
42
42
|
const frame = this.spinnerFrames[this.spinnerIndex];
|
|
43
43
|
const lines = [];
|
|
44
44
|
const isDone = done === total;
|
|
@@ -46,6 +46,7 @@ var PushLogger = class {
|
|
|
46
46
|
const details = [];
|
|
47
47
|
if (pushed > 0) details.push(`new: ${colorizeNumber(pushed)}`);
|
|
48
48
|
if (modified > 0) details.push(`modified: ${colorizeNumber(modified)}`);
|
|
49
|
+
if (upToDate > 0) details.push(colorize(`up-to-date: ${colorizeNumber(upToDate)}`, ANSIColors.GREY));
|
|
49
50
|
if (errors > 0) details.push(colorize(`errors: ${colorizeNumber(errors)}`, ANSIColors.RED));
|
|
50
51
|
const suffix = details.length > 0 ? ` (${details.join(", ")})` : "";
|
|
51
52
|
if (isDone) lines.push(`${colorize("✔", ANSIColors.GREEN)} pushed ${progressLabel}${suffix}`);
|
|
@@ -67,13 +68,15 @@ var PushLogger = class {
|
|
|
67
68
|
const keys = new Set(this.statuses.map((s) => s.dictionaryKey));
|
|
68
69
|
const pushed = this.statuses.filter((s) => s.status === "pushed").length;
|
|
69
70
|
const modified = this.statuses.filter((s) => s.status === "modified").length;
|
|
71
|
+
const upToDate = this.statuses.filter((s) => s.status === "up-to-date").length;
|
|
70
72
|
const errors = this.statuses.filter((s) => s.status === "error").length;
|
|
71
|
-
const done = pushed + modified + errors;
|
|
73
|
+
const done = pushed + modified + upToDate + errors;
|
|
72
74
|
return {
|
|
73
75
|
total: keys.size,
|
|
74
76
|
done,
|
|
75
77
|
pushed,
|
|
76
78
|
modified,
|
|
79
|
+
upToDate,
|
|
77
80
|
errors
|
|
78
81
|
};
|
|
79
82
|
}
|
package/dist/esm/pushLog.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushLog.mjs","names":[],"sources":["../../src/pushLog.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeNumber,\n spinnerFrames,\n} from '@intlayer/config/logger';\n\nexport type PushStatus = {\n dictionaryKey: string;\n status
|
|
1
|
+
{"version":3,"file":"pushLog.mjs","names":[],"sources":["../../src/pushLog.ts"],"sourcesContent":["import * as ANSIColors from '@intlayer/config/colors';\nimport {\n colorize,\n colorizeNumber,\n spinnerFrames,\n} from '@intlayer/config/logger';\n\nexport type PushStatus = {\n dictionaryKey: string;\n status:\n | 'pending'\n | 'pushing'\n | 'pushed'\n | 'modified'\n | 'up-to-date'\n | 'error';\n errorMessage?: string;\n};\n\nexport class PushLogger {\n private statuses: PushStatus[] = [];\n private spinnerTimer: NodeJS.Timeout | null = null;\n private spinnerIndex = 0;\n private renderedLines = 0;\n private readonly spinnerFrames = spinnerFrames;\n private isFinished = false;\n private lastRenderedState: string = '';\n\n update(newStatuses: PushStatus[]) {\n if (this.isFinished) return;\n for (const status of newStatuses) {\n const index = this.statuses.findIndex(\n (s) => s.dictionaryKey === status.dictionaryKey\n );\n if (index >= 0) {\n this.statuses[index] = status;\n } else {\n this.statuses.push(status);\n }\n }\n\n this.startSpinner();\n this.render();\n }\n\n finish() {\n this.isFinished = true;\n this.stopSpinner();\n this.render();\n }\n\n private startSpinner() {\n if (this.spinnerTimer || this.isFinished) return;\n this.spinnerTimer = setInterval(() => {\n this.spinnerIndex = (this.spinnerIndex + 1) % this.spinnerFrames.length;\n this.render();\n }, 100);\n }\n\n private stopSpinner() {\n if (!this.spinnerTimer) return;\n clearInterval(this.spinnerTimer);\n this.spinnerTimer = null;\n }\n\n private render() {\n const { total, done, pushed, modified, upToDate, errors } =\n this.computeProgress();\n\n const frame = this.spinnerFrames[this.spinnerIndex];\n const lines: string[] = [];\n\n const isDone = done === total;\n\n const progressLabel = `dictionaries: ${colorizeNumber(done)}/${colorizeNumber(total)}`;\n const details: string[] = [];\n if (pushed > 0) details.push(`new: ${colorizeNumber(pushed)}`);\n if (modified > 0) details.push(`modified: ${colorizeNumber(modified)}`);\n if (upToDate > 0)\n details.push(\n colorize(`up-to-date: ${colorizeNumber(upToDate)}`, ANSIColors.GREY)\n );\n if (errors > 0)\n details.push(\n colorize(`errors: ${colorizeNumber(errors)}`, ANSIColors.RED)\n );\n\n const suffix = details.length > 0 ? ` (${details.join(', ')})` : '';\n\n if (isDone) {\n lines.push(\n `${colorize('✔', ANSIColors.GREEN)} pushed ${progressLabel}${suffix}`\n );\n } else {\n lines.push(\n `${colorize(frame, ANSIColors.BLUE)} pushing ${progressLabel}${suffix}`\n );\n }\n\n const currentState = lines.join('\\n');\n if (currentState === this.lastRenderedState) {\n return;\n }\n this.lastRenderedState = currentState;\n\n if (this.renderedLines > 0) {\n process.stdout.write(`\\x1b[${this.renderedLines}F`);\n }\n\n const totalLinesToClear = Math.max(this.renderedLines, lines.length);\n for (let i = 0; i < totalLinesToClear; i++) {\n process.stdout.write('\\x1b[2K');\n const line = lines[i];\n if (line !== undefined) {\n process.stdout.write(line);\n }\n process.stdout.write('\\n');\n }\n\n this.renderedLines = lines.length;\n }\n\n private computeProgress() {\n const keys = new Set(this.statuses.map((s) => s.dictionaryKey));\n\n const pushed = this.statuses.filter((s) => s.status === 'pushed').length;\n const modified = this.statuses.filter(\n (s) => s.status === 'modified'\n ).length;\n const upToDate = this.statuses.filter(\n (s) => s.status === 'up-to-date'\n ).length;\n const errors = this.statuses.filter((s) => s.status === 'error').length;\n const done = pushed + modified + upToDate + errors;\n\n return {\n total: keys.size,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AE;EACjE,MAAM,OAAO,SAAS,WAAW,WAAW;EAE5C,OAAO;GACL,OAAO,KAAK;GACZ;GACA;GACA;GACA;GACA;EACF;CACF;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readCliSessionToken } from "../auth/sessionToken.mjs";
|
|
2
|
+
import { login } from "../auth/login.mjs";
|
|
2
3
|
import { checkConfigConsistency } from "./checkConfigConsistency.mjs";
|
|
3
4
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
4
5
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
@@ -28,14 +29,14 @@ const checkProjectConfigConsistency = (project, configuration, appLogger) => {
|
|
|
28
29
|
"Remote configuration is not up to date. The project configuration does not match the local configuration.",
|
|
29
30
|
"You can push the configuration by running",
|
|
30
31
|
colorize("npx intlayer configuration push", ANSIColors.CYAN),
|
|
31
|
-
colorize("(see doc:", ANSIColors.
|
|
32
|
-
colorize("https://intlayer.org/doc/concept/cli/push", ANSIColors.
|
|
33
|
-
colorize(")", ANSIColors.
|
|
32
|
+
colorize("(see doc:", ANSIColors.GREY_LIGHT),
|
|
33
|
+
colorize("https://intlayer.org/doc/concept/cli/push", ANSIColors.GREY_DARK),
|
|
34
|
+
colorize(")", ANSIColors.GREY_LIGHT),
|
|
34
35
|
"."
|
|
35
36
|
], { level: "warn" });
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
|
-
const checkCMSAuth = async (configuration, shouldCheckConfigConsistency = true) => {
|
|
39
|
+
const checkCMSAuth = async (configuration, shouldCheckConfigConsistency = true, shouldAutoLogin = true) => {
|
|
39
40
|
const appLogger = getAppLogger(configuration);
|
|
40
41
|
const sessionData = await readCliSessionToken(configuration);
|
|
41
42
|
if (sessionData) {
|
|
@@ -46,21 +47,38 @@ const checkCMSAuth = async (configuration, shouldCheckConfigConsistency = true)
|
|
|
46
47
|
return true;
|
|
47
48
|
} catch (error) {
|
|
48
49
|
appLogger(extractErrorMessage(error), { level: "error" });
|
|
50
|
+
appLogger([
|
|
51
|
+
"Run",
|
|
52
|
+
colorize("npx intlayer login", ANSIColors.CYAN),
|
|
53
|
+
"to set up a new session."
|
|
54
|
+
], { level: "error" });
|
|
49
55
|
return false;
|
|
50
56
|
}
|
|
51
57
|
}
|
|
52
58
|
if (!(configuration.editor.clientId && configuration.editor.clientSecret)) {
|
|
59
|
+
if (shouldAutoLogin) {
|
|
60
|
+
appLogger([
|
|
61
|
+
"No credentials found. Starting login...",
|
|
62
|
+
colorize("( Set", ANSIColors.GREY_LIGHT),
|
|
63
|
+
colorize("INTLAYER_CLIENT_ID", ANSIColors.BLUE),
|
|
64
|
+
colorize("and", ANSIColors.GREY_LIGHT),
|
|
65
|
+
colorize("INTLAYER_CLIENT_SECRET", ANSIColors.BLUE),
|
|
66
|
+
colorize("in your .env to skip this step)", ANSIColors.GREY_LIGHT)
|
|
67
|
+
], { level: "warn" });
|
|
68
|
+
await login({ exitAfter: false });
|
|
69
|
+
return checkCMSAuth(configuration, shouldCheckConfigConsistency, false);
|
|
70
|
+
}
|
|
53
71
|
appLogger([
|
|
54
72
|
"CMS auth not provided. Run",
|
|
55
73
|
colorize("npx intlayer login", ANSIColors.CYAN),
|
|
56
74
|
"to authenticate, or set",
|
|
57
|
-
colorize("INTLAYER_CLIENT_ID", ANSIColors.
|
|
75
|
+
colorize("INTLAYER_CLIENT_ID", ANSIColors.BLUE),
|
|
58
76
|
"and",
|
|
59
|
-
colorize("INTLAYER_CLIENT_SECRET", ANSIColors.
|
|
77
|
+
colorize("INTLAYER_CLIENT_SECRET", ANSIColors.BLUE),
|
|
60
78
|
"in your .env file",
|
|
61
|
-
colorize("(see doc:", ANSIColors.
|
|
62
|
-
colorize("https://intlayer.org/doc/concept/cms", ANSIColors.
|
|
63
|
-
colorize(")", ANSIColors.
|
|
79
|
+
colorize("(see doc:", ANSIColors.GREY_LIGHT),
|
|
80
|
+
colorize("https://intlayer.org/doc/concept/cms", ANSIColors.GREY_DARK),
|
|
81
|
+
colorize(")", ANSIColors.GREY_LIGHT),
|
|
64
82
|
"."
|
|
65
83
|
], { level: "error" });
|
|
66
84
|
return false;
|
|
@@ -75,29 +93,18 @@ const checkCMSAuth = async (configuration, shouldCheckConfigConsistency = true)
|
|
|
75
93
|
if (shouldCheckConfigConsistency) checkProjectConfigConsistency(project, configuration, appLogger);
|
|
76
94
|
} catch (error) {
|
|
77
95
|
appLogger(extractErrorMessage(error), { level: "error" });
|
|
96
|
+
appLogger([
|
|
97
|
+
"Your access keys appear to be invalid. Run",
|
|
98
|
+
colorize("npx intlayer login", ANSIColors.CYAN),
|
|
99
|
+
"to set up new access keys."
|
|
100
|
+
], { level: "error" });
|
|
78
101
|
return false;
|
|
79
102
|
}
|
|
80
103
|
return true;
|
|
81
104
|
};
|
|
82
105
|
const checkAIAccess = async (configuration, aiOptions, shouldCheckConfigConsistency = true) => {
|
|
83
|
-
const appLogger = getAppLogger(configuration);
|
|
84
|
-
const hasCMSAuth = Boolean(configuration.editor.clientId && configuration.editor.clientSecret);
|
|
85
|
-
const sessionData = await readCliSessionToken(configuration);
|
|
86
|
-
const hasSessionToken = Boolean(sessionData);
|
|
87
106
|
const isOllama = configuration.ai?.provider === "ollama" || aiOptions?.provider === "ollama";
|
|
88
107
|
if (Boolean(configuration.ai?.apiKey || aiOptions?.apiKey) || isOllama) return true;
|
|
89
|
-
if (!hasCMSAuth && !hasSessionToken) {
|
|
90
|
-
appLogger([
|
|
91
|
-
"AI options or API key not provided. Run",
|
|
92
|
-
colorize("npx intlayer login", ANSIColors.CYAN),
|
|
93
|
-
"to authenticate, or provide an API key",
|
|
94
|
-
colorize("(see doc:", ANSIColors.GREY_DARK),
|
|
95
|
-
colorize("https://intlayer.org/doc/concept/configuration", ANSIColors.GREY),
|
|
96
|
-
colorize(")", ANSIColors.GREY_DARK),
|
|
97
|
-
"."
|
|
98
|
-
], { level: "error" });
|
|
99
|
-
return false;
|
|
100
|
-
}
|
|
101
108
|
return await checkCMSAuth(configuration, shouldCheckConfigConsistency);
|
|
102
109
|
};
|
|
103
110
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAccess.mjs","names":[],"sources":["../../../src/utils/checkAccess.ts"],"sourcesContent":["import type { AIOptions, IntlayerAPIProxy } from '@intlayer/api';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { extractErrorMessage } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { type CliSessionData, readCliSessionToken } from '../auth/sessionToken';\nimport { checkConfigConsistency } from './checkConfigConsistency';\n\nexport const getAuthenticatedAPI = async (\n configuration?: IntlayerConfig\n): Promise<IntlayerAPIProxy> => {\n let sessionData: CliSessionData | null = null;\n\n // First use session data if it exists\n if (configuration) {\n sessionData = await readCliSessionToken(configuration);\n }\n\n return getIntlayerAPIProxy(undefined, configuration, sessionData?.token);\n};\n\nconst checkProjectConfigConsistency = (\n project: { configuration?: any } | null | undefined,\n configuration: IntlayerConfig,\n appLogger: ReturnType<typeof getAppLogger>\n): void => {\n if (!project?.configuration) return;\n\n try {\n let remoteConfigToCheck = project.configuration;\n\n if (\n remoteConfigToCheck.ai &&\n 'apiKeyConfigured' in remoteConfigToCheck.ai\n ) {\n const { apiKeyConfigured, ...restAi } = remoteConfigToCheck.ai as any;\n remoteConfigToCheck = { ...remoteConfigToCheck, ai: restAi };\n }\n\n checkConfigConsistency(remoteConfigToCheck, configuration);\n } catch {\n appLogger(\n [\n 'Remote configuration is not up to date. The project configuration does not match the local configuration.',\n 'You can push the configuration by running',\n colorize('npx intlayer configuration push', ANSIColors.CYAN),\n colorize('(see doc:', ANSIColors.
|
|
1
|
+
{"version":3,"file":"checkAccess.mjs","names":[],"sources":["../../../src/utils/checkAccess.ts"],"sourcesContent":["import type { AIOptions, IntlayerAPIProxy } from '@intlayer/api';\nimport { getIntlayerAPIProxy } from '@intlayer/api';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport { extractErrorMessage } from '@intlayer/config/utils';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport { login } from '../auth/login';\nimport { type CliSessionData, readCliSessionToken } from '../auth/sessionToken';\nimport { checkConfigConsistency } from './checkConfigConsistency';\n\nexport const getAuthenticatedAPI = async (\n configuration?: IntlayerConfig\n): Promise<IntlayerAPIProxy> => {\n let sessionData: CliSessionData | null = null;\n\n // First use session data if it exists\n if (configuration) {\n sessionData = await readCliSessionToken(configuration);\n }\n\n return getIntlayerAPIProxy(undefined, configuration, sessionData?.token);\n};\n\nconst checkProjectConfigConsistency = (\n project: { configuration?: any } | null | undefined,\n configuration: IntlayerConfig,\n appLogger: ReturnType<typeof getAppLogger>\n): void => {\n if (!project?.configuration) return;\n\n try {\n let remoteConfigToCheck = project.configuration;\n\n if (\n remoteConfigToCheck.ai &&\n 'apiKeyConfigured' in remoteConfigToCheck.ai\n ) {\n const { apiKeyConfigured, ...restAi } = remoteConfigToCheck.ai as any;\n remoteConfigToCheck = { ...remoteConfigToCheck, ai: restAi };\n }\n\n checkConfigConsistency(remoteConfigToCheck, configuration);\n } catch {\n appLogger(\n [\n 'Remote configuration is not up to date. The project configuration does not match the local configuration.',\n 'You can push the configuration by running',\n colorize('npx intlayer configuration push', ANSIColors.CYAN),\n colorize('(see doc:', ANSIColors.GREY_LIGHT),\n colorize(\n 'https://intlayer.org/doc/concept/cli/push',\n ANSIColors.GREY_DARK\n ),\n colorize(')', ANSIColors.GREY_LIGHT),\n '.',\n ],\n { level: 'warn' }\n );\n }\n};\n\nexport const checkCMSAuth = async (\n configuration: IntlayerConfig,\n shouldCheckConfigConsistency: boolean = true,\n shouldAutoLogin: boolean = true\n): Promise<boolean> => {\n const appLogger = getAppLogger(configuration);\n\n // Try CLI session token first (short-lived 2h token stored in tempDir)\n const sessionData = await readCliSessionToken(configuration);\n if (sessionData) {\n const intlayerAPI = getIntlayerAPIProxy(\n undefined,\n configuration,\n sessionData.token\n );\n\n try {\n const result = await intlayerAPI.oAuth.getCliSessionMe();\n const project = result.data?.project;\n\n if (project && shouldCheckConfigConsistency) {\n checkProjectConfigConsistency(project, configuration, appLogger);\n }\n\n return true;\n } catch (error) {\n const message = extractErrorMessage(error);\n appLogger(message, { level: 'error' });\n appLogger(\n [\n 'Run',\n colorize('npx intlayer login', ANSIColors.CYAN),\n 'to set up a new session.',\n ],\n { level: 'error' }\n );\n return false;\n }\n }\n\n // Fall back to client_credentials (access key)\n const hasCMSAuth =\n configuration.editor.clientId && configuration.editor.clientSecret;\n if (!hasCMSAuth) {\n if (shouldAutoLogin) {\n appLogger(\n [\n 'No credentials found. Starting login...',\n colorize('( Set', ANSIColors.GREY_LIGHT),\n colorize('INTLAYER_CLIENT_ID', ANSIColors.BLUE),\n colorize('and', ANSIColors.GREY_LIGHT),\n colorize('INTLAYER_CLIENT_SECRET', ANSIColors.BLUE),\n colorize('in your .env to skip this step)', ANSIColors.GREY_LIGHT),\n ],\n { level: 'warn' }\n );\n await login({ exitAfter: false });\n return checkCMSAuth(configuration, shouldCheckConfigConsistency, false);\n }\n\n appLogger(\n [\n 'CMS auth not provided. Run',\n colorize('npx intlayer login', ANSIColors.CYAN),\n 'to authenticate, or set',\n colorize('INTLAYER_CLIENT_ID', ANSIColors.BLUE),\n 'and',\n colorize('INTLAYER_CLIENT_SECRET', ANSIColors.BLUE),\n 'in your .env file',\n colorize('(see doc:', ANSIColors.GREY_LIGHT),\n colorize('https://intlayer.org/doc/concept/cms', ANSIColors.GREY_DARK),\n colorize(')', ANSIColors.GREY_LIGHT),\n '.',\n ],\n { level: 'error' }\n );\n\n return false;\n }\n\n const intlayerAPI = getIntlayerAPIProxy(undefined, configuration);\n\n try {\n const result = await intlayerAPI.oAuth.getOAuth2AccessToken();\n\n const project = result.data?.project;\n\n if (!project) {\n appLogger('Project not found');\n return true;\n }\n\n if (shouldCheckConfigConsistency) {\n checkProjectConfigConsistency(project, configuration, appLogger);\n }\n } catch (error) {\n const message = extractErrorMessage(error);\n appLogger(message, { level: 'error' });\n appLogger(\n [\n 'Your access keys appear to be invalid. Run',\n colorize('npx intlayer login', ANSIColors.CYAN),\n 'to set up new access keys.',\n ],\n { level: 'error' }\n );\n return false;\n }\n\n return true;\n};\n\nexport const checkAIAccess = async (\n configuration: IntlayerConfig,\n aiOptions?: AIOptions,\n shouldCheckConfigConsistency: boolean = true\n): Promise<boolean> => {\n const isOllama =\n configuration.ai?.provider === 'ollama' || aiOptions?.provider === 'ollama';\n const hasHisOwnAIAPIKey = Boolean(\n configuration.ai?.apiKey || aiOptions?.apiKey\n );\n\n if (hasHisOwnAIAPIKey || isOllama) {\n return true;\n }\n\n // No local AI key — delegate to CMS auth check (which will auto-login if needed)\n return await checkCMSAuth(configuration, shouldCheckConfigConsistency);\n};\n"],"mappings":";;;;;;;;;AAUA,MAAa,sBAAsB,OACjC,kBAC8B;CAC9B,IAAI,cAAqC;CAGzC,IAAI,eACF,cAAc,MAAM,oBAAoB,aAAa;CAGvD,OAAO,oBAAoB,QAAW,eAAe,aAAa,KAAK;AACzE;AAEA,MAAM,iCACJ,SACA,eACA,cACS;CACT,IAAI,CAAC,SAAS,eAAe;CAE7B,IAAI;EACF,IAAI,sBAAsB,QAAQ;EAElC,IACE,oBAAoB,MACpB,sBAAsB,oBAAoB,IAC1C;GACA,MAAM,EAAE,kBAAkB,GAAG,WAAW,oBAAoB;GAC5D,sBAAsB;IAAE,GAAG;IAAqB,IAAI;GAAO;EAC7D;EAEA,uBAAuB,qBAAqB,aAAa;CAC3D,QAAQ;EACN,UACE;GACE;GACA;GACA,SAAS,mCAAmC,WAAW,IAAI;GAC3D,SAAS,aAAa,WAAW,UAAU;GAC3C,SACE,6CACA,WAAW,SACb;GACA,SAAS,KAAK,WAAW,UAAU;GACnC;EACF,GACA,EAAE,OAAO,OAAO,CAClB;CACF;AACF;AAEA,MAAa,eAAe,OAC1B,eACA,+BAAwC,MACxC,kBAA2B,S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;GACZ,UAAU,mBAAmB;GAC7B,OAAO;EACT;EAEA,IAAI,8BACF,8BAA8B,SAAS,eAAe,SAAS;CAEnE,SAAS,OAAO;EAEd,UADgB,oBAAoB,KACpB,GAAG,EAAE,OAAO,QAAQ,CAAC;EACrC,UACE;GACE;GACA,SAAS,sBAAsB,WAAW,IAAI;GAC9C;EACF,GACA,EAAE,OAAO,QAAQ,CACnB;EACA,OAAO;CACT;CAEA,OAAO;AACT;AAEA,MAAa,gBAAgB,OAC3B,eACA,WACA,+BAAwC,SACnB;CACrB,MAAM,WACJ,cAAc,IAAI,aAAa,YAAY,WAAW,aAAa;CAKrE,IAJ0B,QACxB,cAAc,IAAI,UAAU,WAAW,MAGrB,KAAK,UACvB,OAAO;CAIT,OAAO,MAAM,aAAa,eAAe,4BAA4B;AACvE"}
|
|
@@ -4,8 +4,15 @@ import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
|
4
4
|
type LoginOptions = {
|
|
5
5
|
cmsUrl?: string;
|
|
6
6
|
configOptions?: GetConfigurationOptions;
|
|
7
|
+
/**
|
|
8
|
+
* When false, do not call process.exit(0) after a successful session-token
|
|
9
|
+
* login so the caller can continue (e.g. retry a command inline).
|
|
10
|
+
* Defaults to true to preserve existing standalone-login behaviour.
|
|
11
|
+
* Access-key login always exits because the user must configure .env first.
|
|
12
|
+
*/
|
|
13
|
+
exitAfter?: boolean;
|
|
7
14
|
};
|
|
8
|
-
declare const login: (options
|
|
15
|
+
declare const login: (options?: LoginOptions) => Promise<void>;
|
|
9
16
|
//#endregion
|
|
10
17
|
export { login };
|
|
11
18
|
//# sourceMappingURL=login.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","names":[],"sources":["../../../src/auth/login.ts"],"mappings":";;;KAiEK,YAAA;EACH,MAAA;EACA,aAAA,GAAgB,uBAAuB;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"login.d.ts","names":[],"sources":["../../../src/auth/login.ts"],"mappings":";;;KAiEK,YAAA;EACH,MAAA;EACA,aAAA,GAAgB,uBAAuB;EAFxB;;;;;;EASf,SAAA;AAAA;AAAA,cAGW,KAAA,GAAe,OAAA,GAAS,YAAA,KAAiB,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"mappings":";;;KAOK,aAAA;EACH,aAAA,GAAgB,uBAAuB;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"config.d.ts","names":[],"sources":["../../src/config.ts"],"mappings":";;;KAOK,aAAA;EACH,aAAA,GAAgB,uBAAuB;AAAA;AAAA,cAgB5B,SAAA,GAAa,OAAuB,GAAb,aAAa"}
|
|
@@ -7,8 +7,8 @@ type ListContentDeclarationOptions = {
|
|
|
7
7
|
absolute?: boolean;
|
|
8
8
|
};
|
|
9
9
|
declare const listContentDeclarationRows: (options?: ListContentDeclarationOptions) => Promise<{
|
|
10
|
-
key:
|
|
11
|
-
path:
|
|
10
|
+
key: any;
|
|
11
|
+
path: any;
|
|
12
12
|
}[]>;
|
|
13
13
|
declare const listContentDeclaration: (options?: ListContentDeclarationOptions) => Promise<void>;
|
|
14
14
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","names":[],"sources":["../../../src/push/push.ts"],"mappings":";;;;KAuBK,WAAA;EACH,sBAAA;EACA,oBAAA;EACA,YAAA;EACA,UAAA,GAAa,mBAAA;EACb,aAAA,GAAgB,uBAAuB;EACvC,KAAA;AAAA;;;;
|
|
1
|
+
{"version":3,"file":"push.d.ts","names":[],"sources":["../../../src/push/push.ts"],"mappings":";;;;KAuBK,WAAA;EACH,sBAAA;EACA,oBAAA;EACA,YAAA;EACA,UAAA,GAAa,mBAAA;EACb,aAAA,GAAgB,uBAAuB;EACvC,KAAA;AAAA;;;;cAoCW,IAAA,GAAc,OAAA,GAAU,WAAA,KAAc,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushConfig.d.ts","names":[],"sources":["../../src/pushConfig.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"pushConfig.d.ts","names":[],"sources":["../../src/pushConfig.ts"],"mappings":";;;KAaK,WAAA;EACH,aAAA,GAAgB,uBAAuB;AAAA;AAAA,cAG5B,UAAA,GAAoB,OAAA,GAAU,WAAA,KAAW,OAAA"}
|
package/dist/types/pushLog.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
//#region src/pushLog.d.ts
|
|
2
2
|
type PushStatus = {
|
|
3
3
|
dictionaryKey: string;
|
|
4
|
-
status: 'pending' | 'pushing' | 'pushed' | 'modified' | 'error';
|
|
4
|
+
status: 'pending' | 'pushing' | 'pushed' | 'modified' | 'up-to-date' | 'error';
|
|
5
5
|
errorMessage?: string;
|
|
6
6
|
};
|
|
7
7
|
declare class PushLogger {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pushLog.d.ts","names":[],"sources":["../../src/pushLog.ts"],"mappings":";KAOY,UAAA;EACV,aAAA;EACA,MAAA;
|
|
1
|
+
{"version":3,"file":"pushLog.d.ts","names":[],"sources":["../../src/pushLog.ts"],"mappings":";KAOY,UAAA;EACV,aAAA;EACA,MAAA;EAOA,YAAA;AAAA;AAAA,cAGW,UAAA;EAAA,QACH,QAAA;EAAA,QACA,YAAA;EAAA,QACA,YAAA;EAAA,QACA,aAAA;EAAA,iBACS,aAAA;EAAA,QACT,UAAA;EAAA,QACA,iBAAA;EAER,MAAA,CAAO,WAAA,EAAa,UAAU;EAiB9B,MAAA,CAAA;EAAA,QAMQ,YAAA;EAAA,QAQA,WAAA;EAAA,QAMA,MAAA;EAAA,QAyDA,eAAA;AAAA"}
|
|
@@ -3,7 +3,7 @@ import { AIOptions, IntlayerAPIProxy } from "@intlayer/api";
|
|
|
3
3
|
|
|
4
4
|
//#region src/utils/checkAccess.d.ts
|
|
5
5
|
declare const getAuthenticatedAPI: (configuration?: IntlayerConfig) => Promise<IntlayerAPIProxy>;
|
|
6
|
-
declare const checkCMSAuth: (configuration: IntlayerConfig, shouldCheckConfigConsistency?: boolean) => Promise<boolean>;
|
|
6
|
+
declare const checkCMSAuth: (configuration: IntlayerConfig, shouldCheckConfigConsistency?: boolean, shouldAutoLogin?: boolean) => Promise<boolean>;
|
|
7
7
|
declare const checkAIAccess: (configuration: IntlayerConfig, aiOptions?: AIOptions, shouldCheckConfigConsistency?: boolean) => Promise<boolean>;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { checkAIAccess, checkCMSAuth, getAuthenticatedAPI };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkAccess.d.ts","names":[],"sources":["../../../src/utils/checkAccess.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"checkAccess.d.ts","names":[],"sources":["../../../src/utils/checkAccess.ts"],"mappings":";;;;cAUa,mBAAA,GACX,aAAA,GAAgB,cAAA,KACf,OAAA,CAAQ,gBAAA;AAAA,cAiDE,YAAA,GACX,aAAA,EAAe,cAAA,EACf,4BAAA,YACA,eAAA,eACC,OAAO;AAAA,cA4GG,aAAA,GACX,aAAA,EAAe,cAAA,EACf,SAAA,GAAY,SAAA,EACZ,4BAAA,eACC,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/cli",
|
|
3
|
-
"version": "8.10.
|
|
3
|
+
"version": "8.10.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides uniform command-line interface scripts for Intlayer, used in packages like intlayer-cli and intlayer.",
|
|
6
6
|
"keywords": [
|
|
@@ -67,22 +67,22 @@
|
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@clack/prompts": "0.11.0",
|
|
70
|
-
"@intlayer/api": "8.10.
|
|
71
|
-
"@intlayer/babel": "8.10.
|
|
72
|
-
"@intlayer/chokidar": "8.10.
|
|
73
|
-
"@intlayer/config": "8.10.
|
|
74
|
-
"@intlayer/core": "8.10.
|
|
75
|
-
"@intlayer/dictionaries-entry": "8.10.
|
|
76
|
-
"@intlayer/remote-dictionaries-entry": "8.10.
|
|
77
|
-
"@intlayer/types": "8.10.
|
|
78
|
-
"@intlayer/unmerged-dictionaries-entry": "8.10.
|
|
70
|
+
"@intlayer/api": "8.10.1",
|
|
71
|
+
"@intlayer/babel": "8.10.1",
|
|
72
|
+
"@intlayer/chokidar": "8.10.1",
|
|
73
|
+
"@intlayer/config": "8.10.1",
|
|
74
|
+
"@intlayer/core": "8.10.1",
|
|
75
|
+
"@intlayer/dictionaries-entry": "8.10.1",
|
|
76
|
+
"@intlayer/remote-dictionaries-entry": "8.10.1",
|
|
77
|
+
"@intlayer/types": "8.10.1",
|
|
78
|
+
"@intlayer/unmerged-dictionaries-entry": "8.10.1",
|
|
79
79
|
"commander": "14.0.3",
|
|
80
80
|
"enquirer": "^2.4.1",
|
|
81
81
|
"eventsource": "4.1.0",
|
|
82
82
|
"fast-glob": "3.3.3"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@intlayer/ai": "8.10.
|
|
85
|
+
"@intlayer/ai": "8.10.1",
|
|
86
86
|
"@types/node": "25.9.1",
|
|
87
87
|
"@utils/ts-config": "1.0.4",
|
|
88
88
|
"@utils/ts-config-types": "1.0.4",
|
|
@@ -90,10 +90,10 @@
|
|
|
90
90
|
"rimraf": "6.1.3",
|
|
91
91
|
"tsdown": "0.22.00",
|
|
92
92
|
"typescript": "6.0.3",
|
|
93
|
-
"vitest": "4.1.
|
|
93
|
+
"vitest": "4.1.7"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
|
-
"@intlayer/ai": "8.10.
|
|
96
|
+
"@intlayer/ai": "8.10.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependenciesMeta": {
|
|
99
99
|
"@intlayer/ai": {
|