Skip to content

Commit

Permalink
Initial commit: Setting up project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
abugraokkali committed Dec 26, 2023
0 parents commit c64dfa6
Show file tree
Hide file tree
Showing 72 changed files with 11,882 additions and 0 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This is a basic workflow to help you get started with Actions
name: Extension CI/CD
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: [push]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Install checkout
uses: actions/checkout@v2

- name: Install node
uses: actions/setup-node@v2
with:
node-version: 18

- uses: pnpm/action-setup@v2
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false

- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: sudo apt install jq -y

- name: Build Vue application
run: |
cd frontend
pnpm install
pnpm build
cd ..
rm -rf frontend
rm -rf .git
rm -rf .github
echo "$(jq '.version = "${{ github.run_number }}"' <<< cat db.json)" > db.json
echo "$(jq '.version_code = ${{ github.run_number }}' <<< cat db.json)" > db.json
rm -f .gitignore
[ "$GITHUB_REF" == "refs/heads/master" ] && PRERELEASE=false || PRERELEASE=true
echo "PRERELEASE=$(echo $PRERELEASE)" >> $GITHUB_ENV
echo "BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV
- name: Create zip
run: |
zip -r /tmp/extension-${{ env.BRANCH }}-${{ github.run_number }}.zip .
- name: Release 🚀
id: create_release
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.TOKEN }}
with:
files: /tmp/extension-${{ env.BRANCH }}-${{ github.run_number }}.zip
name: "Release ${{ env.BRANCH }} ${{ github.run_number }}"
tag_name: "release.${{ env.BRANCH }}.${{ github.run_number }}"
prerelease: ${{ env.PRERELEASE }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
public/vite
.vscode
10 changes: 10 additions & 0 deletions app/App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace App;

class App
{
public function init()
{
//will be called when extension init
}
}
16 changes: 16 additions & 0 deletions app/Controllers/HomeController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Controllers;

class HomeController
{
public function index()
{
return view('index');
}

public function development()
{
return view('index_development');
}
}
37 changes: 37 additions & 0 deletions app/Controllers/RequestController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Controllers;

class RequestController
{
public function request($endpoint, $data, $type)
{
$request = getResponse(function ($client) use ($type, $endpoint, $data) {
return $client->request(strtoupper($type), getUrl($endpoint), count($data) ? [
'json' => $data
] : []);
});

return $request;
}

public function apiProxy()
{
validate([
"type" => "required|in:get,post,put,patch,delete",
"endpoint" => "required",
"data" => "json"
]);
$endpoint = request("endpoint");
$data = json_decode(request("data") ? request("data") : "[]", true);
$type = request("type");

$request = getResponse(function ($client) use ($type, $endpoint, $data) {
return $client->request(strtoupper($type), getUrl($endpoint), count($data) ? [
'json' => $data
] : []);
});

return respond($request);
}
}
83 changes: 83 additions & 0 deletions app/Helpers/Helpers.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?php

use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;

if (!function_exists('getUrl')) {
function getUrl($endpoint = "")
{
$tunnel = openTunnel(
server()->ip_address,
'7806',
'',
'',
);

if (!is_numeric($tunnel)) {
if ((int) $tunnel == 0) {
return abort(__("Cannot initialize socket connection."), 502);
}

return abort(__("Cannot initialize socket connection. " . $tunnel), 502);
}

return "http://127.0.0.1:$tunnel/$endpoint";
}
}

if (!function_exists('getDefaults')) {
function getDefaults()
{
global $limanData;

return [
'headers' => [
'Content-Type' => 'application/json',
],
'verify' => false
];
}
}

if (!function_exists('getResponse')) {
function getResponse($function, $opts = [])
{
$client = new Client(array_merge_recursive($opts, getDefaults()));
try {
$response = $function($client);
$response = json_decode($response->getBody()->getContents());
return $response;
} catch (GuzzleException $exception) {
$code = 500;
try {
if ($exception->getResponse() && $exception->getResponse()->getStatusCode() >= 400) {
$code = $exception->getResponse()->getStatusCode();
if ($exception->getResponse()->getStatusCode() == 422) {
abort(json_decode($exception->getResponse()->getBody()->getContents()), 422);
}

$message =
json_decode($exception->getResponse()->getBody()->getContents())
->error;
if ($message == "") {
$message = $exception->getMessage();
}
} else {
$message = $exception->getMessage();
}
} catch (\Throwable $e) {
$message = $exception->getMessage();
}

abort($message, $code);
}
}
}

if (!function_exists('getVersion')) {
function getVersion()
{
$json = json_decode(file_get_contents(getPath("db.json")), true);
return $json["version"];
}
}
23 changes: 23 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "limanmys/devicemanager",
"description": "deviceManager",
"type": "project",
"authors": [
{
"name": "Dogukan OKSUZ",
"email": "[email protected]"
}
],
"require": {},
"autoload": {
"files": [
"app/Helpers/Helpers.php"
],
"psr-4": {
"App\\": "app"
},
"classmap": [
"app"
]
}
}
36 changes: 36 additions & 0 deletions db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "inventory",
"publisher": "HAVELSAN A.\u015e.",
"version": "DEV",
"version_code": 1,
"database": [],
"widgets": [],
"language": "php",
"status": 0,
"service": "8080",
"supportedLiman": "635",
"support": "[email protected]",
"icon": "box-open",
"require_key": "false",
"verification": "verify",
"dependencies": null,
"sslPorts": null,
"display_name": {
"tr": "Envanter Keşif",
"en": "Inventory Explorer"
},
"functions": [],
"vite": true,
"skeleton": true,
"preload": true,
"menus": [
{
"name": {
"tr": "Varlıklar",
"en": "Assets"
},
"url": "#/machines",
"key": "assets"
}
]
}
1 change: 1 addition & 0 deletions frontend/.eslintcache

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions frontend/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/* eslint-env node */
require("@rushstack/eslint-patch/modern-module-resolution")

module.exports = {
root: true,
extends: [
"plugin:vue/vue3-essential",
"eslint:recommended",
"@vue/eslint-config-typescript/recommended",
],
rules: {
semi: ["error", "never"],
"vue/multi-word-component-names": "off",
"@typescript-eslint/no-explicit-any": "off",
},
parserOptions: {
ecmaVersion: "latest",
},
}
30 changes: 30 additions & 0 deletions frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
.DS_Store
dist
dist-ssr
coverage
*.local

/cypress/videos/
/cypress/screenshots/

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

public/vite
5 changes: 5 additions & 0 deletions frontend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"tabWidth": 2,
"useTabs": false,
"semi": false
}
46 changes: 46 additions & 0 deletions frontend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Liman Vue3 + Vite + Typescript Stack

This template should help get you started developing with Vue 3 in Vite.

## Recommended IDE Setup

[VSCode](https://code.visualstudio.com/) + [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur) + [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin).

## Type Support for `.vue` Imports in TS

TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [TypeScript Vue Plugin (Volar)](https://marketplace.visualstudio.com/items?itemName=Vue.vscode-typescript-vue-plugin) to make the TypeScript language service aware of `.vue` types.

If the standalone TypeScript plugin doesn't feel fast enough to you, Volar has also implemented a [Take Over Mode](https://github.com/johnsoncodehk/volar/discussions/471#discussioncomment-1361669) that is more performant. You can enable it by the following steps:

1. Disable the built-in TypeScript Extension
1) Run `Extensions: Show Built-in Extensions` from VSCode's command palette
2) Find `TypeScript and JavaScript Language Features`, right click and select `Disable (Workspace)`
2. Reload the VSCode window by running `Developer: Reload Window` from the command palette.

## Customize configuration

See [Vite Configuration Reference](https://vitejs.dev/config/).

## Project Setup

```sh
npm install
```

### Compile and Hot-Reload for Development

```sh
npm run dev
```

### Type-Check, Compile and Minify for Serverion

```sh
npm run build
```

### Lint with [ESLint](https://eslint.org/)

```sh
npm run lint
```
1 change: 1 addition & 0 deletions frontend/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
Loading

0 comments on commit c64dfa6

Please sign in to comment.