Skip to content

Commit 4e62acc

Browse files
authored
Update and rename text/0000-yarn-create.md to implemented/0000-yarn-create.md
1 parent b02a107 commit 4e62acc

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

text/0000-yarn-create.md renamed to implemented/0000-yarn-create.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,35 @@ Despite their utility, using these tools still require to manually install them,
1717
This RFC suggests to add a new command:
1818

1919
```
20-
$> yarn create <package-name>
20+
$> yarn create <name>
2121
```
2222

23-
Running this command would have the samne effect as:
23+
Running this command would have the same effect as:
2424

2525
```
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>
2928
```
3029

3130
One could assume that a simple boilerplate would be configured as such:
3231

33-
```
32+
```json
3433
{
35-
"scripts": {
36-
"create": "cp -rf ./files $npm_create_path"
34+
"bin": {
35+
"yarn-create-hello": "index.js"
3736
}
3837
}
3938
```
4039

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:
4249

4350
```
4451
$> cat package.json
@@ -52,11 +59,7 @@ $> yarn cra eject
5259

5360
# Alternatives
5461

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.
6063

6164
- 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").
6265

0 commit comments

Comments
 (0)