mirror of
https://github.com/fluxscape/fluxscape.git
synced 2026-01-11 14:52:54 +01:00
feat: Save "nodelibrary.json" with the project (#94)
* feat: Save "nodelibrary.json" with the project To manage the project without the editor/preview, we need to know more about the Node Library. To make this possible, let's save the Node Library next to the project. Hopefully it will work smoothly for a lot of projects. I have tested it with a few big projects, and it works well for them. * chore: clean up * fix: Make compact and check if there is some data
This commit is contained in:
@@ -1167,6 +1167,28 @@ EventDispatcher.instance.on(
|
|||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
||||||
|
NodeLibrary.instance.on('libraryUpdated', () => {
|
||||||
|
const library = NodeLibrary.instance.library;
|
||||||
|
|
||||||
|
// Check if we have any data from the browser
|
||||||
|
if (Object.keys(library?.nodeIndex || {}).length > 0) {
|
||||||
|
const filepath = filesystem.join(ProjectModel.instance._retainedProjectDirectory, 'nodelibrary.json');
|
||||||
|
|
||||||
|
const compactLibrary = {
|
||||||
|
typecasts: library.typecasts,
|
||||||
|
dynamicports: library.dynamicports,
|
||||||
|
nodetypes: library.nodetypes,
|
||||||
|
// NOTE: Let's save the node index for now, most likely this is something we will just ignore.
|
||||||
|
nodeIndex: library.nodeIndex,
|
||||||
|
projectsettings: library.projectsettings
|
||||||
|
};
|
||||||
|
|
||||||
|
filesystem.writeJson(filepath, compactLibrary).then(() => {
|
||||||
|
console.log('saved nodelibrary.json');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
function saveProject() {
|
function saveProject() {
|
||||||
if (!ProjectModel.instance) return;
|
if (!ProjectModel.instance) return;
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { clearFolders } from './cleanup';
|
|||||||
|
|
||||||
export async function copyProjectFilesToFolder(projectPath: string, direntry: string): Promise<void> {
|
export async function copyProjectFilesToFolder(projectPath: string, direntry: string): Promise<void> {
|
||||||
// TODO: Load something like .noodlignore file list
|
// TODO: Load something like .noodlignore file list
|
||||||
const ignoreFiles = ['.DS_Store', '.gitignore', '.gitattributes', 'project.json', 'Dockerfile'];
|
const ignoreFiles = ['.DS_Store', '.gitignore', '.gitattributes', 'project.json', 'Dockerfile', 'nodelibrary.json'];
|
||||||
|
|
||||||
// Copy everything from the project folder
|
// Copy everything from the project folder
|
||||||
if (!projectPath) {
|
if (!projectPath) {
|
||||||
|
|||||||
Reference in New Issue
Block a user