Repository navigation
Expand file tree
/
Copy pathpackage.json.js
More file actions
241 lines (209 loc) · 7.72 KB
/
Copy pathpackage.json.js
File metadata and controls
241 lines (209 loc) · 7.72 KB
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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
import * as fs from 'node:fs';
// Generator for package.json (to allow some more convenient syntax, like comments)
// Usage:
// $ node package.json.js # Generates an updated `package.json` file
const packageConfig = {
name: '@fortanix/baklava',
version: '1.0.0-beta-20261028',
license: 'MPL-2.0',
author: 'Fortanix',
description: 'Fortanix Baklava design system',
repository: { type: 'git', url: 'git+https://github.com/fortanix/baklava.git' },
files: [
'src',
'app',
'dist',
'LICENSE',
'CHANGELOG.md',
'README.md',
],
sideEffects: ['*.css'],
type: 'module',
engines: {
node: '>=26.12.1',
npm: '>=11.17.0',
},
allowScripts: {
'@parcel/watcher': true,
'esbuild': true,
'fsevents': true,
},
exports: {
'.': {
'sass': './dist/baklava.css',
'types': './dist/baklava.d.ts',
//'require': './dist/baklava.cjs',
'default': './dist/baklava.js',
},
// Expose mixins for use in consumer components
'./styling/defs.scss': {
'default': './src/styling/public/defs.scss',
},
// Expose layer ordering, since consumers may want to explicitly emit these first (see note in README.md)
'./styling/layers.scss': {
'default': './src/styling/public/layers.scss',
},
},
scripts: {
// Utilities
'gen-package': 'node package.json.js', // Update `package.json`
'install-project': 'npm run gen-package && npm install', // Project-specific version of `npm install`
// CLI
'plop': 'plop',
'import': 'node scripts/import.ts',
'automate': 'node scripts/automate.ts',
'verify': 'node scripts/verify.ts',
// Library
//'lib:build': '',
// App
'serve:dev': 'vite --config=./vite.config.ts serve',
//'build': 'vite --config=./vite.config.ts --emptyOutDir build && cp src/types/vite-env.d.ts dist && echo \'{"name": "@fortanix/baklava","main": "./baklava.js"}\' > dist/package.json',
'build': 'tsc -b && vite --config=./vite.config.ts build && npm run verify verify:build',
// Storybook
'storybook:serve': 'storybook dev -p 6006',
'storybook:build': 'storybook build --docs',
'chromatic': 'npx chromatic', // Must be run with `CHROMATIC_PROJECT_TOKEN` env variable (secret)
// Static analysis
'check:types': 'tsc -b',
'lint:style': `stylelint 'src/**/*.scss'`,
'lint:script': 'biome lint',
'lint': 'npm run lint:style; npm run lint:script',
// Test
// Note: use `vitest run src/...` to run a single test file
'test:unit': 'vitest run --project=unit',
'test': 'npm run check:types && npm run test:unit && npm run lint:style && npm run verify verify:source', // TODO: add `lint:script`
'test-ui': 'vitest --ui',
'coverage': 'vitest run --coverage',
// Browser automation tests
// https://github.com/storybookjs/test-runner?tab=readme-ov-file#2-running-against-locally-built-storybooks-in-ci
'test:storybook': 'vitest run --project=storybook',
// Shorthands
'start': 'npm run storybook:serve',
// Hooks
'prepare': 'npm run build',
},
// Dev dependencies (only needed when building, or making changes to the code)
devDependencies: {
// CLI
'plop': '^4.0.5',
// Build
'browserslist': '^4.28.2',
'vite': '^8.0.11',
'@vitejs/plugin-react': '^6.0.1',
'vite-plugin-dts': '^5.1.0',
'vite-plugin-lib-inject-css': '^2.2.1',
'vite-plugin-svgr': '^4.5.0',
'vite-plugin-svg-icons-ng': '^1.9.0',
// Static analysis
// ts6 is still required, see https://github.com/fortanix/baklava/pull/730/changes#r4062796736
'@typescript/native': 'npm:typescript@^7.0.2',
'@typescript/typescript6': '^6.0.2',
'typescript': 'npm:@typescript/typescript6@^6.0.2',
'@types/node': '^24.*', // Should match the Node major version in .nvmrc
'stylelint': '^17.11.0',
'stylelint-config-standard-scss': '^17.0.0',
'stylelint-use-logical': '^2.1.3',
'@biomejs/biome': '^2.4.14', // https://biomejs.dev/internals/changelog
// Testing
'jsdom': '^29.1.1', // https://github.com/jsdom/jsdom/releases
'vitest': '^4.1.5',
'@vitest/ui': '^4.1.5',
'@vitest/browser-playwright': '^4.1.5',
'@vitest/coverage-v8': '^4.1.5',
'@testing-library/react': '^16.3.2',
'@testing-library/user-event': '^14.6.1',
'@testing-library/jest-dom': '^6.9.1',
'@ngneat/falso': '^8.0.2',
'mockdate': '^3.0.5',
'playwright': '^1.59.1',
// Storybook
'storybook': '^10.3.6',
'@storybook/react-vite': '^10.3.6',
'@storybook/react': '10.3.6',
'@storybook/addon-a11y': '^10.3.6',
'@storybook/addon-designs': '^11.1.3',
'@storybook/addon-docs': '^10.3.6',
'@storybook/addon-links': '^10.3.6',
'@storybook/addon-vitest': '^10.3.6',
'chromatic': '^16.9.1', // https://github.com/chromaui/chromatic-cli/blob/main/CHANGELOG.md
'@chromatic-com/storybook': '^5.1.2', // Chromatic integration for Storybook
//'storybook-addon-pseudo-states': '^3.1.1',
//'@storybook-community/storybook-dark-mode': '^6.0.0',
//'@percy/cli': '^1.31.2',
//'@percy/storybook': '^9.0.0',
// Styling
'typescript-plugin-css-modules': '^5.2.0',
'sass-embedded': '^1.99.0', // https://github.com/sass/dart-sass/blob/main/CHANGELOG.md
'lightningcss': '^1.31.1',
// React
'@types/react': '^19.2.14',
'@types/react-dom': '^19.2.3',
// Data table
'@types/react-table': '^7.7.20',
},
// Dependencies needed when running the generated build
dependencies: {
// Utilities
'date-fns': '^4.1.0',
'message-tag': '^0.10.0',
'effect': '^3.21.2',
//'optics-ts': '^2.4.1',
// Polyfills
'scroll-into-view-if-needed': '^3.1.0',
'@microsoft/focusgroup-polyfill': '^1.5.0',
// React
'react': '^19.2.6',
'react-dom': '^19.2.6', // Must be in sync with `react`
'react-error-boundary': '^6.1.1',
'classnames': '^2.5.1',
'zustand': '^5.0.13',
// React UI libraries
'@tanstack/react-virtual': '^3.13.24',
'@floating-ui/react': '^0.27.18', // https://github.com/floating-ui/floating-ui/blob/master/packages/react/CHANGELOG.md
'react-hook-form': '^7.75.0',
'react-table': '^7.8.0',
'react-datepicker': '^9.1.0',
},
peerDependencies: {
'react': '>= 19.0.0',
'react-dom': '>= 19.0.0',
},
peerDependenciesMeta: {},
optionalDependencies: {
// Note: if you're hitting issues in GitHub CI where platform-specific dependencies are not found, try removing
// `node_modules` and regenerating `package-lock.json` (see: https://github.com/npm/cli/issues/4828).
//'@rollup/rollup-linux-x64-gnu': '...', // Adding the optionalDependency works, but you'll just get other errors
},
overrides: {
// TODO: Revisit after updating react-table to v8
'react-table': {
'react': '$react',
'react-dom': '$react-dom',
},
less: "^4.6.7",
},
};
const makePackageJson = () => {
const packageJson = {
// http://stackoverflow.com/questions/14221579/how-do-i-add-comments-to-package-json
'//': 'NOTE: This is a generated file. Do not edit this file directly, edit package.json.js instead.',
...packageConfig,
};
/*
const packageJsonCurrent = (() => {
try {
return JSON.parse(fs.readFileSync('./package.json'));
} catch (error) {
return null;
}
})();
// Inherit the version from the existing `package.json`, to allow facilitate version bumps through CI
if (packageJsonCurrent?.version && typeof packageJson.version !== 'string') {
packageJson.version = packageJsonCurrent.version;
}
*/
return packageJson;
};
// Write to `package.json`
fs.writeFileSync('./package.json', `${JSON.stringify(makePackageJson(), null, 2)}\n`);
console.info('Generated package.json');