@dk/jolly 0.2.0 → 0.3.0
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/README.md +7 -5
- package/bin/jolly +9 -22
- package/{src/index.ts → dist/index.js} +782 -825
- package/package.json +14 -10
- package/src/lib/cloud-api.ts +0 -555
- package/src/lib/env-file.ts +0 -68
- package/src/lib/saleor-url.ts +0 -37
package/src/lib/saleor-url.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Normalizes a pasted Saleor URL to the canonical GraphQL endpoint.
|
|
2
|
-
// Contract (see features/step_definitions/012-existing-saleor-store-connection.steps.ts):
|
|
3
|
-
// normalizeSaleorUrl(input) -> { endpoint: string | null; clarification?: string }
|
|
4
|
-
// Accepted forms: Saleor Dashboard URL, storefront API (GraphQL) URL with or
|
|
5
|
-
// without a trailing slash, and the root Saleor Cloud URL — all normalize to
|
|
6
|
-
// `https://<host>/graphql/`. Anything that cannot be normalized safely yields
|
|
7
|
-
// `endpoint: null` plus a clarifying question.
|
|
8
|
-
|
|
9
|
-
export interface NormalizedSaleorUrl {
|
|
10
|
-
endpoint: string | null;
|
|
11
|
-
clarification?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const CLARIFICATION =
|
|
15
|
-
"That doesn't look like a Saleor URL I can use. Could you paste your Saleor Dashboard URL, " +
|
|
16
|
-
"GraphQL API URL, or root Saleor Cloud URL (for example https://your-store.eu.saleor.cloud)?";
|
|
17
|
-
|
|
18
|
-
export function normalizeSaleorUrl(input: string): NormalizedSaleorUrl {
|
|
19
|
-
let url: URL;
|
|
20
|
-
try {
|
|
21
|
-
url = new URL(input.trim());
|
|
22
|
-
} catch {
|
|
23
|
-
return { endpoint: null, clarification: CLARIFICATION };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (url.protocol !== "https:" && url.protocol !== "http:") {
|
|
27
|
-
return { endpoint: null, clarification: CLARIFICATION };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const path = url.pathname.replace(/\/+$/, ""); // strip trailing slashes
|
|
31
|
-
const recognized = path === "" || path === "/graphql" || path === "/dashboard" || /^\/dashboard\//.test(url.pathname);
|
|
32
|
-
if (!recognized) {
|
|
33
|
-
return { endpoint: null, clarification: CLARIFICATION };
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return { endpoint: `${url.protocol}//${url.host}/graphql/` };
|
|
37
|
-
}
|