@simplelocalize/cli 1.0.6 → 1.0.7
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/bin/simplelocalize.exe +0 -0
- package/index.cjs +114 -109
- package/package.json +20 -19
|
Binary file
|
package/index.cjs
CHANGED
|
@@ -1,109 +1,114 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
const { execSync } = require("child_process");
|
|
3
|
-
const path = require("path");
|
|
4
|
-
const fs = require('fs');
|
|
5
|
-
const axios = require('axios');
|
|
6
|
-
const os = require('os');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
console.
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const linkToNodeModulesBin = () => {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const { execSync } = require("child_process");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
const fs = require('fs');
|
|
5
|
+
const axios = require('axios');
|
|
6
|
+
const os = require('os');
|
|
7
|
+
|
|
8
|
+
let binaryPath = path.join(__dirname, 'bin', 'simplelocalize');
|
|
9
|
+
if (os.platform() === 'win32') {
|
|
10
|
+
binaryPath += '.exe';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const isBinaryInstalled = () => {
|
|
14
|
+
try {
|
|
15
|
+
execSync(binaryPath + ' --version', { stdio: 'ignore' });
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const printBinaryVersion = () => {
|
|
24
|
+
try {
|
|
25
|
+
console.log(execSync(binaryPath + ' --version').toString());
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error running SimpleLocalize CLI');
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const buildDownloadBinaryUrl = (version) => {
|
|
34
|
+
let platform = "";
|
|
35
|
+
if (os.platform() === "win32") {
|
|
36
|
+
platform = "windows.exe"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (os.platform() === "darwin") {
|
|
40
|
+
platform = "mac"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (os.platform() === "linux") {
|
|
44
|
+
platform = "linux"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let arch = "";
|
|
48
|
+
if (os.arch() === "arm64") {
|
|
49
|
+
arch = "-arm64"
|
|
50
|
+
}
|
|
51
|
+
console.log(`Downloading SimpleLocalize CLI ${version} for ${platform}${arch}...`);
|
|
52
|
+
return `https://github.com/simplelocalize/simplelocalize-cli/releases/download/${version}/simplelocalize-cli-${platform}${arch}`
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function installBinary() {
|
|
56
|
+
const cliVersion = "2.8.0";
|
|
57
|
+
const downloadUrl = buildDownloadBinaryUrl(cliVersion);
|
|
58
|
+
if (!fs.existsSync(path.join(__dirname, 'bin'))) {
|
|
59
|
+
fs.mkdirSync(path.join(__dirname, 'bin'));
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const response = await axios({
|
|
63
|
+
url: downloadUrl,
|
|
64
|
+
method: 'GET',
|
|
65
|
+
responseType: 'stream'
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const writer = fs.createWriteStream(binaryPath);
|
|
69
|
+
response.data.pipe(writer);
|
|
70
|
+
await new Promise((resolve, reject) => {
|
|
71
|
+
writer.on('finish', resolve);
|
|
72
|
+
writer.on('error', reject);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Make it executable (only on Unix-based systems)
|
|
76
|
+
if (os.platform() !== 'win32') {
|
|
77
|
+
console.log('Making binary executable...');
|
|
78
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const linkToNodeModulesBin = () => {
|
|
83
|
+
let nodeModulesBinPath = path.join(__dirname, '..', '..', '.bin', 'simplelocalize');
|
|
84
|
+
|
|
85
|
+
if (os.platform() === 'win32') {
|
|
86
|
+
nodeModulesBinPath += '.exe';
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (fs.existsSync(nodeModulesBinPath)) {
|
|
90
|
+
fs.unlinkSync(nodeModulesBinPath);
|
|
91
|
+
}
|
|
92
|
+
fs.symlinkSync(binaryPath, nodeModulesBinPath);
|
|
93
|
+
console.log('Link to node_modules/.bin created.');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const init = async () => {
|
|
97
|
+
console.log("Checking if SimpleLocalize CLI is installed...");
|
|
98
|
+
if (!isBinaryInstalled()) {
|
|
99
|
+
console.log("SimpleLocalize CLI not installed. Installing...");
|
|
100
|
+
await installBinary();
|
|
101
|
+
if (!isBinaryInstalled()) {
|
|
102
|
+
console.error('Error installing SimpleLocalize CLI');
|
|
103
|
+
process.exit(1);
|
|
104
|
+
}
|
|
105
|
+
console.log("SimpleLocalize CLI installed successfully!");
|
|
106
|
+
} else {
|
|
107
|
+
console.log("SimpleLocalize CLI already installed.");
|
|
108
|
+
}
|
|
109
|
+
printBinaryVersion();
|
|
110
|
+
linkToNodeModulesBin();
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
init();
|
package/package.json
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@simplelocalize/cli",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "SimpleLocalize CLI for NPM",
|
|
5
|
-
"main": "index.cjs",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "node index.cjs",
|
|
9
|
-
"postinstall": "node index.cjs install"
|
|
10
|
-
},
|
|
11
|
-
"bin": {
|
|
12
|
-
"install": "index.cjs"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@simplelocalize/cli",
|
|
3
|
+
"version": "1.0.7",
|
|
4
|
+
"description": "SimpleLocalize CLI for NPM",
|
|
5
|
+
"main": "index.cjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "node index.cjs",
|
|
9
|
+
"postinstall": "node index.cjs install"
|
|
10
|
+
},
|
|
11
|
+
"bin": {
|
|
12
|
+
"install": "index.cjs",
|
|
13
|
+
"simplelocalize": "bin/simplelocalize"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"axios": "^1.8.3"
|
|
17
|
+
},
|
|
18
|
+
"author": "Jakub Pomykała",
|
|
19
|
+
"license": "MIT"
|
|
20
|
+
}
|