@simplelocalize/cli 1.0.3 → 1.0.5
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/index.cjs +21 -4
- package/package.json +1 -1
package/index.cjs
CHANGED
|
@@ -45,15 +45,32 @@ const buildDownloadBinaryUrl = (version) => {
|
|
|
45
45
|
if (os.arch() === "arm64") {
|
|
46
46
|
arch = "-arm64"
|
|
47
47
|
}
|
|
48
|
+
console.log(`Downloading SimpleLocalize CLI ${version} for ${platform}${arch}...`);
|
|
48
49
|
return `https://github.com/simplelocalize/simplelocalize-cli/releases/download/${version}/simplelocalize-cli-${platform}${arch}`
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
|
|
53
|
+
const getCliVersionFromArgs = () => {
|
|
54
|
+
const args = process.argv.slice(2);
|
|
55
|
+
const versionIndex = args.indexOf('--version');
|
|
56
|
+
if (versionIndex !== -1 && args[versionIndex + 1]) {
|
|
57
|
+
return args[versionIndex + 1];
|
|
58
|
+
}
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async function installBinary() {
|
|
63
|
+
const cliVersion = getCliVersionFromArgs();
|
|
64
|
+
if (!cliVersion) {
|
|
65
|
+
console.error('SimpleLocalize CLI version not specified. Please provide version using --version flag.');
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const downloadUrl = buildDownloadBinaryUrl(cliVersion);
|
|
53
70
|
if (!fs.existsSync(path.join(__dirname, 'bin'))) {
|
|
54
71
|
fs.mkdirSync(path.join(__dirname, 'bin'));
|
|
55
72
|
}
|
|
56
|
-
|
|
73
|
+
|
|
57
74
|
const response = await axios({
|
|
58
75
|
url: downloadUrl,
|
|
59
76
|
method: 'GET',
|
|
@@ -78,7 +95,7 @@ async function installBinary(version = "2.8.0") {
|
|
|
78
95
|
}
|
|
79
96
|
|
|
80
97
|
const linkToNodeModulesBin = () => {
|
|
81
|
-
const nodeModulesBinPath = path.join(__dirname, '..', '.bin', 'simplelocalize');
|
|
98
|
+
const nodeModulesBinPath = path.join(__dirname, '..', '..', '.bin', 'simplelocalize');
|
|
82
99
|
if (fs.existsSync(nodeModulesBinPath)) {
|
|
83
100
|
fs.unlinkSync(nodeModulesBinPath);
|
|
84
101
|
}
|