From d109e19f66e28361d0c174985dbb1b3b36549645 Mon Sep 17 00:00:00 2001 From: Badisi Date: Sat, 22 Jun 2024 00:45:42 +0200 Subject: [PATCH] fix(release): does not respect file indentation @see https://github.com/nrwl/nx/issues/26425 --- package-lock.json | 11 +++++ package.json | 1 + patches/nx+19.3.0.patch | 38 ++++++++++++++++ projects/core/package.json | 90 +++++++++++++++++++------------------- 4 files changed, 95 insertions(+), 45 deletions(-) diff --git a/package-lock.json b/package-lock.json index 435992cb..d31fa00d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,6 +46,7 @@ "@swc/core": "^1.6.3", "@types/jasmine": "~5.1.4", "@types/lodash-es": "^4.17.12", + "detect-indent": "^7.0.1", "husky": "~9.0.11", "jasmine-core": "~4.6.1", "karma": "~6.4.3", @@ -9911,6 +9912,16 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-indent": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.1.tgz", + "integrity": "sha512-Mc7QhQ8s+cLrnUfU/Ji94vG/r8M26m8f++vyres4ZoojaRDpZ1eSIh/EpzLNwlWuvzSZ3UbDFspjFvTDXe6e/g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.20" + } + }, "node_modules/detect-node": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/detect-node/-/detect-node-2.1.0.tgz", diff --git a/package.json b/package.json index a6d03de8..c610f83f 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "@swc/core": "^1.6.3", "@types/jasmine": "~5.1.4", "@types/lodash-es": "^4.17.12", + "detect-indent": "^7.0.1", "husky": "~9.0.11", "jasmine-core": "~4.6.1", "karma": "~6.4.3", diff --git a/patches/nx+19.3.0.patch b/patches/nx+19.3.0.patch index a546da48..e0dabb01 100644 --- a/patches/nx+19.3.0.patch +++ b/patches/nx+19.3.0.patch @@ -30,3 +30,41 @@ index e08aff8..de3cdc7 100644 + return commits.filter((c) => c.affectedFiles.some((f) => filesInReleaseGroup.has(f))); } exports.getCommitsRelevantToProjects = getCommitsRelevantToProjects; +diff --git a/node_modules/nx/src/generators/utils/json.js b/node_modules/nx/src/generators/utils/json.js +index 7db40ce..5e69931 100644 +--- a/node_modules/nx/src/generators/utils/json.js ++++ b/node_modules/nx/src/generators/utils/json.js +@@ -1,6 +1,8 @@ + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.updateJson = exports.writeJson = exports.readJson = void 0; ++let detectIndent_1; ++(async () => detectIndent_1 = ((await import('detect-indent')).default))(); + const json_1 = require("../../utils/json"); + /** + * Reads a json file, removes all comments and parses JSON. +@@ -30,7 +32,10 @@ exports.readJson = readJson; + * @param options Optional JSON Serialize Options + */ + function writeJson(tree, path, value, options) { +- const serialized = (0, json_1.serializeJson)(value, options); ++ // const serialized = (0, json_1.serializeJson)(value, options); ++ // tree.write(path, `${serialized}\n`); ++ const indent = options?.indent ?? detectIndent_1(tree.read(path, 'utf-8')).indent; ++ const serialized = (0, json_1.serializeJson)(value, { ...options, indent }); + tree.write(path, `${serialized}\n`); + } + exports.writeJson = writeJson; +diff --git a/node_modules/nx/src/utils/json.js b/node_modules/nx/src/utils/json.js +index 9ea1345..0a51412 100644 +--- a/node_modules/nx/src/utils/json.js ++++ b/node_modules/nx/src/utils/json.js +@@ -57,6 +57,7 @@ function formatParseError(input, parseError) { + * @returns the formatted JSON representation of the object + */ + function serializeJson(input, options) { +- return JSON.stringify(input, null, options?.spaces ?? 2); ++ // return JSON.stringify(input, null, options?.spaces ?? 2); ++ return JSON.stringify(input, null, options.indent ?? 2); + } + exports.serializeJson = serializeJson; diff --git a/projects/core/package.json b/projects/core/package.json index 2dc2cc23..594affd3 100644 --- a/projects/core/package.json +++ b/projects/core/package.json @@ -1,48 +1,48 @@ { - "name": "@hug/ngx-core", - "version": "1.1.3", - "description": "HUG Angular - the core framework", - "homepage": "https://github.com/dsi-hug/ngx-components", - "license": "GPL-3.0-only", - "author": "HUG - Hôpitaux Universitaires Genève", - "contributors": [ - "badisi (https://github.com/badisi)", - "vapkse (https://github.com/vapkse)" - ], - "repository": { - "type": "git", - "url": "git+https://github.com/dsi-hug/ngx-components.git" - }, - "keywords": [ - "angular", - "material", - "material design", - "components" - ], - "sideEffects": false, - "exports": { - ".": { - "sass": "./styles" + "name": "@hug/ngx-core", + "version": "1.1.3", + "description": "HUG Angular - the core framework", + "homepage": "https://github.com/dsi-hug/ngx-components", + "license": "GPL-3.0-only", + "author": "HUG - Hôpitaux Universitaires Genève", + "contributors": [ + "badisi (https://github.com/badisi)", + "vapkse (https://github.com/vapkse)" + ], + "repository": { + "type": "git", + "url": "git+https://github.com/dsi-hug/ngx-components.git" + }, + "keywords": [ + "angular", + "material", + "material design", + "components" + ], + "sideEffects": false, + "exports": { + ".": { + "sass": "./styles" + } + }, + "scripts": { + "lint": "eslint . --fix", + "test": "ng test core", + "test:ci": "ng test core --watch=false --browsers=ChromeHeadless", + "build:ng": "ng build core -c=production", + "build": "nx build:ng @hug/ngx-core --verbose", + "release": "nx release -p=@hug/ngx-core --yes --verbose", + "release:dry-run": "nx release -p=@hug/ngx-core --verbose --dry-run" + }, + "peerDependencies": { + "@angular/common": ">= 14", + "@angular/core": ">= 14", + "@angular/cdk": ">= 14", + "@angular/material": ">= 14", + "rxjs": ">= 7.0.0", + "date-fns": "^2.30.0" + }, + "dependencies": { + "tslib": "^2.6.3" } - }, - "scripts": { - "lint": "eslint . --fix", - "test": "ng test core", - "test:ci": "ng test core --watch=false --browsers=ChromeHeadless", - "build:ng": "ng build core -c=production", - "build": "nx build:ng @hug/ngx-core --verbose", - "release": "nx release -p=@hug/ngx-core --yes --verbose", - "release:dry-run": "nx release -p=@hug/ngx-core --verbose --dry-run" - }, - "peerDependencies": { - "@angular/common": ">= 14", - "@angular/core": ">= 14", - "@angular/cdk": ">= 14", - "@angular/material": ">= 14", - "rxjs": ">= 7.0.0", - "date-fns": "^2.30.0" - }, - "dependencies": { - "tslib": "^2.6.3" - } }