@vercel/build-utils 2.14.1-canary.4 → 2.14.1-canary.5

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.
@@ -30,5 +30,5 @@ ncc: Using typescript@4.3.4 (local user-provided)
30
30
  3kB dist/main/index.d.ts
31
31
  4kB dist/main/fs/run-user-scripts.d.ts
32
32
  10kB dist/main/types.d.ts
33
- 1234kB dist/main/index.js
34
- 1265kB [7426ms] - ncc 0.24.0
33
+ 1235kB dist/main/index.js
34
+ 1266kB [6928ms] - ncc 0.24.0
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { File } from './types';
2
+ import { FileBase } from './types';
3
3
  interface FileBlobOptions {
4
4
  mode?: number;
5
5
  contentType?: string;
@@ -10,13 +10,14 @@ interface FromStreamOptions {
10
10
  contentType?: string;
11
11
  stream: NodeJS.ReadableStream;
12
12
  }
13
- export default class FileBlob implements File {
13
+ export default class FileBlob implements FileBase {
14
14
  type: 'FileBlob';
15
15
  mode: number;
16
16
  data: string | Buffer;
17
17
  contentType: string | undefined;
18
18
  constructor({ mode, contentType, data }: FileBlobOptions);
19
19
  static fromStream({ mode, contentType, stream, }: FromStreamOptions): Promise<FileBlob>;
20
+ toStreamAsync(): Promise<NodeJS.ReadableStream>;
20
21
  toStream(): NodeJS.ReadableStream;
21
22
  }
22
23
  export {};
package/dist/file-blob.js CHANGED
@@ -26,6 +26,9 @@ class FileBlob {
26
26
  const data = Buffer.concat(chunks);
27
27
  return new FileBlob({ mode, contentType, data });
28
28
  }
29
+ async toStreamAsync() {
30
+ return this.toStream();
31
+ }
29
32
  toStream() {
30
33
  return into_stream_1.default(this.data);
31
34
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { File } from './types';
2
+ import { FileBase } from './types';
3
3
  interface FileFsRefOptions {
4
4
  mode?: number;
5
5
  contentType?: string;
@@ -11,7 +11,7 @@ interface FromStreamOptions {
11
11
  stream: NodeJS.ReadableStream;
12
12
  fsPath: string;
13
13
  }
14
- declare class FileFsRef implements File {
14
+ declare class FileFsRef implements FileBase {
15
15
  type: 'FileFsRef';
16
16
  mode: number;
17
17
  fsPath: string;
@@ -1,12 +1,12 @@
1
1
  /// <reference types="node" />
2
- import { File } from './types';
2
+ import { FileBase } from './types';
3
3
  interface FileRefOptions {
4
4
  mode?: number;
5
5
  digest: string;
6
6
  contentType?: string;
7
7
  mutable?: boolean;
8
8
  }
9
- export default class FileRef implements File {
9
+ export default class FileRef implements FileBase {
10
10
  type: 'FileRef';
11
11
  mode: number;
12
12
  digest: string;
@@ -8,26 +8,38 @@ const path_1 = __importDefault(require("path"));
8
8
  const debug_1 = __importDefault(require("../debug"));
9
9
  const file_fs_ref_1 = __importDefault(require("../file-fs-ref"));
10
10
  const fs_extra_1 = require("fs-extra");
11
+ const stream_to_buffer_1 = __importDefault(require("./stream-to-buffer"));
11
12
  const S_IFMT = 61440; /* 0170000 type of file */
12
13
  const S_IFLNK = 40960; /* 0120000 symbolic link */
13
14
  function isSymbolicLink(mode) {
14
15
  return (mode & S_IFMT) === S_IFLNK;
15
16
  }
16
17
  exports.isSymbolicLink = isSymbolicLink;
18
+ async function prepareSymlinkTarget(file, fsPath) {
19
+ const mkdirPromise = fs_extra_1.mkdirp(path_1.default.dirname(fsPath));
20
+ if (file.type === 'FileFsRef') {
21
+ const [target] = await Promise.all([fs_extra_1.readlink(file.fsPath), mkdirPromise]);
22
+ return target;
23
+ }
24
+ if (file.type === 'FileRef' || file.type === 'FileBlob') {
25
+ const targetPathBufferPromise = await stream_to_buffer_1.default(await file.toStreamAsync());
26
+ const [targetPathBuffer] = await Promise.all([
27
+ targetPathBufferPromise,
28
+ mkdirPromise,
29
+ ]);
30
+ return targetPathBuffer.toString('utf8');
31
+ }
32
+ throw new Error(`file.type "${file.type}" not supported for symlink`);
33
+ }
17
34
  async function downloadFile(file, fsPath) {
18
35
  const { mode } = file;
19
- if (mode && isSymbolicLink(mode) && file.type === 'FileFsRef') {
20
- const [target] = await Promise.all([
21
- fs_extra_1.readlink(file.fsPath),
22
- fs_extra_1.mkdirp(path_1.default.dirname(fsPath)),
23
- ]);
36
+ if (isSymbolicLink(mode)) {
37
+ const target = await prepareSymlinkTarget(file, fsPath);
24
38
  await fs_extra_1.symlink(target, fsPath);
25
39
  return file_fs_ref_1.default.fromFsPath({ mode, fsPath });
26
40
  }
27
- else {
28
- const stream = file.toStream();
29
- return file_fs_ref_1.default.fromStream({ mode, stream, fsPath });
30
- }
41
+ const stream = file.toStream();
42
+ return file_fs_ref_1.default.fromStream({ mode, stream, fsPath });
31
43
  }
32
44
  async function removeFile(basePath, fileMatched) {
33
45
  const file = path_1.default.join(basePath, fileMatched);
package/dist/index.js CHANGED
@@ -26617,6 +26617,7 @@ exports.frameworks = [
26617
26617
  slug: 'nextjs',
26618
26618
  demo: 'https://nextjs-template.vercel.app',
26619
26619
  logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/next.svg',
26620
+ screenshot: 'https://assets.vercel.com/image/upload/v1647366075/front/import/nextjs.png',
26620
26621
  tagline: 'Next.js makes you productive with React instantly — whether you want to build static or dynamic sites.',
26621
26622
  description: 'A Next.js app and a Serverless Function API.',
26622
26623
  website: 'https://nextjs.org',
@@ -27613,6 +27614,7 @@ exports.frameworks = [
27613
27614
  slug: 'sveltekit',
27614
27615
  demo: 'https://sveltekit-template.vercel.app',
27615
27616
  logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/svelte.svg',
27617
+ screenshot: 'https://assets.vercel.com/image/upload/v1647366075/front/import/sveltekit.png',
27616
27618
  tagline: 'SvelteKit is a framework for building web applications of all sizes.',
27617
27619
  description: 'A SvelteKit app optimized Edge-first.',
27618
27620
  website: 'https://kit.svelte.dev',
@@ -28122,6 +28124,7 @@ exports.frameworks = [
28122
28124
  slug: 'nuxtjs',
28123
28125
  demo: 'https://nuxtjs-template.vercel.app',
28124
28126
  logo: 'https://raw.githubusercontent.com/vercel/vercel/main/packages/frameworks/logos/nuxt.svg',
28127
+ screenshot: 'https://assets.vercel.com/image/upload/v1647366075/front/import/nuxtjs.png',
28125
28128
  tagline: 'Nuxt.js is the web comprehensive framework that lets you dream big with Vue.js.',
28126
28129
  description: 'A Nuxt.js app, bootstrapped with create-nuxt-app.',
28127
28130
  website: 'https://nuxtjs.org',
@@ -34085,6 +34088,9 @@ class FileBlob {
34085
34088
  const data = Buffer.concat(chunks);
34086
34089
  return new FileBlob({ mode, contentType, data });
34087
34090
  }
34091
+ async toStreamAsync() {
34092
+ return this.toStream();
34093
+ }
34088
34094
  toStream() {
34089
34095
  return into_stream_1.default(this.data);
34090
34096
  }
@@ -34279,26 +34285,38 @@ const path_1 = __importDefault(__webpack_require__(5622));
34279
34285
  const debug_1 = __importDefault(__webpack_require__(1868));
34280
34286
  const file_fs_ref_1 = __importDefault(__webpack_require__(9331));
34281
34287
  const fs_extra_1 = __webpack_require__(5392);
34288
+ const stream_to_buffer_1 = __importDefault(__webpack_require__(2560));
34282
34289
  const S_IFMT = 61440; /* 0170000 type of file */
34283
34290
  const S_IFLNK = 40960; /* 0120000 symbolic link */
34284
34291
  function isSymbolicLink(mode) {
34285
34292
  return (mode & S_IFMT) === S_IFLNK;
34286
34293
  }
34287
34294
  exports.isSymbolicLink = isSymbolicLink;
34295
+ async function prepareSymlinkTarget(file, fsPath) {
34296
+ const mkdirPromise = fs_extra_1.mkdirp(path_1.default.dirname(fsPath));
34297
+ if (file.type === 'FileFsRef') {
34298
+ const [target] = await Promise.all([fs_extra_1.readlink(file.fsPath), mkdirPromise]);
34299
+ return target;
34300
+ }
34301
+ if (file.type === 'FileRef' || file.type === 'FileBlob') {
34302
+ const targetPathBufferPromise = await stream_to_buffer_1.default(await file.toStreamAsync());
34303
+ const [targetPathBuffer] = await Promise.all([
34304
+ targetPathBufferPromise,
34305
+ mkdirPromise,
34306
+ ]);
34307
+ return targetPathBuffer.toString('utf8');
34308
+ }
34309
+ throw new Error(`file.type "${file.type}" not supported for symlink`);
34310
+ }
34288
34311
  async function downloadFile(file, fsPath) {
34289
34312
  const { mode } = file;
34290
- if (mode && isSymbolicLink(mode) && file.type === 'FileFsRef') {
34291
- const [target] = await Promise.all([
34292
- fs_extra_1.readlink(file.fsPath),
34293
- fs_extra_1.mkdirp(path_1.default.dirname(fsPath)),
34294
- ]);
34313
+ if (isSymbolicLink(mode)) {
34314
+ const target = await prepareSymlinkTarget(file, fsPath);
34295
34315
  await fs_extra_1.symlink(target, fsPath);
34296
34316
  return file_fs_ref_1.default.fromFsPath({ mode, fsPath });
34297
34317
  }
34298
- else {
34299
- const stream = file.toStream();
34300
- return file_fs_ref_1.default.fromStream({ mode, stream, fsPath });
34301
- }
34318
+ const stream = file.toStream();
34319
+ return file_fs_ref_1.default.fromStream({ mode, stream, fsPath });
34302
34320
  }
34303
34321
  async function removeFile(basePath, fileMatched) {
34304
34322
  const file = path_1.default.join(basePath, fileMatched);
package/dist/lambda.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Files, Config } from './types';
2
+ import type { Files, Config } from './types';
3
3
  interface Environment {
4
4
  [key: string]: string;
5
5
  }
@@ -1,11 +1,9 @@
1
- import FileBlob from './file-blob';
2
- import FileFsRef from './file-fs-ref';
3
- import FileRef from './file-ref';
1
+ import { File } from './types';
4
2
  import { Lambda } from './lambda';
5
3
  interface PrerenderOptions {
6
4
  expiration: number | false;
7
5
  lambda: Lambda;
8
- fallback: FileBlob | FileFsRef | FileRef | null;
6
+ fallback: File | null;
9
7
  group?: number;
10
8
  bypassToken?: string | null;
11
9
  allowQuery?: string[];
@@ -14,7 +12,7 @@ export declare class Prerender {
14
12
  type: 'Prerender';
15
13
  expiration: number | false;
16
14
  lambda: Lambda;
17
- fallback: FileBlob | FileFsRef | FileRef | null;
15
+ fallback: File | null;
18
16
  group?: number;
19
17
  bypassToken: string | null;
20
18
  allowQuery?: string[];
package/dist/types.d.ts CHANGED
@@ -1,22 +1,20 @@
1
1
  /// <reference types="node" />
2
2
  import type FileRef from './file-ref';
3
3
  import type FileFsRef from './file-fs-ref';
4
+ import type FileBlob from './file-blob';
4
5
  import type { Lambda } from './lambda';
5
6
  import type { Prerender } from './prerender';
6
7
  import type { EdgeFunction } from './edge-function';
7
8
  export interface Env {
8
9
  [name: string]: string | undefined;
9
10
  }
10
- export interface File {
11
+ export declare type File = FileRef | FileFsRef | FileBlob;
12
+ export interface FileBase {
11
13
  type: string;
12
14
  mode: number;
13
15
  contentType?: string;
14
16
  toStream: () => NodeJS.ReadableStream;
15
17
  toStreamAsync?: () => Promise<NodeJS.ReadableStream>;
16
- /**
17
- * The absolute path to the file in the filesystem
18
- */
19
- fsPath?: string;
20
18
  }
21
19
  export interface Files {
22
20
  [filePath: string]: File;
@@ -344,7 +342,7 @@ export interface BuildResultV2 {
344
342
  routes?: any[];
345
343
  images?: Images;
346
344
  output: {
347
- [key: string]: File | Lambda | Prerender | EdgeFunction;
345
+ [key: string]: FileBase | Lambda | Prerender | EdgeFunction;
348
346
  };
349
347
  wildcard?: Array<{
350
348
  domain: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.14.1-canary.4",
3
+ "version": "2.14.1-canary.5",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -30,7 +30,7 @@
30
30
  "@types/node-fetch": "^2.1.6",
31
31
  "@types/semver": "6.0.0",
32
32
  "@types/yazl": "^2.4.1",
33
- "@vercel/frameworks": "0.6.1-canary.3",
33
+ "@vercel/frameworks": "0.6.1-canary.4",
34
34
  "@vercel/ncc": "0.24.0",
35
35
  "aggregate-error": "3.0.1",
36
36
  "async-retry": "1.2.3",
@@ -49,5 +49,5 @@
49
49
  "typescript": "4.3.4",
50
50
  "yazl": "2.4.3"
51
51
  },
52
- "gitHead": "a24fd64bce88d5025c52ac7dfbdc3c0f457de077"
52
+ "gitHead": "b3ccb5f3ef354da577eeff6ce63d8ee51cfb3e17"
53
53
  }