Skip to content

Commit fc67352

Browse files
committed
add a demo GitHub Page that has Outerbase.EZQL loaded
perttierrc: reduce column width and apply it to the project remove demo/web/bundle.* update dist/*
1 parent 6857d12 commit fc67352

22 files changed

+136
-34
lines changed

.eslintrc.js

+6-10
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ module.exports = {
44
es2021: true,
55
node: true,
66
},
7-
extends: [
8-
"eslint:recommended",
9-
"plugin:@typescript-eslint/recommended",
10-
"prettier",
11-
],
7+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
128
overrides: [],
13-
parser: "@typescript-eslint/parser",
9+
parser: '@typescript-eslint/parser',
1410
parserOptions: {
15-
ecmaVersion: "latest",
16-
sourceType: "module",
11+
ecmaVersion: 'latest',
12+
sourceType: 'module',
1713
},
18-
plugins: ["@typescript-eslint"],
14+
plugins: ['@typescript-eslint'],
1915
rules: {},
20-
};
16+
}

.github/workflows/static.yml

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Simple workflow for deploying static content to GitHub Pages
2+
name: Deploy Demo to GitHub Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches: ['main']
8+
9+
# Allows you to run this workflow manually from the Actions tab
10+
workflow_dispatch:
11+
12+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
13+
permissions:
14+
contents: read
15+
pages: write
16+
id-token: write
17+
18+
# Allow one concurrent deployment
19+
concurrency:
20+
group: 'pages'
21+
cancel-in-progress: true
22+
23+
jobs:
24+
# Single deploy job since we're just deploying
25+
deploy:
26+
environment:
27+
name: github-pages
28+
url: ${{ steps.deployment.outputs.page_url }}
29+
runs-on: ubuntu-latest
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v3
33+
- name: Setup Pages
34+
uses: actions/configure-pages@v3
35+
- name: Upload artifact
36+
uses: actions/upload-pages-artifact@v1
37+
with:
38+
# Upload entire repository
39+
path: './demo/web'
40+
- name: Deploy to GitHub Pages
41+
id: deployment
42+
uses: actions/deploy-pages@v1

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# Project
2+
demo/web/bundle.*
3+
14
# Logs
25
logs
36
*.log

.prettierrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"tabWidth": 2,
44
"semi": false,
55
"singleQuote": true,
6-
"printWidth": 160
6+
"printWidth": 120
77
}

__tests__/ezql.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ describe('register EZQL', () => {
8787
const phrase = 'What is the answer to life, the univerise and everything?'
8888
const response = await ob.prompt(phrase, Prompt.data)
8989

90-
expect(fetch).toHaveBeenCalledWith(`https://${DEFAULT_HOST}/ezql?phrase=What+is+the+answer+to+life%2C+the+univerise+and+everything%3F&type=data`, {
91-
headers: { Authorization: `Bearer ${token}` },
92-
})
90+
expect(fetch).toHaveBeenCalledWith(
91+
`https://${DEFAULT_HOST}/ezql?phrase=What+is+the+answer+to+life%2C+the+univerise+and+everything%3F&type=data`,
92+
{
93+
headers: { Authorization: `Bearer ${token}` },
94+
}
95+
)
9396
expect(response).toEqual(mockedResponse)
9497
})
9598

@@ -102,9 +105,12 @@ describe('register EZQL', () => {
102105
const phrase = 'What is the answer to life, the univerise and everything?'
103106
const response = await ob.prompt(phrase, Prompt.sql)
104107

105-
expect(fetch).toHaveBeenCalledWith(`https://${DEFAULT_HOST}/ezql?phrase=What+is+the+answer+to+life%2C+the+univerise+and+everything%3F&type=sql`, {
106-
headers: { Authorization: `Bearer ${token}` },
107-
})
108+
expect(fetch).toHaveBeenCalledWith(
109+
`https://${DEFAULT_HOST}/ezql?phrase=What+is+the+answer+to+life%2C+the+univerise+and+everything%3F&type=sql`,
110+
{
111+
headers: { Authorization: `Bearer ${token}` },
112+
}
113+
)
108114
expect(response).toEqual(mockedResponse)
109115
})
110116
})

cli/index.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ program
1818
.option('-h, --host <value>', 'API host used for requests. Defaults to "api.outerbase.com".')
1919
.action(async (query, { execute, host, token: _token }) => {
2020
const token = _token || process.env.OUTERBASE_EZQL_TOKEN
21-
if (!token) throw new Error('"token" must be provided either as an argument (--token) or via the environment variable "OUTERBASE_EZQL_TOKEN"')
21+
if (!token)
22+
throw new Error(
23+
'"token" must be provided either as an argument (--token) or via the environment variable "OUTERBASE_EZQL_TOKEN"'
24+
)
2225

2326
const ezql = new EZQL({ token, host })
2427
const response = await ezql.prompt(query, execute ? Prompt.data : Prompt.sql)

contributing.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Welcome! We love receiving contributions from our community, so thanks for stopp
88
2. [Questions](#questions)
99
3. [Feature Requests](#feature-requests)
1010
4. [Reporting Bugs](#reporting-bugs)
11-
<br /><br />
11+
<br /><br />
1212

1313
## Code of Conduct
1414

@@ -18,6 +18,7 @@ To quote the famous William and Theodore:
1818
<br /><br />
1919

2020
## Questions
21+
2122
If you have any questions feel free to utilize our [Slack Community](https://join.slack.com/t/outerbasecommunity/shared_invite/zt-1ple7fhsg-2z6MIC_P4fzdrKe1koJ7kQ) or the [GitHub Discussions](https://github.com/Outerbase/ezql/discussions) board.
2223
<br /><br />
2324

@@ -38,6 +39,4 @@ Before you submit your issue, please [search the issue archive](https://github.c
3839

3940
If you find a bug in the source code, you can help us by [submitting an issue to our GitHub issue tracker](https://github.com/Outerbase/ezql/issues). Even better, you can submit a Pull Request with a fix!
4041

41-
*More contribution guidelines around code contribution and PR guidelines coming soon.*
42-
43-
42+
_More contribution guidelines around code contribution and PR guidelines coming soon._

demo/copy-assets.mjs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { copyFile } from 'fs/promises'
2+
import Path from 'node:path'
3+
import * as url from 'url'
4+
5+
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
6+
7+
export async function copyAssets() {
8+
// copy ../dist/umd/bundle.* to ./web/
9+
const assetPath = Path.join(__dirname, '..', 'dist', 'umd')
10+
const bundlePath = Path.join(assetPath, 'bundle.js')
11+
const bundleMapPath = Path.join(assetPath, 'bundle.js.map')
12+
return Promise.all([
13+
copyFile(bundlePath, Path.join(__dirname, 'web', 'bundle.js')),
14+
copyFile(bundleMapPath, Path.join(__dirname, 'web', 'bundle.map.js')),
15+
])
16+
}
17+
18+
copyAssets().catch((err) => {
19+
console.error(err)
20+
process.exit(1)
21+
})

demo/web/index.html

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
7+
<title>EZQL Demo</title>
8+
</head>
9+
<body>
10+
<!-- bundle.js is made available via `npm run update:demo`, a task that is automatically run by GitHub Actions when deploying the Page -->
11+
<script src="bundle.js"></script>
12+
<script>
13+
const ezql = new Outerbase.EZQL({ token: '8ab87a90-some-fake-uuid-c9bdb9974ce9' })
14+
console.debug('Created EZQL instance at `window.ezql`')
15+
console.debug(ezql)
16+
17+
console.info('You may now access the instantiated EZQL instance globally as `ezql`')
18+
console.info('See documentation at https://github.com/Outerbase/ezql#readme')
19+
console.info('Query for results:\t ezql.prompt("How much money did we make last week", Outerbase.Prompt.data)')
20+
console.info('Query for SQL:\t ezql.prompt("How much money did we make last week", Outerbase.Prompt.sql)')
21+
</script>
22+
</body>
23+
</html>

dist/cjs/ezql.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

dist/cjs/ezql.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/cli/index.js

100755100644
File mode changed.

dist/cli/index.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/esm/ezql.d.ts.map

+1-1
Original file line numberDiff line numberDiff line change

dist/esm/ezql.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"build:esm": "tsc -p config/tsconfig.esm.json",
2222
"build:types": "tsc -p config/tsconfig.types.json",
2323
"build:umd": "rollup --config --bundleConfigAsCjs",
24+
"update:demo": "npm run build:umd && node demo/copy-assets.mjs",
2425
"prepare": "husky install",
2526
"postinstall": "npm run build:cli"
2627
},

0 commit comments

Comments
 (0)