log-queue 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ name: GitHub Actions
2
+ run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
3
+ on: [push]
4
+ jobs:
5
+ Explore-GitHub-Actions:
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
9
+ - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
10
+ - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
11
+ - name: Check out repository code
12
+ uses: actions/checkout@v3
13
+ - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
14
+ - run: echo "🖥️ The workflow is now ready to test your code on the runner."
15
+ - name: List files in the repository
16
+ run: |
17
+ ls ${{ github.workspace }}
18
+ - run: echo "🍏 This job's status is ${{ job.status }}."
19
+ Footer
20
+ © 2023 GitHub, Inc.
21
+ Footer navigation
22
+ Terms
23
+ Privacy
24
+ Security
25
+ Status
26
+ Docs
27
+ Contact GitHub
28
+ Pricing
29
+ API
30
+ Training
31
+ Blog
32
+ About
@@ -0,0 +1,81 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
+
4
+ name: Node.js CI
5
+
6
+ on:
7
+ push:
8
+ branches: [ "master" ]
9
+ pull_request:
10
+ branches: [ "master" ]
11
+ workflow_dispatch: {}
12
+
13
+ jobs:
14
+ build:
15
+
16
+ runs-on: ${{ matrix.os }}
17
+
18
+ defaults:
19
+ run:
20
+ shell: bash
21
+
22
+ strategy:
23
+ matrix:
24
+ os: [ubuntu-latest, windows-latest]
25
+ node-version: [8.x, 10.x, 12.x, 14.x, 16.x, 18.x]
26
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
27
+ include:
28
+ - node-version: 8.x
29
+ npm-i: "eslint@6.x eslint-config-airbnb-base@14.x eslint-config-prettier@6.x eslint-plugin-prettier@3.x fs-extra@8.x nyc@14.x tap@14.x"
30
+
31
+ - node-version: 10.x
32
+ npm-i: "eslint@7.x fs-extra@9.x nyc@14.x tap@14.x"
33
+
34
+ - node-version: 12.x
35
+ npm-i: "nyc@14.x tap@14.x"
36
+
37
+ - node-version: 14.x
38
+ npm-i: "nyc@14.x tap@14.x"
39
+
40
+ steps:
41
+ - uses: actions/checkout@v3
42
+ - name: Use Node.js ${{ matrix.node-version }}
43
+ uses: actions/setup-node@v3
44
+ with:
45
+ node-version: ${{ matrix.node-version }}
46
+ cache: 'npm'
47
+
48
+ - name: Configure npm
49
+ run: npm config set loglevel error
50
+
51
+ - name: Get npm version
52
+ id: npm-version
53
+ run: |
54
+ npm -v
55
+ npmMajorVer=$(npm -v | cut -d. -f1)
56
+ echo "major=$npmMajorVer" >> $GITHUB_OUTPUT
57
+ - name: Disable prettier on older Node.js (8.x, 10.x, 12.x)
58
+ run: |
59
+ sed -i '/"prettier": "prettier/d' package.json
60
+ if: contains(fromJson('["8.x", "10.x", "12.x"]'), matrix.node-version)
61
+
62
+ - name: Install downgraded modules ${{ matrix.npm-i }}
63
+ run: |
64
+ npm install --save-dev ${{ matrix.npm-i }}
65
+ if [ ${{ steps.npm-version.outputs.major }} -le 5 ]; then
66
+ npm install
67
+ fi
68
+ if: matrix.npm-i != ''
69
+
70
+ - run: npm install
71
+ if: matrix.npm-i == '' && steps.npm-version.outputs.major <= 5
72
+
73
+ - run: npm ci
74
+ if: matrix.npm-i == '' && steps.npm-version.outputs.major > 5
75
+
76
+ - name: List dependencies
77
+ run: npm ls --depth=0 --dev && npm ls --depth=0 --prod
78
+
79
+ - run: npm run build --if-present
80
+ - run: npm run test_files
81
+ - run: npm run test_all
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 jman717
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,2 @@
1
+ # log
2
+ Logging mainly to console and log4js-tagline, but can certainly be used for generic logging.
package/app.js ADDED
@@ -0,0 +1,78 @@
1
+ /* @author Jim Manton: jrman@risebroadband.net
2
+ * @since 2023-01-15
3
+ * Main processing app
4
+ */
5
+
6
+ let colors = require('colors')
7
+
8
+ colors.setTheme({
9
+ silly: 'rainbow',
10
+ input: 'grey',
11
+ verbose: 'cyan',
12
+ prompt: 'grey',
13
+ info: 'green',
14
+ data: 'grey',
15
+ help: 'cyan',
16
+ warn: 'yellow',
17
+ debug: 'blue',
18
+ error: 'red',
19
+ success: 'green'
20
+ });
21
+
22
+ exports = module.exports = class LogQueue {
23
+ constructor(props) {
24
+ var t = this, fname = `LogQueue.constructor`
25
+ try {
26
+
27
+ t.parent = props.parent
28
+ t.relative_path = props.relative_path
29
+ t.exclude_logMsg = props.exclude_logMsg
30
+ t.resolve = props.resolve
31
+ t.reject = props.reject
32
+
33
+ t.init = t.init.bind(t)
34
+ t.logMsg = t.logMsg.bind(t)
35
+ t.logMsg({ msg: `${fname}`.debug, type: 'debug' })
36
+
37
+ return t
38
+ } catch (e) {
39
+ e.message = `${fname} error: ${e.message}`
40
+ throw (e)
41
+ }
42
+ }
43
+
44
+ init(props) {
45
+ var t = this, fname = `LogQueue.init`
46
+ try {
47
+ // t.base_queue = new base_queue({
48
+ // parent: t,
49
+ // relative_path: t.relative_path,
50
+ // logMsg: t.logMsg,
51
+ // resolve: t.resolve,
52
+ // reject: t.reject
53
+ // }).load(props).process()
54
+ return t
55
+ } catch (e) {
56
+ e.message = `${fname} error: ${e.message}`
57
+ throw (e)
58
+ }
59
+ }
60
+
61
+ logMsg(props = {}) {
62
+ let t = this, fname = "log_queue.logMsg"
63
+ try {
64
+ if (typeof props.msg == "undefined")
65
+ throw new Error(`no msg property in (${JSON.stringify(props)}) `)
66
+ if (typeof props.type == "undefined")
67
+ throw new Error(`no type property in (${JSON.stringify(props)}) `)
68
+ if (typeof t.exclude_logMsg != "undefined")
69
+ if (t.exclude_logMsg.indexOf(props.type) > -1)
70
+ return
71
+ console.log(props.msg)
72
+ } catch (e) {
73
+ e.message = `${fname} error: ${e.message}`
74
+ console.log(e.message)
75
+ throw e
76
+ }
77
+ }
78
+ }
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "author": {
3
+ "name": "Jim Manton"
4
+ },
5
+ "version": "0.0.3",
6
+ "bundleDependencies": [],
7
+ "dependencies": {
8
+ "@types/node": "^18.11.19",
9
+ "chai": "^4.3.7",
10
+ "colors": "^1.4.0",
11
+ "diffler": "^2.0.4",
12
+ "fs": "^0.0.1-security",
13
+ "mocha": "^10.2.0",
14
+ "valid-path": "^2.1.0"
15
+ },
16
+ "scripts": {
17
+ "start": "node app.ts",
18
+ "test": "mocha",
19
+ "ditched": "ditched -a",
20
+ "test_logs": "node ./tests/logs"
21
+ },
22
+ "keywords": [
23
+ "log",
24
+ "console",
25
+ "appenders",
26
+ "javascript",
27
+ "synchronous",
28
+ "objects",
29
+ "promises",
30
+ "mocha"
31
+ ],
32
+ "homepage": "https://github.com/jman717/file-obj-queue",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "git+https://github.com/jman717/file-obj-queue.git"
36
+ },
37
+ "deprecated": false,
38
+ "description": "Logging",
39
+ "email": "jrman@risebroadband.net",
40
+ "license": "MIT",
41
+ "main": "app.js",
42
+ "name": "log-queue",
43
+ "start": "node app.js"
44
+ }
package/test/app.js ADDED
@@ -0,0 +1,37 @@
1
+ var assert = require('assert');
2
+
3
+ describe('app', function () {
4
+ let app, application
5
+
6
+ it('app.constructor should pass', function () {
7
+ application = require('../app.js')
8
+ assert(app = new application())
9
+ })
10
+
11
+ it('app.logMsg is a function', function () {
12
+ assert(typeof app.logMsg == 'function')
13
+ })
14
+
15
+ it('app.getFileObject is a function', function () {
16
+ assert(typeof app.getFileObject == 'function')
17
+ })
18
+ })
19
+
20
+ describe('require', function () {
21
+
22
+ it('colors', function () {
23
+ assert(require('colors'))
24
+ })
25
+
26
+ it('base_queue', function () {
27
+ assert(require('../base_queue/app'))
28
+ })
29
+
30
+ it('fs', function () {
31
+ assert(require('fs'))
32
+ })
33
+
34
+ it('valid-path', function () {
35
+ assert(require('valid-path'))
36
+ })
37
+ })
@@ -0,0 +1,63 @@
1
+ const assert = require('assert'),
2
+ jsonHasDifferences = require('diffler'),
3
+ packagejson = require('../package.json')
4
+
5
+ const packageMock = {
6
+ "author": {
7
+ "name": "Jim Manton"
8
+ },
9
+ "version": "2.0.4",
10
+ "bundleDependencies": [],
11
+ "dependencies": {
12
+ "@types/node": "^18.11.19",
13
+ "chai": "^4.3.7",
14
+ "colors": "^1.4.0",
15
+ "diffler": "^2.0.4",
16
+ "fs": "^0.0.1-security",
17
+ "mocha": "^10.2.0",
18
+ "queuejson": "^9.0.11",
19
+ "typescript": "^4.9.5",
20
+ "valid-path": "^2.1.0"
21
+ },
22
+ "scripts": {
23
+ "start": "node app.ts",
24
+ "test": "mocha",
25
+ "ditched": "ditched -a",
26
+ "test_files": "node ./tests/files",
27
+ "test_all": "node ./tests/test_all"
28
+ },
29
+ "keywords": [
30
+ "queue",
31
+ "processing",
32
+ "appenders",
33
+ "javascript",
34
+ "synchronous",
35
+ "objects",
36
+ "promises",
37
+ "mocha"
38
+ ],
39
+ "homepage": "https://github.com/jman717/file-obj-queue",
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/jman717/file-obj-queue.git"
43
+ },
44
+ "deprecated": false,
45
+ "description": "Queue File Objects",
46
+ "email": "jrman@risebroadband.net",
47
+ "license": "MIT",
48
+ "main": "app.js",
49
+ "name": "file-obj-queue",
50
+ "start": "node app.js"
51
+ }
52
+
53
+ describe('package.json', function () {
54
+ it('should pass', function () {
55
+ const difference = jsonHasDifferences(packagejson, packageMock)
56
+ assert(JSON.stringify(difference) == "{}")
57
+ })
58
+
59
+ it('should fail', function () {
60
+ packageMock.version = '0'
61
+ assert(jsonHasDifferences(packagejson, packageMock))
62
+ })
63
+ })
package/tests/logs.js ADDED
@@ -0,0 +1,7 @@
1
+ var llog = require("../app.js"),
2
+ a = new llog({ parent: null })
3
+
4
+ a.logMsg({ msg: "hello world".debug, type: "debug" })
5
+ a.logMsg({ msg: "hello world".silly, type: "silly" })
6
+ a.logMsg({ msg: "hello world".error, type: "error" })
7
+