{"id":17508,"library":"base-cli-schema","title":"Base CLI Schema","description":"This package provides a schema definition and normalization utility specifically designed for the `base-cli` plugin. Its primary function is to process and normalize command-line argument values (`argv`) before they are consumed by `cli.process()` within a `base` application. It allows for defining custom fields with specified types (e.g., 'string') and provides a `normalize` function that applies these definitions, including custom normalizer functions, to an `argv` object. The package is currently at version 0.1.19 and was last published in May 2016. Given its age and low version number, the release cadence is effectively inactive, indicating it is no longer actively maintained. Key differentiators include its tight integration with the `base` framework and its focused purpose of defining and applying schemas for CLI arguments, offering a structured approach to argument normalization within the `base` ecosystem, unlike more general-purpose validation libraries.","status":"abandoned","version":"0.1.19","language":"javascript","source_language":"en","source_url":"https://github.com/jonschlinkert/base-cli-schema","tags":["javascript","base","baseplugin","cli","normalize","plugin","schema"],"install":[{"cmd":"npm install base-cli-schema","lang":"bash","label":"npm"},{"cmd":"yarn add base-cli-schema","lang":"bash","label":"yarn"},{"cmd":"pnpm add base-cli-schema","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Core framework this schema plugin integrates with, required for initialization.","package":"base","optional":false},{"reason":"Used for parsing raw command-line arguments (process.argv) into an object before schema normalization.","package":"minimist","optional":false}],"imports":[{"note":"This package is CommonJS-only and does not support ES Modules. Attempting to import using `import` syntax will result in an error in ES Module environments.","wrong":"import cliSchema from 'base-cli-schema';","symbol":"cliSchema","correct":"const cliSchema = require('base-cli-schema');"},{"note":"The `base` framework, a key dependency, is also CommonJS-only.","wrong":"import Base from 'base';","symbol":"Base","correct":"const Base = require('base');"},{"note":"The `minimist` package, used for argv parsing, is typically consumed via CommonJS `require` in contexts where `base-cli-schema` is used.","wrong":"import minimist from 'minimist';","symbol":"minimist","correct":"const minimist = require('minimist');"}],"quickstart":{"code":"const argv = require('minimist')(process.argv.slice(2));\nconst Base = require('base');\nconst cliSchema = require('base-cli-schema');\nconst cli = require('base-cli'); // Assuming base-cli is also required for app.use(cli())\n\nconst app = new Base();\napp.use(cli()); // Attach the cli plugin to the base application\n\nconst schema = cliSchema(app);\n\n// Define a custom field for demonstration\nschema.field('foo', 'string', {\n  normalize: function(val, key, config, schema) {\n    // Example normalization: always return 'bar' for 'foo'\n    return val ? val.toUpperCase() : 'bar';\n  }\n});\n\n// Simulate argv input, e.g., 'node your-script.js --foo=test --other=value'\nconst mockArgv = { foo: 'hello', other: 'world' };\n\nconst obj = schema.normalize(mockArgv);\nconsole.log(obj);\n// Expected output: { foo: 'HELLO', other: 'world' } (if --foo=hello was passed)\n// or { foo: 'BAR' } if --foo was not passed and 'bar' is default/fallback\n","lang":"javascript","description":"Demonstrates initializing a `base` application, attaching `base-cli`, creating a `cliSchema` instance, defining a custom field with a normalizer, and using it to process a mock argv object."},"warnings":[{"fix":"Use a CommonJS environment or project. For ESM projects, consider alternative, more modern CLI argument parsing and schema validation libraries. If absolutely necessary, configure a CommonJS-to-ESM wrapper or bundler like Webpack/Rollup with appropriate plugins (e.g., `@rollup/plugin-commonjs`).","message":"This package, including its core dependency `base`, is CommonJS-only. It does not support ES Modules (ESM) and will cause runtime errors if directly imported or `require`d within an ESM context without specific transpilation or loader configurations.","severity":"breaking","affected_versions":"All versions"},{"fix":"Evaluate if the functionality can be replaced by a more actively maintained library or custom code. If continued use is critical, ensure thorough testing against your specific Node.js version and dependencies. Be aware of potential unpatched vulnerabilities.","message":"The package is effectively abandoned, with its last publish in 2016. This means there will be no new features, bug fixes, or security updates. It may not be compatible with newer Node.js versions or ecosystem changes.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Familiarize yourself with the `base` framework's documentation. Ensure all necessary `base` plugins (like `base-cli`) are correctly installed and used with `app.use()`.","message":"Heavy reliance on the `base` framework, which itself is an older, less commonly used architecture in modern Node.js development. Understanding `base`'s plugin system is crucial for effective use of `base-cli-schema`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-23T00:00:00.000Z","next_check":"2026-07-22T00:00:00.000Z","problems":[{"fix":"Change your file to a CommonJS module (`.js` without `type: \"module\"`) or use a tool like `createRequire` from the `module` module if you must mix ESM and CJS (e.g., `import { createRequire } from 'module'; const require = createRequire(import.meta.url); const cliSchema = require('base-cli-schema');`). Ideally, migrate to an ESM-compatible alternative.","cause":"Attempting to use `require('base-cli-schema')` (a CommonJS module) within an ES Module file (`.mjs` or `type: \"module\"` in `package.json`).","error":"ReferenceError: require is not defined in ES module scope"},{"fix":"Ensure `const Base = require('base');` and `const cli = require('base-cli');` are present, and that `app.use(cli());` is called on your `new Base()` instance before using `cliSchema`.","cause":"The `base` instance (`app`) was not correctly initialized or the `base-cli` plugin was not properly `require`d and passed to `app.use()`.","error":"TypeError: app.use is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}