@glock-org/glock 1.0.0 → 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/package.json +17 -4
- package/lib/platform.js +0 -234
package/package.json
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@glock-org/glock",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Glock - AI Coding Assistant CLI",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"glock",
|
|
7
|
+
"ai",
|
|
8
|
+
"coding",
|
|
9
|
+
"assistant",
|
|
10
|
+
"cli"
|
|
11
|
+
],
|
|
6
12
|
"author": "Glock",
|
|
7
13
|
"license": "UNLICENSED",
|
|
8
14
|
"private": false,
|
|
@@ -22,6 +28,13 @@
|
|
|
22
28
|
"scripts/",
|
|
23
29
|
"README.md"
|
|
24
30
|
],
|
|
25
|
-
"os": [
|
|
26
|
-
|
|
31
|
+
"os": [
|
|
32
|
+
"darwin",
|
|
33
|
+
"linux",
|
|
34
|
+
"win32"
|
|
35
|
+
],
|
|
36
|
+
"cpu": [
|
|
37
|
+
"x64",
|
|
38
|
+
"arm64"
|
|
39
|
+
]
|
|
27
40
|
}
|
package/lib/platform.js
DELETED
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Platform detection for Glock CLI binary downloads.
|
|
3
|
-
*
|
|
4
|
-
* Determines the correct binary to download based on:
|
|
5
|
-
* - Operating system (darwin, linux, win32)
|
|
6
|
-
* - Architecture (x64, arm64)
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
const os = require('os');
|
|
10
|
-
const path = require('path');
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Supported platforms and architectures
|
|
14
|
-
*/
|
|
15
|
-
const SUPPORTED_PLATFORMS = {
|
|
16
|
-
darwin: ['x64', 'arm64'],
|
|
17
|
-
linux: ['x64', 'arm64'],
|
|
18
|
-
win32: ['x64'],
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Binary file names by platform
|
|
23
|
-
*/
|
|
24
|
-
const BINARY_NAMES = {
|
|
25
|
-
darwin: 'glock',
|
|
26
|
-
linux: 'glock',
|
|
27
|
-
win32: 'glock.exe',
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Get the current platform identifier
|
|
32
|
-
* @returns {string} Platform identifier (e.g., 'darwin-arm64')
|
|
33
|
-
*/
|
|
34
|
-
function getPlatformId() {
|
|
35
|
-
const platform = os.platform();
|
|
36
|
-
const arch = os.arch();
|
|
37
|
-
return `${platform}-${arch}`;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Check if the current platform is supported
|
|
42
|
-
* @returns {boolean} True if supported
|
|
43
|
-
*/
|
|
44
|
-
function isPlatformSupported() {
|
|
45
|
-
const platform = os.platform();
|
|
46
|
-
const arch = os.arch();
|
|
47
|
-
|
|
48
|
-
const supportedArchs = SUPPORTED_PLATFORMS[platform];
|
|
49
|
-
if (!supportedArchs) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return supportedArchs.includes(arch);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Get the binary name for the current platform
|
|
58
|
-
* @returns {string} Binary file name
|
|
59
|
-
*/
|
|
60
|
-
function getBinaryName() {
|
|
61
|
-
const platform = os.platform();
|
|
62
|
-
return BINARY_NAMES[platform] || 'glock';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get the download URL for the binary
|
|
67
|
-
* @param {string} version - Version to download (e.g., '1.0.0')
|
|
68
|
-
* @param {string} baseUrl - Base URL for downloads
|
|
69
|
-
* @returns {string} Full download URL
|
|
70
|
-
*/
|
|
71
|
-
function getDownloadUrl(version, baseUrl = 'https://github.com/glock/glock/releases/download') {
|
|
72
|
-
const platform = os.platform();
|
|
73
|
-
const arch = os.arch();
|
|
74
|
-
const platformId = `${platform}-${arch}`;
|
|
75
|
-
|
|
76
|
-
return `${baseUrl}/v${version}/glock-${platformId}.tar.gz`;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Get the installation directory for the binary
|
|
81
|
-
* @returns {string} Installation directory path
|
|
82
|
-
*/
|
|
83
|
-
function getInstallDir() {
|
|
84
|
-
return path.join(__dirname, '..', 'bin', getPlatformId());
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get the full path to the installed binary
|
|
89
|
-
* @returns {string} Full binary path
|
|
90
|
-
*/
|
|
91
|
-
function getBinaryPath() {
|
|
92
|
-
return path.join(getInstallDir(), getBinaryName());
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get platform-specific environment variables
|
|
97
|
-
* @returns {Object} Environment variables to set
|
|
98
|
-
*/
|
|
99
|
-
function getPlatformEnv() {
|
|
100
|
-
const env = {
|
|
101
|
-
GLOCK_NPM_INSTALL: '1',
|
|
102
|
-
GLOCK_PLATFORM: getPlatformId(),
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
// Platform-specific additions
|
|
106
|
-
const platform = os.platform();
|
|
107
|
-
|
|
108
|
-
if (platform === 'darwin') {
|
|
109
|
-
// macOS-specific
|
|
110
|
-
env.GLOCK_MACOS_VERSION = os.release();
|
|
111
|
-
} else if (platform === 'linux') {
|
|
112
|
-
// Linux-specific
|
|
113
|
-
env.GLOCK_LINUX_DISTRO = detectLinuxDistro();
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
return env;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Detect Linux distribution (best effort)
|
|
121
|
-
* @returns {string} Distribution name or 'unknown'
|
|
122
|
-
*/
|
|
123
|
-
function detectLinuxDistro() {
|
|
124
|
-
try {
|
|
125
|
-
const fs = require('fs');
|
|
126
|
-
|
|
127
|
-
// Try /etc/os-release first
|
|
128
|
-
if (fs.existsSync('/etc/os-release')) {
|
|
129
|
-
const content = fs.readFileSync('/etc/os-release', 'utf8');
|
|
130
|
-
const match = content.match(/^ID=(.*)$/m);
|
|
131
|
-
if (match) {
|
|
132
|
-
return match[1].replace(/"/g, '');
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Fallback checks
|
|
137
|
-
if (fs.existsSync('/etc/debian_version')) {
|
|
138
|
-
return 'debian';
|
|
139
|
-
}
|
|
140
|
-
if (fs.existsSync('/etc/redhat-release')) {
|
|
141
|
-
return 'redhat';
|
|
142
|
-
}
|
|
143
|
-
if (fs.existsSync('/etc/alpine-release')) {
|
|
144
|
-
return 'alpine';
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return 'unknown';
|
|
148
|
-
} catch (e) {
|
|
149
|
-
return 'unknown';
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Get system information for debugging
|
|
155
|
-
* @returns {Object} System information
|
|
156
|
-
*/
|
|
157
|
-
function getSystemInfo() {
|
|
158
|
-
return {
|
|
159
|
-
platform: os.platform(),
|
|
160
|
-
arch: os.arch(),
|
|
161
|
-
release: os.release(),
|
|
162
|
-
type: os.type(),
|
|
163
|
-
cpus: os.cpus().length,
|
|
164
|
-
memory: Math.round(os.totalmem() / (1024 * 1024 * 1024)) + 'GB',
|
|
165
|
-
node: process.version,
|
|
166
|
-
npm: process.env.npm_config_user_agent || 'unknown',
|
|
167
|
-
supported: isPlatformSupported(),
|
|
168
|
-
platformId: getPlatformId(),
|
|
169
|
-
binaryName: getBinaryName(),
|
|
170
|
-
installDir: getInstallDir(),
|
|
171
|
-
binaryPath: getBinaryPath(),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Validate that the platform can run Glock
|
|
177
|
-
* @throws {Error} If platform is not supported
|
|
178
|
-
*/
|
|
179
|
-
function validatePlatform() {
|
|
180
|
-
if (!isPlatformSupported()) {
|
|
181
|
-
const platform = os.platform();
|
|
182
|
-
const arch = os.arch();
|
|
183
|
-
const supported = Object.entries(SUPPORTED_PLATFORMS)
|
|
184
|
-
.map(([p, archs]) => `${p} (${archs.join(', ')})`)
|
|
185
|
-
.join(', ');
|
|
186
|
-
|
|
187
|
-
throw new Error(
|
|
188
|
-
`Glock does not support ${platform}-${arch}.\n` +
|
|
189
|
-
`Supported platforms: ${supported}\n` +
|
|
190
|
-
`Please open an issue if you need support for this platform.`
|
|
191
|
-
);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Check if running in CI environment
|
|
197
|
-
* @returns {boolean} True if in CI
|
|
198
|
-
*/
|
|
199
|
-
function isCI() {
|
|
200
|
-
return !!(
|
|
201
|
-
process.env.CI ||
|
|
202
|
-
process.env.CONTINUOUS_INTEGRATION ||
|
|
203
|
-
process.env.GITHUB_ACTIONS ||
|
|
204
|
-
process.env.GITLAB_CI ||
|
|
205
|
-
process.env.CIRCLECI ||
|
|
206
|
-
process.env.TRAVIS ||
|
|
207
|
-
process.env.JENKINS_URL
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Get appropriate temp directory for downloads
|
|
213
|
-
* @returns {string} Temp directory path
|
|
214
|
-
*/
|
|
215
|
-
function getTempDir() {
|
|
216
|
-
return process.env.GLOCK_TEMP_DIR || os.tmpdir();
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
module.exports = {
|
|
220
|
-
getPlatformId,
|
|
221
|
-
isPlatformSupported,
|
|
222
|
-
getBinaryName,
|
|
223
|
-
getDownloadUrl,
|
|
224
|
-
getInstallDir,
|
|
225
|
-
getBinaryPath,
|
|
226
|
-
getPlatformEnv,
|
|
227
|
-
detectLinuxDistro,
|
|
228
|
-
getSystemInfo,
|
|
229
|
-
validatePlatform,
|
|
230
|
-
isCI,
|
|
231
|
-
getTempDir,
|
|
232
|
-
SUPPORTED_PLATFORMS,
|
|
233
|
-
BINARY_NAMES,
|
|
234
|
-
};
|