-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
211 lines (200 loc) · 5.86 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
// const {trim} = require('@inst-cli/template-utils')
const {getPackageName, getPackageRepoPages} = require('@lunde/inst-utils')
module.exports = {}
// creates template variables using Inquirer.js
// see https://github.com/SBoudrias/Inquirer.js#objects for prompt object examples
/*
module.exports.prompts = (
{ROOT_NAME, ROOT_DIR, PKG_NAME, PKG_DIR},
packageJson,
args,
inquirer
) => {
return [
{
type: 'string',
name: 'description',
message: 'Description:',
filter: trim,
},
]
}
*/
// package.json dependencies
module.exports.dependencies = {
'@accessible/button': '^2.0.1',
'@accessible/checkbox': '^4.0.1',
'@accessible/using-keyboard': '^2.1.1',
'@dash-ui/mq': '^0.4.0',
'@dash-ui/react': '^0.9.1',
'@dash-ui/react-layout': '^0.8.2',
'@dash-ui/reset': '^0.3.1',
'@dash-ui/responsive': '^0.2.3',
'@dash-ui/styles': '^0.8.6',
'@react-hook/merged-ref': '^1.3.0',
'@react-hook/window-size': '^3.0.7',
clsx: '^1.1.1',
'forward-ref-as': '^1.0.1',
}
// package.json dev dependencies
module.exports.devDependencies = () => {
let deps = {
'@commitlint/cli': 'latest',
'@commitlint/config-conventional': 'latest',
'@dash-ui/jest': 'latest',
'@storybook/addon-a11y': 'next',
'@storybook/addon-essentials': 'next',
'@storybook/react': 'next',
'@testing-library/jest-dom': '^5.11.2',
'@testing-library/react': '^10.4.8',
'@testing-library/react-hooks': 'latest',
'@testing-library/user-event': '^12.1.0',
'@types/jest': 'latest',
'@types/react': 'latest',
'@types/react-dom': 'latest',
'babel-jest': 'latest',
'cli-confirm': 'latest',
'cz-conventional-changelog': 'latest',
jest: 'latest',
eslint: 'latest',
'eslint-config-lunde': 'latest',
husky: 'latest',
'lint-staged': 'latest',
lundle: 'latest',
'minify-css.macro': '^1.0.10',
prettier: 'latest',
react: 'latest',
'react-dom': 'latest',
'react-is': 'latest',
'react-test-renderer': 'latest',
'standard-version': 'latest',
typescript: 'latest',
}
return deps
}
// package.json peer dependencies
module.exports.peerDependencies = () => ({
react: '>=16.8',
'react-dom': '>=16.8',
})
module.exports.rename = (filename) =>
(filename.endsWith('/gitignore')
? filename.replace('gitignore', '.gitignore')
: filename
).replace('.inst.', '.')
module.exports.getDefaultVariables = async (variables, args, {name}) => {
const pages = await getPackageRepoPages({name}, args)
return {
packageName: getPackageName({name}, args),
repo: pages.repository.replace('github:', ''),
pages,
}
}
// runs after the package.json is created and deps are installed,
// used for adding scripts and whatnot
//
// this function must return a valid package.json object
module.exports.editPackageJson = async function editPackageJson(
// eslint-disable-next-line no-unused-vars
{main, name, description, ...packageJson},
variables /*from prompts() above*/,
args
) {
let pkg = {
name: variables.packageName,
version: packageJson.version,
...variables.pages,
author: packageJson.author,
license: packageJson.license,
description:
variables.description ||
'A design system created with @dash-ui/design-system',
keywords: ['react', variables.PKG_NAME.replace(/-/g, ' ')],
main: 'dist/main/index.js',
module: 'dist/module/index.js',
unpkg: `dist/umd/${
args.hook && !variables.PKG_NAME.startsWith('use-') ? 'use-' : ''
}${variables.PKG_NAME}.js`,
source: 'src/index.tsx',
types: 'types/index.d.ts',
exports: {
'.': {
browser: './dist/module/index.js',
import: './dist/esm/index.mjs',
require: './dist/main/index.js',
umd: `./dist/umd/${
args.hook && !variables.PKG_NAME.startsWith('use-') ? 'use-' : ''
}${variables.PKG_NAME}.js`,
source: './src/index.tsx',
types: './types/index.d.ts',
default: './dist/main/index.js',
},
'./package.json': './package.json',
'./': './',
},
files: ['/dist', '/src', '/types'],
sideEffects: false,
scripts: {
build: 'lundle build',
'build-storybook': 'build-storybook',
'check-types': 'lundle check-types',
dev: 'lundle build -f module,cjs -w',
format:
'prettier --write "{,!(node_modules|dist|coverage)/**/}*.{ts,tsx,js,jsx,md,yml,json}"',
lint: 'eslint . --ext .ts,.tsx',
prepublishOnly: 'cli-confirm "Did you run \'yarn release\' first? (y/N)"',
prerelease: 'npm run validate && npm run build',
release: 'git add . && standard-version -a',
storybook: 'start-storybook -p 6006',
test: 'jest',
validate: 'lundle check-types && npm run lint && jest --coverage',
},
husky: {
hooks: {
'pre-commit': 'lundle check-types && lint-staged',
'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
},
},
'lint-staged': {
'**/*.{ts,tsx,js,jsx}': ['eslint --fix', 'prettier --write'],
'**/*.{md,yml,json}': ['prettier --write'],
},
commitlint: {
extends: ['@commitlint/config-conventional'],
},
config: {
commitizen: {
path: './node_modules/cz-conventional-changelog',
},
},
eslintConfig: {
extends: ['lunde'],
},
eslintIgnore: [
'node_modules',
'coverage',
'dist',
'/types',
'test',
'*.config.js',
],
jest: {
moduleDirectories: ['node_modules', 'src', 'test'],
testMatch: ['<rootDir>/src/**/?(*.)test.{ts,tsx}'],
collectCoverageFrom: ['**/src/**/*.{ts,tsx}'],
setupFilesAfterEnv: ['./test/setup.js'],
snapshotResolver: './test/resolve-snapshot.js',
globals: {
__DEV__: true,
},
},
prettier: {
semi: false,
singleQuote: true,
jsxSingleQuote: true,
bracketSpacing: false,
},
...packageJson,
}
return pkg
}