You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: implemented/0000-yarn-create.md
+17-14Lines changed: 17 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,28 +17,35 @@ Despite their utility, using these tools still require to manually install them,
17
17
This RFC suggests to add a new command:
18
18
19
19
```
20
-
$> yarn create <package-name>
20
+
$> yarn create <name>
21
21
```
22
22
23
-
Running this command would have the samne effect as:
23
+
Running this command would have the same effect as:
24
24
25
25
```
26
-
$> yarn add --dev <package-name>
27
-
$> cd node_modules/<package-name>
28
-
$> npm_create_path="$OLDPWD" yarn run create
26
+
$> yarn global add yarn-create-<name>
27
+
$> yarn-create-<name>
29
28
```
30
29
31
30
One could assume that a simple boilerplate would be configured as such:
32
31
33
-
```
32
+
```json
34
33
{
35
-
"scripts": {
36
-
"create": "cp -rf ./files $npm_create_path"
34
+
"bin": {
35
+
"yarn-create-hello": "index.js"
37
36
}
38
37
}
39
38
```
40
39
41
-
This RFC doesn't cover the case where `yarn create` is called in an already existing package without argument - it is suggested that the boilerplate modules register new script commands that the user could then use:
40
+
With `hello.js`:
41
+
42
+
```js
43
+
let fs =require(`fs`);
44
+
45
+
fs.writeFileSync(`hello.md`, `Hello World!~`);
46
+
```
47
+
48
+
This RFC doesn't cover the case where `yarn create <name>` is called in an already existing package - it is suggested that the boilerplate modules register new script commands that the user could then use:
42
49
43
50
```
44
51
$> cat package.json
@@ -52,11 +59,7 @@ $> yarn cra eject
52
59
53
60
# Alternatives
54
61
55
-
- We could do more than just running a script (maybe automatically copying files, etc), but I'm not sure it would be a good idea - I feel like such a feature should remain very simple.
56
-
57
-
- The `$npm_create_path` variable could be an argument instead of an environment variable. However, it would then be harder to use shellscripts as `create` scripts, and would make programming errors more potent (for example, a `create` script that would end with an `rm -rf` would be bad).
58
-
59
-
- The package could be added globally instead of locally, but doing so could cause versioning issues: if we choose to upgrade `<package-name>` when running `yarn create`, then the other projects created before this time would no longer be able to use the previous version. If we choose not to upgrade `<package-name>`, then the users will probably never upgrade at all.
62
+
- We could do more than just running a binary file (maybe automatically copying files, etc), but I'm not sure it would be a good idea - I feel like such a feature should remain very simple.
60
63
61
64
- The script could be named differently. However, "create" isn't currently used as as lifecycle hook, and doesn't see a lot of usage (of the 490,000+ packages on the npm registry, only 33 of them have a script called "create").
0 commit comments