Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"@types/pluralize": "^0.0.33",
"globby": "^10.0.2",
"type-fest": "^4.41.0",
"winston": "^3.17.0",
"zod": "^3.24.4"
"winston": "^3.17.0"
},
"dependencies": {
"@dotcom-tool-kit/base": "^1.3.0",
Expand All @@ -47,7 +46,8 @@
"pretty-format": "^29.7.0",
"tslib": "^2.8.1",
"yaml": "^2.8.0",
"zod-validation-error": "^3.4.1"
"zod": "^3.25.76",
"zod-validation-error": "^3.5.2"
},
"engines": {
"node": "18.x || 20.x || 22.x"
Expand Down
4 changes: 2 additions & 2 deletions core/cli/src/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {
OptionsForPlugin,
OptionsForTask
} from '@dotcom-tool-kit/plugin'
import type { z } from 'zod'
import { fromZodError } from 'zod-validation-error'
import type { z } from 'zod/v3'
import { fromZodError } from 'zod-validation-error/v3'
import type { Conflict } from '@dotcom-tool-kit/conflict'
import pluralize from 'pluralize'
import { ToolKitError } from '@dotcom-tool-kit/error'
Expand Down
2 changes: 1 addition & 1 deletion core/cli/src/plugin/entry-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Base } from '@dotcom-tool-kit/base'
import type { EntryPoint } from '@dotcom-tool-kit/plugin'
import { Validated, invalid, valid } from '@dotcom-tool-kit/validated'
import { __importDefault } from 'tslib'
import type * as z from 'zod'
import type * as z from 'zod/v3'
import { indentReasons } from '../messages'
import type { ReadonlyDeep } from 'type-fest'

Expand Down
2 changes: 1 addition & 1 deletion core/cli/src/plugin/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { type PluginOptions, PluginSchemas, legacyPluginOptions } from '@dotcom-
import { invalid, reduceValidated, valid, Validated } from '@dotcom-tool-kit/validated'

import type { Logger } from 'winston'
import * as z from 'zod'
import * as z from 'zod/v3'
import { styles } from '@dotcom-tool-kit/logger'

import { toolKitIfDefinedIdent, toolKitOptionIdent } from '../rc-file'
Expand Down
2 changes: 1 addition & 1 deletion core/cli/src/plugin/reduce-installations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { groupBy } from 'lodash'
import type { Logger } from 'winston'
import * as z from 'zod'
import * as z from 'zod/v3'

import type { HookClass, HookInstallation } from '@dotcom-tool-kit/base'
import type { ValidConfig } from '@dotcom-tool-kit/config'
Expand Down
2 changes: 1 addition & 1 deletion core/create/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"simple-git": "^3.27.0",
"tslib": "^2.8.1",
"yaml": "^2.8.0",
"zod": "^3.24.4"
"zod": "^3.25.76"
},
"repository": {
"type": "git",
Expand Down
8 changes: 6 additions & 2 deletions core/create/src/prompts/oidc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import path from 'path'
import prompt from 'prompts'
import { simpleGit } from 'simple-git'
import YAML from 'yaml'
import { z } from 'zod'
import { z } from 'zod/v3'

// git mode indicating an object blob is a file
const FILE_MODE = '100644' as const
Expand Down Expand Up @@ -254,7 +254,11 @@ export default async function oidcPrompt({ toolKitConfig }: OidcParams): Promise
// store path using the same logic we used to use to infer the name
// from Tool Kit vault plugin options. Pass in the options that were
// selected during the options prompt.
const dopplerProjectName = new DopplerEnvVars(winstonLogger, 'prod', toolKitConfig.options.plugins['@dotcom-tool-kit/doppler']).options.project
const dopplerProjectName = new DopplerEnvVars(
winstonLogger,
'prod',
toolKitConfig.options.plugins['@dotcom-tool-kit/doppler']
).options.project
const ssmAction = 'ssm:GetParameter'
const ssmResource = `arn:aws:ssm:eu-west-1:\${AWS::AccountId}:parameter/${dopplerProjectName}/*`
winstonLogger.info(
Expand Down
2 changes: 1 addition & 1 deletion core/create/src/prompts/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import YAML from 'yaml'
import type Logger from 'komatsu'
import partition from 'lodash/partition'
import prompt from 'prompts'
import { z } from 'zod'
import { z } from 'zod/v3'
import type { BizOpsSystem } from '../bizOps'

interface OptionSettings {
Expand Down
2 changes: 1 addition & 1 deletion docs/developing-tool-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ This lets different plugins define the same abstractly labelled hooks with diffe
Plugins can define options that a user can configure in their repo's `.toolkitrc.yml`. We use the [`zod` library](https://zod.dev) to specify the schema, which allows us to define what we expect the options to look like and use this specification to validate the options we receive as well as generate TypeScript types for them. Options are defined within plugins. For tasks and hooks you should export the `zod` schema in the same file as you export your `Task` or `Hook` class as a `schema` object. For plugin options you should define the `zod` schema in a separate file, export it as the default object, and add the path to your `.toolkitrc.yml` with the top-level `optionsSchema` option.

```typescript
import { z } from 'zod'
import { z } from 'zod/v3'

const ESLintSchema = z.object({
files: z.string().array().default(['**/*.js']),
Expand Down
2 changes: 1 addition & 1 deletion docs/extending-tool-kit.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ options:
Additionally, we can define an options schema to ensure that the options passed to task are as we expect them to be, with the correct names and correct types. We use [`zod`](https://zod.dev/) to define our schemas. For plugin options, you should export your schema as the default object in a separate file and specify its path as a top-level `optionsSchema` option in your `.toolkitrc.yml`. For tasks and hooks, you should export your schema as a `schema` object in the same file as you export your task/hook. We could define a `zod` schema for the Rollup task like so:

```js
const z = require('zod')
const z = require('zod/v3')

const RollupSchema = z.object({ configPath: z.string() })
module.exports.schema = RollupSchema
Expand Down
3 changes: 2 additions & 1 deletion jest.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ module.exports.config = {
snapshotSerializers: [
'@relmify/jest-serializer-strip-ansi/always',
path.resolve(__dirname, './jest/serializers/aggregate-error.js'),
path.resolve(__dirname, './jest/serializers/tool-kit-error.js')
path.resolve(__dirname, './jest/serializers/tool-kit-error.js'),
path.resolve(__dirname, './jest/serializers/zod-error.js')
],
transform: {
'^.+\\.tsx?$': ['ts-jest', tsJestConfig]
Expand Down
9 changes: 9 additions & 0 deletions jest/serializers/zod-error.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
test(value) {
return value instanceof Error && value.name === 'ZodError'
},

serialize(val, config, indentation, depth, refs, printer) {
return `ZodError ${printer(val.issues, config, indentation, depth, refs)}`
}
}
4 changes: 2 additions & 2 deletions lib/base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"@dotcom-tool-kit/plugin": "^1.1.0",
"type-fest": "^4.41.0",
"winston": "^3.17.0",
"zod": "^3.24.4"
"zod": "^3.25.76"
},
"peerDependencies": {
"zod": "^3.24.4"
"zod": "^3.25.76"
}
}
2 changes: 1 addition & 1 deletion lib/base/src/hook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Logger } from 'winston'
import { Base } from './base'
import { hookSymbol, typeSymbol } from './symbols'
import type { z } from 'zod'
import type { z } from 'zod/v3'
import type { Plugin } from '@dotcom-tool-kit/plugin'
import { Conflict, isConflict } from '@dotcom-tool-kit/conflict'
import type { Default } from './type-utils'
Expand Down
2 changes: 1 addition & 1 deletion lib/base/src/task.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { z } from 'zod'
import type { z } from 'zod/v3'
import { Base } from './base'
import { taskSymbol, typeSymbol } from './symbols'
import type { Logger } from 'winston'
Expand Down
2 changes: 1 addition & 1 deletion lib/doppler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@dotcom-tool-kit/error": "^4.1.1",
"@dotcom-tool-kit/logger": "^4.2.2",
"tslib": "^2.8.1",
"zod": "^3.24.4"
"zod": "^3.25.76"
},
"keywords": [],
"author": "FT.com Platforms Team <platforms-team.customer-products@ft.com>",
Expand Down
2 changes: 1 addition & 1 deletion lib/doppler/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { spawn } from 'node:child_process'

import type { Logger } from 'winston'
import type * as z from 'zod'
import type * as z from 'zod/v3'

import { ToolKitError } from '@dotcom-tool-kit/error'
import { styles, waitOnExit } from '@dotcom-tool-kit/logger'
Expand Down
2 changes: 1 addition & 1 deletion lib/doppler/src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as z from 'zod'
import * as z from 'zod/v3'

// In theory, these fields should be required as Doppler won't work without them,
// but not every app that pulls in the Doppler plugin actually needs to use
Expand Down
2 changes: 1 addition & 1 deletion lib/plugin/src/root-schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as z from 'zod'
import * as z from 'zod/v3'

export const RootSchema = z.object({
allowNativeFetch: z.boolean().default(false)
Expand Down
Loading