Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundled quartz cli #502

Closed
LukeSavefrogs opened this issue Sep 23, 2023 · 7 comments · May be fixed by #1730
Closed

Bundled quartz cli #502

LukeSavefrogs opened this issue Sep 23, 2023 · 7 comments · May be fixed by #1730
Labels
enhancement New feature or request

Comments

@LukeSavefrogs
Copy link
Contributor

Right now in order to make quartz work one has to fork the project.

It would be great to have a npm package which we can use to build quartz (something like create-react-app).

I saw you had something on npm but it has been deprecated. Why's that?

@LukeSavefrogs LukeSavefrogs added the enhancement New feature or request label Sep 23, 2023
@jackyzha0
Copy link
Owner

You can do this with the nix flake right now: https://github.com/zdcthomas/quartz_flake

I chose not to publish it as an npm packager because it adds unnecessary friction to configuring Quartz and I wanted the gradient of making customization changes to Quartz as smooth as possible

@LukeSavefrogs
Copy link
Contributor Author

LukeSavefrogs commented Sep 24, 2023

I chose not to publish it as an npm packager because it adds unnecessary friction to configuring Quartz and I wanted the gradient of making customization changes to Quartz as smooth as possible

I understand and thank you for pointing out to quartz_flake. 😃

What is the correct workflow then?

  • Clone or fork the repository?
  • How to upgrade to newer versions in case this project updates?

@jackyzha0
Copy link
Owner

Either cloning or forking work. It ships with an npx quartz update command

@LukeSavefrogs
Copy link
Contributor Author

LukeSavefrogs commented Sep 29, 2023

It ships with an npx quartz update command

Perfect!

npx quartz update was exactly what I was looking for to keep it updated! 🎉

I think it should be more visible in the documentation.

@necauqua
Copy link
Contributor

Sorry, but given that without npm it doesn't work this makes no sense

λ npx quartz build
node:internal/modules/esm/resolve:854
  throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), null);
        ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'yargs' imported from /home/necauqua/documents/obsidian/quartz/quartz/bootstrap-cli.mjs
    at packageResolve (node:internal/modules/esm/resolve:854:9)
    at moduleResolve (node:internal/modules/esm/resolve:927:18)
    at defaultResolve (node:internal/modules/esm/resolve:1169:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:542:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:510:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:239:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:96:40)
    at link (node:internal/modules/esm/module_job:95:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v20.18.

You have to run npm install to install the dependencies first.

If quartz was an npm package, and after you started using it npm went down (the collapse scenario I guess) its copy would still remain in your node_modules folder.

And if you dislike npm in particular, you can install packages from git with npm install git+https://github.com/jackyzha0/quartz (or as I just discovered, from GitHub with npm install jackyzha0/quartz).
Sadly currently it does not really work (out of the box at least) as it expects ./quartz/build.ts and not ./node_modules/@jackyzha0/quartz/quartz/build.ts due to your weird package structure 🤷

So the part of the philosophy where you have the copy of the source code locally is fulfilled by npm anyway, as JS is not a compiled language - and even then you just can have the sources in the package too, esp. if you do bundling/minification and/or compile TS.

The part where you allow developer-inclined people to tinker with it could've been covered by exposing an API so that they can use it by making a package of their own and depending on quartz, that's how it's usually done.
And if the API is insufficient, those people can make PRs or go ahead and clone the repo, just like you're forcing all users to do currently.

I guess I can see how having a good API is a lot of work for a slim target audience, but ideally the first consumer of the API is quartz itself, it's just part of the software design then

@aarnphm
Copy link
Collaborator

aarnphm commented Dec 22, 2024

If quartz was an npm package, and after you started using it npm went down (the collapse scenario I guess) its copy would still remain in your node_modules folder.

Sure, once it happens, we can think about other options then. Until then if it works then don't break it.

And if you dislike npm in particular, you can install packages from git with npm install git+https://github.com/jackyzha0/quartz (or as I just discovered, from GitHub with npm install jackyzha0/quartz). Sadly currently it does not really work (out of the box at least) as it expects ./quartz/build.ts and not ./node_modules/@jackyzha0/quartz/quartz/build.ts due to your weird package structure 🤷

feel free to propose something to improve this :) The beauty of open source. Note that we are using our free time to maintain Quartz so if you are displeased with how it works then try to propose something or support the maintainers in general.

So the part of the philosophy where you have the copy of the source code locally is fulfilled by npm anyway, as JS is not a compiled language - and even then you just can have the sources in the package too, esp. if you do bundling/minification and/or compile TS.

The part where you allow developer-inclined people to tinker with it could've been covered by exposing an API so that they can use it by making a package of their own and depending on quartz, that's how it's usually done. And if the API is insufficient, those people can make PRs or go ahead and clone the repo, just like you're forcing all users to do currently.

If you don't like how it is then you can just not used it. The description stated very clear, Quartz is "opinionated", so this frustration seems out of place. The problem with "exposing API" is that the development friction is actually a lot higher. If something breaks, then the burden lies back to the maintainers, then PR, bugfix, releases, updates (the whole software development cycle ig). As we said this many times before, we don't work on this full time and willingly maintain the library out of our free time.

If it is a company product, then sure it makes sense. At the end of the day, this is not our full time job.

For libraries, it makes sense because developers can just think in terms of API access.
With Quartz, one can think of it as a monolith. And it is actually a lot better to have the extensibility to hack around. I tend to agree with this philosophy in general.

fwiw Quartz, by default is already pretty good for most users.

@necauqua
Copy link
Contributor

I was barely frustrated, just voiced a few points, didn't think it was nearly rash enough to bring out "this is voluntary work, be grateful it exists in the first place" guns, lol

something to improve this

Well I'd love to figure out how to make it work from an npm package installed through git, if people are not super-duper against it, sure


Among all of the obsidian exporters quartz does seem to be the best one, and I count the paid first-party publish in this 🙃
The only thing missing for me is the holy grail of having baked dataview (which I'm looking at how to do, people sure love having github login as a requirement) and page properties, for which ig I'll have to write a component myself.

necauqua added a commit to necauqua/beta-quartz that referenced this issue Jan 19, 2025
For the current setup where people have to fork or at least clone quartz
this changes nothing - but it allows you to install quartz as a
devDependency via npm and have it actually work.

One real change is switch from `.quartz-cache` to
`node_modules/.cache/quartz` for transpilation results, this is an
artifact from my previous attempts, I guess with this one I can change
it back - but `node_modules/.cache` feels more better imo idk.

edit: OTOH if you want to have quartz be a _completely_ separate binary
(which this also enables I think), having it create a node_modules
folder is weird, so I made a quick hack for that for now.

Example:
```bash
$ mkdir my-repo && cd my-repo
$ npm i quartz@necauqua/quartz#untangled # quartz@ prefix is important
$ cp node_modules/quartz/quartz.*.ts .   # copy the default configs
$ mkdir content && echo "# Hello World!" > content/index.md
$ npx quartz build --serve # this just works!
$ echo 'body { background: red !important; }' > styles.scss
```
Notice how I used my branch in the `npm i` line, ideally it'd be
`npm i quartz@jackyzho0/quartz`, or maybe we can somehow get the quartz
package on npm and it'll just be `npm i quartz`.
In the latter case `npx quartz build` will literally just work without
a local npm package at all?.

Having some support for components and plugins being in separate npm
packages instead of people copying code around is not out of the picture
with this too btw.

Closes jackyzha0#502
necauqua added a commit to necauqua/beta-quartz that referenced this issue Jan 19, 2025
For the current setup where people have to fork or at least clone quartz
this changes nothing - but it allows you to install quartz as a
devDependency via npm and have it actually work.

One real change is switch from `.quartz-cache` to
`node_modules/.cache/quartz` for transpilation results, this is an
artifact from my previous attempts, I guess with this one I can change
it back - but `node_modules/.cache` feels more better imo idk.

edit: OTOH if you want to have quartz be a _completely_ separate binary
(which this also enables I think), having it create a node_modules
folder is weird, so I made a quick hack for that for now.

Example:
```bash
$ mkdir my-repo && cd my-repo
$ npm i quartz@necauqua/quartz#untangled # quartz@ prefix is important
$ cp node_modules/quartz/quartz.*.ts .   # copy the default configs
$ mkdir content && echo "# Hello World!" > content/index.md
$ npx quartz build --serve # this just works!
$ echo 'body { background: red !important; }' > styles.scss
```
Notice how I used my branch in the `npm i` line, ideally it'd be
`npm i quartz@jackyzho0/quartz`, or maybe we can somehow get the quartz
package on npm and it'll just be `npm i quartz`.
In the latter case `npx quartz build` will literally just work without
a local npm package at all?.

Having some support for components and plugins being in separate npm
packages instead of people copying code around is not out of the picture
with this too btw.

Closes jackyzha0#502
necauqua added a commit to necauqua/beta-quartz that referenced this issue Jan 20, 2025
For the current setup where people have to fork or at least clone quartz
this changes nothing - but it allows you to install quartz as a
devDependency via npm and have it actually work.

One real change is switch from `.quartz-cache` to
`node_modules/.cache/quartz` for transpilation results, this is an
artifact from my previous attempts, I guess with this one I can change
it back - but `node_modules/.cache` feels more better imo idk.

edit: OTOH if you want to have quartz be a _completely_ separate binary
(which this also enables I think), having it create a node_modules
folder is weird, so I made a quick hack for that for now.

Example:
```bash
$ mkdir my-repo && cd my-repo
$ npm i quartz@necauqua/quartz#untangled # quartz@ prefix is important
$ cp node_modules/quartz/quartz.*.ts .   # copy the default configs
$ mkdir content && echo "# Hello World!" > content/index.md
$ npx quartz build --serve # this just works!
$ echo 'body { background: red !important; }' > styles.scss
```
Notice how I used my branch in the `npm i` line, ideally it'd be
`npm i quartz@jackyzho0/quartz`, or maybe we can somehow get the quartz
package on npm and it'll just be `npm i quartz`.
In the latter case `npx quartz build` will literally just work without
a local npm package at all?.

Having some support for components and plugins being in separate npm
packages instead of people copying code around is not out of the picture
with this too btw.

Closes jackyzha0#502
necauqua added a commit to necauqua/beta-quartz that referenced this issue Jan 23, 2025
For the current setup where people have to fork or at least clone quartz
this changes nothing - but it allows you to install quartz as a
devDependency via npm and have it actually work.

One real change is switch from `.quartz-cache` to
`node_modules/.cache/quartz` for transpilation results, this is an
artifact from my previous attempts, I guess with this one I can change
it back - but `node_modules/.cache` feels more better imo idk.

edit: OTOH if you want to have quartz be a _completely_ separate binary
(which this also enables I think), having it create a node_modules
folder is weird, so I made a quick hack for that for now.

Example:
```bash
$ mkdir my-repo && cd my-repo
$ npm i quartz@necauqua/quartz#untangled # quartz@ prefix is important
$ cp node_modules/quartz/quartz.*.ts .   # copy the default configs
$ mkdir content && echo "# Hello World!" > content/index.md
$ npx quartz build --serve # this just works!
$ echo 'body { background: red !important; }' > styles.scss
```
Notice how I used my branch in the `npm i` line, ideally it'd be
`npm i quartz@jackyzho0/quartz`, or maybe we can somehow get the quartz
package on npm and it'll just be `npm i quartz`.
In the latter case `npx quartz build` will literally just work without
a local npm package at all?.

Having some support for components and plugins being in separate npm
packages instead of people copying code around is not out of the picture
with this too btw.

Closes jackyzha0#502

MOVE ME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants