Skip to content

Commit

Permalink
refactor(init): supported stacks and features
Browse files Browse the repository at this point in the history
  • Loading branch information
Ni55aN committed Dec 22, 2023
1 parent a16968f commit 69e796f
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
34 changes: 1 addition & 33 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,12 @@ import { join, dirname, resolve } from 'path'
import { App } from 'rete-kit'
import { appsCachePath, projects } from './consts'
import { log } from './ui'
import { fixtures, getFeatures, stackNames, validate } from './init'

const program = createCommand()

program.version(require('../package.json').version)

const targets: { stack: App.AppStack, versions: number[] }[] = [
{ stack: 'react', versions: [16, 17, 18] },
{ stack: 'vue', versions: [2, 3] },
{ stack: 'angular', versions: [12, 13, 14, 15, 16, 17] },
{ stack: 'svelte', versions: [3, 4] }
]
const stackNames = targets.map(t => t.stack)

const fixtures = targets
.map(({ stack, versions }) => versions.map(version => ({ stack, version, folder: `${stack}${version}` as const })))
.flat()
.map(({ stack, version, folder }) => ({
stack,
version,
folder
}))

function getFeatures({ stack, version }: (typeof fixtures)[0], next: boolean) {
return [
stack === 'angular' && new App.Features.Angular(version as 12 | 13 | 14 | 15, next),
stack === 'react' && new App.Features.React(version, stack, next),
stack === 'vue' && new App.Features.Vue(version as 2 | 3, next),
stack === 'svelte' && new App.Features.Svelte(version as 3 | 4, next),
new App.Features.ZoomAt(),
new App.Features.OrderNodes(),
new App.Features.Dataflow(next),
new App.Features.Selectable(),
new App.Features.Minimap(next),
new App.Features.Reroute(next)
]
}


program
.command('init')
.description(`Initialize testing tool`)
Expand Down
34 changes: 34 additions & 0 deletions src/init/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { App } from 'rete-kit'

export const targets: { stack: App.AppStack, versions: number[] }[] = [
{ stack: 'react', versions: [16, 17, 18] },
{ stack: 'vue', versions: [2, 3] },
{ stack: 'angular', versions: [12, 13, 14, 15, 16, 17] },
{ stack: 'svelte', versions: [3, 4] }
]
export const stackNames = targets.map(t => t.stack)

export const fixtures = targets
.map(({ stack, versions }) => versions.map(version => ({ stack, version, folder: `${stack}${version}` as const })))
.flat()
.map(({ stack, version, folder }) => ({
stack,
version,
folder
}))

export function getFeatures({ stack, version }: (typeof fixtures)[0], next: boolean) {
return [
stack === 'angular' && new App.Features.Angular(version as 12 | 13 | 14 | 15, next),
stack === 'react' && new App.Features.React(version, stack, next),
stack === 'vue' && new App.Features.Vue(version as 2 | 3, next),
stack === 'svelte' && new App.Features.Svelte(version as 3 | 4, next),
new App.Features.ZoomAt(),
new App.Features.OrderNodes(),
new App.Features.Dataflow(next),
new App.Features.Selectable(),
new App.Features.Minimap(next),
new App.Features.Reroute(next)
]
}

0 comments on commit 69e796f

Please sign in to comment.