@staff0rd/assist 0.147.0 → 0.147.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.
Files changed (2) hide show
  1. package/dist/index.js +34 -12
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import { Command } from "commander";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@staff0rd/assist",
9
- version: "0.147.0",
9
+ version: "0.147.1",
10
10
  type: "module",
11
11
  main: "dist/index.js",
12
12
  bin: {
@@ -7290,6 +7290,18 @@ async function applyExtraction(functionName, sourceFile, destPath, plan2, projec
7290
7290
  }
7291
7291
  updateImporters(functionName, sourceFile, plan2.importersToUpdate);
7292
7292
  if (plan2.barrel) {
7293
+ for (const decl of plan2.barrel.getExportDeclarations()) {
7294
+ const named = decl.getNamedExports();
7295
+ const match = named.find((n) => n.getName() === functionName);
7296
+ if (match) {
7297
+ if (named.length === 1) {
7298
+ decl.remove();
7299
+ } else {
7300
+ match.remove();
7301
+ }
7302
+ break;
7303
+ }
7304
+ }
7293
7305
  plan2.barrel.addExportDeclaration({
7294
7306
  moduleSpecifier: plan2.barrelRelPath,
7295
7307
  namedExports: [functionName]
@@ -7298,9 +7310,6 @@ async function applyExtraction(functionName, sourceFile, destPath, plan2, projec
7298
7310
  await project.save();
7299
7311
  }
7300
7312
 
7301
- // src/commands/refactor/extract/buildPlan.ts
7302
- import path29 from "path";
7303
-
7304
7313
  // src/commands/refactor/extract/collectDependencies.ts
7305
7314
  import {
7306
7315
  SyntaxKind as SyntaxKind5
@@ -7628,6 +7637,26 @@ function findImporters(functionName, sourceFile, destPath, project) {
7628
7637
  return result;
7629
7638
  }
7630
7639
 
7640
+ // src/commands/refactor/extract/resolveBarrel.ts
7641
+ import path29 from "path";
7642
+ function resolveBarrel(functionName, sourcePath, destPath, project) {
7643
+ const indexPath = path29.join(path29.dirname(destPath), "index.ts");
7644
+ const barrel = project.getSourceFile(indexPath);
7645
+ if (!barrel) return { barrel: void 0, barrelRelPath: "" };
7646
+ const sourceRelFromBarrel = getRelativeImportPath(indexPath, sourcePath);
7647
+ const alreadyExported = barrel.getExportDeclarations().some((decl) => {
7648
+ const specifier = decl.getModuleSpecifierValue();
7649
+ if (specifier !== sourceRelFromBarrel) return false;
7650
+ const named = decl.getNamedExports();
7651
+ return named.some((n) => n.getName() === functionName);
7652
+ });
7653
+ if (!alreadyExported) return { barrel: void 0, barrelRelPath: "" };
7654
+ return {
7655
+ barrel,
7656
+ barrelRelPath: getRelativeImportPath(indexPath, destPath)
7657
+ };
7658
+ }
7659
+
7631
7660
  // src/commands/refactor/extract/sourceReferencesName.ts
7632
7661
  import { SyntaxKind as SyntaxKind10 } from "ts-morph";
7633
7662
  var DECLARATION_KINDS = /* @__PURE__ */ new Set([
@@ -7660,13 +7689,6 @@ function sourceReferencesName(sourceFile, functionName, extractedNames) {
7660
7689
  }
7661
7690
 
7662
7691
  // src/commands/refactor/extract/buildPlan.ts
7663
- function resolveBarrel(destPath, project) {
7664
- const indexPath = path29.join(path29.dirname(destPath), "index.ts");
7665
- return {
7666
- barrel: project.getSourceFile(indexPath),
7667
- barrelRelPath: getRelativeImportPath(indexPath, destPath)
7668
- };
7669
- }
7670
7692
  function buildPlan(functionName, sourceFile, sourcePath, destPath, project) {
7671
7693
  const analysis = analyseTarget(sourceFile, functionName);
7672
7694
  const sourceRelPath = getRelativeImportPath(destPath, sourcePath);
@@ -7687,7 +7709,7 @@ function buildPlan(functionName, sourceFile, sourcePath, destPath, project) {
7687
7709
  analysis.extractedNames
7688
7710
  ),
7689
7711
  importersToUpdate: analysis.target.isExported() ? findImporters(functionName, sourceFile, destPath, project) : [],
7690
- ...resolveBarrel(destPath, project)
7712
+ ...resolveBarrel(functionName, sourcePath, destPath, project)
7691
7713
  };
7692
7714
  }
7693
7715
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@staff0rd/assist",
3
- "version": "0.147.0",
3
+ "version": "0.147.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {