@fastly/compute-js-static-publish 5.2.0 → 6.0.0-beta.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
@@ -1,6 +1,6 @@
1
- # Static Publisher for JavaScript on Compute@Edge
1
+ # Static Publisher for JavaScript on Fastly Compute
2
2
 
3
- Using a static site generator to build your website? Do you simply need to serve some static files? With `compute-js-static-publish`, now you can deploy and serve everything from Fastly's blazing-fast [Compute@Edge](https://developer.fastly.com/learning/compute/).
3
+ Using a static site generator to build your website? Do you simply need to serve some static files? With `compute-js-static-publish`, now you can deploy and serve everything from Fastly's blazing-fast [Compute](https://developer.fastly.com/learning/compute/).
4
4
 
5
5
  ## Prerequisites
6
6
 
@@ -18,11 +18,11 @@ Assuming the root of your output directory is `./public`,
18
18
  npx @fastly/compute-js-static-publish@latest --root-dir=./public
19
19
  ```
20
20
 
21
- This will generate a Compute@Edge application at `./compute-js`. It will add a default `./src/index.js` file that instantiates the [`PublisherServer`](#publisherserver) class and runs it to serve the static files from your project.
21
+ This will generate a Compute application at `./compute-js`. It will add a default `./src/index.js` file that instantiates the [`PublisherServer`](#publisherserver) class and runs it to serve the static files from your project.
22
22
 
23
- > This process creates a `./static-publish.rc.js` to hold your configuration. This, as well as the other files created in your new Compute@Edge program at `./compute-js`, can be committed to source control (except for the ones we specify in `.gitignore`!)
23
+ > This process creates a `./static-publish.rc.js` to hold your configuration. This, as well as the other files created in your new Compute program at `./compute-js`, can be committed to source control (except for the ones we specify in `.gitignore`!)
24
24
 
25
- Now, each time you build this Compute@Edge project, `compute-js-static-publish` will re-scan your `./public` directory and regenerate `/src/statics-metadata.js` and `/src/statics.js`. These files hold references to your project's public files.
25
+ Now, each time you build this Compute project, `compute-js-static-publish` will re-scan your `./public` directory and regenerate `/src/statics-metadata.js` and `/src/statics.js`. These files hold references to your project's public files.
26
26
 
27
27
  ### 2. Test your application using [Fastly's local development server](https://developer.fastly.com/learning/compute/testing/#running-a-local-testing-server)
28
28
 
@@ -36,7 +36,7 @@ This will serve your application using the default `PublisherServer()`.
36
36
 
37
37
  However, you can modify `/src/index.js` to add your own processing as you need. This file will not be overwritten after it is created.
38
38
 
39
- ### 3. When you're ready to go live, [deploy your Compute@Edge service](https://developer.fastly.com/reference/cli/compute/publish/)
39
+ ### 3. When you're ready to go live, [deploy your Compute service](https://developer.fastly.com/reference/cli/compute/publish/)
40
40
 
41
41
  ```shell
42
42
  fastly compute publish
@@ -51,7 +51,7 @@ fastly compute publish
51
51
  - Support for `If-None-Match` and `If-Modified-Since` request headers.
52
52
  - Optionally use Webpack as a module bundler.
53
53
  - Selectively serve files from Fastly's [KV Store](#kv-store), or embedded into your Wasm module.
54
- - Supports loading JavaScript files as code into your Compute@Edge application.
54
+ - Supports loading JavaScript files as code into your Compute application.
55
55
  - Presets for several static site generators.
56
56
 
57
57
  Some of these features are new! If you wish to update to this version, you may need to re-scaffold your application, or follow the steps outlined in [MIGRATING.md](./MIGRATING.md).
@@ -64,13 +64,13 @@ running as part of your build process.
64
64
  The files you have configured to be included (`--root-dir`) are enumerated and prepared. Their contents are included into
65
65
  your Wasm binary (or made available via [KV Store](#kv-store), if so configured). This process is called "publishing".
66
66
 
67
- Once the files are published, they are available to the other source files in the Compute@Edge application. For example,
67
+ Once the files are published, they are available to the other source files in the Compute application. For example,
68
68
  the stock application runs the [PublisherServer](#publisherserver) class to serve these files.
69
69
 
70
70
  For more advanced uses, such as accessing the contents of these file in your application, see the
71
71
  [Using the packaged objects in your own application](#using-published-assets-in-your-own-application) section below.
72
72
 
73
- Publishing is meant to run each time before building your Compute@Edge application into a Wasm file.
73
+ Publishing is meant to run each time before building your Compute application into a Wasm file.
74
74
  If the files in `--root-dir` have changed, then a new set of files will be published.
75
75
 
76
76
  ### Content Compression
@@ -98,21 +98,21 @@ npx @fastly/compute-js-static-publish \
98
98
 
99
99
  If you provide options, they override the defaults described below.
100
100
 
101
- Any configuration options will be written to a `static-publish.rc.js` file, and used each time you build your Compute@Edge
101
+ Any configuration options will be written to a `static-publish.rc.js` file, and used each time you build your Compute
102
102
  application.
103
103
 
104
- On subsequent builds of your Compute@Edge application, `compute-js-static-publish` will run with a special flag, `build-static`,
104
+ On subsequent builds of your Compute application, `compute-js-static-publish` will run with a special flag, `build-static`,
105
105
  reading from stored configuration, then scanning the `--public-dir` directory to recreate `./src/statics.js`.
106
106
 
107
107
  Any relative file and directory paths passed at the command line are handled as relative to the current directory.
108
108
 
109
109
  ### Publishing options:
110
110
 
111
- | Option | Default | Description |
112
- |------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
113
- | `preset` | (None) | Apply default options from a specified preset. See ["Frameworks and Static Site Generators"](#usage-with-frameworks-and-static-site-generators). |
114
- | `output` | `./compute-js` | The directory in which to create the Compute@Edge application. |
115
- | `root-dir` | (None) | **Required**. The root of the directory that contains the files to include in the publishing. All files you wish to include must reside under this root. |
111
+ | Option | Default | Description |
112
+ |------------------|-------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
113
+ | `preset` | (None) | Apply default options from a specified preset. See ["Frameworks and Static Site Generators"](#usage-with-frameworks-and-static-site-generators). |
114
+ | `output` | `./compute-js` | The directory in which to create the Compute application. |
115
+ | `root-dir` | (None) | **Required**. The root of the directory that contains the files to include in the publishing. All files you wish to include must reside under this root. |
116
116
 
117
117
  ### Server options:
118
118
 
@@ -135,15 +135,15 @@ Note that the files referenced by `--spa` and `--not-found-page` do not necessar
135
135
 
136
136
  ### Fastly service options
137
137
 
138
- These arguments are used to populate the `fastly.toml` and `package.json` files of your Compute@Edge application.
138
+ These arguments are used to populate the `fastly.toml` and `package.json` files of your Compute application.
139
139
 
140
- | Option | Default | Description |
141
- |-----------------|------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
142
- | `name` | `name` from `package.json`, or `compute-js-static-site` | The name of your Compute@Edge application. |
143
- | `description` | `description` from `package.json`, or `Compute@Edge static site` | The description of your Compute@Edge application. |
144
- | `author` | `author` from `package.json`, or `you@example.com` | The author of your Compute@Edge application. |
145
- | `service-id` | (None) | The ID of an existing Fastly WASM service for your Compute@Edge application. |
146
- | `kv-store-name` | (None) | The name of an existing [Fastly KV Store](https://developer.fastly.com/learning/concepts/data-stores/#kv-stores) to hold the content assets. In addition to already existing, it must be linked to the service specified by `--service-id`. |
140
+ | Option | Default | Description |
141
+ |-----------------|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
142
+ | `name` | `name` from `package.json`, or `compute-js-static-site` | The name of your Compute application. |
143
+ | `description` | `description` from `package.json`, or `Compute static site` | The description of your Compute application. |
144
+ | `author` | `author` from `package.json`, or `you@example.com` | The author of your Compute application. |
145
+ | `service-id` | (None) | The ID of an existing Fastly WASM service for your Compute application. |
146
+ | `kv-store-name` | (None) | The name of an existing [Fastly KV Store](https://developer.fastly.com/learning/concepts/data-stores/#kv-stores) to hold the content assets. In addition to already existing, it must be linked to the service specified by `--service-id`. |
147
147
 
148
148
  ## Usage with frameworks and static site generators
149
149
 
@@ -164,7 +164,7 @@ These arguments are used to populate the `fastly.toml` and `package.json` files
164
164
  You may still override any of these options individually.
165
165
 
166
166
  *1 - For Next.js, consider using `@fastly/next-compute-js`, a Next.js server implementation that allows you to run
167
- your Next.js application on Compute@Edge.
167
+ your Next.js application on Compute.
168
168
 
169
169
  *2 - Astro support does not support SSR.
170
170
 
@@ -211,7 +211,7 @@ For `compression`, the following values are allowed:
211
211
 
212
212
  ## Associating your project with a Fastly Service
213
213
 
214
- The project created by this tool is a Fastly Compute@Edge JavaScript application, complete with a `fastly.toml` file that
214
+ The project created by this tool is a Fastly Compute JavaScript application, complete with a `fastly.toml` file that
215
215
  describes your project to the Fastly CLI.
216
216
 
217
217
  To deploy your project to production, you deploy it to a [Fastly service](https://developer.fastly.com/reference/glossary#term-service)
@@ -222,7 +222,7 @@ you to create a Fastly service in your account for you (afterwards saving the ne
222
222
 
223
223
  Alternatively, you may deploy to a service that already exists. You can create this service using the
224
224
  [Fastly CLI](https://developer.fastly.com/reference/cli/service/create/) or the [Fastly web app](https://manage.fastly.com/).
225
- Note that since this is a Compute@Edge application, the service must be created as a Wasm service.
225
+ Note that since this is a Compute application, the service must be created as a Wasm service.
226
226
 
227
227
  Before deploying your application, specify the service by setting the `service_id` value in the `fastly.toml` file to the
228
228
  ID of the service. The `fastly compute publish` will deploy to the service identified by this value.
@@ -410,11 +410,11 @@ This process also makes metadata available about each of the files that are incl
410
410
  modified date, the file hash, and so on.
411
411
 
412
412
  The [`PublisherServer` class](#publisherserver) used by the default scaffolded application is a simple application of this content
413
- and metadata. By importing `./statics.js` into your Compute@Edge application, you can just as easily access this
413
+ and metadata. By importing `./statics.js` into your Compute application, you can just as easily access this
414
414
  information about the assets that were included during publishing.
415
415
 
416
416
  > IMPORTANT: Use a static `import` statement, rather than using `await import()` to load `./statics.js`, in order to
417
- ensure that its top-level code runs during the initialization phase of your Compute@Edge application.
417
+ ensure that its top-level code runs during the initialization phase of your Compute application.
418
418
 
419
419
  #### Assets
420
420
 
@@ -528,9 +528,9 @@ helloModule.hello(); // Will print "Hello, World!"
528
528
  #### Metadata
529
529
 
530
530
  In some use cases, you may have a use case where you need to know about the files that were included during publishing,
531
- but not in the context of Compute@Edge. (e.g., a tool that runs in Node.js that performs some maintenance task on assets).
531
+ but not in the context of Compute. (e.g., a tool that runs in Node.js that performs some maintenance task on assets).
532
532
 
533
- You cannot import `./statics.js` from a Node.js application, as it holds dependencies on Compute@Edge.
533
+ You cannot import `./statics.js` from a Node.js application, as it holds dependencies on Compute.
534
534
 
535
535
  Instead, you can import `./statics-metadata.js`, a companion file that is generated in the same directory. This file
536
536
  exposes plain JavaScript objects that contain the metadata about your content assets that were included in the final
@@ -1 +1 @@
1
- {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build-static.ts"],"names":[],"mappings":"AA+DA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AA6IhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAqe5F"}
1
+ {"version":3,"file":"build-static.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/build-static.ts"],"names":[],"mappings":"AA+DA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AA6IhD,wBAAsB,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,kBAAkB,iBAye5F"}
@@ -264,9 +264,12 @@ export async function buildStaticLoader(commandLineValues) {
264
264
  console.log(`⚠️ Notice: By default, pre-compressed content assets are not generated when KV Store is not used.`);
265
265
  console.log(" If you want to pre-compress assets, add a value for 'contentCompression' to your static-publish.rc.js.");
266
266
  }
267
+ // The Static Content Root Dir, which will hold the loaders and a copy of static files.
268
+ const staticContentRootDir = config.staticContentRootDir;
267
269
  // Create "static content" dir that will be used to hold a copy of static files.
268
- // NOTE: this is needed because includeBytes doesn't seem to be able to traverse up to parent dir of the Compute project.
269
- const staticContentDir = './src/static-content';
270
+ // NOTE: This copy is created so that they can be loaded with includeBytes(), which requires
271
+ // all files to be under the Compute project dir.
272
+ const staticContentDir = staticContentRootDir + '/static-content';
270
273
  fs.rmSync(staticContentDir, { recursive: true, force: true });
271
274
  fs.mkdirSync(staticContentDir, { recursive: true });
272
275
  // Build content assets metadata
@@ -396,12 +399,12 @@ export async function buildStaticLoader(commandLineValues) {
396
399
  metadataFileContents += ` ${JSON.stringify(key)}: ${JSON.stringify(value)},\n`;
397
400
  }
398
401
  metadataFileContents += '};\n';
399
- fs.writeFileSync('./src/statics-metadata.js', metadataFileContents);
402
+ fs.writeFileSync(staticContentRootDir + '/statics-metadata.js', metadataFileContents);
400
403
  console.log(`✅ Wrote static file metadata for ${contentItems} file(s).`);
401
404
  // Copy Types file for static file loader
402
405
  try {
403
406
  const typesFile = path.resolve(__dirname, '../../../resources/statics-metadata.d.ts');
404
- fs.copyFileSync(typesFile, './src/statics-metadata.d.ts');
407
+ fs.copyFileSync(typesFile, staticContentRootDir + '/statics-metadata.d.ts');
405
408
  console.log("✅ Wrote content assets metadata types file statics-metadata.d.ts.");
406
409
  }
407
410
  catch {
@@ -423,9 +426,9 @@ export async function buildStaticLoader(commandLineValues) {
423
426
  if (assetInfo.includeModule && assetInfo.useStaticImport) {
424
427
  staticImportModuleNumber++;
425
428
  staticImportModuleNumbers[assetInfo.assetKey] = staticImportModuleNumber;
426
- // static-content lives in the src dir, so the import must be declared as
429
+ // static-content lives in the staticContentRootDir dir, so the import must be declared as
427
430
  // relative to that file.
428
- const relativeFilePath = path.relative('./src', assetInfo.file);
431
+ const relativeFilePath = path.relative(staticContentRootDir, assetInfo.file);
429
432
  fileContents += `import * as fileModule${staticImportModuleNumber} from "${relativeFilePath}";\n`;
430
433
  }
431
434
  }
@@ -445,9 +448,9 @@ export async function buildStaticLoader(commandLineValues) {
445
448
  module = `fileModule${moduleNumber}`;
446
449
  }
447
450
  else {
448
- // static-content lives in the src dir, so the import must be declared as
451
+ // static-content lives in the staticContentRootDir dir, so the import must be declared as
449
452
  // relative to that file.
450
- const relativeFilePath = path.relative('./src', assetInfo.file);
453
+ const relativeFilePath = path.relative(staticContentRootDir, assetInfo.file);
451
454
  loadModuleFunction = `() => import("${relativeFilePath}")`;
452
455
  module = 'null';
453
456
  }
@@ -520,15 +523,15 @@ export async function buildStaticLoader(commandLineValues) {
520
523
  '\n }' +
521
524
  '\n return server;' +
522
525
  '\n}\n';
523
- fs.writeFileSync('./src/statics.js', fileContents);
526
+ fs.writeFileSync(staticContentRootDir + '/statics.js', fileContents);
524
527
  console.log("✅ Wrote static file loader for " + files.length + " file(s).");
525
528
  // Copy Types file for static file loader
526
529
  try {
527
530
  const staticsTypeFile = path.resolve(__dirname, '../../../resources/statics.d.ts');
528
- fs.copyFileSync(staticsTypeFile, './src/statics.d.ts');
529
- console.log("✅ Wrote static file loader types file statics.d.ts.");
531
+ fs.copyFileSync(staticsTypeFile, staticContentRootDir + '/statics.d.ts');
532
+ console.log(`✅ Wrote static file loader types file ${staticContentRootDir}/statics.d.ts.`);
530
533
  }
531
534
  catch {
532
- console.log("⚠️ Notice: could not write static file loader types file statics.d.ts.");
535
+ console.log(`⚠️ Notice: could not write static file loader types file ${staticContentRootDir}/statics.d.ts.`);
533
536
  }
534
537
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAoPvD,wBAAgB,OAAO,CAAC,iBAAiB,EAAE,kBAAkB,QAka5D"}
1
+ {"version":3,"file":"init-app.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/init-app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAiQvD,wBAAgB,OAAO,CAAC,iBAAiB,EAAE,kBAAkB,QA6c5D"}
@@ -1,7 +1,7 @@
1
- // This program creates a Compute@Edge JavaScript application
1
+ // This program creates a Fastly Compute JavaScript application
2
2
  // in a subfolder named compute-js.
3
3
  // This project can be served using fastly compute serve
4
- // or deployed to a Compute@Edge service using fastly compute publish.
4
+ // or deployed to a Compute service using fastly compute publish.
5
5
  import * as child_process from "child_process";
6
6
  import * as path from "path";
7
7
  import * as fs from "fs";
@@ -11,13 +11,14 @@ const defaultOptions = {
11
11
  rootDir: undefined,
12
12
  publicDir: undefined,
13
13
  staticDirs: [],
14
+ staticContentRootDir: undefined,
14
15
  spa: undefined,
15
16
  notFoundPage: '[public-dir]/404.html',
16
17
  autoIndex: ['index.html', 'index.htm'],
17
18
  autoExt: ['.html', '.htm'],
18
19
  author: 'you@example.com',
19
20
  name: 'compute-js-static-site',
20
- description: 'Compute@Edge static site',
21
+ description: 'Fastly Compute static site',
21
22
  serviceId: undefined,
22
23
  kvStoreName: undefined,
23
24
  };
@@ -67,6 +68,16 @@ function processCommandLineArgs(commandLineValues) {
67
68
  staticDirs = asArray.map(x => path.resolve(x));
68
69
  }
69
70
  }
71
+ let staticContentRootDir;
72
+ {
73
+ const staticContentRootDirValue = commandLineValues['static-content-root-dir'];
74
+ if (staticContentRootDirValue == null || typeof staticContentRootDirValue === 'string') {
75
+ staticContentRootDir = staticContentRootDirValue;
76
+ }
77
+ if (staticContentRootDir != null) {
78
+ staticContentRootDir = path.resolve(staticContentRootDir);
79
+ }
80
+ }
70
81
  let spa;
71
82
  {
72
83
  const spaValue = commandLineValues['spa'];
@@ -167,6 +178,7 @@ function processCommandLineArgs(commandLineValues) {
167
178
  rootDir,
168
179
  publicDir,
169
180
  staticDirs,
181
+ staticContentRootDir,
170
182
  spa,
171
183
  notFoundPage,
172
184
  autoIndex,
@@ -254,7 +266,7 @@ export function initApp(commandLineValues) {
254
266
  ...options,
255
267
  ...(preset != null ? preset.defaultOptions : {}),
256
268
  ...pickKeys(['author', 'name', 'description'], (packageJson ?? {})),
257
- ...pickKeys(['rootDir', 'publicDir', 'staticDirs', 'spa', 'notFoundPage', 'autoIndex', 'autoExt', 'author', 'name', 'description', 'serviceId', 'kvStoreName'], commandLineAppOptions),
269
+ ...pickKeys(['rootDir', 'publicDir', 'staticDirs', 'staticContentRootDir', 'spa', 'notFoundPage', 'autoIndex', 'autoExt', 'author', 'name', 'description', 'serviceId', 'kvStoreName'], commandLineAppOptions),
258
270
  };
259
271
  if (preset != null) {
260
272
  if (!preset.check(packageJson, options)) {
@@ -315,6 +327,22 @@ export function initApp(commandLineValues) {
315
327
  }
316
328
  staticDirs.push(staticDir);
317
329
  }
330
+ // Static Content Root Dir must be under the current dir
331
+ let staticContentRootDir = options.staticContentRootDir;
332
+ if (staticContentRootDir == null) {
333
+ staticContentRootDir = path.resolve('./static-publisher');
334
+ }
335
+ if (staticContentRootDir.includes('//') ||
336
+ !staticContentRootDir.startsWith(process.cwd())) {
337
+ console.error(`❌ Specified static content root directory '${staticContentRootDir}' must be a relative path.`);
338
+ console.error(` * ${publicDir} must be under ${rootDir}`);
339
+ process.exitCode = 1;
340
+ return;
341
+ }
342
+ while (staticContentRootDir.endsWith('/')) {
343
+ staticContentRootDir = staticContentRootDir.slice(0, -1);
344
+ }
345
+ staticContentRootDir = path.relative(process.cwd(), staticContentRootDir);
318
346
  // SPA and Not Found are relative to the asset root dir.
319
347
  const SPA = options.spa;
320
348
  let spaFilename;
@@ -374,36 +402,38 @@ export function initApp(commandLineValues) {
374
402
  return v.startsWith('..') ? v : './' + v;
375
403
  }
376
404
  console.log('');
377
- console.log('Asset Root Dir :', rootRelative(rootDir));
378
- console.log('Public Dir :', rootRelative(publicDir));
379
- console.log('Static Dir :', staticDirs.length > 0 ? staticDirs.map(rootRelative) : '(None)');
380
- console.log('SPA :', rootRelative(spaFilename) ?? '(None)');
381
- console.log('404 Page :', rootRelative(notFoundPageFilename) ?? '(None)');
382
- console.log('Auto-Index :', autoIndex.length > 0 ? autoIndex.map(rootRelative) : '(None)');
383
- console.log('Auto-Ext :', autoExt.length > 0 ? autoExt.map(rootRelative) : '(None)');
384
- console.log('name :', name);
385
- console.log('author :', author);
386
- console.log('description :', description);
387
- console.log('Service ID :', fastlyServiceId ?? '(None)');
388
- console.log('KV Store Name :', kvStoreName ?? '(None)');
405
+ console.log('Asset Root Dir :', rootRelative(rootDir));
406
+ console.log('Public Dir :', rootRelative(publicDir));
407
+ console.log('Static Dir :', staticDirs.length > 0 ? staticDirs.map(rootRelative) : '(None)');
408
+ console.log('Static Content Root Dir :', staticContentRootDir);
409
+ console.log('SPA :', rootRelative(spaFilename) ?? '(None)');
410
+ console.log('404 Page :', rootRelative(notFoundPageFilename) ?? '(None)');
411
+ console.log('Auto-Index :', autoIndex.length > 0 ? autoIndex.map(rootRelative) : '(None)');
412
+ console.log('Auto-Ext :', autoExt.length > 0 ? autoExt.map(rootRelative) : '(None)');
413
+ console.log('name :', name);
414
+ console.log('author :', author);
415
+ console.log('description :', description);
416
+ console.log('Service ID :', fastlyServiceId ?? '(None)');
417
+ console.log('KV Store Name :', kvStoreName ?? '(None)');
389
418
  console.log('');
390
419
  if (useWebpack) {
391
420
  console.log('Creating project with Webpack.');
392
421
  console.log('');
393
422
  }
394
- console.log("Initializing Compute@Edge Application in " + computeJsDir + "...");
423
+ console.log("Initializing Compute Application in " + computeJsDir + "...");
395
424
  fs.mkdirSync(computeJsDir);
396
425
  fs.mkdirSync(path.resolve(computeJsDir, './src'));
426
+ const staticContentRootDirFromRoot = staticContentRootDir.slice(1);
397
427
  // .gitignore
398
428
  const gitIgnoreContent = `\
399
429
  /node_modules
400
430
  /bin
401
431
  /pkg
402
- /src/statics.js
403
- /src/statics.d.ts
404
- /src/statics-metadata.js
405
- /src/statics-metadata.d.ts
406
- /src/static-content
432
+ ${staticContentRootDirFromRoot}/statics.js
433
+ ${staticContentRootDirFromRoot}/statics.d.ts
434
+ ${staticContentRootDirFromRoot}/statics-metadata.js
435
+ ${staticContentRootDirFromRoot}/statics-metadata.d.ts
436
+ ${staticContentRootDirFromRoot}/static-content
407
437
  `;
408
438
  const gitIgnorePath = path.resolve(computeJsDir, '.gitignore');
409
439
  fs.writeFileSync(gitIgnorePath, gitIgnoreContent, "utf-8");
@@ -450,7 +480,7 @@ export function initApp(commandLineValues) {
450
480
  // fastly.toml
451
481
  // language=toml
452
482
  const fastlyTomlContent = `\
453
- # This file describes a Fastly Compute@Edge package. To learn more visit:
483
+ # This file describes a Fastly Compute package. To learn more visit:
454
484
  # https://developer.fastly.com/reference/fastly-toml/
455
485
 
456
486
  authors = [ "${author}" ]
@@ -514,6 +544,7 @@ ${fastlyServiceId != null ? `service_id = "${fastlyServiceId}"
514
544
  /** @type {import('@fastly/compute-js-static-publish').StaticPublisherConfig} */
515
545
  const config = {
516
546
  rootDir: ${JSON.stringify(rootDirRel)},
547
+ staticContentRootDir: ${JSON.stringify(staticContentRootDir)},
517
548
  ${(kvStoreName != null ? 'kvStoreName: ' + JSON.stringify(kvStoreName) : '// kvStoreName: false')},
518
549
  // excludeDirs: [ './node_modules' ],
519
550
  // excludeDotFiles: true,
@@ -547,21 +578,41 @@ ${useWebpack ? 'module.exports =' : 'export default'} config;
547
578
  fs.copyFileSync(webpackConfigJsSrcPath, webpackConfigJsPath);
548
579
  }
549
580
  // src/index.js
550
- const indexJsSrcPath = path.resolve(__dirname, '../../../resources/index.js');
581
+ const staticsRelativePath = path.relative('./src', staticContentRootDir);
582
+ const indexJsContent = /* language=JavaScript */ `\
583
+ /// <reference types="@fastly/js-compute" />
584
+ import { getServer } from '${staticsRelativePath}/statics.js';
585
+ const staticContentServer = getServer();
586
+
587
+ // eslint-disable-next-line no-restricted-globals
588
+ addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
589
+ async function handleRequest(event) {
590
+
591
+ const response = await staticContentServer.serveRequest(event.request);
592
+ if (response != null) {
593
+ return response;
594
+ }
595
+
596
+ // Do custom things here!
597
+ // Handle API requests, serve non-static responses, etc.
598
+
599
+ return new Response('Not found', { status: 404 });
600
+ }
601
+ `;
551
602
  const indexJsPath = path.resolve(computeJsDir, './src/index.js');
552
- fs.copyFileSync(indexJsSrcPath, indexJsPath);
553
- console.log("🚀 Compute@Edge application created!");
603
+ fs.writeFileSync(indexJsPath, indexJsContent, 'utf-8');
604
+ console.log("🚀 Compute application created!");
554
605
  console.log('Installing dependencies...');
555
606
  console.log(`npm --prefix ${COMPUTE_JS_DIR} install`);
556
607
  child_process.spawnSync('npm', ['--prefix', COMPUTE_JS_DIR, 'install'], { stdio: 'inherit' });
557
608
  console.log('');
558
609
  console.log('');
559
- console.log('To run your Compute@Edge application locally:');
610
+ console.log('To run your Compute application locally:');
560
611
  console.log('');
561
612
  console.log(' cd ' + COMPUTE_JS_DIR);
562
613
  console.log(' fastly compute serve');
563
614
  console.log('');
564
- console.log('To build and deploy to your Compute@Edge service:');
615
+ console.log('To build and deploy to your Compute service:');
565
616
  console.log('');
566
617
  console.log(' cd ' + COMPUTE_JS_DIR);
567
618
  console.log(' fastly compute publish');
@@ -33,6 +33,9 @@ const optionDefinitions = [
33
33
  // with a long TTL. Each entry should be a relative path
34
34
  // from 'public-dir'.
35
35
  { name: 'static-dir', type: String, multiple: true, },
36
+ // The 'static content root directory' where the Static Publisher
37
+ // outputs its metadata files and loaders.
38
+ { name: 'static-content-root-dir', type: String, },
36
39
  // Path to a file to be used to serve in a SPA application.
37
40
  // The Publisher Server will serve this file with a 200 status code
38
41
  // when the request doesn't match a known file, and the accept
@@ -70,7 +73,7 @@ const optionDefinitions = [
70
73
  { name: 'clean-kv-store', type: Boolean, },
71
74
  ];
72
75
  const commandLineValues = commandLineArgs(optionDefinitions);
73
- console.log("Fastly Compute@Edge JavaScript Static Publisher");
76
+ console.log("Fastly Compute JavaScript Static Publisher");
74
77
  let mode = 'init-app';
75
78
  if (commandLineValues['build-static']) {
76
79
  mode = 'build-static';
@@ -1 +1 @@
1
- {"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/cli/load-config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,+BAA+B,EAEhC,MAAM,+BAA+B,CAAC;AAyVvC,wBAAsB,cAAc,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,+BAA+B,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAAC,CAiBnI"}
1
+ {"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/cli/load-config.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,+BAA+B,EAEhC,MAAM,+BAA+B,CAAC;AA6WvC,wBAAsB,cAAc,CAAC,MAAM,GAAE,MAAM,EAAO,GAAG,OAAO,CAAC;IAAC,UAAU,EAAE,+BAA+B,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,GAAG,CAAA;CAAC,CAAC,CAiBnI"}
@@ -172,7 +172,7 @@ const normalizePublisherServerConfig = buildNormalizeFunctionForObject((config,
172
172
  };
173
173
  });
174
174
  const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
175
- let { rootDir, kvStoreName, excludeDirs, excludeDotFiles, includeWellKnown, contentAssetInclusionTest, contentCompression, moduleAssetInclusionTest, contentTypes, server, } = config;
175
+ let { rootDir, staticContentRootDir, kvStoreName, excludeDirs, excludeDotFiles, includeWellKnown, contentAssetInclusionTest, contentCompression, moduleAssetInclusionTest, contentTypes, server, } = config;
176
176
  if (!isSpecified(config, 'rootDir')) {
177
177
  errors.push('rootDir must be specified.');
178
178
  }
@@ -184,6 +184,22 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
184
184
  errors.push('rootDir must be a non-empty string.');
185
185
  }
186
186
  }
187
+ if (!isSpecified(config, 'staticContentRootDir')) {
188
+ staticContentRootDir = './src';
189
+ }
190
+ else {
191
+ if (staticContentRootDir.startsWith('./') &&
192
+ staticContentRootDir !== './' &&
193
+ !staticContentRootDir.includes('//')) {
194
+ // ok
195
+ }
196
+ else {
197
+ errors.push('staticContentRootDir must be a relative subdirectory.');
198
+ }
199
+ while (staticContentRootDir.endsWith('/')) {
200
+ staticContentRootDir = staticContentRootDir.slice(0, -1);
201
+ }
202
+ }
187
203
  if (!isSpecified(config, 'kvStoreName')) {
188
204
  kvStoreName = null;
189
205
  }
@@ -335,6 +351,7 @@ const normalizeConfig = buildNormalizeFunctionForObject((config, errors) => {
335
351
  }
336
352
  return {
337
353
  rootDir,
354
+ staticContentRootDir,
338
355
  kvStoreName,
339
356
  excludeDotFiles,
340
357
  includeWellKnown,
@@ -4,7 +4,7 @@ export class AstroPreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './dist',
6
6
  name: 'my-astro-app',
7
- description: 'Compute@Edge static site from Astro',
7
+ description: 'Fastly Compute static site from Astro',
8
8
  };
9
9
  }
10
10
  check(packageJson) {
@@ -5,7 +5,7 @@ export class CreateReactAppPreset {
5
5
  rootDir: './build',
6
6
  staticDirs: ['[public-dir]/static'],
7
7
  name: 'my-create-react-app',
8
- description: 'Compute@Edge static site from create-react-app',
8
+ description: 'Fastly Compute static site from create-react-app',
9
9
  };
10
10
  }
11
11
  check(packageJson) {
@@ -4,7 +4,7 @@ export class DocusaurusPreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './build',
6
6
  name: 'my-docusaurus-app',
7
- description: 'Compute@Edge static site from docusaurus',
7
+ description: 'Fastly Compute static site from docusaurus',
8
8
  };
9
9
  }
10
10
  check() {
@@ -4,7 +4,7 @@ export class GatsbyPreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './public',
6
6
  name: 'my-gatsby-app',
7
- description: 'Compute@Edge static site from Gatsby',
7
+ description: 'Fastly Compute static site from Gatsby',
8
8
  };
9
9
  }
10
10
  check() {
@@ -4,7 +4,7 @@ export class NextJsPreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './out',
6
6
  name: 'my-next-app',
7
- description: 'Compute@Edge static site from Next.js',
7
+ description: 'Fastly Compute static site from Next.js',
8
8
  };
9
9
  }
10
10
  check() {
@@ -4,7 +4,7 @@ export class SvelteKitPreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './dist',
6
6
  name: 'my-sveltekit-app',
7
- description: 'Compute@Edge static site from SvelteKit',
7
+ description: 'Fastly Compute static site from SvelteKit',
8
8
  };
9
9
  }
10
10
  check() {
@@ -4,7 +4,7 @@ export class VitePreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './dist',
6
6
  name: 'my-vite-app',
7
- description: 'Compute@Edge static site from Vite',
7
+ description: 'Fastly Compute static site from Vite',
8
8
  };
9
9
  }
10
10
  check() {
@@ -4,7 +4,7 @@ export class VuePreset {
4
4
  this.defaultOptions = {
5
5
  rootDir: './dist',
6
6
  name: 'my-vue-app',
7
- description: 'Compute@Edge static site from Vue (create-vue)',
7
+ description: 'Fastly Compute static site from Vue (create-vue)',
8
8
  };
9
9
  }
10
10
  check(packageJson) {
@@ -2,6 +2,7 @@ export type AppOptions = {
2
2
  rootDir: string | undefined;
3
3
  publicDir: string | undefined;
4
4
  staticDirs: string[];
5
+ staticContentRootDir: string | undefined;
5
6
  spa: string | undefined;
6
7
  notFoundPage: string | undefined;
7
8
  autoIndex: string[];
@@ -1 +1 @@
1
- {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
1
+ {"version":3,"file":"preset-base.d.ts","sourceRoot":"","sources":["../../../src/cli/presets/preset-base.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG;IACvB,OAAO,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,oBAAoB,EAAE,MAAM,GAAG,SAAS,CAAC;IACzC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,EAAE,OAAO,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,CAAC,WAAW,EAAE,GAAG,GAAG,IAAI,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC;CAC9D"}
@@ -11,6 +11,7 @@ export type ModuleAssetInclusionResultNormalized = {
11
11
  };
12
12
  export type StaticPublisherConfigNormalized = {
13
13
  rootDir: string;
14
+ staticContentRootDir: string;
14
15
  kvStoreName: string | null;
15
16
  excludeDirs: ExcludeDirTest[];
16
17
  excludeDotFiles: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config-normalized.d.ts","sourceRoot":"","sources":["../../src/types/config-normalized.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAE3E,MAAM,MAAM,qCAAqC,GAAG;IAClD,cAAc,EAAE,OAAO,CAAC;IACxB,MAAM,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,oCAAoC,GAAG;IACjD,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;CAC1B,CAAC;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B,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,EAAE,cAAc,EAAE,CAAC;IAC9B,eAAe,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,yBAAyB,EAAE,yBAAyB,GAAG,IAAI,CAAC;IAC5D,kBAAkB,EAAE,uBAAuB,EAAE,CAAC;IAC9C,wBAAwB,EAAE,wBAAwB,GAAG,IAAI,CAAC;IAC1D,YAAY,EAAE,cAAc,EAAE,CAAC;IAC/B,MAAM,EAAE,+BAA+B,GAAG,IAAI,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,+BAA+B,GAAG;IAC5C,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,WAAW,EAAE,uBAAuB,EAAE,CAAC;IACvC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,MAAM,EAAE,CAAC;CAErB,CAAC"}
@@ -14,6 +14,7 @@ export type ModuleAssetInclusionResult = {
14
14
  export type ModuleAssetInclusionTest = (assetKey: string, contentType?: string) => ModuleAssetInclusionResult | true | false | 'static-import' | null;
15
15
  export type StaticPublisherConfig = {
16
16
  rootDir: string;
17
+ staticContentRootDir: string;
17
18
  kvStoreName?: string | false | null;
18
19
  excludeDirs?: (string | ExcludeDirTest)[] | string | ExcludeDirTest | null;
19
20
  excludeDotFiles?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAEzD,MAAM,WAAW,c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/compute-js-static-publish",
3
3
  "type": "module",
4
- "version": "5.2.0",
5
- "description": "Static Publisher for Compute@Edge JavaScript",
4
+ "version": "6.0.0-beta.0",
5
+ "description": "Static Publisher for Fastly Compute JavaScript",
6
6
  "main": "./build/index.js",
7
7
  "types": "./build/index.d.ts",
8
8
  "scripts": {
@@ -1,18 +0,0 @@
1
- /// <reference types="@fastly/js-compute" />
2
- import { getServer } from './statics.js';
3
- const staticContentServer = getServer();
4
-
5
- // eslint-disable-next-line no-restricted-globals
6
- addEventListener("fetch", (event) => event.respondWith(handleRequest(event)));
7
- async function handleRequest(event) {
8
-
9
- const response = await staticContentServer.serveRequest(event.request);
10
- if (response != null) {
11
- return response;
12
- }
13
-
14
- // Do custom things here!
15
- // Handle API requests, serve non-static responses, etc.
16
-
17
- return new Response('Not found', { status: 404 });
18
- }