(data: json.JsonObject, isGlobal: boolean)
| 238 | } |
| 239 | |
| 240 | export 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 | |
| 263 | function findProjectByPath(workspace: AngularWorkspace, location: string): string | null { |
| 264 | const isInside = (base: string, potential: string): boolean => { |
no test coverage detected