Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions news/changelog-1.7.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
All changes included in 1.7:

## Regression fixes

- ([#11532](https://github.com/quarto-dev/quarto-cli/issues/11532)): Fix regression for [#660](https://github.com/quarto-dev/quarto-cli/issues/660), which causes files to have incorrect permissions when Quarto is installed in a location not writable by the current user.
4 changes: 3 additions & 1 deletion package/src/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { info } from "../../../src/deno_ral/log.ts";

import { getEnv } from "../util/utils.ts";

import { os as platformOs } from "../../../src/deno_ral/platform.ts"

// The core configuration for the packaging process
export interface Configuration extends PlatformConfiguration {
productName: string;
Expand Down Expand Up @@ -87,7 +89,7 @@ export function readConfiguration(



const cmdOs = os || getEnv("QUARTO_OS", Deno.build.os);
const cmdOs = os || getEnv("QUARTO_OS", platformOs);
if (!kValidOS.includes(cmdOs)) {
throw new Error(
`Invalid OS ${os} provided. Please use one of ${kValidOS.join(",")}`,
Expand Down
3 changes: 2 additions & 1 deletion package/src/common/configure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from "./dependencies/dependencies.ts";
import { suggestUserBinPaths } from "../../../src/core/path.ts";
import { buildQuartoPreviewJs } from "../../../src/core/previewjs.ts";
import { isWindows } from "../../../src/deno_ral/platform.ts";

export async function configure(
config: Configuration,
Expand Down Expand Up @@ -160,7 +161,7 @@ export function copyPandocScript(config: Configuration, targetDir: string) {
Deno.removeSync(pandocFile);
}

if (Deno.build.os !== "windows") {
if (!isWindows) {
info("> creating pandoc symlink");
Deno.run({
cwd: targetDir,
Expand Down
3 changes: 2 additions & 1 deletion package/src/util/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*
*/
import { info } from "../../../src/deno_ral/log.ts";
import { isWindows } from "../../../src/deno_ral/platform.ts";
import { Configuration } from "../common/config.ts";

export async function bundle(
Expand Down Expand Up @@ -132,7 +133,7 @@ export function updateDenoPath(installPath: string, _config: Configuration) {
if (!denoExecPath) {
throw Error("QUARTO_DENO is not defined");
}
const finalTxt = Deno.build.os === "windows"
const finalTxt = isWindows
? installTxt.replace(
/deno.exe /g,
denoExecPath + " ",
Expand Down
3 changes: 2 additions & 1 deletion package/src/util/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { writeAll } from "io/write-all";
import { CmdResult, runCmd } from "./cmd.ts";
import { isWindows } from "../../../src/deno_ral/platform.ts";

// Read an environment variable
export function getEnv(name: string, defaultValue?: string) {
Expand Down Expand Up @@ -31,7 +32,7 @@ export async function unzip(
zipFile: string,
dest: string,
): Promise<CmdResult> {
if (Deno.build.os === "windows") {
if (isWindows) {
return await runCmd("PowerShell", [
"Expand-Archive",
"-Path",
Expand Down
3 changes: 2 additions & 1 deletion src/command/check/check.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import { dirname } from "../../deno_ral/path.ts";
import { notebookContext } from "../../render/notebook/notebook-context.ts";
import { typstBinaryPath } from "../../core/typst.ts";
import { quartoCacheDir } from "../../core/appdirs.ts";
import { isWindows } from "../../deno_ral/platform.ts";

const kIndent = " ";

Expand Down Expand Up @@ -176,7 +177,7 @@ async function checkInstall(services: RenderServices) {
}
}
info(`${kIndent}Path: ${quartoConfig.binPath()}`);
if (Deno.build.os === "windows") {
if (isWindows) {
try {
const codePage = readCodePage();
clearCodePageCache();
Expand Down
15 changes: 8 additions & 7 deletions src/command/create/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {

import { basename, dirname, join } from "../../deno_ral/path.ts";
import { existsSync } from "../../deno_ral/fs.ts";
import { isMac, isWindows } from "../../deno_ral/platform.ts";

export interface Editor {
// A short, command line friendly id
Expand Down Expand Up @@ -104,7 +105,7 @@ function vscodeEditorInfo(): EditorInfo {
actions: [],
};

if (Deno.build.os === "windows") {
if (isWindows) {
editorInfo.actions.push({
action: "which",
arg: "code.exe",
Expand All @@ -118,7 +119,7 @@ function vscodeEditorInfo(): EditorInfo {
},
);
editorInfo.actions.push(...pathActions);
} else if (Deno.build.os === "darwin") {
} else if (isMac) {
editorInfo.actions.push({
action: "which",
arg: "code",
Expand Down Expand Up @@ -168,7 +169,7 @@ function positronEditorInfo(): EditorInfo {
actions: [],
};

if (Deno.build.os === "windows") {
if (isWindows) {
editorInfo.actions.push({
action: "which",
arg: "Positron.exe",
Expand All @@ -182,7 +183,7 @@ function positronEditorInfo(): EditorInfo {
},
);
editorInfo.actions.push(...pathActions);
} else if (Deno.build.os === "darwin") {
} else if (isMac) {
editorInfo.actions.push({
action: "which",
arg: "positron",
Expand Down Expand Up @@ -223,7 +224,7 @@ function rstudioEditorInfo(): EditorInfo {
const rProjPath = join(cwd, `${artifactName}.Rproj`);
Deno.writeTextFileSync(rProjPath, kRProjContents);

const cmd = path.endsWith(".app") && Deno.build.os === "darwin"
const cmd = path.endsWith(".app") && isMac
? ["open", "-na", path, "--args", rProjPath]
: [path, rProjPath];

Expand All @@ -239,7 +240,7 @@ function rstudioEditorInfo(): EditorInfo {
};

const rstudioExe = "rstudio.exe";
if (Deno.build.os === "windows") {
if (isWindows) {
editorInfo.actions.push({
action: "env",
arg: "RS_RPOSTBACK_PATH",
Expand All @@ -257,7 +258,7 @@ function rstudioEditorInfo(): EditorInfo {
},
);
editorInfo.actions.push(...paths);
} else if (Deno.build.os === "darwin") {
} else if (isMac) {
const paths = macosAppPaths("RStudio.app").map((path) => {
return {
action: "path",
Expand Down
3 changes: 2 additions & 1 deletion src/command/render/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ import { shortUuid } from "../../core/uuid.ts";
import { isServerShinyPython } from "../../core/render.ts";
import { pythonExec } from "../../core/jupyter/exec.ts";
import { kTocIndent } from "../../config/constants.ts";
import { isWindows } from "../../deno_ral/platform.ts";

const kQuartoParams = "quarto-params";

Expand Down Expand Up @@ -700,7 +701,7 @@ async function extensionShortcodes(options: PandocOptions) {

function initFilterParams(dependenciesFile: string) {
const params: Metadata = {};
if (Deno.build.os === "windows") {
if (isWindows) {
const value = readCodePage();
if (value) {
debug("Windows: Using code page " + value);
Expand Down
3 changes: 2 additions & 1 deletion src/command/render/latexmk/pdf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
} from "./parse-error.ts";
import { error, info, warning } from "../../../deno_ral/log.ts";
import { logProgress } from "../../../core/log.ts";
import { isWindows } from "../../../deno_ral/platform.ts";

export async function generatePdf(mkOptions: LatexmkOptions): Promise<string> {
if (!mkOptions.quiet) {
Expand Down Expand Up @@ -369,7 +370,7 @@ async function makeBibliographyIntermediates(
// If we're on windows and auto-install isn't enabled,
// fix up the aux file
//
if (Deno.build.os === "windows") {
if (isWindows) {
if (bibCommand !== "biber" && !hasTexLive()) {
// See https://github.com/rstudio/tinytex/blob/b2d1bae772f3f979e77fca9fb5efda05855b39d2/R/latex.R#L284
// Strips the '.bib' from any match and returns the string without the bib extension
Expand Down
3 changes: 2 additions & 1 deletion src/command/render/latexmk/texlive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { requireQuoting, safeWindowsExec } from "../../../core/windows.ts";
import { hasTinyTex, tinyTexBinDir } from "../../../tools/impl/tinytex-info.ts";
import { join } from "../../../deno_ral/path.ts";
import { logProgress } from "../../../core/log.ts";
import { isWindows } from "../../../deno_ral/platform.ts";

export interface TexLiveContext {
preferTinyTex: boolean;
Expand Down Expand Up @@ -438,7 +439,7 @@ function tlmgrCommand(

// On windows, we always want to call tlmgr through the 'safe'
// cmd /c approach since it is a bat file
if (Deno.build.os === "windows") {
if (isWindows) {
const quoted = requireQuoting(args);
return safeWindowsExec(
tlmgr.fullPath,
Expand Down
8 changes: 4 additions & 4 deletions src/command/render/pandoc-html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import { TempContext } from "../../core/temp.ts";
import { cssImports, cssResources } from "../../core/css.ts";
import { cleanSourceMappingUrl, compileSass } from "../../core/sass.ts";

import { kSourceMappingRegexes } from "../../config/constants.ts";

import { kQuartoHtmlDependency } from "../../format/html/format-html-constants.ts";
import {
kAbbrevs,
Expand All @@ -40,8 +38,8 @@ import { kMinimal } from "../../format/html/format-html-shared.ts";
import { kSassBundles } from "../../config/types.ts";
import { md5HashBytes } from "../../core/hash.ts";
import { InternalError } from "../../core/lib/error.ts";
import { writeTextFileSyncPreserveMode } from "../../core/write.ts";
import { assert } from "testing/asserts";
import { safeModeFromFile } from "../../deno_ral/fs.ts";

// The output target for a sass bundle
// (controls the overall style tag that is emitted)
Expand Down Expand Up @@ -541,7 +539,9 @@ async function processCssIntoExtras(
} else {
const hash = await md5HashBytes(new TextEncoder().encode(cleanedCss));
newCssPath = temp.createFile({ suffix: `-${hash}.css` });
writeTextFileSyncPreserveMode(newCssPath, cleanedCss);
Deno.writeTextFileSync(newCssPath, cleanedCss, {
mode: safeModeFromFile(cssPath),
});
}

return {
Expand Down
5 changes: 3 additions & 2 deletions src/command/render/pandoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ import {
BrandFontGoogle,
} from "../../resources/types/schema-types.ts";
import { kFieldCategories } from "../../project/types/website/listing/website-listing-shared.ts";
import { isWindows } from "../../deno_ral/platform.ts";

// in case we are running multiple pandoc processes
// we need to make sure we capture all of the trace files
Expand Down Expand Up @@ -855,7 +856,7 @@ export async function runPandoc(
// Attempt to cache the code page, if this windows.
// We cache the code page to prevent looking it up
// in the registry repeatedly (which triggers MS Defender)
if (Deno.build.os === "windows") {
if (isWindows) {
await cacheCodePage();
}

Expand Down Expand Up @@ -1271,7 +1272,7 @@ export async function runPandoc(
// Since this render wasn't successful, clear the code page cache
// (since the code page could've changed and we could be caching the
// wrong value)
if (Deno.build.os === "windows") {
if (isWindows) {
clearCodePageCache();
}

Expand Down
3 changes: 2 additions & 1 deletion src/command/render/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { expandGlobSync } from "../../deno_ral/fs.ts";
import { normalizePath } from "../../core/path.ts";
import { isGlob } from "../../core/lib/glob.ts";
import { ProjectContext } from "../../project/types.ts";
import { isWindows } from "../../deno_ral/platform.ts";

export const kPatchedTemplateExt = ".patched";
export const kTemplatePartials = "template-partials";
Expand Down Expand Up @@ -109,7 +110,7 @@ export async function stageTemplate(
const targetFile = join(dir, template);
copyTo(context.template, targetFile);
// Ensure that file is writable
if (Deno.build.os !== "windows") {
if (!isWindows) {
Deno.chmodSync(targetFile, 0o666);
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/core/appdirs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { join } from "../deno_ral/path.ts";
import { ensureDirSync } from "../deno_ral/fs.ts";
import { os as platformOs } from "../deno_ral/platform.ts";

export function quartoDataDir(subdir?: string, roaming = false) {
return quartoDir(userDataDir, subdir, roaming);
Expand Down Expand Up @@ -35,7 +36,7 @@ function quartoDir(
}

export function userDataDir(appName: string, roaming = false) {
switch (Deno.build.os) {
switch (platformOs) {
case "darwin":
return darwinUserDataDir(appName);
case "windows":
Expand All @@ -53,7 +54,7 @@ export function userDataDir(appName: string, roaming = false) {
}

export function userConfigDir(appName: string, roaming = false) {
switch (Deno.build.os) {
switch (platformOs) {
case "darwin":
return darwinUserDataDir(appName);
case "windows":
Expand All @@ -71,7 +72,7 @@ export function userConfigDir(appName: string, roaming = false) {
}

export function userCacheDir(appName: string) {
switch (Deno.build.os) {
switch (platformOs) {
case "darwin":
return darwinUserCacheDir(appName);
case "windows":
Expand All @@ -89,7 +90,7 @@ export function userCacheDir(appName: string) {
}

export function userRuntimeDir(appName: string) {
switch (Deno.build.os) {
switch (platformOs) {
case "darwin":
return darwinUserCacheDir(appName);
case "windows":
Expand Down
3 changes: 2 additions & 1 deletion src/core/console.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import { readAllSync } from "io/read-all";
import { info } from "../deno_ral/log.ts";
import { runningInCI } from "./ci-info.ts";
import { SpinnerOptions } from "./console-types.ts";
import { isWindows } from "../deno_ral/platform.ts";

// The spinner and progress characters
const kSpinnerChars = ["|", "/", "-", "\\"];
const kSpinerContainerChars = ["(", ")"];
const kSpinerCompleteContainerChars = ["[", "]"];
const kSpinnerCompleteChar = Deno.build.os !== "windows" ? "✓" : ">";
const kSpinnerCompleteChar = !isWindows ? "✓" : ">";
const kProgressIncrementChar = "#";
const kProgressContainerChars = ["[", "]"];
const kProgressBarWidth = 35;
Expand Down
4 changes: 2 additions & 2 deletions src/core/copy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
walkSync,
} from "../deno_ral/fs.ts";

import { isWindows } from "./platform.ts";
import { isWindows } from "../deno_ral/platform.ts";

// emulate the Deno copySync function but read and write files manually
// rather than calling Deno.copyFileSync (to avoid deno's attempt to
Expand Down Expand Up @@ -201,7 +201,7 @@ function copySymlinkSync(
}
const originSrcFilePath = Deno.readLinkSync(src);
const type = getFileInfoType(Deno.lstatSync(src));
if (isWindows()) {
if (isWindows) {
Deno.symlinkSync(originSrcFilePath, dest, {
type: type === "dir" ? "dir" : "file",
});
Expand Down
3 changes: 2 additions & 1 deletion src/core/dart-sass.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { lines } from "./text.ts";
import { debug, info } from "../deno_ral/log.ts";
import { existsSync } from "../deno_ral/fs.ts";
import { warnOnce } from "./log.ts";
import { isWindows } from "../deno_ral/platform.ts";

export function dartSassInstallDir() {
return architectureToolsPath("dart-sass");
Expand Down Expand Up @@ -65,7 +66,7 @@ export async function dartCommand(args: string[]) {
}
}

const command = Deno.build.os === "windows" ? "sass.bat" : "sass";
const command = isWindows ? "sass.bat" : "sass";
return architectureToolsPath(join("dart-sass", command));
};
const sass = resolvePath();
Expand Down
Loading
Loading