This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/vue-cli-plugin-vuetify/generator/tools/vuetify.js
2019-08-11 20:48:02 +02:00

64 lines
1.6 KiB
JavaScript

const helpers = require('./helpers')
function addDependencies (api) {
api.extendPackage({
dependencies: {
vuetify: "^2.0.0"
}
})
}
function renderFiles (api, opts) {
const ext = api.hasPlugin('typescript') ? 'ts' : 'js'
const pluginFilename = `vuetify.${ext}`
api.render({
[`./src/plugins/${pluginFilename}`]: '../templates/default/src/plugins/vuetify.js'
}, {
...opts,
typescript: api.hasPlugin('typescript')
})
// Render files if we're replacing
const fs = require('fs')
const routerPath = api.resolve(`./src/router.${ext}`)
opts.router = fs.existsSync(routerPath)
if (opts.replaceComponents) {
const files = {
'./src/App.vue': `../templates/default/src/App.${ext}.vue`,
'./src/assets/logo.svg': '../templates/default/src/assets/logo.svg',
'./src/components/HelloWorld.vue': `../templates/default/src/components/HelloWorld.${ext}.vue`
}
if (opts.router) {
files['./src/views/Home.vue'] = `../templates/default/src/views/Home.${ext}.vue`
}
api.render(files, opts)
}
}
function addImports (api) {
api.injectImports(api.entryFile, `import vuetify from './plugins/vuetify';`)
api.injectRootOptions(api.entryFile, 'vuetify')
}
function setHtmlLang (api, locale) {
helpers.updateFile(api, './public/index.html', lines => {
const htmlIndex = lines.findIndex(line => line.match(/<html\s+(.+\s+)?lang=[^\s>]+(\s|>)/))
if (htmlIndex !== -1) {
lines[htmlIndex] = lines[htmlIndex].replace(/(<html\s+(.+\s+)?)(lang=)([^\s>]+)(\s|>)/, `$1$3"${locale}"$5`)
}
return lines
})
}
module.exports = {
addDependencies,
addImports,
renderFiles,
setHtmlLang,
}