SKILL.md
TypeScript CLI tsgen skill
Role of this repo
- Plugin for
csdx: implementsTypeScriptCodeGeneratorCommandin [src/commands/tsgen.ts](../../src/commands/tsgen.ts). - Generation is delegated to
@contentstack/types-generator(npm, GitHub)—version ^3.9.3 in [package.json](../../package.json). Do not assume a local clone; use npm and published source only.
Change here vs change in the library
| Concern | Where |
|---|---|
New flags, output path, csdx UX, printFormattedError |
This repo (src/commands/, src/lib/) |
| Schema mapping, Delivery SDK calls, GraphQL introspection | @contentstack/types-generator |
Helpers
- [
src/lib/helper.ts](../../src/lib/helper.ts):sanitizePath,printFormattedError(FormattedError,error_codeswitch). - [
src/types/index.ts](../../src/types/index.ts):StackConnectionConfigand related CLI types.
OCLIF
- Commands compile to
lib/commands;prepackrefreshesoclif.manifest.jsonand README.
Command shape (tsgen)
- Extends
Commandfrom@contentstack/cli-command([src/commands/tsgen.ts](../../src/commands/tsgen.ts)). - Flags include
token-alias(-a, required),output(-o),prefix,doc,branch,include-system-fields,include-editable-tags,include-referenced-entry,api-type(rest\|graphql),namespace(GraphQL). - Resolve token via
this.getToken(flags["token-alias"]); warn iftoken.type !== "delivery"(management token can break Delivery/GraphQL flows). - Build
StackConnectionConfig:apiKey,token,region,environment,branch,hostas in existing code. api-type === "graphql"→graphqlTS(...)with delivery token; REST →generateTSwithtokenType: "delivery"; write output withfs.writeFileSyncto the resolved path.- Use
printFormattedErrorfrom [src/lib/helper.ts](../../src/lib/helper.ts) for consistent CLI messaging.