Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow writer to be ended/closed #60

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 15 additions & 14 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
name: Build & Test with Bun
name: Build and tests with Node.js

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build-and-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3 # Checkout repo
- name: Checkout
uses: actions/checkout@v3

- name: Setup Bun
uses: oven-sh/setup-bun@v1 # Setup bun
with:
bun-version: latest

- run: bun i # Install dependencies
- run: bun test # Run tests
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 21.x
cache: "npm"

- run: npm ci
- run: npm run build
- run: npm run test
19 changes: 0 additions & 19 deletions .github/workflows/test.yml

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Js-runner

[![Bun CI](https://github.com/rdf-connect/js-runner/actions/workflows/build-test.yml/badge.svg)](https://github.com/rdf-connect/js-runner/actions/workflows/build-test.yml) [![npm](https://img.shields.io/npm/v/@rdfc/js-runner.svg?style=popout)](https://npmjs.com/package/@rdfc/js-runner)
[![Build and tests with Node.js](https://github.com/rdf-connect/js-runner/actions/workflows/build-test.yml/badge.svg)](https://github.com/rdf-connect/js-runner/actions/workflows/build-test.yml) [![npm](https://img.shields.io/npm/v/@rdfc/js-runner.svg?style=popout)](https://npmjs.com/package/@rdfc/js-runner)

Typescript/Javascript executor for an [RDF-Connect](https://rdf-connect.github.io/rdfc.github.io/) pipeline. Starting from a declarative RDF file describing the pipeline.

Expand Down Expand Up @@ -34,7 +34,7 @@ You can execute this pipeline with

```bash
tsc
bun bin/js-runner.js input.ttl
npx bin/js-runner.js input.ttl
```

This example input configuration file uses `owl:imports` to specify additional configuration files.
This example input configuration file uses `owl:imports` to specify additional configuration files.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
"js-runner": "bin/bundle.mjs"
},
"scripts": {
"build": "tsc && tsc-alias && rollup ./dist/index.js --file ./dist/index.cjs --format cjs && bun build --external debug ./bin/js-runner.js --outfile bin/bundle.mjs --target node && npm run build:recompose",
"build:recompose": "sed -z 's/var __require = (id) => {\\n return import.meta.require(id);\\n};/import Module from \"node:module\";\\nconst __require = Module.createRequire(import.meta.url);/' -i bin/bundle.mjs",
"build": "tsc && tsc-alias",
"watch": "tsc -w",
"test": "vitest run --coverage --coverage.include src",
"prepare": "husky",
Expand Down
88 changes: 50 additions & 38 deletions src/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,58 +2,70 @@ import commandLineArgs from "command-line-args";
import commandLineUsage from "command-line-usage";

const optionDefinitions = [
{ name: 'input', type: String, defaultOption: true, summary: "Specify what input file to start up" },
{ name: 'help', alias: 'h', type: Boolean, description: "Display this help message" },
{
name: "input",
type: String,
defaultOption: true,
summary: "Specify what input file to start up",
},
{
name: "help",
alias: "h",
type: Boolean,
description: "Display this help message",
},
];

const sections = [
{
header: "Js-runner",
content: "JS-runner is part of the {italic connector architecture}. Starting from an input file start up all JsProcessors that are defined. Please do not use blank nodes, skolemize your data somewhere else!"
},
{
header: "Synopsis",
content: "$ js-runner <input>"
},
{
header: "Command List",
content: [{ name: "input", summary: "Specify what input file to start up" }],
},
{
optionList: [optionDefinitions[1]]
}
{
header: "Js-runner",
content:
"JS-runner is part of the {italic connector architecture}. Starting from an input file start up all JsProcessors that are defined. Please do not use blank nodes, skolemize your data somewhere else!",
},
{
header: "Synopsis",
content: "$ js-runner <input>",
},
{
header: "Command List",
content: [
{ name: "input", summary: "Specify what input file to start up" },
],
},
{
optionList: [optionDefinitions[1]],
},
];

export type Args = {
input: string,
input: string;
};

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
function validArgs(args: any): boolean {
if (!args.input) return false;
return true;
if (!args.input) return false;
return true;
}

function printUsage() {
const usage = commandLineUsage(sections);
console.log(usage);
process.exit(0);
const usage = commandLineUsage(sections);
console.log(usage);
process.exit(0);
}

export function getArgs(): Args {
let args: any;
try {
args = commandLineArgs(optionDefinitions);
} catch (e) {
console.error(e);
printUsage();
}

if (args.help || !validArgs(args)) {
printUsage();
}

return <Args>args;
}

/* eslint-disable-next-line @typescript-eslint/no-explicit-any */
let args: any;
try {
args = commandLineArgs(optionDefinitions);
} catch (e) {
console.error(e);
printUsage();
}

if (args.help || !validArgs(args)) {
printUsage();
}

return <Args>args;
}
Loading
Loading