@postman-cse/onboarding-repo-sync 2.1.0 → 2.1.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/action.cjs CHANGED
@@ -122063,7 +122063,7 @@ function getIDToken(aud) {
122063
122063
  }
122064
122064
 
122065
122065
  // src/index.ts
122066
- var import_node_fs2 = require("node:fs");
122066
+ var import_node_fs3 = require("node:fs");
122067
122067
  var path8 = __toESM(require("node:path"), 1);
122068
122068
 
122069
122069
  // node_modules/js-yaml/dist/js-yaml.mjs
@@ -125366,6 +125366,7 @@ function getCiWorkflowTemplate(provider, options = {}) {
125366
125366
  }
125367
125367
 
125368
125368
  // src/lib/github/repo-mutation.ts
125369
+ var import_node_fs = require("node:fs");
125369
125370
  var import_node_path = __toESM(require("node:path"), 1);
125370
125371
 
125371
125372
  // src/lib/secrets.ts
@@ -125607,17 +125608,21 @@ function normalizeStagePaths(stagePaths) {
125607
125608
  if (hasControlCharacter(rawPath) || import_node_path.default.isAbsolute(stagePath) || import_node_path.default.win32.isAbsolute(stagePath) || segments.includes("..") || stagePath.startsWith(":") || hasControlCharacter(stagePath)) {
125608
125609
  throw new Error(`Unsafe git stage path: ${stagePath}`);
125609
125610
  }
125610
- normalized.push(stagePath);
125611
+ if (!normalized.includes(stagePath)) {
125612
+ normalized.push(stagePath);
125613
+ }
125611
125614
  }
125612
125615
  return normalized;
125613
125616
  }
125614
125617
  var RepoMutationService = class {
125618
+ cwd;
125615
125619
  execute;
125616
125620
  provider;
125617
125621
  repository;
125618
125622
  repoUrl;
125619
125623
  secretMasker;
125620
125624
  constructor(options) {
125625
+ this.cwd = options.cwd ?? process.cwd();
125621
125626
  this.execute = options.execute;
125622
125627
  this.provider = options.provider ?? "github";
125623
125628
  this.repository = options.repository;
@@ -125626,7 +125631,8 @@ var RepoMutationService = class {
125626
125631
  }
125627
125632
  async commitAndPush(options) {
125628
125633
  const resolvedCurrentRef = resolveCurrentRef(options);
125629
- const stagePaths = normalizeStagePaths(options.stagePaths);
125634
+ const removePaths = normalizeStagePaths(options.removePaths ?? []);
125635
+ const stagePaths = normalizeStagePaths([...options.stagePaths, ...removePaths]);
125630
125636
  const tokens = this.provider === "azure-devops" ? buildPushTokenOrder({ adoToken: options.adoToken }) : buildPushTokenOrder({
125631
125637
  fallbackToken: options.fallbackToken,
125632
125638
  githubToken: options.githubToken
@@ -125639,8 +125645,43 @@ var RepoMutationService = class {
125639
125645
  resolvedCurrentRef
125640
125646
  };
125641
125647
  }
125648
+ const changed = await this.execute("git", [
125649
+ "status",
125650
+ "--porcelain=v1",
125651
+ "--untracked-files=all",
125652
+ "--",
125653
+ ...stagePaths
125654
+ ]);
125655
+ if (changed.exitCode !== 0) {
125656
+ throw new Error(this.secretMasker(changed.stderr || changed.stdout || "Failed to inspect generated changes"));
125657
+ }
125658
+ const hasPlannedRemoval = removePaths.some(
125659
+ (removePath) => (0, import_node_fs.existsSync)(import_node_path.default.resolve(this.cwd, removePath))
125660
+ );
125661
+ if (!changed.stdout.trim() && !hasPlannedRemoval) {
125662
+ return {
125663
+ commitSha: "",
125664
+ pushed: false,
125665
+ resolvedCurrentRef
125666
+ };
125667
+ }
125668
+ const usePersistedCredentials = tokens.length === 0 && this.provider === "azure-devops";
125669
+ if (options.repoWriteMode === "commit-and-push") {
125670
+ if (!supportsTokenRemote(this.provider)) {
125671
+ throw new Error(`repo-write-mode=commit-and-push is not supported for git provider "${this.provider}"`);
125672
+ }
125673
+ if (!resolvedCurrentRef) {
125674
+ throw new Error("No current ref could be resolved for repo-write-mode=commit-and-push");
125675
+ }
125676
+ if (tokens.length === 0 && !usePersistedCredentials) {
125677
+ throw new Error("No push token configured for repo-write-mode=commit-and-push");
125678
+ }
125679
+ }
125642
125680
  await this.execute("git", ["config", "user.name", options.committerName]);
125643
125681
  await this.execute("git", ["config", "user.email", options.committerEmail]);
125682
+ for (const removePath of removePaths) {
125683
+ (0, import_node_fs.rmSync)(import_node_path.default.resolve(this.cwd, removePath), { force: true });
125684
+ }
125644
125685
  await this.execute("git", ["add", "-A", "--", ...stagePaths]);
125645
125686
  const staged = await this.execute("git", ["diff", "--cached", "--quiet"]);
125646
125687
  if (staged.exitCode === 0) {
@@ -125663,16 +125704,6 @@ var RepoMutationService = class {
125663
125704
  resolvedCurrentRef
125664
125705
  };
125665
125706
  }
125666
- if (!resolvedCurrentRef) {
125667
- throw new Error("No current ref could be resolved for repo-write-mode=commit-and-push");
125668
- }
125669
- const usePersistedCredentials = tokens.length === 0 && this.provider === "azure-devops";
125670
- if (tokens.length === 0 && !usePersistedCredentials) {
125671
- throw new Error("No push token configured for repo-write-mode=commit-and-push");
125672
- }
125673
- if (tokens.length > 0 && !supportsTokenRemote(this.provider)) {
125674
- throw new Error(`repo-write-mode=commit-and-push is not supported for git provider "${this.provider}"`);
125675
- }
125676
125707
  const originalRemote = (await this.execute("git", ["remote", "get-url", "origin"])).stdout.trim();
125677
125708
  let pushed = false;
125678
125709
  let lastError = "";
@@ -126192,11 +126223,11 @@ function createTelemetryContext(options) {
126192
126223
  }
126193
126224
 
126194
126225
  // src/action-version.ts
126195
- var import_node_fs = require("node:fs");
126226
+ var import_node_fs2 = require("node:fs");
126196
126227
  var import_node_path2 = require("node:path");
126197
126228
  function resolveActionVersion2() {
126198
126229
  try {
126199
- const raw = (0, import_node_fs.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
126230
+ const raw = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
126200
126231
  return JSON.parse(raw).version ?? "unknown";
126201
126232
  } catch {
126202
126233
  return "unknown";
@@ -127951,8 +127982,27 @@ function normalizeInputValue(value) {
127951
127982
  return String(value ?? "").trim();
127952
127983
  }
127953
127984
  function getInput2(name, env = process.env) {
127954
- const envName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
127955
- return normalizeInputValue(env[envName]);
127985
+ const normalizedName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
127986
+ const runnerName = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
127987
+ const normalizedRaw = env[normalizedName];
127988
+ const runnerRaw = runnerName === normalizedName ? void 0 : env[runnerName];
127989
+ const hasNormalized = normalizedRaw !== void 0;
127990
+ const hasRunner = runnerRaw !== void 0;
127991
+ if (hasNormalized && hasRunner) {
127992
+ const normalizedValue = normalizeInputValue(normalizedRaw);
127993
+ const runnerValue = normalizeInputValue(runnerRaw);
127994
+ if (normalizedValue !== runnerValue) {
127995
+ throw new Error(
127996
+ `Conflicting values for ${name}: ${normalizedName}=${JSON.stringify(normalizedValue)} vs ${runnerName}=${JSON.stringify(runnerValue)}`
127997
+ );
127998
+ }
127999
+ }
128000
+ return normalizeInputValue(hasNormalized ? normalizedRaw : runnerRaw);
128001
+ }
128002
+ function hasInput(name, env = process.env) {
128003
+ const normalizedName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
128004
+ const runnerName = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
128005
+ return env[normalizedName] !== void 0 || runnerName !== normalizedName && env[runnerName] !== void 0;
127956
128006
  }
127957
128007
  function parseJsonMap(raw) {
127958
128008
  if (!raw.trim()) return {};
@@ -127982,7 +128032,9 @@ function normalizeRepoWriteMode(value) {
127982
128032
  if (value === "none" || value === "commit-only" || value === "commit-and-push") {
127983
128033
  return value;
127984
128034
  }
127985
- return "commit-and-push";
128035
+ throw new Error(
128036
+ `Unsupported repo-write-mode "${value}". Allowed values: none, commit-only, commit-and-push`
128037
+ );
127986
128038
  }
127987
128039
  function normalizeCollectionSyncMode(value) {
127988
128040
  if (value === "refresh" || value === "version") {
@@ -128064,7 +128116,7 @@ function resolveInputs(env = process.env) {
128064
128116
  environmentUids,
128065
128117
  envRuntimeUrls,
128066
128118
  artifactDir: getInput2("artifact-dir", env) || "postman",
128067
- repoWriteMode: normalizeRepoWriteMode(getInput2("repo-write-mode", env) || "commit-and-push"),
128119
+ repoWriteMode: hasInput("repo-write-mode", env) ? normalizeRepoWriteMode(getInput2("repo-write-mode", env)) : "commit-and-push",
128068
128120
  currentRef: getInput2("current-ref", env) || normalizeInputValue(env.GITHUB_REF) || normalizeInputValue(env.BUILD_SOURCEBRANCH),
128069
128121
  githubHeadRef: getInput2("github-head-ref", env) || normalizeInputValue(env.GITHUB_HEAD_REF) || normalizeInputValue(env.SYSTEM_PULLREQUEST_SOURCEBRANCH),
128070
128122
  githubRefName: getInput2("github-ref-name", env) || normalizeInputValue(env.GITHUB_REF_NAME) || normalizeInputValue(repoContext.ref),
@@ -128113,7 +128165,7 @@ function buildEnvironmentValues(envName, baseUrl) {
128113
128165
  var LEGACY_BASELINE_COLLECTION_PREFIX = "[Baseline]";
128114
128166
  function readResourcesState() {
128115
128167
  try {
128116
- return load((0, import_node_fs2.readFileSync)(".postman/resources.yaml", "utf8"));
128168
+ return load((0, import_node_fs3.readFileSync)(".postman/resources.yaml", "utf8"));
128117
128169
  } catch {
128118
128170
  return null;
128119
128171
  }
@@ -128151,7 +128203,7 @@ function isOpenApiSpecFile(filePath) {
128151
128203
  return false;
128152
128204
  }
128153
128205
  try {
128154
- const raw = (0, import_node_fs2.readFileSync)(filePath, "utf8");
128206
+ const raw = (0, import_node_fs3.readFileSync)(filePath, "utf8");
128155
128207
  const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
128156
128208
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
128157
128209
  return false;
@@ -128180,7 +128232,7 @@ function scanLocalSpecReferences(baseDir = ".") {
128180
128232
  const found = /* @__PURE__ */ new Set();
128181
128233
  const refs = [];
128182
128234
  const visit2 = (currentDir) => {
128183
- for (const entry of (0, import_node_fs2.readdirSync)(currentDir, { withFileTypes: true })) {
128235
+ for (const entry of (0, import_node_fs3.readdirSync)(currentDir, { withFileTypes: true })) {
128184
128236
  if (ignoredDirs.has(entry.name)) {
128185
128237
  continue;
128186
128238
  }
@@ -128210,7 +128262,7 @@ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
128210
128262
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
128211
128263
  if (normalizedExplicitPath) {
128212
128264
  const explicitFullPath = path8.resolve(normalizedExplicitPath);
128213
- if ((0, import_node_fs2.existsSync)(explicitFullPath) && (0, import_node_fs2.statSync)(explicitFullPath).isFile()) {
128265
+ if ((0, import_node_fs3.existsSync)(explicitFullPath) && (0, import_node_fs3.statSync)(explicitFullPath).isFile()) {
128214
128266
  return {
128215
128267
  repoRelativePath: normalizedExplicitPath,
128216
128268
  configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
@@ -128425,7 +128477,7 @@ async function upsertEnvironments(inputs, dependencies, resourcesState) {
128425
128477
  return envUids;
128426
128478
  }
128427
128479
  function ensureDir(path9) {
128428
- (0, import_node_fs2.mkdirSync)(path9, { recursive: true });
128480
+ (0, import_node_fs3.mkdirSync)(path9, { recursive: true });
128429
128481
  }
128430
128482
  function getCollectionDirectoryName(kind, projectName) {
128431
128483
  if (kind === "Baseline") {
@@ -128462,7 +128514,7 @@ function stripVolatileFields(obj) {
128462
128514
  }
128463
128515
  function writeJsonFile(path9, content, normalize3 = false) {
128464
128516
  const data = normalize3 ? stripVolatileFields(content) : content;
128465
- (0, import_node_fs2.writeFileSync)(path9, JSON.stringify(data, null, 2));
128517
+ (0, import_node_fs3.writeFileSync)(path9, JSON.stringify(data, null, 2));
128466
128518
  }
128467
128519
  function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir, localSpecRefs, mappedSpecRef, specId) {
128468
128520
  const manifest = {
@@ -128536,21 +128588,21 @@ function assertPathWithinCwd(targetPath, fieldName) {
128536
128588
  if (!rawPath || hasControlCharacter2(originalPath) || path8.isAbsolute(rawPath) || path8.win32.isAbsolute(rawPath) || segments.includes("..") || rawPath.startsWith(":") || hasControlCharacter2(rawPath)) {
128537
128589
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
128538
128590
  }
128539
- const base = (0, import_node_fs2.realpathSync)(process.cwd());
128591
+ const base = (0, import_node_fs3.realpathSync)(process.cwd());
128540
128592
  const resolved = path8.resolve(base, rawPath);
128541
128593
  const relative3 = path8.relative(base, resolved);
128542
128594
  if (relative3.startsWith("..") || path8.isAbsolute(relative3)) {
128543
128595
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
128544
128596
  }
128545
128597
  let existingPath = resolved;
128546
- while (!(0, import_node_fs2.existsSync)(existingPath)) {
128598
+ while (!(0, import_node_fs3.existsSync)(existingPath)) {
128547
128599
  const parent = path8.dirname(existingPath);
128548
128600
  if (parent === existingPath) {
128549
128601
  break;
128550
128602
  }
128551
128603
  existingPath = parent;
128552
128604
  }
128553
- const realExistingPath = (0, import_node_fs2.realpathSync)(existingPath);
128605
+ const realExistingPath = (0, import_node_fs3.realpathSync)(existingPath);
128554
128606
  const realRelative = path8.relative(base, realExistingPath);
128555
128607
  if (realRelative.startsWith("..") || path8.isAbsolute(realRelative)) {
128556
128608
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
@@ -128578,8 +128630,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
128578
128630
  ensureDir(specsDir);
128579
128631
  ensureDir(".postman");
128580
128632
  const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
128581
- if (!(0, import_node_fs2.existsSync)(globalsFilePath)) {
128582
- (0, import_node_fs2.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
128633
+ if (!(0, import_node_fs3.existsSync)(globalsFilePath)) {
128634
+ (0, import_node_fs3.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
128583
128635
  }
128584
128636
  if (inputs.generateCiWorkflow) {
128585
128637
  const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
@@ -128615,7 +128667,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
128615
128667
  true
128616
128668
  );
128617
128669
  }
128618
- (0, import_node_fs2.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
128670
+ (0, import_node_fs3.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
128619
128671
  inputs.workspaceId,
128620
128672
  manifestCollections,
128621
128673
  envUids,
@@ -128625,7 +128677,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
128625
128677
  inputs.specId || void 0
128626
128678
  ));
128627
128679
  if (mappedSpec && Object.keys(manifestCollections).length > 0) {
128628
- (0, import_node_fs2.writeFileSync)(
128680
+ (0, import_node_fs3.writeFileSync)(
128629
128681
  ".postman/workflows.yaml",
128630
128682
  buildSpecCollectionWorkflowManifest(
128631
128683
  mappedSpec.configRelativePath,
@@ -128662,29 +128714,27 @@ function createRepoSummary(outputs, envUids, pushed) {
128662
128714
  });
128663
128715
  }
128664
128716
  async function commitAndPushGeneratedFiles(inputs, dependencies) {
128665
- if (!dependencies.repoMutation || inputs.repoWriteMode === "none") {
128666
- return { commitSha: "", resolvedCurrentRef: "", pushed: false };
128667
- }
128668
128717
  if (inputs.generateCiWorkflow) {
128718
+ assertPathWithinCwd(inputs.ciWorkflowPath, "ci-workflow-path");
128669
128719
  const ciWorkflow = renderCiWorkflow(inputs);
128670
128720
  const parts = inputs.ciWorkflowPath.split("/");
128671
128721
  if (parts.length > 1) {
128672
128722
  const dir = parts.slice(0, -1).join("/");
128673
128723
  ensureDir(dir);
128674
128724
  }
128675
- (0, import_node_fs2.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
128725
+ (0, import_node_fs3.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
128676
128726
  }
128677
- const provisionPath = ".github/workflows/provision.yml";
128678
- const provisionExists = inputs.provider === "github" && (0, import_node_fs2.existsSync)(provisionPath);
128679
- if (provisionExists) {
128680
- (0, import_node_fs2.rmSync)(provisionPath);
128727
+ if (!dependencies.repoMutation || inputs.repoWriteMode === "none") {
128728
+ return { commitSha: "", resolvedCurrentRef: "", pushed: false };
128681
128729
  }
128730
+ const provisionPath = ".github/workflows/provision.yml";
128731
+ const provisionExists = inputs.provider === "github" && (0, import_node_fs3.existsSync)(provisionPath);
128682
128732
  const stagePaths = [
128683
128733
  inputs.artifactDir,
128684
128734
  ".postman",
128685
128735
  inputs.generateCiWorkflow ? inputs.ciWorkflowPath : null,
128686
128736
  provisionExists ? provisionPath : null
128687
- ].filter((entry) => typeof entry === "string" && ((0, import_node_fs2.existsSync)(entry) || entry === provisionPath));
128737
+ ].filter((entry) => typeof entry === "string" && ((0, import_node_fs3.existsSync)(entry) || entry === provisionPath));
128688
128738
  if (stagePaths.length === 0) {
128689
128739
  dependencies.core.info("No generated repository paths were found; skipping repo mutation.");
128690
128740
  return {
@@ -128708,6 +128758,7 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
128708
128758
  adoToken: inputs.provider === "azure-devops" ? inputs.adoToken : void 0,
128709
128759
  githubToken: inputs.provider === "azure-devops" ? void 0 : inputs.githubToken,
128710
128760
  fallbackToken: inputs.provider === "azure-devops" ? void 0 : inputs.ghFallbackToken,
128761
+ removePaths: provisionExists ? [provisionPath] : [],
128711
128762
  stagePaths
128712
128763
  });
128713
128764
  return {
package/dist/cli.cjs CHANGED
@@ -1,3 +1,4 @@
1
+ #!/usr/bin/env node
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -119797,7 +119798,7 @@ __export(cli_exports, {
119797
119798
  });
119798
119799
  module.exports = __toCommonJS(cli_exports);
119799
119800
  var import_node_child_process = require("node:child_process");
119800
- var import_node_fs3 = require("node:fs");
119801
+ var import_node_fs4 = require("node:fs");
119801
119802
  var import_promises = require("node:fs/promises");
119802
119803
  var import_node_path3 = __toESM(require("node:path"), 1);
119803
119804
  var import_node_util = require("node:util");
@@ -120165,7 +120166,7 @@ var ExitCode;
120165
120166
  })(ExitCode || (ExitCode = {}));
120166
120167
 
120167
120168
  // src/index.ts
120168
- var import_node_fs2 = require("node:fs");
120169
+ var import_node_fs3 = require("node:fs");
120169
120170
  var path3 = __toESM(require("node:path"), 1);
120170
120171
 
120171
120172
  // node_modules/js-yaml/dist/js-yaml.mjs
@@ -123468,6 +123469,7 @@ function getCiWorkflowTemplate(provider, options = {}) {
123468
123469
  }
123469
123470
 
123470
123471
  // src/lib/github/repo-mutation.ts
123472
+ var import_node_fs = require("node:fs");
123471
123473
  var import_node_path = __toESM(require("node:path"), 1);
123472
123474
 
123473
123475
  // src/lib/secrets.ts
@@ -123709,17 +123711,21 @@ function normalizeStagePaths(stagePaths) {
123709
123711
  if (hasControlCharacter(rawPath) || import_node_path.default.isAbsolute(stagePath) || import_node_path.default.win32.isAbsolute(stagePath) || segments.includes("..") || stagePath.startsWith(":") || hasControlCharacter(stagePath)) {
123710
123712
  throw new Error(`Unsafe git stage path: ${stagePath}`);
123711
123713
  }
123712
- normalized.push(stagePath);
123714
+ if (!normalized.includes(stagePath)) {
123715
+ normalized.push(stagePath);
123716
+ }
123713
123717
  }
123714
123718
  return normalized;
123715
123719
  }
123716
123720
  var RepoMutationService = class {
123721
+ cwd;
123717
123722
  execute;
123718
123723
  provider;
123719
123724
  repository;
123720
123725
  repoUrl;
123721
123726
  secretMasker;
123722
123727
  constructor(options) {
123728
+ this.cwd = options.cwd ?? process.cwd();
123723
123729
  this.execute = options.execute;
123724
123730
  this.provider = options.provider ?? "github";
123725
123731
  this.repository = options.repository;
@@ -123728,7 +123734,8 @@ var RepoMutationService = class {
123728
123734
  }
123729
123735
  async commitAndPush(options) {
123730
123736
  const resolvedCurrentRef = resolveCurrentRef(options);
123731
- const stagePaths = normalizeStagePaths(options.stagePaths);
123737
+ const removePaths = normalizeStagePaths(options.removePaths ?? []);
123738
+ const stagePaths = normalizeStagePaths([...options.stagePaths, ...removePaths]);
123732
123739
  const tokens = this.provider === "azure-devops" ? buildPushTokenOrder({ adoToken: options.adoToken }) : buildPushTokenOrder({
123733
123740
  fallbackToken: options.fallbackToken,
123734
123741
  githubToken: options.githubToken
@@ -123741,8 +123748,43 @@ var RepoMutationService = class {
123741
123748
  resolvedCurrentRef
123742
123749
  };
123743
123750
  }
123751
+ const changed = await this.execute("git", [
123752
+ "status",
123753
+ "--porcelain=v1",
123754
+ "--untracked-files=all",
123755
+ "--",
123756
+ ...stagePaths
123757
+ ]);
123758
+ if (changed.exitCode !== 0) {
123759
+ throw new Error(this.secretMasker(changed.stderr || changed.stdout || "Failed to inspect generated changes"));
123760
+ }
123761
+ const hasPlannedRemoval = removePaths.some(
123762
+ (removePath) => (0, import_node_fs.existsSync)(import_node_path.default.resolve(this.cwd, removePath))
123763
+ );
123764
+ if (!changed.stdout.trim() && !hasPlannedRemoval) {
123765
+ return {
123766
+ commitSha: "",
123767
+ pushed: false,
123768
+ resolvedCurrentRef
123769
+ };
123770
+ }
123771
+ const usePersistedCredentials = tokens.length === 0 && this.provider === "azure-devops";
123772
+ if (options.repoWriteMode === "commit-and-push") {
123773
+ if (!supportsTokenRemote(this.provider)) {
123774
+ throw new Error(`repo-write-mode=commit-and-push is not supported for git provider "${this.provider}"`);
123775
+ }
123776
+ if (!resolvedCurrentRef) {
123777
+ throw new Error("No current ref could be resolved for repo-write-mode=commit-and-push");
123778
+ }
123779
+ if (tokens.length === 0 && !usePersistedCredentials) {
123780
+ throw new Error("No push token configured for repo-write-mode=commit-and-push");
123781
+ }
123782
+ }
123744
123783
  await this.execute("git", ["config", "user.name", options.committerName]);
123745
123784
  await this.execute("git", ["config", "user.email", options.committerEmail]);
123785
+ for (const removePath of removePaths) {
123786
+ (0, import_node_fs.rmSync)(import_node_path.default.resolve(this.cwd, removePath), { force: true });
123787
+ }
123746
123788
  await this.execute("git", ["add", "-A", "--", ...stagePaths]);
123747
123789
  const staged = await this.execute("git", ["diff", "--cached", "--quiet"]);
123748
123790
  if (staged.exitCode === 0) {
@@ -123765,16 +123807,6 @@ var RepoMutationService = class {
123765
123807
  resolvedCurrentRef
123766
123808
  };
123767
123809
  }
123768
- if (!resolvedCurrentRef) {
123769
- throw new Error("No current ref could be resolved for repo-write-mode=commit-and-push");
123770
- }
123771
- const usePersistedCredentials = tokens.length === 0 && this.provider === "azure-devops";
123772
- if (tokens.length === 0 && !usePersistedCredentials) {
123773
- throw new Error("No push token configured for repo-write-mode=commit-and-push");
123774
- }
123775
- if (tokens.length > 0 && !supportsTokenRemote(this.provider)) {
123776
- throw new Error(`repo-write-mode=commit-and-push is not supported for git provider "${this.provider}"`);
123777
- }
123778
123810
  const originalRemote = (await this.execute("git", ["remote", "get-url", "origin"])).stdout.trim();
123779
123811
  let pushed = false;
123780
123812
  let lastError = "";
@@ -124294,11 +124326,11 @@ function createTelemetryContext(options) {
124294
124326
  }
124295
124327
 
124296
124328
  // src/action-version.ts
124297
- var import_node_fs = require("node:fs");
124329
+ var import_node_fs2 = require("node:fs");
124298
124330
  var import_node_path2 = require("node:path");
124299
124331
  function resolveActionVersion2() {
124300
124332
  try {
124301
- const raw = (0, import_node_fs.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
124333
+ const raw = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
124302
124334
  return JSON.parse(raw).version ?? "unknown";
124303
124335
  } catch {
124304
124336
  return "unknown";
@@ -126001,8 +126033,27 @@ function normalizeInputValue(value) {
126001
126033
  return String(value ?? "").trim();
126002
126034
  }
126003
126035
  function getInput(name, env = process.env) {
126004
- const envName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
126005
- return normalizeInputValue(env[envName]);
126036
+ const normalizedName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
126037
+ const runnerName = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
126038
+ const normalizedRaw = env[normalizedName];
126039
+ const runnerRaw = runnerName === normalizedName ? void 0 : env[runnerName];
126040
+ const hasNormalized = normalizedRaw !== void 0;
126041
+ const hasRunner = runnerRaw !== void 0;
126042
+ if (hasNormalized && hasRunner) {
126043
+ const normalizedValue = normalizeInputValue(normalizedRaw);
126044
+ const runnerValue = normalizeInputValue(runnerRaw);
126045
+ if (normalizedValue !== runnerValue) {
126046
+ throw new Error(
126047
+ `Conflicting values for ${name}: ${normalizedName}=${JSON.stringify(normalizedValue)} vs ${runnerName}=${JSON.stringify(runnerValue)}`
126048
+ );
126049
+ }
126050
+ }
126051
+ return normalizeInputValue(hasNormalized ? normalizedRaw : runnerRaw);
126052
+ }
126053
+ function hasInput(name, env = process.env) {
126054
+ const normalizedName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
126055
+ const runnerName = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
126056
+ return env[normalizedName] !== void 0 || runnerName !== normalizedName && env[runnerName] !== void 0;
126006
126057
  }
126007
126058
  function parseJsonMap(raw) {
126008
126059
  if (!raw.trim()) return {};
@@ -126029,7 +126080,9 @@ function normalizeRepoWriteMode(value) {
126029
126080
  if (value === "none" || value === "commit-only" || value === "commit-and-push") {
126030
126081
  return value;
126031
126082
  }
126032
- return "commit-and-push";
126083
+ throw new Error(
126084
+ `Unsupported repo-write-mode "${value}". Allowed values: none, commit-only, commit-and-push`
126085
+ );
126033
126086
  }
126034
126087
  function normalizeCollectionSyncMode(value) {
126035
126088
  if (value === "refresh" || value === "version") {
@@ -126111,7 +126164,7 @@ function resolveInputs(env = process.env) {
126111
126164
  environmentUids,
126112
126165
  envRuntimeUrls,
126113
126166
  artifactDir: getInput("artifact-dir", env) || "postman",
126114
- repoWriteMode: normalizeRepoWriteMode(getInput("repo-write-mode", env) || "commit-and-push"),
126167
+ repoWriteMode: hasInput("repo-write-mode", env) ? normalizeRepoWriteMode(getInput("repo-write-mode", env)) : "commit-and-push",
126115
126168
  currentRef: getInput("current-ref", env) || normalizeInputValue(env.GITHUB_REF) || normalizeInputValue(env.BUILD_SOURCEBRANCH),
126116
126169
  githubHeadRef: getInput("github-head-ref", env) || normalizeInputValue(env.GITHUB_HEAD_REF) || normalizeInputValue(env.SYSTEM_PULLREQUEST_SOURCEBRANCH),
126117
126170
  githubRefName: getInput("github-ref-name", env) || normalizeInputValue(env.GITHUB_REF_NAME) || normalizeInputValue(repoContext.ref),
@@ -126160,7 +126213,7 @@ function buildEnvironmentValues(envName, baseUrl) {
126160
126213
  var LEGACY_BASELINE_COLLECTION_PREFIX = "[Baseline]";
126161
126214
  function readResourcesState() {
126162
126215
  try {
126163
- return load((0, import_node_fs2.readFileSync)(".postman/resources.yaml", "utf8"));
126216
+ return load((0, import_node_fs3.readFileSync)(".postman/resources.yaml", "utf8"));
126164
126217
  } catch {
126165
126218
  return null;
126166
126219
  }
@@ -126198,7 +126251,7 @@ function isOpenApiSpecFile(filePath) {
126198
126251
  return false;
126199
126252
  }
126200
126253
  try {
126201
- const raw = (0, import_node_fs2.readFileSync)(filePath, "utf8");
126254
+ const raw = (0, import_node_fs3.readFileSync)(filePath, "utf8");
126202
126255
  const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
126203
126256
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
126204
126257
  return false;
@@ -126227,7 +126280,7 @@ function scanLocalSpecReferences(baseDir = ".") {
126227
126280
  const found = /* @__PURE__ */ new Set();
126228
126281
  const refs = [];
126229
126282
  const visit2 = (currentDir) => {
126230
- for (const entry of (0, import_node_fs2.readdirSync)(currentDir, { withFileTypes: true })) {
126283
+ for (const entry of (0, import_node_fs3.readdirSync)(currentDir, { withFileTypes: true })) {
126231
126284
  if (ignoredDirs.has(entry.name)) {
126232
126285
  continue;
126233
126286
  }
@@ -126257,7 +126310,7 @@ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
126257
126310
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
126258
126311
  if (normalizedExplicitPath) {
126259
126312
  const explicitFullPath = path3.resolve(normalizedExplicitPath);
126260
- if ((0, import_node_fs2.existsSync)(explicitFullPath) && (0, import_node_fs2.statSync)(explicitFullPath).isFile()) {
126313
+ if ((0, import_node_fs3.existsSync)(explicitFullPath) && (0, import_node_fs3.statSync)(explicitFullPath).isFile()) {
126261
126314
  return {
126262
126315
  repoRelativePath: normalizedExplicitPath,
126263
126316
  configRelativePath: normalizeToPosix(path3.join("..", normalizedExplicitPath))
@@ -126338,7 +126391,7 @@ async function upsertEnvironments(inputs, dependencies, resourcesState) {
126338
126391
  return envUids;
126339
126392
  }
126340
126393
  function ensureDir(path5) {
126341
- (0, import_node_fs2.mkdirSync)(path5, { recursive: true });
126394
+ (0, import_node_fs3.mkdirSync)(path5, { recursive: true });
126342
126395
  }
126343
126396
  function getCollectionDirectoryName(kind, projectName) {
126344
126397
  if (kind === "Baseline") {
@@ -126375,7 +126428,7 @@ function stripVolatileFields(obj) {
126375
126428
  }
126376
126429
  function writeJsonFile(path5, content, normalize3 = false) {
126377
126430
  const data = normalize3 ? stripVolatileFields(content) : content;
126378
- (0, import_node_fs2.writeFileSync)(path5, JSON.stringify(data, null, 2));
126431
+ (0, import_node_fs3.writeFileSync)(path5, JSON.stringify(data, null, 2));
126379
126432
  }
126380
126433
  function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir, localSpecRefs, mappedSpecRef, specId) {
126381
126434
  const manifest = {
@@ -126449,21 +126502,21 @@ function assertPathWithinCwd(targetPath, fieldName) {
126449
126502
  if (!rawPath || hasControlCharacter2(originalPath) || path3.isAbsolute(rawPath) || path3.win32.isAbsolute(rawPath) || segments.includes("..") || rawPath.startsWith(":") || hasControlCharacter2(rawPath)) {
126450
126503
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
126451
126504
  }
126452
- const base = (0, import_node_fs2.realpathSync)(process.cwd());
126505
+ const base = (0, import_node_fs3.realpathSync)(process.cwd());
126453
126506
  const resolved = path3.resolve(base, rawPath);
126454
126507
  const relative2 = path3.relative(base, resolved);
126455
126508
  if (relative2.startsWith("..") || path3.isAbsolute(relative2)) {
126456
126509
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
126457
126510
  }
126458
126511
  let existingPath = resolved;
126459
- while (!(0, import_node_fs2.existsSync)(existingPath)) {
126512
+ while (!(0, import_node_fs3.existsSync)(existingPath)) {
126460
126513
  const parent = path3.dirname(existingPath);
126461
126514
  if (parent === existingPath) {
126462
126515
  break;
126463
126516
  }
126464
126517
  existingPath = parent;
126465
126518
  }
126466
- const realExistingPath = (0, import_node_fs2.realpathSync)(existingPath);
126519
+ const realExistingPath = (0, import_node_fs3.realpathSync)(existingPath);
126467
126520
  const realRelative = path3.relative(base, realExistingPath);
126468
126521
  if (realRelative.startsWith("..") || path3.isAbsolute(realRelative)) {
126469
126522
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
@@ -126491,8 +126544,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
126491
126544
  ensureDir(specsDir);
126492
126545
  ensureDir(".postman");
126493
126546
  const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
126494
- if (!(0, import_node_fs2.existsSync)(globalsFilePath)) {
126495
- (0, import_node_fs2.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
126547
+ if (!(0, import_node_fs3.existsSync)(globalsFilePath)) {
126548
+ (0, import_node_fs3.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
126496
126549
  }
126497
126550
  if (inputs.generateCiWorkflow) {
126498
126551
  const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
@@ -126528,7 +126581,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
126528
126581
  true
126529
126582
  );
126530
126583
  }
126531
- (0, import_node_fs2.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
126584
+ (0, import_node_fs3.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
126532
126585
  inputs.workspaceId,
126533
126586
  manifestCollections,
126534
126587
  envUids,
@@ -126538,7 +126591,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
126538
126591
  inputs.specId || void 0
126539
126592
  ));
126540
126593
  if (mappedSpec && Object.keys(manifestCollections).length > 0) {
126541
- (0, import_node_fs2.writeFileSync)(
126594
+ (0, import_node_fs3.writeFileSync)(
126542
126595
  ".postman/workflows.yaml",
126543
126596
  buildSpecCollectionWorkflowManifest(
126544
126597
  mappedSpec.configRelativePath,
@@ -126575,29 +126628,27 @@ function createRepoSummary(outputs, envUids, pushed) {
126575
126628
  });
126576
126629
  }
126577
126630
  async function commitAndPushGeneratedFiles(inputs, dependencies) {
126578
- if (!dependencies.repoMutation || inputs.repoWriteMode === "none") {
126579
- return { commitSha: "", resolvedCurrentRef: "", pushed: false };
126580
- }
126581
126631
  if (inputs.generateCiWorkflow) {
126632
+ assertPathWithinCwd(inputs.ciWorkflowPath, "ci-workflow-path");
126582
126633
  const ciWorkflow = renderCiWorkflow(inputs);
126583
126634
  const parts = inputs.ciWorkflowPath.split("/");
126584
126635
  if (parts.length > 1) {
126585
126636
  const dir = parts.slice(0, -1).join("/");
126586
126637
  ensureDir(dir);
126587
126638
  }
126588
- (0, import_node_fs2.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
126639
+ (0, import_node_fs3.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
126589
126640
  }
126590
- const provisionPath = ".github/workflows/provision.yml";
126591
- const provisionExists = inputs.provider === "github" && (0, import_node_fs2.existsSync)(provisionPath);
126592
- if (provisionExists) {
126593
- (0, import_node_fs2.rmSync)(provisionPath);
126641
+ if (!dependencies.repoMutation || inputs.repoWriteMode === "none") {
126642
+ return { commitSha: "", resolvedCurrentRef: "", pushed: false };
126594
126643
  }
126644
+ const provisionPath = ".github/workflows/provision.yml";
126645
+ const provisionExists = inputs.provider === "github" && (0, import_node_fs3.existsSync)(provisionPath);
126595
126646
  const stagePaths = [
126596
126647
  inputs.artifactDir,
126597
126648
  ".postman",
126598
126649
  inputs.generateCiWorkflow ? inputs.ciWorkflowPath : null,
126599
126650
  provisionExists ? provisionPath : null
126600
- ].filter((entry) => typeof entry === "string" && ((0, import_node_fs2.existsSync)(entry) || entry === provisionPath));
126651
+ ].filter((entry) => typeof entry === "string" && ((0, import_node_fs3.existsSync)(entry) || entry === provisionPath));
126601
126652
  if (stagePaths.length === 0) {
126602
126653
  dependencies.core.info("No generated repository paths were found; skipping repo mutation.");
126603
126654
  return {
@@ -126621,6 +126672,7 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
126621
126672
  adoToken: inputs.provider === "azure-devops" ? inputs.adoToken : void 0,
126622
126673
  githubToken: inputs.provider === "azure-devops" ? void 0 : inputs.githubToken,
126623
126674
  fallbackToken: inputs.provider === "azure-devops" ? void 0 : inputs.ghFallbackToken,
126675
+ removePaths: provisionExists ? [provisionPath] : [],
126624
126676
  stagePaths
126625
126677
  });
126626
126678
  return {
@@ -127020,6 +127072,71 @@ function createRepoSyncDependencies(inputs, resolved, factories, options = {}) {
127020
127072
 
127021
127073
  // src/cli.ts
127022
127074
  var execFileAsync = (0, import_node_util.promisify)(import_node_child_process.execFile);
127075
+ var CLI_INPUT_NAMES = [
127076
+ "project-name",
127077
+ "workspace-id",
127078
+ "baseline-collection-id",
127079
+ "smoke-collection-id",
127080
+ "contract-collection-id",
127081
+ "collection-sync-mode",
127082
+ "spec-sync-mode",
127083
+ "release-label",
127084
+ "environments-json",
127085
+ "git-provider",
127086
+ "ado-token",
127087
+ "repo-url",
127088
+ "integration-backend",
127089
+ "workspace-link-enabled",
127090
+ "environment-sync-enabled",
127091
+ "system-env-map-json",
127092
+ "environment-uids-json",
127093
+ "env-runtime-urls-json",
127094
+ "artifact-dir",
127095
+ "repo-write-mode",
127096
+ "repository",
127097
+ "current-ref",
127098
+ "github-head-ref",
127099
+ "github-ref-name",
127100
+ "committer-name",
127101
+ "committer-email",
127102
+ "postman-api-key",
127103
+ "postman-access-token",
127104
+ "credential-preflight",
127105
+ "github-token",
127106
+ "gh-fallback-token",
127107
+ "ci-workflow-base64",
127108
+ "generate-ci-workflow",
127109
+ "monitor-type",
127110
+ "ci-workflow-path",
127111
+ "org-mode",
127112
+ "monitor-id",
127113
+ "mock-url",
127114
+ "monitor-cron",
127115
+ "ssl-client-cert",
127116
+ "ssl-client-key",
127117
+ "ssl-client-passphrase",
127118
+ "ssl-extra-ca-certs",
127119
+ "spec-id",
127120
+ "spec-path",
127121
+ "team-id",
127122
+ "postman-region",
127123
+ "postman-stack"
127124
+ ];
127125
+ var HELP_TEXT = `Usage: postman-repo-sync [options]
127126
+
127127
+ Sync Postman artifacts into a git repository.
127128
+
127129
+ Options:
127130
+ --help Show this help and exit
127131
+ --version Show version and exit
127132
+ --result-json <path> Write JSON result (default: postman-repo-sync-result.json)
127133
+ --dotenv-path <path> Optional dotenv output path
127134
+ --<input-name> <value> Action input as kebab-case flag (same names as action.yml)
127135
+
127136
+ Examples:
127137
+ postman-repo-sync --help
127138
+ postman-repo-sync --repo-write-mode none --workspace-id <id> ...
127139
+ `;
127023
127140
  var ConsoleReporter = class {
127024
127141
  info(message) {
127025
127142
  console.error(message);
@@ -127032,19 +127149,6 @@ var ConsoleReporter = class {
127032
127149
  setSecret() {
127033
127150
  }
127034
127151
  };
127035
- function readFlag(argv, name) {
127036
- const prefix = `--${name}=`;
127037
- for (let index = 0; index < argv.length; index += 1) {
127038
- const arg = argv[index];
127039
- if (arg === `--${name}`) {
127040
- return argv[index + 1];
127041
- }
127042
- if (arg?.startsWith(prefix)) {
127043
- return arg.slice(prefix.length);
127044
- }
127045
- }
127046
- return void 0;
127047
- }
127048
127152
  function normalizeCliFlag(name) {
127049
127153
  return `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
127050
127154
  }
@@ -127107,68 +127211,117 @@ function createCliExec(secretMasker) {
127107
127211
  }
127108
127212
  };
127109
127213
  }
127214
+ function resolvePackageVersion() {
127215
+ const candidates = [];
127216
+ if (typeof __filename === "string" && __filename) {
127217
+ candidates.push(import_node_path3.default.join(import_node_path3.default.dirname(__filename), "..", "package.json"));
127218
+ }
127219
+ candidates.push(import_node_path3.default.join(process.cwd(), "package.json"));
127220
+ for (const packageJsonPath of candidates) {
127221
+ try {
127222
+ const packageJson = JSON.parse((0, import_node_fs4.readFileSync)(packageJsonPath, "utf8"));
127223
+ if (packageJson.name === "@postman-cse/onboarding-repo-sync" && packageJson.version) {
127224
+ return String(packageJson.version).trim();
127225
+ }
127226
+ } catch {
127227
+ }
127228
+ }
127229
+ return "0.0.0";
127230
+ }
127231
+ function wantsHelp(argv) {
127232
+ return argv.includes("--help") || argv.includes("-h");
127233
+ }
127234
+ function wantsVersion(argv) {
127235
+ return argv.includes("--version") || argv.includes("-V");
127236
+ }
127237
+ function runnerFormEnvName(name) {
127238
+ return `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
127239
+ }
127110
127240
  function parseCliArgs(argv, env = process.env) {
127111
- const inputNames = [
127112
- "project-name",
127113
- "workspace-id",
127114
- "baseline-collection-id",
127115
- "smoke-collection-id",
127116
- "contract-collection-id",
127117
- "collection-sync-mode",
127118
- "spec-sync-mode",
127119
- "release-label",
127120
- "environments-json",
127121
- "git-provider",
127122
- "ado-token",
127123
- "repo-url",
127124
- "integration-backend",
127125
- "workspace-link-enabled",
127126
- "environment-sync-enabled",
127127
- "system-env-map-json",
127128
- "environment-uids-json",
127129
- "env-runtime-urls-json",
127130
- "artifact-dir",
127131
- "repo-write-mode",
127132
- "repository",
127133
- "current-ref",
127134
- "github-head-ref",
127135
- "github-ref-name",
127136
- "committer-name",
127137
- "committer-email",
127138
- "postman-api-key",
127139
- "postman-access-token",
127140
- "credential-preflight",
127141
- "github-token",
127142
- "gh-fallback-token",
127143
- "ci-workflow-base64",
127144
- "generate-ci-workflow",
127145
- "monitor-type",
127146
- "ci-workflow-path",
127147
- "org-mode",
127148
- "monitor-id",
127149
- "mock-url",
127150
- "monitor-cron",
127151
- "ssl-client-cert",
127152
- "ssl-client-key",
127153
- "ssl-client-passphrase",
127154
- "ssl-extra-ca-certs",
127155
- "spec-id",
127156
- "spec-path",
127157
- "team-id",
127158
- "postman-region",
127159
- "postman-stack"
127160
- ];
127241
+ const inputNames = new Set(CLI_INPUT_NAMES);
127161
127242
  const inputEnv = { ...env };
127162
- for (const name of inputNames) {
127163
- const value = readFlag(argv, name);
127164
- if (value !== void 0) {
127165
- inputEnv[normalizeCliFlag(name)] = value;
127243
+ let resultJsonPath = "postman-repo-sync-result.json";
127244
+ let dotenvPath;
127245
+ const seenFlags = /* @__PURE__ */ new Map();
127246
+ let sawHelp = false;
127247
+ let sawVersion = false;
127248
+ for (let index = 0; index < argv.length; index += 1) {
127249
+ const arg = argv[index];
127250
+ if (!arg) {
127251
+ continue;
127252
+ }
127253
+ if (arg === "--help" || arg === "-h") {
127254
+ sawHelp = true;
127255
+ continue;
127256
+ }
127257
+ if (arg === "--version" || arg === "-V") {
127258
+ sawVersion = true;
127259
+ continue;
127260
+ }
127261
+ if (!arg.startsWith("--")) {
127262
+ throw new Error(`Unexpected positional argument: ${arg}`);
127166
127263
  }
127264
+ let name;
127265
+ let value;
127266
+ const separator = arg.indexOf("=");
127267
+ if (separator !== -1) {
127268
+ name = arg.slice(2, separator);
127269
+ value = arg.slice(separator + 1);
127270
+ if (value === "") {
127271
+ throw new Error(`Missing value for --${name}`);
127272
+ }
127273
+ } else {
127274
+ name = arg.slice(2);
127275
+ const next = argv[index + 1];
127276
+ if (next === void 0 || next.startsWith("--")) {
127277
+ throw new Error(`Missing value for --${name}`);
127278
+ }
127279
+ value = next;
127280
+ index += 1;
127281
+ }
127282
+ if (!name) {
127283
+ throw new Error(`Unknown option ${arg}`);
127284
+ }
127285
+ if (name === "result-json") {
127286
+ const previous2 = seenFlags.get(name);
127287
+ if (previous2 !== void 0 && previous2 !== value) {
127288
+ throw new Error(`Conflicting values for --${name}`);
127289
+ }
127290
+ seenFlags.set(name, value);
127291
+ resultJsonPath = value;
127292
+ continue;
127293
+ }
127294
+ if (name === "dotenv-path") {
127295
+ const previous2 = seenFlags.get(name);
127296
+ if (previous2 !== void 0 && previous2 !== value) {
127297
+ throw new Error(`Conflicting values for --${name}`);
127298
+ }
127299
+ seenFlags.set(name, value);
127300
+ dotenvPath = value;
127301
+ continue;
127302
+ }
127303
+ if (!inputNames.has(name)) {
127304
+ throw new Error(`Unknown option --${name}`);
127305
+ }
127306
+ const previous = seenFlags.get(name);
127307
+ if (previous !== void 0 && previous !== value) {
127308
+ throw new Error(`Conflicting values for --${name}`);
127309
+ }
127310
+ seenFlags.set(name, value);
127311
+ const normalized = normalizeCliFlag(name);
127312
+ const runnerForm = runnerFormEnvName(name);
127313
+ inputEnv[normalized] = value;
127314
+ if (runnerForm !== normalized) {
127315
+ delete inputEnv[runnerForm];
127316
+ }
127317
+ }
127318
+ if (sawHelp && sawVersion) {
127319
+ throw new Error("Cannot use --help and --version together");
127167
127320
  }
127168
127321
  return {
127169
127322
  inputEnv,
127170
- resultJsonPath: readFlag(argv, "result-json") ?? "postman-repo-sync-result.json",
127171
- dotenvPath: readFlag(argv, "dotenv-path")
127323
+ resultJsonPath,
127324
+ dotenvPath
127172
127325
  };
127173
127326
  }
127174
127327
  function toDotenv(outputs) {
@@ -127216,6 +127369,20 @@ function createCliDependencies(inputs, resolved) {
127216
127369
  );
127217
127370
  }
127218
127371
  async function runCli(argv = process.argv.slice(2), runtime = {}) {
127372
+ const writeStdout = runtime.writeStdout ?? ((chunk) => process.stdout.write(chunk));
127373
+ if (wantsHelp(argv) && wantsVersion(argv)) {
127374
+ throw new Error("Cannot use --help and --version together");
127375
+ }
127376
+ if (wantsHelp(argv)) {
127377
+ writeStdout(HELP_TEXT.endsWith("\n") ? HELP_TEXT : `${HELP_TEXT}
127378
+ `);
127379
+ return;
127380
+ }
127381
+ if (wantsVersion(argv)) {
127382
+ writeStdout(`${resolvePackageVersion()}
127383
+ `);
127384
+ return;
127385
+ }
127219
127386
  const env = runtime.env ?? process.env;
127220
127387
  const config = parseCliArgs(argv, env);
127221
127388
  const inputs = resolveInputs(config.inputEnv);
@@ -127267,7 +127434,6 @@ async function runCli(argv = process.argv.slice(2), runtime = {}) {
127267
127434
  const result = await (runtime.executeRepoSync ?? runRepoSync)(inputs, dependencies);
127268
127435
  await writeOptionalFile(config.resultJsonPath, JSON.stringify(result, null, 2));
127269
127436
  await writeOptionalFile(config.dotenvPath, toDotenv(result));
127270
- const writeStdout = runtime.writeStdout ?? ((chunk) => process.stdout.write(chunk));
127271
127437
  writeStdout(`${JSON.stringify(result, null, 2)}
127272
127438
  `);
127273
127439
  }
@@ -127278,7 +127444,7 @@ function isEntrypoint(currentPath, entrypointPath) {
127278
127444
  return false;
127279
127445
  }
127280
127446
  try {
127281
- return (0, import_node_fs3.realpathSync)(currentPath) === (0, import_node_fs3.realpathSync)(entrypointPath);
127447
+ return (0, import_node_fs4.realpathSync)(currentPath) === (0, import_node_fs4.realpathSync)(entrypointPath);
127282
127448
  } catch {
127283
127449
  return import_node_path3.default.resolve(currentPath) === import_node_path3.default.resolve(entrypointPath);
127284
127450
  }
package/dist/index.cjs CHANGED
@@ -119790,6 +119790,7 @@ __export(index_exports, {
119790
119790
  assertPathWithinCwd: () => assertPathWithinCwd,
119791
119791
  createRepoSyncDependencies: () => createRepoSyncDependencies,
119792
119792
  getInput: () => getInput2,
119793
+ hasInput: () => hasInput,
119793
119794
  readActionInputs: () => readActionInputs,
119794
119795
  resolveInputs: () => resolveInputs,
119795
119796
  resolvePostmanApiKeyAndTeamId: () => resolvePostmanApiKeyAndTeamId,
@@ -122077,7 +122078,7 @@ function getIDToken(aud) {
122077
122078
  }
122078
122079
 
122079
122080
  // src/index.ts
122080
- var import_node_fs2 = require("node:fs");
122081
+ var import_node_fs3 = require("node:fs");
122081
122082
  var path8 = __toESM(require("node:path"), 1);
122082
122083
 
122083
122084
  // node_modules/js-yaml/dist/js-yaml.mjs
@@ -125380,6 +125381,7 @@ function getCiWorkflowTemplate(provider, options = {}) {
125380
125381
  }
125381
125382
 
125382
125383
  // src/lib/github/repo-mutation.ts
125384
+ var import_node_fs = require("node:fs");
125383
125385
  var import_node_path = __toESM(require("node:path"), 1);
125384
125386
 
125385
125387
  // src/lib/secrets.ts
@@ -125621,17 +125623,21 @@ function normalizeStagePaths(stagePaths) {
125621
125623
  if (hasControlCharacter(rawPath) || import_node_path.default.isAbsolute(stagePath) || import_node_path.default.win32.isAbsolute(stagePath) || segments.includes("..") || stagePath.startsWith(":") || hasControlCharacter(stagePath)) {
125622
125624
  throw new Error(`Unsafe git stage path: ${stagePath}`);
125623
125625
  }
125624
- normalized.push(stagePath);
125626
+ if (!normalized.includes(stagePath)) {
125627
+ normalized.push(stagePath);
125628
+ }
125625
125629
  }
125626
125630
  return normalized;
125627
125631
  }
125628
125632
  var RepoMutationService = class {
125633
+ cwd;
125629
125634
  execute;
125630
125635
  provider;
125631
125636
  repository;
125632
125637
  repoUrl;
125633
125638
  secretMasker;
125634
125639
  constructor(options) {
125640
+ this.cwd = options.cwd ?? process.cwd();
125635
125641
  this.execute = options.execute;
125636
125642
  this.provider = options.provider ?? "github";
125637
125643
  this.repository = options.repository;
@@ -125640,7 +125646,8 @@ var RepoMutationService = class {
125640
125646
  }
125641
125647
  async commitAndPush(options) {
125642
125648
  const resolvedCurrentRef = resolveCurrentRef(options);
125643
- const stagePaths = normalizeStagePaths(options.stagePaths);
125649
+ const removePaths = normalizeStagePaths(options.removePaths ?? []);
125650
+ const stagePaths = normalizeStagePaths([...options.stagePaths, ...removePaths]);
125644
125651
  const tokens = this.provider === "azure-devops" ? buildPushTokenOrder({ adoToken: options.adoToken }) : buildPushTokenOrder({
125645
125652
  fallbackToken: options.fallbackToken,
125646
125653
  githubToken: options.githubToken
@@ -125653,8 +125660,43 @@ var RepoMutationService = class {
125653
125660
  resolvedCurrentRef
125654
125661
  };
125655
125662
  }
125663
+ const changed = await this.execute("git", [
125664
+ "status",
125665
+ "--porcelain=v1",
125666
+ "--untracked-files=all",
125667
+ "--",
125668
+ ...stagePaths
125669
+ ]);
125670
+ if (changed.exitCode !== 0) {
125671
+ throw new Error(this.secretMasker(changed.stderr || changed.stdout || "Failed to inspect generated changes"));
125672
+ }
125673
+ const hasPlannedRemoval = removePaths.some(
125674
+ (removePath) => (0, import_node_fs.existsSync)(import_node_path.default.resolve(this.cwd, removePath))
125675
+ );
125676
+ if (!changed.stdout.trim() && !hasPlannedRemoval) {
125677
+ return {
125678
+ commitSha: "",
125679
+ pushed: false,
125680
+ resolvedCurrentRef
125681
+ };
125682
+ }
125683
+ const usePersistedCredentials = tokens.length === 0 && this.provider === "azure-devops";
125684
+ if (options.repoWriteMode === "commit-and-push") {
125685
+ if (!supportsTokenRemote(this.provider)) {
125686
+ throw new Error(`repo-write-mode=commit-and-push is not supported for git provider "${this.provider}"`);
125687
+ }
125688
+ if (!resolvedCurrentRef) {
125689
+ throw new Error("No current ref could be resolved for repo-write-mode=commit-and-push");
125690
+ }
125691
+ if (tokens.length === 0 && !usePersistedCredentials) {
125692
+ throw new Error("No push token configured for repo-write-mode=commit-and-push");
125693
+ }
125694
+ }
125656
125695
  await this.execute("git", ["config", "user.name", options.committerName]);
125657
125696
  await this.execute("git", ["config", "user.email", options.committerEmail]);
125697
+ for (const removePath of removePaths) {
125698
+ (0, import_node_fs.rmSync)(import_node_path.default.resolve(this.cwd, removePath), { force: true });
125699
+ }
125658
125700
  await this.execute("git", ["add", "-A", "--", ...stagePaths]);
125659
125701
  const staged = await this.execute("git", ["diff", "--cached", "--quiet"]);
125660
125702
  if (staged.exitCode === 0) {
@@ -125677,16 +125719,6 @@ var RepoMutationService = class {
125677
125719
  resolvedCurrentRef
125678
125720
  };
125679
125721
  }
125680
- if (!resolvedCurrentRef) {
125681
- throw new Error("No current ref could be resolved for repo-write-mode=commit-and-push");
125682
- }
125683
- const usePersistedCredentials = tokens.length === 0 && this.provider === "azure-devops";
125684
- if (tokens.length === 0 && !usePersistedCredentials) {
125685
- throw new Error("No push token configured for repo-write-mode=commit-and-push");
125686
- }
125687
- if (tokens.length > 0 && !supportsTokenRemote(this.provider)) {
125688
- throw new Error(`repo-write-mode=commit-and-push is not supported for git provider "${this.provider}"`);
125689
- }
125690
125722
  const originalRemote = (await this.execute("git", ["remote", "get-url", "origin"])).stdout.trim();
125691
125723
  let pushed = false;
125692
125724
  let lastError = "";
@@ -126206,11 +126238,11 @@ function createTelemetryContext(options) {
126206
126238
  }
126207
126239
 
126208
126240
  // src/action-version.ts
126209
- var import_node_fs = require("node:fs");
126241
+ var import_node_fs2 = require("node:fs");
126210
126242
  var import_node_path2 = require("node:path");
126211
126243
  function resolveActionVersion2() {
126212
126244
  try {
126213
- const raw = (0, import_node_fs.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
126245
+ const raw = (0, import_node_fs2.readFileSync)((0, import_node_path2.join)(__dirname, "..", "package.json"), "utf8");
126214
126246
  return JSON.parse(raw).version ?? "unknown";
126215
126247
  } catch {
126216
126248
  return "unknown";
@@ -127965,8 +127997,27 @@ function normalizeInputValue(value) {
127965
127997
  return String(value ?? "").trim();
127966
127998
  }
127967
127999
  function getInput2(name, env = process.env) {
127968
- const envName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
127969
- return normalizeInputValue(env[envName]);
128000
+ const normalizedName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
128001
+ const runnerName = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
128002
+ const normalizedRaw = env[normalizedName];
128003
+ const runnerRaw = runnerName === normalizedName ? void 0 : env[runnerName];
128004
+ const hasNormalized = normalizedRaw !== void 0;
128005
+ const hasRunner = runnerRaw !== void 0;
128006
+ if (hasNormalized && hasRunner) {
128007
+ const normalizedValue = normalizeInputValue(normalizedRaw);
128008
+ const runnerValue = normalizeInputValue(runnerRaw);
128009
+ if (normalizedValue !== runnerValue) {
128010
+ throw new Error(
128011
+ `Conflicting values for ${name}: ${normalizedName}=${JSON.stringify(normalizedValue)} vs ${runnerName}=${JSON.stringify(runnerValue)}`
128012
+ );
128013
+ }
128014
+ }
128015
+ return normalizeInputValue(hasNormalized ? normalizedRaw : runnerRaw);
128016
+ }
128017
+ function hasInput(name, env = process.env) {
128018
+ const normalizedName = `INPUT_${name.replace(/-/g, "_").toUpperCase()}`;
128019
+ const runnerName = `INPUT_${name.replace(/ /g, "_").toUpperCase()}`;
128020
+ return env[normalizedName] !== void 0 || runnerName !== normalizedName && env[runnerName] !== void 0;
127970
128021
  }
127971
128022
  function parseJsonMap(raw) {
127972
128023
  if (!raw.trim()) return {};
@@ -127996,7 +128047,9 @@ function normalizeRepoWriteMode(value) {
127996
128047
  if (value === "none" || value === "commit-only" || value === "commit-and-push") {
127997
128048
  return value;
127998
128049
  }
127999
- return "commit-and-push";
128050
+ throw new Error(
128051
+ `Unsupported repo-write-mode "${value}". Allowed values: none, commit-only, commit-and-push`
128052
+ );
128000
128053
  }
128001
128054
  function normalizeCollectionSyncMode(value) {
128002
128055
  if (value === "refresh" || value === "version") {
@@ -128078,7 +128131,7 @@ function resolveInputs(env = process.env) {
128078
128131
  environmentUids,
128079
128132
  envRuntimeUrls,
128080
128133
  artifactDir: getInput2("artifact-dir", env) || "postman",
128081
- repoWriteMode: normalizeRepoWriteMode(getInput2("repo-write-mode", env) || "commit-and-push"),
128134
+ repoWriteMode: hasInput("repo-write-mode", env) ? normalizeRepoWriteMode(getInput2("repo-write-mode", env)) : "commit-and-push",
128082
128135
  currentRef: getInput2("current-ref", env) || normalizeInputValue(env.GITHUB_REF) || normalizeInputValue(env.BUILD_SOURCEBRANCH),
128083
128136
  githubHeadRef: getInput2("github-head-ref", env) || normalizeInputValue(env.GITHUB_HEAD_REF) || normalizeInputValue(env.SYSTEM_PULLREQUEST_SOURCEBRANCH),
128084
128137
  githubRefName: getInput2("github-ref-name", env) || normalizeInputValue(env.GITHUB_REF_NAME) || normalizeInputValue(repoContext.ref),
@@ -128127,7 +128180,7 @@ function buildEnvironmentValues(envName, baseUrl) {
128127
128180
  var LEGACY_BASELINE_COLLECTION_PREFIX = "[Baseline]";
128128
128181
  function readResourcesState() {
128129
128182
  try {
128130
- return load((0, import_node_fs2.readFileSync)(".postman/resources.yaml", "utf8"));
128183
+ return load((0, import_node_fs3.readFileSync)(".postman/resources.yaml", "utf8"));
128131
128184
  } catch {
128132
128185
  return null;
128133
128186
  }
@@ -128165,7 +128218,7 @@ function isOpenApiSpecFile(filePath) {
128165
128218
  return false;
128166
128219
  }
128167
128220
  try {
128168
- const raw = (0, import_node_fs2.readFileSync)(filePath, "utf8");
128221
+ const raw = (0, import_node_fs3.readFileSync)(filePath, "utf8");
128169
128222
  const parsed = filePath.endsWith(".json") ? JSON.parse(raw) : load(raw);
128170
128223
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
128171
128224
  return false;
@@ -128194,7 +128247,7 @@ function scanLocalSpecReferences(baseDir = ".") {
128194
128247
  const found = /* @__PURE__ */ new Set();
128195
128248
  const refs = [];
128196
128249
  const visit2 = (currentDir) => {
128197
- for (const entry of (0, import_node_fs2.readdirSync)(currentDir, { withFileTypes: true })) {
128250
+ for (const entry of (0, import_node_fs3.readdirSync)(currentDir, { withFileTypes: true })) {
128198
128251
  if (ignoredDirs.has(entry.name)) {
128199
128252
  continue;
128200
128253
  }
@@ -128224,7 +128277,7 @@ function resolveMappedSpecReference(explicitSpecPath, discoveredSpecs) {
128224
128277
  const normalizedExplicitPath = normalizeToPosix(explicitSpecPath.trim());
128225
128278
  if (normalizedExplicitPath) {
128226
128279
  const explicitFullPath = path8.resolve(normalizedExplicitPath);
128227
- if ((0, import_node_fs2.existsSync)(explicitFullPath) && (0, import_node_fs2.statSync)(explicitFullPath).isFile()) {
128280
+ if ((0, import_node_fs3.existsSync)(explicitFullPath) && (0, import_node_fs3.statSync)(explicitFullPath).isFile()) {
128228
128281
  return {
128229
128282
  repoRelativePath: normalizedExplicitPath,
128230
128283
  configRelativePath: normalizeToPosix(path8.join("..", normalizedExplicitPath))
@@ -128439,7 +128492,7 @@ async function upsertEnvironments(inputs, dependencies, resourcesState) {
128439
128492
  return envUids;
128440
128493
  }
128441
128494
  function ensureDir(path9) {
128442
- (0, import_node_fs2.mkdirSync)(path9, { recursive: true });
128495
+ (0, import_node_fs3.mkdirSync)(path9, { recursive: true });
128443
128496
  }
128444
128497
  function getCollectionDirectoryName(kind, projectName) {
128445
128498
  if (kind === "Baseline") {
@@ -128476,7 +128529,7 @@ function stripVolatileFields(obj) {
128476
128529
  }
128477
128530
  function writeJsonFile(path9, content, normalize3 = false) {
128478
128531
  const data = normalize3 ? stripVolatileFields(content) : content;
128479
- (0, import_node_fs2.writeFileSync)(path9, JSON.stringify(data, null, 2));
128532
+ (0, import_node_fs3.writeFileSync)(path9, JSON.stringify(data, null, 2));
128480
128533
  }
128481
128534
  function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir, localSpecRefs, mappedSpecRef, specId) {
128482
128535
  const manifest = {
@@ -128550,21 +128603,21 @@ function assertPathWithinCwd(targetPath, fieldName) {
128550
128603
  if (!rawPath || hasControlCharacter2(originalPath) || path8.isAbsolute(rawPath) || path8.win32.isAbsolute(rawPath) || segments.includes("..") || rawPath.startsWith(":") || hasControlCharacter2(rawPath)) {
128551
128604
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
128552
128605
  }
128553
- const base = (0, import_node_fs2.realpathSync)(process.cwd());
128606
+ const base = (0, import_node_fs3.realpathSync)(process.cwd());
128554
128607
  const resolved = path8.resolve(base, rawPath);
128555
128608
  const relative3 = path8.relative(base, resolved);
128556
128609
  if (relative3.startsWith("..") || path8.isAbsolute(relative3)) {
128557
128610
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
128558
128611
  }
128559
128612
  let existingPath = resolved;
128560
- while (!(0, import_node_fs2.existsSync)(existingPath)) {
128613
+ while (!(0, import_node_fs3.existsSync)(existingPath)) {
128561
128614
  const parent = path8.dirname(existingPath);
128562
128615
  if (parent === existingPath) {
128563
128616
  break;
128564
128617
  }
128565
128618
  existingPath = parent;
128566
128619
  }
128567
- const realExistingPath = (0, import_node_fs2.realpathSync)(existingPath);
128620
+ const realExistingPath = (0, import_node_fs3.realpathSync)(existingPath);
128568
128621
  const realRelative = path8.relative(base, realExistingPath);
128569
128622
  if (realRelative.startsWith("..") || path8.isAbsolute(realRelative)) {
128570
128623
  throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
@@ -128592,8 +128645,8 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
128592
128645
  ensureDir(specsDir);
128593
128646
  ensureDir(".postman");
128594
128647
  const globalsFilePath = `${globalsDir}/workspace.globals.yaml`;
128595
- if (!(0, import_node_fs2.existsSync)(globalsFilePath)) {
128596
- (0, import_node_fs2.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
128648
+ if (!(0, import_node_fs3.existsSync)(globalsFilePath)) {
128649
+ (0, import_node_fs3.writeFileSync)(globalsFilePath, "name: Globals\nvalues: []\n");
128597
128650
  }
128598
128651
  if (inputs.generateCiWorkflow) {
128599
128652
  const ciDir = inputs.ciWorkflowPath.split("/").slice(0, -1).join("/");
@@ -128629,7 +128682,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
128629
128682
  true
128630
128683
  );
128631
128684
  }
128632
- (0, import_node_fs2.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
128685
+ (0, import_node_fs3.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
128633
128686
  inputs.workspaceId,
128634
128687
  manifestCollections,
128635
128688
  envUids,
@@ -128639,7 +128692,7 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
128639
128692
  inputs.specId || void 0
128640
128693
  ));
128641
128694
  if (mappedSpec && Object.keys(manifestCollections).length > 0) {
128642
- (0, import_node_fs2.writeFileSync)(
128695
+ (0, import_node_fs3.writeFileSync)(
128643
128696
  ".postman/workflows.yaml",
128644
128697
  buildSpecCollectionWorkflowManifest(
128645
128698
  mappedSpec.configRelativePath,
@@ -128676,29 +128729,27 @@ function createRepoSummary(outputs, envUids, pushed) {
128676
128729
  });
128677
128730
  }
128678
128731
  async function commitAndPushGeneratedFiles(inputs, dependencies) {
128679
- if (!dependencies.repoMutation || inputs.repoWriteMode === "none") {
128680
- return { commitSha: "", resolvedCurrentRef: "", pushed: false };
128681
- }
128682
128732
  if (inputs.generateCiWorkflow) {
128733
+ assertPathWithinCwd(inputs.ciWorkflowPath, "ci-workflow-path");
128683
128734
  const ciWorkflow = renderCiWorkflow(inputs);
128684
128735
  const parts = inputs.ciWorkflowPath.split("/");
128685
128736
  if (parts.length > 1) {
128686
128737
  const dir = parts.slice(0, -1).join("/");
128687
128738
  ensureDir(dir);
128688
128739
  }
128689
- (0, import_node_fs2.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
128740
+ (0, import_node_fs3.writeFileSync)(inputs.ciWorkflowPath, ciWorkflow);
128690
128741
  }
128691
- const provisionPath = ".github/workflows/provision.yml";
128692
- const provisionExists = inputs.provider === "github" && (0, import_node_fs2.existsSync)(provisionPath);
128693
- if (provisionExists) {
128694
- (0, import_node_fs2.rmSync)(provisionPath);
128742
+ if (!dependencies.repoMutation || inputs.repoWriteMode === "none") {
128743
+ return { commitSha: "", resolvedCurrentRef: "", pushed: false };
128695
128744
  }
128745
+ const provisionPath = ".github/workflows/provision.yml";
128746
+ const provisionExists = inputs.provider === "github" && (0, import_node_fs3.existsSync)(provisionPath);
128696
128747
  const stagePaths = [
128697
128748
  inputs.artifactDir,
128698
128749
  ".postman",
128699
128750
  inputs.generateCiWorkflow ? inputs.ciWorkflowPath : null,
128700
128751
  provisionExists ? provisionPath : null
128701
- ].filter((entry) => typeof entry === "string" && ((0, import_node_fs2.existsSync)(entry) || entry === provisionPath));
128752
+ ].filter((entry) => typeof entry === "string" && ((0, import_node_fs3.existsSync)(entry) || entry === provisionPath));
128702
128753
  if (stagePaths.length === 0) {
128703
128754
  dependencies.core.info("No generated repository paths were found; skipping repo mutation.");
128704
128755
  return {
@@ -128722,6 +128773,7 @@ async function commitAndPushGeneratedFiles(inputs, dependencies) {
128722
128773
  adoToken: inputs.provider === "azure-devops" ? inputs.adoToken : void 0,
128723
128774
  githubToken: inputs.provider === "azure-devops" ? void 0 : inputs.githubToken,
128724
128775
  fallbackToken: inputs.provider === "azure-devops" ? void 0 : inputs.ghFallbackToken,
128776
+ removePaths: provisionExists ? [provisionPath] : [],
128725
128777
  stagePaths
128726
128778
  });
128727
128779
  return {
@@ -129179,6 +129231,7 @@ async function runAction(actionCore = core_exports, actionExec = exec_exports) {
129179
129231
  assertPathWithinCwd,
129180
129232
  createRepoSyncDependencies,
129181
129233
  getInput,
129234
+ hasInput,
129182
129235
  readActionInputs,
129183
129236
  resolveInputs,
129184
129237
  resolvePostmanApiKeyAndTeamId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postman-cse/onboarding-repo-sync",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Postman repo sync GitHub Action.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -17,7 +17,7 @@
17
17
  "scripts": {
18
18
  "prepare": "git config core.hooksPath .githooks",
19
19
  "build": "npm run typecheck && rm -rf dist && esbuild src/index.ts --bundle --platform=node --target=node24 --format=cjs --outfile=dist/index.cjs && esbuild src/main.ts --bundle --platform=node --target=node24 --format=cjs --outfile=dist/action.cjs && esbuild src/cli.ts --bundle --platform=node --target=node24 --format=cjs --outfile=dist/cli.cjs",
20
- "verify:dist": "npm run build && git diff --ignore-space-at-eol --text --exit-code -- dist",
20
+ "verify:dist": "npm run build && node -e \"const fs=require('fs');const p='dist/cli.cjs';const s=fs.readFileSync(p,'utf8');if(!s.startsWith('#!/usr/bin/env node\\n')){console.error('dist/cli.cjs missing Node shebang');process.exit(1)}if(!(fs.statSync(p).mode&0o111)){console.error('dist/cli.cjs is not executable');process.exit(1)}\" && git diff --ignore-space-at-eol --text --exit-code -- dist",
21
21
  "docs:tables": "node scripts/render-action-tables.mjs",
22
22
  "lint": "eslint .",
23
23
  "lint:fix": "eslint . --fix",