Today I Learned

6 posts by dawidpośliński

How to use in-repo add-on in another in-repo addon

If you like to have access to in-repo addon from the main app you add in your main app package.json the following code:

"ember-addon": {
  "paths": [
    "lib/in-repo-addon"
  ]
}

If you like to have access from your in-repo addon to add-ons in your main app (in this case ember-can) - you would do:

"dependencies": {
  "ember-can": "*",
}

But how to access in-repo add-on #1 in your in-repo add-on #2?

If you like to use a code from in-repo addon #1 in another in-repo addon #2 you have to do it relatively:

In-repo addon #1 package.json:

"ember-addon": {
  "paths": [
    "../in-repo-addon2"
  ]
}

In-repo addon problem with imports from RFC#176

Symptoms:

I was moving a component from base application (Ember 3.3) to in-repo addon.

It uses import from #RFC176:

import { computed } from '@ember/object';

That caused the following error:

Uncaught Error: Could not find module "@ember/object" imported from "in-repo-addon/components/component-name"

Solution:

I had to make sure than in my in-repo addon package.json had the following dependency:

{
  "name": "in-repo addon name",
  "keywords": [
    "ember-addon"
  ],
  "dependencies": {
    "ember-cli-babel": "*"
  }
}

That’s it :)

Revert^2

In the given scenario:

  1. Pull request was merged
  2. The connected branch#1 was removed
  3. Merged PR was reverted
  4. You don’t have branch#1, but you can see the reverted commit#1

All you have to do is to track the commit#1 and revert reverted commit.

$ git revert commit#1

Clean up local list of your git branches

Have you ever had to search through a long list of local branches, which are mostly obsolete for you?

To keep your local git repository slim and avoid a long list of branches while doing git branch, there is an easy strategy that can save you a bit of time.

First, always remember to push everything you did to the remote when you leave a desk, then just run in the console:

git branch | grep -v "master" | xargs git branch -D

It will remove all your local branches except master. If you need to restore any particular branch, you can fetch and checkout - it will wait for you on your remote!

Remove Docker containers/cache

docker system prune -a -f

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all dangling images
        - all build cache
Deleted Containers:
364bf6faea40cbb733f7fe71d4e6634115c091cf60bba0c3432f0675c4c19026
1b6c011fab7492f5f0f5fd81b23dc71c020524e369f3e04d1da7a6fdfbafdba7
8fd3ce7b846e2927e952378ac763aff2d7e96881e8fb3bf352d014764bbd7625
885c3efd8b6096af8c7227174462972a93d46666f5d1a5b01339b77b2a868baf
ea60a832bc8445da22fa6c460cfa9dc816843fa7176e73c96d6de62f3048ed2d
e96ac95f80f53727e51f313946184db7d768c57808b12dd6f4f69edf038f7c74
54967f9c6c2e74314441d07e26ac4dc0b38ba53a2d2b665ab9c9be9f8d369def
3841b5d1586db0a7b500a3fc3cf54f3628f23b5236c161a1fee2a3a80b4f5cb7

Total reclaimed space: 14.83GB