-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce the `inject-subpath-exports` action (closes #12) * Introduce the `check-subpath-exports` action * Introduce the `publish-github-pages` action * Introduce the `setup-nodejs-context` action * Introduce the `install-system-packages` action * Simplify `find-critical-todos` and its documentation * Add the `registry-url` input to all the npm-related actions * Add the `enforce-esm` input to `verify-npm-package` * Check that package.json exists as a prerequisite for npm actions * Improve the tests and the related projects * Simplify all the `find` calls * Fix whitespace and formatting * Improve the output messages * Use `jq` instead of `cat` to print out `package.json` * Extend the documentation * Explain the permission required by `tag-and-release` * Add standard emojis to the READMEs * Remove the misleading `required` attribute from action inputs * Update repository description * Update the action diagram
- Loading branch information
1 parent
b427a88
commit b137b48
Showing
68 changed files
with
1,502 additions
and
399 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
.github/test-actions/test-check-subpath-exports/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Test check-subpath-exports | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: When the "exports" field is missing | ||
uses: ./.github/test-actions/test-check-subpath-exports/scenario | ||
with: | ||
jq-operation: del(.exports) | ||
|
||
- name: When the "exports" field is present but empty | ||
uses: ./.github/test-actions/test-check-subpath-exports/scenario | ||
with: | ||
jq-operation: .exports={} | ||
|
||
- name: When the "exports" field is a string | ||
uses: ./.github/test-actions/test-check-subpath-exports/scenario | ||
with: | ||
jq-operation: .exports="./src/beta/index.js" | ||
|
||
- name: When the "exports" field contains a string field | ||
uses: ./.github/test-actions/test-check-subpath-exports/scenario | ||
with: | ||
jq-operation: | | ||
.exports={ | ||
"beta": "./src/beta/index.js" | ||
} | ||
- name: When the "exports" field contains an object field | ||
uses: ./.github/test-actions/test-check-subpath-exports/scenario | ||
with: | ||
jq-operation: | | ||
.exports={ | ||
"beta": { | ||
"import": "./src/beta/index.js", | ||
"default": "./src/beta/index.js" | ||
} | ||
} | ||
- name: When the "exports" field contains multiple fields | ||
uses: ./.github/test-actions/test-check-subpath-exports/scenario | ||
with: | ||
jq-operation: | | ||
.exports={ | ||
"alpha": { | ||
"import": "./src/alpha/index.ts", | ||
"default": "./src/alpha/index.ts" | ||
}, | ||
"beta": { | ||
"import": "./src/beta/index.js", | ||
"default": "./src/beta/index.js" | ||
}, | ||
"omega": "./src/omega/index.ts" | ||
} |
20 changes: 20 additions & 0 deletions
20
.github/test-actions/test-check-subpath-exports/scenario/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Update and check subpath exports in the npm test project | ||
|
||
inputs: | ||
jq-operation: | ||
description: The operation altering the package.json descriptor | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Run the requested jq operation on package.json | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
jq '${{ inputs.jq-operation }}' package.json | sponge package.json | ||
echo "🔎The 'exports' field is:" | ||
jq '.exports' package.json | ||
- uses: ./actions/check-subpath-exports | ||
with: | ||
project-directory: ./tests/npm-package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
.github/test-actions/test-inject-subpath-exports/action.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
name: Test inject-subpath-exports | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Setup environment variables | ||
shell: bash | ||
run: | | ||
rootIndexFile="src/index.ts" | ||
echo "rootIndexFile=$rootIndexFile" >> $GITHUB_ENV | ||
- name: Backup package descriptor | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: cp package.json package.json.original | ||
|
||
- name: Ensure the root index file is initially missing | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
rm -f "$rootIndexFile" | ||
- name: Run with prefer-index mode - when the root index file is missing | ||
uses: ./actions/inject-subpath-exports | ||
with: | ||
project-directory: ./tests/npm-package | ||
mode: prefer-index | ||
|
||
- name: A subpath export should be generated for each subdirectory | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
echo "🔎Asserting injected subpath exports from subdirectories only..." | ||
grep -q '"./alpha"' package.json | ||
grep -q '"./beta"' package.json | ||
grep -q '"./omega"' package.json | ||
[[ "$(jq -r '.exports."./alpha".types' package.json)" == "./dist/alpha/index.d.ts" ]] || exit 1 | ||
[[ "$(jq -r '.exports."./alpha".import' package.json)" == "./dist/alpha/index.js" ]] || exit 1 | ||
! grep -q '"."' package.json | ||
! grep -q '"./sigma"' package.json | ||
echo "✅OK!" | ||
- name: Restore package.json and add a root index file | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
cp package.json.original package.json | ||
touch "$rootIndexFile" | ||
- name: Run again with prefer-index mode - now that the root index exists | ||
uses: ./actions/inject-subpath-exports | ||
with: | ||
project-directory: ./tests/npm-package | ||
mode: prefer-index | ||
|
||
- name: A subpath export should be generated only for the root index | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
echo "🔎Asserting injected subpath export for root index only..." | ||
! grep -q '"./alpha"' package.json | ||
! grep -q '"./beta"' package.json | ||
! grep -q '"./omega"' package.json | ||
grep -q '"."' package.json | ||
[[ "$(jq -r '.exports.".".types' package.json)" == "./dist/index.d.ts" ]] || exit 1 | ||
[[ "$(jq -r '.exports.".".import' package.json)" == "./dist/index.js" ]] || exit 1 | ||
! grep -q '"./sigma"' package.json | ||
echo "✅OK!" | ||
- name: Restore package descriptor with custom export | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
cp package.json.original package.json | ||
jq '.exports += {"./my-export": {"types": "./dist/my-export/index.d.ts", "import": "./dist/my-export/index.js"}}' package.json | sponge package.json | ||
- name: Run action with 'all' mode | ||
uses: ./actions/inject-subpath-exports | ||
with: | ||
project-directory: ./tests/npm-package | ||
mode: all | ||
|
||
- name: Subpath exports should be generated for both root index and subdirectories | ||
shell: bash | ||
working-directory: ./tests/npm-package | ||
run: | | ||
echo "🔎Asserting that all exports exist, including the manual ones..." | ||
grep -q '"./my-export"' package.json | ||
grep -q '"./alpha"' package.json | ||
grep -q '"./beta"' package.json | ||
grep -q '"./omega"' package.json | ||
grep -q '"."' package.json | ||
! grep -q '"./sigma"' package.json | ||
echo "✅OK!" |
Oops, something went wrong.