1.2.29 • Published 5 months ago

@cplace/asc v1.2.29

Weekly downloads
2,337
License
ISC
Repository
github
Last release
5 months ago

Document Control / Repository Information

ItemValue
OwnerStefan Stadler, Slaven Kopic, Jan Dittmar
Teamnone yet
Projectnone
Parentnone
Developed bycollaboration Factory AG
DescriptionUnser Kommandozeilen-Werkzeug um Frontend Assets zu bauen.

cplace-asc

cplace-asc is the new cplace assets compiler toolchain used to compile, bundle and minimize TypeScript, LESS and YAML sources into their JavaScript and CSS counterparts.

Installation

Just run the following command which will install the assets compiler globally:

$ npm install -g @cplace/asc

Usage

The assets compiler supports multiple parameters:

$ cplace-asc --help
⇢ Checking whether newer version is available... ✓


  cplace assets compiler

  Usage:
      $ cplace-asc

  Options:
        --plugin, -p <plugins>  Run for specified plugins (and dependencies) - comma separated list of plugin names
        --watch, -w             Enable watching of source files (continuous compilation)
        --onlypre, -o           Run only preprocessing steps (like create tsconfig.json files)
        --clean, -c             Clean generated output folders at the beginning
        --threads, -t           Maximum number of threads to run in parallel
        --localonly, -l         Enable to not scan other directories than CWD for plugins
        --noparents, -x         Enable to only run compilation on plugins in current repository (still scans for other sources to be present)
        --packagejson, -j       Generate package.json files (if missing) in the root and each plugin that has assets
        --withYaml, -y          Generates TypeScript files from the OpenAPI YAML specification
        --verbose, -v           Enable verbose logging
        --production, -P        Enable production mode (ignores test dependencies and E2E)

The tool will automatically check for updates on every run, so you will be prompted with a large message when a newer version is available:

$ cplace-asc --help
⇢ Checking whether newer version is available... ✓
!---------------------------------------------!
! A newer version of @cplace/asc is available !
! -> Please update to the latest version:     !
!    npm install -g @cplace/asc               !
!---------------------------------------------!

...

Publishing a new version

To publish a new version on the NPM registry take the following steps:

  1. Manually bump the version number in package.json as desired (major / minor / patch).
  2. Push the update to GitHub.
  3. Create a new Release on GitHub:
    1. Create a new tag matching the version you want to publish, e.g. v0.20.3.
    2. Put in the proper release notes as description of the Release.
  4. On creating the Release (not as a draft) the GitHub workflow will run and publish the package to NPM automatically.

Source File Requirements

TypeScript

For each plugin there must be one main entry file assets/ts/app.ts which will be used as entry point for bundling. As such any other source file must be imported (transitively) by that file.

If you have additional dependencies to typings files that are placed locally in your plugin you have to include an extra-types.json file. This file can have the following strucutre:

{
    "declarations": ["relative/path/to/typings/file", "..."],
    "externals": {
        "nameOfImport": "_variableName"
    }
}

As you can see you can specify the relative path (taken from the location of the extra-types.json file) to any typings definitions (.d.ts) file which will then be taken into account by the TypeScript compiler. Furthermore, in order for Webpack to complete the bundling process you most likely will also have to specify the externals that this typings file provides. These are given in the externals object. The key must equal to the name of the import in TypeScript (e.g. for import * as myXs from 'xs' the key would be xs). The value is equal to the global variable name to be resolved by Webpack.

LESS

For each plugin there must be one main entry file: either assets/less/plugin.less or assets/less/cplace.less. The generated CSS file will be called assets/generated_css/plugin.css or assets/generated_css/cplace.css respectively.

Compress CSS

For each plugin there must be one main entry file assets/css/imports.css which will be used as entry point for combining and compressing CSS code.

YAML

For each plugin there must be one main entry file assets/api/API.yaml which will be used as an entry point for TypeScript generation.

Details

  • The compiler will spawn at most X number of compile processes in parallel where X equals the number of cores available on the system.
  • Compilation is run inside a subprocess via a scheduler. Cancelling the assets compiler may leave intermediate processing steps running for a short time in the background.
  • The TypeScript compiler is the one located in the main repository's node_modules directory.
  • The clean-css compiler is the one located in the main repository's node_modules directory.

Known Caveats

Implicit Dependencies

As of version 3.4 the TypeScript compiler supports incremental compilation. As such it tracks which files have to be recompiled due to changes of other source files. However, this does not cover implicit dependencies. See the following example:

types.ts:

export interface IComputationResult {
    status: number;
    content: string;
}

utils.ts

import { IComputationResult } from './types';
export function computeValue(input: string): IComputationResult {
    let result: IComputationResult;
    // does some magic
    // ...
    return result;
}

component.ts

import { computeValue } from './utils';

export function componentLogic(): void {
    // does some things...
    const result = computeValue('my complex input');

    console.log(result.status, result.content);
}

As you can see in the example above, component.ts has an implicit dependency on types.ts as it has the result variable with an inferred type of IComputationResult. Changing the IComputationResult, e.g. by renaming content to output, will not cause a compilation error if the TypeScript compiler is running in watch mode with incremental compilation (default behavior). Only a full recompilation will result in the error to be detected.

In order to mitigate this issue you could use the following workaround by explicitly declaring the type of the variable you store the method result in (IntelliJ provides a quickfix for this: "Specify type explicitly"):

component.ts

import { computeValue } from './utils';
// !! See the new import making the dependency explicit
import { IComputationResult } from './types';

export function componentLogic(): void {
    // does some things...
    // !! See the explicit variable type
    const result: IComputationResult = computeValue('my complex input');

    console.log(result.status, result.content);
}
1.2.29

5 months ago

1.2.24

10 months ago

1.2.27

6 months ago

1.2.28

6 months ago

1.2.25

7 months ago

1.2.26

6 months ago

1.2.23

12 months ago

1.2.22

1 year ago

1.2.21

1 year ago

1.2.19

1 year ago

1.2.20

1 year ago

1.2.18

1 year ago

1.2.16

1 year ago

1.2.17

1 year ago

1.2.15

1 year ago

1.2.14

2 years ago

1.2.13

2 years ago

1.2.12

2 years ago

1.2.10

2 years ago

1.2.11

2 years ago

1.2.9

2 years ago

1.2.8

2 years ago

1.2.7

2 years ago

1.2.6

2 years ago

1.2.5

2 years ago

1.2.4

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.0

2 years ago

1.2.1

2 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.2

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago

0.14.2

3 years ago

0.14.0

3 years ago

0.14.1

3 years ago

0.13.0

3 years ago

0.12.7

4 years ago

0.12.6

4 years ago

0.12.5

4 years ago

0.12.1

4 years ago

0.12.2

4 years ago

0.12.3

4 years ago

0.12.4

4 years ago

0.12.0

4 years ago

0.11.3

4 years ago

0.11.2

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.11.0-beta.1

4 years ago

0.11.0-beta

4 years ago

0.10.0

4 years ago

0.9.10

5 years ago

0.9.9

5 years ago

0.9.8

5 years ago

0.9.7

5 years ago

0.9.6

5 years ago

0.9.5

5 years ago

0.9.4

5 years ago

0.9.3

5 years ago

0.9.2

5 years ago

0.9.1

5 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.0

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago

0.4.3

5 years ago

0.4.2

5 years ago

0.4.1

5 years ago

0.4.0

5 years ago

0.3.9

5 years ago

0.3.8

5 years ago

0.3.7

5 years ago

0.3.6

5 years ago

0.3.5

5 years ago

0.3.4

5 years ago

0.3.3

5 years ago

0.3.2

5 years ago

0.3.1

5 years ago

0.3.0

5 years ago

0.2.4

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago