Skip to content

Commit

Permalink
Attempt to fix builds in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
MaddyGuthridge committed Aug 30, 2024
1 parent c6f9e6d commit 2b6be8a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"license": "GPL-3.0-only",
"scripts": {
"dev": "vite dev",
"build": "vite build",
"build": "svelte-kit sync && vite build",
"preview": "vite preview",
"test": "vitest",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
Expand Down
8 changes: 4 additions & 4 deletions src/lib/server/data/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getDataDir } from './dataDir';
import { version } from '$app/environment';

/** Path to config.json */
const CONFIG_JSON = `${getDataDir()}/config.json`;
const CONFIG_JSON = () => `${getDataDir()}/config.json`;

/** Validator for config.json file */
export const ConfigJsonStruct = object({
Expand Down Expand Up @@ -34,15 +34,15 @@ export type ConfigJson = Infer<typeof ConfigJsonStruct>;
* This does not validate any of the data.
*/
export async function getConfigVersion(): Promise<string> {
const data = JSON.parse(await readFile(CONFIG_JSON, { encoding: 'utf-8' }));
const data = JSON.parse(await readFile(CONFIG_JSON(), { encoding: 'utf-8' }));

// Note: v0.1.0 did not have a version number in the file
return data.version ?? '0.1.0';
}

/** Return the configuration, stored in `/data/config.json` */
export async function getConfig(): Promise<ConfigJson> {
const data = await readFile(CONFIG_JSON, { encoding: 'utf-8' });
const data = await readFile(CONFIG_JSON(), { encoding: 'utf-8' });

// Validate data
const [err, parsed] = validate(JSON.parse(data), ConfigJsonStruct);
Expand All @@ -57,7 +57,7 @@ export async function getConfig(): Promise<ConfigJson> {

/** Update the configuration, stored in `/data/config.json` */
export async function setConfig(newConfig: ConfigJson) {
await writeFile(CONFIG_JSON, JSON.stringify(newConfig, undefined, 2));
await writeFile(CONFIG_JSON(), JSON.stringify(newConfig, undefined, 2));
}

/** Set up the default server configuration */
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/data/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { mkdir, readdir, readFile, writeFile } from 'fs/promises';
import { array, enums, intersection, nullable, object, string, type, validate, type Infer } from 'superstruct';
import { array, nullable, string, type, validate, type Infer } from 'superstruct';
import { getDataDir } from './dataDir';
import { rimraf } from 'rimraf';
import formatTemplate from '../formatTemplate';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/server/data/item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { mkdir, readdir, readFile, writeFile } from 'fs/promises';
import { array, intersection, object, optional, nullable, string, tuple, type, validate, type Infer, enums } from 'superstruct';
import { array, intersection, object, nullable, string, tuple, type, validate, type Infer, enums } from 'superstruct';
import { getDataDir } from './dataDir';
import { rimraf } from 'rimraf';
import { RepoInfoStruct } from './itemRepo';
Expand Down
6 changes: 3 additions & 3 deletions src/lib/server/data/localConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { nullable, number, object, record, string, validate, type Infer } from '
import { getDataDir } from './dataDir';

/** Path to config.local.json */
const CONFIG_LOCAL_JSON = `${getDataDir()}/config.local.json`;
const CONFIG_LOCAL_JSON = () => `${getDataDir()}/config.local.json`;

/**
* Validator for config.local.json file
Expand Down Expand Up @@ -63,7 +63,7 @@ export async function getLocalConfig(): Promise<ConfigLocalJson> {
if (localConfigCache) {
return localConfigCache;
}
const data = await readFile(CONFIG_LOCAL_JSON, { encoding: 'utf-8' });
const data = await readFile(CONFIG_LOCAL_JSON(), { encoding: 'utf-8' });

// Validate data
const [err, parsed] = validate(JSON.parse(data), ConfigLocalJsonStruct);
Expand All @@ -81,7 +81,7 @@ export async function getLocalConfig(): Promise<ConfigLocalJson> {
/** Update the local configuration, stored in `/data/config.local.json` */
export async function setLocalConfig(newConfig: ConfigLocalJson) {
localConfigCache = newConfig;
await writeFile(CONFIG_LOCAL_JSON, JSON.stringify(newConfig, undefined, 2));
await writeFile(CONFIG_LOCAL_JSON(), JSON.stringify(newConfig, undefined, 2));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/lib/server/data/readme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ want to [learn Markdown](https://www.markdownguide.org/basic-syntax/).
`.trimStart();

/** Path to README.md */
const README_MD = `${getDataDir()}/README.md`;
const README_MD = () => `${getDataDir()}/README.md`;

/** Return the readme file */
export async function getReadme(): Promise<string> {
return readFile(README_MD, { encoding: 'utf-8' });
return readFile(README_MD(), { encoding: 'utf-8' });
}

/** Update the readme file */
export async function setReadme(newReadme: string) {
await writeFile(README_MD, newReadme);
await writeFile(README_MD(), newReadme);
}

/** Set up the default server README */
Expand Down

0 comments on commit 2b6be8a

Please sign in to comment.