create-webiny-project 0.0.0-mt-2 → 0.0.0-unstable.06b2ede40f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +65 -66
- package/bin.js +99 -41
- package/index.js +8 -2
- package/package.json +14 -12
- package/utils/GracefulError.d.ts +1 -0
- package/utils/GracefulError.js +3 -0
- package/utils/GracefulYarnError.d.ts +3 -0
- package/utils/GracefulYarnError.js +31 -0
- package/utils/binaries/yarn-4.6.0.cjs +934 -0
- package/utils/createProject.js +149 -36
- package/utils/{verifyConfig.js → ensureConfig.js} +5 -3
- package/utils/gracefulYarnErrorHandlers/index.js +1 -0
- package/CHANGELOG.md +0 -1808
- package/utils/getYarnVersion.js +0 -10
- /package/utils/{checkProjectName.js → validateProjectName.js} +0 -0
package/README.md
CHANGED
|
@@ -12,27 +12,33 @@ A tool for setting up a new Webiny project.
|
|
|
12
12
|
#### Simple:
|
|
13
13
|
|
|
14
14
|
```
|
|
15
|
-
npx create-webiny-project@
|
|
15
|
+
npx create-webiny-project@local-npm my-test-project --tag local-npm
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
#### Advanced:
|
|
19
19
|
|
|
20
20
|
```
|
|
21
|
-
npx create-webiny-project@
|
|
22
|
-
--tag
|
|
21
|
+
npx create-webiny-project@local-npm my-test-project
|
|
22
|
+
--tag local-npm --no-interactive
|
|
23
23
|
--assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}'
|
|
24
24
|
--template-options '{"region":"eu-central-1","vpc":false}'
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
This usage is more ideal for CI/CD environments, where interactivity is not available.
|
|
28
28
|
|
|
29
|
-
But do note that this is probably more useful to us, Webiny developers, than for actual Webiny projects. This is simply
|
|
29
|
+
But do note that this is probably more useful to us, Webiny developers, than for actual Webiny projects. This is simply
|
|
30
|
+
because in real project's CI/CD pipelines, users would simply start off by cloning the project from their private
|
|
31
|
+
repository, and not create a new one with the above command.
|
|
30
32
|
|
|
31
33
|
## Development Notes
|
|
32
34
|
|
|
33
|
-
Testing this, and related packages (like [cwp-template-aws](./../cwp-template-aws)) is a bit complicated, because in
|
|
35
|
+
Testing this, and related packages (like [cwp-template-aws](./../cwp-template-aws)) is a bit complicated, because in
|
|
36
|
+
order to get the best results, it's recommended to test everything with packages published to a real NPM.
|
|
34
37
|
|
|
35
|
-
But of course, publishing to NPM just to test something is not ideal, and that's why, we
|
|
38
|
+
But of course, publishing to NPM just to test something is not ideal, and that's why, we
|
|
39
|
+
use [Verdaccio](https://verdaccio.org/) instead, which is, basically, an NPM-like service you can run locally. So,
|
|
40
|
+
instead of publishing packages to NPM, you publish them to Verdaccio, which is much cleaner, because everything stays on
|
|
41
|
+
your laptop.
|
|
36
42
|
|
|
37
43
|
#### Usage
|
|
38
44
|
|
|
@@ -40,21 +46,37 @@ So, you've made some changes, and now you'd like to see the `create-webiny-proje
|
|
|
40
46
|
|
|
41
47
|
The following steps show how to do it.
|
|
42
48
|
|
|
49
|
+
#### 0. TLDR
|
|
50
|
+
|
|
51
|
+
1. `yarn verdaccio:start`
|
|
52
|
+
2. `npm config set registry http://localhost:4873`
|
|
53
|
+
3. `yarn release --type=verdaccio`
|
|
54
|
+
|
|
55
|
+
Once the release is done:
|
|
56
|
+
|
|
57
|
+
4. `npx create-webiny-project@local-npm my-test-project --tag local-npm --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}'`
|
|
58
|
+
|
|
43
59
|
#### 1. Start Verdaccio
|
|
44
60
|
|
|
45
|
-
Start by running the `yarn verdaccio:start` command, which will, as the script name itself suggests, spin up Verdaccio
|
|
61
|
+
Start by running the `yarn verdaccio:start` command, which will, as the script name itself suggests, spin up Verdaccio
|
|
62
|
+
locally.
|
|
46
63
|
|
|
47
|
-
> All of the files uploaded to Verdaccio service will be stored in the `.verdaccio` folder, located in your project
|
|
64
|
+
> All of the files uploaded to Verdaccio service will be stored in the `.verdaccio` folder, located in your project
|
|
65
|
+
> root.
|
|
48
66
|
|
|
49
67
|
#### 2. Set default NPM registry
|
|
50
68
|
|
|
51
|
-
Once you have Verdaccio up and running, you'll also need to change the default NPM registry. Meaning, when you
|
|
69
|
+
Once you have Verdaccio up and running, you'll also need to change the default NPM registry. Meaning, when you
|
|
70
|
+
run `npx create-webiny-project ...`, you want it to start fetching packages from Verdaccio, not real NPM. Verdaccio runs
|
|
71
|
+
on localhost, on port 4873, so, in your terminal, run the following command:
|
|
52
72
|
|
|
53
73
|
```
|
|
54
74
|
npm config set registry http://localhost:4873
|
|
55
75
|
```
|
|
56
76
|
|
|
57
|
-
Note that this will only help you with `npx`, but won't help you when a new project foundation is created, and the
|
|
77
|
+
Note that this will only help you with `npx`, but won't help you when a new project foundation is created, and the
|
|
78
|
+
dependencies start to get pulled. This is because we're using yarn2, which actually doesn't respect the values that were
|
|
79
|
+
written by the `npm config set ...` command we just executed.
|
|
58
80
|
|
|
59
81
|
It's super important that, when you're testing your npx project, you also pass the following argument:
|
|
60
82
|
|
|
@@ -62,78 +84,50 @@ It's super important that, when you're testing your npx project, you also pass t
|
|
|
62
84
|
--assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}'
|
|
63
85
|
```
|
|
64
86
|
|
|
65
|
-
This will set the necessary values in yarn2 config file, which will be located in your newly created project. But don't
|
|
87
|
+
This will set the necessary values in yarn2 config file, which will be located in your newly created project. But don't
|
|
88
|
+
worry about it right now, this will be revisited in step 4.
|
|
66
89
|
|
|
67
|
-
> Yarn2 projects don't rely on global configurations and is not installed globally, but on per-project basis. This
|
|
90
|
+
> Yarn2 projects don't rely on global configurations and is not installed globally, but on per-project basis. This
|
|
91
|
+
> allows having multiple versions of yarn2, for different projects.
|
|
68
92
|
|
|
69
|
-
#### 3.
|
|
93
|
+
#### 3. Release
|
|
70
94
|
|
|
71
95
|
Commit (no need to push it if you don't want to) all of the code changes, and execute the following command:
|
|
72
96
|
|
|
97
|
+
```bash
|
|
98
|
+
yarn release --type=verdaccio
|
|
73
99
|
```
|
|
74
|
-
yarn lerna:version:verdaccio
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
This will increment the version of all packages in the repository, create a tag, and do some other preparations that are needed before we start publishing. Note that it will also create a new commit, which MUST NOT be pushed to your remote origin. If you happen to do it by accident, you'll need to revert the changes and push those.
|
|
78
|
-
|
|
79
|
-
Once that's done, you run the following command:
|
|
80
|
-
|
|
81
|
-
```
|
|
82
|
-
yarn lerna:publish:verdaccio
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
This will publish the packages to Verdaccio. Once it's done, you can start testing.
|
|
86
|
-
|
|
87
|
-
> You can also execute both commands immediately with:
|
|
88
|
-
> ```
|
|
89
|
-
> yarn lerna:version:verdaccio && yarn lerna:publish:verdaccio
|
|
90
|
-
> ```
|
|
91
100
|
|
|
92
101
|
#### 4. Test
|
|
93
102
|
|
|
94
103
|
Test your changes with the following command:
|
|
95
104
|
|
|
96
105
|
```
|
|
97
|
-
npx create-webiny-project@
|
|
106
|
+
npx create-webiny-project@local-npm my-test-project --tag local-npm --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}'
|
|
98
107
|
```
|
|
99
108
|
|
|
100
109
|
This should create a project, with all of the packages pulled from Verdaccio.
|
|
101
110
|
|
|
102
|
-
#### 5.
|
|
103
|
-
|
|
104
|
-
If, while testing, you've spotted an error or something that needs to be improved, you should revert the `lerna:version:verdaccio` commit that was made in your repo and start over, by adding your changes, and repeating the step 3.
|
|
105
|
-
|
|
106
|
-
To revert the version commit, you can run `git reset HEAD~ && git reset --hard HEAD`.
|
|
107
|
-
To restart Verdaccio, you can delete the `.verdaccio` folder created in your project root, stop the existing Verdaccio server (just CMD+C in terminal), and start it again with `yarn verdaccio:start`.
|
|
108
|
-
|
|
109
|
-
##### Why not just make another commit, and repeat step 3?
|
|
110
|
-
|
|
111
|
-
The thing is, you will make your commits, and then another `lerna:version:verdaccio` commit, and so on. So, after a while, you'll end up having a mix of your own commits and `lerna:version:verdaccio` commits, and you still need to remove all of the `lerna:version:verdaccio` commits in the end.
|
|
112
|
-
|
|
113
|
-
> If you come up with a better way to do this, feel free to let us know.
|
|
114
|
-
|
|
115
|
-
#### 6. Cleanup
|
|
111
|
+
#### 5. Cleanup
|
|
116
112
|
|
|
117
113
|
Once you're done, do the following:
|
|
118
114
|
|
|
119
|
-
1.
|
|
120
|
-
2. Remove
|
|
121
|
-
3. Reset NPM registry with `npm config set registry https://registry.npmjs.org/`
|
|
122
|
-
4. Remove `.verdaccio` folder
|
|
115
|
+
1. Reset NPM registry with `npm config set registry https://registry.npmjs.org/`
|
|
116
|
+
2. Remove `.verdaccio` folder
|
|
123
117
|
|
|
124
118
|
### Commands Cheat Sheet
|
|
125
119
|
|
|
126
|
-
| Description | Command
|
|
127
|
-
|
|
128
|
-
| Remove `.verdaccio` folder | `rm -rf .verdaccio`
|
|
129
|
-
| List all v5\* tags | `git tag -l "v5*"`
|
|
130
|
-
| Remove specific tag | `git tag -d "v5.0.0-next.5"`
|
|
131
|
-
| Set Verdaccio as the NPM registry | `npm config set registry http://localhost:4873`
|
|
132
|
-
| Reset NPM registry | `npm config set registry https://registry.npmjs.org/`
|
|
133
|
-
| Start Verdaccio | `yarn verdaccio:start`
|
|
134
|
-
|
|
|
135
|
-
| Create a new Webiny project | `npx create-webiny-project@
|
|
136
|
-
| Revert versioning commit | `git reset HEAD~ && git reset --hard HEAD`
|
|
120
|
+
| Description | Command |
|
|
121
|
+
|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
122
|
+
| Remove `.verdaccio` folder | `rm -rf .verdaccio` |
|
|
123
|
+
| List all v5\* tags | `git tag -l "v5*"` |
|
|
124
|
+
| Remove specific tag | `git tag -d "v5.0.0-next.5"` |
|
|
125
|
+
| Set Verdaccio as the NPM registry | `npm config set registry http://localhost:4873` |
|
|
126
|
+
| Reset NPM registry | `npm config set registry https://registry.npmjs.org/` |
|
|
127
|
+
| Start Verdaccio | `yarn verdaccio:start` |
|
|
128
|
+
| Release to Verdaccio | `yarn release --type=verdaccio` | |
|
|
129
|
+
| Create a new Webiny project | `npx create-webiny-project@local-npm my-test-project --tag local-npm --assign-to-yarnrc '{"npmRegistryServer":"http://localhost:4873","unsafeHttpWhitelist":["localhost"]}` |
|
|
130
|
+
| Revert versioning commit | `git reset HEAD~ && git reset --hard HEAD` |
|
|
137
131
|
|
|
138
132
|
## Troubleshooting
|
|
139
133
|
|
|
@@ -141,18 +135,23 @@ Once you're done, do the following:
|
|
|
141
135
|
|
|
142
136
|
This is probably because of one of the Yarn package caching mechanisms.
|
|
143
137
|
|
|
144
|
-
Yarn has two levels of cache - local and shared.
|
|
138
|
+
Yarn has two levels of cache - local and shared.
|
|
145
139
|
|
|
146
|
-
When you install a package, it gets cached in the local cache folder (located in your project), and in the shared cache
|
|
140
|
+
When you install a package, it gets cached in the local cache folder (located in your project), and in the shared cache
|
|
141
|
+
folder. This makes it much faster when you're working on a couple of projects on your local machine, and you're pulling
|
|
142
|
+
the same package in each. If the package doesn't exist in local cache, it will be pulled from shared cache.
|
|
147
143
|
|
|
148
|
-
On Windows, the shared cache folder should be located in: `C:\Users\{USER-NAME}\AppData\Local\Yarn`.
|
|
144
|
+
On Windows, the shared cache folder should be located in: `C:\Users\{USER-NAME}\AppData\Local\Yarn`.
|
|
149
145
|
On Linux/Mac, the shared cache folder should be located in: `/Users/adrian/Library/Caches/Yarn`.
|
|
150
146
|
|
|
151
|
-
In these folders, most probably, you'll also have the `\Berry\cache` folder. But, there were also cases where this
|
|
147
|
+
In these folders, most probably, you'll also have the `\Berry\cache` folder. But, there were also cases where this
|
|
148
|
+
folder did not exist.
|
|
152
149
|
|
|
153
|
-
Deleting the mentioned cache folders should help with the issue of still receiving old packages in your testing
|
|
150
|
+
Deleting the mentioned cache folders should help with the issue of still receiving old packages in your testing
|
|
151
|
+
sessions.
|
|
154
152
|
|
|
155
|
-
With all of this being said, you can also try
|
|
153
|
+
With all of this being said, you can also try
|
|
154
|
+
the [following command](https://yarnpkg.com/features/offline-cache#cleaning-the-cache):
|
|
156
155
|
|
|
157
156
|
```bash
|
|
158
157
|
yarn cache clean --mirror
|
package/bin.js
CHANGED
|
@@ -1,49 +1,107 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const getYarnVersion = require("./utils/getYarnVersion");
|
|
7
|
-
const verifyConfig = require("./utils/verifyConfig");
|
|
3
|
+
// Ensure system requirements are met.
|
|
4
|
+
require("@webiny/system-requirements").ensureSystemRequirements();
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (!semver.satisfies(nodeVersion, "^12 || ^14")) {
|
|
12
|
-
console.error(
|
|
13
|
-
chalk.red(
|
|
14
|
-
[
|
|
15
|
-
`You are running Node.js ${nodeVersion}, but Webiny requires version 12 or 14.`,
|
|
16
|
-
`Please switch to one of the two versions and try again.`,
|
|
17
|
-
"For more information, please visit https://docs.webiny.com/docs/tutorials/install-webiny#prerequisites."
|
|
18
|
-
].join(" ")
|
|
19
|
-
)
|
|
20
|
-
);
|
|
21
|
-
process.exit(1);
|
|
22
|
-
}
|
|
6
|
+
// Verify `.webiny` config file and continue.
|
|
7
|
+
require("./utils/ensureConfig").ensureConfig();
|
|
23
8
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
console.error(
|
|
28
|
-
chalk.red(
|
|
29
|
-
[
|
|
30
|
-
`Webiny requires yarn@^1.22.0 or higher.`,
|
|
31
|
-
`Please visit https://yarnpkg.com/ to install ${chalk.green("yarn")}.`
|
|
32
|
-
].join("\n")
|
|
33
|
-
)
|
|
34
|
-
);
|
|
35
|
-
process.exit(1);
|
|
36
|
-
}
|
|
37
|
-
} catch (err) {
|
|
38
|
-
console.error(
|
|
39
|
-
chalk.red(`Webiny depends on "yarn" and its built-in support for workspaces.`)
|
|
40
|
-
);
|
|
9
|
+
const yargs = require("yargs");
|
|
10
|
+
const packageJson = require("./package.json");
|
|
11
|
+
const createProject = require("./utils/createProject");
|
|
41
12
|
|
|
42
|
-
|
|
13
|
+
process.on("unhandledRejection", err => {
|
|
14
|
+
throw err;
|
|
15
|
+
});
|
|
43
16
|
|
|
17
|
+
yargs
|
|
18
|
+
.usage("Usage: create-webiny-project <project-name> [options]")
|
|
19
|
+
.version(packageJson.version)
|
|
20
|
+
.demandCommand(1)
|
|
21
|
+
.help()
|
|
22
|
+
.alias("help", "h")
|
|
23
|
+
.scriptName("create-webiny-project")
|
|
24
|
+
.fail(function (msg, err) {
|
|
25
|
+
if (msg) {
|
|
26
|
+
console.log(msg);
|
|
27
|
+
}
|
|
28
|
+
if (err) {
|
|
29
|
+
console.log(err);
|
|
30
|
+
}
|
|
44
31
|
process.exit(1);
|
|
45
|
-
}
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// noinspection BadExpressionStatementJS
|
|
35
|
+
yargs.command(
|
|
36
|
+
"$0 <project-name> [options]",
|
|
37
|
+
"Name of application and template to use",
|
|
38
|
+
yargs => {
|
|
39
|
+
yargs.positional("project-name", {
|
|
40
|
+
describe: "Project name"
|
|
41
|
+
});
|
|
42
|
+
yargs.option("force", {
|
|
43
|
+
describe: "All project creation within an existing folder",
|
|
44
|
+
default: false,
|
|
45
|
+
type: "boolean",
|
|
46
|
+
demandOption: false
|
|
47
|
+
});
|
|
48
|
+
yargs.option("template", {
|
|
49
|
+
describe: `Name of template to use, if no template is provided it will default to "aws" template`,
|
|
50
|
+
alias: "t",
|
|
51
|
+
type: "string",
|
|
52
|
+
default: "aws",
|
|
53
|
+
demandOption: false
|
|
54
|
+
});
|
|
55
|
+
yargs.option("template-options", {
|
|
56
|
+
describe: `A JSON containing template-specific options (usually used in non-interactive environments)`,
|
|
57
|
+
default: null,
|
|
58
|
+
type: "string",
|
|
59
|
+
demandOption: false
|
|
60
|
+
});
|
|
61
|
+
yargs.option("assign-to-yarnrc", {
|
|
62
|
+
describe: `A JSON containing additional options that will be assigned into the "yarnrc.yml" configuration file`,
|
|
63
|
+
default: null,
|
|
64
|
+
type: "string",
|
|
65
|
+
demandOption: false
|
|
66
|
+
});
|
|
67
|
+
yargs.option("tag", {
|
|
68
|
+
describe: "NPM tag to use for @webiny packages",
|
|
69
|
+
type: "string",
|
|
70
|
+
default: "latest",
|
|
71
|
+
demandOption: false
|
|
72
|
+
});
|
|
73
|
+
yargs.option("interactive", {
|
|
74
|
+
describe: "Enable interactive mode for all commands",
|
|
75
|
+
default: true,
|
|
76
|
+
type: "boolean",
|
|
77
|
+
demandOption: false
|
|
78
|
+
});
|
|
79
|
+
yargs.option("log", {
|
|
80
|
+
describe:
|
|
81
|
+
"Creates a log file to see output of installation. Defaults to create-webiny-project-logs.txt in current directory",
|
|
82
|
+
alias: "l",
|
|
83
|
+
default: "create-webiny-project-logs.txt",
|
|
84
|
+
type: "string",
|
|
85
|
+
demandOption: false
|
|
86
|
+
});
|
|
87
|
+
yargs.option("debug", {
|
|
88
|
+
describe: "Turn on debug logs",
|
|
89
|
+
default: false,
|
|
90
|
+
type: "boolean",
|
|
91
|
+
demandOption: false
|
|
92
|
+
});
|
|
93
|
+
yargs.option("cleanup", {
|
|
94
|
+
describe: "If an error occurs upon project creation, deletes all generated files",
|
|
95
|
+
alias: "c",
|
|
96
|
+
default: true,
|
|
97
|
+
type: "boolean",
|
|
98
|
+
demandOption: false
|
|
99
|
+
});
|
|
46
100
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
101
|
+
yargs.example("$0 <project-name>");
|
|
102
|
+
yargs.example("$0 <project-name> --template=aws");
|
|
103
|
+
yargs.example("$0 <project-name> --template=../path/to/template");
|
|
104
|
+
yargs.example("$0 <project-name> --log=./my-logs.txt");
|
|
105
|
+
},
|
|
106
|
+
argv => createProject(argv)
|
|
107
|
+
).argv;
|
package/index.js
CHANGED
|
@@ -71,12 +71,18 @@ yargs.command(
|
|
|
71
71
|
});
|
|
72
72
|
yargs.option("log", {
|
|
73
73
|
describe:
|
|
74
|
-
"Creates a log file to see output of installation. Defaults to
|
|
74
|
+
"Creates a log file to see output of installation. Defaults to create-webiny-project-logs.txt in current directory",
|
|
75
75
|
alias: "l",
|
|
76
|
-
default: "
|
|
76
|
+
default: "create-webiny-project-logs.txt",
|
|
77
77
|
type: "string",
|
|
78
78
|
demandOption: false
|
|
79
79
|
});
|
|
80
|
+
yargs.option("debug", {
|
|
81
|
+
describe: "Turn on debug logs",
|
|
82
|
+
default: false,
|
|
83
|
+
type: "boolean",
|
|
84
|
+
demandOption: false
|
|
85
|
+
});
|
|
80
86
|
yargs.option("cleanup", {
|
|
81
87
|
describe: "If an error occurs upon project creation, deletes all generated files",
|
|
82
88
|
alias: "c",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-webiny-project",
|
|
3
|
-
"version": "0.0.0-
|
|
3
|
+
"version": "0.0.0-unstable.06b2ede40f",
|
|
4
4
|
"description": "Webiny project bootstrap tool.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,27 +13,29 @@
|
|
|
13
13
|
"author": "Webiny Ltd.",
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@webiny/
|
|
17
|
-
"
|
|
18
|
-
"
|
|
16
|
+
"@webiny/system-requirements": "0.0.0-unstable.06b2ede40f",
|
|
17
|
+
"@webiny/telemetry": "0.0.0-unstable.06b2ede40f",
|
|
18
|
+
"chalk": "4.1.2",
|
|
19
|
+
"execa": "5.1.1",
|
|
19
20
|
"find-up": "5.0.0",
|
|
20
|
-
"fs-extra": "
|
|
21
|
+
"fs-extra": "11.2.0",
|
|
21
22
|
"js-yaml": "3.14.1",
|
|
22
23
|
"listr": "0.14.3",
|
|
23
24
|
"load-json-file": "6.2.0",
|
|
24
|
-
"node-fetch": "2.6.
|
|
25
|
+
"node-fetch": "2.6.7",
|
|
25
26
|
"os": "0.1.1",
|
|
26
|
-
"p-retry": "4.2
|
|
27
|
-
"rimraf": "
|
|
28
|
-
"semver": "7.3
|
|
29
|
-
"uuid": "
|
|
27
|
+
"p-retry": "4.6.2",
|
|
28
|
+
"rimraf": "6.0.1",
|
|
29
|
+
"semver": "7.6.3",
|
|
30
|
+
"uuid": "9.0.1",
|
|
30
31
|
"validate-npm-package-name": "3.0.0",
|
|
31
32
|
"write-json-file": "4.3.0",
|
|
32
|
-
"yargs": "
|
|
33
|
+
"yargs": "17.7.2",
|
|
34
|
+
"yesno": "0.4.0"
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|
|
35
37
|
"access": "public",
|
|
36
38
|
"directory": "."
|
|
37
39
|
},
|
|
38
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "06b2ede40fc2212a70eeafd74afd50b56fb0ce82"
|
|
39
41
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export class GracefulError extends Error {}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const { GracefulError } = require("./GracefulError");
|
|
2
|
+
const gracefulYarnErrorHandlers = require("./gracefulYarnErrorHandlers");
|
|
3
|
+
|
|
4
|
+
class GracefulYarnError extends GracefulError {
|
|
5
|
+
static from(e, context) {
|
|
6
|
+
if (e instanceof GracefulError) {
|
|
7
|
+
return e;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
for (const handler of gracefulYarnErrorHandlers) {
|
|
11
|
+
const result = handler({ error: e, context });
|
|
12
|
+
if (!result) {
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
let errorMessage = result;
|
|
17
|
+
if (typeof result === "object") {
|
|
18
|
+
const { message, learnMore } = result;
|
|
19
|
+
|
|
20
|
+
errorMessage = message;
|
|
21
|
+
if (learnMore) {
|
|
22
|
+
errorMessage += ` Learn more: ${learnMore}.`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return new GracefulYarnError(errorMessage, { cause: e });
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module.exports = { GracefulYarnError };
|