From 088e529734b61461aeb25a91bc3ab07f0264b1b7 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 26 Aug 2022 23:03:19 +0800 Subject: [PATCH] chore: upgrade untyped --- docs/package.json | 2 +- packages/kit/package.json | 2 +- packages/nuxt/package.json | 2 +- packages/schema/package.json | 2 +- packages/schema/src/config/_adhoc.ts | 4 +- packages/schema/src/config/_app.ts | 5 +- packages/schema/src/config/_common.ts | 4 +- packages/schema/src/config/_internal.ts | 4 +- packages/schema/src/config/build.ts | 4 +- packages/schema/src/config/cli.ts | 4 +- packages/schema/src/config/experimental.ts | 4 +- packages/schema/src/config/generate.ts | 4 +- packages/schema/src/config/messages.ts | 4 +- packages/schema/src/config/nitro.ts | 4 +- packages/schema/src/config/postcss.ts | 4 +- packages/schema/src/config/render.ts | 4 +- packages/schema/src/config/router.ts | 4 +- packages/schema/src/config/server.ts | 4 +- packages/schema/src/config/typescript.ts | 4 +- packages/schema/src/config/vite.ts | 4 +- packages/schema/src/config/webpack.ts | 4 +- packages/schema/src/utils.ts | 53 ---------------------- yarn.lock | 14 +++--- 23 files changed, 45 insertions(+), 99 deletions(-) delete mode 100644 packages/schema/src/utils.ts diff --git a/docs/package.json b/docs/package.json index 530c5171f88..d17d7368221 100644 --- a/docs/package.json +++ b/docs/package.json @@ -20,7 +20,7 @@ "pathe": "^0.3.5", "rimraf": "^3.0.2", "scule": "^0.3.2", - "untyped": "^0.4.6", + "untyped": "^0.4.7", "vue-mq": "^1.0.1", "vue-plausible": "^1.3.2" }, diff --git a/packages/kit/package.json b/packages/kit/package.json index e52c85dd551..7ae2022be9b 100644 --- a/packages/kit/package.json +++ b/packages/kit/package.json @@ -30,7 +30,7 @@ "semver": "^7.3.7", "unctx": "^2.0.1", "unimport": "^0.6.7", - "untyped": "^0.4.6" + "untyped": "^0.4.7" }, "devDependencies": { "@types/lodash.template": "^4", diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 19d0fffcdcc..d7fa95b46a9 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -65,7 +65,7 @@ "unenv": "^0.6.1", "unimport": "^0.6.7", "unplugin": "^0.9.2", - "untyped": "^0.4.6", + "untyped": "^0.4.7", "vue": "^3.2.37", "vue-bundle-renderer": "^0.4.2", "vue-devtools-stub": "^0.1.0", diff --git a/packages/schema/package.json b/packages/schema/package.json index 768241ab059..15fbf21c4c5 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -17,7 +17,7 @@ "@types/lodash.template": "^4", "@types/semver": "^7", "unbuild": "latest", - "untyped": "^0.4.6", + "untyped": "^0.4.7", "vite": "~3.0.9" }, "dependencies": { diff --git a/packages/schema/src/config/_adhoc.ts b/packages/schema/src/config/_adhoc.ts index c153a9c5fc0..d6926ab68df 100644 --- a/packages/schema/src/config/_adhoc.ts +++ b/packages/schema/src/config/_adhoc.ts @@ -1,6 +1,6 @@ -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Configure Nuxt component auto-registration. * diff --git a/packages/schema/src/config/_app.ts b/packages/schema/src/config/_app.ts index 5afdb230599..a6dec3d01ba 100644 --- a/packages/schema/src/config/_app.ts +++ b/packages/schema/src/config/_app.ts @@ -1,12 +1,11 @@ import { resolve, join } from 'pathe' import { existsSync, readdirSync } from 'node:fs' import defu from 'defu' +import { defineUntypedSchema } from 'untyped' import { MetaObject } from '../types/meta' -import { defineSchemaObject } from '../utils' - -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Vue.js config * @version 2 diff --git a/packages/schema/src/config/_common.ts b/packages/schema/src/config/_common.ts index 619fe0b5827..d6067f441be 100644 --- a/packages/schema/src/config/_common.ts +++ b/packages/schema/src/config/_common.ts @@ -7,9 +7,9 @@ import defu from 'defu' import { RuntimeConfig } from '../types/config' -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Extend nested configurations from multiple local or remote sources. * diff --git a/packages/schema/src/config/_internal.ts b/packages/schema/src/config/_internal.ts index 2c16dabea21..400aad87e86 100644 --- a/packages/schema/src/config/_internal.ts +++ b/packages/schema/src/config/_internal.ts @@ -1,6 +1,6 @@ -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** @private */ _majorVersion: 2, /** @private */ diff --git a/packages/schema/src/config/build.ts b/packages/schema/src/config/build.ts index 12fd0a76e05..e1122c7ec56 100644 --- a/packages/schema/src/config/build.ts +++ b/packages/schema/src/config/build.ts @@ -2,9 +2,9 @@ import defu from 'defu' import { join } from 'pathe' import { isCI, isTest } from 'std-env' import { normalizeURL, withTrailingSlash } from 'ufo' -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * The builder to use for bundling the Vue part of your application. * diff --git a/packages/schema/src/config/cli.ts b/packages/schema/src/config/cli.ts index adec750761a..93bb4219802 100644 --- a/packages/schema/src/config/cli.ts +++ b/packages/schema/src/config/cli.ts @@ -1,6 +1,6 @@ -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Add a message to the CLI banner by adding a string to this array. * @type {string[]} diff --git a/packages/schema/src/config/experimental.ts b/packages/schema/src/config/experimental.ts index 5ebdcfe1e1c..491cb3f82f1 100644 --- a/packages/schema/src/config/experimental.ts +++ b/packages/schema/src/config/experimental.ts @@ -1,6 +1,6 @@ -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** @version 3 */ experimental: { /** diff --git a/packages/schema/src/config/generate.ts b/packages/schema/src/config/generate.ts index fd23b2b4842..ea41f9c0721 100644 --- a/packages/schema/src/config/generate.ts +++ b/packages/schema/src/config/generate.ts @@ -1,11 +1,11 @@ import { resolve } from 'pathe' import { joinURL } from 'ufo' -import { SchemaObject } from '../utils' +import { SchemaDefinition } from 'untyped' /** * @version 2 */ - export default { + export default { /** * Directory name that holds all the assets and generated pages for a `static` build. */ diff --git a/packages/schema/src/config/messages.ts b/packages/schema/src/config/messages.ts index 8917f83b925..f6eff563b53 100644 --- a/packages/schema/src/config/messages.ts +++ b/packages/schema/src/config/messages.ts @@ -1,9 +1,9 @@ -import { SchemaObject } from '../utils' +import { SchemaDefinition } from 'untyped' /** * @version 2 */ -export default { +export default { /** The text that displays on the Nuxt loading indicator when `ssr: false`. */ loading: 'Loading...', /** The 404 text on the default Nuxt error page. */ diff --git a/packages/schema/src/config/nitro.ts b/packages/schema/src/config/nitro.ts index 34881b29b60..091bee65ae7 100644 --- a/packages/schema/src/config/nitro.ts +++ b/packages/schema/src/config/nitro.ts @@ -1,6 +1,6 @@ -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Configuration for Nitro. * diff --git a/packages/schema/src/config/postcss.ts b/packages/schema/src/config/postcss.ts index e046eff7c8d..d2f03632d23 100644 --- a/packages/schema/src/config/postcss.ts +++ b/packages/schema/src/config/postcss.ts @@ -1,8 +1,8 @@ import defu from 'defu' import createResolver from 'postcss-import-resolver' -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** @version 3 */ postcss: { /** Path to postcss config file. */ diff --git a/packages/schema/src/config/render.ts b/packages/schema/src/config/render.ts index d126f56c873..203ebc4e0f9 100644 --- a/packages/schema/src/config/render.ts +++ b/packages/schema/src/config/render.ts @@ -1,9 +1,9 @@ -import { SchemaObject } from '../utils' +import { SchemaDefinition } from 'untyped' /** * @version 2 */ -export default { +export default { /** * Use this option to customize the Vue SSR bundle renderer. * This option is skipped if `ssr: false`. diff --git a/packages/schema/src/config/router.ts b/packages/schema/src/config/router.ts index 3ce84688d8c..6a895654dd0 100644 --- a/packages/schema/src/config/router.ts +++ b/packages/schema/src/config/router.ts @@ -1,7 +1,7 @@ import { normalizeURL, withTrailingSlash } from 'ufo' -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Additional options passed to `vue-router`. * diff --git a/packages/schema/src/config/server.ts b/packages/schema/src/config/server.ts index 49d36ef11ea..51ebed8c4bc 100644 --- a/packages/schema/src/config/server.ts +++ b/packages/schema/src/config/server.ts @@ -1,7 +1,7 @@ -import { SchemaObject } from '../utils' +import { SchemaDefinition } from 'untyped' /** @version 2 */ -export default { +export default { /** * Whether to enable HTTPS. * diff --git a/packages/schema/src/config/typescript.ts b/packages/schema/src/config/typescript.ts index 35d8f612b3e..7b3c7d185e9 100644 --- a/packages/schema/src/config/typescript.ts +++ b/packages/schema/src/config/typescript.ts @@ -1,6 +1,6 @@ -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Configuration for Nuxt's TypeScript integration. * diff --git a/packages/schema/src/config/vite.ts b/packages/schema/src/config/vite.ts index dc0b0b364b3..e5feca1a013 100644 --- a/packages/schema/src/config/vite.ts +++ b/packages/schema/src/config/vite.ts @@ -1,8 +1,8 @@ import { resolve } from 'pathe' import { withoutLeadingSlash } from 'ufo' -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** * Configuration that will be passed directly to Vite. * diff --git a/packages/schema/src/config/webpack.ts b/packages/schema/src/config/webpack.ts index e8f5fa9bb29..42c6830aaba 100644 --- a/packages/schema/src/config/webpack.ts +++ b/packages/schema/src/config/webpack.ts @@ -1,7 +1,7 @@ import { join } from 'pathe' -import { defineSchemaObject } from '../utils' +import { defineUntypedSchema } from 'untyped' -export default defineSchemaObject({ +export default defineUntypedSchema({ /** @version 3 */ webpack: { /** diff --git a/packages/schema/src/utils.ts b/packages/schema/src/utils.ts deleted file mode 100644 index 6e5a3a36dcb..00000000000 --- a/packages/schema/src/utils.ts +++ /dev/null @@ -1,53 +0,0 @@ -//-- From Untyped -export type JSValue = string | number | bigint | boolean | symbol | Function | Array | undefined | object | null; -export type JSType = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'function' | 'object' | 'any' | 'array'; -export type ResolveFn = ((value: any, get: (key: string) => any) => JSValue); -export interface TypeDescriptor { - /** Used internally to handle schema types */ - type?: JSType | JSType[]; - /** Fully resolved correct TypeScript type for generated TS declarations */ - tsType?: string; - /** Human-readable type description for use in generated documentation */ - markdownType?: string; - items?: TypeDescriptor | TypeDescriptor[]; -} -export interface FunctionArg extends TypeDescriptor { - name?: string; - default?: JSValue; - optional?: boolean; -} -export interface Schema extends TypeDescriptor { - id?: string; - default?: JSValue; - resolve?: ResolveFn; - properties?: { - [key: string]: Schema; - }; - title?: string; - description?: string; - $schema?: string; - tags?: string[]; - args?: FunctionArg[]; - returns?: TypeDescriptor; -} -// -- - -export interface SchemaObject { - [key: string]: SchemaObject | JSValue; - $schema?: Schema; - $resolve?: ResolveFn; -} - -defineSchemaObject({ - test: '123', - foo: { - bar: '123', - baz: { - $resolve: (val, get) => val ?? get('test') - } - } -}) - -export function defineSchemaObject(input: SchemaObject): SchemaObject { - return input -} diff --git a/yarn.lock b/yarn.lock index 62c23ff1f2c..64ae347cd81 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1661,7 +1661,7 @@ __metadata: unbuild: latest unctx: ^2.0.1 unimport: ^0.6.7 - untyped: ^0.4.6 + untyped: ^0.4.7 languageName: unknown linkType: soft @@ -1688,7 +1688,7 @@ __metadata: ufo: ^0.8.5 unbuild: latest unimport: ^0.6.7 - untyped: ^0.4.6 + untyped: ^0.4.7 vite: ~3.0.9 languageName: unknown linkType: soft @@ -9995,7 +9995,7 @@ __metadata: unenv: ^0.6.1 unimport: ^0.6.7 unplugin: ^0.9.2 - untyped: ^0.4.6 + untyped: ^0.4.7 vue: ^3.2.37 vue-bundle-renderer: ^0.4.2 vue-devtools-stub: ^0.1.0 @@ -13209,15 +13209,15 @@ __metadata: languageName: node linkType: hard -"untyped@npm:^0.4.6": - version: 0.4.6 - resolution: "untyped@npm:0.4.6" +"untyped@npm:^0.4.7": + version: 0.4.7 + resolution: "untyped@npm:0.4.7" dependencies: "@babel/core": ^7.18.13 "@babel/standalone": ^7.18.13 "@babel/types": ^7.18.13 scule: ^0.3.2 - checksum: 3caf8c6c523dfc7f31282ebaaa70a42c24d8b1682f85953a891a89ef3e3dd75ba470a6a0904b8ec454c374e99f2f9c088e3e9aecc9964539ceb4dfc0366656db + checksum: d5b189b19e114c4d60e122da9234c68a93d71b312a64bd8303e3aaa96f7a677befa8519ce003dec8cb587ed3e5503046131532196257ed10e647bc741532b1bc languageName: node linkType: hard