comment-variables 1.5.0 → 1.5.1
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 +24 -2
- package/generate.variations.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,7 +26,11 @@ npm install -g comment-variables
|
|
|
26
26
|
comment-variables
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Interacts with your root `comments.config.js` file's default exported object to print all the parameters you need to be aware of before running `compress` or `resolve`. Also acts as a dry run validation check. If no error is printed, it means you can run `compress` or `resolve` safely, as long as the printed parameters correspond to what you've expected from your defined config.
|
|
29
|
+
Interacts with your root `comments.config.js` file's default exported object to print all the parameters you need to be aware of before running `compress` or `resolve`. Also acts as a dry run validation check. If no error is printed, it means you can run `compress` or `resolve` safely, as long as the printed parameters correspond to what you've expected from your defined config.
|
|
30
|
+
|
|
31
|
+
Additionally creates a resolved version of your config data as a JSON file, and as a .mjs file exporting both the typedef `ResolvedConfigData` and the object `resolvedConfigData`.
|
|
32
|
+
|
|
33
|
+
If no configuration file is found, a **tutorial mode** is triggered, generating a template config file for you.
|
|
30
34
|
|
|
31
35
|
```
|
|
32
36
|
comment-variables placeholders
|
|
@@ -105,7 +109,25 @@ composedVariablesExclusives:
|
|
|
105
109
|
|
|
106
110
|
In due time, you may end up creating Comment Variables that are exclusively meant to be used to create other Comment Variables – the latter classified as composed variables. Passing an array to this config option, comprised of the keys of these original comment variables (for example, if a Comment Variable placeholder is `$COMMENT#COMMENT` its related key is `COMMENT`), prevents these original comment variables from being affected by the `compress` and `resolve` commands.
|
|
107
111
|
|
|
108
|
-
|
|
112
|
+
**`comment-variables` v2 introduces the concept of variations:**
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
variations:
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Variations provide native support for internationalization to the Comment Variables ecosystem. In fact, since variations aren't limited to languages, they can be applied to any solution of your own based on variants.
|
|
119
|
+
|
|
120
|
+
The `variations` key as an option takes as value an object with the following properties:
|
|
121
|
+
|
|
122
|
+
- `variations.variants`: Defines all variants that have matching variations duly defined within the top-level keys of `data`.
|
|
123
|
+
- `variations.variant`: Defines the current variant that Comment Variables currently resolves to.
|
|
124
|
+
- `variations.referenceData`: Defines the reference variation that all other variations need to have (or aim to have) matching keys with. Requires a JavaScript variable as it needs to be the exact same object as the one referenced at `data[variations.referenceVariant]`.
|
|
125
|
+
- `variations.referenceVariant`: Defines the variant of the reference variation.
|
|
126
|
+
- `variations.allowIncompleteVariations`: Defines the behavior of the error handling in case of variations that do not match one-to-one with the reference variation. If `true`, allows incomplete variations data to remain. If `false`, errors and guides the fixing of missing variations data.
|
|
127
|
+
|
|
128
|
+
When triggering **tutorial mode**, please select `with variations` for a thorough and actionable example.
|
|
129
|
+
|
|
130
|
+
## `comments.config.js`
|
|
109
131
|
|
|
110
132
|
A root `comments.config.js` file looks like this. (This is an earlier version of the config file I'm using to manage my JavaScript comments in this library.)
|
|
111
133
|
|
package/generate.variations.js
CHANGED
|
@@ -62,16 +62,16 @@ const composedVariablesExclusives = [
|
|
|
62
62
|
/* variations */
|
|
63
63
|
|
|
64
64
|
const variations = {
|
|
65
|
-
//
|
|
65
|
+
// Defines all variants that have matching variations duly defined within the top-level keys of `data`.
|
|
66
66
|
variants: {
|
|
67
67
|
[EN]: { label: ENGLISH },
|
|
68
68
|
[FR]: { label: FRANÇAIS },
|
|
69
69
|
},
|
|
70
|
-
//
|
|
70
|
+
// Defines the current variant that Comment Variables currently resolves to.
|
|
71
71
|
variant: FR,
|
|
72
72
|
// Defines the reference variation that all other variations need to have (or aim to have) matching keys with. Requires a JavaScript variable as it needs to be the exact same object as the one referenced at `data[variations.referenceVariant]`.
|
|
73
73
|
referenceData: enData,
|
|
74
|
-
//
|
|
74
|
+
// Defines the variant of the reference variation.
|
|
75
75
|
referenceVariant: EN,
|
|
76
76
|
// Defines the behavior of the error handling in case of variations that do not match one-to-one with the reference variation. If `true`, allows incomplete variations data to remain. If `false`, errors and guides the fixing of missing variations data.
|
|
77
77
|
allowIncompleteVariations: true,
|
package/package.json
CHANGED