@oamm/textor 1.0.14 → 1.0.16
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/README.md +8 -0
- package/dist/bin/textor.js +71 -8
- package/dist/bin/textor.js.map +1 -1
- package/dist/index.cjs +73 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +73 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ declare function statusCommand(): Promise<void>;
|
|
|
31
31
|
|
|
32
32
|
declare function syncCommand(options: any): Promise<void>;
|
|
33
33
|
|
|
34
|
-
declare function adoptCommand(
|
|
34
|
+
declare function adoptCommand(kind: any, arg2: any, arg3: any, options: any): Promise<void>;
|
|
35
35
|
|
|
36
36
|
declare function upgradeConfigCommand(options: any): Promise<void>;
|
|
37
37
|
|
package/dist/index.js
CHANGED
|
@@ -1534,18 +1534,26 @@ function reconstructSections(state, config) {
|
|
|
1534
1534
|
// Keep existing sections if their files still exist
|
|
1535
1535
|
const validSections = (state.sections || []).filter(section => {
|
|
1536
1536
|
// Check if route file exists in state.files
|
|
1537
|
-
const routeFile = Object.keys(files).find(f => {
|
|
1537
|
+
const routeFile = section.route ? Object.keys(files).find(f => {
|
|
1538
1538
|
const normalizedF = f.replace(/\\/g, '/');
|
|
1539
1539
|
const routePath = section.route === '/' ? 'index' : section.route.slice(1);
|
|
1540
1540
|
return normalizedF.startsWith(pagesRoot + '/' + routePath + '.') ||
|
|
1541
1541
|
normalizedF === pagesRoot + '/' + routePath + '/index.astro'; // nested mode
|
|
1542
|
-
});
|
|
1542
|
+
}) : true;
|
|
1543
1543
|
// Check if feature directory has at least one file in state.files
|
|
1544
|
-
const hasFeatureFiles = Object.keys(files).some(f =>
|
|
1544
|
+
const hasFeatureFiles = section.featurePath ? Object.keys(files).some(f => {
|
|
1545
|
+
const normalizedF = f.replace(/\\/g, '/');
|
|
1546
|
+
const featPath = section.featurePath.replace(/\\/g, '/');
|
|
1547
|
+
return normalizedF.startsWith(featPath + '/') ||
|
|
1548
|
+
normalizedF.startsWith(featuresRoot + '/' + featPath + '/');
|
|
1549
|
+
}) : false;
|
|
1545
1550
|
return routeFile && hasFeatureFiles;
|
|
1546
1551
|
});
|
|
1547
1552
|
const sections = new Map();
|
|
1548
|
-
validSections.forEach(s =>
|
|
1553
|
+
validSections.forEach(s => {
|
|
1554
|
+
const key = s.route || `feature:${s.featurePath}`;
|
|
1555
|
+
sections.set(key, s);
|
|
1556
|
+
});
|
|
1549
1557
|
// Try to discover new sections
|
|
1550
1558
|
for (const filePath in files) {
|
|
1551
1559
|
const normalizedPath = filePath.replace(/\\/g, '/');
|
|
@@ -3636,7 +3644,24 @@ async function syncCommand(options) {
|
|
|
3636
3644
|
}
|
|
3637
3645
|
}
|
|
3638
3646
|
|
|
3639
|
-
async function adoptCommand(
|
|
3647
|
+
async function adoptCommand(kind, arg2, arg3, options) {
|
|
3648
|
+
// Handle cases where options is in a different position due to variable arguments
|
|
3649
|
+
if (typeof kind === 'object' && kind !== null && !Array.isArray(kind)) {
|
|
3650
|
+
options = kind;
|
|
3651
|
+
kind = undefined;
|
|
3652
|
+
arg2 = undefined;
|
|
3653
|
+
arg3 = undefined;
|
|
3654
|
+
}
|
|
3655
|
+
else if (typeof arg2 === 'object' && arg2 !== null && !Array.isArray(arg2)) {
|
|
3656
|
+
options = arg2;
|
|
3657
|
+
arg2 = undefined;
|
|
3658
|
+
arg3 = undefined;
|
|
3659
|
+
}
|
|
3660
|
+
else if (typeof arg3 === 'object' && arg3 !== null && !Array.isArray(arg3)) {
|
|
3661
|
+
options = arg3;
|
|
3662
|
+
arg3 = undefined;
|
|
3663
|
+
}
|
|
3664
|
+
options = options || {};
|
|
3640
3665
|
try {
|
|
3641
3666
|
const config = await loadConfig();
|
|
3642
3667
|
const state = await loadState();
|
|
@@ -3646,6 +3671,9 @@ async function adoptCommand(identifier, options) {
|
|
|
3646
3671
|
components: resolvePath(config, 'components')
|
|
3647
3672
|
};
|
|
3648
3673
|
let filesToAdopt = [];
|
|
3674
|
+
let identifier = kind;
|
|
3675
|
+
let customName = null;
|
|
3676
|
+
let sourcePath = null;
|
|
3649
3677
|
if (!identifier && options.all) {
|
|
3650
3678
|
// Adopt all untracked files in all roots
|
|
3651
3679
|
const managedFiles = new Set();
|
|
@@ -3656,6 +3684,46 @@ async function adoptCommand(identifier, options) {
|
|
|
3656
3684
|
}
|
|
3657
3685
|
filesToAdopt = Array.from(managedFiles).filter(f => !state.files[f]);
|
|
3658
3686
|
}
|
|
3687
|
+
else if (kind === 'component' && arg2) {
|
|
3688
|
+
const componentName = arg2;
|
|
3689
|
+
const untrackedFiles = new Set();
|
|
3690
|
+
const compPath = path.join(roots.components, componentName);
|
|
3691
|
+
if (existsSync(compPath)) {
|
|
3692
|
+
await scanDirectoryOrFile(compPath, untrackedFiles, state);
|
|
3693
|
+
}
|
|
3694
|
+
else {
|
|
3695
|
+
throw new Error(`Component directory not found: ${compPath}`);
|
|
3696
|
+
}
|
|
3697
|
+
filesToAdopt = Array.from(untrackedFiles);
|
|
3698
|
+
}
|
|
3699
|
+
else if (kind === 'feature' && arg2 && arg3) {
|
|
3700
|
+
sourcePath = arg2;
|
|
3701
|
+
customName = arg3;
|
|
3702
|
+
const targetPath = path.join(roots.features, customName);
|
|
3703
|
+
const absoluteSource = path.resolve(process.cwd(), sourcePath);
|
|
3704
|
+
const absoluteTarget = path.resolve(targetPath);
|
|
3705
|
+
if (existsSync(absoluteSource)) {
|
|
3706
|
+
if (!options.dryRun && absoluteSource !== absoluteTarget) {
|
|
3707
|
+
if (!existsSync(path.dirname(absoluteTarget))) {
|
|
3708
|
+
await mkdir(path.dirname(absoluteTarget), { recursive: true });
|
|
3709
|
+
}
|
|
3710
|
+
console.log(`Moving files from ${sourcePath} to ${path.relative(process.cwd(), targetPath)}...`);
|
|
3711
|
+
await rename(absoluteSource, absoluteTarget);
|
|
3712
|
+
sourcePath = path.relative(process.cwd(), targetPath);
|
|
3713
|
+
}
|
|
3714
|
+
else if (options.dryRun && absoluteSource !== absoluteTarget) {
|
|
3715
|
+
console.log(`Dry run: would move files from ${sourcePath} to ${path.relative(process.cwd(), targetPath)}`);
|
|
3716
|
+
sourcePath = path.relative(process.cwd(), targetPath);
|
|
3717
|
+
}
|
|
3718
|
+
const untrackedFiles = new Set();
|
|
3719
|
+
const fullPath = absoluteSource !== absoluteTarget && !options.dryRun ? absoluteTarget : absoluteSource;
|
|
3720
|
+
await scanDirectoryOrFile(fullPath, untrackedFiles, state);
|
|
3721
|
+
filesToAdopt = Array.from(untrackedFiles);
|
|
3722
|
+
}
|
|
3723
|
+
else {
|
|
3724
|
+
throw new Error(`Source path not found: ${absoluteSource}`);
|
|
3725
|
+
}
|
|
3726
|
+
}
|
|
3659
3727
|
else if (identifier) {
|
|
3660
3728
|
const untrackedFiles = new Set();
|
|
3661
3729
|
// 1. Try as direct path
|