haraps 1.0.9 → 1.0.11
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/index.js +50 -7
- package/package.json +7 -2
package/bin/index.js
CHANGED
|
@@ -13,11 +13,54 @@ function ensureDir(dir) {
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
function writeFile(filePath, content) {
|
|
16
|
+
function writeFile(filePath, content, checkIfExists = false) {
|
|
17
17
|
const fullPath = path.resolve(process.cwd(), filePath);
|
|
18
|
+
const newContent = content.trim() + '\n';
|
|
19
|
+
|
|
20
|
+
if (checkIfExists && fs.existsSync(fullPath)) {
|
|
21
|
+
const oldContent = fs.readFileSync(fullPath, 'utf8');
|
|
22
|
+
if (oldContent === newContent) {
|
|
23
|
+
console.log(`⏭️ Skipped: ${filePath} (identical content)`);
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
console.log(`\n⚠️ File ${filePath} already exists and differs from the scaffolded version.`);
|
|
28
|
+
|
|
29
|
+
try {
|
|
30
|
+
const diff = require('diff');
|
|
31
|
+
const clc = require('cli-color');
|
|
32
|
+
const changes = diff.diffLines(oldContent, newContent);
|
|
33
|
+
|
|
34
|
+
console.log('\n--- Diff (Green: additions, Red: deletions) ---');
|
|
35
|
+
changes.forEach((part) => {
|
|
36
|
+
const color = part.added ? clc.green : part.removed ? clc.red : clc.blackBright;
|
|
37
|
+
const prefix = part.added ? '+ ' : part.removed ? '- ' : ' ';
|
|
38
|
+
const lines = part.value.split('\n');
|
|
39
|
+
if (lines[lines.length - 1] === '') lines.pop();
|
|
40
|
+
lines.forEach(l => console.log(color(prefix + l)));
|
|
41
|
+
});
|
|
42
|
+
console.log('-----------------------------------------------\n');
|
|
43
|
+
} catch (e) {
|
|
44
|
+
console.log("(Diff skipped, required packages missing)");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let answer = 'n';
|
|
48
|
+
try {
|
|
49
|
+
const readlineSync = require('readline-sync');
|
|
50
|
+
answer = readlineSync.question(`Do you want to overwrite ${filePath}? [y/N]: `);
|
|
51
|
+
} catch (e) {
|
|
52
|
+
answer = 'n';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (answer.toLowerCase() !== 'y') {
|
|
56
|
+
console.log(`⏭️ Skipped: ${filePath} (user chose to keep existing)`);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
18
61
|
ensureDir(path.dirname(fullPath));
|
|
19
|
-
fs.writeFileSync(fullPath,
|
|
20
|
-
console.log(`✅ Created: ${filePath}`);
|
|
62
|
+
fs.writeFileSync(fullPath, newContent, 'utf8');
|
|
63
|
+
console.log(`✅ Created/Updated: ${filePath}`);
|
|
21
64
|
}
|
|
22
65
|
|
|
23
66
|
// 1. Dev Scripts
|
|
@@ -382,7 +425,7 @@ EOF
|
|
|
382
425
|
|
|
383
426
|
node "$runnerPath"
|
|
384
427
|
|
|
385
|
-
|
|
428
|
+
`, true);
|
|
386
429
|
fs.chmodSync(path.resolve(process.cwd(), 'dev.sh'), '755');
|
|
387
430
|
|
|
388
431
|
writeFile('dev.ps1', `
|
|
@@ -796,7 +839,7 @@ if ($null -ne (Get-Variable -Name watcherJob -ErrorAction SilentlyContinue)) {
|
|
|
796
839
|
}
|
|
797
840
|
}
|
|
798
841
|
|
|
799
|
-
|
|
842
|
+
`, true);
|
|
800
843
|
|
|
801
844
|
// 2. Deploy Scripts
|
|
802
845
|
writeFile('deploy.sh', `
|
|
@@ -811,7 +854,7 @@ cd /mnt/c/Users/shivg/Desktop/Hara-XY/mediqueue-main/mediqueue/frontend
|
|
|
811
854
|
$env:WRANGLER_SEND_METRICS="false"
|
|
812
855
|
npx wrangler pages deploy .vercel/output/static
|
|
813
856
|
|
|
814
|
-
|
|
857
|
+
`, true);
|
|
815
858
|
fs.chmodSync(path.resolve(process.cwd(), 'deploy.sh'), '755');
|
|
816
859
|
|
|
817
860
|
writeFile('deploy.ps1', `
|
|
@@ -1230,7 +1273,7 @@ Write-Host "[CLIPBOARD] Full report copied to your clipboard!" -ForegroundColor
|
|
|
1230
1273
|
Write-Host ""
|
|
1231
1274
|
Write-Host ">>> Deployment localized and verified." -ForegroundColor Cyan
|
|
1232
1275
|
|
|
1233
|
-
|
|
1276
|
+
`, true);
|
|
1234
1277
|
|
|
1235
1278
|
// 3. Agent Rules
|
|
1236
1279
|
writeFile('AGENTS.md', `
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "haraps",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "NPM package to scaffold standard development environment, deployment scripts, AGENTS.md guidelines, and core workflows for a Next.js frontend + Rust Cloudflare Worker backend.",
|
|
5
5
|
"main": "bin/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -11,5 +11,10 @@
|
|
|
11
11
|
},
|
|
12
12
|
"keywords": [],
|
|
13
13
|
"author": "",
|
|
14
|
-
"license": "ISC"
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"cli-color": "^2.0.4",
|
|
17
|
+
"diff": "^9.0.0",
|
|
18
|
+
"readline-sync": "^1.4.10"
|
|
19
|
+
}
|
|
15
20
|
}
|