mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 02:24:16 +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": [
|
||||
{
|
||||
"name": "Attach to Chrome",
|
||||
"port": 9222,
|
||||
"request": "attach",
|
||||
"type": "pwa-chrome",
|
||||
"webRoot": "${workspaceFolder}"
|
||||
},
|
||||
{
|
||||
"name": "Attach by Process ID",
|
||||
"processId": "${command:PickProcess}",
|
||||
|
@ -1,7 +1,7 @@
|
||||
module.exports = {
|
||||
app_config: {
|
||||
id: "comty",
|
||||
siteName: 'Comty',
|
||||
guid: "7d6b74b5-1b3b-432f-97df-2c5fc2c2b6ae",
|
||||
siteName: 'Comty™',
|
||||
copyright: 'RageStudio©',
|
||||
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",
|
||||
"UUID": "C8mVSr-4nmPp2-pr5Vrz-CU4kg4",
|
||||
"title": "Comty™",
|
||||
"DevBuild": true,
|
||||
"version": "0.10.12",
|
||||
"stage": "dev",
|
||||
"description": "",
|
||||
"version": "0.10.16",
|
||||
"stage": "alpha",
|
||||
"description": "An prototype of a social network",
|
||||
"author": "RageStudio",
|
||||
"license": "LGPL-2.1",
|
||||
"private": true,
|
||||
"main": "main/index.js",
|
||||
"types": "index.d.ts",
|
||||
"build": {
|
||||
"files": [
|
||||
"./dist/**/*",
|
||||
@ -21,6 +19,7 @@
|
||||
},
|
||||
"scripts": {
|
||||
"start": "umi dev",
|
||||
"test": "jest --no-cache",
|
||||
"debug": "node --inspect-brk ./node_modules/.bin/umi dev",
|
||||
"postinstall": "electron-builder install-app-deps",
|
||||
"electronDev": "concurrently \"electron .\" \"npm start\"",
|
||||
@ -36,6 +35,9 @@
|
||||
"@icons-pack/react-simple-icons": "^3.8.0",
|
||||
"@lingui/react": "^2.9.2",
|
||||
"@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",
|
||||
"axios": "^0.20.0",
|
||||
"babel-core": "^6.26.3",
|
||||
@ -60,14 +62,15 @@
|
||||
"localforage": "^1.7.4",
|
||||
"lodash": "^4.17.19",
|
||||
"moment": "^2.28.0",
|
||||
"npm": "^6.14.8",
|
||||
"nprogress": "^0.2.0",
|
||||
"path-to-regexp": "^6.1.0",
|
||||
"platform": "^1.3.6",
|
||||
"react": "^16.13.1",
|
||||
"react": "^16.14.0",
|
||||
"react-animations": "^1.0.0",
|
||||
"react-color": "^2.18.1",
|
||||
"react-dazzle": "^1.4.0",
|
||||
"react-dom": "^16.12.0",
|
||||
"react-dom": "^16.14.0",
|
||||
"react-emoji": "^0.5.0",
|
||||
"react-google-recaptcha": "^2.0.1",
|
||||
"react-helmet": "^5.2.1",
|
||||
@ -85,6 +88,7 @@
|
||||
"store": "^2.0.12",
|
||||
"styled-components": "^5.2.0",
|
||||
"timeago.js": "^4.0.2",
|
||||
"ts-jest": "^26.4.1",
|
||||
"wait-on": "^5.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -94,7 +98,7 @@
|
||||
"@lingui/loader": "^2.9.2",
|
||||
"@types/electron-devtools-installer": "^2.2.0",
|
||||
"@types/node": "^12.12.59",
|
||||
"@umijs/preset-react": "^1.6.5",
|
||||
"@umijs/preset-react": "^1.6.11",
|
||||
"babel-eslint": "^10.0.1",
|
||||
"babel-plugin-dev-expression": "^0.2.1",
|
||||
"babel-plugin-module-resolver": "^4.0.0",
|
||||
@ -112,7 +116,7 @@
|
||||
"less": "^3.12.2",
|
||||
"less-loader": "^7.0.1",
|
||||
"style-loader": "^1.2.1",
|
||||
"typescript": "^3.8.3",
|
||||
"typescript": "^3.9.7",
|
||||
"umi": "^3.2.23"
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,26 @@
|
||||
import React from 'react'
|
||||
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 antd from 'antd'
|
||||
|
||||
const { logo, name, version, stage, os, layout } = app_info
|
||||
|
||||
export default class App_About extends React.Component {
|
||||
renderStableTag() {
|
||||
if (package_json.DevBuild == false) {
|
||||
return <antd.Tag color="blue">Stable</antd.Tag>
|
||||
} else {
|
||||
return <antd.Tag color="orange">No Stable</antd.Tag>
|
||||
}
|
||||
return <antd.Tag color={clientInfo.buildStable? "blue" : "orange"}>{clientInfo.buildStable? "Stable" : "Not Stable"}</antd.Tag>
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
<div className={styles.aboutWrapper}>
|
||||
<img src={logo} />
|
||||
<img src={clientInfo.logo} />
|
||||
<antd.Card>
|
||||
<h1 className={styles.appName}> {name} </h1>
|
||||
{UUAID}
|
||||
<h1 className={styles.appName}> {clientInfo.siteName} </h1>
|
||||
{GUID}
|
||||
<br />
|
||||
<antd.Tag color="green"><Icons.Monitor />{os.toString()}</antd.Tag>
|
||||
<antd.Tag color="geekblue"><Icons.Package />v{version}</antd.Tag>
|
||||
<antd.Tag color="red"><Icons.Radio />{stage}</antd.Tag>
|
||||
<antd.Tag color="magenta"><Icons.Layers />Render with {layout}</antd.Tag>
|
||||
<antd.Tag color="green"><Icons.Monitor />{clientInfo.os.toString()}</antd.Tag>
|
||||
<antd.Tag color="geekblue"><Icons.Package />v{clientInfo.version}</antd.Tag>
|
||||
<antd.Tag color="red"><Icons.Radio />{clientInfo.packageStage}</antd.Tag>
|
||||
<antd.Tag color="magenta"><Icons.Layers />Render with {clientInfo.layout}</antd.Tag>
|
||||
{this.renderStableTag()}
|
||||
|
||||
|
||||
</antd.Card>
|
||||
</div>
|
||||
|
@ -7,6 +7,9 @@ import handle from 'core/libs/errorhandler'
|
||||
import request from 'request'
|
||||
import html2canvas from 'html2canvas'
|
||||
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');
|
||||
|
||||
@ -15,13 +18,15 @@ export const defaultLanguage = i18n ? i18n.defaultLanguage : '';
|
||||
|
||||
import * as libs from './libs'
|
||||
|
||||
export * from '@ragestudio/nodecore-utils'
|
||||
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 = {
|
||||
appid: package_json.name,
|
||||
stage: package_json.stage,
|
||||
name: package_json.title,
|
||||
export const clientInfo = {
|
||||
buildStable: getBuild()["stable"],
|
||||
packageName: package_json.name,
|
||||
packageStage: package_json.stage,
|
||||
siteName: app_config.siteName,
|
||||
version: package_json.version,
|
||||
logo: app_config.FullLogoPath,
|
||||
logo_dark: app_config.DarkFullLogoPath,
|
||||
@ -29,6 +34,27 @@ export const app_info = {
|
||||
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) {
|
||||
if(!array) return false
|
||||
|
||||
@ -217,30 +243,6 @@ export function objectLast(array, n) {
|
||||
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
|
||||
*
|
||||
@ -265,8 +267,8 @@ export function arrayToObject(array) {
|
||||
* @param id {string}
|
||||
* @return array
|
||||
*/
|
||||
export function objectRemoveByID(object, id) {
|
||||
let arr = objectToArray(object)
|
||||
export function objectRemoveId(object, id) {
|
||||
let arr = __legacy__objectToArray(object)
|
||||
return arr.filter((e) => {
|
||||
return e.id != id;
|
||||
});
|
||||
@ -278,37 +280,13 @@ export function objectRemoveByID(object, id) {
|
||||
* @param key {string}
|
||||
* @return array
|
||||
*/
|
||||
export function objectRemoveByKEY(object, key) {
|
||||
let arr = objectToArray(object)
|
||||
export function objectRemoveKey(object, key) {
|
||||
let arr = __legacy__objectToArray(object)
|
||||
return arr.filter((e) => {
|
||||
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'
|
||||
@ -440,31 +418,6 @@ export function queryPathKeys(array, current, parentId, id = 'id') {
|
||||
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.
|
||||
* @param {layouts} layouts Layout configuration.
|
||||
@ -539,12 +492,7 @@ export function iatToString(iat){
|
||||
return new Date(iat * 1000).toLocaleString()
|
||||
}
|
||||
|
||||
export function extendIDCode(id){
|
||||
num.toString().padStart(4, "0");
|
||||
|
||||
}
|
||||
|
||||
export function generateUUID( lenght = 6 ){
|
||||
export function generateGUID( lenght = 6 ){
|
||||
let text = ""
|
||||
const possibleChars = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
|
||||
@ -554,10 +502,6 @@ export function generateUUID( lenght = 6 ){
|
||||
return text
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a random string
|
||||
* @returns {string}
|
||||
*/
|
||||
export function generateRandomId( length = 15 ){
|
||||
return Math.random ().toString ( 36 ).substring ( 0, length );
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user