heymark 1.1.1 → 1.1.3
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/LICENSE +21 -0
- package/README.ko.md +170 -0
- package/README.md +170 -189
- package/package.json +56 -57
- package/scripts/lib/config.js +110 -73
- package/scripts/lib/parser.js +125 -82
- package/scripts/lib/repo.js +97 -80
- package/scripts/sync.js +312 -239
- package/scripts/tools/antigravity.js +53 -41
- package/scripts/tools/claude.js +53 -42
- package/scripts/tools/codex.js +53 -41
- package/scripts/tools/copilot.js +65 -41
- package/scripts/tools/cursor.js +52 -41
package/scripts/lib/repo.js
CHANGED
|
@@ -1,80 +1,97 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
const { execSync } = require("child_process");
|
|
6
|
-
|
|
7
|
-
const CACHE_DIR_NAME = path.join(".heymark", "cache");
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { execSync } = require("child_process");
|
|
6
|
+
|
|
7
|
+
const CACHE_DIR_NAME = path.join(".heymark", "cache");
|
|
8
|
+
const DEFAULT_BRANCH = "main";
|
|
9
|
+
const GITHUB_REPO_PATTERN = /github\.com[:/]([^/]+\/[^/]+?)(?:\/|$)/;
|
|
10
|
+
const GENERIC_REPO_PATTERN = /([^/]+\/[^/]+?)(?:\/|$)/;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Convert repository URL to a stable cache directory name.
|
|
14
|
+
* https://github.com/org/repo -> org-repo
|
|
15
|
+
* git@github.com:org/repo.git -> org-repo
|
|
16
|
+
* @param {string} repoUrl
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
function sanitizeRepoName(repoUrl) {
|
|
20
|
+
let normalized = repoUrl.trim();
|
|
21
|
+
if (normalized.endsWith(".git")) {
|
|
22
|
+
normalized = normalized.slice(0, -4);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const match = normalized.match(GITHUB_REPO_PATTERN) || normalized.match(GENERIC_REPO_PATTERN);
|
|
26
|
+
if (match) {
|
|
27
|
+
return match[1].replace(/\//g, "-");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return normalized.replace(/[^a-zA-Z0-9._-]/g, "-") || "repo";
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function cloneRulesRepo(projectRoot, clonePath, branch, repoUrl) {
|
|
34
|
+
execSync(`git clone --depth 1 --branch "${branch}" "${repoUrl}" "${clonePath}"`, {
|
|
35
|
+
stdio: "inherit",
|
|
36
|
+
cwd: projectRoot,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function updateRulesRepo(clonePath, branch) {
|
|
41
|
+
execSync(`git fetch origin && git checkout --quiet . && git pull --quiet origin "${branch}"`, {
|
|
42
|
+
stdio: "pipe",
|
|
43
|
+
cwd: clonePath,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function resolveRulesDirectory(clonePath, rulesSourceDir) {
|
|
48
|
+
const rulesDir = rulesSourceDir ? path.join(clonePath, rulesSourceDir) : clonePath;
|
|
49
|
+
if (!fs.existsSync(rulesDir) || !fs.statSync(rulesDir).isDirectory()) {
|
|
50
|
+
console.error(`[Error] Rules directory not found in repo: ${rulesSourceDir || "(root)"}`);
|
|
51
|
+
process.exit(1);
|
|
52
|
+
}
|
|
53
|
+
return rulesDir;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Clone or update remote repository and return local rules directory.
|
|
58
|
+
* Private repositories require user git credentials (SSH key or token).
|
|
59
|
+
* @param {string} projectRoot
|
|
60
|
+
* @param {{ rulesSource: string, branch?: string, rulesSourceDir?: string }} config
|
|
61
|
+
* @returns {string}
|
|
62
|
+
*/
|
|
63
|
+
function getRulesDirFromRepo(projectRoot, config) {
|
|
64
|
+
const repoUrl = config.rulesSource;
|
|
65
|
+
const branch = config.branch || DEFAULT_BRANCH;
|
|
66
|
+
const rulesSourceDir = config.rulesSourceDir || "";
|
|
67
|
+
|
|
68
|
+
const cacheBase = path.join(projectRoot, CACHE_DIR_NAME);
|
|
69
|
+
const repoName = sanitizeRepoName(repoUrl);
|
|
70
|
+
const clonePath = path.join(cacheBase, repoName);
|
|
71
|
+
|
|
72
|
+
if (!fs.existsSync(clonePath)) {
|
|
73
|
+
fs.mkdirSync(cacheBase, { recursive: true });
|
|
74
|
+
try {
|
|
75
|
+
cloneRulesRepo(projectRoot, clonePath, branch, repoUrl);
|
|
76
|
+
} catch {
|
|
77
|
+
console.error("[Error] Failed to clone rules repository.");
|
|
78
|
+
console.error(" For private repos, ensure you have access (SSH key or HTTPS token).");
|
|
79
|
+
console.error(" Example: heymark init https://github.com/org/repo.git");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
} else {
|
|
83
|
+
try {
|
|
84
|
+
updateRulesRepo(clonePath, branch);
|
|
85
|
+
} catch {
|
|
86
|
+
// Continue with cached clone when fetch or pull fails.
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return resolveRulesDirectory(clonePath, rulesSourceDir);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
module.exports = {
|
|
94
|
+
CACHE_DIR_NAME,
|
|
95
|
+
getRulesDirFromRepo,
|
|
96
|
+
sanitizeRepoName,
|
|
97
|
+
};
|