Skip to content

Commit 44cd5be

Browse files
committed
chore: added notes
1 parent 01fb61a commit 44cd5be

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

notes.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Setting up CLI :
2+
3+
1. Need node version 20+
4+
5+
```bash
6+
nvm use 20
7+
node -v
8+
```
9+
10+
2. Install the cli
11+
12+
```bash
13+
npm install -g @contentstack/cli
14+
```
15+
16+
3. Setup the region before CLI
17+
18+
```bash
19+
csdx config:set:region NA
20+
```
21+
22+
4. Login to the CLI
23+
24+
```bash
25+
csdx auth:login
26+
```
27+
28+
5. Try some operations like `csdx cm:export-to-csv`
29+
30+
# Getting started with the tsgen plugin
31+
32+
1. Check if the following command is running :
33+
34+
```bash
35+
csdx plugins:link -h
36+
```
37+
38+
If error comes then install the CLI :
39+
40+
```bash
41+
npm install -g @contentstack/cli
42+
```
43+
44+
2. Check whether the `tsgen` plugin is already installed.
45+
46+
```bash
47+
csdx plugins
48+
```
49+
50+
If the plugin is already installed and version is displayed then remove that plugin
51+
52+
```bash
53+
csdx plugins:remove contentstack-cli-tsgen
54+
```
55+
56+
Now recheck if the plugin was removed or not - `csdx plugins`
57+
58+
3. Now in the root directory of `contentstack-cli-tsgen`, link the plugin to the installed CLI.
59+
60+
```bash
61+
csdx plugins:link .
62+
```
63+
64+
4. Now check this plugin command and the output will be served from the `src/commands/tsgen.ts` file.
65+
66+
```bash
67+
csdx tsgen -h
68+
```
69+
70+
5. Need to setup the delivery token to fetch the stacks data
71+
72+
```bash
73+
csdx auth:tokens:add --delivery
74+
```
75+
76+
```bash
77+
? Provide alias to store token forTSgenPlugin
78+
? Alias is already exists, do you want to replace? Yes
79+
? Enter the api key xxxxxx
80+
? Enter the token xxxxx
81+
? Enter the environment name xxxx
82+
```
83+
84+
The environment name will be the one which you have created in your stack for publishing entries/content types.
85+
86+
6. If it is running correctly then test these commands
87+
88+
1. Default :
89+
90+
```bash
91+
csdx tsgen -a "forTSgenPlugin" -o "contentstack/generated.d.ts"
92+
```
93+
94+
2. Add Prefix :
95+
96+
```bash
97+
csdx tsgen -a "forTSgenPlugin" -o "contentstack/generated.d.ts" -p "I"
98+
```
99+
100+
3. Docs(default is true so lets turn it off) :
101+
102+
```bash
103+
csdx tsgen -a "forTSgenPlugin" -o "contentstack/generated.d.ts" --no-doc
104+
```
105+
106+
4. Add system fields types :
107+
108+
```bash
109+
csdx tsgen -a "forTSgenPlugin" -o "contentstack/generated.d.ts" --include-system-fields
110+
```
111+
112+
5. Add GraphQL schema typpes :
113+
114+
```bash
115+
csdx tsgen -a "forTSgenPlugin" -o "contentstack/generated.d.ts" --api-type graphql
116+
```
117+
118+
6. Add a namespace for the GraphQL API type to organize the generated types :
119+
120+
```bash
121+
csdx tsgen -a "forTSgenPlugin" -o "contentstack/generated.d.ts" --api-type graphql --namespace "Testing-GraphQL"
122+
```

0 commit comments

Comments
 (0)