Remove dump-data-model tool
The simulator now accepts CSV files downloaded from the UI.
This commit is contained in:
1 parent
f62a42ada4
commit
a692dddd50
4 files changed
+3
-123
No files matched your search
@@ -117,7 +117,6 @@ async function init(): Promise<string[]> {
|
|||||||
fs.mkdirSync(OUTPUT_DIR);
|
fs.mkdirSync(OUTPUT_DIR);
|
||||||
fs.mkdirSync(OUTPUT_DIR + "/bin");
|
fs.mkdirSync(OUTPUT_DIR + "/bin");
|
||||||
fs.mkdirSync(OUTPUT_DIR + "/public");
|
fs.mkdirSync(OUTPUT_DIR + "/public");
|
||||||
fs.mkdirSync(OUTPUT_DIR + "/tools");
|
|
||||||
|
|
||||||
// Create package.json
|
// Create package.json
|
||||||
const packageJson = JSON.parse(
|
const packageJson = JSON.parse(
|
||||||
@@ -183,40 +182,6 @@ async function generateCss(): Promise<void> {
|
|||||||
fs.writeFileSync(cssOutPath, cssOut.css);
|
fs.writeFileSync(cssOutPath, cssOut.css);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateToolsJs(externals: string[]): Promise<void> {
|
|
||||||
for (const bin of ["dump-data-model"]) {
|
|
||||||
const inputFile = path.resolve(INPUT_DIR, `tools/${bin}.ts`);
|
|
||||||
const outputFile = path.resolve(OUTPUT_DIR, `tools/${bin}`);
|
|
||||||
const bundle = await rollup({
|
|
||||||
input: inputFile,
|
|
||||||
external: [...builtins, ...externals],
|
|
||||||
acorn: {
|
|
||||||
allowHashBang: true,
|
|
||||||
},
|
|
||||||
plugins: [
|
|
||||||
typescript({
|
|
||||||
tsconfig: "./tsconfig.json",
|
|
||||||
include: [`tools/${bin}.ts`, "lib/**/*.ts"],
|
|
||||||
}),
|
|
||||||
MODE === "production" ? terser() : null,
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
await bundle.write({
|
|
||||||
format: "cjs",
|
|
||||||
preferConst: true,
|
|
||||||
sourcemap: "inline",
|
|
||||||
sourcemapExcludeSources: true,
|
|
||||||
banner: "#!/usr/bin/env node",
|
|
||||||
file: outputFile,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Mark as executable
|
|
||||||
const mode = fs.statSync(outputFile).mode;
|
|
||||||
fs.chmodSync(outputFile, mode | 73);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function generateBackendJs(externals: string[]): Promise<void> {
|
async function generateBackendJs(externals: string[]): Promise<void> {
|
||||||
for (const bin of [
|
for (const bin of [
|
||||||
"genieacs-cwmp",
|
"genieacs-cwmp",
|
||||||
@@ -354,7 +319,6 @@ init()
|
|||||||
copyStatic(),
|
copyStatic(),
|
||||||
generateCss(),
|
generateCss(),
|
||||||
generateIconsSprite(),
|
generateIconsSprite(),
|
||||||
generateToolsJs(externals),
|
|
||||||
generateBackendJs(externals),
|
generateBackendJs(externals),
|
||||||
generateFrontendJs(externals),
|
generateFrontendJs(externals),
|
||||||
])
|
])
|
||||||
|
|||||||
+2
-3
@@ -16,8 +16,7 @@
|
|||||||
"license": "AGPL-3.0",
|
"license": "AGPL-3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"directories": {
|
"directories": {
|
||||||
"bin": "bin",
|
"bin": "bin"
|
||||||
"tools": "tools"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"espresso-iisojs": "^1.0.3",
|
"espresso-iisojs": "^1.0.3",
|
||||||
@@ -77,7 +76,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "ava --verbose --color",
|
"test": "ava --verbose --color",
|
||||||
"lint-eslint": "eslint --fix \"bin/*.ts\" \"lib/**/*.ts\" \"ui/**/*.ts\" \"test/**/*.ts\" \"build/**/*.ts\" \"tools/*.ts\"",
|
"lint-eslint": "eslint --fix \"bin/*.ts\" \"lib/**/*.ts\" \"ui/**/*.ts\" \"test/**/*.ts\" \"build/**/*.ts\"",
|
||||||
"lint-prettier": "prettier --prose-wrap always --write .",
|
"lint-prettier": "prettier --prose-wrap always --write .",
|
||||||
"lint-tsc": "tsc --noEmit",
|
"lint-tsc": "tsc --noEmit",
|
||||||
"lint": "npm run lint-eslint && npm run lint-prettier && npm run lint-tsc",
|
"lint": "npm run lint-eslint && npm run lint-prettier && npm run lint-tsc",
|
||||||
|
|||||||
@@ -1,82 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2013-2019 GenieACS Inc.
|
|
||||||
*
|
|
||||||
* This file is part of GenieACS.
|
|
||||||
*
|
|
||||||
* GenieACS is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as
|
|
||||||
* published by the Free Software Foundation, either version 3 of the
|
|
||||||
* License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* GenieACS is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with GenieACS. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import * as fs from "fs";
|
|
||||||
import * as path from "path";
|
|
||||||
import { connect, devicesCollection } from "../lib/db";
|
|
||||||
|
|
||||||
const outputFilename = path.resolve(`data_model_${process.argv[2]}.json`);
|
|
||||||
process.chdir(path.resolve(path.dirname(fs.realpathSync(__filename)), ".."));
|
|
||||||
|
|
||||||
const dataModel = {};
|
|
||||||
|
|
||||||
function recursive(object, p = ""): void {
|
|
||||||
for (const key in object) {
|
|
||||||
if (key[0] === "_" || !object[key]) continue;
|
|
||||||
|
|
||||||
const isObject = object[key]["_object"];
|
|
||||||
const isValue = "_value" in object[key];
|
|
||||||
|
|
||||||
if ((isObject && isValue) || (!isObject && !isValue))
|
|
||||||
throw new Error("Unexpected object");
|
|
||||||
|
|
||||||
if (isValue) {
|
|
||||||
let value = object[key]["_value"];
|
|
||||||
if (typeof value === "boolean") value = +value;
|
|
||||||
|
|
||||||
const values = [object[key]["_writable"] || false, value.toString()];
|
|
||||||
if (object[key]["_type"]) values.push(object[key]["_type"]);
|
|
||||||
|
|
||||||
dataModel[`${p}${key}`] = values;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isObject) {
|
|
||||||
const values = [object[key]["_writable"] || false];
|
|
||||||
dataModel[`${p}${key}.`] = values;
|
|
||||||
recursive(object[key], `${p}${key}.`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connect()
|
|
||||||
.then(() => {
|
|
||||||
devicesCollection.findOne(
|
|
||||||
{
|
|
||||||
_id: process.argv[2],
|
|
||||||
},
|
|
||||||
{},
|
|
||||||
(err, device) => {
|
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
if (!device) throw new Error("Device not found");
|
|
||||||
|
|
||||||
recursive(device);
|
|
||||||
|
|
||||||
fs.writeFile(outputFilename, JSON.stringify(dataModel, null, 2), () => {
|
|
||||||
if (err) throw err;
|
|
||||||
|
|
||||||
process.stdout.write(`${outputFilename} saved\n`);
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
);
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
throw err;
|
|
||||||
});
|
|
||||||
+1
-2
@@ -16,7 +16,6 @@
|
|||||||
"./lib/**/*",
|
"./lib/**/*",
|
||||||
"./ui/**/*",
|
"./ui/**/*",
|
||||||
"./test/**/*",
|
"./test/**/*",
|
||||||
"./build/**/*",
|
"./build/**/*"
|
||||||
"./tools/*.ts"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user