@roblexperu/style 1.0.59 → 1.1.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/.eslintrc.js +21 -0
- package/.husky/pre-commit +4 -0
- package/CLAUDE.md +52 -0
- package/README.md +123 -0
- package/fonts-icons.js +17 -4
- package/package.json +14 -11
- package/scripts/version-update.js +93 -80
- package/test/js/fonts-icons.test.js +53 -0
- package/test/js/version-update.test.js +49 -0
- package/test/sass/flexbox.test.js +4 -0
- package/test/sass/flexbox.test.scss +479 -0
- package/test/sass/fonts.test.js +4 -0
- package/test/sass/fonts.test.scss +243 -0
- package/test/sass/media.test.js +4 -0
- package/test/sass/media.test.scss +103 -0
- package/.huskyrc.js +0 -6
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
root: true,
|
|
3
|
+
env: {
|
|
4
|
+
node: true,
|
|
5
|
+
es2021: true,
|
|
6
|
+
},
|
|
7
|
+
parserOptions: {
|
|
8
|
+
ecmaVersion: 2021,
|
|
9
|
+
sourceType: 'script',
|
|
10
|
+
},
|
|
11
|
+
extends: 'eslint:recommended',
|
|
12
|
+
overrides: [
|
|
13
|
+
{
|
|
14
|
+
files: ['test/**/*.js'],
|
|
15
|
+
env: {
|
|
16
|
+
jest: true,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
ignorePatterns: ['public/', 'webfonts/', 'fonts/', 'node_modules/'],
|
|
21
|
+
};
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# CLAUDE.md
|
|
2
|
+
|
|
3
|
+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
4
|
+
|
|
5
|
+
## What this is
|
|
6
|
+
|
|
7
|
+
`@roblexperu/style` is a Sass (SCSS) design-system/component-library package for Roblex. It compiles to a single distributable stylesheet (`public/css/roblex-style.css`) that consuming apps import. There is no JS application logic here — this repo is styles, an icon font, and web fonts, published to npm.
|
|
8
|
+
|
|
9
|
+
## Commands
|
|
10
|
+
|
|
11
|
+
- `npm run build` — compile `src/main.scss` → `public/css/roblex-style.css` (expanded, with source map)
|
|
12
|
+
- `npm run build:prod` — same, but compressed output (used for releases)
|
|
13
|
+
- `npm run build:watch` — compile on change, for local development
|
|
14
|
+
- `npm start` — serve `./public` via `live-server` on port 4444, for visually checking compiled CSS
|
|
15
|
+
- `npm run lint:js` — ESLint over `**/*.js` (only `scripts/version-update.js` and `fonts-icons.js` are JS in this repo; runs automatically on staged JS files via husky pre-commit + lint-staged)
|
|
16
|
+
- `npm run build:icon` — regenerates the icon font from `./svg/*.svg` using `fontello-offline-cli`, then runs `fonts-icons.js` to copy the generated font/CSS into `fonts/`, `public/fonts/RoblexIcons`, and `src/icons/_roblex-icons-codes.scss`. Run this after adding/removing/editing an SVG icon in `./svg/`.
|
|
17
|
+
- `npm run update-version` / `npm run push` — interactive version bump (patch/minor/major/preupdate) via `scripts/version-update.js`, which also commits and tags; `push` then runs `npm publish`. This mutates git history and publishes — don't run without the user asking.
|
|
18
|
+
|
|
19
|
+
There is no test suite in this repo.
|
|
20
|
+
|
|
21
|
+
## Architecture
|
|
22
|
+
|
|
23
|
+
Everything is assembled from `src/main.scss`, which imports (in order): Bootstrap 4, then design layers under `src/`, each with its own `_index.scss` partial acting as a barrel file:
|
|
24
|
+
|
|
25
|
+
1. `vars/` — Sass variables and maps: colors (`_colors.scss`, incl. the `$colors-roblex` map), breakpoints, base vars (CDN/font path), flexbox vars. No selectors, just tokens.
|
|
26
|
+
2. `mixins/` — reusable mixins: flexbox helpers, media-query breakpoints, `@font-face`/font-size helpers.
|
|
27
|
+
3. `typography/` — font-face declarations for the two brand typefaces (Maax, Publica Sans Round) plus the icon font (`_roblex-icons.scss`) and color-utility classes.
|
|
28
|
+
4. `atoms/` — smallest reusable UI primitives: buttons, inputs, checkboxes/radios, select, toggle, avatar, divider, rating, progress.
|
|
29
|
+
5. `organisms/` — composed, higher-level components built from atoms: navbar/header, footer, card, dropdown, steps, modal, snack-bar, sidepanel, trading-calculator, calculate, califications, schedule-notifications.
|
|
30
|
+
6. `pages/` — page-specific style blocks (accounts, authentication, changes, operations, profile, main).
|
|
31
|
+
7. `utility/` — utility classes (display, cursor, page-level helpers, sweet-alert overrides).
|
|
32
|
+
8. `icons/` — imports `_roblex-icons-codes.scss`, the generated icon character-code map (do not hand-edit; regenerate via `npm run build:icon`).
|
|
33
|
+
|
|
34
|
+
When adding a new component partial, create the `_name.scss` file in the appropriate layer (atoms/organisms/pages/utility) and add an `@import` line to that layer's `_index.scss` — nothing is auto-globbed.
|
|
35
|
+
|
|
36
|
+
Z-index conventions are documented as a comment at the bottom of `src/main.scss`:
|
|
37
|
+
- `navbar-header`: 1001
|
|
38
|
+
- `roblex-modal`: 2001
|
|
39
|
+
- `cdk-overlay-container`: 4001
|
|
40
|
+
|
|
41
|
+
## Icon font pipeline
|
|
42
|
+
|
|
43
|
+
Source icons live as individual SVGs in `./svg/`. `npm run build:icon` runs `fontello-offline-cli` against `./svg/` to produce a webfont bundle in `./webfonts/`, then `fonts-icons.js` copies the results into place:
|
|
44
|
+
- `./fonts` → `./public/fonts/`
|
|
45
|
+
- `./webfonts/font` → `./public/fonts/RoblexIcons`
|
|
46
|
+
- `./webfonts/css/roblex-font-icons-codes.scss` → `src/icons/_roblex-icons-codes.scss`
|
|
47
|
+
|
|
48
|
+
`webfonts/config.json` is the Fontello project config (re-importable at fontello.com). Never hand-edit `src/icons/_roblex-icons-codes.scss` or the contents of `webfonts/font` — they're generated.
|
|
49
|
+
|
|
50
|
+
## Fonts
|
|
51
|
+
|
|
52
|
+
Two brand typefaces are vendored under `./fonts/` (Maax, PublicaSansRound) and served from `$cdn: 'https://cdn.roblex.pe/fonts'` (see `src/vars/_var.scss`) with a local `$path-fonts: '/assets'` fallback path used in dev.
|
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# @roblexperu/style
|
|
2
|
+
|
|
3
|
+
Librería de estilos (Sass/SCSS) del sistema de diseño de Roblex. Compila a una
|
|
4
|
+
única hoja de estilos distribuible (`public/css/roblex-style.css`) que
|
|
5
|
+
consumen las apps de Roblex, e incluye además la fuente de íconos propia y las
|
|
6
|
+
tipografías de marca (Maax, Publica Sans Round). No contiene lógica de
|
|
7
|
+
aplicación en JS: es únicamente estilos, fuente de íconos y web fonts.
|
|
8
|
+
|
|
9
|
+
## Instalación
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @roblexperu/style
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Uso
|
|
16
|
+
|
|
17
|
+
**Opción A — hoja de estilos ya compilada** (la forma documentada de consumo):
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
// angular.json
|
|
21
|
+
"styles": [
|
|
22
|
+
"node_modules/@roblexperu/style/public/css/roblex-style.css"
|
|
23
|
+
]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Opción B — importar el SCSS fuente**, si tu app necesita acceso a las
|
|
27
|
+
variables/mixins (colores, breakpoints, tipografía, etc.):
|
|
28
|
+
|
|
29
|
+
```scss
|
|
30
|
+
// styles.scss de la app consumidora
|
|
31
|
+
@import '~@roblexperu/style/src/main';
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Scripts
|
|
35
|
+
|
|
36
|
+
| Script | Descripción |
|
|
37
|
+
| --- | --- |
|
|
38
|
+
| `npm run build` | Compila `src/main.scss` → `public/css/roblex-style.css` (expandido, con source map) |
|
|
39
|
+
| `npm run build:prod` | Igual, pero comprimido (usado para releases) |
|
|
40
|
+
| `npm run build:watch` | Compila en cada cambio, para desarrollo local |
|
|
41
|
+
| `npm start` | Sirve `./public` con `live-server` en el puerto 4444, para revisar visualmente el CSS compilado |
|
|
42
|
+
| `npm test` | Corre la suite de pruebas unitarias (Jest: mixins Sass vía `sass-true` + scripts JS) |
|
|
43
|
+
| `npm run lint:js` | ESLint sobre `**/*.js` (corre automático en pre-commit vía husky + lint-staged) |
|
|
44
|
+
| `npm run build:icon` | Regenera la fuente de íconos desde `./svg/*.svg` con `fontello-offline-cli`, y copia el resultado a `fonts/`, `public/fonts/RoblexIcons` y `src/icons/_roblex-icons-codes.scss`. Correr después de agregar/editar/quitar un ícono en `./svg/` |
|
|
45
|
+
| `npm run update-version` | Bump interactivo de versión (patch/minor/major/preupdate) vía `scripts/version-update.js`; también commitea y taggea |
|
|
46
|
+
| `npm run push` | `update-version` + `npm publish`. Muta el historial de git y publica — no correr sin confirmación explícita |
|
|
47
|
+
|
|
48
|
+
## Arquitectura
|
|
49
|
+
|
|
50
|
+
Todo se ensambla desde `src/main.scss`, que importa (en este orden)
|
|
51
|
+
Bootstrap 4 y luego las capas del sistema de diseño bajo `src/`, cada una con
|
|
52
|
+
su propio `_index.scss` como barrel file:
|
|
53
|
+
|
|
54
|
+
1. **`vars/`** — variables y mapas de Sass: colores (`_colors.scss`, incluye
|
|
55
|
+
el mapa `$colors-roblex`), breakpoints, variables base (CDN/ruta de
|
|
56
|
+
fuentes), variables de flexbox. Sin selectores, solo tokens.
|
|
57
|
+
2. **`mixins/`** — mixins reutilizables: helpers de flexbox, breakpoints por
|
|
58
|
+
media query, helpers de `@font-face`/tamaño de fuente.
|
|
59
|
+
3. **`typography/`** — declaraciones `@font-face` de las dos tipografías de
|
|
60
|
+
marca (Maax, Publica Sans Round), la fuente de íconos
|
|
61
|
+
(`_roblex-icons.scss`) y clases utilitarias de color.
|
|
62
|
+
4. **`atoms/`** — primitivas de UI más pequeñas y reutilizables: botones,
|
|
63
|
+
inputs, checkboxes/radios, select, toggle, avatar, divider, rating,
|
|
64
|
+
progress.
|
|
65
|
+
5. **`organisms/`** — componentes compuestos de mayor nivel, construidos a
|
|
66
|
+
partir de átomos: navbar/header, footer, card, dropdown, steps, modal,
|
|
67
|
+
snack-bar, sidepanel, trading-calculator, calculate, califications,
|
|
68
|
+
schedule-notifications.
|
|
69
|
+
6. **`pages/`** — bloques de estilos específicos de página (accounts,
|
|
70
|
+
authentication, changes, operations, profile, main).
|
|
71
|
+
7. **`utility/`** — clases utilitarias (display, cursor, helpers de página,
|
|
72
|
+
overrides de sweet-alert).
|
|
73
|
+
8. **`icons/`** — importa `_roblex-icons-codes.scss`, el mapa de códigos de
|
|
74
|
+
caracteres de la fuente de íconos generado automáticamente (no editar a
|
|
75
|
+
mano; regenerar con `npm run build:icon`).
|
|
76
|
+
|
|
77
|
+
Al agregar un componente nuevo, creá el archivo `_nombre.scss` en la capa
|
|
78
|
+
correspondiente (atoms/organisms/pages/utility) y agregá el `@import` en el
|
|
79
|
+
`_index.scss` de esa capa — nada se importa automáticamente por glob.
|
|
80
|
+
|
|
81
|
+
### Convenciones de z-index
|
|
82
|
+
|
|
83
|
+
Documentadas como comentario al final de `src/main.scss`:
|
|
84
|
+
|
|
85
|
+
- `navbar-header`: 1001
|
|
86
|
+
- `roblex-modal`: 2001
|
|
87
|
+
- `cdk-overlay-container`: 4001
|
|
88
|
+
|
|
89
|
+
## Pipeline de íconos
|
|
90
|
+
|
|
91
|
+
Los íconos fuente viven como SVGs individuales en `./svg/`.
|
|
92
|
+
`npm run build:icon` corre `fontello-offline-cli` contra `./svg/` para
|
|
93
|
+
generar un bundle de webfont en `./webfonts/`, y luego `fonts-icons.js` copia
|
|
94
|
+
el resultado:
|
|
95
|
+
|
|
96
|
+
- `./fonts` → `./public/fonts/`
|
|
97
|
+
- `./webfonts/font` → `./public/fonts/RoblexIcons`
|
|
98
|
+
- `./webfonts/css/roblex-font-icons-codes.scss` → `src/icons/_roblex-icons-codes.scss`
|
|
99
|
+
|
|
100
|
+
`webfonts/config.json` es la configuración del proyecto Fontello
|
|
101
|
+
(reimportable en fontello.com). Nunca editar a mano
|
|
102
|
+
`src/icons/_roblex-icons-codes.scss` ni el contenido de `webfonts/font` —
|
|
103
|
+
son generados.
|
|
104
|
+
|
|
105
|
+
## Fuentes
|
|
106
|
+
|
|
107
|
+
Las dos tipografías de marca están vendoreadas en `./fonts/` (Maax,
|
|
108
|
+
PublicaSansRound) y se sirven desde `$cdn: 'https://cdn.roblex.pe/fonts'`
|
|
109
|
+
(ver `src/vars/_var.scss`), con `$path-fonts: '/assets'` como ruta local de
|
|
110
|
+
fallback en desarrollo.
|
|
111
|
+
|
|
112
|
+
## Tests
|
|
113
|
+
|
|
114
|
+
`npm test` corre Jest sobre `test/`:
|
|
115
|
+
|
|
116
|
+
- **`test/sass/`** — pruebas de los mixins de Sass (flexbox, media,
|
|
117
|
+
tipografía) usando [`sass-true`](https://github.com/oddbird/true),
|
|
118
|
+
comparando el CSS realmente compilado contra el esperado.
|
|
119
|
+
- **`test/js/`** — pruebas de los scripts de build (`scripts/version-update.js`,
|
|
120
|
+
`fonts-icons.js`).
|
|
121
|
+
|
|
122
|
+
Requiere Node dentro del rango declarado en `engines` (compatible con
|
|
123
|
+
Angular 15: `^14.20.0 || ^16.13.0 || >=18.10.0`).
|
package/fonts-icons.js
CHANGED
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
const fs = require('fs-extra');
|
|
2
2
|
|
|
3
|
+
const FILE_MAP = [
|
|
4
|
+
[ './fonts', './public/fonts/' ],
|
|
5
|
+
[ './webfonts/font', './public/fonts/RoblexIcons' ],
|
|
6
|
+
[ './webfonts/css/roblex-font-icons-codes.scss', './src/icons/_roblex-icons-codes.scss' ]
|
|
7
|
+
];
|
|
8
|
+
|
|
3
9
|
// Async/Await:
|
|
4
10
|
async function copyFiles() {
|
|
5
11
|
try {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
for ( const [ src, dest ] of FILE_MAP ) {
|
|
13
|
+
await fs.copy(src, dest);
|
|
14
|
+
}
|
|
9
15
|
console.log('success janus-fonts-icons!');
|
|
10
16
|
} catch (err) {
|
|
11
17
|
console.error(err);
|
|
12
18
|
}
|
|
13
19
|
}
|
|
14
20
|
|
|
15
|
-
|
|
21
|
+
if ( require.main === module ) {
|
|
22
|
+
copyFiles();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = {
|
|
26
|
+
copyFiles,
|
|
27
|
+
FILE_MAP
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roblexperu/style",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "package for styles",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "sass src/main.scss public/css/roblex-style.css ",
|
|
@@ -10,26 +10,29 @@
|
|
|
10
10
|
"start": "live-server ./public --cors --port=4444",
|
|
11
11
|
"update-version": "node scripts/version-update.js",
|
|
12
12
|
"push": "npm run update-version && npm publish",
|
|
13
|
-
"lint:js": "eslint . --ext .js"
|
|
13
|
+
"lint:js": "eslint . --ext .js",
|
|
14
|
+
"test": "jest",
|
|
15
|
+
"prepare": "husky install"
|
|
14
16
|
},
|
|
15
17
|
"author": "roblex",
|
|
16
18
|
"license": "ISC",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "^14.20.0 || ^16.13.0 || >=18.10.0"
|
|
21
|
+
},
|
|
17
22
|
"dependencies": {
|
|
18
23
|
"bootstrap": "^4.6.0",
|
|
19
24
|
"live-server": "^1.2.1"
|
|
20
25
|
},
|
|
21
26
|
"devDependencies": {
|
|
22
27
|
"chalk": "^4.1.0",
|
|
28
|
+
"eslint": "^8.57.1",
|
|
23
29
|
"fontello-offline-cli": "^7.0.0",
|
|
24
|
-
"fs-extra": "^
|
|
25
|
-
"husky": "^
|
|
26
|
-
"
|
|
30
|
+
"fs-extra": "^11.4.0",
|
|
31
|
+
"husky": "^8.0.3",
|
|
32
|
+
"jest": "^29.7.0",
|
|
33
|
+
"lint-staged": "^12.5.0",
|
|
27
34
|
"prompts": "^2.4.0",
|
|
28
|
-
"sass": "
|
|
29
|
-
|
|
30
|
-
"husky": {
|
|
31
|
-
"hooks": {
|
|
32
|
-
"pre-commit": "ng lint"
|
|
33
|
-
}
|
|
35
|
+
"sass": ">=1.58.0 <1.83.0",
|
|
36
|
+
"sass-true": "^7.0.0"
|
|
34
37
|
}
|
|
35
38
|
}
|
|
@@ -7,67 +7,105 @@ const {
|
|
|
7
7
|
} = require('child_process');
|
|
8
8
|
const chalk = require('chalk');
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
function parseVersionString(versionString) {
|
|
11
|
+
const preversion = versionString.split('-');
|
|
12
|
+
const version = preversion[0].split('.');
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
if ( version.length !== 3 ) {
|
|
15
|
+
throw new Error('Formato de versión incorrecto');
|
|
16
|
+
}
|
|
15
17
|
|
|
16
|
-
|
|
17
|
-
console.log('Formato de versión incorrecto', err);
|
|
18
|
-
process.exit(1);
|
|
18
|
+
return { version, prerelease: preversion[1] };
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
function computeNextVersion(versionString, bumpType) {
|
|
22
|
+
const { version, prerelease } = parseVersionString(versionString);
|
|
23
|
+
let [ p, n, m ] = version;
|
|
24
|
+
let nextPrerelease = prerelease;
|
|
25
|
+
|
|
26
|
+
switch (bumpType) {
|
|
27
|
+
case 'patch':
|
|
28
|
+
m = `${ (+m) + 1 }`;
|
|
29
|
+
nextPrerelease = undefined;
|
|
30
|
+
break;
|
|
31
|
+
case 'minor':
|
|
32
|
+
n = `${ (+n) + 1 }`;
|
|
33
|
+
m = '0';
|
|
34
|
+
nextPrerelease = undefined;
|
|
35
|
+
break;
|
|
36
|
+
case 'major':
|
|
37
|
+
p = `${ (+p) + 1 }`;
|
|
38
|
+
n = '0';
|
|
39
|
+
m = '0';
|
|
40
|
+
nextPrerelease = undefined;
|
|
41
|
+
break;
|
|
42
|
+
case 'preupdate':
|
|
43
|
+
nextPrerelease = prerelease !== undefined ? `${ (+prerelease) + 1 }` : '0';
|
|
44
|
+
break;
|
|
45
|
+
default:
|
|
46
|
+
throw new Error(`Tipo de versión desconocido: ${ bumpType }`);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const nextVersion = [ p, n, m ].join('.');
|
|
50
|
+
return nextPrerelease !== undefined ? `${ nextVersion }-${ nextPrerelease }` : nextVersion;
|
|
24
51
|
}
|
|
25
52
|
|
|
26
|
-
|
|
27
|
-
const minor = `${ p }.${ chalk.bold.dim.yellowBright(+n + 1) }.0`;
|
|
28
|
-
const major = `${ chalk.bold.dim.yellowBright(+p + 1) }.0.0`;
|
|
29
|
-
|
|
30
|
-
const preUpdate = `${ p }.${ n }.${ m }-${ chalk.bold.dim.yellowBright(+preversion[1] + 1 || 0) }`;
|
|
31
|
-
|
|
32
|
-
const question = [ {
|
|
33
|
-
type: 'select',
|
|
34
|
-
name: 'version',
|
|
35
|
-
message: `Seleccione la versión a subir. (Actual: ${ currentVersion })`,
|
|
36
|
-
choices: [
|
|
37
|
-
{
|
|
38
|
-
title: `Patch: ${ patch }`,
|
|
39
|
-
value: 'patch'
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
title: `Minor: ${ minor }`,
|
|
43
|
-
value: 'minor'
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
title: `Major: ${ major }`,
|
|
47
|
-
value: 'major'
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: `Preupdate: ${ preUpdate }`,
|
|
51
|
-
value: 'preupdate'
|
|
52
|
-
}
|
|
53
|
-
]
|
|
54
|
-
} ];
|
|
53
|
+
function run() {
|
|
55
54
|
|
|
56
|
-
(
|
|
55
|
+
validateWorkspace();
|
|
57
56
|
|
|
58
|
-
const
|
|
57
|
+
const { version, prerelease } = parseVersionString(packageJson.version);
|
|
58
|
+
const [ p, n, m ] = version;
|
|
59
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let currentVersion = version.join('.');
|
|
61
|
+
if ( prerelease ) {
|
|
62
|
+
currentVersion += `-${ prerelease }`;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
const patch = `${ p }.${ n }.${ chalk.bold.dim.yellowBright(+m + 1) }`;
|
|
66
|
+
const minor = `${ p }.${ chalk.bold.dim.yellowBright(+n + 1) }.0`;
|
|
67
|
+
const major = `${ chalk.bold.dim.yellowBright(+p + 1) }.0.0`;
|
|
68
|
+
|
|
69
|
+
const preUpdate = `${ p }.${ n }.${ m }-${ chalk.bold.dim.yellowBright(+prerelease + 1 || 0) }`;
|
|
70
|
+
|
|
71
|
+
const question = [ {
|
|
72
|
+
type: 'select',
|
|
73
|
+
name: 'version',
|
|
74
|
+
message: `Seleccione la versión a subir. (Actual: ${ currentVersion })`,
|
|
75
|
+
choices: [
|
|
76
|
+
{
|
|
77
|
+
title: `Patch: ${ patch }`,
|
|
78
|
+
value: 'patch'
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
title: `Minor: ${ minor }`,
|
|
82
|
+
value: 'minor'
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
title: `Major: ${ major }`,
|
|
86
|
+
value: 'major'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
title: `Preupdate: ${ preUpdate }`,
|
|
90
|
+
value: 'preupdate'
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
} ];
|
|
94
|
+
|
|
95
|
+
(async () => {
|
|
68
96
|
|
|
97
|
+
const response = await prompts(question);
|
|
69
98
|
|
|
70
|
-
|
|
99
|
+
if ( !response.version ) {
|
|
100
|
+
console.log(chalk.red.bold('No se seleccionó ninguna opción'));
|
|
101
|
+
process.exit(1);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
packageJson.version = computeNextVersion(packageJson.version, response.version);
|
|
105
|
+
writePackageJson();
|
|
106
|
+
|
|
107
|
+
})();
|
|
108
|
+
}
|
|
71
109
|
|
|
72
110
|
function validateWorkspace() {
|
|
73
111
|
const workSpace = spawnSync('git', [ 'status', '--porcelain' ]);
|
|
@@ -99,13 +137,6 @@ function writePackageJson() {
|
|
|
99
137
|
});
|
|
100
138
|
}
|
|
101
139
|
|
|
102
|
-
function updatePackageJsonVersion() {
|
|
103
|
-
packageJson.version = version.join('.');
|
|
104
|
-
if ( preversion[1] ) {
|
|
105
|
-
packageJson.version += `-${ preversion[1] }`;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
140
|
function gitUpdate() {
|
|
110
141
|
const addGit = spawnSync('git', [ 'add', '-A' ]);
|
|
111
142
|
if ( addGit.error ) {
|
|
@@ -124,29 +155,11 @@ function gitUpdate() {
|
|
|
124
155
|
}
|
|
125
156
|
}
|
|
126
157
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
case 'patch':
|
|
130
|
-
version[2] = `${ (+m) + 1 }`;
|
|
131
|
-
preversion[1] = undefined;
|
|
132
|
-
break;
|
|
133
|
-
case 'minor':
|
|
134
|
-
version[1] = `${ (+n) + 1 }`;
|
|
135
|
-
version[2] = '0';
|
|
136
|
-
preversion[1] = undefined;
|
|
137
|
-
break;
|
|
138
|
-
case 'major':
|
|
139
|
-
version[0] = `${ (+p) + 1 }`;
|
|
140
|
-
version[1] = '0';
|
|
141
|
-
version[2] = '0';
|
|
142
|
-
preversion[1] = undefined;
|
|
143
|
-
break;
|
|
144
|
-
case 'preupdate':
|
|
145
|
-
if ( preversion[1] ) {
|
|
146
|
-
preversion[1] = (+preversion[1]) + 1;
|
|
147
|
-
} else {
|
|
148
|
-
preversion[1] = '0';
|
|
149
|
-
}
|
|
150
|
-
break;
|
|
151
|
-
}
|
|
158
|
+
if ( require.main === module ) {
|
|
159
|
+
run();
|
|
152
160
|
}
|
|
161
|
+
|
|
162
|
+
module.exports = {
|
|
163
|
+
parseVersionString,
|
|
164
|
+
computeNextVersion
|
|
165
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
jest.mock('fs-extra');
|
|
2
|
+
|
|
3
|
+
const fs = require('fs-extra');
|
|
4
|
+
const { copyFiles, FILE_MAP } = require('../../fonts-icons');
|
|
5
|
+
|
|
6
|
+
describe('copyFiles', () => {
|
|
7
|
+
afterEach(() => {
|
|
8
|
+
jest.clearAllMocks();
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('copies fonts, the icon webfont, and the generated icon codes scss to their destinations, in order', async () => {
|
|
12
|
+
fs.copy.mockResolvedValue();
|
|
13
|
+
|
|
14
|
+
await copyFiles();
|
|
15
|
+
|
|
16
|
+
expect(fs.copy).toHaveBeenCalledTimes(FILE_MAP.length);
|
|
17
|
+
FILE_MAP.forEach(([ src, dest ], index) => {
|
|
18
|
+
expect(fs.copy).toHaveBeenNthCalledWith(index + 1, src, dest);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('logs a success message once every copy resolves', async () => {
|
|
23
|
+
fs.copy.mockResolvedValue();
|
|
24
|
+
const consoleLogSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
25
|
+
|
|
26
|
+
await copyFiles();
|
|
27
|
+
|
|
28
|
+
expect(consoleLogSpy).toHaveBeenCalledWith('success janus-fonts-icons!');
|
|
29
|
+
consoleLogSpy.mockRestore();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('logs the error instead of throwing when a copy fails', async () => {
|
|
33
|
+
const error = new Error('boom');
|
|
34
|
+
fs.copy.mockRejectedValueOnce(error);
|
|
35
|
+
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
36
|
+
|
|
37
|
+
await expect(copyFiles()).resolves.toBeUndefined();
|
|
38
|
+
|
|
39
|
+
expect(consoleErrorSpy).toHaveBeenCalledWith(error);
|
|
40
|
+
consoleErrorSpy.mockRestore();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('stops copying the remaining files once one copy fails', async () => {
|
|
44
|
+
fs.copy
|
|
45
|
+
.mockResolvedValueOnce()
|
|
46
|
+
.mockRejectedValueOnce(new Error('boom'));
|
|
47
|
+
jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
48
|
+
|
|
49
|
+
await copyFiles();
|
|
50
|
+
|
|
51
|
+
expect(fs.copy).toHaveBeenCalledTimes(2);
|
|
52
|
+
});
|
|
53
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const { parseVersionString, computeNextVersion } = require('../../scripts/version-update');
|
|
2
|
+
|
|
3
|
+
describe('parseVersionString', () => {
|
|
4
|
+
it('splits a plain semver string into its numeric parts', () => {
|
|
5
|
+
expect(parseVersionString('1.0.59')).toEqual({
|
|
6
|
+
version: [ '1', '0', '59' ],
|
|
7
|
+
prerelease: undefined
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('splits a prerelease version into its numeric parts and prerelease counter', () => {
|
|
12
|
+
expect(parseVersionString('1.0.59-3')).toEqual({
|
|
13
|
+
version: [ '1', '0', '59' ],
|
|
14
|
+
prerelease: '3'
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('throws when the version does not have exactly 3 numeric segments', () => {
|
|
19
|
+
expect(() => parseVersionString('1.0')).toThrow('Formato de versión incorrecto');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('computeNextVersion', () => {
|
|
24
|
+
it('bumps the patch segment and drops any existing prerelease', () => {
|
|
25
|
+
expect(computeNextVersion('1.0.59-3', 'patch')).toBe('1.0.60');
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('bumps the minor segment and resets the patch segment to 0', () => {
|
|
29
|
+
expect(computeNextVersion('1.2.59', 'minor')).toBe('1.3.0');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('bumps the major segment and resets minor and patch to 0', () => {
|
|
33
|
+
expect(computeNextVersion('1.2.59', 'major')).toBe('2.0.0');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('starts a prerelease counter at 0 when there is no existing prerelease', () => {
|
|
37
|
+
expect(computeNextVersion('1.0.59', 'preupdate')).toBe('1.0.59-0');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('increments an existing prerelease counter', () => {
|
|
41
|
+
expect(computeNextVersion('1.0.59-3', 'preupdate')).toBe('1.0.59-4');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('throws for an unrecognized bump type', () => {
|
|
45
|
+
expect(() => computeNextVersion('1.0.59', 'unknown')).toThrow(
|
|
46
|
+
'Tipo de versión desconocido: unknown'
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
});
|