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

Deployment to local directory #837

Open
bnmnetp opened this issue Sep 25, 2024 · 13 comments
Open

Deployment to local directory #837

bnmnetp opened this issue Sep 25, 2024 · 13 comments

Comments

@bnmnetp
Copy link
Contributor

bnmnetp commented Sep 25, 2024

After our discussion on dev I dug into the pretext-cli code. Looking for deploy related code, thinking I could do a PR to make it possible to do a deployment to a given folder.

I found "deploy_dir". So I set it in my project.ptx for the sample-book.

<deploy-dir>/Users/bmiller/....</deploy-dir> 

Yes, the sample book still uses the 1.0 format file.

when I tried to run pretext deploy runestone. (no dice)
Maybe just pretext deploy then?

I got the following output, actually below is just a fraction of the output.

Staging deployment according to strategy static
Staging `runestone` at `/Users/bmiller/books/PTXSB/published/PTXSB`.
Staging custom static site located in `/Users/bmiller/Runestone/books/pretext/examples/sample-book` at `/Users/bmiller/Runestone/books/pretext/examples/sample-book/output/stage`.
error: [('/Users/bmiller/Runestone/books/pretext/examples/sample-book/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/ext/image-from-rawpixel-id-8704110-jpeg.jpg', '/Users/bmiller/Runestone/books/pretext/examples/sample-book/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/ext/image-from-rawpixel-id-8704110-jpeg.jpg', "[Errno 63] File name too long: '/Users/bmiller/Runestone/books/pretext/examples/sample-book/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/output/stage/ext/image-from-rawpixel-id-8704110-jpeg.jpg'"),

Seems like deploy could use a -t option.

@StevenClontz
Copy link
Member

Can you share the full 1.0 format file (which I would strongly recommend upgrading to 2.0 to see if that fixes your issue)?

@bnmnetp
Copy link
Contributor Author

bnmnetp commented Sep 25, 2024

Here's the file. had to rename it to attach it.

project.txt

I can update the file to 2.0 but that doesn't address the question of how I tell the cli which target I want to deploy.

@StevenClontz
Copy link
Member

StevenClontz commented Sep 25, 2024

Table 5.2.6
https://pretextbook.org/doc/guide/html/processing-CLI.html#table-cli-target-attributes

Setting deploy-dir is how you tell CLI what target(s) to deploy when running pretext deploy. This should be a relative path, e.g. if you want to deploy a target to https://username.github.io/projectname/foo/bar/ then set deploy-dir="foo/bar". If you don't have a site in your project, you may want to deploy-dir="." to deploy it to the root of your GitHub Pages.

(There's also undocumented support for deploy="yes" which sets the deploy-dir to the name of the target, e.g. a web target would deploy to https://username.github.io/projectname/web/. This goes along with the automatically generated homepage for a PreTeXT project I showed off while in my Tacoma quarantine, used in production at https://tbil.org )

If you want to change CLI to be able to deploy locally rather than gh-pages, start looking here I think: https://github.com/PreTeXtBook/pretext-cli/blob/main/pretext/project/__init__.py#L1580

In any case, we need to handle the case where an absolute path is provided to deploy-dir to raise a warning.

@bnmnetp
Copy link
Contributor Author

bnmnetp commented Sep 25, 2024

OK, after updating to the CLI I don't get the crazy path problem, but it wants to deploy to gh pages, which matches the help string, but is not what I'm after.

I want to do a deploy to a local folder, and I would like to be able to specify an absolute path to said folder.

@StevenClontz
Copy link
Member

Yup - that's not a feature today. What might work in the short term is pretext deploy --stage-only, which will put files in YOUR_OUTPUT_FOLDER/stage, and you can then send files wherever you want from there.

@oscarlevin we might have a use-case for not hard-requiring the stage to live within output here.

@StevenClontz
Copy link
Member

StevenClontz commented Sep 25, 2024

Wait maybe we don't. What if you try <target stage="/Users/bmiller/books/PTXSB/published/PTXSB"/> and pretext deploy --stage-only?

@StevenClontz
Copy link
Member

Maybe we need to make "stage" a first-class verb here. You can "stage" files wherever you want on the local disk, and then you can "deploy" from that stage to GH Pages (and one day we should have support for more kinds of deployments elsewhere on the web).

@bnmnetp
Copy link
Contributor Author

bnmnetp commented Sep 25, 2024

critical: Failed to parse project.ptx. Check the entire file, including all targets, and fix the following errors:
error: Either one of the targets or the root project element has an extra attribute it shouldn't: @stage="/Users/bmiller/books/PTXSB/published/PTXSB"

@bnmnetp
Copy link
Contributor Author

bnmnetp commented Sep 25, 2024

I think this is a use case where the target should be able to specify an @deploy-strategy. Runestone builds different html than web.

A valid strategy should let you copy the built output to a different folder, as specified by @deploy-dir

The defaults would still fall back to a github pages deployment to make it easy for beginners that want to start that way.

the deploy subcommand would also need to allow for an optional command line parameter that specifies the target.

Obviously I could do the copying from my own scripts, but I think it would be nice to make the CLI handle as much of the deployment as possible to keep custom scripts out of it.

@StevenClontz
Copy link
Member

critical: Failed to parse project.ptx. Check the entire file, including all targets, and fix the following errors:
error: Either one of the targets or the root project element has an extra attribute it shouldn't: @stage="/Users/bmiller/books/PTXSB/published/PTXSB"

Oops, <project stage="/Users/bmiller/books/PTXSB/published/PTXSB"/>.

@StevenClontz
Copy link
Member

See also discussion at https://groups.google.com/g/pretext-dev/c/FHlYTvMwxMk/

@StevenClontz StevenClontz changed the title static deploy fails with filename too long Deployment to local directory Sep 25, 2024
@oscarlevin
Copy link
Member

@bnmnetp, is this, or some part of this, something you still need? It seems like you have a good plan for Runestone, maybe without this?

@bnmnetp
Copy link
Contributor Author

bnmnetp commented Oct 4, 2024

I have implemented the copying in Runestone, but I still think there would be utility in having this feature in the cli.

Even for a static build it is nice to be able to:

  1. build a new copy of the book and check it out by viewing
  2. deploy the new book to a different local directory for production.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants