naider 1.17.0 → 1.17.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.
- package/bin/postinstall.js +132 -0
- package/package.json +3 -2
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { execSync } from 'child_process';
|
|
4
|
+
import { existsSync, writeFileSync, mkdirSync, readFileSync } from 'fs';
|
|
5
|
+
import { resolve, dirname, join } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
|
|
8
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
9
|
+
const __dirname = dirname(__filename);
|
|
10
|
+
|
|
11
|
+
const platform = process.platform;
|
|
12
|
+
const naideBin = resolve(__dirname, 'naide.js');
|
|
13
|
+
|
|
14
|
+
function run(cmd, opts = {}) {
|
|
15
|
+
try {
|
|
16
|
+
execSync(cmd, { stdio: 'pipe', ...opts });
|
|
17
|
+
return true;
|
|
18
|
+
} catch {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function registerWindows() {
|
|
24
|
+
const nodePath = process.execPath;
|
|
25
|
+
const npmGlobal = resolve(dirname(nodePath), 'node_modules', 'naider', 'bin', 'naide.js');
|
|
26
|
+
const binPath = existsSync(npmGlobal) ? npmGlobal : naideBin;
|
|
27
|
+
|
|
28
|
+
const nodeEsc = nodePath.replace(/\\/g, '\\\\');
|
|
29
|
+
const binEsc = binPath.replace(/\\/g, '\\\\');
|
|
30
|
+
const cmd = `"${nodePath}" "${binPath}" "%1" %*`;
|
|
31
|
+
|
|
32
|
+
const regAdd = (key, value) => run(`reg add "${key}" /ve /d "${value}" /f`);
|
|
33
|
+
|
|
34
|
+
regAdd('HKCU\\Software\\Classes\\.naide', 'NAIDEFile');
|
|
35
|
+
regAdd('HKCU\\Software\\Classes\\.nx', 'NAIDEXFile');
|
|
36
|
+
regAdd('HKCU\\Software\\Classes\\NAIDEFile', 'NAIDE Source File');
|
|
37
|
+
regAdd('HKCU\\Software\\Classes\\NAIDEXFile', 'NAIDE-X Source File');
|
|
38
|
+
regAdd('HKCU\\Software\\Classes\\NAIDEFile\\shell\\open\\command', cmd);
|
|
39
|
+
regAdd('HKCU\\Software\\Classes\\NAIDEXFile\\shell\\open\\command', cmd);
|
|
40
|
+
|
|
41
|
+
run(`reg add "HKCU\\Software\\Classes\\NAIDEFile\\DefaultIcon" /ve /d "${nodeEsc},0" /f`);
|
|
42
|
+
run(`reg add "HKCU\\Software\\Classes\\NAIDEXFile\\DefaultIcon" /ve /d "${nodeEsc},0" /f`);
|
|
43
|
+
|
|
44
|
+
console.log(' .naide and .nx file associations registered (Windows)');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function registerMacOS() {
|
|
48
|
+
const plistDir = resolve(process.env.HOME, 'Library', 'LaunchAgents');
|
|
49
|
+
if (!existsSync(plistDir)) mkdirSync(plistDir, { recursive: true });
|
|
50
|
+
|
|
51
|
+
const handlerApp = resolve(process.env.HOME, '.naide', 'NAIDE.app');
|
|
52
|
+
const contentsDir = join(handlerApp, 'Contents');
|
|
53
|
+
const macosDir = join(contentsDir, 'MacOS');
|
|
54
|
+
|
|
55
|
+
mkdirSync(macosDir, { recursive: true });
|
|
56
|
+
|
|
57
|
+
writeFileSync(join(contentsDir, 'Info.plist'), `<?xml version="1.0" encoding="UTF-8"?>
|
|
58
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
59
|
+
<plist version="1.0">
|
|
60
|
+
<dict>
|
|
61
|
+
<key>CFBundleName</key><string>NAIDE</string>
|
|
62
|
+
<key>CFBundleIdentifier</key><string>com.naide.runner</string>
|
|
63
|
+
<key>CFBundleVersion</key><string>1.0</string>
|
|
64
|
+
<key>CFBundleExecutable</key><string>naide-run</string>
|
|
65
|
+
<key>CFBundleDocumentTypes</key>
|
|
66
|
+
<array>
|
|
67
|
+
<dict>
|
|
68
|
+
<key>CFBundleTypeExtensions</key><array><string>naide</string><string>nx</string></array>
|
|
69
|
+
<key>CFBundleTypeName</key><string>NAIDE Source</string>
|
|
70
|
+
<key>CFBundleTypeRole</key><string>Editor</string>
|
|
71
|
+
</dict>
|
|
72
|
+
</array>
|
|
73
|
+
</dict>
|
|
74
|
+
</plist>`);
|
|
75
|
+
|
|
76
|
+
writeFileSync(join(macosDir, 'naide-run'), `#!/bin/bash\nexec node "${naideBin}" "$@"\n`);
|
|
77
|
+
run(`chmod +x "${join(macosDir, 'naide-run')}"`);
|
|
78
|
+
|
|
79
|
+
run(`/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -f "${handlerApp}"`);
|
|
80
|
+
|
|
81
|
+
console.log(' .naide and .nx file associations registered (macOS)');
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function registerLinux() {
|
|
85
|
+
const mimeDir = resolve(process.env.HOME, '.local', 'share', 'mime', 'packages');
|
|
86
|
+
const appDir = resolve(process.env.HOME, '.local', 'share', 'applications');
|
|
87
|
+
mkdirSync(mimeDir, { recursive: true });
|
|
88
|
+
mkdirSync(appDir, { recursive: true });
|
|
89
|
+
|
|
90
|
+
writeFileSync(join(mimeDir, 'naide.xml'), `<?xml version="1.0" encoding="UTF-8"?>
|
|
91
|
+
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
|
92
|
+
<mime-type type="text/x-naide">
|
|
93
|
+
<comment>NAIDE Source File</comment>
|
|
94
|
+
<glob pattern="*.naide"/>
|
|
95
|
+
</mime-type>
|
|
96
|
+
<mime-type type="text/x-naidex">
|
|
97
|
+
<comment>NAIDE-X Source File</comment>
|
|
98
|
+
<glob pattern="*.nx"/>
|
|
99
|
+
</mime-type>
|
|
100
|
+
</mime-info>`);
|
|
101
|
+
|
|
102
|
+
writeFileSync(join(appDir, 'naide.desktop'), `[Desktop Entry]
|
|
103
|
+
Type=Application
|
|
104
|
+
Name=NAIDE
|
|
105
|
+
Exec=node "${naideBin}" %f
|
|
106
|
+
MimeType=text/x-naide;text/x-naidex;
|
|
107
|
+
Terminal=true
|
|
108
|
+
Categories=Development;
|
|
109
|
+
`);
|
|
110
|
+
|
|
111
|
+
run('update-mime-database ~/.local/share/mime');
|
|
112
|
+
run('xdg-mime default naide.desktop text/x-naide');
|
|
113
|
+
run('xdg-mime default naide.desktop text/x-naidex');
|
|
114
|
+
|
|
115
|
+
console.log(' .naide and .nx file associations registered (Linux)');
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
console.log('NAIDE: Registering file extensions...');
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
if (platform === 'win32') {
|
|
122
|
+
registerWindows();
|
|
123
|
+
} else if (platform === 'darwin') {
|
|
124
|
+
registerMacOS();
|
|
125
|
+
} else {
|
|
126
|
+
registerLinux();
|
|
127
|
+
}
|
|
128
|
+
} catch (e) {
|
|
129
|
+
console.log(` Skipped file association (${e.message}). You can still run: naide <file.naide>`);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
console.log('NAIDE: Installation complete! Run "naide --help" to get started.');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "naider",
|
|
3
|
-
"version": "1.17.
|
|
3
|
+
"version": "1.17.1",
|
|
4
4
|
"description": "NAIDE - Simpler than Python, compiles to 15 targets. AI-specialized language with 35+ built-in functions, syntax sugar (unless/until/repeat/swap/is/isnt), and 47 features. Targets: Node.js, Python, TypeScript, C, C++, Java, Go, Rust, PHP, Ruby, Kotlin, Swift, Dart, C#, Bun.",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "node --test test/test.js",
|
|
27
27
|
"example": "node bin/naide.js examples/hello.naide",
|
|
28
|
-
"example:x": "node bin/naide.js examples/hello.nx"
|
|
28
|
+
"example:x": "node bin/naide.js examples/hello.nx",
|
|
29
|
+
"postinstall": "node bin/postinstall.js"
|
|
29
30
|
},
|
|
30
31
|
"keywords": [
|
|
31
32
|
"ai",
|