yeknal 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.
- package/bin/yeknal.js +103 -0
- package/package.json +16 -0
package/bin/yeknal.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* yeknal CLI
|
|
5
|
+
* Fetches Markdown files from a GitHub repository to the current working directory.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require("fs");
|
|
9
|
+
const path = require("path");
|
|
10
|
+
const https = require("https");
|
|
11
|
+
const { exec } = require("child_process");
|
|
12
|
+
|
|
13
|
+
// ==========================================
|
|
14
|
+
// USER CONFIGURATION (UPDATE THESE VALUES)
|
|
15
|
+
// ==========================================
|
|
16
|
+
const GITHUB_USERNAME = "tryraisins"; // e.g., 'your-github-username'
|
|
17
|
+
const GITHUB_REPO = "MD_Files"; // e.g., 'your-repo-name'
|
|
18
|
+
const BRANCH = "main"; // e.g., 'main' or 'master'
|
|
19
|
+
// ==========================================
|
|
20
|
+
|
|
21
|
+
// Base URL for GitHub raw content
|
|
22
|
+
const BASE_URL = `https://raw.githubusercontent.com/${GITHUB_USERNAME}/${GITHUB_REPO}/${BRANCH}`;
|
|
23
|
+
|
|
24
|
+
// Map commands to specific file paths in the GitHub repository
|
|
25
|
+
const configs = {
|
|
26
|
+
security: {
|
|
27
|
+
remotePath: "Security/Security-Master.md", // Path in your repo
|
|
28
|
+
localName: "Security-Master.md", // Name saved locally
|
|
29
|
+
},
|
|
30
|
+
design: {
|
|
31
|
+
remotePath: "Design/SKILL.md",
|
|
32
|
+
localName: "Design.md",
|
|
33
|
+
},
|
|
34
|
+
seo: {
|
|
35
|
+
remotePath: "SEO/seo-improvement-prompt.md",
|
|
36
|
+
localName: "SEO-Prompt.md",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const args = process.argv.slice(2);
|
|
41
|
+
const category = args[0] ? args[0].toLowerCase() : null;
|
|
42
|
+
|
|
43
|
+
if (!category || !configs[category]) {
|
|
44
|
+
console.error("ā Error: Invalid or missing category.");
|
|
45
|
+
console.log("\nUsage:");
|
|
46
|
+
console.log(" npx yeknal security");
|
|
47
|
+
console.log(" npx yeknal design");
|
|
48
|
+
console.log(" npx yeknal seo\n");
|
|
49
|
+
process.exit(1);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const config = configs[category];
|
|
53
|
+
const fileUrl = `${BASE_URL}/${config.remotePath}`;
|
|
54
|
+
const localDest = path.join(process.cwd(), config.localName);
|
|
55
|
+
|
|
56
|
+
console.log(`\nā³ Fetching ${category} guidelines...`);
|
|
57
|
+
|
|
58
|
+
https
|
|
59
|
+
.get(fileUrl, (res) => {
|
|
60
|
+
if (res.statusCode !== 200) {
|
|
61
|
+
console.error(
|
|
62
|
+
`\nā Failed to download file. (HTTP Status: ${res.statusCode})`,
|
|
63
|
+
);
|
|
64
|
+
console.error(`Please verify that the file exists at:\nš ${fileUrl}\n`);
|
|
65
|
+
console.error(
|
|
66
|
+
`If the repository is private, this script needs a Personal Access Token.`,
|
|
67
|
+
);
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const fileStream = fs.createWriteStream(localDest);
|
|
72
|
+
res.pipe(fileStream);
|
|
73
|
+
|
|
74
|
+
fileStream.on("finish", () => {
|
|
75
|
+
fileStream.close();
|
|
76
|
+
console.log(`ā
Successfully saved to: ${localDest}\n`);
|
|
77
|
+
|
|
78
|
+
if (category === "security") {
|
|
79
|
+
console.log(`š Running security audit (this may take a moment)...`);
|
|
80
|
+
exec("npx secure-repo audit", (error, stdout, stderr) => {
|
|
81
|
+
const logPath = path.join(process.cwd(), "security-audit.log");
|
|
82
|
+
const output = `--- Security Audit Log ---\nDate: ${new Date().toISOString()}\n\n${stdout}\n${stderr ? "Errors/Warnings:\n" + stderr : ""}`;
|
|
83
|
+
|
|
84
|
+
fs.writeFileSync(logPath, output);
|
|
85
|
+
|
|
86
|
+
if (error) {
|
|
87
|
+
console.log(
|
|
88
|
+
`ā ļø Security audit found issues (or returned an error code).`,
|
|
89
|
+
);
|
|
90
|
+
console.log(`š See ${logPath} for details.\n`);
|
|
91
|
+
} else {
|
|
92
|
+
console.log(
|
|
93
|
+
`ā
Security audit clean. Results saved to: ${logPath}\n`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
})
|
|
100
|
+
.on("error", (err) => {
|
|
101
|
+
console.error("\nā Network error fetching file:", err.message);
|
|
102
|
+
process.exit(1);
|
|
103
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "yeknal",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "CLI to fetch MD templates for security, design, and seo",
|
|
5
|
+
"main": "bin/yeknal.js",
|
|
6
|
+
"bin": {
|
|
7
|
+
"yeknal": "./bin/yeknal.js"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"cli",
|
|
11
|
+
"markdown",
|
|
12
|
+
"templates"
|
|
13
|
+
],
|
|
14
|
+
"author": "nubiaville",
|
|
15
|
+
"license": "ISC"
|
|
16
|
+
}
|