diff --git a/package.json b/package.json index 312fc32..bff8ff3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@subsquid/manifest", "type": "commonjs", - "version": "2.0.0-beta.13", + "version": "2.0.0-beta.14", "homepage": "https://www.subsquid.io", "repository": "https://github.com/subsquid/manifest.git", "license": "GPL-3.0-or-later", diff --git a/src/manifest.ts b/src/manifest.ts index 8e9e79a..507c766 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -45,97 +45,7 @@ export class Manifest { delete this.deploy.migrate; } - if (this.scale) { - defaultsDeep(this, >{ - scale: { - dedicated: true, - }, - }); - } - - if (this.deploy?.api) { - defaultsDeep(this, >{ - scale: { - api: { - replicas: 1, - profile: 'small', - }, - }, - }); - } - - if (this.deploy?.processor) { - defaultsDeep(this, { - scale: { - processor: { - profile: 'small', - }, - }, - }); - } - - if (this.deploy?.addons?.postgres) { - defaultsDeep(this, >{ - deploy: { - addons: { - postgres: { - config: {}, - }, - }, - init: { - cmd: [...DEFAULT_MIGRATION], - }, - }, - scale: { - addons: { - postgres: { - storage: '10Gi', - profile: 'small', - default_storage: !this.scale?.addons?.postgres?.storage, - }, - }, - }, - }); - } - - if (this.deploy?.addons?.neon) { - defaultsDeep(this, >{ - deploy: { - addons: { - neon: {}, - }, - init: { - cmd: [...DEFAULT_MIGRATION], - }, - }, - scale: { - addons: { - neon: { - autoscaling_limit_min_cu: '0.25', - autoscaling_limit_max_cu: '0.25', - }, - }, - }, - }); - } - - if (this.deploy?.addons?.hasura) { - defaultsDeep(this, { - deploy: { - addons: { - hasura: {}, - }, - }, - scale: { - addons: { - hasura: { - replicas: 1, - profile: 'small', - }, - }, - }, - }); - } + Manifest.setDefaults(this); } squidName() { @@ -325,6 +235,98 @@ export class Manifest { }, }); } + + static setDefaults(manifest: Partial) { + defaultsDeep(manifest, >{ + scale: { + dedicated: true, + }, + }); + + if (manifest.deploy?.api) { + defaultsDeep(manifest, >{ + scale: { + api: { + replicas: 1, + profile: 'small', + }, + }, + }); + } + + if (manifest.deploy?.processor) { + defaultsDeep(manifest, { + scale: { + processor: { + profile: 'small', + }, + }, + }); + } + + if (manifest.deploy?.addons?.postgres) { + defaultsDeep(manifest, >{ + deploy: { + addons: { + postgres: { + config: {}, + }, + }, + init: { + cmd: [...DEFAULT_MIGRATION], + }, + }, + scale: { + addons: { + postgres: { + storage: '10Gi', + profile: 'small', + default_storage: !manifest.scale?.addons?.postgres?.storage, + }, + }, + }, + }); + } + + if (manifest.deploy?.addons?.neon) { + defaultsDeep(manifest, >{ + deploy: { + addons: { + neon: {}, + }, + init: { + cmd: [...DEFAULT_MIGRATION], + }, + }, + scale: { + addons: { + neon: { + autoscaling_limit_min_cu: '0.25', + autoscaling_limit_max_cu: '0.25', + }, + }, + }, + }); + } + + if (manifest.deploy?.addons?.hasura) { + defaultsDeep(this, { + deploy: { + addons: { + hasura: {}, + }, + }, + scale: { + addons: { + hasura: { + replicas: 1, + profile: 'small', + }, + }, + }, + }); + } + } } function getError(path: string, expression: string | undefined, error: unknown) {