@secondlayer/cli 3.6.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +105 -99
- package/dist/cli.js.map +28 -28
- package/dist/core/plugin-manager.js +3 -3
- package/dist/core/plugin-manager.js.map +4 -4
- package/dist/index.js +9 -9
- package/dist/index.js.map +5 -5
- package/dist/plugins/index.js +17 -16
- package/dist/plugins/index.js.map +11 -11
- package/package.json +6 -6
- package/templates/subscriptions/inngest/src/server.ts +1 -1
- package/templates/subscriptions/node/src/index.ts +3 -1
|
@@ -118,8 +118,8 @@ var biome = null;
|
|
|
118
118
|
var init_format = () => {};
|
|
119
119
|
|
|
120
120
|
// src/core/plugin-manager.ts
|
|
121
|
-
import { promises as fs } from "fs";
|
|
122
|
-
import path from "path";
|
|
121
|
+
import { promises as fs } from "node:fs";
|
|
122
|
+
import path from "node:path";
|
|
123
123
|
import { isValidAddress as _validateStacksAddress } from "@secondlayer/stacks";
|
|
124
124
|
import { getErrorMessage } from "@secondlayer/shared";
|
|
125
125
|
import { toCamelCase } from "@secondlayer/stacks/clarity";
|
|
@@ -393,5 +393,5 @@ export {
|
|
|
393
393
|
PluginManager
|
|
394
394
|
};
|
|
395
395
|
|
|
396
|
-
//# debugId=
|
|
396
|
+
//# debugId=AADBC2745B9D119564756E2164756E21
|
|
397
397
|
//# sourceMappingURL=plugin-manager.js.map
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types/plugin.ts", "../src/utils/contract-id.ts", "../src/utils/format.ts", "../src/core/plugin-manager.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Plugin system types for @secondlayer/cli\n */\n\nimport type { AbiContract } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tNetworkName,\n\tResolvedContract,\n\tSecondLayerConfig,\n} from \"./config\";\n\n/**\n * Core plugin interface that all plugins must implement\n */\nexport interface SecondLayerPlugin {\n\t/** Plugin name (should be unique) */\n\tname: string;\n\n\t/** Plugin version */\n\tversion: string;\n\n\t// Lifecycle hooks\n\t/** Called after config is resolved but before generation starts */\n\tconfigResolved?: (config: ResolvedConfig) => void | Promise<void>;\n\n\t/** Called before generation starts */\n\tbeforeGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called during generation phase - plugins can add their own outputs */\n\tgenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called after all generation is complete */\n\tafterGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t// Transform hooks\n\t/** Transform user config before resolution */\n\ttransformConfig?: (config: UserConfig) => UserConfig | Promise<UserConfig>;\n\n\t/** Transform individual contracts during processing */\n\ttransformContract?: (\n\t\tcontract: ContractConfig,\n\t) => ContractConfig | Promise<ContractConfig>;\n\n\t/** Transform generated output before writing to disk */\n\ttransformOutput?: (\n\t\toutput: string,\n\t\ttype: OutputType,\n\t) => string | Promise<string>;\n}\n\n/**\n * User configuration (before plugin transformations)\n */\nexport type UserConfig = SecondLayerConfig;\n\n/**\n * Resolved configuration (after plugin transformations)\n */\nexport interface ResolvedConfig extends SecondLayerConfig {\n\t/** Resolved plugins array */\n\tplugins: SecondLayerPlugin[];\n}\n\n/**\n * Contract configuration that can be transformed by plugins\n */\nexport interface ContractConfig {\n\tname?: string;\n\taddress?: string | Partial<Record<NetworkName, string>>;\n\tsource?: string;\n\tabi?: AbiContract;\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Contract config from Clarinet plugin\n */\nexport interface ClarinetContractConfig extends ContractConfig {\n\t_clarinetSource: true;\n}\n\n/**\n * Contract config from direct file input\n */\nexport interface DirectFileContractConfig extends ContractConfig {\n\t_directFile: true;\n}\n\n/**\n * Union of all contract config types\n */\nexport type PluginContractConfig =\n\t| ContractConfig\n\t| ClarinetContractConfig\n\t| DirectFileContractConfig;\n\n/**\n * Type guard for Clarinet contracts\n */\nexport function isClarinetContract(\n\tc: ContractConfig,\n): c is ClarinetContractConfig {\n\treturn \"_clarinetSource\" in c && c._clarinetSource === true;\n}\n\n/**\n * Type guard for direct file contracts\n */\nexport function isDirectFileContract(\n\tc: ContractConfig,\n): c is DirectFileContractConfig {\n\treturn \"_directFile\" in c && c._directFile === true;\n}\n\n/**\n * Processed contract with resolved ABI and metadata\n */\nexport interface ProcessedContract extends ResolvedContract {\n\t/** Additional metadata added by plugins */\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Generated output from plugins\n */\nexport interface GeneratedOutput {\n\t/** File path where output should be written */\n\tpath: string;\n\n\t/** Generated content */\n\tcontent: string;\n\n\t/** Output type for transformation hooks */\n\ttype?: OutputType;\n\n\t/** Whether this output should overwrite existing files */\n\toverwrite?: boolean;\n}\n\n/**\n * Types of outputs that can be generated\n */\nexport type OutputType =\n\t| \"contracts\"\n\t| \"hooks\"\n\t| \"actions\"\n\t| \"types\"\n\t| \"utils\"\n\t| \"config\"\n\t| \"other\";\n\n/**\n * Base context available to all plugin hooks\n */\nexport interface PluginContext {\n\t/** Resolved configuration */\n\tconfig: ResolvedConfig;\n\n\t/** Logger for plugin output */\n\tlogger: Logger;\n\n\t/** Utility functions for plugins */\n\tutils: PluginUtils;\n}\n\n/**\n * Context available during generation phase\n */\nexport interface GenerateContext extends PluginContext {\n\t/** Processed contracts ready for generation */\n\tcontracts: ProcessedContract[];\n\n\t/** Map of output keys to generated content */\n\toutputs: Map<string, GeneratedOutput>;\n\n\t/** Function to augment existing outputs */\n\taugment: (outputKey: string, contractName: string, content: any) => void;\n\n\t/** Function to add new outputs */\n\taddOutput: (key: string, output: GeneratedOutput) => void;\n}\n\n/**\n * Logger interface for plugin output\n */\nexport interface Logger {\n\tinfo: (message: string) => void;\n\twarn: (message: string) => void;\n\terror: (message: string) => void;\n\tdebug: (message: string) => void;\n\tsuccess: (message: string) => void;\n}\n\n/**\n * Utility functions available to plugins\n */\nexport interface PluginUtils {\n\t/** Convert kebab-case to camelCase */\n\ttoCamelCase: (str: string) => string;\n\n\t/** Convert camelCase to kebab-case */\n\ttoKebabCase: (str: string) => string;\n\n\t/** Validate Stacks address format */\n\tvalidateAddress: (address: string) => boolean;\n\n\t/** Parse contract identifier (address.contract-name) */\n\tparseContractId: (contractId: string) => {\n\t\taddress: string;\n\t\tcontractName: string;\n\t};\n\n\t/** Format TypeScript code using prettier */\n\tformatCode: (code: string) => Promise<string>;\n\n\t/** Resolve file path relative to project root */\n\tresolvePath: (relativePath: string) => string;\n\n\t/** Check if file exists */\n\tfileExists: (path: string) => Promise<boolean>;\n\n\t/** Read file content */\n\treadFile: (path: string) => Promise<string>;\n\n\t/** Write file content */\n\twriteFile: (path: string, content: string) => Promise<void>;\n\n\t/** Create directory recursively */\n\tensureDir: (path: string) => Promise<void>;\n}\n\n/**\n * Plugin factory function type for creating plugins with options\n */\nexport type PluginFactory<TOptions = any> = (\n\toptions?: TOptions,\n) => SecondLayerPlugin;\n\n/**\n * Plugin options base interface\n */\nexport interface PluginOptions {\n\t/** Include only specific contracts/functions */\n\tinclude?: string[];\n\n\t/** Exclude specific contracts/functions */\n\texclude?: string[];\n\n\t/** Enable debug output */\n\tdebug?: boolean;\n}\n\n/**\n * Hook execution result\n */\nexport interface HookResult<T = any> {\n\t/** Whether the hook was successful */\n\tsuccess: boolean;\n\n\t/** Result data from the hook */\n\tdata?: T;\n\n\t/** Error if hook failed */\n\terror?: Error;\n\n\t/** Plugin that executed the hook */\n\tplugin: string;\n}\n\n/**\n * Plugin execution context for internal use\n */\nexport interface PluginExecutionContext {\n\t/** Current plugin being executed */\n\tcurrentPlugin?: SecondLayerPlugin;\n\n\t/** Execution phase */\n\tphase: \"config\" | \"generate\" | \"output\";\n\n\t/** Start time for performance tracking */\n\tstartTime: number;\n\n\t/** Plugin execution results */\n\tresults: Map<string, HookResult[]>;\n}\n",
|
|
5
|
+
"/**\n * Plugin system types for @secondlayer/cli\n */\n\nimport type { AbiContract } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tNetworkName,\n\tResolvedContract,\n\tSecondLayerConfig,\n} from \"./config\";\n\n/**\n * Core plugin interface that all plugins must implement\n */\nexport interface SecondLayerPlugin {\n\t/** Plugin name (should be unique) */\n\tname: string;\n\n\t/** Plugin version */\n\tversion: string;\n\n\t// Lifecycle hooks\n\t/** Called after config is resolved but before generation starts */\n\tconfigResolved?: (config: ResolvedConfig) => void | Promise<void>;\n\n\t/** Called before generation starts */\n\tbeforeGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called during generation phase - plugins can add their own outputs */\n\tgenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called after all generation is complete */\n\tafterGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t// Transform hooks\n\t/** Transform user config before resolution */\n\ttransformConfig?: (config: UserConfig) => UserConfig | Promise<UserConfig>;\n\n\t/** Transform individual contracts during processing */\n\ttransformContract?: (\n\t\tcontract: ContractConfig,\n\t) => ContractConfig | Promise<ContractConfig>;\n\n\t/** Transform generated output before writing to disk */\n\ttransformOutput?: (\n\t\toutput: string,\n\t\ttype: OutputType,\n\t) => string | Promise<string>;\n}\n\n/**\n * User configuration (before plugin transformations)\n */\nexport type UserConfig = SecondLayerConfig;\n\n/**\n * Resolved configuration (after plugin transformations)\n */\nexport interface ResolvedConfig extends SecondLayerConfig {\n\t/** Resolved plugins array */\n\tplugins: SecondLayerPlugin[];\n}\n\n/**\n * Contract configuration that can be transformed by plugins\n */\nexport interface ContractConfig {\n\tname?: string;\n\taddress?: string | Partial<Record<NetworkName, string>>;\n\tsource?: string;\n\tabi?: AbiContract;\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Contract config from Clarinet plugin\n */\nexport interface ClarinetContractConfig extends ContractConfig {\n\t_clarinetSource: true;\n}\n\n/**\n * Contract config from direct file input\n */\nexport interface DirectFileContractConfig extends ContractConfig {\n\t_directFile: true;\n}\n\n/**\n * Union of all contract config types\n */\nexport type PluginContractConfig =\n\t| ContractConfig\n\t| ClarinetContractConfig\n\t| DirectFileContractConfig;\n\n/**\n * Type guard for Clarinet contracts\n */\nexport function isClarinetContract(\n\tc: ContractConfig,\n): c is ClarinetContractConfig {\n\treturn \"_clarinetSource\" in c && c._clarinetSource === true;\n}\n\n/**\n * Type guard for direct file contracts\n */\nexport function isDirectFileContract(\n\tc: ContractConfig,\n): c is DirectFileContractConfig {\n\treturn \"_directFile\" in c && c._directFile === true;\n}\n\n/**\n * Processed contract with resolved ABI and metadata\n */\nexport interface ProcessedContract extends ResolvedContract {\n\t/** Additional metadata added by plugins */\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Generated output from plugins\n */\nexport interface GeneratedOutput {\n\t/** File path where output should be written */\n\tpath: string;\n\n\t/** Generated content */\n\tcontent: string;\n\n\t/** Output type for transformation hooks */\n\ttype?: OutputType;\n\n\t/** Whether this output should overwrite existing files */\n\toverwrite?: boolean;\n}\n\n/**\n * Types of outputs that can be generated\n */\nexport type OutputType =\n\t| \"contracts\"\n\t| \"hooks\"\n\t| \"actions\"\n\t| \"types\"\n\t| \"utils\"\n\t| \"config\"\n\t| \"other\";\n\n/**\n * Base context available to all plugin hooks\n */\nexport interface PluginContext {\n\t/** Resolved configuration */\n\tconfig: ResolvedConfig;\n\n\t/** Logger for plugin output */\n\tlogger: Logger;\n\n\t/** Utility functions for plugins */\n\tutils: PluginUtils;\n}\n\n/**\n * Context available during generation phase\n */\nexport interface GenerateContext extends PluginContext {\n\t/** Processed contracts ready for generation */\n\tcontracts: ProcessedContract[];\n\n\t/** Map of output keys to generated content */\n\toutputs: Map<string, GeneratedOutput>;\n\n\t/** Function to augment existing outputs */\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\taugment: (outputKey: string, contractName: string, content: any) => void;\n\n\t/** Function to add new outputs */\n\taddOutput: (key: string, output: GeneratedOutput) => void;\n}\n\n/**\n * Logger interface for plugin output\n */\nexport interface Logger {\n\tinfo: (message: string) => void;\n\twarn: (message: string) => void;\n\terror: (message: string) => void;\n\tdebug: (message: string) => void;\n\tsuccess: (message: string) => void;\n}\n\n/**\n * Utility functions available to plugins\n */\nexport interface PluginUtils {\n\t/** Convert kebab-case to camelCase */\n\ttoCamelCase: (str: string) => string;\n\n\t/** Convert camelCase to kebab-case */\n\ttoKebabCase: (str: string) => string;\n\n\t/** Validate Stacks address format */\n\tvalidateAddress: (address: string) => boolean;\n\n\t/** Parse contract identifier (address.contract-name) */\n\tparseContractId: (contractId: string) => {\n\t\taddress: string;\n\t\tcontractName: string;\n\t};\n\n\t/** Format TypeScript code using prettier */\n\tformatCode: (code: string) => Promise<string>;\n\n\t/** Resolve file path relative to project root */\n\tresolvePath: (relativePath: string) => string;\n\n\t/** Check if file exists */\n\tfileExists: (path: string) => Promise<boolean>;\n\n\t/** Read file content */\n\treadFile: (path: string) => Promise<string>;\n\n\t/** Write file content */\n\twriteFile: (path: string, content: string) => Promise<void>;\n\n\t/** Create directory recursively */\n\tensureDir: (path: string) => Promise<void>;\n}\n\n/**\n * Plugin factory function type for creating plugins with options\n */\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport type PluginFactory<TOptions = any> = (\n\toptions?: TOptions,\n) => SecondLayerPlugin;\n\n/**\n * Plugin options base interface\n */\nexport interface PluginOptions {\n\t/** Include only specific contracts/functions */\n\tinclude?: string[];\n\n\t/** Exclude specific contracts/functions */\n\texclude?: string[];\n\n\t/** Enable debug output */\n\tdebug?: boolean;\n}\n\n/**\n * Hook execution result\n */\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport interface HookResult<T = any> {\n\t/** Whether the hook was successful */\n\tsuccess: boolean;\n\n\t/** Result data from the hook */\n\tdata?: T;\n\n\t/** Error if hook failed */\n\terror?: Error;\n\n\t/** Plugin that executed the hook */\n\tplugin: string;\n}\n\n/**\n * Plugin execution context for internal use\n */\nexport interface PluginExecutionContext {\n\t/** Current plugin being executed */\n\tcurrentPlugin?: SecondLayerPlugin;\n\n\t/** Execution phase */\n\tphase: \"config\" | \"generate\" | \"output\";\n\n\t/** Start time for performance tracking */\n\tstartTime: number;\n\n\t/** Plugin execution results */\n\tresults: Map<string, HookResult[]>;\n}\n",
|
|
6
6
|
"/**\n * Parse a fully-qualified contract ID (\"address.contractName\") into its parts.\n * Throws if the input doesn't contain a dot separator.\n */\nexport function parseContractId(contractId: string): {\n\taddress: string;\n\tcontractName: string;\n} {\n\tconst dotIndex = contractId.indexOf(\".\");\n\tif (dotIndex === -1) {\n\t\tthrow new Error(\n\t\t\t`Invalid contract ID: \"${contractId}\" (expected \"address.contractName\")`,\n\t\t);\n\t}\n\treturn {\n\t\taddress: contractId.slice(0, dotIndex),\n\t\tcontractName: contractId.slice(dotIndex + 1),\n\t};\n}\n",
|
|
7
7
|
"/**\n * Shared code formatting utilities using Biome\n */\n\nimport { Biome, Distribution } from \"@biomejs/js-api\";\n\nlet biome: Biome | null = null;\n\n/**\n * Lazily initialize Biome singleton\n */\nasync function getBiome(): Promise<Biome> {\n\tif (!biome) {\n\t\tbiome = await Biome.create({\n\t\t\tdistribution: Distribution.NODE,\n\t\t});\n\n\t\tbiome.applyConfiguration({\n\t\t\tformatter: {\n\t\t\t\tenabled: true,\n\t\t\t\tindentStyle: \"tab\",\n\t\t\t\tlineWidth: 80,\n\t\t\t},\n\t\t\tjavascript: {\n\t\t\t\tformatter: {\n\t\t\t\t\tsemicolons: \"always\",\n\t\t\t\t\tquoteStyle: \"single\",\n\t\t\t\t},\n\t\t\t},\n\t\t\torganizeImports: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t\tlinter: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t\tassists: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t});\n\n\t\tbiome.registerProjectFolder();\n\t}\n\n\treturn biome;\n}\n\n/**\n * Format TypeScript code using Biome\n */\nexport async function formatCode(code: string): Promise<string> {\n\tconst b = await getBiome();\n\n\t// Use lintContent with SafeFixes to organize imports\n\tconst linted = b.lintContent(code, {\n\t\tfilePath: \"generated.ts\",\n\t\tfixFileMode: \"SafeFixes\",\n\t});\n\n\t// Then format\n\tconst formatted = b.formatContent(linted.content, {\n\t\tfilePath: \"generated.ts\",\n\t});\n\n\treturn formatted.content;\n}\n",
|
|
8
|
-
"/**\n * Plugin Manager for @secondlayer/cli\n * Handles plugin registration, lifecycle execution, and output management\n */\n\nimport { promises as fs } from \"fs\";\nimport path from \"path\";\nimport { isValidAddress as _validateStacksAddress } from \"@secondlayer/stacks\";\nconst validateStacksAddress = _validateStacksAddress as (\n\taddress: string,\n) => boolean;\nimport { getErrorMessage } from \"@secondlayer/shared\";\nimport { toCamelCase } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tContractConfig,\n\tGenerateContext,\n\tGeneratedOutput,\n\tHookResult,\n\tLogger,\n\tPluginExecutionContext,\n\tPluginUtils,\n\tProcessedContract,\n\tResolvedConfig,\n\tSecondLayerPlugin,\n\tUserConfig,\n} from \"../types/plugin\";\nimport { isClarinetContract, isDirectFileContract } from \"../types/plugin\";\nimport { parseContractId } from \"../utils/contract-id\";\n\n/**\n * Core plugin manager that orchestrates plugin execution\n */\nexport class PluginManager {\n\tprivate plugins: SecondLayerPlugin[] = [];\n\tprivate logger: Logger;\n\tprivate utils: PluginUtils;\n\tprivate executionContext: PluginExecutionContext;\n\n\tconstructor() {\n\t\tthis.logger = this.createLogger();\n\t\tthis.utils = this.createUtils();\n\t\tthis.executionContext = {\n\t\t\tphase: \"config\",\n\t\t\tstartTime: Date.now(),\n\t\t\tresults: new Map(),\n\t\t};\n\t}\n\n\t/**\n\t * Register a plugin\n\t */\n\tregister(plugin: SecondLayerPlugin): void {\n\t\t// Validate plugin\n\t\tif (!plugin.name || !plugin.version) {\n\t\t\tthrow new Error(\"Plugin must have a name and version\");\n\t\t}\n\n\t\t// Check for duplicate plugin names\n\t\tconst existing = this.plugins.find((p) => p.name === plugin.name);\n\t\tif (existing) {\n\t\t\tthrow new Error(\n\t\t\t\t`Plugin \"${plugin.name}\" is already registered (version ${existing.version})`,\n\t\t\t);\n\t\t}\n\n\t\tthis.plugins.push(plugin);\n\t\tthis.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetPlugins(): SecondLayerPlugin[] {\n\t\treturn [...this.plugins];\n\t}\n\n\t/**\n\t * Transform user config through all plugins\n\t */\n\tasync transformConfig(config: UserConfig): Promise<ResolvedConfig> {\n\t\tthis.executionContext.phase = \"config\";\n\t\tlet transformedConfig = { ...config };\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tif (plugin.transformConfig) {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await plugin.transformConfig(transformedConfig);\n\t\t\t\t\ttransformedConfig = result;\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during config transformation: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add plugins array to resolved config\n\t\tconst resolvedConfig: ResolvedConfig = {\n\t\t\t...transformedConfig,\n\t\t\tplugins: this.plugins,\n\t\t};\n\n\t\treturn resolvedConfig;\n\t}\n\n\t/**\n\t * Transform contracts through all plugins\n\t */\n\tasync transformContracts(\n\t\tcontracts: ContractConfig[],\n\t\t_config: ResolvedConfig,\n\t): Promise<ProcessedContract[]> {\n\t\tconst processedContracts: ProcessedContract[] = [];\n\n\t\tfor (let contract of contracts) {\n\t\t\tif (isClarinetContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"clarinet\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectFileContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"direct\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Transform through each plugin\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformContract) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontract = await plugin.transformContract(contract);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform contract: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"api\"));\n\t\t\t}\n\t\t}\n\n\t\treturn processedContracts;\n\t}\n\n\t/**\n\t * Execute lifecycle hooks\n\t */\n\tasync executeHook(\n\t\thookName: keyof SecondLayerPlugin,\n\t\tcontext: any,\n\t): Promise<void> {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst hook = plugin[hookName];\n\t\t\tif (typeof hook === \"function\") {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\tawait (hook as any).call(plugin, context);\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during ${hookName as string}: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t\t// Don't throw - allow other plugins to continue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Execute generation phase with full context\n\t */\n\tasync executeGeneration(\n\t\tcontracts: ProcessedContract[],\n\t\tconfig: ResolvedConfig,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"generate\";\n\t\tconst outputs = new Map<string, GeneratedOutput>();\n\n\t\t// Create generation context\n\t\tconst context: GenerateContext = {\n\t\t\tconfig,\n\t\t\tlogger: this.logger,\n\t\t\tutils: this.utils,\n\t\t\tcontracts,\n\t\t\toutputs,\n\t\t\taugment: (outputKey: string, contractName: string, content: any) => {\n\t\t\t\tthis.augmentOutput(outputs, outputKey, contractName, content);\n\t\t\t},\n\t\t\taddOutput: (key: string, output: GeneratedOutput) => {\n\t\t\t\toutputs.set(key, output);\n\t\t\t},\n\t\t};\n\n\t\t// Execute beforeGenerate hooks\n\t\tawait this.executeHook(\"beforeGenerate\", context);\n\n\t\t// Execute generate hooks\n\t\tawait this.executeHook(\"generate\", context);\n\n\t\t// Execute afterGenerate hooks\n\t\tawait this.executeHook(\"afterGenerate\", context);\n\n\t\treturn outputs;\n\t}\n\n\t/**\n\t * Transform outputs through plugins\n\t */\n\tasync transformOutputs(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"output\";\n\t\tconst transformedOutputs = new Map<string, GeneratedOutput>();\n\n\t\tfor (const [key, output] of outputs) {\n\t\t\tlet transformedContent = output.content;\n\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformOutput) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttransformedContent = await plugin.transformOutput(\n\t\t\t\t\t\t\ttransformedContent,\n\t\t\t\t\t\t\toutput.type || \"other\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform output: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttransformedOutputs.set(key, {\n\t\t\t\t...output,\n\t\t\t\tcontent: transformedContent,\n\t\t\t});\n\t\t}\n\n\t\treturn transformedOutputs;\n\t}\n\n\t/**\n\t * Write outputs to disk\n\t */\n\tasync writeOutputs(outputs: Map<string, GeneratedOutput>): Promise<void> {\n\t\tfor (const [, output] of outputs) {\n\t\t\ttry {\n\t\t\t\tconst resolvedPath = path.resolve(process.cwd(), output.path);\n\t\t\t\tawait this.utils.ensureDir(path.dirname(resolvedPath));\n\t\t\t\tawait this.utils.writeFile(resolvedPath, output.content);\n\t\t\t\t// Don't log here - let the main command handle success messaging\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t`Failed to write ${output.path}: ${getErrorMessage(error)}`,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get execution results for debugging\n\t */\n\tgetExecutionResults(): Map<string, HookResult[]> {\n\t\treturn new Map(this.executionContext.results);\n\t}\n\n\t/**\n\t * Convert a contract config with an ABI into a ProcessedContract\n\t */\n\tprivate contractToProcessed(\n\t\tcontract: ContractConfig,\n\t\tsource: string,\n\t): ProcessedContract {\n\t\tconst address =\n\t\t\ttypeof contract.address === \"string\" ? contract.address : \"\";\n\t\tconst parsed = parseContractId(address);\n\t\treturn {\n\t\t\tname: contract.name || parsed.contractName || \"unknown\",\n\t\t\taddress: parsed.address || \"unknown\",\n\t\t\tcontractName: parsed.contractName || contract.name || \"unknown\",\n\t\t\tabi: contract.abi!,\n\t\t\tsource: source === \"api\" ? (\"api\" as const) : (\"local\" as const),\n\t\t\tmetadata: contract.metadata ?? { source },\n\t\t};\n\t}\n\n\t/**\n\t * Augment existing output with additional content\n\t */\n\tprivate augmentOutput(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t\toutputKey: string,\n\t\tcontractName: string,\n\t\tcontent: any,\n\t): void {\n\t\tconst existing = outputs.get(outputKey);\n\t\tif (!existing) {\n\t\t\tthis.logger.warn(`Cannot augment non-existent output: ${outputKey}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Simple augmentation - append content\n\t\t// In a real implementation, this would be more sophisticated\n\t\tconst augmentedContent = `${existing.content}\\n\\n// Augmented by plugin for ${contractName}\\n${JSON.stringify(content, null, 2)}`;\n\n\t\toutputs.set(outputKey, {\n\t\t\t...existing,\n\t\t\tcontent: augmentedContent,\n\t\t});\n\t}\n\n\t/**\n\t * Record hook execution result\n\t */\n\tprivate recordHookResult(\n\t\tpluginName: string,\n\t\thookName: string,\n\t\tresult: Omit<HookResult, \"plugin\">,\n\t): void {\n\t\tconst key = `${pluginName}:${hookName}`;\n\t\tconst existing = this.executionContext.results.get(key) || [];\n\t\texisting.push({ ...result, plugin: pluginName });\n\t\tthis.executionContext.results.set(key, existing);\n\t}\n\n\t/**\n\t * Create logger instance\n\t */\n\tprivate createLogger(): Logger {\n\t\treturn {\n\t\t\tinfo: (message: string) => console.log(`ℹ️ ${message}`),\n\t\t\twarn: (message: string) => console.warn(`⚠️ ${message}`),\n\t\t\terror: (message: string) => console.error(`❌ ${message}`),\n\t\t\tdebug: (message: string) => {\n\t\t\t\tif (process.env.DEBUG) {\n\t\t\t\t\tconsole.log(`🐛 ${message}`);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsuccess: (message: string) => console.log(`✅ ${message}`),\n\t\t};\n\t}\n\n\t/**\n\t * Create utils instance\n\t */\n\tprivate createUtils(): PluginUtils {\n\t\treturn {\n\t\t\ttoCamelCase,\n\n\t\t\ttoKebabCase: (str: string) => {\n\t\t\t\treturn str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\t\t\t},\n\n\t\t\tvalidateAddress: (address: string) => {\n\t\t\t\treturn validateStacksAddress(parseContractId(address).address);\n\t\t\t},\n\n\t\t\tparseContractId: (contractId: string) => {\n\t\t\t\treturn parseContractId(contractId);\n\t\t\t},\n\n\t\t\tformatCode: async (code: string) => {\n\t\t\t\tconst { formatCode } = await import(\"../utils/format\");\n\t\t\t\treturn formatCode(code);\n\t\t\t},\n\n\t\t\tresolvePath: (relativePath: string) => {\n\t\t\t\treturn path.resolve(process.cwd(), relativePath);\n\t\t\t},\n\n\t\t\tfileExists: async (filePath: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.access(filePath);\n\t\t\t\t\treturn true;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treadFile: async (filePath: string) => {\n\t\t\t\treturn fs.readFile(filePath, \"utf-8\");\n\t\t\t},\n\n\t\t\twriteFile: async (filePath: string, content: string) => {\n\t\t\t\tawait fs.writeFile(filePath, content, \"utf-8\");\n\t\t\t},\n\n\t\t\tensureDir: async (dirPath: string) => {\n\t\t\t\tawait fs.mkdir(dirPath, { recursive: true });\n\t\t\t},\n\t\t};\n\t}\n}\n"
|
|
8
|
+
"/**\n * Plugin Manager for @secondlayer/cli\n * Handles plugin registration, lifecycle execution, and output management\n */\n\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { isValidAddress as _validateStacksAddress } from \"@secondlayer/stacks\";\nconst validateStacksAddress = _validateStacksAddress as (\n\taddress: string,\n) => boolean;\nimport { getErrorMessage } from \"@secondlayer/shared\";\nimport { toCamelCase } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tContractConfig,\n\tGenerateContext,\n\tGeneratedOutput,\n\tHookResult,\n\tLogger,\n\tPluginExecutionContext,\n\tPluginUtils,\n\tProcessedContract,\n\tResolvedConfig,\n\tSecondLayerPlugin,\n\tUserConfig,\n} from \"../types/plugin\";\nimport { isClarinetContract, isDirectFileContract } from \"../types/plugin\";\nimport { parseContractId } from \"../utils/contract-id\";\n\n/**\n * Core plugin manager that orchestrates plugin execution\n */\nexport class PluginManager {\n\tprivate plugins: SecondLayerPlugin[] = [];\n\tprivate logger: Logger;\n\tprivate utils: PluginUtils;\n\tprivate executionContext: PluginExecutionContext;\n\n\tconstructor() {\n\t\tthis.logger = this.createLogger();\n\t\tthis.utils = this.createUtils();\n\t\tthis.executionContext = {\n\t\t\tphase: \"config\",\n\t\t\tstartTime: Date.now(),\n\t\t\tresults: new Map(),\n\t\t};\n\t}\n\n\t/**\n\t * Register a plugin\n\t */\n\tregister(plugin: SecondLayerPlugin): void {\n\t\t// Validate plugin\n\t\tif (!plugin.name || !plugin.version) {\n\t\t\tthrow new Error(\"Plugin must have a name and version\");\n\t\t}\n\n\t\t// Check for duplicate plugin names\n\t\tconst existing = this.plugins.find((p) => p.name === plugin.name);\n\t\tif (existing) {\n\t\t\tthrow new Error(\n\t\t\t\t`Plugin \"${plugin.name}\" is already registered (version ${existing.version})`,\n\t\t\t);\n\t\t}\n\n\t\tthis.plugins.push(plugin);\n\t\tthis.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetPlugins(): SecondLayerPlugin[] {\n\t\treturn [...this.plugins];\n\t}\n\n\t/**\n\t * Transform user config through all plugins\n\t */\n\tasync transformConfig(config: UserConfig): Promise<ResolvedConfig> {\n\t\tthis.executionContext.phase = \"config\";\n\t\tlet transformedConfig = { ...config };\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tif (plugin.transformConfig) {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await plugin.transformConfig(transformedConfig);\n\t\t\t\t\ttransformedConfig = result;\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during config transformation: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add plugins array to resolved config\n\t\tconst resolvedConfig: ResolvedConfig = {\n\t\t\t...transformedConfig,\n\t\t\tplugins: this.plugins,\n\t\t};\n\n\t\treturn resolvedConfig;\n\t}\n\n\t/**\n\t * Transform contracts through all plugins\n\t */\n\tasync transformContracts(\n\t\tcontracts: ContractConfig[],\n\t\t_config: ResolvedConfig,\n\t): Promise<ProcessedContract[]> {\n\t\tconst processedContracts: ProcessedContract[] = [];\n\n\t\tfor (let contract of contracts) {\n\t\t\tif (isClarinetContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"clarinet\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectFileContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"direct\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Transform through each plugin\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformContract) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontract = await plugin.transformContract(contract);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform contract: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"api\"));\n\t\t\t}\n\t\t}\n\n\t\treturn processedContracts;\n\t}\n\n\t/**\n\t * Execute lifecycle hooks\n\t */\n\tasync executeHook(\n\t\thookName: keyof SecondLayerPlugin,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcontext: any,\n\t): Promise<void> {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst hook = plugin[hookName];\n\t\t\tif (typeof hook === \"function\") {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\t\t\tawait (hook as any).call(plugin, context);\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during ${hookName as string}: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t\t// Don't throw - allow other plugins to continue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Execute generation phase with full context\n\t */\n\tasync executeGeneration(\n\t\tcontracts: ProcessedContract[],\n\t\tconfig: ResolvedConfig,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"generate\";\n\t\tconst outputs = new Map<string, GeneratedOutput>();\n\n\t\t// Create generation context\n\t\tconst context: GenerateContext = {\n\t\t\tconfig,\n\t\t\tlogger: this.logger,\n\t\t\tutils: this.utils,\n\t\t\tcontracts,\n\t\t\toutputs,\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\taugment: (outputKey: string, contractName: string, content: any) => {\n\t\t\t\tthis.augmentOutput(outputs, outputKey, contractName, content);\n\t\t\t},\n\t\t\taddOutput: (key: string, output: GeneratedOutput) => {\n\t\t\t\toutputs.set(key, output);\n\t\t\t},\n\t\t};\n\n\t\t// Execute beforeGenerate hooks\n\t\tawait this.executeHook(\"beforeGenerate\", context);\n\n\t\t// Execute generate hooks\n\t\tawait this.executeHook(\"generate\", context);\n\n\t\t// Execute afterGenerate hooks\n\t\tawait this.executeHook(\"afterGenerate\", context);\n\n\t\treturn outputs;\n\t}\n\n\t/**\n\t * Transform outputs through plugins\n\t */\n\tasync transformOutputs(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"output\";\n\t\tconst transformedOutputs = new Map<string, GeneratedOutput>();\n\n\t\tfor (const [key, output] of outputs) {\n\t\t\tlet transformedContent = output.content;\n\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformOutput) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttransformedContent = await plugin.transformOutput(\n\t\t\t\t\t\t\ttransformedContent,\n\t\t\t\t\t\t\toutput.type || \"other\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform output: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttransformedOutputs.set(key, {\n\t\t\t\t...output,\n\t\t\t\tcontent: transformedContent,\n\t\t\t});\n\t\t}\n\n\t\treturn transformedOutputs;\n\t}\n\n\t/**\n\t * Write outputs to disk\n\t */\n\tasync writeOutputs(outputs: Map<string, GeneratedOutput>): Promise<void> {\n\t\tfor (const [, output] of outputs) {\n\t\t\ttry {\n\t\t\t\tconst resolvedPath = path.resolve(process.cwd(), output.path);\n\t\t\t\tawait this.utils.ensureDir(path.dirname(resolvedPath));\n\t\t\t\tawait this.utils.writeFile(resolvedPath, output.content);\n\t\t\t\t// Don't log here - let the main command handle success messaging\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t`Failed to write ${output.path}: ${getErrorMessage(error)}`,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get execution results for debugging\n\t */\n\tgetExecutionResults(): Map<string, HookResult[]> {\n\t\treturn new Map(this.executionContext.results);\n\t}\n\n\t/**\n\t * Convert a contract config with an ABI into a ProcessedContract\n\t */\n\tprivate contractToProcessed(\n\t\tcontract: ContractConfig,\n\t\tsource: string,\n\t): ProcessedContract {\n\t\tconst address =\n\t\t\ttypeof contract.address === \"string\" ? contract.address : \"\";\n\t\tconst parsed = parseContractId(address);\n\t\treturn {\n\t\t\tname: contract.name || parsed.contractName || \"unknown\",\n\t\t\taddress: parsed.address || \"unknown\",\n\t\t\tcontractName: parsed.contractName || contract.name || \"unknown\",\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tabi: contract.abi!,\n\t\t\tsource: source === \"api\" ? (\"api\" as const) : (\"local\" as const),\n\t\t\tmetadata: contract.metadata ?? { source },\n\t\t};\n\t}\n\n\t/**\n\t * Augment existing output with additional content\n\t */\n\tprivate augmentOutput(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t\toutputKey: string,\n\t\tcontractName: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcontent: any,\n\t): void {\n\t\tconst existing = outputs.get(outputKey);\n\t\tif (!existing) {\n\t\t\tthis.logger.warn(`Cannot augment non-existent output: ${outputKey}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Simple augmentation - append content\n\t\t// In a real implementation, this would be more sophisticated\n\t\tconst augmentedContent = `${existing.content}\\n\\n// Augmented by plugin for ${contractName}\\n${JSON.stringify(content, null, 2)}`;\n\n\t\toutputs.set(outputKey, {\n\t\t\t...existing,\n\t\t\tcontent: augmentedContent,\n\t\t});\n\t}\n\n\t/**\n\t * Record hook execution result\n\t */\n\tprivate recordHookResult(\n\t\tpluginName: string,\n\t\thookName: string,\n\t\tresult: Omit<HookResult, \"plugin\">,\n\t): void {\n\t\tconst key = `${pluginName}:${hookName}`;\n\t\tconst existing = this.executionContext.results.get(key) || [];\n\t\texisting.push({ ...result, plugin: pluginName });\n\t\tthis.executionContext.results.set(key, existing);\n\t}\n\n\t/**\n\t * Create logger instance\n\t */\n\tprivate createLogger(): Logger {\n\t\treturn {\n\t\t\tinfo: (message: string) => console.log(`ℹ️ ${message}`),\n\t\t\twarn: (message: string) => console.warn(`⚠️ ${message}`),\n\t\t\terror: (message: string) => console.error(`❌ ${message}`),\n\t\t\tdebug: (message: string) => {\n\t\t\t\tif (process.env.DEBUG) {\n\t\t\t\t\tconsole.log(`🐛 ${message}`);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsuccess: (message: string) => console.log(`✅ ${message}`),\n\t\t};\n\t}\n\n\t/**\n\t * Create utils instance\n\t */\n\tprivate createUtils(): PluginUtils {\n\t\treturn {\n\t\t\ttoCamelCase,\n\n\t\t\ttoKebabCase: (str: string) => {\n\t\t\t\treturn str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\t\t\t},\n\n\t\t\tvalidateAddress: (address: string) => {\n\t\t\t\treturn validateStacksAddress(parseContractId(address).address);\n\t\t\t},\n\n\t\t\tparseContractId: (contractId: string) => {\n\t\t\t\treturn parseContractId(contractId);\n\t\t\t},\n\n\t\t\tformatCode: async (code: string) => {\n\t\t\t\tconst { formatCode } = await import(\"../utils/format\");\n\t\t\t\treturn formatCode(code);\n\t\t\t},\n\n\t\t\tresolvePath: (relativePath: string) => {\n\t\t\t\treturn path.resolve(process.cwd(), relativePath);\n\t\t\t},\n\n\t\t\tfileExists: async (filePath: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.access(filePath);\n\t\t\t\t\treturn true;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treadFile: async (filePath: string) => {\n\t\t\t\treturn fs.readFile(filePath, \"utf-8\");\n\t\t\t},\n\n\t\t\twriteFile: async (filePath: string, content: string) => {\n\t\t\t\tawait fs.writeFile(filePath, content, \"utf-8\");\n\t\t\t},\n\n\t\t\tensureDir: async (dirPath: string) => {\n\t\t\t\tawait fs.mkdir(dirPath, { recursive: true });\n\t\t\t},\n\t\t};\n\t}\n}\n"
|
|
9
9
|
],
|
|
10
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
11
|
-
"debugId": "
|
|
10
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoGO,SAAS,kBAAkB,CACjC,GAC8B;AAAA,EAC9B,OAAO,qBAAqB,KAAK,EAAE,oBAAoB;AAAA;AAMjD,SAAS,oBAAoB,CACnC,GACgC;AAAA,EAChC,OAAO,iBAAiB,KAAK,EAAE,gBAAgB;AAAA;;;AC5GzC,SAAS,eAAe,CAAC,YAG9B;AAAA,EACD,MAAM,WAAW,WAAW,QAAQ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
|
11
|
+
"debugId": "AADBC2745B9D119564756E2164756E21",
|
|
12
12
|
"names": []
|
|
13
13
|
}
|
package/dist/index.js
CHANGED
|
@@ -118,8 +118,8 @@ var biome = null;
|
|
|
118
118
|
var init_format = () => {};
|
|
119
119
|
|
|
120
120
|
// src/core/plugin-manager.ts
|
|
121
|
-
import { promises as fs } from "fs";
|
|
122
|
-
import path from "path";
|
|
121
|
+
import { promises as fs } from "node:fs";
|
|
122
|
+
import path from "node:path";
|
|
123
123
|
import { isValidAddress as _validateStacksAddress } from "@secondlayer/stacks";
|
|
124
124
|
import { getErrorMessage } from "@secondlayer/shared";
|
|
125
125
|
import { toCamelCase } from "@secondlayer/stacks/clarity";
|
|
@@ -389,12 +389,12 @@ var init_plugin_manager = __esm(() => {
|
|
|
389
389
|
});
|
|
390
390
|
|
|
391
391
|
// src/utils/config.ts
|
|
392
|
-
import { randomBytes } from "crypto";
|
|
393
|
-
import { promises as fs2 } from "fs";
|
|
394
|
-
import { createRequire as createRequire2 } from "module";
|
|
395
|
-
import { tmpdir } from "os";
|
|
396
|
-
import path2 from "path";
|
|
397
|
-
import { pathToFileURL } from "url";
|
|
392
|
+
import { randomBytes } from "node:crypto";
|
|
393
|
+
import { promises as fs2 } from "node:fs";
|
|
394
|
+
import { createRequire as createRequire2 } from "node:module";
|
|
395
|
+
import { tmpdir } from "node:os";
|
|
396
|
+
import path2 from "node:path";
|
|
397
|
+
import { pathToFileURL } from "node:url";
|
|
398
398
|
async function findConfigFile(cwd) {
|
|
399
399
|
for (const fileName of CONFIG_FILE_NAMES) {
|
|
400
400
|
const filePath = path2.join(cwd, fileName);
|
|
@@ -504,5 +504,5 @@ export {
|
|
|
504
504
|
PluginManager
|
|
505
505
|
};
|
|
506
506
|
|
|
507
|
-
//# debugId=
|
|
507
|
+
//# debugId=3060870279D1AD3464756E2164756E21
|
|
508
508
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/types/plugin.ts", "../src/utils/contract-id.ts", "../src/utils/format.ts", "../src/core/plugin-manager.ts", "../src/utils/config.ts", "../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * Plugin system types for @secondlayer/cli\n */\n\nimport type { AbiContract } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tNetworkName,\n\tResolvedContract,\n\tSecondLayerConfig,\n} from \"./config\";\n\n/**\n * Core plugin interface that all plugins must implement\n */\nexport interface SecondLayerPlugin {\n\t/** Plugin name (should be unique) */\n\tname: string;\n\n\t/** Plugin version */\n\tversion: string;\n\n\t// Lifecycle hooks\n\t/** Called after config is resolved but before generation starts */\n\tconfigResolved?: (config: ResolvedConfig) => void | Promise<void>;\n\n\t/** Called before generation starts */\n\tbeforeGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called during generation phase - plugins can add their own outputs */\n\tgenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called after all generation is complete */\n\tafterGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t// Transform hooks\n\t/** Transform user config before resolution */\n\ttransformConfig?: (config: UserConfig) => UserConfig | Promise<UserConfig>;\n\n\t/** Transform individual contracts during processing */\n\ttransformContract?: (\n\t\tcontract: ContractConfig,\n\t) => ContractConfig | Promise<ContractConfig>;\n\n\t/** Transform generated output before writing to disk */\n\ttransformOutput?: (\n\t\toutput: string,\n\t\ttype: OutputType,\n\t) => string | Promise<string>;\n}\n\n/**\n * User configuration (before plugin transformations)\n */\nexport type UserConfig = SecondLayerConfig;\n\n/**\n * Resolved configuration (after plugin transformations)\n */\nexport interface ResolvedConfig extends SecondLayerConfig {\n\t/** Resolved plugins array */\n\tplugins: SecondLayerPlugin[];\n}\n\n/**\n * Contract configuration that can be transformed by plugins\n */\nexport interface ContractConfig {\n\tname?: string;\n\taddress?: string | Partial<Record<NetworkName, string>>;\n\tsource?: string;\n\tabi?: AbiContract;\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Contract config from Clarinet plugin\n */\nexport interface ClarinetContractConfig extends ContractConfig {\n\t_clarinetSource: true;\n}\n\n/**\n * Contract config from direct file input\n */\nexport interface DirectFileContractConfig extends ContractConfig {\n\t_directFile: true;\n}\n\n/**\n * Union of all contract config types\n */\nexport type PluginContractConfig =\n\t| ContractConfig\n\t| ClarinetContractConfig\n\t| DirectFileContractConfig;\n\n/**\n * Type guard for Clarinet contracts\n */\nexport function isClarinetContract(\n\tc: ContractConfig,\n): c is ClarinetContractConfig {\n\treturn \"_clarinetSource\" in c && c._clarinetSource === true;\n}\n\n/**\n * Type guard for direct file contracts\n */\nexport function isDirectFileContract(\n\tc: ContractConfig,\n): c is DirectFileContractConfig {\n\treturn \"_directFile\" in c && c._directFile === true;\n}\n\n/**\n * Processed contract with resolved ABI and metadata\n */\nexport interface ProcessedContract extends ResolvedContract {\n\t/** Additional metadata added by plugins */\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Generated output from plugins\n */\nexport interface GeneratedOutput {\n\t/** File path where output should be written */\n\tpath: string;\n\n\t/** Generated content */\n\tcontent: string;\n\n\t/** Output type for transformation hooks */\n\ttype?: OutputType;\n\n\t/** Whether this output should overwrite existing files */\n\toverwrite?: boolean;\n}\n\n/**\n * Types of outputs that can be generated\n */\nexport type OutputType =\n\t| \"contracts\"\n\t| \"hooks\"\n\t| \"actions\"\n\t| \"types\"\n\t| \"utils\"\n\t| \"config\"\n\t| \"other\";\n\n/**\n * Base context available to all plugin hooks\n */\nexport interface PluginContext {\n\t/** Resolved configuration */\n\tconfig: ResolvedConfig;\n\n\t/** Logger for plugin output */\n\tlogger: Logger;\n\n\t/** Utility functions for plugins */\n\tutils: PluginUtils;\n}\n\n/**\n * Context available during generation phase\n */\nexport interface GenerateContext extends PluginContext {\n\t/** Processed contracts ready for generation */\n\tcontracts: ProcessedContract[];\n\n\t/** Map of output keys to generated content */\n\toutputs: Map<string, GeneratedOutput>;\n\n\t/** Function to augment existing outputs */\n\taugment: (outputKey: string, contractName: string, content: any) => void;\n\n\t/** Function to add new outputs */\n\taddOutput: (key: string, output: GeneratedOutput) => void;\n}\n\n/**\n * Logger interface for plugin output\n */\nexport interface Logger {\n\tinfo: (message: string) => void;\n\twarn: (message: string) => void;\n\terror: (message: string) => void;\n\tdebug: (message: string) => void;\n\tsuccess: (message: string) => void;\n}\n\n/**\n * Utility functions available to plugins\n */\nexport interface PluginUtils {\n\t/** Convert kebab-case to camelCase */\n\ttoCamelCase: (str: string) => string;\n\n\t/** Convert camelCase to kebab-case */\n\ttoKebabCase: (str: string) => string;\n\n\t/** Validate Stacks address format */\n\tvalidateAddress: (address: string) => boolean;\n\n\t/** Parse contract identifier (address.contract-name) */\n\tparseContractId: (contractId: string) => {\n\t\taddress: string;\n\t\tcontractName: string;\n\t};\n\n\t/** Format TypeScript code using prettier */\n\tformatCode: (code: string) => Promise<string>;\n\n\t/** Resolve file path relative to project root */\n\tresolvePath: (relativePath: string) => string;\n\n\t/** Check if file exists */\n\tfileExists: (path: string) => Promise<boolean>;\n\n\t/** Read file content */\n\treadFile: (path: string) => Promise<string>;\n\n\t/** Write file content */\n\twriteFile: (path: string, content: string) => Promise<void>;\n\n\t/** Create directory recursively */\n\tensureDir: (path: string) => Promise<void>;\n}\n\n/**\n * Plugin factory function type for creating plugins with options\n */\nexport type PluginFactory<TOptions = any> = (\n\toptions?: TOptions,\n) => SecondLayerPlugin;\n\n/**\n * Plugin options base interface\n */\nexport interface PluginOptions {\n\t/** Include only specific contracts/functions */\n\tinclude?: string[];\n\n\t/** Exclude specific contracts/functions */\n\texclude?: string[];\n\n\t/** Enable debug output */\n\tdebug?: boolean;\n}\n\n/**\n * Hook execution result\n */\nexport interface HookResult<T = any> {\n\t/** Whether the hook was successful */\n\tsuccess: boolean;\n\n\t/** Result data from the hook */\n\tdata?: T;\n\n\t/** Error if hook failed */\n\terror?: Error;\n\n\t/** Plugin that executed the hook */\n\tplugin: string;\n}\n\n/**\n * Plugin execution context for internal use\n */\nexport interface PluginExecutionContext {\n\t/** Current plugin being executed */\n\tcurrentPlugin?: SecondLayerPlugin;\n\n\t/** Execution phase */\n\tphase: \"config\" | \"generate\" | \"output\";\n\n\t/** Start time for performance tracking */\n\tstartTime: number;\n\n\t/** Plugin execution results */\n\tresults: Map<string, HookResult[]>;\n}\n",
|
|
5
|
+
"/**\n * Plugin system types for @secondlayer/cli\n */\n\nimport type { AbiContract } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tNetworkName,\n\tResolvedContract,\n\tSecondLayerConfig,\n} from \"./config\";\n\n/**\n * Core plugin interface that all plugins must implement\n */\nexport interface SecondLayerPlugin {\n\t/** Plugin name (should be unique) */\n\tname: string;\n\n\t/** Plugin version */\n\tversion: string;\n\n\t// Lifecycle hooks\n\t/** Called after config is resolved but before generation starts */\n\tconfigResolved?: (config: ResolvedConfig) => void | Promise<void>;\n\n\t/** Called before generation starts */\n\tbeforeGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called during generation phase - plugins can add their own outputs */\n\tgenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t/** Called after all generation is complete */\n\tafterGenerate?: (context: GenerateContext) => void | Promise<void>;\n\n\t// Transform hooks\n\t/** Transform user config before resolution */\n\ttransformConfig?: (config: UserConfig) => UserConfig | Promise<UserConfig>;\n\n\t/** Transform individual contracts during processing */\n\ttransformContract?: (\n\t\tcontract: ContractConfig,\n\t) => ContractConfig | Promise<ContractConfig>;\n\n\t/** Transform generated output before writing to disk */\n\ttransformOutput?: (\n\t\toutput: string,\n\t\ttype: OutputType,\n\t) => string | Promise<string>;\n}\n\n/**\n * User configuration (before plugin transformations)\n */\nexport type UserConfig = SecondLayerConfig;\n\n/**\n * Resolved configuration (after plugin transformations)\n */\nexport interface ResolvedConfig extends SecondLayerConfig {\n\t/** Resolved plugins array */\n\tplugins: SecondLayerPlugin[];\n}\n\n/**\n * Contract configuration that can be transformed by plugins\n */\nexport interface ContractConfig {\n\tname?: string;\n\taddress?: string | Partial<Record<NetworkName, string>>;\n\tsource?: string;\n\tabi?: AbiContract;\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Contract config from Clarinet plugin\n */\nexport interface ClarinetContractConfig extends ContractConfig {\n\t_clarinetSource: true;\n}\n\n/**\n * Contract config from direct file input\n */\nexport interface DirectFileContractConfig extends ContractConfig {\n\t_directFile: true;\n}\n\n/**\n * Union of all contract config types\n */\nexport type PluginContractConfig =\n\t| ContractConfig\n\t| ClarinetContractConfig\n\t| DirectFileContractConfig;\n\n/**\n * Type guard for Clarinet contracts\n */\nexport function isClarinetContract(\n\tc: ContractConfig,\n): c is ClarinetContractConfig {\n\treturn \"_clarinetSource\" in c && c._clarinetSource === true;\n}\n\n/**\n * Type guard for direct file contracts\n */\nexport function isDirectFileContract(\n\tc: ContractConfig,\n): c is DirectFileContractConfig {\n\treturn \"_directFile\" in c && c._directFile === true;\n}\n\n/**\n * Processed contract with resolved ABI and metadata\n */\nexport interface ProcessedContract extends ResolvedContract {\n\t/** Additional metadata added by plugins */\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tmetadata?: Record<string, any>;\n}\n\n/**\n * Generated output from plugins\n */\nexport interface GeneratedOutput {\n\t/** File path where output should be written */\n\tpath: string;\n\n\t/** Generated content */\n\tcontent: string;\n\n\t/** Output type for transformation hooks */\n\ttype?: OutputType;\n\n\t/** Whether this output should overwrite existing files */\n\toverwrite?: boolean;\n}\n\n/**\n * Types of outputs that can be generated\n */\nexport type OutputType =\n\t| \"contracts\"\n\t| \"hooks\"\n\t| \"actions\"\n\t| \"types\"\n\t| \"utils\"\n\t| \"config\"\n\t| \"other\";\n\n/**\n * Base context available to all plugin hooks\n */\nexport interface PluginContext {\n\t/** Resolved configuration */\n\tconfig: ResolvedConfig;\n\n\t/** Logger for plugin output */\n\tlogger: Logger;\n\n\t/** Utility functions for plugins */\n\tutils: PluginUtils;\n}\n\n/**\n * Context available during generation phase\n */\nexport interface GenerateContext extends PluginContext {\n\t/** Processed contracts ready for generation */\n\tcontracts: ProcessedContract[];\n\n\t/** Map of output keys to generated content */\n\toutputs: Map<string, GeneratedOutput>;\n\n\t/** Function to augment existing outputs */\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\taugment: (outputKey: string, contractName: string, content: any) => void;\n\n\t/** Function to add new outputs */\n\taddOutput: (key: string, output: GeneratedOutput) => void;\n}\n\n/**\n * Logger interface for plugin output\n */\nexport interface Logger {\n\tinfo: (message: string) => void;\n\twarn: (message: string) => void;\n\terror: (message: string) => void;\n\tdebug: (message: string) => void;\n\tsuccess: (message: string) => void;\n}\n\n/**\n * Utility functions available to plugins\n */\nexport interface PluginUtils {\n\t/** Convert kebab-case to camelCase */\n\ttoCamelCase: (str: string) => string;\n\n\t/** Convert camelCase to kebab-case */\n\ttoKebabCase: (str: string) => string;\n\n\t/** Validate Stacks address format */\n\tvalidateAddress: (address: string) => boolean;\n\n\t/** Parse contract identifier (address.contract-name) */\n\tparseContractId: (contractId: string) => {\n\t\taddress: string;\n\t\tcontractName: string;\n\t};\n\n\t/** Format TypeScript code using prettier */\n\tformatCode: (code: string) => Promise<string>;\n\n\t/** Resolve file path relative to project root */\n\tresolvePath: (relativePath: string) => string;\n\n\t/** Check if file exists */\n\tfileExists: (path: string) => Promise<boolean>;\n\n\t/** Read file content */\n\treadFile: (path: string) => Promise<string>;\n\n\t/** Write file content */\n\twriteFile: (path: string, content: string) => Promise<void>;\n\n\t/** Create directory recursively */\n\tensureDir: (path: string) => Promise<void>;\n}\n\n/**\n * Plugin factory function type for creating plugins with options\n */\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport type PluginFactory<TOptions = any> = (\n\toptions?: TOptions,\n) => SecondLayerPlugin;\n\n/**\n * Plugin options base interface\n */\nexport interface PluginOptions {\n\t/** Include only specific contracts/functions */\n\tinclude?: string[];\n\n\t/** Exclude specific contracts/functions */\n\texclude?: string[];\n\n\t/** Enable debug output */\n\tdebug?: boolean;\n}\n\n/**\n * Hook execution result\n */\n// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\nexport interface HookResult<T = any> {\n\t/** Whether the hook was successful */\n\tsuccess: boolean;\n\n\t/** Result data from the hook */\n\tdata?: T;\n\n\t/** Error if hook failed */\n\terror?: Error;\n\n\t/** Plugin that executed the hook */\n\tplugin: string;\n}\n\n/**\n * Plugin execution context for internal use\n */\nexport interface PluginExecutionContext {\n\t/** Current plugin being executed */\n\tcurrentPlugin?: SecondLayerPlugin;\n\n\t/** Execution phase */\n\tphase: \"config\" | \"generate\" | \"output\";\n\n\t/** Start time for performance tracking */\n\tstartTime: number;\n\n\t/** Plugin execution results */\n\tresults: Map<string, HookResult[]>;\n}\n",
|
|
6
6
|
"/**\n * Parse a fully-qualified contract ID (\"address.contractName\") into its parts.\n * Throws if the input doesn't contain a dot separator.\n */\nexport function parseContractId(contractId: string): {\n\taddress: string;\n\tcontractName: string;\n} {\n\tconst dotIndex = contractId.indexOf(\".\");\n\tif (dotIndex === -1) {\n\t\tthrow new Error(\n\t\t\t`Invalid contract ID: \"${contractId}\" (expected \"address.contractName\")`,\n\t\t);\n\t}\n\treturn {\n\t\taddress: contractId.slice(0, dotIndex),\n\t\tcontractName: contractId.slice(dotIndex + 1),\n\t};\n}\n",
|
|
7
7
|
"/**\n * Shared code formatting utilities using Biome\n */\n\nimport { Biome, Distribution } from \"@biomejs/js-api\";\n\nlet biome: Biome | null = null;\n\n/**\n * Lazily initialize Biome singleton\n */\nasync function getBiome(): Promise<Biome> {\n\tif (!biome) {\n\t\tbiome = await Biome.create({\n\t\t\tdistribution: Distribution.NODE,\n\t\t});\n\n\t\tbiome.applyConfiguration({\n\t\t\tformatter: {\n\t\t\t\tenabled: true,\n\t\t\t\tindentStyle: \"tab\",\n\t\t\t\tlineWidth: 80,\n\t\t\t},\n\t\t\tjavascript: {\n\t\t\t\tformatter: {\n\t\t\t\t\tsemicolons: \"always\",\n\t\t\t\t\tquoteStyle: \"single\",\n\t\t\t\t},\n\t\t\t},\n\t\t\torganizeImports: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t\tlinter: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t\tassists: {\n\t\t\t\tenabled: true,\n\t\t\t},\n\t\t});\n\n\t\tbiome.registerProjectFolder();\n\t}\n\n\treturn biome;\n}\n\n/**\n * Format TypeScript code using Biome\n */\nexport async function formatCode(code: string): Promise<string> {\n\tconst b = await getBiome();\n\n\t// Use lintContent with SafeFixes to organize imports\n\tconst linted = b.lintContent(code, {\n\t\tfilePath: \"generated.ts\",\n\t\tfixFileMode: \"SafeFixes\",\n\t});\n\n\t// Then format\n\tconst formatted = b.formatContent(linted.content, {\n\t\tfilePath: \"generated.ts\",\n\t});\n\n\treturn formatted.content;\n}\n",
|
|
8
|
-
"/**\n * Plugin Manager for @secondlayer/cli\n * Handles plugin registration, lifecycle execution, and output management\n */\n\nimport { promises as fs } from \"fs\";\nimport path from \"path\";\nimport { isValidAddress as _validateStacksAddress } from \"@secondlayer/stacks\";\nconst validateStacksAddress = _validateStacksAddress as (\n\taddress: string,\n) => boolean;\nimport { getErrorMessage } from \"@secondlayer/shared\";\nimport { toCamelCase } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tContractConfig,\n\tGenerateContext,\n\tGeneratedOutput,\n\tHookResult,\n\tLogger,\n\tPluginExecutionContext,\n\tPluginUtils,\n\tProcessedContract,\n\tResolvedConfig,\n\tSecondLayerPlugin,\n\tUserConfig,\n} from \"../types/plugin\";\nimport { isClarinetContract, isDirectFileContract } from \"../types/plugin\";\nimport { parseContractId } from \"../utils/contract-id\";\n\n/**\n * Core plugin manager that orchestrates plugin execution\n */\nexport class PluginManager {\n\tprivate plugins: SecondLayerPlugin[] = [];\n\tprivate logger: Logger;\n\tprivate utils: PluginUtils;\n\tprivate executionContext: PluginExecutionContext;\n\n\tconstructor() {\n\t\tthis.logger = this.createLogger();\n\t\tthis.utils = this.createUtils();\n\t\tthis.executionContext = {\n\t\t\tphase: \"config\",\n\t\t\tstartTime: Date.now(),\n\t\t\tresults: new Map(),\n\t\t};\n\t}\n\n\t/**\n\t * Register a plugin\n\t */\n\tregister(plugin: SecondLayerPlugin): void {\n\t\t// Validate plugin\n\t\tif (!plugin.name || !plugin.version) {\n\t\t\tthrow new Error(\"Plugin must have a name and version\");\n\t\t}\n\n\t\t// Check for duplicate plugin names\n\t\tconst existing = this.plugins.find((p) => p.name === plugin.name);\n\t\tif (existing) {\n\t\t\tthrow new Error(\n\t\t\t\t`Plugin \"${plugin.name}\" is already registered (version ${existing.version})`,\n\t\t\t);\n\t\t}\n\n\t\tthis.plugins.push(plugin);\n\t\tthis.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetPlugins(): SecondLayerPlugin[] {\n\t\treturn [...this.plugins];\n\t}\n\n\t/**\n\t * Transform user config through all plugins\n\t */\n\tasync transformConfig(config: UserConfig): Promise<ResolvedConfig> {\n\t\tthis.executionContext.phase = \"config\";\n\t\tlet transformedConfig = { ...config };\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tif (plugin.transformConfig) {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await plugin.transformConfig(transformedConfig);\n\t\t\t\t\ttransformedConfig = result;\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during config transformation: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add plugins array to resolved config\n\t\tconst resolvedConfig: ResolvedConfig = {\n\t\t\t...transformedConfig,\n\t\t\tplugins: this.plugins,\n\t\t};\n\n\t\treturn resolvedConfig;\n\t}\n\n\t/**\n\t * Transform contracts through all plugins\n\t */\n\tasync transformContracts(\n\t\tcontracts: ContractConfig[],\n\t\t_config: ResolvedConfig,\n\t): Promise<ProcessedContract[]> {\n\t\tconst processedContracts: ProcessedContract[] = [];\n\n\t\tfor (let contract of contracts) {\n\t\t\tif (isClarinetContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"clarinet\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectFileContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"direct\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Transform through each plugin\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformContract) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontract = await plugin.transformContract(contract);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform contract: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"api\"));\n\t\t\t}\n\t\t}\n\n\t\treturn processedContracts;\n\t}\n\n\t/**\n\t * Execute lifecycle hooks\n\t */\n\tasync executeHook(\n\t\thookName: keyof SecondLayerPlugin,\n\t\tcontext: any,\n\t): Promise<void> {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst hook = plugin[hookName];\n\t\t\tif (typeof hook === \"function\") {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\tawait (hook as any).call(plugin, context);\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during ${hookName as string}: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t\t// Don't throw - allow other plugins to continue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Execute generation phase with full context\n\t */\n\tasync executeGeneration(\n\t\tcontracts: ProcessedContract[],\n\t\tconfig: ResolvedConfig,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"generate\";\n\t\tconst outputs = new Map<string, GeneratedOutput>();\n\n\t\t// Create generation context\n\t\tconst context: GenerateContext = {\n\t\t\tconfig,\n\t\t\tlogger: this.logger,\n\t\t\tutils: this.utils,\n\t\t\tcontracts,\n\t\t\toutputs,\n\t\t\taugment: (outputKey: string, contractName: string, content: any) => {\n\t\t\t\tthis.augmentOutput(outputs, outputKey, contractName, content);\n\t\t\t},\n\t\t\taddOutput: (key: string, output: GeneratedOutput) => {\n\t\t\t\toutputs.set(key, output);\n\t\t\t},\n\t\t};\n\n\t\t// Execute beforeGenerate hooks\n\t\tawait this.executeHook(\"beforeGenerate\", context);\n\n\t\t// Execute generate hooks\n\t\tawait this.executeHook(\"generate\", context);\n\n\t\t// Execute afterGenerate hooks\n\t\tawait this.executeHook(\"afterGenerate\", context);\n\n\t\treturn outputs;\n\t}\n\n\t/**\n\t * Transform outputs through plugins\n\t */\n\tasync transformOutputs(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"output\";\n\t\tconst transformedOutputs = new Map<string, GeneratedOutput>();\n\n\t\tfor (const [key, output] of outputs) {\n\t\t\tlet transformedContent = output.content;\n\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformOutput) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttransformedContent = await plugin.transformOutput(\n\t\t\t\t\t\t\ttransformedContent,\n\t\t\t\t\t\t\toutput.type || \"other\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform output: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttransformedOutputs.set(key, {\n\t\t\t\t...output,\n\t\t\t\tcontent: transformedContent,\n\t\t\t});\n\t\t}\n\n\t\treturn transformedOutputs;\n\t}\n\n\t/**\n\t * Write outputs to disk\n\t */\n\tasync writeOutputs(outputs: Map<string, GeneratedOutput>): Promise<void> {\n\t\tfor (const [, output] of outputs) {\n\t\t\ttry {\n\t\t\t\tconst resolvedPath = path.resolve(process.cwd(), output.path);\n\t\t\t\tawait this.utils.ensureDir(path.dirname(resolvedPath));\n\t\t\t\tawait this.utils.writeFile(resolvedPath, output.content);\n\t\t\t\t// Don't log here - let the main command handle success messaging\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t`Failed to write ${output.path}: ${getErrorMessage(error)}`,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get execution results for debugging\n\t */\n\tgetExecutionResults(): Map<string, HookResult[]> {\n\t\treturn new Map(this.executionContext.results);\n\t}\n\n\t/**\n\t * Convert a contract config with an ABI into a ProcessedContract\n\t */\n\tprivate contractToProcessed(\n\t\tcontract: ContractConfig,\n\t\tsource: string,\n\t): ProcessedContract {\n\t\tconst address =\n\t\t\ttypeof contract.address === \"string\" ? contract.address : \"\";\n\t\tconst parsed = parseContractId(address);\n\t\treturn {\n\t\t\tname: contract.name || parsed.contractName || \"unknown\",\n\t\t\taddress: parsed.address || \"unknown\",\n\t\t\tcontractName: parsed.contractName || contract.name || \"unknown\",\n\t\t\tabi: contract.abi!,\n\t\t\tsource: source === \"api\" ? (\"api\" as const) : (\"local\" as const),\n\t\t\tmetadata: contract.metadata ?? { source },\n\t\t};\n\t}\n\n\t/**\n\t * Augment existing output with additional content\n\t */\n\tprivate augmentOutput(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t\toutputKey: string,\n\t\tcontractName: string,\n\t\tcontent: any,\n\t): void {\n\t\tconst existing = outputs.get(outputKey);\n\t\tif (!existing) {\n\t\t\tthis.logger.warn(`Cannot augment non-existent output: ${outputKey}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Simple augmentation - append content\n\t\t// In a real implementation, this would be more sophisticated\n\t\tconst augmentedContent = `${existing.content}\\n\\n// Augmented by plugin for ${contractName}\\n${JSON.stringify(content, null, 2)}`;\n\n\t\toutputs.set(outputKey, {\n\t\t\t...existing,\n\t\t\tcontent: augmentedContent,\n\t\t});\n\t}\n\n\t/**\n\t * Record hook execution result\n\t */\n\tprivate recordHookResult(\n\t\tpluginName: string,\n\t\thookName: string,\n\t\tresult: Omit<HookResult, \"plugin\">,\n\t): void {\n\t\tconst key = `${pluginName}:${hookName}`;\n\t\tconst existing = this.executionContext.results.get(key) || [];\n\t\texisting.push({ ...result, plugin: pluginName });\n\t\tthis.executionContext.results.set(key, existing);\n\t}\n\n\t/**\n\t * Create logger instance\n\t */\n\tprivate createLogger(): Logger {\n\t\treturn {\n\t\t\tinfo: (message: string) => console.log(`ℹ️ ${message}`),\n\t\t\twarn: (message: string) => console.warn(`⚠️ ${message}`),\n\t\t\terror: (message: string) => console.error(`❌ ${message}`),\n\t\t\tdebug: (message: string) => {\n\t\t\t\tif (process.env.DEBUG) {\n\t\t\t\t\tconsole.log(`🐛 ${message}`);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsuccess: (message: string) => console.log(`✅ ${message}`),\n\t\t};\n\t}\n\n\t/**\n\t * Create utils instance\n\t */\n\tprivate createUtils(): PluginUtils {\n\t\treturn {\n\t\t\ttoCamelCase,\n\n\t\t\ttoKebabCase: (str: string) => {\n\t\t\t\treturn str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\t\t\t},\n\n\t\t\tvalidateAddress: (address: string) => {\n\t\t\t\treturn validateStacksAddress(parseContractId(address).address);\n\t\t\t},\n\n\t\t\tparseContractId: (contractId: string) => {\n\t\t\t\treturn parseContractId(contractId);\n\t\t\t},\n\n\t\t\tformatCode: async (code: string) => {\n\t\t\t\tconst { formatCode } = await import(\"../utils/format\");\n\t\t\t\treturn formatCode(code);\n\t\t\t},\n\n\t\t\tresolvePath: (relativePath: string) => {\n\t\t\t\treturn path.resolve(process.cwd(), relativePath);\n\t\t\t},\n\n\t\t\tfileExists: async (filePath: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.access(filePath);\n\t\t\t\t\treturn true;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treadFile: async (filePath: string) => {\n\t\t\t\treturn fs.readFile(filePath, \"utf-8\");\n\t\t\t},\n\n\t\t\twriteFile: async (filePath: string, content: string) => {\n\t\t\t\tawait fs.writeFile(filePath, content, \"utf-8\");\n\t\t\t},\n\n\t\t\tensureDir: async (dirPath: string) => {\n\t\t\t\tawait fs.mkdir(dirPath, { recursive: true });\n\t\t\t},\n\t\t};\n\t}\n}\n",
|
|
9
|
-
"import { randomBytes } from \"crypto\";\nimport { promises as fs } from \"fs\";\nimport { createRequire } from \"module\";\nimport { tmpdir } from \"os\";\nimport path from \"path\";\nimport { pathToFileURL } from \"url\";\nimport { PluginManager } from \"../core/plugin-manager\";\nimport type { ConfigDefiner, SecondLayerConfig } from \"../types/config\";\nimport type { ResolvedConfig } from \"../types/plugin\";\n\n/**\n * Config file utilities\n */\n\nconst CONFIG_FILE_NAMES = [\n\t\"secondlayer.config.ts\",\n\t\"secondlayer.config\",\n\t\"secondlayer.config.mjs\",\n];\n\nexport async function findConfigFile(cwd: string): Promise<string | null> {\n\tfor (const fileName of CONFIG_FILE_NAMES) {\n\t\tconst filePath = path.join(cwd, fileName);\n\t\ttry {\n\t\t\tawait fs.access(filePath);\n\t\t\treturn filePath;\n\t\t} catch {\n\t\t\t// File doesn't exist, continue\n\t\t}\n\t}\n\treturn null;\n}\n\nexport async function loadConfig(configPath?: string): Promise<ResolvedConfig> {\n\tconst cwd = process.cwd();\n\n\tconst resolvedPath = configPath\n\t\t? path.resolve(cwd, configPath)\n\t\t: await findConfigFile(cwd);\n\n\tif (!resolvedPath) {\n\t\tthrow new Error(\n\t\t\t\"No config file found. Create a secondlayer.config.ts file or specify a path with --config\",\n\t\t);\n\t}\n\n\tlet config: any;\n\n\tif (resolvedPath.endsWith(\".ts\")) {\n\t\tconst code = await fs.readFile(resolvedPath, \"utf-8\");\n\n\t\t// Transform TypeScript to JavaScript, replacing the @secondlayer/cli import\n\t\t// For development/linked packages, we need to resolve to the actual package location\n\t\t// This will work both for published packages and local development\n\t\tlet replacementPath: string;\n\n\t\ttry {\n\t\t\t// Try to resolve @secondlayer/cli as if it were a normal package\n\t\t\tconst require = createRequire(import.meta.url);\n\t\t\tconst packagePath = require.resolve(\"@secondlayer/cli\");\n\t\t\treplacementPath = pathToFileURL(packagePath).href;\n\t\t} catch {\n\t\t\t// Fallback: resolve relative to current module (for development)\n\t\t\tconst currentModuleDir = path.dirname(new URL(import.meta.url).pathname);\n\t\t\tconst indexPath = path.resolve(currentModuleDir, \"../index\");\n\t\t\treplacementPath = pathToFileURL(indexPath).href;\n\t\t}\n\n\t\tconst transformedCode = code.replace(\n\t\t\t/from\\s+[\"']@secondlayer\\/cli[\"']/g,\n\t\t\t`from '${replacementPath}'`,\n\t\t);\n\n\t\tconst { transformSync } = await import(\"esbuild\");\n\t\tconst result = transformSync(transformedCode, {\n\t\t\tformat: \"esm\",\n\t\t\ttarget: \"node18\",\n\t\t\tloader: \"ts\",\n\t\t});\n\n\t\tconst tempPath = path.join(\n\t\t\ttmpdir(),\n\t\t\t`secondlayer-config-${randomBytes(4).toString(\"hex\")}.mjs`,\n\t\t);\n\t\tawait fs.writeFile(tempPath, result.code);\n\n\t\ttry {\n\t\t\tconst fileUrl = pathToFileURL(tempPath).href;\n\t\t\tconst module = await import(fileUrl);\n\t\t\tconfig = module.default;\n\t\t} finally {\n\t\t\tawait fs.unlink(tempPath).catch(() => {});\n\t\t}\n\t} else {\n\t\tconst fileUrl = pathToFileURL(resolvedPath).href;\n\t\tconst module = await import(fileUrl);\n\t\tconfig = module.default;\n\t}\n\n\tif (!config) {\n\t\tthrow new Error(\"Config file must export a default configuration\");\n\t}\n\n\tif (typeof config === \"function\") {\n\t\tconfig = config({} as SecondLayerConfig);\n\t}\n\n\tvalidateConfig(config);\n\n\t// Process plugins if they exist\n\tconst pluginManager = new PluginManager();\n\n\tif (config.plugins && Array.isArray(config.plugins)) {\n\t\tfor (const plugin of config.plugins) {\n\t\t\tpluginManager.register(plugin);\n\t\t}\n\t}\n\n\t// Transform config through plugins\n\tconst resolvedConfig = await pluginManager.transformConfig(config);\n\n\treturn resolvedConfig;\n}\n\nexport function validateConfig(\n\tconfig: unknown,\n): asserts config is SecondLayerConfig {\n\tif (!config || typeof config !== \"object\") {\n\t\tthrow new Error(\"Config must be an object\");\n\t}\n\n\tconst c = config as any;\n\n\t// Contracts are optional now since plugins can provide them\n\tif (c.contracts && !Array.isArray(c.contracts)) {\n\t\tthrow new Error(\"Config contracts must be an array\");\n\t}\n\n\tif (!c.out || typeof c.out !== \"string\") {\n\t\tthrow new Error(\"Config out must be a string path\");\n\t}\n\n\t// Validate contracts if they exist\n\tif (c.contracts) {\n\t\tfor (const contract of c.contracts) {\n\t\t\tif (!contract.address && !contract.source) {\n\t\t\t\tthrow new Error(\"Each contract must have either an address or source\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate plugins if they exist\n\tif (c.plugins && !Array.isArray(c.plugins)) {\n\t\tthrow new Error(\"Config plugins must be an array\");\n\t}\n}\n\n/**\n * Type-safe helper for creating a `secondlayer.config.ts` configuration.\n * Accepts either a config object or a factory function that receives a base config and returns a modified one.\n *\n * @example\n * ```ts\n * import { defineConfig } from \"@secondlayer/cli\";\n *\n * export default defineConfig({\n * contracts: [{ address: \"SP000000000000000000002Q6VF78.bns\" }],\n * out: \"./src/generated.ts\",\n * });\n * ```\n */\nexport function defineConfig(config: SecondLayerConfig): SecondLayerConfig;\nexport function defineConfig(definer: ConfigDefiner): ConfigDefiner;\nexport function defineConfig(\n\tconfigOrDefiner: SecondLayerConfig | ConfigDefiner,\n) {\n\treturn configOrDefiner;\n}\n",
|
|
8
|
+
"/**\n * Plugin Manager for @secondlayer/cli\n * Handles plugin registration, lifecycle execution, and output management\n */\n\nimport { promises as fs } from \"node:fs\";\nimport path from \"node:path\";\nimport { isValidAddress as _validateStacksAddress } from \"@secondlayer/stacks\";\nconst validateStacksAddress = _validateStacksAddress as (\n\taddress: string,\n) => boolean;\nimport { getErrorMessage } from \"@secondlayer/shared\";\nimport { toCamelCase } from \"@secondlayer/stacks/clarity\";\nimport type {\n\tContractConfig,\n\tGenerateContext,\n\tGeneratedOutput,\n\tHookResult,\n\tLogger,\n\tPluginExecutionContext,\n\tPluginUtils,\n\tProcessedContract,\n\tResolvedConfig,\n\tSecondLayerPlugin,\n\tUserConfig,\n} from \"../types/plugin\";\nimport { isClarinetContract, isDirectFileContract } from \"../types/plugin\";\nimport { parseContractId } from \"../utils/contract-id\";\n\n/**\n * Core plugin manager that orchestrates plugin execution\n */\nexport class PluginManager {\n\tprivate plugins: SecondLayerPlugin[] = [];\n\tprivate logger: Logger;\n\tprivate utils: PluginUtils;\n\tprivate executionContext: PluginExecutionContext;\n\n\tconstructor() {\n\t\tthis.logger = this.createLogger();\n\t\tthis.utils = this.createUtils();\n\t\tthis.executionContext = {\n\t\t\tphase: \"config\",\n\t\t\tstartTime: Date.now(),\n\t\t\tresults: new Map(),\n\t\t};\n\t}\n\n\t/**\n\t * Register a plugin\n\t */\n\tregister(plugin: SecondLayerPlugin): void {\n\t\t// Validate plugin\n\t\tif (!plugin.name || !plugin.version) {\n\t\t\tthrow new Error(\"Plugin must have a name and version\");\n\t\t}\n\n\t\t// Check for duplicate plugin names\n\t\tconst existing = this.plugins.find((p) => p.name === plugin.name);\n\t\tif (existing) {\n\t\t\tthrow new Error(\n\t\t\t\t`Plugin \"${plugin.name}\" is already registered (version ${existing.version})`,\n\t\t\t);\n\t\t}\n\n\t\tthis.plugins.push(plugin);\n\t\tthis.logger.debug(`Registered plugin: ${plugin.name}@${plugin.version}`);\n\t}\n\n\t/**\n\t * Get all registered plugins\n\t */\n\tgetPlugins(): SecondLayerPlugin[] {\n\t\treturn [...this.plugins];\n\t}\n\n\t/**\n\t * Transform user config through all plugins\n\t */\n\tasync transformConfig(config: UserConfig): Promise<ResolvedConfig> {\n\t\tthis.executionContext.phase = \"config\";\n\t\tlet transformedConfig = { ...config };\n\n\t\tfor (const plugin of this.plugins) {\n\t\t\tif (plugin.transformConfig) {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\tconst result = await plugin.transformConfig(transformedConfig);\n\t\t\t\t\ttransformedConfig = result;\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformConfig\", {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during config transformation: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Add plugins array to resolved config\n\t\tconst resolvedConfig: ResolvedConfig = {\n\t\t\t...transformedConfig,\n\t\t\tplugins: this.plugins,\n\t\t};\n\n\t\treturn resolvedConfig;\n\t}\n\n\t/**\n\t * Transform contracts through all plugins\n\t */\n\tasync transformContracts(\n\t\tcontracts: ContractConfig[],\n\t\t_config: ResolvedConfig,\n\t): Promise<ProcessedContract[]> {\n\t\tconst processedContracts: ProcessedContract[] = [];\n\n\t\tfor (let contract of contracts) {\n\t\t\tif (isClarinetContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"clarinet\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tif (isDirectFileContract(contract) && contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"direct\"));\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\t// Transform through each plugin\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformContract) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontract = await plugin.transformContract(contract);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformContract\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform contract: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (contract.abi) {\n\t\t\t\tprocessedContracts.push(this.contractToProcessed(contract, \"api\"));\n\t\t\t}\n\t\t}\n\n\t\treturn processedContracts;\n\t}\n\n\t/**\n\t * Execute lifecycle hooks\n\t */\n\tasync executeHook(\n\t\thookName: keyof SecondLayerPlugin,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcontext: any,\n\t): Promise<void> {\n\t\tfor (const plugin of this.plugins) {\n\t\t\tconst hook = plugin[hookName];\n\t\t\tif (typeof hook === \"function\") {\n\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\ttry {\n\t\t\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\t\t\tawait (hook as any).call(plugin, context);\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.recordHookResult(plugin.name, hookName as string, {\n\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\terror:\n\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t});\n\t\t\t\t\tthis.logger.error(\n\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed during ${hookName as string}: ${getErrorMessage(error)}`,\n\t\t\t\t\t);\n\t\t\t\t\t// Don't throw - allow other plugins to continue\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Execute generation phase with full context\n\t */\n\tasync executeGeneration(\n\t\tcontracts: ProcessedContract[],\n\t\tconfig: ResolvedConfig,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"generate\";\n\t\tconst outputs = new Map<string, GeneratedOutput>();\n\n\t\t// Create generation context\n\t\tconst context: GenerateContext = {\n\t\t\tconfig,\n\t\t\tlogger: this.logger,\n\t\t\tutils: this.utils,\n\t\t\tcontracts,\n\t\t\toutputs,\n\t\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\t\taugment: (outputKey: string, contractName: string, content: any) => {\n\t\t\t\tthis.augmentOutput(outputs, outputKey, contractName, content);\n\t\t\t},\n\t\t\taddOutput: (key: string, output: GeneratedOutput) => {\n\t\t\t\toutputs.set(key, output);\n\t\t\t},\n\t\t};\n\n\t\t// Execute beforeGenerate hooks\n\t\tawait this.executeHook(\"beforeGenerate\", context);\n\n\t\t// Execute generate hooks\n\t\tawait this.executeHook(\"generate\", context);\n\n\t\t// Execute afterGenerate hooks\n\t\tawait this.executeHook(\"afterGenerate\", context);\n\n\t\treturn outputs;\n\t}\n\n\t/**\n\t * Transform outputs through plugins\n\t */\n\tasync transformOutputs(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t): Promise<Map<string, GeneratedOutput>> {\n\t\tthis.executionContext.phase = \"output\";\n\t\tconst transformedOutputs = new Map<string, GeneratedOutput>();\n\n\t\tfor (const [key, output] of outputs) {\n\t\t\tlet transformedContent = output.content;\n\n\t\t\tfor (const plugin of this.plugins) {\n\t\t\t\tif (plugin.transformOutput) {\n\t\t\t\t\tthis.executionContext.currentPlugin = plugin;\n\t\t\t\t\ttry {\n\t\t\t\t\t\ttransformedContent = await plugin.transformOutput(\n\t\t\t\t\t\t\ttransformedContent,\n\t\t\t\t\t\t\toutput.type || \"other\",\n\t\t\t\t\t\t);\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: true,\n\t\t\t\t\t\t});\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tthis.recordHookResult(plugin.name, \"transformOutput\", {\n\t\t\t\t\t\t\tsuccess: false,\n\t\t\t\t\t\t\terror:\n\t\t\t\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t\t\t\t? error\n\t\t\t\t\t\t\t\t\t: new Error(getErrorMessage(error)),\n\t\t\t\t\t\t});\n\t\t\t\t\t\tthis.logger.warn(\n\t\t\t\t\t\t\t`Plugin \"${plugin.name}\" failed to transform output: ${getErrorMessage(error)}`,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ttransformedOutputs.set(key, {\n\t\t\t\t...output,\n\t\t\t\tcontent: transformedContent,\n\t\t\t});\n\t\t}\n\n\t\treturn transformedOutputs;\n\t}\n\n\t/**\n\t * Write outputs to disk\n\t */\n\tasync writeOutputs(outputs: Map<string, GeneratedOutput>): Promise<void> {\n\t\tfor (const [, output] of outputs) {\n\t\t\ttry {\n\t\t\t\tconst resolvedPath = path.resolve(process.cwd(), output.path);\n\t\t\t\tawait this.utils.ensureDir(path.dirname(resolvedPath));\n\t\t\t\tawait this.utils.writeFile(resolvedPath, output.content);\n\t\t\t\t// Don't log here - let the main command handle success messaging\n\t\t\t} catch (error) {\n\t\t\t\tthis.logger.error(\n\t\t\t\t\t`Failed to write ${output.path}: ${getErrorMessage(error)}`,\n\t\t\t\t);\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Get execution results for debugging\n\t */\n\tgetExecutionResults(): Map<string, HookResult[]> {\n\t\treturn new Map(this.executionContext.results);\n\t}\n\n\t/**\n\t * Convert a contract config with an ABI into a ProcessedContract\n\t */\n\tprivate contractToProcessed(\n\t\tcontract: ContractConfig,\n\t\tsource: string,\n\t): ProcessedContract {\n\t\tconst address =\n\t\t\ttypeof contract.address === \"string\" ? contract.address : \"\";\n\t\tconst parsed = parseContractId(address);\n\t\treturn {\n\t\t\tname: contract.name || parsed.contractName || \"unknown\",\n\t\t\taddress: parsed.address || \"unknown\",\n\t\t\tcontractName: parsed.contractName || contract.name || \"unknown\",\n\t\t\t// biome-ignore lint/style/noNonNullAssertion: value is non-null after preceding check or by construction; TS narrowing limitation\n\t\t\tabi: contract.abi!,\n\t\t\tsource: source === \"api\" ? (\"api\" as const) : (\"local\" as const),\n\t\t\tmetadata: contract.metadata ?? { source },\n\t\t};\n\t}\n\n\t/**\n\t * Augment existing output with additional content\n\t */\n\tprivate augmentOutput(\n\t\toutputs: Map<string, GeneratedOutput>,\n\t\toutputKey: string,\n\t\tcontractName: string,\n\t\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\t\tcontent: any,\n\t): void {\n\t\tconst existing = outputs.get(outputKey);\n\t\tif (!existing) {\n\t\t\tthis.logger.warn(`Cannot augment non-existent output: ${outputKey}`);\n\t\t\treturn;\n\t\t}\n\n\t\t// Simple augmentation - append content\n\t\t// In a real implementation, this would be more sophisticated\n\t\tconst augmentedContent = `${existing.content}\\n\\n// Augmented by plugin for ${contractName}\\n${JSON.stringify(content, null, 2)}`;\n\n\t\toutputs.set(outputKey, {\n\t\t\t...existing,\n\t\t\tcontent: augmentedContent,\n\t\t});\n\t}\n\n\t/**\n\t * Record hook execution result\n\t */\n\tprivate recordHookResult(\n\t\tpluginName: string,\n\t\thookName: string,\n\t\tresult: Omit<HookResult, \"plugin\">,\n\t): void {\n\t\tconst key = `${pluginName}:${hookName}`;\n\t\tconst existing = this.executionContext.results.get(key) || [];\n\t\texisting.push({ ...result, plugin: pluginName });\n\t\tthis.executionContext.results.set(key, existing);\n\t}\n\n\t/**\n\t * Create logger instance\n\t */\n\tprivate createLogger(): Logger {\n\t\treturn {\n\t\t\tinfo: (message: string) => console.log(`ℹ️ ${message}`),\n\t\t\twarn: (message: string) => console.warn(`⚠️ ${message}`),\n\t\t\terror: (message: string) => console.error(`❌ ${message}`),\n\t\t\tdebug: (message: string) => {\n\t\t\t\tif (process.env.DEBUG) {\n\t\t\t\t\tconsole.log(`🐛 ${message}`);\n\t\t\t\t}\n\t\t\t},\n\t\t\tsuccess: (message: string) => console.log(`✅ ${message}`),\n\t\t};\n\t}\n\n\t/**\n\t * Create utils instance\n\t */\n\tprivate createUtils(): PluginUtils {\n\t\treturn {\n\t\t\ttoCamelCase,\n\n\t\t\ttoKebabCase: (str: string) => {\n\t\t\t\treturn str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);\n\t\t\t},\n\n\t\t\tvalidateAddress: (address: string) => {\n\t\t\t\treturn validateStacksAddress(parseContractId(address).address);\n\t\t\t},\n\n\t\t\tparseContractId: (contractId: string) => {\n\t\t\t\treturn parseContractId(contractId);\n\t\t\t},\n\n\t\t\tformatCode: async (code: string) => {\n\t\t\t\tconst { formatCode } = await import(\"../utils/format\");\n\t\t\t\treturn formatCode(code);\n\t\t\t},\n\n\t\t\tresolvePath: (relativePath: string) => {\n\t\t\t\treturn path.resolve(process.cwd(), relativePath);\n\t\t\t},\n\n\t\t\tfileExists: async (filePath: string) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait fs.access(filePath);\n\t\t\t\t\treturn true;\n\t\t\t\t} catch {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\n\t\t\treadFile: async (filePath: string) => {\n\t\t\t\treturn fs.readFile(filePath, \"utf-8\");\n\t\t\t},\n\n\t\t\twriteFile: async (filePath: string, content: string) => {\n\t\t\t\tawait fs.writeFile(filePath, content, \"utf-8\");\n\t\t\t},\n\n\t\t\tensureDir: async (dirPath: string) => {\n\t\t\t\tawait fs.mkdir(dirPath, { recursive: true });\n\t\t\t},\n\t\t};\n\t}\n}\n",
|
|
9
|
+
"import { randomBytes } from \"node:crypto\";\nimport { promises as fs } from \"node:fs\";\nimport { createRequire } from \"node:module\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { PluginManager } from \"../core/plugin-manager\";\nimport type { ConfigDefiner, SecondLayerConfig } from \"../types/config\";\nimport type { ResolvedConfig } from \"../types/plugin\";\n\n/**\n * Config file utilities\n */\n\nconst CONFIG_FILE_NAMES = [\n\t\"secondlayer.config.ts\",\n\t\"secondlayer.config\",\n\t\"secondlayer.config.mjs\",\n];\n\nexport async function findConfigFile(cwd: string): Promise<string | null> {\n\tfor (const fileName of CONFIG_FILE_NAMES) {\n\t\tconst filePath = path.join(cwd, fileName);\n\t\ttry {\n\t\t\tawait fs.access(filePath);\n\t\t\treturn filePath;\n\t\t} catch {\n\t\t\t// File doesn't exist, continue\n\t\t}\n\t}\n\treturn null;\n}\n\nexport async function loadConfig(configPath?: string): Promise<ResolvedConfig> {\n\tconst cwd = process.cwd();\n\n\tconst resolvedPath = configPath\n\t\t? path.resolve(cwd, configPath)\n\t\t: await findConfigFile(cwd);\n\n\tif (!resolvedPath) {\n\t\tthrow new Error(\n\t\t\t\"No config file found. Create a secondlayer.config.ts file or specify a path with --config\",\n\t\t);\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tlet config: any;\n\n\tif (resolvedPath.endsWith(\".ts\")) {\n\t\tconst code = await fs.readFile(resolvedPath, \"utf-8\");\n\n\t\t// Transform TypeScript to JavaScript, replacing the @secondlayer/cli import\n\t\t// For development/linked packages, we need to resolve to the actual package location\n\t\t// This will work both for published packages and local development\n\t\tlet replacementPath: string;\n\n\t\ttry {\n\t\t\t// Try to resolve @secondlayer/cli as if it were a normal package\n\t\t\tconst require = createRequire(import.meta.url);\n\t\t\tconst packagePath = require.resolve(\"@secondlayer/cli\");\n\t\t\treplacementPath = pathToFileURL(packagePath).href;\n\t\t} catch {\n\t\t\t// Fallback: resolve relative to current module (for development)\n\t\t\tconst currentModuleDir = path.dirname(new URL(import.meta.url).pathname);\n\t\t\tconst indexPath = path.resolve(currentModuleDir, \"../index\");\n\t\t\treplacementPath = pathToFileURL(indexPath).href;\n\t\t}\n\n\t\tconst transformedCode = code.replace(\n\t\t\t/from\\s+[\"']@secondlayer\\/cli[\"']/g,\n\t\t\t`from '${replacementPath}'`,\n\t\t);\n\n\t\tconst { transformSync } = await import(\"esbuild\");\n\t\tconst result = transformSync(transformedCode, {\n\t\t\tformat: \"esm\",\n\t\t\ttarget: \"node18\",\n\t\t\tloader: \"ts\",\n\t\t});\n\n\t\tconst tempPath = path.join(\n\t\t\ttmpdir(),\n\t\t\t`secondlayer-config-${randomBytes(4).toString(\"hex\")}.mjs`,\n\t\t);\n\t\tawait fs.writeFile(tempPath, result.code);\n\n\t\ttry {\n\t\t\tconst fileUrl = pathToFileURL(tempPath).href;\n\t\t\tconst module = await import(fileUrl);\n\t\t\tconfig = module.default;\n\t\t} finally {\n\t\t\tawait fs.unlink(tempPath).catch(() => {});\n\t\t}\n\t} else {\n\t\tconst fileUrl = pathToFileURL(resolvedPath).href;\n\t\tconst module = await import(fileUrl);\n\t\tconfig = module.default;\n\t}\n\n\tif (!config) {\n\t\tthrow new Error(\"Config file must export a default configuration\");\n\t}\n\n\tif (typeof config === \"function\") {\n\t\tconfig = config({} as SecondLayerConfig);\n\t}\n\n\tvalidateConfig(config);\n\n\t// Process plugins if they exist\n\tconst pluginManager = new PluginManager();\n\n\tif (config.plugins && Array.isArray(config.plugins)) {\n\t\tfor (const plugin of config.plugins) {\n\t\t\tpluginManager.register(plugin);\n\t\t}\n\t}\n\n\t// Transform config through plugins\n\tconst resolvedConfig = await pluginManager.transformConfig(config);\n\n\treturn resolvedConfig;\n}\n\nexport function validateConfig(\n\tconfig: unknown,\n): asserts config is SecondLayerConfig {\n\tif (!config || typeof config !== \"object\") {\n\t\tthrow new Error(\"Config must be an object\");\n\t}\n\n\t// biome-ignore lint/suspicious/noExplicitAny: interop boundary or dynamic-shape value where typing adds friction without runtime safety\n\tconst c = config as any;\n\n\t// Contracts are optional now since plugins can provide them\n\tif (c.contracts && !Array.isArray(c.contracts)) {\n\t\tthrow new Error(\"Config contracts must be an array\");\n\t}\n\n\tif (!c.out || typeof c.out !== \"string\") {\n\t\tthrow new Error(\"Config out must be a string path\");\n\t}\n\n\t// Validate contracts if they exist\n\tif (c.contracts) {\n\t\tfor (const contract of c.contracts) {\n\t\t\tif (!contract.address && !contract.source) {\n\t\t\t\tthrow new Error(\"Each contract must have either an address or source\");\n\t\t\t}\n\t\t}\n\t}\n\n\t// Validate plugins if they exist\n\tif (c.plugins && !Array.isArray(c.plugins)) {\n\t\tthrow new Error(\"Config plugins must be an array\");\n\t}\n}\n\n/**\n * Type-safe helper for creating a `secondlayer.config.ts` configuration.\n * Accepts either a config object or a factory function that receives a base config and returns a modified one.\n *\n * @example\n * ```ts\n * import { defineConfig } from \"@secondlayer/cli\";\n *\n * export default defineConfig({\n * contracts: [{ address: \"SP000000000000000000002Q6VF78.bns\" }],\n * out: \"./src/generated.ts\",\n * });\n * ```\n */\nexport function defineConfig(config: SecondLayerConfig): SecondLayerConfig;\nexport function defineConfig(definer: ConfigDefiner): ConfigDefiner;\nexport function defineConfig(\n\tconfigOrDefiner: SecondLayerConfig | ConfigDefiner,\n) {\n\treturn configOrDefiner;\n}\n",
|
|
10
10
|
"/**\n * @secondlayer/cli\n * CLI tool for generating type-safe Stacks contract interfaces\n */\n\nexport { defineConfig } from \"./utils/config\";\nexport type {\n\tSecondLayerConfig,\n\tContractSource,\n\tNetworkName,\n} from \"./types/config\";\n\nexport type {\n\tAbiContract,\n\tAbiFunction,\n\tAbiType,\n} from \"@secondlayer/stacks/clarity\";\n\n// Plugin system exports\nexport type {\n\tSecondLayerPlugin,\n\tPluginFactory,\n\tPluginOptions,\n\tUserConfig,\n\tResolvedConfig,\n\tGenerateContext,\n\tPluginContext,\n\tLogger,\n\tPluginUtils,\n\tGeneratedOutput,\n\tProcessedContract,\n\tContractConfig,\n\tOutputType,\n} from \"./types/plugin\";\n\nexport { PluginManager } from \"./core/plugin-manager\";\n"
|
|
11
11
|
],
|
|
12
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmGO,SAAS,kBAAkB,CACjC,GAC8B;AAAA,EAC9B,OAAO,qBAAqB,KAAK,EAAE,oBAAoB;AAAA;AAMjD,SAAS,oBAAoB,CACnC,GACgC;AAAA,EAChC,OAAO,iBAAiB,KAAK,EAAE,gBAAgB;AAAA;;;AC3GzC,SAAS,eAAe,CAAC,YAG9B;AAAA,EACD,MAAM,WAAW,WAAW,QAAQ,GAAG;AAAA,EACvC,IAAI,aAAa,IAAI;AAAA,IACpB,MAAM,IAAI,MACT,yBAAyB,+CAC1B;AAAA,EACD;AAAA,EACA,OAAO;AAAA,IACN,SAAS,WAAW,MAA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A8BA;",
|
|
13
|
+
"debugId": "3060870279D1AD3464756E2164756E21",
|
|
14
14
|
"names": []
|
|
15
15
|
}
|
package/dist/plugins/index.js
CHANGED
|
@@ -118,8 +118,8 @@ var biome = null;
|
|
|
118
118
|
var init_format = () => {};
|
|
119
119
|
|
|
120
120
|
// src/core/plugin-manager.ts
|
|
121
|
-
import { promises as fs } from "fs";
|
|
122
|
-
import path from "path";
|
|
121
|
+
import { promises as fs } from "node:fs";
|
|
122
|
+
import path from "node:path";
|
|
123
123
|
import { isValidAddress as _validateStacksAddress } from "@secondlayer/stacks";
|
|
124
124
|
import { getErrorMessage } from "@secondlayer/shared";
|
|
125
125
|
import { toCamelCase } from "@secondlayer/stacks/clarity";
|
|
@@ -505,10 +505,10 @@ function generateClarityConversion(argName, argType) {
|
|
|
505
505
|
})()`;
|
|
506
506
|
}
|
|
507
507
|
if (isAbiResponse(type)) {
|
|
508
|
-
const okConversion = generateClarityConversion(
|
|
508
|
+
const okConversion = generateClarityConversion("responseValue.ok", {
|
|
509
509
|
type: type.response.ok
|
|
510
510
|
});
|
|
511
|
-
const errConversion = generateClarityConversion(
|
|
511
|
+
const errConversion = generateClarityConversion("responseValue.err", {
|
|
512
512
|
type: type.response.error
|
|
513
513
|
});
|
|
514
514
|
return `(() => {
|
|
@@ -1112,13 +1112,14 @@ function sanitizeContractName(name) {
|
|
|
1112
1112
|
async function isUserDefinedContract(contractId, manifestPath) {
|
|
1113
1113
|
const { address, contractName } = parseContractId(contractId);
|
|
1114
1114
|
try {
|
|
1115
|
-
const { promises: fs2 } = await import("fs");
|
|
1115
|
+
const { promises: fs2 } = await import("node:fs");
|
|
1116
1116
|
const tomlContent = await fs2.readFile(manifestPath, "utf-8");
|
|
1117
1117
|
const contractSectionRegex = /^\[contracts\.([^\]]+)\]/gm;
|
|
1118
1118
|
const userContracts = new Set;
|
|
1119
|
-
let match;
|
|
1120
|
-
while (
|
|
1119
|
+
let match = contractSectionRegex.exec(tomlContent);
|
|
1120
|
+
while (match !== null) {
|
|
1121
1121
|
userContracts.add(match[1]);
|
|
1122
|
+
match = contractSectionRegex.exec(tomlContent);
|
|
1122
1123
|
}
|
|
1123
1124
|
if (userContracts.has(contractName)) {
|
|
1124
1125
|
return true;
|
|
@@ -1164,7 +1165,7 @@ var clarinet = (options = {}) => {
|
|
|
1164
1165
|
if (options.include && !options.include.includes(contractName)) {
|
|
1165
1166
|
continue;
|
|
1166
1167
|
}
|
|
1167
|
-
if (options.exclude
|
|
1168
|
+
if (options.exclude?.includes(contractName)) {
|
|
1168
1169
|
continue;
|
|
1169
1170
|
}
|
|
1170
1171
|
const sanitizedName = sanitizeContractName(contractName);
|
|
@@ -1209,7 +1210,7 @@ var clarinet = (options = {}) => {
|
|
|
1209
1210
|
};
|
|
1210
1211
|
async function hasClarinetProject(path2 = "./Clarinet.toml") {
|
|
1211
1212
|
try {
|
|
1212
|
-
const { promises: fs2 } = await import("fs");
|
|
1213
|
+
const { promises: fs2 } = await import("node:fs");
|
|
1213
1214
|
await fs2.access(path2);
|
|
1214
1215
|
return true;
|
|
1215
1216
|
} catch {
|
|
@@ -1230,7 +1231,7 @@ function generateReadHelpers(contract, options) {
|
|
|
1230
1231
|
if (options.includeFunctions && !options.includeFunctions.includes(func.name)) {
|
|
1231
1232
|
return false;
|
|
1232
1233
|
}
|
|
1233
|
-
if (options.excludeFunctions
|
|
1234
|
+
if (options.excludeFunctions?.includes(func.name)) {
|
|
1234
1235
|
return false;
|
|
1235
1236
|
}
|
|
1236
1237
|
return true;
|
|
@@ -1274,7 +1275,7 @@ function generateWriteHelpers(contract, options) {
|
|
|
1274
1275
|
if (options.includeFunctions && !options.includeFunctions.includes(func.name)) {
|
|
1275
1276
|
return false;
|
|
1276
1277
|
}
|
|
1277
|
-
if (options.excludeFunctions
|
|
1278
|
+
if (options.excludeFunctions?.includes(func.name)) {
|
|
1278
1279
|
return false;
|
|
1279
1280
|
}
|
|
1280
1281
|
return true;
|
|
@@ -1341,7 +1342,7 @@ var actions = (options = {}) => {
|
|
|
1341
1342
|
if (options.include && !options.include.includes(contract.name)) {
|
|
1342
1343
|
return false;
|
|
1343
1344
|
}
|
|
1344
|
-
if (options.exclude
|
|
1345
|
+
if (options.exclude?.includes(contract.name)) {
|
|
1345
1346
|
return false;
|
|
1346
1347
|
}
|
|
1347
1348
|
return true;
|
|
@@ -2720,7 +2721,7 @@ var testing = (options = {}) => {
|
|
|
2720
2721
|
if (options.include && !options.include.includes(contract.name)) {
|
|
2721
2722
|
return false;
|
|
2722
2723
|
}
|
|
2723
|
-
if (options.exclude
|
|
2724
|
+
if (options.exclude?.includes(contract.name)) {
|
|
2724
2725
|
return false;
|
|
2725
2726
|
}
|
|
2726
2727
|
return true;
|
|
@@ -2752,10 +2753,10 @@ var testing = (options = {}) => {
|
|
|
2752
2753
|
function filterByOptions(items, options = {}) {
|
|
2753
2754
|
let filtered = items;
|
|
2754
2755
|
if (options.include && options.include.length > 0) {
|
|
2755
|
-
filtered = filtered.filter((item) => options.include
|
|
2756
|
+
filtered = filtered.filter((item) => options.include?.some((pattern) => item.name.includes(pattern) || item.name.match(new RegExp(pattern))));
|
|
2756
2757
|
}
|
|
2757
2758
|
if (options.exclude && options.exclude.length > 0) {
|
|
2758
|
-
filtered = filtered.filter((item) => !options.exclude
|
|
2759
|
+
filtered = filtered.filter((item) => !options.exclude?.some((pattern) => item.name.includes(pattern) || item.name.match(new RegExp(pattern))));
|
|
2759
2760
|
}
|
|
2760
2761
|
return filtered;
|
|
2761
2762
|
}
|
|
@@ -2777,5 +2778,5 @@ export {
|
|
|
2777
2778
|
PluginManager
|
|
2778
2779
|
};
|
|
2779
2780
|
|
|
2780
|
-
//# debugId=
|
|
2781
|
+
//# debugId=63411A134FE3EE3564756E2164756E21
|
|
2781
2782
|
//# sourceMappingURL=index.js.map
|