forked from sheetjs/docs.sheetjs.com
automated vitejs and browserify tests
This commit is contained in:
parent
c3741aaf05
commit
ac6e3daa1c
@ -25,7 +25,7 @@ $ make graph # build format graph and legend
|
||||
|
||||
The original documentation used [GFM](https://github.github.com/gfm/).
|
||||
|
||||
Pages currently use MDX v1.
|
||||
Pages currently use MDX v2.
|
||||
|
||||
<details>
|
||||
<summary><b>MDX Notes</b> (click to show)</summary>
|
||||
|
@ -41,9 +41,9 @@ This demo was tested in the following environments:
|
||||
|
||||
| ViteJS | Date |
|
||||
|:---------|:-----------|
|
||||
| `5.0.5` | 2023-12-04 |
|
||||
| `4.5.0` | 2023-12-04 |
|
||||
| `3.2.7` | 2023-12-05 |
|
||||
| `5.2.8` | 2024-04-13 |
|
||||
| `4.5.3` | 2024-04-13 |
|
||||
| `3.2.10` | 2024-04-13 |
|
||||
|
||||
:::
|
||||
|
||||
|
@ -34,8 +34,21 @@ This demo was tested in the following environments:
|
||||
|
||||
| Browserify | Date |
|
||||
|:-----------|:-----------|
|
||||
| `17.0.0` | 2023-12-04 |
|
||||
| `3.46.1` | 2023-12-04 |
|
||||
| `17.0.0` | 2024-04-13 |
|
||||
| `16.5.2` | 2024-04-13 |
|
||||
| `15.2.0` | 2024-04-13 |
|
||||
| `14.5.0` | 2024-04-13 |
|
||||
| `13.3.0` | 2024-04-13 |
|
||||
| `12.0.2` | 2024-04-13 |
|
||||
| `11.2.0` | 2024-04-13 |
|
||||
| `10.2.6` | 2024-04-13 |
|
||||
| `9.0.8` | 2024-04-13 |
|
||||
| `8.1.3` | 2024-04-13 |
|
||||
| `7.1.0` | 2024-04-13 |
|
||||
| `6.3.4` | 2024-04-13 |
|
||||
| `5.13.1` | 2024-04-13 |
|
||||
| `4.2.3` | 2024-04-13 |
|
||||
| `3.46.1` | 2024-04-13 |
|
||||
|
||||
:::
|
||||
|
||||
|
@ -181,7 +181,7 @@ const config = {
|
||||
}
|
||||
})
|
||||
},
|
||||
additionalLanguages: [ "visual-basic", "swift", "java", "php", "csharp", "perl", "ruby", "cpp", "applescript", "liquid", "rust", "dart", "wolfram", "matlab", "stata", "zig", "diff" ],
|
||||
additionalLanguages: [ "visual-basic", "swift", "java", "php", "csharp", "perl", "ruby", "cpp", "applescript", "liquid", "rust", "dart", "wolfram", "matlab", "stata", "zig", "diff", "bash" ],
|
||||
},
|
||||
liveCodeBlock: {
|
||||
playgroundPosition: 'top'
|
||||
|
100
tests/bundler-browserify.sh
Executable file
100
tests/bundler-browserify.sh
Executable file
@ -0,0 +1,100 @@
|
||||
#!/bin/bash
|
||||
# https://docs.sheetjs.com/docs/demos/frontend/bundler/browserify
|
||||
# requires global puppeteer and express
|
||||
|
||||
# sudo npm i -g puppeteer express@4
|
||||
cd /tmp
|
||||
rm -rf sheetjs-browserify-tests
|
||||
mkdir sheetjs-browserify-tests
|
||||
cd sheetjs-browserify-tests
|
||||
|
||||
for n in {3..17}; do
|
||||
mkdir sheetjs-browserify-$n
|
||||
cd sheetjs-browserify-$n
|
||||
npm init -y
|
||||
|
||||
npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz
|
||||
|
||||
cat >index.js <<EOF
|
||||
const { utils, version, writeFileXLSX } = require('xlsx');
|
||||
|
||||
document.getElementById("xport").addEventListener("click", function() {
|
||||
/* fetch JSON data and parse */
|
||||
var url = "https://sheetjs.com/data/executive.json";
|
||||
fetch(url).then(function(res) { return res.json(); }).then(function(raw_data) {
|
||||
|
||||
/* filter for the Presidents */
|
||||
var prez = raw_data.filter(function(row) { return row.terms.some(function(term) { return term.type === "prez"; }); });
|
||||
|
||||
/* sort by first presidential term */
|
||||
prez.forEach(function(row) {
|
||||
row.start = row.terms.find(function(term) {
|
||||
return term.type === "prez";
|
||||
}).start
|
||||
});
|
||||
prez.sort(function(l,r) { return l.start.localeCompare(r.start); });
|
||||
|
||||
/* flatten objects */
|
||||
var rows = prez.map(function(row) { return {
|
||||
name: row.name.first + " " + row.name.last,
|
||||
birthday: row.bio.birthday
|
||||
}; });
|
||||
|
||||
/* generate worksheet and workbook */
|
||||
var worksheet = utils.json_to_sheet(rows);
|
||||
var workbook = utils.book_new();
|
||||
utils.book_append_sheet(workbook, worksheet, "Dates");
|
||||
|
||||
/* fix headers */
|
||||
utils.sheet_add_aoa(worksheet, [["Name", "Birthday"]], { origin: "A1" });
|
||||
|
||||
/* calculate column width */
|
||||
var max_width = rows.reduce(function(w, r) { return Math.max(w, r.name.length); }, 10);
|
||||
worksheet["!cols"] = [ { wch: max_width } ];
|
||||
|
||||
/* create an XLSX file and try to save to Presidents.xlsx */
|
||||
//writeFileXLSX(workbook, "Presidents.xlsx");
|
||||
console.log(utils.sheet_to_csv(worksheet));
|
||||
});
|
||||
});
|
||||
EOF
|
||||
|
||||
npm install --save browserify@$n
|
||||
npm ls | grep browserify
|
||||
npx browserify@$n index.js > index.min.js
|
||||
|
||||
cat >index.html <<EOF
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head></head>
|
||||
<body>
|
||||
<h1>SheetJS Presidents Demo</h1>
|
||||
<button id="xport">Click here to export</button>
|
||||
<script src="./index.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
cat >test.js <<EOF
|
||||
const puppeteer = require('puppeteer');
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
app.use(express.static('./'));
|
||||
app.listen(7262, async() => {
|
||||
await new Promise((res,rej) => setTimeout(res, 1000));
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
page.on("console", msg => console.log("PAGE LOG:", msg.text()));
|
||||
await page.setViewport({width: 1920, height: 1080});
|
||||
await page.goto('http://localhost:7262/');
|
||||
await page.click("#xport");
|
||||
await new Promise((res,rej) => setTimeout(res, 1000));
|
||||
await browser.close();
|
||||
process.exit();
|
||||
});
|
||||
EOF
|
||||
|
||||
node test.js
|
||||
|
||||
cd -
|
||||
done
|
69
tests/bundler-vite.sh
Executable file
69
tests/bundler-vite.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# https://docs.sheetjs.com/docs/demos/frontend/bundler/vitejs
|
||||
# NOTE: this only checks whether data or SheetJS code is added to the bundle
|
||||
|
||||
cd /tmp
|
||||
rm -rf sheetjs-vite-tests
|
||||
mkdir sheetjs-vite-tests
|
||||
cd sheetjs-vite-tests
|
||||
|
||||
for n in {3..5}; do
|
||||
npm create vite@$n sheetjs-vite$n -- --template vue-ts
|
||||
cd sheetjs-vite$n
|
||||
npm i
|
||||
npm i --save https://cdn.sheetjs.com/xlsx-0.20.2/xlsx-0.20.2.tgz
|
||||
npm ls | grep vite
|
||||
|
||||
curl -O https://docs.sheetjs.com/vitejs/vite.config.ts
|
||||
|
||||
mkdir -p data
|
||||
curl -L -o data/pres.xlsx https://sheetjs.com/pres.xlsx
|
||||
|
||||
cat >src/components/HelloWorld.vue <<EOF
|
||||
<script setup lang="ts">
|
||||
// @ts-ignore
|
||||
import data from '../../data/pres.xlsx?sheetjs';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table>
|
||||
<tr><th>Name</th><th>Index</th></tr>
|
||||
<tr v-for="(row,R) in data" v-bind:key="R">
|
||||
<td>{{row.Name}}</td>
|
||||
<td>{{row.Index}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
EOF
|
||||
|
||||
npm run build
|
||||
echo "### Results: " $(grep Clinton -R dist | wc -l) $(grep BESSELJ -R dist | wc -l)
|
||||
|
||||
cat >src/components/HelloWorld.vue <<EOF
|
||||
<script setup lang="ts">
|
||||
// @ts-ignore
|
||||
import b64 from '../../data/pres.xlsx?b64';
|
||||
import { read, utils } from "xlsx";
|
||||
/* parse workbook and convert first sheet to row array */
|
||||
const wb = read(b64);
|
||||
const ws = wb.Sheets[wb.SheetNames[0]];
|
||||
interface IPresident { Name: string; Index: number; };
|
||||
const data = utils.sheet_to_json<IPresident>(ws);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<table>
|
||||
<tr><th>Name</th><th>Index</th></tr>
|
||||
<tr v-for="(row,R) in data" v-bind:key="R">
|
||||
<td>{{row.Name}}</td>
|
||||
<td>{{row.Index}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</template>
|
||||
EOF
|
||||
|
||||
npm run build
|
||||
echo "### Results: " $(grep Clinton -R dist | wc -l) $(grep BESSELJ -R dist | wc -l)
|
||||
cd -
|
||||
|
||||
done
|
@ -1,8 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# https://docs.sheetjs.com/docs/demos/engines/nashorn
|
||||
cd /tmp
|
||||
mkdir -p nashorn
|
||||
cd nashorn
|
||||
rm -rf sheetjs-nashorn
|
||||
mkdir -p sheetjs-nashorn
|
||||
cd sheetjs-nashorn
|
||||
|
||||
curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/xlsx.full.min.js
|
||||
curl -LO https://cdn.sheetjs.com/xlsx-latest/package/dist/shim.min.js
|
Loading…
Reference in New Issue
Block a user