edge-functions 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +13 -0
- package/.eslintignore +3 -0
- package/.eslintrc.json +42 -0
- package/.github/workflows/major.yml +28 -0
- package/.github/workflows/minor.yml +31 -0
- package/.vscode/settings.json +20 -0
- package/CODEOWNERS +2 -0
- package/CODE_OF_CONDUCT.md +73 -0
- package/CONTRIBUTING.md +90 -0
- package/LICENSE.md +21 -0
- package/README.md +60 -0
- package/aliases.js +13 -0
- package/docs/overview.md +36 -0
- package/docs/presets.md +115 -0
- package/examples/angular-static/.editorconfig +16 -0
- package/examples/angular-static/README.md +27 -0
- package/examples/angular-static/angular.json +98 -0
- package/examples/angular-static/package.json +39 -0
- package/examples/angular-static/src/app/app-routing.module.ts +10 -0
- package/examples/angular-static/src/app/app.component.css +0 -0
- package/examples/angular-static/src/app/app.component.html +484 -0
- package/examples/angular-static/src/app/app.component.spec.ts +29 -0
- package/examples/angular-static/src/app/app.component.ts +10 -0
- package/examples/angular-static/src/app/app.module.ts +18 -0
- package/examples/angular-static/src/assets/.gitkeep +0 -0
- package/examples/angular-static/src/favicon.ico +0 -0
- package/examples/angular-static/src/index.html +13 -0
- package/examples/angular-static/src/main.ts +7 -0
- package/examples/angular-static/src/styles.css +1 -0
- package/examples/angular-static/tsconfig.app.json +14 -0
- package/examples/angular-static/tsconfig.json +33 -0
- package/examples/angular-static/tsconfig.spec.json +14 -0
- package/examples/astro-static/README.md +55 -0
- package/examples/astro-static/astro.config.mjs +5 -0
- package/examples/astro-static/package.json +15 -0
- package/examples/astro-static/public/favicon.svg +9 -0
- package/examples/astro-static/src/components/Card.astro +63 -0
- package/examples/astro-static/src/env.d.ts +1 -0
- package/examples/astro-static/src/layouts/Layout.astro +36 -0
- package/examples/astro-static/src/pages/edge/index.astro +55 -0
- package/examples/astro-static/src/pages/index.astro +81 -0
- package/examples/astro-static/tsconfig.json +3 -0
- package/examples/hexo-static/.github/dependabot.yml +7 -0
- package/examples/hexo-static/_config.landscape.yml +0 -0
- package/examples/hexo-static/_config.yml +105 -0
- package/examples/hexo-static/package.json +26 -0
- package/examples/hexo-static/scaffolds/draft.md +4 -0
- package/examples/hexo-static/scaffolds/page.md +4 -0
- package/examples/hexo-static/scaffolds/post.md +5 -0
- package/examples/hexo-static/source/_posts/hello-world.md +38 -0
- package/examples/hexo-static/source/_posts/other-page.md +62 -0
- package/examples/hexo-static/themes/.gitkeep +0 -0
- package/examples/hexo-static/yarn.lock +1625 -0
- package/examples/next-12-static/.babelrc +3 -0
- package/examples/next-12-static/README.md +21 -0
- package/examples/next-12-static/components/post.jsx +27 -0
- package/examples/next-12-static/package-lock.json +6191 -0
- package/examples/next-12-static/package.json +18 -0
- package/examples/next-12-static/pages/index.jsx +34 -0
- package/examples/next-12-static/pages/post/[id].jsx +63 -0
- package/examples/next-static/README.md +34 -0
- package/examples/next-static/jsconfig.json +7 -0
- package/examples/next-static/next.config.js +9 -0
- package/examples/next-static/package.json +16 -0
- package/examples/next-static/public/next.svg +1 -0
- package/examples/next-static/public/vercel.svg +1 -0
- package/examples/next-static/src/app/blog/[slug]/page.js +27 -0
- package/examples/next-static/src/app/favicon.ico +0 -0
- package/examples/next-static/src/app/globals.css +107 -0
- package/examples/next-static/src/app/layout.js +17 -0
- package/examples/next-static/src/app/misty-mountains/moria/page.js +15 -0
- package/examples/next-static/src/app/page.js +96 -0
- package/examples/next-static/src/app/page.module.css +229 -0
- package/examples/next-static/yarn.lock +199 -0
- package/examples/react-static/README.md +70 -0
- package/examples/react-static/package.json +38 -0
- package/examples/react-static/public/favicon.ico +0 -0
- package/examples/react-static/public/index.html +43 -0
- package/examples/react-static/public/logo192.png +0 -0
- package/examples/react-static/public/logo512.png +0 -0
- package/examples/react-static/public/manifest.json +25 -0
- package/examples/react-static/public/robots.txt +3 -0
- package/examples/react-static/src/App.css +38 -0
- package/examples/react-static/src/App.js +25 -0
- package/examples/react-static/src/App.test.js +8 -0
- package/examples/react-static/src/index.css +13 -0
- package/examples/react-static/src/index.js +17 -0
- package/examples/react-static/src/logo.svg +1 -0
- package/examples/react-static/src/reportWebVitals.js +13 -0
- package/examples/react-static/src/setupTests.js +5 -0
- package/examples/simple-js-esm/main.js +14 -0
- package/examples/simple-js-esm/messages.js +7 -0
- package/examples/simple-js-node/main.js +18 -0
- package/examples/vue-static/README.md +24 -0
- package/examples/vue-static/babel.config.js +5 -0
- package/examples/vue-static/jsconfig.json +19 -0
- package/examples/vue-static/package.json +45 -0
- package/examples/vue-static/public/favicon.ico +0 -0
- package/examples/vue-static/public/index.html +17 -0
- package/examples/vue-static/src/App.vue +16 -0
- package/examples/vue-static/src/assets/logo.png +0 -0
- package/examples/vue-static/src/components/HelloWorld.vue +58 -0
- package/examples/vue-static/src/main.js +28 -0
- package/examples/vue-static/src/views/Home.vue +14 -0
- package/examples/vue-static/vue.config.js +4 -0
- package/jest.config.js +6 -0
- package/jsconfig.json +40 -0
- package/jsdoc.json +52 -0
- package/lib/build/bundlers/index.js +4 -0
- package/lib/build/bundlers/webpack/index.js +40 -0
- package/lib/build/bundlers/webpack/webpack.config.js +38 -0
- package/lib/build/dispatcher/dispatcher.js +211 -0
- package/lib/build/dispatcher/dispatcher.test.js +0 -0
- package/lib/build/dispatcher/index.js +3 -0
- package/lib/build/polyfills/index.js +0 -0
- package/lib/constants/azion-edges.constants.js +98 -0
- package/lib/constants/index.js +5 -0
- package/lib/constants/messages/build.messages.js +23 -0
- package/lib/constants/messages/env.messages.js +38 -0
- package/lib/constants/messages/global.messages.js +19 -0
- package/lib/constants/messages/index.js +10 -0
- package/lib/constants/messages/platform.messages.js +84 -0
- package/lib/constants/runtime-apis.constants.js +118 -0
- package/lib/env/index.js +5 -0
- package/lib/env/runtime.env.js +69 -0
- package/lib/env/server.env.js +90 -0
- package/lib/env/vulcan.env.js +93 -0
- package/lib/main.js +260 -0
- package/lib/notations/namespaces.js +30 -0
- package/lib/notations/typedef.js +10 -0
- package/lib/platform/actions/application/createApplication.actions.js +33 -0
- package/lib/platform/actions/application/enableEdgeFunctions.actions.js +34 -0
- package/lib/platform/actions/application/instantiateFunction.actions.js +37 -0
- package/lib/platform/actions/application/setFunctionAsDefaultRule.actions.js +33 -0
- package/lib/platform/actions/core/auth.actions.js +67 -0
- package/lib/platform/actions/core/deploy.actions.js +73 -0
- package/lib/platform/actions/core/propagation.actions.js +75 -0
- package/lib/platform/actions/core/storage.actions.js +84 -0
- package/lib/platform/actions/domain/createDomain.actions.js +42 -0
- package/lib/platform/actions/function/createFunction.actions.js +79 -0
- package/lib/platform/actions/function/showFunctionLogs.actions.js +149 -0
- package/lib/platform/edgehooks/ErrorHTML/ErrorHTML.hooks.js +101 -0
- package/lib/platform/edgehooks/ErrorHTML/index.js +3 -0
- package/lib/platform/edgehooks/index.js +5 -0
- package/lib/platform/edgehooks/mountSPA/index.js +3 -0
- package/lib/platform/edgehooks/mountSPA/mountSPA.hooks.js +55 -0
- package/lib/platform/edgehooks/mountSPA/mountSPA.hooks.test.js +19 -0
- package/lib/platform/edgehooks/mountSSG/index.js +3 -0
- package/lib/platform/edgehooks/mountSSG/mountSSG.hooks.js +61 -0
- package/lib/platform/edgehooks/mountSSG/mountSSG.hooks.test.js +0 -0
- package/lib/platform/index.js +65 -0
- package/lib/platform/services/application.service.js +140 -0
- package/lib/platform/services/base.service.js +200 -0
- package/lib/platform/services/domain.service.js +80 -0
- package/lib/platform/services/events.service.js +65 -0
- package/lib/platform/services/function.service.js +105 -0
- package/lib/platform/services/index.js +8 -0
- package/lib/platform/services/storage.service.js +59 -0
- package/lib/platform/services/tokens.service.js +55 -0
- package/lib/presets/custom/angular/deliver/config.js +12 -0
- package/lib/presets/custom/angular/deliver/handler.js +8 -0
- package/lib/presets/custom/angular/deliver/prebuild.js +20 -0
- package/lib/presets/custom/astro/deliver/config.js +12 -0
- package/lib/presets/custom/astro/deliver/handler.js +8 -0
- package/lib/presets/custom/astro/deliver/prebuild.js +37 -0
- package/lib/presets/custom/hexo/deliver/config.js +12 -0
- package/lib/presets/custom/hexo/deliver/handler.js +8 -0
- package/lib/presets/custom/hexo/deliver/prebuild.js +37 -0
- package/lib/presets/custom/next/deliver/config.js +14 -0
- package/lib/presets/custom/next/deliver/handler.js +9 -0
- package/lib/presets/custom/next/deliver/prebuild.js +193 -0
- package/lib/presets/custom/react/deliver/config.js +12 -0
- package/lib/presets/custom/react/deliver/handler.js +8 -0
- package/lib/presets/custom/react/deliver/prebuild.js +16 -0
- package/lib/presets/custom/vue/deliver/config.js +12 -0
- package/lib/presets/custom/vue/deliver/handler.js +8 -0
- package/lib/presets/custom/vue/deliver/prebuild.js +20 -0
- package/lib/presets/default/html/deliver/config.js +13 -0
- package/lib/presets/default/html/deliver/handler.js +9 -0
- package/lib/presets/default/html/deliver/prebuild.js +15 -0
- package/lib/presets/default/javascript/compute/config.js +13 -0
- package/lib/presets/default/javascript/compute/handler.js +5 -0
- package/lib/presets/default/javascript/compute/prebuild.js +6 -0
- package/lib/presets/default/typescript/compute/config.js +0 -0
- package/lib/presets/default/typescript/compute/handler.js +0 -0
- package/lib/presets/default/typescript/compute/prebuild.js +0 -0
- package/lib/providers/azion/worker.js +12 -0
- package/lib/utils/copyDirectory/copyDirectory.utils.js +54 -0
- package/lib/utils/copyDirectory/copyDirectory.utils.test.js +43 -0
- package/lib/utils/copyDirectory/index.js +3 -0
- package/lib/utils/debug/debug.utils.js +36 -0
- package/lib/utils/debug/debug.utils.test.js +43 -0
- package/lib/utils/debug/index.js +3 -0
- package/lib/utils/exec/exec.utils.js +58 -0
- package/lib/utils/exec/exec.utils.test.js +84 -0
- package/lib/utils/exec/index.js +3 -0
- package/lib/utils/feedback/feedback.utils.js +81 -0
- package/lib/utils/feedback/feedback.utils.test.js +11 -0
- package/lib/utils/feedback/index.js +3 -0
- package/lib/utils/generateTimestamp/generateTimestamp.utils.js +25 -0
- package/lib/utils/generateTimestamp/generateTimestamp.utils.test.js +10 -0
- package/lib/utils/generateTimestamp/index.js +3 -0
- package/lib/utils/getAbsoluteLibDirPath/getAbsoluteLibDirPath.utils.js +21 -0
- package/lib/utils/getAbsoluteLibDirPath/getAbsoluteLibDirPath.utils.test.js +13 -0
- package/lib/utils/getAbsoluteLibDirPath/index.js +3 -0
- package/lib/utils/getPackageManager/getPackageManager.utils.js +118 -0
- package/lib/utils/getPackageManager/getPackageManager.utils.test.js +35 -0
- package/lib/utils/getPackageManager/index.js +3 -0
- package/lib/utils/getPackageVersion/getPackageVersion.utils.js +25 -0
- package/lib/utils/getPackageVersion/getPackageVersion.utils.test.js +48 -0
- package/lib/utils/getPackageVersion/index.js +3 -0
- package/lib/utils/getPresetsList/getPresetsList.utils.js +50 -0
- package/lib/utils/getPresetsList/getPresetsList.utils.test.js +19 -0
- package/lib/utils/getPresetsList/index.js +3 -0
- package/lib/utils/getProjectJsonFile/getProjectJsonFile.utils.js +21 -0
- package/lib/utils/getProjectJsonFile/getProjectJsonFile.utils.test.js +39 -0
- package/lib/utils/getProjectJsonFile/index.js +3 -0
- package/lib/utils/getVulcanBuildId/getVulcanBuildId.utils.js +49 -0
- package/lib/utils/getVulcanBuildId/getVulcanBuildId.utils.test.js +36 -0
- package/lib/utils/getVulcanBuildId/index.js +3 -0
- package/lib/utils/index.js +29 -0
- package/lib/utils/overrideStaticOutputPath/index.js +3 -0
- package/lib/utils/overrideStaticOutputPath/overrideStaticOutputPath.utils.js +47 -0
- package/lib/utils/overrideStaticOutputPath/overrideStaticOutputPath.utils.test.js +35 -0
- package/lib/utils/readWorkerFile/index.js +3 -0
- package/lib/utils/readWorkerFile/readWorkerFile.utils.js +36 -0
- package/lib/utils/readWorkerFile/readWorkerFile.utils.test.js +24 -0
- package/package.json +99 -0
- package/releaserc.json +87 -0
- package/tasks/sync-aliases.js +115 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "vue-static",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"scripts": {
|
|
6
|
+
"serve": "vue-cli-service serve",
|
|
7
|
+
"build": "vue-cli-service build",
|
|
8
|
+
"lint": "vue-cli-service lint"
|
|
9
|
+
},
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"core-js": "^3.8.3",
|
|
12
|
+
"vue": "^3.2.13",
|
|
13
|
+
"vue-router": "^4.2.2"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@babel/core": "^7.12.16",
|
|
17
|
+
"@babel/eslint-parser": "^7.12.16",
|
|
18
|
+
"@vue/cli-plugin-babel": "~5.0.0",
|
|
19
|
+
"@vue/cli-plugin-eslint": "~5.0.0",
|
|
20
|
+
"@vue/cli-service": "~5.0.0",
|
|
21
|
+
"eslint": "^7.32.0",
|
|
22
|
+
"eslint-plugin-vue": "^8.0.3",
|
|
23
|
+
"vulcan": "../../"
|
|
24
|
+
},
|
|
25
|
+
"eslintConfig": {
|
|
26
|
+
"root": true,
|
|
27
|
+
"env": {
|
|
28
|
+
"node": true
|
|
29
|
+
},
|
|
30
|
+
"extends": [
|
|
31
|
+
"plugin:vue/vue3-essential",
|
|
32
|
+
"eslint:recommended"
|
|
33
|
+
],
|
|
34
|
+
"parserOptions": {
|
|
35
|
+
"parser": "@babel/eslint-parser"
|
|
36
|
+
},
|
|
37
|
+
"rules": {}
|
|
38
|
+
},
|
|
39
|
+
"browserslist": [
|
|
40
|
+
"> 1%",
|
|
41
|
+
"last 2 versions",
|
|
42
|
+
"not dead",
|
|
43
|
+
"not ie 11"
|
|
44
|
+
]
|
|
45
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8">
|
|
5
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
6
|
+
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
|
7
|
+
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
|
|
8
|
+
<title><%= htmlWebpackPlugin.options.title %></title>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<noscript>
|
|
12
|
+
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
|
13
|
+
</noscript>
|
|
14
|
+
<div id="app"></div>
|
|
15
|
+
<!-- built files will be auto injected -->
|
|
16
|
+
</body>
|
|
17
|
+
</html>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div id="app">
|
|
3
|
+
<router-view></router-view>
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<style>
|
|
8
|
+
#app {
|
|
9
|
+
font-family: Avenir, Helvetica, Arial, sans-serif;
|
|
10
|
+
-webkit-font-smoothing: antialiased;
|
|
11
|
+
-moz-osx-font-smoothing: grayscale;
|
|
12
|
+
text-align: center;
|
|
13
|
+
color: #2c3e50;
|
|
14
|
+
margin-top: 60px;
|
|
15
|
+
}
|
|
16
|
+
</style>
|
|
Binary file
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hello">
|
|
3
|
+
<h1>{{ msg }}</h1>
|
|
4
|
+
<p>
|
|
5
|
+
For a guide and recipes on how to configure / customize this project,<br>
|
|
6
|
+
check out the
|
|
7
|
+
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
|
|
8
|
+
</p>
|
|
9
|
+
<h3>Installed CLI Plugins</h3>
|
|
10
|
+
<ul>
|
|
11
|
+
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
|
|
12
|
+
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint" target="_blank" rel="noopener">eslint</a></li>
|
|
13
|
+
</ul>
|
|
14
|
+
<h3>Essential Links</h3>
|
|
15
|
+
<ul>
|
|
16
|
+
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
|
|
17
|
+
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
|
|
18
|
+
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
|
|
19
|
+
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
|
|
20
|
+
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
|
|
21
|
+
</ul>
|
|
22
|
+
<h3>Ecosystem</h3>
|
|
23
|
+
<ul>
|
|
24
|
+
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
|
|
25
|
+
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
|
|
26
|
+
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
|
|
27
|
+
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
|
|
28
|
+
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
|
|
29
|
+
</ul>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<script>
|
|
34
|
+
export default {
|
|
35
|
+
name: 'HelloWorld',
|
|
36
|
+
props: {
|
|
37
|
+
msg: String
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
43
|
+
<style scoped>
|
|
44
|
+
h3 {
|
|
45
|
+
margin: 40px 0 0;
|
|
46
|
+
}
|
|
47
|
+
ul {
|
|
48
|
+
list-style-type: none;
|
|
49
|
+
padding: 0;
|
|
50
|
+
}
|
|
51
|
+
li {
|
|
52
|
+
display: inline-block;
|
|
53
|
+
margin: 0 10px;
|
|
54
|
+
}
|
|
55
|
+
a {
|
|
56
|
+
color: #42b983;
|
|
57
|
+
}
|
|
58
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createApp } from 'vue';
|
|
2
|
+
import App from './App.vue';
|
|
3
|
+
import { createRouter, createWebHistory } from 'vue-router';
|
|
4
|
+
|
|
5
|
+
import HelloWorld from './components/HelloWorld.vue';
|
|
6
|
+
import Home from './views/Home.vue';
|
|
7
|
+
|
|
8
|
+
const routes = [
|
|
9
|
+
{
|
|
10
|
+
path: '/',
|
|
11
|
+
name: 'Home',
|
|
12
|
+
component: Home
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
path: '/hello',
|
|
16
|
+
name: 'HelloWorld',
|
|
17
|
+
component: HelloWorld
|
|
18
|
+
}
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
const router = createRouter({
|
|
22
|
+
history: createWebHistory(),
|
|
23
|
+
routes
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const app = createApp(App);
|
|
27
|
+
app.use(router);
|
|
28
|
+
app.mount('#app');
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<h1>Welcome to the Home Page!</h1>
|
|
4
|
+
<p>Here is some content for the home page.</p>
|
|
5
|
+
<router-link to="/hello">Hello World</router-link>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
export default {
|
|
11
|
+
name: 'HomePage'
|
|
12
|
+
}
|
|
13
|
+
</script>
|
|
14
|
+
|
package/jest.config.js
ADDED
package/jsconfig.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"baseUrl": "./",
|
|
4
|
+
"paths": {
|
|
5
|
+
"#root/*": [
|
|
6
|
+
"./"
|
|
7
|
+
],
|
|
8
|
+
"#lib/*": [
|
|
9
|
+
"./lib"
|
|
10
|
+
],
|
|
11
|
+
"#utils": [
|
|
12
|
+
"./lib/utils/index.js"
|
|
13
|
+
],
|
|
14
|
+
"#polyfills": [
|
|
15
|
+
"./lib/build/polyfills/index.js"
|
|
16
|
+
],
|
|
17
|
+
"#build": [
|
|
18
|
+
"./lib/build/dispatcher/index.js"
|
|
19
|
+
],
|
|
20
|
+
"#bundlers": [
|
|
21
|
+
"./lib/build/bundlers/index.js"
|
|
22
|
+
],
|
|
23
|
+
"#notations/*": [
|
|
24
|
+
"./lib/notations"
|
|
25
|
+
],
|
|
26
|
+
"#env": [
|
|
27
|
+
"./lib/env/index.js"
|
|
28
|
+
],
|
|
29
|
+
"#platform": [
|
|
30
|
+
"./lib/platform/index.js"
|
|
31
|
+
],
|
|
32
|
+
"#constants": [
|
|
33
|
+
"./lib/constants/index.js"
|
|
34
|
+
],
|
|
35
|
+
"#edge": [
|
|
36
|
+
"./lib/platform/edgehooks/index.js"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
package/jsdoc.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"tags": {
|
|
3
|
+
"allowUnknownTags": true,
|
|
4
|
+
"dictionaries": ["jsdoc"]
|
|
5
|
+
},
|
|
6
|
+
"source": {
|
|
7
|
+
"include": ["./lib", "package.json", "README.md"],
|
|
8
|
+
"includePattern": ".js$",
|
|
9
|
+
"excludePattern": "(node_modules/|docs)"
|
|
10
|
+
},
|
|
11
|
+
"plugins": ["plugins/markdown"],
|
|
12
|
+
"templates": {
|
|
13
|
+
"referenceTitle": "My SDK Name",
|
|
14
|
+
"cleverLinks": false,
|
|
15
|
+
"monospaceLinks": false
|
|
16
|
+
},
|
|
17
|
+
"opts": {
|
|
18
|
+
"destination": "./jsdoc",
|
|
19
|
+
"encoding": "utf8",
|
|
20
|
+
"private": true,
|
|
21
|
+
"recurse": true,
|
|
22
|
+
"template": "node_modules/clean-jsdoc-theme",
|
|
23
|
+
"tutorials": "./docs/",
|
|
24
|
+
"displayModuleHeader": true,
|
|
25
|
+
"theme_opts": {
|
|
26
|
+
"sections": ["Namespaces"],
|
|
27
|
+
"prefixModuleToSidebarItems_experimental": true,
|
|
28
|
+
"title": "Vulcan - Documentation",
|
|
29
|
+
"homepageTitle": "Vulcan - Documentation",
|
|
30
|
+
"menu": [
|
|
31
|
+
{
|
|
32
|
+
"title": "Github",
|
|
33
|
+
"link": "https://github.com/@aziontech/vulcan/",
|
|
34
|
+
"target": "_blank",
|
|
35
|
+
"class": "some-class",
|
|
36
|
+
"id": "some-id"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"title": "Azion",
|
|
40
|
+
"link": "https:/azion.com",
|
|
41
|
+
"target": "_blank",
|
|
42
|
+
"class": "some-class",
|
|
43
|
+
"id": "some-id"
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"markdown": {
|
|
49
|
+
"hardwrap": false,
|
|
50
|
+
"idInHeadings": true
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import { promisify } from 'util';
|
|
3
|
+
import { feedback, debug } from '#utils';
|
|
4
|
+
import { Messages } from '#constants';
|
|
5
|
+
|
|
6
|
+
import AzionWebpackConfig from './webpack.config.js';
|
|
7
|
+
|
|
8
|
+
class Webpack {
|
|
9
|
+
constructor(customConfig, useNodePolyfills) {
|
|
10
|
+
this.customConfig = customConfig;
|
|
11
|
+
this.useNodePolyfills = useNodePolyfills;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
run = async () => {
|
|
15
|
+
const runWebpack = promisify(webpack);
|
|
16
|
+
|
|
17
|
+
const config = AzionWebpackConfig;
|
|
18
|
+
config.entry = this.customConfig.entry;
|
|
19
|
+
config.plugins = [
|
|
20
|
+
new webpack.ProgressPlugin(),
|
|
21
|
+
...config.plugins,
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
const stats = await runWebpack(config);
|
|
26
|
+
|
|
27
|
+
const info = stats.toJson();
|
|
28
|
+
if (stats.hasErrors()) {
|
|
29
|
+
info.errors.forEach((msg) => {
|
|
30
|
+
feedback.build.error(msg);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
} catch (error) {
|
|
34
|
+
debug.error(error);
|
|
35
|
+
throw Error(Messages.build.error.vulcan_build_failed);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export default Webpack;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import webpack from 'webpack';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import { writeFile, mkdir } from 'fs/promises';
|
|
4
|
+
import { generateTimestamp } from '#utils';
|
|
5
|
+
|
|
6
|
+
const projectRoot = process.cwd();
|
|
7
|
+
const outputPath = join(projectRoot, '.edge');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generates a build ID and saves it in the .env file (for deploy).
|
|
11
|
+
* @returns {Promise<string>} The generated build ID.
|
|
12
|
+
*/
|
|
13
|
+
async function generateBuildId() {
|
|
14
|
+
const envFilePath = join(outputPath, '.env');
|
|
15
|
+
const BUILD_VERSION___AKA__VERSION_ID = generateTimestamp();
|
|
16
|
+
const envContent = `VERSION_ID=${BUILD_VERSION___AKA__VERSION_ID}`;
|
|
17
|
+
|
|
18
|
+
await mkdir(outputPath, { recursive: true });
|
|
19
|
+
await writeFile(envFilePath, envContent);
|
|
20
|
+
return BUILD_VERSION___AKA__VERSION_ID;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default {
|
|
24
|
+
output: {
|
|
25
|
+
path: outputPath,
|
|
26
|
+
filename: 'worker.js',
|
|
27
|
+
globalObject: 'this',
|
|
28
|
+
},
|
|
29
|
+
mode: 'production',
|
|
30
|
+
target: 'webworker',
|
|
31
|
+
plugins: [
|
|
32
|
+
new webpack.DefinePlugin({
|
|
33
|
+
AZION: {
|
|
34
|
+
VERSION_ID: JSON.stringify(await generateBuildId()),
|
|
35
|
+
},
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { join, resolve } from 'path';
|
|
2
|
+
import { readFileSync, readdirSync, existsSync } from 'fs';
|
|
3
|
+
import { writeFile, rm } from 'fs/promises';
|
|
4
|
+
import { Webpack } from '#bundlers';
|
|
5
|
+
import { feedback, generateTimestamp, getAbsoluteLibDirPath } from '#utils';
|
|
6
|
+
import { Messages } from '#constants';
|
|
7
|
+
|
|
8
|
+
const vulcanLibPath = getAbsoluteLibDirPath();
|
|
9
|
+
const vulcanRootPath = resolve(vulcanLibPath, '..');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get the valid build presets based on the folders inside the presets/default
|
|
13
|
+
* and presets/custom directories.
|
|
14
|
+
* @returns {string[]} An array of valid build presets.
|
|
15
|
+
*/
|
|
16
|
+
function getValidPresets() {
|
|
17
|
+
const types = ['default', 'custom'];
|
|
18
|
+
const validPresets = [];
|
|
19
|
+
|
|
20
|
+
types.forEach((type) => {
|
|
21
|
+
const presetsPath = join(vulcanLibPath, 'presets', type);
|
|
22
|
+
const directories = readdirSync(presetsPath, { withFileTypes: true })
|
|
23
|
+
.filter((dirent) => dirent.isDirectory())
|
|
24
|
+
.map((dirent) => dirent.name);
|
|
25
|
+
|
|
26
|
+
validPresets.push(...directories);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
return validPresets;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get the path corresponding to a specific alias defined in the package.json.
|
|
34
|
+
* @param {string} alias - The desired alias.
|
|
35
|
+
* @returns {string} The path corresponding to the alias.
|
|
36
|
+
*/
|
|
37
|
+
async function getAliasPath(alias) {
|
|
38
|
+
const packageJsonPath = join(vulcanRootPath, 'package.json');
|
|
39
|
+
const packageJsonContent = readFileSync(packageJsonPath, 'utf8');
|
|
40
|
+
const packageJson = JSON.parse(packageJsonContent);
|
|
41
|
+
let aliasPath = packageJson.imports[`#${alias}`];
|
|
42
|
+
aliasPath = aliasPath.replace('./', `${vulcanRootPath}/`);
|
|
43
|
+
return aliasPath;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Move requires and imports to file init
|
|
48
|
+
* @param {string} entryContent - The file content to be fixed.
|
|
49
|
+
* @returns {string} The fixed file content.
|
|
50
|
+
*/
|
|
51
|
+
function fixImportsAndRequestsPlace(entryContent) {
|
|
52
|
+
const importRegex = /import\s+.*?['"](.*?)['"];?/g;
|
|
53
|
+
const requireRegex = /const\s.*?=\s*require\(['"](.*?)['"]\);?/g;
|
|
54
|
+
|
|
55
|
+
const importsList = [...entryContent.matchAll(importRegex)].map(
|
|
56
|
+
(match) => match[0],
|
|
57
|
+
);
|
|
58
|
+
const requiresList = [...entryContent.matchAll(requireRegex)].map(
|
|
59
|
+
(match) => match[0],
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
let newCode = entryContent.replace(importRegex, '').replace(requireRegex, '');
|
|
63
|
+
newCode = `${[...importsList, ...requiresList].join('\n')}\n${newCode}`;
|
|
64
|
+
|
|
65
|
+
return newCode;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Get a build context based on arguments
|
|
70
|
+
* @param {string} preset - The build preset.
|
|
71
|
+
* @param {string} entry - The entrypoint file path.
|
|
72
|
+
* @param {string} mode - The mode of preset build.
|
|
73
|
+
* @returns {any} The context that will be used in build.
|
|
74
|
+
*/
|
|
75
|
+
async function loadBuildContext(preset, entry, mode) {
|
|
76
|
+
const VALID_BUILD_PRESETS = getValidPresets();
|
|
77
|
+
const validPreset = VALID_BUILD_PRESETS.includes(preset);
|
|
78
|
+
|
|
79
|
+
if (!validPreset) {
|
|
80
|
+
throw Error(
|
|
81
|
+
'Invalid build preset. Available presets: ',
|
|
82
|
+
VALID_BUILD_PRESETS.concat(','),
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
let configFilePath;
|
|
87
|
+
let prebuildFilePath;
|
|
88
|
+
let handlerFilePath;
|
|
89
|
+
|
|
90
|
+
const defaultModePath = join(vulcanLibPath, 'presets', 'default', preset, mode);
|
|
91
|
+
const customModePath = join(vulcanLibPath, 'presets', 'custom', preset, mode);
|
|
92
|
+
let modePath;
|
|
93
|
+
|
|
94
|
+
// Check if the 'mode' folder exists within the default or custom preset paths
|
|
95
|
+
if (existsSync(defaultModePath)) {
|
|
96
|
+
modePath = defaultModePath;
|
|
97
|
+
} else if (existsSync(customModePath)) {
|
|
98
|
+
modePath = customModePath;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (modePath) {
|
|
102
|
+
configFilePath = join(modePath, 'config.js');
|
|
103
|
+
prebuildFilePath = join(modePath, 'prebuild.js');
|
|
104
|
+
handlerFilePath = join(modePath, 'handler.js');
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const config = (await import(configFilePath)).default;
|
|
108
|
+
const prebuild = (await import(prebuildFilePath)).default;
|
|
109
|
+
const handlerTemplate = readFileSync(handlerFilePath, 'utf-8');
|
|
110
|
+
// use default provider - azion
|
|
111
|
+
const workerFilePath = join(
|
|
112
|
+
vulcanLibPath,
|
|
113
|
+
'providers',
|
|
114
|
+
'azion',
|
|
115
|
+
'worker.js',
|
|
116
|
+
);
|
|
117
|
+
const workerTemplate = readFileSync(workerFilePath, 'utf-8');
|
|
118
|
+
|
|
119
|
+
// build entry file string
|
|
120
|
+
let newEntryContent = workerTemplate.replace('__HANDLER__', handlerTemplate);
|
|
121
|
+
|
|
122
|
+
// resolve #edge alias without vulcan context
|
|
123
|
+
const edgehooksPath = await getAliasPath('edge');
|
|
124
|
+
newEntryContent = newEntryContent.replace('#edge', edgehooksPath);
|
|
125
|
+
|
|
126
|
+
if (mode === 'server') {
|
|
127
|
+
const filePath = join(process.cwd(), entry);
|
|
128
|
+
const entryContent = readFileSync(filePath, 'utf-8');
|
|
129
|
+
newEntryContent = newEntryContent.replace('__JS_CODE__', entryContent);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
newEntryContent = fixImportsAndRequestsPlace(newEntryContent);
|
|
133
|
+
|
|
134
|
+
const buildContext = {
|
|
135
|
+
entryContent: newEntryContent,
|
|
136
|
+
prebuild,
|
|
137
|
+
config,
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
return buildContext;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Class representing a Dispatcher for build operations.
|
|
145
|
+
* @example
|
|
146
|
+
* const dispatcher = new Dispatcher('js', 'dist', 'main.js', 'v1');
|
|
147
|
+
* dispatcher.run();
|
|
148
|
+
*/
|
|
149
|
+
class Dispatcher {
|
|
150
|
+
/**
|
|
151
|
+
* Create a Dispatcher.
|
|
152
|
+
* @param {string} preset - The preset for the build.
|
|
153
|
+
* @param {string} mode - The mode of build target.
|
|
154
|
+
* @param {string} entry - The entry point for the build.
|
|
155
|
+
* @param {string} versionId - The version ID for the build.
|
|
156
|
+
*/
|
|
157
|
+
constructor(preset, mode, entry, versionId) {
|
|
158
|
+
this.preset = preset;
|
|
159
|
+
this.mode = mode;
|
|
160
|
+
this.entry = entry;
|
|
161
|
+
this.versionId = versionId;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Run the build process.
|
|
166
|
+
*/
|
|
167
|
+
run = async () => {
|
|
168
|
+
// Load Context based on preset
|
|
169
|
+
feedback.prebuild.info(Messages.build.info.prebuild_starting);
|
|
170
|
+
|
|
171
|
+
const { entryContent, prebuild, config } = await loadBuildContext(
|
|
172
|
+
this.preset,
|
|
173
|
+
this.entry,
|
|
174
|
+
this.mode,
|
|
175
|
+
);
|
|
176
|
+
|
|
177
|
+
// Run prebuild actions
|
|
178
|
+
await prebuild(); // TODO: send context to prebuild
|
|
179
|
+
feedback.prebuild.success(Messages.build.success.prebuild_succeeded);
|
|
180
|
+
feedback.prebuild.info(Messages.build.info.vulcan_build_starting);
|
|
181
|
+
|
|
182
|
+
// create tmp entrypoint
|
|
183
|
+
const buildId = generateTimestamp(); // TODO: use versionID
|
|
184
|
+
const currentDir = process.cwd();
|
|
185
|
+
const tempBuilderEntryPath = join(currentDir, `vulcan-${buildId}.temp.js`);
|
|
186
|
+
|
|
187
|
+
await writeFile(tempBuilderEntryPath, entryContent);
|
|
188
|
+
|
|
189
|
+
// builder entry
|
|
190
|
+
config.entry = tempBuilderEntryPath;
|
|
191
|
+
|
|
192
|
+
let builder;
|
|
193
|
+
switch (config.builder) {
|
|
194
|
+
case 'webpack':
|
|
195
|
+
builder = new Webpack(config, config.useNodePolyfills);
|
|
196
|
+
break;
|
|
197
|
+
default:
|
|
198
|
+
builder = new Webpack(config, config.useNodePolyfills);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Run common build
|
|
203
|
+
await builder.run();
|
|
204
|
+
|
|
205
|
+
// delete .temp files
|
|
206
|
+
rm(tempBuilderEntryPath);
|
|
207
|
+
feedback.build.success(Messages.build.success.vulcan_build_succeeded);
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export default Dispatcher;
|
|
File without changes
|
|
File without changes
|