@gitlab/ui 87.3.0 → 87.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/CHANGELOG.md +14 -0
- package/bin/migrate_custom_utils_to_tw.bundled.mjs +84 -31
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [87.4.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v87.3.1...v87.4.0) (2024-07-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* make Tailwind migrations a 2-steps process ([b148f2b](https://gitlab.com/gitlab-org/gitlab-ui/commit/b148f2bae2064f199c285e1d55ec12bc7a651f8d))
|
|
7
|
+
|
|
8
|
+
## [87.3.1](https://gitlab.com/gitlab-org/gitlab-ui/compare/v87.3.0...v87.3.1) (2024-07-30)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add missing Tailwind equivalent for `gl-flex-shrink-0` ([5e20414](https://gitlab.com/gitlab-org/gitlab-ui/commit/5e20414a18ddd14247862baaf3eedc5390683e82))
|
|
14
|
+
|
|
1
15
|
# [87.3.0](https://gitlab.com/gitlab-org/gitlab-ui/compare/v87.2.1...v87.3.0) (2024-07-30)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -183900,6 +183900,7 @@ var tailwindEquivalents = {
|
|
|
183900
183900
|
"gl-md-flex-direction-row-reverse": "md:gl-flex-row-reverse",
|
|
183901
183901
|
"gl-flex-grow-0!": "!gl-grow-0",
|
|
183902
183902
|
"gl-flex-grow-1": "gl-grow",
|
|
183903
|
+
"gl-flex-shrink-0": "gl-shrink-0",
|
|
183903
183904
|
"gl-md-flex-grow-0": "md:gl-grow-0",
|
|
183904
183905
|
"gl-flex-basis-0": "gl-basis-0",
|
|
183905
183906
|
"gl-flex-basis-quarter": "gl-basis-1/4",
|
|
@@ -184330,32 +184331,48 @@ function runMigrations(contents, migrationsToDo) {
|
|
|
184330
184331
|
}
|
|
184331
184332
|
|
|
184332
184333
|
// bin/migrate_custom_utils_to_tw.mjs
|
|
184333
|
-
function
|
|
184334
|
-
|
|
184334
|
+
function isFrontendFile(file) {
|
|
184335
|
+
return file.endsWith(".js") || file.endsWith(".vue");
|
|
184336
|
+
}
|
|
184337
|
+
function isPositiveAnswer(answer) {
|
|
184338
|
+
const a3 = answer.toLowerCase();
|
|
184339
|
+
return ["y", "yes", ""].includes(a3);
|
|
184340
|
+
}
|
|
184341
|
+
function createRewriter(dryRun, migrationsToDo) {
|
|
184335
184342
|
return async function rewrite(file) {
|
|
184336
184343
|
const contents = await readFile3(file, { encoding: "utf8" });
|
|
184337
|
-
|
|
184344
|
+
const newContents = runMigrations(contents, migrationsToDo);
|
|
184338
184345
|
if (contents === newContents) {
|
|
184339
184346
|
console.warn(`No changes to ${file}`);
|
|
184340
|
-
return;
|
|
184347
|
+
return false;
|
|
184341
184348
|
}
|
|
184342
184349
|
if (dryRun) {
|
|
184343
184350
|
console.warn(`Would fix up ${file}`);
|
|
184344
|
-
return;
|
|
184345
|
-
}
|
|
184346
|
-
if (file.endsWith(".js") || file.endsWith(".vue")) {
|
|
184347
|
-
const prettierConfig = await resolveConfig(file) || {};
|
|
184348
|
-
newContents = await format22(newContents, {
|
|
184349
|
-
filepath: file,
|
|
184350
|
-
...prettierConfig,
|
|
184351
|
-
plugins: [dist_exports],
|
|
184352
|
-
tailwindConfig
|
|
184353
|
-
});
|
|
184351
|
+
return false;
|
|
184354
184352
|
}
|
|
184355
184353
|
await writeFile2(file, newContents, { encoding: "utf8" });
|
|
184356
184354
|
console.warn(`Fixed ${file}`);
|
|
184355
|
+
return true;
|
|
184357
184356
|
};
|
|
184358
184357
|
}
|
|
184358
|
+
async function prettify(tailwindConfig, files) {
|
|
184359
|
+
for (const file of files) {
|
|
184360
|
+
const contents = await readFile3(file, { encoding: "utf8" });
|
|
184361
|
+
const prettierConfig = await resolveConfig(file) || {};
|
|
184362
|
+
const newContents = await format22(contents, {
|
|
184363
|
+
filepath: file,
|
|
184364
|
+
...prettierConfig,
|
|
184365
|
+
plugins: [dist_exports],
|
|
184366
|
+
tailwindConfig
|
|
184367
|
+
});
|
|
184368
|
+
if (contents === newContents) {
|
|
184369
|
+
console.warn(`${file} did not need to be prettified`);
|
|
184370
|
+
} else {
|
|
184371
|
+
await writeFile2(file, newContents, { encoding: "utf8" });
|
|
184372
|
+
console.warn(`Prettified ${file}`);
|
|
184373
|
+
}
|
|
184374
|
+
}
|
|
184375
|
+
}
|
|
184359
184376
|
function validateMigrations(processedMigrations) {
|
|
184360
184377
|
const errors = [];
|
|
184361
184378
|
for (const { from, to: to4 } of processedMigrations) {
|
|
@@ -184451,6 +184468,10 @@ function getArgsParser() {
|
|
|
184451
184468
|
describe: "Don't actually update files, but print more info",
|
|
184452
184469
|
type: "boolean",
|
|
184453
184470
|
default: false
|
|
184471
|
+
}).option("single-step-migration", {
|
|
184472
|
+
describe: "Run the migration in a single step. This means that migrated files are prettified with the Tailwind plugin immediately. Leave this disabled to have a chance to commit migrate files before `prettier-plugin-tailwindcss` re-orders classes.",
|
|
184473
|
+
type: "boolean",
|
|
184474
|
+
default: false
|
|
184454
184475
|
}).help("help");
|
|
184455
184476
|
}
|
|
184456
184477
|
async function main() {
|
|
@@ -184469,32 +184490,64 @@ async function main() {
|
|
|
184469
184490
|
console.warn("Will do approximately %d class migrations:", migrations.length);
|
|
184470
184491
|
console.warn(migrations.map((m3) => ` ${m3.from} => ${m3.to}`).join("\n"));
|
|
184471
184492
|
}
|
|
184472
|
-
const rewrite = createRewriter(program, migrations);
|
|
184493
|
+
const rewrite = createRewriter(program.dryRun, migrations);
|
|
184494
|
+
let files = [];
|
|
184473
184495
|
if (program.fromStdin) {
|
|
184474
184496
|
console.warn("Reading files from stdin:");
|
|
184475
184497
|
for await (const file of readline.createInterface({ input: process.stdin })) {
|
|
184476
184498
|
if (file.trim()) {
|
|
184477
|
-
|
|
184499
|
+
files.push(file);
|
|
184478
184500
|
}
|
|
184479
184501
|
}
|
|
184480
|
-
|
|
184481
|
-
|
|
184482
|
-
|
|
184483
|
-
|
|
184484
|
-
program.dryRun
|
|
184485
|
-
);
|
|
184486
|
-
if (program.dryRun) {
|
|
184487
|
-
console.warn(
|
|
184488
|
-
[`Running on %d files across %d directories`, `(using pattern: %s).`].join("\n"),
|
|
184489
|
-
files.length,
|
|
184490
|
-
directories.length,
|
|
184491
|
-
pattern
|
|
184502
|
+
} else {
|
|
184503
|
+
const filesAndDirectories = await getFilesAndDirectories(
|
|
184504
|
+
program.directories ?? [],
|
|
184505
|
+
program.dryRun
|
|
184492
184506
|
);
|
|
184493
|
-
|
|
184494
|
-
|
|
184507
|
+
files = filesAndDirectories.files;
|
|
184508
|
+
const { pattern, directories } = filesAndDirectories;
|
|
184509
|
+
if (program.dryRun) {
|
|
184510
|
+
console.warn(
|
|
184511
|
+
[`Running on %d files across %d directories`, `(using pattern: %s).`].join("\n"),
|
|
184512
|
+
files.length,
|
|
184513
|
+
directories.length,
|
|
184514
|
+
pattern
|
|
184515
|
+
);
|
|
184516
|
+
console.warn("Directories searched:");
|
|
184517
|
+
console.warn(` ${directories.join("\n ")}`);
|
|
184518
|
+
}
|
|
184495
184519
|
}
|
|
184520
|
+
let migratedFilesCount = 0;
|
|
184496
184521
|
for (const file of files) {
|
|
184497
|
-
await rewrite(file)
|
|
184522
|
+
if (await rewrite(file)) {
|
|
184523
|
+
migratedFilesCount += 1;
|
|
184524
|
+
}
|
|
184525
|
+
}
|
|
184526
|
+
if (migratedFilesCount === 0) {
|
|
184527
|
+
console.warn("No files needed to be migrated");
|
|
184528
|
+
return;
|
|
184529
|
+
}
|
|
184530
|
+
const filesToBePrettified = files.filter((file) => isFrontendFile(file));
|
|
184531
|
+
if (filesToBePrettified.length === 0) {
|
|
184532
|
+
console.warn("No files to be prettified");
|
|
184533
|
+
return;
|
|
184534
|
+
}
|
|
184535
|
+
if (!program.singleStepMigration) {
|
|
184536
|
+
const rl5 = readline.createInterface({
|
|
184537
|
+
input: process.stdin,
|
|
184538
|
+
output: process.stdout
|
|
184539
|
+
});
|
|
184540
|
+
const answer = await rl5.question(`
|
|
184541
|
+
Files have been migrated and will now be prettified.
|
|
184542
|
+
Make sure to commit the changes before proceeding if you would like to track
|
|
184543
|
+
the diff before CSS classes get re-ordered by the Tailwind Prettier plugin.
|
|
184544
|
+
Continue? (Y/n) `);
|
|
184545
|
+
rl5.close();
|
|
184546
|
+
if (isPositiveAnswer(answer)) {
|
|
184547
|
+
await prettify(program.tailwindConfig, filesToBePrettified);
|
|
184548
|
+
}
|
|
184549
|
+
} else {
|
|
184550
|
+
await prettify(program.tailwindConfig, filesToBePrettified);
|
|
184498
184551
|
}
|
|
184499
184552
|
}
|
|
184500
184553
|
main();
|