Skip to content

Commit ff88164

Browse files
Merge pull request #47 from Contentstack-Solutions/staging
Merge staging to master
2 parents c656d83 + 15e2780 commit ff88164

16 files changed

+39
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "contentstack-cli-tsgen",
33
"description": "Generate TypeScript typings from a Stack.",
4-
"version": "2.1.6",
4+
"version": "2.1.7",
55
"author": "Michael Davis",
66
"bugs": "https://github.com/Contentstack-Solutions/contentstack-cli-tsgen/issues",
77
"dependencies": {
@@ -58,5 +58,10 @@
5858
"prepack": "rm -rf lib && tsc -b && oclif manifest && oclif readme",
5959
"test": "jest",
6060
"version": "oclif readme && git add README.md"
61+
},
62+
"csdxConfig": {
63+
"shortCommandName": {
64+
"tsgen": "TSGEN"
65+
}
6166
}
6267
}

src/lib/stack/schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export type Block = {
2727
export type GlobalField = {
2828
reference_to: string;
2929
schema: Schema;
30+
_version?: number
3031
} & FieldOptions;
3132

3233
export type ReferenceField = {

src/lib/tsgen/factory.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ export default function (userOptions: TSGenOptions) {
228228
options.docgen.interface(contentType.description),
229229
define_interface(contentType),
230230
'{',
231+
['/**', "Version", '*/'].join(' '),
232+
[`version: `,contentType._version,';'].join(' '),
231233
visit_fields(contentType.schema),
232234
'}',
233235
]

tests/tsgen/boolean.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ describe('builtin boolean field', () => {
2424
expect(result.definition).toMatchInlineSnapshot(`
2525
"export interface IBoolean
2626
{
27+
/** Version */
28+
version: 2 ;
2729
title: string;
2830
boolean?: boolean;
2931
}"

tests/tsgen/defaults.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ describe('default single content block', () => {
1717
expect(result.definition).toMatchInlineSnapshot(`
1818
"export interface IMetadataSingleContentBlock
1919
{
20+
/** Version */
21+
version: 2 ;
2022
title: string;
2123
}"
2224
`)
@@ -41,6 +43,8 @@ describe('default single webpage', () => {
4143
expect(result.definition).toMatchInlineSnapshot(`
4244
"export interface IMetadataSingleWebpage
4345
{
46+
/** Version */
47+
version: 2 ;
4448
title: string;
4549
url: string;
4650
}"

tests/tsgen/global.fields.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ describe('global fields', () => {
2424
expect(globalField.definition).toMatchInlineSnapshot(`
2525
"export interface ISeo
2626
{
27+
/** Version */
28+
version: ;
2729
keywords?: string;
2830
description?: string;
2931
}"
@@ -34,6 +36,8 @@ describe('global fields', () => {
3436
expect(result.definition).toMatchInlineSnapshot(`
3537
"export interface IGlobalFields
3638
{
39+
/** Version */
40+
version: 2 ;
3741
title: string;
3842
seo?: ISeo;
3943
}"

tests/tsgen/group.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ describe('group', () => {
2323
expect(result.definition).toMatchInlineSnapshot(`
2424
"export interface Group
2525
{
26+
/** Version */
27+
version: 3 ;
2628
title: string;
2729
multiple_group_max_limit?: [{
2830
number?: number;

tests/tsgen/isodate.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ describe('builtin isodate field', () => {
2424
expect(result.definition).toMatchInlineSnapshot(`
2525
"export interface Isodate
2626
{
27+
/** Version */
28+
version: 2 ;
2729
title: string;
2830
date?: string;
2931
date_required: string;

tests/tsgen/jsdoc.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ describe('jsdoc', () => {
1515
"/** Content Type Description */
1616
export interface Jsdoc
1717
{
18+
/** Version */
19+
version: 3 ;
1820
/** Name */
1921
title: string;
2022
/** Age */

0 commit comments

Comments
 (0)