-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(backend): Create / delete plugin
- Loading branch information
1 parent
a562f8b
commit eacddcb
Showing
17 changed files
with
178 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
packages/backend/src/core/admin/plugins/helpers/verify-files.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { ABSOLUTE_PATHS_BACKEND, CustomError } from '@/index'; | ||
import { Injectable } from '@nestjs/common'; | ||
import { existsSync } from 'fs'; | ||
|
||
@Injectable() | ||
export class VerifyFilesAdminPluginsService { | ||
verifyFiles({ | ||
code, | ||
errorHandler, | ||
}: { | ||
code: string; | ||
errorHandler?: (path: string) => void; | ||
}) { | ||
const pathsToFolders = [ | ||
// Frontend - pages | ||
ABSOLUTE_PATHS_BACKEND.plugin({ code }).frontend.pages, | ||
ABSOLUTE_PATHS_BACKEND.plugin({ code }).frontend.pages_main, | ||
ABSOLUTE_PATHS_BACKEND.plugin({ code }).frontend.pages_main_layout, | ||
// Frontend - admin pages | ||
ABSOLUTE_PATHS_BACKEND.plugin({ code }).frontend.admin_pages, | ||
ABSOLUTE_PATHS_BACKEND.plugin({ code }).frontend.admin_pages_auth, | ||
// Frontend - plugin | ||
ABSOLUTE_PATHS_BACKEND.plugin({ code }).frontend.plugin, | ||
]; | ||
|
||
// Check if the folders exist | ||
pathsToFolders.forEach(path => { | ||
if (existsSync(path)) { | ||
errorHandler?.(path); | ||
throw new CustomError({ | ||
code: 'CONFLICT_PLUGIN', | ||
message: `Folder ${path} already exists!`, | ||
}); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.