Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:JavidSumra/care_fe into issues/9…
Browse files Browse the repository at this point in the history
…053/prevent-negative-quantity-and-empty-description
  • Loading branch information
JavidSumra committed Nov 9, 2024
2 parents 9256e70 + 6bd2aa8 commit 41c1b1c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ cypress/fixtures/token.json
# Care Apps
/apps/*
src/pluginMap.ts
/apps_backup/*
6 changes: 3 additions & 3 deletions plugins/treeShakeCareIcons.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Plugin } from "vite";
import * as fs from "fs";
import * as path from "path";
import { globSync } from "glob";
import * as path from "path";
import { Plugin } from "vite";

/**
* Interface defining options for the treeShakeUniconPathsPlugin.
Expand Down Expand Up @@ -48,7 +48,7 @@ export function treeShakeCareIcons(
}
// Finds all used icon names within the project's source files (`.tsx` or `.res` extensions).
function getAllUsedIconNames() {
const files = globSync(path.resolve(rootDir, "src/**/*.{tsx,res}"));
const files = globSync(path.resolve(rootDir, "{apps,src}/**/*.{tsx,res}"));
const usedIconsArray: string[] = [];

files.forEach((file) => {
Expand Down
30 changes: 30 additions & 0 deletions scripts/setup-care-apps.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,36 @@ const installApp = (app) => {
);
};

const backupDir = path.join(__dirname, "..", "apps_backup");

// Create backup directory if needed
if (!fs.existsSync(backupDir)) {
fs.mkdirSync(backupDir);
}

try {
fs.readdirSync(appsDir, { withFileTypes: true })
.filter((dirent) => dirent.isDirectory())
.map((dirent) => dirent.name)
.filter(
(dir) =>
!appsConfig.map((app) => app.package.split("/")[1]).includes(dir),
)
.forEach((unusedApp) => {
const appPath = path.join(appsDir, unusedApp);
const backupPath = path.join(backupDir, `${unusedApp}_${Date.now()}`);
console.log(`Backing up '${unusedApp}' to ${backupPath}`);
fs.cpSync(appPath, backupPath, { recursive: true });
console.log(
`Removing existing app '${unusedApp}' as it is not configured.`,
);
fs.rmSync(appPath, { recursive: true, force: true });
});
} catch (error) {
console.error("Error during cleanup:", error);
process.exit(1);
}

// Clone or pull care apps
appsConfig.forEach((app) => {
const appDir = path.join(appsDir, app.package.split("/")[1]);
Expand Down

0 comments on commit 41c1b1c

Please sign in to comment.