@grafana/create-plugin 2.11.2 → 2.12.0-canary.658.dabaee1.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.
Files changed (62) hide show
  1. package/dist/bin/run.js +13 -18
  2. package/dist/commands/generate/prettify-files.js +15 -70
  3. package/dist/commands/generate/print-success-message.js +28 -31
  4. package/dist/commands/generate/prompt-user.js +23 -91
  5. package/dist/commands/generate/update-go-sdk-and-packages.js +36 -105
  6. package/dist/commands/generate.command.js +122 -240
  7. package/dist/commands/index.js +5 -21
  8. package/dist/commands/migrate.command.js +71 -134
  9. package/dist/commands/provisioning.command.js +30 -85
  10. package/dist/commands/types.js +1 -2
  11. package/dist/commands/update.command.js +44 -97
  12. package/dist/commands/version.command.js +16 -57
  13. package/dist/constants.js +37 -32
  14. package/dist/utils/tests/utils.files.test.js +21 -23
  15. package/dist/utils/tests/utils.handlebars.test.js +24 -26
  16. package/dist/utils/tests/utils.npm.test.js +103 -95
  17. package/dist/utils/tests/utils.plugin.test.js +11 -13
  18. package/dist/utils/tests/utils.templates.test.js +16 -18
  19. package/dist/utils/utils.config.js +30 -32
  20. package/dist/utils/utils.console.js +25 -31
  21. package/dist/utils/utils.files.js +38 -104
  22. package/dist/utils/utils.handlebars.js +30 -65
  23. package/dist/utils/utils.npm.js +75 -118
  24. package/dist/utils/utils.os.js +3 -7
  25. package/dist/utils/utils.packageManager.js +31 -37
  26. package/dist/utils/utils.packagejson.js +13 -22
  27. package/dist/utils/utils.path.js +7 -14
  28. package/dist/utils/utils.plugin.js +6 -13
  29. package/dist/utils/utils.templates.js +58 -80
  30. package/dist/utils/utils.version.js +9 -11
  31. package/package.json +20 -6
  32. package/src/bin/run.ts +2 -2
  33. package/src/commands/generate/prettify-files.ts +1 -1
  34. package/src/commands/generate/print-success-message.ts +4 -4
  35. package/src/commands/generate/prompt-user.ts +2 -2
  36. package/src/commands/generate/update-go-sdk-and-packages.ts +2 -2
  37. package/src/commands/generate.command.ts +15 -15
  38. package/src/commands/index.ts +5 -5
  39. package/src/commands/migrate.command.ts +6 -6
  40. package/src/commands/provisioning.command.ts +6 -6
  41. package/src/commands/types.ts +1 -1
  42. package/src/commands/update.command.ts +5 -5
  43. package/src/commands/version.command.ts +5 -2
  44. package/src/constants.ts +4 -1
  45. package/src/utils/tests/utils.files.test.ts +2 -2
  46. package/src/utils/tests/utils.handlebars.test.ts +2 -2
  47. package/src/utils/tests/utils.npm.test.ts +43 -34
  48. package/src/utils/tests/utils.plugin.test.ts +2 -2
  49. package/src/utils/tests/utils.templates.test.ts +2 -2
  50. package/src/utils/utils.config.ts +3 -3
  51. package/src/utils/utils.console.ts +16 -11
  52. package/src/utils/utils.files.ts +3 -3
  53. package/src/utils/utils.handlebars.ts +3 -3
  54. package/src/utils/utils.npm.ts +3 -3
  55. package/src/utils/utils.packageManager.ts +3 -3
  56. package/src/utils/utils.packagejson.ts +5 -5
  57. package/src/utils/utils.path.ts +3 -3
  58. package/src/utils/utils.plugin.ts +2 -3
  59. package/src/utils/utils.templates.ts +10 -10
  60. package/src/utils/utils.version.ts +5 -2
  61. package/tsconfig.json +5 -0
  62. package/vitest.config.ts +10 -0
@@ -1,95 +1,73 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
14
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
15
- if (ar || !(i in from)) {
16
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
17
- ar[i] = from[i];
18
- }
19
- }
20
- return to.concat(ar || Array.prototype.slice.call(from));
21
- };
22
- var __importDefault = (this && this.__importDefault) || function (mod) {
23
- return (mod && mod.__esModule) ? mod : { "default": mod };
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getTemplateData = exports.renderTemplateFromFile = exports.compileProvisioningTemplateFile = exports.compileSingleTemplateFile = exports.compileTemplateFiles = exports.getProjectRelativeTemplatePath = exports.getTemplateFiles = void 0;
27
- var glob_1 = __importDefault(require("glob"));
28
- var path_1 = __importDefault(require("path"));
29
- var fs_1 = __importDefault(require("fs"));
30
- var mkdirp_1 = __importDefault(require("mkdirp"));
31
- var utils_files_1 = require("./utils.files");
32
- var utils_handlebars_1 = require("./utils.handlebars");
33
- var utils_plugin_1 = require("./utils.plugin");
34
- var constants_1 = require("../constants");
35
- var utils_packageManager_1 = require("./utils.packageManager");
36
- var utils_files_2 = require("../utils/utils.files");
37
- var utils_version_1 = require("./utils.version");
38
- var utils_config_1 = require("./utils.config");
39
- function getTemplateFiles(pluginType, filter) {
40
- var commonFiles = glob_1.default.sync("".concat(constants_1.TEMPLATE_PATHS.common, "/**"), { dot: true });
41
- var pluginTypeSpecificFiles = glob_1.default.sync("".concat(constants_1.TEMPLATE_PATHS[pluginType], "/**"), { dot: true });
42
- var templateFiles = (0, utils_files_1.filterOutCommonFiles)(__spreadArray(__spreadArray([], commonFiles, true), pluginTypeSpecificFiles, true), pluginType);
1
+ import glob from 'glob';
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+ import mkdirp from 'mkdirp';
5
+ import { filterOutCommonFiles, isFile, isFileStartingWith } from './utils.files.js';
6
+ import { renderHandlebarsTemplate } from './utils.handlebars.js';
7
+ import { getPluginJson } from './utils.plugin.js';
8
+ import { TEMPLATE_PATHS, EXPORT_PATH_PREFIX, EXTRA_TEMPLATE_VARIABLES } from '../constants.js';
9
+ import { getPackageManagerWithFallback } from './utils.packageManager.js';
10
+ import { getExportFileName } from '../utils/utils.files.js';
11
+ import { getVersion } from './utils.version.js';
12
+ import { getConfig } from './utils.config.js';
13
+ export function getTemplateFiles(pluginType, filter) {
14
+ const commonFiles = glob.sync(`${TEMPLATE_PATHS.common}/**`, { dot: true });
15
+ const pluginTypeSpecificFiles = glob.sync(`${TEMPLATE_PATHS[pluginType]}/**`, { dot: true });
16
+ const templateFiles = filterOutCommonFiles([...commonFiles, ...pluginTypeSpecificFiles], pluginType);
43
17
  if (filter) {
44
- return templateFiles.filter(function (file) {
45
- var projectRelativePath = getProjectRelativeTemplatePath(file, pluginType);
46
- return (0, utils_files_1.isFileStartingWith)(projectRelativePath, filter);
18
+ return templateFiles.filter((file) => {
19
+ const projectRelativePath = getProjectRelativeTemplatePath(file, pluginType);
20
+ return isFileStartingWith(projectRelativePath, filter);
47
21
  });
48
22
  }
49
23
  return templateFiles;
50
24
  }
51
- exports.getTemplateFiles = getTemplateFiles;
52
- function getProjectRelativeTemplatePath(file, pluginType) {
53
- return file.replace(constants_1.TEMPLATE_PATHS.common, '').replace(constants_1.TEMPLATE_PATHS[pluginType], '').replace(/^\/+/, '');
25
+ export function getProjectRelativeTemplatePath(file, pluginType) {
26
+ return file.replace(TEMPLATE_PATHS.common, '').replace(TEMPLATE_PATHS[pluginType], '').replace(/^\/+/, '');
54
27
  }
55
- exports.getProjectRelativeTemplatePath = getProjectRelativeTemplatePath;
56
- function compileTemplateFiles(filter, data) {
57
- var type = (0, utils_plugin_1.getPluginJson)().type;
58
- getTemplateFiles(type, filter).forEach(function (file) { return compileSingleTemplateFile(type, file, data); });
28
+ export function compileTemplateFiles(filter, data) {
29
+ const { type } = getPluginJson();
30
+ getTemplateFiles(type, filter).forEach((file) => compileSingleTemplateFile(type, file, data));
59
31
  }
60
- exports.compileTemplateFiles = compileTemplateFiles;
61
- function compileSingleTemplateFile(pluginType, templateFile, data) {
62
- if (!(0, utils_files_1.isFile)(templateFile)) {
32
+ export function compileSingleTemplateFile(pluginType, templateFile, data) {
33
+ if (!isFile(templateFile)) {
63
34
  return;
64
35
  }
65
- var rendered = renderTemplateFromFile(templateFile, data);
66
- var relativeExportPath = templateFile.replace(constants_1.TEMPLATE_PATHS.common, '').replace(constants_1.TEMPLATE_PATHS[pluginType], '');
67
- var exportPath = path_1.default.join(constants_1.EXPORT_PATH_PREFIX, path_1.default.dirname(relativeExportPath), (0, utils_files_2.getExportFileName)(templateFile));
68
- mkdirp_1.default.sync(path_1.default.dirname(exportPath));
69
- fs_1.default.writeFileSync(exportPath, rendered);
36
+ const rendered = renderTemplateFromFile(templateFile, data);
37
+ const relativeExportPath = templateFile.replace(TEMPLATE_PATHS.common, '').replace(TEMPLATE_PATHS[pluginType], '');
38
+ const exportPath = path.join(EXPORT_PATH_PREFIX, path.dirname(relativeExportPath), getExportFileName(templateFile));
39
+ mkdirp.sync(path.dirname(exportPath));
40
+ fs.writeFileSync(exportPath, rendered);
70
41
  }
71
- exports.compileSingleTemplateFile = compileSingleTemplateFile;
72
- function compileProvisioningTemplateFile(pluginType, templateFile, data) {
73
- if (!(0, utils_files_1.isFile)(templateFile)) {
42
+ export function compileProvisioningTemplateFile(pluginType, templateFile, data) {
43
+ if (!isFile(templateFile)) {
74
44
  return;
75
45
  }
76
- var rendered = renderTemplateFromFile(templateFile, data);
77
- var relativeExportPath = templateFile.replace(constants_1.TEMPLATE_PATHS[pluginType], '.');
78
- var exportPath = path_1.default.join(constants_1.EXPORT_PATH_PREFIX, path_1.default.dirname(relativeExportPath), (0, utils_files_2.getExportFileName)(templateFile));
79
- mkdirp_1.default.sync(path_1.default.dirname(exportPath));
80
- fs_1.default.writeFileSync(exportPath, rendered);
46
+ const rendered = renderTemplateFromFile(templateFile, data);
47
+ const relativeExportPath = templateFile.replace(TEMPLATE_PATHS[pluginType], '.');
48
+ const exportPath = path.join(EXPORT_PATH_PREFIX, path.dirname(relativeExportPath), getExportFileName(templateFile));
49
+ mkdirp.sync(path.dirname(exportPath));
50
+ fs.writeFileSync(exportPath, rendered);
81
51
  }
82
- exports.compileProvisioningTemplateFile = compileProvisioningTemplateFile;
83
- function renderTemplateFromFile(templateFile, data) {
84
- return (0, utils_handlebars_1.renderHandlebarsTemplate)(fs_1.default.readFileSync(templateFile).toString(), data);
52
+ export function renderTemplateFromFile(templateFile, data) {
53
+ return renderHandlebarsTemplate(fs.readFileSync(templateFile).toString(), data);
85
54
  }
86
- exports.renderTemplateFromFile = renderTemplateFromFile;
87
- function getTemplateData() {
88
- var _a, _b, _c;
89
- var pluginJson = (0, utils_plugin_1.getPluginJson)();
90
- var features = (0, utils_config_1.getConfig)().features;
91
- var currentVersion = (0, utils_version_1.getVersion)();
92
- var _d = (0, utils_packageManager_1.getPackageManagerWithFallback)(), packageManagerName = _d.packageManagerName, packageManagerVersion = _d.packageManagerVersion;
93
- return __assign(__assign({}, constants_1.EXTRA_TEMPLATE_VARIABLES), { pluginId: pluginJson.id, pluginName: pluginJson.name, pluginDescription: (_a = pluginJson.info) === null || _a === void 0 ? void 0 : _a.description, hasBackend: Boolean(pluginJson.backend), orgName: (_c = (_b = pluginJson.info) === null || _b === void 0 ? void 0 : _b.author) === null || _c === void 0 ? void 0 : _c.name, pluginType: pluginJson.type, packageManagerName: packageManagerName, packageManagerVersion: packageManagerVersion, version: currentVersion, bundleGrafanaUI: features.bundleGrafanaUI });
55
+ export function getTemplateData() {
56
+ const pluginJson = getPluginJson();
57
+ const { features } = getConfig();
58
+ const currentVersion = getVersion();
59
+ const { packageManagerName, packageManagerVersion } = getPackageManagerWithFallback();
60
+ return {
61
+ ...EXTRA_TEMPLATE_VARIABLES,
62
+ pluginId: pluginJson.id,
63
+ pluginName: pluginJson.name,
64
+ pluginDescription: pluginJson.info?.description,
65
+ hasBackend: Boolean(pluginJson.backend),
66
+ orgName: pluginJson.info?.author?.name,
67
+ pluginType: pluginJson.type,
68
+ packageManagerName,
69
+ packageManagerVersion,
70
+ version: currentVersion,
71
+ bundleGrafanaUI: features.bundleGrafanaUI,
72
+ };
94
73
  }
95
- exports.getTemplateData = getTemplateData;
@@ -1,15 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getVersion = void 0;
4
- var fs_1 = require("fs");
5
- var path_1 = require("path");
6
- function getVersion() {
7
- var packageJsonPath = (0, path_1.resolve)(__dirname, '..', '..', 'package.json');
8
- var pkg = (0, fs_1.readFileSync)(packageJsonPath, 'utf8');
9
- var version = JSON.parse(pkg).version;
1
+ import { readFileSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
5
+ export function getVersion() {
6
+ const packageJsonPath = resolve(__dirname, '..', '..', 'package.json');
7
+ const pkg = readFileSync(packageJsonPath, 'utf8');
8
+ const { version } = JSON.parse(pkg);
10
9
  if (!version) {
11
- throw "Could not find the version of create-plugin";
10
+ throw `Could not find the version of create-plugin`;
12
11
  }
13
12
  return version;
14
13
  }
15
- exports.getVersion = getVersion;
package/package.json CHANGED
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "name": "@grafana/create-plugin",
3
- "version": "2.11.2",
4
- "main": "index.js",
3
+ "version": "2.12.0-canary.658.dabaee1.0",
5
4
  "repository": {
6
5
  "directory": "packages/create-plugin",
7
6
  "url": "https://github.com/grafana/plugin-tools"
@@ -9,6 +8,13 @@
9
8
  "author": "Grafana",
10
9
  "license": "Apache-2.0",
11
10
  "bin": "./dist/bin/run.js",
11
+ "type": "module",
12
+ "exports": {
13
+ "node": {
14
+ "import": "./index.js"
15
+ },
16
+ "default": "./index.js"
17
+ },
12
18
  "publishConfig": {
13
19
  "registry": "https://registry.npmjs.org/",
14
20
  "access": "public"
@@ -30,10 +36,12 @@
30
36
  "generate-datasource-backend": "tsc && npm run clean-generated && CREATE_PLUGIN_DEV=true node ./dist/bin/run.js --pluginName='Sample datasource' --orgName='sample-org' --pluginDescription='This is a sample datasource.' --pluginType='datasource' --hasBackend --hasGithubWorkflows --hasGithubLevitateWorkflow",
31
37
  "lint": "eslint --cache --ext .js,.jsx,.ts,.tsx ./src",
32
38
  "lint:fix": "npm run lint -- --fix",
33
- "test": "jest",
39
+ "test": "vitest",
40
+ "test:ci": "vitest run",
34
41
  "typecheck": "tsc --noEmit"
35
42
  },
36
43
  "dependencies": {
44
+ "@types/marked-terminal": "^6.0.1",
37
45
  "@types/minimist": "^1.2.2",
38
46
  "@types/mkdirp": "^1.0.2",
39
47
  "@types/semver": "^7.3.9",
@@ -45,7 +53,7 @@
45
53
  "glob": "^7.1.7",
46
54
  "handlebars": "^4.7.8",
47
55
  "marked": "^10.0.0",
48
- "marked-terminal": "^5.1.1",
56
+ "marked-terminal": "^6.2.0",
49
57
  "minimist": "^1.2.8",
50
58
  "mkdirp": "^1.0.4",
51
59
  "semver": "^7.3.5",
@@ -55,7 +63,13 @@
55
63
  "devDependencies": {
56
64
  "@types/glob": "^7.0.0",
57
65
  "eslint-plugin-react": "^7.26.1",
58
- "eslint-plugin-react-hooks": "^4.2.0"
66
+ "eslint-plugin-react-hooks": "^4.2.0",
67
+ "vitest": "^1.1.3"
68
+ },
69
+ "overrides": {
70
+ "@types/marked-terminal": {
71
+ "marked": "^10.0.0"
72
+ }
59
73
  },
60
74
  "nodemonConfig": {
61
75
  "watch": [
@@ -73,5 +87,5 @@
73
87
  "engines": {
74
88
  "node": ">=20"
75
89
  },
76
- "gitHead": "fb151d4a42b5070192759ad4e86d79ce6ce9fbe9"
90
+ "gitHead": "dabaee1ff0a80d59cf5ffb016b5deda96e052633"
77
91
  }
package/src/bin/run.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import minimist from 'minimist';
4
- import { generate, update, migrate, version, provisioning } from '../commands';
5
- import { isUnsupportedPlatform } from '../utils/utils.os';
4
+ import { generate, update, migrate, version, provisioning } from '../commands/index.js';
5
+ import { isUnsupportedPlatform } from '../utils/utils.os.js';
6
6
 
7
7
  // Exit early if operating system isn't supported.
8
8
  if (isUnsupportedPlatform()) {
@@ -1,6 +1,6 @@
1
1
  import { exec as nodeExec } from 'node:child_process';
2
2
  import { promisify } from 'node:util';
3
- import fs from 'fs';
3
+ import fs from 'node:fs';
4
4
 
5
5
  const exec = promisify(nodeExec);
6
6
 
@@ -1,7 +1,7 @@
1
- import { displayAsMarkdown } from '../../utils/utils.console';
2
- import { normalizeId } from '../../utils/utils.handlebars';
3
- import { getPackageManagerFromUserAgent } from '../../utils/utils.packageManager';
4
- import { CliArgs } from '../types';
1
+ import { displayAsMarkdown } from '../../utils/utils.console.js';
2
+ import { normalizeId } from '../../utils/utils.handlebars.js';
3
+ import { getPackageManagerFromUserAgent } from '../../utils/utils.packageManager.js';
4
+ import { CliArgs } from '../types.js';
5
5
 
6
6
  export function printGenerateSuccessMessage(answers: CliArgs) {
7
7
  const directory = normalizeId(answers.pluginName, answers.orgName, answers.pluginType);
@@ -1,7 +1,7 @@
1
1
  import minimist from 'minimist';
2
2
  import Enquirer from 'enquirer';
3
- import { PLUGIN_TYPES } from '../../constants';
4
- import { CliArgs } from '../types';
3
+ import { PLUGIN_TYPES } from '../../constants.js';
4
+ import { CliArgs } from '../types.js';
5
5
 
6
6
  export async function promptUser(argv: minimist.ParsedArgs) {
7
7
  let answers: Partial<CliArgs> = {};
@@ -1,6 +1,6 @@
1
1
  import which from 'which';
2
- import fs from 'fs';
3
- import { exec } from 'child_process';
2
+ import fs from 'node:fs';
3
+ import { exec } from 'node:child_process';
4
4
 
5
5
  const SDK_GO_MODULE = 'github.com/grafana/grafana-plugin-sdk-go';
6
6
 
@@ -2,21 +2,21 @@ import glob from 'glob';
2
2
  import minimist from 'minimist';
3
3
  import chalk from 'chalk';
4
4
  import { mkdir, readdir, writeFile } from 'node:fs/promises';
5
- import path from 'path';
6
- import { EXTRA_TEMPLATE_VARIABLES, IS_DEV, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants';
7
- import { getConfig } from '../utils/utils.config';
8
- import { printError } from '../utils/utils.console';
9
- import { directoryExists, getExportFileName, isFile } from '../utils/utils.files';
10
- import { normalizeId } from '../utils/utils.handlebars';
11
- import { getPackageManagerFromUserAgent, getPackageManagerInstallCmd } from '../utils/utils.packageManager';
12
- import { getExportPath } from '../utils/utils.path';
13
- import { renderTemplateFromFile } from '../utils/utils.templates';
14
- import { getVersion } from '../utils/utils.version';
15
- import { prettifyFiles } from './generate/prettify-files';
16
- import { printGenerateSuccessMessage } from './generate/print-success-message';
17
- import { promptUser } from './generate/prompt-user';
18
- import { updateGoSdkAndModules } from './generate/update-go-sdk-and-packages';
19
- import { CliArgs, TemplateData } from './types';
5
+ import path from 'node:path';
6
+ import { EXTRA_TEMPLATE_VARIABLES, IS_DEV, PLUGIN_TYPES, TEMPLATE_PATHS } from '../constants.js';
7
+ import { getConfig } from '../utils/utils.config.js';
8
+ import { printError } from '../utils/utils.console.js';
9
+ import { directoryExists, getExportFileName, isFile } from '../utils/utils.files.js';
10
+ import { normalizeId } from '../utils/utils.handlebars.js';
11
+ import { getPackageManagerFromUserAgent, getPackageManagerInstallCmd } from '../utils/utils.packageManager.js';
12
+ import { getExportPath } from '../utils/utils.path.js';
13
+ import { renderTemplateFromFile } from '../utils/utils.templates.js';
14
+ import { getVersion } from '../utils/utils.version.js';
15
+ import { prettifyFiles } from './generate/prettify-files.js';
16
+ import { printGenerateSuccessMessage } from './generate/print-success-message.js';
17
+ import { promptUser } from './generate/prompt-user.js';
18
+ import { updateGoSdkAndModules } from './generate/update-go-sdk-and-packages.js';
19
+ import { CliArgs, TemplateData } from './types.js';
20
20
 
21
21
  export const generate = async (argv: minimist.ParsedArgs) => {
22
22
  const answers = await promptUser(argv);
@@ -1,5 +1,5 @@
1
- export * from './generate.command';
2
- export * from './update.command';
3
- export * from './migrate.command';
4
- export * from './version.command';
5
- export * from './provisioning.command';
1
+ export * from './generate.command.js';
2
+ export * from './update.command.js';
3
+ export * from './migrate.command.js';
4
+ export * from './version.command.js';
5
+ export * from './provisioning.command.js';
@@ -1,12 +1,12 @@
1
- import { TEXT, MIGRATION_CONFIG } from '../constants';
2
- import { displayArrayAsList, printMessage, printSuccessMessage, confirmPrompt } from '../utils/utils.console';
3
- import { compileTemplateFiles, getTemplateData } from '../utils/utils.templates';
1
+ import { TEXT, MIGRATION_CONFIG } from '../constants.js';
2
+ import { displayArrayAsList, printMessage, printSuccessMessage, confirmPrompt } from '../utils/utils.console.js';
3
+ import { compileTemplateFiles, getTemplateData } from '../utils/utils.templates.js';
4
4
  import {
5
5
  getExportTemplateName,
6
6
  getOnlyExistingInCwd,
7
7
  getOnlyNotExistingInCwd,
8
8
  removeFilesInCwd,
9
- } from '../utils/utils.files';
9
+ } from '../utils/utils.files.js';
10
10
  import {
11
11
  getPackageJsonUpdatesAsText,
12
12
  updatePackageJson,
@@ -16,8 +16,8 @@ import {
16
16
  updateNpmScripts,
17
17
  cleanUpPackageJson,
18
18
  writePackageManagerInPackageJson,
19
- } from '../utils/utils.npm';
20
- import { getPackageManagerWithFallback } from '../utils/utils.packageManager';
19
+ } from '../utils/utils.npm.js';
20
+ import { getPackageManagerWithFallback } from '../utils/utils.packageManager.js';
21
21
 
22
22
  export const migrate = async () => {
23
23
  try {
@@ -1,10 +1,10 @@
1
1
  import glob from 'glob';
2
- import path from 'path';
3
- import fs from 'fs';
4
- import { TEMPLATE_PATHS, TEXT } from '../constants';
5
- import { getPluginJson } from '../utils/utils.plugin';
6
- import { compileProvisioningTemplateFile, getTemplateData } from '../utils/utils.templates';
7
- import { confirmPrompt, printMessage, printSuccessMessage, printError } from '../utils/utils.console';
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+ import { TEMPLATE_PATHS, TEXT } from '../constants.js';
5
+ import { getPluginJson } from '../utils/utils.plugin.js';
6
+ import { compileProvisioningTemplateFile, getTemplateData } from '../utils/utils.templates.js';
7
+ import { confirmPrompt, printMessage, printSuccessMessage, printError } from '../utils/utils.console.js';
8
8
 
9
9
  export const provisioning = async () => {
10
10
  const { type } = getPluginJson();
@@ -1,4 +1,4 @@
1
- import { PLUGIN_TYPES } from '../constants';
1
+ import { PLUGIN_TYPES } from '../constants.js';
2
2
 
3
3
  export type CliArgs = {
4
4
  pluginName: string;
@@ -1,14 +1,14 @@
1
- import { TEXT, UDPATE_CONFIG } from '../constants';
2
- import { compileTemplateFiles, getTemplateData } from '../utils/utils.templates';
3
- import { confirmPrompt, selectPrompt, printMessage, printSuccessMessage } from '../utils/utils.console';
1
+ import { TEXT, UDPATE_CONFIG } from '../constants.js';
2
+ import { compileTemplateFiles, getTemplateData } from '../utils/utils.templates.js';
3
+ import { confirmPrompt, selectPrompt, printMessage, printSuccessMessage } from '../utils/utils.console.js';
4
4
  import {
5
5
  updatePackageJson,
6
6
  hasNpmDependenciesToUpdate,
7
7
  getPackageJsonUpdatesAsText,
8
8
  updateNpmScripts,
9
9
  writePackageManagerInPackageJson,
10
- } from '../utils/utils.npm';
11
- import { getPackageManagerWithFallback } from '../utils/utils.packageManager';
10
+ } from '../utils/utils.npm.js';
11
+ import { getPackageManagerWithFallback } from '../utils/utils.packageManager.js';
12
12
 
13
13
  export const update = async () => {
14
14
  try {
@@ -1,5 +1,8 @@
1
- import { resolve } from 'path';
2
- import { readFileSync } from 'fs';
1
+ import { resolve } from 'node:path';
2
+ import { readFileSync } from 'node:fs';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
3
6
 
4
7
  export const version = async () => {
5
8
  try {
package/src/constants.ts CHANGED
@@ -1,4 +1,7 @@
1
- import path from 'path';
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ const __dirname = fileURLToPath(new URL('.', import.meta.url));
2
5
 
3
6
  export const IS_DEV = process.env.CREATE_PLUGIN_DEV !== undefined;
4
7
 
@@ -1,5 +1,5 @@
1
- import { PLUGIN_TYPES, TEMPLATE_PATHS } from '../../constants';
2
- import { filterOutCommonFiles, isFile } from '../utils.files';
1
+ import { PLUGIN_TYPES, TEMPLATE_PATHS } from '../../constants.js';
2
+ import { filterOutCommonFiles, isFile } from '../utils.files.js';
3
3
 
4
4
  describe('Utils/Files', () => {
5
5
  describe('filterOutCommonFiles()', () => {
@@ -1,5 +1,5 @@
1
- import { PLUGIN_TYPES } from '../../constants';
2
- import { normalizeId } from '../utils.handlebars';
1
+ import { PLUGIN_TYPES } from '../../constants.js';
2
+ import { normalizeId } from '../utils.handlebars.js';
3
3
 
4
4
  describe('Handlebars helpers', () => {
5
5
  describe('normalize id', () => {