Skip to content

Commit 4c7b5d2

Browse files
authored
fix(extension): quarto use template failed correctly copy extensions when scoped in organisation/owner name (#14010)
`quarto use template quarto-journals/acm` created an empty `_extensions` folder and installed no extension. The acm template keeps its extension under `_extensions/quarto-journals/acm/`, one level deeper than templates like jasa, and `useTemplate` passed the staged template root to `copyExtensions`, so it never found the extension. It now passes the template's `_extensions` directory, which it already reads to list the extensions to install. The smoke test runs for both jasa and acm and asserts that `_extensions/quarto-journals/<name>` exists after the command. Fixes #14008
1 parent 78877e0 commit 4c7b5d2

3 files changed

Lines changed: 59 additions & 40 deletions

File tree

‎news/changelog-1.11.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ All changes included in 1.11:
128128

129129
- ([#14960](https://github.com/quarto-dev/quarto-cli/issues/14960)): Fix `quarto check` failing when the project contains a directory it cannot read, for example when a stray `_quarto.yml` in the home directory makes the home directory a project. `quarto check` now reads only the project configuration, without scanning input files or creating a `.quarto` directory in the project root. `quarto check info` reports the project root and the `_quarto.yml` that set it (`info.project` in `--output` JSON), and warns when the project root is the home directory or a filesystem root. `quarto render` and `quarto preview` now report an unreadable directory in the project as one error naming the directory, the project root and its `_quarto.yml`, instead of a raw `readdir` error with a stack trace.
130130

131+
### `use template`
132+
133+
- ([#14008](https://github.com/quarto-dev/quarto-cli/issues/14008)): Fix `quarto use template` not installing the template's extensions when they are scoped by organisation, such as `quarto-journals/acm`. (author: @mcanouil)
134+
131135
## Extensions
132136

133137
- ([#14254](https://github.com/quarto-dev/quarto-cli/issues/14254)): Fix `quarto render` hanging when the input file is at the filesystem root. (author: @mcanouil)

‎src/command/use/commands/template.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ async function useTemplate(
157157
// Copy the extensions into a substaging directory
158158
// this will ensure that they are namespaced properly
159159
const subStagedDir = tempContext.createDir();
160-
await copyExtensions(source, stagedDir, subStagedDir);
160+
await copyExtensions(source, extDir, subStagedDir);
161161

162162
// Now complete installation from this sub-staged directory
163163
await completeInstallation(subStagedDir, outputDirectory);

‎tests/smoke/use/template.test.ts‎

Lines changed: 54 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,46 @@
11
import { testQuartoCmd } from "../../test.ts";
2-
import { directoryContainsOnlyAllowedPaths, fileExists, folderExists, noErrorsOrWarnings, printsMessage } from "../../verify.ts";
2+
import {
3+
directoryContainsOnlyAllowedPaths,
4+
fileExists,
5+
folderExists,
6+
noErrorsOrWarnings,
7+
printsMessage,
8+
} from "../../verify.ts";
39
import { join } from "../../../src/deno_ral/path.ts";
410
import { ensureDirSync } from "../../../src/deno_ral/fs.ts";
511

612
const tempDir = Deno.makeTempDirSync();
713

8-
const templateFolder = "article";
9-
const workingDir = join(tempDir, templateFolder);
10-
const extensionsDir = join(workingDir, "_extensions");
11-
ensureDirSync(workingDir);
12-
testQuartoCmd(
13-
"use",
14-
["template", "quarto-journals/jasa", "--no-prompt"],
15-
[noErrorsOrWarnings, fileExists(`${templateFolder}.qmd`), folderExists(extensionsDir)],
16-
{
17-
setup: () => {
18-
return Promise.resolve();
19-
},
20-
cwd: () => {
21-
return workingDir;
14+
for (const ext of ["jasa", "acm"]) {
15+
const templateFolder = `${ext}-article`;
16+
const workingDir = join(tempDir, templateFolder);
17+
const extensionDir = join(workingDir, "_extensions", "quarto-journals", ext);
18+
ensureDirSync(workingDir);
19+
testQuartoCmd(
20+
"use",
21+
["template", `quarto-journals/${ext}`, "--no-prompt"],
22+
[
23+
noErrorsOrWarnings,
24+
fileExists(`${templateFolder}.qmd`),
25+
folderExists(extensionDir),
26+
],
27+
{
28+
setup: () => {
29+
return Promise.resolve();
30+
},
31+
cwd: () => {
32+
return workingDir;
33+
},
34+
teardown: () => {
35+
try {
36+
Deno.removeSync(workingDir, { recursive: true });
37+
} catch {
38+
}
39+
return Promise.resolve();
40+
},
2241
},
23-
teardown: () => {
24-
try {
25-
Deno.removeSync(workingDir, {recursive: true});
26-
} catch {
27-
28-
}
29-
return Promise.resolve();
30-
}
31-
}
32-
)
42+
);
43+
}
3344

3445
const nonEmptyTemplateFolder = "notempty";
3546
const nonEmptyFileName = `${nonEmptyTemplateFolder}.qmd`;
@@ -39,25 +50,30 @@ ensureDirSync(nonEmptyWorkingDir);
3950
testQuartoCmd(
4051
"use",
4152
["template", "quarto-journals/jasa", "--no-prompt"],
42-
[printsMessage({level: "ERROR", regex: /directory isn't empty/}), directoryContainsOnlyAllowedPaths(nonEmptyWorkingDir, [nonEmptyFileName])],
53+
[
54+
printsMessage({ level: "ERROR", regex: /directory isn't empty/ }),
55+
directoryContainsOnlyAllowedPaths(nonEmptyWorkingDir, [nonEmptyFileName]),
56+
],
4357
{
4458
setup: () => {
45-
Deno.writeTextFileSync(join(nonEmptyWorkingDir, nonEmptyFileName), "Just making a non-empty file!");
59+
Deno.writeTextFileSync(
60+
join(nonEmptyWorkingDir, nonEmptyFileName),
61+
"Just making a non-empty file!",
62+
);
4663
return Promise.resolve();
4764
},
4865
cwd: () => {
4966
return nonEmptyWorkingDir;
5067
},
5168
teardown: () => {
5269
try {
53-
Deno.removeSync(nonEmptyWorkingDir, {recursive: true});
70+
Deno.removeSync(nonEmptyWorkingDir, { recursive: true });
5471
} catch {
55-
5672
}
57-
return Promise.resolve();
58-
}
59-
}
60-
)
73+
return Promise.resolve();
74+
},
75+
},
76+
);
6177

6278
const starterFolder = "starterFolder";
6379
const starterWorkingDir = join(tempDir, starterFolder);
@@ -75,11 +91,10 @@ testQuartoCmd(
7591
},
7692
teardown: () => {
7793
try {
78-
Deno.removeSync(starterWorkingDir, {recursive: true});
94+
Deno.removeSync(starterWorkingDir, { recursive: true });
7995
} catch {
80-
8196
}
82-
return Promise.resolve();
83-
}
84-
}
85-
)
97+
return Promise.resolve();
98+
},
99+
},
100+
);

0 commit comments

Comments
 (0)