Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lukasalvarezdev/imports-duplicator
A blazingly fast tool that lets you to copy imported files to another directory
https://github.com/lukasalvarezdev/imports-duplicator
golang typescript
Last synced: 12 days ago
JSON representation
A blazingly fast tool that lets you to copy imported files to another directory
- Host: GitHub
- URL: https://github.com/lukasalvarezdev/imports-duplicator
- Owner: lukasalvarezdev
- License: gpl-3.0
- Created: 2022-05-27T17:46:57.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-28T06:41:54.000Z (over 2 years ago)
- Last Synced: 2024-05-04T04:33:46.743Z (6 months ago)
- Topics: golang, typescript
- Language: Go
- Homepage:
- Size: 3.34 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-blazingly-fast - imports-duplicator - A blazingly fast tool that allows you to copy imported files to another directory (Go)
README
# Welcome to Imports Duplicator!
A blazingly fast tool that allows you to copy imported files to another directory.## Get started
1. Clone this repository.
2. Set up golang (v1.18)
3. Run `go test`
4. Run `go run . `If all that worked, you should have now a directory `/out` with all the files that are being referenced in ``
and a file `.ts` with all the info in `` but with the imports updated.That's it!, now it's time to rock!
## How to use
Very easy, just run:
```
go build .
```Now you should have a binary file `imports-duplicator` in the root directory.
## Usage
This will execute the binary file, you can use your favorite terminal
```
imports-duplicator
```
## Example
Your folder structure looks like this:
- `components/...`
- `types.ts`
The file `types.ts` that looks like this:
```typescript
import type { User } from '../dir_outside_root/user'
import type { Address } from '../dir_outside_root/address'
export type { User, Address }
```
And your code works just fine in dev, but in the build step for some reason you don't have access
to `../dir_outside_root`. So to have `dir_outside_root/user.ts`
and `dir_outside_root/address.ts` avaliable in the build step you would do it like this:
```sh
go build .
imports-duplicator types.ts import-from-here
# Your build step
npm run build
```In the build, `import-from-here.ts` would look like this:
```typescript
import type { User } from './out/user'
import type { Address } from './out/address'
export type { User, Address }
```
And your folder structure would look like this:
- `components/...`
- `types.ts`
- `import-from-here.ts`
- `out/user.ts`
- `out/address.ts`## Known limitations
- This tool only copies the files that are referenced in the file that you provide, if those files have imports from another
files, it won't copy them.
- It only works `.ts` files.## Why would I use this?
This helped my team to solve a * **really** * specific case (just temporarily), but it's not intended to have a real use, maybe in the future.## Extra
I built this project as a part of my learning journey of golang, so you may find this code a bit awful, but I'm open
and would love any suggestions!