Skip to content

Commit

Permalink
Merge pull request #6 from doox911-opensource/dev
Browse files Browse the repository at this point in the history
feat: ✨ Move store-flag.d.ts to shared
  • Loading branch information
doox911-opensource authored Feb 4, 2024
2 parents 3d57b24 + 5e44997 commit f72c7a7
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"editor.formatOnSave": true,
"[javascript]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[javascriptreact]": {
"editor.defaultFormatter": "dprint.dprint"
},
"[typescript]": {
"editor.defaultFormatter": "dprint.dprint"
},
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ See [dprint repository](https://github.com/dprint/dprint) or [site](https://dpri
### Customize the configuration

See [Configuring quasar.config.js](https://v2.quasar.dev/quasar-cli-vite/quasar-config-js).

**Attention!**

> The file `/src/app/store-flag.d.ts` is automatically moved to the directory `/src/shared/types/store-flag.d.ts`
> To disable this, comment out `fsdFix()` in `quasar.config.js`
12 changes: 12 additions & 0 deletions config/fsd/fsdFix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const { moveStoreFlagsToShared } = require('./move-store-flags-to-shared')

function fsdFix() {
/**
* This is necessary because Quasar does not provide
* the ability to specify the location of the - store-flag.d.ts
* file generation in the project
*/
moveStoreFlagsToShared()
}

module.exports = fsdFix
54 changes: 54 additions & 0 deletions config/fsd/move-store-flags-to-shared.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const fs = require('fs')

const path = require('path')

const { black, red, green, bgRed, bgGreen, lightCyan } = require('kolorist')

const ROOT = path.resolve(__dirname, '../../')

function moveStoreFlagsToShared() {
const name = 'store-flag.d.ts'

const currentDir = '/src/app'

const newDir = '/src/shared/types'

const dts = path.join(ROOT, `${currentDir}/${name}`)

fs.stat(dts, e => {
if (e) return
fs.copyFile(dts, path.join(ROOT, `${newDir}/${name}`), (e) => {
if (e) {
console.log(
`${red(' App •')} ${bgRed(black(' FSD FIX '))} ${red('•')} File ${
lightCyan(`.${currentDir}/${name}`)
} was not copied (see: quasar.config.js)`,
)
} else {
console.log(
`${green(' App •')} ${bgGreen(black(' FSD FIX '))} ${green('•')} File ${
lightCyan(`.${currentDir}/${name}`)
} was copied to ${lightCyan(`.${newDir}/${name}`)})} (see: quasar.config.js)`,
)

fs.unlink(dts, (e) => {
if (e) {
console.log(
`${red(' App •')} ${bgRed(black(' FSD FIX '))} ${red('•')} File ${
lightCyan(`.${currentDir}/${name}`)
} was deleted (see: quasar.config.js)`,
)
}

console.log(
`${green(' App •')} ${bgGreen(black(' FSD FIX '))} ${green('•')} File ${
lightCyan(`.${currentDir}/${name}`)
} was deleted (see: quasar.config.js)`,
)
})
}
})
})
}

module.exports = { moveStoreFlagsToShared }
1 change: 1 addition & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { fsdFix: require('./fsd/fsdFix') }
3 changes: 2 additions & 1 deletion dprint.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"excludes": [
"**/node_modules",
"**/*-lock.json"
"**/*-lock.json",
"**/*-flag.d.ts"
],
"plugins": [
"https://plugins.dprint.dev/typescript-0.88.10.wasm",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"eslint-plugin-n": "^15.0.0",
"eslint-plugin-promise": "^6.0.0",
"eslint-plugin-vue": "^9.0.0",
"kolorist": "^1.8.0",
"typescript": "^4.5.4"
},
"engines": {
Expand Down
7 changes: 6 additions & 1 deletion quasar.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js

const { configure } = require('quasar/wrappers')

const { fsdFix } = require('./config')

const path = require('path')

module.exports = configure(function(/* ctx */) {
Expand Down Expand Up @@ -82,7 +85,9 @@ module.exports = configure(function(/* ctx */) {
// polyfillModulePreload: true,
// distDir

// extendViteConf (viteConf) {},
extendViteConf() {
fsdFix()
},
// viteVuePluginOptions: {},

vitePlugins: [
Expand Down
6 changes: 3 additions & 3 deletions src/app/store-flag.d.ts → src/shared/types/store-flag.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* eslint-disable */
// THIS FEATURE-FLAG FILE IS AUTOGENERATED,
// REMOVAL OR CHANGES WILL CAUSE RELATED TYPES TO STOP WORKING
import 'quasar/dist/types/feature-flag'
import "quasar/dist/types/feature-flag";

declare module 'quasar/dist/types/feature-flag' {
declare module "quasar/dist/types/feature-flag" {
interface QuasarFeatureFlags {
store: true
store: true;
}
}
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2548,7 +2548,7 @@ kind-of@^6.0.2:
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd"
integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==

kolorist@^1.5.1:
kolorist@^1.5.1, kolorist@^1.8.0:
version "1.8.0"
resolved "https://registry.yarnpkg.com/kolorist/-/kolorist-1.8.0.tgz#edddbbbc7894bc13302cdf740af6374d4a04743c"
integrity sha512-Y+60/zizpJ3HRH8DCss+q95yr6145JXZo46OTpFvDZWLfRCE4qChOyk1b26nMaNpfHHgxagk9dXT5OP0Tfe+dQ==
Expand Down

0 comments on commit f72c7a7

Please sign in to comment.