@clarigen/cli 4.0.2-alpha.0 → 4.1.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/{esm-CO92uOgU.mjs → esm-BjGH_MkS.mjs} +85 -245
- package/dist/esm-BjGH_MkS.mjs.map +1 -0
- package/dist/{esm-CRbGFHSR.cjs → esm-DPOm6Bdw.cjs} +114 -316
- package/dist/esm-DPOm6Bdw.cjs.map +1 -0
- package/dist/index.cjs +1 -8
- package/dist/index.d.cts +21 -64
- package/dist/index.d.mts +21 -64
- package/dist/index.mjs +2 -2
- package/dist/run-cli.cjs +53 -50
- package/dist/run-cli.cjs.map +1 -1
- package/dist/run-cli.mjs +51 -48
- package/dist/run-cli.mjs.map +1 -1
- package/package.json +17 -15
- package/dist/esm-CO92uOgU.mjs.map +0 -1
- package/dist/esm-CRbGFHSR.cjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"esm-DPOm6Bdw.cjs","names":["contractLines: string[]","defaultConfigFile: ConfigFile","type","sessionConfig: ConfigFile | undefined","excluded: Record<string, boolean>","contractFile: string | undefined","tupleDefs: string[]","type","h: Record<string, boolean>","functionLines: string[]","type","inspect","varsAbi: Writeable<ClarityAbiTypeTuple>","plan: Plan"],"sources":["../src/utils.ts","../src/docs/markdown.ts","../src/logger.ts","../src/docs/index.ts","../src/clarinet-config.ts","../src/config.ts","../src/files/docs.ts","../src/declaration.ts","../src/files/accounts.ts","../src/files/identifiers.ts","../src/files/base.ts","../src/files/variables.ts","../src/files/esm.ts"],"sourcesContent":["// import { dirname, relative, resolve } from '../deps.ts';\n/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */\nimport { getContractName, toCamelCase } from '@clarigen/core';\n// export { getContractName, toCamelCase, toKebabCase } from '@clarigen/core';\nimport { stat, mkdir, writeFile as fsWriteFile } from 'node:fs/promises';\nimport { dirname, relative } from 'node:path';\n\nexport function encodeVariableName(name: string) {\n // biome-ignore lint/performance/useTopLevelRegex: ignored using `--suppress`\n if (/^[A-Z\\-_]*$/.test(name)) return name.replaceAll('-', '_');\n return toCamelCase(name);\n}\n\nexport async function fileExists(filename: string): Promise<boolean> {\n try {\n await stat(filename);\n // successful, file or directory must exist\n return true;\n } catch (_error) {\n return false;\n // if (error.code === 'ENOENT') {\n // // file or directory does not exist\n // return false;\n // } else {\n // // unexpected error, maybe permissions, pass it along\n // throw error;\n // }\n }\n}\n\nexport async function writeFile(path: string, contents: string) {\n const dir = dirname(path);\n await mkdir(dir, { recursive: true });\n await fsWriteFile(path, contents, 'utf-8');\n return path;\n}\n\nexport function cwdRelative(path: string) {\n return relative(process.cwd(), path);\n}\n\n// Sort contracts alphabetically by their contract name.\n// Used to preserve ordering when generating files\nexport function sortContracts<T extends { contract_id: string }>(\n contracts: T[]\n): T[] {\n const nameSorted = [...contracts].sort((a, b) => {\n if (\n getContractName(a.contract_id, false) <\n getContractName(b.contract_id, false)\n ) {\n return -1;\n }\n return 1;\n });\n return nameSorted;\n}\n","/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */\nimport type { Session, SessionContract } from '../session';\nimport { getContractName, getTypeString } from '@clarigen/core';\nimport {\n type ClaridocContract,\n type ClaridocFunction,\n type ClaridocItem,\n type ClaridocMap,\n type ClaridocParam,\n type ClaridocVariable,\n createContractDocInfo,\n} from '@clarigen/docs';\nimport { basename } from 'node:path';\nimport { sortContracts } from '../utils';\n\nexport function generateMarkdown({\n contract,\n contractFile,\n withToc = true,\n}: {\n contract: SessionContract;\n contractFile?: string;\n withToc?: boolean;\n}) {\n const contractName = getContractName(contract.contract_id, false);\n const doc = createContractDocInfo({\n contractSrc: contract.source,\n abi: contract.contract_interface,\n });\n\n const functions = doc.functions.map(fn => markdownFunction(fn, contractFile));\n const maps = doc.maps.map(map => markdownMap(map, contractFile));\n const vars = doc.variables\n .filter(v => v.abi.access === 'variable')\n .map(v => markdownVar(v, contractFile));\n const constants = doc.variables\n .filter(v => v.abi.access === 'constant')\n .map(v => markdownVar(v, contractFile));\n let fileLine = '';\n if (contractFile) {\n const fileName = basename(contractFile);\n fileLine = `\\n[\\`${fileName}\\`](${contractFile})`;\n }\n\n return `\n# ${contractName}\n${fileLine}\n\n${doc.comments.join('\\n\\n')}\n\n${withToc ? markdownTOC(doc) : ''}\n\n## Functions\n\n${functions.join('\\n\\n')}\n\n## Maps\n\n${maps.join('\\n\\n')}\n\n## Variables\n\n${vars.join('\\n\\n')}\n\n## Constants\n\n${constants.join('\\n\\n')}\n `;\n}\n\nexport function markdownFunction(fn: ClaridocFunction, contractFile?: string) {\n const params = mdParams(fn);\n const returnType = getTypeString(fn.abi.outputs.type);\n const paramSigs = fn.abi.args.map(arg => `(${arg.name} ${getTypeString(arg.type)})`);\n\n const startLine = fn.startLine + 1;\n\n let link = '';\n if (contractFile) {\n link = `[View in file](${contractFile}#L${startLine})`;\n }\n\n const source = `<details>\n <summary>Source code:</summary>\n\n\\`\\`\\`clarity\n${fn.source.join('\\n')}\n\\`\\`\\`\n</details>\n`;\n\n const sig = `(define-${fn.abi.access.replace('_', '-')} (${fn.abi.name} (${paramSigs.join(\n ' '\n )}) ${returnType})`;\n\n return `### ${fn.abi.name}\n\n${link}\n\n\\`${sig}\\`\n\n${fn.comments.text.join('\\n')}\n\n${source}\n\n${params}`;\n}\n\nfunction mdParams(fn: ClaridocFunction) {\n if (fn.abi.args.length === 0) return '';\n const hasDescription = Object.values(fn.comments.params).some(p => p.comments.length > 0);\n const params = Object.values(fn.comments.params).map(p => markdownParam(p, hasDescription));\n // const hasDescription = params.some(p => p.includes('Description'));\n\n return `**Parameters:**\n\n| Name | Type | ${hasDescription ? 'Description |' : ''}\n| --- | --- | ${hasDescription ? '--- |' : ''}\n${params.join('\\n')}`;\n}\n\nfunction markdownParam(param: ClaridocParam, withDescription: boolean) {\n const typeString = getTypeString(param.abi.type);\n const base = `| ${param.abi.name} | ${typeString} |`;\n if (!withDescription) return base;\n return `${base} ${param.comments.join(' ')} |`;\n // return `| ${param.abi.name} | ${typeString} | ${param.comments.join(' ')} |`;\n}\n\nfunction markdownMap(map: ClaridocMap, contractFile?: string) {\n const startLine = map.startLine + 1;\n\n let link = '';\n if (contractFile) {\n link = `[View in file](${contractFile}#L${startLine})`;\n }\n\n return `### ${map.abi.name}\n\n${map.comments.text.join('\\n')}\n\n\\`\\`\\`clarity\n${map.source.join('\\n')}\n\\`\\`\\`\n\n${link}`;\n}\n\nfunction markdownVar(variable: ClaridocVariable, contractFile?: string) {\n const startLine = variable.startLine + 1;\n\n let link = '';\n if (contractFile) {\n link = `[View in file](${contractFile}#L${startLine})`;\n }\n\n const sig = variable.abi.access === 'variable' ? getTypeString(variable.abi.type) : '';\n\n return `### ${variable.abi.name}\n\n${sig}\n\n${variable.comments.text.join('\\n')}\n\n\\`\\`\\`clarity\n${variable.source.join('\\n')}\n\\`\\`\\`\n\n${link}`;\n}\n\nfunction markdownTOC(contract: ClaridocContract) {\n const publics = contract.functions.filter(fn => fn.abi.access === 'public');\n const readOnly = contract.functions.filter(fn => fn.abi.access === 'read_only');\n const privates = contract.functions.filter(fn => fn.abi.access === 'private');\n const maps = contract.maps;\n const constants = contract.variables.filter(v => v.abi.access === 'constant');\n const vars = contract.variables.filter(v => v.abi.access === 'variable');\n\n function tocLine(fn: ClaridocItem) {\n const name = fn.abi.name;\n return `- [\\`${name}\\`](#${name.toLowerCase().replaceAll('?', '')})`;\n }\n\n return `**Public functions:**\n\n${publics.map(tocLine).join('\\n')}\n\n**Read-only functions:**\n\n${readOnly.map(tocLine).join('\\n')}\n\n**Private functions:**\n\n${privates.map(tocLine).join('\\n')}\n\n**Maps**\n\n${maps.map(tocLine).join('\\n')}\n\n**Variables**\n\n${vars.map(tocLine).join('\\n')}\n\n**Constants**\n\n${constants.map(tocLine).join('\\n')}\n`;\n}\n\nexport function generateReadme(session: Session, excluded: Record<string, boolean>) {\n const contractLines: string[] = [];\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n sortContracts(session.contracts).forEach(contract => {\n const name = getContractName(contract.contract_id, false);\n if (excluded[name]) return;\n const fileName = `${name}.md`;\n const line = `- [\\`${name}\\`](${fileName})`;\n contractLines.push(line);\n });\n const fileContents = `# Contracts\n\n${contractLines.join('\\n')}\n `;\n\n return fileContents;\n}\n\n// function md(strings: TemplateStringsArray, ..._values: any) {\n// const raw = String.raw({ raw: strings }, ..._values);\n// const fixed = raw.split('\\n').map((s) => s.trim()).join('\\n');\n// return fixed;\n// }\n","import { pino } from 'pino';\nimport pinoPretty from 'pino-pretty';\n\nexport const colorizedClarigen = '\\x1b[33m[Clarigen]\\x1b[0m';\n\nexport const logger = pino(\n pinoPretty({\n colorize: true,\n ignore: 'pid,hostname,time',\n messageFormat: `${colorizedClarigen} {msg}`,\n minimumLevel: 'debug',\n })\n);\nlogger.level = 'info';\n\nexport const log = logger;\n","import type { Config } from '../config';\nimport { logger } from '../logger';\nimport { spawn } from 'node:child_process';\n\n// biome-ignore lint/suspicious/useAwait: ignored using `--suppress`\nexport async function afterDocs(config: Config): Promise<void> {\n const command = config.docs?.after;\n if (!command) return;\n logger.debug(`Running after docs command: ${command}`);\n const parts = command.split(' ');\n const [cmd, ...args] = parts;\n return new Promise((resolve, reject) => {\n const child = spawn(cmd, args, {\n cwd: config.cwd,\n stdio: 'inherit',\n });\n child.on('error', reject);\n child.on('exit', code => {\n if (code === 0) {\n resolve();\n } else {\n reject(new Error(`Command failed with code ${code ?? 'unknown'}`));\n }\n });\n });\n}\n","/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */\nimport { type } from 'arktype';\nimport { readFile } from 'node:fs/promises';\nimport { parse } from '@iarna/toml';\n\nexport const ClarinetConfig = type({\n project: type({\n requirements: type({\n contract_id: type('string').describe('Contract ID'),\n })\n .array()\n .describe('Project requirements')\n .optional(),\n cache_location: type({\n path: type('string').describe('Cache location path'),\n }).optional(),\n }),\n contracts: type({\n '[string]': type({\n path: type('string').describe('Contract path'),\n }),\n }).optional(),\n});\n\nexport type ClarinetConfig = typeof ClarinetConfig.infer;\n\nexport async function getClarinetConfig(path: string): Promise<ClarinetConfig> {\n const file = await readFile(path, 'utf-8');\n const config = ClarinetConfig.assert(parse(file));\n return config;\n}\n","/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */\nimport { type } from 'arktype';\nimport { log, logger } from './logger';\nimport { fileExists, writeFile } from './utils';\nimport { type ClarinetConfig, getClarinetConfig } from './clarinet-config';\nimport { dirname, join, relative, resolve } from 'node:path';\nimport { stringify, parse } from '@iarna/toml';\nimport { readFile } from 'node:fs/promises';\n\nexport const CONFIG_FILE = 'Clarigen.toml' as const;\n\n// biome-ignore lint/style/noEnum: ignored using `--suppress`\nexport enum OutputType {\n ESM = 'types',\n ESM_OLD = 'esm',\n Docs = 'docs',\n}\n\nconst typesSchema = type({\n 'output?': type('string').describe('Path to the output file'),\n 'outputs?': type('string[]').describe('Paths to the output files'),\n 'include_accounts?': type('boolean').describe(\n 'Include accounts in the output'\n ),\n 'after?': type('string').describe(\n 'Script to run after the output is generated'\n ),\n 'include_boot_contracts?': type('boolean').describe(\n 'Include boot contracts in the output'\n ),\n 'watch_folders?': type('string[]').describe('Folders to watch for changes'),\n}).optional();\n\nexport const ConfigFile = type({\n clarinet: type('string').describe('Path to the Clarinet config file'),\n [OutputType.ESM]: typesSchema,\n [OutputType.ESM_OLD]: typesSchema,\n [OutputType.Docs]: type({\n 'output?': type('string').describe(\n 'Path to docs output folder. Defaults to ./docs'\n ),\n 'outputs?': type('string[]').describe('Paths to docs output folders'),\n 'exclude?': type('string[]').describe(\n 'Contracts to exclude from docs generation'\n ),\n 'after?': type('string').describe('Script to run after docs are generated'),\n }).optional(),\n});\n\nexport type ConfigFile = typeof ConfigFile.infer;\n\nexport const defaultConfigFile: ConfigFile = {\n clarinet: './Clarinet.toml',\n};\n\nexport class Config {\n // biome-ignore lint/style/useConsistentMemberAccessibility: ignored using `--suppress`\n public configFile: ConfigFile;\n // biome-ignore lint/style/useConsistentMemberAccessibility: ignored using `--suppress`\n public clarinet: ClarinetConfig;\n // biome-ignore lint/style/useConsistentMemberAccessibility: ignored using `--suppress`\n public cwd: string;\n\n constructor(config: ConfigFile, clarinet: ClarinetConfig, cwd?: string) {\n this.configFile = config;\n this.clarinet = clarinet;\n this.cwd = cwd ?? process.cwd();\n }\n\n // biome-ignore lint/style/useConsistentMemberAccessibility: ignored using `--suppress`\n public static async load(cwd?: string) {\n const config = await getConfig(cwd);\n if (config[OutputType.ESM_OLD]) {\n config[OutputType.ESM] = config[OutputType.ESM_OLD];\n delete config[OutputType.ESM_OLD];\n }\n const clarinet = await getClarinetConfig(\n resolve(cwd ?? '', config.clarinet)\n );\n return new Config(config, clarinet, cwd);\n }\n\n // biome-ignore lint/nursery/noShadow: ignored using `--suppress`\n getOutputs(type: OutputType): string[] {\n const singlePath = this.configFile[type]?.output;\n const multiPath = this.configFile[type]?.outputs || [];\n if (singlePath !== undefined) return [singlePath];\n return multiPath;\n }\n\n // biome-ignore lint/nursery/noShadow: ignored using `--suppress`\n outputResolve(type: OutputType, filePath?: string): string[] | null {\n const outputs = this.getOutputs(type);\n if (!this.supports(type)) return null;\n return outputs.map((path) => resolve(this.cwd, path, filePath || ''));\n }\n\n // biome-ignore lint/nursery/noShadow: ignored using `--suppress`\n async writeOutput(type: OutputType, contents: string, filePath?: string) {\n const paths = this.outputResolve(type, filePath);\n if (paths === null) return null;\n await Promise.all(\n paths.map(async (path) => {\n await writeFile(path, contents);\n log.debug(`Generated ${type} file at ${relative(this.cwd, path)}`);\n })\n );\n return paths;\n }\n\n // biome-ignore lint/nursery/noShadow: ignored using `--suppress`\n supports(type: OutputType) {\n return this.getOutputs(type).length > 0;\n }\n\n // biome-ignore lint/nursery/noShadow: ignored using `--suppress`\n type(type: OutputType) {\n return this.configFile[type];\n }\n\n get esm() {\n return this.configFile[OutputType.ESM];\n }\n get docs() {\n return this.configFile[OutputType.Docs];\n }\n\n clarinetFile() {\n return resolve(this.cwd, this.configFile.clarinet);\n }\n\n joinFromClarinet(filePath: string) {\n const baseDir = dirname(this.clarinetFile());\n return join(baseDir, filePath);\n }\n}\n\nexport function configFilePath(cwd?: string) {\n return resolve(cwd ?? process.cwd(), CONFIG_FILE);\n}\n\nexport async function saveConfig(config: ConfigFile) {\n const configToml = stringify({ ...config });\n await writeFile(configFilePath(), configToml);\n}\n\n// memoize / singleton\nlet sessionConfig: ConfigFile | undefined;\n\nexport async function getConfig(cwd?: string): Promise<ConfigFile> {\n if (typeof sessionConfig !== 'undefined') return sessionConfig;\n const path = configFilePath(cwd);\n if (await fileExists(path)) {\n const toml = await readFile(path, 'utf-8');\n const parsedToml = parse(toml);\n const parsed = ConfigFile(parsedToml);\n if (parsed instanceof type.errors) {\n logger.error(`Error parsing Clarigen config: ${parsed.summary}`);\n throw new Error(`Error parsing Clarigen config: ${parsed.summary}`);\n }\n sessionConfig = parsed;\n } else {\n sessionConfig = defaultConfigFile;\n }\n return sessionConfig;\n}\n","/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */\nimport type { SessionWithVariables } from '../session';\nimport { type Config, OutputType } from '../config';\nimport { log } from '../logger';\nimport { getContractName } from '@clarigen/core';\nimport { relative, extname } from 'node:path';\nimport { generateMarkdown, generateReadme } from '../docs/markdown';\nimport { afterDocs } from '../docs';\n\nexport async function generateDocs({\n session,\n config,\n}: {\n session: SessionWithVariables;\n config: Config;\n}) {\n const docs = config.configFile[OutputType.Docs];\n const docsBase = docs?.output;\n if (!docsBase) {\n warnNoDocs();\n return;\n }\n const docsPathExt = extname(docsBase);\n if (docsPathExt) {\n log.warn(`Docs output path ('${docsBase}') looks like a file - it needs to be a directory.`);\n }\n const excluded: Record<string, boolean> = Object.fromEntries(\n (docs.exclude || []).map(e => [e, true])\n );\n log.debug(`Generating docs at path \\`${docsBase}\\``);\n // biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`\n // biome-ignore lint/suspicious/noNonNullAssertedOptionalChain: ignored using `--suppress`\n const docsBaseFolder = config.outputResolve(OutputType.Docs, './')?.[0]!;\n const paths = await Promise.all(\n session.contracts.map(async contract => {\n const name = getContractName(contract.contract_id, false);\n if (excluded[name]) return null;\n const docFile = `${name}.md`;\n // location of\n const contractPathDef = config.clarinet.contracts?.[name]?.path;\n let contractFile: string | undefined;\n // if we have the contract file, make a relative link\n if (contractPathDef) {\n const contractPathFull = config.joinFromClarinet(contractPathDef);\n contractFile = relative(docsBaseFolder, contractPathFull);\n } else {\n // TODO: probably a requirement\n log.debug(`Couldn't find contract file from Clarinet.toml for contract ${name}`);\n }\n\n const md = generateMarkdown({ contract, contractFile });\n\n // log.debug(`Writing docs markdown file at ${cwdRelative(docPathFull)}`);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n // biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`\n const path = (await config.writeOutput(OutputType.Docs, md, docFile))!;\n return path[0];\n })\n );\n\n const readme = generateReadme(session, excluded);\n\n paths.push(\n // biome-ignore lint/suspicious/noNonNullAssertedOptionalChain: ignored using `--suppress`\n // biome-ignore lint/style/noNonNullAssertion: ignored using `--suppress`\n (await config.writeOutput(OutputType.Docs, readme, 'README.md'))?.[0]!\n );\n await afterDocs(config);\n}\n\nfunction warnNoDocs() {\n log.warn(\n `\\nClarigen config file doesn't include an output directory for docs.\n\nTo generate docs, specify 'docs.output' in your config file:\n\n[docs]\noutput = \"docs/\"\n `.trimEnd()\n );\n}\n","import {\n isClarityAbiBuffer,\n isClarityAbiList,\n isClarityAbiOptional,\n isClarityAbiPrimitive,\n isClarityAbiResponse,\n isClarityAbiStringAscii,\n isClarityAbiStringUtf8,\n isClarityAbiTuple,\n type ClarityAbiType,\n isClarityAbiTraitReference,\n} from '@clarigen/core';\n// import { ClarityAbiArg, ClarityAbiFunction, ClarityAbiType } from '../types.ts';\nimport {\n toCamelCase,\n type ClarityAbiArg,\n type ClarityAbiFunction,\n} from '@clarigen/core';\n\nexport const jsTypeFromAbiType = (\n val: ClarityAbiType,\n isArgument = false\n // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: ignored using `--suppress`\n): string => {\n if (isClarityAbiPrimitive(val)) {\n if (val === 'uint128') {\n if (isArgument) return 'number | bigint';\n return 'bigint';\n }\n if (val === 'int128') {\n if (isArgument) return 'number | bigint';\n return 'bigint';\n }\n if (val === 'bool') {\n return 'boolean';\n }\n if (val === 'principal') {\n return 'string';\n }\n if (val === 'none') {\n return 'null';\n }\n if (val === 'trait_reference') {\n return 'string';\n }\n throw new Error(\n `Unexpected Clarity ABI type primitive: ${JSON.stringify(val)}`\n );\n }\n if (isClarityAbiBuffer(val)) {\n return 'Uint8Array';\n }\n if (isClarityAbiResponse(val)) {\n const ok = jsTypeFromAbiType(val.response.ok, isArgument);\n const err = jsTypeFromAbiType(val.response.error, isArgument);\n return `Response<${ok}, ${err}>`;\n }\n if (isClarityAbiOptional(val)) {\n const innerType = jsTypeFromAbiType(val.optional, isArgument);\n return `${innerType} | null`;\n }\n if (isClarityAbiTuple(val)) {\n const tupleDefs: string[] = [];\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n val.tuple.forEach(({ name, type }) => {\n const camelName = toCamelCase(name);\n const innerType = jsTypeFromAbiType(type, isArgument);\n tupleDefs.push(`\"${camelName}\": ${innerType};`);\n });\n return `{\n ${tupleDefs.join('\\n ')}\n}`;\n }\n if (isClarityAbiList(val)) {\n const innerType = jsTypeFromAbiType(val.list.type, isArgument);\n return `${innerType}[]`;\n }\n if (isClarityAbiStringAscii(val)) {\n return 'string';\n }\n if (isClarityAbiStringUtf8(val)) {\n return 'string';\n }\n if (isClarityAbiTraitReference(val)) {\n return 'string';\n }\n throw new Error(`Unexpected Clarity ABI type: ${JSON.stringify(val)}`);\n};\n\nexport function abiArgType(arg: ClarityAbiArg) {\n const nativeType = jsTypeFromAbiType(arg.type, true);\n const argName = getArgName(arg.name);\n return `${argName}: TypedAbiArg<${nativeType}, \"${argName}\">`;\n}\n\nexport function abiFunctionType(abiFunction: ClarityAbiFunction) {\n const args = abiFunction.args.map(abiArgType);\n const retType = jsTypeFromAbiType(abiFunction.outputs.type);\n const argsTuple = `[${args.join(', ')}]`;\n return `TypedAbiFunction<${argsTuple}, ${retType}>`;\n}\n\n// Check if it's a reserved word, and then camelCase\nexport function getArgName(name: string) {\n const camel = toCamelCase(name);\n const prefix = RESERVED[camel] ? '_' : '';\n return `${prefix}${camel}`;\n}\n\nfunction _hash(...words: string[]) {\n const h: Record<string, boolean> = {};\n for (const word of words) {\n h[word] = true;\n }\n return h;\n}\n\nconst RESERVED = _hash(\n // Keywords, ES6 11.6.2.1, http://www.ecma-international.org/ecma-262/6.0/index.html#sec-keywords\n 'break',\n 'do',\n 'in',\n 'typeof',\n 'case',\n 'else',\n 'instanceof',\n 'var',\n 'catch',\n 'export',\n 'new',\n 'void',\n 'class',\n 'extends',\n 'return',\n 'while',\n 'const',\n 'finally',\n 'super',\n 'with',\n 'continue',\n 'for',\n 'switch',\n 'yield',\n 'debugger',\n 'function',\n 'this',\n 'default',\n 'if',\n 'throw',\n 'delete',\n 'import',\n 'try',\n // Future Reserved Words, ES6 11.6.2.2\n // http://www.ecma-international.org/ecma-262/6.0/index.html#sec-future-reserved-words\n 'enum',\n 'await',\n // NullLiteral & BooleanLiteral\n 'null',\n 'true',\n 'false'\n);\n","import type { SessionAccount } from '../session';\n\nexport function generateAccountsCode(accounts: SessionAccount[]) {\n const sortedAccounts = sortAccounts(accounts);\n const namedAccounts = Object.fromEntries(\n sortedAccounts.map(a => {\n const { name, ...rest } = a;\n return [name, rest];\n })\n );\n // return `export const accounts = ${JSON.stringify(namedAccounts)} as const;`;\n return JSON.stringify(namedAccounts);\n}\n\n// Sort accounts alphabetically by their name.\n// Used to preserve ordering when generating files\nexport function sortAccounts(accounts: SessionAccount[]): SessionAccount[] {\n const nameSorted = [...accounts].sort((a, b) => {\n if (a.name < b.name) {\n return -1;\n }\n return 1;\n });\n return nameSorted;\n}\n","import { getContractName } from '@clarigen/core';\nimport type { Session } from '../session';\nimport { sortContracts } from '../utils';\n\nexport function generateIdentifiers(session: Session) {\n const identifiers = Object.fromEntries(\n sortContracts(session.contracts).map(c => {\n const contractName = getContractName(c.contract_id);\n return [contractName, c.contract_id];\n })\n );\n return identifiers;\n}\n\nexport function generateIdentifiersCode(session: Session) {\n const identifiers = generateIdentifiers(session);\n\n return `export const identifiers = ${JSON.stringify(identifiers)} as const`;\n}\n","import { abiFunctionType, jsTypeFromAbiType } from '../declaration';\nimport type { SessionContract, SessionWithVariables } from '../session';\nimport { encodeVariableName, sortContracts } from '../utils';\nimport { toCamelCase, type ClarityAbiVariable } from '@clarigen/core';\nimport { generateAccountsCode } from './accounts';\nimport { generateIdentifiersCode } from './identifiers';\nimport { inspect, type InspectOptions } from 'node:util';\n\nexport function generateContractMeta(contract: SessionContract, constants: string) {\n const abi = contract.contract_interface;\n const functionLines: string[] = [];\n const { functions, maps, variables, non_fungible_tokens, ...rest } = abi;\n\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n functions.forEach(func => {\n let functionLine = `${toCamelCase(func.name)}: `;\n const funcDef = JSON.stringify(func);\n functionLine += funcDef;\n const functionType = abiFunctionType(func);\n functionLine += ` as ${functionType}`;\n functionLines.push(functionLine);\n });\n\n const mapLines = maps.map(map => {\n let mapLine = `${toCamelCase(map.name)}: `;\n const keyType = jsTypeFromAbiType(map.key, true);\n const valType = jsTypeFromAbiType(map.value);\n mapLine += JSON.stringify(map);\n mapLine += ` as TypedAbiMap<${keyType}, ${valType}>`;\n return mapLine;\n });\n\n const otherAbi = JSON.stringify(rest);\n const contractName = contract.contract_id.split('.')[1];\n\n const variableLines = encodeVariables(variables);\n\n const nftLines = non_fungible_tokens.map(nft => JSON.stringify(nft));\n\n return `{\n ${serializeLines('functions', functionLines)}\n ${serializeLines('maps', mapLines)}\n ${serializeLines('variables', variableLines)}\n constants: ${constants},\n ${serializeArray('non_fungible_tokens', nftLines)}\n ${otherAbi.slice(1, -1)},\n contractName: '${contractName}',\n }`;\n}\n\nexport const TYPE_IMPORTS = `import type { TypedAbiArg, TypedAbiFunction, TypedAbiMap, TypedAbiVariable, Response } from '@clarigen/core';`;\n\nexport function generateBaseFile(session: SessionWithVariables) {\n const combined = session.contracts.map((c, i) => ({\n ...c,\n constants: session.variables[i],\n }));\n const contractDefs = sortContracts(combined).map(contract => {\n const meta = generateContractMeta(contract, contract.constants);\n const id = contract.contract_id.split('.')[1];\n const keyName = toCamelCase(id);\n return `${keyName}: ${meta}`;\n });\n\n const file = `\n${TYPE_IMPORTS}\n\nexport const contracts = {\n ${contractDefs.join(',\\n')}\n} as const;\n\nexport const accounts = ${generateAccountsCode(session.accounts)} as const;\n\n${generateIdentifiersCode(session)}\n\nexport const simnet = {\n accounts,\n contracts,\n identifiers,\n} as const;\n\n`;\n return file;\n}\n\nexport function encodeVariables(variables: ClarityAbiVariable[]) {\n return variables.map(v => {\n let varLine = `${encodeVariableName(v.name)}: `;\n const type = jsTypeFromAbiType(v.type);\n const varJSON = serialize(v);\n varLine += `${varJSON} as TypedAbiVariable<${type}>`;\n return varLine;\n });\n}\n\n// Extend the Uint8Array prototype in TypeScript to include util.inspect.custom\ndeclare global {\n // biome-ignore lint/style/useConsistentTypeDefinitions: ignored using `--suppress`\n interface Uint8Array {\n [inspect.custom](depth: number, options: InspectOptions): string;\n }\n}\n\nUint8Array.prototype[inspect.custom] = function (_depth: number, _options: InspectOptions) {\n return `Uint8Array.from([${this.join(',')}])`;\n};\n\n// biome-ignore lint/suspicious/noExplicitAny: ignored using `--suppress`\nexport function serialize(obj: any) {\n return inspect(obj, {\n // showHidden: false,\n // depth: 100,\n // colors: false,\n showHidden: false,\n // iterableLimit: 100000,\n compact: false,\n // trailingComma: true,\n depth: 100,\n colors: false,\n maxArrayLength: Number.POSITIVE_INFINITY,\n maxStringLength: Number.POSITIVE_INFINITY,\n breakLength: Number.POSITIVE_INFINITY,\n numericSeparator: true,\n // strAbbreviateSize: 100000,\n });\n}\n\nfunction serializeLines(key: string, lines: string[]) {\n return `\"${key}\": {\n ${lines.join(',\\n ')}\n },`;\n}\n\nfunction serializeArray(key: string, lines: string[]) {\n return `\"${key}\": [\n ${lines.join(',\\n ')}\n ],`;\n}\n","import type { Simnet } from '@stacks/clarinet-sdk';\nimport { logger } from '../logger';\nimport type { Session, SessionContract } from '../session';\nimport {\n type ClarityAbiTypeTuple,\n type ClarityAbiVariable,\n cvToValue,\n getContractName,\n} from '@clarigen/core';\nimport { serialize } from './base';\n\nfunction clarityVersionForContract(contract: SessionContract) {\n switch (contract.contract_interface.clarity_version) {\n case 'Clarity1':\n return 1;\n case 'Clarity2':\n return 2;\n case 'Clarity3':\n return 3;\n case 'Clarity4':\n return 4;\n default:\n return 3;\n }\n}\n\nexport function getVariablesV2(contract: SessionContract, simnet: Simnet, verbose?: boolean) {\n const [deployer] = contract.contract_id.split('.');\n const fakeId = `${getContractName(contract.contract_id)}-vars`;\n logger.debug(`Deploying ${contract.contract_id} for variables.`);\n\n if (!contract.source) {\n logger.debug(\n `Contract ${getContractName(contract.contract_id)} has no source. Skipping variables.`\n );\n return {};\n }\n\n if (contract.contract_interface.variables.length === 0) {\n logger.info(`Contract ${getContractName(contract.contract_id, false)} has no variables`);\n return {};\n }\n\n let varFn = '{\\n';\n\n const varLines = contract.contract_interface.variables.map(variable => {\n let varLine = `${variable.name}: `;\n if (variable.access === 'constant') {\n varLine += `${variable.name}`;\n } else {\n varLine += `(var-get ${variable.name})`;\n }\n return varLine;\n });\n varFn += varLines.map(l => ` ${l},`).join('\\n');\n\n varFn += '\\n}';\n\n const fullSrc = `${contract.source}\\n\\n${varFn}`;\n try {\n const receipt = simnet.deployContract(\n fakeId,\n fullSrc,\n {\n clarityVersion: clarityVersionForContract(contract),\n },\n deployer\n );\n const result = receipt.result;\n\n const varsAbi: Writeable<ClarityAbiTypeTuple> = {\n tuple: [],\n };\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n contract.contract_interface.variables.forEach(v => {\n const _v = v as unknown as Writeable<ClarityAbiVariable>;\n varsAbi.tuple.push({\n type: _v.type,\n name: _v.name,\n });\n });\n\n if (verbose) {\n // const cv = cvConvertHiro(result);\n // console.log('cv', cv);\n // console.log(esCvToValue(cvConvertHiro(result), true));\n logger.info(cvToValue(result, true));\n }\n\n // return esCvToValue(cvConvertHiro(result), true);\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return cvToValue(result, true);\n } catch (error) {\n logger.warn(\n { err: error },\n `Error getting variables for ${getContractName(contract.contract_id, false)}`\n );\n // logger.error(`Source code: ${contract.source} with type ${String(typeof contract.source)}`);\n // logger.error(fullSrc);\n return {};\n }\n}\n\ntype Writeable<T> = { -readonly [P in keyof T]: Writeable<T[P]> };\n\nexport function mapVariables(session: Session, simnet: Simnet) {\n return session.contracts.map(contract => {\n const vars = getVariablesV2(contract, simnet);\n return serialize(vars);\n });\n}\n","/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */\nimport { readFile } from 'node:fs/promises';\nimport { join, dirname, relative } from 'node:path';\nimport type { Config } from '../config';\nimport { parse } from 'yaml';\nimport {\n type Batch,\n getContractTxs,\n getDeploymentContract,\n getDeploymentTxPath,\n getIdentifierForDeploymentTx,\n type DeploymentTransaction,\n} from '@clarigen/core/deployment';\nimport type { DeploymentPlan, SimnetDeploymentPlan } from '@clarigen/core';\nimport { getContractName } from '@clarigen/core';\nimport { sortContracts } from '../utils';\nimport type { Session } from '../session';\nimport { spawn } from 'node:child_process';\nimport { logger } from '../logger';\n\nexport async function parseDeployment(path: string) {\n const contents = await readFile(path, 'utf-8');\n const parsed = parse(contents);\n return parsed as Plan;\n}\n\nexport const DEPLOYMENT_NETWORKS = ['devnet', 'simnet', 'testnet', 'mainnet'] as const;\nexport type DeploymentNetwork = (typeof DEPLOYMENT_NETWORKS)[number];\n\ntype Plan = DeploymentPlan | undefined;\ntype DeploymentsMap = {\n [key in DeploymentNetwork]: Plan;\n};\n\nexport async function getDeployments(config: Config): Promise<DeploymentsMap> {\n const entries = await Promise.all(\n DEPLOYMENT_NETWORKS.map(async network => {\n const file = `default.${network}-plan.yaml`;\n const path = join(dirname(config.clarinetFile()), 'deployments', file);\n let plan: Plan;\n try {\n plan = await parseDeployment(path);\n // biome-ignore lint/suspicious/noEmptyBlockStatements: ignored using `--suppress`\n } catch (_) {}\n return [network, plan] as [DeploymentNetwork, Plan];\n })\n );\n return Object.fromEntries(entries) as DeploymentsMap;\n}\n\nexport async function generateESMFile({\n baseFile,\n session,\n config,\n}: {\n baseFile: string;\n session: Session;\n config: Config;\n}) {\n const deployments = await getDeployments(config);\n const contractDeployments = collectContractDeployments(session, deployments, config);\n\n const simnet = generateSimnetCode(config, deployments, session);\n\n return `${baseFile}\nexport const deployments = ${JSON.stringify(contractDeployments)} as const;\n${simnet}\nexport const project = {\n contracts,\n deployments,\n} as const;\n `;\n}\n\nexport type ContractDeployments = {\n [key in DeploymentNetwork]: string | null;\n};\n\nexport type FullContractDeployments = {\n [contractName: string]: ContractDeployments;\n};\n\nfunction insertNetworkId(\n deployments: FullContractDeployments,\n identifier: string,\n network: DeploymentNetwork\n) {\n const name = getContractName(identifier);\n if (!deployments[name]) {\n // log.debug(`Not setting deployment ID for ${name} on ${network}`);\n return;\n }\n if (deployments[name][network] === null) {\n deployments[name][network] = identifier;\n }\n}\n\nexport function collectContractDeployments(\n session: Session,\n deployments: DeploymentsMap,\n config: Config\n): FullContractDeployments {\n const full = Object.fromEntries(\n sortContracts(session.contracts).map(contract => {\n const contractName = getContractName(contract.contract_id);\n const contractDeployments = Object.fromEntries(\n DEPLOYMENT_NETWORKS.map(network => {\n const deployment = deployments[network];\n if (typeof deployment === 'undefined') {\n return [network, null];\n }\n try {\n // biome-ignore lint/nursery/noShadow: ignored using `--suppress`\n const contractName = contract.contract_id.split('.')[1];\n const tx = getDeploymentContract(contractName, deployment);\n const id = getIdentifierForDeploymentTx(tx);\n return [network, id];\n } catch (_) {\n return [network, null];\n }\n })\n ) as ContractDeployments;\n return [contractName, contractDeployments];\n })\n ) as FullContractDeployments;\n\n const deployer = session.accounts.find(a => a.name === 'deployer');\n\n // handle defaults when there is no deployment file\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n config.clarinet.project.requirements?.forEach(({ contract_id }) => {\n insertNetworkId(full, contract_id, 'mainnet');\n const contractName = contract_id.split('.')[1];\n if (deployer) {\n const devnetId = `${deployer.address}.${contractName}`;\n insertNetworkId(full, devnetId, 'devnet');\n }\n });\n\n // biome-ignore lint/complexity/noForEach: ignored using `--suppress`\n session.contracts.forEach(contract => {\n insertNetworkId(full, contract.contract_id, 'devnet');\n insertNetworkId(full, contract.contract_id, 'simnet');\n });\n\n return full;\n}\n\nexport function collectDeploymentFiles(\n deployments: DeploymentsMap,\n clarinetFolder: string,\n cwd: string\n) {\n if (!deployments.simnet) return [];\n const simnet = deployments.simnet as SimnetDeploymentPlan;\n const txs = getContractTxs(simnet.plan.batches as Batch<DeploymentTransaction>[]);\n const entries = txs.map(tx => {\n const id = getIdentifierForDeploymentTx(tx);\n const contractFile = getDeploymentTxPath(tx);\n return {\n identifier: id,\n file: relative(cwd, join(clarinetFolder, contractFile)),\n };\n });\n return entries;\n}\n\nfunction generateSimnetCode(config: Config, deployments: DeploymentsMap, _session: Session) {\n if (!config.esm?.include_accounts) return '';\n\n const clarinetFolder = dirname(config.clarinetFile());\n\n const files = collectDeploymentFiles(deployments, clarinetFolder, config.cwd);\n // const accounts = generateAccountsCode(session);\n\n return `\nexport const simnetDeployment = ${JSON.stringify(files)};\n`;\n // ${accounts}\n\n // export const simnet = {\n // deployment: simnetDeployment,\n // accounts,\n // };\n}\n\n// biome-ignore lint/suspicious/useAwait: ignored using `--suppress`\nexport async function afterESM(config: Config): Promise<void> {\n const command = config.esm?.after;\n if (!command) return;\n logger.debug(`Running after ESM command: ${command}`);\n const parts = command.split(' ');\n const [cmd, ...args] = parts;\n return new Promise((resolve, reject) => {\n const child = spawn(cmd, args, {\n cwd: config.cwd,\n stdio: 'inherit',\n });\n child.on('error', reject);\n child.on('exit', code => {\n if (code === 0) {\n resolve();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C,GAAG;GAIzC,8BAAe,yBAAU,oEAHc,GAAG,CAGY,CAAC;GACxD;GACD;;AAIJ,SAAS,mBAAmB,QAAgB,aAA6B,UAAmB;;AAC1F,KAAI,iBAAC,OAAO,+DAAK,kBAAkB,QAAO;CAI1C,MAAM,QAAQ,uBAAuB,oCAFN,OAAO,cAAc,CAAC,EAEa,OAAO,IAAI;AAG7E,QAAO;kCACyB,KAAK,UAAU,MAAM,CAAC;;;AAWxD,eAAsB,SAAS,QAA+B;;CAC5D,MAAM,0BAAU,OAAO,iEAAK;AAC5B,KAAI,CAAC,QAAS;AACd,QAAO,MAAM,8BAA8B,UAAU;CAErD,MAAM,CAAC,KAAK,GAAG,QADD,QAAQ,MAAM,IAAI;AAEhC,QAAO,IAAI,SAAS,WAAS,WAAW;EACtC,MAAM,sCAAc,KAAK,MAAM;GAC7B,KAAK,OAAO;GACZ,OAAO;GACR,CAAC;AACF,QAAM,GAAG,SAAS,OAAO;AACzB,QAAM,GAAG,SAAQ,SAAQ;AACvB,OAAI,SAAS,EACX,YAAS;OAET,wBAAO,IAAI,MAAM,4BAA4B,QAAQ,YAAY,CAAC;IAEpE;GACF"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
const require_esm = require('./esm-
|
|
1
|
+
const require_esm = require('./esm-DPOm6Bdw.cjs');
|
|
2
2
|
|
|
3
3
|
exports.CONFIG_FILE = require_esm.CONFIG_FILE;
|
|
4
4
|
exports.ClarinetConfig = require_esm.ClarinetConfig;
|
|
5
5
|
exports.Config = require_esm.Config;
|
|
6
6
|
exports.ConfigFile = require_esm.ConfigFile;
|
|
7
7
|
exports.DEPLOYMENT_NETWORKS = require_esm.DEPLOYMENT_NETWORKS;
|
|
8
|
-
exports.FN_TYPES = require_esm.FN_TYPES;
|
|
9
8
|
exports.OutputType = require_esm.OutputType;
|
|
10
9
|
exports.TYPE_IMPORTS = require_esm.TYPE_IMPORTS;
|
|
11
|
-
exports.VAR_TYPES = require_esm.VAR_TYPES;
|
|
12
10
|
exports.abiArgType = require_esm.abiArgType;
|
|
13
11
|
exports.abiFunctionType = require_esm.abiFunctionType;
|
|
14
12
|
exports.afterDocs = require_esm.afterDocs;
|
|
@@ -16,7 +14,6 @@ exports.afterESM = require_esm.afterESM;
|
|
|
16
14
|
exports.collectContractDeployments = require_esm.collectContractDeployments;
|
|
17
15
|
exports.collectDeploymentFiles = require_esm.collectDeploymentFiles;
|
|
18
16
|
exports.configFilePath = require_esm.configFilePath;
|
|
19
|
-
exports.createContractDocInfo = require_esm.createContractDocInfo;
|
|
20
17
|
exports.cwdRelative = require_esm.cwdRelative;
|
|
21
18
|
exports.defaultConfigFile = require_esm.defaultConfigFile;
|
|
22
19
|
exports.encodeVariableName = require_esm.encodeVariableName;
|
|
@@ -32,16 +29,12 @@ exports.getArgName = require_esm.getArgName;
|
|
|
32
29
|
exports.getClarinetConfig = require_esm.getClarinetConfig;
|
|
33
30
|
exports.getConfig = require_esm.getConfig;
|
|
34
31
|
exports.getDeployments = require_esm.getDeployments;
|
|
35
|
-
exports.getFnName = require_esm.getFnName;
|
|
36
32
|
exports.getVariablesV2 = require_esm.getVariablesV2;
|
|
37
|
-
exports.isComment = require_esm.isComment;
|
|
38
33
|
exports.jsTypeFromAbiType = require_esm.jsTypeFromAbiType;
|
|
39
34
|
exports.mapVariables = require_esm.mapVariables;
|
|
40
35
|
exports.markdownFunction = require_esm.markdownFunction;
|
|
41
|
-
exports.parseComments = require_esm.parseComments;
|
|
42
36
|
exports.parseDeployment = require_esm.parseDeployment;
|
|
43
37
|
exports.saveConfig = require_esm.saveConfig;
|
|
44
38
|
exports.serialize = require_esm.serialize;
|
|
45
39
|
exports.sortContracts = require_esm.sortContracts;
|
|
46
|
-
exports.traceParens = require_esm.traceParens;
|
|
47
40
|
exports.writeFile = require_esm.writeFile;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
1
|
+
import { ClarityAbi, ClarityAbiArg, ClarityAbiFunction, ClarityAbiType, ClarityAbiVariable, DeploymentPlan } from "@clarigen/core";
|
|
2
|
+
import { ClaridocFunction } from "@clarigen/docs";
|
|
3
3
|
import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
|
|
4
4
|
import { Simnet } from "@stacks/clarinet-sdk";
|
|
5
|
-
import { InspectOptions } from "util";
|
|
5
|
+
import { InspectOptions } from "node:util";
|
|
6
6
|
|
|
7
7
|
//#region src/session.d.ts
|
|
8
|
-
|
|
8
|
+
type SessionContract = {
|
|
9
9
|
contract_id: string;
|
|
10
10
|
contract_interface: ClarityAbi;
|
|
11
11
|
source: string;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
type EpochType = ClarityAbi;
|
|
14
14
|
type SessionAccount = {
|
|
15
15
|
address: string;
|
|
16
16
|
balance: string;
|
|
17
17
|
name: string;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type Session = {
|
|
20
20
|
session_id: number;
|
|
21
21
|
accounts: SessionAccount[];
|
|
22
22
|
contracts: SessionContract[];
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
interface SessionWithVariables extends Session {
|
|
25
25
|
variables: string[];
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
+
//#region src/docs/markdown.d.ts
|
|
29
|
+
declare function generateMarkdown({
|
|
30
|
+
contract,
|
|
31
|
+
contractFile,
|
|
32
|
+
withToc
|
|
33
|
+
}: {
|
|
34
|
+
contract: SessionContract;
|
|
35
|
+
contractFile?: string;
|
|
36
|
+
withToc?: boolean;
|
|
37
|
+
}): string;
|
|
38
|
+
declare function markdownFunction(fn: ClaridocFunction, contractFile?: string): string;
|
|
39
|
+
declare function generateReadme(session: Session, excluded: Record<string, boolean>): string;
|
|
40
|
+
//#endregion
|
|
28
41
|
//#region src/clarinet-config.d.ts
|
|
29
42
|
declare const ClarinetConfig: arktype_internal_variants_object_ts0.ObjectType<{
|
|
30
43
|
project: {
|
|
@@ -123,64 +136,8 @@ declare function saveConfig(config: ConfigFile): Promise<void>;
|
|
|
123
136
|
declare function getConfig(cwd?: string): Promise<ConfigFile>;
|
|
124
137
|
//#endregion
|
|
125
138
|
//#region src/docs/index.d.ts
|
|
126
|
-
declare const FN_TYPES: readonly ["read-only", "public", "private"];
|
|
127
|
-
declare const VAR_TYPES: readonly ["map", "data-var", "constant"];
|
|
128
|
-
type ClarityAbiItem = ClarityAbiFunction | ClarityAbiMap | ClarityAbiVariable;
|
|
129
|
-
type ClaridocItemType<T extends ClarityAbiItem> = {
|
|
130
|
-
abi: T;
|
|
131
|
-
comments: Comments;
|
|
132
|
-
startLine: number;
|
|
133
|
-
source: string[];
|
|
134
|
-
};
|
|
135
|
-
type ClaridocFunction = ClaridocItemType<ClarityAbiFunction>;
|
|
136
|
-
type ClaridocMap = ClaridocItemType<ClarityAbiMap>;
|
|
137
|
-
type ClaridocVariable = ClaridocItemType<ClarityAbiVariable>;
|
|
138
|
-
interface ClaridocItem {
|
|
139
|
-
abi: ClarityAbiItem;
|
|
140
|
-
comments: Comments;
|
|
141
|
-
startLine: number;
|
|
142
|
-
source: string[];
|
|
143
|
-
}
|
|
144
|
-
interface Comments {
|
|
145
|
-
params: Record<string, ClaridocParam>;
|
|
146
|
-
text: string[];
|
|
147
|
-
}
|
|
148
|
-
interface ClaridocContract {
|
|
149
|
-
functions: ClaridocFunction[];
|
|
150
|
-
maps: ClaridocMap[];
|
|
151
|
-
variables: ClaridocVariable[];
|
|
152
|
-
comments: string[];
|
|
153
|
-
}
|
|
154
|
-
interface ClaridocParam {
|
|
155
|
-
abi: ClarityAbiArg;
|
|
156
|
-
comments: string[];
|
|
157
|
-
}
|
|
158
|
-
declare function createContractDocInfo({
|
|
159
|
-
contractSrc,
|
|
160
|
-
abi
|
|
161
|
-
}: {
|
|
162
|
-
contractSrc: string;
|
|
163
|
-
abi: ClarityAbi;
|
|
164
|
-
}): ClaridocContract;
|
|
165
|
-
declare function isComment(line: string): boolean;
|
|
166
|
-
declare function getFnName(line: string): string | undefined;
|
|
167
|
-
declare function traceParens(line: string, count: number): number;
|
|
168
|
-
declare function parseComments(comments: string[], abi: ClarityAbiItem): Comments;
|
|
169
139
|
declare function afterDocs(config: Config): Promise<void>;
|
|
170
140
|
//#endregion
|
|
171
|
-
//#region src/docs/markdown.d.ts
|
|
172
|
-
declare function generateMarkdown({
|
|
173
|
-
contract,
|
|
174
|
-
contractFile,
|
|
175
|
-
withToc
|
|
176
|
-
}: {
|
|
177
|
-
contract: SessionContract;
|
|
178
|
-
contractFile?: string;
|
|
179
|
-
withToc?: boolean;
|
|
180
|
-
}): string;
|
|
181
|
-
declare function markdownFunction(fn: ClaridocFunction, contractFile?: string): string;
|
|
182
|
-
declare function generateReadme(session: Session, excluded: Record<string, boolean>): string;
|
|
183
|
-
//#endregion
|
|
184
141
|
//#region src/files/docs.d.ts
|
|
185
142
|
declare function generateDocs({
|
|
186
143
|
session,
|
|
@@ -248,5 +205,5 @@ declare function sortContracts<T extends {
|
|
|
248
205
|
contract_id: string;
|
|
249
206
|
}>(contracts: T[]): T[];
|
|
250
207
|
//#endregion
|
|
251
|
-
export { CONFIG_FILE,
|
|
208
|
+
export { CONFIG_FILE, ClarinetConfig, Config, ConfigFile, ContractDeployments, DEPLOYMENT_NETWORKS, DeploymentNetwork, EpochType, FullContractDeployments, OutputType, Session, SessionAccount, SessionContract, SessionWithVariables, TYPE_IMPORTS, abiArgType, abiFunctionType, afterDocs, afterESM, collectContractDeployments, collectDeploymentFiles, configFilePath, cwdRelative, defaultConfigFile, encodeVariableName, encodeVariables, fileExists, generateBaseFile, generateContractMeta, generateDocs, generateESMFile, generateMarkdown, generateReadme, getArgName, getClarinetConfig, getConfig, getDeployments, getVariablesV2, jsTypeFromAbiType, mapVariables, markdownFunction, parseDeployment, saveConfig, serialize, sortContracts, writeFile };
|
|
252
209
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,30 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { InspectOptions } from "util";
|
|
1
|
+
import { ClarityAbi, ClarityAbiArg, ClarityAbiFunction, ClarityAbiType, ClarityAbiVariable, DeploymentPlan } from "@clarigen/core";
|
|
2
|
+
import { ClaridocFunction } from "@clarigen/docs";
|
|
3
|
+
import { InspectOptions, inspect } from "node:util";
|
|
4
4
|
import { Simnet } from "@stacks/clarinet-sdk";
|
|
5
5
|
import * as arktype_internal_variants_object_ts0 from "arktype/internal/variants/object.ts";
|
|
6
6
|
|
|
7
7
|
//#region src/session.d.ts
|
|
8
|
-
|
|
8
|
+
type SessionContract = {
|
|
9
9
|
contract_id: string;
|
|
10
10
|
contract_interface: ClarityAbi;
|
|
11
11
|
source: string;
|
|
12
|
-
}
|
|
12
|
+
};
|
|
13
13
|
type EpochType = ClarityAbi;
|
|
14
14
|
type SessionAccount = {
|
|
15
15
|
address: string;
|
|
16
16
|
balance: string;
|
|
17
17
|
name: string;
|
|
18
18
|
};
|
|
19
|
-
|
|
19
|
+
type Session = {
|
|
20
20
|
session_id: number;
|
|
21
21
|
accounts: SessionAccount[];
|
|
22
22
|
contracts: SessionContract[];
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
24
|
interface SessionWithVariables extends Session {
|
|
25
25
|
variables: string[];
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
+
//#region src/docs/markdown.d.ts
|
|
29
|
+
declare function generateMarkdown({
|
|
30
|
+
contract,
|
|
31
|
+
contractFile,
|
|
32
|
+
withToc
|
|
33
|
+
}: {
|
|
34
|
+
contract: SessionContract;
|
|
35
|
+
contractFile?: string;
|
|
36
|
+
withToc?: boolean;
|
|
37
|
+
}): string;
|
|
38
|
+
declare function markdownFunction(fn: ClaridocFunction, contractFile?: string): string;
|
|
39
|
+
declare function generateReadme(session: Session, excluded: Record<string, boolean>): string;
|
|
40
|
+
//#endregion
|
|
28
41
|
//#region src/clarinet-config.d.ts
|
|
29
42
|
declare const ClarinetConfig: arktype_internal_variants_object_ts0.ObjectType<{
|
|
30
43
|
project: {
|
|
@@ -123,64 +136,8 @@ declare function saveConfig(config: ConfigFile): Promise<void>;
|
|
|
123
136
|
declare function getConfig(cwd?: string): Promise<ConfigFile>;
|
|
124
137
|
//#endregion
|
|
125
138
|
//#region src/docs/index.d.ts
|
|
126
|
-
declare const FN_TYPES: readonly ["read-only", "public", "private"];
|
|
127
|
-
declare const VAR_TYPES: readonly ["map", "data-var", "constant"];
|
|
128
|
-
type ClarityAbiItem = ClarityAbiFunction | ClarityAbiMap | ClarityAbiVariable;
|
|
129
|
-
type ClaridocItemType<T extends ClarityAbiItem> = {
|
|
130
|
-
abi: T;
|
|
131
|
-
comments: Comments;
|
|
132
|
-
startLine: number;
|
|
133
|
-
source: string[];
|
|
134
|
-
};
|
|
135
|
-
type ClaridocFunction = ClaridocItemType<ClarityAbiFunction>;
|
|
136
|
-
type ClaridocMap = ClaridocItemType<ClarityAbiMap>;
|
|
137
|
-
type ClaridocVariable = ClaridocItemType<ClarityAbiVariable>;
|
|
138
|
-
interface ClaridocItem {
|
|
139
|
-
abi: ClarityAbiItem;
|
|
140
|
-
comments: Comments;
|
|
141
|
-
startLine: number;
|
|
142
|
-
source: string[];
|
|
143
|
-
}
|
|
144
|
-
interface Comments {
|
|
145
|
-
params: Record<string, ClaridocParam>;
|
|
146
|
-
text: string[];
|
|
147
|
-
}
|
|
148
|
-
interface ClaridocContract {
|
|
149
|
-
functions: ClaridocFunction[];
|
|
150
|
-
maps: ClaridocMap[];
|
|
151
|
-
variables: ClaridocVariable[];
|
|
152
|
-
comments: string[];
|
|
153
|
-
}
|
|
154
|
-
interface ClaridocParam {
|
|
155
|
-
abi: ClarityAbiArg;
|
|
156
|
-
comments: string[];
|
|
157
|
-
}
|
|
158
|
-
declare function createContractDocInfo({
|
|
159
|
-
contractSrc,
|
|
160
|
-
abi
|
|
161
|
-
}: {
|
|
162
|
-
contractSrc: string;
|
|
163
|
-
abi: ClarityAbi;
|
|
164
|
-
}): ClaridocContract;
|
|
165
|
-
declare function isComment(line: string): boolean;
|
|
166
|
-
declare function getFnName(line: string): string | undefined;
|
|
167
|
-
declare function traceParens(line: string, count: number): number;
|
|
168
|
-
declare function parseComments(comments: string[], abi: ClarityAbiItem): Comments;
|
|
169
139
|
declare function afterDocs(config: Config): Promise<void>;
|
|
170
140
|
//#endregion
|
|
171
|
-
//#region src/docs/markdown.d.ts
|
|
172
|
-
declare function generateMarkdown({
|
|
173
|
-
contract,
|
|
174
|
-
contractFile,
|
|
175
|
-
withToc
|
|
176
|
-
}: {
|
|
177
|
-
contract: SessionContract;
|
|
178
|
-
contractFile?: string;
|
|
179
|
-
withToc?: boolean;
|
|
180
|
-
}): string;
|
|
181
|
-
declare function markdownFunction(fn: ClaridocFunction, contractFile?: string): string;
|
|
182
|
-
declare function generateReadme(session: Session, excluded: Record<string, boolean>): string;
|
|
183
|
-
//#endregion
|
|
184
141
|
//#region src/files/docs.d.ts
|
|
185
142
|
declare function generateDocs({
|
|
186
143
|
session,
|
|
@@ -248,5 +205,5 @@ declare function sortContracts<T extends {
|
|
|
248
205
|
contract_id: string;
|
|
249
206
|
}>(contracts: T[]): T[];
|
|
250
207
|
//#endregion
|
|
251
|
-
export { CONFIG_FILE,
|
|
208
|
+
export { CONFIG_FILE, ClarinetConfig, Config, ConfigFile, ContractDeployments, DEPLOYMENT_NETWORKS, DeploymentNetwork, EpochType, FullContractDeployments, OutputType, Session, SessionAccount, SessionContract, SessionWithVariables, TYPE_IMPORTS, abiArgType, abiFunctionType, afterDocs, afterESM, collectContractDeployments, collectDeploymentFiles, configFilePath, cwdRelative, defaultConfigFile, encodeVariableName, encodeVariables, fileExists, generateBaseFile, generateContractMeta, generateDocs, generateESMFile, generateMarkdown, generateReadme, getArgName, getClarinetConfig, getConfig, getDeployments, getVariablesV2, jsTypeFromAbiType, mapVariables, markdownFunction, parseDeployment, saveConfig, serialize, sortContracts, writeFile };
|
|
252
209
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as afterDocs, C as OutputType, D as saveConfig, E as getConfig, F as cwdRelative, I as encodeVariableName, L as fileExists, M as generateMarkdown, N as generateReadme, O as ClarinetConfig, P as markdownFunction, R as sortContracts, S as ConfigFile, T as defaultConfigFile, _ as getArgName, a as generateESMFile, b as CONFIG_FILE, c as getVariablesV2, d as encodeVariables, f as generateBaseFile, g as abiFunctionType, h as abiArgType, i as collectDeploymentFiles, k as getClarinetConfig, l as mapVariables, m as serialize, n as afterESM, o as getDeployments, p as generateContractMeta, r as collectContractDeployments, s as parseDeployment, t as DEPLOYMENT_NETWORKS, u as TYPE_IMPORTS, v as jsTypeFromAbiType, w as configFilePath, x as Config, y as generateDocs, z as writeFile } from "./esm-BjGH_MkS.mjs";
|
|
2
2
|
|
|
3
|
-
export { CONFIG_FILE, ClarinetConfig, Config, ConfigFile, DEPLOYMENT_NETWORKS,
|
|
3
|
+
export { CONFIG_FILE, ClarinetConfig, Config, ConfigFile, DEPLOYMENT_NETWORKS, OutputType, TYPE_IMPORTS, abiArgType, abiFunctionType, afterDocs, afterESM, collectContractDeployments, collectDeploymentFiles, configFilePath, cwdRelative, defaultConfigFile, encodeVariableName, encodeVariables, fileExists, generateBaseFile, generateContractMeta, generateDocs, generateESMFile, generateMarkdown, generateReadme, getArgName, getClarinetConfig, getConfig, getDeployments, getVariablesV2, jsTypeFromAbiType, mapVariables, markdownFunction, parseDeployment, saveConfig, serialize, sortContracts, writeFile };
|
package/dist/run-cli.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_esm = require('./esm-
|
|
2
|
+
const require_esm = require('./esm-DPOm6Bdw.cjs');
|
|
3
3
|
let __clarigen_core = require("@clarigen/core");
|
|
4
|
-
let
|
|
4
|
+
let node_path = require("node:path");
|
|
5
|
+
let node_fs_promises = require("node:fs/promises");
|
|
5
6
|
let arktype = require("arktype");
|
|
6
7
|
let clipanion = require("clipanion");
|
|
7
8
|
let __stacks_clarinet_sdk = require("@stacks/clarinet-sdk");
|
|
8
9
|
let chokidar = require("chokidar");
|
|
9
10
|
chokidar = require_esm.__toESM(chokidar);
|
|
10
|
-
let node_path = require("node:path");
|
|
11
11
|
|
|
12
12
|
//#region src/commands/base-command.ts
|
|
13
13
|
var BaseCommand = class extends clipanion.Command {
|
|
@@ -28,6 +28,7 @@ var BaseCommand = class extends clipanion.Command {
|
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/commands/session-info.ts
|
|
31
|
+
/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */
|
|
31
32
|
var SessionInfoCommand = class extends BaseCommand {
|
|
32
33
|
static paths = [["session-info"]];
|
|
33
34
|
static usage = clipanion.Command.Usage({ description: "Log info about this project's Clarinet session" });
|
|
@@ -41,6 +42,7 @@ var SessionInfoCommand = class extends BaseCommand {
|
|
|
41
42
|
|
|
42
43
|
//#endregion
|
|
43
44
|
//#region src/clarinet-sdk.ts
|
|
45
|
+
/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */
|
|
44
46
|
async function getSession(config) {
|
|
45
47
|
const simnet = await (0, __stacks_clarinet_sdk.initSimnet)(config.clarinetFile(), true);
|
|
46
48
|
const interfaces = simnet.getContractsInterfaces();
|
|
@@ -59,7 +61,7 @@ async function getSession(config) {
|
|
|
59
61
|
const name = (0, __clarigen_core.getContractName)(contract_id, false);
|
|
60
62
|
const contractPathDef = (_config$clarinet$cont = config.clarinet.contracts) === null || _config$clarinet$cont === void 0 || (_config$clarinet$cont = _config$clarinet$cont[name]) === null || _config$clarinet$cont === void 0 ? void 0 : _config$clarinet$cont.path;
|
|
61
63
|
let source;
|
|
62
|
-
if (contractPathDef) source = await (0,
|
|
64
|
+
if (contractPathDef) source = await (0, node_fs_promises.readFile)(config.joinFromClarinet(contractPathDef), "utf-8");
|
|
63
65
|
return {
|
|
64
66
|
contract_id,
|
|
65
67
|
contract_interface: {
|
|
@@ -84,6 +86,7 @@ async function getSession(config) {
|
|
|
84
86
|
|
|
85
87
|
//#endregion
|
|
86
88
|
//#region src/commands/default-command.ts
|
|
89
|
+
/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */
|
|
87
90
|
async function generate(config) {
|
|
88
91
|
const session = await getSession(config);
|
|
89
92
|
const baseFile = require_esm.generateBaseFile(session);
|
|
@@ -100,7 +103,7 @@ async function generate(config) {
|
|
|
100
103
|
require_esm.logger.info("Types generated!");
|
|
101
104
|
}
|
|
102
105
|
async function watch$1(config, cwd) {
|
|
103
|
-
return new Promise(async (
|
|
106
|
+
return new Promise(async (_resolve, _reject) => {
|
|
104
107
|
var _config$esm;
|
|
105
108
|
try {
|
|
106
109
|
await generate(config);
|
|
@@ -165,52 +168,51 @@ var DefaultCommand = class extends BaseCommand {
|
|
|
165
168
|
|
|
166
169
|
//#endregion
|
|
167
170
|
//#region src/commands/docs-command.ts
|
|
171
|
+
/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */
|
|
168
172
|
async function watch(config, cwd) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
173
|
+
var _config$esm;
|
|
174
|
+
const session = await getSession(config);
|
|
175
|
+
try {
|
|
176
|
+
await require_esm.generateDocs({
|
|
177
|
+
session,
|
|
178
|
+
config
|
|
179
|
+
});
|
|
180
|
+
} catch (error) {
|
|
181
|
+
require_esm.logger.error({ error }, "Error generating types");
|
|
182
|
+
}
|
|
183
|
+
const clarinetFolder = (0, node_path.dirname)(config.clarinetFile());
|
|
184
|
+
const contractsFolder = (0, node_path.join)(clarinetFolder, "/contracts/**/*.clar");
|
|
185
|
+
const relativeFolder = (0, node_path.relative)(cwd || process.cwd(), contractsFolder);
|
|
186
|
+
const watchFolders = ((_config$esm = config.esm) === null || _config$esm === void 0 ? void 0 : _config$esm.watch_folders) ?? [];
|
|
187
|
+
watchFolders.push(relativeFolder);
|
|
188
|
+
require_esm.logger.info(`Watching for changes in ${watchFolders}`);
|
|
189
|
+
const watcher = chokidar.default.watch(watchFolders, {
|
|
190
|
+
persistent: true,
|
|
191
|
+
cwd: clarinetFolder
|
|
192
|
+
});
|
|
193
|
+
let running = false;
|
|
194
|
+
let start = 0;
|
|
195
|
+
require_esm.logger.level;
|
|
196
|
+
watcher.on("change", async (path) => {
|
|
197
|
+
if (!running) {
|
|
198
|
+
start = Date.now();
|
|
199
|
+
require_esm.logger.info(`File ${path} has been changed. Generating types.`);
|
|
200
|
+
running = true;
|
|
201
|
+
require_esm.generateDocs({
|
|
202
|
+
session: await getSession(config),
|
|
175
203
|
config
|
|
204
|
+
}).catch((e) => {
|
|
205
|
+
require_esm.logger.error({ error: e }, "Error generating types");
|
|
206
|
+
}).then(() => {
|
|
207
|
+
setTimeout(() => {
|
|
208
|
+
process.stdout.moveCursor(0, -1);
|
|
209
|
+
process.stdout.clearLine(1);
|
|
210
|
+
const elapsed = Date.now() - start;
|
|
211
|
+
require_esm.logger.info(`Docs generated (${(elapsed / 1e3).toFixed(2)}s). Watching for changes...`);
|
|
212
|
+
running = false;
|
|
213
|
+
});
|
|
176
214
|
});
|
|
177
|
-
} catch (error) {
|
|
178
|
-
require_esm.logger.error({ error }, "Error generating types");
|
|
179
215
|
}
|
|
180
|
-
const clarinetFolder = (0, node_path.dirname)(config.clarinetFile());
|
|
181
|
-
const contractsFolder = (0, node_path.join)(clarinetFolder, "/contracts/**/*.clar");
|
|
182
|
-
const relativeFolder = (0, node_path.relative)(cwd || process.cwd(), contractsFolder);
|
|
183
|
-
const watchFolders = ((_config$esm = config.esm) === null || _config$esm === void 0 ? void 0 : _config$esm.watch_folders) ?? [];
|
|
184
|
-
watchFolders.push(relativeFolder);
|
|
185
|
-
require_esm.logger.info(`Watching for changes in ${watchFolders}`);
|
|
186
|
-
const watcher = chokidar.default.watch(watchFolders, {
|
|
187
|
-
persistent: true,
|
|
188
|
-
cwd: clarinetFolder
|
|
189
|
-
});
|
|
190
|
-
let running = false;
|
|
191
|
-
let start = 0;
|
|
192
|
-
require_esm.logger.level;
|
|
193
|
-
watcher.on("change", async (path) => {
|
|
194
|
-
if (!running) {
|
|
195
|
-
start = Date.now();
|
|
196
|
-
require_esm.logger.info(`File ${path} has been changed. Generating types.`);
|
|
197
|
-
running = true;
|
|
198
|
-
require_esm.generateDocs({
|
|
199
|
-
session: await getSession(config),
|
|
200
|
-
config
|
|
201
|
-
}).catch((e) => {
|
|
202
|
-
require_esm.logger.error({ error: e }, "Error generating types");
|
|
203
|
-
}).then(() => {
|
|
204
|
-
setTimeout(() => {
|
|
205
|
-
process.stdout.moveCursor(0, -1);
|
|
206
|
-
process.stdout.clearLine(1);
|
|
207
|
-
const elapsed = Date.now() - start;
|
|
208
|
-
require_esm.logger.info(`Docs generated (${(elapsed / 1e3).toFixed(2)}s). Watching for changes...`);
|
|
209
|
-
running = false;
|
|
210
|
-
});
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
});
|
|
214
216
|
});
|
|
215
217
|
}
|
|
216
218
|
var DocsCommand = class extends BaseCommand {
|
|
@@ -271,6 +273,7 @@ output = "docs"
|
|
|
271
273
|
|
|
272
274
|
//#endregion
|
|
273
275
|
//#region src/commands/init-config-command.ts
|
|
276
|
+
/** biome-ignore-all lint/style/useTrimStartEnd: suppressed */
|
|
274
277
|
var InitConfigCommand = class extends BaseCommand {
|
|
275
278
|
static paths = [["init-config"], ["init"]];
|
|
276
279
|
static usage = { description: "Initialize a Clarigen configuration file" };
|
|
@@ -284,17 +287,17 @@ var InitConfigCommand = class extends BaseCommand {
|
|
|
284
287
|
return 1;
|
|
285
288
|
}
|
|
286
289
|
require_esm.logger.debug(`Writing configuration file to ${path}`);
|
|
287
|
-
await (0,
|
|
290
|
+
await (0, node_fs_promises.writeFile)(path, tomlInit, "utf-8");
|
|
288
291
|
}
|
|
289
292
|
};
|
|
290
293
|
|
|
291
294
|
//#endregion
|
|
292
295
|
//#region src/generated/version.ts
|
|
293
|
-
const version = "4.0.2-alpha.
|
|
296
|
+
const version = "4.0.2-alpha.1";
|
|
294
297
|
|
|
295
298
|
//#endregion
|
|
296
299
|
//#region src/run-cli.ts
|
|
297
|
-
const [
|
|
300
|
+
const [_node, _script, ...args] = process.argv;
|
|
298
301
|
const cli = new clipanion.Cli({
|
|
299
302
|
binaryLabel: "Clarigen",
|
|
300
303
|
binaryName: "clarigen",
|