Skip to content

Commit b68eb62

Browse files
committed
Init
0 parents  commit b68eb62

File tree

377 files changed

+47384
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

377 files changed

+47384
-0
lines changed

.gitignore

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
4+
### STS ###
5+
.apt_generated
6+
.classpath
7+
.factorypath
8+
.project
9+
.settings
10+
.springBeans
11+
.sts4-cache
12+
13+
### IntelliJ IDEA ###
14+
.idea
15+
*.iws
16+
*.iml
17+
*.ipr
18+
19+
extraction.json
20+
21+
test
22+
23+
### NetBeans ###
24+
/nbproject/private/
25+
/nbbuild/
26+
/nbdist/
27+
/.nb-gradle/
28+
/build/
29+
30+
simplelocalize-dev.properties
31+
simplelocalize-dev.yml
32+
simplelocalize-dev.yaml
33+
simplelocalize*.jar
34+
*ITE.java
35+
36+
io.simplelocalize.cli.simplelocalizeclicommand
37+
simplelocalize-cli
38+
39+
.*bgv
40+
41+
### macOS ###
42+
*.DS_Store
43+
.AppleDouble
44+
.LSOverride
45+
46+
47+
### Windows ###
48+
# Windows thumbnail cache files
49+
Thumbs.db
50+
ehthumbs.db
51+
ehthumbs_vista.db
52+
53+
# Folder config file
54+
Desktop.ini
55+
56+
# Recycle Bin used on file shares
57+
$RECYCLE.BIN/
58+
59+
# Windows Installer files
60+
*.cab
61+
*.msi
62+
*.msm
63+
*.msp
64+
65+
# Windows shortcuts
66+
*.lnk
67+
68+
/simplelocalize-sample.yml
69+
/dependency-reduced-pom.xml
70+
/build-far-jar.sh
71+
/build-quick.sh
72+
/build-production.sh
73+
/build-m1.sh
74+
/install.sh
75+
/install-locally.sh
76+
/simplelocalize-init-command.yml

bin/simplelocalize

54.4 MB
Binary file not shown.

index.js

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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+
const binaryPath = path.join(__dirname, 'bin', 'simplelocalize');
9+
10+
const isBinaryInstalled = () => {
11+
try {
12+
execSync(binaryPath + ' --version', { stdio: 'ignore' });
13+
return true;
14+
}
15+
catch (error) {
16+
return false;
17+
}
18+
}
19+
20+
const printBinaryVersion = () => {
21+
try {
22+
console.log(execSync(binaryPath + ' --version').toString());
23+
}
24+
catch (error) {
25+
console.error('Error running SimpleLocalize CLI');
26+
process.exit(1);
27+
}
28+
}
29+
30+
const buildDownloadBinaryUrl = (version) => {
31+
let platform = "";
32+
if (os.platform() === "win32") {
33+
platform = "windows.exe"
34+
}
35+
36+
if (os.platform() === "darwin") {
37+
platform = "mac"
38+
}
39+
40+
if (os.platform() === "linux") {
41+
platform = "linux"
42+
}
43+
44+
let arch = "";
45+
if (os.arch() === "arm64") {
46+
arch = "-arm64"
47+
}
48+
return `https://github.com/simplelocalize/simplelocalize-cli/releases/download/${version}/simplelocalize-cli-${platform}${arch}`
49+
}
50+
51+
async function installBinary(version = "2.8.0") {
52+
const downloadUrl = buildDownloadBinaryUrl(version);
53+
if (!fs.existsSync(path.join(__dirname, 'bin'))) {
54+
fs.mkdirSync(path.join(__dirname, 'bin'));
55+
}
56+
console.log(`Downloading ${downloadUrl}...`);
57+
const response = await axios({
58+
url: downloadUrl,
59+
method: 'GET',
60+
responseType: 'stream'
61+
});
62+
63+
const writer = fs.createWriteStream(binaryPath);
64+
response.data.pipe(writer);
65+
await new Promise((resolve, reject) => {
66+
writer.on('finish', resolve);
67+
writer.on('error', reject);
68+
});
69+
70+
console.log('SimpleLocalize CLI downloaded successfully!');
71+
72+
// Make it executable (only on Unix-based systems)
73+
if (os.platform() !== 'win32') {
74+
fs.chmodSync(binaryPath, 0o755);
75+
}
76+
77+
console.log('Binary is now executable.');
78+
}
79+
80+
const init = async () => {
81+
console.log("Checking if SimpleLocalize CLI is installed...");
82+
if (!isBinaryInstalled()) {
83+
console.log("SimpleLocalize CLI not installed. Installing...");
84+
await installBinary();
85+
if (!isBinaryInstalled()) {
86+
console.error('Error installing SimpleLocalize CLI');
87+
process.exit(1);
88+
}
89+
console.log("SimpleLocalize CLI installed successfully!");
90+
} else {
91+
console.log("SimpleLocalize CLI already installed.");
92+
}
93+
printBinaryVersion();
94+
process.exit(0);
95+
}
96+
97+
await init();

0 commit comments

Comments
 (0)