@depup/vercel 50.32.5-depup.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.
Files changed (96) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +38 -0
  3. package/changes.json +38 -0
  4. package/dist/chunks/chunk-2DLBVZWU.js +197 -0
  5. package/dist/chunks/chunk-2HSQ7YUK.js +93 -0
  6. package/dist/chunks/chunk-2IQTNMUG.js +86 -0
  7. package/dist/chunks/chunk-3FRG2XGZ.js +466 -0
  8. package/dist/chunks/chunk-3KMKI2FP.js +34 -0
  9. package/dist/chunks/chunk-3XFFP2BA.js +110 -0
  10. package/dist/chunks/chunk-4S3Y3ATR.js +5383 -0
  11. package/dist/chunks/chunk-7EHTK7LP.js +359 -0
  12. package/dist/chunks/chunk-7YHZDJ4G.js +116 -0
  13. package/dist/chunks/chunk-A3NYPUKZ.js +17 -0
  14. package/dist/chunks/chunk-AA7QEJFB.js +5204 -0
  15. package/dist/chunks/chunk-AHU7WNL2.js +24 -0
  16. package/dist/chunks/chunk-AKQZ7KG3.js +4172 -0
  17. package/dist/chunks/chunk-AQLVWVEN.js +39155 -0
  18. package/dist/chunks/chunk-BQ3DXZNT.js +968 -0
  19. package/dist/chunks/chunk-E65JE2CC.js +102 -0
  20. package/dist/chunks/chunk-EKPSCRJZ.js +26 -0
  21. package/dist/chunks/chunk-EOZFDJSY.js +18 -0
  22. package/dist/chunks/chunk-FDJURQMQ.js +4676 -0
  23. package/dist/chunks/chunk-FLKHKWZV.js +1854 -0
  24. package/dist/chunks/chunk-G6BUEBF5.js +192 -0
  25. package/dist/chunks/chunk-GBNIO3KP.js +771 -0
  26. package/dist/chunks/chunk-GGP5R3FU.js +129 -0
  27. package/dist/chunks/chunk-H5XJSH37.js +91 -0
  28. package/dist/chunks/chunk-IB5L4LKZ.js +1082 -0
  29. package/dist/chunks/chunk-IE7MNZ56.js +149 -0
  30. package/dist/chunks/chunk-IK7DLK2T.js +16112 -0
  31. package/dist/chunks/chunk-IUGPWINM.js +104 -0
  32. package/dist/chunks/chunk-J7HDA5GH.js +54 -0
  33. package/dist/chunks/chunk-JLYZNGYY.js +293 -0
  34. package/dist/chunks/chunk-JQ4NA5MX.js +250 -0
  35. package/dist/chunks/chunk-LL26LVRR.js +81 -0
  36. package/dist/chunks/chunk-LW5ZNGW7.js +127 -0
  37. package/dist/chunks/chunk-LWBSOTJP.js +1772 -0
  38. package/dist/chunks/chunk-MBGJBHYD.js +388 -0
  39. package/dist/chunks/chunk-NUKAG3YM.js +168 -0
  40. package/dist/chunks/chunk-O7I4ZOCC.js +58 -0
  41. package/dist/chunks/chunk-OWR3XNE3.js +48 -0
  42. package/dist/chunks/chunk-P3SKP5WM.js +27 -0
  43. package/dist/chunks/chunk-P4I4DMEU.js +342 -0
  44. package/dist/chunks/chunk-P5Q6F5IA.js +107 -0
  45. package/dist/chunks/chunk-PMSMUMUO.js +30 -0
  46. package/dist/chunks/chunk-QXRJ52T4.js +2977 -0
  47. package/dist/chunks/chunk-RQXPRFRM.js +90 -0
  48. package/dist/chunks/chunk-S7KYDPEM.js +1564 -0
  49. package/dist/chunks/chunk-SGGLJFUZ.js +68 -0
  50. package/dist/chunks/chunk-SOTR4CXR.js +34 -0
  51. package/dist/chunks/chunk-TEVP63TU.js +1717 -0
  52. package/dist/chunks/chunk-TNBMKNET.js +323 -0
  53. package/dist/chunks/chunk-TZ2YI2VH.js +87 -0
  54. package/dist/chunks/chunk-U6XOC6E4.js +903 -0
  55. package/dist/chunks/chunk-V5P25P7F.js +22 -0
  56. package/dist/chunks/chunk-WQ5CUZWR.js +333 -0
  57. package/dist/chunks/chunk-WU2BPWRP.js +12237 -0
  58. package/dist/chunks/chunk-XPKWKPWA.js +44 -0
  59. package/dist/chunks/chunk-XR53KVJD.js +33 -0
  60. package/dist/chunks/chunk-Y4JJYHUG.js +16 -0
  61. package/dist/chunks/chunk-YPQSDAEW.js +29 -0
  62. package/dist/chunks/chunk-ZB2UO4V2.js +135 -0
  63. package/dist/chunks/chunk-ZLCMHY2G.js +1528 -0
  64. package/dist/chunks/compile-vercel-config-XU3YY2CZ.js +32 -0
  65. package/dist/chunks/delete-EJ2V7KQO.js +144 -0
  66. package/dist/chunks/disable-BKRFMX4U.js +122 -0
  67. package/dist/chunks/discard-4WF34DXK.js +118 -0
  68. package/dist/chunks/edit-FQE7JGU3.js +509 -0
  69. package/dist/chunks/emit-flags-datafiles-QYKPNWPX.js +17 -0
  70. package/dist/chunks/enable-VCNMX63U.js +122 -0
  71. package/dist/chunks/export-3KNVJCQR.js +133 -0
  72. package/dist/chunks/list-43XQCGKH.js +382 -0
  73. package/dist/chunks/list-DUL6PHUR.js +394 -0
  74. package/dist/chunks/publish-CF7GVZK3.js +128 -0
  75. package/dist/chunks/query-KWKO7VWO.js +954 -0
  76. package/dist/chunks/reorder-GU65YMIN.js +259 -0
  77. package/dist/chunks/restore-Q7ENGWVJ.js +158 -0
  78. package/dist/chunks/routes-Q5CWG44T.js +20 -0
  79. package/dist/chunks/schema-PJKLO2K2.js +176 -0
  80. package/dist/chunks/stamp-RTPE2EBB.js +15 -0
  81. package/dist/chunks/types-563KUQRV.js +108 -0
  82. package/dist/chunks/update-route-version-E3V47KNI.js +13 -0
  83. package/dist/commands/build/index.js +1597 -0
  84. package/dist/commands/deploy/index.js +1711 -0
  85. package/dist/commands/dev/builder-worker.cjs +95 -0
  86. package/dist/commands/dev/index.js +20810 -0
  87. package/dist/commands/env/index.js +2154 -0
  88. package/dist/commands/link/index.js +225 -0
  89. package/dist/commands/list/index.js +528 -0
  90. package/dist/commands-bulk.js +29627 -0
  91. package/dist/get-latest-worker.cjs +272 -0
  92. package/dist/help.js +14 -0
  93. package/dist/index.js +24274 -0
  94. package/dist/vc.js +36 -0
  95. package/dist/version.mjs +1 -0
  96. package/package.json +254 -0
@@ -0,0 +1,272 @@
1
+ /**
2
+ * This file is spawned in the background and checks npm for the latest version
3
+ * of the CLI, then writes the version to the cache file.
4
+ *
5
+ * NOTE: Since this file runs asynchronously in the background, it's possible
6
+ * for multiple instances of this file to be running at the same time leading
7
+ * to a race condition where the most recent instance will overwrite the
8
+ * previous cache file resetting the `notified` flag and cause the update
9
+ * notification to appear for multiple consequetive commands. Not the end of
10
+ * the world, but something to be aware of.
11
+ *
12
+ * IMPORTANT! This file must NOT depend on any 3rd party dependencies. This
13
+ * file is NOT bundled by `esbuild` and thus any 3rd party dependencies will
14
+ * never be available.
15
+ */
16
+
17
+ const https = require('https');
18
+ const { mkdirSync, writeFileSync } = require('fs');
19
+ const { access, mkdir, readFile, unlink, writeFile } = require('fs/promises');
20
+ const path = require('path');
21
+ const { format, inspect } = require('util');
22
+
23
+ /**
24
+ * An simple output helper which accumulates error and debug log messages in
25
+ * memory for potential persistence to disk while immediately outputting errors
26
+ * and debug messages, when the `--debug` flag is set, to `stderr`.
27
+ */
28
+ class WorkerOutput {
29
+ debugLog = [];
30
+ logFile = null;
31
+
32
+ constructor({ debug = true }) {
33
+ this.debugOutputEnabled = debug;
34
+ }
35
+
36
+ debug(...args) {
37
+ this.print('debug', args);
38
+ }
39
+
40
+ error(...args) {
41
+ this.print('error', args);
42
+ }
43
+
44
+ print(type, args) {
45
+ // note: `args` may contain an `Error` that will be toString()'d and thus
46
+ // no stack trace
47
+ const str = format(
48
+ ...args.map(s => (typeof s === 'string' ? s : inspect(s)))
49
+ );
50
+ this.debugLog.push(`[${new Date().toISOString()}] [${type}] ${str}`);
51
+ if (type === 'debug' && this.debugOutputEnabled) {
52
+ // biome-ignore lint/suspicious/noConsole: intentional console usage
53
+ console.error(`> '[debug] [${new Date().toISOString()}] ${str}`);
54
+ } else if (type === 'error') {
55
+ // biome-ignore lint/suspicious/noConsole: intentional console usage
56
+ console.error(`Error: ${str}`);
57
+ }
58
+ }
59
+
60
+ setLogFile(file) {
61
+ // wire up the exit handler the first time the log file is set
62
+ if (this.logFile === null) {
63
+ process.on('exit', () => {
64
+ if (this.debugLog.length) {
65
+ mkdirSync(path.dirname(this.logFile), { recursive: true });
66
+ writeFileSync(this.logFile, this.debugLog.join('\n'));
67
+ }
68
+ });
69
+ }
70
+ this.logFile = file;
71
+ }
72
+ }
73
+
74
+ const output = new WorkerOutput({
75
+ // enable the debug logging if the `--debug` is set or if this worker script
76
+ // was directly executed
77
+ debug: process.argv.includes('--debug') || !process.connected,
78
+ });
79
+
80
+ process.on('unhandledRejection', err => {
81
+ output.error('Exiting worker due to unhandled rejection:', err);
82
+ process.exit(1);
83
+ });
84
+
85
+ // this timer will prevent this worker process from running longer than 10s
86
+ const timer = setTimeout(() => {
87
+ output.error('Worker timed out after 10 seconds');
88
+ process.exit(1);
89
+ }, 10000);
90
+
91
+ // wait for the parent to give us the work payload
92
+ process.once('message', async msg => {
93
+ output.debug('Received message from parent:', msg);
94
+
95
+ output.debug('Disconnecting from parent');
96
+ process.disconnect();
97
+
98
+ const { cacheFile, distTag, name, updateCheckInterval } = msg;
99
+ const cacheFileParsed = path.parse(cacheFile);
100
+ await mkdir(cacheFileParsed.dir, { recursive: true });
101
+
102
+ output.setLogFile(
103
+ path.join(cacheFileParsed.dir, `${cacheFileParsed.name}.log`)
104
+ );
105
+
106
+ const lockFile = path.join(
107
+ cacheFileParsed.dir,
108
+ `${cacheFileParsed.name}.lock`
109
+ );
110
+
111
+ try {
112
+ // check for a lock file and either bail if running or write our pid and continue
113
+ output.debug(`Checking lock file: ${lockFile}`);
114
+ if (await isRunning(lockFile)) {
115
+ output.debug('Worker already running, exiting');
116
+ process.exit(1);
117
+ }
118
+ output.debug(`Initializing lock file with pid ${process.pid}`);
119
+ await writeFile(lockFile, String(process.pid), 'utf-8');
120
+
121
+ const tags = await fetchDistTags(name);
122
+ const version = tags[distTag];
123
+ const expireAt = Date.now() + updateCheckInterval;
124
+ const notifyAt = await getNotifyAt(cacheFile, version);
125
+
126
+ if (version) {
127
+ output.debug(`Found dist tag "${distTag}" with version "${version}"`);
128
+ } else {
129
+ output.error(`Dist tag "${distTag}" not found`);
130
+ output.debug('Available dist tags:', Object.keys(tags));
131
+ }
132
+
133
+ output.debug(`Writing cache file: ${cacheFile}`);
134
+ await writeFile(
135
+ cacheFile,
136
+ JSON.stringify({
137
+ expireAt,
138
+ notifyAt,
139
+ version,
140
+ })
141
+ );
142
+ } catch (err) {
143
+ output.error(`Failed to get package info:`, err);
144
+ } finally {
145
+ clearTimeout(timer);
146
+
147
+ if (await fileExists(lockFile)) {
148
+ output.debug(`Releasing lock file: ${lockFile}`);
149
+ await unlink(lockFile);
150
+ }
151
+
152
+ output.debug(`Worker finished successfully!`);
153
+
154
+ // force the worker to exit
155
+ process.exit(0);
156
+ }
157
+ });
158
+
159
+ // signal the parent process we're ready
160
+ if (process.connected) {
161
+ output.debug("Notifying parent we're ready");
162
+ process.send({ type: 'ready' });
163
+ } else {
164
+ // biome-ignore lint/suspicious/noConsole: intentional console usage
165
+ console.error('No IPC bridge detected, exiting');
166
+ process.exit(1);
167
+ }
168
+
169
+ async function fileExists(file) {
170
+ return access(file)
171
+ .then(() => true)
172
+ .catch(() => false);
173
+ }
174
+
175
+ async function isRunning(lockFile) {
176
+ try {
177
+ const pid = parseInt(await readFile(lockFile, 'utf-8'));
178
+ output.debug(`Found lock file with pid: ${pid}`);
179
+
180
+ // checks for existence of a process; throws if not found
181
+ process.kill(pid, 0);
182
+
183
+ // process is still running
184
+ return true;
185
+ } catch (err) {
186
+ if (await fileExists(lockFile)) {
187
+ // lock file does not exist or process is not running and pid is stale
188
+ output.debug(`Resetting lock file: ${err.toString()}`);
189
+ await unlink(lockFile);
190
+ }
191
+ return false;
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Attempts to load and return the previous `notifyAt` value.
197
+ *
198
+ * If the latest version is newer than the previous latest version, then
199
+ * return `undefined` to invalidate `notifyAt` which forces the notification
200
+ * to be displayed, otherwise keep the existing `notifyAt`.
201
+ *
202
+ * @param {string} cacheFile The path to the cache file
203
+ * @param {string} version The latest version
204
+ * @returns {number | undefined} The previous notifyAt
205
+ */
206
+ async function getNotifyAt(cacheFile, version) {
207
+ try {
208
+ const old = JSON.parse(await readFile(cacheFile, 'utf-8'));
209
+ if (old?.version && old.version === version) {
210
+ return old.notifyAt;
211
+ }
212
+ } catch (err) {
213
+ // cache does not exist or malformed
214
+ if (err.code !== 'ENOENT') {
215
+ output.debug(`Error reading latest package cache file: ${err}`);
216
+ }
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Fetches the dist tags from npm for a given package.
222
+ *
223
+ * @param {string} name The package name
224
+ * @returns A map of dist tags to versions
225
+ */
226
+ async function fetchDistTags(name) {
227
+ // fetch the latest version from npm
228
+ const agent = new https.Agent({
229
+ keepAlive: true,
230
+ maxSockets: 15, // See: `npm config get maxsockets`
231
+ });
232
+ const headers = {
233
+ accept:
234
+ 'application/vnd.npm.install-v1+json; q=1.0, application/json; q=0.8, */*',
235
+ };
236
+ const url = `https://registry.npmjs.org/-/package/${name}/dist-tags`;
237
+ output.debug(`Fetching ${url}`);
238
+
239
+ return new Promise((resolve, reject) => {
240
+ const req = https.get(
241
+ url,
242
+ {
243
+ agent,
244
+ headers,
245
+ },
246
+ res => {
247
+ let buf = '';
248
+ res.on('data', chunk => {
249
+ buf += chunk;
250
+ });
251
+ res.on('end', () => {
252
+ try {
253
+ if (res.statusCode && res.statusCode >= 400) {
254
+ return reject(
255
+ new Error(
256
+ `Fetch dist-tags failed ${res.statusCode} ${res.statusMessage}`
257
+ )
258
+ );
259
+ }
260
+
261
+ resolve(JSON.parse(buf));
262
+ } catch (err) {
263
+ reject(err);
264
+ }
265
+ });
266
+ }
267
+ );
268
+
269
+ req.on('error', reject);
270
+ req.end();
271
+ });
272
+ }
package/dist/help.js ADDED
@@ -0,0 +1,14 @@
1
+ import { createRequire as __createRequire } from 'node:module';
2
+ import { fileURLToPath as __fileURLToPath } from 'node:url';
3
+ import { dirname as __dirname_ } from 'node:path';
4
+ const require = __createRequire(import.meta.url);
5
+ const __filename = __fileURLToPath(import.meta.url);
6
+ const __dirname = __dirname_(__filename);
7
+ import {
8
+ help
9
+ } from "./chunks/chunk-7YHZDJ4G.js";
10
+ import "./chunks/chunk-S7KYDPEM.js";
11
+ import "./chunks/chunk-TZ2YI2VH.js";
12
+ export {
13
+ help
14
+ };