@risingstack/trace-cli
Advanced tools
| 'use strict' | ||
| const program = require('commander') | ||
| const merge = require('lodash.merge') | ||
| const deployhook = require('../lib/deployhook') | ||
| program | ||
| .usage('<args ...>') | ||
| .option('-g, --git [value]', 'use last GIT commit for revision, description and user') | ||
| .option('-r, --revision [value]', 'deploy revision, like GIT short hash') | ||
| .option('-m, --message [value]', 'deploy message, like commit message') | ||
| .option('-u, --user [value]', 'deploy created by, like committer') | ||
| .option('--api-key [value]', 'TRACE_API_KEY from Trace') | ||
| .option('--service-name [value]', 'TRACE_SERVICE_NAME from Trace') | ||
| .parse(process.argv) | ||
| // output help by default | ||
| if (!process.argv.slice(2).length) { | ||
| program.outputHelp() | ||
| process.exit(1) | ||
| } | ||
| const apiKey = program.apiKey || process.env.TRACE_API_KEY | ||
| const serviceName = program.serviceName || process.env.TRACE_SERVICE_NAME | ||
| // validation | ||
| if (!apiKey) { | ||
| console.error('--api-key argument or TRACE_API_KEY environment variable is required') | ||
| process.exit(1) | ||
| } | ||
| if (!serviceName) { | ||
| console.error('--serice-name argument or TRACE_SERVICE_NAME environment variable is required') | ||
| process.exit(1) | ||
| } | ||
| // deploy data | ||
| let revision = { | ||
| revision: '', | ||
| description: '', | ||
| user: '' | ||
| } | ||
| // from git | ||
| if (program.git) { | ||
| const gitRevision = deployhook.revision.getGIT() | ||
| revision = merge(revision, gitRevision) | ||
| } | ||
| // from arguments | ||
| const argumentRevision = { | ||
| revision: program.revision, | ||
| description: program.message, | ||
| user: program.user | ||
| } | ||
| revision = merge(revision, argumentRevision) | ||
| // send to Trace | ||
| deployhook.api.send(apiKey, serviceName, revision, function (err) { | ||
| if (err) { | ||
| console.error(`Deployhook rejected: ${err.message}`) | ||
| process.exit(1) | ||
| } | ||
| console.log('Deployhook accepted!') | ||
| process.exit(0) | ||
| }) |
| 'use strict' | ||
| const expect = require('chai').expect | ||
| const execSync = require('child_process').execSync | ||
| const path = require('path') | ||
| const cli = path.join(__dirname, 'cli-deployhook') | ||
| describe('deployhook', function () { | ||
| it('should reject without api key', () => { | ||
| const fn = () => { | ||
| execSync(`node ${cli} --service-name foo`).toString() | ||
| } | ||
| expect(fn).to.throw(/TRACE_API_KEY/) | ||
| }) | ||
| it('should reject without service name', () => { | ||
| const fn = () => { | ||
| execSync(`node ${cli} --api-key bar`).toString() | ||
| } | ||
| expect(fn).to.throw(/TRACE_SERVICE_NAME/) | ||
| }) | ||
| }) |
| #!/usr/bin/env node | ||
| 'use strict' | ||
| const program = require('commander') | ||
| const pkg = require('../package.json') | ||
| program | ||
| .version(pkg.version) | ||
| .usage('[subcommand] <args ...>') | ||
| .description('Example: trace-cli deployhook --git') | ||
| .command('deployhook', 'Sends deployhook to highlight your application versions in Trace') | ||
| .parse(process.argv) |
+2
-2
| { | ||
| "name": "@risingstack/trace-cli", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "CLI for Trace by RisingStack", | ||
@@ -22,3 +22,3 @@ "main": "index.js", | ||
| "bin": { | ||
| "trace-cli": "./bin/cli.js" | ||
| "trace-cli": "./bin/trace-cli.js" | ||
| }, | ||
@@ -25,0 +25,0 @@ "dependencies": { |
| 'use strict' | ||
| const program = require('commander') | ||
| const merge = require('lodash.merge') | ||
| const deployhook = require('../lib/deployhook') | ||
| program | ||
| .usage('<args ...>') | ||
| .option('-g, --git [value]', 'use last GIT commit for revision, description and user') | ||
| .option('-r, --revision [value]', 'deploy revision, like GIT short hash') | ||
| .option('-m, --message [value]', 'deploy message, like commit message') | ||
| .option('-u, --user [value]', 'deploy created by, like committer') | ||
| .option('--api-key [value]', 'TRACE_API_KEY from Trace') | ||
| .option('--service-name [value]', 'TRACE_SERVICE_NAME from Trace') | ||
| .parse(process.argv) | ||
| // output help by default | ||
| if (!process.argv.slice(2).length) { | ||
| program.outputHelp() | ||
| process.exit(1) | ||
| } | ||
| const apiKey = program.apiKey || process.env.TRACE_API_KEY | ||
| const serviceName = program.serviceName || process.env.TRACE_SERVICE_NAME | ||
| // validation | ||
| if (!apiKey) { | ||
| console.error('--api-key argument or TRACE_API_KEY environment variable is required') | ||
| process.exit(1) | ||
| } | ||
| if (!serviceName) { | ||
| console.error('--serice-name argument or TRACE_SERVICE_NAME environment variable is required') | ||
| process.exit(1) | ||
| } | ||
| // deploy data | ||
| let revision = { | ||
| revision: '', | ||
| description: '', | ||
| user: '' | ||
| } | ||
| // from git | ||
| if (program.git) { | ||
| const gitRevision = deployhook.revision.getGIT() | ||
| revision = merge(revision, gitRevision) | ||
| } | ||
| // from arguments | ||
| const argumentRevision = { | ||
| revision: program.revision, | ||
| description: program.message, | ||
| user: program.user | ||
| } | ||
| revision = merge(revision, argumentRevision) | ||
| // send to Trace | ||
| deployhook.api.send(apiKey, serviceName, revision, function (err) { | ||
| if (err) { | ||
| console.error(`Deployhook rejected: ${err.message}`) | ||
| process.exit(1) | ||
| } | ||
| console.log('Deployhook accepted!') | ||
| process.exit(0) | ||
| }) |
| 'use strict' | ||
| const expect = require('chai').expect | ||
| const execSync = require('child_process').execSync | ||
| const path = require('path') | ||
| const cli = path.join(__dirname, 'cli-deployhook') | ||
| describe('deployhook', function () { | ||
| it('should reject without api key', () => { | ||
| const fn = () => { | ||
| execSync(`node ${cli} --service-name foo`).toString() | ||
| } | ||
| expect(fn).to.throw(/TRACE_API_KEY/) | ||
| }) | ||
| it('should reject without service name', () => { | ||
| const fn = () => { | ||
| execSync(`node ${cli} --api-key bar`).toString() | ||
| } | ||
| expect(fn).to.throw(/TRACE_SERVICE_NAME/) | ||
| }) | ||
| }) |
-12
| #!/usr/bin/env node | ||
| 'use strict' | ||
| const program = require('commander') | ||
| const pkg = require('../package.json') | ||
| program | ||
| .version(pkg.version) | ||
| .usage('[subcommand] <args ...>') | ||
| .description('Example: trace-cli deployhook --git') | ||
| .command('deployhook', 'Sends deployhook to highlight your application versions in Trace') | ||
| .parse(process.argv) |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
10326
0.06%