This repository was archived by the owner on May 8, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 113
task(helpers): Abstract helpers and remove duplicates #226
Draft
ElijahKotyluk
wants to merge
15
commits into
master
Choose a base branch
from
task/224-utils
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 6 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
809cfba
refactor(helpers): remove repetetive update file helper function
ElijahKotyluk 145624a
improvement(utils): add update babel config function to utils package
ElijahKotyluk 133ad08
improvement(utils): add addimport and addimports functions to utils p…
ElijahKotyluk 273e2c0
fix(utils): remove unique helpers
ElijahKotyluk 6d3e845
refactor(plugin-utils): replace duplicate code with fileExists util
ElijahKotyluk 3824ed5
improvement(plugin-utils): add resolve function to utils package
ElijahKotyluk 75574ae
Update packages/@vuetify/cli-plugin-utils/index.js
ElijahKotyluk 37291a1
Update packages/vue-cli-plugin-vuetify/generator/tools/fonts.js
ElijahKotyluk 4f29944
Update packages/vue-cli-plugin-vuetify/generator/tools/polyfill.js
ElijahKotyluk 27851bd
Update packages/vue-cli-plugin-vuetify/generator/tools/polyfill.js
ElijahKotyluk 78c7759
Update packages/vue-cli-plugin-vuetify/generator/tools/vuetify.js
ElijahKotyluk be101a8
Update packages/vue-cli-plugin-vuetify/generator/tools/vuetify.js
ElijahKotyluk 11553e0
improvement(plugin-utils): add parseFile util function
ElijahKotyluk a70d4e9
refactor(plugin-utils): parsefile: add description comment
ElijahKotyluk 0f5933d
chore(merge): into local
ElijahKotyluk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,7 @@ function generatePreset (api, preset, onCreateComplete) { | |
const file = 'src/plugins/vuetify.js' | ||
const plugin = api.resolve(file) | ||
|
||
if (!fs.existsSync(plugin)) { | ||
if (!fileExists(api, plugin)) { | ||
console.warn('Unable to locate `vuetify.js` plugin file in `src/plugins`.') | ||
|
||
return | ||
|
@@ -104,11 +104,49 @@ function mergeSassVariables (opt, file) { | |
return opt | ||
} | ||
|
||
// Resolve the supplied file | ||
function resolve(file) { | ||
return path.resolve(__dirname, file); | ||
} | ||
|
||
// Update Babel config file with supplied callback | ||
function updateBabelConfig(api, callback) { | ||
let config, configPath; | ||
|
||
const rcPath = api.resolve("./babel.config.js"); | ||
const pkgPath = api.resolve("./package.json"); | ||
if (fileExists(api, rcPath)) { | ||
configPath = rcPath; | ||
config = callback(require(rcPath)); | ||
} else if (fileExists(api, pkgPath)) { | ||
configPath = pkgPath; | ||
config = JSON.parse(fs.readFileSync(pkgPath, { encoding: "utf8" })); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like it would be reused a lot, maybe can go into utils? |
||
|
||
if (config.babel) { | ||
config.babel = callback(config.babel); | ||
} else { | ||
// TODO: error handling here? | ||
} | ||
} | ||
|
||
if (configPath) { | ||
const moduleExports = configPath !== pkgPath ? "module.exports = " : ""; | ||
|
||
fs.writeFileSync( | ||
configPath, | ||
`${moduleExports}${JSON.stringify(config, null, 2)}`, | ||
{ encoding: "utf8" } | ||
); | ||
} else { | ||
// TODO: handle if babel config doesn't exist | ||
} | ||
} | ||
|
||
// Update local file with supplied callback | ||
function updateFile (api, file, callback) { | ||
const { EOL } = require('os') | ||
file = api.resolve(file) | ||
let content = fs.existsSync(file) | ||
let content = fileExists(api, file) | ||
? fs.readFileSync(file, { encoding: 'utf8' }) | ||
: '' | ||
|
||
|
@@ -189,6 +227,8 @@ module.exports = { | |
injectHtmlLink, | ||
injectSassVariables, | ||
mergeSassVariables, | ||
resolve, | ||
updateBabelConfig, | ||
updateFile, | ||
updateVuetifyObject, | ||
VuetifyPresetGenerator, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.