Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { TestProjectHost } from '@angular-devkit/architect/testing';
import { join, normalize } from '@angular-devkit/core';
const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
const basicWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/basic-app/');
export const basicHost = new TestProjectHost(basicWorkspaceRoot);
const angularWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/angular-app/');
export const angularHost = new TestProjectHost(angularWorkspaceRoot);
cp(
'-ru',
testingAppSrc,
templateRoot,
);
// link node packages
symlinkSync(
path.join(require.resolve('npm/node_modules/@angular/core/package.json'), '../../../'),
path.join(process.env.TEST_TMPDIR as string, 'node_modules'),
'junction'
);
export const workspaceRoot = normalize(templateRoot);
export const host = new TestProjectHost(workspaceRoot);
export const outputPathBrowser = normalize('dist/app/browser');
export const outputPathServer = normalize('dist/app/server');
export async function createArchitect(root: Path) {
const workspaceSysPath = getSystemPath(root);
// link @nguniversal packages
const nodeModuleDir = path.join(workspaceSysPath, 'node_modules');
if (!existsSync(nodeModuleDir)) {
mkdirSync(nodeModuleDir);
}
const ngUniversalNodePackages = path.join(nodeModuleDir, '@nguniversal');
if (!existsSync(ngUniversalNodePackages)) {
mkdirSync(ngUniversalNodePackages);
}
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { TestProjectHost } from '@angular-devkit/architect/testing';
import { join, normalize } from '@angular-devkit/core';
const devkitRoot = normalize((global as any)._DevKitRoot); // tslint:disable-line:no-any
const basicWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/basic-app/');
export const basicHost = new TestProjectHost(basicWorkspaceRoot);
const angularWorkspaceRoot = join(devkitRoot, 'tests/angular_devkit/build_webpack/angular-app/');
export const angularHost = new TestProjectHost(angularWorkspaceRoot);
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { TestProjectHost } from '@angular-devkit/architect/testing';
import { getSystemPath, join } from '@angular-devkit/core';
import { ScriptTarget } from 'typescript';
import { BuildBrowserFeatures } from './build-browser-features';
const devkitRoot = (global as any)._DevKitRoot; // tslint:disable-line:no-any
const workspaceRoot = join(
devkitRoot,
'tests/angular_devkit/build_angular/hello-world-app/'
);
const host = new TestProjectHost(workspaceRoot);
describe('BuildBrowserFeatures', () => {
let workspaceRootSysPath = '';
beforeEach(async () => {
await host.initialize().toPromise();
workspaceRootSysPath = getSystemPath(host.root());
});
afterEach(async () => host.restore().toPromise());
describe('isDifferentialLoadingNeeded', () => {
it('should be true for for IE 9-11 and ES2015', () => {
host.writeMultipleFiles({
browserslist: 'IE 9-11'
});
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import { TestProjectHost } from '@angular-devkit/architect/testing';
import { getSystemPath, join } from '@angular-devkit/core';
import { ScriptTarget } from 'typescript';
import { isDifferentialLoadingNeeded } from './differential-loading';
const devkitRoot = (global as any)._DevKitRoot; // tslint:disable-line:no-any
const workspaceRoot = join(
devkitRoot,
'tests/angular_devkit/build_angular/hello-world-app/');
const host = new TestProjectHost(workspaceRoot);
describe('differential loading', () => {
beforeEach(async () => host.initialize().toPromise());
afterEach(async () => host.restore().toPromise());
it('detects the need for differential loading for IE 9-11 and ES2015', () => {
host.writeMultipleFiles({
'browserslist': 'IE 9-11',
});
const needed = isDifferentialLoadingNeeded(getSystemPath(host.root()), ScriptTarget.ES2015);
expect(needed).toBe(true);
});
describe("Stylelint Target", () => {
const filesWithErrors = { "src/foo.scss": "a { color: #ffffff }" };
const stylelintTargetSpec = { project: "app", target: "lint" };
let testArchitectHost: TestingArchitectHost;
let architect: Architect;
const workspaceRoot = path.join(__dirname, "hello-world-app");
const host = new TestProjectHost(normalize(workspaceRoot));
beforeEach(async () => {
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const { workspace } = await workspaces.readWorkspace(
workspaceRoot,
workspaces.createWorkspaceHost(host)
);
await host.initialize().toPromise();
testArchitectHost = new TestingArchitectHost(
getSystemPath(host.root()),
getSystemPath(host.root()),
new WorkspaceNodeModulesArchitectHost(workspace, workspaceRoot)
describe('NgPackagr Builder', () => {
const host = new TestProjectHost(workspaceRoot);
let architect: Architect;
beforeEach(async () => {
await host.initialize().toPromise();
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspaceSysPath = getSystemPath(host.root());
const { workspace } = await workspaces.readWorkspace(
workspaceSysPath,
workspaces.createWorkspaceHost(host),
);
const architectHost = new TestingArchitectHost(
workspaceSysPath,
workspaceSysPath,
describe('NgPackagr Builder', () => {
const host = new TestProjectHost(workspaceRoot);
let architect: Architect;
beforeEach(async () => {
await host.initialize().toPromise();
const registry = new schema.CoreSchemaRegistry();
registry.addPostTransform(schema.transforms.addUndefinedDefaults);
const workspaceSysPath = getSystemPath(host.root());
const { workspace } = await workspaces.readWorkspace(
workspaceSysPath,
workspaces.createWorkspaceHost(host),
);
const architectHost = new TestingArchitectHost(
workspaceSysPath,
workspaceSysPath,