@intlayer/chokidar 6.0.0-canary.1 → 6.0.0-canary.3

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.
@@ -79,6 +79,16 @@ const printSummary = (configuration = (0, import_config.getConfiguration)()) =>
79
79
  byKey.set(s.dictionaryKey, rec);
80
80
  }
81
81
  const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));
82
+ let maxLocalLabelLen = 0;
83
+ for (const key of keys) {
84
+ const rec = byKey.get(key);
85
+ if (rec.local) {
86
+ const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
87
+ if (visibleLocal.length > maxLocalLabelLen) {
88
+ maxLocalLabelLen = visibleLocal.length;
89
+ }
90
+ }
91
+ }
82
92
  for (const key of keys) {
83
93
  const rec = byKey.get(key);
84
94
  const labels = [];
@@ -87,9 +97,12 @@ const printSummary = (configuration = (0, import_config.getConfiguration)()) =>
87
97
  `${iconFor(rec.local)} ${rec.local}`,
88
98
  colorFor(rec.local)
89
99
  );
90
- labels.push(
91
- `${import_config.ANSIColors.GREY}[` + (0, import_config.colorize)("local: ", import_config.ANSIColors.GREY) + inner + `${import_config.ANSIColors.GREY}]${import_config.ANSIColors.RESET}`
92
- );
100
+ const coloredLocal = `${import_config.ANSIColors.GREY}[` + (0, import_config.colorize)("local: ", import_config.ANSIColors.GREY) + inner + `${import_config.ANSIColors.GREY}]${import_config.ANSIColors.RESET}`;
101
+ const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
102
+ const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);
103
+ labels.push(coloredLocal + " ".repeat(pad));
104
+ } else {
105
+ labels.push(" ".repeat(maxLocalLabelLen));
93
106
  }
94
107
  if (rec.remote) {
95
108
  const inner = (0, import_config.colorize)(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'node:path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n}> => {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n appLogger(\n [\n 'Content declaration has no exported content',\n dict.filePath\n ? relative(configuration.content.baseDir, dict.filePath)\n : '',\n ],\n { level: 'error' }\n );\n } else if (!hasKey) {\n appLogger(['Content declaration has no key', dict.filePath], {\n level: 'error',\n });\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus\n );\n }\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBASO;AAEP,uBAAyB;AACzB,oCAAwC;AACxC,oCAAuC;AACvC,iBAAmC;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,8BAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AAEA,2BAAyB;AACzB,SAAO,OAAO,QAAQ;AAEtB,SAAO;AACT;AAOA,MAAM,UAAU,CAAC,WAAyC;AACxD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA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BAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,UAAM;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'node:path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n}> => {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n appLogger(\n [\n 'Content declaration has no exported content',\n dict.filePath\n ? relative(configuration.content.baseDir, dict.filePath)\n : '',\n ],\n { level: 'error' }\n );\n } else if (!hasKey) {\n appLogger(['Content declaration has no key', dict.filePath], {\n level: 'error',\n });\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus\n );\n }\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBASO;AAEP,uBAAyB;AACzB,oCAAwC;AACxC,oCAAuC;AACvC,iBAAmC;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,8BAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AAEA,2BAAyB;AACzB,SAAO,OAAO,QAAQ;AAEtB,SAAO;AACT;AAOA,MAAM,UAAU,CAAC,WAAyC;AACxD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,MAAM,WAAW,CAAC,WAAyC;AACzD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,yBAAW;AAAA,IACpB,KAAK;AACH,aAAO,yBAAW;AAAA,IACpB;AACE,aAAO,yBAAW;AAAA,EACtB;AACF;AAEA,MAAM,eAAe,CAAC,oBAAgC,gCAAiB,MAAM;AAC3E,MAAI,cAAc,IAAI,SAAS,UAAW;AAE1C,QAAM,gBAAY,4BAAa,aAAa;AAG5C,QAAM,QAAQ,oBAAI,IAA0B;AAC5C,aAAW,KAAK,w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,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,UAAM;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
@@ -64,6 +64,16 @@ const printSummary = (configuration = getConfiguration()) => {
64
64
  byKey.set(s.dictionaryKey, rec);
65
65
  }
66
66
  const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));
67
+ let maxLocalLabelLen = 0;
68
+ for (const key of keys) {
69
+ const rec = byKey.get(key);
70
+ if (rec.local) {
71
+ const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
72
+ if (visibleLocal.length > maxLocalLabelLen) {
73
+ maxLocalLabelLen = visibleLocal.length;
74
+ }
75
+ }
76
+ }
67
77
  for (const key of keys) {
68
78
  const rec = byKey.get(key);
69
79
  const labels = [];
@@ -72,9 +82,12 @@ const printSummary = (configuration = getConfiguration()) => {
72
82
  `${iconFor(rec.local)} ${rec.local}`,
73
83
  colorFor(rec.local)
74
84
  );
75
- labels.push(
76
- `${ANSIColors.GREY}[` + colorize("local: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`
77
- );
85
+ const coloredLocal = `${ANSIColors.GREY}[` + colorize("local: ", ANSIColors.GREY) + inner + `${ANSIColors.GREY}]${ANSIColors.RESET}`;
86
+ const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;
87
+ const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);
88
+ labels.push(coloredLocal + " ".repeat(pad));
89
+ } else {
90
+ labels.push(" ".repeat(maxLocalLabelLen));
78
91
  }
79
92
  if (rec.remote) {
80
93
  const inner = colorize(
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'node:path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n}> => {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n appLogger(\n [\n 'Content declaration has no exported content',\n dict.filePath\n ? relative(configuration.content.baseDir, dict.filePath)\n : '',\n ],\n { level: 'error' }\n );\n } else if (!hasKey) {\n appLogger(['Content declaration has no key', dict.filePath], {\n level: 'error',\n });\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus\n );\n }\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n };\n};\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,mBAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,I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;AAAA,EACnB,CAAC;AAED,QAAM,0BAA0B,0BAA0B;AAAA,IACxD,CAAC,UACE;AAAA,MACC,eAAe,KAAK;AAAA,MACpB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,MAAM;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"sourcesContent":["// @ts-ignore @intlayer/backend is not build yet\nimport {\n ANSIColors,\n colon,\n colorize,\n colorizeKey,\n ESMxCJSRequire,\n getAppLogger,\n getConfiguration,\n type IntlayerConfig,\n} from '@intlayer/config';\nimport type { Dictionary } from '@intlayer/core';\nimport { relative } from 'node:path';\nimport { loadContentDeclarations } from './loadContentDeclaration';\nimport { loadRemoteDictionaries } from './loadRemoteDictionaries';\nimport { DictionariesLogger } from './log';\n\nexport type DictionariesStatus = {\n dictionaryKey: string;\n type: 'local' | 'remote';\n status:\n | 'pending' // Key found but not fetched yet\n | 'fetching' // If dictionary fetch is in progress\n | 'fetched' // If dictionary fetch succeeded\n | 'error' // If dictionary fetch failed\n | 'imported' // If dictionary already fetched and still up to date\n | 'found' // If dictionary key is found but promise is not resolved yet (ex: fetching distant content)\n | 'building' // If dictionary is being built\n | 'built'; // If dictionary is built;\n error?: string;\n};\n\nlet loadDictionariesStatus: DictionariesStatus[] = [];\nconst logger = new DictionariesLogger();\n\nconst setLoadDictionariesStatus = (statuses: DictionariesStatus[]) => {\n let updated: DictionariesStatus[] = [...loadDictionariesStatus];\n\n for (const incoming of statuses) {\n const idx = updated.findIndex(\n (s) =>\n s.dictionaryKey === incoming.dictionaryKey && s.type === incoming.type\n );\n if (idx >= 0) {\n updated[idx] = incoming;\n } else {\n updated.push(incoming);\n }\n }\n\n loadDictionariesStatus = updated;\n logger.update(statuses);\n\n return updated;\n};\n\ntype StatusRecord = {\n local?: DictionariesStatus['status'];\n remote?: DictionariesStatus['status'];\n};\n\nconst iconFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return '✔';\n case 'error':\n return '✖';\n default:\n return '⏲';\n }\n};\n\nconst colorFor = (status: DictionariesStatus['status']) => {\n switch (status) {\n case 'built':\n case 'imported':\n case 'fetched':\n return ANSIColors.GREEN;\n case 'error':\n return ANSIColors.RED;\n default:\n return ANSIColors.BLUE;\n }\n};\n\nconst printSummary = (configuration: IntlayerConfig = getConfiguration()) => {\n if (configuration.log.mode !== 'verbose') return;\n\n const appLogger = getAppLogger(configuration);\n\n // Aggregate by dictionary key\n const byKey = new Map<string, StatusRecord>();\n for (const s of loadDictionariesStatus) {\n const rec = byKey.get(s.dictionaryKey) ?? {};\n if (s.type === 'local') rec.local = s.status;\n if (s.type === 'remote') rec.remote = s.status;\n byKey.set(s.dictionaryKey, rec);\n }\n\n const keys = Array.from(byKey.keys()).sort((a, b) => a.localeCompare(b));\n\n // Compute the max visible length of the local label to align distant labels\n let maxLocalLabelLen = 0;\n for (const key of keys) {\n const rec = byKey.get(key)!;\n if (rec.local) {\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n if (visibleLocal.length > maxLocalLabelLen) {\n maxLocalLabelLen = visibleLocal.length;\n }\n }\n }\n\n for (const key of keys) {\n const rec = byKey.get(key)!;\n const labels: string[] = [];\n\n if (rec.local) {\n const inner = colorize(\n `${iconFor(rec.local)} ${rec.local}`,\n colorFor(rec.local)\n );\n const coloredLocal =\n `${ANSIColors.GREY}[` +\n colorize('local: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`;\n\n // Pad to align distant label across rows\n const visibleLocal = `[local: ${iconFor(rec.local)} ${rec.local}]`;\n const pad = Math.max(0, maxLocalLabelLen - visibleLocal.length);\n labels.push(coloredLocal + ' '.repeat(pad));\n } else {\n // If no local label, insert spaces to keep distant aligned\n labels.push(' '.repeat(maxLocalLabelLen));\n }\n\n if (rec.remote) {\n const inner = colorize(\n `${iconFor(rec.remote)} ${rec.remote}`,\n colorFor(rec.remote)\n );\n labels.push(\n `${ANSIColors.GREY}[` +\n colorize('distant: ', ANSIColors.GREY) +\n inner +\n `${ANSIColors.GREY}]${ANSIColors.RESET}`\n );\n }\n\n appLogger(\n ` - ${colon(colorizeKey(key), { colSize: keys })} ${labels.join(' ')}`\n );\n }\n};\n\nexport const loadDictionaries = async (\n contentDeclarationsPaths: string[] | string,\n configuration: IntlayerConfig = getConfiguration(),\n projectRequire = ESMxCJSRequire\n): Promise<{\n localDictionaries: Dictionary[];\n remoteDictionaries: Dictionary[];\n}> => {\n const appLogger = getAppLogger(configuration);\n\n appLogger('Dictionaries:', { isVerbose: true });\n\n const files = Array.isArray(contentDeclarationsPaths)\n ? contentDeclarationsPaths\n : [contentDeclarationsPaths];\n\n const localDictionaries: Dictionary[] = await loadContentDeclarations(\n files,\n configuration,\n projectRequire,\n setLoadDictionariesStatus\n );\n\n const filteredLocalDictionaries = localDictionaries.filter((dict) => {\n const hasKey = Boolean(dict.key);\n const hasContent = Boolean(dict.content);\n\n if (!hasContent) {\n appLogger(\n [\n 'Content declaration has no exported content',\n dict.filePath\n ? relative(configuration.content.baseDir, dict.filePath)\n : '',\n ],\n { level: 'error' }\n );\n } else if (!hasKey) {\n appLogger(['Content declaration has no key', dict.filePath], {\n level: 'error',\n });\n }\n\n return hasKey && hasContent;\n });\n\n const localDictionariesStatus = filteredLocalDictionaries.map(\n (dict) =>\n ({\n dictionaryKey: dict.key,\n type: 'local',\n status: 'built',\n }) as const\n );\n\n setLoadDictionariesStatus(localDictionariesStatus);\n\n const hasRemoteDictionaries = Boolean(\n configuration.editor.clientId && configuration.editor.clientSecret\n );\n\n let remoteDictionaries: Dictionary[] = [];\n if (hasRemoteDictionaries) {\n remoteDictionaries = await loadRemoteDictionaries(\n configuration,\n setLoadDictionariesStatus\n );\n }\n\n // Stop spinner and show final progress line(s)\n logger.finish();\n\n printSummary(configuration);\n\n return {\n localDictionaries: filteredLocalDictionaries,\n remoteDictionaries,\n };\n};\n"],"mappings":"AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,gBAAgB;AACzB,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AACvC,SAAS,0BAA0B;AAiBnC,IAAI,yBAA+C,CAAC;AACpD,MAAM,SAAS,IAAI,mBAAmB;AAEtC,MAAM,4BAA4B,CAAC,aAAmC;AACpE,MAAI,UAAgC,CAAC,GAAG,sBAAsB;AAE9D,aAAW,YAAY,UAAU;AAC/B,UAAM,MAAM,QAAQ;AAAA,MAClB,CAAC,MACC,EAAE,kBAAkB,SAAS,iBAAiB,EAAE,SAAS,SAAS;AAAA,IACtE;AACA,QAAI,OAAO,GAAG;AACZ,cAAQ,GAAG,IAAI;AAAA,IACjB,OAAO;AACL,cAAQ,KAAK,QAAQ;AAAA,IACvB;AAAA,EACF;AAEA,2BAAyB;AACzB,SAAO,OAAO,QAAQ;AAEtB,SAAO;AACT;AAOA,MAAM,UAAU,CAAC,WAAyC;AACxD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT;AACE,aAAO;AAAA,EACX;AACF;AAEA,MAAM,WAAW,CAAC,WAAyC;AACzD,UAAQ,QAAQ;AAAA,IACd,KAAK;AAAA,IACL,KAAK;AAAA,IACL,KAAK;AACH,aAAO,WAAW;AAAA,IACpB,KAAK;AACH,aAAO,WAAW;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,QAAQ,GAAG;AAAA,QAC3D,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,WAAO,UAAU;AAAA,EACnB,CAAC;AAED,QAAM,0BAA0B,0BAA0B;AAAA,IACxD,CAAC,UACE;AAAA,MACC,eAAe,KAAK;AAAA,MACpB,MAAM;AAAA,MACN,QAAQ;AAAA,IACV;AAAA,EACJ;AAEA,4BAA0B,uBAAuB;AAEjD,QAAM,wBAAwB;AAAA,IAC5B,cAAc,OAAO,YAAY,cAAc,OAAO;AAAA,EACxD;AAEA,MAAI,qBAAmC,CAAC;AACxC,MAAI,uBAAuB;AACzB,yBAAqB,MAAM;AAAA,MACzB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAGA,SAAO,OAAO;AAEd,eAAa,aAAa;AAE1B,SAAO;AAAA,IACL,mBAAmB;AAAA,IACnB;AAAA,EACF;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,MAAM,EACF,SAAS,GACT,UAAU,GACV,SAAS,GACT,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA6GF,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,gBAAe,cAAmC,EAClD,+BAA+B,KAC9B,OAAO,CAAC;IACT,iBAAiB,EAAE,UAAU,EAAE,CAAC;IAChC,kBAAkB,EAAE,UAAU,EAAE,CAAC;CAClC,CAuEA,CAAC"}
1
+ {"version":3,"file":"loadDictionaries.d.ts","sourceRoot":"","sources":["../../../src/loadDictionaries/loadDictionaries.ts"],"names":[],"mappings":"AACA,OAAO,EAQL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAMjD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,MAAM,EACF,SAAS,GACT,UAAU,GACV,SAAS,GACT,OAAO,GACP,UAAU,GACV,OAAO,GACP,UAAU,GACV,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAgIF,eAAO,MAAM,gBAAgB,GAC3B,0BAA0B,MAAM,EAAE,GAAG,MAAM,EAC3C,gBAAe,cAAmC,EAClD,+BAA+B,KAC9B,OAAO,CAAC;IACT,iBAAiB,EAAE,UAAU,EAAE,CAAC;IAChC,kBAAkB,EAAE,UAAU,EAAE,CAAC;CAClC,CAuEA,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/chokidar",
3
- "version": "6.0.0-canary.1",
3
+ "version": "6.0.0-canary.3",
4
4
  "private": false,
5
5
  "description": "Uses chokidar to scan and build Intlayer declaration files into dictionaries based on Intlayer configuration.",
6
6
  "keywords": [
@@ -68,12 +68,12 @@
68
68
  "fast-glob": "^3.3.3",
69
69
  "p-limit": "^3.1.0",
70
70
  "simple-git": "^3.27.0",
71
- "@intlayer/api": "6.0.0-canary.1",
72
- "@intlayer/config": "6.0.0-canary.1",
73
- "@intlayer/dictionaries-entry": "6.0.0-canary.1",
74
- "@intlayer/unmerged-dictionaries-entry": "6.0.0-canary.1",
75
- "@intlayer/core": "6.0.0-canary.1",
76
- "@intlayer/remote-dictionaries-entry": "6.0.0-canary.1"
71
+ "@intlayer/api": "6.0.0-canary.3",
72
+ "@intlayer/config": "6.0.0-canary.3",
73
+ "@intlayer/remote-dictionaries-entry": "6.0.0-canary.3",
74
+ "@intlayer/unmerged-dictionaries-entry": "6.0.0-canary.3",
75
+ "@intlayer/core": "6.0.0-canary.3",
76
+ "@intlayer/dictionaries-entry": "6.0.0-canary.3"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@changesets/cli": "2.29.5",
@@ -92,20 +92,20 @@
92
92
  "typescript": "^5.9.2",
93
93
  "vitest": "^3.2.4",
94
94
  "@utils/eslint-config": "1.0.4",
95
- "@utils/ts-config": "1.0.4",
95
+ "@utils/ts-config-types": "1.0.4",
96
96
  "@utils/tsup-config": "1.0.4",
97
- "@utils/ts-config-types": "1.0.4"
97
+ "@utils/ts-config": "1.0.4"
98
98
  },
99
99
  "peerDependencies": {
100
100
  "fast-glob": "^3.3.3",
101
101
  "react": ">=16.0.0",
102
- "@intlayer/api": "6.0.0-canary.1",
103
- "@intlayer/core": "6.0.0-canary.1",
104
- "intlayer": "6.0.0-canary.1",
105
- "@intlayer/config": "6.0.0-canary.1",
106
- "@intlayer/dictionaries-entry": "6.0.0-canary.1",
107
- "@intlayer/unmerged-dictionaries-entry": "6.0.0-canary.1",
108
- "@intlayer/remote-dictionaries-entry": "6.0.0-canary.1"
102
+ "@intlayer/api": "6.0.0-canary.3",
103
+ "@intlayer/core": "6.0.0-canary.3",
104
+ "@intlayer/remote-dictionaries-entry": "6.0.0-canary.3",
105
+ "@intlayer/dictionaries-entry": "6.0.0-canary.3",
106
+ "@intlayer/config": "6.0.0-canary.3",
107
+ "@intlayer/unmerged-dictionaries-entry": "6.0.0-canary.3",
108
+ "intlayer": "6.0.0-canary.3"
109
109
  },
110
110
  "engines": {
111
111
  "node": ">=14.18"