pax_global_header 0000666 0000000 0000000 00000000064 15177426216 0014525 g ustar 00root root 0000000 0000000 52 comment=847941ced4fb8465f0ccb383fd8b15c7e5aa09fc
npm-ini-847941c/ 0000775 0000000 0000000 00000000000 15177426216 0013361 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.commitlintrc.js 0000664 0000000 0000000 00000000566 15177426216 0016510 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],
'body-max-line-length': [0],
'footer-max-line-length': [0],
},
}
npm-ini-847941c/.eslintrc.js 0000664 0000000 0000000 00000000623 15177426216 0015621 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,
ignorePatterns: [
'tap-testdir*/',
],
extends: [
'@npmcli',
...localConfigs,
],
}
npm-ini-847941c/.github/ 0000775 0000000 0000000 00000000000 15177426216 0014721 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/CODEOWNERS 0000664 0000000 0000000 00000000152 15177426216 0016312 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team @npm/cli-triage
npm-ini-847941c/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 15177426216 0017104 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 15177426216 0020414 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
npm-ini-847941c/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 15177426216 0021074 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
npm-ini-847941c/.github/actions/ 0000775 0000000 0000000 00000000000 15177426216 0016361 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/actions/create-check/ 0000775 0000000 0000000 00000000000 15177426216 0020677 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/actions/create-check/action.yml 0000664 0000000 0000000 00000002720 15177426216 0022700 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: 'Create Check'
inputs:
name:
required: true
token:
required: true
sha:
required: true
check-name:
default: ''
outputs:
check-id:
value: ${{ steps.create-check.outputs.check_id }}
runs:
using: "composite"
steps:
- name: Get Workflow Job
uses: actions/github-script@v7
id: workflow
env:
JOB_NAME: "${{ inputs.name }}"
SHA: "${{ inputs.sha }}"
with:
result-encoding: string
script: |
const { repo: { owner, repo}, runId, serverUrl } = context
const { JOB_NAME, SHA } = process.env
const job = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: runId,
per_page: 100
}).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME)))
return [
`This check is assosciated with ${serverUrl}/${owner}/${repo}/commit/${SHA}.`,
'Run logs:',
job?.html_url || `could not be found for a job ending with: "${JOB_NAME}"`,
].join(' ')
- name: Create Check
uses: LouisBrunner/checks-action@v1.6.0
id: create-check
with:
token: ${{ inputs.token }}
sha: ${{ inputs.sha }}
status: in_progress
name: ${{ inputs.check-name || inputs.name }}
output: |
{"summary":"${{ steps.workflow.outputs.result }}"}
npm-ini-847941c/.github/actions/install-latest-npm/ 0000775 0000000 0000000 00000000000 15177426216 0022111 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/actions/install-latest-npm/action.yml 0000664 0000000 0000000 00000003406 15177426216 0024114 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: 'Install Latest npm'
description: 'Install the latest version of npm compatible with the Node version'
inputs:
node:
description: 'Current Node version'
required: true
runs:
using: "composite"
steps:
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
if: |
runner.os == 'Windows' && (
startsWith(inputs.node, 'v10.') ||
startsWith(inputs.node, 'v12.') ||
startsWith(inputs.node, 'v14.')
)
shell: cmd
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: Install Latest npm
shell: bash
env:
NODE_VERSION: ${{ inputs.node }}
working-directory: ${{ runner.temp }}
run: |
MATCH=""
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
echo "node@$NODE_VERSION"
for SPEC in ${SPECS[@]}; do
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
MATCH=$SPEC
echo "Found compatible version: npm@$MATCH"
break
fi
done
if [ -z $MATCH ]; then
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
exit 1
fi
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
- name: npm Version
shell: bash
run: npm -v
npm-ini-847941c/.github/dependabot.yml 0000664 0000000 0000000 00000000656 15177426216 0017560 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
target-branch: "main"
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
open-pull-requests-limit: 10
npm-ini-847941c/.github/matchers/ 0000775 0000000 0000000 00000000000 15177426216 0016527 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/matchers/tap.json 0000664 0000000 0000000 00000001204 15177426216 0020203 0 ustar 00root root 0000000 0000000 {
"//@npmcli/template-oss": "This file is automatically added by @npmcli/template-oss. Do not edit.",
"problemMatcher": [
{
"owner": "tap",
"pattern": [
{
"regexp": "^\\s*not ok \\d+ - (.*)",
"message": 1
},
{
"regexp": "^\\s*---"
},
{
"regexp": "^\\s*at:"
},
{
"regexp": "^\\s*line:\\s*(\\d+)",
"line": 1
},
{
"regexp": "^\\s*column:\\s*(\\d+)",
"column": 1
},
{
"regexp": "^\\s*file:\\s*(.*)",
"file": 1
}
]
}
]
}
npm-ini-847941c/.github/settings.yml 0000664 0000000 0000000 00000001377 15177426216 0017314 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
repository:
allow_merge_commit: false
allow_rebase_merge: true
allow_squash_merge: true
squash_merge_commit_title: PR_TITLE
squash_merge_commit_message: PR_BODY
delete_branch_on_merge: true
enable_automated_security_fixes: true
enable_vulnerability_alerts: true
branches:
- name: main
protection:
required_status_checks: null
enforce_admins: true
block_creations: true
required_pull_request_reviews:
required_approving_review_count: 1
require_code_owner_reviews: true
require_last_push_approval: true
dismiss_stale_reviews: true
restrictions:
apps: []
users: []
teams: [ "cli-team" ]
npm-ini-847941c/.github/workflows/ 0000775 0000000 0000000 00000000000 15177426216 0016756 5 ustar 00root root 0000000 0000000 npm-ini-847941c/.github/workflows/audit.yml 0000664 0000000 0000000 00000002275 15177426216 0020615 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 08:00 UTC (01:00 PT) on Monday" https://crontab.guru/#0_8_*_*_1
- cron: "0 8 * * 1"
permissions:
contents: read
jobs:
audit:
name: Audit Dependencies
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- name: Run Production Audit
run: npm audit --omit=dev
- name: Run Full Audit
run: npm audit --audit-level=none
npm-ini-847941c/.github/workflows/ci-release.yml 0000664 0000000 0000000 00000011424 15177426216 0021514 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI - Release
on:
workflow_dispatch:
inputs:
ref:
required: true
type: string
default: main
workflow_call:
inputs:
ref:
required: true
type: string
check-sha:
required: true
type: string
permissions:
contents: read
checks: write
jobs:
lint-all:
name: Lint All
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Create Check
id: create-check
if: ${{ inputs.check-sha }}
uses: ./.github/actions/create-check
with:
name: "Lint All"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ inputs.check-sha }}
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: steps.create-check.outputs.check-id && always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.create-check.outputs.check-id }}
test-all:
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: macOS
os: macos-15-intel
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 22.22.2
- 22.x
- 24.15.0
- 24.x
- 26.0.0
- 26.x
exclude:
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 22.22.2
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 22.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 24.15.0
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 24.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 26.0.0
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 26.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ inputs.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Create Check
id: create-check
if: ${{ inputs.check-sha }}
uses: ./.github/actions/create-check
with:
name: "Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ inputs.check-sha }}
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')
- name: Install Latest npm
if: ${{ !startsWith(matrix.node-version, '22.') }}
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: steps.create-check.outputs.check-id && always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.create-check.outputs.check-id }}
npm-ini-847941c/.github/workflows/ci.yml 0000664 0000000 0000000 00000006656 15177426216 0020111 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:
push:
branches:
- main
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"
permissions:
contents: read
jobs:
lint:
name: Lint
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
test:
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: macOS
os: macos-15-intel
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 22.22.2
- 22.x
- 24.15.0
- 24.x
- 26.0.0
- 26.x
exclude:
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 22.22.2
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 22.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 24.15.0
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 24.x
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 26.0.0
- platform: { name: macOS, os: macos-15-intel, shell: bash }
node-version: 26.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')
- name: Install Latest npm
if: ${{ !startsWith(matrix.node-version, '22.') }}
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
npm-ini-847941c/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000001606 15177426216 0022574 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CodeQL
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 1"
permissions:
contents: read
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v6
- 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@v3
with:
languages: javascript
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
npm-ini-847941c/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000012004 15177426216 0022566 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Post Dependabot
on: pull_request
permissions:
contents: write
jobs:
template-oss:
name: template-oss
if: github.repository_owner == 'npm' && github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Fetch Dependabot Metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Dependabot can update multiple directories so we output which directory
# it is acting on so we can run the command for the correct root or workspace
- name: Get Dependabot Directory
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
id: flags
run: |
dependabot_dir="${{ steps.metadata.outputs.directory }}"
if [[ "$dependabot_dir" == "/" || "$dependabot_dir" == "/main" ]]; then
echo "workspace=-iwr" >> $GITHUB_OUTPUT
else
# strip leading slash from directory so it works as a
# a path to the workspace flag
echo "workspace=--workspace ${dependabot_dir#/}" >> $GITHUB_OUTPUT
fi
- name: Apply Changes
if: steps.flags.outputs.workspace
id: apply
run: |
npm run template-oss-apply ${{ steps.flags.outputs.workspace }}
if [[ `git status --porcelain` ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
# This only sets the conventional commit prefix. This workflow can't reliably determine
# what the breaking change is though. If a BREAKING CHANGE message is required then
# this PR check will fail and the commit will be amended with stafftools
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
prefix='feat!'
else
prefix='chore'
fi
echo "message=$prefix: postinstall for dependabot template-oss PR" >> $GITHUB_OUTPUT
# This step will fail if template-oss has made any workflow updates. It is impossible
# for a workflow to update other workflows. In the case it does fail, we continue
# and then try to apply only a portion of the changes in the next step
- name: Push All Changes
if: steps.apply.outputs.changes
id: push
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -am "${{ steps.apply.outputs.message }}"
git push
# If the previous step failed, then reset the commit and remove any workflow changes
# and attempt to commit and push again. This is helpful because we will have a commit
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
- name: Push All Changes Except Workflows
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git reset HEAD~
git checkout HEAD -- .github/workflows/
git clean -fd .github/workflows/
git commit -am "${{ steps.apply.outputs.message }}"
git push
# Check if all the necessary template-oss changes were applied. Since we continued
# on errors in one of the previous steps, this check will fail if our follow up
# only applied a portion of the changes and we need to followup manually.
#
# Note that this used to run `lint` and `postlint` but that will fail this action
# if we've also shipped any linting changes separate from template-oss. We do
# linting in another action, so we want to fail this one only if there are
# template-oss changes that could not be applied.
- name: Check Changes
if: steps.apply.outputs.changes
run: |
npm exec --offline ${{ steps.flags.outputs.workspace }} -- template-oss-check
- name: Fail on Breaking Change
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
run: |
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
echo "for more information on how to fix this with a BREAKING CHANGE footer."
exit 1
npm-ini-847941c/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002737 15177426216 0022154 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Pull Request
on:
pull_request:
types:
- opened
- reopened
- edited
- synchronize
permissions:
contents: read
jobs:
commitlint:
name: Lint Commits
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
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"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Commitlint on Commits
id: commit
continue-on-error: true
run: npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }}
- name: Run Commitlint on PR Title
if: steps.commit.outcome == 'failure'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: echo "$PR_TITLE" | npx --offline commitlint -V
npm-ini-847941c/.github/workflows/release-integration.yml 0000664 0000000 0000000 00000004163 15177426216 0023446 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release Integration
on:
workflow_dispatch:
inputs:
releases:
required: true
type: string
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
workflow_call:
inputs:
releases:
required: true
type: string
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
secrets:
PUBLISH_TOKEN:
required: true
permissions:
contents: read
id-token: write
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
ref: ${{ fromJSON(inputs.releases)[0].tagName }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Set npm authToken
run: npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN}
- name: Publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
RELEASES: ${{ inputs.releases }}
run: |
EXIT_CODE=0
for release in $(echo $RELEASES | jq -r '.[] | @base64'); do
PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
npm publish --provenance --tag="$PUBLISH_TAG"
STATUS=$?
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
fi
done
exit $EXIT_CODE
npm-ini-847941c/.github/workflows/release.yml 0000664 0000000 0000000 00000026106 15177426216 0021126 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
checks: write
jobs:
release:
outputs:
pr: ${{ steps.release.outputs.pr }}
pr-branch: ${{ steps.release.outputs.pr-branch }}
pr-number: ${{ steps.release.outputs.pr-number }}
pr-sha: ${{ steps.release.outputs.pr-sha }}
releases: ${{ steps.release.outputs.releases }}
comment-id: ${{ steps.create-comment.outputs.comment-id || steps.update-comment.outputs.comment-id }}
check-id: ${{ steps.create-check.outputs.check-id }}
name: Release
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Release Please
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --offline template-oss-release-please --branch="${{ github.ref_name }}" --backport="" --defaultTag="latest"
- name: Create Release Manager Comment Text
if: steps.release.outputs.pr-number
uses: actions/github-script@v7
id: comment-text
with:
result-encoding: string
script: |
const { runId, repo: { owner, repo } } = context
const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId })
return['## Release Manager', `Release workflow run: ${workflow.html_url}`].join('\n\n')
- name: Find Release Manager Comment
uses: peter-evans/find-comment@v2
if: steps.release.outputs.pr-number
id: found-comment
with:
issue-number: ${{ steps.release.outputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: '## Release Manager'
- name: Create Release Manager Comment
id: create-comment
if: steps.release.outputs.pr-number && !steps.found-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ steps.release.outputs.pr-number }}
body: ${{ steps.comment-text.outputs.result }}
- name: Update Release Manager Comment
id: update-comment
if: steps.release.outputs.pr-number && steps.found-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.found-comment.outputs.comment-id }}
body: ${{ steps.comment-text.outputs.result }}
edit-mode: 'replace'
- name: Create Check
id: create-check
uses: ./.github/actions/create-check
if: steps.release.outputs.pr-sha
with:
name: "Release"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.release.outputs.pr-sha }}
update:
needs: release
outputs:
sha: ${{ steps.commit.outputs.sha }}
check-id: ${{ steps.create-check.outputs.check-id }}
name: Update - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ needs.release.outputs.pr-branch }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v6
id: node
with:
node-version: 26.x
check-latest: contains('26.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Create Release Manager Checklist Text
id: comment-text
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm exec --offline -- template-oss-release-manager --pr="${{ needs.release.outputs.pr-number }}" --backport="" --defaultTag="latest" --publish
- name: Append Release Manager Comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ needs.release.outputs.comment-id }}
body: ${{ steps.comment-text.outputs.result }}
edit-mode: 'append'
- name: Run Post Pull Request Actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run rp-pull-request --ignore-scripts --if-present -- --pr="${{ needs.release.outputs.pr-number }}" --commentId="${{ needs.release.outputs.comment-id }}"
- name: Commit
id: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit --all --amend --no-edit || true
git push --force-with-lease
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Create Check
id: create-check
uses: ./.github/actions/create-check
with:
name: "Update - Release"
check-name: "Release"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.commit.outputs.sha }}
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ needs.release.outputs.check-id }}
ci:
name: CI - Release
needs: [ release, update ]
if: needs.release.outputs.pr
uses: ./.github/workflows/ci-release.yml
with:
ref: ${{ needs.release.outputs.pr-branch }}
check-sha: ${{ needs.update.outputs.sha }}
post-ci:
needs: [ release, update, ci ]
name: Post CI - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get CI Conclusion
id: conclusion
run: |
result=""
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
result="failure"
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
result="cancelled"
else
result="success"
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ steps.conclusion.outputs.result }}
check_id: ${{ needs.update.outputs.check-id }}
post-release:
needs: release
outputs:
comment-id: ${{ steps.create-comment.outputs.comment-id }}
name: Post Release - Release
if: github.repository_owner == 'npm' && needs.release.outputs.releases
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Create Release PR Comment Text
id: comment-text
uses: actions/github-script@v7
env:
RELEASES: ${{ needs.release.outputs.releases }}
with:
result-encoding: string
script: |
const releases = JSON.parse(process.env.RELEASES)
const { runId, repo: { owner, repo } } = context
const issue_number = releases[0].prNumber
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`
return [
'## Release Workflow\n',
...releases.map(r => `- \`${r.pkgName}@${r.version}\` ${r.url}`),
`- Workflow run: :arrows_counterclockwise: ${runUrl}`,
].join('\n')
- name: Create Release PR Comment
id: create-comment
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }}
body: ${{ steps.comment-text.outputs.result }}
release-integration:
needs: release
name: Release Integration
if: needs.release.outputs.releases
uses: ./.github/workflows/release-integration.yml
permissions:
contents: read
id-token: write
secrets:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
with:
releases: ${{ needs.release.outputs.releases }}
post-release-integration:
needs: [ release, release-integration, post-release ]
name: Post Release Integration - Release
if: github.repository_owner == 'npm' && needs.release.outputs.releases && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Post Release Conclusion
id: conclusion
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
result="x"
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
result="heavy_multiplication_x"
else
result="white_check_mark"
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: Find Release PR Comment
uses: peter-evans/find-comment@v2
id: found-comment
with:
issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }}
comment-author: 'github-actions[bot]'
body-includes: '## Release Workflow'
- name: Create Release PR Comment Text
id: comment-text
if: steps.found-comment.outputs.comment-id
uses: actions/github-script@v7
env:
RESULT: ${{ steps.conclusion.outputs.result }}
BODY: ${{ steps.found-comment.outputs.comment-body }}
with:
result-encoding: string
script: |
const { RESULT, BODY } = process.env
const body = [BODY.replace(/(Workflow run: :)[a-z_]+(:)/, `$1${RESULT}$2`)]
if (RESULT !== 'white_check_mark') {
body.push(':rotating_light::rotating_light::rotating_light:')
body.push([
'@npm/cli-team: The post-release workflow failed for this release.',
'Manual steps may need to be taken after examining the workflow output.'
].join(' '))
body.push(':rotating_light::rotating_light::rotating_light:')
}
return body.join('\n\n').trim()
- name: Update Release PR Comment
if: steps.comment-text.outputs.result
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.found-comment.outputs.comment-id }}
body: ${{ steps.comment-text.outputs.result }}
edit-mode: 'replace'
npm-ini-847941c/.gitignore 0000664 0000000 0000000 00000001050 15177426216 0015345 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
# ignore everything in the root
/*
!**/.gitignore
!/.commitlintrc.js
!/.eslint.config.js
!/.eslintrc.js
!/.eslintrc.local.*
!/.git-blame-ignore-revs
!/.github/
!/.gitignore
!/.npmrc
!/.prettierignore
!/.prettierrc.js
!/.release-please-manifest.json
!/bin/
!/CHANGELOG*
!/CODE_OF_CONDUCT.md
!/CONTRIBUTING.md
!/docs/
!/lib/
!/LICENSE*
!/map.js
!/package.json
!/README*
!/release-please-config.json
!/scripts/
!/SECURITY.md
!/tap-snapshots/
!/test/
!/tsconfig.json
tap-testdir*/
npm-ini-847941c/.npmrc 0000664 0000000 0000000 00000000135 15177426216 0014500 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
npm-ini-847941c/.release-please-manifest.json 0000664 0000000 0000000 00000000023 15177426216 0021020 0 ustar 00root root 0000000 0000000 {
".": "7.0.0"
}
npm-ini-847941c/CHANGELOG.md 0000664 0000000 0000000 00000024140 15177426216 0015173 0 ustar 00root root 0000000 0000000 # Changelog
## [7.0.0](https://github.com/npm/ini/compare/v6.0.0...v7.0.0) (2026-05-08)
### ⚠️ BREAKING CHANGES
* `ini` now supports node `^22.22.2 || ^24.15.0 || >=26.0.0`
* template-oss-apply
### Features
* [`55b6841`](https://github.com/npm/ini/commit/55b6841261aad580ce979c1ada97885a0617b965) [#301](https://github.com/npm/ini/pull/301) bump to new node engine range (@owlstronaut)
* [`2b11ba8`](https://github.com/npm/ini/commit/2b11ba8283afa33211844be6fa29794970ccf7b7) [#301](https://github.com/npm/ini/pull/301) template-oss-apply (@owlstronaut)
### Chores
* [`f6ed5be`](https://github.com/npm/ini/commit/f6ed5bee3d7b1c175b687c703213217b23df9199) [#301](https://github.com/npm/ini/pull/301) template-oss-apply (@owlstronaut)
* [`a2c835e`](https://github.com/npm/ini/commit/a2c835ec4690c5e67651a403d0f952aaff018f42) [#293](https://github.com/npm/ini/pull/293) bump @npmcli/eslint-config from 5.1.0 to 6.0.0 (#293) (@dependabot[bot])
* [`3661dce`](https://github.com/npm/ini/commit/3661dce193f03675ec6ddc0938e2483d0ab41f38) [#296](https://github.com/npm/ini/pull/296) bump @npmcli/template-oss from 4.28.0 to 4.28.1 (#296) (@dependabot[bot], @npm-cli-bot)
## [6.0.0](https://github.com/npm/ini/compare/v5.0.0...v6.0.0) (2025-10-22)
### ⚠️ BREAKING CHANGES
* `ini` now supports node `^20.17.0 || >=22.9.0`
### Bug Fixes
* [`6d395a4`](https://github.com/npm/ini/commit/6d395a4aaf7d7a5e32e250809cb7bd04c6a27b66) [#291](https://github.com/npm/ini/pull/291) align to npm 11 node engine range (#291) (@owlstronaut)
### Chores
* [`23a36a9`](https://github.com/npm/ini/commit/23a36a9ca194d97486ed367f63d13a2cde1d1ce5) [#290](https://github.com/npm/ini/pull/290) bump @npmcli/template-oss from 4.26.0 to 4.27.1 (#290) (@dependabot[bot], @npm-cli-bot)
## [5.0.0](https://github.com/npm/ini/compare/v4.1.3...v5.0.0) (2024-09-03)
### ⚠️ BREAKING CHANGES
* `ini` now supports node `^18.17.0 || >=20.5.0`
### Bug Fixes
* [`3eca645`](https://github.com/npm/ini/commit/3eca645de8586b8349acd79211b01a9199d8fd32) [#279](https://github.com/npm/ini/pull/279) align to npm 10 node engine range (@hashtagchris)
### Chores
* [`c89e209`](https://github.com/npm/ini/commit/c89e2090d7989bb91255ec46eaaf5f8cb1c34b34) [#279](https://github.com/npm/ini/pull/279) run template-oss-apply (@hashtagchris)
* [`fc44750`](https://github.com/npm/ini/commit/fc447500efe6523746fd9db9d3123485eed14b76) [#276](https://github.com/npm/ini/pull/276) bump @npmcli/eslint-config from 4.0.5 to 5.0.0 (@dependabot[bot])
* [`21c20bb`](https://github.com/npm/ini/commit/21c20bb1729005ab46e0f248cea1a881c6ab5b49) [#277](https://github.com/npm/ini/pull/277) postinstall for dependabot template-oss PR (@hashtagchris)
* [`44b3b50`](https://github.com/npm/ini/commit/44b3b503fdd923fb230b6a4d859014b9364ee466) [#277](https://github.com/npm/ini/pull/277) bump @npmcli/template-oss from 4.23.1 to 4.23.3 (@dependabot[bot])
## [4.1.3](https://github.com/npm/ini/compare/v4.1.2...v4.1.3) (2024-05-22)
### Bug Fixes
* [`858cc82`](https://github.com/npm/ini/commit/858cc82dff7eac9ff9a56181132d66d0e09a803c) [#252](https://github.com/npm/ini/pull/252) decoding bracketed arrays (#252) (@Cherry)
### Chores
* [`2da0471`](https://github.com/npm/ini/commit/2da047162452b6c74fbec797c115530547216685) [#251](https://github.com/npm/ini/pull/251) bump @npmcli/template-oss to 4.22.0 (@lukekarrys)
* [`1eaf0fb`](https://github.com/npm/ini/commit/1eaf0fb982e6c905342e7fac3cb43574231a22f5) [#251](https://github.com/npm/ini/pull/251) postinstall for dependabot template-oss PR (@lukekarrys)
* [`faf21a1`](https://github.com/npm/ini/commit/faf21a13f35089a8ce5ebea438718c65b5b0e749) [#249](https://github.com/npm/ini/pull/249) bump @npmcli/template-oss from 4.21.3 to 4.21.4 (@dependabot[bot])
## [4.1.2](https://github.com/npm/ini/compare/v4.1.1...v4.1.2) (2024-03-04)
### Bug Fixes
* [`e237377`](https://github.com/npm/ini/commit/e237377029caa6fe76b1290eb6e64247e3e11cf3) [#243](https://github.com/npm/ini/pull/243) Removed the unused doUnesc param in the unsafe function (#243) (@LoicE5)
### Documentation
* [`31b3209`](https://github.com/npm/ini/commit/31b3209c45498d1e0f4e38ee5d451ea80b56aa01) [#239](https://github.com/npm/ini/pull/239) Fix typo in `bracketedArray` option name in README.md (#239) (@futpib)
* [`24eb9a0`](https://github.com/npm/ini/commit/24eb9a0a8e5b3de43c993d463314d64f88ca1d50) Reworked README (#235) (@PhoneDroid)
* [`fc6ce28`](https://github.com/npm/ini/commit/fc6ce28a5963aa09d70ad70353397868e99fe804) [#212](https://github.com/npm/ini/pull/212) Fix typo in `bracketedArray` option name in README.md (#212) (@futpib)
### Chores
* [`29caa7c`](https://github.com/npm/ini/commit/29caa7c7578b9ed0b3d36987dc48cec30608d05a) [#240](https://github.com/npm/ini/pull/240) postinstall for dependabot template-oss PR (@lukekarrys)
* [`eafd8f7`](https://github.com/npm/ini/commit/eafd8f75194ba913a5aa23a920c84808452b0f24) [#240](https://github.com/npm/ini/pull/240) bump @npmcli/template-oss from 4.21.1 to 4.21.3 (@dependabot[bot])
* [`5cb0c9f`](https://github.com/npm/ini/commit/5cb0c9f453a190ee5a1d33c590945ca5bafd5fb5) [#238](https://github.com/npm/ini/pull/238) postinstall for dependabot template-oss PR (@lukekarrys)
* [`4ad194e`](https://github.com/npm/ini/commit/4ad194e5f01e67cc52f5a4f1a68e50d596cd51e5) [#238](https://github.com/npm/ini/pull/238) bump @npmcli/template-oss from 4.21.0 to 4.21.1 (@dependabot[bot])
* [`a138d1f`](https://github.com/npm/ini/commit/a138d1f1e210fc5d67c45465265030188b752308) [#233](https://github.com/npm/ini/pull/233) postinstall for dependabot template-oss PR (@lukekarrys)
* [`e37a22e`](https://github.com/npm/ini/commit/e37a22ed0c52ac4f9432fb99357a1d10291d56bb) [#233](https://github.com/npm/ini/pull/233) bump @npmcli/template-oss from 4.19.0 to 4.21.0 (@dependabot[bot])
* [`2f57997`](https://github.com/npm/ini/commit/2f5799792c0f06c6db8a0fcf882c6d7487c4710a) [#215](https://github.com/npm/ini/pull/215) postinstall for dependabot template-oss PR (@lukekarrys)
* [`526d5fe`](https://github.com/npm/ini/commit/526d5fec9d2be1dc4307f6ee7a2994bb9d59d4f6) [#215](https://github.com/npm/ini/pull/215) bump @npmcli/template-oss from 4.18.1 to 4.19.0 (@dependabot[bot])
* [`98de8c2`](https://github.com/npm/ini/commit/98de8c2fb6e640da26546dbcb90fa36af1f3b864) [#214](https://github.com/npm/ini/pull/214) postinstall for dependabot template-oss PR (@lukekarrys)
* [`fd33f54`](https://github.com/npm/ini/commit/fd33f541d8d54967c65b993a59af164448d0c798) [#214](https://github.com/npm/ini/pull/214) bump @npmcli/template-oss from 4.18.0 to 4.18.1 (@dependabot[bot])
* [`21abe16`](https://github.com/npm/ini/commit/21abe160c2314b6a96ce536c05a9b6ca79b394da) [#211](https://github.com/npm/ini/pull/211) postinstall for dependabot template-oss PR (@lukekarrys)
* [`f52bed5`](https://github.com/npm/ini/commit/f52bed502eb4bc1e182d027013b89d8653db9e57) [#211](https://github.com/npm/ini/pull/211) bump @npmcli/template-oss from 4.17.0 to 4.18.0 (@dependabot[bot])
* [`da3b717`](https://github.com/npm/ini/commit/da3b717f81a06ae06f03cc784d56c653839bb66a) [#210](https://github.com/npm/ini/pull/210) postinstall for dependabot template-oss PR (@lukekarrys)
* [`9e9adf4`](https://github.com/npm/ini/commit/9e9adf45e0ad196e9dd76a65ca85047cee909870) [#210](https://github.com/npm/ini/pull/210) bump @npmcli/template-oss from 4.15.1 to 4.17.0 (@dependabot[bot])
## [4.1.1](https://github.com/npm/ini/compare/v4.1.0...v4.1.1) (2023-05-16)
### Bug Fixes
* [`090f64e`](https://github.com/npm/ini/commit/090f64e92a7ff722adf723dc13e7b468e591f057) [#208](https://github.com/npm/ini/pull/208) check process on browser (#208) (@Creskendoll)
## [4.1.0](https://github.com/npm/ini/compare/v4.0.0...v4.1.0) (2023-04-13)
### Features
* [`622106a`](https://github.com/npm/ini/commit/622106a1a0bcd2bc32bfd2e6f9cc45a1a1cb53f7) [#205](https://github.com/npm/ini/pull/205) add "align" and "sort" options (#205) (@rquadling)
* [`dc64a1a`](https://github.com/npm/ini/commit/dc64a1a3aa322c0c258383bedcae738aaa67028d) [#204](https://github.com/npm/ini/pull/204) add bracketedArray option (#204) (@wraithgar)
* [`6a3cb38`](https://github.com/npm/ini/commit/6a3cb38b134f674dff1a7b5d3732553e8bace777) [#199](https://github.com/npm/ini/pull/199) add platform option to force line endings (#199) (@wraithgar, Francois-Xavier Kowalski)
* [`b363ae6`](https://github.com/npm/ini/commit/b363ae67ddf9b1232daafb3cc2b2b1e5cb656406) [#198](https://github.com/npm/ini/pull/198) add newline option (#198) (@wraithgar, Francois-Xavier Kowalski)
### Bug Fixes
* [`ad4b5d8`](https://github.com/npm/ini/commit/ad4b5d8423f67d67b8683ac8e809b9dd23fe82e2) [#200](https://github.com/npm/ini/pull/200) Refactored section split logic (#200) (@wraithgar, @platinumazure)
* [`5b5c9b7`](https://github.com/npm/ini/commit/5b5c9b777209bae480f62fb80149008350d37bc5) [#123](https://github.com/npm/ini/pull/123) residual space after section causes bad parsing (#123) (@Nautigsam)
* [`fa2c17e`](https://github.com/npm/ini/commit/fa2c17e6e5f4ebaec30e08653b9603049c8cf0c3) [#201](https://github.com/npm/ini/pull/201) ignore all whitespace lines (#201) (@wraithgar)
## [4.0.0](https://github.com/npm/ini/compare/v3.0.1...v4.0.0) (2023-03-08)
### ⚠️ BREAKING CHANGES
* `ini` is now compatible with the following semver range for node: `^14.17.0 || ^16.13.0 || >=18.0.0`
### Features
* [`6b70a48`](https://github.com/npm/ini/commit/6b70a480a47cac47b2da4ec40aba6b9b4bb77608) [#176](https://github.com/npm/ini/pull/176) postinstall for dependabot template-oss PR (@lukekarrys)
## [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))
npm-ini-847941c/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 15177426216 0016162 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.
npm-ini-847941c/CONTRIBUTING.md 0000664 0000000 0000000 00000005133 15177426216 0015614 0 ustar 00root root 0000000 0000000
# Contributing
## Code of Conduct
All interactions in the **npm** organization on GitHub are considered to be covered by our standard [Code of Conduct](https://docs.npmjs.com/policies/conduct).
## Reporting Bugs
Before submitting a new bug report please search for an existing or similar report.
Use one of our existing issue templates if you believe you've come across a unique problem.
Duplicate issues, or issues that don't use one of our templates may get closed without a response.
## Pull Request Conventions
### Commits
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
When opening a pull request please be sure that either the pull request title, or each commit in the pull request, has one of the following prefixes:
- `feat`: For when introducing a new feature. The result will be a new semver minor version of the package when it is next published.
- `fix`: For bug fixes. The result will be a new semver patch version of the package when it is next published.
- `docs`: For documentation updates. The result will be a new semver patch version of the package when it is next published.
- `chore`: For changes that do not affect the published module. Often these are changes to tests. The result will be *no* change to the version of the package when it is next published (as the commit does not affect the published version).
### Test Coverage
Pull requests made against this repo will run `npm test` automatically. Please make sure tests pass locally before submitting a PR.
Every new feature or bug fix should come with a corresponding test or tests that validate the solutions. Testing also reports on code coverage and will fail if code coverage drops.
### Linting
Linting is also done automatically once tests pass. `npm run lintfix` will fix most linting errors automatically.
Please make sure linting passes before submitting a PR.
## What _not_ to contribute?
### Dependencies
It should be noted that our team does not accept third-party dependency updates/PRs. If you submit a PR trying to update our dependencies we will close it with or without a reference to these contribution guidelines.
### Tools/Automation
Our core team is responsible for the maintenance of the tooling/automation in this project and we ask contributors to not make changes to these when contributing (e.g. `.github/*`, `.eslintrc.json`, `.licensee.json`). Most of those files also have a header at the top to remind folks they are automatically generated. Pull requests that alter these will not be accepted.
npm-ini-847941c/LICENSE 0000664 0000000 0000000 00000001375 15177426216 0014374 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.
npm-ini-847941c/README.md 0000664 0000000 0000000 00000006160 15177426216 0014643 0 ustar 00root root 0000000 0000000
An INI format parser & serializer.
## Note
- Sections are treated as nested objects.
- Section-less items are treated as globals.
## Usage
Consider an INI file such as the following:
```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**, **modify** and **write** it like so:
```js
import { writeFile , readFile } from 'node:fs/promises'
import { stringify , parse } from 'ini'
// Read INI file as text
let text = await readFile(`./Original.ini`,{
encoding : 'utf-8'
})
// Parse text data to object
const config = parse(text)
// Modify data object
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')
// Stringify data object
text = stringify(config,{
section : 'section'
})
// Write INI file as text
await writeFile(`./Modified.ini`,text)
```
The written file will contain the following:
```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
### Parse
Attempts to turn the given INI string into a nested data object.
```js
// You can also use `decode`
const object = parse(``)
```
### Stringify
Encodes the given data object as an INI formatted string.
```js
// You can also use `encode`
stringify(object,{
/**
* Whether to insert spaces before & after `=`
*
* Disabled by default to have better
* compatibility with old picky parsers.
*/
whitespace : false ,
/**
* Whether to align the `=` character for each section.
* -> Also enables the `whitespace` option
*/
align : false ,
/**
* Identifier to use for global items
* and to prepend to all other sections.
*/
section ,
/**
* Whether to sort all sections & their keys alphabetically.
*/
sort : false ,
/**
* Whether to insert a newline after each section header.
*
* The TOSHIBA & FlashAir parser require this format.
*/
newline : false ,
/**
* Which platforms line-endings should be used.
*
* win32 -> CR+LF
* other -> LF
*
* Default is the current platform
*/
platform ,
/**
* Whether to append `[]` to array keys.
*
* Some parsers treat duplicate names by themselves as arrays
*/
bracketedArray : true
})
```
*For backwards compatibility any string passed as the*
*options parameter is treated as the `section` option.*
```js
stringify(object,'section')
```
### Un / Escape
Turn the given string into a safe to
use key or value in your INI file.
```js
safe(`"unsafe string"`) // -> \"unsafe string\"
```
Or reverse the process with:
```js
unsafe(`\\"safe string\\"`) // -> "safe string"
```
npm-ini-847941c/SECURITY.md 0000664 0000000 0000000 00000002320 15177426216 0015147 0 ustar 00root root 0000000 0000000
GitHub takes the security of our software products and services seriously, including the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub).
If you believe you have found a security vulnerability in this GitHub-owned open source repository, you can report it to us in one of two ways.
If the vulnerability you have found is *not* [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) or if you do not wish to be considered for a bounty reward, please report the issue to us directly through [opensource-security@github.com](mailto:opensource-security@github.com).
If the vulnerability you have found is [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) and you would like for your finding to be considered for a bounty reward, please submit the vulnerability to us through [HackerOne](https://hackerone.com/github) in order to be eligible to receive a bounty award.
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
Thanks for helping make GitHub safe for everyone.
npm-ini-847941c/lib/ 0000775 0000000 0000000 00000000000 15177426216 0014127 5 ustar 00root root 0000000 0000000 npm-ini-847941c/lib/ini.js 0000664 0000000 0000000 00000015723 15177426216 0015254 0 ustar 00root root 0000000 0000000 const { hasOwnProperty } = Object.prototype
const encode = (obj, opt = {}) => {
if (typeof opt === 'string') {
opt = { section: opt }
}
opt.align = opt.align === true
opt.newline = opt.newline === true
opt.sort = opt.sort === true
opt.whitespace = opt.whitespace === true || opt.align === true
// The `typeof` check is required because accessing the `process` directly fails on browsers.
/* istanbul ignore next */
opt.platform = opt.platform || (typeof process !== 'undefined' && process.platform)
opt.bracketedArray = opt.bracketedArray !== false
/* istanbul ignore next */
const eol = opt.platform === 'win32' ? '\r\n' : '\n'
const separator = opt.whitespace ? ' = ' : '='
const children = []
const keys = opt.sort ? Object.keys(obj).sort() : Object.keys(obj)
let padToChars = 0
// If aligning on the separator, then padToChars is determined as follows:
// 1. Get the keys
// 2. Exclude keys pointing to objects unless the value is null or an array
// 3. Add `[]` to array keys
// 4. Ensure non empty set of keys
// 5. Reduce the set to the longest `safe` key
// 6. Get the `safe` length
if (opt.align) {
padToChars = safe(
(
keys
.filter(k => obj[k] === null || Array.isArray(obj[k]) || typeof obj[k] !== 'object')
.map(k => Array.isArray(obj[k]) ? `${k}[]` : k)
)
.concat([''])
.reduce((a, b) => safe(a).length >= safe(b).length ? a : b)
).length
}
let out = ''
const arraySuffix = opt.bracketedArray ? '[]' : ''
for (const k of keys) {
const val = obj[k]
if (val && Array.isArray(val)) {
for (const item of val) {
out += safe(`${k}${arraySuffix}`).padEnd(padToChars, ' ') + separator + safe(item) + eol
}
} else if (val && typeof val === 'object') {
children.push(k)
} else {
out += safe(k).padEnd(padToChars, ' ') + separator + safe(val) + eol
}
}
if (opt.section && out.length) {
out = '[' + safe(opt.section) + ']' + (opt.newline ? eol + eol : eol) + out
}
for (const k of children) {
const nk = splitSections(k, '.').join('\\.')
const section = (opt.section ? opt.section + '.' : '') + nk
const child = encode(obj[k], {
...opt,
section,
})
if (out.length && child.length) {
out += eol
}
out += child
}
return out
}
function splitSections (str, separator) {
var lastMatchIndex = 0
var lastSeparatorIndex = 0
var nextIndex = 0
var sections = []
do {
nextIndex = str.indexOf(separator, lastMatchIndex)
if (nextIndex !== -1) {
lastMatchIndex = nextIndex + separator.length
if (nextIndex > 0 && str[nextIndex - 1] === '\\') {
continue
}
sections.push(str.slice(lastSeparatorIndex, nextIndex))
lastSeparatorIndex = nextIndex + separator.length
}
} while (nextIndex !== -1)
sections.push(str.slice(lastSeparatorIndex))
return sections
}
const decode = (str, opt = {}) => {
opt.bracketedArray = opt.bracketedArray !== false
const out = Object.create(null)
let p = out
let section = null
// section |key = value
const re = /^\[([^\]]*)\]\s*$|^([^=]+)(=(.*))?$/i
const lines = str.split(/[\r\n]+/g)
const duplicates = {}
for (const line of lines) {
if (!line || line.match(/^\s*[;#]/) || 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])
let isArray
if (opt.bracketedArray) {
isArray = keyRaw.length > 2 && keyRaw.slice(-2) === '[]'
} else {
duplicates[keyRaw] = (duplicates?.[keyRaw] || 0) + 1
isArray = duplicates[keyRaw] > 1
}
const key = isArray && keyRaw.endsWith('[]')
? 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 = splitSections(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 => {
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,
}
npm-ini-847941c/package.json 0000664 0000000 0000000 00000002054 15177426216 0015650 0 ustar 00root root 0000000 0000000 {
"author": "GitHub Inc.",
"name": "ini",
"description": "An ini encoder/decoder for node",
"version": "7.0.0",
"repository": {
"type": "git",
"url": "git+https://github.com/npm/ini.git"
},
"main": "lib/ini.js",
"scripts": {
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"lint": "npm run eslint",
"lintfix": "npm run eslint -- --fix",
"test": "tap",
"snap": "tap",
"posttest": "npm run lint",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force"
},
"devDependencies": {
"@npmcli/eslint-config": "^6.0.0",
"@npmcli/template-oss": "5.0.0",
"tap": "^16.0.1"
},
"license": "ISC",
"files": [
"bin/",
"lib/"
],
"engines": {
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "5.0.0",
"publish": "true"
},
"tap": {
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
}
}
npm-ini-847941c/release-please-config.json 0000664 0000000 0000000 00000001277 15177426216 0020415 0 ustar 00root root 0000000 0000000 {
"group-pull-request-title-pattern": "chore: release ${version}",
"pull-request-title-pattern": "chore: release${component} ${version}",
"changelog-sections": [
{
"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",
"section": "Chores",
"hidden": true
}
],
"packages": {
".": {
"package-name": ""
}
},
"prerelease-type": "pre.0"
}
npm-ini-847941c/tap-snapshots/ 0000775 0000000 0000000 00000000000 15177426216 0016165 5 ustar 00root root 0000000 0000000 npm-ini-847941c/tap-snapshots/test/ 0000775 0000000 0000000 00000000000 15177426216 0017144 5 ustar 00root root 0000000 0000000 npm-ini-847941c/tap-snapshots/test/duplicate-properties.js.test.cjs 0000664 0000000 0000000 00000002155 15177426216 0025405 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/duplicate-properties.js TAP decode duplicate properties with bracketedArray=false > must match snapshot 1`] = `
Null Object {
"ar": Array [
"three",
],
"ar[]": "one",
"brr": Array [
"1",
"2",
"3",
"3",
],
"str": "3",
"zr": "123",
"zr[]": "deedee",
}
`
exports[`test/duplicate-properties.js TAP decode with duplicate properties > must match snapshot 1`] = `
Null Object {
"ar": Array [
"one",
"three",
],
"brr": "3",
"str": "3",
"zr": Array [
"deedee",
"123",
],
}
`
exports[`test/duplicate-properties.js TAP encode duplicate properties with bracketedArray=false > must match snapshot 1`] = `
ar=1
ar=2
ar=3
br=1
br=2
`
exports[`test/duplicate-properties.js TAP encode with duplicate properties > must match snapshot 1`] = `
ar[]=1
ar[]=2
ar[]=3
br[]=1
br[]=2
`
npm-ini-847941c/tap-snapshots/test/foo.js.test.cjs 0000664 0000000 0000000 00000013645 15177426216 0022032 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",
],
"b": Null Object {},
"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 align > 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 align and sort > must match snapshot 1`] = `
" xa n p " = "\\"\\r\\nyoyoyo\\r\\r\\n"
"[disturbing]" = hey you never know
a with spaces = b c
ar[] = one
ar[] = three
ar[] = 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
zr[] = deedee
[a]
"[]" = a square?
av = a val
cr[] = four
cr[] = 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.b.c]
e = 1
j = 2
[x\\.y\\.z]
x.y.z = xyz
[x\\.y\\.z.a\\.b\\.c]
a.b.c = abc
noHashComment = this\\# this is not a comment
nocomment = this\\; this is not a comment
`
exports[`test/foo.js TAP encode with newline > must match snapshot 1`] = `
[log]
type=file
[log.level]
label=debug
value=10
`
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 platform=win32 > must match snapshot 1`] = `
Array [
"[log]",
"type=file",
"",
"[log.level]",
"label=debug",
"value=10",
"",
]
`
exports[`test/foo.js TAP encode with sort > must match snapshot 1`] = `
" xa n p "="\\"\\r\\nyoyoyo\\r\\r\\n"
"[disturbing]"=hey you never know
a with spaces=b c
ar[]=one
ar[]=three
ar[]=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
zr[]=deedee
[a]
"[]"=a square?
av=a val
cr[]=four
cr[]=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.b.c]
e=1
j=2
[x\\.y\\.z]
x.y.z=xyz
[x\\.y\\.z.a\\.b\\.c]
a.b.c=abc
noHashComment=this\\# this is not a comment
nocomment=this\\; this is not a comment
`
exports[`test/foo.js TAP encode with whitespace > must match snapshot 1`] = `
[log]
type = file
[log.level]
label = debug
value = 10
`
exports[`test/foo.js TAP encode within browser context > must match snapshot 1`] = `
[log]
type=file
[log.level]
label=debug
value=10
`
npm-ini-847941c/test/ 0000775 0000000 0000000 00000000000 15177426216 0014340 5 ustar 00root root 0000000 0000000 npm-ini-847941c/test/bar.js 0000664 0000000 0000000 00000000711 15177426216 0015441 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()
})
npm-ini-847941c/test/duplicate-properties.js 0000664 0000000 0000000 00000001672 15177426216 0021050 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/duplicate.ini')
const data = fs.readFileSync(fixture, 'utf8')
tap.cleanSnapshot = s => s.replace(/\r\n/g, '\n')
test('decode with duplicate properties', function (t) {
const d = i.decode(data)
t.matchSnapshot(d)
t.end()
})
test('encode with duplicate properties', function (t) {
const e = i.encode({
ar: ['1', '2', '3'],
br: ['1', '2'],
})
t.matchSnapshot(e)
t.end()
})
test('decode duplicate properties with bracketedArray=false', function (t) {
const d = i.decode(data, { bracketedArray: false })
t.matchSnapshot(d)
t.end()
})
test('encode duplicate properties with bracketedArray=false', function (t) {
const e = i.encode({
ar: ['1', '2', '3'],
br: ['1', '2'],
}, { bracketedArray: false })
t.matchSnapshot(e)
t.end()
})
npm-ini-847941c/test/fixtures/ 0000775 0000000 0000000 00000000000 15177426216 0016211 5 ustar 00root root 0000000 0000000 npm-ini-847941c/test/fixtures/duplicate.ini 0000664 0000000 0000000 00000000125 15177426216 0020662 0 ustar 00root root 0000000 0000000 zr[] = deedee
zr=123
ar[] = one
ar[] = three
str = 3
brr = 1
brr = 2
brr = 3
brr = 3
npm-ini-847941c/test/fixtures/foo.ini 0000664 0000000 0000000 00000003265 15177426216 0017503 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
; b section with a space after its title
[b]
; 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
npm-ini-847941c/test/foo.js 0000664 0000000 0000000 00000004470 15177426216 0015466 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()
})
test('encode with newline', function (t) {
const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj, { newline: true })
t.matchSnapshot(e)
t.end()
})
test('encode with platform=win32', function (t) {
const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj, { platform: 'win32' })
t.matchSnapshot(e.split('\r\n'))
t.end()
})
test('encode with align', function (t) {
const d = i.decode(data)
const e = i.encode(d, { align: true })
t.matchSnapshot(e)
t.end()
})
test('encode with sort', function (t) {
const d = i.decode(data)
const e = i.encode(d, { sort: true })
t.matchSnapshot(e)
t.end()
})
test('encode with align and sort', function (t) {
const d = i.decode(data)
const e = i.encode(d, { align: true, sort: true })
t.matchSnapshot(e)
t.end()
})
test('encode within browser context', function (t) {
Object.defineProperty(process, 'platform', { value: undefined })
const obj = { log: { type: 'file', level: { label: 'debug', value: 10 } } }
const e = i.encode(obj)
t.matchSnapshot(e)
t.end()
})
npm-ini-847941c/test/proto.js 0000664 0000000 0000000 00000002642 15177426216 0016045 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)
npm-ini-847941c/test/win32.js 0000664 0000000 0000000 00000001060 15177426216 0015635 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 "\\')