@intlayer/chokidar 8.0.4 → 8.0.5
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/assets/installSkills/skills/angular.md +40 -0
- package/dist/assets/installSkills/skills/astro.md +13 -0
- package/dist/assets/installSkills/skills/config.md +5 -0
- package/dist/assets/installSkills/skills/content.md +127 -0
- package/dist/assets/installSkills/skills/extra_action.md +6 -0
- package/dist/assets/installSkills/skills/next_js.md +35 -0
- package/dist/assets/installSkills/skills/react.md +18 -0
- package/dist/assets/installSkills/skills/remote_content.md +6 -0
- package/dist/assets/installSkills/skills/setup.md +25 -0
- package/dist/assets/installSkills/skills/svelte.md +17 -0
- package/dist/assets/installSkills/skills/usage.md +103 -0
- package/dist/assets/installSkills/skills/vue.md +27 -0
- package/dist/cjs/_virtual/{rolldown_runtime.cjs → _rolldown/runtime.cjs} +1 -1
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs +2 -1
- package/dist/cjs/buildIntlayerDictionary/buildIntlayerDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/index.cjs +1 -0
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs +2 -1
- package/dist/cjs/buildIntlayerDictionary/processContentDeclaration.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +2 -1
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +2 -1
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +2 -1
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -1
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs.map +1 -1
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +3 -2
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs.map +1 -1
- package/dist/cjs/cleanOutputDir.cjs +2 -1
- package/dist/cjs/cleanOutputDir.cjs.map +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +3 -2
- package/dist/cjs/cleanRemovedContentDeclaration.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +2 -1
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs +2 -1
- package/dist/cjs/createDictionaryEntryPoint/generateDictionaryListContent.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +3 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +3 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +3 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +3 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +3 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs.map +1 -1
- package/dist/cjs/createDictionaryEntryPoint/index.cjs +1 -0
- package/dist/cjs/createType/createModuleAugmentation.cjs +3 -2
- package/dist/cjs/createType/createModuleAugmentation.cjs.map +1 -1
- package/dist/cjs/createType/createType.cjs +2 -1
- package/dist/cjs/createType/createType.cjs.map +1 -1
- package/dist/cjs/createType/index.cjs +1 -0
- package/dist/cjs/fetchDistantDictionaries.cjs +2 -1
- package/dist/cjs/fetchDistantDictionaries.cjs.map +1 -1
- package/dist/cjs/filterInvalidDictionaries.cjs +2 -1
- package/dist/cjs/filterInvalidDictionaries.cjs.map +1 -1
- package/dist/cjs/formatDictionary.cjs +2 -1
- package/dist/cjs/formatDictionary.cjs.map +1 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs +2 -1
- package/dist/cjs/getContentDeclarationFileTemplate/getContentDeclarationFileTemplate.cjs.map +1 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs +2 -1
- package/dist/cjs/handleAdditionalContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +2 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs +2 -1
- package/dist/cjs/handleContentDeclarationFileMoved.cjs.map +1 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs +2 -1
- package/dist/cjs/handleUnlinkedContentDeclarationFile.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -0
- package/dist/cjs/init/index.cjs +75 -9
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +165 -0
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -0
- package/dist/cjs/init/utils/fileSystem.cjs +2 -1
- package/dist/cjs/init/utils/fileSystem.cjs.map +1 -1
- package/dist/cjs/init/utils/index.cjs +4 -0
- package/dist/cjs/init/utils/jsonParser.cjs +1 -0
- package/dist/cjs/init/utils/jsonParser.cjs.map +1 -1
- package/dist/cjs/init/utils/tsConfig.cjs +2 -1
- package/dist/cjs/init/utils/tsConfig.cjs.map +1 -1
- package/dist/cjs/initConfig/index.cjs +2 -1
- package/dist/cjs/initConfig/index.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +65 -0
- package/dist/cjs/installSkills/index.cjs.map +1 -0
- package/dist/cjs/listDictionariesPath.cjs +3 -2
- package/dist/cjs/listDictionariesPath.cjs.map +1 -1
- package/dist/cjs/listGitFiles.cjs +4 -3
- package/dist/cjs/listGitFiles.cjs.map +1 -1
- package/dist/cjs/listProjects.cjs +4 -3
- package/dist/cjs/listProjects.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +2 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/index.cjs +1 -0
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +2 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs +2 -1
- package/dist/cjs/loadDictionaries/loadDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +2 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs +2 -1
- package/dist/cjs/loadDictionaries/loadRemoteDictionaries.cjs.map +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +3 -2
- package/dist/cjs/loadDictionaries/log.cjs.map +1 -1
- package/dist/cjs/prepareIntlayer.cjs +3 -2
- package/dist/cjs/prepareIntlayer.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs +1 -0
- package/dist/cjs/reduceDictionaryContent/applyMask.cjs.map +1 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs +2 -1
- package/dist/cjs/reduceDictionaryContent/reduceDictionaryContent.cjs.map +1 -1
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs +2 -1
- package/dist/cjs/transformFiles/extractDictionaryKey.cjs.map +1 -1
- package/dist/cjs/transformFiles/index.cjs +1 -0
- package/dist/cjs/transformFiles/transformFiles.cjs +4 -3
- package/dist/cjs/transformFiles/transformFiles.cjs.map +1 -1
- package/dist/cjs/utils/autoDecorateContent.cjs +2 -1
- package/dist/cjs/utils/autoDecorateContent.cjs.map +1 -1
- package/dist/cjs/utils/buildFilesList.cjs +3 -2
- package/dist/cjs/utils/buildFilesList.cjs.map +1 -1
- package/dist/cjs/utils/chunkJSON.cjs +1 -0
- package/dist/cjs/utils/chunkJSON.cjs.map +1 -1
- package/dist/cjs/utils/formatter.cjs +3 -2
- package/dist/cjs/utils/formatter.cjs.map +1 -1
- package/dist/cjs/utils/getChunk.cjs +1 -0
- package/dist/cjs/utils/getChunk.cjs.map +1 -1
- package/dist/cjs/utils/getComponentTransformPattern.cjs +6 -6
- package/dist/cjs/utils/getComponentTransformPattern.cjs.map +1 -1
- package/dist/cjs/utils/getFileHash.cjs +3 -2
- package/dist/cjs/utils/getFileHash.cjs.map +1 -1
- package/dist/cjs/utils/getFormatFromExtension.cjs +1 -0
- package/dist/cjs/utils/getFormatFromExtension.cjs.map +1 -1
- package/dist/cjs/utils/pLimit.cjs +1 -0
- package/dist/cjs/utils/pLimit.cjs.map +1 -1
- package/dist/cjs/utils/parallelize.cjs +1 -0
- package/dist/cjs/utils/parallelize.cjs.map +1 -1
- package/dist/cjs/utils/parallelizeGlobal.cjs +1 -0
- package/dist/cjs/utils/parallelizeGlobal.cjs.map +1 -1
- package/dist/cjs/utils/reduceObjectFormat.cjs +1 -0
- package/dist/cjs/utils/reduceObjectFormat.cjs.map +1 -1
- package/dist/cjs/utils/resolveObjectPromises.cjs +1 -0
- package/dist/cjs/utils/resolveObjectPromises.cjs.map +1 -1
- package/dist/cjs/utils/runOnce.cjs +3 -2
- package/dist/cjs/utils/runOnce.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bin.cjs +2 -1
- package/dist/cjs/utils/runParallel/bin.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/bootstrap.cjs +1 -0
- package/dist/cjs/utils/runParallel/bootstrap.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/index.cjs +2 -1
- package/dist/cjs/utils/runParallel/index.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/pidTree.cjs +3 -2
- package/dist/cjs/utils/runParallel/pidTree.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/ps.cjs +3 -2
- package/dist/cjs/utils/runParallel/ps.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/runTask.cjs +2 -1
- package/dist/cjs/utils/runParallel/runTask.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnPosix.cjs +2 -1
- package/dist/cjs/utils/runParallel/spawnPosix.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs +2 -1
- package/dist/cjs/utils/runParallel/spawnWin32.cjs.map +1 -1
- package/dist/cjs/utils/runParallel/wmic.cjs +3 -2
- package/dist/cjs/utils/runParallel/wmic.cjs.map +1 -1
- package/dist/cjs/utils/sortAlphabetically.cjs +1 -0
- package/dist/cjs/utils/sortAlphabetically.cjs.map +1 -1
- package/dist/cjs/utils/splitTextByLine.cjs +1 -0
- package/dist/cjs/utils/splitTextByLine.cjs.map +1 -1
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs +1 -0
- package/dist/cjs/utils/verifyIdenticObjectFormat.cjs.map +1 -1
- package/dist/cjs/watcher.cjs +2 -1
- package/dist/cjs/watcher.cjs.map +1 -1
- package/dist/cjs/writeConfiguration/index.cjs +2 -1
- package/dist/cjs/writeConfiguration/index.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs +1 -0
- package/dist/cjs/writeContentDeclaration/detectExportedComponentName.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs +2 -1
- package/dist/cjs/writeContentDeclaration/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/index.cjs +1 -0
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +2 -1
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs +2 -1
- package/dist/cjs/writeContentDeclaration/transformJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs +2 -1
- package/dist/cjs/writeContentDeclaration/transformJSONFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +2 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +2 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +2 -1
- package/dist/cjs/writeFileIfChanged.cjs.map +1 -1
- package/dist/cjs/writeJsonIfChanged.cjs +1 -0
- package/dist/cjs/writeJsonIfChanged.cjs.map +1 -1
- package/dist/esm/_virtual/{rolldown_runtime.mjs → _rolldown/runtime.mjs} +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +1 -1
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs.map +1 -1
- package/dist/esm/index.mjs +2 -1
- package/dist/esm/init/index.mjs +74 -9
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +162 -0
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -0
- package/dist/esm/init/utils/index.mjs +2 -1
- package/dist/esm/installSkills/index.mjs +60 -0
- package/dist/esm/installSkills/index.mjs.map +1 -0
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
- package/dist/esm/transformFiles/transformFiles.mjs +1 -1
- package/dist/esm/utils/getComponentTransformPattern.mjs +4 -4
- package/dist/esm/utils/getComponentTransformPattern.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +2 -2
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeDynamicDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts +3 -3
- package/dist/types/buildIntlayerDictionary/writeFetchDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeMergedDictionary.d.ts.map +1 -1
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts +2 -2
- package/dist/types/buildIntlayerDictionary/writeRemoteDictionary.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts.map +1 -1
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts +2 -2
- package/dist/types/createDictionaryEntryPoint/generateDictionaryListContent.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/init/utils/configManipulation.d.ts +18 -0
- package/dist/types/init/utils/configManipulation.d.ts.map +1 -0
- package/dist/types/init/utils/index.d.ts +2 -1
- package/dist/types/installSkills/index.d.ts +21 -0
- package/dist/types/installSkills/index.d.ts.map +1 -0
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +2 -2
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts.map +1 -1
- package/dist/types/watcher.d.ts +2 -2
- package/dist/types/watcher.d.ts.map +1 -1
- package/package.json +12 -12
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configManipulation.mjs","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"sourcesContent":["import {\n type ObjectLiteralExpression,\n Project,\n type SourceFile,\n SyntaxKind,\n} from 'ts-morph';\n\n/**\n * Checks if a module is already imported or required in the source file.\n */\nconst isModuleImported = (\n sourceFile: SourceFile,\n moduleName: string\n): boolean => {\n const hasImport = sourceFile\n .getImportDeclarations()\n .some((i) => i.getModuleSpecifierValue() === moduleName);\n\n const hasRequire = sourceFile\n .getDescendantsOfKind(SyntaxKind.CallExpression)\n .some((c) => {\n const expression = c.getExpression();\n return (\n expression.getText() === 'require' &&\n c\n .getArguments()[0]\n ?.asKind(SyntaxKind.StringLiteral)\n ?.getLiteralValue() === moduleName\n );\n });\n\n return hasImport || hasRequire;\n};\n\n/**\n * Checks if the file should be treated as CommonJS.\n */\nconst isCJS = (content: string, extension: string): boolean => {\n if (extension === 'cjs') return true;\n if (['mjs', 'ts'].includes(extension)) return false;\n\n return (\n content.includes('module.exports') &&\n !content.includes('import ') &&\n !content.includes('export ')\n );\n};\n\n/**\n * Updates a Vite configuration file to include the Intlayer plugin.\n * @param content The content of the vite.config file\n * @param extension The file extension (ts, js, mjs, cjs)\n * @returns The updated content\n */\nexport const updateViteConfig = (\n content: string,\n extension: string\n): string => {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\n `vite.config.${extension}`,\n content\n );\n\n const isCJSFile = isCJS(content, extension);\n\n // Add import if missing\n const hasIntlayerImport = isModuleImported(sourceFile, 'vite-intlayer');\n\n if (!hasIntlayerImport) {\n if (isCJSFile) {\n sourceFile.insertVariableStatement(0, {\n declarationKind: 'const' as any,\n declarations: [\n {\n name: '{ intlayer }',\n initializer: 'require(\"vite-intlayer\")',\n },\n ],\n });\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'vite-intlayer',\n namedImports: ['intlayer'],\n });\n }\n }\n\n // Find the configuration object\n let configObject: ObjectLiteralExpression | undefined;\n\n // Case: export default defineConfig({...})\n const exportDefault = sourceFile.getExportAssignment(\n (e) => !e.isExportEquals()\n );\n if (exportDefault) {\n const expression = exportDefault.getExpression();\n\n if (expression.getKind() === SyntaxKind.CallExpression) {\n const call = expression.asKind(SyntaxKind.CallExpression);\n\n if (call?.getExpression().getText() === 'defineConfig') {\n const arg = call.getArguments()[0];\n\n if (arg?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n } else if (expression.getKind() === SyntaxKind.ObjectLiteralExpression) {\n // Case: export default {...}\n configObject = expression.asKind(SyntaxKind.ObjectLiteralExpression);\n } else if (expression.getKind() === SyntaxKind.Identifier) {\n // Case: const config = {...}; export default config;\n const identifier = expression.asKind(SyntaxKind.Identifier);\n const definitions = identifier?.getDefinitions();\n\n if (definitions && definitions.length > 0) {\n const node = definitions[0].getDeclarationNode();\n\n if (node?.getKind() === SyntaxKind.VariableDeclaration) {\n const init = node\n .asKind(SyntaxKind.VariableDeclaration)\n ?.getInitializer();\n\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = init.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n }\n }\n }\n\n // Case: module.exports = {...}\n if (!configObject) {\n const expressionStatements = sourceFile.getStatements();\n for (const statement of expressionStatements) {\n if (statement.getKind() === SyntaxKind.ExpressionStatement) {\n const expr = statement\n .asKind(SyntaxKind.ExpressionStatement)\n ?.getExpression();\n\n if (expr?.getKind() === SyntaxKind.BinaryExpression) {\n const binary = expr.asKind(SyntaxKind.BinaryExpression);\n\n if (\n binary?.getLeft().getText() === 'module.exports' &&\n binary.getOperatorToken().getKind() === SyntaxKind.EqualsToken\n ) {\n const right = binary.getRight();\n\n if (right.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = right.asKind(SyntaxKind.ObjectLiteralExpression);\n } else if (right.getKind() === SyntaxKind.CallExpression) {\n // Case: module.exports = defineConfig({...})\n const call = right.asKind(SyntaxKind.CallExpression);\n\n if (call?.getExpression().getText() === 'defineConfig') {\n const arg = call.getArguments()[0];\n\n if (arg?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = arg.asKind(SyntaxKind.ObjectLiteralExpression);\n }\n }\n } else if (right.getKind() === SyntaxKind.Identifier) {\n // Case: const config = {...}; module.exports = config;\n const identifier = right.asKind(SyntaxKind.Identifier);\n const definitions = identifier?.getDefinitions();\n\n if (definitions && definitions.length > 0) {\n const node = definitions[0].getDeclarationNode();\n\n if (node?.getKind() === SyntaxKind.VariableDeclaration) {\n const init = node\n .asKind(SyntaxKind.VariableDeclaration)\n ?.getInitializer();\n\n if (init?.getKind() === SyntaxKind.ObjectLiteralExpression) {\n configObject = init.asKind(\n SyntaxKind.ObjectLiteralExpression\n );\n }\n }\n }\n }\n }\n }\n }\n }\n }\n\n // 3. Update plugins array\n if (configObject) {\n let pluginsProp = configObject.getProperty('plugins');\n\n if (!pluginsProp) {\n configObject.addPropertyAssignment({\n name: 'plugins',\n initializer: '[]',\n });\n pluginsProp = configObject.getProperty('plugins');\n }\n\n if (pluginsProp?.getKind() === SyntaxKind.PropertyAssignment) {\n const initializer = pluginsProp\n .asKind(SyntaxKind.PropertyAssignment)\n ?.getInitializer();\n\n if (initializer?.getKind() === SyntaxKind.ArrayLiteralExpression) {\n const array = initializer.asKind(SyntaxKind.ArrayLiteralExpression);\n const hasIntlayer = array\n ?.getElements()\n .some((el) => el.getText().includes('intlayer('));\n\n if (!hasIntlayer) {\n array?.addElement('intlayer()');\n }\n }\n }\n }\n\n return sourceFile.getFullText();\n};\n\n/**\n * Updates a Next.js configuration file to wrap the export with withIntlayer.\n * @param content The content of the next.config file\n * @param extension The file extension (ts, js, mjs, cjs)\n * @returns The updated content\n */\nexport const updateNextConfig = (\n content: string,\n extension: string\n): string => {\n const project = new Project({ useInMemoryFileSystem: true });\n const sourceFile = project.createSourceFile(\n `next.config.${extension}`,\n content\n );\n\n const isCJSFile = isCJS(content, extension);\n\n // 1. Add import if missing\n const hasIntlayerImport = isModuleImported(\n sourceFile,\n 'next-intlayer/server'\n );\n\n if (!hasIntlayerImport) {\n if (isCJSFile) {\n sourceFile.insertVariableStatement(0, {\n declarationKind: 'const' as any,\n declarations: [\n {\n name: '{ withIntlayer }',\n initializer: 'require(\"next-intlayer/server\")',\n },\n ],\n });\n } else {\n sourceFile.addImportDeclaration({\n moduleSpecifier: 'next-intlayer/server',\n namedImports: ['withIntlayer'],\n });\n }\n }\n\n // 2. Wrap export\n let updated = false;\n\n // Case: export default ...\n const exportDefault = sourceFile.getExportAssignment(\n (e) => !e.isExportEquals()\n );\n if (exportDefault) {\n const expression = exportDefault.getExpression();\n\n if (!expression.getText().includes('withIntlayer')) {\n exportDefault.setExpression(`withIntlayer(${expression.getText()})`);\n updated = true;\n }\n }\n\n // Case: module.exports = ...\n if (!updated) {\n const expressionStatements = sourceFile.getStatements();\n for (const statement of expressionStatements) {\n if (statement.getKind() === SyntaxKind.ExpressionStatement) {\n const expr = statement\n .asKind(SyntaxKind.ExpressionStatement)\n ?.getExpression();\n\n if (expr?.getKind() === SyntaxKind.BinaryExpression) {\n const binary = expr.asKind(SyntaxKind.BinaryExpression);\n\n if (\n binary?.getLeft().getText() === 'module.exports' &&\n binary.getOperatorToken().getKind() === SyntaxKind.EqualsToken\n ) {\n const right = binary.getRight();\n\n if (!right.getText().includes('withIntlayer')) {\n right.replaceWithText(`withIntlayer(${right.getText()})`);\n updated = true;\n }\n }\n }\n }\n }\n }\n\n return sourceFile.getFullText();\n};\n"],"mappings":";;;;;;AAUA,MAAM,oBACJ,YACA,eACY;CACZ,MAAM,YAAY,WACf,uBAAuB,CACvB,MAAM,MAAM,EAAE,yBAAyB,KAAK,WAAW;CAE1D,MAAM,aAAa,WAChB,qBAAqB,WAAW,eAAe,CAC/C,MAAM,MAAM;AAEX,SADmB,EAAE,eAAe,CAEvB,SAAS,KAAK,aACzB,EACG,cAAc,CAAC,IACd,OAAO,WAAW,cAAc,EAChC,iBAAiB,KAAK;GAE5B;AAEJ,QAAO,aAAa;;;;;AAMtB,MAAM,SAAS,SAAiB,cAA+B;AAC7D,KAAI,cAAc,MAAO,QAAO;AAChC,KAAI,CAAC,OAAO,KAAK,CAAC,SAAS,UAAU,CAAE,QAAO;AAE9C,QACE,QAAQ,SAAS,iBAAiB,IAClC,CAAC,QAAQ,SAAS,UAAU,IAC5B,CAAC,QAAQ,S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AAW,iBAAiB;AAEvD,QACE,QAAQ,SAAS,CAAC,SAAS,KAAK,oBAChC,OAAO,kBAAkB,CAAC,SAAS,KAAK,WAAW,aACnD;KACA,MAAM,QAAQ,OAAO,UAAU;AAE/B,SAAI,CAAC,MAAM,SAAS,CAAC,SAAS,eAAe,EAAE;AAC7C,YAAM,gBAAgB,gBAAgB,MAAM,SAAS,CAAC,GAAG;AACzD,gBAAU;;;;;;AAQtB,QAAO,WAAW,aAAa"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { updateNextConfig, updateViteConfig } from "./configManipulation.mjs";
|
|
1
2
|
import { exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.mjs";
|
|
2
3
|
import { parseJSONWithComments } from "./jsonParser.mjs";
|
|
3
4
|
import { findTsConfigFiles } from "./tsConfig.mjs";
|
|
4
5
|
|
|
5
|
-
export { exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, writeFileToRoot };
|
|
6
|
+
export { exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, updateNextConfig, updateViteConfig, writeFileToRoot };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { readAsset } from "../_virtual/_utils_asset.mjs";
|
|
2
|
+
import { promises } from "node:fs";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
//#region src/installSkills/index.ts
|
|
6
|
+
const SKILLS_METADATA = {
|
|
7
|
+
Setup: "General Intlayer setup guide",
|
|
8
|
+
Usage: "How to use Intlayer in your project",
|
|
9
|
+
RemoteContent: "How to use Intlayer with Remote/CMS/Server-side content",
|
|
10
|
+
Config: "Intlayer configuration documentation",
|
|
11
|
+
ExtraAction: "Additional CLI and automated actions",
|
|
12
|
+
Content: "Reference for all Intlayer content node types (t, enu, etc.)",
|
|
13
|
+
React: "React-specific syntax and hooks usage",
|
|
14
|
+
Angular: "Angular-specific syntax and Injectable Function usage",
|
|
15
|
+
NextJS: "Next.js-specific usage (Server & Client components)",
|
|
16
|
+
Vue: "Vue-specific composables and syntax",
|
|
17
|
+
Svelte: "Svelte-specific stores and syntax",
|
|
18
|
+
Astro: "Astro-specific usage and getIntlayer"
|
|
19
|
+
};
|
|
20
|
+
const SKILLS = Object.keys(SKILLS_METADATA);
|
|
21
|
+
/**
|
|
22
|
+
* Helper to convert CamelCase to snake_case
|
|
23
|
+
*/
|
|
24
|
+
const camelToSnakeCase = (str) => str.replace(/([a-z0-9])([A-Z])/g, "$1_$2").toLowerCase();
|
|
25
|
+
const getSkillContent = (skill) => {
|
|
26
|
+
return readAsset(`./skills/${camelToSnakeCase(skill)}.md`);
|
|
27
|
+
};
|
|
28
|
+
const installSkills = async (projectRoot, platform, skills) => {
|
|
29
|
+
const content = skills.map((skill) => getSkillContent(skill)).join("\n\n");
|
|
30
|
+
if (platform === "Cursor" || platform === "Claude") {
|
|
31
|
+
const fileName = platform === "Cursor" ? ".cursorrules" : ".clauderules";
|
|
32
|
+
const filePath = path.join(projectRoot, fileName);
|
|
33
|
+
try {
|
|
34
|
+
let existingContent = "";
|
|
35
|
+
try {
|
|
36
|
+
existingContent = await promises.readFile(filePath, "utf-8");
|
|
37
|
+
} catch {}
|
|
38
|
+
const newContent = existingContent ? `${existingContent}\n\n${content}` : content;
|
|
39
|
+
await promises.writeFile(filePath, newContent, "utf-8");
|
|
40
|
+
return `Updated ${fileName} with ${skills.join(", ")} skills.`;
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(`Failed to write ${fileName}: ${error}`);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
const skillsDir = path.join(projectRoot, ".intlayer/skills");
|
|
46
|
+
await promises.mkdir(skillsDir, { recursive: true });
|
|
47
|
+
const createdFiles = [];
|
|
48
|
+
for (const skill of skills) {
|
|
49
|
+
const fileName = `${camelToSnakeCase(skill)}.md`;
|
|
50
|
+
const filePath = path.join(skillsDir, fileName);
|
|
51
|
+
await promises.writeFile(filePath, getSkillContent(skill), "utf-8");
|
|
52
|
+
createdFiles.push(filePath);
|
|
53
|
+
}
|
|
54
|
+
return `Created skills files in ${skillsDir}: ${createdFiles.map((f) => path.basename(f)).join(", ")}`;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
//#endregion
|
|
59
|
+
export { SKILLS, SKILLS_METADATA, installSkills };
|
|
60
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fs"],"sources":["../../../src/installSkills/index.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { readAsset } from 'utils:asset';\n\nexport const SKILLS_METADATA = {\n Setup: 'General Intlayer setup guide',\n Usage: 'How to use Intlayer in your project',\n RemoteContent: 'How to use Intlayer with Remote/CMS/Server-side content',\n Config: 'Intlayer configuration documentation',\n ExtraAction: 'Additional CLI and automated actions',\n Content: 'Reference for all Intlayer content node types (t, enu, etc.)',\n React: 'React-specific syntax and hooks usage',\n Angular: 'Angular-specific syntax and Injectable Function usage',\n NextJS: 'Next.js-specific usage (Server & Client components)',\n Vue: 'Vue-specific composables and syntax',\n Svelte: 'Svelte-specific stores and syntax',\n Astro: 'Astro-specific usage and getIntlayer',\n} as const;\n\nexport const SKILLS = Object.keys(\n SKILLS_METADATA\n) as (keyof typeof SKILLS_METADATA)[];\n\nexport type Skill = (typeof SKILLS)[number];\n\n/**\n * Helper to convert CamelCase to snake_case\n */\nconst camelToSnakeCase = (str: string) =>\n str.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();\n\nconst getSkillContent = (skill: Skill): string => {\n const fileName = `./skills/${camelToSnakeCase(skill)}.md`;\n return readAsset(fileName);\n};\n\nexport const installSkills = async (\n projectRoot: string,\n platform: 'Cursor' | 'VSCode' | 'OpenCode' | 'Claude' | 'Other',\n skills: Skill[]\n): Promise<string> => {\n const content = skills.map((skill) => getSkillContent(skill)).join('\\n\\n');\n\n if (platform === 'Cursor' || platform === 'Claude') {\n const fileName = platform === 'Cursor' ? '.cursorrules' : '.clauderules';\n const filePath = path.join(projectRoot, fileName);\n try {\n let existingContent = '';\n try {\n existingContent = await fs.readFile(filePath, 'utf-8');\n } catch {\n // File doesn't exist, ignore\n }\n\n const newContent = existingContent\n ? `${existingContent}\\n\\n${content}`\n : content;\n await fs.writeFile(filePath, newContent, 'utf-8');\n return `Updated ${fileName} with ${skills.join(', ')} skills.`;\n } catch (error) {\n throw new Error(`Failed to write ${fileName}: ${error}`);\n }\n } else {\n // For other platforms, write to .intlayer/skills\n const skillsDir = path.join(projectRoot, '.intlayer/skills');\n await fs.mkdir(skillsDir, { recursive: true });\n\n const createdFiles: string[] = [];\n\n for (const skill of skills) {\n const fileName = `${camelToSnakeCase(skill)}.md`;\n const filePath = path.join(skillsDir, fileName);\n await fs.writeFile(filePath, getSkillContent(skill), 'utf-8');\n createdFiles.push(filePath);\n }\n\n return `Created skills files in ${skillsDir}: ${createdFiles.map((f) => path.basename(f)).join(', ')}`;\n }\n};\n"],"mappings":";;;;;AAIA,MAAa,kBAAkB;CAC7B,OAAO;CACP,OAAO;CACP,eAAe;CACf,QAAQ;CACR,aAAa;CACb,SAAS;CACT,OAAO;CACP,SAAS;CACT,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,OAAO;CACR;AAED,MAAa,SAAS,OAAO,KAC3B,gBACD;;;;AAOD,MAAM,oBAAoB,QACxB,IAAI,QAAQ,sBAAsB,QAAQ,CAAC,aAAa;AAE1D,MAAM,mBAAmB,UAAyB;AAEhD,QAAO,UADU,YAAY,iBAAiB,MAAM,CAAC,KAC3B;;AAG5B,MAAa,gBAAgB,OAC3B,aACA,UACA,WACoB;CACpB,MAAM,UAAU,OAAO,KAAK,UAAU,gBAAgB,MAAM,CAAC,CAAC,KAAK,OAAO;AAE1E,KAAI,aAAa,YAAY,aAAa,UAAU;EAClD,MAAM,WAAW,aAAa,WAAW,iBAAiB;EAC1D,MAAM,WAAW,KAAK,KAAK,aAAa,SAAS;AACjD,MAAI;GACF,IAAI,kBAAkB;AACtB,OAAI;AACF,sBAAkB,MAAMA,SAAG,SAAS,UAAU,QAAQ;WAChD;GAIR,MAAM,aAAa,kBACf,GAAG,gBAAgB,MAAM,YACzB;AACJ,SAAMA,SAAG,UAAU,UAAU,YAAY,QAAQ;AACjD,UAAO,WAAW,SAAS,QAAQ,OAAO,KAAK,KAAK,CAAC;WAC9C,OAAO;AACd,SAAM,IAAI,MAAM,mBAAmB,SAAS,IAAI,QAAQ;;QAErD;EAEL,MAAM,YAAY,KAAK,KAAK,aAAa,mBAAmB;AAC5D,QAAMA,SAAG,MAAM,WAAW,EAAE,WAAW,MAAM,CAAC;EAE9C,MAAM,eAAyB,EAAE;AAEjC,OAAK,MAAM,SAAS,QAAQ;GAC1B,MAAM,WAAW,GAAG,iBAAiB,MAAM,CAAC;GAC5C,MAAM,WAAW,KAAK,KAAK,WAAW,SAAS;AAC/C,SAAMA,SAAG,UAAU,UAAU,gBAAgB,MAAM,EAAE,QAAQ;AAC7D,gBAAa,KAAK,SAAS;;AAG7B,SAAO,2BAA2B,UAAU,IAAI,aAAa,KAAK,MAAM,KAAK,SAAS,EAAE,CAAC,CAAC,KAAK,KAAK"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __require } from "../_virtual/
|
|
1
|
+
import { __require } from "../_virtual/_rolldown/runtime.mjs";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { bundleFile, configESMxCJSRequire, getProjectRequire, isESModule } from "@intlayer/config";
|
|
@@ -4,8 +4,8 @@ import { writeContentDeclaration } from "../writeContentDeclaration/writeContent
|
|
|
4
4
|
import fs from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, extname, join, relative, resolve } from "node:path";
|
|
6
6
|
import { ANSIColors, camelCaseToKebabCase, colorizePath, getAppLogger, getConfiguration } from "@intlayer/config";
|
|
7
|
-
import { execSync } from "node:child_process";
|
|
8
7
|
import { Node, Project, SyntaxKind } from "ts-morph";
|
|
8
|
+
import { execSync } from "node:child_process";
|
|
9
9
|
|
|
10
10
|
//#region src/transformFiles/transformFiles.ts
|
|
11
11
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { isAbsolute, relative, resolve } from "node:path";
|
|
2
2
|
import fg from "fast-glob";
|
|
3
3
|
|
|
4
4
|
//#region src/utils/getComponentTransformPattern.ts
|
|
@@ -8,12 +8,12 @@ import fg from "fast-glob";
|
|
|
8
8
|
* This prevents scanning the same files twice.
|
|
9
9
|
*/
|
|
10
10
|
const getDistinctRootDirs = (dirs) => {
|
|
11
|
-
const uniqueDirs = Array.from(new Set(dirs.map((
|
|
11
|
+
const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));
|
|
12
12
|
uniqueDirs.sort((a, b) => a.length - b.length);
|
|
13
13
|
return uniqueDirs.reduce((acc, dir) => {
|
|
14
14
|
if (!acc.some((parent) => {
|
|
15
|
-
const
|
|
16
|
-
return !
|
|
15
|
+
const relativePath = relative(parent, dir);
|
|
16
|
+
return !relativePath.startsWith("..") && !isAbsolute(relativePath) && relativePath !== "";
|
|
17
17
|
})) acc.push(dir);
|
|
18
18
|
return acc;
|
|
19
19
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getComponentTransformPattern.mjs","names":[],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"getComponentTransformPattern.mjs","names":[],"sources":["../../../src/utils/getComponentTransformPattern.ts"],"sourcesContent":["import { isAbsolute, relative, resolve } from 'node:path';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\n\n/**\n * Helper to remove directories that are subdirectories of others in the list.\n * Example: ['/root', '/root/src'] -> ['/root']\n * This prevents scanning the same files twice.\n */\nconst getDistinctRootDirs = (dirs: string[]): string[] => {\n // Resolve to absolute paths and remove exact duplicates\n const uniqueDirs = Array.from(new Set(dirs.map((dir) => resolve(dir))));\n\n // Sort by length (shortest paths first) so parents appear before children\n uniqueDirs.sort((a, b) => a.length - b.length);\n\n // Filter out any directory that is inside a parent already in the accepted list\n return uniqueDirs.reduce((acc: string[], dir) => {\n const isNested = acc.some((parent) => {\n const relativePath = relative(parent, dir);\n return (\n !relativePath.startsWith('..') && // It is inside the parent\n !isAbsolute(relativePath) && // It is not a different drive/root\n relativePath !== '' // It is not the parent itself (already handled by Set, but good for safety)\n );\n });\n\n if (!isNested) {\n acc.push(dir);\n }\n return acc;\n }, []);\n};\n\nexport const getComponentTransformPattern = async (\n intlayerConfig: IntlayerConfig\n): Promise<string[]> => {\n const { baseDir, codeDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out codeDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...codeDir]);\n\n const filesListPatternPromises = distinctRoots.map((cwd) =>\n fg(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n const filesList = (await Promise.all(filesListPatternPromises)).flat();\n\n // Deduplicate files just in case of overlapping patterns or symlinks\n return Array.from(new Set(filesList));\n};\n\nexport const getComponentTransformPatternSync = (\n intlayerConfig: IntlayerConfig\n): string[] => {\n const { baseDir, codeDir } = intlayerConfig.content;\n const { traversePattern } = intlayerConfig.build;\n\n // Optimize: Filter out codeDir paths if they are already covered by baseDir\n const distinctRoots = getDistinctRootDirs([baseDir, ...codeDir]);\n\n const filesList = distinctRoots.flatMap((cwd) =>\n fg.sync(traversePattern, {\n cwd,\n absolute: true,\n dot: true,\n })\n );\n\n return Array.from(new Set(filesList));\n};\n"],"mappings":";;;;;;;;;AASA,MAAM,uBAAuB,SAA6B;CAExD,MAAM,aAAa,MAAM,KAAK,IAAI,IAAI,KAAK,KAAK,QAAQ,QAAQ,IAAI,CAAC,CAAC,CAAC;AAGvE,YAAW,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO;AAG9C,QAAO,WAAW,QAAQ,KAAe,QAAQ;AAU/C,MAAI,CATa,IAAI,MAAM,WAAW;GACpC,MAAM,eAAe,SAAS,QAAQ,IAAI;AAC1C,UACE,CAAC,aAAa,WAAW,KAAK,IAC9B,CAAC,WAAW,aAAa,IACzB,iBAAiB;IAEnB,CAGA,KAAI,KAAK,IAAI;AAEf,SAAO;IACN,EAAE,CAAC;;AAGR,MAAa,+BAA+B,OAC1C,mBACsB;CACtB,MAAM,EAAE,SAAS,YAAY,eAAe;CAC5C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,2BAFgB,oBAAoB,CAAC,SAAS,GAAG,QAAQ,CAAC,CAEjB,KAAK,QAClD,GAAG,iBAAiB;EAClB;EACA,UAAU;EACV,KAAK;EACN,CAAC,CACH;CAED,MAAM,aAAa,MAAM,QAAQ,IAAI,yBAAyB,EAAE,MAAM;AAGtE,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC;;AAGvC,MAAa,oCACX,mBACa;CACb,MAAM,EAAE,SAAS,YAAY,eAAe;CAC5C,MAAM,EAAE,oBAAoB,eAAe;CAK3C,MAAM,YAFgB,oBAAoB,CAAC,SAAS,GAAG,QAAQ,CAAC,CAEhC,SAAS,QACvC,GAAG,KAAK,iBAAiB;EACvB;EACA,UAAU;EACV,KAAK;EACN,CAAC,CACH;AAED,QAAO,MAAM,KAAK,IAAI,IAAI,UAAU,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
2
|
import { dirname, join } from "node:path";
|
|
3
3
|
import { colorizePath, x } from "@intlayer/config";
|
|
4
|
-
import { deepTransformNode
|
|
4
|
+
import { deepTransformNode } from "@intlayer/core";
|
|
5
5
|
import { NodeType } from "@intlayer/types";
|
|
6
6
|
|
|
7
7
|
//#region src/writeContentDeclaration/processContentDeclarationContent.ts
|
|
@@ -76,7 +76,7 @@ const htmlFilePlugin = {
|
|
|
76
76
|
*
|
|
77
77
|
* And write external sources as file content if necessary.
|
|
78
78
|
*/
|
|
79
|
-
const processContentDeclarationContent = async (dictionary) => deepTransformNode
|
|
79
|
+
const processContentDeclarationContent = async (dictionary) => deepTransformNode(dictionary, {
|
|
80
80
|
dictionaryKey: dictionary.key,
|
|
81
81
|
keyPath: [],
|
|
82
82
|
plugins: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processContentDeclarationContent.mjs","names":[
|
|
1
|
+
{"version":3,"file":"processContentDeclarationContent.mjs","names":[],"sources":["../../../src/writeContentDeclaration/processContentDeclarationContent.ts"],"sourcesContent":["import { existsSync, mkdirSync, writeFileSync } from 'node:fs';\nimport { dirname, join } from 'node:path';\nimport { colorizePath, x } from '@intlayer/config';\nimport {\n deepTransformNode,\n type FileContent,\n type FileContentConstructor,\n type HTMLContent,\n type HTMLContentConstructor,\n type InsertionContent,\n type InsertionContentConstructor,\n type MarkdownContent,\n type MarkdownContentConstructor,\n type Plugins,\n} from '@intlayer/core';\nimport { type Dictionary, NodeType } from '@intlayer/types';\n\n/**\n * Write file plugin\n */\n\nconst writeFilePlugin: Plugins = {\n id: 'write-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.File,\n transform: (node: FileContent) => {\n const fileContent = node.content;\n const filePath = node.fixedPath;\n\n if (typeof fileContent !== 'string') {\n throw new Error('File content must be a string');\n }\n\n if (typeof filePath !== 'string') {\n throw new Error('File path must be a string');\n }\n\n // Write the file to the file system\n try {\n const absoluteFilePath = join(process.cwd(), filePath);\n\n // Create the file directory if it doesn't exist\n const fileDirectory = dirname(absoluteFilePath);\n\n if (!existsSync(fileDirectory)) {\n mkdirSync(fileDirectory, { recursive: true });\n }\n\n // Write the file\n writeFileSync(absoluteFilePath, fileContent);\n } catch (error) {\n throw new Error(\n `${x} Error writing file to ${colorizePath(filePath)}: ${error}`\n );\n }\n\n const transformedFileContent: FileContentConstructor = {\n nodeType: NodeType.File,\n [NodeType.File]: node.file,\n };\n\n return transformedFileContent;\n },\n};\n\n/**\n * Markdown file plugin\n */\n\nconst markdownFilePlugin: Plugins = {\n id: 'markdown-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const simplifiedMarkdownNode: MarkdownContentConstructor = {\n nodeType: NodeType.Markdown,\n [NodeType.Markdown]: deepTransformNode(node.markdown, props),\n };\n\n return simplifiedMarkdownNode;\n },\n};\n\n/**\n * Insertion file plugin\n */\n\nconst insertionFilePlugin: Plugins = {\n id: 'insertion-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const simplifiedInsertionNode: InsertionContentConstructor = {\n nodeType: NodeType.Insertion,\n [NodeType.Insertion]: deepTransformNode(node.insertion, props),\n };\n\n return simplifiedInsertionNode;\n },\n};\n\n/**\n * HTML file plugin\n */\n\nconst htmlFilePlugin: Plugins = {\n id: 'html-file-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n transform: (node: HTMLContent, props, deepTransformNode) => {\n const simplifiedHTMLNode: HTMLContentConstructor = {\n nodeType: NodeType.HTML,\n [NodeType.HTML]: deepTransformNode(node.html, props),\n };\n\n return simplifiedHTMLNode;\n },\n};\n\n/**\n * Process content declaration content\n *\n * It filter node that are autogenerated by intlayer to do not rewrite them in the content declaration file.\n *\n * And write external sources as file content if necessary.\n */\nexport const processContentDeclarationContent = async (\n dictionary: Dictionary\n) =>\n deepTransformNode(dictionary, {\n dictionaryKey: dictionary.key,\n keyPath: [],\n plugins: [\n writeFilePlugin,\n markdownFilePlugin,\n insertionFilePlugin,\n htmlFilePlugin,\n ],\n });\n"],"mappings":";;;;;;;;;;AAqBA,MAAM,kBAA2B;CAC/B,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAAY,MAAM,aAAa,SAAS;CAC1D,YAAY,SAAsB;EAChC,MAAM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,WAAW;CAC1B,SAAS,EAAE;CACX,SAAS;EACP;EACA;EACA;EACA;EACD;CACF,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MergedDictionaryOutput } from "./writeMergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
import { Dictionary, Locale } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeDynamicDictionary.d.ts
|
|
@@ -12,7 +12,7 @@ type LocalizedDictionaryOutput = Record<string, LocalizedDictionaryResult>;
|
|
|
12
12
|
/**
|
|
13
13
|
* This function generates the content of the dictionary list file
|
|
14
14
|
*/
|
|
15
|
-
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
15
|
+
declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types0.IntlayerConfig) => string;
|
|
16
16
|
/**
|
|
17
17
|
* Write the localized dictionaries to the dictionariesDir
|
|
18
18
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -29,7 +29,7 @@ declare const generateDictionaryEntryPoint: (localizedDictionariesPathsRecord: L
|
|
|
29
29
|
* // { key: 'home', content: { ... } },
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
|
-
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?:
|
|
32
|
+
declare const writeDynamicDictionary: (mergedDictionaries: MergedDictionaryOutput, configuration?: _intlayer_types0.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
33
33
|
//#endregion
|
|
34
34
|
export { DictionaryResult, LocalizedDictionaryOutput, LocalizedDictionaryResult, generateDictionaryEntryPoint, writeDynamicDictionary };
|
|
35
35
|
//# sourceMappingURL=writeDynamicDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;KAcY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;cAMW,4BAAA,GACX,gCAAA,EAAkC,yBAAA,EAClC,MAAA,kBACA,aAAA,GAF2D,
|
|
1
|
+
{"version":3,"file":"writeDynamicDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeDynamicDictionary.ts"],"mappings":";;;;;KAcY,gBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,yBAAA,GAA4B,OAAA,CACtC,MAAA,CAAO,MAAA,EAAQ,gBAAA;AAAA,KAGL,yBAAA,GAA4B,MAAA,SAEtC,yBAAA;;;;cAMW,4BAAA,GACX,gCAAA,EAAkC,yBAAA,EAClC,MAAA,kBACA,aAAA,GAF2D,gBAAA,CAE3D,cAAA;;;AAfF;;;;;;;;;;;;;;cAkEa,sBAAA,GACX,kBAAA,EAAoB,sBAAA,EACpB,aAAA,GAD0C,gBAAA,CAC1C,cAAA,EACA,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { LocalizedDictionaryOutput, LocalizedDictionaryResult } from "./writeDynamicDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeFetchDictionary.d.ts
|
|
5
5
|
/**
|
|
6
6
|
* This function generates the content of the dictionary list file
|
|
7
7
|
*/
|
|
8
|
-
declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?:
|
|
8
|
+
declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: LocalizedDictionaryResult, format?: "cjs" | "esm", configuration?: _intlayer_types0.IntlayerConfig) => string;
|
|
9
9
|
/**
|
|
10
10
|
* Write the localized dictionaries to the dictionariesDir
|
|
11
11
|
* @param mergedDictionaries - The merged dictionaries
|
|
@@ -22,7 +22,7 @@ declare const generateDictionaryEntryPoint: (localedDictionariesPathsRecord: Loc
|
|
|
22
22
|
* // { key: 'home', content: { ... } },
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?:
|
|
25
|
+
declare const writeFetchDictionary: (dynamicDictionaries: LocalizedDictionaryOutput, configuration?: _intlayer_types0.IntlayerConfig, formats?: ("cjs" | "esm")[]) => Promise<LocalizedDictionaryOutput>;
|
|
26
26
|
//#endregion
|
|
27
27
|
export { generateDictionaryEntryPoint, writeFetchDictionary };
|
|
28
28
|
//# sourceMappingURL=writeFetchDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;cAiBa,4BAAA,GACX,8BAAA,EAAgC,yBAAA,EAChC,MAAA,kBACA,aAAA,GAFyD,
|
|
1
|
+
{"version":3,"file":"writeFetchDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeFetchDictionary.ts"],"mappings":";;;;;;;cAiBa,4BAAA,GACX,8BAAA,EAAgC,yBAAA,EAChC,MAAA,kBACA,aAAA,GAFyD,gBAAA,CAEzD,cAAA;;;;;;;;;;;AA+CF;;;;;;cAAa,oBAAA,GACX,mBAAA,EAAqB,yBAAA,EACrB,aAAA,GAD8C,gBAAA,CAC9C,cAAA,EACA,OAAA,yBACC,OAAA,CAAQ,yBAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { UnmergedDictionaryOutput } from "./writeUnmergedDictionary.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
import { Dictionary } from "@intlayer/types";
|
|
4
4
|
|
|
5
5
|
//#region src/buildIntlayerDictionary/writeMergedDictionary.d.ts
|
|
@@ -24,7 +24,7 @@ type MergedDictionaryOutput = Record<string, MergedDictionaryResult>;
|
|
|
24
24
|
* // { key: 'home', content: { ... } },
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?:
|
|
27
|
+
declare const writeMergedDictionaries: (groupedDictionaries: UnmergedDictionaryOutput, configuration?: _intlayer_types0.IntlayerConfig) => Promise<MergedDictionaryOutput>;
|
|
28
28
|
//#endregion
|
|
29
29
|
export { MergedDictionaryOutput, MergedDictionaryResult, writeMergedDictionaries };
|
|
30
30
|
//# sourceMappingURL=writeMergedDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KASY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,GAD6C,
|
|
1
|
+
{"version":3,"file":"writeMergedDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeMergedDictionary.ts"],"mappings":";;;;;KASY,sBAAA;EACV,cAAA;EACA,UAAA,EAAY,UAAA;AAAA;AAAA,KAGF,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,uBAAA,GACX,mBAAA,EAAqB,wBAAA,EACrB,aAAA,GAD6C,gBAAA,CAC7C,cAAA,KACC,OAAA,CAAQ,sBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
2
2
|
import { Dictionary } from "@intlayer/types";
|
|
3
3
|
|
|
4
4
|
//#region src/buildIntlayerDictionary/writeRemoteDictionary.d.ts
|
|
@@ -23,7 +23,7 @@ type RemoteDictionaryOutput = Record<string, RemoteDictionaryResult>;
|
|
|
23
23
|
* // { key: 'home', content: { ... } },
|
|
24
24
|
* ```
|
|
25
25
|
*/
|
|
26
|
-
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?:
|
|
26
|
+
declare const writeRemoteDictionary: (remoteDictionaries: Dictionary[], configuration?: _intlayer_types0.IntlayerConfig) => Promise<RemoteDictionaryOutput>;
|
|
27
27
|
//#endregion
|
|
28
28
|
export { RemoteDictionaryOutput, RemoteDictionaryResult, writeRemoteDictionary };
|
|
29
29
|
//# sourceMappingURL=writeRemoteDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"mappings":";;;;KAcY,sBAAA;EACV,cAAA;EACA,YAAA,EAAc,UAAA;AAAA;AAAA,KAGJ,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,qBAAA,GACX,kBAAA,EAAoB,UAAA,IACpB,aAAA,GAD8B,
|
|
1
|
+
{"version":3,"file":"writeRemoteDictionary.d.ts","names":[],"sources":["../../../src/buildIntlayerDictionary/writeRemoteDictionary.ts"],"mappings":";;;;KAcY,sBAAA;EACV,cAAA;EACA,YAAA,EAAc,UAAA;AAAA;AAAA,KAGJ,sBAAA,GAAyB,MAAA,SAAe,sBAAA;;;;;;;;AAApD;;;;;AAkBA;;;;cAAa,qBAAA,GACX,kBAAA,EAAoB,UAAA,IACpB,aAAA,GAD8B,gBAAA,CAC9B,cAAA,KACC,OAAA,CAAQ,sBAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/createDictionaryEntryPoint.d.ts
|
|
4
4
|
type CreateDictionaryEntryPointOptions = {
|
|
@@ -8,7 +8,7 @@ type CreateDictionaryEntryPointOptions = {
|
|
|
8
8
|
/**
|
|
9
9
|
* This function generates a list of dictionaries in the main directory
|
|
10
10
|
*/
|
|
11
|
-
declare const createDictionaryEntryPoint: (configuration?:
|
|
11
|
+
declare const createDictionaryEntryPoint: (configuration?: _intlayer_types0.IntlayerConfig, options?: CreateDictionaryEntryPointOptions) => Promise<void>;
|
|
12
12
|
//#endregion
|
|
13
13
|
export { CreateDictionaryEntryPointOptions, createDictionaryEntryPoint };
|
|
14
14
|
//# sourceMappingURL=createDictionaryEntryPoint.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"mappings":";;;KAqCY,iCAAA;EACV,OAAA;EACA,WAAA;AAAA;;;;cAMW,0BAAA,GACX,aAAA,GAkFD,
|
|
1
|
+
{"version":3,"file":"createDictionaryEntryPoint.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/createDictionaryEntryPoint.ts"],"mappings":";;;KAqCY,iCAAA;EACV,OAAA;EACA,WAAA;AAAA;;;;cAMW,0BAAA,GACX,aAAA,GAkFD,gBAAA,CAlFC,cAAA,EACA,OAAA,GAAS,iCAAA,KAAsC,OAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
2
2
|
|
|
3
3
|
//#region src/createDictionaryEntryPoint/generateDictionaryListContent.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* This function generates the content of the dictionary list file
|
|
6
6
|
*/
|
|
7
|
-
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?:
|
|
7
|
+
declare const generateDictionaryListContent: (dictionaries: string[], functionName: string, importType: "json" | "javascript", format?: "cjs" | "esm", configuration?: _intlayer_types0.IntlayerConfig) => string;
|
|
8
8
|
//#endregion
|
|
9
9
|
export { generateDictionaryListContent };
|
|
10
10
|
//# sourceMappingURL=generateDictionaryListContent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"mappings":";;;;;;cAOa,6BAAA,GACX,YAAA,YACA,YAAA,UACA,UAAA,yBACA,MAAA,kBACA,aAAA,GA2CD,
|
|
1
|
+
{"version":3,"file":"generateDictionaryListContent.d.ts","names":[],"sources":["../../../src/createDictionaryEntryPoint/generateDictionaryListContent.ts"],"mappings":";;;;;;cAOa,6BAAA,GACX,YAAA,YACA,YAAA,UACA,UAAA,yBACA,MAAA,kBACA,aAAA,GA2CD,gBAAA,CA3CC,cAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -25,6 +25,7 @@ import { handleAdditionalContentDeclarationFile } from "./handleAdditionalConten
|
|
|
25
25
|
import { handleContentDeclarationFileChange } from "./handleContentDeclarationFileChange.js";
|
|
26
26
|
import { handleUnlinkedContentDeclarationFile } from "./handleUnlinkedContentDeclarationFile.js";
|
|
27
27
|
import { initIntlayer } from "./init/index.js";
|
|
28
|
+
import { SKILLS, SKILLS_METADATA, Skill, installSkills } from "./installSkills/index.js";
|
|
28
29
|
import { listDictionaries, listDictionariesWithStats } from "./listDictionariesPath.js";
|
|
29
30
|
import { DiffMode, ListGitFilesOptions, ListGitLinesOptions, listGitFiles, listGitLines } from "./listGitFiles.js";
|
|
30
31
|
import { ListProjectsOptions, listProjects } from "./listProjects.js";
|
|
@@ -58,4 +59,4 @@ import { transformJSFile } from "./writeContentDeclaration/transformJSFile.js";
|
|
|
58
59
|
import { writeContentDeclaration } from "./writeContentDeclaration/writeContentDeclaration.js";
|
|
59
60
|
import { writeJSFile } from "./writeContentDeclaration/writeJSFile.js";
|
|
60
61
|
import "./writeContentDeclaration/index.js";
|
|
61
|
-
export { ATTRIBUTES_TO_EXTRACT, type BuildFilesListOptions, type DictionaryStatus, type DiffMode, type Extension, type Format, type JSONObject, type JsonChunk, type ListGitFilesOptions, type ListGitLinesOptions, type ListProjectsOptions, type PackageName, type ParallelHandle, assembleJSON, autoDecorateContent, buildAndWatchIntlayer, buildDictionary, buildFilesList, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, extractDictionaryKey, extractIntlayer, fetchDistantDictionaries, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatLocale, formatPath, generateDictionaryListContent, generateKey, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, initIntlayer, isInvalidDictionary, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, shouldExtract, sortAlphabetically, splitTextByLines, transformFiles, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
|
|
62
|
+
export { ATTRIBUTES_TO_EXTRACT, type BuildFilesListOptions, type DictionaryStatus, type DiffMode, type Extension, type Format, type JSONObject, type JsonChunk, type ListGitFilesOptions, type ListGitLinesOptions, type ListProjectsOptions, type PackageName, type ParallelHandle, SKILLS, SKILLS_METADATA, type Skill, assembleJSON, autoDecorateContent, buildAndWatchIntlayer, buildDictionary, buildFilesList, chunkJSON, cleanOutputDir, createDictionaryEntryPoint, createModuleAugmentation, createTypes, detectExportedComponentName, detectFormatCommand, extractDictionaryKey, extractIntlayer, fetchDistantDictionaries, formatDictionaries, formatDictionariesOutput, formatDictionary, formatDictionaryOutput, formatLocale, formatPath, generateDictionaryListContent, generateKey, getBuiltDictionariesPath, getBuiltDynamicDictionariesPath, getBuiltFetchDictionariesPath, getBuiltRemoteDictionariesPath, getBuiltUnmergedDictionariesPath, getChunk, getComponentTransformPattern, getComponentTransformPatternSync, getContentDeclarationFileTemplate, getExtensionFromFormat, getFileHash, getFormatFromExtension, getGlobalLimiter, getTaskLimiter, handleAdditionalContentDeclarationFile, handleContentDeclarationFileChange, handleUnlinkedContentDeclarationFile, initIntlayer, installSkills, isInvalidDictionary, listDictionaries, listDictionariesWithStats, listGitFiles, listGitLines, listProjects, loadContentDeclarations, loadDictionaries, loadLocalDictionaries, loadRemoteDictionaries, pLimit, parallelize, parallelizeGlobal, prepareIntlayer, reconstructFromSingleChunk, reduceDictionaryContent, reduceObjectFormat, resolveObjectPromises, runOnce, runParallel, shouldExtract, sortAlphabetically, splitTextByLines, transformFiles, transformJSFile, verifyIdenticObjectFormat, watch, writeContentDeclaration, writeJSFile };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/init/index.ts"],"mappings":";;AAgKA;;cAAa,YAAA,GAAsB,OAAA,aAAe,OAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/init/utils/configManipulation.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Updates a Vite configuration file to include the Intlayer plugin.
|
|
4
|
+
* @param content The content of the vite.config file
|
|
5
|
+
* @param extension The file extension (ts, js, mjs, cjs)
|
|
6
|
+
* @returns The updated content
|
|
7
|
+
*/
|
|
8
|
+
declare const updateViteConfig: (content: string, extension: string) => string;
|
|
9
|
+
/**
|
|
10
|
+
* Updates a Next.js configuration file to wrap the export with withIntlayer.
|
|
11
|
+
* @param content The content of the next.config file
|
|
12
|
+
* @param extension The file extension (ts, js, mjs, cjs)
|
|
13
|
+
* @returns The updated content
|
|
14
|
+
*/
|
|
15
|
+
declare const updateNextConfig: (content: string, extension: string) => string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { updateNextConfig, updateViteConfig };
|
|
18
|
+
//# sourceMappingURL=configManipulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configManipulation.d.ts","names":[],"sources":["../../../../src/init/utils/configManipulation.ts"],"mappings":";;AAsDA;;;;;cAAa,gBAAA,GACX,OAAA,UACA,SAAA;;;;;;;cA6KW,gBAAA,GACX,OAAA,UACA,SAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { updateNextConfig, updateViteConfig } from "./configManipulation.js";
|
|
1
2
|
import { exists, readFileFromRoot, writeFileToRoot } from "./fileSystem.js";
|
|
2
3
|
import { parseJSONWithComments } from "./jsonParser.js";
|
|
3
4
|
import { findTsConfigFiles } from "./tsConfig.js";
|
|
4
|
-
export { exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, writeFileToRoot };
|
|
5
|
+
export { exists, findTsConfigFiles, parseJSONWithComments, readFileFromRoot, updateNextConfig, updateViteConfig, writeFileToRoot };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
//#region src/installSkills/index.d.ts
|
|
2
|
+
declare const SKILLS_METADATA: {
|
|
3
|
+
readonly Setup: "General Intlayer setup guide";
|
|
4
|
+
readonly Usage: "How to use Intlayer in your project";
|
|
5
|
+
readonly RemoteContent: "How to use Intlayer with Remote/CMS/Server-side content";
|
|
6
|
+
readonly Config: "Intlayer configuration documentation";
|
|
7
|
+
readonly ExtraAction: "Additional CLI and automated actions";
|
|
8
|
+
readonly Content: "Reference for all Intlayer content node types (t, enu, etc.)";
|
|
9
|
+
readonly React: "React-specific syntax and hooks usage";
|
|
10
|
+
readonly Angular: "Angular-specific syntax and Injectable Function usage";
|
|
11
|
+
readonly NextJS: "Next.js-specific usage (Server & Client components)";
|
|
12
|
+
readonly Vue: "Vue-specific composables and syntax";
|
|
13
|
+
readonly Svelte: "Svelte-specific stores and syntax";
|
|
14
|
+
readonly Astro: "Astro-specific usage and getIntlayer";
|
|
15
|
+
};
|
|
16
|
+
declare const SKILLS: (keyof typeof SKILLS_METADATA)[];
|
|
17
|
+
type Skill = (typeof SKILLS)[number];
|
|
18
|
+
declare const installSkills: (projectRoot: string, platform: "Cursor" | "VSCode" | "OpenCode" | "Claude" | "Other", skills: Skill[]) => Promise<string>;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SKILLS, SKILLS_METADATA, Skill, installSkills };
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../src/installSkills/index.ts"],"mappings":";cAIa,eAAA;EAAA;;;;;;;;;;;;;cAeA,MAAA,gBAEM,eAAA;AAAA,KAEP,KAAA,WAAgB,MAAA;AAAA,cAaf,aAAA,GACX,WAAA,UACA,QAAA,yDACA,MAAA,EAAQ,KAAA,OACP,OAAA"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { DictionariesStatus } from "./loadDictionaries.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as _intlayer_types0 from "@intlayer/types";
|
|
3
3
|
import { Dictionary } from "@intlayer/types";
|
|
4
4
|
import { DictionaryAPI } from "@intlayer/backend";
|
|
5
5
|
|
|
6
6
|
//#region src/loadDictionaries/loadRemoteDictionaries.d.ts
|
|
7
7
|
declare const formatDistantDictionaries: (dictionaries: (DictionaryAPI | Dictionary)[]) => Dictionary[];
|
|
8
|
-
declare const loadRemoteDictionaries: (configuration?:
|
|
8
|
+
declare const loadRemoteDictionaries: (configuration?: _intlayer_types0.IntlayerConfig, onStatusUpdate?: (status: DictionariesStatus[]) => void, options?: {
|
|
9
9
|
onStartRemoteCheck?: () => void;
|
|
10
10
|
onStopRemoteCheck?: () => void;
|
|
11
11
|
onError?: (error: Error) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"mappings":";;;;;;cAUa,yBAAA,GACX,YAAA,GAAe,aAAA,GAAgB,UAAA,QAC9B,UAAA;AAAA,cAOU,sBAAA,GACX,aAAA,GAqID,
|
|
1
|
+
{"version":3,"file":"loadRemoteDictionaries.d.ts","names":[],"sources":["../../../src/loadDictionaries/loadRemoteDictionaries.ts"],"mappings":";;;;;;cAUa,yBAAA,GACX,YAAA,GAAe,aAAA,GAAgB,UAAA,QAC9B,UAAA;AAAA,cAOU,sBAAA,GACX,aAAA,GAqID,gBAAA,CArIC,cAAA,EACA,cAAA,IAAkB,MAAA,EAAQ,kBAAA,aAC1B,OAAA;EACE,kBAAA;EACA,iBAAA;EACA,OAAA,IAAW,KAAA,EAAO,KAAA;AAAA,MAEnB,OAAA,CAAQ,UAAA"}
|
package/dist/types/watcher.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { IntlayerConfig } from "@intlayer/types";
|
|
2
2
|
import { GetConfigurationOptions } from "@intlayer/config";
|
|
3
|
-
import * as
|
|
3
|
+
import * as chokidar from "chokidar";
|
|
4
4
|
import { ChokidarOptions } from "chokidar";
|
|
5
5
|
|
|
6
6
|
//#region src/watcher.d.ts
|
|
@@ -9,7 +9,7 @@ type WatchOptions = ChokidarOptions & {
|
|
|
9
9
|
configOptions?: GetConfigurationOptions;
|
|
10
10
|
skipPrepare?: boolean;
|
|
11
11
|
};
|
|
12
|
-
declare const watch: (options?: WatchOptions) =>
|
|
12
|
+
declare const watch: (options?: WatchOptions) => chokidar.FSWatcher;
|
|
13
13
|
declare const buildAndWatchIntlayer: (options?: WatchOptions) => Promise<void>;
|
|
14
14
|
//#endregion
|
|
15
15
|
export { buildAndWatchIntlayer, watch };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;;;KAuBK,YAAA,GAAe,eAAA;EAClB,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;AAAA;AAAA,cAIW,KAAA,GAAS,OAAA,GAAU,YAAA,KAAY,
|
|
1
|
+
{"version":3,"file":"watcher.d.ts","names":[],"sources":["../../src/watcher.ts"],"mappings":";;;;;;KAuBK,YAAA,GAAe,eAAA;EAClB,aAAA,GAAgB,cAAA;EAChB,aAAA,GAAgB,uBAAA;EAChB,WAAA;AAAA;AAAA,cAIW,KAAA,GAAS,OAAA,GAAU,YAAA,KAAY,QAAA,CAAA,SAAA;AAAA,cA0H/B,qBAAA,GAA+B,OAAA,GAAU,YAAA,KAAY,OAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/chokidar",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.5",
|
|
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": [
|
|
@@ -75,13 +75,13 @@
|
|
|
75
75
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@intlayer/api": "8.0.
|
|
79
|
-
"@intlayer/config": "8.0.
|
|
80
|
-
"@intlayer/core": "8.0.
|
|
81
|
-
"@intlayer/dictionaries-entry": "8.0.
|
|
82
|
-
"@intlayer/remote-dictionaries-entry": "8.0.
|
|
83
|
-
"@intlayer/types": "8.0.
|
|
84
|
-
"@intlayer/unmerged-dictionaries-entry": "8.0.
|
|
78
|
+
"@intlayer/api": "8.0.5",
|
|
79
|
+
"@intlayer/config": "8.0.5",
|
|
80
|
+
"@intlayer/core": "8.0.5",
|
|
81
|
+
"@intlayer/dictionaries-entry": "8.0.5",
|
|
82
|
+
"@intlayer/remote-dictionaries-entry": "8.0.5",
|
|
83
|
+
"@intlayer/types": "8.0.5",
|
|
84
|
+
"@intlayer/unmerged-dictionaries-entry": "8.0.5",
|
|
85
85
|
"chokidar": "3.6.0",
|
|
86
86
|
"crypto-js": "4.2.0",
|
|
87
87
|
"defu": "6.1.4",
|
|
@@ -92,19 +92,19 @@
|
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@types/crypto-js": "4.2.2",
|
|
95
|
-
"@types/node": "25.
|
|
95
|
+
"@types/node": "25.2.2",
|
|
96
96
|
"@utils/ts-config": "1.0.4",
|
|
97
97
|
"@utils/ts-config-types": "1.0.4",
|
|
98
98
|
"@utils/tsdown-config": "1.0.4",
|
|
99
99
|
"rimraf": "6.1.2",
|
|
100
|
-
"tsdown": "0.20.
|
|
100
|
+
"tsdown": "0.20.3",
|
|
101
101
|
"typescript": "5.9.3",
|
|
102
102
|
"vitest": "4.0.18",
|
|
103
103
|
"zod": "4.3.6"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
|
-
"@intlayer/svelte-transformer": "8.0.
|
|
107
|
-
"@intlayer/vue-transformer": "8.0.
|
|
106
|
+
"@intlayer/svelte-transformer": "8.0.5",
|
|
107
|
+
"@intlayer/vue-transformer": "8.0.5"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@intlayer/svelte-transformer": {
|