@kumologica/sdk 3.2.2 → 3.3.0-beta2

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.
@@ -0,0 +1,73 @@
1
+ const path = require('path');
2
+ const _ = require('lodash');
3
+ const { prompt, Select } = require('enquirer');
4
+ const { logNotice, logError } = require('../../utils/logger');
5
+
6
+ const { codegen } = require('@kumologica/devkit')
7
+
8
+ /**
9
+ * ensureNodeNamingConvention - will generate a tuple with first part being the node nade (capitalized), and second with the
10
+ * fully qualified name (kumologica-contrib-<name>)
11
+ * @param {} nodeName
12
+ * @returns {[string, string]} - A tuple with two strings: simpleNodeName and fqNodeName.
13
+ */
14
+ function ensureNodeNamingConvention(nodeName){
15
+ if (!nodeName){
16
+ return ["Default", "kumologica-contrib-default"];
17
+ }
18
+ if (nodeName.includes('kumologica-contrib-')){
19
+ const [, simpleName] = nodeName.split('kumologica-contrib-');
20
+ return [_.capitalize(simpleName), nodeName]; // return [NodeName, kumologica-contrib-nodeName]
21
+ }
22
+ return [_.capitalize(nodeName), `kumologica-contrib-${nodeName}`];
23
+
24
+ }
25
+
26
+ async function createNodeIteratively(){
27
+ // Name name
28
+ const nodeNameResponse = await prompt({
29
+ type: 'input',
30
+ name: 'name',
31
+ message: 'Enter the name for the node. (It will be prefixed with "kumologica-contrib-<name>")'
32
+ });
33
+
34
+ const [simpleNodeName, fqNodeName] = ensureNodeNamingConvention(nodeNameResponse.name);
35
+
36
+ // Node Category
37
+ const answerCategory = await prompt({
38
+ type: 'input',
39
+ name: 'category',
40
+ message: 'Enter the name for the category of the node. (Default: "misc")'
41
+ });
42
+
43
+ const nodeCategory = answerCategory.category || 'misc';
44
+
45
+ // Base Path
46
+ const answerDirectory = await prompt({
47
+ type: 'input',
48
+ name: 'directory',
49
+ message: 'Enter the path where the project will be created. (Default: current directory)'
50
+ });
51
+ let basePath = answerDirectory.directory || process.cwd();
52
+
53
+ // Final Project Path
54
+ let projectDir = path.join(basePath, fqNodeName);
55
+
56
+ try{
57
+ codegen.generateBoilerplateCodeContribNode({
58
+ projectDir,
59
+ simpleNodeName,
60
+ fqNodeName,
61
+ nodeCategory
62
+ });
63
+
64
+ logNotice(`Contrib node project created in: "${projectDir}"`)
65
+ } catch (err){
66
+ throw err;
67
+ }
68
+ }
69
+
70
+
71
+ module.exports = {
72
+ createNodeIteratively
73
+ }
@@ -0,0 +1,5 @@
1
+ const { createNodeIteratively } = require('./create-node-iteratively');
2
+
3
+ module.exports = {
4
+ createNodeIteratively
5
+ }
@@ -0,0 +1,14 @@
1
+ const { logError } = require('../utils/logger');
2
+ const { createNodeIteratively } = require('./create-node-commands');
3
+
4
+ exports.command = 'create-node'
5
+ exports.desc = 'Create the boilerplate code for a new contrib node.'
6
+
7
+ exports.handler = async () => {
8
+ try{
9
+ await createNodeIteratively();
10
+ }catch(err){
11
+ logError(`Error found while creating kumologica node project due to: ${err.message}`)
12
+ throw err;
13
+ }
14
+ }
@@ -1,3 +1,7 @@
1
+ // kl doc html --serve
2
+ const express = require('express');
3
+ const chalk = require('chalk');
4
+
1
5
  exports.command = 'html';
2
6
  exports.desc = `Generates html documentation of kumologica flow.`;
3
7
 
@@ -20,7 +24,13 @@ exports.builder = {
20
24
  alias: 'c',
21
25
  default: 'docs',
22
26
  nargs: 1
23
- }
27
+ },
28
+ "serve": {
29
+ describe: "\nServe the resulting documentation via an HTTP server (port: 3000).",
30
+ type: 'boolean',
31
+ alias: 's',
32
+ default: false
33
+ }
24
34
  }
25
35
 
26
36
  function validate(argv) {
@@ -34,27 +44,38 @@ function validate(argv) {
34
44
  function display(argv) {
35
45
  console.log('Parameters:');
36
46
  console.log(' documentation-directory: %s', argv["documentation-directory"]||'');
37
- console.log(' project-directory: %s', argv["project-directory"]||'');
38
- console.log(' flow-file-name: %s', argv["flow-file-name"]||'');
47
+ console.log(' project-directory: %s', argv["project-directory"]||`${__dirname}`);
48
+ console.log(' flow-file-name: %s', argv["flow-file-name"]||'(auto-search)');
49
+ console.log(' serve: %s', argv["serve"]||'false');
39
50
  }
40
51
 
41
52
  exports.handler = async function (argv) {
42
- console.log('\nGenerating html documentation\n');
43
53
  display(argv);
44
54
  validate(argv);
45
55
 
46
- const chalk = require('chalk');
47
-
48
56
  try {
49
57
  const { doc } = require('@kumologica/builder');
50
58
  const docsDirectory = doc("html", argv);
51
- console.log(chalk.greenBright('Documentation generated successfully:'));
52
- console.log(chalk.greenBright(docsDirectory));
53
-
54
- process.exit(0);
59
+ console.log(chalk.greenBright(`Documentation generated successfully: ${docsDirectory}`));
60
+ if (argv.serve){
61
+ serve(docsDirectory);
62
+ }else{
63
+ process.exit(0);
64
+ }
65
+
66
+
55
67
  } catch (e) {
56
68
 
57
69
  console.log(`${chalk.redBright(e.message)}`);
58
70
  process.exit(1);
59
71
  }
72
+ }
73
+
74
+ function serve(websiteDir) {
75
+ const app = express();
76
+ const port = 3000;
77
+ app.use(express.static(websiteDir));
78
+ app.listen(port, () => {
79
+ console.log(chalk.yellowBright(`Documentation available at http://localhost:${port}`));
80
+ })
60
81
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "productName": "Kumologica Designer",
4
4
  "copyright": "Copyright 2020 Kumologica Pty Ltd, All Rights Reserved.",
5
5
  "author": "Kumologica Pty Ltd <contact@kumologica.com>",
6
- "version": "3.2.2",
6
+ "version": "3.3.0-beta2",
7
7
  "description": "Kumologica Designer, harnessing Serverless for your cloud integration needs",
8
8
  "main": "src/app/main.js",
9
9
  "files": [
@@ -64,9 +64,9 @@
64
64
  "license": "Proprietary",
65
65
  "dependencies": {
66
66
  "@electron/remote": "^2.0.8",
67
- "@kumologica/builder": "3.2.2",
68
- "@kumologica/devkit": "3.2.2",
69
- "@kumologica/runtime": "3.2.2",
67
+ "@kumologica/builder": "3.3.0-beta2",
68
+ "@kumologica/devkit": "3.3.0-beta2",
69
+ "@kumologica/runtime": "3.3.0-beta2",
70
70
  "adm-zip": "0.4.13",
71
71
  "ajv": "8.10.0",
72
72
  "archive-type": "^4.0.0",
package/cli/.DS_Store DELETED
Binary file
Binary file