gtx-cli 1.2.26 → 1.2.27

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # gtx-cli
2
2
 
3
+ ## 1.2.27
4
+
5
+ ### Patch Changes
6
+
7
+ - [#392](https://github.com/generaltranslation/gt/pull/392) [`cebc905`](https://github.com/generaltranslation/gt/commit/cebc905cb5364bdcc218d4e93a6aee606d804419) Thanks [@brian-lou](https://github.com/brian-lou)! - Fix require not being present in ESM package
8
+
3
9
  ## 1.2.26
4
10
 
5
11
  ### Patch Changes
@@ -1,17 +1,17 @@
1
1
  import fs from 'node:fs';
2
+ import { spawn } from 'node:child_process';
2
3
  import chalk from 'chalk';
3
- import { logMessage, logWarning, } from '../console/logging.js';
4
+ import { logMessage, logWarning } from '../console/logging.js';
4
5
  export async function detectFormatter() {
5
6
  // Try Prettier
6
7
  try {
7
- require('prettier');
8
+ await import('prettier');
8
9
  return 'prettier';
9
10
  }
10
11
  catch { }
11
12
  // Try Biome
12
13
  try {
13
14
  return await new Promise((resolve, reject) => {
14
- const { spawn } = require('child_process');
15
15
  const child = spawn('npx', ['@biomejs/biome', '--version'], {
16
16
  stdio: 'ignore',
17
17
  });
@@ -31,7 +31,7 @@ export async function detectFormatter() {
31
31
  catch { }
32
32
  // Try ESLint
33
33
  try {
34
- require('eslint');
34
+ await import('eslint');
35
35
  return 'eslint';
36
36
  }
37
37
  catch { }
@@ -48,7 +48,7 @@ export async function formatFiles(filesUpdated, formatter) {
48
48
  }
49
49
  if (detectedFormatter === 'prettier') {
50
50
  logMessage(chalk.dim('Cleaning up with prettier...'));
51
- const prettier = require('prettier');
51
+ const prettier = await import('prettier');
52
52
  for (const file of filesUpdated) {
53
53
  const config = await prettier.resolveConfig(file);
54
54
  const content = await fs.promises.readFile(file, 'utf-8');
@@ -64,7 +64,6 @@ export async function formatFiles(filesUpdated, formatter) {
64
64
  logMessage(chalk.dim('Cleaning up with biome...'));
65
65
  try {
66
66
  await new Promise((resolve, reject) => {
67
- const { spawn } = require('child_process');
68
67
  const args = [
69
68
  '@biomejs/biome',
70
69
  'format',
@@ -93,7 +92,7 @@ export async function formatFiles(filesUpdated, formatter) {
93
92
  }
94
93
  if (detectedFormatter === 'eslint') {
95
94
  logMessage(chalk.dim('Cleaning up with eslint...'));
96
- const { ESLint } = require('eslint');
95
+ const { ESLint } = await import('eslint');
97
96
  const eslint = new ESLint({
98
97
  fix: true,
99
98
  overrideConfigFile: undefined, // Will use project's .eslintrc
@@ -24,10 +24,10 @@ export default async function createDictionaryUpdates(options, dictionaryPath, e
24
24
  const bundledCode = result.outputFiles[0].text;
25
25
  const tempFilePath = path.join(os.tmpdir(), 'bundled-dictionary.js');
26
26
  await fs.promises.writeFile(tempFilePath, bundledCode);
27
- // Load the module using require
27
+ // Load the module using dynamic import
28
28
  let dictionaryModule;
29
29
  try {
30
- dictionaryModule = require(tempFilePath);
30
+ dictionaryModule = await import(tempFilePath);
31
31
  }
32
32
  catch (error) {
33
33
  logError(`Failed to load the bundled dictionary code: ${error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "1.2.26",
3
+ "version": "1.2.27",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [