@vercel/build-utils 2.17.0 → 3.0.2-canary.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.
@@ -1,4 +1,9 @@
1
1
  /// <reference types="node" />
2
+ export interface Stat {
3
+ name: string;
4
+ path: string;
5
+ type: 'file' | 'dir';
6
+ }
2
7
  /**
3
8
  * `DetectorFilesystem` is an abstract class that represents a virtual filesystem
4
9
  * to perform read-only operations on in order to detect which framework is being
@@ -28,11 +33,22 @@ export declare abstract class DetectorFilesystem {
28
33
  protected abstract _hasPath(name: string): Promise<boolean>;
29
34
  protected abstract _readFile(name: string): Promise<Buffer>;
30
35
  protected abstract _isFile(name: string): Promise<boolean>;
36
+ protected abstract _readdir(name: string): Promise<Stat[]>;
37
+ protected abstract _chdir(name: string): DetectorFilesystem;
31
38
  private pathCache;
32
39
  private fileCache;
33
40
  private readFileCache;
41
+ private readdirCache;
34
42
  constructor();
35
43
  hasPath: (path: string) => Promise<boolean>;
36
44
  isFile: (name: string) => Promise<boolean>;
37
45
  readFile: (name: string) => Promise<Buffer>;
46
+ /**
47
+ * Returns a list of Stat objects from the current working directory.
48
+ */
49
+ readdir: (name: string) => Promise<Stat[]>;
50
+ /**
51
+ * Changes the current directory to the specified path and returns a new instance of DetectorFilesystem.
52
+ */
53
+ chdir: (name: string) => DetectorFilesystem;
38
54
  }
@@ -52,9 +52,27 @@ class DetectorFilesystem {
52
52
  }
53
53
  return p;
54
54
  };
55
+ /**
56
+ * Returns a list of Stat objects from the current working directory.
57
+ */
58
+ this.readdir = async (name) => {
59
+ let p = this.readdirCache.get(name);
60
+ if (!p) {
61
+ p = this._readdir(name);
62
+ this.readdirCache.set(name, p);
63
+ }
64
+ return p;
65
+ };
66
+ /**
67
+ * Changes the current directory to the specified path and returns a new instance of DetectorFilesystem.
68
+ */
69
+ this.chdir = (name) => {
70
+ return this._chdir(name);
71
+ };
55
72
  this.pathCache = new Map();
56
73
  this.fileCache = new Map();
57
74
  this.readFileCache = new Map();
75
+ this.readdirCache = new Map();
58
76
  }
59
77
  }
60
78
  exports.DetectorFilesystem = DetectorFilesystem;
@@ -10,7 +10,12 @@ const debug_1 = __importDefault(require("../debug"));
10
10
  const allOptions = [
11
11
  { major: 16, range: '16.x', runtime: 'nodejs16.x' },
12
12
  { major: 14, range: '14.x', runtime: 'nodejs14.x' },
13
- { major: 12, range: '12.x', runtime: 'nodejs12.x' },
13
+ {
14
+ major: 12,
15
+ range: '12.x',
16
+ runtime: 'nodejs12.x',
17
+ discontinueDate: new Date('2022-08-09'),
18
+ },
14
19
  {
15
20
  major: 10,
16
21
  range: '10.x',
@@ -309,11 +309,9 @@ function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }
309
309
  }
310
310
  }
311
311
  else if (cliType === 'pnpm') {
312
- if (typeof lockfileVersion === 'number' &&
313
- lockfileVersion === 5.4 &&
314
- ((nodeVersion === null || nodeVersion === void 0 ? void 0 : nodeVersion.major) || 0) > 12) {
312
+ if (typeof lockfileVersion === 'number' && lockfileVersion === 5.4) {
315
313
  // Ensure that pnpm 7 is at the beginning of the `$PATH`
316
- newEnv.PATH = `/pnpm7/pnpm:${env.PATH}`;
314
+ newEnv.PATH = `/pnpm7/node_modules/.bin:${env.PATH}`;
317
315
  console.log('Detected `pnpm-lock.yaml` generated by pnpm 7...');
318
316
  }
319
317
  }
package/dist/index.js CHANGED
@@ -34239,9 +34239,27 @@ class DetectorFilesystem {
34239
34239
  }
34240
34240
  return p;
34241
34241
  };
34242
+ /**
34243
+ * Returns a list of Stat objects from the current working directory.
34244
+ */
34245
+ this.readdir = async (name) => {
34246
+ let p = this.readdirCache.get(name);
34247
+ if (!p) {
34248
+ p = this._readdir(name);
34249
+ this.readdirCache.set(name, p);
34250
+ }
34251
+ return p;
34252
+ };
34253
+ /**
34254
+ * Changes the current directory to the specified path and returns a new instance of DetectorFilesystem.
34255
+ */
34256
+ this.chdir = (name) => {
34257
+ return this._chdir(name);
34258
+ };
34242
34259
  this.pathCache = new Map();
34243
34260
  this.fileCache = new Map();
34244
34261
  this.readFileCache = new Map();
34262
+ this.readdirCache = new Map();
34245
34263
  }
34246
34264
  }
34247
34265
  exports.DetectorFilesystem = DetectorFilesystem;
@@ -34765,7 +34783,12 @@ const debug_1 = __importDefault(__webpack_require__(1868));
34765
34783
  const allOptions = [
34766
34784
  { major: 16, range: '16.x', runtime: 'nodejs16.x' },
34767
34785
  { major: 14, range: '14.x', runtime: 'nodejs14.x' },
34768
- { major: 12, range: '12.x', runtime: 'nodejs12.x' },
34786
+ {
34787
+ major: 12,
34788
+ range: '12.x',
34789
+ runtime: 'nodejs12.x',
34790
+ discontinueDate: new Date('2022-08-09'),
34791
+ },
34769
34792
  {
34770
34793
  major: 10,
34771
34794
  range: '10.x',
@@ -35236,11 +35259,9 @@ function getEnvForPackageManager({ cliType, lockfileVersion, nodeVersion, env, }
35236
35259
  }
35237
35260
  }
35238
35261
  else if (cliType === 'pnpm') {
35239
- if (typeof lockfileVersion === 'number' &&
35240
- lockfileVersion === 5.4 &&
35241
- ((nodeVersion === null || nodeVersion === void 0 ? void 0 : nodeVersion.major) || 0) > 12) {
35262
+ if (typeof lockfileVersion === 'number' && lockfileVersion === 5.4) {
35242
35263
  // Ensure that pnpm 7 is at the beginning of the `$PATH`
35243
- newEnv.PATH = `/pnpm7/pnpm:${env.PATH}`;
35264
+ newEnv.PATH = `/pnpm7/node_modules/.bin:${env.PATH}`;
35244
35265
  console.log('Detected `pnpm-lock.yaml` generated by pnpm 7...');
35245
35266
  }
35246
35267
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/build-utils",
3
- "version": "2.17.0",
3
+ "version": "3.0.2-canary.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.js",
@@ -12,8 +12,9 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "node build",
15
- "test-unit": "jest --env node --verbose --runInBand --bail test/unit.*test.*",
16
- "test-integration-once": "jest --env node --verbose --runInBand --bail test/integration.test.ts",
15
+ "test": "jest --env node --verbose --runInBand --bail",
16
+ "test-unit": "yarn test test/unit.*test.*",
17
+ "test-integration-once": "yarn test test/integration.test.ts",
17
18
  "prepublishOnly": "node build"
18
19
  },
19
20
  "devDependencies": {
@@ -30,7 +31,7 @@
30
31
  "@types/node-fetch": "^2.1.6",
31
32
  "@types/semver": "6.0.0",
32
33
  "@types/yazl": "2.4.2",
33
- "@vercel/frameworks": "0.9.0",
34
+ "@vercel/frameworks": "0.9.1-canary.0",
34
35
  "@vercel/ncc": "0.24.0",
35
36
  "aggregate-error": "3.0.1",
36
37
  "async-retry": "1.2.3",
@@ -49,5 +50,5 @@
49
50
  "typescript": "4.3.4",
50
51
  "yazl": "2.5.1"
51
52
  },
52
- "gitHead": "15c7ad241a44d037ceed0101b89e3a73f09fab2b"
53
+ "gitHead": "f26858b735ad5d54e01afa67133b9f9456fbe72f"
53
54
  }