Fresh changes after cleanup
Some checks failed
armco-org/configs/pipeline/head There was a failure building this commit
Some checks failed
armco-org/configs/pipeline/head There was a failure building this commit
This commit is contained in:
7
.gitignore
vendored
Normal file
7
.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
build
|
||||
dist
|
||||
node_modules
|
||||
.DS_Store
|
||||
constants
|
||||
endpoints
|
||||
navigator
|
||||
6
Jenkinsfile
vendored
Normal file
6
Jenkinsfile
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
@Library('jenkins-shared') _
|
||||
kanikoPipeline(
|
||||
repoName: 'configs',
|
||||
branch: env.BRANCH_NAME ?: 'main',
|
||||
isNpmLib: true
|
||||
)
|
||||
36
build-tools/build.sh
Executable file
36
build-tools/build.sh
Executable file
@@ -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
|
||||
33
build-tools/generate-module.js
Normal file
33
build-tools/generate-module.js
Normal file
@@ -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
|
||||
25
build-tools/post-processor.js
Normal file
25
build-tools/post-processor.js
Normal file
@@ -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)
|
||||
}
|
||||
68
package-lock.json
generated
Normal file
68
package-lock.json
generated
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
46
package.json
Normal file
46
package.json
Normal file
@@ -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"
|
||||
}
|
||||
}
|
||||
16
publish-local.sh
Executable file
16
publish-local.sh
Executable file
@@ -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
|
||||
16
publish.sh
Executable file
16
publish.sh
Executable file
@@ -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
|
||||
2
src/constants.ts
Normal file
2
src/constants.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const SESSION_TOKEN_NAME = "x-access-token"
|
||||
export const SESSION_USER_TOKEN_NAME = "auth-session-user"
|
||||
105
src/endpoints.ts
Normal file
105
src/endpoints.ts
Normal file
@@ -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
|
||||
}
|
||||
2
src/index.ts
Normal file
2
src/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./endpoints"
|
||||
export * from "./constants"
|
||||
20
src/types.ts
Normal file
20
src/types.ts
Normal file
@@ -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
|
||||
}
|
||||
23
tsconfig.json
Normal file
23
tsconfig.json
Normal file
@@ -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"
|
||||
]
|
||||
}
|
||||
34
vite-dev.config.ts
Normal file
34
vite-dev.config.ts
Normal file
@@ -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",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
33
vite.config.ts
Normal file
33
vite.config.ts
Normal file
@@ -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",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
Reference in New Issue
Block a user