edge-functions 1.6.5 → 1.7.0-stage.2
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/CHANGELOG.md +28 -8
- package/lib/build/dispatcher/dispatcher.js +65 -22
- package/lib/build/polyfills/node/dns.js +150 -0
- package/lib/build/polyfills/node/globals/navigator.js +5 -0
- package/lib/build/polyfills/node/globals/performance.js +43 -0
- package/lib/build/polyfills/node/http2.js +106 -0
- package/lib/commands/presets.commands.js +15 -3
- package/lib/constants/messages/build.messages.js +6 -4
- package/lib/env/polyfills/fetch.polyfills.js +3 -1
- package/lib/env/runtime.env.js +7 -1
- package/lib/env/server.env.js +2 -6
- package/lib/main.js +4 -3
- package/lib/presets/custom/next/compute/config.js +91 -0
- package/lib/presets/custom/next/compute/default/index.js +15 -0
- package/lib/presets/custom/next/compute/handler.js +21 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/index.js +14 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/base-http/compute-js.js +16 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/compute-js.js +47 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/config.js +722 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/load-components.js +70 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/next-compute-js-server.js +1017 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/next.js +84 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/require.js +153 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/response-cache/index.js +113 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/server/serve-static.js +47 -0
- package/lib/presets/custom/next/compute/node/custom-server/12.3.1/util/etag.js +31 -0
- package/lib/presets/custom/next/compute/node/index.js +57 -0
- package/lib/presets/custom/next/compute/node/prebuild/index.js +3 -0
- package/lib/presets/custom/next/compute/node/prebuild/statics/index.js +196 -0
- package/lib/presets/custom/next/compute/prebuild.js +98 -0
- package/lib/utils/generateWebpackBanner/generateWebpackBanner.utils.js +17 -0
- package/lib/utils/generateWebpackBanner/index.js +3 -0
- package/lib/utils/index.js +4 -0
- package/lib/utils/presets/presets.utils.js +47 -4
- package/lib/utils/vercel/index.js +3 -0
- package/lib/utils/vercel/vercel.utils.js +49 -0
- package/package.json +33 -3
- package/.babelrc +0 -13
- package/.eslintignore +0 -3
- package/.eslintrc.json +0 -91
- package/.github/workflows/release.yml +0 -35
- package/.releaserc +0 -62
- package/.vscode/settings.json +0 -20
- package/examples/angular-static/.editorconfig +0 -16
- package/examples/angular-static/README.md +0 -27
- package/examples/angular-static/angular.json +0 -98
- package/examples/angular-static/package.json +0 -38
- package/examples/angular-static/src/app/app-routing.module.ts +0 -10
- package/examples/angular-static/src/app/app.component.css +0 -0
- package/examples/angular-static/src/app/app.component.html +0 -484
- package/examples/angular-static/src/app/app.component.spec.ts +0 -29
- package/examples/angular-static/src/app/app.component.ts +0 -10
- package/examples/angular-static/src/app/app.module.ts +0 -18
- 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 +0 -13
- package/examples/angular-static/src/main.ts +0 -7
- package/examples/angular-static/src/styles.css +0 -1
- package/examples/angular-static/tsconfig.app.json +0 -14
- package/examples/angular-static/tsconfig.json +0 -33
- package/examples/angular-static/tsconfig.spec.json +0 -14
- package/examples/astro-static/README.md +0 -55
- package/examples/astro-static/astro.config.mjs +0 -5
- package/examples/astro-static/package.json +0 -15
- package/examples/astro-static/public/favicon.svg +0 -9
- package/examples/astro-static/src/components/Card.astro +0 -63
- package/examples/astro-static/src/env.d.ts +0 -1
- package/examples/astro-static/src/layouts/Layout.astro +0 -36
- package/examples/astro-static/src/pages/edge/index.astro +0 -55
- package/examples/astro-static/src/pages/index.astro +0 -81
- package/examples/astro-static/tsconfig.json +0 -3
- package/examples/hexo-static/.github/dependabot.yml +0 -7
- package/examples/hexo-static/_config.landscape.yml +0 -0
- package/examples/hexo-static/_config.yml +0 -105
- package/examples/hexo-static/package.json +0 -26
- package/examples/hexo-static/scaffolds/draft.md +0 -4
- package/examples/hexo-static/scaffolds/page.md +0 -4
- package/examples/hexo-static/scaffolds/post.md +0 -5
- package/examples/hexo-static/source/_posts/hello-world.md +0 -38
- package/examples/hexo-static/source/_posts/other-page.md +0 -62
- package/examples/hexo-static/themes/.gitkeep +0 -0
- package/examples/next-12-static/.babelrc +0 -3
- package/examples/next-12-static/README.md +0 -21
- package/examples/next-12-static/components/post.jsx +0 -27
- package/examples/next-12-static/package-lock.json +0 -6191
- package/examples/next-12-static/package.json +0 -18
- package/examples/next-12-static/pages/index.jsx +0 -34
- package/examples/next-12-static/pages/post/[id].jsx +0 -63
- package/examples/next-static/README.md +0 -34
- package/examples/next-static/jsconfig.json +0 -7
- package/examples/next-static/next.config.js +0 -9
- package/examples/next-static/package.json +0 -16
- package/examples/next-static/public/next.svg +0 -1
- package/examples/next-static/public/vercel.svg +0 -1
- package/examples/next-static/src/app/blog/[slug]/page.js +0 -27
- package/examples/next-static/src/app/favicon.ico +0 -0
- package/examples/next-static/src/app/globals.css +0 -107
- package/examples/next-static/src/app/layout.js +0 -17
- package/examples/next-static/src/app/misty-mountains/moria/page.js +0 -15
- package/examples/next-static/src/app/page.js +0 -96
- package/examples/next-static/src/app/page.module.css +0 -229
- package/examples/next-static/yarn.lock +0 -199
- package/examples/react-static/README.md +0 -70
- package/examples/react-static/package.json +0 -38
- package/examples/react-static/public/favicon.ico +0 -0
- package/examples/react-static/public/index.html +0 -43
- 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 +0 -25
- package/examples/react-static/public/robots.txt +0 -3
- package/examples/react-static/src/App.css +0 -38
- package/examples/react-static/src/App.js +0 -25
- package/examples/react-static/src/App.test.js +0 -8
- package/examples/react-static/src/index.css +0 -13
- package/examples/react-static/src/index.js +0 -17
- package/examples/react-static/src/logo.svg +0 -1
- package/examples/react-static/src/reportWebVitals.js +0 -13
- package/examples/react-static/src/setupTests.js +0 -5
- package/examples/simple-js-esm/main.js +0 -19
- package/examples/simple-js-esm/messages.js +0 -7
- package/examples/simple-js-esm-node/index.js +0 -45
- package/examples/simple-js-node/main.js +0 -18
- package/examples/simple-ts-esm/main.ts +0 -24
- package/examples/simple-ts-esm/messages.ts +0 -11
- package/examples/simple-ts-esm/package.json +0 -9
- package/examples/simple-ts-esm/tsconfig.json +0 -109
- package/examples/simple-ts-esm/yarn.lock +0 -8
- package/examples/vue-static/README.md +0 -24
- package/examples/vue-static/babel.config.js +0 -5
- package/examples/vue-static/jsconfig.json +0 -19
- package/examples/vue-static/package.json +0 -45
- package/examples/vue-static/public/favicon.ico +0 -0
- package/examples/vue-static/public/index.html +0 -17
- package/examples/vue-static/src/App.vue +0 -16
- package/examples/vue-static/src/assets/logo.png +0 -0
- package/examples/vue-static/src/components/HelloWorld.vue +0 -58
- package/examples/vue-static/src/main.js +0 -28
- package/examples/vue-static/src/views/Home.vue +0 -14
- package/examples/vue-static/vue.config.js +0 -4
- package/examples/vue-static/yarn.lock +0 -13094
- package/examples/vue-vite-static/README.md +0 -29
- package/examples/vue-vite-static/index.html +0 -13
- package/examples/vue-vite-static/package.json +0 -18
- package/examples/vue-vite-static/public/favicon.ico +0 -0
- package/examples/vue-vite-static/src/App.vue +0 -85
- package/examples/vue-vite-static/src/assets/base.css +0 -73
- package/examples/vue-vite-static/src/assets/logo.svg +0 -1
- package/examples/vue-vite-static/src/assets/main.css +0 -35
- package/examples/vue-vite-static/src/components/HelloWorld.vue +0 -44
- package/examples/vue-vite-static/src/components/TheWelcome.vue +0 -86
- package/examples/vue-vite-static/src/components/WelcomeItem.vue +0 -86
- package/examples/vue-vite-static/src/components/icons/IconCommunity.vue +0 -7
- package/examples/vue-vite-static/src/components/icons/IconDocumentation.vue +0 -7
- package/examples/vue-vite-static/src/components/icons/IconEcosystem.vue +0 -7
- package/examples/vue-vite-static/src/components/icons/IconSupport.vue +0 -7
- package/examples/vue-vite-static/src/components/icons/IconTooling.vue +0 -19
- package/examples/vue-vite-static/src/main.js +0 -11
- package/examples/vue-vite-static/src/router/index.js +0 -23
- package/examples/vue-vite-static/src/views/AboutView.vue +0 -15
- package/examples/vue-vite-static/src/views/HomeView.vue +0 -9
- package/examples/vue-vite-static/vite.config.js +0 -16
- package/examples/vue-vite-static/yarn.lock +0 -333
- package/jest.config.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
## [1.7.0-stage.2](https://github.com/aziontech/vulcan/compare/v1.7.0-stage.1...v1.7.0-stage.2) (2023-09-14)
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
* Add
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
* Add unused files in npm ignore ([ea3acf8](https://github.com/aziontech/vulcan/commit/ea3acf8a536fbe26f0e3e5b359385607930e79ec))
|
|
7
|
+
* Create .npmignore ([#131](https://github.com/aziontech/vulcan/issues/131)) ([90383b0](https://github.com/aziontech/vulcan/commit/90383b01cd0dea848840d3348bf30cdcfdd79388))
|
|
8
|
+
|
|
9
|
+
## [1.7.0-stage.1](https://github.com/aziontech/vulcan/compare/v1.6.4-stage.2...v1.7.0-stage.1) (2023-09-14)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* add custom server with js files ([#97](https://github.com/aziontech/vulcan/issues/97)) ([f73a31e](https://github.com/aziontech/vulcan/commit/f73a31e19e23c773e379f3cd193262468cf1ba52))
|
|
15
|
+
* Add list preset modes ([4d1b924](https://github.com/aziontech/vulcan/commit/4d1b924f1c3d403683dcd1d0a2245cf9d68cd3a3))
|
|
16
|
+
* Add next webpack polyfills ([#98](https://github.com/aziontech/vulcan/issues/98)) ([5451fa5](https://github.com/aziontech/vulcan/commit/5451fa59c69f4bc148649e2f0b67e7b15012f678))
|
|
17
|
+
* Add Next.js support ([#125](https://github.com/aziontech/vulcan/issues/125)) ([a53c807](https://github.com/aziontech/vulcan/commit/a53c80727673ff209842372eb467d01595f3d15d))
|
|
18
|
+
* added handler and code compile ([#100](https://github.com/aziontech/vulcan/issues/100)) ([2e245fd](https://github.com/aziontech/vulcan/commit/2e245fdf67f5fdb746072950b6e64b14d9273d19))
|
|
19
|
+
* check if dependencies are installed and log vercel cli ([144bc7a](https://github.com/aziontech/vulcan/commit/144bc7ac02b626fa9c1693ebd9a2f39a17244473))
|
|
20
|
+
* Improve vercel build logs ([67ad3bd](https://github.com/aziontech/vulcan/commit/67ad3bd8f918c23d09514ce7acac77a5ac519db5))
|
|
21
|
+
* list presets modes ([df1d71e](https://github.com/aziontech/vulcan/commit/df1d71e43041224a47653e0c9853e18205f92c51))
|
|
22
|
+
* pre build configuration and custom static file server Next ([#96](https://github.com/aziontech/vulcan/issues/96)) ([1d2ab58](https://github.com/aziontech/vulcan/commit/1d2ab58370432b81cfa625a0d9a1c32eaa27cb93))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Bug Fixes
|
|
26
|
+
|
|
27
|
+
* change exit code from 0 to 1 in catch ([835bc89](https://github.com/aziontech/vulcan/commit/835bc8920e9228835e87020e8d98b3ba9c366208))
|
|
28
|
+
* custom server code and config file ([#103](https://github.com/aziontech/vulcan/issues/103)) ([340dd11](https://github.com/aziontech/vulcan/commit/340dd11acf0fb5e89e84d83404e0659ffd3f5b42))
|
|
29
|
+
* Next build fix and improvements ([#101](https://github.com/aziontech/vulcan/issues/101)) ([f9100c5](https://github.com/aziontech/vulcan/commit/f9100c5177abae307985257afe471f3538762161))
|
|
30
|
+
* remove local run command message ([2d527b3](https://github.com/aziontech/vulcan/commit/2d527b3bb1b4abe383ce4ca969d70a9f5513c1c9))
|
|
31
|
+
* remove unnecessary Error ([3fdf2d9](https://github.com/aziontech/vulcan/commit/3fdf2d9fa3c4e477296019160d0681e5d7e5408a))
|
|
32
|
+
* response cache and improvements ([#102](https://github.com/aziontech/vulcan/issues/102)) ([ee2da8a](https://github.com/aziontech/vulcan/commit/ee2da8a9ec5ade1b509dfbaf87a01ae8946d6342))
|
|
13
33
|
|
|
14
34
|
### [1.6.4-stage.2](https://github.com/aziontech/vulcan/compare/v1.6.4-stage.1...v1.6.4-stage.2) (2023-09-14)
|
|
15
35
|
|
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { join, resolve } from 'path';
|
|
2
2
|
import {
|
|
3
|
-
readFileSync,
|
|
3
|
+
readFileSync,
|
|
4
|
+
existsSync,
|
|
5
|
+
mkdirSync,
|
|
6
|
+
writeFileSync,
|
|
7
|
+
rmSync,
|
|
8
|
+
promises as fsPromises,
|
|
4
9
|
} from 'fs';
|
|
5
10
|
import { fileURLToPath } from 'url';
|
|
6
11
|
import { Esbuild, Webpack } from '#bundlers';
|
|
7
12
|
import {
|
|
8
|
-
feedback,
|
|
13
|
+
feedback,
|
|
14
|
+
debug,
|
|
15
|
+
generateTimestamp,
|
|
16
|
+
getAbsoluteLibDirPath,
|
|
17
|
+
presets,
|
|
18
|
+
getPackageManager,
|
|
9
19
|
} from '#utils';
|
|
10
20
|
import { Messages } from '#constants';
|
|
11
21
|
import { vulcan } from '#env';
|
|
@@ -83,7 +93,13 @@ async function loadBuildContext(preset, entry, mode) {
|
|
|
83
93
|
let prebuildFilePath;
|
|
84
94
|
let handlerFilePath;
|
|
85
95
|
|
|
86
|
-
const defaultModePath = join(
|
|
96
|
+
const defaultModePath = join(
|
|
97
|
+
vulcanLibPath,
|
|
98
|
+
'presets',
|
|
99
|
+
'default',
|
|
100
|
+
preset,
|
|
101
|
+
mode,
|
|
102
|
+
);
|
|
87
103
|
const customModePath = join(vulcanLibPath, 'presets', 'custom', preset, mode);
|
|
88
104
|
let modePath;
|
|
89
105
|
|
|
@@ -99,7 +115,9 @@ async function loadBuildContext(preset, entry, mode) {
|
|
|
99
115
|
prebuildFilePath = join(modePath, 'prebuild.js');
|
|
100
116
|
handlerFilePath = join(modePath, 'handler.js');
|
|
101
117
|
} else {
|
|
102
|
-
feedback.build.error(
|
|
118
|
+
feedback.build.error(
|
|
119
|
+
Messages.build.error.invalid_preset_mode(mode, preset),
|
|
120
|
+
);
|
|
103
121
|
process.exit(1);
|
|
104
122
|
}
|
|
105
123
|
|
|
@@ -110,12 +128,7 @@ async function loadBuildContext(preset, entry, mode) {
|
|
|
110
128
|
const prebuild = (await import(prebuildFilePath)).default;
|
|
111
129
|
const handlerTemplate = readFileSync(handlerFilePath, 'utf-8');
|
|
112
130
|
// use default provider - azion
|
|
113
|
-
const workerFilePath = join(
|
|
114
|
-
vulcanLibPath,
|
|
115
|
-
'providers',
|
|
116
|
-
'azion',
|
|
117
|
-
'worker.js',
|
|
118
|
-
);
|
|
131
|
+
const workerFilePath = join(vulcanLibPath, 'providers', 'azion', 'worker.js');
|
|
119
132
|
const workerTemplate = readFileSync(workerFilePath, 'utf-8');
|
|
120
133
|
|
|
121
134
|
// build entry file string
|
|
@@ -125,7 +138,10 @@ async function loadBuildContext(preset, entry, mode) {
|
|
|
125
138
|
const edgehooksPath = await getAliasPath('edge');
|
|
126
139
|
newEntryContent = newEntryContent.replace('#edge', edgehooksPath);
|
|
127
140
|
|
|
128
|
-
if (
|
|
141
|
+
if (
|
|
142
|
+
(preset === 'javascript' || preset === 'typescript') &&
|
|
143
|
+
mode === 'compute'
|
|
144
|
+
) {
|
|
129
145
|
try {
|
|
130
146
|
const filePath = join(process.cwd(), entry);
|
|
131
147
|
const entryContent = readFileSync(filePath, 'utf-8');
|
|
@@ -158,17 +174,32 @@ Create a .env file in the build folder with specified parameters.
|
|
|
158
174
|
*/
|
|
159
175
|
function createDotEnvFile(buildId) {
|
|
160
176
|
const projectRoot = process.cwd();
|
|
161
|
-
const outputPath = isWindows
|
|
177
|
+
const outputPath = isWindows
|
|
178
|
+
? fileURLToPath(new URL(`file:///${join(projectRoot, '.edge')}`))
|
|
179
|
+
: join(projectRoot, '.edge');
|
|
162
180
|
const envFilePath = join(outputPath, '.env');
|
|
163
181
|
|
|
164
|
-
const envContent = [
|
|
165
|
-
`VERSION_ID=${buildId}`,
|
|
166
|
-
].join('\n');
|
|
182
|
+
const envContent = [`VERSION_ID=${buildId}`].join('\n');
|
|
167
183
|
|
|
168
184
|
mkdirSync(outputPath, { recursive: true });
|
|
169
185
|
writeFileSync(envFilePath, envContent);
|
|
170
186
|
}
|
|
171
187
|
|
|
188
|
+
/**
|
|
189
|
+
* Check folder exists in project
|
|
190
|
+
* @param {string} folder - Folder e.g node_modules
|
|
191
|
+
* @returns {Promise<boolean>}
|
|
192
|
+
*/
|
|
193
|
+
async function folderExistsInProject(folder) {
|
|
194
|
+
const filePath = join(process.cwd(), folder);
|
|
195
|
+
try {
|
|
196
|
+
const stats = await fsPromises.stat(filePath);
|
|
197
|
+
return Promise.resolve(stats.isDirectory());
|
|
198
|
+
} catch (error) {
|
|
199
|
+
return Promise.resolve(false);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
172
203
|
/**
|
|
173
204
|
* Class representing a Dispatcher for build operations.
|
|
174
205
|
* @example
|
|
@@ -195,6 +226,15 @@ class Dispatcher {
|
|
|
195
226
|
* Run the build process.
|
|
196
227
|
*/
|
|
197
228
|
run = async () => {
|
|
229
|
+
// Check install depenedencies
|
|
230
|
+
const pckManager = await getPackageManager();
|
|
231
|
+
const existNodeModules = await folderExistsInProject('node_modules');
|
|
232
|
+
if (!existNodeModules) {
|
|
233
|
+
feedback.prebuild.error(
|
|
234
|
+
Messages.build.error.install_dependencies_failed(pckManager),
|
|
235
|
+
);
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
198
238
|
// Load Context based on preset
|
|
199
239
|
const { entryContent, prebuild, config } = await loadBuildContext(
|
|
200
240
|
this.preset,
|
|
@@ -223,7 +263,7 @@ class Dispatcher {
|
|
|
223
263
|
// create tmp entrypoint
|
|
224
264
|
const currentDir = process.cwd();
|
|
225
265
|
let tempEntryFile = `vulcan-${this.buildId}.temp.`;
|
|
226
|
-
tempEntryFile +=
|
|
266
|
+
tempEntryFile += this.preset === 'typescript' ? 'ts' : 'js';
|
|
227
267
|
const tempBuilderEntryPath = join(currentDir, tempEntryFile);
|
|
228
268
|
|
|
229
269
|
writeFileSync(tempBuilderEntryPath, entryContent);
|
|
@@ -252,12 +292,15 @@ class Dispatcher {
|
|
|
252
292
|
// delete .temp files
|
|
253
293
|
rmSync(tempBuilderEntryPath);
|
|
254
294
|
|
|
255
|
-
await vulcan.createVulcanEnv(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
295
|
+
await vulcan.createVulcanEnv(
|
|
296
|
+
{
|
|
297
|
+
entry: this.entry,
|
|
298
|
+
preset: this.preset,
|
|
299
|
+
mode: this.mode,
|
|
300
|
+
useNodePolyfills: this.useNodePolyfills,
|
|
301
|
+
},
|
|
302
|
+
'local',
|
|
303
|
+
);
|
|
261
304
|
|
|
262
305
|
feedback.build.success(Messages.build.success.vulcan_build_succeeded);
|
|
263
306
|
} catch (error) {
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
function unimplemented() {
|
|
2
|
+
throw new Error(
|
|
3
|
+
'Node.js dns is not supported'
|
|
4
|
+
)
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
var promises = {
|
|
8
|
+
lookup: unimplemented,
|
|
9
|
+
lookupService: unimplemented,
|
|
10
|
+
Resolver: unimplemented,
|
|
11
|
+
getServers: unimplemented,
|
|
12
|
+
resolve: unimplemented,
|
|
13
|
+
resolve4: unimplemented,
|
|
14
|
+
resolve6: unimplemented,
|
|
15
|
+
resolveAny: unimplemented,
|
|
16
|
+
resolveCname: unimplemented,
|
|
17
|
+
resolveMx: unimplemented,
|
|
18
|
+
resolveNaptr: unimplemented,
|
|
19
|
+
resolveNs: unimplemented,
|
|
20
|
+
resolvePtr: unimplemented,
|
|
21
|
+
resolveSoa: unimplemented,
|
|
22
|
+
resolveSrv: unimplemented,
|
|
23
|
+
resolveTxt: unimplemented,
|
|
24
|
+
reverse: unimplemented,
|
|
25
|
+
setServers: unimplemented,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var dns = {
|
|
29
|
+
lookup: unimplemented,
|
|
30
|
+
lookupService: unimplemented,
|
|
31
|
+
Resolver: unimplemented,
|
|
32
|
+
setServers: unimplemented,
|
|
33
|
+
ADDRCONFIG: null,
|
|
34
|
+
V4MAPPED: null,
|
|
35
|
+
NODATA: null,
|
|
36
|
+
FORMERR: null,
|
|
37
|
+
SERVFAIL: null,
|
|
38
|
+
NOTFOUND: null,
|
|
39
|
+
NOTIMP: null,
|
|
40
|
+
REFUSED: null,
|
|
41
|
+
BADQUERY: null,
|
|
42
|
+
BADNAME: null,
|
|
43
|
+
BADFAMILY: null,
|
|
44
|
+
BADRESP: null,
|
|
45
|
+
CONNREFUSED: null,
|
|
46
|
+
TIMEOUT: null,
|
|
47
|
+
EOF: null,
|
|
48
|
+
FILE: null,
|
|
49
|
+
NOMEM: null,
|
|
50
|
+
DESTRUCTION: null,
|
|
51
|
+
BADSTR: null,
|
|
52
|
+
BADFLAGS: null,
|
|
53
|
+
NONAME: null,
|
|
54
|
+
BADHINTS: null,
|
|
55
|
+
NOTINITIALIZED: null,
|
|
56
|
+
LOADIPHLPAPI: null,
|
|
57
|
+
ADDRGETNETWORKPARAMS: null,
|
|
58
|
+
CANCELLED: null,
|
|
59
|
+
getServers: unimplemented,
|
|
60
|
+
resolve: unimplemented,
|
|
61
|
+
resolve4: unimplemented,
|
|
62
|
+
resolve6: unimplemented,
|
|
63
|
+
resolveAny: unimplemented,
|
|
64
|
+
resolveCname: unimplemented,
|
|
65
|
+
resolveMx: unimplemented,
|
|
66
|
+
resolveNaptr: unimplemented,
|
|
67
|
+
resolveNs: unimplemented,
|
|
68
|
+
resolvePtr: unimplemented,
|
|
69
|
+
resolveSoa: unimplemented,
|
|
70
|
+
resolveSrv: unimplemented,
|
|
71
|
+
resolveTxt: unimplemented,
|
|
72
|
+
reverse: unimplemented,
|
|
73
|
+
promises: promises,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var ADDRCONFIG = null,
|
|
77
|
+
V4MAPPED = null,
|
|
78
|
+
NODATA = null,
|
|
79
|
+
FORMERR = null,
|
|
80
|
+
SERVFAIL = null,
|
|
81
|
+
NOTFOUND = null,
|
|
82
|
+
NOTIMP = null,
|
|
83
|
+
REFUSED = null,
|
|
84
|
+
BADQUERY = null,
|
|
85
|
+
BADNAME = null,
|
|
86
|
+
BADFAMILY = null,
|
|
87
|
+
BADRESP = null,
|
|
88
|
+
CONNREFUSED = null,
|
|
89
|
+
TIMEOUT = null,
|
|
90
|
+
EOF = null,
|
|
91
|
+
FILE = null,
|
|
92
|
+
NOMEM = null,
|
|
93
|
+
DESTRUCTION = null,
|
|
94
|
+
BADSTR = null,
|
|
95
|
+
BADFLAGS = null,
|
|
96
|
+
NONAME = null,
|
|
97
|
+
BADHINTS = null,
|
|
98
|
+
NOTINITIALIZED = null,
|
|
99
|
+
LOADIPHLPAPI = null,
|
|
100
|
+
ADDRGETNETWORKPARAMS = null,
|
|
101
|
+
CANCELLED = null
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
ADDRCONFIG,
|
|
105
|
+
ADDRGETNETWORKPARAMS,
|
|
106
|
+
BADFAMILY,
|
|
107
|
+
BADFLAGS,
|
|
108
|
+
BADHINTS,
|
|
109
|
+
BADNAME,
|
|
110
|
+
BADQUERY,
|
|
111
|
+
BADRESP,
|
|
112
|
+
BADSTR,
|
|
113
|
+
CANCELLED,
|
|
114
|
+
CONNREFUSED,
|
|
115
|
+
DESTRUCTION,
|
|
116
|
+
EOF,
|
|
117
|
+
FILE,
|
|
118
|
+
FORMERR,
|
|
119
|
+
LOADIPHLPAPI,
|
|
120
|
+
NODATA,
|
|
121
|
+
NOMEM,
|
|
122
|
+
NONAME,
|
|
123
|
+
NOTFOUND,
|
|
124
|
+
NOTIMP,
|
|
125
|
+
NOTINITIALIZED,
|
|
126
|
+
REFUSED,
|
|
127
|
+
unimplemented as Resolver,
|
|
128
|
+
SERVFAIL,
|
|
129
|
+
TIMEOUT,
|
|
130
|
+
V4MAPPED,
|
|
131
|
+
dns as default,
|
|
132
|
+
unimplemented as getServers,
|
|
133
|
+
unimplemented as lookup,
|
|
134
|
+
unimplemented as lookupService,
|
|
135
|
+
promises,
|
|
136
|
+
unimplemented as resolve,
|
|
137
|
+
unimplemented as resolve4,
|
|
138
|
+
unimplemented as resolve6,
|
|
139
|
+
unimplemented as resolveAny,
|
|
140
|
+
unimplemented as resolveCname,
|
|
141
|
+
unimplemented as resolveMx,
|
|
142
|
+
unimplemented as resolveNaptr,
|
|
143
|
+
unimplemented as resolveNs,
|
|
144
|
+
unimplemented as resolvePtr,
|
|
145
|
+
unimplemented as resolveSoa,
|
|
146
|
+
unimplemented as resolveSrv,
|
|
147
|
+
unimplemented as resolveTxt,
|
|
148
|
+
unimplemented as reverse,
|
|
149
|
+
unimplemented as setServers,
|
|
150
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2013 Braveg1rl
|
|
3
|
+
* github.com/braveg1rl/performance-now
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
|
9
|
+
of the Software, and to permit persons to whom the Software is furnished to do
|
|
10
|
+
so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
var loadTime = Date.now();
|
|
25
|
+
globalThis.performance = new Proxy({}, {
|
|
26
|
+
get(target, prop) {
|
|
27
|
+
if (prop === 'now') {
|
|
28
|
+
return () => {
|
|
29
|
+
const result = Date.now() - loadTime;
|
|
30
|
+
loadTime = Date.now();
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
return () => {
|
|
36
|
+
const result = Date.now() - loadTime;
|
|
37
|
+
loadTime = Date.now();
|
|
38
|
+
|
|
39
|
+
return 100;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
// Copyright Joyent and Node contributors. All rights reserved. MIT license.
|
|
2
|
+
|
|
3
|
+
function unimplemented(name) {
|
|
4
|
+
throw new Error(`Node.js HTTP/2 ${name} is not currently supported`);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class Http2Session {
|
|
8
|
+
constructor() {
|
|
9
|
+
unimplemented(this.constructor.name);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
class ServerHttp2Session {
|
|
13
|
+
constructor() {
|
|
14
|
+
unimplemented(this.constructor.name);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
class ClientHttp2Session {
|
|
18
|
+
constructor() {
|
|
19
|
+
unimplemented(this.constructor.name);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
class Http2Stream {
|
|
23
|
+
constructor() {
|
|
24
|
+
unimplemented(this.constructor.name);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
class ClientHttp2Stream {
|
|
28
|
+
constructor() {
|
|
29
|
+
unimplemented(this.constructor.name);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
class ServerHttp2Stream {
|
|
33
|
+
constructor() {
|
|
34
|
+
unimplemented(this.constructor.name);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
class Http2Server {
|
|
38
|
+
constructor() {
|
|
39
|
+
unimplemented(this.constructor.name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
class Http2SecureServer {
|
|
43
|
+
constructor() {
|
|
44
|
+
unimplemented(this.constructor.name);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function createServer() {}
|
|
48
|
+
function createSecureServer() {}
|
|
49
|
+
function connect() {}
|
|
50
|
+
const constants = {};
|
|
51
|
+
function getDefaultSettings() {}
|
|
52
|
+
function getPackedSettings() {}
|
|
53
|
+
function getUnpackedSettings() {}
|
|
54
|
+
const sensitiveHeaders = Symbol("nodejs.http2.sensitiveHeaders");
|
|
55
|
+
class Http2ServerRequest {
|
|
56
|
+
constructor() {
|
|
57
|
+
unimplemented(this.constructor.name);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
class Http2ServerResponse {
|
|
61
|
+
constructor() {
|
|
62
|
+
unimplemented(this.constructor.name);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
var http2 = {
|
|
66
|
+
Http2Session,
|
|
67
|
+
ServerHttp2Session,
|
|
68
|
+
ClientHttp2Session,
|
|
69
|
+
Http2Stream,
|
|
70
|
+
ClientHttp2Stream,
|
|
71
|
+
ServerHttp2Stream,
|
|
72
|
+
Http2Server,
|
|
73
|
+
Http2SecureServer,
|
|
74
|
+
createServer,
|
|
75
|
+
createSecureServer,
|
|
76
|
+
connect,
|
|
77
|
+
constants,
|
|
78
|
+
getDefaultSettings,
|
|
79
|
+
getPackedSettings,
|
|
80
|
+
getUnpackedSettings,
|
|
81
|
+
sensitiveHeaders,
|
|
82
|
+
Http2ServerRequest,
|
|
83
|
+
Http2ServerResponse,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export {
|
|
87
|
+
ClientHttp2Session,
|
|
88
|
+
ClientHttp2Stream,
|
|
89
|
+
Http2SecureServer,
|
|
90
|
+
Http2Server,
|
|
91
|
+
Http2ServerRequest,
|
|
92
|
+
Http2ServerResponse,
|
|
93
|
+
Http2Session,
|
|
94
|
+
Http2Stream,
|
|
95
|
+
ServerHttp2Session,
|
|
96
|
+
ServerHttp2Stream,
|
|
97
|
+
connect,
|
|
98
|
+
constants,
|
|
99
|
+
createSecureServer,
|
|
100
|
+
createServer,
|
|
101
|
+
http2 as default,
|
|
102
|
+
getDefaultSettings,
|
|
103
|
+
getPackedSettings,
|
|
104
|
+
getUnpackedSettings,
|
|
105
|
+
sensitiveHeaders,
|
|
106
|
+
};
|
|
@@ -7,10 +7,12 @@ const prompt = createPromptModule();
|
|
|
7
7
|
/**
|
|
8
8
|
* Manages presets for the application.
|
|
9
9
|
* @memberof commands
|
|
10
|
-
* This command allows the user to create or list presets.
|
|
10
|
+
* This command allows the user to create or list presets and modes.
|
|
11
11
|
* The user is guided by a series of prompts to enter a preset name and mode.
|
|
12
12
|
* @param {string} command - The operation to be performed:
|
|
13
13
|
* 'create' to create a preset, 'ls' to list presets.
|
|
14
|
+
* @param {string} [presetName] - The name of the preset for which to list available modes.
|
|
15
|
+
* If specified, the function will return the modes available for this preset.
|
|
14
16
|
* @returns {Promise<void>} - A promise that resolves when the action is complete.
|
|
15
17
|
* @example
|
|
16
18
|
*
|
|
@@ -20,7 +22,7 @@ const prompt = createPromptModule();
|
|
|
20
22
|
* // To list existing presets
|
|
21
23
|
* presetsCommand('ls');
|
|
22
24
|
*/
|
|
23
|
-
async function presetsCommand(command) {
|
|
25
|
+
async function presetsCommand(command, presetName) {
|
|
24
26
|
const { presets } = await import('#utils');
|
|
25
27
|
|
|
26
28
|
let name;
|
|
@@ -85,7 +87,17 @@ async function presetsCommand(command) {
|
|
|
85
87
|
break;
|
|
86
88
|
|
|
87
89
|
case 'ls':
|
|
88
|
-
|
|
90
|
+
if (presetName) {
|
|
91
|
+
const modes = presets.getModes(presetName);
|
|
92
|
+
if (modes.length > 0) {
|
|
93
|
+
modes.forEach((presetMode) => feedback.option(presetMode));
|
|
94
|
+
} else {
|
|
95
|
+
feedback.error(`No modes found for preset ${presetName}.`);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (!presetName) {
|
|
99
|
+
presets.getBeautify().forEach((preset) => feedback.option(preset));
|
|
100
|
+
}
|
|
89
101
|
break;
|
|
90
102
|
|
|
91
103
|
default:
|
|
@@ -13,14 +13,16 @@ const build = {
|
|
|
13
13
|
rebuilding: 'We are rebuilding with the new changes...',
|
|
14
14
|
prebuild_starting: 'Starting prebuild...',
|
|
15
15
|
vulcan_build_starting: 'Starting Vulcan build...',
|
|
16
|
-
|
|
17
16
|
},
|
|
18
17
|
error: {
|
|
19
18
|
vulcan_build_failed: 'Vulcan build failed.',
|
|
20
|
-
invalid_preset:
|
|
21
|
-
|
|
19
|
+
invalid_preset:
|
|
20
|
+
'Invalid build preset. Run "vulcan preset ls" to view available presets.',
|
|
21
|
+
invalid_preset_mode: (mode, preset) =>
|
|
22
|
+
`Mode '${mode}' does not exists in preset '${preset}'. Try 'deliver' or 'compute'.`,
|
|
23
|
+
install_dependencies_failed: (pckManager) =>
|
|
24
|
+
`Please run command to install dependencies. e.g ${pckManager} install.`,
|
|
22
25
|
},
|
|
23
|
-
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export default build;
|
|
@@ -2,7 +2,7 @@ import { join } from 'path';
|
|
|
2
2
|
import { readFileSync } from 'fs';
|
|
3
3
|
import mime from 'mime-types';
|
|
4
4
|
import { EdgeRuntime } from 'edge-runtime';
|
|
5
|
-
import { getUrlFromResource, getVulcanBuildId } from '#utils';
|
|
5
|
+
import { getUrlFromResource, getVulcanBuildId, debug } from '#utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* A custom fetch implementation that adds an additional path to the URL if it starts with 'file://'.
|
|
@@ -19,10 +19,12 @@ async function fetchPolyfill(context, resource, options) {
|
|
|
19
19
|
|
|
20
20
|
const urlObj = getUrlFromResource(resource);
|
|
21
21
|
|
|
22
|
+
// console.log(filePath);
|
|
22
23
|
if (urlObj.href.startsWith('file://')) {
|
|
23
24
|
const versionId = getVulcanBuildId();
|
|
24
25
|
const file = urlObj.pathname.replace(`/${versionId}`, '');
|
|
25
26
|
const filePath = join(process.cwd(), '.edge', 'storage', file);
|
|
27
|
+
|
|
26
28
|
const fileContent = readFileSync(filePath);
|
|
27
29
|
const contentType = mime.lookup(filePath) || 'application/octet-stream';
|
|
28
30
|
|
package/lib/env/runtime.env.js
CHANGED
|
@@ -56,7 +56,13 @@ function runtime(code) {
|
|
|
56
56
|
return context;
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
-
const edgeRuntime = new EdgeRuntime({
|
|
59
|
+
const edgeRuntime = new EdgeRuntime({
|
|
60
|
+
extend,
|
|
61
|
+
initialCode: code,
|
|
62
|
+
codeGeneration: {
|
|
63
|
+
strings: true,
|
|
64
|
+
},
|
|
65
|
+
});
|
|
60
66
|
return edgeRuntime;
|
|
61
67
|
}
|
|
62
68
|
|
package/lib/env/server.env.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
debug, readWorkerFile, feedback, exec,
|
|
3
|
-
} from '#utils';
|
|
1
|
+
import { debug, readWorkerFile, feedback, exec } from '#utils';
|
|
4
2
|
import { Messages } from '#constants';
|
|
5
3
|
import edgeRuntimePackage from 'edge-runtime';
|
|
6
4
|
import chokidar from 'chokidar';
|
|
@@ -84,9 +82,7 @@ async function handleFileChange(path, workerPath, port) {
|
|
|
84
82
|
return;
|
|
85
83
|
}
|
|
86
84
|
|
|
87
|
-
const {
|
|
88
|
-
entry, preset, mode, useNodePolyfills,
|
|
89
|
-
} = await vulcan.readVulcanEnv('local');
|
|
85
|
+
const { entry, preset, mode, useNodePolyfills } = await vulcan.readVulcanEnv('local');
|
|
90
86
|
|
|
91
87
|
feedback.build.info(Messages.build.info.rebuilding);
|
|
92
88
|
|
package/lib/main.js
CHANGED
|
@@ -112,10 +112,11 @@ function startVulcanProgram() {
|
|
|
112
112
|
|
|
113
113
|
program
|
|
114
114
|
.command('presets <command>')
|
|
115
|
-
.description('Create or
|
|
116
|
-
.
|
|
115
|
+
.description('Create <create> or list <ls> defined project presets for Edge')
|
|
116
|
+
.option('--preset <name>', 'Specify the name of the preset to list its modes')
|
|
117
|
+
.action(async (command, options) => {
|
|
117
118
|
const { presetsCommand } = await import('#commands');
|
|
118
|
-
await presetsCommand(command);
|
|
119
|
+
await presetsCommand(command, options.preset);
|
|
119
120
|
});
|
|
120
121
|
|
|
121
122
|
if (debugEnabled) {
|