pax_global_header 0000666 0000000 0000000 00000000064 14300735466 0014522 g ustar 00root root 0000000 0000000 52 comment=153678b91f53c1827c1e8e089f721fe7dcc33cd4
ini-3.0.1/ 0000775 0000000 0000000 00000000000 14300735466 0012302 5 ustar 00root root 0000000 0000000 ini-3.0.1/.commitlintrc.js 0000664 0000000 0000000 00000000553 14300735466 0015425 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
},
}
ini-3.0.1/.eslintrc.js 0000664 0000000 0000000 00000000545 14300735466 0014545 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)
module.exports = {
root: true,
extends: [
'@npmcli',
...localConfigs,
],
}
ini-3.0.1/.github/ 0000775 0000000 0000000 00000000000 14300735466 0013642 5 ustar 00root root 0000000 0000000 ini-3.0.1/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 14300735466 0015231 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
ini-3.0.1/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14300735466 0016025 5 ustar 00root root 0000000 0000000 ini-3.0.1/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 14300735466 0017335 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Bug
description: File a bug/issue
title: "[BUG]
"
labels: [ Bug, Needs Triage ]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false
ini-3.0.1/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 14300735466 0020015 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
ini-3.0.1/.github/dependabot.yml 0000664 0000000 0000000 00000000565 14300735466 0016500 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: daily
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
ini-3.0.1/.github/settings.yml 0000664 0000000 0000000 00000000055 14300735466 0016225 0 ustar 00root root 0000000 0000000 ---
_extends: '.github:npm-cli/settings.yml'
ini-3.0.1/.github/workflows/ 0000775 0000000 0000000 00000000000 14300735466 0015677 5 ustar 00root root 0000000 0000000 ini-3.0.1/.github/workflows/audit.yml 0000664 0000000 0000000 00000001370 14300735466 0017531 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Audit
on:
workflow_dispatch:
schedule:
# "At 01:00 on Monday" https://crontab.guru/#0_1_*_*_1
- cron: "0 1 * * 1"
jobs:
audit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- run: npm audit
ini-3.0.1/.github/workflows/ci.yml 0000664 0000000 0000000 00000005114 14300735466 0017016 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI
on:
workflow_dispatch:
pull_request:
branches:
- '*'
push:
branches:
- main
- latest
schedule:
# "At 02:00 on Monday" https://crontab.guru/#0_2_*_*_1
- cron: "0 2 * * 1"
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm run lint
test:
strategy:
fail-fast: false
matrix:
node-version:
- 12.13.0
- 12.x
- 14.15.0
- 14.x
- 16.0.0
- 16.x
platform:
- os: ubuntu-latest
shell: bash
- os: macos-latest
shell: bash
- os: windows-latest
shell: cmd
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Update to workable npm (windows)
# node 12 and 14 ship with npm@6, which is known to fail when updating itself in windows
if: matrix.platform.os == 'windows-latest' && (startsWith(matrix.node-version, '12.') || startsWith(matrix.node-version, '14.'))
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Update npm to 7
# If we do test on npm 10 it needs npm7
if: startsWith(matrix.node-version, '10.')
run: npm i --prefer-online --no-fund --no-audit -g npm@7
- name: Update npm to latest
if: ${{ !startsWith(matrix.node-version, '10.') }}
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- run: npm i --ignore-scripts --no-audit --no-fund
- run: npm test --ignore-scripts
ini-3.0.1/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000002001 14300735466 0021503 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: "CodeQL"
on:
push:
branches:
- main
- latest
pull_request:
# The branches below must be a subset of the branches above
branches:
- main
- latest
schedule:
# "At 03:00 on Monday" https://crontab.guru/#0_3_*_*_1
- cron: "0 3 * * 1"
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ javascript ]
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
ini-3.0.1/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000002641 14300735466 0021515 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Post Dependabot Actions
on: pull_request
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: write
jobs:
template-oss-apply:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- uses: actions/checkout@v3
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: npm install and commit
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr checkout ${{ github.event.pull_request.number }}
npm install --ignore-scripts --no-audit --no-fund
npm run template-oss-apply
git add .
git commit -am "chore: postinstall for dependabot template-oss PR"
git push
npm run lint
ini-3.0.1/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002143 14300735466 0021064 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Pull Request Linting
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
jobs:
check:
name: Check PR Title or Commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup git user
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- uses: actions/setup-node@v3
with:
node-version: 16.x
- name: Update npm to latest
run: npm i --prefer-online --no-fund --no-audit -g npm@latest
- run: npm -v
- name: Install deps
run: npm i -D @commitlint/cli @commitlint/config-conventional
- name: Check commits OR PR title
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: |
npx --offline commitlint -V --from origin/main --to ${{ github.event.pull_request.head.sha }} \
|| echo $PR_TITLE | npx --offline commitlint -V
ini-3.0.1/.github/workflows/release-please.yml 0000664 0000000 0000000 00000001314 14300735466 0021310 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release Please
on:
push:
branches:
- main
- latest
jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
changelog-types: >
[
{"type":"feat","section":"Features","hidden":false},
{"type":"fix","section":"Bug Fixes","hidden":false},
{"type":"docs","section":"Documentation","hidden":false},
{"type":"deps","section":"Dependencies","hidden":false},
{"type":"chore","hidden":true}
]
ini-3.0.1/.gitignore 0000664 0000000 0000000 00000000570 14300735466 0014274 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
# ignore everything in the root
/*
# keep these
!/.eslintrc.local.*
!**/.gitignore
!/docs/
!/tap-snapshots/
!/test/
!/map.js
!/scripts/
!/README*
!/LICENSE*
!/CHANGELOG*
!/.commitlintrc.js
!/.eslintrc.js
!/.github/
!/.gitignore
!/.npmrc
!/CODE_OF_CONDUCT.md
!/SECURITY.md
!/bin/
!/lib/
!/package.json
ini-3.0.1/.npmrc 0000664 0000000 0000000 00000000135 14300735466 0013421 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
ini-3.0.1/CHANGELOG.md 0000664 0000000 0000000 00000001462 14300735466 0014116 0 ustar 00root root 0000000 0000000 # Changelog
## [3.0.1](https://github.com/npm/ini/compare/v3.0.0...v3.0.1) (2022-08-22)
### Bug Fixes
* linting ([#166](https://github.com/npm/ini/issues/166)) ([5d9ab39](https://github.com/npm/ini/commit/5d9ab392643a93358e1d7595e8efb3d6d97d1181))
## [3.0.0](https://github.com/npm/ini/compare/v2.0.1...v3.0.0) (2022-04-05)
### ⚠ BREAKING CHANGES
* this drops support for node 10 and non-LTS versions of node 12 and node 14
### Bug Fixes
* replace deprecated String.prototype.substr() ([#155](https://github.com/npm/ini/issues/155)) ([e3a5d18](https://github.com/npm/ini/commit/e3a5d183269744f6b590c1a9916ef151de09bf64))
### Dependencies
* @npmcli/template-oss@3.2.2 ([#156](https://github.com/npm/ini/issues/156)) ([837831a](https://github.com/npm/ini/commit/837831a44ba1f04f62a9d0b369525a4f8d8116e9))
ini-3.0.1/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 14300735466 0015103 0 ustar 00root root 0000000 0000000
All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)
The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
ini-3.0.1/LICENSE 0000664 0000000 0000000 00000001375 14300735466 0013315 0 ustar 00root root 0000000 0000000 The ISC License
Copyright (c) Isaac Z. Schlueter 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.
ini-3.0.1/README.md 0000664 0000000 0000000 00000005306 14300735466 0013565 0 ustar 00root root 0000000 0000000 An ini format parser and serializer for node.
Sections are treated as nested objects. Items before the first
heading are saved on the object directly.
## Usage
Consider an ini-file `config.ini` that looks like this:
```ini
; this comment is being ignored
scope = global
[database]
user = dbuser
password = dbpassword
database = use_this_database
[paths.default]
datadir = /var/lib/data
array[] = first value
array[] = second value
array[] = third value
```
You can read, manipulate and write the ini-file like so:
```js
var fs = require('fs')
, ini = require('ini')
var config = ini.parse(fs.readFileSync('./config.ini', 'utf-8'))
config.scope = 'local'
config.database.database = 'use_another_database'
config.paths.default.tmpdir = '/tmp'
delete config.paths.default.datadir
config.paths.default.array.push('fourth value')
fs.writeFileSync('./config_modified.ini', ini.stringify(config, { section: 'section' }))
```
This will result in a file called `config_modified.ini` being written
to the filesystem with the following content:
```ini
[section]
scope=local
[section.database]
user=dbuser
password=dbpassword
database=use_another_database
[section.paths.default]
tmpdir=/tmp
array[]=first value
array[]=second value
array[]=third value
array[]=fourth value
```
## API
### decode(inistring)
Decode the ini-style formatted `inistring` into a nested object.
### parse(inistring)
Alias for `decode(inistring)`
### encode(object, [options])
Encode the object `object` into an ini-style formatted string. If the
optional parameter `section` is given, then all top-level properties
of the object are put into this section and the `section`-string is
prepended to all sub-sections, see the usage example above.
The `options` object may contain the following:
* `section` A string which will be the first `section` in the encoded
ini data. Defaults to none.
* `whitespace` Boolean to specify whether to put whitespace around the
`=` character. By default, whitespace is omitted, to be friendly to
some persnickety old parsers that don't tolerate it well. But some
find that it's more human-readable and pretty with the whitespace.
For backwards compatibility reasons, if a `string` options is passed
in, then it is assumed to be the `section` value.
### stringify(object, [options])
Alias for `encode(object, [options])`
### safe(val)
Escapes the string `val` such that it is safe to be used as a key or
value in an ini-file. Basically escapes quotes. For example
```js
ini.safe('"unsafe string"')
```
would result in
"\"unsafe string\""
### unsafe(val)
Unescapes the string `val`
ini-3.0.1/SECURITY.md 0000664 0000000 0000000 00000000246 14300735466 0014075 0 ustar 00root root 0000000 0000000
Please send vulnerability reports through [hackerone](https://hackerone.com/github).
ini-3.0.1/lib/ 0000775 0000000 0000000 00000000000 14300735466 0013050 5 ustar 00root root 0000000 0000000 ini-3.0.1/lib/ini.js 0000664 0000000 0000000 00000012340 14300735466 0014165 0 ustar 00root root 0000000 0000000 const { hasOwnProperty } = Object.prototype
/* istanbul ignore next */
const eol = typeof process !== 'undefined' &&
process.platform === 'win32' ? '\r\n' : '\n'
const encode = (obj, opt) => {
const children = []
let out = ''
if (typeof opt === 'string') {
opt = {
section: opt,
whitespace: false,
}
} else {
opt = opt || Object.create(null)
opt.whitespace = opt.whitespace === true
}
const separator = opt.whitespace ? ' = ' : '='
for (const k of Object.keys(obj)) {
const val = obj[k]
if (val && Array.isArray(val)) {
for (const item of val) {
out += safe(k + '[]') + separator + safe(item) + eol
}
} else if (val && typeof val === 'object') {
children.push(k)
} else {
out += safe(k) + separator + safe(val) + eol
}
}
if (opt.section && out.length) {
out = '[' + safe(opt.section) + ']' + eol + out
}
for (const k of children) {
const nk = dotSplit(k).join('\\.')
const section = (opt.section ? opt.section + '.' : '') + nk
const { whitespace } = opt
const child = encode(obj[k], {
section,
whitespace,
})
if (out.length && child.length) {
out += eol
}
out += child
}
return out
}
const dotSplit = str =>
str.replace(/\1/g, '\u0002LITERAL\\1LITERAL\u0002')
.replace(/\\\./g, '\u0001')
.split(/\./)
.map(part =>
part.replace(/\1/g, '\\.')
.replace(/\2LITERAL\\1LITERAL\2/g, '\u0001'))
const decode = str => {
const out = Object.create(null)
let p = out
let section = null
// section |key = value
const re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i
const lines = str.split(/[\r\n]+/g)
for (const line of lines) {
if (!line || line.match(/^\s*[;#]/)) {
continue
}
const match = line.match(re)
if (!match) {
continue
}
if (match[1] !== undefined) {
section = unsafe(match[1])
if (section === '__proto__') {
// not allowed
// keep parsing the section, but don't attach it.
p = Object.create(null)
continue
}
p = out[section] = out[section] || Object.create(null)
continue
}
const keyRaw = unsafe(match[2])
const isArray = keyRaw.length > 2 && keyRaw.slice(-2) === '[]'
const key = isArray ? keyRaw.slice(0, -2) : keyRaw
if (key === '__proto__') {
continue
}
const valueRaw = match[3] ? unsafe(match[4]) : true
const value = valueRaw === 'true' ||
valueRaw === 'false' ||
valueRaw === 'null' ? JSON.parse(valueRaw)
: valueRaw
// Convert keys with '[]' suffix to an array
if (isArray) {
if (!hasOwnProperty.call(p, key)) {
p[key] = []
} else if (!Array.isArray(p[key])) {
p[key] = [p[key]]
}
}
// safeguard against resetting a previously defined
// array by accidentally forgetting the brackets
if (Array.isArray(p[key])) {
p[key].push(value)
} else {
p[key] = value
}
}
// {a:{y:1},"a.b":{x:2}} --> {a:{y:1,b:{x:2}}}
// use a filter to return the keys that have to be deleted.
const remove = []
for (const k of Object.keys(out)) {
if (!hasOwnProperty.call(out, k) ||
typeof out[k] !== 'object' ||
Array.isArray(out[k])) {
continue
}
// see if the parent section is also an object.
// if so, add it to that, and mark this one for deletion
const parts = dotSplit(k)
p = out
const l = parts.pop()
const nl = l.replace(/\\\./g, '.')
for (const part of parts) {
if (part === '__proto__') {
continue
}
if (!hasOwnProperty.call(p, part) || typeof p[part] !== 'object') {
p[part] = Object.create(null)
}
p = p[part]
}
if (p === out && nl === l) {
continue
}
p[nl] = out[k]
remove.push(k)
}
for (const del of remove) {
delete out[del]
}
return out
}
const isQuoted = val => {
return (val.startsWith('"') && val.endsWith('"')) ||
(val.startsWith("'") && val.endsWith("'"))
}
const safe = val => {
if (
typeof val !== 'string' ||
val.match(/[=\r\n]/) ||
val.match(/^\[/) ||
(val.length > 1 && isQuoted(val)) ||
val !== val.trim()
) {
return JSON.stringify(val)
}
return val.split(';').join('\\;').split('#').join('\\#')
}
const unsafe = (val, doUnesc) => {
val = (val || '').trim()
if (isQuoted(val)) {
// remove the single quotes before calling JSON.parse
if (val.charAt(0) === "'") {
val = val.slice(1, -1)
}
try {
val = JSON.parse(val)
} catch {
// ignore errors
}
} else {
// walk the val to find the first not-escaped ; character
let esc = false
let unesc = ''
for (let i = 0, l = val.length; i < l; i++) {
const c = val.charAt(i)
if (esc) {
if ('\\;#'.indexOf(c) !== -1) {
unesc += c
} else {
unesc += '\\' + c
}
esc = false
} else if (';#'.indexOf(c) !== -1) {
break
} else if (c === '\\') {
esc = true
} else {
unesc += c
}
}
if (esc) {
unesc += '\\'
}
return unesc.trim()
}
return val
}
module.exports = {
parse: decode,
decode,
stringify: encode,
encode,
safe,
unsafe,
}
ini-3.0.1/package.json 0000664 0000000 0000000 00000002026 14300735466 0014570 0 ustar 00root root 0000000 0000000 {
"author": "GitHub Inc.",
"name": "ini",
"description": "An ini encoder/decoder for node",
"version": "3.0.1",
"repository": {
"type": "git",
"url": "https://github.com/npm/ini.git"
},
"main": "lib/ini.js",
"scripts": {
"eslint": "eslint",
"lint": "eslint \"**/*.js\"",
"lintfix": "npm run lint -- --fix",
"test": "tap",
"snap": "tap",
"posttest": "npm run lint",
"preversion": "npm test",
"postversion": "npm publish",
"prepublishOnly": "git push origin --follow-tags",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force"
},
"devDependencies": {
"@npmcli/eslint-config": "^3.0.1",
"@npmcli/template-oss": "3.5.0",
"tap": "^16.0.1"
},
"license": "ISC",
"files": [
"bin/",
"lib/"
],
"engines": {
"node": "^12.13.0 || ^14.15.0 || >=16.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "3.5.0"
}
}
ini-3.0.1/tap-snapshots/ 0000775 0000000 0000000 00000000000 14300735466 0015106 5 ustar 00root root 0000000 0000000 ini-3.0.1/tap-snapshots/test/ 0000775 0000000 0000000 00000000000 14300735466 0016065 5 ustar 00root root 0000000 0000000 ini-3.0.1/tap-snapshots/test/foo.js.test.cjs 0000664 0000000 0000000 00000004706 14300735466 0020751 0 ustar 00root root 0000000 0000000 /* IMPORTANT
* This snapshot file is auto-generated, but designed for humans.
* It should be checked into source control and tracked carefully.
* Re-generate by setting TAP_SNAPSHOT=1 and running tests.
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/foo.js TAP decode from file > must match snapshot 1`] = `
Null Object {
" xa n p ": String(
"\\r
yoyoyo\\r\\r
),
"[disturbing]": "hey you never know",
"a": Null Object {
"[]": "a square?",
"av": "a val",
"b": Null Object {
"c": Null Object {
"e": "1",
"j": "2",
},
},
"cr": Array [
"four",
"eight",
],
"e": "{ o: p, a: { av: a val, b: { c: { e: \\"this [value]\\" } } } }",
"j": "\\"{ o: \\"p\\", a: { av: \\"a val\\", b: { c: { e: \\"this [value]\\" } } } }\\"",
},
"a with spaces": "b c",
"ar": Array [
"one",
"three",
"this is included",
],
"br": "warm",
"eq": "eq=eq",
"false": false,
"null": null,
"o": "p",
"s": "something",
"s1": "\\"something'",
"s2": "something else",
"s3": "",
"s4": "",
"s5": " ",
"s6": " a ",
"s7": true,
"true": true,
"undefined": "undefined",
"x.y.z": Null Object {
"a.b.c": Null Object {
"a.b.c": "abc",
"nocomment": "this; this is not a comment",
"noHashComment": "this# this is not a comment",
},
"x.y.z": "xyz",
},
"zr": Array [
"deedee",
],
}
`
exports[`test/foo.js TAP encode from data > must match snapshot 1`] = `
o=p
a with spaces=b c
" xa n p "="\\"\\r\\nyoyoyo\\r\\r\\n"
"[disturbing]"=hey you never know
s=something
s1="something'
s2=something else
s3=
s4=
s5=" "
s6=" a "
s7=true
true=true
false=false
null=null
undefined=undefined
zr[]=deedee
ar[]=one
ar[]=three
ar[]=this is included
br=warm
eq="eq=eq"
[a]
av=a val
e={ o: p, a: { av: a val, b: { c: { e: "this [value]" } } } }
j="\\"{ o: \\"p\\", a: { av: \\"a val\\", b: { c: { e: \\"this [value]\\" } } } }\\""
"[]"=a square?
cr[]=four
cr[]=eight
[a.b.c]
e=1
j=2
[x\\.y\\.z]
x.y.z=xyz
[x\\.y\\.z.a\\.b\\.c]
a.b.c=abc
nocomment=this\\; this is not a comment
noHashComment=this\\# this is not a comment
`
exports[`test/foo.js TAP encode with option > must match snapshot 1`] = `
[prefix.log]
type=file
[prefix.log.level]
label=debug
value=10
`
exports[`test/foo.js TAP encode with whitespace > must match snapshot 1`] = `
[log]
type = file
[log.level]
label = debug
value = 10
`
ini-3.0.1/test/ 0000775 0000000 0000000 00000000000 14300735466 0013261 5 ustar 00root root 0000000 0000000 ini-3.0.1/test/bar.js 0000664 0000000 0000000 00000000711 14300735466 0014362 0 ustar 00root root 0000000 0000000 // test that parse(stringify(obj)
var ini = require('../')
var test = require('tap').test
var data = {
number: { count: 10 },
string: { drink: 'white russian' },
boolean: { isTrue: true },
'nested boolean': { theDude: { abides: true, rugCount: 1 } },
}
test('parse(stringify(x)) is same as x', function (t) {
for (var k in data) {
var s = ini.stringify(data[k])
t.comment(s, data[k])
t.same(ini.parse(s), data[k])
}
t.end()
})
ini-3.0.1/test/fixtures/ 0000775 0000000 0000000 00000000000 14300735466 0015132 5 ustar 00root root 0000000 0000000 ini-3.0.1/test/fixtures/foo.ini 0000664 0000000 0000000 00000003203 14300735466 0016414 0 ustar 00root root 0000000 0000000 o = p
a with spaces = b c
; wrap in quotes to JSON-decode and preserve spaces
" xa n p " = "\"\r\nyoyoyo\r\r\n"
; wrap in quotes to get a key with a bracket, not a section.
"[disturbing]" = hey you never know
; Test single quotes
s = 'something'
; Test mixing quotes
s1 = "something'
; Test double quotes
s2 = "something else"
; Test blank value
s3 =
; Test value with only spaces
s4 =
; Test quoted value with only spaces
s5 = ' '
; Test quoted value with leading and trailing spaces
s6 = ' a '
; Test no equal sign
s7
; Test bool(true)
true = true
; Test bool(false)
false = false
; Test null
null = null
; Test undefined
undefined = undefined
; Test arrays
zr[] = deedee
ar[] = one
ar[] = three
; This should be included in the array
ar = this is included
; Test resetting of a value (and not turn it into an array)
br = cold
br = warm
eq = "eq=eq"
; a section
[a]
av = a val
e = { o: p, a: { av: a val, b: { c: { e: "this [value]" } } } }
j = "{ o: "p", a: { av: "a val", b: { c: { e: "this [value]" } } } }"
"[]" = a square?
; Nested array
cr[] = four
cr[] = eight
; nested child without middle parent
; should create otherwise-empty a.b
[a.b.c]
e = 1
j = 2
; dots in the section name should be literally interpreted
[x\.y\.z]
x.y.z = xyz
[x\.y\.z.a\.b\.c]
a.b.c = abc
; this next one is not a comment! it's escaped!
nocomment = this\; this is not a comment
# Support the use of the number sign (#) as an alternative to the semicolon for indicating comments.
# http://en.wikipedia.org/wiki/INI_file#Comments
# this next one is not a comment! it's escaped!
noHashComment = this\# this is not a comment
ini-3.0.1/test/foo.js 0000664 0000000 0000000 00000002300 14300735466 0014375 0 ustar 00root root 0000000 0000000 const i = require('../')
const tap = require('tap')
const test = tap.test
const fs = require('fs')
const path = require('path')
const fixture = path.resolve(__dirname, './fixtures/foo.ini')
const data = fs.readFileSync(fixture, 'utf8')
tap.cleanSnapshot = s => s.replace(/\r\n/g, '\n')
test('decode from file', function (t) {
const d = i.decode(data)
t.matchSnapshot(d)
t.end()
})
test('encode from data', function (t) {
const d = i.decode(data)
const e = i.encode(d)
t.matchSnapshot(e)
t.end()
})
test('never a blank first or last line', function (t) {
const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj)
t.not(e.slice(0, 1), '\n', 'Never a blank first line')
t.not(e.slice(-2), '\n\n', 'Never a blank final line')
t.end()
})
test('encode with option', function (t) {
const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj, { section: 'prefix' })
t.matchSnapshot(e)
t.end()
})
test('encode with whitespace', function (t) {
const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj, { whitespace: true })
t.matchSnapshot(e)
t.end()
})
ini-3.0.1/test/proto.js 0000664 0000000 0000000 00000002642 14300735466 0014766 0 ustar 00root root 0000000 0000000 /* eslint no-proto: "off" */
var ini = require('../')
var t = require('tap')
var data = `
__proto__ = quux
constructor.prototype.foo = asdfasdf
foo = baz
[__proto__]
foo = bar
[other]
foo = asdf
[kid.__proto__.foo]
foo = kid
[arrproto]
hello = snyk
__proto__[] = you did a good job
__proto__[] = so you deserve arrays
thanks = true
[ctor.constructor.prototype]
foo = asdfasdf
`
var res = ini.parse(data)
t.same(res, Object.assign(Object.create(null), {
'constructor.prototype.foo': 'asdfasdf',
foo: 'baz',
other: Object.assign(Object.create(null), {
foo: 'asdf',
}),
kid: Object.assign(Object.create(null), {
foo: Object.assign(Object.create(null), {
foo: 'kid',
}),
}),
arrproto: Object.assign(Object.create(null), {
hello: 'snyk',
thanks: true,
}),
ctor: Object.assign(Object.create(null), {
constructor: Object.assign(Object.create(null), {
prototype: Object.assign(Object.create(null), {
foo: 'asdfasdf',
}),
}),
}),
}))
t.equal(res.__proto__, undefined)
t.equal(res.kid.__proto__, undefined)
t.equal(res.kid.foo.__proto__, undefined)
t.equal(res.arrproto.__proto__, undefined)
t.equal(Object.prototype.foo, undefined)
t.equal(Object.prototype[0], undefined)
t.equal(Object.prototype['0'], undefined)
t.equal(Object.prototype[1], undefined)
t.equal(Object.prototype['1'], undefined)
t.equal(Array.prototype[0], undefined)
t.equal(Array.prototype[1], undefined)
ini-3.0.1/test/win32.js 0000664 0000000 0000000 00000001060 14300735466 0014556 0 ustar 00root root 0000000 0000000 var t = require('tap')
Object.defineProperty(process, 'platform', { value: 'win32' })
const ini = require('..')
const res = ini.encode({ foo: { bar: 'baz' } })
t.equal(res, '[foo]\r\nbar=baz\r\n')
t.equal(ini.encode({ bar: 'baz' }, 'foo'), '[foo]\r\nbar=baz\r\n')
t.same(ini.decode('=just junk!\r\n[foo]\r\nbar\r\n'),
{ foo: { bar: true } })
t.same(ini.decode('[x]\r\ny=1\r\ny[]=2\r\n'), {
x: {
y: [1, 2],
},
})
t.equal(ini.unsafe(''), '')
t.equal(ini.unsafe('x;y'), 'x')
t.equal(ini.unsafe('x # y'), 'x')
t.equal(ini.unsafe('x "\\'), 'x "\\')