### Start Backend Service (Command Line) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to start the backend service after installing dependencies and configuring the .env file. Ensure MySQL and Redis services are running. ```bash npm run start ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Commands to navigate to the frontend directory and install its Node.js dependencies. ```bash cd tiny-pro/web npm i ``` -------------------------------- ### TinyCLI Local Development Setup Source: https://github.com/opentiny/tiny-cli/blob/dev/CONTRIBUTING.zh-CN.md Steps to set up the TinyCLI project locally for development. This includes forking the repository, cloning, installing dependencies, and starting the development server. ```Shell git clone git@github.com:username/tiny-cli.git cd tiny-cli git remote add upstream git@github.com:opentiny/tiny-cli.git npm i # 启动项目 npm run dev ``` -------------------------------- ### Configure Backend Environment Variables (Command Line) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Example .env file for backend services when starting via command line. Configure database connection details, authentication secrets, Redis settings, and pagination defaults. ```properties # 数据库IP DATABASE_HOST = 'localhost' # 数据库端口 DATABASE_PORT = 3306 # 数据库用户名 DATABASE_USERNAME = 'root' # 数据库密码 DATABASE_PASSWORD = 'root' # 数据库名 (请确保该库存在) DATABASE_NAME = 'ospp-nest' # 请阅读: https://www.typeorm.org/migrations # 线上环境请关闭 DATABASE_SYNCHRONIZE = true DATABASE_AUTOLOADENTITIES = true # jwt secret AUTH_SECRET = 'secret' REDIS_SECONDS = 7200 # redis ip REDIS_HOST = 'localhost' # redis 端口 REDIS_PORT = 6379 # token过期时间 EXPIRES_IN = '2h' # 分页默认起始页 (一般可以不修改) PAGINATION_PAGE = 1 # 分页默认大小 PAGINATION_LIMIT = 10 ``` -------------------------------- ### Install Backend Dependencies Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to install Node.js dependencies for the backend service. ```bash npm i ``` -------------------------------- ### Start Frontend Service Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to start the frontend development server. Ensure backend services are running and mock services are optionally started. ```bash npm run start ``` -------------------------------- ### Start Backend with Docker Compose Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to start backend services using Docker Compose after configuring the .env file. Ensures all containers (backend, redis, mysql) are running. ```bash docker compose up -d ``` -------------------------------- ### Configure Backend Environment Variables (Docker) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Example .env file for backend services when using Docker. Configure database connection details, authentication secrets, Redis settings, and pagination defaults. ```properties # 数据库IP DATABASE_HOST = 'mysql' # 数据库端口 DATABASE_PORT = 3306 # 数据库用户名 DATABASE_USERNAME = 'root' # 数据库密码 DATABASE_PASSWORD = 'root' # 数据库名 (请确保该库存在) DATABASE_NAME = 'ospp-nest' # 请阅读: https://www.typeorm.org/migrations # 线上环境请关闭 DATABASE_SYNCHRONIZE = true DATABASE_AUTOLOADENTITIES = true # jwt secret AUTH_SECRET = 'secret' REDIS_SECONDS = 7200 # redis ip REDIS_HOST = 'redis' # redis 端口 REDIS_PORT = 6379 # token过期时间 EXPIRES_IN = '2h' # 分页默认起始页 (一般可以不修改) PAGINATION_PAGE = 1 # 分页默认大小 PAGINATION_LIMIT = 10 ``` -------------------------------- ### Build Frontend Project Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to build the frontend project for production deployment. ```bash npm run build ``` -------------------------------- ### Initialize Tiny Pro Project Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to initialize a new Tiny Pro project. Follow the prompts to configure project name, description, client/server stacks, build tools, and database settings. ```bash tiny init pro ``` -------------------------------- ### Start Backend Development Server Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro-backend-dev-guideline.md This section describes how to start the backend development server using npm. It also provides the expected output upon successful startup, indicating the application is running and on which port. ```shell npm run start:dev ``` ```text LOG [NestApplication] Nest application successfully started +11ms Application is running on: http://[::1]:3000 ``` -------------------------------- ### Build Backend Service (Command Line) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to build the backend service using npm. ```bash npm run build ``` -------------------------------- ### Configure Frontend Proxy for CORS Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Example of configuring the Vite dev-server's proxy setting to handle frontend cross-origin resource sharing (CORS) issues during development. ```text 对于开发环境来说,可以直接修改`dev-server`的`proxy`. 例如`vite`工具的`server.proxy` ``` -------------------------------- ### Commit Message Guidelines Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Recommendation to follow Angular commit message conventions or remove Husky if code submission is problematic. ```text 您可以选择移除husky或根据[Angular 规范](https://zj-git-guide.readthedocs.io/zh-cn/latest/message/Angular%E6%8F%90%E4%BA%A4%E4%BF%A1%E6%81%AF%E8%A7%84%E8%30%83/)书写commit信息 ``` -------------------------------- ### Clone and Run TinyCLI Locally Source: https://github.com/opentiny/tiny-cli/blob/dev/CONTRIBUTING.md Steps to clone the TinyCLI repository, install dependencies, and run the local development server. This involves forking the repository, cloning it, installing npm packages, and starting the development environment. ```shell # You need to replace username with your own user name git clone git@github.com:username/tiny-cli.git cd tiny-cli git remote add upstream git@github.com:opentiny/tiny-cli.git npm i # Launch npm run dev ``` -------------------------------- ### Build Backend Service (Docker) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to build a Docker image for the backend service. Assumes default configurations; modify Dockerfile if system-level dependencies like node-gyp are added. ```bash docker build -t tinypro:latest ``` -------------------------------- ### Resolve Frontend 404 After Deployment Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Guidance for resolving 404 errors on refreshed pages after deploying a Vue application. Links to Vue Router server deployment configurations. ```text 请移步[Vue Router服务器部署指南](https://router.vuejs.org/guide/essentials/history-mode.html#Example-Server-Configurations) ``` -------------------------------- ### Troubleshoot Docker Port Conflict Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Solution for Docker port conflicts (e.g., port 3306 already in use). Release the port on the host machine or manually start the service. ```text Error response from daemon: Ports are not available: exposing port TCP 0.0.0.0:3306 -> 0.0.0.0:0: listen tcp 0.0.0.0:3306: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted. ``` -------------------------------- ### Handle Initialization Lock File Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Instructions to resolve the 'Lock file exists' error during initialization. Delete the 'dist/app/lock' file or the entire 'dist' folder to re-initialize. ```text Lock file exists, if you want init agin, please remove dist or dist/lock ``` -------------------------------- ### Address Docker Deployment Database Timeout Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Guidance for database timeouts in Docker deployments when using `docker-compose.yaml`. Restart the backend service manually after the MySQL container is confirmed to be running. ```text `docker-compose.yaml`实际上配置了`depends_on`字段,但`mysql`镜像并没有提供对应的健康检查。如果服务挂掉,可以等待`mysql`启动成功后手动重启后端服务 ``` -------------------------------- ### Tiny CLI Help and Basic Commands Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-cli.md Displays the overall help information for the Tiny CLI and lists available basic commands. It shows how to get help, initialize toolkits, update modules, list plugins, install npm modules, clear cache, and access plugin commands. ```bash $ tiny -h tiny 使用帮助: $ tiny [command] [options] $ tiny 显示tiny帮助信息,若目录下有使用的套件,则会同时显示套件的帮助信息 $ tiny init [toolkitName] 初始化套件 $ tiny update [name] 更新tiny模块 $ tiny list [type] 插件列表 $ tiny i 安装npm模块 $ tiny clear 清空 tiny 的本地缓存 $ tiny help 显示套件帮助信息 $ tiny [name] 其他调用插件命令 ``` -------------------------------- ### Quick Start: Initialize Project Source: https://github.com/opentiny/tiny-cli/blob/dev/README.md Initializes a new project using the Tiny CLI with the 'dev' toolkit. This involves creating a project folder and then running the initialization command within it. ```bash # Create and enter the project folder $ mkdir my-project && cd $_ # Initializing the Dev Development Environment $ tiny init dev ``` -------------------------------- ### Install Tiny Modules (Packages and Plugins) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-cli.md Installs Tiny modules, including toolkits and plugins. This command is similar to `npm i` or `npm install` but utilizes `pnpm` for faster installation. It supports installing specific modules by name, installing all dependencies listed in `package.json`, or installing specific versions of modules. ```bash $ tiny install [name] ``` ```bash # 安装jquery 到项目中 $ tiny i jquery -S # 安装package.json中的依赖 $ tiny i # 安装 4.2.0版本的 co模块 $ tiny i co@4.2.0 ``` -------------------------------- ### Quick Start: Start Local Environment Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Starts the local development environment for the 'dev' toolkit after project initialization. This command is used to run the project locally during development. ```bash # 开启dev的开发环境 $ tiny start ``` -------------------------------- ### Check Docker Backend Status Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Command to verify if backend Docker containers are running successfully. Look for 'Up' status in the STATUS column. ```bash docker ps ``` -------------------------------- ### Quick Start: Start Local Environment Source: https://github.com/opentiny/tiny-cli/blob/dev/README.md Enables the local development environment for a project initialized with Tiny CLI. This command is used to run the project locally for development and debugging. ```bash # Enabling the Dev Development Environment $ tiny start ``` -------------------------------- ### Troubleshoot Docker I/O Timeout Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro.md Commands to pull necessary Docker images (node:alpine, node:lts) to resolve I/O timeout errors during `docker compose up -d`. ```bash docker pull node:alpine docker pull node:lts ``` -------------------------------- ### Quick Start: Build Project Source: https://github.com/opentiny/tiny-cli/blob/dev/README.md Compiles and packages the project using the Tiny CLI. This command is typically used after development to prepare the project for deployment. ```bash $ tiny build ``` -------------------------------- ### Quick Start: Initialize Project Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Initializes a new project using the 'dev' toolkit. This involves creating a project directory and then running the 'tiny init dev' command within it. ```bash # 创建并进入项目文件夹 $ mkdir my-project && cd $_ # 初始化dev的开发环境 $ tiny init dev ``` -------------------------------- ### Install Tiny CLI Source: https://github.com/opentiny/tiny-cli/blob/dev/README.md Installs the Tiny CLI globally using npm. Ensure Node.js (12.x or later) and npm are installed beforehand. After installation, verify by checking the version. ```bash $ npm i @opentiny/cli -g ``` -------------------------------- ### Quick Start: Build Project Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Compiles and packages the project. This command is used to build the project for deployment or distribution. ```bash $ tiny build ``` -------------------------------- ### Install Tiny CLI Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Installs the Tiny CLI globally using npm. Ensure you have Node.js (v12.x or higher) and npm installed before running this command. After installation, verify by checking the version. ```bash $ npm i @opentiny/cli -g ``` -------------------------------- ### Basic tiny.config.js Structure Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-config.md This snippet shows the fundamental structure of a tiny.config.js file, including the toolkitName, task definitions for 'start', 'build', and 'publish', and an example of CI plugin configuration for webpack. ```javascript // tiny.config.js module.exports = { // 组件所使用的tiny toolkit toolkitName: '@opentiny/tiny-toolkit-xxx', tasks: { start: [ { // 使用tiny link插件将当前目录链接到tiny 本地cdn目录 command: 'tiny link' } ], build: [ { // 执行自定义脚本 command: 'node custom.js' } ], publish: [ { command: 'npm publish' } ] }, // ci 插件所需的配置 ci: { // 返回项目中的webpack配置 getWebpackConfig() { return require('./webpack.config').dev(); } } }; ``` -------------------------------- ### Verify Node.js and npm Installation Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-install.md Commands to check if Node.js and npm are installed and to view their versions. This is a prerequisite for installing the OpenTiny CLI. ```Bash $ node -v v16.18.1 $ npm -v 8.19.2 ``` -------------------------------- ### Config Get Example Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Demonstrates how to retrieve specific configuration values from the tiny.config.js file using the config.get() method. It shows accessing nested properties. ```javascript import { config } from '@opentiny/cli-devkit' //获取配置文件中go字段的内容 config.get('go'); // => 返回 { projectId : 85932, assetsId : 21443 } ``` -------------------------------- ### Tiny CLI Help Information Source: https://github.com/opentiny/tiny-cli/blob/dev/README.md Displays the help information for the Tiny CLI, including available commands, options, and usage examples. It also shows how to view help for toolkits and plugins. ```bash tiny help info: $ tiny [command] [options] $ tiny The help information is displayed. If a toolkit is used in the directory, the help information of the toolkit is also displayed. $ tiny init [toolkitName] Initialization Kit $ tiny update [name] Update module $ tiny list [type] Plug-in list $ tiny i Installing the NPM Module $ tiny clear Clear the local cache of Tiny. $ tiny help Displays suite help information. $ tiny [name] Other Invoking Plug-in Commands Options: -h, --help Displays help information. -v, --version Show Tiny Version Hint: Toolkits - To view help information about toolkits used in your project, execute this command in the project root directory. Plugins - To view the help information about the plugin, run the tiny [name] help command, for example, tiny git help. ``` -------------------------------- ### Install npm Package Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Installs an npm package using the npm.install function. Supports specifying package versions and configuring registry and stdio options. ```javascript import { npm } from '@opentiny/cli-devkit'; await npm.install('tiny'); await npm.install('tiny@2.7.7'); ``` -------------------------------- ### CLI Task Configuration Example Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tool-design.md Illustrates how to define a series of tasks for the CLI tool in a configuration file (e.g., config.js). Tasks can include running scripts, installing dependencies, or executing other CLI commands, with options for asynchronous execution. ```javascript // config.js module.exports = { tasks: { init: [{ // 清除临时文件 command: 'node tools/clean.js' }, { // 安装依赖 command: 'npm install' }, ] start: [{ // 开启服务 command: 'node tools/server.js' }, { // 监听文件变化 command: 'watch', }, { // 异步开启前端资源代理服务 command: 'proxy start --enable', async: true }], build: [{ // 基于webpack构建 command: 'webpack', }, ], test: [{ // 执行eslint command: 'eslint', }, ], }, }; ``` -------------------------------- ### Install CLI Devkit Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Installs the @opentiny/cli-devkit package as a dependency for your project using npm. ```bash tiny i @opentiny/cli-devkit --save ``` -------------------------------- ### Plugin Configuration Example (awp) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-config.md Illustrates how to configure specific plugins, using 'awp' as an example. Each plugin's configuration is nested under a field with the same name as the plugin. ```javascript { awp: { dailyAppID: 554, onlineAppID: 219, appDir: 'mcm', awpBuildDir: 'build' } } ``` -------------------------------- ### Verify Official Version Installation Source: https://github.com/opentiny/tiny-cli/wiki/@opentiny-tiny‐tookit‐pro-包发布说明 This section demonstrates how to install the latest official version of a package and verify its installation by checking the package.json file. ```bash tiny install @opentiny/tiny-toolkit-pro cat ~/.tiny/node_modules/@opentiny/tiny-toolkit-pro/package.json ``` -------------------------------- ### Verify OpenTiny CLI Installation Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-install.md Command to check if the OpenTiny CLI has been installed successfully and to view its version. ```Bash $ tiny -v tiny v1.x.x ``` -------------------------------- ### Start Local Development Server with Tiny CLI Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-toolkit.md Starts a local development server for the project. This command often includes features like hot-reloading, where changes to project files are automatically compiled and reflected in the browser, facilitating rapid development and debugging. ```bash # Start development environment $ tiny start ``` -------------------------------- ### Development: Install Lerna Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Installs Lerna globally, which is a prerequisite for local development and debugging of the Tiny CLI. Lerna is a tool for managing JavaScript projects with multiple packages. ```bash npm install --global lerna ``` -------------------------------- ### Configure npm Registry and Verify Installation Source: https://github.com/opentiny/tiny-cli/wiki/@opentiny-tiny‐tookit‐pro-包发布说明 This section provides commands to configure the npm registry to the official npm registry and list the current configuration. It also shows how to install a specific version of a package and check its package.json file. ```bash tiny config set registry https://registry.npmjs.org/ tiny config list tiny install @opentiny/tiny-toolkit-pro@1.0.20-alpha.0 cat ~/.tiny/node_modules/@opentiny/tiny-toolkit-pro/package.json ``` -------------------------------- ### Install OpenTiny Module Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Installs an OpenTiny module. A specific version can be specified by appending it to the module name (e.g., 'gulp@1.0.0'). ```javascript import { modules } from '@opentiny/cli-devkit'; await modules.install(name); ``` -------------------------------- ### Initialize Tiny Toolkit Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-cli.md Initializes a Tiny toolkit. The `toolkitName` parameter specifies the name of the toolkit to be initialized, typically following the format `tiny-toolkit-{toolkitName}`. The command automatically checks if the toolkit is installed locally and installs it if necessary before proceeding with initialization. ```bash $ tiny init [toolkitName] ``` ```bash # 创建一个叫toolkit-demo的空文件夹,并进入该文件夹 $ mkdir toolkit-demo && cd $_ # 初始化dev套件 $ tiny init dev ``` -------------------------------- ### Use Cache and Logs APIs Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Demonstrates how to import and use the cache and logs objects from the @opentiny/cli-devkit. It shows examples of logging information and setting/getting cache values. ```javascript const { cache , logs } = require('@opentiny/cli-devkit'); const log = logs; log.info('啦啦啦'); cache.set('ff', 'ee'); cache.get('ff'); ``` -------------------------------- ### Get OpenTiny Module Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Fetches an OpenTiny module. If the module is not installed locally, it will be automatically installed. It can also fetch package.json information for a module. ```javascript import { modules } from '@opentiny/cli-devkit'; const blue = await modules.get('@opentiny/tiny-toolkit-blue'); // blue 为blue套件时是一个对象,下面挂载几个命令对应的函数 yield blue.build(tinyObj, { clientArgs: ['index'] }); // 获取模块手 package.json 信息 import { modules } from '@opentiny/cli-devkit'; const pkg = await modules.get('@opentiny/tiny-toolkit-blue/package.json'); console.log(pkg.tinyOption); ``` -------------------------------- ### Get OpenTiny Modules Path Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Retrieves the path where OpenTiny modules are installed. ```javascript import { home } from '@opentiny/cli-devkit' const modulesPath = home.getModulesPath(); ``` -------------------------------- ### Build Process Source: https://github.com/opentiny/tiny-cli/blob/dev/README.md Describes the build process for the Tiny CLI project. Running `npm run build` in the root directory packages the lib and dist directories. ```bash npm run build ``` -------------------------------- ### Initialize Project with Tiny CLI Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-toolkit.md Initializes a new project using a Tiny CLI package. This command typically presents a menu of available package templates to choose from, setting up the directory structure and initial configurations based on the selected template. ```bash # Create and enter project folder $ mkdir my-project && cd $_ # Initialize development environment $ tiny init ``` -------------------------------- ### CLI Module Management (cli-module) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tool-design.md Handles the lifecycle of CLI modules (plugins and toolkits), including getting, installing, uninstalling, updating, and listing local and online modules. It also provides utilities for module naming. ```javascript - cli-module - cli 模块的获取、安装及卸载 - get(name) - 获取 cli 模块 - install(name) - 安装 cli 模块 - unInstall(name) - 卸载 cli 模块 - update(name) - 更新 cli 模块 - localList(options) - 获取本地已安装的 cli 插件和套件列表 - onlineList(options) - 获取线上的 cli 插件和套件列表 - fullName(name) - 获取cli模块全名 - pluginFullName(name) - 获取cli插件全称 - toolkitFullName(name) - 获取cli套件全称 ``` -------------------------------- ### Cache Management (Set, Get, Clear) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Provides examples for managing cache data using the cache module. It shows how to set a key-value pair with an expiration time, retrieve cached data, and clear all cached content. ```javascript import { cache } from '@opentiny/cli-devkit' // 将abc这个key的对象写入tiny缓存文件。(该缓存文件一般在 ~/.tiny/tiny.cache.json 中) cache.set('abc',{ data : 1 }); // 从tiny缓存中获取 abc 这个key的内容。 cache.get('abc'); // => return { data : 1 } //清空tiny的缓存内容 cache.clear(); ``` -------------------------------- ### Implement Internationalized Error Messages in Nest.js Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro-backend-dev-guideline.md This example demonstrates how to use the `nestjs-i18n` library to implement internationalized error messages in a Nest.js service. It shows how to define translation keys in JSON files and how to inject and use the `I18nService` to throw localized `HttpException`s. ```json // zhCN/exception.json { // 前面不做修改 "policy":{ "exists": "Policy已存在" } } ``` ```typescript import { HttpException, HttpStatus, Injectable } from '@nestjs/common'; import { I18nTranslations } from '../.generate/i18n.generated'; import { I18nContext, I18nService } from 'nestjs-i18n'; @Injectable() export class PolicyService { constructor( private readonly i18n: I18nService ) {} createPolicy(){ const exists = ...; if (exists){ throw new HttpException( this.i18n.translate('exception.policy.exists', { lang: I18nContext.current().lang, }), HttpStatus.CONFLICT // 409 ) } //.... } } ``` -------------------------------- ### Initialize Project with tiny-cli Source: https://github.com/opentiny/tiny-cli/wiki/@opentiny-tiny‐tookit‐pro-包发布说明 This command initializes a new project using the tiny-cli, specifically for a 'pro' type project. ```bash tiny init pro ``` -------------------------------- ### Tiny CLI Usage Help Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Displays the help information for the Tiny CLI, including available commands and options. You can view general help, toolkit-specific help, or plugin-specific help. ```bash tiny 使用帮助: $ tiny [command] [options] $ tiny 显示tiny帮助信息,若目录下有使用的套件,则会同时显示套件的帮助信息 $ tiny init [toolkitName] 初始化套件 $ tiny update [name] 更新tiny模块 $ tiny list [type] 插件列表 $ tiny i 安装npm模块 $ tiny clear 清空 tiny 的本地缓存 $ tiny help 显示套件帮助信息 $ tiny [name] 其他调用插件命令 Options: -h, --help 显示tiny帮助信息 -v, --version 显示tiny版本 提示: 套件 - 若想查看项目中所使用的套件帮助信息,请在项目根目录执行该命令. 插件 - 若想查看插件的帮助信息,请使用 tiny [name] help 命令, eg : tiny git help ``` -------------------------------- ### npm Scripts Example Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tool-design.md Demonstrates the definition of common development tasks like cleaning, development server startup, and building within the 'scripts' section of a package.json file, executable via 'npm run'. ```json { "scripts": { "clean": "git reset --hard && git clean -df", "dev": "cross-env NODE_ENV=development BABEL_ENV=dev node tools/server.js", "build": "NODE_ENV=production BABEL_ENV=production node tools/packer.js" } } ``` -------------------------------- ### Apply Public and Permission Decorators for API Access Control Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro-backend-dev-guideline.md This example illustrates how to use `@Public()` and `@Permission()` decorators in Nest.js controllers to manage API access. `@Public()` allows unauthenticated access, while `@Permission()` restricts access to users with specific roles or permissions. It shows how to apply these at the method or controller level. ```typescript @Controller('/policy') export class PolicyController { @Get('/list') async getPolicy(){} } @Controller('/policy') export class PolicyController { @Get('/list') @Permission('policy::get::list') async getPolicy(){} } @Controller('/policy') export class PolicyController { @Get('/list') @Permission('policy::get::list') async getPolicies(){} @Get('/') @Public() async getPolicy(){} } @Public() @Controller('/policy') export class PolicyController { @Get('/list') async getPolicies(){} @Get('/') async getPolicy(){} } ``` -------------------------------- ### Development: Local Debugging Commands Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Provides commands for local development and debugging of the Tiny CLI. These include initializing dependencies, running the development server, building the project, and linking locally. ```bash 首次:`npm run init` 开发:`npm run dev` 构建:`npm run build` 本地验证: `npm run link` ``` -------------------------------- ### Create Basic Vue Page Structure Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tiny-pro-front-dev-guideline.md This snippet shows the basic structure of a Vue.js page component (`index.vue`) within the TinyPro framework. It includes a simple template with a paragraph displaying 'hello world'. This serves as the initial file for a new page before adding dynamic content or logic. ```html ``` -------------------------------- ### Install OpenTiny CLI Globally Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-install.md Command to install the OpenTiny CLI globally using npm. For macOS users encountering permission issues, prefix the command with 'sudo'. ```Bash $ npm install @opentiny/cli -g ``` -------------------------------- ### npm 发布命令 Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/dev-plugin.md 用于将开发的 Tiny 插件发布到 npm 仓库的命令。 ```bash npm publish ``` -------------------------------- ### Development: Build Process Source: https://github.com/opentiny/tiny-cli/blob/dev/README.zh-CN.md Builds the Tiny CLI project. Executing 'npm run build' in the root directory will generate 'lib' and 'dist' directories containing the compiled output. ```bash 根目录执行`npm run build`即可,会打包出lib目录和dist目录。 ``` -------------------------------- ### NPM Package Management (cli-npm) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/tool-design.md Provides functions for installing, uninstalling, and checking the existence of npm packages. It also allows fetching the latest package information and installing dependencies defined in package.json. ```javascript - cli-npm - npm模块的安装及卸载 - install(pkg, options) - 安装一个 npm 包 - uninstall(pkg, options) - 卸载一个 npm 包 - installDependencies(options) - 安装package.json 对应的依赖包 - latest(pkg, options) - 获取最新的 npm 包信息 - has(pkg, options) - 判断是否存在某个 npm 包 - install(pkg, options) - uninstall(pkg, options) - installDependencies(options) - latest(pkg, options) - has(pkg, options) ``` -------------------------------- ### List Tiny Modules (Toolkits and Plugins) Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-cli.md Displays a list of available Tiny modules. You can specify the type of module to list, such as 'toolkit' or 'plugin', or list all available modules if no type is specified. ```bash # 显示tiny所有模块 $ tiny list # 显示tiny所有套件 $ tiny list toolkit # 显示tiny所有插件 $ tiny list plugin ``` -------------------------------- ### Clear Tiny Local Cache Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-cli.md Clears the local cache used by Tiny. This command is useful for resolving installation issues by resetting the cache directory. Be aware that executing this command will remove all previously installed Tiny modules. ```bash # 清空tiny本地缓存 $ tiny clear ``` -------------------------------- ### Initialize OpenTiny Home Directory Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/api.md Initializes the OpenTiny home directory. ```javascript import { home } from '@opentiny/cli-devkit' home.initHomeDir(); ``` -------------------------------- ### View Tiny CLI Help Information Source: https://github.com/opentiny/tiny-cli/blob/dev/docs/use-toolkit.md Displays help information for the Tiny CLI and its associated packages. Executing `tiny help` in the project's root directory shows package-specific commands, while running it outside the root directory displays general Tiny CLI help. ```bash # View package help information $ tiny help ```