Skip to content

Commit 2cd3ed4

Browse files
committed
Removed the references
1 parent c5d2ffc commit 2cd3ed4

File tree

8 files changed

+215
-234
lines changed

8 files changed

+215
-234
lines changed

skills/code-review/SKILL.md

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,65 @@ description: >-
1818

1919
Provide consistent **security**, **correctness**, and **maintainability** review for this repository. The plugin handles stack API keys in error messages, opens **HTML** diffs in a browser, and writes **diagram** files via Graphviz.
2020

21+
Use **Critical** / **Important** / **Suggestion** when leaving feedback.
22+
2123
### Highlights
2224

2325
- **Secrets**: Never approve logging of tokens, `authtoken` / `authorization` values, or raw management tokens.
2426
- **Compare / diagram**: Changes to [src/core/content-type/compare.ts](../../src/core/content-type/compare.ts) or [diagram.ts](../../src/core/content-type/diagram.ts) deserve extra scrutiny (temp files, browser open, paths, binary dependency).
2527
- **Dependencies**: axios, diff2html, git-diff, node-graphviz, tmp, cli-ux—review changelog and supply-chain for version bumps.
2628
- **Quality**: TypeScript and **eslint-config-oclif-typescript** ([.eslintrc](../../.eslintrc)); behavioral changes should include or update **Jest** tests where appropriate.
2729

28-
### Full checklist
30+
### Security and privacy
31+
32+
| Severity | Item |
33+
|----------|------|
34+
| Critical | No logging or serializing of **access tokens**, **management tokens**, or **Bearer** strings. |
35+
| Critical | No new `console.log` of full API responses that may contain secrets. |
36+
| Important | Stack API keys appear in user-facing errors only in line with [src/core/contentstack/client.ts](../../src/core/contentstack/client.ts) (`buildError` + optional key suffix). |
37+
38+
### Correctness
39+
40+
| Severity | Item |
41+
|----------|------|
42+
| Critical | Command flags and `setup(flags)` behavior remain consistent; **compare-remote** still resolves origin vs remote stacks correctly. |
43+
| Important | **Compare**: left/right version logic and warning when versions are equal; HTML output path and browser open behavior unchanged unless intentionally redesigned. |
44+
| Important | **Diagram**: output path validation; Graphviz / DOT paths; orientation and file type flags. |
45+
| Suggestion | Edge cases for empty audit logs, missing references, or single-version content types. |
46+
47+
### Compare and diagram (touching core)
48+
49+
| Severity | Item |
50+
|----------|------|
51+
| Critical | [compare.ts](../../src/core/content-type/compare.ts): temp HTML creation does not write sensitive data beyond the diff; file handling is safe on failure paths. |
52+
| Important | [diagram.ts](../../src/core/content-type/diagram.ts): `sanitizePath` / path usage; large stack models do not cause unbounded memory without consideration. |
53+
| Suggestion | User messaging when Graphviz is missing or SVG generation fails. |
54+
55+
### Dependencies
56+
57+
| Severity | Item |
58+
|----------|------|
59+
| Important | **axios**: security advisories; upgrade notes. |
60+
| Important | **diff2html**, **git-diff**, **tmp**, **cli-ux**: behavior changes affecting compare UX. |
61+
| Important | **node-graphviz**: compatibility with supported Node and system Graphviz. |
62+
| Suggestion | **moment** (if touched): prefer minimal churn; note maintenance status of dependencies. |
63+
64+
### Tests and tooling
65+
66+
| Severity | Item |
67+
|----------|------|
68+
| Important | New behavior in `src/core/` or `src/utils/` has **Jest** coverage or a clear reason why not. |
69+
| Important | `npm test` and **ESLint** (`posttest` / [`.eslintrc`](../../.eslintrc)) pass. |
70+
| Suggestion | Tests mock HTTP/SDK boundaries; no accidental live API calls. |
71+
72+
### Documentation
2973

30-
Use [references/checklist.md](references/checklist.md) for the printable severity-labeled checklist.
74+
| Severity | Item |
75+
|----------|------|
76+
| Important | If commands or flags change, **README** (generated via `oclif readme`) is updated via `prepack` / `version` workflow. |
77+
| Suggestion | User-facing strings and examples match `src/commands/content-type/*.ts` examples. |
3178

3279
## References
3380

34-
- [references/checklist.md](references/checklist.md)
3581
- [testing/SKILL.md](../testing/SKILL.md) — test and lint expectations.
3682
- [contentstack-cli-content-type/SKILL.md](../contentstack-cli-content-type/SKILL.md) — architecture and risky areas.

skills/code-review/references/checklist.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

skills/contentstack-cli-content-type/SKILL.md

Lines changed: 105 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,43 @@ npm package `contentstack-cli-content-type`: a **Contentstack CLI** (`csdx`) plu
3333
| Types | `src/types/index.ts` |
3434
| Config (pagination limits) | `src/config/index.ts` |
3535

36-
Commands **parse flags**, call **`setup(flags)`**, build **`managementSDKClient`**, then call utils + core builders. See [references/architecture.md](references/architecture.md) and [references/commands.md](references/commands.md).
36+
Commands **parse flags**, call **`setup(flags)`**, build **`managementSDKClient`**, then call utils + core builders.
37+
38+
### Command → core modules
39+
40+
| Command file | Core / utilities | Notes |
41+
|--------------|------------------|--------|
42+
| `src/commands/content-type/audit.ts` | `core/content-type/audit.ts`, `utils` (`getStack`, `getUsers`, `getContentType`), `client.getContentTypeAuditLogs` | Audit + users for display |
43+
| `src/commands/content-type/compare.ts` | `core/content-type/compare.ts`, `utils` | Same-stack two versions; optional `--left` / `--right` |
44+
| `src/commands/content-type/compare-remote.ts` | `core/content-type/compare.ts` (same `buildOutput`), `utils` | Two stacks; `setup` uses origin stack key only |
45+
| `src/commands/content-type/details.ts` | `core/content-type/details.ts`, `utils`, `client.getContentTypeReferences` | `--path` / `--no-path` |
46+
| `src/commands/content-type/diagram.ts` | `core/content-type/diagram.ts`, `utils` (`getStack`, `getContentTypes`, `getGlobalFields`) | Writes file via Graphviz |
47+
| `src/commands/content-type/list.ts` | `core/content-type/list.ts`, `utils` | `--order title|modified` |
48+
49+
Formatting helpers live under `src/core/content-type/formatting.ts` where imported by core modules.
50+
51+
### Auth flow (high level)
52+
53+
```mermaid
54+
flowchart LR
55+
subgraph setup [ContentTypeCommand.setup]
56+
A[getAuthDetails]
57+
B{accessToken?}
58+
C[error auth:login]
59+
D{alias or stack key?}
60+
E[exit 1 missing stack]
61+
F[getToken or use stack API key]
62+
G[ContentstackClient]
63+
end
64+
A --> B
65+
B -->|no| C
66+
B -->|yes| D
67+
D -->|neither| E
68+
D -->|ok| F
69+
F --> G
70+
```
71+
72+
- **`compare-remote`**: `setup` is called with `{ alias: undefined, stack: flags["origin-stack"] }` so `apiKey` is the **origin** stack API key; remote stack is passed only in `getStack` / `getContentType` calls.
3773

3874
### Authentication and stack identity
3975

@@ -46,9 +82,76 @@ Commands **parse flags**, call **`setup(flags)`**, build **`managementSDKClient`
4682

4783
### Two ways to call APIs
4884

49-
- **Axios `ContentstackClient`**: `GET https://{cmaHost}/v3/...` with default headers `authorization` (if Bearer) or `authtoken`, plus per-request `headers: { api_key }`. Used for audit logs and references. Errors → `ContentstackError` via `buildError`.
85+
- **Axios `ContentstackClient`**: `GET https://{cmaHost}/v3/...` with default headers `authorization` (if Bearer) or `authtoken`, plus per-request `headers: { api_key }`. Used for audit logs and CT references. Errors → `ContentstackError` via `buildError`.
5086
- **Management SDK** (`managementSDKClient({ host, 'X-CS-CLI': ... })`): stack fetch, content types, global fields, content type by version—see `src/utils/index.ts`.
5187

88+
**CMA request shape (`ContentstackClient`)**
89+
90+
- **Base URL**: `https://{cmaHost}/v3/` (`cmaHost` from command context).
91+
- **Default axios headers**: `authorization: <token>` if token string includes `Bearer`, else `authtoken: <token>`.
92+
- **Per-request**: `headers: { api_key: <stack API key> }` for stack-scoped routes.
93+
94+
| Method | HTTP | Path / params |
95+
|--------|------|----------------|
96+
| `getContentTypeAuditLogs` | GET | `/audit-logs``params.query.$and`: `module: content_type`, `metadata.uid` |
97+
| `getContentTypeReferences` | GET | `/content_types/{uid}/references``include_global_fields: true` |
98+
99+
Errors: response `data.errors``ContentstackError`; optional suffix with stack API key when `data.errors.api_key` and context `api_key` are set.
100+
101+
### Compare and diagram pipelines
102+
103+
- **Compare**: `core/content-type/compare.ts` builds a unified diff from two JSON snapshots (`git-diff`), parses with **diff2html**, writes a **temporary HTML** file, opens it in the browser (`cli-ux` / `cli.open`). Not a terminal table.
104+
- **Diagram**: `core/content-type/diagram.ts` builds a DOT graph, runs **node-graphviz** (`graphviz` binary must be available on the system for SVG rendering). Output path is sanitized where utilities apply.
105+
106+
### Commands (flags and behavior)
107+
108+
Primary sources: `README.md` and `src/commands/content-type/*.ts`.
109+
110+
#### `content-type:list`
111+
112+
- **Flags**: `--stack-api-key` (`-k`), `--stack` (deprecated → use stack key), `--token-alias` / `--alias` (`-a`), `--order` (`-o`) `title` \| `modified` (default `title`).
113+
- **Files**: `src/commands/content-type/list.ts`, `src/core/content-type/list.ts`.
114+
- **Behavior**: Lists Content Types for the stack; table output via core builder.
115+
116+
#### `content-type:details`
117+
118+
- **Flags**: stack identity flags as above; `--content-type` (`-c`) required; `--path` / `--no-path` (`-p`) — default shows path column; use `--no-path` on narrow terminals (README).
119+
- **Files**: `src/commands/content-type/details.ts`, `src/core/content-type/details.ts`.
120+
- **Behavior**: Fetches CT + **references** via `ContentstackClient.getContentTypeReferences`.
121+
122+
#### `content-type:audit`
123+
124+
- **Flags**: stack identity + `--content-type` (`-c`) required.
125+
- **Files**: `src/commands/content-type/audit.ts`, `src/core/content-type/audit.ts`.
126+
- **Behavior**: Audit logs via `getContentTypeAuditLogs`; README notes **audit log retention** (e.g. 90 days) per Contentstack docs.
127+
128+
#### `content-type:compare`
129+
130+
- **Flags**: stack identity + `--content-type` (`-c`); optional `--left` (`-l`) / `--right` (`-r`) **integers** (both required if either set). If omitted, command infers latest version vs previous from discovery fetch.
131+
- **Files**: `src/commands/content-type/compare.ts`, `src/core/content-type/compare.ts`.
132+
- **Behavior**: Side-by-side diff in **HTML** in a browser; not stdout-only. Warns if left === right.
133+
134+
#### `content-type:compare-remote`
135+
136+
- **Flags**: `--origin-stack` (`-o`) and `--remote-stack` (`-r`) **required** (stack API keys); `--content-type` (`-c`) required. No token-alias flow for two stacks—setup uses **origin** stack key for session.
137+
- **Files**: `src/commands/content-type/compare-remote.ts`, same `core/content-type/compare.ts` as same-stack compare.
138+
- **Behavior**: Same HTML diff pipeline; compares CT JSON from two stacks. Warns if origin === remote API key.
139+
140+
#### `content-type:diagram`
141+
142+
- **Flags**: stack identity; `--output` (`-o`) **required** (full path); `--direction` (`-d`) `portrait` \| `landscape` (required in schema, default portrait); `--type` (`-t`) `svg` \| `dot` (default svg).
143+
- **Files**: `src/commands/content-type/diagram.ts`, `src/core/content-type/diagram.ts`.
144+
- **Behavior**: Loads all content types + global fields; renders graph. **Graphviz** must be installed for typical SVG generation; DOT export available. README documents `-t dot` for raw DOT language.
145+
146+
### Editing checklist
147+
148+
| Change | Touch first |
149+
|--------|-------------|
150+
| New flag / description | Command file under `src/commands/content-type/`, then `oclif readme` |
151+
| Output format / table | `src/core/content-type/*.ts`, `formatting.ts` |
152+
| REST audit/references | `src/core/contentstack/client.ts`, `error.ts` |
153+
| SDK pagination / fetch | `src/utils/index.ts`, `src/config/index.ts` |
154+
52155
### Build and CLI metadata
53156

54157
`package.json` scripts **`prepack`** and **`version`** drive `tsc`, `oclif manifest`, and `oclif readme`. After changing commands, flags, or descriptions, keep **README.md** and **oclif.manifest.json** in sync—see [dev-workflow/SKILL.md](../dev-workflow/SKILL.md) for commands and workflow.
@@ -68,8 +171,6 @@ Commands **parse flags**, call **`setup(flags)`**, build **`managementSDKClient`
68171

69172
## References
70173

71-
- [references/architecture.md](references/architecture.md) — command → core mapping, auth flow, CMA shape.
72-
- [references/commands.md](references/commands.md) — flags, UX notes, files to edit per command.
73174
- [dev-workflow/SKILL.md](../dev-workflow/SKILL.md) — TypeScript build, ESLint, oclif docs, `npm run prepack`.
74175
- [testing/SKILL.md](../testing/SKILL.md) — Jest layout, mocks, coverage.
75176
- [Content Management API](https://www.contentstack.com/docs/developers/apis/content-management-api/) (external).

skills/contentstack-cli-content-type/references/architecture.md

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)