Skip to content

Commit

Permalink
Pass the builder tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-raining committed Jan 9, 2025
1 parent 3dd9fed commit 9b29bf7
Show file tree
Hide file tree
Showing 18 changed files with 162 additions and 310 deletions.
23 changes: 23 additions & 0 deletions src/config/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
getEpubRootDir,
isInContainer,
isValidUri,
pathContains,
pathEquals,
readJSON,
statFileSync,
Expand Down Expand Up @@ -599,6 +600,27 @@ export function resolveTaskConfig(
cover,
});

// Check overwrites
for (const output of outputs) {
const relPath = upath.relative(context, output.path);
if (
pathContains(output.path, entryContextDir) ||
pathEquals(output.path, entryContextDir)
) {
throw new Error(
`The output path is set to "${relPath}", but this will overwrite the original manuscript file. Please specify a different path.`,
);
}
if (
pathContains(output.path, projectConfig.workspaceDir) ||
pathEquals(output.path, projectConfig.workspaceDir)
) {
throw new Error(

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (20, macos-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (20, macos-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (18, macos-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (18, macos-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (22, ubuntu-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (22, ubuntu-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (20, ubuntu-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (20, ubuntu-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (18, ubuntu-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (18, ubuntu-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (22, macos-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (22, macos-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (22, windows-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (22, windows-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (20, windows-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (20, windows-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (18, windows-latest)

tests/config.test.ts > imports a webbook compliant to W3C Web publication

Error: The output path is set to "w3c-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:275:24

Check failure on line 618 in src/config/resolve.ts

View workflow job for this annotation

GitHub Actions / build-and-test (18, windows-latest)

tests/config.test.ts > imports a webbook compliant to Readium Web publication

Error: The output path is set to "readium-webpub", but this will overwrite the working directory of Vivliostyle. Please specify a different path. ❯ Module.resolveTaskConfig src/config/resolve.ts:618:13 ❯ Module.getTaskConfig tests/command-util.ts:61:26 ❯ tests/config.test.ts:291:24
`The output path is set to "${relPath}", but this will overwrite the working directory of Vivliostyle. Please specify a different path.`,
);
}
}

const resolvedConfig = {
...projectConfig,
context,
Expand Down Expand Up @@ -876,6 +898,7 @@ function resolveComposedProjectConfig({
themesDir,
}),
) ?? [];
rootThemes.forEach((t) => themeIndexes.add(t));
const tocConfig = {
tocTitle: config.toc?.title ?? config?.tocTitle ?? TOC_TITLE,
target: upath.resolve(workspaceDir, config.toc?.htmlPath ?? TOC_FILENAME),
Expand Down
4 changes: 2 additions & 2 deletions src/config/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -671,9 +671,9 @@ export const BuildTask = v.pipe(
v.transform((input) =>
typeof input === 'string'
? { htmlPath: input }
: typeof input === 'boolean'
: input === true
? {}
: input,
: input || undefined,
),
v.description($`
Options for Table of Contents (ToC) documents.
Expand Down
20 changes: 0 additions & 20 deletions src/processor/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,23 +523,3 @@ export async function copyAssets({
await copy(upath.resolve(entryContextDir, asset), target);
}
}

export function checkOverwriteViolation(
{ entryContextDir, workspaceDir }: ResolvedTaskConfig,
target: string,
fileInformation: string,
) {
if (
pathContains(target, entryContextDir) ||
pathEquals(target, entryContextDir)
) {
throw new Error(
`${target} is set as output destination of ${fileInformation}, however, this output path will overwrite the manuscript file(s). Please specify other paths.`,
);
}
if (pathContains(target, workspaceDir) || pathEquals(target, workspaceDir)) {
throw new Error(
`${target} is set as output destination of ${fileInformation}, however, this output path will overwrite the working directory of Vivliostyle. Please specify other paths.`,
);
}
}
Loading

0 comments on commit 9b29bf7

Please sign in to comment.