From adbb06b34bd5e0ff3460e84b2d6d17345180c4ce Mon Sep 17 00:00:00 2001 From: mohiit1502 Date: Wed, 18 Sep 2024 16:30:58 +0530 Subject: [PATCH] Publishable version of configs completed --- .DS_Store | Bin 0 -> 6148 bytes api-config.ts | 30 ---------- index.ts | 4 -- package.json | 18 ++++-- publish.sh | 8 +++ constants.ts => src/constants.ts | 71 ---------------------- src/endpoints.ts | 99 +++++++++++++++++++++++++++++++ src/index.ts | 3 + navigator.ts => src/navigator.ts | 0 tsconfig.json | 21 +------ vite.config.ts | 33 +++++++++++ web-config.ts | 18 ------ 12 files changed, 158 insertions(+), 147 deletions(-) create mode 100644 .DS_Store delete mode 100644 api-config.ts delete mode 100644 index.ts create mode 100755 publish.sh rename constants.ts => src/constants.ts (83%) create mode 100644 src/endpoints.ts create mode 100644 src/index.ts rename navigator.ts => src/navigator.ts (100%) create mode 100644 vite.config.ts delete mode 100644 web-config.ts diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..ba544ca64d87407c253c113110af02fee8872402 GIT binary patch literal 6148 zcmeHKy-LJD5T5Z)2-sX{VX=*s)qxKXkJu>)R|`ijph7|p<@$iVFX408`Wzzo6gGad zGkUjo0Xq?$f!%L*es+=%vYR0yo-C^|(TIpL3_%v9N5tIg+Oc49a@?b;ug24P+bnvv z`JE0C%=Xwx{T`GvEw3178ft z`4BJ!bHh$C9vzrs3jiF#90j`c5|R@PbHh#%9tdkHP*d4j4AykmgT>{BouZ}_Tl2wI z`LlW9SRMO^7*3ok`s@ri11SRoU5@1bKgB20+vKMyzH$bffj`Co4~uCr!AsfQy7hW; w*9MFkhKR&JOqLE;sBHWf!r>bfEtTL_&OW27Z8n4@W;n#Q*>R literal 0 HcmV?d00001 diff --git a/api-config.ts b/api-config.ts deleted file mode 100644 index 7ad5be8..0000000 --- a/api-config.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ApiConfig } from "@armco/types" - -const API_CONFIG: ApiConfig = { - HOST: { - development: "http://localhost:5000/api", - production: "https://api.armco.tech", - }, - STATIC_HOST: { - development: "http://localhost:5001/api", - production: "https://static.armco.tech", - }, - TASKER: { - development: "http://localhost:5002/api", - production: "https://tasks.armco.tech", - }, - CONFIG: { - development: "http://localhost:5003/api", - production: "https://config.armco.tech", - }, - IAM: { - development: "http://localhost:5004/api", - production: "https://iam.armco.tech", - }, - SEER: { - development: "http://localhost:5005/api", - production: "https://telemetry.armco.tech", - }, -} - -export default API_CONFIG diff --git a/index.ts b/index.ts deleted file mode 100644 index eeeccf0..0000000 --- a/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from "./api-config" -export * from "./web-config" -export * from "./constants" -export * from "./navigator" diff --git a/package.json b/package.json index 132f77a..7eaca64 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,18 @@ { "name": "@armco/configs", - "private": true, - "version": "0.0.0", + "version": "0.0.2", "type": "module", + "main": "build/cjs/index.js", + "module": "build/es/index.js", + "types": "build/types/index.d.ts", "scripts": { - "build": "tsc", + "build": "rm -rf build && tsc && vite build", "format": "prettier --write .", - "lint": "eslint ." + "lint": "eslint .", + "publish:sh": "./publish.sh" + }, + "dependencies": { + "@armco/types": "^0.0.8" }, "devDependencies": { "typescript": "^5.0.2" @@ -20,7 +26,6 @@ } }, "prettier": "prettier-config-nick", - "main": "build/index.js", "repository": { "type": "git", "url": "git+https://github.com/ReStruct-Corporate-Advantage/configs.git" @@ -31,6 +36,9 @@ "building-blocks", "foundation" ], + "files": [ + "build" + ], "license": "ISC", "bugs": { "url": "https://github.com/ReStruct-Corporate-Advantage/configs/issues" diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..a0d2fb4 --- /dev/null +++ b/publish.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +semver=${1:-patch} + +npm run build +set -e +npm --no-git-tag-version version ${semver} +npm publish --access public --loglevel verbose diff --git a/constants.ts b/src/constants.ts similarity index 83% rename from constants.ts rename to src/constants.ts index 48885ff..0e0591e 100644 --- a/constants.ts +++ b/src/constants.ts @@ -1,75 +1,4 @@ -import moment from "moment" import { ArWebPageLayout, ObjectType } from "@armco/types" -import API_CONFIG from "./api-config" - -export const ICON_ROOT = `${ - API_CONFIG.STATIC_HOST[process.env.NODE_ENV as "production" | "development"] -}/icon` - -export const DEFAULT_LOCALE = { - direction: "ltr", - format: moment.localeData().longDateFormat("L"), - separator: " - ", - applyLabel: "Apply", - cancelLabel: "Cancel", - weekLabel: "W", - customRangeLabel: "Custom Range", - daysOfWeek: moment.weekdaysMin(), - monthNames: moment.monthsShort(), - firstDay: moment.localeData().firstDayOfWeek(), -} - -export const ENDPOINTS = { - STATIC: { - ICON: { - ROOT: "/icon", - PAGE: "/page", - }, - LOTTIE: { - ROOT: "/lottie", - TOMP4: "/to-mp4", - TOGIF: "/to-gif", - TOPNG: "/to-png", - TOSVG: "/to-svg", - }, - FONT: { - ROOT: "/font", - PAGE: "/page", - }, - }, - USERS: { - ROOT: "/secure/users", - ADD: "/add", - UPDATE: "/update", - CHECK: "/check", - }, - AUTH: { - ROOT: "/auth", - LOGIN: "/login", - FORGOT: "/forgot", - SIGNUP: "/register", - LOGOUT: "/logout", - }, - NAMESPACE: { - ROOT: "/secure/namespace", - CREATE: "/", - FETCHALL: "/", - FETCH: "/", - }, - CONFIG: { - ROOT: "/secure/config", - SAVE: "/", - DELETE: "/delete", - }, - TASKER: { - ROOT: "/secure/jobs", - SAVE: "/", - DELETE: "/delete", - RUN: "/run", - FETCHALL: "/", - FETCH: "/", - }, -} export const MONTH_INDEX = [ "January", diff --git a/src/endpoints.ts b/src/endpoints.ts new file mode 100644 index 0000000..7315ab8 --- /dev/null +++ b/src/endpoints.ts @@ -0,0 +1,99 @@ +import { ApiConfig, WebConfig } from "@armco/types" + +export const API_CONFIG: ApiConfig = { + HOST: { + development: "http://localhost:5000/api", + production: "https://api.armco.tech", + }, + STATIC_HOST: { + development: "http://localhost:5001/api", + production: "https://static.armco.tech", + }, + TASKER: { + development: "http://localhost:5002/api", + production: "https://tasks.armco.tech", + }, + CONFIG: { + development: "http://localhost:5003/api", + production: "https://config.armco.tech", + }, + IAM: { + development: "http://localhost:5004/api", + production: "https://iam.armco.tech", + }, + SEER: { + development: "http://localhost:5005/api", + production: "https://telemetry.armco.tech", + }, +} + +export const ICON_ROOT = `${ + API_CONFIG.STATIC_HOST[process.env.NODE_ENV as "production" | "development"] +}/icon` + +export const WEB_CONFIG: WebConfig = { + ARMORY: { + development: "http://localhost:7992", + production: "https://armco.tech", + }, + IAM: { + development: "http://localhost:3001", + production: "https://iam.notabuck.com", + }, + FORESEER: { + development: "http://localhost:3002", + production: "https://seer.notabuck.com", + }, +} + +export const ENDPOINTS = { + STATIC: { + ICON: { + ROOT: "/icon", + PAGE: "/page", + }, + LOTTIE: { + ROOT: "/lottie", + TOMP4: "/to-mp4", + TOGIF: "/to-gif", + TOPNG: "/to-png", + TOSVG: "/to-svg", + }, + FONT: { + ROOT: "/font", + PAGE: "/page", + }, + }, + USERS: { + ROOT: "/secure/users", + ADD: "/add", + UPDATE: "/update", + CHECK: "/check", + }, + AUTH: { + ROOT: "/auth", + LOGIN: "/login", + FORGOT: "/forgot", + SIGNUP: "/register", + LOGOUT: "/logout", + }, + NAMESPACE: { + ROOT: "/secure/namespace", + CREATE: "/", + FETCHALL: "/", + FETCH: "/", + }, + CONFIG: { + ROOT: "/secure/config", + SAVE: "/", + DELETE: "/delete", + }, + TASKER: { + ROOT: "/secure/jobs", + SAVE: "/", + DELETE: "/delete", + RUN: "/run", + FETCHALL: "/", + FETCH: "/", + }, +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..8c8a8ab --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +export * from "./endpoints" +export * from "./constants" +export { default as NAVIGATOR } from "./navigator" diff --git a/navigator.ts b/src/navigator.ts similarity index 100% rename from navigator.ts rename to src/navigator.ts diff --git a/tsconfig.json b/tsconfig.json index 3b10e96..54d05ab 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,21 +1,4 @@ { - "compilerOptions": { - "skipLibCheck": true, - "esModuleInterop": true, - "strict": true, - "forceConsistentCasingInFileNames": true, - "module": "esnext", - "moduleResolution": "node", - "outDir": "build", - "resolveJsonModule": true, - "isolatedModules": true, - "declaration": true, - "noEmit": false, - "lib": [ - "dom", - "esnext" - ], - "target": "es5", - }, - "exclude": ["build"] + "extends": "../../tsconfig.json", + "include": ["src"], } diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..7382819 --- /dev/null +++ b/vite.config.ts @@ -0,0 +1,33 @@ +import { resolve } from "node:path" +import glob from "glob" +import { defineConfig } from "vitest/config" +import react from "@vitejs/plugin-react" +import dts from "vite-plugin-dts" + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [react(), dts({ outDir: "build/types" })], + build: { + outDir: "build", + lib: { + entry: glob.sync(resolve(__dirname, "src/**/*.ts")), + name: "@armco/configs", + formats: ["es", "cjs"], + }, + rollupOptions: { + treeshake: true, + output: [ + { + format: "es", + dir: "build/es", + entryFileNames: "[name].js", + }, + { + format: "cjs", + dir: "build/cjs", + entryFileNames: "[name].js", + }, + ], + }, + }, +}) diff --git a/web-config.ts b/web-config.ts deleted file mode 100644 index db40bb2..0000000 --- a/web-config.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { WebConfig } from "@armco/types" - -const WEB_CONFIG: WebConfig = { - ARMORY: { - development: "http://localhost:7992", - production: "https://armco.tech", - }, - IAM: { - development: "http://localhost:3001", - production: "https://iam.notabuck.com", - }, - FORESEER: { - development: "http://localhost:3002", - production: "https://seer.notabuck.com", - }, -} - -export default WEB_CONFIG