### Mime Module Quick Start Examples Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/mime/src/README_js.md Basic usage examples for the Mime module, showing how to get the MIME type from an extension and the extension from a MIME type. ```javascript const mime = require('mime'); mime.getType('txt'); mime.getExtension('text/plain'); ``` -------------------------------- ### Create and Listen with ldapjs Server Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/spartan/index.html Initializes an ldapjs server instance and starts listening on a specified port. This is the foundational step for any ldapjs server application. It requires the 'ldapjs' library to be installed. ```javascript var ldap = require('ldapjs'); var server = ldap.createServer(); server.listen(1389, function() { console.log('/etc/passwd LDAP server up at: %s', server.url); }); ``` -------------------------------- ### Setup Failure Debugging Commands Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Offers commands for debugging setup failures on the headnode. This includes checking SMF service logs, examining zone setup status, accessing zone-specific logs after `zlogin`, and performing a factory reset to re-run setup. ```bash # Check headnode setup service logs svcs -L init cat /var/svc/log/system-smartdc-init:default.log # Check zone setup status cat /var/lib/setup.json | json # Zone-specific logs (after zlogin to zone) svcs -L mdata:fetch svcs -L mdata:execute cat /var/svc/setup.log ls -la /var/svc/setup_complete # Factory reset and re-run setup sdc-factoryreset ``` -------------------------------- ### Basic CLI Argument Parsing with Environment Variable Support (JavaScript) Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/cmdln/node_modules/dashdash/TODO.txt Illustrates a basic setup for parsing command-line arguments using 'dashdash' in Node.js. This example shows how to define an option that can be controlled by both a command-line flag and a corresponding environment variable. ```javascript var dashdash = require('dashdash'); var options = [{name: 'v', env: 'FOO_VERBOSE', type: 'bool'}]; var parser = new dashdash.Parser({options: options}); var opts = parser.parse(process.argv); ``` -------------------------------- ### scripts/headnode.sh - Main Setup Script Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt The primary setup script that runs during first boot to configure the headnode and create core zones. It orchestrates the setup of various services. ```APIDOC ## scripts/headnode.sh - Main Setup Script ### Description The primary setup script that runs during first boot to configure the headnode and create core zones. It orchestrates the setup of various services. ### Method Shell script execution ### Endpoint N/A ### Parameters None ### Request Example ```bash # Automatically executed by SMF service during boot # Manual execution (for debugging): /mnt/usbkey/scripts/headnode.sh ``` ### Response N/A (Script execution output) ### Response Example Output indicates the progress and success/failure of zone setup. ``` -------------------------------- ### Install isarray using component Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/readable-stream/node_modules/isarray/README.md Instructions for installing the 'isarray' package using component, a front-end package manager. ```bash $ component install juliangruber/isarray ``` -------------------------------- ### Install ldapjs using npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/spartan/index.md This command installs the ldapjs library, a Node.js module for building LDAP clients and servers. Ensure Node.js and npm are installed beforehand. ```bash npm install ldapjs ``` -------------------------------- ### scripts/joysetup.sh - Initial Zpool Setup Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Creates the zones ZFS pool during initial headnode setup. This script is automatically called by `headnode.sh` and can be configured via `answers.json`. ```APIDOC ## scripts/joysetup.sh - Initial Zpool Setup ### Description Creates the zones ZFS pool during initial headnode setup. This script is automatically called by `headnode.sh` and can be configured via `answers.json`. ### Method Shell script execution ### Endpoint N/A ### Parameters #### Request Body - **answers.json** (file) - Optional configuration file for disk layout, spares, width, and exclusions. - **layout** (string) - `single`, `mirror`, `raidz1`, `raidz2`, `raidz3` - **spares** (integer) - Number of hot spare disks. - **width** (integer) - Stripe width for RAIDZ layouts. - **exclude** (string) - Comma-separated list of disks to exclude. ### Request Example ```bash # Automatically called by headnode.sh # Creates 'zones' zpool from available disks ``` ### Response N/A (Script execution output) ### Response Example Output indicates the creation and status of the 'zones' ZFS pool. ``` -------------------------------- ### Automated Headnode Setup Configuration (JSON) Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Provides pre-configured answers for headnode setup, enabling unattended installation. This JSON file specifies network settings, datacenter details, and administrative credentials. ```json // answers.json.tmpl.external - COAL with external network { "config_console": "vga", "skip_instructions": true, "simple_headers": true, "skip_final_confirm": true, "skip_edit_config": true, "skip_dns_check": true, "datacenter_company_name": "MyCompany", "region_name": "us-west", "datacenter_name": "dc01", "datacenter_location": "San Francisco", "admin_nic": "00:50:56:34:60:4c", "admin_ip": "10.99.99.7", "admin_netmask": "255.255.255.0", "admin_gateway": "10.99.99.7", "setup_external_network": true, "external_nic": "00:50:56:3d:a7:95", "external_ip": "10.88.88.200", "external_netmask": "255.255.255.0", "external_gateway": "10.88.88.2", "dns_domain": "example.com", "dns_search": "example.com", "dhcp_range_end": "10.99.99.253", "root_password": "securepassword", "admin_password": "adminpass123", "install_pkgsrc": true, "update_channel": "release" } ``` -------------------------------- ### Install isarray using npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/readable-stream/node_modules/isarray/README.md Instructions for installing the 'isarray' package using npm, a popular package manager for Node.js and front-end development. ```bash $ npm install isarray ``` -------------------------------- ### Initial Zpool Setup Script (scripts/joysetup.sh) Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt This script is automatically called by headnode.sh during the initial headnode setup. It is responsible for creating the 'zones' ZFS pool using available disks and supports various disk layout options configurable via answers.json. ```bash # Automatically called by headnode.sh # Creates 'zones' zpool from available disks # Manual disk layout options (via answers.json): # - layout: single, mirror, raidz1, raidz2, raidz3 # - spares: number of hot spare disks # - width: stripe width for raidz layouts # - exclude: comma-separated list of disks to exclude ``` -------------------------------- ### Agent Installation Script (scripts/agentsetup.sh) Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Installs Triton agents on headnode and compute nodes. This script, typically found at /mnt/usbkey/ur-scripts/agents-*.sh, installs essential agents like config-agent, cn-agent, vm-agent, and others for monitoring and management. ```bash # Install agents from USB key bash /mnt/usbkey/ur-scripts/agents-*.sh # Agents installed: # - config-agent: Configuration management # - cn-agent: Compute node agent # - vm-agent: VM lifecycle agent # - net-agent: Network agent # - amon-agent: Monitoring agent # - amon-relay: Monitoring relay # - firewaller: Firewall rules agent # - hagfish-watcher: Metering agent # - cmon-agent: Container monitoring ``` -------------------------------- ### Example User List for Password Generation Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/ohthejoy/index.md This example shows how to define a list of users for whom passwords should be generated during dataset provisioning. It includes 'root' and 'admin' users. ```json { "users": [ { "name": "root" }, { "name": "admin" } ] } ``` -------------------------------- ### Setup Failure Debugging Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Provides commands and locations for debugging setup failures on the headnode, including checking service logs, zone status, and performing a factory reset. ```APIDOC ## Setup Failure Debugging ### Description Provides commands and locations for debugging setup failures on the headnode, including checking service logs, zone status, and performing a factory reset. ### Method Command-line utilities ### Endpoint N/A ### Parameters None ### Request Example ```bash # Check headnode setup service logs svcs -L init cat /var/svc/log/system-smartdc-init:default.log # Check zone setup status cat /var/lib/setup.json | json # Zone-specific logs (after zlogin to zone) svcs -L mdata:fetch svcs -L mdata:execute cat /var/svc/setup.log ls -la /var/svc/setup_complete # Factory reset and re-run setup sdc-factoryreset ``` ### Response N/A (Commands provide diagnostic information or perform actions) ### Response Example Log files and JSON status files will contain relevant debugging information. ``` -------------------------------- ### Installation of assert-plus Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/assert-plus/README.md Provides the command to install the assert-plus library using npm. This is the standard method for adding the package as a dependency to a Node.js project. ```bash npm install assert-plus ``` -------------------------------- ### Install extsprintf using npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/extsprintf/README.md This command installs the extsprintf module from the npm registry. It is a prerequisite for using the module in your Node.js project. ```bash # npm install extsprintf ``` -------------------------------- ### LDAP Search Command Example Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/spartan/index.html This is an example command-line invocation using 'ldapsearch' to query the LDAP server. It demonstrates how to connect, authenticate as 'cn=root', specify the base DN, and filter search results. ```bash ldapsearch -H ldap://localhost:1389 -x -D cn=root -w secret -LLL -b "o=myhost" cn=root ``` -------------------------------- ### Build ISO Installation Image with make iso Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Generates an ISO image suitable for installation on systems with bootable ZFS pool support or virtual machines. This command is specific to SmartOS. The output is an ISO file that can be used to boot and install the headnode. ```bash # Build ISO image (SmartOS only) make iso # Output: iso-master-TIMESTAMP-gSHA.iso # Boot from ISO to install on systems with existing zones pool ``` -------------------------------- ### Install restdown Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/README.md This snippet shows the steps to install the restdown tool by cloning the repository and adding its binary directory to the system's PATH. It also includes optional steps for checking out a specific release tag. ```bash cd /opt git clone https://github.com/trentm/restdown.git cd restdown # Optionally checkout a particular release tag. E.g.: # LATEST_RELEASE_TAG=`git tag -l | grep '[0-9]\+\.[0-9]\+\.[0-9]\+' | tail -1` # git checkout $LATEST_RELEASE_TAG export PATH=`pwd`/bin:$PATH restdown --version restdown --help ``` -------------------------------- ### SDC Headnode Main Setup Script (scripts/headnode.sh) Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt The primary setup script executed during the first boot of an SDC headnode. It configures the headnode and creates essential zones in a specific order, including assets, sapi, binder, and others up to vmapi and adminui. ```bash # Automatically executed by SMF service during boot # Manual execution (for debugging): /mnt/usbkey/scripts/headnode.sh # Setup creates zones in order: # 1. assets (serves boot files) # 2. sapi (service configuration) # 3. binder (DNS) # 4. manatee (PostgreSQL cluster) # 5. moray (key-value store) # 6. amonredis (monitoring cache) # 7. ufds (user directory) # 8. workflow (job orchestration) # 9. amon (monitoring) # 10. sdc (operator tools) # 11. papi (packages) # 12. napi (networking) # 13. rabbitmq (messaging) # 14. imgapi (images) # 15. cnapi (compute nodes) # 16. dhcpd (DHCP server) # 17. fwapi (firewall) # 18. vmapi (VMs) # 19. mahi (authorization) # 20. adminui (web console) ``` -------------------------------- ### Install balanced-match using npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/glob/node_modules/balanced-match/README.md Provides the command to install the balanced-match package using npm, the Node Package Manager. ```bash npm install balanced-match ``` -------------------------------- ### Example Inherited Directories for Zone Dataset Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/ohthejoy/index.md This example illustrates how to specify inherited directories for a dataset of type 'zone-dataset'. It includes '/opt/support' as an inherited directory. ```json { "inherited_directories": [ "/opt/support" ] } ``` -------------------------------- ### scripts/agentsetup.sh - Agent Installation Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Installs Triton agents on headnode and compute nodes. The script name may vary based on the version. ```APIDOC ## scripts/agentsetup.sh - Agent Installation ### Description Installs Triton agents on headnode and compute nodes. The script name may vary based on the version. ### Method Shell script execution ### Endpoint N/A ### Parameters None ### Request Example ```bash # Install agents from USB key bash /mnt/usbkey/ur-scripts/agents-*.sh ``` ### Response N/A (Script execution output) ### Response Example Output indicates the installation status of various Triton agents. ``` -------------------------------- ### Install Git Pre-push Hooks Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/restify-errors/README.md Provides the command to install git pre-push hooks for the project. These hooks help ensure code quality and consistency before commits. ```sh make githooks ``` -------------------------------- ### Install and Use extsprintf for String Formatting Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/cmdln/node_modules/extsprintf/README.md Demonstrates how to install the extsprintf library using npm and then use its sprintf function to format a string with a specified field width. This is useful for aligning text output. ```bash npm install extsprintf ``` ```javascript var mod_extsprintf = require('extsprintf'); console.log(mod_extsprintf.sprintf('hello %25s', 'world')); ``` -------------------------------- ### Install brace-expansion via npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/glob/node_modules/brace-expansion/README.md Instructions for installing the brace-expansion library using npm, the Node Package Manager. This is the standard way to add the package to your project's dependencies. ```bash npm install brace-expansion ``` -------------------------------- ### Automate Headnode Setup with Build Spec (Shell) Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/README.md This command configures local build settings for automating the headnode setup process by creating a local build specification file. It uses a template answer file for external network configurations. ```shell echo '{"answer-file": "answers.json.tmpl.external"}' >build.spec.local ``` -------------------------------- ### GET / Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/ohthejoy/index.md Retrieves the API documentation. Returns HTML documentation or a JSON representation based on the 'Accept' header. ```APIDOC ## GET / ### Description Return this HTML documentation or a JSON representation of the API, depending on the request "Accept" header. ### Method GET ### Endpoint / ### Response #### Success Response (200 OK) Returns either HTML documentation or a JSON object detailing available endpoints and API version. #### Example JSON Response ```json { "endpoints": [ "GET /datasets", "GET /datasets/:id", "GET /datasets/:id/:path", "GET /assets/:path", "PUT /datasets/:uuid", "DELETE /datasets/:uuid", "GET /", "GET /ping" ], "version": "2.2.0", "cloud_name": "sdc" } ``` ``` -------------------------------- ### BasicParser Constructor and Option String Examples (JavaScript) Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/posix-getopt/README.md Illustrates how to instantiate the BasicParser and the format of the optstring argument. The optstring defines available options, whether they take arguments, and their long-option aliases. A leading colon enables silent error reporting. ```javascript var mod_getopt = require('posix-getopt'); // Example option strings: // ':r' Command takes one option with no args: -r // ':ra' Command takes two option with no args: -r and -a // ':raf:' Command takes two option with no args: -r and -a // and a single option that takes an arg: -f // ':f:(file)' Command takes a single option with an argument: -f // -f can also be specified as --file // Instantiate with an option string and arguments var parser = new mod_getopt.BasicParser(':raf:', process.argv); var parserWithLong = new mod_getopt.BasicParser(':f:(file)', process.argv); ``` -------------------------------- ### Get indices of first matching pair of braces using balanced.range Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/glob/node_modules/balanced-match/README.md Illustrates the usage of the balanced.range function, which returns an array containing the start and end indices of the first non-nested matching pair of specified delimiters (e.g., '{' and '}'). ```javascript var balanced = require('balanced-match'); console.log(balanced.range('{', '}', 'pre{in{nested}}post')); console.log(balanced.range('{', '}', 'pre{first}between{second}post')); ``` -------------------------------- ### Get first matching pair of braces using balanced-match Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/glob/node_modules/balanced-match/README.md Demonstrates how to use the balanced-match function to find the first non-nested pair of braces ('{' and '}') within a string. It shows examples with simple strings and with regular expressions for the delimiters. ```javascript var balanced = require('balanced-match'); console.log(balanced('{', '}', 'pre{in{nested}}post')); console.log(balanced('{', '}', 'pre{first}between{second}post')); console.log(balanced(/\s+\{\s+/, /\s+\}\s+/, 'pre { in{nest} } post')); ``` -------------------------------- ### Initialize BasicParser and Parse Simple Short Options Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/posix-getopt/README.md Demonstrates how to initialize a BasicParser with a short option string and an array of arguments, then iterates through the arguments to parse simple short options. It shows the output for each successfully parsed option. ```javascript var mod_getopt = require('getopt') var parser, option; parser = new mod_getopt.BasicParser('la', ['node', 'script', '-l', '-a', 'stuff']); while ((option = parser.getopt()) !== undefined && !option.error) console.error(option); ``` -------------------------------- ### Extend Function.prototype to call a function only once in JavaScript Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/glob/node_modules/once/README.md This example shows how to augment the Function.prototype with a 'once' method, allowing functions to be wrapped directly. This provides a more concise syntax for ensuring a function is called only once. After extending the prototype, you can call `.once()` on any function to get a version that executes only on its first invocation. ```javascript // only has to be done once require('once').proto() function load (file, cb) { cb = cb.once() loader.load('file') loader.once('load', cb) loader.once('error', cb) } ``` -------------------------------- ### Install safe-buffer Package Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/tunnel-agent/node_modules/safe-buffer/README.md This command installs the 'safe-buffer' package using npm, making it available for use in your Node.js project. Ensure you have Node.js and npm installed. ```bash npm install safe-buffer ``` -------------------------------- ### Install process-nextick-args Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/sshpk-agent/node_modules/readable-stream/node_modules/process-nextick-args/readme.md Installs the process-nextick-args package as a dependency for your project. ```bash npm install --save process-nextick-args ``` -------------------------------- ### Install semver package Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/semver/README.md Installs the semver package as a dependency for a Node.js project using npm. ```bash npm install --save semver ``` -------------------------------- ### LDAP Server Initialization and Authentication (Node.js) Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/deps/restdown/examples/spartan/index.html Initializes an LDAP server using the 'ldapjs' library and sets up a root bind handler for authentication. It requires the correct DN and password for administrative access. ```javascript var ldap = require('ldapjs'); var server = ldap.createServer(); server.bind('cn=root', function(req, res, next) { if (req.dn.toString() !== 'cn=root' || req.credentials !== 'secret') return next(new ldap.InvalidCredentialsError()); res.end(); return next(); }); ``` -------------------------------- ### Install getpass Module Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/sshpk/node_modules/getpass/README.md Installs the getpass module using npm. This is the first step to using the module in your Node.js project. ```bash npm install --save getpass ``` -------------------------------- ### Hyphen Range Examples Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/semver/README.md Demonstrates how hyphen ranges specify inclusive version sets. Partial versions are handled by defaulting missing components to zero or by setting upper bounds. ```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 ``` -------------------------------- ### Run precond Unit Tests Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/backoff/node_modules/precond/README.md This snippet demonstrates how to execute the unit tests for the 'precond' package using npm. Running tests ensures the library is functioning as expected. ```bash npm test ``` -------------------------------- ### Initialize and Use LRU Cache Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/lru-cache/README.md Demonstrates how to initialize an LRU cache with custom options and perform basic operations like setting and getting values. It also highlights support for non-string keys and cache resetting. ```javascript var LRU = require("lru-cache") , options = { max: 500 , length: function (n, key) { return n * 2 + key.length } , dispose: function (key, n) { n.close() } , maxAge: 1000 * 60 * 60 } , cache = LRU(options) , otherCache = LRU(50) // sets just the max size cache.set("key", "value") cache.get("key") // "value" // non-string keys ARE fully supported // but note that it must be THE SAME object, not // just a JSON-equivalent object. var someObject = { a: 1 } cache.set(someObject, 'a value') // Object keys are not toString()-ed cache.set('[object Object]', 'a different value') assert.equal(cache.get(someObject), 'a value') // A similar object with same keys/values won't work, // because it's a different object identity assert.equal(cache.get({ a: 1 }), undefined) cache.reset() // empty the cache ``` -------------------------------- ### List SDC Resources using sdc command Source: https://context7.com/tritondatacenter/sdc-headnode/llms.txt Demonstrates listing resources for image administration and user administration using the sdc command-line tool. These commands are typically run on the SDC headnode. ```bash sdc "sdc-imgadm list" sdc "sdc-useradm list" ``` -------------------------------- ### Parse CLI Arguments with Environment Variables and Config Files (JavaScript) Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/cmdln/node_modules/dashdash/TODO.txt Demonstrates parsing command-line arguments using the 'dashdash' library in Node.js. It shows how to define options, link them to environment variables for overriding, and parse arguments from both the command line and a configuration file. ```javascript var dashdash = require('dashdash'); var options = [ {name: 'v', env: 'FOO_VERBOSE', type: 'bool'}, {name: 'i', type: 'bool'}, {name: 'file', env: 'FOO_FILE', type: 'string'} ]; var parser = new dashdash.Parser({options: options}); var opts = parser.parse(process.argv); ``` -------------------------------- ### Install uuid Module Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/uuid/README.md This command installs the 'uuid' module using npm. This is the recommended first step before using the module in a Node.js project. ```shell npm install uuid ``` -------------------------------- ### Install node-dashdash using npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/cmdln/node_modules/dashdash/README.md This command installs the node-dashdash library, which is a dependency for option parsing in Node.js projects. It uses the npm package manager. ```bash npm install dashdash ``` -------------------------------- ### Instantiating the Minimatch Class Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/glob/node_modules/minimatch/README.md Shows how to create a Minimatch object by instantiating the Minimatch class with a pattern and optional configuration settings. ```javascript var Minimatch = require("minimatch").Minimatch var mm = new Minimatch(pattern, options) ``` -------------------------------- ### Install NPM Modules for Development Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/sshpk/node_modules/tweetnacl/README.md Installs the necessary Node Package Manager (NPM) modules required for development and testing of the project. This command should be run in the project's root directory. ```bash $ npm install ``` -------------------------------- ### X-Range Examples Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/semver/README.md Illustrates the use of X-ranges ('x', 'X', '*') as wildcards for major, minor, or patch versions. Partial versions are also treated as X-ranges. ```text * := >=0.0.0 1.x := >=1.0.0 <2.0.0 1.2.x := >=1.2.0 <1.3.0 "" := * := >=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 LRU Cache using npm Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/lru-cache/README.md This snippet shows how to install the 'lru-cache' package using npm, a common package manager for Node.js. It adds the package as a dependency to your project. ```javascript npm install lru-cache --save ``` -------------------------------- ### Parse Options with Arguments using Node.js getopt Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/posix-getopt/README.md Demonstrates how to use the BasicParser from the 'getopt' module to parse command-line options that require arguments. It shows how to define the option string and the arguments array, and then iterate through the parsed options, accessing their values. ```javascript var mod_getopt = require('getopt') var parser, option; parser = new mod_getopt.BasicParser('f:lad:', ['node', 'script', '-l', '-f', 'filename', '-dtype', 'stuff']); while ((option = parser.getopt()) !== undefined && !option.error) console.error(option); ``` -------------------------------- ### Install Mime Module via NPM Source: https://github.com/tritondatacenter/sdc-headnode/blob/master/tools/node_modules/sdc-clients/node_modules/restify-clients/node_modules/mime/README.md Installs the Mime module using npm, the Node Package Manager. This is the standard way to add the module to your project for server-side use. ```bash npm install mime ```