The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/packages/grafana-toolkit/bin/grafana-toolkit.js

49 lines
1.4 KiB

#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
let includeInternalScripts = false;
const isLinkedMode = () => {
// In circleci we are in linked mode. Detect by using the circle working directory,
// rather than the present working directory.
const pwd = process.env.CIRCLE_WORKING_DIRECTORY || process.env.PWD || process.cwd();
if (path.basename(pwd) === 'grafana-toolkit') {
return true;
}
try {
const resolvedPath = require.resolve('@grafana/toolkit');
return fs.lstatSync(resolvedPath).isSymbolicLink();
} catch {
return false;
}
};
const entrypoint = () => {
const entrypointBase = `${__dirname}/../src/cli/index`;
const resolvedJsDir = path.resolve(`${entrypointBase}.js`);
const resolvedTsDir = path.resolve(`${entrypointBase}.ts`);
// IF we have a toolkit directory AND linked grafana toolkit AND the toolkit dir is a symbolic lik
// THEN run everything in linked mode
if (isLinkedMode() || !fs.existsSync(resolvedJsDir)) {
console.log('Running in local/linked mode');
// This bin is used for cli executed internally
var tsProjectPath = path.resolve(__dirname, '../tsconfig.json');
require('ts-node').register({
project: tsProjectPath,
transpileOnly: true,
});
includeInternalScripts = true;
return resolvedTsDir;
}
// The default entrypoint must exist, return it now.
return resolvedJsDir;
};
require(entrypoint()).run(includeInternalScripts);