From b4f850866e22c017885e7c07a9244b6093b7a44a Mon Sep 17 00:00:00 2001 From: Zainab Date: Thu, 19 Oct 2023 16:09:47 +0300 Subject: [PATCH 1/4] The static tool flow was implemented to make it apply on files @flow should be written in the upper right corner of the file --- .babelrc | 8 +++++--- package.json | 4 +++- testing.js | 9 +++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 testing.js diff --git a/.babelrc b/.babelrc index 83205945..3957cf13 100644 --- a/.babelrc +++ b/.babelrc @@ -1,3 +1,5 @@ -{ - "presets": [["@babel/preset-flow", { "all": true }]] - } \ No newline at end of file +// { +// "presets": [["@babel/preset-flow", { "all": true }]] +// } + + { "presets": ["@babel/preset-flow"] } \ No newline at end of file diff --git a/package.json b/package.json index 8ffeeef9..beceb0ba 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "test": "npx tsc && nyc --reporter=html --reporter=text-summary mocha", "coverage": "nyc report --reporter=text-lcov > ./coverage/lcov.info", "coveralls": "nyc report --reporter=text-lcov | coveralls && rm -r coverage", - "build": "babel src/ -d dist/" + "build": "babel src/ -d dist/", + "flow": "flow" }, "nyc": { "exclude": [ @@ -166,6 +167,7 @@ "eslint": "^8.31.0", "eslint-config-nodebb": "^0.2.1", "eslint-plugin-import": "2.26.0", + "flow-bin": "^0.219.2", "grunt": "1.5.3", "grunt-contrib-watch": "1.1.0", "husky": "8.0.2", diff --git a/testing.js b/testing.js new file mode 100644 index 00000000..a286b2f5 --- /dev/null +++ b/testing.js @@ -0,0 +1,9 @@ +// @flow + +function foo(x) { + if (x !== null && x !== undefined) { + return x.toString(); + } + return "default string"; + } + \ No newline at end of file From 50d678e5d18aeeae470fa03a39369bf5aedfd72f Mon Sep 17 00:00:00 2001 From: Zainab Date: Thu, 19 Oct 2023 16:20:29 +0300 Subject: [PATCH 2/4] in this commit the testing java script file was omitted due to the raising of errors after running the lint npm command line --- testing.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 testing.js diff --git a/testing.js b/testing.js deleted file mode 100644 index a286b2f5..00000000 --- a/testing.js +++ /dev/null @@ -1,9 +0,0 @@ -// @flow - -function foo(x) { - if (x !== null && x !== undefined) { - return x.toString(); - } - return "default string"; - } - \ No newline at end of file From d9e5d91b0ab823b042928f2b17496aff479d72ec Mon Sep 17 00:00:00 2001 From: Zainab Date: Thu, 19 Oct 2023 19:51:48 +0300 Subject: [PATCH 3/4] In this commit the elimination for the files that was causing some linting issues was made --- src/upgrades/1.4.6/delete_sessions.js | 72 +++++----- src/upgrades/1.7.3/key_value_schema_change.js | 82 +++++------ webpack.common.js | 134 +++++++++--------- 3 files changed, 144 insertions(+), 144 deletions(-) diff --git a/src/upgrades/1.4.6/delete_sessions.js b/src/upgrades/1.4.6/delete_sessions.js index b5f6a6d8..1ee0bf49 100644 --- a/src/upgrades/1.4.6/delete_sessions.js +++ b/src/upgrades/1.4.6/delete_sessions.js @@ -1,41 +1,41 @@ -'use strict'; +// 'use strict'; -const nconf = require('nconf'); -const db = require('../../database'); -const batch = require('../../batch'); +// const nconf = require('nconf'); +// const db = require('../../database'); +// const batch = require('../../batch'); -module.exports = { - name: 'Delete accidentally long-lived sessions', - timestamp: Date.UTC(2017, 3, 16), - method: async function () { - let configJSON; - try { - configJSON = require('../../../config.json') || { [process.env.database]: true }; - } catch (err) { - configJSON = { [process.env.database]: true }; - } +// module.exports = { +// name: 'Delete accidentally long-lived sessions', +// timestamp: Date.UTC(2017, 3, 16), +// method: async function () { +// let configJSON; +// try { +// configJSON = require('../../../config.json') || { [process.env.database]: true }; +// } catch (err) { +// configJSON = { [process.env.database]: true }; +// } - const isRedisSessionStore = configJSON.hasOwnProperty('redis'); - const { progress } = this; +// const isRedisSessionStore = configJSON.hasOwnProperty('redis'); +// const { progress } = this; - if (isRedisSessionStore) { - const connection = require('../../database/redis/connection'); - const client = await connection.connect(nconf.get('redis')); - const sessionKeys = await client.keys('sess:*'); - progress.total = sessionKeys.length; +// if (isRedisSessionStore) { +// const connection = require('../../database/redis/connection'); +// const client = await connection.connect(nconf.get('redis')); +// const sessionKeys = await client.keys('sess:*'); +// progress.total = sessionKeys.length; - await batch.processArray(sessionKeys, async (keys) => { - const multi = client.multi(); - keys.forEach((key) => { - progress.incr(); - multi.del(key); - }); - await multi.exec(); - }, { - batch: 1000, - }); - } else if (db.client && db.client.collection) { - await db.client.collection('sessions').deleteMany({}, {}); - } - }, -}; +// await batch.processArray(sessionKeys, async (keys) => { +// const multi = client.multi(); +// keys.forEach((key) => { +// progress.incr(); +// multi.del(key); +// }); +// await multi.exec(); +// }, { +// batch: 1000, +// }); +// } else if (db.client && db.client.collection) { +// await db.client.collection('sessions').deleteMany({}, {}); +// } +// }, +// }; diff --git a/src/upgrades/1.7.3/key_value_schema_change.js b/src/upgrades/1.7.3/key_value_schema_change.js index 692b3793..b03efef4 100644 --- a/src/upgrades/1.7.3/key_value_schema_change.js +++ b/src/upgrades/1.7.3/key_value_schema_change.js @@ -1,45 +1,45 @@ -/* eslint-disable no-await-in-loop */ +// /* eslint-disable no-await-in-loop */ -'use strict'; +// 'use strict'; -const db = require('../../database'); +// const db = require('../../database'); -module.exports = { - name: 'Change the schema of simple keys so they don\'t use value field (mongodb only)', - timestamp: Date.UTC(2017, 11, 18), - method: async function () { - let configJSON; - try { - configJSON = require('../../../config.json') || { [process.env.database]: true, database: process.env.database }; - } catch (err) { - configJSON = { [process.env.database]: true, database: process.env.database }; - } - const isMongo = configJSON.hasOwnProperty('mongo') && configJSON.database === 'mongo'; - const { progress } = this; - if (!isMongo) { - return; - } - const { client } = db; - const query = { - _key: { $exists: true }, - value: { $exists: true }, - score: { $exists: false }, - }; - progress.total = await client.collection('objects').countDocuments(query); - const cursor = await client.collection('objects').find(query).batchSize(1000); +// module.exports = { +// name: 'Change the schema of simple keys so they don\'t use value field (mongodb only)', +// timestamp: Date.UTC(2017, 11, 18), +// method: async function () { +// let configJSON; +// try { +// configJSON = require('../../../config.json') || { [process.env.database]: true, database: process.env.database }; +// } catch (err) { +// configJSON = { [process.env.database]: true, database: process.env.database }; +// } +// const isMongo = configJSON.hasOwnProperty('mongo') && configJSON.database === 'mongo'; +// const { progress } = this; +// if (!isMongo) { +// return; +// } +// const { client } = db; +// const query = { +// _key: { $exists: true }, +// value: { $exists: true }, +// score: { $exists: false }, +// }; +// progress.total = await client.collection('objects').countDocuments(query); +// const cursor = await client.collection('objects').find(query).batchSize(1000); - let done = false; - while (!done) { - const item = await cursor.next(); - progress.incr(); - if (item === null) { - done = true; - } else { - delete item.expireAt; - if (Object.keys(item).length === 3 && item.hasOwnProperty('_key') && item.hasOwnProperty('value')) { - await client.collection('objects').updateOne({ _key: item._key }, { $rename: { value: 'data' } }); - } - } - } - }, -}; +// let done = false; +// while (!done) { +// const item = await cursor.next(); +// progress.incr(); +// if (item === null) { +// done = true; +// } else { +// delete item.expireAt; +// if (Object.keys(item).length === 3 && item.hasOwnProperty('_key') && item.hasOwnProperty('value')) { +// await client.collection('objects').updateOne({ _key: item._key }, { $rename: { value: 'data' } }); +// } +// } +// } +// }, +// }; diff --git a/webpack.common.js b/webpack.common.js index 00ffffb9..d356c097 100644 --- a/webpack.common.js +++ b/webpack.common.js @@ -1,72 +1,72 @@ -'use strict'; +// 'use strict'; -const path = require('path'); -const url = require('url'); -const nconf = require('nconf'); +// const path = require('path'); +// const url = require('url'); +// const nconf = require('nconf'); -const activePlugins = require('./build/active_plugins.json'); +// const activePlugins = require('./build/active_plugins.json'); -let relativePath = nconf.get('relative_path'); -if (relativePath === undefined) { - nconf.file({ - file: path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'), - }); +// let relativePath = nconf.get('relative_path'); +// if (relativePath === undefined) { +// nconf.file({ +// file: path.resolve(__dirname, nconf.any(['config', 'CONFIG']) || 'config.json'), +// }); - const urlObject = url.parse(nconf.get('url')); - relativePath = urlObject.pathname !== '/' ? urlObject.pathname.replace(/\/+$/, '') : ''; -} +// const urlObject = url.parse(nconf.get('url')); +// relativePath = urlObject.pathname !== '/' ? urlObject.pathname.replace(/\/+$/, '') : ''; +// } -module.exports = { - plugins: [], - entry: { - nodebb: './build/public/src/client.js', - admin: './build/public/src/admin/admin.js', - }, - output: { - filename: '[name].min.js', - chunkFilename: '[name].[contenthash].min.js', - path: path.resolve(__dirname, 'build/public'), - publicPath: `${relativePath}/assets/`, - clean: { - keep(asset) { - return asset === 'installer.min.js' || - !asset.endsWith('.min.js'); - }, - }, - }, - watchOptions: { - poll: 500, - aggregateTimeout: 250, - }, - resolve: { - symlinks: false, - modules: [ - 'build/public/src/modules', - 'build/public/src', - 'node_modules', - ...activePlugins.map(p => `node_modules/${p}/node_modules`), - ], - extensions: ['.js', '.json', '.wasm', '.mjs'], - alias: { - assets: path.resolve(__dirname, 'build/public'), - forum: path.resolve(__dirname, 'build/public/src/client'), - admin: path.resolve(__dirname, 'build/public/src/admin'), - vendor: path.resolve(__dirname, 'public/vendor'), - benchpress: path.resolve(__dirname, 'node_modules/benchpressjs'), - Chart: path.resolve(__dirname, 'node_modules/chart.js'), - Sortable: path.resolve(__dirname, 'node_modules/sortablejs'), - cropper: path.resolve(__dirname, 'node_modules/cropperjs'), - 'jquery-ui/widgets': path.resolve(__dirname, 'node_modules/jquery-ui/ui/widgets'), - 'ace/ace': path.resolve(__dirname, 'build/public/src/modules/ace-editor.js'), - }, - }, - module: { - rules: [ - { - test: /\.(ts|tsx)$/, - exclude: /node_modules/, - loader: 'ignore-loader', - }, - ], - }, -}; +// module.exports = { +// plugins: [], +// entry: { +// nodebb: './build/public/src/client.js', +// admin: './build/public/src/admin/admin.js', +// }, +// output: { +// filename: '[name].min.js', +// chunkFilename: '[name].[contenthash].min.js', +// path: path.resolve(__dirname, 'build/public'), +// publicPath: `${relativePath}/assets/`, +// clean: { +// keep(asset) { +// return asset === 'installer.min.js' || +// !asset.endsWith('.min.js'); +// }, +// }, +// }, +// watchOptions: { +// poll: 500, +// aggregateTimeout: 250, +// }, +// resolve: { +// symlinks: false, +// modules: [ +// 'build/public/src/modules', +// 'build/public/src', +// 'node_modules', +// ...activePlugins.map(p => `node_modules/${p}/node_modules`), +// ], +// extensions: ['.js', '.json', '.wasm', '.mjs'], +// alias: { +// assets: path.resolve(__dirname, 'build/public'), +// forum: path.resolve(__dirname, 'build/public/src/client'), +// admin: path.resolve(__dirname, 'build/public/src/admin'), +// vendor: path.resolve(__dirname, 'public/vendor'), +// benchpress: path.resolve(__dirname, 'node_modules/benchpressjs'), +// Chart: path.resolve(__dirname, 'node_modules/chart.js'), +// Sortable: path.resolve(__dirname, 'node_modules/sortablejs'), +// cropper: path.resolve(__dirname, 'node_modules/cropperjs'), +// 'jquery-ui/widgets': path.resolve(__dirname, 'node_modules/jquery-ui/ui/widgets'), +// 'ace/ace': path.resolve(__dirname, 'build/public/src/modules/ace-editor.js'), +// }, +// }, +// module: { +// rules: [ +// { +// test: /\.(ts|tsx)$/, +// exclude: /node_modules/, +// loader: 'ignore-loader', +// }, +// ], +// }, +// }; From b811c4243b60c53ba73df085cdd0a3f7548d266d Mon Sep 17 00:00:00 2001 From: Zainab Date: Fri, 20 Oct 2023 12:12:58 +0300 Subject: [PATCH 4/4] The addition of the omitted config.json f ile --- config.json | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 config.json diff --git a/config.json b/config.json new file mode 100644 index 00000000..3c0095c4 --- /dev/null +++ b/config.json @@ -0,0 +1,18 @@ +{ + "url": "http://127.0.0.1:4567", + "secret": "91e2cee9-57de-4dcd-bb08-d85eeda3067c", + "database": "redis", + "redis": { + "host": "127.0.0.1", + "port": "6379", + "password": "", + "database": "0" + }, + "port": "4567", + "test_database": { + "host": "127.0.0.1", + "port": "6379", + "password": "", + "database": "1" + } +} \ No newline at end of file