@twin.org/cli-core 0.9.2-next.8 → 0.9.2
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/es/cliDisplay.js.map +1 -1
- package/docs/changelog.md +76 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cliDisplay.js","sourceRoot":"","sources":["../../src/cliDisplay.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;;OAGG;IACK,MAAM,CAAC,kBAAkB,CAAsC;IAEvE;;;OAGG;IACI,MAAM,CAAC,KAAK,GAA0C,MAAM,CAAC,EAAE,CACrE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;;OAGG;IACI,MAAM,CAAC,UAAU,GAA0C,MAAM,CAAC,EAAE,CAC1E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACI,MAAM,CAAC,SAAS,GAAe,GAAG,EAAE;QAC1C,SAAS,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QAC7B,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAC7B,CAAC,CAAC;IAEF;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,KAAa,EAAE,OAAe,EAAE,IAAY;QAChE,MAAM,YAAY,GAAG,GAAG,KAAK,KAAK,OAAO,EAAE,CAAC;QAC5C,UAAU,CAAC,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ACjB,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACxB,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC;QAClF,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACI,MAAM,CAAC,YAAY,CACzB,cAAsB,yBAAyB,EAC/C,oBAA8B,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAChF,WAAmB,GAAG;QAEtB,IAAI,YAAY,GAAG,CAAC,CAAC;QACrB,IAAI,UAAU,CAAC,kBAAkB,EAAE,CAAC;YACnC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;QAC9C,CAAC;QACD,UAAU,CAAC,kBAAkB,GAAG,WAAW,CAAC,GAAG,EAAE;YAChD,UAAU,CAAC,SAAS,EAAE,CAAC;YACvB,UAAU,CAAC,KAAK,CACf,GAAG,iBAAiB,CAAC,YAAY,EAAE,GAAG,iBAAiB,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,EAAE,CACpG,CAAC;QACH,CAAC,EAAE,QAAQ,CAAC,CAAC;IACd,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,WAAW;QACxB,IAAI,UAAU,CAAC,kBAAkB,EAAE,CAAC;YACnC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;YAC7C,UAAU,CAAC,kBAAkB,GAAG,SAAS,CAAC;QAC3C,CAAC;QACD,UAAU,CAAC,SAAS,EAAE,CAAC;IACxB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { clearLine, cursorTo } from \"node:readline\";\nimport { inspect } from \"node:util\";\nimport { Coerce, ErrorHelper, I18n, Is } from \"@twin.org/core\";\nimport chalk from \"chalk\";\n\n/**\n * Display utilities for the CLI.\n */\nexport class CLIDisplay {\n\t/**\n\t * The interval ID for the spinner.\n\t * @internal\n\t */\n\tprivate static _spinnerIntervalId: NodeJS.Timeout | number | undefined;\n\n\t/**\n\t * The default output method for writing standard messages.\n\t * @param buffer The message to output.\n\t */\n\tpublic static write: (buffer: string | Uint8Array) => void = buffer =>\n\t\tprocess.stdout.write(buffer);\n\n\t/**\n\t * The default output method for writing error messages.\n\t * @param buffer The message to output.\n\t */\n\tpublic static writeError: (buffer: string | Uint8Array) => void = buffer =>\n\t\tprocess.stderr.write(buffer);\n\n\t/**\n\t * The default output method for clearing the current line.\n\t */\n\tpublic static clearLine: () => void = () => {\n\t\tclearLine(process.stdout, 0);\n\t\tcursorTo(process.stdout, 0);\n\t};\n\n\t/**\n\t * Display the header for the CLI.\n\t * @param title The title of the CLI.\n\t * @param version The version of the CLI.\n\t * @param icon The icon for the CLI.\n\t */\n\tpublic static header(title: string, version: string, icon: string): void {\n\t\tconst titleVersion = `${title} v${version}`;\n\t\tCLIDisplay.write(`${icon} ${chalk.underline.bold.blue(titleVersion)}\\n`);\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display an error message.\n\t * @param error The error to display.\n\t * @param lineBreaks Whether to add a line break after the error.\n\t * @param options Options for formatting the error.\n\t * @param options.includeStack Whether to include the stack trace in the output, defaults to false.\n\t * @param options.includeAdditional Whether to include additional error information in the output, defaults to false.\n\t */\n\tpublic static error(\n\t\terror: unknown,\n\t\tlineBreaks: boolean = true,\n\t\toptions: { includeStack?: boolean; includeAdditional?: boolean } = {}\n\t): void {\n\t\tCLIDisplay.writeError(\"❗ \");\n\t\tCLIDisplay.writeError(chalk.red(I18n.formatMessage(\"cli.progress.error\")));\n\t\tif (lineBreaks) {\n\t\t\tCLIDisplay.writeError(\"\\n\");\n\t\t}\n\n\t\tconst formatted = ErrorHelper.localizeErrors(error);\n\t\tCLIDisplay.writeError(chalk.red(formatted.map(e => `\\t${e.message}`).join(\"\\n\")));\n\n\t\tif (options.includeAdditional) {\n\t\t\tfor (const err of formatted) {\n\t\t\t\tif (Is.arrayValue(err.additional)) {\n\t\t\t\t\tCLIDisplay.writeError(chalk.red(`\\n\\t\\t${err.additional.join(\"\\n\\t\\t\")}\\n`));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (options.includeStack) {\n\t\t\tCLIDisplay.writeError(\"\\n\");\n\t\t\tCLIDisplay.writeError(\"\\n-----DEBUG STACK START-----\\n\\n\");\n\t\t\tfor (const err of formatted) {\n\t\t\t\tif (Is.stringValue(err.stack)) {\n\t\t\t\t\tCLIDisplay.writeError(`${err.stack}\\n`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tCLIDisplay.writeError(\"\\n-----DEBUG STACK END-----\\n\");\n\t\t}\n\n\t\tif (lineBreaks) {\n\t\t\tCLIDisplay.writeError(\"\\n\");\n\t\t}\n\t}\n\n\t/**\n\t * Display an error message in simple form.\n\t * @param error The error to display.\n\t */\n\tpublic static errorMessage(error: string): void {\n\t\tCLIDisplay.writeError(\"❗ \");\n\t\tCLIDisplay.writeError(chalk.red(error));\n\t\tCLIDisplay.writeError(\"\\n\");\n\t}\n\n\t/**\n\t * Display a section.\n\t * @param label The label for the section.\n\t */\n\tpublic static section(label: string): void {\n\t\tCLIDisplay.write(chalk.hex(\"#FFA500\").bold.underline(label));\n\t\tCLIDisplay.write(\"\\n\\n\");\n\t}\n\n\t/**\n\t * Display a value with a label.\n\t * @param label The label for the value.\n\t * @param value The value to display.\n\t * @param indentLevel The level of indentation.\n\t */\n\tpublic static value(label: string, value: unknown, indentLevel: number = 0): void {\n\t\tCLIDisplay.write(\"\\t\".repeat(indentLevel));\n\t\tif (Is.stringValue(label)) {\n\t\t\tCLIDisplay.write(chalk.hex(\"#FFA500\").bold(`${label}: `));\n\t\t}\n\t\tCLIDisplay.write(Coerce.string(value) ?? \"\");\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display a task with a label.\n\t * @param label The label for the value.\n\t * @param task The task to display.\n\t */\n\tpublic static task(label: string, task?: string): void {\n\t\tCLIDisplay.write(\"➡️ \");\n\t\tif (Is.empty(task)) {\n\t\t\tCLIDisplay.write(chalk.cyan(label));\n\t\t} else {\n\t\t\tCLIDisplay.write(chalk.cyan(`${label}: `));\n\t\t\tCLIDisplay.write(task);\n\t\t}\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display a break.\n\t */\n\tpublic static break(): void {\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display formatted and colorized JSON.\n\t * @param obj The object to display.\n\t */\n\tpublic static json(obj: unknown): void {\n\t\tCLIDisplay.write(inspect(obj, false, null, true));\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display a warning.\n\t * @param label The label for the warning.\n\t */\n\tpublic static warning(label: string): void {\n\t\tCLIDisplay.write(\"⚠️ \");\n\t\tCLIDisplay.write(chalk.hex(\"#FFA500\").bold(label));\n\t\tCLIDisplay.write(\"\\n\\n\");\n\t}\n\n\t/**\n\t * Display the processing is done.\n\t */\n\tpublic static done(): void {\n\t\tCLIDisplay.write(\"🎉 \");\n\t\tCLIDisplay.write(chalk.greenBright.bold(I18n.formatMessage(\"cli.progress.done\")));\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Start the spinner.\n\t * @param i18nMessage The message to display with the spinner.\n\t * @param spinnerCharacters The characters to use in the spinner.\n\t * @param interval The interval for the spinner.\n\t */\n\tpublic static spinnerStart(\n\t\ti18nMessage: string = \"cli.progress.pleaseWait\",\n\t\tspinnerCharacters: string[] = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"],\n\t\tinterval: number = 100\n\t): void {\n\t\tlet spinnerIndex = 0;\n\t\tif (CLIDisplay._spinnerIntervalId) {\n\t\t\tclearInterval(CLIDisplay._spinnerIntervalId);\n\t\t}\n\t\tCLIDisplay._spinnerIntervalId = setInterval(() => {\n\t\t\tCLIDisplay.clearLine();\n\t\t\tCLIDisplay.write(\n\t\t\t\t`${spinnerCharacters[spinnerIndex++ % spinnerCharacters.length]} ${I18n.formatMessage(i18nMessage)}`\n\t\t\t);\n\t\t}, interval);\n\t}\n\n\t/**\n\t * Stop the spinner.\n\t */\n\tpublic static spinnerStop(): void {\n\t\tif (CLIDisplay._spinnerIntervalId) {\n\t\t\tclearInterval(CLIDisplay._spinnerIntervalId);\n\t\t\tCLIDisplay._spinnerIntervalId = undefined;\n\t\t}\n\t\tCLIDisplay.clearLine();\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cliDisplay.js","sourceRoot":"","sources":["../../src/cliDisplay.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B;;GAEG;AACH,MAAM,OAAO,UAAU;IACtB;;;OAGG;IACK,MAAM,CAAC,kBAAkB,CAAqD;IAEtF;;;OAGG;IACI,MAAM,CAAC,KAAK,GAA0C,MAAM,CAAC,EAAE,CACrE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;;OAGG;IACI,MAAM,CAAC,UAAU,GAA0C,MAAM,CAAC,EAAE,CAC1E,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B;;OAEG;IACI,MAAM,CAAC,SAAS,GAAe,GAAG,EAAE;QAC1C,SAAS,CAAC,O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B,EAAE,CAAC;YACnC,aAAa,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;YAC7C,UAAU,CAAC,kBAAkB,GAAG,SAAS,CAAC;QAC3C,CAAC;QACD,UAAU,CAAC,SAAS,EAAE,CAAC;IACxB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { clearLine, cursorTo } from \"node:readline\";\nimport { inspect } from \"node:util\";\nimport { Coerce, ErrorHelper, I18n, Is } from \"@twin.org/core\";\nimport chalk from \"chalk\";\n\n/**\n * Display utilities for the CLI.\n */\nexport class CLIDisplay {\n\t/**\n\t * The interval ID for the spinner.\n\t * @internal\n\t */\n\tprivate static _spinnerIntervalId: ReturnType<typeof setTimeout> | number | undefined;\n\n\t/**\n\t * The default output method for writing standard messages.\n\t * @param buffer The message to output.\n\t */\n\tpublic static write: (buffer: string | Uint8Array) => void = buffer =>\n\t\tprocess.stdout.write(buffer);\n\n\t/**\n\t * The default output method for writing error messages.\n\t * @param buffer The message to output.\n\t */\n\tpublic static writeError: (buffer: string | Uint8Array) => void = buffer =>\n\t\tprocess.stderr.write(buffer);\n\n\t/**\n\t * The default output method for clearing the current line.\n\t */\n\tpublic static clearLine: () => void = () => {\n\t\tclearLine(process.stdout, 0);\n\t\tcursorTo(process.stdout, 0);\n\t};\n\n\t/**\n\t * Display the header for the CLI.\n\t * @param title The title of the CLI.\n\t * @param version The version of the CLI.\n\t * @param icon The icon for the CLI.\n\t */\n\tpublic static header(title: string, version: string, icon: string): void {\n\t\tconst titleVersion = `${title} v${version}`;\n\t\tCLIDisplay.write(`${icon} ${chalk.underline.bold.blue(titleVersion)}\\n`);\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display an error message.\n\t * @param error The error to display.\n\t * @param lineBreaks Whether to add a line break after the error.\n\t * @param options Options for formatting the error.\n\t * @param options.includeStack Whether to include the stack trace in the output, defaults to false.\n\t * @param options.includeAdditional Whether to include additional error information in the output, defaults to false.\n\t */\n\tpublic static error(\n\t\terror: unknown,\n\t\tlineBreaks: boolean = true,\n\t\toptions: { includeStack?: boolean; includeAdditional?: boolean } = {}\n\t): void {\n\t\tCLIDisplay.writeError(\"❗ \");\n\t\tCLIDisplay.writeError(chalk.red(I18n.formatMessage(\"cli.progress.error\")));\n\t\tif (lineBreaks) {\n\t\t\tCLIDisplay.writeError(\"\\n\");\n\t\t}\n\n\t\tconst formatted = ErrorHelper.localizeErrors(error);\n\t\tCLIDisplay.writeError(chalk.red(formatted.map(e => `\\t${e.message}`).join(\"\\n\")));\n\n\t\tif (options.includeAdditional) {\n\t\t\tfor (const err of formatted) {\n\t\t\t\tif (Is.arrayValue(err.additional)) {\n\t\t\t\t\tCLIDisplay.writeError(chalk.red(`\\n\\t\\t${err.additional.join(\"\\n\\t\\t\")}\\n`));\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (options.includeStack) {\n\t\t\tCLIDisplay.writeError(\"\\n\");\n\t\t\tCLIDisplay.writeError(\"\\n-----DEBUG STACK START-----\\n\\n\");\n\t\t\tfor (const err of formatted) {\n\t\t\t\tif (Is.stringValue(err.stack)) {\n\t\t\t\t\tCLIDisplay.writeError(`${err.stack}\\n`);\n\t\t\t\t}\n\t\t\t}\n\t\t\tCLIDisplay.writeError(\"\\n-----DEBUG STACK END-----\\n\");\n\t\t}\n\n\t\tif (lineBreaks) {\n\t\t\tCLIDisplay.writeError(\"\\n\");\n\t\t}\n\t}\n\n\t/**\n\t * Display an error message in simple form.\n\t * @param error The error to display.\n\t */\n\tpublic static errorMessage(error: string): void {\n\t\tCLIDisplay.writeError(\"❗ \");\n\t\tCLIDisplay.writeError(chalk.red(error));\n\t\tCLIDisplay.writeError(\"\\n\");\n\t}\n\n\t/**\n\t * Display a section.\n\t * @param label The label for the section.\n\t */\n\tpublic static section(label: string): void {\n\t\tCLIDisplay.write(chalk.hex(\"#FFA500\").bold.underline(label));\n\t\tCLIDisplay.write(\"\\n\\n\");\n\t}\n\n\t/**\n\t * Display a value with a label.\n\t * @param label The label for the value.\n\t * @param value The value to display.\n\t * @param indentLevel The level of indentation.\n\t */\n\tpublic static value(label: string, value: unknown, indentLevel: number = 0): void {\n\t\tCLIDisplay.write(\"\\t\".repeat(indentLevel));\n\t\tif (Is.stringValue(label)) {\n\t\t\tCLIDisplay.write(chalk.hex(\"#FFA500\").bold(`${label}: `));\n\t\t}\n\t\tCLIDisplay.write(Coerce.string(value) ?? \"\");\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display a task with a label.\n\t * @param label The label for the value.\n\t * @param task The task to display.\n\t */\n\tpublic static task(label: string, task?: string): void {\n\t\tCLIDisplay.write(\"➡️ \");\n\t\tif (Is.empty(task)) {\n\t\t\tCLIDisplay.write(chalk.cyan(label));\n\t\t} else {\n\t\t\tCLIDisplay.write(chalk.cyan(`${label}: `));\n\t\t\tCLIDisplay.write(task);\n\t\t}\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display a break.\n\t */\n\tpublic static break(): void {\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display formatted and colorized JSON.\n\t * @param obj The object to display.\n\t */\n\tpublic static json(obj: unknown): void {\n\t\tCLIDisplay.write(inspect(obj, false, null, true));\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Display a warning.\n\t * @param label The label for the warning.\n\t */\n\tpublic static warning(label: string): void {\n\t\tCLIDisplay.write(\"⚠️ \");\n\t\tCLIDisplay.write(chalk.hex(\"#FFA500\").bold(label));\n\t\tCLIDisplay.write(\"\\n\\n\");\n\t}\n\n\t/**\n\t * Display the processing is done.\n\t */\n\tpublic static done(): void {\n\t\tCLIDisplay.write(\"🎉 \");\n\t\tCLIDisplay.write(chalk.greenBright.bold(I18n.formatMessage(\"cli.progress.done\")));\n\t\tCLIDisplay.write(\"\\n\");\n\t}\n\n\t/**\n\t * Start the spinner.\n\t * @param i18nMessage The message to display with the spinner.\n\t * @param spinnerCharacters The characters to use in the spinner.\n\t * @param interval The interval for the spinner.\n\t */\n\tpublic static spinnerStart(\n\t\ti18nMessage: string = \"cli.progress.pleaseWait\",\n\t\tspinnerCharacters: string[] = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"],\n\t\tinterval: number = 100\n\t): void {\n\t\tlet spinnerIndex = 0;\n\t\tif (CLIDisplay._spinnerIntervalId) {\n\t\t\tclearInterval(CLIDisplay._spinnerIntervalId);\n\t\t}\n\t\tCLIDisplay._spinnerIntervalId = setInterval(() => {\n\t\t\tCLIDisplay.clearLine();\n\t\t\tCLIDisplay.write(\n\t\t\t\t`${spinnerCharacters[spinnerIndex++ % spinnerCharacters.length]} ${I18n.formatMessage(i18nMessage)}`\n\t\t\t);\n\t\t}, interval);\n\t}\n\n\t/**\n\t * Stop the spinner.\n\t */\n\tpublic static spinnerStop(): void {\n\t\tif (CLIDisplay._spinnerIntervalId) {\n\t\t\tclearInterval(CLIDisplay._spinnerIntervalId);\n\t\t\tCLIDisplay._spinnerIntervalId = undefined;\n\t\t}\n\t\tCLIDisplay.clearLine();\n\t}\n}\n"]}
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,81 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.2](https://github.com/iotaledger/twin-framework/compare/cli-core-v0.9.2...cli-core-v0.9.2) (2026-08-24)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* release to production ([b24cba1](https://github.com/iotaledger/twin-framework/commit/b24cba1b6a969278d638e632590602ec881e49fb))
|
|
9
|
+
* release to production ([787287d](https://github.com/iotaledger/twin-framework/commit/787287d06ea8319657401589d61fff369310c422))
|
|
10
|
+
* release to production ([53f4843](https://github.com/iotaledger/twin-framework/commit/53f484326b2851d7a506d2620db24c4a65cee7b3))
|
|
11
|
+
* release to production ([56cda4d](https://github.com/iotaledger/twin-framework/commit/56cda4da93e978c5be19ec7cfd421ae2a7fe4147))
|
|
12
|
+
* release to production ([f7c6586](https://github.com/iotaledger/twin-framework/commit/f7c6586f6976b903b647b4c5ac5ad9421e0c9051))
|
|
13
|
+
* release to production ([829d53d](https://github.com/iotaledger/twin-framework/commit/829d53d3953b1e1b40b0243c04cfdfd3842aac7b))
|
|
14
|
+
* release to production ([5cf3a76](https://github.com/iotaledger/twin-framework/commit/5cf3a76a09eff2e6414d0cba846c7c37400a11d6))
|
|
15
|
+
* release to production ([#330](https://github.com/iotaledger/twin-framework/issues/330)) ([d73f565](https://github.com/iotaledger/twin-framework/commit/d73f565588d156d23ef49b2a5718973756f7a696))
|
|
16
|
+
* release to production ([#382](https://github.com/iotaledger/twin-framework/issues/382)) ([bbed01a](https://github.com/iotaledger/twin-framework/commit/bbed01a605ee9724bda77a0f7feab249118c2d90))
|
|
17
|
+
* release to production ([#417](https://github.com/iotaledger/twin-framework/issues/417)) ([59727e7](https://github.com/iotaledger/twin-framework/commit/59727e73903a137310ca48fe469189cf29879cb9))
|
|
18
|
+
* release to production ([#459](https://github.com/iotaledger/twin-framework/issues/459)) ([e26e2d9](https://github.com/iotaledger/twin-framework/commit/e26e2d9a88767364c32494c45232033447b26e22))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Miscellaneous Chores
|
|
22
|
+
|
|
23
|
+
* release to production ([63cae24](https://github.com/iotaledger/twin-framework/commit/63cae2401f6c11f93b2a01260b665064e8bd28e0))
|
|
24
|
+
|
|
25
|
+
## [0.9.2-next.11](https://github.com/iotaledger/twin-framework/compare/cli-core-v0.9.2-next.10...cli-core-v0.9.2-next.11) (2026-08-20)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Miscellaneous Chores
|
|
29
|
+
|
|
30
|
+
* **cli-core:** Synchronize repo versions
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Dependencies
|
|
34
|
+
|
|
35
|
+
* The following workspace dependencies were updated
|
|
36
|
+
* dependencies
|
|
37
|
+
* @twin.org/core bumped from 0.9.2-next.10 to 0.9.2-next.11
|
|
38
|
+
* @twin.org/nameof bumped from 0.9.2-next.10 to 0.9.2-next.11
|
|
39
|
+
* devDependencies
|
|
40
|
+
* @twin.org/nameof-transformer bumped from 0.9.2-next.10 to 0.9.2-next.11
|
|
41
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.10 to 0.9.2-next.11
|
|
42
|
+
|
|
43
|
+
## [0.9.2-next.10](https://github.com/iotaledger/twin-framework/compare/cli-core-v0.9.2-next.9...cli-core-v0.9.2-next.10) (2026-08-11)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
### Features
|
|
47
|
+
|
|
48
|
+
* timeout return type ([4b40b23](https://github.com/iotaledger/twin-framework/commit/4b40b23a7e6b073c7e96cbccc1d41ba7caed2556))
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
### Dependencies
|
|
52
|
+
|
|
53
|
+
* The following workspace dependencies were updated
|
|
54
|
+
* dependencies
|
|
55
|
+
* @twin.org/core bumped from 0.9.2-next.9 to 0.9.2-next.10
|
|
56
|
+
* @twin.org/nameof bumped from 0.9.2-next.9 to 0.9.2-next.10
|
|
57
|
+
* devDependencies
|
|
58
|
+
* @twin.org/nameof-transformer bumped from 0.9.2-next.9 to 0.9.2-next.10
|
|
59
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.9 to 0.9.2-next.10
|
|
60
|
+
|
|
61
|
+
## [0.9.2-next.9](https://github.com/iotaledger/twin-framework/compare/cli-core-v0.9.2-next.8...cli-core-v0.9.2-next.9) (2026-08-10)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
### Miscellaneous Chores
|
|
65
|
+
|
|
66
|
+
* **cli-core:** Synchronize repo versions
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
### Dependencies
|
|
70
|
+
|
|
71
|
+
* The following workspace dependencies were updated
|
|
72
|
+
* dependencies
|
|
73
|
+
* @twin.org/core bumped from 0.9.2-next.8 to 0.9.2-next.9
|
|
74
|
+
* @twin.org/nameof bumped from 0.9.2-next.8 to 0.9.2-next.9
|
|
75
|
+
* devDependencies
|
|
76
|
+
* @twin.org/nameof-transformer bumped from 0.9.2-next.8 to 0.9.2-next.9
|
|
77
|
+
* @twin.org/nameof-vitest-plugin bumped from 0.9.2-next.8 to 0.9.2-next.9
|
|
78
|
+
|
|
3
79
|
## [0.9.2-next.8](https://github.com/iotaledger/twin-framework/compare/cli-core-v0.9.2-next.7...cli-core-v0.9.2-next.8) (2026-08-10)
|
|
4
80
|
|
|
5
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/cli-core",
|
|
3
|
-
"version": "0.9.2
|
|
3
|
+
"version": "0.9.2",
|
|
4
4
|
"description": "Core classes for building a CLI",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"node": ">=24.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/core": "0.9.2
|
|
18
|
-
"@twin.org/nameof": "0.9.2
|
|
17
|
+
"@twin.org/core": "^0.9.2",
|
|
18
|
+
"@twin.org/nameof": "^0.9.2",
|
|
19
19
|
"chalk": "5.6.2",
|
|
20
20
|
"commander": "15.0.0",
|
|
21
21
|
"dotenv": "17.4.2"
|