cds-plugin-ui5 0.9.0 → 0.9.2
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 +16 -0
- package/cds-plugin.js +43 -25
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.9.2](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.1...cds-plugin-ui5@0.9.2) (2024-05-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cds-plugin-ui5
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.9.1](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.0...cds-plugin-ui5@0.9.1) (2024-05-14)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package cds-plugin-ui5
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
# [0.9.0](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.8.3...cds-plugin-ui5@0.9.0) (2024-05-13)
|
|
7
23
|
|
|
8
24
|
|
package/cds-plugin.js
CHANGED
|
@@ -192,7 +192,8 @@ if (!skip) {
|
|
|
192
192
|
});
|
|
193
193
|
|
|
194
194
|
// check if the register function for build tasks is available at the cds object
|
|
195
|
-
// and if the Plugin class is available to register the cds build task
|
|
195
|
+
// and if the Plugin class is available to register the cds build task to cover
|
|
196
|
+
// the tracks of the cds-plugin-ui5 workspace configuration and dependencies
|
|
196
197
|
if (typeof cds.build?.register === "function" && typeof cds.build?.Plugin?.constructor === "function") {
|
|
197
198
|
const { readFile, writeFile } = require("fs").promises;
|
|
198
199
|
const { existsSync } = require("fs");
|
|
@@ -213,46 +214,63 @@ if (!skip) {
|
|
|
213
214
|
// register the cds build task to sanitize the package.json and update the package-lock.json
|
|
214
215
|
cds.build.register(
|
|
215
216
|
"ui5",
|
|
217
|
+
/**
|
|
218
|
+
* CDS Build Plugin to ensure that the workspace configuration and the workspace dev
|
|
219
|
+
* dependencies are removed and finally runs the npm install --package-lock-only to
|
|
220
|
+
* update the package-lock.json
|
|
221
|
+
*/
|
|
216
222
|
class UI5Plugin extends cds.build.Plugin {
|
|
217
223
|
static taskDefaults = { src: cds.env.folders.srv };
|
|
218
224
|
static hasTask() {
|
|
219
|
-
return true;
|
|
225
|
+
return true; // plugin is a cds build task
|
|
220
226
|
}
|
|
221
227
|
init() {}
|
|
222
228
|
clean() {
|
|
223
|
-
this._priority = -1; // hack to ensure that the
|
|
229
|
+
this._priority = -1; // hack to ensure that the task is executed last!
|
|
224
230
|
}
|
|
225
231
|
get priority() {
|
|
226
232
|
return this._priority || 1;
|
|
227
233
|
}
|
|
228
234
|
async build() {
|
|
229
|
-
//
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
235
|
+
// determine the namespace from the model
|
|
236
|
+
const model = await this.model();
|
|
237
|
+
if (!model) return;
|
|
238
|
+
const namespace = model.namespace || "<unknown>";
|
|
239
|
+
// sanitize the package.json if it exists
|
|
240
|
+
const packageJsonPath = join(this.task.dest, "package.json");
|
|
241
|
+
if (existsSync(packageJsonPath)) {
|
|
242
|
+
log.info(`Sanitizing the package.json for "${namespace}"...`);
|
|
243
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath), "utf-8");
|
|
244
|
+
let modified = false;
|
|
245
|
+
// remove the workspace configuration
|
|
246
|
+
if (packageJson.workspaces) {
|
|
247
|
+
delete packageJson.workspaces;
|
|
248
|
+
modified = true;
|
|
249
|
+
}
|
|
250
|
+
// remove the workspace dev dependencies and the cds-plugin-ui5
|
|
251
|
+
if (packageJson.devDependencies) {
|
|
252
|
+
packageJson.devDependencies = Object.entries(packageJson.devDependencies).reduce((acc, [dep, version]) => {
|
|
253
|
+
if (valid(version) && dep !== "cds-plugin-ui5") {
|
|
254
|
+
acc[dep] = version;
|
|
255
|
+
}
|
|
256
|
+
return acc;
|
|
257
|
+
}, {});
|
|
258
|
+
modified = true;
|
|
259
|
+
}
|
|
260
|
+
// overwrite the package.json if it was modified only
|
|
261
|
+
if (modified) {
|
|
262
|
+
await writeFile(packageJsonPath, JSON.stringify(packageJson, null, 2), "utf-8");
|
|
263
|
+
}
|
|
249
264
|
}
|
|
265
|
+
// update the package-lock.json if it exists
|
|
250
266
|
if (existsSync(join(this.task.dest, "package-lock.json"))) {
|
|
251
|
-
log.info(
|
|
267
|
+
log.info(`Updating the package-lock.json for "${namespace}"...`);
|
|
268
|
+
// run the npm install --package-lock-only to only update the package-lock.json
|
|
269
|
+
// without installing the dependencies to node_modules
|
|
252
270
|
try {
|
|
253
271
|
/* const { stdout, stderr } = */ await exec("npm install --package-lock-only", { cwd: this.task.dest });
|
|
254
272
|
} catch (e) {
|
|
255
|
-
|
|
273
|
+
log.error(`Failed to update the package-lock.json for "${namespace}"! Error: ${e.code} - ${e.message}`);
|
|
256
274
|
}
|
|
257
275
|
}
|
|
258
276
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cds-plugin-ui5",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "A CDS server plugin to inject the middlewares of all related UI5 tooling based projects.",
|
|
5
5
|
"author": "Peter Muessig",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@ui5/fs": "^3.0.5",
|
|
15
|
-
"@ui5/project": "^3.9.
|
|
16
|
-
"@ui5/server": "^3.
|
|
15
|
+
"@ui5/project": "^3.9.1",
|
|
16
|
+
"@ui5/server": "^3.2.0",
|
|
17
17
|
"js-yaml": "^4.1.0",
|
|
18
|
-
"node-html-parser": "^6.1.
|
|
19
|
-
"semver": "^7.
|
|
18
|
+
"node-html-parser": "^6.1.13",
|
|
19
|
+
"semver": "^7.6.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@sap/cds": "^6.8.4",
|
|
23
|
-
"express": "^4.
|
|
23
|
+
"express": "^4.19.2"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@sap/cds": ">=6.8.2",
|
|
27
27
|
"express": ">=4.18.2"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "19436c1cb787ae5afe0fa7ae45ced2d28a73d986"
|
|
30
30
|
}
|