fukamachi / cl-project

Generate modern project skeletons
MIT License
241 stars 40 forks source link

Copy binary files #44

Open eternal-turtles opened 1 month ago

eternal-turtles commented 1 month ago

It would be convenient to be able to specify some files from the skeleton to copy over without being processed by cl-emb.

I'd like to include favicon.ico or a png, or some other file that is not text-based, but currently an error like the following is signaled:

debugger invoked on a SB-INT:STREAM-DECODING-ERROR in thread
#<THREAD tid=162769 "main thread" RUNNING {10044E8113}>:
  :UTF-8 stream decoding error on
  #<SB-SYS:FD-STREAM for "file /home/jnewton/quicklisp/local-projects/foo.lisp.vinland/skeleton/web/static/favicon.ico" {100423E973}>:

    the octet sequence #(158) cannot be decoded.

Perhaps there could be a second special variable that would be bound to a regular expression representing files to copy directly, or else a list of file extensions or filenames.

As a workaround, I can keep these files in another directory and copy them over after calling CL-PROJECT:MAKE-PROJECT, but this seems like a feature that could be added to the library.

kilianmh commented 1 month ago

So it could look like this, whereas the first value is the path to the file to be copied and the second is the path where to copy the file: :copy-file (list (list (pathname "/home/jnewton/web/static/favicon.ico") (pathname "/web/static/favorite-icon.ico")))

eternal-turtles commented 3 weeks ago

I should have mentioned, but this feature request is for when a custom cl-project:*skeleton-directory* is provided before calling cl-project:make-project (which allows for custom project skeletons).

I was imagining that there would be an additional special variable that might be checked around here https://github.com/fukamachi/cl-project/blob/0df6de16e98fc402d830b70d323f79d2df4791e6/src/io.lisp#L15-L18 and if the file pathname has a file-type that indicates it is binary, then it would be copied without calling cl-emb:execute-emb. I do like the idea though of being able to specify a static directory or have a default static directory for which files would be copied without cl-emb processing. I'm not sure though about being able to specify different target filenames/locations for the copied static files, as I don't have a use-case for this and it wouldn't really be consistent with how cl-emb processed files are copied, always with the same name/relative location except with "skeleton" replaced with the project name.

@fukamachi Any thoughts on the right design for this feature if you agree with it and if you'd be open to a PR?

Edit: it now occurs to me that there might be JS or CSS files in the static directory that might be useful to process with cl-emb, so to me I think being able to specify binary file types, either with a special variable or an additional parameter to cl-project:make-project, still makes the most sense.