You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by al...@apache.org on 2020/04/10 18:06:59 UTC
[openwhisk-wskdebug] branch master updated (ac161d5 -> 9853359)
This is an automated email from the ASF dual-hosted git repository.
alexkli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git.
from ac161d5 allow scancode.sh to be run repeatedly and locally (#38)
new 2525400 npm audit fix
new e7d7c81 Support reading package name from WSK_PACKAGE env var #10
new 9853359 remove trailing whitespace
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
README.md | 37 +++++++++++++++++++++++++++++++-
examples/nodejs/.env | 2 ++
examples/nodejs/.vscode/launch.json | 14 ++++++++++++-
index.js | 4 ++++
package-lock.json | 29 ++++++++++++++++++-------
test/wskdebug.test.js | 42 ++++++++++++++++++++++++++++++++++++-
6 files changed, 118 insertions(+), 10 deletions(-)
create mode 100644 examples/nodejs/.env
[openwhisk-wskdebug] 01/03: npm audit fix
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexkli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git
commit 2525400265eb14a18fc58864c1e6c8f1f3071f57
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Thu Apr 9 20:53:59 2020 -0700
npm audit fix
---
package-lock.json | 29 ++++++++++++++++++++++-------
1 file changed, 22 insertions(+), 7 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 64dbc66..8267421 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2018,18 +2018,18 @@
}
},
"minimist": {
- "version": "0.0.8",
- "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
- "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
+ "version": "1.2.5",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz",
+ "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==",
"dev": true
},
"mkdirp": {
- "version": "0.5.1",
- "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
- "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "version": "0.5.5",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.5.tgz",
+ "integrity": "sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ==",
"dev": true,
"requires": {
- "minimist": "0.0.8"
+ "minimist": "^1.2.5"
}
},
"mkpath": {
@@ -2125,6 +2125,21 @@
"path-is-absolute": "^1.0.0"
}
},
+ "minimist": {
+ "version": "0.0.8",
+ "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=",
+ "dev": true
+ },
+ "mkdirp": {
+ "version": "0.5.1",
+ "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=",
+ "dev": true,
+ "requires": {
+ "minimist": "0.0.8"
+ }
+ },
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
[openwhisk-wskdebug] 03/03: remove trailing whitespace
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexkli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git
commit 9853359fba96295c0adcb98ab8e01274136d6325
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Thu Apr 9 21:57:50 2020 -0700
remove trailing whitespace
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 7b79ffa..28fe10b 100644
--- a/README.md
+++ b/README.md
@@ -155,7 +155,7 @@ To use custom credentials from a custom `.wskprops` and/or use a developer-speci
WSK_CONFIG_FILE=/Users/user/.wskprops-custom
WSK_PACKAGE=my-package
```
-
+
Set either of the variables as needed.
2. Make sure to not commit this file into source control, by e.g. adding `.env` to a `.gitignore` file.
[openwhisk-wskdebug] 02/03: Support reading package name from
WSK_PACKAGE env var #10
Posted by al...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
alexkli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git
commit e7d7c81d05e3d397f5aef416488f06d570addffb
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Thu Apr 9 21:50:12 2020 -0700
Support reading package name from WSK_PACKAGE env var #10
---
README.md | 37 +++++++++++++++++++++++++++++++-
examples/nodejs/.env | 2 ++
examples/nodejs/.vscode/launch.json | 14 ++++++++++++-
index.js | 4 ++++
test/wskdebug.test.js | 42 ++++++++++++++++++++++++++++++++++++-
5 files changed, 96 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index d3b8943..7b79ffa 100644
--- a/README.md
+++ b/README.md
@@ -124,7 +124,7 @@ The action to debug (e.g. `myaction`) must already be deployed.
Add the configuration below to your [launch.json](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations). Replace `MYACTION` with the name of your action and `ACTION.js` with the source file containing the action. When you run this, it will start wskdebug and should automatically connect the debugger.
-```
+```json
"configurations": [
{
"type": "node",
@@ -145,6 +145,41 @@ This snippets enables browser LiveReloading using `-l`. For other reloading opti
For troubleshooting, you can run the debugger in verbose mode by adding `"-v"` to the `args` array.
+#### Control wskprops credentials
+
+To use custom credentials from a custom `.wskprops` and/or use a developer-specific openwhisk package name, but avoid committing that into your source control system, you can use an `.env` file.
+
+1. Put this `.env` file in your VS Code project root:
+
+ ```
+ WSK_CONFIG_FILE=/Users/user/.wskprops-custom
+ WSK_PACKAGE=my-package
+ ```
+
+ Set either of the variables as needed.
+
+2. Make sure to not commit this file into source control, by e.g. adding `.env` to a `.gitignore` file.
+
+2. Add an `envFile` setting to the `.vscode/launch.json`, which you can share with co-workers and commit to source control:
+
+ ```json
+ "configurations": [
+ {
+ "type": "node",
+ "request": "launch",
+ "name": "wskdebug",
+ "runtimeExecutable": "wskdebug",
+ "args": [ "MYACTION", "ACTION.js", "-l" ],
+ "localRoot": "${workspaceFolder}",
+ "remoteRoot": "/code",
+ "outputCapture": "std",
+ "envFile": "${workspaceFolder}/.env"
+ }
+ ]
+ ```
+
+
+
<a name="nodejs-multiple-actions"></a>
### Node.js: Multiple actions
diff --git a/examples/nodejs/.env b/examples/nodejs/.env
new file mode 100644
index 0000000..d2c1e30
--- /dev/null
+++ b/examples/nodejs/.env
@@ -0,0 +1,2 @@
+WSK_PACKAGE=wskdebug-examples
+#WSK_CONFIG_FILE=<absolute-path-to-custom-wskprops>
diff --git a/examples/nodejs/.vscode/launch.json b/examples/nodejs/.vscode/launch.json
index aeb9f4e..47501f7 100644
--- a/examples/nodejs/.vscode/launch.json
+++ b/examples/nodejs/.vscode/launch.json
@@ -49,7 +49,19 @@
"localRoot": "${workspaceFolder}",
"remoteRoot": "/code",
"outputCapture": "std"
+ },
+ {
+ "type": "node",
+ "request": "launch",
+ "name": "wskdebug with WSK_PACKAGE",
+ "runtimeExecutable": "wskdebug",
+ "args": [
+ "webaction"
+ ],
+ "localRoot": "${workspaceFolder}",
+ "remoteRoot": "/code",
+ "outputCapture": "std",
+ "envFile": "${workspaceFolder}/.env"
}
-
]
}
\ No newline at end of file
diff --git a/index.js b/index.js
index 96a83cb..0406efe 100644
--- a/index.js
+++ b/index.js
@@ -258,6 +258,10 @@ function normalizeArgs(argv) {
argv.invokeParams = argv.P;
argv.invokeAction = argv.a;
argv.onChange = argv.r;
+
+ if (process.env.WSK_PACKAGE && argv.action && !argv.action.includes("/")) {
+ argv.action = `${process.env.WSK_PACKAGE}/${argv.action}`;
+ }
}
function printErrorAndExit(err, argv) {
diff --git a/test/wskdebug.test.js b/test/wskdebug.test.js
index ca8e941..959168e 100644
--- a/test/wskdebug.test.js
+++ b/test/wskdebug.test.js
@@ -22,13 +22,32 @@
// tests basic cli
-const wskdebug = require('../index');
+let wskdebug = require('../index');
const test = require('./test');
const assert = require('assert');
const stripAnsi = require('strip-ansi');
const {execSync} = require('child_process');
+const mockRequire = require('mock-require');
+
+function mockDebugger() {
+ const receivedArgv = {};
+
+ class MockDebugger {
+ constructor(argv) {
+ Object.assign(receivedArgv, argv);
+ }
+
+ start() {}
+ run() {}
+ }
+
+ mockRequire("../src/debugger", MockDebugger);
+ wskdebug = mockRequire.reRequire("../index");
+ return receivedArgv;
+}
+
describe('wskdebug cli', function() {
it("should print version (via wskdebug.js)", async function() {
@@ -66,4 +85,25 @@ describe('wskdebug cli', function() {
assert.equal(stripAnsi(stdio.stdout.trim()), require(`${process.cwd()}/package.json`).version);
});
+ it("should take action argument", async function() {
+ const argv = mockDebugger();
+
+ await wskdebug(`action`);
+ assert.strictEqual(argv.action, "action");
+
+ await wskdebug(`package/action`);
+ assert.strictEqual(argv.action, "package/action");
+ });
+
+ it("should use WSK_PACKAGE env var as package name", async function() {
+ const argv = mockDebugger();
+
+ process.env.WSK_PACKAGE = "envPackage";
+ await wskdebug(`action`);
+ assert.strictEqual(argv.action, "envPackage/action");
+
+ // cli package takes precedence
+ await wskdebug(`package/action`);
+ assert.strictEqual(argv.action, "package/action");
+ });
});