@optimajet/workflow-designer 12.5.1 → 13.0.0
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/bin/index.js +65 -0
- package/bin/template/index.html +18 -0
- package/bin/template/index.js +20 -0
- package/dist/workflowdesignerfull.min.js +1 -1
- package/package.json +10 -2
package/bin/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const {exec} = require('child_process');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const os = require('os');
|
|
6
|
+
const fs = require('fs')
|
|
7
|
+
const util = require('util');
|
|
8
|
+
const fsPromises = require('node:fs/promises');
|
|
9
|
+
const crypto = require('node:crypto')
|
|
10
|
+
|
|
11
|
+
function runCommand(command) {
|
|
12
|
+
return new Promise((resolve, reject) => {
|
|
13
|
+
exec(command, (error) => {
|
|
14
|
+
if (error) {
|
|
15
|
+
reject(error);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
resolve();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async function passSettings(file, url, schemeCode) {
|
|
24
|
+
const readFile = util.promisify(fs.readFile);
|
|
25
|
+
const writeFile = util.promisify(fs.writeFile);
|
|
26
|
+
|
|
27
|
+
const data = await readFile(file);
|
|
28
|
+
const result = data.toString()
|
|
29
|
+
.replace(/URL_PLACEHOLDER/g, url)
|
|
30
|
+
.replace(/SCHEME_CODE_PLACEHOLDER/g, schemeCode);
|
|
31
|
+
await writeFile(file, result);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function createTempFolder(sourcePath) {
|
|
35
|
+
const args = process.argv.slice(2).join('|');
|
|
36
|
+
const digest = crypto.createHash('sha256')
|
|
37
|
+
.update(args)
|
|
38
|
+
.digest('hex');
|
|
39
|
+
|
|
40
|
+
const tempPath = path.join(sourcePath, '..', `workflow-designer-${digest}`);
|
|
41
|
+
await fsPromises.mkdir(tempPath, {recursive: true});
|
|
42
|
+
await fsPromises.copyFile(path.resolve(sourcePath, 'index.js'), path.resolve(tempPath, 'index.js'));
|
|
43
|
+
await fsPromises.copyFile(path.resolve(sourcePath, 'index.html'), path.resolve(tempPath, 'index.html'));
|
|
44
|
+
return tempPath
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function main() {
|
|
48
|
+
const args = process.argv.slice(2);
|
|
49
|
+
|
|
50
|
+
const templateDirectory = path.resolve(__dirname, '..', 'bin', 'template');
|
|
51
|
+
const tempFolderName = await createTempFolder(templateDirectory);
|
|
52
|
+
|
|
53
|
+
const jsFile = path.resolve(tempFolderName, 'index.js');
|
|
54
|
+
const htmlFile = path.resolve(tempFolderName, 'index.html');
|
|
55
|
+
|
|
56
|
+
const designerUrl = args[0] ?? 'https://demo.workflowengine.io/Designer/API';
|
|
57
|
+
const schemeCode = args[1] ?? 'SimpleWF';
|
|
58
|
+
await passSettings(jsFile, designerUrl, schemeCode);
|
|
59
|
+
|
|
60
|
+
const platform = os.platform();
|
|
61
|
+
const command = platform === 'win32' ? `start ${htmlFile}` : `open ${htmlFile}`;
|
|
62
|
+
await runCommand(command);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
main().catch(console.error);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>WorkflowEngine Designer</title>
|
|
6
|
+
<link rel="stylesheet" href="../../dist/workflowdesigner.min.css">
|
|
7
|
+
</head>
|
|
8
|
+
<body style="margin: 0">
|
|
9
|
+
<div id="root"></div>
|
|
10
|
+
|
|
11
|
+
<script
|
|
12
|
+
src="https://code.jquery.com/jquery-3.7.1.min.js"
|
|
13
|
+
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
|
|
14
|
+
crossorigin="anonymous"></script>
|
|
15
|
+
<script src="../../dist/workflowdesignerfull.min.js"></script>
|
|
16
|
+
<script src="./index.js"></script>
|
|
17
|
+
</body>
|
|
18
|
+
</html>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var wfdesigner = new WorkflowDesigner({
|
|
2
|
+
apiurl: 'URL_PLACEHOLDER',
|
|
3
|
+
name: 'wfe',
|
|
4
|
+
language: 'en',
|
|
5
|
+
renderTo: 'root',
|
|
6
|
+
graphwidth: window.innerWidth,
|
|
7
|
+
graphheight: window.innerHeight,
|
|
8
|
+
showSaveButton: true,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const data = {
|
|
12
|
+
schemecode: 'SCHEME_CODE_PLACEHOLDER',
|
|
13
|
+
processid: ''
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
if (wfdesigner.exists(data)) {
|
|
17
|
+
wfdesigner.load(data);
|
|
18
|
+
} else {
|
|
19
|
+
wfdesigner.create(data.schemecode);
|
|
20
|
+
}
|