@pnpm/read-project-manifest
Advanced tools
Comparing version 1.1.7 to 2.0.0
# @pnpm/read-project-manifest | ||
## 2.0.0 | ||
### Major Changes | ||
- 97b986fbc: Node.js 10 support is dropped. At least Node.js 12.17 is required for the package to work. | ||
### Patch Changes | ||
- Updated dependencies [97b986fbc] | ||
- @pnpm/error@2.0.0 | ||
- @pnpm/types@7.0.0 | ||
- @pnpm/write-project-manifest@2.0.0 | ||
## 1.1.7 | ||
@@ -4,0 +17,0 @@ |
@@ -16,5 +16,5 @@ import { ProjectManifest } from '@pnpm/types'; | ||
export declare function readExactProjectManifest(manifestPath: string): Promise<{ | ||
manifest: ProjectManifest; | ||
manifest: any; | ||
writeProjectManifest: WriteProjectManifest; | ||
}>; | ||
export {}; |
@@ -7,14 +7,12 @@ "use strict"; | ||
exports.readExactProjectManifest = exports.tryReadProjectManifest = exports.readProjectManifestOnly = exports.safeReadProjectManifestOnly = void 0; | ||
const util_1 = require("util"); | ||
const fs_1 = require("fs"); | ||
const path_1 = __importDefault(require("path")); | ||
const error_1 = __importDefault(require("@pnpm/error")); | ||
const write_project_manifest_1 = __importDefault(require("@pnpm/write-project-manifest")); | ||
const read_yaml_file_1 = __importDefault(require("read-yaml-file")); | ||
const detect_indent_1 = __importDefault(require("detect-indent")); | ||
const fast_deep_equal_1 = __importDefault(require("fast-deep-equal")); | ||
const is_windows_1 = __importDefault(require("is-windows")); | ||
const sort_keys_1 = __importDefault(require("sort-keys")); | ||
const readFile_1 = require("./readFile"); | ||
const fs = require("fs"); | ||
const detectIndent = require("detect-indent"); | ||
const equal = require("fast-deep-equal"); | ||
const isWindows = require("is-windows"); | ||
const path = require("path"); | ||
const sortKeys = require("sort-keys"); | ||
const stat = util_1.promisify(fs.stat); | ||
async function safeReadProjectManifestOnly(projectDir) { | ||
@@ -47,4 +45,4 @@ try { | ||
try { | ||
const manifestPath = path.join(projectDir, 'package.json'); | ||
const { data, text } = await readFile_1.readJsonFile(manifestPath); | ||
const manifestPath = path_1.default.join(projectDir, 'package.json'); | ||
const { data, text } = await (0, readFile_1.readJsonFile)(manifestPath); | ||
return { | ||
@@ -65,4 +63,4 @@ fileName: 'package.json', | ||
try { | ||
const manifestPath = path.join(projectDir, 'package.json5'); | ||
const { data, text } = await readFile_1.readJson5File(manifestPath); | ||
const manifestPath = path_1.default.join(projectDir, 'package.json5'); | ||
const { data, text } = await (0, readFile_1.readJson5File)(manifestPath); | ||
return { | ||
@@ -83,3 +81,3 @@ fileName: 'package.json5', | ||
try { | ||
const manifestPath = path.join(projectDir, 'package.yaml'); | ||
const manifestPath = path_1.default.join(projectDir, 'package.yaml'); | ||
const manifest = await readPackageYaml(manifestPath); | ||
@@ -96,7 +94,7 @@ return { | ||
} | ||
if (isWindows()) { | ||
if ((0, is_windows_1.default)()) { | ||
// ENOTDIR isn't used on Windows, but pnpm expects it. | ||
let s; | ||
try { | ||
s = await stat(projectDir); | ||
s = await fs_1.promises.stat(projectDir); | ||
} | ||
@@ -106,3 +104,3 @@ catch (err) { | ||
} | ||
if (s && !s.isDirectory()) { | ||
if ((s != null) && !s.isDirectory()) { | ||
const err = new Error(`"${projectDir}" is not a directory`); | ||
@@ -113,7 +111,7 @@ err['code'] = 'ENOTDIR'; // eslint-disable-line | ||
} | ||
const filePath = path.join(projectDir, 'package.json'); | ||
const filePath = path_1.default.join(projectDir, 'package.json'); | ||
return { | ||
fileName: 'package.json', | ||
manifest: null, | ||
writeProjectManifest: (manifest) => write_project_manifest_1.default(filePath, manifest), | ||
writeProjectManifest: async (manifest) => (0, write_project_manifest_1.default)(filePath, manifest), | ||
}; | ||
@@ -124,3 +122,3 @@ } | ||
return { | ||
indent: detectIndent(text).indent, | ||
indent: (0, detect_indent_1.default)(text).indent, | ||
insertFinalNewline: text.endsWith('\n'), | ||
@@ -130,6 +128,6 @@ }; | ||
async function readExactProjectManifest(manifestPath) { | ||
const base = path.basename(manifestPath).toLowerCase(); | ||
const base = path_1.default.basename(manifestPath).toLowerCase(); | ||
switch (base) { | ||
case 'package.json': { | ||
const { data, text } = await readFile_1.readJsonFile(manifestPath); | ||
const { data, text } = await (0, readFile_1.readJsonFile)(manifestPath); | ||
return { | ||
@@ -145,3 +143,3 @@ manifest: data, | ||
case 'package.json5': { | ||
const { data, text } = await readFile_1.readJson5File(manifestPath); | ||
const { data, text } = await (0, readFile_1.readJson5File)(manifestPath); | ||
return { | ||
@@ -169,3 +167,3 @@ manifest: data, | ||
try { | ||
return await read_yaml_file_1.default(filePath); | ||
return await (0, read_yaml_file_1.default)(filePath); | ||
} | ||
@@ -182,6 +180,6 @@ catch (err) { // eslint-disable-line | ||
const initialManifest = normalize(JSON.parse(JSON.stringify(opts.initialManifest))); | ||
return (updatedManifest, force) => { | ||
return async (updatedManifest, force) => { | ||
updatedManifest = normalize(updatedManifest); | ||
if (force === true || !equal(initialManifest, updatedManifest)) { | ||
return write_project_manifest_1.default(opts.manifestPath, updatedManifest, { | ||
if (force === true || !(0, fast_deep_equal_1.default)(initialManifest, updatedManifest)) { | ||
return (0, write_project_manifest_1.default)(opts.manifestPath, updatedManifest, { | ||
indent: opts.indent, | ||
@@ -207,3 +205,3 @@ insertFinalNewline: opts.insertFinalNewline, | ||
else if (Object.keys(manifest[key]).length !== 0) { | ||
result[key] = sortKeys(manifest[key]); | ||
result[key] = (0, sort_keys_1.default)(manifest[key]); | ||
} | ||
@@ -210,0 +208,0 @@ } |
import { ProjectManifest } from '@pnpm/types'; | ||
export declare function readJson5File(filePath: string): Promise<{ | ||
data: ProjectManifest; | ||
data: any; | ||
text: string; | ||
@@ -5,0 +5,0 @@ }>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readJsonFile = exports.readJson5File = void 0; | ||
const util_1 = require("util"); | ||
const fs = require("graceful-fs"); | ||
const JSON5 = require("json5"); | ||
const parseJson = require("parse-json"); | ||
const stripBom = require("strip-bom"); | ||
const readFile = util_1.promisify(fs.readFile); | ||
const fs_1 = require("fs"); | ||
const json5_1 = __importDefault(require("json5")); | ||
const parse_json_1 = __importDefault(require("parse-json")); | ||
const strip_bom_1 = __importDefault(require("strip-bom")); | ||
async function readJson5File(filePath) { | ||
@@ -14,3 +15,3 @@ const text = await readFileWithoutBom(filePath); | ||
return { | ||
data: JSON5.parse(text), | ||
data: json5_1.default.parse(text), | ||
text, | ||
@@ -30,3 +31,3 @@ }; | ||
return { | ||
data: parseJson(text, filePath), | ||
data: (0, parse_json_1.default)(text, filePath), | ||
text, | ||
@@ -42,4 +43,4 @@ }; | ||
async function readFileWithoutBom(path) { | ||
return stripBom(await readFile(path, 'utf8')); | ||
return (0, strip_bom_1.default)(await fs_1.promises.readFile(path, 'utf8')); | ||
} | ||
//# sourceMappingURL=readFile.js.map |
{ | ||
"name": "@pnpm/read-project-manifest", | ||
"version": "1.1.7", | ||
"version": "2.0.0", | ||
"description": "Read a project manifest (called package.json in most cases)", | ||
@@ -8,3 +8,3 @@ "main": "lib/index.js", | ||
"engines": { | ||
"node": ">=10.16" | ||
"node": ">=12.17" | ||
}, | ||
@@ -20,3 +20,3 @@ "files": [ | ||
"prepublishOnly": "pnpm run compile", | ||
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build" | ||
"compile": "rimraf lib tsconfig.tsbuildinfo && tsc --build && pnpm run lint -- --fix" | ||
}, | ||
@@ -27,3 +27,2 @@ "repository": "https://github.com/pnpm/pnpm/blob/master/packages/read-project-manifest", | ||
], | ||
"author": "Zoltan Kochan <z@kochan.io> (https://www.kochan.io/)", | ||
"license": "MIT", | ||
@@ -35,19 +34,17 @@ "bugs": { | ||
"dependencies": { | ||
"@pnpm/error": "1.4.0", | ||
"@pnpm/types": "6.4.0", | ||
"@pnpm/write-project-manifest": "1.1.7", | ||
"@pnpm/error": "2.0.0", | ||
"@pnpm/types": "7.0.0", | ||
"@pnpm/write-project-manifest": "2.0.0", | ||
"detect-indent": "^6.0.0", | ||
"fast-deep-equal": "^3.1.3", | ||
"graceful-fs": "4.2.4", | ||
"is-windows": "^1.0.2", | ||
"json5": "^2.1.3", | ||
"parse-json": "^5.1.0", | ||
"read-yaml-file": "^2.0.0", | ||
"sort-keys": "^4.1.0", | ||
"read-yaml-file": "^2.1.0", | ||
"sort-keys": "^4.2.0", | ||
"strip-bom": "^4.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/graceful-fs": "^4.1.4", | ||
"@types/is-windows": "^1.0.0", | ||
"@types/json5": "^0.0.30", | ||
"@types/json5": "^2.2.0", | ||
"@types/parse-json": "^4.0.0", | ||
@@ -54,0 +51,0 @@ "tempy": "^1.0.0" |
@@ -25,2 +25,2 @@ # @pnpm/read-project-manifest | ||
MIT © [Zoltan Kochan](https://www.kochan.io/) | ||
MIT |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15157
11
4
267
1
3
1
+ Added@pnpm/error@2.0.0(transitive)
+ Added@pnpm/types@7.0.0(transitive)
+ Added@pnpm/write-project-manifest@2.0.0(transitive)
- Removedgraceful-fs@4.2.4
- Removed@pnpm/error@1.4.0(transitive)
- Removed@pnpm/types@6.4.0(transitive)
- Removed@pnpm/write-project-manifest@1.1.7(transitive)
- Removedany-promise@1.3.0(transitive)
- Removedgraceful-fs@4.2.4(transitive)
- Removedmz@2.7.0(transitive)
- Removedobject-assign@4.1.1(transitive)
- Removedthenify@3.3.1(transitive)
- Removedthenify-all@1.6.0(transitive)
Updated@pnpm/error@2.0.0
Updated@pnpm/types@7.0.0
Updatedread-yaml-file@^2.1.0
Updatedsort-keys@^4.2.0