@directivegames/genesys.sdk 3.3.3 → 3.3.4
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/src/core/cli.js +12 -15
- package/package.json +1 -1
package/dist/src/core/cli.js
CHANGED
|
@@ -69,16 +69,11 @@ function isInstalledPackage() {
|
|
|
69
69
|
return false;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
// Get
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return packageJson.version;
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return 'unknown';
|
|
81
|
-
}
|
|
72
|
+
// Get package.json
|
|
73
|
+
function getPackageJson() {
|
|
74
|
+
const packageJsonPath = path.join(getProjectRoot(), 'package.json');
|
|
75
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
|
|
76
|
+
return packageJson;
|
|
82
77
|
}
|
|
83
78
|
// Check for updates and prompt user
|
|
84
79
|
async function checkForUpdates() {
|
|
@@ -87,11 +82,13 @@ async function checkForUpdates() {
|
|
|
87
82
|
if (!isInstalledPackage())
|
|
88
83
|
return;
|
|
89
84
|
logger.log('Checking for updates...');
|
|
90
|
-
const
|
|
85
|
+
const packageJson = getPackageJson();
|
|
86
|
+
const currentVersion = packageJson.version;
|
|
87
|
+
const packageName = packageJson.name;
|
|
91
88
|
if (currentVersion === 'unknown')
|
|
92
89
|
return;
|
|
93
90
|
// Fetch latest version from npm registry
|
|
94
|
-
const response = await fetch(
|
|
91
|
+
const response = await fetch(`https://registry.npmjs.org/${packageJson.name}/latest`);
|
|
95
92
|
if (!response.ok)
|
|
96
93
|
return;
|
|
97
94
|
const data = await response.json();
|
|
@@ -106,9 +103,8 @@ async function checkForUpdates() {
|
|
|
106
103
|
// Prompt user if they want to upgrade now
|
|
107
104
|
const answer = await promptUser('Would you like to upgrade now? (Y/n): ');
|
|
108
105
|
if (answer === '' || answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes') {
|
|
109
|
-
logger.log(
|
|
106
|
+
logger.log(`\nUpgrading ${packageName}...\n`);
|
|
110
107
|
const { execSync } = await import('child_process');
|
|
111
|
-
const packageName = '@directivegames/genesys.sdk';
|
|
112
108
|
try {
|
|
113
109
|
execSync(`pnpm remove -g ${packageName} && pnpm add -g ${packageName}`, {
|
|
114
110
|
stdio: 'inherit'
|
|
@@ -160,7 +156,8 @@ async function main() {
|
|
|
160
156
|
await checkForUpdates();
|
|
161
157
|
const program = new Command();
|
|
162
158
|
const handler = new ConsoleHandler();
|
|
163
|
-
const
|
|
159
|
+
const packageJson = getPackageJson();
|
|
160
|
+
const currentVersion = packageJson.version;
|
|
164
161
|
program
|
|
165
162
|
.name('genesys-sdk')
|
|
166
163
|
.description('Genesys SDK CLI - Game Project Management Tool')
|