@acoustic-content-sdk/schematics
TypeScript icon, indicating that this package has built-in type declarations

9.0.10076 • Public • Published

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:

  1. 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
    }
  }
}
  1. 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.

  1. Reference your collection.json in the package.json of your module.
{
  "schematics": "./collection.json"
}

API Documentation

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;
}

Package Sidebar

Install

npm i @acoustic-content-sdk/schematics

Weekly Downloads

1

Version

9.0.10076

License

MIT

Unpacked Size

2.05 MB

Total Files

179

Last publish

Collaborators

  • marcin-pasiewicz
  • nikodem.graczewski.acoustic
  • pawel.galias-ac
  • orenaksakal
  • marcin.konopka-ac