@vc-shell/create-vc-app 1.1.30 → 1.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import i from "node:path";
|
|
|
6
6
|
import s from "node:fs";
|
|
7
7
|
import { fileURLToPath as Re } from "node:url";
|
|
8
8
|
import { cwd as je, argv as Ae, exit as we } from "node:process";
|
|
9
|
-
const ke = "1.1.
|
|
9
|
+
const ke = "1.1.31", Oe = {
|
|
10
10
|
version: ke
|
|
11
11
|
};
|
|
12
12
|
var Ne = typeof global == "object" && global && global.Object === Object && global, Me = typeof self == "object" && self && self.Object === Object && self, Te = Ne || Me || Function("return this")(), g = Te.Symbol, H = Object.prototype, Ue = H.hasOwnProperty, Ee = H.toString, y = g ? g.toStringTag : void 0;
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"@types/node": "^20.10.5",
|
|
24
24
|
"@typescript-eslint/eslint-plugin": "^6.16.0",
|
|
25
25
|
"@typescript-eslint/parser": "^6.16.0",
|
|
26
|
-
"@vc-shell/api-client-generator": "^1.1.
|
|
27
|
-
"@vc-shell/release-config": "^1.1.
|
|
28
|
-
"@vc-shell/ts-config": "^1.1.
|
|
26
|
+
"@vc-shell/api-client-generator": "^1.1.31",
|
|
27
|
+
"@vc-shell/release-config": "^1.1.31",
|
|
28
|
+
"@vc-shell/ts-config": "^1.1.31",
|
|
29
29
|
"@vitejs/plugin-vue": "^5.2.3",
|
|
30
30
|
"@vue/eslint-config-prettier": "^9.0.0",
|
|
31
31
|
"@vue/eslint-config-typescript": "^12.0.0",
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"vue-tsc": "^2.2.10"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@vc-shell/config-generator": "^1.1.
|
|
57
|
-
"@vc-shell/framework": "^1.1.
|
|
56
|
+
"@vc-shell/config-generator": "^1.1.31",
|
|
57
|
+
"@vc-shell/framework": "^1.1.31",
|
|
58
58
|
"@vueuse/core": "^10.7.1",
|
|
59
59
|
"@vueuse/integrations": "^10.7.1",
|
|
60
60
|
"cross-spawn": "^7.0.3",
|
|
@@ -1,78 +1,199 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
| `--
|
|
61
|
-
| `--
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
# Platform Manager REST Client
|
|
2
|
+
|
|
3
|
+
# Generate API client
|
|
4
|
+
|
|
5
|
+
This guide describes the process of generating an API client to access the VC Platform API from your custom application.
|
|
6
|
+
|
|
7
|
+
!!! note
|
|
8
|
+
Platform Manager REST Client offers generated REST API methods that make it easy to interact with the existing VirtoCommerce Platform API.
|
|
9
|
+
|
|
10
|
+
## Prerequisites
|
|
11
|
+
|
|
12
|
+
* .NET Core 6.0, particularly if you are using MacOS or Linux.
|
|
13
|
+
|
|
14
|
+
## Generate TypeScript API clients
|
|
15
|
+
|
|
16
|
+
To enable TypeScript API client generation in your project:
|
|
17
|
+
|
|
18
|
+
1. Add dependencies to your project:
|
|
19
|
+
|
|
20
|
+
Using command
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
yarn add @vc-shell/api-client-generator cross-env
|
|
24
|
+
```
|
|
25
|
+
<br>
|
|
26
|
+
|
|
27
|
+
`cross-env` runs scripts that set and use environment variables across platforms.
|
|
28
|
+
|
|
29
|
+
Manually
|
|
30
|
+
|
|
31
|
+
Add the dependencies to your project's **package.json**:
|
|
32
|
+
|
|
33
|
+
```json title="vc-app/package.json" linenums="1"
|
|
34
|
+
{
|
|
35
|
+
...
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
...
|
|
38
|
+
"@vc-shell/api-client-generator": "latest",
|
|
39
|
+
"cross-env": "latest",
|
|
40
|
+
...
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
2. Configure client generation in your project. Inside your project's **package.json** file, add a `"generate-api-client"` command to the list of scripts:
|
|
46
|
+
|
|
47
|
+
```title="vc-app-extend/package.json" linenums="1"
|
|
48
|
+
{
|
|
49
|
+
"scripts": {
|
|
50
|
+
...
|
|
51
|
+
"generate-api-client": cross-env api-client-generator --APP_PLATFORM_MODULES='[MarketplaceVendor,Catalog,Orders]' --APP_API_CLIENT_DIRECTORY=./src/api_client/
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
The options are listed in the table below:
|
|
57
|
+
|
|
58
|
+
| Options | Description | Example |
|
|
59
|
+
|----------------------------- |---------------------------------------------------------------- |------------------------------------------------------------ |
|
|
60
|
+
| `--APP_PLATFORM_MODULES` | Platform modules to generate API client.<br>{==string[]==} <br> Customize the `--APP_PLATFORM_MODULES` list<br>to match your project's requirements. | `--APP_PLATFORM_MODULES='[MarketplaceVendor,Orders,Catalog]'` |
|
|
61
|
+
| `--APP_API_CLIENT_DIRECTORY` | Output directory for generated API clients. <br>{==string==} | `--APP_API_CLIENT_DIRECTORY=./src/api_client/` |
|
|
62
|
+
| `--APP_PLATFORM_URL` | Platform URL to obtain client API configs. <br>{==string==} | `--APP_PLATFORM_URL=https://vcmp-dev.govirto.com/` |
|
|
63
|
+
| `--APP_PACKAGE_NAME` | Package name for generated API clients. <br>{==string==} | `--APP_PACKAGE_NAME=vc-app-extend` |
|
|
64
|
+
| `--APP_PACKAGE_VERSION` | Package version for generated API clients. <br>{==string==} | `--APP_PACKAGE_VERSION=1.0.0` |
|
|
65
|
+
| `--APP_TYPE_STYLE` | Sets the type style for generated DTOs. Can be 'Class' or 'Interface'.<br>{==string==} | `--APP_TYPE_STYLE=Interface` |
|
|
66
|
+
| `--APP_OUT_DIR` | Output directory for generated API clients. <br>{==string==} | `--APP_OUT_DIR=./src/api_client/` |
|
|
67
|
+
| `--APP_BUILD_DIR` | Directory where TypeScript files will be compiled. <br>{==string==} | `--APP_BUILD_DIR=lib` (default is "dist") |
|
|
68
|
+
| `--SKIP_BUILD` | Skip build step. <br>{==boolean==} | `--SKIP_BUILD=true` |
|
|
69
|
+
| `--VERBOSE` | Enable verbose logging. <br>{==boolean==} | `--VERBOSE=true` |
|
|
70
|
+
|
|
71
|
+
3. Configure Platform URL to ensure your project can access the platform's API configurations. Add the platform URL to your project's **.env** file:
|
|
72
|
+
|
|
73
|
+
```title="vc-app-extend/.env"
|
|
74
|
+
APP_PLATFORM_URL=https://vcmp-dev.govirto.com/
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
!!! note
|
|
78
|
+
Alternatively, you can specify the Platform URL as a command option in the previous step when running the `"generate-api-client"` command.
|
|
79
|
+
|
|
80
|
+
4. Generate the API clients using the following command:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
yarn generate-api-client
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
This command generates the required API clients for your custom application. Now you can effortlessly access the VC Platform API from your custom application using the generated API client.
|
|
87
|
+
|
|
88
|
+
## Features
|
|
89
|
+
|
|
90
|
+
### Smart Configuration Merging
|
|
91
|
+
|
|
92
|
+
The generator now intelligently merges configuration files to preserve your custom settings. When you update an existing API client:
|
|
93
|
+
|
|
94
|
+
- Custom package.json fields like name, version, description, keywords, author and license are preserved
|
|
95
|
+
- Custom tsconfig.json settings are maintained
|
|
96
|
+
- Exports are intelligently updated to preserve existing paths
|
|
97
|
+
|
|
98
|
+
### Metadata Tracking
|
|
99
|
+
|
|
100
|
+
API client now includes metadata to track the generation:
|
|
101
|
+
|
|
102
|
+
```json
|
|
103
|
+
{
|
|
104
|
+
"apiClientGenerator": {
|
|
105
|
+
"version": "1.1.0",
|
|
106
|
+
"generatedAt": "2025-04-01T12:30:45.123Z"
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### Multiple API Exports
|
|
112
|
+
|
|
113
|
+
The generator handles multiple API clients effectively:
|
|
114
|
+
|
|
115
|
+
- Creates standardized exports with both short names (`./{moduleName}`) and full names (`./virtocommerce.{moduleName}`)
|
|
116
|
+
- Prevents duplicate module exports by intelligently merging with existing ones
|
|
117
|
+
- Automatically removes `module` and `types` fields that conflict with multiple exports
|
|
118
|
+
- Works properly with incremental generation (can add new APIs without breaking existing ones)
|
|
119
|
+
|
|
120
|
+
### Smart Root Export Handling
|
|
121
|
+
|
|
122
|
+
The generator now intelligently handles root exports based on the number of API modules:
|
|
123
|
+
|
|
124
|
+
- **Single API Module**: When only one API module is generated, it automatically becomes the root export (`.`) and `module`/`types` fields are maintained
|
|
125
|
+
- **Multiple API Modules**: When multiple API modules are generated, only subpath exports are used (e.g., `./moduleA`, `./moduleB`)
|
|
126
|
+
- **Preserving Preferences**: If a root export already exists, it will be preserved as long as it points to one of the generated modules
|
|
127
|
+
|
|
128
|
+
This enables both simple usage for single-API packages and proper subpath exporting for multi-API packages:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
// Single API package (using root export)
|
|
132
|
+
import { MyClient } from '@myapp/api';
|
|
133
|
+
|
|
134
|
+
// Multi-API package (using subpath exports)
|
|
135
|
+
import { ClientA } from '@myapp/api/moduleA';
|
|
136
|
+
import { ClientB } from '@myapp/api/moduleB';
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Directory Creation
|
|
140
|
+
|
|
141
|
+
Target directories are automatically created if they don't exist.
|
|
142
|
+
|
|
143
|
+
### Verbose Logging
|
|
144
|
+
|
|
145
|
+
Enable detailed logging to troubleshoot generation issues:
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
yarn generate-api-client --VERBOSE=true
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Custom Build Directory
|
|
152
|
+
|
|
153
|
+
You can specify a custom build directory where TypeScript files will be compiled:
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
yarn generate-api-client --APP_BUILD_DIR=lib
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
By default, the build directory is "dist".
|
|
160
|
+
|
|
161
|
+
### Error Handling Improvements
|
|
162
|
+
|
|
163
|
+
Better error handling and reporting make it easier to diagnose issues during client generation.
|
|
164
|
+
|
|
165
|
+
## Recent Improvements (v1.1.8)
|
|
166
|
+
|
|
167
|
+
### Fixed Issues
|
|
168
|
+
|
|
169
|
+
- **Configuration Preservation**: Fixed issue where package.json and tsconfig.json user settings were being overwritten
|
|
170
|
+
- **Export Path Management**: Improved export path handling to prevent incorrect paths with duplicated prefixes
|
|
171
|
+
- **Path Normalization**: Added better path normalization to handle edge cases correctly
|
|
172
|
+
- **Export Deduplication**: Implemented smarter export merging to prevent duplicate exports with different path formats
|
|
173
|
+
- **Build Directory Support**: Added proper support for custom build directories via APP_BUILD_DIR parameter
|
|
174
|
+
- **Declaration Files Location**: Fixed issue with TypeScript declaration files location to match the build directory
|
|
175
|
+
- **Error Handling**: Improved JSON parsing error handling with better fallback strategies
|
|
176
|
+
- **Root Export Handling**: Fixed issue with root exports being ignored or improperly handled
|
|
177
|
+
|
|
178
|
+
### New Features
|
|
179
|
+
|
|
180
|
+
- **Intelligent Config Merging**: Complete rewrite of configuration merging logic to better preserve user settings
|
|
181
|
+
- **Export Path Standardization**: New system for standardizing export paths to improve consistency
|
|
182
|
+
- **Path Validation**: Added strict validation of export paths to prevent invalid configurations
|
|
183
|
+
- **Improved Logging**: Added more detailed logging for better debugging
|
|
184
|
+
- **Extended User Fields Preservation**: Expanded the list of user-defined fields that are preserved during updates
|
|
185
|
+
- **Better Directory Management**: Improved directory creation and validation process
|
|
186
|
+
- **Smart Single/Multi API Detection**: Automatically detects single API scenarios and creates appropriate root exports
|
|
187
|
+
- **Module/Types Field Handling**: Preserves module and types fields for single API packages while removing them for multi-API packages
|
|
188
|
+
|
|
189
|
+
## Troubleshooting
|
|
190
|
+
|
|
191
|
+
If you encounter issues during API client generation:
|
|
192
|
+
|
|
193
|
+
1. Enable verbose logging with `--VERBOSE=true`
|
|
194
|
+
2. Ensure target directories have proper permissions
|
|
195
|
+
3. Check your connectivity to the platform URL
|
|
196
|
+
4. Verify that the specified platform modules exist
|
|
197
|
+
5. If you encounter JSON parsing errors in tsconfig.json or package.json, try using the `--VERBOSE=true` flag to see detailed error messages
|
|
198
|
+
6. Check for duplicate exports in your package.json which might cause conflicts
|
|
199
|
+
7. If you manually modified exports in package.json, ensure they follow the correct format
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vc-shell/create-vc-app",
|
|
3
3
|
"description": "Application scaffolding",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.31",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": "./dist/index.js",
|
|
7
7
|
"files": [
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/prompts": "^2.4.4",
|
|
16
|
-
"@vc-shell/ts-config": "^1.1.
|
|
16
|
+
"@vc-shell/ts-config": "^1.1.31",
|
|
17
17
|
"copyfiles": "^2.4.1",
|
|
18
18
|
"cross-env": "^7.0.3",
|
|
19
19
|
"shx": "^0.3.4",
|