@mimi-ng/cli 0.2.0 → 0.4.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 +35 -2
- package/dist/init/css.js +1 -1
- package/dist/init/index.js +25 -0
- package/dist/init/paths.js +20 -0
- package/dist/registry.json +385 -14
- package/dist/templates/blocks/login-01/index.ts +1 -0
- package/dist/templates/blocks/login-01/login-01.html +174 -0
- package/dist/templates/blocks/login-01/login-01.ts +105 -0
- package/dist/templates/blocks/login-02/index.ts +1 -0
- package/dist/templates/blocks/login-02/login-02.html +186 -0
- package/dist/templates/blocks/login-02/login-02.ts +92 -0
- package/dist/templates/blocks/otp-01/index.ts +1 -0
- package/dist/templates/blocks/otp-01/otp-01.html +166 -0
- package/dist/templates/blocks/otp-01/otp-01.ts +212 -0
- package/dist/templates/blocks/pricing-01/index.ts +1 -0
- package/dist/templates/blocks/pricing-01/pricing-01.html +173 -0
- package/dist/templates/blocks/pricing-01/pricing-01.ts +178 -0
- package/dist/templates/blocks/settings-01/index.ts +1 -0
- package/dist/templates/blocks/settings-01/settings-01.html +424 -0
- package/dist/templates/blocks/settings-01/settings-01.ts +382 -0
- package/dist/templates/blocks/signup-01/index.ts +1 -0
- package/dist/templates/blocks/signup-01/signup-01.html +332 -0
- package/dist/templates/blocks/signup-01/signup-01.ts +176 -0
- package/dist/templates/components/calendar/calendar-texts.ts +72 -0
- package/dist/templates/components/calendar/calendar.ts +588 -0
- package/dist/templates/components/calendar/dates.ts +181 -0
- package/dist/templates/components/calendar/index.ts +3 -0
- package/dist/templates/components/chip/chip-texts.ts +40 -0
- package/dist/templates/components/chip/chip.ts +116 -0
- package/dist/templates/components/chip/index.ts +2 -0
- package/dist/templates/components/color-picker/color-picker-texts.ts +57 -0
- package/dist/templates/components/color-picker/color-picker.ts +718 -0
- package/dist/templates/components/color-picker/color.ts +157 -0
- package/dist/templates/components/color-picker/index.ts +3 -0
- package/dist/templates/components/combobox/combobox-texts.ts +70 -0
- package/dist/templates/components/combobox/combobox.ts +798 -0
- package/dist/templates/components/combobox/index.ts +2 -0
- package/dist/templates/components/date-picker/date-picker.ts +240 -0
- package/dist/templates/components/date-picker/index.ts +3 -0
- package/dist/templates/components/date-range/date-range.ts +308 -0
- package/dist/templates/components/date-range/index.ts +1 -0
- package/dist/templates/components/file-upload/file-upload-texts.ts +77 -0
- package/dist/templates/components/file-upload/file-upload.ts +698 -0
- package/dist/templates/components/file-upload/index.ts +2 -0
- package/dist/templates/components/input-mask/index.ts +1 -0
- package/dist/templates/components/input-mask/input-mask.ts +319 -0
- package/dist/templates/components/input-otp/index.ts +1 -0
- package/dist/templates/components/input-otp/input-otp.ts +212 -0
- package/dist/templates/components/number-input/index.ts +2 -0
- package/dist/templates/components/number-input/number-input-texts.ts +46 -0
- package/dist/templates/components/number-input/number-input.ts +450 -0
- package/dist/templates/components/option-list/index.ts +11 -0
- package/dist/templates/components/option-list/option-list.ts +518 -0
- package/dist/templates/components/password/index.ts +2 -0
- package/dist/templates/components/password/password-texts.ts +68 -0
- package/dist/templates/components/password/password.ts +363 -0
- package/dist/templates/components/popover/popover.ts +12 -4
- package/dist/templates/components/progress/index.ts +1 -0
- package/dist/templates/components/progress/progress.ts +217 -0
- package/dist/templates/components/select/select.ts +3 -2
- package/dist/templates/components/slider/index.ts +2 -0
- package/dist/templates/components/slider/slider-texts.ts +26 -0
- package/dist/templates/components/slider/slider.ts +425 -0
- package/dist/templates/components/tabs/tabs.ts +88 -23
- package/dist/templates/components/tags-input/index.ts +2 -0
- package/dist/templates/components/tags-input/tags-input-texts.ts +44 -0
- package/dist/templates/components/tags-input/tags-input.ts +303 -0
- package/dist/templates/components/toggle-group/index.ts +1 -0
- package/dist/templates/components/toggle-group/toggle-group.ts +406 -0
- package/dist/templates/theme/provider.ts +13 -0
- package/dist/templates/theme/theme-base.css +103 -0
- package/dist/templates/theme/types.ts +216 -0
- package/dist/templates/utils/overlay.ts +17 -4
- package/dist/ui/index.js +232 -10
- package/dist/ui/schema.json +82 -2
- package/dist/utils/project.js +35 -0
- package/dist/utils/tailwind.js +80 -0
- package/dist/utils/write-files.js +49 -9
- package/package.json +1 -1
package/dist/ui/schema.json
CHANGED
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
"items": {
|
|
10
10
|
"type": "string"
|
|
11
11
|
},
|
|
12
|
-
"description": "Componentes que se agregan (varios a la vez: button input form-field).",
|
|
12
|
+
"description": "Componentes o Blocks que se agregan (varios a la vez: button input form-field, o un Block: login-01).",
|
|
13
13
|
"$default": {
|
|
14
14
|
"$source": "argv",
|
|
15
15
|
"index": 0
|
|
16
16
|
},
|
|
17
17
|
"x-prompt": {
|
|
18
|
-
"message": "¿Qué componentes quieres agregar?",
|
|
18
|
+
"message": "¿Qué componentes o Blocks quieres agregar?",
|
|
19
19
|
"type": "list",
|
|
20
20
|
"multiselect": true,
|
|
21
21
|
"items": [
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
"value": "button",
|
|
32
32
|
"label": "button"
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
"value": "calendar",
|
|
36
|
+
"label": "calendar"
|
|
37
|
+
},
|
|
34
38
|
{
|
|
35
39
|
"value": "card",
|
|
36
40
|
"label": "card"
|
|
@@ -39,6 +43,14 @@
|
|
|
39
43
|
"value": "checkbox",
|
|
40
44
|
"label": "checkbox"
|
|
41
45
|
},
|
|
46
|
+
{
|
|
47
|
+
"value": "color-picker",
|
|
48
|
+
"label": "color-picker"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"value": "combobox",
|
|
52
|
+
"label": "combobox"
|
|
53
|
+
},
|
|
42
54
|
{
|
|
43
55
|
"value": "confirm",
|
|
44
56
|
"label": "confirm"
|
|
@@ -47,6 +59,14 @@
|
|
|
47
59
|
"value": "context-menu",
|
|
48
60
|
"label": "context-menu"
|
|
49
61
|
},
|
|
62
|
+
{
|
|
63
|
+
"value": "date-picker",
|
|
64
|
+
"label": "date-picker"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"value": "date-range",
|
|
68
|
+
"label": "date-range"
|
|
69
|
+
},
|
|
50
70
|
{
|
|
51
71
|
"value": "dialog",
|
|
52
72
|
"label": "dialog"
|
|
@@ -55,6 +75,10 @@
|
|
|
55
75
|
"value": "dropdown-menu",
|
|
56
76
|
"label": "dropdown-menu"
|
|
57
77
|
},
|
|
78
|
+
{
|
|
79
|
+
"value": "file-upload",
|
|
80
|
+
"label": "file-upload"
|
|
81
|
+
},
|
|
58
82
|
{
|
|
59
83
|
"value": "form-field",
|
|
60
84
|
"label": "form-field"
|
|
@@ -63,14 +87,34 @@
|
|
|
63
87
|
"value": "input",
|
|
64
88
|
"label": "input"
|
|
65
89
|
},
|
|
90
|
+
{
|
|
91
|
+
"value": "input-mask",
|
|
92
|
+
"label": "input-mask"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"value": "input-otp",
|
|
96
|
+
"label": "input-otp"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"value": "number-input",
|
|
100
|
+
"label": "number-input"
|
|
101
|
+
},
|
|
66
102
|
{
|
|
67
103
|
"value": "pagination",
|
|
68
104
|
"label": "pagination"
|
|
69
105
|
},
|
|
106
|
+
{
|
|
107
|
+
"value": "password",
|
|
108
|
+
"label": "password"
|
|
109
|
+
},
|
|
70
110
|
{
|
|
71
111
|
"value": "popover",
|
|
72
112
|
"label": "popover"
|
|
73
113
|
},
|
|
114
|
+
{
|
|
115
|
+
"value": "progress",
|
|
116
|
+
"label": "progress"
|
|
117
|
+
},
|
|
74
118
|
{
|
|
75
119
|
"value": "select",
|
|
76
120
|
"label": "select"
|
|
@@ -83,6 +127,10 @@
|
|
|
83
127
|
"value": "skeleton",
|
|
84
128
|
"label": "skeleton"
|
|
85
129
|
},
|
|
130
|
+
{
|
|
131
|
+
"value": "slider",
|
|
132
|
+
"label": "slider"
|
|
133
|
+
},
|
|
86
134
|
{
|
|
87
135
|
"value": "switch",
|
|
88
136
|
"label": "switch"
|
|
@@ -91,6 +139,10 @@
|
|
|
91
139
|
"value": "tabs",
|
|
92
140
|
"label": "tabs"
|
|
93
141
|
},
|
|
142
|
+
{
|
|
143
|
+
"value": "tags-input",
|
|
144
|
+
"label": "tags-input"
|
|
145
|
+
},
|
|
94
146
|
{
|
|
95
147
|
"value": "textarea",
|
|
96
148
|
"label": "textarea"
|
|
@@ -99,6 +151,10 @@
|
|
|
99
151
|
"value": "toast",
|
|
100
152
|
"label": "toast"
|
|
101
153
|
},
|
|
154
|
+
{
|
|
155
|
+
"value": "toggle-group",
|
|
156
|
+
"label": "toggle-group"
|
|
157
|
+
},
|
|
102
158
|
{
|
|
103
159
|
"value": "toolbar",
|
|
104
160
|
"label": "toolbar"
|
|
@@ -106,6 +162,30 @@
|
|
|
106
162
|
{
|
|
107
163
|
"value": "tooltip",
|
|
108
164
|
"label": "tooltip"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"value": "login-01",
|
|
168
|
+
"label": "login-01 (Block)"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"value": "login-02",
|
|
172
|
+
"label": "login-02 (Block)"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
"value": "otp-01",
|
|
176
|
+
"label": "otp-01 (Block)"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"value": "pricing-01",
|
|
180
|
+
"label": "pricing-01 (Block)"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"value": "settings-01",
|
|
184
|
+
"label": "settings-01 (Block)"
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
"value": "signup-01",
|
|
188
|
+
"label": "signup-01 (Block)"
|
|
109
189
|
}
|
|
110
190
|
]
|
|
111
191
|
}
|
package/dist/utils/project.js
CHANGED
|
@@ -1,12 +1,47 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MIMI_COLLECTION = void 0;
|
|
4
|
+
exports.defaultBlocksDir = defaultBlocksDir;
|
|
5
|
+
exports.assertAliases = assertAliases;
|
|
4
6
|
exports.readJson = readJson;
|
|
5
7
|
exports.allDependencies = allDependencies;
|
|
6
8
|
exports.majorOf = majorOf;
|
|
7
9
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
10
|
+
const paths_1 = require("../init/paths");
|
|
8
11
|
/** Nombre de esta colección (el paquete). */
|
|
9
12
|
exports.MIMI_COLLECTION = '@mimi-ng/cli';
|
|
13
|
+
/**
|
|
14
|
+
* Carpeta de los Blocks si mimi.json no la dice: la hermana de `components/` cuando la de
|
|
15
|
+
* componentes es la de siempre (`src/app/components/ui` → `src/app/blocks`), o si no, la hermana
|
|
16
|
+
* de la carpeta de componentes (`src/app/ui` → `src/app/blocks`).
|
|
17
|
+
*/
|
|
18
|
+
function defaultBlocksDir(componentsDir) {
|
|
19
|
+
const parts = componentsDir.split('/').filter(Boolean);
|
|
20
|
+
if (parts.length >= 2 && parts.at(-1) === 'ui' && parts.at(-2) === 'components') {
|
|
21
|
+
parts.splice(-2, 2);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
parts.pop();
|
|
25
|
+
}
|
|
26
|
+
return [...parts, 'blocks'].join('/');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* M2: falla con un error claro (sin escribir nada) si `aliases.components` o `aliases.blocks` de
|
|
30
|
+
* mimi.json es absoluto, tiene `..` o sale del proyecto.
|
|
31
|
+
*/
|
|
32
|
+
function assertAliases(config) {
|
|
33
|
+
for (const name of ['components', 'blocks']) {
|
|
34
|
+
const value = config.aliases?.[name];
|
|
35
|
+
if (value === undefined)
|
|
36
|
+
continue;
|
|
37
|
+
const reason = (0, paths_1.invalidAliasReason)(value);
|
|
38
|
+
if (!reason)
|
|
39
|
+
continue;
|
|
40
|
+
const example = name === 'blocks' ? 'src/app/blocks' : 'src/app/components/ui';
|
|
41
|
+
throw new schematics_1.SchematicsException(`mimi.json → aliases.${name} ${reason}: ${JSON.stringify(value)}. Usa una ruta relativa a ` +
|
|
42
|
+
`la raíz del workspace y dentro de ella (por ejemplo "${example}"). No se cambió nada.`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
10
45
|
function readJson(tree, path) {
|
|
11
46
|
if (!tree.exists(path))
|
|
12
47
|
return null;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.tailwindSupportsSourceNot = tailwindSupportsSourceNot;
|
|
4
|
+
exports.withBlocksSource = withBlocksSource;
|
|
5
|
+
exports.mimiSourceNotLine = mimiSourceNotLine;
|
|
6
|
+
exports.mimiSourceNotPath = mimiSourceNotPath;
|
|
7
|
+
exports.missingMimiExclusion = missingMimiExclusion;
|
|
8
|
+
const css_1 = require("../init/css");
|
|
9
|
+
const paths_1 = require("../init/paths");
|
|
10
|
+
/** La carpeta de las copias originales (`.mimi/base/`), en la raíz del workspace. */
|
|
11
|
+
const MIMI_DIR = '.mimi';
|
|
12
|
+
/**
|
|
13
|
+
* ¿El Tailwind del proyecto entiende `@source not` (4.1 o superior)? Manda la versión instalada
|
|
14
|
+
* (`node_modules`, la que corre de verdad); si no está instalado, el rango de package.json: solo
|
|
15
|
+
* un rango que no puede pasar de la 4.0 (`4.0.5`, `~4.0.17`) cuenta como 4.0. `^4.0.17` instala
|
|
16
|
+
* la última 4.x, así que sí lo entiende.
|
|
17
|
+
*/
|
|
18
|
+
function tailwindSupportsSourceNot(tree, declared) {
|
|
19
|
+
const file = tree.read('node_modules/tailwindcss/package.json');
|
|
20
|
+
const installed = file
|
|
21
|
+
? JSON.parse(file.toString('utf-8')).version
|
|
22
|
+
: undefined;
|
|
23
|
+
if (installed)
|
|
24
|
+
return atLeast41(installed);
|
|
25
|
+
if (!declared)
|
|
26
|
+
return true;
|
|
27
|
+
// Solo un rango exacto o con `~` fija el minor; `^4.0.17`, `>=4`, `^4`, `latest`: la última 4.x.
|
|
28
|
+
const match = /^\s*(?:~|=|v)?\s*(\d+)\.(\d+)/.exec(declared);
|
|
29
|
+
if (!match)
|
|
30
|
+
return true;
|
|
31
|
+
const [major, minor] = [Number(match[1]), Number(match[2])];
|
|
32
|
+
return major > 4 || (major === 4 && minor >= 1);
|
|
33
|
+
}
|
|
34
|
+
function atLeast41(version) {
|
|
35
|
+
const [major, minor] = version.split('.').map((n) => Number.parseInt(n, 10) || 0);
|
|
36
|
+
return major > 4 || (major === 4 && minor >= 1);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Con `source(none)`, Tailwind solo escanea lo que dice un `@source`: la carpeta de los Blocks
|
|
40
|
+
* necesita el suyo (G1), como la de componentes. Devuelve el CSS con la línea agregada (después
|
|
41
|
+
* del `@source` de componentes, o del tema), o `null` si no hace falta: sin `source(none)`, o si
|
|
42
|
+
* ya está (comillas simples o dobles).
|
|
43
|
+
*/
|
|
44
|
+
function withBlocksSource(css, cssPath, componentsDir, blocksDir) {
|
|
45
|
+
const tailwind = (0, css_1.findTailwindImport)(css);
|
|
46
|
+
if (!tailwind?.sourceNone)
|
|
47
|
+
return null;
|
|
48
|
+
const cssDir = (0, paths_1.dirnameOf)(cssPath);
|
|
49
|
+
const path = (0, paths_1.relativePath)(cssDir, blocksDir);
|
|
50
|
+
if ((0, css_1.hasDirective)(css, '@source', path))
|
|
51
|
+
return null;
|
|
52
|
+
const line = `@source "${path}";`;
|
|
53
|
+
const after = new RegExp(String.raw `^[ \t]*@source\s+(["'])` +
|
|
54
|
+
(0, paths_1.relativePath)(cssDir, componentsDir).replace(/[.*+?^${}()|[\]\\]/g, '\\$&') +
|
|
55
|
+
String.raw `\1[^;\n]*;[^\n]*$`, 'm').exec(css);
|
|
56
|
+
if (after) {
|
|
57
|
+
const end = after.index + after[0].length;
|
|
58
|
+
const eol = /\r\n/.test(css) ? '\r\n' : '\n';
|
|
59
|
+
return { css: css.slice(0, end) + eol + line + css.slice(end), line };
|
|
60
|
+
}
|
|
61
|
+
const updated = (0, css_1.insertAfterTheme)(css, [line]);
|
|
62
|
+
return updated === null ? null : { css: updated, line };
|
|
63
|
+
}
|
|
64
|
+
/** La línea que excluye `.mimi/` del escaneo de Tailwind, relativa al CSS global. */
|
|
65
|
+
function mimiSourceNotLine(cssPath) {
|
|
66
|
+
return `@source not "${mimiSourceNotPath(cssPath)}";`;
|
|
67
|
+
}
|
|
68
|
+
function mimiSourceNotPath(cssPath) {
|
|
69
|
+
return (0, paths_1.relativePath)((0, paths_1.dirnameOf)(cssPath), MIMI_DIR);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* ¿Falta la exclusión de `.mimi/` en este CSS? No hace falta con `source(none)` (Tailwind no
|
|
73
|
+
* escanea nada por su cuenta) ni si ya está, con comillas simples o dobles.
|
|
74
|
+
*/
|
|
75
|
+
function missingMimiExclusion(css, cssPath) {
|
|
76
|
+
const tailwind = (0, css_1.findTailwindImport)(css);
|
|
77
|
+
if (!tailwind || tailwind.sourceNone)
|
|
78
|
+
return false;
|
|
79
|
+
return !(0, css_1.hasDirective)(css, '@source not', mimiSourceNotPath(cssPath));
|
|
80
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasFileChanges = exports.emptyReport = exports.MANIFEST = exports.BASE_DIR = void 0;
|
|
3
|
+
exports.isBlockFile = exports.hasFileChanges = exports.emptyReport = exports.MANIFEST = exports.BASE_DIR = void 0;
|
|
4
4
|
exports.projectPathOf = projectPathOf;
|
|
5
|
+
exports.targetPathOf = targetPathOf;
|
|
5
6
|
exports.basePathOf = basePathOf;
|
|
6
7
|
exports.writeTemplates = writeTemplates;
|
|
7
8
|
exports.blockedMessages = blockedMessages;
|
|
@@ -9,6 +10,7 @@ exports.compareVersions = compareVersions;
|
|
|
9
10
|
exports.updatedMessages = updatedMessages;
|
|
10
11
|
const schematics_1 = require("@angular-devkit/schematics");
|
|
11
12
|
const registry_1 = require("../registry");
|
|
13
|
+
const project_1 = require("./project");
|
|
12
14
|
/** Carpeta de las copias originales, en la raíz del workspace. Debe quedar en git. */
|
|
13
15
|
exports.BASE_DIR = '.mimi/base';
|
|
14
16
|
/** Versión de Mimi con la que se escribió la base de cada archivo. */
|
|
@@ -34,7 +36,26 @@ exports.hasFileChanges = hasFileChanges;
|
|
|
34
36
|
function projectPathOf(file) {
|
|
35
37
|
return file.replace(/^components\//, '');
|
|
36
38
|
}
|
|
37
|
-
/**
|
|
39
|
+
/** Prefijo de los archivos de un Block en las plantillas (`blocks/login-01/login-01.ts`). */
|
|
40
|
+
const BLOCKS_PREFIX = 'blocks/';
|
|
41
|
+
/** ¿Es un archivo de un Block? */
|
|
42
|
+
const isBlockFile = (file) => file.startsWith(BLOCKS_PREFIX);
|
|
43
|
+
exports.isBlockFile = isBlockFile;
|
|
44
|
+
/**
|
|
45
|
+
* Ruta en el proyecto de un archivo de las plantillas: los Blocks van a su carpeta, sin
|
|
46
|
+
* `blocks/` (`blocks/login-01/login-01.ts` → `<blocksDir>/login-01/login-01.ts`); el resto, a la
|
|
47
|
+
* de componentes (ver projectPathOf).
|
|
48
|
+
*/
|
|
49
|
+
function targetPathOf(file, componentsDir, blocksDir) {
|
|
50
|
+
return (0, exports.isBlockFile)(file)
|
|
51
|
+
? `${blocksDir}/${file.slice(BLOCKS_PREFIX.length)}`
|
|
52
|
+
: `${componentsDir}/${projectPathOf(file)}`;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Copia original en .mimi/base, con la misma estructura (`.mimi/base/button/button.ts`). Los
|
|
56
|
+
* Blocks conservan `blocks/` (`.mimi/base/blocks/login-01/login-01.ts`), y esa es también su
|
|
57
|
+
* clave en el manifiesto.
|
|
58
|
+
*/
|
|
38
59
|
function basePathOf(file) {
|
|
39
60
|
return `${exports.BASE_DIR}/${projectPathOf(file)}`;
|
|
40
61
|
}
|
|
@@ -61,7 +82,8 @@ function readManifest(tree) {
|
|
|
61
82
|
* - si no, se crean los que faltan y se actualizan los que el usuario no tocó. Los modificados
|
|
62
83
|
* sobre esta versión se conservan (`skipped`).
|
|
63
84
|
*
|
|
64
|
-
* Con `overwrite`, todo se reemplaza y nada se bloquea
|
|
85
|
+
* Con `overwrite`, todo se reemplaza y nada se bloquea, también un archivo igual a su base de la
|
|
86
|
+
* misma versión (`formatted`; M.11). Los ítems `implicit` (el tema y lo que
|
|
65
87
|
* copia init, que `ng g mimi` revisa aunque no se pidan) solo se escriben si hay que
|
|
66
88
|
* actualizarlos: un cambio del usuario sobre la versión actual se respeta en silencio, también
|
|
67
89
|
* con `overwrite`, y no bloquean a otros ítems.
|
|
@@ -87,7 +109,7 @@ function writeTemplates(options) {
|
|
|
87
109
|
const write = (tree) => {
|
|
88
110
|
const manifest = readManifest(tree);
|
|
89
111
|
let manifestChanged = false;
|
|
90
|
-
const targetOf = (file) =>
|
|
112
|
+
const targetOf = (file) => targetPathOf(file, options.componentsDir, options.blocksDir ?? (0, project_1.defaultBlocksDir)(options.componentsDir));
|
|
91
113
|
const stateOf = (file) => {
|
|
92
114
|
const target = targetOf(file);
|
|
93
115
|
if (!tree.exists(target))
|
|
@@ -172,7 +194,16 @@ function writeTemplates(options) {
|
|
|
172
194
|
writeBase(file, content);
|
|
173
195
|
break;
|
|
174
196
|
case 'formatted':
|
|
175
|
-
|
|
197
|
+
// Con --overwrite se reemplaza siempre, también con la misma versión (M.11): sin él,
|
|
198
|
+
// un archivo distinto de la plantilla con la misma versión no se podía reponer.
|
|
199
|
+
if (options.overwrite && !implicit.has(item)) {
|
|
200
|
+
tree.overwrite(target, content);
|
|
201
|
+
options.report.overwritten.push(file);
|
|
202
|
+
writeBase(file, content);
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
options.report.unchanged.push(file);
|
|
206
|
+
}
|
|
176
207
|
break;
|
|
177
208
|
case 'old':
|
|
178
209
|
tree.overwrite(target, content);
|
|
@@ -209,8 +240,8 @@ function writeTemplates(options) {
|
|
|
209
240
|
* Los avisos de los ítems que no se escribieron (`report.blocked`): qué no se actualizó, por qué
|
|
210
241
|
* y qué hacer. Nunca dicen «actualizado».
|
|
211
242
|
*/
|
|
212
|
-
function blockedMessages(report, componentsDir, version) {
|
|
213
|
-
const path = (file) =>
|
|
243
|
+
function blockedMessages(report, componentsDir, version, blocksDir = (0, project_1.defaultBlocksDir)(componentsDir)) {
|
|
244
|
+
const path = (file) => targetPathOf(file, componentsDir, blocksDir);
|
|
214
245
|
return report.blocked.map(({ item, files, dependency, installed }) => {
|
|
215
246
|
if (dependency) {
|
|
216
247
|
const needs = `necesita ${dependency} ${version}, que no se actualizó (ver el aviso de ${dependency}).`;
|
|
@@ -218,9 +249,18 @@ function blockedMessages(report, componentsDir, version) {
|
|
|
218
249
|
? `${item} no se actualizó a ${version}: ${needs}`
|
|
219
250
|
: `${item} no se agregó: ${needs}`;
|
|
220
251
|
}
|
|
221
|
-
const
|
|
222
|
-
const label = isTheme ? 'El tema' : item;
|
|
252
|
+
const type = registry_1.registry.items[item]?.type;
|
|
223
253
|
const dir = projectPathOf(files[0]).split('/').slice(0, -1).join('/');
|
|
254
|
+
if (type === 'block') {
|
|
255
|
+
// Lo normal es editar un Block (es una pantalla del usuario): el aviso no alarma (B.1-b).
|
|
256
|
+
return (`${item} no se actualizó a ${version}: es tu pantalla y la modificaste ` +
|
|
257
|
+
`(${files.map(path).join(', ')}), así que no se tocó ninguno de sus archivos. Es lo ` +
|
|
258
|
+
`normal con un Block. La versión de Mimi que modificaste está en ${exports.BASE_DIR}/${dir}/, ` +
|
|
259
|
+
'para comparar. Si quieres la nueva, guarda tus cambios (por ejemplo, en git) y vuelve ' +
|
|
260
|
+
'a ejecutar el comando con --overwrite: reemplaza tu pantalla entera.');
|
|
261
|
+
}
|
|
262
|
+
const isTheme = type === 'theme';
|
|
263
|
+
const label = isTheme ? 'El tema' : item;
|
|
224
264
|
return (`${label} no se actualizó a ${version} porque modificaste ${files.map(path).join(', ')}. ` +
|
|
225
265
|
'No se cambió ninguno de sus archivos, para no mezclar versiones.' +
|
|
226
266
|
(isTheme
|
package/package.json
CHANGED