gtx-cli 2.0.23 → 2.0.24

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
+ ## 2.0.24
4
+
5
+ ### Patch Changes
6
+
7
+ - [#552](https://github.com/generaltranslation/gt/pull/552) [`65acf00`](https://github.com/generaltranslation/gt/commit/65acf0085a2b2c89f46b6b4685d94815a16467e6) Thanks [@brian-lou](https://github.com/brian-lou)! - Remove wizard auto-add T components
8
+
3
9
  ## 2.0.23
4
10
 
5
11
  ### Patch Changes
@@ -1,13 +1,12 @@
1
1
  import { detectFormatter } from '../hooks/postProcess.js';
2
- import { createSpinner, logMessage, promptSelect } from '../console/logging.js';
3
- import { logInfo, logError, logSuccess, logStep, logWarning, } from '../console/logging.js';
2
+ import { createSpinner, promptSelect } from '../console/logging.js';
3
+ import { logInfo, logError, logStep, logWarning } from '../console/logging.js';
4
4
  import chalk from 'chalk';
5
5
  import { promptConfirm } from '../console/logging.js';
6
6
  import findFilepath from '../fs/findFilepath.js';
7
7
  import { formatFiles } from '../hooks/postProcess.js';
8
8
  import { handleInitGT } from '../next/parse/handleInitGT.js';
9
9
  import { getPackageJson, isPackageInstalled } from '../utils/packageJson.js';
10
- import { wrapContentReact } from '../react/parse/wrapContent.js';
11
10
  import { wrapContentNext } from '../next/parse/wrapContent.js';
12
11
  import { getPackageManager } from '../utils/packageManager.js';
13
12
  import { installPackage } from '../utils/installPackage.js';
@@ -86,75 +85,28 @@ Please let us know what you would like to see supported at https://github.com/ge
86
85
  logError('No next.config.[js|ts|mjs|mts] file found.');
87
86
  process.exit(1);
88
87
  }
89
- const addGTProvider = await promptConfirm({
90
- message: 'Do you want the setup wizard to automatically add the GTProvider component?',
91
- defaultValue: true,
92
- });
93
- const addWithGTConfig = await promptConfirm({
94
- message: `Do you want to automatically add withGTConfig() to your ${nextConfigPath}?`,
95
- defaultValue: true,
96
- });
97
- const includeTId = await promptConfirm({
98
- message: 'Do you want to include an unique id for each <T> tag?',
99
- defaultValue: true,
100
- });
101
88
  const mergeOptions = {
102
89
  ...options,
103
- disableIds: !includeTId,
90
+ disableIds: true,
104
91
  disableFormatting: true,
105
- skipTs: false,
106
- addGTProvider,
92
+ skipTs: true,
93
+ addGTProvider: true,
107
94
  };
108
95
  const spinner = createSpinner();
109
96
  spinner.start('Wrapping JSX content with <T> tags...');
110
97
  // Wrap all JSX elements in the src directory with a <T> tag, with unique ids
111
98
  const { filesUpdated: filesUpdatedNext } = await wrapContentNext(mergeOptions, 'gt-next', errors, warnings);
112
99
  filesUpdated = [...filesUpdated, ...filesUpdatedNext];
113
- spinner.stop(chalk.green(`Success! Added <T> tags and updated ${chalk.bold.cyan(filesUpdated.length)} files:\n`) + filesUpdated.map((file) => `${chalk.green('-')} ${file}`).join('\n'));
114
- if (addWithGTConfig) {
115
- // Read tsconfig.json if it exists
116
- const tsconfigPath = findFilepath(['tsconfig.json']);
117
- const tsconfigJson = tsconfigPath ? loadConfig(tsconfigPath) : undefined;
118
- // Add the withGTConfig() function to the next.config.js file
119
- await handleInitGT(nextConfigPath, errors, warnings, filesUpdated, packageJson, tsconfigJson);
120
- logStep(chalk.green(`Added withGTConfig() to your ${nextConfigPath} file.`));
121
- }
122
- if (errors.length > 0) {
123
- logError(chalk.red('Failed to write files:\n') + errors.join('\n'));
124
- }
125
- logSuccess(chalk.green(`Success! All JSX content has been wrapped with <T> tags${includeTId ? ' and unique ids.' : '.'}`));
126
- logMessage(`To translate strings, see the docs on useGT and getGT: https://generaltranslation.com/docs/next/api/strings/getGT`);
100
+ spinner.stop(chalk.green(`Success! Updated ${chalk.bold.cyan(filesUpdated.length)} files:\n`) + filesUpdated.map((file) => `${chalk.green('-')} ${file}`).join('\n'));
101
+ // Read tsconfig.json if it exists
102
+ const tsconfigPath = findFilepath(['tsconfig.json']);
103
+ const tsconfigJson = tsconfigPath ? loadConfig(tsconfigPath) : undefined;
104
+ // Add the withGTConfig() function to the next.config.js file
105
+ await handleInitGT(nextConfigPath, errors, warnings, filesUpdated, packageJson, tsconfigJson);
106
+ logStep(chalk.green(`Added withGTConfig() to your ${nextConfigPath} file.`));
127
107
  }
128
- else {
129
- let addGTProvider = false;
130
- if (frameworkType === 'next-pages') {
131
- addGTProvider = await promptConfirm({
132
- message: 'Do you want the setup wizard to automatically add the GTProvider component?',
133
- defaultValue: true,
134
- });
135
- }
136
- const includeTId = await promptConfirm({
137
- message: 'Do you want to include an unique id for each <T> tag?',
138
- defaultValue: true,
139
- });
140
- const mergeOptions = {
141
- ...options,
142
- disableIds: !includeTId,
143
- disableFormatting: true,
144
- skipTs: false,
145
- addGTProvider,
146
- };
147
- const spinner = createSpinner();
148
- spinner.start('Wrapping JSX content with <T> tags...');
149
- // Wrap all JSX elements in the src directory with a <T> tag, with unique ids
150
- const { filesUpdated: filesUpdatedReact } = await wrapContentReact(mergeOptions, 'gt-react', frameworkType, errors, warnings);
151
- filesUpdated = [...filesUpdated, ...filesUpdatedReact];
152
- spinner.stop(chalk.green(`Success! Added <T> tags and updated ${chalk.bold.cyan(filesUpdated.length)} files:\n`) + filesUpdated.map((file) => `${chalk.green('-')} ${file}`).join('\n'));
153
- if (errors.length > 0) {
154
- logError(chalk.red('Failed to write files:\n') + errors.join('\n'));
155
- }
156
- logSuccess(chalk.green(`Success! All JSX content has been wrapped with <T> tags${includeTId ? ' and unique ids.' : '.'}`));
157
- logMessage(`To translate strings, see the docs on useGT: https://generaltranslation.com/docs/react/api/strings/useGT`);
108
+ if (errors.length > 0) {
109
+ logError(chalk.red('Failed to write files:\n') + errors.join('\n'));
158
110
  }
159
111
  if (warnings.length > 0) {
160
112
  logWarning(chalk.yellow('Warnings encountered:') +
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtx-cli",
3
- "version": "2.0.23",
3
+ "version": "2.0.24",
4
4
  "main": "dist/index.js",
5
5
  "bin": "dist/main.js",
6
6
  "files": [