@intlayer/cli 8.6.5 → 8.6.7

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.
@@ -89,18 +89,16 @@ const extract = async (options) => {
89
89
  });
90
90
  if (absoluteFiles.length === 0) return;
91
91
  const unmergedDictionaries = (0, _intlayer_unmerged_dictionaries_entry.getUnmergedDictionaries)(configuration);
92
- await Promise.all(absoluteFiles.map(async (filePath) => {
93
- try {
94
- await extractContent(filePath, packageName, {
95
- unmergedDictionaries,
96
- configuration,
97
- codeOnly: options.codeOnly,
98
- declarationOnly: options.declarationOnly
99
- });
100
- } catch (error) {
101
- appLogger(`Failed to transform ${filePath}: ${error.message}`);
102
- }
103
- }));
92
+ for (const filePath of absoluteFiles) try {
93
+ await extractContent(filePath, packageName, {
94
+ unmergedDictionaries,
95
+ configuration,
96
+ codeOnly: options.codeOnly,
97
+ declarationOnly: options.declarationOnly
98
+ });
99
+ } catch (error) {
100
+ appLogger(`Failed to transform ${filePath}: ${error.message}`);
101
+ }
104
102
  await (0, _intlayer_chokidar_build.prepareIntlayer)(configuration);
105
103
  };
106
104
 
@@ -1 +1 @@
1
- {"version":3,"file":"extract.cjs","names":["x","ANSIColors"],"sources":["../../src/extract.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { PackageName } from '@intlayer/babel';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { buildComponentFilesList, formatPath } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger, x } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport enquirer from 'enquirer';\n\ntype ExtractOptions = {\n files?: string[];\n output?: FilePathPattern;\n configOptions?: GetConfigurationOptions;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extract = async (options: ExtractOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const { baseDir } = configuration.system;\n const { output } = configuration.compiler;\n\n if (!output) {\n appLogger(\n `${x} No output configuration found. Add a ${colorize('compiler.output', ANSIColors.BLUE)} in your configuration.`,\n {\n level: 'error',\n }\n );\n return;\n }\n\n const { detectPackageName, extractContent } = await import('@intlayer/babel');\n\n // Detect package\n const packageName: PackageName = detectPackageName(baseDir);\n\n let filesToExtract = options.files ?? [];\n\n if (filesToExtract.length === 0) {\n // Await all promises simultaneously\n const fileList = buildComponentFilesList(configuration);\n\n // Flatten the nested arrays and remove duplicates\n // Relative paths for selection\n const choices = fileList.map((file) => {\n const relPath = relative(baseDir, file);\n\n return {\n value: file,\n label: relPath,\n };\n });\n\n if (choices.length === 0) {\n appLogger('No extractable files found in the project.');\n return;\n }\n\n const SELECT_ALL = '__select_all__';\n\n type PromptChoice = {\n name: string;\n enabled: boolean;\n disabled?: boolean | string;\n };\n\n type PromptContext = {\n choices: PromptChoice[];\n render(): void | Promise<void>;\n state: { submitted: boolean };\n selected: PromptChoice[];\n input: string;\n options: { multiple?: boolean };\n };\n\n let selectedFiles: string[] | symbol;\n try {\n const maxLen = Math.max((process.stdout.columns || 80) - 15, 20);\n const truncatePath = (path: string) =>\n path.length > maxLen ? `...${path.slice(-(maxLen - 3))}` : path;\n\n const { files: enquirerSelectedFiles } = await enquirer.prompt<{\n files: string[];\n }>({\n type: 'autocomplete',\n name: 'files',\n message: 'Select files to extract (Type to search):',\n multiple: true,\n // @ts-ignore limit exist but is not typed\n limit: 40,\n choices: [\n { name: SELECT_ALL, message: '────── Select all ──────' },\n ...choices.map((choice) => ({\n name: choice.value,\n message: truncatePath(choice.label),\n })),\n ],\n async toggle(\n this: PromptContext,\n choice: PromptChoice,\n enabled?: boolean\n ) {\n if (!choice || choice.disabled) return;\n choice.enabled = enabled == null ? !choice.enabled : enabled;\n\n if (choice.name === SELECT_ALL) {\n this.choices\n .filter((choiceEl) => choiceEl.name !== SELECT_ALL)\n .forEach((choiceEl) => {\n choiceEl.enabled = choice.enabled;\n });\n }\n\n return this.render();\n },\n format(this: PromptContext) {\n if (this.state?.submitted && this.options?.multiple) {\n return `${this.selected.filter((s) => s.name !== SELECT_ALL).length} file(s) selected`;\n }\n return this.input ?? '';\n },\n });\n\n selectedFiles = enquirerSelectedFiles.filter(\n (file) => file !== SELECT_ALL\n );\n } catch {\n selectedFiles = Symbol('cancel');\n }\n\n if (typeof selectedFiles === 'symbol') {\n // User cancelled\n process.exit(0);\n }\n\n filesToExtract = selectedFiles as string[];\n }\n\n if (filesToExtract.length === 0) {\n appLogger('No files selected for extraction.');\n return;\n }\n\n const absoluteFiles = filesToExtract\n .map((file) => resolve(baseDir, file))\n .filter((file) => {\n if (!existsSync(file)) {\n appLogger(`File not found: ${formatPath(file)}`);\n return false;\n }\n return true;\n });\n\n if (absoluteFiles.length === 0) {\n return;\n }\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n await Promise.all(\n absoluteFiles.map(async (filePath) => {\n try {\n await extractContent(filePath, packageName, {\n unmergedDictionaries,\n configuration,\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n } catch (error) {\n appLogger(\n `Failed to transform ${filePath}: ${(error as Error).message}`\n );\n }\n })\n );\n\n await prepareIntlayer(configuration); // Prepare Intlayer to apply the changes\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,UAAU,OAAO,YAA4B;CACxD,MAAM,4DAAiC,QAAQ,cAAc;AAE7D,8CAAiB,SAAS,cAAc;CAExC,MAAM,sDAAyB,cAAc;CAE7C,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,WAAW,cAAc;AAEjC,KAAI,CAAC,QAAQ;AACX,YACE,GAAGA,0BAAE,8E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AEtE,YAAO,KAAK,SAAS;;IAExB,CAAC;AAEF,mBAAgB,sBAAsB,QACnC,SAAS,SAAS,WACpB;UACK;AACN,mBAAgB,OAAO,SAAS;;AAGlC,MAAI,OAAO,kBAAkB,SAE3B,SAAQ,KAAK,EAAE;AAGjB,mBAAiB;;AAGnB,KAAI,eAAe,WAAW,GAAG;AAC/B,YAAU,oCAAoC;AAC9C;;CAGF,MAAM,gBAAgB,eACnB,KAAK,gCAAiB,SAAS,KAAK,CAAC,CACrC,QAAQ,SAAS;AAChB,MAAI,yBAAY,KAAK,EAAE;AACrB,aAAU,4DAA8B,KAAK,GAAG;AAChD,UAAO;;AAET,SAAO;GACP;AAEJ,KAAI,cAAc,WAAW,EAC3B;CAGF,MAAM,0FAA+C,cAAc;AAEnE,OAAM,QAAQ,IACZ,cAAc,IAAI,OAAO,aAAa;AACpC,MAAI;AACF,SAAM,eAAe,UAAU,aAAa;IAC1C;IACA;IACA,UAAU,QAAQ;IAClB,iBAAiB,QAAQ;IAC1B,CAAC;WACK,OAAO;AACd,aACE,uBAAuB,SAAS,IAAK,MAAgB,UACtD;;GAEH,CACH;AAED,qDAAsB,cAAc"}
1
+ {"version":3,"file":"extract.cjs","names":["x","ANSIColors"],"sources":["../../src/extract.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { PackageName } from '@intlayer/babel';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { buildComponentFilesList, formatPath } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger, x } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport enquirer from 'enquirer';\n\ntype ExtractOptions = {\n files?: string[];\n output?: FilePathPattern;\n configOptions?: GetConfigurationOptions;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extract = async (options: ExtractOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const { baseDir } = configuration.system;\n const { output } = configuration.compiler;\n\n if (!output) {\n appLogger(\n `${x} No output configuration found. Add a ${colorize('compiler.output', ANSIColors.BLUE)} in your configuration.`,\n {\n level: 'error',\n }\n );\n return;\n }\n\n const { detectPackageName, extractContent } = await import('@intlayer/babel');\n\n // Detect package\n const packageName: PackageName = detectPackageName(baseDir);\n\n let filesToExtract = options.files ?? [];\n\n if (filesToExtract.length === 0) {\n // Await all promises simultaneously\n const fileList = buildComponentFilesList(configuration);\n\n // Flatten the nested arrays and remove duplicates\n // Relative paths for selection\n const choices = fileList.map((file) => {\n const relPath = relative(baseDir, file);\n\n return {\n value: file,\n label: relPath,\n };\n });\n\n if (choices.length === 0) {\n appLogger('No extractable files found in the project.');\n return;\n }\n\n const SELECT_ALL = '__select_all__';\n\n type PromptChoice = {\n name: string;\n enabled: boolean;\n disabled?: boolean | string;\n };\n\n type PromptContext = {\n choices: PromptChoice[];\n render(): void | Promise<void>;\n state: { submitted: boolean };\n selected: PromptChoice[];\n input: string;\n options: { multiple?: boolean };\n };\n\n let selectedFiles: string[] | symbol;\n try {\n const maxLen = Math.max((process.stdout.columns || 80) - 15, 20);\n const truncatePath = (path: string) =>\n path.length > maxLen ? `...${path.slice(-(maxLen - 3))}` : path;\n\n const { files: enquirerSelectedFiles } = await enquirer.prompt<{\n files: string[];\n }>({\n type: 'autocomplete',\n name: 'files',\n message: 'Select files to extract (Type to search):',\n multiple: true,\n // @ts-ignore limit exist but is not typed\n limit: 40,\n choices: [\n { name: SELECT_ALL, message: '────── Select all ──────' },\n ...choices.map((choice) => ({\n name: choice.value,\n message: truncatePath(choice.label),\n })),\n ],\n async toggle(\n this: PromptContext,\n choice: PromptChoice,\n enabled?: boolean\n ) {\n if (!choice || choice.disabled) return;\n choice.enabled = enabled == null ? !choice.enabled : enabled;\n\n if (choice.name === SELECT_ALL) {\n this.choices\n .filter((choiceEl) => choiceEl.name !== SELECT_ALL)\n .forEach((choiceEl) => {\n choiceEl.enabled = choice.enabled;\n });\n }\n\n return this.render();\n },\n format(this: PromptContext) {\n if (this.state?.submitted && this.options?.multiple) {\n return `${this.selected.filter((s) => s.name !== SELECT_ALL).length} file(s) selected`;\n }\n return this.input ?? '';\n },\n });\n\n selectedFiles = enquirerSelectedFiles.filter(\n (file) => file !== SELECT_ALL\n );\n } catch {\n selectedFiles = Symbol('cancel');\n }\n\n if (typeof selectedFiles === 'symbol') {\n // User cancelled\n process.exit(0);\n }\n\n filesToExtract = selectedFiles as string[];\n }\n\n if (filesToExtract.length === 0) {\n appLogger('No files selected for extraction.');\n return;\n }\n\n const absoluteFiles = filesToExtract\n .map((file) => resolve(baseDir, file))\n .filter((file) => {\n if (!existsSync(file)) {\n appLogger(`File not found: ${formatPath(file)}`);\n return false;\n }\n return true;\n });\n\n if (absoluteFiles.length === 0) {\n return;\n }\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n for (const filePath of absoluteFiles) {\n try {\n await extractContent(filePath, packageName, {\n unmergedDictionaries,\n configuration,\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }\n\n await prepareIntlayer(configuration); // Prepare Intlayer to apply the changes\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAwBA,MAAa,UAAU,OAAO,YAA4B;CACxD,MAAM,4DAAiC,QAAQ,cAAc;AAE7D,8CAAiB,SAAS,cAAc;CAExC,MAAM,sDAAyB,cAAc;CAE7C,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,WAAW,cAAc;AAEjC,KAAI,CAAC,QAAQ;AACX,YACE,GAAGA,0BAAE,8EAAiD,mBAAmBC,wBAA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AS;;IAExB,CAAC;AAEF,mBAAgB,sBAAsB,QACnC,SAAS,SAAS,WACpB;UACK;AACN,mBAAgB,OAAO,SAAS;;AAGlC,MAAI,OAAO,kBAAkB,SAE3B,SAAQ,KAAK,EAAE;AAGjB,mBAAiB;;AAGnB,KAAI,eAAe,WAAW,GAAG;AAC/B,YAAU,oCAAoC;AAC9C;;CAGF,MAAM,gBAAgB,eACnB,KAAK,gCAAiB,SAAS,KAAK,CAAC,CACrC,QAAQ,SAAS;AAChB,MAAI,yBAAY,KAAK,EAAE;AACrB,aAAU,4DAA8B,KAAK,GAAG;AAChD,UAAO;;AAET,SAAO;GACP;AAEJ,KAAI,cAAc,WAAW,EAC3B;CAGF,MAAM,0FAA+C,cAAc;AAEnE,MAAK,MAAM,YAAY,cACrB,KAAI;AACF,QAAM,eAAe,UAAU,aAAa;GAC1C;GACA;GACA,UAAU,QAAQ;GAClB,iBAAiB,QAAQ;GAC1B,CAAC;UACK,OAAO;AACd,YAAU,uBAAuB,SAAS,IAAK,MAAgB,UAAU;;AAI7E,qDAAsB,cAAc"}
@@ -85,18 +85,16 @@ const extract = async (options) => {
85
85
  });
86
86
  if (absoluteFiles.length === 0) return;
87
87
  const unmergedDictionaries = getUnmergedDictionaries(configuration);
88
- await Promise.all(absoluteFiles.map(async (filePath) => {
89
- try {
90
- await extractContent(filePath, packageName, {
91
- unmergedDictionaries,
92
- configuration,
93
- codeOnly: options.codeOnly,
94
- declarationOnly: options.declarationOnly
95
- });
96
- } catch (error) {
97
- appLogger(`Failed to transform ${filePath}: ${error.message}`);
98
- }
99
- }));
88
+ for (const filePath of absoluteFiles) try {
89
+ await extractContent(filePath, packageName, {
90
+ unmergedDictionaries,
91
+ configuration,
92
+ codeOnly: options.codeOnly,
93
+ declarationOnly: options.declarationOnly
94
+ });
95
+ } catch (error) {
96
+ appLogger(`Failed to transform ${filePath}: ${error.message}`);
97
+ }
100
98
  await prepareIntlayer(configuration);
101
99
  };
102
100
 
@@ -1 +1 @@
1
- {"version":3,"file":"extract.mjs","names":[],"sources":["../../src/extract.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { PackageName } from '@intlayer/babel';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { buildComponentFilesList, formatPath } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger, x } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport enquirer from 'enquirer';\n\ntype ExtractOptions = {\n files?: string[];\n output?: FilePathPattern;\n configOptions?: GetConfigurationOptions;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extract = async (options: ExtractOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const { baseDir } = configuration.system;\n const { output } = configuration.compiler;\n\n if (!output) {\n appLogger(\n `${x} No output configuration found. Add a ${colorize('compiler.output', ANSIColors.BLUE)} in your configuration.`,\n {\n level: 'error',\n }\n );\n return;\n }\n\n const { detectPackageName, extractContent } = await import('@intlayer/babel');\n\n // Detect package\n const packageName: PackageName = detectPackageName(baseDir);\n\n let filesToExtract = options.files ?? [];\n\n if (filesToExtract.length === 0) {\n // Await all promises simultaneously\n const fileList = buildComponentFilesList(configuration);\n\n // Flatten the nested arrays and remove duplicates\n // Relative paths for selection\n const choices = fileList.map((file) => {\n const relPath = relative(baseDir, file);\n\n return {\n value: file,\n label: relPath,\n };\n });\n\n if (choices.length === 0) {\n appLogger('No extractable files found in the project.');\n return;\n }\n\n const SELECT_ALL = '__select_all__';\n\n type PromptChoice = {\n name: string;\n enabled: boolean;\n disabled?: boolean | string;\n };\n\n type PromptContext = {\n choices: PromptChoice[];\n render(): void | Promise<void>;\n state: { submitted: boolean };\n selected: PromptChoice[];\n input: string;\n options: { multiple?: boolean };\n };\n\n let selectedFiles: string[] | symbol;\n try {\n const maxLen = Math.max((process.stdout.columns || 80) - 15, 20);\n const truncatePath = (path: string) =>\n path.length > maxLen ? `...${path.slice(-(maxLen - 3))}` : path;\n\n const { files: enquirerSelectedFiles } = await enquirer.prompt<{\n files: string[];\n }>({\n type: 'autocomplete',\n name: 'files',\n message: 'Select files to extract (Type to search):',\n multiple: true,\n // @ts-ignore limit exist but is not typed\n limit: 40,\n choices: [\n { name: SELECT_ALL, message: '────── Select all ──────' },\n ...choices.map((choice) => ({\n name: choice.value,\n message: truncatePath(choice.label),\n })),\n ],\n async toggle(\n this: PromptContext,\n choice: PromptChoice,\n enabled?: boolean\n ) {\n if (!choice || choice.disabled) return;\n choice.enabled = enabled == null ? !choice.enabled : enabled;\n\n if (choice.name === SELECT_ALL) {\n this.choices\n .filter((choiceEl) => choiceEl.name !== SELECT_ALL)\n .forEach((choiceEl) => {\n choiceEl.enabled = choice.enabled;\n });\n }\n\n return this.render();\n },\n format(this: PromptContext) {\n if (this.state?.submitted && this.options?.multiple) {\n return `${this.selected.filter((s) => s.name !== SELECT_ALL).length} file(s) selected`;\n }\n return this.input ?? '';\n },\n });\n\n selectedFiles = enquirerSelectedFiles.filter(\n (file) => file !== SELECT_ALL\n );\n } catch {\n selectedFiles = Symbol('cancel');\n }\n\n if (typeof selectedFiles === 'symbol') {\n // User cancelled\n process.exit(0);\n }\n\n filesToExtract = selectedFiles as string[];\n }\n\n if (filesToExtract.length === 0) {\n appLogger('No files selected for extraction.');\n return;\n }\n\n const absoluteFiles = filesToExtract\n .map((file) => resolve(baseDir, file))\n .filter((file) => {\n if (!existsSync(file)) {\n appLogger(`File not found: ${formatPath(file)}`);\n return false;\n }\n return true;\n });\n\n if (absoluteFiles.length === 0) {\n return;\n }\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n await Promise.all(\n absoluteFiles.map(async (filePath) => {\n try {\n await extractContent(filePath, packageName, {\n unmergedDictionaries,\n configuration,\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n } catch (error) {\n appLogger(\n `Failed to transform ${filePath}: ${(error as Error).message}`\n );\n }\n })\n );\n\n await prepareIntlayer(configuration); // Prepare Intlayer to apply the changes\n};\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAa,UAAU,OAAO,YAA4B;CACxD,MAAM,gBAAgB,iBAAiB,QAAQ,cAAc;AAE7D,kBAAiB,SAAS,cAAc;CAExC,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,WAAW,cAAc;AAEjC,KAAI,CAAC,QAAQ;AACX,YACE,GAAG,EAAE,wCAAwC,SAAS,mBAAmB,WAAW,KAAK,CAAC,0BAC1F,EACE,OAAO,SACR,CACF;AACD;;CAGF,MAAM,EAAE,mBAAmB,mBAAmB,MAAM,OAAO;CAG3D,MAAM,cAA2B,kBAAkB,QAAQ;CAE3D,IAAI,iBAAiB,QAAQ,SAAS,EAAE;AAExC,KAAI,eAAe,WAAW,GAAG;EAM/B,MAAM,UAJW,wBAAwB,cAAc,CAI9B,KAAK,SAAS;AAGrC,UAAO;IACL,OAAO;IACP,OAJc,SAAS,SAAS,KAAK;IAKtC;IACD;AAEF,MAAI,QAAQ,WAAW,GAAG;AACxB,aAAU,6CAA6C;AACvD;;EAGF,MAAM,aAAa;EAiBnB,IAAI;AACJ,MAAI;GACF,MAAM,SAAS,KAAK,KAAK,QAAQ,OAAO,WAAW,MAAM,IAAI,GAAG;GAChE,MAAM,gBAAgB,SACpB,KAAK,SAAS,SAAS,MAAM,KAAK,MAAM,EAAE,SAAS,GAAG,KAAK;GAE7D,MAAM,EAAE,OAAO,0BAA0B,MAAM,SAAS,OAErD;IACD,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IAEV,OAAO;IACP,SAAS,CACP;KAAE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H,CACH;AAED,OAAM,gBAAgB,cAAc"}
1
+ {"version":3,"file":"extract.mjs","names":[],"sources":["../../src/extract.ts"],"sourcesContent":["import { existsSync } from 'node:fs';\nimport { relative, resolve } from 'node:path';\nimport type { PackageName } from '@intlayer/babel';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { buildComponentFilesList, formatPath } from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { colorize, getAppLogger, x } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport type { FilePathPattern } from '@intlayer/types/filePathPattern';\nimport { getUnmergedDictionaries } from '@intlayer/unmerged-dictionaries-entry';\nimport enquirer from 'enquirer';\n\ntype ExtractOptions = {\n files?: string[];\n output?: FilePathPattern;\n configOptions?: GetConfigurationOptions;\n codeOnly?: boolean;\n declarationOnly?: boolean;\n};\n\nexport const extract = async (options: ExtractOptions) => {\n const configuration = getConfiguration(options.configOptions);\n\n logConfigDetails(options?.configOptions);\n\n const appLogger = getAppLogger(configuration);\n\n const { baseDir } = configuration.system;\n const { output } = configuration.compiler;\n\n if (!output) {\n appLogger(\n `${x} No output configuration found. Add a ${colorize('compiler.output', ANSIColors.BLUE)} in your configuration.`,\n {\n level: 'error',\n }\n );\n return;\n }\n\n const { detectPackageName, extractContent } = await import('@intlayer/babel');\n\n // Detect package\n const packageName: PackageName = detectPackageName(baseDir);\n\n let filesToExtract = options.files ?? [];\n\n if (filesToExtract.length === 0) {\n // Await all promises simultaneously\n const fileList = buildComponentFilesList(configuration);\n\n // Flatten the nested arrays and remove duplicates\n // Relative paths for selection\n const choices = fileList.map((file) => {\n const relPath = relative(baseDir, file);\n\n return {\n value: file,\n label: relPath,\n };\n });\n\n if (choices.length === 0) {\n appLogger('No extractable files found in the project.');\n return;\n }\n\n const SELECT_ALL = '__select_all__';\n\n type PromptChoice = {\n name: string;\n enabled: boolean;\n disabled?: boolean | string;\n };\n\n type PromptContext = {\n choices: PromptChoice[];\n render(): void | Promise<void>;\n state: { submitted: boolean };\n selected: PromptChoice[];\n input: string;\n options: { multiple?: boolean };\n };\n\n let selectedFiles: string[] | symbol;\n try {\n const maxLen = Math.max((process.stdout.columns || 80) - 15, 20);\n const truncatePath = (path: string) =>\n path.length > maxLen ? `...${path.slice(-(maxLen - 3))}` : path;\n\n const { files: enquirerSelectedFiles } = await enquirer.prompt<{\n files: string[];\n }>({\n type: 'autocomplete',\n name: 'files',\n message: 'Select files to extract (Type to search):',\n multiple: true,\n // @ts-ignore limit exist but is not typed\n limit: 40,\n choices: [\n { name: SELECT_ALL, message: '────── Select all ──────' },\n ...choices.map((choice) => ({\n name: choice.value,\n message: truncatePath(choice.label),\n })),\n ],\n async toggle(\n this: PromptContext,\n choice: PromptChoice,\n enabled?: boolean\n ) {\n if (!choice || choice.disabled) return;\n choice.enabled = enabled == null ? !choice.enabled : enabled;\n\n if (choice.name === SELECT_ALL) {\n this.choices\n .filter((choiceEl) => choiceEl.name !== SELECT_ALL)\n .forEach((choiceEl) => {\n choiceEl.enabled = choice.enabled;\n });\n }\n\n return this.render();\n },\n format(this: PromptContext) {\n if (this.state?.submitted && this.options?.multiple) {\n return `${this.selected.filter((s) => s.name !== SELECT_ALL).length} file(s) selected`;\n }\n return this.input ?? '';\n },\n });\n\n selectedFiles = enquirerSelectedFiles.filter(\n (file) => file !== SELECT_ALL\n );\n } catch {\n selectedFiles = Symbol('cancel');\n }\n\n if (typeof selectedFiles === 'symbol') {\n // User cancelled\n process.exit(0);\n }\n\n filesToExtract = selectedFiles as string[];\n }\n\n if (filesToExtract.length === 0) {\n appLogger('No files selected for extraction.');\n return;\n }\n\n const absoluteFiles = filesToExtract\n .map((file) => resolve(baseDir, file))\n .filter((file) => {\n if (!existsSync(file)) {\n appLogger(`File not found: ${formatPath(file)}`);\n return false;\n }\n return true;\n });\n\n if (absoluteFiles.length === 0) {\n return;\n }\n\n const unmergedDictionaries = getUnmergedDictionaries(configuration);\n\n for (const filePath of absoluteFiles) {\n try {\n await extractContent(filePath, packageName, {\n unmergedDictionaries,\n configuration,\n codeOnly: options.codeOnly,\n declarationOnly: options.declarationOnly,\n });\n } catch (error) {\n appLogger(`Failed to transform ${filePath}: ${(error as Error).message}`);\n }\n }\n\n await prepareIntlayer(configuration); // Prepare Intlayer to apply the changes\n};\n"],"mappings":";;;;;;;;;;;;AAwBA,MAAa,UAAU,OAAO,YAA4B;CACxD,MAAM,gBAAgB,iBAAiB,QAAQ,cAAc;AAE7D,kBAAiB,SAAS,cAAc;CAExC,MAAM,YAAY,aAAa,cAAc;CAE7C,MAAM,EAAE,YAAY,cAAc;CAClC,MAAM,EAAE,WAAW,cAAc;AAEjC,KAAI,CAAC,QAAQ;AACX,YACE,GAAG,EAAE,wCAAwC,SAAS,mBAAmB,WAAW,KAAK,CAAC,0BAC1F,EACE,OAAO,SACR,CACF;AACD;;CAGF,MAAM,EAAE,mBAAmB,mBAAmB,MAAM,OAAO;CAG3D,MAAM,cAA2B,kBAAkB,QAAQ;CAE3D,IAAI,iBAAiB,QAAQ,SAAS,EAAE;AAExC,KAAI,eAAe,WAAW,GAAG;EAM/B,MAAM,UAJW,wBAAwB,cAAc,CAI9B,KAAK,SAAS;AAGrC,UAAO;IACL,OAAO;IACP,OAJc,SAAS,SAAS,KAAK;IAKtC;IACD;AAEF,MAAI,QAAQ,WAAW,GAAG;AACxB,aAAU,6CAA6C;AACvD;;EAGF,MAAM,aAAa;EAiBnB,IAAI;AACJ,MAAI;GACF,MAAM,SAAS,KAAK,KAAK,QAAQ,OAAO,WAAW,MAAM,IAAI,GAAG;GAChE,MAAM,gBAAgB,SACpB,KAAK,SAAS,SAAS,MAAM,KAAK,MAAM,EAAE,SAAS,GAAG,KAAK;GAE7D,MAAM,EAAE,OAAO,0BAA0B,MAAM,SAAS,OAErD;IACD,MAAM;IACN,MAAM;IACN,SAAS;IACT,UAAU;IAEV,OAAO;IACP,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,gBAAgB,cAAc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@intlayer/cli",
3
- "version": "8.6.5",
3
+ "version": "8.6.7",
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,16 +67,16 @@
67
67
  },
68
68
  "dependencies": {
69
69
  "@clack/prompts": "0.11.0",
70
- "@intlayer/ai": "8.6.5",
71
- "@intlayer/api": "8.6.5",
72
- "@intlayer/babel": "8.6.5",
73
- "@intlayer/chokidar": "8.6.5",
74
- "@intlayer/config": "8.6.5",
75
- "@intlayer/core": "8.6.5",
76
- "@intlayer/dictionaries-entry": "8.6.5",
77
- "@intlayer/remote-dictionaries-entry": "8.6.5",
78
- "@intlayer/types": "8.6.5",
79
- "@intlayer/unmerged-dictionaries-entry": "8.6.5",
70
+ "@intlayer/ai": "8.6.7",
71
+ "@intlayer/api": "8.6.7",
72
+ "@intlayer/babel": "8.6.7",
73
+ "@intlayer/chokidar": "8.6.7",
74
+ "@intlayer/config": "8.6.7",
75
+ "@intlayer/core": "8.6.7",
76
+ "@intlayer/dictionaries-entry": "8.6.7",
77
+ "@intlayer/remote-dictionaries-entry": "8.6.7",
78
+ "@intlayer/types": "8.6.7",
79
+ "@intlayer/unmerged-dictionaries-entry": "8.6.7",
80
80
  "commander": "14.0.3",
81
81
  "enquirer": "^2.4.1",
82
82
  "eventsource": "4.1.0",
@@ -93,7 +93,7 @@
93
93
  "vitest": "4.1.2"
94
94
  },
95
95
  "peerDependencies": {
96
- "@intlayer/ai": "8.6.5"
96
+ "@intlayer/ai": "8.6.7"
97
97
  },
98
98
  "peerDependenciesMeta": {
99
99
  "@intlayer/ai": {