### Create and Use DirectedGraph Source: https://context7.com/searchfe/makit/llms.txt Demonstrates creating a DirectedGraph, adding vertices and edges, checking for circular dependencies, and performing various graph operations. Ensure the 'makit' package is installed. ```javascript const { DirectedGraph } = require('makit') // Create a dependency graph const graph = new DirectedGraph() // Add vertices (nodes) graph.addVertex('app.js') graph.addVertex('module-a.js') graph.addVertex('module-b.js') graph.addVertex('utils.js') // Add edges (dependencies) graph.addEdge('app.js', 'module-a.js') // app.js depends on module-a.js graph.addEdge('app.js', 'module-b.js') // app.js depends on module-b.js graph.addEdge('module-a.js', 'utils.js') // module-a.js depends on utils.js graph.addEdge('module-b.js', 'utils.js') // module-b.js depends on utils.js // Check for circular dependencies try { graph.checkCircular('app.js') console.log('No circular dependencies') } catch (err) { console.error('Circular dependency detected:', err.message) } // Check if edge exists console.log(graph.hasEdge('app.js', 'module-a.js')) // true // Get out-degree (number of dependencies) console.log(graph.getOutDegree('app.js')) // 2 // Find path from a node to root const path = graph.findPathToRoot('utils.js') console.log('Path to root:', path) // ['utils.js', 'module-a.js', 'app.js'] // Iterate in pre-order (topological) for (const node of graph.preOrder('app.js')) { console.log('Processing:', node) } // Print tree visualization console.log(graph.toString()) // Output: // app.js // ├─ module-a.js // │ └─ utils.js // └─ module-b.js // └─ utils.js ``` -------------------------------- ### Programmatic Makefile Definition and Execution Source: https://context7.com/searchfe/makit/llms.txt Use this snippet to define build rules and execute builds programmatically using the Makefile class. Instantiate Makefile with a project root, add rules using `addRule` or `addRude`, and execute builds with `make`. It also shows how to get a dependency graph string. ```javascript const { Makefile } = require('makit') // Create a new Makefile instance with custom root const makefile = new Makefile('/path/to/project') // Add rules programmatically makefile.addRule('all', ['dist/app.js', 'dist/app.css']) makefile.addRule('dist/app.js', ['src/app.js'], async function () { const src = await this.readDependency(0) await this.writeTarget(src) }) makefile.addRule('dist/app.css', ['src/styles.css'], async function () { const css = await this.readDependency(0) await this.writeTarget(css) }) // Add rude rule with dynamic dependencies makefile.addRude('bundle.js', [], async ctx => { await ctx.make('module-a.js') await ctx.make('module-b.js') const a = await ctx.readFile('module-a.js') const b = await ctx.readFile('module-b.js') await ctx.writeTarget(a + b) }) // Execute build async function runBuild() { try { await makefile.make('all') console.log('Build successful!') // Get dependency graph visualization console.log(makefile.dependencyGraphString()) } catch (err) { console.error('Build failed:', err.message) } } runBuild() ``` -------------------------------- ### Interface: MakeOptions Source: https://github.com/searchfe/makit/blob/master/docs/interfaces/_make_.makeoptions.html Configuration options for initializing the Makit build process. ```APIDOC ## Interface MakeOptions ### Description Defines the configuration object used to customize the behavior of the Makit build system. ### Properties - **root** (string) - Optional - The root directory for the build process. - **reporter** (Reporter) - Required - The reporter instance used for logging build progress and results. - **disableCheckCircular** (boolean) - Optional - If set to true, disables the detection of circular dependencies. - **matchRule** (function) - Required - A function that takes a target string and returns a tuple containing a Rule and a RegExpExecArray, or null if no match is found. ``` -------------------------------- ### checkCircular Source: https://github.com/searchfe/makit/blob/master/docs/classes/_utils_graph_.directedgraph.html Checks the graph for circular dependencies starting from a specific vertex. ```APIDOC ## checkCircular ### Description Checks if a circular dependency exists starting from vertex 'u'. If a circuit exists, it returns the circuit; otherwise, it returns null. ### Parameters - **u** (T) - Required - The starting vertex. - **path** (Set) - Optional - The current path being traversed. - **visited** (Set) - Optional - The set of already visited vertices. ### Returns - **void** ``` -------------------------------- ### Constructor - Context Source: https://github.com/searchfe/makit/blob/master/docs/classes/_context_.context.html Initializes a new instance of the Context class with file system and target configuration. ```APIDOC ## Constructor ### Description Creates a new Context instance used for managing build targets and file system operations. ### Parameters #### Request Body - **fs** (FileSystem) - Required - The file system implementation. - **make** (function) - Required - A function that takes a target string and returns a Promise resolving to a TimeStamp. - **match** (RegExpExecArray | null) - Optional - Regex match result for the target. - **root** (string) - Required - The root directory path. - **target** (string) - Required - The target file path. ``` -------------------------------- ### Array Fill Method Source: https://github.com/searchfe/makit/blob/master/docs/interfaces/_makefile_prerequisites_.prerequisitearray.html The fill() method changes all elements in an array to a static value, from a start index to an end index. ```APIDOC ## fill ### Description Changes all elements in an array to a static value, from a start index to an end index. ### Method N/A (This is a method of the Array object) ### Endpoint N/A ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **this** (Object) - The array instance itself. #### Response Example None ``` -------------------------------- ### Constructor - new Make() Source: https://github.com/searchfe/makit/blob/master/docs/classes/_make_.make.html Initializes a new instance of the Make class with configuration for rule matching, reporting, and root directory. ```APIDOC ## constructor ### Description Creates a new Make instance. ### Parameters #### Request Body - **__namedParameters** (object) - Required - **disableCheckCircular** (boolean) - Optional - Flag to disable circular dependency checks. - **matchRule** (function) - Required - Function to match a target string to a Rule and RegExpExecArray. - **reporter** (Reporter) - Required - The reporter interface for logging. - **root** (string) - Required - The root directory path. ``` -------------------------------- ### Manual Target Invalidation with File Watcher Source: https://context7.com/searchfe/makit/llms.txt This snippet demonstrates how to manually invalidate build targets when external changes occur, such as file modifications detected by a watcher. It uses `invalidate` to mark targets for rebuild and `make` to trigger the build process. Ensure `makit` and `chokidar` are installed. ```javascript const { rule, make, invalidate } = require('makit') const chokidar = require('chokidar') rule('all', ['dist/bundle.js']) rule('dist/bundle.js', ['src/index.js'], async function () { const src = await this.readDependency(0) await this.writeTarget(src) }) // Initial build await make('all') // Watch for changes and rebuild const watcher = chokidar.watch('src/**/*.js') watcher.on('change', async (path) => { console.log(`File changed: ${path}`) // Invalidate targets that depend on the changed file invalidate('dist/bundle.js') // Trigger rebuild try { await make('all') console.log('Rebuild complete') } catch (err) { console.error('Rebuild failed:', err.message) } }) console.log('Watching for changes...') ``` -------------------------------- ### View makit CLI usage Source: https://github.com/searchfe/makit/blob/master/README.md Display the command-line interface options and help information. ```text makit.js [OPTION] ... Options: --version Show version number [boolean] --makefile, -m makefile path [string] --database, -d database file, will be used for cache invalidation [default: "./.makit.db"] --require, -r require a module before loading makefile.js or makefile.ts [array] [default: []] --verbose, -v set loglevel to verbose [boolean] --debug, -v set loglevel to debug [boolean] --loglevel, -l error, warning, info, verbose, debug [choices: 0, 1, 2, 3, 4] --graph, -g output dependency graph [boolean] [default: false] --help Show help [boolean] ``` -------------------------------- ### Constructor - Makefile Source: https://github.com/searchfe/makit/blob/master/docs/classes/_makefile_makefile_.makefile.html Initializes a new instance of the Makefile class with an optional root directory and reporter. ```APIDOC ## Constructor ### Description Creates a new Makefile instance. ### Parameters #### Path Parameters - **root** (string) - Optional - The root directory, defaults to current working directory. - **reporter** (Reporter) - Optional - The reporter instance, defaults to DotReporter. ``` -------------------------------- ### MemoryFileSystem Methods Source: https://github.com/searchfe/makit/blob/master/docs/classes/_fs_memfs_impl_.memoryfilesystem.html Detailed documentation for each method in the MemoryFileSystem class. ```APIDOC ### exists * `exists(path: string): Promise` * Defined in [fs/memfs-impl.ts:65](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L65) #### Parameters * `path`: string #### Returns `Promise` ### existsSync * `existsSync(path: string): boolean` * Implementation of [FileSystem](../interfaces/_fs_file_system_.filesystem.html).[existsSync](../interfaces/_fs_file_system_.filesystem.html#existssync) * Defined in [fs/memfs-impl.ts:68](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L68) #### Parameters * `path`: string #### Returns `boolean` ### mkdir * `mkdir(path: string, options?: MakeDirectoryOptions): Promise` * Defined in [fs/memfs-impl.ts:15](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L15) #### Parameters * `path`: string * `options`: MakeDirectoryOptions = {} #### Returns `Promise` ### mkdirSync * `mkdirSync(path: string, options?: MakeDirectoryOptions): void` * Defined in [fs/memfs-impl.ts:18](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L18) #### Parameters * `path`: string * `options`: MakeDirectoryOptions = {} #### Returns `void` ### readFile * `readFile(path: string, encoding: undefined | string): any` * Implementation of [FileSystem](../interfaces/_fs_file_system_.filesystem.html).[readFile](../interfaces/_fs_file_system_.filesystem.html#readfile) * Defined in [fs/memfs-impl.ts:23](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L23) #### Parameters * `path`: string * `encoding`: undefined | string (Optional) #### Returns `any` ### readFileSync * `readFileSync(path: string, encoding: undefined | string): any` * Implementation of [FileSystem](../interfaces/_fs_file_system_.filesystem.html).[readFileSync](../interfaces/_fs_file_system_.filesystem.html#readfilesync) * Defined in [fs/memfs-impl.ts:26](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L26) #### Parameters * `path`: string * `encoding`: undefined | string (Optional) #### Returns `any` ### stat * `stat(path: string): Promise` * Defined in [fs/memfs-impl.ts:31](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L31) #### Parameters * `path`: string #### Returns `Promise` ### statSync * `statSync(path: string): any` * Defined in [fs/memfs-impl.ts:34](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L34) #### Parameters * `path`: string #### Returns `any` ### unlink * `unlink(path: string): Promise` * Defined in [fs/memfs-impl.ts:40](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L40) #### Parameters * `path`: string #### Returns `Promise` ### unlinkSync * `unlinkSync(path: string): void` * Defined in [fs/memfs-impl.ts:43](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L43) #### Parameters * `path`: string #### Returns `void` ### utimes * `utimes(path: string, atime: TimeStamp, mtime: TimeStamp): Promise` * Defined in [fs/memfs-impl.ts:50](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L50) #### Parameters * `path`: string * `atime`: TimeStamp * `mtime`: TimeStamp #### Returns `Promise` ### utimesSync * `utimesSync(path: string, atime: TimeStamp, mtime: TimeStamp): void` * Defined in [fs/memfs-impl.ts:53](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L53) #### Parameters * `path`: string * `atime`: TimeStamp * `mtime`: TimeStamp #### Returns `void` ### writeFile * `writeFile(path: string, data: any, encoding?: string): Promise` * Defined in [fs/memfs-impl.ts:58](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L58) #### Parameters * `path`: string * `data`: any * `encoding`: string (Optional) #### Returns `Promise` ### writeFileSync * `writeFileSync(path: string, data: any, encoding?: string): void` * Defined in [fs/memfs-impl.ts:61](https://github.com/searchfe/makit/blob/ea2bb7b/src/fs/memfs-impl.ts#L61) #### Parameters * `path`: string * `data`: any * `encoding`: string (Optional) #### Returns `void` ``` -------------------------------- ### FileSystem Interface Methods Source: https://github.com/searchfe/makit/blob/master/docs/interfaces/_fs_file_system_.filesystem.html This section details the methods available in the FileSystem interface. ```APIDOC ## FileSystem Interface ### Description The FileSystem interface defines a set of operations for interacting with a file system. ### Methods #### existsSync * **Description**: Checks if a file or directory exists at the given path. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to check. * **Returns**: boolean - True if the path exists, false otherwise. #### mkdir * **Description**: Creates a directory at the specified path. * **Method**: Asynchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path of the directory to create. * **options** (number | string | MakeDirectoryOptions | null) - Optional - Options for directory creation. * **Returns**: Promise #### mkdirSync * **Description**: Creates a directory at the specified path synchronously. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path of the directory to create. * **options** (number | string | MakeDirectoryOptions | null) - Optional - Options for directory creation. * **Returns**: void #### readFile * **Description**: Reads the content of a file asynchronously. * **Method**: Asynchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file to read. * **encoding** (undefined | string) - Optional - The encoding to use for reading the file. * **Returns**: Promise - The content of the file as a string or Buffer. #### readFileSync * **Description**: Reads the content of a file synchronously. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file to read. * **encoding** (string | undefined | string) - Required/Optional - The encoding to use for reading the file. * **Returns**: string | Buffer - The content of the file as a string or Buffer. #### stat * **Description**: Retrieves the status of a file or directory asynchronously. * **Method**: Asynchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file or directory. * **Returns**: Promise - The file status information. #### statSync * **Description**: Retrieves the status of a file or directory synchronously. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file or directory. * **Returns**: Stats - The file status information. #### unlink * **Description**: Deletes a file or directory asynchronously. * **Method**: Asynchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file or directory to delete. * **Returns**: Promise #### unlinkSync * **Description**: Deletes a file or directory synchronously. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file or directory to delete. * **Returns**: void #### utimes * **Description**: Changes the access and modification times of a file asynchronously. * **Method**: Asynchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file. * **atime** (Date | number) - Required - The access time. * **mtime** (Date | number) - Required - The modification time. * **Returns**: Promise #### utimesSync * **Description**: Changes the access and modification times of a file synchronously. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file. * **atime** (Date | number) - Required - The access time. * **mtime** (Date | number) - Required - The modification time. * **Returns**: void #### writeFile * **Description**: Writes data to a file asynchronously. * **Method**: Asynchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file to write to. * **data** (string | Buffer) - Required - The data to write. * **options** (string | WriteFileOptions) - Optional - Options for writing the file. * **Returns**: Promise #### writeFileSync * **Description**: Writes data to a file synchronously. * **Method**: Synchronous * **Endpoint**: N/A (Method within an interface) * **Parameters**: * **path** (string) - Required - The path to the file to write to. * **data** (string | Buffer) - Required - The data to write. * **options** (string | WriteFileOptions) - Optional - Options for writing the file. * **Returns**: void ``` -------------------------------- ### Define Basic Build Rules with Makit Source: https://context7.com/searchfe/makit/llms.txt Use the `rule` function to define build targets, their prerequisites, and the recipes to generate them. Supports synchronous, async, and callback-style recipes. ```javascript const { rule } = require('makit') const UglifyJS = require('uglify-js') // Basic rule with literal target and simple prerequisite rule('all', ['app.min.js', 'vendor.min.js']) ``` ```javascript // Rule with synchronous recipe using this context rule('app.min.js', ['src/app.js'], function () { const src = require('fs').readFileSync(this.dependencies[0], 'utf8') const minified = UglifyJS.minify(src).code require('fs').writeFileSync(this.target, minified) }) ``` ```javascript // Rule with async recipe using context parameter rule('vendor.min.js', ['src/vendor.js'], async function (ctx) { const src = await ctx.readDependency(0) const minified = UglifyJS.minify(src).code await ctx.writeTarget(minified) }) ``` ```javascript // Rule with callback-style recipe rule('clean', [], (ctx, done) => { require('rimraf')('{*.min.js,dist}', done) }) ``` ```javascript // Rule with multiple prerequisites rule('bundle.js', ['module-a.js', 'module-b.js', 'module-c.js'], async function () { const contents = await Promise.all( this.dependencies.map(dep => this.readFile(dep)) ) await this.writeTarget(contents.join(' ')) }) ``` -------------------------------- ### Makit CLI Tool Source: https://github.com/searchfe/makit/blob/master/docs/modules/_bin_makit_.html Documentation for the main entry point of the Makit CLI tool. ```APIDOC ## main ### Description The main function serves as the entry point for the Makit CLI tool. ### Method N/A (CLI Entry Point) ### Endpoint N/A (CLI Tool) ### Parameters This function does not accept direct parameters. ### Request Example N/A ### Response #### Success Response (void) - **Promise** - Indicates successful execution. #### Response Example N/A ``` -------------------------------- ### Define Async Build Rules Source: https://github.com/searchfe/makit/blob/master/README.md Demonstrates using async functions or callbacks to handle file transformations within build rules. ```javascript rule('a1.min.js', ['a.js'], async function () { const src = await readFile(this.dependencies[0], 'utf8') const dst = UglifyJS.minify(src).code await writeFile(this.target, dst) }) // equivelent to rule('a1.min.js', ['a.js'], async ctx => { const src = await readFile(ctx.dependencies[0], 'utf8') const dst = UglifyJS.minify(src).code await writeFile(ctx.target, dst) }) ``` ```javascript rule('clean', [], (ctx, done) => rimraf('{*.md5,*.min.js}', done)) ``` -------------------------------- ### MakeOptions Interface Source: https://github.com/searchfe/makit/blob/master/docs/modules/_make_.html Documentation for the MakeOptions interface within the 'make' module. ```APIDOC ## MakeOptions Interface ### Description Defines the options for the Make class. ### Interface `MakeOptions` ### Fields This interface may contain various fields related to make options. Refer to the source for specific field details. ``` -------------------------------- ### Static create Source: https://github.com/searchfe/makit/blob/master/docs/classes/_target_.target.html Factory method to create a new Target instance. ```APIDOC ## Static create ### Description Creates a new Target instance using the provided configuration. ### Parameters - **__namedParameters** (object) - Required - **fs** (FileSystem) - Required - **make** (function) - Required - Function taking a target string and returning a Promise - **match** (null | RegExpExecArray) - Optional - **root** (string) - Required - **rule** (undefined | Rule) - Optional - **target** (string) - Required ### Returns - **Target** - The created Target instance. ``` -------------------------------- ### ContextOptions Interface Source: https://github.com/searchfe/makit/blob/master/docs/modules/_context_.html Documentation for the ContextOptions interface within the Makit module. ```APIDOC ### Interface: ContextOptions #### Description Options for configuring a Context. #### Properties * **option1** (type) - Required - Description of option1. * **option2** (type) - Optional - Description of option2. ``` -------------------------------- ### MemoryFileSystem Class Overview Source: https://github.com/searchfe/makit/blob/master/docs/classes/_fs_memfs_impl_.memoryfilesystem.html This section provides an overview of the MemoryFileSystem class, including its properties and methods. ```APIDOC ## MemoryFileSystem Class ### Description Provides an in-memory file system implementation. ### Hierarchy * MemoryFileSystem ### Implements * [FileSystem](../interfaces/_fs_file_system_.filesystem.html) ### Properties * [fs](_fs_memfs_impl_.memoryfilesystem.html#fs) * [mtimes](_fs_memfs_impl_.memoryfilesystem.html#mtimes) * [now](_fs_memfs_impl_.memoryfilesystem.html#now) ### Methods * [exists](_fs_memfs_impl_.memoryfilesystem.html#exists) * [existsSync](_fs_memfs_impl_.memoryfilesystem.html#existssync) * [mkdir](_fs_memfs_impl_.memoryfilesystem.html#mkdir) * [mkdirSync](_fs_memfs_impl_.memoryfilesystem.html#mkdirsync) * [readFile](_fs_memfs_impl_.memoryfilesystem.html#readfile) * [readFileSync](_fs_memfs_impl_.memoryfilesystem.html#readfilesync) * [stat](_fs_memfs_impl_.memoryfilesystem.html#stat) * [statSync](_fs_memfs_impl_.memoryfilesystem.html#statsync) * [unlink](_fs_memfs_impl_.memoryfilesystem.html#unlink) * [unlinkSync](_fs_memfs_impl_.memoryfilesystem.html#unlinksync) * [utimes](_fs_memfs_impl_.memoryfilesystem.html#utimes) * [utimesSync](_fs_memfs_impl_.memoryfilesystem.html#utimessync) * [writeFile](_fs_memfs_impl_.memoryfilesystem.html#writefile) * [writeFileSync](_fs_memfs_impl_.memoryfilesystem.html#writefilesync) ``` -------------------------------- ### Glob and Pattern Matching Source: https://context7.com/searchfe/makit/llms.txt Explains how to use glob patterns and capturing groups for dynamic build rules. ```APIDOC ## Glob and Pattern Matching Targets ### Description Makit supports glob patterns and capturing groups in targets, allowing a single rule to match multiple files. Capturing groups use parentheses and can be referenced in prerequisites using $0, $1, etc. ### Usage - **Glob Patterns**: Use wildcards to match multiple files. - **Capturing Groups**: Use parentheses in the target string to capture parts of the path, which can then be referenced in the prerequisites array using back-references like $1, $2. ``` -------------------------------- ### Programmatically Trigger Builds (make) Source: https://context7.com/searchfe/makit/llms.txt Use `make()` to programmatically trigger a build for a specified target. This function returns a Promise that resolves when the target and its dependencies are built. Should not be called inside regular rule recipes; use `ctx.make()` within `rude()` for dynamic dependencies. Requires `make` to be imported from 'makit'. ```javascript const { rule, make } = require('makit') // Define rules rule('all', ['dist/app.js', 'dist/app.css']) rule('dist/app.js', ['src/app.js'], async function () { const src = await this.readDependency(0) await this.writeTarget(src) }) rule('dist/app.css', ['src/styles.css'], async function () { const src = await this.readDependency(0) await this.writeTarget(src) }) // Programmatically trigger builds async function build() { try { // Build default target (first rule) await make('all') console.log('Build completed successfully') // Or build specific target await make('dist/app.js') console.log('JavaScript build completed') } catch (err) { console.error('Build failed:', err.message) process.exit(1) } } build() ``` -------------------------------- ### getPrerequisites Method Source: https://github.com/searchfe/makit/blob/master/docs/classes/_makefile_prerequisites_.prerequisites.html Retrieves the prerequisites for a given context. ```APIDOC ## getPrerequisites ### Description Retrieves the prerequisites for a given context. ### Method GET ### Endpoint /searchfe/makit/prerequisites ### Parameters #### Query Parameters - **ctx** (Context) - Required - The context object to determine prerequisites. ### Response #### Success Response (200) - **prerequisites** (string[]) - An array of strings representing the prerequisites. #### Response Example ```json { "prerequisites": [ "prerequisite1", "prerequisite2" ] } ``` ``` -------------------------------- ### Recipe Class Methods Source: https://github.com/searchfe/makit/blob/master/docs/classes/_makefile_recipe_.recipe.html Documentation for the constructor and methods of the Recipe class. ```APIDOC ## constructor ### Description Creates a new instance of the Recipe class. ### Parameters - **fn** (RecipeDeclaration) - Required - The recipe declaration function. ### Returns - **Recipe** - A new instance of the Recipe class. --- ## make ### Description Executes the recipe within the provided context. ### Parameters - **context** (Context) - Required - The execution context for the recipe. ### Returns - **Promise** - A promise that resolves to a TimeStamp upon completion. --- ## __computed ### Description Computes a string representation or value associated with the recipe. ### Returns - **string** - The computed string value. ``` -------------------------------- ### Handle Dynamic Prerequisites with Rude Source: https://github.com/searchfe/makit/blob/master/README.md Illustrates the invalid use of global make() versus the correct usage of the rude() API for dynamic dependency resolution. ```javascript const { rule, make } = require('makit') rule('bundle.js', 'a.js', async (ctx) => { await make('b.js') const js = (await ctx.readFile('a.js')) + (await ctx.readFile('b.js')) ctx.writeTarget(js) }) ``` ```javascript const { rude } = require('makit') rude( 'bundle.js', [], async ctx => { await ctx.make('a.js') await ctx.make('b.js') const js = (await ctx.readFile('a.js')) + (await ctx.readFile('b.js')) return ctx.writeTarget(js) } ) ``` -------------------------------- ### Target Class Methods Source: https://github.com/searchfe/makit/blob/master/docs/classes/_target_.target.html Documentation for the methods available on a Target instance. ```APIDOC ## Target Methods ### __computed * **Description**: Computes a string representation of the target. * **Returns**: `string` ### addPromise * **Description**: Adds resolve and reject handlers to the target's promises. * **Parameters**: * `resolve` (function): A function to call when the target is resolved. It accepts a `TimeStamp` as an argument. * `reject` (function): A function to call when the target fails. It accepts an `Error` object as an argument. * **Returns**: `void` ### getDependencies * **Description**: Retrieves the list of dependencies for the target. * **Returns**: `string[]` - An array of dependency names. ### isFinished * **Description**: Checks if the target has completed processing. * **Returns**: `boolean` ### isReady * **Description**: Checks if the target is ready to be processed (i.e., all dependencies are met). * **Returns**: `boolean` ### isResolved * **Description**: Checks if the target has been successfully resolved. * **Returns**: `boolean` ### isStarted * **Description**: Checks if the target has started processing. * **Returns**: `boolean` ### reject * **Description**: Rejects the target with a given error. * **Parameters**: * `error` (Error): The error to reject with. * **Returns**: `void` ### reset * **Description**: Resets the target to its initial state. * **Returns**: `void` ### resolve * **Description**: Resolves the target, marking it as completed successfully. * **Parameters**: * `timestamp` (TimeStamp): The timestamp indicating when the target was resolved. * **Returns**: `void` ### start * **Description**: Starts the processing of the target. * **Returns**: `void` ### updateMtime * **Description**: Updates the modification time of the target. * **Parameters**: * `mtime` (number): The new modification time. * **Returns**: `void` ### writeDependency * **Description**: Records a dependency for the target. * **Parameters**: * `dependency` (string): The name of the dependency. * **Returns**: `void` ### create * **Description**: Static method to create a new Target instance. * **Parameters**: * `target` (string): The name of the target. * `context` (Context): The build context. * `mtime` (number): The modification time. * `rule` (Rule): Optional rule associated with the target. * **Returns**: `Target` ```