@grafana/react-detect 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/LICENSE +201 -0
- package/README.md +23 -0
- package/dist/analyzer.js +37 -0
- package/dist/bin/run.js +12 -0
- package/dist/commands/detect19.js +41 -0
- package/dist/file-scanner.js +20 -0
- package/dist/libs/output/src/index.js +132 -0
- package/dist/parser.js +23 -0
- package/dist/patterns/definitions.js +119 -0
- package/dist/patterns/matcher.js +146 -0
- package/dist/reporters/console.js +132 -0
- package/dist/reporters/json.js +11 -0
- package/dist/results.js +128 -0
- package/dist/source-extractor.js +80 -0
- package/dist/utils/analyzer.js +88 -0
- package/dist/utils/ast.js +20 -0
- package/dist/utils/dependencies.js +97 -0
- package/dist/utils/output.js +5 -0
- package/dist/utils/plugin.js +36 -0
- package/package.json +42 -0
- package/src/analyzer.test.ts +14 -0
- package/src/analyzer.ts +42 -0
- package/src/bin/run.ts +17 -0
- package/src/commands/detect19.ts +53 -0
- package/src/file-scanner.ts +19 -0
- package/src/parser.ts +22 -0
- package/src/patterns/definitions.ts +125 -0
- package/src/patterns/matcher.test.ts +221 -0
- package/src/patterns/matcher.ts +268 -0
- package/src/reporters/console.ts +139 -0
- package/src/reporters/json.ts +13 -0
- package/src/results.ts +170 -0
- package/src/source-extractor.ts +101 -0
- package/src/types/patterns.ts +14 -0
- package/src/types/plugins.ts +6 -0
- package/src/types/processors.ts +40 -0
- package/src/types/reporters.ts +53 -0
- package/src/utils/analyzer.test.ts +190 -0
- package/src/utils/analyzer.ts +120 -0
- package/src/utils/ast.ts +19 -0
- package/src/utils/dependencies.test.ts +123 -0
- package/src/utils/dependencies.ts +141 -0
- package/src/utils/output.ts +3 -0
- package/src/utils/plugin.ts +72 -0
- package/test/fixtures/dependencies/package-lock.json +49 -0
- package/test/fixtures/dependencies/package.json +16 -0
- package/test/fixtures/patterns/module.js.map +1 -0
- package/tsconfig.json +9 -0
- package/vitest.config.ts +12 -0
package/src/utils/ast.ts
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function walk(node: any, callback: (node: any) => void): void {
|
|
2
|
+
callback(node);
|
|
3
|
+
for (const key in node) {
|
|
4
|
+
if (node[key] && typeof node[key] === 'object') {
|
|
5
|
+
if (Array.isArray(node[key])) {
|
|
6
|
+
node[key].forEach((child) => walk(child, callback));
|
|
7
|
+
} else if (node[key].type) {
|
|
8
|
+
walk(node[key], callback);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function getSurroundingCode(code: string, node: any): string {
|
|
15
|
+
const lines = code.split('\n');
|
|
16
|
+
const startLine = Math.max(0, node.loc.start.line - 3);
|
|
17
|
+
const endLine = Math.min(lines.length, node.loc.end.line + 2);
|
|
18
|
+
return lines.slice(startLine, endLine).join('\n');
|
|
19
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { DependencyContext, isExternal } from './dependencies.js';
|
|
3
|
+
|
|
4
|
+
describe('DependencyContext', () => {
|
|
5
|
+
let context: DependencyContext;
|
|
6
|
+
const fixturesPath = join(__dirname, '../../test/fixtures/dependencies');
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
context = new DependencyContext();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('loadDependencies', () => {
|
|
13
|
+
it('should load direct dependencies from package.json', async () => {
|
|
14
|
+
await context.loadDependencies(fixturesPath);
|
|
15
|
+
|
|
16
|
+
expect(context.isDirect('has')).toBe(true);
|
|
17
|
+
expect(context.getVersion('has')).toBe('^1.0.4');
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('should load dev dependencies from package.json', async () => {
|
|
21
|
+
await context.loadDependencies(fixturesPath);
|
|
22
|
+
|
|
23
|
+
expect(context.isDirect('debug')).toBe(true);
|
|
24
|
+
expect(context.getVersion('debug')).toBe('^4.4.3');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('findRootDependency', () => {
|
|
29
|
+
it('should return package name if it is a direct dependency', async () => {
|
|
30
|
+
await context.loadDependencies(fixturesPath);
|
|
31
|
+
|
|
32
|
+
expect(context.findRootDependency('has')).toBe('has');
|
|
33
|
+
expect(context.findRootDependency('debug')).toBe('debug');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('should find root dependency for transitive packages', async () => {
|
|
37
|
+
await context.loadDependencies(fixturesPath);
|
|
38
|
+
|
|
39
|
+
const rootDep = context.findRootDependency('ms');
|
|
40
|
+
expect(rootDep).toBe('debug');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('should return package name as fallback if not found in tree', async () => {
|
|
44
|
+
await context.loadDependencies(fixturesPath);
|
|
45
|
+
|
|
46
|
+
expect(context.findRootDependency('unknown-package')).toBe('unknown-package');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('isDirect', () => {
|
|
51
|
+
it('should return true for direct dependencies', async () => {
|
|
52
|
+
await context.loadDependencies(fixturesPath);
|
|
53
|
+
|
|
54
|
+
expect(context.isDirect('has')).toBe(true);
|
|
55
|
+
expect(context.isDirect('debug')).toBe(true);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should return false for transitive dependencies', async () => {
|
|
59
|
+
await context.loadDependencies(fixturesPath);
|
|
60
|
+
|
|
61
|
+
expect(context.isDirect('ms')).toBe(false);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return false for unknown packages', async () => {
|
|
65
|
+
await context.loadDependencies(fixturesPath);
|
|
66
|
+
|
|
67
|
+
expect(context.isDirect('unknown-package')).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('getVersion', () => {
|
|
72
|
+
it('should return version for direct dependencies', async () => {
|
|
73
|
+
await context.loadDependencies(fixturesPath);
|
|
74
|
+
|
|
75
|
+
expect(context.getVersion('has')).toBe('^1.0.4');
|
|
76
|
+
expect(context.getVersion('debug')).toBe('^4.4.3');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('should return undefined for transitive dependencies', async () => {
|
|
80
|
+
await context.loadDependencies(fixturesPath);
|
|
81
|
+
|
|
82
|
+
expect(context.getVersion('ms')).toBeUndefined();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should return undefined for unknown packages', async () => {
|
|
86
|
+
await context.loadDependencies(fixturesPath);
|
|
87
|
+
|
|
88
|
+
expect(context.getVersion('unknown-package')).toBeUndefined();
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('getAllDependencies', () => {
|
|
93
|
+
it('should return combined dependencies and devDependencies', async () => {
|
|
94
|
+
await context.loadDependencies(fixturesPath);
|
|
95
|
+
|
|
96
|
+
const allDeps = context.getAllDependencies();
|
|
97
|
+
expect(allDeps.has('has')).toBe(true);
|
|
98
|
+
expect(allDeps.has('debug')).toBe(true);
|
|
99
|
+
expect(allDeps.size).toBe(2);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('isExternal', () => {
|
|
104
|
+
it('should return true for Grafana external packages', () => {
|
|
105
|
+
expect(isExternal('react')).toBe(true);
|
|
106
|
+
expect(isExternal('react-dom')).toBe(true);
|
|
107
|
+
expect(isExternal('@grafana/data')).toBe(true);
|
|
108
|
+
expect(isExternal('@grafana/ui')).toBe(true);
|
|
109
|
+
expect(isExternal('@emotion/css')).toBe(true);
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
it('should return true for sub-paths of external packages', () => {
|
|
113
|
+
expect(isExternal('react/jsx-runtime')).toBe(true);
|
|
114
|
+
expect(isExternal('@grafana/data/utils')).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should return false for non-external packages', () => {
|
|
118
|
+
expect(isExternal('axios')).toBe(false);
|
|
119
|
+
expect(isExternal('express')).toBe(false);
|
|
120
|
+
expect(isExternal('@some-org/package')).toBe(false);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
});
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { parsePnpmProject, parseNpmLockV2Project, parseYarnLockV2Project } from 'snyk-nodejs-lockfile-parser';
|
|
3
|
+
import type { DepGraph } from '@snyk/dep-graph';
|
|
4
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
5
|
+
import { readJsonFile } from './plugin.js';
|
|
6
|
+
|
|
7
|
+
export class DependencyContext {
|
|
8
|
+
private dependencies: Map<string, string> = new Map();
|
|
9
|
+
private devDependencies: Map<string, string> = new Map();
|
|
10
|
+
private depGraph: DepGraph | null = null;
|
|
11
|
+
|
|
12
|
+
async loadDependencies(pluginRoot = process.cwd()): Promise<void> {
|
|
13
|
+
const lockfile = this.findLockfile(pluginRoot);
|
|
14
|
+
const packageJsonPath = join(pluginRoot, 'package.json');
|
|
15
|
+
|
|
16
|
+
if (lockfile) {
|
|
17
|
+
const pkgJsonContent = readJsonFile(packageJsonPath);
|
|
18
|
+
const lockfileContent = readFileSync(join(pluginRoot, lockfile), 'utf8');
|
|
19
|
+
const pkgJsonContentString = JSON.stringify(pkgJsonContent);
|
|
20
|
+
if (lockfile === 'pnpm-lock.yaml') {
|
|
21
|
+
this.depGraph = await parsePnpmProject(pkgJsonContentString, lockfileContent, {
|
|
22
|
+
includeDevDeps: true,
|
|
23
|
+
includeOptionalDeps: true,
|
|
24
|
+
strictOutOfSync: false,
|
|
25
|
+
pruneWithinTopLevelDeps: false,
|
|
26
|
+
});
|
|
27
|
+
} else if (lockfile === 'package-lock.json') {
|
|
28
|
+
this.depGraph = await parseNpmLockV2Project(pkgJsonContentString, lockfileContent, {
|
|
29
|
+
includeDevDeps: true,
|
|
30
|
+
includeOptionalDeps: true,
|
|
31
|
+
strictOutOfSync: false,
|
|
32
|
+
pruneCycles: false,
|
|
33
|
+
});
|
|
34
|
+
} else if (lockfile === 'yarn.lock') {
|
|
35
|
+
this.depGraph = await parseYarnLockV2Project(pkgJsonContentString, lockfileContent, {
|
|
36
|
+
includeDevDeps: true,
|
|
37
|
+
includeOptionalDeps: true,
|
|
38
|
+
strictOutOfSync: false,
|
|
39
|
+
pruneWithinTopLevelDeps: true,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (pkgJsonContent.dependencies) {
|
|
44
|
+
Object.entries(pkgJsonContent.dependencies).forEach(([name, version]) => {
|
|
45
|
+
this.dependencies.set(name, version as string);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (pkgJsonContent.devDependencies) {
|
|
49
|
+
Object.entries(pkgJsonContent.devDependencies).forEach(([name, version]) => {
|
|
50
|
+
this.devDependencies.set(name, version as string);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
} else {
|
|
54
|
+
throw new Error(`No lockfile found in ${pluginRoot}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
private findLockfile(pluginRoot: string): string | null {
|
|
59
|
+
const lockfiles = ['package-lock.json', 'pnpm-lock.yaml', 'yarn.lock'];
|
|
60
|
+
for (const lockfile of lockfiles) {
|
|
61
|
+
if (existsSync(join(pluginRoot, lockfile))) {
|
|
62
|
+
return lockfile;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
findRootDependency(packageName: string): string {
|
|
69
|
+
if (this.isDirect(packageName)) {
|
|
70
|
+
return packageName;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (this.depGraph) {
|
|
74
|
+
try {
|
|
75
|
+
const pkgs = this.depGraph.getPkgs().filter((p) => p.name === packageName);
|
|
76
|
+
|
|
77
|
+
if (pkgs.length > 0) {
|
|
78
|
+
const paths = this.depGraph.pkgPathsToRoot(pkgs[0]);
|
|
79
|
+
|
|
80
|
+
if (paths.length > 0 && paths[0].length > 1) {
|
|
81
|
+
return paths[0][paths[0].length - 2].name;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return packageName;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
isDirect(packageName: string): boolean {
|
|
93
|
+
return this.dependencies.has(packageName) || this.devDependencies.has(packageName);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
getVersion(packageName: string): string | undefined {
|
|
97
|
+
return this.dependencies.get(packageName) || this.devDependencies.get(packageName);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
getAllDependencies(): Map<string, string> {
|
|
101
|
+
return new Map([...this.dependencies, ...this.devDependencies]);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export const GRAFANA_EXTERNALS = [
|
|
106
|
+
'@emotion/css',
|
|
107
|
+
'@emotion/react',
|
|
108
|
+
'@grafana/data',
|
|
109
|
+
'@grafana/runtime',
|
|
110
|
+
'@grafana/slate-react',
|
|
111
|
+
'@grafana/ui',
|
|
112
|
+
'angular',
|
|
113
|
+
'd3',
|
|
114
|
+
'emotion',
|
|
115
|
+
'i18next',
|
|
116
|
+
'jquery',
|
|
117
|
+
'lodash',
|
|
118
|
+
'moment',
|
|
119
|
+
'prismjs',
|
|
120
|
+
'react-dom',
|
|
121
|
+
'react-redux',
|
|
122
|
+
'react-router-dom',
|
|
123
|
+
'react-router',
|
|
124
|
+
'react',
|
|
125
|
+
'redux',
|
|
126
|
+
'rxjs',
|
|
127
|
+
'slate-plain-serializer',
|
|
128
|
+
'slate',
|
|
129
|
+
];
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Check if a package is externalized by Grafana
|
|
133
|
+
*/
|
|
134
|
+
export function isExternal(packageName: string): boolean {
|
|
135
|
+
// Direct match
|
|
136
|
+
if (GRAFANA_EXTERNALS.includes(packageName)) {
|
|
137
|
+
return true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
return GRAFANA_EXTERNALS.some((external) => packageName.startsWith(external + '/'));
|
|
141
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
|
|
4
|
+
interface PluginJson {
|
|
5
|
+
id: string;
|
|
6
|
+
type: string;
|
|
7
|
+
info: {
|
|
8
|
+
version: string;
|
|
9
|
+
};
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let cachedPluginJson: PluginJson | null = null;
|
|
14
|
+
|
|
15
|
+
export function getPluginJson(dir?: string) {
|
|
16
|
+
if (cachedPluginJson) {
|
|
17
|
+
return cachedPluginJson;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const srcPath = dir ? path.join(dir, 'dist') : path.join(process.cwd(), 'dist');
|
|
21
|
+
const pluginJsonPath = path.join(srcPath, 'plugin.json');
|
|
22
|
+
cachedPluginJson = readJsonFile(pluginJsonPath);
|
|
23
|
+
return cachedPluginJson;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function isFile(path: string) {
|
|
27
|
+
try {
|
|
28
|
+
return fs.lstatSync(path).isFile();
|
|
29
|
+
} catch (e) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function readJsonFile(filename: string) {
|
|
35
|
+
if (!isFile(filename)) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`There is no "${path.basename(
|
|
38
|
+
filename
|
|
39
|
+
)}" file found at "${filename}". Make sure you run this command from a plugins root directory.`
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
return JSON.parse(fs.readFileSync(filename).toString());
|
|
45
|
+
} catch (error: unknown) {
|
|
46
|
+
throw new Error(`Failed to load json file ${filename}: ${error instanceof Error ? error.message : String(error)}`);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function hasTsConfigAutomaticJsx(): boolean {
|
|
51
|
+
const tsConfigPathsToCheck = ['tsconfig.json', '.config/tsconfig.json'];
|
|
52
|
+
|
|
53
|
+
for (const tsConfigPath of tsConfigPathsToCheck) {
|
|
54
|
+
const jsxConfig = readJsonFile(path.join(process.cwd(), tsConfigPath));
|
|
55
|
+
const jsx = jsxConfig?.compilerOptions?.jsx;
|
|
56
|
+
if (jsx === 'react-jsx' || jsx === 'react-jsxdev') {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function hasSwcAutomaticJsx(): boolean {
|
|
64
|
+
const webpackConfigPathsToCheck = ['webpack.config.js', '.config/webpack/webpack.config.js'];
|
|
65
|
+
for (const webpackConfigPath of webpackConfigPathsToCheck) {
|
|
66
|
+
const webpackConfig = fs.readFileSync(path.join(process.cwd(), webpackConfigPath)).toString();
|
|
67
|
+
if (webpackConfig.includes("runtime: 'automatic'")) {
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simple-npm-check",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"name": "simple-npm-check",
|
|
9
|
+
"version": "1.0.0",
|
|
10
|
+
"license": "ISC",
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"debug": "^4.4.3",
|
|
13
|
+
"has": "^1.0.4"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"node_modules/debug": {
|
|
17
|
+
"version": "4.4.3",
|
|
18
|
+
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
|
|
19
|
+
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
|
|
20
|
+
"license": "MIT",
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"ms": "^2.1.3"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=6.0"
|
|
26
|
+
},
|
|
27
|
+
"peerDependenciesMeta": {
|
|
28
|
+
"supports-color": {
|
|
29
|
+
"optional": true
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"node_modules/has": {
|
|
34
|
+
"version": "1.0.4",
|
|
35
|
+
"resolved": "https://registry.npmjs.org/has/-/has-1.0.4.tgz",
|
|
36
|
+
"integrity": "sha512-qdSAmqLF6209RFj4VVItywPMbm3vWylknmB3nvNiUIs72xAimcM8nVYxYr7ncvZq5qzk9MKIZR8ijqD/1QuYjQ==",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">= 0.4.0"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"node_modules/ms": {
|
|
43
|
+
"version": "2.1.3",
|
|
44
|
+
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
|
45
|
+
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "simple-npm-check",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"license": "ISC",
|
|
6
|
+
"author": "",
|
|
7
|
+
"type": "commonjs",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"scripts": {
|
|
10
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"debug": "^4.4.3",
|
|
14
|
+
"has": "^1.0.4"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","mappings":";;oEAAAA,EAAOC,QAAUC,C,UCAjBF,EAAOC,QAAUE,C,GCCbC,EAA2B,CAAC,EAGhC,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBE,IAAjBD,EACH,OAAOA,EAAaN,QAGrB,IAAID,EAASI,EAAyBE,GAAY,CAGjDL,QAAS,CAAC,GAOX,OAHAQ,EAAoBH,GAAUN,EAAQA,EAAOC,QAASI,GAG/CL,EAAOC,OACf,CCrBAI,EAAoBK,EAAKV,IACxB,IAAIW,EAASX,GAAUA,EAAOY,WAC7B,IAAOZ,EAAiB,QACxB,IAAM,EAEP,OADAK,EAAoBQ,EAAEF,EAAQ,CAAEG,EAAGH,IAC5BA,CAAM,ECLdN,EAAoBQ,EAAI,CAACZ,EAASc,KACjC,IAAI,IAAIC,KAAOD,EACXV,EAAoBY,EAAEF,EAAYC,KAASX,EAAoBY,EAAEhB,EAASe,IAC5EE,OAAOC,eAAelB,EAASe,EAAK,CAAEI,YAAY,EAAMC,IAAKN,EAAWC,IAE1E,ECNDX,EAAoBY,EAAI,CAACK,EAAKC,IAAUL,OAAOM,UAAUC,eAAeC,KAAKJ,EAAKC,GCClFlB,EAAoBsB,EAAK1B,IACH,oBAAX2B,QAA0BA,OAAOC,aAC1CX,OAAOC,eAAelB,EAAS2B,OAAOC,YAAa,CAAEC,MAAO,WAE7DZ,OAAOC,eAAelB,EAAS,aAAc,CAAE6B,OAAO,GAAO,ECL9DzB,EAAoB0B,EAAI,8C,+ECGxB,IACE,KAAiB,QACb,QAAkBC,MAAM,EAAG,QAAkBC,YAAY,KAAO,GAChE,8C,sBCJC,MAAMC,EAAc,EAAGC,UACrB,kBAACC,MAAAA,KAAKD,GAGfD,EAAYG,aAAe,CACzBF,KAAM,gBAGR,U","sources":["webpack://heywesty-trafficlight-panel/external amd \"module\"","webpack://heywesty-trafficlight-panel/external amd \"react\"","webpack://heywesty-trafficlight-panel/webpack/bootstrap","webpack://heywesty-trafficlight-panel/webpack/runtime/compat get default export","webpack://heywesty-trafficlight-panel/webpack/runtime/define property getters","webpack://heywesty-trafficlight-panel/webpack/runtime/hasOwnProperty shorthand","webpack://heywesty-trafficlight-panel/webpack/runtime/make namespace object","webpack://heywesty-trafficlight-panel/webpack/runtime/publicPath","webpack://heywesty-trafficlight-panel/./node_modules/grafana-public-path.js","webpack://heywesty-trafficlight-panel/./module.tsx"],"sourcesContent":["module.exports = __WEBPACK_EXTERNAL_MODULE__308__;","module.exports = __WEBPACK_EXTERNAL_MODULE__959__;","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","__webpack_require__.p = \"public/plugins/heywesty-trafficlight-panel/\";","\nimport amdMetaModule from 'amd-module';\n\n__webpack_public_path__ =\n amdMetaModule && amdMetaModule.uri\n ? amdMetaModule.uri.slice(0, amdMetaModule.uri.lastIndexOf('/') + 1)\n : 'public/plugins/heywesty-trafficlight-panel/';\n","import React from 'react';\n\nexport const MyComponent = ({ name }: { name: string }) => {\n return <div>{name}</div>;\n};\n\nMyComponent.defaultProps = {\n name: 'My Component',\n};\n\nexport default MyComponent;\n"],"names":["module","exports","__WEBPACK_EXTERNAL_MODULE__308__","__WEBPACK_EXTERNAL_MODULE__959__","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","n","getter","__esModule","d","a","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","r","Symbol","toStringTag","value","p","slice","lastIndexOf","MyComponent","name","div","defaultProps"],"sourceRoot":""}
|
package/tsconfig.json
ADDED
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { defineProject, mergeConfig } from 'vitest/config';
|
|
3
|
+
import configShared from '../../vitest.config.base.js';
|
|
4
|
+
|
|
5
|
+
export default mergeConfig(
|
|
6
|
+
configShared,
|
|
7
|
+
defineProject({
|
|
8
|
+
test: {
|
|
9
|
+
root: resolve(__dirname),
|
|
10
|
+
},
|
|
11
|
+
})
|
|
12
|
+
);
|