Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove unused codeGenGlobs #21438

Merged
merged 5 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions packages/app/src/specs/CreateSpecModal.cy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ describe('<CreateSpecModal />', () => {
gql={{
currentProject: {
id: 'id',
codeGenGlobs: {
id: 'super-unique-id',
__typename: 'CodeGenGlobs',
component: '**.vue',
},
currentTestingType: 'component',
configFile: 'cypress.config.js',
configFileAbsolutePath: '/path/to/cypress.config.js',
Expand Down Expand Up @@ -79,11 +74,6 @@ describe('playground', () => {
gql={{
currentProject: {
id: 'id',
codeGenGlobs: {
id: 'super-unique-id',
__typename: 'CodeGenGlobs',
component: '**.vue',
},
currentTestingType: 'component',
configFile: 'cypress.config.js',
configFileAbsolutePath: '/path/to/cypress.config.js',
Expand Down
13 changes: 0 additions & 13 deletions packages/app/src/specs/CreateSpecModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
v-if="generator"
:key="`${generator.id}-${iteration}`"
v-model:title="title"
:code-gen-glob="codeGenGlob"
:gql="props.gql.currentProject"
:type="props.gql.currentProject?.currentTestingType"
:spec-file-name="specFileName"
Expand Down Expand Up @@ -78,10 +77,6 @@ fragment CreateSpecModal on Query {
id
fileExtensionToUse
defaultSpecFileName
codeGenGlobs {
id
component
}
...EmptyGenerator
}
}
Expand Down Expand Up @@ -114,14 +109,6 @@ const specFileName = computed(() => {
return getPathForPlatform(fileName)
})

const codeGenGlob = computed(() => {
if (!generator.value) {
return null
}

return props.gql.currentProject?.codeGenGlobs[generator.value.id]
})

const filteredGenerators = getFilteredGeneratorList(props.gql.currentProject?.currentTestingType)

const singleGenerator = computed(() => filteredGenerators.value.length === 1 ? filteredGenerators.value[0] : null)
Expand Down
1 change: 0 additions & 1 deletion packages/data-context/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"@urql/exchange-graphcache": "4.3.6",
"chokidar": "3.5.1",
"common-path-prefix": "3.0.0",
"create-cypress-tests": "0.0.0-development",
"cross-fetch": "^3.1.4",
"dataloader": "^2.0.0",
"dayjs": "^1.9.3",
Expand Down
27 changes: 0 additions & 27 deletions packages/data-context/src/sources/ProjectDataSource.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import os from 'os'
import chokidar from 'chokidar'
import type { ResolvedFromConfig, RESOLVED_FROM, FoundSpec, TestingType } from '@packages/types'
import { WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
import { scanFSForAvailableDependency } from 'create-cypress-tests'
import minimatch from 'minimatch'
import { debounce, isEqual } from 'lodash'
import path from 'path'
Expand Down Expand Up @@ -365,31 +363,6 @@ export class ProjectDataSource {
return preferences[projectTitle] ?? null
}

private guessFramework (projectRoot: string) {
const guess = WIZARD_FRAMEWORKS.find((framework) => {
const lookingForDeps = framework.detectors.map((x) => x.package).reduce(
(acc, dep) => ({ ...acc, [dep]: '*' }),
{},
)

return scanFSForAvailableDependency(projectRoot, lookingForDeps)
})

return guess ?? null
}

async getCodeGenGlobs () {
assert(this.ctx.currentProject, `Cannot find glob without currentProject.`)

const looseComponentGlob = '*.{js,jsx,ts,tsx,.vue}'

const framework = this.guessFramework(this.ctx.currentProject)

return {
component: framework?.glob ?? looseComponentGlob,
}
}

async getResolvedConfigFields (): Promise<ResolvedFromConfig[]> {
const config = this.ctx.lifecycleManager.loadedFullConfig?.resolved ?? {}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { parse } from '@babel/parser'
import { WIZARD_FRAMEWORKS } from '@packages/scaffold-config'
import { expect } from 'chai'
import dedent from 'dedent'
import fs from 'fs-extra'
import path from 'path'
import sinon from 'sinon'
import { DataContext } from '../../../src'
import {
Action, codeGenerator, CodeGenResult, CodeGenResults,
Expand Down Expand Up @@ -221,9 +219,6 @@ describe('code-generator', () => {
target,
}

// @ts-ignore
sinon.stub(ctx.project, 'guessFramework').returns(WIZARD_FRAMEWORKS[0])

const newSpecCodeGenOptions = new SpecOptions(ctx, {
codeGenPath: path.join(__dirname, 'files', 'react', 'Button.jsx'),
codeGenType: 'component',
Expand All @@ -244,9 +239,6 @@ describe('code-generator', () => {
target,
}

// @ts-ignore
sinon.stub(ctx.project, 'guessFramework').returns(WIZARD_FRAMEWORKS[1])

const newSpecCodeGenOptions = new SpecOptions(ctx, {
codeGenPath: path.join(__dirname, 'files', 'vue', 'Button.vue'),
codeGenType: 'component',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@ export const createTestCurrentProject = (title: string, currentProject: Partial<
],
config,
cloudProject: CloudProjectStubs.componentProject,
codeGenGlobs: {
id: 'super-unique-id',
__typename: 'CodeGenGlobs',
component: '**/*.vue',
},
activeBrowser: stubBrowsers[0],
browsers: stubBrowsers,
isDefaultSpecPattern: true,
Expand Down
9 changes: 0 additions & 9 deletions packages/graphql/schemas/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -357,14 +357,6 @@ type CodeFrame {
line: Int
}

"""Glob patterns for detecting files for code gen."""
type CodeGenGlobs implements Node {
component: String!

"""Relay style Node ID field for the CodeGenGlobs field"""
id: ID!
}

enum CodeGenType {
component
e2e
Expand Down Expand Up @@ -397,7 +389,6 @@ type CurrentProject implements Node & ProjectLike {

"""List of all code generation candidates stories"""
codeGenCandidates(glob: String!): [FileParts]
codeGenGlobs: CodeGenGlobs!

"""Project configuration"""
config: JSON!
Expand Down
10 changes: 0 additions & 10 deletions packages/graphql/src/schemaTypes/objectTypes/gql-CodeGenGlobs.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import path from 'path'
import { BrowserStatusEnum, FileExtensionEnum } from '..'
import { TestingTypeEnum } from '../enumTypes/gql-WizardEnums'
import { Browser } from './gql-Browser'
import { CodeGenGlobs } from './gql-CodeGenGlobs'
import { FileParts } from './gql-FileParts'
import { ProjectPreferences } from './gql-ProjectPreferences'
import { Spec } from './gql-Spec'
Expand Down Expand Up @@ -194,11 +193,6 @@ export const CurrentProject = objectType({
},
})

t.nonNull.field('codeGenGlobs', {
type: CodeGenGlobs,
resolve: (src, args, ctx) => ctx.project.getCodeGenGlobs(),
})

t.list.field('codeGenCandidates', {
type: FileParts,
description: 'List of all code generation candidates stories',
Expand Down
1 change: 0 additions & 1 deletion packages/graphql/src/schemaTypes/objectTypes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * from './gql-AuthState'
export * from './gql-Browser'
export * from './gql-CachedUser'
export * from './gql-CodeFrame'
export * from './gql-CodeGenGlobs'
export * from './gql-CurrentProject'
export * from './gql-DevState'
export * from './gql-Editor'
Expand Down
8 changes: 0 additions & 8 deletions packages/scaffold-config/src/frameworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'react',
glob: '*.{js,jsx,tsx}',
mountModule: 'cypress/react',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand All @@ -93,7 +92,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'vue',
glob: '*.vue',
mountModule: 'cypress/vue2',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand All @@ -113,7 +111,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'vue',
glob: '*.vue',
mountModule: 'cypress/vue',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand All @@ -132,7 +129,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'react',
glob: '*.{js,jsx,tsx}',
mountModule: 'cypress/react',
supportStatus: 'alpha',
componentIndexHtml: componentIndexHtmlGenerator('<div id="__next_css__DO_NOT_USE__"></div>'),
Expand All @@ -151,7 +147,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'vue',
glob: '*.vue',
mountModule: 'cypress/vue2',
supportStatus: 'alpha',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand All @@ -170,7 +165,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'vue',
glob: '*.vue',
mountModule: 'cypress/vue2',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand All @@ -189,7 +183,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'vue',
glob: '*.vue',
mountModule: 'cypress/vue',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand All @@ -208,7 +201,6 @@ export const WIZARD_FRAMEWORKS = [
]
},
codeGenFramework: 'react',
glob: '*.{js,jsx,tsx}',
mountModule: 'cypress/react',
supportStatus: 'full',
componentIndexHtml: componentIndexHtmlGenerator(),
Expand Down