Skip to content

Commit

Permalink
WIP: Make it possible to develop with Vite
Browse files Browse the repository at this point in the history
  • Loading branch information
dschmidt committed Nov 25, 2022
1 parent 499e52b commit 4f94082
Show file tree
Hide file tree
Showing 22 changed files with 2,144 additions and 2,717 deletions.
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"Orta.vscode-jest",
"Vue.volar"
"Vue.volar",
"ZixuanChen.vitest-explorer"
]
}
17 changes: 17 additions & 0 deletions config/vite_oc10/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"server": "http://host.docker.internal:8080",
"theme": "https://host.docker.internal:8081/themes/owncloud/theme.json",
"auth": {
"clientId": "AWhZZsxb59ouGg97HsdR7GiN8pnzEYvk1cL6aVJgTQH1Gcdxly1gendLVTZ5zpYC",
"clientSecret": "VsrTbbeTPJ56e93eKpCdb6Wf5IGHD2meadlsDT1M9EpS3k7Y1ywTYgOhTkKZ0QTL",
"url": "http://host.docker.internal:8080/index.php/apps/oauth2/api/v1/token",
"authUrl": "http://host.docker.internal:8080/index.php/apps/oauth2/authorize",
"logoutUrl": "http://host.docker.internal:8080/index.php/logout"
},
"apps": [
"files",
"text-editor",
"pdf-viewer",
"search"
]
}
19 changes: 19 additions & 0 deletions config/vite_ocis/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"server": "https://host.docker.internal:9200",
"theme": "https://host.docker.internal:9201/themes/owncloud/theme.json",
"openIdConnect": {
"metadata_url": "https://host.docker.internal:9200/.well-known/openid-configuration",
"authority": "https://host.docker.internal:9200",
"client_id": "web",
"response_type": "code",
"scope": "openid profile email"
},
"apps": [
"files",
"text-editor",
"pdf-viewer",
"search",
"external",
"user-management"
]
}
7 changes: 7 additions & 0 deletions dev/docker/oc10.entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ then
UmCVsEIxdWmssxa6uVRRPC3txYBVN4qqxooJbsPhuuoPmHk9Pt9Oy68N4ZaKXUYy \
HW1fo6lbtgEERBQufBouJ4HID2QaDfngvIdc2vjDUE46qKB4JRG1YDir41LliReC \
http://localhost:9100/oidc-callback.html
occ oauth2:add-client \
web-vite \
AWhZZsxb59ouGg97HsdR7GiN8pnzEYvk1cL6aVJgTQH1Gcdxly1gendLVTZ5zpYC \
VsrTbbeTPJ56e93eKpCdb6Wf5IGHD2meadlsDT1M9EpS3k7Y1ywTYgOhTkKZ0QTL \
http://host.docker.internal:8081/oidc-callback.html \
false \
true
occ config:system:set trusted_domains 0 --value="localhost"
occ config:system:set cors.allowed-domains 0 --value="http://localhost:9100"
fi
Expand Down
3 changes: 3 additions & 0 deletions dev/docker/ocis.idp.config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ clients:
redirect_uris:
- https://host.docker.internal:9100/
- https://host.docker.internal:9200/
- https://host.docker.internal:9201/
- https://host.docker.internal:9100/oidc-callback.html
- https://host.docker.internal:9200/oidc-callback.html
- https://host.docker.internal:9201/oidc-callback.html
origins:
- https://host.docker.internal:9100
- https://host.docker.internal:9200
- https://host.docker.internal:9201
21 changes: 11 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,24 @@ services:
- 8080:8080
environment:
OWNCLOUD_LOCKING_ENABLED: "false"
OWNCLOUD_CORS_ALLOWED_DOMAINS: http://host.docker.internal:8081
volumes:
- ${OC10_WEB_CONFIG:-./dev/docker/oc10.web.config.json}:/mnt/data/config/config.json
- ${OC10_CONFIG:-./dev/docker/oc10.config.php}:/mnt/data/config/setup.config.php
- ./dev/docker/oc10.entrypoint.sh:/usr/bin/entrypoint
- ./packages/web-integration-oc10/appinfo:/mnt/data/apps/web/appinfo
- ./packages/web-integration-oc10/lib:/mnt/data/apps/web/lib
- ./dist/css:/mnt/data/apps/web/css
- ./dist/img:/mnt/data/apps/web/img
- ./dist/js:/mnt/data/apps/web/js/
# - ./dist/css:/mnt/data/apps/web/css
# - ./dist/img:/mnt/data/apps/web/img
# - ./dist/js:/mnt/data/apps/web/js/
- ./packages/web-integration-oc10/js/app.js:/mnt/data/apps/web/js/app.js
- ./dist/themes:/mnt/data/apps/web/themes
- ./dist/icons:/mnt/data/apps/web/icons
- ./dist/fonts:/mnt/data/apps/web/fonts
- ./dist/index.html:/mnt/data/apps/web/index.html
- ./dist/manifest.json:/mnt/data/apps/web/manifest.json
- ./dist/oidc-callback.html:/mnt/data/apps/web/oidc-callback.html
- ./dist/oidc-silent-redirect.html:/mnt/data/apps/web/oidc-silent-redirect.html
# - ./dist/themes:/mnt/data/apps/web/themes
# - ./dist/icons:/mnt/data/apps/web/icons
# - ./dist/fonts:/mnt/data/apps/web/fonts
# - ./dist/index.html:/mnt/data/apps/web/index.html
# - ./dist/manifest.json:/mnt/data/apps/web/manifest.json
# - ./dist/oidc-callback.html:/mnt/data/apps/web/oidc-callback.html
# - ./dist/oidc-silent-redirect.html:/mnt/data/apps/web/oidc-silent-redirect.html
extra_hosts:
- host.docker.internal:${DOCKER_HOST:-host-gateway}
entrypoint: /usr/bin/entrypoint
Expand Down
13 changes: 13 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ownCloud</title>
</head>
<body>
<div id="owncloud"></div>
<script type="module" src="../packages/web-runtime/src/index.ts"></script>
</body>
</html>
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
"test:unit": "NODE_OPTIONS=--unhandled-rejections=throw jest --config ./tests/unit/config/jest.config.js",
"licenses:check": "license-checker-rseidelsohn --summary --relativeLicensePath --onlyAllow 'Python-2.0;Apache*;Apache License, Version 2.0;Apache-2.0;Apache 2.0;Artistic-2.0;BSD;BSD-3-Clause;CC-BY-3.0;CC-BY-4.0;CC0-1.0;ISC;MIT;MPL-2.0;Public Domain;Unicode-TOU;Unlicense;WTFPL' --excludePackages '@ownclouders/babel-preset;@ownclouders/eslint-config;@ownclouders/prettier-config;@ownclouders/tsconfig;@ownclouders/web-client;@ownclouders/web-pkg,draw-io;external;web-app-files;text-editor;preview;@ownclouders/design-system;pdf-viewer;web-app-search;user-management;web-runtime'",
"licenses:csv": "license-checker-rseidelsohn --relativeLicensePath --csv --out ./third-party-licenses/third-party-licenses.csv",
"licenses:save": "license-checker-rseidelsohn --relativeLicensePath --out /dev/null --files ./third-party-licenses/third-party-licenses"
"licenses:save": "license-checker-rseidelsohn --relativeLicensePath --out /dev/null --files ./third-party-licenses/third-party-licenses",
"vite": "pnpm vite:ocis",
"vite:ocis": "vite",
"vite:oc10": "OCIS=false vite"
},
"browserslist": [
"last 2 versions",
Expand All @@ -29,6 +32,7 @@
],
"dependencies": {
"keycode": "^2.2.1",
"vite-plugin-static-copy": "^0.12.0",
"vue": "2.7.14"
},
"peerDependencies": {
Expand All @@ -44,6 +48,8 @@
"@cucumber/cucumber": "7.3.2",
"@cucumber/messages": "17.1.1",
"@cucumber/pretty-formatter": "1.0.0",
"@esbuild-plugins/node-globals-polyfill": "^0.1.1",
"@esbuild-plugins/node-modules-polyfill": "^0.1.4",
"@noble/hashes": "1.1.3",
"@ownclouders/design-system": "workspace:*",
"@ownclouders/babel-preset": "workspace:*",
Expand All @@ -65,6 +71,7 @@
"@types/lodash-es": "4.17.6",
"@types/node": "16.18.3",
"@types/node-fetch": "2.6.2",
"@vitejs/plugin-vue2": "2.0.1",
"@vue/test-utils": "1.3.3",
"@vue/vue2-jest": "29.2.0",
"autoprefixer": "10.4.13",
Expand All @@ -88,6 +95,7 @@
"jest-mock-extended": "3.0.1",
"jest-serializer-vue": "2.0.2",
"join-path": "1.1.1",
"jsdom": "^20.0.2",
"license-checker-rseidelsohn": "3.1.0",
"lodash": "4.17.21",
"node-fetch": "2.6.7",
Expand All @@ -103,6 +111,7 @@
"rollup-plugin-gzip": "3.1.0",
"rollup-plugin-livereload": "2.0.5",
"rollup-plugin-modify": "3.0.0",
"rollup-plugin-node-polyfills": "0.2.1",
"rollup-plugin-polyfill-node": "0.11.0",
"rollup-plugin-postcss": "4.0.2",
"rollup-plugin-progress": "1.1.2",
Expand All @@ -116,6 +125,10 @@
"typescript": "4.9.3",
"url-search-params-polyfill": "8.1.1",
"vue-gettext": "2.1.12",
"vite": "3.2.3",
"vite-plugin-environment": "^1.1.3",
"vitest": "^0.25.2",
"vue-tsc": "1.0.9",
"vuex-mock-store": "0.0.8",
"wait-for-expect": "3.0.2"
},
Expand Down
9 changes: 3 additions & 6 deletions packages/tsconfig/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
"downlevelIteration": true,
/* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */

"isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": false,
/* Enable all strict type-checking options. */
Expand Down Expand Up @@ -65,24 +64,22 @@
/* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */

/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */

/* Experimental Options */
"experimentalDecorators": true,
/* Enables experimental support for ES7 decorators. */
//"emitDecoratorMetadata": true,
/* Enables experimental support for emitting type metadata for decorators. */

/* Advanced Options */
"skipLibCheck": true,
/* Skip type checking of declaration files. */
"forceConsistentCasingInFileNames": true
"forceConsistentCasingInFileNames": true,
/* Disallow inconsistently-cased references to the same file. */
"resolveJsonModule": true
},
"exclude": [
"node_modules"
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/components/AppBar/AppBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { defineComponent, PropType } from 'vue'
import { Resource } from 'web-client'
import { BreadcrumbItem } from '../../helpers/breadcrumbs'
import { SpaceResource } from 'web-client/src/helpers'
import { isLocationTrashActive } from 'web-app-files/src/router'
import { isLocationTrashActive } from '../../../src/router'
export default defineComponent({
components: {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/router/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
isLocationTrashActive,
createLocationTrash
} from './trash'
import { ActiveRouteDirectorFunc } from './utils'
import type { ActiveRouteDirectorFunc } from './utils'

const ROOT_ROUTE = {
path: '/',
Expand Down
2 changes: 1 addition & 1 deletion packages/web-app-files/src/services/folder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
FolderLoaderSharedWithMe,
FolderLoaderSharedWithOthers,
FolderLoaderTrashbin
} from './folder/'
} from './folder/index'

export * from './folder/types'

Expand Down
6 changes: 3 additions & 3 deletions packages/web-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { AxiosInstance } from 'axios'
import { graph, Graph } from './graph'
import { ocs, OCS } from './ocs'

export { Graph } from './graph'
export { OCS } from './ocs'
export type { Graph } from './graph'
export type { OCS } from './ocs'

export * as helpers from './helpers'

export { Resource, User } from './helpers'
export type { Resource, User } from './helpers'

interface Client {
graph: Graph
Expand Down
2 changes: 1 addition & 1 deletion packages/web-client/src/ocs/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Capabilities, GetCapabilitiesFactory } from './capabilities'
import { AxiosInstance } from 'axios'

export { Capabilities } from './capabilities'
export type { Capabilities } from './capabilities'

export interface OCS {
getCapabilities: () => Promise<Capabilities>
Expand Down
28 changes: 13 additions & 15 deletions packages/web-runtime/src/container/application/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export { NextApplication } from './next'
const { requirejs, define } = window as any

// register modules with requirejs to provide them to applications
define('vuex', () => {
return vuex
})
define('luxon', () => {
return luxon
})
// define('vuex', () => {
// return vuex
// })
// define('luxon', () => {
// return luxon
// })

/**
* sniffs arguments and decides if given manifest is of next or current application style.
Expand All @@ -46,16 +46,14 @@ export const buildApplication = async ({
throw new RuntimeError('application already announced', applicationPath)
}

const applicationScript: ClassicApplicationScript = await new Promise((resolve, reject) =>
requirejs(
[applicationPath],
(app) => resolve(app),
(err) => reject(err)
)
).catch((e) => {
let applicationScript: ClassicApplicationScript
try {
let modulePath = `/packages/${applicationPath}/src/index`
applicationScript = (await import(modulePath)).default
} catch(e) {
console.error(e)
throw new RuntimeError('cannot load application', applicationPath)
})
throw new RuntimeError('cannot load application', applicationPath, e)
}

let application: NextApplication

Expand Down
3 changes: 1 addition & 2 deletions packages/web-runtime/src/container/versions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { Store } from 'vuex'

export const getWebVersion = (): string => {
const version = process.env.PACKAGE_VERSION
return `ownCloud Web UI ${version}`
return `ownCloud Web UI ${process.env.PACKAGE_VERSION}`
}

export const getBackendVersion = ({ store }: { store: Store<unknown> }): string => {
Expand Down
3 changes: 3 additions & 0 deletions packages/web-runtime/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,6 @@ export const renderFailure = async (err: Error): Promise<void> => {
render: (h) => h(pages.failure)
})
}


bootstrap('config.json').then(renderSuccess).catch(renderFailure)
2 changes: 1 addition & 1 deletion packages/web-runtime/src/layouts/Loading.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<oc-spinner size="xlarge" :aria-label="$gettext('Loading')" />
</div>
</template>
<script>
<script lang="ts">
import { mapGetters } from 'vuex'
export default {
Expand Down
2 changes: 1 addition & 1 deletion packages/web-runtime/src/pages/logout.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<script lang="ts">
import { computed, defineComponent } from 'vue'
import { useRouter, useStore, useTranslations } from 'web-pkg'
import { authService } from 'web-runtime/src/services/auth'
import { authService } from '../services/auth'
export default defineComponent({
name: 'LogoutPage',
Expand Down
2 changes: 1 addition & 1 deletion packages/web-runtime/src/pages/oidcCallback.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<script lang="ts">
import { computed, defineComponent, onMounted, ref, unref } from 'vue'
import { useRoute, useStore } from 'web-pkg'
import { authService } from 'web-runtime/src/services/auth'
import { authService } from '../services/auth'
export default defineComponent({
name: 'OidcCallbackPage',
Expand Down
Loading

0 comments on commit 4f94082

Please sign in to comment.