@grafana/create-plugin 6.4.5-canary.2349.20276304868.0 → 6.4.5-canary.2350.20292287699.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.
@@ -1,7 +1,7 @@
1
1
  import { join, dirname } from 'node:path';
2
2
  import { createRequire } from 'node:module';
3
3
  import { mkdirSync, writeFileSync, rmSync } from 'node:fs';
4
- import { styleText } from 'node:util';
4
+ import chalk from 'chalk';
5
5
  import { output } from '../utils/utils.console.js';
6
6
  import { getPackageManagerWithFallback, getPackageManagerSilentInstallCmd } from '../utils/utils.packageManager.js';
7
7
  import { execSync } from 'node:child_process';
@@ -13,11 +13,11 @@ function printChanges(context, key, description) {
13
13
  const lines = [];
14
14
  for (const [filePath, { changeType }] of Object.entries(changes)) {
15
15
  if (changeType === "add") {
16
- lines.push(`${styleText(["green"], "ADD")} ${filePath}`);
16
+ lines.push(`${chalk.green("ADD")} ${filePath}`);
17
17
  } else if (changeType === "update") {
18
- lines.push(`${styleText(["yellow"], "UPDATE")} ${filePath}`);
18
+ lines.push(`${chalk.yellow("UPDATE")} ${filePath}`);
19
19
  } else if (changeType === "delete") {
20
- lines.push(`${styleText(["red"], "DELETE")} ${filePath}`);
20
+ lines.push(`${chalk.red("DELETE")} ${filePath}`);
21
21
  }
22
22
  }
23
23
  output.addHorizontalLine("gray");
@@ -1,5 +1,5 @@
1
1
  import { machine } from 'node:os';
2
- import { styleText } from 'node:util';
2
+ import chalk from 'chalk';
3
3
  import { output } from '../../utils/utils.console.js';
4
4
  import { normalizeId } from '../../utils/utils.handlebars.js';
5
5
  import { getPackageManagerFromUserAgent } from '../../utils/utils.packageManager.js';
@@ -9,14 +9,14 @@ function printGenerateSuccessMessage(answers) {
9
9
  const { packageManagerName } = getPackageManagerFromUserAgent();
10
10
  const commands = output.bulletList([
11
11
  output.formatCode(`cd ./${directory}`),
12
- `${output.formatCode(packageManagerName + " install")} ${styleText(["dim"], "to install frontend dependencies")}`,
13
- `${output.formatCode(packageManagerName + " exec playwright install chromium")} ${styleText(["dim"], "to install e2e test dependencies")}`,
14
- `${output.formatCode(packageManagerName + " run dev")} ${styleText(["dim"], "to build (and watch) the plugin frontend code")}`,
12
+ `${output.formatCode(packageManagerName + " install")} ${chalk.dim("to install frontend dependencies")}`,
13
+ `${output.formatCode(packageManagerName + " exec playwright install chromium")} ${chalk.dim("to install e2e test dependencies")}`,
14
+ `${output.formatCode(packageManagerName + " run dev")} ${chalk.dim("to build (and watch) the plugin frontend code")}`,
15
15
  ...answers.hasBackend ? [
16
- `${getBackendCmd()} ${styleText(["dim"], "to build the plugin backend code. Rerun this command every time you edit your backend files")}`
16
+ `${getBackendCmd()} ${chalk.dim("to build the plugin backend code. Rerun this command every time you edit your backend files")}`
17
17
  ] : [],
18
- `${output.formatCode("docker compose up")} ${styleText(["dim"], "to start a grafana development server")}`,
19
- `Open ${output.formatUrl("http://localhost:3000")} ${styleText(["dim"], "in your browser to begin developing your plugin")}`
18
+ `${output.formatCode("docker compose up")} ${chalk.dim("to start a grafana development server")}`,
19
+ `Open ${output.formatUrl("http://localhost:3000")} ${chalk.dim("in your browser to begin developing your plugin")}`
20
20
  ]);
21
21
  output.log({
22
22
  title: "Next steps:",
@@ -24,8 +24,7 @@ function printGenerateSuccessMessage(answers) {
24
24
  "Run the following commands to get started:",
25
25
  ...commands,
26
26
  "",
27
- styleText(
28
- ["italic"],
27
+ chalk.italic(
29
28
  `Note: We strongly recommend creating a new Git repository by running ${output.formatCode("git init")} in ./${directory} before continuing.`
30
29
  ),
31
30
  "",
@@ -1,4 +1,4 @@
1
- import { styleText } from 'node:util';
1
+ import chalk from 'chalk';
2
2
  import { glob } from 'glob';
3
3
  import { readdir, mkdir, writeFile } from 'node:fs/promises';
4
4
  import path from 'node:path';
@@ -22,7 +22,7 @@ const generate = async (argv) => {
22
22
  if (exportPathIsPopulated && !IS_DEV) {
23
23
  output.error({
24
24
  title: "Aborting plugin scaffold.",
25
- body: [`Directory ${styleText(["bold"], exportPath)} exists and contains files.`]
25
+ body: [`Directory ${chalk.bold(exportPath)} exists and contains files.`]
26
26
  });
27
27
  process.exit(1);
28
28
  }
@@ -148,7 +148,7 @@ async function execPostScaffoldFunction(fn, ...args) {
148
148
  try {
149
149
  const resultMsg = await fn.apply(void 0, args);
150
150
  if (resultMsg) {
151
- console.log(`${styleText(["green"], "\u2714\uFE0E")} ${resultMsg}`);
151
+ console.log(`${chalk.green("\u2714\uFE0E")} ${resultMsg}`);
152
152
  }
153
153
  } catch (error) {
154
154
  if (error instanceof Error) {
@@ -4,7 +4,7 @@ import { getTemplateData, compileTemplateFiles } from '../utils/utils.templates.
4
4
  import { getExportTemplateName, getOnlyNotExistingInCwd, getOnlyExistingInCwd, removeFilesInCwd } from '../utils/utils.files.js';
5
5
  import { hasNpmDependenciesToUpdate, getPackageJsonUpdatesAsText, updatePackageJson, getRemovableNpmDependencies, removeNpmDependencies, updateNpmScripts, writePackageManagerInPackageJson, cleanUpPackageJson } from '../utils/utils.npm.js';
6
6
  import { getPackageManagerWithFallback } from '../utils/utils.packageManager.js';
7
- import { styleText } from 'node:util';
7
+ import chalk from 'chalk';
8
8
 
9
9
  const migrate = async () => {
10
10
  try {
@@ -91,7 +91,7 @@ const migrate = async () => {
91
91
  output.success({
92
92
  title: "Migration completed successfully.",
93
93
  body: [
94
- styleText(["bold"], "What's next?"),
94
+ chalk.bold("What's next?"),
95
95
  ...nextSteps,
96
96
  "See instructions on how to customize your configuration here: https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations"
97
97
  ]
@@ -1,9 +1,16 @@
1
- import { styleText } from 'node:util';
1
+ import chalk from 'chalk';
2
2
  import { EOL } from 'os';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
6
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
+ function isCI() {
8
+ return process.env.CI && process.env.CI !== "false" || // Drone CI plus others
9
+ process.env.GITHUB_ACTIONS === "true";
10
+ }
11
+ if (isCI()) {
12
+ chalk.level = 0;
13
+ }
7
14
  class Output {
8
15
  constructor(name, version) {
9
16
  __publicField(this, "appName");
@@ -22,7 +29,7 @@ class Output {
22
29
  return separator;
23
30
  }
24
31
  addHorizontalLine(color) {
25
- const separator = styleText(["dim", color], this.separator);
32
+ const separator = chalk.dim[color](this.separator);
26
33
  this.write(`${separator}${EOL}`);
27
34
  }
28
35
  addNewLine() {
@@ -38,19 +45,19 @@ class Output {
38
45
  getStatusIcon(taskStatus) {
39
46
  switch (taskStatus) {
40
47
  case "success":
41
- return styleText(["green"], "\u2713");
48
+ return chalk.green("\u2713");
42
49
  case "failure":
43
- return styleText(["red"], "\u2A2F");
50
+ return chalk.red("\u2A2F");
44
51
  case "skipped":
45
- return styleText(["yellow"], "\u2212");
52
+ return chalk.yellow("\u2212");
46
53
  }
47
54
  }
48
55
  addPrefix(color, text) {
49
- const namePrefix = styleText(["reset", "inverse", "bold", color], ` ${this.appName} `);
56
+ const namePrefix = chalk.reset.inverse.bold[color](` ${this.appName} `);
50
57
  if (!this.appVersion) {
51
58
  return `${namePrefix} ${text}`;
52
59
  }
53
- const nameAndVersionPrefix = styleText(["reset", "inverse", "bold", color], ` ${this.appName}@${this.appVersion} `);
60
+ const nameAndVersionPrefix = chalk.reset.inverse.bold[color](` ${this.appName}@${this.appVersion} `);
54
61
  return `${nameAndVersionPrefix} ${text}`;
55
62
  }
56
63
  writeBody(body) {
@@ -69,12 +76,12 @@ class Output {
69
76
  withPrefix = true
70
77
  }) {
71
78
  this.addNewLine();
72
- this.writeTitle("red", styleText(["red", "bold"], title), withPrefix);
79
+ this.writeTitle("red", chalk.red.bold(title), withPrefix);
73
80
  this.writeBody(body);
74
81
  if (link) {
75
82
  this.addNewLine();
76
- this.write(`${styleText(["gray"], "Learn more about this error: ")}
77
- ${styleText(["cyan"], link)}`);
83
+ this.write(`${chalk.gray("Learn more about this error: ")}
84
+ ${chalk.cyan(link)}`);
78
85
  }
79
86
  this.addNewLine();
80
87
  }
@@ -85,24 +92,24 @@ class Output {
85
92
  withPrefix = true
86
93
  }) {
87
94
  this.addNewLine();
88
- this.writeTitle("yellow", styleText(["yellow", "bold"], title), withPrefix);
95
+ this.writeTitle("yellow", chalk.yellow.bold(title), withPrefix);
89
96
  this.writeBody(body);
90
97
  if (link) {
91
98
  this.addNewLine();
92
- this.write(`${styleText(["gray"], "Learn more about this warning: ")}
99
+ this.write(`${chalk.gray("Learn more about this warning: ")}
93
100
  ${this.formatUrl(link)}`);
94
101
  }
95
102
  this.addNewLine();
96
103
  }
97
104
  success({ title, body, withPrefix = true }) {
98
105
  this.addNewLine();
99
- this.writeTitle("green", styleText(["green", "bold"], title), withPrefix);
106
+ this.writeTitle("green", chalk.green.bold(title), withPrefix);
100
107
  this.writeBody(body);
101
108
  this.addNewLine();
102
109
  }
103
110
  log({ title, body, withPrefix = true }) {
104
111
  this.addNewLine();
105
- this.writeTitle("cyan", styleText(["cyan", "bold"], title), withPrefix);
112
+ this.writeTitle("cyan", chalk.cyan.bold(title), withPrefix);
106
113
  this.writeBody(body);
107
114
  this.addNewLine();
108
115
  }
@@ -117,10 +124,10 @@ class Output {
117
124
  });
118
125
  }
119
126
  formatCode(code) {
120
- return styleText(["italic", "cyan"], code);
127
+ return chalk.italic.cyan(code);
121
128
  }
122
129
  formatUrl(url) {
123
- return styleText(["reset", "blue", "underline"], url);
130
+ return chalk.reset.blue.underline(url);
124
131
  }
125
132
  statusList(status, list) {
126
133
  return list.map((item) => {
@@ -1,4 +1,4 @@
1
- import { styleText } from 'node:util';
1
+ import chalk from 'chalk';
2
2
  import Enquirer from 'enquirer';
3
3
  import { Output } from '../libs/output/src/index.js';
4
4
  import { CURRENT_APP_VERSION } from './utils.version.js';
@@ -12,7 +12,7 @@ async function confirmPrompt(message) {
12
12
  const question = await prompt({
13
13
  name: "confirmPrompt",
14
14
  type: "confirm",
15
- message: styleText(["bold"], message)
15
+ message: chalk.bold(message)
16
16
  });
17
17
  return question["confirmPrompt"];
18
18
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "6.4.5-canary.2349.20276304868.0",
3
+ "version": "6.4.5-canary.2350.20292287699.0",
4
4
  "repository": {
5
5
  "directory": "packages/create-plugin",
6
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -27,6 +27,7 @@
27
27
  "dependencies": {
28
28
  "@babel/parser": "^7.28.5",
29
29
  "@ivanmaxlogiudice/gitignore": "^0.0.2",
30
+ "chalk": "^5.3.0",
30
31
  "change-case": "^5.4.0",
31
32
  "debug": "^4.3.4",
32
33
  "enquirer": "^2.4.1",
@@ -43,7 +44,7 @@
43
44
  "yaml": "^2.7.0"
44
45
  },
45
46
  "devDependencies": {
46
- "@libs/output": "1.0.3-canary.2349.20276304868.0",
47
+ "@libs/output": "^1.0.2",
47
48
  "@libs/version": "^1.0.2",
48
49
  "@types/glob": "^9.0.0",
49
50
  "@types/minimist": "^1.2.5",
@@ -55,5 +56,5 @@
55
56
  "engines": {
56
57
  "node": ">=20"
57
58
  },
58
- "gitHead": "cd9ed6bc420dcc839939f055239bfc4fecbf0dde"
59
+ "gitHead": "f6e2eff60123827f33edfe0c9b3deac60a704444"
59
60
  }
@@ -2,7 +2,7 @@ import { dirname, join } from 'node:path';
2
2
  import { createRequire } from 'node:module';
3
3
  import { Context } from './context.js';
4
4
  import { mkdirSync, rmSync, writeFileSync } from 'node:fs';
5
- import { styleText } from 'node:util';
5
+ import chalk from 'chalk';
6
6
  import { output } from '../utils/utils.console.js';
7
7
  import { getPackageManagerSilentInstallCmd, getPackageManagerWithFallback } from '../utils/utils.packageManager.js';
8
8
  import { execSync } from 'node:child_process';
@@ -15,11 +15,11 @@ export function printChanges(context: Context, key: string, description: string)
15
15
 
16
16
  for (const [filePath, { changeType }] of Object.entries(changes)) {
17
17
  if (changeType === 'add') {
18
- lines.push(`${styleText(['green'], 'ADD')} ${filePath}`);
18
+ lines.push(`${chalk.green('ADD')} ${filePath}`);
19
19
  } else if (changeType === 'update') {
20
- lines.push(`${styleText(['yellow'], 'UPDATE')} ${filePath}`);
20
+ lines.push(`${chalk.yellow('UPDATE')} ${filePath}`);
21
21
  } else if (changeType === 'delete') {
22
- lines.push(`${styleText(['red'], 'DELETE')} ${filePath}`);
22
+ lines.push(`${chalk.red('DELETE')} ${filePath}`);
23
23
  }
24
24
  }
25
25
 
@@ -1,5 +1,5 @@
1
1
  import { machine } from 'node:os';
2
- import { styleText } from 'node:util';
2
+ import chalk from 'chalk';
3
3
  import { TemplateData } from '../../types.js';
4
4
  import { output } from '../../utils/utils.console.js';
5
5
  import { normalizeId } from '../../utils/utils.handlebars.js';
@@ -11,16 +11,16 @@ export function printGenerateSuccessMessage(answers: TemplateData) {
11
11
 
12
12
  const commands = output.bulletList([
13
13
  output.formatCode(`cd ./${directory}`),
14
- `${output.formatCode(packageManagerName + ' install')} ${styleText(['dim'], 'to install frontend dependencies')}`,
15
- `${output.formatCode(packageManagerName + ' exec playwright install chromium')} ${styleText(['dim'], 'to install e2e test dependencies')}`,
16
- `${output.formatCode(packageManagerName + ' run dev')} ${styleText(['dim'], 'to build (and watch) the plugin frontend code')}`,
14
+ `${output.formatCode(packageManagerName + ' install')} ${chalk.dim('to install frontend dependencies')}`,
15
+ `${output.formatCode(packageManagerName + ' exec playwright install chromium')} ${chalk.dim('to install e2e test dependencies')}`,
16
+ `${output.formatCode(packageManagerName + ' run dev')} ${chalk.dim('to build (and watch) the plugin frontend code')}`,
17
17
  ...(answers.hasBackend
18
18
  ? [
19
- `${getBackendCmd()} ${styleText(['dim'], 'to build the plugin backend code. Rerun this command every time you edit your backend files')}`,
19
+ `${getBackendCmd()} ${chalk.dim('to build the plugin backend code. Rerun this command every time you edit your backend files')}`,
20
20
  ]
21
21
  : []),
22
- `${output.formatCode('docker compose up')} ${styleText(['dim'], 'to start a grafana development server')}`,
23
- `Open ${output.formatUrl('http://localhost:3000')} ${styleText(['dim'], 'in your browser to begin developing your plugin')}`,
22
+ `${output.formatCode('docker compose up')} ${chalk.dim('to start a grafana development server')}`,
23
+ `Open ${output.formatUrl('http://localhost:3000')} ${chalk.dim('in your browser to begin developing your plugin')}`,
24
24
  ]);
25
25
 
26
26
  output.log({
@@ -29,8 +29,7 @@ export function printGenerateSuccessMessage(answers: TemplateData) {
29
29
  'Run the following commands to get started:',
30
30
  ...commands,
31
31
  '',
32
- styleText(
33
- ['italic'],
32
+ chalk.italic(
34
33
  `Note: We strongly recommend creating a new Git repository by running ${output.formatCode('git init')} in ./${directory} before continuing.`
35
34
  ),
36
35
  '',
@@ -1,4 +1,4 @@
1
- import { styleText } from 'node:util';
1
+ import chalk from 'chalk';
2
2
  import { glob } from 'glob';
3
3
  import minimist from 'minimist';
4
4
  import { mkdir, readdir, writeFile } from 'node:fs/promises';
@@ -26,7 +26,7 @@ export const generate = async (argv: minimist.ParsedArgs) => {
26
26
  if (exportPathIsPopulated && !IS_DEV) {
27
27
  output.error({
28
28
  title: 'Aborting plugin scaffold.',
29
- body: [`Directory ${styleText(['bold'], exportPath)} exists and contains files.`],
29
+ body: [`Directory ${chalk.bold(exportPath)} exists and contains files.`],
30
30
  });
31
31
  process.exit(1);
32
32
  }
@@ -200,7 +200,7 @@ async function execPostScaffoldFunction<T>(fn: AsyncFunction<T>, ...args: Parame
200
200
  try {
201
201
  const resultMsg = await fn.apply(undefined, args);
202
202
  if (resultMsg) {
203
- console.log(`${styleText(['green'], '✔︎')} ${resultMsg}`);
203
+ console.log(`${chalk.green('✔︎')} ${resultMsg}`);
204
204
  }
205
205
  } catch (error) {
206
206
  if (error instanceof Error) {
@@ -18,7 +18,7 @@ import {
18
18
  writePackageManagerInPackageJson,
19
19
  } from '../utils/utils.npm.js';
20
20
  import { getPackageManagerWithFallback } from '../utils/utils.packageManager.js';
21
- import { styleText } from 'node:util';
21
+ import chalk from 'chalk';
22
22
 
23
23
  export const migrate = async () => {
24
24
  try {
@@ -161,7 +161,7 @@ export const migrate = async () => {
161
161
  output.success({
162
162
  title: 'Migration completed successfully.',
163
163
  body: [
164
- styleText(['bold'], "What's next?"),
164
+ chalk.bold("What's next?"),
165
165
  ...nextSteps,
166
166
  'See instructions on how to customize your configuration here: https://grafana.com/developers/plugin-tools/how-to-guides/extend-configurations',
167
167
  ],
@@ -1,4 +1,4 @@
1
- import { styleText } from 'node:util';
1
+ import chalk from 'chalk';
2
2
  import Enquirer from 'enquirer';
3
3
  import { Output } from '@libs/output';
4
4
  import { CURRENT_APP_VERSION } from './utils.version.js';
@@ -14,7 +14,7 @@ export async function confirmPrompt(message: string): Promise<boolean> {
14
14
  const question: Record<string, boolean> = await prompt({
15
15
  name: 'confirmPrompt',
16
16
  type: 'confirm',
17
- message: styleText(['bold'], message),
17
+ message: chalk.bold(message),
18
18
  });
19
19
 
20
20
  return question['confirmPrompt'];
@@ -25,7 +25,7 @@ export async function selectPrompt(message: string, choices: string[]): Promise<
25
25
  name: 'selectPrompt',
26
26
  type: 'select',
27
27
  choices,
28
- message: styleText(['bold'], message),
28
+ message: chalk.bold(message),
29
29
  });
30
30
 
31
31
  return question['selectPrompt'];