@grafana/plugin-types-bundler 0.3.0-canary.1597.13828816481.0 → 0.3.1-canary.1688.14351851013.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/CHANGELOG.md +12 -0
- package/package.json +4 -4
- package/dist/args.js +0 -8
- package/dist/bin/run.js +0 -34
- package/dist/bundleTypes.js +0 -8
- package/dist/chunk-3T7KI6U2.js +0 -28
- package/dist/chunk-DOK72DBQ.js +0 -7
- package/dist/chunk-SCBFTMD7.js +0 -70
- package/dist/debug.js +0 -6
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
# v0.3.0 (Thu Mar 13 2025)
|
2
|
+
|
3
|
+
#### 🚀 Enhancement
|
4
|
+
|
5
|
+
- Feature: Consistent CLI output [#1597](https://github.com/grafana/plugin-tools/pull/1597) ([@jackw](https://github.com/jackw))
|
6
|
+
|
7
|
+
#### Authors: 1
|
8
|
+
|
9
|
+
- Jack Westbrook ([@jackw](https://github.com/jackw))
|
10
|
+
|
11
|
+
---
|
12
|
+
|
1
13
|
# v0.2.5 (Thu Feb 20 2025)
|
2
14
|
|
3
15
|
#### 🐛 Bug Fix
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@grafana/plugin-types-bundler",
|
3
|
-
"version": "0.3.
|
3
|
+
"version": "0.3.1-canary.1688.14351851013.0",
|
4
4
|
"description": "Bundle grafana plugin typescript types for sharing with other plugins",
|
5
5
|
"bin": "./dist/bin/run.js",
|
6
6
|
"type": "module",
|
@@ -17,8 +17,8 @@
|
|
17
17
|
],
|
18
18
|
"scripts": {
|
19
19
|
"test": "vitest --passWithNoTests",
|
20
|
-
"build": "
|
21
|
-
"dev": "
|
20
|
+
"build": "rollup -c ../../rollup.config.ts --configPlugin esbuild",
|
21
|
+
"dev": "npm run build -- -w",
|
22
22
|
"lint": "eslint --cache ./src",
|
23
23
|
"lint:fix": "npm run lint -- --fix",
|
24
24
|
"typecheck": "tsc --noEmit"
|
@@ -55,5 +55,5 @@
|
|
55
55
|
"jackw-dts-bundle-gen-test": "^9.5.1",
|
56
56
|
"minimist": "^1.2.8"
|
57
57
|
},
|
58
|
-
"gitHead": "
|
58
|
+
"gitHead": "d12e0b3b91fd84644f6a17c5c6a62bc29f0b8bca"
|
59
59
|
}
|
package/dist/args.js
DELETED
package/dist/bin/run.js
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
#!/usr/bin/env node
|
2
|
-
import {
|
3
|
-
generateTypes
|
4
|
-
} from "../chunk-SCBFTMD7.js";
|
5
|
-
import {
|
6
|
-
parsedArgs
|
7
|
-
} from "../chunk-3T7KI6U2.js";
|
8
|
-
import {
|
9
|
-
debug
|
10
|
-
} from "../chunk-DOK72DBQ.js";
|
11
|
-
|
12
|
-
// src/bin/run.ts
|
13
|
-
import { existsSync } from "fs";
|
14
|
-
var { entryPoint, tsConfig, outDir } = parsedArgs;
|
15
|
-
if (entryPoint === void 0) {
|
16
|
-
console.error("Please provide the path for the entry types file as an argument.");
|
17
|
-
console.error('(E.g. "npx @grafana/plugin-types-bundler ./src/types/index.ts")');
|
18
|
-
process.exit(1);
|
19
|
-
}
|
20
|
-
if (!existsSync(entryPoint)) {
|
21
|
-
console.error(`File not found: ${entryPoint}`);
|
22
|
-
process.exit(1);
|
23
|
-
}
|
24
|
-
var startTime = Date.now().valueOf();
|
25
|
-
try {
|
26
|
-
console.log("\u26A1\uFE0F Starting to bundle types for plugin...");
|
27
|
-
debug({ entryPoint, tsConfig, outDir });
|
28
|
-
generateTypes({ entryPoint, tsConfig, outDir });
|
29
|
-
} catch (error) {
|
30
|
-
console.error("Error while bundling types:", error);
|
31
|
-
process.exit(1);
|
32
|
-
}
|
33
|
-
var endTime = Date.now().valueOf();
|
34
|
-
console.log(`\u{1F4E6} Types bundled successfully (${endTime - startTime}ms)`);
|
package/dist/bundleTypes.js
DELETED
package/dist/chunk-3T7KI6U2.js
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
// src/args.ts
|
2
|
-
import parseArgs from "minimist";
|
3
|
-
import { join, resolve } from "node:path";
|
4
|
-
import { fileURLToPath } from "node:url";
|
5
|
-
var args = process.argv.slice(2);
|
6
|
-
var __dirname = fileURLToPath(new URL(".", import.meta.url));
|
7
|
-
var parsedArgs = parseArgs(args, {
|
8
|
-
alias: {
|
9
|
-
entryPoint: "entry-point",
|
10
|
-
tsConfig: "ts-config",
|
11
|
-
outDir: "out-dir"
|
12
|
-
},
|
13
|
-
string: ["entryPoint", "tsConfig", "outDir"],
|
14
|
-
unknown: (arg) => {
|
15
|
-
console.error(`Unknown argument: ${arg}`);
|
16
|
-
process.exit(1);
|
17
|
-
}
|
18
|
-
});
|
19
|
-
var DEFAULT_ARGS = {
|
20
|
-
entryPoint: void 0,
|
21
|
-
tsConfig: resolve(__dirname, "../tsconfig", "tsconfig.json"),
|
22
|
-
outDir: join(process.cwd(), "dist")
|
23
|
-
};
|
24
|
-
|
25
|
-
export {
|
26
|
-
parsedArgs,
|
27
|
-
DEFAULT_ARGS
|
28
|
-
};
|
package/dist/chunk-DOK72DBQ.js
DELETED
package/dist/chunk-SCBFTMD7.js
DELETED
@@ -1,70 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
DEFAULT_ARGS
|
3
|
-
} from "./chunk-3T7KI6U2.js";
|
4
|
-
import {
|
5
|
-
debug
|
6
|
-
} from "./chunk-DOK72DBQ.js";
|
7
|
-
|
8
|
-
// src/bundleTypes.ts
|
9
|
-
import { getImportsInfo } from "@grafana/levitate";
|
10
|
-
import { generateDtsBundle } from "jackw-dts-bundle-gen-test";
|
11
|
-
import { mkdirSync, writeFileSync, existsSync } from "node:fs";
|
12
|
-
import { extname, join } from "node:path";
|
13
|
-
var generateTypes = (args) => {
|
14
|
-
const { entryPoint, tsConfig, outDir } = handleArgs(args);
|
15
|
-
const entryPoints = [
|
16
|
-
{
|
17
|
-
filePath: entryPoint,
|
18
|
-
libraries: {
|
19
|
-
inlinedLibraries: getImportedPackages(entryPoint)
|
20
|
-
}
|
21
|
-
}
|
22
|
-
];
|
23
|
-
const options = {
|
24
|
-
preferredConfigPath: tsConfig
|
25
|
-
};
|
26
|
-
debug({ ...entryPoints[0], ...options });
|
27
|
-
const dts = generateDtsBundle(entryPoints, options);
|
28
|
-
const cleanedDts = cleanDTS(dts);
|
29
|
-
mkdirSync(outDir, { recursive: true });
|
30
|
-
writeFileSync(join(outDir, "index.d.ts"), cleanedDts);
|
31
|
-
};
|
32
|
-
function getImportedPackages(entryPoint) {
|
33
|
-
const { imports } = getImportsInfo(entryPoint);
|
34
|
-
const npmPackages = imports.map((importInfo) => importInfo.packageName).filter((packageName) => isBareSpecifier(packageName));
|
35
|
-
return Array.from(new Set(npmPackages));
|
36
|
-
}
|
37
|
-
function cleanDTS(dtsContent) {
|
38
|
-
let dtsString = dtsContent.join("\n");
|
39
|
-
dtsString = dtsString.replace("export {};", "");
|
40
|
-
return dtsString.trim() + "\n";
|
41
|
-
}
|
42
|
-
function isBareSpecifier(packageName) {
|
43
|
-
const isRelative = packageName.startsWith("./") || packageName.startsWith("../") || packageName.startsWith("/");
|
44
|
-
const hasExtension = extname(packageName) !== "";
|
45
|
-
return !isRelative && !hasExtension;
|
46
|
-
}
|
47
|
-
function handleArgs(args) {
|
48
|
-
let { entryPoint, tsConfig, outDir } = args;
|
49
|
-
if (entryPoint === void 0) {
|
50
|
-
throw new Error(
|
51
|
-
'Please provide the path for the entry types file as an argument. (E.g. "npx @grafana/plugin-types-bundler --entry-point ./src/types/index.ts")'
|
52
|
-
);
|
53
|
-
}
|
54
|
-
if (!existsSync(entryPoint)) {
|
55
|
-
throw new Error(`Entry point not found: ${entryPoint}`);
|
56
|
-
}
|
57
|
-
if (!Boolean(tsConfig)) {
|
58
|
-
debug("No tsconfig provided, using default tsconfig.json ('../tsconfig/tsconfig.json')");
|
59
|
-
tsConfig = DEFAULT_ARGS.tsConfig;
|
60
|
-
}
|
61
|
-
if (!Boolean(outDir)) {
|
62
|
-
debug("No outDir provided, using default dist ('./dist')");
|
63
|
-
outDir = DEFAULT_ARGS.outDir;
|
64
|
-
}
|
65
|
-
return { entryPoint, tsConfig, outDir };
|
66
|
-
}
|
67
|
-
|
68
|
-
export {
|
69
|
-
generateTypes
|
70
|
-
};
|