diff --git a/build/build.ts b/build/build.ts index 73f29c8..5f77a79 100644 --- a/build/build.ts +++ b/build/build.ts @@ -117,7 +117,6 @@ async function init(): Promise { fs.mkdirSync(OUTPUT_DIR); fs.mkdirSync(OUTPUT_DIR + "/bin"); fs.mkdirSync(OUTPUT_DIR + "/public"); - fs.mkdirSync(OUTPUT_DIR + "/tools"); // Create package.json const packageJson = JSON.parse( @@ -183,40 +182,6 @@ async function generateCss(): Promise { fs.writeFileSync(cssOutPath, cssOut.css); } -async function generateToolsJs(externals: string[]): Promise { - 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 { for (const bin of [ "genieacs-cwmp", @@ -354,7 +319,6 @@ init() copyStatic(), generateCss(), generateIconsSprite(), - generateToolsJs(externals), generateBackendJs(externals), generateFrontendJs(externals), ]) diff --git a/package.json b/package.json index 16b8bf3..53630c1 100644 --- a/package.json +++ b/package.json @@ -16,8 +16,7 @@ "license": "AGPL-3.0", "private": true, "directories": { - "bin": "bin", - "tools": "tools" + "bin": "bin" }, "dependencies": { "espresso-iisojs": "^1.0.3", @@ -77,7 +76,7 @@ }, "scripts": { "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-tsc": "tsc --noEmit", "lint": "npm run lint-eslint && npm run lint-prettier && npm run lint-tsc", diff --git a/tools/dump-data-model.ts b/tools/dump-data-model.ts deleted file mode 100755 index 7166b0b..0000000 --- a/tools/dump-data-model.ts +++ /dev/null @@ -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 . - */ - -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; - }); diff --git a/tsconfig.json b/tsconfig.json index af20786..5a5f8d8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,6 @@ "./lib/**/*", "./ui/**/*", "./test/**/*", - "./build/**/*", - "./tools/*.ts" + "./build/**/*" ] }