Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2acb78c
added the build script for npm package
yunchengyang515 Dec 19, 2023
a82d333
added the build script for npm package
yunchengyang515 Dec 19, 2023
f678a55
added publish github workflow
yunchengyang515 Dec 25, 2023
9bd5a18
added manual deploy workflow
yunchengyang515 Dec 25, 2023
5ef65f9
modified publish script
yunchengyang515 Dec 26, 2023
8e7e98a
added org scope in npm build
yunchengyang515 Dec 26, 2023
575dcd3
fix incorrect branch name in workflow
yunchengyang515 Dec 26, 2023
96fe6e9
fix incorrect script path
yunchengyang515 Dec 26, 2023
54adc1c
adjust the workflow to only run with release
yunchengyang515 Dec 26, 2023
1c3e70e
fix issues in workflow file
yunchengyang515 Dec 26, 2023
5d0c97c
added version debug
yunchengyang515 Dec 26, 2023
a67b233
fix indentation
yunchengyang515 Dec 26, 2023
3cf2534
fix nodejs support issue
yunchengyang515 Dec 26, 2023
b7319af
make access public
yunchengyang515 Dec 26, 2023
a35c363
added integration testing for NPM Package
yunchengyang515 Dec 29, 2023
6dc51e9
modify the integration test to run a script
yunchengyang515 Dec 29, 2023
0083fd3
added short sha in test version
yunchengyang515 Dec 29, 2023
806469d
correct the script name and path
yunchengyang515 Dec 29, 2023
c45150d
correct the path to the script
yunchengyang515 Dec 29, 2023
03b06b0
updated import
yunchengyang515 Dec 29, 2023
df86ade
rename testing file to mjs
yunchengyang515 Dec 29, 2023
cbf4347
forgot to rename the path to mjs in workflow
yunchengyang515 Dec 29, 2023
3fd9dc6
adjusted the imported object from npm package
yunchengyang515 Dec 29, 2023
aeb1c06
small error in test script
yunchengyang515 Dec 29, 2023
d34078e
update all the deno std version to 0.207.0
yunchengyang515 Dec 29, 2023
69cc407
fix assert import
yunchengyang515 Dec 29, 2023
210ea5e
worked around crypto error
yunchengyang515 Dec 30, 2023
97b5175
starting node project
yunchengyang515 Jan 4, 2024
91c558c
created new deno folder
yunchengyang515 Jan 7, 2024
bcb5f1d
fix deno fmt settings
yunchengyang515 Jan 7, 2024
b78047e
fixed deno issue by use deno.enablePaths
yunchengyang515 Jan 7, 2024
3db4418
fix deno config and include path
yunchengyang515 Jan 7, 2024
14e9312
fmt from cli with uniformed config
yunchengyang515 Jan 7, 2024
7d3a784
setup vitest
yunchengyang515 Jan 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Build and Publish Packages

on:
release:
types: [created]
# push:
# branches:
# - dev/nodejs-support
workflow_dispatch:
inputs:
version:
description: "Version for Manual Release (e.g., 1.2.3-beta)"
required: true

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Set up Deno
uses: denoland/setup-deno@v1
with:
deno-version: "v1.x"

- name: Determine Version
id: get_version
run: |
SHORT_SHA=$(echo ${{ github.sha }} | cut -c1-7)
if [ "${{ github.event_name }}" = "release" ]; then
VERSION=${{ github.event.release.tag_name }}
elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
VERSION=${{ github.event.inputs.version }}-$SHORT_SHA
elif [ "${{ github.ref }}" = "refs/heads/dev/nodejs-support" ]; then
VERSION=0.0.0-test-$SHORT_SHA
fi
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Build NPM Package
run: |
echo "Building Version ${{ env.VERSION }}"
deno run -A npm-support/build-npm.ts ${{ env.VERSION }}

- name: Publish to NPM
run: |
cd npm
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install Dependencies for Test
run: npm install @stackql/stackqljs@${{ env.VERSION }}

- name: Run Integration Test Script
run: node ./.github/workflows/scripts/npm-module-test.mjs
35 changes: 35 additions & 0 deletions .github/workflows/scripts/npm-module-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { StackQL } from "@stackql/stackqljs"; // Adjust this if the import path differs
const assert = require("assert").strict;

async function runTests() {
try {
// Initialize stackQL
await StackQL.initialize({ serverMode: false });

// Define queries
const providerQuery = "SHOW PROVIDERS";
const githubTestQuery = `SELECT id, name from github.repos.repos where org='stackql' and name='stackql'`;

// Execute queries
const result = await stackQL.executeStatement(providerQuery);
const githubResult = await stackQL.execute(githubTestQuery);
const githubResultObj = githubResult[0];

// Assert
assert(result.includes("name"), 'Result should include "name"');
assert(result.includes("version"), 'Result should include "version"');
assert(result.includes("github"), 'Result should include "github"');
assert.equal(
githubResultObj.name,
"stackql",
'GitHub result name should be "stackql"'
);

console.log("All tests passed!");
} catch (error) {
console.error("Test failed:", error);
process.exit(1); // Exit with error code
}
}

runTests();
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ yarn-error.log*
# typescript
*.tsbuildinfo
next-env.d.ts
.stackql*
.stackql*

# npm
npm/*
*/node_modules/
4 changes: 2 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"deno.enable": true,
"deno.enablePaths": ["/deno"],
"deno.lint": true,
"deno.unstable": true,
"deno.config": "./deno.json",
"deno.config": "./deno/deno.json",
"editor.formatOnSave": true,
"[typescript]": {
"editor.defaultFormatter": "denoland.vscode-deno"
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@
```
deno task test <optional: test file path>
```

## NPM Support

- run ` deno run -A scripts/npm-build.ts`
273 changes: 0 additions & 273 deletions deno.lock

This file was deleted.

6 changes: 2 additions & 4 deletions deno.json → deno/deno.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
{
"lint": {
"include": ["src/"],
"exclude": ["src/testing/", "src/**/*.test.ts", "src/*test.ts/"],
"rules": {
"tags": ["recommended"],
"include": [],
Expand All @@ -15,8 +13,8 @@
"semiColons": true,
"singleQuote": true,
"proseWrap": "preserve",
"include": ["src/"],
"exclude": ["*.md"]
"exclude": ["/esm"],
"include": ["./**/*.ts"]
},
"tasks": {
"test": "deno test --allow-net --allow-read --allow-write --allow-env --allow-run"
Expand Down
82 changes: 82 additions & 0 deletions deno/deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions deno/deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { Client } from 'https://deno.land/x/[email protected]/client.ts';
export { assertExists } from 'https://deno.land/[email protected]/assert/assert_exists.ts';
export { decompress } from 'https://deno.land/x/[email protected]/mod.ts';
export { join } from 'https://deno.land/[email protected]/path/mod.ts';
17 changes: 17 additions & 0 deletions deno/dev_deps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export {
assertRejects,
assertStringIncludes,
assertThrows,
} from 'https://deno.land/[email protected]/assert/mod.ts';
export {
assert,
assertEquals,
assertExists,
} from 'https://deno.land/[email protected]/testing/asserts.ts';

export {
assertSpyCall,
assertSpyCalls,
spy,
stub,
} from 'https://deno.land/[email protected]/testing/mock.ts';
3 changes: 3 additions & 0 deletions deno/mod.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { StackQL } from './src/stackql.ts';

export { StackQL };
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { assertExists, assertSpyCalls, spy } from '../../dev_deps.ts';
import { Downloader } from './downloader.ts';
import { removeStackQLDownload } from '../../testing/utils.ts';
import { removeStackQLDownload } from '../../../testing/utils.ts';

Deno.test('Downloader setupStackQL and upgrade Test', async () => {
// Arrange
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Server } from './server.ts';
import { assert } from '../../dev_deps.ts';
import { startStackQLServer } from '../../testing/utils.ts';
import { startStackQLServer } from '../../../testing/utils.ts';

Deno.test('Successful Connection', async () => {
const { closeProcess } = await startStackQLServer();
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/stackql.test.ts → deno/src/stackql.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../dev_deps.ts';

import { StackQL } from './stackql.ts';
import { isCsvString, startStackQLServer } from '../testing/utils.ts';
import { isCsvString, startStackQLServer } from '../../testing/utils.ts';
import { Downloader } from './services/downloader.ts';
import osUtils from './utils/os.ts';

Expand Down Expand Up @@ -176,7 +176,7 @@ Deno.test('Server mode: csv output throw error', async () => {
connectionString:
'postgres://postgres:password@localhost:5444/postgres',
});
const testQuery = 'SHOW SERVICES IN github LIKE \'%repos%\';'; // Replace with a valid query for your context
const testQuery = "SHOW SERVICES IN github LIKE '%repos%';"; // Replace with a valid query for your context

await stackQL.execute(testQuery);
} catch (error) {
Expand Down Expand Up @@ -204,7 +204,7 @@ Deno.test('Server mode: Query', async () => {
'postgres://postgres:password@localhost:5444/postgres',
});
const pullQuery = 'REGISTRY PULL github;';
const showServiceQuery = 'SHOW SERVICES IN github LIKE \'%repos%\';'; // Replace with a valid query for your context
const showServiceQuery = "SHOW SERVICES IN github LIKE '%repos%';"; // Replace with a valid query for your context

// Act
await stackQL.executeStatement(pullQuery);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 19 additions & 19 deletions src/utils/os.ts → deno/src/utils/os.ts
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
const fileExists = (path?: string) => {
if (!path) {
return false
return false;
}
try {
Deno.statSync(path)
return true
Deno.statSync(path);
return true;
} catch (error) {
if (error instanceof Deno.errors.NotFound) {
return false
return false;
}
throw error
throw error;
}
}
};

const chmod = async (path: string, mode: number) => {
if (Deno.build.os !== 'windows') {
await Deno.chmod(path, mode)
await Deno.chmod(path, mode);
}
}
};

const runCommand = async (path: string, args: string[]) => {
const process = new Deno.Command(path, {
args,
stdout: 'piped',
stderr: 'piped',
})
});

const { code, stdout, stderr } = await process.output()
const { code, stdout, stderr } = await process.output();

if (code === 0) {
const output = stdout
const result = new TextDecoder().decode(output)
return result
const output = stdout;
const result = new TextDecoder().decode(output);
return result;
} else {
const errorOutput = stderr
const errorMessage = new TextDecoder().decode(errorOutput)
throw new Error(errorMessage)
const errorOutput = stderr;
const errorMessage = new TextDecoder().decode(errorOutput);
throw new Error(errorMessage);
}
}
};

const osUtils = {
fileExists,
chmod,
runCommand,
}
};

export default osUtils
export default osUtils;
4 changes: 0 additions & 4 deletions deps.ts

This file was deleted.

15 changes: 0 additions & 15 deletions dev_deps.ts

This file was deleted.

Loading