starlight-cli 1.0.0

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 +18 -0
  2. package/install.js +58 -0
  3. package/package.json +14 -0
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env node
2
+
3
+ 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
+
15
+ spawn(exePath, process.argv.slice(2), {
16
+ stdio: 'inherit',
17
+ windowsHide: false
18
+ });
package/install.js ADDED
@@ -0,0 +1,58 @@
1
+ const https = require('https');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const { execSync } = require('child_process');
5
+
6
+ const INSTALL_DIR = 'C:\\Starlight';
7
+ const EXE_PATH = path.join(INSTALL_DIR, 'starlight.exe');
8
+ const EXE_URL = 'https://github.com/developerdominex/dominexmacedon/releases/download/programming/starlight.exe';
9
+
10
+ function addToPath(dir) {
11
+ try {
12
+ const currentPath = execSync(
13
+ 'powershell -Command "[Environment]::GetEnvironmentVariable(\'Path\', \'User\')"',
14
+ { encoding: 'utf8' }
15
+ ).trim();
16
+
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
+ }
28
+
29
+ if (!fs.existsSync(INSTALL_DIR)) {
30
+ fs.mkdirSync(INSTALL_DIR, { recursive: true });
31
+ }
32
+
33
+ if (fs.existsSync(EXE_PATH)) {
34
+ console.log('Starlight already installed.');
35
+ addToPath(INSTALL_DIR);
36
+ process.exit(0);
37
+ }
38
+
39
+ console.log('Downloading Starlight...');
40
+
41
+ https.get(EXE_URL, res => {
42
+ if (res.statusCode !== 200) {
43
+ console.error('Failed to download Starlight.');
44
+ process.exit(1);
45
+ }
46
+
47
+ const file = fs.createWriteStream(EXE_PATH);
48
+ res.pipe(file);
49
+
50
+ file.on('finish', () => {
51
+ file.close();
52
+ console.log('Starlight installed to C:\\Starlight');
53
+ addToPath(INSTALL_DIR);
54
+ });
55
+ }).on('error', err => {
56
+ console.error('Download error:', err.message);
57
+ process.exit(1);
58
+ });
package/package.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "name": "starlight-cli",
3
+ "version": "1.0.0",
4
+ "description": "Starlight Programming Language CLI",
5
+ "bin": {
6
+ "starlight": "index.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "author": "Macedon",
12
+ "license": "MIT",
13
+ "os": ["win32"]
14
+ }