Skip to content

Configuration Options

Create Your App provides various configuration options to customize your project creation and component generation. This page documents all available configuration options.

Project Configuration

When creating a project, you can configure it using command-line options or by answering the interactive prompts.

Command-line Options

bash
npx @rjkt/create-your-app create <project-name> [options]
OptionDescriptionDefault
-t, --template <template>Specify the template to usereact-webpack
-p, --package-manager <manager>Specify the package manager to use (npm, yarn, or pnpm)Detected from environment
-s, --skip-installSkip installing dependenciesfalse
-g, --gitInitialize a git repositorytrue
--no-gitSkip git initializationfalse
-f, --forceOverwrite target directory if it existsfalse
-v, --verbosePrint additional logsfalse

Configuration File

You can create a configuration file in your project to customize the behavior of Create Your App. Create a file named .createyourapprc.js or .createyourapprc.json in your project root.

.createyourapprc.js Example

js
module.exports = {
  // Default template to use when creating components
  componentTemplate: 'function',

  // Default style type for components
  styleType: 'css',

  // Default path for components
  componentPath: 'src/components',

  // Custom templates for components
  templates: {
    component: {
      function: './templates/component-function.js',
      class: './templates/component-class.js'
    },
    style: {
      css: './templates/style-css.js',
      scss: './templates/style-scss.js'
    }
  },

  // Package manager to use
  packageManager: 'npm',

  // Whether to initialize git
  git: true,

  // Whether to install dependencies
  skipInstall: false,

  // Whether to print verbose logs
  verbose: false
};

.createyourapprc.json Example

json
{
  "componentTemplate": "function",
  "styleType": "css",
  "componentPath": "src/components",
  "templates": {
    "component": {
      "function": "./templates/component-function.js",
      "class": "./templates/component-class.js"
    },
    "style": {
      "css": "./templates/style-css.js",
      "scss": "./templates/style-scss.js"
    }
  },
  "packageManager": "npm",
  "git": true,
  "skipInstall": false,
  "verbose": false
}

Component Configuration

When generating components, you can configure them using command-line options:

bash
npx @rjkt/create-your-app component <component-name> [options]
OptionDescriptionDefault
--type <type>Component type (function or class)function
--style <style>Style type (css, scss, less, or none)css
--path <path>Path to create the componentsrc/components
--testGenerate test filetrue
--storyGenerate Storybook story filefalse
--no-styleSkip generating style filefalse
--no-testSkip generating test filefalse
--no-storySkip generating Storybook story filetrue

Template Configuration

Each template has its own configuration options. You can find the specific configuration options for each template in the template documentation:

Environment Variables

Create Your App respects the following environment variables:

VariableDescription
CYA_TEMPLATEDefault template to use
CYA_PACKAGE_MANAGERDefault package manager to use
CYA_SKIP_INSTALLWhether to skip installing dependencies
CYA_GITWhether to initialize git
CYA_VERBOSEWhether to print verbose logs
CYA_COMPONENT_TEMPLATEDefault component template to use
CYA_STYLE_TYPEDefault style type for components
CYA_COMPONENT_PATHDefault path for components

Example:

bash
CYA_TEMPLATE=react-webpack CYA_PACKAGE_MANAGER=yarn npx @rjkt/create-your-app create my-app

基于 MIT 许可发布