From 98cef508a6c879d290f1a29aaafb13e873e6b557 Mon Sep 17 00:00:00 2001
From: Timothy Carambat <rambat1010@gmail.com>
Date: Fri, 7 Jun 2024 03:50:42 +0800
Subject: [PATCH] Feature/devcontv2 (#1622)

* Updated apt-packages source for devcontainer

Switched the devcontainer's package source to a different repository to
align with updated dependencies and package availability. The previous
source from 'rocker-org' is replaced with 'devcontainers-contrib', which
may offer more recent or relevant development tools.

* Subject: Centralize prettier ignores and refine
config

Body:
Centralized all prettier ignore rules by removing individual
`.prettierignore` files in subprojects and updating the root
`.prettierignore` to include previously ignored patterns, ensuring
consistency across the workspace. Additionally, the prettier
configuration was refined by making the file pattern for `.config.js`
files consistent and adjusting quote styles for better readability. All
lint scripts across the project were updated to respect the centralized
ignore path, enhancing maintainability.

The consolidation simplifies the process of managing ignore rules as the
project scales, ensuring developers can focus on writing code without
worrying about divergent formatting standards. These changes also align
with introducing comprehensive linting across multiple environments to
keep the codebase clean and consistent.

This adjustment is a foundational step towards a more streamlined and
unified code base, making it easier for new contributors to adhere to
established coding standards and reducing the cognitive load associated
with managing multiple configuration files across the project.

* unset package json changes

---------

Co-authored-by: Francisco Bischoff <franzbischoff@gmail.com>
Co-authored-by: Francisco Bischoff <984592+franzbischoff@users.noreply.github.com>
---
 .devcontainer/devcontainer.json |  2 +-
 .prettierignore                 |  4 ++++
 .prettierrc                     |  2 +-
 collector/package.json          |  2 +-
 embed/.prettierignore           |  9 ---------
 embed/jsconfig.json             | 10 ++++------
 embed/package.json              |  3 ++-
 embed/vite.config.js            |  6 +++---
 frontend/jsconfig.json          |  6 ++----
 frontend/package.json           |  2 +-
 frontend/vite.config.js         |  2 +-
 server/package.json             |  2 +-
 12 files changed, 21 insertions(+), 29 deletions(-)
 delete mode 100644 embed/.prettierignore

diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index 83792da78..58c42b62d 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -22,7 +22,7 @@
     // Terraform support
     "ghcr.io/devcontainers/features/terraform:1": {},
     // Just a wrap to install needed packages
-    "ghcr.io/rocker-org/devcontainer-features/apt-packages:1": {
+    "ghcr.io/devcontainers-contrib/features/apt-packages:1": {
       // Dependencies copied from ../docker/Dockerfile plus some dev stuff
       "packages": [
         "build-essential",
diff --git a/.prettierignore b/.prettierignore
index faedf3258..e3b0c14e0 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -10,3 +10,7 @@ frontend/bundleinspector.html
 
 #server
 server/swagger/openapi.json
+
+#embed
+**/static/**
+embed/src/utils/chat/hljs.js
diff --git a/.prettierrc b/.prettierrc
index 3574c1dfd..5e2bccfe4 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -17,7 +17,7 @@
       }
     },
     {
-      "files": "*.config.js",
+      "files": ["*.config.js"],
       "options": {
         "semi": false,
         "parser": "flow",
diff --git a/collector/package.json b/collector/package.json
index 785604e38..938d65e15 100644
--- a/collector/package.json
+++ b/collector/package.json
@@ -12,7 +12,7 @@
   "scripts": {
     "dev": "NODE_ENV=development nodemon --ignore hotdir --ignore storage --trace-warnings index.js",
     "start": "NODE_ENV=production node index.js",
-    "lint": "yarn prettier --write ./processSingleFile ./processLink ./utils index.js"
+    "lint": "yarn prettier --ignore-path ../.prettierignore --write ./processSingleFile ./processLink ./utils index.js"
   },
   "dependencies": {
     "@googleapis/youtube": "^9.0.0",
diff --git a/embed/.prettierignore b/embed/.prettierignore
deleted file mode 100644
index d90a3c089..000000000
--- a/embed/.prettierignore
+++ /dev/null
@@ -1,9 +0,0 @@
-# defaults
-**/.git
-**/.svn
-**/.hg
-**/node_modules
-
-**/dist
-**/static/**
-src/utils/chat/hljs.js
diff --git a/embed/jsconfig.json b/embed/jsconfig.json
index c8cc81fdb..20cd368c0 100644
--- a/embed/jsconfig.json
+++ b/embed/jsconfig.json
@@ -4,9 +4,7 @@
     "target": "esnext",
     "jsx": "react",
     "paths": {
-      "@/*": [
-        "./src/*"
-      ],
-    }
-  }
-}
\ No newline at end of file
+      "@/*": ["./src/*"],
+    },
+  },
+}
diff --git a/embed/package.json b/embed/package.json
index eb3999303..712af8e6c 100644
--- a/embed/package.json
+++ b/embed/package.json
@@ -1,6 +1,7 @@
 {
   "name": "anythingllm-embedded-chat",
   "private": false,
+  "license": "MIT",
   "type": "module",
   "scripts": {
     "dev": "nodemon -e js,jsx,css --watch src --exec \"yarn run dev:preview\"",
@@ -8,7 +9,7 @@
     "dev:build": "vite build && cat src/static/tailwind@3.4.1.js >> dist/anythingllm-chat-widget.js",
     "build": "vite build && cat src/static/tailwind@3.4.1.js >> dist/anythingllm-chat-widget.js && npx terser --compress -o dist/anythingllm-chat-widget.min.js -- dist/anythingllm-chat-widget.js",
     "build:publish": "yarn build && mkdir -p ../frontend/public/embed && cp -r dist/anythingllm-chat-widget.min.js ../frontend/public/embed/anythingllm-chat-widget.min.js",
-    "lint": "yarn prettier --write ./src"
+    "lint": "yarn prettier --ignore-path ../.prettierignore --write ./src"
   },
   "dependencies": {
     "@microsoft/fetch-event-source": "^2.0.1",
diff --git a/embed/vite.config.js b/embed/vite.config.js
index 215064221..9e23c70d2 100644
--- a/embed/vite.config.js
+++ b/embed/vite.config.js
@@ -38,7 +38,7 @@ export default defineConfig({
     rollupOptions: {
       external: [
         // Reduces transformation time by 50% and we don't even use this variant, so we can ignore.
-        /@phosphor-icons\/react\/dist\/ssr/,
+        /@phosphor-icons\/react\/dist\/ssr/
       ]
     },
     commonjsOptions: {
@@ -51,7 +51,7 @@ export default defineConfig({
     emptyOutDir: true,
     inlineDynamicImports: true,
     assetsDir: "",
-    sourcemap: 'inline',
+    sourcemap: "inline"
   },
   optimizeDeps: {
     esbuildOptions: {
@@ -60,5 +60,5 @@ export default defineConfig({
       },
       plugins: []
     }
-  },
+  }
 })
diff --git a/frontend/jsconfig.json b/frontend/jsconfig.json
index c8cc81fdb..e21fc3764 100644
--- a/frontend/jsconfig.json
+++ b/frontend/jsconfig.json
@@ -4,9 +4,7 @@
     "target": "esnext",
     "jsx": "react",
     "paths": {
-      "@/*": [
-        "./src/*"
-      ],
+      "@/*": ["./src/*"]
     }
   }
-}
\ No newline at end of file
+}
diff --git a/frontend/package.json b/frontend/package.json
index 11e612fcd..2b669731a 100644
--- a/frontend/package.json
+++ b/frontend/package.json
@@ -7,7 +7,7 @@
     "start": "vite --open",
     "dev": "NODE_ENV=development vite --debug --host=0.0.0.0",
     "build": "vite build",
-    "lint": "yarn prettier --write ./src",
+    "lint": "yarn prettier --ignore-path ../.prettierignore --write ./src",
     "preview": "vite preview"
   },
   "dependencies": {
diff --git a/frontend/vite.config.js b/frontend/vite.config.js
index 3785b9477..ff96bdcd2 100644
--- a/frontend/vite.config.js
+++ b/frontend/vite.config.js
@@ -51,7 +51,7 @@ export default defineConfig({
     rollupOptions: {
       external: [
         // Reduces transformation time by 50% and we don't even use this variant, so we can ignore.
-        /@phosphor-icons\/react\/dist\/ssr/,
+        /@phosphor-icons\/react\/dist\/ssr/
       ]
     },
     commonjsOptions: {
diff --git a/server/package.json b/server/package.json
index 4f9954700..b107695cc 100644
--- a/server/package.json
+++ b/server/package.json
@@ -12,7 +12,7 @@
   "scripts": {
     "dev": "NODE_ENV=development nodemon --ignore documents --ignore vector-cache --ignore storage --ignore swagger --trace-warnings index.js",
     "start": "NODE_ENV=production node index.js",
-    "lint": "yarn prettier --write ./endpoints ./models ./utils index.js",
+    "lint": "yarn prettier --ignore-path ../.prettierignore --write ./endpoints ./models ./utils index.js",
     "swagger": "node ./swagger/init.js",
     "sqlite:migrate": "cd ./utils/prisma && node migrateFromSqlite.js"
   },
-- 
GitLab