forked from sheetjs/docs.sheetjs.com
		
	
		
			
				
	
	
		
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			75 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
#!/bin/bash
 | 
						|
# https://docs.sheetjs.com/docs/demos/static/esbuild
 | 
						|
cd /tmp
 | 
						|
rm -rf sheetjs-esb
 | 
						|
mkdir sheetjs-esb
 | 
						|
cd sheetjs-esb
 | 
						|
npm init -y
 | 
						|
 | 
						|
npm i --save https://cdn.sheetjs.com/xlsx-latest/xlsx-latest.tgz
 | 
						|
npm i --save puppeteer express
 | 
						|
 | 
						|
cat >index.html <<EOF
 | 
						|
<!DOCTYPE html>
 | 
						|
<html>
 | 
						|
  <head>
 | 
						|
    <title>SheetJS + ESBuild</title>
 | 
						|
  </head>
 | 
						|
  <body>
 | 
						|
   <script src="out.js"></script>
 | 
						|
  </body>
 | 
						|
</html>
 | 
						|
EOF
 | 
						|
 | 
						|
cat >app.js <<EOF
 | 
						|
import data from './pres.numbers'
 | 
						|
const elt = document.createElement('div');
 | 
						|
elt.innerHTML = "<table><tr><th>Name</th><th>Index</th></tr>" +
 | 
						|
  data.map((row) => \`<tr>
 | 
						|
    <td>\${row.Name}</td>
 | 
						|
    <td>\${row.Index}</td>
 | 
						|
  </tr>\`).join("") +
 | 
						|
"</table>";
 | 
						|
document.body.appendChild(elt);
 | 
						|
EOF
 | 
						|
 | 
						|
curl -LO https://docs.sheetjs.com/esbuild/build.mjs
 | 
						|
curl -LO https://docs.sheetjs.com/pres.numbers
 | 
						|
 | 
						|
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});
 | 
						|
  const client = await page.target().createCDPSession();
 | 
						|
  await client.send('Browser.setDownloadBehavior', {
 | 
						|
    behavior: 'allow',
 | 
						|
    downloadPath: require("path").resolve('./')
 | 
						|
  });
 | 
						|
  page.on('request', req => console.log(req.url()));
 | 
						|
  await page.goto('http://localhost:7262/');
 | 
						|
  await new Promise((res,rej) => setTimeout(res, 1000));
 | 
						|
	const innerText = await page.evaluate(() => document.body.innerText);
 | 
						|
	console.log(innerText);
 | 
						|
  await browser.close();
 | 
						|
  process.exit();
 | 
						|
});
 | 
						|
EOF
 | 
						|
 | 
						|
 | 
						|
for n in 0.9.1 0.{9..24}; do
 | 
						|
	npm i --save esbuild@$n
 | 
						|
	npm ls | grep esbuild
 | 
						|
	rm -f out.js
 | 
						|
	node build.mjs
 | 
						|
	echo "Clinton" $(grep Clinton out.js | wc -l) "BESSELJ" $(grep BESSELJ out.js | wc -l)
 | 
						|
	node test.js
 | 
						|
done
 | 
						|
 |