Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: automate @angular/cli schema.json generation #20221

Merged
merged 1 commit into from Mar 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 44 additions & 3 deletions packages/angular/cli/BUILD.bazel
Expand Up @@ -5,6 +5,7 @@

load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:ts_json_schema.bzl", "ts_json_schema")
load("//tools:ng_cli_schema_generator.bzl", "cli_json_schema")
load("//tools:defaults.bzl", "ts_library")

# @external_begin
Expand All @@ -28,7 +29,7 @@ ts_library(
) + [
# @external_begin
# These files are generated from the JSON schema
"//packages/angular/cli:lib/config/schema.ts",
"//packages/angular/cli:lib/config/workspace-schema.ts",
"//packages/angular/cli:commands/analytics.ts",
"//packages/angular/cli:commands/add.ts",
"//packages/angular/cli:commands/build.ts",
Expand Down Expand Up @@ -58,8 +59,11 @@ ts_library(
exclude = [
# NB: we need to exclude the nested node_modules that is laid out by yarn workspaces
"node_modules/**",
"cli/lib/config/workspace-schema.json",
],
),
) + [
"//packages/angular/cli:lib/config/schema.json",
],
module_name = "@angular/cli",
# strict_checks = False,
deps = [
Expand All @@ -84,9 +88,46 @@ ts_library(
],
)

CLI_SCHEMA_DATA = [
"//packages/angular_devkit/build_angular:src/app-shell/schema.json",
"//packages/angular_devkit/build_angular:src/browser/schema.json",
"//packages/angular_devkit/build_angular:src/dev-server/schema.json",
"//packages/angular_devkit/build_angular:src/extract-i18n/schema.json",
"//packages/angular_devkit/build_angular:src/karma/schema.json",
"//packages/angular_devkit/build_angular:src/ng-packagr/schema.json",
"//packages/angular_devkit/build_angular:src/protractor/schema.json",
"//packages/angular_devkit/build_angular:src/server/schema.json",
"//packages/angular_devkit/build_angular:src/tslint/schema.json",
"//packages/schematics/angular:app-shell/schema.json",
"//packages/schematics/angular:application/schema.json",
"//packages/schematics/angular:class/schema.json",
"//packages/schematics/angular:component/schema.json",
"//packages/schematics/angular:directive/schema.json",
"//packages/schematics/angular:enum/schema.json",
"//packages/schematics/angular:guard/schema.json",
"//packages/schematics/angular:interceptor/schema.json",
"//packages/schematics/angular:interface/schema.json",
"//packages/schematics/angular:library/schema.json",
"//packages/schematics/angular:module/schema.json",
"//packages/schematics/angular:ng-new/schema.json",
"//packages/schematics/angular:pipe/schema.json",
"//packages/schematics/angular:resolver/schema.json",
"//packages/schematics/angular:service/schema.json",
"//packages/schematics/angular:service-worker/schema.json",
"//packages/schematics/angular:web-worker/schema.json",
]

cli_json_schema(
name = "cli_config_schema",
src = "lib/config/workspace-schema.json",
out = "lib/config/schema.json",
data = CLI_SCHEMA_DATA,
)

ts_json_schema(
name = "cli_schema",
src = "lib/config/schema.json",
src = "lib/config/workspace-schema.json",
data = CLI_SCHEMA_DATA,
)

ts_json_schema(
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/commands/add-impl.ts
Expand Up @@ -9,7 +9,7 @@ import { analytics, tags } from '@angular-devkit/core';
import { NodePackageDoesNotSupportSchematics } from '@angular-devkit/schematics/tools';
import { dirname, join } from 'path';
import { intersects, prerelease, rcompare, satisfies, valid, validRange } from 'semver';
import { PackageManager } from '../lib/config/schema';
import { PackageManager } from '../lib/config/workspace-schema';
import { isPackageNameSafeForAnalytics } from '../models/analytics';
import { Arguments } from '../models/interface';
import { RunSchematicOptions, SchematicCommand } from '../models/schematic-command';
Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/commands/update-impl.ts
Expand Up @@ -11,7 +11,7 @@ import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import * as semver from 'semver';
import { PackageManager } from '../lib/config/schema';
import { PackageManager } from '../lib/config/workspace-schema';
import { Command } from '../models/command';
import { Arguments } from '../models/interface';
import { SchematicEngineHost } from '../models/schematic-engine-host';
Expand Down