gtx-cli 1.2.24-alpha.1 → 1.2.24-alpha.3
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/console/logging.js +1 -1
- package/dist/utils/installPackage.d.ts +1 -0
- package/dist/utils/installPackage.js +34 -0
- package/dist/utils/packageInfo.d.ts +3 -0
- package/dist/utils/packageInfo.js +20 -0
- package/dist/utils/packageManager.d.ts +2 -1
- package/dist/utils/packageManager.js +14 -1
- package/package.json +1 -1
package/dist/console/logging.js
CHANGED
|
@@ -97,7 +97,7 @@ function displayResolvedPaths(resolvedPaths) {
|
|
|
97
97
|
prompts_1.log.step(`Resolved path aliases:\n${paths.join('\n')}`);
|
|
98
98
|
}
|
|
99
99
|
function displayCreatedConfigFile(configFilepath) {
|
|
100
|
-
prompts_1.log.
|
|
100
|
+
prompts_1.log.step(`Created config file ${chalk_1.default.cyan(configFilepath)}`);
|
|
101
101
|
}
|
|
102
102
|
function displayUpdatedConfigFile(configFilepath) {
|
|
103
103
|
prompts_1.log.success(`Updated config file ${chalk_1.default.cyan(configFilepath)}`);
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import { PackageManager } from './packageManager';
|
|
2
2
|
export declare function installPackage(packageName: string, packageManager: PackageManager, asDevDependency?: boolean): Promise<void>;
|
|
3
|
+
export declare function installPackageGlobal(packageName: string, version?: string): Promise<void>;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.installPackage = installPackage;
|
|
7
|
+
exports.installPackageGlobal = installPackageGlobal;
|
|
7
8
|
const chalk_1 = __importDefault(require("chalk"));
|
|
8
9
|
const child_process_1 = require("child_process");
|
|
9
10
|
const console_1 = require("../console");
|
|
@@ -43,3 +44,36 @@ async function installPackage(packageName, packageManager, asDevDependency) {
|
|
|
43
44
|
});
|
|
44
45
|
});
|
|
45
46
|
}
|
|
47
|
+
async function installPackageGlobal(packageName, version) {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const command = 'npm';
|
|
50
|
+
const args = ['install', '-g', packageName, version ? `@${version}` : ''];
|
|
51
|
+
const childProcess = (0, child_process_1.spawn)(command, args, {
|
|
52
|
+
stdio: ['pipe', 'ignore', 'pipe'],
|
|
53
|
+
});
|
|
54
|
+
let errorOutput = '';
|
|
55
|
+
if (childProcess.stderr) {
|
|
56
|
+
childProcess.stderr.on('data', (data) => {
|
|
57
|
+
errorOutput += data.toString();
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
childProcess.on('error', (error) => {
|
|
61
|
+
(0, console_1.logError)(chalk_1.default.red(`Installation error: ${error.message}`));
|
|
62
|
+
(0, console_1.logInfo)(`Please manually install ${packageName} with: npm install -g ${packageName}`);
|
|
63
|
+
reject(error);
|
|
64
|
+
});
|
|
65
|
+
childProcess.on('close', (code) => {
|
|
66
|
+
if (code === 0) {
|
|
67
|
+
resolve();
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
(0, console_1.logError)(chalk_1.default.red(`Installation failed with exit code ${code}`));
|
|
71
|
+
if (errorOutput) {
|
|
72
|
+
(0, console_1.logError)(chalk_1.default.red(`Error details: ${errorOutput}`));
|
|
73
|
+
}
|
|
74
|
+
(0, console_1.logInfo)(`Please manually install ${packageName} with: npm install -g ${packageName}`);
|
|
75
|
+
reject(new Error(`Process exited with code ${code}`));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPackageInfo = getPackageInfo;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
async function getPackageInfo(packageName) {
|
|
6
|
+
try {
|
|
7
|
+
const output = (0, child_process_1.execSync)(`npm list -g ${packageName}`, {
|
|
8
|
+
encoding: 'utf8',
|
|
9
|
+
stdio: 'pipe',
|
|
10
|
+
});
|
|
11
|
+
const match = output.match(new RegExp(`${packageName}@([\\d\\.\\w-]+)`));
|
|
12
|
+
if (match && match[1]) {
|
|
13
|
+
return { version: match[1] };
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export interface PackageManager {
|
|
2
|
+
id: string;
|
|
2
3
|
name: string;
|
|
3
4
|
label: string;
|
|
4
5
|
installCommand: string;
|
|
@@ -20,4 +21,4 @@ export declare const PNPM: PackageManager;
|
|
|
20
21
|
export declare const NPM: PackageManager;
|
|
21
22
|
export declare const packageManagers: PackageManager[];
|
|
22
23
|
export declare function _detectPackageManger(managers?: PackageManager[]): PackageManager | null;
|
|
23
|
-
export declare function getPackageManager(): Promise<PackageManager>;
|
|
24
|
+
export declare function getPackageManager(specifiedPackageManager?: string): Promise<PackageManager>;
|
|
@@ -42,6 +42,7 @@ const path = __importStar(require("path"));
|
|
|
42
42
|
const packageJson_1 = require("./packageJson");
|
|
43
43
|
const console_1 = require("../console");
|
|
44
44
|
exports.BUN = {
|
|
45
|
+
id: 'bun',
|
|
45
46
|
name: 'bun',
|
|
46
47
|
label: 'Bun',
|
|
47
48
|
installCommand: 'add',
|
|
@@ -71,6 +72,7 @@ exports.BUN = {
|
|
|
71
72
|
},
|
|
72
73
|
};
|
|
73
74
|
exports.DENO = {
|
|
75
|
+
id: 'deno',
|
|
74
76
|
name: 'deno',
|
|
75
77
|
label: 'Deno',
|
|
76
78
|
installCommand: 'install',
|
|
@@ -101,6 +103,7 @@ exports.DENO = {
|
|
|
101
103
|
},
|
|
102
104
|
};
|
|
103
105
|
exports.YARN_V1 = {
|
|
106
|
+
id: 'yarn_v1',
|
|
104
107
|
name: 'yarn',
|
|
105
108
|
label: 'Yarn V1',
|
|
106
109
|
installCommand: 'add',
|
|
@@ -134,6 +137,7 @@ exports.YARN_V1 = {
|
|
|
134
137
|
};
|
|
135
138
|
/** YARN V2/3/4 */
|
|
136
139
|
exports.YARN_V2 = {
|
|
140
|
+
id: 'yarn_v2',
|
|
137
141
|
name: 'yarn',
|
|
138
142
|
label: 'Yarn V2/3/4',
|
|
139
143
|
installCommand: 'add',
|
|
@@ -166,6 +170,7 @@ exports.YARN_V2 = {
|
|
|
166
170
|
},
|
|
167
171
|
};
|
|
168
172
|
exports.PNPM = {
|
|
173
|
+
id: 'pnpm',
|
|
169
174
|
name: 'pnpm',
|
|
170
175
|
label: 'PNPM',
|
|
171
176
|
installCommand: 'add',
|
|
@@ -199,6 +204,7 @@ exports.PNPM = {
|
|
|
199
204
|
},
|
|
200
205
|
};
|
|
201
206
|
exports.NPM = {
|
|
207
|
+
id: 'npm',
|
|
202
208
|
name: 'npm',
|
|
203
209
|
label: 'NPM',
|
|
204
210
|
installCommand: 'install',
|
|
@@ -239,11 +245,18 @@ function _detectPackageManger(managers) {
|
|
|
239
245
|
}
|
|
240
246
|
// Get the package manager for the current project
|
|
241
247
|
// Uses a global cache to avoid prompting the user multiple times
|
|
242
|
-
async function getPackageManager() {
|
|
248
|
+
async function getPackageManager(specifiedPackageManager) {
|
|
243
249
|
const globalWizard = global;
|
|
244
250
|
if (globalWizard._gt_wizard_cached_package_manager) {
|
|
245
251
|
return globalWizard._gt_wizard_cached_package_manager;
|
|
246
252
|
}
|
|
253
|
+
if (specifiedPackageManager) {
|
|
254
|
+
const packageManager = exports.packageManagers.find((packageManager) => packageManager.id === specifiedPackageManager);
|
|
255
|
+
if (packageManager) {
|
|
256
|
+
globalWizard._gt_wizard_cached_package_manager = packageManager;
|
|
257
|
+
return packageManager;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
247
260
|
const detectedPackageManager = _detectPackageManger();
|
|
248
261
|
if (detectedPackageManager) {
|
|
249
262
|
globalWizard._gt_wizard_cached_package_manager = detectedPackageManager;
|