@postman-cse/onboarding-repo-sync 2.1.2 → 2.1.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/action.cjs +54 -10
- package/dist/cli.cjs +54 -10
- package/dist/index.cjs +54 -10
- package/package.json +2 -2
package/dist/action.cjs
CHANGED
|
@@ -128699,10 +128699,33 @@ function writeJsonFile(path9, content, normalize3 = false) {
|
|
|
128699
128699
|
const data = normalize3 ? stripVolatileFields(content) : content;
|
|
128700
128700
|
(0, import_node_fs3.writeFileSync)(path9, JSON.stringify(data, null, 2));
|
|
128701
128701
|
}
|
|
128702
|
-
function
|
|
128703
|
-
|
|
128704
|
-
|
|
128705
|
-
}
|
|
128702
|
+
function buildMappedSpecCloudKey(mappedSource, specSyncMode, releaseLabel) {
|
|
128703
|
+
if (specSyncMode !== "version") {
|
|
128704
|
+
return mappedSource;
|
|
128705
|
+
}
|
|
128706
|
+
const normalized = normalizeReleaseLabel(releaseLabel || "");
|
|
128707
|
+
if (!normalized) {
|
|
128708
|
+
return void 0;
|
|
128709
|
+
}
|
|
128710
|
+
return `${mappedSource}#release=${normalized}`;
|
|
128711
|
+
}
|
|
128712
|
+
function resolveDurableWorkspaceId(options) {
|
|
128713
|
+
const { candidateId, priorId, workspaceLinkEnabled, workspaceLinkStatus } = options;
|
|
128714
|
+
const candidate = candidateId.trim();
|
|
128715
|
+
const prior = priorId?.trim() || void 0;
|
|
128716
|
+
if (!workspaceLinkEnabled) {
|
|
128717
|
+
return candidate || prior;
|
|
128718
|
+
}
|
|
128719
|
+
if (workspaceLinkStatus === "success") {
|
|
128720
|
+
return candidate || void 0;
|
|
128721
|
+
}
|
|
128722
|
+
return prior === candidate ? prior : void 0;
|
|
128723
|
+
}
|
|
128724
|
+
function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir, localSpecRefs, mappedSpecRef, specId, existingSpecs) {
|
|
128725
|
+
const manifest = {};
|
|
128726
|
+
if (workspaceId) {
|
|
128727
|
+
manifest.workspace = { id: workspaceId };
|
|
128728
|
+
}
|
|
128706
128729
|
const localResources = {};
|
|
128707
128730
|
const cloudResources = {};
|
|
128708
128731
|
const collectionKeys = Object.keys(collectionMap);
|
|
@@ -128723,8 +128746,12 @@ function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir,
|
|
|
128723
128746
|
if (localSpecRefs.length > 0) {
|
|
128724
128747
|
localResources.specs = localSpecRefs;
|
|
128725
128748
|
}
|
|
128749
|
+
const specs = { ...existingSpecs || {} };
|
|
128726
128750
|
if (mappedSpecRef && specId) {
|
|
128727
|
-
|
|
128751
|
+
specs[mappedSpecRef] = specId;
|
|
128752
|
+
}
|
|
128753
|
+
if (Object.keys(specs).length > 0) {
|
|
128754
|
+
cloudResources.specs = specs;
|
|
128728
128755
|
}
|
|
128729
128756
|
if (Object.keys(localResources).length > 0) {
|
|
128730
128757
|
manifest.localResources = localResources;
|
|
@@ -128791,7 +128818,7 @@ function assertPathWithinCwd(targetPath, fieldName) {
|
|
|
128791
128818
|
throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
|
|
128792
128819
|
}
|
|
128793
128820
|
}
|
|
128794
|
-
async function exportArtifacts(inputs, dependencies, envUids, assetProjectName) {
|
|
128821
|
+
async function exportArtifacts(inputs, dependencies, envUids, assetProjectName, options) {
|
|
128795
128822
|
if (!inputs.workspaceId) {
|
|
128796
128823
|
return;
|
|
128797
128824
|
}
|
|
@@ -128825,6 +128852,11 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
|
|
|
128825
128852
|
const manifestCollections = {};
|
|
128826
128853
|
const discoveredSpecs = scanLocalSpecReferences();
|
|
128827
128854
|
const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
|
|
128855
|
+
const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
|
|
128856
|
+
mappedSpec.configRelativePath,
|
|
128857
|
+
inputs.specSyncMode,
|
|
128858
|
+
options.releaseLabel
|
|
128859
|
+
) : void 0;
|
|
128828
128860
|
if (inputs.baselineCollectionId) {
|
|
128829
128861
|
const col = await dependencies.postman.getCollection(inputs.baselineCollectionId);
|
|
128830
128862
|
const dirName = getCollectionDirectoryName("Baseline", assetProjectName);
|
|
@@ -128850,14 +128882,21 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
|
|
|
128850
128882
|
true
|
|
128851
128883
|
);
|
|
128852
128884
|
}
|
|
128885
|
+
const durableWorkspaceId = resolveDurableWorkspaceId({
|
|
128886
|
+
candidateId: inputs.workspaceId,
|
|
128887
|
+
priorId: options.priorWorkspaceId,
|
|
128888
|
+
workspaceLinkEnabled: inputs.workspaceLinkEnabled,
|
|
128889
|
+
workspaceLinkStatus: options.workspaceLinkStatus
|
|
128890
|
+
});
|
|
128853
128891
|
(0, import_node_fs3.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
|
|
128854
|
-
|
|
128892
|
+
durableWorkspaceId,
|
|
128855
128893
|
manifestCollections,
|
|
128856
128894
|
envUids,
|
|
128857
128895
|
inputs.artifactDir,
|
|
128858
128896
|
discoveredSpecs.map((spec) => spec.configRelativePath),
|
|
128859
|
-
|
|
128860
|
-
inputs.specId || void 0
|
|
128897
|
+
mappedSpecCloudKey,
|
|
128898
|
+
inputs.specId || void 0,
|
|
128899
|
+
options.existingSpecs
|
|
128861
128900
|
));
|
|
128862
128901
|
if (mappedSpec && Object.keys(manifestCollections).length > 0) {
|
|
128863
128902
|
(0, import_node_fs3.writeFileSync)(
|
|
@@ -129116,7 +129155,12 @@ async function runRepoSyncInner(inputs, dependencies) {
|
|
|
129116
129155
|
);
|
|
129117
129156
|
}
|
|
129118
129157
|
}
|
|
129119
|
-
await exportArtifacts(inputs, dependencies, envUids, assetProjectName
|
|
129158
|
+
await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
|
|
129159
|
+
workspaceLinkStatus: outputs["workspace-link-status"],
|
|
129160
|
+
priorWorkspaceId: resourcesState?.workspace?.id,
|
|
129161
|
+
existingSpecs: resourcesState?.cloudResources?.specs,
|
|
129162
|
+
releaseLabel
|
|
129163
|
+
});
|
|
129120
129164
|
const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
|
|
129121
129165
|
outputs["commit-sha"] = commit.commitSha;
|
|
129122
129166
|
if (commit.resolvedCurrentRef) {
|
package/dist/cli.cjs
CHANGED
|
@@ -126613,10 +126613,33 @@ function writeJsonFile(path5, content, normalize3 = false) {
|
|
|
126613
126613
|
const data = normalize3 ? stripVolatileFields(content) : content;
|
|
126614
126614
|
(0, import_node_fs3.writeFileSync)(path5, JSON.stringify(data, null, 2));
|
|
126615
126615
|
}
|
|
126616
|
-
function
|
|
126617
|
-
|
|
126618
|
-
|
|
126619
|
-
}
|
|
126616
|
+
function buildMappedSpecCloudKey(mappedSource, specSyncMode, releaseLabel) {
|
|
126617
|
+
if (specSyncMode !== "version") {
|
|
126618
|
+
return mappedSource;
|
|
126619
|
+
}
|
|
126620
|
+
const normalized = normalizeReleaseLabel(releaseLabel || "");
|
|
126621
|
+
if (!normalized) {
|
|
126622
|
+
return void 0;
|
|
126623
|
+
}
|
|
126624
|
+
return `${mappedSource}#release=${normalized}`;
|
|
126625
|
+
}
|
|
126626
|
+
function resolveDurableWorkspaceId(options) {
|
|
126627
|
+
const { candidateId, priorId, workspaceLinkEnabled, workspaceLinkStatus } = options;
|
|
126628
|
+
const candidate = candidateId.trim();
|
|
126629
|
+
const prior = priorId?.trim() || void 0;
|
|
126630
|
+
if (!workspaceLinkEnabled) {
|
|
126631
|
+
return candidate || prior;
|
|
126632
|
+
}
|
|
126633
|
+
if (workspaceLinkStatus === "success") {
|
|
126634
|
+
return candidate || void 0;
|
|
126635
|
+
}
|
|
126636
|
+
return prior === candidate ? prior : void 0;
|
|
126637
|
+
}
|
|
126638
|
+
function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir, localSpecRefs, mappedSpecRef, specId, existingSpecs) {
|
|
126639
|
+
const manifest = {};
|
|
126640
|
+
if (workspaceId) {
|
|
126641
|
+
manifest.workspace = { id: workspaceId };
|
|
126642
|
+
}
|
|
126620
126643
|
const localResources = {};
|
|
126621
126644
|
const cloudResources = {};
|
|
126622
126645
|
const collectionKeys = Object.keys(collectionMap);
|
|
@@ -126637,8 +126660,12 @@ function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir,
|
|
|
126637
126660
|
if (localSpecRefs.length > 0) {
|
|
126638
126661
|
localResources.specs = localSpecRefs;
|
|
126639
126662
|
}
|
|
126663
|
+
const specs = { ...existingSpecs || {} };
|
|
126640
126664
|
if (mappedSpecRef && specId) {
|
|
126641
|
-
|
|
126665
|
+
specs[mappedSpecRef] = specId;
|
|
126666
|
+
}
|
|
126667
|
+
if (Object.keys(specs).length > 0) {
|
|
126668
|
+
cloudResources.specs = specs;
|
|
126642
126669
|
}
|
|
126643
126670
|
if (Object.keys(localResources).length > 0) {
|
|
126644
126671
|
manifest.localResources = localResources;
|
|
@@ -126705,7 +126732,7 @@ function assertPathWithinCwd(targetPath, fieldName) {
|
|
|
126705
126732
|
throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
|
|
126706
126733
|
}
|
|
126707
126734
|
}
|
|
126708
|
-
async function exportArtifacts(inputs, dependencies, envUids, assetProjectName) {
|
|
126735
|
+
async function exportArtifacts(inputs, dependencies, envUids, assetProjectName, options) {
|
|
126709
126736
|
if (!inputs.workspaceId) {
|
|
126710
126737
|
return;
|
|
126711
126738
|
}
|
|
@@ -126739,6 +126766,11 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
|
|
|
126739
126766
|
const manifestCollections = {};
|
|
126740
126767
|
const discoveredSpecs = scanLocalSpecReferences();
|
|
126741
126768
|
const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
|
|
126769
|
+
const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
|
|
126770
|
+
mappedSpec.configRelativePath,
|
|
126771
|
+
inputs.specSyncMode,
|
|
126772
|
+
options.releaseLabel
|
|
126773
|
+
) : void 0;
|
|
126742
126774
|
if (inputs.baselineCollectionId) {
|
|
126743
126775
|
const col = await dependencies.postman.getCollection(inputs.baselineCollectionId);
|
|
126744
126776
|
const dirName = getCollectionDirectoryName("Baseline", assetProjectName);
|
|
@@ -126764,14 +126796,21 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
|
|
|
126764
126796
|
true
|
|
126765
126797
|
);
|
|
126766
126798
|
}
|
|
126799
|
+
const durableWorkspaceId = resolveDurableWorkspaceId({
|
|
126800
|
+
candidateId: inputs.workspaceId,
|
|
126801
|
+
priorId: options.priorWorkspaceId,
|
|
126802
|
+
workspaceLinkEnabled: inputs.workspaceLinkEnabled,
|
|
126803
|
+
workspaceLinkStatus: options.workspaceLinkStatus
|
|
126804
|
+
});
|
|
126767
126805
|
(0, import_node_fs3.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
|
|
126768
|
-
|
|
126806
|
+
durableWorkspaceId,
|
|
126769
126807
|
manifestCollections,
|
|
126770
126808
|
envUids,
|
|
126771
126809
|
inputs.artifactDir,
|
|
126772
126810
|
discoveredSpecs.map((spec) => spec.configRelativePath),
|
|
126773
|
-
|
|
126774
|
-
inputs.specId || void 0
|
|
126811
|
+
mappedSpecCloudKey,
|
|
126812
|
+
inputs.specId || void 0,
|
|
126813
|
+
options.existingSpecs
|
|
126775
126814
|
));
|
|
126776
126815
|
if (mappedSpec && Object.keys(manifestCollections).length > 0) {
|
|
126777
126816
|
(0, import_node_fs3.writeFileSync)(
|
|
@@ -127030,7 +127069,12 @@ async function runRepoSyncInner(inputs, dependencies) {
|
|
|
127030
127069
|
);
|
|
127031
127070
|
}
|
|
127032
127071
|
}
|
|
127033
|
-
await exportArtifacts(inputs, dependencies, envUids, assetProjectName
|
|
127072
|
+
await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
|
|
127073
|
+
workspaceLinkStatus: outputs["workspace-link-status"],
|
|
127074
|
+
priorWorkspaceId: resourcesState?.workspace?.id,
|
|
127075
|
+
existingSpecs: resourcesState?.cloudResources?.specs,
|
|
127076
|
+
releaseLabel
|
|
127077
|
+
});
|
|
127034
127078
|
const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
|
|
127035
127079
|
outputs["commit-sha"] = commit.commitSha;
|
|
127036
127080
|
if (commit.resolvedCurrentRef) {
|
package/dist/index.cjs
CHANGED
|
@@ -128714,10 +128714,33 @@ function writeJsonFile(path9, content, normalize3 = false) {
|
|
|
128714
128714
|
const data = normalize3 ? stripVolatileFields(content) : content;
|
|
128715
128715
|
(0, import_node_fs3.writeFileSync)(path9, JSON.stringify(data, null, 2));
|
|
128716
128716
|
}
|
|
128717
|
-
function
|
|
128718
|
-
|
|
128719
|
-
|
|
128720
|
-
}
|
|
128717
|
+
function buildMappedSpecCloudKey(mappedSource, specSyncMode, releaseLabel) {
|
|
128718
|
+
if (specSyncMode !== "version") {
|
|
128719
|
+
return mappedSource;
|
|
128720
|
+
}
|
|
128721
|
+
const normalized = normalizeReleaseLabel(releaseLabel || "");
|
|
128722
|
+
if (!normalized) {
|
|
128723
|
+
return void 0;
|
|
128724
|
+
}
|
|
128725
|
+
return `${mappedSource}#release=${normalized}`;
|
|
128726
|
+
}
|
|
128727
|
+
function resolveDurableWorkspaceId(options) {
|
|
128728
|
+
const { candidateId, priorId, workspaceLinkEnabled, workspaceLinkStatus } = options;
|
|
128729
|
+
const candidate = candidateId.trim();
|
|
128730
|
+
const prior = priorId?.trim() || void 0;
|
|
128731
|
+
if (!workspaceLinkEnabled) {
|
|
128732
|
+
return candidate || prior;
|
|
128733
|
+
}
|
|
128734
|
+
if (workspaceLinkStatus === "success") {
|
|
128735
|
+
return candidate || void 0;
|
|
128736
|
+
}
|
|
128737
|
+
return prior === candidate ? prior : void 0;
|
|
128738
|
+
}
|
|
128739
|
+
function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir, localSpecRefs, mappedSpecRef, specId, existingSpecs) {
|
|
128740
|
+
const manifest = {};
|
|
128741
|
+
if (workspaceId) {
|
|
128742
|
+
manifest.workspace = { id: workspaceId };
|
|
128743
|
+
}
|
|
128721
128744
|
const localResources = {};
|
|
128722
128745
|
const cloudResources = {};
|
|
128723
128746
|
const collectionKeys = Object.keys(collectionMap);
|
|
@@ -128738,8 +128761,12 @@ function buildResourcesManifest(workspaceId, collectionMap, envMap, artifactDir,
|
|
|
128738
128761
|
if (localSpecRefs.length > 0) {
|
|
128739
128762
|
localResources.specs = localSpecRefs;
|
|
128740
128763
|
}
|
|
128764
|
+
const specs = { ...existingSpecs || {} };
|
|
128741
128765
|
if (mappedSpecRef && specId) {
|
|
128742
|
-
|
|
128766
|
+
specs[mappedSpecRef] = specId;
|
|
128767
|
+
}
|
|
128768
|
+
if (Object.keys(specs).length > 0) {
|
|
128769
|
+
cloudResources.specs = specs;
|
|
128743
128770
|
}
|
|
128744
128771
|
if (Object.keys(localResources).length > 0) {
|
|
128745
128772
|
manifest.localResources = localResources;
|
|
@@ -128806,7 +128833,7 @@ function assertPathWithinCwd(targetPath, fieldName) {
|
|
|
128806
128833
|
throw new Error(`${fieldName} must stay within the repository root; received ${targetPath}`);
|
|
128807
128834
|
}
|
|
128808
128835
|
}
|
|
128809
|
-
async function exportArtifacts(inputs, dependencies, envUids, assetProjectName) {
|
|
128836
|
+
async function exportArtifacts(inputs, dependencies, envUids, assetProjectName, options) {
|
|
128810
128837
|
if (!inputs.workspaceId) {
|
|
128811
128838
|
return;
|
|
128812
128839
|
}
|
|
@@ -128840,6 +128867,11 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
|
|
|
128840
128867
|
const manifestCollections = {};
|
|
128841
128868
|
const discoveredSpecs = scanLocalSpecReferences();
|
|
128842
128869
|
const mappedSpec = resolveMappedSpecReference(inputs.specPath, discoveredSpecs);
|
|
128870
|
+
const mappedSpecCloudKey = mappedSpec && inputs.specId ? buildMappedSpecCloudKey(
|
|
128871
|
+
mappedSpec.configRelativePath,
|
|
128872
|
+
inputs.specSyncMode,
|
|
128873
|
+
options.releaseLabel
|
|
128874
|
+
) : void 0;
|
|
128843
128875
|
if (inputs.baselineCollectionId) {
|
|
128844
128876
|
const col = await dependencies.postman.getCollection(inputs.baselineCollectionId);
|
|
128845
128877
|
const dirName = getCollectionDirectoryName("Baseline", assetProjectName);
|
|
@@ -128865,14 +128897,21 @@ async function exportArtifacts(inputs, dependencies, envUids, assetProjectName)
|
|
|
128865
128897
|
true
|
|
128866
128898
|
);
|
|
128867
128899
|
}
|
|
128900
|
+
const durableWorkspaceId = resolveDurableWorkspaceId({
|
|
128901
|
+
candidateId: inputs.workspaceId,
|
|
128902
|
+
priorId: options.priorWorkspaceId,
|
|
128903
|
+
workspaceLinkEnabled: inputs.workspaceLinkEnabled,
|
|
128904
|
+
workspaceLinkStatus: options.workspaceLinkStatus
|
|
128905
|
+
});
|
|
128868
128906
|
(0, import_node_fs3.writeFileSync)(".postman/resources.yaml", buildResourcesManifest(
|
|
128869
|
-
|
|
128907
|
+
durableWorkspaceId,
|
|
128870
128908
|
manifestCollections,
|
|
128871
128909
|
envUids,
|
|
128872
128910
|
inputs.artifactDir,
|
|
128873
128911
|
discoveredSpecs.map((spec) => spec.configRelativePath),
|
|
128874
|
-
|
|
128875
|
-
inputs.specId || void 0
|
|
128912
|
+
mappedSpecCloudKey,
|
|
128913
|
+
inputs.specId || void 0,
|
|
128914
|
+
options.existingSpecs
|
|
128876
128915
|
));
|
|
128877
128916
|
if (mappedSpec && Object.keys(manifestCollections).length > 0) {
|
|
128878
128917
|
(0, import_node_fs3.writeFileSync)(
|
|
@@ -129131,7 +129170,12 @@ async function runRepoSyncInner(inputs, dependencies) {
|
|
|
129131
129170
|
);
|
|
129132
129171
|
}
|
|
129133
129172
|
}
|
|
129134
|
-
await exportArtifacts(inputs, dependencies, envUids, assetProjectName
|
|
129173
|
+
await exportArtifacts(inputs, dependencies, envUids, assetProjectName, {
|
|
129174
|
+
workspaceLinkStatus: outputs["workspace-link-status"],
|
|
129175
|
+
priorWorkspaceId: resourcesState?.workspace?.id,
|
|
129176
|
+
existingSpecs: resourcesState?.cloudResources?.specs,
|
|
129177
|
+
releaseLabel
|
|
129178
|
+
});
|
|
129135
129179
|
const commit = await commitAndPushGeneratedFiles(inputs, dependencies);
|
|
129136
129180
|
outputs["commit-sha"] = commit.commitSha;
|
|
129137
129181
|
if (commit.resolvedCurrentRef) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postman-cse/onboarding-repo-sync",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Postman repo sync GitHub Action.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"docs:tables": "node scripts/render-action-tables.mjs",
|
|
22
22
|
"lint": "eslint .",
|
|
23
23
|
"lint:fix": "eslint . --fix",
|
|
24
|
-
"test": "vitest run",
|
|
24
|
+
"test": "vitest run && node --test .github/scripts/wait-for-e2e-gate.test.mjs",
|
|
25
25
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
26
26
|
},
|
|
27
27
|
"keywords": [
|