codeplay-common 1.2.5 → 1.2.6
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.
|
@@ -2,6 +2,69 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const plist = require('plist');
|
|
4
4
|
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
//Check codeplay-common latest version installed or not Start
|
|
8
|
+
const { execSync } = require('child_process');
|
|
9
|
+
|
|
10
|
+
function getInstalledVersion(packageName) {
|
|
11
|
+
try {
|
|
12
|
+
const packageJsonPath = path.join(process.cwd(), 'node_modules', packageName, 'package.json');
|
|
13
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
14
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
|
|
15
|
+
return packageJson.version;
|
|
16
|
+
}
|
|
17
|
+
} catch (error) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function getLatestVersion(packageName) {
|
|
24
|
+
try {
|
|
25
|
+
return execSync(`npm view ${packageName} version`).toString().trim();
|
|
26
|
+
} catch (error) {
|
|
27
|
+
console.error(`Failed to fetch latest version for ${packageName}`);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function checkPackageVersion() {
|
|
33
|
+
const packageName = 'codeplay-common';
|
|
34
|
+
const installedVersion = getInstalledVersion(packageName);
|
|
35
|
+
const latestVersion = getLatestVersion(packageName);
|
|
36
|
+
|
|
37
|
+
if (!installedVersion) {
|
|
38
|
+
console.error(`${packageName} is not installed. Please install it using "npm install ${packageName}".`);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (installedVersion !== latestVersion) {
|
|
43
|
+
console.error(`\x1b[31m${packageName} is outdated (installed: ${installedVersion}, latest: ${latestVersion}). Please update it.\x1b[0m\n\x1b[33mUse 'npm uninstall codeplay-common ; npm i codeplay-common'\x1b[0m`);
|
|
44
|
+
process.exit(1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
console.log(`${packageName} is up to date (version ${installedVersion}).`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Run package version check before executing the main script
|
|
51
|
+
try {
|
|
52
|
+
checkPackageVersion();
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(error.message);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
//Check codeplay-common latest version installed or not End
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
5
68
|
const configPath = path.join(process.cwd(), 'capacitor.config.json');
|
|
6
69
|
const androidPlatformPath = path.join(process.cwd(), 'android');
|
|
7
70
|
const iosPlatformPath = path.join(process.cwd(), 'ios');
|