Giter VIP home page Giter VIP logo

spin's Introduction

Logo

OCaml project generator.

Build Status npm version

FeaturesInstallationTemplatesUsageRoadmapContributingLicenseAcknowledgements

Demo

Features

🚀 Quickly start new projects that are ready for the real world.

❤️ Have a great developer experience when developing with OCaml.

🏄 Be as productive as Ruby-on-Rails or Elixir's Mix users.

🔌 Establish a convention for projects organizations to make it easy to get into new projects.

Installation

Using Homebrew (macOS)

brew install tmattio/tap/spin

Using Opam

opam install spin

Using a script

curl -fsSL https://github.com/tmattio/spin/raw/main/script/install.sh | bash

Templates

You can generate a new project using a template with spin new. For instance:

spin new bin my_app

Will create a new binary application in the directory ./my_app/

Anyone can create new Spin templates, but we provide official templates for a lot of use cases.

Official templates

The official Spin templates templates are the following:

  • bin - Native project containing a binary.
  • cli - Command Line Interface releasable on Opam.
  • lib - Library releasable on Opam.
  • ppx - PPX library.
  • c-bindings - Bindings to a C library.
  • js - Js application with Js_of_ocaml.

If you'd like to add an official template, don't hesitate to open a PR!

Other OCaml templates

You can find community Spin templates for various projects here: https://github.com/ocaml-templates

Here are some non-official Spin templates that you can use:

Other non-OCaml templates

Although the focus of Spin is to offer a great project generator for the OCaml ecosystem, it can also be used to generate non-OCaml templates. Here are a few examples:

Usage

For a detailed documentation of Spin's CLI, run spin --help, or refer to the CLI documentation.

spin new TEMPLATE [PATH] [--default] [--ignore-config]

Create a new ReasonML/Ocaml project from a template.

PATH defaults to the current working directory.

When --default is passed, the user will not be prompted for configurations that have a default value.

When --ignore-config is passed, the configuration file will be ignored and the user will be prompted for all the configurations.

spin ls

List the official Spin templates.

spin config

Prompt the user for values that can be saved in the configuration file.

If a value is present in the configuration file, it will not be prompted when generating a new project.

Roadmap

See our development board for a list of selected features and issues.

Here are some of the improvements we'll be working on as well in for next releases:

  • Support windows
  • Support CLI options/args for configurations
  • Minimal hello template
  • Generators for lib/bin/test for all templates

Contributing

We'd love your help improving Spin!

Take a look at our Contributing Guide to get started.

License

Distributed under the ISC License. See LICENSE for more information.

Acknowledgements

Thanks to everyone who contributed to Spin!

Special thanks to @wesoudshoorn for creating Spin's logo.

spin's People

Contributors

citizen428 avatar joseferben avatar mbarbin avatar tmattio 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  avatar  avatar  avatar  avatar

spin's Issues

running `spin gen` in terminal throws error

spin gen
📡  Updating official templates.
Done!

😱  Ooops, an unknown error occured. You can file a bug reports at https://github.com/tmattio/spin.
Here is the stack trace in case it helps:

spin: internal error, uncaught exception:
      (Sys_error
        "/Users/prisc_000/.cache/spin/spin-templates/native/generators: No such file or directory")
      Raised by primitive operation at file "lib/utils.re", line 60, characters 6-33
      Called from file "lib/generators.re", line 25, characters 2-52
      Called from file "bin/commands/cmd_gen.re", line 10, characters 6-29
      Called from file "lib/errors.re", line 9, characters 5-11
      Re-raised at file "lib/errors.re", line 66, characters 4-15
      Called from file "bin/commands/cmd_gen.re", line 47, characters 4-43
      Called from file "cmdliner_term.ml", line 25, characters 19-24
      Called from file "cmdliner.ml", line 117, characters 32-39
➜  spin-webmachine

Char.code not found

I created a new project:

reasonlab> spin new native spintest
📡  Updating official templates.
Done!

Project name: spintest
Project slug: [spintest] 
Description: [] 
Name of the author: J D Eisenberg
Github username: jdeisenberg
Which syntax do you use?
1 - Reason
2 - OCaml
Choose from (1, 2): 1

🏗️  Creating a new native in spintest
Done!

🎁  Installing packages. This might take a couple minutes.
[snip lots of lines of install output]
Done!
[snip more lines of install output]
🎉  Success! Created the project at spintest

Then modified bin/spintest_app.re to read as follows:

open Spintest;

/** Main entry point for our application. */
let s = "abcde";
let c = String.get(s, 0); 
let n = Char.code(c);
let () = Stdio.Out_channel.print_endline @@ Utils.hello();

Then attempted to build the project:

spintest> esy build
info esy build 0.6.0 (using package.json)
      ocamlc bin/.spintest_app.eobjs/byte/spintest_app.{cmi,cmo,cmt} (exit 2)
(cd /home/david/reasonlab/spintest/_esy/default/store/b/spintest-4245a00c/default && /home/david/.esy/3/i/ocaml-4.8.1000-e74c5c0d/bin/ocamlc.opt -open Base -g -bin-annot -I bin/.spintest_app.eobjs/byte -I /home/david/.esy/3/i/opam__s__base-opam__c__v0.13.0-10f912a7/lib/base -I /home/david/.esy/3/i/opam__s__base-opam__c__v0.13.0-10f912a7/lib/base/base_internalhash_types -I /home/david/.esy/3/i/opam__s__base-opam__c__v0.13.0-10f912a7/lib/base/caml -I /home/david/.esy/3/i/opam__s__base-opam__c__v0.13.0-10f912a7/lib/base/shadow_stdlib -I /home/david/.esy/3/i/opam__s__sexplib0-opam__c__v0.13.0-c49ef5df/lib/sexplib0 -I /home/david/.esy/3/i/opam__s__stdio-opam__c__v0.13.0-b84fea6e/lib/stdio -I lib/.Spintest.objs/byte -I lib/.Spintest.objs/native -no-alias-deps -o bin/.spintest_app.eobjs/byte/spintest_app.cmo -c -impl bin/spintest_app.re.ml)
# Unformatted Error Output:
# File "bin/spintest_app.re", line 6, characters 8-17:
# Error: Unbound value Char.code

ERROR  bin/spintest_app.re:6 8-17 

3 ┆ /** Main entry point for our application. */
4 ┆ let s = "abcde";
5 ┆ let c = String.get(s, 0);
6 ┆ let n = Char.code(c);
7 ┆ let () = Stdio.Out_channel.print_endline @@ Utils.hello();

The value named Char.code can't be found. Could it be a typo?

error: command failed: 'refmterr' 'dune' 'build' '-p' 'spintest' (exited with 1)
esy-build-package: exiting with errors above...
error: build failed with exit code: 1
  
esy: exiting due to errors above

This error does not occur with the same code in the hello-reason template from https://github.com/esy-ocaml/hello-reason.git

Add generator for arguments global to all subcommands in cli template

Here are some consideration to have when designing the solution:

  • How can we provide the value with an env variable as well (the order of priority would be env variable -> cli argument -> default value)
  • What is the best way to add arguments common to all sub-commands, while conserving the sub-commands separation, to use with spin gen cmd
  • Can we create common arguments with a modular design? This would allow us to create a generator for the arguments (e.g. spin gen arg)

Symbol not found: ____chkstk_darwin on mac

I received the error below when trying to create a new project on a late 2015 Mac running Sierra.

This is with a fresh install of spin via brew

Error:

$ spin new native myspin
dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin
  Referenced from: /usr/local/bin/spin
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ____chkstk_darwin
  Referenced from: /usr/local/bin/spin
  Expected in: /usr/lib/libSystem.B.dylib

[1]    27181 abort      spin new native myspin

Machine details:

$ uname -a
Darwin AUSC02QRF6FG8WP 16.7.0 Darwin Kernel Version 16.7.0: Sun Jun  2 20:26:31 PDT 2019; root:xnu-3789.73.50~1/RELEASE_X86_64 x86_64

Decide on project structure and naming conventions

OCaml and Reason communities have several different conventions for organizing code, naming modules and variables. There are, however, two conventions that stand out:

  • In Reason: camelCase for variables and CameCase for modules
  • In OCaml: snake_case for variables and snake_case for modules (which will be transformed into Snake_case).

One goal of Spin is to reduce the gap between OCaml and Reason ecosystems. All the templates are offered in Reason and OCaml, they use mostly the same libraries so that choosing OCaml or Reason boils down to only a syntactic choice. Having two different conventions for projects organization and naming would go against that goal, a Reason developer who gets in an OCaml repository would not feel familiar, and vice-versa.

I mentioned that all the templates are offered in OCaml and Reason, this is actually not true: the web templates are only offered in Reason. There is a separation between native development and web development for Reason. The standard libraries, and most libraries, are different, the compilers are different, etc. The web side of Reason is influenced by Javascript and React, whereas the native side is influenced by OCaml. The fact that this separation in the language already exist inclined me to choose the following conventions for the templates:

  • camelCase for variables and CameCase for modules for web Reason templates
  • snake_case for variables and snake_case for modules for native Reason and OCaml templates

Putting this in an issue to open the discussion.
@musha68k Any input?

Here are some projects I looked into:

Can't install on mac os 10.15

spin ls

dyld: lazy symbol binding failed: Symbol not found: ____chkstk_darwin
Referenced from: /Users/fabien/.npm-packages/bin/spin (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: ____chkstk_darwin
Referenced from: /Users/fabien/.npm-packages/bin/spin (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib

Use Spin as a base for official cli template

As a CLI, Spin is a perfect candidate to bootstrap the official cli templates.
To do this, I would like to improve the quality of the repository first to create the best template possible.

Here is the list of the things I would like to review/discuss before creating the cli template:

  • Error handling - Really not sure raising exceptions everywhere in the code is a good practice. Also, maybe find a better data structure for the errors so that we can't have undocumented errors.
  • Configuration with env variable - It would be nice to have a generator for those. How can we make it more modular? Also, maybe we should have cli options for each of the config, can we automate this?
  • Directory structure - I don't like the explicit namespacing, but at the same time, I don't want the package.json file to become huge or force the user to configure the package every time they want a new directory. Review how large projects organize their code.
  • README.md - It's awful to find a repo that is interesting, but undocumented and to end up having to read the code. The templates should have great documentation, ask people to review Spin's documentation and aggressively look for feedback.
  • .rei - Create .rei files for all the modules, and document them!
  • Release - This is a milestone in itself, but the release process should be seamless.

Evaluate Tablecloth as standard library

As mentioned in #12:

One goal of Spin is to reduce the gap between OCaml and Reason ecosystems.

Tablecloth aims to provide a consistent standard library between BuckleScript and Reason Native. As such it addresses the concerns mentioned in the above linked issue. Should we explore the feasibility of Tablecloth as standard library for Spin? Or make it an option during spin new?

Support windows

There are currently a few blockers to support windows:

  • Spin unit test fail on Windows
  • Some templates cannot compile on Windows

esy start failing on bootstrap

After bootstrapping with spin new native tdlib-reason, esy start is failing:

Happy hacking!
➜  GitHub cd tdlib-reason
➜  tdlib-reason esy install
info install 0.5.8 (using package.json)
➜  tdlib-reason esy build
info esy build 0.5.8 (using package.json)
➜  tdlib-reason esy test
Running 1 test suite
 PASS  my first test suite

Test Suites: 0 failed, 1 passed, 1 total
Tests:       0 failed, 1 passed, 1 total
Time:        < 1ms

➜  tdlib-reason esy start
error: unable to resolve command: tdlib-reason.exe

Did I miss a step? Thanks.

Nice work here @tmattio! Thanks for sharing it.

Add versionning for the templates

Spin should not depend on the master branch of the official templates. This is causing every breaking changes of the templates to break any version of Spin that does not support the change.

Instead, we should depend on a major version checkout only minor or patch updates. We can versionize the templates with git tag.

Add basic project generation test in CI/CD

The release of Spin 0.5.0 is incompatible with the current version of the templates. We should have spotted that before releasing it. To ensure we don't publish a version that can't even generate a project, we need to add a basic project generation test in Spin's CI/CD.

Upper vs. lower case

When I created a ReasonML project with spin new native SpinTest, file names become all lower case (spintest_app.re, for example). ReasonML modules should begin with upper case. Is there some way to preserve the capitalization that I entered for the project name when prompted:

Project name: SpinTest
Project slug: [spintest] 

Spin fails to generate Bucklescript project even when npm is installed

Using Spin 0.5.1 on MacOS and running spin new bs-react spin-test

🏗️  Creating a new bs-react in spin-test
Done!
[...config options here]
🎁  Installing packages. This might take a couple minutes.
😱  External command not available: yarn. Please install it and try again.

I don't have yarn installed. It would be nice if was smart enough to use either yarn or npm.

Implement MVP

Meta issue containing the list of things to implement to arrive at a working prototype:

Cloning

  • spin new clones spin-templates if not already in the cache dir or if not up to date
  • spin ls clones spin-templates if not already in the cache dir or if not up to date
  • spin new checks if the template is a local path before cloning (and after checking in list of official templates)
  • spin new takes a --default option that will not prompt the user for config if they have a default value

Templates

  • Read configuration file and prompt user for configuration values
  • Copy the template in the path and change files names and content using template engine
  • Filter camel_case
  • Filter snake_case

Generators

  • Read config file for generator
  • Generate new files from templates
  • Create generator for subcommands for cli template

Templates

  • lib
  • ppx
  • cli
  • react
  • CI/CD for spin-template

Release

  • Release with npm (github registry?)
  • Release with script
  • Release with brew

Unknown error when using `spin new native <name>`

Thanks in advance to anyone that takes a look at this one.

I'm getting an exception + stack trace when trying to create a new native project. I coped the terminal output I'm seeing below.

$ spin new native letsgo
📡  Updating official templates.
Done!

😱  Ooops, an unknown error occured. You can file a bug reports at https://github.com/tmattio/spin.
Here is the stack trace in case it helps:

spin: internal error, uncaught exception:
      (Of_sexp_error
        "lib/config_file/config_file_doc.re.cst_of_sexp: unexpected sum tag"
        (invalid_sexp
          (command
            ((name "esy install")
              (description "Download and lock the dependencies.")))))
      Raised at file "sexp_conv.ml", line 203, characters 30-72
      Called from file "src/list.ml", line 376, characters 13-17
      Called from file "src/list.ml" (inlined), line 387, characters 15-31
      Called from file "lib/config_file/config_file.re" (inlined), line 40, characters 7-33
      Called from file "lib/config_file/config_file.re", line 38, characters 4-74
      Called from file "src/list.ml", line 368, characters 13-17
      Called from file "lib/source.re", line 36, characters 20-43
      Called from file "bin/commands/cmd_new.re", line 13, characters 15-41
      Called from file "lib/errors.re", line 18, characters 5-11
      Re-raised at file "lib/errors.re", line 107, characters 4-15
      Called from file "bin/commands/cmd_new.re", line 49, characters 4-84
      Called from file "cmdliner_term.ml", line 25, characters 19-24
      Called from file "cmdliner.ml", line 117, characters 32-39

As for the versions of things I have - they are here.

$ spin --version
0.5.0
$ which spin
/Users/liam/.nvm/versions/node/v12.14.1/bin/spin
$ ocaml --version
The OCaml toplevel, version 4.08.1

Let me know if I can provide some more information! ❤️

Create a Docusaurus website

The website will contain:

  • Announcement post (WIP) and upcoming articles
  • General Spin documentation (Install, Config, New project, Generators, etc.)
  • List of the templates and their features
  • Tutorials

Binary error on linux (debian)

I'm getting a binary exec format error while trying to run this on Debian.

System configuration

Linux debian 4.9.0-11-amd64 #1 SMP Debian 4.9.189-3+deb9u2 (2019-11-11) x86_64 GNU/Linux

Steps

Here's that I did:

  1. Manually download https://github.com/tmattio/spin/releases/download/v0.4.1/spin-linux-x64.zip
  2. Unzip it
  3. chmod +x spin
  4. ./spin

Error

Here's the error I'm getting:

bash: ./spin: cannot execute binary file: Exec format error

Extras

After running file command, looks like this exec was built for MacOS

spin: Mach-O 64-bit x86_64 executable, flags:<NOUNDEFS|DYLDLINK|TWOLEVEL|WEAK_DEFINES|BINDS_TO_WEAK|PIE>

Spin list of templates doesn't work

➜ spin ls
📡  Downloading official templates.
Done!

😱  Ooops, an unknown error occured. You can file a bug reports at https://github.com/tmattio/spin.
Here is the stack trace in case it helps:

spin: internal error, uncaught exception:
      (Sys_error
        "/Users/oskar/.cache/spin/spin-templates: No such file or directory")
      Raised by primitive operation at file "library/TemplateOfficial.re", line 21, characters 2-24
      Called from file "library/Errors.re", line 7, characters 5-11
      Re-raised at file "library/Errors.re", line 50, characters 4-15
      Called from file "executable/cmd/Cmd__list_templates.re", line 6, characters 4-139
      Called from file "executable/cmd/Cmd__list_templates.re", line 22, characters 38-43
      Called from file "cmdliner_term.ml", line 25, characters 19-24
      Called from file "cmdliner.ml", line 117, characters 32-39

Remove Pesy and move test runner to test directory

I've been experimenting with new official templates (namely, lib, rest and graphql), and Pesy is not supporting a few use cases that we need.

To unable these use cases, we need to remove Pesy from the official templates (consistency between all the official templates is a must) and add the dune files manually. This will also allow us to move the test runner in the test directory with a custom dune file.

  • Remove Pesy and create dune files
  • Update the post install commands
  • Enable formatting of dune files in dune-project
  • Move test runner in test directory

Reduce redundencies of templates

Here is a example: https://github.com/tmattio/spin-templates/blob/master/cli/template/.gitignore this file is in each template so if one update one template it might also have to update other template. For instance the .gitignore proposed by GitHub. We can miss it easily. It would be cool if we can have a base template and override it: like adding deps. Some base template could be https://github.com/esy-ocaml/hello-reason

For instance: https://github.com/tmattio/spin-templates/blob/master/cli/template/package.json#L18 this command build in release mode even for dev or peerDependencies are useless now ? we have resolutions in esy.

Add warning message when no config file is found

The templates are becoming really heavy on the prompts... To cope with that, we added a spin config command that allows users to configure a global context so that they can skip general prompts such as their names.

However, a first time user might not know about spin config and be discouraged to use Spin due to the time it takes to create a new project.

We could add a warning to the users if no global configuration file is found to incentivize them to create one which will give them a better UX of Spin.

Add Bucklescript integration test in PPX template

This was included in the template initially, but I had problems with it while working on Opam's support, and I've removed it to be able to release faster.

We should add it back at some point as it's a must-have for people who develop PPXs for Bucklescript.

Error Adding Package to spin.

I am trying to add aantron/luv to a project and I am getting the error below.

~/Github/luv-cli adding-luv* ⇡ 16s
❯ esy start Luvers                                                          
# Unformatted Error Output:
# File "lib/demo.re", line 8, characters 28-41:
# Error: Unbound value Result.get_ok


 ERROR  lib/demo.re:8 28-41 

 5 ┆ ~service="80",
 6  (),
 7 ┆ (result) => {
 8 ┆   let address = List.hd(Result.get_ok(result)).addr;
 9 ┆   let socket = Luv.TCP.init() |> Result.get_ok;
10 ┆   Luv.TCP.connect(
11 ┆     socket,

The value named Result.get_ok can't be found. Could it be a typo?
error: command failed: 'refmterr' 'dune' 'build' '--root' '.' '--only-package' 'luv-cli' (exited with 1)
esy-build-package: exiting with errors above...
error: build failed with exit code: 1
  
esy: exiting due to errors above

Here is the working project before you add luv. https://github.com/idkjs/luv-cli

As soon as you add luv, the build breaks with the above error. luv requires ocaml 4.08+.* or higher. spin bootstrapped with 4.09.0 so I dont know if that should be an issue. I though maybe add @opam/result to fix but you still get the error.

I added luv and result to lib/dune also:

(library
 (name Luv_cli)
 (public_name luv-cli.lib)
 (modules (:standard))
(libraries base console.lib pastel.lib cmdliner luv result)
 (flags -open Base))

(include_subdirs unqualified)

I though maybe add result and luv to dune_project because they were not added after running esy install and esy build, same error.

Any guidance would be greatly appreciated. Thank you.

I was able to add it to a pesy generated project without issue as seen idkjs/luv-with-pesy
Here is the full error output:

esy               
info esy 0.6.2 (using esy.json)
info checking https://github.com/ocaml/opam-repository for updates...
info checking https://github.com/esy-ocaml/esy-opam-override for updates...
info resolving esy packages: done                         
info solving esy constraints: done         
info resolving npm packages: done
info fetching: done                                                                                    
info installing: done                                                                                             
Error: exception Sys_error("luv-cli.opam: Operation not permitted")
Raised by primitive operation at file "stdlib.ml", line 324, characters 29-55
Called from file "src/stdune/io.ml", line 173, characters 8-126
Re-raised at file "src/stdune/io.ml", line 178, characters 8-23
Called from file "src/dune/artifact_substitution.ml", line 383, characters
  15-48
Called from file "src/fiber/fiber.ml", line 229, characters 16-19
Called from file "src/dune/build_system.ml", line 1588, characters 8-1023
Called from file "src/fiber/fiber.ml", line 114, characters 10-15
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17
Re-raised at file "src/stdune/exn.ml" (inlined), line 37, characters 27-56
Called from file "src/stdune/exn_with_backtrace.ml", line 13, characters
  33-71
Called from file "src/fiber/fiber.ml", line 85, characters 10-17

I must not crash.  Uncertainty is the mind-killer. Exceptions are the
little-death that brings total obliteration.  I will fully express my cases. 
Execution will pass over me and through me.  And when it has gone past, I
will unwind the stack along its path.  Where the cases are handled there will
be nothing.  Only I will remain.
# Unformatted Error Output:
# File "lib/demo.re", line 8, characters 28-41:
# Error: Unbound value Result.get_ok


 ERROR  lib/demo.re:8 28-41 

 5 ┆ ~service="80",
 6 ┆ (),
 7 ┆ (result) => {
 8 ┆   let address = List.hd(Result.get_ok(result)).addr;
 9 ┆   let socket = Luv.TCP.init() |> Result.get_ok;
10 ┆   Luv.TCP.connect(
11 ┆     socket,

The value named Result.get_ok can't be found. Could it be a typo?


error: command failed: 'refmterr' 'dune' 'build' '--root' '.' '--only-package' 'luv-cli' (exited with 1)
esy-build-package: exiting with errors above...
error: build failed with exit code: 1
  
esy: exiting due to errors above

Question on `.spin` file

Does the .spin file have a purpose after the project is set up?

Can we do something like run spin in the root and it reads the .spin file to execute?

Never seen a .spin extension before. Thanks for any insight.

Internal error, uncaught exception: unexpected sum tag

Hey folks!

When I run spin new react I get an

📡  Updating official templates.
Done!

😱  Ooops, an unknown error occured. You can file a bug reports at https://github.com/tmattio/spin.
Here is the stack trace in case it helps:

spin: internal error, uncaught exception:
      (Of_sexp_error
        "lib/config_file/config_file_doc.re.cst_of_sexp: unexpected sum tag"
        (invalid_sexp
          (command
            ((name "esy install")
              (description "Download and lock the dependencies.")))))
      Raised at file "sexp_conv.ml", line 203, characters 30-72
      Called from file "src/list.ml", line 376, characters 13-17
      Called from file "src/list.ml" (inlined), line 387, characters 15-31
      Called from file "lib/config_file/config_file.re" (inlined), line 40, characters 7-33
      Called from file "lib/config_file/config_file.re", line 38, characters 4-74
      Called from file "src/list.ml", line 368, characters 13-17
      Called from file "lib/source.re", line 36, characters 20-43
      Called from file "bin/commands/cmd_new.re", line 13, characters 15-41
      Called from file "lib/errors.re", line 18, characters 5-11
      Re-raised at file "lib/errors.re", line 107, characters 4-15
      Called from file "bin/commands/cmd_new.re", line 49, characters 4-84
      Called from file "cmdliner_term.ml", line 25, characters 19-24
      Called from file "cmdliner.ml", line 117, characters 32-39
Installed Version
spin 0.5.0
Arch Linux 5.5.8-arch1-1
OCaml ocaml-base-compiler.4.08.1 4.08.1
opam 2.0.6
esy 0.6.2
ppx_sexp_conv v0.13.0
sexplib v0.13.0
sexplib0 v0.13.0

I get the same error regardless of installation-method: I've tried doing it through yarn (global) and through opam.

It also happens on different templates.

(Sidenote: "You can file a bug reports" has a typo.)

Running offline after installation crashes

I installed spin, then later whilst I was offline tried to generate a new project:

spin new cli error-example

But this cased an exception to be raised.

📡  Downloading official templates.
Done!

😱  Ooops, an unknown error occured. You can file a bug reports at https://github.com/tmattio/spin.
Here is the stack trace in case it helps:

spin: internal error, uncaught exception:
      (Sys_error
        "/Users/deanmerchant/.cache/spin/spin-templates: No such file or directory")
      Raised by primitive operation at file "lib/template_official.re", line 24, characters 2-24
      Called from file "lib/source.re", line 28, characters 20-43
      Called from file "bin/commands/cmd_new.re", line 13, characters 15-41
      Called from file "lib/errors.re", line 10, characters 5-11
      Re-raised at file "lib/errors.re", line 76, characters 4-15
      Called from file "bin/commands/cmd_new.re", line 49, characters 4-84
      Called from file "cmdliner_term.ml", line 25, characters 19-24
      Called from file "cmdliner.ml", line 117, characters 32-39

It looks like there are two issues:

  • In template_official.re "Done"! gets printed regardless of the clone succeeding.
  • Spin needs to be online the first time it is run.

Bug: Will not create cli template if a folder called cli is present

> ls
cli

> spin new cli somecliapp                                                      
😱  Ooops, an unknown error occured. You can file a bug report at https://github.com/tmattio/spin.
Here is the stack trace in case it helps:

spin: internal error, uncaught exception:
      (Sys_error "cli/template/spin: No such file or directory")
      Raised by primitive operation at file "stdlib.ml", line 398, characters 28-54
      Called from file "stdlib.ml" (inlined), line 403, characters 2-45
      Called from file "src/pre_sexp.ml", line 632, characters 11-23
      Called from file "src/pre_sexp.ml" (inlined), line 639, characters 31-75
      Called from file "src/pre_sexp.ml", line 641, characters 36-62
      Called from file "lib/config_file/config_file.re", line 31, characters 4-40
      Called from file "lib/template.re", line 77, characters 4-70
      Called from file "bin/commands/cmd_new.re", line 16, characters 2-65
      Called from file "lib/errors.re", line 19, characters 5-11
      Re-raised at file "lib/errors.re", line 116, characters 4-15
      Called from file "bin/commands/cmd_new.re", line 49, characters 4-84
      Called from file "cmdliner_term.ml", line 25, characters 19-24
      Called from file "cmdliner.ml", line 117, characters 32-39
Installed Version
spin 0.5.1
Arch Linux 5.5.8-arch1-1

Happens with the names of other templates too (lib, ppx, ...)

CLI template, why do you open Base?

Hello!
Thank you for this project that lets me easily get into native reason development.
Today I experienced some weird errors until I look quiet (I calm myself down and come back) and I realized the problem.
My problem was that I copy pasted some code from another project which was using Sys.read_dir and friends, and all those calls were erroring out.
I look for documentation, and Sys had those methods (dam, it compiled on the other project!) and they were not deprecated. I tried to search for my particular error, but nothing was found.

Then, I realize that my IDE was telling my that Sys, was on module Base, that gave me a good hint... I come to dune config and, yes, there was an open Base flag, this should be some kind of shadowing problem...
Then I looked into Base.Sys docs and discovered that it was different from the Sys docs I was reading.
I don't know how, but I come to the conclusion that I needed to use Caml.Sys. Caml seems to be the root module, so in normal circumstances Sys should be directly accessible.

This is a very confusing situation for a newcomer and I'm very glad that I figured out, but can be very frustrating. So my question is, is opening Base by default that important? Wouldn't it be better to just open it on those places where it is required?

Thanks and regards

Support cli with no subcommands

There are two types of CLIs a user might want to create:

  • A single command, with arguments and options, such as curl
  • A multi-command CLI, with subcommands which themselves have arguments and options, such as git

The CLI template currently generates the second option, but it should allow the user to build a single command as well.

This can be added as an new template option when configuring the project.

Add more official templates

A meta issue to track the official templates we (might) want to develop.

  • data-science - Data Science workflow.
  • desktop - Native UI application using Revery.
  • graphql-api - HTTP server that serves a GraphQL API.
  • rest-api - HTTP server that serves a REST API.
  • react-components - React component library with Storybook.
  • bs-bindings - BuckleScript bindings to Javascript libraries.

Add a `config` subcommand to configure global context

The global context would allow users to set stuff like:

  • Their name, email, github username, npm organization
  • Their prefered syntax

When adding this, we should probably add a flag --ignore-config to force the prompt of the values defined in the global context.

Error running `esy` on fresh ppx project

So I created a new ppx project with

spin new ppx testing_ppx

and after running esy inside the directory I immediately got the following error:

$ esy
info esy 0.6.2 (using esy.json)
File "test/dune", line 6, characters 2-23:
6 |   (pps testingppx.lib))
      ^^^^^^^^^^^^^^^^^^^^^
Warning: .merlin generated is inaccurate. Cannot mix preprocessed and non
preprocessed specificiations.
Split the stanzas into different directories or silence this warning by
adding (allow_approximate_merlin) to your dune-project.

I solved the issue with rm -rf test but this doesn't seem like the right approach. Can I get some advice on how to solve this? Thanks in advance!

Put test_runner and test in one directory

(library (name $name_test) (public_name $name.test)
    (modules (:standard \ test_runner)) (libraries $name.lib rely.lib)
    (flags -linkall -g -w -9))

(include_subdirs unqualified)

(executable (name test_runner) (modules test_runner)
    (public_name test-runner.exe) (libraries $name.test))

Check for post install dependencies before generating

If the template contains post install commands, we should check if the users have the required command on their system.

Probably checking for the return code of which is enough.

If the user does not have one of the dependency, the project generation needs to be interrupted with an error message.

Support Opam workflow

The templates currently don't support an Opam workflow. We need to support it.

As far as I can tell, the current blockers are the reason-native projects that are not published on Opam. Maybe we need to use alternatives, or maybe there is a way to add Github dependencies on Opam files.

As part of supporting an Opam workflow, we should also release Spin on Opam.

[HELP] How does %%VERSION%% work?

Hello,
Sorry for opening an issue just partially related (this is code that I got from running a template), but I'm not sure if this is a common Ocaml idiom or something specific to your template.
How is the version thing supposed to work? If I run esy x cmd --version I just get the literal string %%VERSION%%. On CI the test expects an empty string but the actual command returns a git sha. How is this supposed to be configured/used?

Many thanks

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.