### Install Guidepup Setup Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@guidepup/setup/README.md Run this command to install and set up Guidepup for screen reader automation. ```bash npx @guidepup/setup ``` -------------------------------- ### Install process-nextick-args Source: https://github.com/guidepup/setup-action/blob/main/node_modules/process-nextick-args/readme.md Install the process-nextick-args package using npm. ```bash npm install --save process-nextick-args ``` -------------------------------- ### Install to-buffer Source: https://github.com/guidepup/setup-action/blob/main/node_modules/to-buffer/README.md Install the to-buffer package using npm. ```bash npm install to-buffer ``` -------------------------------- ### Dispatch GET Request with Undici Client Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/Dispatcher.md This example demonstrates how to dispatch a GET request using the Undici Client and handle the response lifecycle with various callbacks. It sets up a simple HTTP server, makes a request to it, and logs connection, headers, data, and completion events. Ensure the server is listening before making the client request. ```javascript import { createServer } from 'http' import { Client } from 'undici' import { once } from 'events' const server = createServer((request, response) => { response.end('Hello, World!') }).listen() await once(server, 'listening') const client = new Client(`http://localhost:${server.address().port}`) const data = [] client.dispatch({ path: '/', method: 'GET', headers: { 'x-foo': 'bar' } }, { onConnect: () => { console.log('Connected!') }, onError: (error) => { console.error(error) }, onHeaders: (statusCode, headers) => { console.log(`onHeaders | statusCode: ${statusCode} | headers: ${headers}`) }, onData: (chunk) => { console.log('onData: chunk received') data.push(chunk) }, onComplete: (trailers) => { console.log(`onComplete | trailers: ${trailers}`) const res = Buffer.concat(data).toString('utf8') console.log(`Data: ${res}`) client.close() server.close() } }) ``` -------------------------------- ### WebSocket Connection Example with https-proxy-agent Source: https://github.com/guidepup/setup-action/blob/main/node_modules/ffmpeg-static/node_modules/https-proxy-agent/README.md Shows how to use https-proxy-agent to establish a proxied WebSocket connection. This example requires the 'ws' package to be installed. ```javascript var url = require('url'); var WebSocket = require('ws'); var HttpsProxyAgent = require('https-proxy-agent'); // HTTP/HTTPS proxy to connect to var proxy = process.env.http_proxy || 'http://168.63.76.32:3128'; console.log('using proxy server %j', proxy); // WebSocket endpoint for the proxy to connect to var endpoint = process.argv[2] || 'ws://echo.websocket.org'; var parsed = url.parse(endpoint); console.log('attempting to connect to WebSocket %j', endpoint); // create an instance of the `HttpsProxyAgent` class with the proxy server information var options = url.parse(proxy); var agent = new HttpsProxyAgent(options); // finally, initiate the WebSocket connection var socket = new WebSocket(endpoint, { agent: agent }); socket.on('open', function () { console.log('"open" event!'); socket.send('hello world'); }); socket.on('message', function (data, flags) { console.log('"message" event! %j %j', data, flags); socket.close(); }); ``` -------------------------------- ### Install supports-color Source: https://github.com/guidepup/setup-action/blob/main/node_modules/supports-color/readme.md Install the supports-color module using npm. ```bash $ npm install supports-color ``` -------------------------------- ### Install @guidepup/record Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@guidepup/record/README.md Install the @guidepup/record package using npm. ```bash npm install @guidepup/record ``` -------------------------------- ### Install ffmpeg-static Source: https://github.com/guidepup/setup-action/blob/main/node_modules/ffmpeg-static/README.md Install the ffmpeg-static package using npm. This command downloads the appropriate ffmpeg binary for your system during installation. ```bash npm install ffmpeg-static ``` -------------------------------- ### Install get-stream Source: https://github.com/guidepup/setup-action/blob/main/node_modules/get-stream/readme.md Install the get-stream package using npm. ```bash $ npm install --save get-stream ``` -------------------------------- ### Install http-response-object Source: https://github.com/guidepup/setup-action/blob/main/node_modules/http-response-object/README.md Install the http-response-object package using npm. ```bash npm install http-response-object ``` -------------------------------- ### Basic Environment Setup Source: https://github.com/guidepup/setup-action/blob/main/README.md Use this snippet to add the Guidepup Setup Action to your GitHub Actions workflow. ```yaml - name: Setup Environment uses: guidepup/setup-action ``` -------------------------------- ### Install pinkie-promise Source: https://github.com/guidepup/setup-action/blob/main/node_modules/pinkie-promise/readme.md Install the pinkie-promise package using npm. ```bash $ npm install --save pinkie-promise ``` -------------------------------- ### Install buffer-from Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer-from/readme.md Install the buffer-from package using npm. ```sh npm install --save buffer-from ``` -------------------------------- ### Guidepup Setup in CI Environment Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@guidepup/setup/README.md Run this command in a CI/CD environment to prevent interactive prompts during setup. ```bash npx @guidepup/setup --ci ``` -------------------------------- ### Install isarray with component Source: https://github.com/guidepup/setup-action/blob/main/node_modules/isarray/README.md Illustrates how to install the isarray package using the component package manager. ```bash $ component install juliangruber/isarray ``` -------------------------------- ### Mocking a Request with Default Reply Trailers Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/MockPool.md Illustrates setting default trailers for a mocked reply. This example intercepts a GET request to '/foo' and configures it to include 'foo: bar' in the response trailers. ```javascript import { MockAgent, setGlobalDispatcher, request } from 'undici' const mockAgent = new MockAgent() setGlobalDispatcher(mockAgent) const mockPool = mockAgent.get('http://localhost:3000') mockPool.intercept({ path: '/foo', method: 'GET' }).defaultReplyTrailers({ foo: 'bar' }) .reply(200, 'foo') const { trailers } = await request('http://localhost:3000/foo') console.log('trailers', trailers) // trailers { foo: 'bar' } ``` -------------------------------- ### Install file-type Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-tarbz2/node_modules/file-type/readme.md Install the file-type package using npm. ```bash $ npm install file-type ``` -------------------------------- ### Install file-type Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-unzip/node_modules/file-type/readme.md Install the file-type package using npm. ```bash $ npm install --save file-type ``` -------------------------------- ### Install @actions/http-client Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@actions/http-client/README.md Install the @actions/http-client package using npm. ```bash npm install @actions/http-client --save ``` -------------------------------- ### Install env-paths Source: https://github.com/guidepup/setup-action/blob/main/node_modules/env-paths/readme.md Install the `env-paths` package using npm. ```bash $ npm install env-paths ``` -------------------------------- ### Install pify Source: https://github.com/guidepup/setup-action/blob/main/node_modules/make-dir/node_modules/pify/readme.md Install the pify module using npm. ```bash $ npm install --save pify ``` -------------------------------- ### Install Undici Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/README.md Install the undici package using npm. ```bash npm i undici ``` -------------------------------- ### Record Setup Process on MacOS Source: https://github.com/guidepup/setup-action/blob/main/README.md Enable screen recording of the setup process on MacOS by setting the `record` option to `true`. Recordings are saved to the `./recordings/` directory. ```yaml - name: Setup Environment uses: guidepup/setup-action with: record: true ``` -------------------------------- ### Install Chalk Source: https://github.com/guidepup/setup-action/blob/main/node_modules/chalk/readme.md Install the Chalk package using npm. ```bash npm install chalk ``` -------------------------------- ### Install tar-stream Source: https://github.com/guidepup/setup-action/blob/main/node_modules/tar-stream/README.md Install the tar-stream module using npm. ```bash npm install tar-stream ``` -------------------------------- ### Install color-convert using npm Source: https://github.com/guidepup/setup-action/blob/main/node_modules/color-convert/README.md Shows the command to install the color-convert library using npm. ```bash $ npm install color-convert ``` -------------------------------- ### Install agent-base Source: https://github.com/guidepup/setup-action/blob/main/node_modules/ffmpeg-static/node_modules/agent-base/README.md Install the agent-base module using npm. ```bash npm install agent-base ``` -------------------------------- ### Install buffer-fill Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer-fill/readme.md Install the buffer-fill package using npm. ```sh npm install --save buffer-fill ``` -------------------------------- ### Install buffer-alloc Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer-alloc/readme.md Install the buffer-alloc package using npm. ```sh npm install --save buffer-alloc ``` -------------------------------- ### Install stream-slicer Source: https://github.com/guidepup/setup-action/blob/main/node_modules/stream-slicer/README.md Install the stream-slicer package using npm. ```bash npm install stream-slicer ``` -------------------------------- ### Install make-dir with npm Source: https://github.com/guidepup/setup-action/blob/main/node_modules/make-dir/readme.md Install the make-dir package using npm. This is the first step before using the module in your project. ```bash $ npm install make-dir ``` -------------------------------- ### Install with npm Source: https://github.com/guidepup/setup-action/blob/main/node_modules/is-natural-number/README.md Install the is-natural-number package using npm. ```bash npm install is-natural-number ``` -------------------------------- ### Install https-proxy-agent Source: https://github.com/guidepup/setup-action/blob/main/node_modules/ffmpeg-static/node_modules/https-proxy-agent/README.md Install the https-proxy-agent package using npm. ```bash npm install https-proxy-agent ``` -------------------------------- ### Install isarray with npm Source: https://github.com/guidepup/setup-action/blob/main/node_modules/isarray/README.md Shows the command to install the isarray package using npm. This is a prerequisite for bundling it with tools like browserify. ```bash $ npm install isarray ``` -------------------------------- ### Install safe-buffer Source: https://github.com/guidepup/setup-action/blob/main/node_modules/bl/node_modules/safe-buffer/README.md Install the safe-buffer package using npm. ```bash npm install safe-buffer ``` -------------------------------- ### Install Dependencies Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@actions/http-client/README.md Install project dependencies using npm. ```bash npm install ``` -------------------------------- ### Install readable-stream Source: https://github.com/guidepup/setup-action/blob/main/node_modules/concat-stream/node_modules/readable-stream/README.md Install the readable-stream package using npm. ```bash npm install --save readable-stream ``` -------------------------------- ### Install Debug Utility Source: https://github.com/guidepup/setup-action/blob/main/node_modules/agent-base/node_modules/debug/README.md Install the debug package using npm. ```bash npm install debug ``` -------------------------------- ### Install string_decoder Source: https://github.com/guidepup/setup-action/blob/main/node_modules/concat-stream/node_modules/string_decoder/README.md Install the string_decoder package using npm. ```bash npm install --save string_decoder ``` -------------------------------- ### Install Progress Bar Module Source: https://github.com/guidepup/setup-action/blob/main/node_modules/progress/Readme.md Install the progress bar Node.js module using npm. ```bash $ npm install progress ``` -------------------------------- ### Install semver with npm Source: https://github.com/guidepup/setup-action/blob/main/node_modules/semver/README.md Install the semver module using npm. This is the first step to using it in your Node.js project. ```bash npm install semver ``` -------------------------------- ### Install Buffer Module Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer/README.md Install the buffer module using npm for direct use without a bundler. ```bash npm install buffer ``` -------------------------------- ### Usage Example Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-tarbz2/readme.md Use decompress-tarbz2 as a plugin with the decompress library to extract tar.bz2 files. Ensure both decompress and decompress-tarbz2 are installed. ```javascript const decompress = require('decompress'); const decompressTarbz = require('decompress-tarbz2'); decompress('unicorn.tar.gz', 'dist', { plugins: [ decompressTarbz() ] }).then(() => { console.log('Files decompressed'); }); ``` -------------------------------- ### Guidepup Setup with Recording for CI Errors Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@guidepup/setup/README.md Pass the --record flag to generate a screen recording of the setup process in the ./recordings/ directory, useful for debugging errors in CI environments on MacOS. ```bash npx @guidepup/setup --ci --record ``` -------------------------------- ### Install strip-dirs using npm Source: https://github.com/guidepup/setup-action/blob/main/node_modules/strip-dirs/README.md Shows the command to install the strip-dirs package as a project dependency. ```bash npm install --save strip-dirs ``` -------------------------------- ### Resetting ANSI Escape Codes After Each Line Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@actions/core/README.md Shows how ANSI escape codes reset at the start of each line and provides an example of default text reset. ```javascript core.info('\u001b[35mThis foreground will be magenta') core.info('This foreground will reset to the default') ``` -------------------------------- ### Mocking a Request with Default Reply Headers Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/MockPool.md Demonstrates setting default headers for a mocked reply. The example intercepts a GET request to '/foo' and configures it to include 'foo: bar' in the response headers. ```javascript import { MockAgent, setGlobalDispatcher, request } from 'undici' const mockAgent = new MockAgent() setGlobalDispatcher(mockAgent) const mockPool = mockAgent.get('http://localhost:3000') mockPool.intercept({ path: '/foo', method: 'GET' }).defaultReplyHeaders({ foo: 'bar' }) .reply(200, 'foo') const { headers } = await request('http://localhost:3000/foo') console.log('headers', headers) // headers { foo: 'bar' } ``` -------------------------------- ### Start Screen Recording on Windows Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@guidepup/record/README.md Use the `windowsRecord` function to start a screen recording on Windows. The function returns a callback to stop the recording. ```typescript import { windowsRecord } from "@guidepup/record"; (async () => { // Start the screen recording passing the location to save the recording. const stopRecording = windowsRecord("./recordings/screenRecording.mp4"); // ... perform some commands. // Stop the screen recording. stopRecording(); })(); ``` -------------------------------- ### Mocking Request with Automatic Content-Length Calculation (String) Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/MockPool.md Shows how to automatically calculate and set the 'Content-Length' header for a mocked reply. The example intercepts a GET request and replies with 'foo', letting Undici handle the header. ```javascript import { MockAgent, setGlobalDispatcher, request } from 'undici' const mockAgent = new MockAgent() setGlobalDispatcher(mockAgent) const mockPool = mockAgent.get('http://localhost:3000') mockPool.intercept({ path: '/foo', method: 'GET' }).replyContentLength().reply(200, 'foo') const { headers } = await request('http://localhost:3000/foo') console.log('headers', headers) // headers { 'content-length': '3' } ``` -------------------------------- ### Client Certificate Authentication Example Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/best-practices/client-certificate.md Demonstrates setting up an HTTPS server that requests client certificates and an Undici client that provides its own certificate for authentication. The server checks the validity of the client certificate. ```javascript const { readFileSync } = require('fs') const { join } = require('path') const { createServer } = require('https') const { Client } = require('undici') const serverOptions = { ca: [ readFileSync(join(__dirname, 'client-ca-crt.pem'), 'utf8') ], key: readFileSync(join(__dirname, 'server-key.pem'), 'utf8'), cert: readFileSync(join(__dirname, 'server-crt.pem'), 'utf8'), requestCert: true, rejectUnauthorized: false } const server = createServer(serverOptions, (req, res) => { // true if client cert is valid if(req.client.authorized === true) { console.log('valid') } else { console.error(req.client.authorizationError) } res.end() }) server.listen(0, function () { const tls = { ca: [ readFileSync(join(__dirname, 'server-ca-crt.pem'), 'utf8') ], key: readFileSync(join(__dirname, 'client-key.pem'), 'utf8'), cert: readFileSync(join(__dirname, 'client-crt.pem'), 'utf8'), rejectUnauthorized: false, servername: 'agent1' } const client = new Client(`https://localhost:${server.address().port}`, { connect: tls }) client.request({ path: '/', method: 'GET' }, (err, { body }) => { body.on('data', (buf) => {}) // eslint-disable-line no-unused-vars body.on('end', () => { client.close() server.close() }) }) }) ``` -------------------------------- ### Install ieee754 Module Source: https://github.com/guidepup/setup-action/blob/main/node_modules/ieee754/README.md Install the ieee754 module using npm. This command downloads and installs the package into your project's node_modules directory. ```bash npm install ieee754 ``` -------------------------------- ### Buffer Alloc Usage Examples Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer-alloc/readme.md Demonstrates allocating new Buffers with different fill values and encodings using the buffer-alloc package. ```js const alloc = require('buffer-alloc') console.log(alloc(4)) //=> console.log(alloc(6, 0x41)) //=> console.log(alloc(10, 'linus', 'utf8')) //=> ``` -------------------------------- ### Creating a Spec-Conformant ZIP File Source: https://github.com/guidepup/setup-action/blob/main/node_modules/yauzl/README.md This example demonstrates how to create a ZIP file that is difficult for streaming parsers to interpret correctly, using the 'zip' command line tool. It highlights the use of General Purpose Bit 3 to obscure file size information. ```bash $ echo -ne '\x50\x4b\x07\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' > file.txt $ zip -q0 - file.txt | cat > out.zip ``` -------------------------------- ### Instantiating BufferList Source: https://github.com/guidepup/setup-action/blob/main/node_modules/bl/README.md Demonstrates two ways to create a new BufferList instance: using the default constructor or calling the module directly. ```javascript var bl = require('bl') var myinstance = bl() // equivalent to: var BufferList = require('bl') var myinstance = new BufferList() ``` -------------------------------- ### Install lru-cache Source: https://github.com/guidepup/setup-action/blob/main/node_modules/lru-cache/README.md Install the lru-cache module using npm. ```javascript npm install lru-cache --save ``` -------------------------------- ### Basic Custom Connector Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/Connector.md Demonstrates how to create a basic custom connector using `buildConnector` and integrate it with an Undici `Client`. This example shows how to intercept the socket creation process. ```javascript 'use strict' import { Client, buildConnector } from 'undici' const connector = buildConnector({ rejectUnauthorized: false }) const client = new Client('https://localhost:3000', { connect (opts, cb) { connector(opts, (err, socket) => { if (err) { cb(err) } else if (/* assertion */) { socket.destroy() cb(new Error('kaboom')) } else { cb(null, socket) } }) } }) ``` -------------------------------- ### Install is-stream Source: https://github.com/guidepup/setup-action/blob/main/node_modules/is-stream/readme.md Install the is-stream package using npm. ```bash $ npm install --save is-stream ``` -------------------------------- ### Install with Bower Source: https://github.com/guidepup/setup-action/blob/main/node_modules/is-natural-number/README.md Install the is-natural-number package using Bower. ```bash bower install is-natural-number ``` -------------------------------- ### Download Progress Bar Example Source: https://github.com/guidepup/setup-action/blob/main/node_modules/progress/Readme.md Implement a progress bar to visualize the download progress of a file, showing rate, percentage, and estimated time. ```javascript var ProgressBar = require('progress'); var https = require('https'); var req = https.request({ host: 'download.github.com', port: 443, path: '/visionmedia-node-jscoverage-0d4608a.zip' }); req.on('response', function(res){ var len = parseInt(res.headers['content-length'], 10); console.log(); var bar = new ProgressBar(' downloading [:bar] :rate/bps :percent :etas', { complete: '=', incomplete: ' ', width: 20, total: len }); res.on('data', function (chunk) { bar.tick(chunk.length); }); res.on('end', function () { console.log('\n'); }); }); req.end(); ``` -------------------------------- ### Install has-flag Source: https://github.com/guidepup/setup-action/blob/main/node_modules/has-flag/readme.md Install the has-flag package using npm. ```bash $ npm install has-flag ``` -------------------------------- ### Install fs-constants Source: https://github.com/guidepup/setup-action/blob/main/node_modules/fs-constants/README.md Install the fs-constants module using npm. ```bash npm install fs-constants ``` -------------------------------- ### Client Constructor Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/Client.md Initializes a new Client instance. The constructor takes a URL and optional configuration options to customize the client's behavior. ```APIDOC ## `new Client(url[, options])` ### Description Initializes a new Client instance. The constructor takes a URL and optional configuration options to customize the client's behavior. ### Parameters * **url** `URL | string` - Should only include the **protocol, hostname, and port**. * **options** `ClientOptions` (optional) ### Returns `Client` ### Parameter: `ClientOptions` > ⚠️ Warning: The `H2` support is experimental. * **bodyTimeout** `number | null` (optional) - Default: `300e3` - The timeout after which a request will time out, in milliseconds. Monitors time between receiving body data. Use `0` to disable it entirely. Defaults to 300 seconds. * **headersTimeout** `number | null` (optional) - Default: `300e3` - The amount of time, in milliseconds, the parser will wait to receive the complete HTTP headers while not sending the request. Defaults to 300 seconds. * **keepAliveMaxTimeout** `number | null` (optional) - Default: `600e3` - The maximum allowed `keepAliveTimeout`, in milliseconds, when overridden by *keep-alive* hints from the server. Defaults to 10 minutes. * **keepAliveTimeout** `number | null` (optional) - Default: `4e3` - The timeout, in milliseconds, after which a socket without active requests will time out. Monitors time between activity on a connected socket. This value may be overridden by *keep-alive* hints from the server. See [MDN: HTTP - Headers - Keep-Alive directives](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Keep-Alive#directives) for more details. Defaults to 4 seconds. * **keepAliveTimeoutThreshold** `number | null` (optional) - Default: `1e3` - A number of milliseconds subtracted from server *keep-alive* hints when overriding `keepAliveTimeout` to account for timing inaccuracies caused by e.g. transport latency. Defaults to 1 second. * **maxHeaderSize** `number | null` (optional) - Default: `--max-http-header-size` or `16384` - The maximum length of request headers in bytes. Defaults to Node.js' --max-http-header-size or 16KiB. * **maxResponseSize** `number | null` (optional) - Default: `-1` - The maximum length of response body in bytes. Set to `-1` to disable. * **pipelining** `number | null` (optional) - Default: `1` - The amount of concurrent requests to be sent over the single TCP/TLS connection according to [RFC7230](https://tools.ietf.org/html/rfc7230#section-6.3.2). Carefully consider your workload and environment before enabling concurrent requests as pipelining may reduce performance if used incorrectly. Pipelining is sensitive to network stack settings as well as head of line blocking caused by e.g. long running requests. Set to `0` to disable keep-alive connections. * **connect** `ConnectOptions | Function | null` (optional) - Default: `null`. * **strictContentLength** `Boolean` (optional) - Default: `true` - Whether to treat request content length mismatches as errors. If true, an error is thrown when the request content-length header doesn't match the length of the request body. * **interceptors** `{ Client: DispatchInterceptor[] }` - Default: `[RedirectInterceptor]` - A list of interceptors that are applied to the dispatch method. Additional logic can be applied (such as, but not limited to: 302 status code handling, authentication, cookies, compression and caching). Note that the behavior of interceptors is Experimental and might change at any given time. * **autoSelectFamily**: `boolean` (optional) - Default: depends on local Node version, on Node 18.13.0 and above is `false`. Enables a family autodetection algorithm that loosely implements section 5 of [RFC 8305](https://tools.ietf.org/html/rfc8305#section-5). See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details. This option is ignored if not supported by the current Node version. * **autoSelectFamilyAttemptTimeout**: `number` - Default: depends on local Node version, on Node 18.13.0 and above is `250`. The amount of time in milliseconds to wait for a connection attempt to finish before trying the next address when using the `autoSelectFamily` option. See [here](https://nodejs.org/api/net.html#socketconnectoptions-connectlistener) for more details. * **allowH2**: `boolean` - Default: `false`. Enables support for H2 if the server has assigned bigger priority to it through ALPN negotiation. * **maxConcurrentStreams**: `number` - Default: `100`. Dictates the maximum number of concurrent streams for a single H2 session. It can be overridden by a SETTINGS remote frame. ``` -------------------------------- ### Initializing and Appending Buffers Source: https://github.com/guidepup/setup-action/blob/main/node_modules/bl/README.md Demonstrates how to create a BufferList instance, append various data types (Buffers and strings), and access its length. It also shows how to slice and convert parts of the BufferList to strings. ```javascript const BufferList = require('bl') var bl = new BufferList() bl.append(new Buffer('abcd')) bl.append(new Buffer('efg')) bl.append('hi') // bl will also accept & convert Strings bl.append(new Buffer('j')) bl.append(new Buffer([ 0x3, 0x4 ])) console.log(bl.length) // 12 console.log(bl.slice(0, 10).toString('ascii')) // 'abcdefghij' console.log(bl.slice(3, 10).toString('ascii')) // 'defghij' console.log(bl.slice(3, 6).toString('ascii')) // 'def' console.log(bl.slice(3, 8).toString('ascii')) // 'defgh' console.log(bl.slice(5, 10).toString('ascii')) // 'fghij' // or just use toString! console.log(bl.toString()) // 'abcdefghij\u0003\u0004' console.log(bl.toString('ascii', 3, 8)) // 'defgh' console.log(bl.toString('ascii', 5, 10)) // 'fghij' // other standard Buffer readables console.log(bl.readUInt16BE(10)) // 0x0304 console.log(bl.readUInt16LE(10)) // 0x0403 ``` -------------------------------- ### Install decompress-unzip Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-unzip/readme.md Install the decompress-unzip package using npm. ```bash $ npm install --save decompress-unzip ``` -------------------------------- ### Basic GET Request with Undici Client Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/Dispatcher.md Demonstrates a basic GET request using the Undici Client. It shows how to set up a mock server, make a request, and process the response, including status code, headers, body, and trailers. Ensure the client and server are closed after use. ```javascript import { createServer } from 'http' import { Client } from 'undici' import { once } from 'events' const server = createServer((request, response) => { response.end('Hello, World!') }).listen() await once(server, 'listening') const client = new Client(`http://localhost:${server.address().port}`) try { const { body, headers, statusCode, trailers } = await client.request({ path: '/', method: 'GET' }) console.log(`response received ${statusCode}`) console.log('headers', headers) body.setEncoding('utf8') body.on('data', console.log) body.on('end', () => { console.log('trailers', trailers) }) client.close() server.close() } catch (error) { console.error(error) } ``` -------------------------------- ### Install decompress-targz Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-targz/readme.md Install the decompress-targz package using npm. ```bash $ npm install decompress-targz ``` -------------------------------- ### Instantiate ProxyAgent Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/ProxyAgent.md Demonstrates how to create a new ProxyAgent instance, either by passing the proxy URI as a string or as part of an options object. ```javascript import { ProxyAgent } from 'undici' const proxyAgent = new ProxyAgent('my.proxy.server') // or const proxyAgent = new ProxyAgent({ uri: 'my.proxy.server' }) ``` -------------------------------- ### Install decompress Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress/readme.md Install the decompress module using npm. ```bash $ npm install decompress ``` -------------------------------- ### Create a directory synchronously Source: https://github.com/guidepup/setup-action/blob/main/node_modules/make-dir/readme.md Use the `makeDir.sync` method to create a directory and its parents synchronously. This method returns the path of the created directory. ```javascript makeDir.sync(path, [options]) ``` -------------------------------- ### Install decompress-tarbz2 Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-tarbz2/readme.md Install the decompress-tarbz2 package using npm. ```bash $ npm install decompress-tarbz2 ``` -------------------------------- ### Basic Usage Source: https://github.com/guidepup/setup-action/blob/main/node_modules/chalk/readme.md Import Chalk and use it to style a string with blue color. ```javascript const chalk = require('chalk'); console.log(chalk.blue('Hello world!')); ``` -------------------------------- ### Git-style Sub-commands with Descriptions Source: https://github.com/guidepup/setup-action/blob/main/node_modules/commander/Readme.md Shows how to define multiple sub-commands for a program using `.command()`. When a description is provided, Commander assumes separate executables for sub-commands (e.g., `pm-install`). ```javascript // file: ./examples/pm var program = require('commander'); program .version('0.1.0') .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); ``` -------------------------------- ### Install decompress-tar Source: https://github.com/guidepup/setup-action/blob/main/node_modules/decompress-tar/readme.md Install the decompress-tar package using npm. ```bash $ npm install decompress-tar ``` -------------------------------- ### Build Project Source: https://github.com/guidepup/setup-action/blob/main/node_modules/@actions/http-client/README.md Build the project using npm scripts. ```bash npm run build ``` -------------------------------- ### HTTPS Module Example with https-proxy-agent Source: https://github.com/guidepup/setup-action/blob/main/node_modules/ffmpeg-static/node_modules/https-proxy-agent/README.md Demonstrates how to use https-proxy-agent with the built-in 'https' module to make a proxied HTTPS request. Requires setting the http_proxy environment variable or providing a proxy URL. ```javascript var url = require('url'); var https = require('https'); var HttpsProxyAgent = require('https-proxy-agent'); // HTTP/HTTPS proxy to connect to var proxy = process.env.http_proxy || 'http://168.63.76.32:3128'; console.log('using proxy server %j', proxy); // HTTPS endpoint for the proxy to connect to var endpoint = process.argv[2] || 'https://graph.facebook.com/tootallnate'; console.log('attempting to GET %j', endpoint); var options = url.parse(endpoint); // create an instance of the `HttpsProxyAgent` class with the proxy server information var agent = new HttpsProxyAgent(proxy); options.agent = agent; https.get(options, function (res) { console.log('"response" event!', res.headers); res.pipe(process.stdout); }); ``` -------------------------------- ### Install buffer-alloc-unsafe Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer-alloc-unsafe/readme.md Install the buffer-alloc-unsafe package using npm. ```sh npm install --save buffer-alloc-unsafe ``` -------------------------------- ### Install buffer-crc32 Source: https://github.com/guidepup/setup-action/blob/main/node_modules/buffer-crc32/README.md Install the buffer-crc32 module using npm. ```bash npm install buffer-crc32 ``` -------------------------------- ### Instantiate MockPool with MockAgent Source: https://github.com/guidepup/setup-action/blob/main/node_modules/undici/docs/api/MockPool.md Demonstrates how to create a MockAgent and obtain a MockPool instance for a specific origin. This pool can then be configured to intercept requests. ```javascript import { MockAgent } from 'undici' const mockAgent = new MockAgent() const mockPool = mockAgent.get('http://localhost:3000') ```