mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-26 19:00:08 +00:00
Compare commits
93 Commits
@now/node@
...
@now/frame
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd4a0cbd32 | ||
|
|
7ff9adc90e | ||
|
|
b279f1ffae | ||
|
|
344cc103ee | ||
|
|
83249b3685 | ||
|
|
79e7a9f477 | ||
|
|
b3dce70271 | ||
|
|
cff8d8b8a0 | ||
|
|
da892100d9 | ||
|
|
72e87ee6e4 | ||
|
|
3f9afad167 | ||
|
|
1527447914 | ||
|
|
9ca35df5fb | ||
|
|
05b2e2216c | ||
|
|
167fd5750a | ||
|
|
4a3cd7ec72 | ||
|
|
9aef718917 | ||
|
|
3cdc261802 | ||
|
|
5c71f672b3 | ||
|
|
dbc5f73984 | ||
|
|
1d269fffc8 | ||
|
|
cc146ba0f5 | ||
|
|
f8a2519838 | ||
|
|
1781376d47 | ||
|
|
d9fda14969 | ||
|
|
a4de9272e7 | ||
|
|
9b9037de91 | ||
|
|
8d18c65e3e | ||
|
|
e7d7de61b6 | ||
|
|
11927883c3 | ||
|
|
57d25b184b | ||
|
|
95f716fb3f | ||
|
|
8dd52605be | ||
|
|
4b9c6a2a2a | ||
|
|
17f92a5ad3 | ||
|
|
0aab7cc509 | ||
|
|
b39622b271 | ||
|
|
1e9aeee8e9 | ||
|
|
49fac0dfad | ||
|
|
a668df829f | ||
|
|
3d4ef1f825 | ||
|
|
f986daa1cc | ||
|
|
549c8777ba | ||
|
|
51d7242fda | ||
|
|
36db0e5bab | ||
|
|
99368b4248 | ||
|
|
95daf0e292 | ||
|
|
8bfa9c1a42 | ||
|
|
4208dc0466 | ||
|
|
00ae011b95 | ||
|
|
a770991a81 | ||
|
|
f80a6d6392 | ||
|
|
30777384ec | ||
|
|
0c719b7f6a | ||
|
|
ff18788b20 | ||
|
|
752ab39787 | ||
|
|
c1df8c8bd1 | ||
|
|
25fd1df35d | ||
|
|
d32ab1e0d9 | ||
|
|
a69c460760 | ||
|
|
b985853f15 | ||
|
|
94e607a93a | ||
|
|
f97a81fa14 | ||
|
|
6e28438eb4 | ||
|
|
8fcdf3f458 | ||
|
|
dbf0cc3562 | ||
|
|
27ccfa7e7a | ||
|
|
f37edbc670 | ||
|
|
b7943e83d2 | ||
|
|
300ed5b952 | ||
|
|
9e6ebfb3ec | ||
|
|
f49620790c | ||
|
|
84065688b5 | ||
|
|
5a1012fb0f | ||
|
|
4b6143c293 | ||
|
|
b6601b0d9a | ||
|
|
2870a1dd49 | ||
|
|
6249f7e293 | ||
|
|
6f9545e097 | ||
|
|
8095ba5cf9 | ||
|
|
e02128e5a3 | ||
|
|
2567b8c8b8 | ||
|
|
5bfcdec471 | ||
|
|
6609686a2b | ||
|
|
709aaf2285 | ||
|
|
6b3908d4dc | ||
|
|
9d19d02a0a | ||
|
|
533b059947 | ||
|
|
2a7c1dc4e4 | ||
|
|
07a920ed18 | ||
|
|
db36c874a0 | ||
|
|
cc58af74d6 | ||
|
|
1bcb95a9f0 |
6
.github/workflows/continuous-integration.yml
vendored
6
.github/workflows/continuous-integration.yml
vendored
@@ -45,6 +45,9 @@ jobs:
|
||||
- run: yarn install
|
||||
- run: yarn run build
|
||||
- run: yarn test-integration-once --clean false
|
||||
env:
|
||||
ZEIT_TEAM_TOKEN: ${{ secrets.ZEIT_TEAM_TOKEN }}
|
||||
ZEIT_REGISTRATION_URL: ${{ secrets.ZEIT_REGISTRATION_URL }}
|
||||
|
||||
test-now-cli:
|
||||
name: Now CLI Tests
|
||||
@@ -68,6 +71,9 @@ jobs:
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: yarn test-integration --clean false
|
||||
env:
|
||||
ZEIT_TEAM_TOKEN: ${{ secrets.ZEIT_TEAM_TOKEN }}
|
||||
ZEIT_REGISTRATION_URL: ${{ secrets.ZEIT_REGISTRATION_URL }}
|
||||
|
||||
test-now-dev:
|
||||
name: "`now dev` Tests"
|
||||
|
||||
2
.github/workflows/publish.yml
vendored
2
.github/workflows/publish.yml
vendored
@@ -27,3 +27,5 @@ jobs:
|
||||
run: yarn publish-from-github
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }}
|
||||
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
||||
|
||||
8
codecov.yml
Normal file
8
codecov.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
codecov:
|
||||
require_ci_to_pass: yes
|
||||
|
||||
coverage:
|
||||
status:
|
||||
project: off
|
||||
patch: off
|
||||
|
||||
115
examples/brunch/app/assets/brunch-napkin.svg
Normal file
115
examples/brunch/app/assets/brunch-napkin.svg
Normal file
@@ -0,0 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="256px" height="256px" viewBox="0 0 256 256" enable-background="new 0 0 256 256" xml:space="preserve">
|
||||
<rect x="65" y="68" fill="#7C7C7C" width="127" height="124"/>
|
||||
<rect x="83.392" y="22.163" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 266.9294 23.9747)" fill="#86AD8A" width="90.215" height="90.215"/>
|
||||
<path fill="#FFFFFF" d="M117.601,167.637c3.788-11.191,5.795-45.647,4.728-62.795c-0.128-2.057-0.333-4.445-0.692-6.351
|
||||
c-0.112-0.607-0.244-1.168-0.391-1.651c0-6.672,0-62.892,0-67.02c0-5.717,5.242-8.419,10.166,4.128
|
||||
c4.925,12.547,3.495,57.175,3.495,60.348c0,0.673-0.611,1.469-1.57,2.25c-0.383,0.247-0.73,0.499-1.051,0.754
|
||||
c-2.949,2.366-3.379,5.095-3.533,7.542c-1.067,17.148-1.554,51.604,2.234,62.795c4.438,13.112-4.004,14.759-6.691,14.759
|
||||
C121.605,182.395,113.163,180.748,117.601,167.637z"/>
|
||||
<path fill="#FFFFFF" d="M103.019,47.413c-0.472,0.049-1.062,9.387-1.257,16.131c-0.238,8.194-0.607,15.482-2.908,15.482
|
||||
c-1.728,0-2.8-2.853-2.517-10.094c0.407-10.427,0.395-21.519-0.219-21.519c-0.774,0-4.358,22.999-4.358,31.09
|
||||
c0,5.803,2.487,11.269,5.603,14.115c0.01,0.008,0.019,0.019,0.033,0.027c0.093,0.081,0.191,0.166,0.278,0.247
|
||||
c0.005,0.004,0.01,0.004,0.01,0.008c2.252,2.053,2.819,4.283,2.971,6.32c1.286,17.143-1.128,59.614-5.678,70.804
|
||||
c-5.33,13.108,4.811,14.759,8.042,14.759c3.227,0,13.368-1.651,8.037-14.759c-4.55-11.191-6.96-53.661-5.678-70.804
|
||||
c0.153-2.037,0.719-4.267,2.971-6.32c0-0.004,0.005-0.004,0.01-0.008c0.088-0.081,0.185-0.166,0.278-0.247
|
||||
c0.014-0.008,0.023-0.019,0.033-0.027c3.116-2.845,5.764-8.314,5.604-14.115c-0.635-23.017-3.263-31.09-4.037-31.09
|
||||
c-0.614,0-0.613,12.286-0.438,21.024c0.143,7.158-0.471,10.383-2.49,10.383c-1.923,0-2.504-6.972-2.748-15.368
|
||||
c-0.196-6.762-0.804-16.039-1.54-16.039"/>
|
||||
<path fill="#FFFFFF" d="M154.075,179.591c-2.546,0-10.532-1.562-6.332-13.967c3.585-10.59,5.483-50.779,4.474-67.007
|
||||
c-0.051-0.826-0.256-1.664-0.413-2.55c-0.443-2.504-3.543-4.555-5.338-6.356c-3.486-3.498-5.725-9.38-5.725-16.013
|
||||
c0-10.77,5.97-24.4,13.334-24.4c7.364,0,13.334,13.63,13.334,24.4c0,6.633-2.24,12.515-5.725,16.013
|
||||
c-1.795,1.801-4.895,3.852-5.338,6.356c-0.157,0.886-0.361,1.724-0.413,2.55c-1.01,16.227,0.889,56.416,4.474,67.007
|
||||
C164.607,178.03,156.621,179.591,154.075,179.591z"/>
|
||||
<polyline fill="#CECCAE" points="65,68 65,192 192,192 "/>
|
||||
<polygon fill="#3F894A" points="65,191.835 65,253 192,253 192,191.835 192,66.938 "/>
|
||||
<g>
|
||||
<g>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="0.5" stroke-miterlimit="10" x1="191.658" y1="82.55" x2="190.946" y2="83.253"/>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="0.5" stroke-miterlimit="10" stroke-dasharray="2.02,2.02" x1="189.509" y1="84.672" x2="66.629" y2="206.035"/>
|
||||
|
||||
<line fill="none" stroke="#FFFFFF" stroke-width="0.5" stroke-miterlimit="10" x1="65.91" y1="206.745" x2="65.199" y2="207.448"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
<path fill="#FFFFFF" d="M85.353,211.117h6.328c0.827,0,1.665,0.067,2.513,0.201c0.848,0.135,1.608,0.414,2.28,0.838
|
||||
c0.672,0.424,1.22,1.014,1.644,1.768c0.424,0.756,0.636,1.753,0.636,2.994c0,1.116-0.331,2.089-0.993,2.916
|
||||
c-0.662,0.827-1.644,1.376-2.947,1.645v0.062c0.724,0.062,1.385,0.232,1.985,0.512c0.6,0.279,1.117,0.651,1.551,1.117
|
||||
c0.434,0.465,0.77,1.019,1.008,1.659c0.238,0.642,0.357,1.345,0.357,2.109c0,1.262-0.243,2.291-0.729,3.087
|
||||
c-0.486,0.797-1.097,1.422-1.83,1.877c-0.734,0.455-1.531,0.766-2.389,0.931c-0.858,0.166-1.66,0.248-2.404,0.248h-7.011V211.117z
|
||||
M87.4,220.609h4.25c1.055,0,1.913-0.129,2.575-0.388c0.662-0.259,1.179-0.574,1.551-0.946c0.373-0.372,0.621-0.771,0.745-1.194
|
||||
s0.186-0.812,0.186-1.163c0-0.765-0.129-1.401-0.388-1.908c-0.259-0.506-0.605-0.909-1.039-1.21
|
||||
c-0.435-0.299-0.941-0.512-1.52-0.636c-0.579-0.124-1.189-0.186-1.831-0.186H87.4V220.609z M87.4,231.219h4.684
|
||||
c1.199,0,2.166-0.145,2.9-0.435c0.734-0.289,1.298-0.651,1.691-1.085c0.393-0.435,0.656-0.895,0.791-1.381
|
||||
c0.134-0.485,0.202-0.926,0.202-1.318c0-0.807-0.155-1.499-0.465-2.078s-0.713-1.05-1.21-1.412c-0.496-0.361-1.06-0.625-1.69-0.791
|
||||
c-0.631-0.165-1.267-0.248-1.908-0.248H87.4V231.219z"/>
|
||||
<path fill="#FFFFFF" d="M103.73,222.781c0-0.269-0.011-0.595-0.031-0.978c-0.021-0.383-0.036-0.771-0.046-1.163
|
||||
c-0.011-0.393-0.026-0.76-0.047-1.102c-0.021-0.341-0.031-0.604-0.031-0.791h1.861c0.021,0.538,0.036,1.055,0.046,1.551
|
||||
c0.01,0.497,0.036,0.817,0.078,0.962c0.476-0.848,1.086-1.54,1.83-2.078c0.745-0.538,1.654-0.807,2.73-0.807
|
||||
c0.186,0,0.367,0.016,0.543,0.047c0.175,0.03,0.357,0.067,0.543,0.108l-0.217,1.83c-0.248-0.082-0.486-0.124-0.713-0.124
|
||||
c-0.807,0-1.504,0.129-2.094,0.388c-0.589,0.259-1.075,0.615-1.458,1.07s-0.667,0.987-0.853,1.598s-0.279,1.267-0.279,1.97v7.817
|
||||
h-1.861V222.781z"/>
|
||||
<path fill="#FFFFFF" d="M126,229.047c0,0.27,0.01,0.595,0.031,0.978c0.021,0.383,0.036,0.771,0.046,1.163
|
||||
c0.01,0.394,0.026,0.761,0.047,1.102c0.02,0.341,0.031,0.604,0.031,0.791h-1.861c-0.021-0.537-0.036-1.055-0.046-1.551
|
||||
c-0.011-0.497-0.036-0.817-0.078-0.962h-0.093c-0.373,0.786-0.993,1.463-1.861,2.032c-0.869,0.568-1.882,0.853-3.04,0.853
|
||||
c-1.117,0-2.032-0.176-2.746-0.527s-1.272-0.812-1.675-1.38c-0.403-0.569-0.678-1.226-0.822-1.971
|
||||
c-0.145-0.744-0.217-1.509-0.217-2.295v-8.531h1.861v8.438c0,0.58,0.051,1.144,0.155,1.691s0.284,1.039,0.543,1.474
|
||||
c0.258,0.434,0.621,0.78,1.086,1.039s1.07,0.388,1.815,0.388c0.682,0,1.329-0.119,1.938-0.356c0.61-0.238,1.137-0.6,1.582-1.086
|
||||
s0.796-1.097,1.055-1.83c0.258-0.734,0.388-1.598,0.388-2.591v-7.166H126V229.047z"/>
|
||||
<path fill="#FFFFFF" d="M130.584,222.781c0-0.269-0.01-0.595-0.029-0.978c-0.021-0.383-0.037-0.771-0.047-1.163
|
||||
c-0.012-0.393-0.027-0.76-0.047-1.102c-0.021-0.341-0.031-0.604-0.031-0.791h1.861c0.02,0.538,0.035,1.055,0.047,1.551
|
||||
c0.01,0.497,0.035,0.817,0.076,0.962h0.094c0.373-0.785,0.992-1.463,1.861-2.032c0.869-0.568,1.883-0.853,3.041-0.853
|
||||
c1.115,0,2.025,0.176,2.729,0.527s1.258,0.812,1.66,1.381c0.404,0.568,0.684,1.225,0.838,1.97c0.154,0.744,0.232,1.51,0.232,2.295
|
||||
v8.531h-1.861v-8.438c0-0.579-0.051-1.143-0.154-1.691c-0.104-0.547-0.285-1.039-0.543-1.473c-0.26-0.435-0.621-0.781-1.086-1.04
|
||||
c-0.465-0.258-1.07-0.388-1.814-0.388c-0.684,0-1.33,0.119-1.939,0.357c-0.609,0.237-1.137,0.6-1.582,1.085
|
||||
c-0.445,0.486-0.797,1.097-1.055,1.831c-0.26,0.734-0.389,1.598-0.389,2.59v7.166h-1.861V222.781z"/>
|
||||
<path fill="#FFFFFF" d="M159.28,230.971c-0.703,0.849-1.5,1.474-2.389,1.877c-0.89,0.403-1.852,0.604-2.885,0.604
|
||||
c-1.097,0-2.11-0.186-3.041-0.559c-0.931-0.372-1.727-0.894-2.389-1.566c-0.662-0.672-1.179-1.468-1.551-2.389
|
||||
c-0.372-0.92-0.559-1.928-0.559-3.024c0-1.096,0.187-2.104,0.559-3.024s0.889-1.717,1.551-2.389s1.458-1.194,2.389-1.566
|
||||
c0.931-0.373,1.944-0.559,3.041-0.559c1.055,0,2.031,0.217,2.931,0.651c0.9,0.435,1.701,1.045,2.404,1.83l-1.489,1.117
|
||||
c-0.537-0.6-1.127-1.07-1.768-1.412c-0.642-0.341-1.334-0.512-2.078-0.512c-0.869,0-1.655,0.155-2.358,0.466
|
||||
c-0.703,0.31-1.303,0.729-1.799,1.256s-0.874,1.148-1.133,1.861c-0.259,0.714-0.388,1.474-0.388,2.28s0.129,1.566,0.388,2.28
|
||||
c0.259,0.713,0.637,1.334,1.133,1.861s1.096,0.946,1.799,1.256c0.703,0.311,1.489,0.466,2.358,0.466
|
||||
c0.785,0,1.504-0.181,2.155-0.543c0.651-0.361,1.215-0.843,1.69-1.442L159.28,230.971z"/>
|
||||
<path fill="#FFFFFF" d="M161.925,209.628h1.861v11.633h0.062c0.372-0.785,0.992-1.463,1.861-2.032
|
||||
c0.868-0.568,1.882-0.853,3.04-0.853c1.116,0,2.026,0.176,2.729,0.527s1.257,0.812,1.66,1.381c0.403,0.568,0.683,1.225,0.837,1.97
|
||||
c0.155,0.744,0.233,1.51,0.233,2.295v8.531h-1.861v-8.438c0-0.579-0.052-1.143-0.155-1.691c-0.104-0.547-0.285-1.039-0.543-1.473
|
||||
c-0.259-0.435-0.62-0.781-1.086-1.04c-0.465-0.258-1.07-0.388-1.814-0.388c-0.683,0-1.329,0.119-1.939,0.357
|
||||
c-0.609,0.237-1.137,0.6-1.582,1.085c-0.444,0.486-0.796,1.097-1.055,1.831s-0.388,1.598-0.388,2.59v7.166h-1.861V209.628z"/>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@@ -10,7 +10,8 @@
|
||||
</head>
|
||||
<body>
|
||||
<div class="brunch">
|
||||
<a href="http://brunch.io"><img src="http://brunch.io/images/logo.png" alt="Brunch"></a>
|
||||
<p>Bon Appétit.</p>
|
||||
<img src="/brunch-napkin.svg" alt="Brunch">
|
||||
<h4>Bon Appétit.</h4>
|
||||
<h6>A <a href="http://brunch.io" target="_blank">Brunch</a> website deployed on <a href="https://zeit.co" target="_blank">ZEIT Now</a></h6>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
@@ -1,6 +1,21 @@
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
display: flex;
|
||||
margin: 0;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.brunch {
|
||||
font-family: -apple-system, Sans-Serif;
|
||||
text-align: center;
|
||||
font-size: 24pt;
|
||||
color: #3f894a;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "gatsby-starter-default",
|
||||
"name": "gatsby",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"gatsby": "^2.18.14",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "gridsomee",
|
||||
"name": "gridsome",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "gridsome build",
|
||||
|
||||
@@ -79,4 +79,4 @@ DEPENDENCIES
|
||||
wdm (~> 0.1.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.2
|
||||
2.1.4
|
||||
|
||||
@@ -105,4 +105,4 @@ DEPENDENCIES
|
||||
wdm (~> 0.1)
|
||||
|
||||
BUNDLED WITH
|
||||
1.17.2
|
||||
2.1.4
|
||||
|
||||
16
examples/nextjs/.gitignore
vendored
16
examples/nextjs/.gitignore
vendored
@@ -1,18 +1,26 @@
|
||||
# See https://help.github.com/ignore-files/ for more about ignoring files.
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# next.js
|
||||
/.next/
|
||||
/out/
|
||||
!public/
|
||||
|
||||
# production
|
||||
/build
|
||||
/dist
|
||||
/.next
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env*
|
||||
|
||||
# debug
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
@@ -20,5 +28,3 @@ yarn-error.log*
|
||||
# Environment Variables
|
||||
.env
|
||||
.env.build
|
||||
|
||||
.now
|
||||
@@ -1,2 +0,0 @@
|
||||
README.md
|
||||
yarn.lock
|
||||
@@ -1,29 +1,30 @@
|
||||

|
||||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app).
|
||||
|
||||
# Next.js Example
|
||||
## Getting Started
|
||||
|
||||
This directory is a brief example of a [Next.js](https://nextjs.org) app that can be deployed with ZEIT Now and zero configuration.
|
||||
First, run the development server:
|
||||
|
||||
## Deploy Your Own
|
||||
|
||||
Deploy your own Next.js project with ZEIT Now.
|
||||
|
||||
[](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/nextjs)
|
||||
|
||||
_Live Example: https://nextjs.now-examples.now.sh_
|
||||
|
||||
### How We Created This Example
|
||||
|
||||
To get started with Next.js deployed with ZEIT Now, you can use [npm create](https://www.npmjs.com/package/create-next-app) to initialize the project:
|
||||
|
||||
```shell
|
||||
$ npm create next-app my-app
|
||||
```bash
|
||||
npm run dev
|
||||
# or
|
||||
yarn dev
|
||||
```
|
||||
|
||||
### Deploying From Your Terminal
|
||||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
||||
|
||||
You can deploy your new Next.js project with a single command from your terminal using [Now CLI](https://zeit.co/download):
|
||||
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
|
||||
|
||||
```shell
|
||||
$ now
|
||||
```
|
||||
## Learn More
|
||||
|
||||
To learn more about Next.js, take a look at the following resources:
|
||||
|
||||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
||||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
||||
|
||||
You can check out [the Next.js GitHub repository](https://github.com/zeit/next.js/) - your feedback and contributions are welcome!
|
||||
|
||||
## Deploy on ZEIT Now
|
||||
|
||||
The easiest way to deploy your Next.js app is to use the [ZEIT Now Platform](https://zeit.co/import?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
||||
|
||||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
import React from 'react';
|
||||
import NextHead from 'next/head';
|
||||
import { string } from 'prop-types';
|
||||
|
||||
const defaultDescription = '';
|
||||
const defaultOGURL = '';
|
||||
const defaultOGImage = '';
|
||||
|
||||
const Head = props => (
|
||||
<NextHead>
|
||||
<meta charSet="UTF-8" />
|
||||
<title>{props.title || ''}</title>
|
||||
<meta
|
||||
name="description"
|
||||
content={props.description || defaultDescription}
|
||||
/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<meta property="og:url" content={props.url || defaultOGURL} />
|
||||
<meta property="og:title" content={props.title || ''} />
|
||||
<meta
|
||||
property="og:description"
|
||||
content={props.description || defaultDescription}
|
||||
/>
|
||||
<meta name="twitter:site" content={props.url || defaultOGURL} />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:image" content={props.ogImage || defaultOGImage} />
|
||||
<meta property="og:image" content={props.ogImage || defaultOGImage} />
|
||||
<meta property="og:image:width" content="1200" />
|
||||
<meta property="og:image:height" content="630" />
|
||||
</NextHead>
|
||||
);
|
||||
|
||||
Head.propTypes = {
|
||||
title: string,
|
||||
description: string,
|
||||
url: string,
|
||||
ogImage: string,
|
||||
};
|
||||
|
||||
export default Head;
|
||||
@@ -1,56 +0,0 @@
|
||||
import React from 'react';
|
||||
import Link from 'next/link';
|
||||
|
||||
const links = [
|
||||
{ href: 'https://zeit.co/now', label: 'ZEIT' },
|
||||
{ href: 'https://github.com/zeit/next.js', label: 'GitHub' },
|
||||
].map(link => {
|
||||
link.key = `nav-link-${link.href}-${link.label}`;
|
||||
return link;
|
||||
});
|
||||
|
||||
const Nav = () => (
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<Link href="/">
|
||||
<a>Home</a>
|
||||
</Link>
|
||||
</li>
|
||||
{links.map(({ key, href, label }) => (
|
||||
<li key={key}>
|
||||
<a href={href}>{label}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<style jsx>{`
|
||||
:global(body) {
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Avenir Next, Avenir,
|
||||
Helvetica, sans-serif;
|
||||
}
|
||||
nav {
|
||||
text-align: center;
|
||||
}
|
||||
ul {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
}
|
||||
nav > ul {
|
||||
padding: 4px 16px;
|
||||
}
|
||||
li {
|
||||
display: flex;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
a {
|
||||
color: #067df7;
|
||||
text-decoration: none;
|
||||
font-size: 13px;
|
||||
}
|
||||
`}</style>
|
||||
</nav>
|
||||
);
|
||||
|
||||
export default Nav;
|
||||
@@ -1,19 +1,15 @@
|
||||
{
|
||||
"name": "create-next-example-app",
|
||||
"description": "A Next.js starter app.",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zeit/now/tree/master/examples/nextjs"
|
||||
},
|
||||
"license": "MIT",
|
||||
"name": "nextjs",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next",
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "^9.1.6",
|
||||
"react": "^16.12.0",
|
||||
"react-dom": "^16.12.0"
|
||||
"next": "9.2.2",
|
||||
"react": "16.13.0",
|
||||
"react-dom": "16.13.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
export default (req, res) => {
|
||||
const date = new Date()
|
||||
.toISOString()
|
||||
.replace(/T/, ' ')
|
||||
.replace(/\..+/, '');
|
||||
|
||||
res.json({ date });
|
||||
};
|
||||
@@ -1,143 +1,203 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import Head from '../components/head';
|
||||
import Nav from '../components/nav';
|
||||
import Head from 'next/head'
|
||||
|
||||
const Home = () => {
|
||||
const [date, setDate] = useState(null);
|
||||
const Home = () => (
|
||||
<div className="container">
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
|
||||
useEffect(() => {
|
||||
async function getDate() {
|
||||
const res = await fetch('/api/date');
|
||||
const newDate = await res.json();
|
||||
setDate(newDate);
|
||||
}
|
||||
getDate();
|
||||
}, []);
|
||||
<main>
|
||||
<h1 className="title">
|
||||
Welcome to <a href="https://nextjs.org">Next.js!</a>
|
||||
</h1>
|
||||
|
||||
return (
|
||||
<div>
|
||||
<Head title="Home" />
|
||||
<Nav />
|
||||
<p className="description">
|
||||
Get started by editing <code>pages/index.js</code>
|
||||
</p>
|
||||
|
||||
<div className="hero">
|
||||
<h1 className="title">Welcome to Next!</h1>
|
||||
<p className="description">
|
||||
To get started, edit the <code>pages/index.js</code> or{' '}
|
||||
<code>pages/api/date.js</code> files, then save to reload.
|
||||
</p>
|
||||
<div className="grid">
|
||||
<a href="https://nextjs.org/docs" className="card">
|
||||
<h3>Documentation →</h3>
|
||||
<p>Find in-depth information about Next.js features and API.</p>
|
||||
</a>
|
||||
|
||||
<p className="row date">
|
||||
The date is: {' '}
|
||||
{date ? (
|
||||
<span>
|
||||
<b>{date.date}</b>
|
||||
</span>
|
||||
) : (
|
||||
<span className="loading"></span>
|
||||
)}
|
||||
</p>
|
||||
<a href="https://nextjs.org/learn" className="card">
|
||||
<h3>Learn →</h3>
|
||||
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
||||
</a>
|
||||
|
||||
<div className="row">
|
||||
<Link href="https://github.com/zeit/next.js#setup">
|
||||
<a className="card">
|
||||
<h3>Getting Started →</h3>
|
||||
<p>Learn more about Next.js on GitHub and in their examples.</p>
|
||||
</a>
|
||||
</Link>
|
||||
<Link href="https://github.com/zeit/next.js/tree/master/examples">
|
||||
<a className="card">
|
||||
<h3>Examples →</h3>
|
||||
<p>Find other example boilerplates on the Next.js GitHub.</p>
|
||||
</a>
|
||||
</Link>
|
||||
<Link href="https://github.com/zeit/next.js">
|
||||
<a className="card">
|
||||
<h3>Create Next App →</h3>
|
||||
<p>Was this tool helpful? Let us know how we can improve it!</p>
|
||||
</a>
|
||||
</Link>
|
||||
</div>
|
||||
<a
|
||||
href="https://github.com/zeit/next.js/tree/master/examples"
|
||||
className="card"
|
||||
>
|
||||
<h3>Examples →</h3>
|
||||
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://zeit.co/new?filter=next.js&utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
className="card"
|
||||
>
|
||||
<h3>Deploy →</h3>
|
||||
<p>
|
||||
Instantly deploy your Next.js site to a public URL with ZEIT Now.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<style jsx>{`
|
||||
.hero {
|
||||
width: 100%;
|
||||
color: #333;
|
||||
}
|
||||
.title {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
padding-top: 80px;
|
||||
line-height: 1.15;
|
||||
font-size: 48px;
|
||||
}
|
||||
.title,
|
||||
.description {
|
||||
text-align: center;
|
||||
}
|
||||
.row {
|
||||
max-width: 880px;
|
||||
margin: 80px auto 40px;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.date {
|
||||
height: 24px;
|
||||
max-width: calc(100% - 32px)
|
||||
text-align: center;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 0 16px;
|
||||
}
|
||||
.date p {
|
||||
text-align: center;
|
||||
}
|
||||
.date span {
|
||||
width: 176px;
|
||||
text-align: center;
|
||||
}
|
||||
@keyframes Loading {
|
||||
0%{background-position:0% 50%}
|
||||
50%{background-position:100% 50%}
|
||||
100%{background-position:0% 50%}
|
||||
}
|
||||
.date .loading {
|
||||
max-width: 100%;
|
||||
height: 24px;
|
||||
border-radius: 4px;
|
||||
display: inline-block;
|
||||
background: linear-gradient(270deg, #D1D1D1, #EAEAEA);
|
||||
background-size: 200% 200%;
|
||||
animation: Loading 2s ease infinite;
|
||||
}
|
||||
.card {
|
||||
padding: 18px 18px 24px;
|
||||
width: 220px;
|
||||
text-align: left;
|
||||
text-decoration: none;
|
||||
color: #434343;
|
||||
border: 1px solid #9b9b9b;
|
||||
}
|
||||
.card:hover {
|
||||
border-color: #067df7;
|
||||
}
|
||||
.card h3 {
|
||||
margin: 0;
|
||||
color: #067df7;
|
||||
font-size: 18px;
|
||||
}
|
||||
.card p {
|
||||
margin: 0;
|
||||
padding: 12px 0 0;
|
||||
font-size: 13px;
|
||||
color: #333;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
<footer>
|
||||
<a
|
||||
href="https://zeit.co?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Powered by <img src="/zeit.svg" alt="ZEIT Logo" />
|
||||
</a>
|
||||
</footer>
|
||||
|
||||
export default Home;
|
||||
<style jsx>{`
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
padding: 0 0.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
main {
|
||||
padding: 5rem 0;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
footer {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
border-top: 1px solid #eaeaea;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
footer img {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
footer a {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
a {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.title a {
|
||||
color: #0070f3;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.title a:hover,
|
||||
.title a:focus,
|
||||
.title a:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
line-height: 1.15;
|
||||
font-size: 4rem;
|
||||
}
|
||||
|
||||
.title,
|
||||
.description {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.description {
|
||||
line-height: 1.5;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
code {
|
||||
background: #fafafa;
|
||||
border-radius: 5px;
|
||||
padding: 0.75rem;
|
||||
font-size: 1.1rem;
|
||||
font-family: Menlo, Monaco, Lucida Console, Liberation Mono,
|
||||
DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
|
||||
max-width: 800px;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin: 1rem;
|
||||
flex-basis: 45%;
|
||||
padding: 1.5rem;
|
||||
text-align: left;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
border: 1px solid #eaeaea;
|
||||
border-radius: 10px;
|
||||
transition: color 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.card:hover,
|
||||
.card:focus,
|
||||
.card:active {
|
||||
color: #0070f3;
|
||||
border-color: #0070f3;
|
||||
}
|
||||
|
||||
.card h3 {
|
||||
margin: 0 0 1rem 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.card p {
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.grid {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
||||
`}</style>
|
||||
|
||||
<style jsx global>{`
|
||||
html,
|
||||
body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
`}</style>
|
||||
</div>
|
||||
)
|
||||
|
||||
export default Home
|
||||
|
||||
10
examples/nextjs/public/zeit.svg
Normal file
10
examples/nextjs/public/zeit.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<svg width="82" height="16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill="url(#prefix__paint0_linear)" d="M9.018 0l9.019 16H0L9.018 0z"/>
|
||||
<path fill="#333" fill-rule="evenodd" d="M51.634 12.028h-6.492V2.052h6.492v1.256H46.61v3.007h4.37V7.57h-4.37v3.202h5.024v1.255zm-14.063 0h-7.235v-1.096l5.342-7.624h-5.253V2.052h7.058v1.097l-5.342 7.623h5.43v1.256zm21.88 0h6.333v-1.256h-2.423V3.308h2.423V2.052h-6.332v1.256h2.441v7.465h-2.441v1.255zm18.22 0h-1.468v-8.72h-3.36V2.052h8.225v1.256H77.67v8.72z" clip-rule="evenodd"/>
|
||||
<defs>
|
||||
<linearGradient id="prefix__paint0_linear" x1="28.022" x2="16.189" y1="22.991" y2="8.569" gradientUnits="userSpaceOnUse">
|
||||
<stop stop-color="#fff"/>
|
||||
<stop offset="1"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 794 B |
4
now.json
4
now.json
@@ -3,6 +3,10 @@
|
||||
{
|
||||
"source": "/",
|
||||
"destination": "/api/frameworks"
|
||||
},
|
||||
{
|
||||
"source": "/api/v1/frameworks",
|
||||
"destination": "/api/frameworks"
|
||||
}
|
||||
],
|
||||
"env": {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"eslint": "6.2.2",
|
||||
"eslint-config-prettier": "6.1.0",
|
||||
"husky": "3.0.4",
|
||||
"json5": "2.1.1",
|
||||
"lint-staged": "9.2.5",
|
||||
"node-fetch": "2.6.0",
|
||||
"prettier": "1.18.2"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`build` from `package.json` or `next build`"
|
||||
"placeholder": "`npm run build` or `next build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "next dev --port $PORT"
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`gatsby build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `gatsby build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "gatsby develop --port $PORT"
|
||||
@@ -62,6 +62,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/hexo.svg",
|
||||
"tagline": "Hexo is a fast, simple & powerful blog framework powered by Node.js.",
|
||||
"description": "A Hexo site, created with the Hexo CLI.",
|
||||
"website": "https://hexo.io/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -72,7 +73,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`hexo generate` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `hexo generate`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "hexo server --port $PORT"
|
||||
@@ -89,6 +90,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/eleventy.svg",
|
||||
"tagline": "11ty is a simpler static site generator written in JavaScript, created to be an alternative to Jekyll.",
|
||||
"description": "An Eleventy site, created with npm init.",
|
||||
"website": "https://www.11ty.dev/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -99,7 +101,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`npx @11ty/eleventy` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `npx @11ty/eleventy`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "npx @11ty/eleventy --serve --watch --port $PORT"
|
||||
@@ -110,18 +112,15 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Docusaurus",
|
||||
"slug": "docusaurus",
|
||||
"name": "Docusaurus 2",
|
||||
"slug": "docusaurus-2",
|
||||
"demo": "https://docusaurus.now-examples.now.sh",
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/docusaurus.svg",
|
||||
"tagline": "Docusaurus makes it easy to maintain Open Source documentation websites.",
|
||||
"description": "A static Docusaurus site that makes it easy to maintain OSS documentation.",
|
||||
"website": "https://v2.docusaurus.io",
|
||||
"detectors": {
|
||||
"some": [
|
||||
{
|
||||
"path": "package.json",
|
||||
"matchContent": "\"(dev)?(d|D)ependencies\":\\s*{[^}]*\"docusaurus\":\\s*\".+?\"[^}]*}"
|
||||
},
|
||||
{
|
||||
"path": "package.json",
|
||||
"matchContent": "\"(dev)?(d|D)ependencies\":\\s*{[^}]*\"@docusaurus\\/core\":\\s*\".+?\"[^}]*}"
|
||||
@@ -130,7 +129,35 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`docusaurus-build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `docusaurus build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "docusaurus start --port $PORT"
|
||||
},
|
||||
"outputDirectory": {
|
||||
"value": "build"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Docusaurus 1",
|
||||
"slug": "docusaurus",
|
||||
"demo": "https://docusaurus.now-examples.now.sh",
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/docusaurus.svg",
|
||||
"tagline": "Docusaurus makes it easy to maintain Open Source documentation websites.",
|
||||
"description": "A static Docusaurus site that makes it easy to maintain OSS documentation.",
|
||||
"website": "https://docusaurus.io/",
|
||||
"detectors": {
|
||||
"some": [
|
||||
{
|
||||
"path": "package.json",
|
||||
"matchContent": "\"(dev)?(d|D)ependencies\":\\s*{[^}]*\"docusaurus\":\\s*\".+?\"[^}]*}"
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`npm run build` or `docusaurus-build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "docusaurus-start --port $PORT"
|
||||
@@ -158,7 +185,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`preact build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `preact build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "preact watch --port $PORT"
|
||||
@@ -175,6 +202,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/ember.svg",
|
||||
"tagline": "Ember.js helps webapp developers be more productive out of the box.",
|
||||
"description": "An Ember app, created with the Ember CLI.",
|
||||
"website": "https://emberjs.com/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -185,7 +213,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`ember build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `ember build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "ember serve --port $PORT"
|
||||
@@ -213,7 +241,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`vue-cli-service build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `vue-cli-service build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "vue-cli-service serve --port $PORT"
|
||||
@@ -229,6 +257,7 @@
|
||||
"demo": "https://scully.now-examples.now.sh",
|
||||
"tagline": "Scully is a static site generator for Angular.",
|
||||
"description": "The Static Site Generator for Angular apps.",
|
||||
"website": "https://github.com/scullyio/scully",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -239,7 +268,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`ng build && scully` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `ng build && scully`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "ng serve --port $PORT"
|
||||
@@ -267,7 +296,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`ng build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `ng build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "ng serve --port $PORT"
|
||||
@@ -284,6 +313,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/polymer.svg",
|
||||
"tagline": "Polymer is an open-source webapps library from Google, for building using Web Components.",
|
||||
"description": "A Polymer app, created with the Polymer CLI.",
|
||||
"website": "https://www.polymer-project.org/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -294,7 +324,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`polymer build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `polymer build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "polymer serve --port $PORT"
|
||||
@@ -322,7 +352,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`rollup -c` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `rollup -c`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "sirv public --single --dev --port $PORT"
|
||||
@@ -350,7 +380,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`build` from `package.json`"
|
||||
"placeholder": "npm run build"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "stencil build --dev --watch --serve --port $PORT"
|
||||
@@ -382,7 +412,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`react-scripts build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `react-scripts build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "react-scripts start"
|
||||
@@ -399,6 +429,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/gridsome.svg",
|
||||
"tagline": "Gridsome is a Vue.js-powered framework for building websites & apps that are fast by default.",
|
||||
"description": "A Gridsome app, created with the Gridsome CLI.",
|
||||
"website": "https://gridsome.org/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -409,7 +440,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`gridsome build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `gridsome build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "gridsome develop -p $PORT"
|
||||
@@ -437,7 +468,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`umi build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `umi build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "umi dev --port $PORT"
|
||||
@@ -465,7 +496,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`sapper export` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `sapper export`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "sapper dev --port $PORT"
|
||||
@@ -482,6 +513,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/saber.svg",
|
||||
"tagline": "Saber is a framework for building static sites in Vue.js that supports data from any source.",
|
||||
"description": "A Saber site, created with npm init.",
|
||||
"website": "https://saber.land/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -492,7 +524,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`saber build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `saber build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "saber --port $PORT"
|
||||
@@ -509,6 +541,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/stencil.svg",
|
||||
"tagline": "Stencil is a powerful toolchain for building Progressive Web Apps and Design Systems.",
|
||||
"description": "A Stencil site, created with the Stencil CLI.",
|
||||
"website": "https://stenciljs.com/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -519,7 +552,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`stencil build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `stencil build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "stencil build --dev --watch --serve --port $PORT"
|
||||
@@ -547,7 +580,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`nuxt build` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `nuxt build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "nuxt"
|
||||
@@ -580,7 +613,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"value": "hugo -D --gc"
|
||||
"placeholder": "`npm run build` or `hugo -D --gc`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "hugo server -D -w -p $PORT"
|
||||
@@ -597,6 +630,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/jekyll.svg",
|
||||
"tagline": "Jekyll makes it super easy to transform your plain text into static websites and blogs.",
|
||||
"description": "A Jekyll site, created with the Jekyll CLI.",
|
||||
"website": "https://jekyllrb.com/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -606,7 +640,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"value": "jekyll build"
|
||||
"placeholder": "`npm run build` or `jekyll build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "bundle exec jekyll serve --watch --port $PORT"
|
||||
@@ -623,6 +657,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/brunch.svg",
|
||||
"tagline": "Brunch is a fast and simple webapp build tool with seamless incremental compilation for rapid development.",
|
||||
"description": "A Brunch app, created with the Brunch CLI.",
|
||||
"website": "https://brunch.io/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -632,7 +667,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`brunch build --production` or `build` from `package.json`"
|
||||
"placeholder": "`npm run build` or `brunch build --production`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "brunch watch --server --port $PORT"
|
||||
@@ -649,6 +684,7 @@
|
||||
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/middleman.svg",
|
||||
"tagline": "Middleman is a static site generator that uses all the shortcuts and tools in modern web development.",
|
||||
"description": "A Middleman app, created with the Middleman CLI.",
|
||||
"website": "https://middlemanapp.com/",
|
||||
"detectors": {
|
||||
"every": [
|
||||
{
|
||||
@@ -658,7 +694,7 @@
|
||||
},
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"value": "bundle exec middleman build"
|
||||
"value": "`npm run build` or `bundle exec middleman build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"value": "bundle exec middleman server -p $PORT"
|
||||
@@ -675,7 +711,7 @@
|
||||
"description": "No framework or a unoptimized framework.",
|
||||
"settings": {
|
||||
"buildCommand": {
|
||||
"placeholder": "`build` or `now-build` from `package.json` if it exists"
|
||||
"placeholder": "`npm run now-build` or `npm run build`"
|
||||
},
|
||||
"devCommand": {
|
||||
"placeholder": "None"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/frameworks",
|
||||
"version": "0.0.11-canary.0",
|
||||
"version": "0.0.12",
|
||||
"main": "frameworks.json",
|
||||
"license": "UNLICENSED"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/build-utils",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"license": "MIT",
|
||||
"main": "./dist/index.js",
|
||||
"types": "./dist/index.d.js",
|
||||
|
||||
@@ -99,6 +99,11 @@ export async function execCommand(command: string, options: SpawnOptions = {}) {
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function getNodeBinPath({ cwd }: { cwd: string }) {
|
||||
const { stdout } = await execAsync('npm', ['bin'], { cwd });
|
||||
return stdout.trim();
|
||||
}
|
||||
|
||||
async function chmodPlusX(fsPath: string) {
|
||||
const s = await fs.stat(fsPath);
|
||||
const newMode = s.mode | 64 | 8 | 1; // eslint-disable-line no-bitwise
|
||||
@@ -189,6 +194,46 @@ async function scanParentDirs(destPath: string, readPackageJson = false) {
|
||||
return { hasPackageLockJson, packageJson };
|
||||
}
|
||||
|
||||
interface WalkParentDirsProps {
|
||||
/**
|
||||
* The highest directory, typically the workPath root of the project.
|
||||
* If this directory is reached and it doesn't contain the file, null is returned.
|
||||
*/
|
||||
base: string;
|
||||
/**
|
||||
* The directory to start searching, typically the same directory of the entrypoint.
|
||||
* If this directory doesn't contain the file, the parent is checked, etc.
|
||||
*/
|
||||
start: string;
|
||||
/**
|
||||
* The name of the file to search for, typically `package.json` or `Gemfile`.
|
||||
*/
|
||||
filename: string;
|
||||
}
|
||||
|
||||
export async function walkParentDirs({
|
||||
base,
|
||||
start,
|
||||
filename,
|
||||
}: WalkParentDirsProps): Promise<string | null> {
|
||||
assert(path.isAbsolute(base), 'Expected "base" to be absolute path');
|
||||
assert(path.isAbsolute(start), 'Expected "start" to be absolute path');
|
||||
let parent = '';
|
||||
|
||||
for (let current = start; base.length <= current.length; current = parent) {
|
||||
const fullPath = path.join(current, filename);
|
||||
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
if (await fs.pathExists(fullPath)) {
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
parent = path.dirname(current);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
export async function runNpmInstall(
|
||||
destPath: string,
|
||||
args: string[] = [],
|
||||
@@ -201,30 +246,31 @@ export async function runNpmInstall(
|
||||
}
|
||||
|
||||
assert(path.isAbsolute(destPath));
|
||||
|
||||
let commandArgs = args;
|
||||
debug(`Installing to ${destPath}`);
|
||||
const { hasPackageLockJson } = await scanParentDirs(destPath);
|
||||
|
||||
const { hasPackageLockJson } = await scanParentDirs(destPath);
|
||||
const opts: SpawnOptions = { cwd: destPath, ...spawnOpts };
|
||||
const env = opts.env ? { ...opts.env } : { ...process.env };
|
||||
delete env.NODE_ENV;
|
||||
opts.env = env;
|
||||
|
||||
let command: 'npm' | 'yarn';
|
||||
let commandArgs: string[];
|
||||
|
||||
if (hasPackageLockJson) {
|
||||
commandArgs = args.filter(a => a !== '--prefer-offline');
|
||||
await spawnAsync(
|
||||
'npm',
|
||||
commandArgs.concat(['install', '--no-audit', '--unsafe-perm']),
|
||||
opts
|
||||
);
|
||||
command = 'npm';
|
||||
commandArgs = args
|
||||
.filter(a => a !== '--prefer-offline')
|
||||
.concat(['install', '--no-audit', '--unsafe-perm']);
|
||||
} else {
|
||||
await spawnAsync(
|
||||
'yarn',
|
||||
commandArgs.concat(['--ignore-engines', '--cwd', destPath]),
|
||||
opts
|
||||
);
|
||||
command = 'yarn';
|
||||
commandArgs = args.concat(['install', '--ignore-engines']);
|
||||
}
|
||||
|
||||
if (process.env.NPM_ONLY_PRODUCTION) {
|
||||
commandArgs.push('--production');
|
||||
}
|
||||
await spawnAsync(command, commandArgs, opts);
|
||||
}
|
||||
|
||||
export async function runBundleInstall(
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
spawnAsync,
|
||||
execCommand,
|
||||
spawnCommand,
|
||||
walkParentDirs,
|
||||
installDependencies,
|
||||
runPackageJsonScript,
|
||||
runNpmInstall,
|
||||
@@ -20,6 +21,7 @@ import {
|
||||
runShellScript,
|
||||
getNodeVersion,
|
||||
getSpawnOptions,
|
||||
getNodeBinPath,
|
||||
} from './fs/run-user-scripts';
|
||||
import {
|
||||
getLatestNodeVersion,
|
||||
@@ -48,6 +50,8 @@ export {
|
||||
runPackageJsonScript,
|
||||
execCommand,
|
||||
spawnCommand,
|
||||
walkParentDirs,
|
||||
getNodeBinPath,
|
||||
runNpmInstall,
|
||||
runBundleInstall,
|
||||
runPipInstall,
|
||||
|
||||
@@ -18,7 +18,7 @@ module.exports = {
|
||||
{
|
||||
resolve: `gatsby-plugin-manifest`,
|
||||
options: {
|
||||
name: `gatsby-starter-default`,
|
||||
name: `05-zero-config-gatsby`,
|
||||
short_name: `starter`,
|
||||
start_url: `/`,
|
||||
background_color: `#663399`,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "gatsby-starter-default",
|
||||
"name": "05-zero-config-gatsby",
|
||||
"private": true,
|
||||
"description": "A simple starter to get up and developing quickly with Gatsby",
|
||||
"version": "0.1.0",
|
||||
|
||||
1
packages/now-build-utils/test/fixtures/18-install-only-production/.gitignore
vendored
Normal file
1
packages/now-build-utils/test/fixtures/18-install-only-production/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!package-lock.json
|
||||
12
packages/now-build-utils/test/fixtures/18-install-only-production/now.json
vendored
Normal file
12
packages/now-build-utils/test/fixtures/18-install-only-production/now.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": 2,
|
||||
"build": { "env": { "NPM_ONLY_PRODUCTION": "1" } },
|
||||
"builds": [
|
||||
{ "src": "npm/package.json", "use": "@now/static-build" },
|
||||
{ "src": "yarn/package.json", "use": "@now/static-build" }
|
||||
],
|
||||
"probes": [
|
||||
{ "path": "/npm", "mustContain": "npm-prod:RANDOMNESS_PLACEHOLDER" },
|
||||
{ "path": "/yarn", "mustContain": "yarn-prod:RANDOMNESS_PLACEHOLDER" }
|
||||
]
|
||||
}
|
||||
24
packages/now-build-utils/test/fixtures/18-install-only-production/npm/build.js
vendored
Normal file
24
packages/now-build-utils/test/fixtures/18-install-only-production/npm/build.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
function found(pkgname) {
|
||||
try {
|
||||
require(pkgname);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const production = found('copee');
|
||||
const development = found('tls-check');
|
||||
|
||||
if (!production) {
|
||||
throw new Error('Expected production dependencies to be installed.');
|
||||
}
|
||||
|
||||
if (development) {
|
||||
throw new Error('Expected development dependencies to _NOT_ be installed.');
|
||||
}
|
||||
|
||||
// This is to satisfy `@now/static-build` which needs a `dist` directory.
|
||||
const { execSync } = require('child_process');
|
||||
execSync('mkdir dist');
|
||||
execSync('echo "npm-prod:RANDOMNESS_PLACEHOLDER" > dist/index.html');
|
||||
17
packages/now-build-utils/test/fixtures/18-install-only-production/npm/package-lock.json
generated
vendored
Normal file
17
packages/now-build-utils/test/fixtures/18-install-only-production/npm/package-lock.json
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"copee": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/copee/-/copee-1.0.6.tgz",
|
||||
"integrity": "sha512-l5mIlUejgG4Q+pb8yoDPDFI6ehjx4u6vaUd2tv4HxaaZ3vMkuQmmFStU1BNmomj3DXtht6mjD4ZiUOVu72v/QA=="
|
||||
},
|
||||
"tls-check": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/tls-check/-/tls-check-1.0.0.tgz",
|
||||
"integrity": "sha512-C3jinh6+ttd8QGaJYoHGlbckwh/7MuuO22CeeQcs2U5XIg5Har3Uaj0NWIB4M97pZQDhFWwT9G8tD5GXqmR2sQ==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
}
|
||||
12
packages/now-build-utils/test/fixtures/18-install-only-production/npm/package.json
vendored
Normal file
12
packages/now-build-utils/test/fixtures/18-install-only-production/npm/package.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "node build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"copee": "1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tls-check": "1.0.0"
|
||||
}
|
||||
}
|
||||
24
packages/now-build-utils/test/fixtures/18-install-only-production/yarn/build.js
vendored
Normal file
24
packages/now-build-utils/test/fixtures/18-install-only-production/yarn/build.js
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
function found(pkgname) {
|
||||
try {
|
||||
require(pkgname);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
const production = found('copee');
|
||||
const development = found('tls-check');
|
||||
|
||||
if (!production) {
|
||||
throw new Error('Expected production dependencies to be installed.');
|
||||
}
|
||||
|
||||
if (development) {
|
||||
throw new Error('Expected development dependencies to _NOT_ be installed.');
|
||||
}
|
||||
|
||||
// This is to satisfy `@now/static-build` which needs a `dist` directory.
|
||||
const { execSync } = require('child_process');
|
||||
execSync('mkdir dist');
|
||||
execSync('echo "yarn-prod:RANDOMNESS_PLACEHOLDER" > dist/index.html');
|
||||
12
packages/now-build-utils/test/fixtures/18-install-only-production/yarn/package.json
vendored
Normal file
12
packages/now-build-utils/test/fixtures/18-install-only-production/yarn/package.json
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"build": "node build.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"copee": "1.0.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tls-check": "1.0.0"
|
||||
}
|
||||
}
|
||||
109
packages/now-build-utils/test/unit.walk.test.ts
vendored
Normal file
109
packages/now-build-utils/test/unit.walk.test.ts
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
import { walkParentDirs } from '../';
|
||||
import { strict } from 'assert';
|
||||
import { join } from 'path';
|
||||
import { promises } from 'fs';
|
||||
const { deepEqual, notDeepEqual, fail } = strict;
|
||||
const { readFile } = promises;
|
||||
const fixture = (name: string) => join(__dirname, 'walk', name);
|
||||
const filename = 'file.txt';
|
||||
|
||||
async function assertContent(target: string | null, contents: string) {
|
||||
notDeepEqual(target, null);
|
||||
const actual = await readFile(target!, 'utf8');
|
||||
deepEqual(actual.trim(), contents.trim());
|
||||
}
|
||||
|
||||
describe('Test `walkParentDirs`', () => {
|
||||
it('should throw when `base` is relative', async () => {
|
||||
const base = './relative';
|
||||
const start = __dirname;
|
||||
try {
|
||||
await walkParentDirs({ base, start, filename });
|
||||
fail('Expected error');
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
deepEqual(
|
||||
(error as Error).message,
|
||||
'Expected "base" to be absolute path'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('should throw when `start` is relative', async () => {
|
||||
const base = __dirname;
|
||||
const start = './relative';
|
||||
try {
|
||||
await walkParentDirs({ base, start, filename });
|
||||
fail('Expected error');
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
deepEqual(
|
||||
(error as Error).message,
|
||||
'Expected "start" to be absolute path'
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
it('should find nested one', async () => {
|
||||
const base = fixture('every-directory');
|
||||
const start = base;
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
await assertContent(target, 'First');
|
||||
});
|
||||
|
||||
it('should find nested two', async () => {
|
||||
const base = fixture('every-directory');
|
||||
const start = join(base, 'two');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
await assertContent(target, 'Second');
|
||||
});
|
||||
|
||||
it('should find nested three', async () => {
|
||||
const base = fixture('every-directory');
|
||||
const start = join(base, 'two', 'three');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
await assertContent(target, 'Third');
|
||||
});
|
||||
|
||||
it('should not find nested one', async () => {
|
||||
const base = fixture('not-found');
|
||||
const start = base;
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
deepEqual(target, null);
|
||||
});
|
||||
|
||||
it('should not find nested two', async () => {
|
||||
const base = fixture('not-found');
|
||||
const start = join(base, 'two');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
deepEqual(target, null);
|
||||
});
|
||||
|
||||
it('should not find nested three', async () => {
|
||||
const base = fixture('not-found');
|
||||
const start = join(base, 'two', 'three');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
deepEqual(target, null);
|
||||
});
|
||||
|
||||
it('should find only one', async () => {
|
||||
const base = fixture('only-one');
|
||||
const start = join(base, 'two', 'three');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
await assertContent(target, 'First');
|
||||
});
|
||||
|
||||
it('should find only two', async () => {
|
||||
const base = fixture('only-two');
|
||||
const start = join(base, 'two', 'three');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
await assertContent(target, 'Second');
|
||||
});
|
||||
|
||||
it('should find only three', async () => {
|
||||
const base = fixture('only-three');
|
||||
const start = join(base, 'two', 'three');
|
||||
const target = await walkParentDirs({ base, start, filename });
|
||||
await assertContent(target, 'Third');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
First
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Second
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Third
|
||||
1
packages/now-build-utils/test/walk/not-found/another.txt
Normal file
1
packages/now-build-utils/test/walk/not-found/another.txt
Normal file
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
1
packages/now-build-utils/test/walk/only-one/another.txt
Normal file
1
packages/now-build-utils/test/walk/only-one/another.txt
Normal file
@@ -0,0 +1 @@
|
||||
Another
|
||||
1
packages/now-build-utils/test/walk/only-one/file.txt
Normal file
1
packages/now-build-utils/test/walk/only-one/file.txt
Normal file
@@ -0,0 +1 @@
|
||||
First
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Third
|
||||
1
packages/now-build-utils/test/walk/only-two/another.txt
Normal file
1
packages/now-build-utils/test/walk/only-two/another.txt
Normal file
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
1
packages/now-build-utils/test/walk/only-two/two/file.txt
Normal file
1
packages/now-build-utils/test/walk/only-two/two/file.txt
Normal file
@@ -0,0 +1 @@
|
||||
Second
|
||||
@@ -0,0 +1 @@
|
||||
Another
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@now/cgi",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -8,7 +8,6 @@
|
||||
"directory": "packages/now-cgi"
|
||||
},
|
||||
"scripts": {
|
||||
"test-integration": "best -I test/*.js",
|
||||
"prepublish": "./build.sh"
|
||||
},
|
||||
"files": [
|
||||
@@ -19,7 +18,6 @@
|
||||
"fs-extra": "7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@zeit/best": "0.4.3",
|
||||
"rmfr": "2.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,862 +0,0 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
"@mrmlnc/readdir-enhanced@^2.2.1":
|
||||
version "2.2.1"
|
||||
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
|
||||
dependencies:
|
||||
call-me-maybe "^1.0.1"
|
||||
glob-to-regexp "^0.3.0"
|
||||
|
||||
"@nodelib/fs.stat@^1.0.1":
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.3.tgz#2b5a3ab3f918cca48a8c754c08168e3f03eba61b"
|
||||
|
||||
"@zeit/best@0.4.3":
|
||||
version "0.4.3"
|
||||
resolved "https://registry.npmjs.org/@zeit/best/-/best-0.4.3.tgz#eaebdfa8b24121a97b1753501ea8c9330d549b30"
|
||||
dependencies:
|
||||
arg "1.0.0"
|
||||
chalk "2.3.1"
|
||||
diff "3.5.0"
|
||||
globby "8.0.0"
|
||||
signal-exit "3.0.2"
|
||||
|
||||
ansi-styles@^3.2.0:
|
||||
version "3.2.1"
|
||||
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
|
||||
dependencies:
|
||||
color-convert "^1.9.0"
|
||||
|
||||
append-type@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/append-type/-/append-type-1.0.1.tgz#e29a6eb22cec0c0b9b93063b3cf6b10d9e0c60f4"
|
||||
|
||||
arg@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/arg/-/arg-1.0.0.tgz#444d885a4e25b121640b55155ef7cd03975d6050"
|
||||
|
||||
arr-diff@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520"
|
||||
|
||||
arr-flatten@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1"
|
||||
|
||||
arr-union@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4"
|
||||
|
||||
array-to-sentence@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/array-to-sentence/-/array-to-sentence-1.1.0.tgz#c804956dafa53232495b205a9452753a258d39fc"
|
||||
|
||||
array-union@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
|
||||
dependencies:
|
||||
array-uniq "^1.0.1"
|
||||
|
||||
array-uniq@^1.0.1:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
|
||||
|
||||
array-unique@^0.3.2:
|
||||
version "0.3.2"
|
||||
resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"
|
||||
|
||||
arrify@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
|
||||
|
||||
assert-valid-glob-opts@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/assert-valid-glob-opts/-/assert-valid-glob-opts-1.0.0.tgz#ab9b5438ec5e929f5bb08201819affb1227f730a"
|
||||
dependencies:
|
||||
glob-option-error "^1.0.0"
|
||||
validate-glob-opts "^1.0.0"
|
||||
|
||||
assign-symbols@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367"
|
||||
|
||||
atob@^2.1.1:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
|
||||
|
||||
balanced-match@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
|
||||
|
||||
base@^0.11.1:
|
||||
version "0.11.2"
|
||||
resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f"
|
||||
dependencies:
|
||||
cache-base "^1.0.1"
|
||||
class-utils "^0.3.5"
|
||||
component-emitter "^1.2.1"
|
||||
define-property "^1.0.0"
|
||||
isobject "^3.0.1"
|
||||
mixin-deep "^1.2.0"
|
||||
pascalcase "^0.1.1"
|
||||
|
||||
brace-expansion@^1.1.7:
|
||||
version "1.1.11"
|
||||
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
|
||||
dependencies:
|
||||
balanced-match "^1.0.0"
|
||||
concat-map "0.0.1"
|
||||
|
||||
braces@^2.3.1:
|
||||
version "2.3.2"
|
||||
resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729"
|
||||
dependencies:
|
||||
arr-flatten "^1.1.0"
|
||||
array-unique "^0.3.2"
|
||||
extend-shallow "^2.0.1"
|
||||
fill-range "^4.0.0"
|
||||
isobject "^3.0.1"
|
||||
repeat-element "^1.1.2"
|
||||
snapdragon "^0.8.1"
|
||||
snapdragon-node "^2.0.1"
|
||||
split-string "^3.0.2"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
cache-base@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2"
|
||||
dependencies:
|
||||
collection-visit "^1.0.0"
|
||||
component-emitter "^1.2.1"
|
||||
get-value "^2.0.6"
|
||||
has-value "^1.0.0"
|
||||
isobject "^3.0.1"
|
||||
set-value "^2.0.0"
|
||||
to-object-path "^0.3.0"
|
||||
union-value "^1.0.0"
|
||||
unset-value "^1.0.0"
|
||||
|
||||
call-me-maybe@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b"
|
||||
|
||||
chalk@2.3.1:
|
||||
version "2.3.1"
|
||||
resolved "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796"
|
||||
dependencies:
|
||||
ansi-styles "^3.2.0"
|
||||
escape-string-regexp "^1.0.5"
|
||||
supports-color "^5.2.0"
|
||||
|
||||
class-utils@^0.3.5:
|
||||
version "0.3.6"
|
||||
resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463"
|
||||
dependencies:
|
||||
arr-union "^3.1.0"
|
||||
define-property "^0.2.5"
|
||||
isobject "^3.0.0"
|
||||
static-extend "^0.1.1"
|
||||
|
||||
collection-visit@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0"
|
||||
dependencies:
|
||||
map-visit "^1.0.0"
|
||||
object-visit "^1.0.0"
|
||||
|
||||
color-convert@^1.9.0:
|
||||
version "1.9.3"
|
||||
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
|
||||
dependencies:
|
||||
color-name "1.1.3"
|
||||
|
||||
color-name@1.1.3:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
|
||||
|
||||
component-emitter@^1.2.1:
|
||||
version "1.2.1"
|
||||
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6"
|
||||
|
||||
concat-map@0.0.1:
|
||||
version "0.0.1"
|
||||
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
|
||||
|
||||
copy-descriptor@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d"
|
||||
|
||||
debug@^2.2.0, debug@^2.3.3:
|
||||
version "2.6.9"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
|
||||
dependencies:
|
||||
ms "2.0.0"
|
||||
|
||||
decode-uri-component@^0.2.0:
|
||||
version "0.2.0"
|
||||
resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545"
|
||||
|
||||
define-property@^0.2.5:
|
||||
version "0.2.5"
|
||||
resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116"
|
||||
dependencies:
|
||||
is-descriptor "^0.1.0"
|
||||
|
||||
define-property@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6"
|
||||
dependencies:
|
||||
is-descriptor "^1.0.0"
|
||||
|
||||
define-property@^2.0.2:
|
||||
version "2.0.2"
|
||||
resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d"
|
||||
dependencies:
|
||||
is-descriptor "^1.0.2"
|
||||
isobject "^3.0.1"
|
||||
|
||||
diff@3.5.0:
|
||||
version "3.5.0"
|
||||
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
|
||||
|
||||
dir-glob@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034"
|
||||
dependencies:
|
||||
arrify "^1.0.1"
|
||||
path-type "^3.0.0"
|
||||
|
||||
escape-string-regexp@^1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||
|
||||
expand-brackets@^2.1.4:
|
||||
version "2.1.4"
|
||||
resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622"
|
||||
dependencies:
|
||||
debug "^2.3.3"
|
||||
define-property "^0.2.5"
|
||||
extend-shallow "^2.0.1"
|
||||
posix-character-classes "^0.1.0"
|
||||
regex-not "^1.0.0"
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
extend-shallow@^2.0.1:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f"
|
||||
dependencies:
|
||||
is-extendable "^0.1.0"
|
||||
|
||||
extend-shallow@^3.0.0, extend-shallow@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8"
|
||||
dependencies:
|
||||
assign-symbols "^1.0.0"
|
||||
is-extendable "^1.0.1"
|
||||
|
||||
extglob@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543"
|
||||
dependencies:
|
||||
array-unique "^0.3.2"
|
||||
define-property "^1.0.0"
|
||||
expand-brackets "^2.1.4"
|
||||
extend-shallow "^2.0.1"
|
||||
fragment-cache "^0.2.1"
|
||||
regex-not "^1.0.0"
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
fast-glob@^2.0.2:
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.3.tgz#d09d378e9ef6b0076a0fa1ba7519d9d4d9699c28"
|
||||
dependencies:
|
||||
"@mrmlnc/readdir-enhanced" "^2.2.1"
|
||||
"@nodelib/fs.stat" "^1.0.1"
|
||||
glob-parent "^3.1.0"
|
||||
is-glob "^4.0.0"
|
||||
merge2 "^1.2.1"
|
||||
micromatch "^3.1.10"
|
||||
|
||||
fill-range@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7"
|
||||
dependencies:
|
||||
extend-shallow "^2.0.1"
|
||||
is-number "^3.0.0"
|
||||
repeat-string "^1.6.1"
|
||||
to-regex-range "^2.1.0"
|
||||
|
||||
for-in@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
|
||||
|
||||
fragment-cache@^0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19"
|
||||
dependencies:
|
||||
map-cache "^0.2.2"
|
||||
|
||||
fs-extra@7.0.0:
|
||||
version "7.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-7.0.0.tgz#8cc3f47ce07ef7b3593a11b9fb245f7e34c041d6"
|
||||
dependencies:
|
||||
graceful-fs "^4.1.2"
|
||||
jsonfile "^4.0.0"
|
||||
universalify "^0.1.0"
|
||||
|
||||
fs.realpath@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
|
||||
|
||||
get-value@^2.0.3, get-value@^2.0.6:
|
||||
version "2.0.6"
|
||||
resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28"
|
||||
|
||||
glob-option-error@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/glob-option-error/-/glob-option-error-1.0.0.tgz#57cc65def9c7d5c1461baf13129bb5403cff6176"
|
||||
|
||||
glob-parent@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae"
|
||||
dependencies:
|
||||
is-glob "^3.1.0"
|
||||
path-dirname "^1.0.0"
|
||||
|
||||
glob-to-regexp@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab"
|
||||
|
||||
glob@^7.0.5, glob@^7.1.2:
|
||||
version "7.1.3"
|
||||
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1"
|
||||
dependencies:
|
||||
fs.realpath "^1.0.0"
|
||||
inflight "^1.0.4"
|
||||
inherits "2"
|
||||
minimatch "^3.0.4"
|
||||
once "^1.3.0"
|
||||
path-is-absolute "^1.0.0"
|
||||
|
||||
globby@8.0.0:
|
||||
version "8.0.0"
|
||||
resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.0.tgz#e6f8340ead9a52fa417ec0e75ae664ae0026f5c6"
|
||||
dependencies:
|
||||
array-union "^1.0.1"
|
||||
dir-glob "^2.0.0"
|
||||
fast-glob "^2.0.2"
|
||||
glob "^7.1.2"
|
||||
ignore "^3.3.5"
|
||||
pify "^3.0.0"
|
||||
slash "^1.0.0"
|
||||
|
||||
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6:
|
||||
version "4.1.14"
|
||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.14.tgz#1b6e8362ef8c5ecb5da799901f39297e3054773a"
|
||||
|
||||
has-flag@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
|
||||
|
||||
has-value@^0.3.1:
|
||||
version "0.3.1"
|
||||
resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f"
|
||||
dependencies:
|
||||
get-value "^2.0.3"
|
||||
has-values "^0.1.4"
|
||||
isobject "^2.0.0"
|
||||
|
||||
has-value@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177"
|
||||
dependencies:
|
||||
get-value "^2.0.6"
|
||||
has-values "^1.0.0"
|
||||
isobject "^3.0.0"
|
||||
|
||||
has-values@^0.1.4:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771"
|
||||
|
||||
has-values@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f"
|
||||
dependencies:
|
||||
is-number "^3.0.0"
|
||||
kind-of "^4.0.0"
|
||||
|
||||
ignore@^3.3.5:
|
||||
version "3.3.10"
|
||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043"
|
||||
|
||||
indexed-filter@^1.0.0:
|
||||
version "1.0.3"
|
||||
resolved "https://registry.yarnpkg.com/indexed-filter/-/indexed-filter-1.0.3.tgz#7911439191cac588188464640a8db4f6b324973d"
|
||||
dependencies:
|
||||
append-type "^1.0.1"
|
||||
|
||||
inflight@^1.0.4:
|
||||
version "1.0.6"
|
||||
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
|
||||
dependencies:
|
||||
once "^1.3.0"
|
||||
wrappy "1"
|
||||
|
||||
inherits@2:
|
||||
version "2.0.3"
|
||||
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
|
||||
|
||||
inspect-with-kind@^1.0.4:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/inspect-with-kind/-/inspect-with-kind-1.0.5.tgz#fce151d4ce89722c82ca8e9860bb96f9167c316c"
|
||||
dependencies:
|
||||
kind-of "^6.0.2"
|
||||
|
||||
is-accessor-descriptor@^0.1.6:
|
||||
version "0.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6"
|
||||
dependencies:
|
||||
kind-of "^3.0.2"
|
||||
|
||||
is-accessor-descriptor@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656"
|
||||
dependencies:
|
||||
kind-of "^6.0.0"
|
||||
|
||||
is-buffer@^1.1.5:
|
||||
version "1.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be"
|
||||
|
||||
is-data-descriptor@^0.1.4:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56"
|
||||
dependencies:
|
||||
kind-of "^3.0.2"
|
||||
|
||||
is-data-descriptor@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7"
|
||||
dependencies:
|
||||
kind-of "^6.0.0"
|
||||
|
||||
is-descriptor@^0.1.0:
|
||||
version "0.1.6"
|
||||
resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca"
|
||||
dependencies:
|
||||
is-accessor-descriptor "^0.1.6"
|
||||
is-data-descriptor "^0.1.4"
|
||||
kind-of "^5.0.0"
|
||||
|
||||
is-descriptor@^1.0.0, is-descriptor@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec"
|
||||
dependencies:
|
||||
is-accessor-descriptor "^1.0.0"
|
||||
is-data-descriptor "^1.0.0"
|
||||
kind-of "^6.0.2"
|
||||
|
||||
is-extendable@^0.1.0, is-extendable@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89"
|
||||
|
||||
is-extendable@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4"
|
||||
dependencies:
|
||||
is-plain-object "^2.0.4"
|
||||
|
||||
is-extglob@^2.1.0, is-extglob@^2.1.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
|
||||
|
||||
is-glob@^3.1.0:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a"
|
||||
dependencies:
|
||||
is-extglob "^2.1.0"
|
||||
|
||||
is-glob@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.0.tgz#9521c76845cc2610a85203ddf080a958c2ffabc0"
|
||||
dependencies:
|
||||
is-extglob "^2.1.1"
|
||||
|
||||
is-number@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195"
|
||||
dependencies:
|
||||
kind-of "^3.0.2"
|
||||
|
||||
is-plain-obj@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-1.1.0.tgz#71a50c8429dfca773c92a390a4a03b39fcd51d3e"
|
||||
|
||||
is-plain-object@^2.0.1, is-plain-object@^2.0.3, is-plain-object@^2.0.4:
|
||||
version "2.0.4"
|
||||
resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677"
|
||||
dependencies:
|
||||
isobject "^3.0.1"
|
||||
|
||||
is-windows@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
|
||||
|
||||
isarray@1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
|
||||
|
||||
isobject@^2.0.0:
|
||||
version "2.1.0"
|
||||
resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89"
|
||||
dependencies:
|
||||
isarray "1.0.0"
|
||||
|
||||
isobject@^3.0.0, isobject@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df"
|
||||
|
||||
jsonfile@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-4.0.0.tgz#8771aae0799b64076b76640fca058f9c10e33ecb"
|
||||
optionalDependencies:
|
||||
graceful-fs "^4.1.6"
|
||||
|
||||
kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0:
|
||||
version "3.2.2"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64"
|
||||
dependencies:
|
||||
is-buffer "^1.1.5"
|
||||
|
||||
kind-of@^4.0.0:
|
||||
version "4.0.0"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57"
|
||||
dependencies:
|
||||
is-buffer "^1.1.5"
|
||||
|
||||
kind-of@^5.0.0:
|
||||
version "5.1.0"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d"
|
||||
|
||||
kind-of@^6.0.0, kind-of@^6.0.2:
|
||||
version "6.0.2"
|
||||
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
|
||||
|
||||
map-cache@^0.2.2:
|
||||
version "0.2.2"
|
||||
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
|
||||
|
||||
map-visit@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f"
|
||||
dependencies:
|
||||
object-visit "^1.0.0"
|
||||
|
||||
merge2@^1.2.1:
|
||||
version "1.2.3"
|
||||
resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.3.tgz#7ee99dbd69bb6481689253f018488a1b902b0ed5"
|
||||
|
||||
micromatch@^3.1.10:
|
||||
version "3.1.10"
|
||||
resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23"
|
||||
dependencies:
|
||||
arr-diff "^4.0.0"
|
||||
array-unique "^0.3.2"
|
||||
braces "^2.3.1"
|
||||
define-property "^2.0.2"
|
||||
extend-shallow "^3.0.2"
|
||||
extglob "^2.0.4"
|
||||
fragment-cache "^0.2.1"
|
||||
kind-of "^6.0.2"
|
||||
nanomatch "^1.2.9"
|
||||
object.pick "^1.3.0"
|
||||
regex-not "^1.0.0"
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.2"
|
||||
|
||||
minimatch@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
|
||||
dependencies:
|
||||
brace-expansion "^1.1.7"
|
||||
|
||||
mixin-deep@^1.2.0:
|
||||
version "1.3.2"
|
||||
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566"
|
||||
dependencies:
|
||||
for-in "^1.0.2"
|
||||
is-extendable "^1.0.1"
|
||||
|
||||
ms@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"
|
||||
|
||||
nanomatch@^1.2.9:
|
||||
version "1.2.13"
|
||||
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
|
||||
dependencies:
|
||||
arr-diff "^4.0.0"
|
||||
array-unique "^0.3.2"
|
||||
define-property "^2.0.2"
|
||||
extend-shallow "^3.0.2"
|
||||
fragment-cache "^0.2.1"
|
||||
is-windows "^1.0.2"
|
||||
kind-of "^6.0.2"
|
||||
object.pick "^1.3.0"
|
||||
regex-not "^1.0.0"
|
||||
snapdragon "^0.8.1"
|
||||
to-regex "^3.0.1"
|
||||
|
||||
object-copy@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c"
|
||||
dependencies:
|
||||
copy-descriptor "^0.1.0"
|
||||
define-property "^0.2.5"
|
||||
kind-of "^3.0.3"
|
||||
|
||||
object-visit@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb"
|
||||
dependencies:
|
||||
isobject "^3.0.0"
|
||||
|
||||
object.pick@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747"
|
||||
dependencies:
|
||||
isobject "^3.0.1"
|
||||
|
||||
once@^1.3.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
|
||||
dependencies:
|
||||
wrappy "1"
|
||||
|
||||
pascalcase@^0.1.1:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14"
|
||||
|
||||
path-dirname@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0"
|
||||
|
||||
path-is-absolute@^1.0.0:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
|
||||
|
||||
path-type@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f"
|
||||
dependencies:
|
||||
pify "^3.0.0"
|
||||
|
||||
pify@^3.0.0:
|
||||
version "3.0.0"
|
||||
resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176"
|
||||
|
||||
posix-character-classes@^0.1.0:
|
||||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
||||
|
||||
regex-not@^1.0.0, regex-not@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c"
|
||||
dependencies:
|
||||
extend-shallow "^3.0.2"
|
||||
safe-regex "^1.1.0"
|
||||
|
||||
repeat-element@^1.1.2:
|
||||
version "1.1.3"
|
||||
resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce"
|
||||
|
||||
repeat-string@^1.6.1:
|
||||
version "1.6.1"
|
||||
resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637"
|
||||
|
||||
resolve-url@^0.2.1:
|
||||
version "0.2.1"
|
||||
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
|
||||
|
||||
ret@~0.1.10:
|
||||
version "0.1.15"
|
||||
resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc"
|
||||
|
||||
rimraf@^2.6.2:
|
||||
version "2.6.2"
|
||||
resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"
|
||||
dependencies:
|
||||
glob "^7.0.5"
|
||||
|
||||
rmfr@2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/rmfr/-/rmfr-2.0.0.tgz#8a42e81332550b3f0019b8fb8ab245bea81b6d1c"
|
||||
dependencies:
|
||||
assert-valid-glob-opts "^1.0.0"
|
||||
glob "^7.1.2"
|
||||
graceful-fs "^4.1.11"
|
||||
inspect-with-kind "^1.0.4"
|
||||
rimraf "^2.6.2"
|
||||
|
||||
safe-regex@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"
|
||||
dependencies:
|
||||
ret "~0.1.10"
|
||||
|
||||
set-value@^0.4.3:
|
||||
version "0.4.3"
|
||||
resolved "https://registry.yarnpkg.com/set-value/-/set-value-0.4.3.tgz#7db08f9d3d22dc7f78e53af3c3bf4666ecdfccf1"
|
||||
dependencies:
|
||||
extend-shallow "^2.0.1"
|
||||
is-extendable "^0.1.1"
|
||||
is-plain-object "^2.0.1"
|
||||
to-object-path "^0.3.0"
|
||||
|
||||
set-value@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.0.tgz#71ae4a88f0feefbbf52d1ea604f3fb315ebb6274"
|
||||
dependencies:
|
||||
extend-shallow "^2.0.1"
|
||||
is-extendable "^0.1.1"
|
||||
is-plain-object "^2.0.3"
|
||||
split-string "^3.0.1"
|
||||
|
||||
signal-exit@3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d"
|
||||
|
||||
slash@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"
|
||||
|
||||
snapdragon-node@^2.0.1:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b"
|
||||
dependencies:
|
||||
define-property "^1.0.0"
|
||||
isobject "^3.0.0"
|
||||
snapdragon-util "^3.0.1"
|
||||
|
||||
snapdragon-util@^3.0.1:
|
||||
version "3.0.1"
|
||||
resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2"
|
||||
dependencies:
|
||||
kind-of "^3.2.0"
|
||||
|
||||
snapdragon@^0.8.1:
|
||||
version "0.8.2"
|
||||
resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d"
|
||||
dependencies:
|
||||
base "^0.11.1"
|
||||
debug "^2.2.0"
|
||||
define-property "^0.2.5"
|
||||
extend-shallow "^2.0.1"
|
||||
map-cache "^0.2.2"
|
||||
source-map "^0.5.6"
|
||||
source-map-resolve "^0.5.0"
|
||||
use "^3.1.0"
|
||||
|
||||
source-map-resolve@^0.5.0:
|
||||
version "0.5.2"
|
||||
resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.2.tgz#72e2cc34095543e43b2c62b2c4c10d4a9054f259"
|
||||
dependencies:
|
||||
atob "^2.1.1"
|
||||
decode-uri-component "^0.2.0"
|
||||
resolve-url "^0.2.1"
|
||||
source-map-url "^0.4.0"
|
||||
urix "^0.1.0"
|
||||
|
||||
source-map-url@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
|
||||
|
||||
source-map@^0.5.6:
|
||||
version "0.5.7"
|
||||
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
|
||||
|
||||
split-string@^3.0.1, split-string@^3.0.2:
|
||||
version "3.1.0"
|
||||
resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2"
|
||||
dependencies:
|
||||
extend-shallow "^3.0.0"
|
||||
|
||||
static-extend@^0.1.1:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6"
|
||||
dependencies:
|
||||
define-property "^0.2.5"
|
||||
object-copy "^0.1.0"
|
||||
|
||||
supports-color@^5.2.0:
|
||||
version "5.5.0"
|
||||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
|
||||
dependencies:
|
||||
has-flag "^3.0.0"
|
||||
|
||||
to-object-path@^0.3.0:
|
||||
version "0.3.0"
|
||||
resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af"
|
||||
dependencies:
|
||||
kind-of "^3.0.2"
|
||||
|
||||
to-regex-range@^2.1.0:
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38"
|
||||
dependencies:
|
||||
is-number "^3.0.0"
|
||||
repeat-string "^1.6.1"
|
||||
|
||||
to-regex@^3.0.1, to-regex@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce"
|
||||
dependencies:
|
||||
define-property "^2.0.2"
|
||||
extend-shallow "^3.0.2"
|
||||
regex-not "^1.0.2"
|
||||
safe-regex "^1.1.0"
|
||||
|
||||
union-value@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.0.tgz#5c71c34cb5bad5dcebe3ea0cd08207ba5aa1aea4"
|
||||
dependencies:
|
||||
arr-union "^3.1.0"
|
||||
get-value "^2.0.6"
|
||||
is-extendable "^0.1.1"
|
||||
set-value "^0.4.3"
|
||||
|
||||
universalify@^0.1.0:
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
|
||||
|
||||
unset-value@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559"
|
||||
dependencies:
|
||||
has-value "^0.3.1"
|
||||
isobject "^3.0.0"
|
||||
|
||||
urix@^0.1.0:
|
||||
version "0.1.0"
|
||||
resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72"
|
||||
|
||||
use@^3.1.0:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f"
|
||||
|
||||
validate-glob-opts@^1.0.0:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/validate-glob-opts/-/validate-glob-opts-1.0.2.tgz#ef9f98977d965537ea4f51fa7d5799e9c6ebca91"
|
||||
dependencies:
|
||||
array-to-sentence "^1.1.0"
|
||||
indexed-filter "^1.0.0"
|
||||
inspect-with-kind "^1.0.4"
|
||||
is-plain-obj "^1.1.0"
|
||||
|
||||
wrappy@1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "now",
|
||||
"version": "18.0.0-canary.2",
|
||||
"version": "17.1.2-canary.3",
|
||||
"preferGlobal": true,
|
||||
"license": "Apache-2.0",
|
||||
"description": "The command-line interface for Now",
|
||||
@@ -14,6 +14,7 @@
|
||||
"preinstall": "node ./scripts/preinstall.js",
|
||||
"test-unit": "nyc ava test/unit.js test/dev-builder.unit.js test/dev-router.unit.js test/dev-server.unit.js --serial --fail-fast --verbose",
|
||||
"test-integration": "ava test/integration.js --serial --fail-fast",
|
||||
"test-integration-v1": "ava test/integration-v1.js --serial --fail-fast",
|
||||
"test-integration-now-dev": "ava test/dev/integration.js --serial --fail-fast --verbose",
|
||||
"prepublishOnly": "yarn build",
|
||||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov",
|
||||
@@ -91,10 +92,12 @@
|
||||
"@types/universal-analytics": "0.4.2",
|
||||
"@types/which": "1.3.2",
|
||||
"@types/write-json-file": "2.2.1",
|
||||
"@zeit/dockerignore": "0.0.5",
|
||||
"@zeit/fun": "0.11.2",
|
||||
"@zeit/ncc": "0.18.5",
|
||||
"@zeit/source-map-support": "0.6.2",
|
||||
"ajv": "6.10.2",
|
||||
"alpha-sort": "2.0.1",
|
||||
"ansi-escapes": "3.0.0",
|
||||
"ansi-regex": "3.0.0",
|
||||
"arg": "2.0.0",
|
||||
@@ -127,6 +130,8 @@
|
||||
"get-port": "5.1.1",
|
||||
"glob": "7.1.2",
|
||||
"http-proxy": "1.17.0",
|
||||
"ignore": "4.0.6",
|
||||
"ini": "1.3.4",
|
||||
"inquirer": "7.0.4",
|
||||
"is-port-reachable": "3.0.0",
|
||||
"is-url": "1.2.2",
|
||||
|
||||
@@ -81,12 +81,39 @@ async function isBinary(nowPath) {
|
||||
return !stats.isDirectory();
|
||||
}
|
||||
|
||||
function validateNodeVersion() {
|
||||
let semver = '>= 0';
|
||||
let major = '1';
|
||||
|
||||
try {
|
||||
major = process.versions.node.split('.')[0];
|
||||
const pkg = require('../package.json');
|
||||
semver = pkg.engines.node;
|
||||
} catch (e) {
|
||||
debug('Failed to read package.json engines');
|
||||
}
|
||||
|
||||
const isValid = eval(`${major} ${semver}`);
|
||||
return { isValid, expected: semver, actual: process.versions.node };
|
||||
}
|
||||
|
||||
async function main() {
|
||||
if (!isGlobal()) {
|
||||
debug('Skip preinstall since now is being installed locally');
|
||||
return;
|
||||
}
|
||||
|
||||
const ver = validateNodeVersion();
|
||||
|
||||
if (!ver.isValid) {
|
||||
error(
|
||||
`Detected unsupported Node.js version.\n` +
|
||||
`Expected "${ver.expected}" but found "${ver.actual}".\n` +
|
||||
`Please update to the latest Node.js LTS version to install Now CLI.`
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const nowPath = getNowPath();
|
||||
|
||||
if (nowPath === null) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//
|
||||
import chalk from 'chalk';
|
||||
|
||||
import { handleError } from '../../util/error';
|
||||
@@ -30,12 +31,16 @@ const help = () => {
|
||||
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
|
||||
'DIR'
|
||||
)} Path to the global ${'`.now`'} directory
|
||||
-r ${chalk.bold.underline('RULES_FILE')}, --rules=${chalk.bold.underline(
|
||||
'RULES_FILE'
|
||||
)} Rules file
|
||||
-d, --debug Debug mode [off]
|
||||
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
|
||||
'TOKEN'
|
||||
)} Login token
|
||||
-S, --scope Set a custom scope
|
||||
|
||||
-n, --no-verify Don't wait until instance count meets the previous alias constraints
|
||||
-N, --next Show next page of results
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
${chalk.gray('–')} Add a new alias to ${chalk.underline('my-api.now.sh')}
|
||||
@@ -60,6 +65,28 @@ const help = () => {
|
||||
${chalk.dim('–')} ${chalk.dim(
|
||||
'Protocols'
|
||||
)} in the URLs are unneeded and ignored.
|
||||
|
||||
${chalk.gray('–')} Add and modify path based aliases for ${chalk.underline(
|
||||
'zeit.ninja'
|
||||
)}
|
||||
|
||||
${chalk.cyan(
|
||||
`$ now alias ${chalk.underline('zeit.ninja')} -r ${chalk.underline(
|
||||
'rules.json'
|
||||
)}`
|
||||
)}
|
||||
|
||||
Export effective routing rules
|
||||
|
||||
${chalk.cyan(
|
||||
`$ now alias ls aliasId --json > ${chalk.underline('rules.json')}`
|
||||
)}
|
||||
|
||||
${chalk.gray('–')} Paginate results, where ${chalk.dim(
|
||||
'`1584722256178`'
|
||||
)} is the time in milliseconds since the UNIX epoch.
|
||||
|
||||
${chalk.cyan(`$ now alias ls --next 1584722256178`)}
|
||||
`);
|
||||
};
|
||||
|
||||
@@ -76,8 +103,14 @@ export default async function main(ctx) {
|
||||
try {
|
||||
argv = getArgs(ctx.argv.slice(2), {
|
||||
'--json': Boolean,
|
||||
'--no-verify': Boolean,
|
||||
'--rules': String,
|
||||
'--yes': Boolean,
|
||||
'--next': Number,
|
||||
'-n': '--no-verify',
|
||||
'-r': '--rules',
|
||||
'-y': '--yes',
|
||||
'-N': '--next',
|
||||
});
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
|
||||
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
||||
import ms from 'ms';
|
||||
import plural from 'pluralize';
|
||||
import table from 'text-table';
|
||||
import Now from '../../util/now';
|
||||
import Now from '../../util';
|
||||
import Client from '../../util/client.ts';
|
||||
import getAliases from '../../util/alias/get-aliases';
|
||||
import getScope from '../../util/get-scope.ts';
|
||||
@@ -16,7 +16,7 @@ export default async function ls(ctx, opts, args, output) {
|
||||
} = ctx;
|
||||
const { currentTeam } = config;
|
||||
const { apiUrl } = ctx;
|
||||
const { '--debug': debugEnabled } = opts;
|
||||
const { '--debug': debugEnabled, '--next': nextTimestamp } = opts;
|
||||
const client = new Client({
|
||||
apiUrl,
|
||||
token,
|
||||
@@ -36,7 +36,17 @@ export default async function ls(ctx, opts, args, output) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
||||
if (typeof nextTimestamp !== undefined && Number.isNaN(nextTimestamp)) {
|
||||
output.error('Please provide a number for flag --next');
|
||||
return 1;
|
||||
}
|
||||
|
||||
const now = new Now({
|
||||
apiUrl,
|
||||
token,
|
||||
debug: debugEnabled,
|
||||
currentTeam,
|
||||
});
|
||||
const lsStamp = stamp();
|
||||
let cancelWait;
|
||||
|
||||
@@ -57,7 +67,11 @@ export default async function ls(ctx, opts, args, output) {
|
||||
: `Fetching aliases under ${chalk.bold(contextName)}`
|
||||
);
|
||||
|
||||
const aliases = await getAliases(now);
|
||||
const { aliases, pagination } = await getAliases(
|
||||
now,
|
||||
undefined,
|
||||
nextTimestamp
|
||||
);
|
||||
if (cancelWait) cancelWait();
|
||||
|
||||
if (args[0]) {
|
||||
@@ -83,15 +97,16 @@ export default async function ls(ctx, opts, args, output) {
|
||||
output.print(`${printPathAliasTable(rules)}\n`);
|
||||
}
|
||||
} else {
|
||||
aliases.sort((a, b) => new Date(b.created) - new Date(a.created));
|
||||
output.log(
|
||||
`${plural('alias', aliases.length, true)} found under ${chalk.bold(
|
||||
contextName
|
||||
)} ${lsStamp()}`
|
||||
);
|
||||
output.log(`aliases found under ${chalk.bold(contextName)} ${lsStamp()}`);
|
||||
console.log(printAliasTable(aliases));
|
||||
}
|
||||
|
||||
if (pagination && aliases.length === 20) {
|
||||
output.log(
|
||||
`To display the next page use the flag --next ${pagination.next}`
|
||||
);
|
||||
}
|
||||
|
||||
now.close();
|
||||
return 0;
|
||||
}
|
||||
@@ -110,7 +125,7 @@ function printAliasTable(aliases) {
|
||||
? a.deployment.url
|
||||
: chalk.gray('–'),
|
||||
a.alias,
|
||||
ms(Date.now() - new Date(a.created)),
|
||||
ms(Date.now() - new Date(a.createdAt)),
|
||||
]),
|
||||
],
|
||||
{
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from 'chalk';
|
||||
import ms from 'ms';
|
||||
import table from 'text-table';
|
||||
import Now from '../../util/now';
|
||||
import Now from '../../util';
|
||||
import cmd from '../../util/output/cmd.ts';
|
||||
import Client from '../../util/client.ts';
|
||||
import getScope from '../../util/get-scope.ts';
|
||||
@@ -39,6 +39,7 @@ export default async function rm(ctx, opts, args, output) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
// $FlowFixMe
|
||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
||||
const [aliasOrId] = args;
|
||||
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
import ms from 'ms';
|
||||
import chalk from 'chalk';
|
||||
import { SetDifference } from 'utility-types';
|
||||
import { AliasRecord } from '../../util/alias/create-alias';
|
||||
import { NowContext, Domain } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import assignAlias from '../../util/alias/assign-alias';
|
||||
import Client from '../../util/client';
|
||||
import cmd from '../../util/output/cmd';
|
||||
import formatDnsTable from '../../util/format-dns-table';
|
||||
import formatNSTable from '../../util/format-ns-table';
|
||||
import getDeploymentByIdOrHost from '../../util/deploy/get-deployment-by-id-or-host';
|
||||
import getDeploymentForAlias from '../../util/alias/get-deployment-for-alias';
|
||||
import getRulesFromFile from '../../util/alias/get-rules-from-file';
|
||||
import getScope from '../../util/get-scope';
|
||||
import { getTargetsForAlias } from '../../util/alias/get-targets-for-alias';
|
||||
import humanizePath from '../../util/humanize-path';
|
||||
import setupDomain from '../../util/domains/setup-domain';
|
||||
import stamp from '../../util/output/stamp';
|
||||
import { isValidName } from '../../util/is-valid-name';
|
||||
import upsertPathAlias from '../../util/alias/upsert-path-alias';
|
||||
import handleCertError from '../../util/certs/handle-cert-error';
|
||||
import isWildcardAlias from '../../util/alias/is-wildcard-alias';
|
||||
import link from '../../util/output/link';
|
||||
import { User } from '../../types';
|
||||
|
||||
type Options = {
|
||||
'--debug': boolean;
|
||||
'--local-config': string;
|
||||
'--no-verify': boolean;
|
||||
'--rules': string;
|
||||
};
|
||||
|
||||
export default async function set(
|
||||
@@ -30,13 +40,18 @@ export default async function set(
|
||||
const {
|
||||
authConfig: { token },
|
||||
config,
|
||||
localConfig,
|
||||
} = ctx;
|
||||
|
||||
const { currentTeam } = config;
|
||||
const { apiUrl } = ctx;
|
||||
const setStamp = stamp();
|
||||
|
||||
const { '--debug': debugEnabled } = opts;
|
||||
const {
|
||||
'--debug': debugEnabled,
|
||||
'--no-verify': noVerify,
|
||||
'--rules': rulesPath,
|
||||
} = opts;
|
||||
|
||||
const client = new Client({
|
||||
apiUrl,
|
||||
@@ -44,10 +59,12 @@ export default async function set(
|
||||
currentTeam,
|
||||
debug: debugEnabled,
|
||||
});
|
||||
let contextName = null;
|
||||
|
||||
let user: User;
|
||||
let contextName: string | null = null;
|
||||
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
({ contextName, user } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
@@ -77,7 +94,35 @@ export default async function set(
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.length === 0) {
|
||||
// Read the path alias rules in case there is is given
|
||||
const rules = await getRulesFromFile(rulesPath);
|
||||
if (rules instanceof ERRORS.FileNotFound) {
|
||||
output.error(`Can't find the provided rules file at location:`);
|
||||
output.print(` ${chalk.gray('-')} ${rules.meta.file}\n`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rules instanceof ERRORS.CantParseJSONFile) {
|
||||
output.error(`Error parsing provided rules.json file at location:`);
|
||||
output.print(` ${chalk.gray('-')} ${rules.meta.file}\n`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rules instanceof ERRORS.RulesFileValidationError) {
|
||||
output.error(`Path Alias validation error: ${rules.meta.message}`);
|
||||
output.print(` ${chalk.gray('-')} ${rules.meta.location}\n`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// If the user provided rules and also a deployment target, we should fail
|
||||
if (args.length === 2 && rules) {
|
||||
output.error(
|
||||
`You can't supply a deployment target and target rules simultaneously.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (args.length === 0 && !rules) {
|
||||
output.error(
|
||||
`To ship to production, optionally configure your domains (${link(
|
||||
'https://zeit.co/docs/v2/custom-domains/'
|
||||
@@ -86,11 +131,62 @@ export default async function set(
|
||||
return 1;
|
||||
}
|
||||
|
||||
const [deploymentIdOrHost, aliasTarget] = args;
|
||||
// Find the targets to perform the alias
|
||||
const targets = getTargetsForAlias(args, localConfig);
|
||||
|
||||
if (targets instanceof ERRORS.NoAliasInConfig) {
|
||||
output.error(`Couldn't find an alias in config`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (targets instanceof ERRORS.InvalidAliasInConfig) {
|
||||
output.error(
|
||||
`Wrong value for alias found in config. It must be a string or array of string.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (rules) {
|
||||
// If we have rules for path alias we assign them to the domain
|
||||
for (const target of targets) {
|
||||
output.log(
|
||||
`Assigning path alias rules from ${humanizePath(
|
||||
rulesPath
|
||||
)} to ${target}`
|
||||
);
|
||||
const pathAlias = await upsertPathAlias(
|
||||
output,
|
||||
client,
|
||||
rules,
|
||||
target,
|
||||
contextName
|
||||
);
|
||||
const remaining = handleCreateAliasError(output, pathAlias);
|
||||
if (handleSetupDomainError(output, remaining) !== 1) {
|
||||
console.log(
|
||||
`${chalk.cyan('> Success!')} ${
|
||||
rules.length
|
||||
} rules configured for ${chalk.underline(target)} ${setStamp()}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If there are no rules for path alias we should find out a deployment and perform the alias
|
||||
|
||||
const deployment = handleCertError(
|
||||
output,
|
||||
await getDeploymentByIdOrHost(client, contextName, deploymentIdOrHost)
|
||||
await getDeploymentForAlias(
|
||||
client,
|
||||
output,
|
||||
args,
|
||||
opts['--local-config'],
|
||||
user,
|
||||
contextName,
|
||||
localConfig
|
||||
)
|
||||
);
|
||||
|
||||
if (deployment === 1) {
|
||||
@@ -127,34 +223,37 @@ export default async function set(
|
||||
return 1;
|
||||
}
|
||||
|
||||
output.log(`Assigning alias ${aliasTarget} to deployment ${deployment.url}`);
|
||||
// Assign the alias for each of the targets in the array
|
||||
for (const target of targets) {
|
||||
output.log(`Assigning alias ${target} to deployment ${deployment.url}`);
|
||||
|
||||
const isWildcard = isWildcardAlias(aliasTarget);
|
||||
const record = await assignAlias(
|
||||
output,
|
||||
client,
|
||||
deployment,
|
||||
aliasTarget,
|
||||
contextName
|
||||
);
|
||||
const isWildcard = isWildcardAlias(target);
|
||||
const record = await assignAlias(
|
||||
output,
|
||||
client,
|
||||
deployment,
|
||||
target,
|
||||
contextName,
|
||||
noVerify
|
||||
);
|
||||
const handleResult = handleSetupDomainError(
|
||||
output,
|
||||
handleCreateAliasError(output, record),
|
||||
isWildcard
|
||||
);
|
||||
if (handleResult === 1) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const handleResult = handleSetupDomainError(
|
||||
output,
|
||||
handleCreateAliasError(output, record)
|
||||
);
|
||||
const prefix = isWildcard ? '' : 'https://';
|
||||
|
||||
if (handleResult === 1) {
|
||||
return 1;
|
||||
console.log(
|
||||
`${chalk.cyan('> Success!')} ${chalk.bold(
|
||||
`${prefix}${handleResult.alias}`
|
||||
)} now points to https://${deployment.url} ${setStamp()}`
|
||||
);
|
||||
}
|
||||
|
||||
const prefix = isWildcard ? '' : 'https://';
|
||||
|
||||
console.log(
|
||||
`${chalk.cyan('> Success!')} ${chalk.bold(
|
||||
`${prefix}${handleResult.alias}`
|
||||
)} now points to https://${deployment.url} ${setStamp()}`
|
||||
);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -164,7 +263,8 @@ type SetupDomainError = Exclude<SetupDomainResolve, Domain>;
|
||||
|
||||
function handleSetupDomainError<T>(
|
||||
output: Output,
|
||||
error: SetupDomainError | T
|
||||
error: SetupDomainError | T,
|
||||
isWildcard: boolean = false
|
||||
): T | 1 {
|
||||
if (
|
||||
error instanceof ERRORS.DomainVerificationFailed ||
|
||||
@@ -176,7 +276,9 @@ function handleSetupDomainError<T>(
|
||||
`We could not alias since the domain ${domain} could not be verified due to the following reasons:\n`
|
||||
);
|
||||
output.print(
|
||||
`Nameservers verification failed since we see a different set than the intended set:`
|
||||
` ${chalk.gray(
|
||||
'a)'
|
||||
)} Nameservers verification failed since we see a different set than the intended set:`
|
||||
);
|
||||
output.print(
|
||||
`\n${formatNSTable(
|
||||
@@ -185,6 +287,34 @@ function handleSetupDomainError<T>(
|
||||
{ extraSpace: ' ' }
|
||||
)}\n\n`
|
||||
);
|
||||
if (error instanceof ERRORS.DomainVerificationFailed && !isWildcard) {
|
||||
const { txtVerification } = error.meta;
|
||||
output.print(
|
||||
` ${chalk.gray(
|
||||
'b)'
|
||||
)} DNS TXT verification failed since found no matching records.`
|
||||
);
|
||||
output.print(
|
||||
`\n${formatDnsTable(
|
||||
[['_now', 'TXT', txtVerification.verificationRecord]],
|
||||
{ extraSpace: ' ' }
|
||||
)}\n\n`
|
||||
);
|
||||
output.print(
|
||||
` Once your domain uses either the nameservers or the TXT DNS record from above, run again ${cmd(
|
||||
'now domains verify <domain>'
|
||||
)}.\n`
|
||||
);
|
||||
output.print(
|
||||
` We will also periodically run a verification check for you and you will receive an email once your domain is verified.\n`
|
||||
);
|
||||
} else {
|
||||
output.print(
|
||||
` Once your domain uses the nameservers from above, run again ${cmd(
|
||||
'now domains verify <domain>'
|
||||
)}.\n`
|
||||
);
|
||||
}
|
||||
output.print(' Read more: https://err.sh/now/domain-verification\n');
|
||||
return 1;
|
||||
}
|
||||
@@ -325,6 +455,66 @@ function handleCreateAliasError<T>(
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error instanceof ERRORS.RuleValidationFailed) {
|
||||
output.error(`Rule validation error: ${error.meta.message}.`);
|
||||
output.print(` Make sure your rules file is written correctly.\n`);
|
||||
return 1;
|
||||
}
|
||||
if (error instanceof ERRORS.VerifyScaleTimeout) {
|
||||
output.error(`Instance verification timed out (${ms(error.meta.timeout)})`);
|
||||
output.log('Read more: https://err.sh/now/verification-timeout');
|
||||
return 1;
|
||||
}
|
||||
if (error instanceof ERRORS.NotSupportedMinScaleSlots) {
|
||||
output.error(
|
||||
`Scale rules from previous aliased deployment ${chalk.dim(
|
||||
error.meta.url
|
||||
)} could not be copied since Cloud v2 deployments cannot have a non-zero min`
|
||||
);
|
||||
output.log(
|
||||
`Update the scale settings on ${chalk.dim(
|
||||
error.meta.url
|
||||
)} with \`now scale\` and try again`
|
||||
);
|
||||
output.log('Read more: https://err.sh/now/v2-no-min');
|
||||
return 1;
|
||||
}
|
||||
if (error instanceof ERRORS.ForbiddenScaleMaxInstances) {
|
||||
output.error(
|
||||
`Scale rules from previous aliased deployment ${chalk.dim(
|
||||
error.meta.url
|
||||
)} could not be copied since the given number of max instances (${
|
||||
error.meta.max
|
||||
}) is not allowed.`
|
||||
);
|
||||
output.log(
|
||||
`Update the scale settings on ${chalk.dim(
|
||||
error.meta.url
|
||||
)} with \`now scale\` and try again`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
if (error instanceof ERRORS.ForbiddenScaleMinInstances) {
|
||||
output.error(
|
||||
`You can't scale to more than ${error.meta.max} min instances with your current plan.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error instanceof ERRORS.InvalidScaleMinMaxRelation) {
|
||||
output.error(
|
||||
`Scale rules from previous aliased deployment ${chalk.dim(
|
||||
error.meta.url
|
||||
)} could not be copied becuase the relation between min and max instances is wrong.`
|
||||
);
|
||||
output.log(
|
||||
`Update the scale settings on ${chalk.dim(
|
||||
error.meta.url
|
||||
)} with \`now scale\` and try again`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (error instanceof ERRORS.CertMissing) {
|
||||
output.error(
|
||||
`There is no certificate for the domain ${error.meta.domain} and it could not be created.`
|
||||
|
||||
@@ -300,13 +300,10 @@ async function run({ token, config: { currentTeam } }) {
|
||||
const deletedCard = cards.sources.find(card => card.id === cardId);
|
||||
const remainingCards = cards.sources.filter(card => card.id !== cardId);
|
||||
|
||||
let text = `The provided card does not exist`;
|
||||
|
||||
if (deletedCard) {
|
||||
text = `${deletedCard.brand ||
|
||||
deletedCard.card.brand} ending in ${deletedCard.last4 ||
|
||||
deletedCard.card.last4} was deleted`;
|
||||
}
|
||||
let text = `${deletedCard.brand ||
|
||||
deletedCard.card.brand} ending in ${deletedCard.last4 ||
|
||||
deletedCard.card.last4} was deleted`;
|
||||
// ${chalk.gray(`[${elapsed}]`)}
|
||||
|
||||
if (cardId === cards.defaultSource) {
|
||||
if (remainingCards.length === 0) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import chalk from 'chalk';
|
||||
import Now from '../../util/now';
|
||||
|
||||
// @ts-ignore
|
||||
import Now from '../../util';
|
||||
import Client from '../../util/client';
|
||||
import getScope from '../../util/get-scope';
|
||||
import stamp from '../../util/output/stamp';
|
||||
@@ -59,6 +61,7 @@ async function add(
|
||||
throw err;
|
||||
}
|
||||
|
||||
// $FlowFixMe
|
||||
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
|
||||
|
||||
if (overwite) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
||||
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import Client from '../../util/client';
|
||||
import createCertForCns from '../../util/certs/create-cert-for-cns';
|
||||
import createCertFromFile from '../../util/certs/create-cert-from-file';
|
||||
|
||||
@@ -3,13 +3,14 @@ import ms from 'ms';
|
||||
import plural from 'pluralize';
|
||||
import psl from 'psl';
|
||||
import table from 'text-table';
|
||||
import Now from '../../util/now';
|
||||
// @ts-ignore
|
||||
import Now from '../../util';
|
||||
import cmd from '../../util/output/cmd';
|
||||
import Client from '../../util/client';
|
||||
import getScope from '../../util/get-scope';
|
||||
import stamp from '../../util/output/stamp';
|
||||
import getCerts from '../../util/certs/get-certs';
|
||||
import { CertNotFound } from '../../util/errors';
|
||||
import { CertNotFound } from '../../util/errors-ts';
|
||||
import strlen from '../../util/strlen';
|
||||
import { Output } from '../../util/output';
|
||||
import { NowContext, Cert } from '../../types';
|
||||
|
||||
@@ -3,7 +3,7 @@ import ms from 'ms';
|
||||
import plural from 'pluralize';
|
||||
import table from 'text-table';
|
||||
import { NowContext, Cert } from '../../types';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import { Output } from '../../util/output';
|
||||
import deleteCertById from '../../util/certs/delete-cert-by-id';
|
||||
import getCertById from '../../util/certs/get-cert-by-id';
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import chalk from 'chalk';
|
||||
import logo from '../../util/output/logo';
|
||||
import code from '../../util/output/code';
|
||||
import note from '../../util/output/note';
|
||||
|
||||
export const help = () => `
|
||||
export const latestHelp = () => `
|
||||
${chalk.bold(`${logo} now`)} [options] <command | path>
|
||||
|
||||
${chalk.dim('Commands:')}
|
||||
@@ -35,6 +37,7 @@ export const help = () => `
|
||||
|
||||
-h, --help Output usage information
|
||||
-v, --version Output the version number
|
||||
-V, --platform-version Set the platform version to deploy to
|
||||
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
|
||||
'FILE'
|
||||
)} Path to the local ${'`now.json`'} file
|
||||
@@ -43,6 +46,7 @@ export const help = () => `
|
||||
)} Path to the global ${'`.now`'} directory
|
||||
-d, --debug Debug mode [off]
|
||||
-f, --force Force a new deployment even if nothing has changed
|
||||
--force-with-cache Force a new deployment even if nothing has changed but retain build cache
|
||||
-t ${chalk.underline('TOKEN')}, --token=${chalk.underline(
|
||||
'TOKEN'
|
||||
)} Login token
|
||||
@@ -64,6 +68,12 @@ export const help = () => `
|
||||
--prod Create a production deployment
|
||||
-c, --confirm Confirm default options and skip questions
|
||||
|
||||
${note(
|
||||
`To view the usage information for Now 1.0, run ${code(
|
||||
'now help deploy-v1'
|
||||
)}`
|
||||
)}
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
${chalk.gray('–')} Deploy the current directory
|
||||
@@ -86,13 +96,15 @@ export const help = () => `
|
||||
|
||||
`;
|
||||
|
||||
export const args = {
|
||||
export const latestArgs = {
|
||||
'--force': Boolean,
|
||||
'--force-with-cache': Boolean,
|
||||
'--public': Boolean,
|
||||
'--no-clipboard': Boolean,
|
||||
'--env': [String],
|
||||
'--build-env': [String],
|
||||
'--meta': [String],
|
||||
'--no-scale': Boolean,
|
||||
// This is not an array in favor of matching
|
||||
// the config property name.
|
||||
'--regions': String,
|
||||
@@ -111,3 +123,180 @@ export const args = {
|
||||
'-n': '--name',
|
||||
'--target': String,
|
||||
};
|
||||
|
||||
export const legacyArgsMri = {
|
||||
string: [
|
||||
'name',
|
||||
'build-env',
|
||||
'alias',
|
||||
'meta',
|
||||
'session-affinity',
|
||||
'regions',
|
||||
'dotenv',
|
||||
'target',
|
||||
],
|
||||
boolean: [
|
||||
'help',
|
||||
'version',
|
||||
'debug',
|
||||
'force',
|
||||
'links',
|
||||
'C',
|
||||
'clipboard',
|
||||
'forward-npm',
|
||||
'docker',
|
||||
'npm',
|
||||
'static',
|
||||
'public',
|
||||
'no-scale',
|
||||
'no-verify',
|
||||
'dotenv',
|
||||
'prod',
|
||||
],
|
||||
default: {
|
||||
C: false,
|
||||
clipboard: true,
|
||||
},
|
||||
alias: {
|
||||
env: 'e',
|
||||
meta: 'm',
|
||||
'build-env': 'b',
|
||||
dotenv: 'E',
|
||||
help: 'h',
|
||||
debug: 'd',
|
||||
version: 'v',
|
||||
force: 'f',
|
||||
links: 'l',
|
||||
public: 'p',
|
||||
'forward-npm': 'N',
|
||||
'session-affinity': 'S',
|
||||
name: 'n',
|
||||
project: 'P',
|
||||
alias: 'a',
|
||||
},
|
||||
};
|
||||
|
||||
// The following arg parsing is simply to make it compatible
|
||||
// with the index. Let's not migrate it to the new args parsing, as
|
||||
// we are gonna delete this file soon anyways.
|
||||
const argList = {};
|
||||
|
||||
for (const item of legacyArgsMri.string) {
|
||||
argList[`--${item}`] = String;
|
||||
}
|
||||
|
||||
for (const item of legacyArgsMri.boolean) {
|
||||
argList[`--${item}`] = Boolean;
|
||||
}
|
||||
|
||||
for (const item of Object.keys(legacyArgsMri.alias)) {
|
||||
argList[`-${legacyArgsMri.alias[item]}`] = `--${item}`;
|
||||
}
|
||||
|
||||
export const legacyArgs = argList;
|
||||
|
||||
export const legacyHelp = () => `
|
||||
${chalk.bold(`${logo} now`)} [options] <command | path>
|
||||
|
||||
${chalk.dim('Commands:')}
|
||||
|
||||
${chalk.dim('Cloud')}
|
||||
|
||||
deploy [path] Performs a deployment ${chalk.bold(
|
||||
'(default)'
|
||||
)}
|
||||
ls | list [app] Lists deployments
|
||||
rm | remove [id] Removes a deployment
|
||||
ln | alias [id] [url] Configures aliases for deployments
|
||||
inspect [id] Displays information related to a deployment
|
||||
domains [name] Manages your domain names
|
||||
certs [cmd] Manages your SSL certificates
|
||||
secrets [name] Manages your secret environment variables
|
||||
dns [name] Manages your DNS records
|
||||
logs [url] Displays the logs for a deployment
|
||||
scale [args] Scales the instance count of a deployment
|
||||
init [example] Initialize an example project
|
||||
help [cmd] Displays complete help for [cmd]
|
||||
|
||||
${chalk.dim('Administrative')}
|
||||
|
||||
billing | cc [cmd] Manages your credit cards and billing methods
|
||||
upgrade | downgrade [plan] Upgrades or downgrades your plan
|
||||
teams Manages your teams
|
||||
switch [scope] Switches between teams and your account
|
||||
login [email] Logs into your account or creates a new one
|
||||
logout Logs out of your account
|
||||
whoami Shows the username of the currently logged in user
|
||||
|
||||
${chalk.dim('Options:')}
|
||||
|
||||
-h, --help Output usage information
|
||||
-v, --version Output the version number
|
||||
-V, --platform-version Set the platform version to deploy to
|
||||
-n, --name Set the project name of the deployment
|
||||
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
|
||||
'FILE'
|
||||
)} Path to the local ${'`now.json`'} file
|
||||
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
|
||||
'DIR'
|
||||
)} Path to the global ${'`.now`'} directory
|
||||
-d, --debug Debug mode [off]
|
||||
-f, --force Force a new deployment even if nothing has changed
|
||||
-t ${chalk.underline('TOKEN')}, --token=${chalk.underline(
|
||||
'TOKEN'
|
||||
)} Login token
|
||||
-l, --links Copy symlinks without resolving their target
|
||||
-p, --public Deployment is public (${chalk.dim(
|
||||
'`/_src`'
|
||||
)} is exposed) [on for oss, off for premium]
|
||||
-e, --env Include an env var during run time (e.g.: ${chalk.dim(
|
||||
'`-e KEY=value`'
|
||||
)}). Can appear many times.
|
||||
-b, --build-env Similar to ${chalk.dim(
|
||||
'`--env`'
|
||||
)} but for build time only.
|
||||
-m, --meta Add metadata for the deployment (e.g.: ${chalk.dim(
|
||||
'`-m KEY=value`'
|
||||
)}). Can appear many times.
|
||||
-E ${chalk.underline('FILE')}, --dotenv=${chalk.underline(
|
||||
'FILE'
|
||||
)} Include env vars from .env file. Defaults to '.env'
|
||||
-C, --no-clipboard Do not attempt to copy URL to clipboard
|
||||
-N, --forward-npm Forward login information to install private npm modules
|
||||
--session-affinity Session affinity, \`ip\` or \`random\` (default) to control session affinity
|
||||
-S, --scope Set a custom scope
|
||||
--regions Set default regions or DCs to enable the deployment on
|
||||
--no-scale Skip scaling rules deploying with the default presets
|
||||
--no-verify Skip step of waiting until instance count meets given constraints
|
||||
|
||||
${chalk.dim(`Enforceable Types (by default, it's detected automatically):`)}
|
||||
|
||||
--npm Node.js application
|
||||
--docker Docker container
|
||||
--static Static file hosting
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
${chalk.gray('–')} Deploy the current directory
|
||||
|
||||
${chalk.cyan('$ now')}
|
||||
|
||||
${chalk.gray('–')} Deploy a custom path
|
||||
|
||||
${chalk.cyan('$ now /usr/src/project')}
|
||||
|
||||
${chalk.gray('–')} Deploy a GitHub repository
|
||||
|
||||
${chalk.cyan('$ now user/repo#ref')}
|
||||
|
||||
${chalk.gray('–')} Deploy with environment variables
|
||||
|
||||
${chalk.cyan('$ now -e NODE_ENV=production -e SECRET=@mysql-secret')}
|
||||
|
||||
${chalk.gray('–')} Show the usage information for the sub command ${chalk.dim(
|
||||
'`list`'
|
||||
)}
|
||||
|
||||
${chalk.cyan('$ now help list')}
|
||||
|
||||
`;
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
import fs from 'fs-extra';
|
||||
import { resolve, basename } from 'path';
|
||||
import { resolve, basename, parse, join } from 'path';
|
||||
import Client from '../../util/client.ts';
|
||||
import getScope from '../../util/get-scope.ts';
|
||||
import createOutput from '../../util/output';
|
||||
import code from '../../util/output/code';
|
||||
import highlight from '../../util/output/highlight';
|
||||
import param from '../../util/output/param.ts';
|
||||
import { readLocalConfig } from '../../util/config/files';
|
||||
import getArgs from '../../util/get-args';
|
||||
import { help, args } from './args';
|
||||
import * as parts from './args';
|
||||
import { handleError } from '../../util/error';
|
||||
import deploy from './deploy';
|
||||
import readPackage from '../../util/read-package';
|
||||
import preferV2Deployment, {
|
||||
hasDockerfile,
|
||||
hasServerfile,
|
||||
} from '../../util/prefer-v2-deployment';
|
||||
import getProjectName from '../../util/get-project-name';
|
||||
|
||||
export default async ctx => {
|
||||
const {
|
||||
@@ -15,11 +23,14 @@ export default async ctx => {
|
||||
config: { currentTeam },
|
||||
apiUrl,
|
||||
} = ctx;
|
||||
const combinedArgs = Object.assign({}, parts.legacyArgs, parts.latestArgs);
|
||||
|
||||
let platformVersion = null;
|
||||
let contextName = currentTeam || 'current user';
|
||||
let argv = null;
|
||||
|
||||
try {
|
||||
argv = getArgs(ctx.argv.slice(2), args);
|
||||
argv = getArgs(ctx.argv.slice(2), combinedArgs);
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
return 1;
|
||||
@@ -46,8 +57,12 @@ export default async ctx => {
|
||||
const debugEnabled = argv['--debug'];
|
||||
const output = createOutput({ debug: debugEnabled });
|
||||
const stats = {};
|
||||
const versionFlag = argv['--platform-version'];
|
||||
|
||||
if (argv['--help']) {
|
||||
const lastArg = argv._[argv._.length - 1];
|
||||
const help = lastArg === 'deploy-v1' ? parts.legacyHelp : parts.latestHelp;
|
||||
|
||||
output.print(help());
|
||||
return 2;
|
||||
}
|
||||
@@ -56,15 +71,28 @@ export default async ctx => {
|
||||
try {
|
||||
stats[path] = await fs.lstat(path);
|
||||
} catch (err) {
|
||||
output.error(
|
||||
`The specified file or directory "${basename(path)}" does not exist.`
|
||||
);
|
||||
return 1;
|
||||
const { ext } = parse(path);
|
||||
|
||||
if (versionFlag === 1 && !ext) {
|
||||
// This will ensure `-V 1 zeit/serve` (GitHub deployments) work. Since
|
||||
// GitHub repositories are never just one file, we need to set
|
||||
// the `isFile` property accordingly.
|
||||
stats[path] = {
|
||||
isFile: () => false,
|
||||
};
|
||||
} else {
|
||||
output.error(
|
||||
`The specified file or directory "${basename(path)}" does not exist.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let client = null;
|
||||
|
||||
const isFile = Object.keys(stats).length === 1 && stats[paths[0]].isFile();
|
||||
|
||||
if (authConfig && authConfig.token) {
|
||||
client = new Client({
|
||||
apiUrl,
|
||||
@@ -73,7 +101,7 @@ export default async ctx => {
|
||||
debug: debugEnabled,
|
||||
});
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
({ contextName, platformVersion } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
@@ -84,5 +112,89 @@ export default async ctx => {
|
||||
}
|
||||
}
|
||||
|
||||
return deploy(ctx, contextName, output, stats, localConfig, args);
|
||||
const file = highlight('now.json');
|
||||
const prop = code('version');
|
||||
|
||||
if (localConfig) {
|
||||
const { version } = localConfig;
|
||||
|
||||
if (version) {
|
||||
if (typeof version === 'number') {
|
||||
if (version !== 1 && version !== 2) {
|
||||
const first = code(1);
|
||||
const second = code(2);
|
||||
|
||||
output.error(
|
||||
`The value of the ${prop} property within ${file} can only be ${first} or ${second}.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
platformVersion = version;
|
||||
} else {
|
||||
output.error(
|
||||
`The ${prop} property inside your ${file} file must be a number.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (versionFlag) {
|
||||
if (versionFlag !== 1 && versionFlag !== 2) {
|
||||
output.error(
|
||||
`The ${param('--platform-version')} option must be either ${code(
|
||||
'1'
|
||||
)} or ${code('2')}.`
|
||||
);
|
||||
return 1;
|
||||
}
|
||||
|
||||
platformVersion = versionFlag;
|
||||
}
|
||||
|
||||
if (
|
||||
platformVersion === 1 &&
|
||||
versionFlag !== 1 &&
|
||||
!argv['--docker'] &&
|
||||
!argv['--npm']
|
||||
) {
|
||||
// Only check when it was not set via CLI flag
|
||||
const reason = await preferV2Deployment({
|
||||
client,
|
||||
localConfig,
|
||||
projectName: getProjectName({
|
||||
argv,
|
||||
nowConfig: localConfig || {},
|
||||
isFile,
|
||||
paths,
|
||||
}),
|
||||
hasServerfile: await hasServerfile(paths[0]),
|
||||
hasDockerfile: await hasDockerfile(paths[0]),
|
||||
pkg: await readPackage(join(paths[0], 'package.json')),
|
||||
});
|
||||
|
||||
if (reason) {
|
||||
output.note(reason);
|
||||
platformVersion = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (platformVersion === null || platformVersion > 1) {
|
||||
return require('./latest').default(
|
||||
ctx,
|
||||
contextName,
|
||||
output,
|
||||
stats,
|
||||
localConfig,
|
||||
parts.latestArgs
|
||||
);
|
||||
}
|
||||
|
||||
return require('./legacy').default(
|
||||
ctx,
|
||||
contextName,
|
||||
output,
|
||||
parts.legacyArgsMri
|
||||
);
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import Client from '../../util/client';
|
||||
import { handleError } from '../../util/error';
|
||||
import getArgs from '../../util/get-args';
|
||||
import toHumanPath from '../../util/humanize-path';
|
||||
import Now from '../../util/now';
|
||||
import Now from '../../util';
|
||||
import stamp from '../../util/output/stamp.ts';
|
||||
import createDeploy from '../../util/deploy/create-deploy';
|
||||
import getDeploymentByIdOrHost from '../../util/deploy/get-deployment-by-id-or-host';
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
ConflictingPathSegment,
|
||||
BuildError,
|
||||
NotDomainOwner,
|
||||
} from '../../util/errors';
|
||||
} from '../../util/errors-ts';
|
||||
import { SchemaValidationFailed } from '../../util/errors';
|
||||
import purchaseDomainIfAvailable from '../../util/domains/purchase-domain-if-available';
|
||||
import isWildcardAlias from '../../util/alias/is-wildcard-alias';
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
getLinkedProject,
|
||||
linkFolderToProject,
|
||||
} from '../../util/projects/link';
|
||||
import { getProjectName } from '../../util/get-project-name';
|
||||
import getProjectName from '../../util/get-project-name';
|
||||
import selectOrg from '../../util/input/select-org';
|
||||
import inputProject from '../../util/input/input-project';
|
||||
import { prependEmoji, emoji } from '../../util/emoji';
|
||||
@@ -225,6 +225,7 @@ export default async function main(
|
||||
const paths = Object.keys(stats);
|
||||
const debugEnabled = argv['--debug'];
|
||||
|
||||
// $FlowFixMe
|
||||
const isTTY = process.stdout.isTTY;
|
||||
const quiet = !isTTY;
|
||||
|
||||
@@ -505,6 +506,7 @@ export default async function main(
|
||||
env: deploymentEnv,
|
||||
build: { env: deploymentBuildEnv },
|
||||
forceNew: argv['--force'],
|
||||
forceNewWithCache: argv['--force-with-cache'],
|
||||
quiet,
|
||||
wantsPublic: argv['--public'] || localConfig.public,
|
||||
isFile,
|
||||
@@ -575,7 +577,7 @@ export default async function main(
|
||||
}
|
||||
|
||||
if (deployment.readyState === 'CANCELED') {
|
||||
output.log('The deployment has been canceled');
|
||||
output.print('The deployment has been canceled.\n');
|
||||
return 1;
|
||||
}
|
||||
|
||||
1142
packages/now-cli/src/commands/deploy/legacy.ts
Normal file
1142
packages/now-cli/src/commands/deploy/legacy.ts
Normal file
File diff suppressed because it is too large
Load Diff
@@ -56,6 +56,7 @@ export default async function dev(
|
||||
}
|
||||
|
||||
let devCommand: undefined | string;
|
||||
let frameworkSlug: null | string = null;
|
||||
if (link.status === 'linked') {
|
||||
const { project } = link;
|
||||
|
||||
@@ -65,6 +66,7 @@ export default async function dev(
|
||||
const framework = frameworks.find(f => f.slug === project.framework);
|
||||
|
||||
if (framework) {
|
||||
frameworkSlug = framework.slug;
|
||||
const defaults = framework.settings.devCommand;
|
||||
|
||||
if (isSettingValue(defaults)) {
|
||||
@@ -78,7 +80,12 @@ export default async function dev(
|
||||
}
|
||||
}
|
||||
|
||||
const devServer = new DevServer(cwd, { output, debug, devCommand });
|
||||
const devServer = new DevServer(cwd, {
|
||||
output,
|
||||
debug,
|
||||
devCommand,
|
||||
frameworkSlug,
|
||||
});
|
||||
|
||||
process.once('SIGINT', () => devServer.stop());
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ const help = () => {
|
||||
-h, --help Output usage information
|
||||
-d, --debug Debug mode [off]
|
||||
-l, --listen [uri] Specify a URI endpoint on which to listen [0.0.0.0:3000]
|
||||
-t, --token [token] Specify an Authorization Token
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
DNSPermissionDenied,
|
||||
DNSInvalidPort,
|
||||
DNSInvalidType,
|
||||
} from '../../util/errors';
|
||||
} from '../../util/errors-ts';
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import addDNSRecord from '../../util/dns/add-dns-record';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import Client from '../../util/client';
|
||||
import getScope from '../../util/get-scope';
|
||||
import { DomainNotFound, InvalidDomain } from '../../util/errors';
|
||||
import { DomainNotFound, InvalidDomain } from '../../util/errors-ts';
|
||||
import stamp from '../../util/output/stamp';
|
||||
import importZonefile from '../../util/dns/import-zonefile';
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
||||
import ms from 'ms';
|
||||
import plural from 'pluralize';
|
||||
import { Output } from '../../util/output';
|
||||
import { DomainNotFound } from '../../util/errors';
|
||||
import { DomainNotFound } from '../../util/errors-ts';
|
||||
import { ThenArg, DNSRecord, NowContext } from '../../types';
|
||||
import Client from '../../util/client';
|
||||
import formatTable from '../../util/format-table';
|
||||
|
||||
@@ -3,7 +3,7 @@ import psl from 'psl';
|
||||
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import addDomain from '../../util/domains/add-domain';
|
||||
import Client from '../../util/client';
|
||||
import cmd from '../../util/output/cmd';
|
||||
|
||||
@@ -3,7 +3,7 @@ import psl from 'psl';
|
||||
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import Client from '../../util/client';
|
||||
import cmd from '../../util/output/cmd';
|
||||
import getDomainPrice from '../../util/domains/get-domain-price';
|
||||
|
||||
@@ -45,6 +45,7 @@ const help = () => {
|
||||
'TOKEN'
|
||||
)} Login token
|
||||
-S, --scope Set a custom scope
|
||||
-N, --next Show next page of results
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
@@ -61,6 +62,12 @@ const help = () => {
|
||||
if it's configured with these nameservers (no need to ${chalk.dim(
|
||||
'`domain add`'
|
||||
)}).
|
||||
|
||||
${chalk.gray('–')} Paginate results, where ${chalk.dim(
|
||||
'`1584722256178`'
|
||||
)} is the time in milliseconds since the UNIX epoch.
|
||||
|
||||
${chalk.cyan(`$ now domains ls --next 1584722256178`)}
|
||||
`);
|
||||
};
|
||||
|
||||
@@ -72,7 +79,7 @@ const COMMAND_CONFIG = {
|
||||
move: ['move'],
|
||||
rm: ['rm', 'remove'],
|
||||
transferIn: ['transfer-in'],
|
||||
verify: ['verify']
|
||||
verify: ['verify'],
|
||||
};
|
||||
|
||||
export default async function main(ctx: NowContext) {
|
||||
@@ -83,7 +90,9 @@ export default async function main(ctx: NowContext) {
|
||||
'--cdn': Boolean,
|
||||
'--code': String,
|
||||
'--no-cdn': Boolean,
|
||||
'--yes': Boolean
|
||||
'--yes': Boolean,
|
||||
'--next': Number,
|
||||
'-N': '--next',
|
||||
});
|
||||
} catch (error) {
|
||||
handleError(error);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import chalk from 'chalk';
|
||||
import { DomainNotFound, DomainPermissionDenied } from '../../util/errors';
|
||||
import { DomainNotFound, DomainPermissionDenied } from '../../util/errors-ts';
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import Client from '../../util/client';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import ms from 'ms';
|
||||
import chalk from 'chalk';
|
||||
import plural from 'pluralize';
|
||||
import table from 'text-table';
|
||||
|
||||
import Client from '../../util/client';
|
||||
@@ -13,6 +12,7 @@ import { Domain, NowContext } from '../../types';
|
||||
|
||||
type Options = {
|
||||
'--debug': boolean;
|
||||
'--next': number;
|
||||
};
|
||||
|
||||
export default async function ls(
|
||||
@@ -21,13 +21,21 @@ export default async function ls(
|
||||
args: string[],
|
||||
output: Output
|
||||
) {
|
||||
const { authConfig: { token }, config } = ctx;
|
||||
const {
|
||||
authConfig: { token },
|
||||
config,
|
||||
} = ctx;
|
||||
const { currentTeam } = config;
|
||||
const { apiUrl } = ctx;
|
||||
const debug = opts['--debug'];
|
||||
const { '--debug': debug, '--next': nextTimestamp } = opts;
|
||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
||||
let contextName = null;
|
||||
|
||||
if (typeof nextTimestamp !== undefined && Number.isNaN(nextTimestamp)) {
|
||||
output.error('Please provide a number for flag --next');
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
} catch (err) {
|
||||
@@ -48,16 +56,24 @@ export default async function ls(
|
||||
return 1;
|
||||
}
|
||||
|
||||
const domains = await getDomains(client, contextName);
|
||||
const { domains, pagination } = await getDomains(
|
||||
client,
|
||||
contextName,
|
||||
nextTimestamp
|
||||
);
|
||||
output.log(
|
||||
`${plural('domain', domains.length, true)} found under ${chalk.bold(
|
||||
contextName
|
||||
)} ${chalk.gray(lsStamp())}\n`
|
||||
`Domains found under ${chalk.bold(contextName)} ${chalk.gray(lsStamp())}\n`
|
||||
);
|
||||
if (domains.length > 0) {
|
||||
console.log(`${formatDomainsTable(domains)}\n`);
|
||||
}
|
||||
|
||||
if (pagination && domains.length === 20) {
|
||||
output.log(
|
||||
`To display the next page use the flag --next ${pagination.next}`
|
||||
);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -71,18 +87,18 @@ function formatDomainsTable(domains: Domain[]) {
|
||||
chalk.gray('serviceType'),
|
||||
chalk.gray('verified'),
|
||||
chalk.gray('cdn'),
|
||||
chalk.gray('age')
|
||||
chalk.gray('age'),
|
||||
].map(s => chalk.dim(s)),
|
||||
...domains.map(domain => {
|
||||
const url = chalk.bold(domain.name);
|
||||
const time = chalk.gray(ms(current.getTime() - domain.createdAt));
|
||||
return ['', url, domain.serviceType, domain.verified, true, time];
|
||||
})
|
||||
}),
|
||||
],
|
||||
{
|
||||
align: ['l', 'l', 'l', 'l', 'l'],
|
||||
hsep: ' '.repeat(4),
|
||||
stringLength: strlen
|
||||
stringLength: strlen,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import plural from 'pluralize';
|
||||
|
||||
import { NowContext, User, Team } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import Client from '../../util/client';
|
||||
import cmd from '../../util/output/cmd';
|
||||
import getScope from '../../util/get-scope';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from 'chalk';
|
||||
import plural from 'pluralize';
|
||||
|
||||
import { DomainNotFound, DomainPermissionDenied } from '../../util/errors';
|
||||
import { DomainNotFound, DomainPermissionDenied } from '../../util/errors-ts';
|
||||
import { NowContext, Domain } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import Client from '../../util/client';
|
||||
@@ -12,7 +12,7 @@ import getScope from '../../util/get-scope';
|
||||
import removeAliasById from '../../util/alias/remove-alias-by-id';
|
||||
import removeDomainByName from '../../util/domains/remove-domain-by-name';
|
||||
import stamp from '../../util/output/stamp';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import param from '../../util/output/param';
|
||||
import promptBool from '../../util/input/prompt-bool';
|
||||
import setCustomSuffix from '../../util/domains/set-custom-suffix';
|
||||
@@ -111,12 +111,26 @@ async function removeDomain(
|
||||
|
||||
for (const id of aliasIds) {
|
||||
output.debug(`Removing alias ${id}`);
|
||||
await removeAliasById(client, id);
|
||||
try {
|
||||
await removeAliasById(client, id);
|
||||
} catch (error) {
|
||||
// Ignore if the alias does not exist anymore
|
||||
if (error.status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const id of certIds) {
|
||||
output.debug(`Removing cert ${id}`);
|
||||
await deleteCertById(output, client, id);
|
||||
try {
|
||||
await deleteCertById(output, client, id);
|
||||
} catch (error) {
|
||||
// Ignore if the cert does not exist anymore
|
||||
if (error.status !== 404) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (suffix) {
|
||||
|
||||
@@ -2,7 +2,7 @@ import chalk from 'chalk';
|
||||
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import Client from '../../util/client';
|
||||
import cmd from '../../util/output/cmd';
|
||||
import getScope from '../../util/get-scope';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from 'chalk';
|
||||
import { NowContext } from '../../types';
|
||||
import { Output } from '../../util/output';
|
||||
import * as ERRORS from '../../util/errors';
|
||||
import * as ERRORS from '../../util/errors-ts';
|
||||
import Client from '../../util/client';
|
||||
import cmd from '../../util/output/cmd';
|
||||
import formatDnsTable from '../../util/format-dns-table';
|
||||
|
||||
@@ -6,11 +6,14 @@ export default new Map([
|
||||
['cert', 'certs'],
|
||||
['certs', 'certs'],
|
||||
['deploy', 'deploy'],
|
||||
['deploy-v1', 'deploy'],
|
||||
['deploy-v2', 'deploy'],
|
||||
['dev', 'dev'],
|
||||
['dns', 'dns'],
|
||||
['domain', 'domains'],
|
||||
['domains', 'domains'],
|
||||
['downgrade', 'upgrade'],
|
||||
['help', 'help'],
|
||||
['init', 'init'],
|
||||
['inspect', 'inspect'],
|
||||
['list', 'list'],
|
||||
@@ -24,6 +27,7 @@ export default new Map([
|
||||
['projects', 'projects'],
|
||||
['remove', 'remove'],
|
||||
['rm', 'remove'],
|
||||
['scale', 'scale'],
|
||||
['secret', 'secrets'],
|
||||
['secrets', 'secrets'],
|
||||
['switch', 'teams'],
|
||||
|
||||
@@ -185,7 +185,7 @@ function prepareFolder(cwd: string, folder: string, force?: boolean) {
|
||||
folder
|
||||
)}" already exists and is not an empty directory. You may use ${cmd(
|
||||
'--force'
|
||||
)} or ${cmd('--f')} to override it.`
|
||||
)} or ${cmd('-f')} to override it.`
|
||||
);
|
||||
}
|
||||
} else if (dest !== cwd) {
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
import chalk from 'chalk';
|
||||
import table from 'text-table';
|
||||
import getArgs from '../util/get-args';
|
||||
import buildsList from '../util/output/builds';
|
||||
import routesList from '../util/output/routes';
|
||||
import indent from '../util/output/indent';
|
||||
import cmd from '../util/output/cmd.ts';
|
||||
import createOutput from '../util/output';
|
||||
import Now from '../util/now';
|
||||
import Now from '../util';
|
||||
import logo from '../util/output/logo';
|
||||
import elapsed from '../util/output/elapsed.ts';
|
||||
import { handleError } from '../util/error';
|
||||
import strlen from '../util/strlen.ts';
|
||||
import Client from '../util/client.ts';
|
||||
import getScope from '../util/get-scope.ts';
|
||||
|
||||
const STATIC = 'STATIC';
|
||||
|
||||
const help = () => {
|
||||
console.log(`
|
||||
${chalk.bold(`${logo} now inspect`)} <url>
|
||||
@@ -44,6 +48,7 @@ const help = () => {
|
||||
};
|
||||
|
||||
export default async function main(ctx) {
|
||||
let id;
|
||||
let deployment;
|
||||
let argv;
|
||||
|
||||
@@ -65,7 +70,7 @@ export default async function main(ctx) {
|
||||
const { print, log, error } = output;
|
||||
|
||||
// extract the first parameter
|
||||
const [, deploymentIdOrHost] = argv._;
|
||||
id = argv._[1];
|
||||
|
||||
if (argv._.length !== 2) {
|
||||
error(`${cmd('now inspect <url>')} expects exactly one argument`);
|
||||
@@ -102,24 +107,20 @@ export default async function main(ctx) {
|
||||
// resolve the deployment, since we might have been given an alias
|
||||
const depFetchStart = Date.now();
|
||||
const cancelWait = output.spinner(
|
||||
`Fetching deployment "${deploymentIdOrHost}" in ${chalk.bold(contextName)}`
|
||||
`Fetching deployment "${id}" in ${chalk.bold(contextName)}`
|
||||
);
|
||||
|
||||
try {
|
||||
deployment = await now.findDeployment(deploymentIdOrHost);
|
||||
deployment = await now.findDeployment(id);
|
||||
} catch (err) {
|
||||
cancelWait();
|
||||
if (err.status === 404) {
|
||||
error(
|
||||
`Failed to find deployment "${deploymentIdOrHost}" in ${chalk.bold(
|
||||
contextName
|
||||
)}`
|
||||
);
|
||||
error(`Failed to find deployment "${id}" in ${chalk.bold(contextName)}`);
|
||||
return 1;
|
||||
}
|
||||
if (err.status === 403) {
|
||||
error(
|
||||
`No permission to access deployment "${deploymentIdOrHost}" in ${chalk.bold(
|
||||
`No permission to access deployment "${id}" in ${chalk.bold(
|
||||
contextName
|
||||
)}`
|
||||
);
|
||||
@@ -129,12 +130,39 @@ export default async function main(ctx) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const { id, name, url, created, routes, readyState } = deployment;
|
||||
const {
|
||||
id: finalId,
|
||||
name,
|
||||
state,
|
||||
type,
|
||||
slot,
|
||||
sessionAffinity,
|
||||
url,
|
||||
created,
|
||||
limits,
|
||||
version,
|
||||
routes,
|
||||
readyState,
|
||||
} = deployment;
|
||||
|
||||
const { builds } =
|
||||
deployment.version === 2
|
||||
? await now.fetch(`/v1/now/deployments/${id}/builds`)
|
||||
: { builds: [] };
|
||||
const isBuilds = version === 2;
|
||||
const buildsUrl = `/v1/now/deployments/${finalId}/builds`;
|
||||
|
||||
const [scale, events, { builds }] = await Promise.all([
|
||||
caught(
|
||||
now.fetch(`/v3/now/deployments/${encodeURIComponent(finalId)}/instances`)
|
||||
),
|
||||
type === STATIC
|
||||
? null
|
||||
: caught(
|
||||
now.fetch(
|
||||
`/v1/now/deployments/${encodeURIComponent(
|
||||
finalId
|
||||
)}/events?types=event`
|
||||
)
|
||||
),
|
||||
isBuilds ? now.fetch(buildsUrl) : { builds: [] },
|
||||
]);
|
||||
|
||||
cancelWait();
|
||||
log(
|
||||
@@ -145,9 +173,21 @@ export default async function main(ctx) {
|
||||
|
||||
print('\n');
|
||||
print(chalk.bold(' General\n\n'));
|
||||
print(` ${chalk.cyan('id')}\t\t${id}\n`);
|
||||
print(` ${chalk.cyan('version')}\t${version}\n`);
|
||||
print(` ${chalk.cyan('id')}\t\t${finalId}\n`);
|
||||
print(` ${chalk.cyan('name')}\t${name}\n`);
|
||||
print(` ${chalk.cyan('readyState')}\t${stateString(readyState)}\n`);
|
||||
print(
|
||||
` ${chalk.cyan('readyState')}\t${stateString(state || readyState)}\n`
|
||||
);
|
||||
if (!isBuilds) {
|
||||
print(` ${chalk.cyan('type')}\t${type}\n`);
|
||||
}
|
||||
if (slot) {
|
||||
print(` ${chalk.cyan('slot')}\t${slot}\n`);
|
||||
}
|
||||
if (sessionAffinity) {
|
||||
print(` ${chalk.cyan('affinity')}\t${sessionAffinity}\n`);
|
||||
}
|
||||
print(` ${chalk.cyan('url')}\t\t${url}\n`);
|
||||
if (created) {
|
||||
print(
|
||||
@@ -178,7 +218,95 @@ export default async function main(ctx) {
|
||||
print(`\n\n`);
|
||||
}
|
||||
|
||||
return 0;
|
||||
if (limits) {
|
||||
print(chalk.bold(' Limits\n\n'));
|
||||
print(
|
||||
` ${chalk.dim('duration')}\t\t${limits.duration} ${elapsed(
|
||||
limits.duration
|
||||
)}\n`
|
||||
);
|
||||
print(
|
||||
` ${chalk.dim('maxConcurrentReqs')}\t${limits.maxConcurrentReqs}\n`
|
||||
);
|
||||
print(
|
||||
` ${chalk.dim('timeout')}\t\t${limits.timeout} ${elapsed(
|
||||
limits.timeout
|
||||
)}\n`
|
||||
);
|
||||
print('\n');
|
||||
}
|
||||
|
||||
if (type === STATIC || isBuilds) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
print(chalk.bold(' Scale\n\n'));
|
||||
|
||||
let exitCode = 0;
|
||||
|
||||
if (scale instanceof Error) {
|
||||
error(`Scale information unavailable: ${scale}`);
|
||||
exitCode = 1;
|
||||
} else {
|
||||
const dcs = Object.keys(scale);
|
||||
const t = [['dc', 'min', 'max', 'current'].map(v => chalk.gray(v))];
|
||||
for (const dc of dcs) {
|
||||
const { instances } = scale[dc];
|
||||
const cfg = deployment.scale[dc] || {};
|
||||
t.push([dc, cfg.min || 0, cfg.max || 0, instances.length]);
|
||||
}
|
||||
print(
|
||||
`${table(t, {
|
||||
align: ['l', 'c', 'c', 'c'],
|
||||
hsep: ' '.repeat(8),
|
||||
stringLength: strlen,
|
||||
}).replace(/^(.*)/gm, ' $1')}\n`
|
||||
);
|
||||
print('\n');
|
||||
}
|
||||
|
||||
print(chalk.bold(' Events\n\n'));
|
||||
if (events instanceof Error) {
|
||||
error(`Events unavailable: ${scale}`);
|
||||
exitCode = 1;
|
||||
} else if (events) {
|
||||
events.forEach(data => {
|
||||
if (!data.event) return; // keepalive
|
||||
print(
|
||||
` ${chalk.gray(new Date(data.created).toISOString())} ${
|
||||
data.event
|
||||
} ${getEventMetadata(data)}\n`
|
||||
);
|
||||
});
|
||||
print('\n');
|
||||
}
|
||||
|
||||
return exitCode;
|
||||
}
|
||||
|
||||
// gets the metadata that should be printed next to
|
||||
// each event
|
||||
|
||||
function getEventMetadata({ event, payload }) {
|
||||
if (event === 'state') {
|
||||
return chalk.bold(payload.value);
|
||||
}
|
||||
|
||||
if (event === 'instance-start' || event === 'instance-stop') {
|
||||
if (payload.dc != null) {
|
||||
return chalk.green(`(${payload.dc})`);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// makes sure the promise never rejects, exposing the error
|
||||
// as the resolved value instead
|
||||
function caught(p) {
|
||||
return new Promise(r => {
|
||||
p.then(r).catch(r);
|
||||
});
|
||||
}
|
||||
|
||||
// renders the state string
|
||||
@@ -190,9 +318,6 @@ function stateString(s) {
|
||||
case 'ERROR':
|
||||
return chalk.red(s);
|
||||
|
||||
case 'BUILDING':
|
||||
return chalk.grey(s);
|
||||
|
||||
case 'READY':
|
||||
return s;
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import chalk from 'chalk';
|
||||
import ms from 'ms';
|
||||
import plural from 'pluralize';
|
||||
import table from 'text-table';
|
||||
import Now from '../util/now';
|
||||
import Now from '../util';
|
||||
import getAliases from '../util/alias/get-aliases';
|
||||
import getArgs from '../util/get-args';
|
||||
import getDeploymentInstances from '../util/deploy/get-deployment-instances';
|
||||
import createOutput from '../util/output';
|
||||
import { handleError } from '../util/error';
|
||||
import cmd from '../util/output/cmd.ts';
|
||||
@@ -13,7 +14,7 @@ import wait from '../util/output/wait';
|
||||
import strlen from '../util/strlen.ts';
|
||||
import Client from '../util/client.ts';
|
||||
import getScope from '../util/get-scope.ts';
|
||||
import { toHost } from '../util/to-host';
|
||||
import toHost from '../util/to-host';
|
||||
import parseMeta from '../util/parse-meta';
|
||||
import { isValidName } from '../util/is-valid-name';
|
||||
|
||||
@@ -39,6 +40,7 @@ const help = () => {
|
||||
-m, --meta Filter deployments by metadata (e.g.: ${chalk.dim(
|
||||
'`-m KEY=value`'
|
||||
)}). Can appear many times.
|
||||
-N, --next Show next page of results
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
@@ -59,9 +61,17 @@ const help = () => {
|
||||
${chalk.gray('–')} Filter deployments by metadata
|
||||
|
||||
${chalk.cyan('$ now ls -m key1=value1 -m key2=value2')}
|
||||
|
||||
${chalk.gray('–')} Paginate deployments for a project, where ${chalk.dim(
|
||||
'`1584722256178`'
|
||||
)} is the time in milliseconds since the UNIX epoch.
|
||||
|
||||
${chalk.cyan(`$ now ls my-app --next 1584722256178`)}
|
||||
`);
|
||||
};
|
||||
|
||||
// Options
|
||||
// $FlowFixMe
|
||||
export default async function main(ctx) {
|
||||
let argv;
|
||||
|
||||
@@ -71,6 +81,8 @@ export default async function main(ctx) {
|
||||
'--meta': [String],
|
||||
'-a': '--all',
|
||||
'-m': '--meta',
|
||||
'--next': Number,
|
||||
'-N': '--next',
|
||||
});
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
@@ -123,6 +135,13 @@ export default async function main(ctx) {
|
||||
throw err;
|
||||
}
|
||||
|
||||
const nextTimestamp = argv['--next'];
|
||||
|
||||
if (typeof nextTimestamp !== undefined && Number.isNaN(nextTimestamp)) {
|
||||
error('Please provide a number for flag `--next`');
|
||||
return 1;
|
||||
}
|
||||
|
||||
const stopSpinner = wait(
|
||||
`Fetching deployments in ${chalk.bold(contextName)}`
|
||||
);
|
||||
@@ -160,16 +179,22 @@ export default async function main(ctx) {
|
||||
host = asHost;
|
||||
}
|
||||
|
||||
let deployments;
|
||||
let response;
|
||||
|
||||
try {
|
||||
debug('Fetching deployments');
|
||||
deployments = await now.list(app, { version: 5, meta });
|
||||
response = await now.list(app, {
|
||||
version: 6,
|
||||
meta,
|
||||
nextTimestamp,
|
||||
});
|
||||
} catch (err) {
|
||||
stopSpinner();
|
||||
throw err;
|
||||
}
|
||||
|
||||
let { deployments, pagination } = response;
|
||||
|
||||
if (app && !deployments.length) {
|
||||
debug(
|
||||
'No deployments: attempting to find deployment that matches supplied app name'
|
||||
@@ -193,19 +218,60 @@ export default async function main(ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
if (app && !deployments.length) {
|
||||
debug(
|
||||
'No deployments: attempting to find aliases that matches supplied app name'
|
||||
);
|
||||
const { aliases } = await getAliases(now);
|
||||
const item = aliases.find(e => e.uid === app || e.alias === app);
|
||||
|
||||
if (item) {
|
||||
debug(`Found alias that matches app name: ${item.alias}`);
|
||||
|
||||
if (Array.isArray(item.rules)) {
|
||||
now.close();
|
||||
stopSpinner();
|
||||
log(`Found matching path alias: ${chalk.cyan(item.alias)}`);
|
||||
log(`Please run ${cmd(`now alias ls ${item.alias}`)} instead`);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const match = await now.findDeployment(item.deploymentId);
|
||||
const instances = await getDeploymentInstances(
|
||||
now,
|
||||
item.deploymentId,
|
||||
'now_cli_alias_instances'
|
||||
);
|
||||
match.instanceCount = Object.keys(instances).reduce(
|
||||
(count, dc) => count + instances[dc].instances.length,
|
||||
0
|
||||
);
|
||||
if (match !== null && typeof match !== 'undefined') {
|
||||
deployments = Array.of(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
now.close();
|
||||
|
||||
if (argv['--all']) {
|
||||
await Promise.all(
|
||||
deployments.map(async ({ uid, instanceCount }, i) => {
|
||||
deployments[i].instances =
|
||||
instanceCount > 0 ? await now.listInstances(uid) : [];
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
if (host) {
|
||||
deployments = deployments.filter(deployment => deployment.url === host);
|
||||
}
|
||||
|
||||
stopSpinner();
|
||||
log(
|
||||
`Fetched ${plural(
|
||||
'deployment',
|
||||
deployments.length,
|
||||
true
|
||||
)} under ${chalk.bold(contextName)} ${elapsed(Date.now() - start)}`
|
||||
`Deployments under ${chalk.bold(contextName)} ${elapsed(
|
||||
Date.now() - start
|
||||
)}`
|
||||
);
|
||||
|
||||
// we don't output the table headers if we have no deployments
|
||||
@@ -218,6 +284,8 @@ export default async function main(ctx) {
|
||||
log(
|
||||
`To list more deployments for a project run ${cmd('now ls [project]')}`
|
||||
);
|
||||
} else if (!argv['--all']) {
|
||||
log(`To list deployment instances run ${cmd('now ls --all [project]')}`);
|
||||
}
|
||||
|
||||
print('\n');
|
||||
@@ -235,9 +303,18 @@ export default async function main(ctx) {
|
||||
getProjectName(dep),
|
||||
chalk.bold((includeScheme ? 'https://' : '') + dep.url),
|
||||
stateString(dep.state),
|
||||
chalk.gray(ms(Date.now() - new Date(dep.created))),
|
||||
chalk.gray(ms(Date.now() - new Date(dep.createdAt))),
|
||||
dep.creator.username,
|
||||
],
|
||||
...(argv['--all']
|
||||
? dep.instances.map(i => [
|
||||
'',
|
||||
` ${chalk.gray('-')} ${i.url} `,
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
])
|
||||
: []),
|
||||
])
|
||||
// flatten since the previous step returns a nested
|
||||
// array of the deployment and (optionally) its instances
|
||||
@@ -257,6 +334,10 @@ export default async function main(ctx) {
|
||||
}
|
||||
).replace(/^/gm, ' ')}\n\n`
|
||||
);
|
||||
|
||||
if (pagination && deployments.length === 20) {
|
||||
log(`To display the next page use the flag --next ${pagination.next}`);
|
||||
}
|
||||
}
|
||||
|
||||
function getProjectName(d) {
|
||||
@@ -288,7 +369,7 @@ function stateString(s) {
|
||||
// sorts by most recent deployment
|
||||
function sortRecent() {
|
||||
return function recencySort(a, b) {
|
||||
return b.created - a.created;
|
||||
return b.createdAt - a.createdAt;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import mri from 'mri';
|
||||
import chalk from 'chalk';
|
||||
import fetch from 'node-fetch';
|
||||
import ora from 'ora';
|
||||
import logo from '../util/output/logo';
|
||||
// @ts-ignore
|
||||
import { handleError } from '../util/error';
|
||||
import {
|
||||
readConfigFile,
|
||||
writeToConfigFile,
|
||||
readAuthConfigFile,
|
||||
writeToAuthConfigFile
|
||||
writeToAuthConfigFile,
|
||||
} from '../util/config/files';
|
||||
import error from '../util/output/error';
|
||||
import exit from '../util/exit';
|
||||
import getArgs from '../util/get-args';
|
||||
import { NowContext } from '../types';
|
||||
import createOutput, { Output } from '../util/output';
|
||||
|
||||
const help = () => {
|
||||
console.log(`
|
||||
@@ -35,56 +35,31 @@ const help = () => {
|
||||
`);
|
||||
};
|
||||
|
||||
let argv;
|
||||
let apiUrl;
|
||||
export default async function main(ctx: NowContext): Promise<number> {
|
||||
let argv;
|
||||
|
||||
const main = async ctx => {
|
||||
argv = mri(ctx.argv.slice(2), {
|
||||
boolean: ['help'],
|
||||
alias: {
|
||||
help: 'h'
|
||||
}
|
||||
});
|
||||
|
||||
apiUrl = ctx.apiUrl;
|
||||
argv._ = argv._.slice(1);
|
||||
|
||||
if (argv.help || argv._[0] === 'help') {
|
||||
help();
|
||||
await exit(0);
|
||||
}
|
||||
|
||||
logout();
|
||||
};
|
||||
|
||||
export default async ctx => {
|
||||
try {
|
||||
await main(ctx);
|
||||
argv = getArgs(ctx.argv.slice(2), {
|
||||
'--help': Boolean,
|
||||
'-h': '--help',
|
||||
});
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
process.exit(1);
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
const revokeToken = async (token) => {
|
||||
const options = {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
};
|
||||
|
||||
const result = await fetch(`${apiUrl}/v3/user/tokens/current`, options);
|
||||
|
||||
if (!result.ok) {
|
||||
console.error(error('Not able to log out'));
|
||||
if (argv['--help']) {
|
||||
help();
|
||||
return 2;
|
||||
}
|
||||
};
|
||||
|
||||
const logout = async () => {
|
||||
const spinner = ora({
|
||||
text: 'Logging out...'
|
||||
}).start();
|
||||
const debugEnabled = argv['--debug'];
|
||||
const output = createOutput({ debug: debugEnabled });
|
||||
return logout(ctx.apiUrl, output);
|
||||
}
|
||||
|
||||
const logout = async (apiUrl: string, output: Output) => {
|
||||
const spinner = output.spinner('Logging out...', 200);
|
||||
|
||||
const configContent = readConfigFile();
|
||||
const authContent = readAuthConfigFile();
|
||||
@@ -103,19 +78,33 @@ const logout = async () => {
|
||||
delete authContent.token;
|
||||
|
||||
try {
|
||||
await writeToConfigFile(configContent);
|
||||
await writeToAuthConfigFile(authContent);
|
||||
writeToConfigFile(configContent);
|
||||
writeToAuthConfigFile(authContent);
|
||||
output.debug('Configuration has been deleted');
|
||||
} catch (err) {
|
||||
spinner.fail(`Couldn't remove config while logging out`);
|
||||
process.exit(1);
|
||||
spinner();
|
||||
output.error(`Couldn't remove config while logging out`);
|
||||
return 1;
|
||||
}
|
||||
|
||||
try {
|
||||
await revokeToken(token);
|
||||
} catch (err) {
|
||||
spinner.fail('Could not revoke token on logout');
|
||||
process.exit(1);
|
||||
const res = await fetch(`${apiUrl}/v3/user/tokens/current`, {
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (res.status === 403) {
|
||||
output.debug('Token is invalid so it cannot be revoked');
|
||||
} else if (res.status !== 200) {
|
||||
spinner();
|
||||
const err = await res.json();
|
||||
output.error('Failed to revoke token');
|
||||
output.debug(err ? err.message : '');
|
||||
return 1;
|
||||
}
|
||||
|
||||
spinner.succeed('Logged out!');
|
||||
spinner();
|
||||
output.log('Logged out!');
|
||||
return 0;
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import mri from 'mri';
|
||||
import chalk from 'chalk';
|
||||
import Now from '../util/now';
|
||||
import Now from '../util';
|
||||
import createOutput from '../util/output';
|
||||
import logo from '../util/output/logo';
|
||||
import elapsed from '../util/output/elapsed.ts';
|
||||
|
||||
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
||||
import ms from 'ms';
|
||||
import plural from 'pluralize';
|
||||
import table from 'text-table';
|
||||
import Now from '../util/now';
|
||||
import Now from '../util';
|
||||
import getAliases from '../util/alias/get-aliases';
|
||||
import createOutput from '../util/output';
|
||||
import logo from '../util/output/logo';
|
||||
|
||||
340
packages/now-cli/src/commands/scale.js
Normal file
340
packages/now-cli/src/commands/scale.js
Normal file
@@ -0,0 +1,340 @@
|
||||
import ms from 'ms';
|
||||
import chalk from 'chalk';
|
||||
|
||||
import cmd from '../util/output/cmd.ts';
|
||||
import createOutput from '../util/output';
|
||||
import logo from '../util/output/logo';
|
||||
import stamp from '../util/output/stamp.ts';
|
||||
|
||||
import Now from '../util';
|
||||
import getArgs from '../util/get-args';
|
||||
import Client from '../util/client.ts';
|
||||
import getScope from '../util/get-scope.ts';
|
||||
import getDCsFromArgs from '../util/scale/get-dcs-from-args';
|
||||
import getDeploymentByIdOrHost from '../util/deploy/get-deployment-by-id-or-host';
|
||||
import getDeploymentByIdOrThrow from '../util/deploy/get-deployment-by-id-or-throw';
|
||||
import getMaxFromArgs from '../util/scale/get-max-from-args';
|
||||
import getMinFromArgs from '../util/scale/get-min-from-args';
|
||||
import patchDeploymentScale from '../util/scale/patch-deployment-scale';
|
||||
import waitVerifyDeploymentScale from '../util/scale/wait-verify-deployment-scale';
|
||||
import { handleError } from '../util/error';
|
||||
import {
|
||||
VerifyScaleTimeout,
|
||||
DeploymentTypeUnsupported,
|
||||
} from '../util/errors-ts';
|
||||
import {
|
||||
DeploymentNotFound,
|
||||
DeploymentPermissionDenied,
|
||||
ForbiddenScaleMaxInstances,
|
||||
ForbiddenScaleMinInstances,
|
||||
InvalidArgsForMinMaxScale,
|
||||
InvalidMaxForScale,
|
||||
InvalidMinForScale,
|
||||
InvalidScaleMinMaxRelation,
|
||||
NotSupportedMinScaleSlots,
|
||||
} from '../util/errors-ts';
|
||||
import { InvalidAllForScale, InvalidRegionOrDCForScale } from '../util/errors';
|
||||
import handleCertError from '../util/certs/handle-cert-error';
|
||||
|
||||
const help = () => {
|
||||
console.log(`
|
||||
${chalk.bold(`${logo} now scale`)} <url> <dc> [min] [max]
|
||||
|
||||
${chalk.dim('Options:')}
|
||||
|
||||
-h, --help Output usage information
|
||||
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
|
||||
'FILE'
|
||||
)} Path to the local ${'`now.json`'} file
|
||||
-Q ${chalk.bold.underline('DIR')}, --global-config=${chalk.bold.underline(
|
||||
'DIR'
|
||||
)} Path to the global ${'`.now`'} directory
|
||||
-t ${chalk.bold.underline('TOKEN')}, --token=${chalk.bold.underline(
|
||||
'TOKEN'
|
||||
)} Login token
|
||||
-d, --debug Debug mode [off]
|
||||
-S, --scope Set a custom scope
|
||||
-n, --no-verify Skip step of waiting until instance count meets given constraints
|
||||
-t, --verify-timeout How long to wait for verification to complete [5m]
|
||||
|
||||
${chalk.dim('Examples:')}
|
||||
|
||||
${chalk.gray(
|
||||
'–'
|
||||
)} Enable your deployment in all datacenters (min: 0, max: auto)
|
||||
|
||||
${chalk.cyan('$ now scale my-deployment-123.now.sh all')}
|
||||
|
||||
${chalk.gray(
|
||||
'-'
|
||||
)} Enable your deployment in the SFO datacenter (min: 0, max: auto)
|
||||
|
||||
${chalk.cyan('$ now scale my-deployment-123.now.sh sfo')}
|
||||
|
||||
${chalk.gray(
|
||||
'–'
|
||||
)} Scale a deployment in all datacenters to 3 instances at all times (no sleep)
|
||||
|
||||
${chalk.cyan('$ now scale my-deployment-123.now.sh all 3')}
|
||||
|
||||
${chalk.gray(
|
||||
'–'
|
||||
)} Enable your deployment in all datacenters, with auto-scaling
|
||||
|
||||
${chalk.cyan('$ now scale my-deployment-123.now.sh all auto')}
|
||||
`);
|
||||
};
|
||||
|
||||
export default async function main(ctx) {
|
||||
let argv;
|
||||
|
||||
try {
|
||||
argv = getArgs(ctx.argv.slice(2), {
|
||||
'--verify-timeout': Number,
|
||||
'--no-verify': Boolean,
|
||||
'-n': '--no-verify',
|
||||
});
|
||||
} catch (err) {
|
||||
handleError(err);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (argv['--help']) {
|
||||
help();
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Prepare the context
|
||||
const {
|
||||
authConfig: { token },
|
||||
config,
|
||||
} = ctx;
|
||||
const { currentTeam } = config;
|
||||
const { apiUrl } = ctx;
|
||||
const debug = argv['--debug'];
|
||||
|
||||
// $FlowFixMe
|
||||
const now = new Now({ apiUrl, token, debug, currentTeam });
|
||||
const output = createOutput({ debug });
|
||||
const client = new Client({ apiUrl, token, currentTeam, debug });
|
||||
let contextName = null;
|
||||
|
||||
try {
|
||||
({ contextName } = await getScope(client));
|
||||
} catch (err) {
|
||||
if (err.code === 'NOT_AUTHORIZED' || err.code === 'TEAM_DELETED') {
|
||||
output.error(err.message);
|
||||
return 1;
|
||||
}
|
||||
|
||||
throw err;
|
||||
}
|
||||
|
||||
// Fail if the user is providing an old command
|
||||
if (argv._[1] === 'ls') {
|
||||
output.error(
|
||||
`${cmd('now scale ls')} has been deprecated. Use ${cmd(
|
||||
'now ls'
|
||||
)} and ${cmd('now inspect <url>')}`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Ensure the number of arguments is between the allower range
|
||||
if (argv._.length < 3 || argv._.length > 5) {
|
||||
output.error(
|
||||
`${cmd(
|
||||
'now scale <url> <dc> [min] [max]'
|
||||
)} expects at least two arguments`
|
||||
);
|
||||
help();
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const dcs = getDCsFromArgs(argv._);
|
||||
if (dcs instanceof InvalidAllForScale) {
|
||||
output.error(
|
||||
'The region value "all" was used, but it cannot be used alongside other region or dc identifiers'
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (dcs instanceof InvalidRegionOrDCForScale) {
|
||||
output.error(
|
||||
`The value "${dcs.meta.regionOrDC}" is not a valid region or DC identifier`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const min = getMinFromArgs(argv._);
|
||||
if (min instanceof InvalidMinForScale) {
|
||||
output.error(
|
||||
`Invalid <min> parameter "${min.meta.value}". A number or "auto" were expected`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const max = getMaxFromArgs(argv._);
|
||||
if (max instanceof InvalidMinForScale) {
|
||||
output.error(
|
||||
`Invalid <min> parameter "${max.meta.value}". A number or "auto" were expected`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (max instanceof InvalidArgsForMinMaxScale) {
|
||||
output.error(
|
||||
`Invalid number of arguments: expected <min> ("${max.meta.min}") and [max]`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (max instanceof InvalidMaxForScale) {
|
||||
output.error(
|
||||
`Invalid <max> parameter "${max.meta.value}". A number or "auto" were expected`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Fetch the deployment
|
||||
const deploymentStamp = stamp();
|
||||
const deployment = handleCertError(
|
||||
output,
|
||||
await getDeploymentByIdOrHost(now, contextName, argv._[1])
|
||||
);
|
||||
|
||||
if (deployment === 1) {
|
||||
return deployment;
|
||||
}
|
||||
if (deployment instanceof DeploymentPermissionDenied) {
|
||||
output.error(
|
||||
`No permission to access deployment ${chalk.dim(
|
||||
deployment.meta.id
|
||||
)} under ${chalk.bold(deployment.meta.context)}`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (deployment instanceof DeploymentNotFound) {
|
||||
output.error(
|
||||
`Failed to find deployment "${argv._[1]}" in ${chalk.bold(contextName)}`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
output.log(`Fetched deployment "${deployment.url}" ${deploymentStamp()}`);
|
||||
|
||||
// Make sure the deployment can be scaled
|
||||
if (deployment.type === 'STATIC') {
|
||||
output.error('Scaling rules cannot be set on static deployments');
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (deployment.state === 'ERROR') {
|
||||
output.error('Cannot scale a deployment in the ERROR state');
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (deployment.version === 2) {
|
||||
output.error('Cannot scale a Now 2.0 deployment');
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
const scaleArgs = dcs.reduce(
|
||||
(result, dc) => ({ ...result, [dc]: { min, max } }),
|
||||
{}
|
||||
);
|
||||
output.debug(
|
||||
`Setting scale deployment presets to ${JSON.stringify(scaleArgs)}`
|
||||
);
|
||||
|
||||
// Set the deployment scale
|
||||
const scaleStamp = stamp();
|
||||
const result = await patchDeploymentScale(
|
||||
output,
|
||||
now,
|
||||
deployment.uid,
|
||||
scaleArgs,
|
||||
deployment.url
|
||||
);
|
||||
if (result instanceof ForbiddenScaleMinInstances) {
|
||||
output.error(
|
||||
`You can't scale to more than ${result.meta.max} min instances with your current plan.`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (result instanceof ForbiddenScaleMaxInstances) {
|
||||
output.error(
|
||||
`You can't scale to more than ${result.meta.max} max instances with your current plan.`
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (result instanceof InvalidScaleMinMaxRelation) {
|
||||
output.error(`Min number of instances can't be higher than max.`);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (result instanceof NotSupportedMinScaleSlots) {
|
||||
output.error(
|
||||
`Cloud v2 does not yet support setting a non-zero min number of instances.`
|
||||
);
|
||||
output.log('Read more: https://err.sh/now/v2-no-min');
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
if (result instanceof DeploymentTypeUnsupported) {
|
||||
output.error(`This region only accepts Serverless Docker Deployments.`);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
|
||||
console.log(
|
||||
`${chalk.gray('>')} Scale rules for ${dcs
|
||||
.map(d => chalk.bold(d))
|
||||
.join(', ')} (min: ${chalk.bold(min)}, max: ${chalk.bold(
|
||||
max
|
||||
)}) saved ${scaleStamp()}`
|
||||
);
|
||||
|
||||
if (argv['--no-verify']) {
|
||||
now.close();
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Verify that the scale presets are there
|
||||
const verifyStamp = stamp();
|
||||
const updatedDeployment = await getDeploymentByIdOrThrow(
|
||||
now,
|
||||
contextName,
|
||||
deployment.uid
|
||||
);
|
||||
if (updatedDeployment.type === 'NPM' || updatedDeployment.type === 'DOCKER') {
|
||||
const result = await waitVerifyDeploymentScale(
|
||||
output,
|
||||
now,
|
||||
deployment.uid,
|
||||
updatedDeployment.scale
|
||||
);
|
||||
if (result instanceof VerifyScaleTimeout) {
|
||||
output.error(
|
||||
`Instance verification timed out (${ms(result.meta.timeout)})`,
|
||||
'verification-timeout'
|
||||
);
|
||||
now.close();
|
||||
return 1;
|
||||
}
|
||||
output.success(`Scale state verified ${verifyStamp()}`);
|
||||
}
|
||||
|
||||
now.close();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
import chalk from 'chalk';
|
||||
import { email as regexEmail } from '../../util/input/regexes';
|
||||
import createOutput from '../../util/output/create-output';
|
||||
import wait from '../../util/output/wait';
|
||||
import fatalError from '../../util/fatal-error';
|
||||
import cmd from '../../util/output/cmd.ts';
|
||||
import info from '../../util/output/info';
|
||||
import stamp from '../../util/output/stamp.ts';
|
||||
@@ -65,7 +65,6 @@ export default async function({
|
||||
apiUrl,
|
||||
token,
|
||||
} = {}) {
|
||||
const output = createOutput();
|
||||
const { currentTeam: currentTeamId } = config;
|
||||
|
||||
const stopSpinner = wait('Fetching teams');
|
||||
@@ -100,8 +99,7 @@ export default async function({
|
||||
)}.\nPlease select a team scope using ${cmd('now switch')} or use ${cmd(
|
||||
'--scope'
|
||||
)}`;
|
||||
output.error(err);
|
||||
return 1;
|
||||
return fatalError(err);
|
||||
}
|
||||
|
||||
console.log(
|
||||
|
||||
@@ -15,7 +15,7 @@ try {
|
||||
}
|
||||
import 'core-js/modules/es7.symbol.async-iterator';
|
||||
import { join } from 'path';
|
||||
import { existsSync } from 'fs';
|
||||
import { existsSync, lstatSync } from 'fs';
|
||||
import sourceMap from '@zeit/source-map-support';
|
||||
import { mkdirp } from 'fs-extra';
|
||||
import chalk from 'chalk';
|
||||
@@ -43,7 +43,7 @@ import { handleError } from './util/error';
|
||||
import highlight from './util/output/highlight';
|
||||
import reportError from './util/report-error';
|
||||
import getConfig from './util/get-config';
|
||||
import * as ERRORS from './util/errors';
|
||||
import * as ERRORS from './util/errors-ts';
|
||||
import { NowError } from './util/now-error';
|
||||
import { SENTRY_DSN } from './util/constants.ts';
|
||||
import getUpdateCommand from './util/get-update-command';
|
||||
@@ -375,10 +375,30 @@ const main = async argv_ => {
|
||||
commands.has(targetOrSubcommand);
|
||||
|
||||
if (targetPathExists && subcommandExists) {
|
||||
const fileType = lstatSync(targetPath).isDirectory()
|
||||
? 'subdirectory'
|
||||
: 'file';
|
||||
const plural = targetOrSubcommand + 's';
|
||||
const singular = targetOrSubcommand.endsWith('s')
|
||||
? targetOrSubcommand.slice(0, -1)
|
||||
: '';
|
||||
let alternative = '';
|
||||
if (commands.has(plural)) {
|
||||
alternative = plural;
|
||||
} else if (commands.has(singular)) {
|
||||
alternative = singular;
|
||||
}
|
||||
console.error(
|
||||
error(
|
||||
`The supplied argument ${param(targetOrSubcommand)} is ambiguous. ` +
|
||||
'Both a directory and a subcommand are known'
|
||||
`The supplied argument ${param(targetOrSubcommand)} is ambiguous.` +
|
||||
`\nIf you wish to deploy the ${fileType} ${param(
|
||||
targetOrSubcommand
|
||||
)}, first run "cd ${targetOrSubcommand}". ` +
|
||||
(alternative
|
||||
? `\nIf you wish to use the subcommand ${param(
|
||||
targetOrSubcommand
|
||||
)}, use ${param(alternative)} instead.`
|
||||
: '')
|
||||
)
|
||||
);
|
||||
return 1;
|
||||
@@ -519,7 +539,12 @@ const main = async argv_ => {
|
||||
|
||||
let scope = argv['--scope'] || argv['--team'] || localConfig.scope;
|
||||
|
||||
if (process.env.NOW_ORG_ID || !scope) {
|
||||
const targetCommand = commands.get(subcommand);
|
||||
|
||||
if (
|
||||
!['login', 'logout'].includes(targetCommand) &&
|
||||
(process.env.NOW_ORG_ID || !scope)
|
||||
) {
|
||||
const client = new Client({ apiUrl, token });
|
||||
const link = await getLinkedOrg(client, output);
|
||||
|
||||
@@ -532,8 +557,6 @@ const main = async argv_ => {
|
||||
}
|
||||
}
|
||||
|
||||
const targetCommand = commands.get(subcommand);
|
||||
|
||||
if (
|
||||
typeof scope === 'string' &&
|
||||
targetCommand !== 'login' &&
|
||||
|
||||
@@ -4,10 +4,6 @@ export type ThenArg<T> = T extends Promise<infer U> ? U : T;
|
||||
|
||||
export type Config = NowConfig;
|
||||
|
||||
export interface Dictionary<T> {
|
||||
[key: string]: T;
|
||||
}
|
||||
|
||||
export interface NowContext {
|
||||
argv: string[];
|
||||
apiUrl: string;
|
||||
@@ -106,7 +102,7 @@ export type DeploymentScale = {
|
||||
};
|
||||
|
||||
export type NpmDeployment = {
|
||||
id: string;
|
||||
uid: string;
|
||||
url: string;
|
||||
name: string;
|
||||
type: 'NPM';
|
||||
@@ -119,7 +115,7 @@ export type NpmDeployment = {
|
||||
};
|
||||
|
||||
export type StaticDeployment = {
|
||||
id: string;
|
||||
uid: string;
|
||||
url: string;
|
||||
name: string;
|
||||
type: 'STATIC';
|
||||
@@ -131,7 +127,7 @@ export type StaticDeployment = {
|
||||
};
|
||||
|
||||
export type DockerDeployment = {
|
||||
id: string;
|
||||
uid: string;
|
||||
url: string;
|
||||
name: string;
|
||||
type: 'DOCKER';
|
||||
@@ -229,6 +225,7 @@ export interface Project {
|
||||
devCommand?: string | null;
|
||||
framework?: string | null;
|
||||
rootDirectory?: string | null;
|
||||
latestDeployments?: Partial<Deployment>[];
|
||||
}
|
||||
|
||||
export interface Org {
|
||||
@@ -241,3 +238,9 @@ export interface ProjectLink {
|
||||
projectId: string;
|
||||
orgId: string;
|
||||
}
|
||||
|
||||
export interface PaginationOptions {
|
||||
prev: number;
|
||||
count: number;
|
||||
next?: number;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
import { Deployment } from '../../types';
|
||||
import { Output } from '../output';
|
||||
import * as ERRORS from '../errors-ts';
|
||||
import Client from '../client';
|
||||
import createAlias from './create-alias';
|
||||
import deploymentShouldCopyScale from './deployment-should-copy-scale';
|
||||
import deploymentShouldDownscale from './deployment-should-downscale';
|
||||
import findAliasByAliasOrId from './find-alias-by-alias-or-id';
|
||||
import getDeploymentDownscalePresets from './get-deployment-downscale-presets';
|
||||
import getDeploymentFromAlias from './get-deployment-from-alias';
|
||||
import isDomainExternal from '../domains/is-domain-external';
|
||||
import setDeploymentScale from '../scale/set-deployment-scale';
|
||||
import setupDomain from '../domains/setup-domain';
|
||||
import stamp from '../output/stamp';
|
||||
import waitForScale from '../scale/wait-verify-deployment-scale';
|
||||
|
||||
const NOW_SH_REGEX = /\.now\.sh$/;
|
||||
|
||||
@@ -12,11 +21,71 @@ export default async function assignAlias(
|
||||
client: Client,
|
||||
deployment: Deployment,
|
||||
alias: string,
|
||||
contextName: string
|
||||
contextName: string,
|
||||
noVerify: boolean
|
||||
) {
|
||||
const prevAlias = await findAliasByAliasOrId(output, client, alias);
|
||||
let externalDomain = false;
|
||||
|
||||
// Check if the alias is a custom domain, because then
|
||||
// If there was a previous deployment, we should fetch it to scale and downscale later
|
||||
let prevDeployment = await getDeploymentFromAlias(
|
||||
client,
|
||||
contextName,
|
||||
prevAlias,
|
||||
deployment
|
||||
);
|
||||
|
||||
// If there is an alias laying around that points to a deleted
|
||||
// deployment, we need to account for it here.
|
||||
if (prevDeployment instanceof ERRORS.DeploymentNotFound) {
|
||||
prevDeployment = null;
|
||||
}
|
||||
|
||||
if (prevDeployment instanceof Error) {
|
||||
return prevDeployment;
|
||||
}
|
||||
|
||||
// If there was a prev deployment that wasn't static we have to check if we should scale
|
||||
if (
|
||||
prevDeployment !== null &&
|
||||
prevDeployment.type !== 'STATIC' &&
|
||||
deployment.type !== 'STATIC'
|
||||
) {
|
||||
if (deploymentShouldCopyScale(prevDeployment, deployment)) {
|
||||
const scaleStamp = stamp();
|
||||
const result = await setDeploymentScale(
|
||||
output,
|
||||
client,
|
||||
deployment.uid,
|
||||
prevDeployment.scale,
|
||||
deployment.url
|
||||
);
|
||||
if (result instanceof Error) {
|
||||
return result;
|
||||
}
|
||||
|
||||
output.log(
|
||||
`Scale rules copied from previous alias ${
|
||||
prevDeployment.url
|
||||
} ${scaleStamp()}`
|
||||
);
|
||||
if (!noVerify) {
|
||||
const result = await waitForScale(
|
||||
output,
|
||||
client,
|
||||
deployment.uid,
|
||||
prevDeployment.scale
|
||||
);
|
||||
if (result instanceof ERRORS.VerifyScaleTimeout) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
output.debug(`Both deployments have the same scaling rules.`);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the alias is a custom domain and if case we have a positive
|
||||
// we have to configure the DNS records and certificate
|
||||
if (alias.indexOf('.') !== -1 && !NOW_SH_REGEX.test(alias)) {
|
||||
// Now the domain shouldn't be available and it might or might not belong to the user
|
||||
@@ -38,6 +107,23 @@ export default async function assignAlias(
|
||||
alias,
|
||||
externalDomain
|
||||
);
|
||||
if (record instanceof Error) {
|
||||
return record;
|
||||
}
|
||||
|
||||
// Downscale if the previous deployment is not static and doesn't have the minimal presets
|
||||
if (prevDeployment !== null && prevDeployment.type !== 'STATIC') {
|
||||
if (await deploymentShouldDownscale(output, client, prevDeployment)) {
|
||||
await setDeploymentScale(
|
||||
output,
|
||||
client,
|
||||
prevDeployment.uid,
|
||||
getDeploymentDownscalePresets(prevDeployment),
|
||||
prevDeployment.url
|
||||
);
|
||||
output.log(`Previous deployment ${prevDeployment.url} downscaled`);
|
||||
}
|
||||
}
|
||||
|
||||
return record;
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user