lumpiajs 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 (2) hide show
  1. package/index.js +105 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ // --- KAMUS BAHASA SEMARANG (LumpiaJS) ---
6
+ const dictionary = [
7
+ // Struktur
8
+ { asal: /<lump>/g, jadi: '' },
9
+ { asal: /<\/lump>/g, jadi: '' },
10
+
11
+ // Variabel
12
+ { asal: /ono\s/g, jadi: 'let ' },
13
+ { asal: /paten\s/g, jadi: 'const ' },
14
+
15
+ // Logic
16
+ { asal: /gawe\s/g, jadi: 'function ' },
17
+ { asal: /yen\s/g, jadi: 'if ' },
18
+ { asal: /liyane/g, jadi: 'else' },
19
+ { asal: /mandek;/g, jadi: 'return;' },
20
+
21
+ // Operator
22
+ { asal: /ora\s/g, jadi: '!' },
23
+ { asal: /panjang\(/g, jadi: 'len(' },
24
+ ];
25
+
26
+ // Script Bantuan (Runtime)
27
+ const runtimeScript = `
28
+ <script>
29
+ function ambil(sel) { return document.querySelector(sel).value; }
30
+ function tampil(txt) {
31
+ let el = document.getElementById('output-lumpia');
32
+ if(el) el.innerText = txt;
33
+ else alert(txt);
34
+ }
35
+ function len(x) { return x.length; }
36
+ </script>
37
+ `;
38
+
39
+ async function main() {
40
+ const args = process.argv.slice(2);
41
+ const perintah = args[0];
42
+
43
+ // Perintah: lumpia goreng
44
+ if (perintah === 'goreng') {
45
+ console.log('🍳 Sik, lagi nggoreng kodingan...');
46
+
47
+ const srcDir = './src';
48
+ const distDir = './dist';
49
+
50
+ // Cek folder src
51
+ if (!fs.existsSync(srcDir)) {
52
+ console.log('❌ Waduh, folder "src" ora ono! Gaweo sek.');
53
+ return;
54
+ }
55
+
56
+ // Bikin folder dist kalo belum ada
57
+ if (!fs.existsSync(distDir)) fs.mkdirSync(distDir);
58
+
59
+ // Baca file .lmp
60
+ const files = fs.readdirSync(srcDir).filter(file => file.endsWith('.lmp'));
61
+
62
+ if (files.length === 0) {
63
+ console.log('⚠️ Gak ono file .lmp nang folder src.');
64
+ return;
65
+ }
66
+
67
+ files.forEach(file => {
68
+ let content = fs.readFileSync(path.join(srcDir, file), 'utf-8');
69
+
70
+ // Pisah Kulit & Isi
71
+ const matchKulit = content.match(/<kulit>([\s\S]*?)<\/kulit>/);
72
+ const matchIsi = content.match(/<isi>([\s\S]*?)<\/isi>/);
73
+
74
+ let htmlnya = matchKulit ? matchKulit[1] : '';
75
+ let logicnya = matchIsi ? matchIsi[1] : '';
76
+
77
+ // Translate Logic
78
+ dictionary.forEach(kata => {
79
+ logicnya = logicnya.replace(kata.asal, kata.jadi);
80
+ });
81
+
82
+ // Gabung jadi HTML
83
+ const hasil = `<!DOCTYPE html>
84
+ <html>
85
+ <head><title>Lumpia App</title></head>
86
+ <body style="font-family:sans-serif; padding:20px;">
87
+ ${htmlnya}
88
+ <div id="output-lumpia" style="margin-top:20px; font-weight:bold;"></div>
89
+ ${runtimeScript}
90
+ <script>${logicnya}</script>
91
+ </body>
92
+ </html>`;
93
+
94
+ // Simpan
95
+ const namaFileBaru = file.replace('.lmp', '.html');
96
+ fs.writeFileSync(path.join(distDir, namaFileBaru), hasil);
97
+ console.log(`✅ Mateng: dist/${namaFileBaru}`);
98
+ });
99
+
100
+ } else {
101
+ console.log('Gunakno perintah: lumpia goreng');
102
+ }
103
+ }
104
+
105
+ main();
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "lumpiajs",
3
+ "version": "1.0.0",
4
+ "description": "Bahasa Pemrograman Semarangan",
5
+ "type": "module",
6
+ "bin": {
7
+ "lumpia": "./index.js"
8
+ },
9
+ "dependencies": {
10
+ "fs-extra": "^11.1.1"
11
+ }
12
+ }