@oamm/textor 1.0.0 → 1.0.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/bin/textor.js +21 -12
- package/dist/bin/textor.js.map +1 -1
- package/dist/index.cjs +19 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/bin/textor.js
CHANGED
|
@@ -1728,8 +1728,12 @@ async function addSectionCommand(route, featurePath, options) {
|
|
|
1728
1728
|
featureImportPath = `${config.importAliases.features}/${normalizedFeaturePath}${entryPart}${config.naming.featureExtension}`;
|
|
1729
1729
|
} else {
|
|
1730
1730
|
const relativeFeatureFile = getRelativeImportPath(routeFilePath, featureFilePath);
|
|
1731
|
-
// Remove extension for import
|
|
1732
|
-
|
|
1731
|
+
// Remove extension for import if it's not an .astro file
|
|
1732
|
+
if (config.naming.featureExtension === '.astro') {
|
|
1733
|
+
featureImportPath = relativeFeatureFile;
|
|
1734
|
+
} else {
|
|
1735
|
+
featureImportPath = relativeFeatureFile.replace(/\.[^/.]+$/, '');
|
|
1736
|
+
}
|
|
1733
1737
|
}
|
|
1734
1738
|
|
|
1735
1739
|
let scriptImportPath;
|
|
@@ -2358,11 +2362,12 @@ async function moveSectionCommand(fromRoute, fromFeature, toRoute, toFeature, op
|
|
|
2358
2362
|
if (normalizedFromFeature !== targetFeature) {
|
|
2359
2363
|
const oldAliasPath = `${config.importAliases.features}/${normalizedFromFeature}`;
|
|
2360
2364
|
const newAliasPath = `${config.importAliases.features}/${targetFeature}`;
|
|
2365
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2361
2366
|
|
|
2362
2367
|
// Replace both the path and the component name if they are different
|
|
2363
2368
|
await updateSignature(toRoutePath,
|
|
2364
|
-
`import ${fromFeatureComponentName} from '${oldAliasPath}/${fromFeatureComponentName}'`,
|
|
2365
|
-
`import ${toFeatureComponentName} from '${newAliasPath}/${toFeatureComponentName}'`
|
|
2369
|
+
`import ${fromFeatureComponentName} from '${oldAliasPath}/${fromFeatureComponentName}${ext}'`,
|
|
2370
|
+
`import ${toFeatureComponentName} from '${newAliasPath}/${toFeatureComponentName}${ext}'`
|
|
2366
2371
|
);
|
|
2367
2372
|
|
|
2368
2373
|
// Fallback for prefix only replacement
|
|
@@ -2370,17 +2375,19 @@ async function moveSectionCommand(fromRoute, fromFeature, toRoute, toFeature, op
|
|
|
2370
2375
|
} else if (fromFeatureComponentName !== toFeatureComponentName) {
|
|
2371
2376
|
// Name changed but path didn't
|
|
2372
2377
|
const aliasPath = `${config.importAliases.features}/${targetFeature}`;
|
|
2378
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2373
2379
|
await updateSignature(toRoutePath,
|
|
2374
|
-
`import ${fromFeatureComponentName} from '${aliasPath}/${fromFeatureComponentName}'`,
|
|
2375
|
-
`import ${toFeatureComponentName} from '${aliasPath}/${toFeatureComponentName}'`
|
|
2380
|
+
`import ${fromFeatureComponentName} from '${aliasPath}/${fromFeatureComponentName}${ext}'`,
|
|
2381
|
+
`import ${toFeatureComponentName} from '${aliasPath}/${toFeatureComponentName}${ext}'`
|
|
2376
2382
|
);
|
|
2377
2383
|
}
|
|
2378
2384
|
} else {
|
|
2379
2385
|
const oldRelativeDir = getRelativeImportPath(fromRoutePath, fromFeatureDirPath);
|
|
2380
2386
|
const newRelativeDir = getRelativeImportPath(toRoutePath, toFeatureDirPath);
|
|
2387
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2381
2388
|
|
|
2382
|
-
const oldImportPath = `import ${fromFeatureComponentName} from '${oldRelativeDir}/${fromFeatureComponentName}'`;
|
|
2383
|
-
const newImportPath = `import ${toFeatureComponentName} from '${newRelativeDir}/${toFeatureComponentName}'`;
|
|
2389
|
+
const oldImportPath = `import ${fromFeatureComponentName} from '${oldRelativeDir}/${fromFeatureComponentName}${ext}'`;
|
|
2390
|
+
const newImportPath = `import ${toFeatureComponentName} from '${newRelativeDir}/${toFeatureComponentName}${ext}'`;
|
|
2384
2391
|
|
|
2385
2392
|
if (oldImportPath !== newImportPath) {
|
|
2386
2393
|
await updateSignature(toRoutePath, oldImportPath, newImportPath);
|
|
@@ -2470,14 +2477,16 @@ async function scanAndReplaceImports(config, state, fromInfo, toInfo, options) {
|
|
|
2470
2477
|
let content = await readFile(fullPath, 'utf-8');
|
|
2471
2478
|
let changed = false;
|
|
2472
2479
|
|
|
2480
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2481
|
+
|
|
2473
2482
|
// Handle Aliases
|
|
2474
2483
|
if (config.importAliases.features) {
|
|
2475
2484
|
const oldAlias = `${config.importAliases.features}/${fromFeaturePath}`;
|
|
2476
2485
|
const newAlias = `${config.importAliases.features}/${toFeaturePath}`;
|
|
2477
2486
|
|
|
2478
2487
|
// Update component name and path if both changed
|
|
2479
|
-
const oldFullImport = `from '${oldAlias}/${fromComponentName}'`;
|
|
2480
|
-
const newFullImport = `from '${newAlias}/${toComponentName}'`;
|
|
2488
|
+
const oldFullImport = `from '${oldAlias}/${fromComponentName}${ext}'`;
|
|
2489
|
+
const newFullImport = `from '${newAlias}/${toComponentName}${ext}'`;
|
|
2481
2490
|
|
|
2482
2491
|
if (content.includes(oldFullImport)) {
|
|
2483
2492
|
content = content.replace(new RegExp(oldFullImport.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), newFullImport);
|
|
@@ -2495,8 +2504,8 @@ async function scanAndReplaceImports(config, state, fromInfo, toInfo, options) {
|
|
|
2495
2504
|
const oldRelPath = getRelativeImportPath(fullPath, fromFeatureDir);
|
|
2496
2505
|
const newRelPath = getRelativeImportPath(fullPath, toFeatureDir);
|
|
2497
2506
|
|
|
2498
|
-
const oldImport = `'${oldRelPath}/${fromComponentName}'`;
|
|
2499
|
-
const newImport = `'${newRelPath}/${toComponentName}'`;
|
|
2507
|
+
const oldImport = `'${oldRelPath}/${fromComponentName}${ext}'`;
|
|
2508
|
+
const newImport = `'${newRelPath}/${toComponentName}${ext}'`;
|
|
2500
2509
|
|
|
2501
2510
|
if (content.includes(oldImport)) {
|
|
2502
2511
|
content = content.replace(new RegExp(oldImport.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), newImport);
|
package/dist/bin/textor.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textor.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textor.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.cjs
CHANGED
|
@@ -1528,8 +1528,13 @@ async function addSectionCommand(route, featurePath, options) {
|
|
|
1528
1528
|
}
|
|
1529
1529
|
else {
|
|
1530
1530
|
const relativeFeatureFile = getRelativeImportPath(routeFilePath, featureFilePath);
|
|
1531
|
-
// Remove extension for import
|
|
1532
|
-
|
|
1531
|
+
// Remove extension for import if it's not an .astro file
|
|
1532
|
+
if (config.naming.featureExtension === '.astro') {
|
|
1533
|
+
featureImportPath = relativeFeatureFile;
|
|
1534
|
+
}
|
|
1535
|
+
else {
|
|
1536
|
+
featureImportPath = relativeFeatureFile.replace(/\.[^/.]+$/, '');
|
|
1537
|
+
}
|
|
1533
1538
|
}
|
|
1534
1539
|
let scriptImportPath;
|
|
1535
1540
|
if (shouldCreateScriptsDir) {
|
|
@@ -2029,22 +2034,25 @@ async function moveSectionCommand(fromRoute, fromFeature, toRoute, toFeature, op
|
|
|
2029
2034
|
if (normalizedFromFeature !== targetFeature) {
|
|
2030
2035
|
const oldAliasPath = `${config.importAliases.features}/${normalizedFromFeature}`;
|
|
2031
2036
|
const newAliasPath = `${config.importAliases.features}/${targetFeature}`;
|
|
2037
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2032
2038
|
// Replace both the path and the component name if they are different
|
|
2033
|
-
await updateSignature(toRoutePath, `import ${fromFeatureComponentName} from '${oldAliasPath}/${fromFeatureComponentName}'`, `import ${toFeatureComponentName} from '${newAliasPath}/${toFeatureComponentName}'`);
|
|
2039
|
+
await updateSignature(toRoutePath, `import ${fromFeatureComponentName} from '${oldAliasPath}/${fromFeatureComponentName}${ext}'`, `import ${toFeatureComponentName} from '${newAliasPath}/${toFeatureComponentName}${ext}'`);
|
|
2034
2040
|
// Fallback for prefix only replacement
|
|
2035
2041
|
await updateSignature(toRoutePath, oldAliasPath, newAliasPath);
|
|
2036
2042
|
}
|
|
2037
2043
|
else if (fromFeatureComponentName !== toFeatureComponentName) {
|
|
2038
2044
|
// Name changed but path didn't
|
|
2039
2045
|
const aliasPath = `${config.importAliases.features}/${targetFeature}`;
|
|
2040
|
-
|
|
2046
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2047
|
+
await updateSignature(toRoutePath, `import ${fromFeatureComponentName} from '${aliasPath}/${fromFeatureComponentName}${ext}'`, `import ${toFeatureComponentName} from '${aliasPath}/${toFeatureComponentName}${ext}'`);
|
|
2041
2048
|
}
|
|
2042
2049
|
}
|
|
2043
2050
|
else {
|
|
2044
2051
|
const oldRelativeDir = getRelativeImportPath(fromRoutePath, fromFeatureDirPath);
|
|
2045
2052
|
const newRelativeDir = getRelativeImportPath(toRoutePath, toFeatureDirPath);
|
|
2046
|
-
const
|
|
2047
|
-
const
|
|
2053
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2054
|
+
const oldImportPath = `import ${fromFeatureComponentName} from '${oldRelativeDir}/${fromFeatureComponentName}${ext}'`;
|
|
2055
|
+
const newImportPath = `import ${toFeatureComponentName} from '${newRelativeDir}/${toFeatureComponentName}${ext}'`;
|
|
2048
2056
|
if (oldImportPath !== newImportPath) {
|
|
2049
2057
|
await updateSignature(toRoutePath, oldImportPath, newImportPath);
|
|
2050
2058
|
}
|
|
@@ -2117,13 +2125,14 @@ async function scanAndReplaceImports(config, state, fromInfo, toInfo, options) {
|
|
|
2117
2125
|
continue;
|
|
2118
2126
|
let content = await promises.readFile(fullPath, 'utf-8');
|
|
2119
2127
|
let changed = false;
|
|
2128
|
+
const ext = config.naming.featureExtension === '.astro' ? '.astro' : '';
|
|
2120
2129
|
// Handle Aliases
|
|
2121
2130
|
if (config.importAliases.features) {
|
|
2122
2131
|
const oldAlias = `${config.importAliases.features}/${fromFeaturePath}`;
|
|
2123
2132
|
const newAlias = `${config.importAliases.features}/${toFeaturePath}`;
|
|
2124
2133
|
// Update component name and path if both changed
|
|
2125
|
-
const oldFullImport = `from '${oldAlias}/${fromComponentName}'`;
|
|
2126
|
-
const newFullImport = `from '${newAlias}/${toComponentName}'`;
|
|
2134
|
+
const oldFullImport = `from '${oldAlias}/${fromComponentName}${ext}'`;
|
|
2135
|
+
const newFullImport = `from '${newAlias}/${toComponentName}${ext}'`;
|
|
2127
2136
|
if (content.includes(oldFullImport)) {
|
|
2128
2137
|
content = content.replace(new RegExp(oldFullImport.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), newFullImport);
|
|
2129
2138
|
changed = true;
|
|
@@ -2140,8 +2149,8 @@ async function scanAndReplaceImports(config, state, fromInfo, toInfo, options) {
|
|
|
2140
2149
|
const toFeatureDir = secureJoin(featuresRoot, toFeaturePath);
|
|
2141
2150
|
const oldRelPath = getRelativeImportPath(fullPath, fromFeatureDir);
|
|
2142
2151
|
const newRelPath = getRelativeImportPath(fullPath, toFeatureDir);
|
|
2143
|
-
const oldImport = `'${oldRelPath}/${fromComponentName}'`;
|
|
2144
|
-
const newImport = `'${newRelPath}/${toComponentName}'`;
|
|
2152
|
+
const oldImport = `'${oldRelPath}/${fromComponentName}${ext}'`;
|
|
2153
|
+
const newImport = `'${newRelPath}/${toComponentName}${ext}'`;
|
|
2145
2154
|
if (content.includes(oldImport)) {
|
|
2146
2155
|
content = content.replace(new RegExp(oldImport.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'), 'g'), newImport);
|
|
2147
2156
|
changed = true;
|