Skip to content

Commit 50f3dd1

Browse files
authored
Merge pull request #23 from stackql/dev/nodejs-support
Dev/nodejs support
2 parents 6abf926 + 7d3a784 commit 50f3dd1

30 files changed

+2158
-326
lines changed

.github/workflows/publish.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build and Publish Packages
2+
3+
on:
4+
release:
5+
types: [created]
6+
# push:
7+
# branches:
8+
# - dev/nodejs-support
9+
workflow_dispatch:
10+
inputs:
11+
version:
12+
description: "Version for Manual Release (e.g., 1.2.3-beta)"
13+
required: true
14+
15+
jobs:
16+
build-and-publish:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
21+
- name: Set up Deno
22+
uses: denoland/setup-deno@v1
23+
with:
24+
deno-version: "v1.x"
25+
26+
- name: Determine Version
27+
id: get_version
28+
run: |
29+
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
30+
if [ "${{ github.event_name }}" = "release" ]; then
31+
VERSION=${{ github.event.release.tag_name }}
32+
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
33+
VERSION=${{ github.event.inputs.version }}-$SHORT_SHA
34+
elif [ "${{ github.ref }}" = "refs/heads/dev/nodejs-support" ]; then
35+
VERSION=0.0.0-test-$SHORT_SHA
36+
fi
37+
echo "VERSION=$VERSION" >> $GITHUB_ENV
38+
39+
- name: Build NPM Package
40+
run: |
41+
echo "Building Version ${{ env.VERSION }}"
42+
deno run -A npm-support/build-npm.ts ${{ env.VERSION }}
43+
44+
- name: Publish to NPM
45+
run: |
46+
cd npm
47+
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
48+
npm publish --access public
49+
env:
50+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
51+
52+
- name: Install Dependencies for Test
53+
run: npm install @stackql/stackqljs@${{ env.VERSION }}
54+
55+
- name: Run Integration Test Script
56+
run: node ./.github/workflows/scripts/npm-module-test.mjs
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { StackQL } from "@stackql/stackqljs"; // Adjust this if the import path differs
2+
const assert = require("assert").strict;
3+
4+
async function runTests() {
5+
try {
6+
// Initialize stackQL
7+
await StackQL.initialize({ serverMode: false });
8+
9+
// Define queries
10+
const providerQuery = "SHOW PROVIDERS";
11+
const githubTestQuery = `SELECT id, name from github.repos.repos where org='stackql' and name='stackql'`;
12+
13+
// Execute queries
14+
const result = await stackQL.executeStatement(providerQuery);
15+
const githubResult = await stackQL.execute(githubTestQuery);
16+
const githubResultObj = githubResult[0];
17+
18+
// Assert
19+
assert(result.includes("name"), 'Result should include "name"');
20+
assert(result.includes("version"), 'Result should include "version"');
21+
assert(result.includes("github"), 'Result should include "github"');
22+
assert.equal(
23+
githubResultObj.name,
24+
"stackql",
25+
'GitHub result name should be "stackql"'
26+
);
27+
28+
console.log("All tests passed!");
29+
} catch (error) {
30+
console.error("Test failed:", error);
31+
process.exit(1); // Exit with error code
32+
}
33+
}
34+
35+
runTests();

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,8 @@ yarn-error.log*
3434
# typescript
3535
*.tsbuildinfo
3636
next-env.d.ts
37-
.stackql*
37+
.stackql*
38+
39+
# npm
40+
npm/*
41+
*/node_modules/

.vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"deno.enable": true,
2+
"deno.enablePaths": ["/deno"],
33
"deno.lint": true,
44
"deno.unstable": true,
5-
"deno.config": "./deno.json",
5+
"deno.config": "./deno/deno.json",
66
"editor.formatOnSave": true,
77
"[typescript]": {
88
"editor.defaultFormatter": "denoland.vscode-deno"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@
2929
```
3030
deno task test <optional: test file path>
3131
```
32+
33+
## NPM Support
34+
35+
- run ` deno run -A scripts/npm-build.ts`

deno.lock

Lines changed: 0 additions & 273 deletions
This file was deleted.

deno.json renamed to deno/deno.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
22
"lint": {
3-
"include": ["src/"],
4-
"exclude": ["src/testing/", "src/**/*.test.ts", "src/*test.ts/"],
53
"rules": {
64
"tags": ["recommended"],
75
"include": [],
@@ -15,8 +13,8 @@
1513
"semiColons": true,
1614
"singleQuote": true,
1715
"proseWrap": "preserve",
18-
"include": ["src/"],
19-
"exclude": ["*.md"]
16+
"exclude": ["/esm"],
17+
"include": ["./**/*.ts"]
2018
},
2119
"tasks": {
2220
"test": "deno test --allow-net --allow-read --allow-write --allow-env --allow-run"

deno/deno.lock

Lines changed: 82 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

deno/deps.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export { Client } from 'https://deno.land/x/postgres@v0.17.0/client.ts';
2+
export { assertExists } from 'https://deno.land/std@0.207.0/assert/assert_exists.ts';
3+
export { decompress } from 'https://deno.land/x/zip@v1.2.5/mod.ts';
4+
export { join } from 'https://deno.land/std@0.207.0/path/mod.ts';

deno/dev_deps.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export {
2+
assertRejects,
3+
assertStringIncludes,
4+
assertThrows,
5+
} from 'https://deno.land/std@0.207.0/assert/mod.ts';
6+
export {
7+
assert,
8+
assertEquals,
9+
assertExists,
10+
} from 'https://deno.land/std@0.207.0/testing/asserts.ts';
11+
12+
export {
13+
assertSpyCall,
14+
assertSpyCalls,
15+
spy,
16+
stub,
17+
} from 'https://deno.land/std@0.207.0/testing/mock.ts';

0 commit comments

Comments
 (0)