@cuzfrog/pi-module-gates 0.10.0 → 0.12.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/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# pi-module-gates - Constraints liberate, liberties constrain.
|
|
2
2
|
|
|
3
|
-
pi cli extension that controls the entropy of the codebase by enforcing code module boundaries.
|
|
3
|
+
Expirimental pi cli extension that controls the entropy of the codebase by enforcing code module boundaries.
|
|
4
4
|
It helps combat slop generation and code architecture degradation.
|
|
5
5
|
|
|
6
6
|
## Problem
|
|
@@ -108,11 +108,11 @@ A `MODULE.md` semantically gates exposures at the module level it resides.
|
|
|
108
108
|
|
|
109
109
|
## Configuration
|
|
110
110
|
|
|
111
|
-
Add a `module-
|
|
111
|
+
Add a `module-gates` entry to `.pi/settings.json`:
|
|
112
112
|
|
|
113
113
|
```json
|
|
114
114
|
{
|
|
115
|
-
"module-
|
|
115
|
+
"module-gates": {
|
|
116
116
|
"moduleDescriptorFileName": "MODULE.md",
|
|
117
117
|
"moduleDescriptorReadonly": true,
|
|
118
118
|
"sourceRoot": "src/"
|
|
@@ -122,11 +122,11 @@ Add a `module-gate` entry to `.pi/settings.json`:
|
|
|
122
122
|
|
|
123
123
|
| Option | Default | Description |
|
|
124
124
|
|--------|---------|-------------|
|
|
125
|
-
| `moduleDescriptorFileName` | `
|
|
125
|
+
| `moduleDescriptorFileName` | `MODULE.md` | File name used for module descriptors (case-insensitive) |
|
|
126
126
|
| `moduleDescriptorReadonly` | `true` | When `true`, descriptor files are readonly.|
|
|
127
127
|
| `sourceRoot` | `"src/"` | Directory to scan for descriptor files and enforce gates. Set to `""` to scan from project root. |
|
|
128
128
|
|
|
129
|
-
When no settings file exists or no `module-
|
|
129
|
+
When no settings file exists or no `module-gates` key is present, defaults apply.
|
|
130
130
|
|
|
131
131
|
## License
|
|
132
132
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cuzfrog/pi-module-gates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "pi extension that controls the entropy of the codebase by enforcing code module boundaries.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"repository": {
|
|
31
31
|
"type": "git",
|
|
32
|
-
"url": "git+https://github.com/cuzfrog/pi-module-
|
|
32
|
+
"url": "git+https://github.com/cuzfrog/pi-module-gates.git"
|
|
33
33
|
},
|
|
34
34
|
"bugs": {
|
|
35
|
-
"url": "https://github.com/cuzfrog/pi-module-
|
|
35
|
+
"url": "https://github.com/cuzfrog/pi-module-gates/issues"
|
|
36
36
|
},
|
|
37
|
-
"homepage": "https://github.com/cuzfrog/pi-module-
|
|
37
|
+
"homepage": "https://github.com/cuzfrog/pi-module-gates#readme",
|
|
38
38
|
"license": "MIT",
|
|
39
39
|
"author": "Cause Chung (cuzfrog@gmail.com)",
|
|
40
40
|
"files": [
|
|
@@ -17,7 +17,7 @@ function main() {
|
|
|
17
17
|
root: { type: "string", default: "src" },
|
|
18
18
|
"dry-run": { type: "boolean", default: false },
|
|
19
19
|
create: { type: "boolean", default: false },
|
|
20
|
-
"descriptor-name": { type: "string", default: "
|
|
20
|
+
"descriptor-name": { type: "string", default: "MODULE.md" },
|
|
21
21
|
},
|
|
22
22
|
});
|
|
23
23
|
|
package/src/config.ts
CHANGED
|
@@ -19,8 +19,8 @@ export function loadConfig(cwd: string): ModuleGateConfig {
|
|
|
19
19
|
try {
|
|
20
20
|
const raw = fs.readFileSync(settingsPath, "utf-8");
|
|
21
21
|
const settings = JSON.parse(raw);
|
|
22
|
-
if (settings["module-
|
|
23
|
-
userConfig = settings["module-
|
|
22
|
+
if (settings["module-gates"] && typeof settings["module-gates"] === "object") {
|
|
23
|
+
userConfig = settings["module-gates"];
|
|
24
24
|
}
|
|
25
25
|
} catch {
|
|
26
26
|
// file doesn't exist or invalid — use defaults
|
|
@@ -13,7 +13,29 @@ const tsChecker: ExportChecker = {
|
|
|
13
13
|
registerChecker(tsChecker);
|
|
14
14
|
|
|
15
15
|
function extractExports(src: string): Signature[] {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
const results: Signature[] = [
|
|
17
|
+
...src.matchAll(
|
|
18
|
+
/^export\s+(?:default\s+)?(?:\w+\s+)*(?:function(?:\s*\*)?|class|const|let|var|type|interface|enum)\s+(\w+)/gm,
|
|
19
|
+
),
|
|
20
|
+
].map((m) => ({ name: m[1] }));
|
|
21
|
+
|
|
22
|
+
for (const m of src.matchAll(/^export\s*\{\s*([^}]+)\s*\}\s*from/gm)) {
|
|
23
|
+
const inner = m[1];
|
|
24
|
+
for (const entry of inner.split(",")) {
|
|
25
|
+
const trimmed = entry.trim();
|
|
26
|
+
if (!trimmed) continue;
|
|
27
|
+
const asMatch = trimmed.match(/^(\w+)\s+as\s+(\w+)$/);
|
|
28
|
+
if (asMatch) {
|
|
29
|
+
results.push({ name: asMatch[2] });
|
|
30
|
+
} else {
|
|
31
|
+
results.push({ name: trimmed });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
for (const m of src.matchAll(/^export\s*\*\s*as\s+(\w+)\s+from/gm)) {
|
|
37
|
+
results.push({ name: m[1] });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return results;
|
|
19
41
|
}
|