@grafana/plugin-types-bundler 0.2.7 → 0.2.8-canary.1594.13829022326.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/args.js CHANGED
@@ -1,22 +1,8 @@
1
- import parseArgs from 'minimist';
2
- import { join, resolve } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- const args = process.argv.slice(2);
5
- const __dirname = fileURLToPath(new URL('.', import.meta.url));
6
- export const parsedArgs = parseArgs(args, {
7
- alias: {
8
- entryPoint: 'entry-point',
9
- tsConfig: 'ts-config',
10
- outDir: 'out-dir',
11
- },
12
- string: ['entryPoint', 'tsConfig', 'outDir'],
13
- unknown: (arg) => {
14
- console.error(`Unknown argument: ${arg}`);
15
- process.exit(1);
16
- },
17
- });
18
- export const DEFAULT_ARGS = {
19
- entryPoint: undefined,
20
- tsConfig: resolve(__dirname, '../tsconfig', 'tsconfig.json'),
21
- outDir: join(process.cwd(), 'dist'),
1
+ import {
2
+ DEFAULT_ARGS,
3
+ parsedArgs
4
+ } from "./chunk-3T7KI6U2.js";
5
+ export {
6
+ DEFAULT_ARGS,
7
+ parsedArgs
22
8
  };
package/dist/bin/run.js CHANGED
@@ -1,27 +1,34 @@
1
1
  #!/usr/bin/env node
2
- import { existsSync } from 'fs';
3
- import { parsedArgs } from '../args.js';
4
- import { generateTypes } from '../bundleTypes.js';
5
- import { debug } from '../debug.js';
6
- let { entryPoint, tsConfig, outDir } = parsedArgs;
7
- if (entryPoint === undefined) {
8
- console.error('Please provide the path for the entry types file as an argument.');
9
- console.error('(E.g. "npx @grafana/plugin-types-bundler ./src/types/index.ts")');
10
- process.exit(1);
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);
11
19
  }
12
20
  if (!existsSync(entryPoint)) {
13
- console.error(`File not found: ${entryPoint}`);
14
- process.exit(1);
21
+ console.error(`File not found: ${entryPoint}`);
22
+ process.exit(1);
15
23
  }
16
- const startTime = Date.now().valueOf();
24
+ var startTime = Date.now().valueOf();
17
25
  try {
18
- console.log('⚡️ Starting to bundle types for plugin...');
19
- debug({ entryPoint, tsConfig, outDir });
20
- generateTypes({ entryPoint, tsConfig, outDir });
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);
21
32
  }
22
- catch (error) {
23
- console.error('Error while bundling types:', error);
24
- process.exit(1);
25
- }
26
- const endTime = Date.now().valueOf();
27
- console.log(`📦 Types bundled successfully (${endTime - startTime}ms)`);
33
+ var endTime = Date.now().valueOf();
34
+ console.log(`\u{1F4E6} Types bundled successfully (${endTime - startTime}ms)`);
@@ -1,60 +1,8 @@
1
- import { getImportsInfo } from '@grafana/levitate';
2
- import { generateDtsBundle } from 'jackw-dts-bundle-gen-test';
3
- import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
4
- import { extname, join } from 'node:path';
5
- import { DEFAULT_ARGS } from './args.js';
6
- import { debug } from './debug.js';
7
- export const generateTypes = (args) => {
8
- const { entryPoint, tsConfig, outDir } = handleArgs(args);
9
- const entryPoints = [
10
- {
11
- filePath: entryPoint,
12
- libraries: {
13
- inlinedLibraries: getImportedPackages(entryPoint),
14
- },
15
- },
16
- ];
17
- const options = {
18
- preferredConfigPath: tsConfig,
19
- };
20
- debug({ ...entryPoints[0], ...options });
21
- const dts = generateDtsBundle(entryPoints, options);
22
- const cleanedDts = cleanDTS(dts);
23
- mkdirSync(outDir, { recursive: true });
24
- writeFileSync(join(outDir, 'index.d.ts'), cleanedDts);
1
+ import {
2
+ generateTypes
3
+ } from "./chunk-SCBFTMD7.js";
4
+ import "./chunk-3T7KI6U2.js";
5
+ import "./chunk-DOK72DBQ.js";
6
+ export {
7
+ generateTypes
25
8
  };
26
- function getImportedPackages(entryPoint) {
27
- const { imports } = getImportsInfo(entryPoint);
28
- const npmPackages = imports
29
- .map((importInfo) => importInfo.packageName)
30
- .filter((packageName) => isBareSpecifier(packageName));
31
- return Array.from(new Set(npmPackages));
32
- }
33
- function cleanDTS(dtsContent) {
34
- let dtsString = dtsContent.join('\n');
35
- dtsString = dtsString.replace('export {};', '');
36
- return dtsString.trim() + '\n';
37
- }
38
- function isBareSpecifier(packageName) {
39
- const isRelative = packageName.startsWith('./') || packageName.startsWith('../') || packageName.startsWith('/');
40
- const hasExtension = extname(packageName) !== '';
41
- return !isRelative && !hasExtension;
42
- }
43
- function handleArgs(args) {
44
- let { entryPoint, tsConfig, outDir } = args;
45
- if (entryPoint === undefined) {
46
- throw new Error('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")');
47
- }
48
- if (!existsSync(entryPoint)) {
49
- throw new Error(`Entry point not found: ${entryPoint}`);
50
- }
51
- if (!Boolean(tsConfig)) {
52
- debug("No tsconfig provided, using default tsconfig.json ('../tsconfig/tsconfig.json')");
53
- tsConfig = DEFAULT_ARGS.tsConfig;
54
- }
55
- if (!Boolean(outDir)) {
56
- debug("No outDir provided, using default dist ('./dist')");
57
- outDir = DEFAULT_ARGS.outDir;
58
- }
59
- return { entryPoint, tsConfig, outDir };
60
- }
@@ -0,0 +1,28 @@
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
+ };
@@ -0,0 +1,7 @@
1
+ // src/debug.ts
2
+ import createDebug from "debug";
3
+ var debug = createDebug("plugin-types-bundler");
4
+
5
+ export {
6
+ debug
7
+ };
@@ -0,0 +1,70 @@
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
+ };
package/dist/debug.js CHANGED
@@ -1,2 +1,6 @@
1
- import createDebug from 'debug';
2
- export const debug = createDebug('plugin-types-bundler');
1
+ import {
2
+ debug
3
+ } from "./chunk-DOK72DBQ.js";
4
+ export {
5
+ debug
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/plugin-types-bundler",
3
- "version": "0.2.7",
3
+ "version": "0.2.8-canary.1594.13829022326.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": "tsc --project tsconfig.json && chmod +x ./dist/bin/run.js",
21
- "dev": "tsc --project tsconfig.json --watch",
20
+ "build": "tsup",
21
+ "dev": "tsup --watch ./src",
22
22
  "lint": "eslint --cache ./src",
23
23
  "lint:fix": "npm run lint -- --fix",
24
24
  "typecheck": "tsc --noEmit"
@@ -50,10 +50,10 @@
50
50
  "dependencies": {
51
51
  "@grafana/levitate": "^0.16.0",
52
52
  "@types/minimist": "^1.2.2",
53
- "@types/node": "22.13.8",
53
+ "@types/node": "22.13.10",
54
54
  "debug": "^4.3.4",
55
55
  "jackw-dts-bundle-gen-test": "^9.5.1",
56
56
  "minimist": "^1.2.8"
57
57
  },
58
- "gitHead": "aac915a269accd1150d594928235952de8b58854"
58
+ "gitHead": "2221acaad0d985a3d2d08c9a982338d256d145a4"
59
59
  }