refactor: determine framework based on project info
This commit is contained in:
parent
b55573ac4d
commit
b271e1e8df
|
|
@ -5,6 +5,7 @@ import { consola } from 'consola'
|
||||||
import { colors } from 'consola/utils'
|
import { colors } from 'consola/utils'
|
||||||
import { Command } from 'commander'
|
import { Command } from 'commander'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
import { getProjectInfo } from '../utils/get-project-info'
|
||||||
import frameworksCommands from './frameworks'
|
import frameworksCommands from './frameworks'
|
||||||
import { handleError } from '@/src/utils/handle-error'
|
import { handleError } from '@/src/utils/handle-error'
|
||||||
|
|
||||||
|
|
@ -45,8 +46,8 @@ export const add = new Command()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the corresponding framework commands
|
// Get the corresponding framework commands
|
||||||
// TODO: Pass this to action inside a `context` argument to the function
|
const { isNuxt } = await getProjectInfo()
|
||||||
const framework = 'vue'
|
const framework = isNuxt ? 'nuxt' : 'vue'
|
||||||
const { loadConfig, add } = frameworksCommands[framework]
|
const { loadConfig, add } = frameworksCommands[framework]
|
||||||
|
|
||||||
// Read config
|
// Read config
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import { consola } from 'consola'
|
||||||
import { colors } from 'consola/utils'
|
import { colors } from 'consola/utils'
|
||||||
import { Command } from 'commander'
|
import { Command } from 'commander'
|
||||||
import { z } from 'zod'
|
import { z } from 'zod'
|
||||||
|
import { getProjectInfo } from '../utils/get-project-info'
|
||||||
import frameworksCommands from './frameworks'
|
import frameworksCommands from './frameworks'
|
||||||
import { handleError } from '@/src/utils/handle-error'
|
import { handleError } from '@/src/utils/handle-error'
|
||||||
|
|
||||||
|
|
@ -40,8 +41,8 @@ export const diff = new Command()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the corresponding framework commands
|
// Get the corresponding framework commands
|
||||||
// TODO: Pass this to action inside a `context` argument to the function
|
const { isNuxt } = await getProjectInfo()
|
||||||
const framework = 'vue'
|
const framework = isNuxt ? 'nuxt' : 'vue'
|
||||||
const { loadConfig, diff } = frameworksCommands[framework]
|
const { loadConfig, diff } = frameworksCommands[framework]
|
||||||
|
|
||||||
// Load Config
|
// Load Config
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,12 @@ export default {
|
||||||
add: addVue,
|
add: addVue,
|
||||||
diff: diffVue,
|
diff: diffVue,
|
||||||
},
|
},
|
||||||
|
// For now we run the same commands for Nuxt as for Vue
|
||||||
|
// TODO: replace with Nuxt-specific commands when required
|
||||||
|
nuxt: {
|
||||||
|
loadConfig: loadConfigVue,
|
||||||
|
init: initVue,
|
||||||
|
add: addVue,
|
||||||
|
diff: diffVue,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import { z } from 'zod'
|
||||||
import { consola } from 'consola'
|
import { consola } from 'consola'
|
||||||
import { colors } from 'consola/utils'
|
import { colors } from 'consola/utils'
|
||||||
import { handleError } from '../utils/handle-error'
|
import { handleError } from '../utils/handle-error'
|
||||||
|
import { getProjectInfo } from '../utils/get-project-info'
|
||||||
import frameworksCommands from './frameworks'
|
import frameworksCommands from './frameworks'
|
||||||
|
|
||||||
const initOptionsSchema = z.object({
|
const initOptionsSchema = z.object({
|
||||||
|
|
@ -34,8 +35,8 @@ export const init = new Command()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the corresponding framework commands
|
// Get the corresponding framework commands
|
||||||
// TODO: Pass this to action inside a `context` argument to the function
|
const { isNuxt } = await getProjectInfo()
|
||||||
const framework = 'vue'
|
const framework = isNuxt ? 'nuxt' : 'vue'
|
||||||
const { loadConfig, init } = frameworksCommands[framework]
|
const { loadConfig, init } = frameworksCommands[framework]
|
||||||
|
|
||||||
// Read config
|
// Read config
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user