-
Notifications
You must be signed in to change notification settings - Fork 780
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
111 changed files
with
1,825 additions
and
48 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
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,30 @@ | ||
name: typesense | ||
on: | ||
# Once a day at 11:30 UTC <https://crontab.guru/> | ||
schedule: | ||
- cron: '30 11 * * *' | ||
# Or after a deployment | ||
push: | ||
branches: | ||
- main | ||
# Or manually | ||
workflow_dispatch: | ||
|
||
jobs: | ||
typesense: | ||
name: Update Typesense | ||
if: ${{ github.repository_owner == 'qunitjs' }} # skip on forks | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Docsearch Scraper | ||
shell: bash | ||
run: | | ||
# 0.6.0.rc1: https://github.com/typesense/typesense-docsearch-scraper/issues/36 | ||
docker run \ | ||
-e TYPESENSE_API_KEY=${{ secrets.TYPESENSE_ADMIN_KEY }} \ | ||
-e TYPESENSE_HOST="${{ secrets.TYPESENSE_HOST }}" \ | ||
-e TYPESENSE_PORT="443" \ | ||
-e TYPESENSE_PROTOCOL="https" \ | ||
-e CONFIG="$(cat docsearch.config.json | jq -r tostring)" \ | ||
typesense/docsearch-scraper:0.6.0.rc2 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/** | ||
* npm-search.js is based on npm-keyword v6.1.0 by @sindresorhus, | ||
* but simplified to not have 32 needless dependencies. | ||
* | ||
* - <https://github.com/sindresorhus/npm-keyword/tree/v6.1.0> | ||
* - <https://snyk.io/test/npm/npm-keyword/6.1.0?tab=dependencies> | ||
*/ | ||
'use strict'; | ||
const https = require('https'); | ||
const registryUrl = 'https://registry.npmjs.org/'; | ||
|
||
function fetch(url) { | ||
return new Promise((resolve, reject) => { | ||
const req = https.get(url, (resp) => { | ||
let data = ''; | ||
resp.on('data', (chunk) => { | ||
data += chunk; | ||
}); | ||
resp.on('end', () => { | ||
resolve(data); | ||
}); | ||
}); | ||
req.on('error', reject); | ||
}); | ||
} | ||
|
||
async function search(phrase, options) { | ||
if (options.size < 1 || options.size > 250) { | ||
// This limitation is enforced by the npm registry API. | ||
// <https://github.com/npm/registry/blob/1e2d9529e1/docs/REGISTRY-API.md#get-v1search> | ||
throw new TypeError('Size must be between 1 and 250'); | ||
} | ||
|
||
phrase = encodeURIComponent(phrase).replace('%2C', '+'); | ||
const url = `${registryUrl}-/v1/search?text=${phrase}&size=${options.size}`; | ||
return JSON.parse(await fetch(url)); | ||
} | ||
|
||
/** | ||
* @param {string} keyword | ||
* @return {Object[]} List of package objects | ||
*/ | ||
async function keyword(keyword) { | ||
const { objects } = await search('keywords:' + keyword, { size: 250 }); | ||
return objects.map(element => element.package); | ||
} | ||
|
||
module.exports = { search, keyword }; | ||
|
||
// Copyright 2020 Timo Tijhof <https://timotijhof.net> | ||
// Copyright 2017 Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining | ||
// a copy of this software and associated documentation files (the | ||
// "Software"), to deal in the Software without restriction, including | ||
// without limitation the rights to use, copy, modify, merge, publish, | ||
// distribute, sublicense, and/or sell copies of the Software, and to | ||
// permit persons to whom the Software is furnished to do so, subject to | ||
// the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be | ||
// included in all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
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,39 @@ | ||
const fs = require( "fs" ); | ||
|
||
const cdnLinks = [ | ||
|
||
// Match qunit-VERSION.js, qunit-VERSION.css, qunit-VERSION.{css.js} | ||
"qunit-VERSION" | ||
]; | ||
const files = { | ||
"docs/index.md": [ | ||
"vVERSION", | ||
"blob\/VERSION\/History.md", | ||
...cdnLinks | ||
], | ||
"docs/intro.md": [ ...cdnLinks ], | ||
"docs/resources/example-add.html": [ ...cdnLinks ], | ||
"docs/resources/example-index.html": [ ...cdnLinks ] | ||
}; | ||
|
||
const version = process.argv[ 2 ]; | ||
if ( typeof version !== "string" || !/^\d+\.\d+\.\d+$/.test( version ) ) { | ||
throw new Error( "Invalid or missing version argument" ); | ||
} | ||
|
||
for ( const [ file, patterns ] of Object.entries( files ) ) { | ||
console.log( `... updating ${file}` ); | ||
for ( let pattern of patterns ) { | ||
const replacement = pattern.replace( "VERSION", version ); | ||
pattern = pattern.replace( "VERSION", "\\d+\\.\\d+\\.\\d+" ); | ||
const find = new RegExp( `\\b${pattern}\\b`, 'g' ); | ||
const content = fs.readFileSync( file, "utf8" ).toString(); | ||
fs.writeFileSync( | ||
file, | ||
content.replace( find, replacement ), | ||
"utf8" | ||
); | ||
} | ||
} | ||
|
||
console.log( "Done!" ); |
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,13 @@ | ||
const fs = require('fs'); | ||
const { keyword } = require('./npm-search.js'); | ||
|
||
(async function main() { | ||
let plugins = await keyword('qunit-plugin'); | ||
plugins = plugins.map((plugin) => ({ | ||
name: plugin.name, | ||
description: plugin.description, | ||
date: plugin.date | ||
})).sort((a, b) => a.name < b.name ? -1 : 1); | ||
fs.writeFileSync('./docs/_data/plugins.json', JSON.stringify(plugins, null, 2) + '\n'); | ||
console.log('Done!'); | ||
}()); |
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
Oops, something went wrong.