Skip to content

A full-featured CRM built with React, shadcn/ui, and Supabase.

feat(skill): delete-resource

erwanMarmelabaf217f3dcae5
diff --git a/.claude/skills/delete-initial-resource/SKILL.md b/.claude/skills/delete-initial-resource/SKILL.md
new file mode 100644
index 00000000..e69de29b
diff --git a/.claude/skills/delete-initial-resource/delete-initial-resource.ts b/.claude/skills/delete-initial-resource/delete-initial-resource.ts
new file mode 100755
index 00000000..74aef937
--- /dev/null
+++ b/.claude/skills/delete-initial-resource/delete-initial-resource.ts
@@ -0,0 +1,138 @@
+#!/usr/bin/node
+
+declare const process: {
+ cwd(): unknown;
+ argv: string[];
+ exit(code?: number): never;
+};
+import { existsSync } from "node:fs";
+import { rm } from "node:fs/promises";
+
+// ================================ CONSTANTS ================================
+const initialResource = [
+ "contacts",
+ "companies",
+ "deals",
+ "tags",
+ "tasks",
+] as const;
+const dependentFiles: ResourceFiles = {
+ companies: [
+ "src/components/atomic-crm/contacts/ContactInputs.tsx",
+ "src/components/atomic-crm/deals/DealInputs.tsx",
+ "src/components/atomic-crm/activity/ActivityLogCompanyCreated.tsx",
+ "src/components/atomic-crm/activity/ActivityLogDealNoteCreated.tsx",
+ "src/components/atomic-crm/contacts/ContactShow.tsx",
+ "src/components/atomic-crm/dashboard/DealsPipeline.tsx",
+ "src/components/atomic-crm/deals/DealCard.tsx",
+ "src/components/atomic-crm/deals/DealEdit.tsx",
+ "src/components/atomic-crm/deals/DealShow.tsx",
+ "src/components/atomic-crm/notes/Note.tsx",
+ ],
+ contacts: [
+ "src/components/atomic-crm/companies/CompanyShow.tsx",
+ "src/components/atomic-crm/misc/useImportFromJson.ts",
+ "src/components/atomic-crm/providers/fakerest/dataGenerator/contacts.ts",
+ "src/components/atomic-crm/dashboard/DashboardStepper.tsx",
+ "src/components/atomic-crm/layout/MobileNavigation.tsx",
+ "src/components/atomic-crm/activity/ActivityLogContactCreated.tsx",
+ "src/components/atomic-crm/activity/ActivityLogContactNoteCreated.tsx",
+ "src/components/atomic-crm/companies/CompanyCard.tsx",
+ "src/components/atomic-crm/companies/CompanyShow.tsx",
+ "src/components/atomic-crm/dashboard/HotContacts.tsx",
+ "src/components/atomic-crm/deals/ContactList.tsx",
+ "src/components/atomic-crm/misc/ContactOption.tsx",
+ ],
+ deals: [
+ "src/components/atomic-crm/dashboard/DealsPipeline.tsx",
+ "src/components/atomic-crm/dashboard/DealsChart.tsx",
+ "src/components/atomic-crm/companies/CompanyShow.tsx",
+ ],
+ tags: [
+ "src/components/atomic-crm/misc/useImportFromJson.ts",
+ "src/components/atomic-crm/contacts/TagsListEdit.tsx",
+ "src/components/atomic-crm/contacts/BulkTagButton.tsx",
+ ],
+ tasks: [
+ "src/components/atomic-crm/dashboard/TasksList.tsx",
+ "src/components/atomic-crm/contacts/ContactAside.tsx",
+ "src/components/atomic-crm/layout/MobileNavigation.tsx",
+ "src/components/atomic-crm/contacts/ContactTasksList.tsx",
+ ],
+} as const;
+const sharedDependentFiles: string[] = [
+ "src/components/atomic-crm/root/CRM.tsx",
+] as const;
+const resourceFilesPath = "src/components/atomic-crm" as const;
+
+// ================================ TYPES ================================
+type InitialResource = (typeof initialResource)[number];
+type DependentFile = string;
+type ResourceFiles = Record<InitialResource, DependentFile[]>;
+
+// ================================ FONCTIONS ================================
+const main = async () => {
+ const resourceToDelete = getResource();
+ const basePath = process.cwd() as string;
+ await deleteIsolatedFiles(resourceToDelete, basePath);
+ returnDependentFiles(resourceToDelete);
+};
+
+// Get the resource to delete from the command line arguments, and check if it's valid
+const getResource = (): InitialResource => {
+ const resourceToDelete = process.argv[2];
+ if (!resourceToDelete) {
+ console.error("Please provide a resource to delete.");
+ process.exit(1);
+ }
+
+ if (!checkResourceExists(resourceToDelete)) {
+ console.error(`Resource "${resourceToDelete}" does not exist.`);
+ process.exit(1);
+ }
+
+ return resourceToDelete as InitialResource;
+};
+// Check if the resource exists in the initialResource array
+const checkResourceExists = (resource: string): boolean => {
+ if (!initialResource.includes(resource as InitialResource)) {
+ return false;
+ }
+ return true;
+};
+
+// Delete the ressource folder and their files. And return any that failed to delete
+const deleteIsolatedFiles = async (
+ resource: InitialResource,
+ basePath: string,
+) => {
+ const folderPath = `${basePath}/${resourceFilesPath}/${resource}`;
+
+ if (!existsSync(folderPath)) {
+ console.error(
+ `Folder for resource "${resource}" does not exist. Skipping deletion of isolated files.`,
+ );
+ process.exit(1);
+ }
+
+ await rm(folderPath, { recursive: true, force: true });
+};
+
+// Return to Claude all the files dependent on the deleted resource
+const returnDependentFiles = (resource: InitialResource) => {
+ const dependentFilesToReturn = dependentFiles[resource];
+ const allDependentFilesToReturn = [
+ ...dependentFilesToReturn,
+ ...sharedDependentFiles,
+ ];
+
+ // eslint-disable-next-line no-console
+ console.log(
+ `Dependent files for resource "${resource}":\n`,
+ allDependentFilesToReturn,
+ );
+ process.exit(0);
+};
+
+// ================================ MAIN CALL ================================
+await main();
diff --git a/package-lock.json b/package-lock.json
index cbdb1153..1b630eb6 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -87,7 +87,7 @@
"@types/jsonexport": "^3.0.5",
"@types/lodash": "^4.17.20",
"@types/ms": "^2.1.0",
- "@types/node": "^22.16.5",
+ "@types/node": "^22.19.19",
"@types/papaparse": "^5.3.16",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
@@ -8943,9 +8943,9 @@
"license": "MIT"
},
"node_modules/@types/node": {
- "version": "22.18.0",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-22.18.0.tgz",
- "integrity": "sha512-m5ObIqwsUp6BZzyiy4RdZpzWGub9bqLJMvZDD0QMXhxjqMHMENlj+SqF5QxoUwaQNFe+8kz8XM8ZQhqkQPTgMQ==",
+ "version": "22.19.19",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.19.tgz",
+ "integrity": "sha512-dyh/xO2Fh5bYrfWaaqGrRQQGkNdmYw6AmaAUvYeUMNTWQtvb796ikLdmTchRmOlOiIJ1TDXfWgVx1QkUlQ6Hew==",
"license": "MIT",
"dependencies": {
"undici-types": "~6.21.0"
diff --git a/package.json b/package.json
index 2b0ed36d..cb3d41a1 100644
--- a/package.json
+++ b/package.json
@@ -105,7 +105,7 @@
"@types/jsonexport": "^3.0.5",
"@types/lodash": "^4.17.20",
"@types/ms": "^2.1.0",
- "@types/node": "^22.16.5",
+ "@types/node": "^22.19.19",
"@types/papaparse": "^5.3.16",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",