Skip to content

Commit 45afc36

Browse files
committed
Auto-generated commit
1 parent 405ffa7 commit 45afc36

File tree

9 files changed

+212
-37
lines changed

9 files changed

+212
-37
lines changed

.github/workflows/productionize.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ on:
3434
type: boolean
3535
default: true
3636

37+
# Run workflow upon completion of `publish` workflow run:
38+
workflow_run:
39+
workflows: ["publish"]
40+
types: [completed]
41+
42+
3743
# Concurrency group to prevent multiple concurrent executions:
3844
concurrency:
3945
group: productionize
@@ -94,10 +100,11 @@ jobs:
94100
# Change `@stdlib/string-format` to `@stdlib/error-tools-fmtprodmsg` in package.json if the former is a dependency, otherwise insert it as a dependency:
95101
- name: 'Update dependencies in package.json'
96102
run: |
103+
PKG_VERSION=$(npm view @stdlib/error-tools-fmtprodmsg version)
97104
if grep -q '"@stdlib/string-format"' package.json; then
98-
sed -i "s/\"@stdlib\/string-format\"/\"@stdlib\/error-tools-fmtprodmsg\"/g" package.json
105+
sed -i "s/\"@stdlib\/string-format\": \"^.*\"/\"@stdlib\/error-tools-fmtprodmsg\": \"^$PKG_VERSION\"/g" package.json
99106
else
100-
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 ) );"
107+
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 ) );"
101108
fi
102109
103110
# Configure git:

.github/workflows/publish.yml

Lines changed: 131 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,23 @@ name: publish
2121

2222
# Workflow triggers:
2323
on:
24-
# Run workflow when a new tag is pushed to the repository:
25-
push:
26-
tags: v[0-9]+.[0-9]+.[0-9]+
24+
# Allow the workflow to be manually run:
25+
workflow_dispatch:
26+
# Workflow inputs:
27+
inputs:
28+
version:
29+
description: 'Version Increment'
30+
type: choice
31+
default: 'none'
32+
options:
33+
- 'none'
34+
- 'major'
35+
- 'minor'
36+
- 'patch'
37+
- 'premajor'
38+
- 'preminor'
39+
- 'prepatch'
40+
- 'prerelease'
2741

2842
# Workflow jobs:
2943
jobs:
@@ -32,14 +46,15 @@ jobs:
3246
publish:
3347

3448
# Define display name:
35-
name: 'Publish to npm'
49+
name: 'Publish package to npm'
3650

3751
# Define the type of virtual host machine on which to run the job:
3852
runs-on: ubuntu-latest
3953

4054
# Define environment variables:
4155
env:
4256
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
57+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4358

4459
# Define the sequence of job steps...
4560
steps:
@@ -55,6 +70,91 @@ jobs:
5570
node-version: 16
5671
timeout-minutes: 5
5772

73+
# Configure git:
74+
- name: 'Configure git'
75+
run: |
76+
git config --local user.email "[email protected]"
77+
git config --local user.name "stdlib-bot"
78+
79+
# Increment package version (if requested):
80+
- name: 'Increment package version (if requested)'
81+
if: ${{ github.event.inputs.version != 'none' }}
82+
run: |
83+
# Save NPM_TOKEN to user's .npmrc:
84+
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
85+
86+
# Increment package version:
87+
npm version ${{ github.event.inputs.version }} --no-git-tag-version
88+
89+
# Define variable for new version:
90+
NEW_VERSION=$(node -p "require('./package.json').version")
91+
92+
# Replace branch in README.md link definitions for badges with the new version:
93+
find . -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/branch([=:])[^ ]+/branch\1v${NEW_VERSION}/g"
94+
95+
# Create a new commit and tag:
96+
git add package.json README.md
97+
git commit -m "Release v${NEW_VERSION}"
98+
git tag -a "v${NEW_VERSION}" -m "Release v${NEW_VERSION}"
99+
100+
# Push changes to GitHub:
101+
SLUG=${{ github.repository }}
102+
git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" --follow-tags
103+
104+
# Remove CLI:
105+
- name: 'Remove CLI'
106+
if: ${{ github.ref == 'refs/heads/main' }}
107+
run: |
108+
# Exit if the package does not have a CLI:
109+
if ! grep -q '"bin":' package.json; then
110+
exit 0
111+
fi
112+
rm -rf ./bin/cli
113+
rm -f test/test.cli.js
114+
rm -f etc/cli_opts.json
115+
rm -f docs/usage.txt
116+
117+
# For all dependencies, check in all *.js files if they are still used; if not, remove them:
118+
jq -r '.dependencies | keys[]' ./package.json | while read -r dep; do
119+
dep=$(echo "$dep" | xargs)
120+
if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
121+
jq --indent 2 "del(.dependencies[\"$dep\"])" ./package.json > ./package.json.tmp
122+
mv ./package.json.tmp ./package.json
123+
fi
124+
done
125+
jq -r '.devDependencies | keys[]' ./package.json | while read -r dep; do
126+
if [[ "$dep" != "@stdlib"* ]]; then
127+
continue
128+
fi
129+
dep=$(echo "$dep" | xargs)
130+
if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
131+
jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp
132+
mv ./package.json.tmp ./package.json
133+
fi
134+
done
135+
136+
# Remove CLI section:
137+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+?<\!\-\- \/.cli \-\->//"
138+
139+
# Remove CLI from package.json:
140+
jq -r 'del(.bin)' package.json > package.json.tmp
141+
mv package.json.tmp package.json
142+
143+
# Add entry for CLI package to See Also section of README.md:
144+
cliPkgName=$(jq -r '.name' package.json)-cli
145+
escapedPkg=$(echo "$cliPkgName" | sed -e 's/\//\\\//g')
146+
escapedPkg=$(echo "$escapedPkg" | sed -e 's/\@/\\\@/g')
147+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"related\">(?:\n\n\* \* \*\n\n## See Also\n\n)?/<section class=\"related\">\n\n## See Also\n\n- <span class=\"package-name\">[\`$escapedPkg\`][$escapedPkg]<\/span><span class=\"delimiter\">: <\/span><span class=\"description\">CLI package for use as a command-line utility.<\/span>\n/"
148+
149+
# Add link definition for CLI package to README.md:
150+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<section class=\"links\">/<section class=\"links\">\n\n[$escapedPkg]: https:\/\/www.npmjs.com\/package\/$escapedPkg/"
151+
152+
# Replace GitHub MathJax equations with SVGs:
153+
- name: 'Replace GitHub MathJax equations with SVGs'
154+
run: |
155+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/```math\n([\s\S]+?)\n```\n\n//g'
156+
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe 's/<!-- <div class="equation"(.*)(<\/div>\s*-->)/<div class="equation"$1<\/div>/sg'
157+
58158
# Replace GitHub links to individual packages with npm links:
59159
- name: 'Replace all GitHub links to individual packages with npm links'
60160
run: |
@@ -65,14 +165,39 @@ jobs:
65165
run: |
66166
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`\n\nAlternatively,[^<]+<\/section>/\`\`\`\n\n<\/section>/"
67167
168+
# Remove unnecessary files:
169+
- name: 'Remove unnecessary files'
170+
run: |
171+
rm -f docs/repl.txt
172+
rm -f docs/types/test.ts
173+
68174
# Replace all stdlib GitHub dependencies with the respective npm packages:
69175
- name: 'Replace all stdlib GitHub dependencies with the respective npm packages'
70176
run: |
71-
find package.json -type f -print0 | xargs -0 sed -Ei 's/"github:stdlib-js[^"]*"/"^0.0.x"/g'
177+
for dep in $(jq -r '.dependencies | keys | .[]' package.json); do
178+
if [[ "$dep" != "@stdlib"* ]]; then
179+
continue
180+
fi
181+
# Trim leading and trailing whitespace:
182+
dep=$(echo "$dep" | xargs)
183+
version="^$(npm view $dep version)"
184+
jq -r --arg dep "$dep" --arg version "$version" '.dependencies[$dep] = $version' package.json > package.json.tmp
185+
mv package.json.tmp package.json
186+
done
187+
for dep in $(jq -r '.devDependencies | keys | .[]' package.json); do
188+
if [[ "$dep" != "@stdlib"* ]]; then
189+
continue
190+
fi
191+
# Trim leading and trailing whitespace:
192+
dep=$(echo "$dep" | xargs)
193+
version="^$(npm view $dep version)"
194+
jq -r --arg dep "$dep" --arg version "$version" '.devDependencies[$dep] = $version' package.json > package.json.tmp
195+
mv package.json.tmp package.json
196+
done
72197
73198
# Publish package to npm:
74199
- name: 'Publish package to npm'
75-
uses: JS-DevTools/npm-publish@v1
200+
uses: JS-DevTools/npm-publish@v2
76201
with:
77202
token: ${{ secrets.NPM_TOKEN }}
78203
access: public

.github/workflows/test.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ on:
3232
# Run workflow on each push to the main branch:
3333
push:
3434

35+
# Run workflow upon completion of `publish` workflow run:
36+
workflow_run:
37+
workflows: ["publish"]
38+
types: [completed]
39+
3540
# Workflow jobs:
3641
jobs:
3742

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,3 +182,7 @@ jsconfig.json
182182
################
183183
*.sublime-workspace
184184
*.sublime-project
185+
186+
# Other editor files #
187+
######################
188+
.idea/

CONTRIBUTORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,30 @@ Bruno Fenzl <[email protected]>
99
Christopher Dambamuromo <[email protected]>
1010
Dominik Moritz <[email protected]>
1111
Frank Kovacs <[email protected]>
12+
Harshita Kalani <[email protected]>
1213
1314
Jithin KS <[email protected]>
1415
Joey Reed <[email protected]>
16+
Jordan-Gallivan <[email protected]>
1517
Joris Labie <[email protected]>
1618
Justin Dennison <[email protected]>
19+
KATTA NAGA NITHIN <[email protected]>
1720
1821
Matt Cochrane <[email protected]>
1922
Milan Raj <[email protected]>
2023
Momtchil Momtchev <[email protected]>
24+
Naresh Jagadeesan <[email protected]>
2125
Ognjen Jevremović <[email protected]>
2226
Philipp Burckhardt <[email protected]>
2327
2428
Ricky Reusser <[email protected]>
29+
Roman Stetsyk <[email protected]>
2530
Ryan Seal <[email protected]>
2631
Seyyed Parsa Neshaei <[email protected]>
2732
Shraddheya Shendre <[email protected]>
2833
Stephannie Jiménez Gacha <[email protected]>
34+
Yernar Yergaziyev <[email protected]>
2935
dorrin-sot <[email protected]>
36+
drunken_devv <[email protected]>
37+
orimiles5 <[email protected]>
3038

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
200200
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-assert-is-accessor-array.svg
201201
[npm-url]: https://npmjs.org/package/@stdlib/array-base-assert-is-accessor-array
202202

203-
[test-image]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml/badge.svg?branch=v0.0.1
204-
[test-url]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml?query=branch:v0.0.1
203+
[test-image]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml/badge.svg?branch=main
204+
[test-url]: https://github.com/stdlib-js/array-base-assert-is-accessor-array/actions/workflows/test.yml?query=branch:main
205205

206206
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-assert-is-accessor-array/main.svg
207207
[coverage-url]: https://codecov.io/github/stdlib-js/array-base-assert-is-accessor-array?branch=main
@@ -214,7 +214,7 @@ Copyright &copy; 2016-2023. The Stdlib [Authors][stdlib-authors].
214214
-->
215215

216216
[chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
217-
[chat-url]: https://gitter.im/stdlib-js/stdlib/
217+
[chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
218218

219219
[stdlib]: https://github.com/stdlib-js/stdlib
220220

branches.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ C -->|bundle| D[esm];
3838
C -->|bundle| E[deno];
3939
C -->|bundle| F[umd];
4040
41-
click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/assert/is-accessor-array"
42-
click B href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/main"
43-
click C href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/production"
44-
click D href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/esm"
45-
click E href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/deno"
46-
click F href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/umd"
41+
%% click A href "https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/assert/is-accessor-array"
42+
%% click B href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/main"
43+
%% click C href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/production"
44+
%% click D href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/esm"
45+
%% click E href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/deno"
46+
%% click F href "https://github.com/stdlib-js/array-base-assert-is-accessor-array/tree/umd"
4747
```
4848

4949
[stdlib-url]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/base/assert/is-accessor-array

docs/types/index.d.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,38 @@
1616
* limitations under the License.
1717
*/
1818

19-
// TypeScript Version: 2.0
19+
// TypeScript Version: 4.1
2020

2121
/// <reference types="@stdlib/types"/>
2222

2323
import { Collection } from '@stdlib/types/object';
2424

25+
/**
26+
* Interface defining an array-like object supporting the accessor (get/set) protocol.
27+
*/
28+
interface AccessorArray {
29+
/**
30+
* Number of elements.
31+
*/
32+
length: number;
33+
34+
/**
35+
* Returns an array element.
36+
*
37+
* @param i - element index
38+
* @returns array element
39+
*/
40+
get( i: number ): any;
41+
42+
/**
43+
* Sets an array element.
44+
*
45+
* @param value - value(s)
46+
* @param i - element index at which to start writing values (default: 0)
47+
*/
48+
set( value: any, i?: number ): void;
49+
}
50+
2551
/**
2652
* Tests if an array-like object supports the accessor (get/set) protocol.
2753
*
@@ -39,7 +65,7 @@ import { Collection } from '@stdlib/types/object';
3965
* var bool = isAccessorArray( [] );
4066
* // returns false
4167
*/
42-
declare function isAccessorArray( value: Collection ): boolean;
68+
declare function isAccessorArray( value: Collection | AccessorArray ): value is AccessorArray; // tslint-disable-line max-line-length
4369

4470

4571
// EXPORTS //

package.json

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,24 +37,24 @@
3737
"url": "https://github.com/stdlib-js/stdlib/issues"
3838
},
3939
"dependencies": {
40-
"@stdlib/types": "^0.0.x"
40+
"@stdlib/types": "^0.0.14"
4141
},
4242
"devDependencies": {
43-
"@stdlib/array-complex128": "^0.0.x",
44-
"@stdlib/array-complex64": "^0.0.x",
45-
"@stdlib/array-float32": "^0.0.x",
46-
"@stdlib/array-float64": "^0.0.x",
47-
"@stdlib/array-int16": "^0.0.x",
48-
"@stdlib/array-int32": "^0.0.x",
49-
"@stdlib/array-int8": "^0.0.x",
50-
"@stdlib/array-uint16": "^0.0.x",
51-
"@stdlib/array-uint32": "^0.0.x",
52-
"@stdlib/array-uint8": "^0.0.x",
53-
"@stdlib/array-uint8c": "^0.0.x",
54-
"@stdlib/assert-is-boolean": "^0.0.x",
55-
"@stdlib/bench": "^0.0.x",
56-
"@stdlib/buffer-alloc-unsafe": "^0.0.x",
57-
"@stdlib/utils-constructor-name": "^0.0.x",
43+
"@stdlib/array-complex128": "^0.0.6",
44+
"@stdlib/array-complex64": "^0.0.6",
45+
"@stdlib/array-float32": "^0.0.6",
46+
"@stdlib/array-float64": "^0.0.6",
47+
"@stdlib/array-int16": "^0.0.6",
48+
"@stdlib/array-int32": "^0.0.6",
49+
"@stdlib/array-int8": "^0.0.6",
50+
"@stdlib/array-uint16": "^0.0.6",
51+
"@stdlib/array-uint32": "^0.0.6",
52+
"@stdlib/array-uint8": "^0.0.7",
53+
"@stdlib/array-uint8c": "^0.0.8",
54+
"@stdlib/assert-is-boolean": "^0.0.8",
55+
"@stdlib/bench": "^0.0.12",
56+
"@stdlib/buffer-alloc-unsafe": "^0.0.7",
57+
"@stdlib/utils-constructor-name": "^0.0.8",
5858
"tape": "git+https://github.com/kgryte/tape.git#fix/globby",
5959
"istanbul": "^0.4.1",
6060
"tap-min": "git+https://github.com/Planeshifter/tap-min.git"
@@ -107,7 +107,7 @@
107107
"validate"
108108
],
109109
"funding": {
110-
"type": "patreon",
111-
"url": "https://www.patreon.com/athan"
110+
"type": "opencollective",
111+
"url": "https://opencollective.com/stdlib"
112112
}
113113
}

0 commit comments

Comments
 (0)