Add merger capability to make grabbing projects easier

pull/11/head
Dave Conway-Jones 2019-11-18 21:52:11 +00:00
rodzic 1ec358a110
commit 38eaac77e6
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 302A6725C594817F
8 zmienionych plików z 189 dodań i 7 usunięć

Wyświetl plik

@ -45,6 +45,12 @@ then retry the command.
Runtimes are created in the `dist` directory under the `electron-node-red` project. Runtimes are created in the `dist` directory under the `electron-node-red` project.
The `merger.js` utility can be pointed at an existing Node-RED projects directory and it will try to copy over and package up the relevant files into this project ready to install and build - so the simple flow would be
```
./merger.js {path to my Node-RED project directory} && yarn && yarn start
```
### Building for other platforms ### Building for other platforms
Generally you can just add the required parameter to the command Generally you can just add the required parameter to the command

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -0,0 +1 @@
{"$":"8dbcfcd6d9f25932aa00994065774d5ctxk="}

Wyświetl plik

@ -0,0 +1,17 @@
{
"name": "electron_node_red",
"description": "Electron Node-RED application starter kit for development",
"version": "1.0.2",
"dependencies": {
"node-red-contrib-play-audio": "*",
"node-red-contrib-web-worldmap": "*",
"node-red-dashboard": "*",
"node-red-node-base64": "*",
"node-red-node-geofence": "*",
"node-red-node-random": "*",
"node-red-node-smooth": "*"
},
"scripts": {
"start": "node node_modules/node-red/red.js -u . electronflow.json"
}
}

Wyświetl plik

@ -50,7 +50,7 @@ red_app.use("/",express.static("web"));
// Create a server // Create a server
var server = http.createServer(red_app); var server = http.createServer(red_app);
// Setup user directory and flowfile // Setup user directory and flowfile (if editable)
var userdir = __dirname; var userdir = __dirname;
if (editable) { if (editable) {
// if running as raw electron use the current directory (mainly for dev) // if running as raw electron use the current directory (mainly for dev)

73
merger.js 100755
Wyświetl plik

@ -0,0 +1,73 @@
#!/usr/bin/env node
const fs = require("fs");
const path = require('path');
const pkg = require("./package-template.json");
let arg = "./example";
let flowfile = null;
let dn = arg;
let app;
if (process.argv.length === 3 ) {
arg = process.argv[2];
let dn = path.dirname(arg);
if (path.extname(arg) === ".json") {
if (path.basename(arg, '.json') !== "package") {
flowfile = path.basename(arg);
app = require(path.join(dn, "package.json"));
}
else {
app = require(arg);
}
}
else {
app = require(path.join(arg, "package.json"));
dn = arg;
}
}
else {
app = require(arg+"/package.json");
}
const merge = {
...app.dependencies,
...pkg.dependencies
};
pkg.dependencies = merge;
// Try to get flow file name
if (app.hasOwnProperty("node-red") && app["node-red"].hasOwnProperty("settings") && app["node-red"].settings.hasOwnProperty("flowFile") ) {
pkg.NRelectron.flowFile = app["node-red"].settings.flowFile;
}
else if (app.hasOwnProperty("scripts") && app.scripts.hasOwnProperty("start")) {
pkg.NRelectron.flowFile = app.scripts.start.split(' ').pop();
}
else {
pkg.NRelectron.flowFile = flowfile || "flow.json";
}
if (merge.hasOwnProperty("node-red-dashboard")) {
pkg.NRelectron.start = "dashboard";
}
pkg.name = app.name;
pkg.version = app.version;
pkg.description = app.description;
// console.log(pkg);
fs.copyFile(path.join(arg, pkg.NRelectron.flowFile), path.join("./", pkg.NRelectron.flowFile), (err) => {
if (err) { console.log("Failed to copy flows file - "+path.join(arg, pkg.NRelectron.flowFile)); }
else { console.log('Copied flows file - '+pkg.NRelectron.flowFile); }
});
const creds = path.basename(pkg.NRelectron.flowFile,".json")+"_cred.json";
fs.copyFile(path.join(arg, creds), path.join("./", creds), (err) => {
if (err) { console.log("Failed to copy creds file - "+path.join(arg, creds)); }
else { console.log('Copied creds file - '+creds); }
});
fs.writeFile("./package.json", JSON.stringify(pkg, null, 4), 'utf8', function (err) {
if (err) { console.log("Failed to re-write package.json file."); }
else {
console.log("Merged package.json.");
}
});

Wyświetl plik

@ -0,0 +1,84 @@
{
"name": "electron_node_red",
"version": "1.0.2",
"description": "Electron Node-RED application starter kit for development",
"main": "main.js",
"scripts": {
"pack": "electron-builder --dir",
"dist": "electron-builder",
"release": "electron-builder build -p always",
"postinstall": "electron-builder install-app-deps",
"start": "electron main.js",
"test": "echo \" Warning: no test specified \""
},
"repository": {
"type": "git",
"url": "git+https://github.com/dceejay/electron-node-red.git"
},
"dependencies": {
"electron-is-dev": "*",
"express": "^4.17.1",
"node-red": "1.0.2"
},
"keywords": [
"electron",
"quick start",
"node-red"
],
"author": {
"name": "Dave Conway-Jones",
"email": "dceejay@gmail.com"
},
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/dceejay/electron-node-red/issues"
},
"homepage": "https://github.com/dceejay/electron-node-red#readme",
"devDependencies": {
"electron": "^7.1.1",
"electron-builder": "^22.1.0"
},
"NRelectron": {
"productName": "Node-RED Electron",
"editable": true,
"allowLoadSave": false,
"showMap": false,
"kioskMode": false,
"flowFile": "electronflow.json",
"start": "editor"
},
"build": {
"appId": "com.electron.node-red",
"productName": "Node-RED Electron",
"copyright": "Copyright © 2019 D.Conway-Jones",
"mac": {
"category": "public.app-category.developer-tools",
"target": "dmg"
},
"linux": {
"target": [
"rpm",
"apk",
{
"target": "deb",
"arch": [
"x64",
"armv7l"
]
}
],
"synopsis": "Node-RED Low Code development",
"category": "Development"
},
"win": {
"target": [
{
"target": "msi",
"arch": [
"x64"
]
}
]
}
}
}

Wyświetl plik

@ -16,16 +16,16 @@
"url": "git+https://github.com/dceejay/electron-node-red.git" "url": "git+https://github.com/dceejay/electron-node-red.git"
}, },
"dependencies": { "dependencies": {
"electron-is-dev": "*",
"express": "^4.17.1",
"node-red": "1.0.2",
"node-red-contrib-play-audio": "*", "node-red-contrib-play-audio": "*",
"node-red-contrib-web-worldmap": "*", "node-red-contrib-web-worldmap": "*",
"node-red-dashboard": "*", "node-red-dashboard": "*",
"node-red-node-base64": "*", "node-red-node-base64": "*",
"node-red-node-geofence": "*", "node-red-node-geofence": "*",
"node-red-node-random": "*", "node-red-node-random": "*",
"node-red-node-smooth": "*" "node-red-node-smooth": "*",
"electron-is-dev": "*",
"express": "^4.17.1",
"node-red": "1.0.2"
}, },
"keywords": [ "keywords": [
"electron", "electron",
@ -50,7 +50,7 @@
"editable": true, "editable": true,
"allowLoadSave": false, "allowLoadSave": false,
"showMap": false, "showMap": false,
"kioskMode": false, "kioskMode": false,
"flowFile": "electronflow.json", "flowFile": "electronflow.json",
"start": "dashboard" "start": "dashboard"
}, },
@ -88,4 +88,4 @@
] ]
} }
} }
} }