Skip to content

Commit

Permalink
Don't manage pnpm through Depot (#76)
Browse files Browse the repository at this point in the history
* Attempt Windows integration

* Add nested gitignore test, ensure tests are --no-incremental, remove vike test

* Refer to pnpm.exe

* Preinstall pnpm on Windows

* pnpm.exe?

* Don't install pnpm in depot setup if exists on path

* Don't search for .exe

* Give up for now

* Don't manage pnpm. I give up

* Add Node and pnpm to CI

* Disable incremental compilation by default. Check for node/pnpm
  • Loading branch information
willcrichton authored Nov 20, 2024
1 parent e7464c5 commit 9293654
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 238 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/pre-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20.15.0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.13.2
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Cross-compile
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Node
uses: actions/setup-node@v4
with:
node-version: 20.15.0
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9.13.2
- name: Run tests
run: cargo test --features dev -- --test-threads=1
- name: Run lints
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Depot (formerly Graco) is a tool for orchestrating other Javascript devtools. As an analogy:
* Depot is like [Cargo], but for Javascript.
* Depot is like [create-react-app], but for people who like software engineering.
* Depot is like the [`"scripts"` field of package.json](https://docs.npmjs.com/cli/v9/using-npm/scripts), but with more power and flexibility.
* Depot is like the [`"scripts"` field of package.json][package.json], but with more power and flexibility.

Depot works on Javascript workspaces that have been created by Depot, specifically those using the [model JS workspace] format. Depot supports the following commands:

Expand All @@ -26,7 +26,9 @@ A few benefits of using Depot:

## Installation

The [install script](https://github.com/cognitive-engineering-lab/depot/blob/main/scripts/install.sh) will download a prebuilt binary if possible. Run the script as follows:
As prerequisites, you must have [NodeJS][node-install] (≥20) and [pnpm][pnpm-install] (≥9.9) installed on your computer.

The [install script] will download a prebuilt binary if possible. Run the script as follows:

```
curl https://raw.githubusercontent.com/cognitive-engineering-lab/depot/main/scripts/install.sh | sh
Expand Down Expand Up @@ -98,3 +100,7 @@ Depot is used in a few of our projects:
[Biome]: https://biomejs.dev/
[Typedoc]: https://typedoc.org/
[pnpm]: https://pnpm.io/
[node-install]: https://nodejs.org/en/download/package-manager
[pnpm-install]: https://pnpm.io/installation
[install script]: https://github.com/cognitive-engineering-lab/depot/blob/main/scripts/install.sh
[package.json]: https://docs.npmjs.com/cli/v9/using-npm/scripts
11 changes: 0 additions & 11 deletions crates/depot-test-utils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
fs,
path::{Path, PathBuf},
process::Command,
sync::Once,
};

use either::Either;
Expand All @@ -25,17 +24,8 @@ fn new_cmd(s: impl AsRef<str>) -> String {
format!("{} --prefer-offline", s.as_ref())
}

static SETUP: Once = Once::new();

impl ProjectBuilder {
pub fn new() -> Self {
SETUP.call_once(|| {
let status = Command::new(depot_exe()).arg("setup").status().unwrap();
if !status.success() {
panic!("depot setup failed");
}
});

let tmpdir = TempDir::new().unwrap();
ProjectBuilder {
tmpdir: Either::Left(tmpdir),
Expand Down Expand Up @@ -69,7 +59,6 @@ impl ProjectBuilder {
dir: impl AsRef<Path>,
) -> Result<CommandOutput> {
let mut process = Command::new(depot_exe());
process.arg("--no-incremental");
process.current_dir(dir);
process.args(shlex::split(cmd.as_ref()).unwrap());

Expand Down
3 changes: 0 additions & 3 deletions crates/depot/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub mod fix;
pub mod fmt;
pub mod init;
pub mod new;
pub mod setup;
pub mod test;

#[derive(clap::Subcommand)]
Expand All @@ -30,6 +29,4 @@ pub enum Command {
Fix(fix::FixArgs),

Init(init::InitArgs),

Setup(setup::SetupArgs),
}
18 changes: 5 additions & 13 deletions crates/depot/src/commands/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ use crate::{
CommonArgs,
};

use super::setup::GlobalConfig;

const REACT_INDEX: &str = r#"import React from "react";
import ReactDOM from "react-dom/client";
Expand Down Expand Up @@ -103,7 +101,6 @@ pub struct NewArgs {
pub struct NewCommand {
args: NewArgs,
ws_opt: Option<Workspace>,
global_config: GlobalConfig,
}

fn json_merge(a: &mut Value, b: Value) {
Expand Down Expand Up @@ -157,15 +154,9 @@ fn test_json_merge() {
type FileVec = Vec<(PathBuf, Cow<'static, str>)>;

impl NewCommand {
pub async fn new(args: NewArgs, global_config: GlobalConfig) -> Self {
let ws_opt = Workspace::load(global_config.clone(), None, CommonArgs::default())
.await
.ok();
Self {
args,
ws_opt,
global_config,
}
pub async fn new(args: NewArgs) -> Self {
let ws_opt = Workspace::load(None, CommonArgs::default()).await.ok();
Self { args, ws_opt }
}

fn new_workspace(self, root: &Path) -> Result<()> {
Expand Down Expand Up @@ -547,7 +538,8 @@ export default defineConfig(({{ mode }}) => ({{
}

fn run_pnpm(&self, f: impl Fn(&mut Command)) -> Result<()> {
let mut cmd = Command::new(self.global_config.pnpm_path());
let pnpm_bin = utils::find_pnpm(None).context("Could not find pnpm")?;
let mut cmd = Command::new(pnpm_bin);
f(&mut cmd);

if self.args.offline {
Expand Down
165 changes: 0 additions & 165 deletions crates/depot/src/commands/setup.rs

This file was deleted.

35 changes: 14 additions & 21 deletions crates/depot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@
)]

use self::commands::Command;
use anyhow::{Context, Result};
use anyhow::{bail, Result};
use clap::Parser;
use commands::{
build::BuildCommand,
clean::CleanCommand,
doc::DocCommand,
fix::FixCommand,
fmt::FmtCommand,
init::InitCommand,
new::NewCommand,
setup::{GlobalConfig, SetupCommand},
test::TestCommand,
build::BuildCommand, clean::CleanCommand, doc::DocCommand, fix::FixCommand, fmt::FmtCommand,
init::InitCommand, new::NewCommand, test::TestCommand,
};
use workspace::{package::PackageName, Workspace};

Expand All @@ -34,9 +27,9 @@ pub struct CommonArgs {
#[clap(short, long)]
package: Option<PackageName>,

/// Disable incremental compilation
/// Enable incremental compilation
#[clap(long)]
no_incremental: bool,
incremental: bool,

/// Disable fullscreen UI
#[clap(long)]
Expand All @@ -57,20 +50,20 @@ struct Args {
pub async fn run() -> Result<()> {
let Args { command, common } = Args::parse();

let command = match command {
Command::Setup(args) => return SetupCommand::new(args).run().await,
command => command,
};
if utils::find_node().is_none() {
bail!("Failed to find `node` installed on your path. Depot requires NodeJS to be installed. See: https://nodejs.org/en/download/package-manager");
}

let global_config =
GlobalConfig::load().context("Depot has not been setup yet. Run `depot setup` to proceed.")?;
if utils::find_pnpm(None).is_none() {
bail!("Failed to find `pnpm` installed on your path. Depot requires pnpm to be installed. See: https://pnpm.io/installation")
}

let command = match command {
Command::New(args) => return NewCommand::new(args, global_config).await.run(),
Command::New(args) => return NewCommand::new(args).await.run(),
command => command,
};

let ws = Workspace::load(global_config, None, common).await?;
let ws = Workspace::load(None, common).await?;

// TODO: merge all tasks into a single task graph like Cargo
let command = match command {
Expand All @@ -81,7 +74,7 @@ pub async fn run() -> Result<()> {
Command::Clean(args) => CleanCommand::new(args).kind(),
Command::Doc(args) => DocCommand::new(args).kind(),
Command::Fix(args) => FixCommand::new(args).kind(),
Command::Setup(..) | Command::New(..) => unreachable!(),
Command::New(..) => unreachable!(),
};

ws.run(command).await?;
Expand Down
Loading

0 comments on commit 9293654

Please sign in to comment.