fabrique 0.2.0-beta-1 → 0.2.4

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/.yarnrc.yml CHANGED
@@ -2,3 +2,5 @@ nodeLinker: node-modules
2
2
 
3
3
  unsafeHttpWhitelist:
4
4
  - localhost
5
+
6
+ yarnPath: .yarn/releases/yarn-4.6.0.cjs
package/README.md CHANGED
@@ -3,12 +3,12 @@
3
3
  ![NPM](https://img.shields.io/npm/l/fabrique.svg)
4
4
  ![npm type definitions](https://img.shields.io/npm/types/fabrique.svg)
5
5
 
6
- ## Fabrique
6
+ # Fabrique
7
7
 
8
- `Fabrique` is a **cli to create and build libraries**,
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 `Fabrique` you'll be able to:
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
- `Fabrique` is not intended to provide ci scripts and pipelines to automate the processes.
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
- ### Motivation
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 `Fabrique` comes in.
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 `Fabrique` all comes in pre-configured.
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
- ## 📦 Installation
113
+ ##### example
38
114
 
39
115
  ```shell
40
- yarn add fabrique
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fabrique",
3
- "version": "0.2.0-beta-1",
3
+ "version": "0.2.4",
4
4
  "type": "module",
5
5
  "main": "./src/index.js",
6
6
  "bin": "./src/index.js",
@@ -19,15 +19,15 @@
19
19
  "type": "git",
20
20
  "url": "https://github.com/lifaon74/fabrique"
21
21
  },
22
- "packageManager": "yarn@4.5.1",
22
+ "packageManager": "yarn@4.6.0",
23
23
  "devDependencies": {
24
- "@inquirer/prompts": "^7.0.1",
25
- "prettier": "^3.3.3",
24
+ "@inquirer/prompts": "^7.2.1",
25
+ "prettier": "^3.4.2",
26
26
  "prettier-plugin-organize-imports": "^4.1.0",
27
- "typescript": "^5.6.3"
27
+ "typescript": "^5.7.2"
28
28
  },
29
29
  "dependencies": {
30
- "chalk": "^5.3.0",
31
- "commander": "^12.1.0"
30
+ "chalk": "^5.4.1",
31
+ "commander": "^13.0.0"
32
32
  }
33
33
  }
@@ -94,7 +94,7 @@ export async function upgrade({ force = false } = {}) {
94
94
  async function upgradeFiles(templatePath, destinationPath) {
95
95
  // files to exclude
96
96
  const exclude = [
97
- /^src(?:\/.*)?$/,
97
+ /^src(?:[\\\/].*)?$/,
98
98
  /^README\.md$/,
99
99
  /^LICENSE$/,
100
100
  /^package\.json$/,