Skip to content

Commit 1b4a1c2

Browse files
committed
Added Skill Files and dependency updates
1 parent 6181c29 commit 1b4a1c2

18 files changed

Lines changed: 743 additions & 291 deletions

File tree

.cursor/rules/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Cursor rules
2+
3+
Context-aware guidance for developing `@contentstack/cli-cm-regex-validate` (Contentstack CLI oclif plugin).
4+
5+
## Rules overview
6+
7+
| File | Scope |
8+
|------|--------|
9+
| `dev-workflow.md` | Core workflow, validation commands, links to skills (always applied) |
10+
| `typescript.mdc` | TypeScript and ESLint conventions |
11+
| `testing.mdc` | Jest + ts-jest tests |
12+
| `oclif-commands.mdc` | Command classes under `src/commands/` |
13+
| `contentstack-cli.mdc` | Utilities under `src/utils/` (SDK, safe-regex, output) |
14+
15+
## How rules apply
16+
17+
- `dev-workflow.md` uses `alwaysApply: true` and broad globs so it loads for most edits.
18+
- `.mdc` rules load when you work in matching paths (see each file’s `globs`).
19+
20+
## Manual references in chat
21+
22+
You can mention rules by context, for example: TypeScript guidance when editing `src/**/*.ts`, testing patterns when editing `**/*.test.ts`.

.cursor/rules/contentstack-cli.mdc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
description: "Contentstack Management SDK and regex-validation utilities"
3+
globs: ["**/utils/*.ts"]
4+
alwaysApply: false
5+
---
6+
7+
# Contentstack CLI utilities (this plugin)
8+
9+
## Management client
10+
11+
- Create client with `contentstackSdk.client` and `ContentstackConfig` (`host` from command `cmaHost`).
12+
- Optional `early_access` from `configHandler.get('earlyAccessHeaders')` when configured.
13+
- Obtain stack with `api_key` and `management_token` from token details.
14+
15+
## Stack processing
16+
17+
- Query content types and/or global fields with `.query({}).find()` (see `process-stack.ts`).
18+
- Use `cli.action.start` / `cli.action.stop` from `cli-ux` for timed progress messages.
19+
20+
## Regex validation
21+
22+
- Walk schema recursively in `safe-regex.ts`: handle `group`, `global_field`, `blocks`, and nested `schema` arrays.
23+
- Evaluate `format` fields with the `safe-regex` package; collect invalid patterns into rows for CSV and summary table.
24+
25+
## Output
26+
27+
- Write CSV with `jsonexport`; render summary table with `cli-table3`; print via `cliux` / `sanitizePath` from `@contentstack/cli-utilities` for paths.
28+
- Default results directory is resolved relative to compiled output; optional `-f` / `--filePath` overrides the directory.
29+
30+
## Security
31+
32+
- Never log management tokens or API keys. Errors should use messages from `messages/index.json`.

.cursor/rules/dev-workflow.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
description: "Core development workflow for cli-cm-regex-validate - always applied"
3+
globs: ["**/*.ts", "**/*.js", "**/*.json"]
4+
alwaysApply: true
5+
---
6+
7+
# Development workflow
8+
9+
## Quick reference
10+
11+
Detailed patterns live in project skills:
12+
13+
- `@skills/testing` — Jest tests, mocks, fixtures under `test/data/`
14+
- `@skills/contentstack-cli` — Command flow, Management SDK, `safe-regex`, CSV output
15+
- `@skills/code-review` — PR and release checklist
16+
17+
## Validation commands
18+
19+
- `npm test` — Jest (`jest.config.ts`, ts-jest). This is the canonical test runner; CI uses it in `.github/workflows/unit-tests.yml`.
20+
- `npm run posttest` — ESLint on `.ts` files (same as running eslint after tests).
21+
22+
## Local hooks
23+
24+
If Husky is installed, pre-commit may run Talisman (secrets) and Snyk. Use `SKIP_HOOK=1` only when you understand the bypass.
25+
26+
## TDD (recommended)
27+
28+
1. **Red** — Add or change a failing test in `test/utils/` (or add a fixture in `test/data/`).
29+
2. **Green** — Minimal change in `src/` to pass.
30+
3. **Refactor** — Keep tests green; avoid drive-by refactors outside the task.
31+
32+
## Repository layout
33+
34+
- `src/commands/` — oclif commands (this plugin: `cm/stacks/validate-regex`)
35+
- `src/utils/` — Shared logic (connect stack, process stack, safe-regex, output, prompts)
36+
- `messages/index.json` — User-facing strings for the command
37+
- `test/utils/` — Jest suites mirroring utils
38+
- `test/data/` — JSON fixtures for schema and expected outputs
39+
40+
## Before merging
41+
42+
- Tests pass (`npm test`).
43+
- Lint clean (`npm run posttest` or eslint as configured in `package.json`).

.cursor/rules/oclif-commands.mdc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
description: "oclif command patterns for Contentstack CLI plugin commands"
3+
globs: ["**/commands/**/*.ts"]
4+
alwaysApply: false
5+
---
6+
7+
# OCLIF command standards
8+
9+
## Base class
10+
11+
- Commands extend `Command` from `@contentstack/cli-command` (see `src/commands/cm/stacks/validate-regex.ts`).
12+
13+
## Flags
14+
15+
- Build flags with `flags` from `@contentstack/cli-utilities` (e.g. `flags.string`, `flags.boolean`, `flags.help`).
16+
- Keep descriptions aligned with `messages/index.json` under `validateRegex.command` where applicable.
17+
18+
## Run flow
19+
20+
1. `await this.parse(CommandClass)` to get flags.
21+
2. Prompt for missing alias or module selection via `src/utils/interactive.ts` when needed.
22+
3. Resolve token with `this.getToken(alias)`; handle failure with `this.error(..., { ref: ... })` using message keys from `messages/index.json`.
23+
4. Delegate stack work to `src/utils/connect-stack.ts` (and downstream utils).
24+
25+
## User messages
26+
27+
- Centralize copy in `messages/index.json`; avoid hard-coded user strings in the command except where unavoidable.
28+
29+
## Examples
30+
31+
- Maintain `static examples` with realistic `csdx cm:stacks:validate-regex` invocations.

.cursor/rules/testing.mdc

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
description: "Jest and ts-jest testing patterns for cli-cm-regex-validate"
3+
globs: ["**/*.test.ts", "**/__tests__/**/*.ts"]
4+
alwaysApply: false
5+
---
6+
7+
# Testing standards
8+
9+
## Runner
10+
11+
- **Jest** with **ts-jest** (`jest.config.ts`). Do not document Mocha/Chai/Sinon as the primary stack for this repository.
12+
13+
## Conventions
14+
15+
- Test files live under `test/utils/` and mirror `src/utils/` where applicable.
16+
- Use `describe` / `test` (or `it`) with clear behavior-focused names.
17+
- Prefer `beforeEach(() => jest.restoreAllMocks())` or `jest.clearAllMocks()` when tests share mocks.
18+
19+
## Mocking
20+
21+
- Mock external I/O: `@contentstack/management`, `fs`, `cli-ux`, `@contentstack/cli-utilities` as needed.
22+
- Use `jest.spyOn` for targeted spies; `jest.mock` for module substitution.
23+
- Do not call real Contentstack APIs in unit tests.
24+
25+
## Assertions
26+
27+
- Prefer `toHaveBeenCalled` / `toHaveBeenCalledWith` over deprecated Jest matchers.
28+
- Use fixture JSON from `test/data/` via `require` for documents and expected invalid-regex output.
29+
30+
## Fixtures
31+
32+
- Keep schema samples and expected arrays in `test/data/*.json` to avoid huge inline objects in tests.

.cursor/rules/typescript.mdc

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
description: "TypeScript and ESLint conventions for cli-cm-regex-validate"
3+
globs: ["**/*.ts", "**/*.tsx"]
4+
alwaysApply: false
5+
---
6+
7+
# TypeScript standards
8+
9+
## Compiler
10+
11+
- Project uses `strict: true` in `tsconfig.json` (root `src/` only for emit).
12+
- Prefer explicit types on public functions and command flags over untyped `any` where practical.
13+
14+
## ESLint (`.eslintrc`)
15+
16+
- Extends `eslint-config-oclif` and `eslint-config-oclif-typescript`.
17+
- Single quotes; no semicolons; `object-curly-spacing: never`.
18+
- `require()` for JSON such as `messages/index.json` is allowed (`@typescript-eslint/no-require-imports` is off).
19+
20+
## Imports
21+
22+
- ES modules for TypeScript sources; `require` is acceptable for JSON message bundles and legacy interop per eslint rules.
23+
24+
## Naming
25+
26+
- Files: kebab-case (e.g. `connect-stack.ts`, `validate-regex.ts`).
27+
- Classes: PascalCase. Functions and variables: camelCase.
28+
29+
## Error handling
30+
31+
- Surface user-facing errors via `this.error()` in commands or localized strings from `messages/index.json` in utilities.

.cursor/skills/SKILL.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Project skills
2+
3+
Authoritative skill packages for this repository live under **`skills/`** at the repo root.
4+
5+
- `skills/README.md` — index and quick reference
6+
- `skills/testing/` — Jest patterns and references
7+
- `skills/contentstack-cli/` — command and SDK patterns for regex validation
8+
- `skills/code-review/` — PR review checklist
9+
10+
Use `@skills/<name>` in Cursor or other agents to point at these folders.

.talismanrc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
fileignoreconfig:
2-
- filename: package-lock.json
3-
checksum: 98330174c261d1793f7e44c1889aea8c6bc1f6dfaa9a5cb4f58ad2c402f4db06
2+
- filename: package-lock.json
3+
checksum: 3f663322d950acc49b7e8899ca353456b1e7ac6277ac36fdfcac813644fb07d7
4+
- filename: .cursor/rules/dev-workflow.md
5+
checksum: 9912be426cb15077a67b81bd5801f2a65d367e30204d278c6814ebb1d74661ba
6+
- filename: skills/code-review/references/code-review-checklist.md
7+
checksum: 8bc8e53a9775258ddfadb40f9a6f415508d87aa9c70c95ebf748737e1ef7dbee
8+
- filename: skills/contentstack-cli/references/contentstack-patterns.md
9+
checksum: 3e3f445d01c67577dc91b1ba6ee27dcd1ffc1e907b2fbf33ce9b2905eaba239a
410
version: ""

AGENTS.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# cli-cm-regex-validate
2+
3+
`@contentstack/cli-cm-regex-validate` is a **Contentstack CLI** oclif plugin with a single command, **`csdx cm:stacks:validate-regex`**, which scans content types and/or global fields in a stack for regex `format` values that fail the `safe-regex` check, then writes results to CSV and prints a summary table. User-facing copy lives in `messages/index.json`.
4+
5+
## Layout
6+
7+
| Area | Path |
8+
|------|------|
9+
| Command | `src/commands/cm/stacks/validate-regex.ts` |
10+
| Utils | `src/utils/` (`connect-stack`, `process-stack`, `safe-regex`, `generate-output`, `interactive`) |
11+
| Messages | `messages/index.json` |
12+
| Tests | `test/utils/*.test.ts` |
13+
| Fixtures | `test/data/*.json` |
14+
15+
## Workflow
16+
17+
- Run **`npm test`** (Jest + ts-jest) before pushing; CI uses the same in `.github/workflows/unit-tests.yml`.
18+
- Run ESLint after tests via **`npm run posttest`** (or your team’s eslint invocation from `package.json`).
19+
20+
## Naming
21+
22+
- Source files: kebab-case.
23+
- Tests: describe behavior clearly (what should happen under which condition).
24+
25+
## Universal skills (any agent)
26+
27+
- `@skills/testing` — Jest mocks, fixtures, no live API calls
28+
- `@skills/contentstack-cli` — SDK flow, schema recursion, `safe-regex`, output
29+
- `@skills/code-review` — PR checklist (security, packaging, CI, messages)
30+
31+
## Cursor rules (IDE)
32+
33+
For file-scoped guidance, Cursor loads rules under `.cursor/rules/`. You can reference them in chat by intent, for example:
34+
35+
- TypeScript and ESLint conventions — `typescript.mdc`
36+
- Jest tests — `testing.mdc`
37+
- Command class — `oclif-commands.mdc`
38+
- Utils (SDK, safe-regex, output) — `contentstack-cli.mdc`
39+
- Dev workflow — `dev-workflow.md` (always applied)
40+
41+
See `.cursor/rules/README.md` for the full index.

0 commit comments

Comments
 (0)