gtx-cli 1.0.1 → 1.0.2
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/dist/cli/base.d.ts +2 -1
- package/dist/cli/base.js +17 -8
- package/dist/cli/next.d.ts +1 -1
- package/dist/cli/next.js +2 -2
- package/dist/cli/react.d.ts +1 -1
- package/dist/cli/react.js +2 -2
- package/dist/fs/determineFramework.d.ts +4 -1
- package/dist/fs/determineFramework.js +12 -10
- package/dist/index.js +4 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/cli/base.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SupportedLibraries } from '../types';
|
|
2
2
|
export declare class BaseCLI {
|
|
3
3
|
private library;
|
|
4
|
-
|
|
4
|
+
private additionalModules;
|
|
5
|
+
constructor(library: SupportedLibraries, additionalModules?: SupportedLibraries[]);
|
|
5
6
|
init(): void;
|
|
6
7
|
execute(): void;
|
|
7
8
|
protected setupGTCommand(): void;
|
package/dist/cli/base.js
CHANGED
|
@@ -63,8 +63,9 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
63
63
|
const SUPPORTED_DATA_FORMATS = ['JSX', 'ICU', 'I18NEXT'];
|
|
64
64
|
class BaseCLI {
|
|
65
65
|
// Constructor is shared amongst all CLI class types
|
|
66
|
-
constructor(library) {
|
|
66
|
+
constructor(library, additionalModules) {
|
|
67
67
|
this.library = library;
|
|
68
|
+
this.additionalModules = additionalModules || [];
|
|
68
69
|
this.setupInitCommand();
|
|
69
70
|
}
|
|
70
71
|
// Init is never called in a child class
|
|
@@ -120,13 +121,21 @@ class BaseCLI {
|
|
|
120
121
|
const fileExtension = settings.translationsDir
|
|
121
122
|
.split('.')
|
|
122
123
|
.pop();
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
let dataFormat;
|
|
125
|
+
if (this.library === 'next-intl') {
|
|
126
|
+
dataFormat = 'ICU';
|
|
127
|
+
}
|
|
128
|
+
else if (this.library === 'i18next') {
|
|
129
|
+
if (this.additionalModules.includes('i18next-icu')) {
|
|
130
|
+
dataFormat = 'ICU';
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
dataFormat = 'I18NEXT';
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
dataFormat = 'JSX';
|
|
138
|
+
}
|
|
130
139
|
if (!dataFormat) {
|
|
131
140
|
console.error(errors_1.noDataFormatError);
|
|
132
141
|
process.exit(1);
|
package/dist/cli/next.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WrapOptions, Options, Updates, SetupOptions, SupportedFrameworks, SupportedLibraries } from '../types';
|
|
2
2
|
import { ReactCLI } from './react';
|
|
3
3
|
export declare class NextCLI extends ReactCLI {
|
|
4
|
-
constructor(library: SupportedLibraries);
|
|
4
|
+
constructor(library: SupportedLibraries, additionalModules?: SupportedLibraries[]);
|
|
5
5
|
init(): void;
|
|
6
6
|
execute(): void;
|
|
7
7
|
protected scanForContent(options: WrapOptions, framework: SupportedFrameworks): Promise<{
|
package/dist/cli/next.js
CHANGED
|
@@ -26,8 +26,8 @@ const react_1 = require("./react");
|
|
|
26
26
|
const generateSettings_1 = require("../config/generateSettings");
|
|
27
27
|
const pkg = 'gt-next';
|
|
28
28
|
class NextCLI extends react_1.ReactCLI {
|
|
29
|
-
constructor(library) {
|
|
30
|
-
super(library);
|
|
29
|
+
constructor(library, additionalModules) {
|
|
30
|
+
super(library, additionalModules);
|
|
31
31
|
}
|
|
32
32
|
init() {
|
|
33
33
|
this.setupTranslateCommand();
|
package/dist/cli/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Options, SetupOptions, SupportedFrameworks, Updates, WrapOptions, GenerateSourceOptions, SupportedLibraries } from '../types';
|
|
2
2
|
import { BaseCLI } from './base';
|
|
3
3
|
export declare class ReactCLI extends BaseCLI {
|
|
4
|
-
constructor(library: SupportedLibraries);
|
|
4
|
+
constructor(library: SupportedLibraries, additionalModules?: SupportedLibraries[]);
|
|
5
5
|
init(): void;
|
|
6
6
|
execute(): void;
|
|
7
7
|
protected scanForContent(options: WrapOptions, framework: SupportedFrameworks): Promise<{
|
package/dist/cli/react.js
CHANGED
|
@@ -70,8 +70,8 @@ const saveJSON_1 = require("../fs/saveJSON");
|
|
|
70
70
|
const DEFAULT_TIMEOUT = 600;
|
|
71
71
|
const pkg = 'gt-react';
|
|
72
72
|
class ReactCLI extends base_1.BaseCLI {
|
|
73
|
-
constructor(library) {
|
|
74
|
-
super(library);
|
|
73
|
+
constructor(library, additionalModules) {
|
|
74
|
+
super(library, additionalModules);
|
|
75
75
|
}
|
|
76
76
|
init() {
|
|
77
77
|
this.setupTranslateCommand();
|
|
@@ -8,6 +8,8 @@ const chalk_1 = __importDefault(require("chalk"));
|
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
9
|
const fs_1 = __importDefault(require("fs"));
|
|
10
10
|
function determineLibrary() {
|
|
11
|
+
let library = 'base';
|
|
12
|
+
let additionalModules = [];
|
|
11
13
|
try {
|
|
12
14
|
// Get the current working directory (where the CLI is being run)
|
|
13
15
|
const cwd = process.cwd();
|
|
@@ -15,32 +17,32 @@ function determineLibrary() {
|
|
|
15
17
|
// Check if package.json exists
|
|
16
18
|
if (!fs_1.default.existsSync(packageJsonPath)) {
|
|
17
19
|
console.log(chalk_1.default.red('No package.json found in the current directory. Please run this command from the root of your project.'));
|
|
18
|
-
return 'base';
|
|
20
|
+
return { library: 'base', additionalModules: [] };
|
|
19
21
|
}
|
|
20
22
|
// Read and parse package.json
|
|
21
23
|
const packageJson = JSON.parse(fs_1.default.readFileSync(packageJsonPath, 'utf8'));
|
|
22
24
|
const dependencies = Object.assign(Object.assign({}, packageJson.dependencies), packageJson.devDependencies);
|
|
23
25
|
// Check for gt-next or gt-react in dependencies
|
|
24
26
|
if (dependencies['gt-next']) {
|
|
25
|
-
|
|
27
|
+
library = 'gt-next';
|
|
26
28
|
}
|
|
27
29
|
else if (dependencies['gt-react']) {
|
|
28
|
-
|
|
30
|
+
library = 'gt-react';
|
|
29
31
|
}
|
|
30
32
|
else if (dependencies['next-intl']) {
|
|
31
|
-
|
|
33
|
+
library = 'next-intl';
|
|
32
34
|
}
|
|
33
|
-
else if (dependencies['
|
|
34
|
-
|
|
35
|
+
else if (dependencies['i18next']) {
|
|
36
|
+
library = 'i18next';
|
|
35
37
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
if (dependencies['i18next-icu']) {
|
|
39
|
+
additionalModules.push('i18next-icu');
|
|
38
40
|
}
|
|
39
41
|
// Fallback to base if neither is found
|
|
40
|
-
return
|
|
42
|
+
return { library, additionalModules };
|
|
41
43
|
}
|
|
42
44
|
catch (error) {
|
|
43
45
|
console.error('Error determining framework:', error);
|
|
44
|
-
return 'base';
|
|
46
|
+
return { library: 'base', additionalModules: [] };
|
|
45
47
|
}
|
|
46
48
|
}
|
package/dist/index.js
CHANGED
|
@@ -8,16 +8,16 @@ const next_1 = require("./cli/next");
|
|
|
8
8
|
const react_1 = require("./cli/react");
|
|
9
9
|
const determineFramework_1 = require("./fs/determineFramework");
|
|
10
10
|
function main() {
|
|
11
|
-
const library = (0, determineFramework_1.determineLibrary)();
|
|
11
|
+
const { library, additionalModules } = (0, determineFramework_1.determineLibrary)();
|
|
12
12
|
let cli;
|
|
13
13
|
if (library === 'gt-next') {
|
|
14
|
-
cli = new next_1.NextCLI(
|
|
14
|
+
cli = new next_1.NextCLI(library, additionalModules);
|
|
15
15
|
}
|
|
16
16
|
else if (library === 'gt-react') {
|
|
17
|
-
cli = new react_1.ReactCLI(
|
|
17
|
+
cli = new react_1.ReactCLI(library, additionalModules);
|
|
18
18
|
}
|
|
19
19
|
else {
|
|
20
|
-
cli = new base_1.BaseCLI(library);
|
|
20
|
+
cli = new base_1.BaseCLI(library, additionalModules);
|
|
21
21
|
}
|
|
22
22
|
cli.init();
|
|
23
23
|
cli.execute();
|
package/dist/types/index.d.ts
CHANGED
|
@@ -53,7 +53,7 @@ export type GenerateSourceOptions = {
|
|
|
53
53
|
};
|
|
54
54
|
export type Framework = 'gt-next' | 'gt-react';
|
|
55
55
|
export type SupportedFrameworks = 'next-app' | 'next-pages' | 'vite' | 'react' | 'gatsby';
|
|
56
|
-
export type SupportedLibraries = 'gt-next' | 'gt-react' | 'next-intl' | 'react-i18next' | 'next-i18next' | 'base';
|
|
56
|
+
export type SupportedLibraries = 'gt-next' | 'gt-react' | 'next-intl' | 'react-i18next' | 'next-i18next' | 'i18next' | 'i18next-icu' | 'base';
|
|
57
57
|
export interface ContentScanner {
|
|
58
58
|
scanForContent(options: WrapOptions, framework: Framework): Promise<{
|
|
59
59
|
errors: string[];
|