fix: substitute moment in npm challenges (#46924)
* fix: substitute moment infirst challenge * fix: other challenges moment->freecodecamp * use @freecodecamp/ex in first npm challengnge * @freecodecamp/example in second npm challenge * @freecodecamp/example in third npm challenge * @freecodecamp/example in fourth npm challenge * @freecodecamp/example in fifth npm challenge * Apply suggestions from code review Co-authored-by: Shaun Hamilton <shauhami020@gmail.com> Co-authored-by: Shaun Hamilton <shauhami020@gmail.com>pull/46956/head^2
parent
cb632fcb1c
commit
659f055589
|
@ -22,13 +22,13 @@ In this section, packages your project requires are stored using the following f
|
|||
|
||||
# --instructions--
|
||||
|
||||
Add version "2.14.0" of the "moment" package to the `dependencies` field of your package.json file.
|
||||
Add version "1.1.0" of the `@freecodecamp/example` package to the `dependencies` field of your `package.json` file.
|
||||
|
||||
**Note:** Moment is a handy library for working with time and dates.
|
||||
**Note:** `@freecodecamp/example` is a faux package used as a learning tool.
|
||||
|
||||
# --hints--
|
||||
|
||||
"dependencies" should include "moment"
|
||||
`"dependencies"` should include `"@freecodecamp/example"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -37,8 +37,8 @@ Add version "2.14.0" of the "moment" package to the `dependencies` field of your
|
|||
var packJson = JSON.parse(data);
|
||||
assert.property(
|
||||
packJson.dependencies,
|
||||
'moment',
|
||||
'"dependencies" does not include "moment"'
|
||||
'@freecodecamp/example',
|
||||
'"dependencies" does not include "@freecodecamp/example"'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
@ -47,7 +47,7 @@ Add version "2.14.0" of the "moment" package to the `dependencies` field of your
|
|||
);
|
||||
```
|
||||
|
||||
"moment" version should be "2.14.0"
|
||||
`"@freecodecamp/example"` version should be `"1.1.0"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -55,9 +55,9 @@ Add version "2.14.0" of the "moment" package to the `dependencies` field of your
|
|||
(data) => {
|
||||
var packJson = JSON.parse(data);
|
||||
assert.match(
|
||||
packJson.dependencies.moment,
|
||||
/^[\^\~]?2\.14\.0/,
|
||||
'Wrong version of "moment" installed. It should be 2.14.0'
|
||||
packJson.dependencies["@freecodecamp/example"],
|
||||
/^[\^\~]?1\.1\.0/,
|
||||
'Wrong version of "@freecodecamp/example" installed. It should be 1.1.0'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
|
|
@ -20,11 +20,11 @@ The MAJOR version should increment when you make incompatible API changes. The M
|
|||
|
||||
# --instructions--
|
||||
|
||||
In the dependencies section of your package.json file, change the `version` of moment to match MAJOR version 2, MINOR version 10 and PATCH version 2
|
||||
In the dependencies section of your `package.json` file, change the version of `@freecodecamp/example` to match MAJOR version 1, MINOR version 2 and PATCH version 13
|
||||
|
||||
# --hints--
|
||||
|
||||
"dependencies" should include "moment"
|
||||
`"dependencies"` should include `"@freecodecamp/example"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -33,8 +33,8 @@ In the dependencies section of your package.json file, change the `version` of m
|
|||
var packJson = JSON.parse(data);
|
||||
assert.property(
|
||||
packJson.dependencies,
|
||||
'moment',
|
||||
'"dependencies" does not include "moment"'
|
||||
'@freecodecamp/example',
|
||||
'"dependencies" does not include "@freecodecamp/example"'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
@ -43,7 +43,7 @@ In the dependencies section of your package.json file, change the `version` of m
|
|||
);
|
||||
```
|
||||
|
||||
"moment" version should be "2.10.2"
|
||||
`"@freecodecamp/example"` version should be `"1.2.13"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -51,9 +51,9 @@ In the dependencies section of your package.json file, change the `version` of m
|
|||
(data) => {
|
||||
var packJson = JSON.parse(data);
|
||||
assert.equal(
|
||||
packJson.dependencies.moment,
|
||||
'2.10.2',
|
||||
'Wrong version of "moment". It should be 2.10.2'
|
||||
packJson.dependencies["@freecodecamp/example"],
|
||||
'1.2.13',
|
||||
'Wrong version of "@freecodecamp/example". It should be 1.2.13'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
|
|
@ -16,13 +16,13 @@ This same method applies to removing other fields in your package.json as well
|
|||
|
||||
# --instructions--
|
||||
|
||||
Remove the moment package from your dependencies.
|
||||
Remove the `@freecodecamp/example` package from your dependencies.
|
||||
|
||||
**Note:** Make sure you have the right amount of commas after removing it.
|
||||
|
||||
# --hints--
|
||||
|
||||
"dependencies" should not include "moment"
|
||||
`"dependencies"` should not include `"@freecodecamp/example"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -31,8 +31,8 @@ Remove the moment package from your dependencies.
|
|||
var packJson = JSON.parse(data);
|
||||
assert.notProperty(
|
||||
packJson.dependencies,
|
||||
'moment',
|
||||
'"dependencies" still includes "moment"'
|
||||
'@freecodecamp/example',
|
||||
'"dependencies" still includes "@freecodecamp/example"'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
|
|
@ -10,7 +10,7 @@ dashedName: use-the-caret-character-to-use-the-latest-minor-version-of-a-depende
|
|||
|
||||
Similar to how the tilde we learned about in the last challenge allows npm to install the latest PATCH for a dependency, the caret (`^`) allows npm to install future updates as well. The difference is that the caret will allow both MINOR updates and PATCHes.
|
||||
|
||||
Your current version of moment should be "~2.10.2" which allows npm to install to the latest 2.10.x version. If you were to use the caret (^) as a version prefix instead, npm would be allowed to update to any 2.x.x version.
|
||||
Your current version of `@freecodecamp/example` should be "~1.2.13" which allows npm to install to the latest 1.2.x version. If you were to use the caret (^) as a version prefix instead, npm would be allowed to update to any 1.x.x version.
|
||||
|
||||
```json
|
||||
"package": "^1.3.8"
|
||||
|
@ -20,13 +20,13 @@ This would allow updates to any 1.x.x version of the package.
|
|||
|
||||
# --instructions--
|
||||
|
||||
Use the caret (`^`) to prefix the version of moment in your dependencies and allow npm to update it to any new MINOR release.
|
||||
Use the caret (`^`) to prefix the version of `@freecodecamp/example` in your dependencies and allow npm to update it to any new MINOR release.
|
||||
|
||||
**Note:** The version numbers themselves should not be changed.
|
||||
|
||||
# --hints--
|
||||
|
||||
"dependencies" should include "moment"
|
||||
`"dependencies"` should include `"@freecodecamp/example"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -35,8 +35,8 @@ Use the caret (`^`) to prefix the version of moment in your dependencies and all
|
|||
var packJson = JSON.parse(data);
|
||||
assert.property(
|
||||
packJson.dependencies,
|
||||
'moment',
|
||||
'"dependencies" does not include "moment"'
|
||||
'@freecodecamp/example',
|
||||
'"dependencies" does not include "@freecodecamp/example"'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
@ -45,7 +45,7 @@ Use the caret (`^`) to prefix the version of moment in your dependencies and all
|
|||
);
|
||||
```
|
||||
|
||||
"moment" version should match "^2.x.x"
|
||||
`"@freecodecamp/example"` version should match `"^1.x.x"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -53,9 +53,9 @@ Use the caret (`^`) to prefix the version of moment in your dependencies and all
|
|||
(data) => {
|
||||
var packJson = JSON.parse(data);
|
||||
assert.match(
|
||||
packJson.dependencies.moment,
|
||||
/^\^2\./,
|
||||
'Wrong version of "moment". It should be ^2.10.2'
|
||||
packJson.dependencies["@freecodecamp/example"],
|
||||
/^\^1\./,
|
||||
'Wrong version of "@freecodecamp/example". It should be ^1.2.13'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
|
|
@ -18,15 +18,15 @@ To allow an npm dependency to update to the latest PATCH version, you can prefix
|
|||
|
||||
# --instructions--
|
||||
|
||||
In the package.json file, your current rule for how npm may upgrade moment is to use a specific version (2.10.2). But now, you want to allow the latest 2.10.x version.
|
||||
In the package.json file, your current rule for how npm may upgrade `@freecodecamp/example` is to use a specific version (1.2.13). But now, you want to allow the latest 1.2.x version.
|
||||
|
||||
Use the tilde (`~`) character to prefix the version of moment in your dependencies, and allow npm to update it to any new PATCH release.
|
||||
Use the tilde (`~`) character to prefix the version of `@freecodecamp/example` in your dependencies, and allow npm to update it to any new _patch_ release.
|
||||
|
||||
**Note:** The version numbers themselves should not be changed.
|
||||
|
||||
# --hints--
|
||||
|
||||
"dependencies" should include "moment"
|
||||
`"dependencies"` should include `"@freecodecamp/example"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -35,8 +35,8 @@ Use the tilde (`~`) character to prefix the version of moment in your dependenci
|
|||
var packJson = JSON.parse(data);
|
||||
assert.property(
|
||||
packJson.dependencies,
|
||||
'moment',
|
||||
'"dependencies" does not include "moment"'
|
||||
'@freecodecamp/example',
|
||||
'"dependencies" does not include "@freecodecamp/example"'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
@ -45,7 +45,7 @@ Use the tilde (`~`) character to prefix the version of moment in your dependenci
|
|||
);
|
||||
```
|
||||
|
||||
"moment" version should match "~2.10.2"
|
||||
`"@freecodecamp/example"` version should match `"~1.2.13"`.
|
||||
|
||||
```js
|
||||
(getUserInput) =>
|
||||
|
@ -53,9 +53,9 @@ Use the tilde (`~`) character to prefix the version of moment in your dependenci
|
|||
(data) => {
|
||||
var packJson = JSON.parse(data);
|
||||
assert.match(
|
||||
packJson.dependencies.moment,
|
||||
/^\~2\.10\.2/,
|
||||
'Wrong version of "moment". It should be ~2.10.2'
|
||||
packJson.dependencies["@freecodecamp/example"],
|
||||
/^\~1\.2\.13/,
|
||||
'Wrong version of "@freecodecamp/example". It should be ~1.2.13'
|
||||
);
|
||||
},
|
||||
(xhr) => {
|
||||
|
|
Loading…
Reference in New Issue