edge-functions 1.1.0 → 1.3.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.
Files changed (35) hide show
  1. package/.eslintrc.json +1 -1
  2. package/README.md +36 -0
  3. package/aliases.js +1 -1
  4. package/docs/overview.md +4 -3
  5. package/docs/presets.md +16 -4
  6. package/jsconfig.json +1 -1
  7. package/lib/build/dispatcher/dispatcher.js +62 -66
  8. package/lib/constants/framework-initializer.constants.js +51 -0
  9. package/lib/constants/index.js +4 -1
  10. package/lib/constants/messages/build.messages.js +2 -0
  11. package/lib/constants/messages/global.messages.js +4 -1
  12. package/lib/env/polyfills/FetchEvent.polyfills.js +13 -0
  13. package/lib/env/polyfills/fetch.polyfills.js +39 -0
  14. package/lib/env/polyfills/index.js +4 -0
  15. package/lib/env/runtime.env.js +9 -1
  16. package/lib/main.js +234 -94
  17. package/lib/platform/actions/core/propagation.actions.js +5 -4
  18. package/lib/presets/custom/angular/deliver/prebuild.js +6 -10
  19. package/lib/presets/custom/astro/deliver/prebuild.js +16 -20
  20. package/lib/presets/custom/hexo/deliver/prebuild.js +16 -20
  21. package/lib/presets/custom/next/deliver/prebuild.js +31 -35
  22. package/lib/presets/custom/react/deliver/prebuild.js +2 -6
  23. package/lib/presets/custom/vue/deliver/prebuild.js +28 -57
  24. package/lib/utils/exec/exec.utils.js +34 -24
  25. package/lib/utils/getAbsoluteLibDirPath/getAbsoluteLibDirPath.utils.js +1 -3
  26. package/lib/utils/getVulcanBuildId/getVulcanBuildId.utils.js +1 -1
  27. package/lib/utils/index.js +2 -2
  28. package/lib/utils/presets/index.js +3 -0
  29. package/lib/utils/presets/presets.utils.js +169 -0
  30. package/lib/utils/spinner/index.js +2 -2
  31. package/lib/utils/spinner/spinner.utils.js +1 -1
  32. package/package.json +10 -3
  33. package/lib/utils/getPresetsList/getPresetsList.utils.js +0 -68
  34. package/lib/utils/getPresetsList/index.js +0 -3
  35. /package/lib/utils/{getPresetsList/getPresetsList.utils.test.js → presets/presets.utils.test.js} +0 -0
package/lib/main.js CHANGED
@@ -1,15 +1,23 @@
1
1
  #! /usr/bin/env node
2
- import path from 'path';
2
+ import { join, resolve } from 'path';
3
+ import { readFileSync } from 'fs';
3
4
  import { Command } from 'commander';
4
5
  import { createPromptModule } from 'inquirer';
5
6
  import { satisfies } from 'semver';
6
- import { feedback, debug } from '#utils';
7
- import { Messages } from '#constants';
7
+ import {
8
+ feedback, debug, getAbsoluteLibDirPath,
9
+ } from '#utils';
10
+ import { Messages, FrameworkInitializer } from '#constants';
8
11
 
9
12
  const MIN_NODE_VERSION = '18.0.0';
10
13
 
14
+ const vulcanLibPath = getAbsoluteLibDirPath();
15
+ const vulcanRootPath = resolve(vulcanLibPath, '..');
16
+ const vulcanPackageJSON = JSON.parse(readFileSync(`${vulcanRootPath}/package.json`, 'utf8'));
17
+ const vulcanVersion = vulcanPackageJSON.version;
18
+
11
19
  const debugEnabled = process.env.DEBUG === 'true';
12
- const version = process.env.npm_package_version;
20
+
13
21
  const program = new Command();
14
22
  const prompt = createPromptModule();
15
23
 
@@ -33,21 +41,231 @@ function validateNodeMinVersion() {
33
41
  * setVulcanEnvironment();
34
42
  */
35
43
  function setVulcanEnvironment() {
36
- const ENV = process.env.AZION_ENV || 'production';
37
- if (!['production', 'stage', 'local'].includes(ENV)) {
44
+ const vulcanContext = {
45
+ env: 'production',
46
+ root: vulcanRootPath,
47
+ package: vulcanPackageJSON,
48
+ debug: debugEnabled,
49
+ version: vulcanVersion,
50
+ };
51
+
52
+ const AZION_ENV = process.env.AZION_ENV || vulcanContext.env;
53
+ if (!['production', 'stage', 'local'].includes(AZION_ENV)) {
38
54
  feedback.error(Messages.env.errors.invalid_environment);
39
55
  process.exit(1);
40
56
  } else {
41
- globalThis.vulcan = { env: ENV };
57
+ vulcanContext.env = AZION_ENV;
42
58
  }
59
+ globalThis.vulcan = vulcanContext;
43
60
  }
44
61
  /**
45
62
  * Starts the command-line interface program.
46
63
  * @example
47
- * startProgram();
64
+ * startVulcanProgram();
48
65
  */
49
66
  function startVulcanProgram() {
50
- program.version(version);
67
+ program.version(vulcanVersion);
68
+
69
+ program
70
+ .command('init')
71
+ .option('--name <project_name>', 'Project name')
72
+ .description('Initialize a new project')
73
+ .action(async (options) => {
74
+ const AVALIABLE_TEMPLATES = Object.keys(FrameworkInitializer);
75
+ let projectName = options.name;
76
+
77
+ const { frameworkChoice } = await prompt([
78
+ {
79
+ type: 'list',
80
+ name: 'frameworkChoice',
81
+ message: 'Choose a template for your project:',
82
+ choices: AVALIABLE_TEMPLATES,
83
+ },
84
+ ]);
85
+
86
+ while (!projectName) {
87
+ // eslint-disable-next-line no-await-in-loop
88
+ const { projectName: inputName } = await prompt([
89
+ {
90
+ type: 'input',
91
+ name: 'projectName',
92
+ message: 'Enter your project name:',
93
+ },
94
+ ]);
95
+
96
+ if (inputName) {
97
+ projectName = inputName;
98
+ }
99
+ if (!inputName) {
100
+ feedback.pending(Messages.info.name_required);
101
+ }
102
+ }
103
+
104
+ const createFrameworkTemplate = FrameworkInitializer[frameworkChoice];
105
+
106
+ if (createFrameworkTemplate) {
107
+ await createFrameworkTemplate(projectName);
108
+ } else {
109
+ feedback.error(Messages.errors.invalid_choice);
110
+ }
111
+ });
112
+
113
+ program
114
+ .command('build')
115
+ .description('Build a project for edge deployment')
116
+ .option(
117
+ '--preset <type>',
118
+ 'Preset of build target (e.g., vue, next, javascript)',
119
+ 'javascript',
120
+ )
121
+ .option(
122
+ '--mode <type>',
123
+ 'Mode of build target (e.g., deliver, compute)',
124
+ 'compute',
125
+ )
126
+ .option(
127
+ '--entry <string>',
128
+ 'Code entrypoint (default: ./main.js)',
129
+ './main.js',
130
+ )
131
+ .option(
132
+ '--useNodePolyfills',
133
+ 'Use node polyfills in build.',
134
+ )
135
+ .action(async ({
136
+ preset, mode, entry, versionId, useNodePolyfills,
137
+ }) => {
138
+ let entryPoint = entry;
139
+
140
+ if (preset === 'javascript') {
141
+ feedback.info('Using main.js as entrypoint by default');
142
+ }
143
+ if (preset === 'typescript') {
144
+ feedback.info('Using main.ts as entrypoint by default');
145
+ entryPoint = './main.ts';
146
+ }
147
+
148
+ const BuildDispatcher = (await import('#build')).default;
149
+ const buildDispatcher = new BuildDispatcher(
150
+ preset,
151
+ mode,
152
+ entryPoint,
153
+ versionId,
154
+ useNodePolyfills,
155
+ );
156
+ await buildDispatcher.run();
157
+ });
158
+
159
+ program
160
+ .command('dev')
161
+ .description('Start local environment')
162
+ .arguments('[file]')
163
+ .option('-p, --port <port>', 'Specify the port', '3000')
164
+ .action(async (file, options) => {
165
+ const { port } = options;
166
+ const parsedPort = parseInt(port, 10);
167
+ const { server } = await import('#env');
168
+ const entryPoint = file || join(process.cwd(), '.edge/worker.js');
169
+ server(entryPoint, parsedPort);
170
+ });
171
+
172
+ program
173
+ .command('presets <type>')
174
+ .description('Create or use defined project presets for Edge')
175
+ .action(async (type) => {
176
+ const { presets } = await import('#utils');
177
+
178
+ let name;
179
+ let mode;
180
+
181
+ switch (type) {
182
+ case 'create':
183
+ // eslint-disable-next-line no-constant-condition
184
+ while (true) {
185
+ // eslint-disable-next-line no-await-in-loop
186
+ const { inputPresetName } = await prompt([
187
+ {
188
+ type: 'input',
189
+ name: 'inputPresetName',
190
+ message: 'Enter the preset name:',
191
+ },
192
+ ]);
193
+
194
+ const presetExists = presets
195
+ .getKeys()
196
+ .map((existingPresetName) => existingPresetName.toLowerCase())
197
+ .includes(inputPresetName.toLowerCase());
198
+
199
+ if (presetExists) {
200
+ feedback.error('A preset with this name already exists.');
201
+ } else if (!inputPresetName) {
202
+ feedback.error('Preset name cannot be empty.');
203
+ } else {
204
+ name = inputPresetName;
205
+ break;
206
+ }
207
+ }
208
+
209
+ // eslint-disable-next-line no-constant-condition
210
+ while (true) {
211
+ // eslint-disable-next-line no-await-in-loop
212
+ const { inputMode } = await prompt([
213
+ {
214
+ type: 'list',
215
+ name: 'inputMode',
216
+ message: 'Choose the mode:',
217
+ choices: ['compute', 'deliver'],
218
+ },
219
+ ]);
220
+
221
+ if (['compute', 'deliver'].includes(inputMode)) {
222
+ mode = inputMode;
223
+ break;
224
+ } else {
225
+ feedback.error('Invalid mode. Choose either "compute" or "deliver".');
226
+ }
227
+ }
228
+
229
+ try {
230
+ presets.set(name, mode);
231
+ feedback.success(`${name}(${mode}) created with success!`);
232
+ feedback.info(`Now open './lib/presets/${name}/${mode}' and work on your preset.`);
233
+ } catch (error) {
234
+ debug.error(error);
235
+ feedback.error(Messages.errors.folder_creation_failed(name));
236
+ }
237
+ break;
238
+
239
+ case 'ls':
240
+ presets.getBeautify().forEach((preset) => feedback.option(preset));
241
+ break;
242
+
243
+ default:
244
+ feedback.error('Invalid argument provided.');
245
+ break;
246
+ }
247
+ });
248
+
249
+ program
250
+ .command('logs <type> [id]')
251
+ .description('Perform operations on function or application logs')
252
+ .option('-w, --watch', 'Show real-time logs')
253
+ .action(async (type, id, options) => {
254
+ const { functions } = await import('#platform');
255
+ const { watch } = options;
256
+
257
+ if (!['function', 'application'].includes(type)) {
258
+ feedback.error(Messages.platform.logs.errors.invalid_log_type);
259
+ return;
260
+ }
261
+
262
+ if (type === 'function') {
263
+ functions.actions.showFunctionLogs(id, watch);
264
+ }
265
+ if (type === 'application') {
266
+ feedback.info(Messages.platform.logs.info.unsupported_log_type);
267
+ }
268
+ });
51
269
 
52
270
  if (debugEnabled) {
53
271
  program
@@ -123,14 +341,14 @@ function startVulcanProgram() {
123
341
  program
124
342
  .command('storage sync')
125
343
  .description(
126
- 'Synchronize local .edge/statics with the Edge Function storage',
344
+ 'Synchronize local .edge/storage with the Edge Function storage',
127
345
  )
128
346
  .action(async () => {
129
347
  const { core } = await import('#platform');
130
348
  const { getVulcanBuildId } = await import('#utils');
131
349
 
132
350
  const versionId = getVulcanBuildId();
133
- const basePath = path.join(process.cwd(), '.edge/statics/');
351
+ const basePath = join(process.cwd(), '.edge/storage/');
134
352
  await core.actions.uploadStatics(versionId, basePath);
135
353
  });
136
354
 
@@ -142,7 +360,7 @@ function startVulcanProgram() {
142
360
  const { getVulcanBuildId } = await import('#utils');
143
361
 
144
362
  const versionId = getVulcanBuildId();
145
- const staticsPath = path.join(process.cwd(), '/.edge/statics');
363
+ const staticsPath = join(process.cwd(), '/.edge/storage');
146
364
 
147
365
  const answers = await prompt([
148
366
  {
@@ -167,87 +385,6 @@ function startVulcanProgram() {
167
385
  });
168
386
  }
169
387
 
170
- program
171
- .command('run')
172
- .description('Run Edge Function')
173
- .arguments('[file]')
174
- .option('-p, --port <port>', 'Specify the port', '3000')
175
- .action(async (file, options) => {
176
- const { port } = options;
177
- const parsedPort = parseInt(port, 10);
178
- const { server } = await import('#env');
179
- const entryPoint = file || path.join(process.cwd(), '.edge/worker.js');
180
- server(entryPoint, parsedPort);
181
- });
182
-
183
- program
184
- .command('logs <type> [id]')
185
- .description('Perform operations on function or application logs')
186
- .option('-w, --watch', 'Show real-time logs')
187
- .action(async (type, id, options) => {
188
- const { functions } = await import('#platform');
189
- const { watch } = options;
190
-
191
- if (!['function', 'application'].includes(type)) {
192
- feedback.error(Messages.platform.logs.errors.invalid_log_type);
193
- return;
194
- }
195
-
196
- if (type === 'function') {
197
- functions.actions.showFunctionLogs(id, watch);
198
- }
199
- if (type === 'application') {
200
- feedback.info(Messages.platform.logs.info.unsupported_log_type);
201
- }
202
- });
203
- program
204
- .command('build')
205
- .description('Build a project for edge deployment')
206
- .option(
207
- '--preset <type>',
208
- 'Preset of build target (e.g., vue, next, javascript)',
209
- 'javascript',
210
- )
211
- .option(
212
- '--mode <type>',
213
- 'Mode of build target (e.g., deliver, compute)',
214
- 'compute',
215
- )
216
- .option(
217
- '--entry <string>',
218
- 'Code entrypoint (default: ./main.js)',
219
- './main.js',
220
- )
221
- .option(
222
- '--useNodePolyfills',
223
- 'Use node polyfills in build.',
224
- )
225
- .action(async ({
226
- preset, mode, entry, versionId, useNodePolyfills,
227
- }) => {
228
- // TODO: generate versionID in dispatcher (currently generated for webpackconfig)
229
- const BuildDispatcher = (await import('#build')).default;
230
- const buildDispatcher = new BuildDispatcher(
231
- preset,
232
- mode,
233
- entry,
234
- versionId,
235
- useNodePolyfills,
236
- );
237
- await buildDispatcher.run();
238
- });
239
-
240
- program
241
- .command('presets <type>')
242
- .description('Create or use defined project presets for Edge.')
243
- .action(async (type) => {
244
- const { getPresetsList } = await import('#utils');
245
- const presets = getPresetsList();
246
-
247
- if (type === 'ls') {
248
- presets.forEach((preset) => feedback.option(preset));
249
- }
250
- });
251
388
  program.parse(process.argv);
252
389
  }
253
390
 
@@ -255,10 +392,13 @@ try {
255
392
  if (validateNodeMinVersion()) {
256
393
  setVulcanEnvironment();
257
394
  startVulcanProgram();
258
- } else {
395
+ }
396
+ if (!validateNodeMinVersion()) {
259
397
  feedback.error(Messages.errors.invalid_node_version(MIN_NODE_VERSION));
398
+ process.exit(1);
260
399
  }
261
400
  } catch (error) {
262
401
  feedback.error(Messages.errors.unknown_error);
263
402
  debug.error(error);
403
+ process.exit(1);
264
404
  }
@@ -1,5 +1,8 @@
1
1
  import { AzionEdges, Messages } from '#constants';
2
2
  import { feedback, debug, exec } from '#utils';
3
+
4
+ const isWindows = process.platform === 'win32';
5
+
3
6
  /**
4
7
  * @function
5
8
  * @memberof platform
@@ -18,8 +21,6 @@ import { feedback, debug, exec } from '#utils';
18
21
  * console.error(error);
19
22
  * }
20
23
  */
21
- const isWindows = process.platform === 'win32';
22
-
23
24
  function watchPropagation(domain) {
24
25
  let currentEdgeIndex = 0;
25
26
  let intervalId = null;
@@ -39,13 +40,13 @@ function watchPropagation(domain) {
39
40
  clearInterval(intervalId);
40
41
 
41
42
  let remainingEdgeIndex = currentEdgeIndex + 1;
42
- const remainingEdgesIntervalId = setInterval(async () => {
43
+ const remainingEdgesIntervalId = setInterval(async () => {
43
44
  if (remainingEdgeIndex >= AzionEdges.length) {
44
45
  clearInterval(remainingEdgesIntervalId);
45
46
  f.interactive.complete(
46
47
  Messages.platform.propagation.success.propagation_complete,
47
48
  );
48
- await exec(`${isWindows ? 'start ' : 'open ' } https://${domain} `)
49
+ await exec(`${isWindows ? 'start ' : 'open '} https://${domain} `);
49
50
 
50
51
  process.exit(0);
51
52
  } else {
@@ -1,4 +1,4 @@
1
- import { exec, feedback, getPackageManager } from '#utils';
1
+ import { exec, getPackageManager } from '#utils';
2
2
 
3
3
  const packageManager = await getPackageManager();
4
4
 
@@ -7,15 +7,11 @@ const packageManager = await getPackageManager();
7
7
  * @param {object} buildContext - info about the build
8
8
  */
9
9
  async function prebuild(buildContext) {
10
- try {
11
- // This is because npm interprets arguments passed directly
12
- // after the script as options for npm itself, not the script itself.
13
- const npmArgsForward = packageManager === 'npm' ? '--' : '';
14
- // support npm, yarn, pnpm
15
- await exec(`${packageManager} run build ${npmArgsForward} --output-path=.edge/storage`, 'Angular', true);
16
- } catch (error) {
17
- feedback.prebuild.error(error);
18
- }
10
+ // This is because npm interprets arguments passed directly
11
+ // after the script as options for npm itself, not the script itself.
12
+ const npmArgsForward = packageManager === 'npm' ? '--' : '';
13
+ // support npm, yarn, pnpm
14
+ await exec(`${packageManager} run build ${npmArgsForward} --output-path=.edge/storage`, 'Angular', true);
19
15
  }
20
16
 
21
17
  export default prebuild;
@@ -10,29 +10,25 @@ const packageManager = await getPackageManager();
10
10
  * @param {object} buildContext - info about the build
11
11
  */
12
12
  async function prebuild(buildContext) {
13
- try {
14
- const newOutDir = '.edge/storage';
15
- let outDir = 'dist';
13
+ const newOutDir = '.edge/storage';
14
+ let outDir = 'dist';
16
15
 
17
- // check if an output path is specified in config file
18
- const configFileContent = await readFile('./astro.config.mjs', 'utf-8');
19
- const attributeMatch = Array.from(
20
- configFileContent.matchAll(/outDir:(.*)\n/g),
21
- (match) => match,
22
- )[0];
23
- if (attributeMatch) {
24
- // get the specified value in config
25
- outDir = attributeMatch[1].trim();
26
- }
16
+ // check if an output path is specified in config file
17
+ const configFileContent = await readFile('./astro.config.mjs', 'utf-8');
18
+ const attributeMatch = Array.from(
19
+ configFileContent.matchAll(/outDir:(.*)\n/g),
20
+ (match) => match,
21
+ )[0];
22
+ if (attributeMatch) {
23
+ // get the specified value in config
24
+ outDir = attributeMatch[1].trim();
25
+ }
27
26
 
28
- await exec(`${packageManager} run build`, 'Astro', true);
27
+ await exec(`${packageManager} run build`, 'Astro', true);
29
28
 
30
- // move files to vulcan default path
31
- copyDirectory(outDir, newOutDir);
32
- rm(outDir, { recursive: true, force: true });
33
- } catch (error) {
34
- feedback.prebuild.error(error);
35
- }
29
+ // move files to vulcan default path
30
+ copyDirectory(outDir, newOutDir);
31
+ rm(outDir, { recursive: true, force: true });
36
32
  }
37
33
 
38
34
  export default prebuild;
@@ -10,29 +10,25 @@ const packageManager = await getPackageManager();
10
10
  * @param {object} buildContext - info about the build
11
11
  */
12
12
  async function prebuild(buildContext) {
13
- try {
14
- const newOutDir = '.edge/storage';
15
- let outDir = 'public';
13
+ const newOutDir = '.edge/storage';
14
+ let outDir = 'public';
16
15
 
17
- // check if an output path is specified in config file
18
- const configFileContent = await readFile('./_config.yml', 'utf-8');
19
- const attributeMatch = Array.from(
20
- configFileContent.matchAll(/public_dir:(.*)\n/g),
21
- (match) => match,
22
- )[0];
23
- if (attributeMatch) {
24
- // get the specified value in config
25
- outDir = attributeMatch[1].trim().replace(/["']/g, '');
26
- }
16
+ // check if an output path is specified in config file
17
+ const configFileContent = await readFile('./_config.yml', 'utf-8');
18
+ const attributeMatch = Array.from(
19
+ configFileContent.matchAll(/public_dir:(.*)\n/g),
20
+ (match) => match,
21
+ )[0];
22
+ if (attributeMatch) {
23
+ // get the specified value in config
24
+ outDir = attributeMatch[1].trim().replace(/["']/g, '');
25
+ }
27
26
 
28
- await exec('npx hexo generate', 'Hexo', true);
27
+ await exec(`${packageManager} hexo generate`, 'Hexo', true);
29
28
 
30
- // move files to vulcan default path
31
- copyDirectory(outDir, newOutDir);
32
- rm(outDir, { recursive: true, force: true });
33
- } catch (error) {
34
- feedback.prebuild.error(error);
35
- }
29
+ // move files to vulcan default path
30
+ copyDirectory(outDir, newOutDir);
31
+ rm(outDir, { recursive: true, force: true });
36
32
  }
37
33
 
38
34
  export default prebuild;
@@ -143,52 +143,48 @@ function validateStaticSiteMode(nextConfig) {
143
143
  * @param {object} buildContext - info about the build
144
144
  */
145
145
  async function prebuild(buildContext) {
146
- try {
147
- feedback.prebuild.info('Starting Next.js static build process...');
146
+ feedback.prebuild.info('Starting Next.js static build process...');
148
147
 
149
- const nextVersion = getPackageVersion('next');
150
- feedback.prebuild.info('Detected Next.js version:', nextVersion);
148
+ const nextVersion = getPackageVersion('next');
149
+ feedback.prebuild.info('Detected Next.js version:', nextVersion);
151
150
 
152
- const staticsOutputDir = '.edge/storage';
151
+ const staticsOutputDir = '.edge/storage';
153
152
 
154
- if (isANewerVersion(nextVersion)) {
155
- const nextConfig = await getNextConfig();
153
+ if (isANewerVersion(nextVersion)) {
154
+ const nextConfig = await getNextConfig();
156
155
 
157
- validateStaticSiteMode(nextConfig);
156
+ validateStaticSiteMode(nextConfig);
158
157
 
159
- // check if an output path is specified in config file
160
- let outDir = 'out';
161
- const configFileContent = await readFile('./next.config.js', 'utf-8');
162
- const attributeMatch = Array.from(
163
- configFileContent.matchAll(/distDir:(.*),/g),
164
- (match) => match,
165
- )[0];
166
- if (attributeMatch) {
167
- // get the specified value in config
168
- outDir = attributeMatch[1].trim().replace(/["']/g, '');
169
- }
158
+ // check if an output path is specified in config file
159
+ let outDir = 'out';
160
+ const configFileContent = await readFile('./next.config.js', 'utf-8');
161
+ const attributeMatch = Array.from(
162
+ configFileContent.matchAll(/distDir:(.*),/g),
163
+ (match) => match,
164
+ )[0];
165
+ if (attributeMatch) {
166
+ // get the specified value in config
167
+ outDir = attributeMatch[1].trim().replace(/["']/g, '');
168
+ }
170
169
 
171
- await exec(`${packageManager} run build`, `Next ${nextVersion}`, true);
170
+ await exec(`${packageManager} run build`, `Next ${nextVersion}`, true);
172
171
 
173
- // move files to vulcan default path
174
- copyDirectory(outDir, staticsOutputDir);
175
- rm(outDir, { recursive: true, force: true });
172
+ // move files to vulcan default path
173
+ copyDirectory(outDir, staticsOutputDir);
174
+ rm(outDir, { recursive: true, force: true });
176
175
 
177
- feedback.prebuild.info('Adapting Next.js build output...');
178
- await moveFiles(`${process.cwd()}/${staticsOutputDir}`);
179
- } else {
180
- await exec(`${packageManager} run build`, `Next ${nextVersion}`, true);
176
+ feedback.prebuild.info('Adapting Next.js build output...');
177
+ await moveFiles(`${process.cwd()}/${staticsOutputDir}`);
178
+ } else {
179
+ await exec(`${packageManager} run build`, `Next ${nextVersion}`, true);
181
180
 
182
- await exec(`npx next export -o ${staticsOutputDir}`, `Next ${nextVersion}`, true);
181
+ await exec(`npx next export -o ${staticsOutputDir}`, `Next ${nextVersion}`, true);
183
182
 
184
- feedback.prebuild.info('Adapting Next.js build output...');
185
- await moveFiles(`${process.cwd()}/${staticsOutputDir}`);
186
- }
187
-
188
- feedback.prebuild.success('Next.js build adaptation completed successfully.');
189
- } catch (error) {
190
- feedback.prebuild.error('Error occurred during Next.js build adaptation:', error);
183
+ feedback.prebuild.info('Adapting Next.js build output...');
184
+ await moveFiles(`${process.cwd()}/${staticsOutputDir}`);
191
185
  }
186
+
187
+ feedback.prebuild.success('Next.js build adaptation completed successfully.');
192
188
  }
193
189
 
194
190
  export default prebuild;
@@ -1,4 +1,4 @@
1
- import { exec, feedback, getPackageManager } from '#utils';
1
+ import { exec, getPackageManager } from '#utils';
2
2
 
3
3
  const packageManager = await getPackageManager();
4
4
 
@@ -7,11 +7,7 @@ const packageManager = await getPackageManager();
7
7
  * @param {object} buildContext - info about the build
8
8
  */
9
9
  async function prebuild(buildContext) {
10
- try {
11
- await exec(`BUILD_PATH="./.edge/storage" ${packageManager} run build`, 'React', true);
12
- } catch (error) {
13
- feedback.prebuild.error(error);
14
- }
10
+ await exec(`BUILD_PATH="./.edge/storage" ${packageManager} run build`, 'React', true);
15
11
  }
16
12
 
17
13
  export default prebuild;