Compare commits
8 commits
v2023.01.2
...
main
Author | SHA1 | Date | |
---|---|---|---|
fdfd8c092d | |||
|
d66ba6f0b0 | ||
94fcad4e70 | |||
3cf58b2ea8 | |||
|
d6614242cb | ||
|
4e34575033 | ||
|
3e8c5e06f9 | ||
|
c8b4822cd7 |
11 changed files with 52 additions and 131 deletions
11
.github/dependabot.yml
vendored
Normal file
11
.github/dependabot.yml
vendored
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
# To get started with Dependabot version updates, you'll need to specify which
|
||||||
|
# package ecosystems to update and where the package manifests are located.
|
||||||
|
# Please see the documentation for all configuration options:
|
||||||
|
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
|
||||||
|
|
||||||
|
version: 2
|
||||||
|
updates:
|
||||||
|
- package-ecosystem: "npm" # See documentation for possible values
|
||||||
|
directory: "/" # Location of package manifests
|
||||||
|
schedule:
|
||||||
|
interval: "weekly"
|
12
.github/workflows/npm-publish.yml
vendored
12
.github/workflows/npm-publish.yml
vendored
|
@ -4,7 +4,7 @@ on:
|
||||||
types: [created]
|
types: [created]
|
||||||
jobs:
|
jobs:
|
||||||
Publish-NPM:
|
Publish-NPM:
|
||||||
runs-on: ubuntu-latest
|
runs-on: node1
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -14,6 +14,10 @@ jobs:
|
||||||
node-version: '16.x'
|
node-version: '16.x'
|
||||||
registry-url: 'https://registry.npmjs.org'
|
registry-url: 'https://registry.npmjs.org'
|
||||||
scope: '@thundernetworkrad'
|
scope: '@thundernetworkrad'
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm i
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
- name: Publish package on NPM 📦
|
- name: Publish package on NPM 📦
|
||||||
run: npm publish --access public
|
run: npm publish --access public
|
||||||
env:
|
env:
|
||||||
|
@ -22,7 +26,7 @@ jobs:
|
||||||
REGISTRY2: 'registry=https://registry.npmjs.org/'
|
REGISTRY2: 'registry=https://registry.npmjs.org/'
|
||||||
|
|
||||||
Publish-GitHub-NPM:
|
Publish-GitHub-NPM:
|
||||||
runs-on: ubuntu-latest
|
runs-on: node1
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -32,6 +36,10 @@ jobs:
|
||||||
node-version: '16.x'
|
node-version: '16.x'
|
||||||
registry-url: 'https://npm.pkg.github.com'
|
registry-url: 'https://npm.pkg.github.com'
|
||||||
scope: '@thundernetworkrad'
|
scope: '@thundernetworkrad'
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: npm i
|
||||||
|
- name: Build
|
||||||
|
run: npm run build
|
||||||
- name: Publish package on NPM 📦
|
- name: Publish package on NPM 📦
|
||||||
run: npm publish --access public
|
run: npm publish --access public
|
||||||
env:
|
env:
|
||||||
|
|
10
README.md
10
README.md
|
@ -2,17 +2,15 @@
|
||||||
|
|
||||||
Standard module for NodeJS / TypeScript
|
Standard module for NodeJS / TypeScript
|
||||||
|
|
||||||
Note: TypeScript support is in testing
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { cin } = require('@thundernetworkrad/std');
|
import { cin } from '@thundernetworkrad/std';
|
||||||
cin('Question').then((response) => {
|
cin('Question').then((response) => {
|
||||||
console.log(response)
|
console.log(response)
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { createCout } = require('@thundernetworkrad/std');
|
import { createCout } from '@thundernetworkrad/std';
|
||||||
|
|
||||||
let ccout = new createCout(0, true); // debugLevel, logs enabled (file) (like using log() )
|
let ccout = new createCout(0, true); // debugLevel, logs enabled (file) (like using log() )
|
||||||
|
|
||||||
|
@ -22,13 +20,13 @@ cout('test', 0) // console.log day, time and the string, if the number is >= to
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { log } = require('@thundernetworkrad/std');
|
import { log } from '@thundernetworkrad/std';
|
||||||
|
|
||||||
log('test') // create a file at the first log, add the string to the log
|
log('test') // create a file at the first log, add the string to the log
|
||||||
```
|
```
|
||||||
|
|
||||||
```js
|
```js
|
||||||
const { getTime } = require('@thundernetworkrad/std');
|
import { getTime } from '@thundernetworkrad/std';
|
||||||
|
|
||||||
let time = getTime() // return { year, month, day, hours, minutes, seconds }
|
let time = getTime() // return { year, month, day, hours, minutes, seconds }
|
||||||
```
|
```
|
13
index.ts
13
index.ts
|
@ -1,13 +0,0 @@
|
||||||
//import { appendFile, existsSync } from 'node:fs';
|
|
||||||
//import { mkdir } from 'node:fs/promises';
|
|
||||||
import getTime from './src/getTime.js';
|
|
||||||
import log from './src/log.js';
|
|
||||||
import cin from './src/cin.js';
|
|
||||||
import cout from './src/cout.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
getTime,
|
|
||||||
log,
|
|
||||||
cin,
|
|
||||||
cout
|
|
||||||
}
|
|
23
package.json
23
package.json
|
@ -1,15 +1,15 @@
|
||||||
{
|
{
|
||||||
"name": "@thundernetworkrad/std",
|
"name": "@thundernetworkrad/std",
|
||||||
"version": "2023.01.28",
|
"version": "2023.02.05",
|
||||||
"description": "Standard module for javascript",
|
"description": "Standard module for JavaScript / TypeScript",
|
||||||
"main": "build/index.js",
|
"main": "build/index.js",
|
||||||
"type": "module",
|
"types": "build/index.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"install": "tsc"
|
"build": "tsc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://github.com/FIUSDevelopment/std.git"
|
"url": "git+https://github.com/ThunderNetworkRaD/std.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"std",
|
"std",
|
||||||
|
@ -22,14 +22,17 @@
|
||||||
"author": "Thunder Network RaD | Killer Boss Original",
|
"author": "Thunder Network RaD | Killer Boss Original",
|
||||||
"license": "SEE LICENSE IN LICENSE.txt",
|
"license": "SEE LICENSE IN LICENSE.txt",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/FIUSDevelopment/std/issues"
|
"url": "https://github.com/ThunderNetworkRaD/std/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/FIUSDevelopment/std#readme",
|
"homepage": "https://github.com/ThunderNetworkRaD/std#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@thundernetworkrad/readline-sync": "^2023.1.26-2"
|
"@thundernetworkrad/logs": "^2023.2.5-1",
|
||||||
},
|
"@thundernetworkrad/readline-sync": "^2023.1.26-2",
|
||||||
"devDependencies": {
|
"@thundernetworkrad/time": "^2023.2.5-2",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.11.18",
|
||||||
|
"node-cin": "^2023.2.5",
|
||||||
|
"node-cout": "^2023.2.5-1",
|
||||||
|
"tslib": "^2.5.0",
|
||||||
"typescript": "^4.9.4"
|
"typescript": "^4.9.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
22
src/cin.ts
22
src/cin.ts
|
@ -1,22 +0,0 @@
|
||||||
import readlineSync from '@thundernetworkrad/readline-sync';
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param question what question you need to make?
|
|
||||||
* @param hide is the question private?
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
function cin (question: string, hide: boolean) {
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
try {
|
|
||||||
let answer: string = readlineSync.question(`${question} `, {
|
|
||||||
hideEchoBack: hide || false
|
|
||||||
})
|
|
||||||
return resolve(answer);
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e)
|
|
||||||
return resolve('error');
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
export default cin;
|
|
35
src/cout.ts
35
src/cout.ts
|
@ -1,35 +0,0 @@
|
||||||
let debug: number, logs1: boolean|undefined|null;
|
|
||||||
import getTime from './getTime.js';
|
|
||||||
import log from './log.js';
|
|
||||||
export default class createCout {
|
|
||||||
/**
|
|
||||||
* @constructor
|
|
||||||
* @param debugLevel from what debug level you want to log?
|
|
||||||
* @param logs do you want files log?
|
|
||||||
*/
|
|
||||||
constructor (debugLevel: number, logs?: boolean) {
|
|
||||||
if (!debugLevel) debugLevel = 0;
|
|
||||||
if (!logs) logs = false;
|
|
||||||
debug = debugLevel;
|
|
||||||
logs1 = logs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string what to log?
|
|
||||||
* @param debugLevel from what debug level this will logged?
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
cout (string: string, debugLevel?: number) {
|
|
||||||
if (!debugLevel) debugLevel = 0;
|
|
||||||
var time = getTime();
|
|
||||||
|
|
||||||
if (debug >= debugLevel) {
|
|
||||||
console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
|
|
||||||
if (logs1) {
|
|
||||||
log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -1,16 +0,0 @@
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
function getTime () {
|
|
||||||
const date_time = new Date();
|
|
||||||
const year = date_time.getFullYear();
|
|
||||||
const month = parseInt(("0" + (date_time.getMonth() + 1)).slice(-2));
|
|
||||||
const day = parseInt(("0" + date_time.getDate()).slice(-2));
|
|
||||||
const hours = date_time.getHours();
|
|
||||||
const minutes = date_time.getMinutes();
|
|
||||||
const seconds = date_time.getSeconds();
|
|
||||||
return({year, month, day, hours, minutes, seconds})
|
|
||||||
};
|
|
||||||
export default getTime;
|
|
11
src/index.ts
Normal file
11
src/index.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import { getTime } from '@thundernetworkrad/time';
|
||||||
|
import { log } from '@thundernetworkrad/logs';
|
||||||
|
import { cin } from 'node-cin';
|
||||||
|
import { createCout } from 'node-cout';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
getTime,
|
||||||
|
log,
|
||||||
|
cin,
|
||||||
|
createCout
|
||||||
|
}
|
24
src/log.ts
24
src/log.ts
|
@ -1,24 +0,0 @@
|
||||||
import { appendFile, existsSync } from 'node:fs';
|
|
||||||
import { mkdir } from 'node:fs/promises';
|
|
||||||
import getTime from './getTime.js';
|
|
||||||
|
|
||||||
let time;
|
|
||||||
const startTime = getTime();
|
|
||||||
time = startTime;
|
|
||||||
const name = `${time.year}.${time.month}.${time.day}.${time.hours}.${time.minutes}.${time.seconds}.log`;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string to log
|
|
||||||
*/
|
|
||||||
function log (string?: string) {
|
|
||||||
if (!existsSync('./logs')) mkdir('./logs', { recursive: true });
|
|
||||||
|
|
||||||
appendFile(`./logs/${name}`, string+'\n', (err: any) => {
|
|
||||||
if (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
})
|
|
||||||
};
|
|
||||||
|
|
||||||
export default log;
|
|
|
@ -25,8 +25,8 @@
|
||||||
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
||||||
|
|
||||||
/* Modules */
|
/* Modules */
|
||||||
"module": "ESNext", /* Specify what module code is generated. */
|
"module": "CommonJS", /* Specify what module code is generated. */
|
||||||
"rootDir": "./", /* Specify the root folder within your source files. */
|
"rootDir": "src", /* Specify the root folder within your source files. */
|
||||||
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
"moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
||||||
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
||||||
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
||||||
|
|
Loading…
Reference in a new issue