@kumologica/sdk 3.6.0-alpha7 → 3.6.0-alpha8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,117 +1,139 @@
1
- const path = require('path');
1
+ const path = require("path");
2
2
  const { spawn } = require("child_process");
3
- const { Updater } = require('@kumologica/builder');
4
- const { confirm } = require('enquirer');
3
+ const { Updater } = require("@kumologica/builder");
4
+ const { confirm } = require("enquirer");
5
5
 
6
- const { logError } = require('../utils/logger');
7
- const rootPath = path.join(__dirname, '..', '..', '..', '..');
6
+ const { logError } = require("../utils/logger");
7
+ const rootPath = path.join(__dirname, "..", ".."); // DO NOT CHANGE THIS PATH. SET THE ENV VAR: "KUMOLOGICA_ELECTRON_PATH" INSTEAD!!!!
8
8
 
9
9
  function displayTable(data) {
10
- if (!data.length) {
11
- return;
12
- }
13
-
14
- // Get the keys (property names) from the first row
15
- const keys = Object.keys(data[0]);
16
-
17
- // Get the maximum width for each column
18
- const colWidths = keys.map(key =>
19
- Math.max(...data.map(row => row[key].length), key.length) // Include header (key) length
20
- );
21
-
22
- // Display the headers (property names)
23
- const headerRow = keys
24
- .map((key, i) => key.padEnd(colWidths[i])) // Align headers
25
- .join(' '); // Add spaces between columns
26
- console.log(headerRow);
27
-
28
- // Display rows with left-aligned columns
29
- data.forEach(row => {
30
- const formattedRow = keys
31
- .map((key, i) => row[key].padEnd(colWidths[i])) // Align row data
32
- .join(' '); // Add spaces between columns
33
- console.log(formattedRow);
34
- });
10
+ if (!data.length) {
11
+ return;
12
+ }
13
+
14
+ // Get the keys (property names) from the first row
15
+ const keys = Object.keys(data[0]);
16
+
17
+ // Get the maximum width for each column
18
+ const colWidths = keys.map(
19
+ (key) => Math.max(...data.map((row) => row[key].length), key.length) // Include header (key) length
20
+ );
21
+
22
+ // Display the headers (property names)
23
+ const headerRow = keys
24
+ .map((key, i) => key.padEnd(colWidths[i])) // Align headers
25
+ .join(" "); // Add spaces between columns
26
+ console.log(headerRow);
27
+
28
+ // Display rows with left-aligned columns
29
+ data.forEach((row) => {
30
+ const formattedRow = keys
31
+ .map((key, i) => row[key].padEnd(colWidths[i])) // Align row data
32
+ .join(" "); // Add spaces between columns
33
+ console.log(formattedRow);
34
+ });
35
35
  }
36
36
 
37
37
  function startElectron(projectDir) {
38
- console.debug(`Project directory: ${projectDir}`);
39
- console.debug(`Root directory: ${rootPath}`);
40
-
41
- let electronPath = process.env["KUMOLOGICA_ELECTRON_PATH"] || path.join(rootPath, "node_modules", ".bin", "electron");
42
- console.debug(`Electron path: ${electronPath}`);
43
-
44
- const e = spawn( electronPath, ['.', projectDir], { cwd: rootPath, shell: true } );
45
-
46
- e.stdout.on("data", data => {
47
- console.log(data.toString().trim());
48
- });
49
-
50
- e.stderr.on("data", data => {
51
- logError(data.toString().trim());
52
- });
53
-
54
- e.on('error', (error) => {
55
- console.log(`==> ${error.message}`);
56
- });
57
-
58
- e.on("close", code => {
59
- console.log(`exited with code ${code}`);
60
- });
38
+ console.debug(`Project directory: ${projectDir}`);
39
+ console.debug(`Root directory: ${rootPath}`);
40
+
41
+ let electronPath =
42
+ process.env["KUMOLOGICA_ELECTRON_PATH"] ||
43
+ path.join(rootPath, "node_modules", ".bin", "electron");
44
+ console.debug(`Electron path: ${electronPath}`);
45
+
46
+ const e = spawn(electronPath, [".", projectDir], {
47
+ cwd: rootPath,
48
+ shell: true,
49
+ });
50
+
51
+ e.stdout.on("data", (data) => {
52
+ console.log(data.toString().trim());
53
+ });
54
+
55
+ e.stderr.on("data", (data) => {
56
+ logError(data.toString().trim());
57
+ });
58
+
59
+ e.on("error", (error) => {
60
+ console.log(`==> ${error.message}`);
61
+ });
62
+
63
+ e.on("close", (code) => {
64
+ console.log(`exited with code ${code}`);
65
+ });
61
66
  }
62
67
 
63
68
  // Prompt to upgrade to aws sdk v3
64
69
  async function promptV3(updates) {
65
- if (updates.v3) {
66
- console.log("");
67
- console.log("This project uses the deprecated aws-sdk v2. Migration to aws-sdk v3 is available.");
68
- console.log("");
69
-
70
- const answer = await confirm({ message: 'Do you wish to migrate the project to aws-sdk v3?' });
71
- if (!answer) {
72
- return;
73
- }
74
-
75
- if (updater.checkFunctionAWS()) {
76
- console.log("");
77
- console.warn("WARNING");
78
- console.warn("This project contains function nodes that use aws-sdk v2. These functions can not be automatically migrated to aws-sdk v3.");
79
- console.warn("Manual migration is required. For details, see: https://github.com/aws/aws-sdk-js-v3/blob/main/UPGRADING.md");
80
- console.warn("");
81
- const res = await confirm({ message: 'Do you wish to continue with the project migration to aws-sdk v3?' });
82
- if (!res) {
83
- return;
84
- }
85
- }
86
-
87
- return "v3";
88
- }
89
- }
70
+ if (updates.v3) {
71
+ console.log("");
72
+ console.log(
73
+ "This project uses the deprecated aws-sdk v2. Migration to aws-sdk v3 is available."
74
+ );
75
+ console.log("");
90
76
 
91
- // prompt to upgrade to latest versions and run install
92
- async function promptUpdates(updates) {
93
- let displayPrompt = false;
94
- if (updates.installs && updates.installs.length > 0) {
95
- console.log("");
96
- console.log("The following dependency versions are not installed and may affect your service logic:");
97
- console.log("");
98
- displayTable(updates.installs);
99
- displayPrompt = true;
77
+ const answer = await confirm({
78
+ message: "Do you wish to migrate the project to aws-sdk v3?",
79
+ });
80
+ if (!answer) {
81
+ return;
100
82
  }
101
83
 
102
- if (updates.updates && updates.updates.length > 0) {
103
- console.log("");
104
- console.log("The following dependencies have new versions available:");
105
- console.log("");
106
- displayTable(updates.updates);
107
- console.log("");
108
- displayPrompt = true;
84
+ if (updater.checkFunctionAWS()) {
85
+ console.log("");
86
+ console.warn("WARNING");
87
+ console.warn(
88
+ "This project contains function nodes that use aws-sdk v2. These functions can not be automatically migrated to aws-sdk v3."
89
+ );
90
+ console.warn(
91
+ "Manual migration is required. For details, see: https://github.com/aws/aws-sdk-js-v3/blob/main/UPGRADING.md"
92
+ );
93
+ console.warn("");
94
+ const res = await confirm({
95
+ message:
96
+ "Do you wish to continue with the project migration to aws-sdk v3?",
97
+ });
98
+ if (!res) {
99
+ return;
100
+ }
109
101
  }
110
102
 
111
- if (displayPrompt) {
112
- return await confirm({ initial: true, message: 'Do you wish to upgrade and install latest versions in your project?' });
113
- }
114
- return false;
103
+ return "v3";
104
+ }
105
+ }
106
+
107
+ // prompt to upgrade to latest versions and run install
108
+ async function promptUpdates(updates) {
109
+ let displayPrompt = false;
110
+ if (updates.installs && updates.installs.length > 0) {
111
+ console.log("");
112
+ console.log(
113
+ "The following dependency versions are not installed and may affect your service logic:"
114
+ );
115
+ console.log("");
116
+ displayTable(updates.installs);
117
+ displayPrompt = true;
118
+ }
119
+
120
+ if (updates.updates && updates.updates.length > 0) {
121
+ console.log("");
122
+ console.log("The following dependencies have new versions available:");
123
+ console.log("");
124
+ displayTable(updates.updates);
125
+ console.log("");
126
+ displayPrompt = true;
127
+ }
128
+
129
+ if (displayPrompt) {
130
+ return await confirm({
131
+ initial: true,
132
+ message:
133
+ "Do you wish to upgrade and install latest versions in your project?",
134
+ });
135
+ }
136
+ return false;
115
137
  }
116
138
 
117
139
  /*
@@ -120,40 +142,42 @@ async function promptUpdates(updates) {
120
142
  check if missing node_modules
121
143
  */
122
144
  async function updater(projectDir) {
123
- if (!projectDir) {
124
- console.debug("Project directory not provided, skipping upgrade check");
125
- return;
126
- }
127
- const updater = new Updater(projectDir);
128
- const updates = await updater.checkForUpdates();
129
-
130
- const upd = await promptUpdates(updates);
131
- if (!upd) {
132
- delete updates.updates;
133
- delete updates.installs;
134
- }
135
-
136
- const v3 = await promptV3(updates);
137
- if (!v3) {
138
- delete updates.v3;
139
- }
140
-
141
- await updater.update(updates);
145
+ if (!projectDir) {
146
+ console.debug("Project directory not provided, skipping upgrade check");
147
+ return;
148
+ }
149
+ const updater = new Updater(projectDir);
150
+ const updates = await updater.checkForUpdates();
151
+
152
+ const upd = await promptUpdates(updates);
153
+ if (!upd) {
154
+ delete updates.updates;
155
+ delete updates.installs;
156
+ }
157
+
158
+ const v3 = await promptV3(updates);
159
+ if (!v3) {
160
+ delete updates.v3;
161
+ }
162
+
163
+ await updater.update(updates);
142
164
  }
143
165
 
144
- exports.command = "open [project_directory]"
166
+ exports.command = "open [project_directory]";
145
167
  exports.builder = (yargs) => {
146
- yargs.positional(`project_directory`, {
147
- type: 'string',
148
- describe: 'Path to a valid kumologica project. (Optional)'
149
- })
150
- }
168
+ yargs.positional(`project_directory`, {
169
+ type: "string",
170
+ describe: "Path to a valid kumologica project. (Optional)",
171
+ });
172
+ };
151
173
 
152
- exports.desc = 'Open Kumologica Designer'
174
+ exports.desc = "Open Kumologica Designer";
153
175
 
154
176
  exports.handler = async ({ project_directory }) => {
155
- const projectDir = project_directory? path.resolve(project_directory): undefined;
156
- await updater(projectDir);
157
-
158
- startElectron(projectDir);
159
- }
177
+ const projectDir = project_directory
178
+ ? path.resolve(project_directory)
179
+ : undefined;
180
+ await updater(projectDir);
181
+
182
+ startElectron(projectDir);
183
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kumologica/sdk",
3
- "version": "3.6.0-alpha7",
3
+ "version": "3.6.0-alpha8",
4
4
  "productName": "Kumologica Designer",
5
5
  "copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
6
6
  "author": "Kumologica Pty Ltd <contact@kumologica.com>",
@@ -82,9 +82,9 @@
82
82
  "@aws-sdk/credential-providers": "^3.556.0",
83
83
  "@aws-sdk/lib-dynamodb": "^3.549.0",
84
84
  "@electron/remote": "^2.0.8",
85
- "@kumologica/builder": "3.6.0-alpha7",
86
- "@kumologica/devkit": "3.6.0-alpha7",
87
- "@kumologica/runtime": "3.6.0-alpha7",
85
+ "@kumologica/builder": "3.6.0-alpha8",
86
+ "@kumologica/devkit": "3.6.0-alpha8",
87
+ "@kumologica/runtime": "3.6.0-alpha8",
88
88
  "adm-zip": "0.4.13",
89
89
  "ajv": "8.10.0",
90
90
  "archive-type": "^4.0.0",
@@ -37567,20 +37567,33 @@ RED.notifications = (function() {
37567
37567
  class: "ui-settings",
37568
37568
  }).appendTo("#main-container");
37569
37569
 
37570
+ let dialogContainer = $(
37571
+ `<div id="ui-settings-container" class="ui-settings-conatiner" style="display:flex; height: 100%" </div>`
37572
+ ).appendTo(dialog);
37570
37573
  // Programmatically calculate the height of the ui-settings window
37571
37574
  totalHeightAvailable = $("#main-container").height();
37572
37575
  let offset = 74;
37573
- $("#ui-settings").height(900);
37576
+ $("#ui-settings").height(totalHeightAvailable - 200);
37574
37577
 
37575
- let wrapperDiv = $("<div>", {
37578
+ // Left pannel of settings
37579
+ let optionsLeft = $(`<div id="ui-settings-left"></div>`).appendTo(
37580
+ dialogContainer
37581
+ );
37582
+
37583
+ let rightSide = $(`<div id="ui-settings-right" </div>`).appendTo(
37584
+ dialogContainer
37585
+ );
37586
+
37587
+ let rightSideSettingsBody = $("<div>", {
37576
37588
  class: "ui-settings-body",
37577
- }).appendTo(dialog);
37589
+ }).appendTo(rightSide);
37578
37590
 
37579
- // Left pannel of settings
37580
- let optionsDiv = $(`
37581
- <div id="ui-settings-options">
37582
- </div>
37583
- `).appendTo(wrapperDiv);
37591
+ $(`
37592
+ <div class="editor-tray-toolbar">
37593
+ <button class="ui-button ui-widget ui-state-default ui-corner-all ui-buton-text-only secondary" role="button" aria-disabled="false" id="options-cancel">Cancel</button>
37594
+ <button class="ui-button ui-widget ui-state-default ui-corner-all ui-buton-text-only primary" role="button" aria-disabled="false" id="options-save">Save</button>
37595
+ </div>
37596
+ `).appendTo(rightSide);
37584
37597
 
37585
37598
  // Left pannel of settings
37586
37599
  getScreen().forEach((option) => {
@@ -37590,14 +37603,14 @@ RED.notifications = (function() {
37590
37603
  <span class="settingsOptionLabel">
37591
37604
  ${option.label}
37592
37605
  </span>
37593
- </div>`).appendTo(optionsDiv);
37606
+ </div>`).appendTo(optionsLeft);
37594
37607
  } else {
37595
37608
  $(`
37596
37609
  <div id="${option.id}" class="ui-settings-option ui-settings-option">
37597
37610
  <span class="settingsOptionLabel">
37598
37611
  ${option.label}
37599
37612
  </span>
37600
- </div>`).appendTo(optionsDiv);
37613
+ </div>`).appendTo(optionsLeft);
37601
37614
  }
37602
37615
  });
37603
37616
 
@@ -37605,7 +37618,7 @@ RED.notifications = (function() {
37605
37618
  let optionsBodyDiv = $(`
37606
37619
  <div id="ui-settings-optionsbody">
37607
37620
  </div>
37608
- `).appendTo(wrapperDiv);
37621
+ `).appendTo(rightSideSettingsBody);
37609
37622
 
37610
37623
  getScreen().forEach((option) => {
37611
37624
  $(`
@@ -37619,13 +37632,6 @@ RED.notifications = (function() {
37619
37632
  `).appendTo(optionsBodyDiv);
37620
37633
  });
37621
37634
 
37622
- $(`
37623
- <div class="editor-tray-toolbar">
37624
- <button class="ui-button ui-widget ui-state-default ui-corner-all ui-buton-text-only secondary" role="button" aria-disabled="false" id="options-cancel">Cancel</button>
37625
- <button class="ui-button ui-widget ui-state-default ui-corner-all ui-buton-text-only primary" role="button" aria-disabled="false" id="options-save">Save</button>
37626
- </div>
37627
- `).appendTo(optionsBodyDiv);
37628
-
37629
37635
  // Initialize the options body screen
37630
37636
  getScreen().forEach((option) => {
37631
37637
  // Left click on option
@@ -37827,7 +37833,7 @@ RED.notifications = (function() {
37827
37833
  //console.log(`lineCount: ${cmInstance.lineCount()}`)
37828
37834
  // Set the cursor at the end of existing content
37829
37835
  cmInstance.setCursor(cmInstance.lineCount(), 0);
37830
- let codeMirrorHeight = 650; // totalHeightAvailable - 400;
37836
+ let codeMirrorHeight = totalHeightAvailable - 440;
37831
37837
 
37832
37838
  cmInstance.setSize(null, codeMirrorHeight);
37833
37839
  // cmInstance.refresh();