Skip to content

Commit

Permalink
feat: use yaml nodejs lib to save/load projects
Browse files Browse the repository at this point in the history
  • Loading branch information
qarlosalberto committed May 31, 2024
1 parent 2d390ee commit fa1b6f2
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 201 deletions.
2 changes: 0 additions & 2 deletions packages/colibri/src/project_manager/list_manager/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ export class File_manager extends Manager<t_file, undefined, string, string> {
const new_files = this.files.map(obj => ({ ...obj }));
for (let i = 0; i < new_files.length; i++) {
new_files[i].name = file_utils.get_relative_path(new_files[i].name, reference_file_path);
// Replaces double back slash generated when running on Windows
new_files[i].name = new_files[i].name.replace(/\\/g, '/');
}
return new_files;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ export class Toplevel_path_manager extends Manager<string, undefined, string, un
const new_files = [...this.toplevel_paths];
for (let i = 0; i < new_files.length; i++) {
new_files[i] = file_utils.get_relative_path(new_files[i], reference_path);
// Replaces double back slash generated when running on Windows
new_files[i] = new_files[i].replace(/\\/g, '/');
}
return new_files;
}
Expand Down
121 changes: 0 additions & 121 deletions packages/colibri/src/project_manager/utils/json2yaml.ts

This file was deleted.

13 changes: 4 additions & 9 deletions packages/colibri/src/project_manager/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,9 @@
// along with TerosHDL. If not, see <https://www.gnu.org/licenses/>.

import { t_project_definition } from "../project_definition";
import { convert_to_yaml } from "./json2yaml";
import * as file_utils from "../../utils/file_utils";
import * as general from "../../common/general";
// import { Database } from 'sqlite3';

// const fs = require('fs');
// const initSqlJs = require('sql-wasm.js');
// const initSqlJs = require('/home/carlos/Desktop/fs/sql-wasm.js');
import * as jsYaml from 'js-yaml';
const initSqlJs = require('sql.js');

export function get_edam_json(prj: t_project_definition, top_level_list: undefined | string[],
Expand Down Expand Up @@ -69,9 +64,9 @@ export function get_edam_json(prj: t_project_definition, top_level_list: undefin

export function get_edam_yaml(prj: t_project_definition, top_level_list: undefined | string[],
reference_path?: string) {
const edam_json = get_edam_json(prj, top_level_list, reference_path);
const edam_yaml = convert_to_yaml(edam_json);
return edam_yaml;
const edamJSON = get_edam_json(prj, top_level_list, reference_path);
const edamYaml = jsYaml.dump(edamJSON);
return edamYaml;
}

/**
Expand Down
66 changes: 0 additions & 66 deletions packages/colibri/tests/project_manager/utils.spec.ts

This file was deleted.

5 changes: 4 additions & 1 deletion packages/teroshdl/src/features/tree_views/project/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,10 +267,13 @@ export class Project_manager extends BaseView {

async create_project_from_yaml(prj_path: string) {
try {
const fileContent = teroshdl2.utils.file.read_file_sync(prj_path)
const repJSON = yaml.load(fileContent, { json: true });
const prj = await teroshdl2.project_manager.project_manager.Project_manager.fromJson(
yaml.load(teroshdl2.utils.file.read_file_sync(prj_path)), prj_path, this.emitterProject);
repJSON, prj_path, this.emitterProject);
this.project_manager.add_project(prj);
} catch (error) {
console.log(error)
}
}

Expand Down

0 comments on commit fa1b6f2

Please sign in to comment.