Git Product home page Git Product logo

ffizer's People

Contributors

albanminassian avatar davidb avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar forgemo avatar igorlaboriewefox avatar ilaborie avatar vivienrobert-wefox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ffizer's Issues

cached composite template are not updated

Steps to reproduce:

  • A git repository with several templates already cached
  • Add a new template into the repository
  • Create a local template that use the newly template from the repository
  • Call ffizer apply on the local template

The command failed because the cache of the repository doesn't include the new template.

Output:

$ ffizer apply -s amethyst-starter-2d -d my-game
Error: LocalPathNotFound { path: "/home/david/.cache/git/github.com/ffizer/templates_default/master/oss_license", uri: "[email protected]:ffizer/templates_default.git", subfolder: Some("oss_license") }

error with a composed template (from private repository)

Context:

  • create from a composed template via ssh url (like git@....)
  • the import is defined via an https url (like https:...) but on the same host than git
  • both repositories are private (same authn could be used)

Actual:

$ ffizer apply --source [email protected]:zzzz/template_python.git --destination dt2vec
Nov 18 15:20:02.170 WARN failed to download, error: GitRetrieve { dst: "/Users/xxx/Library/Caches/git/bitbucket.org/zzzz/template_ci/master", url: "https://bitbucket.org/zzzz/template_ci.git", rev: "master", source: Error { code: -3, klass: 4, message: "revspec \'master\' not found" } }, path: "/Users/xxxx/Library/Caches/git/bitbucket.org/zzzz/template_ci/master", src: SourceLoc { uri: SourceUri { raw: "https://bitbucket.org/zzzz/template_ci.git", path: "zzzz/template_ci", host: Some("bitbucket.org") }, rev: "master", subfolder: None }, sub-cmd: apply
Nov 18 15:20:02.173 ERRO cmd: CliOpts {
    verbose: 0,
    cmd: Apply(
        ApplyOpts {
            confirm: Never,
            update_mode: Ask,
            no_interaction: false,
            offline: false,
            src: SourceLoc {
                uri: SourceUri {
                    raw: "[email protected]:zzzz/template_python.git",
                    path: "zzzz/template_python",
                    host: Some(
                        "bitbucket.org",
                    ),
                },
                rev: "master",
                subfolder: None,
            },
            dst_folder: "dt2vec",
            key_value: [],
        },
    ),
}
Nov 18 15:20:02.173 ERRO failed: GitRetrieve {
    dst: "/Users/xxxx/Library/Caches/git/bitbucket.org/zzzz/template_ci/master",
    url: "https://bitbucket.org/zzzz/template_ci.git",
    rev: "master",
    source: Error {
        code: -3,
        klass: 4,
        message: "revspec \'master\' not found",
    },
}

Expected:

  • no error
  • maybe translate the https into the git@... if same host
  • ask for the password of the imported template

list of templates

As a project creator
I want to have a list of available templates
So that I could find available templates, and may be apply them simpler

demo:

ffizer list
alias\tflags
  • alias is the name to provide to the ffizer apply -t, alias are NOT unique
  • flags is the flags to provide to ffizer apply to use this template
  • default output is a tsv
  • the output is listed in LRU, then alphabetically
  • the final list remove duplicate

The content of the list comes from a local configuration (eg $HOME/.config/ffizer/templates.yaml)
Content of templates.yaml

  • could be edited manually
  • is enriched automatically when using ffizer apply -s ... with an unlisted template, the alias is defaulted by by removing https://hostname/ or git@hostname: from source, for local template "just" the "filename" of the folder.

the format of templates.yam could be something like

templates:
- alias: ...
  source: ...
  ref: ...
  subfolder: ...
templates_list:
- $url
  • the download of entry in templates_list could be cached, recursive (avoid loop)

  • issue on download, parsing,... is a warning but should not stop the listing

  • Maybe add ffizer apply -t alias ... as a shorter version instead of -s ...

  • Maybe display a selection with the list of filtered templates when using -t alias with more than 1 found, or when no -t ... nor -s ... then display the full list in LRU, alphabetical order (the last used should be the easiest to select)

error with composed repositories

The following .ffizer.yaml produces following error

variables:
  - name: author_name
    default_value: '{{ env_var "USERNAME" }}'

ignores:
  - .git # exclude .git of the template host

imports:
  - uri: "https://github.com/ffizer/templates_default.git"
    rev: "master"
    subfolder: "oss_license"
ffizer test-samples --source .
Jul 15 11:58:36.085 ERROR ffizer: cmd: CliOpts {
    verbose: 0,
    cmd: TestSamples(
        TestSamplesOpts {
            src: SourceLoc {
                uri: SourceUri {
                    raw: ".",
                    path: ".",
                    host: None,
                },
                rev: "master",
                subfolder: None,
            },
            offline: false,
        },
    ),
}
Jul 15 11:58:36.086 ERROR ffizer: failed: SerdeYaml {
    source: Scan(
        ScanError {
            mark: Marker {
                index: 30,
                line: 1,
                col: 30,
            },
            info: "while scanning a tag, did not find expected whitespace or line break",
        },
    ),
}

If I comment out imports it works fine.

The error message is very cryptic and it is hard to guess that is caused by imports section.

Remarques

Ffizer est très sympathique (et largement meilleur que cargo-generate).
Merci pour cet excellent programme.

Voici mes remarques de "première fois":

  • j'ai tout de suite envie de taper ffizer --source ./xxxx --destination . (99% des utilisateurs aussi feignant que moi ont envie de faire). Mais il faut en réalité taper ffizer apply --source ./xxxx --destination . Donc on se demande a quoi sert la commande ffizer tout seul car c'est quand même la première commande expliqué dans le README.md.

  • --source-folder et --source sont ambiguës car j'ai lu la doc en diagonal et j'ai d'abord tapé ffizer --source-folder ./xxxx --destination . ... peut être renommer source-folder en subfolder et n'avoir que un seul paramètre --source.

  • ffizer upgrade ne nécessite peut être pas de subcommand mais seulement ffizer --upgrade.

Cordialement
Alban

[Feature] Support HTTP Proxy

I'm behind an HTTP proxy and ffizer is hanging when attempting to apply from GitHub. It would be great if it respected the http_proxy, https_proxy, and no_proxy environment variables.

Is the .ffizer.hbs extension necessary?

It seems to me like to only reason to treat file extensions differently is to avoid having to escape double braces in files without the extension. Wouldn't it make more sense to expand templates in all files? I think this would also make existing cookiecutter templates mostly compatible with ffizer.

improve merge worflow

[ ] display a message if git mergetool is not defined (or doesn't propose to merge file)
[ ] on merge, generate a MERGED file with conflict by using the diff function and follow the rule from https://git-scm.com/docs/git-merge#_how_conflicts_are_presented & https://stackoverflow.com/questions/44549733/how-to-use-visual-studio-code-as-default-editor-for-git-mergetool
[ ] if vscode is installed (code is in the path) then use it for merge code --wait $MERGED (see https://medium.com/faun/using-vscode-as-git-mergetool-and-difftool-2e241123abe7)

Enhance project template documentation

README is will become too long with all the details, rules. So provide the longer documentation (as html/pdf page) with more details about how to create a template. Template creation should stay simple and the documentation should not afraid creator ;-).

[ ] use mdbook
[ ] start with doc in README
[ ] add link in README
[ ] publish on gh-pages
[ ] update link in Cargo.toml
[ ] add badges

  • after publish Book
  • after publish Docs

File names which start with `{{` do not copy correctly

Hello

In my template I have a file structure as follows:

folder1
    {{project_name}}.data.ffizer.hbs

In the output I get:

folder1
folder1{{project_name}}.data

i.e. Both at top level and the handlebars keywords in the file name have not been resolved.

I'm on Windows and I think that perhaps it is due to a / or \ escaping in the path?

If I put something before the {{ e.g. hello{{project_name}}.data.ffizer.hbs then ffizer works as expected.

keep variables value between 2 `apply`

When I re-apply a template on an folder, I want to have the default value for variables set to the value used during previous apply.

Value should be stored as part of the target folder (by default):

  • to allow move of the folder and keep the feature
  • to allow to share (via git,...) the folder and allow other to re-apply with the previous value

Priority order for default value:

  • cli
  • previous apply
  • value from template (top to bottom)

The value should be linked to the template that declare the variable ? use case:

  • I apply 2 templates A & B with the same variable delared in both, I use different value for each, when re-apply remember the value for A and the value for B
  • I apply 1 template A that import B, when re-apply A remember the value, if remember only B reuse the same value

Apply templates to a git branch

This is easy to do manually, but it would be a nice convenience feature and would provide useful diffing/merging/overwriting with very little work.

[Feature] support boolean values in select_in_values

I am trying to render a section conditionally based on a parameter. However it is quite tricky.

  1. Try using select_in_values. The following construct silently fails without producing anything.
  - name: repo_init
    ask: Do you want to initialize git repository
    default_value: true
    select_in_values:
      - true
      - false
  1. Try using {{#if repo_init}} with strings in select_in_values. This doesn't work because #if expects boolean:
  - name: repo_init
    ask: Do you want to initialize git repository
    default_value: true
    select_in_values:
      - "true"
      - "false"
{{ #if init }}
git init
git worktree add --track -b gh-pages site origin/gh-pages
{{ /if }}
  1. Try using {{#if repo_init}} with hidden variable. It silently fails because repo_init is still a string
  - name: ask_repo_init
    ask: Do you want to initialize git repository
    default_value: true
    select_in_values:
      - "true"
      - "false"
  - name: repo_init
    default_value: {{ str_to_json(ask_repo_init) }}
    hidden: true
  1. assign variable inside template itself. This works but requires boiler plate in every template file.
{{ assign "init" (str_to_json(repo_init)) }}
{{ #if init }}
git init
git worktree add --track -b gh-pages site origin/gh-pages
{{ /if }}

more info when error during ffizer parsing

Provide a better message error during parsing of .ffizer.yaml (eg: tell that the issue is in .ffizer.yaml and with one)

May 06 14:33:24.253 ERRO failed, cmd: CliOpts { verbose: 0, cmd: Apply(ApplyOpts { confirm: Never, update_mode: Ask, no_interaction: false, offline: false, src: SourceLoc { uri: SourceUri { raw: "template_android-bootstrap", path: "template_android-bootstrap", host: None }, rev: "master", subfolder: None }, dst_folder: "foo" }) }, error: SerdeYaml { source: Scan(ScanError { mark: Marker { index: 270, line: 8, col: 44 }, info: "while parsing a block mapping, did not find expected key" }) }

Separate the template repository from template content

If I understand correctly, the template contents are stored directly in the root of the template repository. Thus, if I want to refer to a template that is hosted on github, the template metadata is mixed in with the content. I think it would be cleaner to store the template contents inside a sub-directory like porteurbars does. Is it possible to define this behavior in the .ffizer.yaml file?

ffizer silently fail if one of the ffizer.hbs files contains not escaped {{

In cases when one of the ffizer.hbs contains non escaped {{ the ffizer exits with non zero exit code without any meaningful error message. The only way to find the problematic file is to search for a file with 0 bytes in it.

I created a small reproducer https://gist.github.com/iilyak/f3352a2ae5ea632610bdd191f6f685e8
Here is the output

❯ rm -rf ttttttt/ && ffizer apply --source reproducer/ --destination ttttttt --update-mode Override


Configure variables

foo: myfoo


Plan to execute

   - make dir        ttttttt
   - add file         └─bar

~/dev
❯ echo $?
1

~/dev
❯ ls -la ttttttt/
total 8
drwxr-xr-x   2 iilyak users 4096 Jan 23 18:09 .
drwxr-xr-x 100 iilyak users 4096 Jan 23 18:09 ..
-rw-r--r--   1 iilyak users    0 Jan 23 18:09 bar

Panic when applying a template

Hi,

I've been getting a panic in Ffizer 0.9.0, when applying a template, looks like a failing .unwrap(). Stack trace below:

name = 'ffizer' operating_system = 'unix:Ubuntu' crate_version = '0.9.0' explanation = ''' Panic occurred in file 'src/libcore/result.rs' at line 1009 ''' method = 'Panic' backtrace = ''' stack backtrace: 0: backtrace::backtrace::trace_unsynchronized::h63e17ec3c9056468 (0x7f6e81596666) 1: backtrace::capture::Backtrace::create::h9daf768f506c2ccb (0x7f6e8159574e) 2: backtrace::capture::Backtrace::new::h86b73149f7417b9d (0x7f6e8159560d) 3: human_panic::handle_dump::hdecd64e38b6fe626 (0x7f6e812aac00) 4: ffizer::main::{{closure}}::h94eb8ae2ae6e936b (0x7f6e815c8617) 5: std::panicking::rust_panic_with_hook::h8cbdfe43764887be (0x7f6e8159aec2) at src/libstd/panicking.rs:495 6: std::panicking::continue_panic_fmt::h3d3c5a833c00a5e1 (0x7f6e8159ac4d) at src/libstd/panicking.rs:398 7: rust_begin_unwind (0x7f6e815b22c5) at src/libstd/panicking.rs:325 8: core::panicking::panic_fmt::h4d67173bc68f6d5a (0x7f6e815b675b) at src/libcore/panicking.rs:95 9: core::result::unwrap_failed::hd0c279d6e3f0bab1 (0x7f6e812bc0d1) 10: ffizer::process::h52385e7807c213d4 (0x7f6e81301d9b) 11: ffizer::main::hbc950faad6240cd0 (0x7f6e815c66a7) 12: std::rt::lang_start::{{closure}}::hf601071dd1b5cfb3 (0x7f6e815ce252) 13: main (0x7f6e815c3dac) 14: __libc_start_main (0x7f6e80111b96) 15: _start (0x7f6e81256869) 16: <unknown> (0x0)'''

The template isn't too complex: it's three files which include two variables and some to_camel_case() calls. If you'd like, I can provide them as well.

Thanks!

ffizer doesn't assume master as default value for rev on imports

Importing like:

imports:
  - uri: "[email protected]:xxx/yy.git"

generate error like

ffizer apply --source [email protected]:xxx/zz.git --destination .
May 11 11:11:44.910 WARN failed to download, error: GitRetrieve { dst: "/Users/**/Library/Caches/git/bitbucket.org/xxx/yy/", url: "[email protected]:xxx/template_ci.git", rev: "", source: Error { code: -12, klass: 3, message: "failed to parse revision specifier - Invalid pattern \'\'" } }, path: "/Users/**/Library/Caches/git/bitbucket.org/xxx/yy/", src: SourceLoc { uri: SourceUri { raw: "[email protected]:xxx/yy.git", path: "xxx/yy", host: Some("bitbucket.org") }, rev: "", subfolder: None }, sub-cmd: apply
May 11 11:11:44.914 ERRO failed, cmd: CliOpts { verbose: 0, cmd: Apply(ApplyOpts { confirm: Never, update_mode: Ask, no_interaction: false, offline: false, src: SourceLoc { uri: SourceUri { raw: "[email protected]:xxx/zz.git", path: "xxx/zz, host: Some("bitbucket.org") }, rev: "master", subfolder: None }, dst_folder: "." }) }, error: GitRetrieve { dst: "/Users/d.bernard1/Library/Caches/git/bitbucket.org/xxx/yy/", url: "[email protected]:xxx/yy.git", rev: "", source: Error { code: -12, klass: 3, message: "failed to parse revision specifier - Invalid pattern \'\'" } }

add description to template's variable

Quand on lance ffizer apply il manque une petite description des variables.
Peut être permettre une nouvelle variable du genre

variables:
  - name: project
    default_value: my-project
    description: a long description ...

Cordiallement
Alban

[Feature] Run commands after scaffold completion

Usually when new project is started there is a need to run some initialization commands, such as for example:

  • git init
  • git remote add upstream ....
  • git worktree add --track -b gh-pages site origin/gh-pages
  • direnv allow

It would be nice to be able to run the commands automatically or be able to print them (and suppress all other output) to pipe into sh.
I.e. the scaffold command would look like ffizer apply --source <source_dir> --destination <dest_dir> | sh.

Display a message at end of generation

allow to display a message at end of "apply" command

Acceptance Criteria

  • section about this feature in the doc (book)
  • message define into .ffizer
  • message define as handlebars template
  • for composite template, display every message at end (with the source location of the template-layer)

enhance wrapped error with backtrace

For yaml, io, ... error only wrapped into lib Error without providing more context, adding backtrace will help to debug in case of error.

Using backtrace imply to build with rust nightly.

ffizer snap was built with outdated Ubuntu packages

A scan of this snap shows that it was built with packages from the Ubuntu
archive that have since received security updates. The following lists new
USNs for affected build packages in each snap revision:

Revision r605 (i386; channels: edge)

  • snapcraft: 4661-1

Revision r606 (amd64; channels: edge)

  • snapcraft: 4661-1

Revision r607 (s390x; channels: edge)

  • snapcraft: 4661-1

Revision r608 (ppc64el; channels: edge)

  • snapcraft: 4661-1

Revision r609 (arm64; channels: edge)

  • snapcraft: 4661-1

Revision r610 (armhf; channels: edge)

  • snapcraft: 4661-1

Simply rebuilding the snap will pull in the new security updates and
resolve this. If your snap also contains vendored code, now might be a
good time to review it for any needed updates.

Thank you for your snap and for attending to this matter.

References:

Comparison to porteurbars

The two projects seem quite similar. It would be useful to have a comparison. Here is a short list:

  • I'm not sure whether porteurbars templates can import other templates
  • I prefer treating templates as local files by default instead of having to type file://.... Ideally this would be handled in a smart way so that a github lookup would be a fallback for non-existent files, for example.
  • Very subjective, but I prefer the name ffizer.
  • ffizer has a handy gitignore.io helper function
  • ffizer has more recent development activity
  • Overall, I prefer the UI of porteurbars except for the url handling (see my other issues).

Any other differences?

Conditionally copy a file

I have binary files which completely different content which I want to copy only if the user selects a variable.
e.g. .ffizer.yaml

  - name: BIN_TYPE
    default_value: fast

In my template directory I have 3 files

  • fast.bin
  • slow.bin
  • balanced.bin

I would like to only render the selected binary type.

In the README, the following phrase makes me think this must be possible

file / folder ignored under conditions (ignores'item in ffizer.yaml are defined as handlerbar expression)

So I have tried the following (and multiple variants of it) to no prevail. Always says it's not a valid exclude statement.

ignores:
  - .git # exclude .git of the template host
  - {{#unless (eq BIN_TYPE 'fast')}}**/fast.bin{{/unless}}

Try reuse tempates from altervatives generator

Some project templates already exist. Triages for some of them:

  • compatible (could be used 'as is')
  • need to be converted (need to create a converter tool or guide)

Some template source to try to work with:

provide a jsonschema for .ffizer.yaml

Providing a json-schema can help editor to validate and provide code-completion. It could also help document the API of the file. (Optional register the schema into JSON Schema Store )

Links:

Notes:

display plan with a tree

to improve readability of "plan of execution", maybe replace or combine with color to display file layout as a tree:

//!     ┌───────┬───────┬───────────────────────┐
//!     │ Depth │ Last  │ Output                │
//!     ├───────┼───────┼───────────────────────┤
//!     │     0 │       │ documents             │
//!     │     1 │ false │ ├── this_file.txt     │
//!     │     1 │ false │ ├── that_file.txt     │
//!     │     1 │ false │ ├── features          │
//!     │     2 │ false │ │  ├── feature_1.rs   │
//!     │     2 │ false │ │  ├── feature_2.rs   │
//!     │     2 │ true  │ │  └── feature_3.rs   │
//!     │     1 │ true  │ └── pictures          │
//!     │     2 │ false │    ├── garden.jpg     │
//!     │     2 │ false │    ├── flowers.jpg    │
//!     │     2 │ false │    ├── library.png    │
//!     │     2 │ true  │    └── space.tiff     │
//!     └───────┴───────┴───────────────────────┘

see https://github.com/ogham/exa/blob/a3b2f2b3f43a874b50fda12a5a77fa63842c30de/src/output/tree.rs

`ffizer upgrade` failed : Could not find the required path in the archive

╰─ ffizer upgrade
Checking target-arch... x86_64-unknown-linux-gnu
Checking current version... v1.1.0
Checking latest released version... v1.3.0
New release found! v1.1.0 --> v1.3.0
New release is compatible

ffizer release status:
  * Current exe: "/home/david/.cargo/bin/ffizer"
  * New exe release: "ffizer_1.3.0-x86_64-unknown-linux-gnu.tar.gz"
  * New exe download url: "https://github.com/ffizer/ffizer/releases/download/1.3.0/ffizer_1.3.0-x86_64-unknown-linux-gnu.tar.gz"

The new release will be downloaded/extracted and the existing binary will be replaced.
Do you want to continue? [Y/n] 
Downloading...
3.20 MB / 3.20 MB [=======================================] 100.00 % 5.53 MB/s   ... Done
Extracting archive... Error: Update("Could not find the required path in the archive: \"ffizer\"")

add the test mode for ffizer

to be able to check a template against an expected result.

Could be useful to document a template or to test a template into a CI flow (may be add a github-actions also to run it)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.