Skip to content

Commit

Permalink
Merge branch 'fix/public-env' of github.com:island-is/island.is into …
Browse files Browse the repository at this point in the history
…fix/public-env
  • Loading branch information
busla committed Oct 22, 2024
2 parents 58ba7fa + 0ed1ae9 commit 2a4ee91
Show file tree
Hide file tree
Showing 7 changed files with 233 additions and 78 deletions.
2 changes: 1 addition & 1 deletion infra/src/common/nx-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const nxCommand = async <T>(options: {
}

// If not parsing JSON, return raw stdout
return (stdout as unknown) as T
return stdout as unknown as T
} catch (error) {
handleNxCommandError(error)
throw error
Expand Down
5 changes: 2 additions & 3 deletions infra/src/dsl/output-generators/map-to-helm-values.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,8 @@ function serializeIngress(
ingressConf: IngressForEnv,
env: EnvironmentConfig,
) {
const hosts = (typeof ingressConf.host === 'string'
? [ingressConf.host]
: ingressConf.host
const hosts = (
typeof ingressConf.host === 'string' ? [ingressConf.host] : ingressConf.host
).map((host) =>
ingressConf.public ?? true
? hostFullName(host, env)
Expand Down
9 changes: 3 additions & 6 deletions infra/src/dsl/service-to-environment/pre-process-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,12 +306,9 @@ function addFeaturesConfig(
env: EnvironmentConfig,
serviceName: string,
) {
const activeFeatures = Object.entries(
serviceDefFeatures,
).filter(([feature]) => env.featuresOn.includes(feature as FeatureNames)) as [
FeatureNames,
Feature,
][]
const activeFeatures = Object.entries(serviceDefFeatures).filter(
([feature]) => env.featuresOn.includes(feature as FeatureNames),
) as [FeatureNames, Feature][]
const featureEnvs = activeFeatures.map(([name, v]) => {
const { envs, errors } = getEnvVariables(v.env, serviceName, env.type)
return {
Expand Down
8 changes: 3 additions & 5 deletions infra/src/dsl/types/input-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,9 @@ export interface Ingress {
}
paths: string[]
public?: boolean
extraAnnotations?: Partial<
{
[env in OpsEnv]: { [annotation: string]: string | null }
}
>
extraAnnotations?: Partial<{
[env in OpsEnv]: { [annotation: string]: string | null }
}>
}

export interface IngressForEnv {
Expand Down
12 changes: 6 additions & 6 deletions infra/src/dsl/value-files-generators/local-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ export const mapServiceToNXname = async (

if (!validatedProjectMeta.name || !validatedProjectMeta.sourceRoot) {
throw new Error(
`Project metadata is missing required fields: name or sourceRoot.`
);
`Project metadata is missing required fields: name or sourceRoot.`,
)
}

return {
serviceName: validatedProjectMeta.name,
projectPath: validatedProjectMeta.sourceRoot,
};
}
} catch (error) {
logger.error('Error in mapServiceToNXname:', error);
logger.error('Error in mapServiceToNXname:', error)

if (error instanceof Error) {
throw new Error(`Unexpected error: ${error.message}`);
throw new Error(`Unexpected error: ${error.message}`)
}
throw new Error('An unknown error occurred.');
throw new Error('An unknown error occurred.')
}
}

Expand Down
272 changes: 216 additions & 56 deletions infra/src/generated/nx-project-schema.ts
Original file line number Diff line number Diff line change
@@ -1,60 +1,220 @@
// This file is auto-generated. Do not edit directly.

import { z } from "zod"
import { z } from 'zod'

export const nxProjectSchema = z.object({ "name": z.string().describe("Project's name. Optional if specified in workspace.json").optional(), "root": z.string().describe("Project's location relative to the root of the workspace").optional(), "sourceRoot": z.string().describe("The location of project's sources relative to the root of the workspace").optional(), "projectType": z.enum(["library","application"]).describe("Type of project supported").optional(), "generators": z.record(z.any()).describe("List of default values used by generators").optional(), "namedInputs": z.record(z.any()).describe("Named inputs used by inputs defined in targets").optional(), "targets": z.record(z.object({ "executor": z.string().describe("The function that Nx will invoke when you run this target").optional(), "options": z.record(z.any()).optional(), "outputs": z.array(z.string()).optional(), "defaultConfiguration": z.string().describe("The name of a configuration to use as the default if a configuration is not provided").optional(), "configurations": z.record(z.record(z.any())).describe("provides extra sets of values that will be merged into the options map").optional(), "inputs": z.any().optional(), "dependsOn": z.array(z.any().superRefine((x, ctx) => {
const schemas = [z.string(), z.object({ "projects": z.any().superRefine((x, ctx) => {
const schemas = [z.string().describe("A project name"), z.array(z.string()).describe("An array of project names")];
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
((result) =>
result.error ? [...errors, result.error] : errors)(
schema.safeParse(x),
),
[],
);
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: "invalid_union",
unionErrors: errors,
message: "Invalid input: Should pass single schema",
});
}
}).optional(), "dependencies": z.boolean().optional(), "target": z.string().describe("The name of the target.").optional(), "params": z.enum(["ignore","forward"]).describe("Configuration for params handling.").default("ignore") }).strict().and(z.any().superRefine((x, ctx) => {
const schemas = [z.any(), z.any(), z.any().refine((value) => !z.union([z.any(), z.any()]).safeParse(value).success, "Invalid input: Should NOT be valid against schema")];
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
((result) =>
result.error ? [...errors, result.error] : errors)(
schema.safeParse(x),
),
[],
);
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: "invalid_union",
unionErrors: errors,
message: "Invalid input: Should pass single schema",
});
}
}))];
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
((result) =>
result.error ? [...errors, result.error] : errors)(
schema.safeParse(x),
),
[],
);
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: "invalid_union",
unionErrors: errors,
message: "Invalid input: Should pass single schema",
});
}
})).optional(), "command": z.string().describe("A shorthand for using the nx:run-commands executor").optional(), "cache": z.boolean().describe("Specifies if the given target should be cacheable").optional(), "parallelism": z.boolean().describe("Whether this target can be run in parallel with other tasks").default(true), "metadata": z.object({ "description": z.string().describe("A description of the target").optional() }).catchall(z.any()).describe("Metadata about the target").optional(), "syncGenerators": z.array(z.string()).describe("List of generators to run before the target to ensure the workspace is up to date").optional() })).describe("Configures all the targets which define what tasks you can run against the project").optional(), "tags": z.array(z.string()).optional(), "implicitDependencies": z.array(z.string()).optional(), "metadata": z.object({ "description": z.string().describe("A description of the project.").optional() }).catchall(z.any()).describe("Metadata about the project.").optional(), "release": z.object({ "version": z.object({ "generator": z.string().describe("The version generator to use. Defaults to @nx/js:release-version.").optional(), "generatorOptions": z.record(z.any()).describe("Options for the version generator.").optional() }).describe("Configuration for the nx release version command.").optional() }).describe("Configuration for the nx release commands.").optional() })
export const nxProjectSchema = z.object({
name: z
.string()
.describe("Project's name. Optional if specified in workspace.json")
.optional(),
root: z
.string()
.describe("Project's location relative to the root of the workspace")
.optional(),
sourceRoot: z
.string()
.describe(
"The location of project's sources relative to the root of the workspace",
)
.optional(),
projectType: z
.enum(['library', 'application'])
.describe('Type of project supported')
.optional(),
generators: z
.record(z.any())
.describe('List of default values used by generators')
.optional(),
namedInputs: z
.record(z.any())
.describe('Named inputs used by inputs defined in targets')
.optional(),
targets: z
.record(
z.object({
executor: z
.string()
.describe('The function that Nx will invoke when you run this target')
.optional(),
options: z.record(z.any()).optional(),
outputs: z.array(z.string()).optional(),
defaultConfiguration: z
.string()
.describe(
'The name of a configuration to use as the default if a configuration is not provided',
)
.optional(),
configurations: z
.record(z.record(z.any()))
.describe(
'provides extra sets of values that will be merged into the options map',
)
.optional(),
inputs: z.any().optional(),
dependsOn: z
.array(
z.any().superRefine((x, ctx) => {
const schemas = [
z.string(),
z
.object({
projects: z
.any()
.superRefine((x, ctx) => {
const schemas = [
z.string().describe('A project name'),
z
.array(z.string())
.describe('An array of project names'),
]
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
((result) =>
result.error
? [...errors, result.error]
: errors)(schema.safeParse(x)),
[],
)
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: 'invalid_union',
unionErrors: errors,
message: 'Invalid input: Should pass single schema',
})
}
})
.optional(),
dependencies: z.boolean().optional(),
target: z
.string()
.describe('The name of the target.')
.optional(),
params: z
.enum(['ignore', 'forward'])
.describe('Configuration for params handling.')
.default('ignore'),
})
.strict()
.and(
z.any().superRefine((x, ctx) => {
const schemas = [
z.any(),
z.any(),
z
.any()
.refine(
(value) =>
!z.union([z.any(), z.any()]).safeParse(value)
.success,
'Invalid input: Should NOT be valid against schema',
),
]
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
((result) =>
result.error ? [...errors, result.error] : errors)(
schema.safeParse(x),
),
[],
)
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: 'invalid_union',
unionErrors: errors,
message: 'Invalid input: Should pass single schema',
})
}
}),
),
]
const errors = schemas.reduce<z.ZodError[]>(
(errors, schema) =>
((result) =>
result.error ? [...errors, result.error] : errors)(
schema.safeParse(x),
),
[],
)
if (schemas.length - errors.length !== 1) {
ctx.addIssue({
path: ctx.path,
code: 'invalid_union',
unionErrors: errors,
message: 'Invalid input: Should pass single schema',
})
}
}),
)
.optional(),
command: z
.string()
.describe('A shorthand for using the nx:run-commands executor')
.optional(),
cache: z
.boolean()
.describe('Specifies if the given target should be cacheable')
.optional(),
parallelism: z
.boolean()
.describe(
'Whether this target can be run in parallel with other tasks',
)
.default(true),
metadata: z
.object({
description: z
.string()
.describe('A description of the target')
.optional(),
})
.catchall(z.any())
.describe('Metadata about the target')
.optional(),
syncGenerators: z
.array(z.string())
.describe(
'List of generators to run before the target to ensure the workspace is up to date',
)
.optional(),
}),
)
.describe(
'Configures all the targets which define what tasks you can run against the project',
)
.optional(),
tags: z.array(z.string()).optional(),
implicitDependencies: z.array(z.string()).optional(),
metadata: z
.object({
description: z
.string()
.describe('A description of the project.')
.optional(),
})
.catchall(z.any())
.describe('Metadata about the project.')
.optional(),
release: z
.object({
version: z
.object({
generator: z
.string()
.describe(
'The version generator to use. Defaults to @nx/js:release-version.',
)
.optional(),
generatorOptions: z
.record(z.any())
.describe('Options for the version generator.')
.optional(),
})
.describe('Configuration for the nx release version command.')
.optional(),
})
.describe('Configuration for the nx release commands.')
.optional(),
})
export type NxProjectSchema = z.infer<typeof nxProjectSchema>
3 changes: 2 additions & 1 deletion infra/src/uber-charts/islandis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ const downloadService = downloadServiceSetup({
const userNotificationWorkerService = userNotificationWorkerSetup({
userProfileApi: servicePortalApi,
})
const userNotificationCleanupWorkerService = userNotificationCleanUpWorkerSetup()
const userNotificationCleanupWorkerService =
userNotificationCleanUpWorkerSetup()

const githubActionsCache = githubActionsCacheSetup()

Expand Down

0 comments on commit 2a4ee91

Please sign in to comment.