Skip to content

Commit

Permalink
feat: build process and ci for web-client
Browse files Browse the repository at this point in the history
  • Loading branch information
JammingBen committed Apr 17, 2024
1 parent 547d671 commit 05eb6e5
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 16 deletions.
4 changes: 4 additions & 0 deletions .clean-publish
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"withoutPublish": true,
"tempDir": "package"
}
12 changes: 10 additions & 2 deletions .drone.star
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ def beforePipelines(ctx):

def stagePipelines(ctx):
unit_test_pipelines = unitTests(ctx)

# only run unit tests when publishing a standalone package
if (determineReleasePackage(ctx) != None):
return [] # FIXME: quick iteration, comment in before merge: unit_test_pipelines

e2e_pipelines = e2eTests(ctx)
acceptance_pipelines = acceptance(ctx)
keycloak_pipelines = e2eTestsOnKeycloak(ctx)
Expand Down Expand Up @@ -1078,6 +1083,7 @@ def buildRelease(ctx):
},
]
else:
full_package_name = "%s/%s" % (WEB_PUBLISH_NPM_ORGANIZATION, package)
steps.append(
{
"name": "publish",
Expand All @@ -1088,15 +1094,17 @@ def buildRelease(ctx):
},
},
"commands": [
"echo " + package + " " + version,
"echo Build " + package + " " + version + " package.json: $(jq -r '.version' < packages/%s/package.json)" % package,
"[ \"$(jq -r '.version' < packages/%s/package.json)\" = \"%s\" ] || (echo \"git tag does not match version in packages/%s/package.json\"; exit 1)" % (package, version, package),
"git checkout .",
"git clean -fd",
"git diff",
"git status",
"pnpm build:tokens",
"bash -c '[ \"%s\" == \"web-client\" ] && pnpm --filter \"%s\" vite build || true'" % (package, full_package_name),
# until https://github.com/pnpm/pnpm/issues/5775 is resolved, we print pnpm whoami because that fails when the npm_token is invalid
"env \"npm_config_//registry.npmjs.org/:_authToken=$${NPM_TOKEN}\" pnpm whoami",
"env \"npm_config_//registry.npmjs.org/:_authToken=$${NPM_TOKEN}\" pnpm publish --no-git-checks --filter %s --access public --tag latest" % ("%s/%s" % (WEB_PUBLISH_NPM_ORGANIZATION, package)),
"env \"npm_config_//registry.npmjs.org/:_authToken=$${NPM_TOKEN}\" pnpm publish --no-git-checks --filter %s --access public --tag latest" % full_package_name,
],
"when": {
"ref": [
Expand Down
52 changes: 49 additions & 3 deletions packages/web-client/package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
{
"name": "@ownclouders/web-client",
"version": "0.0.1",
"version": "0.0.2",
"description": "ownCloud web client",
"license": "AGPL-3.0",
"private": false,
"type": "module",
"author": "ownCloud GmbH <[email protected]>",
"homepage": "https://github.com/owncloud/web/tree/master/packages/web-client",
"repository": {
"type": "git",
"url": "https://github.com/owncloud/web",
"directory": "packages/web-client"
},
"files": [
"dist/"
],
"publishConfig": {
"directory": "package",
"linkDirectory": false,
"exports": {
".": {
"default": "./dist/web-client.js",
"require": "./dist/web-client.cjs",
"types": "./dist/src/index.d.ts"
},
"./graph": {
"default": "./dist/web-client/graph.js",
"require": "./dist/web-client/graph.cjs",
"types": "./dist/src/graph/index.d.ts"
},
"./graph/generated": {
"default": "./dist/web-client/graph/generated.js",
"require": "./dist/web-client/graph/generated.cjs",
"types": "./dist/src/graph/generated/index.d.ts"
},
"./ocs": {
"default": "./dist/web-client/ocs.js",
"require": "./dist/web-client/ocs.cjs",
"types": "./dist/src/ocs/index.d.ts"
},
"./sse": {
"default": "./dist/web-client/sse.js",
"require": "./dist/web-client/sse.cjs",
"types": "./dist/src/sse/index.d.ts"
},
"./webdav": {
"default": "./dist/web-client/webdav.js",
"require": "./dist/web-client/webdav.cjs",
"types": "./dist/src/webdav/index.d.ts"
}
}
},
"exports": {
".": {
"default": "./src/index.ts"
Expand All @@ -35,12 +75,18 @@
}
},
"scripts": {
"generate-openapi": "rm -rf src/generated && docker run --rm -v \"${PWD}/src:/local\" openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/owncloud/libre-graph-api/main/api/openapi-spec/v1.0.yaml -g typescript-axios -o /local/generated"
"generate-openapi": "rm -rf src/generated && docker run --rm -v \"${PWD}/src:/local\" openapitools/openapi-generator-cli generate -i https://raw.githubusercontent.com/owncloud/libre-graph-api/main/api/openapi-spec/v1.0.yaml -g typescript-axios -o /local/generated",
"vite": "vite",
"prepublishOnly": "rm -rf ./package && clean-publish && rm -rf package/dist/tests && find package && cat package/package.json",
"postpublish": "rm -rf ./package"
},
"devDependencies": {
"vite-plugin-dts": "3.6.0"
},
"peerDependencies": {
"@ownclouders/web-client": "workspace:*",
"@casl/ability": "^6.3.3",
"axios": "1.6.8",
"clean-publish": "4.2.0",
"fast-xml-parser": "4.3.3",
"lodash-es": "^4.17.21",
"luxon": "3.2.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/web-client/src/webdav/client/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { WebDavResponseResource } from '../../helpers'
import { HttpError } from '../../errors'
import { AxiosInstance } from 'axios'

interface DAVOptions {
export interface DAVOptions {
axiosClient: AxiosInstance
baseUrl: string
}

interface DavResult {
export interface DavResult {
body: WebDavResponseResource[] | undefined
status: number
result: Response
Expand Down
3 changes: 3 additions & 0 deletions packages/web-client/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@ownclouders/tsconfig"
}
33 changes: 33 additions & 0 deletions packages/web-client/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { join, resolve } from 'path'
import { defineConfig, searchForWorkspaceRoot } from 'vite'
import dts from 'vite-plugin-dts'

const projectRootDir = searchForWorkspaceRoot(process.cwd())

export default defineConfig({
resolve: {
alias: {
path: 'rollup-plugin-node-polyfills/polyfills/path',
crypto: join(projectRootDir, 'polyfills/crypto.js'),
stream: 'rollup-plugin-node-polyfills/polyfills/stream',
string_decoder: 'rollup-plugin-node-polyfills/polyfills/string-decoder',
util: 'rollup-plugin-node-polyfills/polyfills/util',
buffer: 'rollup-plugin-node-polyfills/polyfills/buffer-es6',
process: 'rollup-plugin-node-polyfills/polyfills/process-es6',
events: 'rollup-plugin-node-polyfills/polyfills/events'
}
},
build: {
lib: {
entry: {
'web-client': resolve(__dirname, 'src/index.ts'),
'web-client/graph': resolve(__dirname, 'src/graph/index.ts'),
'web-client/graph/generated': resolve(__dirname, 'src/graph/generated/index.ts'),
'web-client/ocs': resolve(__dirname, 'src/ocs/index.ts'),
'web-client/sse': resolve(__dirname, 'src/sse/index.ts'),
'web-client/webdav': resolve(__dirname, 'src/webdav/index.ts')
}
}
},
plugins: [dts()]
})
Loading

0 comments on commit 05eb6e5

Please sign in to comment.