From 2e1cab23a48fd9742cbdfb49ff76c213bb33af31 Mon Sep 17 00:00:00 2001 From: yuto-yuto Date: Sat, 10 Jul 2021 19:18:20 +0200 Subject: [PATCH] temp --- .vscode/launch.json | 26 ++++++++++++++++++++++++++ Docker/Dockerfile | 2 +- Docker/docker-compose.yml | 2 +- Docker/flow/.config.nodes.json | 6 +++--- Docker/flow/.config.nodes.json.backup | 6 +++--- package.json | 13 ++++++------- test/PasswordGenerator_spec.ts | 13 ++++++++++++- 7 files changed, 52 insertions(+), 16 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..b6e6b5e --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,26 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "node", + "request": "launch", + "name": "Mocha Test", + "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha", + "sourceMaps": true, + "skipFiles": ["/**"], + "args": [ + "-r", + "ts-node/register", + "--timeout", + "999999", + "--colors", + "${workspaceFolder}/test/**/*_spec.ts" + ], + "internalConsoleOptions": "openOnSessionStart", + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/Docker/Dockerfile b/Docker/Dockerfile index a4cd09f..c9008d2 100644 --- a/Docker/Dockerfile +++ b/Docker/Dockerfile @@ -1,7 +1,7 @@ FROM nodered/node-red # error without this -RUN mkdir -p ./password-generator/node_modules/ +# RUN mkdir -p ./password-generator/node_modules/ COPY ../package.json ../package-lock.json ./password-generator/ COPY ../dist ./password-generator/dist diff --git a/Docker/docker-compose.yml b/Docker/docker-compose.yml index 606d6b9..fd7cd41 100644 --- a/Docker/docker-compose.yml +++ b/Docker/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" services: nodered: - image: nodered-update-detector + image: nodered-password-generator ports: - "1880:1880" volumes: diff --git a/Docker/flow/.config.nodes.json b/Docker/flow/.config.nodes.json index 36de66a..1e0f3b6 100644 --- a/Docker/flow/.config.nodes.json +++ b/Docker/flow/.config.nodes.json @@ -397,15 +397,15 @@ "version": "1.0.0", "local": false, "nodes": { - "valueChangeDetector": { - "name": "valueChangeDetector", + "passwordGeneratorNode": { + "name": "passwordGeneratorNode", "types": [ "password-generator" ], "enabled": true, "local": false, "module": "node-red-contrib-password-generator", - "file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/ValueChangeDetectorNode.js" + "file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/PasswordGeneratorNode.js" } } } diff --git a/Docker/flow/.config.nodes.json.backup b/Docker/flow/.config.nodes.json.backup index 7bddd0b..f75ecff 100644 --- a/Docker/flow/.config.nodes.json.backup +++ b/Docker/flow/.config.nodes.json.backup @@ -397,13 +397,13 @@ "version": "1.0.0", "local": false, "nodes": { - "valueChangeDetector": { - "name": "valueChangeDetector", + "passwordGeneratorNode": { + "name": "passwordGeneratorNode", "types": [], "enabled": true, "local": false, "module": "node-red-contrib-password-generator", - "file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/ValueChangeDetectorNode.js" + "file": "/usr/src/node-red/node_modules/node-red-contrib-password-generator/dist/lib/PasswordGeneratorNode123.js" } } } diff --git a/package.json b/package.json index 85aa5cb..0e3a94f 100644 --- a/package.json +++ b/package.json @@ -1,24 +1,24 @@ { "name": "node-red-contrib-password-generator", "version": "1.0.0", - "description": "Send message only when the specified key's value changes", + "description": "Generate random password", "main": "index.js", "scripts": { "start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS", "build": "tsc && cp ./lib/*.html ./dist/lib/", - "build-d": "npm run build && docker build -t nodered-update-detector -f ./Docker/Dockerfile .", + "build-d": "npm run build && docker build -t nodered-password-generator -f ./Docker/Dockerfile .", "clean": "rm -rf ./dist", "test": "mocha --recursive --require ts-node/register test/*.ts" }, "keywords": [ "node-red", "password-generator", - "update-detector", - "rbe" + "rbe", + "crypto" ], "node-red": { "nodes": { - "valueChangeDetector": "./dist/lib/ValueChangeDetectorNode.js" + "passwordGeneratorNode": "./dist/lib/PasswordGeneratorNode.js" } }, "author": "yuto-yuto", @@ -32,14 +32,13 @@ "@types/sinon": "^9.0.5", "chai": "^4.2.0", "mocha": "^8.1.3", + "node-red": "^1.3.5", "node-red-node-test-helper": "^0.2.6", "sinon": "^9.0.3", "ts-node": "^8.10.2", "typescript": "^3.9.7" }, "dependencies": { - "fast-deep-equal": "^3.1.3", - "node-red": "^1.3.5", "yutolity": "^1.1.1" } } diff --git a/test/PasswordGenerator_spec.ts b/test/PasswordGenerator_spec.ts index 6eccc7c..ee938b8 100644 --- a/test/PasswordGenerator_spec.ts +++ b/test/PasswordGenerator_spec.ts @@ -1,11 +1,22 @@ import "mocha"; +import * as crypto from "crypto"; import { expect } from "chai"; +import * as sinon from "sinon"; import { generatePassword } from "../lib/PasswordGenerator"; describe("PasswordGenerator", () => { it("should return true for the first time", async () => { const result = await generatePassword(10); - console.log(`before: "${result}"`) expect(result).to.lengthOf(10); }); + // it.only("should return true for the first time", async () => { + // const testData = Buffer.from([31, 32, 126, 127]); + // sinon.stub(crypto, "randomBytes") + // .callsFake((size: number, cb: (err: Error | null, buf: Buffer) => void) => { + // console.log("HEY") + // cb(null, testData); + // }); + // const result = await generatePassword(10); + // expect(result).to.equal(" ~"); + // }); }); \ No newline at end of file