@intlayer/editor 5.0.5 → 5.1.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport * as fsPromises from 'fs/promises';\nimport { basename, dirname, extname } from 'path';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport * as fsPromises from 'fs/promises';\nimport { basename, dirname, extname } from 'path';\nimport { type IntlayerConfig, getConfiguration } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport deepEqual from 'deep-equal';\nimport type { DictionaryStatus } from '../dictionaryStatus';\n\nconst DEFAULT_NEW_DICTIONARY_PATH = 'intlayer-dictionaries';\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n config?: IntlayerConfig,\n newDictionariesPath?: string\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const {\n content: { baseDir },\n } = config ?? getConfiguration();\n\n const newDictionaryRelativeLocationPath =\n newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;\n const newDictionaryLocationPath = `${baseDir}/${newDictionaryRelativeLocationPath}`;\n\n const existingDictionary = dictionariesRecord[dictionary.key];\n\n if (existingDictionary) {\n const { filePath, ...dictionaryWithoutPath } = dictionary;\n\n // Compare existing dictionary with distant dictionary\n if (deepEqual(existingDictionary, dictionary)) {\n // Up to date, nothing to do\n return {\n status: 'up-to-date',\n path: filePath!,\n };\n } else {\n if (filePath) {\n const isDictionaryJSON = filePath.endsWith('.json');\n\n if (isDictionaryJSON) {\n const contentDeclarationPath = `${baseDir}/${filePath}`;\n // Write the dictionary to the same location of the existing dictionary file\n await fsPromises.writeFile(\n contentDeclarationPath,\n JSON.stringify(\n {\n $schema: 'https://intlayer.org/schema.json',\n ...dictionaryWithoutPath,\n },\n null,\n 2\n )\n );\n return { status: 'updated', path: contentDeclarationPath };\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const dictionariesDirPath = dirname(filePath);\n const dictionariesFileName = basename(filePath, extname(filePath));\n\n const newFilePath = `${dictionariesDirPath}/${dictionariesFileName}.json`;\n\n await writeFileWithDirectories(\n newFilePath,\n JSON.stringify(dictionaryWithoutPath, null, 2)\n );\n\n return {\n status: 'updated',\n path: newFilePath,\n };\n }\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const contentDeclarationPath = `${newDictionaryLocationPath}/${dictionary.key}.content.json`;\n await writeFileWithDirectories(\n contentDeclarationPath,\n JSON.stringify(dictionaryWithoutPath, null, 2)\n );\n return {\n status: 'reimported in new location',\n path: contentDeclarationPath,\n };\n }\n }\n } else {\n // No existing dictionary, write to new location\n const contentDeclarationPath = `${newDictionaryLocationPath}/${dictionary.key}.content.json`;\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n JSON.stringify(dictionary, null, 2)\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n }\n};\n\nconst writeFileWithDirectories = async (\n filePath: string,\n data: string | Buffer\n): Promise<void> => {\n try {\n // Extract the directory from the file path\n const dir = dirname(filePath);\n\n // Check if the directory exists\n const directoryExists = existsSync(dir);\n\n if (!directoryExists) {\n // Create the directory recursively\n await fsPromises.mkdir(dir, { recursive: true });\n }\n\n // Write the file\n await fsPromises.writeFile(filePath, data);\n } catch (error) {\n throw new Error(`Error writing file to ${filePath}: ${error}`);\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAA2B;AAC3B,iBAA4B;AAC5B,kBAA2C;AAC3C,oBAAsD;AAEtD,gCAA+B;AAC/B,wBAAsB;AAGtB,MAAM,8BAA8B;AAE7B,MAAM,0BAA0B,OACrC,YACA,QACA,wBACwD;AACxD,QAAM;AAAA,I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;AAAA,EACF,OAAO;AAEL,UAAM,yBAAyB,GAAG,yBAAyB,IAAI,WAAW,GAAG;AAE7E,UAAM;AAAA,MACJ;AAAA,MACA,KAAK,UAAU,YAAY,MAAM,CAAC;AAAA,IACpC;AAEA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEA,MAAM,2BAA2B,OAC/B,UACA,SACkB;AAClB,MAAI;AAEF,UAAM,UAAM,qBAAQ,QAAQ;AAG5B,UAAM,sBAAkB,sBAAW,GAAG;AAEtC,QAAI,CAAC,iBAAiB;AAEpB,YAAM,WAAW,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IACjD;AAGA,UAAM,WAAW,UAAU,UAAU,IAAI;AAAA,EAC3C,SAAS,OAAO;AACd,UAAM,IAAI,MAAM,yBAAyB,QAAQ,KAAK,KAAK,EAAE;AAAA,EAC/D;AACF;","names":["dictionariesRecord","deepEqual"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/server/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport * as fsPromises from 'fs/promises';\nimport { basename, dirname, extname } from 'path';\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/server/writeContentDeclaration.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport * as fsPromises from 'fs/promises';\nimport { basename, dirname, extname } from 'path';\nimport { type IntlayerConfig, getConfiguration } from '@intlayer/config/client';\nimport type { Dictionary } from '@intlayer/core';\nimport dictionariesRecord from '@intlayer/dictionaries-entry';\nimport deepEqual from 'deep-equal';\nimport type { DictionaryStatus } from '../dictionaryStatus';\n\nconst DEFAULT_NEW_DICTIONARY_PATH = 'intlayer-dictionaries';\n\nexport const writeContentDeclaration = async (\n dictionary: Dictionary,\n config?: IntlayerConfig,\n newDictionariesPath?: string\n): Promise<{ status: DictionaryStatus; path: string }> => {\n const {\n content: { baseDir },\n } = config ?? getConfiguration();\n\n const newDictionaryRelativeLocationPath =\n newDictionariesPath ?? DEFAULT_NEW_DICTIONARY_PATH;\n const newDictionaryLocationPath = `${baseDir}/${newDictionaryRelativeLocationPath}`;\n\n const existingDictionary = dictionariesRecord[dictionary.key];\n\n if (existingDictionary) {\n const { filePath, ...dictionaryWithoutPath } = dictionary;\n\n // Compare existing dictionary with distant dictionary\n if (deepEqual(existingDictionary, dictionary)) {\n // Up to date, nothing to do\n return {\n status: 'up-to-date',\n path: filePath!,\n };\n } else {\n if (filePath) {\n const isDictionaryJSON = filePath.endsWith('.json');\n\n if (isDictionaryJSON) {\n const contentDeclarationPath = `${baseDir}/${filePath}`;\n // Write the dictionary to the same location of the existing dictionary file\n await fsPromises.writeFile(\n contentDeclarationPath,\n JSON.stringify(\n {\n $schema: 'https://intlayer.org/schema.json',\n ...dictionaryWithoutPath,\n },\n null,\n 2\n )\n );\n return { status: 'updated', path: contentDeclarationPath };\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const dictionariesDirPath = dirname(filePath);\n const dictionariesFileName = basename(filePath, extname(filePath));\n\n const newFilePath = `${dictionariesDirPath}/${dictionariesFileName}.json`;\n\n await writeFileWithDirectories(\n newFilePath,\n JSON.stringify(dictionaryWithoutPath, null, 2)\n );\n\n return {\n status: 'updated',\n path: newFilePath,\n };\n }\n } else {\n // Write the dictionary to the intlayer-dictionaries directory\n const contentDeclarationPath = `${newDictionaryLocationPath}/${dictionary.key}.content.json`;\n await writeFileWithDirectories(\n contentDeclarationPath,\n JSON.stringify(dictionaryWithoutPath, null, 2)\n );\n return {\n status: 'reimported in new location',\n path: contentDeclarationPath,\n };\n }\n }\n } else {\n // No existing dictionary, write to new location\n const contentDeclarationPath = `${newDictionaryLocationPath}/${dictionary.key}.content.json`;\n\n await writeFileWithDirectories(\n contentDeclarationPath,\n JSON.stringify(dictionary, null, 2)\n );\n\n return {\n status: 'imported',\n path: contentDeclarationPath,\n };\n }\n};\n\nconst writeFileWithDirectories = async (\n filePath: string,\n data: string | Buffer\n): Promise<void> => {\n try {\n // Extract the directory from the file path\n const dir = dirname(filePath);\n\n // Check if the directory exists\n const directoryExists = existsSync(dir);\n\n if (!directoryExists) {\n // Create the directory recursively\n await fsPromises.mkdir(dir, { recursive: true });\n }\n\n // Write the file\n await fsPromises.writeFile(filePath, data);\n } catch (error) {\n throw new Error(`Error writing file to ${filePath}: ${error}`);\n }\n};\n"],"mappings":"AAAA,SAAS,kBAAkB;AAC3B,YAAY,gBAAgB;AAC5B,SAAS,UAAU,SAAS,eAAe;AAC3C,SAA8B,wBAAwB;AAEtD,OAAO,wBAAwB;AAC/B,OAAO,eAAe;AAGtB,MAAM,8BAA8B;AAE7B,MAAM,0BAA0B,OACrC,YACA,QACA,wBACwD;AACxD,QAAM;AAAA,IACJ,SAAS,EAAE,QAAQ;AAAA,EACrB,IAAI,UAAU,iBAAiB;AAE/B,QAAM,oCACJ,uBAAuB;AACzB,QAAM,4BAA4B,GAAG,OAAO,IAAI,iCAAiC;AAEjF,QAAM,qBAAqB,mBAAmB,WAAW,GAAG;AAE5D,MAAI,oBAAoB;AACtB,UAAM,EAAE,UAAU,GAAG,sBAAsB,IAAI;AAG/C,QAAI,UAAU,oBAAoB,UAAU,GAAG;AAE7C,aAAO;AAAA,QACL,QAAQ;AAAA,QACR,MAAM;AAAA,MACR;AAAA,IACF,OAAO;AACL,UAAI,UAAU;AACZ,cAAM,mBAAmB,SAAS,SAAS,OAAO;AAElD,YAAI,kBAAkB;AACpB,gBAAM,yBAAyB,GAAG,OAAO,IAAI,QAAQ;AAErD,gBAAM,WAAW;AAAA,YACf;AAAA,YACA,KAAK;AAAA,cACH;AAAA,gBACE,SAAS;AAAA,gBACT,GAAG;AAAA,cACL;AAAA,cACA;AAAA,cACA;AAAA,YACF;AAAA,UACF;AACA,iBAAO,EAAE,QAAQ,WAAW,MAAM,uBAAuB;AAAA,QAC3D,OAAO;AAEL,gBAAM,sBAAsB,QAAQ,QAAQ;AAC5C,gBAAM,uBAAuB,SAAS,UAAU,QAAQ,QAAQ,CAAC;AAEjE,gBAAM,cAAc,GAAG,mBAAmB,IAAI,oBAAoB;AAElE,gBAAM;AAAA,YACJ;AAAA,YACA,KAAK,UAAU,uBAAuB,MAAM,CAAC;AAAA,UAC/C;AAEA,iBAAO;AAAA,YACL,QAAQ;AAAA,YACR,MAAM;AAAA,UACR;AAAA,QACF;AAAA,MACF,OAAO;AAEL,cAAM,yBAAyB,GAAG,yBAAyB,IAAI,WAAW,GAAG;AAC7E,cAAM;AAAA,UACJ;AAAA,UACA,KAAK,UAAU,uBAAuB,MAAM,CAAC;AAAA,QAC/C;AACA,eAAO;AAAA,UACL,QAAQ;AAAA,UACR,MAAM;AAAA,QACR;AAAA,MACF;AAAA,IACF;AAAA,EACF,OAAO;AAEL,UAAM,yBAAyB,GAAG,yBAAyB,IAAI,WAAW,GAAG;AAE7E,UAAM;AAAA,MACJ;AAAA,MACA,KAAK,UAAU,YAAY,MAAM,CAAC;AAAA,IACpC;AAEA,WAAO;AAAA,MACL,QAAQ;AAAA,MACR,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEA,MAAM,2BAA2B,OAC/B,UACA,SACkB;AAClB,MAAI;AAEF,UAAM,MAAM,QAAQ,QAAQ;AAG5B,UAAM,kBAAkB,WAAW,GAAG;AAEtC,QAAI,CAAC,iBAAiB;AAEpB,YAAM,WAAW,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IACjD;AAGA,UAAM,WAAW,UAAU,UAAU,IAAI;AAAA,EAC3C,SAAS,OAAO;AACd,UAAM,IAAI,MAAM,yBAAyB,QAAQ,KAAK,KAAK,EAAE;AAAA,EAC/D;AACF;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IntlayerConfig } from '@intlayer/config/client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { type IntlayerConfig } from '@intlayer/config/client';
|
|
2
|
+
import type { Dictionary } from '@intlayer/core';
|
|
3
|
+
import type { DictionaryStatus } from '../dictionaryStatus';
|
|
4
4
|
export declare const writeContentDeclaration: (dictionary: Dictionary, config?: IntlayerConfig, newDictionariesPath?: string) => Promise<{
|
|
5
5
|
status: DictionaryStatus;
|
|
6
6
|
path: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeContentDeclaration.d.ts","sourceRoot":"","sources":["../../../src/server/writeContentDeclaration.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"writeContentDeclaration.d.ts","sourceRoot":"","sources":["../../../src/server/writeContentDeclaration.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,yBAAyB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAI5D,eAAO,MAAM,uBAAuB,eACtB,UAAU,WACb,cAAc,wBACD,MAAM,KAC3B,OAAO,CAAC;IAAE,MAAM,EAAE,gBAAgB,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAoFpD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/editor",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provides the utilities to interface the application with the Intlayer editor and manipulate dictionaries",
|
|
6
6
|
"keywords": [
|
|
@@ -57,30 +57,30 @@
|
|
|
57
57
|
],
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"deep-equal": "^2.2.3",
|
|
60
|
-
"@intlayer/
|
|
61
|
-
"@intlayer/
|
|
62
|
-
"@intlayer/dictionaries-entry": "5.0
|
|
60
|
+
"@intlayer/config": "5.1.0",
|
|
61
|
+
"@intlayer/core": "5.1.0",
|
|
62
|
+
"@intlayer/dictionaries-entry": "5.1.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/deep-equal": "^1.0.4",
|
|
66
66
|
"@types/node": "^22.10.6",
|
|
67
|
-
"@typescript-eslint/parser": "^8.
|
|
67
|
+
"@typescript-eslint/parser": "^8.24.0",
|
|
68
68
|
"concurrently": "^9.1.2",
|
|
69
|
-
"eslint": "^9.
|
|
70
|
-
"prettier": "^3.
|
|
69
|
+
"eslint": "^9.20.0",
|
|
70
|
+
"prettier": "^3.5.0",
|
|
71
71
|
"rimraf": "^6.0.1",
|
|
72
72
|
"tsc-alias": "^1.8.10",
|
|
73
73
|
"tsup": "^8.3.5",
|
|
74
74
|
"typescript": "^5.7.3",
|
|
75
75
|
"@utils/eslint-config": "1.0.4",
|
|
76
|
-
"@utils/tsup-config": "1.0.4",
|
|
77
76
|
"@utils/ts-config": "1.0.4",
|
|
77
|
+
"@utils/tsup-config": "1.0.4",
|
|
78
78
|
"@utils/ts-config-types": "1.0.4"
|
|
79
79
|
},
|
|
80
80
|
"peerDependencies": {
|
|
81
|
-
"@intlayer/
|
|
82
|
-
"@intlayer/
|
|
83
|
-
"@intlayer/
|
|
81
|
+
"@intlayer/config": "5.1.0",
|
|
82
|
+
"@intlayer/core": "5.1.0",
|
|
83
|
+
"@intlayer/dictionaries-entry": "5.1.0"
|
|
84
84
|
},
|
|
85
85
|
"engines": {
|
|
86
86
|
"node": ">=14.18"
|