Skip to content

Commit

Permalink
refactor and rename namespace (#6)
Browse files Browse the repository at this point in the history
* refactor: change namespace to RajaOngkir and remove unused dependencies

BREAKING CHANGE: provider renamed to Kodepintar\LaravelRajaOngkir\RajaOngkir

* chore: update changelog

* Fix styling

Co-authored-by: axmad386 <[email protected]>
  • Loading branch information
axmad386 and axmad386 authored Nov 4, 2021
1 parent 3d1e5e2 commit cd85b11
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 143 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@
/psalm.xml export-ignore
/psalm.xml.dist export-ignore
/testbench.yaml export-ignore
/.chglog export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ testbench.yaml
vendor
node_modules
.php-cs-fixer.cache
.chglog/
29 changes: 25 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,28 @@
# Changelog
<a name="v2.0.0"></a>
## [v2.0.0](https://github.com/kodepintar/laravel-rajaongkir/compare/v1.0.0...v2.0.0) (2021-11-04)

All notable changes to `laravel-rajaongkir` will be documented in this file.
### Refactor

## 1.0.0 - 202X-XX-XX
* change namespace to RajaOngkir and remove unused dependencies

- initial release
### BREAKING CHANGE


provider renamed to Kodepintar\LaravelRajaOngkir\RajaOngkir


<a name="v1.0.0"></a>
## v1.0.0 (2021-10-07)

### Docs

* add README-ID.md ([#4](https://github.com/kodepintar/laravel-rajaongkir/issues/4))
* change readme ([#2](https://github.com/kodepintar/laravel-rajaongkir/issues/2))

### Fix

* update readme and fix load config ([#5](https://github.com/kodepintar/laravel-rajaongkir/issues/5))

### Refactor

* simplify RajaOngkir API Call ([#1](https://github.com/kodepintar/laravel-rajaongkir/issues/1))
23 changes: 8 additions & 15 deletions README-ID.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
*Baca ini dalam bahasa: [Inggris](README.md)*

# laravel-rajaongkir
# Laravel RajaOngkir API Wrapper

<p align="center">
<img src="https://img.shields.io/static/v1?label=Language&message=PHP&color=green">
<img src="https://img.shields.io/static/v1?label=Version&message=8.0&color=blue">
<img src="https://img.shields.io/static/v1?label=PHP&message=8.0&color=green">
<img src="https://img.shields.io/static/v1?label=Version&message=2.0.0&color=blue">
<img src="https://img.shields.io/static/v1?label=Framework&message=Laravel&color=red">
</p>

Expand All @@ -16,16 +16,9 @@ Anda dapat menginstall package ini melalui composer:
composer require kodepintar/laravel-rajaongkir
```

Anda dapat mempublish dan menjalankan migrasi dengan cara:

```bash
php artisan vendor:publish --provider="Kodepintar\LaravelRajaongkir\LaravelRajaongkirServiceProvider" --tag="laravel-rajaongkir-migrations"
php artisan migrate
```

Anda dapat mempublish file config dengan cara:
```bash
php artisan vendor:publish --provider="Kodepintar\LaravelRajaongkir\LaravelRajaongkirServiceProvider" --tag="laravel-rajaongkir-config"
php artisan vendor:publish --tag="rajaongkir-config"
```

Ini adalah konten dari file config yang telah dipublish:
Expand All @@ -40,10 +33,10 @@ return [
## Penggunaan

```php
use Kodepintar\LaravelRajaongkir\LaravelRajaongkir as Ongkir;
use Kodepintar\LaravelRajaOngkir\Facades\RajaOngkir;

$data = RajaOngkir::getProvince();

$data = new Ongkir();
$data = $data->getProvince();
return $data;
```

Expand All @@ -52,7 +45,7 @@ return $data;
- [Tio](https://github.com/sangvictim)
- [Akhmad Salafudin](https://github.com/axmad386)

Repositori ini menggunakan template dari spatie
Repositori ini menggunakan template dari [spatie](https://github.com/spatie/package-skeleton-laravel)

## Lisensi

Expand Down
23 changes: 8 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
*Baca ini dalam bahasa: [Indonesia](README-ID.md)*
# This is my package laravel-rajaongkir
# Laravel RajaOngkir API Wrapper

<p align="center">
<img src="https://img.shields.io/static/v1?label=Language&message=PHP&color=green">
<img src="https://img.shields.io/static/v1?label=Version&message=8.0&color=blue">
<img src="https://img.shields.io/static/v1?label=PHP&message=8.0&color=green">
<img src="https://img.shields.io/static/v1?label=Version&message=2.0.0&color=blue">
<img src="https://img.shields.io/static/v1?label=Framework&message=Laravel&color=red">
</p>

Expand All @@ -15,16 +15,9 @@ You can install the package via composer:
composer require kodepintar/laravel-rajaongkir
```

You can publish and run the migrations with:

```bash
php artisan vendor:publish --provider="Kodepintar\LaravelRajaongkir\LaravelRajaongkirServiceProvider" --tag="laravel-rajaongkir-migrations"
php artisan migrate
```

You can publish the config file with:
```bash
php artisan vendor:publish --provider="Kodepintar\LaravelRajaongkir\LaravelRajaongkirServiceProvider" --tag="laravel-rajaongkir-config"
php artisan vendor:publish --tag="rajaongkir-config"
```

This is the contents of the published config file:
Expand All @@ -39,10 +32,10 @@ return [
## Usage

```php
use Kodepintar\LaravelRajaongkir\LaravelRajaongkir as Ongkir;
use Kodepintar\LaravelRajaOngkir\Facades\RajaOngkir;

$data = RajaOngkir::getProvince();

$data = new Ongkir();
$data = $data->getProvince();
return $data;
```

Expand All @@ -51,7 +44,7 @@ return $data;
- [Tio](https://github.com/sangvictim)
- [Akhmad Salafudin](https://github.com/axmad386)

this repo used template from spatie
This repo used template from [spatie](https://github.com/spatie/package-skeleton-laravel)

## License

Expand Down
28 changes: 11 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "kodepintar/laravel-rajaongkir",
"description": "This is my package laravel-rajaongkir",
"version": "1.0",
"description": "RajaOngkir wrapper for Laravel",
"version": "2.0.0",
"keywords": [
"kodepintar",
"laravel",
Expand All @@ -19,26 +19,23 @@
],
"require": {
"php": "^7.4|^8.0",
"spatie/laravel-package-tools": "^1.4.3",
"illuminate/contracts": "^8.37"
"illuminate/config": "^8",
"illuminate/support": "^8"

},
"require-dev": {
"nunomaduro/collision": "^5.3",
"orchestra/testbench": "^6.15",
"pestphp/pest": "^1.18",
"pestphp/pest-plugin-laravel": "^1.1",
"spatie/laravel-ray": "^1.23",
"vimeo/psalm": "^4.8"
"pestphp/pest-plugin-laravel": "^1.1"
},
"autoload": {
"psr-4": {
"Kodepintar\\LaravelRajaongkir\\": "src",
"Kodepintar\\LaravelRajaongkir\\Database\\Factories\\": "database/factories"
"Kodepintar\\LaravelRajaOngkir\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Kodepintar\\LaravelRajaongkir\\Tests\\": "tests"
"Kodepintar\\LaravelRajaOngkir\\Tests\\": "tests"
}
},
"scripts": {
Expand All @@ -51,13 +48,10 @@
"extra": {
"laravel": {
"providers": [
"Kodepintar\\LaravelRajaongkir\\LaravelRajaongkirServiceProvider"
],
"aliases": {
"LaravelRajaongkir": "Kodepintar\\LaravelRajaongkir\\LaravelRajaongkirFacade"
}
"Kodepintar\\LaravelRajaOngkir\\RajaOngkirServiceProvider"
]
}
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
2 changes: 1 addition & 1 deletion config/rajaongkir.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// config for Kodepintar/LaravelRajaongkir
// config for Kodepintar/LaravelRajaOngkir
return [
/**
* api key yang di dapat dari akun raja ongkir
Expand Down
19 changes: 0 additions & 19 deletions database/factories/ModelFactory.php

This file was deleted.

19 changes: 0 additions & 19 deletions database/migrations/create_rajaongkir_table.php.stub

This file was deleted.

17 changes: 17 additions & 0 deletions src/Facades/RajaOngkir.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace Kodepintar\LaravelRajaOngkir\Facades;

use Illuminate\Support\Facades\Facade;
use Kodepintar\LaravelRajaOngkir\RajaOngkir as Accessor;

/**
* @see \Kodepintar\LaravelRajaOngkir\LaravelRajaOngkir
*/
class RajaOngkir extends Facade
{
protected static function getFacadeAccessor()
{
return Accessor::class;
}
}
16 changes: 0 additions & 16 deletions src/LaravelRajaongkirFacade.php

This file was deleted.

25 changes: 0 additions & 25 deletions src/LaravelRajaongkirServiceProvider.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/LaravelRajaongkir.php → src/RajaOngkir.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

namespace Kodepintar\LaravelRajaongkir;
namespace Kodepintar\LaravelRajaOngkir;

use Illuminate\Support\Facades\Http;

class LaravelRajaongkir
class RajaOngkir
{
protected $BASE_URL = [
'starter' => 'https://api.rajaongkir.com/starter',
Expand Down
22 changes: 22 additions & 0 deletions src/RajaOngkirServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Kodepintar\LaravelRajaOngkir;

use Illuminate\Support\Facades\App;
use Illuminate\Support\ServiceProvider;

class RajaOngkirServiceProvider extends ServiceProvider
{
public function register(): void
{
$this->mergeConfigFrom(__DIR__ . '/../config/rajaongkir.php', 'rajaongkir');
}

public function boot(): void
{
$this->publishes(
[__DIR__ . '/../config/rajaongkir.php' => App::configPath('rajaongkir.php')],
'rajaongkir-config'
);
}
}
2 changes: 1 addition & 1 deletion tests/ConfigTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

it('can load rajangkir config', function () {
/** @var Kodepintar\LaravelRajaongkir\Tests\TestCase $this */
/** @var Kodepintar\LaravelRajaOngkir\Tests\TestCase $this */
$this->assertEquals(config('rajaongkir.ACCOUNT_TYPE'), 'starter');
$this->assertEquals(config('rajaongkir.API_KEY'), 'somerandomstring');
});
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

use Kodepintar\LaravelRajaongkir\Tests\TestCase;
use Kodepintar\LaravelRajaOngkir\Tests\TestCase;

uses(TestCase::class)->in(__DIR__);
Loading

0 comments on commit cd85b11

Please sign in to comment.