-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
1,025 additions
and
140 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
public-hoist-pattern[]=*vue* | ||
public-hoist-pattern[]=*nuxt* | ||
public-hoist-pattern[]=defu | ||
public-hoist-pattern[]=ufo | ||
public-hoist-pattern[]=ufo | ||
public-hoist-pattern[]=quasar |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<template> | ||
<div>foo</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import {PropType} from 'vue' | ||
const props = defineProps({}) | ||
const emit = defineEmits([]) | ||
</script> |
This file contains 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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<template> | ||
<Story> | ||
<div> | ||
<span>hello</span> | ||
<foo /> | ||
</div> | ||
</Story> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import {PropType} from 'vue' | ||
import Foo from 'components/Foo.vue' | ||
const props = defineProps({}) | ||
const emit = defineEmits([]) | ||
</script> |
This file contains 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 |
---|---|---|
@@ -1,15 +1,5 @@ | ||
export default { | ||
/** | ||
* Add extend the plugin options under the `chakra` key. | ||
**/ | ||
chakra: { | ||
extendTheme: { | ||
colors: { | ||
brand: { | ||
// | ||
/* ... */ | ||
}, | ||
}, | ||
}, | ||
}, | ||
} | ||
import {defineNuxtConfig} from 'nuxt/config' | ||
export default defineNuxtConfig({ | ||
modules: ['nuxt-quasar-ui'], | ||
// quasar: {}, | ||
}) |
This file contains 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 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 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 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import {defineConfig, getDefaultConfig} from 'histoire' | ||
import {HstVue} from '@histoire/plugin-vue' | ||
|
||
export default defineConfig({ | ||
backgroundPresets: [ | ||
...(getDefaultConfig().backgroundPresets || []), | ||
{ | ||
color: '#cafff5', | ||
contrastColor: '#005142', | ||
label: 'Custom gray', | ||
}, | ||
], | ||
// outDir: 'hdist', | ||
plugins: [HstVue()], | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {defineSetupVue3} from '@histoire/plugin-vue' | ||
import {createPinia} from 'pinia' | ||
|
||
export const setupVue3 = defineSetupVue3(({app}) => { | ||
const pinia = createPinia() | ||
|
||
app.use(pinia) | ||
}) |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "@byte-abc/vite-monorepo-alias", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"vue": "3.3.4" | ||
}, | ||
"scripts": { | ||
"build": "cross-env NODE_ENV=production vite build", | ||
"dev": "cross-env NODE_ENV=dev vite build --watch", | ||
"prepare": "cross-env NODE_ENV=dev vite build", | ||
"type-check": "tsc --noEmit" | ||
}, | ||
"devDependencies": { | ||
"vite": "^4.3.9", | ||
"@types/node": "^20.3.1", | ||
"@vitejs/plugin-vue": "^4.2.3", | ||
"lodash": "^4.17.21", | ||
"vite-plugin-dts": "^2.3.0", | ||
"@vue/test-utils": "^2.3.2" | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
...ges/vite-monorepo-alias/src/change-path-delimiter/__tests__/change-path-delimiter.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {changePathDelimiter} from '../' | ||
import {describe, expect, it} from 'vitest' | ||
|
||
describe('changePathDelimiter', () => { | ||
it('should change the path delimiter', () => { | ||
expect(changePathDelimiter('\\a\\b\\c\\', '\\')).toBe('/a/b/c/') | ||
}) | ||
}) |
7 changes: 7 additions & 0 deletions
7
packages/vite-monorepo-alias/src/change-path-delimiter/index.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const changePathDelimiter = ( | ||
path: string, | ||
delimiter: string, | ||
targetDelimiter: string = '/', | ||
) => { | ||
return path.split(delimiter).join(targetDelimiter) | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/vite-monorepo-alias/src/depub-separator/__tests__/index.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {createDedupSeparator, dedupSeparator} from '../' | ||
import {describe, expect, it} from 'vitest' | ||
|
||
describe('createTrimDupPath', () => { | ||
it('should return the trimmed path', () => { | ||
expect(dedupSeparator('a/b/c/d')).toBe('a/b/c/d') | ||
expect(dedupSeparator('a///b/c/d')).toBe('a/b/c/d') | ||
expect(dedupSeparator('a///b//c/d')).toBe('a/b/c/d') | ||
expect(dedupSeparator('a///b//c/d///')).toBe('a/b/c/d/') | ||
expect(dedupSeparator('///a///b//c/d///')).toBe('/a/b/c/d/') | ||
}) | ||
}) | ||
|
||
describe('createDedupSeparator', () => { | ||
it('should return trimMidPath', () => { | ||
const trimMidPath = createDedupSeparator('.') | ||
expect(trimMidPath('a.b.c.d')).toBe('a.b.c.d') | ||
expect(trimMidPath('a...b.c.d')).toBe('a.b.c.d') | ||
expect(trimMidPath('a..b..c.d')).toBe('a.b.c.d') | ||
expect(trimMidPath('a...b.c.d...')).toBe('a.b.c.d.') | ||
expect(trimMidPath('..a..b..c.d..')).toBe('.a.b.c.d.') | ||
}) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export const createDedupSeparatorRegExp = (pathSeparator: string = '/') => { | ||
return RegExp(`[${pathSeparator}]+`, 'giu') | ||
} | ||
const MAX_URL_LENGTH = 300 | ||
|
||
export const createDedupSeparator = (pathSeparator: string = '/', max: number = MAX_URL_LENGTH) => { | ||
const MID_TRIM_URL_REGX = createDedupSeparatorRegExp(pathSeparator) | ||
return (path: string, replaceValue: string = pathSeparator): string => { | ||
if (process.env.NODE_ENV === 'development' && path.length > max) { | ||
console.warn('please do not pass a string path too long') | ||
} | ||
return path.slice(0, max).replace(MID_TRIM_URL_REGX, replaceValue) | ||
} | ||
} | ||
|
||
/** | ||
* 좌우와 가운데 '/' 패스도 변경 합니다 | ||
* @param path | ||
* @param replaceValue | ||
*/ | ||
export const dedupSeparator = createDedupSeparator() |
This file contains 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './vite-alias' |
26 changes: 26 additions & 0 deletions
26
packages/vite-monorepo-alias/src/resolve-url/__tests__/index.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {createResolveUrl, resolveUrl} from '../' | ||
import {describe, expect, it} from 'vitest' | ||
|
||
describe('createResolveUrl', () => { | ||
it('should return resolveUrl', () => { | ||
const resolveUrl = createResolveUrl() | ||
const url = resolveUrl('/foo', '///bar/', 'john') | ||
expect(url).toBe('foo/bar/john') | ||
}) | ||
it('should return resolveUrl with a custom separator', () => { | ||
const resolveUrl = createResolveUrl('~') | ||
const url = resolveUrl('/foo', '///bar/', 'john') | ||
expect(url).toBe('foo~bar~john') | ||
}) | ||
}) | ||
|
||
describe('resolve-url', () => { | ||
it('should right url', () => { | ||
const url = resolveUrl('/foo', '///bar/', 'john') | ||
expect(url).toBe('foo/bar/john') | ||
}) | ||
it('should resolve', () => { | ||
const url = resolveUrl('foo///bar', '///bar/', 'john') | ||
expect(url).toBe('foo/bar/bar/john') | ||
}) | ||
}) |
This file contains 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import {trimPath} from '../trim-path' | ||
import {dedupSeparator} from '../depub-separator' | ||
|
||
const MAX_URL_LENGTH = 300 | ||
const MAX_URL_COUNT = 100 | ||
|
||
export const createResolveUrl = ( | ||
separator: string = '/', | ||
max: number = MAX_URL_LENGTH, | ||
maxCount: number = MAX_URL_COUNT, | ||
) => { | ||
return (...urls: string[]): string => { | ||
if (process.env.NODE_ENV === 'development' && urls.length > maxCount) { | ||
console.warn('please do not pass string url list too long') | ||
} | ||
const _urls = urls.slice(0, maxCount) | ||
return _urls | ||
.map((url) => { | ||
if (process.env.NODE_ENV === 'development' && url.length > max) { | ||
console.warn('please do not pass a string url too long') | ||
} | ||
const maxedUrl = url.slice(0, max) | ||
return trimPath(dedupSeparator(maxedUrl)) | ||
}) | ||
.join(separator) | ||
} | ||
} | ||
|
||
export const resolveUrl = createResolveUrl() |
11 changes: 11 additions & 0 deletions
11
packages/vite-monorepo-alias/src/split-window-root/__tests__/index.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import {splitWindowRoot} from '../' | ||
import {describe, expect, it} from 'vitest' | ||
|
||
describe('split-window-root', () => { | ||
it('should return path array with window path', () => { | ||
expect(splitWindowRoot('C:\\Users\\foo\\web\\')).toEqual(['C:', '\\Users\\foo\\web\\']) | ||
}) | ||
it('should return path array with path ', () => { | ||
expect(splitWindowRoot('/users/foo/web/')).toEqual([undefined, '/users/foo/web/']) | ||
}) | ||
}) |
10 changes: 10 additions & 0 deletions
10
packages/vite-monorepo-alias/src/split-window-root/index.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const windowRoot = /(?<root>^\w:)(?<restPath>\\.*)/u | ||
export const splitWindowRoot = (path: string): [undefined | string, string] => { | ||
const {root, restPath} = path.match(windowRoot)?.groups ?? {} | ||
|
||
if (!root) { | ||
return [undefined, path] | ||
} | ||
|
||
return [root, restPath] | ||
} |
28 changes: 28 additions & 0 deletions
28
packages/vite-monorepo-alias/src/trim-path/__tests__/index.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import {createTrimPath, trimPath} from '../' | ||
import {describe, expect, it} from 'vitest' | ||
|
||
describe('trimPath', () => { | ||
it('should return trimmed path with both', () => { | ||
expect(trimPath('/foo')).toBe('foo') | ||
expect(trimPath('//foo')).toBe('foo') | ||
expect(trimPath('//foo/')).toBe('foo') | ||
expect(trimPath('foo/')).toBe('foo') | ||
expect(trimPath('foo//')).toBe('foo') | ||
}) | ||
it('should return trimmed path with left', () => { | ||
const trimPath = createTrimPath('/', 1000, 'left') | ||
expect(trimPath('/foo')).toBe('foo') | ||
expect(trimPath('//foo')).toBe('foo') | ||
expect(trimPath('//foo/')).toBe('foo/') | ||
expect(trimPath('foo/')).toBe('foo/') | ||
expect(trimPath('foo//')).toBe('foo//') | ||
}) | ||
it('should return trimmed path with right', () => { | ||
const trimPath = createTrimPath('/', 1000, 'right') | ||
expect(trimPath('/foo')).toBe('/foo') | ||
expect(trimPath('//foo')).toBe('//foo') | ||
expect(trimPath('//foo/')).toBe('//foo') | ||
expect(trimPath('foo/')).toBe('foo') | ||
expect(trimPath('foo//')).toBe('foo') | ||
}) | ||
}) |
Oops, something went wrong.