create-rstack 1.6.2 → 1.7.1
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/index.js
CHANGED
|
@@ -1670,6 +1670,10 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
1670
1670
|
skipFiles
|
|
1671
1671
|
});
|
|
1672
1672
|
const packageRoot = node_path.resolve(src_dirname, '..');
|
|
1673
|
+
const agentsMdSearchDirs = [
|
|
1674
|
+
srcFolder,
|
|
1675
|
+
commonFolder
|
|
1676
|
+
];
|
|
1673
1677
|
for (const tool of tools){
|
|
1674
1678
|
const toolFolder = node_path.join(packageRoot, `template-${tool}`);
|
|
1675
1679
|
if ('eslint' === tool) {
|
|
@@ -1685,6 +1689,8 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
1685
1689
|
skipFiles,
|
|
1686
1690
|
isMergePackageJson: true
|
|
1687
1691
|
});
|
|
1692
|
+
agentsMdSearchDirs.push(toolFolder);
|
|
1693
|
+
agentsMdSearchDirs.push(subFolder);
|
|
1688
1694
|
continue;
|
|
1689
1695
|
}
|
|
1690
1696
|
copyFolder({
|
|
@@ -1694,8 +1700,15 @@ async function create({ name, root, templates, skipFiles, getTemplateName, mapES
|
|
|
1694
1700
|
skipFiles,
|
|
1695
1701
|
isMergePackageJson: true
|
|
1696
1702
|
});
|
|
1703
|
+
agentsMdSearchDirs.push(toolFolder);
|
|
1697
1704
|
if ('biome' === tool) await node_fs.promises.rename(node_path.join(distFolder, 'biome.json.template'), node_path.join(distFolder, 'biome.json'));
|
|
1698
1705
|
}
|
|
1706
|
+
const agentsFiles = collectAgentsFiles(agentsMdSearchDirs);
|
|
1707
|
+
if (agentsFiles.length > 0) {
|
|
1708
|
+
const mergedAgents = mergeAgentsFiles(agentsFiles);
|
|
1709
|
+
const agentsPath = node_path.join(distFolder, 'AGENTS.md');
|
|
1710
|
+
node_fs.writeFileSync(agentsPath, `${mergedAgents}\n`);
|
|
1711
|
+
}
|
|
1699
1712
|
const nextSteps = noteInformation ? noteInformation : [
|
|
1700
1713
|
`1. ${picocolors_default().cyan(`cd ${targetDir}`)}`,
|
|
1701
1714
|
`2. ${picocolors_default().cyan('git init')} ${picocolors_default().dim('(optional)')}`,
|
|
@@ -1776,4 +1789,69 @@ const updatePackageJson = (pkgJsonPath, version, name)=>{
|
|
|
1776
1789
|
if (name && '.' !== name) pkg.name = name;
|
|
1777
1790
|
node_fs.writeFileSync(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
1778
1791
|
};
|
|
1792
|
+
function readAgentsFile(filePath) {
|
|
1793
|
+
if (!node_fs.existsSync(filePath)) return null;
|
|
1794
|
+
return node_fs.readFileSync(filePath, 'utf-8');
|
|
1795
|
+
}
|
|
1796
|
+
function parseAgentsContent(content) {
|
|
1797
|
+
const sections = {};
|
|
1798
|
+
const lines = content.split('\n');
|
|
1799
|
+
let currentKey = '';
|
|
1800
|
+
let currentTitle = '';
|
|
1801
|
+
let currentLevel = 0;
|
|
1802
|
+
let currentContent = [];
|
|
1803
|
+
for (const line of lines){
|
|
1804
|
+
const sectionMatch = line.match(/^(#{1,2})\s+(.+)$/);
|
|
1805
|
+
if (sectionMatch) {
|
|
1806
|
+
if (currentKey) sections[currentKey] = {
|
|
1807
|
+
title: currentTitle,
|
|
1808
|
+
level: currentLevel,
|
|
1809
|
+
content: currentContent.join('\n').trim()
|
|
1810
|
+
};
|
|
1811
|
+
currentLevel = sectionMatch[1].length;
|
|
1812
|
+
currentTitle = sectionMatch[2].trim();
|
|
1813
|
+
currentKey = `${currentLevel}-${currentTitle.toLowerCase()}`;
|
|
1814
|
+
currentContent = [];
|
|
1815
|
+
} else if (currentKey) currentContent.push(line);
|
|
1816
|
+
}
|
|
1817
|
+
if (currentKey) sections[currentKey] = {
|
|
1818
|
+
title: currentTitle,
|
|
1819
|
+
level: currentLevel,
|
|
1820
|
+
content: currentContent.join('\n').trim()
|
|
1821
|
+
};
|
|
1822
|
+
return sections;
|
|
1823
|
+
}
|
|
1824
|
+
function mergeAgentsFiles(agentsFiles) {
|
|
1825
|
+
const allSections = {};
|
|
1826
|
+
for (const fileContent of agentsFiles){
|
|
1827
|
+
if (!fileContent) continue;
|
|
1828
|
+
const sections = parseAgentsContent(fileContent);
|
|
1829
|
+
for (const [key, section] of Object.entries(sections)){
|
|
1830
|
+
if (!allSections[key]) allSections[key] = {
|
|
1831
|
+
title: section.title,
|
|
1832
|
+
level: section.level,
|
|
1833
|
+
contents: []
|
|
1834
|
+
};
|
|
1835
|
+
if (section.content && !allSections[key].contents.includes(section.content)) allSections[key].contents.push(section.content);
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1838
|
+
const result = [];
|
|
1839
|
+
for (const [, section] of Object.entries(allSections)){
|
|
1840
|
+
result.push(`${'#'.repeat(section.level)} ${section.title}`);
|
|
1841
|
+
result.push('');
|
|
1842
|
+
for (const content of section.contents){
|
|
1843
|
+
result.push(content);
|
|
1844
|
+
result.push('');
|
|
1845
|
+
}
|
|
1846
|
+
}
|
|
1847
|
+
return result.join('\n').trim();
|
|
1848
|
+
}
|
|
1849
|
+
function collectAgentsFiles(agentsMdSearchDirs) {
|
|
1850
|
+
const agentsFiles = [];
|
|
1851
|
+
for (const dir of agentsMdSearchDirs){
|
|
1852
|
+
const agentsContent = readAgentsFile(node_path.join(dir, 'AGENTS.md'));
|
|
1853
|
+
if (agentsContent) agentsFiles.push(agentsContent);
|
|
1854
|
+
}
|
|
1855
|
+
return agentsFiles;
|
|
1856
|
+
}
|
|
1779
1857
|
export { checkCancel, copyFolder, create, mergePackageJson, fe as multiselect, ve as select, he as text };
|
package/package.json
CHANGED