diff --git a/.gitignore b/.gitignore index 57026783..a8b67aca 100644 --- a/.gitignore +++ b/.gitignore @@ -61,5 +61,10 @@ typings/ # dotenv environment variables file .env +# IDEs and editors +.idea + +#Dist folders +dist/ # End of https://www.gitignore.io/api/node diff --git a/index.js b/index.js index dc4a86fd..439044b1 100644 --- a/index.js +++ b/index.js @@ -3,10 +3,9 @@ const { Reference } = require('./lib/reference'); const { parseQualifiedName, parseQualifiedNameOptimized, parseFamiliarName, parseAll } = require('./lib/parsers'); -Object.assign(exports, { - Reference, - parseQualifiedName, - parseQualifiedNameOptimized, - parseFamiliarName, - parseAll -}); +// please export like this to work fine with typescript definitions +exports.Reference = Reference; +exports.parseQualifiedName = parseQualifiedName; +exports.parseQualifiedNameOptimized = parseQualifiedNameOptimized; +exports.parseFamiliarName = parseFamiliarName; +exports.parseAll = parseAll; diff --git a/package.json b/package.json index 351d5598..3f789ac9 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "@codefresh-io/docker-reference", - "version": "0.0.8", - "description": "A node.js pacakge to parse docker image reference", + "version": "0.0.9", + "description": "A node.js package to parse docker image reference", "main": "index.js", + "types": "./dist/index.d.ts", "repository": "https://github.com/codefresh-io/node-docker-reference", "author": "Roy Shmueli ", "license": "MIT", @@ -11,11 +12,13 @@ "test:coverage": "istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- tests/**/*.spec.js", "lint": "eslint --rule 'no-trailing-spaces: [\"warn\", { \"skipBlankLines\": false }]' \"./src/**/*.js\"", "coveralls": "cat ./coverage/lcov.info | coveralls", - "depcheck": "depcheck --ignores rimraf", + "depcheck": "depcheck --ignores='rimraf,@types/*'", "clean": "rimraf ./coverage", - "publish": "publish" + "build:ts-definitions": "tsc", + "publish": "yarn build:definitions && publish" }, "devDependencies": { + "@types/node": "^16.11.12", "chai": "^3.5.0", "coveralls": "^2.13.1", "depcheck": "^0.6.7", @@ -28,7 +31,8 @@ "istanbul": "^0.4.5", "mocha": "^3.4.2", "publish": "^0.6.0", - "rimraf": "^2.6.1" + "rimraf": "^2.6.1", + "typescript": "^4.5.3" }, "dependencies": { "re2": "^1.16.0" diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..e962b9bb --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": ["./index.js"], + "compilerOptions": { + "allowJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "dist", + "declarationMap": true + } +} diff --git a/yarn.lock b/yarn.lock index 035326d5..0a9dcccc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,6 +15,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82" integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw== +"@types/node@^16.11.12": + version "16.11.12" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.12.tgz#ac7fb693ac587ee182c3780c26eb65546a1a3c10" + integrity sha512-+2Iggwg7PxoO5Kyhvsq9VarmPbIelXP070HMImEpbtGCoyWNINQj4wzjbQCXzdHTRXnqufutJb5KAURZANNBAw== + abbrev@1, abbrev@1.0.x, abbrev@~1.0.9: version "1.0.9" resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.0.9.tgz#91b4792588a7738c25f35dd6f63752a2f8776135" @@ -2919,6 +2924,11 @@ typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" +typescript@^4.5.3: + version "4.5.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.3.tgz#afaa858e68c7103317d89eb90c5d8906268d353c" + integrity sha512-eVYaEHALSt+s9LbvgEv4Ef+Tdq7hBiIZgii12xXJnukryt3pMgJf6aKhoCZ3FWQsu6sydEnkg11fYXLzhLBjeQ== + uglify-js@^2.6: version "2.8.27" resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-2.8.27.tgz#47787f912b0f242e5b984343be8e35e95f694c9c"