my-gadgetry 1.3.2 → 1.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -15
- package/color/package.json +2 -2
- package/converters/array/package.json +2 -2
- package/converters/number/package.json +2 -2
- package/converters/string/package.json +2 -2
- package/dev-ops/package-generator/generate-alias/package.json +2 -2
- package/dist/{_core → lib/_core}/fs.d.ts +1 -0
- package/dist/lib/_core/fs.d.ts.map +1 -0
- package/dist/{_core → lib/_core}/type-check.d.ts +1 -0
- package/dist/lib/_core/type-check.d.ts.map +1 -0
- package/dist/{_core → lib/_core}/type-check.js +11 -6
- package/dist/{_core → lib/_core}/types/utilities.d.ts +1 -0
- package/dist/lib/_core/types/utilities.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/color.d.ts +1 -0
- package/dist/lib/_internal/color.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/converters/array.d.ts +1 -0
- package/dist/lib/_internal/converters/array.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/converters/number.d.ts +1 -0
- package/dist/lib/_internal/converters/number.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/converters/string.d.ts +1 -0
- package/dist/lib/_internal/converters/string.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/converters/string.js +2 -0
- package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/clean-directories.d.ts +1 -0
- package/dist/lib/_internal/dev-ops/package-generator/generate-alias/clean-directories.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/get-aliases.d.ts +1 -0
- package/dist/lib/_internal/dev-ops/package-generator/generate-alias/get-aliases.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/write-package-json.d.ts +1 -0
- package/dist/lib/_internal/dev-ops/package-generator/generate-alias/write-package-json.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias.d.ts +1 -0
- package/dist/lib/_internal/dev-ops/package-generator/generate-alias.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/fs.d.ts +1 -0
- package/dist/lib/_internal/fs.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/type-check.d.ts +1 -0
- package/dist/lib/_internal/type-check.d.ts.map +1 -0
- package/dist/{_internal → lib/_internal}/types/utilities.d.ts +1 -0
- package/dist/lib/_internal/types/utilities.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/color.d.ts +1 -0
- package/dist/lib/modules/color.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/converters/array.d.ts +1 -0
- package/dist/lib/modules/converters/array.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/converters/number.d.ts +1 -0
- package/dist/lib/modules/converters/number.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/converters/string.d.ts +1 -0
- package/dist/lib/modules/converters/string.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/dev-ops/package-generator/generate-alias.d.ts +1 -0
- package/dist/lib/modules/dev-ops/package-generator/generate-alias.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/fs.d.ts +1 -0
- package/dist/lib/modules/fs.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/type-check.d.ts +1 -0
- package/dist/lib/modules/type-check.d.ts.map +1 -0
- package/dist/{modules → lib/modules}/types/utilities.d.ts +1 -0
- package/dist/lib/modules/types/utilities.d.ts.map +1 -0
- package/fs/package.json +2 -2
- package/package.json +29 -97
- package/type-check/package.json +2 -2
- package/LICENSE +0 -21
- package/src/_core/__tests__/fs/get-all-files.spec.ts +0 -90
- package/src/_core/__tests__/fs/get-depth.spec.ts +0 -46
- package/src/_core/__tests__/fs/is-shallow.spec.ts +0 -13
- package/src/_core/fs.ts +0 -77
- package/src/_core/type-check.ts +0 -49
- package/src/_core/types/utilities.ts +0 -17
- package/src/_internal/__tests__/color.spec.ts +0 -156
- package/src/_internal/color.ts +0 -7
- package/src/_internal/converters/__tests__/array.spec.ts +0 -9
- package/src/_internal/converters/array.ts +0 -6
- package/src/_internal/converters/number.ts +0 -1
- package/src/_internal/converters/string.ts +0 -22
- package/src/_internal/dev-ops/README.md +0 -9
- package/src/_internal/dev-ops/package-generator/generate-alias/clean-directories.ts +0 -17
- package/src/_internal/dev-ops/package-generator/generate-alias/get-aliases.ts +0 -11
- package/src/_internal/dev-ops/package-generator/generate-alias/write-package-json.ts +0 -29
- package/src/_internal/dev-ops/package-generator/generate-alias.ts +0 -2
- package/src/_internal/fs.ts +0 -1
- package/src/_internal/type-check.ts +0 -1
- package/src/_internal/types/utilities.ts +0 -1
- package/src/modules/color.ts +0 -1
- package/src/modules/converters/array.ts +0 -1
- package/src/modules/converters/number.ts +0 -1
- package/src/modules/converters/string.ts +0 -1
- package/src/modules/dev-ops/package-generator/generate-alias.ts +0 -1
- package/src/modules/fs.ts +0 -1
- package/src/modules/type-check.ts +0 -1
- package/src/modules/types/utilities.ts +0 -1
- package/tsconfig.json +0 -26
- /package/dist/{_core → lib/_core}/fs.js +0 -0
- /package/dist/{_core → lib/_core}/types/utilities.js +0 -0
- /package/dist/{_internal → lib/_internal}/color.js +0 -0
- /package/dist/{_internal → lib/_internal}/converters/array.js +0 -0
- /package/dist/{_internal → lib/_internal}/converters/number.js +0 -0
- /package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/clean-directories.js +0 -0
- /package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/get-aliases.js +0 -0
- /package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/write-package-json.js +0 -0
- /package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias.js +0 -0
- /package/dist/{_internal → lib/_internal}/fs.js +0 -0
- /package/dist/{_internal → lib/_internal}/type-check.js +0 -0
- /package/dist/{_internal → lib/_internal}/types/utilities.js +0 -0
- /package/dist/{modules → lib/modules}/color.js +0 -0
- /package/dist/{modules → lib/modules}/converters/array.js +0 -0
- /package/dist/{modules → lib/modules}/converters/number.js +0 -0
- /package/dist/{modules → lib/modules}/converters/string.js +0 -0
- /package/dist/{modules → lib/modules}/dev-ops/package-generator/generate-alias.js +0 -0
- /package/dist/{modules → lib/modules}/fs.js +0 -0
- /package/dist/{modules → lib/modules}/type-check.js +0 -0
- /package/dist/{modules → lib/modules}/types/utilities.js +0 -0
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { getDepth } from '../../fs.js'
|
|
2
|
-
|
|
3
|
-
describe('getDepth', () => {
|
|
4
|
-
describe('shallow', () => {
|
|
5
|
-
it('root', () => {
|
|
6
|
-
expect(getDepth('hoge')).toBe(1)
|
|
7
|
-
})
|
|
8
|
-
it('/', () => {
|
|
9
|
-
expect(getDepth('hoge')).toBe(1)
|
|
10
|
-
})
|
|
11
|
-
it('.', () => {
|
|
12
|
-
expect(getDepth('./hoge')).toBe(1)
|
|
13
|
-
})
|
|
14
|
-
it('..', () => {
|
|
15
|
-
expect(getDepth('../hoge')).toBe(0)
|
|
16
|
-
})
|
|
17
|
-
})
|
|
18
|
-
describe('deep', () => {
|
|
19
|
-
it('root', () => {
|
|
20
|
-
expect(getDepth('hoge/foo')).toBe(2)
|
|
21
|
-
})
|
|
22
|
-
it('/', () => {
|
|
23
|
-
expect(getDepth('foo/hoge')).toBe(2)
|
|
24
|
-
})
|
|
25
|
-
it('.', () => {
|
|
26
|
-
expect(getDepth('./foo/hoge')).toBe(2)
|
|
27
|
-
})
|
|
28
|
-
it('..', () => {
|
|
29
|
-
expect(getDepth('../foo/hoge')).toBe(1)
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
describe('deep/filename', () => {
|
|
33
|
-
it('root', () => {
|
|
34
|
-
expect(getDepth('hoge/foo/piyo.js')).toBe(3)
|
|
35
|
-
})
|
|
36
|
-
it('/', () => {
|
|
37
|
-
expect(getDepth('foo/hoge/piyo.js')).toBe(3)
|
|
38
|
-
})
|
|
39
|
-
it('.', () => {
|
|
40
|
-
expect(getDepth('./foo/hoge/piyo.js')).toBe(3)
|
|
41
|
-
})
|
|
42
|
-
it('..', () => {
|
|
43
|
-
expect(getDepth('../foo/hoge/piyo.js')).toBe(2)
|
|
44
|
-
})
|
|
45
|
-
})
|
|
46
|
-
})
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { isShallow } from '../../fs.js'
|
|
2
|
-
import { resolve } from 'path'
|
|
3
|
-
|
|
4
|
-
const path = resolve(__dirname, '../../../..', 'fs-test')
|
|
5
|
-
|
|
6
|
-
describe('isShallow', () => {
|
|
7
|
-
it('depth: 1', () => {
|
|
8
|
-
expect(isShallow(path, `${path}/foo`, 1)).toBeTruthy()
|
|
9
|
-
})
|
|
10
|
-
it('same path', () => {
|
|
11
|
-
expect(isShallow(path, path, 0)).toBeTruthy()
|
|
12
|
-
})
|
|
13
|
-
})
|
package/src/_core/fs.ts
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { statSync, readdirSync } from 'fs'
|
|
2
|
-
import { relative } from 'path'
|
|
3
|
-
|
|
4
|
-
import { minimatch } from 'minimatch'
|
|
5
|
-
|
|
6
|
-
export interface Options {
|
|
7
|
-
include?: string[]
|
|
8
|
-
exclude?: string[]
|
|
9
|
-
depth?: number
|
|
10
|
-
startDir?: string
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const OPTIONS = {
|
|
14
|
-
include: [],
|
|
15
|
-
exclude: [],
|
|
16
|
-
depth: 0,
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface Stacks {
|
|
20
|
-
files: string[]
|
|
21
|
-
depth: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const isMatch = (path: string, patterns: string[]) => {
|
|
25
|
-
return patterns.some(pattern => minimatch(path, pattern))
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const getDepth = (path: string) => {
|
|
29
|
-
if (!path) {
|
|
30
|
-
return 0
|
|
31
|
-
}
|
|
32
|
-
let depth = 0
|
|
33
|
-
for (const p of path.replace(/^\.?\/(.*$)/, '$1').split('/')) {
|
|
34
|
-
switch (p) {
|
|
35
|
-
case '..':
|
|
36
|
-
--depth
|
|
37
|
-
break
|
|
38
|
-
default:
|
|
39
|
-
++depth
|
|
40
|
-
break
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return depth
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const isShallow = (from: string, to: string, depth: number) => {
|
|
47
|
-
return getDepth(relative(from, to)) <= depth
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const _getAllFiles = (dir: string, options: Required<Options>, _files: string[] = []) => {
|
|
51
|
-
const files = readdirSync(dir)
|
|
52
|
-
for (const file of files) {
|
|
53
|
-
const name = `${dir}/${file}`
|
|
54
|
-
if (isMatch(name, options.exclude)) {
|
|
55
|
-
continue
|
|
56
|
-
}
|
|
57
|
-
if (options.depth >= 1 && !isShallow(options.startDir, name, options.depth)) {
|
|
58
|
-
continue
|
|
59
|
-
}
|
|
60
|
-
if (statSync(name).isDirectory()) {
|
|
61
|
-
_getAllFiles(name, options, _files)
|
|
62
|
-
} else {
|
|
63
|
-
if (options.include.length > 0 && !isMatch(name, options.include)) {
|
|
64
|
-
continue
|
|
65
|
-
}
|
|
66
|
-
_files.push(name)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return _files
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export const getAllFiles = (startDir: string, _options?: Options) => {
|
|
73
|
-
if (!!_options && 'depth' in _options && typeof _options.depth !== 'undefined' && _options.depth < 1) {
|
|
74
|
-
throw new Error('Invalid depth, must be greater than 0')
|
|
75
|
-
}
|
|
76
|
-
return _getAllFiles(startDir, { ...OPTIONS, ...(_options || {}), startDir })
|
|
77
|
-
}
|
package/src/_core/type-check.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
export const getValueType = (value: any): string => Object.prototype.toString.call(value).slice(8, -1)
|
|
3
|
-
|
|
4
|
-
const onlyNumberReg = new RegExp(/^[0-90-9]+$/)
|
|
5
|
-
const urlPattern = new RegExp(
|
|
6
|
-
'^(https?:\\/\\/)?' + // protocol
|
|
7
|
-
'((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' + // domain name
|
|
8
|
-
'((\\d{1,3}\\.){3}\\d{1,3}))' + // OR ip (v4) address
|
|
9
|
-
'(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' + // port and path
|
|
10
|
-
'(\\?[;&a-z\\d%_.~+=-]*)?' + // query string
|
|
11
|
-
'(\\#[-a-z\\d_]*)?$',
|
|
12
|
-
'i'
|
|
13
|
-
) // fragment locator
|
|
14
|
-
|
|
15
|
-
// export const isNumber = (value): boolean => getValueType(value) === 'Number'
|
|
16
|
-
const _isNumber = (value: any): boolean => getValueType(value) === 'Number' && !Number.isNaN(value)
|
|
17
|
-
export const isBoolean = (value: any): boolean => getValueType(value) === 'Boolean'
|
|
18
|
-
export const isString = (value: any): boolean => getValueType(value) === 'String'
|
|
19
|
-
export const isArray = (value: any): boolean => getValueType(value) === 'Array'
|
|
20
|
-
// export const isArray = (value: any): boolean => Array.isArray(value)
|
|
21
|
-
export const isObject = (value: any): boolean => getValueType(value) === 'Object'
|
|
22
|
-
export const isDate = (value: any): boolean => getValueType(value) === 'Date'
|
|
23
|
-
export const isUrlString = (value: string): boolean => urlPattern.test(value)
|
|
24
|
-
export const isStringNumbers = (name: string) => onlyNumberReg.test(name)
|
|
25
|
-
export const isNumber = (value: any, allowString = false) => {
|
|
26
|
-
if (_isNumber(value)) {
|
|
27
|
-
return value - value === 0
|
|
28
|
-
}
|
|
29
|
-
if (!allowString) {
|
|
30
|
-
return false
|
|
31
|
-
}
|
|
32
|
-
if (isString(value) && value.trim() !== '') {
|
|
33
|
-
return Number.isFinite ? Number.isFinite(+value) : isFinite(+value)
|
|
34
|
-
}
|
|
35
|
-
return false
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const isJson = (str: string): boolean => {
|
|
39
|
-
if (!isString(str)) {
|
|
40
|
-
return false
|
|
41
|
-
}
|
|
42
|
-
try {
|
|
43
|
-
const result = JSON.parse(str)
|
|
44
|
-
return isString(result) || isObject(result)
|
|
45
|
-
} catch (_e) {
|
|
46
|
-
return false
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/* eslint-enable */
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export type Merge<T> = {
|
|
2
|
-
[K in keyof T]: T[K]
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export type AddOR<T, K extends keyof T, V> = Merge<
|
|
6
|
-
Omit<T, K> & {
|
|
7
|
-
[key in K]: T[K] | V
|
|
8
|
-
}
|
|
9
|
-
>
|
|
10
|
-
|
|
11
|
-
export type Update<T, K extends keyof T, V> = Merge<
|
|
12
|
-
Omit<T, K> & {
|
|
13
|
-
[key in K]: V
|
|
14
|
-
}
|
|
15
|
-
>
|
|
16
|
-
|
|
17
|
-
export type ToRecord<T> = Record<keyof T, T[keyof T]>
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import { isDarker } from '../color.js'
|
|
2
|
-
|
|
3
|
-
describe('isDarker', () => {
|
|
4
|
-
const DARK_LISTS = [
|
|
5
|
-
'#000000',
|
|
6
|
-
'#696969',
|
|
7
|
-
'#708090',
|
|
8
|
-
'#4682b4',
|
|
9
|
-
'#4169e1',
|
|
10
|
-
'#191970',
|
|
11
|
-
'#000080',
|
|
12
|
-
'#00008b',
|
|
13
|
-
'#0000cd',
|
|
14
|
-
'#0000ff',
|
|
15
|
-
'#1e90ff',
|
|
16
|
-
'#008b8b',
|
|
17
|
-
'#008080',
|
|
18
|
-
'#2f4f4f',
|
|
19
|
-
'#006400',
|
|
20
|
-
'#008000',
|
|
21
|
-
'#228b22',
|
|
22
|
-
'#2e8b57',
|
|
23
|
-
'#556b2f',
|
|
24
|
-
'#6b8e23',
|
|
25
|
-
'#808000',
|
|
26
|
-
'#a0522d',
|
|
27
|
-
'#8b4513',
|
|
28
|
-
'#800000',
|
|
29
|
-
'#8b0000',
|
|
30
|
-
'#a52a2a',
|
|
31
|
-
'#b22222',
|
|
32
|
-
'#cd5c5c',
|
|
33
|
-
'#ff4500',
|
|
34
|
-
'#ff0000',
|
|
35
|
-
'#dc143c',
|
|
36
|
-
'#c71585',
|
|
37
|
-
'#ff1493',
|
|
38
|
-
'#ff00ff',
|
|
39
|
-
'#9932cc',
|
|
40
|
-
'#9400d3',
|
|
41
|
-
'#8b008b',
|
|
42
|
-
'#800080',
|
|
43
|
-
'#4b0082',
|
|
44
|
-
'#483d8b',
|
|
45
|
-
'#8a2be2',
|
|
46
|
-
'#6a5acd',
|
|
47
|
-
'#7b68ee',
|
|
48
|
-
]
|
|
49
|
-
for (const DARK of DARK_LISTS) {
|
|
50
|
-
it(DARK, () => expect(isDarker(DARK)).toBeTruthy())
|
|
51
|
-
}
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
describe('isNotDarker', () => {
|
|
55
|
-
const NOT_DARK_LISTS = [
|
|
56
|
-
'#808080',
|
|
57
|
-
'#a9a9a9',
|
|
58
|
-
'#c0c0c0',
|
|
59
|
-
'#d3d3d3',
|
|
60
|
-
'#dcdcdc',
|
|
61
|
-
'#f5f5f5',
|
|
62
|
-
'#ffffff',
|
|
63
|
-
'#fffafa',
|
|
64
|
-
'#f8f8ff',
|
|
65
|
-
'#fffaf0',
|
|
66
|
-
'#faf0e6',
|
|
67
|
-
'#faebd7',
|
|
68
|
-
'#ffefd5',
|
|
69
|
-
'#ffebcd',
|
|
70
|
-
'#ffe4c4',
|
|
71
|
-
'#ffe4b5',
|
|
72
|
-
'#ffdead',
|
|
73
|
-
'#ffdab9',
|
|
74
|
-
'#ffe4e1',
|
|
75
|
-
'#fff0f5',
|
|
76
|
-
'#fff5ee',
|
|
77
|
-
'#fdf5e6',
|
|
78
|
-
'#fffff0',
|
|
79
|
-
'#f0fff0',
|
|
80
|
-
'#f5fffa',
|
|
81
|
-
'#f0ffff',
|
|
82
|
-
'#f0f8ff',
|
|
83
|
-
'#e6e6fa',
|
|
84
|
-
'#b0c4de',
|
|
85
|
-
'#778899',
|
|
86
|
-
'#6495ed',
|
|
87
|
-
'#00bfff',
|
|
88
|
-
'#87cefa',
|
|
89
|
-
'#87ceeb',
|
|
90
|
-
'#add8e6',
|
|
91
|
-
'#b0e0e6',
|
|
92
|
-
'#afeeee',
|
|
93
|
-
'#e0ffff',
|
|
94
|
-
'#00ffff',
|
|
95
|
-
'#40e0d0',
|
|
96
|
-
'#48d1cc',
|
|
97
|
-
'#00ced1',
|
|
98
|
-
'#20b2aa',
|
|
99
|
-
'#5f9ea0',
|
|
100
|
-
'#3cb371',
|
|
101
|
-
'#66cdaa',
|
|
102
|
-
'#8fbc8f',
|
|
103
|
-
'#7fffd4',
|
|
104
|
-
'#98fb98',
|
|
105
|
-
'#90ee90',
|
|
106
|
-
'#00ff7f',
|
|
107
|
-
'#00fa9a',
|
|
108
|
-
'#7cfc00',
|
|
109
|
-
'#7fff00',
|
|
110
|
-
'#adff2f',
|
|
111
|
-
'#00ff00',
|
|
112
|
-
'#32cd32',
|
|
113
|
-
'#9acd32',
|
|
114
|
-
'#bdb76b',
|
|
115
|
-
'#eee8aa',
|
|
116
|
-
'#fff8dc',
|
|
117
|
-
'#f5f5dc',
|
|
118
|
-
'#ffffe0',
|
|
119
|
-
'#fafad2',
|
|
120
|
-
'#fffacd',
|
|
121
|
-
'#f5deb3',
|
|
122
|
-
'#deb887',
|
|
123
|
-
'#d2b48c',
|
|
124
|
-
'#f0e68c',
|
|
125
|
-
'#ffff00',
|
|
126
|
-
'#ffd700',
|
|
127
|
-
'#ffa500',
|
|
128
|
-
'#f4a460',
|
|
129
|
-
'#ff8c00',
|
|
130
|
-
'#daa520',
|
|
131
|
-
'#cd853f',
|
|
132
|
-
'#b8860b',
|
|
133
|
-
'#d2691e',
|
|
134
|
-
'#bc8f8f',
|
|
135
|
-
'#e9967a',
|
|
136
|
-
'#f08080',
|
|
137
|
-
'#fa8072',
|
|
138
|
-
'#ffa07a',
|
|
139
|
-
'#ff7f50',
|
|
140
|
-
'#ff6347',
|
|
141
|
-
'#ff69b4',
|
|
142
|
-
'#db7093',
|
|
143
|
-
'#ffc0cb',
|
|
144
|
-
'#ffb6c1',
|
|
145
|
-
'#d8bfd8',
|
|
146
|
-
'#ee82ee',
|
|
147
|
-
'#dda0dd',
|
|
148
|
-
'#da70d6',
|
|
149
|
-
'#ba55d3',
|
|
150
|
-
'#9370db',
|
|
151
|
-
]
|
|
152
|
-
|
|
153
|
-
for (const NOT_DARK of NOT_DARK_LISTS) {
|
|
154
|
-
it(NOT_DARK, () => expect(isDarker(NOT_DARK)).toBeFalsy())
|
|
155
|
-
}
|
|
156
|
-
})
|
package/src/_internal/color.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { hexdec } from './converters/string.js'
|
|
2
|
-
|
|
3
|
-
export const getLuminance = (code: string): number =>
|
|
4
|
-
(hexdec(code.substring(1, 3)) * 0.299 + hexdec(code.substring(3, 5)) * 0.587 + hexdec(code.substring(5, 7)) * 0.114) /
|
|
5
|
-
2.55
|
|
6
|
-
|
|
7
|
-
export const isDarker = (code: string): boolean => getLuminance(`#${code}`.replace(/^#{2,}/, '#')) < 50
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getUnique } from '../array.js'
|
|
2
|
-
|
|
3
|
-
describe('getUnique', () => {
|
|
4
|
-
const list = [1, 2, 3, 1, 1, 1, 3, 100, 'foo', 'hoge', 1, 'foo']
|
|
5
|
-
const expects = [1, 2, 3, 100, 'foo', 'hoge']
|
|
6
|
-
it('should be equal', () => {
|
|
7
|
-
expect(JSON.stringify(getUnique(list))).toBe(JSON.stringify(expects))
|
|
8
|
-
})
|
|
9
|
-
})
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export const getUnique = <T extends string | number>(list: T[]): T[] => [...new Set(list)]
|
|
2
|
-
export const chunk = <T = unknown>(list: T[], size: number): T[][] =>
|
|
3
|
-
list.reduce(
|
|
4
|
-
(acc: T[][], _: T, i: number, self: T[]) => (i % size ? acc : [...acc, self.slice(i, i + size)]),
|
|
5
|
-
[] as T[][]
|
|
6
|
-
) as T[][]
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const digits = (num: number | string, count = 2) => `${'0'.repeat(count)}${num}`.slice(-count)
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { isArray } from '~core/type-check.js'
|
|
2
|
-
// const validate = (text: string): RegExpMatchArray | null =>
|
|
3
|
-
// text.match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g)
|
|
4
|
-
|
|
5
|
-
isArray([])
|
|
6
|
-
|
|
7
|
-
export const camelCase = (text: string) =>
|
|
8
|
-
`${text.charAt(0).toLowerCase()}${text.slice(1)}`.replace(/[-_](.)/g, (_, group1) => group1.toUpperCase())
|
|
9
|
-
|
|
10
|
-
export const snakeCase = (text: string) => camelCase(text).replace(/[A-Z]/g, s => `_${s.charAt(0).toLowerCase()}`)
|
|
11
|
-
|
|
12
|
-
export const kebabCase = (text: string): string =>
|
|
13
|
-
camelCase(text).replace(/[A-Z]/g, s => `-${s.charAt(0).toLowerCase()}`)
|
|
14
|
-
|
|
15
|
-
export const pascalCase = (text: string) => {
|
|
16
|
-
const camel = camelCase(text)
|
|
17
|
-
return `${camel.charAt(0).toUpperCase()}${camel.slice(1)}`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const hexdec = (stringText: string): number => {
|
|
21
|
-
return parseInt(stringText.replace(/[^a-f0-9]/gi, ''), 16)
|
|
22
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
|
|
3
|
-
import { ensureDirSync, pathExistsSync, removeSync } from 'fs-extra/esm'
|
|
4
|
-
|
|
5
|
-
export const cleanDirectory = (prefix: string, dir: string) => {
|
|
6
|
-
const path = resolve(prefix, dir)
|
|
7
|
-
if (pathExistsSync(path)) {
|
|
8
|
-
removeSync(path)
|
|
9
|
-
}
|
|
10
|
-
ensureDirSync(path)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const cleanDirectories = (prefix: string, aliases: string[]) => {
|
|
14
|
-
for (const alias of aliases) {
|
|
15
|
-
cleanDirectory(prefix, alias)
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { getAllFiles } from '~core/fs.js'
|
|
2
|
-
|
|
3
|
-
export const getAliases = (path: string, excludes: string[]) => {
|
|
4
|
-
const regExp = new RegExp(`^${path}/`)
|
|
5
|
-
const excludesExp = new RegExp(excludes.join('|'))
|
|
6
|
-
const aliases = getAllFiles(path).map(path => path.replace(regExp, '').replace(/\.ts$/, ''))
|
|
7
|
-
if (excludes.length) {
|
|
8
|
-
return aliases.filter(path => !excludesExp.test(path))
|
|
9
|
-
}
|
|
10
|
-
return aliases
|
|
11
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { join } from 'path'
|
|
2
|
-
|
|
3
|
-
import { writeJsonSync } from 'fs-extra/esm'
|
|
4
|
-
|
|
5
|
-
import { cleanDirectory } from './clean-directories.js'
|
|
6
|
-
|
|
7
|
-
export const writePackageJson = (
|
|
8
|
-
prefix: string,
|
|
9
|
-
author: string,
|
|
10
|
-
name: string,
|
|
11
|
-
outputDir: string,
|
|
12
|
-
aliases: string[],
|
|
13
|
-
ignoreDirectory = ''
|
|
14
|
-
) => {
|
|
15
|
-
for (const alias of aliases) {
|
|
16
|
-
const splits = alias.split(/\//g)
|
|
17
|
-
const outputPaths = splits.filter(dir => dir !== ignoreDirectory)
|
|
18
|
-
const relative = outputPaths.map(() => '..').join('/')
|
|
19
|
-
const outputPath = outputPaths.join('/')
|
|
20
|
-
const pkgManifest = {
|
|
21
|
-
name: `${author}/${[name, ...splits].join('-')}`,
|
|
22
|
-
types: `${relative}/${outputDir}/${alias}.d.ts`,
|
|
23
|
-
main: `${relative}/${outputDir}/${alias}.js`,
|
|
24
|
-
sideEffects: false,
|
|
25
|
-
}
|
|
26
|
-
cleanDirectory(prefix, outputPath)
|
|
27
|
-
writeJsonSync(join(prefix, outputPath, 'package.json'), pkgManifest, { spaces: 2 })
|
|
28
|
-
}
|
|
29
|
-
}
|
package/src/_internal/fs.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~core/fs.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~core/type-check.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~core/types/utilities.js'
|
package/src/modules/color.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/color.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/converters/array.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/converters/number.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/converters/string.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/dev-ops/package-generator/generate-alias.js'
|
package/src/modules/fs.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/fs.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/type-check.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '~internal/types/utilities.js'
|
package/tsconfig.json
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ESNext",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"types": ["jest", "node"],
|
|
6
|
-
"moduleResolution": "NodeNext",
|
|
7
|
-
"allowJs": true,
|
|
8
|
-
"checkJs": false,
|
|
9
|
-
"declaration": true,
|
|
10
|
-
"strict": true,
|
|
11
|
-
"outDir": "dist",
|
|
12
|
-
"rootDir": "./src",
|
|
13
|
-
"removeComments": true,
|
|
14
|
-
"allowSyntheticDefaultImports": true,
|
|
15
|
-
"resolveJsonModule": true,
|
|
16
|
-
"sourceMap": true,
|
|
17
|
-
"typeRoots": ["node_modules/@types", "src/types"],
|
|
18
|
-
"baseUrl": "./",
|
|
19
|
-
"paths": {
|
|
20
|
-
"~internal/*": ["./src/_internal/*"],
|
|
21
|
-
"~core/*": ["./src/_core/*"]
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
"include": ["src/**/*"],
|
|
25
|
-
"exclude": ["src/**/*.spec.ts"]
|
|
26
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{_internal → lib/_internal}/dev-ops/package-generator/generate-alias/get-aliases.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|