pax_global_header00006660000000000000000000000064143237111010014503gustar00rootroot0000000000000052 comment=ae1f107953b0882ea2c44989e12d5ee08849663b npmlog-7.0.1/000077500000000000000000000000001432371110100130045ustar00rootroot00000000000000npmlog-7.0.1/.commitlintrc.js000066400000000000000000000005531432371110100161270ustar00rootroot00000000000000/* 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']], }, } npmlog-7.0.1/.eslintrc.js000066400000000000000000000005451432371110100152470ustar00rootroot00000000000000/* 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, ], } npmlog-7.0.1/.github/000077500000000000000000000000001432371110100143445ustar00rootroot00000000000000npmlog-7.0.1/.github/CODEOWNERS000066400000000000000000000001321432371110100157330ustar00rootroot00000000000000# This file is automatically added by @npmcli/template-oss. Do not edit. * @npm/cli-team npmlog-7.0.1/.github/ISSUE_TEMPLATE/000077500000000000000000000000001432371110100165275ustar00rootroot00000000000000npmlog-7.0.1/.github/ISSUE_TEMPLATE/bug.yml000066400000000000000000000026551432371110100200370ustar00rootroot00000000000000# 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 �����������������������������������������������������������������������������������npmlog-7.0.1/.github/ISSUE_TEMPLATE/config.yml������������������������������������������������������0000664�0000000�0000000�00000000145�14323711101�0020517�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. blank_issues_enabled: true ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/dependabot.yml�����������������������������������������������������������������0000664�0000000�0000000�00000000563�14323711101�0017200�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" ���������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/matchers/����������������������������������������������������������������������0000775�0000000�0000000�00000000000�14323711101�0016152�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/matchers/tap.json��������������������������������������������������������������0000664�0000000�0000000�00000001204�14323711101�0017626�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 } ] } ] } ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/settings.yml�������������������������������������������������������������������0000664�0000000�0000000�00000000055�14323711101�0016727�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������--- _extends: '.github:npm-cli/settings.yml' �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/workflows/���������������������������������������������������������������������0000775�0000000�0000000�00000000000�14323711101�0016401�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/workflows/audit.yml������������������������������������������������������������0000664�0000000�0000000�00000001775�14323711101�0020244�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" jobs: audit: name: Audit Dependencies if: github.repository_owner == 'npm' runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout 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: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund --package-lock - name: Run Audit run: npm audit ���npmlog-7.0.1/.github/workflows/ci-release.yml�������������������������������������������������������0000664�0000000�0000000�00000015060�14323711101�0021137�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: CI - Release on: workflow_call: inputs: ref: required: true type: string check-sha: required: true type: string jobs: lint-all: name: Lint All if: github.repository_owner == 'npm' runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Get Workflow Job uses: actions/github-script@v6 id: check-output env: JOB_NAME: "Lint All" MATRIX_NAME: "" with: script: | const { owner, repo } = context.repo const { data } = await github.rest.actions.listJobsForWorkflowRun({ owner, repo, run_id: context.runId, per_page: 100 }) const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME const job = data.jobs.find(j => j.name.endsWith(jobName)) const jobUrl = job?.html_url const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` let summary = `This check is assosciated with ${shaUrl}\n\n` if (jobUrl) { summary += `For run logs, click here: ${jobUrl}` } else { summary += `Run logs could not be found for a job with name: "${jobName}"` } return { summary } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check with: token: ${{ secrets.GITHUB_TOKEN }} status: in_progress name: Lint All sha: ${{ inputs.check-sha }} output: ${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 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: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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.3.1 if: always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} check_id: ${{ steps.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: Windows os: windows-latest shell: cmd node-version: - 14.17.0 - 14.x - 16.13.0 - 16.x - 18.0.0 - 18.x runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Get Workflow Job uses: actions/github-script@v6 id: check-output env: JOB_NAME: "Test All" MATRIX_NAME: " - ${{ matrix.platform.name }} - ${{ matrix.node-version }}" with: script: | const { owner, repo } = context.repo const { data } = await github.rest.actions.listJobsForWorkflowRun({ owner, repo, run_id: context.runId, per_page: 100 }) const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME const job = data.jobs.find(j => j.name.endsWith(jobName)) const jobUrl = job?.html_url const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ inputs.check-sha }}` let summary = `This check is assosciated with ${shaUrl}\n\n` if (jobUrl) { summary += `For run logs, click here: ${jobUrl}` } else { summary += `Run logs could not be found for a job with name: "${jobName}"` } return { summary } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check with: token: ${{ secrets.GITHUB_TOKEN }} status: in_progress name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }} sha: ${{ inputs.check-sha }} output: ${{ steps.check-output.outputs.result }} - name: Checkout uses: actions/checkout@v3 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: Setup Node uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Update Windows npm # 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: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - name: Install npm@latest if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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.3.1 if: always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ job.status }} check_id: ${{ steps.check.outputs.check_id }} ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/workflows/ci.yml���������������������������������������������������������������0000664�0000000�0000000�00000011746�14323711101�0017530�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 - latest schedule: # "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1 - cron: "0 9 * * 1" jobs: engines: name: Engines - ${{ matrix.platform.name }} - ${{ matrix.node-version }} if: github.repository_owner == 'npm' strategy: fail-fast: false matrix: platform: - name: Linux os: ubuntu-latest shell: bash node-version: - 14.17.0 - 16.13.0 - 18.0.0 runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Checkout 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: Setup Node uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Update Windows npm # 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: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - name: Install npm@latest if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund --engines-strict lint: name: Lint if: github.repository_owner == 'npm' runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout 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: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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: Windows os: windows-latest shell: cmd node-version: - 14.17.0 - 14.x - 16.13.0 - 16.x - 18.0.0 - 18.x runs-on: ${{ matrix.platform.os }} defaults: run: shell: ${{ matrix.platform.shell }} steps: - name: Checkout 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: Setup Node uses: actions/setup-node@v3 with: node-version: ${{ matrix.node-version }} - name: Update Windows npm # 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: Install npm@7 if: startsWith(matrix.node-version, '10.') run: npm i --prefer-online --no-fund --no-audit -g npm@7 - name: Install npm@latest if: ${{ !startsWith(matrix.node-version, '10.') }} run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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 ��������������������������npmlog-7.0.1/.github/workflows/codeql-analysis.yml��������������������������������������������������0000664�0000000�0000000�00000001605�14323711101�0022216�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: branches: - main - latest schedule: # "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1 - cron: "0 10 * * 1" jobs: analyze: name: Analyze runs-on: ubuntu-latest permissions: actions: read contents: read security-events: write steps: - name: Checkout 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@v2 with: languages: javascript - name: Perform CodeQL Analysis uses: github/codeql-action/analyze@v2 ���������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/workflows/post-dependabot.yml��������������������������������������������������0000664�0000000�0000000�00000011634�14323711101�0022221�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@v3 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@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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" == "/" ]]; then echo "::set-output name=workspace::-iwr" else # strip leading slash from directory so it works as a # a path to the workspace flag echo "::set-output name=workspace::-w ${dependabot_dir#/}" 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 "::set-output name=changes::true" 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 "::set-output name=message::$prefix: postinstall for dependabot template-oss PR" # 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 ����������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/workflows/pull-request.yml�����������������������������������������������������0000664�0000000�0000000�00000002545�14323711101�0021574�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 jobs: commitlint: name: Lint Commits if: github.repository_owner == 'npm' runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout 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" - name: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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' run: | echo ${{ github.event.pull_request.title }} | npx --offline commitlint -V �����������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.github/workflows/release.yml����������������������������������������������������������0000664�0000000�0000000�00000023634�14323711101�0020554�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# This file is automatically added by @npmcli/template-oss. Do not edit. name: Release on: workflow_dispatch: push: branches: - main - latest permissions: contents: write pull-requests: write checks: write jobs: release: outputs: pr: ${{ steps.release.outputs.pr }} releases: ${{ steps.release.outputs.releases }} release-flags: ${{ steps.release.outputs.release-flags }} branch: ${{ steps.release.outputs.pr-branch }} pr-number: ${{ steps.release.outputs.pr-number }} comment-id: ${{ steps.pr-comment.outputs.result }} check-id: ${{ steps.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@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: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - 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 ${{ github.ref_name }} ${{ github.event_name }} - name: Post Pull Request Comment if: steps.release.outputs.pr-number uses: actions/github-script@v6 id: pr-comment env: PR_NUMBER: ${{ steps.release.outputs.pr-number }} REF_NAME: ${{ github.ref_name }} with: script: | const { REF_NAME, PR_NUMBER } = process.env const repo = { owner: context.repo.owner, repo: context.repo.repo } const issue = { ...repo, issue_number: PR_NUMBER } const { data: workflow } = await github.rest.actions.getWorkflowRun({ ...repo, run_id: context.runId }) let body = '## Release Manager\n\n' const comments = await github.paginate(github.rest.issues.listComments, issue) let commentId = comments?.find(c => c.user.login === 'github-actions[bot]' && c.body.startsWith(body))?.id body += `Release workflow run: ${workflow.html_url}\n\n#### Force CI to Rerun for This Release\n\n` body += `This PR will be updated and CI will run for every non-\`chore:\` commit that is pushed to \`main\`. ` body += `To force CI to rerun, run this command:\n\n` body += `\`\`\`\ngh workflow run release.yml -r ${REF_NAME}\n\`\`\`` if (commentId) { await github.rest.issues.updateComment({ ...repo, comment_id: commentId, body }) } else { const { data: comment } = await github.rest.issues.createComment({ ...issue, body }) commentId = comment?.id } return commentId - name: Get Workflow Job uses: actions/github-script@v6 if: steps.release.outputs.pr-number id: check-output env: JOB_NAME: "Release" MATRIX_NAME: "" with: script: | const { owner, repo } = context.repo const { data } = await github.rest.actions.listJobsForWorkflowRun({ owner, repo, run_id: context.runId, per_page: 100 }) const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME const job = data.jobs.find(j => j.name.endsWith(jobName)) const jobUrl = job?.html_url const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.release.outputs.pr-sha }}` let summary = `This check is assosciated with ${shaUrl}\n\n` if (jobUrl) { summary += `For run logs, click here: ${jobUrl}` } else { summary += `Run logs could not be found for a job with name: "${jobName}"` } return { summary } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check if: steps.release.outputs.pr-number with: token: ${{ secrets.GITHUB_TOKEN }} status: in_progress name: Release sha: ${{ steps.release.outputs.pr-sha }} output: ${{ steps.check-output.outputs.result }} update: needs: release outputs: sha: ${{ steps.commit.outputs.sha }} check-id: ${{ steps.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@v3 with: fetch-depth: 0 ref: ${{ needs.release.outputs.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@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Run Post Pull Request Actions env: RELEASE_PR_NUMBER: ${{ needs.release.outputs.pr-number }} RELEASE_COMMENT_ID: ${{ needs.release.outputs.comment-id }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | npm exec --offline -- template-oss-release-manager npm run rp-pull-request --ignore-scripts --if-present - name: Commit id: commit env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git commit --all --amend --no-edit || true git push --force-with-lease echo "::set-output name=sha::$(git rev-parse HEAD)" - name: Get Workflow Job uses: actions/github-script@v6 id: check-output env: JOB_NAME: "Update - Release" MATRIX_NAME: "" with: script: | const { owner, repo } = context.repo const { data } = await github.rest.actions.listJobsForWorkflowRun({ owner, repo, run_id: context.runId, per_page: 100 }) const jobName = process.env.JOB_NAME + process.env.MATRIX_NAME const job = data.jobs.find(j => j.name.endsWith(jobName)) const jobUrl = job?.html_url const shaUrl = `${context.serverUrl}/${owner}/${repo}/commit/${{ steps.commit.outputs.sha }}` let summary = `This check is assosciated with ${shaUrl}\n\n` if (jobUrl) { summary += `For run logs, click here: ${jobUrl}` } else { summary += `Run logs could not be found for a job with name: "${jobName}"` } return { summary } - name: Create Check uses: LouisBrunner/checks-action@v1.3.1 id: check with: token: ${{ secrets.GITHUB_TOKEN }} status: in_progress name: Release sha: ${{ steps.commit.outputs.sha }} output: ${{ steps.check-output.outputs.result }} - name: Conclude Check uses: LouisBrunner/checks-action@v1.3.1 if: always() 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.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 Needs Result id: needs-result 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 "::set-output name=result::$result" - name: Conclude Check uses: LouisBrunner/checks-action@v1.3.1 if: always() with: token: ${{ secrets.GITHUB_TOKEN }} conclusion: ${{ steps.needs-result.outputs.result }} check_id: ${{ needs.update.outputs.check-id }} post-release: needs: release name: Post Release - Release if: github.repository_owner == 'npm' && needs.release.outputs.releases runs-on: ubuntu-latest defaults: run: shell: bash steps: - name: Checkout 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: Setup Node uses: actions/setup-node@v3 with: node-version: 18.x - name: Install npm@latest run: npm i --prefer-online --no-fund --no-audit -g npm@latest - name: npm Version run: npm -v - name: Install Dependencies run: npm i --ignore-scripts --no-audit --no-fund - name: Run Post Release Actions env: RELEASES: ${{ needs.release.outputs.releases }} run: | npm run rp-release --ignore-scripts --if-present ${{ join(fromJSON(needs.release.outputs.release-flags), ' ') }} ����������������������������������������������������������������������������������������������������npmlog-7.0.1/.gitignore�����������������������������������������������������������������������������0000664�0000000�0000000�00000000665�14323711101�0015003�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 !**/.gitignore !/.commitlintrc.js !/.eslintrc.js !/.eslintrc.local.* !/.github/ !/.gitignore !/.npmrc !/.release-please-manifest.json !/bin/ !/CHANGELOG* !/CODE_OF_CONDUCT.md !/docs/ !/lib/ !/LICENSE* !/map.js !/package.json !/README* !/release-please-config.json !/scripts/ !/SECURITY.md !/tap-snapshots/ !/test/ ���������������������������������������������������������������������������npmlog-7.0.1/.npmrc���������������������������������������������������������������������������������0000664�0000000�0000000�00000000135�14323711101�0014123�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������; This file is automatically added by @npmcli/template-oss. Do not edit. package-lock=false �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/.release-please-manifest.json����������������������������������������������������������0000664�0000000�0000000�00000000023�14323711101�0020443�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ ".": "7.0.1" } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/CHANGELOG.md���������������������������������������������������������������������������0000664�0000000�0000000�00000007711�14323711101�0014623�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# Changelog ## [7.0.1](https://github.com/npm/npmlog/compare/v7.0.0...v7.0.1) (2022-10-19) ### Bug Fixes * [`add709d`](https://github.com/npm/npmlog/commit/add709df1974412b2b298cee13abb6b72dbf88d0) [#133](https://github.com/npm/npmlog/pull/133) do not enable progress while paused (@lukekarrys) ## [7.0.0](https://github.com/npm/npmlog/compare/v6.0.2...v7.0.0) (2022-10-14) ### ⚠️ BREAKING CHANGES * `npmlog` is now compatible with the following semver range for node: `^14.17.0 || ^16.13.0 || >=18.0.0` ### Features * [`b7d204d`](https://github.com/npm/npmlog/commit/b7d204dc1531770279b4bb3ccd9b406e6be2e052) [#122](https://github.com/npm/npmlog/pull/122) postinstall for dependabot template-oss PR (@lukekarrys) ### Dependencies * [`01dd16e`](https://github.com/npm/npmlog/commit/01dd16e4e59fc98b82bd1c9307128d0d05551648) [#130](https://github.com/npm/npmlog/pull/130) bump gauge from 4.0.4 to 5.0.0 * [`f896c8e`](https://github.com/npm/npmlog/commit/f896c8e649c2b3dabd98eb493387f9275e90901b) [#129](https://github.com/npm/npmlog/pull/129) bump are-we-there-yet from 3.0.1 to 4.0.0 ### [6.0.2](https://github.com/npm/npmlog/compare/v6.0.1...v6.0.2) (2022-04-20) ### Dependencies * update gauge requirement from ^4.0.0 to ^4.0.1 ([cf52b06](https://github.com/npm/npmlog/commit/cf52b06b3221d0d1081c8e5c4162b7f2a9c3549d)) * update gauge requirement from ^4.0.1 to ^4.0.2 ([#96](https://github.com/npm/npmlog/issues/96)) ([53063a9](https://github.com/npm/npmlog/commit/53063a97a3fe2c582c50ccd23b3e3f3a5c633964)) * update gauge requirement from ^4.0.2 to ^4.0.3 ([#101](https://github.com/npm/npmlog/issues/101)) ([929686c](https://github.com/npm/npmlog/commit/929686cf3d91885218380cbec915ecdc6991842d)) ### v6.0.0 * Drop support for node 10 and non-lts versions of 12 and 14 ### [6.0.1](https://www.github.com/npm/npmlog/compare/v6.0.0...v6.0.1) (2022-02-09) ### Bug Fixes * evaluate this.heading only once ([3633d33](https://www.github.com/npm/npmlog/commit/3633d3395574fc87d734e31e40f4b19eaa3045c3)) * **notice:** change blue foreground to cyan ([eba1a41](https://www.github.com/npm/npmlog/commit/eba1a413c84bf31d6d0eb2cd3b9254debb07e0fb)) ### Dependencies * @npmcli/template-oss@2.7.1 ([5e7b9f4](https://www.github.com/npm/npmlog/commit/5e7b9f42b5c6b2b32613f5164a4524cc71eeb46f)) * are-we-there-yet@3.0.0 ([7aefa36](https://www.github.com/npm/npmlog/commit/7aefa36320a4265f2825f34db29f129f5927f41b)) ### v5.0.1 * update are-we-there-yet to v2.0.0. ### v5.0.0 * Drop support for node versions 6 and 8 * Fix bug where gauge was enabled when paused ### v4.0.2 * Added installation instructions. ### v4.0.1 * Fix bugs where `log.progressEnabled` got out of sync with how `gauge` kept track of these things resulting in a progressbar that couldn't be disabled. ### v4.0.0 * Allow creating log levels that are an empty string or 0. ### v3.1.2 * Update to `gauge@1.6.0` adding support for default values for template items. ### v3.1.1 * Update to `gauge@1.5.3` to fix to `1.x` compatibility when it comes to when a progress bar is enabled. In `1.x` if you didn't have a TTY the progress bar was never shown. In `2.x` it merely defaults to disabled, but you can enable it explicitly if you still want progress updates. ### v3.1.0 * Update to `gauge@2.5.2`: * Updates the `signal-exit` dependency which fixes an incompatibility with the node profiler. * Uses externalizes its ansi code generation in `console-control-strings` * Make the default progress bar include the last line printed, colored as it would be when printing to a tty. ### v3.0.0 * Switch to `gauge@2.0.0`, for better performance, better look. * Set stderr/stdout blocking if they're tty's, so that we can hide a progress bar going to stderr and then safely print to stdout. Without this the two can end up overlapping producing confusing and sometimes corrupted output. ### v2.0.0 * Make the `error` event non-fatal so that folks can use it as a prefix. ### v1.0.0 * Add progress bar with `gauge@1.1.0` �������������������������������������������������������npmlog-7.0.1/CODE_OF_CONDUCT.md���������������������������������������������������������������������0000664�0000000�0000000�00000000507�14323711101�0015605�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> 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. �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/LICENSE.md�����������������������������������������������������������������������������0000664�0000000�0000000�00000001436�14323711101�0014414�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> ISC License Copyright npm, Inc. 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 NPM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NPM 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. ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/README.md������������������������������������������������������������������������������0000664�0000000�0000000�00000013537�14323711101�0014274�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������# npmlog The logger util that npm uses. This logger is very basic. It does the logging for npm. It supports custom levels and colored output. By default, logs are written to stderr. If you want to send log messages to outputs other than streams, then you can change the `log.stream` member, or you can just listen to the events that it emits, and do whatever you want with them. # Installation ```console npm install npmlog --save ``` # Basic Usage ```javascript var log = require('npmlog') // additional stuff ---------------------------+ // message ----------+ | // prefix ----+ | | // level -+ | | | // v v v v log.info('fyi', 'I have a kitty cat: %j', myKittyCat) ``` ## log.level * {String} The level to display logs at. Any logs at or above this level will be displayed. The special level `silent` will prevent anything from being displayed ever. ## log.record * {Array} An array of all the log messages that have been entered. ## log.maxRecordSize * {Number} The maximum number of records to keep. If log.record gets bigger than 10% over this value, then it is sliced down to 90% of this value. The reason for the 10% window is so that it doesn't have to resize a large array on every log entry. ## log.prefixStyle * {Object} A style object that specifies how prefixes are styled. (See below) ## log.headingStyle * {Object} A style object that specifies how the heading is styled. (See below) ## log.heading * {String} Default: "" If set, a heading that is printed at the start of every line. ## log.stream * {Stream} Default: `process.stderr` The stream where output is written. ## log.enableColor() Force colors to be used on all messages, regardless of the output stream. ## log.disableColor() Disable colors on all messages. ## log.enableProgress() Enable the display of log activity spinner and progress bar ## log.disableProgress() Disable the display of a progress bar ## log.enableUnicode() Force the unicode theme to be used for the progress bar. ## log.disableUnicode() Disable the use of unicode in the progress bar. ## log.setGaugeTemplate(template) Set a template for outputting the progress bar. See the [gauge documentation] for details. [gauge documentation]: https://npmjs.com/package/gauge ## log.setGaugeThemeset(themes) Select a themeset to pick themes from for the progress bar. See the [gauge documentation] for details. ## log.pause() Stop emitting messages to the stream, but do not drop them. ## log.resume() Emit all buffered messages that were written while paused. ## log.log(level, prefix, message, ...) * `level` {String} The level to emit the message at * `prefix` {String} A string prefix. Set to "" to skip. * `message...` Arguments to `util.format` Emit a log message at the specified level. ## log\[level](prefix, message, ...) For example, * log.silly(prefix, message, ...) * log.verbose(prefix, message, ...) * log.info(prefix, message, ...) * log.http(prefix, message, ...) * log.warn(prefix, message, ...) * log.error(prefix, message, ...) Like `log.log(level, prefix, message, ...)`. In this way, each level is given a shorthand, so you can do `log.info(prefix, message)`. ## log.addLevel(level, n, style, disp) * `level` {String} Level indicator * `n` {Number} The numeric level * `style` {Object} Object with fg, bg, inverse, etc. * `disp` {String} Optional replacement for `level` in the output. Sets up a new level with a shorthand function and so forth. Note that if the number is `Infinity`, then setting the level to that will cause all log messages to be suppressed. If the number is `-Infinity`, then the only way to show it is to enable all log messages. ## log.newItem(name, todo, weight) * `name` {String} Optional; progress item name. * `todo` {Number} Optional; total amount of work to be done. Default 0. * `weight` {Number} Optional; the weight of this item relative to others. Default 1. This adds a new `are-we-there-yet` item tracker to the progress tracker. The object returned has the `log[level]` methods but is otherwise an `are-we-there-yet` `Tracker` object. ## log.newStream(name, todo, weight) This adds a new `are-we-there-yet` stream tracker to the progress tracker. The object returned has the `log[level]` methods but is otherwise an `are-we-there-yet` `TrackerStream` object. ## log.newGroup(name, weight) This adds a new `are-we-there-yet` tracker group to the progress tracker. The object returned has the `log[level]` methods but is otherwise an `are-we-there-yet` `TrackerGroup` object. # Events Events are all emitted with the message object. * `log` Emitted for all messages * `log.<level>` Emitted for all messages with the `<level>` level. * `<prefix>` Messages with prefixes also emit their prefix as an event. # Style Objects Style objects can have the following fields: * `fg` {String} Color for the foreground text * `bg` {String} Color for the background * `bold`, `inverse`, `underline` {Boolean} Set the associated property * `bell` {Boolean} Make a noise (This is pretty annoying, probably.) # Message Objects Every log event is emitted with a message object, and the `log.record` list contains all of them that have been created. They have the following fields: * `id` {Number} * `level` {String} * `prefix` {String} * `message` {String} Result of `util.format()` * `messageRaw` {Array} Arguments to `util.format()` # Blocking TTYs We use [`set-blocking`](https://npmjs.com/package/set-blocking) to set stderr and stdout blocking if they are tty's and have the setBlocking call. This is a work around for an issue in early versions of Node.js 6.x, which made stderr and stdout non-blocking on OSX. (They are always blocking Windows and were never blocking on Linux.) `npmlog` needs them to be blocking so that it can allow output to stdout and stderr to be interlaced. �����������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/SECURITY.md����������������������������������������������������������������������������0000664�0000000�0000000�00000000246�14323711101�0014577�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������<!-- This file is automatically added by @npmcli/template-oss. Do not edit. --> Please send vulnerability reports through [hackerone](https://hackerone.com/github). ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/docs/����������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�14323711101�0013734�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/docs/example.js������������������������������������������������������������������������0000664�0000000�0000000�00000004122�14323711101�0015724�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������var log = require('./log.js') log.heading = 'npm' console.error('log.level=silly') log.level = 'silly' log.silly('silly prefix', 'x = %j', { foo: { bar: 'baz' } }) log.verbose('verbose prefix', 'x = %j', { foo: { bar: 'baz' } }) log.info('info prefix', 'x = %j', { foo: { bar: 'baz' } }) log.timing('timing prefix', 'x = %j', { foo: { bar: 'baz' } }) log.http('http prefix', 'x = %j', { foo: { bar: 'baz' } }) log.notice('notice prefix', 'x = %j', { foo: { bar: 'baz' } }) log.warn('warn prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('error prefix', 'x = %j', { foo: { bar: 'baz' } }) log.silent('silent prefix', 'x = %j', { foo: { bar: 'baz' } }) console.error('log.level=silent') log.level = 'silent' log.silly('silly prefix', 'x = %j', { foo: { bar: 'baz' } }) log.verbose('verbose prefix', 'x = %j', { foo: { bar: 'baz' } }) log.info('info prefix', 'x = %j', { foo: { bar: 'baz' } }) log.timing('timing prefix', 'x = %j', { foo: { bar: 'baz' } }) log.http('http prefix', 'x = %j', { foo: { bar: 'baz' } }) log.notice('notice prefix', 'x = %j', { foo: { bar: 'baz' } }) log.warn('warn prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('error prefix', 'x = %j', { foo: { bar: 'baz' } }) log.silent('silent prefix', 'x = %j', { foo: { bar: 'baz' } }) console.error('log.level=info') log.level = 'info' log.silly('silly prefix', 'x = %j', { foo: { bar: 'baz' } }) log.verbose('verbose prefix', 'x = %j', { foo: { bar: 'baz' } }) log.info('info prefix', 'x = %j', { foo: { bar: 'baz' } }) log.timing('timing prefix', 'x = %j', { foo: { bar: 'baz' } }) log.http('http prefix', 'x = %j', { foo: { bar: 'baz' } }) log.notice('notice prefix', 'x = %j', { foo: { bar: 'baz' } }) log.warn('warn prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('error prefix', 'x = %j', { foo: { bar: 'baz' } }) log.silent('silent prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('404', 'This is a longer\n' + 'message, with some details\n' + 'and maybe a stack.\n' + new Error('a 404 error').stack) log.addLevel('noise', 10000, { beep: true }) log.noise(false, 'LOUD NOISES') ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/lib/�����������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�14323711101�0013552�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/lib/log.js�����������������������������������������������������������������������������0000664�0000000�0000000�00000021500�14323711101�0014667�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������'use strict' var Progress = require('are-we-there-yet') var Gauge = require('gauge') var EE = require('events').EventEmitter var log = exports = module.exports = new EE() var util = require('util') var setBlocking = require('set-blocking') var consoleControl = require('console-control-strings') setBlocking(true) var stream = process.stderr Object.defineProperty(log, 'stream', { set: function (newStream) { stream = newStream if (this.gauge) { this.gauge.setWriteTo(stream, stream) } }, get: function () { return stream }, }) // by default, decide based on tty-ness. var colorEnabled log.useColor = function () { return colorEnabled != null ? colorEnabled : stream.isTTY } log.enableColor = function () { colorEnabled = true this.gauge.setTheme({ hasColor: colorEnabled, hasUnicode: unicodeEnabled }) } log.disableColor = function () { colorEnabled = false this.gauge.setTheme({ hasColor: colorEnabled, hasUnicode: unicodeEnabled }) } // default level log.level = 'info' log.gauge = new Gauge(stream, { enabled: false, // no progress bars unless asked theme: { hasColor: log.useColor() }, template: [ { type: 'progressbar', length: 20 }, { type: 'activityIndicator', kerning: 1, length: 1 }, { type: 'section', default: '' }, ':', { type: 'logline', kerning: 1, default: '' }, ], }) log.tracker = new Progress.TrackerGroup() // we track this separately as we may need to temporarily disable the // display of the status bar for our own loggy purposes. log.progressEnabled = log.gauge.isEnabled() var unicodeEnabled log.enableUnicode = function () { unicodeEnabled = true this.gauge.setTheme({ hasColor: this.useColor(), hasUnicode: unicodeEnabled }) } log.disableUnicode = function () { unicodeEnabled = false this.gauge.setTheme({ hasColor: this.useColor(), hasUnicode: unicodeEnabled }) } log.setGaugeThemeset = function (themes) { this.gauge.setThemeset(themes) } log.setGaugeTemplate = function (template) { this.gauge.setTemplate(template) } log.enableProgress = function () { if (this.progressEnabled || this._paused) { return } this.progressEnabled = true this.tracker.on('change', this.showProgress) this.gauge.enable() } log.disableProgress = function () { if (!this.progressEnabled) { return } this.progressEnabled = false this.tracker.removeListener('change', this.showProgress) this.gauge.disable() } var trackerConstructors = ['newGroup', 'newItem', 'newStream'] var mixinLog = function (tracker) { // mixin the public methods from log into the tracker // (except: conflicts and one's we handle specially) Object.keys(log).forEach(function (P) { if (P[0] === '_') { return } if (trackerConstructors.filter(function (C) { return C === P }).length) { return } if (tracker[P]) { return } if (typeof log[P] !== 'function') { return } var func = log[P] tracker[P] = function () { return func.apply(log, arguments) } }) // if the new tracker is a group, make sure any subtrackers get // mixed in too if (tracker instanceof Progress.TrackerGroup) { trackerConstructors.forEach(function (C) { var func = tracker[C] tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } }) } return tracker } // Add tracker constructors to the top level log object trackerConstructors.forEach(function (C) { log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } }) log.clearProgress = function (cb) { if (!this.progressEnabled) { return cb && process.nextTick(cb) } this.gauge.hide(cb) } log.showProgress = function (name, completed) { if (!this.progressEnabled) { return } var values = {} if (name) { values.section = name } var last = log.record[log.record.length - 1] if (last) { values.subsection = last.prefix var disp = log.disp[last.level] || last.level var logline = this._format(disp, log.style[last.level]) if (last.prefix) { logline += ' ' + this._format(last.prefix, this.prefixStyle) } logline += ' ' + last.message.split(/\r?\n/)[0] values.logline = logline } values.completed = completed || this.tracker.completed() this.gauge.show(values) }.bind(log) // bind for use in tracker's on-change listener // temporarily stop emitting, but don't drop log.pause = function () { this._paused = true if (this.progressEnabled) { this.gauge.disable() } } log.resume = function () { if (!this._paused) { return } this._paused = false var b = this._buffer this._buffer = [] b.forEach(function (m) { this.emitLog(m) }, this) if (this.progressEnabled) { this.gauge.enable() } } log._buffer = [] var id = 0 log.record = [] log.maxRecordSize = 10000 log.log = function (lvl, prefix, message) { var l = this.levels[lvl] if (l === undefined) { return this.emit('error', new Error(util.format( 'Undefined log level: %j', lvl))) } var a = new Array(arguments.length - 2) var stack = null for (var i = 2; i < arguments.length; i++) { var arg = a[i - 2] = arguments[i] // resolve stack traces to a plain string. if (typeof arg === 'object' && arg instanceof Error && arg.stack) { Object.defineProperty(arg, 'stack', { value: stack = arg.stack + '', enumerable: true, writable: true, }) } } if (stack) { a.unshift(stack + '\n') } message = util.format.apply(util, a) var m = { id: id++, level: lvl, prefix: String(prefix || ''), message: message, messageRaw: a, } this.emit('log', m) this.emit('log.' + lvl, m) if (m.prefix) { this.emit(m.prefix, m) } this.record.push(m) var mrs = this.maxRecordSize var n = this.record.length - mrs if (n > mrs / 10) { var newSize = Math.floor(mrs * 0.9) this.record = this.record.slice(-1 * newSize) } this.emitLog(m) }.bind(log) log.emitLog = function (m) { if (this._paused) { this._buffer.push(m) return } if (this.progressEnabled) { this.gauge.pulse(m.prefix) } var l = this.levels[m.level] if (l === undefined) { return } if (l < this.levels[this.level]) { return } if (l > 0 && !isFinite(l)) { return } // If 'disp' is null or undefined, use the lvl as a default // Allows: '', 0 as valid disp var disp = log.disp[m.level] != null ? log.disp[m.level] : m.level this.clearProgress() m.message.split(/\r?\n/).forEach(function (line) { var heading = this.heading if (heading) { this.write(heading, this.headingStyle) this.write(' ') } this.write(disp, log.style[m.level]) var p = m.prefix || '' if (p) { this.write(' ') } this.write(p, this.prefixStyle) this.write(' ' + line + '\n') }, this) this.showProgress() } log._format = function (msg, style) { if (!stream) { return } var output = '' if (this.useColor()) { style = style || {} var settings = [] if (style.fg) { settings.push(style.fg) } if (style.bg) { settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) } if (style.bold) { settings.push('bold') } if (style.underline) { settings.push('underline') } if (style.inverse) { settings.push('inverse') } if (settings.length) { output += consoleControl.color(settings) } if (style.beep) { output += consoleControl.beep() } } output += msg if (this.useColor()) { output += consoleControl.color('reset') } return output } log.write = function (msg, style) { if (!stream) { return } stream.write(this._format(msg, style)) } log.addLevel = function (lvl, n, style, disp) { // If 'disp' is null or undefined, use the lvl as a default if (disp == null) { disp = lvl } this.levels[lvl] = n this.style[lvl] = style if (!this[lvl]) { this[lvl] = function () { var a = new Array(arguments.length + 1) a[0] = lvl for (var i = 0; i < arguments.length; i++) { a[i + 1] = arguments[i] } return this.log.apply(this, a) }.bind(this) } this.disp[lvl] = disp } log.prefixStyle = { fg: 'magenta' } log.headingStyle = { fg: 'white', bg: 'black' } log.style = {} log.levels = {} log.disp = {} log.addLevel('silly', -Infinity, { inverse: true }, 'sill') log.addLevel('verbose', 1000, { fg: 'cyan', bg: 'black' }, 'verb') log.addLevel('info', 2000, { fg: 'green' }) log.addLevel('timing', 2500, { fg: 'green', bg: 'black' }) log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) log.addLevel('notice', 3500, { fg: 'cyan', bg: 'black' }) log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') log.addLevel('silent', Infinity) // allow 'error' prefix log.on('error', function () {}) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/package.json���������������������������������������������������������������������������0000664�0000000�0000000�00000002302�14323711101�0015267�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "author": "GitHub Inc.", "name": "npmlog", "description": "logger for npm", "version": "7.0.1", "repository": { "type": "git", "url": "https://github.com/npm/npmlog.git" }, "main": "lib/log.js", "files": [ "bin/", "lib/" ], "scripts": { "test": "tap", "npmclilint": "npmcli-lint", "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", "posttest": "npm run lint", "postsnap": "npm run lintfix --", "postlint": "template-oss-check", "snap": "tap", "template-oss-apply": "template-oss-apply --force" }, "dependencies": { "are-we-there-yet": "^4.0.0", "console-control-strings": "^1.1.0", "gauge": "^5.0.0", "set-blocking": "^2.0.0" }, "devDependencies": { "@npmcli/eslint-config": "^4.0.0", "@npmcli/template-oss": "4.6.1", "tap": "^16.0.1" }, "license": "ISC", "engines": { "node": "^14.17.0 || ^16.13.0 || >=18.0.0" }, "tap": { "branches": 95, "nyc-arg": [ "--exclude", "tap-snapshots/**" ] }, "templateOSS": { "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", "version": "4.6.1" } } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/release-please-config.json�������������������������������������������������������������0000664�0000000�0000000�00000001254�14323711101�0020033�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������{ "exclude-packages-from-root": true, "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", "hidden": true } ], "packages": { ".": { "package-name": "" } } } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/test/����������������������������������������������������������������������������������0000775�0000000�0000000�00000000000�14323711101�0013763�5����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/test/basic.js��������������������������������������������������������������������������0000664�0000000�0000000�00000042142�14323711101�0015405�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������const t = require('tap') const log = require('../') const stream = require('stream') const result = [] const logEvents = [] const logInfoEvents = [] const logPrefixEvents = [] const resultExpect = [ // eslint-disable-next-line max-len '\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[7msill\u001b[0m \u001b[0m\u001b[35msilly prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mverb\u001b[0m \u001b[0m\u001b[35mverbose prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[32minfo\u001b[0m \u001b[0m\u001b[35minfo prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[32;40mtiming\u001b[0m \u001b[0m\u001b[35mtiming prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[32;40mhttp\u001b[0m \u001b[0m\u001b[35mhttp prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m \u001b[0m\u001b[35mnotice prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[30;43mWARN\u001b[0m \u001b[0m\u001b[35mwarn prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[31;40mERR!\u001b[0m \u001b[0m\u001b[35merror prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[32minfo\u001b[0m \u001b[0m\u001b[35minfo prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[32;40mtiming\u001b[0m \u001b[0m\u001b[35mtiming prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[32;40mhttp\u001b[0m \u001b[0m\u001b[35mhttp prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[36;40mnotice\u001b[0m \u001b[0m\u001b[35mnotice prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[30;43mWARN\u001b[0m \u001b[0m\u001b[35mwarn prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[31;40mERR!\u001b[0m \u001b[0m\u001b[35merror prefix\u001b[0m x = {"foo":{"bar":"baz"}}\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[31;40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m This is a longer\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[31;40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m message, with some details\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[31;40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m and maybe a stack.\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u001b[31;40mERR!\u001b[0m \u001b[0m\u001b[35m404\u001b[0m \n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u0007noise\u001b[0m\u001b[35m\u001b[0m LOUD NOISES\n', // eslint-disable-next-line max-len '\u001b[0m\u001b[37;40mnpm\u001b[0m \u001b[0m\u0007noise\u001b[0m \u001b[0m\u001b[35merror\u001b[0m erroring\n', '\u001b[0m', ] const logPrefixEventsExpect = [ { id: 2, level: 'info', prefix: 'info prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 11, level: 'info', prefix: 'info prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 20, level: 'info', prefix: 'info prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, ] // should be the same. const logInfoEventsExpect = logPrefixEventsExpect const logEventsExpect = [ { id: 0, level: 'silly', prefix: 'silly prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 1, level: 'verbose', prefix: 'verbose prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 2, level: 'info', prefix: 'info prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 3, level: 'timing', prefix: 'timing prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 4, level: 'http', prefix: 'http prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 5, level: 'notice', prefix: 'notice prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 6, level: 'warn', prefix: 'warn prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 7, level: 'error', prefix: 'error prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 8, level: 'silent', prefix: 'silent prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 9, level: 'silly', prefix: 'silly prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 10, level: 'verbose', prefix: 'verbose prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 11, level: 'info', prefix: 'info prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 12, level: 'timing', prefix: 'timing prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 13, level: 'http', prefix: 'http prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 14, level: 'notice', prefix: 'notice prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 15, level: 'warn', prefix: 'warn prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 16, level: 'error', prefix: 'error prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 17, level: 'silent', prefix: 'silent prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 18, level: 'silly', prefix: 'silly prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 19, level: 'verbose', prefix: 'verbose prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 20, level: 'info', prefix: 'info prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 21, level: 'timing', prefix: 'timing prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 22, level: 'http', prefix: 'http prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 23, level: 'notice', prefix: 'notice prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 24, level: 'warn', prefix: 'warn prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 25, level: 'error', prefix: 'error prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 26, level: 'silent', prefix: 'silent prefix', message: 'x = {"foo":{"bar":"baz"}}', messageRaw: ['x = %j', { foo: { bar: 'baz' } }] }, { id: 27, level: 'error', prefix: '404', message: 'This is a longer\nmessage, with some details\nand maybe a stack.\n', messageRaw: ['This is a longer\nmessage, with some details\nand maybe a stack.\n'] }, { id: 28, level: 'noise', prefix: false, message: 'LOUD NOISES', messageRaw: ['LOUD NOISES'] }, { id: 29, level: 'noise', prefix: 'error', message: 'erroring', messageRaw: ['erroring'] }, ] const Stream = require('stream').Stream const s = new Stream() s.write = function (m) { result.push(m) } s.writable = true s.isTTY = true s.end = function () {} log.stream = s log.heading = 'npm' t.test('basic', async t => { t.same(log.stream, s, 'stream getter works') log.on('log', logEvents.push.bind(logEvents)) log.on('log.info', logInfoEvents.push.bind(logInfoEvents)) log.on('info prefix', logPrefixEvents.push.bind(logPrefixEvents)) console.error('log.level=silly') log.level = 'silly' log.silly('silly prefix', 'x = %j', { foo: { bar: 'baz' } }) log.verbose('verbose prefix', 'x = %j', { foo: { bar: 'baz' } }) log.info('info prefix', 'x = %j', { foo: { bar: 'baz' } }) log.timing('timing prefix', 'x = %j', { foo: { bar: 'baz' } }) log.http('http prefix', 'x = %j', { foo: { bar: 'baz' } }) log.notice('notice prefix', 'x = %j', { foo: { bar: 'baz' } }) log.warn('warn prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('error prefix', 'x = %j', { foo: { bar: 'baz' } }) log.silent('silent prefix', 'x = %j', { foo: { bar: 'baz' } }) console.error('log.level=silent') log.level = 'silent' log.silly('silly prefix', 'x = %j', { foo: { bar: 'baz' } }) log.verbose('verbose prefix', 'x = %j', { foo: { bar: 'baz' } }) log.info('info prefix', 'x = %j', { foo: { bar: 'baz' } }) log.timing('timing prefix', 'x = %j', { foo: { bar: 'baz' } }) log.http('http prefix', 'x = %j', { foo: { bar: 'baz' } }) log.notice('notice prefix', 'x = %j', { foo: { bar: 'baz' } }) log.warn('warn prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('error prefix', 'x = %j', { foo: { bar: 'baz' } }) log.silent('silent prefix', 'x = %j', { foo: { bar: 'baz' } }) console.error('log.level=info') log.level = 'info' log.silly('silly prefix', 'x = %j', { foo: { bar: 'baz' } }) log.verbose('verbose prefix', 'x = %j', { foo: { bar: 'baz' } }) log.info('info prefix', 'x = %j', { foo: { bar: 'baz' } }) log.timing('timing prefix', 'x = %j', { foo: { bar: 'baz' } }) log.http('http prefix', 'x = %j', { foo: { bar: 'baz' } }) log.notice('notice prefix', 'x = %j', { foo: { bar: 'baz' } }) log.warn('warn prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('error prefix', 'x = %j', { foo: { bar: 'baz' } }) log.silent('silent prefix', 'x = %j', { foo: { bar: 'baz' } }) log.error('404', 'This is a longer\n' + 'message, with some details\n' + 'and maybe a stack.\n') log.addLevel('noise', 10000, { beep: true }) log.noise(false, 'LOUD NOISES') log.noise('error', 'erroring') t.same(result.join('').trim(), resultExpect.join('').trim(), 'result') t.same(log.record, logEventsExpect, 'record') t.same(logEvents, logEventsExpect, 'logEvents') t.same(logInfoEvents, logInfoEventsExpect, 'logInfoEvents') t.same(logPrefixEvents, logPrefixEventsExpect, 'logPrefixEvents') }) t.test('util functions', async t => { t.teardown(() => { log.resume() log.gauge.enable() }) t.test('enableColor', async t => { t.teardown(() => { log.disableColor() }) log.enableColor() t.same(log.useColor(), true, 'log has color enabled') t.match(log.gauge._theme, { hasColor: true }, 'gauge has color enabled') }) t.test('disableColor', async t => { log.disableColor() t.same(log.useColor(), false, 'color is disabled') t.match(log.gauge._theme, { hasColor: false }, 'gauge has color disabled') }) t.test('enableUnicode', async t => { t.teardown(() => { log.disableUnicode() }) log.enableUnicode() t.match(log.gauge._theme, { hasUnicode: true }, 'gauge has unicode enabled') }) t.test('disableUnicode', async t => { log.disableUnicode() t.match(log.gauge._theme, { hasUnicode: false }, 'gauge has unicode disabled') }) t.test('themes', async t => { const _themes = log.gauge._themes t.teardown(() => { log.setGaugeThemeset(_themes) }) const themes = require('gauge/lib/themes') const newThemes = themes.newThemeSet() log.setGaugeThemeset(newThemes) t.match(log.gauge._themes, newThemes, 'gauge has new theme set') }) t.test('template', async t => { const _template = log.gauge._gauge.template t.teardown(() => { log.gauge._gauge.template = _template }) const template = [{ type: 'progressbar', length: 100 }] log.setGaugeTemplate(template) t.match(log.gauge._gauge.template, template) }) t.test('enableProgress while paused', async t => { t.teardown(() => { log.enableProgress() log.resume() }) log.disableProgress() log.pause() log.enableProgress() t.same(log.gauge.isEnabled(), false, 'gauge is still disabled') }) t.test('pause while progressEnabled', async t => { t.teardown(() => { log.resume() }) log.pause() t.same(log.gauge.isEnabled(), false, 'gauge is disabled') }) t.test('_buffer while paused', async t => { t.teardown(() => { log.resume() }) // const bufferLength = this._buffer.length log.pause() log.log('verbose', 'test', 'test log') t.equal(log._buffer.length, 1, 'message was buffered') log.resume() t.equal(log._buffer.length, 0, 'message was unbuffered') }) }) t.test('log.log', async t => { t.test('emits error on bad loglevel', t => { log.once('error', (err) => { t.match(err, /Undefined log level: "asdf"/) t.end() }) log.log('asdf', 'bad loglevel') }) t.test('resolves stack traces to a plain string', t => { log.once('log', (m) => { t.match(m.message, 'Error: with a stack trace', 'has error message') t.match(m.message, 'at Test', 'has stack info') t.end() }) const err = new Error('with a stack trace') log.log('verbose', 'oops', err) }) t.test('max record size', async t => { const mrs = log.maxRecordSize t.teardown(() => { log.maxRecordSize = mrs }) log.maxRecordSize = 3 log.log('verbose', 'test', 'log 1') log.log('verbose', 'test', 'log 2') log.log('verbose', 'test', 'log 3') log.log('verbose', 'test', 'log 4') t.equal(log.record.length, 3, 'only maxRecordSize entries in record') }) }) t.test('write with no stream', async t => { const gauge = log.gauge t.teardown(() => { log.gauge = gauge log.stream = s }) log.gauge = null log.stream = null log.write('message') t.ok('does not throw') }) t.test('emitLog to nonexistant level', async t => { t.teardown(() => { log.stream = s }) const badStream = new stream.Writable() badStream.on('data', () => { throw new Error('should not have gotten data!') }) log.emitLog({ prefix: 'test', level: 'asdf' }) t.ok('does not throw') }) t.test('emitLog to nonexistant level', async t => { t.teardown(() => { log.stream = s }) const badStream = new stream.Writable() badStream.on('data', () => { throw new Error('should not have gotten data!') }) log.emitLog({ prefix: 'test', level: 'asdf' }) t.ok('does not throw') }) t.test('_format with nonexistant stream', async t => { const gauge = log.gauge t.teardown(() => { log.gauge = gauge log.stream = s }) log.gauge = null log.stream = null t.match(log._format('message'), undefined, 'does nothing') }) t.test('_format', async t => { t.teardown(() => { log.disableColor() }) t.test('nonexistant stream', async t => { const gauge = log.gauge t.teardown(() => { log.gauge = gauge log.stream = s }) log.gauge = null log.stream = null t.match(log._format('message'), undefined, 'does nothing') }) t.test('fg', async t => { log.enableColor() const o = log._format('test message', { bg: 'blue' }) t.match(o, '\u001b[44mtest message\u001b[0m') }) t.test('bg', async t => { log.enableColor() const o = log._format('test message', { bg: 'white' }) t.match(o, '\u001b[47mtest message\u001b[0m') }) t.test('bold', async t => { log.enableColor() const o = log._format('test message', { bold: true }) t.match(o, '\u001b[1mtest message\u001b[0m') }) t.test('underline', async t => { log.enableColor() const o = log._format('test message', { underline: true }) t.match(o, '\u001b[4mtest message\u001b[0m') }) t.test('inverse', async t => { log.enableColor() const o = log._format('test message', { inverse: true }) t.match(o, '\u001b[7mtest message\u001b[0m') }) }) ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/test/display.js������������������������������������������������������������������������0000664�0000000�0000000�00000001425�14323711101�0015770�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������var tap = require('tap') var log = require('../') var actual = '' // Store and stub log.write, so we can get at // the actual arguments passed to it on each call. var write = log.write log.write = function (msg) { actual += msg } tap.test('explicitly set new log level display to empty string', function (t) { log.addLevel('explicitNoLevelDisplayed', 20000, {}, '') log.explicitNoLevelDisplayed('1', '2') t.equal(actual.trim(), '1 2') actual = '' log.explicitNoLevelDisplayed('', '1') t.equal(actual.trim(), '1') actual = '' t.end() }) tap.test('explicitly set new log level display to 0', function (t) { log.addLevel('explicitNoLevelDisplayed', 20000, {}, 0) log.explicitNoLevelDisplayed('', '1') t.equal(actual.trim(), '0 1') t.end() }) log.write = write �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������npmlog-7.0.1/test/progress.js�����������������������������������������������������������������������0000664�0000000�0000000�00000013115�14323711101�0016166�0����������������������������������������������������������������������������������������������������ustar�00root����������������������������root����������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������'use strict' var test = require('tap').test var Progress = require('are-we-there-yet') var log = require('../') var actions = [] log.gauge = { enabled: false, enable: function () { this.enabled = true actions.push(['enable']) }, disable: function () { this.enabled = false actions.push(['disable']) }, isEnabled: function () { return this.enabled }, hide: function () { actions.push(['hide']) }, show: function () { actions.push(['show'].concat(Array.prototype.slice.call(arguments))) }, pulse: function (name) { actions.push(['pulse', name]) }, } function recursiveMatch (t, actual, expected, desc) { if (expected instanceof RegExp) { return t.match(actual, expected, desc + ' matches') } else if (typeof expected === 'boolean') { return t.equal(!!actual, expected, desc + ' exists') } else if (typeof expected !== 'object' || expected == null) { return t.equal(actual, expected, desc + ' are equal') } else { if (actual == null) { actual = {} } Object.keys(expected).forEach(function (key) { recursiveMatch(t, actual && actual[key], expected[key], desc + ':' + key) }) if (Array.isArray(actual)) { if (!t.equal(actual.length, expected.length, desc + ' has matching length')) { t.comment(' Actual: ', actual) t.comment(' Expected: ', expected) } } else { Object.keys(actual).forEach(function (key) { if (expected[key] == null) { t.fail(desc + ':' + key + ' should not be set') } }) } } } function didActions (t, msg, output) { t.equal(actions.length, output.length, msg) for (var cmd = 0; cmd < output.length; ++cmd) { recursiveMatch(t, actions[cmd], output[cmd], msg + ':' + output[cmd][0]) } actions = [] } function resetTracker () { log.disableProgress() log.resume() log.tracker = new Progress.TrackerGroup() log.enableProgress() actions = [] } test('enableProgress', function (t) { t.plan(4) resetTracker() log.disableProgress() actions = [] log.enableProgress() didActions(t, 'enableProgress', [['enable']]) log.enableProgress() didActions(t, 'enableProgress again', []) }) test('disableProgress', function (t) { t.plan(4) resetTracker() log.disableProgress() didActions(t, 'disableProgress', [['disable']]) log.disableProgress() didActions(t, 'disableProgress again', []) }) test('showProgress', function (t) { t.plan(6) resetTracker() log.disableProgress() actions = [] log.showProgress('foo') didActions(t, 'showProgress disabled', []) log.enableProgress() actions = [] log.showProgress('foo') didActions(t, 'showProgress', [['show', { section: 'foo', completed: 0 }]]) }) test('clearProgress', function (t) { t.plan(4) resetTracker() log.clearProgress() didActions(t, 'clearProgress', [['hide']]) log.disableProgress() actions = [] log.clearProgress() didActions(t, 'clearProgress disabled', []) }) test('newItem', function (t) { t.plan(21) resetTracker() actions = [] var a = log.newItem('test', 10) didActions(t, 'newItem', [['show', { section: 'test', completed: 0, subsection: false, logline: false, }]]) a.completeWork(5) didActions(t, 'newItem:completeWork', [['show', { section: 'test', completed: 0.5, subsection: false, logline: false, }]]) a.finish() didActions(t, 'newItem:finish', [['show', { section: 'test', completed: 1, subsection: false, logline: false, }]]) }) // Test that log objects proxy through. // Test that completion status filters up. test('newGroup', function (t) { t.plan(39) resetTracker() var a = log.newGroup('newGroup') didActions(t, 'newGroup', [['show', { section: 'newGroup', completed: 0, subsection: false, logline: false, }]]) a.warn('test', 'this is a test') didActions(t, 'newGroup:warn', [['pulse', 'test'], ['hide'], ['show', { subsection: 'test', logline: /this is a test$/, completed: 0, }]]) var b = a.newItem('newGroup2', 10) didActions(t, 'newGroup:newItem', [['show', { section: 'newGroup2', completed: 0, subsection: true, logline: true, }]]) b.completeWork(5) didActions(t, 'newGroup:completeWork', [['show', { section: 'newGroup2', completed: 0.5, subsection: true, logline: true, }]]) a.finish() didActions(t, 'newGroup:finish', [['show', { section: 'newGroup', completed: 1, subsection: true, logline: true, }]]) }) test('newStream', function (t) { t.plan(22) resetTracker() var a = log.newStream('newStream', 10) didActions(t, 'newStream', [['show', { completed: 0, section: 'newStream', subsection: true, logline: true, }]]) a.write('abcde') didActions(t, 'newStream', [['show', { completed: 0.5, section: 'newStream', subsection: true, logline: true, }]]) a.write('fghij') didActions(t, 'newStream', [['show', { completed: 1, section: 'newStream', subsection: true, logline: true, }]]) t.equal(log.tracker.completed(), 1, 'Overall completion') }) test('enableProgress while paused', function (t) { t.plan(2) resetTracker() log.disableProgress() actions = [] log.pause() log.enableProgress() didActions(t, 'enableProgress', []) log.enableProgress() didActions(t, 'enableProgress again', []) }) test('pause while enableProgress', function (t) { t.plan(8) resetTracker() log.disableProgress() actions = [] log.enableProgress() log.pause() didActions(t, 'enableProgress', [['enable'], ['disable']]) log.resume() didActions(t, 'enableProgress', [['enable']]) }) �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������