cleanv

command module
v0.0.0-...-ff189c9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2023 License: MIT Imports: 3 Imported by: 0

README

Cleanv - Golang SDK for Vue Projects

Reference Release Software License Test status Coverage


Why?

This project is part of my personal portfolio, so, I'll be happy if you could provide me any feedback about the project, code, structure or anything that you can report that could make me a better developer!

Email-me: boscardinvinicius@gmail.com

Connect with me at LinkedIn.


Functionalities

  • Creating a standard development framework
  • Creating separate files within existing code structures
  • Automatically update

Starting

Installation


Download the library and configure it in the path/environment variables of your operating system


Linux:

mv ~/Downloads/cleanv /usr/local/cleanv/
nano ~/.bashrc

# paste the line below at the end of the file
PATH=$PATH:/usr/local/cleanv

# give general permissions on the folder
sudo chmod 777 /usr/local/cleanv

# reload bash info
source ~/.bashrc

# add autocomplete in bash
cleanv completion bash > /tmp/completion
source /tmp/completion

Windows:



The initial struct of vue app code like this:

Struct1



With commands

cleanv template


This command will generate the complete structure for developing a new program on the web.

Positioned in the root of the project with vue.js run the command:

cleanv template -s payment001 -m payment -r findPayment

Prompt1


cleanv repository


This command will generate the structure of a new api call within a ready-made structure. Importing and injecting dependencies if necessary.

Positioned in the root of the project with vue.js run the command:

cleanv repository -s payment001 -m payment -n findTickets

Prompt1



Caution!!! Using the -d flag will delete the corresponding files.

cleanv repository -s screen_name -m module_name -n findSomething1 -d

cleanv update


This command updates the sdk binary automatically;

cleanv update



Examples of code struct generation

cleanv template -s payment001 -m payment -r findPayment
- module
  - payment
    - payment001
      - di
        - di.js
        - axios.js
      - controller
        - paymentController001.js
      - data
        - repository
          - findPaymentRepository.js
      - domain
        - model
          - payment001.js
        - usecase
          - findPaymentUseCase.js
      - view
        - payment001.vue
//Repository
const findPaymentRepository = (axios) => async () => {
  try {
    const response = await axios.get('/rest/TODO')
    return response //TODO
  } catch (error) {
    throw error
  }
}

export default findPaymentRepository
//Usecase
const findPaymentUseCase = (repository) => async () => {
  try {
    //TODO
    return await repository()
  } catch (error) {
    throw error
  }
}

export default findPaymentUseCase
//Model
class Payment001 {
    constructor() {}
}

export default Payment001
//Dependencie Injection
import axiosInstance from './axios'

import findPaymentRepository from '../data/repository/findPaymentRepository'
import findPaymentUseCase from '../domain/usecase/findPaymentUseCase'

import Payment001Controller from '../controller/payment001Controller'

const instance = axiosInstance

const findPaymentRepositoryImpl = findPaymentRepository(instance)
const findPaymentUseCaseImpl = findPaymentUseCase(findPaymentRepositoryImpl)

const payment001Controller = (context) =>
  new Payment001Controller(
    context,
	  findPaymentUseCaseImpl,
  )

export { payment001Controller }
//Axios instance for Dependencie Injection
import axios from 'axios'

const axiosInstace = axios.create({
  baseURL: process.env.VUE_APP_API_BASE_URL,
  headers: {
    Accept: 'application/json',
    'Content-Type': 'application/json',
    Access: 'application/json',
  },
})

export default axiosInstace
//Controller
class Payment001Controller {

  constructor(
    context,
    findPaymentUseCase,
  ) {
    this.context = context
    this.findPaymentUseCase = findPaymentUseCase
  }

  async mounted() {
    try {
      //TODO
    } catch (error) {
      //HANDLER ERROR
    }
  }
}

export default Payment001Controller
//Vue Screen
<template>
  <div>
    <!-- your code here -->
  </div>
</template>

<script>
import { payment001Controller } from "../di/di";
export default {
  data: (context) => ({
    controller: payment001Controller(context),
  }),
  mounted() {
    this.controller.mounted();
  },
};
</script>

Adding new repository

cleanv repository -s payment001 -m payment -n findTickets
- module
  - payment
    - payment001
      - di
        - di.js
        - axios.js
      - controller
        - paymentController001.js
      - data
        - repository
          - findPaymentRepository.js
          - findTicketsRepository.js
      - domain
        - model
          - payment001.js
        - usecase
          - findPaymentUseCase.js
          - findTicketsUseCase.js
      - view
        - payment001.vue
//Repository
const findTicketsRepository = (axios) => async () => {
  try {
    const response = await axios.get('/rest/TODO')
    return response //TODO
  } catch (error) {
    throw error
  }
}

export default findTicketsRepository
//Usecase
const findTicketsUseCase = (repository) => async () => {
  try {
    //TODO
    return await repository()
  } catch (error) {
    throw error
  }
}

export default findTicketsUseCase
//Dependencie Injection
import axiosInstance from './axios'

import findTicketsRepository from '../data/repository/findTicketsRepository'
import findTicketsUseCase from '../domain/usecase/findTicketsUseCase'

import findPaymentRepository from '../data/repository/findPaymentRepository'
import findPaymentUseCase from '../domain/usecase/findPaymentUseCase'

import Payment001Controller from '../controller/payment001Controller'

const instance = axiosInstance

const findTicketsRepositoryImpl = findTicketsRepository(instance)
const findTicketsUseCaseImpl = findTicketsUseCase(findTicketsRepositoryImpl)


const findPaymentRepositoryImpl = findPaymentRepository(instance)
const findPaymentUseCaseImpl = findPaymentUseCase(findPaymentRepositoryImpl)


const payment001Controller = (context) =>
  new Payment001Controller(
    context,
		findTicketsUseCaseImpl,
    findPaymentUseCaseImpl,
  )

export { payment001Controller }
//Controller
class Payment001Controller {

  constructor(
    context,
    findTicketsUseCase
    findPaymentUseCase,
  ) {
    this.context = context
    this.findTicketsUseCase = findTicketsUseCase
    this.findPaymentUseCase = findPaymentUseCase
  }

  async mounted() {
    try {
      //TODO
    } catch (error) {
      //HANDLER ERROR
    }
  }
}

export default Payment001Controller

Contributing

You can send how many PR's do you want, I'll be glad to analyze and accept them! And if you have any question about the project...

Email-me: boscardinvinicius@gmail.com

Connect with me at LinkedIn

Thank you!

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Documentation

Overview

Copyright © 2022 Vinícius Boscardin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL