mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
change app_info
object from core to clientInfo
, added getBuild
function and tidy up, remplazed local utils
methods to nodecore-utils lib
This commit is contained in:
parent
9f7a0f5ec8
commit
201306bceb
17
.github/workflows/validate.yml
vendored
Executable file
17
.github/workflows/validate.yml
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
name: Validate code
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/setup-node@v1
|
||||||
|
with:
|
||||||
|
node-version: 12
|
||||||
|
- run: npm ci
|
||||||
|
- run: npm test
|
7
.vscode/launch.json
vendored
7
.vscode/launch.json
vendored
@ -1,5 +1,12 @@
|
|||||||
{
|
{
|
||||||
"configurations": [
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Attach to Chrome",
|
||||||
|
"port": 9222,
|
||||||
|
"request": "attach",
|
||||||
|
"type": "pwa-chrome",
|
||||||
|
"webRoot": "${workspaceFolder}"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "Attach by Process ID",
|
"name": "Attach by Process ID",
|
||||||
"processId": "${command:PickProcess}",
|
"processId": "${command:PickProcess}",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
app_config: {
|
app_config: {
|
||||||
id: "comty",
|
guid: "7d6b74b5-1b3b-432f-97df-2c5fc2c2b6ae",
|
||||||
siteName: 'Comty',
|
siteName: 'Comty™',
|
||||||
copyright: 'RageStudio©',
|
copyright: 'RageStudio©',
|
||||||
MainPath: '/',
|
MainPath: '/',
|
||||||
|
|
||||||
|
9
jest.config.js
Normal file
9
jest.config.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
verbose: false,
|
||||||
|
modulePaths: [
|
||||||
|
'<rootDir>',
|
||||||
|
],
|
||||||
|
transform: {
|
||||||
|
'^.+\\.tsx?$': 'ts-jest',
|
||||||
|
},
|
||||||
|
}
|
24
package.json
24
package.json
@ -1,15 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "comty-development",
|
"name": "comty-development",
|
||||||
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
|
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
|
||||||
"title": "Comty™",
|
"version": "0.10.16",
|
||||||
"DevBuild": true,
|
"stage": "alpha",
|
||||||
"version": "0.10.12",
|
"description": "An prototype of a social network",
|
||||||
"stage": "dev",
|
|
||||||
"description": "",
|
|
||||||
"author": "RageStudio",
|
"author": "RageStudio",
|
||||||
"license": "LGPL-2.1",
|
"license": "LGPL-2.1",
|
||||||
"private": true,
|
|
||||||
"main": "main/index.js",
|
"main": "main/index.js",
|
||||||
|
"types": "index.d.ts",
|
||||||
"build": {
|
"build": {
|
||||||
"files": [
|
"files": [
|
||||||
"./dist/**/*",
|
"./dist/**/*",
|
||||||
@ -21,6 +19,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "umi dev",
|
"start": "umi dev",
|
||||||
|
"test": "jest --no-cache",
|
||||||
"debug": "node --inspect-brk ./node_modules/.bin/umi dev",
|
"debug": "node --inspect-brk ./node_modules/.bin/umi dev",
|
||||||
"postinstall": "electron-builder install-app-deps",
|
"postinstall": "electron-builder install-app-deps",
|
||||||
"electronDev": "concurrently \"electron .\" \"npm start\"",
|
"electronDev": "concurrently \"electron .\" \"npm start\"",
|
||||||
@ -36,6 +35,9 @@
|
|||||||
"@icons-pack/react-simple-icons": "^3.8.0",
|
"@icons-pack/react-simple-icons": "^3.8.0",
|
||||||
"@lingui/react": "^2.9.2",
|
"@lingui/react": "^2.9.2",
|
||||||
"@ragestudio/nodecore-api-lib": "^0.2.6",
|
"@ragestudio/nodecore-api-lib": "^0.2.6",
|
||||||
|
"@ragestudio/nodecore-utils": "^0.1.18",
|
||||||
|
"@types/jest": "^26.0.14",
|
||||||
|
"@types/lodash": "^4.14.162",
|
||||||
"antd": "^4.6.6",
|
"antd": "^4.6.6",
|
||||||
"axios": "^0.20.0",
|
"axios": "^0.20.0",
|
||||||
"babel-core": "^6.26.3",
|
"babel-core": "^6.26.3",
|
||||||
@ -60,14 +62,15 @@
|
|||||||
"localforage": "^1.7.4",
|
"localforage": "^1.7.4",
|
||||||
"lodash": "^4.17.19",
|
"lodash": "^4.17.19",
|
||||||
"moment": "^2.28.0",
|
"moment": "^2.28.0",
|
||||||
|
"npm": "^6.14.8",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"path-to-regexp": "^6.1.0",
|
"path-to-regexp": "^6.1.0",
|
||||||
"platform": "^1.3.6",
|
"platform": "^1.3.6",
|
||||||
"react": "^16.13.1",
|
"react": "^16.14.0",
|
||||||
"react-animations": "^1.0.0",
|
"react-animations": "^1.0.0",
|
||||||
"react-color": "^2.18.1",
|
"react-color": "^2.18.1",
|
||||||
"react-dazzle": "^1.4.0",
|
"react-dazzle": "^1.4.0",
|
||||||
"react-dom": "^16.12.0",
|
"react-dom": "^16.14.0",
|
||||||
"react-emoji": "^0.5.0",
|
"react-emoji": "^0.5.0",
|
||||||
"react-google-recaptcha": "^2.0.1",
|
"react-google-recaptcha": "^2.0.1",
|
||||||
"react-helmet": "^5.2.1",
|
"react-helmet": "^5.2.1",
|
||||||
@ -85,6 +88,7 @@
|
|||||||
"store": "^2.0.12",
|
"store": "^2.0.12",
|
||||||
"styled-components": "^5.2.0",
|
"styled-components": "^5.2.0",
|
||||||
"timeago.js": "^4.0.2",
|
"timeago.js": "^4.0.2",
|
||||||
|
"ts-jest": "^26.4.1",
|
||||||
"wait-on": "^5.2.0"
|
"wait-on": "^5.2.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@ -94,7 +98,7 @@
|
|||||||
"@lingui/loader": "^2.9.2",
|
"@lingui/loader": "^2.9.2",
|
||||||
"@types/electron-devtools-installer": "^2.2.0",
|
"@types/electron-devtools-installer": "^2.2.0",
|
||||||
"@types/node": "^12.12.59",
|
"@types/node": "^12.12.59",
|
||||||
"@umijs/preset-react": "^1.6.5",
|
"@umijs/preset-react": "^1.6.11",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.1",
|
||||||
"babel-plugin-dev-expression": "^0.2.1",
|
"babel-plugin-dev-expression": "^0.2.1",
|
||||||
"babel-plugin-module-resolver": "^4.0.0",
|
"babel-plugin-module-resolver": "^4.0.0",
|
||||||
@ -112,7 +116,7 @@
|
|||||||
"less": "^3.12.2",
|
"less": "^3.12.2",
|
||||||
"less-loader": "^7.0.1",
|
"less-loader": "^7.0.1",
|
||||||
"style-loader": "^1.2.1",
|
"style-loader": "^1.2.1",
|
||||||
"typescript": "^3.8.3",
|
"typescript": "^3.9.7",
|
||||||
"umi": "^3.2.23"
|
"umi": "^3.2.23"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,34 +1,27 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import styles from './index.less'
|
import styles from './index.less'
|
||||||
import { app_info, UUAID, package_json } from 'core'
|
import { clientInfo, GUID, package_json } from 'core'
|
||||||
import * as Icons from 'components/Icons'
|
import * as Icons from 'components/Icons'
|
||||||
import * as antd from 'antd'
|
import * as antd from 'antd'
|
||||||
|
|
||||||
const { logo, name, version, stage, os, layout } = app_info
|
|
||||||
|
|
||||||
export default class App_About extends React.Component {
|
export default class App_About extends React.Component {
|
||||||
renderStableTag() {
|
renderStableTag() {
|
||||||
if (package_json.DevBuild == false) {
|
return <antd.Tag color={clientInfo.buildStable? "blue" : "orange"}>{clientInfo.buildStable? "Stable" : "Not Stable"}</antd.Tag>
|
||||||
return <antd.Tag color="blue">Stable</antd.Tag>
|
|
||||||
} else {
|
|
||||||
return <antd.Tag color="orange">No Stable</antd.Tag>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className={styles.aboutWrapper}>
|
<div className={styles.aboutWrapper}>
|
||||||
<img src={logo} />
|
<img src={clientInfo.logo} />
|
||||||
<antd.Card>
|
<antd.Card>
|
||||||
<h1 className={styles.appName}> {name} </h1>
|
<h1 className={styles.appName}> {clientInfo.siteName} </h1>
|
||||||
{UUAID}
|
{GUID}
|
||||||
<br />
|
<br />
|
||||||
<antd.Tag color="green"><Icons.Monitor />{os.toString()}</antd.Tag>
|
<antd.Tag color="green"><Icons.Monitor />{clientInfo.os.toString()}</antd.Tag>
|
||||||
<antd.Tag color="geekblue"><Icons.Package />v{version}</antd.Tag>
|
<antd.Tag color="geekblue"><Icons.Package />v{clientInfo.version}</antd.Tag>
|
||||||
<antd.Tag color="red"><Icons.Radio />{stage}</antd.Tag>
|
<antd.Tag color="red"><Icons.Radio />{clientInfo.packageStage}</antd.Tag>
|
||||||
<antd.Tag color="magenta"><Icons.Layers />Render with {layout}</antd.Tag>
|
<antd.Tag color="magenta"><Icons.Layers />Render with {clientInfo.layout}</antd.Tag>
|
||||||
{this.renderStableTag()}
|
{this.renderStableTag()}
|
||||||
|
|
||||||
|
|
||||||
</antd.Card>
|
</antd.Card>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
|
@ -7,6 +7,9 @@ import handle from 'core/libs/errorhandler'
|
|||||||
import request from 'request'
|
import request from 'request'
|
||||||
import html2canvas from 'html2canvas'
|
import html2canvas from 'html2canvas'
|
||||||
import platform from 'platform'
|
import platform from 'platform'
|
||||||
|
import path from 'path'
|
||||||
|
import fs from 'fs'
|
||||||
|
import * as utils from '@ragestudio/nodecore-utils'
|
||||||
|
|
||||||
const { pathToRegexp } = require('path-to-regexp');
|
const { pathToRegexp } = require('path-to-regexp');
|
||||||
|
|
||||||
@ -15,13 +18,15 @@ export const defaultLanguage = i18n ? i18n.defaultLanguage : '';
|
|||||||
|
|
||||||
import * as libs from './libs'
|
import * as libs from './libs'
|
||||||
|
|
||||||
|
export * from '@ragestudio/nodecore-utils'
|
||||||
export const package_json = require('../../package.json');
|
export const package_json = require('../../package.json');
|
||||||
export const UUAID = `${package_json.name}==${package_json.UUID}`;
|
export const GUID = app_config.guid;
|
||||||
|
|
||||||
export const app_info = {
|
export const clientInfo = {
|
||||||
appid: package_json.name,
|
buildStable: getBuild()["stable"],
|
||||||
stage: package_json.stage,
|
packageName: package_json.name,
|
||||||
name: package_json.title,
|
packageStage: package_json.stage,
|
||||||
|
siteName: app_config.siteName,
|
||||||
version: package_json.version,
|
version: package_json.version,
|
||||||
logo: app_config.FullLogoPath,
|
logo: app_config.FullLogoPath,
|
||||||
logo_dark: app_config.DarkFullLogoPath,
|
logo_dark: app_config.DarkFullLogoPath,
|
||||||
@ -29,6 +34,27 @@ export const app_info = {
|
|||||||
layout: platform.layout
|
layout: platform.layout
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export function getBuild() {
|
||||||
|
let build = {
|
||||||
|
stable: false
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (!window.__build) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
const buildPath = path.resolve(__dirname, "./dist")
|
||||||
|
const data = JSON.parse(fs.readFileSync(`${buildPath}/build.json`))
|
||||||
|
if (typeof(data) !== "undefined" && Array.isArray(data)) {
|
||||||
|
utils.__legacy____legacy__objectToArray(data).forEach((e) => {
|
||||||
|
build[e.key] = e.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// tf this is not a build sorry
|
||||||
|
}
|
||||||
|
return build
|
||||||
|
}
|
||||||
|
|
||||||
export function queryIndexer(array, callback, params) {
|
export function queryIndexer(array, callback, params) {
|
||||||
if(!array) return false
|
if(!array) return false
|
||||||
|
|
||||||
@ -217,30 +243,6 @@ export function objectLast(array, n) {
|
|||||||
return array.slice(Math.max(array.length - n, 0));
|
return array.slice(Math.max(array.length - n, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Object to array scheme RSA-YCORE-ARRAYPROTO.2
|
|
||||||
*
|
|
||||||
* @param object {object}
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
export function objectToArray(object) {
|
|
||||||
if(!object) return false
|
|
||||||
let tmp = []
|
|
||||||
|
|
||||||
const keys = Object.keys(object)
|
|
||||||
const values = Object.values(object)
|
|
||||||
const sourceLength = keys.length
|
|
||||||
|
|
||||||
for (let i = 0; i < sourceLength; i++) {
|
|
||||||
let obj = {}
|
|
||||||
obj.key = keys[i]
|
|
||||||
obj.value = values[i]
|
|
||||||
|
|
||||||
tmp[i] = obj
|
|
||||||
}
|
|
||||||
return tmp
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object to array scheme RSA-YCORE-ARRAYPROTO.2
|
* Object to array scheme RSA-YCORE-ARRAYPROTO.2
|
||||||
*
|
*
|
||||||
@ -265,8 +267,8 @@ export function arrayToObject(array) {
|
|||||||
* @param id {string}
|
* @param id {string}
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
export function objectRemoveByID(object, id) {
|
export function objectRemoveId(object, id) {
|
||||||
let arr = objectToArray(object)
|
let arr = __legacy__objectToArray(object)
|
||||||
return arr.filter((e) => {
|
return arr.filter((e) => {
|
||||||
return e.id != id;
|
return e.id != id;
|
||||||
});
|
});
|
||||||
@ -278,37 +280,13 @@ export function objectRemoveByID(object, id) {
|
|||||||
* @param key {string}
|
* @param key {string}
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
export function objectRemoveByKEY(object, key) {
|
export function objectRemoveKey(object, key) {
|
||||||
let arr = objectToArray(object)
|
let arr = __legacy__objectToArray(object)
|
||||||
return arr.filter((e) => {
|
return arr.filter((e) => {
|
||||||
return e.key != key;
|
return e.key != key;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove an element by id from an array
|
|
||||||
*
|
|
||||||
* @param array {array}
|
|
||||||
* @param id {string}
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
export function arrayRemoveByID(arr, id) {
|
|
||||||
return arr.filter(function(ele) {
|
|
||||||
return ele.id != id;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Remove an element by key from an array
|
|
||||||
*
|
|
||||||
* @param array {array}
|
|
||||||
* @param key {string}
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
export function arrayRemoveByKEY(arr, key) {
|
|
||||||
return arr.filter(function(ele) {
|
|
||||||
return ele.key != key;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global fix for convert '1, 0' to string boolean 'true, false'
|
* Global fix for convert '1, 0' to string boolean 'true, false'
|
||||||
@ -440,31 +418,6 @@ export function queryPathKeys(array, current, parentId, id = 'id') {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* In an array of objects, specify an object that traverses the objects whose parent ID matches.
|
|
||||||
* @param {array} array The Array need to Converted.
|
|
||||||
* @param {string} current Specify the object that needs to be queried.
|
|
||||||
* @param {string} parentId The alias of the parent ID of the object in the array.
|
|
||||||
* @param {string} id The alias of the unique ID of the object in the array.
|
|
||||||
* @return {array} Return a key array.
|
|
||||||
*/
|
|
||||||
export function queryAncestors(array, current, parentId, id = 'id') {
|
|
||||||
const result = [current];
|
|
||||||
const hashMap = new Map();
|
|
||||||
array.forEach(item => hashMap.set(item[id], item));
|
|
||||||
|
|
||||||
const getPath = current => {
|
|
||||||
const currentParentId = hashMap.get(current[id])[parentId];
|
|
||||||
if (currentParentId) {
|
|
||||||
result.push(hashMap.get(currentParentId));
|
|
||||||
getPath(hashMap.get(currentParentId));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
getPath(current);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query which layout should be used for the current path based on the configuration.
|
* Query which layout should be used for the current path based on the configuration.
|
||||||
* @param {layouts} layouts Layout configuration.
|
* @param {layouts} layouts Layout configuration.
|
||||||
@ -539,12 +492,7 @@ export function iatToString(iat){
|
|||||||
return new Date(iat * 1000).toLocaleString()
|
return new Date(iat * 1000).toLocaleString()
|
||||||
}
|
}
|
||||||
|
|
||||||
export function extendIDCode(id){
|
export function generateGUID( lenght = 6 ){
|
||||||
num.toString().padStart(4, "0");
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export function generateUUID( lenght = 6 ){
|
|
||||||
let text = ""
|
let text = ""
|
||||||
const possibleChars = "abcdefghijklmnopqrstuvwxyz0123456789"
|
const possibleChars = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||||
|
|
||||||
@ -554,10 +502,6 @@ export function generateUUID( lenght = 6 ){
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate a random string
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
export function generateRandomId( length = 15 ){
|
export function generateRandomId( length = 15 ){
|
||||||
return Math.random ().toString ( 36 ).substring ( 0, length );
|
return Math.random ().toString ( 36 ).substring ( 0, length );
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user