|
1 |
| -import { join } from 'node:path'; |
2 | 1 | import process from 'node:process';
|
3 | 2 |
|
4 | 3 | /** @typedef {import('./types.js').Validator} Validator */
|
@@ -125,18 +124,19 @@ const options = object(
|
125 | 124 | }),
|
126 | 125 |
|
127 | 126 | files: object({
|
128 |
| - assets: string('static'), |
| 127 | + src: deprecate(string('src')), |
| 128 | + assets: deprecate(string('static')), |
129 | 129 | hooks: object({
|
130 |
| - client: string(join('src', 'hooks.client')), |
131 |
| - server: string(join('src', 'hooks.server')), |
132 |
| - universal: string(join('src', 'hooks')) |
| 130 | + client: deprecate(string(null)), |
| 131 | + server: deprecate(string(null)), |
| 132 | + universal: deprecate(string(null)) |
133 | 133 | }),
|
134 |
| - lib: string(join('src', 'lib')), |
135 |
| - params: string(join('src', 'params')), |
136 |
| - routes: string(join('src', 'routes')), |
137 |
| - serviceWorker: string(join('src', 'service-worker')), |
138 |
| - appTemplate: string(join('src', 'app.html')), |
139 |
| - errorTemplate: string(join('src', 'error.html')) |
| 134 | + lib: deprecate(string(null)), |
| 135 | + params: deprecate(string(null)), |
| 136 | + routes: deprecate(string(null)), |
| 137 | + serviceWorker: deprecate(string(null)), |
| 138 | + appTemplate: deprecate(string(null)), |
| 139 | + errorTemplate: deprecate(string(null)) |
140 | 140 | }),
|
141 | 141 |
|
142 | 142 | inlineStyleThreshold: number(0),
|
@@ -287,6 +287,25 @@ const options = object(
|
287 | 287 | true
|
288 | 288 | );
|
289 | 289 |
|
| 290 | +/** |
| 291 | + * @param {Validator} fn |
| 292 | + * @param {(keypath: string) => string} get_message |
| 293 | + * @returns {Validator} |
| 294 | + */ |
| 295 | +function deprecate( |
| 296 | + fn, |
| 297 | + get_message = (keypath) => |
| 298 | + `The \`${keypath}\` option is deprecated, and will be removed in a future version` |
| 299 | +) { |
| 300 | + return (input, keypath) => { |
| 301 | + if (input !== undefined) { |
| 302 | + console.warn(get_message(keypath)); |
| 303 | + } |
| 304 | + |
| 305 | + return fn(input, keypath); |
| 306 | + }; |
| 307 | +} |
| 308 | + |
290 | 309 | /**
|
291 | 310 | * @param {Record<string, Validator>} children
|
292 | 311 | * @param {boolean} [allow_unknown]
|
|
0 commit comments