@visulima/cerebro 3.0.0-alpha.3 → 3.0.0-alpha.30

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.
Files changed (90) hide show
  1. package/CHANGELOG.md +458 -0
  2. package/LICENSE.md +605 -4095
  3. package/README.md +152 -2
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +3 -3
  6. package/dist/commands/help-command.d.ts +10 -9
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +20 -20
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/index.d.ts +501 -95
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +745 -8
  14. package/dist/logger/create-pail-logger.js +1 -1
  15. package/dist/packem_chunks/has-new-version.js +1 -1
  16. package/dist/packem_shared/Cerebro-BN_nIZ8z.js +4 -0
  17. package/dist/packem_shared/VisulimaError-WfDZ45Qv.js +76 -0
  18. package/dist/packem_shared/constants-DmzZF6_u-BmMwILI_.js +1 -0
  19. package/dist/packem_shared/index-CkkDAMKi.js +6 -0
  20. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  21. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  22. package/dist/packem_shared/plugin-manager.d-BSQtHbWS.d.ts +620 -0
  23. package/dist/packem_shared/renderError-DxgI44AK-DFDWFoCr.js +24 -0
  24. package/dist/packem_shared/{runtime-process-G-n-wOub.js → runtime-process-DKHFvYkv.js} +1 -1
  25. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  26. package/dist/plugins/error-handler-plugin.js +1 -1
  27. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  28. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  29. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  30. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  31. package/dist/util/general/compile-cache.d.ts +41 -0
  32. package/dist/util/general/compile-cache.js +1 -0
  33. package/dist/util/general/heap-tuning.d.ts +18 -0
  34. package/dist/util/general/heap-tuning.js +1 -0
  35. package/package.json +32 -26
  36. package/dist/cli.d.ts +0 -203
  37. package/dist/constants.d.ts +0 -29
  38. package/dist/default-env.d.ts +0 -7
  39. package/dist/default-options.d.ts +0 -3
  40. package/dist/empty-toolbox.d.ts +0 -15
  41. package/dist/errors/cerebro-error.d.ts +0 -10
  42. package/dist/errors/command-not-found-error.d.ts +0 -9
  43. package/dist/errors/command-validation-error.d.ts +0 -10
  44. package/dist/errors/completion-error.d.ts +0 -9
  45. package/dist/errors/conflicting-options-error.d.ts +0 -10
  46. package/dist/errors/plugin-error.d.ts +0 -9
  47. package/dist/errors/update-notifier-error.d.ts +0 -7
  48. package/dist/packem_shared/Cerebro-aPZjbfzf.js +0 -4
  49. package/dist/packem_shared/VisulimaError-BJideSBf.js +0 -76
  50. package/dist/packem_shared/help-command-CIRIXN03.js +0 -1
  51. package/dist/packem_shared/index-DQ3pvLQH.js +0 -6
  52. package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +0 -24
  53. package/dist/plugin-manager.d.ts +0 -53
  54. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  55. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  56. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  57. package/dist/types/cli.d.ts +0 -102
  58. package/dist/types/command-line-usage.d.ts +0 -37
  59. package/dist/types/command.d.ts +0 -136
  60. package/dist/types/option-types.d.ts +0 -83
  61. package/dist/types/options.d.ts +0 -4
  62. package/dist/types/plugin.d.ts +0 -53
  63. package/dist/types/toolbox.d.ts +0 -96
  64. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  65. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  66. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  67. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  68. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  69. package/dist/util/command-line-commands.d.ts +0 -10
  70. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  71. package/dist/util/command-line-usage/index.d.ts +0 -3
  72. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  73. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  74. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  75. package/dist/util/command-processing/command-processor.d.ts +0 -37
  76. package/dist/util/command-processing/command-validation.d.ts +0 -17
  77. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  78. package/dist/util/command-processing/option-processor.d.ts +0 -44
  79. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  80. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  81. package/dist/util/general/find-alternatives.d.ts +0 -8
  82. package/dist/util/general/hide-bin.d.ts +0 -2
  83. package/dist/util/general/parse-raw-command.d.ts +0 -7
  84. package/dist/util/general/register-exception-handler.d.ts +0 -9
  85. package/dist/util/general/runtime-process.d.ts +0 -65
  86. package/dist/util/general/semver-gt.d.ts +0 -2
  87. package/dist/util/general/validate-input.d.ts +0 -24
  88. package/dist/util/process-env-variables.d.ts +0 -9
  89. package/dist/util/security.d.ts +0 -58
  90. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -1,21 +1,23 @@
1
- import type { RenderErrorOptions } from "@visulima/error";
2
- import type { Plugin } from "../types/plugin.d.ts";
3
- export type ErrorHandlerOptions = {
4
- /** Show detailed error information including stack traces and code frames (default: false) */
5
- detailed?: boolean;
6
- /** Exit process after handling error (default: true) */
7
- exitOnError?: boolean;
8
- /** Custom error formatter function */
9
- formatter?: (error: Error) => string;
10
- /** Whether to log errors (default: true) */
11
- logErrors?: boolean;
12
- /** Options for renderError from \@visulima/error (only used when detailed is true) */
13
- renderOptions?: Partial<RenderErrorOptions>;
1
+ import { O as Options$1 } from "../packem_shared/index.d-Br8HpP0A.js";
2
+ import { P as Plugin } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
3
+ import '@visulima/tabular';
4
+ type ErrorHandlerOptions = {
5
+ /** Show detailed error information including stack traces and code frames (default: false) */
6
+ detailed?: boolean;
7
+ /** Exit process after handling error (default: true) */
8
+ exitOnError?: boolean;
9
+ /** Custom error formatter function */
10
+ formatter?: (error: Error) => string;
11
+ /** Whether to log errors (default: true) */
12
+ logErrors?: boolean;
13
+ /** Options for renderError from \@visulima/error (only used when detailed is true) */
14
+ renderOptions?: Partial<Options$1>;
14
15
  };
15
16
  /**
16
- * Create an error handler plugin for enhanced error reporting.
17
- * Uses \@visulima/error for beautiful error formatting with code frames and stack traces.
18
- * @param options Error handler configuration options
19
- * @returns Plugin instance
20
- */
21
- export declare const errorHandlerPlugin: (options?: ErrorHandlerOptions) => Plugin;
17
+ * Create an error handler plugin for enhanced error reporting.
18
+ * Uses \@visulima/error for beautiful error formatting with code frames and stack traces.
19
+ * @param options Error handler configuration options
20
+ * @returns Plugin instance
21
+ */
22
+ declare const errorHandlerPlugin: (options?: ErrorHandlerOptions) => Plugin;
23
+ export { ErrorHandlerOptions, errorHandlerPlugin };
@@ -1 +1 @@
1
- var u=Object.defineProperty;var i=(e,r)=>u(e,"name",{value:r,configurable:!0});import{G as h}from"../packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js";import{e as p}from"../packem_shared/runtime-process-G-n-wOub.js";var E=Object.defineProperty,a=i((e,r)=>E(e,"name",{value:r,configurable:!0}),"n");const P=a((e={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:a(async(r,t)=>{const{logger:o,runtime:l}=t,{detailed:s=!1,exitOnError:d=!0,formatter:n,logErrors:f=!0,renderOptions:c={}}=e;if(f)if(n)o.error(n(r));else if(s){const g=l.getCwd(),m=h(r,{cwd:g,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...c});o.error(m)}else o.error(r);d&&p(1)},"handleError"),version:"1.0.0"}),"errorHandlerPlugin");export{P as errorHandlerPlugin};
1
+ var u=Object.defineProperty;var n=(e,r)=>u(e,"name",{value:r,configurable:!0});import{G as h}from"../packem_shared/renderError-DxgI44AK-DFDWFoCr.js";import{e as p}from"../packem_shared/runtime-process-DKHFvYkv.js";var E=Object.defineProperty,a=n((e,r)=>E(e,"name",{value:r,configurable:!0}),"n");const P=a((e={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:a((r,t)=>{const{logger:o,runtime:l}=t,{detailed:s=!1,exitOnError:d=!0,formatter:i,logErrors:f=!0,renderOptions:g={}}=e;if(f)if(i)o.error(i(r));else if(s){const c=l.getCwd(),m=h(r,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...g});o.error(m)}else o.error(r);d&&p(1)},"handleError"),version:"1.0.0"}),"errorHandlerPlugin");export{P as errorHandlerPlugin};
@@ -1,23 +1,25 @@
1
- import type { Plugin } from "../types/plugin.d.ts";
2
- export type RuntimeType = "bun" | "deno" | "node";
3
- export type RuntimeVersionRequirement = {
4
- /** Minimum version required */
5
- minVersion: number;
1
+ import { P as Plugin } from "../packem_shared/plugin-manager.d-BSQtHbWS.js";
2
+ import '@visulima/tabular';
3
+ type RuntimeType = "bun" | "deno" | "node";
4
+ type RuntimeVersionRequirement = {
5
+ /** Minimum version required */
6
+ minVersion: number;
6
7
  };
7
- export type RuntimeVersionCheckOptions = {
8
- /** Runtime version requirements for specific runtimes */
9
- runtimes?: {
10
- /** Minimum Bun version requirement */
11
- bun?: RuntimeVersionRequirement;
12
- /** Minimum Deno version requirement */
13
- deno?: RuntimeVersionRequirement;
14
- /** Minimum Node.js version requirement */
15
- node?: RuntimeVersionRequirement;
16
- };
8
+ type RuntimeVersionCheckOptions = {
9
+ /** Runtime version requirements for specific runtimes */
10
+ runtimes?: {
11
+ /** Minimum Bun version requirement */
12
+ bun?: RuntimeVersionRequirement;
13
+ /** Minimum Deno version requirement */
14
+ deno?: RuntimeVersionRequirement;
15
+ /** Minimum Node.js version requirement */
16
+ node?: RuntimeVersionRequirement;
17
+ };
17
18
  };
18
19
  /**
19
- * Create a runtime version check plugin that supports Node.js, Bun, and Deno.
20
- * @param options Configuration for runtime version requirements
21
- * @returns Plugin instance that validates runtime version on initialization
22
- */
23
- export declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
20
+ * Create a runtime version check plugin that supports Node.js, Bun, and Deno.
21
+ * @param options Configuration for runtime version requirements
22
+ * @returns Plugin instance that validates runtime version on initialization
23
+ */
24
+ declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
25
+ export { RuntimeType, RuntimeVersionCheckOptions, RuntimeVersionRequirement, runtimeVersionCheckPlugin };
@@ -1 +1 @@
1
- var a=Object.defineProperty;var p=(r,t)=>a(r,"name",{value:t,configurable:!0});import{d as v,e as d,g as y}from"../packem_shared/runtime-process-G-n-wOub.js";var g=Object.defineProperty,n=p((r,t)=>g(r,"name",{value:t,configurable:!0}),"o");const s=n(r=>{if(!r||typeof r!="string")return 0;const t=r.split(".");if(t.length===0||!t[0])return 0;const e=Number.parseInt(t[0],10);return Number.isNaN(e)?0:e},"parseMajorVersion"),h=n(r=>!r||typeof r!="string"?"":r.replace("v",""),"extractNodeVersion"),l=n(()=>{if(typeof Bun<"u"){const e=Bun.version||"";return{major:s(e),type:"bun",version:e}}if(typeof Deno<"u"){const e=Deno.version?.deno||"";return{major:s(e),type:"deno",version:e}}const r=y().node??"",t=h(r);return{major:s(t),type:"node",version:t}},"detectRuntime"),b=n((r={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:n(async t=>{const e=l(),c={bun:1,deno:1,node:18};let o;try{const u=v().CEREBRO_MIN_NODE_VERSION,m=u===void 0?void 0:Number.parseInt(u,10);o=Number.isNaN(m)?void 0:m}catch{o=void 0}let i;r.runtimes?.[e.type]?.minVersion!==void 0?i=r.runtimes[e.type].minVersion:e.type==="node"&&o!==void 0?i=o:i=c[e.type],e.major<i&&(t.logger.error(`cerebro requires ${e.type} version ${i} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),d(1)),t.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${i}`)},"init"),name:"runtime-version-check",version:"1.0.0"}),"runtimeVersionCheckPlugin");export{b as runtimeVersionCheckPlugin};
1
+ var v=Object.defineProperty;var p=(r,t)=>v(r,"name",{value:t,configurable:!0});import{d as a,e as d,g}from"../packem_shared/runtime-process-DKHFvYkv.js";var y=Object.defineProperty,n=p((r,t)=>y(r,"name",{value:t,configurable:!0}),"o");const s=n(r=>{if(!r||typeof r!="string")return 0;const t=r.split(".");if(t.length===0||!t[0])return 0;const e=Number.parseInt(t[0],10);return Number.isNaN(e)?0:e},"parseMajorVersion"),h=n(r=>!r||typeof r!="string"?"":r.replace("v",""),"extractNodeVersion"),l=n(()=>{if(typeof Bun<"u"){const e=Bun.version||"";return{major:s(e),type:"bun",version:e}}if(typeof Deno<"u"){const e=Deno.version?.deno||"";return{major:s(e),type:"deno",version:e}}const r=g().node??"",t=h(r);return{major:s(t),type:"node",version:t}},"detectRuntime"),b=n((r={})=>({description:"Checks if the current runtime version meets the minimum requirement",init:n(t=>{const e=l(),c={bun:1,deno:1,node:18};let o;try{const u=a().CEREBRO_MIN_NODE_VERSION,m=u===void 0?void 0:Number.parseInt(u,10);o=Number.isNaN(m)?void 0:m}catch{o=void 0}let i;r.runtimes?.[e.type]?.minVersion!==void 0?i=r.runtimes[e.type].minVersion:e.type==="node"&&o!==void 0?i=o:i=c[e.type],e.major<i&&(t.logger.error(`cerebro requires ${e.type} version ${String(i)} or higher. You have ${e.type} ${e.version}. Read our version support policy: https://github.com/visulima/visulima#supported-runtimes`),d(1)),t.logger.debug(`Runtime version check passed: ${e.type} ${e.version} >= ${String(i)}`)},"init"),name:"runtime-version-check",version:"1.0.0"}),"runtimeVersionCheckPlugin");export{b as runtimeVersionCheckPlugin};
@@ -1,9 +1,22 @@
1
- import type { Plugin } from "../../types/plugin.d.ts";
2
- import type { UpdateNotifierOptions } from "./has-new-version.d.ts";
3
- export type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
1
+ import { P as Plugin } from "../../packem_shared/plugin-manager.d-BSQtHbWS.js";
2
+ import '@visulima/tabular';
3
+ type UpdateNotifierOptions = {
4
+ alwaysRun?: boolean;
5
+ debug?: boolean;
6
+ distTag?: string;
7
+ pkg: {
8
+ name: string;
9
+ version: string;
10
+ };
11
+ registryUrl?: string;
12
+ shouldNotifyInNpmScript?: boolean;
13
+ updateCheckInterval?: number;
14
+ };
15
+ type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
4
16
  /**
5
- * Create an update notifier plugin that checks for package updates.
6
- * @param options Update notifier configuration options.
7
- * @returns Plugin instance.
8
- */
9
- export declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
17
+ * Create an update notifier plugin that checks for package updates.
18
+ * @param options Update notifier configuration options.
19
+ * @returns Plugin instance.
20
+ */
21
+ declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
22
+ export { UpdateNotifierPluginOptions, updateNotifierPlugin };
@@ -1 +1 @@
1
- var m=Object.defineProperty;var I=(t,r)=>m(t,"name",{value:r,configurable:!0});import{d as A}from"../../packem_shared/runtime-process-G-n-wOub.js";var i={},c,U;function l(){return U||(U=1,c=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]),c}I(l,"requireVendors");var L;function d(){return L||(L=1,(function(t){var r=Object.defineProperty,E=I((n,a)=>r(n,"name",{value:a,configurable:!0}),"t");const s=l(),e=process.env;Object.defineProperty(t,"_vendors",{value:s.map(function(n){return n.constant})}),t.name=null,t.isPR=null,t.id=null,e.CI!=="false"&&s.forEach(function(n){const a=(Array.isArray(n.env)?n.env:[n.env]).every(function(R){return o(R)});t[n.constant]=a,a&&(t.name=n.name,t.isPR=_(n),t.id=n.constant)}),t.isCI=!!(e.CI!=="false"&&(e.BUILD_ID||e.BUILD_NUMBER||e.CI||e.CI_APP_ID||e.CI_BUILD_ID||e.CI_BUILD_NUMBER||e.CI_NAME||e.CONTINUOUS_INTEGRATION||e.RUN_ID||t.name));function o(n){return typeof n=="string"?!!e[n]:"env"in n?e[n.env]&&e[n.env].includes(n.includes):"any"in n?n.any.some(function(a){return!!e[a]}):Object.keys(n).every(function(a){return e[a]===n[a]})}I(o,"checkEnv"),E(o,"checkEnv");function _(n){switch(typeof n.pr){case"string":return!!e[n.pr];case"object":return"env"in n.pr?"any"in n.pr?n.pr.any.some(function(a){return e[n.pr.env]===a}):n.pr.env in e&&e[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(a){return!!e[a]}):o(n.pr);default:return null}}I(_,"checkPR"),E(_,"checkPR")})(i)),i}I(d,"requireCiInfo");var P=d(),O=Object.defineProperty,C=I((t,r)=>O(t,"name",{value:r,configurable:!0}),"i");const f=C((t={})=>({beforeCommand:C(async r=>{const{logger:E,runtime:s}=r,e=s.getPackageName(),o=s.getPackageVersion();if(!e||!o){E.debug("Update notifier: package name or version not provided, skipping...");return}const _=A(),n={alwaysRun:!1,debug:_.CEREBRO_OUTPUT_LEVEL==="256",distTag:"latest",pkg:{name:e,version:o},updateCheckInterval:1e3*60*60*24,...t};if(!(n.alwaysRun||!(_.NO_UPDATE_NOTIFIER||_.NODE_ENV==="test"||r.argv.includes("--no-update-notifier")||P.isCI))){E.debug("Update notifier: skipping check (disabled by environment or flags)");return}(E?.raw??E.log)("Checking for updates...");try{const a=await(await import("../../packem_chunks/has-new-version.js").then(R=>R.default))(n);if(a){const[{boxen:R},{dim:v,green:u,reset:T,yellow:D}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),p=`Update available ${v(o.toString())}${T(" → ")}${u(a)}`;E.error(R(p,{borderColor:C(S=>D(S),"borderColor"),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}catch(a){E.debug("Update notifier: failed to check for updates",a)}},"beforeCommand"),description:"Checks for package updates and notifies users",name:"update-notifier",version:"1.0.0"}),"updateNotifierPlugin");export{f as updateNotifierPlugin};
1
+ var f=Object.defineProperty;var E=(e,r)=>f(e,"name",{value:r,configurable:!0});import{d as T}from"../../packem_shared/runtime-process-DKHFvYkv.js";var P=Object.defineProperty,i=E((e,r)=>P(e,"name",{value:r,configurable:!0}),"t");function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}E(A,"getDefaultExportFromCjs");i(A,"getDefaultExportFromCjs");function O(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}E(O,"getDefaultExportFromNamespaceIfPresent");i(O,"getDefaultExportFromNamespaceIfPresent");function S(e){return e&&Object.prototype.hasOwnProperty.call(e,"default")&&Object.keys(e).length===1?e.default:e}E(S,"getDefaultExportFromNamespaceIfNotNamed");i(S,"getDefaultExportFromNamespaceIfNotNamed");function N(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var r=e.default;if(typeof r=="function"){var o=i(E(function c(){var t=!1;try{t=this instanceof c}catch{}return t?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)},"a"),"a");o.prototype=r.prototype}else o={};return Object.defineProperty(o,"__esModule",{value:!0}),Object.keys(e).forEach(function(c){var t=Object.getOwnPropertyDescriptor(e,c);Object.defineProperty(o,c,t.get?t:{enumerable:!0,get:i(function(){return e[c]},"get")})}),o}E(N,"getAugmentedNamespace");i(N,"getAugmentedNamespace");var u={},R,p;function B(){return p||(p=1,R=[{name:"Agola CI",constant:"AGOLA",env:"AGOLA_GIT_REF",pr:"AGOLA_PULL_REQUEST_ID"},{name:"Alpic",constant:"ALPIC",env:"ALPIC_HOST"},{name:"Appcircle",constant:"APPCIRCLE",env:"AC_APPCIRCLE",pr:{env:"AC_GIT_PR",ne:"false"}},{name:"AppVeyor",constant:"APPVEYOR",env:"APPVEYOR",pr:"APPVEYOR_PULL_REQUEST_NUMBER"},{name:"AWS CodeBuild",constant:"CODEBUILD",env:"CODEBUILD_BUILD_ARN",pr:{env:"CODEBUILD_WEBHOOK_EVENT",any:["PULL_REQUEST_CREATED","PULL_REQUEST_UPDATED","PULL_REQUEST_REOPENED"]}},{name:"Azure Pipelines",constant:"AZURE_PIPELINES",env:"TF_BUILD",pr:{BUILD_REASON:"PullRequest"}},{name:"Bamboo",constant:"BAMBOO",env:"bamboo_planKey"},{name:"Bitbucket Pipelines",constant:"BITBUCKET",env:"BITBUCKET_COMMIT",pr:"BITBUCKET_PR_ID"},{name:"Bitrise",constant:"BITRISE",env:"BITRISE_IO",pr:"BITRISE_PULL_REQUEST"},{name:"Buddy",constant:"BUDDY",env:"BUDDY_WORKSPACE_ID",pr:"BUDDY_EXECUTION_PULL_REQUEST_ID"},{name:"Buildkite",constant:"BUILDKITE",env:"BUILDKITE",pr:{env:"BUILDKITE_PULL_REQUEST",ne:"false"}},{name:"CircleCI",constant:"CIRCLE",env:"CIRCLECI",pr:"CIRCLE_PULL_REQUEST"},{name:"Cirrus CI",constant:"CIRRUS",env:"CIRRUS_CI",pr:"CIRRUS_PR"},{name:"Cloudflare Pages",constant:"CLOUDFLARE_PAGES",env:"CF_PAGES"},{name:"Cloudflare Workers",constant:"CLOUDFLARE_WORKERS",env:"WORKERS_CI"},{name:"Codefresh",constant:"CODEFRESH",env:"CF_BUILD_ID",pr:{any:["CF_PULL_REQUEST_NUMBER","CF_PULL_REQUEST_ID"]}},{name:"Codemagic",constant:"CODEMAGIC",env:"CM_BUILD_ID",pr:"CM_PULL_REQUEST"},{name:"Codeship",constant:"CODESHIP",env:{CI_NAME:"codeship"}},{name:"Drone",constant:"DRONE",env:"DRONE",pr:{DRONE_BUILD_EVENT:"pull_request"}},{name:"dsari",constant:"DSARI",env:"DSARI"},{name:"Earthly",constant:"EARTHLY",env:"EARTHLY_CI"},{name:"Expo Application Services",constant:"EAS",env:"EAS_BUILD"},{name:"Gerrit",constant:"GERRIT",env:"GERRIT_PROJECT"},{name:"Gitea Actions",constant:"GITEA_ACTIONS",env:"GITEA_ACTIONS"},{name:"GitHub Actions",constant:"GITHUB_ACTIONS",env:"GITHUB_ACTIONS",pr:{GITHUB_EVENT_NAME:"pull_request"}},{name:"GitLab CI",constant:"GITLAB",env:"GITLAB_CI",pr:"CI_MERGE_REQUEST_ID"},{name:"GoCD",constant:"GOCD",env:"GO_PIPELINE_LABEL"},{name:"Google Cloud Build",constant:"GOOGLE_CLOUD_BUILD",env:"BUILDER_OUTPUT"},{name:"Harness CI",constant:"HARNESS",env:"HARNESS_BUILD_ID"},{name:"Heroku",constant:"HEROKU",env:{env:"NODE",includes:"/app/.heroku/node/bin/node"}},{name:"Hudson",constant:"HUDSON",env:"HUDSON_URL"},{name:"Jenkins",constant:"JENKINS",env:["JENKINS_URL","BUILD_ID"],pr:{any:["ghprbPullId","CHANGE_ID"]}},{name:"LayerCI",constant:"LAYERCI",env:"LAYERCI",pr:"LAYERCI_PULL_REQUEST"},{name:"Magnum CI",constant:"MAGNUM",env:"MAGNUM"},{name:"Netlify CI",constant:"NETLIFY",env:"NETLIFY",pr:{env:"PULL_REQUEST",ne:"false"}},{name:"Nevercode",constant:"NEVERCODE",env:"NEVERCODE",pr:{env:"NEVERCODE_PULL_REQUEST",ne:"false"}},{name:"Prow",constant:"PROW",env:"PROW_JOB_ID"},{name:"ReleaseHub",constant:"RELEASEHUB",env:"RELEASE_BUILD_ID"},{name:"Render",constant:"RENDER",env:"RENDER",pr:{IS_PULL_REQUEST:"true"}},{name:"Sail CI",constant:"SAIL",env:"SAILCI",pr:"SAIL_PULL_REQUEST_NUMBER"},{name:"Screwdriver",constant:"SCREWDRIVER",env:"SCREWDRIVER",pr:{env:"SD_PULL_REQUEST",ne:"false"}},{name:"Semaphore",constant:"SEMAPHORE",env:"SEMAPHORE",pr:"PULL_REQUEST_NUMBER"},{name:"Sourcehut",constant:"SOURCEHUT",env:{CI_NAME:"sourcehut"}},{name:"Strider CD",constant:"STRIDER",env:"STRIDER"},{name:"TaskCluster",constant:"TASKCLUSTER",env:["TASK_ID","RUN_ID"]},{name:"TeamCity",constant:"TEAMCITY",env:"TEAMCITY_VERSION"},{name:"Travis CI",constant:"TRAVIS",env:"TRAVIS",pr:{env:"TRAVIS_PULL_REQUEST",ne:"false"}},{name:"Vela",constant:"VELA",env:"VELA",pr:{VELA_PULL_REQUEST:"1"}},{name:"Vercel",constant:"VERCEL",env:{any:["NOW_BUILDER","VERCEL"]},pr:"VERCEL_GIT_PULL_REQUEST_ID"},{name:"Visual Studio App Center",constant:"APPCENTER",env:"APPCENTER_BUILD_ID"},{name:"Woodpecker",constant:"WOODPECKER",env:{CI:"woodpecker"},pr:{CI_BUILD_EVENT:"pull_request"}},{name:"Xcode Cloud",constant:"XCODE_CLOUD",env:"CI_XCODE_PROJECT",pr:"CI_PULL_REQUEST_NUMBER"},{name:"Xcode Server",constant:"XCODE_SERVER",env:"XCS"}]),R}E(B,"requireVendors");var U;function g(){return U||(U=1,(function(e){var r=Object.defineProperty,o=E((n,a)=>r(n,"name",{value:a,configurable:!0}),"t");const c=B(),t=process.env;Object.defineProperty(e,"_vendors",{value:c.map(function(n){return n.constant})}),e.name=null,e.isPR=null,e.id=null,t.CI!=="false"&&c.forEach(function(n){const a=(Array.isArray(n.env)?n.env:[n.env]).every(function(_){return s(_)});e[n.constant]=a,a&&(e.name=n.name,e.isPR=I(n),e.id=n.constant)}),e.isCI=!!(t.CI!=="false"&&(t.BUILD_ID||t.BUILD_NUMBER||t.CI||t.CI_APP_ID||t.CI_BUILD_ID||t.CI_BUILD_NUMBER||t.CI_NAME||t.CONTINUOUS_INTEGRATION||t.RUN_ID||e.name));function s(n){return typeof n=="string"?!!t[n]:"env"in n?t[n.env]&&t[n.env].includes(n.includes):"any"in n?n.any.some(function(a){return!!t[a]}):Object.keys(n).every(function(a){return t[a]===n[a]})}E(s,"checkEnv"),o(s,"checkEnv");function I(n){switch(typeof n.pr){case"string":return!!t[n.pr];case"object":return"env"in n.pr?"any"in n.pr?n.pr.any.some(function(a){return t[n.pr.env]===a}):n.pr.env in t&&t[n.pr.env]!==n.pr.ne:"any"in n.pr?n.pr.any.some(function(a){return!!t[a]}):s(n.pr);default:return null}}E(I,"checkPR"),o(I,"checkPR")})(u)),u}E(g,"requireCiInfo");var y=g(),b=Object.defineProperty,C=E((e,r)=>b(e,"name",{value:r,configurable:!0}),"i");const V=C((e={})=>({beforeCommand:C(async r=>{const{logger:o,runtime:c}=r,t=c.getPackageName(),s=c.getPackageVersion();if(!t||!s){o.debug("Update notifier: package name or version not provided, skipping...");return}const I=T(),n={alwaysRun:!1,debug:I.CEREBRO_OUTPUT_LEVEL==="256",distTag:"latest",pkg:{name:t,version:s},updateCheckInterval:1e3*60*60*24,...e};if(!(n.alwaysRun||!(I.NO_UPDATE_NOTIFIER||I.NODE_ENV==="test"||r.argv.includes("--no-update-notifier")||y.isCI))){o.debug("Update notifier: skipping check (disabled by environment or flags)");return}(o.raw??o.log)("Checking for updates...");try{const a=await(await import("../../packem_chunks/has-new-version.js").then(_=>_.default))(n);if(a){const[{boxen:_},{dim:l,green:L,reset:v,yellow:m}]=await Promise.all([import("@visulima/boxen"),import("@visulima/colorize")]),D=`Update available ${l(s)}${v(" → ")}${L(a)}`;o.error(_(D,{borderColor:C(d=>m(d),"borderColor"),borderStyle:"round",margin:1,padding:1,textAlignment:"center"}))}}catch(a){o.debug("Update notifier: failed to check for updates",a)}},"beforeCommand"),description:"Checks for package updates and notifies users",name:"update-notifier",version:"1.0.0"}),"updateNotifierPlugin");export{V as updateNotifierPlugin};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * V8 compile cache helper for faster CLI startup.
3
+ *
4
+ * Enables the V8 compile cache so that subsequent runs of the CLI skip
5
+ * re-parsing and re-compiling JavaScript/TypeScript source files. This
6
+ * can reduce startup time by 30-70% for large CLI tools.
7
+ *
8
+ * ## When to use
9
+ *
10
+ * Call `enableCompileCache()` early in your CLI entry point, after heap
11
+ * tuning but before importing heavy modules:
12
+ *
13
+ * ```typescript
14
+ * // bin.ts
15
+ * import { applyHeapTuning } from "@visulima/cerebro/heap-tuning";
16
+ * import { enableCompileCache } from "@visulima/cerebro/compile-cache";
17
+ *
18
+ * applyHeapTuning();
19
+ * enableCompileCache();
20
+ *
21
+ * import { createCerebro } from "@visulima/cerebro";
22
+ * // ... rest of your CLI setup
23
+ * ```
24
+ *
25
+ * ## How it works
26
+ *
27
+ * 1. Tries `module.enableCompileCache()` (Node.js 22.8+ native API) which
28
+ * stores compiled bytecode alongside source files for instant reuse.
29
+ * 2. If that's unavailable, falls back to the `v8-compile-cache` npm package
30
+ * which achieves a similar effect on older Node.js versions.
31
+ * 3. If neither is available, silently does nothing — startup is just slower.
32
+ * @module
33
+ */
34
+ /**
35
+ * Enable V8 compile cache for faster subsequent CLI startups.
36
+ *
37
+ * Safe to call unconditionally — silently no-ops if the runtime doesn't
38
+ * support compile caching or the fallback package isn't installed.
39
+ */
40
+ declare const enableCompileCache: () => void;
41
+ export { enableCompileCache as default };
@@ -0,0 +1 @@
1
+ var t=Object.defineProperty;var r=(e,a)=>t(e,"name",{value:a,configurable:!0});var c=Object.defineProperty,n=r((e,a)=>c(e,"name",{value:a,configurable:!0}),"o");const l=n(()=>{try{const e=require("node:module");if(typeof e.enableCompileCache=="function"){e.enableCompileCache();return}}catch{}try{require("v8-compile-cache")}catch{}},"enableCompileCache");export{l as default};
@@ -0,0 +1,18 @@
1
+ interface HeapTuningOptions {
2
+ /**
3
+ * Fraction of total system memory to allocate as `--max-old-space-size`.
4
+ * Must be between 0 and 1. Default: `0.75` (75%).
5
+ */
6
+ maxOldSpacePercent?: number;
7
+ }
8
+ /**
9
+ * Apply heap memory tuning to the current process.
10
+ *
11
+ * When tuning is needed, this function re-spawns the process with computed
12
+ * V8 memory flags and **never returns** — the parent exits with the child's
13
+ * exit code. When no tuning is needed (flags already set), it returns
14
+ * immediately.
15
+ * @param options Optional configuration for heap tuning.
16
+ */
17
+ declare const applyHeapTuning: (options?: HeapTuningOptions) => void;
18
+ export { type HeapTuningOptions, applyHeapTuning };
@@ -0,0 +1 @@
1
+ var h=Object.defineProperty;var p=(e,s)=>h(e,"name",{value:s,configurable:!0});import{createRequire as x}from"node:module";import{f as b,h as z,i as j,d as M,e as d}from"../../packem_shared/runtime-process-DKHFvYkv.js";const _=x(import.meta.url),o=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,g=p(e=>{if(typeof o<"u"&&o.versions&&o.versions.node){const[s,t]=o.versions.node.split(".").map(Number);if(s>22||s===22&&t>=3||s===20&&t>=16)return o.getBuiltinModule(e)}return _(e)},"__cjs_getBuiltinModule"),{execFileSync:y}=g("node:child_process"),{totalmem:S}=g("node:os");var P=Object.defineProperty,n=p((e,s)=>P(e,"name",{value:s,configurable:!0}),"r");const T=/--max-old-space-size=(\d+)/,q=/--max-semi-space-size=(\d+)/,A=n(e=>Math.floor(S()/1024/1024*e),"getDefaultMaxOldSpaceSize"),E=n(e=>e<=512?4:e<=1024?8:e<=2048?16:e<=4096?32:e<=8192?64:Math.floor(Math.log2(e))*8,"getSemiSpaceSize"),f=n((e,s)=>{for(const t of s){const i=e.exec(t);if(i)return Number.parseInt(i[1],10)}},"extractFlag"),H=n(e=>{const s=e?.maxOldSpacePercent??.75,t=[...b()],i=[...z()],a=f(T,t),c=f(q,t);if(a!==void 0&&c!==void 0)return;const l=a??A(s),m=c??E(l),r=[];if(a===void 0&&r.push(`--max-old-space-size=${String(l)}`),c===void 0&&r.push(`--max-semi-space-size=${String(m)}`),r.length!==0)try{y(j(),[...r,...t,...i.slice(1)],{env:M(),stdio:"inherit"}),d(0)}catch(v){const u=v.status;d(typeof u=="number"?u:1)}},"applyHeapTuning");export{H as applyHeapTuning};
package/package.json CHANGED
@@ -1,40 +1,38 @@
1
1
  {
2
2
  "name": "@visulima/cerebro",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.30",
4
4
  "description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
5
5
  "keywords": [
6
- "visulima",
7
- "command",
8
- "line",
9
- "class",
10
- "terminal",
11
6
  "ansi",
12
- "cli",
13
- "opts",
14
- "nopt",
15
- "options",
16
7
  "args",
8
+ "argument",
17
9
  "argv",
18
- "interactive",
19
- "commander",
20
10
  "clap",
11
+ "class",
12
+ "cli",
21
13
  "cli-app",
22
- "minimist",
14
+ "command",
23
15
  "command line apps",
24
16
  "command-line-usage",
25
- "option",
26
- "parser",
27
- "argument",
17
+ "commander",
28
18
  "flag",
29
19
  "gluegun",
20
+ "interactive",
21
+ "line",
30
22
  "meow",
23
+ "minimist",
24
+ "nopt",
31
25
  "oclif",
26
+ "option",
27
+ "options",
28
+ "opts",
29
+ "parser",
30
+ "terminal",
31
+ "visulima",
32
32
  "yargs"
33
33
  ],
34
34
  "homepage": "https://visulima.com/packages/cerebro",
35
- "bugs": {
36
- "url": "https://github.com/visulima/visulima/issues"
37
- },
35
+ "bugs": "https://github.com/visulima/visulima/issues",
38
36
  "repository": {
39
37
  "type": "git",
40
38
  "url": "git+https://github.com/visulima/visulima.git",
@@ -90,6 +88,14 @@
90
88
  "types": "./dist/plugins/update-notifier/update-notifier-plugin.d.ts",
91
89
  "default": "./dist/plugins/update-notifier/update-notifier-plugin.js"
92
90
  },
91
+ "./compile-cache": {
92
+ "types": "./dist/util/general/compile-cache.d.ts",
93
+ "default": "./dist/util/general/compile-cache.js"
94
+ },
95
+ "./heap-tuning": {
96
+ "types": "./dist/util/general/heap-tuning.d.ts",
97
+ "default": "./dist/util/general/heap-tuning.js"
98
+ },
93
99
  "./logger/pail": {
94
100
  "types": "./dist/logger/create-pail-logger.d.ts",
95
101
  "default": "./dist/logger/create-pail-logger.js"
@@ -103,15 +109,15 @@
103
109
  "LICENSE.md"
104
110
  ],
105
111
  "dependencies": {
106
- "@visulima/colorize": "2.0.0-alpha.3",
107
- "@visulima/tabular": "4.0.0-alpha.3",
112
+ "@visulima/colorize": "2.0.0-alpha.13",
113
+ "@visulima/tabular": "4.0.0-alpha.13",
108
114
  "fastest-levenshtein": "^1.0.16"
109
115
  },
110
116
  "peerDependencies": {
111
- "@bomb.sh/tab": "^0.0.7",
112
- "@visulima/boxen": "3.0.0-alpha.3",
113
- "@visulima/find-cache-dir": "3.0.0-alpha.2",
114
- "@visulima/pail": "4.0.0-alpha.3",
117
+ "@bomb.sh/tab": "0.0.15",
118
+ "@visulima/boxen": "3.0.0-alpha.12",
119
+ "@visulima/find-cache-dir": "3.0.0-alpha.11",
120
+ "@visulima/pail": "4.0.0-alpha.20",
115
121
  "github-slugger": "2.0.0"
116
122
  },
117
123
  "peerDependenciesMeta": {
@@ -132,7 +138,7 @@
132
138
  }
133
139
  },
134
140
  "engines": {
135
- "node": ">=22.13 <=25.x"
141
+ "node": "^22.14.0 || >=24.10.0"
136
142
  },
137
143
  "os": [
138
144
  "darwin",
package/dist/cli.d.ts DELETED
@@ -1,203 +0,0 @@
1
- import PluginManager from "./plugin-manager.d.ts";
2
- import type { Cli as ICli, CliRunOptions, CommandSection as ICommandSection, RunCommandOptions } from "./types/cli.d.ts";
3
- import type { Command as ICommand, OptionDefinition } from "./types/command.d.ts";
4
- import type { Plugin } from "./types/plugin.d.ts";
5
- export type CliOptions<T extends Console = Console> = {
6
- argv?: ReadonlyArray<string>;
7
- cwd?: string;
8
- logger?: T;
9
- packageName?: string;
10
- packageVersion?: string;
11
- };
12
- export declare class Cli<T extends Console = Console> implements ICli<T> {
13
- #private;
14
- /**
15
- * Create a new CLI instance.
16
- * @param cliName
17
- * @param options The options for the CLI.
18
- * @param options.argv The command line arguments.
19
- * @param options.cwd The current working directory.
20
- * @param options.logger The logger to use.
21
- * @param options.packageName
22
- * @param options.packageVersion
23
- */
24
- constructor(cliName: string, options?: CliOptions<T>);
25
- /**
26
- * Sets the command section configuration for help display.
27
- *
28
- * This affects how the CLI name and version are displayed in help output.
29
- * @param commandSection The command section configuration
30
- * @returns The CLI instance for method chaining
31
- * @example
32
- * ```typescript
33
- * cli.setCommandSection({
34
- * header: 'My App v2.0.0',
35
- * footer: 'For more info, visit https://example.com'
36
- * });
37
- * ```
38
- */
39
- setCommandSection(commandSection: ICommandSection): this;
40
- /**
41
- * Gets the current command section configuration.
42
- * @returns The command section configuration
43
- */
44
- getCommandSection(): ICommandSection;
45
- /**
46
- * Sets the default command to run when no command is specified.
47
- *
48
- * By default, this is set to 'help'. The command must already be registered
49
- * with the CLI instance.
50
- * @param commandName The command name to use as the default
51
- * @returns The CLI instance for method chaining
52
- * @example
53
- * ```typescript
54
- * cli.setDefaultCommand('start');
55
- * ```
56
- */
57
- setDefaultCommand(commandName: string): this;
58
- /**
59
- * Gets the current default command.
60
- * @returns The name of the default command
61
- */
62
- get defaultCommand(): string;
63
- /**
64
- * Adds a command to the CLI.
65
- *
66
- * Commands define the available operations that users can execute.
67
- * Each command can have options, arguments, aliases, and custom execution logic.
68
- * @template OD - The option definition type for the command
69
- * @param command The command configuration object
70
- * @returns The CLI instance for method chaining
71
- * @throws {CerebroError} If the command name already exists or validation fails
72
- * @example
73
- * ```typescript
74
- * cli.addCommand({
75
- * name: 'build',
76
- * description: 'Build the project',
77
- * options: [
78
- * {
79
- * name: 'output',
80
- * alias: 'o',
81
- * type: String,
82
- * description: 'Output directory'
83
- * }
84
- * ],
85
- * execute: ({ options }) => {
86
- * console.log(`Building to ${options.output || 'dist'}`);
87
- * }
88
- * });
89
- * ```
90
- */
91
- addCommand<OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: ICommand<OD, T>): this;
92
- /**
93
- * Adds a plugin to extend the CLI functionality.
94
- *
95
- * Plugins can hook into various lifecycle events and modify the toolbox
96
- * to provide additional functionality to commands.
97
- * @param plugin The plugin to register
98
- * @returns The CLI instance for method chaining
99
- * @example
100
- * ```typescript
101
- * cli.addPlugin({
102
- * name: 'logger',
103
- * execute: (toolbox) => {
104
- * toolbox.logger = createCustomLogger();
105
- * }
106
- * });
107
- * ```
108
- */
109
- addPlugin(plugin: Plugin<T>): this;
110
- /**
111
- * Gets the plugin manager instance for advanced plugin management.
112
- * @returns The plugin manager instance
113
- */
114
- getPluginManager(): PluginManager<T>;
115
- /**
116
- * Gets the CLI application name.
117
- */
118
- getCliName(): string;
119
- /**
120
- * Gets the package version if configured.
121
- * @returns The package version or undefined
122
- */
123
- getPackageVersion(): string | undefined;
124
- /**
125
- * Gets the package name if configured.
126
- * @returns The package name or undefined
127
- */
128
- getPackageName(): string | undefined;
129
- /**
130
- * Gets all registered commands.
131
- * @returns A map of command names to command definitions
132
- */
133
- getCommands(): Map<string, ICommand<OptionDefinition<unknown>, T>>;
134
- /**
135
- * Gets the current working directory.
136
- * @returns The current working directory path
137
- */
138
- getCwd(): string;
139
- /**
140
- * Disposes the CLI instance and cleans up resources.
141
- *
142
- * This method removes event listeners and performs cleanup to prevent memory leaks.
143
- * Call this method when the CLI instance is no longer needed, especially in long-running
144
- * processes or when creating multiple CLI instances.
145
- * @example
146
- * ```typescript
147
- * const cli = new Cerebro('my-app');
148
- * // ... use the cli
149
- * cli.dispose(); // Clean up when done
150
- * ```
151
- */
152
- dispose(): void;
153
- /**
154
- * Runs the CLI application.
155
- *
156
- * This method parses command line arguments, executes the appropriate command,
157
- * and handles the complete CLI lifecycle including plugin initialization,
158
- * error handling, process termination, and automatic cleanup.
159
- * @param extraOptions Additional options to pass to commands
160
- * @param extraOptions.shouldExitProcess Whether to exit the process after execution (default: true)
161
- * @param extraOptions.autoDispose Whether to automatically cleanup/dispose resources after execution (default: true)
162
- * @returns A promise that resolves when execution completes
163
- * @throws {CommandNotFoundError} If the specified command doesn't exist
164
- * @throws {Error} If command arguments are invalid or conflicting options are provided
165
- * @example
166
- * ```typescript
167
- * // Run with default behavior (exits process and auto-disposes)
168
- * await cli.run();
169
- *
170
- * // Run without exiting (for testing)
171
- * await cli.run({ shouldExitProcess: false });
172
- *
173
- * // Run without auto-disposing (for reuse)
174
- * await cli.run({ autoDispose: false });
175
- * ```
176
- */
177
- run(extraOptions?: CliRunOptions): Promise<void>;
178
- /**
179
- * Runs a command programmatically from within another command.
180
- *
181
- * This method allows commands to call other commands during execution,
182
- * enabling composition of commands and reusable command logic.
183
- * @param commandName The name of the command to execute
184
- * @param options Optional options including argv and other command options
185
- * @returns A promise that resolves with the command's result
186
- * @throws {CommandNotFoundError} If the specified command doesn't exist
187
- * @throws {CerebroError} If command validation fails
188
- * @example
189
- * ```typescript
190
- * cli.addCommand({
191
- * name: 'deploy',
192
- * execute: async ({ runtime, logger }) => {
193
- * logger.info('Building...');
194
- * await runtime.runCommand('build', { argv: ['--production'] });
195
- *
196
- * logger.info('Testing...');
197
- * await runtime.runCommand('test', { argv: ['--coverage'] });
198
- * }
199
- * });
200
- * ```
201
- */
202
- runCommand(commandName: string, options?: RunCommandOptions): Promise<unknown>;
203
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Output with this option will be formatted.
3
- */
4
- export declare const OUTPUT_NORMAL = 1;
5
- /**
6
- * Output with this option will be passed as-is.
7
- */
8
- export declare const OUTPUT_RAW = 2;
9
- /**
10
- * Output with this option will have any formatting stripped away.
11
- */
12
- export declare const OUTPUT_PLAIN = 4;
13
- /**
14
- * Output with this verbosity won't write anything at all.
15
- */
16
- export declare const VERBOSITY_QUIET = 16;
17
- /**
18
- * Output with this verbosity will write default content.
19
- */
20
- export declare const VERBOSITY_NORMAL = 32;
21
- /**
22
- * Output with this verbosity will be more detailed.
23
- */
24
- export declare const VERBOSITY_VERBOSE = 64;
25
- /**
26
- * Output with this verbosity will reveal internals.
27
- */
28
- export declare const VERBOSITY_DEBUG = 128;
29
- export declare const POSITIONALS_KEY = "positionals";
@@ -1,7 +0,0 @@
1
- import type { EnvDefinition } from "./types/command.d.ts";
2
- /**
3
- * Default environment variables used by Cerebro CLI framework.
4
- * These are displayed in the help output.
5
- */
6
- declare const defaultEnv: (EnvDefinition<string> | EnvDefinition<number> | EnvDefinition<boolean>)[];
7
- export default defaultEnv;
@@ -1,3 +0,0 @@
1
- import type { OptionDefinition } from "./types/command.d.ts";
2
- declare const defaultOptions: OptionDefinition<boolean>[];
3
- export default defaultOptions;
@@ -1,15 +0,0 @@
1
- import type { Toolbox as IToolbox } from "./types/toolbox.d.ts";
2
- declare class EmptyToolbox implements Partial<IToolbox> {
3
- [x: string]: unknown;
4
- result?: unknown;
5
- argv?: IToolbox["argv"];
6
- options?: IToolbox["options"];
7
- argument?: IToolbox["argument"];
8
- command: IToolbox["command"];
9
- commandName: IToolbox["commandName"];
10
- env?: IToolbox["env"];
11
- logger?: IToolbox["logger"];
12
- runtime?: IToolbox["runtime"];
13
- constructor(commandName: IToolbox["commandName"], command: IToolbox["command"]);
14
- }
15
- export default EmptyToolbox;
@@ -1,10 +0,0 @@
1
- import { VisulimaError } from "@visulima/error";
2
- /**
3
- * Base error class for Cerebro CLI operations.
4
- */
5
- declare class CerebroError extends VisulimaError {
6
- readonly code: string;
7
- readonly context?: Record<string, unknown>;
8
- constructor(message: string, code: string, context?: Record<string, unknown>);
9
- }
10
- export default CerebroError;