@atlashub/smartstack-cli 2.6.1 → 2.6.3

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
@@ -124620,7 +124620,16 @@ function readPackageVersion(csprojContent, packageName) {
124620
124620
  const match2 = csprojContent.match(regex2);
124621
124621
  return match2 ? match2[1] : null;
124622
124622
  }
124623
- async function findProjectsWithSmartStack(projectDir) {
124623
+ function readAllPackageReferences(csprojContent) {
124624
+ const regex2 = /<PackageReference\s+Include="([^"]+)"\s+Version="([^"]+)"/gi;
124625
+ const packages = [];
124626
+ let match2;
124627
+ while ((match2 = regex2.exec(csprojContent)) !== null) {
124628
+ packages.push({ name: match2[1], currentVersion: match2[2] });
124629
+ }
124630
+ return packages;
124631
+ }
124632
+ async function findAllProjects(projectDir) {
124624
124633
  const srcDir = (0, import_path7.join)(projectDir, "src");
124625
124634
  if (!await import_fs_extra6.default.pathExists(srcDir)) {
124626
124635
  return [];
@@ -124636,13 +124645,11 @@ async function findProjectsWithSmartStack(projectDir) {
124636
124645
  const csprojPath = (0, import_path7.join)(folderPath, csproj);
124637
124646
  const content = await import_fs_extra6.default.readFile(csprojPath, "utf-8");
124638
124647
  const currentVersion = readPackageVersion(content, "SmartStack");
124639
- if (currentVersion !== null) {
124640
- projects.push({
124641
- csprojPath,
124642
- relPath: csprojPath.replace(projectDir, "").replace(/^[/\\]/, ""),
124643
- currentVersion
124644
- });
124645
- }
124648
+ projects.push({
124649
+ csprojPath,
124650
+ relPath: csprojPath.replace(projectDir, "").replace(/^[/\\]/, ""),
124651
+ currentVersion
124652
+ });
124646
124653
  }
124647
124654
  }
124648
124655
  }
@@ -124787,6 +124794,9 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
124787
124794
  nugetUpgraded: 0,
124788
124795
  nugetSkipped: 0,
124789
124796
  nugetFailed: 0,
124797
+ otherPkgUpdated: 0,
124798
+ otherPkgSkipped: 0,
124799
+ otherPkgFailed: 0,
124790
124800
  npmUpgraded: false,
124791
124801
  npmSkipped: false
124792
124802
  };
@@ -124821,42 +124831,95 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
124821
124831
  logger.success(`Latest npm version: ${source_default.cyan(npmVersion)}`);
124822
124832
  }
124823
124833
  console.log();
124824
- logger.info("Scanning for SmartStack projects...");
124825
- const projects = await findProjectsWithSmartStack(projectDir);
124826
- if (projects.length === 0) {
124827
- logger.warning("No .NET projects found with SmartStack PackageReference.");
124828
- logger.info('Tip: Ensure your .csproj files contain <PackageReference Include="SmartStack" Version="..." />');
124834
+ logger.info("Scanning for .NET projects...");
124835
+ const allProjects = await findAllProjects(projectDir);
124836
+ if (allProjects.length === 0) {
124837
+ logger.warning("No .NET projects found in src/ directory.");
124829
124838
  } else {
124830
- logger.info(`Found ${source_default.cyan(projects.length)} project(s):`);
124831
- for (const p of projects) {
124832
- const versionInfo = p.currentVersion ? `${source_default.yellow(p.currentVersion)} \u2192 ${source_default.cyan(nugetVersion)}` : source_default.gray("version unknown");
124833
- const upToDate = p.currentVersion === nugetVersion;
124834
- const statusIcon = upToDate ? source_default.green("\u2713") : source_default.yellow("\u2191");
124835
- logger.info(` ${statusIcon} ${p.relPath} (${upToDate ? source_default.green("up to date") : versionInfo})`);
124839
+ const smartStackProjects = allProjects.filter((p) => p.currentVersion !== null);
124840
+ const otherProjects = allProjects.filter((p) => p.currentVersion === null);
124841
+ if (smartStackProjects.length > 0) {
124842
+ logger.info(`Found ${source_default.cyan(smartStackProjects.length)} project(s) with SmartStack:`);
124843
+ for (const p of smartStackProjects) {
124844
+ const versionInfo = `${source_default.yellow(p.currentVersion)} \u2192 ${source_default.cyan(nugetVersion)}`;
124845
+ const upToDate = p.currentVersion === nugetVersion;
124846
+ const statusIcon = upToDate ? source_default.green("\u2713") : source_default.yellow("\u2191");
124847
+ logger.info(` ${statusIcon} ${p.relPath} (${upToDate ? source_default.green("up to date") : versionInfo})`);
124848
+ }
124849
+ }
124850
+ if (otherProjects.length > 0) {
124851
+ logger.info(`Found ${source_default.cyan(otherProjects.length)} other project(s):`);
124852
+ for (const p of otherProjects) {
124853
+ logger.info(` ${source_default.gray("\u25CB")} ${p.relPath}`);
124854
+ }
124836
124855
  }
124837
124856
  console.log();
124838
- const projectsToUpgrade = projects.filter((p) => p.currentVersion !== nugetVersion);
124839
- result.nugetSkipped = projects.length - projectsToUpgrade.length;
124840
- if (projectsToUpgrade.length === 0) {
124841
- logger.success(`All ${projects.length} project(s) already at ${source_default.cyan(nugetVersion)}`);
124842
- } else {
124843
- logger.info(`Upgrading ${projectsToUpgrade.length} project(s)...`);
124844
- for (const project of projectsToUpgrade) {
124845
- logger.info(`Upgrading ${source_default.cyan(project.relPath)}...`);
124857
+ if (smartStackProjects.length > 0) {
124858
+ const projectsToUpgrade = smartStackProjects.filter((p) => p.currentVersion !== nugetVersion);
124859
+ result.nugetSkipped = smartStackProjects.length - projectsToUpgrade.length;
124860
+ if (projectsToUpgrade.length === 0) {
124861
+ logger.success(`All ${smartStackProjects.length} SmartStack project(s) already at ${source_default.cyan(nugetVersion)}`);
124862
+ } else {
124863
+ logger.info(`Upgrading SmartStack in ${projectsToUpgrade.length} project(s)...`);
124864
+ for (const project of projectsToUpgrade) {
124865
+ logger.info(`Upgrading ${source_default.cyan(project.relPath)}...`);
124866
+ try {
124867
+ execCommand2(`dotnet add "${project.csprojPath}" package SmartStack --version ${nugetVersion}`, void 0, dryRun);
124868
+ result.nugetUpgraded++;
124869
+ } catch (error) {
124870
+ result.nugetFailed++;
124871
+ logger.error(`Failed to upgrade ${project.relPath}: ${error instanceof Error ? error.message : error}`);
124872
+ }
124873
+ }
124874
+ if (result.nugetUpgraded > 0) {
124875
+ logger.success(`${result.nugetUpgraded} project(s) upgraded to ${source_default.cyan(nugetVersion)}`);
124876
+ }
124877
+ if (result.nugetFailed > 0) {
124878
+ logger.error(`${result.nugetFailed} project(s) failed to upgrade`);
124879
+ }
124880
+ }
124881
+ console.log();
124882
+ }
124883
+ logger.info("Checking other NuGet packages...");
124884
+ for (const project of allProjects) {
124885
+ const content = await import_fs_extra6.default.readFile(project.csprojPath, "utf-8");
124886
+ const allPackages = readAllPackageReferences(content);
124887
+ const otherPackages = allPackages.filter((p) => p.name !== "SmartStack");
124888
+ if (otherPackages.length === 0) continue;
124889
+ logger.info(` ${source_default.cyan(project.relPath)}:`);
124890
+ for (const pkg2 of otherPackages) {
124846
124891
  try {
124847
- execCommand2(`dotnet add "${project.csprojPath}" package SmartStack --version ${nugetVersion}`, void 0, dryRun);
124848
- result.nugetUpgraded++;
124892
+ const output = dryRun ? `[DRY RUN] dotnet add "${project.csprojPath}" package ${pkg2.name}` : (0, import_child_process6.execSync)(
124893
+ `dotnet add "${project.csprojPath}" package ${pkg2.name}`,
124894
+ { shell: true, encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }
124895
+ );
124896
+ if (dryRun) {
124897
+ logger.info(` [DRY RUN] ${pkg2.name} ${source_default.yellow(pkg2.currentVersion)} \u2192 latest`);
124898
+ result.otherPkgUpdated++;
124899
+ continue;
124900
+ }
124901
+ const newContent = await import_fs_extra6.default.readFile(project.csprojPath, "utf-8");
124902
+ const newVersion = readPackageVersion(newContent, pkg2.name);
124903
+ if (newVersion && newVersion !== pkg2.currentVersion) {
124904
+ logger.success(` ${source_default.green("\u2713")} ${pkg2.name} ${source_default.yellow(pkg2.currentVersion)} \u2192 ${source_default.cyan(newVersion)}`);
124905
+ result.otherPkgUpdated++;
124906
+ } else {
124907
+ result.otherPkgSkipped++;
124908
+ }
124849
124909
  } catch (error) {
124850
- result.nugetFailed++;
124851
- logger.error(`Failed to upgrade ${project.relPath}: ${error instanceof Error ? error.message : error}`);
124910
+ result.otherPkgFailed++;
124911
+ logger.error(` ${source_default.red("\u2717")} ${pkg2.name}: ${error instanceof Error ? error.message : error}`);
124852
124912
  }
124853
124913
  }
124854
- if (result.nugetUpgraded > 0) {
124855
- logger.success(`${result.nugetUpgraded} project(s) upgraded to ${source_default.cyan(nugetVersion)}`);
124856
- }
124857
- if (result.nugetFailed > 0) {
124858
- logger.error(`${result.nugetFailed} project(s) failed to upgrade`);
124859
- }
124914
+ }
124915
+ if (result.otherPkgUpdated > 0) {
124916
+ logger.success(`${result.otherPkgUpdated} package(s) updated`);
124917
+ }
124918
+ if (result.otherPkgSkipped > 0) {
124919
+ logger.info(`${result.otherPkgSkipped} package(s) already at latest`);
124920
+ }
124921
+ if (result.otherPkgFailed > 0) {
124922
+ logger.error(`${result.otherPkgFailed} package(s) failed to update`);
124860
124923
  }
124861
124924
  console.log();
124862
124925
  }
@@ -124917,8 +124980,8 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
124917
124980
  logger.success(`Updated config version to ${source_default.cyan(nugetVersion)}`);
124918
124981
  console.log();
124919
124982
  }
124920
- const totalChanged = result.nugetUpgraded + (result.npmUpgraded ? 1 : 0) + migrationSummary.totalApplied;
124921
- const allUpToDate = totalChanged === 0 && result.nugetFailed === 0;
124983
+ const totalChanged = result.nugetUpgraded + result.otherPkgUpdated + (result.npmUpgraded ? 1 : 0) + migrationSummary.totalApplied;
124984
+ const allUpToDate = totalChanged === 0 && result.nugetFailed === 0 && result.otherPkgFailed === 0;
124922
124985
  if (allUpToDate) {
124923
124986
  const summary = [
124924
124987
  source_default.green.bold("Already up to date!"),
@@ -124926,7 +124989,7 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
124926
124989
  ` NuGet SmartStack: ${source_default.cyan(nugetVersion)}`,
124927
124990
  npmVersion ? ` npm @atlashub/smartstack: ${source_default.cyan(npmVersion)}` : "",
124928
124991
  "",
124929
- "No changes needed."
124992
+ "All packages at latest versions."
124930
124993
  ].filter(Boolean);
124931
124994
  logger.box(summary, "success");
124932
124995
  } else {
@@ -124935,13 +124998,19 @@ var upgradeCommand = new Command("upgrade").description("Upgrade SmartStack pack
124935
124998
  ""
124936
124999
  ];
124937
125000
  if (result.nugetUpgraded > 0) {
124938
- lines.push(` ${source_default.green("\u2713")} NuGet: ${result.nugetUpgraded} project(s) \u2192 ${source_default.cyan(nugetVersion)}`);
125001
+ lines.push(` ${source_default.green("\u2713")} SmartStack: ${result.nugetUpgraded} project(s) \u2192 ${source_default.cyan(nugetVersion)}`);
124939
125002
  }
124940
125003
  if (result.nugetSkipped > 0) {
124941
- lines.push(` ${source_default.gray("\u2013")} NuGet: ${result.nugetSkipped} project(s) already up to date`);
125004
+ lines.push(` ${source_default.gray("\u2013")} SmartStack: ${result.nugetSkipped} project(s) already up to date`);
124942
125005
  }
124943
125006
  if (result.nugetFailed > 0) {
124944
- lines.push(` ${source_default.red("\u2717")} NuGet: ${result.nugetFailed} project(s) failed`);
125007
+ lines.push(` ${source_default.red("\u2717")} SmartStack: ${result.nugetFailed} project(s) failed`);
125008
+ }
125009
+ if (result.otherPkgUpdated > 0) {
125010
+ lines.push(` ${source_default.green("\u2713")} Other NuGet: ${result.otherPkgUpdated} package(s) updated`);
125011
+ }
125012
+ if (result.otherPkgFailed > 0) {
125013
+ lines.push(` ${source_default.red("\u2717")} Other NuGet: ${result.otherPkgFailed} package(s) failed`);
124945
125014
  }
124946
125015
  if (result.npmUpgraded) {
124947
125016
  lines.push(` ${source_default.green("\u2713")} npm: @atlashub/smartstack \u2192 ${source_default.cyan(npmVersion)}`);