Gathering detailed insights and metrics for @sitcs/angular-devkit-core
Gathering detailed insights and metrics for @sitcs/angular-devkit-core
npm install @sitcs/angular-devkit-core
Typescript
Module System
Node Version
NPM Version
Total Downloads
749
Last Day
1
Last Week
9
Last Month
24
Last Year
113
Minified
Minified + Gzipped
Latest Version
8.0.6
Package Id
@sitcs/angular-devkit-core@8.0.6
Unpacked Size
631.91 kB
Size
194.18 kB
File Count
271
NPM Version
6.10.2
Node Version
12.7.0
Cumulative downloads
Total Downloads
Last day
-75%
1
Compared to previous day
Last week
125%
9
Compared to previous week
Last month
2,300%
24
Compared to previous month
Last year
-47.2%
113
Compared to previous year
Shared utilities for Angular DevKit. Customized for use by SITCS.
Bazel
builds to native tsc
builds.No content at this time.
No content at this time.
1export interface SchemaValidatorResult { 2 success: boolean; 3 errors?: string[]; 4}
1export interface SchemaValidator { 2 (data: any): Observable<SchemaValidatorResult>; 3}
1export interface SchemaFormatter { 2 readonly async: boolean; 3 validate(data: any): boolean | Observable<boolean>; 4}
1export interface SchemaRegistry { 2 compile(schema: Object): Observable<SchemaValidator>; 3 addFormat(name: string, formatter: SchemaFormatter): void; 4}
SchemaRegistry
implementation using AJV.
Constructor accepts object containing SchemaFormatter
that will be added automatically.
1export class CoreSchemaRegistry implements SchemaRegistry { 2 constructor(formats: { [name: string]: SchemaFormatter} = {}) {} 3}
No content at this time.
Modifed the capitalize
function to now accept a 2nd argument to fully capitalize a string instead of just the first character.
Added a new lowercase
function that works exactly like capitalize
but in reverse.
Added a new dottify
function that works similar to underscore
but instead of underscores _
it uses dots .
and also classifies the entire string.
No content at this time.
The workspaces
namespace provides an API for interacting with the workspace file formats.
It provides an abstraction of the underlying storage format of the workspace and provides
support for both reading and writing. Currently, the only supported format is the JSON-based
format used by the Angular CLI. For this format, the API provides internal change tracking of values which
enables fine-grained updates to the underlying storage of the workspace. This allows for the
retention of existing formatting and comments.
A workspace is defined via the following object model. Definition collection objects are specialized
Javascript Map
objects with an additional add
method to simplify addition and provide more localized
error checking of the newly added values.
1export interface WorkspaceDefinition { 2 readonly extensions: Record<string, JsonValue | undefined>; 3 readonly projects: ProjectDefinitionCollection; 4} 5 6export interface ProjectDefinition { 7 readonly extensions: Record<string, JsonValue | undefined>; 8 readonly targets: TargetDefinitionCollection; 9 root: string; 10 prefix?: string; 11 sourceRoot?: string; 12} 13 14export interface TargetDefinition { 15 options?: Record<string, JsonValue | undefined>; 16 configurations?: Record<string, Record<string, JsonValue | undefined> | undefined>; 17 builder: string; 18}
The API is asynchronous and has two main functions to facilitate reading, creation, and modifying
a workspace: readWorkspace
and writeWorkspace
.
1export enum WorkspaceFormat { 2 JSON, 3}
1export function readWorkspace(
2 path: string,
3 host: WorkspaceHost,
4 format?: WorkspaceFormat,
5): Promise<{ workspace: WorkspaceDefinition; }>;
1export function writeWorkspace(
2 workspace: WorkspaceDefinition,
3 host: WorkspaceHost,
4 path?: string,
5 format?: WorkspaceFormat,
6): Promise<void>;
A WorkspaceHost
abstracts the underlying data access methods from the functions. It provides
methods to read, write, and analyze paths. A utility function is provided to create
an instance of a WorkspaceHost
from the Angular DevKit's virtual filesystem host abstraction.
1export interface WorkspaceHost {
2 readFile(path: string): Promise<string>;
3 writeFile(path: string, data: string): Promise<void>;
4 isDirectory(path: string): Promise<boolean>;
5 isFile(path: string): Promise<boolean>;
6}
7
8export function createWorkspaceHost(host: virtualFs.Host): WorkspaceHost;
To demonstrate the usage of the API, the following code will show how to add a option property to a build target for an application.
1import { NodeJsSyncHost } from '@angular-devkit/core/node'; 2import { workspaces } from '@angular-devkit/core'; 3 4async function demonstrate() { 5 const host = workspaces.createWorkspaceHost(new NodeJsSyncHost()); 6 const workspace = await workspaces.readWorkspace('path/to/workspace/directory/', host); 7 8 const project = workspace.projects.get('my-app'); 9 if (!project) { 10 throw new Error('my-app does not exist'); 11 } 12 13 const buildTarget = project.targets.get('build'); 14 if (!buildTarget) { 15 throw new Error('build target does not exist'); 16 } 17 18 buildTarget.options.optimization = true; 19 20 await workspaces.writeWorkspace(workspace, host); 21} 22 23demonstrate();
No vulnerabilities found.
No security vulnerabilities found.