diff --git a/.gitignore b/.gitignore index 143fabd..eb36b35 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ bin +dist node_modules solaris output diff --git a/package.json b/package.json index d09a1f4..e122dd0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "httpyac-import", - "version": "0.3.3", + "version": "0.3.4", "description": "CLI to convert Postman collection to httpyac files", "homepage": "https://github.com/matthewturner/httpyac-import", "repository": { @@ -12,7 +12,7 @@ }, "main": "./src/app.ts", "bin": { - "httpyac-import": "./bin/httpyac-import.js" + "httpyac-import": "./dist/app.js" }, "scripts": { "build": "npx tsc", diff --git a/src/app.ts b/src/app.ts index d93307f..289f87b 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,3 +1,5 @@ +#! /usr/bin/env node + import { writeFileSync, readFileSync, mkdirSync, existsSync } from 'fs'; import { Collection, ItemGroup, Item, PropertyList } from 'postman-collection'; import { parse } from 'ts-command-line-args'; @@ -7,7 +9,7 @@ import { sanitize } from './helpers'; import { RequestDefinitionBuilder } from './RequestDefinitionBuilder'; const args = parse({ - sourcePath: { + sourcePath: { type: String, alias: 's', optional: true as const, description: 'Path to the exported postman_collection.json' }, targetPath: { @@ -21,23 +23,23 @@ const args = parse({ description: 'List of headers to ignore, useful when using default headers. Supports regex patterns', defaultValue: [] }, - help: { + help: { type: Boolean, optional: true, alias: 'h', description: 'Prints this usage guide' }, }, -{ - helpArg: 'help', - headerContentSections: [{ header: 'Postman 2 HttpYac', content: 'Converts Postman collections to HttpYac format' }] -}); + { + helpArg: 'help', + headerContentSections: [{ header: 'HttpYac Import', content: 'Converts Postman collections to HttpYac format' }] + }); const sourcePostmanCollectionPath = args.sourcePath.toString(); const sourcePostmanCollection = JSON.parse(readFileSync(sourcePostmanCollectionPath).toString()); -const targetPaths = [ args.targetPath ]; +const targetPaths = [args.targetPath]; const sourceCollection = new Collection(sourcePostmanCollection); -function processItems(items : PropertyList>) { +function processItems(items: PropertyList>) { for (const item of items.all()) { if (item instanceof Item) { processItem(item); @@ -51,7 +53,7 @@ function processItems(items : PropertyList>) { } } -function processItem(item : Item) { +function processItem(item: Item) { const directory = join(...targetPaths); if (!existsSync(directory)) { diff --git a/tsconfig.json b/tsconfig.json index fa038ca..65da4f6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -4,7 +4,7 @@ "experimentalDecorators": true, "module": "commonjs", "target": "ES5", - "outDir": "bin", + "outDir": "dist", "rootDir": "src", "sourceMap": true, "lib": [