Skip to content

Commit

Permalink
Add load by URL example, package keywords and link to docs in RADME (#14
Browse files Browse the repository at this point in the history
)

* Add example for loading documents by URL to README

* Add keywords to package

* Add link to documentation to README

* Increase version number
  • Loading branch information
ZimmerA authored Jan 6, 2022
1 parent 6bfc23e commit b00f15a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ To install the latest version of cwl-ts-auto execute:
### Loading Documents
Documents can be loaded by specyfying a file path or by string
```TypeScript
import * as cwltsauto from 'cwl-ts-auto'
import * as cwlTsAuto from 'cwl-ts-auto'
import fs from 'fs'
import url from 'url'

// Load document by file
cwltsauto.loadDocument('./test.cwl')
cwlTsAuto.loadDocument('./test.cwl')
.then((file) => {
if (file instanceof cwltsauto.CommandLineTool) {
if (file instanceof cwlTsAuto.CommandLineTool) {
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
}
})
.catch((e) => {
if(e instanceof cwltsauto.ValidationException) {
if(e instanceof cwlTsAuto.ValidationException) {
console.log(e.toString())
} else {
console.log(e)
Expand All @@ -33,14 +33,29 @@ cwltsauto.loadDocument('./test.cwl')

// Load document by string
let docAsString = fs.readFileSync('./test.cwl').toString()
cwltsauto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/').toString())
cwlTsAuto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/').toString())
.then((file) => {
if (file instanceof cwltsauto.CommandLineTool) {
if (file instanceof cwlTsAuto.CommandLineTool) {
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
}
})
.catch((e) => {
if(e instanceof cwltsauto.ValidationException) {
if(e instanceof cwlTsAuto.ValidationException) {
console.log(e.toString())
} else {
console.log(e)
}
})

// Load document by URL
cwlTsAuto.loadDocument('https://raw.githubusercontent.com/common-workflow-lab/cwl-ts-auto/main/src/test/data/examples/valid-cat-tool.cwl')
.then((file) => {
if (file instanceof cwlTsAuto.CommandLineTool) {
console.log('This document is a CommandLineTool with baseCommand: ', file.baseCommand)
}
})
.catch((e) => {
if(e instanceof cwlTsAuto.ValidationException) {
console.log(e.toString())
} else {
console.log(e)
Expand All @@ -51,24 +66,29 @@ cwltsauto.loadDocumentByString(docAsString, url.pathToFileURL('/your/base/uri/')
### Creating, editing and saving Documents
This example shows how to create a simple CommandLineTool with one input
```TypeScript
import * as cwltsauto from 'cwl-ts-auto'
import * as cwlTsAuto from 'cwl-ts-auto'

let exampleCommandLineTool =
new cwltsauto.CommandLineTool({
class_: cwltsauto.CommandLineTool_class.COMMANDLINETOOL,
new cwlTsAuto.CommandLineTool({
class_: cwlTsAuto.CommandLineTool_class.COMMANDLINETOOL,
inputs: [],
outputs: []
})
exampleCommandLineTool.baseCommand = 'echo'

let exampleInput =
new cwltsauto.CommandInputParameter({
type: cwltsauto.PrimitiveType.STRING
new cwlTsAuto.CommandInputParameter({
type: cwlTsAuto.PrimitiveType.STRING
})
exampleInput.default_ = 'Hello World!'
exampleCommandLineTool.inputs.push(exampleInput)

console.log(JSON.stringify(exampleCommandLineTool.save()))
```

## Documentation
The complete documentation, autogenerated by [TypeDoc](https://typedoc.org/) can be found under the following link:
https://common-workflow-lab.github.io/cwl-ts-auto/

## Limitations
cwl-ts-auto only supports the CWL v1.2 syntax. Other documents have to be upgraded using the [cwl-upgrader](https://pypi.org/project/cwl-upgrader/)
cwl-ts-auto only supports the CWL v1.2 syntax. Other documents have to be upgraded using the [cwl-upgrader](https://pypi.org/project/cwl-upgrader/)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "cwl-ts-auto",
"version": "0.1.1",
"version": "0.1.2",
"description": "This project contains TypeScript objects and utilities auto-generated by https://github.com/common-workflow-language/schema_salad for parsing documents corresponding to the https://w3id.org/cwl/cwl# schema.",
"author": "Adrian Zimmer",
"homepage": "https://www.commonwl.org/",
"keywords": ["cwl", "cwl-ts-auto", "commonwl", "common workflow language", "typescript", "models", "parsing", "serialization", "deserialization"],
"license": "Apache License, Version 2.0",
"repository": {
"type": "git",
Expand Down

0 comments on commit b00f15a

Please sign in to comment.