Skip to content

Commit

Permalink
fix: Correct URL detection (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
ffflorian authored and bennycode committed May 30, 2019
1 parent a4c886e commit 2144fee
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 26 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"swaxios": "dist/cli.js"
},
"dependencies": {
"axios": "0.18.0",
"axios": "0.19.0",
"ci-info": "2.0.0",
"cli-interact": "0.1.9",
"commander": "2.20.0",
Expand All @@ -16,6 +16,7 @@
},
"description": "Generate Swagger API clients with axios",
"devDependencies": {
"@types/ci-info": "2.0.0",
"@types/cli-interact": "0.1.0",
"@types/fs-extra": "7.0.0",
"@types/handlebars-helpers": "0.5.2",
Expand All @@ -39,7 +40,7 @@
"tslint-plugin-prettier": "2.0.1",
"tslint-react": "4.0.0",
"tslint-react-hooks": "2.1.0",
"typescript": "3.4.5"
"typescript": "3.5.1"
},
"files": [
"dist"
Expand Down
4 changes: 2 additions & 2 deletions src/Swaxios.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import axios from 'axios';
import {isCI} from 'ci-info';
import {getYesNo} from 'cli-interact';
import fs from 'fs-extra';
import initializeHelpers from 'handlebars-helpers';
import path from 'path';
import {Path, Spec} from 'swagger-schema-official';
import url from 'url';
import yaml from 'yamljs';
const {isCI} = require('ci-info');

import {APIClientGenerator, IndexFileGenerator, ResourceGenerator} from './generators';
import {DirEntry, generateFileIndex} from './util/FileUtil';
Expand Down Expand Up @@ -125,7 +125,7 @@ async function checkOutputDirectory(outputDirectory: string, forceDeletion?: boo
export async function writeClient(inputFile: string, outputDirectory: string, forceDeletion?: boolean): Promise<void> {
await checkOutputDirectory(outputDirectory, forceDeletion);
const parsedInput = url.parse(inputFile);
const isUrl = parsedInput.protocol && /^https?:\/\//.test(parsedInput.protocol);
const isUrl = parsedInput.protocol && /^https?/.test(parsedInput.protocol);
const swaggerJson = isUrl ? await readInputURL(inputFile) : await readInputFile(inputFile);
await validateConfig(swaggerJson);
return generateClient(swaggerJson, outputDirectory);
Expand Down
54 changes: 32 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@
dependencies:
any-observable "^0.3.0"

"@types/ci-info@2.0.0":
version "2.0.0"
resolved "https://registry.npmjs.org/@types/ci-info/-/ci-info-2.0.0.tgz#51848cc0f5c30c064f4b25f7f688bf35825b3971"
integrity sha512-5R2/MHILQLDCzTuhs1j4Qqq8AaKUf7Ma4KSSkCtc12+fMs47zfa34qhto9goxpyX00tQK1zxB885VCiawZ5Qhg==

"@types/cli-interact@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@types/cli-interact/-/cli-interact-0.1.0.tgz#63379a2009727dd3d893d098bc183700c28ee711"
Expand Down Expand Up @@ -590,13 +595,13 @@ autolinker@~0.15.0:
resolved "https://registry.yarnpkg.com/autolinker/-/autolinker-0.15.3.tgz#342417d8f2f3461b14cf09088d5edf8791dc9832"
integrity sha1-NCQX2PLzRhsUzwkIjV7fh5HcmDI=

axios@0.18.0:
version "0.18.0"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.18.0.tgz#32d53e4851efdc0a11993b6cd000789d70c05102"
integrity sha1-MtU+SFHv3AoRmTts0AB4nXDAUQI=
axios@0.19.0:
version "0.19.0"
resolved "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz#8e09bff3d9122e133f7b8101c8fbdd00ed3d2ab8"
integrity sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==
dependencies:
follow-redirects "^1.3.0"
is-buffer "^1.1.5"
follow-redirects "1.5.10"
is-buffer "^2.0.2"

babel-runtime@^6.9.2:
version "6.26.0"
Expand Down Expand Up @@ -964,6 +969,13 @@ date.js@^0.3.1:
dependencies:
debug "~3.1.0"

debug@=3.1.0, debug@~3.1.0:
version "3.1.0"
resolved "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"

debug@^2.2.0, debug@^2.3.3:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
Expand All @@ -985,13 +997,6 @@ debug@^4.0.1, debug@^4.1.0, debug@^4.1.1:
dependencies:
ms "^2.1.1"

debug@~3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261"
integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==
dependencies:
ms "2.0.0"

decamelize@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
Expand Down Expand Up @@ -1314,12 +1319,12 @@ fn-name@~2.0.1:
resolved "https://registry.yarnpkg.com/fn-name/-/fn-name-2.0.1.tgz#5214d7537a4d06a4a301c0cc262feb84188002e7"
integrity sha1-UhTXU3pNBqSjAcDMJi/rhBiAAuc=

follow-redirects@^1.3.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.7.0.tgz#489ebc198dc0e7f64167bd23b03c4c19b5784c76"
integrity sha512-m/pZQy4Gj287eNy94nivy5wchN3Kp+Q5WgUPNy5lJSZ3sgkVKSYV/ZChMAQVIgx1SqfZ2zBZtPA2YlXIWxxJOQ==
follow-redirects@1.5.10:
version "1.5.10"
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==
dependencies:
debug "^3.2.6"
debug "=3.1.0"

for-in@^1.0.1, for-in@^1.0.2:
version "1.0.2"
Expand Down Expand Up @@ -1776,6 +1781,11 @@ is-buffer@^1.1.5:
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==

is-buffer@^2.0.2:
version "2.0.3"
resolved "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz#4ecf3fcf749cbd1e472689e109ac66261a25e725"
integrity sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw==

is-ci@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c"
Expand Down Expand Up @@ -3765,10 +3775,10 @@ typeof-article@^0.1.1:
dependencies:
kind-of "^3.1.0"

typescript@3.4.5:
version "3.4.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99"
integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw==
typescript@3.5.1:
version "3.5.1"
resolved "https://registry.npmjs.org/typescript/-/typescript-3.5.1.tgz#ba72a6a600b2158139c5dd8850f700e231464202"
integrity sha512-64HkdiRv1yYZsSe4xC1WVgamNigVYjlssIoaH2HcZF0+ijsk5YK2g0G34w9wJkze8+5ow4STd22AynfO6ZYYLw==

uglify-js@^3.1.4:
version "3.5.15"
Expand Down

0 comments on commit 2144fee

Please sign in to comment.