MCPcopy Index your code
hub / github.com/angular/angular-cli / validateWorkspace

Function validateWorkspace

packages/angular/cli/src/utilities/config.ts:240–261  ·  view source on GitHub ↗
(data: json.JsonObject, isGlobal: boolean)

Source from the content-addressed store, hash-verified

238}
239
240export async function validateWorkspace(data: json.JsonObject, isGlobal: boolean): Promise<void> {
241 const schema = readAndParseJson(workspaceSchemaPath);
242 if (!isJsonObject(schema)) {
243 throw new Error('Workspace schema is not a JSON object.');
244 }
245
246 // We should eventually have a dedicated global config schema and use that to validate.
247 const schemaToValidate: json.schema.JsonSchema = isGlobal
248 ? {
249 '$ref': '#/definitions/global',
250 definitions: schema['definitions'] as json.JsonObject,
251 }
252 : schema;
253
254 const { formats } = await import('@angular-devkit/schematics');
255 const registry = new json.schema.CoreSchemaRegistry(formats.standardFormats);
256 const validator = await registry.compile(schemaToValidate);
257 const { success, errors } = await validator(data);
258 if (!success) {
259 throw new json.schema.SchemaValidationException(errors);
260 }
261}
262
263function findProjectByPath(workspace: AngularWorkspace, location: string): string | null {
264 const isInside = (base: string, potential: string): boolean => {

Callers 1

setMethod · 0.90

Calls 3

compileMethod · 0.95
readAndParseJsonFunction · 0.90
isJsonObjectFunction · 0.70

Tested by

no test coverage detected