fabrique 0.2.0-beta-1 → 0.2.0
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 +186 -9
- package/package.json +1 -1
- package/templates/lib/CONTRIBUTING.md +2 -2
package/README.md
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|

|
|
4
4
|

|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
# Fabrique
|
|
7
7
|
|
|
8
|
-
`
|
|
8
|
+
`fabrique` is a **cli to create and build libraries**,
|
|
9
9
|
letting the user **focus on the functionalities** of its library, instead of the build process.
|
|
10
10
|
|
|
11
|
-
With `
|
|
11
|
+
With `fabrique` you'll be able to:
|
|
12
12
|
|
|
13
13
|
- create rapidly a library with all the tools and scripts to:
|
|
14
14
|
- build and publish your library
|
|
@@ -17,25 +17,202 @@ With `Fabrique` you'll be able to:
|
|
|
17
17
|
- and debug it
|
|
18
18
|
- upgrade any Fabrique project to get the last functionalities in one command line.
|
|
19
19
|
|
|
20
|
-
`
|
|
20
|
+
`fabrique` is not intended to provide ci scripts and pipelines to automate the processes.
|
|
21
21
|
Instead, it gives a uniform and simple entry point for everyone, to publish rapidly our own libraries,
|
|
22
22
|
on which we may add automation, scripts, and complexity.
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
> `fabrique` is the French word for "made/factory"
|
|
25
|
+
|
|
26
|
+
## Motivation
|
|
25
27
|
|
|
26
28
|
When we develop javascript/typescript libraries, we frequently create new repositories,
|
|
27
29
|
and maintains the scripts to build, test, and debug them.
|
|
28
30
|
This tends to become rapidly cumbersome, especially when their number grows.
|
|
29
31
|
We may choose to opt in for a _monorepo_, and I'll tell you: yes, in many cases, this is the optimal solution.
|
|
30
|
-
However, in many other cases, one library per-repo makes sense, and this is where `
|
|
32
|
+
However, in many other cases, one library per-repo makes sense, and this is where `fabrique` comes in.
|
|
31
33
|
|
|
32
34
|
Another goal is to focus on simplicity: for new incomers in javascript,
|
|
33
35
|
learning all the tools and build processes is complicated.
|
|
34
36
|
You want to write your library, but you have to learn `vite`, `jest`, how to build and publish a lib,
|
|
35
|
-
install `prettier`, etc. With `
|
|
37
|
+
install `prettier`, etc. With `fabrique` all comes in pre-configured.
|
|
38
|
+
|
|
39
|
+
## 📝 Documentation
|
|
40
|
+
|
|
41
|
+
### Requirements
|
|
42
|
+
|
|
43
|
+
The library requires [Node.js](https://nodejs.org/en) `22+` and [yarn](https://yarnpkg.com/) `4+`.
|
|
44
|
+
|
|
45
|
+
### Installation
|
|
46
|
+
|
|
47
|
+
We recommend to use [npx](https://docs.npmjs.com/cli/v8/commands/npx):
|
|
48
|
+
|
|
49
|
+
```shell
|
|
50
|
+
npx fabrique CMD
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
But, you may prefer to install globally `fabrique`:
|
|
54
|
+
|
|
55
|
+
```shell
|
|
56
|
+
npm install -g fabrique
|
|
57
|
+
```
|
|
58
|
+
And run a command with:
|
|
59
|
+
|
|
60
|
+
```shell
|
|
61
|
+
fabrique CMD
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
### List of commands
|
|
66
|
+
|
|
67
|
+
#### create
|
|
68
|
+
|
|
69
|
+
```shell
|
|
70
|
+
npx fabrique upgrade lib [name]
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
##### example
|
|
74
|
+
|
|
75
|
+
```shell
|
|
76
|
+
npx fabrique create @my-company/my-library
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
##### action
|
|
80
|
+
|
|
81
|
+
This command creates a new library with the name `[name]` inside the folder `./[name]` (in our example: `./@my-company/my-library`).
|
|
82
|
+
You'll be prompted for a description, author and git url.
|
|
83
|
+
|
|
84
|
+
> INFO: run the command where you want to create your project.
|
|
85
|
+
|
|
86
|
+
##### options
|
|
87
|
+
|
|
88
|
+
- `[name]`: the library name
|
|
89
|
+
|
|
90
|
+
#### upgrade
|
|
91
|
+
|
|
92
|
+
```shell
|
|
93
|
+
npx fabrique upgrade
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
##### action
|
|
97
|
+
|
|
98
|
+
This command updates an existing `fabrique` project: it updates the build files, the scripts, etc.
|
|
99
|
+
It tries to be non-destructive.
|
|
100
|
+
|
|
101
|
+
> INFO: run the command **inside** the `fabrique` project.
|
|
102
|
+
|
|
103
|
+
##### options
|
|
104
|
+
|
|
105
|
+
- `--force`: forces an upgrade even if the lib is not a `fabrique` project or if the version is identical. _Use with caution._
|
|
106
|
+
|
|
107
|
+
#### refactor
|
|
108
|
+
|
|
109
|
+
```shell
|
|
110
|
+
npx fabrique refactor [from] [to]
|
|
111
|
+
```
|
|
36
112
|
|
|
37
|
-
|
|
113
|
+
##### example
|
|
38
114
|
|
|
39
115
|
```shell
|
|
40
|
-
|
|
116
|
+
npx fabrique refactor my-component my-new-component
|
|
41
117
|
```
|
|
118
|
+
|
|
119
|
+
> Refactors all files and directories containing `my-component` as name into `my-new-component` (recursively).
|
|
120
|
+
> And all text content `my-component` (or derived cases) into `my-new-component` (keeping the same case).
|
|
121
|
+
|
|
122
|
+
If we run it with the following files:
|
|
123
|
+
|
|
124
|
+
- some-component
|
|
125
|
+
- my-component
|
|
126
|
+
- my-component.ts
|
|
127
|
+
- my-component-abc
|
|
128
|
+
- my-component-abc.ts
|
|
129
|
+
|
|
130
|
+
We get:
|
|
131
|
+
|
|
132
|
+
- some-component
|
|
133
|
+
- my-new-component
|
|
134
|
+
- my-new-component.ts
|
|
135
|
+
- my-new-component-abc
|
|
136
|
+
- my-new-component-abc.ts
|
|
137
|
+
|
|
138
|
+
And with this file content:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
class MyComponent {}
|
|
142
|
+
|
|
143
|
+
// my-component
|
|
144
|
+
const MY_COMPONENT = null;
|
|
145
|
+
function my_component(myComponent: MyComponent) {}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
We get:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
class MyNewComponent {}
|
|
152
|
+
|
|
153
|
+
// my-new-component
|
|
154
|
+
const MY_NEW_COMPONENT = null;
|
|
155
|
+
function my_new_component(myNewComponent: MyNewComponent) {}
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
##### action
|
|
159
|
+
|
|
160
|
+
This command refactors files and directories recursively from the `cwd` (by default, the current directory in which the script is executed).
|
|
161
|
+
It preserves the case of the names (ex: `dash-case`, or `cameCase`).
|
|
162
|
+
|
|
163
|
+
> INFO: run the command inside the folder that you want to refactor.
|
|
164
|
+
|
|
165
|
+
##### options
|
|
166
|
+
|
|
167
|
+
- `[from]`: the "source" text to refactor. Must be `dash-case`.
|
|
168
|
+
- `[to]`: the "destination" text to refactor. Must be `dash-case`.
|
|
169
|
+
- `--dry` (default: false): runs without modifying the files. This is useful to check if your refactoring is safe or not.
|
|
170
|
+
- `--cwd` (default: current folder): specifies the directory to start from.
|
|
171
|
+
|
|
172
|
+
#### verdaccio
|
|
173
|
+
|
|
174
|
+
```shell
|
|
175
|
+
npx fabrique verdaccio
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Installs and lauches [verdaccio](https://verdaccio.org/). This is useful to debug interdependent libraries.
|
|
179
|
+
|
|
180
|
+
Let's say we have:
|
|
181
|
+
|
|
182
|
+
- a library `my-lib-a`
|
|
183
|
+
- a library `my-lib-b` with `my-lib-a` as `dependency`
|
|
184
|
+
|
|
185
|
+
If we're working on `my-lib-a`, and want to test if it works on `my-lib-b`, we'll publish a `dev` version of `my-lib-a` on a local `verdaccio`.
|
|
186
|
+
And consume this dev version on `my-lib-b`.
|
|
187
|
+
|
|
188
|
+
> We choose verdaccio instead of `npm link` because versions and dev packages are unique with a package registry.
|
|
189
|
+
>
|
|
190
|
+
> Thus, we may have `my-lib-b` consuming `my-lib-a-dev.0` and `my-lib-c` consuming `my-lib-a-dev.1`, which is not possible with `npm link`.
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
#### version
|
|
194
|
+
|
|
195
|
+
```shell
|
|
196
|
+
npx fabrique --version
|
|
197
|
+
# or
|
|
198
|
+
npx fabrique -v
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
Returns the current `fabrique` version.
|
|
202
|
+
|
|
203
|
+
#### help
|
|
204
|
+
|
|
205
|
+
```shell
|
|
206
|
+
npx fabrique --help
|
|
207
|
+
# or
|
|
208
|
+
npx fabrique -h
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
You may get help on individual commands:
|
|
212
|
+
|
|
213
|
+
```shell
|
|
214
|
+
npx fabrique create -h
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ This projet is open to everyone. Feel free to test the library, share it, improv
|
|
|
4
4
|
|
|
5
5
|
### Getting started
|
|
6
6
|
|
|
7
|
-
The library requires [Node.js](https://nodejs.org/en) `22+` and
|
|
7
|
+
The library requires [Node.js](https://nodejs.org/en) `22+` and [yarn](https://yarnpkg.com/).
|
|
8
8
|
|
|
9
9
|
First, we have to switch to the correct version of node:
|
|
10
10
|
|
|
@@ -12,7 +12,7 @@ First, we have to switch to the correct version of node:
|
|
|
12
12
|
nvm use
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
If you don't have
|
|
15
|
+
If you don't have [nvm](https://github.com/nvm-sh/nvm), you may manually install and use Node.js 22+.
|
|
16
16
|
|
|
17
17
|
Then, we have to use the proper package manager (here `yarn`):
|
|
18
18
|
|