Skip to content

Commit

Permalink
feat: enable Angular CT support (#23089)
Browse files Browse the repository at this point in the history
  • Loading branch information
ZachJW34 committed Aug 3, 2022
1 parent f73810d commit 94e78eb
Show file tree
Hide file tree
Showing 14 changed files with 47 additions and 46 deletions.
8 changes: 7 additions & 1 deletion cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@
"vue",
"react",
"vue2",
"react18"
"react18",
"angular"
],
"bin": {
"cypress": "bin/cypress"
Expand Down Expand Up @@ -149,6 +150,11 @@
"./mount-utils": {
"require": "./mount-utils/dist/index.js",
"types": "./mount-utils/dist/index.d.ts"
},
"./angular": {
"import": "./angular/dist/index.js",
"require": "./angular/dist/index.js",
"types": "./angular/dist/index.d.ts"
}
},
"workspaces": {
Expand Down
1 change: 1 addition & 0 deletions cli/scripts/post-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const npmModulesToCopy = [
'react18',
'vue',
'vue2',
'angular',
]

npmModulesToCopy.forEach((folder) => {
Expand Down
2 changes: 1 addition & 1 deletion cli/types/cypress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3044,7 +3044,7 @@ declare namespace Cypress {

type DevServerConfigOptions = {
bundler: 'webpack'
framework: 'react' | 'vue' | 'vue-cli' | 'nuxt' | 'create-react-app' | 'next'
framework: 'react' | 'vue' | 'vue-cli' | 'nuxt' | 'create-react-app' | 'next' | 'angular'
webpackConfig?: PickConfigOpt<'webpackConfig'>
} | {
bundler: 'vite'
Expand Down
1 change: 1 addition & 0 deletions npm/angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"prebuild": "rimraf dist",
"build": "tsc || echo 'built, with type errors'",
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
"build-prod": "yarn build",
"check-ts": "tsc --noEmit"
},
Expand Down
3 changes: 1 addition & 2 deletions npm/webpack-dev-server/cypress/e2e/angular.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ for (const project of WEBPACK_REACT) {
continue
}

// TODO: revert once Angular is slated for release
describe.skip(`Working with ${project}`, () => {
describe(`Working with ${project}`, () => {
beforeEach(() => {
cy.scaffoldProject(project)
cy.openProject(project)
Expand Down
8 changes: 4 additions & 4 deletions npm/webpack-dev-server/src/devServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { nuxtHandler } from './helpers/nuxtHandler'
import { createReactAppHandler } from './helpers/createReactAppHandler'
import { nextHandler } from './helpers/nextHandler'
import { sourceDefaultWebpackDependencies, SourceRelativeWebpackResult } from './helpers/sourceRelativeWebpackModules'
import { angularHandler } from './helpers/angularHandler'

const debug = debugLib('cypress:webpack-dev-server:devServer')

Expand All @@ -25,7 +26,7 @@ export type WebpackDevServerConfig = {
webpackConfig?: unknown // Derived from the user's webpack
}

export const ALL_FRAMEWORKS = ['create-react-app', 'nuxt', 'react', 'vue-cli', 'next', 'vue'] as const
export const ALL_FRAMEWORKS = ['create-react-app', 'nuxt', 'react', 'vue-cli', 'next', 'vue', 'angular'] as const

/**
* @internal
Expand Down Expand Up @@ -115,9 +116,8 @@ async function getPreset (devServerConfig: WebpackDevServerConfig): Promise<Opti
case 'next':
return await nextHandler(devServerConfig)

// TODO: revert once Angular is slated for release
// case 'angular':
// return await angularHandler(devServerConfig)
case 'angular':
return await angularHandler(devServerConfig)

case 'react':
case 'vue':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ const frameworkWebpackMapper: FrameworkWebpackMapper = {
react: undefined,
vue: undefined,
next: 'next',
// TODO: revert once Angular is slated for release
// 'angular': '@angular-devkit/build-angular',
'angular': '@angular-devkit/build-angular',
}

// Source the users framework from the provided projectRoot. The framework, if available, will serve
Expand Down
3 changes: 1 addition & 2 deletions npm/webpack-dev-server/src/makeDefaultWebpackConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ export function makeDefaultWebpackConfig (
plugins: [
new HtmlWebpackPlugin({
template: indexHtmlFile,
// TODO: revert once Angular is slated for release
// Angular generates all of it's scripts with <script type="module">. Live-reloading breaks without this option.
// ...(config.devServerConfig.framework === 'angular' ? { scriptLoading: 'module' } : {}),
...(config.devServerConfig.framework === 'angular' ? { scriptLoading: 'module' } : {}),
}),
],
} as any
Expand Down
7 changes: 3 additions & 4 deletions npm/webpack-dev-server/test/handlers/angularHandler.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ const projectConfig: AngularJsonProjectConfig = {
},
}

// TODO: revert once Angular is slated for release
describe.skip('angularHandler', function () {
describe('angularHandler', function () {
this.timeout(1000 * 60)

it('sources the config from angular-13', async () => {
Expand All @@ -54,7 +53,7 @@ describe.skip('angularHandler', function () {
projectRoot,
specPattern: 'src/**/*.cy.ts',
} as Cypress.PluginConfigOptions,
// framework: 'angular',
framework: 'angular',
} as WebpackDevServerConfig

const { frameworkConfig: webpackConfig, sourceWebpackModulesResult } = await angularHandler(devServerConfig)
Expand All @@ -79,7 +78,7 @@ describe.skip('angularHandler', function () {
projectRoot,
specPattern: 'src/**/*.cy.ts',
} as Cypress.PluginConfigOptions,
// framework: 'angular',
framework: 'angular',
} as WebpackDevServerConfig

const { frameworkConfig: webpackConfig, sourceWebpackModulesResult } = await angularHandler(devServerConfig)
Expand Down
1 change: 1 addition & 0 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ type FileParts implements Node {
}

enum FrontendFrameworkEnum {
angular
nextjs
nuxtjs
react
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,7 @@ describe('scaffolding component testing', {
})
})

// TODO: revert once Angular is slated for release
context.skip('angular-cli-unconfigured', () => {
context('angular-cli-unconfigured', () => {
it('scaffolds component testing for Angular', () => {
startSetupFor('angular-cli-unconfigured')

Expand Down
5 changes: 2 additions & 3 deletions packages/launchpad/src/utils/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import LogoNext from '../images/logos/nextjs.svg'
import LogoNuxt from '../images/logos/nuxt.svg'
import LogoVue from '../images/logos/vue.svg'
import LogoReact from '../images/logos/react.svg'
// import LogoAngular from '../images/logos/angular.svg'
import LogoAngular from '../images/logos/angular.svg'

import type { FrontendFrameworkEnum, SupportedBundlers } from '../generated/graphql'

Expand All @@ -19,6 +19,5 @@ export const FrameworkBundlerLogos: Record<FrontendFrameworkEnum | SupportedBund
nuxtjs: LogoNuxt,
react: LogoReact,
reactscripts: LogoReact,
// TODO: revert once Angular is slated for release
// angular: LogoAngular,
angular: LogoAngular,
}
45 changes: 22 additions & 23 deletions packages/scaffold-config/src/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,27 +219,26 @@ export const WIZARD_FRAMEWORKS = [
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
},
// TODO: revert once Angular is slated for release
// {
// type: 'angular',
// configFramework: 'angular',
// category: 'template',
// name: 'Angular',
// detectors: [dependencies.WIZARD_DEPENDENCY_ANGULAR_CLI],
// supportedBundlers: [dependencies.WIZARD_DEPENDENCY_WEBPACK],
// dependencies: (bundler: WizardBundler['type'], projectPath: string): DependencyToInstall[] => {
// return [
// isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_CLI, projectPath),
// isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_DEVKIT_BUILD_ANGULAR, projectPath),
// isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_CORE, projectPath),
// isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_COMMON, projectPath),
// isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_PLATFORM_BROWSER_DYNAMIC, projectPath),
// ]
// },
// codeGenFramework: 'angular',
// mountModule: 'cypress/angular',
// supportStatus: 'full',
// componentIndexHtml: componentIndexHtmlGenerator(),
// specPattern: '**/*.cy.ts',
// },
{
type: 'angular',
configFramework: 'angular',
category: 'template',
name: 'Angular',
detectors: [dependencies.WIZARD_DEPENDENCY_ANGULAR_CLI],
supportedBundlers: [dependencies.WIZARD_DEPENDENCY_WEBPACK],
dependencies: (bundler: WizardBundler['type'], projectPath: string): Promise<DependencyToInstall[]> => {
return Promise.all([
isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_CLI, projectPath),
isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_DEVKIT_BUILD_ANGULAR, projectPath),
isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_CORE, projectPath),
isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_COMMON, projectPath),
isDependencyInstalled(dependencies.WIZARD_DEPENDENCY_ANGULAR_PLATFORM_BROWSER_DYNAMIC, projectPath),
])
},
codeGenFramework: 'angular',
mountModule: 'cypress/angular',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
specPattern: '**/*.cy.ts',
},
] as const
3 changes: 1 addition & 2 deletions packages/scaffold-config/test/unit/detect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,7 @@ describe('detectFramework', () => {
})

;['13.0.0', '14.0.0'].forEach((v) => {
// TODO: revert once Angular is slated for release
it.skip(`Angular CLI v${v}`, async () => {
it(`Angular CLI v${v}`, async () => {
const projectPath = await scaffoldMigrationProject('angular-cli-unconfigured')

fakeDepsInNodeModules(projectPath, [
Expand Down

5 comments on commit 94e78eb

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 94e78eb Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/linux-x64/develop-94e78eba0430eae97529058c40611e5f24dbf140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 94e78eb Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/darwin-arm64/develop-94e78eba0430eae97529058c40611e5f24dbf140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 94e78eb Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/linux-arm64/develop-94e78eba0430eae97529058c40611e5f24dbf140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 94e78eb Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/darwin-x64/develop-94e78eba0430eae97529058c40611e5f24dbf140/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 94e78eb Aug 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.4.0/win32-x64/develop-94e78eba0430eae97529058c40611e5f24dbf140/cypress.tgz

Please sign in to comment.