which-url 0.0.9 → 0.0.11
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 +59 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/types.d.ts +5 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Auto-detect your app's URL across hosting providers. Zero config.
|
|
4
4
|
|
|
5
|
+
This README documents `which-url@0.0.11`.
|
|
6
|
+
|
|
5
7
|
```bash
|
|
6
8
|
npm install which-url
|
|
7
9
|
```
|
|
@@ -22,16 +24,20 @@ Production https://myapp.com "production"
|
|
|
22
24
|
|
|
23
25
|
Works across environments (local, preview, production), browser bundles, Node/Bun servers, and edge runtimes that expose compatible env vars through `process.env` or build-time public env replacement.
|
|
24
26
|
|
|
27
|
+
For browser bundles, framework-prefixed env vars must be referenced statically so the bundler can inline them at build time. `which-url` includes literal references such as `process.env.NEXT_PUBLIC_APP_URL` and `process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL`; dynamic lookup like `process.env["NEXT_PUBLIC_" + name]` cannot be inlined by Next.js.
|
|
28
|
+
|
|
25
29
|
The default export gives you everything as an object:
|
|
26
30
|
|
|
27
31
|
```typescript
|
|
28
32
|
import appUrl from 'which-url'
|
|
29
33
|
|
|
30
34
|
appUrl.origin // "https://myapp.com"
|
|
35
|
+
appUrl.productionOrigin // "https://myapp.com" or undefined
|
|
31
36
|
appUrl.hostname // "myapp.com"
|
|
32
37
|
appUrl.protocol // "https:"
|
|
33
38
|
appUrl.env // "production"
|
|
34
39
|
appUrl.platform // "vercel"
|
|
40
|
+
appUrl.isResolved // true
|
|
35
41
|
appUrl.isProduction // true
|
|
36
42
|
```
|
|
37
43
|
|
|
@@ -87,7 +93,11 @@ Reads environment variables that hosting providers set automatically:
|
|
|
87
93
|
|
|
88
94
|
When you call `createUrl({ env })`, the passed object replaces `process.env` as the source for steps 1–2.
|
|
89
95
|
|
|
90
|
-
If nothing is detected in production, the default singleton returns empty URL strings so imports stay safe in tests, client bundles, and build tools. Call `createUrl()` directly when a missing URL should throw.
|
|
96
|
+
If nothing is detected in production, the default singleton returns empty current-URL strings and `isResolved: false` so imports stay safe in tests, client bundles, and build tools. Call `createUrl()` directly when a missing current URL should throw.
|
|
97
|
+
|
|
98
|
+
`origin` is the current environment origin. In a preview deployment, it should point at the preview. In production, it should point at production. Locally, it should point at local dev.
|
|
99
|
+
|
|
100
|
+
`productionOrigin` is the canonical production origin when configured or detectable, otherwise `undefined`. Use it for things that should still point at the public production site from previews, such as canonical metadata, social cards, and "view live site" links. When you need a URL in all environments, use `productionOrigin ?? origin`.
|
|
91
101
|
|
|
92
102
|
## Strict mode with `createUrl()`
|
|
93
103
|
|
|
@@ -109,6 +119,18 @@ auth({ baseURL: appUrl.origin })
|
|
|
109
119
|
|
|
110
120
|
`createUrl()` resolves fresh environment values when called. If no URL can be detected in production, it throws with instructions to set `APP_URL`.
|
|
111
121
|
|
|
122
|
+
If you intentionally use the import-safe singleton in production code, branch on `isResolved` before trusting URL strings:
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
import { isResolved, origin } from 'which-url'
|
|
126
|
+
|
|
127
|
+
if (!isResolved) {
|
|
128
|
+
throw new Error('APP_URL is required in production')
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
auth({ baseURL: origin })
|
|
132
|
+
```
|
|
133
|
+
|
|
112
134
|
For runtimes that pass env as an argument (e.g. Cloudflare Workers), call `createUrl({ env })` and the passed object replaces `process.env` for that resolution. See [Cloudflare Workers](#cloudflare-workers) below.
|
|
113
135
|
|
|
114
136
|
## Override with `APP_URL`
|
|
@@ -122,7 +144,40 @@ APP_URL=https://myapp.com
|
|
|
122
144
|
|
|
123
145
|
Works with or without protocol (`APP_URL=myapp.com` → `https://myapp.com`).
|
|
124
146
|
|
|
125
|
-
**Client-side frameworks:** All framework prefixes are supported automatically — `NEXT_PUBLIC_APP_URL`, `VITE_APP_URL`, `PUBLIC_APP_URL`, `NUXT_ENV_APP_URL`, etc.
|
|
147
|
+
**Client-side frameworks:** All framework prefixes are supported automatically — `NEXT_PUBLIC_APP_URL`, `VITE_APP_URL`, `PUBLIC_APP_URL`, `NUXT_ENV_APP_URL`, etc. These are build-time values in browser bundles.
|
|
148
|
+
|
|
149
|
+
## Production URL
|
|
150
|
+
|
|
151
|
+
Use `APP_PRODUCTION_URL` when the canonical production URL is different from the current environment URL:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
APP_PRODUCTION_URL=https://myapp.com
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```typescript
|
|
158
|
+
import { origin, productionOrigin } from 'which-url'
|
|
159
|
+
|
|
160
|
+
origin // current environment origin
|
|
161
|
+
productionOrigin // canonical production origin, or undefined
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
On Vercel, `productionOrigin` is detected from `VERCEL_PROJECT_PRODUCTION_URL`, even in preview deployments.
|
|
165
|
+
|
|
166
|
+
In Next.js browser bundles on Vercel deployments, it is detected from `NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL`. Vercel adds these framework-prefixed vars for production and preview deployments based on the framework preset, but `vercel env pull` does not create the prefixed local versions automatically.
|
|
167
|
+
|
|
168
|
+
**Client-side frameworks:** Framework prefixes are supported here too — `NEXT_PUBLIC_APP_PRODUCTION_URL`, `VITE_APP_PRODUCTION_URL`, `PUBLIC_APP_PRODUCTION_URL`, etc. These are build-time values in browser bundles.
|
|
169
|
+
|
|
170
|
+
## Multi-tenant apps
|
|
171
|
+
|
|
172
|
+
For subdomain-based tenants, `hostname` is often enough when the current app host is also the tenant suffix:
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
import { hostname } from 'which-url'
|
|
176
|
+
|
|
177
|
+
const tenantSuffix = hostname
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
If your app origin and tenant suffix differ — for example `app.foo.com` for the product UI and `*.foo.com` for tenants — keep that suffix in your own env var for now. `which-url` does not currently expose a separate tenant suffix.
|
|
126
181
|
|
|
127
182
|
## Platform support
|
|
128
183
|
|
|
@@ -255,9 +310,11 @@ Strict resolver function. It resolves when called and throws if no URL can be de
|
|
|
255
310
|
| `href` | `string` | Same as `origin` |
|
|
256
311
|
| `protocol` | `string` | `"https:"` |
|
|
257
312
|
| `port` | `string` | `""` or `"3000"` |
|
|
313
|
+
| `productionOrigin` | `string \| undefined` | `"https://myapp.com"` or `undefined` |
|
|
258
314
|
| `env` | `AppEnv` | `"production"` \| `"preview"` \| `"local"` |
|
|
259
315
|
| `platform` | `Platform` | `"vercel"` \| `"netlify"` \| ... \| `null` |
|
|
260
316
|
| `debug`* | `string` | `"[provider:vercel] url=myapp.com \| env=production (vercel:production)"` |
|
|
317
|
+
| `isResolved` | `boolean` | `true` unless the import-safe fallback was used |
|
|
261
318
|
| `isProduction` | `boolean` | |
|
|
262
319
|
| `isPreview` | `boolean` | |
|
|
263
320
|
| `isLocal` | `boolean` | |
|
package/dist/index.d.ts
CHANGED
|
@@ -13,12 +13,16 @@ export declare const host: string;
|
|
|
13
13
|
export declare const protocol: string;
|
|
14
14
|
/** Port string — `""` for default ports, `"3000"` for custom */
|
|
15
15
|
export declare const port: string;
|
|
16
|
+
/** Canonical production origin when configured or detectable, otherwise `undefined`. */
|
|
17
|
+
export declare const productionOrigin: string | undefined;
|
|
16
18
|
/** Current environment — `"production"`, `"preview"`, or `"local"` */
|
|
17
19
|
export declare const env: AppEnv;
|
|
18
20
|
/** Detected hosting platform — `"vercel"`, `"netlify"`, etc. or `null` */
|
|
19
21
|
export declare const platform: Platform;
|
|
20
22
|
/** Resolution debug string. */
|
|
21
23
|
export declare const debug: string;
|
|
24
|
+
/** `true` when the current URL resolved successfully; `false` only on the import-safe fallback. */
|
|
25
|
+
export declare const isResolved: boolean;
|
|
22
26
|
/** `true` when running in production */
|
|
23
27
|
export declare const isProduction: boolean;
|
|
24
28
|
/** `true` when running in a preview/staging deployment */
|
|
@@ -33,8 +37,10 @@ export declare const isLocal: boolean;
|
|
|
33
37
|
* import appUrl from 'which-url'
|
|
34
38
|
*
|
|
35
39
|
* appUrl.origin // "https://myapp.com"
|
|
40
|
+
* appUrl.productionOrigin // "https://myapp.com" or undefined
|
|
36
41
|
* appUrl.env // "production"
|
|
37
42
|
* appUrl.platform // "vercel"
|
|
43
|
+
* appUrl.isResolved // true
|
|
38
44
|
* appUrl.debug // "[provider:vercel] url=myapp.com | env=production (vercel:production)"
|
|
39
45
|
* ```
|
|
40
46
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=["VERCEL_ENV","VERCEL_URL","VERCEL_BRANCH_URL","VERCEL_PROJECT_PRODUCTION_URL","APP_URL","APP_PRODUCTION_URL","APP_ENV"];function G(E){switch(E){case"VERCEL_ENV":return process.env.VERCEL_ENV||process.env.NEXT_PUBLIC_VERCEL_ENV||process.env.NUXT_ENV_VERCEL_ENV||process.env.VITE_VERCEL_ENV||process.env.PUBLIC_VERCEL_ENV||process.env.REACT_APP_VERCEL_ENV||process.env.GATSBY_VERCEL_ENV||process.env.VUE_APP_VERCEL_ENV||process.env.REDWOOD_ENV_VERCEL_ENV||process.env.SANITY_STUDIO_VERCEL_ENV||void 0;case"VERCEL_URL":return process.env.VERCEL_URL||process.env.NEXT_PUBLIC_VERCEL_URL||process.env.NUXT_ENV_VERCEL_URL||process.env.VITE_VERCEL_URL||process.env.PUBLIC_VERCEL_URL||process.env.REACT_APP_VERCEL_URL||process.env.GATSBY_VERCEL_URL||process.env.VUE_APP_VERCEL_URL||process.env.REDWOOD_ENV_VERCEL_URL||process.env.SANITY_STUDIO_VERCEL_URL||void 0;case"VERCEL_BRANCH_URL":return process.env.VERCEL_BRANCH_URL||process.env.NEXT_PUBLIC_VERCEL_BRANCH_URL||process.env.NUXT_ENV_VERCEL_BRANCH_URL||process.env.VITE_VERCEL_BRANCH_URL||process.env.PUBLIC_VERCEL_BRANCH_URL||process.env.REACT_APP_VERCEL_BRANCH_URL||process.env.GATSBY_VERCEL_BRANCH_URL||process.env.VUE_APP_VERCEL_BRANCH_URL||process.env.REDWOOD_ENV_VERCEL_BRANCH_URL||process.env.SANITY_STUDIO_VERCEL_BRANCH_URL||void 0;case"VERCEL_PROJECT_PRODUCTION_URL":return process.env.VERCEL_PROJECT_PRODUCTION_URL||process.env.NEXT_PUBLIC_VERCEL_PROJECT_PRODUCTION_URL||process.env.NUXT_ENV_VERCEL_PROJECT_PRODUCTION_URL||process.env.VITE_VERCEL_PROJECT_PRODUCTION_URL||process.env.PUBLIC_VERCEL_PROJECT_PRODUCTION_URL||process.env.REACT_APP_VERCEL_PROJECT_PRODUCTION_URL||process.env.GATSBY_VERCEL_PROJECT_PRODUCTION_URL||process.env.VUE_APP_VERCEL_PROJECT_PRODUCTION_URL||process.env.REDWOOD_ENV_VERCEL_PROJECT_PRODUCTION_URL||process.env.SANITY_STUDIO_VERCEL_PROJECT_PRODUCTION_URL||void 0;case"APP_URL":return process.env.APP_URL||process.env.NEXT_PUBLIC_APP_URL||process.env.NUXT_ENV_APP_URL||process.env.VITE_APP_URL||process.env.PUBLIC_APP_URL||process.env.REACT_APP_APP_URL||process.env.GATSBY_APP_URL||process.env.VUE_APP_APP_URL||process.env.REDWOOD_ENV_APP_URL||process.env.SANITY_STUDIO_APP_URL||void 0;case"APP_PRODUCTION_URL":return process.env.APP_PRODUCTION_URL||process.env.NEXT_PUBLIC_APP_PRODUCTION_URL||process.env.NUXT_ENV_APP_PRODUCTION_URL||process.env.VITE_APP_PRODUCTION_URL||process.env.PUBLIC_APP_PRODUCTION_URL||process.env.REACT_APP_APP_PRODUCTION_URL||process.env.GATSBY_APP_PRODUCTION_URL||process.env.VUE_APP_APP_PRODUCTION_URL||process.env.REDWOOD_ENV_APP_PRODUCTION_URL||process.env.SANITY_STUDIO_APP_PRODUCTION_URL||void 0;case"APP_ENV":return process.env.APP_ENV||process.env.NEXT_PUBLIC_APP_ENV||process.env.NUXT_ENV_APP_ENV||process.env.VITE_APP_ENV||process.env.PUBLIC_APP_ENV||process.env.REACT_APP_APP_ENV||process.env.GATSBY_APP_ENV||process.env.VUE_APP_APP_ENV||process.env.REDWOOD_ENV_APP_ENV||process.env.SANITY_STUDIO_APP_ENV||void 0;default:return}}function C(E,P){if(typeof process<"u"&&process?.env&&E===process.env){if(D.includes(P)){let _=G(P);if(_)return _}}let L=["","NEXT_PUBLIC_","NUXT_ENV_","VITE_","PUBLIC_","REACT_APP_","GATSBY_","VUE_APP_","REDWOOD_ENV_","SANITY_STUDIO_"];for(let _ of L){let A=E[_+P];if(A)return A}return}function I(E){if(E!==void 0)return K(E);if(typeof process<"u"&&process?.env)return process.env;return{}}function K(E){let P={};for(let[L,_]of Object.entries(E))if(typeof _==="string")P[L]=_;return P}var U=[{name:"vercel",detect:(E)=>!!E.VERCEL||!!C(E,"VERCEL_ENV"),resolveUrl:(E)=>{if(C(E,"VERCEL_ENV")==="production")return C(E,"VERCEL_PROJECT_PRODUCTION_URL")||C(E,"VERCEL_URL")||null;return C(E,"VERCEL_BRANCH_URL")||C(E,"VERCEL_URL")||null},resolveProductionUrl:(E)=>C(E,"VERCEL_PROJECT_PRODUCTION_URL")||null,resolveEnv:(E)=>{let P=C(E,"VERCEL_ENV");if(P==="production")return"production";if(P==="preview")return"preview";return"local"}},{name:"netlify",detect:(E)=>!!E.NETLIFY,resolveUrl:(E)=>{if(E.CONTEXT==="production")return E.URL||null;return E.DEPLOY_PRIME_URL||E.DEPLOY_URL||null},resolveProductionUrl:(E)=>E.URL||null,resolveEnv:(E)=>{if(E.CONTEXT==="production")return"production";if(E.CONTEXT==="deploy-preview"||E.CONTEXT==="branch-deploy")return"preview";return"local"}},{name:"cloudflare",detect:(E)=>!!E.CF_PAGES,resolveUrl:(E)=>E.CF_PAGES_URL||null,resolveEnv:(E)=>{if(E.CF_PAGES_BRANCH==="main"||E.CF_PAGES_BRANCH==="master")return"production";return"preview"}},{name:"railway",detect:(E)=>!!E.RAILWAY_PUBLIC_DOMAIN,resolveUrl:(E)=>E.RAILWAY_PUBLIC_DOMAIN||null,resolveProductionUrl:(E)=>E.RAILWAY_PUBLIC_DOMAIN||null,resolveEnv:(E)=>{if(E.RAILWAY_ENVIRONMENT==="production")return"production";return"production"}},{name:"fly",detect:(E)=>!!E.FLY_APP_NAME,resolveUrl:(E)=>E.FLY_APP_NAME?`${E.FLY_APP_NAME}.fly.dev`:null,resolveProductionUrl:(E)=>E.FLY_APP_NAME?`${E.FLY_APP_NAME}.fly.dev`:null,resolveEnv:()=>"production"},{name:"render",detect:(E)=>!!E.RENDER,resolveUrl:(E)=>E.RENDER_EXTERNAL_URL||null,resolveProductionUrl:(E)=>E.IS_PULL_REQUEST==="true"?null:E.RENDER_EXTERNAL_URL||null,resolveEnv:(E)=>{if(E.IS_PULL_REQUEST==="true")return"preview";return"production"}},{name:"digitalocean",detect:(E)=>!!E.DIGITALOCEAN_APP_PLATFORM,resolveUrl:(E)=>E.APP_URL||null,resolveProductionUrl:(E)=>E.APP_URL||null,resolveEnv:()=>"production"},{name:"heroku",detect:(E)=>!!E.HEROKU_APP_NAME,resolveUrl:(E)=>E.HEROKU_APP_NAME?`${E.HEROKU_APP_NAME}.herokuapp.com`:null,resolveProductionUrl:(E)=>E.HEROKU_APP_NAME?`${E.HEROKU_APP_NAME}.herokuapp.com`:null,resolveEnv:()=>"production"}];function T(E){let P=E.trim().replace(/\/+$/,"");if(P.startsWith("http://")||P.startsWith("https://"))return P;return`https://${P}`}function F(E){let P=I(E),L=C(P,"APP_URL");if(L)return{url:T(L),debugLabel:`[override] APP_URL=${L}`};if(P.PORTLESS_TAILSCALE_URL)return{url:P.PORTLESS_TAILSCALE_URL,debugLabel:`[portless:tailscale] PORTLESS_TAILSCALE_URL=${P.PORTLESS_TAILSCALE_URL}`};if(P.PORTLESS_URL)return{url:P.PORTLESS_URL,debugLabel:`[portless] PORTLESS_URL=${P.PORTLESS_URL}`};for(let A of U)if(A.detect(P)){let R=A.resolveUrl(P);if(R)return{url:T(R),debugLabel:`[provider:${A.name}] url=${R}`}}if(typeof window<"u"&&window.location)return{url:window.location.origin,debugLabel:"[browser] window.location.origin"};if(P.NODE_ENV!=="production"){let A=P.PORT||"3000";return{url:`http://localhost:${A}`,debugLabel:`[fallback] PORT=${A}`}}throw Error("which-url: Cannot detect app URL. Set APP_URL environment variable.")}function H(E){let P=I(E),L=C(P,"APP_PRODUCTION_URL");if(L)return{url:T(L),debugLabel:`[production:override] APP_PRODUCTION_URL=${L}`};for(let A of U)if(A.detect(P)){let R=A.resolveProductionUrl?.(P);if(R)return{url:T(R),debugLabel:`[production:provider:${A.name}] url=${R}`}}for(let A of U)if(A.detect(P)&&A.resolveEnv(P)==="production"){let R=A.resolveUrl(P);if(R)return{url:T(R),debugLabel:`[production:current:${A.name}] url=${R}`}}let _=C(P,"APP_URL");if(_&&P.NODE_ENV==="production")return{url:T(_),debugLabel:`[production:current] APP_URL=${_}`};return null}function M(E){let P=I(E);for(let L of U)if(L.detect(P))return L.name;return null}var X=["production","preview","local"];function c(E){let P=I(E),L=C(P,"APP_ENV");if(L&&X.includes(L))return{env:L,debugLabel:`APP_ENV=${L}`};if(P.NODE_ENV==="development")return{env:"local",debugLabel:"NODE_ENV=development"};for(let _ of U)if(_.detect(P)){let A=_.resolveEnv(P);return{env:A,debugLabel:`${_.name}:${A}`}}if(P.NODE_ENV==="production")return{env:"production",debugLabel:"NODE_ENV=production"};return{env:"local",debugLabel:"default"}}function f(E){return Object.defineProperty(E,"debug",{value:E.debug,enumerable:!1,configurable:!1}),E}function S(E){let P=E?.env,{url:L,debugLabel:_}=F(P),A=new URL(L),{env:R,debugLabel:O}=c(P),V=M(P),t=H(P),Y=t?new URL(t.url).origin:void 0,B=t?` | production=${Y} (${t.debugLabel})`:" | production=unresolved",W=`${_} | env=${R} (${O})${B}`,$={href:A.origin,origin:A.origin,hostname:A.hostname,host:A.host,protocol:A.protocol,port:A.port,productionOrigin:Y,env:R,platform:V,debug:W,isResolved:!0,isProduction:R==="production",isPreview:R==="preview",isLocal:R==="local"};return f($)}function u(E){let P=E instanceof Error?E.message:"resolution failed",L="local",_="default";try{let R=c();L=R.env,_=R.debugLabel}catch{}let A={href:"",origin:"",hostname:"",host:"",protocol:"",port:"",productionOrigin:void 0,env:L,platform:M(),debug:`[error] ${P} | env=${L} (${_})`,isResolved:!1,isProduction:L==="production",isPreview:L==="preview",isLocal:L==="local"};return f(A)}var N;try{N=S()}catch(E){N=u(E)}var{href:l,origin:g,hostname:i,host:o,protocol:s,port:n,productionOrigin:d,env:a,platform:p,debug:r,isResolved:v,isProduction:e,isPreview:EE,isLocal:PE}=N,LE=N;export{s as protocol,d as productionOrigin,n as port,p as platform,g as origin,v as isResolved,e as isProduction,EE as isPreview,PE as isLocal,l as href,i as hostname,o as host,a as env,LE as default,r as debug,S as createUrl};
|
package/dist/types.d.ts
CHANGED
|
@@ -14,10 +14,14 @@ export interface WhichUrl {
|
|
|
14
14
|
readonly protocol: string;
|
|
15
15
|
/** Port string — `""` for default ports, `"3000"` for custom */
|
|
16
16
|
readonly port: string;
|
|
17
|
+
/** Canonical production origin when configured or detectable, otherwise `undefined`. */
|
|
18
|
+
readonly productionOrigin: string | undefined;
|
|
17
19
|
/** Current environment — `"production"`, `"preview"`, or `"local"` */
|
|
18
20
|
readonly env: AppEnv;
|
|
19
21
|
/** Detected hosting platform — `"vercel"`, `"netlify"`, etc. or `null` */
|
|
20
22
|
readonly platform: Platform;
|
|
23
|
+
/** `true` when the current URL resolved successfully; `false` only on the import-safe fallback. */
|
|
24
|
+
readonly isResolved: boolean;
|
|
21
25
|
/** `true` when running in production */
|
|
22
26
|
readonly isProduction: boolean;
|
|
23
27
|
/** `true` when running in a preview/staging deployment */
|
|
@@ -45,6 +49,7 @@ export interface ProviderDetector {
|
|
|
45
49
|
name: PlatformName;
|
|
46
50
|
detect: (env: Record<string, string | undefined>) => boolean;
|
|
47
51
|
resolveUrl: (env: Record<string, string | undefined>) => string | null;
|
|
52
|
+
resolveProductionUrl?: (env: Record<string, string | undefined>) => string | null;
|
|
48
53
|
resolveEnv: (env: Record<string, string | undefined>) => AppEnv;
|
|
49
54
|
}
|
|
50
55
|
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "which-url",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Auto-detect your app's URL across hosting providers. Zero config.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,6 +31,8 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "bun build src/index.ts --outdir dist --format esm --minify && tsc --emitDeclarationOnly --outDir dist",
|
|
33
33
|
"test": "bun test",
|
|
34
|
+
"release:check": "bun test && bun run build && git diff --quiet && git diff --cached --quiet && node -e \"const { execSync } = require('node:child_process'); const version = require('./package.json').version; const tag = execSync('git describe --tags --exact-match', { encoding: 'utf8' }).trim(); const expected = 'v' + version; if (tag !== expected) throw new Error('package.json version ' + version + ' must match checked-out tag ' + tag)\"",
|
|
35
|
+
"release:publish": "bun run release:check && git push && git push --tags && npm publish",
|
|
34
36
|
"prepublishOnly": "bun run build"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|