@acoustic-content-sdk/schematics 中文文档教程
Suggestion
您可能希望使用 @acoustic-content-sdk/app 示意图来引导您的应用程序.
Prereq
- Install the Angular CLI
- Make sure you have an Angular project set up
Installation
如果您已使用 @acoustic-content-sdk/app 引导您的应用程序,则无需额外的安装步骤是必须的。
否则从应用程序文件夹中的命令行运行
npm install --dev @acoustic-content-sdk/schematics
Basic usage
原理图与 ng generate
命令集成并使用以下语法:
npx ng generate @acoustic-content-sdk/schematics:<COMMAND> <OPTIONS>
获得有关特定命令支持选项的帮助支持
npx ng generate @acoustic-content-sdk/schematics:<COMMAND> --help
Commands
您可以通过以下命令 以下命令:
Layouts
根据类型信息在wchtools文件夹中批量生成布局和布局映射。 工件的名称源自类型名称。
npx ng generate @acoustic-content-sdk/schematics:layouts
此命令仅生成布局和映射的 JSON 描述符,不生成代码组件。 它在 wchtools 文件夹之上工作,并假设存在内容类型的 JSON 记录。
Layout
为一种类型生成布局和布局映射。 可以指定所需布局的名称。
npx ng generate @acoustic-content-sdk/schematics:layout <NAME>
此命令仅生成布局和映射的 JSON 描述符,不生成代码组件。 当默认命名机制不够用时,使用此命令为自动生成的布局创建额外的布局。
Components
基于 wchtools 文件夹生成角度布局和组件。 使用来自内容类型、布局和布局映射的信息。
npx ng generate @acoustic-content-sdk/schematics:components
此命令创建代表 wchtools 文件夹中的映射布局的 Angular 组件。 该命令旨在以批处理模式工作,只要布局、布局映射或类型发生变化,就应调用该命令。
Contributions
根据 Angular 构建输出生成引导 sites-next 应用程序所需的 wchtools 工件。 此命令通常在应用程序的生产构建之后运行。
应用程序的构建输出通常包含两个版本的应用程序,一个用于live
模式,一个用于preview
模式。 这些由 工作区配置 中各自名称的构建配置定义,写入不同的输出文件夹。
此命令生成的工件确保在预览主机上运行时引导应用程序的 preview
版本,否则引导应用程序的 live
版本。
npx ng generate @acoustic-content-sdk/schematics:contributions
运行命令后,通过 wchtools 推送文件夹以部署它。
WCH Tools Folder
许多命令在 wchtools 文件夹 之上运行,该文件夹包含 JSON 记录形式的 WCH 内容模型。 此文件夹通常通过调用 wchtools 命令维护,例如 wchtools pull -t
。
wchtools 文件夹 文件夹的位置可以通过 package.json
在config.data
字段,相对于package.json
的位置,我们推荐./data
作为该文件夹的默认名称。 在该文件夹内的 ./data/.wchtoolsoptions.json
中指定其他配置。
如果您已使用 @acoustic-content-sdk/app 引导您的应用程序,则文件夹和已经设置了必要的配置。
Documentation
Feature Modules
在为应用程序功能生成 NPM 模块时,包含一种自动方法以添加模块到现有应用程序是很有帮助的。 模块可以使用导出的 addFeatureModuleToApplication
函数来实现这一点,而无需任何额外的编码:
- add a
collection.json
file to your module. This schema points to a general purpose implementation of the required command.
{
"$schema": "./../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"ng-add": {
"factory": "@acoustic-content-sdk/schematics#addFeatureModuleToApplication",
"description": "YOUR_DESCRIPTION",
"schema": "./add/schema.json",
"private": true,
"hidden": true
}
}
}
- include your
schema.json
. This describes your module to the schematics engine.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"id": "SOME_UNIQUE_IDENTIFIER",
"title": "SOME_NICE_TITLE",
"type": "object",
"properties": {
"module": {
"type": "string",
"description": "Name of the main module to import. Use a comma separated list for more than one module, defaults to 'YOUR_MODULE_NAME'.",
"default": "YOUR_MODULE_NAME"
}
},
"required": [],
"additionalProperties": false
}
确保将 YOUR_MODULE_NAME
替换为 ngModule 导出您的组件。
- Reference your
collection.json
in thepackage.json
of your module.
{
"schematics": "./collection.json"
}
API Documentation
Home > @acoustic-content-sdk/schematics
schematics package
角度示意图用于添加工作流支持对于声音内容。
Functions
Function | Description |
---|---|
generateComponents(options) | Construct the components |
generateContributions(options) | Generates all wchtools artifacts required to bootstrap a sites next application from the Angular build configuration that the schema points to. |
generateLayout(options) | |
generateLayouts(options) | |
generateVersion(options) | Updates code artifacts to contain the current version |
Variables
Variable | Description |
---|---|
VERSION | Version and build number of the package |
Home > @acoustic-content-sdk/schematics > generateComponents
generateComponents() function
构造组件
Signature:
export declare function generateComponents(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema | our options |
Returns:
Rule
新规则
db31a972e4a270a51 @acoustic-content-sdk/schematics > generateContributions
generateContributions() function
生成从模式指向的 Angular 构建配置引导站点下一个应用程序所需的所有 wchtools 工件。
签名:
export declare function generateContributions(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema | the options |
返回:
规则
生成工件的规则
主页 > @acoustic-content-sdk/schematics > generateLayout
generateLayout() function
Signature:
export declare function generateLayout(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema |
Returns:
Rule
首页 > @acoustic-content-sdk/schematics > generateLayouts
generateLayouts() function
Signature:
export declare function generateLayouts(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema |
Returns:
Rule
首页 > @acoustic-content-sdk/schematics > generateVersion
generateVersion() function
更新代码工件以包含当前版本
签名:
export declare function generateVersion(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema | the options |
返回:
Rule
规则that generates the artifacts
Home > @acoustic-content-sdk/schematics > VERSION
VERSION variable
软件包的版本和构建号
签名:
VERSION: {
version: {
major: string;
minor: string;
patch: string;
branch: string;
};
build: Date;
}
These schematics add workflow to application development for Angular applications for Acoustic Content.
Suggestion
You might want to bootstrap your application by using the @acoustic-content-sdk/app schematics.
Prereq
- Install the Angular CLI
- Make sure you have an Angular project set up
Installation
If you have bootstrapped your application with @acoustic-content-sdk/app no extra installation step is required.
Otherwise from the command line from within you application folder run
npm install --dev @acoustic-content-sdk/schematics
Basic usage
The schematics integrate with the ng generate
command and use the following syntax:
npx ng generate @acoustic-content-sdk/schematics:<COMMAND> <OPTIONS>
You can get help on the supported options for a particular command via
npx ng generate @acoustic-content-sdk/schematics:<COMMAND> --help
Commands
The following commands are supported:
Layouts
Generates layouts and layout mappings based on type information in a batch in the wchtools folder. The names of the artifacts are derived from the type names.
npx ng generate @acoustic-content-sdk/schematics:layouts
This command only generates the JSON descriptors for layouts and mappings, no code components. It works on top of the wchtools folder and assumes the existence of JSON records for content types.
Layout
Generates a layout and layout mapping for one type. The name of the desired layout can be specified.
npx ng generate @acoustic-content-sdk/schematics:layout <NAME>
This command only generates the JSON descriptors for layouts and mappings, no code components. Use this command to create additional layouts to the auto generated ones, when the default naming mechanism is not sufficient.
Components
Generates angular layouts and components based on a wchtools folder. Uses information from the content types, layout and layout mappings.
npx ng generate @acoustic-content-sdk/schematics:components
This command creates Angular components that represent the mapped layouts from the wchtools folder. The command is designed to work in batch mode and should be called whenever layouts, layout mappings or types change.
Contributions
Generates the wchtools artifacts required to bootstrap a sites-next application based on an Angular build output. This command would typically be run after a production build of the application.
The build output of the application typically consists of two versions of the application, one for live
mode and one for preview
mode. These are defined by build configurations of the respective names in the workspace configuration, written to different output folders.
The artifacts generated by this command make sure to bootstrap the preview
version of the application when run on the preview host and otherwise the live
version of the application.
npx ng generate @acoustic-content-sdk/schematics:contributions
After running the command push the folders via wchtools to deploy it.
WCH Tools Folder
Many command operate on top of a wchtools folder, that contains the WCH content model in form of JSON records. This folder is typically maintained by calling wchtools commands, e.g. wchtools pull -t
.
The location of the wchtools folder folder can be configured via the package.json
in the config.data
field, relative to the location of the package.json
, we recommend ./data
as the default name of this folder. Specify additional configuration in the ./data/.wchtoolsoptions.json
inside that folder.
If you have bootstrapped your application with @acoustic-content-sdk/app then the folder and necessary configuration will be setup, already.
Documentation
Feature Modules
When generating NPM modules for application features it is helpful to include an automated way to add the module to an existing application. Modules can use the exported addFeatureModuleToApplication
function to implement this without any additional coding required:
- add a
collection.json
file to your module. This schema points to a general purpose implementation of the required command.
{
"$schema": "./../node_modules/@angular-devkit/schematics/collection-schema.json",
"schematics": {
"ng-add": {
"factory": "@acoustic-content-sdk/schematics#addFeatureModuleToApplication",
"description": "YOUR_DESCRIPTION",
"schema": "./add/schema.json",
"private": true,
"hidden": true
}
}
}
- include your
schema.json
. This describes your module to the schematics engine.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"id": "SOME_UNIQUE_IDENTIFIER",
"title": "SOME_NICE_TITLE",
"type": "object",
"properties": {
"module": {
"type": "string",
"description": "Name of the main module to import. Use a comma separated list for more than one module, defaults to 'YOUR_MODULE_NAME'.",
"default": "YOUR_MODULE_NAME"
}
},
"required": [],
"additionalProperties": false
}
Make sure to replace YOUR_MODULE_NAME
by the name of the ngModule that exports your components.
- Reference your
collection.json
in thepackage.json
of your module.
{
"schematics": "./collection.json"
}
API Documentation
Home > @acoustic-content-sdk/schematics
schematics package
Angular schematics used to add workflow support for Acoustic Content.
Functions
Function | Description |
---|---|
generateComponents(options) | Construct the components |
generateContributions(options) | Generates all wchtools artifacts required to bootstrap a sites next application from the Angular build configuration that the schema points to. |
generateLayout(options) | |
generateLayouts(options) | |
generateVersion(options) | Updates code artifacts to contain the current version |
Variables
Variable | Description |
---|---|
VERSION | Version and build number of the package |
Home > @acoustic-content-sdk/schematics > generateComponents
generateComponents() function
Construct the components
Signature:
export declare function generateComponents(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema | our options |
Returns:
Rule
the new rule
Home > @acoustic-content-sdk/schematics > generateContributions
generateContributions() function
Generates all wchtools artifacts required to bootstrap a sites next application from the Angular build configuration that the schema points to.
Signature:
export declare function generateContributions(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema | the options |
Returns:
Rule
the rule that generates the artifacts
Home > @acoustic-content-sdk/schematics > generateLayout
generateLayout() function
Signature:
export declare function generateLayout(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema |
Returns:
Rule
Home > @acoustic-content-sdk/schematics > generateLayouts
generateLayouts() function
Signature:
export declare function generateLayouts(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema |
Returns:
Rule
Home > @acoustic-content-sdk/schematics > generateVersion
generateVersion() function
Updates code artifacts to contain the current version
Signature:
export declare function generateVersion(options: Schema): Rule;
Parameters
Parameter | Type | Description |
---|---|---|
options | Schema | the options |
Returns:
Rule
the rule that generates the artifacts
Home > @acoustic-content-sdk/schematics > VERSION
VERSION variable
Version and build number of the package
Signature:
VERSION: {
version: {
major: string;
minor: string;
patch: string;
branch: string;
};
build: Date;
}