### Command-Line Utility: Basic Usage of Semver Source: https://github.com/snyk/cli/blob/main/test/fixtures/dev-deps-demo/node_modules/semver/README.md Shows how to install and use the semver tool from the command line. This example covers basic installation and accessing help information. The utility assists in version testing and sorting. ```bash npm install semver semver -h ``` -------------------------------- ### Configstore Usage Example in JavaScript Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/clite/node_modules/configstore/readme.md Demonstrates how to initialize a Configstore instance with a package name and default values, set and get configuration items, and delete items. It shows how nested keys can be used and how to access all configuration data. Requires the 'configstore' and './package.json' modules. ```javascript const Configstore = require('configstore'); const pkg = require('./package.json'); // Init a Configstore instance with an unique ID e.g. // package name and optionally some default values const conf = new Configstore(pkg.name, {foo: 'bar'}); conf.set('awesome', true); console.log(conf.get('awesome')); //=> true console.log(conf.get('foo')); //=> bar conf.set('bar.baz', true); console.log(conf.get('bar')); //=> { baz: true } console.log(conf.all); //=> { foo: 'bar', awesome: true, bar: { baz: true } } conf.del('awesome'); console.log(conf.get('awesome')); //=> undefined ``` -------------------------------- ### Provide Example Invocations Source: https://github.com/snyk/cli/blob/main/test/fixtures/uglify-package/node_modules/ug-deep-alt/node_modules/uglify-js/node_modules/yargs/README.md Use the `.example()` method to provide example command-line invocations of your program. The string `$0` in the command string will be replaced with the script name. These examples are displayed in the help message to guide users. ```javascript var argv = require('yargs') .usage('$0 --input --output ') .example('$0 --input data.txt --output results.txt', 'Process data.txt and save to results.txt') .argv; ``` -------------------------------- ### Install and Use extsprintf for Formatted Output Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/extsprintf/README.md Demonstrates how to install the extsprintf library using npm and provides an example of its usage for formatted string output. This snippet shows basic string alignment. ```bash npm install extsprintf ``` ```javascript var mod_extsprintf = require('extsprintf'); console.log(mod_extsprintf.sprintf('hello %25s', 'world')); ``` -------------------------------- ### Define Git-style Sub-commands in Node.js Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/commander/Readme.md This example demonstrates how to define Git-style sub-commands for a Node.js application using the commander.js library. It sets up commands like 'install', 'search', and a default 'list' command. When a command is provided with a description, commander expects separate executables (e.g., 'pm-install') to handle the sub-command logic, similar to how tools like git manage their sub-commands. Options like `noHelp` and `isDefault` can be passed to customize command behavior and help output. Ensure executables have appropriate permissions (e.g., 755) if installed globally. ```javascript var program = require('..'); program .version('0.0.1') .command('install [name]', 'install one or more packages') .command('search [query]', 'search with optional query') .command('list', 'list packages installed', {isDefault: true}) .parse(process.argv); ``` -------------------------------- ### Create a Promise Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/promise/Readme.md Demonstrates creating a new Promise from scratch. The constructor takes a function with `resolve` and `reject` arguments. This example shows asynchronous operation using a hypothetical `get` function. ```javascript var Promise = require('promise'); var promise = new Promise(function (resolve, reject) { get('http://www.google.com', function (err, res) { if (err) reject(err); else resolve(res); }); }); ``` -------------------------------- ### Install Dev Dependencies and Run Tests with npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/dev-deps-demo/node_modules/kind-of/README.md This command installs development dependencies and then runs the test suite for the project using npm. It's a standard command for setting up a development environment and verifying the project's integrity. ```sh npm i -d && npm test ``` -------------------------------- ### Install RxJS with Jam Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/rx/readme.md This command installs the RxJS library using Jam, another package manager for front-end JavaScript. Similar to Bower, it's used for managing client-side dependencies. The `jam install rx` command fetches and installs the RxJS package. ```bash $ jam install rx ``` -------------------------------- ### Install cli-width using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/cli-width/README.md Installs the cli-width package as a dependency for your project. ```bash npm install --save cli-width ``` -------------------------------- ### Enable Compressor with Options Source: https://github.com/snyk/cli/blob/main/test/fixtures/uglify-package/node_modules/ug-deep-alt/node_modules/uglify-js/README.md This demonstrates how to enable the compressor using the --compress or -c flag. It also shows how to pass a comma-separated list of specific options, such as 'properties' or 'dead_code', to fine-tune the compression process. ```bash # Enable compressor with default options snyk cli --compress # Enable compressor with specific options snyk cli --compress=properties,dead_code ``` -------------------------------- ### Install node-uuid in Node.js Source: https://github.com/snyk/cli/blob/main/test/acceptance/workspaces/large-mono-repo/npm-project-10/node_modules/node-uuid/README.md Install the node-uuid library using npm. This command downloads and installs the package, making it available for use in your Node.js projects. After installation, you can require the module to start using its functionalities. ```bash npm install node-uuid ``` -------------------------------- ### Install verb and generate documentation Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/repeat-string/README.md Shows how to install the 'verb' documentation generator and run the documentation generation script. This is used for building the project's readme and API documentation. ```sh npm install verb && npm run docs ``` -------------------------------- ### Install os-locale using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/os-locale/readme.md This snippet demonstrates how to install the os-locale package using npm. It's a standard Node.js package installation command. ```bash npm install --save os-locale ``` -------------------------------- ### Install latest-version npm package Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/update-notifier/node_modules/latest-version/readme.md Installs the 'latest-version' package as a project dependency. ```sh npm install --save latest-version ``` -------------------------------- ### Basic Clite CLI Script Setup (Node.js) Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/clite/README.md This snippet demonstrates the fundamental setup for a CLI script using the Clite framework. It requires the 'clite' module and initializes it with a configuration object. The script expects the configuration to return a string or throw an error. This is the entry point for most Clite-based CLI tools. ```javascript #!/usr/bin/env node var clite = require('clite'); clite(require('./config')); ``` -------------------------------- ### Install xdg-basedir with npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/xdg-basedir/readme.md This command installs the xdg-basedir package as a dependency for your Node.js project using npm. Ensure you have Node.js and npm installed. ```bash npm install --save xdg-basedir ``` -------------------------------- ### Install semver-diff npm package Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/semver-diff/readme.md Installs the semver-diff package as a dependency for your project using npm. ```sh npm install --save semver-diff ``` -------------------------------- ### Install RxJS via NuGet Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/rx/readme.md These commands demonstrate how to install RxJS packages using NuGet, a package manager for .NET. The first command installs all RxJS components, while subsequent commands show how to install individual packages for more granular control over dependencies. This is relevant for developers integrating RxJS into .NET projects. ```powershell $Install-Package RxJS-All $Install-Package RxJS-Lite $Install-Package RxJS-Main $Install-Package RxJS-Aggregates $Install-Package RxJS-Async $Install-Package RxJS-BackPressure $Install-Package RxJS-Binding $Install-Package RxJS-Coincidence $Install-Package RxJS-Experimental $Install-Package RxJS-JoinPatterns $Install-Package RxJS-Testing $Install-Package RxJS-Time ``` -------------------------------- ### Install win-release with npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/win-release/readme.md This command installs the win-release package as a dependency for your Node.js project using npm. ```bash npm install --save win-release ``` -------------------------------- ### Helper Setup and Parameter Handling (JavaScript) Source: https://github.com/snyk/cli/blob/main/test/fixtures/hbs-demo/node_modules/handlebars/coverage/lcov-report/dist/cjs/handlebars/compiler/javascript-compiler.js.html Sets up parameters and options for Handlebars helpers. `setupHelper` prepares parameters and looks up helper information. `setupParams` formats these parameters, potentially including options, and handles register usage. `setupOptions` manages the stack for options, hash parameters, and program/inverse functions, supporting features like ID tracking and string parameters. ```javascript setupHelper: function(paramSize, name, blockHelper) { var params = [], paramsInit = this.setupParams(name, paramSize, params, blockHelper); var foundHelper = this.nameLookup('helpers', name, 'helper'); return { params: params, paramsInit: paramsInit, name: foundHelper, callParams: [this.contextName(0)].concat(params).join(", ") }; }, setupOptions: function(helper, paramSize, params) { var options = {}, contexts = [], types = [], ids = [], param, inverse, program; options.name = this.quotedString(helper); options.hash = this.popStack(); if (this.trackIds) { options.hashIds = this.popStack(); } if (this.stringParams) { options.hashTypes = this.popStack(); options.hashContexts = this.popStack(); } inverse = this.popStack(); program = this.popStack(); // Avoid setting fn and inverse if neither are set. This allows // helpers to do a check for `if (options.fn)` if (program || inverse) { if (!program) { program = 'this.noop'; } if (!inverse) { inverse = 'this.noop'; } options.fn = program; options.inverse = inverse; } // The parameters go on to the stack in order (making sure that they are evaluated in order) // so we need to pop them off the stack in reverse order var i = paramSize; while (i--) { param = this.popStack(); params[i] = param; if (this.trackIds) { ids[i] = this.popStack(); } if (this.stringParams) { types[i] = this.popStack(); contexts[i] = this.popStack(); } } if (this.trackIds) { options.ids = "[" + ids.join(",") + "]"; } if (this.stringParams) { options.types = "[" + types.join(",") + "]"; options.contexts = "[" + contexts.join(",") + "]"; } if (this.options.data) { options.data = "data"; } return options; }, // the params and contexts arguments are passed in arrays // to fill in setupParams: function(helperName, paramSize, params, useRegister) { var options = this.objectLiteral(this.setupOptions(helperName, paramSize, params)); if (useRegister) { this.useRegister('options'); params.push('options'); return 'options=' + options; } else { params.push(options); return ''; } } ``` -------------------------------- ### Install latest-version globally for CLI usage Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/update-notifier/node_modules/latest-version/readme.md Installs the 'latest-version' package globally, making its command-line interface (CLI) available on the system. ```sh npm install --global latest-version ``` -------------------------------- ### Hyphen Range Syntax Examples Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/snyk-policy/node_modules/semver/README.md Demonstrates how hyphen ranges (inclusive version sets) are interpreted into primitive comparators. It covers cases with partial version inputs and shows the desugared form for each example. ```text * `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` * `1.2 - 2.3.4` := `>=1.2.0 <=2.3.4` * `1.2.3 - 2.3` := `>=1.2.3 <2.4.0` * `1.2.3 - 2` := `>=1.2.3 <3.0.0` ``` -------------------------------- ### Install package-json module Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/package-json/readme.md This snippet shows how to install the 'package-json' module using npm. It is a dependency for using the module's functionality. ```bash $ npm install --save package-json ``` -------------------------------- ### Install tempfile using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/tempfile/readme.md This command installs the tempfile package as a project dependency using npm. It adds the package to your package.json file. ```sh $ npm install --save tempfile ``` -------------------------------- ### X-Range Syntax Examples Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/snyk-policy/node_modules/semver/README.md Illustrates the usage of X-Ranges (using 'X', 'x', or '*') as wildcards in version ranges. It shows how these wildcards are expanded into specific comparator sets, including handling of empty strings and partial versions. ```text * `*` := `>=0.0.0` * `1.x` := `>=1.0.0 <2.0.0` * `1.2.x` := `>=1.2.0 <1.3.0` * `""` (empty string) := `*` := `>=0.0.0` * `1` := `1.x.x` := `>=1.0.0 <2.0.0` * `1.2` := `1.2.x` := `>=1.2.0 <1.3.0` ``` -------------------------------- ### Install string-width with npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/string-width/readme.md Installs the string-width module using the npm package manager. This is the standard way to add the package as a dependency to your Node.js project. ```bash $ npm install --save string-width ``` -------------------------------- ### Scan .NET Projects from Solution File Source: https://github.com/snyk/cli/blob/main/help/cli-commands/sbom.md The `--file=.sln` option enables testing of all .NET projects included within the specified solution file. All referenced projects must have supported manifests. ```bash snyk --file=myproject.sln ``` -------------------------------- ### Basic Chalk Usage Examples Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/chalk/readme.md Demonstrates fundamental ways to use Chalk for styling strings in the terminal. Includes styling individual strings, combining styled and unstyled strings, composing multiple styles, and passing multiple arguments. ```javascript var chalk = require('chalk'); // style a string chalk.blue('Hello world!'); // combine styled and normal strings chalk.blue('Hello') + 'World' + chalk.red('!'); // compose multiple styles using the chainable API chalk.blue.bgRed.bold('Hello world!'); // pass in multiple arguments chalk.blue('Hello', 'World!', 'Foo', 'bar', 'biz', 'baz'); // nest styles chalk.red('Hello', chalk.underline.bgBlue('world') + '!'); // nest styles of the same type even (color, underline, background) chalk.green( 'I am a green line ' + chalk.blue.underline.bold('with a blue substring') + ' that becomes green again!' ); ``` -------------------------------- ### Install node-uuid Globally Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/node-uuid/README.md Provides the command to install the `node-uuid` library globally using npm, enabling the use of the `uuid` command-line interface. This is a prerequisite for using the CLI examples. ```bash npm install -g node-uuid ``` -------------------------------- ### Install os-name package Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/os-name/readme.md Installs the 'os-name' package as a project dependency using npm. This allows the module to be required and used within your Node.js application. ```sh $ npm install --save os-name ``` -------------------------------- ### Tilde Range Syntax Examples Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/snyk-policy/node_modules/semver/README.md Explains Tilde Ranges, which allow for patch-level or minor-level changes depending on the version specified. It shows how these ranges are converted to equivalent primitive comparators, including handling of prereleases. ```text * `~1.2.3` := `>=1.2.3 <1.3.0` * `~1.2` := `>=1.2.0 <1.3.0` * `~1` := `>=1.0.0 <2.0.0` * `~0.2.3` := `>=0.2.3 <0.3.0` * `~0.2` := `>=0.2.0 <0.3.0` * `~0` := `>=0.0.0 <1.0.0` * `~1.2.3-beta.2` := `>=1.2.3-beta.2 <1.3.0` ``` -------------------------------- ### Install 'longest' with npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/longest/README.md This snippet shows how to install the 'longest' package using npm, a popular JavaScript package manager. It adds the package as a project dependency. ```bash npm i longest --save ``` -------------------------------- ### Initialize and Use Configstore in JavaScript Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/configstore/readme.md This snippet demonstrates how to initialize a Configstore instance with a package name and optional default values, set, get, and delete configuration items. It requires the 'configstore' module and a 'package.json' file. ```javascript const Configstore = require('configstore'); const pkg = require('./package.json'); // Init a Configstore instance with an unique ID e.g. // package name and optionally some default values const conf = new Configstore(pkg.name, {foo: 'bar'}); conf.set('awesome', true); console.log(conf.get('awesome')); //=> true console.log(conf.get('foo')); //=> bar conf.del('awesome'); console.log(conf.get('awesome')); //=> undefined ``` -------------------------------- ### Initializing Compression Loop (C) Source: https://github.com/snyk/cli/blob/main/test/acceptance/workspaces/unmanaged/deps/zlib-1.2.11.1/examples/zlib_how.html This snippet initiates a do-while loop designed to process input data through the deflate() function until all output buffers are full or compression is complete. It's a core part of the data compression workflow. ```c /* run deflate() on input until output buffer not full, finish compression if all of source has been read in */ do { ``` -------------------------------- ### Install widest-line with npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/widest-line/readme.md This command installs the widest-line package as a project dependency using npm. It ensures the package is available for use in your Node.js project. ```bash $ npm install --save widest-line ``` -------------------------------- ### Install kind-of using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/kind-of/README.md This command installs the 'kind-of' package as a project dependency using npm. It's a common way to add libraries to Node.js projects. ```sh npm install kind-of --save ``` -------------------------------- ### Install dev dependencies and run benchmarks Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/repeat-string/README.md This command installs the necessary development dependencies for running benchmarks and then executes the benchmark script. It helps in comparing the performance of 'repeat-string' against native methods. ```sh npm i -d && node benchmark ``` -------------------------------- ### Install 'longest' with bower Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/longest/README.md This snippet demonstrates how to install the 'longest' package using bower, a web development package manager. It also adds the package as a project dependency. ```bash bower install longest --save ``` -------------------------------- ### Install run-async Package Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/run-async/README.md Installs the 'run-async' package as a dependency for your project using npm. ```bash npm install --save run-async ``` -------------------------------- ### Install latest-version using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/latest-version/readme.md This command installs the 'latest-version' package as a project dependency using npm. It ensures the package is available for use in your Node.js project. ```bash $ npm install --save latest-version ``` -------------------------------- ### Basic nconf Configuration Setup and Usage (Node.js) Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/nconf/README.md Demonstrates setting up nconf to prioritize command-line arguments, environment variables, and a configuration file. It shows how to set and retrieve configuration values, including nested objects, and save the configuration back to a file. Dependencies include the 'fs' module. ```javascript var fs = require('fs'); var nconf = require('nconf'); // Setup nconf to use: // 1. Command-line arguments // 2. Environment variables // 3. A file located at 'path/to/config.json' nconf.argv() .env() .file({ file: 'path/to/config.json' }); // Set a few variables on `nconf`. nconf.set('database:host', '127.0.0.1'); nconf.set('database:port', 5984); // Get the entire database object from nconf. console.log('foo: ' + nconf.get('foo')); console.log('NODE_ENV: ' + nconf.get('NODE_ENV')); console.log('database: ' + JSON.stringify(nconf.get('database'))); // Save the configuration object to disk nconf.save(function (err) { if (err) { console.error('Error saving config:', err); return; } fs.readFile('path/to/config.json', function (err, data) { if (err) { console.error('Error reading saved config:', err); return; } console.dir(JSON.parse(data.toString())); }); }); ``` -------------------------------- ### Install kind-of using npm or Bower Source: https://github.com/snyk/cli/blob/main/test/fixtures/dev-deps-demo/node_modules/kind-of/README.md This snippet shows how to install the 'kind-of' utility using either npm or Bower package managers. It is a prerequisite for using the library in your project. ```shell $ npm i kind-of --save ``` ```shell $ bower install kind-of --save ``` -------------------------------- ### Setting Output Buffer for Deflate (C) Source: https://github.com/snyk/cli/blob/main/test/acceptance/workspaces/unmanaged/deps/zlib-1.2.11.1/examples/zlib_how.html This snippet shows how to prepare the output buffer for the deflate() function by setting the available output bytes (strm.avail_out) and the pointer to the output buffer (strm.next_out). ```c strm.avail_out = CHUNK; strm.next_out = out; ``` -------------------------------- ### Install os-name globally for CLI usage Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/os-name/readme.md Installs the 'os-name' package globally, making its command-line interface (CLI) available on your system. This allows you to run 'os-name' directly from the terminal. ```sh $ npm install --global os-name ``` -------------------------------- ### Install kind-of using bower Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/kind-of/README.md This command installs the 'kind-of' package using the bower package manager. Bower is a client-side package manager, often used for front-end web development. ```sh bower install kind-of --save ``` -------------------------------- ### Install RxJS with NPM Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/rx/readme.md These commands show how to install the RxJS library using NPM, the Node Package Manager. The first command installs it locally for a project, and the second installs it globally, making it available system-wide. This is a primary method for managing JavaScript dependencies. ```bash $ npm install rx $ npm install -g rx ``` -------------------------------- ### Install string-length using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/string-length/readme.md Installs the 'string-length' package as a project dependency. This package is used to accurately measure string lengths, especially those containing astral symbols or ANSI escape codes. ```bash $ npm install --save string-length ``` -------------------------------- ### Providing Example Invocations in Yargs Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/clite/node_modules/yargs/README.md Explains how to use the `.example()` method in Yargs to provide sample command-line invocations. The `$0` placeholder is automatically replaced with the current script name. ```javascript .example('mycommand --foo', 'do the foo thing') ``` -------------------------------- ### Install registry-url using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/registry-url/readme.md Install the registry-url package as a dependency for your project using npm. This command adds the package to your project's node_modules directory and updates your package.json file. ```bash $ npm install --save registry-url ``` -------------------------------- ### Main Routine for Compression/Decompression Source: https://github.com/snyk/cli/blob/main/test/acceptance/workspaces/unmanaged/deps/zlib-1.2.11.1/examples/zlib_how.html The main entry point for the command-line utility. It handles command-line arguments to determine whether to perform compression (default or with arguments) or decompression (with '-d' argument). It also sets the binary mode for stdin/stdout and reports usage errors. ```c int main(int argc, char **argv) { int ret; /* avoid end-of-line conversions */ SET_BINARY_MODE(stdin); SET_BINARY_MODE(stdout); /* do compression if no arguments */ if (argc == 1) { ret = def(stdin, stdout, Z_DEFAULT_COMPRESSION); if (ret != Z_OK) zerr(ret); return ret; } /* do decompression if -d specified */ else if (argc == 2 && strcmp(argv[1], "-d") == 0) { ret = inf(stdin, stdout); if (ret != Z_OK) zerr(ret); return ret; } /* otherwise, report usage */ else { fputs("zpipe usage: zpipe [-d] < source > dest\n", stderr); return 1; } } ``` -------------------------------- ### Hawk Server URI Authentication Example (Node.js) Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/hawk/README.md Illustrates how to implement server-side URI authentication using Hawk in a Node.js HTTP server. This example shows how to authenticate incoming requests based on bewit credentials. ```javascript var Http = require('http'); var Hawk = require('hawk'); // Credentials lookup function var credentialsFunc = function (id, callback) { var credentials = { key: 'werxhqb98rpaxn39848xrunpaw3489ruxnpa98w4rxn', algorithm: 'sha256' }; return callback(null, credentials); }; // Create HTTP server var handler = function (req, res) { Hawk.uri.authenticate(req, credentialsFunc, {}, function (err, credentials, attributes) { res.writeHead(!err ? 200 : 401, { 'Content-Type': 'text/plain' }); res.end(!err ? 'Access granted' : 'Shoosh!'); }); }; Http.createServer(handler).listen(8000, 'example.com'); ``` -------------------------------- ### Install osx-release using npm Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/osx-release/readme.md Installs the 'osx-release' package as a project dependency using npm. This command is typically run in the root directory of a Node.js project. ```sh #!/bin/bash npm install --save osx-release ``` -------------------------------- ### Install Snyk CLI Development Dependencies (Bash) Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/bluebird/README.md This command sequence outlines the initial steps for setting up the Snyk CLI development environment. It involves cloning the repository and installing the necessary development dependencies using npm. Prerequisites include having Node.js and npm installed. ```bash git clone git@github.com:petkaantonov/bluebird.git cd bluebird npm install ``` -------------------------------- ### Install osx-release globally for CLI usage Source: https://github.com/snyk/cli/blob/main/test/fixtures/qs-package/node_modules/osx-release/readme.md Installs the 'osx-release' package globally using npm, making its command-line interface available system-wide. This is useful for running the tool directly from the terminal. ```sh #!/bin/bash npm install --global osx-release ```