@interfere/next 0.1.0-alpha.0 → 0.1.0-alpha.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/_virtual/_rolldown/runtime.mjs +13 -0
- package/dist/config.d.mts.map +1 -1
- package/dist/config.mjs +22 -11
- package/dist/config.mjs.map +1 -1
- package/dist/instrument-client.d.mts +2 -0
- package/dist/instrument-client.mjs +2 -0
- package/dist/internal/build/injected.d.mts +6 -5
- package/dist/internal/build/injected.d.mts.map +1 -1
- package/dist/internal/build/injected.mjs.map +1 -1
- package/dist/internal/build/release/destinations/vercel.d.mts +6 -0
- package/dist/internal/build/release/destinations/vercel.d.mts.map +1 -0
- package/dist/internal/build/release/destinations/vercel.mjs +25 -0
- package/dist/internal/build/release/destinations/vercel.mjs.map +1 -0
- package/dist/internal/build/release/git.d.mts +4 -0
- package/dist/internal/build/release/git.d.mts.map +1 -0
- package/dist/internal/build/release/git.mjs +21 -0
- package/dist/internal/build/release/git.mjs.map +1 -0
- package/dist/internal/build/release/index.d.mts +7 -0
- package/dist/internal/build/release/index.d.mts.map +1 -0
- package/dist/internal/build/release/index.mjs +26 -0
- package/dist/internal/build/release/index.mjs.map +1 -0
- package/dist/internal/build/release/sources/github.d.mts +6 -0
- package/dist/internal/build/release/sources/github.d.mts.map +1 -0
- package/dist/internal/build/release/sources/github.mjs +15 -0
- package/dist/internal/build/release/sources/github.mjs.map +1 -0
- package/dist/internal/build/release/types.d.mts +11 -0
- package/dist/internal/build/release/types.d.mts.map +1 -0
- package/dist/internal/build/release/types.mjs +1 -0
- package/dist/internal/build/source-maps/discover.d.mts.map +1 -1
- package/dist/internal/build/source-maps/discover.mjs +15 -13
- package/dist/internal/build/source-maps/discover.mjs.map +1 -1
- package/dist/internal/build/source-maps/index.d.mts +2 -2
- package/dist/internal/build/source-maps/index.mjs.map +1 -1
- package/dist/internal/env.d.mts.map +1 -1
- package/dist/internal/env.mjs +3 -4
- package/dist/internal/env.mjs.map +1 -1
- package/dist/internal/route/sw-script.d.mts +1 -1
- package/dist/internal/route/sw-script.mjs +20 -4
- package/dist/internal/route/sw-script.mjs.map +1 -1
- package/dist/internal/server/runtime.d.mts +1 -1
- package/dist/internal/server/runtime.mjs +1 -0
- package/dist/internal/server/runtime.mjs.map +1 -1
- package/dist/provider.d.mts +2 -13
- package/dist/provider.mjs +1 -14
- package/package.json +6 -1
- package/dist/internal/build/release.d.mts +0 -9
- package/dist/internal/build/release.d.mts.map +0 -1
- package/dist/internal/build/release.mjs +0 -66
- package/dist/internal/build/release.mjs.map +0 -1
- package/dist/provider.d.mts.map +0 -1
- package/dist/provider.mjs.map +0 -1
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
//#endregion
|
|
13
|
+
export { __exportAll };
|
package/dist/config.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"config.d.mts","names":[],"sources":["../src/config.ts"],"mappings":";;;;UAkBiB,eAAA,SACP,OAAA,CAAQ,IAAA,CAAK,QAAA;AAAA,KAEX,uBAAA,GAA0B,UAAA;EACpC,SAAA,GAAY,eAAA;AAAA;AAAA,iBAGE,aAAA,CACd,UAAA,GAAY,uBAAA,GACX,UAAA"}
|
package/dist/config.mjs
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { configureBuild } from "./internal/build/configure-build.mjs";
|
|
2
2
|
import { buildInjectedValues } from "./internal/build/injected.mjs";
|
|
3
3
|
import { buildLog } from "./internal/build/logger.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { runSourceMapPipeline } from "./internal/build/source-maps/index.mjs";
|
|
4
|
+
import { runGitCommand } from "./internal/build/release/git.mjs";
|
|
6
5
|
import { readInterfereEnv } from "./internal/env.mjs";
|
|
7
6
|
import { releaseDestinationIdEnvKeys, releaseSourceIdEnvKeys } from "@interfere/types/integrations";
|
|
8
7
|
import { parseEnvValue, readFirstEnvValue } from "@interfere/types/sdk/env";
|
|
@@ -18,10 +17,11 @@ function withInterfere(nextConfig = {}) {
|
|
|
18
17
|
projectDir: process.cwd(),
|
|
19
18
|
values: injectedValues
|
|
20
19
|
});
|
|
20
|
+
if (hasApiKey && !build.webpack && !build.turbopack) throw new Error("[Interfere] INTERFERE_API_KEY is set but no instrumentation-client file was found. Create an instrumentation-client.ts file in your project root or src/ directory. See: https://interfere.com/docs/nextjs/setup");
|
|
21
21
|
return {
|
|
22
22
|
...rest,
|
|
23
23
|
env: mergeEnvConfig(userEnv, metadata),
|
|
24
|
-
compiler: buildCompilerConfig(compiler, hasApiKey
|
|
24
|
+
compiler: buildCompilerConfig(compiler, hasApiKey),
|
|
25
25
|
webpack: build.webpack,
|
|
26
26
|
turbopack: build.turbopack,
|
|
27
27
|
productionBrowserSourceMaps: hasApiKey ? true : productionBrowserSourceMaps
|
|
@@ -43,7 +43,7 @@ function mergeEnvConfig(userEnv, metadata) {
|
|
|
43
43
|
...userEnv
|
|
44
44
|
};
|
|
45
45
|
}
|
|
46
|
-
function buildCompilerConfig(existingCompiler, enabled
|
|
46
|
+
function buildCompilerConfig(existingCompiler, enabled) {
|
|
47
47
|
const compiler = existingCompiler;
|
|
48
48
|
const existingHook = compiler?.runAfterProductionCompile;
|
|
49
49
|
if (!(existingHook || enabled)) return existingCompiler;
|
|
@@ -51,28 +51,39 @@ function buildCompilerConfig(existingCompiler, enabled, metadata) {
|
|
|
51
51
|
...compiler ?? {},
|
|
52
52
|
async runAfterProductionCompile(context) {
|
|
53
53
|
if (existingHook) await existingHook(context);
|
|
54
|
-
if (enabled) await runBuildReleasePipeline(context
|
|
54
|
+
if (enabled) await runBuildReleasePipeline(context);
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
|
-
async function runBuildReleasePipeline(context
|
|
58
|
+
async function runBuildReleasePipeline(context) {
|
|
59
59
|
const env = readInterfereEnv();
|
|
60
|
-
const apiKey = env
|
|
60
|
+
const { apiKey, apiUrl } = env;
|
|
61
61
|
if (apiKey === null) {
|
|
62
62
|
buildLog.warn("Skipping", ["Missing INTERFERE_API_KEY."]);
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
65
|
+
const buildId = env.release.sourceId;
|
|
66
|
+
if (buildId === null) {
|
|
67
|
+
buildLog.error("Build ID missing", [
|
|
68
|
+
"Could not resolve a build ID from config, environment variables, or git.",
|
|
69
|
+
"Source maps will not be uploaded and errors will have unresolved stack traces.",
|
|
70
|
+
"Set INTERFERE_BUILD_ID, or ensure git is available in your build environment."
|
|
71
|
+
]);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const { createRelease } = await import("./internal/build/release/index.mjs");
|
|
75
|
+
const { runSourceMapPipeline } = await import("./internal/build/source-maps/index.mjs");
|
|
65
76
|
const client = {
|
|
66
77
|
async createRelease() {
|
|
67
|
-
const release = await createRelease(apiKey,
|
|
78
|
+
const release = await createRelease(apiKey, buildId);
|
|
68
79
|
return {
|
|
69
80
|
slug: release.destination.slug,
|
|
70
81
|
orgSlug: release.org.slug,
|
|
71
|
-
buildId: release.build.hash
|
|
82
|
+
buildId: release.build.hash ?? buildId
|
|
72
83
|
};
|
|
73
84
|
},
|
|
74
85
|
async uploadSourceMaps(releaseSlug, body) {
|
|
75
|
-
const url = `${
|
|
86
|
+
const url = `${apiUrl}/v1/releases/${releaseSlug}/source-maps`;
|
|
76
87
|
const response = await fetch(url, {
|
|
77
88
|
method: "POST",
|
|
78
89
|
headers: { "x-api-key": apiKey },
|
|
@@ -93,7 +104,7 @@ async function runBuildReleasePipeline(context, metadata) {
|
|
|
93
104
|
buildLog.info("Completed", [
|
|
94
105
|
`https://interfere.com/~/${result.orgSlug}`,
|
|
95
106
|
`Release: ${result.releaseSlug}`,
|
|
96
|
-
`Build: ${result.buildId
|
|
107
|
+
`Build: ${result.buildId}`,
|
|
97
108
|
`Artifacts: ${result.fileCount} source maps`
|
|
98
109
|
]);
|
|
99
110
|
} catch (error) {
|
package/dist/config.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import {\n releaseDestinationIdEnvKeys,\n releaseSourceIdEnvKeys,\n} from \"@interfere/types/integrations\";\nimport { parseEnvValue, readFirstEnvValue } from \"@interfere/types/sdk/env\";\nimport type { Envelope } from \"@interfere/types/sdk/envelope\";\n\nimport type { NextConfig } from \"next\";\n\nimport { configureBuild } from \"./internal/build/configure-build.js\";\nimport {\n buildInjectedValues,\n type InterfereBuildMetadata,\n} from \"./internal/build/injected.js\";\nimport { buildLog } from \"./internal/build/logger.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"config.mjs","names":[],"sources":["../src/config.ts"],"sourcesContent":["import {\n releaseDestinationIdEnvKeys,\n releaseSourceIdEnvKeys,\n} from \"@interfere/types/integrations\";\nimport { parseEnvValue, readFirstEnvValue } from \"@interfere/types/sdk/env\";\nimport type { Envelope } from \"@interfere/types/sdk/envelope\";\n\nimport type { NextConfig } from \"next\";\n\nimport { configureBuild } from \"./internal/build/configure-build.js\";\nimport {\n buildInjectedValues,\n type InterfereBuildMetadata,\n} from \"./internal/build/injected.js\";\nimport { buildLog } from \"./internal/build/logger.js\";\nimport { runGitCommand } from \"./internal/build/release/git.js\";\nimport { readInterfereEnv } from \"./internal/env.js\";\n\nexport interface InterfereConfig\n extends Partial<Pick<Envelope, \"buildId\" | \"releaseId\">> {}\n\nexport type NextConfigWithInterfere = NextConfig & {\n interfere?: InterfereConfig;\n};\n\nexport function withInterfere(\n nextConfig: NextConfigWithInterfere = {}\n): NextConfig {\n const {\n interfere,\n env: userEnv,\n webpack,\n turbopack,\n compiler,\n productionBrowserSourceMaps,\n ...rest\n } = nextConfig;\n const metadata = resolveBuildMetadata(interfere);\n const injectedValues = buildInjectedValues(metadata);\n const hasApiKey = readInterfereEnv().apiKey !== null;\n const build = configureBuild({\n existingWebpack: webpack,\n existingTurbopack: turbopack,\n projectDir: process.cwd(),\n values: injectedValues,\n });\n\n if (hasApiKey && !build.webpack && !build.turbopack) {\n throw new Error(\n \"[Interfere] INTERFERE_API_KEY is set but no instrumentation-client file was found. \" +\n \"Create an instrumentation-client.ts file in your project root or src/ directory. \" +\n \"See: https://interfere.com/docs/nextjs/setup\"\n );\n }\n\n return {\n ...rest,\n env: mergeEnvConfig(userEnv, metadata),\n compiler: buildCompilerConfig(compiler, hasApiKey),\n webpack: build.webpack,\n turbopack: build.turbopack,\n productionBrowserSourceMaps: hasApiKey ? true : productionBrowserSourceMaps,\n };\n}\n\nfunction resolveBuildMetadata(\n config?: InterfereConfig\n): InterfereBuildMetadata {\n const buildId =\n parseEnvValue(config?.buildId) ??\n readFirstEnvValue(process.env, releaseSourceIdEnvKeys) ??\n runGitCommand(\"git rev-parse HEAD\");\n const releaseId =\n parseEnvValue(config?.releaseId) ??\n readFirstEnvValue(process.env, releaseDestinationIdEnvKeys) ??\n buildId;\n\n return { buildId, releaseId };\n}\n\nfunction mergeEnvConfig(\n userEnv: NextConfig[\"env\"] | undefined,\n metadata: InterfereBuildMetadata\n): NextConfig[\"env\"] {\n const merged: Record<string, string> = {};\n\n if (metadata.buildId !== null) {\n merged.NEXT_PUBLIC_INTERFERE_BUILD_ID = metadata.buildId;\n }\n\n if (metadata.releaseId !== null) {\n merged.NEXT_PUBLIC_INTERFERE_RELEASE_ID = metadata.releaseId;\n }\n\n return { ...merged, ...userEnv };\n}\n\ninterface ProductionCompileContext {\n readonly distDir: string;\n readonly projectDir: string;\n}\n\ntype NextCompilerWithProductionHook = NonNullable<NextConfig[\"compiler\"]> & {\n runAfterProductionCompile?: (\n context: ProductionCompileContext\n ) => void | Promise<void>;\n};\n\nfunction buildCompilerConfig(\n existingCompiler: NextConfig[\"compiler\"] | undefined,\n enabled: boolean\n): NextConfig[\"compiler\"] | undefined {\n const compiler = existingCompiler as\n | NextCompilerWithProductionHook\n | undefined;\n const existingHook = compiler?.runAfterProductionCompile;\n\n if (!(existingHook || enabled)) {\n return existingCompiler;\n }\n\n return {\n ...(compiler ?? {}),\n async runAfterProductionCompile(context: ProductionCompileContext) {\n if (existingHook) {\n await existingHook(context);\n }\n\n if (enabled) {\n await runBuildReleasePipeline(context);\n }\n },\n } as NextConfig[\"compiler\"];\n}\n\nasync function runBuildReleasePipeline(\n context: ProductionCompileContext\n): Promise<void> {\n const env = readInterfereEnv();\n\n const { apiKey, apiUrl } = env;\n\n if (apiKey === null) {\n buildLog.warn(\"Skipping\", [\"Missing INTERFERE_API_KEY.\"]);\n return;\n }\n\n const buildId = env.release.sourceId;\n\n if (buildId === null) {\n buildLog.error(\"Build ID missing\", [\n \"Could not resolve a build ID from config, environment variables, or git.\",\n \"Source maps will not be uploaded and errors will have unresolved stack traces.\",\n \"Set INTERFERE_BUILD_ID, or ensure git is available in your build environment.\",\n ]);\n return;\n }\n\n const { createRelease } = await import(\"./internal/build/release/index.js\");\n const { runSourceMapPipeline } = await import(\n \"./internal/build/source-maps/index.js\"\n );\n\n const client: import(\"./internal/build/source-maps/index.js\").BuildClient = {\n async createRelease() {\n const release = await createRelease(apiKey, buildId);\n return {\n slug: release.destination.slug,\n orgSlug: release.org.slug,\n buildId: release.build.hash ?? buildId,\n };\n },\n async uploadSourceMaps(releaseSlug, body) {\n const url = `${apiUrl}/v1/releases/${releaseSlug}/source-maps`;\n const response = await fetch(url, {\n method: \"POST\",\n headers: { \"x-api-key\": apiKey },\n body,\n });\n\n if (!response.ok) {\n const text = await response.text().catch(() => \"\");\n throw new Error(\n `Source map upload failed: ${response.status} ${response.statusText} ${text}`\n );\n }\n },\n };\n\n try {\n const result = await runSourceMapPipeline(\n context.projectDir,\n context.distDir,\n client\n );\n\n if (!result.ready) {\n buildLog.warn(\"Skipping\", [\"No source maps found\"]);\n return;\n }\n\n buildLog.info(\"Completed\", [\n `https://interfere.com/~/${result.orgSlug}`,\n `Release: ${result.releaseSlug}`,\n `Build: ${result.buildId}`,\n `Artifacts: ${result.fileCount} source maps`,\n ]);\n } catch (error) {\n buildLog.error(\"Error\", [\n error instanceof Error ? error.message : String(error),\n ]);\n throw error;\n }\n}\n"],"mappings":";;;;;;;;AAyBA,SAAgB,cACd,aAAsC,EAAE,EAC5B;CACZ,MAAM,EACJ,WACA,KAAK,SACL,SACA,WACA,UACA,6BACA,GAAG,SACD;CACJ,MAAM,WAAW,qBAAqB,UAAU;CAChD,MAAM,iBAAiB,oBAAoB,SAAS;CACpD,MAAM,YAAY,kBAAkB,CAAC,WAAW;CAChD,MAAM,QAAQ,eAAe;EAC3B,iBAAiB;EACjB,mBAAmB;EACnB,YAAY,QAAQ,KAAK;EACzB,QAAQ;EACT,CAAC;AAEF,KAAI,aAAa,CAAC,MAAM,WAAW,CAAC,MAAM,UACxC,OAAM,IAAI,MACR,mNAGD;AAGH,QAAO;EACL,GAAG;EACH,KAAK,eAAe,SAAS,SAAS;EACtC,UAAU,oBAAoB,UAAU,UAAU;EAClD,SAAS,MAAM;EACf,WAAW,MAAM;EACjB,6BAA6B,YAAY,OAAO;EACjD;;AAGH,SAAS,qBACP,QACwB;CACxB,MAAM,UACJ,cAAc,QAAQ,QAAQ,IAC9B,kBAAkB,QAAQ,KAAK,uBAAuB,IACtD,cAAc,qBAAqB;AAMrC,QAAO;EAAE;EAAS,WAJhB,cAAc,QAAQ,UAAU,IAChC,kBAAkB,QAAQ,KAAK,4BAA4B,IAC3D;EAE2B;;AAG/B,SAAS,eACP,SACA,UACmB;CACnB,MAAM,SAAiC,EAAE;AAEzC,KAAI,SAAS,YAAY,KACvB,QAAO,iCAAiC,SAAS;AAGnD,KAAI,SAAS,cAAc,KACzB,QAAO,mCAAmC,SAAS;AAGrD,QAAO;EAAE,GAAG;EAAQ,GAAG;EAAS;;AAclC,SAAS,oBACP,kBACA,SACoC;CACpC,MAAM,WAAW;CAGjB,MAAM,eAAe,UAAU;AAE/B,KAAI,EAAE,gBAAgB,SACpB,QAAO;AAGT,QAAO;EACL,GAAI,YAAY,EAAE;EAClB,MAAM,0BAA0B,SAAmC;AACjE,OAAI,aACF,OAAM,aAAa,QAAQ;AAG7B,OAAI,QACF,OAAM,wBAAwB,QAAQ;;EAG3C;;AAGH,eAAe,wBACb,SACe;CACf,MAAM,MAAM,kBAAkB;CAE9B,MAAM,EAAE,QAAQ,WAAW;AAE3B,KAAI,WAAW,MAAM;AACnB,WAAS,KAAK,YAAY,CAAC,6BAA6B,CAAC;AACzD;;CAGF,MAAM,UAAU,IAAI,QAAQ;AAE5B,KAAI,YAAY,MAAM;AACpB,WAAS,MAAM,oBAAoB;GACjC;GACA;GACA;GACD,CAAC;AACF;;CAGF,MAAM,EAAE,kBAAkB,MAAM,OAAO;CACvC,MAAM,EAAE,yBAAyB,MAAM,OACrC;CAGF,MAAM,SAAsE;EAC1E,MAAM,gBAAgB;GACpB,MAAM,UAAU,MAAM,cAAc,QAAQ,QAAQ;AACpD,UAAO;IACL,MAAM,QAAQ,YAAY;IAC1B,SAAS,QAAQ,IAAI;IACrB,SAAS,QAAQ,MAAM,QAAQ;IAChC;;EAEH,MAAM,iBAAiB,aAAa,MAAM;GACxC,MAAM,MAAM,GAAG,OAAO,eAAe,YAAY;GACjD,MAAM,WAAW,MAAM,MAAM,KAAK;IAChC,QAAQ;IACR,SAAS,EAAE,aAAa,QAAQ;IAChC;IACD,CAAC;AAEF,OAAI,CAAC,SAAS,IAAI;IAChB,MAAM,OAAO,MAAM,SAAS,MAAM,CAAC,YAAY,GAAG;AAClD,UAAM,IAAI,MACR,6BAA6B,SAAS,OAAO,GAAG,SAAS,WAAW,GAAG,OACxE;;;EAGN;AAED,KAAI;EACF,MAAM,SAAS,MAAM,qBACnB,QAAQ,YACR,QAAQ,SACR,OACD;AAED,MAAI,CAAC,OAAO,OAAO;AACjB,YAAS,KAAK,YAAY,CAAC,uBAAuB,CAAC;AACnD;;AAGF,WAAS,KAAK,aAAa;GACzB,2BAA2B,OAAO;GAClC,YAAY,OAAO;GACnB,UAAU,OAAO;GACjB,cAAc,OAAO,UAAU;GAChC,CAAC;UACK,OAAO;AACd,WAAS,MAAM,SAAS,CACtB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CACvD,CAAC;AACF,QAAM"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { Envelope } from "@interfere/types/sdk/envelope";
|
|
2
|
-
|
|
3
1
|
//#region src/internal/build/injected.d.ts
|
|
4
|
-
|
|
2
|
+
interface InterfereBuildMetadata {
|
|
3
|
+
readonly buildId: string | null;
|
|
4
|
+
readonly releaseId: string | null;
|
|
5
|
+
}
|
|
5
6
|
interface InterfereInjectedValues {
|
|
6
|
-
readonly __INTERFERE_BUILD_ID__:
|
|
7
|
-
readonly __INTERFERE_RELEASE_ID__:
|
|
7
|
+
readonly __INTERFERE_BUILD_ID__: string | null;
|
|
8
|
+
readonly __INTERFERE_RELEASE_ID__: string | null;
|
|
8
9
|
}
|
|
9
10
|
declare function buildInjectedValues(metadata: InterfereBuildMetadata): InterfereInjectedValues;
|
|
10
11
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injected.d.mts","names":[],"sources":["../../../src/internal/build/injected.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"injected.d.mts","names":[],"sources":["../../../src/internal/build/injected.ts"],"mappings":";UAAiB,sBAAA;EAAA,SACN,OAAA;EAAA,SACA,SAAA;AAAA;AAAA,UAGM,uBAAA;EAAA,SACN,sBAAA;EAAA,SACA,wBAAA;AAAA;AAAA,iBAGK,mBAAA,CACd,QAAA,EAAU,sBAAA,GACT,uBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injected.mjs","names":[],"sources":["../../../src/internal/build/injected.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"file":"injected.mjs","names":[],"sources":["../../../src/internal/build/injected.ts"],"sourcesContent":["export interface InterfereBuildMetadata {\n readonly buildId: string | null;\n readonly releaseId: string | null;\n}\n\nexport interface InterfereInjectedValues {\n readonly __INTERFERE_BUILD_ID__: string | null;\n readonly __INTERFERE_RELEASE_ID__: string | null;\n}\n\nexport function buildInjectedValues(\n metadata: InterfereBuildMetadata\n): InterfereInjectedValues {\n return {\n __INTERFERE_BUILD_ID__: metadata.buildId,\n __INTERFERE_RELEASE_ID__: metadata.releaseId,\n };\n}\n"],"mappings":";AAUA,SAAgB,oBACd,UACyB;AACzB,QAAO;EACL,wBAAwB,SAAS;EACjC,0BAA0B,SAAS;EACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel.d.mts","names":[],"sources":["../../../../../src/internal/build/release/destinations/vercel.ts"],"mappings":";;;iBAGgB,OAAA,CAAA,GAAW,0BAAA"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { __exportAll } from "../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { parseEnvValue } from "@interfere/types/sdk/env";
|
|
3
|
+
//#region src/internal/build/release/destinations/vercel.ts
|
|
4
|
+
var vercel_exports = /* @__PURE__ */ __exportAll({ resolve: () => resolve });
|
|
5
|
+
function resolve() {
|
|
6
|
+
const deploymentId = parseEnvValue(process.env.VERCEL_DEPLOYMENT_ID);
|
|
7
|
+
const environment = parseEnvValue(process.env.VERCEL_ENV ?? process.env.VERCEL_TARGET_ENV);
|
|
8
|
+
if (!deploymentId && !environment) return null;
|
|
9
|
+
return {
|
|
10
|
+
provider: "vercel",
|
|
11
|
+
environment,
|
|
12
|
+
deploymentId,
|
|
13
|
+
deploymentUrl: resolveDeploymentUrl(),
|
|
14
|
+
environmentName: environment,
|
|
15
|
+
environmentTarget: environment
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function resolveDeploymentUrl() {
|
|
19
|
+
const deploymentUrl = parseEnvValue(process.env.VERCEL_URL);
|
|
20
|
+
if (deploymentUrl === null) return null;
|
|
21
|
+
if (deploymentUrl.startsWith("https://") || deploymentUrl.startsWith("http://")) return deploymentUrl;
|
|
22
|
+
return `https://${deploymentUrl}`;
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { resolve, vercel_exports };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vercel.mjs","names":[],"sources":["../../../../../src/internal/build/release/destinations/vercel.ts"],"sourcesContent":["import type { ReleaseDestinationMetadata } from \"@interfere/types/integrations\";\nimport { parseEnvValue } from \"@interfere/types/sdk/env\";\n\nexport function resolve(): ReleaseDestinationMetadata | null {\n const deploymentId = parseEnvValue(process.env.VERCEL_DEPLOYMENT_ID);\n const environment = parseEnvValue(\n process.env.VERCEL_ENV ?? process.env.VERCEL_TARGET_ENV,\n );\n\n if (!deploymentId && !environment) {\n return null;\n }\n\n return {\n provider: \"vercel\",\n environment,\n deploymentId,\n deploymentUrl: resolveDeploymentUrl(),\n environmentName: environment,\n environmentTarget: environment,\n };\n}\n\nfunction resolveDeploymentUrl(): string | null {\n const deploymentUrl = parseEnvValue(process.env.VERCEL_URL);\n\n if (deploymentUrl === null) {\n return null;\n }\n\n if (\n deploymentUrl.startsWith(\"https://\") ||\n deploymentUrl.startsWith(\"http://\")\n ) {\n return deploymentUrl;\n }\n\n return `https://${deploymentUrl}`;\n}\n"],"mappings":";;;;AAGA,SAAgB,UAA6C;CAC3D,MAAM,eAAe,cAAc,QAAQ,IAAI,qBAAqB;CACpE,MAAM,cAAc,cAClB,QAAQ,IAAI,cAAc,QAAQ,IAAI,kBACvC;AAED,KAAI,CAAC,gBAAgB,CAAC,YACpB,QAAO;AAGT,QAAO;EACL,UAAU;EACV;EACA;EACA,eAAe,sBAAsB;EACrC,iBAAiB;EACjB,mBAAmB;EACpB;;AAGH,SAAS,uBAAsC;CAC7C,MAAM,gBAAgB,cAAc,QAAQ,IAAI,WAAW;AAE3D,KAAI,kBAAkB,KACpB,QAAO;AAGT,KACE,cAAc,WAAW,WAAW,IACpC,cAAc,WAAW,UAAU,CAEnC,QAAO;AAGT,QAAO,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.mts","names":[],"sources":["../../../../src/internal/build/release/git.ts"],"mappings":";iBAIgB,aAAA,CAAc,OAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { buildLog } from "../logger.mjs";
|
|
2
|
+
import { execSync } from "node:child_process";
|
|
3
|
+
//#region src/internal/build/release/git.ts
|
|
4
|
+
function runGitCommand(command) {
|
|
5
|
+
try {
|
|
6
|
+
const output = execSync(command, {
|
|
7
|
+
encoding: "utf8",
|
|
8
|
+
stdio: [
|
|
9
|
+
"ignore",
|
|
10
|
+
"pipe",
|
|
11
|
+
"ignore"
|
|
12
|
+
]
|
|
13
|
+
}).trim();
|
|
14
|
+
return output.length > 0 ? output : null;
|
|
15
|
+
} catch {
|
|
16
|
+
buildLog.warn("Git unavailable", [`Failed: ${command}`]);
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { runGitCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.mjs","names":[],"sources":["../../../../src/internal/build/release/git.ts"],"sourcesContent":["import { execSync } from \"node:child_process\";\n\nimport { buildLog } from \"../logger.js\";\n\nexport function runGitCommand(command: string): string | null {\n try {\n const output = execSync(command, {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n\n return output.length > 0 ? output : null;\n } catch {\n buildLog.warn(\"Git unavailable\", [`Failed: ${command}`]);\n return null;\n }\n}\n"],"mappings":";;;AAIA,SAAgB,cAAc,SAAgC;AAC5D,KAAI;EACF,MAAM,SAAS,SAAS,SAAS;GAC/B,UAAU;GACV,OAAO;IAAC;IAAU;IAAQ;IAAS;GACpC,CAAC,CAAC,MAAM;AAET,SAAO,OAAO,SAAS,IAAI,SAAS;SAC9B;AACN,WAAS,KAAK,mBAAmB,CAAC,WAAW,UAAU,CAAC;AACxD,SAAO"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { runGitCommand } from "./git.mjs";
|
|
2
|
+
import { CreateReleaseResponse } from "@interfere/types/releases/definition";
|
|
3
|
+
|
|
4
|
+
//#region src/internal/build/release/index.d.ts
|
|
5
|
+
declare function createRelease(apiKey: string, buildId: string): Promise<CreateReleaseResponse>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createRelease, runGitCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/internal/build/release/index.ts"],"mappings":";;;;iBAwBsB,aAAA,CACpB,MAAA,UACA,OAAA,WACC,OAAA,CAAQ,qBAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { runGitCommand } from "./git.mjs";
|
|
2
|
+
import { readInterfereEnv } from "../../env.mjs";
|
|
3
|
+
import { vercel_exports } from "./destinations/vercel.mjs";
|
|
4
|
+
import { github_exports } from "./sources/github.mjs";
|
|
5
|
+
import { Interfere } from "@interfere/sdk";
|
|
6
|
+
import { InterfereHTTPError } from "@interfere/sdk/models/errors/interfere-http-error.js";
|
|
7
|
+
//#region src/internal/build/release/index.ts
|
|
8
|
+
const sources = { github: github_exports };
|
|
9
|
+
const destinations = { vercel: vercel_exports };
|
|
10
|
+
async function createRelease(apiKey, buildId) {
|
|
11
|
+
const { apiUrl } = readInterfereEnv();
|
|
12
|
+
const sdk = new Interfere({ serverURL: apiUrl });
|
|
13
|
+
const request = {
|
|
14
|
+
source: sources.github.resolve(),
|
|
15
|
+
destination: destinations.vercel.resolve(),
|
|
16
|
+
buildId
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
return await sdk.releases.createRelease(request, { headers: { "x-api-key": apiKey } });
|
|
20
|
+
} catch (error) {
|
|
21
|
+
if (error instanceof InterfereHTTPError && error.statusCode === 404) throw new Error(`Interfere release API returned 404 at '${error.rawResponse.url}'. Is INTERFERE_API_URL incorrectly set?`);
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { createRelease, runGitCommand };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/internal/build/release/index.ts"],"sourcesContent":["import type {\n DestinationProvider,\n SourceProvider,\n} from \"@interfere/types/integrations\";\nimport type { CreateReleaseResponse } from \"@interfere/types/releases/definition\";\n\nimport { Interfere } from \"@interfere/sdk\";\nimport { InterfereHTTPError } from \"@interfere/sdk/models/errors/interfere-http-error.js\";\n\nimport { readInterfereEnv } from \"../../env.js\";\nimport * as vercel from \"./destinations/vercel.js\";\nimport * as github from \"./sources/github.js\";\nimport type { DestinationResolver, SourceResolver } from \"./types.js\";\n\nexport { runGitCommand } from \"./git.js\";\n\nconst sources: Record<SourceProvider, SourceResolver> = {\n github,\n};\n\nconst destinations: Record<DestinationProvider, DestinationResolver> = {\n vercel,\n};\n\nexport async function createRelease(\n apiKey: string,\n buildId: string,\n): Promise<CreateReleaseResponse> {\n const { apiUrl } = readInterfereEnv();\n const sdk = new Interfere({ serverURL: apiUrl });\n\n const request = {\n source: sources.github.resolve(),\n destination: destinations.vercel.resolve(),\n buildId,\n };\n\n try {\n return await sdk.releases.createRelease(request, {\n headers: { \"x-api-key\": apiKey },\n });\n } catch (error) {\n if (error instanceof InterfereHTTPError && error.statusCode === 404) {\n throw new Error(\n `Interfere release API returned 404 at '${error.rawResponse.url}'. Is INTERFERE_API_URL incorrectly set?`,\n );\n }\n\n throw error;\n }\n}\n"],"mappings":";;;;;;;AAgBA,MAAM,UAAkD,EACtD,QAAA,gBACD;AAED,MAAM,eAAiE,EACrE,QAAA,gBACD;AAED,eAAsB,cACpB,QACA,SACgC;CAChC,MAAM,EAAE,WAAW,kBAAkB;CACrC,MAAM,MAAM,IAAI,UAAU,EAAE,WAAW,QAAQ,CAAC;CAEhD,MAAM,UAAU;EACd,QAAQ,QAAQ,OAAO,SAAS;EAChC,aAAa,aAAa,OAAO,SAAS;EAC1C;EACD;AAED,KAAI;AACF,SAAO,MAAM,IAAI,SAAS,cAAc,SAAS,EAC/C,SAAS,EAAE,aAAa,QAAQ,EACjC,CAAC;UACK,OAAO;AACd,MAAI,iBAAiB,sBAAsB,MAAM,eAAe,IAC9D,OAAM,IAAI,MACR,0CAA0C,MAAM,YAAY,IAAI,0CACjE;AAGH,QAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.d.mts","names":[],"sources":["../../../../../src/internal/build/release/sources/github.ts"],"mappings":";;;iBAKgB,OAAA,CAAA,GAAW,qBAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { __exportAll } from "../../../../_virtual/_rolldown/runtime.mjs";
|
|
2
|
+
import { runGitCommand } from "../git.mjs";
|
|
3
|
+
import { parseEnvValue } from "@interfere/types/sdk/env";
|
|
4
|
+
//#region src/internal/build/release/sources/github.ts
|
|
5
|
+
var github_exports = /* @__PURE__ */ __exportAll({ resolve: () => resolve });
|
|
6
|
+
function resolve() {
|
|
7
|
+
return {
|
|
8
|
+
provider: "github",
|
|
9
|
+
branch: parseEnvValue(process.env.VERCEL_GIT_COMMIT_REF) ?? parseEnvValue(process.env.GITHUB_REF_NAME) ?? parseEnvValue(process.env.GITHUB_HEAD_REF) ?? runGitCommand("git rev-parse --abbrev-ref HEAD") ?? "unknown",
|
|
10
|
+
commitMessage: parseEnvValue(process.env.VERCEL_GIT_COMMIT_MESSAGE) ?? runGitCommand("git log -1 --pretty=%B") ?? "",
|
|
11
|
+
commitSha: parseEnvValue(process.env.VERCEL_GIT_COMMIT_SHA) ?? parseEnvValue(process.env.GITHUB_SHA) ?? runGitCommand("git rev-parse HEAD")
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { github_exports, resolve };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"github.mjs","names":[],"sources":["../../../../../src/internal/build/release/sources/github.ts"],"sourcesContent":["import type { ReleaseSourceMetadata } from \"@interfere/types/integrations\";\nimport { parseEnvValue } from \"@interfere/types/sdk/env\";\n\nimport { runGitCommand } from \"../git.js\";\n\nexport function resolve(): ReleaseSourceMetadata {\n return {\n provider: \"github\",\n branch:\n parseEnvValue(process.env.VERCEL_GIT_COMMIT_REF) ??\n parseEnvValue(process.env.GITHUB_REF_NAME) ??\n parseEnvValue(process.env.GITHUB_HEAD_REF) ??\n runGitCommand(\"git rev-parse --abbrev-ref HEAD\") ??\n \"unknown\",\n commitMessage:\n parseEnvValue(process.env.VERCEL_GIT_COMMIT_MESSAGE) ??\n runGitCommand(\"git log -1 --pretty=%B\") ??\n \"\",\n commitSha:\n parseEnvValue(process.env.VERCEL_GIT_COMMIT_SHA) ??\n parseEnvValue(process.env.GITHUB_SHA) ??\n runGitCommand(\"git rev-parse HEAD\"),\n };\n}\n"],"mappings":";;;;;AAKA,SAAgB,UAAiC;AAC/C,QAAO;EACL,UAAU;EACV,QACE,cAAc,QAAQ,IAAI,sBAAsB,IAChD,cAAc,QAAQ,IAAI,gBAAgB,IAC1C,cAAc,QAAQ,IAAI,gBAAgB,IAC1C,cAAc,kCAAkC,IAChD;EACF,eACE,cAAc,QAAQ,IAAI,0BAA0B,IACpD,cAAc,yBAAyB,IACvC;EACF,WACE,cAAc,QAAQ,IAAI,sBAAsB,IAChD,cAAc,QAAQ,IAAI,WAAW,IACrC,cAAc,qBAAqB;EACtC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReleaseDestinationMetadata, ReleaseSourceMetadata } from "@interfere/types/integrations";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/build/release/types.d.ts
|
|
4
|
+
interface SourceResolver {
|
|
5
|
+
resolve(): ReleaseSourceMetadata;
|
|
6
|
+
}
|
|
7
|
+
interface DestinationResolver {
|
|
8
|
+
resolve(): ReleaseDestinationMetadata | null;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { DestinationResolver, SourceResolver };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.mts","names":[],"sources":["../../../../src/internal/build/release/types.ts"],"mappings":";;;UAKiB,cAAA;EACf,OAAA,IAAW,qBAAA;AAAA;AAAA,UAGI,mBAAA;EACf,OAAA,IAAW,0BAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.d.mts","names":[],"sources":["../../../../src/internal/build/source-maps/discover.ts"],"mappings":";
|
|
1
|
+
{"version":3,"file":"discover.d.mts","names":[],"sources":["../../../../src/internal/build/source-maps/discover.ts"],"mappings":";KAMY,aAAA;EAAA,SACD,QAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;EAAA,SACA,IAAA;AAAA;AAAA,iBAgBW,QAAA,CAAS,UAAA,UAAoB,OAAA,WAAe,OAAA;;;;iBAsDlD,gBAAA,CAAiB,OAAA"}
|
|
@@ -1,26 +1,28 @@
|
|
|
1
|
-
import { relative } from "node:path";
|
|
2
|
-
import { readFile } from "node:fs/promises";
|
|
1
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
3
2
|
import { createHash } from "node:crypto";
|
|
4
|
-
import {
|
|
3
|
+
import { readFile, readdir } from "node:fs/promises";
|
|
5
4
|
//#region src/internal/build/source-maps/discover.ts
|
|
6
5
|
const SOURCEMAPPING_RE = /\/\/[#@]\s*sourceMappingURL=(\S+)\s*$/;
|
|
6
|
+
function resolveDistDir(projectDir, distDir) {
|
|
7
|
+
return isAbsolute(distDir) ? distDir : resolve(projectDir, distDir);
|
|
8
|
+
}
|
|
9
|
+
async function findJsFiles(dir) {
|
|
10
|
+
return (await readdir(dir, { recursive: true }).catch(() => [])).filter((entry) => entry.endsWith(".js")).map((entry) => join(dir, entry));
|
|
11
|
+
}
|
|
7
12
|
async function discover(projectDir, distDir) {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
nodir: true
|
|
13
|
-
};
|
|
14
|
-
const jsPaths = await glob(patterns.map((p) => `${p}/*.js`), opts);
|
|
13
|
+
const absDistDir = resolveDistDir(projectDir, distDir);
|
|
14
|
+
const relDistDir = relative(projectDir, absDistDir);
|
|
15
|
+
const [staticFiles, serverFiles] = await Promise.all([findJsFiles(join(absDistDir, "static")), findJsFiles(join(absDistDir, "server"))]);
|
|
16
|
+
const jsPaths = [...staticFiles, ...serverFiles];
|
|
15
17
|
const mapping = {};
|
|
16
18
|
const mapAbsolutes = /* @__PURE__ */ new Map();
|
|
17
19
|
for (const jsAbs of jsPaths) {
|
|
18
20
|
const content = await readFile(jsAbs, "utf8");
|
|
19
21
|
const match = SOURCEMAPPING_RE.exec(content);
|
|
20
22
|
if (!match?.[1]) continue;
|
|
21
|
-
const mapAbs = `${jsAbs.slice(0, jsAbs.lastIndexOf("/") + 1)}${match[1]}`;
|
|
22
|
-
const jsPublic = toPublicPath(relative(projectDir, jsAbs),
|
|
23
|
-
const mapPublic = toPublicPath(relative(projectDir, mapAbs),
|
|
23
|
+
const mapAbs = `${jsAbs.slice(0, jsAbs.lastIndexOf("/") + 1)}${decodeURIComponent(match[1])}`;
|
|
24
|
+
const jsPublic = toPublicPath(relative(projectDir, jsAbs), relDistDir);
|
|
25
|
+
const mapPublic = toPublicPath(relative(projectDir, mapAbs), relDistDir);
|
|
24
26
|
mapping[mapPublic] = jsPublic;
|
|
25
27
|
mapAbsolutes.set(mapPublic, mapAbs);
|
|
26
28
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover.mjs","names":[],"sources":["../../../../src/internal/build/source-maps/discover.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readFile } from \"node:fs/promises\";\nimport { relative } from \"node:path\";\
|
|
1
|
+
{"version":3,"file":"discover.mjs","names":[],"sources":["../../../../src/internal/build/source-maps/discover.ts"],"sourcesContent":["import { createHash } from \"node:crypto\";\nimport { readFile, readdir } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve } from \"node:path\";\n\nconst SOURCEMAPPING_RE = /\\/\\/[#@]\\s*sourceMappingURL=(\\S+)\\s*$/;\n\nexport type SourceMapFile = {\n readonly absolute: string;\n readonly path: string;\n readonly content: string;\n readonly hash: string;\n};\n\nfunction resolveDistDir(projectDir: string, distDir: string) {\n return isAbsolute(distDir) ? distDir : resolve(projectDir, distDir);\n}\n\nasync function findJsFiles(dir: string) {\n const entries = await readdir(dir, { recursive: true }).catch(\n () => [] as string[]\n );\n return entries\n .filter((entry) => entry.endsWith(\".js\"))\n .map((entry) => join(dir, entry));\n}\n\nexport async function discover(projectDir: string, distDir: string) {\n const absDistDir = resolveDistDir(projectDir, distDir);\n const relDistDir = relative(projectDir, absDistDir);\n\n const [staticFiles, serverFiles] = await Promise.all([\n findJsFiles(join(absDistDir, \"static\")),\n findJsFiles(join(absDistDir, \"server\")),\n ]);\n\n const jsPaths = [...staticFiles, ...serverFiles];\n\n const mapping: Record<string, string> = {};\n const mapAbsolutes = new Map<string, string>();\n\n for (const jsAbs of jsPaths) {\n const content = await readFile(jsAbs, \"utf8\");\n const match = SOURCEMAPPING_RE.exec(content);\n if (!match?.[1]) continue;\n\n const jsDir = jsAbs.slice(0, jsAbs.lastIndexOf(\"/\") + 1);\n const mapRef = decodeURIComponent(match[1]);\n const mapAbs = `${jsDir}${mapRef}`;\n const jsPublic = toPublicPath(relative(projectDir, jsAbs), relDistDir);\n const mapPublic = toPublicPath(relative(projectDir, mapAbs), relDistDir);\n\n mapping[mapPublic] = jsPublic;\n mapAbsolutes.set(mapPublic, mapAbs);\n }\n\n const files = await Promise.all(\n [...mapAbsolutes.entries()].map(async ([mapPublic, mapAbs]) => {\n const content = await readFile(mapAbs, \"utf8\").catch(() => null);\n if (content === null) return null;\n\n return {\n absolute: mapAbs,\n path: mapPublic,\n content,\n hash: createHash(\"sha256\").update(content).digest(\"hex\"),\n };\n }),\n );\n\n const loaded = files.filter((f): f is SourceMapFile => f !== null);\n\n const validMapping: Record<string, string> = {};\n for (const file of loaded) {\n const js = mapping[file.path];\n if (js) validMapping[file.path] = js;\n }\n\n return { files: loaded, mapping: validMapping };\n}\n\nexport function normalizeDistDir(distDir = \".next\") {\n let d = distDir.split(\"\\\\\").join(\"/\");\n while (d.startsWith(\"./\")) d = d.slice(2);\n return d;\n}\n\nfunction toPublicPath(rel: string, distDir: string) {\n const p = rel.split(\"\\\\\").join(\"/\");\n if (p.startsWith(`${distDir}/`)) return `_next/${p.slice(distDir.length + 1)}`;\n if (p.startsWith(\".next/\")) return `_next/${p.slice(6)}`;\n return p;\n}\n"],"mappings":";;;;AAIA,MAAM,mBAAmB;AASzB,SAAS,eAAe,YAAoB,SAAiB;AAC3D,QAAO,WAAW,QAAQ,GAAG,UAAU,QAAQ,YAAY,QAAQ;;AAGrE,eAAe,YAAY,KAAa;AAItC,SAHgB,MAAM,QAAQ,KAAK,EAAE,WAAW,MAAM,CAAC,CAAC,YAChD,EAAE,CACT,EAEE,QAAQ,UAAU,MAAM,SAAS,MAAM,CAAC,CACxC,KAAK,UAAU,KAAK,KAAK,MAAM,CAAC;;AAGrC,eAAsB,SAAS,YAAoB,SAAiB;CAClE,MAAM,aAAa,eAAe,YAAY,QAAQ;CACtD,MAAM,aAAa,SAAS,YAAY,WAAW;CAEnD,MAAM,CAAC,aAAa,eAAe,MAAM,QAAQ,IAAI,CACnD,YAAY,KAAK,YAAY,SAAS,CAAC,EACvC,YAAY,KAAK,YAAY,SAAS,CAAC,CACxC,CAAC;CAEF,MAAM,UAAU,CAAC,GAAG,aAAa,GAAG,YAAY;CAEhD,MAAM,UAAkC,EAAE;CAC1C,MAAM,+BAAe,IAAI,KAAqB;AAE9C,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,UAAU,MAAM,SAAS,OAAO,OAAO;EAC7C,MAAM,QAAQ,iBAAiB,KAAK,QAAQ;AAC5C,MAAI,CAAC,QAAQ,GAAI;EAIjB,MAAM,SAAS,GAFD,MAAM,MAAM,GAAG,MAAM,YAAY,IAAI,GAAG,EAAE,GACzC,mBAAmB,MAAM,GAAG;EAE3C,MAAM,WAAW,aAAa,SAAS,YAAY,MAAM,EAAE,WAAW;EACtE,MAAM,YAAY,aAAa,SAAS,YAAY,OAAO,EAAE,WAAW;AAExE,UAAQ,aAAa;AACrB,eAAa,IAAI,WAAW,OAAO;;CAiBrC,MAAM,UAdQ,MAAM,QAAQ,IAC1B,CAAC,GAAG,aAAa,SAAS,CAAC,CAAC,IAAI,OAAO,CAAC,WAAW,YAAY;EAC7D,MAAM,UAAU,MAAM,SAAS,QAAQ,OAAO,CAAC,YAAY,KAAK;AAChE,MAAI,YAAY,KAAM,QAAO;AAE7B,SAAO;GACL,UAAU;GACV,MAAM;GACN;GACA,MAAM,WAAW,SAAS,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM;GACzD;GACD,CACH,EAEoB,QAAQ,MAA0B,MAAM,KAAK;CAElE,MAAM,eAAuC,EAAE;AAC/C,MAAK,MAAM,QAAQ,QAAQ;EACzB,MAAM,KAAK,QAAQ,KAAK;AACxB,MAAI,GAAI,cAAa,KAAK,QAAQ;;AAGpC,QAAO;EAAE,OAAO;EAAQ,SAAS;EAAc;;AAGjD,SAAgB,iBAAiB,UAAU,SAAS;CAClD,IAAI,IAAI,QAAQ,MAAM,KAAK,CAAC,KAAK,IAAI;AACrC,QAAO,EAAE,WAAW,KAAK,CAAE,KAAI,EAAE,MAAM,EAAE;AACzC,QAAO;;AAGT,SAAS,aAAa,KAAa,SAAiB;CAClD,MAAM,IAAI,IAAI,MAAM,KAAK,CAAC,KAAK,IAAI;AACnC,KAAI,EAAE,WAAW,GAAG,QAAQ,GAAG,CAAE,QAAO,SAAS,EAAE,MAAM,QAAQ,SAAS,EAAE;AAC5E,KAAI,EAAE,WAAW,SAAS,CAAE,QAAO,SAAS,EAAE,MAAM,EAAE;AACtD,QAAO"}
|
|
@@ -3,7 +3,7 @@ interface BuildClient {
|
|
|
3
3
|
createRelease(): Promise<{
|
|
4
4
|
slug: string;
|
|
5
5
|
orgSlug: string;
|
|
6
|
-
buildId: string
|
|
6
|
+
buildId: string;
|
|
7
7
|
}>;
|
|
8
8
|
uploadSourceMaps(releaseSlug: string, body: FormData): Promise<void>;
|
|
9
9
|
}
|
|
@@ -16,7 +16,7 @@ type PipelineResult = {
|
|
|
16
16
|
fileCount: number;
|
|
17
17
|
releaseSlug: string;
|
|
18
18
|
orgSlug: string;
|
|
19
|
-
buildId: string
|
|
19
|
+
buildId: string;
|
|
20
20
|
};
|
|
21
21
|
declare function runSourceMapPipeline(projectDir: string, distDir: string | undefined, client: BuildClient, cleanup?: boolean): Promise<PipelineResult>;
|
|
22
22
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/internal/build/source-maps/index.ts"],"sourcesContent":["import { unlink } from \"node:fs/promises\";\n\nimport { discover, normalizeDistDir } from \"./discover.js\";\n\nexport interface BuildClient {\n createRelease(): Promise<{ slug: string; orgSlug: string; buildId: string
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/internal/build/source-maps/index.ts"],"sourcesContent":["import { unlink } from \"node:fs/promises\";\n\nimport { discover, normalizeDistDir } from \"./discover.js\";\n\nexport interface BuildClient {\n createRelease(): Promise<{ slug: string; orgSlug: string; buildId: string }>;\n uploadSourceMaps(releaseSlug: string, body: FormData): Promise<void>;\n}\n\nexport type PipelineResult =\n | { ready: false; reason: \"no_source_maps\"; fileCount: 0 }\n | { ready: true; fileCount: number; releaseSlug: string; orgSlug: string; buildId: string };\n\nexport async function runSourceMapPipeline(\n projectDir: string,\n distDir: string | undefined,\n client: BuildClient,\n cleanup = true,\n): Promise<PipelineResult> {\n const { files, mapping } = await discover(projectDir, normalizeDistDir(distDir));\n\n if (files.length === 0) {\n return { ready: false, reason: \"no_source_maps\", fileCount: 0 };\n }\n\n const { slug, orgSlug, buildId } = await client.createRelease();\n\n const body = new FormData();\n const hashes: Record<string, string> = {};\n\n for (const file of files) {\n body.append(\"files\", new Blob([file.content], { type: \"application/json\" }), file.path);\n hashes[file.path] = file.hash;\n }\n\n body.append(\"metadata\", JSON.stringify({ sourceMapToGenerated: mapping, hashes }));\n\n await client.uploadSourceMaps(slug, body);\n\n if (cleanup) {\n await Promise.all(files.map((f) => unlink(f.absolute).catch(() => undefined)));\n }\n\n return { ready: true, fileCount: files.length, releaseSlug: slug, orgSlug, buildId };\n}\n"],"mappings":";;;AAaA,eAAsB,qBACpB,YACA,SACA,QACA,UAAU,MACe;CACzB,MAAM,EAAE,OAAO,YAAY,MAAM,SAAS,YAAY,iBAAiB,QAAQ,CAAC;AAEhF,KAAI,MAAM,WAAW,EACnB,QAAO;EAAE,OAAO;EAAO,QAAQ;EAAkB,WAAW;EAAG;CAGjE,MAAM,EAAE,MAAM,SAAS,YAAY,MAAM,OAAO,eAAe;CAE/D,MAAM,OAAO,IAAI,UAAU;CAC3B,MAAM,SAAiC,EAAE;AAEzC,MAAK,MAAM,QAAQ,OAAO;AACxB,OAAK,OAAO,SAAS,IAAI,KAAK,CAAC,KAAK,QAAQ,EAAE,EAAE,MAAM,oBAAoB,CAAC,EAAE,KAAK,KAAK;AACvF,SAAO,KAAK,QAAQ,KAAK;;AAG3B,MAAK,OAAO,YAAY,KAAK,UAAU;EAAE,sBAAsB;EAAS;EAAQ,CAAC,CAAC;AAElF,OAAM,OAAO,iBAAiB,MAAM,KAAK;AAEzC,KAAI,QACF,OAAM,QAAQ,IAAI,MAAM,KAAK,MAAM,OAAO,EAAE,SAAS,CAAC,YAAY,KAAA,EAAU,CAAC,CAAC;AAGhF,QAAO;EAAE,OAAO;EAAM,WAAW,MAAM;EAAQ,aAAa;EAAM;EAAS;EAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.d.mts","names":[],"sources":["../../src/internal/env.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"env.d.mts","names":[],"sources":["../../src/internal/env.ts"],"mappings":";;;UAKiB,YAAA;EAAA,SACN,MAAA;EAAA,SACA,MAAA;EAAA,SACA,eAAA,EAAiB,OAAA,CAAQ,GAAA;EAAA,SACzB,OAAA;IAAA,SACE,QAAA;IAAA,SACA,aAAA;EAAA;AAAA;AAAA,iBAIG,gBAAA,CAAA,GAAoB,YAAA"}
|
package/dist/internal/env.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { parseEnvValue, readFirstEnvValue } from "@interfere/types/sdk/env";
|
|
1
|
+
import { parseEnvValue } from "@interfere/types/sdk/env";
|
|
3
2
|
import { API_URL } from "@interfere/constants/api";
|
|
4
3
|
import { normalizeEnv } from "@interfere/types/sdk/runtime";
|
|
5
4
|
//#region src/internal/env.ts
|
|
@@ -10,8 +9,8 @@ function readInterfereEnv() {
|
|
|
10
9
|
apiUrl: parseEnvValue(process.env.INTERFERE_API_URL) ?? API_URL,
|
|
11
10
|
nodeEnvironment,
|
|
12
11
|
release: {
|
|
13
|
-
sourceId:
|
|
14
|
-
destinationId:
|
|
12
|
+
sourceId: parseEnvValue(process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID),
|
|
13
|
+
destinationId: parseEnvValue(process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID)
|
|
15
14
|
}
|
|
16
15
|
};
|
|
17
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.mjs","names":[],"sources":["../../src/internal/env.ts"],"sourcesContent":["import { API_URL } from \"@interfere/constants/api\";\nimport {
|
|
1
|
+
{"version":3,"file":"env.mjs","names":[],"sources":["../../src/internal/env.ts"],"sourcesContent":["import { API_URL } from \"@interfere/constants/api\";\nimport { parseEnvValue } from \"@interfere/types/sdk/env\";\nimport type { Env } from \"@interfere/types/sdk/runtime\";\nimport { normalizeEnv } from \"@interfere/types/sdk/runtime\";\n\nexport interface InterfereEnv {\n readonly apiKey: string | null;\n readonly apiUrl: string;\n readonly nodeEnvironment: Exclude<Env, null>;\n readonly release: {\n readonly sourceId: string | null;\n readonly destinationId: string | null;\n };\n}\n\nexport function readInterfereEnv(): InterfereEnv {\n const nodeEnvironment = normalizeEnv(process.env.NODE_ENV) ?? \"production\";\n return {\n apiKey: parseEnvValue(process.env.INTERFERE_API_KEY),\n apiUrl: parseEnvValue(process.env.INTERFERE_API_URL) ?? API_URL,\n nodeEnvironment,\n release: {\n sourceId: parseEnvValue(process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID),\n destinationId: parseEnvValue(\n process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID\n ),\n },\n };\n}\n"],"mappings":";;;;AAeA,SAAgB,mBAAiC;CAC/C,MAAM,kBAAkB,aAAa,QAAQ,IAAI,SAAS,IAAI;AAC9D,QAAO;EACL,QAAQ,cAAc,QAAQ,IAAI,kBAAkB;EACpD,QAAQ,cAAc,QAAQ,IAAI,kBAAkB,IAAI;EACxD;EACA,SAAS;GACP,UAAU,cAAc,QAAQ,IAAI,+BAA+B;GACnE,eAAe,cACb,QAAQ,IAAI,iCACb;GACF;EACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
//#region src/internal/route/sw-script.d.ts
|
|
2
|
-
declare const SW_SCRIPT = "importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.3.0/workbox-sw.js');\
|
|
2
|
+
declare const SW_SCRIPT = "importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.3.0/workbox-sw.js');\n\nself.addEventListener('install', function() { self.skipWaiting(); });\nself.addEventListener('activate', function(e) { e.waitUntil(self.clients.claim()); });\n\nworkbox.setConfig({ debug: false });\n\nworkbox.routing.registerRoute(\n function(ctx) {\n return ctx.request.method === 'POST' && ctx.url.pathname.startsWith('/api/interfere/');\n },\n new workbox.strategies.NetworkOnly({\n plugins: [\n new workbox.backgroundSync.BackgroundSyncPlugin('interfere-queue', {\n maxRetentionTime: 1440,\n }),\n {\n fetchDidSucceed: function(ctx) {\n if (ctx.response.status >= 500) {\n throw new Error(ctx.request.url + ' returned ' + ctx.response.status);\n }\n return ctx.response;\n },\n },\n ],\n }),\n 'POST'\n);";
|
|
3
3
|
//#endregion
|
|
4
4
|
export { SW_SCRIPT };
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
//#region src/internal/route/sw-script.ts
|
|
2
2
|
const SW_SCRIPT = `\
|
|
3
3
|
importScripts('https://storage.googleapis.com/workbox-cdn/releases/7.3.0/workbox-sw.js');
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
self.addEventListener('install', function() { self.skipWaiting(); });
|
|
6
|
+
self.addEventListener('activate', function(e) { e.waitUntil(self.clients.claim()); });
|
|
7
|
+
|
|
8
|
+
workbox.setConfig({ debug: false });
|
|
9
|
+
|
|
5
10
|
workbox.routing.registerRoute(
|
|
6
|
-
function(ctx) {
|
|
11
|
+
function(ctx) {
|
|
12
|
+
return ctx.request.method === 'POST' && ctx.url.pathname.startsWith('/api/interfere/');
|
|
13
|
+
},
|
|
7
14
|
new workbox.strategies.NetworkOnly({
|
|
8
15
|
plugins: [
|
|
9
|
-
new workbox.backgroundSync.BackgroundSyncPlugin('interfere-queue', {
|
|
10
|
-
|
|
16
|
+
new workbox.backgroundSync.BackgroundSyncPlugin('interfere-queue', {
|
|
17
|
+
maxRetentionTime: 1440,
|
|
18
|
+
}),
|
|
19
|
+
{
|
|
20
|
+
fetchDidSucceed: function(ctx) {
|
|
21
|
+
if (ctx.response.status >= 500) {
|
|
22
|
+
throw new Error(ctx.request.url + ' returned ' + ctx.response.status);
|
|
23
|
+
}
|
|
24
|
+
return ctx.response;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
11
27
|
],
|
|
12
28
|
}),
|
|
13
29
|
'POST'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sw-script.mjs","names":[],"sources":["../../../src/internal/route/sw-script.ts"],"sourcesContent":["export const SW_SCRIPT = `\\\nimportScripts('https://storage.googleapis.com/workbox-cdn/releases/7.3.0/workbox-sw.js');\
|
|
1
|
+
{"version":3,"file":"sw-script.mjs","names":[],"sources":["../../../src/internal/route/sw-script.ts"],"sourcesContent":["export const SW_SCRIPT = `\\\nimportScripts('https://storage.googleapis.com/workbox-cdn/releases/7.3.0/workbox-sw.js');\n\nself.addEventListener('install', function() { self.skipWaiting(); });\nself.addEventListener('activate', function(e) { e.waitUntil(self.clients.claim()); });\n\nworkbox.setConfig({ debug: false });\n\nworkbox.routing.registerRoute(\n function(ctx) {\n return ctx.request.method === 'POST' && ctx.url.pathname.startsWith('/api/interfere/');\n },\n new workbox.strategies.NetworkOnly({\n plugins: [\n new workbox.backgroundSync.BackgroundSyncPlugin('interfere-queue', {\n maxRetentionTime: 1440,\n }),\n {\n fetchDidSucceed: function(ctx) {\n if (ctx.response.status >= 500) {\n throw new Error(ctx.request.url + ' returned ' + ctx.response.status);\n }\n return ctx.response;\n },\n },\n ],\n }),\n 'POST'\n);`;\n"],"mappings":";AAAA,MAAa,YAAY"}
|
|
@@ -3,7 +3,7 @@ import { Env, Runtime } from "@interfere/types/sdk/runtime";
|
|
|
3
3
|
//#region src/internal/server/runtime.d.ts
|
|
4
4
|
interface ServerCaptureRuntime {
|
|
5
5
|
readonly apiKey: string | null;
|
|
6
|
-
readonly buildId: string
|
|
6
|
+
readonly buildId: string;
|
|
7
7
|
readonly environment: Env;
|
|
8
8
|
readonly ingestUrl: string;
|
|
9
9
|
readonly releaseId: string | null;
|
|
@@ -4,6 +4,7 @@ import { inferRuntime } from "@interfere/types/sdk/runtime";
|
|
|
4
4
|
//#region src/internal/server/runtime.ts
|
|
5
5
|
function resolveServerCaptureRuntime() {
|
|
6
6
|
const env = readInterfereEnv();
|
|
7
|
+
if (env.release.sourceId === null) throw new Error("[interfere] Missing NEXT_PUBLIC_INTERFERE_BUILD_ID at runtime. Ensure withInterfere() wraps your Next.js config.");
|
|
7
8
|
return {
|
|
8
9
|
apiKey: env.apiKey,
|
|
9
10
|
ingestUrl: `${env.apiUrl}${API_PATHS.INGEST}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/internal/server/runtime.ts"],"sourcesContent":["import { API_PATHS } from \"@interfere/constants/api\";\nimport type { Env, Runtime } from \"@interfere/types/sdk/runtime\";\nimport { inferRuntime } from \"@interfere/types/sdk/runtime\";\n\nimport { readInterfereEnv } from \"../env.js\";\n\nexport interface ServerCaptureRuntime {\n readonly apiKey: string | null;\n readonly buildId: string
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/internal/server/runtime.ts"],"sourcesContent":["import { API_PATHS } from \"@interfere/constants/api\";\nimport type { Env, Runtime } from \"@interfere/types/sdk/runtime\";\nimport { inferRuntime } from \"@interfere/types/sdk/runtime\";\n\nimport { readInterfereEnv } from \"../env.js\";\n\nexport interface ServerCaptureRuntime {\n readonly apiKey: string | null;\n readonly buildId: string;\n readonly environment: Env;\n readonly ingestUrl: string;\n readonly releaseId: string | null;\n readonly runtime: Runtime;\n}\n\nexport function resolveServerCaptureRuntime(): ServerCaptureRuntime {\n const env = readInterfereEnv();\n\n if (env.release.sourceId === null) {\n throw new Error(\n \"[interfere] Missing NEXT_PUBLIC_INTERFERE_BUILD_ID at runtime. \" +\n \"Ensure withInterfere() wraps your Next.js config.\"\n );\n }\n\n return {\n apiKey: env.apiKey,\n ingestUrl: `${env.apiUrl}${API_PATHS.INGEST}`,\n environment: env.nodeEnvironment,\n runtime: inferRuntime({ nextRuntime: process.env.NEXT_RUNTIME }),\n buildId: env.release.sourceId,\n releaseId: env.release.destinationId,\n };\n}\n"],"mappings":";;;;AAeA,SAAgB,8BAAoD;CAClE,MAAM,MAAM,kBAAkB;AAE9B,KAAI,IAAI,QAAQ,aAAa,KAC3B,OAAM,IAAI,MACR,mHAED;AAGH,QAAO;EACL,QAAQ,IAAI;EACZ,WAAW,GAAG,IAAI,SAAS,UAAU;EACrC,aAAa,IAAI;EACjB,SAAS,aAAa,EAAE,aAAa,QAAQ,IAAI,cAAc,CAAC;EAChE,SAAS,IAAI,QAAQ;EACrB,WAAW,IAAI,QAAQ;EACxB"}
|
package/dist/provider.d.mts
CHANGED
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
//#region src/provider.d.ts
|
|
5
|
-
type InterfereProviderProps = InterfereProviderProps$1;
|
|
6
|
-
declare function InterfereProvider({
|
|
7
|
-
children,
|
|
8
|
-
...props
|
|
9
|
-
}: InterfereProviderProps): ReactNode;
|
|
10
|
-
declare const useInterfere: typeof useInterfere$1;
|
|
11
|
-
declare const useSession: typeof useSession$1;
|
|
12
|
-
//#endregion
|
|
13
|
-
export { InterfereProvider, InterfereProviderProps, useInterfere, useSession };
|
|
1
|
+
import { InterfereProvider, useInterfere, useSession } from "@interfere/react/provider";
|
|
2
|
+
export { InterfereProvider, useInterfere, useSession };
|
package/dist/provider.mjs
CHANGED
|
@@ -1,16 +1,3 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { InterfereProvider
|
|
3
|
-
import { jsx } from "react/jsx-runtime";
|
|
4
|
-
//#region src/provider.tsx
|
|
5
|
-
function InterfereProvider({ children, ...props }) {
|
|
6
|
-
return /* @__PURE__ */ jsx(InterfereProvider$1, {
|
|
7
|
-
buildId: process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID ?? null,
|
|
8
|
-
releaseId: process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID ?? null,
|
|
9
|
-
...props,
|
|
10
|
-
children
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
const useInterfere = useInterfere$1;
|
|
14
|
-
const useSession = useSession$1;
|
|
15
|
-
//#endregion
|
|
2
|
+
import { InterfereProvider, useInterfere, useSession } from "@interfere/react/provider";
|
|
16
3
|
export { InterfereProvider, useInterfere, useSession };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@interfere/next",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Next.js SDK v2 for Interfere.",
|
|
6
6
|
"keywords": [
|
|
@@ -30,6 +30,11 @@
|
|
|
30
30
|
"types": "./dist/config.d.mts",
|
|
31
31
|
"default": "./dist/config.mjs"
|
|
32
32
|
},
|
|
33
|
+
"./instrument-client": {
|
|
34
|
+
"@source": "./src/instrument-client.ts",
|
|
35
|
+
"types": "./dist/instrument-client.d.mts",
|
|
36
|
+
"default": "./dist/instrument-client.mjs"
|
|
37
|
+
},
|
|
33
38
|
"./provider": {
|
|
34
39
|
"@source": "./src/provider.tsx",
|
|
35
40
|
"types": "./dist/provider.d.mts",
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ReleasesCreateReleaseResponse } from "@interfere/sdk/models/releases-create-release-response.js";
|
|
2
|
-
import { CreateReleaseRequest } from "@interfere/types/releases/definition";
|
|
3
|
-
|
|
4
|
-
//#region src/internal/build/release.d.ts
|
|
5
|
-
declare function createRelease(apiKey: string, apiUrl: string, buildId: string | null): Promise<ReleasesCreateReleaseResponse>;
|
|
6
|
-
declare function resolveReleaseRequest(buildId: string | null): CreateReleaseRequest;
|
|
7
|
-
declare function runGitCommand(command: string): string | null;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { createRelease, resolveReleaseRequest, runGitCommand };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release.d.mts","names":[],"sources":["../../../src/internal/build/release.ts"],"mappings":";;;;iBAQsB,aAAA,CACpB,MAAA,UACA,MAAA,UACA,OAAA,kBACC,OAAA,CAAQ,6BAAA;AAAA,iBAkBK,qBAAA,CACd,OAAA,kBACC,oBAAA;AAAA,iBA8Ca,aAAA,CAAc,OAAA"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { parseEnvValue } from "@interfere/types/sdk/env";
|
|
2
|
-
import { Interfere } from "@interfere/sdk";
|
|
3
|
-
import { InterfereHTTPError } from "@interfere/sdk/models/errors/interfere-http-error.js";
|
|
4
|
-
import { execSync } from "node:child_process";
|
|
5
|
-
//#region src/internal/build/release.ts
|
|
6
|
-
async function createRelease(apiKey, apiUrl, buildId) {
|
|
7
|
-
const request = resolveReleaseRequest(buildId);
|
|
8
|
-
const sdk = new Interfere({ serverURL: apiUrl });
|
|
9
|
-
try {
|
|
10
|
-
return await sdk.releases.createRelease(request, { headers: { "x-api-key": apiKey } });
|
|
11
|
-
} catch (error) {
|
|
12
|
-
if (error instanceof InterfereHTTPError && error.statusCode === 404) throw new Error(`Interfere release API returned 404 at '${apiUrl}/v1/releases/'. Is INTERFERE_API_URL incorrectly set?`);
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
function resolveReleaseRequest(buildId) {
|
|
17
|
-
return {
|
|
18
|
-
source: resolveGithubSource(),
|
|
19
|
-
destination: resolveVercelDestination(),
|
|
20
|
-
buildId
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
function resolveGithubSource() {
|
|
24
|
-
return {
|
|
25
|
-
provider: "github",
|
|
26
|
-
branch: parseEnvValue(process.env.VERCEL_GIT_COMMIT_REF) ?? parseEnvValue(process.env.GITHUB_REF_NAME) ?? parseEnvValue(process.env.GITHUB_HEAD_REF) ?? runGitCommand("git rev-parse --abbrev-ref HEAD") ?? "unknown",
|
|
27
|
-
commitMessage: parseEnvValue(process.env.VERCEL_GIT_COMMIT_MESSAGE) ?? runGitCommand("git log -1 --pretty=%B") ?? "",
|
|
28
|
-
commitSha: parseEnvValue(process.env.VERCEL_GIT_COMMIT_SHA) ?? parseEnvValue(process.env.GITHUB_SHA) ?? runGitCommand("git rev-parse HEAD")
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function resolveVercelDestination() {
|
|
32
|
-
const deploymentId = parseEnvValue(process.env.VERCEL_DEPLOYMENT_ID);
|
|
33
|
-
const environment = parseEnvValue(process.env.VERCEL_ENV);
|
|
34
|
-
if (!deploymentId && !environment) return null;
|
|
35
|
-
return {
|
|
36
|
-
provider: "vercel",
|
|
37
|
-
environment: environment ?? parseEnvValue(process.env.VERCEL_TARGET_ENV) ?? null,
|
|
38
|
-
deploymentId,
|
|
39
|
-
deploymentUrl: resolveVercelDeploymentUrl(),
|
|
40
|
-
environmentName: environment,
|
|
41
|
-
environmentTarget: parseEnvValue(process.env.VERCEL_TARGET_ENV)
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function runGitCommand(command) {
|
|
45
|
-
try {
|
|
46
|
-
const output = execSync(command, {
|
|
47
|
-
encoding: "utf8",
|
|
48
|
-
stdio: [
|
|
49
|
-
"ignore",
|
|
50
|
-
"pipe",
|
|
51
|
-
"ignore"
|
|
52
|
-
]
|
|
53
|
-
}).trim();
|
|
54
|
-
return output.length > 0 ? output : null;
|
|
55
|
-
} catch {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
function resolveVercelDeploymentUrl() {
|
|
60
|
-
const deploymentUrl = parseEnvValue(process.env.VERCEL_URL);
|
|
61
|
-
if (deploymentUrl === null) return null;
|
|
62
|
-
if (deploymentUrl.startsWith("https://") || deploymentUrl.startsWith("http://")) return deploymentUrl;
|
|
63
|
-
return `https://${deploymentUrl}`;
|
|
64
|
-
}
|
|
65
|
-
//#endregion
|
|
66
|
-
export { createRelease, resolveReleaseRequest, runGitCommand };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"release.mjs","names":[],"sources":["../../../src/internal/build/release.ts"],"sourcesContent":["import { Interfere } from \"@interfere/sdk\";\nimport { InterfereHTTPError } from \"@interfere/sdk/models/errors/interfere-http-error.js\";\nimport type { ReleasesCreateReleaseResponse } from \"@interfere/sdk/models/releases-create-release-response.js\";\nimport type { CreateReleaseRequest } from \"@interfere/types/releases/definition\";\nimport { parseEnvValue } from \"@interfere/types/sdk/env\";\n\nimport { execSync } from \"node:child_process\";\n\nexport async function createRelease(\n apiKey: string,\n apiUrl: string,\n buildId: string | null,\n): Promise<ReleasesCreateReleaseResponse> {\n const request = resolveReleaseRequest(buildId);\n const sdk = new Interfere({ serverURL: apiUrl });\n\n try {\n return await sdk.releases.createRelease(request, {\n headers: { \"x-api-key\": apiKey },\n });\n } catch (error) {\n if (error instanceof InterfereHTTPError && error.statusCode === 404) {\n throw new Error(\n `Interfere release API returned 404 at '${apiUrl}/v1/releases/'. Is INTERFERE_API_URL incorrectly set?`,\n );\n }\n throw error;\n }\n}\n\nexport function resolveReleaseRequest(\n buildId: string | null,\n): CreateReleaseRequest {\n const source = resolveGithubSource();\n const destination = resolveVercelDestination();\n\n return { source, destination, buildId };\n}\n\nfunction resolveGithubSource(): CreateReleaseRequest[\"source\"] {\n return {\n provider: \"github\",\n branch:\n parseEnvValue(process.env.VERCEL_GIT_COMMIT_REF) ??\n parseEnvValue(process.env.GITHUB_REF_NAME) ??\n parseEnvValue(process.env.GITHUB_HEAD_REF) ??\n runGitCommand(\"git rev-parse --abbrev-ref HEAD\") ??\n \"unknown\",\n commitMessage:\n parseEnvValue(process.env.VERCEL_GIT_COMMIT_MESSAGE) ??\n runGitCommand(\"git log -1 --pretty=%B\") ??\n \"\",\n commitSha:\n parseEnvValue(process.env.VERCEL_GIT_COMMIT_SHA) ??\n parseEnvValue(process.env.GITHUB_SHA) ??\n runGitCommand(\"git rev-parse HEAD\"),\n };\n}\n\nfunction resolveVercelDestination(): CreateReleaseRequest[\"destination\"] {\n const deploymentId = parseEnvValue(process.env.VERCEL_DEPLOYMENT_ID);\n const environment = parseEnvValue(process.env.VERCEL_ENV);\n\n if (!deploymentId && !environment) {\n return null;\n }\n\n return {\n provider: \"vercel\",\n environment:\n environment ?? parseEnvValue(process.env.VERCEL_TARGET_ENV) ?? null,\n deploymentId,\n deploymentUrl: resolveVercelDeploymentUrl(),\n environmentName: environment,\n environmentTarget: parseEnvValue(process.env.VERCEL_TARGET_ENV),\n };\n}\n\nexport function runGitCommand(command: string): string | null {\n try {\n const output = execSync(command, {\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n }).trim();\n\n return output.length > 0 ? output : null;\n } catch {\n return null;\n }\n}\n\nfunction resolveVercelDeploymentUrl(): string | null {\n const deploymentUrl = parseEnvValue(process.env.VERCEL_URL);\n if (deploymentUrl === null) {\n return null;\n }\n\n if (\n deploymentUrl.startsWith(\"https://\") ||\n deploymentUrl.startsWith(\"http://\")\n ) {\n return deploymentUrl;\n }\n\n return `https://${deploymentUrl}`;\n}\n"],"mappings":";;;;;AAQA,eAAsB,cACpB,QACA,QACA,SACwC;CACxC,MAAM,UAAU,sBAAsB,QAAQ;CAC9C,MAAM,MAAM,IAAI,UAAU,EAAE,WAAW,QAAQ,CAAC;AAEhD,KAAI;AACF,SAAO,MAAM,IAAI,SAAS,cAAc,SAAS,EAC/C,SAAS,EAAE,aAAa,QAAQ,EACjC,CAAC;UACK,OAAO;AACd,MAAI,iBAAiB,sBAAsB,MAAM,eAAe,IAC9D,OAAM,IAAI,MACR,0CAA0C,OAAO,uDAClD;AAEH,QAAM;;;AAIV,SAAgB,sBACd,SACsB;AAItB,QAAO;EAAE,QAHM,qBAAqB;EAGnB,aAFG,0BAA0B;EAEhB;EAAS;;AAGzC,SAAS,sBAAsD;AAC7D,QAAO;EACL,UAAU;EACV,QACE,cAAc,QAAQ,IAAI,sBAAsB,IAChD,cAAc,QAAQ,IAAI,gBAAgB,IAC1C,cAAc,QAAQ,IAAI,gBAAgB,IAC1C,cAAc,kCAAkC,IAChD;EACF,eACE,cAAc,QAAQ,IAAI,0BAA0B,IACpD,cAAc,yBAAyB,IACvC;EACF,WACE,cAAc,QAAQ,IAAI,sBAAsB,IAChD,cAAc,QAAQ,IAAI,WAAW,IACrC,cAAc,qBAAqB;EACtC;;AAGH,SAAS,2BAAgE;CACvE,MAAM,eAAe,cAAc,QAAQ,IAAI,qBAAqB;CACpE,MAAM,cAAc,cAAc,QAAQ,IAAI,WAAW;AAEzD,KAAI,CAAC,gBAAgB,CAAC,YACpB,QAAO;AAGT,QAAO;EACL,UAAU;EACV,aACE,eAAe,cAAc,QAAQ,IAAI,kBAAkB,IAAI;EACjE;EACA,eAAe,4BAA4B;EAC3C,iBAAiB;EACjB,mBAAmB,cAAc,QAAQ,IAAI,kBAAkB;EAChE;;AAGH,SAAgB,cAAc,SAAgC;AAC5D,KAAI;EACF,MAAM,SAAS,SAAS,SAAS;GAC/B,UAAU;GACV,OAAO;IAAC;IAAU;IAAQ;IAAS;GACpC,CAAC,CAAC,MAAM;AAET,SAAO,OAAO,SAAS,IAAI,SAAS;SAC9B;AACN,SAAO;;;AAIX,SAAS,6BAA4C;CACnD,MAAM,gBAAgB,cAAc,QAAQ,IAAI,WAAW;AAC3D,KAAI,kBAAkB,KACpB,QAAO;AAGT,KACE,cAAc,WAAW,WAAW,IACpC,cAAc,WAAW,UAAU,CAEnC,QAAO;AAGT,QAAO,WAAW"}
|
package/dist/provider.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.mts","names":[],"sources":["../src/provider.tsx"],"mappings":";;;;KAWY,sBAAA,GAAyB,wBAAA;AAAA,iBAErB,iBAAA,CAAA;EACd,QAAA;EAAA,GACG;AAAA,GACF,sBAAA,GAAyB,SAAA;AAAA,cAYf,YAAA,SAAY,cAAA;AAAA,cACZ,UAAA,SAAU,YAAA"}
|
package/dist/provider.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"provider.mjs","names":["ReactInterfereProvider","useReactInterfere","useReactSession"],"sources":["../src/provider.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n InterfereProvider as ReactInterfereProvider,\n type InterfereProviderProps as ReactInterfereProviderProps,\n useInterfere as useReactInterfere,\n useSession as useReactSession,\n} from \"@interfere/react/provider\";\n\nimport type { ReactNode } from \"react\";\n\nexport type InterfereProviderProps = ReactInterfereProviderProps;\n\nexport function InterfereProvider({\n children,\n ...props\n}: InterfereProviderProps): ReactNode {\n return (\n <ReactInterfereProvider\n buildId={process.env.NEXT_PUBLIC_INTERFERE_BUILD_ID ?? null}\n releaseId={process.env.NEXT_PUBLIC_INTERFERE_RELEASE_ID ?? null}\n {...props}\n >\n {children}\n </ReactInterfereProvider>\n );\n}\n\nexport const useInterfere = useReactInterfere;\nexport const useSession = useReactSession;\n"],"mappings":";;;;AAaA,SAAgB,kBAAkB,EAChC,UACA,GAAG,SACiC;AACpC,QACE,oBAACA,qBAAD;EACE,SAAS,QAAQ,IAAI,kCAAkC;EACvD,WAAW,QAAQ,IAAI,oCAAoC;EAC3D,GAAI;EAEH;EACsB,CAAA;;AAI7B,MAAa,eAAeC;AAC5B,MAAa,aAAaC"}
|