Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
scriptor files
Browse files Browse the repository at this point in the history
  • Loading branch information
ciansen committed Nov 18, 2022
1 parent 876de1c commit 949ede5
Show file tree
Hide file tree
Showing 74 changed files with 4,766 additions and 0 deletions.
1 change: 1 addition & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL="http://localhost:8080"
1 change: 1 addition & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VITE_API_URL=""
25 changes: 25 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = {
root: true,
env: {
node: true,
},

'extends': [
'plugin:vue/vue3-essential',
'eslint:recommended'
],
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-unused-vars': 'off',
'no-empty': 'off',
'vue/no-unused-components': 'off',
'vue/no-deprecated-slot-attribute': 'off', //Webcomponents use slot attribute
"no-unreachable":"off",
"no-mixed-spaces-and-tabs": "off"

}
}
46 changes: 46 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Publish scriptor
on:
push:
tags:
- 'v*.*.*'


jobs:
publish:
runs-on: ubuntu-latest
name: Build
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v3
with:
node-version: 16
- uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Build usepython
working-directory: ./src/usepython
run: |
npm install
npm run build
- name: install node modules
run: npm install
- name: zipping scriptor python module
working-directory: ./src/assets
run: python3 make.py
- name: build scriptor
run: npm run build
- name: zipping scriptor build
run: python3 make.py
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
- name: Upload Release
uses: ncipollo/release-action@v1
with:
artifacts: "source.zip"
token: ${{ secrets.GITHUB_TOKEN }}
- name: Done
run: echo 'Done'
5 changes: 5 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
presets: [
'@babel/preset-env'
]
}
19 changes: 19 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="de" class="sl-theme-viur">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex,nofollow">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">

<title>Scriptor v1.0</title>
</head>
<body>
<noscript>
<strong>We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<script type="module" src="/src/main.js"></script>
<!-- built files will be auto injected -->
</body>
</html>
19 changes: 19 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "es5",
"module": "esnext",
"baseUrl": "./",
"moduleResolution": "node",
"paths": {
"@/*": [
"src/*"
]
},
"lib": [
"esnext",
"dom",
"dom.iterable",
"scripthost"
]
}
}
15 changes: 15 additions & 0 deletions make.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import zipfile


def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(path, '..')))


with zipfile.ZipFile('source.zip', 'w', zipfile.ZIP_DEFLATED) as zipf:
zipdir('../../deploy', zipf)
69 changes: 69 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "stand-alone-scriptor",
"version": "0.1.0",
"private": true,
"scripts": {
"preinstall": "npm install ./src/usepython",
"serve": "vue-cli-service serve",
"lint": "vue-cli-service lint",
"dev": "vite",
"build": "vite build"
},
"dependencies": {
"@codemirror/commands": "^6.1.0",
"@codemirror/lang-javascript": "^6.0.2",
"@codemirror/lang-python": "^6.0.1",
"@codemirror/language": "^6.2.1",
"@codemirror/next": "^0.16.0",
"@codemirror/theme-one-dark": "^6.1.0",
"@codemirror/view": "^6.2.3",
"@viur/viur-shoelace": "^2.0.0-beta.82-viur-11",
"@viur/viur-vue-utils": "^0.5.9",
"babel-eslint": "^10.1.0",
"codemirror": "^6.0.1",
"core-js": "^3.8.3",
"pinia": "^2.0.23",
"pyodide": "^0.21.2",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-delete": "^2.0.0",
"rollup-plugin-visualizer": "^5.8.3",
"typescript-eslint": "^0.0.1-alpha.0",
"usepython": "file:src/usepython",
"vue": "^3.2.13",
"vue-json-pretty": "^2.2.3"
},
"devDependencies": {
"@babel/core": "^7.12.16",
"@babel/eslint-parser": "^7.12.16",
"@vitejs/plugin-vue": "^3.1.0",
"@vue/cli-plugin-babel": "~5.0.0",
"@vue/cli-service": "~5.0.0",
"eslint": "^7.32.0",
"eslint-plugin-vue": "^8.7.1",
"raw-loader": "^4.0.2",
"rollup-plugin-mv": "^0.0.2",
"vite": "^3.1.4",
"less": "^4.1.3"

},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/vue3-essential",
"eslint:recommended"
],
"parserOptions": {
"parser": "@babel/eslint-parser"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead",
"not ie 11"
]
}
85 changes: 85 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<template>

<template v-if="isLoggedIn && !isLoading">
<Home></Home>
</template>

</template>

<style lang="less">
@import "style/app.less";
</style>

<script lang="ts">
import Home from './components/Home.vue'
import {Request} from "@viur/viur-vue-utils";
import {ref, onBeforeMount, inject} from 'vue';
import {usePythonStore} from "./PythonStore";
import LoadingSpinner from "./components/common/LoadingSpinner.vue";
export default {
name: 'App',
components: {
Home,
LoadingSpinner
},
setup(){
let isLoggedIn = ref<boolean>(false);
let isLoading = ref<boolean>(true);
const global = inject("global")
let pythonStore = usePythonStore();
async function init() {
isLoading.value = true;
await pythonStore.py.load();
let baseUrl: string = "";
if (import.meta.env.VITE_API_URL)
baseUrl = `${import.meta.env.VITE_API_URL}`;
else
baseUrl = `${window.location.origin}`;
await pythonStore.py.run(`
with open("config.py", "w") as f:
f.write("BASE_URL='${baseUrl}'")
`)
const zipUrl = new URL('./assets/scriptor.zip', import.meta.url).href
console.log("zipUrl:", zipUrl);
// Loading scriptor library
await pythonStore.py.run(`
from pyodide.http import pyfetch
response = await pyfetch("${zipUrl}")
await response.unpack_archive()
`)
isLoading.value = false;
}
onBeforeMount(async () => {
try {
let resp = await Request.get("/vi/user/view/self");
let data = await resp.json();
isLoggedIn.value = true;
global.user = data.values;
await init();
}
catch (error) {
isLoggedIn.value = false;
}
});
return {isLoggedIn, isLoading}
}
}
</script>

<style scoped>
</style>
9 changes: 9 additions & 0 deletions src/PythonStore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineStore } from 'pinia'
import { usePython} from "usepython";

export const usePythonStore = defineStore('python', () => {
const py = usePython();


return { py }
})
Binary file added src/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions src/assets/make.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import zipfile


def zipdir(path, ziph):
# ziph is zipfile handle
for root, dirs, files in os.walk(path):
for file in files:
ziph.write(os.path.join(root, file),
os.path.relpath(os.path.join(root, file),
os.path.join(path, '..')))


with zipfile.ZipFile('scriptor.zip', 'w', zipfile.ZIP_DEFLATED) as zipf:
zipdir('scriptor/', zipf)
24 changes: 24 additions & 0 deletions src/assets/scriptor/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from .utils import get_json_object



from .network import Request
from .viur import viur
from .writer import Writer
from .csvwriter import CsvWriter
from .logger import Logging as logging

try:
from js import console
except ModuleNotFoundError:
pass


import json
import copy

def print(*args, **kwargs):
console.log("my own print!")

for arg in args:
logging.info(arg)
Loading

0 comments on commit 949ede5

Please sign in to comment.