@vercel/static-build 1.0.37 → 1.0.39

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/dist/index.js CHANGED
@@ -187104,6 +187104,132 @@ module.exports = function(num) {
187104
187104
  };
187105
187105
 
187106
187106
 
187107
+ /***/ }),
187108
+
187109
+ /***/ 3255:
187110
+ /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
187111
+
187112
+ "use strict";
187113
+
187114
+
187115
+ var childProcess = __webpack_require__(3129);
187116
+ var spawn = childProcess.spawn;
187117
+ var exec = childProcess.exec;
187118
+
187119
+ module.exports = function (pid, signal, callback) {
187120
+ if (typeof signal === 'function' && callback === undefined) {
187121
+ callback = signal;
187122
+ signal = undefined;
187123
+ }
187124
+
187125
+ pid = parseInt(pid);
187126
+ if (Number.isNaN(pid)) {
187127
+ if (callback) {
187128
+ return callback(new Error("pid must be a number"));
187129
+ } else {
187130
+ throw new Error("pid must be a number");
187131
+ }
187132
+ }
187133
+
187134
+ var tree = {};
187135
+ var pidsToProcess = {};
187136
+ tree[pid] = [];
187137
+ pidsToProcess[pid] = 1;
187138
+
187139
+ switch (process.platform) {
187140
+ case 'win32':
187141
+ exec('taskkill /pid ' + pid + ' /T /F', callback);
187142
+ break;
187143
+ case 'darwin':
187144
+ buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {
187145
+ return spawn('pgrep', ['-P', parentPid]);
187146
+ }, function () {
187147
+ killAll(tree, signal, callback);
187148
+ });
187149
+ break;
187150
+ // case 'sunos':
187151
+ // buildProcessTreeSunOS(pid, tree, pidsToProcess, function () {
187152
+ // killAll(tree, signal, callback);
187153
+ // });
187154
+ // break;
187155
+ default: // Linux
187156
+ buildProcessTree(pid, tree, pidsToProcess, function (parentPid) {
187157
+ return spawn('ps', ['-o', 'pid', '--no-headers', '--ppid', parentPid]);
187158
+ }, function () {
187159
+ killAll(tree, signal, callback);
187160
+ });
187161
+ break;
187162
+ }
187163
+ };
187164
+
187165
+ function killAll (tree, signal, callback) {
187166
+ var killed = {};
187167
+ try {
187168
+ Object.keys(tree).forEach(function (pid) {
187169
+ tree[pid].forEach(function (pidpid) {
187170
+ if (!killed[pidpid]) {
187171
+ killPid(pidpid, signal);
187172
+ killed[pidpid] = 1;
187173
+ }
187174
+ });
187175
+ if (!killed[pid]) {
187176
+ killPid(pid, signal);
187177
+ killed[pid] = 1;
187178
+ }
187179
+ });
187180
+ } catch (err) {
187181
+ if (callback) {
187182
+ return callback(err);
187183
+ } else {
187184
+ throw err;
187185
+ }
187186
+ }
187187
+ if (callback) {
187188
+ return callback();
187189
+ }
187190
+ }
187191
+
187192
+ function killPid(pid, signal) {
187193
+ try {
187194
+ process.kill(parseInt(pid, 10), signal);
187195
+ }
187196
+ catch (err) {
187197
+ if (err.code !== 'ESRCH') throw err;
187198
+ }
187199
+ }
187200
+
187201
+ function buildProcessTree (parentPid, tree, pidsToProcess, spawnChildProcessesList, cb) {
187202
+ var ps = spawnChildProcessesList(parentPid);
187203
+ var allData = '';
187204
+ ps.stdout.on('data', function (data) {
187205
+ var data = data.toString('ascii');
187206
+ allData += data;
187207
+ });
187208
+
187209
+ var onClose = function (code) {
187210
+ delete pidsToProcess[parentPid];
187211
+
187212
+ if (code != 0) {
187213
+ // no more parent processes
187214
+ if (Object.keys(pidsToProcess).length == 0) {
187215
+ cb();
187216
+ }
187217
+ return;
187218
+ }
187219
+
187220
+ allData.match(/\d+/g).forEach(function (pid) {
187221
+ pid = parseInt(pid, 10);
187222
+ tree[parentPid].push(pid);
187223
+ tree[pid] = [];
187224
+ pidsToProcess[pid] = 1;
187225
+ buildProcessTree(pid, tree, pidsToProcess, spawnChildProcessesList, cb);
187226
+ });
187227
+ };
187228
+
187229
+ ps.on('close', onClose);
187230
+ }
187231
+
187232
+
187107
187233
  /***/ }),
187108
187234
 
187109
187235
  /***/ 4490:
@@ -224025,6 +224151,7 @@ const BuildOutputV2 = __importStar(__webpack_require__(5154));
224025
224151
  const BuildOutputV3 = __importStar(__webpack_require__(8939));
224026
224152
  const GatsbyUtils = __importStar(__webpack_require__(8573));
224027
224153
  const NuxtUtils = __importStar(__webpack_require__(431));
224154
+ const tree_kill_1 = __importDefault(__webpack_require__(3255));
224028
224155
  const sleep = (n) => new Promise(resolve => setTimeout(resolve, n));
224029
224156
  const DEV_SERVER_PORT_BIND_TIMEOUT = ms_1.default('5m');
224030
224157
  async function checkForPort(port, timeout) {
@@ -224117,10 +224244,10 @@ exports.version = 2;
224117
224244
  const nowDevScriptPorts = new Map();
224118
224245
  const nowDevChildProcesses = new Set();
224119
224246
  ['SIGINT', 'SIGTERM'].forEach(signal => {
224120
- process.once(signal, () => {
224247
+ process.once(signal, async () => {
224121
224248
  for (const child of nowDevChildProcesses) {
224122
224249
  build_utils_1.debug(`Got ${signal}, killing dev server child process (pid=${child.pid})`);
224123
- process.kill(child.pid, signal);
224250
+ await new Promise(resolve => tree_kill_1.default(child.pid, signal, resolve));
224124
224251
  }
224125
224252
  process.exit(0);
224126
224253
  });
@@ -224418,7 +224545,7 @@ const build = async ({ files, entrypoint, workPath, config, meta = {}, }) => {
224418
224545
  };
224419
224546
  const cmd = devCommand || `yarn run ${devScript}`;
224420
224547
  const child = build_utils_1.spawnCommand(cmd, opts);
224421
- child.on('exit', () => nowDevScriptPorts.delete(entrypoint));
224548
+ child.on('close', () => nowDevScriptPorts.delete(entrypoint));
224422
224549
  nowDevChildProcesses.add(child);
224423
224550
  // Wait for the server to have listened on `$PORT`, after which we
224424
224551
  // will ProxyPass any requests to that development server that come in
@@ -225074,7 +225201,7 @@ exports.injectVercelAnalyticsPlugin = void 0;
225074
225201
  const fs_1 = __webpack_require__(5747);
225075
225202
  const path = __importStar(__webpack_require__(5622));
225076
225203
  const _shared_1 = __webpack_require__(2229);
225077
- const defaultConfig = {
225204
+ const DEFAULT_CONFIG = {
225078
225205
  plugins: [
225079
225206
  {
225080
225207
  resolve: 'gatsby-plugin-vercel',
@@ -225082,26 +225209,77 @@ const defaultConfig = {
225082
225209
  },
225083
225210
  ],
225084
225211
  };
225212
+ const GATSBY_PLUGIN_PACKAGE_NAME = 'gatsby-plugin-vercel';
225213
+ const GATSBY_CONFIG_FILE = 'gatsby-config';
225085
225214
  async function injectVercelAnalyticsPlugin(dir) {
225086
225215
  // Gatsby requires a special variable name for environment variables to be
225087
225216
  // exposed to the client-side JavaScript bundles:
225088
225217
  process.env.GATSBY_VERCEL_ANALYTICS_ID = process.env.VERCEL_ANALYTICS_ID;
225089
- const gatsbyConfigName = 'gatsby-config.js';
225090
- const gatsbyPluginPackageName = 'gatsby-plugin-vercel';
225091
- const gatsbyConfigPath = path.join(dir, gatsbyConfigName);
225092
- console.log(`Injecting Gatsby.js analytics plugin "${gatsbyPluginPackageName}" to \`${gatsbyConfigPath}\``);
225218
+ const gatsbyConfigPathJs = path.join(dir, `${GATSBY_CONFIG_FILE}.js`);
225219
+ const gatsbyConfigPathTs = path.join(dir, `${GATSBY_CONFIG_FILE}.ts`);
225220
+ if (await _shared_1.fileExists(gatsbyConfigPathTs)) {
225221
+ console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathTs}\``);
225222
+ await addGatsbyPackage(dir);
225223
+ return updateGatsbyTsConfig(gatsbyConfigPathTs);
225224
+ }
225225
+ console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathJs}\``);
225226
+ await addGatsbyPackage(dir);
225227
+ if (await _shared_1.fileExists(gatsbyConfigPathJs)) {
225228
+ await updateGatsbyJsConfig(gatsbyConfigPathJs);
225229
+ }
225230
+ else {
225231
+ await fs_1.promises.writeFile(gatsbyConfigPathJs, `module.exports = ${JSON.stringify(DEFAULT_CONFIG)}`);
225232
+ }
225233
+ }
225234
+ exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
225235
+ async function addGatsbyPackage(dir) {
225093
225236
  const pkgJson = (await _shared_1.readPackageJson(dir));
225094
225237
  if (!pkgJson.dependencies) {
225095
225238
  pkgJson.dependencies = {};
225096
225239
  }
225097
- if (!pkgJson.dependencies[gatsbyPluginPackageName]) {
225098
- console.log(`Adding "${gatsbyPluginPackageName}" to \`package.json\` "dependencies"`);
225099
- pkgJson.dependencies[gatsbyPluginPackageName] = 'latest';
225240
+ if (!pkgJson.dependencies[GATSBY_PLUGIN_PACKAGE_NAME]) {
225241
+ console.log(`Adding "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`package.json\` "dependencies"`);
225242
+ pkgJson.dependencies[GATSBY_PLUGIN_PACKAGE_NAME] = 'latest';
225100
225243
  await _shared_1.writePackageJson(dir, pkgJson);
225101
225244
  }
225102
- if (await _shared_1.fileExists(gatsbyConfigPath)) {
225103
- await fs_1.promises.rename(gatsbyConfigPath, gatsbyConfigPath + '.__vercel_builder_backup__.js');
225104
- await fs_1.promises.writeFile(gatsbyConfigPath, `const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
225245
+ }
225246
+ async function updateGatsbyTsConfig(configPath) {
225247
+ await fs_1.promises.rename(configPath, configPath + '.__vercel_builder_backup__.ts');
225248
+ await fs_1.promises.writeFile(configPath, `import userConfig from "./gatsby-config.ts.__vercel_builder_backup__.ts";
225249
+ import type { PluginRef } from "gatsby";
225250
+
225251
+ // https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
225252
+ const preferDefault = (m: any) => (m && m.default) || m;
225253
+
225254
+ const vercelConfig = Object.assign(
225255
+ {},
225256
+
225257
+ // https://github.com/gatsbyjs/gatsby/blob/a6ecfb2b01d761e8a3612b8ea132c698659923d9/packages/gatsby/src/services/initialize.ts#L113-L117
225258
+ preferDefault(userConfig)
225259
+ );
225260
+ if (!vercelConfig.plugins) {
225261
+ vercelConfig.plugins = [];
225262
+ }
225263
+
225264
+ const hasPlugin = vercelConfig.plugins.find(
225265
+ (p: PluginRef) =>
225266
+ p && (p === "gatsby-plugin-vercel" || p.resolve === "gatsby-plugin-vercel")
225267
+ );
225268
+
225269
+ if (!hasPlugin) {
225270
+ vercelConfig.plugins = vercelConfig.plugins.slice();
225271
+ vercelConfig.plugins.push({
225272
+ resolve: "gatsby-plugin-vercel",
225273
+ options: {},
225274
+ });
225275
+ }
225276
+
225277
+ export default vercelConfig;
225278
+ `);
225279
+ }
225280
+ async function updateGatsbyJsConfig(configPath) {
225281
+ await fs_1.promises.rename(configPath, configPath + '.__vercel_builder_backup__.js');
225282
+ await fs_1.promises.writeFile(configPath, `const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
225105
225283
 
225106
225284
  // https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
225107
225285
  const preferDefault = m => (m && m.default) || m;
@@ -225130,12 +225308,7 @@ if (!hasPlugin) {
225130
225308
 
225131
225309
  module.exports = vercelConfig;
225132
225310
  `);
225133
- }
225134
- else {
225135
- await fs_1.promises.writeFile(gatsbyConfigPath, `module.exports = ${JSON.stringify(defaultConfig)}`);
225136
- }
225137
225311
  }
225138
- exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
225139
225312
 
225140
225313
 
225141
225314
  /***/ }),
@@ -225150,7 +225323,7 @@ exports.injectVercelAnalyticsPlugin = void 0;
225150
225323
  const path_1 = __webpack_require__(5622);
225151
225324
  const rc9_1 = __webpack_require__(6649);
225152
225325
  const _shared_1 = __webpack_require__(2229);
225153
- // https://github.com/nuxt-community/web-vitals-module
225326
+ // https://github.com/nuxt-modules/web-vitals
225154
225327
  const ANALYTICS_PLUGIN_PACKAGE = '@nuxtjs/web-vitals';
225155
225328
  async function injectVercelAnalyticsPlugin(dir) {
225156
225329
  // First update the `.nuxtrc` file to inject the analytics plugin.
@@ -225299,6 +225472,14 @@ module.exports = require("buffer");
225299
225472
 
225300
225473
  /***/ }),
225301
225474
 
225475
+ /***/ 3129:
225476
+ /***/ ((module) => {
225477
+
225478
+ "use strict";
225479
+ module.exports = require("child_process");
225480
+
225481
+ /***/ }),
225482
+
225302
225483
  /***/ 7619:
225303
225484
  /***/ ((module) => {
225304
225485
 
@@ -23,7 +23,7 @@ exports.injectVercelAnalyticsPlugin = void 0;
23
23
  const fs_1 = require("fs");
24
24
  const path = __importStar(require("path"));
25
25
  const _shared_1 = require("./_shared");
26
- const defaultConfig = {
26
+ const DEFAULT_CONFIG = {
27
27
  plugins: [
28
28
  {
29
29
  resolve: 'gatsby-plugin-vercel',
@@ -31,26 +31,77 @@ const defaultConfig = {
31
31
  },
32
32
  ],
33
33
  };
34
+ const GATSBY_PLUGIN_PACKAGE_NAME = 'gatsby-plugin-vercel';
35
+ const GATSBY_CONFIG_FILE = 'gatsby-config';
34
36
  async function injectVercelAnalyticsPlugin(dir) {
35
37
  // Gatsby requires a special variable name for environment variables to be
36
38
  // exposed to the client-side JavaScript bundles:
37
39
  process.env.GATSBY_VERCEL_ANALYTICS_ID = process.env.VERCEL_ANALYTICS_ID;
38
- const gatsbyConfigName = 'gatsby-config.js';
39
- const gatsbyPluginPackageName = 'gatsby-plugin-vercel';
40
- const gatsbyConfigPath = path.join(dir, gatsbyConfigName);
41
- console.log(`Injecting Gatsby.js analytics plugin "${gatsbyPluginPackageName}" to \`${gatsbyConfigPath}\``);
40
+ const gatsbyConfigPathJs = path.join(dir, `${GATSBY_CONFIG_FILE}.js`);
41
+ const gatsbyConfigPathTs = path.join(dir, `${GATSBY_CONFIG_FILE}.ts`);
42
+ if (await _shared_1.fileExists(gatsbyConfigPathTs)) {
43
+ console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathTs}\``);
44
+ await addGatsbyPackage(dir);
45
+ return updateGatsbyTsConfig(gatsbyConfigPathTs);
46
+ }
47
+ console.log(`Injecting Gatsby.js analytics plugin "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`${gatsbyConfigPathJs}\``);
48
+ await addGatsbyPackage(dir);
49
+ if (await _shared_1.fileExists(gatsbyConfigPathJs)) {
50
+ await updateGatsbyJsConfig(gatsbyConfigPathJs);
51
+ }
52
+ else {
53
+ await fs_1.promises.writeFile(gatsbyConfigPathJs, `module.exports = ${JSON.stringify(DEFAULT_CONFIG)}`);
54
+ }
55
+ }
56
+ exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
57
+ async function addGatsbyPackage(dir) {
42
58
  const pkgJson = (await _shared_1.readPackageJson(dir));
43
59
  if (!pkgJson.dependencies) {
44
60
  pkgJson.dependencies = {};
45
61
  }
46
- if (!pkgJson.dependencies[gatsbyPluginPackageName]) {
47
- console.log(`Adding "${gatsbyPluginPackageName}" to \`package.json\` "dependencies"`);
48
- pkgJson.dependencies[gatsbyPluginPackageName] = 'latest';
62
+ if (!pkgJson.dependencies[GATSBY_PLUGIN_PACKAGE_NAME]) {
63
+ console.log(`Adding "${GATSBY_PLUGIN_PACKAGE_NAME}" to \`package.json\` "dependencies"`);
64
+ pkgJson.dependencies[GATSBY_PLUGIN_PACKAGE_NAME] = 'latest';
49
65
  await _shared_1.writePackageJson(dir, pkgJson);
50
66
  }
51
- if (await _shared_1.fileExists(gatsbyConfigPath)) {
52
- await fs_1.promises.rename(gatsbyConfigPath, gatsbyConfigPath + '.__vercel_builder_backup__.js');
53
- await fs_1.promises.writeFile(gatsbyConfigPath, `const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
67
+ }
68
+ async function updateGatsbyTsConfig(configPath) {
69
+ await fs_1.promises.rename(configPath, configPath + '.__vercel_builder_backup__.ts');
70
+ await fs_1.promises.writeFile(configPath, `import userConfig from "./gatsby-config.ts.__vercel_builder_backup__.ts";
71
+ import type { PluginRef } from "gatsby";
72
+
73
+ // https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
74
+ const preferDefault = (m: any) => (m && m.default) || m;
75
+
76
+ const vercelConfig = Object.assign(
77
+ {},
78
+
79
+ // https://github.com/gatsbyjs/gatsby/blob/a6ecfb2b01d761e8a3612b8ea132c698659923d9/packages/gatsby/src/services/initialize.ts#L113-L117
80
+ preferDefault(userConfig)
81
+ );
82
+ if (!vercelConfig.plugins) {
83
+ vercelConfig.plugins = [];
84
+ }
85
+
86
+ const hasPlugin = vercelConfig.plugins.find(
87
+ (p: PluginRef) =>
88
+ p && (p === "gatsby-plugin-vercel" || p.resolve === "gatsby-plugin-vercel")
89
+ );
90
+
91
+ if (!hasPlugin) {
92
+ vercelConfig.plugins = vercelConfig.plugins.slice();
93
+ vercelConfig.plugins.push({
94
+ resolve: "gatsby-plugin-vercel",
95
+ options: {},
96
+ });
97
+ }
98
+
99
+ export default vercelConfig;
100
+ `);
101
+ }
102
+ async function updateGatsbyJsConfig(configPath) {
103
+ await fs_1.promises.rename(configPath, configPath + '.__vercel_builder_backup__.js');
104
+ await fs_1.promises.writeFile(configPath, `const userConfig = require("./gatsby-config.js.__vercel_builder_backup__.js");
54
105
 
55
106
  // https://github.com/gatsbyjs/gatsby/blob/354003fb2908e02ff12109ca3a02978a5a6e608c/packages/gatsby/src/bootstrap/prefer-default.ts
56
107
  const preferDefault = m => (m && m.default) || m;
@@ -79,9 +130,4 @@ if (!hasPlugin) {
79
130
 
80
131
  module.exports = vercelConfig;
81
132
  `);
82
- }
83
- else {
84
- await fs_1.promises.writeFile(gatsbyConfigPath, `module.exports = ${JSON.stringify(defaultConfig)}`);
85
- }
86
133
  }
87
- exports.injectVercelAnalyticsPlugin = injectVercelAnalyticsPlugin;
@@ -4,7 +4,7 @@ exports.injectVercelAnalyticsPlugin = void 0;
4
4
  const path_1 = require("path");
5
5
  const rc9_1 = require("rc9");
6
6
  const _shared_1 = require("./_shared");
7
- // https://github.com/nuxt-community/web-vitals-module
7
+ // https://github.com/nuxt-modules/web-vitals
8
8
  const ANALYTICS_PLUGIN_PACKAGE = '@nuxtjs/web-vitals';
9
9
  async function injectVercelAnalyticsPlugin(dir) {
10
10
  // First update the `.nuxtrc` file to inject the analytics plugin.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vercel/static-build",
3
- "version": "1.0.37",
3
+ "version": "1.0.39",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index",
6
6
  "homepage": "https://vercel.com/docs/build-step",
@@ -36,7 +36,7 @@
36
36
  "@types/ms": "0.7.31",
37
37
  "@types/node-fetch": "2.5.4",
38
38
  "@types/promise-timeout": "1.3.0",
39
- "@vercel/build-utils": "5.5.8",
39
+ "@vercel/build-utils": "5.5.9",
40
40
  "@vercel/frameworks": "1.1.12",
41
41
  "@vercel/ncc": "0.24.0",
42
42
  "@vercel/routing-utils": "2.1.3",
@@ -47,7 +47,8 @@
47
47
  "ms": "2.1.2",
48
48
  "node-fetch": "2.6.7",
49
49
  "rc9": "1.2.0",
50
+ "tree-kill": "1.2.2",
50
51
  "typescript": "4.3.4"
51
52
  },
52
- "gitHead": "74593e4d813cb3f9ae5bb44878461355c3a86849"
53
+ "gitHead": "7003531d5db7895fc3b2fa940c2d83b6e75bbd9e"
53
54
  }