@anhcodo13/lattice 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/cli.d.ts +8 -0
- package/dist/cli.js +1045 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +290 -0
- package/governance/policy.json +23 -0
- package/package.json +34 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 KhucHieuNghi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,71 @@
|
|
|
1
|
-
#
|
|
1
|
+
# NKLattice
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
NKLattice is an independent, local CLI for architecture analysis and dependency governance across Next.js, Vite + React, and React applications. It supports standalone repositories and npm or pnpm workspaces.
|
|
4
|
+
|
|
5
|
+
**Tiếng Việt:** NKLattice phân tích kiến trúc mã nguồn và kiểm tra phiên bản thư viện theo một policy chung cho nhiều ứng dụng Next.js, Vite và React. Xem [tài liệu tiếng Việt](https://khuchieunghi.github.io/nklattice/vi/docs/introduction/).
|
|
6
|
+
|
|
7
|
+
## Install the CLI
|
|
8
|
+
|
|
9
|
+
Requires Node.js 24 or newer. The npm package is `@anhcodo13/lattice`; the executable is `lattice`.
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
npm install --global @anhcodo13/lattice@0.1.0
|
|
13
|
+
lattice --version
|
|
14
|
+
lattice governance check path/to/app --expect-apps 1
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Build and try the source
|
|
18
|
+
|
|
19
|
+
The source checkout uses pnpm 10.30.3:
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
corepack enable
|
|
23
|
+
pnpm install --frozen-lockfile
|
|
24
|
+
pnpm verify
|
|
25
|
+
node dist/cli.js doctor examples/governance/apps/vite
|
|
26
|
+
node dist/cli.js analyze examples/governance/apps/vite
|
|
27
|
+
node dist/cli.js governance check examples/governance \
|
|
28
|
+
--workspace-root examples/governance \
|
|
29
|
+
--policy governance/policy.json --expect-apps 3
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
The analysis writes `report.html` and `analysis.json` into the app's `.nklattice-report/` directory. The HTML opens offline.
|
|
33
|
+
|
|
34
|
+
## Architecture analysis
|
|
35
|
+
|
|
36
|
+
NKLattice scans supported JS/TS and JSX/TSX files, resolves local imports, builds a module graph, and reports cycles, dependency concentration, long chains, duplicate imports, unused internal exports, component size, JSX depth, and approximate complexity. Define boundary policies and adjust thresholds or score weights in `.nklattice.json`.
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
node dist/cli.js init path/to/app
|
|
40
|
+
node dist/cli.js analyze path/to/app --output path/to/report
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The score is an explainable review aid, not a claim about runtime speed or correctness. See [findings](https://khuchieunghi.github.io/nklattice/docs/findings/) and [scoring](https://khuchieunghi.github.io/nklattice/docs/scoring/).
|
|
44
|
+
|
|
45
|
+
## Dependency governance
|
|
46
|
+
|
|
47
|
+
The versioned [central policy](governance/policy.json) requires exact versions. For each supported app, the CLI checks direct `package.json` declarations **and** matching npm/pnpm lockfile resolution. It returns exit `7` on drift and exit `3` for invalid input. The result lists the approved, declared, and locked versions.
|
|
48
|
+
|
|
49
|
+
Profiles are `next`, `vite-react`, and `react`. NKLattice can infer them from direct dependencies or read an explicit app profile:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{ "nklattice": { "profile": "next" } }
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
The [reusable governance workflow](.github/workflows/governance-check.yml) requires a reviewed 40-character `core-ref` and an `expected-apps` count. It checks out the CLI and policy from that commit, then fails if the number of managed apps differs. The [consumer workflow template](examples/consumer-workflow.yml) pins both the workflow `uses` ref and `core-ref` to the same SHA, with deployment depending on the governance job. Replace its placeholders and set `expected-apps` for each consuming repository. For a pnpm monorepo, pass its root as `--workspace-root` when running the CLI directly.
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
node dist/cli.js governance check ./my-app --policy ./governance/policy.json
|
|
59
|
+
node dist/cli.js governance check ./monorepo/apps \
|
|
60
|
+
--workspace-root ./monorepo --policy ./governance/policy.json --expect-apps 3 --json
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Website and documentation
|
|
64
|
+
|
|
65
|
+
- [English](https://khuchieunghi.github.io/nklattice/) · [Tiếng Việt](https://khuchieunghi.github.io/nklattice/vi/)
|
|
66
|
+
- [Documentation](https://khuchieunghi.github.io/nklattice/docs/introduction/) · [Tài liệu](https://khuchieunghi.github.io/nklattice/vi/docs/introduction/)
|
|
67
|
+
- [Strategy](STRATEGY.md) · [Roadmap](ROADMAP.md) · [Changelog](CHANGELOG.md)
|
|
68
|
+
|
|
69
|
+
Build the Astro/Starlight website with `pnpm --dir docs install --frozen-lockfile && pnpm --dir docs verify`.
|
|
70
|
+
|
|
71
|
+
NKLattice is released under the [MIT License](LICENSE).
|