Skip to content

Commit

Permalink
Import site
Browse files Browse the repository at this point in the history
  • Loading branch information
Krinkle committed Mar 28, 2024
1 parent 8a6723f commit 81e485a
Show file tree
Hide file tree
Showing 111 changed files with 1,825 additions and 48 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/spider-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ jobs:
# - https://example.org
# - https://example.github.io/
# - https://example.github.io/my-project/
MY_SITE: https://api.qunitjs.com
MY_SITE: https://qunitjs.com
steps:
- name: Checkout repo
uses: actions/checkout@v3
- uses: actions/checkout@v3

- name: Run hydra-link-checker
run: |
Expand Down
30 changes: 30 additions & 0 deletions .github/workflows/typesense.yaml
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
8 changes: 4 additions & 4 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,19 @@ git show
After the release is published, we need to update the website.
Check out the main branch of the [qunitjs/qunitjs.com](https://github.com/qunitjs/qunitjs.com) repository, and ensure it is clean and up-to-date. Run the following script, which will update release links and demos to use the new version:
Check out the main branch of the [qunitjs/qunit](https://github.com/qunitjs/qunit) repository, and ensure it is clean and up-to-date. Run the following script, which will update release links and demos to use the new version:
```
qunitjs.com$ node build/set-version.js <version>
qunit$ node build/site-set-version.js <version>
```
Stage the changes it made, and commit with the following message:
```
All: Update url and version to <version>
Docs: Update url and version to <version>
```
Push the commit, and check the website in a few minutes to verify the change ([deployment log](https://github.com/qunitjs/qunitjs.com/deployments/activity_log?environment=github-pages)).
Push the commit to a branch on origin, wait CI checks to complete, then re-push to the main branch. Check the website in a few minutes to verify the change ([deployment log](https://github.com/qunitjs/qunit/deployments/activity_log?environment=github-pages)).
## Final steps
Expand Down
70 changes: 70 additions & 0 deletions build/npm-search.js
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 <[email protected]> (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.
39 changes: 39 additions & 0 deletions build/site-set-version.js
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!" );
13 changes: 13 additions & 0 deletions build/site-update-plugins.js
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!');
}());
24 changes: 18 additions & 6 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[![Build Status: spider-check](https://github.com/qunitjs/qunit/actions/workflows/spider-check.yaml/badge.svg)](https://github.com/qunitjs/qunit/actions/workflows/spider-check.yaml)

# [api.qunitjs.com](https://api.qunitjs.com/)
# [qunitjs.com](https://qunitjs.com/)

This directory houses the content and code for the [qunitjs.com](https://qunitjs.com/) website.

## Table of contents

Expand All @@ -14,8 +16,6 @@

## Contribute

The API documentation site is hosted at <https://api.qunitjs.com> using GitHub Pages.

### Requirements

* [Ruby](https://www.ruby-lang.org/) (tested with Ruby 2.7)
Expand All @@ -24,11 +24,23 @@ The API documentation site is hosted at <https://api.qunitjs.com> using GitHub P
To install or update Jekyll and plugins:

```shell
bundle update
qunit/docs/$ bundle update
```

To regenerate the site and serve locally at <http://localhost:4000/>:

```shell
qunit/docs/$ bundle exec jekyll serve
```

### Update plugins

```shell
qunit/$ node build/site-update-plugins.js
```

To regenerate the site and serve locally at <http://127.0.0.1:4000/>:
### Update QUnit version

```shell
bundle exec jekyll serve
qunit/$ node build/site-set-version.js VERSION
```
18 changes: 14 additions & 4 deletions docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# Docs: https://jekyllrb.com/docs/configuration/
title: QUnit
description: The powerful, easy-to-use JavaScript testing framework.
url: "https://api.qunitjs.com"
baseurl: ""
permalink: /:title/
url: "https://qunitjs.com"
# For pages (not blog posts) this is equivalant to /:title/
permalink: /:year/:month/:day/:title/
lang: en
timezone: UTC
highlighter: rouge
Expand Down Expand Up @@ -36,7 +36,7 @@ amethyst:
# We keep a classic ICO file as well, for compat with de-facto standard
# machine discovery, e.g. search engines and analytics software.
favicon: /favicon.svg
home_href: https://qunitjs.com
home_href:
header_logo:
src: /img/logo-with-colored-text.svg
width: 250
Expand All @@ -47,8 +47,18 @@ amethyst:
twitter: qunitjs
github: qunitjs
gitter: qunitjs/qunit
# https://github.com/qunitjs/jekyll-theme-amethyst/blob/main/docs/getting-started.md#enable-typesense
typesense:
origin: https://typesense.jquery.com
collection: qunitjs_com
search_only_api_key: Zh8mMgohXECel9wjPwqT7lekLSG3OCgz

# Blog archives
#
# Docs: https://github.com/jekyll/jekyll-archives/
jekyll-archives:
enabled:
- year
layout: posts-year
permalinks:
year: "/:year/"
Loading

0 comments on commit 81e485a

Please sign in to comment.