Skip to content

Commit

Permalink
deps: @npmcli/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Jun 27, 2024
1 parent ac937d4 commit 29204c8
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 20 deletions.
19 changes: 7 additions & 12 deletions node_modules/@npmcli/package-json/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const { readFile, writeFile } = require('fs/promises')
const { resolve } = require('path')
const { readFile, writeFile } = require('node:fs/promises')
const { resolve } = require('node:path')
const parseJSON = require('json-parse-even-better-errors')

const updateDeps = require('./update-dependencies.js')
const updateScripts = require('./update-scripts.js')
const updateWorkspaces = require('./update-workspaces.js')
const normalize = require('./normalize.js')

const parseJSON = require('json-parse-even-better-errors')
const { read, parse } = require('./read-package.js')

// a list of handy specialized helper functions that take
// care of special cases that are handled by the npm cli
Expand Down Expand Up @@ -126,9 +127,8 @@ class PackageJson {
this.#path = path
let parseErr
try {
this.#readFileContent = await readFile(this.filename, 'utf8')
this.#readFileContent = await read(this.filename)
} catch (err) {
err.message = `Could not read package.json: ${err}`
if (!parseIndex) {
throw err
}
Expand Down Expand Up @@ -158,12 +158,7 @@ class PackageJson {

// Load data from a JSON string/buffer
fromJSON (data) {
try {
this.#manifest = parseJSON(data)
} catch (err) {
err.message = `Invalid package.json: ${err}`
throw err
}
this.#manifest = parse(data)
return this
}

Expand Down
4 changes: 2 additions & 2 deletions node_modules/@npmcli/package-json/lib/normalize.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const valid = require('semver/functions/valid')
const clean = require('semver/functions/clean')
const fs = require('fs/promises')
const path = require('path')
const fs = require('node:fs/promises')
const path = require('node:path')
const { log } = require('proc-log')

/**
Expand Down
39 changes: 39 additions & 0 deletions node_modules/@npmcli/package-json/lib/read-package.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// This is JUST the code needed to open a package.json file and parse it.
// It's isolated out so that code needing to parse a package.json file can do so in the same way as this module does, without needing to require the whole module, or needing to require the underlying parsing library.

const { readFile } = require('fs/promises')
const parseJSON = require('json-parse-even-better-errors')

async function read (filename) {
try {
const data = await readFile(filename, 'utf8')
return data
} catch (err) {
err.message = `Could not read package.json: ${err}`
throw err
}
}

function parse (data) {
try {
const content = parseJSON(data)
return content
} catch (err) {
err.message = `Invalid package.json: ${err}`
throw err
}
}

// This is what most external libs will use.
// PackageJson will call read and parse separately
async function readPackage (filename) {
const data = await read(filename)
const content = parse(data)
return content
}

module.exports = {
read,
parse,
readPackage,
}
2 changes: 1 addition & 1 deletion node_modules/@npmcli/package-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/package-json",
"version": "5.1.1",
"version": "5.2.0",
"description": "Programmatic API to update package.json",
"main": "lib/index.js",
"files": [
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"@npmcli/config": "^8.3.3",
"@npmcli/fs": "^3.1.1",
"@npmcli/map-workspaces": "^3.0.6",
"@npmcli/package-json": "^5.1.1",
"@npmcli/package-json": "^5.2.0",
"@npmcli/promise-spawn": "^7.0.2",
"@npmcli/redact": "^2.0.0",
"@npmcli/run-script": "^8.1.0",
Expand Down Expand Up @@ -1716,9 +1716,9 @@
}
},
"node_modules/@npmcli/package-json": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-5.1.1.tgz",
"integrity": "sha512-uTq5j/UqUzbOaOxVy+osfOhpqOiLfUZ0Ut33UbcyyAPJbZcJsf4Mrsyb8r58FoIFlofw0iOFsuCA/oDK14VDJQ==",
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-5.2.0.tgz",
"integrity": "sha512-qe/kiqqkW0AGtvBjL8TJKZk/eBBSpnJkUWvHdQ9jM2lKHXRYYJuyNpJPlJw3c8QjC2ow6NZYiLExhUaeJelbxQ==",
"inBundle": true,
"license": "ISC",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@npmcli/config": "^8.3.3",
"@npmcli/fs": "^3.1.1",
"@npmcli/map-workspaces": "^3.0.6",
"@npmcli/package-json": "^5.1.1",
"@npmcli/package-json": "^5.2.0",
"@npmcli/promise-spawn": "^7.0.2",
"@npmcli/redact": "^2.0.0",
"@npmcli/run-script": "^8.1.0",
Expand Down

0 comments on commit 29204c8

Please sign in to comment.