starlight-cli 1.0.0 → 1.0.1

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.
Files changed (3) hide show
  1. package/index.js +2 -13
  2. package/install.js +52 -43
  3. package/package.json +4 -2
package/index.js CHANGED
@@ -1,18 +1,7 @@
1
1
  #!/usr/bin/env node
2
-
3
2
  const { spawn } = require('child_process');
4
- const path = require('path');
5
- const fs = require('fs');
6
-
7
- const exePath = 'C:\\Starlight\\starlight.exe';
8
-
9
- if (!fs.existsSync(exePath)) {
10
- console.error('Starlight is not installed correctly.');
11
- console.error('Please reinstall: npm install -g starlight-cli');
12
- process.exit(1);
13
- }
14
3
 
15
- spawn(exePath, process.argv.slice(2), {
4
+ spawn('starlight.exe', process.argv.slice(2), {
16
5
  stdio: 'inherit',
17
- windowsHide: false
6
+ shell: true
18
7
  });
package/install.js CHANGED
@@ -3,56 +3,65 @@ const fs = require('fs');
3
3
  const path = require('path');
4
4
  const { execSync } = require('child_process');
5
5
 
6
- const INSTALL_DIR = 'C:\\Starlight';
6
+ const DOWNLOAD_URL =
7
+ 'https://github.com/developerdominex/dominexmacedon/releases/download/programming/starlight.exe';
8
+
9
+ const INSTALL_DIR = 'C:\\Starlight\\bin';
7
10
  const EXE_PATH = path.join(INSTALL_DIR, 'starlight.exe');
8
- const EXE_URL = 'https://github.com/developerdominex/dominexmacedon/releases/download/programming/starlight.exe';
9
11
 
10
- function addToPath(dir) {
11
- try {
12
- const currentPath = execSync(
13
- 'powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"',
14
- { encoding: 'utf8' }
15
- ).trim();
12
+ console.log('Downloading Starlight...');
16
13
 
17
- if (!currentPath.includes(dir)) {
18
- execSync(
19
- `powershell -Command "[Environment]::SetEnvironmentVariable('Path', '${currentPath};${dir}', 'User')"`
20
- );
21
- console.log('Added Starlight to PATH.');
22
- console.log('Restart your terminal to use it.');
23
- }
24
- } catch {
25
- console.warn('Could not modify PATH automatically.');
26
- }
27
- }
14
+ // Ensure install directory exists
15
+ fs.mkdirSync(INSTALL_DIR, { recursive: true });
28
16
 
29
- if (!fs.existsSync(INSTALL_DIR)) {
30
- fs.mkdirSync(INSTALL_DIR, { recursive: true });
31
- }
17
+ // Handle GitHub redirects properly
18
+ function download(url, dest) {
19
+ return new Promise((resolve, reject) => {
20
+ https.get(url, res => {
21
+ if (res.statusCode === 302 || res.statusCode === 301) {
22
+ return download(res.headers.location, dest)
23
+ .then(resolve)
24
+ .catch(reject);
25
+ }
32
26
 
33
- if (fs.existsSync(EXE_PATH)) {
34
- console.log('Starlight already installed.');
35
- addToPath(INSTALL_DIR);
36
- process.exit(0);
37
- }
27
+ if (res.statusCode !== 200) {
28
+ reject(new Error(`HTTP ${res.statusCode}`));
29
+ return;
30
+ }
38
31
 
39
- console.log('Downloading Starlight...');
32
+ const file = fs.createWriteStream(dest);
33
+ res.pipe(file);
40
34
 
41
- https.get(EXE_URL, res => {
42
- if (res.statusCode !== 200) {
43
- console.error('Failed to download Starlight.');
44
- process.exit(1);
45
- }
35
+ file.on('finish', () => {
36
+ file.close(resolve);
37
+ });
46
38
 
47
- const file = fs.createWriteStream(EXE_PATH);
48
- res.pipe(file);
39
+ file.on('error', err => {
40
+ fs.unlinkSync(dest);
41
+ reject(err);
42
+ });
43
+ }).on('error', reject);
44
+ });
45
+ }
49
46
 
50
- file.on('finish', () => {
51
- file.close();
52
- console.log('Starlight installed to C:\\Starlight');
53
- addToPath(INSTALL_DIR);
47
+ download(DOWNLOAD_URL, EXE_PATH)
48
+ .then(() => {
49
+ console.log('Downloaded to:', EXE_PATH);
50
+
51
+ // Add to PATH (Windows)
52
+ try {
53
+ execSync(
54
+ `setx PATH "%PATH%;${INSTALL_DIR}"`,
55
+ { stdio: 'ignore' }
56
+ );
57
+ console.log('Added Starlight to PATH');
58
+ } catch {
59
+ console.log('PATH update skipped (may already exist)');
60
+ }
61
+
62
+ console.log('Starlight installed successfully');
63
+ })
64
+ .catch(err => {
65
+ console.error('Download error:', err.message);
66
+ process.exit(1);
54
67
  });
55
- }).on('error', err => {
56
- console.error('Download error:', err.message);
57
- process.exit(1);
58
- });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Starlight Programming Language CLI",
5
5
  "bin": {
6
6
  "starlight": "index.js"
@@ -10,5 +10,7 @@
10
10
  },
11
11
  "author": "Macedon",
12
12
  "license": "MIT",
13
- "os": ["win32"]
13
+ "os": [
14
+ "win32"
15
+ ]
14
16
  }