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

How to create and use Amber 0.14.1 libraries? #20

Open
hhzl opened this issue Oct 11, 2014 · 14 comments
Open

How to create and use Amber 0.14.1 libraries? #20

hhzl opened this issue Oct 11, 2014 · 14 comments
Milestone

Comments

@hhzl
Copy link
Member

hhzl commented Oct 11, 2014

The wiki page on Amber-Config has a basic paragraph about Amber libraries. A follow up question:

How do I create an Amber library 0.13 style which then can be loaded with bower?

For example

  1. what are the steps involved to create a new repository with the TrySmalltalk.st copied into it?
  2. http://bower.io/docs/creating-packages/ gives the steps to create and publish a bower package.
  3. How is that newly created library loaded into a 0.13 type project I just created with amber init?
@ghost
Copy link

ghost commented Oct 11, 2014

  1. Nothing special, just follow migration steps (or, do amber init, copy just the code, and adapt the rest to be 0.13).
  2. Everything is ready for bower after amber init. Just bower register it when you want it to be in bower. And create semver tag in repo for each version to be available.
  3. Just as any other dependency, bower install foo --save. Since it is an amber library and has its *.amd.json files, you do not create them as with common libraries, just run grunt devel or grunt deploy to reflect changed config.

@sebastianconcept
Copy link

In teresting, people asks me this every now and then.

I'll try publishing a package and see (I don't have clear what gets saved by bower, if the package only or more)

Thanks for the step by step description!

@ghost
Copy link

ghost commented Oct 11, 2014

Sebastian Sastre [email protected]ísal/a:

In teresting, people asks me this every now and then.
I'll try publishing a package and see (I don't have clear what gets saved by bower, if the package only or more)

It is good to realize there is nothing like "saved by bower" thing out there, because of different models of npm and bower.

In npm, you push any version you want to publish to npm registry, from disk, and it the stores and serves it.

With bower, you must register git url, and bower then uses this git repo when installing, so it pulls the files. To publish a version, you must create a tag in the registered repo.

And as for what bower pulls - everything except what is listed in ignore section of bower.json.

@sebastianconcept
Copy link

So we have two ways of doing it! that's great!

Wiki pages or protips in codewall explaining by example one each way of doing it would be really handy

Volunteers?

@ghost
Copy link

ghost commented Oct 11, 2014

Sebastian Sastre [email protected]ísal/a:

So we have two ways of doing it! that's great!

??? What is 'it' and what two ways are you talking about?

@sebastianconcept
Copy link

Two ways to publish Amber libraries:

  1. bower
  2. npm

@ghost
Copy link

ghost commented Oct 11, 2014

Oh. No, that was a misunderstanding. I mentioned npm only as an example of push model (which is what people probably see as default) to contrast it with bower model. In no way did (and do) I endorse using npm as a way to publish amber libraries. 99% of Amber projects, including libraries, is browser-based, and there just nothing else makes sense except bower. Of course, technically you can use any other channels, but it's IMO just not relevant to mention them.

Sebastian Sastre [email protected]ísal/a:

TwowaystopublishAmberlibraries:bowernpmReplytothisemaildirectlyorviewitonGitHub.

@sebastianconcept
Copy link

Good point.

So bower it is.

Here is a friendly how to

@ghost
Copy link

ghost commented Oct 12, 2014

Well, too much unneeded information there, as no bower init is needed, and of course, no Polymer and no script tags using ../otherdir/foo. In essence, only initial git repo / semver tag part and register part are needed, the rest is already done.

@hhzl
Copy link
Member Author

hhzl commented Oct 14, 2014

As a summary so far:

Instructions from Herby above copied and adapted for the case that you start a fresh amber 0.13 project possibly then copying Smalltalk code from an earlier project with fileIn in the legacy browser workspace)

  1. amber init
  2. If your library needs other libraries install them with bower install theLibrary --save. Force the file config.js to be rebuilt by running. grunt devel. As we are creating an amber library which already has its own .amd.json file, you do not need to create it as with common libraries.
  3. Push your project to github
  4. Register it with bower.io http://bower.io/docs/creating-packages/#register

@Herby Is this correct?

@ghost
Copy link

ghost commented Oct 14, 2014

No, the "which already has its own .amd.json file, you do not need to create it as with common libraries" was about use, not about creation. Of course you must create .amd.json files just as with any other app - local.amd.json for your own mappings (prepopulated by amber init) and foo.amd.json for every external library (unless it is nice enough to have .amd.json files itself).

@ghost
Copy link

ghost commented Oct 14, 2014

Overall, I'd say there is no magic in creating libraries at all. They are identical to any other project (except they will likely never run grunt deploy as there is no point to).

What is magic is use of libraries, and only those which do not have .amd.json files of their own (which Amber libraries have), so only external libraries. For those you need to create .amd.json file with mappings.

All in all, every component must have mappings in some .amd.json file. If it is nice, it has its own local.amd.json file with its own mappings. If it does not (is an external library, for example jQuery), its holder should supply .amd.json file for it. So that, ultimately, every component has its piece of config defined. config.js is then built from all these pieces found in the hierarchy.

So, to use nice library means only to install it via bower and regenerate config. To use non-nice library involves the additional step of defining its mappings.

Nothing really hard, when you see into the abstraction.

@hhzl
Copy link
Member Author

hhzl commented Oct 14, 2014

OK, let me this later by converting amber-examples/trysmalltalk to an Amber 0.13 library which can be loaded through bower.

@hhzl hhzl changed the title How to create and use Amber 0.13 libraries? How to create and use Amber 0.14.1 libraries? Jan 9, 2015
@hhzl hhzl added this to the 0.14 milestone Jan 9, 2015
@hhzl
Copy link
Member Author

hhzl commented Jan 14, 2015

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

2 participants