@konfik-plugin/package-json
Advanced tools
Comparing version 0.0.12 to 0.0.13
@@ -5,3 +5,14 @@ import { KonfikFactory } from '@konfik/core'; | ||
brand: PackageJsonKonfikBrand, | ||
toString: (config) => JSON.stringify(config), | ||
toString: (config) => { | ||
if (config.dependencies) { | ||
config.dependencies = sortObjectAlphabetically(config.dependencies); | ||
} | ||
if (config.devDependencies) { | ||
config.devDependencies = sortObjectAlphabetically(config.devDependencies); | ||
} | ||
if (config.peerDependencies) { | ||
config.peerDependencies = sortObjectAlphabetically(config.peerDependencies); | ||
} | ||
return JSON.stringify(config); | ||
}, | ||
// NOTE we can't simply use `json` here since prettier seems to format `package.json` files with the `json-stringify` parser by default | ||
@@ -11,2 +22,11 @@ // We should come up with a better solution to this | ||
}); | ||
const sortObjectAlphabetically = (obj) => { | ||
const sorted = {}; | ||
Object.keys(obj) | ||
.sort() | ||
.forEach((key) => { | ||
sorted[key] = obj[key]; | ||
}); | ||
return sorted; | ||
}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@konfik-plugin/package-json", | ||
"version": "0.0.12", | ||
"version": "0.0.13", | ||
"exports": { | ||
@@ -9,3 +9,3 @@ ".": "./src/index.ts" | ||
"dependencies": { | ||
"@konfik/core": "0.0.12", | ||
"@konfik/core": "0.0.13", | ||
"type-fest": "^2.10.0" | ||
@@ -12,0 +12,0 @@ }, |
@@ -9,3 +9,17 @@ import { KonfikFactory } from '@konfik/core' | ||
brand: PackageJsonKonfikBrand, | ||
toString: (config) => JSON.stringify(config), | ||
toString: (config) => { | ||
if (config.dependencies) { | ||
config.dependencies = sortObjectAlphabetically(config.dependencies) | ||
} | ||
if (config.devDependencies) { | ||
config.devDependencies = sortObjectAlphabetically(config.devDependencies) | ||
} | ||
if (config.peerDependencies) { | ||
config.peerDependencies = sortObjectAlphabetically(config.peerDependencies) | ||
} | ||
return JSON.stringify(config) | ||
}, | ||
// NOTE we can't simply use `json` here since prettier seems to format `package.json` files with the `json-stringify` parser by default | ||
@@ -15,1 +29,11 @@ // We should come up with a better solution to this | ||
}) | ||
const sortObjectAlphabetically = <T extends Record<string, any>>(obj: T) => { | ||
const sorted = {} as T | ||
Object.keys(obj) | ||
.sort() | ||
.forEach((key: keyof T) => { | ||
sorted[key] = obj[key] | ||
}) | ||
return sorted | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
AI-detected possible typosquat
Supply chain riskAI has identified this package as a potential typosquat of a more popular package. This suggests that the package may be intentionally mimicking another package's name, description, or other metadata.
Found 1 instance in 1 package
353458
106
0
+ Added@konfik/core@0.0.13(transitive)
- Removed@konfik/core@0.0.12(transitive)
Updated@konfik/core@0.0.13