DEV Community

ILshat Khamitov
ILshat Khamitov

Posted on

Two updates to the rucken copy-paste utility

1) Add support correct generate new files path names

Original files
admin.ts

export class Admin {
  id: string;
}
Enter fullscreen mode Exit fullscreen mode

admin-repository.ts

import { Admin } from './admin';

export class AdminRepository {
  admins: Admin[];
  createOneAdmin() {
    //null
  }
  updateOneAdmin() {
    //null
  }
  deleteOneAdmin() {
    //null
  }
  findManyAdmins() {
    //null
  }
}
Enter fullscreen mode Exit fullscreen mode

Command

npx -y rucken copy-paste --find=admin --replace=my-company --path=./libs/feature
Enter fullscreen mode Exit fullscreen mode

New files:
my-company.ts

export class MyCompany {
  id: string;
}
Enter fullscreen mode Exit fullscreen mode

my-company-repository.ts

import { MyCompany } from './my-company';

export class MyCompanyRepository {
  myCompanies: MyCompany[];
  createOneMyCompany() {
    //null
  }
  updateOneMyCompany() {
    //null
  }
  deleteOneMyCompany() {
    //null
  }
  findManyMyCompanies() {
    //null
  }
}
Enter fullscreen mode Exit fullscreen mode

2) Add support correct replace long text with two or more words, when word for find include in replace options

Original files
new.ts

export class New {
  id: string;
}
Enter fullscreen mode Exit fullscreen mode

new-repository.ts

import { New } from './new';

export class NewRepository {
  news: New[];
  createOneNew() {
    //null
  }
  updateOneNew() {
    //null
  }
  deleteOneNew() {
    //null
  }
  findManyNews() {
    //null
  }
}
Enter fullscreen mode Exit fullscreen mode

Command

npx -y rucken copy-paste --find=new --replace=new-user --path=./libs/feature
Enter fullscreen mode Exit fullscreen mode

New files:
new-user.ts

export class NewUser {
  id: string;
}
Enter fullscreen mode Exit fullscreen mode

new-user-repository.ts

import { NewUser } from './new-user';

export class NewUserRepository {
  newUsers: NewUser[];
  createOneNewUser() {
    //null
  }
  updateOneNewUser() {
    //null
  }
  deleteOneNewUser() {
    //null
  }
  findManyNewUsers() {
    //null
  }
}
Enter fullscreen mode Exit fullscreen mode

https://www.npmjs.com/package/rucken

Top comments (0)