@fastly/compute-js-static-publish 2.0.0 → 2.2.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/README.md CHANGED
@@ -94,6 +94,19 @@ You may still override any of these options individually.
94
94
  *1 - For Next.js, consider using `@fastly/next-compute-js`, a Node.js server implementation that allows you to run
95
95
  your Next.js application on Compute@Edge.
96
96
 
97
+ ## Troubleshooting
98
+
99
+ If you're using Fastly CLI 4.0.0 or newer, and your project was scaffolded using a version
100
+ of this tool older than 2.1.0, then you'll need to add the following to the
101
+ `fastly.toml` file that is in your `compute-js` directory.
102
+
103
+ ```toml
104
+ [scripts]
105
+ build = "npx @fastly/compute-js-static-publish --build-static && $(npm bin)/webpack && $(npm bin)/js-compute-runtime ./bin/index.js ./bin/main.wasm"
106
+ ```
107
+
108
+ If Fastly CLI has already added `build = "$(npm bin)/webpack && $(npm bin)/js-compute-runtime ./bin/index.js ./bin/main.wasm"`, then replace it with the above.
109
+
97
110
  ## Issues
98
111
 
99
112
  If you encounter any non-security-related bug or unexpected behavior, please [file an issue][bug].
@@ -20,9 +20,11 @@ function getFiles(results, dir) {
20
20
  }
21
21
  }
22
22
  }
23
- export async function buildStaticLoader() {
23
+ export async function buildStaticLoader(commandLineValues) {
24
24
  var _a, _b, _c, _d, _e, _f, _g, _h;
25
- console.log("Building loader...");
25
+ const { 'suppress-framework-warnings': suppressFrameworkWarnings } = commandLineValues;
26
+ const displayFrameworkWarnings = !suppressFrameworkWarnings;
27
+ console.log("🚀 Building loader...");
26
28
  let config;
27
29
  try {
28
30
  const staticPublishRcPath = path.resolve('./static-publish.rc.js');
@@ -32,19 +34,22 @@ export async function buildStaticLoader() {
32
34
  console.error("❌ Can't load static-publish.rc.js");
33
35
  console.error("Run this from a compute-js-static-publish compute-js directory.");
34
36
  console.error("Error: ", String(ex));
35
- process.exit(1);
37
+ process.exitCode = 1;
38
+ return;
36
39
  }
37
40
  const results = [];
38
41
  getFiles(results, config.publicDir);
39
42
  const outputDir = path.resolve();
40
43
  const publicDirRoot = path.resolve(config.publicDir);
41
- console.log(`Public directory '${publicDirRoot}'.`);
44
+ console.log(`✅ Public directory '${publicDirRoot}'.`);
42
45
  const staticDirs = (_a = config.staticDirs) !== null && _a !== void 0 ? _a : [];
43
46
  if (staticDirs.length > 0) {
44
- console.log(`Using static directories: ${staticDirs.join(', ')}`);
47
+ console.log(`✅ Using static directories: ${staticDirs.join(', ')}`);
45
48
  }
46
49
  else {
47
- console.log(`No static directories defined.`);
50
+ if (displayFrameworkWarnings) {
51
+ console.log(`✅ No static directories defined.`);
52
+ }
48
53
  }
49
54
  const staticRoots = staticDirs.map(dir => path.resolve(config.publicDir, dir));
50
55
  const DEFAULT_EXCLUDE_DIRS = [
@@ -52,10 +57,12 @@ export async function buildStaticLoader() {
52
57
  ];
53
58
  const excludeDirs = (_b = config.excludeDirs) !== null && _b !== void 0 ? _b : DEFAULT_EXCLUDE_DIRS;
54
59
  if (excludeDirs.length > 0) {
55
- console.log(`Using exclude directories: ${excludeDirs.join(', ')}`);
60
+ console.log(`✅ Using exclude directories: ${excludeDirs.join(', ')}`);
56
61
  }
57
62
  else {
58
- console.log(`No exclude directories defined.`);
63
+ if (displayFrameworkWarnings) {
64
+ console.log(`✅ No exclude directories defined.`);
65
+ }
59
66
  }
60
67
  const excludeRoots = excludeDirs.map(dir => path.resolve(config.publicDir, dir));
61
68
  // Load defaultContentTypes module
@@ -72,10 +79,12 @@ export async function buildStaticLoader() {
72
79
  ];
73
80
  const includeDirs = (_d = config.includeDirs) !== null && _d !== void 0 ? _d : DEFAULT_INCLUDE_DIRS;
74
81
  if (includeDirs.length > 0) {
75
- console.log(`Using include directories: ${includeDirs.join(', ')}`);
82
+ console.log(`✅ Using include directories: ${includeDirs.join(', ')}`);
76
83
  }
77
84
  else {
78
- console.log(`No include directories defined.`);
85
+ if (displayFrameworkWarnings) {
86
+ console.log(`✅ No include directories defined.`);
87
+ }
79
88
  }
80
89
  const includeRoots = includeDirs.map(dir => path.resolve(config.publicDir, dir));
81
90
  const excludeTest = config.excludeTest;
@@ -132,10 +141,12 @@ export async function buildStaticLoader() {
132
141
  const filePath = file.slice(publicDirRoot.length);
133
142
  const { contentType: type, isStatic, loadModule } = knownAssets[filePath];
134
143
  if (contentDef != null) {
135
- console.log(filePath + ': ' + JSON.stringify(type) + (isStatic ? ' [STATIC]' : ''));
144
+ console.log('✅ ' + filePath + ': ' + JSON.stringify(type) + (isStatic ? ' [STATIC]' : ''));
136
145
  }
137
146
  else {
138
- console.warn('Warning: Unknown file type ' + filePath + '...');
147
+ if (displayFrameworkWarnings) {
148
+ console.log('⚠️ Notice: Unknown file type ' + filePath + '. Treating as binary file.');
149
+ }
139
150
  }
140
151
  let content;
141
152
  if (contentDef == null || contentDef.binary) {
@@ -156,26 +167,34 @@ export async function buildStaticLoader() {
156
167
  fileContents += '};\n';
157
168
  let spaFile = (_e = config.spa) !== null && _e !== void 0 ? _e : false;
158
169
  if (spaFile) {
159
- console.log(`Application SPA file '${spaFile}'.`);
170
+ console.log(`✅ Application SPA file '${spaFile}'.`);
160
171
  if (!knownAssets[spaFile] || knownAssets[spaFile].contentType !== 'text/html') {
161
- console.warn(`'${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
172
+ if (displayFrameworkWarnings) {
173
+ console.log(`⚠️ Notice: '${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
174
+ }
162
175
  spaFile = false;
163
176
  }
164
177
  }
165
178
  else {
166
- console.log(`Application is not a SPA.`);
179
+ if (displayFrameworkWarnings) {
180
+ console.log(`✅ Application is not a SPA.`);
181
+ }
167
182
  }
168
183
  fileContents += `\nexport const spaFile = ${JSON.stringify(spaFile)};\n`;
169
184
  let notFoundPageFile = (_f = config.notFoundPage) !== null && _f !== void 0 ? _f : false;
170
185
  if (notFoundPageFile) {
171
- console.log(`Application 'not found (404)' file '${notFoundPageFile}'.`);
186
+ console.log(`✅ Application 'not found (404)' file '${notFoundPageFile}'.`);
172
187
  if (!knownAssets[notFoundPageFile] || knownAssets[notFoundPageFile].contentType !== 'text/html') {
173
- console.warn(`'${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
188
+ if (displayFrameworkWarnings) {
189
+ console.log(`⚠️ Notice: '${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
190
+ }
174
191
  notFoundPageFile = false;
175
192
  }
176
193
  }
177
194
  else {
178
- console.log(`Application specifies no 'not found (404)' page.`);
195
+ if (displayFrameworkWarnings) {
196
+ console.log(`✅ Application specifies no 'not found (404)' page.`);
197
+ }
179
198
  }
180
199
  fileContents += `\nexport const notFoundPageFile = ${JSON.stringify(notFoundPageFile)};\n`;
181
200
  let autoIndex = (_g = config.autoIndex) !== null && _g !== void 0 ? _g : null;
@@ -183,5 +202,5 @@ export async function buildStaticLoader() {
183
202
  let autoExt = (_h = config.autoExt) !== null && _h !== void 0 ? _h : null;
184
203
  fileContents += `\nexport const autoExt = ${JSON.stringify(autoExt)};\n`;
185
204
  fs.writeFileSync('./src/statics.js', fileContents);
186
- console.log("🚀 Wrote static file loader for " + files.length + " file(s).");
205
+ console.log("✅ Wrote static file loader for " + files.length + " file(s).");
187
206
  }
package/build/index.js CHANGED
@@ -12,6 +12,7 @@ const optionDefinitions = [
12
12
  // - docusaurus
13
13
  { name: 'preset', type: String, },
14
14
  { name: 'build-static', type: Boolean },
15
+ { name: 'suppress-framework-warnings', type: Boolean },
15
16
  { name: 'output', alias: 'o', type: String, defaultValue: './compute-js', },
16
17
  { name: 'public-dir', type: String, },
17
18
  { name: 'static-dir', type: String, },
@@ -62,8 +63,15 @@ const optionDefinitions = [
62
63
  ];
63
64
  const commandLineValues = commandLineArgs(optionDefinitions);
64
65
  console.log("Fastly Compute@Edge JavaScript Static Publisher");
66
+ let mode = 'init-app';
65
67
  if (commandLineValues['build-static']) {
66
- await buildStaticLoader();
67
- process.exit();
68
+ mode = 'build-static';
69
+ }
70
+ switch (mode) {
71
+ case 'build-static':
72
+ await buildStaticLoader(commandLineValues);
73
+ break;
74
+ case 'init-app':
75
+ initApp(commandLineValues);
76
+ break;
68
77
  }
69
- initApp(commandLineValues);
package/build/init-app.js CHANGED
@@ -44,7 +44,7 @@ export function initApp(commandLineValues) {
44
44
  if (presetClass == null) {
45
45
  console.error('Unknown preset name.');
46
46
  console.error("--preset must be one of: none, " + (Object.keys(presets).join(', ')));
47
- process.exit(1);
47
+ process.exitCode = 1;
48
48
  return;
49
49
  }
50
50
  preset = new presetClass();
@@ -67,7 +67,7 @@ export function initApp(commandLineValues) {
67
67
  if (preset != null) {
68
68
  if (!preset.check(packageJson, options)) {
69
69
  console.log("Failed preset check.");
70
- process.exit(1);
70
+ process.exitCode = 1;
71
71
  return;
72
72
  }
73
73
  }
@@ -76,7 +76,7 @@ export function initApp(commandLineValues) {
76
76
  const PUBLIC_DIR = options['public-dir'];
77
77
  if (PUBLIC_DIR == null) {
78
78
  console.error("❌ required parameter --public-dir not provided.");
79
- process.exit(1);
79
+ process.exitCode = 1;
80
80
  return;
81
81
  }
82
82
  const publicDir = path.resolve(PUBLIC_DIR);
@@ -100,7 +100,7 @@ export function initApp(commandLineValues) {
100
100
  spaFilename = path.resolve(spaFilename);
101
101
  if (!spaFilename.startsWith(publicDir)) {
102
102
  console.error(`❌ SPA file '${spaFilename}' not inside public directory!`);
103
- process.exit(1);
103
+ process.exitCode = 1;
104
104
  return;
105
105
  }
106
106
  }
@@ -118,14 +118,14 @@ export function initApp(commandLineValues) {
118
118
  notFoundPageFilename = path.resolve(notFoundPageFilename);
119
119
  if (!notFoundPageFilename.startsWith(publicDir)) {
120
120
  console.error(`❌ --not-found-page file '${notFoundPageFilename}' not inside public directory!`);
121
- process.exit(1);
121
+ process.exitCode = 1;
122
122
  return;
123
123
  }
124
124
  }
125
125
  const exists = fs.existsSync(computeJsDir);
126
126
  if (exists) {
127
127
  console.error(`❌ '${COMPUTE_JS_DIR}' directory already exists!`);
128
- process.exit(1);
128
+ process.exitCode = 1;
129
129
  return;
130
130
  }
131
131
  const author = options['author'];
@@ -173,22 +173,20 @@ export function initApp(commandLineValues) {
173
173
  "author": ${JSON.stringify(author)},
174
174
  "devDependencies": {
175
175
  "@fastly/expressly": "^1.0.0-alpha.7",
176
- "@fastly/js-compute": "^0.3.0",
176
+ "@fastly/js-compute": "^0.5.3",
177
177
  "buffer": "^6.0.3",
178
178
  "core-js": "^3.19.1",
179
179
  "webpack": "^5.64.0",
180
180
  "webpack-cli": "^4.9.1"
181
181
  },
182
182
  "engines": {
183
- "node": "^16"
183
+ "node": ">=16.0.0"
184
184
  },
185
185
  "license": "MIT",
186
186
  "private": true,
187
187
  "main": "src/index.js",
188
188
  "scripts": {
189
- "build": "js-compute-runtime bin/index.js bin/main.wasm",
190
- "deploy": "npm run build && fastly compute deploy",
191
- "prebuild": "npx @fastly/compute-js-static-publish --build-static && webpack"
189
+ "deploy": "fastly compute deploy"
192
190
  },
193
191
  "version": "0.2.1"
194
192
  }
@@ -207,6 +205,9 @@ language = "javascript"
207
205
  manifest_version = 2
208
206
  name = "${name}"
209
207
  service_id = "${fastlyServiceId}"
208
+
209
+ [scripts]
210
+ build = "npx @fastly/compute-js-static-publish --build-static && $(npm bin)/webpack && $(npm bin)/js-compute-runtime ./bin/index.js ./bin/main.wasm"
210
211
  `;
211
212
  const fastlyTomlPath = path.resolve(computeJsDir, 'fastly.toml');
212
213
  fs.writeFileSync(fastlyTomlPath, fastlyTomlContent, "utf-8");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fastly/compute-js-static-publish",
3
3
  "type": "module",
4
- "version": "2.0.0",
4
+ "version": "2.2.0",
5
5
  "description": "Static Publisher for Compute@Edge JavaScript",
6
6
  "main": "./build/index.js",
7
7
  "scripts": {
@@ -12,6 +12,7 @@ import * as fs from "fs";
12
12
  import * as path from "path";
13
13
  import * as url from "url";
14
14
  import { ContentTypeDef } from "./content-types.js";
15
+ import commandLineArgs from "command-line-args";
15
16
 
16
17
  function getFiles(results: string[], dir: string) {
17
18
  const entries = fs.readdirSync(dir, { withFileTypes: true });
@@ -25,9 +26,12 @@ function getFiles(results: string[], dir: string) {
25
26
  }
26
27
  }
27
28
 
28
- export async function buildStaticLoader() {
29
+ export async function buildStaticLoader(commandLineValues: commandLineArgs.CommandLineOptions) {
29
30
 
30
- console.log("Building loader...");
31
+ const { 'suppress-framework-warnings': suppressFrameworkWarnings } = commandLineValues;
32
+ const displayFrameworkWarnings = !suppressFrameworkWarnings;
33
+
34
+ console.log("🚀 Building loader...");
31
35
 
32
36
  let config: any;
33
37
  try {
@@ -37,7 +41,8 @@ export async function buildStaticLoader() {
37
41
  console.error("❌ Can't load static-publish.rc.js");
38
42
  console.error("Run this from a compute-js-static-publish compute-js directory.");
39
43
  console.error("Error: ", String(ex));
40
- process.exit(1);
44
+ process.exitCode = 1;
45
+ return;
41
46
  }
42
47
 
43
48
  const results: string[] = [];
@@ -47,13 +52,15 @@ export async function buildStaticLoader() {
47
52
 
48
53
  const publicDirRoot = path.resolve(config.publicDir);
49
54
 
50
- console.log(`Public directory '${publicDirRoot}'.`);
55
+ console.log(`✅ Public directory '${publicDirRoot}'.`);
51
56
 
52
57
  const staticDirs: string[] = config.staticDirs ?? [];
53
58
  if (staticDirs.length > 0) {
54
- console.log(`Using static directories: ${staticDirs.join(', ')}`);
59
+ console.log(`✅ Using static directories: ${staticDirs.join(', ')}`);
55
60
  } else {
56
- console.log(`No static directories defined.`);
61
+ if (displayFrameworkWarnings) {
62
+ console.log(`✅ No static directories defined.`);
63
+ }
57
64
  }
58
65
  const staticRoots = staticDirs.map(
59
66
  dir => path.resolve(config.publicDir, dir)
@@ -65,9 +72,11 @@ export async function buildStaticLoader() {
65
72
 
66
73
  const excludeDirs: string[] = config.excludeDirs ?? DEFAULT_EXCLUDE_DIRS;
67
74
  if (excludeDirs.length > 0) {
68
- console.log(`Using exclude directories: ${excludeDirs.join(', ')}`);
75
+ console.log(`✅ Using exclude directories: ${excludeDirs.join(', ')}`);
69
76
  } else {
70
- console.log(`No exclude directories defined.`);
77
+ if (displayFrameworkWarnings) {
78
+ console.log(`✅ No exclude directories defined.`);
79
+ }
71
80
  }
72
81
  const excludeRoots = excludeDirs.map(
73
82
  dir => path.resolve(config.publicDir, dir)
@@ -91,9 +100,11 @@ export async function buildStaticLoader() {
91
100
 
92
101
  const includeDirs: string[] = config.includeDirs ?? DEFAULT_INCLUDE_DIRS;
93
102
  if (includeDirs.length > 0) {
94
- console.log(`Using include directories: ${includeDirs.join(', ')}`);
103
+ console.log(`✅ Using include directories: ${includeDirs.join(', ')}`);
95
104
  } else {
96
- console.log(`No include directories defined.`);
105
+ if (displayFrameworkWarnings) {
106
+ console.log(`✅ No include directories defined.`);
107
+ }
97
108
  }
98
109
  const includeRoots = includeDirs.map(
99
110
  dir => path.resolve(config.publicDir, dir)
@@ -161,9 +172,11 @@ export async function buildStaticLoader() {
161
172
  const { contentType: type, isStatic, loadModule } = knownAssets[filePath];
162
173
 
163
174
  if (contentDef != null) {
164
- console.log(filePath + ': ' + JSON.stringify(type) + (isStatic ? ' [STATIC]' : ''));
175
+ console.log('✅ ' + filePath + ': ' + JSON.stringify(type) + (isStatic ? ' [STATIC]' : ''));
165
176
  } else {
166
- console.warn('Warning: Unknown file type ' + filePath + '...');
177
+ if (displayFrameworkWarnings) {
178
+ console.log('⚠️ Notice: Unknown file type ' + filePath + '. Treating as binary file.');
179
+ }
167
180
  }
168
181
 
169
182
  let content;
@@ -187,26 +200,34 @@ export async function buildStaticLoader() {
187
200
 
188
201
  let spaFile: string | false = config.spa ?? false;
189
202
  if(spaFile) {
190
- console.log(`Application SPA file '${spaFile}'.`);
203
+ console.log(`✅ Application SPA file '${spaFile}'.`);
191
204
  if(!knownAssets[spaFile] || knownAssets[spaFile].contentType !== 'text/html') {
192
- console.warn(`'${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
205
+ if (displayFrameworkWarnings) {
206
+ console.log(`⚠️ Notice: '${spaFile}' does not exist or is not of type 'text/html'. Ignoring.`);
207
+ }
193
208
  spaFile = false;
194
209
  }
195
210
  } else {
196
- console.log(`Application is not a SPA.`);
211
+ if (displayFrameworkWarnings) {
212
+ console.log(`✅ Application is not a SPA.`);
213
+ }
197
214
  }
198
215
 
199
216
  fileContents += `\nexport const spaFile = ${JSON.stringify(spaFile)};\n`;
200
217
 
201
218
  let notFoundPageFile: string | false = config.notFoundPage ?? false;
202
219
  if(notFoundPageFile) {
203
- console.log(`Application 'not found (404)' file '${notFoundPageFile}'.`);
220
+ console.log(`✅ Application 'not found (404)' file '${notFoundPageFile}'.`);
204
221
  if(!knownAssets[notFoundPageFile] || knownAssets[notFoundPageFile].contentType !== 'text/html') {
205
- console.warn(`'${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
222
+ if (displayFrameworkWarnings) {
223
+ console.log(`⚠️ Notice: '${notFoundPageFile}' does not exist or is not of type 'text/html'. Ignoring.`);
224
+ }
206
225
  notFoundPageFile = false;
207
226
  }
208
227
  } else {
209
- console.log(`Application specifies no 'not found (404)' page.`);
228
+ if (displayFrameworkWarnings) {
229
+ console.log(`✅ Application specifies no 'not found (404)' page.`);
230
+ }
210
231
  }
211
232
 
212
233
  fileContents += `\nexport const notFoundPageFile = ${JSON.stringify(notFoundPageFile)};\n`;
@@ -219,6 +240,6 @@ export async function buildStaticLoader() {
219
240
 
220
241
  fs.writeFileSync('./src/statics.js', fileContents);
221
242
 
222
- console.log("🚀 Wrote static file loader for " + files.length + " file(s).");
243
+ console.log("✅ Wrote static file loader for " + files.length + " file(s).");
223
244
 
224
245
  }
package/src/index.ts CHANGED
@@ -16,6 +16,7 @@ const optionDefinitions: OptionDefinition[] = [
16
16
  { name: 'preset', type: String, },
17
17
 
18
18
  { name: 'build-static', type: Boolean },
19
+ { name: 'suppress-framework-warnings', type: Boolean },
19
20
  { name: 'output', alias: 'o', type: String, defaultValue: './compute-js', },
20
21
  { name: 'public-dir', type: String, },
21
22
  { name: 'static-dir', type: String, },
@@ -73,9 +74,16 @@ const commandLineValues = commandLineArgs(optionDefinitions);
73
74
 
74
75
  console.log("Fastly Compute@Edge JavaScript Static Publisher");
75
76
 
76
- if (commandLineValues['build-static']) {
77
- await buildStaticLoader();
78
- process.exit();
77
+ let mode: 'init-app' | 'build-static' = 'init-app';
78
+ if(commandLineValues['build-static']) {
79
+ mode = 'build-static';
79
80
  }
80
81
 
81
- initApp(commandLineValues);
82
+ switch(mode) {
83
+ case 'build-static':
84
+ await buildStaticLoader(commandLineValues);
85
+ break;
86
+ case 'init-app':
87
+ initApp(commandLineValues);
88
+ break;
89
+ }
package/src/init-app.ts CHANGED
@@ -58,7 +58,7 @@ export function initApp(commandLineValues: CommandLineOptions) {
58
58
  if(presetClass == null) {
59
59
  console.error('Unknown preset name.');
60
60
  console.error("--preset must be one of: none, " + (Object.keys(presets).join(', ')));
61
- process.exit(1);
61
+ process.exitCode = 1;
62
62
  return;
63
63
  }
64
64
  preset = new presetClass();
@@ -83,7 +83,7 @@ export function initApp(commandLineValues: CommandLineOptions) {
83
83
  if(preset != null) {
84
84
  if(!preset.check(packageJson, options)) {
85
85
  console.log("Failed preset check.");
86
- process.exit(1);
86
+ process.exitCode = 1;
87
87
  return;
88
88
  }
89
89
  }
@@ -94,7 +94,7 @@ export function initApp(commandLineValues: CommandLineOptions) {
94
94
  const PUBLIC_DIR = options['public-dir'];
95
95
  if(PUBLIC_DIR == null) {
96
96
  console.error("❌ required parameter --public-dir not provided.");
97
- process.exit(1);
97
+ process.exitCode = 1;
98
98
  return;
99
99
  }
100
100
  const publicDir = path.resolve(PUBLIC_DIR);
@@ -124,7 +124,7 @@ export function initApp(commandLineValues: CommandLineOptions) {
124
124
  spaFilename = path.resolve(spaFilename);
125
125
  if(!spaFilename.startsWith(publicDir)) {
126
126
  console.error(`❌ SPA file '${spaFilename}' not inside public directory!`);
127
- process.exit(1);
127
+ process.exitCode = 1;
128
128
  return;
129
129
  }
130
130
  }
@@ -145,7 +145,7 @@ export function initApp(commandLineValues: CommandLineOptions) {
145
145
  notFoundPageFilename = path.resolve(notFoundPageFilename);
146
146
  if(!notFoundPageFilename.startsWith(publicDir)) {
147
147
  console.error(`❌ --not-found-page file '${notFoundPageFilename}' not inside public directory!`);
148
- process.exit(1);
148
+ process.exitCode = 1;
149
149
  return;
150
150
  }
151
151
  }
@@ -153,7 +153,7 @@ export function initApp(commandLineValues: CommandLineOptions) {
153
153
  const exists = fs.existsSync(computeJsDir);
154
154
  if(exists) {
155
155
  console.error(`❌ '${COMPUTE_JS_DIR}' directory already exists!`);
156
- process.exit(1);
156
+ process.exitCode = 1;
157
157
  return;
158
158
  }
159
159
 
@@ -209,22 +209,20 @@ export function initApp(commandLineValues: CommandLineOptions) {
209
209
  "author": ${JSON.stringify(author)},
210
210
  "devDependencies": {
211
211
  "@fastly/expressly": "^1.0.0-alpha.7",
212
- "@fastly/js-compute": "^0.3.0",
212
+ "@fastly/js-compute": "^0.5.3",
213
213
  "buffer": "^6.0.3",
214
214
  "core-js": "^3.19.1",
215
215
  "webpack": "^5.64.0",
216
216
  "webpack-cli": "^4.9.1"
217
217
  },
218
218
  "engines": {
219
- "node": "^16"
219
+ "node": ">=16.0.0"
220
220
  },
221
221
  "license": "MIT",
222
222
  "private": true,
223
223
  "main": "src/index.js",
224
224
  "scripts": {
225
- "build": "js-compute-runtime bin/index.js bin/main.wasm",
226
- "deploy": "npm run build && fastly compute deploy",
227
- "prebuild": "npx @fastly/compute-js-static-publish --build-static && webpack"
225
+ "deploy": "fastly compute deploy"
228
226
  },
229
227
  "version": "0.2.1"
230
228
  }
@@ -246,6 +244,9 @@ language = "javascript"
246
244
  manifest_version = 2
247
245
  name = "${name}"
248
246
  service_id = "${fastlyServiceId}"
247
+
248
+ [scripts]
249
+ build = "npx @fastly/compute-js-static-publish --build-static && $(npm bin)/webpack && $(npm bin)/js-compute-runtime ./bin/index.js ./bin/main.wasm"
249
250
  `;
250
251
 
251
252
  const fastlyTomlPath = path.resolve(computeJsDir, 'fastly.toml');