@ttoss/config 1.18.1 → 1.18.2

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 CHANGED
@@ -1,70 +1,27 @@
1
1
  # @ttoss/config
2
2
 
3
- <strong>@ttoss/config</strong> is an opinionated configuration library for monorepo repositories, packages, and applications. It contains a set of <a href="/docs/core/config/default-configs">default configurations</a> that you can use on your projects.
4
-
5
- Each configuration is customizable and you can extend them with your own. For example, you can use the default `.prettierrc.js` file in your monorepo:
6
-
7
- ```js title=".prettierrc.js"
8
- const { prettierConfig } = require('@ttoss/config');
9
-
10
- module.exports = prettierConfig();
11
- ```
12
-
13
- But, if you want to change the `printWidth` [option](https://prettier.io/docs/en/options.html), you can do so:
14
-
15
- ```js title=".prettierrc.js"
16
- const { prettierConfig } = require('@ttoss/config');
17
-
18
- module.exports = prettierConfig({
19
- printWidth: 120,
20
- });
21
- ```
22
-
23
- You can also pass a second argument to every configuration to handle array's append or overwrite items.
24
-
25
- ```js title="babel.config.js"
26
- const { babelConfig } = require('@ttoss/config');
27
-
28
- // Append plugins (default)
29
- const appendConfig = babelConfig(
30
- {
31
- plugins: ['@babel/plugin-proposal-class-properties'],
32
- },
33
- {
34
- arrayMerge: 'append',
35
- }
36
- );
37
-
38
- const overwriteConfig = babelConfig(
39
- {
40
- plugins: ['@babel/plugin-proposal-class-properties'],
41
- },
42
- {
43
- arrayMerge: 'overwrite',
44
- }
45
- );
46
- ```
3
+ **@ttoss/config** is an opinionated configuration library for [monorepo](#monorepo) and [packages](#packages). It contains a set of [default configurations](./defaults) that you can use on your projects.
47
4
 
48
5
  ## Install
49
6
 
50
7
  ```shell
51
- $ yarn add -DW @ttoss/config @ttoss/eslint-config
8
+ yarn add -DW @ttoss/config
52
9
  ```
53
10
 
54
- It already installs:
55
-
56
- - ESLint
57
- - Prettier
58
- - commitlint
59
- - lint-staged
60
-
61
11
  ## Monorepo
62
12
 
63
- Add the configs of this section on the root of your monorepo. For configs for packages, you can check the section [Packages and Applications](#packages-and-applications). You can check [this monorepo template](https://github.com/ttoss/monorepo) if you want to see the final configuration after following the steps.
13
+ Use the configs of this section on the root of your monorepo.
64
14
 
65
15
  ### ESLint and Prettier
66
16
 
67
- Create `.prettierrc.js` (`touch .prettierrc.js`) and add the following to it:
17
+ Install the following packages:
18
+
19
+ ```shell
20
+ yarn add -DW eslint prettier @ttoss/eslint-config
21
+
22
+ ```
23
+
24
+ Create the `.prettierrc.js` file and add the following configuration:
68
25
 
69
26
  ```js title=".prettierrc.js"
70
27
  const { prettierConfig } = require('@ttoss/config');
@@ -72,7 +29,7 @@ const { prettierConfig } = require('@ttoss/config');
72
29
  module.exports = prettierConfig();
73
30
  ```
74
31
 
75
- Create `.eslintrc.js` (`touch .eslintrc.js`) and add the following to it:
32
+ Create the `.eslintrc.js` file and add the following configuration:
76
33
 
77
34
  ```js title=".eslintrc.js"
78
35
  module.exports = {
@@ -82,15 +39,15 @@ module.exports = {
82
39
 
83
40
  ### Husky, commitlint, and lint-staged
84
41
 
85
- This group of packages will only work if you have already installed [ESLint and Prettier](#eslint-and-prettier).
42
+ This group of packages will only work if you have already installed [ESLint and Prettier](#eslint-and-prettier) because lint-staged will run the `eslint --fix` command.
86
43
 
87
44
  Install the following packages on the root of your monorepo:
88
45
 
89
46
  ```shell
90
- yarn add -DW husky
47
+ yarn add -DW husky @commitlint/cli lint-staged
91
48
  ```
92
49
 
93
- Create `.commitlintrc.js` (`touch .commitlintrc.js`) and add the following to it:
50
+ Create the `.commitlintrc.js` file and add the following configuration:
94
51
 
95
52
  ```js title=".commitlintrc.js"
96
53
  const { commitlintConfig } = require('@ttoss/config');
@@ -98,7 +55,7 @@ const { commitlintConfig } = require('@ttoss/config');
98
55
  module.exports = commitlintConfig();
99
56
  ```
100
57
 
101
- Create `.lintstagedrc.js` (`touch .lintstagedrc.js`) and add the following to it:
58
+ Create the `.lintstagedrc.js` file and add the following configuration:
102
59
 
103
60
  ```js title=".lintstagedrc.js"
104
61
  const { lintstagedConfig } = require('@ttoss/config');
@@ -115,57 +72,13 @@ yarn husky add .husky/commit-msg "yarn commitlint --edit"
115
72
  yarn husky add .husky/pre-commit "yarn lint-staged"
116
73
  ```
117
74
 
118
- ### Lerna and Yarn Workspaces
119
-
120
- Although this package doesn't export any configuration for [Lerna](https://github.com/lerna/lerna) or [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/), it's still useful to have them installed.
121
-
122
- Install [Lerna](https://github.com/lerna/lerna) on the root of your monorepo:
123
-
124
- ```shell
125
- yarn add -DW lerna
126
- ```
127
-
128
- And add `lerna.json` (`touch lerna.json`) config file:
129
-
130
- ```json title="lerna.json"
131
- {
132
- "version": "0.0.0",
133
- "npmClient": "yarn",
134
- "useWorkspaces": true,
135
- "stream": true,
136
- "command": {
137
- "publish": {
138
- "allowBranch": "main",
139
- "conventionalCommits": true,
140
- "message": "chore: publish new version"
141
- },
142
- "version": {
143
- "forcePublish": true
144
- }
145
- }
146
- }
147
- ```
148
-
149
- Finally, add the following in a `package.json` file to configure [Yarn Workspaces](https://classic.yarnpkg.com/lang/en/docs/workspaces/):
75
+ ## Packages
150
76
 
151
- ```json title="package.json"
152
- {
153
- "private": true,
154
- "workspaces": ["packages/**/*"]
155
- }
156
- ```
157
-
158
- ### Turborepo
159
-
160
- Coming soon...
161
-
162
- ## Packages and Applications
163
-
164
- You can use configs below to your packages and applications folders.
77
+ You can use configs below to your packages folders.
165
78
 
166
79
  ### Babel
167
80
 
168
- Add `babel.config.js` (`touch babel.config.js`) on the package folder:
81
+ Add the `babel.config.js` file on the package folder:
169
82
 
170
83
  ```js title="babel.config.js"
171
84
  const { babelConfig } = require('@ttoss/config');
@@ -181,7 +94,7 @@ Install [Jest](https://jestjs.io/) and its types on your package:
181
94
  yarn add -D jest @types/jest
182
95
  ```
183
96
 
184
- Create `jest.config.ts` (`touch jest.config.ts`) on the package folder:
97
+ Create the `jest.config.ts` file on the package folder:
185
98
 
186
99
  ```ts title="jest.config.ts"
187
100
  import { jestConfig } from '@ttoss/config';
@@ -201,15 +114,15 @@ Configure the `test` script on `package.json` of your package:
201
114
 
202
115
  ### Tsup
203
116
 
204
- Use [tsup](https://tsup.egoist.sh/) to bundle your TypeScript package, if you need to.
117
+ Use [tsup](https://tsup.egoist.sh/) to bundle your TypeScript packages.
205
118
 
206
- Install [tsup](https://tsup.egoist.sh/) on the root of your monorepo:
119
+ Install [tsup](https://tsup.egoist.sh/) on your package.
207
120
 
208
121
  ```shell
209
- yarn add -DW tsup
122
+ yarn add -D tsup
210
123
  ```
211
124
 
212
- Create `tsup.config.ts` (`touch tsup.config.ts`) on the package folder:
125
+ Create the `tsup.config.ts` file on the package folder:
213
126
 
214
127
  ```ts title="tsup.config.ts"
215
128
  import { tsupConfig } from '@ttoss/config';
@@ -227,10 +140,10 @@ Configure the `build` script on `package.json`:
227
140
 
228
141
  ### TypeScript
229
142
 
230
- Install [TypeScript](https://www.npmjs.com/package/typescript) on the root of your monorepo:
143
+ Install [TypeScript](https://www.npmjs.com/package/typescript) on your package:
231
144
 
232
145
  ```shell
233
- yarn add -DW typescript
146
+ yarn add -D typescript
234
147
  ```
235
148
 
236
149
  Extend default configuration for each `tsconfig.json` (`touch tsconfig.json`) on the package folder:
@@ -240,3 +153,48 @@ Extend default configuration for each `tsconfig.json` (`touch tsconfig.json`) on
240
153
  "extends": "@ttoss/config/tsconfig.json"
241
154
  }
242
155
  ```
156
+
157
+ ## Extending configurations
158
+
159
+ Each configuration is customizable and you can extend them with your own. For example, you can use the default `.prettierrc.js` file in your monorepo:
160
+
161
+ ```js title=".prettierrc.js"
162
+ const { prettierConfig } = require('@ttoss/config');
163
+
164
+ module.exports = prettierConfig();
165
+ ```
166
+
167
+ But, if you want to change the `printWidth` [option](https://prettier.io/docs/en/options.html), you can do so:
168
+
169
+ ```js title=".prettierrc.js"
170
+ const { prettierConfig } = require('@ttoss/config');
171
+
172
+ module.exports = prettierConfig({
173
+ printWidth: 120,
174
+ });
175
+ ```
176
+
177
+ You can also pass a second argument to every configuration to handle array's append or overwrite items.
178
+
179
+ ```js title="babel.config.js"
180
+ const { babelConfig } = require('@ttoss/config');
181
+
182
+ // Append plugins (default)
183
+ const appendConfig = babelConfig(
184
+ {
185
+ plugins: ['@babel/plugin-proposal-class-properties'],
186
+ },
187
+ {
188
+ arrayMerge: 'append',
189
+ }
190
+ );
191
+
192
+ const overwriteConfig = babelConfig(
193
+ {
194
+ plugins: ['@babel/plugin-proposal-class-properties'],
195
+ },
196
+ {
197
+ arrayMerge: 'overwrite',
198
+ }
199
+ );
200
+ ```
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
2
 
3
3
  // src/configCreator.ts
4
4
  import deepmerge from "deepmerge";
@@ -72,7 +72,10 @@ var defaultConfig6 = {
72
72
  entryPoints: ["src/index.ts"],
73
73
  format: ["cjs", "esm"],
74
74
  legacyOutput: true,
75
- minify: false
75
+ minify: false,
76
+ banner: {
77
+ js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
78
+ }
76
79
  };
77
80
  var tsupConfig = configCreator(defaultConfig6);
78
81
  export {
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
1
2
  "use strict";
2
3
  var __create = Object.create;
3
4
  var __defProp = Object.defineProperty;
@@ -17,7 +18,10 @@ var __copyProps = (to, from, except, desc) => {
17
18
  }
18
19
  return to;
19
20
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
21
25
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
26
 
23
27
  // src/index.ts
@@ -104,7 +108,10 @@ var defaultConfig6 = {
104
108
  entryPoints: ["src/index.ts"],
105
109
  format: ["cjs", "esm"],
106
110
  legacyOutput: true,
107
- minify: false
111
+ minify: false,
112
+ banner: {
113
+ js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`
114
+ }
108
115
  };
109
116
  var tsupConfig = configCreator(defaultConfig6);
110
117
  // Annotate the CommonJS export names for ESM import in node:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/config",
3
- "version": "1.18.1",
3
+ "version": "1.18.2",
4
4
  "description": "Default configuration for packages.",
5
5
  "license": "UNLICENSED",
6
6
  "author": "ttoss",
@@ -39,5 +39,5 @@
39
39
  "publishConfig": {
40
40
  "access": "public"
41
41
  },
42
- "gitHead": "5624791e118681b8ecbe2372bbc61806442df71b"
42
+ "gitHead": "4548135614dd048140cece482703445cf436f39f"
43
43
  }
package/src/tsup.ts CHANGED
@@ -15,6 +15,9 @@ export const defaultConfig: Options = {
15
15
  * Becomes difficult to debug if code is minified.
16
16
  */
17
17
  minify: false,
18
+ banner: {
19
+ js: `/** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */`,
20
+ },
18
21
  };
19
22
 
20
23
  export const tsupConfig = configCreator(defaultConfig);