Skip to content

Commit 0c98051

Browse files
authored
Add listCustomersByName (#54)
* use search endpoint to list customers * prettier
1 parent cbb55e3 commit 0c98051

File tree

9 files changed

+3551
-3218
lines changed

9 files changed

+3551
-3218
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,12 @@ jobs:
1616
with:
1717
registry-url: 'https://registry.npmjs.org/'
1818
node-version-file: 'package.json'
19-
- name: Build
20-
run: make build
21-
22-
- name: Prettier
23-
run: make prettier
24-
25-
- name: fail if files changed
19+
- name: Show versions
2620
run: |
27-
if ! git diff --quiet --exit-code ; then
28-
echo "Please run 'make build' and 'make prettier' locally and commit the changes."
29-
exit 1
30-
fi
21+
echo "Node version: $(node --version)"
22+
echo "npm version: $(npm --version)"
23+
- name: CI Check
24+
run: make ci-check
3125

3226
- name: Test
3327
run: make test

Makefile

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,60 @@
11

22

3+
.PHONY: clean
4+
clean:
5+
rm -rf dist
6+
rm -rf coverage
7+
rm -rf examples/*.js
8+
find . -name "*.tsbuildinfo" -delete
9+
310
.PHONY: deps
411
deps:
5-
npm i
12+
npm install
613

714
.PHONY: build
8-
build: deps
15+
build: clean deps
916
npm run build
1017

1118
.PHONY: test
1219
test: build
1320
npm run test
1421

1522
.PHONY: prettier
16-
prettier:
23+
prettier: deps
1724
npm run prettier
25+
26+
.PHONY: prettier-check
27+
prettier-check: deps
28+
npx prettier --config .prettierrc 'src/**/*.ts' --check
1829

30+
.PHONY: ci-check
31+
ci-check: deps build prettier
32+
@echo "Checking for uncommitted changes..."
33+
@if ! git diff --quiet --exit-code; then \
34+
echo "❌ Error: Files were modified by 'npm install', build, or prettier"; \
35+
echo "Modified files:"; \
36+
git diff --name-only; \
37+
echo ""; \
38+
if git diff --quiet package-lock.json 2>/dev/null; then \
39+
echo "Please run 'make build' and 'make prettier' locally and commit the changes."; \
40+
else \
41+
echo "package-lock.json was modified. Checking if it's just peer metadata differences..."; \
42+
git diff package-lock.json > /tmp/package-lock.diff; \
43+
if grep -q '^[+-].*"peer":' /tmp/package-lock.diff && ! grep -qvE '^[+-].*"peer":|^[+-]---|^[+]\+\+\+|^@@' /tmp/package-lock.diff; then \
44+
echo "⚠️ Only peer metadata differences detected. These are harmless but should be normalized."; \
45+
echo " Run 'npm install --package-lock-only' locally and commit the updated package-lock.json"; \
46+
else \
47+
echo "package-lock.json has significant differences (not just peer metadata)"; \
48+
echo "Please run 'npm install' locally and commit the updated package-lock.json"; \
49+
fi; \
50+
echo ""; \
51+
echo "Differences in package-lock.json:"; \
52+
git diff package-lock.json | head -100; \
53+
fi; \
54+
exit 1; \
55+
fi
56+
@echo "✅ No uncommitted changes detected"
57+
1958
.PHONY: publish
2059
publish: test
2160
npm publish

package-lock.json

Lines changed: 3193 additions & 3181 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "Can interact with the vendor portal api!",
55
"scripts": {
66
"build": "rm -rf dist && tsc --build",
7-
"prettier": "prettier --config .prettierrc 'src/**/*.ts' --write",
7+
"prettier": "npx prettier --config .prettierrc 'src/**/*.ts' --write",
88
"test": "npx jest --coverage --verbose --setupFiles ./pacts/configuration.ts",
99
"create-object-store": "rm -rf examples/*.js && tsc examples/create-object-store.ts && node examples/create-object-store.js",
1010
"create-postgres": "rm -rf examples/*.js && tsc examples/create-postgres.ts && node examples/create-postgres.js",

scripts/verify-ci-match.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
# Script to verify local environment matches CI exactly
3+
4+
set -e
5+
6+
echo "=== Verifying local matches CI ==="
7+
echo ""
8+
9+
# Check npm and node versions
10+
echo "1. Checking versions..."
11+
NPM_VERSION=$(npm --version)
12+
NODE_VERSION=$(node --version)
13+
echo " npm: $NPM_VERSION"
14+
echo " node: $NODE_VERSION"
15+
echo ""
16+
17+
# Clean state
18+
echo "2. Cleaning node_modules and dist..."
19+
rm -rf node_modules dist coverage
20+
21+
# Install exactly as CI does (npm install, not npm ci)
22+
echo "3. Installing with 'npm install' (as CI does)..."
23+
npm install
24+
25+
# Check if package-lock.json was modified
26+
if ! git diff --quiet --exit-code package-lock.json; then
27+
echo "❌ package-lock.json was modified by npm install!"
28+
echo " This means it's out of sync with package.json"
29+
echo " Differences:"
30+
git diff package-lock.json | head -50
31+
echo ""
32+
echo " To fix:"
33+
echo " 1. Review the changes above"
34+
echo " 2. Commit the updated package-lock.json"
35+
exit 1
36+
fi
37+
echo "✅ package-lock.json is up to date"
38+
echo ""
39+
40+
# Build and check for changes
41+
echo "5. Building..."
42+
npm run build
43+
44+
echo "6. Running prettier..."
45+
npm run prettier
46+
47+
echo "7. Checking for uncommitted changes..."
48+
if ! git diff --quiet --exit-code; then
49+
echo "❌ Files were modified:"
50+
git diff --name-only
51+
echo ""
52+
echo " Differences:"
53+
git diff | head -100
54+
exit 1
55+
fi
56+
57+
echo "✅ Everything matches CI!"
58+
echo ""
59+
echo "Your local environment matches what CI will produce."
60+

src/channels.spec.ts

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,18 @@ describe("ChannelsService", () => {
8484
});
8585

8686
describe("pollForAirgapReleaseStatus", () => {
87-
const mockServer = mockttp.getLocal();
87+
let mockServer: mockttp.Mockttp;
8888
const apiClient = new VendorPortalApi();
8989
apiClient.apiToken = "abcd1234";
90-
apiClient.endpoint = "http://localhost:8080";
91-
// Start your mock server
92-
beforeEach(() => {
93-
mockServer.start(8080);
90+
91+
beforeEach(async () => {
92+
mockServer = mockttp.getLocal();
93+
await mockServer.start();
94+
apiClient.endpoint = "http://localhost:" + mockServer.port;
95+
});
96+
afterEach(async () => {
97+
await mockServer.stop();
9498
});
95-
afterEach(() => mockServer.stop());
9699

97100
it("should poll for airgapped release status until it reaches the expected status", async () => {
98101
const releaseData = {
@@ -105,23 +108,26 @@ describe("pollForAirgapReleaseStatus", () => {
105108
]
106109
};
107110

108-
await mockServer.forGet("/app/1234abcd/channel/1/releases").thenReply(200, JSON.stringify(releaseData));
111+
await mockServer.forGet("/app/1234abcd/channel/1/releases").once().thenReply(200, JSON.stringify(releaseData));
109112

110113
const releaseResult = await pollForAirgapReleaseStatus(apiClient, "1234abcd", "1", 0, "built");
111114
expect(releaseResult).toEqual("built");
112115
});
113116
});
114117

115118
describe("getDownloadUrlAirgapBuildRelease", () => {
116-
const mockServer = mockttp.getLocal();
119+
let mockServer: mockttp.Mockttp;
117120
const apiClient = new VendorPortalApi();
118121
apiClient.apiToken = "abcd1234";
119-
apiClient.endpoint = "http://localhost:8081";
120-
// Start your mock server
121-
beforeEach(() => {
122-
mockServer.start(8081);
122+
123+
beforeEach(async () => {
124+
mockServer = mockttp.getLocal();
125+
await mockServer.start();
126+
apiClient.endpoint = "http://localhost:" + mockServer.port;
127+
});
128+
afterEach(async () => {
129+
await mockServer.stop();
123130
});
124-
afterEach(() => mockServer.stop());
125131

126132
it("should get the download URL for an airgap build release", async () => {
127133
const releaseData = {
@@ -137,8 +143,8 @@ describe("getDownloadUrlAirgapBuildRelease", () => {
137143
url: "https://s3.amazonaws.com/airgap.replicated.com/xxxxxxxxx/7.airgap?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxx%2F20250317%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date="
138144
};
139145

140-
await mockServer.forGet("/app/1234abcd/channel/1/releases").thenReply(200, JSON.stringify(releaseData));
141-
await mockServer.forGet("/app/1234abcd/channel/1/airgap/download-url").withQuery({ channelSequence: 1 }).thenReply(200, JSON.stringify(downloadUrlData));
146+
await mockServer.forGet("/app/1234abcd/channel/1/releases").once().thenReply(200, JSON.stringify(releaseData));
147+
await mockServer.forGet("/app/1234abcd/channel/1/airgap/download-url").withQuery({ channelSequence: 1 }).once().thenReply(200, JSON.stringify(downloadUrlData));
142148

143149
const downloadUrlResult = await getDownloadUrlAirgapBuildRelease(apiClient, "1234abcd", "1", 0);
144150
expect(downloadUrlResult).toEqual("https://s3.amazonaws.com/airgap.replicated.com/xxxxxxxxx/7.airgap?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=xxxxxx%2F20250317%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=");

0 commit comments

Comments
 (0)