Skip to content

Commit c785207

Browse files
committed
feat: Use handlebars to create files and enhance cli options
To create the class and index files, a handlebar template is used. Enhance the cli with extra options to include classes, e.g. that are not covered by --prefix. Enhance console output. Recursively search dependencies in classes. BREAKING CHANGE: The new functionality are probably not backwards compatible!
1 parent a09cf5f commit c785207

File tree

14 files changed

+1372
-812
lines changed

14 files changed

+1372
-812
lines changed

README.md

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A schema manager for Parse Server
44

55
## CLI Usage
66

7-
Repository on npm: https://www.npmjs.com/package/@openinc/parse-server-schema
7+
Repository on npm:| `--include <include...>` | string[] | `[]` | Additional class name(s) to add to the schema (beyond prefix filter). Supports wildcards with `*`. Can be specified multiple times |https://www.npmjs.com/package/@openinc/parse-server-schema
88

99
```
1010
npm i -g @openinc/parse-server-schema
@@ -95,6 +95,48 @@ The file has to be an array of form `classname` --> `fields` --> `[key: fieldnam
9595
]
9696
```
9797

98+
### CLI options for typescript conversion
99+
100+
The `typescript` command supports the following options:
101+
102+
| Option | Type | Default | Description |
103+
| ------------------------------------------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
104+
| `--prefix <prefix>` | string | `""` | Prefix will be stripped from class names in generated TypeScript files |
105+
| `--ignore <ignore...>` | string[] | `[]` | Class name(s) to ignore during generation. Supports wildcards: `Prefix*` (starts with) or `*Suffix` (ends with). Can be specified multiple times |
106+
| `--include <include...>` | string[] | `[]` | Class name(s) to include (overrides --ignore). Supports wildcards with `*`. Can be specified multiple times |
107+
| `--no-class` | boolean | `false` | Don't create and register custom Parse.Object classes (generates type definitions only) |
108+
| `--no-sdk` | boolean | `false` | Don't use Parse JS SDK dependencies, generates plain TypeScript types only |
109+
| `--global-sdk` | boolean | `false` | Assume Parse JS SDK is globally available (doesn't import Parse) |
110+
| `--is-esm` | boolean | `false` | Use ES module imports/exports with `.js` extensions in generated files |
111+
| `--resolve-referenced-classes` | boolean | `false` | Generate TypeScript files for all referenced classes, even if they're not in the initial schema (enables recursive dependency resolution) |
112+
| `--custom-class-field-types-config <path>` | string | - | Path to JSON config file for custom class field type mappings |
113+
| `--verbose` | boolean | `false` | Enable verbose logging including dependency validation and dependency graph visualization |
114+
115+
**Examples:**
116+
117+
```bash
118+
# Basic usage with prefix stripping
119+
parse-server-schema typescript ./types --prefix "MyApp_"
120+
121+
# Generate with ES modules and recursive dependencies
122+
parse-server-schema typescript ./types --is-esm --resolve-referenced-classes
123+
124+
# Generate type definitions only (no Parse.Object classes)
125+
parse-server-schema typescript ./types --no-class --no-sdk
126+
127+
# Ignore specific classes and use custom field types
128+
parse-server-schema typescript ./types --ignore "_Session" "TempClass*" --custom-class-field-types-config ./custom-types.json
129+
130+
# Enable verbose logging for debugging dependency issues
131+
parse-server-schema typescript ./types --verbose --resolve-referenced-classes
132+
133+
# Generate MyApp_ prefixed classes plus additional Asset classes
134+
parse-server-schema typescript ./types --prefix "MyApp_" --include "Asset*"
135+
136+
# Generate Documentation classes plus specific additional classes
137+
parse-server-schema typescript ./types --prefix "OD3_Documentation_" --include "OD3_Asset" "User"
138+
```
139+
98140
## Version update and deployment to npm
99141

100142
The next version number is calculated by semantic release.
@@ -109,13 +151,13 @@ A GitHub workflow publishes the package automatically to npm.
109151
import { loadConfig, up, down, typescript } from "@openinc/parse-server-schema";
110152

111153
// load JSON file with config
112-
const cfg = await loadConfig("./parse-server-config.json");
154+
await loadConfig("./parse-server-config.json");
113155
// or load config from process.env
114-
const cfg = await loadConfig();
156+
await loadConfig();
115157

116-
await up(cfg, schemaPath);
158+
await up(schemaPath);
117159

118-
await down(cfg, schemaPath);
160+
await down(schemaPath);
119161

120-
await typescript(cfg, typescriptPath);
162+
await typescript(typescriptPath);
121163
```

package.json

Lines changed: 83 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,83 @@
1-
{
2-
"name": "@openinc/parse-server-schema",
3-
"version": "2.0.4",
4-
"description": "Parse Server Schema Manager - Provides functionality to manage Parse Server schemas like converting to typescript interfaces, exporting and importing schemas.",
5-
"packageManager": "pnpm@10.15.1",
6-
"type": "module",
7-
"keywords": [
8-
"parse",
9-
"schema"
10-
],
11-
"license": "MIT",
12-
"main": "dist/index.js",
13-
"files": [
14-
"dist",
15-
"bin",
16-
"README.md",
17-
"LICENSE",
18-
"package.json"
19-
],
20-
"release": {
21-
"branches": [
22-
"master"
23-
],
24-
"repositoryUrl": "https://github.com/open-inc/node-parse-server-schema.git",
25-
"plugins": [
26-
"@semantic-release/commit-analyzer",
27-
"@semantic-release/release-notes-generator",
28-
"@semantic-release/changelog",
29-
"@semantic-release/github",
30-
"@semantic-release/npm",
31-
"semantic-release-export-data"
32-
],
33-
"prepare": [
34-
"@semantic-release/changelog",
35-
"@semantic-release/npm",
36-
{
37-
"path": "@semantic-release/git",
38-
"assets": [
39-
"package.json",
40-
"pnpm-lock.json",
41-
"CHANGELOG.md"
42-
],
43-
"message": "chore(release): Release ${nextRelease.version} \n\n${nextRelease.notes}"
44-
}
45-
]
46-
},
47-
"author": {
48-
"name": "open.INC GmbH",
49-
"email": "info@openinc.de",
50-
"url": "https://openinc.de"
51-
},
52-
"repository": {
53-
"type": "git",
54-
"url": "git+https://github.com/open-inc/node-parse-server-schema.git"
55-
},
56-
"scripts": {
57-
"start": "node bin/parse-server-schema.js",
58-
"build": "rimraf ./dist && tsc --build --force"
59-
},
60-
"bin": {
61-
"parse-server-schema": "bin/parse-server-schema.js"
62-
},
63-
"dependencies": {
64-
"commander": "^14.0.0",
65-
"dotenv": "^17.2.2",
66-
"mkdirp": "^3.0.1",
67-
"semantic-release": "^24.2.7",
68-
"rimraf": "^6.0.1"
69-
},
70-
"devDependencies": {
71-
"@semantic-release/changelog": "^6.0.3",
72-
"@semantic-release/commit-analyzer": "^13.0.1",
73-
"@semantic-release/exec": "^7.1.0",
74-
"@semantic-release/git": "^10.0.1",
75-
"@semantic-release/github": "^11.0.5",
76-
"@semantic-release/npm": "^12.0.2",
77-
"@semantic-release/release-notes-generator": "^14.0.3",
78-
"@types/node": "^24.3.1",
79-
"semantic-release-export-data": "^1.1.1"
80-
}
81-
}
1+
{
2+
"name": "@openinc/parse-server-schema",
3+
"version": "2.0.4",
4+
"description": "Parse Server Schema Manager - Provides functionality to manage Parse Server schemas like converting to typescript interfaces, exporting and importing schemas.",
5+
"packageManager": "pnpm@10.16.1",
6+
"type": "module",
7+
"keywords": [
8+
"parse",
9+
"schema"
10+
],
11+
"license": "MIT",
12+
"main": "dist/index.js",
13+
"files": [
14+
"dist",
15+
"bin",
16+
"README.md",
17+
"LICENSE",
18+
"package.json"
19+
],
20+
"release": {
21+
"branches": [
22+
"master"
23+
],
24+
"repositoryUrl": "https://github.com/open-inc/node-parse-server-schema.git",
25+
"plugins": [
26+
"@semantic-release/commit-analyzer",
27+
"@semantic-release/release-notes-generator",
28+
"@semantic-release/changelog",
29+
"@semantic-release/github",
30+
"@semantic-release/npm",
31+
"semantic-release-export-data"
32+
],
33+
"prepare": [
34+
"@semantic-release/changelog",
35+
"@semantic-release/npm",
36+
{
37+
"path": "@semantic-release/git",
38+
"assets": [
39+
"package.json",
40+
"pnpm-lock.json",
41+
"CHANGELOG.md"
42+
],
43+
"message": "chore(release): Release ${nextRelease.version} \n\n${nextRelease.notes}"
44+
}
45+
]
46+
},
47+
"author": {
48+
"name": "open.INC GmbH",
49+
"email": "info@openinc.de",
50+
"url": "https://openinc.de"
51+
},
52+
"repository": {
53+
"type": "git",
54+
"url": "git+https://github.com/open-inc/node-parse-server-schema.git"
55+
},
56+
"scripts": {
57+
"start": "node bin/parse-server-schema.js",
58+
"build": "rimraf ./dist && tsc --build --force"
59+
},
60+
"bin": {
61+
"parse-server-schema": "bin/parse-server-schema.js"
62+
},
63+
"dependencies": {
64+
"commander": "^14.0.1",
65+
"dotenv": "^17.2.2",
66+
"handlebars": "^4.7.8",
67+
"mkdirp": "^3.0.1",
68+
"rimraf": "^6.0.1",
69+
"semantic-release": "^24.2.8"
70+
},
71+
"devDependencies": {
72+
"@semantic-release/changelog": "^6.0.3",
73+
"@semantic-release/commit-analyzer": "^13.0.1",
74+
"@semantic-release/exec": "^7.1.0",
75+
"@semantic-release/git": "^10.0.1",
76+
"@semantic-release/github": "^11.0.6",
77+
"@semantic-release/npm": "^12.0.2",
78+
"@semantic-release/release-notes-generator": "^14.1.0",
79+
"@types/handlebars": "^4.1.0",
80+
"@types/node": "^24.5.1",
81+
"semantic-release-export-data": "^1.1.1"
82+
}
83+
}

0 commit comments

Comments
 (0)