|
1 | 1 | #/ |
2 | 2 | # @license Apache-2.0 |
3 | 3 | # |
4 | | -# Copyright (c) 2021 The Stdlib Authors. |
| 4 | +# Copyright (c) 2023 The Stdlib Authors. |
5 | 5 | # |
6 | 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
7 | 7 | # you may not use this file except in compliance with the License. |
|
46 | 46 | publish: |
47 | 47 |
|
48 | 48 | # Define display name: |
49 | | - name: 'Publish package to npm' |
| 49 | + name: 'Publish top-level package to npm' |
50 | 50 |
|
51 | 51 | # Define the type of virtual host machine on which to run the job: |
52 | 52 | runs-on: ubuntu-latest |
@@ -103,54 +103,6 @@ jobs: |
103 | 103 | SLUG=${{ github.repository }} |
104 | 104 | git push "https://$GITHUB_ACTOR:[email protected]/$SLUG.git" --follow-tags |
105 | 105 |
|
106 | | - # Remove CLI: |
107 | | - - name: 'Remove CLI' |
108 | | - if: ${{ github.ref == 'refs/heads/main' }} |
109 | | - run: | |
110 | | - # Exit if the package does not have a CLI: |
111 | | - if ! grep -q '"bin":' package.json; then |
112 | | - exit 0 |
113 | | - fi |
114 | | - rm -rf ./bin/cli |
115 | | - rm -f test/test.cli.js |
116 | | - rm -f etc/cli_opts.json |
117 | | - rm -f docs/usage.txt |
118 | | -
|
119 | | - # For all dependencies, check in all *.js files if they are still used; if not, remove them: |
120 | | - jq -r '.dependencies | keys[]' ./package.json | while read -r dep; do |
121 | | - dep=$(echo "$dep" | xargs) |
122 | | - if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then |
123 | | - jq --indent 2 "del(.dependencies[\"$dep\"])" ./package.json > ./package.json.tmp |
124 | | - mv ./package.json.tmp ./package.json |
125 | | - fi |
126 | | - done |
127 | | - jq -r '.devDependencies | keys[]' ./package.json | while read -r dep; do |
128 | | - if [[ "$dep" != "@stdlib"* ]]; then |
129 | | - continue |
130 | | - fi |
131 | | - dep=$(echo "$dep" | xargs) |
132 | | - if ! grep -q "$dep" lib/** && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then |
133 | | - jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp |
134 | | - mv ./package.json.tmp ./package.json |
135 | | - fi |
136 | | - done |
137 | | -
|
138 | | - # Remove CLI section: |
139 | | - find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+?<\!\-\- \/.cli \-\->//" |
140 | | -
|
141 | | - # Remove CLI from package.json: |
142 | | - jq -r 'del(.bin)' package.json > package.json.tmp |
143 | | - mv package.json.tmp package.json |
144 | | -
|
145 | | - # Add entry for CLI package to See Also section of README.md: |
146 | | - cliPkgName=$(jq -r '.name' package.json)-cli |
147 | | - escapedPkg=$(echo "$cliPkgName" | sed -e 's/\//\\\//g') |
148 | | - escapedPkg=$(echo "$escapedPkg" | sed -e 's/\@/\\\@/g') |
149 | | - 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/" |
150 | | -
|
151 | | - # Add link definition for CLI package to README.md: |
152 | | - 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/" |
153 | | -
|
154 | 106 | # Replace GitHub MathJax equations with SVGs: |
155 | 107 | - name: 'Replace GitHub MathJax equations with SVGs' |
156 | 108 | run: | |
|
0 commit comments