@eclipse-glsp/cli 2.7.0 → 2.8.0-next.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/cli.js CHANGED
@@ -13443,7 +13443,7 @@ var child = __toESM(require("child_process"));
13443
13443
  var path3 = __toESM(require("path"));
13444
13444
 
13445
13445
  // package.json
13446
- var version = "2.7.0";
13446
+ var version = "2.8.0-next";
13447
13447
 
13448
13448
  // src/util/logger.ts
13449
13449
  var levels = {
@@ -13646,6 +13646,30 @@ function commitChanges(message, path26) {
13646
13646
  function getChangesOfLastCommit(path26) {
13647
13647
  return exec("git diff --name-only HEAD^", { cwd: path26 }).split("\n").map((file) => (0, import_path.resolve)(path26 ?? process.cwd(), file));
13648
13648
  }
13649
+ function getChangesComparedToDefaultBranch(path26) {
13650
+ const baseRef = getDefaultBranchRef(path26);
13651
+ const committedChanges = baseRef ? exec(`git diff --name-only ${baseRef}...HEAD`, { cwd: path26, silent: true }).split("\n").filter((value) => value.trim().length !== 0).map((file) => (0, import_path.resolve)(path26 ?? process.cwd(), file.trim())) : [];
13652
+ return [.../* @__PURE__ */ new Set([...committedChanges, ...getUncommittedChanges(path26)])];
13653
+ }
13654
+ function getDefaultBranchRef(path26) {
13655
+ try {
13656
+ const ref = exec("git symbolic-ref --short refs/remotes/origin/HEAD", { cwd: path26, silent: true, fatal: false });
13657
+ if (ref) {
13658
+ return ref;
13659
+ }
13660
+ } catch {
13661
+ }
13662
+ const candidates = ["origin/main", "origin/master", "main", "master"];
13663
+ return candidates.find((ref) => refExists(ref, path26));
13664
+ }
13665
+ function refExists(ref, path26) {
13666
+ try {
13667
+ exec(`git rev-parse --verify --quiet ${ref}`, { cwd: path26, silent: true, fatal: false });
13668
+ return true;
13669
+ } catch {
13670
+ return false;
13671
+ }
13672
+ }
13649
13673
  function getLastModificationDate(filePath, repoRoot, excludeMessage) {
13650
13674
  const additionalArgs = excludeMessage ? `--grep="${excludeMessage}" --invert-grep` : "";
13651
13675
  try {
@@ -13896,7 +13920,7 @@ var AUTO_FIX_MESSAGE = "Fix copyright header violations";
13896
13920
  var CheckHeaderCommand = baseCommand().name("checkHeaders").description("Validates the copyright year range (end year) of license header files").argument("<rootDir>", "The starting directory for the check", validateGitDirectory).addOption(
13897
13921
  new Option(
13898
13922
  "-t, --type <type>",
13899
- "The scope of the check. In addition to a full recursive check, is also possible to only consider pending changes or the last commit"
13923
+ "The scope of the check. In addition to a full recursive check, it is also possible to only consider the files changed compared to the default branch (`changes`, incl. uncommitted changes - i.e. the files that would show up in a pull request) or the files changed with the last commit (`lastCommit`)"
13900
13924
  ).choices(checkTypes).default("full")
13901
13925
  ).option("-f, --fileExtensions <extensions...>", "File extensions that should be checked", ["ts", "tsx"]).addOption(
13902
13926
  new Option(
@@ -13933,7 +13957,7 @@ async function getFiles(rootDir, options) {
13933
13957
  });
13934
13958
  return resolveFiles(result2);
13935
13959
  }
13936
- let changedFiles = options.type === "changes" ? getUncommittedChanges(rootDir) : getChangesOfLastCommit(rootDir);
13960
+ let changedFiles = options.type === "changes" ? getChangesComparedToDefaultBranch(rootDir) : getChangesOfLastCommit(rootDir);
13937
13961
  changedFiles = changedFiles.filter(minimatch.filter(includePattern));
13938
13962
  excludePattern.forEach((pattern) => {
13939
13963
  changedFiles = changedFiles.filter(minimatch.filter(`!${pattern}`));
@@ -14732,6 +14756,14 @@ function resolveWorkspaceDir(cliDir) {
14732
14756
  }
14733
14757
  return process.cwd();
14734
14758
  }
14759
+ function resolveRepoDir(repo, cliDir) {
14760
+ const workspaceDir = resolveWorkspaceDir(cliDir);
14761
+ const repoDir = path11.resolve(workspaceDir, repo);
14762
+ if (!fs10.existsSync(repoDir) && path11.basename(workspaceDir) === repo) {
14763
+ return workspaceDir;
14764
+ }
14765
+ return repoDir;
14766
+ }
14735
14767
  function discoverRepos(dir) {
14736
14768
  if (!fs10.existsSync(dir)) {
14737
14769
  return [];
@@ -15479,16 +15511,14 @@ function resolveBundlePath(repoDir, relativePath, label) {
15479
15511
  var BrowserBundleCommand = baseCommand().name("browser-bundle").description("Print the absolute path to the browser (Web Worker) server bundle").option("-d, --dir <path>", "Target directory where repos are cloned").option("-v, --verbose", "Verbose output", false).action(async (_cmdOptions, thisCmd) => {
15480
15512
  const cli = thisCmd.opts();
15481
15513
  configureRepoEnv(cli);
15482
- const dir = resolveWorkspaceDir(cli.dir);
15483
- const repoDir = path20.resolve(dir, "glsp-server-node");
15514
+ const repoDir = resolveRepoDir("glsp-server-node", cli.dir);
15484
15515
  const bundlePath = resolveBundlePath(repoDir, BROWSER_BUNDLE_PATH, "Browser bundle");
15485
15516
  process.stdout.write(bundlePath);
15486
15517
  });
15487
15518
  var NodeBundleCommand = baseCommand().name("node-bundle").description("Print the absolute path to the Node.js server bundle").option("-d, --dir <path>", "Target directory where repos are cloned").option("-v, --verbose", "Verbose output", false).action(async (_cmdOptions, thisCmd) => {
15488
15519
  const cli = thisCmd.opts();
15489
15520
  configureRepoEnv(cli);
15490
- const dir = resolveWorkspaceDir(cli.dir);
15491
- const repoDir = path20.resolve(dir, "glsp-server-node");
15521
+ const repoDir = resolveRepoDir("glsp-server-node", cli.dir);
15492
15522
  const bundlePath = resolveBundlePath(repoDir, NODE_BUNDLE_PATH, "Node server bundle");
15493
15523
  process.stdout.write(bundlePath);
15494
15524
  });