@kargo-pulse/vite-plugin 0.1.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/dist/index.cjs +2 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +53 -0
- package/package.json +35 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("node:fs/promises"),s=require("node:path");function c(t){let r;return{name:"kargo-pulse-sourcemap",apply:"build",configResolved(o){r=o},async closeBundle(){if(!r)return;const o=s.join(r.root,r.build.outDir),a=await l(o);if(a.length===0)return;const n=t.fetcher??globalThis.fetch;if(!n)throw new Error("Kargo Pulse sourcemap upload requires fetch");const e=await n(t.endpoint,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({appId:t.appId,release:t.release,files:a})});if(!e.ok)throw new Error(`Kargo Pulse sourcemap upload failed: ${e.status} ${await e.text()}`)}}}async function l(t){const r=[];async function o(a){const n=await u.readdir(a,{withFileTypes:!0});for(const e of n){const i=s.join(a,e.name);if(e.isDirectory()){await o(i);continue}e.isFile()&&e.name.endsWith(".map")&&r.push({fileName:s.relative(t,i),content:await u.readFile(i,"utf8")})}}return await o(t),r}exports.kargoPulseSourcemapPlugin=c;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from 'vite';
|
|
2
|
+
export interface KargoPulseSourcemapPluginOptions {
|
|
3
|
+
appId: string;
|
|
4
|
+
release: string;
|
|
5
|
+
endpoint: string;
|
|
6
|
+
fetcher?: typeof fetch;
|
|
7
|
+
}
|
|
8
|
+
export declare function kargoPulseSourcemapPlugin(options: KargoPulseSourcemapPluginOptions): Plugin;
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { readdir as c, readFile as u } from "node:fs/promises";
|
|
2
|
+
import { join as s, relative as l } from "node:path";
|
|
3
|
+
function m(t) {
|
|
4
|
+
let r;
|
|
5
|
+
return {
|
|
6
|
+
name: "kargo-pulse-sourcemap",
|
|
7
|
+
apply: "build",
|
|
8
|
+
configResolved(a) {
|
|
9
|
+
r = a;
|
|
10
|
+
},
|
|
11
|
+
async closeBundle() {
|
|
12
|
+
if (!r) return;
|
|
13
|
+
const a = s(r.root, r.build.outDir), o = await f(a);
|
|
14
|
+
if (o.length === 0) return;
|
|
15
|
+
const n = t.fetcher ?? globalThis.fetch;
|
|
16
|
+
if (!n)
|
|
17
|
+
throw new Error("Kargo Pulse sourcemap upload requires fetch");
|
|
18
|
+
const e = await n(t.endpoint, {
|
|
19
|
+
method: "POST",
|
|
20
|
+
headers: { "content-type": "application/json" },
|
|
21
|
+
body: JSON.stringify({
|
|
22
|
+
appId: t.appId,
|
|
23
|
+
release: t.release,
|
|
24
|
+
files: o
|
|
25
|
+
})
|
|
26
|
+
});
|
|
27
|
+
if (!e.ok)
|
|
28
|
+
throw new Error(`Kargo Pulse sourcemap upload failed: ${e.status} ${await e.text()}`);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
async function f(t) {
|
|
33
|
+
const r = [];
|
|
34
|
+
async function a(o) {
|
|
35
|
+
const n = await c(o, { withFileTypes: !0 });
|
|
36
|
+
for (const e of n) {
|
|
37
|
+
const i = s(o, e.name);
|
|
38
|
+
if (e.isDirectory()) {
|
|
39
|
+
await a(i);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
e.isFile() && e.name.endsWith(".map") && r.push({
|
|
43
|
+
fileName: l(t, i),
|
|
44
|
+
content: await u(i, "utf8")
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return await a(t), r;
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
m as kargoPulseSourcemapPlugin
|
|
52
|
+
};
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@kargo-pulse/vite-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"license": "UNLICENSED",
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist/**/*.js",
|
|
14
|
+
"dist/**/*.cjs",
|
|
15
|
+
"dist/**/*.d.ts",
|
|
16
|
+
"package.json"
|
|
17
|
+
],
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"require": "./dist/index.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"vite": "^6.0.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"vite": "^6.2.2"
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "vite build && tsc -p tsconfig.json --emitDeclarationOnly",
|
|
33
|
+
"typecheck": "tsc --noEmit"
|
|
34
|
+
}
|
|
35
|
+
}
|