From 62f89abbd0b8d9449f29b55b3b24ac581624b6a4 Mon Sep 17 00:00:00 2001 From: Markus Hederstrom Date: Tue, 15 Jul 2025 13:03:23 +0200 Subject: [PATCH] Initial commit --- templates/cli-component/package.json | 22 ++++++++ templates/cli-component/src/index.js | 1 + .../cli-setup/.gitea/workflows/deploy.yaml | 35 +++++++++++++ templates/cli/.gitignore | 2 + templates/cli/.npmrc | 1 + templates/cli/index.html | 13 +++++ templates/cli/package.json | 23 +++++++++ templates/cli/src/index.ts | 1 + templates/cli/tsconfig.json | 21 ++++++++ templates/cli/vite.config.ts | 6 +++ .../default/.gitea/workflows/deploy.yaml | 35 +++++++++++++ templates/default/.gitignore | 1 + templates/default/.npmrc | 1 + templates/default/index.html | 13 +++++ templates/default/index.js | 27 ++++++++++ templates/default/package.json | 23 +++++++++ templates/default/vite.config.js | 6 +++ templates/default/webprovisions.json | 6 +++ templates/site/.gitea/workflows/deploy.yaml | 35 +++++++++++++ templates/site/.gitignore | 1 + templates/site/.npmrc | 1 + templates/site/index.html | 13 +++++ templates/site/index.js | 14 +++++ templates/site/package.json | 19 +++++++ templates/site/vite.config.js | 6 +++ templates/site/webprovisions.json | 6 +++ .../.gitea/workflows/deploy.yaml | 35 +++++++++++++ templates/widget-template/.gitignore | 1 + templates/widget-template/.npmrc | 1 + templates/widget-template/index.html | 13 +++++ templates/widget-template/index.js | 51 +++++++++++++++++++ templates/widget-template/package.json | 25 +++++++++ templates/widget-template/vite.config.js | 6 +++ templates/widget-template/webprovisions.json | 6 +++ 34 files changed, 470 insertions(+) create mode 100644 templates/cli-component/package.json create mode 100644 templates/cli-component/src/index.js create mode 100644 templates/cli-setup/.gitea/workflows/deploy.yaml create mode 100644 templates/cli/.gitignore create mode 100644 templates/cli/.npmrc create mode 100644 templates/cli/index.html create mode 100644 templates/cli/package.json create mode 100644 templates/cli/src/index.ts create mode 100644 templates/cli/tsconfig.json create mode 100644 templates/cli/vite.config.ts create mode 100644 templates/default/.gitea/workflows/deploy.yaml create mode 100644 templates/default/.gitignore create mode 100644 templates/default/.npmrc create mode 100644 templates/default/index.html create mode 100644 templates/default/index.js create mode 100644 templates/default/package.json create mode 100644 templates/default/vite.config.js create mode 100644 templates/default/webprovisions.json create mode 100644 templates/site/.gitea/workflows/deploy.yaml create mode 100644 templates/site/.gitignore create mode 100644 templates/site/.npmrc create mode 100644 templates/site/index.html create mode 100644 templates/site/index.js create mode 100644 templates/site/package.json create mode 100644 templates/site/vite.config.js create mode 100644 templates/site/webprovisions.json create mode 100644 templates/widget-template/.gitea/workflows/deploy.yaml create mode 100644 templates/widget-template/.gitignore create mode 100644 templates/widget-template/.npmrc create mode 100644 templates/widget-template/index.html create mode 100644 templates/widget-template/index.js create mode 100644 templates/widget-template/package.json create mode 100644 templates/widget-template/vite.config.js create mode 100644 templates/widget-template/webprovisions.json diff --git a/templates/cli-component/package.json b/templates/cli-component/package.json new file mode 100644 index 0000000..7a6b4fa --- /dev/null +++ b/templates/cli-component/package.json @@ -0,0 +1,22 @@ +{ + "name": "", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "type": "module", + "author": "", + "dependencies": {}, + "scripts": { + "start": "npx vite --open", + "build-prod": "npx vite build", + "build-dev": "npx vite build --mode development" + }, + "devDependencies": { + "vite": "^4.4.9", + "@webprovisions/utilities": "^1.0.3", + "typescript": "^5.1.6" + }, + "webprovisions": { + "type": "distribution" + } +} diff --git a/templates/cli-component/src/index.js b/templates/cli-component/src/index.js new file mode 100644 index 0000000..77f366e --- /dev/null +++ b/templates/cli-component/src/index.js @@ -0,0 +1 @@ +console.log('Hello from Webprovisions component!'); diff --git a/templates/cli-setup/.gitea/workflows/deploy.yaml b/templates/cli-setup/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..8cf1852 --- /dev/null +++ b/templates/cli-setup/.gitea/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: Deploy Distribution +run-name: ${{ gitea.actor }} is Deploying 🚀 +on: [release] + +jobs: + Deploy-Distribution: + runs-on: ubuntu-latest + steps: + - run: echo "Deploying to Cloud 🚀" + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Verify components + uses: https://source.webprovisions.io/webprovisions/registry-action@v4 + with: + registry-token: ${{ secrets.REGISTRY_KEY }} + + - name: Start build + run: | + curl -X PUT "${{secrets.wpapi}}/distributions/${{env.GITHUB_REPOSITORY}}/status" \ + -H "Content-Type: application/json" \ + -d '{"version": "'${{ github.event.release.tag_name }}'", "status": "in-progress"}' + + - name: Install Dependencies & Build + run: | + npm install + npm run build-prod + + - name: Deploy Distribution + uses: https://source.webprovisions.io/webprovisions/deploy-action@v1 + with: + minio_access_key: ${{ secrets.minioaccess }} + minio_secret_key: ${{ secrets.miniosecret }} + minio_host: ${{ secrets.miniohost }} + wp_api: ${{ secrets.wpapi }} diff --git a/templates/cli/.gitignore b/templates/cli/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/templates/cli/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/templates/cli/.npmrc b/templates/cli/.npmrc new file mode 100644 index 0000000..a64415e --- /dev/null +++ b/templates/cli/.npmrc @@ -0,0 +1 @@ +@webprovisions-registry:registry=https://registry.webprovisions.io \ No newline at end of file diff --git a/templates/cli/index.html b/templates/cli/index.html new file mode 100644 index 0000000..9456b51 --- /dev/null +++ b/templates/cli/index.html @@ -0,0 +1,13 @@ + + + Webprovisions Development + + + + + + + diff --git a/templates/cli/package.json b/templates/cli/package.json new file mode 100644 index 0000000..06bad6a --- /dev/null +++ b/templates/cli/package.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://developers.webprovisions.io/schemas/2021-11/webprovisions-manifest.schema.json", + "name": "@webprovisions-registry/", + "version": "1.0.0", + "description": "", + "main": "src/index.js", + "type": "module", + "author": "", + "dependencies": {}, + "scripts": { + "start": "npx vite --open", + "build-prod": "npx vite build", + "build-dev": "npx vite build --mode development" + }, + "devDependencies": { + "vite": "^4.4.9", + "@webprovisions/utilities": "^1.0.3", + "typescript": "^5.1.6" + }, + "webprovisions": { + "type": "distribution" + } +} diff --git a/templates/cli/src/index.ts b/templates/cli/src/index.ts new file mode 100644 index 0000000..e1d712a --- /dev/null +++ b/templates/cli/src/index.ts @@ -0,0 +1 @@ +console.log('Hello from distribution!'); diff --git a/templates/cli/tsconfig.json b/templates/cli/tsconfig.json new file mode 100644 index 0000000..5e17e93 --- /dev/null +++ b/templates/cli/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "module": "ESNext", + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "skipLibCheck": true, + + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"] +} diff --git a/templates/cli/vite.config.ts b/templates/cli/vite.config.ts new file mode 100644 index 0000000..5e99dbe --- /dev/null +++ b/templates/cli/vite.config.ts @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; +import { webprovisionsPackageVitePlugin } from '@webprovisions/utilities'; + +export default defineConfig({ + plugins: [webprovisionsPackageVitePlugin()], +}); diff --git a/templates/default/.gitea/workflows/deploy.yaml b/templates/default/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..67f5202 --- /dev/null +++ b/templates/default/.gitea/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: Deploy Distribution +run-name: ${{ gitea.actor }} is Deploying 🚀 +on: [release] + +jobs: + Deploy Distribution: + runs-on: ubuntu-latest + steps: + - run: echo "Deploying to Cloud 🚀" + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Verify components + uses: https://source.webprovisions.io/webprovisions/registry-action@v4 + with: + registry-token: ${{ secrets.REGISTRY_KEY }} + + - name: Start build + run: | + curl -X PUT "${{secrets.wpapi}}/distributions/${{env.GITHUB_REPOSITORY}}/status" \ + -H "Content-Type: application/json" \ + -d '{"version": "'${{ github.event.release.tag_name }}'", "status": "in-progress"}' + + - name: Install Dependencies & Build + run: | + npm install + npm run build-prod + + - name: Deploy Distribution + uses: https://source.webprovisions.io/webprovisions/deploy-action@v9 + with: + minio_access_key: ${{ secrets.minioaccess }} + minio_secret_key: ${{ secrets.miniosecret }} + minio_host: ${{ secrets.miniohost }} + wp_api: ${{ secrets.wpapi }} diff --git a/templates/default/.gitignore b/templates/default/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/templates/default/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/templates/default/.npmrc b/templates/default/.npmrc new file mode 100644 index 0000000..a64415e --- /dev/null +++ b/templates/default/.npmrc @@ -0,0 +1 @@ +@webprovisions-registry:registry=https://registry.webprovisions.io \ No newline at end of file diff --git a/templates/default/index.html b/templates/default/index.html new file mode 100644 index 0000000..d20dfee --- /dev/null +++ b/templates/default/index.html @@ -0,0 +1,13 @@ + + + Webprovisions Development + + + + + + + diff --git a/templates/default/index.js b/templates/default/index.js new file mode 100644 index 0000000..1fa857b --- /dev/null +++ b/templates/default/index.js @@ -0,0 +1,27 @@ +// ##RUNTIME_IMPORT## +import { bootstrap } from '@telia-ace/widget-core-flamingo'; +// ##PLUGIN_IMPORTS## + +const client = createHttpClient('https://widgets.ace.teliacompany.net/v1'); + +(async () => { + bootstrap( + { + httpClient: client, + apps: [ + { + renderStrategy: 'trigger', + autoActivate: true, + widgetId: '##WIDGET_ID##', + triggerIcon: 'question', + }, + ], + }, + (siteConfig) => { + siteConfig.applications.forEach((config) => { + // ##PLUGINS## + }); + } + ); +})(); + diff --git a/templates/default/package.json b/templates/default/package.json new file mode 100644 index 0000000..ff8fafb --- /dev/null +++ b/templates/default/package.json @@ -0,0 +1,23 @@ +{ + "$schema": "https://developers.webprovisions.io/schemas/2021-11/webprovisions-manifest.schema.json", + "name": "@webprovisions-registry/", + "version": "", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "start": "npx vite --open", + "build-prod": "npx vite build", + "build-dev": "npx vite build --mode development" + }, + "author": "", + "license": "ISC", + "dependencies": {}, + "devDependencies": { + "vite": "^4.1.4", + "@webprovisions/utilities": "^1.0.3" + }, + "webprovisions": { + "type": "distribution" + } +} diff --git a/templates/default/vite.config.js b/templates/default/vite.config.js new file mode 100644 index 0000000..5e99dbe --- /dev/null +++ b/templates/default/vite.config.js @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; +import { webprovisionsPackageVitePlugin } from '@webprovisions/utilities'; + +export default defineConfig({ + plugins: [webprovisionsPackageVitePlugin()], +}); diff --git a/templates/default/webprovisions.json b/templates/default/webprovisions.json new file mode 100644 index 0000000..c558d0b --- /dev/null +++ b/templates/default/webprovisions.json @@ -0,0 +1,6 @@ +{ + "distributionName": "", + "version": "1.0.0", + "organizationName": "", + "remote": "" +} \ No newline at end of file diff --git a/templates/site/.gitea/workflows/deploy.yaml b/templates/site/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..34ba9e1 --- /dev/null +++ b/templates/site/.gitea/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: Deploy Distribution +run-name: ${{ gitea.actor }} is Deploying 🚀 +on: [release] + +jobs: + Deploy Distribution: + runs-on: ubuntu-latest + steps: + - run: echo "Deploying to Cloud 🚀" + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Verify components + uses: https://source.webprovisions.io/webprovisions/registry-action@v4 + with: + registry-token: ${{ secrets.REGISTRY_KEY }} + + - name: Start build + run: | + curl -X PUT "${{secrets.wpapi}}/distributions/${{env.GITHUB_REPOSITORY}}/status" \ + -H "Content-Type: application/json" \ + -d '{"version": "'${{ github.event.release.tag_name }}'", "status": "in-progress"}' + + - name: Install Dependencies & Build + run: | + npm install + npm run build-prod + + - name: Deploy Distribution + uses: https://source.webprovisions.io/webprovisions/deploy-action@v1 + with: + minio_access_key: ${{ secrets.minioaccess }} + minio_secret_key: ${{ secrets.miniosecret }} + minio_host: ${{ secrets.miniohost }} + wp_api: ${{ secrets.wpapi }} \ No newline at end of file diff --git a/templates/site/.gitignore b/templates/site/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/templates/site/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/templates/site/.npmrc b/templates/site/.npmrc new file mode 100644 index 0000000..a64415e --- /dev/null +++ b/templates/site/.npmrc @@ -0,0 +1 @@ +@webprovisions-registry:registry=https://registry.webprovisions.io \ No newline at end of file diff --git a/templates/site/index.html b/templates/site/index.html new file mode 100644 index 0000000..c83112a --- /dev/null +++ b/templates/site/index.html @@ -0,0 +1,13 @@ + + + Webprovisions Development + + + + + + + \ No newline at end of file diff --git a/templates/site/index.js b/templates/site/index.js new file mode 100644 index 0000000..52b0968 --- /dev/null +++ b/templates/site/index.js @@ -0,0 +1,14 @@ +// ##RUNTIME_IMPORT## +import { bootstrap } from '@telia-ace/widget-core-flamingo'; +// ##PLUGIN_IMPORTS## + +(async () => { + bootstrap( + '##SITE_URL##', + (siteConfig) => { + siteConfig.applications.forEach((config) => { + // ##PLUGINS## + }); + } + ); +})(); \ No newline at end of file diff --git a/templates/site/package.json b/templates/site/package.json new file mode 100644 index 0000000..a2d472b --- /dev/null +++ b/templates/site/package.json @@ -0,0 +1,19 @@ +{ + "name": "@webprovisions-registry/", + "version": "", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "start": "npx vite --open", + "build-prod": "npx vite build", + "build-dev": "npx vite build --mode development" + }, + "author": "", + "license": "ISC", + "dependencies": {}, + "devDependencies": { + "vite": "^4.1.4", + "@webprovisions/utilities": "^1.0.3" + } +} \ No newline at end of file diff --git a/templates/site/vite.config.js b/templates/site/vite.config.js new file mode 100644 index 0000000..f370654 --- /dev/null +++ b/templates/site/vite.config.js @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; +import { webprovisionsPackageVitePlugin } from '@webprovisions/utilities'; + +export default defineConfig({ + plugins: [webprovisionsPackageVitePlugin()], +}); \ No newline at end of file diff --git a/templates/site/webprovisions.json b/templates/site/webprovisions.json new file mode 100644 index 0000000..473c2a1 --- /dev/null +++ b/templates/site/webprovisions.json @@ -0,0 +1,6 @@ +{ + "distributionName": "", + "version": "1.0.0", + "organizationName": "", + "remote": "" +} \ No newline at end of file diff --git a/templates/widget-template/.gitea/workflows/deploy.yaml b/templates/widget-template/.gitea/workflows/deploy.yaml new file mode 100644 index 0000000..a03190c --- /dev/null +++ b/templates/widget-template/.gitea/workflows/deploy.yaml @@ -0,0 +1,35 @@ +name: Deploy Distribution +run-name: ${{ gitea.actor }} is Deploying 🚀 +on: [release] + +jobs: + Deploy Distribution: + runs-on: ubuntu-latest + steps: + - run: echo "Deploying to Cloud 🚀" + - name: Check out repository code + uses: actions/checkout@v3 + + - name: Verify components + uses: https://source.webprovisions.io/webprovisions/registry-action@v4 + with: + registry-token: ${{ secrets.REGISTRY_KEY }} + + - name: Start build + run: | + curl -X PUT "${{secrets.wpapi}}/distributions/${{env.GITHUB_REPOSITORY}}/status" \ + -H "Content-Type: application/json" \ + -d '{"version": "'${{ github.event.release.tag_name }}'", "status": "in-progress"}' + + - name: Install Dependencies & Build + run: | + npm install + npm run build-prod + + - name: Deploy Distribution + uses: https://source.webprovisions.io/webprovisions/deploy-action@v1 + with: + minio_access_key: ${{ secrets.minioaccess }} + minio_secret_key: ${{ secrets.miniosecret }} + minio_host: ${{ secrets.miniohost }} + wp_api: ${{ secrets.wpapi }} \ No newline at end of file diff --git a/templates/widget-template/.gitignore b/templates/widget-template/.gitignore new file mode 100644 index 0000000..b512c09 --- /dev/null +++ b/templates/widget-template/.gitignore @@ -0,0 +1 @@ +node_modules \ No newline at end of file diff --git a/templates/widget-template/.npmrc b/templates/widget-template/.npmrc new file mode 100644 index 0000000..a64415e --- /dev/null +++ b/templates/widget-template/.npmrc @@ -0,0 +1 @@ +@webprovisions-registry:registry=https://registry.webprovisions.io \ No newline at end of file diff --git a/templates/widget-template/index.html b/templates/widget-template/index.html new file mode 100644 index 0000000..c83112a --- /dev/null +++ b/templates/widget-template/index.html @@ -0,0 +1,13 @@ + + + Webprovisions Development + + + + + + + \ No newline at end of file diff --git a/templates/widget-template/index.js b/templates/widget-template/index.js new file mode 100644 index 0000000..160793f --- /dev/null +++ b/templates/widget-template/index.js @@ -0,0 +1,51 @@ +// ##RUNTIME_IMPORT## +import { bootstrap, createHttpClient } from "@telia-ace/widget-core-flamingo"; +// ##PLUGIN_IMPORTS## + +const client = createHttpClient("https://widgets.ace.teliacompany.net/v1"); + +const getDetails = async () => { + const currentScript = new URL(import.meta.url); + const parts = currentScript.pathname.replace('/v1/install/', '').split('/'); + + const organization = parts[0]; + const distribution = parts[1]; + + const resp = await fetch(`https://widgets.ace.teliacompany.net/v1/widget/dist/${organization}/${distribution}`); + const json = await resp.json(); + + return json.id; +}; + +(async () => { + getDetails(); + + let widgetId = ""; + + try { + widgetId = await getDetails(); + } catch { + console.log("Widget not found"); + return; + } + + bootstrap( + { + httpClient: client, + apps: [ + { + renderStrategy: "trigger", + autoActivate: true, + // widgetId: "__#_#WIDGET_ID__#__#", + widgetId: widgetId, + triggerIcon: "question", + }, + ], + }, + (siteConfig) => { + siteConfig.applications.forEach((config) => { + // ##PLUGINS## + }); + }, + ); +})(); diff --git a/templates/widget-template/package.json b/templates/widget-template/package.json new file mode 100644 index 0000000..782710f --- /dev/null +++ b/templates/widget-template/package.json @@ -0,0 +1,25 @@ +{ + "$schema": "https://developers.webprovisions.io/schemas/2021-11/webprovisions-manifest.schema.json", + "name": "@webprovisions-registry/", + "version": "", + "description": "", + "main": "index.js", + "type": "module", + "scripts": { + "start": "npx vite --open", + "build-prod": "npx vite build", + "build-dev": "npx vite build --mode development" + }, + "author": "", + "license": "ISC", + "dependencies": { + "@telia-ace/widget-core-flamingo": "latest" + }, + "devDependencies": { + "vite": "^4.1.4", + "@webprovisions/utilities": "^1.0.3" + }, + "webprovisions": { + "type": "distribution" + } +} \ No newline at end of file diff --git a/templates/widget-template/vite.config.js b/templates/widget-template/vite.config.js new file mode 100644 index 0000000..f370654 --- /dev/null +++ b/templates/widget-template/vite.config.js @@ -0,0 +1,6 @@ +import { defineConfig } from 'vite'; +import { webprovisionsPackageVitePlugin } from '@webprovisions/utilities'; + +export default defineConfig({ + plugins: [webprovisionsPackageVitePlugin()], +}); \ No newline at end of file diff --git a/templates/widget-template/webprovisions.json b/templates/widget-template/webprovisions.json new file mode 100644 index 0000000..473c2a1 --- /dev/null +++ b/templates/widget-template/webprovisions.json @@ -0,0 +1,6 @@ +{ + "distributionName": "", + "version": "1.0.0", + "organizationName": "", + "remote": "" +} \ No newline at end of file