Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ packages/angular_devkit/architect_cli/package.json=1551210941
packages/angular_devkit/build_webpack/package.json=373950017
packages/angular_devkit/core/package.json=339935828
packages/angular_devkit/schematics/package.json=673943597
packages/angular_devkit/schematics_cli/package.json=-356386813
packages/ngtools/webpack/package.json=-942726894
packages/schematics/angular/package.json=251715148
pnpm-lock.yaml=1833329901
pnpm-workspace.yaml=634423855
pnpm-lock.yaml=-2120244736
pnpm-workspace.yaml=1732591250
yarn.lock=1185228888
1 change: 1 addition & 0 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ npm_translate_lock(
"//packages/angular_devkit/build_webpack:package.json",
"//packages/angular_devkit/core:package.json",
"//packages/angular_devkit/schematics:package.json",
"//packages/angular_devkit/schematics_cli:package.json",
"//packages/ngtools/webpack:package.json",
"//packages/schematics/angular:package.json",
],
Expand Down
12 changes: 5 additions & 7 deletions packages/angular_devkit/architect/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.dev/license

load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:interop.bzl", "ts_project")
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")

licenses(["notice"])

Expand All @@ -21,8 +20,7 @@ ts_project(
"//:node_modules/@types/node",
"//:node_modules/rxjs",
"//packages/angular_devkit/architect:architect_rjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
"//packages/angular_devkit/architect:node_modules/@angular-devkit/core",
],
)

Expand All @@ -39,11 +37,11 @@ ts_project(
"//:node_modules/@types/jasmine",
"//:node_modules/rxjs",
"//packages/angular_devkit/architect:architect_rjs",
"//tests/angular_devkit/architect/node/jobs:jobs_test_lib_rjs",
"//packages/angular_devkit/architect/node/test:test_lib_rjs",
],
)

jasmine_node_test(
jasmine_test(
name = "node_test",
srcs = [":node_test_lib"],
data = [":node_test_lib_rjs"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { jobs } from '@angular-devkit/architect';
import { JsonValue, schema } from '@angular-devkit/core';
import { Observable, of } from 'rxjs';
import { jobs } from '../../src';

export class NodeModuleJobRegistry<
MinimumArgumentValueT extends JsonValue = JsonValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { jobs } from '@angular-devkit/architect';
import * as path from 'path';
import { lastValueFrom } from 'rxjs';
import { jobs } from '../../src';
import { NodeModuleJobRegistry } from './job-registry';

const root = path.join(__dirname, '../../../../../tests/angular_devkit/architect/node/jobs');
const root = path.join(__dirname, '../test/jobs');

describe('NodeModuleJobScheduler', () => {
it('works', async () => {
Expand Down
11 changes: 11 additions & 0 deletions packages/angular_devkit/architect/node/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//tools:interop.bzl", "ts_project")

ts_project(
name = "test_lib",
srcs = glob(["**/*.ts"]),
visibility = ["//packages/angular_devkit/architect/node:__pkg__"],
deps = [
"//:node_modules/@types/node",
"//packages/angular_devkit/architect:architect_rjs",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { jobs } from '@angular-devkit/architect';
import { jobs } from '../../../index';

// Export the job using a createJob. We use our own spec file here to do the job.
export default jobs.createJobHandler<number[], null, number>(
Expand Down
13 changes: 3 additions & 10 deletions packages/angular_devkit/core/node/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
# Use of this source code is governed by an MIT-style license that can be
# found in the LICENSE file at https://angular.dev/license

load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:interop.bzl", "ts_project")
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")

licenses(["notice"])

Expand All @@ -28,8 +27,6 @@ ts_project(
],
)

# @external_begin

ts_project(
name = "node_test_lib",
testonly = True,
Expand All @@ -49,11 +46,7 @@ ts_project(
],
)

jasmine_node_test(
jasmine_test(
name = "node_test",
srcs = [":node_test_lib"],
deps = [
"@npm//chokidar",
],
data = [":node_test_lib_rjs"],
)
# @external_end
13 changes: 5 additions & 8 deletions packages/angular_devkit/schematics/tools/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:interop.bzl", "ts_project")
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")

# Copyright Google Inc. All Rights Reserved.
#
Expand All @@ -24,8 +23,7 @@ ts_project(
"//:node_modules/@types/node",
"//:node_modules/jsonc-parser",
"//:node_modules/rxjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
"//packages/angular_devkit/schematics:node_modules/@angular-devkit/core",
"//packages/angular_devkit/schematics:schematics_rjs",
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
"//packages/angular_devkit/schematics/tasks/node:node_rjs",
Expand All @@ -45,16 +43,15 @@ ts_project(
":tools_rjs",
"//:node_modules/@types/jasmine",
"//:node_modules/rxjs",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
"//packages/angular_devkit/schematics:node_modules/@angular-devkit/core",
"//packages/angular_devkit/schematics:schematics_rjs",
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
"//packages/angular_devkit/schematics/testing:testing_rjs",
"//tests/angular_devkit/schematics/tools/file-system-engine-host:file_system_engine_host_test_lib_rjs",
],
)

jasmine_node_test(
jasmine_test(
name = "tools_test",
deps = [":tools_test_lib"],
data = [":tools_test_lib_rjs"],
)
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

/* eslint-disable @typescript-eslint/no-explicit-any, import/no-extraneous-dependencies */
import { normalize, virtualFs } from '@angular-devkit/core';
import { HostSink, HostTree, SchematicEngine } from '@angular-devkit/schematics';
import { FileSystemEngineHost } from '@angular-devkit/schematics/tools';
import * as path from 'path';
import { from, lastValueFrom, of as observableOf } from 'rxjs';
import { HostSink, HostTree, SchematicEngine } from '../index';
import { FileSystemEngineHost } from './file-system-engine-host';

describe('FileSystemEngineHost', () => {
// We need to resolve a file that actually exists, and not just a folder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,23 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { SchematicEngine } from '@angular-devkit/schematics';
import * as fs from 'fs';
import * as os from 'os';
import * as path from 'path';
import { SchematicEngine } from '../index';
import { NodeModulesEngineHost } from './node-module-engine-host';

const TMP_DIR = process.env['TEST_TMPDIR'] || os.tmpdir();

describe('NodeModulesEngineHost', () => {
let tmpDir!: string;
let previousDir!: string;

beforeEach(() => {
tmpDir = fs.mkdtempSync(
path.join(TMP_DIR, 'angular-devkit-schematics-tools-node-module-engine-host'),
);
previousDir = process.cwd();
process.chdir(tmpDir);
});

afterEach(() => process.chdir(previousDir));

/** Creates a fake NPM module that can be used to test the node module engine host. */
function createFakeNpmModule() {
fs.mkdirSync(path.join(tmpDir, 'node_modules'));
Expand All @@ -47,19 +42,11 @@ describe('NodeModulesEngineHost', () => {
it('should properly create collections with explicit collection path', () => {
createFakeNpmModule();

const engineHost = new NodeModulesEngineHost();
const engineHost = new NodeModulesEngineHost([tmpDir]);
const engine = new SchematicEngine(engineHost);

// Under Bazel 'require.resolve' is patched to use Bazel resolutions from the MANIFEST FILES.
// Adding a temporary file won't be enough to make Bazel aware of this file.
// We provide the full path here just to verify that the underlying logic works
let prefix = '';
if (process.env['BAZEL_TARGET']) {
prefix = path.join(process.cwd(), 'node_modules');
}

expect(() => {
engine.createCollection(path.join(prefix, '@angular/core', './schematics/migrations.json'));
engine.createCollection(path.join('@angular/core', './schematics/migrations.json'));
}).not.toThrow();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

/* eslint-disable import/no-extraneous-dependencies */
import { NodeJsSyncHost } from '@angular-devkit/core/node';
import { NodeWorkflow } from '@angular-devkit/schematics/tools';
import * as path from 'path';
import { NodeWorkflow } from './node-workflow';

describe('NodeWorkflow', () => {
// TODO: this test seems to either not work on windows or on linux.
Expand Down
33 changes: 5 additions & 28 deletions packages/angular_devkit/schematics_cli/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("//tools:defaults2.bzl", "npm_package", "ts_project")
load("//tools:ts_json_schema.bzl", "ts_json_schema")

Expand All @@ -10,6 +10,8 @@ licenses(["notice"])

package(default_visibility = ["//visibility:public"])

npm_link_all_packages()

RUNTIME_ASSETS = [
"blank/schema.json",
"collection.json",
Expand Down Expand Up @@ -44,39 +46,14 @@ ts_project(
data = RUNTIME_ASSETS,
module_name = "@angular-devkit/schematics-cli",
deps = [
":node_modules/@angular-devkit/core",
":node_modules/@angular-devkit/schematics",
"//:node_modules/@inquirer/prompts",
"//:node_modules/@types/node",
"//:node_modules/@types/yargs-parser",
"//:node_modules/ansi-colors",
"//:node_modules/symbol-observable",
"//:node_modules/yargs-parser",
"//packages/angular_devkit/core:core_rjs",
"//packages/angular_devkit/core/node:node_rjs",
"//packages/angular_devkit/schematics:schematics_rjs",
"//packages/angular_devkit/schematics/tasks:tasks_rjs",
"//packages/angular_devkit/schematics/tools:tools_rjs",
],
)

ts_project(
name = "schematics_cli_test_lib",
testonly = True,
srcs = glob(
include = [
"bin/**/*_spec.ts",
],
),
deps = [
":schematics_cli_rjs",
],
)

jasmine_node_test(
name = "schematics_cli_test",
srcs = [":schematics_cli_test_lib"],
data = [
# The package is loaded at runtime within the tests
":schematics_cli",
],
)

Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/schematics_cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
],
"schematics": "./collection.json",
"dependencies": {
"@angular-devkit/core": "0.0.0-PLACEHOLDER",
"@angular-devkit/schematics": "0.0.0-PLACEHOLDER",
"@angular-devkit/core": "workspace:0.0.0-PLACEHOLDER",
"@angular-devkit/schematics": "workspace:0.0.0-PLACEHOLDER",
"@inquirer/prompts": "7.2.1",
"ansi-colors": "4.1.3",
"symbol-observable": "4.0.0",
Expand Down
31 changes: 31 additions & 0 deletions packages/angular_devkit/schematics_cli/test/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@aspect_rules_js//npm:defs.bzl", "npm_link_package")
load("//tools:defaults2.bzl", "jasmine_test", "ts_project")

ts_project(
name = "schematics_cli_test_lib",
testonly = True,
srcs = glob(["**/*"]),
deps = [
"//packages/angular_devkit/schematics_cli:schematics_cli_rjs",
],
)

# Note: Link the schematics CLI package into node modules for testing. Notably, tests
# of a package typically don't use the npm package, to e.g. allow for relative
# imports, but here this is an exception as the package needs to be resolvable at runtime.
npm_link_package(
name = "node_modules/@angular-devkit/schematics-cli",
src = "//packages/angular_devkit/schematics_cli:pkg",
package = "@angular-devkit/schematics-cli",
root_package = package_name(),
)

jasmine_test(
name = "schematics_cli_test",
data = [
":schematics_cli_test_lib_rjs",
# The npm package itself is needed for the test at runtime, so we
# link it into this folder as `node_modules/@angular-devkit/schematics-cli`.
":node_modules/@angular-devkit/schematics-cli",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* found in the LICENSE file at https://angular.dev/license
*/

import { main } from './schematics';
import { main } from '../bin/schematics';

// We only care about the write method in these mocks of NodeJS.WriteStream.
class MockWriteStream {
Expand Down
16 changes: 11 additions & 5 deletions packages/ngtools/webpack/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
# found in the LICENSE file at https://angular.dev/license

load("@npm//@angular/build-tooling/bazel/api-golden:index.bzl", "api_golden_test_npm_package")
load("@npm//@bazel/jasmine:index.bzl", "jasmine_node_test")
load("//tools:defaults2.bzl", "npm_package", "ts_project")
load("@npm2//:defs.bzl", "npm_link_all_packages")
load("//tools:defaults2.bzl", "jasmine_test", "npm_package", "ts_project")

licenses(["notice"])

package(default_visibility = ["//visibility:public"])

npm_link_all_packages()

ts_project(
name = "webpack",
srcs = glob(
Expand Down Expand Up @@ -46,17 +48,21 @@ ts_project(
],
),
deps = [
":node_modules/@angular-devkit/core",
":webpack_rjs",
"//:node_modules/@angular/compiler",
"//:node_modules/@types/jasmine",
"//:node_modules/typescript",
"//packages/angular_devkit/core:core_rjs",
],
)

jasmine_node_test(
jasmine_test(
name = "webpack_test",
srcs = [":webpack_test_lib"],
data = [
":webpack_test_lib_rjs",
# Needed at runtime for runtime TS compilations performed by tests.
"//:node_modules/tslib",
],
)

genrule(
Expand Down
Loading
Loading