@intlayer/engine 9.8.0 → 9.8.2
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/initConfig/templates/cjs.txt +16 -15
- package/dist/assets/initConfig/templates/json.txt +8 -7
- package/dist/assets/initConfig/templates/mjs.txt +16 -15
- package/dist/assets/initConfig/templates/ts.txt +16 -15
- package/dist/cjs/_virtual/_utils_asset.cjs +1 -1
- package/dist/cjs/build.cjs +9 -9
- package/dist/cjs/buildIntlayerDictionary/writeDynamicDictionary.cjs +3 -3
- package/dist/cjs/buildIntlayerDictionary/writeFetchDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeMergedDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeNestedDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeRemoteDictionary.cjs +2 -2
- package/dist/cjs/buildIntlayerDictionary/writeUnmergedDictionary.cjs +2 -2
- package/dist/cjs/cleanOutputDir.cjs +1 -1
- package/dist/cjs/cleanRemovedContentDeclaration.cjs +1 -1
- package/dist/cjs/cli.cjs +22 -7
- package/dist/cjs/createDictionaryEntryPoint/createDictionaryEntryPoint.cjs +1 -1
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.cjs +2 -2
- package/dist/cjs/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.cjs +2 -2
- package/dist/cjs/createType/createModuleAugmentation.cjs +1 -1
- package/dist/cjs/createType/createType.cjs +1 -1
- package/dist/cjs/detectFormatCommand.cjs +45 -0
- package/dist/cjs/detectFormatCommand.cjs.map +1 -1
- package/dist/cjs/handleContentDeclarationFileChange.cjs +2 -2
- package/dist/cjs/init/aiSetup.cjs +280 -0
- package/dist/cjs/init/aiSetup.cjs.map +1 -0
- package/dist/cjs/init/cms.cjs +50 -6
- package/dist/cjs/init/cms.cjs.map +1 -1
- package/dist/cjs/init/frameworkSetup/nextAppRouter/index.cjs +2 -2
- package/dist/cjs/init/frameworkSetup/nextAppRouter/restructure.cjs +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/index.cjs +1 -1
- package/dist/cjs/init/frameworkSetup/tanstackStart/restructure.cjs +1 -1
- package/dist/cjs/init/index.cjs +29 -3
- package/dist/cjs/init/index.cjs.map +1 -1
- package/dist/cjs/init/utils/configManipulation.cjs +47 -10
- package/dist/cjs/init/utils/configManipulation.cjs.map +1 -1
- package/dist/cjs/init/utils/fileSystem.cjs +2 -2
- package/dist/cjs/init/utils/githubActions.cjs +1 -1
- package/dist/cjs/init/utils/index.cjs +11 -0
- package/dist/cjs/init/utils/intlayerDependencies.cjs +2 -2
- package/dist/cjs/init/utils/packageManager.cjs +1 -1
- package/dist/cjs/init/utils/toolConfigManipulation.cjs +247 -0
- package/dist/cjs/init/utils/toolConfigManipulation.cjs.map +1 -0
- package/dist/cjs/initConfig/index.cjs +1 -1
- package/dist/cjs/installLSP.cjs +1 -1
- package/dist/cjs/installMCP/installMCP.cjs +44 -2
- package/dist/cjs/installMCP/installMCP.cjs.map +1 -1
- package/dist/cjs/installSkills/index.cjs +1 -1
- package/dist/cjs/listGitFiles.cjs +1 -1
- package/dist/cjs/loadDictionaries/getIntlayerBundle.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadContentDeclaration.cjs +1 -1
- package/dist/cjs/loadDictionaries/loadLocalDictionaries.cjs +1 -1
- package/dist/cjs/loadDictionaries/log.cjs +1 -1
- package/dist/cjs/prepareIntlayer.cjs +2 -2
- package/dist/cjs/scan/index.cjs +7 -7
- package/dist/cjs/syncPluginKit/createFileAdapter.cjs +1 -1
- package/dist/cjs/utils/buildComponentFilesList.cjs +1 -1
- package/dist/cjs/utils/contentWatcherLock.cjs +2 -2
- package/dist/cjs/utils/readDictionariesFromDisk.cjs +1 -1
- package/dist/cjs/utils/runOnce.cjs +2 -2
- package/dist/cjs/utils/withFileLock.cjs +2 -2
- package/dist/cjs/watcher.cjs +4 -4
- package/dist/cjs/writeConfiguration/index.cjs +2 -2
- package/dist/cjs/writeContentDeclaration/processContentDeclarationContent.cjs +1 -1
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs +3 -12
- package/dist/cjs/writeContentDeclaration/writeContentDeclaration.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs +3 -12
- package/dist/cjs/writeContentDeclaration/writeJSFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs +2 -11
- package/dist/cjs/writeContentDeclaration/writeMarkdownFile.cjs.map +1 -1
- package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs +2 -11
- package/dist/cjs/writeContentDeclaration/writeYamlFile.cjs.map +1 -1
- package/dist/cjs/writeFileIfChanged.cjs +2 -2
- package/dist/esm/_virtual/_utils_asset.mjs +1 -1
- package/dist/esm/build.mjs +9 -9
- package/dist/esm/buildIntlayerDictionary/writeDynamicDictionary.mjs +3 -3
- package/dist/esm/buildIntlayerDictionary/writeFetchDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeMergedDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeNestedDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeRemoteDictionary.mjs +2 -2
- package/dist/esm/buildIntlayerDictionary/writeUnmergedDictionary.mjs +2 -2
- package/dist/esm/cleanOutputDir.mjs +1 -1
- package/dist/esm/cleanRemovedContentDeclaration.mjs +1 -1
- package/dist/esm/cli.mjs +12 -11
- package/dist/esm/createDictionaryEntryPoint/createDictionaryEntryPoint.mjs +1 -1
- package/dist/esm/createDictionaryEntryPoint/getBuiltDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltDynamicDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltFetchDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltRemoteDictionariesPath.mjs +2 -2
- package/dist/esm/createDictionaryEntryPoint/getBuiltUnmergedDictionariesPath.mjs +2 -2
- package/dist/esm/createType/createModuleAugmentation.mjs +1 -1
- package/dist/esm/createType/createType.mjs +1 -1
- package/dist/esm/detectFormatCommand.mjs +43 -1
- package/dist/esm/detectFormatCommand.mjs.map +1 -1
- package/dist/esm/handleContentDeclarationFileChange.mjs +2 -2
- package/dist/esm/init/aiSetup.mjs +270 -0
- package/dist/esm/init/aiSetup.mjs.map +1 -0
- package/dist/esm/init/cms.mjs +50 -8
- package/dist/esm/init/cms.mjs.map +1 -1
- package/dist/esm/init/frameworkSetup/nextAppRouter/index.mjs +2 -2
- package/dist/esm/init/frameworkSetup/nextAppRouter/restructure.mjs +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/index.mjs +1 -1
- package/dist/esm/init/frameworkSetup/tanstackStart/restructure.mjs +1 -1
- package/dist/esm/init/index.mjs +29 -3
- package/dist/esm/init/index.mjs.map +1 -1
- package/dist/esm/init/utils/configManipulation.mjs +47 -11
- package/dist/esm/init/utils/configManipulation.mjs.map +1 -1
- package/dist/esm/init/utils/fileSystem.mjs +2 -2
- package/dist/esm/init/utils/githubActions.mjs +1 -1
- package/dist/esm/init/utils/index.mjs +3 -2
- package/dist/esm/init/utils/intlayerDependencies.mjs +2 -2
- package/dist/esm/init/utils/packageManager.mjs +1 -1
- package/dist/esm/init/utils/toolConfigManipulation.mjs +236 -0
- package/dist/esm/init/utils/toolConfigManipulation.mjs.map +1 -0
- package/dist/esm/initConfig/index.mjs +1 -1
- package/dist/esm/installLSP.mjs +1 -1
- package/dist/esm/installMCP/installMCP.mjs +44 -3
- package/dist/esm/installMCP/installMCP.mjs.map +1 -1
- package/dist/esm/installSkills/index.mjs +1 -1
- package/dist/esm/listGitFiles.mjs +1 -1
- package/dist/esm/loadDictionaries/getIntlayerBundle.mjs +1 -1
- package/dist/esm/loadDictionaries/loadContentDeclaration.mjs +1 -1
- package/dist/esm/loadDictionaries/loadLocalDictionaries.mjs +1 -1
- package/dist/esm/loadDictionaries/log.mjs +1 -1
- package/dist/esm/prepareIntlayer.mjs +2 -2
- package/dist/esm/scan/index.mjs +7 -7
- package/dist/esm/syncPluginKit/createFileAdapter.mjs +1 -1
- package/dist/esm/utils/buildComponentFilesList.mjs +1 -1
- package/dist/esm/utils/contentWatcherLock.mjs +2 -2
- package/dist/esm/utils/readDictionariesFromDisk.mjs +1 -1
- package/dist/esm/utils/runOnce.mjs +2 -2
- package/dist/esm/utils/withFileLock.mjs +2 -2
- package/dist/esm/watcher.mjs +4 -4
- package/dist/esm/writeConfiguration/index.mjs +2 -2
- package/dist/esm/writeContentDeclaration/processContentDeclarationContent.mjs +1 -1
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs +4 -13
- package/dist/esm/writeContentDeclaration/writeContentDeclaration.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs +4 -13
- package/dist/esm/writeContentDeclaration/writeJSFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs +3 -12
- package/dist/esm/writeContentDeclaration/writeMarkdownFile.mjs.map +1 -1
- package/dist/esm/writeContentDeclaration/writeYamlFile.mjs +3 -12
- package/dist/esm/writeContentDeclaration/writeYamlFile.mjs.map +1 -1
- package/dist/esm/writeFileIfChanged.mjs +2 -2
- package/dist/types/build.d.ts +15 -15
- package/dist/types/cli.d.ts +14 -13
- package/dist/types/detectFormatCommand.d.ts +24 -0
- package/dist/types/detectFormatCommand.d.ts.map +1 -1
- package/dist/types/init/aiSetup.d.ts +69 -0
- package/dist/types/init/aiSetup.d.ts.map +1 -0
- package/dist/types/init/cms.d.ts +13 -1
- package/dist/types/init/cms.d.ts.map +1 -1
- package/dist/types/init/index.d.ts.map +1 -1
- package/dist/types/init/utils/configManipulation.d.ts +14 -0
- package/dist/types/init/utils/configManipulation.d.ts.map +1 -1
- package/dist/types/init/utils/index.d.ts +3 -2
- package/dist/types/init/utils/toolConfigManipulation.d.ts +46 -0
- package/dist/types/init/utils/toolConfigManipulation.d.ts.map +1 -0
- package/dist/types/installMCP/installMCP.d.ts +6 -0
- package/dist/types/installMCP/installMCP.d.ts.map +1 -1
- package/dist/types/loadDictionaries/loadRemoteDictionaries.d.ts +1 -1
- package/dist/types/scan/index.d.ts +2 -2
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts +1 -1
- package/dist/types/writeContentDeclaration/writeContentDeclaration.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeJSFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeMarkdownFile.d.ts.map +1 -1
- package/dist/types/writeContentDeclaration/writeYamlFile.d.ts.map +1 -1
- package/package.json +10 -10
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_runtime = require("../../_virtual/_rolldown/runtime.cjs");
|
|
3
|
+
const require_utils_babelParser = require("../../utils/babelParser.cjs");
|
|
4
|
+
const require_init_utils_astImports = require("./astImports.cjs");
|
|
5
|
+
const require_init_utils_lintConfig = require("./lintConfig.cjs");
|
|
6
|
+
const require_init_utils_prettierConfig = require("./prettierConfig.cjs");
|
|
7
|
+
let recast = require("recast");
|
|
8
|
+
recast = require_runtime.__toESM(recast);
|
|
9
|
+
|
|
10
|
+
// src/init/utils/toolConfigManipulation.ts
|
|
11
|
+
const { builders: b, namedTypes: n } = recast.types;
|
|
12
|
+
/** ESLint flat config file names, in the order ESLint resolves them. */
|
|
13
|
+
const ESLINT_FLAT_CONFIG_FILES = [
|
|
14
|
+
"eslint.config.js",
|
|
15
|
+
"eslint.config.mjs",
|
|
16
|
+
"eslint.config.cjs",
|
|
17
|
+
"eslint.config.ts",
|
|
18
|
+
"eslint.config.mts",
|
|
19
|
+
"eslint.config.cts"
|
|
20
|
+
];
|
|
21
|
+
/** Prettier config files holding JavaScript / TypeScript. */
|
|
22
|
+
const SCRIPT_PRETTIER_CONFIG_FILES = [
|
|
23
|
+
"prettier.config.js",
|
|
24
|
+
"prettier.config.mjs",
|
|
25
|
+
"prettier.config.cjs",
|
|
26
|
+
"prettier.config.ts",
|
|
27
|
+
"prettier.config.mts",
|
|
28
|
+
"prettier.config.cts",
|
|
29
|
+
".prettierrc.js",
|
|
30
|
+
".prettierrc.mjs",
|
|
31
|
+
".prettierrc.cjs",
|
|
32
|
+
".prettierrc.ts",
|
|
33
|
+
".prettierrc.mts",
|
|
34
|
+
".prettierrc.cts"
|
|
35
|
+
];
|
|
36
|
+
/** Prettier config files holding YAML. */
|
|
37
|
+
const YAML_PRETTIER_CONFIG_FILES = [".prettierrc.yaml", ".prettierrc.yml"];
|
|
38
|
+
/** Local name the plugin default import is bound to. */
|
|
39
|
+
const LINT_PLUGIN_BINDING = "intlayer";
|
|
40
|
+
/**
|
|
41
|
+
* Prints the AST with the quote style the file already uses (single quotes
|
|
42
|
+
* unless the source prefers double ones), so injected strings match it.
|
|
43
|
+
*/
|
|
44
|
+
const printWithSourceQuotes = (ast, source) => {
|
|
45
|
+
const singleQuoteCount = (source.match(/'/g) ?? []).length;
|
|
46
|
+
const doubleQuoteCount = (source.match(/"/g) ?? []).length;
|
|
47
|
+
return recast.print(ast, { quote: doubleQuoteCount > singleQuoteCount ? "double" : "single" }).code;
|
|
48
|
+
};
|
|
49
|
+
/** Whether the file is CommonJS (`require` / `module.exports`). */
|
|
50
|
+
const isCommonJsFile = (content, extension) => extension === "cjs" || extension === "cts" || content.includes("module.exports") && !/^\s*import\s/m.test(content);
|
|
51
|
+
/** Strips `satisfies` / `as` / parentheses wrappers from an expression. */
|
|
52
|
+
const unwrapExpression = (expression) => {
|
|
53
|
+
let current = expression;
|
|
54
|
+
while (current && (current.type === "TSSatisfiesExpression" || current.type === "TSAsExpression" || current.type === "ParenthesizedExpression")) current = current.expression;
|
|
55
|
+
return current;
|
|
56
|
+
};
|
|
57
|
+
/** Finds the initializer of a top-level `const|let|var <name> = …`. */
|
|
58
|
+
const findTopLevelInitializer = (ast, name) => {
|
|
59
|
+
for (const statement of ast.program.body) {
|
|
60
|
+
const declaration = statement.type === "ExportNamedDeclaration" ? statement.declaration : statement;
|
|
61
|
+
if (declaration?.type !== "VariableDeclaration") continue;
|
|
62
|
+
for (const declarator of declaration.declarations) if (declarator.id?.type === "Identifier" && declarator.id.name === name) return declarator.init;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Resolves the exported config expression (`export default …` or
|
|
67
|
+
* `module.exports = …`), following one identifier indirection
|
|
68
|
+
* (`const config = …; export default config`).
|
|
69
|
+
*/
|
|
70
|
+
const findExportedConfigExpression = (ast) => {
|
|
71
|
+
let exported;
|
|
72
|
+
for (const statement of ast.program.body) if (statement.type === "ExportDefaultDeclaration") exported = statement.declaration;
|
|
73
|
+
else if (statement.type === "ExpressionStatement" && statement.expression.type === "AssignmentExpression" && recast.print(statement.expression.left).code === "module.exports") exported = statement.expression.right;
|
|
74
|
+
const unwrapped = unwrapExpression(exported);
|
|
75
|
+
if (unwrapped?.type === "Identifier") return unwrapExpression(findTopLevelInitializer(ast, unwrapped.name));
|
|
76
|
+
return unwrapped;
|
|
77
|
+
};
|
|
78
|
+
/** Adds `import <binding> from '<source>'` (or its `require` form). */
|
|
79
|
+
const addDefaultImport = (ast, binding, source, isCommonJs) => {
|
|
80
|
+
const declaration = isCommonJs ? b.variableDeclaration("const", [b.variableDeclarator(b.identifier(binding), b.callExpression(b.identifier("require"), [b.stringLiteral(source)]))]) : b.importDeclaration([b.importDefaultSpecifier(b.identifier(binding))], b.stringLiteral(source));
|
|
81
|
+
const body = ast.program.body;
|
|
82
|
+
let insertIndex = require_init_utils_astImports.firstInsertIndex(ast);
|
|
83
|
+
if (isCommonJs) while (insertIndex < body.length && body[insertIndex].type === "VariableDeclaration" && body[insertIndex].declarations.every((declarator) => declarator.init?.type === "CallExpression" && declarator.init.callee?.name === "require")) insertIndex++;
|
|
84
|
+
body.splice(insertIndex, 0, declaration);
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Adds `...intlayer.configs.recommended` to an ESLint flat config, importing
|
|
88
|
+
* `eslint-plugin-intlayer` when needed. Handles the exported array, and the
|
|
89
|
+
* `defineConfig(…)` / `tseslint.config(…)` / `composer(…)`-style helpers
|
|
90
|
+
* (array argument or variadic configs).
|
|
91
|
+
*/
|
|
92
|
+
const addIntlayerPresetToEslintFlatConfig = (content, extension) => {
|
|
93
|
+
if (content.includes("eslint-plugin-intlayer")) return { status: "already" };
|
|
94
|
+
let ast;
|
|
95
|
+
try {
|
|
96
|
+
ast = recast.parse(content, { parser: require_utils_babelParser.typescriptParser });
|
|
97
|
+
} catch {
|
|
98
|
+
return { status: "unsupported" };
|
|
99
|
+
}
|
|
100
|
+
const configExpression = findExportedConfigExpression(ast);
|
|
101
|
+
/** Array the preset is spread into, when the config is (or wraps) one. */
|
|
102
|
+
const targetArray = configExpression?.type === "ArrayExpression" ? configExpression : configExpression?.type === "CallExpression" && configExpression.arguments.length === 1 && unwrapExpression(configExpression.arguments[0])?.type === "ArrayExpression" ? unwrapExpression(configExpression.arguments[0]) : void 0;
|
|
103
|
+
const isVariadicHelper = !targetArray && configExpression?.type === "CallExpression";
|
|
104
|
+
if (!targetArray && !isVariadicHelper) return { status: "unsupported" };
|
|
105
|
+
const binding = require_init_utils_astImports.isModuleScopeBinding(ast, LINT_PLUGIN_BINDING) ? "intlayerPlugin" : LINT_PLUGIN_BINDING;
|
|
106
|
+
if (require_init_utils_astImports.isModuleScopeBinding(ast, binding)) return { status: "unsupported" };
|
|
107
|
+
const presetSpread = b.spreadElement(b.memberExpression(b.memberExpression(b.identifier(binding), b.identifier("configs")), b.identifier("recommended")));
|
|
108
|
+
if (targetArray) targetArray.elements.push(presetSpread);
|
|
109
|
+
else configExpression.arguments.push(presetSpread);
|
|
110
|
+
addDefaultImport(ast, binding, require_init_utils_lintConfig.LINT_PLUGIN_PACKAGE_NAME, isCommonJsFile(content, extension));
|
|
111
|
+
return {
|
|
112
|
+
status: "updated",
|
|
113
|
+
content: printWithSourceQuotes(ast, content)
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Adds `prettier-plugin-intlayer` to the `plugins` of a JavaScript /
|
|
118
|
+
* TypeScript Prettier config (`export default {…}`, `module.exports = {…}`,
|
|
119
|
+
* or an exported `const config = {…}`).
|
|
120
|
+
*/
|
|
121
|
+
const addIntlayerPluginToPrettierScriptConfig = (content) => {
|
|
122
|
+
if (content.includes("prettier-plugin-intlayer")) return { status: "already" };
|
|
123
|
+
let ast;
|
|
124
|
+
try {
|
|
125
|
+
ast = recast.parse(content, { parser: require_utils_babelParser.typescriptParser });
|
|
126
|
+
} catch {
|
|
127
|
+
return { status: "unsupported" };
|
|
128
|
+
}
|
|
129
|
+
const configObject = findExportedConfigExpression(ast);
|
|
130
|
+
if (!n.ObjectExpression.check(configObject)) return { status: "unsupported" };
|
|
131
|
+
const pluginsProperty = configObject.properties.find((property) => (property.key?.name ?? property.key?.value) === "plugins" && property.type !== "SpreadElement");
|
|
132
|
+
const pluginLiteral = b.stringLiteral(require_init_utils_prettierConfig.PRETTIER_PLUGIN_PACKAGE_NAME);
|
|
133
|
+
if (!pluginsProperty) configObject.properties.push(b.property("init", b.identifier("plugins"), b.arrayExpression([pluginLiteral])));
|
|
134
|
+
else if (unwrapExpression(pluginsProperty.value)?.type === "ArrayExpression") unwrapExpression(pluginsProperty.value).elements.push(pluginLiteral);
|
|
135
|
+
else return { status: "unsupported" };
|
|
136
|
+
return {
|
|
137
|
+
status: "updated",
|
|
138
|
+
content: printWithSourceQuotes(ast, content)
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Adds `prettier-plugin-intlayer` to a YAML Prettier config: appends a
|
|
143
|
+
* `plugins` block, or extends an existing block / flow list.
|
|
144
|
+
*/
|
|
145
|
+
const addIntlayerPluginToPrettierYamlConfig = (content) => {
|
|
146
|
+
if (content.includes("prettier-plugin-intlayer")) return { status: "already" };
|
|
147
|
+
const pluginsLineMatch = content.match(/^plugins:[ \t]*(.*)$/m);
|
|
148
|
+
if (!pluginsLineMatch) return {
|
|
149
|
+
status: "updated",
|
|
150
|
+
content: `${content}${content.length > 0 && !content.endsWith("\n") ? "\n" : ""}plugins:\n - ${require_init_utils_prettierConfig.PRETTIER_PLUGIN_PACKAGE_NAME}\n`
|
|
151
|
+
};
|
|
152
|
+
const inlineValue = (pluginsLineMatch[1] ?? "").trim();
|
|
153
|
+
const flowListMatch = inlineValue.match(/^\[(.*)\]$/);
|
|
154
|
+
if (flowListMatch) {
|
|
155
|
+
const items = (flowListMatch[1] ?? "").trim();
|
|
156
|
+
const nextList = items ? `[${items}, ${require_init_utils_prettierConfig.PRETTIER_PLUGIN_PACKAGE_NAME}]` : `[${require_init_utils_prettierConfig.PRETTIER_PLUGIN_PACKAGE_NAME}]`;
|
|
157
|
+
return {
|
|
158
|
+
status: "updated",
|
|
159
|
+
content: content.replace(pluginsLineMatch[0], `plugins: ${nextList}`)
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (inlineValue !== "") return { status: "unsupported" };
|
|
163
|
+
const lines = content.split("\n");
|
|
164
|
+
const pluginsLineIndex = lines.findIndex((line) => line.startsWith("plugins:"));
|
|
165
|
+
let lastItemIndex = pluginsLineIndex;
|
|
166
|
+
let indentation = " ";
|
|
167
|
+
for (let index = pluginsLineIndex + 1; index < lines.length; index++) {
|
|
168
|
+
const line = lines[index] ?? "";
|
|
169
|
+
const itemMatch = line.match(/^([ \t]*)-\s/);
|
|
170
|
+
if (itemMatch) {
|
|
171
|
+
lastItemIndex = index;
|
|
172
|
+
indentation = itemMatch[1] ?? "";
|
|
173
|
+
} else if (line.trim() !== "" && !/^\s/.test(line)) break;
|
|
174
|
+
}
|
|
175
|
+
lines.splice(lastItemIndex + 1, 0, `${indentation}- ${require_init_utils_prettierConfig.PRETTIER_PLUGIN_PACKAGE_NAME}`);
|
|
176
|
+
return {
|
|
177
|
+
status: "updated",
|
|
178
|
+
content: lines.join("\n")
|
|
179
|
+
};
|
|
180
|
+
};
|
|
181
|
+
/** Content declaration extensions TanStack Router must not treat as routes. */
|
|
182
|
+
const CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN = "\\.content\\.(ts|tsx|js|jsx|mjs|cjs|json|jsonc|json5|md|mdx|yaml|yml)$";
|
|
183
|
+
/** TanStack plugins accepting a router config, and where it lives. */
|
|
184
|
+
const TANSTACK_ROUTER_PLUGINS = {
|
|
185
|
+
tanstackStart: "router",
|
|
186
|
+
tanstackRouter: "root",
|
|
187
|
+
TanStackRouterVite: "root"
|
|
188
|
+
};
|
|
189
|
+
/** Whether a Vite config registers a TanStack Router / Start plugin. */
|
|
190
|
+
const hasTanStackRouterVitePlugin = (content) => Object.keys(TANSTACK_ROUTER_PLUGINS).some((pluginName) => content.includes(`${pluginName}(`));
|
|
191
|
+
/**
|
|
192
|
+
* Sets `routeFileIgnorePattern` on the TanStack Start / Router Vite plugin so
|
|
193
|
+
* co-located `.content.*` files are not picked up as route files. An existing
|
|
194
|
+
* string pattern is combined with the content one.
|
|
195
|
+
*/
|
|
196
|
+
const setTanStackRouteFileIgnorePattern = (content) => {
|
|
197
|
+
let ast;
|
|
198
|
+
try {
|
|
199
|
+
ast = recast.parse(content, { parser: require_utils_babelParser.typescriptParser });
|
|
200
|
+
} catch {
|
|
201
|
+
return { status: "unsupported" };
|
|
202
|
+
}
|
|
203
|
+
const outcome = { status: "unsupported" };
|
|
204
|
+
recast.visit(ast, { visitCallExpression(path) {
|
|
205
|
+
const { callee, arguments: callArguments } = path.node;
|
|
206
|
+
const location = callee.type === "Identifier" ? TANSTACK_ROUTER_PLUGINS[callee.name] : void 0;
|
|
207
|
+
if (!location) return this.traverse(path);
|
|
208
|
+
if (callArguments.length === 0) callArguments.push(b.objectExpression([]));
|
|
209
|
+
let optionsObject = callArguments[0];
|
|
210
|
+
if (optionsObject.type !== "ObjectExpression") return false;
|
|
211
|
+
if (location === "router") {
|
|
212
|
+
let routerProperty = optionsObject.properties.find((property) => (property.key?.name ?? property.key?.value) === "router");
|
|
213
|
+
if (!routerProperty) {
|
|
214
|
+
routerProperty = b.property("init", b.identifier("router"), b.objectExpression([]));
|
|
215
|
+
optionsObject.properties.push(routerProperty);
|
|
216
|
+
}
|
|
217
|
+
if (routerProperty.value?.type !== "ObjectExpression") return false;
|
|
218
|
+
optionsObject = routerProperty.value;
|
|
219
|
+
}
|
|
220
|
+
const ignoreProperty = optionsObject.properties.find((property) => (property.key?.name ?? property.key?.value) === "routeFileIgnorePattern");
|
|
221
|
+
if (!ignoreProperty) {
|
|
222
|
+
optionsObject.properties.push(b.property("init", b.identifier("routeFileIgnorePattern"), b.stringLiteral(CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN)));
|
|
223
|
+
outcome.status = "updated";
|
|
224
|
+
} else if (ignoreProperty.value?.type === "StringLiteral" && ignoreProperty.value.value.includes(".content")) outcome.status = "already";
|
|
225
|
+
else if (ignoreProperty.value?.type === "StringLiteral") {
|
|
226
|
+
ignoreProperty.value = b.stringLiteral(`(?:${ignoreProperty.value.value})|(?:${CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN})`);
|
|
227
|
+
outcome.status = "updated";
|
|
228
|
+
}
|
|
229
|
+
return false;
|
|
230
|
+
} });
|
|
231
|
+
if (outcome.status === "updated") return {
|
|
232
|
+
status: "updated",
|
|
233
|
+
content: printWithSourceQuotes(ast, content)
|
|
234
|
+
};
|
|
235
|
+
return { status: outcome.status };
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
exports.CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN = CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN;
|
|
239
|
+
exports.ESLINT_FLAT_CONFIG_FILES = ESLINT_FLAT_CONFIG_FILES;
|
|
240
|
+
exports.SCRIPT_PRETTIER_CONFIG_FILES = SCRIPT_PRETTIER_CONFIG_FILES;
|
|
241
|
+
exports.YAML_PRETTIER_CONFIG_FILES = YAML_PRETTIER_CONFIG_FILES;
|
|
242
|
+
exports.addIntlayerPluginToPrettierScriptConfig = addIntlayerPluginToPrettierScriptConfig;
|
|
243
|
+
exports.addIntlayerPluginToPrettierYamlConfig = addIntlayerPluginToPrettierYamlConfig;
|
|
244
|
+
exports.addIntlayerPresetToEslintFlatConfig = addIntlayerPresetToEslintFlatConfig;
|
|
245
|
+
exports.hasTanStackRouterVitePlugin = hasTanStackRouterVitePlugin;
|
|
246
|
+
exports.setTanStackRouteFileIgnorePattern = setTanStackRouteFileIgnorePattern;
|
|
247
|
+
//# sourceMappingURL=toolConfigManipulation.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toolConfigManipulation.cjs","names":["firstInsertIndex","typescriptParser","isModuleScopeBinding","LINT_PLUGIN_PACKAGE_NAME","PRETTIER_PLUGIN_PACKAGE_NAME"],"sources":["../../../../src/init/utils/toolConfigManipulation.ts"],"sourcesContent":["import * as recast from 'recast';\nimport { typescriptParser } from '../../utils/babelParser';\nimport { firstInsertIndex, isModuleScopeBinding } from './astImports';\nimport { LINT_PLUGIN_PACKAGE_NAME } from './lintConfig';\nimport { PRETTIER_PLUGIN_PACKAGE_NAME } from './prettierConfig';\n\nconst { builders: b, namedTypes: n } = recast.types;\n\n/** ESLint flat config file names, in the order ESLint resolves them. */\nexport const ESLINT_FLAT_CONFIG_FILES = [\n 'eslint.config.js',\n 'eslint.config.mjs',\n 'eslint.config.cjs',\n 'eslint.config.ts',\n 'eslint.config.mts',\n 'eslint.config.cts',\n];\n\n/** Prettier config files holding JavaScript / TypeScript. */\nexport const SCRIPT_PRETTIER_CONFIG_FILES = [\n 'prettier.config.js',\n 'prettier.config.mjs',\n 'prettier.config.cjs',\n 'prettier.config.ts',\n 'prettier.config.mts',\n 'prettier.config.cts',\n '.prettierrc.js',\n '.prettierrc.mjs',\n '.prettierrc.cjs',\n '.prettierrc.ts',\n '.prettierrc.mts',\n '.prettierrc.cts',\n];\n\n/** Prettier config files holding YAML. */\nexport const YAML_PRETTIER_CONFIG_FILES = [\n '.prettierrc.yaml',\n '.prettierrc.yml',\n];\n\n/**\n * Outcome of a config patch: `updated` carries the rewritten file, `already`\n * means the plugin is wired, `unsupported` that the file shape is not one the\n * patcher can edit safely (the caller prints the manual snippet instead).\n */\nexport type ToolConfigPatchResult =\n | { status: 'updated'; content: string }\n | { status: 'already' | 'unsupported' };\n\n/** Local name the plugin default import is bound to. */\nconst LINT_PLUGIN_BINDING = 'intlayer';\n\n/**\n * Prints the AST with the quote style the file already uses (single quotes\n * unless the source prefers double ones), so injected strings match it.\n */\nconst printWithSourceQuotes = (ast: any, source: string): string => {\n const singleQuoteCount = (source.match(/'/g) ?? []).length;\n const doubleQuoteCount = (source.match(/\"/g) ?? []).length;\n\n return recast.print(ast, {\n quote: doubleQuoteCount > singleQuoteCount ? 'double' : 'single',\n }).code;\n};\n\n/** Whether the file is CommonJS (`require` / `module.exports`). */\nconst isCommonJsFile = (content: string, extension: string): boolean =>\n extension === 'cjs' ||\n extension === 'cts' ||\n (content.includes('module.exports') && !/^\\s*import\\s/m.test(content));\n\n/** Strips `satisfies` / `as` / parentheses wrappers from an expression. */\nconst unwrapExpression = (expression: any): any => {\n let current = expression;\n\n while (\n current &&\n (current.type === 'TSSatisfiesExpression' ||\n current.type === 'TSAsExpression' ||\n current.type === 'ParenthesizedExpression')\n ) {\n current = current.expression;\n }\n\n return current;\n};\n\n/** Finds the initializer of a top-level `const|let|var <name> = …`. */\nconst findTopLevelInitializer = (ast: any, name: string): any => {\n for (const statement of ast.program.body) {\n const declaration =\n statement.type === 'ExportNamedDeclaration'\n ? statement.declaration\n : statement;\n\n if (declaration?.type !== 'VariableDeclaration') continue;\n\n for (const declarator of declaration.declarations) {\n if (declarator.id?.type === 'Identifier' && declarator.id.name === name) {\n return declarator.init;\n }\n }\n }\n\n return undefined;\n};\n\n/**\n * Resolves the exported config expression (`export default …` or\n * `module.exports = …`), following one identifier indirection\n * (`const config = …; export default config`).\n */\nconst findExportedConfigExpression = (ast: any): any => {\n let exported: any;\n\n for (const statement of ast.program.body) {\n if (statement.type === 'ExportDefaultDeclaration') {\n exported = statement.declaration;\n } else if (\n statement.type === 'ExpressionStatement' &&\n statement.expression.type === 'AssignmentExpression' &&\n recast.print(statement.expression.left).code === 'module.exports'\n ) {\n exported = statement.expression.right;\n }\n }\n\n const unwrapped = unwrapExpression(exported);\n\n if (unwrapped?.type === 'Identifier') {\n return unwrapExpression(findTopLevelInitializer(ast, unwrapped.name));\n }\n\n return unwrapped;\n};\n\n/** Adds `import <binding> from '<source>'` (or its `require` form). */\nconst addDefaultImport = (\n ast: any,\n binding: string,\n source: string,\n isCommonJs: boolean\n): void => {\n const declaration = isCommonJs\n ? b.variableDeclaration('const', [\n b.variableDeclarator(\n b.identifier(binding),\n b.callExpression(b.identifier('require'), [b.stringLiteral(source)])\n ),\n ])\n : b.importDeclaration(\n [b.importDefaultSpecifier(b.identifier(binding))],\n b.stringLiteral(source)\n );\n\n const body = ast.program.body;\n let insertIndex = firstInsertIndex(ast);\n\n if (isCommonJs) {\n // Group with the leading `const … = require(…)` statements.\n while (\n insertIndex < body.length &&\n body[insertIndex].type === 'VariableDeclaration' &&\n body[insertIndex].declarations.every(\n (declarator: any) =>\n declarator.init?.type === 'CallExpression' &&\n declarator.init.callee?.name === 'require'\n )\n ) {\n insertIndex++;\n }\n }\n\n body.splice(insertIndex, 0, declaration);\n};\n\n/**\n * Adds `...intlayer.configs.recommended` to an ESLint flat config, importing\n * `eslint-plugin-intlayer` when needed. Handles the exported array, and the\n * `defineConfig(…)` / `tseslint.config(…)` / `composer(…)`-style helpers\n * (array argument or variadic configs).\n */\nexport const addIntlayerPresetToEslintFlatConfig = (\n content: string,\n extension: string\n): ToolConfigPatchResult => {\n if (content.includes(LINT_PLUGIN_PACKAGE_NAME)) return { status: 'already' };\n\n let ast: any;\n try {\n ast = recast.parse(content, { parser: typescriptParser });\n } catch {\n return { status: 'unsupported' };\n }\n\n const configExpression = findExportedConfigExpression(ast);\n\n /** Array the preset is spread into, when the config is (or wraps) one. */\n const targetArray =\n configExpression?.type === 'ArrayExpression'\n ? configExpression\n : configExpression?.type === 'CallExpression' &&\n configExpression.arguments.length === 1 &&\n unwrapExpression(configExpression.arguments[0])?.type ===\n 'ArrayExpression'\n ? unwrapExpression(configExpression.arguments[0])\n : undefined;\n\n const isVariadicHelper =\n !targetArray && configExpression?.type === 'CallExpression';\n\n if (!targetArray && !isVariadicHelper) return { status: 'unsupported' };\n\n // A name clash with an unrelated `intlayer` binding falls back to an alias.\n const binding = isModuleScopeBinding(ast, LINT_PLUGIN_BINDING)\n ? 'intlayerPlugin'\n : LINT_PLUGIN_BINDING;\n\n if (isModuleScopeBinding(ast, binding)) return { status: 'unsupported' };\n\n const presetSpread = b.spreadElement(\n b.memberExpression(\n b.memberExpression(b.identifier(binding), b.identifier('configs')),\n b.identifier('recommended')\n )\n );\n\n if (targetArray) {\n targetArray.elements.push(presetSpread);\n } else {\n configExpression.arguments.push(presetSpread);\n }\n\n addDefaultImport(\n ast,\n binding,\n LINT_PLUGIN_PACKAGE_NAME,\n isCommonJsFile(content, extension)\n );\n\n return { status: 'updated', content: printWithSourceQuotes(ast, content) };\n};\n\n/**\n * Adds `prettier-plugin-intlayer` to the `plugins` of a JavaScript /\n * TypeScript Prettier config (`export default {…}`, `module.exports = {…}`,\n * or an exported `const config = {…}`).\n */\nexport const addIntlayerPluginToPrettierScriptConfig = (\n content: string\n): ToolConfigPatchResult => {\n if (content.includes(PRETTIER_PLUGIN_PACKAGE_NAME)) {\n return { status: 'already' };\n }\n\n let ast: any;\n try {\n ast = recast.parse(content, { parser: typescriptParser });\n } catch {\n return { status: 'unsupported' };\n }\n\n const configObject = findExportedConfigExpression(ast);\n\n if (!n.ObjectExpression.check(configObject)) {\n return { status: 'unsupported' };\n }\n\n const pluginsProperty = (configObject.properties as any[]).find(\n (property) =>\n (property.key?.name ?? property.key?.value) === 'plugins' &&\n property.type !== 'SpreadElement'\n );\n const pluginLiteral = b.stringLiteral(PRETTIER_PLUGIN_PACKAGE_NAME);\n\n if (!pluginsProperty) {\n configObject.properties.push(\n b.property(\n 'init',\n b.identifier('plugins'),\n b.arrayExpression([pluginLiteral])\n )\n );\n } else if (\n unwrapExpression(pluginsProperty.value)?.type === 'ArrayExpression'\n ) {\n unwrapExpression(pluginsProperty.value).elements.push(pluginLiteral);\n } else {\n return { status: 'unsupported' };\n }\n\n return { status: 'updated', content: printWithSourceQuotes(ast, content) };\n};\n\n/**\n * Adds `prettier-plugin-intlayer` to a YAML Prettier config: appends a\n * `plugins` block, or extends an existing block / flow list.\n */\nexport const addIntlayerPluginToPrettierYamlConfig = (\n content: string\n): ToolConfigPatchResult => {\n if (content.includes(PRETTIER_PLUGIN_PACKAGE_NAME)) {\n return { status: 'already' };\n }\n\n const pluginsLineMatch = content.match(/^plugins:[ \\t]*(.*)$/m);\n\n if (!pluginsLineMatch) {\n const separator = content.length > 0 && !content.endsWith('\\n') ? '\\n' : '';\n return {\n status: 'updated',\n content: `${content}${separator}plugins:\\n - ${PRETTIER_PLUGIN_PACKAGE_NAME}\\n`,\n };\n }\n\n const inlineValue = (pluginsLineMatch[1] ?? '').trim();\n\n // Flow list: `plugins: [a, b]` / `plugins: []`.\n const flowListMatch = inlineValue.match(/^\\[(.*)\\]$/);\n if (flowListMatch) {\n const items = (flowListMatch[1] ?? '').trim();\n const nextList = items\n ? `[${items}, ${PRETTIER_PLUGIN_PACKAGE_NAME}]`\n : `[${PRETTIER_PLUGIN_PACKAGE_NAME}]`;\n\n return {\n status: 'updated',\n content: content.replace(pluginsLineMatch[0], `plugins: ${nextList}`),\n };\n }\n\n if (inlineValue !== '') return { status: 'unsupported' };\n\n // Block list: append after the last `- item` of the block.\n const lines = content.split('\\n');\n const pluginsLineIndex = lines.findIndex((line) =>\n line.startsWith('plugins:')\n );\n let lastItemIndex = pluginsLineIndex;\n let indentation = ' ';\n\n for (let index = pluginsLineIndex + 1; index < lines.length; index++) {\n const line = lines[index] ?? '';\n const itemMatch = line.match(/^([ \\t]*)-\\s/);\n if (itemMatch) {\n lastItemIndex = index;\n indentation = itemMatch[1] ?? '';\n } else if (line.trim() !== '' && !/^\\s/.test(line)) {\n break;\n }\n }\n\n lines.splice(\n lastItemIndex + 1,\n 0,\n `${indentation}- ${PRETTIER_PLUGIN_PACKAGE_NAME}`\n );\n\n return { status: 'updated', content: lines.join('\\n') };\n};\n\n/** Content declaration extensions TanStack Router must not treat as routes. */\nexport const CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN =\n '\\\\.content\\\\.(ts|tsx|js|jsx|mjs|cjs|json|jsonc|json5|md|mdx|yaml|yml)$';\n\n/** TanStack plugins accepting a router config, and where it lives. */\nconst TANSTACK_ROUTER_PLUGINS: Record<string, 'root' | 'router'> = {\n tanstackStart: 'router',\n tanstackRouter: 'root',\n TanStackRouterVite: 'root',\n};\n\n/** Whether a Vite config registers a TanStack Router / Start plugin. */\nexport const hasTanStackRouterVitePlugin = (content: string): boolean =>\n Object.keys(TANSTACK_ROUTER_PLUGINS).some((pluginName) =>\n content.includes(`${pluginName}(`)\n );\n\n/**\n * Sets `routeFileIgnorePattern` on the TanStack Start / Router Vite plugin so\n * co-located `.content.*` files are not picked up as route files. An existing\n * string pattern is combined with the content one.\n */\nexport const setTanStackRouteFileIgnorePattern = (\n content: string\n): ToolConfigPatchResult => {\n let ast: any;\n try {\n ast = recast.parse(content, { parser: typescriptParser });\n } catch {\n return { status: 'unsupported' };\n }\n\n // Mutated inside the visitor: an object keeps TS from narrowing it away.\n const outcome: { status: ToolConfigPatchResult['status'] } = {\n status: 'unsupported',\n };\n\n recast.visit(ast, {\n visitCallExpression(path) {\n const { callee, arguments: callArguments } = path.node as any;\n const location =\n callee.type === 'Identifier'\n ? TANSTACK_ROUTER_PLUGINS[callee.name]\n : undefined;\n\n if (!location) return this.traverse(path);\n\n if (callArguments.length === 0) {\n callArguments.push(b.objectExpression([]));\n }\n\n let optionsObject = callArguments[0];\n if (optionsObject.type !== 'ObjectExpression') return false;\n\n if (location === 'router') {\n let routerProperty = optionsObject.properties.find(\n (property: any) =>\n (property.key?.name ?? property.key?.value) === 'router'\n );\n\n if (!routerProperty) {\n routerProperty = b.property(\n 'init',\n b.identifier('router'),\n b.objectExpression([])\n );\n optionsObject.properties.push(routerProperty);\n }\n\n if (routerProperty.value?.type !== 'ObjectExpression') return false;\n optionsObject = routerProperty.value;\n }\n\n const ignoreProperty = optionsObject.properties.find(\n (property: any) =>\n (property.key?.name ?? property.key?.value) ===\n 'routeFileIgnorePattern'\n );\n\n if (!ignoreProperty) {\n optionsObject.properties.push(\n b.property(\n 'init',\n b.identifier('routeFileIgnorePattern'),\n b.stringLiteral(CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN)\n )\n );\n outcome.status = 'updated';\n } else if (\n ignoreProperty.value?.type === 'StringLiteral' &&\n ignoreProperty.value.value.includes('.content')\n ) {\n outcome.status = 'already';\n } else if (ignoreProperty.value?.type === 'StringLiteral') {\n ignoreProperty.value = b.stringLiteral(\n `(?:${ignoreProperty.value.value})|(?:${CONTENT_DECLARATION_ROUTE_IGNORE_PATTERN})`\n );\n outcome.status = 'updated';\n }\n\n return false;\n },\n });\n\n if (outcome.status === 'updated') {\n return { status: 'updated', content: printWithSourceQuotes(ast, content) };\n }\n\n return { status: outcome.status };\n};\n"],"mappings":";;;;;;;;;;AAMA,MAAM,EAAE,UAAU,GAAG,YAAY,MAAM,OAAO;;AAG9C,MAAa,2BAA2B;CACtC;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,+BAA+B;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;AAGA,MAAa,6BAA6B,CACxC,oB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F;GACA,QAAQ,SAAS;EACnB,OAAO,IACL,eAAe,OAAO,SAAS,mBAC/B,eAAe,MAAM,MAAM,SAAS,UAAU,GAE9C,QAAQ,SAAS;OACZ,IAAI,eAAe,OAAO,SAAS,iBAAiB;GACzD,eAAe,QAAQ,EAAE,cACvB,MAAM,eAAe,MAAM,MAAM,OAAO,yCAAyC,EACnF;GACA,QAAQ,SAAS;EACnB;EAEA,OAAO;CACT,EACF,CAAC;CAED,IAAI,QAAQ,WAAW,WACrB,OAAO;EAAE,QAAQ;EAAW,SAAS,sBAAsB,KAAK,OAAO;CAAE;CAG3E,OAAO,EAAE,QAAQ,QAAQ,OAAO;AAClC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require__utils_asset = require("../_virtual/_utils_asset.cjs");
|
|
3
3
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
4
|
-
let node_path = require("node:path");
|
|
5
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
|
+
let node_path = require("node:path");
|
|
6
6
|
let _intlayer_config_node = require("@intlayer/config/node");
|
|
7
7
|
|
|
8
8
|
// src/initConfig/index.ts
|
package/dist/cjs/installLSP.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require("./_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
3
|
let node_path = require("node:path");
|
|
5
4
|
node_path = require_runtime.__toESM(node_path);
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
6
|
|
|
7
7
|
// src/installLSP.ts
|
|
8
8
|
const VSCODE_DIR = ".vscode";
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_installSkills_index = require("../installSkills/index.cjs");
|
|
4
|
-
let node_fs = require("node:fs");
|
|
5
4
|
let node_path = require("node:path");
|
|
6
5
|
node_path = require_runtime.__toESM(node_path);
|
|
6
|
+
let node_fs = require("node:fs");
|
|
7
7
|
|
|
8
8
|
// src/installMCP/installMCP.ts
|
|
9
9
|
/** Transports accepted by `intlayer init mcp --transport`. */
|
|
10
10
|
const MCP_TRANSPORTS = ["stdio", "sse"];
|
|
11
11
|
const MCP_CONFIG_FILENAME = "mcp.json";
|
|
12
|
+
/** Package run by the stdio MCP server entry. */
|
|
13
|
+
const MCP_PACKAGE_NAME = "@intlayer/mcp";
|
|
14
|
+
/**
|
|
15
|
+
* `npx` spec of the MCP server. The dist-tag makes `npx` resolve the published
|
|
16
|
+
* version on start, where a bare name keeps serving its cached copy.
|
|
17
|
+
*/
|
|
18
|
+
const getMCPPackageSpecifier = (distTag = "latest") => `${MCP_PACKAGE_NAME}@${distTag}`;
|
|
12
19
|
/** Project-scoped MCP configuration file read by Claude Code. */
|
|
13
20
|
const CLAUDE_CODE_MCP_CONFIG_FILENAME = ".mcp.json";
|
|
14
21
|
/** Platforms whose MCP entries declare their transport as `type`. */
|
|
@@ -24,7 +31,7 @@ const getMCPServerConfig = (platform, transport) => {
|
|
|
24
31
|
const isTypedTransport = TYPED_TRANSPORT_PLATFORMS.includes(platform);
|
|
25
32
|
if (transport === "stdio") return {
|
|
26
33
|
command: "npx",
|
|
27
|
-
args: ["-y",
|
|
34
|
+
args: ["-y", getMCPPackageSpecifier()],
|
|
28
35
|
...isTypedTransport ? { type: "stdio" } : {}
|
|
29
36
|
};
|
|
30
37
|
return {
|
|
@@ -54,7 +61,42 @@ const installMCP = async (projectRoot, platform, transport) => {
|
|
|
54
61
|
await node_fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
55
62
|
return `MCP server configuration updated in ${configPath}`;
|
|
56
63
|
};
|
|
64
|
+
/** Matches `@intlayer/mcp`, optionally followed by a version or dist-tag. */
|
|
65
|
+
const MCP_PACKAGE_ARGUMENT_PATTERN = /^@intlayer\/mcp(@.+)?$/;
|
|
66
|
+
/**
|
|
67
|
+
* Points the stdio Intlayer MCP entries of every platform config of the
|
|
68
|
+
* project at the given dist-tag (`npx -y @intlayer/mcp@latest`), so agents
|
|
69
|
+
* start the upgraded server. Returns the config files that were rewritten.
|
|
70
|
+
*/
|
|
71
|
+
const upgradeMCPConfigs = async (projectRoot, distTag = "latest") => {
|
|
72
|
+
const packageSpecifier = getMCPPackageSpecifier(distTag);
|
|
73
|
+
const configPaths = [...new Set(Object.keys(require_installSkills_index.PLATFORMS_METADATA).map((platform) => getMCPConfigPath(projectRoot, platform)))];
|
|
74
|
+
const updatedConfigPaths = [];
|
|
75
|
+
for (const configPath of configPaths) {
|
|
76
|
+
let config;
|
|
77
|
+
try {
|
|
78
|
+
config = JSON.parse(await node_fs.promises.readFile(configPath, "utf-8"));
|
|
79
|
+
} catch {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
let isUpdated = false;
|
|
83
|
+
for (const serversKey of ["servers", "mcpServers"]) {
|
|
84
|
+
const servers = config[serversKey];
|
|
85
|
+
for (const server of Object.values(servers ?? {})) server.args = server.args?.map((argument) => {
|
|
86
|
+
if (!MCP_PACKAGE_ARGUMENT_PATTERN.test(argument) || argument === packageSpecifier) return argument;
|
|
87
|
+
isUpdated = true;
|
|
88
|
+
return packageSpecifier;
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (isUpdated) {
|
|
92
|
+
await node_fs.promises.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
93
|
+
updatedConfigPaths.push(configPath);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return updatedConfigPaths;
|
|
97
|
+
};
|
|
57
98
|
|
|
58
99
|
exports.MCP_TRANSPORTS = MCP_TRANSPORTS;
|
|
59
100
|
exports.installMCP = installMCP;
|
|
101
|
+
exports.upgradeMCPConfigs = upgradeMCPConfigs;
|
|
60
102
|
//# sourceMappingURL=installMCP.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installMCP.cjs","names":["path","PLATFORMS_METADATA","fs"],"sources":["../../../src/installMCP/installMCP.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { PLATFORMS_METADATA, type Platform } from '../installSkills';\n\nexport type MCPTransport = 'stdio' | 'sse';\n\n/** Transports accepted by `intlayer init mcp --transport`. */\nexport const MCP_TRANSPORTS: MCPTransport[] = ['stdio', 'sse'];\n\nconst MCP_CONFIG_FILENAME = 'mcp.json';\n\n/** Project-scoped MCP configuration file read by Claude Code. */\nconst CLAUDE_CODE_MCP_CONFIG_FILENAME = '.mcp.json';\n\n/** One MCP server entry, as written under the platform's servers key. */\ntype MCPServerConfig = {\n command?: string;\n args?: string[];\n url?: string;\n type?: MCPTransport;\n transport?: MCPTransport;\n};\n\n/** Parsed MCP configuration file, keeping any unrelated keys untouched. */\ntype MCPConfigFile = Record<string, unknown>;\n\n/** Platforms whose MCP entries declare their transport as `type`. */\nconst TYPED_TRANSPORT_PLATFORMS: Platform[] = ['VSCode', 'Claude'];\n\n/** Resolves the MCP configuration file written for a platform. */\nconst getMCPConfigPath = (projectRoot: string, platform: Platform): string => {\n if (platform === 'Claude') {\n return path.join(projectRoot, CLAUDE_CODE_MCP_CONFIG_FILENAME);\n }\n\n // e.g. `.cursor/skills` → `.cursor/mcp.json`\n const relativeDir = path.dirname(PLATFORMS_METADATA[platform]?.dir ?? '.');\n\n return path.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);\n};\n\n/** Builds the Intlayer MCP server entry for a platform and transport. */\nconst getMCPServerConfig = (\n platform: Platform,\n transport: MCPTransport\n): MCPServerConfig => {\n const isTypedTransport = TYPED_TRANSPORT_PLATFORMS.includes(platform);\n\n if (transport === 'stdio') {\n return {\n command: 'npx',\n args: ['-y',
|
|
1
|
+
{"version":3,"file":"installMCP.cjs","names":["path","PLATFORMS_METADATA","fs"],"sources":["../../../src/installMCP/installMCP.ts"],"sourcesContent":["import { promises as fs } from 'node:fs';\nimport path from 'node:path';\nimport { PLATFORMS_METADATA, type Platform } from '../installSkills';\n\nexport type MCPTransport = 'stdio' | 'sse';\n\n/** Transports accepted by `intlayer init mcp --transport`. */\nexport const MCP_TRANSPORTS: MCPTransport[] = ['stdio', 'sse'];\n\nconst MCP_CONFIG_FILENAME = 'mcp.json';\n\n/** Package run by the stdio MCP server entry. */\nconst MCP_PACKAGE_NAME = '@intlayer/mcp';\n\n/**\n * `npx` spec of the MCP server. The dist-tag makes `npx` resolve the published\n * version on start, where a bare name keeps serving its cached copy.\n */\nconst getMCPPackageSpecifier = (distTag: string = 'latest'): string =>\n `${MCP_PACKAGE_NAME}@${distTag}`;\n\n/** Project-scoped MCP configuration file read by Claude Code. */\nconst CLAUDE_CODE_MCP_CONFIG_FILENAME = '.mcp.json';\n\n/** One MCP server entry, as written under the platform's servers key. */\ntype MCPServerConfig = {\n command?: string;\n args?: string[];\n url?: string;\n type?: MCPTransport;\n transport?: MCPTransport;\n};\n\n/** Parsed MCP configuration file, keeping any unrelated keys untouched. */\ntype MCPConfigFile = Record<string, unknown>;\n\n/** Platforms whose MCP entries declare their transport as `type`. */\nconst TYPED_TRANSPORT_PLATFORMS: Platform[] = ['VSCode', 'Claude'];\n\n/** Resolves the MCP configuration file written for a platform. */\nconst getMCPConfigPath = (projectRoot: string, platform: Platform): string => {\n if (platform === 'Claude') {\n return path.join(projectRoot, CLAUDE_CODE_MCP_CONFIG_FILENAME);\n }\n\n // e.g. `.cursor/skills` → `.cursor/mcp.json`\n const relativeDir = path.dirname(PLATFORMS_METADATA[platform]?.dir ?? '.');\n\n return path.join(projectRoot, relativeDir, MCP_CONFIG_FILENAME);\n};\n\n/** Builds the Intlayer MCP server entry for a platform and transport. */\nconst getMCPServerConfig = (\n platform: Platform,\n transport: MCPTransport\n): MCPServerConfig => {\n const isTypedTransport = TYPED_TRANSPORT_PLATFORMS.includes(platform);\n\n if (transport === 'stdio') {\n return {\n command: 'npx',\n args: ['-y', getMCPPackageSpecifier()],\n ...(isTypedTransport ? { type: 'stdio' } : {}),\n };\n }\n\n return {\n url: 'https://mcp.intlayer.org',\n ...(isTypedTransport ? { type: 'sse' } : { transport: 'sse' }),\n };\n};\n\n/**\n * Installs the Intlayer MCP server configuration for a specific platform.\n * Every platform is configured at the project level (Claude Code included,\n * through `.mcp.json`), so nothing outside the project is modified.\n */\nexport const installMCP = async (\n projectRoot: string,\n platform: Platform,\n transport: MCPTransport\n): Promise<string> => {\n const configPath = getMCPConfigPath(projectRoot, platform);\n const serversKey = platform === 'VSCode' ? 'servers' : 'mcpServers';\n\n // Ensure the configuration directory exists\n await fs.mkdir(path.dirname(configPath), { recursive: true });\n\n let config: MCPConfigFile = {};\n try {\n const content = await fs.readFile(configPath, 'utf-8');\n config = JSON.parse(content) as MCPConfigFile;\n } catch {\n // File doesn't exist or is invalid JSON, start fresh\n }\n\n const servers = (config[serversKey] ?? {}) as Record<string, MCPServerConfig>;\n\n config[serversKey] = {\n ...servers,\n intlayer: getMCPServerConfig(platform, transport),\n };\n\n await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');\n\n return `MCP server configuration updated in ${configPath}`;\n};\n\n/** Matches `@intlayer/mcp`, optionally followed by a version or dist-tag. */\nconst MCP_PACKAGE_ARGUMENT_PATTERN = /^@intlayer\\/mcp(@.+)?$/;\n\n/**\n * Points the stdio Intlayer MCP entries of every platform config of the\n * project at the given dist-tag (`npx -y @intlayer/mcp@latest`), so agents\n * start the upgraded server. Returns the config files that were rewritten.\n */\nexport const upgradeMCPConfigs = async (\n projectRoot: string,\n distTag: string = 'latest'\n): Promise<string[]> => {\n const packageSpecifier = getMCPPackageSpecifier(distTag);\n const configPaths = [\n ...new Set(\n (Object.keys(PLATFORMS_METADATA) as Platform[]).map((platform) =>\n getMCPConfigPath(projectRoot, platform)\n )\n ),\n ];\n const updatedConfigPaths: string[] = [];\n\n for (const configPath of configPaths) {\n let config: MCPConfigFile;\n\n try {\n config = JSON.parse(await fs.readFile(configPath, 'utf-8'));\n } catch {\n continue;\n }\n\n let isUpdated = false;\n\n for (const serversKey of ['servers', 'mcpServers']) {\n const servers = config[serversKey] as\n | Record<string, MCPServerConfig>\n | undefined;\n\n for (const server of Object.values(servers ?? {})) {\n server.args = server.args?.map((argument) => {\n if (\n !MCP_PACKAGE_ARGUMENT_PATTERN.test(argument) ||\n argument === packageSpecifier\n ) {\n return argument;\n }\n\n isUpdated = true;\n return packageSpecifier;\n });\n }\n }\n\n if (isUpdated) {\n await fs.writeFile(configPath, JSON.stringify(config, null, 2), 'utf-8');\n updatedConfigPaths.push(configPath);\n }\n }\n\n return updatedConfigPaths;\n};\n"],"mappings":";;;;;;;;;AAOA,MAAa,iBAAiC,CAAC,SAAS,KAAK;AAE7D,MAAM,sBAAsB;;AAG5B,MAAM,mBAAmB;;;;;AAMzB,MAAM,0BAA0B,UAAkB,aAChD,GAAG,iBAAiB,GAAG;;AAGzB,MAAM,kCAAkC;;AAexC,MAAM,4BAAwC,CAAC,UAAU,QAAQ;;AAGjE,MAAM,oBAAoB,aAAqB,aAA+B;CAC5E,IAAI,aAAa,UACf,OAAOA,kBAAK,KAAK,aAAa,+BAA+B;CAI/D,MAAM,cAAcA,kBAAK,QAAQC,+CAAmB,SAAS,EAAE,OAAO,GAAG;CAEzE,OAAOD,kBAAK,KAAK,aAAa,aAAa,mBAAmB;AAChE;;AAGA,MAAM,sBACJ,UACA,cACoB;CACpB,MAAM,mBAAmB,0BAA0B,SAAS,QAAQ;CAEpE,IAAI,cAAc,SAChB,OAAO;EACL,SAAS;EACT,MAAM,CAAC,MAAM,uBAAuB,CAAC;EACrC,GAAI,mBAAmB,EAAE,MAAM,QAAQ,IAAI,CAAC;CAC9C;CAGF,OAAO;EACL,KAAK;EACL,GAAI,mBAAmB,EAAE,MAAM,MAAM,IAAI,EAAE,WAAW,MAAM;CAC9D;AAC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,CAAC;EAEL;EAEA,IAAI,WAAW;GACb,MAAMA,iBAAG,UAAU,YAAY,KAAK,UAAU,QAAQ,MAAM,CAAC,GAAG,OAAO;GACvE,mBAAmB,KAAK,UAAU;EACpC;CACF;CAEA,OAAO;AACT"}
|
|
@@ -2,9 +2,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require__utils_asset = require("../_virtual/_utils_asset.cjs");
|
|
4
4
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
5
|
-
let node_fs = require("node:fs");
|
|
6
5
|
let node_path = require("node:path");
|
|
7
6
|
node_path = require_runtime.__toESM(node_path);
|
|
7
|
+
let node_fs = require("node:fs");
|
|
8
8
|
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
9
9
|
|
|
10
10
|
// src/installSkills/index.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
3
|
let node_path = require("node:path");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
5
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
6
6
|
let simple_git = require("simple-git");
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let node_path = require("node:path");
|
|
3
2
|
let node_fs_promises = require("node:fs/promises");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
4
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
5
5
|
let _intlayer_config_file = require("@intlayer/config/file");
|
|
6
6
|
let node_module = require("node:module");
|
|
@@ -5,8 +5,8 @@ const require_loadDictionaries_getIntlayerBundle = require("./getIntlayerBundle.
|
|
|
5
5
|
const require_loadDictionaries_loadMarkdownContentDeclaration = require("./loadMarkdownContentDeclaration.cjs");
|
|
6
6
|
const require_loadDictionaries_loadYamlContentDeclaration = require("./loadYamlContentDeclaration.cjs");
|
|
7
7
|
const require_loadDictionaries_logTypeScriptErrors = require("./logTypeScriptErrors.cjs");
|
|
8
|
-
let node_path = require("node:path");
|
|
9
8
|
let node_fs_promises = require("node:fs/promises");
|
|
9
|
+
let node_path = require("node:path");
|
|
10
10
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
11
11
|
let _intlayer_config_file = require("@intlayer/config/file");
|
|
12
12
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_loadDictionaries_loadContentDeclaration = require("./loadContentDeclaration.cjs");
|
|
3
|
-
let node_path = require("node:path");
|
|
4
3
|
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
5
|
|
|
6
6
|
// src/loadDictionaries/loadLocalDictionaries.ts
|
|
7
7
|
const loadLocalDictionaries = async (contentDeclarationsPaths, configuration) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
4
|
-
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
5
4
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
6
5
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
6
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
7
7
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
8
8
|
|
|
9
9
|
// src/loadDictionaries/log.ts
|
|
@@ -11,13 +11,13 @@ const require_loadDictionaries_loadDictionaries = require("./loadDictionaries/lo
|
|
|
11
11
|
const require_utils_runOnce = require("./utils/runOnce.cjs");
|
|
12
12
|
const require_writeConfiguration_index = require("./writeConfiguration/index.cjs");
|
|
13
13
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
14
|
-
let node_path = require("node:path");
|
|
15
14
|
let node_fs_promises = require("node:fs/promises");
|
|
16
|
-
let
|
|
15
|
+
let node_path = require("node:path");
|
|
17
16
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
18
17
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
19
18
|
let _intlayer_config_package_json = require("@intlayer/config/package.json");
|
|
20
19
|
_intlayer_config_package_json = require_runtime.__toESM(_intlayer_config_package_json);
|
|
20
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
21
21
|
|
|
22
22
|
// src/prepareIntlayer.ts
|
|
23
23
|
const DEFAULT_PREPARE_INTLAYER_OPTIONS = {
|
package/dist/cjs/scan/index.cjs
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_scan_analyzeBundleContent = require("./analyzeBundleContent.cjs");
|
|
3
3
|
const require_scan_calculateScore = require("./calculateScore.cjs");
|
|
4
|
-
const require_scan_detection_localeCode = require("./detection/localeCode.cjs");
|
|
5
|
-
const require_scan_detection_url = require("./detection/url.cjs");
|
|
6
|
-
const require_scan_detection_detectRoutingStrategy = require("./detection/detectRoutingStrategy.cjs");
|
|
7
|
-
const require_scan_detection_classifyInternalLinks = require("./detection/classifyInternalLinks.cjs");
|
|
8
4
|
const require_scan_checks = require("./checks.cjs");
|
|
5
|
+
const require_scan_detection_technologySignatures = require("./detection/technologySignatures.cjs");
|
|
6
|
+
const require_scan_detection_url = require("./detection/url.cjs");
|
|
7
|
+
const require_scan_detection_detectTechnologies = require("./detection/detectTechnologies.cjs");
|
|
9
8
|
const require_scan_fetchText = require("./fetchText.cjs");
|
|
10
9
|
const require_scan_parseHtml = require("./parseHtml.cjs");
|
|
10
|
+
const require_scan_detection_localeCode = require("./detection/localeCode.cjs");
|
|
11
|
+
const require_scan_detection_detectRoutingStrategy = require("./detection/detectRoutingStrategy.cjs");
|
|
12
|
+
const require_scan_detection_classifyInternalLinks = require("./detection/classifyInternalLinks.cjs");
|
|
11
13
|
const require_scan_robots = require("./robots.cjs");
|
|
12
|
-
const require_scan_detection_technologySignatures = require("./detection/technologySignatures.cjs");
|
|
13
|
-
const require_scan_detection_detectTechnologies = require("./detection/detectTechnologies.cjs");
|
|
14
14
|
const require_scan_runScanChecks = require("./runScanChecks.cjs");
|
|
15
15
|
const require_scan_scanWebsite = require("./scanWebsite.cjs");
|
|
16
|
+
const require_scan_sitemap = require("./sitemap.cjs");
|
|
16
17
|
const require_scan_detection_checkDetails = require("./detection/checkDetails.cjs");
|
|
17
18
|
const require_scan_detection_localizedPages = require("./detection/localizedPages.cjs");
|
|
18
|
-
const require_scan_sitemap = require("./sitemap.cjs");
|
|
19
19
|
|
|
20
20
|
exports.analyzeBundleContent = require_scan_analyzeBundleContent.analyzeBundleContent;
|
|
21
21
|
exports.byteLength = require_scan_parseHtml.byteLength;
|
|
@@ -3,8 +3,8 @@ const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
|
3
3
|
const require_writeFileIfChanged = require("../writeFileIfChanged.cjs");
|
|
4
4
|
const require_syncPluginKit_extractKeyAndLocaleFromPath = require("./extractKeyAndLocaleFromPath.cjs");
|
|
5
5
|
const require_syncPluginKit_filePathPatternHelpers = require("./filePathPatternHelpers.cjs");
|
|
6
|
-
let node_path = require("node:path");
|
|
7
6
|
let node_fs_promises = require("node:fs/promises");
|
|
7
|
+
let node_path = require("node:path");
|
|
8
8
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
9
9
|
let fast_glob = require("fast-glob");
|
|
10
10
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
const require_utils_isDirectoryExcluded = require("./isDirectoryExcluded.cjs");
|
|
4
|
-
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
5
4
|
let node_path = require("node:path");
|
|
6
5
|
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
6
|
+
let _intlayer_config_defaultValues = require("@intlayer/config/defaultValues");
|
|
7
7
|
let fast_glob = require("fast-glob");
|
|
8
8
|
fast_glob = require_runtime.__toESM(fast_glob);
|
|
9
9
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
3
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
4
|
-
let node_fs = require("node:fs");
|
|
5
|
-
let node_path = require("node:path");
|
|
6
4
|
let node_fs_promises = require("node:fs/promises");
|
|
5
|
+
let node_path = require("node:path");
|
|
7
6
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
8
7
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
8
|
+
let node_fs = require("node:fs");
|
|
9
9
|
|
|
10
10
|
// src/utils/contentWatcherLock.ts
|
|
11
11
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_runtime = require("../_virtual/_rolldown/runtime.cjs");
|
|
3
|
-
let node_fs = require("node:fs");
|
|
4
|
-
let node_path = require("node:path");
|
|
5
3
|
let node_fs_promises = require("node:fs/promises");
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
let node_fs = require("node:fs");
|
|
6
6
|
let _intlayer_core_package_json = require("@intlayer/core/package.json");
|
|
7
7
|
_intlayer_core_package_json = require_runtime.__toESM(_intlayer_core_package_json);
|
|
8
8
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
let node_fs = require("node:fs");
|
|
3
|
-
let node_path = require("node:path");
|
|
4
2
|
let node_fs_promises = require("node:fs/promises");
|
|
3
|
+
let node_path = require("node:path");
|
|
4
|
+
let node_fs = require("node:fs");
|
|
5
5
|
|
|
6
6
|
// src/utils/withFileLock.ts
|
|
7
7
|
const DEFAULT_OPTIONS = {
|
package/dist/cjs/watcher.cjs
CHANGED
|
@@ -11,14 +11,14 @@ const require_utils_isDirectoryExcluded = require("./utils/isDirectoryExcluded.c
|
|
|
11
11
|
const require_utils_parseContentDeclarationFileName = require("./utils/parseContentDeclarationFileName.cjs");
|
|
12
12
|
const require_utils_createBatchDebounce = require("./utils/createBatchDebounce.cjs");
|
|
13
13
|
let _intlayer_config_logger = require("@intlayer/config/logger");
|
|
14
|
-
let node_fs = require("node:fs");
|
|
15
|
-
let node_path = require("node:path");
|
|
16
14
|
let node_fs_promises = require("node:fs/promises");
|
|
17
|
-
let
|
|
15
|
+
let node_path = require("node:path");
|
|
18
16
|
let _intlayer_config_colors = require("@intlayer/config/colors");
|
|
19
17
|
_intlayer_config_colors = require_runtime.__toESM(_intlayer_config_colors);
|
|
20
|
-
let
|
|
18
|
+
let _intlayer_config_utils = require("@intlayer/config/utils");
|
|
19
|
+
let node_fs = require("node:fs");
|
|
21
20
|
let _intlayer_config_file = require("@intlayer/config/file");
|
|
21
|
+
let _intlayer_config_node = require("@intlayer/config/node");
|
|
22
22
|
|
|
23
23
|
// src/watcher.ts
|
|
24
24
|
const pendingUnlinks = /* @__PURE__ */ new Map();
|