pax_global_header 0000666 0000000 0000000 00000000064 14546020536 0014517 g ustar 00root root 0000000 0000000 52 comment=4f4c7daa424e5514a5da4067249ee5b96c20d6df
npm-are-we-there-yet-4f4c7da/ 0000775 0000000 0000000 00000000000 14546020536 0016071 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.commitlintrc.js 0000664 0000000 0000000 00000000553 14546020536 0021214 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
module.exports = {
extends: ['@commitlint/config-conventional'],
rules: {
'type-enum': [2, 'always', ['feat', 'fix', 'docs', 'deps', 'chore']],
'header-max-length': [2, 'always', 80],
'subject-case': [0, 'always', ['lower-case', 'sentence-case', 'start-case']],
},
}
npm-are-we-there-yet-4f4c7da/.eslintrc.js 0000664 0000000 0000000 00000000623 14546020536 0020331 0 ustar 00root root 0000000 0000000 /* This file is automatically added by @npmcli/template-oss. Do not edit. */
'use strict'
const { readdirSync: readdir } = require('fs')
const localConfigs = readdir(__dirname)
.filter((file) => file.startsWith('.eslintrc.local.'))
.map((file) => `./${file}`)
module.exports = {
root: true,
ignorePatterns: [
'tap-testdir*/',
],
extends: [
'@npmcli',
...localConfigs,
],
}
npm-are-we-there-yet-4f4c7da/.github/ 0000775 0000000 0000000 00000000000 14546020536 0017431 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/CODEOWNERS 0000664 0000000 0000000 00000000132 14546020536 0021020 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
* @npm/cli-team
npm-are-we-there-yet-4f4c7da/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14546020536 0021614 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/ISSUE_TEMPLATE/bug.yml 0000664 0000000 0000000 00000002655 14546020536 0023124 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Bug
description: File a bug/issue
title: "[BUG]
"
labels: [ Bug, Needs Triage ]
body:
- type: checkboxes
attributes:
label: Is there an existing issue for this?
description: Please [search here](./issues) to see if an issue already exists for your problem.
options:
- label: I have searched the existing issues
required: true
- type: textarea
attributes:
label: Current Behavior
description: A clear & concise description of what you're experiencing.
validations:
required: false
- type: textarea
attributes:
label: Expected Behavior
description: A clear & concise description of what you expected to happen.
validations:
required: false
- type: textarea
attributes:
label: Steps To Reproduce
description: Steps to reproduce the behavior.
value: |
1. In this environment...
2. With this config...
3. Run '...'
4. See error...
validations:
required: false
- type: textarea
attributes:
label: Environment
description: |
examples:
- **npm**: 7.6.3
- **Node**: 13.14.0
- **OS**: Ubuntu 20.04
- **platform**: Macbook Pro
value: |
- npm:
- Node:
- OS:
- platform:
validations:
required: false
npm-are-we-there-yet-4f4c7da/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000145 14546020536 0023604 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
blank_issues_enabled: true
npm-are-we-there-yet-4f4c7da/.github/actions/ 0000775 0000000 0000000 00000000000 14546020536 0021071 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/actions/create-check/ 0000775 0000000 0000000 00000000000 14546020536 0023407 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/actions/create-check/action.yml 0000664 0000000 0000000 00000002732 14546020536 0025413 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: 'Create Check'
inputs:
name:
required: true
token:
required: true
sha:
required: true
check-name:
default: ''
outputs:
check-id:
value: ${{ steps.create-check.outputs.check_id }}
runs:
using: "composite"
steps:
- name: Get Workflow Job
uses: actions/github-script@v6
id: workflow
env:
JOB_NAME: "${{ inputs.name }}"
SHA: "${{ inputs.sha }}"
with:
result-encoding: string
script: |
const { repo: { owner, repo}, runId, serverUrl } = context
const { JOB_NAME, SHA } = process.env
const job = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: runId,
per_page: 100
}).then(r => r.data.jobs.find(j => j.name.endsWith(JOB_NAME)))
return [
`This check is assosciated with ${serverUrl}/${owner}/${repo}/commit/${SHA}.`,
'Run logs:',
job?.html_url || `could not be found for a job ending with: "${JOB_NAME}"`,
].join(' ')
- name: Create Check
uses: LouisBrunner/checks-action@v1.6.0
id: create-check
with:
token: ${{ inputs.token }}
sha: ${{ inputs.sha }}
status: in_progress
name: ${{ inputs.check-name || inputs.name }}
output: |
{"summary":"${{ steps.workflow.outputs.result }}"}
npm-are-we-there-yet-4f4c7da/.github/actions/install-latest-npm/ 0000775 0000000 0000000 00000000000 14546020536 0024621 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/actions/install-latest-npm/action.yml 0000664 0000000 0000000 00000003410 14546020536 0026617 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: 'Install Latest npm'
description: 'Install the latest version of npm compatible with the Node version'
inputs:
node:
description: 'Current Node version'
required: true
runs:
using: "composite"
steps:
# node 10/12/14 ship with npm@6, which is known to fail when updating itself in windows
- name: Update Windows npm
if: |
runner.os == 'Windows' && (
startsWith(inputs.node, 'v10.') ||
startsWith(inputs.node, 'v12.') ||
startsWith(inputs.node, 'v14.')
)
shell: cmd
run: |
curl -sO https://registry.npmjs.org/npm/-/npm-7.5.4.tgz
tar xf npm-7.5.4.tgz
cd package
node lib/npm.js install --no-fund --no-audit -g ..\npm-7.5.4.tgz
cd ..
rmdir /s /q package
- name: Install Latest npm
shell: bash
env:
NODE_VERSION: ${{ inputs.node }}
working-directory: ${{ runner.temp }}
run: |
MATCH=""
SPECS=("latest" "next-10" "next-9" "next-8" "next-7" "next-6")
echo "node@$NODE_VERSION"
for SPEC in ${SPECS[@]}; do
ENGINES=$(npm view npm@$SPEC --json | jq -r '.engines.node')
echo "Checking if node@$NODE_VERSION satisfies npm@$SPEC ($ENGINES)"
if npx semver -r "$ENGINES" "$NODE_VERSION" > /dev/null; then
MATCH=$SPEC
echo "Found compatible version: npm@$MATCH"
break
fi
done
if [ -z $MATCH ]; then
echo "Could not find a compatible version of npm for node@$NODE_VERSION"
exit 1
fi
npm i --prefer-online --no-fund --no-audit -g npm@$MATCH
- name: npm Version
shell: bash
run: npm -v
npm-are-we-there-yet-4f4c7da/.github/dependabot.yml 0000664 0000000 0000000 00000000656 14546020536 0022270 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
version: 2
updates:
- package-ecosystem: npm
directory: /
schedule:
interval: daily
target-branch: "main"
allow:
- dependency-type: direct
versioning-strategy: increase-if-necessary
commit-message:
prefix: deps
prefix-development: chore
labels:
- "Dependencies"
open-pull-requests-limit: 10
npm-are-we-there-yet-4f4c7da/.github/matchers/ 0000775 0000000 0000000 00000000000 14546020536 0021237 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/matchers/tap.json 0000664 0000000 0000000 00000001204 14546020536 0022713 0 ustar 00root root 0000000 0000000 {
"//@npmcli/template-oss": "This file is automatically added by @npmcli/template-oss. Do not edit.",
"problemMatcher": [
{
"owner": "tap",
"pattern": [
{
"regexp": "^\\s*not ok \\d+ - (.*)",
"message": 1
},
{
"regexp": "^\\s*---"
},
{
"regexp": "^\\s*at:"
},
{
"regexp": "^\\s*line:\\s*(\\d+)",
"line": 1
},
{
"regexp": "^\\s*column:\\s*(\\d+)",
"column": 1
},
{
"regexp": "^\\s*file:\\s*(.*)",
"file": 1
}
]
}
]
}
npm-are-we-there-yet-4f4c7da/.github/settings.yml 0000664 0000000 0000000 00000001377 14546020536 0022024 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
repository:
allow_merge_commit: false
allow_rebase_merge: true
allow_squash_merge: true
squash_merge_commit_title: PR_TITLE
squash_merge_commit_message: PR_BODY
delete_branch_on_merge: true
enable_automated_security_fixes: true
enable_vulnerability_alerts: true
branches:
- name: main
protection:
required_status_checks: null
enforce_admins: true
block_creations: true
required_pull_request_reviews:
required_approving_review_count: 1
require_code_owner_reviews: true
require_last_push_approval: true
dismiss_stale_reviews: true
restrictions:
apps: []
users: []
teams: [ "cli-team" ]
npm-are-we-there-yet-4f4c7da/.github/workflows/ 0000775 0000000 0000000 00000000000 14546020536 0021466 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/.github/workflows/audit.yml 0000664 0000000 0000000 00000002236 14546020536 0023322 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
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund --package-lock
- name: Run Production Audit
run: npm audit --omit=dev
- name: Run Full Audit
run: npm audit --audit-level=none
npm-are-we-there-yet-4f4c7da/.github/workflows/ci-release.yml 0000664 0000000 0000000 00000007641 14546020536 0024232 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI - Release
on:
workflow_dispatch:
inputs:
ref:
required: true
type: string
default: main
workflow_call:
inputs:
ref:
required: true
type: string
check-sha:
required: true
type: string
jobs:
lint-all:
name: Lint All
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@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: Create Check
id: create-check
if: ${{ inputs.check-sha }}
uses: ./.github/actions/create-check
with:
name: "Lint All"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ inputs.check-sha }}
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.create-check.outputs.check-id }}
test-all:
name: Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 14.17.0
- 14.x
- 16.13.0
- 16.x
- 18.0.0
- 18.x
- 20.x
runs-on: ${{ matrix.platform.os }}
defaults:
run:
shell: ${{ matrix.platform.shell }}
steps:
- 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: Create Check
id: create-check
if: ${{ inputs.check-sha }}
uses: ./.github/actions/create-check
with:
name: "Test All - ${{ matrix.platform.name }} - ${{ matrix.node-version }}"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ inputs.check-sha }}
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ steps.create-check.outputs.check-id }}
npm-are-we-there-yet-4f4c7da/.github/workflows/ci.yml 0000664 0000000 0000000 00000005231 14546020536 0022605 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
schedule:
# "At 09:00 UTC (02:00 PT) on Monday" https://crontab.guru/#0_9_*_*_1
- cron: "0 9 * * 1"
jobs:
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
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Lint
run: npm run lint --ignore-scripts
- name: Post Lint
run: npm run postlint --ignore-scripts
test:
name: Test - ${{ matrix.platform.name }} - ${{ matrix.node-version }}
if: github.repository_owner == 'npm'
strategy:
fail-fast: false
matrix:
platform:
- name: Linux
os: ubuntu-latest
shell: bash
- name: macOS
os: macos-latest
shell: bash
- name: Windows
os: windows-latest
shell: cmd
node-version:
- 14.17.0
- 14.x
- 16.13.0
- 16.x
- 18.0.0
- 18.x
- 20.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
id: node
with:
node-version: ${{ matrix.node-version }}
check-latest: contains(matrix.node-version, '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Add Problem Matcher
run: echo "::add-matcher::.github/matchers/tap.json"
- name: Test
run: npm test --ignore-scripts
npm-are-we-there-yet-4f4c7da/.github/workflows/codeql-analysis.yml 0000664 0000000 0000000 00000001547 14546020536 0025310 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: CodeQL
on:
push:
branches:
- main
pull_request:
branches:
- main
schedule:
# "At 10:00 UTC (03:00 PT) on Monday" https://crontab.guru/#0_10_*_*_1
- cron: "0 10 * * 1"
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
npm-are-we-there-yet-4f4c7da/.github/workflows/post-dependabot.yml 0000664 0000000 0000000 00000011733 14546020536 0025306 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
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Fetch Dependabot Metadata
id: metadata
uses: dependabot/fetch-metadata@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
# Dependabot can update multiple directories so we output which directory
# it is acting on so we can run the command for the correct root or workspace
- name: Get Dependabot Directory
if: contains(steps.metadata.outputs.dependency-names, '@npmcli/template-oss')
id: flags
run: |
dependabot_dir="${{ steps.metadata.outputs.directory }}"
if [[ "$dependabot_dir" == "/" ]]; then
echo "workspace=-iwr" >> $GITHUB_OUTPUT
else
# strip leading slash from directory so it works as a
# a path to the workspace flag
echo "workspace=-w ${dependabot_dir#/}" >> $GITHUB_OUTPUT
fi
- name: Apply Changes
if: steps.flags.outputs.workspace
id: apply
run: |
npm run template-oss-apply ${{ steps.flags.outputs.workspace }}
if [[ `git status --porcelain` ]]; then
echo "changes=true" >> $GITHUB_OUTPUT
fi
# This only sets the conventional commit prefix. This workflow can't reliably determine
# what the breaking change is though. If a BREAKING CHANGE message is required then
# this PR check will fail and the commit will be amended with stafftools
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-major" ]]; then
prefix='feat!'
else
prefix='chore'
fi
echo "message=$prefix: postinstall for dependabot template-oss PR" >> $GITHUB_OUTPUT
# This step will fail if template-oss has made any workflow updates. It is impossible
# for a workflow to update other workflows. In the case it does fail, we continue
# and then try to apply only a portion of the changes in the next step
- name: Push All Changes
if: steps.apply.outputs.changes
id: push
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit -am "${{ steps.apply.outputs.message }}"
git push
# If the previous step failed, then reset the commit and remove any workflow changes
# and attempt to commit and push again. This is helpful because we will have a commit
# with the correct prefix that we can then --amend with @npmcli/stafftools later.
- name: Push All Changes Except Workflows
if: steps.apply.outputs.changes && steps.push.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git reset HEAD~
git checkout HEAD -- .github/workflows/
git clean -fd .github/workflows/
git commit -am "${{ steps.apply.outputs.message }}"
git push
# Check if all the necessary template-oss changes were applied. Since we continued
# on errors in one of the previous steps, this check will fail if our follow up
# only applied a portion of the changes and we need to followup manually.
#
# Note that this used to run `lint` and `postlint` but that will fail this action
# if we've also shipped any linting changes separate from template-oss. We do
# linting in another action, so we want to fail this one only if there are
# template-oss changes that could not be applied.
- name: Check Changes
if: steps.apply.outputs.changes
run: |
npm exec --offline ${{ steps.flags.outputs.workspace }} -- template-oss-check
- name: Fail on Breaking Change
if: steps.apply.outputs.changes && startsWith(steps.apply.outputs.message, 'feat!')
run: |
echo "This PR has a breaking change. Run 'npx -p @npmcli/stafftools gh template-oss-fix'"
echo "for more information on how to fix this with a BREAKING CHANGE footer."
exit 1
npm-are-we-there-yet-4f4c7da/.github/workflows/pull-request.yml 0000664 0000000 0000000 00000002700 14546020536 0024652 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
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Run Commitlint on Commits
id: commit
continue-on-error: true
run: npx --offline commitlint -V --from 'origin/${{ github.base_ref }}' --to ${{ github.event.pull_request.head.sha }}
- name: Run Commitlint on PR Title
if: steps.commit.outcome == 'failure'
env:
PR_TITLE: ${{ github.event.pull_request.title }}
run: echo "$PR_TITLE" | npx --offline commitlint -V
npm-are-we-there-yet-4f4c7da/.github/workflows/release-integration.yml 0000664 0000000 0000000 00000004272 14546020536 0026157 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release Integration
on:
workflow_dispatch:
inputs:
releases:
required: true
type: string
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
workflow_call:
inputs:
releases:
required: true
type: string
description: 'A json array of releases. Required fields: publish: tagName, publishTag. publish check: pkgName, version'
secrets:
PUBLISH_TOKEN:
required: true
jobs:
publish:
name: Publish
runs-on: ubuntu-latest
defaults:
run:
shell: bash
permissions:
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ fromJSON(inputs.releases)[0].tagName }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Set npm authToken
run: npm config set '//registry.npmjs.org/:_authToken'=\${PUBLISH_TOKEN}
- name: Publish
env:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
run: |
EXIT_CODE=0
function each_release {
if npm publish --provenance --tag="$1"; then
echo 0
else
echo 1
fi
}
for release in $(echo '${{ inputs.releases }}' | jq -r '.[] | @base64'); do
PUBLISH_TAG=$(echo "$release" | base64 --decode | jq -r .publishTag)
STATUS=$(each_release "$PUBLISH_TAG")
if [[ "$STATUS" -eq 1 ]]; then
EXIT_CODE=$STATUS
fi
done
exit $EXIT_CODE
npm-are-we-there-yet-4f4c7da/.github/workflows/release.yml 0000664 0000000 0000000 00000026061 14546020536 0023636 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
name: Release
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
checks: write
jobs:
release:
outputs:
pr: ${{ steps.release.outputs.pr }}
pr-branch: ${{ steps.release.outputs.pr-branch }}
pr-number: ${{ steps.release.outputs.pr-number }}
pr-sha: ${{ steps.release.outputs.pr-sha }}
releases: ${{ steps.release.outputs.releases }}
comment-id: ${{ steps.create-comment.outputs.comment-id || steps.update-comment.outputs.comment-id }}
check-id: ${{ steps.create-check.outputs.check-id }}
name: Release
if: github.repository_owner == 'npm'
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@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
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Release Please
id: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx --offline template-oss-release-please --branch="${{ github.ref_name }}" --backport="" --defaultTag="latest"
- name: Create Release Manager Comment Text
if: steps.release.outputs.pr-number
uses: actions/github-script@v6
id: comment-text
with:
result-encoding: string
script: |
const { runId, repo: { owner, repo } } = context
const { data: workflow } = await github.rest.actions.getWorkflowRun({ owner, repo, run_id: runId })
return['## Release Manager', `Release workflow run: ${workflow.html_url}`].join('\n\n')
- name: Find Release Manager Comment
uses: peter-evans/find-comment@v2
if: steps.release.outputs.pr-number
id: found-comment
with:
issue-number: ${{ steps.release.outputs.pr-number }}
comment-author: 'github-actions[bot]'
body-includes: '## Release Manager'
- name: Create Release Manager Comment
id: create-comment
if: steps.release.outputs.pr-number && !steps.found-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ steps.release.outputs.pr-number }}
body: ${{ steps.comment-text.outputs.result }}
- name: Update Release Manager Comment
id: update-comment
if: steps.release.outputs.pr-number && steps.found-comment.outputs.comment-id
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.found-comment.outputs.comment-id }}
body: ${{ steps.comment-text.outputs.result }}
edit-mode: 'replace'
- name: Create Check
id: create-check
uses: ./.github/actions/create-check
if: steps.release.outputs.pr-sha
with:
name: "Release"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.release.outputs.pr-sha }}
update:
needs: release
outputs:
sha: ${{ steps.commit.outputs.sha }}
check-id: ${{ steps.create-check.outputs.check-id }}
name: Update - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.release.outputs.pr-branch }}
- name: Setup Git User
run: |
git config --global user.email "npm-cli+bot@github.com"
git config --global user.name "npm CLI robot"
- name: Setup Node
uses: actions/setup-node@v3
id: node
with:
node-version: 20.x
check-latest: contains('20.x', '.x')
- name: Install Latest npm
uses: ./.github/actions/install-latest-npm
with:
node: ${{ steps.node.outputs.node-version }}
- name: Install Dependencies
run: npm i --ignore-scripts --no-audit --no-fund
- name: Create Release Manager Checklist Text
id: comment-text
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm exec --offline -- template-oss-release-manager --pr="${{ needs.release.outputs.pr-number }}" --backport="" --defaultTag="latest" --publish
- name: Append Release Manager Comment
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ needs.release.outputs.comment-id }}
body: ${{ steps.comment-text.outputs.result }}
edit-mode: 'append'
- name: Run Post Pull Request Actions
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npm run rp-pull-request --ignore-scripts --if-present -- --pr="${{ needs.release.outputs.pr-number }}" --commentId="${{ needs.release.outputs.comment-id }}"
- name: Commit
id: commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git commit --all --amend --no-edit || true
git push --force-with-lease
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Create Check
id: create-check
uses: ./.github/actions/create-check
with:
name: "Update - Release"
check-name: "Release"
token: ${{ secrets.GITHUB_TOKEN }}
sha: ${{ steps.commit.outputs.sha }}
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ job.status }}
check_id: ${{ needs.release.outputs.check-id }}
ci:
name: CI - Release
needs: [ release, update ]
if: needs.release.outputs.pr
uses: ./.github/workflows/ci-release.yml
with:
ref: ${{ needs.release.outputs.pr-branch }}
check-sha: ${{ needs.update.outputs.sha }}
post-ci:
needs: [ release, update, ci ]
name: Post CI - Release
if: github.repository_owner == 'npm' && needs.release.outputs.pr && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get CI Conclusion
id: conclusion
run: |
result=""
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
result="failure"
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
result="cancelled"
else
result="success"
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: Conclude Check
uses: LouisBrunner/checks-action@v1.6.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
conclusion: ${{ steps.conclusion.outputs.result }}
check_id: ${{ needs.update.outputs.check-id }}
post-release:
needs: release
outputs:
comment-id: ${{ steps.create-comment.outputs.comment-id }}
name: Post Release - Release
if: github.repository_owner == 'npm' && needs.release.outputs.releases
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Create Release PR Comment Text
id: comment-text
uses: actions/github-script@v6
env:
RELEASES: ${{ needs.release.outputs.releases }}
with:
result-encoding: string
script: |
const releases = JSON.parse(process.env.RELEASES)
const { runId, repo: { owner, repo } } = context
const issue_number = releases[0].prNumber
const runUrl = `https://github.com/${owner}/${repo}/actions/runs/${runId}`
return [
'## Release Workflow\n',
...releases.map(r => `- \`${r.pkgName}@${r.version}\` ${r.url}`),
`- Workflow run: :arrows_counterclockwise: ${runUrl}`,
].join('\n')
- name: Create Release PR Comment
id: create-comment
uses: peter-evans/create-or-update-comment@v3
with:
issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }}
body: ${{ steps.comment-text.outputs.result }}
release-integration:
needs: release
name: Release Integration
if: needs.release.outputs.releases
uses: ./.github/workflows/release-integration.yml
permissions:
id-token: write
secrets:
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }}
with:
releases: ${{ needs.release.outputs.releases }}
post-release-integration:
needs: [ release, release-integration, post-release ]
name: Post Release Integration - Release
if: github.repository_owner == 'npm' && needs.release.outputs.releases && always()
runs-on: ubuntu-latest
defaults:
run:
shell: bash
steps:
- name: Get Post Release Conclusion
id: conclusion
run: |
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" ]]; then
result="x"
elif [[ "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
result="heavy_multiplication_x"
else
result="white_check_mark"
fi
echo "result=$result" >> $GITHUB_OUTPUT
- name: Find Release PR Comment
uses: peter-evans/find-comment@v2
id: found-comment
with:
issue-number: ${{ fromJSON(needs.release.outputs.releases)[0].prNumber }}
comment-author: 'github-actions[bot]'
body-includes: '## Release Workflow'
- name: Create Release PR Comment Text
id: comment-text
if: steps.found-comment.outputs.comment-id
uses: actions/github-script@v6
env:
RESULT: ${{ steps.conclusion.outputs.result }}
BODY: ${{ steps.found-comment.outputs.comment-body }}
with:
result-encoding: string
script: |
const { RESULT, BODY } = process.env
const body = [BODY.replace(/(Workflow run: :)[a-z_]+(:)/, `$1${RESULT}$2`)]
if (RESULT !== 'white_check_mark') {
body.push(':rotating_light::rotating_light::rotating_light:')
body.push([
'@npm/cli-team: The post-release workflow failed for this release.',
'Manual steps may need to be taken after examining the workflow output.'
].join(' '))
body.push(':rotating_light::rotating_light::rotating_light:')
}
return body.join('\n\n').trim()
- name: Update Release PR Comment
if: steps.comment-text.outputs.result
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.found-comment.outputs.comment-id }}
body: ${{ steps.comment-text.outputs.result }}
edit-mode: 'replace'
npm-are-we-there-yet-4f4c7da/.gitignore 0000664 0000000 0000000 00000001002 14546020536 0020052 0 ustar 00root root 0000000 0000000 # This file is automatically added by @npmcli/template-oss. Do not edit.
# ignore everything in the root
/*
# transient test directories
tap-testdir*/
# keep these
!**/.gitignore
!/.commitlintrc.js
!/.eslintrc.js
!/.eslintrc.local.*
!/.github/
!/.gitignore
!/.npmrc
!/.release-please-manifest.json
!/bin/
!/CHANGELOG*
!/CODE_OF_CONDUCT.md
!/CONTRIBUTING.md
!/docs/
!/lib/
!/LICENSE*
!/map.js
!/package.json
!/README*
!/release-please-config.json
!/scripts/
!/SECURITY.md
!/tap-snapshots/
!/test/
!/tsconfig.json
npm-are-we-there-yet-4f4c7da/.npmrc 0000664 0000000 0000000 00000000135 14546020536 0017210 0 ustar 00root root 0000000 0000000 ; This file is automatically added by @npmcli/template-oss. Do not edit.
package-lock=false
npm-are-we-there-yet-4f4c7da/.release-please-manifest.json 0000664 0000000 0000000 00000000023 14546020536 0023530 0 ustar 00root root 0000000 0000000 {
".": "4.0.2"
}
npm-are-we-there-yet-4f4c7da/CHANGELOG.md 0000664 0000000 0000000 00000013307 14546020536 0017706 0 ustar 00root root 0000000 0000000 # Changelog
## [4.0.2](https://github.com/npm/are-we-there-yet/compare/v4.0.1...v4.0.2) (2024-01-05)
### Dependencies
* [`09d821a`](https://github.com/npm/are-we-there-yet/commit/09d821a57c52a658a8105825ffeff92ef55f51cc) [#207](https://github.com/npm/are-we-there-yet/pull/207) remove delegates (#207)
* [`fef6c21`](https://github.com/npm/are-we-there-yet/commit/fef6c2146e5c09ff512ac4c4d459093a9ac7487f) [#206](https://github.com/npm/are-we-there-yet/pull/206) remove readable-stream (#206)
### Chores
* [`6c3cebf`](https://github.com/npm/are-we-there-yet/commit/6c3cebfc65c5e9041ffd83a1615639ff47421958) [#205](https://github.com/npm/are-we-there-yet/pull/205) postinstall for dependabot template-oss PR (@lukekarrys)
* [`809215c`](https://github.com/npm/are-we-there-yet/commit/809215c7fff063d03550849b312b6de759c5e2db) [#205](https://github.com/npm/are-we-there-yet/pull/205) bump @npmcli/template-oss from 4.21.1 to 4.21.3 (@dependabot[bot])
* [`8858a73`](https://github.com/npm/are-we-there-yet/commit/8858a73ca0ae1b2d669865da3f5d17db78184bc0) [#202](https://github.com/npm/are-we-there-yet/pull/202) postinstall for dependabot template-oss PR (@lukekarrys)
* [`b2134b9`](https://github.com/npm/are-we-there-yet/commit/b2134b9fa69ff7d69636c8d3a75f951f36645f1e) [#202](https://github.com/npm/are-we-there-yet/pull/202) bump @npmcli/template-oss from 4.19.0 to 4.21.1 (@dependabot[bot])
* [`9acf64b`](https://github.com/npm/are-we-there-yet/commit/9acf64b5001329f36c0b49374de8dcd4be6ff102) [#184](https://github.com/npm/are-we-there-yet/pull/184) postinstall for dependabot template-oss PR (@lukekarrys)
* [`d8bacce`](https://github.com/npm/are-we-there-yet/commit/d8bacceae21b598de516c0553b7cc0efa7ed7dcc) [#184](https://github.com/npm/are-we-there-yet/pull/184) bump @npmcli/template-oss from 4.18.1 to 4.19.0 (@dependabot[bot])
* [`9e4783f`](https://github.com/npm/are-we-there-yet/commit/9e4783f17c1b3eaec7d8a4292b99fd2ce7711205) [#182](https://github.com/npm/are-we-there-yet/pull/182) postinstall for dependabot template-oss PR (@lukekarrys)
* [`d55ffbf`](https://github.com/npm/are-we-there-yet/commit/d55ffbf7743276b2caa7a15ed466ff5bcc1652e7) [#182](https://github.com/npm/are-we-there-yet/pull/182) bump @npmcli/template-oss from 4.18.0 to 4.18.1 (@dependabot[bot])
* [`08dc9f5`](https://github.com/npm/are-we-there-yet/commit/08dc9f551e5b6c88cf55c8b358597ec00ea14473) [#181](https://github.com/npm/are-we-there-yet/pull/181) postinstall for dependabot template-oss PR (@lukekarrys)
* [`8145faf`](https://github.com/npm/are-we-there-yet/commit/8145faf4d52aeb91d203c147fb94294a62298122) [#181](https://github.com/npm/are-we-there-yet/pull/181) bump @npmcli/template-oss from 4.17.0 to 4.18.0 (@dependabot[bot])
## [4.0.1](https://github.com/npm/are-we-there-yet/compare/v4.0.0...v4.0.1) (2023-07-17)
### Bug Fixes
* [`aee9063`](https://github.com/npm/are-we-there-yet/commit/aee90632efbeb9d2d0efc98e4a8346906bc0fe3f) [#178](https://github.com/npm/are-we-there-yet/pull/178) modernize class inheritance (#178) (@jimmywarting)
## [4.0.0](https://github.com/npm/are-we-there-yet/compare/v3.0.1...v4.0.0) (2022-10-10)
### ⚠️ BREAKING CHANGES
* `are-we-there-yet` is now compatible with the following semver range for node: `^14.17.0 || ^16.13.0 || >=18.0.0`
### Features
* [`529459c`](https://github.com/npm/are-we-there-yet/commit/529459c24875a8210c5fb472dcb6199cfea61acd) [#157](https://github.com/npm/are-we-there-yet/pull/157) postinstall for dependabot template-oss PR (@lukekarrys)
### Dependencies
* [`7af13fa`](https://github.com/npm/are-we-there-yet/commit/7af13fa1388e09abbbf4ce7e2ac6bb7a5fb81bc5) [#146](https://github.com/npm/are-we-there-yet/pull/146) bump readable-stream from 3.6.0 to 4.1.0
## [3.0.1](https://github.com/npm/are-we-there-yet/compare/v3.0.0...v3.0.1) (2022-07-21)
### Bug Fixes
* replace deprecated String.prototype.substr() ([#140](https://github.com/npm/are-we-there-yet/issues/140)) ([6145a9e](https://github.com/npm/are-we-there-yet/commit/6145a9ef6908c0feb107ac41f704e0aabe2718d0))
## [3.0.0](https://www.github.com/npm/are-we-there-yet/compare/v2.0.0...v3.0.0) (2022-02-09)
### ⚠ BREAKING CHANGES
* This drops support for node10 and non-LTS versions of node 12 and node 14
### Bug Fixes
* @npmcli/template-oss@2.7.1 ([f742777](https://www.github.com/npm/are-we-there-yet/commit/f7427775fcf59185b99693d2e5480e1185de8589))
### Documentation
* rename CHANGE.md to CHANGELOG.md ([2667644](https://www.github.com/npm/are-we-there-yet/commit/2667644d37bf9d1d9c25cdf3a133d607f151b8c2))
## 1.1.5 2018-05-24
* [#92](https://github.com/iarna/are-we-there-yet/pull/92) Fix bug where
`finish` would throw errors when including `TrackerStream` objects in
`TrackerGroup` collections. (@brianloveswords)
## 1.1.4 2017-04-21
* Fix typo in package.json
## 1.1.3 2017-04-21
* Improve documentation and limit files included in the distribution.
## 1.1.2 2016-03-15
* Add tracker group cycle detection and tests for it
## 1.1.1 2016-01-29
* Fix a typo in stream completion tracker
## 1.1.0 2016-01-29
* Rewrote completion percent computation to be low impact– no more walking a
tree of completion groups every time we need this info. Previously, with
medium sized tree of completion groups, even a relatively modest number of
calls to the top level `completed()` method would result in absurd numbers
of calls overall as it walked down the tree. We now, instead, keep track as
we bubble up changes, so the computation is limited to when data changes and
to the depth of that one branch, instead of _every_ node. (Plus, we were already
incurring _this_ cost, since we already bubbled out changes.)
* Moved different tracker types out to their own files.
* Made tests test for TOO MANY events too.
* Standarized the source code formatting
npm-are-we-there-yet-4f4c7da/CODE_OF_CONDUCT.md 0000664 0000000 0000000 00000000507 14546020536 0020672 0 ustar 00root root 0000000 0000000
All interactions in this repo are covered by the [npm Code of
Conduct](https://docs.npmjs.com/policies/conduct)
The npm cli team may, at its own discretion, moderate, remove, or edit
any interactions such as pull requests, issues, and comments.
npm-are-we-there-yet-4f4c7da/CONTRIBUTING.md 0000664 0000000 0000000 00000005133 14546020536 0020324 0 ustar 00root root 0000000 0000000
# Contributing
## Code of Conduct
All interactions in the **npm** organization on GitHub are considered to be covered by our standard [Code of Conduct](https://docs.npmjs.com/policies/conduct).
## Reporting Bugs
Before submitting a new bug report please search for an existing or similar report.
Use one of our existing issue templates if you believe you've come across a unique problem.
Duplicate issues, or issues that don't use one of our templates may get closed without a response.
## Pull Request Conventions
### Commits
We use [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
When opening a pull request please be sure that either the pull request title, or each commit in the pull request, has one of the following prefixes:
- `feat`: For when introducing a new feature. The result will be a new semver minor version of the package when it is next published.
- `fix`: For bug fixes. The result will be a new semver patch version of the package when it is next published.
- `docs`: For documentation updates. The result will be a new semver patch version of the package when it is next published.
- `chore`: For changes that do not affect the published module. Often these are changes to tests. The result will be *no* change to the version of the package when it is next published (as the commit does not affect the published version).
### Test Coverage
Pull requests made against this repo will run `npm test` automatically. Please make sure tests pass locally before submitting a PR.
Every new feature or bug fix should come with a corresponding test or tests that validate the solutions. Testing also reports on code coverage and will fail if code coverage drops.
### Linting
Linting is also done automatically once tests pass. `npm run lintfix` will fix most linting errors automatically.
Please make sure linting passes before submitting a PR.
## What _not_ to contribute?
### Dependencies
It should be noted that our team does not accept third-party dependency updates/PRs. If you submit a PR trying to update our dependencies we will close it with or without a reference to these contribution guidelines.
### Tools/Automation
Our core team is responsible for the maintenance of the tooling/automation in this project and we ask contributors to not make changes to these when contributing (e.g. `.github/*`, `.eslintrc.json`, `.licensee.json`). Most of those files also have a header at the top to remind folks they are automatically generated. Pull requests that alter these will not be accepted.
npm-are-we-there-yet-4f4c7da/LICENSE.md 0000664 0000000 0000000 00000001315 14546020536 0017475 0 ustar 00root root 0000000 0000000 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.
npm-are-we-there-yet-4f4c7da/README.md 0000664 0000000 0000000 00000014704 14546020536 0017356 0 ustar 00root root 0000000 0000000 are-we-there-yet
----------------
Track complex hierarchies of asynchronous task completion statuses. This is
intended to give you a way of recording and reporting the progress of the big
recursive fan-out and gather type workflows that are so common in async.
What you do with this completion data is up to you, but the most common use case is to
feed it to one of the many progress bar modules.
Most progress bar modules include a rudimentary version of this, but my
needs were more complex.
Usage
=====
```javascript
var TrackerGroup = require("are-we-there-yet").TrackerGroup
var top = new TrackerGroup("program")
var single = top.newItem("one thing", 100)
single.completeWork(20)
console.log(top.completed()) // 0.2
fs.stat("file", function(er, stat) {
if (er) throw er
var stream = top.newStream("file", stat.size)
console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete
// and 50% * 20% == 10%
fs.createReadStream("file").pipe(stream).on("data", function (chunk) {
// do stuff with chunk
})
top.on("change", function (name) {
// called each time a chunk is read from "file"
// top.completed() will start at 0.1 and fill up to 0.6 as the file is read
})
})
```
Shared Methods
==============
* var completed = tracker.completed()
Implemented in: `Tracker`, `TrackerGroup`, `TrackerStream`
Returns the ratio of completed work to work to be done. Range of 0 to 1.
* tracker.finish()
Implemented in: `Tracker`, `TrackerGroup`
Marks the tracker as completed. With a TrackerGroup this marks all of its
components as completed.
Marks all of the components of this tracker as finished, which in turn means
that `tracker.completed()` for this will now be 1.
This will result in one or more `change` events being emitted.
Events
======
All tracker objects emit `change` events with the following arguments:
```
function (name, completed, tracker)
```
`name` is the name of the tracker that originally emitted the event,
or if it didn't have one, the first containing tracker group that had one.
`completed` is the percent complete (as returned by `tracker.completed()` method).
`tracker` is the tracker object that you are listening for events on.
TrackerGroup
============
* var tracker = new TrackerGroup(**name**)
* **name** *(optional)* - The name of this tracker group, used in change
notifications if the component updating didn't have a name. Defaults to undefined.
Creates a new empty tracker aggregation group. These are trackers whose
completion status is determined by the completion status of other trackers added to this aggregation group.
Ex.
```javascript
var tracker = new TrackerGroup("parent")
var foo = tracker.newItem("firstChild", 100)
var bar = tracker.newItem("secondChild", 100)
foo.finish()
console.log(tracker.completed()) // 0.5
bar.finish()
console.log(tracker.completed()) // 1
```
* tracker.addUnit(**otherTracker**, **weight**)
* **otherTracker** - Any of the other are-we-there-yet tracker objects
* **weight** *(optional)* - The weight to give the tracker, defaults to 1.
Adds the **otherTracker** to this aggregation group. The weight determines
how long you expect this tracker to take to complete in proportion to other
units. So for instance, if you add one tracker with a weight of 1 and
another with a weight of 2, you're saying the second will take twice as long
to complete as the first. As such, the first will account for 33% of the
completion of this tracker and the second will account for the other 67%.
Returns **otherTracker**.
* var subGroup = tracker.newGroup(**name**, **weight**)
The above is exactly equivalent to:
```javascript
var subGroup = tracker.addUnit(new TrackerGroup(name), weight)
```
* var subItem = tracker.newItem(**name**, **todo**, **weight**)
The above is exactly equivalent to:
```javascript
var subItem = tracker.addUnit(new Tracker(name, todo), weight)
```
* var subStream = tracker.newStream(**name**, **todo**, **weight**)
The above is exactly equivalent to:
```javascript
var subStream = tracker.addUnit(new TrackerStream(name, todo), weight)
```
* console.log( tracker.debug() )
Returns a tree showing the completion of this tracker group and all of its
children, including recursively entering all of the children.
Tracker
=======
* var tracker = new Tracker(**name**, **todo**)
* **name** *(optional)* The name of this counter to report in change
events. Defaults to undefined.
* **todo** *(optional)* The amount of work todo (a number). Defaults to 0.
Ordinarily these are constructed as a part of a tracker group (via
`newItem`).
* var completed = tracker.completed()
Returns the ratio of completed work to work to be done. Range of 0 to 1. If
total work to be done is 0 then it will return 0.
* tracker.addWork(**todo**)
* **todo** A number to add to the amount of work to be done.
Increases the amount of work to be done, thus decreasing the completion
percentage. Triggers a `change` event.
* tracker.completeWork(**completed**)
* **completed** A number to add to the work complete
Increase the amount of work complete, thus increasing the completion percentage.
Will never increase the work completed past the amount of work todo. That is,
percentages > 100% are not allowed. Triggers a `change` event.
* tracker.finish()
Marks this tracker as finished, tracker.completed() will now be 1. Triggers
a `change` event.
TrackerStream
=============
* var tracker = new TrackerStream(**name**, **size**, **options**)
* **name** *(optional)* The name of this counter to report in change
events. Defaults to undefined.
* **size** *(optional)* The number of bytes being sent through this stream.
* **options** *(optional)* A hash of stream options
The tracker stream object is a pass through stream that updates an internal
tracker object each time a block passes through. It's intended to track
downloads, file extraction and other related activities. You use it by piping
your data source into it and then using it as your data source.
If your data has a length attribute then that's used as the amount of work
completed when the chunk is passed through. If it does not (eg, object
streams) then each chunk counts as completing 1 unit of work, so your size
should be the total number of objects being streamed.
* tracker.addWork(**todo**)
* **todo** Increase the expected overall size by **todo** bytes.
Increases the amount of work to be done, thus decreasing the completion
percentage. Triggers a `change` event.
npm-are-we-there-yet-4f4c7da/SECURITY.md 0000664 0000000 0000000 00000002321 14546020536 0017660 0 ustar 00root root 0000000 0000000
GitHub takes the security of our software products and services seriously, including the open source code repositories managed through our GitHub organizations, such as [GitHub](https://github.com/GitHub).
If you believe you have found a security vulnerability in this GitHub-owned open source repository, you can report it to us in one of two ways.
If the vulnerability you have found is *not* [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) or if you do not wish to be considered for a bounty reward, please report the issue to us directly through [opensource-security@github.com](mailto:opensource-security@github.com).
If the vulnerability you have found is [in scope for the GitHub Bug Bounty Program](https://bounty.github.com/#scope) and you would like for your finding to be considered for a bounty reward, please submit the vulnerability to us through [HackerOne](https://hackerone.com/github) in order to be eligible to receive a bounty award.
**Please do not report security vulnerabilities through public GitHub issues, discussions, or pull requests.**
Thanks for helping make GitHub safe for everyone.
npm-are-we-there-yet-4f4c7da/lib/ 0000775 0000000 0000000 00000000000 14546020536 0016637 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/lib/index.js 0000664 0000000 0000000 00000000243 14546020536 0020303 0 ustar 00root root 0000000 0000000 'use strict'
exports.TrackerGroup = require('./tracker-group.js')
exports.Tracker = require('./tracker.js')
exports.TrackerStream = require('./tracker-stream.js')
npm-are-we-there-yet-4f4c7da/lib/tracker-base.js 0000664 0000000 0000000 00000000346 14546020536 0021543 0 ustar 00root root 0000000 0000000 'use strict'
const EventEmitter = require('events')
let trackerId = 0
class TrackerBase extends EventEmitter {
constructor (name) {
super()
this.id = ++trackerId
this.name = name
}
}
module.exports = TrackerBase
npm-are-we-there-yet-4f4c7da/lib/tracker-group.js 0000664 0000000 0000000 00000005551 14546020536 0021770 0 ustar 00root root 0000000 0000000 'use strict'
const TrackerBase = require('./tracker-base.js')
const Tracker = require('./tracker.js')
const TrackerStream = require('./tracker-stream.js')
class TrackerGroup extends TrackerBase {
parentGroup = null
trackers = []
completion = {}
weight = {}
totalWeight = 0
finished = false
bubbleChange = bubbleChange(this)
nameInTree () {
var names = []
var from = this
while (from) {
names.unshift(from.name)
from = from.parentGroup
}
return names.join('/')
}
addUnit (unit, weight) {
if (unit.addUnit) {
var toTest = this
while (toTest) {
if (unit === toTest) {
throw new Error(
'Attempted to add tracker group ' +
unit.name + ' to tree that already includes it ' +
this.nameInTree(this))
}
toTest = toTest.parentGroup
}
unit.parentGroup = this
}
this.weight[unit.id] = weight || 1
this.totalWeight += this.weight[unit.id]
this.trackers.push(unit)
this.completion[unit.id] = unit.completed()
unit.on('change', this.bubbleChange)
if (!this.finished) {
this.emit('change', unit.name, this.completion[unit.id], unit)
}
return unit
}
completed () {
if (this.trackers.length === 0) {
return 0
}
var valPerWeight = 1 / this.totalWeight
var completed = 0
for (var ii = 0; ii < this.trackers.length; ii++) {
var trackerId = this.trackers[ii].id
completed +=
valPerWeight * this.weight[trackerId] * this.completion[trackerId]
}
return completed
}
newGroup (name, weight) {
return this.addUnit(new TrackerGroup(name), weight)
}
newItem (name, todo, weight) {
return this.addUnit(new Tracker(name, todo), weight)
}
newStream (name, todo, weight) {
return this.addUnit(new TrackerStream(name, todo), weight)
}
finish () {
this.finished = true
if (!this.trackers.length) {
this.addUnit(new Tracker(), 1, true)
}
for (var ii = 0; ii < this.trackers.length; ii++) {
var tracker = this.trackers[ii]
tracker.finish()
tracker.removeListener('change', this.bubbleChange)
}
this.emit('change', this.name, 1, this)
}
debug (depth = 0) {
const indent = ' '.repeat(depth)
let output = `${indent}${this.name || 'top'}: ${this.completed()}\n`
this.trackers.forEach(function (tracker) {
output += tracker instanceof TrackerGroup
? tracker.debug(depth + 1)
: `${indent} ${tracker.name}: ${tracker.completed()}\n`
})
return output
}
}
function bubbleChange (trackerGroup) {
return function (name, completed, tracker) {
trackerGroup.completion[tracker.id] = completed
if (trackerGroup.finished) {
return
}
trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup)
}
}
module.exports = TrackerGroup
npm-are-we-there-yet-4f4c7da/lib/tracker-stream.js 0000664 0000000 0000000 00000001501 14546020536 0022116 0 ustar 00root root 0000000 0000000 'use strict'
const stream = require('stream')
const Tracker = require('./tracker.js')
class TrackerStream extends stream.Transform {
constructor (name, size, options) {
super(options)
this.tracker = new Tracker(name, size)
this.name = name
this.id = this.tracker.id
this.tracker.on('change', this.trackerChange.bind(this))
}
trackerChange (name, completion) {
this.emit('change', name, completion, this)
}
_transform (data, encoding, cb) {
this.tracker.completeWork(data.length ? data.length : 1)
this.push(data)
cb()
}
_flush (cb) {
this.tracker.finish()
cb()
}
completed () {
return this.tracker.completed()
}
addWork (work) {
return this.tracker.addWork(work)
}
finish () {
return this.tracker.finish()
}
}
module.exports = TrackerStream
npm-are-we-there-yet-4f4c7da/lib/tracker.js 0000664 0000000 0000000 00000001324 14546020536 0020630 0 ustar 00root root 0000000 0000000 'use strict'
const TrackerBase = require('./tracker-base.js')
class Tracker extends TrackerBase {
constructor (name, todo) {
super(name)
this.workDone = 0
this.workTodo = todo || 0
}
completed () {
return this.workTodo === 0 ? 0 : this.workDone / this.workTodo
}
addWork (work) {
this.workTodo += work
this.emit('change', this.name, this.completed(), this)
}
completeWork (work) {
this.workDone += work
if (this.workDone > this.workTodo) {
this.workDone = this.workTodo
}
this.emit('change', this.name, this.completed(), this)
}
finish () {
this.workTodo = this.workDone = 1
this.emit('change', this.name, 1, this)
}
}
module.exports = Tracker
npm-are-we-there-yet-4f4c7da/package.json 0000664 0000000 0000000 00000002477 14546020536 0020371 0 ustar 00root root 0000000 0000000 {
"name": "are-we-there-yet",
"version": "4.0.2",
"description": "Keep track of the overall completion of many disparate processes",
"main": "lib/index.js",
"scripts": {
"test": "tap",
"lint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\"",
"lintfix": "npm run lint -- --fix",
"posttest": "npm run lint",
"postsnap": "npm run lintfix --",
"snap": "tap",
"postlint": "template-oss-check",
"template-oss-apply": "template-oss-apply --force"
},
"repository": {
"type": "git",
"url": "https://github.com/npm/are-we-there-yet.git"
},
"author": "GitHub Inc.",
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/are-we-there-yet/issues"
},
"homepage": "https://github.com/npm/are-we-there-yet",
"devDependencies": {
"@npmcli/eslint-config": "^4.0.0",
"@npmcli/template-oss": "4.21.3",
"tap": "^16.0.1"
},
"files": [
"bin/",
"lib/"
],
"engines": {
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
},
"tap": {
"branches": 68,
"statements": 92,
"functions": 86,
"lines": 92,
"nyc-arg": [
"--exclude",
"tap-snapshots/**"
]
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.21.3",
"publish": true
}
}
npm-are-we-there-yet-4f4c7da/release-please-config.json 0000664 0000000 0000000 00000001473 14546020536 0023123 0 ustar 00root root 0000000 0000000 {
"group-pull-request-title-pattern": "chore: release ${version}",
"pull-request-title-pattern": "chore: release${component} ${version}",
"changelog-sections": [
{
"type": "feat",
"section": "Features",
"hidden": false,
"collapse": false
},
{
"type": "fix",
"section": "Bug Fixes",
"hidden": false,
"collapse": false
},
{
"type": "docs",
"section": "Documentation",
"hidden": false,
"collapse": false
},
{
"type": "deps",
"section": "Dependencies",
"hidden": false,
"collapse": false
},
{
"type": "chore",
"section": "Chores",
"hidden": false,
"collapse": false
}
],
"packages": {
".": {
"package-name": ""
}
},
"prerelease-type": "pre"
}
npm-are-we-there-yet-4f4c7da/test/ 0000775 0000000 0000000 00000000000 14546020536 0017050 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/test/lib/ 0000775 0000000 0000000 00000000000 14546020536 0017616 5 ustar 00root root 0000000 0000000 npm-are-we-there-yet-4f4c7da/test/lib/test-event.js 0000664 0000000 0000000 00000001626 14546020536 0022257 0 ustar 00root root 0000000 0000000 'use strict'
var util = require('util')
module.exports = function (obj, event, next) {
var timeout = setTimeout(gotTimeout, 10)
obj.once(event, gotResult)
function gotTimeout () {
obj.removeListener(event, gotResult)
next(new Error('Timeout listening for ' + event))
}
var result = []
function gotResult () {
result = Array.prototype.slice.call(arguments)
clearTimeout(timeout)
timeout = setTimeout(gotNoMoreResults, 10)
obj.once(event, gotTooManyResults)
}
function gotNoMoreResults () {
obj.removeListener(event, gotTooManyResults)
var args = [null].concat(result)
next.apply(null, args)
}
function gotTooManyResults () {
var secondResult = Array.prototype.slice.call(arguments)
clearTimeout(timeout)
next(new Error(
'Got too many results, first ' +
util.inspect(result) + ' and then ' +
util.inspect(secondResult))
)
}
}
npm-are-we-there-yet-4f4c7da/test/lib/tracker.js 0000664 0000000 0000000 00000003055 14546020536 0021612 0 ustar 00root root 0000000 0000000 'use strict'
var test = require('tap').test
var Tracker = require('../..').Tracker
var testEvent = require('./test-event.js')
var name = 'test'
test('initialization', function (t) {
var simple = new Tracker(name)
t.equal(simple.completed(), 0, 'Nothing todo is 0 completion')
t.end()
})
var track
var todo = 100
test('completion', function (t) {
track = new Tracker(name, todo)
t.equal(track.completed(), 0, 'Nothing done is 0 completion')
testEvent(track, 'change', afterCompleteWork)
track.completeWork(todo)
t.equal(track.completed(), 1, 'completeWork: 100% completed')
function afterCompleteWork (er, onChangeName) {
t.equal(er, null, 'completeWork: on change event fired')
t.equal(onChangeName, name, 'completeWork: on change emits the correct name')
t.end()
}
})
test('add more work', function (t) {
testEvent(track, 'change', afterAddWork)
track.addWork(todo)
t.equal(track.completed(), 0.5, 'addWork: 50% completed')
function afterAddWork (er, onChangeName) {
t.equal(er, null, 'addWork: on change event fired')
t.equal(onChangeName, name, 'addWork: on change emits the correct name')
t.end()
}
})
test('complete more work', function (t) {
track.completeWork(200)
t.equal(track.completed(), 1, 'completeWork: Over completion is still only 100% complete')
t.end()
})
test('finish is always 100%', function (t) {
var finishtest = new Tracker(name, todo)
finishtest.completeWork(50)
finishtest.finish()
t.equal(finishtest.completed(), 1, 'finish: Explicitly finishing moves to 100%')
t.end()
})
npm-are-we-there-yet-4f4c7da/test/lib/trackergroup.js 0000664 0000000 0000000 00000010133 14546020536 0022662 0 ustar 00root root 0000000 0000000 'use strict'
var test = require('tap').test
var TrackerGroup = require('../..').TrackerGroup
var testEvent = require('./test-event.js')
test('TrackerGroup', function (t) {
var name = 'test'
var track = new TrackerGroup(name)
t.equal(track.completed(), 0, 'Nothing todo is 0 completion')
testEvent(track, 'change', afterFinishEmpty)
track.finish()
var a, b
function afterFinishEmpty (er, onChangeName, completion) {
t.equal(er, null, 'finishEmpty: on change event fired')
t.equal(onChangeName, name, 'finishEmpty: on change emits the correct name')
t.equal(completion, 1, 'finishEmpty: passed through completion was correct')
t.equal(track.completed(), 1, 'finishEmpty: Finishing an empty group actually finishes it')
track = new TrackerGroup(name)
a = track.newItem('a', 10, 1)
b = track.newItem('b', 10, 1)
t.equal(track.completed(), 0, 'Initially empty')
testEvent(track, 'change', afterCompleteWork)
a.completeWork(5)
}
function afterCompleteWork (er, onChangeName, completion) {
t.equal(er, null, 'on change event fired')
t.equal(onChangeName, 'a', 'on change emits the correct name')
t.equal(completion, 0.25, 'Complete half of one is a quarter overall')
t.equal(track.completed(), 0.25, 'Complete half of one is a quarter overall')
testEvent(track, 'change', afterFinishAll)
track.finish()
}
function afterFinishAll (er, onChangeName, completion) {
t.equal(er, null, 'finishAll: on change event fired')
t.equal(onChangeName, name, 'finishAll: on change emits the correct name')
t.equal(completion, 1, 'Finishing everything ')
t.equal(track.completed(), 1, 'Finishing everything ')
track = new TrackerGroup(name)
a = track.newItem('a', 10, 2)
b = track.newItem('b', 10, 1)
t.equal(track.completed(), 0, 'weighted: Initially empty')
testEvent(track, 'change', afterWeightedCompleteWork)
a.completeWork(5)
}
function afterWeightedCompleteWork (er, onChangeName, completion) {
t.equal(er, null, 'weighted: on change event fired')
t.equal(onChangeName, 'a', 'weighted: on change emits the correct name')
t.equal(Math.floor(completion * 100), 33, 'weighted: Complete half of double weighted')
t.equal(Math.floor(track.completed() * 100), 33, 'weighted: Complete half of double weighted')
testEvent(track, 'change', afterWeightedFinishAll)
track.finish()
}
function afterWeightedFinishAll (er, onChangeName, completion) {
t.equal(er, null, 'weightedFinishAll: on change event fired')
t.equal(onChangeName, name, 'weightedFinishAll: on change emits the correct name')
t.equal(completion, 1, 'weightedFinishaAll: Finishing everything ')
t.equal(track.completed(), 1, 'weightedFinishaAll: Finishing everything ')
track = new TrackerGroup(name)
a = track.newGroup('a', 10)
b = track.newGroup('b', 10)
var a1 = a.newItem('a.1', 10)
a1.completeWork(5)
t.equal(track.completed(), 0.25, 'nested: Initially quarter done')
testEvent(track, 'change', afterNestedComplete)
b.finish()
}
function afterNestedComplete (er, onChangeName, completion) {
t.equal(er, null, 'nestedComplete: on change event fired')
t.equal(onChangeName, 'b', 'nestedComplete: on change emits the correct name')
t.equal(completion, 0.75, 'nestedComplete: Finishing everything ')
t.equal(track.completed(), 0.75, 'nestedComplete: Finishing everything ')
t.end()
}
})
test('cycles', function (t) {
var track = new TrackerGroup('top')
testCycle(track, track)
var layer1 = track.newGroup('layer1')
testCycle(layer1, track)
t.equal(track.debug(), 'top: 0\n layer1: 0\n')
t.end()
function testCycle (addTo, toAdd) {
try {
addTo.addUnit(toAdd)
t.fail(toAdd.name)
} catch (ex) {
console.log(ex)
t.pass(toAdd.name)
}
}
})
test('should properly handle finish calls when the group contains a stream', function (t) {
var track = new TrackerGroup('test')
track.newStream('test-stream', 100)
try {
track.finish()
t.pass('did not error on `finish()` call')
} catch (e) {
t.fail('threw error on `finish()` call')
}
t.end()
})
npm-are-we-there-yet-4f4c7da/test/lib/trackerstream.js 0000664 0000000 0000000 00000002713 14546020536 0023026 0 ustar 00root root 0000000 0000000 'use strict'
var test = require('tap').test
var util = require('util')
var stream = require('stream')
var TrackerStream = require('../..').TrackerStream
var testEvent = require('./test-event.js')
var Sink = function () {
stream.Writable.apply(this, arguments)
}
util.inherits(Sink, stream.Writable)
Sink.prototype._write = function (data, encoding, cb) {
cb()
}
test('TrackerStream', function (t) {
t.plan(9)
var name = 'test'
var track = new TrackerStream(name)
t.equal(track.completed(), 0, 'Nothing todo is 0 completion')
var todo = 10
track = new TrackerStream(name, todo)
t.equal(track.completed(), 0, 'Nothing done is 0 completion')
track.pipe(new Sink())
testEvent(track, 'change', afterCompleteWork)
track.write('0123456789')
function afterCompleteWork (er, onChangeName) {
t.equal(er, null, 'write: on change event fired')
t.equal(onChangeName, name, 'write: on change emits the correct name')
t.equal(track.completed(), 1, 'write: 100% completed')
testEvent(track, 'change', afterAddWork)
track.addWork(10)
}
function afterAddWork (er, onChangeName) {
t.equal(er, null, 'addWork: on change event fired')
t.equal(track.completed(), 0.5, 'addWork: 50% completed')
testEvent(track, 'change', afterAllWork)
track.write('ABCDEFGHIJKLMNOPQRST')
}
function afterAllWork (er) {
t.equal(er, null, 'allWork: on change event fired')
t.equal(track.completed(), 1, 'allWork: 100% completed')
}
})