@kumologica/sdk 3.6.0-beta8 → 3.6.0-beta9
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.
package/cli/commands/open.js
CHANGED
|
@@ -1,117 +1,139 @@
|
|
|
1
|
-
const path = require(
|
|
1
|
+
const path = require("path");
|
|
2
2
|
const { spawn } = require("child_process");
|
|
3
|
-
const { Updater } = require(
|
|
4
|
-
const { confirm } = require(
|
|
3
|
+
const { Updater } = require("@kumologica/builder");
|
|
4
|
+
const { confirm } = require("enquirer");
|
|
5
5
|
|
|
6
|
-
const { logError } = require(
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
if (
|
|
95
|
-
|
|
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 (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
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
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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 =
|
|
174
|
+
exports.desc = "Open Kumologica Designer";
|
|
153
175
|
|
|
154
176
|
exports.handler = async ({ project_directory }) => {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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-
|
|
3
|
+
"version": "3.6.0-beta9",
|
|
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-
|
|
86
|
-
"@kumologica/devkit": "3.6.0-
|
|
87
|
-
"@kumologica/runtime": "3.6.0-
|
|
85
|
+
"@kumologica/builder": "3.6.0-beta9",
|
|
86
|
+
"@kumologica/devkit": "3.6.0-beta9",
|
|
87
|
+
"@kumologica/runtime": "3.6.0-beta9",
|
|
88
88
|
"adm-zip": "0.4.13",
|
|
89
89
|
"ajv": "8.10.0",
|
|
90
90
|
"archive-type": "^4.0.0",
|