From 71d983587e49295829406c1654600ac054c3d46b Mon Sep 17 00:00:00 2001 From: jotanarciso Date: Tue, 5 Nov 2024 20:06:38 -0300 Subject: [PATCH 1/2] feat: presets --- package-lock.json | 21 +++++- package.json | 8 +++ packages/config/tsconfig.json | 2 +- packages/presets/.gitignore | 2 + packages/presets/jest.config.js | 10 +++ packages/presets/package.json | 36 ++++++++++ packages/presets/src/index.ts | 65 +++++++++++++++++++ .../presets/src/presets/angular/config.ts | 50 ++++++++++++++ packages/presets/src/presets/angular/index.ts | 9 +++ packages/presets/src/presets/astro/config.ts | 56 ++++++++++++++++ packages/presets/src/presets/astro/index.ts | 9 +++ .../presets/src/presets/docusaurus/config.ts | 56 ++++++++++++++++ .../presets/src/presets/docusaurus/index.ts | 9 +++ .../presets/src/presets/eleventy/config.ts | 56 ++++++++++++++++ .../presets/src/presets/eleventy/index.ts | 9 +++ .../presets/src/presets/emscripten/config.ts | 24 +++++++ .../presets/src/presets/emscripten/index.ts | 9 +++ packages/presets/src/presets/gatsby/config.ts | 54 +++++++++++++++ packages/presets/src/presets/gatsby/index.ts | 9 +++ packages/presets/src/presets/hexo/config.ts | 54 +++++++++++++++ packages/presets/src/presets/hexo/index.ts | 9 +++ packages/presets/src/presets/html/config.ts | 29 +++++++++ packages/presets/src/presets/html/index.ts | 9 +++ packages/presets/src/presets/hugo/config.ts | 54 +++++++++++++++ packages/presets/src/presets/hugo/index.ts | 9 +++ .../presets/src/presets/javascript/config.ts | 22 +++++++ .../presets/src/presets/javascript/index.ts | 9 +++ packages/presets/src/presets/jekyll/config.ts | 54 +++++++++++++++ packages/presets/src/presets/jekyll/index.ts | 9 +++ packages/presets/src/presets/next/config.ts | 51 +++++++++++++++ packages/presets/src/presets/next/index.ts | 9 +++ packages/presets/src/presets/nuxt/config.ts | 56 ++++++++++++++++ packages/presets/src/presets/nuxt/index.ts | 9 +++ packages/presets/src/presets/react/config.ts | 49 ++++++++++++++ packages/presets/src/presets/react/index.ts | 9 +++ .../presets/src/presets/rustwasm/config.ts | 22 +++++++ .../presets/src/presets/rustwasm/index.ts | 9 +++ packages/presets/src/presets/svelte/config.ts | 56 ++++++++++++++++ packages/presets/src/presets/svelte/index.ts | 9 +++ .../presets/src/presets/typescript/config.ts | 22 +++++++ .../presets/src/presets/typescript/index.ts | 9 +++ .../presets/src/presets/vitepress/config.ts | 54 +++++++++++++++ .../presets/src/presets/vitepress/index.ts | 9 +++ packages/presets/src/presets/vue/config.ts | 48 ++++++++++++++ packages/presets/src/presets/vue/index.ts | 9 +++ packages/presets/src/types.ts | 8 +++ packages/presets/tsconfig.json | 25 +++++++ 47 files changed, 1211 insertions(+), 4 deletions(-) create mode 100644 packages/presets/.gitignore create mode 100644 packages/presets/jest.config.js create mode 100644 packages/presets/package.json create mode 100644 packages/presets/src/index.ts create mode 100644 packages/presets/src/presets/angular/config.ts create mode 100644 packages/presets/src/presets/angular/index.ts create mode 100644 packages/presets/src/presets/astro/config.ts create mode 100644 packages/presets/src/presets/astro/index.ts create mode 100644 packages/presets/src/presets/docusaurus/config.ts create mode 100644 packages/presets/src/presets/docusaurus/index.ts create mode 100644 packages/presets/src/presets/eleventy/config.ts create mode 100644 packages/presets/src/presets/eleventy/index.ts create mode 100644 packages/presets/src/presets/emscripten/config.ts create mode 100644 packages/presets/src/presets/emscripten/index.ts create mode 100644 packages/presets/src/presets/gatsby/config.ts create mode 100644 packages/presets/src/presets/gatsby/index.ts create mode 100644 packages/presets/src/presets/hexo/config.ts create mode 100644 packages/presets/src/presets/hexo/index.ts create mode 100644 packages/presets/src/presets/html/config.ts create mode 100644 packages/presets/src/presets/html/index.ts create mode 100644 packages/presets/src/presets/hugo/config.ts create mode 100644 packages/presets/src/presets/hugo/index.ts create mode 100644 packages/presets/src/presets/javascript/config.ts create mode 100644 packages/presets/src/presets/javascript/index.ts create mode 100644 packages/presets/src/presets/jekyll/config.ts create mode 100644 packages/presets/src/presets/jekyll/index.ts create mode 100644 packages/presets/src/presets/next/config.ts create mode 100644 packages/presets/src/presets/next/index.ts create mode 100644 packages/presets/src/presets/nuxt/config.ts create mode 100644 packages/presets/src/presets/nuxt/index.ts create mode 100644 packages/presets/src/presets/react/config.ts create mode 100644 packages/presets/src/presets/react/index.ts create mode 100644 packages/presets/src/presets/rustwasm/config.ts create mode 100644 packages/presets/src/presets/rustwasm/index.ts create mode 100644 packages/presets/src/presets/svelte/config.ts create mode 100644 packages/presets/src/presets/svelte/index.ts create mode 100644 packages/presets/src/presets/typescript/config.ts create mode 100644 packages/presets/src/presets/typescript/index.ts create mode 100644 packages/presets/src/presets/vitepress/config.ts create mode 100644 packages/presets/src/presets/vitepress/index.ts create mode 100644 packages/presets/src/presets/vue/config.ts create mode 100644 packages/presets/src/presets/vue/index.ts create mode 100644 packages/presets/src/types.ts create mode 100644 packages/presets/tsconfig.json diff --git a/package-lock.json b/package-lock.json index 8f510e9..ba96cba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "azion", - "version": "1.8.2", + "version": "1.9.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "azion", - "version": "1.8.2", + "version": "1.9.0", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -17,7 +17,8 @@ "progress": "^2.0.3" }, "bin": { - "azion": "bin/azion" + "azion": "bin/azion", + "azlib": "bin/azion" }, "devDependencies": { "@commitlint/cli": "^18.4.1", @@ -2241,6 +2242,10 @@ "resolved": "packages/jwt", "link": true }, + "node_modules/@lib/presets": { + "resolved": "packages/presets", + "link": true + }, "node_modules/@lib/purge": { "resolved": "packages/purge", "link": true @@ -14569,6 +14574,16 @@ "typescript": "^5.5.3" } }, + "packages/presets": { + "name": "@lib/presets", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "ajv": "^8.17.1", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } + }, "packages/purge": { "name": "@lib/purge", "version": "1.0.0", diff --git a/package.json b/package.json index 65b1ca6..f85764d 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,11 @@ "import": "./packages/client/dist/index.mjs", "types": "./packages/client/dist/index.d.ts" }, + "./presets": { + "require": "./packages/presets/dist/index.js", + "import": "./packages/presets/dist/index.mjs", + "types": "./packages/presets/dist/index.d.ts" + }, "./ai": { "require": "./packages/ai/dist/index.js", "import": "./packages/ai/dist/index.mjs", @@ -153,6 +158,9 @@ "ai": [ "./packages/ai/dist/index.d.ts" ], + "presets": [ + "./packages/presets/dist/index.d.ts" + ], "application": [ "./packages/application/dist/index.d.ts" ], diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json index 9603f77..68f8166 100644 --- a/packages/config/tsconfig.json +++ b/packages/config/tsconfig.json @@ -7,7 +7,7 @@ "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true, - "moduleResolution": "node", + "moduleResolution": "bundler", "isolatedModules": true, "resolveJsonModule": true } diff --git a/packages/presets/.gitignore b/packages/presets/.gitignore new file mode 100644 index 0000000..76add87 --- /dev/null +++ b/packages/presets/.gitignore @@ -0,0 +1,2 @@ +node_modules +dist \ No newline at end of file diff --git a/packages/presets/jest.config.js b/packages/presets/jest.config.js new file mode 100644 index 0000000..b71a63f --- /dev/null +++ b/packages/presets/jest.config.js @@ -0,0 +1,10 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + displayName: 'Utils', + preset: 'ts-jest', + transform: { + '^.+\\.(t|j)s?$': '@swc/jest', + }, + testPathIgnorePatterns: ['/node_modules/', '/dist/'], + testEnvironment: 'node', +}; diff --git a/packages/presets/package.json b/packages/presets/package.json new file mode 100644 index 0000000..4d2b69e --- /dev/null +++ b/packages/presets/package.json @@ -0,0 +1,36 @@ +{ + "name": "@lib/presets", + "version": "1.0.0", + "description": "", + "main": "./dist/index.js", + "module": "./dist/index.mjs", + "scripts": { + "compile": "tsup --config ../../tsup.config.json", + "lint": "eslint .", + "lint:fix": "eslint --fix .", + "test": "jest --clearCache && jest -c jest.config.js .", + "test:watch": "jest -c jest.config.js . --watch", + "test:coverage": "jest --clearCache && jest -c jest.config.js . --coverage", + "prettier": "prettier --write .", + "prettier:check": "prettier --check ." + }, + "types": "./dist/index.d.ts", + "exports": { + ".": { + "require": "./dist/index.js", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } + }, + "author": "aziontech", + "license": "MIT", + "files": [ + "dist", + "package.json" + ], + "devDependencies": { + "ajv": "^8.17.1", + "ajv-errors": "^3.0.0", + "ajv-keywords": "^5.1.0" + } +} diff --git a/packages/presets/src/index.ts b/packages/presets/src/index.ts new file mode 100644 index 0000000..e02bca4 --- /dev/null +++ b/packages/presets/src/index.ts @@ -0,0 +1,65 @@ +import Angular from './presets/angular/index'; +import Astro from './presets/astro/index'; +import Docusaurus from './presets/docusaurus/index'; +import Eleventy from './presets/eleventy/index'; +import Emscripten from './presets/emscripten/index'; +import Gatsby from './presets/gatsby/index'; +import Hexo from './presets/hexo/index'; +import Html from './presets/html/index'; +import Hugo from './presets/hugo/index'; +import JavaScript from './presets/javascript/index'; +import Jekyll from './presets/jekyll/index'; +import Next from './presets/next/index'; +import Nuxt from './presets/nuxt/index'; +import React from './presets/react/index'; +import RustWasm from './presets/rustwasm/index'; +import Svelte from './presets/svelte/index'; +import TypeScript from './presets/typescript/index'; +import VitePress from './presets/vitepress/index'; +import Vue from './presets/vue/index'; + +const presets = { + Angular, + Astro, + Docusaurus, + Eleventy, + Emscripten, + Gatsby, + Hexo, + Html, + Hugo, + JavaScript, + Jekyll, + Next, + Nuxt, + React, + RustWasm, + Svelte, + TypeScript, + VitePress, + Vue, +}; + +export { + Angular, + Astro, + Docusaurus, + Eleventy, + Emscripten, + Gatsby, + Hexo, + Html, + Hugo, + JavaScript, + Jekyll, + Next, + Nuxt, + React, + RustWasm, + Svelte, + TypeScript, + VitePress, + Vue, +}; + +export default presets; diff --git a/packages/presets/src/presets/angular/config.ts b/packages/presets/src/presets/angular/config.ts new file mode 100644 index 0000000..2102406 --- /dev/null +++ b/packages/presets/src/presets/angular/config.ts @@ -0,0 +1,50 @@ +import { defineConfig } from 'azion/config'; + +const config = defineConfig({ + build: { + preset: { + name: 'angular', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '^\\/', + behavior: { + rewrite: `/index.html`, + }, + }, + ], + }, +}); + +export default config; diff --git a/packages/presets/src/presets/angular/index.ts b/packages/presets/src/presets/angular/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/angular/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/astro/config.ts b/packages/presets/src/presets/astro/config.ts new file mode 100644 index 0000000..790751c --- /dev/null +++ b/packages/presets/src/presets/astro/config.ts @@ -0,0 +1,56 @@ +import { defineConfig } from 'azion/config'; + +const config = defineConfig({ + build: { + preset: { + name: 'astro', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); + +export default config; diff --git a/packages/presets/src/presets/astro/index.ts b/packages/presets/src/presets/astro/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/astro/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/docusaurus/config.ts b/packages/presets/src/presets/docusaurus/config.ts new file mode 100644 index 0000000..23e5289 --- /dev/null +++ b/packages/presets/src/presets/docusaurus/config.ts @@ -0,0 +1,56 @@ +import { defineConfig } from 'azion/config'; + +const config = defineConfig({ + build: { + preset: { + name: 'docusaurus', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); + +export default config; diff --git a/packages/presets/src/presets/docusaurus/index.ts b/packages/presets/src/presets/docusaurus/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/docusaurus/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/eleventy/config.ts b/packages/presets/src/presets/eleventy/config.ts new file mode 100644 index 0000000..c59313a --- /dev/null +++ b/packages/presets/src/presets/eleventy/config.ts @@ -0,0 +1,56 @@ +import { defineConfig } from 'azion/config'; + +const config = defineConfig({ + build: { + preset: { + name: 'eleventy', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); + +export default config; diff --git a/packages/presets/src/presets/eleventy/index.ts b/packages/presets/src/presets/eleventy/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/eleventy/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/emscripten/config.ts b/packages/presets/src/presets/emscripten/config.ts new file mode 100644 index 0000000..4a476bb --- /dev/null +++ b/packages/presets/src/presets/emscripten/config.ts @@ -0,0 +1,24 @@ +import { defineConfig } from 'azion/config'; + +const config = defineConfig({ + build: { + preset: { + name: 'emscripten', + }, + }, + rules: { + request: [ + { + name: 'Execute Edge Function', + match: '^\\/', + behavior: { + runFunction: { + path: '.edge/worker.js', + }, + }, + }, + ], + }, +}); + +export default config; diff --git a/packages/presets/src/presets/emscripten/index.ts b/packages/presets/src/presets/emscripten/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/emscripten/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/gatsby/config.ts b/packages/presets/src/presets/gatsby/config.ts new file mode 100644 index 0000000..de51262 --- /dev/null +++ b/packages/presets/src/presets/gatsby/config.ts @@ -0,0 +1,54 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'gatsby', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/gatsby/index.ts b/packages/presets/src/presets/gatsby/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/gatsby/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/hexo/config.ts b/packages/presets/src/presets/hexo/config.ts new file mode 100644 index 0000000..91b8a1a --- /dev/null +++ b/packages/presets/src/presets/hexo/config.ts @@ -0,0 +1,54 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'hexo', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/hexo/index.ts b/packages/presets/src/presets/hexo/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/hexo/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/html/config.ts b/packages/presets/src/presets/html/config.ts new file mode 100644 index 0000000..feb3920 --- /dev/null +++ b/packages/presets/src/presets/html/config.ts @@ -0,0 +1,29 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'html', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/html/index.ts b/packages/presets/src/presets/html/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/html/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/hugo/config.ts b/packages/presets/src/presets/hugo/config.ts new file mode 100644 index 0000000..91e29bf --- /dev/null +++ b/packages/presets/src/presets/hugo/config.ts @@ -0,0 +1,54 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'hugo', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/hugo/index.ts b/packages/presets/src/presets/hugo/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/hugo/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/javascript/config.ts b/packages/presets/src/presets/javascript/config.ts new file mode 100644 index 0000000..b84135f --- /dev/null +++ b/packages/presets/src/presets/javascript/config.ts @@ -0,0 +1,22 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'javascript', + }, + }, + rules: { + request: [ + { + name: 'Execute Edge Function', + match: '^\\/', + behavior: { + runFunction: { + path: '.edge/worker.js', + }, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/javascript/index.ts b/packages/presets/src/presets/javascript/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/javascript/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/jekyll/config.ts b/packages/presets/src/presets/jekyll/config.ts new file mode 100644 index 0000000..d340a9f --- /dev/null +++ b/packages/presets/src/presets/jekyll/config.ts @@ -0,0 +1,54 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'jekyll', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/jekyll/index.ts b/packages/presets/src/presets/jekyll/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/jekyll/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/next/config.ts b/packages/presets/src/presets/next/config.ts new file mode 100644 index 0000000..6f324b3 --- /dev/null +++ b/packages/presets/src/presets/next/config.ts @@ -0,0 +1,51 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'next', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/_next\\/static\\/', // starts with '/_next/static/' + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Execute Edge Function', + match: '^/', + behavior: { + runFunction: { + path: '.edge/worker.js', + }, + forwardCookies: true, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/next/index.ts b/packages/presets/src/presets/next/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/next/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/nuxt/config.ts b/packages/presets/src/presets/nuxt/config.ts new file mode 100644 index 0000000..9ab1656 --- /dev/null +++ b/packages/presets/src/presets/nuxt/config.ts @@ -0,0 +1,56 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'nuxt', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + // eslint-disable-next-line no-template-curly-in-string + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + // eslint-disable-next-line no-template-curly-in-string + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/nuxt/index.ts b/packages/presets/src/presets/nuxt/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/nuxt/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/react/config.ts b/packages/presets/src/presets/react/config.ts new file mode 100644 index 0000000..89b3511 --- /dev/null +++ b/packages/presets/src/presets/react/config.ts @@ -0,0 +1,49 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'react', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + + { + name: 'Redirect to index.html', + match: '^\\/', + behavior: { + rewrite: `/index.html`, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/react/index.ts b/packages/presets/src/presets/react/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/react/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/rustwasm/config.ts b/packages/presets/src/presets/rustwasm/config.ts new file mode 100644 index 0000000..e8f6229 --- /dev/null +++ b/packages/presets/src/presets/rustwasm/config.ts @@ -0,0 +1,22 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'rustwasm', + }, + }, + rules: { + request: [ + { + name: 'Execute Edge Function', + match: '^\\/', + behavior: { + runFunction: { + path: '.edge/worker.js', + }, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/rustwasm/index.ts b/packages/presets/src/presets/rustwasm/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/rustwasm/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/svelte/config.ts b/packages/presets/src/presets/svelte/config.ts new file mode 100644 index 0000000..1a55c06 --- /dev/null +++ b/packages/presets/src/presets/svelte/config.ts @@ -0,0 +1,56 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'svelte', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + // eslint-disable-next-line no-template-curly-in-string + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + // eslint-disable-next-line no-template-curly-in-string + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/svelte/index.ts b/packages/presets/src/presets/svelte/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/svelte/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/typescript/config.ts b/packages/presets/src/presets/typescript/config.ts new file mode 100644 index 0000000..cf45684 --- /dev/null +++ b/packages/presets/src/presets/typescript/config.ts @@ -0,0 +1,22 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'typescript', + }, + }, + rules: { + request: [ + { + name: 'Execute Edge Function', + match: '^\\/', + behavior: { + runFunction: { + path: '.edge/worker.js', + }, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/typescript/index.ts b/packages/presets/src/presets/typescript/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/typescript/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/vitepress/config.ts b/packages/presets/src/presets/vitepress/config.ts new file mode 100644 index 0000000..7310aff --- /dev/null +++ b/packages/presets/src/presets/vitepress/config.ts @@ -0,0 +1,54 @@ +import { defineConfig } from 'azion/config'; + +export default defineConfig({ + build: { + preset: { + name: 'vitepress', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + { + name: 'Redirect to index.html', + match: '.*/$', + behavior: { + rewrite: '${uri}index.html', + }, + }, + { + name: 'Redirect to index.html for Subpaths', + match: '^(?!.*\\/$)(?![\\s\\S]*\\.[a-zA-Z0-9]+$).*', + behavior: { + rewrite: '${uri}/index.html', + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/vitepress/index.ts b/packages/presets/src/presets/vitepress/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/vitepress/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/presets/vue/config.ts b/packages/presets/src/presets/vue/config.ts new file mode 100644 index 0000000..051d7c5 --- /dev/null +++ b/packages/presets/src/presets/vue/config.ts @@ -0,0 +1,48 @@ +import { defineConfig } from 'azion'; + +export default defineConfig({ + build: { + preset: { + name: 'vue', + }, + }, + origin: [ + { + name: 'origin-storage-default', + type: 'object_storage', + }, + ], + rules: { + request: [ + { + name: 'Set Storage Origin for All Requests', + match: '^\\/', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + }, + }, + { + name: 'Deliver Static Assets', + match: '.(css|js|ttf|woff|woff2|pdf|svg|jpg|jpeg|gif|bmp|png|ico|mp4|json|xml|html)$', + behavior: { + setOrigin: { + name: 'origin-storage-default', + type: 'object_storage', + }, + deliver: true, + }, + }, + + { + name: 'Redirect to index.html', + match: '^\\/', + behavior: { + rewrite: `/index.html`, + }, + }, + ], + }, +}); diff --git a/packages/presets/src/presets/vue/index.ts b/packages/presets/src/presets/vue/index.ts new file mode 100644 index 0000000..6c16479 --- /dev/null +++ b/packages/presets/src/presets/vue/index.ts @@ -0,0 +1,9 @@ +import { AzionBuildPreset } from '../../types'; +import config from './config'; +// import handler from './handler'; +// import prebuild from './prebuild'; +// import postbuild from './postbuild'; + +const preset: AzionBuildPreset = { config }; + +export default preset; diff --git a/packages/presets/src/types.ts b/packages/presets/src/types.ts new file mode 100644 index 0000000..da15583 --- /dev/null +++ b/packages/presets/src/types.ts @@ -0,0 +1,8 @@ +import { AzionConfig } from 'azion/config'; + +export interface AzionBuildPreset { + config: AzionConfig; + handler?: () => void; + prebuild?: () => void; + postbuild?: () => void; +} diff --git a/packages/presets/tsconfig.json b/packages/presets/tsconfig.json new file mode 100644 index 0000000..b2c4c2b --- /dev/null +++ b/packages/presets/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "es2022", + "module": "ESNext", + "outDir": "./dist", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true, + "moduleResolution": "bundler", + "resolveJsonModule": true, + "isolatedModules": true, + "baseUrl": ".", + "paths": { + "azion": ["../client/src/index.ts"], + "azion/sql": ["../sql/src/index.ts"], + "azion/storage": ["../storage/src/index.ts"], + "azion/purge": ["../purge/src/index.ts"], + "azion/config": ["../config/src/index.ts"], + "azion/domains": ["../domains/src/index.ts"], + "azion/applications": ["../applications/src/index.ts"], + "azion/ai": ["../ai/src/index.ts"] + } + } +} From 87b6d1225a360ee2fdd39c95b06fbdc279b57c97 Mon Sep 17 00:00:00 2001 From: semantic-release-bot Date: Wed, 6 Nov 2024 19:38:21 +0000 Subject: [PATCH 2/2] chore(release): 1.10.0-stage.1 [skip ci] ## [1.10.0-stage.1](https://github.com/aziontech/lib/compare/v1.9.0...v1.10.0-stage.1) (2024-11-06) ### Features * presets ([71d9835](https://github.com/aziontech/lib/commit/71d983587e49295829406c1654600ac054c3d46b)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 65f4200..1b9398e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [1.10.0-stage.1](https://github.com/aziontech/lib/compare/v1.9.0...v1.10.0-stage.1) (2024-11-06) + + +### Features + +* presets ([71d9835](https://github.com/aziontech/lib/commit/71d983587e49295829406c1654600ac054c3d46b)) + ## [1.9.0](https://github.com/aziontech/lib/compare/v1.8.2...v1.9.0) (2024-10-28) diff --git a/package.json b/package.json index f85764d..abcc185 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "azion", - "version": "1.9.0", + "version": "1.10.0-stage.1", "description": "Azion Packages for Edge Computing.", "bin": { "azion": "./bin/azion",