diff --git a/.github/.keepalive b/.github/.keepalive deleted file mode 100644 index 128d472..0000000 --- a/.github/.keepalive +++ /dev/null @@ -1 +0,0 @@ -2023-02-01T02:39:54.431Z diff --git a/.github/workflows/productionize.yml b/.github/workflows/productionize.yml index f4eea88..3e8e2db 100644 --- a/.github/workflows/productionize.yml +++ b/.github/workflows/productionize.yml @@ -34,6 +34,12 @@ on: type: boolean default: true + # Run workflow upon completion of `publish` workflow run: + workflow_run: + workflows: ["publish"] + types: [completed] + + # Concurrency group to prevent multiple concurrent executions: concurrency: group: productionize @@ -94,10 +100,11 @@ jobs: # Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency: - name: 'Update dependencies in package.json' run: | + PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version) if grep -q '"@stdlib/string-format"' package.json; then - sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json + sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json else - node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^0.0.x'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" + node -e "var pkg = require( './package.json' ); pkg.dependencies[ '@stdlib/error-tools-fmtprodmsg' ] = '^$PKG_VERSION'; require( 'fs' ).writeFileSync( 'package.json', JSON.stringify( pkg, null, 2 ) );" fi # Configure git: diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ad8ed19..26be02d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -21,9 +21,23 @@ name: publish # Workflow triggers: on: - # Run workflow when a new tag is pushed to the repository: - push: - tags: v[0-9]+.[0-9]+.[0-9]+ + # Allow the workflow to be manually run: + workflow_dispatch: + # Workflow inputs: + inputs: + version: + description: 'Version Increment' + type: choice + default: 'none' + options: + - 'none' + - 'major' + - 'minor' + - 'patch' + - 'premajor' + - 'preminor' + - 'prepatch' + - 'prerelease' # Workflow jobs: jobs: @@ -32,7 +46,7 @@ jobs: publish: # Define display name: - name: 'Publish to npm' + name: 'Publish package to npm' # Define the type of virtual host machine on which to run the job: runs-on: ubuntu-latest @@ -40,6 +54,7 @@ jobs: # Define environment variables: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} # Define the sequence of job steps... steps: @@ -55,6 +70,91 @@ jobs: node-version: 16 timeout-minutes: 5 + # Configure git: + - name: 'Configure git' + run: | + git config --local user.email "noreply@stdlib.io" + git config --local user.name "stdlib-bot" + + # Increment package version (if requested): + - name: 'Increment package version (if requested)' + if: ${{ github.event.inputs.version != 'none' }} + run: | + # Save NPM_TOKEN to user's .npmrc: + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc + + # Increment package version: + npm version ${{ github.event.inputs.version }} --no-git-tag-version + + # Define variable for new version: + NEW_VERSION=$(node -p "require('./package.json').version") + + # Replace branch in README.md link definitions for badges with the new version: + find . -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/branch([=:])[^ ]+/branch\1v${NEW_VERSION}/g" + + # Create a new commit and tag: + git add package.json README.md + git commit -m "Release v${NEW_VERSION}" + git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}" + + # Push changes to GitHub: + SLUG=${{ github.repository }} + git push "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$SLUG.git" --follow-tags + + # Remove CLI: + - name: 'Remove CLI' + if: ${{ github.ref == 'refs/heads/main' }} + run: | + # Exit if the package does not have a CLI: + if ! grep -q '"bin":' package.json; then + exit 0 + fi + rm -rf ./bin/cli + rm -f test/test.cli.js + rm -f etc/cli_opts.json + rm -f docs/usage.txt + + # For all dependencies, check in all *.js files if they are still used; if not, remove them: + jq -r '.dependencies | keys[]' ./package.json | while read -r dep; do + dep=$(echo "$dep" | xargs) + if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then + jq --indent 2 "del(.dependencies[\"$dep\"])" ./package.json > ./package.json.tmp + mv ./package.json.tmp ./package.json + fi + done + jq -r '.devDependencies | keys[]' ./package.json | while read -r dep; do + if [[ "$dep" != "@stdlib"* ]]; then + continue + fi + dep=$(echo "$dep" | xargs) + if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then + jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp + mv ./package.json.tmp ./package.json + fi + done + + # Remove CLI section: + find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?
[\s\S]+?<\!\-\- \/.cli \-\->//" + + # Remove CLI from package.json: + jq -r 'del(.bin)' package.json > package.json.tmp + mv package.json.tmp package.json + + # Add entry for CLI package to See Also section of README.md: + cliPkgName=$(jq -r '.name' package.json)-cli + escapedPkg=$(echo "$cliPkgName" | sed -e 's/\//\\\//g') + escapedPkg=$(echo "$escapedPkg" | sed -e 's/\@/\\\@/g') + find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
(?:\n\n\* \* \*\n\n## See Also\n\n)?/
\n\n## See Also\n\n- [\`$escapedPkg\`][$escapedPkg]<\/span>: <\/span>CLI package for use as a command-line utility.<\/span>\n/" + + # Add link definition for CLI package to README.md: + find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/
/
\n\n[$escapedPkg]: https:\/\/www.npmjs.com\/package\/$escapedPkg/" + + # Replace GitHub MathJax equations with SVGs: + - name: 'Replace GitHub MathJax equations with SVGs' + run: | + find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/```math\n([\s\S]+?)\n```\n\n//g' + find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/)/
/sg' + # Replace GitHub links to individual packages with npm links: - name: 'Replace all GitHub links to individual packages with npm links' run: | @@ -65,14 +165,39 @@ jobs: run: | find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`\n\nAlternatively,[^<]+<\/section>/\`\`\`\n\n<\/section>/" + # Remove unnecessary files: + - name: 'Remove unnecessary files' + run: | + rm -f docs/repl.txt + rm -f docs/types/test.ts + # Replace all stdlib GitHub dependencies with the respective npm packages: - name: 'Replace all stdlib GitHub dependencies with the respective npm packages' run: | - find package.json -type f -print0 | xargs -0 sed -Ei 's/"github:stdlib-js[^"]*"/"^0.0.x"/g' + for dep in $(jq -r '.dependencies | keys | .[]' package.json); do + if [[ "$dep" != "@stdlib"* ]]; then + continue + fi + # Trim leading and trailing whitespace: + dep=$(echo "$dep" | xargs) + version="^$(npm view $dep version)" + jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp + mv package.json.tmp package.json + done + for dep in $(jq -r '.devDependencies | keys | .[]' package.json); do + if [[ "$dep" != "@stdlib"* ]]; then + continue + fi + # Trim leading and trailing whitespace: + dep=$(echo "$dep" | xargs) + version="^$(npm view $dep version)" + jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp + mv package.json.tmp package.json + done # Publish package to npm: - name: 'Publish package to npm' - uses: JS-DevTools/npm-publish@v1 + uses: JS-DevTools/npm-publish@v2 with: token: ${{ secrets.NPM_TOKEN }} access: public diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index efa04b5..30de997 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,6 +32,11 @@ on: # Run workflow on each push to the main branch: push: + # Run workflow upon completion of `publish` workflow run: + workflow_run: + workflows: ["publish"] + types: [completed] + # Workflow jobs: jobs: diff --git a/.gitignore b/.gitignore index 9641214..49b206b 100644 --- a/.gitignore +++ b/.gitignore @@ -182,3 +182,7 @@ jsconfig.json ################ *.sublime-workspace *.sublime-project + +# Other editor files # +###################### +.idea/ diff --git a/CONTRIBUTORS b/CONTRIBUTORS index f97b6ef..0c2727b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -9,22 +9,30 @@ Bruno Fenzl Christopher Dambamuromo Dominik Moritz Frank Kovacs +Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com> James Jithin KS Joey Reed +Jordan-Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com> Joris Labie Justin Dennison +KATTA NAGA NITHIN <88046362+nithinkatta@users.noreply.github.com> Marcus Matt Cochrane Milan Raj Momtchil Momtchev +Naresh Jagadeesan <37257700+Infinage@users.noreply.github.com> Ognjen Jevremović Philipp Burckhardt Pranav <85227306+Pranavchiku@users.noreply.github.com> Ricky Reusser +Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Ryan Seal Seyyed Parsa Neshaei Shraddheya Shendre Stephannie Jiménez Gacha +Yernar Yergaziyev dorrin-sot <59933477+dorrin-sot@users.noreply.github.com> +drunken_devv <90555965+amitjimiwal@users.noreply.github.com> +orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu diff --git a/README.md b/README.md index b160206..3c69ded 100644 --- a/README.md +++ b/README.md @@ -231,7 +231,7 @@ while ( true ) { ## See Also -- [`@stdlib/random/base/gumbel`][@stdlib/random/base/gumbel]: Gumbel distributed pseudorandom numbers. +- [`@stdlib/random-base/gumbel`][@stdlib/random/base/gumbel]: Gumbel distributed pseudorandom numbers.
@@ -290,7 +290,7 @@ Copyright © 2016-2023. The Stdlib [Authors][stdlib-authors]. --> [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg -[chat-url]: https://gitter.im/stdlib-js/stdlib/ +[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im [stdlib]: https://github.com/stdlib-js/stdlib diff --git a/branches.md b/branches.md index 6aee481..8c6dab8 100644 --- a/branches.md +++ b/branches.md @@ -38,12 +38,12 @@ C -->|bundle| D[esm]; C -->|bundle| E[deno]; C -->|bundle| F[umd]; -click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/iter/gumbel" -click B href "https://github.com/stdlib-js/random-iter-gumbel/tree/main" -click C href "https://github.com/stdlib-js/random-iter-gumbel/tree/production" -click D href "https://github.com/stdlib-js/random-iter-gumbel/tree/esm" -click E href "https://github.com/stdlib-js/random-iter-gumbel/tree/deno" -click F href "https://github.com/stdlib-js/random-iter-gumbel/tree/umd" +%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/iter/gumbel" +%% click B href "https://github.com/stdlib-js/random-iter-gumbel/tree/main" +%% click C href "https://github.com/stdlib-js/random-iter-gumbel/tree/production" +%% click D href "https://github.com/stdlib-js/random-iter-gumbel/tree/esm" +%% click E href "https://github.com/stdlib-js/random-iter-gumbel/tree/deno" +%% click F href "https://github.com/stdlib-js/random-iter-gumbel/tree/umd" ``` [stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/random/iter/gumbel diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index 20d227d..2a8ad52 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -21,7 +21,7 @@ /// import * as random from '@stdlib/types/random'; -import { Iterator } from '@stdlib/types/iter'; +import { TypedIterator } from '@stdlib/types/iter'; /** * Interface defining function options. @@ -56,7 +56,7 @@ interface Options { /** * Interface for iterators of pseudorandom numbers drawn from a Gumbel distribution. */ -interface RandIter extends Iterator { +interface Iterator extends TypedIterator { /** * Underlying PRNG. */ @@ -113,7 +113,7 @@ interface RandIter extends Iterator { * * // ... */ -declare function iterator( mu: number, beta: number, options?: Options ): RandIter; // tslint:disable-line:max-line-length +declare function iterator( mu: number, beta: number, options?: Options ): Iterator; // EXPORTS // diff --git a/docs/types/test.ts b/docs/types/test.ts index deb936d..7c4e5e7 100644 --- a/docs/types/test.ts +++ b/docs/types/test.ts @@ -23,9 +23,9 @@ import iterator = require( './index' ); // The function returns an iterator... { - iterator( -2.0, 5.0 ); // $ExpectType RandIter - iterator( 2.0, 5.0, {} ); // $ExpectType RandIter - iterator( 2.0, 5.0, { 'iter': 10 } ); // $ExpectType RandIter + iterator( -2.0, 5.0 ); // $ExpectType Iterator + iterator( 2.0, 5.0, {} ); // $ExpectType Iterator + iterator( 2.0, 5.0, { 'iter': 10 } ); // $ExpectType Iterator } // The compiler throws an error if the function is provided invalid input arguments... diff --git a/package.json b/package.json index 4f9b38c..0488a75 100644 --- a/package.json +++ b/package.json @@ -37,33 +37,33 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { - "@stdlib/assert-has-own-property": "^0.0.x", - "@stdlib/assert-is-nonnegative-integer": "^0.0.x", - "@stdlib/assert-is-number": "^0.0.x", - "@stdlib/assert-is-plain-object": "^0.0.x", - "@stdlib/assert-is-positive-number": "^0.0.x", - "@stdlib/constants-float64-max": "^0.0.x", - "@stdlib/math-base-assert-is-nan": "^0.0.x", - "@stdlib/random-base-gumbel": "^0.0.x", - "@stdlib/string-format": "^0.0.x", - "@stdlib/symbol-iterator": "^0.0.x", - "@stdlib/types": "^0.0.x", - "@stdlib/utils-constant-function": "^0.0.x", - "@stdlib/utils-copy": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x", - "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.x", - "@stdlib/utils-noop": "^0.0.x" + "@stdlib/assert-has-own-property": "^0.0.7", + "@stdlib/assert-is-nonnegative-integer": "^0.0.7", + "@stdlib/assert-is-number": "^0.0.7", + "@stdlib/assert-is-plain-object": "^0.0.7", + "@stdlib/assert-is-positive-number": "^0.0.7", + "@stdlib/constants-float64-max": "^0.0.8", + "@stdlib/math-base-assert-is-nan": "^0.0.8", + "@stdlib/random-base-gumbel": "^0.0.6", + "@stdlib/string-format": "^0.0.3", + "@stdlib/symbol-iterator": "^0.0.7", + "@stdlib/types": "^0.0.14", + "@stdlib/utils-constant-function": "^0.0.8", + "@stdlib/utils-copy": "^0.0.7", + "@stdlib/utils-define-nonenumerable-read-only-accessor": "^0.0.7", + "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.7", + "@stdlib/utils-define-nonenumerable-read-write-accessor": "^0.0.7", + "@stdlib/utils-noop": "^0.0.14" }, "devDependencies": { - "@stdlib/array-uint32": "^0.0.x", - "@stdlib/assert-is-uint32array": "^0.0.x", - "@stdlib/bench": "^0.0.x", - "@stdlib/constants-float64-eps": "^0.0.x", - "@stdlib/constants-uint32-max": "^0.0.x", - "@stdlib/random-base-minstd": "^0.0.x", - "@stdlib/random-base-randu": "^0.0.x", - "@stdlib/time-now": "^0.0.x", + "@stdlib/array-uint32": "^0.0.6", + "@stdlib/assert-is-uint32array": "^0.0.8", + "@stdlib/bench": "^0.0.12", + "@stdlib/constants-float64-eps": "^0.0.8", + "@stdlib/constants-uint32-max": "^0.0.7", + "@stdlib/random-base-minstd": "^0.0.6", + "@stdlib/random-base-randu": "^0.0.8", + "@stdlib/time-now": "^0.0.9", "proxyquire": "^2.0.0", "tape": "git+https://github.com/kgryte/tape.git#fix/globby", "istanbul": "^0.4.1", @@ -105,7 +105,7 @@ "iterable" ], "funding": { - "type": "patreon", - "url": "https://www.patreon.com/athan" + "type": "opencollective", + "url": "https://opencollective.com/stdlib" } }