### Install Project Dependencies with Lerna Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md After cloning the project, execute this command from the root directory to bootstrap the Lerna monorepo and install all package dependencies. ```bash lerna bootstrap ``` -------------------------------- ### Install Lerna Globally Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Install Lerna globally on your system, which is required to manage this monorepo project. ```bash npm install --global lerna ``` -------------------------------- ### Start Web Simulation Test Server Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Start the web simulation test server on port 80. This command requires sudo privileges as it binds to a privileged port. ```bash sudo npm run test:web ``` -------------------------------- ### Build Cloudbase JS SDK Project Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Run this command from the project root directory to build all packages within the monorepo. ```bash npm run build ``` -------------------------------- ### Initializing Cloudbase Analytics Module Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/analytics/README.md This snippet demonstrates the basic initialization of the `@cloudbase/analytics` module using `require`. Further API usage examples are pending. ```JavaScript const analytics = require('@cloudbase/analytics'); // TODO: DEMONSTRATE API ``` -------------------------------- ### Install @cloudbase/js-sdk via npm or yarn Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/cloudbase/README.md This snippet demonstrates how to install the @cloudbase/js-sdk using popular package managers like npm and yarn. The SDK can be installed as a full package or as granular modules. The -S flag for npm saves the package as a dependency. ```bash # npm npm install @cloudbase/js-sdk -S # yarn yarn add @cloudbase/js-sdk ``` -------------------------------- ### Run End-to-End Tests Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Execute this command to run the end-to-end tests for the project. ```bash npm run test:e2e ``` -------------------------------- ### Publish Beta Version of Packages Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Use this command to publish a beta version of the project's packages. During the process, you will be prompted to select version numbers for each package. ```bash npm run publish:beta ``` -------------------------------- ### Publish Official Version of Packages Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Execute this command to publish an official release version of the project's packages. You will need to select version numbers for each package during the publishing process. ```bash npm run publish ``` -------------------------------- ### Add New Package to Lerna Monorepo Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md When adding a new package to the project, use this Lerna command to properly integrate it into the monorepo structure, specifying the new package name and scope. ```bash lerna add 新包名 --scope=@cloudbase/js-sdk ``` -------------------------------- ### Configure Web Simulation Test Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/dev.md Create a 'test.config.js' file in the project root to configure web simulation tests. This configuration includes environment ID, WeChat AppID, custom login URL, and credentials for username/password login. ```javascript /** * 测试配置 */ module.exports = { // 环境id env: "", // 微信公众号appid,仅当需要测试微信登录时配置 appid: "", // 获取自定义登录ticket的函数http访问地址,仅当需要测试自定义登录时配置 authFnUrl: "", // 用户名密码登录-用户名,仅当需要测试用户名登录时配置 authUsername: "", // 用户名密码登录-密码,仅当需要测试用户名登录时配置 authPassword: "" } ``` -------------------------------- ### Build @cloudbase/js-sdk packages Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/cloudbase/README.md This snippet provides the command to build the @cloudbase/js-sdk. The build process generates npm packages, which are organized into module subdirectories, and CDN-hosted JavaScript files, which are stored in the `cdnjs` directory and categorized by version. ```bash npm run build ``` -------------------------------- ### Import full @cloudbase/js-sdk in JavaScript Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/cloudbase/README.md This JavaScript snippet shows how to perform a full import of the Cloudbase JavaScript SDK, providing access to all its features and APIs. ```javascript import cloudbase from '@cloudbase/js-sdk'; ``` -------------------------------- ### Include full @cloudbase/js-sdk via CDN in HTML Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/cloudbase/README.md This HTML snippet demonstrates how to include the complete Cloudbase JavaScript SDK directly from a CDN using a script tag. This method is suitable for browser environments and provides all SDK functionalities. ```html ``` -------------------------------- ### Include specific @cloudbase/js-sdk modules via CDN in HTML Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/cloudbase/README.md This HTML snippet shows how to include individual Cloudbase JavaScript SDK modules from a CDN. This allows for selective loading of features. It requires including the main `cloudbase.js` file first, followed by specific module files like auth, functions, storage, and database. ```html ``` -------------------------------- ### Import specific @cloudbase/js-sdk modules in JavaScript Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/packages/cloudbase/README.md This JavaScript snippet illustrates how to import individual modules of the Cloudbase JavaScript SDK, allowing for optimized bundle sizes and selective feature usage. Modules include app (core), auth (login), functions, storage, and database. ```javascript // 内核 import cloudbase from '@cloudbase/js-sdk/app'; // 登录模块 import cloudbase from '@cloudbase/js-sdk/auth'; // 函数模块 import cloudbase from '@cloudbase/js-sdk/functions'; // 云存储模块 import cloudbase from '@cloudbase/js-sdk/storage'; // 数据库模块 import cloudbase from '@cloudbase/js-sdk/database'; ``` -------------------------------- ### Webpack Source Map Loader Configuration Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/errlog.md Add `source-map-loader` to Webpack's module rules to pre-process JavaScript files. This enables the SDK to utilize sourcemaps for accurate source code location in the optimized error stack traces. ```javascript module.exports = { module: { rules: [ { test: /\.js$/, enforce: 'pre', use: ['source-map-loader'] } // ...其他rules ] } // ...其他配置 } ``` -------------------------------- ### Rollup Development Configuration with Plugins Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/errlog.md Configure Rollup with `rollup-plugin-sourcemaps` to load sourcemaps and `rollup-plugin-replace` to inject `process.env.NODE_ENV` as 'development'. These plugins are crucial for enabling the enhanced error messages in a Rollup build. ```javascript import sourcemaps from 'rollup-plugin-sourcemaps'; import replace from 'rollup-plugin-replace'; export default { plugins: [ sourcemaps(), replace({ 'process.env.NODE_ENV': JSON.stringify('development') }) // ...其他插件 ] // ...其他配置 }; ``` -------------------------------- ### Webpack DefinePlugin for NODE_ENV (Older Versions) Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/errlog.md For older Webpack versions (pre-4), use the `DefinePlugin` to explicitly inject `process.env.NODE_ENV` as 'development' into the bundle, ensuring the SDK's optimized error messages are active. ```javascript const webpack = require('webpack') module.exports = { plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('development') }) // ...其他插件 ] // ...其他配置 } ``` -------------------------------- ### Webpack 4+ Development Mode Configuration Source: https://github.com/tencentcloudbase/cloudbase-js-sdk/blob/master/docs/errlog.md Configure Webpack 4 and newer versions to set the `mode` option to 'development', which automatically sets `process.env.NODE_ENV` and enables development-specific features, including enhanced error messages. ```javascript module.exports = { mode: 'development' } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.