# Moving to @wix scopes

## TLDR

We want to make all our private npm packages to be scoped.
It means that, for example, instead of having `wix-axios-config` you should start using `@wix/wix-axios-config`.
The `update-scopes` tool helps to migrate your code to use scoped packages.

## Usage

Use our standalone CLI tool, with [npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) in each of your builds' root directory.

```bash
npx update-scopes
```

Or install it globally:

```bash
npm install -g update-scopes
update-scopes
```

## What's happening?

This tool will change your code to use scoped packages (`@wix`).
Your code will still use the private npm registry but will require the scoped packages.
Since we already publish all packages both as scoped and non-scoped versions this should have no runtime effects on your application.

## What to do if I run into problems?

If you experience any issues please contact us at [#update-scopes](https://slack.com/app_redirect?channel=update-scopes).

## What if I have a monorepo or an n-build 1 repo?

You can use the following script to migrate repos with multiple packages easier. The script runs recursively on all directories other than `node_modules` and runs the `update-scopes` script on any package it finds:

```bash
curl -L https://bit.ly/update-scopes-recursively | bash
```

It then creates a different commit for each sub-package.

## What should I do if I am already using scoped packages?

Run the script anyway, you might have missed something.
The script will detect that you're already using scoped packages and will not make any changes if none are needed.

## Caveats

1. The script will notify you if it finds any Wix packages names that it's not sure if it should migrate or not:

```bash
/var/folders/q4/y966_22s5q533wldcfdkdx0rwls4rs/T/us-Dj5Nt0/files-suspicious.txt
```

Check the contents of the file and migrate manually if needed.

2. If you are exposing `.d.ts` files from a Javascript project this script will change all the declarations and this might result in duplicate declarations. Change them back manually if needed.

   An example of a `.d.ts` that needs to be fixed:
   https://github.com/wix-private/fed-infra/blob/7d33a851fec588263967b06b2ae79686fdcf1ff7/wix-axios-config/index.d.ts
