cleanup(angular): switch tests to use project name and root as-provided format by default (#18792)
This commit is contained in:
parent
a009523086
commit
b9eba9d72d
@ -13,11 +13,13 @@ describe('angular.json v1 config', () => {
|
||||
|
||||
beforeAll(() => {
|
||||
newProject();
|
||||
runCLI(`generate @nx/angular:app ${app1} --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${app1} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
// reset workspace to use v1 config
|
||||
updateFile(`angular.json`, angularV1Json(app1));
|
||||
removeFile(`apps/${app1}/project.json`);
|
||||
removeFile(`apps/${app1}-e2e/project.json`);
|
||||
removeFile(`${app1}/project.json`);
|
||||
removeFile(`${app1}-e2e/project.json`);
|
||||
});
|
||||
afterAll(() => cleanupProject());
|
||||
|
||||
@ -31,10 +33,12 @@ describe('angular.json v1 config', () => {
|
||||
it('should generate new app with project.json and keep the existing in angular.json', async () => {
|
||||
// create new app
|
||||
const app2 = uniq('app2');
|
||||
runCLI(`generate @nx/angular:app ${app2} --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${app2} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// should generate project.json for new projects
|
||||
checkFilesExist(`apps/${app2}/project.json`);
|
||||
checkFilesExist(`${app2}/project.json`);
|
||||
// check it works correctly
|
||||
expect(runCLI(`build ${app2}`)).toContain('Successfully ran target build');
|
||||
expect(runCLI(`test ${app2} --no-watch`)).toContain(
|
||||
@ -53,21 +57,21 @@ const angularV1Json = (appName: string) => `{
|
||||
"projects": {
|
||||
"${appName}": {
|
||||
"projectType": "application",
|
||||
"root": "apps/${appName}",
|
||||
"sourceRoot": "apps/${appName}/src",
|
||||
"root": "${appName}",
|
||||
"sourceRoot": "${appName}/src",
|
||||
"prefix": "v1angular",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"outputs": ["{options.outputPath}"],
|
||||
"options": {
|
||||
"outputPath": "dist/apps/${appName}",
|
||||
"index": "apps/${appName}/src/index.html",
|
||||
"main": "apps/${appName}/src/main.ts",
|
||||
"outputPath": "dist${appName}",
|
||||
"index": "${appName}/src/index.html",
|
||||
"main": "${appName}/src/main.ts",
|
||||
"polyfills": ["zone.js"],
|
||||
"tsConfig": "apps/${appName}/tsconfig.app.json",
|
||||
"assets": ["apps/${appName}/src/favicon.ico", "apps/${appName}/src/assets"],
|
||||
"styles": ["apps/${appName}/src/styles.css"],
|
||||
"tsConfig": "${appName}/tsconfig.app.json",
|
||||
"assets": ["${appName}/src/favicon.ico", "${appName}/src/assets"],
|
||||
"styles": ["${appName}/src/styles.css"],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
@ -119,16 +123,16 @@ const angularV1Json = (appName: string) => `{
|
||||
"builder": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/${appName}/src/**/*.ts",
|
||||
"apps/${appName}/src/**/*.html"
|
||||
"${appName}/src/**/*.ts",
|
||||
"${appName}/src/**/*.html"
|
||||
]
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@nx/jest:jest",
|
||||
"outputs": ["coverage/apps/${appName}"],
|
||||
"outputs": ["coverage${appName}"],
|
||||
"options": {
|
||||
"jestConfig": "apps/${appName}/jest.config.ts",
|
||||
"jestConfig": "${appName}/jest.config.ts",
|
||||
"passWithNoTests": true
|
||||
}
|
||||
}
|
||||
@ -136,14 +140,14 @@ const angularV1Json = (appName: string) => `{
|
||||
"tags": []
|
||||
},
|
||||
"${appName}-e2e": {
|
||||
"root": "apps/${appName}-e2e",
|
||||
"sourceRoot": "apps/${appName}-e2e/src",
|
||||
"root": "${appName}-e2e",
|
||||
"sourceRoot": "${appName}-e2e/src",
|
||||
"projectType": "application",
|
||||
"architect": {
|
||||
"e2e": {
|
||||
"builder": "@nx/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/${appName}-e2e/cypress.json",
|
||||
"cypressConfig": "${appName}-e2e/cypress.json",
|
||||
"devServerTarget": "${appName}:serve:development",
|
||||
"testingType": "e2e"
|
||||
},
|
||||
@ -157,7 +161,7 @@ const angularV1Json = (appName: string) => `{
|
||||
"builder": "@nx/linter:eslint",
|
||||
"outputs": ["{options.outputFile}"],
|
||||
"options": {
|
||||
"lintFilePatterns": ["apps/${appName}-e2e/**/*.{js,ts}"]
|
||||
"lintFilePatterns": ["${appName}-e2e/**/*.{js,ts}"]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -34,10 +34,18 @@ describe('Angular Module Federation', () => {
|
||||
const remotePort = 4301;
|
||||
|
||||
// generate host app
|
||||
runCLI(`generate @nx/angular:host ${hostApp} --style=css --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:host ${hostApp} --style=css --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
// generate remote app
|
||||
runCLI(
|
||||
`generate @nx/angular:remote ${remoteApp1} --host=${hostApp} --port=${remotePort} --style=css --no-interactive`
|
||||
`generate @nx/angular:remote ${remoteApp1} --host=${hostApp} --port=${remotePort} --style=css --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// check files are generated without the layout directory ("apps/")
|
||||
checkFilesExist(
|
||||
`${hostApp}/src/app/app.module.ts`,
|
||||
`${remoteApp1}/src/app/app.module.ts`
|
||||
);
|
||||
|
||||
// check default generated host is built successfully
|
||||
@ -46,14 +54,14 @@ describe('Angular Module Federation', () => {
|
||||
|
||||
// generate a shared lib with a seconary entry point
|
||||
runCLI(
|
||||
`generate @nx/angular:library ${sharedLib} --buildable --no-interactive`
|
||||
`generate @nx/angular:library ${sharedLib} --buildable --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:library-secondary-entry-point --library=${sharedLib} --name=${secondaryEntry} --no-interactive`
|
||||
);
|
||||
// update host & remote files to use shared library
|
||||
updateFile(
|
||||
`apps/${hostApp}/src/app/app.module.ts`,
|
||||
`${hostApp}/src/app/app.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { ${
|
||||
@ -91,7 +99,7 @@ describe('Angular Module Federation', () => {
|
||||
`
|
||||
);
|
||||
updateFile(
|
||||
`apps/${remoteApp1}/src/app/remote-entry/entry.module.ts`,
|
||||
`${remoteApp1}/src/app/remote-entry/entry.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
@ -138,9 +146,11 @@ describe('Angular Module Federation', () => {
|
||||
|
||||
// generate apps
|
||||
runCLI(
|
||||
`generate @nx/angular:application ${app1} --routing --no-interactive`
|
||||
`generate @nx/angular:application ${app1} --routing --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:application ${app2} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(`generate @nx/angular:application ${app2} --no-interactive`);
|
||||
|
||||
// convert apps
|
||||
runCLI(
|
||||
@ -168,7 +178,7 @@ describe('Angular Module Federation', () => {
|
||||
|
||||
// generate remote apps
|
||||
runCLI(
|
||||
`generate @nx/angular:host ${host} --ssr --remotes=${remote1},${remote2} --no-interactive`
|
||||
`generate @nx/angular:host ${host} --ssr --remotes=${remote1},${remote2} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// ports
|
||||
@ -196,7 +206,7 @@ describe('Angular Module Federation', () => {
|
||||
await killProcessAndPorts(process.pid, hostPort, remote1Port, remote2Port);
|
||||
}, 20_000_000);
|
||||
|
||||
it('should should support generating host and remote apps with the new name and root format', async () => {
|
||||
it('should should support generating host and remote apps with --project-name-and-root-format=derived', async () => {
|
||||
const hostApp = uniq('host');
|
||||
const remoteApp = uniq('remote');
|
||||
const hostPort = 4800;
|
||||
@ -204,17 +214,18 @@ describe('Angular Module Federation', () => {
|
||||
|
||||
// generate host app
|
||||
runCLI(
|
||||
`generate @nx/angular:host ${hostApp} --project-name-and-root-format=as-provided --no-interactive`
|
||||
`generate @nx/angular:host ${hostApp} --project-name-and-root-format=derived --no-interactive`
|
||||
);
|
||||
// generate remote app
|
||||
runCLI(
|
||||
`generate @nx/angular:remote ${remoteApp} --host=${hostApp} --port=${remotePort} --project-name-and-root-format=as-provided --no-interactive`
|
||||
`generate @nx/angular:remote ${remoteApp} --host=${hostApp} --port=${remotePort} --project-name-and-root-format=derived --no-interactive`
|
||||
);
|
||||
|
||||
// check files are generated without the layout directory ("apps/") and
|
||||
// using the project name as the directory when no directory is provided
|
||||
checkFilesExist(`${hostApp}/src/app/app.module.ts`);
|
||||
checkFilesExist(`${remoteApp}/src/app/app.module.ts`);
|
||||
// check files are generated with the layout directory ("apps/")
|
||||
checkFilesExist(
|
||||
`apps/${hostApp}/src/app/app.module.ts`,
|
||||
`apps/${remoteApp}/src/app/app.module.ts`
|
||||
);
|
||||
|
||||
// check default generated host is built successfully
|
||||
const buildOutput = runCLI(`build ${hostApp}`);
|
||||
|
||||
@ -27,20 +27,22 @@ describe('Angular Projects', () => {
|
||||
|
||||
beforeAll(() => {
|
||||
proj = newProject();
|
||||
runCLI(`generate @nx/angular:app ${app1} --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${lib1} --add-module-spec --no-interactive`
|
||||
`generate @nx/angular:app ${app1} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
app1DefaultModule = readFile(`apps/${app1}/src/app/app.module.ts`);
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${lib1} --add-module-spec --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
app1DefaultModule = readFile(`${app1}/src/app/app.module.ts`);
|
||||
app1DefaultComponentTemplate = readFile(
|
||||
`apps/${app1}/src/app/app.component.html`
|
||||
`${app1}/src/app/app.component.html`
|
||||
);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
updateFile(`apps/${app1}/src/app/app.module.ts`, app1DefaultModule);
|
||||
updateFile(`${app1}/src/app/app.module.ts`, app1DefaultModule);
|
||||
updateFile(
|
||||
`apps/${app1}/src/app/app.component.html`,
|
||||
`${app1}/src/app/app.component.html`,
|
||||
app1DefaultComponentTemplate
|
||||
);
|
||||
});
|
||||
@ -50,16 +52,16 @@ describe('Angular Projects', () => {
|
||||
it('should successfully generate apps and libs and work correctly', async () => {
|
||||
const standaloneApp = uniq('standalone-app');
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${standaloneApp} --directory=myDir --standalone=true --no-interactive`
|
||||
`generate @nx/angular:app ${standaloneApp} --directory=myDir/${standaloneApp} --standalone=true --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
const esbuildApp = uniq('esbuild-app');
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${esbuildApp} --bundler=esbuild --directory=myDir --no-interactive`
|
||||
`generate @nx/angular:app ${esbuildApp} --bundler=esbuild --directory=myDir/${esbuildApp} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
updateFile(
|
||||
`apps/${app1}/src/app/app.module.ts`,
|
||||
`${app1}/src/app/app.module.ts`,
|
||||
`
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
@ -78,14 +80,14 @@ describe('Angular Projects', () => {
|
||||
|
||||
// check build
|
||||
runCLI(
|
||||
`run-many --target build --projects=${app1},my-dir-${standaloneApp},my-dir-${esbuildApp} --parallel --prod --output-hashing none`
|
||||
`run-many --target build --projects=${app1},${standaloneApp},${esbuildApp} --parallel --prod --output-hashing none`
|
||||
);
|
||||
checkFilesExist(`dist/apps/${app1}/main.js`);
|
||||
checkFilesExist(`dist/apps/my-dir/${standaloneApp}/main.js`);
|
||||
checkFilesExist(`dist/apps/my-dir/${esbuildApp}/main.js`);
|
||||
checkFilesExist(`dist/${app1}/main.js`);
|
||||
checkFilesExist(`dist/my-dir/${standaloneApp}/main.js`);
|
||||
checkFilesExist(`dist/my-dir/${esbuildApp}/main.js`);
|
||||
// This is a loose requirement because there are a lot of
|
||||
// influences external from this project that affect this.
|
||||
const es2015BundleSize = getSize(tmpProjPath(`dist/apps/${app1}/main.js`));
|
||||
const es2015BundleSize = getSize(tmpProjPath(`dist/${app1}/main.js`));
|
||||
console.log(
|
||||
`The current es2015 bundle size is ${es2015BundleSize / 1000} KB`
|
||||
);
|
||||
@ -93,7 +95,7 @@ describe('Angular Projects', () => {
|
||||
|
||||
// check unit tests
|
||||
runCLI(
|
||||
`run-many --target test --projects=${app1},my-dir-${standaloneApp},my-dir-${esbuildApp},${lib1} --parallel`
|
||||
`run-many --target test --projects=${app1},${standaloneApp},${esbuildApp},${lib1} --parallel`
|
||||
);
|
||||
|
||||
// check e2e tests
|
||||
@ -113,7 +115,7 @@ describe('Angular Projects', () => {
|
||||
await killProcessAndPorts(process.pid, appPort);
|
||||
|
||||
const esbProcess = await runCommandUntil(
|
||||
`serve my-dir-${esbuildApp} -- --port=${appPort}`,
|
||||
`serve ${esbuildApp} -- --port=${appPort}`,
|
||||
(output) =>
|
||||
output.includes(`Application bundle generation complete`) &&
|
||||
output.includes(`localhost:${appPort}`)
|
||||
@ -127,7 +129,7 @@ describe('Angular Projects', () => {
|
||||
const app = uniq('app');
|
||||
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${app} --e2eTestRunner=playwright --no-interactive`
|
||||
`generate @nx/angular:app ${app} --e2eTestRunner=playwright --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
if (runE2ETests()) {
|
||||
@ -146,7 +148,7 @@ describe('Angular Projects', () => {
|
||||
// External HTML template file
|
||||
const templateWhichFailsBananaInBoxLintCheck = `<div ([foo])="bar"></div>`;
|
||||
updateFile(
|
||||
`apps/${app1}/src/app/app.component.html`,
|
||||
`${app1}/src/app/app.component.html`,
|
||||
templateWhichFailsBananaInBoxLintCheck
|
||||
);
|
||||
// Inline template within component.ts file
|
||||
@ -162,7 +164,7 @@ describe('Angular Projects', () => {
|
||||
export class InlineTemplateComponent {}
|
||||
`;
|
||||
updateFile(
|
||||
`apps/${app1}/src/app/inline-template.component.ts`,
|
||||
`${app1}/src/app/inline-template.component.ts`,
|
||||
wrappedAsInlineTemplate
|
||||
);
|
||||
|
||||
@ -170,12 +172,12 @@ describe('Angular Projects', () => {
|
||||
silenceError: true,
|
||||
});
|
||||
expect(appLintStdOut).toContain(
|
||||
normalize(`apps/${app1}/src/app/app.component.html`)
|
||||
normalize(`${app1}/src/app/app.component.html`)
|
||||
);
|
||||
expect(appLintStdOut).toContain(`1:6`);
|
||||
expect(appLintStdOut).toContain(`Invalid binding syntax`);
|
||||
expect(appLintStdOut).toContain(
|
||||
normalize(`apps/${app1}/src/app/inline-template.component.ts`)
|
||||
normalize(`${app1}/src/app/inline-template.component.ts`)
|
||||
);
|
||||
expect(appLintStdOut).toContain(`5:19`);
|
||||
expect(appLintStdOut).toContain(
|
||||
@ -185,29 +187,29 @@ describe('Angular Projects', () => {
|
||||
expect(appLintStdOut).toContain(`Invalid binding syntax`);
|
||||
|
||||
// cleanup added component
|
||||
removeFile(`apps/${app1}/src/app/inline-template.component.ts`);
|
||||
removeFile(`${app1}/src/app/inline-template.component.ts`);
|
||||
}, 1000000);
|
||||
|
||||
it('should build the dependent buildable lib and its child lib, as well as the app', async () => {
|
||||
// ARRANGE
|
||||
const esbuildApp = uniq('esbuild-app');
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${esbuildApp} --bundler=esbuild --no-interactive`
|
||||
`generate @nx/angular:app ${esbuildApp} --bundler=esbuild --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
const buildableLib = uniq('buildlib1');
|
||||
const buildableChildLib = uniq('buildlib2');
|
||||
|
||||
runCLI(
|
||||
`generate @nx/angular:library ${buildableLib} --buildable=true --no-interactive`
|
||||
`generate @nx/angular:library ${buildableLib} --buildable=true --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:library ${buildableChildLib} --buildable=true --no-interactive`
|
||||
`generate @nx/angular:library ${buildableChildLib} --buildable=true --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// update the app module to include a ref to the buildable lib
|
||||
updateFile(
|
||||
`apps/${app1}/src/app/app.module.ts`,
|
||||
`${app1}/src/app/app.module.ts`,
|
||||
`
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
@ -228,7 +230,7 @@ describe('Angular Projects', () => {
|
||||
`
|
||||
);
|
||||
updateFile(
|
||||
`apps/${esbuildApp}/src/app/app.module.ts`,
|
||||
`${esbuildApp}/src/app/app.module.ts`,
|
||||
`
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { NgModule } from '@angular/core';
|
||||
@ -251,7 +253,7 @@ describe('Angular Projects', () => {
|
||||
|
||||
// update the buildable lib module to include a ref to the buildable child lib
|
||||
updateFile(
|
||||
`libs/${buildableLib}/src/lib/${names(buildableLib).fileName}.module.ts`,
|
||||
`${buildableLib}/src/lib/${names(buildableLib).fileName}.module.ts`,
|
||||
`
|
||||
import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@ -299,11 +301,11 @@ describe('Angular Projects', () => {
|
||||
|
||||
// to proof it has been built from source the "main.js" should actually contain
|
||||
// the path to dist
|
||||
const mainBundle = readFile(`dist/apps/${app1}/main.js`);
|
||||
expect(mainBundle).toContain(`dist/libs/${buildableLib}`);
|
||||
const mainBundle = readFile(`dist/${app1}/main.js`);
|
||||
expect(mainBundle).toContain(`dist/${buildableLib}`);
|
||||
|
||||
const mainEsBuildBundle = readFile(`dist/apps/${esbuildApp}/main.js`);
|
||||
expect(mainEsBuildBundle).toContain(`dist/libs/${buildableLib}`);
|
||||
const mainEsBuildBundle = readFile(`dist/${esbuildApp}/main.js`);
|
||||
expect(mainEsBuildBundle).toContain(`dist/${buildableLib}`);
|
||||
});
|
||||
|
||||
it('should build publishable libs successfully', () => {
|
||||
@ -313,14 +315,14 @@ describe('Angular Projects', () => {
|
||||
const entryPoint = uniq('entrypoint');
|
||||
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${lib} --publishable --importPath=@${proj}/${lib} --no-interactive`
|
||||
`generate @nx/angular:lib ${lib} --publishable --importPath=@${proj}/${lib} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:secondary-entry-point --name=${entryPoint} --library=${lib} --no-interactive`
|
||||
);
|
||||
|
||||
runCLI(
|
||||
`generate @nx/angular:library ${childLib} --publishable=true --importPath=@${proj}/${childLib} --no-interactive`
|
||||
`generate @nx/angular:library ${childLib} --publishable=true --importPath=@${proj}/${childLib} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:secondary-entry-point --name=sub --library=${childLib} --no-interactive`
|
||||
@ -338,7 +340,7 @@ describe('Angular Projects', () => {
|
||||
})
|
||||
export class ${names(lib).className}Module {}`;
|
||||
|
||||
updateFile(`libs/${lib}/src/lib/${lib}.module.ts`, moduleContent);
|
||||
updateFile(`${lib}/src/lib/${lib}.module.ts`, moduleContent);
|
||||
|
||||
// ACT
|
||||
const buildOutput = runCLI(`build ${lib}`);
|
||||
@ -351,17 +353,16 @@ describe('Angular Projects', () => {
|
||||
expect(buildOutput).toContain('Successfully ran target build');
|
||||
});
|
||||
|
||||
it('should support generating projects with the new name and root format', () => {
|
||||
it('should support generating projects with --project-name-and-root-format=derived', () => {
|
||||
const appName = uniq('app1');
|
||||
const libName = uniq('@my-org/lib1');
|
||||
const libName = uniq('lib1');
|
||||
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${appName} --project-name-and-root-format=as-provided --no-interactive`
|
||||
`generate @nx/angular:app ${appName} --project-name-and-root-format=derived --no-interactive`
|
||||
);
|
||||
|
||||
// check files are generated without the layout directory ("apps/") and
|
||||
// using the project name as the directory when no directory is provided
|
||||
checkFilesExist(`${appName}/src/app/app.module.ts`);
|
||||
// check files are generated with the layout directory ("apps/")
|
||||
checkFilesExist(`apps/${appName}/src/app/app.module.ts`);
|
||||
// check build works
|
||||
expect(runCLI(`build ${appName}`)).toContain(
|
||||
`Successfully ran target build for project ${appName}`
|
||||
@ -372,6 +373,29 @@ describe('Angular Projects', () => {
|
||||
`Successfully ran target test for project ${appName}`
|
||||
);
|
||||
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${libName} --buildable --project-name-and-root-format=derived`
|
||||
);
|
||||
|
||||
// check files are generated with the layout directory ("libs/")
|
||||
checkFilesExist(
|
||||
`libs/${libName}/src/index.ts`,
|
||||
`libs/${libName}/src/lib/${libName}.module.ts`
|
||||
);
|
||||
// check build works
|
||||
expect(runCLI(`build ${libName}`)).toContain(
|
||||
`Successfully ran target build for project ${libName}`
|
||||
);
|
||||
// check tests pass
|
||||
const libTestResult = runCLI(`test ${libName}`);
|
||||
expect(libTestResult).toContain(
|
||||
`Successfully ran target test for project ${libName}`
|
||||
);
|
||||
}, 500_000);
|
||||
|
||||
it('should support generating libraries with a scoped name when --project-name-and-root-format=as-provided', () => {
|
||||
const libName = uniq('@my-org/lib1');
|
||||
|
||||
// assert scoped project names are not supported when --project-name-and-root-format=derived
|
||||
expect(() =>
|
||||
runCLI(
|
||||
|
||||
@ -78,14 +78,14 @@ describe('Angular Cypress Component Tests', () => {
|
||||
// add tailwind
|
||||
runCLI(`generate @nx/angular:setup-tailwind --project=${buildableLibName}`);
|
||||
updateFile(
|
||||
`libs/${buildableLibName}/src/lib/input/input.component.cy.ts`,
|
||||
`${buildableLibName}/src/lib/input/input.component.cy.ts`,
|
||||
(content) => {
|
||||
// text-green-500 should now apply
|
||||
return content.replace('rgb(0, 0, 0)', 'rgb(34, 197, 94)');
|
||||
}
|
||||
);
|
||||
updateFile(
|
||||
`libs/${buildableLibName}/src/lib/input-standalone/input-standalone.component.cy.ts`,
|
||||
`${buildableLibName}/src/lib/input-standalone/input-standalone.component.cy.ts`,
|
||||
(content) => {
|
||||
// text-green-500 should now apply
|
||||
return content.replace('rgb(0, 0, 0)', 'rgb(34, 197, 94)');
|
||||
@ -96,7 +96,7 @@ describe('Angular Cypress Component Tests', () => {
|
||||
expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain(
|
||||
'All specs passed!'
|
||||
);
|
||||
checkFilesDoNotExist(`tmp/libs/${buildableLibName}/ct-styles.css`);
|
||||
checkFilesDoNotExist(`tmp${buildableLibName}/ct-styles.css`);
|
||||
}
|
||||
}, 300_000);
|
||||
|
||||
@ -116,11 +116,9 @@ describe('Angular Cypress Component Tests', () => {
|
||||
});
|
||||
|
||||
it('should use root level tailwinds config', () => {
|
||||
useRootLevelTailwindConfig(
|
||||
join('libs', buildableLibName, 'tailwind.config.js')
|
||||
);
|
||||
useRootLevelTailwindConfig(join(buildableLibName, 'tailwind.config.js'));
|
||||
checkFilesExist('tailwind.config.js');
|
||||
checkFilesDoNotExist(`libs/${buildableLibName}/tailwind.config.js`);
|
||||
checkFilesDoNotExist(`${buildableLibName}/tailwind.config.js`);
|
||||
|
||||
if (runE2ETests()) {
|
||||
expect(runCLI(`component-test ${buildableLibName} --no-watch`)).toContain(
|
||||
@ -131,14 +129,18 @@ describe('Angular Cypress Component Tests', () => {
|
||||
});
|
||||
|
||||
function createApp(appName: string) {
|
||||
runCLI(`generate @nx/angular:app ${appName} --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${appName} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:component fancy-component --project=${appName} --no-interactive`
|
||||
);
|
||||
}
|
||||
|
||||
function createLib(projectName: string, appName: string, libName: string) {
|
||||
runCLI(`generate @nx/angular:lib ${libName} --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${libName} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:component btn --project=${libName} --inlineTemplate --inlineStyle --export --no-interactive`
|
||||
);
|
||||
@ -146,7 +148,7 @@ function createLib(projectName: string, appName: string, libName: string) {
|
||||
`generate @nx/angular:component btn-standalone --project=${libName} --inlineTemplate --inlineStyle --export --standalone --no-interactive`
|
||||
);
|
||||
updateFile(
|
||||
`libs/${libName}/src/lib/btn/btn.component.ts`,
|
||||
`${libName}/src/lib/btn/btn.component.ts`,
|
||||
`
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
@ -161,7 +163,7 @@ export class BtnComponent {
|
||||
`
|
||||
);
|
||||
updateFile(
|
||||
`libs/${libName}/src/lib/btn-standalone/btn-standalone.component.ts`,
|
||||
`${libName}/src/lib/btn-standalone/btn-standalone.component.ts`,
|
||||
`
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@ -181,7 +183,9 @@ export class BtnStandaloneComponent {
|
||||
|
||||
function createBuildableLib(projectName: string, libName: string) {
|
||||
// create lib
|
||||
runCLI(`generate @nx/angular:lib ${libName} --buildable --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${libName} --buildable --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
// create cmp for lib
|
||||
runCLI(
|
||||
`generate @nx/angular:component input --project=${libName} --inlineTemplate --inlineStyle --export --no-interactive`
|
||||
@ -192,7 +196,7 @@ function createBuildableLib(projectName: string, libName: string) {
|
||||
);
|
||||
// update cmp implmentation to use tailwind clasasserting in tests
|
||||
updateFile(
|
||||
`libs/${libName}/src/lib/input/input.component.ts`,
|
||||
`${libName}/src/lib/input/input.component.ts`,
|
||||
`
|
||||
import {Component, Input} from '@angular/core';
|
||||
|
||||
@ -207,7 +211,7 @@ import {Component, Input} from '@angular/core';
|
||||
`
|
||||
);
|
||||
updateFile(
|
||||
`libs/${libName}/src/lib/input-standalone/input-standalone.component.ts`,
|
||||
`${libName}/src/lib/input-standalone/input-standalone.component.ts`,
|
||||
`
|
||||
import {Component, Input} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
@ -227,7 +231,7 @@ import {CommonModule} from '@angular/common';
|
||||
|
||||
function useLibInApp(projectName: string, appName: string, libName: string) {
|
||||
createFile(
|
||||
`apps/${appName}/src/app/app.component.html`,
|
||||
`${appName}/src/app/app.component.html`,
|
||||
`
|
||||
<${projectName}-btn></${projectName}-btn>
|
||||
<${projectName}-btn-standalone></${projectName}-btn-standalone>
|
||||
@ -236,7 +240,7 @@ function useLibInApp(projectName: string, appName: string, libName: string) {
|
||||
);
|
||||
const btnModuleName = names(libName).className;
|
||||
updateFile(
|
||||
`apps/${appName}/src/app/app.component.scss`,
|
||||
`${appName}/src/app/app.component.scss`,
|
||||
`
|
||||
@use 'styleguide' as *;
|
||||
|
||||
@ -245,7 +249,7 @@ h1 {
|
||||
}`
|
||||
);
|
||||
updateFile(
|
||||
`apps/${appName}/src/app/app.module.ts`,
|
||||
`${appName}/src/app/app.module.ts`,
|
||||
`
|
||||
import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
@ -294,7 +298,7 @@ async function useWorkspaceAssetsInApp(appName: string) {
|
||||
|
||||
function updateTestToAssertTailwindIsNotApplied(libName: string) {
|
||||
createFile(
|
||||
`libs/${libName}/src/lib/input/input.component.cy.ts`,
|
||||
`${libName}/src/lib/input/input.component.cy.ts`,
|
||||
`
|
||||
import { MountConfig } from 'cypress/angular';
|
||||
import { InputComponent } from './input.component';
|
||||
@ -325,7 +329,7 @@ describe(InputComponent.name, () => {
|
||||
);
|
||||
|
||||
createFile(
|
||||
`libs/${libName}/src/lib/input-standalone/input-standalone.component.cy.ts`,
|
||||
`${libName}/src/lib/input-standalone/input-standalone.component.cy.ts`,
|
||||
`
|
||||
import { MountConfig } from 'cypress/angular';
|
||||
import { InputStandaloneComponent } from './input-standalone.component';
|
||||
@ -363,7 +367,7 @@ function useBuildableLibInLib(
|
||||
const buildLibNames = names(buildableLibName);
|
||||
// use the buildable lib in lib so now buildableLib has an indirect dep on app
|
||||
updateFile(
|
||||
`libs/${libName}/src/lib/btn-standalone/btn-standalone.component.ts`,
|
||||
`${libName}/src/lib/btn-standalone/btn-standalone.component.ts`,
|
||||
`
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@ -386,14 +390,11 @@ function updateBuilableLibTestsToAssertAppStyles(
|
||||
appName: string,
|
||||
buildableLibName: string
|
||||
) {
|
||||
updateFile(
|
||||
`apps/${appName}/src/styles.css`,
|
||||
`label {color: pink !important;}`
|
||||
);
|
||||
updateFile(`${appName}/src/styles.css`, `label {color: pink !important;}`);
|
||||
|
||||
removeFile(`libs/${buildableLibName}/src/lib/input/input.component.cy.ts`);
|
||||
removeFile(`${buildableLibName}/src/lib/input/input.component.cy.ts`);
|
||||
updateFile(
|
||||
`libs/${buildableLibName}/src/lib/input-standalone/input-standalone.component.cy.ts`,
|
||||
`${buildableLibName}/src/lib/input-standalone/input-standalone.component.cy.ts`,
|
||||
(content) => {
|
||||
// app styles should now apply
|
||||
return content.replace('rgb(34, 197, 94)', 'rgb(255, 192, 203)');
|
||||
|
||||
@ -20,11 +20,13 @@ describe('Angular Package', () => {
|
||||
|
||||
it('should work', async () => {
|
||||
const myapp = uniq('myapp');
|
||||
runCLI(`generate @nx/angular:app ${myapp} --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${myapp} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// Generate root ngrx state management
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx users --parent=apps/${myapp}/src/app/app.module.ts --root --minimal=false`
|
||||
`generate @nx/angular:ngrx users --parent=${myapp}/src/app/app.module.ts --root --minimal=false`
|
||||
);
|
||||
const packageJson = readJson('package.json');
|
||||
expect(packageJson.dependencies['@ngrx/store']).toBeDefined();
|
||||
@ -34,9 +36,11 @@ describe('Angular Package', () => {
|
||||
|
||||
const mylib = uniq('mylib');
|
||||
// Generate feature library and ngrx state within that library
|
||||
runCLI(`g @nx/angular:lib ${mylib} --prefix=fl`);
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx flights --parent=libs/${mylib}/src/lib/${mylib}.module.ts --facade`
|
||||
`g @nx/angular:lib ${mylib} --prefix=fl --project-name-and-root-format=as-provided`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx flights --parent=${mylib}/src/lib/${mylib}.module.ts --facade`
|
||||
);
|
||||
|
||||
expect(runCLI(`build ${myapp}`)).toMatch(/main\.[a-z0-9]+\.js/);
|
||||
@ -49,11 +53,13 @@ describe('Angular Package', () => {
|
||||
|
||||
it('should work with creators', async () => {
|
||||
const myapp = uniq('myapp');
|
||||
runCLI(`generate @nx/angular:app ${myapp} --routing --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${myapp} --routing --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// Generate root ngrx state management
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx users --parent=apps/${myapp}/src/app/app.module.ts --root`
|
||||
`generate @nx/angular:ngrx users --parent=${myapp}/src/app/app.module.ts --root`
|
||||
);
|
||||
const packageJson = readJson('package.json');
|
||||
expect(packageJson.dependencies['@ngrx/entity']).toBeDefined();
|
||||
@ -65,11 +71,13 @@ describe('Angular Package', () => {
|
||||
|
||||
const mylib = uniq('mylib');
|
||||
// Generate feature library and ngrx state within that library
|
||||
runCLI(`g @nx/angular:lib ${mylib} --prefix=fl`);
|
||||
runCLI(
|
||||
`g @nx/angular:lib ${mylib} --prefix=fl --project-name-and-root-format=as-provided`
|
||||
);
|
||||
|
||||
const flags = `--facade --barrels`;
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx flights --parent=libs/${mylib}/src/lib/${mylib}.module.ts ${flags}`
|
||||
`generate @nx/angular:ngrx flights --parent=${mylib}/src/lib/${mylib}.module.ts ${flags}`
|
||||
);
|
||||
|
||||
expect(runCLI(`build ${myapp}`)).toMatch(/main\.[a-z0-9]+\.js/);
|
||||
@ -82,11 +90,13 @@ describe('Angular Package', () => {
|
||||
|
||||
it('should work with creators using --module', async () => {
|
||||
const myapp = uniq('myapp');
|
||||
runCLI(`generate @nx/angular:app ${myapp} --routing --no-interactive`);
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${myapp} --routing --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
|
||||
// Generate root ngrx state management
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx users --parent=apps/${myapp}/src/app/app.module.ts --root`
|
||||
`generate @nx/angular:ngrx users --parent=${myapp}/src/app/app.module.ts --root`
|
||||
);
|
||||
const packageJson = readJson('package.json');
|
||||
expect(packageJson.dependencies['@ngrx/entity']).toBeDefined();
|
||||
@ -98,11 +108,13 @@ describe('Angular Package', () => {
|
||||
|
||||
const mylib = uniq('mylib');
|
||||
// Generate feature library and ngrx state within that library
|
||||
runCLI(`g @nx/angular:lib ${mylib} --prefix=fl`);
|
||||
runCLI(
|
||||
`g @nx/angular:lib ${mylib} --prefix=fl --project-name-and-root-format=as-provided`
|
||||
);
|
||||
|
||||
const flags = `--facade --barrels`;
|
||||
runCLI(
|
||||
`generate @nx/angular:ngrx flights --module=libs/${mylib}/src/lib/${mylib}.module.ts ${flags}`
|
||||
`generate @nx/angular:ngrx flights --module=${mylib}/src/lib/${mylib}.module.ts ${flags}`
|
||||
);
|
||||
|
||||
expect(runCLI(`build ${myapp}`)).toMatch(/main\.[a-z0-9]+\.js/);
|
||||
|
||||
@ -10,8 +10,6 @@ import {
|
||||
updateProjectConfig,
|
||||
} from '@nx/e2e/utils';
|
||||
|
||||
// TODO(Colum or Leosvel): Investigate and fix these tests
|
||||
|
||||
describe('Tailwind support', () => {
|
||||
let project: string;
|
||||
|
||||
@ -54,8 +52,8 @@ describe('Tailwind support', () => {
|
||||
|
||||
const tailwindConfig = `module.exports = {
|
||||
content: [
|
||||
'./apps/**/!(*.stories|*.spec).{ts,html}',
|
||||
'./libs/**/!(*.stories|*.spec).{ts,html}',
|
||||
'**/!(*.stories|*.spec).{ts,html}',
|
||||
'**/!(*.stories|*.spec).{ts,html}',
|
||||
],
|
||||
theme: {
|
||||
spacing: {
|
||||
@ -133,7 +131,7 @@ describe('Tailwind support', () => {
|
||||
buttonBgColor: string = defaultButtonBgColor
|
||||
) => {
|
||||
updateFile(
|
||||
`libs/${lib}/src/lib/foo.component.ts`,
|
||||
`${lib}/src/lib/foo.component.ts`,
|
||||
`import { Component } from '@angular/core';
|
||||
|
||||
@Component({
|
||||
@ -150,7 +148,7 @@ describe('Tailwind support', () => {
|
||||
);
|
||||
|
||||
updateFile(
|
||||
`libs/${lib}/src/lib/${lib}.module.ts`,
|
||||
`${lib}/src/lib/${lib}.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FooComponent } from './foo.component';
|
||||
@ -165,7 +163,7 @@ describe('Tailwind support', () => {
|
||||
);
|
||||
|
||||
updateFile(
|
||||
`libs/${lib}/src/index.ts`,
|
||||
`${lib}/src/index.ts`,
|
||||
`export * from './lib/foo.component';
|
||||
export * from './lib/${lib}.module';
|
||||
`
|
||||
@ -177,7 +175,7 @@ describe('Tailwind support', () => {
|
||||
libSpacing: typeof spacing['root']
|
||||
) => {
|
||||
const builtComponentContent = readFile(
|
||||
`dist/libs/${lib}/esm2022/lib/foo.component.mjs`
|
||||
`dist/${lib}/esm2022/lib/foo.component.mjs`
|
||||
);
|
||||
let expectedStylesRegex = new RegExp(
|
||||
`styles: \\[\\"\\.custom\\-btn(\\[_ngcontent\\-%COMP%\\])?{margin:${libSpacing.md};padding:${libSpacing.sm}}(\\\\n)?\\"\\]`
|
||||
@ -188,10 +186,10 @@ describe('Tailwind support', () => {
|
||||
|
||||
it('should generate a buildable library with tailwind and build correctly', () => {
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${buildLibWithTailwind.name} --buildable --add-tailwind --no-interactive`
|
||||
`generate @nx/angular:lib ${buildLibWithTailwind.name} --buildable --add-tailwind --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
updateTailwindConfig(
|
||||
`libs/${buildLibWithTailwind.name}/tailwind.config.js`,
|
||||
`${buildLibWithTailwind.name}/tailwind.config.js`,
|
||||
spacing.projectVariant1
|
||||
);
|
||||
createLibComponent(
|
||||
@ -210,13 +208,13 @@ describe('Tailwind support', () => {
|
||||
it('should set up tailwind in a previously generated buildable library and build correctly', () => {
|
||||
const buildLibSetupTailwind = uniq('build-lib-setup-tailwind');
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${buildLibSetupTailwind} --buildable --no-interactive`
|
||||
`generate @nx/angular:lib ${buildLibSetupTailwind} --buildable --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:setup-tailwind ${buildLibSetupTailwind} --no-interactive`
|
||||
);
|
||||
updateTailwindConfig(
|
||||
`libs/${buildLibSetupTailwind}/tailwind.config.js`,
|
||||
`${buildLibSetupTailwind}/tailwind.config.js`,
|
||||
spacing.projectVariant2
|
||||
);
|
||||
createLibComponent(buildLibSetupTailwind);
|
||||
@ -229,10 +227,10 @@ describe('Tailwind support', () => {
|
||||
it('should correctly build a buildable library with a tailwind.config.js file in the project root or workspace root', () => {
|
||||
const buildLibNoProjectConfig = uniq('build-lib-no-project-config');
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${buildLibNoProjectConfig} --buildable --no-interactive`
|
||||
`generate @nx/angular:lib ${buildLibNoProjectConfig} --buildable --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
createTailwindConfigFile(
|
||||
`libs/${buildLibNoProjectConfig}/tailwind.config.js`,
|
||||
`${buildLibNoProjectConfig}/tailwind.config.js`,
|
||||
spacing.projectVariant3
|
||||
);
|
||||
createLibComponent(buildLibNoProjectConfig);
|
||||
@ -245,7 +243,7 @@ describe('Tailwind support', () => {
|
||||
);
|
||||
|
||||
// remove tailwind.config.js file from the project root to test the one in the workspace root
|
||||
removeFile(`libs/${buildLibNoProjectConfig}/tailwind.config.js`);
|
||||
removeFile(`${buildLibNoProjectConfig}/tailwind.config.js`);
|
||||
|
||||
runCLI(`build ${buildLibNoProjectConfig}`);
|
||||
|
||||
@ -254,10 +252,10 @@ describe('Tailwind support', () => {
|
||||
|
||||
it('should generate a publishable library with tailwind and build correctly', () => {
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${pubLibWithTailwind.name} --publishable --add-tailwind --importPath=@${project}/${pubLibWithTailwind.name} --no-interactive`
|
||||
`generate @nx/angular:lib ${pubLibWithTailwind.name} --publishable --add-tailwind --importPath=@${project}/${pubLibWithTailwind.name} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
updateTailwindConfig(
|
||||
`libs/${pubLibWithTailwind.name}/tailwind.config.js`,
|
||||
`${pubLibWithTailwind.name}/tailwind.config.js`,
|
||||
spacing.projectVariant1
|
||||
);
|
||||
createLibComponent(
|
||||
@ -276,13 +274,13 @@ describe('Tailwind support', () => {
|
||||
it('should set up tailwind in a previously generated publishable library and build correctly', () => {
|
||||
const pubLibSetupTailwind = uniq('pub-lib-setup-tailwind');
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${pubLibSetupTailwind} --publishable --importPath=@${project}/${pubLibSetupTailwind} --no-interactive`
|
||||
`generate @nx/angular:lib ${pubLibSetupTailwind} --publishable --importPath=@${project}/${pubLibSetupTailwind} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
runCLI(
|
||||
`generate @nx/angular:setup-tailwind ${pubLibSetupTailwind} --no-interactive`
|
||||
);
|
||||
updateTailwindConfig(
|
||||
`libs/${pubLibSetupTailwind}/tailwind.config.js`,
|
||||
`${pubLibSetupTailwind}/tailwind.config.js`,
|
||||
spacing.projectVariant2
|
||||
);
|
||||
createLibComponent(pubLibSetupTailwind);
|
||||
@ -295,10 +293,10 @@ describe('Tailwind support', () => {
|
||||
it('should correctly build a publishable library with a tailwind.config.js file in the project root or workspace root', () => {
|
||||
const pubLibNoProjectConfig = uniq('pub-lib-no-project-config');
|
||||
runCLI(
|
||||
`generate @nx/angular:lib ${pubLibNoProjectConfig} --publishable --importPath=@${project}/${pubLibNoProjectConfig} --no-interactive`
|
||||
`generate @nx/angular:lib ${pubLibNoProjectConfig} --publishable --importPath=@${project}/${pubLibNoProjectConfig} --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
createTailwindConfigFile(
|
||||
`libs/${pubLibNoProjectConfig}/tailwind.config.js`,
|
||||
`${pubLibNoProjectConfig}/tailwind.config.js`,
|
||||
spacing.projectVariant3
|
||||
);
|
||||
createLibComponent(pubLibNoProjectConfig);
|
||||
@ -308,7 +306,7 @@ describe('Tailwind support', () => {
|
||||
assertLibComponentStyles(pubLibNoProjectConfig, spacing.projectVariant3);
|
||||
|
||||
// remove tailwind.config.js file from the project root to test the one in the workspace root
|
||||
removeFile(`libs/${pubLibNoProjectConfig}/tailwind.config.js`);
|
||||
removeFile(`${pubLibNoProjectConfig}/tailwind.config.js`);
|
||||
|
||||
runCLI(`build ${pubLibNoProjectConfig}`);
|
||||
|
||||
@ -319,12 +317,12 @@ describe('Tailwind support', () => {
|
||||
describe('Applications', () => {
|
||||
const updateAppComponent = (app: string) => {
|
||||
updateFile(
|
||||
`apps/${app}/src/app/app.component.html`,
|
||||
`${app}/src/app/app.component.html`,
|
||||
`<button class="custom-btn text-white">Click me!</button>`
|
||||
);
|
||||
|
||||
updateFile(
|
||||
`apps/${app}/src/app/app.component.css`,
|
||||
`${app}/src/app/app.component.css`,
|
||||
`.custom-btn {
|
||||
@apply m-md p-sm;
|
||||
}`
|
||||
@ -332,10 +330,10 @@ describe('Tailwind support', () => {
|
||||
};
|
||||
|
||||
const readAppStylesBundle = (app: string) => {
|
||||
const stylesBundlePath = listFiles(`dist/apps/${app}`).find((file) =>
|
||||
const stylesBundlePath = listFiles(`dist/${app}`).find((file) =>
|
||||
file.startsWith('styles.')
|
||||
);
|
||||
const stylesBundle = readFile(`dist/apps/${app}/${stylesBundlePath}`);
|
||||
const stylesBundle = readFile(`dist/${app}/${stylesBundlePath}`);
|
||||
|
||||
return stylesBundle;
|
||||
};
|
||||
@ -344,10 +342,10 @@ describe('Tailwind support', () => {
|
||||
app: string,
|
||||
appSpacing: typeof spacing['root']
|
||||
) => {
|
||||
const mainBundlePath = listFiles(`dist/apps/${app}`).find((file) =>
|
||||
const mainBundlePath = listFiles(`dist/${app}`).find((file) =>
|
||||
file.startsWith('main.')
|
||||
);
|
||||
const mainBundle = readFile(`dist/apps/${app}/${mainBundlePath}`);
|
||||
const mainBundle = readFile(`dist/${app}/${mainBundlePath}`);
|
||||
let expectedStylesRegex = new RegExp(
|
||||
`styles:\\[\\"\\.custom\\-btn\\[_ngcontent\\-%COMP%\\]{margin:${appSpacing.md};padding:${appSpacing.sm}}\\"\\]`
|
||||
);
|
||||
@ -358,7 +356,7 @@ describe('Tailwind support', () => {
|
||||
it('should build correctly and only output the tailwind utilities used', async () => {
|
||||
const appWithTailwind = uniq('app-with-tailwind');
|
||||
runCLI(
|
||||
`generate @nx/angular:app ${appWithTailwind} --add-tailwind --no-interactive`
|
||||
`generate @nx/angular:app ${appWithTailwind} --add-tailwind --project-name-and-root-format=as-provided --no-interactive`
|
||||
);
|
||||
await updateProjectConfig(appWithTailwind, (config) => {
|
||||
config.targets.build.executor = '@nx/angular:webpack-browser';
|
||||
@ -369,11 +367,11 @@ describe('Tailwind support', () => {
|
||||
return config;
|
||||
});
|
||||
updateTailwindConfig(
|
||||
`apps/${appWithTailwind}/tailwind.config.js`,
|
||||
`${appWithTailwind}/tailwind.config.js`,
|
||||
spacing.projectVariant1
|
||||
);
|
||||
updateFile(
|
||||
`apps/${appWithTailwind}/src/app/app.module.ts`,
|
||||
`${appWithTailwind}/src/app/app.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { LibModule as LibModule1 } from '@${project}/${buildLibWithTailwind.name}';
|
||||
|
||||
@ -206,6 +206,486 @@ exports[`app --minimal should skip "nx-welcome.component.ts" file and references
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when directory is provided 1`] = `
|
||||
{
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"name": "my-dir-my-app",
|
||||
"prefix": "proj",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-dir/my-app",
|
||||
"sourceRoot": "apps/my-dir/my-app/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"extractLicenses": false,
|
||||
"namedChunks": true,
|
||||
"optimization": false,
|
||||
"sourceMap": true,
|
||||
"vendorChunk": true,
|
||||
},
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"maximumError": "1mb",
|
||||
"maximumWarning": "500kb",
|
||||
"type": "initial",
|
||||
},
|
||||
{
|
||||
"maximumError": "4kb",
|
||||
"maximumWarning": "2kb",
|
||||
"type": "anyComponentStyle",
|
||||
},
|
||||
],
|
||||
"outputHashing": "all",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "production",
|
||||
"executor": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"assets": [
|
||||
"apps/my-dir/my-app/src/favicon.ico",
|
||||
"apps/my-dir/my-app/src/assets",
|
||||
],
|
||||
"index": "apps/my-dir/my-app/src/index.html",
|
||||
"main": "apps/my-dir/my-app/src/main.ts",
|
||||
"outputPath": "dist/apps/my-dir/my-app",
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
],
|
||||
"scripts": [],
|
||||
"styles": [
|
||||
"apps/my-dir/my-app/src/styles.css",
|
||||
],
|
||||
"tsConfig": "apps/my-dir/my-app/tsconfig.app.json",
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputPath}",
|
||||
],
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "my-dir-my-app:build",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-dir/my-app/**/*.ts",
|
||||
"apps/my-dir/my-app/**/*.html",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
"serve": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"browserTarget": "my-dir-my-app:build:development",
|
||||
},
|
||||
"production": {
|
||||
"browserTarget": "my-dir-my-app:build:production",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "development",
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
},
|
||||
"serve-static": {
|
||||
"executor": "@nx/web:file-server",
|
||||
"options": {
|
||||
"buildTarget": "my-dir-my-app:build",
|
||||
},
|
||||
},
|
||||
"test": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true,
|
||||
},
|
||||
},
|
||||
"executor": "@nx/jest:jest",
|
||||
"options": {
|
||||
"jestConfig": "apps/my-dir/my-app/jest.config.ts",
|
||||
"passWithNoTests": true,
|
||||
},
|
||||
"outputs": [
|
||||
"{workspaceRoot}/coverage/{projectRoot}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when directory is provided 2`] = `
|
||||
{
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"implicitDependencies": [
|
||||
"my-dir-my-app",
|
||||
],
|
||||
"name": "my-dir-my-app-e2e",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-dir/my-app-e2e",
|
||||
"sourceRoot": "apps/my-dir/my-app-e2e/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"devServerTarget": "my-dir-my-app:serve-static",
|
||||
},
|
||||
"production": {
|
||||
"devServerTarget": "my-dir-my-app:serve:production",
|
||||
},
|
||||
},
|
||||
"executor": "@nx/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/my-dir/my-app-e2e/cypress.config.ts",
|
||||
"devServerTarget": "my-dir-my-app:serve:development",
|
||||
"testingType": "e2e",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-dir/my-app-e2e/**/*.{js,ts}",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when directory is provided: e2e tsconfig.json 1`] = `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"outDir": "../../../dist/out-tsc",
|
||||
"sourceMap": false,
|
||||
"strict": true,
|
||||
"types": [
|
||||
"cypress",
|
||||
"node",
|
||||
],
|
||||
},
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
"cypress.config.ts",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when directory is provided: tsconfig.app.json 1`] = `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "../../../dist/out-tsc",
|
||||
"types": [],
|
||||
},
|
||||
"exclude": [
|
||||
"jest.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
],
|
||||
"extends": "./tsconfig.json",
|
||||
"files": [
|
||||
"src/main.ts",
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when directory is provided: tsconfig.json 1`] = `
|
||||
{
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true,
|
||||
},
|
||||
"compilerOptions": {
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"strict": true,
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
},
|
||||
"extends": "../../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json",
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json",
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.editor.json",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when no directory is provided 1`] = `
|
||||
{
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"name": "my-app",
|
||||
"prefix": "proj",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-app",
|
||||
"sourceRoot": "apps/my-app/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"extractLicenses": false,
|
||||
"namedChunks": true,
|
||||
"optimization": false,
|
||||
"sourceMap": true,
|
||||
"vendorChunk": true,
|
||||
},
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"maximumError": "1mb",
|
||||
"maximumWarning": "500kb",
|
||||
"type": "initial",
|
||||
},
|
||||
{
|
||||
"maximumError": "4kb",
|
||||
"maximumWarning": "2kb",
|
||||
"type": "anyComponentStyle",
|
||||
},
|
||||
],
|
||||
"outputHashing": "all",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "production",
|
||||
"executor": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"assets": [
|
||||
"apps/my-app/src/favicon.ico",
|
||||
"apps/my-app/src/assets",
|
||||
],
|
||||
"index": "apps/my-app/src/index.html",
|
||||
"main": "apps/my-app/src/main.ts",
|
||||
"outputPath": "dist/apps/my-app",
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
],
|
||||
"scripts": [],
|
||||
"styles": [
|
||||
"apps/my-app/src/styles.css",
|
||||
],
|
||||
"tsConfig": "apps/my-app/tsconfig.app.json",
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputPath}",
|
||||
],
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "my-app:build",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-app/**/*.ts",
|
||||
"apps/my-app/**/*.html",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
"serve": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"browserTarget": "my-app:build:development",
|
||||
},
|
||||
"production": {
|
||||
"browserTarget": "my-app:build:production",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "development",
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
},
|
||||
"serve-static": {
|
||||
"executor": "@nx/web:file-server",
|
||||
"options": {
|
||||
"buildTarget": "my-app:build",
|
||||
},
|
||||
},
|
||||
"test": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true,
|
||||
},
|
||||
},
|
||||
"executor": "@nx/jest:jest",
|
||||
"options": {
|
||||
"jestConfig": "apps/my-app/jest.config.ts",
|
||||
"passWithNoTests": true,
|
||||
},
|
||||
"outputs": [
|
||||
"{workspaceRoot}/coverage/{projectRoot}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when no directory is provided 2`] = `
|
||||
{
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"implicitDependencies": [
|
||||
"my-app",
|
||||
],
|
||||
"name": "my-app-e2e",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-app-e2e",
|
||||
"sourceRoot": "apps/my-app-e2e/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"devServerTarget": "my-app:serve-static",
|
||||
},
|
||||
"production": {
|
||||
"devServerTarget": "my-app:serve:production",
|
||||
},
|
||||
},
|
||||
"executor": "@nx/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/my-app-e2e/cypress.config.ts",
|
||||
"devServerTarget": "my-app:serve:development",
|
||||
"testingType": "e2e",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-app-e2e/**/*.{js,ts}",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when no directory is provided: e2e tsconfig.json 1`] = `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowJs": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"sourceMap": false,
|
||||
"strict": true,
|
||||
"types": [
|
||||
"cypress",
|
||||
"node",
|
||||
],
|
||||
},
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
"cypress.config.ts",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when no directory is provided: tsconfig.app.json 1`] = `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"types": [],
|
||||
},
|
||||
"exclude": [
|
||||
"jest.config.ts",
|
||||
"src/**/*.test.ts",
|
||||
"src/**/*.spec.ts",
|
||||
],
|
||||
"extends": "./tsconfig.json",
|
||||
"files": [
|
||||
"src/main.ts",
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts",
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --project-name-and-root-format=derived should generate correctly when no directory is provided: tsconfig.json 1`] = `
|
||||
{
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true,
|
||||
},
|
||||
"compilerOptions": {
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"strict": true,
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
},
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
{
|
||||
"path": "./tsconfig.app.json",
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.spec.json",
|
||||
},
|
||||
{
|
||||
"path": "./tsconfig.editor.json",
|
||||
},
|
||||
],
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app --standalone should generate a standalone app correctly with routing 1`] = `
|
||||
"import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
@ -372,7 +852,7 @@ exports[`app --strict should enable strict type checking: app tsconfig.json 1`]
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
},
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"extends": "../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
@ -398,7 +878,7 @@ exports[`app --strict should enable strict type checking: e2e tsconfig.json 1`]
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"outDir": "../dist/out-tsc",
|
||||
"sourceMap": false,
|
||||
"strict": true,
|
||||
"types": [
|
||||
@ -406,7 +886,7 @@ exports[`app --strict should enable strict type checking: e2e tsconfig.json 1`]
|
||||
"node",
|
||||
],
|
||||
},
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"extends": "../tsconfig.base.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
@ -418,171 +898,13 @@ exports[`app --strict should enable strict type checking: e2e tsconfig.json 1`]
|
||||
exports[`app at the root should accept numbers in the path 1`] = `"src/9-websites/my-app"`;
|
||||
|
||||
exports[`app nested should create project configs 1`] = `
|
||||
{
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"name": "my-dir-my-app",
|
||||
"prefix": "proj",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-dir/my-app",
|
||||
"sourceRoot": "apps/my-dir/my-app/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"extractLicenses": false,
|
||||
"namedChunks": true,
|
||||
"optimization": false,
|
||||
"sourceMap": true,
|
||||
"vendorChunk": true,
|
||||
},
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"maximumError": "1mb",
|
||||
"maximumWarning": "500kb",
|
||||
"type": "initial",
|
||||
},
|
||||
{
|
||||
"maximumError": "4kb",
|
||||
"maximumWarning": "2kb",
|
||||
"type": "anyComponentStyle",
|
||||
},
|
||||
],
|
||||
"outputHashing": "all",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "production",
|
||||
"executor": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"assets": [
|
||||
"apps/my-dir/my-app/src/favicon.ico",
|
||||
"apps/my-dir/my-app/src/assets",
|
||||
],
|
||||
"index": "apps/my-dir/my-app/src/index.html",
|
||||
"main": "apps/my-dir/my-app/src/main.ts",
|
||||
"outputPath": "dist/apps/my-dir/my-app",
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
],
|
||||
"scripts": [],
|
||||
"styles": [
|
||||
"apps/my-dir/my-app/src/styles.css",
|
||||
],
|
||||
"tsConfig": "apps/my-dir/my-app/tsconfig.app.json",
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputPath}",
|
||||
],
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "my-dir-my-app:build",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-dir/my-app/**/*.ts",
|
||||
"apps/my-dir/my-app/**/*.html",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
"serve": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"browserTarget": "my-dir-my-app:build:development",
|
||||
},
|
||||
"production": {
|
||||
"browserTarget": "my-dir-my-app:build:production",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "development",
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
},
|
||||
"serve-static": {
|
||||
"executor": "@nx/web:file-server",
|
||||
"options": {
|
||||
"buildTarget": "my-dir-my-app:build",
|
||||
},
|
||||
},
|
||||
"test": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true,
|
||||
},
|
||||
},
|
||||
"executor": "@nx/jest:jest",
|
||||
"options": {
|
||||
"jestConfig": "apps/my-dir/my-app/jest.config.ts",
|
||||
"passWithNoTests": true,
|
||||
},
|
||||
"outputs": [
|
||||
"{workspaceRoot}/coverage/{projectRoot}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app nested should create project configs 2`] = `
|
||||
{
|
||||
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
||||
"implicitDependencies": [
|
||||
"my-dir-my-app",
|
||||
],
|
||||
"name": "my-dir-my-app-e2e",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-dir/my-app-e2e",
|
||||
"sourceRoot": "apps/my-dir/my-app-e2e/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"devServerTarget": "my-dir-my-app:serve-static",
|
||||
},
|
||||
"production": {
|
||||
"devServerTarget": "my-dir-my-app:serve:production",
|
||||
},
|
||||
},
|
||||
"executor": "@nx/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/my-dir/my-app-e2e/cypress.config.ts",
|
||||
"devServerTarget": "my-dir-my-app:serve:development",
|
||||
"testingType": "e2e",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-dir/my-app-e2e/**/*.{js,ts}",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app not nested should create project configs 1`] = `
|
||||
{
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"name": "my-app",
|
||||
"prefix": "proj",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-app",
|
||||
"sourceRoot": "apps/my-app/src",
|
||||
"root": "my-dir/my-app",
|
||||
"sourceRoot": "my-dir/my-app/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
@ -615,20 +937,20 @@ exports[`app not nested should create project configs 1`] = `
|
||||
"executor": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"assets": [
|
||||
"apps/my-app/src/favicon.ico",
|
||||
"apps/my-app/src/assets",
|
||||
"my-dir/my-app/src/favicon.ico",
|
||||
"my-dir/my-app/src/assets",
|
||||
],
|
||||
"index": "apps/my-app/src/index.html",
|
||||
"main": "apps/my-app/src/main.ts",
|
||||
"outputPath": "dist/apps/my-app",
|
||||
"index": "my-dir/my-app/src/index.html",
|
||||
"main": "my-dir/my-app/src/main.ts",
|
||||
"outputPath": "dist/my-dir/my-app",
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
],
|
||||
"scripts": [],
|
||||
"styles": [
|
||||
"apps/my-app/src/styles.css",
|
||||
"my-dir/my-app/src/styles.css",
|
||||
],
|
||||
"tsConfig": "apps/my-app/tsconfig.app.json",
|
||||
"tsConfig": "my-dir/my-app/tsconfig.app.json",
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputPath}",
|
||||
@ -644,8 +966,8 @@ exports[`app not nested should create project configs 1`] = `
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-app/**/*.ts",
|
||||
"apps/my-app/**/*.html",
|
||||
"my-dir/my-app/**/*.ts",
|
||||
"my-dir/my-app/**/*.html",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
@ -679,7 +1001,7 @@ exports[`app not nested should create project configs 1`] = `
|
||||
},
|
||||
"executor": "@nx/jest:jest",
|
||||
"options": {
|
||||
"jestConfig": "apps/my-app/jest.config.ts",
|
||||
"jestConfig": "my-dir/my-app/jest.config.ts",
|
||||
"passWithNoTests": true,
|
||||
},
|
||||
"outputs": [
|
||||
@ -690,7 +1012,7 @@ exports[`app not nested should create project configs 1`] = `
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app not nested should create project configs 2`] = `
|
||||
exports[`app nested should create project configs 2`] = `
|
||||
{
|
||||
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
||||
"implicitDependencies": [
|
||||
@ -698,8 +1020,8 @@ exports[`app not nested should create project configs 2`] = `
|
||||
],
|
||||
"name": "my-app-e2e",
|
||||
"projectType": "application",
|
||||
"root": "apps/my-app-e2e",
|
||||
"sourceRoot": "apps/my-app-e2e/src",
|
||||
"root": "my-dir/my-app-e2e",
|
||||
"sourceRoot": "my-dir/my-app-e2e/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"e2e": {
|
||||
@ -713,7 +1035,7 @@ exports[`app not nested should create project configs 2`] = `
|
||||
},
|
||||
"executor": "@nx/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "apps/my-app-e2e/cypress.config.ts",
|
||||
"cypressConfig": "my-dir/my-app-e2e/cypress.config.ts",
|
||||
"devServerTarget": "my-app:serve:development",
|
||||
"testingType": "e2e",
|
||||
},
|
||||
@ -722,7 +1044,165 @@ exports[`app not nested should create project configs 2`] = `
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-app-e2e/**/*.{js,ts}",
|
||||
"my-dir/my-app-e2e/**/*.{js,ts}",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app not nested should create project configs 1`] = `
|
||||
{
|
||||
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
||||
"name": "my-app",
|
||||
"prefix": "proj",
|
||||
"projectType": "application",
|
||||
"root": "my-app",
|
||||
"sourceRoot": "my-app/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"build": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"buildOptimizer": false,
|
||||
"extractLicenses": false,
|
||||
"namedChunks": true,
|
||||
"optimization": false,
|
||||
"sourceMap": true,
|
||||
"vendorChunk": true,
|
||||
},
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"maximumError": "1mb",
|
||||
"maximumWarning": "500kb",
|
||||
"type": "initial",
|
||||
},
|
||||
{
|
||||
"maximumError": "4kb",
|
||||
"maximumWarning": "2kb",
|
||||
"type": "anyComponentStyle",
|
||||
},
|
||||
],
|
||||
"outputHashing": "all",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "production",
|
||||
"executor": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"assets": [
|
||||
"my-app/src/favicon.ico",
|
||||
"my-app/src/assets",
|
||||
],
|
||||
"index": "my-app/src/index.html",
|
||||
"main": "my-app/src/main.ts",
|
||||
"outputPath": "dist/my-app",
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
],
|
||||
"scripts": [],
|
||||
"styles": [
|
||||
"my-app/src/styles.css",
|
||||
],
|
||||
"tsConfig": "my-app/tsconfig.app.json",
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputPath}",
|
||||
],
|
||||
},
|
||||
"extract-i18n": {
|
||||
"executor": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"browserTarget": "my-app:build",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"my-app/**/*.ts",
|
||||
"my-app/**/*.html",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
"{options.outputFile}",
|
||||
],
|
||||
},
|
||||
"serve": {
|
||||
"configurations": {
|
||||
"development": {
|
||||
"browserTarget": "my-app:build:development",
|
||||
},
|
||||
"production": {
|
||||
"browserTarget": "my-app:build:production",
|
||||
},
|
||||
},
|
||||
"defaultConfiguration": "development",
|
||||
"executor": "@angular-devkit/build-angular:dev-server",
|
||||
},
|
||||
"serve-static": {
|
||||
"executor": "@nx/web:file-server",
|
||||
"options": {
|
||||
"buildTarget": "my-app:build",
|
||||
},
|
||||
},
|
||||
"test": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"ci": true,
|
||||
"codeCoverage": true,
|
||||
},
|
||||
},
|
||||
"executor": "@nx/jest:jest",
|
||||
"options": {
|
||||
"jestConfig": "my-app/jest.config.ts",
|
||||
"passWithNoTests": true,
|
||||
},
|
||||
"outputs": [
|
||||
"{workspaceRoot}/coverage/{projectRoot}",
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
exports[`app not nested should create project configs 2`] = `
|
||||
{
|
||||
"$schema": "../node_modules/nx/schemas/project-schema.json",
|
||||
"implicitDependencies": [
|
||||
"my-app",
|
||||
],
|
||||
"name": "my-app-e2e",
|
||||
"projectType": "application",
|
||||
"root": "my-app-e2e",
|
||||
"sourceRoot": "my-app-e2e/src",
|
||||
"tags": [],
|
||||
"targets": {
|
||||
"e2e": {
|
||||
"configurations": {
|
||||
"ci": {
|
||||
"devServerTarget": "my-app:serve-static",
|
||||
},
|
||||
"production": {
|
||||
"devServerTarget": "my-app:serve:production",
|
||||
},
|
||||
},
|
||||
"executor": "@nx/cypress:cypress",
|
||||
"options": {
|
||||
"cypressConfig": "my-app-e2e/cypress.config.ts",
|
||||
"devServerTarget": "my-app:serve:development",
|
||||
"testingType": "e2e",
|
||||
},
|
||||
},
|
||||
"lint": {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"my-app-e2e/**/*.{js,ts}",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
@ -742,7 +1222,7 @@ exports[`app not nested should generate files: e2e tsconfig.json 1`] = `
|
||||
"noImplicitOverride": true,
|
||||
"noImplicitReturns": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"outDir": "../dist/out-tsc",
|
||||
"sourceMap": false,
|
||||
"strict": true,
|
||||
"types": [
|
||||
@ -750,7 +1230,7 @@ exports[`app not nested should generate files: e2e tsconfig.json 1`] = `
|
||||
"node",
|
||||
],
|
||||
},
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"extends": "../tsconfig.base.json",
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.js",
|
||||
@ -762,7 +1242,7 @@ exports[`app not nested should generate files: e2e tsconfig.json 1`] = `
|
||||
exports[`app not nested should generate files: tsconfig.app.json 1`] = `
|
||||
{
|
||||
"compilerOptions": {
|
||||
"outDir": "../../dist/out-tsc",
|
||||
"outDir": "../dist/out-tsc",
|
||||
"types": [],
|
||||
},
|
||||
"exclude": [
|
||||
@ -798,7 +1278,7 @@ exports[`app not nested should generate files: tsconfig.json 1`] = `
|
||||
"target": "es2022",
|
||||
"useDefineForClassFields": false,
|
||||
},
|
||||
"extends": "../../tsconfig.base.json",
|
||||
"extends": "../tsconfig.base.json",
|
||||
"files": [],
|
||||
"include": [],
|
||||
"references": [
|
||||
|
||||
@ -66,7 +66,7 @@ describe('app', () => {
|
||||
const { targets } = readProjectConfiguration(appTree, 'my-app');
|
||||
expect(targets.test).toBeFalsy();
|
||||
expect(
|
||||
appTree.exists('apps/my-app/src/app/app.component.spec.ts')
|
||||
appTree.exists('my-app/src/app/app.component.spec.ts')
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -104,33 +104,31 @@ describe('app', () => {
|
||||
it('should generate files', async () => {
|
||||
await generateApp(appTree);
|
||||
|
||||
expect(appTree.exists(`apps/my-app/jest.config.ts`)).toBeTruthy();
|
||||
expect(appTree.exists('apps/my-app/src/main.ts')).toBeTruthy();
|
||||
expect(appTree.exists('apps/my-app/src/app/app.module.ts')).toBeTruthy();
|
||||
expect(
|
||||
appTree.exists('apps/my-app/src/app/app.component.ts')
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
appTree.read('apps/my-app/src/app/app.module.ts', 'utf-8')
|
||||
).toContain('class AppModule');
|
||||
expect(appTree.exists('my-app/jest.config.ts')).toBeTruthy();
|
||||
expect(appTree.exists('my-app/src/main.ts')).toBeTruthy();
|
||||
expect(appTree.exists('my-app/src/app/app.module.ts')).toBeTruthy();
|
||||
expect(appTree.exists('my-app/src/app/app.component.ts')).toBeTruthy();
|
||||
expect(appTree.read('my-app/src/app/app.module.ts', 'utf-8')).toContain(
|
||||
'class AppModule'
|
||||
);
|
||||
|
||||
expect(readJson(appTree, 'apps/my-app/tsconfig.json')).toMatchSnapshot(
|
||||
expect(readJson(appTree, 'my-app/tsconfig.json')).toMatchSnapshot(
|
||||
'tsconfig.json'
|
||||
);
|
||||
|
||||
const tsconfigApp = parseJson(
|
||||
appTree.read('apps/my-app/tsconfig.app.json', 'utf-8')
|
||||
appTree.read('my-app/tsconfig.app.json', 'utf-8')
|
||||
);
|
||||
expect(tsconfigApp).toMatchSnapshot('tsconfig.app.json');
|
||||
|
||||
const eslintrcJson = parseJson(
|
||||
appTree.read('apps/my-app/.eslintrc.json', 'utf-8')
|
||||
appTree.read('my-app/.eslintrc.json', 'utf-8')
|
||||
);
|
||||
expect(eslintrcJson.extends).toEqual(['../../.eslintrc.json']);
|
||||
expect(eslintrcJson.extends).toEqual(['../.eslintrc.json']);
|
||||
|
||||
expect(appTree.exists('apps/my-app-e2e/cypress.config.ts')).toBeTruthy();
|
||||
expect(appTree.exists('my-app-e2e/cypress.config.ts')).toBeTruthy();
|
||||
const tsconfigE2E = parseJson(
|
||||
appTree.read('apps/my-app-e2e/tsconfig.json', 'utf-8')
|
||||
appTree.read('my-app-e2e/tsconfig.json', 'utf-8')
|
||||
);
|
||||
expect(tsconfigE2E).toMatchSnapshot('e2e tsconfig.json');
|
||||
});
|
||||
@ -141,10 +139,10 @@ describe('app', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
appTree.exists('apps/playwright-app-e2e/playwright.config.ts')
|
||||
appTree.exists('playwright-app-e2e/playwright.config.ts')
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
appTree.exists('apps/playwright-app-e2e/src/example.spec.ts')
|
||||
appTree.exists('playwright-app-e2e/src/example.spec.ts')
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'playwright-app-e2e')?.targets?.e2e
|
||||
@ -155,13 +153,13 @@ describe('app', () => {
|
||||
it('should setup jest with serializers', async () => {
|
||||
await generateApp(appTree);
|
||||
|
||||
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
|
||||
expect(appTree.read('my-app/jest.config.ts', 'utf-8')).toContain(
|
||||
`'jest-preset-angular/build/serializers/no-ng-attributes'`
|
||||
);
|
||||
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
|
||||
expect(appTree.read('my-app/jest.config.ts', 'utf-8')).toContain(
|
||||
`'jest-preset-angular/build/serializers/ng-snapshot'`
|
||||
);
|
||||
expect(appTree.read('apps/my-app/jest.config.ts', 'utf-8')).toContain(
|
||||
expect(appTree.read('my-app/jest.config.ts', 'utf-8')).toContain(
|
||||
`'jest-preset-angular/build/serializers/html-comment'`
|
||||
);
|
||||
});
|
||||
@ -174,8 +172,8 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'app');
|
||||
|
||||
// ASSERT
|
||||
const appTsConfig = readJson(appTree, 'apps/app/tsconfig.json');
|
||||
expect(appTsConfig.extends).toBe('../../tsconfig.json');
|
||||
const appTsConfig = readJson(appTree, 'app/tsconfig.json');
|
||||
expect(appTsConfig.extends).toBe('../tsconfig.json');
|
||||
});
|
||||
|
||||
it('should not overwrite default project if already set', async () => {
|
||||
@ -195,29 +193,25 @@ describe('app', () => {
|
||||
|
||||
describe('nested', () => {
|
||||
it('should create project configs', async () => {
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir' });
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'my-dir-my-app')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'my-dir-my-app-e2e')
|
||||
).toMatchSnapshot();
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
|
||||
expect(readProjectConfiguration(appTree, 'my-app')).toMatchSnapshot();
|
||||
expect(readProjectConfiguration(appTree, 'my-app-e2e')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should update tags + implicit dependencies', async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'myDir',
|
||||
tags: 'one,two,my-dir-my-app',
|
||||
directory: 'myDir/myApp',
|
||||
tags: 'one,two,my-app',
|
||||
});
|
||||
const projects = devkit.getProjects(appTree);
|
||||
expect(projects).toEqual(
|
||||
new Map(
|
||||
Object.entries({
|
||||
'my-dir-my-app': expect.objectContaining({
|
||||
tags: ['one', 'two', 'my-dir-my-app'],
|
||||
'my-app': expect.objectContaining({
|
||||
tags: ['one', 'two', 'my-app'],
|
||||
}),
|
||||
'my-dir-my-app-e2e': expect.objectContaining({
|
||||
implicitDependencies: ['my-dir-my-app'],
|
||||
'my-app-e2e': expect.objectContaining({
|
||||
implicitDependencies: ['my-app'],
|
||||
tags: [],
|
||||
}),
|
||||
})
|
||||
@ -231,18 +225,18 @@ describe('app', () => {
|
||||
|
||||
expect(lookupFn(content)).toEqual(expectedValue);
|
||||
};
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir' });
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
|
||||
|
||||
const appModulePath = 'apps/my-dir/my-app/src/app/app.module.ts';
|
||||
const appModulePath = 'my-dir/my-app/src/app/app.module.ts';
|
||||
expect(appTree.read(appModulePath, 'utf-8')).toContain('class AppModule');
|
||||
|
||||
// Make sure these exist
|
||||
[
|
||||
`apps/my-dir/my-app/jest.config.ts`,
|
||||
'apps/my-dir/my-app/src/main.ts',
|
||||
'apps/my-dir/my-app/src/app/app.module.ts',
|
||||
'apps/my-dir/my-app/src/app/app.component.ts',
|
||||
'apps/my-dir/my-app-e2e/cypress.config.ts',
|
||||
`my-dir/my-app/jest.config.ts`,
|
||||
'my-dir/my-app/src/main.ts',
|
||||
'my-dir/my-app/src/app/app.module.ts',
|
||||
'my-dir/my-app/src/app/app.component.ts',
|
||||
'my-dir/my-app-e2e/cypress.config.ts',
|
||||
].forEach((path) => {
|
||||
expect(appTree.exists(path)).toBeTruthy();
|
||||
});
|
||||
@ -250,12 +244,12 @@ describe('app', () => {
|
||||
// Make sure these have properties
|
||||
[
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tsconfig.app.json',
|
||||
path: 'my-dir/my-app/tsconfig.app.json',
|
||||
lookupFn: (json) => json.compilerOptions.outDir,
|
||||
expectedValue: '../../../dist/out-tsc',
|
||||
expectedValue: '../../dist/out-tsc',
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app/tsconfig.app.json',
|
||||
path: 'my-dir/my-app/tsconfig.app.json',
|
||||
lookupFn: (json) => json.exclude,
|
||||
expectedValue: [
|
||||
'jest.config.ts',
|
||||
@ -264,20 +258,20 @@ describe('app', () => {
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'apps/my-dir/my-app/.eslintrc.json',
|
||||
path: 'my-dir/my-app/.eslintrc.json',
|
||||
lookupFn: (json) => json.extends,
|
||||
expectedValue: ['../../../.eslintrc.json'],
|
||||
expectedValue: ['../../.eslintrc.json'],
|
||||
},
|
||||
].forEach(hasJsonValue);
|
||||
});
|
||||
|
||||
it('should extend from tsconfig.base.json', async () => {
|
||||
// ACT
|
||||
await generateApp(appTree, 'app', { directory: 'myDir' });
|
||||
await generateApp(appTree, 'app', { directory: 'myDir/app' });
|
||||
|
||||
// ASSERT
|
||||
const appTsConfig = readJson(appTree, 'apps/my-dir/app/tsconfig.json');
|
||||
expect(appTsConfig.extends).toBe('../../../tsconfig.base.json');
|
||||
const appTsConfig = readJson(appTree, 'my-dir/app/tsconfig.json');
|
||||
expect(appTsConfig.extends).toBe('../../tsconfig.base.json');
|
||||
});
|
||||
|
||||
it('should support a root tsconfig.json instead of tsconfig.base.json', async () => {
|
||||
@ -285,11 +279,11 @@ describe('app', () => {
|
||||
appTree.rename('tsconfig.base.json', 'tsconfig.json');
|
||||
|
||||
// ACT
|
||||
await generateApp(appTree, 'app', { directory: 'myDir' });
|
||||
await generateApp(appTree, 'app', { directory: 'myDir/app' });
|
||||
|
||||
// ASSERT
|
||||
const appTsConfig = readJson(appTree, 'apps/my-dir/app/tsconfig.json');
|
||||
expect(appTsConfig.extends).toBe('../../../tsconfig.json');
|
||||
const appTsConfig = readJson(appTree, 'my-dir/app/tsconfig.json');
|
||||
expect(appTsConfig.extends).toBe('../../tsconfig.json');
|
||||
});
|
||||
});
|
||||
|
||||
@ -304,12 +298,14 @@ describe('app', () => {
|
||||
|
||||
it('should accept numbers in the path', async () => {
|
||||
// ACT
|
||||
await generateApp(appTree, 'myApp', { directory: 'src/9-websites' });
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'src/9-websites/my-app',
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'src-9-websites-my-app').root
|
||||
readProjectConfiguration(appTree, 'my-app').root
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -319,7 +315,7 @@ describe('app', () => {
|
||||
|
||||
expect(lookupFn(content)).toEqual(expectedValue);
|
||||
};
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir' });
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
|
||||
|
||||
const appModulePath = 'my-dir/my-app/src/app/app.module.ts';
|
||||
expect(appTree.read(appModulePath, 'utf-8')).toContain('class AppModule');
|
||||
@ -363,99 +359,87 @@ describe('app', () => {
|
||||
describe('routing', () => {
|
||||
it('should include RouterTestingModule', async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'myDir',
|
||||
directory: 'myDir/myApp',
|
||||
routing: true,
|
||||
});
|
||||
expect(
|
||||
appTree.read('apps/my-dir/my-app/src/app/app.module.ts', 'utf-8')
|
||||
appTree.read('my-dir/my-app/src/app/app.module.ts', 'utf-8')
|
||||
).toContain('RouterModule.forRoot');
|
||||
expect(
|
||||
appTree.read(
|
||||
'apps/my-dir/my-app/src/app/app.component.spec.ts',
|
||||
'utf-8'
|
||||
)
|
||||
appTree.read('my-dir/my-app/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toContain('imports: [RouterTestingModule]');
|
||||
});
|
||||
|
||||
it('should not modify tests when --skip-tests is set', async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'myDir',
|
||||
directory: 'myDir/myApp',
|
||||
routing: true,
|
||||
skipTests: true,
|
||||
});
|
||||
expect(
|
||||
appTree.exists('apps/my-dir/my-app/src/app/app.component.spec.ts')
|
||||
appTree.exists('my-dir/my-app/src/app/app.component.spec.ts')
|
||||
).toBeFalsy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('template generation mode', () => {
|
||||
it('should create Nx specific `app.component.html` template', async () => {
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir' });
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
|
||||
expect(
|
||||
appTree.read('apps/my-dir/my-app/src/app/app.component.html', 'utf-8')
|
||||
appTree.read('my-dir/my-app/src/app/app.component.html', 'utf-8')
|
||||
).toContain('<proj-nx-welcome></proj-nx-welcome>');
|
||||
});
|
||||
|
||||
it("should update `template`'s property of AppComponent with Nx content", async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'myDir',
|
||||
directory: 'myDir/myApp',
|
||||
inlineTemplate: true,
|
||||
});
|
||||
expect(
|
||||
appTree.read('apps/my-dir/my-app/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('my-dir/my-app/src/app/app.component.ts', 'utf-8')
|
||||
).toContain('<proj-nx-welcome></proj-nx-welcome>');
|
||||
});
|
||||
|
||||
it('should create Nx specific `nx-welcome.component.ts` file', async () => {
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir' });
|
||||
await generateApp(appTree, 'myApp', { directory: 'myDir/myApp' });
|
||||
expect(
|
||||
appTree.read(
|
||||
'apps/my-dir/my-app/src/app/nx-welcome.component.ts',
|
||||
'utf-8'
|
||||
)
|
||||
appTree.read('my-dir/my-app/src/app/nx-welcome.component.ts', 'utf-8')
|
||||
).toContain('Hello there');
|
||||
});
|
||||
|
||||
it('should update the AppComponent spec to target Nx content', async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'myDir',
|
||||
directory: 'myDir/myApp',
|
||||
inlineTemplate: true,
|
||||
});
|
||||
const testFileContent = appTree.read(
|
||||
'apps/my-dir/my-app/src/app/app.component.spec.ts',
|
||||
'my-dir/my-app/src/app/app.component.spec.ts',
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
expect(testFileContent).toContain(`querySelector('h1')`);
|
||||
expect(testFileContent).toContain('Welcome my-dir-my-app');
|
||||
expect(testFileContent).toContain('Welcome my-app');
|
||||
});
|
||||
});
|
||||
|
||||
describe('--style scss', () => {
|
||||
it('should generate scss styles', async () => {
|
||||
await generateApp(appTree, 'myApp', { style: 'scss' });
|
||||
expect(appTree.exists('apps/my-app/src/app/app.component.scss')).toEqual(
|
||||
true
|
||||
);
|
||||
expect(appTree.exists('my-app/src/app/app.component.scss')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('--style sass', () => {
|
||||
it('should generate sass styles', async () => {
|
||||
await generateApp(appTree, 'myApp', { style: 'sass' });
|
||||
expect(appTree.exists('apps/my-app/src/app/app.component.sass')).toEqual(
|
||||
true
|
||||
);
|
||||
expect(appTree.exists('my-app/src/app/app.component.sass')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe('--style less', () => {
|
||||
it('should generate less styles', async () => {
|
||||
await generateApp(appTree, 'myApp', { style: 'less' });
|
||||
expect(appTree.exists('apps/my-app/src/app/app.component.less')).toEqual(
|
||||
true
|
||||
);
|
||||
expect(appTree.exists('my-app/src/app/app.component.less')).toEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -482,7 +466,7 @@ describe('app', () => {
|
||||
|
||||
describe('--linter', () => {
|
||||
describe('eslint', () => {
|
||||
it('should add lint taret', async () => {
|
||||
it('should add lint target', async () => {
|
||||
await generateApp(appTree, 'myApp', { linter: Linter.EsLint });
|
||||
expect(readProjectConfiguration(appTree, 'my-app').targets.lint)
|
||||
.toMatchInlineSnapshot(`
|
||||
@ -490,8 +474,8 @@ describe('app', () => {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-app/**/*.ts",
|
||||
"apps/my-app/**/*.html",
|
||||
"my-app/**/*.ts",
|
||||
"my-app/**/*.html",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
@ -505,7 +489,7 @@ describe('app', () => {
|
||||
"executor": "@nx/linter:eslint",
|
||||
"options": {
|
||||
"lintFilePatterns": [
|
||||
"apps/my-app-e2e/**/*.{js,ts}",
|
||||
"my-app-e2e/**/*.{js,ts}",
|
||||
],
|
||||
},
|
||||
"outputs": [
|
||||
@ -518,11 +502,11 @@ describe('app', () => {
|
||||
it('should add valid eslint JSON configuration which extends from Nx presets', async () => {
|
||||
await generateApp(appTree, 'myApp', { linter: Linter.EsLint });
|
||||
|
||||
const eslintConfig = readJson(appTree, 'apps/my-app/.eslintrc.json');
|
||||
const eslintConfig = readJson(appTree, 'my-app/.eslintrc.json');
|
||||
expect(eslintConfig).toMatchInlineSnapshot(`
|
||||
{
|
||||
"extends": [
|
||||
"../../.eslintrc.json",
|
||||
"../.eslintrc.json",
|
||||
],
|
||||
"ignorePatterns": [
|
||||
"!**/*",
|
||||
@ -585,7 +569,7 @@ describe('app', () => {
|
||||
it('should generate jest.config.ts with serializers', async () => {
|
||||
await generateApp(appTree);
|
||||
|
||||
const jestConfig = appTree.read('apps/my-app/jest.config.ts', 'utf-8');
|
||||
const jestConfig = appTree.read('my-app/jest.config.ts', 'utf-8');
|
||||
|
||||
expect(jestConfig).toContain(
|
||||
`'jest-preset-angular/build/serializers/no-ng-attributes'`
|
||||
@ -601,7 +585,7 @@ describe('app', () => {
|
||||
it('should add reference to tsconfig.spec.json to tsconfig.json', async () => {
|
||||
await generateApp(appTree);
|
||||
|
||||
const { references } = readJson(appTree, 'apps/my-app/tsconfig.json');
|
||||
const { references } = readJson(appTree, 'my-app/tsconfig.json');
|
||||
expect(
|
||||
references.find((r) => r.path.includes('tsconfig.spec.json'))
|
||||
).toBeTruthy();
|
||||
@ -613,19 +597,19 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
unitTestRunner: UnitTestRunner.None,
|
||||
});
|
||||
expect(appTree.exists('apps/my-app/src/test-setup.ts')).toBeFalsy();
|
||||
expect(appTree.exists('apps/my-app/src/test.ts')).toBeFalsy();
|
||||
expect(appTree.exists('apps/my-app/tsconfig.spec.json')).toBeFalsy();
|
||||
expect(appTree.exists('apps/my-app/jest.config.ts')).toBeFalsy();
|
||||
expect(appTree.exists('apps/my-app/karma.config.js')).toBeFalsy();
|
||||
expect(appTree.exists('my-app/src/test-setup.ts')).toBeFalsy();
|
||||
expect(appTree.exists('my-app/src/test.ts')).toBeFalsy();
|
||||
expect(appTree.exists('my-app/tsconfig.spec.json')).toBeFalsy();
|
||||
expect(appTree.exists('my-app/jest.config.ts')).toBeFalsy();
|
||||
expect(appTree.exists('my-app/karma.config.js')).toBeFalsy();
|
||||
expect(
|
||||
appTree.exists('apps/my-app/src/app/app.component.spec.ts')
|
||||
appTree.exists('my-app/src/app/app.component.spec.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'my-app').targets.test
|
||||
).toBeUndefined();
|
||||
// check tsconfig.spec.json is not referenced
|
||||
const { references } = readJson(appTree, 'apps/my-app/tsconfig.json');
|
||||
const { references } = readJson(appTree, 'my-app/tsconfig.json');
|
||||
expect(
|
||||
references.every((r) => !r.path.includes('tsconfig.spec.json'))
|
||||
).toBe(true);
|
||||
@ -639,7 +623,7 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
e2eTestRunner: E2eTestRunner.None,
|
||||
});
|
||||
expect(appTree.exists('apps/my-app-e2e')).toBeFalsy();
|
||||
expect(appTree.exists('my-app-e2e')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -662,10 +646,10 @@ describe('app', () => {
|
||||
2
|
||||
);
|
||||
|
||||
expect(appTree.exists('apps/customer-ui/proxy.conf.json')).toBeTruthy();
|
||||
expect(
|
||||
appTree.read('apps/customer-ui/proxy.conf.json', 'utf-8')
|
||||
).toContain(proxyConfContent);
|
||||
expect(appTree.exists('customer-ui/proxy.conf.json')).toBeTruthy();
|
||||
expect(appTree.read('customer-ui/proxy.conf.json', 'utf-8')).toContain(
|
||||
proxyConfContent
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@ -673,7 +657,7 @@ describe('app', () => {
|
||||
it('should not generate a proxy.conf.json', async () => {
|
||||
await generateApp(appTree, 'customer-ui');
|
||||
|
||||
expect(appTree.exists('apps/customer-ui/proxy.conf.json')).toBeFalsy();
|
||||
expect(appTree.exists('customer-ui/proxy.conf.json')).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -682,9 +666,9 @@ describe('app', () => {
|
||||
it('should enable strict type checking', async () => {
|
||||
await generateApp(appTree, 'my-app', { strict: true });
|
||||
|
||||
const appTsConfig = readJson(appTree, 'apps/my-app/tsconfig.json');
|
||||
const appTsConfig = readJson(appTree, 'my-app/tsconfig.json');
|
||||
expect(appTsConfig).toMatchSnapshot('app tsconfig.json');
|
||||
const e2eTsConfig = readJson(appTree, 'apps/my-app-e2e/tsconfig.json');
|
||||
const e2eTsConfig = readJson(appTree, 'my-app-e2e/tsconfig.json');
|
||||
expect(e2eTsConfig).toMatchSnapshot('e2e tsconfig.json');
|
||||
|
||||
// should not update workspace configuration since --strict=true is the default
|
||||
@ -710,7 +694,7 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'app1');
|
||||
|
||||
// ASSERT
|
||||
expect(appTree.exists('apps/app1/tailwind.config.js')).toBeFalsy();
|
||||
expect(appTree.exists('app1/tailwind.config.js')).toBeFalsy();
|
||||
const { devDependencies } = readJson(appTree, 'package.json');
|
||||
expect(devDependencies['tailwindcss']).toBeUndefined();
|
||||
expect(devDependencies['postcss']).toBeUndefined();
|
||||
@ -722,7 +706,7 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'app1', { addTailwind: false });
|
||||
|
||||
// ASSERT
|
||||
expect(appTree.exists('apps/app1/tailwind.config.js')).toBeFalsy();
|
||||
expect(appTree.exists('app1/tailwind.config.js')).toBeFalsy();
|
||||
const { devDependencies } = readJson(appTree, 'package.json');
|
||||
expect(devDependencies['tailwindcss']).toBeUndefined();
|
||||
expect(devDependencies['postcss']).toBeUndefined();
|
||||
@ -734,7 +718,7 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'app1', { addTailwind: true });
|
||||
|
||||
// ASSERT
|
||||
expect(appTree.read('apps/app1/tailwind.config.js', 'utf-8'))
|
||||
expect(appTree.read('app1/tailwind.config.js', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"const { createGlobPatternsForDependencies } = require('@nx/angular/tailwind');
|
||||
const { join } = require('path');
|
||||
@ -768,26 +752,22 @@ describe('app', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(appTree.read('standalone/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/main.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.config.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.config.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.routes.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.routes.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(appTree.exists('standalone/src/app/app.module.ts')).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.exists('apps/standalone/src/app/app.module.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/nx-welcome.component.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/nx-welcome.component.ts', 'utf-8')
|
||||
).toContain('standalone: true');
|
||||
});
|
||||
|
||||
@ -799,23 +779,19 @@ describe('app', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(appTree.read('standalone/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/main.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.config.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.config.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(appTree.exists('standalone/src/app/app.module.ts')).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.exists('apps/standalone/src/app/app.module.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/standalone/src/app/nx-welcome.component.ts', 'utf-8')
|
||||
appTree.read('standalone/src/app/nx-welcome.component.ts', 'utf-8')
|
||||
).toContain('standalone: true');
|
||||
});
|
||||
|
||||
@ -831,9 +807,7 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'nostandalone');
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
appTree.exists('apps/nostandalone/src/app/app.module.ts')
|
||||
).toBeTruthy();
|
||||
expect(appTree.exists('nostandalone/src/app/app.module.ts')).toBeTruthy();
|
||||
expect(enquirer.prompt).toHaveBeenCalled();
|
||||
|
||||
// CLEANUP
|
||||
@ -853,7 +827,7 @@ describe('app', () => {
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
appTree.exists('apps/nostandalone/src/app/app.module.ts')
|
||||
appTree.exists('nostandalone/src/app/app.module.ts')
|
||||
).not.toBeTruthy();
|
||||
expect(enquirer.prompt).toHaveBeenCalled();
|
||||
|
||||
@ -867,8 +841,7 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'myapp');
|
||||
|
||||
// ASSERT
|
||||
expect(appTree.read('apps/myapp/src/main.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
expect(appTree.read('myapp/src/main.ts', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
@ -932,19 +905,19 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'plain', { minimal: true });
|
||||
|
||||
expect(
|
||||
appTree.exists('apps/plain/src/app/nx-welcome.component.ts')
|
||||
appTree.exists('plain/src/app/nx-welcome.component.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.module.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.html', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.html', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -952,19 +925,19 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'plain', { minimal: true, routing: true });
|
||||
|
||||
expect(
|
||||
appTree.exists('apps/plain/src/app/nx-welcome.component.ts')
|
||||
appTree.exists('plain/src/app/nx-welcome.component.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.module.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.html', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.html', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -972,16 +945,16 @@ describe('app', () => {
|
||||
await generateApp(appTree, 'plain', { minimal: true, standalone: true });
|
||||
|
||||
expect(
|
||||
appTree.exists('apps/plain/src/app/nx-welcome.component.ts')
|
||||
appTree.exists('plain/src/app/nx-welcome.component.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.html', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.html', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -993,16 +966,16 @@ describe('app', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
appTree.exists('apps/plain/src/app/nx-welcome.component.ts')
|
||||
appTree.exists('plain/src/app/nx-welcome.component.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.spec.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
appTree.read('apps/plain/src/app/app.component.html', 'utf-8')
|
||||
appTree.read('plain/src/app/app.component.html', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -1027,6 +1000,85 @@ describe('app', () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('--project-name-and-root-format=derived', () => {
|
||||
it('should generate correctly when no directory is provided', async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
expect(readProjectConfiguration(appTree, 'my-app')).toMatchSnapshot();
|
||||
expect(readProjectConfiguration(appTree, 'my-app-e2e')).toMatchSnapshot();
|
||||
expect(appTree.exists('apps/my-app/jest.config.ts')).toBeTruthy();
|
||||
expect(appTree.exists('apps/my-app/src/main.ts')).toBeTruthy();
|
||||
expect(appTree.exists('apps/my-app/src/app/app.module.ts')).toBeTruthy();
|
||||
expect(
|
||||
appTree.exists('apps/my-app/src/app/app.component.ts')
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
appTree.read('apps/my-app/src/app/app.module.ts', 'utf-8')
|
||||
).toContain('class AppModule');
|
||||
expect(readJson(appTree, 'apps/my-app/tsconfig.json')).toMatchSnapshot(
|
||||
'tsconfig.json'
|
||||
);
|
||||
const tsconfigApp = parseJson(
|
||||
appTree.read('apps/my-app/tsconfig.app.json', 'utf-8')
|
||||
);
|
||||
expect(tsconfigApp).toMatchSnapshot('tsconfig.app.json');
|
||||
const eslintrcJson = parseJson(
|
||||
appTree.read('apps/my-app/.eslintrc.json', 'utf-8')
|
||||
);
|
||||
expect(eslintrcJson.extends).toEqual(['../../.eslintrc.json']);
|
||||
expect(appTree.exists('apps/my-app-e2e/cypress.config.ts')).toBeTruthy();
|
||||
const tsconfigE2E = parseJson(
|
||||
appTree.read('apps/my-app-e2e/tsconfig.json', 'utf-8')
|
||||
);
|
||||
expect(tsconfigE2E).toMatchSnapshot('e2e tsconfig.json');
|
||||
});
|
||||
|
||||
it('should generate correctly when directory is provided', async () => {
|
||||
await generateApp(appTree, 'myApp', {
|
||||
directory: 'myDir',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'my-dir-my-app')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
readProjectConfiguration(appTree, 'my-dir-my-app-e2e')
|
||||
).toMatchSnapshot();
|
||||
expect(appTree.exists('apps/my-dir/my-app/jest.config.ts')).toBeTruthy();
|
||||
expect(appTree.exists('apps/my-dir/my-app/src/main.ts')).toBeTruthy();
|
||||
expect(
|
||||
appTree.exists('apps/my-dir/my-app/src/app/app.module.ts')
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
appTree.exists('apps/my-dir/my-app/src/app/app.component.ts')
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
appTree.read('apps/my-dir/my-app/src/app/app.module.ts', 'utf-8')
|
||||
).toContain('class AppModule');
|
||||
expect(
|
||||
readJson(appTree, 'apps/my-dir/my-app/tsconfig.json')
|
||||
).toMatchSnapshot('tsconfig.json');
|
||||
const tsconfigApp = parseJson(
|
||||
appTree.read('apps/my-dir/my-app/tsconfig.app.json', 'utf-8')
|
||||
);
|
||||
expect(tsconfigApp).toMatchSnapshot('tsconfig.app.json');
|
||||
const eslintrcJson = parseJson(
|
||||
appTree.read('apps/my-dir/my-app/.eslintrc.json', 'utf-8')
|
||||
);
|
||||
expect(eslintrcJson.extends).toEqual(['../../../.eslintrc.json']);
|
||||
expect(
|
||||
appTree.exists('apps/my-dir/my-app-e2e/cypress.config.ts')
|
||||
).toBeTruthy();
|
||||
const tsconfigE2E = parseJson(
|
||||
appTree.read('apps/my-dir/my-app-e2e/tsconfig.json', 'utf-8')
|
||||
);
|
||||
expect(tsconfigE2E).toMatchSnapshot('e2e tsconfig.json');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function generateApp(
|
||||
|
||||
@ -14,7 +14,7 @@ jest.mock('@nx/cypress/src/utils/cypress-version');
|
||||
describe('componentCypressSpec generator', () => {
|
||||
let tree: Tree;
|
||||
const appName = 'ng-app1';
|
||||
const specFile = `apps/${appName}-e2e/src/e2e/test-button/test-button.component.cy.ts`;
|
||||
const specFile = `${appName}-e2e/src/e2e/test-button/test-button.component.cy.ts`;
|
||||
let mockedInstalledCypressVersion: jest.Mock<
|
||||
ReturnType<typeof installedCypressVersion>
|
||||
> = installedCypressVersion as never;
|
||||
@ -28,7 +28,7 @@ describe('componentCypressSpec generator', () => {
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`apps/${appName}/src/app/test-button/test-button.component.ts`,
|
||||
`${appName}/src/app/test-button/test-button.component.ts`,
|
||||
`import { Component, Input } from '@angular/core';
|
||||
|
||||
export type ButtonStyle = 'default' | 'primary' | 'accent';
|
||||
@ -57,7 +57,7 @@ export class TestButtonComponent {
|
||||
componentFileName: 'test-button.component',
|
||||
componentName: 'TestButtonComponent',
|
||||
componentPath: `test-button`,
|
||||
projectPath: `apps/${appName}/src/app`,
|
||||
projectPath: `${appName}/src/app`,
|
||||
projectName: appName,
|
||||
});
|
||||
|
||||
@ -72,7 +72,7 @@ export class TestButtonComponent {
|
||||
componentFileName: 'test-button.component',
|
||||
componentName: 'TestButtonComponent',
|
||||
componentPath: `test-button`,
|
||||
projectPath: `apps/${appName}/src/app`,
|
||||
projectPath: `${appName}/src/app`,
|
||||
projectName: appName,
|
||||
});
|
||||
|
||||
@ -83,15 +83,15 @@ export class TestButtonComponent {
|
||||
|
||||
it('should generate .spec.ts when using cypress.json', async () => {
|
||||
mockedInstalledCypressVersion.mockReturnValue(9);
|
||||
const v9SpecFile = `apps/${appName}-e2e/src/integration/test-button/test-button.component.spec.ts`;
|
||||
tree.delete(`apps/${appName}-e2e/cypress.config.ts`);
|
||||
tree.write(`apps/${appName}-e2e/cypress.json`, `{}`);
|
||||
const v9SpecFile = `${appName}-e2e/src/integration/test-button/test-button.component.spec.ts`;
|
||||
tree.delete(`${appName}-e2e/cypress.config.ts`);
|
||||
tree.write(`${appName}-e2e/cypress.json`, `{}`);
|
||||
|
||||
await componentCypressSpecGenerator(tree, {
|
||||
componentFileName: 'test-button.component',
|
||||
componentName: 'TestButtonComponent',
|
||||
componentPath: `test-button`,
|
||||
projectPath: `apps/${appName}/src/app`,
|
||||
projectPath: `${appName}/src/app`,
|
||||
projectName: appName,
|
||||
});
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ import { componentStoryGenerator } from './component-story';
|
||||
describe('componentStory generator', () => {
|
||||
let tree: Tree;
|
||||
const libName = 'ng-lib1';
|
||||
const storyFile = `libs/${libName}/src/lib/test-button/test-button.component.stories.ts`;
|
||||
const storyFile = `${libName}/src/lib/test-button/test-button.component.stories.ts`;
|
||||
|
||||
beforeEach(async () => {
|
||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
@ -21,7 +21,7 @@ describe('componentStory generator', () => {
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.ts`,
|
||||
`${libName}/src/lib/test-button/test-button.component.ts`,
|
||||
`import { Component, Input } from '@angular/core';
|
||||
|
||||
export type ButtonStyle = 'default' | 'primary' | 'accent';
|
||||
@ -52,7 +52,7 @@ describe('componentStory generator', () => {
|
||||
componentFileName: 'test-button.component',
|
||||
componentName: 'TestButtonComponent',
|
||||
componentPath: `src/lib/test-button`,
|
||||
projectPath: `libs/${libName}`,
|
||||
projectPath: `${libName}`,
|
||||
});
|
||||
|
||||
expect(storybookUtils.getComponentProps).not.toHaveBeenCalled();
|
||||
@ -65,7 +65,7 @@ describe('componentStory generator', () => {
|
||||
componentFileName: 'test-button.component',
|
||||
componentName: 'TestButtonComponent',
|
||||
componentPath: `src/lib/test-button`,
|
||||
projectPath: `libs/${libName}`,
|
||||
projectPath: `${libName}`,
|
||||
});
|
||||
|
||||
expect(tree.exists(storyFile)).toBe(true);
|
||||
@ -76,7 +76,7 @@ describe('componentStory generator', () => {
|
||||
componentFileName: 'test-button.component',
|
||||
componentName: 'TestButtonComponent',
|
||||
componentPath: `src/lib/test-button`,
|
||||
projectPath: `libs/${libName}`,
|
||||
projectPath: `${libName}`,
|
||||
});
|
||||
|
||||
expect(tree.read(storyFile).toString()).toMatchSnapshot();
|
||||
|
||||
@ -38,7 +38,7 @@ describe('Angular Cypress Component Test Generator', () => {
|
||||
componentDir: 'src/lib/my-lib',
|
||||
});
|
||||
expect(
|
||||
tree.read('libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
tree.read('my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -54,7 +54,7 @@ describe('Angular Cypress Component Test Generator', () => {
|
||||
});
|
||||
|
||||
tree.write(
|
||||
'libs/my-lib/src/lib/my-lib/my-lib.component.ts',
|
||||
'my-lib/src/lib/my-lib/my-lib.component.ts',
|
||||
`
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
|
||||
@ -90,7 +90,7 @@ export class MyLibComponent implements OnInit {
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
tree.read('my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -106,7 +106,7 @@ export class MyLibComponent implements OnInit {
|
||||
standalone: true,
|
||||
});
|
||||
tree.write(
|
||||
'libs/my-lib/src/lib/my-lib/my-lib.component.ts',
|
||||
'my-lib/src/lib/my-lib/my-lib.component.ts',
|
||||
`
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@ -141,7 +141,7 @@ export class MyLibComponent implements OnInit {
|
||||
componentDir: 'src/lib/my-lib',
|
||||
});
|
||||
expect(
|
||||
tree.read('libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
tree.read('my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -154,7 +154,7 @@ export class MyLibComponent implements OnInit {
|
||||
|
||||
await componentGenerator(tree, { name: 'my-lib', project: 'my-lib' });
|
||||
tree.write(
|
||||
'libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts',
|
||||
'my-lib/src/lib/my-lib/my-lib.component.cy.ts',
|
||||
`should not overwrite`
|
||||
);
|
||||
|
||||
@ -166,7 +166,7 @@ export class MyLibComponent implements OnInit {
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
tree.read('my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
).toEqual('should not overwrite');
|
||||
});
|
||||
|
||||
@ -207,7 +207,7 @@ describe(MyLibComponent.name, () => {
|
||||
componentDir: 'src/lib/my-lib',
|
||||
});
|
||||
expect(
|
||||
tree.read('libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
tree.read('my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
).toEqual(expected);
|
||||
|
||||
componentTestGenerator(tree, {
|
||||
@ -217,7 +217,7 @@ describe(MyLibComponent.name, () => {
|
||||
componentDir: 'src/lib/my-lib',
|
||||
});
|
||||
expect(
|
||||
tree.read('libs/my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
tree.read('my-lib/src/lib/my-lib/my-lib.component.cy.ts', 'utf-8')
|
||||
).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
@ -89,16 +89,14 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
generateTests: false,
|
||||
});
|
||||
expect(
|
||||
tree.exists(
|
||||
'libs/fancy-lib/src/lib/fancy-cmp/fancy-cmp.component.cy.ts'
|
||||
)
|
||||
tree.exists('fancy-lib/src/lib/fancy-cmp/fancy-cmp.component.cy.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
readProjectConfiguration(tree, 'fancy-lib').targets['component-test']
|
||||
).toEqual({
|
||||
executor: '@nx/cypress:cypress',
|
||||
options: {
|
||||
cypressConfig: 'libs/fancy-lib/cypress.config.ts',
|
||||
cypressConfig: 'fancy-lib/cypress.config.ts',
|
||||
devServerTarget: 'fancy-app:build',
|
||||
skipServe: true,
|
||||
testingType: 'component',
|
||||
@ -151,16 +149,14 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
generateTests: false,
|
||||
});
|
||||
expect(
|
||||
tree.exists(
|
||||
'libs/fancy-lib/src/lib/fancy-cmp/fancy-cmp.component.cy.ts'
|
||||
)
|
||||
tree.exists('fancy-lib/src/lib/fancy-cmp/fancy-cmp.component.cy.ts')
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
readProjectConfiguration(tree, 'fancy-lib').targets['component-test']
|
||||
).toEqual({
|
||||
executor: '@nx/cypress:cypress',
|
||||
options: {
|
||||
cypressConfig: 'libs/fancy-lib/cypress.config.ts',
|
||||
cypressConfig: 'fancy-lib/cypress.config.ts',
|
||||
devServerTarget: 'fancy-app:build:development',
|
||||
skipServe: true,
|
||||
testingType: 'component',
|
||||
@ -252,7 +248,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
).toEqual({
|
||||
executor: '@nx/cypress:cypress',
|
||||
options: {
|
||||
cypressConfig: 'apps/fancy-app/cypress.config.ts',
|
||||
cypressConfig: 'fancy-app/cypress.config.ts',
|
||||
devServerTarget: 'fancy-app:build',
|
||||
skipServe: true,
|
||||
testingType: 'component',
|
||||
@ -273,7 +269,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
export: true,
|
||||
});
|
||||
tree.write(
|
||||
'apps/fancy-app/src/app/blah.component.ts',
|
||||
'fancy-app/src/app/blah.component.ts',
|
||||
`import {FancyCmpComponent} from '@something/fancy-lib'`
|
||||
);
|
||||
projectGraph = {
|
||||
@ -312,7 +308,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
).toEqual({
|
||||
executor: '@nx/cypress:cypress',
|
||||
options: {
|
||||
cypressConfig: 'libs/fancy-lib/cypress.config.ts',
|
||||
cypressConfig: 'fancy-lib/cypress.config.ts',
|
||||
devServerTarget: 'fancy-app:build',
|
||||
skipServe: true,
|
||||
testingType: 'component',
|
||||
@ -363,7 +359,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
generateTests: true,
|
||||
});
|
||||
|
||||
expect(tree.read('libs/my-lib/cypress.config.ts', 'utf-8'))
|
||||
expect(tree.read('my-lib/cypress.config.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';
|
||||
import { defineConfig } from 'cypress';
|
||||
@ -374,7 +370,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
"
|
||||
`);
|
||||
expect(
|
||||
tree.read('libs/my-lib/cypress/support/component.ts', 'utf-8')
|
||||
tree.read('my-lib/cypress/support/component.ts', 'utf-8')
|
||||
).toMatchSnapshot('component.ts');
|
||||
});
|
||||
it('should work with simple components', async () => {
|
||||
@ -421,7 +417,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
|
||||
const [one, two, three] = getCmpsFromTree(tree, {
|
||||
basePath: 'libs/my-lib/src/lib',
|
||||
basePath: 'my-lib/src/lib',
|
||||
name: 'something',
|
||||
});
|
||||
expect(one.cy).toMatchSnapshot();
|
||||
@ -473,7 +469,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
|
||||
const [one, two, three] = getCmpsFromTree(tree, {
|
||||
basePath: 'libs/my-lib-standalone/src/lib',
|
||||
basePath: 'my-lib-standalone/src/lib',
|
||||
name: 'something',
|
||||
});
|
||||
expect(one.cy).toMatchSnapshot();
|
||||
@ -491,7 +487,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
name: 'something',
|
||||
standalone: false,
|
||||
withInputs: true,
|
||||
basePath: 'libs/with-inputs-cmp/src/lib',
|
||||
basePath: 'with-inputs-cmp/src/lib',
|
||||
});
|
||||
projectGraph = {
|
||||
nodes: {
|
||||
@ -527,7 +523,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
|
||||
const [one, two, three] = getCmpsFromTree(tree, {
|
||||
basePath: 'libs/with-inputs-cmp/src/lib',
|
||||
basePath: 'with-inputs-cmp/src/lib',
|
||||
name: 'something',
|
||||
});
|
||||
expect(one.cy).toMatchSnapshot();
|
||||
@ -545,7 +541,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
name: 'something',
|
||||
standalone: true,
|
||||
withInputs: true,
|
||||
basePath: 'libs/with-inputs-standalone-cmp/src/lib',
|
||||
basePath: 'with-inputs-standalone-cmp/src/lib',
|
||||
});
|
||||
projectGraph = {
|
||||
nodes: {
|
||||
@ -581,7 +577,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
|
||||
const [one, two, three] = getCmpsFromTree(tree, {
|
||||
basePath: 'libs/with-inputs-standalone-cmp/src/lib',
|
||||
basePath: 'with-inputs-standalone-cmp/src/lib',
|
||||
name: 'something',
|
||||
});
|
||||
expect(one.cy).toMatchSnapshot();
|
||||
@ -603,13 +599,13 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
await componentGenerator(tree, {
|
||||
name: 'fancy-button',
|
||||
path: 'libs/secondary/src/lib/button',
|
||||
path: 'secondary/src/lib/button',
|
||||
project: 'secondary',
|
||||
flat: true,
|
||||
});
|
||||
await componentGenerator(tree, {
|
||||
name: 'standalone-fancy-button',
|
||||
path: 'libs/secondary/src/lib/button',
|
||||
path: 'secondary/src/lib/button',
|
||||
project: 'secondary',
|
||||
standalone: true,
|
||||
flat: true,
|
||||
@ -641,13 +637,13 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
expect(
|
||||
tree.read(
|
||||
'libs/secondary/src/lib/button/fancy-button.component.cy.ts',
|
||||
'secondary/src/lib/button/fancy-button.component.cy.ts',
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(
|
||||
'libs/secondary/src/lib/button/standalone-fancy-button.component.cy.ts',
|
||||
'secondary/src/lib/button/standalone-fancy-button.component.cy.ts',
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
@ -660,15 +656,15 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
});
|
||||
await setup(tree, { project: 'cool-lib', name: 'abc', standalone: false });
|
||||
tree.write(
|
||||
'libs/cool-lib/src/lib/abc-one/abc-one.component.cy.ts',
|
||||
'cool-lib/src/lib/abc-one/abc-one.component.cy.ts',
|
||||
`const msg = 'should not overwrite abc-one';`
|
||||
);
|
||||
tree.write(
|
||||
'libs/cool-lib/src/lib/abc-two/abc-two.component.cy.ts',
|
||||
'cool-lib/src/lib/abc-two/abc-two.component.cy.ts',
|
||||
`const msg = 'should not overwrite abc-two';`
|
||||
);
|
||||
tree.write(
|
||||
'libs/cool-lib/src/lib/abc-three/abc-three.component.cy.ts',
|
||||
'cool-lib/src/lib/abc-three/abc-three.component.cy.ts',
|
||||
`const msg = 'should not overwrite abc-three';`
|
||||
);
|
||||
projectGraph = {
|
||||
@ -698,7 +694,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
|
||||
const [one, two, three] = getCmpsFromTree(tree, {
|
||||
name: 'abc',
|
||||
basePath: 'libs/cool-lib/src/lib',
|
||||
basePath: 'cool-lib/src/lib',
|
||||
});
|
||||
|
||||
expect(one.cy).toMatchInlineSnapshot(`
|
||||
@ -733,7 +729,7 @@ describe('Cypress Component Testing Configuration', () => {
|
||||
flat: true,
|
||||
});
|
||||
tree.write(
|
||||
`libs/multiple-components/src/lib/cmp-one.component.ts`,
|
||||
`multiple-components/src/lib/cmp-one.component.ts`,
|
||||
`
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
|
||||
@ -790,10 +786,7 @@ export class MultipleComponentsModule { }
|
||||
generateTests: true,
|
||||
});
|
||||
expect(
|
||||
tree.read(
|
||||
'libs/multiple-components/src/lib/cmp-one.component.cy.ts',
|
||||
'utf-8'
|
||||
)
|
||||
tree.read('multiple-components/src/lib/cmp-one.component.cy.ts', 'utf-8')
|
||||
).toEqual('');
|
||||
});
|
||||
});
|
||||
|
||||
@ -160,11 +160,11 @@ exports[`Host App Generator --ssr should generate the correct files 9`] = `
|
||||
"executor": "@nx/angular:webpack-server",
|
||||
"options": {
|
||||
"customWebpackConfig": {
|
||||
"path": "apps/test/webpack.server.config.js",
|
||||
"path": "test/webpack.server.config.js",
|
||||
},
|
||||
"main": "apps/test/server.ts",
|
||||
"outputPath": "dist/apps/test/server",
|
||||
"tsConfig": "apps/test/tsconfig.server.json",
|
||||
"main": "test/server.ts",
|
||||
"outputPath": "dist/test/server",
|
||||
"tsConfig": "test/tsconfig.server.json",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -359,11 +359,11 @@ exports[`Host App Generator --ssr should generate the correct files for standalo
|
||||
"executor": "@nx/angular:webpack-server",
|
||||
"options": {
|
||||
"customWebpackConfig": {
|
||||
"path": "apps/test/webpack.server.config.js",
|
||||
"path": "test/webpack.server.config.js",
|
||||
},
|
||||
"main": "apps/test/server.ts",
|
||||
"outputPath": "dist/apps/test/server",
|
||||
"tsConfig": "apps/test/tsconfig.server.json",
|
||||
"main": "test/server.ts",
|
||||
"outputPath": "dist/test/server",
|
||||
"tsConfig": "test/tsconfig.server.json",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -509,10 +509,10 @@ describe('AppComponent', () => {
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(\`should have as title 'test-dashboard'\`, () => {
|
||||
it(\`should have as title 'dashboard'\`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('test-dashboard');
|
||||
expect(app.title).toEqual('dashboard');
|
||||
});
|
||||
|
||||
it('should render title', fakeAsync(() => {
|
||||
@ -523,7 +523,7 @@ describe('AppComponent', () => {
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain(
|
||||
'Welcome test-dashboard'
|
||||
'Welcome dashboard'
|
||||
);
|
||||
}));
|
||||
});
|
||||
|
||||
@ -21,7 +21,7 @@ describe('Host App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a host app with a remote', async () => {
|
||||
@ -39,10 +39,8 @@ describe('Host App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
tree.read('apps/remote/webpack.config.js', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('remote/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a host and any remotes that dont exist with correct routing setup', async () => {
|
||||
@ -57,12 +55,12 @@ describe('Host App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists('apps/remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('remote2/project.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.read('apps/host-app/module-federation.config.js', 'utf-8')
|
||||
tree.read('host-app/module-federation.config.js', 'utf-8')
|
||||
).toContain(`'remote1', 'remote2'`);
|
||||
expect(tree.read('apps/host-app/src/app/app.component.html', 'utf-8'))
|
||||
expect(tree.read('host-app/src/app/app.component.html', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"<ul class="remote-menu">
|
||||
<li><a routerLink="/">Home</a></li>
|
||||
@ -88,11 +86,11 @@ describe('Host App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists('apps/remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/remote3/project.json')).toBeTruthy();
|
||||
expect(tree.exists('remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('remote3/project.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.read('apps/host-app/module-federation.config.js', 'utf-8')
|
||||
tree.read('host-app/module-federation.config.js', 'utf-8')
|
||||
).toContain(`'remote1', 'remote2', 'remote3'`);
|
||||
});
|
||||
|
||||
@ -106,17 +104,17 @@ describe('Host App Generator', () => {
|
||||
// ACT
|
||||
await generateTestHostApplication(tree, {
|
||||
name: 'hostApp',
|
||||
directory: 'foo',
|
||||
directory: 'foo/hostApp',
|
||||
remotes: ['remote1', 'remote2', 'remote3'],
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists('apps/remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/foo/remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/foo/remote3/project.json')).toBeTruthy();
|
||||
expect(tree.exists('remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('foo/remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('foo/remote3/project.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.read('apps/foo/host-app/module-federation.config.js', 'utf-8')
|
||||
).toContain(`'remote1', 'foo-remote2', 'foo-remote3'`);
|
||||
tree.read('foo/host-app/module-federation.config.js', 'utf-8')
|
||||
).toContain(`'remote1', 'remote2', 'remote3'`);
|
||||
});
|
||||
|
||||
it('should generate a host with remotes using standalone components', async () => {
|
||||
@ -131,11 +129,11 @@ describe('Host App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists(`apps/host/src/app/app.module.ts`)).toBeFalsy();
|
||||
expect(tree.read(`apps/host/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read(`apps/host/src/remotes.d.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.exists(`host/src/app/app.module.ts`)).toBeFalsy();
|
||||
expect(tree.read(`host/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read(`host/src/remotes.d.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/host/src/app/app.component.ts`, 'utf-8')
|
||||
tree.read(`host/src/app/app.component.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -152,7 +150,7 @@ describe('Host App Generator', () => {
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
tree.read(`apps/host/src/app/app.component.spec.ts`, 'utf-8')
|
||||
tree.read(`host/src/app/app.component.spec.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -164,13 +162,13 @@ describe('Host App Generator', () => {
|
||||
await generateTestHostApplication(tree, {
|
||||
name: 'dashboard',
|
||||
remotes: ['remote1'],
|
||||
directory: 'test',
|
||||
directory: 'test/dashboard',
|
||||
standalone: true,
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
tree.read(`apps/test/dashboard/src/app/app.component.spec.ts`, 'utf-8')
|
||||
tree.read(`test/dashboard/src/app/app.component.spec.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -205,26 +203,22 @@ describe('Host App Generator', () => {
|
||||
// ASSERT
|
||||
const project = readProjectConfiguration(tree, 'test');
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.module.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/app.module.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`test/src/bootstrap.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/main.server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read(`test/server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`test/module-federation.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/bootstrap.ts`, 'utf-8')
|
||||
tree.read(`test/webpack.server.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/bootstrap.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/main.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`apps/test/server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/module-federation.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/webpack.server.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.routes.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/app.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(project.targets.server).toMatchSnapshot();
|
||||
expect(project.targets['serve-ssr']).toMatchSnapshot();
|
||||
@ -243,31 +237,27 @@ describe('Host App Generator', () => {
|
||||
|
||||
// ASSERT
|
||||
const project = readProjectConfiguration(tree, 'test');
|
||||
expect(tree.exists(`apps/test/src/app/app.module.ts`)).toBeFalsy();
|
||||
expect(tree.exists(`test/src/app/app.module.ts`)).toBeFalsy();
|
||||
expect(tree.read(`test/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/bootstrap.ts`, 'utf-8')
|
||||
tree.read(`test/src/bootstrap.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/main.server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read(`test/server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`test/module-federation.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/bootstrap.server.ts`, 'utf-8')
|
||||
tree.read(`test/webpack.server.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/main.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`apps/test/server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/module-federation.config.js`, 'utf-8')
|
||||
tree.read(`test/src/app/app.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/webpack.server.config.js`, 'utf-8')
|
||||
tree.read(`test/src/app/app.config.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.config.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.config.server.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/app.config.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(project.targets.server).toMatchSnapshot();
|
||||
expect(project.targets['serve-ssr']).toMatchSnapshot();
|
||||
@ -294,4 +284,55 @@ describe('Host App Generator', () => {
|
||||
.toThrow(stripIndents`The "standalone" option is only supported in Angular >= 14.1.0. You are currently using 14.0.0.
|
||||
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
||||
});
|
||||
|
||||
describe('--project-name-and-root-format=derived', () => {
|
||||
it('should generate a host, integrate existing remotes and generate any remotes that dont exist', async () => {
|
||||
// ARRANGE
|
||||
const tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
await generateTestRemoteApplication(tree, {
|
||||
name: 'remote1',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
// ACT
|
||||
await generateTestHostApplication(tree, {
|
||||
name: 'hostApp',
|
||||
remotes: ['remote1', 'remote2', 'remote3'],
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists('apps/remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/remote3/project.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.read('apps/host-app/module-federation.config.js', 'utf-8')
|
||||
).toContain(`'remote1', 'remote2', 'remote3'`);
|
||||
});
|
||||
|
||||
it('should generate a host, integrate existing remotes and generate any remotes that dont exist, in a directory', async () => {
|
||||
// ARRANGE
|
||||
const tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
await generateTestRemoteApplication(tree, {
|
||||
name: 'remote1',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
// ACT
|
||||
await generateTestHostApplication(tree, {
|
||||
name: 'hostApp',
|
||||
directory: 'foo',
|
||||
remotes: ['remote1', 'remote2', 'remote3'],
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists('apps/remote1/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/foo/remote2/project.json')).toBeTruthy();
|
||||
expect(tree.exists('apps/foo/remote3/project.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.read('apps/foo/host-app/module-federation.config.js', 'utf-8')
|
||||
).toContain(`'remote1', 'foo-remote2', 'foo-remote3'`);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -413,7 +413,7 @@ export const myLibRoutes: Route[] = [
|
||||
`;
|
||||
|
||||
exports[`lib --standalone should generate a library with a standalone component in a directory 1`] = `
|
||||
"export * from './lib/my-dir-my-lib/my-dir-my-lib.component';
|
||||
"export * from './lib/my-lib/my-lib.component';
|
||||
"
|
||||
`;
|
||||
|
||||
@ -422,30 +422,30 @@ exports[`lib --standalone should generate a library with a standalone component
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@Component({
|
||||
selector: 'proj-my-dir-my-lib',
|
||||
selector: 'proj-my-lib',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: './my-dir-my-lib.component.html',
|
||||
styleUrls: ['./my-dir-my-lib.component.css'],
|
||||
templateUrl: './my-lib.component.html',
|
||||
styleUrls: ['./my-lib.component.css'],
|
||||
})
|
||||
export class MyDirMyLibComponent {}
|
||||
export class MyLibComponent {}
|
||||
"
|
||||
`;
|
||||
|
||||
exports[`lib --standalone should generate a library with a standalone component in a directory 3`] = `
|
||||
"import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { MyDirMyLibComponent } from './my-dir-my-lib.component';
|
||||
import { MyLibComponent } from './my-lib.component';
|
||||
|
||||
describe('MyDirMyLibComponent', () => {
|
||||
let component: MyDirMyLibComponent;
|
||||
let fixture: ComponentFixture<MyDirMyLibComponent>;
|
||||
describe('MyLibComponent', () => {
|
||||
let component: MyLibComponent;
|
||||
let fixture: ComponentFixture<MyLibComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [MyDirMyLibComponent],
|
||||
imports: [MyLibComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(MyDirMyLibComponent);
|
||||
fixture = TestBed.createComponent(MyLibComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
@ -506,12 +506,12 @@ exports[`lib router lazy should add RouterModule.forChild 1`] = `
|
||||
"import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { RouterModule } from '@angular/router';
|
||||
import { myDirMyLibRoutes } from './lib.routes';
|
||||
import { myLibRoutes } from './lib.routes';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, RouterModule.forChild(myDirMyLibRoutes)],
|
||||
imports: [CommonModule, RouterModule.forChild(myLibRoutes)],
|
||||
})
|
||||
export class MyDirMyLibModule {}
|
||||
export class MyLibModule {}
|
||||
"
|
||||
`;
|
||||
|
||||
@ -538,9 +538,8 @@ import { AppComponent } from './app.component';
|
||||
BrowserModule,
|
||||
RouterModule.forRoot([
|
||||
{
|
||||
path: 'my-dir-my-lib',
|
||||
loadChildren: () =>
|
||||
import('@proj/my-dir/my-lib').then((m) => m.MyDirMyLibModule),
|
||||
path: 'my-lib',
|
||||
loadChildren: () => import('@proj/my-lib').then((m) => m.MyLibModule),
|
||||
},
|
||||
]),
|
||||
],
|
||||
@ -561,19 +560,16 @@ import { AppComponent } from './app.component';
|
||||
BrowserModule,
|
||||
RouterModule.forRoot([
|
||||
{
|
||||
path: 'my-dir-my-lib',
|
||||
loadChildren: () =>
|
||||
import('@proj/my-dir/my-lib').then((m) => m.MyDirMyLibModule),
|
||||
path: 'my-lib',
|
||||
loadChildren: () => import('@proj/my-lib').then((m) => m.MyLibModule),
|
||||
},
|
||||
{
|
||||
path: 'my-lib2',
|
||||
loadChildren: () =>
|
||||
import('@proj/my-dir/my-lib2').then((m) => m.MyLib2Module),
|
||||
loadChildren: () => import('@proj/my-lib2').then((m) => m.MyLib2Module),
|
||||
},
|
||||
{
|
||||
path: 'my-lib3',
|
||||
loadChildren: () =>
|
||||
import('@proj/my-dir/my-lib3').then((m) => m.MyLib3Module),
|
||||
loadChildren: () => import('@proj/my-lib3').then((m) => m.MyLib3Module),
|
||||
},
|
||||
]),
|
||||
],
|
||||
@ -592,9 +588,8 @@ import { AppComponent } from './app.component';
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: 'my-dir-my-lib',
|
||||
loadChildren: () =>
|
||||
import('@proj/my-dir/my-lib').then((m) => m.MyDirMyLibModule),
|
||||
path: 'my-lib',
|
||||
loadChildren: () => import('@proj/my-lib').then((m) => m.MyLibModule),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ describe('updateModuleName Rule', () => {
|
||||
destination: 'my/first',
|
||||
updateImportPath: true,
|
||||
newProjectName: 'my-first',
|
||||
oldProjectRoot: 'libs/my-first',
|
||||
oldProjectRoot: 'my-first',
|
||||
};
|
||||
await moveGenerator(tree, schema);
|
||||
|
||||
@ -42,14 +42,14 @@ describe('updateModuleName Rule', () => {
|
||||
const updatedModuleSpecPath =
|
||||
'/libs/shared/my-first/src/lib/shared-my-first.module.spec.ts';
|
||||
const indexPath = '/libs/shared/my-first/src/index.ts';
|
||||
const secondModulePath = '/libs/my-second/src/lib/my-second.module.ts';
|
||||
const secondModulePath = 'my-second/src/lib/my-second.module.ts';
|
||||
|
||||
const schema: NormalizedSchema = {
|
||||
projectName: 'my-first',
|
||||
destination: 'shared/my-first',
|
||||
updateImportPath: true,
|
||||
newProjectName: 'shared-my-first',
|
||||
oldProjectRoot: 'libs/my-first',
|
||||
oldProjectRoot: 'my-first',
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
@ -72,7 +72,7 @@ describe('updateModuleName Rule', () => {
|
||||
unitTestRunner: UnitTestRunner.Jest,
|
||||
});
|
||||
tree.write(
|
||||
'/libs/my-first/src/lib/my-first.module.ts',
|
||||
'my-first/src/lib/my-first.module.ts',
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
|
||||
@ -83,7 +83,7 @@ describe('updateModuleName Rule', () => {
|
||||
);
|
||||
|
||||
tree.write(
|
||||
'/libs/my-first/src/lib/my-first.module.spec.ts',
|
||||
'my-first/src/lib/my-first.module.spec.ts',
|
||||
`import { async, TestBed } from '@angular/core/testing';
|
||||
import { MyFirstModule } from './my-first.module';
|
||||
|
||||
@ -159,14 +159,14 @@ describe('updateModuleName Rule', () => {
|
||||
destination: 'my-destination',
|
||||
updateImportPath: true,
|
||||
newProjectName: 'my-destination',
|
||||
oldProjectRoot: 'libs/my-source',
|
||||
oldProjectRoot: 'my-source',
|
||||
};
|
||||
|
||||
const modulePath = '/libs/my-destination/src/lib/my-destination.module.ts';
|
||||
const modulePath = 'my-destination/src/lib/my-destination.module.ts';
|
||||
const moduleSpecPath =
|
||||
'/libs/my-destination/src/lib/my-destination.module.spec.ts';
|
||||
const indexPath = '/libs/my-destination/src/index.ts';
|
||||
const importerPath = '/libs/my-importer/src/lib/my-importing-file.ts';
|
||||
'my-destination/src/lib/my-destination.module.spec.ts';
|
||||
const indexPath = 'my-destination/src/index.ts';
|
||||
const importerPath = 'my-importer/src/lib/my-importing-file.ts';
|
||||
|
||||
beforeEach(async () => {
|
||||
// fake a mid-move tree:
|
||||
@ -181,7 +181,7 @@ describe('updateModuleName Rule', () => {
|
||||
});
|
||||
|
||||
tree.write(
|
||||
'/libs/my-destination/src/lib/my-source.module.ts',
|
||||
'my-destination/src/lib/my-source.module.ts',
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@NgModule({
|
||||
@ -191,7 +191,7 @@ describe('updateModuleName Rule', () => {
|
||||
);
|
||||
|
||||
tree.write(
|
||||
'/libs/my-destination/src/lib/my-source.module.spec.ts',
|
||||
'my-destination/src/lib/my-source.module.spec.ts',
|
||||
`import { async, TestBed } from '@angular/core/testing';
|
||||
import { MySourceModule } from './my-source.module';
|
||||
describe('MySourceModule', () => {
|
||||
@ -292,7 +292,7 @@ describe('updateModuleName Rule', () => {
|
||||
updateModuleName(tree, schema);
|
||||
|
||||
const moduleFile = tree.read(
|
||||
'/libs/my-source-demo/src/lib/my-source-demo.module.ts',
|
||||
'my-source-demo/src/lib/my-source-demo.module.ts',
|
||||
'utf-8'
|
||||
);
|
||||
expect(moduleFile).toContain(`export class MySourceDemoModule {}`);
|
||||
|
||||
@ -23,21 +23,21 @@ describe('ngrx', () => {
|
||||
const defaultOptions: NgRxGeneratorOptions = {
|
||||
directory: '+state',
|
||||
minimal: true,
|
||||
parent: 'apps/myapp/src/app/app.module.ts',
|
||||
parent: 'myapp/src/app/app.module.ts',
|
||||
name: 'users',
|
||||
};
|
||||
|
||||
const defaultStandaloneOptions: NgRxGeneratorOptions = {
|
||||
directory: '+state',
|
||||
minimal: true,
|
||||
parent: 'apps/my-app/src/app/app.config.ts',
|
||||
parent: 'my-app/src/app/app.config.ts',
|
||||
name: 'users',
|
||||
};
|
||||
|
||||
const defaultModuleOptions: NgRxGeneratorOptions = {
|
||||
directory: '+state',
|
||||
minimal: true,
|
||||
module: 'apps/myapp/src/app/app.module.ts',
|
||||
module: 'myapp/src/app/app.module.ts',
|
||||
name: 'users',
|
||||
};
|
||||
|
||||
@ -85,7 +85,7 @@ describe('ngrx', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/app.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -96,24 +96,18 @@ describe('ngrx', () => {
|
||||
minimal: true,
|
||||
});
|
||||
|
||||
expect(tree.exists('/apps/myapp/src/app/+state/users.actions.ts')).toBe(
|
||||
expect(tree.exists('myapp/src/app/+state/users.actions.ts')).toBe(false);
|
||||
expect(tree.exists('myapp/src/app/+state/users.effects.ts')).toBe(false);
|
||||
expect(tree.exists('myapp/src/app/+state/users.effects.spec.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(tree.exists('/apps/myapp/src/app/+state/users.effects.ts')).toBe(
|
||||
expect(tree.exists('myapp/src/app/+state/users.reducer.ts')).toBe(false);
|
||||
expect(tree.exists('myapp/src/app/+state/users.selectors.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(
|
||||
tree.exists('/apps/myapp/src/app/+state/users.effects.spec.ts')
|
||||
).toBe(false);
|
||||
expect(tree.exists('/apps/myapp/src/app/+state/users.reducer.ts')).toBe(
|
||||
expect(tree.exists('myapp/src/app/+state/users.selectors.spec.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(tree.exists('/apps/myapp/src/app/+state/users.selectors.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(
|
||||
tree.exists('/apps/myapp/src/app/+state/users.selectors.spec.ts')
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should add a root module with feature module when minimal is set to false', async () => {
|
||||
@ -124,7 +118,7 @@ describe('ngrx', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/app.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -136,7 +130,7 @@ describe('ngrx', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/app.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -145,12 +139,12 @@ describe('ngrx', () => {
|
||||
|
||||
await ngrxGenerator(tree, {
|
||||
...defaultOptions,
|
||||
module: 'apps/no-router-app/src/app/app.module.ts',
|
||||
module: 'no-router-app/src/app/app.module.ts',
|
||||
root: true,
|
||||
});
|
||||
|
||||
const appModule = tree.read(
|
||||
'/apps/no-router-app/src/app/app.module.ts',
|
||||
'no-router-app/src/app/app.module.ts',
|
||||
'utf-8'
|
||||
);
|
||||
expect(appModule).not.toContain('StoreRouterConnectingModule.forRoot()');
|
||||
@ -164,7 +158,7 @@ describe('ngrx', () => {
|
||||
facade: true,
|
||||
});
|
||||
|
||||
expect(tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')).toContain(
|
||||
expect(tree.read('myapp/src/app/app.module.ts', 'utf-8')).toContain(
|
||||
'providers: [UsersFacade]'
|
||||
);
|
||||
});
|
||||
@ -177,9 +171,9 @@ describe('ngrx', () => {
|
||||
facade: false,
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')
|
||||
).not.toContain('providers: [UsersFacade]');
|
||||
expect(tree.read('myapp/src/app/app.module.ts', 'utf-8')).not.toContain(
|
||||
'providers: [UsersFacade]'
|
||||
);
|
||||
});
|
||||
|
||||
it('should not add facade provider when minimal is true', async () => {
|
||||
@ -190,9 +184,9 @@ describe('ngrx', () => {
|
||||
facade: true,
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')
|
||||
).not.toContain('providers: [UsersFacade]');
|
||||
expect(tree.read('myapp/src/app/app.module.ts', 'utf-8')).not.toContain(
|
||||
'providers: [UsersFacade]'
|
||||
);
|
||||
});
|
||||
|
||||
it('should not generate imports when skipImport is true', async () => {
|
||||
@ -202,14 +196,14 @@ describe('ngrx', () => {
|
||||
skipImport: true,
|
||||
});
|
||||
|
||||
expectFileToExist('/apps/myapp/src/app/+state/users.actions.ts');
|
||||
expectFileToExist('/apps/myapp/src/app/+state/users.effects.ts');
|
||||
expectFileToExist('/apps/myapp/src/app/+state/users.effects.spec.ts');
|
||||
expectFileToExist('/apps/myapp/src/app/+state/users.reducer.ts');
|
||||
expectFileToExist('/apps/myapp/src/app/+state/users.selectors.ts');
|
||||
expectFileToExist('/apps/myapp/src/app/+state/users.selectors.spec.ts');
|
||||
expectFileToExist('myapp/src/app/+state/users.actions.ts');
|
||||
expectFileToExist('myapp/src/app/+state/users.effects.ts');
|
||||
expectFileToExist('myapp/src/app/+state/users.effects.spec.ts');
|
||||
expectFileToExist('myapp/src/app/+state/users.reducer.ts');
|
||||
expectFileToExist('myapp/src/app/+state/users.selectors.ts');
|
||||
expectFileToExist('myapp/src/app/+state/users.selectors.spec.ts');
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/app.module.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/app.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -356,7 +350,7 @@ describe('ngrx', () => {
|
||||
});
|
||||
|
||||
it('should generate with custom directory', async () => {
|
||||
statePath = '/apps/myapp/src/app/my-custom-directory';
|
||||
statePath = 'myapp/src/app/my-custom-directory';
|
||||
|
||||
await ngrxGenerator(tree, {
|
||||
...defaultOptions,
|
||||
@ -502,11 +496,11 @@ describe('ngrx', () => {
|
||||
routing: true,
|
||||
});
|
||||
tree.write(
|
||||
'apps/my-app/src/app/app.component.html',
|
||||
'my-app/src/app/app.component.html',
|
||||
'<router-outlet></router-outlet>'
|
||||
);
|
||||
tree.write(
|
||||
'apps/my-app/src/app/app.routes.ts',
|
||||
'my-app/src/app/app.routes.ts',
|
||||
`import { Routes } from '@angular/router';
|
||||
import { NxWelcomeComponent } from './nx-welcome.component';
|
||||
export const appRoutes: Routes = [{ path: '', component: NxWelcomeComponent }];`
|
||||
@ -515,7 +509,7 @@ describe('ngrx', () => {
|
||||
|
||||
it('should throw when the parent cannot be found', async () => {
|
||||
// ARRANGE
|
||||
const parentPath = 'apps/my-app/src/app/non-existent.routes.ts';
|
||||
const parentPath = 'my-app/src/app/non-existent.routes.ts';
|
||||
|
||||
// ACT & ASSERT
|
||||
await expect(
|
||||
@ -533,28 +527,22 @@ describe('ngrx', () => {
|
||||
minimal: true,
|
||||
});
|
||||
|
||||
expect(tree.read('/apps/my-app/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('my-app/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.config.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.config.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.exists('/apps/my-app/src/app/+state/users.actions.ts')).toBe(
|
||||
expect(tree.exists('my-app/src/app/+state/users.actions.ts')).toBe(false);
|
||||
expect(tree.exists('my-app/src/app/+state/users.effects.ts')).toBe(false);
|
||||
expect(tree.exists('my-app/src/app/+state/users.effects.spec.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(tree.exists('/apps/my-app/src/app/+state/users.effects.ts')).toBe(
|
||||
expect(tree.exists('my-app/src/app/+state/users.reducer.ts')).toBe(false);
|
||||
expect(tree.exists('my-app/src/app/+state/users.selectors.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(
|
||||
tree.exists('/apps/my-app/src/app/+state/users.effects.spec.ts')
|
||||
).toBe(false);
|
||||
expect(tree.exists('/apps/my-app/src/app/+state/users.reducer.ts')).toBe(
|
||||
expect(tree.exists('my-app/src/app/+state/users.selectors.spec.ts')).toBe(
|
||||
false
|
||||
);
|
||||
expect(
|
||||
tree.exists('/apps/my-app/src/app/+state/users.selectors.ts')
|
||||
).toBe(false);
|
||||
expect(
|
||||
tree.exists('/apps/my-app/src/app/+state/users.selectors.spec.ts')
|
||||
).toBe(false);
|
||||
});
|
||||
|
||||
it('should add a root module with feature module when minimal is set to false', async () => {
|
||||
@ -564,9 +552,9 @@ describe('ngrx', () => {
|
||||
minimal: false,
|
||||
});
|
||||
|
||||
expect(tree.read('/apps/my-app/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('my-app/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.config.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.config.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -575,17 +563,17 @@ describe('ngrx', () => {
|
||||
...defaultStandaloneOptions,
|
||||
root: false,
|
||||
route: undefined,
|
||||
parent: 'apps/my-app/src/app/app.routes.ts',
|
||||
parent: 'my-app/src/app/app.routes.ts',
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.routes.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.routes.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should add a feature module when route is non-empty', async () => {
|
||||
tree.write(
|
||||
'apps/my-app/src/app/app.routes.ts',
|
||||
'my-app/src/app/app.routes.ts',
|
||||
`import { Routes } from '@angular/router';
|
||||
import { NxWelcomeComponent } from './nx-welcome.component';
|
||||
export const appRoutes: Routes = [{ path: 'home', component: NxWelcomeComponent }];`
|
||||
@ -595,11 +583,11 @@ describe('ngrx', () => {
|
||||
...defaultStandaloneOptions,
|
||||
root: false,
|
||||
route: 'home',
|
||||
parent: 'apps/my-app/src/app/app.routes.ts',
|
||||
parent: 'my-app/src/app/app.routes.ts',
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.routes.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.routes.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -608,11 +596,11 @@ describe('ngrx', () => {
|
||||
...defaultStandaloneOptions,
|
||||
root: false,
|
||||
route: '',
|
||||
parent: 'apps/my-app/src/app/app.routes.ts',
|
||||
parent: 'my-app/src/app/app.routes.ts',
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.routes.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.routes.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -624,9 +612,9 @@ describe('ngrx', () => {
|
||||
facade: true,
|
||||
});
|
||||
|
||||
expect(tree.read('/apps/my-app/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('my-app/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.config.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.config.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -636,11 +624,11 @@ describe('ngrx', () => {
|
||||
root: false,
|
||||
minimal: false,
|
||||
facade: true,
|
||||
parent: 'apps/my-app/src/app/app.routes.ts',
|
||||
parent: 'my-app/src/app/app.routes.ts',
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('/apps/my-app/src/app/app.routes.ts', 'utf-8')
|
||||
tree.read('my-app/src/app/app.routes.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
@ -691,7 +679,7 @@ describe('ngrx', () => {
|
||||
await ngrxGenerator(tree, defaultOptions);
|
||||
|
||||
expect(
|
||||
tree.read('apps/myapp/src/app/+state/users.effects.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/+state/users.effects.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -707,7 +695,7 @@ describe('ngrx', () => {
|
||||
await ngrxGenerator(tree, defaultOptions);
|
||||
|
||||
expect(
|
||||
tree.read('apps/myapp/src/app/+state/users.effects.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/+state/users.effects.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -715,7 +703,7 @@ describe('ngrx', () => {
|
||||
await ngrxGenerator(tree, { ...defaultOptions, facade: true });
|
||||
|
||||
expect(
|
||||
tree.read('apps/myapp/src/app/+state/users.facade.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/+state/users.facade.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -731,12 +719,12 @@ describe('ngrx', () => {
|
||||
await ngrxGenerator(tree, { ...defaultOptions, facade: true });
|
||||
|
||||
expect(
|
||||
tree.read('apps/myapp/src/app/+state/users.facade.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/+state/users.facade.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should throw when Angular version < 14.1 and NgRx < 15 but path to routes file is provided', async () => {
|
||||
const parentPath = 'apps/myapp/src/app/app.routes.ts';
|
||||
const parentPath = 'myapp/src/app/app.routes.ts';
|
||||
tree.write(
|
||||
parentPath,
|
||||
`import { Routes } from '@angular/router';
|
||||
@ -765,7 +753,7 @@ describe('ngrx', () => {
|
||||
});
|
||||
|
||||
it('should throw when Angular version < 15 and NgRx is not currently installed but path to routes file is provided', async () => {
|
||||
const parentPath = 'apps/myapp/src/app/app.routes.ts';
|
||||
const parentPath = 'myapp/src/app/app.routes.ts';
|
||||
tree.write(
|
||||
parentPath,
|
||||
`import { Routes } from '@angular/router';
|
||||
@ -793,7 +781,7 @@ describe('ngrx', () => {
|
||||
});
|
||||
|
||||
it('should throw when the provided parent does not have an NgModule', async () => {
|
||||
const parentPath = 'apps/myapp/src/app/app.routes.ts';
|
||||
const parentPath = 'myapp/src/app/app.routes.ts';
|
||||
tree.write(
|
||||
parentPath,
|
||||
`import { Routes } from '@angular/router';
|
||||
@ -830,7 +818,7 @@ describe('ngrx', () => {
|
||||
await ngrxGenerator(tree, defaultOptions);
|
||||
|
||||
expect(
|
||||
tree.read('/apps/myapp/src/app/+state/users.effects.ts', 'utf-8')
|
||||
tree.read('myapp/src/app/+state/users.effects.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@ -130,7 +130,7 @@ exports[`MF Remote App Generator --ssr should generate the correct files 6`] = `
|
||||
"module.exports = {
|
||||
name: 'test',
|
||||
exposes: {
|
||||
'./Module': 'apps/test/src/app/remote-entry/entry.module.ts',
|
||||
'./Module': 'test/src/app/remote-entry/entry.module.ts',
|
||||
},
|
||||
};
|
||||
"
|
||||
@ -198,11 +198,11 @@ exports[`MF Remote App Generator --ssr should generate the correct files 11`] =
|
||||
"executor": "@nx/angular:webpack-server",
|
||||
"options": {
|
||||
"customWebpackConfig": {
|
||||
"path": "apps/test/webpack.server.config.js",
|
||||
"path": "test/webpack.server.config.js",
|
||||
},
|
||||
"main": "apps/test/server.ts",
|
||||
"outputPath": "dist/apps/test/server",
|
||||
"tsConfig": "apps/test/tsconfig.server.json",
|
||||
"main": "test/server.ts",
|
||||
"outputPath": "dist/test/server",
|
||||
"tsConfig": "test/tsconfig.server.json",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -225,7 +225,7 @@ exports[`MF Remote App Generator --ssr should generate the correct files 13`] =
|
||||
],
|
||||
"executor": "nx:run-commands",
|
||||
"options": {
|
||||
"command": "PORT=4201 node dist/apps/test/server/main.js",
|
||||
"command": "PORT=4201 node dist/test/server/main.js",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -266,7 +266,7 @@ exports[`MF Remote App Generator should generate the a remote setup for standalo
|
||||
"module.exports = {
|
||||
name: 'test',
|
||||
exposes: {
|
||||
'./Routes': 'apps/test/src/app/remote-entry/entry.routes.ts',
|
||||
'./Routes': 'test/src/app/remote-entry/entry.routes.ts',
|
||||
},
|
||||
};
|
||||
"
|
||||
|
||||
@ -24,7 +24,7 @@ describe('MF Remote App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should generate a remote mf app with a host', async () => {
|
||||
@ -42,8 +42,8 @@ describe('MF Remote App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/host/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('apps/test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('host/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('test/webpack.config.js', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should error when a remote app is attempted to be generated with an incorrect host', async () => {
|
||||
@ -122,23 +122,21 @@ describe('MF Remote App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.exists(`apps/test/src/app/app.module.ts`)).toBeFalsy();
|
||||
expect(tree.exists(`apps/test/src/app/app.component.ts`)).toBeFalsy();
|
||||
expect(tree.exists(`test/src/app/app.module.ts`)).toBeFalsy();
|
||||
expect(tree.exists(`test/src/app/app.component.ts`)).toBeFalsy();
|
||||
expect(
|
||||
tree.exists(`apps/test/src/app/remote-entry/entry.module.ts`)
|
||||
tree.exists(`test/src/app/remote-entry/entry.module.ts`)
|
||||
).toBeFalsy();
|
||||
expect(tree.read(`apps/test/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/module-federation.config.js`, 'utf-8')
|
||||
tree.read(`test/module-federation.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/remote-entry/entry.component.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/remote-entry/entry.component.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/app/app.routes.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -168,7 +166,7 @@ describe('MF Remote App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/test/src/app/app.component.ts', 'utf-8'))
|
||||
expect(tree.read('test/src/app/app.component.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { Component } from '@angular/core';
|
||||
|
||||
@ -192,10 +190,10 @@ describe('MF Remote App Generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/test/src/index.html', 'utf-8')).not.toContain(
|
||||
expect(tree.read('test/src/index.html', 'utf-8')).not.toContain(
|
||||
'proj-root'
|
||||
);
|
||||
expect(tree.read('apps/test/src/index.html', 'utf-8')).toContain(
|
||||
expect(tree.read('test/src/index.html', 'utf-8')).toContain(
|
||||
'proj-test-entry'
|
||||
);
|
||||
});
|
||||
@ -214,39 +212,35 @@ describe('MF Remote App Generator', () => {
|
||||
// ASSERT
|
||||
const project = readProjectConfiguration(tree, 'test');
|
||||
expect(
|
||||
tree.exists(`apps/test/src/app/remote-entry/entry.module.ts`)
|
||||
tree.exists(`test/src/app/remote-entry/entry.module.ts`)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.module.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/app.module.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/bootstrap.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`test/src/bootstrap.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`test/src/main.server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read(`test/server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`test/module-federation.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/bootstrap.ts`, 'utf-8')
|
||||
tree.read(`test/webpack.server.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/bootstrap.server.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/remote-entry/entry.component.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/main.server.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read(`apps/test/server.ts`, 'utf-8')).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/module-federation.config.js`, 'utf-8')
|
||||
tree.read(`test/src/app/app.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/webpack.server.config.js`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/remote-entry/entry.component.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/app.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(project.targets.server).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(`apps/test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
|
||||
tree.read(`test/src/app/remote-entry/entry.routes.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(project.targets['static-server']).toMatchSnapshot();
|
||||
});
|
||||
@ -272,4 +266,35 @@ describe('MF Remote App Generator', () => {
|
||||
.toThrow(stripIndents`The "standalone" option is only supported in Angular >= 14.1.0. You are currently using 14.0.0.
|
||||
You can resolve this error by removing the "standalone" option or by migrating to Angular 14.1.0.`);
|
||||
});
|
||||
|
||||
describe('--project-name-and-root-format=derived', () => {
|
||||
it('should generate remote', async () => {
|
||||
const tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
|
||||
await generateTestRemoteApplication(tree, {
|
||||
name: 'test',
|
||||
port: 4201,
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
expect(tree.exists('apps/test/webpack.config.js')).toBe(true);
|
||||
expect(readProjectConfiguration(tree, 'test').root).toBe('apps/test');
|
||||
});
|
||||
|
||||
it('should generate remote in a directory', async () => {
|
||||
const tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
|
||||
await generateTestRemoteApplication(tree, {
|
||||
name: 'test',
|
||||
port: 4201,
|
||||
directory: 'shared',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
expect(tree.exists('apps/shared/test/webpack.config.js')).toBe(true);
|
||||
expect(readProjectConfiguration(tree, 'shared-test').root).toBe(
|
||||
'apps/shared/test'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -11,7 +11,7 @@ describe('scam-to-standalone', () => {
|
||||
await scamGenerator(tree, { name: 'bar', project: 'foo' });
|
||||
|
||||
tree.write(
|
||||
'apps/foo/src/app/mymodule.module.ts',
|
||||
'foo/src/app/mymodule.module.ts',
|
||||
`import { BarComponentModule } from './bar/bar.component';
|
||||
|
||||
@NgModule({
|
||||
@ -25,7 +25,7 @@ describe('scam-to-standalone', () => {
|
||||
project: 'foo',
|
||||
});
|
||||
|
||||
expect(tree.read('apps/foo/src/app/bar/bar.component.ts', 'utf-8'))
|
||||
expect(tree.read('foo/src/app/bar/bar.component.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { Component, NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
@ -41,7 +41,7 @@ describe('scam-to-standalone', () => {
|
||||
"
|
||||
`);
|
||||
|
||||
expect(tree.read('apps/foo/src/app/mymodule.module.ts', 'utf-8'))
|
||||
expect(tree.read('foo/src/app/mymodule.module.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { BarComponent } from './bar/bar.component';
|
||||
|
||||
@ -52,7 +52,7 @@ describe('scam-to-standalone', () => {
|
||||
"
|
||||
`);
|
||||
|
||||
expect(tree.read('apps/foo/src/app/bar/bar.component.spec.ts', 'utf-8'))
|
||||
expect(tree.read('foo/src/app/bar/bar.component.spec.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { BarComponent } from './bar.component';
|
||||
|
||||
@ -94,7 +94,7 @@ exports[`Init MF should create webpack and mf configs correctly 4`] = `
|
||||
"module.exports = {
|
||||
name: 'remote1',
|
||||
exposes: {
|
||||
'./Module': 'apps/remote1/src/app/remote-entry/entry.module.ts',
|
||||
'./Module': 'remote1/src/app/remote-entry/entry.module.ts',
|
||||
},
|
||||
};
|
||||
"
|
||||
|
||||
@ -36,20 +36,15 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
tree.exists(`apps/${app}/module-federation.config.js`)
|
||||
).toBeTruthy();
|
||||
expect(tree.exists(`apps/${app}/webpack.config.js`)).toBeTruthy();
|
||||
expect(tree.exists(`apps/${app}/webpack.prod.config.js`)).toBeTruthy();
|
||||
expect(tree.exists(`${app}/module-federation.config.js`)).toBeTruthy();
|
||||
expect(tree.exists(`${app}/webpack.config.js`)).toBeTruthy();
|
||||
expect(tree.exists(`${app}/webpack.prod.config.js`)).toBeTruthy();
|
||||
|
||||
const webpackContents = tree.read(
|
||||
`apps/${app}/webpack.config.js`,
|
||||
'utf-8'
|
||||
);
|
||||
const webpackContents = tree.read(`${app}/webpack.config.js`, 'utf-8');
|
||||
expect(webpackContents).toMatchSnapshot();
|
||||
|
||||
const mfConfigContents = tree.read(
|
||||
`apps/${app}/module-federation.config.js`,
|
||||
`${app}/module-federation.config.js`,
|
||||
'utf-8'
|
||||
);
|
||||
expect(mfConfigContents).toMatchSnapshot();
|
||||
@ -63,7 +58,7 @@ describe('Init MF', () => {
|
||||
'create bootstrap file with the contents of main.ts',
|
||||
async (app, type: 'host' | 'remote') => {
|
||||
// ARRANGE
|
||||
const mainContents = tree.read(`apps/${app}/src/main.ts`, 'utf-8');
|
||||
const mainContents = tree.read(`${app}/src/main.ts`, 'utf-8');
|
||||
|
||||
// ACT
|
||||
await setupMf(tree, {
|
||||
@ -72,11 +67,8 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
const bootstrapContents = tree.read(
|
||||
`apps/${app}/src/bootstrap.ts`,
|
||||
'utf-8'
|
||||
);
|
||||
const updatedMainContents = tree.read(`apps/${app}/src/main.ts`, 'utf-8');
|
||||
const bootstrapContents = tree.read(`${app}/src/bootstrap.ts`, 'utf-8');
|
||||
const updatedMainContents = tree.read(`${app}/src/main.ts`, 'utf-8');
|
||||
|
||||
expect(bootstrapContents).toEqual(mainContents);
|
||||
expect(updatedMainContents).not.toEqual(mainContents);
|
||||
@ -90,7 +82,7 @@ describe('Init MF', () => {
|
||||
'should alter main.ts to import the bootstrap file dynamically',
|
||||
async (app, type: 'host' | 'remote') => {
|
||||
// ARRANGE
|
||||
const mainContents = tree.read(`apps/${app}/src/main.ts`, 'utf-8');
|
||||
const mainContents = tree.read(`${app}/src/main.ts`, 'utf-8');
|
||||
|
||||
// ACT
|
||||
await setupMf(tree, {
|
||||
@ -99,7 +91,7 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
const updatedMainContents = tree.read(`apps/${app}/src/main.ts`, 'utf-8');
|
||||
const updatedMainContents = tree.read(`${app}/src/main.ts`, 'utf-8');
|
||||
|
||||
expect(updatedMainContents).toEqual(
|
||||
`import('./bootstrap').catch((err) => console.error(err));\n`
|
||||
@ -130,7 +122,7 @@ describe('Init MF', () => {
|
||||
);
|
||||
expect(build.executor).toEqual('@nx/angular:webpack-browser');
|
||||
expect(build.options.customWebpackConfig.path).toEqual(
|
||||
`apps/${app}/webpack.config.js`
|
||||
`${app}/webpack.config.js`
|
||||
);
|
||||
}
|
||||
);
|
||||
@ -145,7 +137,7 @@ describe('Init MF', () => {
|
||||
|
||||
// ASSERT
|
||||
const { build } = readProjectConfiguration(tree, 'app1').targets;
|
||||
expect(tree.exists('apps/app1/webpack.prod.config.js')).toBeFalsy();
|
||||
expect(tree.exists('app1/webpack.prod.config.js')).toBeFalsy();
|
||||
expect(build.configurations.production.customWebpackConfig).toBeUndefined();
|
||||
});
|
||||
|
||||
@ -159,10 +151,10 @@ describe('Init MF', () => {
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
tree.read('apps/remote1/src/app/remote-entry/entry.component.ts', 'utf-8')
|
||||
tree.read('remote1/src/app/remote-entry/entry.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read('apps/remote1/src/app/remote-entry/entry.module.ts', 'utf-8')
|
||||
tree.read('remote1/src/app/remote-entry/entry.module.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -172,7 +164,7 @@ describe('Init MF', () => {
|
||||
|
||||
// ASSERT
|
||||
expect(
|
||||
tree.read('apps/remote1/src/app/remote-entry/entry.component.ts', 'utf-8')
|
||||
tree.read('remote1/src/app/remote-entry/entry.component.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -186,7 +178,7 @@ describe('Init MF', () => {
|
||||
|
||||
// ASSERT
|
||||
const mfConfigContents = tree.read(
|
||||
`apps/app1/module-federation.config.js`,
|
||||
`app1/module-federation.config.js`,
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
@ -208,10 +200,7 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
const hostMfConfig = tree.read(
|
||||
'apps/app1/module-federation.config.js',
|
||||
'utf-8'
|
||||
);
|
||||
const hostMfConfig = tree.read('app1/module-federation.config.js', 'utf-8');
|
||||
expect(hostMfConfig).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -242,10 +231,7 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
const hostMfConfig = tree.read(
|
||||
'apps/app1/module-federation.config.js',
|
||||
'utf-8'
|
||||
);
|
||||
const hostMfConfig = tree.read('app1/module-federation.config.js', 'utf-8');
|
||||
expect(hostMfConfig).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -280,7 +266,7 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
const hostAppRoutes = tree.read('apps/app1/src/app/app.routes.ts', 'utf-8');
|
||||
const hostAppRoutes = tree.read('app1/src/app/app.routes.ts', 'utf-8');
|
||||
expect(hostAppRoutes).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -301,7 +287,7 @@ describe('Init MF', () => {
|
||||
|
||||
// ASSERT
|
||||
const cypressCommands = tree.read(
|
||||
'apps/test-app-e2e/src/support/e2e.ts',
|
||||
'test-app-e2e/src/support/e2e.ts',
|
||||
'utf-8'
|
||||
);
|
||||
expect(cypressCommands).toContain(
|
||||
@ -320,13 +306,13 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('app1/module-federation.config.js', 'utf-8')).toContain(
|
||||
'remotes: []'
|
||||
);
|
||||
expect(
|
||||
tree.read('apps/app1/module-federation.config.js', 'utf-8')
|
||||
).toContain('remotes: []');
|
||||
expect(
|
||||
tree.exists('apps/app1/src/assets/module-federation.manifest.json')
|
||||
tree.exists('app1/src/assets/module-federation.manifest.json')
|
||||
).toBeTruthy();
|
||||
expect(tree.read('apps/app1/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('app1/src/main.ts', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
||||
@ -355,8 +341,7 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/ng14/src/bootstrap.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
expect(tree.read('ng14/src/bootstrap.ts', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { RemoteEntryComponent } from './app/remote-entry/entry.component';
|
||||
@ -392,17 +377,15 @@ describe('Init MF', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('app1/module-federation.config.js', 'utf-8')).toContain(
|
||||
'remotes: []'
|
||||
);
|
||||
expect(
|
||||
tree.read('apps/app1/module-federation.config.js', 'utf-8')
|
||||
).toContain('remotes: []');
|
||||
expect(
|
||||
readJson(tree, 'apps/app1/src/assets/module-federation.manifest.json')
|
||||
readJson(tree, 'app1/src/assets/module-federation.manifest.json')
|
||||
).toEqual({
|
||||
remote1: 'http://localhost:4201',
|
||||
});
|
||||
expect(
|
||||
tree.read('apps/app1/src/app/app.routes.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read('app1/src/app/app.routes.ts', 'utf-8')).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('should throw an error when installed version of angular < 14.1.0 and --standalone is used', async () => {
|
||||
|
||||
@ -20,9 +20,9 @@ exports[`setupSSR should create the files correctly for ssr 1`] = `
|
||||
],
|
||||
"executor": "@angular-devkit/build-angular:server",
|
||||
"options": {
|
||||
"main": "apps/app1/server.ts",
|
||||
"outputPath": "dist/apps/app1/server",
|
||||
"tsConfig": "apps/app1/tsconfig.server.json",
|
||||
"main": "app1/server.ts",
|
||||
"outputPath": "dist/app1/server",
|
||||
"tsConfig": "app1/tsconfig.server.json",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -41,7 +41,7 @@ import { AppServerModule } from './src/main.server';
|
||||
// The Express app is exported so that it can be used by serverless Functions.
|
||||
export function app(): express.Express {
|
||||
const server = express();
|
||||
const distFolder = join(process.cwd(), 'dist/apps/app1/browser');
|
||||
const distFolder = join(process.cwd(), 'dist/app1/browser');
|
||||
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
|
||||
? 'index.original.html'
|
||||
: 'index';
|
||||
@ -122,9 +122,9 @@ exports[`setupSSR should create the files correctly for ssr when app is standalo
|
||||
],
|
||||
"executor": "@angular-devkit/build-angular:server",
|
||||
"options": {
|
||||
"main": "apps/app1/server.ts",
|
||||
"outputPath": "dist/apps/app1/server",
|
||||
"tsConfig": "apps/app1/tsconfig.server.json",
|
||||
"main": "app1/server.ts",
|
||||
"outputPath": "dist/app1/server",
|
||||
"tsConfig": "app1/tsconfig.server.json",
|
||||
},
|
||||
}
|
||||
`;
|
||||
@ -143,7 +143,7 @@ import bootstrap from './src/main.server';
|
||||
// The Express app is exported so that it can be used by serverless Functions.
|
||||
export function app(): express.Express {
|
||||
const server = express();
|
||||
const distFolder = join(process.cwd(), 'dist/apps/app1/browser');
|
||||
const distFolder = join(process.cwd(), 'dist/app1/browser');
|
||||
const indexHtml = existsSync(join(distFolder, 'index.original.html'))
|
||||
? 'index.original.html'
|
||||
: 'index';
|
||||
@ -217,8 +217,8 @@ exports[`setupSSR should use fileReplacements if they already exist 1`] = `
|
||||
"production": {
|
||||
"fileReplacements": [
|
||||
{
|
||||
"replace": "apps/app1/src/environments/environment.ts",
|
||||
"with": "apps/app1/src/environments/environment.prod.ts",
|
||||
"replace": "app1/src/environments/environment.ts",
|
||||
"with": "app1/src/environments/environment.prod.ts",
|
||||
},
|
||||
],
|
||||
"outputHashing": "media",
|
||||
@ -230,9 +230,9 @@ exports[`setupSSR should use fileReplacements if they already exist 1`] = `
|
||||
],
|
||||
"executor": "@angular-devkit/build-angular:server",
|
||||
"options": {
|
||||
"main": "apps/app1/server.ts",
|
||||
"outputPath": "dist/apps/app1/server",
|
||||
"tsConfig": "apps/app1/tsconfig.server.json",
|
||||
"main": "app1/server.ts",
|
||||
"outputPath": "dist/app1/server",
|
||||
"tsConfig": "app1/tsconfig.server.json",
|
||||
},
|
||||
}
|
||||
`;
|
||||
|
||||
@ -27,13 +27,13 @@ describe('setupSSR', () => {
|
||||
expect(
|
||||
readProjectConfiguration(tree, 'app1').targets.server
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read('apps/app1/server.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('apps/app1/src/main.server.ts', 'utf-8'))
|
||||
expect(tree.read('app1/server.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('app1/src/main.server.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"export { AppServerModule } from './app/app.server.module';
|
||||
"
|
||||
`);
|
||||
expect(tree.read('apps/app1/src/main.ts', 'utf-8')).toMatchInlineSnapshot(`
|
||||
expect(tree.read('app1/src/main.ts', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
@ -42,7 +42,7 @@ describe('setupSSR', () => {
|
||||
.catch((err) => console.error(err));
|
||||
"
|
||||
`);
|
||||
expect(tree.read('apps/app1/tsconfig.server.json', 'utf-8'))
|
||||
expect(tree.read('app1/tsconfig.server.json', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
@ -56,7 +56,7 @@ describe('setupSSR', () => {
|
||||
}
|
||||
"
|
||||
`);
|
||||
expect(tree.read('apps/app1/src/app/app.server.module.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.server.module.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { NgModule } from '@angular/core';
|
||||
import { ServerModule } from '@angular/platform-server';
|
||||
@ -71,7 +71,7 @@ describe('setupSSR', () => {
|
||||
export class AppServerModule {}
|
||||
"
|
||||
`);
|
||||
expect(tree.read('apps/app1/src/app/app.module.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.module.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
@ -128,13 +128,13 @@ describe('setupSSR', () => {
|
||||
name: 'app1',
|
||||
});
|
||||
|
||||
tree.write('apps/app1/src/environments/environment.ts', '');
|
||||
tree.write('apps/app1/src/environments/environment.prod.ts', '');
|
||||
tree.write('app1/src/environments/environment.ts', '');
|
||||
tree.write('app1/src/environments/environment.prod.ts', '');
|
||||
const project = readProjectConfiguration(tree, 'app1');
|
||||
project.targets.build.configurations.production.fileReplacements = [
|
||||
{
|
||||
replace: 'apps/app1/src/environments/environment.ts',
|
||||
with: 'apps/app1/src/environments/environment.prod.ts',
|
||||
replace: 'app1/src/environments/environment.ts',
|
||||
with: 'app1/src/environments/environment.prod.ts',
|
||||
},
|
||||
];
|
||||
updateProjectConfiguration(tree, 'app1', project);
|
||||
@ -164,8 +164,8 @@ describe('setupSSR', () => {
|
||||
expect(
|
||||
readProjectConfiguration(tree, 'app1').targets.server
|
||||
).toMatchSnapshot();
|
||||
expect(tree.read('apps/app1/server.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('apps/app1/src/main.server.ts', 'utf-8'))
|
||||
expect(tree.read('app1/server.ts', 'utf-8')).toMatchSnapshot();
|
||||
expect(tree.read('app1/src/main.server.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { AppComponent } from './app/app.component';
|
||||
@ -176,7 +176,7 @@ describe('setupSSR', () => {
|
||||
export default bootstrap;
|
||||
"
|
||||
`);
|
||||
expect(tree.read('apps/app1/tsconfig.server.json', 'utf-8'))
|
||||
expect(tree.read('app1/tsconfig.server.json', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
@ -190,7 +190,7 @@ describe('setupSSR', () => {
|
||||
}
|
||||
"
|
||||
`);
|
||||
expect(tree.read('apps/app1/src/app/app.config.server.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.config.server.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||
import { provideServerRendering } from '@angular/platform-server';
|
||||
@ -249,7 +249,7 @@ describe('setupSSR', () => {
|
||||
await setupSsr(tree, { project: 'app1', hydration: true });
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/app1/src/app/app.module.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.module.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { NgModule } from '@angular/core';
|
||||
import {
|
||||
@ -283,7 +283,7 @@ describe('setupSSR', () => {
|
||||
await setupSsr(tree, { project: 'app1', hydration: true });
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/app1/src/app/app.config.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.config.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { ApplicationConfig } from '@angular/core';
|
||||
import { provideClientHydration } from '@angular/platform-browser';
|
||||
@ -294,7 +294,7 @@ describe('setupSSR', () => {
|
||||
"
|
||||
`);
|
||||
|
||||
expect(tree.read('apps/app1/src/app/app.config.server.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.config.server.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { mergeApplicationConfig, ApplicationConfig } from '@angular/core';
|
||||
import { provideServerRendering } from '@angular/platform-server';
|
||||
@ -356,7 +356,7 @@ describe('setupSSR', () => {
|
||||
await setupSsr(tree, { project: 'app1' });
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/app1/src/main.server.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/main.server.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"/***************************************************************************************************
|
||||
* Initialize the server environment - for example, adding DOM built-in types to the global scope.
|
||||
@ -389,7 +389,7 @@ describe('setupSSR', () => {
|
||||
await setupSsr(tree, { project: 'app1' });
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/app1/src/app/app.module.ts', 'utf-8'))
|
||||
expect(tree.read('app1/src/app/app.module.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"import { NgModule } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
@ -422,8 +422,7 @@ describe('setupSSR', () => {
|
||||
await setupSsr(tree, { project: 'app1' });
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read('apps/app1/src/main.ts', 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
expect(tree.read('app1/src/main.ts', 'utf-8')).toMatchInlineSnapshot(`
|
||||
"import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
|
||||
@ -32,7 +32,7 @@ describe('angularStories generator: applications', () => {
|
||||
await angularStoriesGenerator(tree, { name: appName });
|
||||
|
||||
expect(
|
||||
tree.read(`apps/${appName}/src/app/app.component.stories.ts`, 'utf-8')
|
||||
tree.read(`${appName}/src/app/app.component.stories.ts`, 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -42,9 +42,7 @@ describe('angularStories generator: applications', () => {
|
||||
await angularStoriesGenerator(tree, { name: appName });
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`apps/${appName}/src/app/my-scam/my-scam.component.stories.ts`
|
||||
)
|
||||
tree.exists(`${appName}/src/app/my-scam/my-scam.component.stories.ts`)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -53,13 +51,11 @@ describe('angularStories generator: applications', () => {
|
||||
|
||||
await angularStoriesGenerator(tree, {
|
||||
name: appName,
|
||||
ignorePaths: [`apps/${appName}/src/app/my-scam/**`],
|
||||
ignorePaths: [`${appName}/src/app/my-scam/**`],
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`apps/${appName}/src/app/my-scam/my-scam.component.stories.ts`
|
||||
)
|
||||
tree.exists(`${appName}/src/app/my-scam/my-scam.component.stories.ts`)
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -68,13 +64,11 @@ describe('angularStories generator: applications', () => {
|
||||
|
||||
await angularStoriesGenerator(tree, {
|
||||
name: appName,
|
||||
ignorePaths: [`apps/${appName}/src/app/my-scam/my-scam.component.ts`],
|
||||
ignorePaths: [`${appName}/src/app/my-scam/my-scam.component.ts`],
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`apps/${appName}/src/app/my-scam/my-scam.component.stories.ts`
|
||||
)
|
||||
tree.exists(`${appName}/src/app/my-scam/my-scam.component.stories.ts`)
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -87,27 +81,25 @@ describe('angularStories generator: applications', () => {
|
||||
|
||||
await angularStoriesGenerator(tree, {
|
||||
name: appName,
|
||||
ignorePaths: [
|
||||
`apps/${appName}/src/app/component-a/component-a.component.ts`,
|
||||
],
|
||||
ignorePaths: [`${appName}/src/app/component-a/component-a.component.ts`],
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read(
|
||||
`apps/${appName}/src/app/component-a/component-b/component-b.component.stories.ts`,
|
||||
`${appName}/src/app/component-a/component-b/component-b.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.exists(
|
||||
`apps/${appName}/src/app/component-a/component-a.component.stories.ts`
|
||||
`${appName}/src/app/component-a/component-a.component.stories.ts`
|
||||
)
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should ignore a path when using a routing module', async () => {
|
||||
tree.write(
|
||||
`apps/${appName}/src/app/component/component.module.ts`,
|
||||
`${appName}/src/app/component/component.module.ts`,
|
||||
stripIndents`
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
@ -116,7 +108,7 @@ describe('angularStories generator: applications', () => {
|
||||
`
|
||||
);
|
||||
tree.write(
|
||||
`apps/${appName}/src/app/component/component-routing.module.ts`,
|
||||
`${appName}/src/app/component/component-routing.module.ts`,
|
||||
stripIndents`
|
||||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
@ -138,17 +130,17 @@ describe('angularStories generator: applications', () => {
|
||||
|
||||
await angularStoriesGenerator(tree, {
|
||||
name: appName,
|
||||
ignorePaths: [`apps/${appName}/src/app/app.component.ts`],
|
||||
ignorePaths: [`${appName}/src/app/app.component.ts`],
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read(
|
||||
`apps/${appName}/src/app/component/component.component.stories.ts`,
|
||||
`${appName}/src/app/component/component.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.exists(`apps/${appName}/src/app/app.component.stories.ts`)
|
||||
tree.exists(`${appName}/src/app/app.component.stories.ts`)
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -163,7 +155,7 @@ describe('angularStories generator: applications', () => {
|
||||
|
||||
expect(
|
||||
tree.read(
|
||||
`apps/${appName}/src/app/my-scam/my-scam.component.stories.ts`,
|
||||
`${appName}/src/app/my-scam/my-scam.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
|
||||
@ -53,7 +53,7 @@ describe('angularStories generator: libraries', () => {
|
||||
|
||||
it('should generate stories.ts files', async () => {
|
||||
// add secondary entrypoint
|
||||
writeJson(tree, `libs/${libName}/package.json`, { name: libName });
|
||||
writeJson(tree, `${libName}/package.json`, { name: libName });
|
||||
await librarySecondaryEntryPointGenerator(tree, {
|
||||
library: libName,
|
||||
name: 'secondary-entry-point',
|
||||
@ -62,40 +62,40 @@ describe('angularStories generator: libraries', () => {
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
});
|
||||
|
||||
await angularStoriesGenerator(tree, { name: libName });
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/barrel/barrel-button/barrel-button.component.stories.ts`
|
||||
`${libName}/src/lib/barrel/barrel-button/barrel-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/nested/nested-button/nested-button.component.stories.ts`
|
||||
`${libName}/src/lib/nested/nested-button/nested-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.stories.ts`
|
||||
`${libName}/src/lib/test-button/test-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/test-other/test-other.component.stories.ts`
|
||||
`${libName}/src/lib/test-other/test-other.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.read(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.stories.ts`,
|
||||
`${libName}/src/lib/test-button/test-button.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts`
|
||||
`${libName}/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
@ -118,12 +118,12 @@ describe('angularStories generator: libraries', () => {
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.stories.ts`
|
||||
`${libName}/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.stories.ts`
|
||||
`${libName}/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
@ -135,17 +135,17 @@ describe('angularStories generator: libraries', () => {
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.stories.ts`
|
||||
`${libName}/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.stories.ts`
|
||||
`${libName}/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.stories.ts`
|
||||
`${libName}/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
@ -157,12 +157,12 @@ describe('angularStories generator: libraries', () => {
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/static-member-declarations/cmp1/cmp1.component.stories.ts`
|
||||
`${libName}/src/lib/static-member-declarations/cmp1/cmp1.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/static-member-declarations/cmp2/cmp2.component.stories.ts`
|
||||
`${libName}/src/lib/static-member-declarations/cmp2/cmp2.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
});
|
||||
@ -173,9 +173,7 @@ describe('angularStories generator: libraries', () => {
|
||||
await angularStoriesGenerator(tree, { name: libName });
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/my-scam/my-scam.component.stories.ts`
|
||||
)
|
||||
tree.exists(`${libName}/src/lib/my-scam/my-scam.component.stories.ts`)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -189,9 +187,7 @@ describe('angularStories generator: libraries', () => {
|
||||
await angularStoriesGenerator(tree, { name: libName });
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/my-scam/my-scam.component.stories.ts`
|
||||
)
|
||||
tree.exists(`${libName}/src/lib/my-scam/my-scam.component.stories.ts`)
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
@ -203,7 +199,7 @@ describe('angularStories generator: libraries', () => {
|
||||
standalone: true,
|
||||
});
|
||||
// add secondary entrypoint
|
||||
writeJson(tree, `libs/${libName}/package.json`, { name: libName });
|
||||
writeJson(tree, `${libName}/package.json`, { name: libName });
|
||||
await librarySecondaryEntryPointGenerator(tree, {
|
||||
library: libName,
|
||||
name: 'secondary-entry-point',
|
||||
@ -212,7 +208,7 @@ describe('angularStories generator: libraries', () => {
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-standalone',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
standalone: true,
|
||||
});
|
||||
|
||||
@ -220,23 +216,23 @@ describe('angularStories generator: libraries', () => {
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/standalone/standalone.component.stories.ts`
|
||||
`${libName}/src/lib/standalone/standalone.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.read(
|
||||
`libs/${libName}/src/lib/standalone/standalone.component.stories.ts`,
|
||||
`${libName}/src/lib/standalone/standalone.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts`
|
||||
`${libName}/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.read(
|
||||
`libs/${libName}/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts`,
|
||||
`${libName}/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
@ -244,7 +240,7 @@ describe('angularStories generator: libraries', () => {
|
||||
|
||||
it('should ignore paths', async () => {
|
||||
// add secondary entrypoint
|
||||
writeJson(tree, `libs/${libName}/package.json`, { name: libName });
|
||||
writeJson(tree, `${libName}/package.json`, { name: libName });
|
||||
await librarySecondaryEntryPointGenerator(tree, {
|
||||
library: libName,
|
||||
name: 'secondary-entry-point',
|
||||
@ -253,46 +249,46 @@ describe('angularStories generator: libraries', () => {
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
});
|
||||
|
||||
await angularStoriesGenerator(tree, {
|
||||
name: libName,
|
||||
ignorePaths: [
|
||||
`libs/${libName}/src/lib/barrel/**`,
|
||||
`libs/${libName}/secondary-entry-point/**`,
|
||||
`${libName}/src/lib/barrel/**`,
|
||||
`${libName}/secondary-entry-point/**`,
|
||||
],
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/barrel/barrel-button/barrel-button.component.stories.ts`
|
||||
`${libName}/src/lib/barrel/barrel-button/barrel-button.component.stories.ts`
|
||||
)
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/nested/nested-button/nested-button.component.stories.ts`
|
||||
`${libName}/src/lib/nested/nested-button/nested-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.stories.ts`
|
||||
`${libName}/src/lib/test-button/test-button.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/src/lib/test-other/test-other.component.stories.ts`
|
||||
`${libName}/src/lib/test-other/test-other.component.stories.ts`
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
tree.read(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.stories.ts`,
|
||||
`${libName}/src/lib/test-button/test-button.component.stories.ts`,
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.exists(
|
||||
`libs/${libName}/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts`
|
||||
`${libName}/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts`
|
||||
)
|
||||
).toBeFalsy();
|
||||
});
|
||||
|
||||
@ -97,102 +97,102 @@ exports[`StorybookConfiguration generator should generate in the correct folder
|
||||
"jest.config.ts",
|
||||
"jest.preset.js",
|
||||
"libs/.gitignore",
|
||||
"libs/test-ui-lib/.eslintrc.json",
|
||||
"libs/test-ui-lib/.storybook/main.ts",
|
||||
"libs/test-ui-lib/.storybook/preview.ts",
|
||||
"libs/test-ui-lib/.storybook/tsconfig.json",
|
||||
"libs/test-ui-lib/jest.config.ts",
|
||||
"libs/test-ui-lib/package.json",
|
||||
"libs/test-ui-lib/project.json",
|
||||
"libs/test-ui-lib/README.md",
|
||||
"libs/test-ui-lib/secondary-entry-point/ng-package.json",
|
||||
"libs/test-ui-lib/secondary-entry-point/README.md",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/index.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.css",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.html",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.spec.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-entry-point.module.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.css",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.html",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.spec.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.ts",
|
||||
"libs/test-ui-lib/src/index.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/index.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel.module.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested.module.ts",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.css",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.html",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.css",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.html",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.css",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.html",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/static-member-declarations.module.ts",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.css",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.html",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.ts",
|
||||
"libs/test-ui-lib/src/lib/test-ui-lib.module.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare.module.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare.module.ts",
|
||||
"libs/test-ui-lib/src/test-setup.ts",
|
||||
"libs/test-ui-lib/tsconfig.json",
|
||||
"libs/test-ui-lib/tsconfig.lib.json",
|
||||
"libs/test-ui-lib/tsconfig.spec.json",
|
||||
"nx.json",
|
||||
"package.json",
|
||||
"test-ui-lib/.eslintrc.json",
|
||||
"test-ui-lib/.storybook/main.ts",
|
||||
"test-ui-lib/.storybook/preview.ts",
|
||||
"test-ui-lib/.storybook/tsconfig.json",
|
||||
"test-ui-lib/jest.config.ts",
|
||||
"test-ui-lib/package.json",
|
||||
"test-ui-lib/project.json",
|
||||
"test-ui-lib/README.md",
|
||||
"test-ui-lib/secondary-entry-point/ng-package.json",
|
||||
"test-ui-lib/secondary-entry-point/README.md",
|
||||
"test-ui-lib/secondary-entry-point/src/index.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.css",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.html",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.spec.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-entry-point.module.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.css",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.html",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.spec.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.ts",
|
||||
"test-ui-lib/src/index.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.css",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.html",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/index.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel.module.ts",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.css",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.html",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.ts",
|
||||
"test-ui-lib/src/lib/nested/nested.module.ts",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.css",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.html",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.spec.ts",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.stories.ts",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.css",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.html",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.spec.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.stories.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.css",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.html",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.spec.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.stories.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/static-member-declarations.module.ts",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.css",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.html",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.ts",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.css",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.html",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.spec.ts",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.stories.ts",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.ts",
|
||||
"test-ui-lib/src/lib/test-ui-lib.module.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.css",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.html",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.css",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.html",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare.module.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.css",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.html",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.css",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.html",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.css",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.html",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare.module.ts",
|
||||
"test-ui-lib/src/test-setup.ts",
|
||||
"test-ui-lib/tsconfig.json",
|
||||
"test-ui-lib/tsconfig.lib.json",
|
||||
"test-ui-lib/tsconfig.spec.json",
|
||||
"tsconfig.base.json",
|
||||
]
|
||||
`;
|
||||
@ -208,102 +208,102 @@ exports[`StorybookConfiguration generator should generate the right files 1`] =
|
||||
"jest.config.ts",
|
||||
"jest.preset.js",
|
||||
"libs/.gitignore",
|
||||
"libs/test-ui-lib/.eslintrc.json",
|
||||
"libs/test-ui-lib/.storybook/main.ts",
|
||||
"libs/test-ui-lib/.storybook/preview.ts",
|
||||
"libs/test-ui-lib/.storybook/tsconfig.json",
|
||||
"libs/test-ui-lib/jest.config.ts",
|
||||
"libs/test-ui-lib/package.json",
|
||||
"libs/test-ui-lib/project.json",
|
||||
"libs/test-ui-lib/README.md",
|
||||
"libs/test-ui-lib/secondary-entry-point/ng-package.json",
|
||||
"libs/test-ui-lib/secondary-entry-point/README.md",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/index.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.css",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.html",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.spec.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-entry-point.module.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.css",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.html",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.spec.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts",
|
||||
"libs/test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.ts",
|
||||
"libs/test-ui-lib/src/index.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel-button/index.ts",
|
||||
"libs/test-ui-lib/src/lib/barrel/barrel.module.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested-button/nested-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/nested/nested.module.ts",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.css",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.html",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/standalone/standalone.component.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.css",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.html",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.css",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.html",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.ts",
|
||||
"libs/test-ui-lib/src/lib/static-member-declarations/static-member-declarations.module.ts",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/test-button/test-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.css",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.html",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/test-other/test-other.component.ts",
|
||||
"libs/test-ui-lib/src/lib/test-ui-lib.module.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-declare/variable-declare.module.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.css",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.html",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.spec.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.stories.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.ts",
|
||||
"libs/test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare.module.ts",
|
||||
"libs/test-ui-lib/src/test-setup.ts",
|
||||
"libs/test-ui-lib/tsconfig.json",
|
||||
"libs/test-ui-lib/tsconfig.lib.json",
|
||||
"libs/test-ui-lib/tsconfig.spec.json",
|
||||
"nx.json",
|
||||
"package.json",
|
||||
"test-ui-lib/.eslintrc.json",
|
||||
"test-ui-lib/.storybook/main.ts",
|
||||
"test-ui-lib/.storybook/preview.ts",
|
||||
"test-ui-lib/.storybook/tsconfig.json",
|
||||
"test-ui-lib/jest.config.ts",
|
||||
"test-ui-lib/package.json",
|
||||
"test-ui-lib/project.json",
|
||||
"test-ui-lib/README.md",
|
||||
"test-ui-lib/secondary-entry-point/ng-package.json",
|
||||
"test-ui-lib/secondary-entry-point/README.md",
|
||||
"test-ui-lib/secondary-entry-point/src/index.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.css",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.html",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.spec.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.stories.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-button/secondary-button.component.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-entry-point.module.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.css",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.html",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.spec.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.stories.ts",
|
||||
"test-ui-lib/secondary-entry-point/src/lib/secondary-standalone/secondary-standalone.component.ts",
|
||||
"test-ui-lib/src/index.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.css",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.html",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/barrel-button.component.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel-button/index.ts",
|
||||
"test-ui-lib/src/lib/barrel/barrel.module.ts",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.css",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.html",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/nested/nested-button/nested-button.component.ts",
|
||||
"test-ui-lib/src/lib/nested/nested.module.ts",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.css",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.html",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.spec.ts",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.stories.ts",
|
||||
"test-ui-lib/src/lib/standalone/standalone.component.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.css",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.html",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.spec.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.stories.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp1/cmp1.component.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.css",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.html",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.spec.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.stories.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/cmp2/cmp2.component.ts",
|
||||
"test-ui-lib/src/lib/static-member-declarations/static-member-declarations.module.ts",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.css",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.html",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/test-button/test-button.component.ts",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.css",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.html",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.spec.ts",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.stories.ts",
|
||||
"test-ui-lib/src/lib/test-other/test-other.component.ts",
|
||||
"test-ui-lib/src/lib/test-ui-lib.module.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.css",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.html",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-button/variable-declare-button.component.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.css",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.html",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare-view/variable-declare-view.component.ts",
|
||||
"test-ui-lib/src/lib/variable-declare/variable-declare.module.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.css",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.html",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-anotherview/variable-spread-declare-anotherview.component.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.css",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.html",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-button/variable-spread-declare-button.component.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.css",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.html",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.spec.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.stories.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare-view/variable-spread-declare-view.component.ts",
|
||||
"test-ui-lib/src/lib/variable-spread-declare/variable-spread-declare.module.ts",
|
||||
"test-ui-lib/src/test-setup.ts",
|
||||
"test-ui-lib/tsconfig.json",
|
||||
"test-ui-lib/tsconfig.lib.json",
|
||||
"test-ui-lib/tsconfig.spec.json",
|
||||
"tsconfig.base.json",
|
||||
]
|
||||
`;
|
||||
|
||||
@ -50,18 +50,16 @@ describe('StorybookConfiguration generator', () => {
|
||||
generateStories: false,
|
||||
});
|
||||
|
||||
expect(tree.exists('libs/test-ui-lib/.storybook/main.ts')).toBeTruthy();
|
||||
expect(
|
||||
tree.exists('libs/test-ui-lib/.storybook/tsconfig.json')
|
||||
).toBeTruthy();
|
||||
expect(tree.exists('test-ui-lib/.storybook/main.ts')).toBeTruthy();
|
||||
expect(tree.exists('test-ui-lib/.storybook/tsconfig.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.exists(
|
||||
'libs/test-ui-lib/src/lib/test-button/test-button.component.stories.ts'
|
||||
'test-ui-lib/src/lib/test-button/test-button.component.stories.ts'
|
||||
)
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
tree.exists(
|
||||
'libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts'
|
||||
'test-ui-lib/src/lib/test-other/test-other.component.stories.ts'
|
||||
)
|
||||
).toBeFalsy();
|
||||
});
|
||||
@ -74,7 +72,7 @@ describe('StorybookConfiguration generator', () => {
|
||||
});
|
||||
|
||||
expect(
|
||||
tree.read('libs/test-ui-lib/.storybook/main.ts', 'utf-8')
|
||||
tree.read('test-ui-lib/.storybook/main.ts', 'utf-8')
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
|
||||
@ -84,19 +82,17 @@ describe('StorybookConfiguration generator', () => {
|
||||
generateStories: true,
|
||||
});
|
||||
|
||||
expect(tree.exists('libs/test-ui-lib/.storybook/main.ts')).toBeTruthy();
|
||||
expect(
|
||||
tree.exists('libs/test-ui-lib/.storybook/tsconfig.json')
|
||||
).toBeTruthy();
|
||||
expect(tree.exists('test-ui-lib/.storybook/main.ts')).toBeTruthy();
|
||||
expect(tree.exists('test-ui-lib/.storybook/tsconfig.json')).toBeTruthy();
|
||||
expect(
|
||||
tree.read(
|
||||
'libs/test-ui-lib/src/lib/test-button/test-button.component.stories.ts',
|
||||
'test-ui-lib/src/lib/test-button/test-button.component.stories.ts',
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
expect(
|
||||
tree.read(
|
||||
'libs/test-ui-lib/src/lib/test-other/test-other.component.stories.ts',
|
||||
'test-ui-lib/src/lib/test-other/test-other.component.stories.ts',
|
||||
'utf-8'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
@ -120,7 +116,7 @@ describe('StorybookConfiguration generator', () => {
|
||||
standalone: true,
|
||||
});
|
||||
// add secondary entrypoint
|
||||
writeJson(tree, `libs/${libName}/package.json`, { name: libName });
|
||||
writeJson(tree, `${libName}/package.json`, { name: libName });
|
||||
await librarySecondaryEntryPointGenerator(tree, {
|
||||
library: libName,
|
||||
name: 'secondary-entry-point',
|
||||
@ -129,14 +125,14 @@ describe('StorybookConfiguration generator', () => {
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
export: true,
|
||||
});
|
||||
// add a standalone component to the secondary entrypoint
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-standalone',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
standalone: true,
|
||||
export: true,
|
||||
});
|
||||
@ -157,7 +153,7 @@ describe('StorybookConfiguration generator', () => {
|
||||
standalone: true,
|
||||
});
|
||||
// add secondary entrypoint
|
||||
writeJson(tree, `libs/${libName}/package.json`, { name: libName });
|
||||
writeJson(tree, `${libName}/package.json`, { name: libName });
|
||||
await librarySecondaryEntryPointGenerator(tree, {
|
||||
library: libName,
|
||||
name: 'secondary-entry-point',
|
||||
@ -166,14 +162,14 @@ describe('StorybookConfiguration generator', () => {
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
export: true,
|
||||
});
|
||||
// add a standalone component to the secondary entrypoint
|
||||
await componentGenerator(tree, {
|
||||
name: 'secondary-standalone',
|
||||
project: libName,
|
||||
path: `libs/${libName}/secondary-entry-point/src/lib`,
|
||||
path: `${libName}/secondary-entry-point/src/lib`,
|
||||
standalone: true,
|
||||
export: true,
|
||||
});
|
||||
|
||||
@ -20,7 +20,10 @@ export async function generateTestApplication(
|
||||
): Promise<void> {
|
||||
addAngularPluginPeerDeps(tree);
|
||||
tree.write('.gitignore', '');
|
||||
await applicationGenerator(tree, options);
|
||||
await applicationGenerator(tree, {
|
||||
projectNameAndRootFormat: 'as-provided',
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
export async function generateTestHostApplication(
|
||||
@ -29,7 +32,7 @@ export async function generateTestHostApplication(
|
||||
): Promise<void> {
|
||||
addAngularPluginPeerDeps(tree);
|
||||
tree.write('.gitignore', '');
|
||||
await host(tree, options);
|
||||
await host(tree, { projectNameAndRootFormat: 'as-provided', ...options });
|
||||
}
|
||||
|
||||
export async function generateTestRemoteApplication(
|
||||
@ -38,7 +41,7 @@ export async function generateTestRemoteApplication(
|
||||
): Promise<void> {
|
||||
addAngularPluginPeerDeps(tree);
|
||||
tree.write('.gitignore', '');
|
||||
await remote(tree, options);
|
||||
await remote(tree, { projectNameAndRootFormat: 'as-provided', ...options });
|
||||
}
|
||||
|
||||
export async function generateTestLibrary(
|
||||
@ -47,7 +50,10 @@ export async function generateTestLibrary(
|
||||
): Promise<void> {
|
||||
addAngularPluginPeerDeps(tree);
|
||||
tree.write('.gitignore', '');
|
||||
await libraryGenerator(tree, options);
|
||||
await libraryGenerator(tree, {
|
||||
projectNameAndRootFormat: 'as-provided',
|
||||
...options,
|
||||
});
|
||||
}
|
||||
|
||||
export async function createStorybookTestWorkspaceForLib(
|
||||
@ -65,6 +71,7 @@ export async function createStorybookTestWorkspaceForLib(
|
||||
simpleName: false,
|
||||
skipFormat: false,
|
||||
unitTestRunner: UnitTestRunner.Jest,
|
||||
projectNameAndRootFormat: 'as-provided',
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
@ -73,7 +80,7 @@ export async function createStorybookTestWorkspaceForLib(
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.ts`,
|
||||
`${libName}/src/lib/test-button/test-button.component.ts`,
|
||||
`import { Component, Input } from '@angular/core';
|
||||
|
||||
export type ButtonStyle = 'default' | 'primary' | 'accent';
|
||||
@ -92,11 +99,11 @@ export class TestButtonComponent {
|
||||
);
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/test-button/test-button.component.html`,
|
||||
`${libName}/src/lib/test-button/test-button.component.html`,
|
||||
`<button [attr.type]="type" [ngClass]="style"></button>`
|
||||
);
|
||||
|
||||
const modulePath = `libs/${libName}/src/lib/${libName}.module.ts`;
|
||||
const modulePath = `${libName}/src/lib/${libName}.module.ts`;
|
||||
tree.write(
|
||||
modulePath,
|
||||
`import * as ButtonExports from './test-button/test-button.component';
|
||||
@ -112,17 +119,17 @@ export class TestButtonComponent {
|
||||
await componentGenerator(tree, {
|
||||
name: 'barrel-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/barrel`,
|
||||
path: `${libName}/src/lib/barrel`,
|
||||
module: 'barrel',
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/barrel/barrel-button/index.ts`,
|
||||
`${libName}/src/lib/barrel/barrel-button/index.ts`,
|
||||
`export * from './barrel-button.component';`
|
||||
);
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/barrel/barrel.module.ts`,
|
||||
`${libName}/src/lib/barrel/barrel.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { BarrelButtonComponent } from './barrel-button';
|
||||
@ -143,19 +150,19 @@ export class BarrelModule {}`
|
||||
await componentGenerator(tree, {
|
||||
name: 'variable-declare-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/variable-declare`,
|
||||
path: `${libName}/src/lib/variable-declare`,
|
||||
module: 'variable-declare',
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
name: 'variable-declare-view',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/variable-declare`,
|
||||
path: `${libName}/src/lib/variable-declare`,
|
||||
module: 'variable-declare',
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/variable-declare/variable-declare.module.ts`,
|
||||
`${libName}/src/lib/variable-declare/variable-declare.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { VariableDeclareButtonComponent } from './variable-declare-button/variable-declare-button.component';
|
||||
@ -183,26 +190,26 @@ export class VariableDeclareModule {}`
|
||||
await componentGenerator(tree, {
|
||||
name: 'variable-spread-declare-button',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/variable-spread-declare`,
|
||||
path: `${libName}/src/lib/variable-spread-declare`,
|
||||
module: 'variable-spread-declare',
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
name: 'variable-spread-declare-view',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/variable-spread-declare`,
|
||||
path: `${libName}/src/lib/variable-spread-declare`,
|
||||
module: 'variable-spread-declare',
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
name: 'variable-spread-declare-anotherview',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/variable-spread-declare`,
|
||||
path: `${libName}/src/lib/variable-spread-declare`,
|
||||
module: 'variable-spread-declare',
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/variable-spread-declare/variable-spread-declare.module.ts`,
|
||||
`${libName}/src/lib/variable-spread-declare/variable-spread-declare.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { VariableSpreadDeclareButtonComponent } from './variable-spread-declare-button/variable-spread-declare-button.component';
|
||||
@ -230,19 +237,19 @@ export class VariableSpreadDeclareModule {}`
|
||||
await componentGenerator(tree, {
|
||||
name: 'cmp1',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/static-member-declarations`,
|
||||
path: `${libName}/src/lib/static-member-declarations`,
|
||||
module: 'static-member-declarations',
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
name: 'cmp2',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib/static-member-declarations`,
|
||||
path: `${libName}/src/lib/static-member-declarations`,
|
||||
module: 'static-member-declarations',
|
||||
});
|
||||
|
||||
tree.write(
|
||||
`libs/${libName}/src/lib/static-member-declarations/static-member-declarations.module.ts`,
|
||||
`${libName}/src/lib/static-member-declarations/static-member-declarations.module.ts`,
|
||||
`import { NgModule } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { Cmp1Component } from './cmp1/cmp1.component';
|
||||
@ -262,14 +269,14 @@ export class StaticMemberDeclarationsModule {
|
||||
generateModule(tree, {
|
||||
name: 'nested',
|
||||
project: libName,
|
||||
path: `libs/${libName}/src/lib`,
|
||||
path: `${libName}/src/lib`,
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
name: 'nested-button',
|
||||
project: libName,
|
||||
module: 'nested',
|
||||
path: `libs/${libName}/src/lib/nested`,
|
||||
path: `${libName}/src/lib/nested`,
|
||||
});
|
||||
|
||||
await componentGenerator(tree, {
|
||||
|
||||
@ -17,16 +17,16 @@ describe('webWorker generator', () => {
|
||||
it('should generate files', async () => {
|
||||
await webWorkerGenerator(tree, { name: 'test-worker', project: appName });
|
||||
|
||||
expect(tree.exists(`apps/${appName}/tsconfig.worker.json`));
|
||||
expect(tree.exists(`apps/${appName}/src/app/test-worker.worker.ts`));
|
||||
expect(tree.exists(`${appName}/tsconfig.worker.json`));
|
||||
expect(tree.exists(`${appName}/src/app/test-worker.worker.ts`));
|
||||
});
|
||||
|
||||
it('should extend from tsconfig.base.json', async () => {
|
||||
await webWorkerGenerator(tree, { name: 'test-worker', project: appName });
|
||||
|
||||
expect(
|
||||
tree.read(`apps/${appName}/tsconfig.worker.json`, 'utf-8')
|
||||
).toContain('"extends": "../../tsconfig.base.json"');
|
||||
expect(tree.read(`${appName}/tsconfig.worker.json`, 'utf-8')).toContain(
|
||||
'"extends": "../tsconfig.base.json"'
|
||||
);
|
||||
});
|
||||
|
||||
it('should extend from tsconfig.json when used instead of tsconfig.base.json', async () => {
|
||||
@ -34,9 +34,9 @@ describe('webWorker generator', () => {
|
||||
|
||||
await webWorkerGenerator(tree, { name: 'test-worker', project: appName });
|
||||
|
||||
expect(
|
||||
tree.read(`apps/${appName}/tsconfig.worker.json`, 'utf-8')
|
||||
).toContain('"extends": "../../tsconfig.json"');
|
||||
expect(tree.read(`${appName}/tsconfig.worker.json`, 'utf-8')).toContain(
|
||||
'"extends": "../tsconfig.json"'
|
||||
);
|
||||
});
|
||||
|
||||
it('should format files', async () => {
|
||||
@ -61,7 +61,7 @@ describe('webWorker generator', () => {
|
||||
|
||||
it('should add the snippet correctly', async () => {
|
||||
// ARRANGE
|
||||
tree.write(`apps/${appName}/src/app/test-worker.ts`, ``);
|
||||
tree.write(`${appName}/src/app/test-worker.ts`, ``);
|
||||
|
||||
// ACT
|
||||
await webWorkerGenerator(tree, {
|
||||
@ -71,7 +71,7 @@ describe('webWorker generator', () => {
|
||||
});
|
||||
|
||||
// ASSERT
|
||||
expect(tree.read(`apps/${appName}/src/app/test-worker.ts`, 'utf-8'))
|
||||
expect(tree.read(`${appName}/src/app/test-worker.ts`, 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"if (typeof Worker !== 'undefined') {
|
||||
// Create a new
|
||||
@ -86,7 +86,7 @@ describe('webWorker generator', () => {
|
||||
}
|
||||
"
|
||||
`);
|
||||
expect(tree.read(`apps/${appName}/src/app/test-worker.worker.ts`, 'utf-8'))
|
||||
expect(tree.read(`${appName}/src/app/test-worker.worker.ts`, 'utf-8'))
|
||||
.toMatchInlineSnapshot(`
|
||||
"/// <reference lib="webworker" />
|
||||
|
||||
|
||||
@ -7,7 +7,10 @@ describe('renameWebpackServer', () => {
|
||||
it('should rename webpack-server to webpack-dev-server correctly', async () => {
|
||||
// ARRANGE
|
||||
const tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
await generateTestRemoteApplication(tree, { name: 'remote' });
|
||||
await generateTestRemoteApplication(tree, {
|
||||
name: 'remote',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
updateJson(tree, 'apps/remote/project.json', (json) => {
|
||||
json.targets.serve.executor = '@nrwl/angular:webpack-server';
|
||||
|
||||
@ -12,6 +12,7 @@ describe('Migration to delete Browserslist configurations', () => {
|
||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
await generateTestApplication(tree, {
|
||||
name: 'test',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@ -16,10 +16,12 @@ describe('Migration to update target and add useDefineForClassFields', () => {
|
||||
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
await generateTestApplication(tree, {
|
||||
name: 'test',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
await generateTestApplication(tree, {
|
||||
name: 'karma',
|
||||
unitTestRunner: UnitTestRunner.None,
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
const karmaProject = readProjectConfiguration(tree, 'karma');
|
||||
|
||||
@ -12,6 +12,7 @@ describe(`Migration to remove bundleDependencies`, () => {
|
||||
const tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
|
||||
await generateTestApplication(tree, {
|
||||
name: 'test',
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
const project = readProjectConfiguration(tree, 'test');
|
||||
|
||||
@ -74,6 +74,7 @@ async function setup(tree: Tree, name: string) {
|
||||
await generateTestApplication(tree, {
|
||||
name,
|
||||
skipPackageJson: true,
|
||||
projectNameAndRootFormat: 'derived',
|
||||
});
|
||||
|
||||
const projectConfig = readProjectConfiguration(tree, name);
|
||||
|
||||
@ -32,7 +32,7 @@ export function createApp(
|
||||
// save for getAppDir() lookup by external *.spec.ts tests
|
||||
appConfig = {
|
||||
appName,
|
||||
appModule: `/apps/${appName}/src/app/app.module.ts`,
|
||||
appModule: `${appName}/src/app/app.module.ts`,
|
||||
};
|
||||
|
||||
tree.write(
|
||||
@ -51,7 +51,7 @@ export function createApp(
|
||||
`
|
||||
);
|
||||
tree.write(
|
||||
`/apps/${appName}/src/main.ts`,
|
||||
`${appName}/src/main.ts`,
|
||||
`
|
||||
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
|
||||
|
||||
@ -63,24 +63,24 @@ export function createApp(
|
||||
`
|
||||
);
|
||||
tree.write(
|
||||
`/apps/${appName}/tsconfig.app.json`,
|
||||
`${appName}/tsconfig.app.json`,
|
||||
JSON.stringify({
|
||||
include: ['**/*.ts'],
|
||||
})
|
||||
);
|
||||
tree.write(
|
||||
`/apps/${appName}-e2e/tsconfig.e2e.json`,
|
||||
`${appName}-e2e/tsconfig.e2e.json`,
|
||||
JSON.stringify({
|
||||
include: ['../**/*.ts'],
|
||||
})
|
||||
);
|
||||
addProjectConfiguration(tree, appName, {
|
||||
root: `apps/${appName}`,
|
||||
sourceRoot: `apps/${appName}/src`,
|
||||
root: `${appName}`,
|
||||
sourceRoot: `${appName}/src`,
|
||||
targets: {
|
||||
build: {
|
||||
options: {
|
||||
main: `apps/${appName}/src/main.ts`,
|
||||
main: `${appName}/src/main.ts`,
|
||||
},
|
||||
},
|
||||
serve: {
|
||||
@ -96,8 +96,8 @@ export function createLib(tree: Tree, libName: string) {
|
||||
|
||||
libConfig = {
|
||||
name,
|
||||
module: `/libs/${propertyName}/src/lib/${fileName}.module.ts`,
|
||||
barrel: `/libs/${propertyName}/src/index.ts`,
|
||||
module: `${propertyName}/src/lib/${fileName}.module.ts`,
|
||||
barrel: `${propertyName}/src/index.ts`,
|
||||
};
|
||||
|
||||
tree.write(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user