commit e9ab1817510c320887c8d168d18f04a710d7fdd9 Author: mohiit1502 Date: Sun Nov 9 01:25:39 2025 +0530 Fresh changes after cleanup diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e6cc387 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +build +dist +node_modules +.DS_Store +constants +endpoints +navigator \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..3d0d771 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,6 @@ +@Library('jenkins-shared') _ +kanikoPipeline( + repoName: 'configs', + branch: env.BRANCH_NAME ?: 'main', + isNpmLib: true +) \ No newline at end of file diff --git a/build-tools/build.sh b/build-tools/build.sh new file mode 100755 index 0000000..35ca06b --- /dev/null +++ b/build-tools/build.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +# Get the directory of the current script +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Default values +DEV_FLAG="" + +# Parse arguments +for arg in "$@" +do + case $arg in + --dev) + DEV_FLAG="--dev" + shift # Remove --dev from processing + ;; + esac +done + +echo "[BUILD:SH] Dev flag is: $DEV_FLAG" +echo "[BUILD:SH] Removing build if exists" +rm -rf build +echo "[BUILD:SH] Checking TS Types" +npx tsc +echo "[BUILD:SH] Initiating build..." +# Conditionally use vite-dev.config.ts if --dev flag is present +if [ "$DEV_FLAG" == "--dev" ]; then + vite build --config vite-dev.config.ts +else + vite build +fi + +echo "[BUILD:SH] Running post processor scripts..." +# Run Post processors: Update style imports in .js files, create component modules +node "$SCRIPT_DIR/post-processor.js" build/cjs $DEV_FLAG +node "$SCRIPT_DIR/post-processor.js" build/es $DEV_FLAG \ No newline at end of file diff --git a/build-tools/generate-module.js b/build-tools/generate-module.js new file mode 100644 index 0000000..41dff34 --- /dev/null +++ b/build-tools/generate-module.js @@ -0,0 +1,33 @@ +import { promises as fs } from "fs" +import { dirname, resolve } from "path" +import { fileURLToPath } from "url" + +const __filename = fileURLToPath(import.meta.url) +const __dirname = dirname(__filename) + +const exclusions = ["index.js"] + +async function generateModule(fileName, isDev) { + if (!exclusions.includes(fileName) && !fileName.endsWith(".map")) { + const dir = fileName.slice(0, -3) + const name = `@armco/configs/${dir}` + const packageJsonContent = { + name, + main: `../${isDev ? "build/" : ""}cjs/${dir}.js`, + module: `../${isDev ? "build/" : ""}es/${dir}.js`, + types: `../${isDev ? "build/" : ""}types/${dir}.d.ts`, + } + const dirPath = resolve(__dirname, `../${isDev ? "" : "build/"}${dir}`) + try { + await fs.mkdir(dirPath, { recursive: true }) + await fs.writeFile( + resolve(dirPath, "package.json"), + JSON.stringify(packageJsonContent, null, 2), + ) + } catch (error) { + console.error(`Error processing directory ${dirPath}:`, error) + } + } +} + +export default generateModule diff --git a/build-tools/post-processor.js b/build-tools/post-processor.js new file mode 100644 index 0000000..6c6cf6f --- /dev/null +++ b/build-tools/post-processor.js @@ -0,0 +1,25 @@ +import { readdir } from "fs/promises" +import generateModule from "./generate-module.js" + +async function postProcessor(dir, isDev) { + try { + const files = await readdir(dir) + await Promise.all( + files.map(async (file) => { + await generateModule(file, isDev) + }), + ) + } catch (error) { + console.error(`Error processing directory ${dir}:`, error) + } +} + +const targetDir = process.argv[2] +const isDev = process.argv.includes("--dev") + +if (targetDir) { + postProcessor(targetDir, isDev) +} else { + console.error("Please provide the build directory to run post processor on.") + process.exit(1) +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..1fc2a24 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,68 @@ +{ + "name": "@armco/configs", + "version": "0.0.11", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "@armco/configs", + "version": "0.0.11", + "license": "ISC", + "dependencies": { + "@types/uuid": "^10.0.0" + }, + "devDependencies": { + "@armco/types": "^0.0.20", + "@types/node": "^24.10.0" + }, + "peerDependencies": { + "@armco/types": "^0.0.18", + "uuid": "^9.0.1" + } + }, + "node_modules/@armco/types": { + "version": "0.0.20", + "resolved": "https://registry.npmjs.org/@armco/types/-/types-0.0.20.tgz", + "integrity": "sha512-7Q6iXeeYBLtE88zhDBE78zEdHZVCIq+68RsraJr98xzP0z0wUEvYr2Tfv7wynjV/qv1aH58XK/dAsqXL7IeqNg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "24.10.0", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.0.tgz", + "integrity": "sha512-qzQZRBqkFsYyaSWXuEHc2WR9c0a0CXwiE5FWUvn7ZM+vdy1uZLfCunD38UzhuB7YN/J11ndbDBcTmOdxJo9Q7A==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~7.16.0" + } + }, + "node_modules/@types/uuid": { + "version": "10.0.0", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-10.0.0.tgz", + "integrity": "sha512-7gqG38EyHgyP1S+7+xomFtL+ZNHcKv6DwNaCZmJmo1vgMugyF3TCnXVg4t1uk89mLNwnLtnY3TpOpCOyp1/xHQ==", + "license": "MIT" + }, + "node_modules/undici-types": { + "version": "7.16.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", + "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", + "dev": true, + "license": "MIT" + }, + "node_modules/uuid": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "peer": true, + "bin": { + "uuid": "dist/bin/uuid" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..9d24518 --- /dev/null +++ b/package.json @@ -0,0 +1,46 @@ +{ + "name": "@armco/configs", + "version": "0.0.11", + "type": "module", + "main": "build/cjs/index.js", + "module": "build/es/index.js", + "types": "build/types/index.d.ts", + "scripts": { + "build": "./build-tools/build.sh", + "build:sm": "./build-tools/build.sh --dev", + "format": "prettier --write .", + "lint": "eslint .", + "publish:sh": "./publish.sh", + "publish:local": "./publish-local.sh" + }, + "peerDependencies": { + "@armco/types": "^0.0.18", + "uuid": "^9.0.1" + }, + "prettier": "prettier-config-nick", + "repository": { + "type": "git", + "url": "git+https://github.com/ReStruct-Corporate-Advantage/configs.git" + }, + "keywords": [ + "components", + "atomic", + "building-blocks", + "foundation" + ], + "files": [ + "build" + ], + "license": "ISC", + "bugs": { + "url": "https://github.com/ReStruct-Corporate-Advantage/configs/issues" + }, + "homepage": "https://github.com/ReStruct-Corporate-Advantage/configs#readme", + "devDependencies": { + "@armco/types": "^0.0.20", + "@types/node": "^24.10.0" + }, + "dependencies": { + "@types/uuid": "^10.0.0" + } +} diff --git a/publish-local.sh b/publish-local.sh new file mode 100755 index 0000000..46b66a6 --- /dev/null +++ b/publish-local.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +semver=${1:-patch} + +set -e + +npm run build +cp package.json build/ +sed -i '' -E 's/"build"/"*"/' build/package.json + +sed -i '' 's#"build/cjs/index.js"#"cjs/index.js"#' build/package.json +sed -i '' 's#"build/es/index.js"#"es/index.js"#' build/package.json +sed -i '' 's#"build/types/index.d.ts"#"types/index.d.ts"#' build/package.json + +cd build +npm pack --pack-destination ~/__Projects__/Common \ No newline at end of file diff --git a/publish.sh b/publish.sh new file mode 100755 index 0000000..94621ea --- /dev/null +++ b/publish.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +semver=${1:-patch} + +set -e +npm --no-git-tag-version version ${semver} +npm run build +cp package.json build/ +sed -i '' -E 's/"build"/"*"/' build/package.json + +sed -i '' 's#"build/cjs/index.js"#"cjs/index.js"#' build/package.json +sed -i '' 's#"build/es/index.js"#"es/index.js"#' build/package.json +sed -i '' 's#"build/types/index.d.ts"#"types/index.d.ts"#' build/package.json + +cd build +npm publish --access public --loglevel verbose diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 0000000..4dd1185 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,2 @@ +export const SESSION_TOKEN_NAME = "x-access-token" +export const SESSION_USER_TOKEN_NAME = "auth-session-user" \ No newline at end of file diff --git a/src/endpoints.ts b/src/endpoints.ts new file mode 100644 index 0000000..cfec0da --- /dev/null +++ b/src/endpoints.ts @@ -0,0 +1,105 @@ +import { ApiConfig, WebConfig } from "./types" + +export const HOST = { + development: "http://localhost:5000/api", + production: "https://api.armco.dev", +} +export const STATIC_HOST = { + development: "http://localhost:5001/api", + production: "https://static.armco.dev", +} +export const TASKER = { + development: "http://localhost:5002/api", + production: "https://tasks.armco.dev", +} +export const CONFIG = { + development: "http://localhost:5003/api", + production: "https://config.armco.dev", +} +export const IAM = { + development: "http://localhost:5004/api", + production: "https://iam.armco.dev", +} +export const SEER = { + development: "http://localhost:5005/api", + production: "https://telemetry.armco.dev", +} + +export const ICON_ROOT = `${ + STATIC_HOST[process.env.NODE_ENV as "production" | "development"] +}/icon` + +export const ARMORY = { + development: "http://localhost:7992", + production: "https://armco.dev", +} +export const IAMCLIENT = { + development: "http://localhost:3001", + production: "https://iam.notabuck.com", +} +export const 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: "/", + }, +} + +export const API_CONFIG: ApiConfig = { + HOST, STATIC_HOST, CONFIG, TASKER, IAM, SEER +} + +export const WEB_CONFIG: WebConfig = { + ARMORY, + IAM: IAMCLIENT, + FORESEER +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..99ca0dc --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export * from "./endpoints" +export * from "./constants" diff --git a/src/types.ts b/src/types.ts new file mode 100644 index 0000000..a643b31 --- /dev/null +++ b/src/types.ts @@ -0,0 +1,20 @@ +export interface HOSTS { + development: string + production: string +} + + +export interface ApiConfig { + HOST: HOSTS + STATIC_HOST: HOSTS + IAM: HOSTS + CONFIG: HOSTS + TASKER: HOSTS + SEER: HOSTS +} + +export interface WebConfig { + ARMORY: HOSTS + IAM: HOSTS + FORESEER: HOSTS +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..9139935 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "es5", + // "lib": [ + // "dom", + // "dom.iterable", + // "esnext" + // ], + "outDir": "build", + "skipLibCheck": true, + "esModuleInterop": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noFallthroughCasesInSwitch": true, + "module": "esnext", + "moduleResolution": "node", + "isolatedModules": true, + "noEmit": true, + }, + "include": [ + "src" + ] +} diff --git a/vite-dev.config.ts b/vite-dev.config.ts new file mode 100644 index 0000000..cedbdaf --- /dev/null +++ b/vite-dev.config.ts @@ -0,0 +1,34 @@ +import { resolve } from "node:path" +import { glob } from "glob" +import { defineConfig } from "vitest/config" +import dts from "vite-plugin-dts" + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [dts({ outDir: "build/types" })], + build: { + outDir: "build", + lib: { + entry: glob.sync(resolve(__dirname, "src/**/*.ts")), + }, + sourcemap: true, + rollupOptions: { + treeshake: true, + external: ["react", "react/jsx-runtime", "react-dom", "uuid"], + output: [ + { + format: "es", + dir: "build/es", + entryFileNames: "[name].js", + chunkFileNames: "[name].js", + }, + { + format: "cjs", + dir: "build/cjs", + entryFileNames: "[name].js", + chunkFileNames: "[name].js", + }, + ], + }, + }, +}) diff --git a/vite.config.ts b/vite.config.ts new file mode 100644 index 0000000..7cae700 --- /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 dts from "vite-plugin-dts" + +// https://vitejs.dev/config/ +export default defineConfig({ + plugins: [dts({ outDir: "build/types" })], + build: { + outDir: "build", + lib: { + entry: glob.sync(resolve(__dirname, "src/**/*.ts")), + }, + rollupOptions: { + treeshake: true, + external: ["react", "react/jsx-runtime", "react-dom", "uuid"], + output: [ + { + format: "es", + dir: "build/es", + entryFileNames: "[name].js", + chunkFileNames: "[name].js", + }, + { + format: "cjs", + dir: "build/cjs", + entryFileNames: "[name].js", + chunkFileNames: "[name].js", + }, + ], + }, + }, +})