diff options
| author | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-01 20:05:50 +0100 | 
|---|---|---|
| committer | Nevena Bojovic <nenabojov@gmail.com> | 2022-03-01 20:05:50 +0100 | 
| commit | 291803c31f829fe0d32bb3207bc11def95a7408c (patch) | |
| tree | c7d43107d79291b19d8c9eceefbe91c9f9a52acf /sandbox/testAppNevena/Front/node_modules/read-package-json-fast | |
| parent | 1fa69862057db4db53cfda5be9c24b4228ef63f7 (diff) | |
Urađena test aplikacija. Povezan front i back.
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/read-package-json-fast')
4 files changed, 264 insertions, 0 deletions
| diff --git a/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/LICENSE b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/LICENSE new file mode 100644 index 00000000..20a47625 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/LICENSE @@ -0,0 +1,15 @@ +The ISC License + +Copyright (c) npm, Inc. and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR +IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/README.md b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/README.md new file mode 100644 index 00000000..5ab6adbe --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/README.md @@ -0,0 +1,79 @@ +# read-package-json-fast + +Like [`read-package-json`](http://npm.im/read-package-json), but faster and +more accepting of "missing" data. + +This is only suitable for reading package.json files in a node_modules +tree, since it doesn't do the various cleanups, normalization, and warnings +that are beneficial at the root level in a package being published. + +## USAGE + +```js +const rpj = require('read-package-json-fast') + +// typical promisey type API +rpj('/path/to/package.json') +  .then(data => ...) +  .catch(er => ...) + +// or just normalize a package manifest +const normalized = rpj.normalize(packageJsonObject) +``` + +Errors raised from parsing will use +[`json-parse-even-better-errors`](http://npm.im/json-parse-even-better-errors), +so they'll be of type `JSONParseError` and have a `code: 'EJSONPARSE'` +property.  Errors will also always have a `path` member referring to the +path originally passed into the function. + +## Indentation + +To preserve indentation when the file is saved back to disk, use +`data[Symbol.for('indent')]` as the third argument to `JSON.stringify`, and +if you want to preserve windows `\r\n` newlines, replace the `\n` chars in +the string with `data[Symbol.for('newline')]`. + +For example: + +```js +const data = await readPackageJsonFast('./package.json') +const indent = Symbol.for('indent') +const newline = Symbol.for('newline') +// .. do some stuff to the data .. +const string = JSON.stringify(data, null, data[indent]) + '\n' +const eolFixed = data[newline] === '\n' ? string +  : string.replace(/\n/g, data[newline]) +await writeFile('./package.json', eolFixed) +``` + +Indentation is determined by looking at the whitespace between the initial +`{` and the first `"` that follows it.  If you have lots of weird +inconsistent indentation, then it won't track that or give you any way to +preserve it.  Whether this is a bug or a feature is debatable ;) + +## WHAT THIS MODULE DOES + +- Parse JSON +- Normalize `bundledDependencies`/`bundleDependencies` naming to just +  `bundleDependencies` (without the extra `d`) +- Handle `true`, `false`, or object values passed to `bundleDependencies` +- Normalize `funding: <string>` to `funding: { url: <string> }` +- Remove any `scripts` members that are not a string value. +- Normalize a string `bin` member to `{ [name]: bin }`. +- Fold `optionalDependencies` into `dependencies`. +- Set the `_id` property if name and version are set.  (This is +  load-bearing in a few places within the npm CLI.) + +## WHAT THIS MODULE DOES NOT DO + +- Warn about invalid/missing name, version, repository, etc. +- Extract a description from the `README.md` file, or attach the readme to +  the parsed data object. +- Read the `HEAD` value out of the `.git` folder. +- Warn about potentially typo'ed scripts (eg, `tset` instead of `test`) +- Check to make sure that all the files in the `files` field exist and are +  valid files. +- Fix bundleDependencies that are not listed in `dependencies`. +- Fix `dependencies` fields that are not strictly objects of string values. +- Anything involving the `directories` field (ie, bins, mans, and so on). diff --git a/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/index.js b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/index.js new file mode 100644 index 00000000..646ff7df --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/index.js @@ -0,0 +1,136 @@ +const {promisify} = require('util') +const fs = require('fs') +const readFile = promisify(fs.readFile) +const lstat = promisify(fs.lstat) +const readdir = promisify(fs.readdir) +const parse = require('json-parse-even-better-errors') + +const { resolve, dirname, join, relative } = require('path') + +const rpj = path => readFile(path, 'utf8') +  .then(data => readBinDir(path, normalize(stripUnderscores(parse(data))))) +  .catch(er => { +    er.path = path +    throw er +  }) + +const normalizePackageBin = require('npm-normalize-package-bin') + +// load the directories.bin folder as a 'bin' object +const readBinDir = async (path, data) => { +  if (data.bin) +    return data + +  const m = data.directories && data.directories.bin +  if (!m || typeof m !== 'string') +    return data + +  // cut off any monkey business, like setting directories.bin +  // to ../../../etc/passwd or /etc/passwd or something like that. +  const root = dirname(path) +  const dir = join('.', join('/', m)) +  data.bin = await walkBinDir(root, dir, {}) +  return data +} + +const walkBinDir = async (root, dir, obj) => { +  const entries = await readdir(resolve(root, dir)).catch(() => []) +  for (const entry of entries) { +    if (entry.charAt(0) === '.') +      continue +    const f = resolve(root, dir, entry) +    // ignore stat errors, weird file types, symlinks, etc. +    const st = await lstat(f).catch(() => null) +    if (!st) +      continue +    else if (st.isFile()) +      obj[entry] = relative(root, f) +    else if (st.isDirectory()) +      await walkBinDir(root, join(dir, entry), obj) +  } +  return obj +} + +// do not preserve _fields set in files, they are sus +const stripUnderscores = data => { +  for (const key of Object.keys(data).filter(k => /^_/.test(k))) +    delete data[key] +  return data +} + +const normalize = data => { +  add_id(data) +  fixBundled(data) +  pruneRepeatedOptionals(data) +  fixScripts(data) +  fixFunding(data) +  normalizePackageBin(data) +  return data +} + +rpj.normalize = normalize + +const add_id = data => { +  if (data.name && data.version) +    data._id = `${data.name}@${data.version}` +  return data +} + +// it was once common practice to list deps both in optionalDependencies +// and in dependencies, to support npm versions that did not know abbout +// optionalDependencies.  This is no longer a relevant need, so duplicating +// the deps in two places is unnecessary and excessive. +const pruneRepeatedOptionals = data => { +  const od = data.optionalDependencies +  const dd = data.dependencies || {} +  if (od && typeof od === 'object') { +    for (const name of Object.keys(od)) { +      delete dd[name] +    } +  } +  if (Object.keys(dd).length === 0) +    delete data.dependencies +  return data +} + +const fixBundled = data => { +  const bdd = data.bundledDependencies +  const bd = data.bundleDependencies === undefined ? bdd +    : data.bundleDependencies + +  if (bd === false) +    data.bundleDependencies = [] +  else if (bd === true) +    data.bundleDependencies = Object.keys(data.dependencies || {}) +  else if (bd && typeof bd === 'object') { +    if (!Array.isArray(bd)) +      data.bundleDependencies = Object.keys(bd) +    else +      data.bundleDependencies = bd +  } else +    delete data.bundleDependencies + +  delete data.bundledDependencies +  return data +} + +const fixScripts = data => { +  if (!data.scripts || typeof data.scripts !== 'object') { +    delete data.scripts +    return data +  } + +  for (const [name, script] of Object.entries(data.scripts)) { +    if (typeof script !== 'string') +      delete data.scripts[name] +  } +  return data +} + +const fixFunding = data => { +  if (data.funding && typeof data.funding === 'string') +    data.funding = { url: data.funding } +  return data +} + +module.exports = rpj diff --git a/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/package.json b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/package.json new file mode 100644 index 00000000..c3a9f7dc --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/read-package-json-fast/package.json @@ -0,0 +1,34 @@ +{ +  "name": "read-package-json-fast", +  "version": "2.0.3", +  "description": "Like read-package-json, but faster", +  "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)", +  "license": "ISC", +  "scripts": { +    "test": "tap", +    "snap": "tap", +    "preversion": "npm test", +    "postversion": "npm publish", +    "postpublish": "git push origin --follow-tags" +  }, +  "engines": { +    "node": ">=10" +  }, +  "tap": { +    "check-coverage": true +  }, +  "devDependencies": { +    "tap": "^15.0.9" +  }, +  "dependencies": { +    "json-parse-even-better-errors": "^2.3.0", +    "npm-normalize-package-bin": "^1.0.1" +  }, +  "repository": { +    "type": "git", +    "url": "git+https://github.com/npm/read-package-json-fast.git" +  }, +  "files": [ +    "index.js" +  ] +} | 
