quarto-dev / quarto-dev/quarto-cli

platform arch refactor

Open
#240 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

builds enhancement
Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Description

In working on #237 getting arm logic added in will take some interface redesign:

The existing Dependency interface is as such:

dependencies.ts

export interface Dependency {
  name: string;
  version: string;
  "darwin"?: PlatformDependency;
  "linux"?: PlatformDependency;
  "windows": PlatformDependency;
}

which is used by say the esBuild (and dart/pandoc) resolvers:

return {
    name: "esbuild javscript bundler",
    version,
    "windows": esBuildRelease("windows-64"),
    "linux": esBuildRelease("linux-64"),
    "darwin": esBuildRelease("darwin-64"),
  };

these then are used in configure.ts as kDependencies

// Download dependencies
  info("Downloading dependencies");
  for (const dependency of kDependencies) {
    info(`Preparing ${dependency.name}`);
    const platformDep = dependency[Deno.build.os];
    if (platformDep) {
      info(`Downloading ${dependency.name}`);
      const targetFile = await downloadBinaryDependency(platformDep, config);

      info(`Configuring ${dependency.name}`);
      await platformDep.configure(targetFile);

      info(`Cleaning up`);
      Deno.removeSync(targetFile);
    }
    info(`${dependency.name} complete.\n`);
  }

APIs to consider:

nested archs - Deno.build.arch can be "x86_64" | "aarch64" making it easy to use as a key

export interface Dependency {
  name: string;
  version: string;
  "aarch64": {
	  "darwin"?: PlatformDependency;
	  "linux"?: PlatformDependency;
	  "windows"?: PlatformDependency;
  };
  "x86_64": {
	  "darwin"?: PlatformDependency;
	  "linux"?: PlatformDependency;
	  "windows"?: PlatformDependency;
  };
}

which would essentially result in dl resolution code changing to:

-const platformDep = dependency[Deno.build.os];
+const platformDep = dependency[Deno.build.arch][Deno.build.os];

or some flatter designs:

  • x86 default:
    • darwin + darwin-aarch64
  • no default (my preference given a flat structure):
    • darwin-x86_64 + darwin-x86_64

and do something like

-const platformDep = dependency[Deno.build.os];
+const platformDep = dependency[`${Deno.build.os}-${Deno.build.arch}`];

Secondarily, the other implication to consider in the surrounding code is that arm builds are still generally not as first-class. While it seems everything has x86 builds in place, even for misc dev versions, arm versions are more hit or miss. As such, the general codebase could potentially use a little love to make more informative where its hitting problems and potentially more aggressively halt. The existing code just tries to dl if it exists and regardless will print info(${dependency.name} complete.\n);

@dragonstyle any particular preferences or other interface designs come to mind?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dependencies.ts and configure.ts, including the kDependencies loop and its use of Deno.build.os; review the existing resolver examples for esBuild, dart, and pandoc. Done means the project has a settled interface for OS and architecture selection and dependency setup reports missing or unsuccessful downloads instead of unconditionally printing completion.

Written by the indexing model from the issue text.

Assessment

Tech stack
deno, typescript
Domain
build-system, tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.