From f26ec11d506d507896047e6e9c3763ed69d6ce3f Mon Sep 17 00:00:00 2001 From: Emanuel Tesar Date: Sun, 26 Jan 2020 12:11:36 +0100 Subject: [PATCH] Check all exports are exported by index.ts --- check_exports.py | 30 ++++++++++++++++++++++++++++++ index.ts | 3 +++ package.json | 4 ++-- 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 check_exports.py diff --git a/check_exports.py b/check_exports.py new file mode 100644 index 0000000..8cbd8b6 --- /dev/null +++ b/check_exports.py @@ -0,0 +1,30 @@ +from os import listdir +from re import match + +with open('index.ts') as f: + exports = [x.strip() for x in f.readlines()] + +# verify exports structure (and create the export names) +exportNames = set() +for e in exports: + m = match("^export { default as (.*) } from '(.*)'$", e) + if not m: + print(f'Line "{e}" is not a valid export!') + exit(1) + + g = m.groups() + if len(g) != 2 or f'./src/{g[0]}' != g[1]: + print(f'Export "{e}" doesn\'t match the library folder name!') + exit(1) + + exportNames.add(g[0]) + +# verify that all helpers are exported (except the ignored ones) +ignored = set(['test', 'common']) +srcFolders = set(listdir('src')) +diff = srcFolders.difference(ignored.union(exportNames)) +if len(diff) != 0: + print(f'Found non-exported folder names {diff}!') + exit(1) + +print('All helpers are correctly exported by "index.ts"!') diff --git a/index.ts b/index.ts index 404ae41..ddfca79 100644 --- a/index.ts +++ b/index.ts @@ -5,7 +5,10 @@ export { default as map } from './src/map' export { default as omit } from './src/omit' export { default as pick } from './src/pick' export { default as set } from './src/set' +export { default as update } from './src/update' export { default as unset } from './src/unset' export { default as fpSet } from './src/fpSet' export { default as fpUnset } from './src/fpUnset' export { default as fpUpdate } from './src/fpUpdate' +export { default as pipe } from './src/pipe' +export { default as compose } from './src/compose' diff --git a/package.json b/package.json index e951885..a8424d1 100644 --- a/package.json +++ b/package.json @@ -34,8 +34,8 @@ }, "husky": { "hooks": { - "pre-commit": "yarn test && yarn clean && yarn docs && git add docs/*", - "pre-push": "yarn test" + "pre-commit": "python3 check_exports.py && yarn test && yarn clean && yarn docs && git add docs/*", + "pre-push": "python3 check_exports.py && yarn test" } }, "description": "Tsfunct is a **T**ype**S**cript **funct**ional library made directly for TS with its static typesystem in mind.",