vercel-cli 41.1.0__py3-none-any.whl

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.

Potentially problematic release.


This version of vercel-cli might be problematic. Click here for more details.

Files changed (99) hide show
  1. vercel_cli/vendor/LICENSE +202 -0
  2. vercel_cli/vendor/README.md +63 -0
  3. vercel_cli/vendor/dist/VERCEL_DIR_README.txt +11 -0
  4. vercel_cli/vendor/dist/builder-worker.js +62 -0
  5. vercel_cli/vendor/dist/get-latest-worker.js +272 -0
  6. vercel_cli/vendor/dist/index.js +172693 -0
  7. vercel_cli/vendor/dist/vc.js +11 -0
  8. vercel_cli/vendor/node_modules/.package-lock.json +18 -0
  9. vercel_cli/vendor/node_modules/@vercel/build-utils/CHANGELOG.md +488 -0
  10. vercel_cli/vendor/node_modules/@vercel/build-utils/LICENSE +202 -0
  11. vercel_cli/vendor/node_modules/@vercel/build-utils/build.mjs +3 -0
  12. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/clone-env.d.ts +10 -0
  13. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/clone-env.js +43 -0
  14. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/debug.d.ts +1 -0
  15. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/debug.js +31 -0
  16. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/default-cache-path-glob.d.ts +1 -0
  17. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/default-cache-path-glob.js +28 -0
  18. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/edge-function.d.ts +41 -0
  19. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/edge-function.js +40 -0
  20. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/errors.d.ts +39 -0
  21. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/errors.js +95 -0
  22. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-blob.d.ts +23 -0
  23. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-blob.js +67 -0
  24. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-fs-ref.d.ts +27 -0
  25. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-fs-ref.js +113 -0
  26. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-ref.d.ts +38 -0
  27. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/file-ref.js +147 -0
  28. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/download.d.ts +9 -0
  29. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/download.js +136 -0
  30. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/get-writable-directory.d.ts +1 -0
  31. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/get-writable-directory.js +32 -0
  32. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/glob.d.ts +10 -0
  33. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/glob.js +111 -0
  34. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/node-version.d.ts +9 -0
  35. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/node-version.js +180 -0
  36. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/normalize-path.d.ts +4 -0
  37. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/normalize-path.js +31 -0
  38. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/read-config-file.d.ts +1 -0
  39. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/read-config-file.js +76 -0
  40. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/rename.d.ts +11 -0
  41. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/rename.js +30 -0
  42. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/run-user-scripts.d.ts +206 -0
  43. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/run-user-scripts.js +944 -0
  44. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/stream-to-buffer.d.ts +3 -0
  45. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/fs/stream-to-buffer.js +87 -0
  46. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-ignore-filter.d.ts +1 -0
  47. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-ignore-filter.js +90 -0
  48. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-installed-package-version.d.ts +1 -0
  49. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-installed-package-version.js +53 -0
  50. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-platform-env.d.ts +5 -0
  51. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-platform-env.js +45 -0
  52. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-prefixed-env-vars.d.ts +14 -0
  53. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/get-prefixed-env-vars.js +51 -0
  54. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/hard-link-dir.d.ts +1 -0
  55. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/hard-link-dir.js +104 -0
  56. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/index.d.ts +33 -0
  57. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/index.js +24390 -0
  58. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/lambda.d.ts +81 -0
  59. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/lambda.js +231 -0
  60. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/nodejs-lambda.d.ts +16 -0
  61. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/nodejs-lambda.js +44 -0
  62. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/os.d.ts +3 -0
  63. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/os.js +62 -0
  64. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/prerender.d.ts +37 -0
  65. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/prerender.js +169 -0
  66. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/schemas.d.ts +60 -0
  67. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/schemas.js +87 -0
  68. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/should-serve.d.ts +2 -0
  69. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/should-serve.js +47 -0
  70. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/constants.d.ts +2 -0
  71. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/constants.js +31 -0
  72. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/index.d.ts +3 -0
  73. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/index.js +33 -0
  74. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/trace.d.ts +37 -0
  75. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/trace/trace.js +92 -0
  76. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/types.d.ts +503 -0
  77. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/types.js +51 -0
  78. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/validate-npmrc.d.ts +12 -0
  79. vercel_cli/vendor/node_modules/@vercel/build-utils/dist/validate-npmrc.js +41 -0
  80. vercel_cli/vendor/node_modules/@vercel/build-utils/file-blob.js +1 -0
  81. vercel_cli/vendor/node_modules/@vercel/build-utils/file-fs-ref.js +1 -0
  82. vercel_cli/vendor/node_modules/@vercel/build-utils/file-ref.js +1 -0
  83. vercel_cli/vendor/node_modules/@vercel/build-utils/fs/download.js +1 -0
  84. vercel_cli/vendor/node_modules/@vercel/build-utils/fs/get-writable-directory.js +1 -0
  85. vercel_cli/vendor/node_modules/@vercel/build-utils/fs/glob.js +1 -0
  86. vercel_cli/vendor/node_modules/@vercel/build-utils/fs/rename.js +1 -0
  87. vercel_cli/vendor/node_modules/@vercel/build-utils/fs/run-user-scripts.js +1 -0
  88. vercel_cli/vendor/node_modules/@vercel/build-utils/fs/stream-to-buffer.js +1 -0
  89. vercel_cli/vendor/node_modules/@vercel/build-utils/lambda.js +1 -0
  90. vercel_cli/vendor/node_modules/@vercel/build-utils/package.json +60 -0
  91. vercel_cli/vendor/node_modules/@vercel/python/LICENSE +202 -0
  92. vercel_cli/vendor/node_modules/@vercel/python/dist/index.js +3132 -0
  93. vercel_cli/vendor/node_modules/@vercel/python/package.json +36 -0
  94. vercel_cli/vendor/node_modules/@vercel/python/vc_init.py +681 -0
  95. vercel_cli/vendor/package.json +40 -0
  96. vercel_cli-41.1.0.dist-info/METADATA +188 -0
  97. vercel_cli-41.1.0.dist-info/RECORD +99 -0
  98. vercel_cli-41.1.0.dist-info/WHEEL +4 -0
  99. vercel_cli-41.1.0.dist-info/entry_points.txt +3 -0
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2017 Vercel, Inc.
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,63 @@
1
+ <p align="center">
2
+ <a href="https://vercel.com">
3
+ <img src="https://assets.vercel.com/image/upload/v1588805858/repositories/vercel/logo.png" height="96">
4
+ <h3 align="center">Vercel</h3>
5
+ </a>
6
+ <p align="center">Develop. Preview. Ship.</p>
7
+ </p>
8
+
9
+ [Join the Vercel Community](https://vercel.community/)
10
+
11
+ ## Usage
12
+
13
+ Vercel's frontend cloud gives developers frameworks, workflows, and infrastructure to build a faster, more personalized web.
14
+
15
+ To install the latest version of Vercel CLI, run this command:
16
+
17
+ ```bash
18
+ npm i -g vercel
19
+ ```
20
+
21
+ To quickly start a new project, run the following commands:
22
+
23
+ ```bash
24
+ vercel init # Pick an example project
25
+ cd <PROJECT> # Change directory to the new project
26
+ vercel # Deploy to the cloud
27
+ ```
28
+
29
+ Finally, [connect your Git repository to Vercel](https://vercel.com/docs/git) and deploy with `git push`.
30
+
31
+ ## Documentation
32
+
33
+ For details on how to use Vercel CLI, check out our [documentation](https://vercel.com/docs/cli).
34
+
35
+ ## Local Development
36
+
37
+ To develop Vercel CLI, first check out the source code, install dependencies, and build all packages:
38
+
39
+ ```bash
40
+ git clone https://github.com/vercel/vercel.git
41
+ cd vercel
42
+ pnpm install
43
+ pnpm build
44
+ ```
45
+
46
+ At this point you can make modifications to the CLI source code and test them out locally. The CLI source code is located in the `packages/cli` directory.
47
+
48
+ ```bash
49
+ cd packages/cli
50
+ ```
51
+
52
+ ### `pnpm vercel <cli-commands...>`
53
+
54
+ From within the `packages/cli` directory, you can use the "vercel" script to quickly execute Vercel CLI from its TypeScript source code directly (without having to manually compile first). For example:
55
+
56
+ ```bash
57
+ pnpm vercel deploy
58
+ pnpm vercel whoami
59
+ pnpm vercel login
60
+ pnpm vercel switch --debug
61
+ ```
62
+
63
+ When you are satisfied with your changes, make a commit and create a pull request!
@@ -0,0 +1,11 @@
1
+ > Why do I have a folder named ".vercel" in my project?
2
+ The ".vercel" folder is created when you link a directory to a Vercel project.
3
+
4
+ > What does the "project.json" file contain?
5
+ The "project.json" file contains:
6
+ - The ID of the Vercel project that you linked ("projectId")
7
+ - The ID of the user or team your Vercel project is owned by ("orgId")
8
+
9
+ > Should I commit the ".vercel" folder?
10
+ No, you should not share the ".vercel" folder with anyone.
11
+ Upon creation, it will be automatically added to your ".gitignore" file.
@@ -0,0 +1,62 @@
1
+ /**
2
+ * This file gets copied out of the `pkg` snapshot filesystem into the `vc dev`
3
+ * builder cache directory, so it's very important that it does not rely on any
4
+ * modules from npm that would not be available in that directory (so basically,
5
+ * only Vercel Runtimes and `@vercel/build-utils`.
6
+ */
7
+ const { FileFsRef } = require('@vercel/build-utils');
8
+
9
+ process.on('unhandledRejection', err => {
10
+ // eslint-disable-next-line no-console
11
+ console.error('Exiting builder due to build error:');
12
+ // eslint-disable-next-line no-console
13
+ console.error(err);
14
+ process.exit(1);
15
+ });
16
+
17
+ process.on('message', onMessage);
18
+
19
+ function onMessage(message) {
20
+ processMessage(message).catch(err => {
21
+ Object.defineProperty(err, 'message', { enumerable: true });
22
+ Object.defineProperty(err, 'stack', { enumerable: true });
23
+ process.removeListener('message', onMessage);
24
+ process.send({ type: 'buildResult', error: err }, () => process.exit(1));
25
+ });
26
+ }
27
+
28
+ async function processMessage(message) {
29
+ const { requirePath, buildOptions } = message;
30
+ const builder = require(requirePath);
31
+
32
+ // Convert the `files` to back into `FileFsRef` instances
33
+ for (const name of Object.keys(buildOptions.files)) {
34
+ const ref = Object.assign(
35
+ Object.create(FileFsRef.prototype),
36
+ buildOptions.files[name]
37
+ );
38
+ buildOptions.files[name] = ref;
39
+ }
40
+
41
+ const result = await builder.build(buildOptions);
42
+
43
+ // `@vercel/next` sets this, but it causes "Converting circular
44
+ // structure to JSON" errors, so delete the property...
45
+ delete result.childProcesses;
46
+
47
+ if (builder.version === 3) {
48
+ if (result.output.type === 'Lambda') {
49
+ result.output.zipBuffer = await result.output.createZip();
50
+ }
51
+ } else {
52
+ for (const output of Object.values(result.output)) {
53
+ if (output.type === 'Lambda') {
54
+ output.zipBuffer = await output.createZip();
55
+ }
56
+ }
57
+ }
58
+
59
+ process.send({ type: 'buildResult', result });
60
+ }
61
+
62
+ process.send({ type: 'ready' });
@@ -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
+ // eslint-disable-next-line no-console
53
+ console.error(`> '[debug] [${new Date().toISOString()}] ${str}`);
54
+ } else if (type === 'error') {
55
+ // eslint-disable-next-line no-console
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
+ // eslint-disable-next-line no-console
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
+ }