Skip to content

Commit

Permalink
Merge pull request #7 from lastlink/f/fixes
Browse files Browse the repository at this point in the history
F/fixes embed version
  • Loading branch information
lastlink authored Jun 23, 2024
2 parents b54909a + 67bb402 commit dd82b5a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
4 changes: 3 additions & 1 deletion build/updateVersion.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ console.log("Updating to version " + package.version);
files.forEach((file) => {
const filePath = `${directoryPath}/${file}`;
let content = fs.readFileSync(filePath, "utf8");
content = content.replace(oldText, package.version);
while(content.includes(oldText)) {
content = content.replace(oldText, package.version);
}
// content = content.replace(new RegExp(oldText, "g"), newText);
fs.writeFileSync(filePath, content, "utf8");
console.log(`Replaced text in ${file}`);
Expand Down
15 changes: 6 additions & 9 deletions dist/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,11 +900,7 @@ const sqlsimpleparser_1 = require("@funktechno/sqlsimpleparser");
*/
Draw.loadPlugin(function (ui) {
// export sql methods
/**
* Mermaid Models TO SQL parser
* src https://github.com/Software-Developers-IRL/Little-Mermaid-2-The-SQL/blob/main/src/generate-sql-ddl.ts
*/
// DbParser
const pluginVersion = "0.0.1";
//Create Base div
const divGenSQL = document.createElement("div");
divGenSQL.style.userSelect = "none";
Expand All @@ -914,7 +910,8 @@ Draw.loadPlugin(function (ui) {
const sqlInputGenSQL = document.createElement("textarea");
sqlInputGenSQL.style.height = "200px";
sqlInputGenSQL.style.width = "100%";
sqlInputGenSQL.value = "-- click a database type button";
const sqlExportDefault = "-- click a database type button";
sqlInputGenSQL.value = sqlExportDefault;
mxUtils.br(divGenSQL);
divGenSQL.appendChild(sqlInputGenSQL);
const theMenuExportAs = ui.menus.get("exportAs");
Expand Down Expand Up @@ -1177,7 +1174,7 @@ Draw.loadPlugin(function (ui) {
const parser = new generate_sql_ddl_1.DbParser(type, db);
// generate sql
let sql = parser.getSQLDataDefinition();
sql = `/*\n\tGenerated in drawio\n\tDatabase: ${type}\n*/\n\n` + sql;
sql = `/*\n\tGenerated in drawio\n\tDatabase: ${type}\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\n` + sql;
sql = sql.trim();
// update sql value in text area
sqlInputGenSQL.value = sql;
Expand All @@ -1187,7 +1184,7 @@ Draw.loadPlugin(function (ui) {
;
mxUtils.br(divGenSQL);
const resetBtnGenSQL = mxUtils.button(mxResources.get("reset"), function () {
sqlInputGenSQL.value = "";
sqlInputGenSQL.value = sqlExportDefault;
});
resetBtnGenSQL.style.marginTop = "8px";
resetBtnGenSQL.style.marginRight = "4px";
Expand Down Expand Up @@ -1245,7 +1242,7 @@ Draw.loadPlugin(function (ui) {
const sqlInputFromSQL = document.createElement("textarea");
sqlInputFromSQL.style.height = "200px";
sqlInputFromSQL.style.width = "100%";
const defaultReset = "/*\n\tDraw io default value\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
const defaultReset = "/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
"\n);";
Expand Down
17 changes: 7 additions & 10 deletions src/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ import { ForeignKeyModel, PrimaryKeyModel, PropertyModel, TableModel } from "@fu
Draw.loadPlugin(function(ui) {

// export sql methods

/**
* Mermaid Models TO SQL parser
* src https://github.com/Software-Developers-IRL/Little-Mermaid-2-The-SQL/blob/main/src/generate-sql-ddl.ts
*/
// DbParser
const pluginVersion = "<VERSION>";

//Create Base div
const divGenSQL = document.createElement("div");
Expand All @@ -28,7 +23,8 @@ Draw.loadPlugin(function(ui) {
const sqlInputGenSQL = document.createElement("textarea");
sqlInputGenSQL.style.height = "200px";
sqlInputGenSQL.style.width = "100%";
sqlInputGenSQL.value = "-- click a database type button";
const sqlExportDefault = "-- click a database type button";
sqlInputGenSQL.value = sqlExportDefault;
mxUtils.br(divGenSQL);
divGenSQL.appendChild(sqlInputGenSQL);
const theMenuExportAs = ui.menus.get("exportAs");
Expand Down Expand Up @@ -308,7 +304,7 @@ Draw.loadPlugin(function(ui) {
const parser = new DbParser(type as string, db);
// generate sql
let sql = parser.getSQLDataDefinition();
sql = `/*\n\tGenerated in drawio\n\tDatabase: ${type}\n*/\n\n` + sql;
sql = `/*\n\tGenerated in drawio\n\tDatabase: ${type}\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\n` + sql;
sql = sql.trim();
// update sql value in text area
sqlInputGenSQL.value = sql;
Expand All @@ -319,7 +315,7 @@ Draw.loadPlugin(function(ui) {
mxUtils.br(divGenSQL);

const resetBtnGenSQL = mxUtils.button(mxResources.get("reset"), function() {
sqlInputGenSQL.value = "";
sqlInputGenSQL.value = sqlExportDefault;
});

resetBtnGenSQL.style.marginTop = "8px";
Expand Down Expand Up @@ -395,10 +391,11 @@ Draw.loadPlugin(function(ui) {
const sqlInputFromSQL = document.createElement("textarea");
sqlInputFromSQL.style.height = "200px";
sqlInputFromSQL.style.width = "100%";
const defaultReset = "/*\n\tDraw io default value\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
const defaultReset = "/*\n\tDrawio default value\n\tPlugin: sql\n\tVersion: ${pluginVersion}\n*/\n\nCREATE TABLE Persons\n(\n PersonID int NOT NULL,\n LastName varchar(255),\n " +
"FirstName varchar(255),\n Address varchar(255),\n City varchar(255),\n Primary Key(PersonID)\n);\n\n" +
"CREATE TABLE Orders\n(\n OrderID int NOT NULL PRIMARY KEY,\n PersonID int NOT NULL,\n FOREIGN KEY ([PersonID]) REFERENCES [Persons]([PersonID])" +
"\n);";

sqlInputFromSQL.value = defaultReset;
mxUtils.br(divFromSQL);
divFromSQL.appendChild(sqlInputFromSQL);
Expand Down

0 comments on commit dd82b5a

Please sign in to comment.