Skip to content

Commit a7b140d

Browse files
authored
feat: add angular-ct project setup (#22897)
1 parent aedb1e9 commit a7b140d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+14022
-76
lines changed

packages/config/src/ast-utils/astConfigHelpers.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface ASTComponentDefinitionConfig {
2828
testingType: 'component'
2929
bundler: 'vite' | 'webpack'
3030
framework?: string
31+
specPattern?: string
3132
}
3233

3334
/**
@@ -41,15 +42,18 @@ export interface ASTComponentDefinitionConfig {
4142
* }
4243
*/
4344
export function addComponentDefinition (config: ASTComponentDefinitionConfig): t.ObjectProperty {
44-
return extractProperty(`
45-
const toMerge = {
46-
component: {
47-
devServer: {
48-
framework: ${config.framework ? `'${config.framework}'` : 'undefined'},
49-
bundler: '${config.bundler}',
50-
},
45+
const componentConfig = JSON.stringify({
46+
component: {
47+
devServer: {
48+
framework: config.framework,
49+
bundler: config.bundler,
5150
},
52-
}
51+
specPattern: config.specPattern,
52+
},
53+
}, null, 2)
54+
55+
return extractProperty(`
56+
const toMerge = ${componentConfig}
5357
`)
5458
}
5559

packages/data-context/src/actions/WizardActions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NexusGenObjects } from '@packages/graphql/src/gen/nxs.gen'
2-
import { detectFramework, WIZARD_FRAMEWORKS, WIZARD_BUNDLERS, commandsFileBody, supportFileComponent, supportFileE2E } from '@packages/scaffold-config'
2+
import { detectFramework, WIZARD_FRAMEWORKS, commandsFileBody, supportFileComponent, supportFileE2E, WizardBundler, WizardFrontendFramework } from '@packages/scaffold-config'
33
import assert from 'assert'
44
import path from 'path'
55
import Debug from 'debug'
@@ -23,7 +23,7 @@ export class WizardActions {
2323
return this.ctx.wizardData
2424
}
2525

26-
setFramework (framework: typeof WIZARD_FRAMEWORKS[number] | null): void {
26+
setFramework (framework: WizardFrontendFramework | null): void {
2727
const next = WIZARD_FRAMEWORKS.find((x) => x.type === framework?.type)
2828

2929
this.ctx.update((coreData) => {
@@ -51,7 +51,7 @@ export class WizardActions {
5151
}
5252
}
5353

54-
setBundler (bundler: typeof WIZARD_BUNDLERS[number] | null) {
54+
setBundler (bundler: WizardBundler | null) {
5555
this.ctx.update((coreData) => {
5656
coreData.wizard.chosenBundler = bundler
5757
})
@@ -227,6 +227,7 @@ export class WizardActions {
227227
testingType: 'component',
228228
bundler: this.ctx.coreData.wizard.chosenBundler?.package ?? 'webpack',
229229
framework: this.ctx.coreData.wizard.chosenFramework?.configFramework,
230+
specPattern: this.ctx.coreData.wizard.chosenFramework?.specPattern,
230231
}
231232

232233
const result = await addTestingTypeToCypressConfig({
@@ -292,7 +293,7 @@ export class WizardActions {
292293
}
293294
}
294295

295-
private async scaffoldComponentIndexHtml (chosenFramework: typeof WIZARD_FRAMEWORKS[number]): Promise<NexusGenObjects['ScaffoldedFile']> {
296+
private async scaffoldComponentIndexHtml (chosenFramework: WizardFrontendFramework): Promise<NexusGenObjects['ScaffoldedFile']> {
296297
const componentIndexHtmlPath = path.join(this.projectRoot, 'cypress', 'support', 'component-index.html')
297298

298299
await this.ensureDir('support')

packages/data-context/src/data/coreDataShape.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { FoundBrowser, Editor, AllowedState, AllModeOptions, TestingType, BrowserStatus, PACKAGE_MANAGERS, AuthStateName, MIGRATION_STEPS, MigrationStep } from '@packages/types'
2-
import type { WIZARD_BUNDLERS, WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
2+
import type { WizardFrontendFramework, WizardBundler } from '@packages/scaffold-config'
33
import type { NexusGenObjects } from '@packages/graphql/src/gen/nxs.gen'
44
import type { App, BrowserWindow } from 'electron'
55
import type { ChildProcess } from 'child_process'
@@ -63,11 +63,11 @@ export interface AppDataShape {
6363
}
6464

6565
export interface WizardDataShape {
66-
chosenBundler: typeof WIZARD_BUNDLERS[number] | null
67-
chosenFramework: typeof WIZARD_FRAMEWORKS[number] | null
66+
chosenBundler: WizardBundler | null
67+
chosenFramework: WizardFrontendFramework | null
6868
chosenManualInstall: boolean
69-
detectedBundler: typeof WIZARD_BUNDLERS[number] | null
70-
detectedFramework: typeof WIZARD_FRAMEWORKS[number] | null
69+
detectedBundler: WizardBundler | null
70+
detectedFramework: WizardFrontendFramework | null
7171
}
7272

7373
export interface MigrationDataShape {

packages/data-context/test/unit/sources/WizardDataSource.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { WIZARD_BUNDLERS, WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
1+
import { WizardBundler, WizardFrontendFramework, WIZARD_BUNDLERS, WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
22
import { expect } from 'chai'
33
import { createTestDataContext, scaffoldMigrationProject, removeCommonNodeModules } from '../helper'
44

5-
function findFramework (type: typeof WIZARD_FRAMEWORKS[number]['type']) {
5+
function findFramework (type: WizardFrontendFramework['type']) {
66
return WIZARD_FRAMEWORKS.find((x) => x.type === type)!
77
}
88

9-
function findBundler (type: typeof WIZARD_BUNDLERS[number]['type']) {
9+
function findBundler (type: WizardBundler['type']) {
1010
return WIZARD_BUNDLERS.find((x) => x.type === type)!
1111
}
1212

@@ -149,8 +149,8 @@ describe('packagesToInstall', () => {
149149
ctx.update((coreData) => {
150150
// this should never happen!
151151
coreData.currentProject = projectPath
152-
coreData.wizard.chosenFramework = undefined
153-
coreData.wizard.chosenBundler = undefined
152+
coreData.wizard.chosenFramework = null
153+
coreData.wizard.chosenBundler = null
154154
})
155155

156156
const actual = ctx.wizard.installDependenciesCommand()

packages/graphql/schemas/schema.graphql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ type FileParts implements Node {
870870
}
871871

872872
enum FrontendFrameworkEnum {
873+
angular
873874
nextjs
874875
nuxtjs
875876
react

packages/launchpad/cypress/e2e/scaffold-component-testing.cy.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,17 @@ describe('scaffolding component testing', {
107107
verifyConfigFile(`cypress.config.js`)
108108
})
109109
})
110+
111+
context('angular-cli-unconfigured', () => {
112+
it('scaffolds component testing for Angular', () => {
113+
startSetupFor('angular-cli-unconfigured')
114+
115+
// should detect correctly
116+
// Screen reader text is "Support is in", but don't want to rely on DOM introduced whitespace so using regex
117+
cy.contains('button', 'Angular(detected)').should('be.visible')
118+
cy.contains('button', 'Next Step').click()
119+
cy.findByRole('button', { name: 'Continue' }).click()
120+
verifyConfigFile(`cypress.config.ts`)
121+
})
122+
})
110123
})

packages/launchpad/cypress/e2e/scaffold-project.cy.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
1+
import type { WizardFrontendFramework } from '@packages/scaffold-config'
22
import type { SnapshotScaffoldTestResult } from '@packages/launchpad/cypress/tasks/snapshotsScaffold'
33

44
// The tests in this file take an existing project without Cypress Configured
@@ -55,8 +55,8 @@ function scaffoldAndOpenE2EProject (opts: {
5555

5656
function scaffoldAndOpenCTProject (opts: {
5757
name: Parameters<typeof cy.scaffoldProject>[0]
58-
framework: typeof WIZARD_FRAMEWORKS[number]['name']
59-
bundler?: typeof WIZARD_FRAMEWORKS[number]['supportedBundlers'][number]['name']
58+
framework: WizardFrontendFramework['name']
59+
bundler?: WizardFrontendFramework['supportedBundlers'][number]['name']
6060
args?: Parameters<typeof cy.openProject>[1]
6161
removeFixturesFolder?: boolean
6262
}) {
Lines changed: 15 additions & 0 deletions
Loading

packages/launchpad/src/utils/icons.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import LogoNext from '../images/logos/nextjs.svg'
44
import LogoNuxt from '../images/logos/nuxt.svg'
55
import LogoVue from '../images/logos/vue.svg'
66
import LogoReact from '../images/logos/react.svg'
7+
import LogoAngular from '../images/logos/angular.svg'
78

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

@@ -18,4 +19,5 @@ export const FrameworkBundlerLogos: Record<FrontendFrameworkEnum | SupportedBund
1819
nuxtjs: LogoNuxt,
1920
react: LogoReact,
2021
reactscripts: LogoReact,
22+
angular: LogoAngular,
2123
}

packages/launchpad/src/utils/logos.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)