Skip to content

Commit a382dd8

Browse files
committed
inspect - report installed extensions
1 parent 2ff847b commit a382dd8

File tree

18 files changed

+239
-27
lines changed

18 files changed

+239
-27
lines changed

news/changelog-1.8.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,10 @@ All changes included in 1.8:
3939

4040
## Lua Filters
4141

42-
- ([#12727](https://github.com/quarto-dev/quarto-cli/issues/12727)): Do not crash in the presence of malformed tabset contents.
42+
- ([#12727](https://github.com/quarto-dev/quarto-cli/issues/12727)): Do not crash in the presence of malformed tabset contents.
43+
44+
## Commands
45+
46+
### `inspect`
47+
48+
- ([#12733](https://github.com/quarto-dev/quarto-cli/issues/12733)): Add installed extensions to `quarto inspect` project report.

src/command/inspect/cmd.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
setInitializer,
1212
} from "../../core/lib/yaml-validation/state.ts";
1313
import { initYamlIntelligenceResourcesFromFilesystem } from "../../core/schema/utils.ts";
14-
import { inspectConfig } from "../../quarto-core/inspect.ts";
14+
import { inspectConfig } from "../../inspect/inspect.ts";
1515

1616
export const inspectCommand = new Command()
1717
.name("inspect")

src/quarto-core/inspect-types.ts renamed to src/inspect/inspect-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66

77
import { Format } from "../config/types.ts";
8+
import { Extension } from "../extension/types.ts";
89
import {
910
FileInclusion,
1011
ProjectConfig,
@@ -38,6 +39,7 @@ export interface InspectedProjectConfig extends InspectedConfig {
3839
dir: string;
3940
config: ProjectConfig;
4041
files: ProjectFiles;
42+
extensions: Extension[];
4143
}
4244

4345
export interface InspectedDocumentConfig extends InspectedConfig {

src/quarto-core/inspect.ts renamed to src/inspect/inspect.ts

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
resolveFileResources,
2121
resourcesFromMetadata,
2222
} from "../command/render/resources.ts";
23-
import { kLocalDevelopment, quartoConfig } from "../core/quarto.ts";
23+
import { quartoConfig } from "../core/quarto.ts";
2424

2525
import { cssFileResourceReferences } from "../core/css.ts";
2626
import {
@@ -31,7 +31,10 @@ import {
3131
} from "../project/project-shared.ts";
3232
import { normalizePath, safeExistsSync } from "../core/path.ts";
3333
import { kExtensionDir } from "../extension/constants.ts";
34-
import { extensionFilesFromDirs } from "../extension/extension.ts";
34+
import {
35+
createExtensionContext,
36+
extensionFilesFromDirs,
37+
} from "../extension/extension.ts";
3538
import { withRenderServices } from "../command/render/render-services.ts";
3639
import { notebookContext } from "../render/notebook/notebook-context.ts";
3740
import { RenderServices } from "../command/render/types.ts";
@@ -88,27 +91,9 @@ const inspectProjectConfig = async (context: ProjectContext) => {
8891
}
8992
const fileInformation: Record<string, InspectedFile> = {};
9093
for (const file of context.files.input) {
91-
const engine = await fileExecutionEngine(file, undefined, context);
92-
const src = await context.resolveFullMarkdownForFile(engine, file);
93-
if (engine) {
94-
const errors = await validateDocumentFromSource(
95-
src,
96-
engine.name,
97-
error,
98-
);
99-
if (errors.length) {
100-
throw new Error(`${file} is not a valid Quarto input document`);
101-
}
102-
}
103-
await projectResolveCodeCellsForFile(context, engine, file);
104-
await projectFileMetadata(context, file);
105-
fileInformation[file] = {
106-
includeMap: context.fileInformationCache.get(file)?.includeMap ??
107-
[],
108-
codeCells: context.fileInformationCache.get(file)?.codeCells ?? [],
109-
metadata: context.fileInformationCache.get(file)?.metadata ?? {},
110-
};
94+
await populateFileInformation(context, fileInformation, file);
11195
}
96+
const extensions = await populateExtensionInformation(context);
11297
const config: InspectedProjectConfig = {
11398
quarto: {
11499
version: quartoConfig.version(),
@@ -118,10 +103,50 @@ const inspectProjectConfig = async (context: ProjectContext) => {
118103
config: context.config,
119104
files: context.files,
120105
fileInformation,
106+
extensions: extensions,
121107
};
122108
return config;
123109
};
124110

111+
const populateExtensionInformation = async (
112+
context: ProjectContext,
113+
) => {
114+
const extensionContext = createExtensionContext();
115+
return await extensionContext.extensions(
116+
context.dir,
117+
context.config,
118+
context.dir,
119+
{ builtIn: false },
120+
);
121+
};
122+
123+
const populateFileInformation = async (
124+
context: ProjectContext,
125+
fileInformation: Record<string, InspectedFile>,
126+
file: string,
127+
) => {
128+
const engine = await fileExecutionEngine(file, undefined, context);
129+
const src = await context.resolveFullMarkdownForFile(engine, file);
130+
if (engine) {
131+
const errors = await validateDocumentFromSource(
132+
src,
133+
engine.name,
134+
error,
135+
);
136+
if (errors.length) {
137+
throw new Error(`${file} is not a valid Quarto input document`);
138+
}
139+
}
140+
await projectResolveCodeCellsForFile(context, engine, file);
141+
await projectFileMetadata(context, file);
142+
fileInformation[file] = {
143+
includeMap: context.fileInformationCache.get(file)?.includeMap ??
144+
[],
145+
codeCells: context.fileInformationCache.get(file)?.codeCells ?? [],
146+
metadata: context.fileInformationCache.get(file)?.metadata ?? {},
147+
};
148+
};
149+
125150
const inspectDocumentConfig = async (path: string) => {
126151
const nbContext = notebookContext();
127152
const project = await projectContext(path, nbContext) ||

src/project/project-shared.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import { createTempContext } from "../core/temp.ts";
3838
import { RenderContext, RenderFlags } from "../command/render/types.ts";
3939
import { LanguageCellHandlerOptions } from "../core/handlers/types.ts";
4040
import { ExecutionEngine } from "../execute/types.ts";
41-
import { InspectedMdCell } from "../quarto-core/inspect-types.ts";
41+
import { InspectedMdCell } from "../inspect/inspect-types.ts";
4242
import { breakQuartoMd, QuartoMdCell } from "../core/lib/break-quarto-md.ts";
4343
import { partitionCellOptionsText } from "../core/lib/partition-cell-options.ts";
4444
import { parse } from "../core/yaml.ts";

src/project/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Brand, LightDarkBrand } from "../core/brand/brand.ts";
1111
import { MappedString } from "../core/mapped-text.ts";
1212
import { PartitionedMarkdown } from "../core/pandoc/types.ts";
1313
import { ExecutionEngine, ExecutionTarget } from "../execute/types.ts";
14-
import { InspectedMdCell } from "../quarto-core/inspect-types.ts";
14+
import { InspectedMdCell } from "../inspect/inspect-types.ts";
1515
import { NotebookContext } from "../render/notebook/notebook-types.ts";
1616
import {
1717
NavigationItem as NavItem,

src/publish/publish.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import { projectOutputDir } from "../project/project-shared.ts";
3333
import { PublishRecord } from "../publish/types.ts";
3434
import { ProjectContext } from "../project/types.ts";
3535
import { renderProgress } from "../command/render/render-info.ts";
36-
import { inspectConfig, isDocumentConfig } from "../quarto-core/inspect.ts";
36+
import { inspectConfig, isDocumentConfig } from "../inspect/inspect.ts";
3737
import { kOutputFile, kTitle } from "../config/constants.ts";
3838
import { inputFilesDir } from "../core/render.ts";
3939
import {

src/resources/schema/definitions.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3026,3 +3026,5 @@
30263026
- string
30273027
- boolean
30283028
- number
3029+
3030+
# - id: quarto-extension
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/.quarto/
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# MODIFIED SOURCE -----------------------------------------------------------
2+
3+
Copyright (C) 2024 Garrick Aden-Buie
4+
AGPL v3: https://www.gnu.org/licenses/agpl-3.0.en.html
5+
6+
This program is free software: you can redistribute it and/or modify
7+
it under the terms of the GNU Affero General Public License as
8+
published by the Free Software Foundation, either version 3 of the
9+
License, or (at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU Affero General Public License for more details.
15+
16+
You should have received a copy of the GNU Affero General Public License
17+
along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
19+
20+
# ORIGINAL SOURCE -----------------------------------------------------------
21+
# https://ar.al/2021/08/24/implementing-dark-mode-in-a-handful-of-lines-of-css-with-css-filters/
22+
23+
Copyright (C) 2021 Aral Balkan
24+
AGPL v3: https://www.gnu.org/licenses/agpl-3.0.en.html
25+
26+
This program is free software: you can redistribute it and/or modify
27+
it under the terms of the GNU Affero General Public License as
28+
published by the Free Software Foundation, either version 3 of the
29+
License, or (at your option) any later version.
30+
31+
This program is distributed in the hope that it will be useful,
32+
but WITHOUT ANY WARRANTY; without even the implied warranty of
33+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34+
GNU Affero General Public License for more details.
35+
36+
You should have received a copy of the GNU Affero General Public License
37+
along with this program. If not, see <https://www.gnu.org/licenses/>.

0 commit comments

Comments
 (0)