Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Jun 1, 2022
1 parent e6b93bd commit fd037d5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
22 changes: 15 additions & 7 deletions .github/workflows/bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,12 +233,20 @@ jobs:
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
echo "::set-output name=alias::${alias}"
# Create Universal Module Definition (UMD) bundle:
- name: 'Create Universal Module Definition (UMD) bundle'
id: umd-bundle
# Create Universal Module Definition (UMD) Node.js bundle:
- name: 'Create Universal Module Definition (UMD) Node.js bundle'
id: umd-bundle-node
uses: stdlib-js/bundle-action@main
with:
target: 'umd'
target: 'umd-node'
alias: ${{ steps.extract-alias.outputs.alias }}

# Create Universal Module Definition (UMD) browser bundle:
- name: 'Create Universal Module Definition (UMD) browser bundle'
id: umd-bundle-browser
uses: stdlib-js/bundle-action@main
with:
target: 'umd-browser'
alias: ${{ steps.extract-alias.outputs.alias }}

# Rewrite file contents:
Expand All @@ -254,19 +262,19 @@ jobs:
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"c\">[\s\S]+<\!\-\- \/.c \-\->//g"
# Rewrite first `require()` to show consumption of the UMD bundle in Observable and via a `script` tag:
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n\`\`\`\n\nIf no recognized module system is present, access bundle contents via the global scope:\n\n\`\`\`html\n<script type=\"text\/javascript\">\n window.\2;\n<\/script>\n\`\`\`/"
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\`\`\`javascript\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);\n\`\`\`/To use in Observable,\n\n\`\`\`javascript\n\2 = require\( 'https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js' \)\n\`\`\`\n\nTo include the bundle in a webpage,\n\n\`\`\`html\n<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js\"><\/script>\n\`\`\`\n\nIf no recognized module system is present, access bundle contents via the global scope:\n\n\`\`\`html\n<script type=\"text\/javascript\">\n window.\2;\n<\/script>\n\`\`\`/"
# Rewrite examples section to be a HTML file:
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/\#\# Examples([\s\S]*)\`\`\`javascript([\s\S]+?)\`\`\`/\#\# Examples\1\`\`\`html\n<\!DOCTYPE html>\n<html lang=\"en\">\n<body>\n<script type=\"text\/javascript\">\2\n<\/script>\n<\/body>\n<\/html>\n\`\`\`/"
# Rewrite all `require()`s in the examples section as `script` tags loading the respective UMD bundle:
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "1 while s/<script type=\"text\/javascript\">\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);?/<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/bundle.js\"><\/script>\n<script type=\"text\/javascript\">/g"
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "1 while s/<script type=\"text\/javascript\">\n(var|let|const)\s+([a-zA-Z0-9_]+)\s+=\s*require\( '\@stdlib\/([^']+)' \);?/<script type=\"text\/javascript\" src=\"https:\/\/cdn.jsdelivr.net\/gh\/stdlib-js\/\3\@umd\/browser.js\"><\/script>\n<script type=\"text\/javascript\">/g"
# Wrap contents of `<script type="text/javascript">` tag contents in an IIFE:
find ./umd -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/<script type=\"text\/javascript\">([\s\S]+?)<\/script>/<script type=\"text\/javascript\">\n\(function \(\) {\1}\)\(\);\n<\/script>/g"
# Create package.json file for umd branch:
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "main": "./bundle.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./umd/package.json
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "main": "./index.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./umd/package.json
# Configure git:
- name: 'Configure git'
Expand Down
24 changes: 23 additions & 1 deletion .github/workflows/test_bundles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,29 @@ jobs:
# Try loading the UMD bundle:
- name: 'Try loading UMD bundle'
run: |
node --eval "require( './bundle.js' )" || exit $?
node --eval "require( './index.js' )" || exit $?
# Install playwright for headless browser testing:
- name: 'Install playwright'
run: |
npm install playwright
npx playwright install --with-deps chromium
# Try loading the UMD browser bundle with playwright:
- name: 'Try loading UMD browser bundle with playwright'
run: |
PLAYWRIGHT_SCRIPT="\
const { chromium } = require( 'playwright' );\
(async () => {\
const browser = await chromium.launch();\
const page = await browser.newPage();\
page.on( 'pageerror', exception => {\
throw new Error( exception.message );\
});\
await page.addScriptTag({ path: './browser.js' });\
await browser.close();\
})();"
node --eval "$PLAYWRIGHT_SCRIPT" || exit $?
# Send notification to Slack channel if job fails:
- name: 'Send status to Slack channel in case of failure'
Expand Down
4 changes: 2 additions & 2 deletions num-grapheme-clusters/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ var format = require( './../../format' );
* Returns the number of grapheme clusters in a string.
*
* @param {string} str - input string
* @throws {TypeError} must provide a string primitive
* @returns {NonNegative} number of grapheme clusters
* @throws {TypeError} must provide a string
* @returns {NonNegativeInteger} number of grapheme clusters
*
* @example
* var out = numGraphemeClusters( 'last man standing' );
Expand Down

0 comments on commit fd037d5

Please sign in to comment.