diff --git a/.eslintignore b/.eslintignore index 37a6766..eb2d651 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,6 @@ node_modules *.env -dist +dist/cjs/** +dist/esm/** errors.log .eslintrc.js \ No newline at end of file diff --git a/.gitignore b/.gitignore index e96dfc0..97108dc 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ build/** dist/** .next/** yarn-error.log +dist \ No newline at end of file diff --git a/.husky/pre-commit b/.husky/pre-commit old mode 100644 new mode 100755 diff --git a/.husky/pre-push b/.husky/pre-push old mode 100644 new mode 100755 diff --git a/lint-staged.config.js b/lint-staged.config.js new file mode 100644 index 0000000..6511ff3 --- /dev/null +++ b/lint-staged.config.js @@ -0,0 +1,11 @@ +const prettierWriteCommand = 'yarn prettier --write' + +// eslint-disable-next-line no-undef +module.exports = { + '*.ts': [prettierWriteCommand], + '*.tsx': [prettierWriteCommand], + '*.js': [prettierWriteCommand], + '*.jsx': [prettierWriteCommand], + '*.css': [prettierWriteCommand], + '*.scss': [prettierWriteCommand] +} diff --git a/package.json b/package.json index 219c27b..1bc659e 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,11 @@ ], "private": true, "scripts": { + "test": "turbo test --concurrency=2", + "clean": "turbo clean --concurrency=2", "build": "turbo build --concurrency=2", - "watch": "tsc --pretty -w", + "build:esm": "turbo build:esm --concurrency=2", + "build:cjs": "turbo build:cjs --concurrency=2", "lint": "turbo run lint --concurrency=2", "prepare": "husky install", "pretty": "turbo pretty --concurrency=2", diff --git a/packages/component-generator/.eslintignore b/packages/component-generator/.eslintignore new file mode 100644 index 0000000..53c37a1 --- /dev/null +++ b/packages/component-generator/.eslintignore @@ -0,0 +1 @@ +dist \ No newline at end of file diff --git a/.prettierrc.js b/packages/component-generator/.prettierrc.js similarity index 100% rename from .prettierrc.js rename to packages/component-generator/.prettierrc.js diff --git a/packages/component-generator/dist/index.d.ts b/packages/component-generator/dist/index.d.ts deleted file mode 100644 index f36479a..0000000 --- a/packages/component-generator/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/packages/component-generator/dist/index.d.ts.map b/packages/component-generator/dist/index.d.ts.map deleted file mode 100644 index 535b86d..0000000 --- a/packages/component-generator/dist/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/component-generator/dist/index.js b/packages/component-generator/dist/index.js deleted file mode 100644 index fa69a5a..0000000 --- a/packages/component-generator/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/component-generator/dist/index.js.map b/packages/component-generator/dist/index.js.map deleted file mode 100644 index 1ed2df6..0000000 --- a/packages/component-generator/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/component-generator/dist/reusable-functions.d.ts b/packages/component-generator/dist/reusable-functions.d.ts deleted file mode 100644 index 44e98a0..0000000 --- a/packages/component-generator/dist/reusable-functions.d.ts +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=reusable-functions.d.ts.map \ No newline at end of file diff --git a/packages/component-generator/dist/reusable-functions.d.ts.map b/packages/component-generator/dist/reusable-functions.d.ts.map deleted file mode 100644 index 998aee6..0000000 --- a/packages/component-generator/dist/reusable-functions.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"reusable-functions.d.ts","sourceRoot":"","sources":["../src/reusable-functions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/component-generator/dist/reusable-functions.js b/packages/component-generator/dist/reusable-functions.js deleted file mode 100644 index b5fd893..0000000 --- a/packages/component-generator/dist/reusable-functions.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=reusable-functions.js.map \ No newline at end of file diff --git a/packages/component-generator/dist/reusable-functions.js.map b/packages/component-generator/dist/reusable-functions.js.map deleted file mode 100644 index ca98716..0000000 --- a/packages/component-generator/dist/reusable-functions.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"reusable-functions.js","sourceRoot":"","sources":["../src/reusable-functions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/component-generator/package.json b/packages/component-generator/package.json index 64151f0..484f943 100644 --- a/packages/component-generator/package.json +++ b/packages/component-generator/package.json @@ -2,12 +2,16 @@ "name": "component-generator", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", "scripts": { "test": "vitest run", - "build": "yarn tsc --pretty", + "clean": "rm -rf ./dist", + "build:cjs": "yarn tsc -p tsconfig-cjs.json --pretty", + "build:esm": "yarn tsc -p tsconfig.json --pretty", + "build": "yarn run clean && concurrently -n esm,cjs \"npm run build:esm\" \"npm run build:cjs\"", "lint": "yarn eslint . --max-warnings=0", - "pretty": "prettier --config ../../.prettierrc.js --write ./src/**/**/**/**/**/**/**/**/**/**/**/**/**/*.{ts}", + "pretty": "yarn prettier --write \"src/**/*.ts\"", "clean-install": "rm -rf ./node_modules && yarn install --frozen-lockfile" }, "keywords": [], diff --git a/packages/component-generator/src/reusable-functions.ts b/packages/component-generator/src/reusable-functions.ts deleted file mode 100644 index e69de29..0000000 diff --git a/packages/component-generator/tsconfig-cjs.json b/packages/component-generator/tsconfig-cjs.json new file mode 100644 index 0000000..c60a733 --- /dev/null +++ b/packages/component-generator/tsconfig-cjs.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist/cjs", + "module": "CommonJS" + }, + "include": [ + "src/", + "*.ts" + ], + "exclude": [ + "node_modules", + "dist" + ] +} \ No newline at end of file diff --git a/packages/component-generator/tsconfig.json b/packages/component-generator/tsconfig.json index 2bf5730..969dece 100644 --- a/packages/component-generator/tsconfig.json +++ b/packages/component-generator/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "dist" + "module": "ESNext", + "outDir": "dist/esm" }, "include": [ "src/", @@ -9,6 +10,6 @@ ], "exclude": [ "node_modules", - "dist" + "dist/**" ] } \ No newline at end of file diff --git a/packages/wapi.js/.eslintignore b/packages/wapi.js/.eslintignore new file mode 100644 index 0000000..1521c8b --- /dev/null +++ b/packages/wapi.js/.eslintignore @@ -0,0 +1 @@ +dist diff --git a/packages/wapi.js/.prettierrc.js b/packages/wapi.js/.prettierrc.js new file mode 100644 index 0000000..2621c56 --- /dev/null +++ b/packages/wapi.js/.prettierrc.js @@ -0,0 +1,11 @@ +module.exports = { + arrowParens: 'avoid', + trailingComma: 'none', + tabWidth: 4, + printWidth: 100, + semi: false, + useTabs: true, + bracketSpacing: true, + bracketSameLine: false, + singleQuote: true +} diff --git a/packages/wapi.js/dist/index.d.ts b/packages/wapi.js/dist/index.d.ts deleted file mode 100644 index f36479a..0000000 --- a/packages/wapi.js/dist/index.d.ts +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/packages/wapi.js/dist/index.d.ts.map b/packages/wapi.js/dist/index.d.ts.map deleted file mode 100644 index 1be7a7a..0000000 --- a/packages/wapi.js/dist/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/wapi.js/dist/index.js b/packages/wapi.js/dist/index.js deleted file mode 100644 index fa69a5a..0000000 --- a/packages/wapi.js/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/packages/wapi.js/dist/index.js.map b/packages/wapi.js/dist/index.js.map deleted file mode 100644 index 8067393..0000000 --- a/packages/wapi.js/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/wapi.js/dist/src/reusable-functions.d.ts b/packages/wapi.js/dist/src/reusable-functions.d.ts deleted file mode 100644 index 44e98a0..0000000 --- a/packages/wapi.js/dist/src/reusable-functions.d.ts +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=reusable-functions.d.ts.map \ No newline at end of file diff --git a/packages/wapi.js/dist/src/reusable-functions.d.ts.map b/packages/wapi.js/dist/src/reusable-functions.d.ts.map deleted file mode 100644 index 6bdfe07..0000000 --- a/packages/wapi.js/dist/src/reusable-functions.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"reusable-functions.d.ts","sourceRoot":"","sources":["../../src/reusable-functions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/wapi.js/dist/src/reusable-functions.js b/packages/wapi.js/dist/src/reusable-functions.js deleted file mode 100644 index b5fd893..0000000 --- a/packages/wapi.js/dist/src/reusable-functions.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=reusable-functions.js.map \ No newline at end of file diff --git a/packages/wapi.js/dist/src/reusable-functions.js.map b/packages/wapi.js/dist/src/reusable-functions.js.map deleted file mode 100644 index f145011..0000000 --- a/packages/wapi.js/dist/src/reusable-functions.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"reusable-functions.js","sourceRoot":"","sources":["../../src/reusable-functions.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/wapi.js/dist/src/utils.d.ts b/packages/wapi.js/dist/src/utils.d.ts deleted file mode 100644 index 7ee98a3..0000000 --- a/packages/wapi.js/dist/src/utils.d.ts +++ /dev/null @@ -1 +0,0 @@ -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/packages/wapi.js/dist/src/utils.d.ts.map b/packages/wapi.js/dist/src/utils.d.ts.map deleted file mode 100644 index 937aea5..0000000 --- a/packages/wapi.js/dist/src/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/wapi.js/dist/src/utils.js b/packages/wapi.js/dist/src/utils.js deleted file mode 100644 index 6662b59..0000000 --- a/packages/wapi.js/dist/src/utils.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/packages/wapi.js/dist/src/utils.js.map b/packages/wapi.js/dist/src/utils.js.map deleted file mode 100644 index d25bf81..0000000 --- a/packages/wapi.js/dist/src/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/packages/wapi.js/package.json b/packages/wapi.js/package.json index 33f755c..cadf968 100644 --- a/packages/wapi.js/package.json +++ b/packages/wapi.js/package.json @@ -2,27 +2,33 @@ "name": "wapi.js", "version": "1.0.0", "description": "", - "main": "index.js", + "main": "dist/cjs/index.js", + "module": "dist/esm/index.js", "scripts": { "test": "vitest run", - "build": "yarn tsc --pretty", + "clean": "rm -rf ./dist", + "build:cjs": "yarn tsc -p tsconfig-cjs.json --pretty", + "build:esm": "yarn tsc -p tsconfig.json --pretty", + "build": "yarn run clean && concurrently -n esm,cjs \"npm run build:esm\" \"npm run build:cjs\"", "lint": "yarn eslint . --max-warnings=0", - "pretty": "prettier --config ../../prettierrc.js --write ./src/**/**/**/**/**/**/**/**/**/**/**/**/**/*.{ts}", + "pretty": "yarn prettier --write \"src/**/*.ts\"", "clean-install": "rm -rf ./node_modules && yarn install --frozen-lockfile" }, "keywords": [], "author": "", "license": "Apache-2.0", "devDependencies": { + "concurrently": "^8.2.1", "eslint": "^8.48.0", "eslint-config-next": "^13.4.19", "eslint-config-prettier": "^9.0.0", "eslint-import-resolver-typescript": "^3.6.0", "eslint-plugin-import": "^2.28.1", + "lint-staged": "^14.0.1", "prettier": "^3.0.3", "typescript": "^5.2.2" }, "dependencies": { "dayjs": "^1.11.9" } -} +} \ No newline at end of file diff --git a/packages/wapi.js/src/constants.ts b/packages/wapi.js/src/constants.ts new file mode 100644 index 0000000..070731f --- /dev/null +++ b/packages/wapi.js/src/constants.ts @@ -0,0 +1,72 @@ +export const errorCodes: { code: number; message: string; description: string }[] = [ + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app use' + }, + { + code: 3, + message: 'API Method', + description: 'Capability or permissions issue' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + }, + { + code: 0, + message: 'AuthException', + description: 'We were unable to authenticate the app user.' + } +] diff --git a/packages/wapi.js/src/reusable-functions.ts b/packages/wapi.js/src/reusable-functions.ts deleted file mode 100644 index e69de29..0000000 diff --git a/packages/wapi.js/src/utils.ts b/packages/wapi.js/src/utils.ts deleted file mode 100644 index e69de29..0000000 diff --git a/packages/wapi.js/tsconfig-cjs.json b/packages/wapi.js/tsconfig-cjs.json new file mode 100644 index 0000000..c60a733 --- /dev/null +++ b/packages/wapi.js/tsconfig-cjs.json @@ -0,0 +1,15 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "outDir": "dist/cjs", + "module": "CommonJS" + }, + "include": [ + "src/", + "*.ts" + ], + "exclude": [ + "node_modules", + "dist" + ] +} \ No newline at end of file diff --git a/packages/wapi.js/tsconfig.json b/packages/wapi.js/tsconfig.json index 2bf5730..6e49310 100644 --- a/packages/wapi.js/tsconfig.json +++ b/packages/wapi.js/tsconfig.json @@ -1,7 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "outDir": "dist" + "module": "ESNext", + "outDir": "dist/esm", }, "include": [ "src/", @@ -9,6 +10,6 @@ ], "exclude": [ "node_modules", - "dist" + "dist/**" ] } \ No newline at end of file diff --git a/tsconfig.base.json b/tsconfig.base.json index 45c2d0a..95698a9 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,10 +1,10 @@ { "compilerOptions": { "allowUnreachableCode": false, + "allowJs": true, "strict": true, - "module": "ESNext", "declaration": true, - "declarationMap": true, + "declarationMap": false, "importHelpers": false, "newLine": "lf", "noEmitHelpers": true, diff --git a/tsconfig.json b/tsconfig.json index e69de29..4d1c4c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "./tsconfig.base.json", +} \ No newline at end of file diff --git a/turbo.json b/turbo.json index fbd9a4a..d04cb9e 100644 --- a/turbo.json +++ b/turbo.json @@ -1,6 +1,25 @@ { "$schema": "https://turbo.build/schema.json", "pipeline": { + "clean": {}, + "build:esm": { + "cache": false, + "dependsOn": [ + "^build" + ], + "outputs": [ + "./dist/**/*" + ] + }, + "build:cjs": { + "cache": false, + "dependsOn": [ + "^build" + ], + "outputs": [ + "./dist/**/*" + ] + }, "build": { "cache": false, "dependsOn": [ @@ -18,21 +37,15 @@ "src/**/*.tsx", "src/**/*.ts", "test/**/*.ts", - "test/**/*.tsx", - "package.json", - "tsconfig.json" + "test/**/*.tsx" ] }, "pretty": { - "inputs": [ - "src/**/*.tsx", - "src/**/*.ts", - "test/**/*.ts", - "test/**/*.tsx" - ], + "cache": false, "outputMode": "errors-only" }, "lint": { + "cache": false, "inputs": [ "src/**/*.tsx", "src/**/*.ts", @@ -40,10 +53,6 @@ "test/**/*.tsx" ], "outputMode": "errors-only" - }, - "dev": { - "cache": false, - "persistent": true } } } \ No newline at end of file