@dialpad/dialtone-css 9.3.0 → 9.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/lib/build/js/dialtone_migrate/git_environment.mjs +13 -0
- package/lib/build/js/dialtone_migrate/index.mjs +43 -8
- package/lib/build/js/dialtone_migrate/test.mjs +116 -5
- package/lib/build/js/dialtone_migrate_text_variant/index.mjs +227 -0
- package/lib/build/js/dialtone_migrate_text_variant/test.mjs +108 -0
- package/lib/build/less/components/slider.less +13 -0
- package/lib/dist/dialtone-default-theme.css +7 -0
- package/lib/dist/dialtone-default-theme.min.css +1 -1
- package/lib/dist/dialtone-docs.json +1 -1
- package/lib/dist/dialtone.css +7 -0
- package/lib/dist/dialtone.min.css +1 -1
- package/lib/dist/js/dialtone_migrate/git_environment.mjs +13 -0
- package/lib/dist/js/dialtone_migrate/index.mjs +43 -8
- package/lib/dist/js/dialtone_migrate/test.mjs +116 -5
- package/lib/dist/js/dialtone_migrate_text_variant/index.mjs +227 -0
- package/lib/dist/js/dialtone_migrate_text_variant/test.mjs +108 -0
- package/lib/dist/no-layers/dialtone-default-theme.css +7 -0
- package/lib/dist/no-layers/dialtone-default-theme.min.css +1 -1
- package/lib/dist/no-layers/dialtone.css +7 -0
- package/lib/dist/no-layers/dialtone.min.css +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
export function gitEnvironment (cwd) {
|
|
4
|
+
const env = { ...process.env, LC_ALL: 'C' };
|
|
5
|
+
const names = new Set(execFileSync('git', ['rev-parse', '--local-env-vars'], {
|
|
6
|
+
cwd, env, encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'],
|
|
7
|
+
}).trim().split(/\r?\n/));
|
|
8
|
+
names.add('GIT_CEILING_DIRECTORIES');
|
|
9
|
+
for (const name of Object.keys(env)) {
|
|
10
|
+
if (names.has(name.toUpperCase())) delete env[name];
|
|
11
|
+
}
|
|
12
|
+
return env;
|
|
13
|
+
}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* --health-check Report migration status without modifying files
|
|
20
20
|
* --all Run all required migrations without selection prompt
|
|
21
21
|
* --include-opt-in Also run opt-in migrations (with --all, or on its own = everything)
|
|
22
|
-
* --only <ids> Comma-separated list of migration IDs to run
|
|
22
|
+
* --only <ids> Comma-separated list of migration IDs to run (in supplied order)
|
|
23
23
|
* --package <name> Package name to use for injected component imports
|
|
24
24
|
* (default: @dialpad/dialtone-vue). Useful when running
|
|
25
25
|
* Dialtone under a custom package alias (e.g. @dialpad/dialtone-next).
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
* npx dialtone-migrate --health-check --cwd ./src
|
|
31
31
|
* npx dialtone-migrate --all --dry-run
|
|
32
32
|
* npx dialtone-migrate --only color-stops,hsl-to-oklch
|
|
33
|
+
* npx dialtone-migrate --only typography,text-variant --dry-run
|
|
33
34
|
*/
|
|
34
35
|
|
|
35
36
|
import { spawn, execFileSync } from 'node:child_process';
|
|
@@ -37,6 +38,8 @@ import fs from 'fs/promises';
|
|
|
37
38
|
import path from 'path';
|
|
38
39
|
import readline from 'readline';
|
|
39
40
|
import { fileURLToPath } from 'node:url';
|
|
41
|
+
import { transformContent as transformTextVariant } from '../dialtone_migrate_text_variant/index.mjs';
|
|
42
|
+
import { gitEnvironment } from './git_environment.mjs';
|
|
40
43
|
|
|
41
44
|
const __filename = fileURLToPath(import.meta.url);
|
|
42
45
|
const __dirname = path.dirname(__filename);
|
|
@@ -360,6 +363,16 @@ const MIGRATIONS = [
|
|
|
360
363
|
],
|
|
361
364
|
fileExtensions: ['.vue', '.html'],
|
|
362
365
|
},
|
|
366
|
+
{
|
|
367
|
+
id: 'text-variant',
|
|
368
|
+
name: 'Text Kind and Size to Variant',
|
|
369
|
+
description: 'Convert static DtText kind + size pairs to variant; preserve explicit variants and report uncertain inputs.',
|
|
370
|
+
category: 'opt-in',
|
|
371
|
+
type: 'standalone',
|
|
372
|
+
scriptDir: 'dialtone_migrate_text_variant',
|
|
373
|
+
detectPatterns: [],
|
|
374
|
+
fileExtensions: ['.vue', '.html'],
|
|
375
|
+
},
|
|
363
376
|
{
|
|
364
377
|
id: 'vue3-to-vue-imports',
|
|
365
378
|
name: 'Vue 3 Import Paths',
|
|
@@ -386,6 +399,7 @@ function getRepoRoot (cwd) {
|
|
|
386
399
|
try {
|
|
387
400
|
return execFileSync('git', ['rev-parse', '--show-toplevel'], {
|
|
388
401
|
cwd,
|
|
402
|
+
env: gitEnvironment(cwd),
|
|
389
403
|
encoding: 'utf8',
|
|
390
404
|
stdio: ['ignore', 'pipe', 'ignore'],
|
|
391
405
|
}).trim();
|
|
@@ -463,7 +477,7 @@ Options:
|
|
|
463
477
|
--health-check Report migration status without modifying files
|
|
464
478
|
--all Run all required migrations without selection prompt
|
|
465
479
|
--include-opt-in Also run opt-in migrations (with --all, or on its own = everything)
|
|
466
|
-
--only <ids> Comma-separated list of migration IDs to run
|
|
480
|
+
--only <ids> Comma-separated list of migration IDs to run (in supplied order)
|
|
467
481
|
--package <name> Package name to use for injected component imports
|
|
468
482
|
(default: @dialpad/dialtone-vue). Useful when running
|
|
469
483
|
Dialtone under a custom package alias (e.g. @dialpad/dialtone-next).
|
|
@@ -481,6 +495,12 @@ Examples:
|
|
|
481
495
|
npx dialtone-migrate --all --dry-run # Dry-run all required
|
|
482
496
|
npx dialtone-migrate --all --include-opt-in --yes # Run required + opt-in
|
|
483
497
|
npx dialtone-migrate --only color-stops,hsl-to-oklch --yes
|
|
498
|
+
npx dialtone-migrate --only text-variant --dry-run --cwd ./src
|
|
499
|
+
npx dialtone-migrate --only typography,text-variant --dry-run --cwd ./src
|
|
500
|
+
|
|
501
|
+
Combined dry-run stages inspect current files; they do not simulate earlier writes.
|
|
502
|
+
After applying typography, preview text-variant separately for newly created pairs.
|
|
503
|
+
Health-check and text-variant skip nested Git repositories; target each explicitly with --cwd.
|
|
484
504
|
`);
|
|
485
505
|
}
|
|
486
506
|
|
|
@@ -511,18 +531,21 @@ function isIgnoredPath (fullPath) {
|
|
|
511
531
|
function filterGitIgnored (files, cwd) {
|
|
512
532
|
if (files.length === 0) return files;
|
|
513
533
|
try {
|
|
514
|
-
const input = files.join('\
|
|
515
|
-
const output = execFileSync('git', ['check-ignore', '--stdin'], {
|
|
534
|
+
const input = files.join('\0') + '\0';
|
|
535
|
+
const output = execFileSync('git', ['check-ignore', '--stdin', '-z'], {
|
|
516
536
|
input,
|
|
517
537
|
cwd,
|
|
518
538
|
encoding: 'utf8',
|
|
519
|
-
stdio: ['pipe', 'pipe', '
|
|
539
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
540
|
+
env: gitEnvironment(cwd),
|
|
541
|
+
maxBuffer: Math.max(1024 * 1024, Buffer.byteLength(input) + 1),
|
|
520
542
|
});
|
|
521
|
-
const ignored = new Set(output.
|
|
543
|
+
const ignored = new Set(output.split('\0'));
|
|
522
544
|
return files.filter(f => !ignored.has(f));
|
|
523
545
|
} catch (err) {
|
|
524
|
-
//
|
|
525
|
-
|
|
546
|
+
// Keep the no-repository fallback, but never bypass fatal Git access errors.
|
|
547
|
+
const notRepository = err.status === 128 && err.stderr?.includes('not a git repository');
|
|
548
|
+
if (err.status === 1 || notRepository || err.code === 'ENOENT') {
|
|
526
549
|
return files;
|
|
527
550
|
}
|
|
528
551
|
throw err;
|
|
@@ -536,6 +559,8 @@ async function findFiles (dir, extensions) {
|
|
|
536
559
|
try {
|
|
537
560
|
entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
538
561
|
} catch { return; }
|
|
562
|
+
// Nested repositories need their own --cwd and ignore context.
|
|
563
|
+
if (currentDir !== dir && entries.some(entry => entry.name === '.git')) return;
|
|
539
564
|
for (const entry of entries) {
|
|
540
565
|
const fullPath = path.join(currentDir, entry.name);
|
|
541
566
|
if (isIgnoredPath(fullPath)) continue;
|
|
@@ -587,6 +612,16 @@ async function healthCheck (cwd) {
|
|
|
587
612
|
for (const [file, content] of fileContents) {
|
|
588
613
|
if (!migration.fileExtensions.some(ext => file.endsWith(ext))) continue;
|
|
589
614
|
|
|
615
|
+
if (migration.id === 'text-variant') {
|
|
616
|
+
const result = transformTextVariant(content, { vue: file.endsWith('.vue') });
|
|
617
|
+
const pending = result.count + result.diagnostics.length;
|
|
618
|
+
if (pending) {
|
|
619
|
+
matchedFiles.add(path.relative(cwd, file));
|
|
620
|
+
matchCount += pending;
|
|
621
|
+
}
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
|
|
590
625
|
let patterns = migration.detectPatterns;
|
|
591
626
|
const alreadyMigrated = migration.skipIfPatterns?.some(pattern => pattern.test(content));
|
|
592
627
|
if (!alreadyMigrated && migration.ambiguousDetectPatterns) {
|
|
@@ -16,6 +16,13 @@ import { fileURLToPath } from 'node:url';
|
|
|
16
16
|
|
|
17
17
|
const cli = path.join(path.dirname(fileURLToPath(import.meta.url)), 'index.mjs');
|
|
18
18
|
|
|
19
|
+
// Fixture subprocesses must never inherit a caller's repository/index overrides.
|
|
20
|
+
const gitEnv = { ...process.env };
|
|
21
|
+
for (const name of Object.keys(gitEnv)) {
|
|
22
|
+
if (name.toUpperCase().startsWith('GIT_')) delete gitEnv[name];
|
|
23
|
+
}
|
|
24
|
+
const runGit = args => execFileSync('git', args, { encoding: 'utf8', env: gitEnv });
|
|
25
|
+
|
|
19
26
|
// Run the CLI in --dry-run against an empty temp dir and return stdout.
|
|
20
27
|
function runDryRun (flags) {
|
|
21
28
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dlt-master-'));
|
|
@@ -23,7 +30,7 @@ function runDryRun (flags) {
|
|
|
23
30
|
return execFileSync(
|
|
24
31
|
process.execPath,
|
|
25
32
|
[cli, '--dry-run', '--cwd', tmp, ...flags],
|
|
26
|
-
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] },
|
|
33
|
+
{ encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'ignore'] },
|
|
27
34
|
);
|
|
28
35
|
} finally {
|
|
29
36
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
@@ -44,13 +51,13 @@ describe('migration selection', () => {
|
|
|
44
51
|
|
|
45
52
|
it('--all --include-opt-in selects every migration', () => {
|
|
46
53
|
const output = runDryRun(['--all', '--include-opt-in']);
|
|
47
|
-
assert.equal(selectedCount(output),
|
|
54
|
+
assert.equal(selectedCount(output), 21);
|
|
48
55
|
assert.ok(output.includes('[OPT-IN]'), 'opt-in migrations should be selected');
|
|
49
56
|
});
|
|
50
57
|
|
|
51
58
|
it('--include-opt-in on its own also selects every migration', () => {
|
|
52
59
|
const output = runDryRun(['--include-opt-in']);
|
|
53
|
-
assert.equal(selectedCount(output),
|
|
60
|
+
assert.equal(selectedCount(output), 21);
|
|
54
61
|
});
|
|
55
62
|
});
|
|
56
63
|
|
|
@@ -60,7 +67,7 @@ describe('--package validation', () => {
|
|
|
60
67
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dlt-master-'));
|
|
61
68
|
try {
|
|
62
69
|
execFileSync(process.execPath, [cli, '--dry-run', '--cwd', tmp, ...extraArgs],
|
|
63
|
-
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
70
|
+
{ encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'pipe'] });
|
|
64
71
|
return { status: 0, stderr: '' };
|
|
65
72
|
} catch (err) {
|
|
66
73
|
return { status: err.status, stderr: String(err.stderr ?? '') };
|
|
@@ -95,7 +102,7 @@ describe('--health-check', () => {
|
|
|
95
102
|
fs.writeFileSync(path.join(tmp, name), contents);
|
|
96
103
|
}
|
|
97
104
|
return execFileSync(process.execPath, [cli, '--health-check', '--cwd', tmp],
|
|
98
|
-
{ encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] });
|
|
105
|
+
{ encoding: 'utf8', env: gitEnv, stdio: ['ignore', 'pipe', 'ignore'] });
|
|
99
106
|
} finally {
|
|
100
107
|
fs.rmSync(tmp, { recursive: true, force: true });
|
|
101
108
|
}
|
|
@@ -234,3 +241,107 @@ describe('--health-check', () => {
|
|
|
234
241
|
assert.match(output, /\[DONE\].*Stack Gap to Spacing \(stack-gap-to-spacing\)/);
|
|
235
242
|
});
|
|
236
243
|
});
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
describe('text-variant stage', () => {
|
|
247
|
+
it('detects real pairs, protects overrides, preserves dry-run and rescans after typography', () => {
|
|
248
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dlt-text-variant-'));
|
|
249
|
+
const file = path.join(tmp, 'App.vue');
|
|
250
|
+
const run = (...flags) => execFileSync(process.execPath, [cli, '--cwd', tmp, ...flags], { encoding: 'utf8', env: gitEnv });
|
|
251
|
+
const source = '<template><p class="d-body--md">Copy</p><DtText :kind="\'label\'" :size="200">Label</DtText><dt-text kind="body" size="sm" variant="body-md" /></template>';
|
|
252
|
+
try {
|
|
253
|
+
fs.writeFileSync(file, source);
|
|
254
|
+
assert.match(run('--health-check'), /\[PENDING\].*Text Kind and Size to Variant \(text-variant\)/);
|
|
255
|
+
assert.match(run('--only', 'text-variant', '--dry-run'), /1 eligible, 1 existing-variant elements unchanged, 0 manual review/);
|
|
256
|
+
assert.equal(fs.readFileSync(file, 'utf8'), source);
|
|
257
|
+
assert.deepEqual(fs.readdirSync(tmp), ['App.vue']);
|
|
258
|
+
run('--only', 'typography,text-variant', '--yes');
|
|
259
|
+
const output = fs.readFileSync(file, 'utf8');
|
|
260
|
+
assert.match(output, /as="p" variant="body-md"/);
|
|
261
|
+
assert.match(output, /variant="label-sm"/);
|
|
262
|
+
assert.match(output, /kind="body" size="sm" variant="body-md"/);
|
|
263
|
+
assert.match(run('--health-check'), /\[DONE\].*Text Kind and Size to Variant \(text-variant\)/);
|
|
264
|
+
} finally {
|
|
265
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
it('uses health-check scope for hidden source and Git-ignored generated files', () => {
|
|
270
|
+
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'dlt-text-scope-'));
|
|
271
|
+
const source = '<template><dt-text kind="body" size="300">Copy</dt-text></template>';
|
|
272
|
+
const included = ['.storybook/Story.vue', '.Hidden.vue', '.vuepress/components/Text.vue'];
|
|
273
|
+
const excluded = ['out/Generated.vue', 'out/café.vue', 'vendor/nested/Text.vue', 'vendor/nested/ignored/Generated.vue', 'dist/Bundle.vue', 'node_modules/Dependency.vue', 'compiled/Output.vue', 'storybook-static/Page.html', '.vuepress/public/Example.vue', '.vuepress/.temp/Example.vue', '.vuepress/.cache/Example.vue'];
|
|
274
|
+
// Exceed Git's default child-process output buffer without a separate stress suite.
|
|
275
|
+
const longDirectory = Array(8).fill('nested'.repeat(13)).join('/');
|
|
276
|
+
excluded.push(...Array.from({ length: 1700 }, (_, index) => `out/${longDirectory}/Ignored-${index}.vue`));
|
|
277
|
+
assert.ok(Buffer.byteLength(excluded.map(name => path.join(tmp, name)).join('\0')) > 1024 * 1024);
|
|
278
|
+
const scanEnv = { ...gitEnv };
|
|
279
|
+
const run = (...flags) => execFileSync(process.execPath, [cli, '--cwd', tmp, ...flags], { encoding: 'utf8', env: scanEnv });
|
|
280
|
+
try {
|
|
281
|
+
runGit(['init', '--quiet', tmp]);
|
|
282
|
+
assert.equal(fs.realpathSync(runGit(['-C', tmp, 'rev-parse', '--absolute-git-dir']).trim()), fs.realpathSync(path.join(tmp, '.git')));
|
|
283
|
+
runGit(['-C', tmp, 'config', 'core.quotePath', 'true']);
|
|
284
|
+
fs.writeFileSync(path.join(tmp, '.gitignore'), 'out/\n');
|
|
285
|
+
for (const name of [...included, ...excluded]) {
|
|
286
|
+
fs.mkdirSync(path.dirname(path.join(tmp, name)), { recursive: true });
|
|
287
|
+
fs.writeFileSync(path.join(tmp, name), source);
|
|
288
|
+
}
|
|
289
|
+
const nested = path.join(tmp, 'vendor/nested');
|
|
290
|
+
runGit(['init', '--quiet', nested]);
|
|
291
|
+
assert.equal(fs.realpathSync(runGit(['-C', nested, 'rev-parse', '--absolute-git-dir']).trim()), fs.realpathSync(path.join(nested, '.git')));
|
|
292
|
+
fs.writeFileSync(path.join(nested, '.gitignore'), 'ignored/\n');
|
|
293
|
+
runGit(['-C', nested, 'add', 'Text.vue', '.gitignore']);
|
|
294
|
+
const hooks = path.join(tmp, 'empty-hooks');
|
|
295
|
+
fs.mkdirSync(hooks);
|
|
296
|
+
runGit(['-C', nested, '-c', `core.hooksPath=${hooks}`, '-c', 'commit.gpgsign=false',
|
|
297
|
+
'-c', 'user.name=Fixture', '-c', 'user.email=fixture@example.invalid', 'commit', '--quiet', '-m', 'fixture']);
|
|
298
|
+
assert.equal(runGit(['-C', nested, 'status', '--porcelain']).trim(), '');
|
|
299
|
+
const nestedHead = runGit(['-C', nested, 'rev-parse', 'HEAD']).trim();
|
|
300
|
+
fs.writeFileSync(path.join(tmp, '.gitmodules'), '[submodule "vendor/nested"]\n path = vendor/nested\n url = ../nested-fixture\n');
|
|
301
|
+
runGit(['-C', tmp, 'update-index', '--add', '--cacheinfo', `160000,${nestedHead},vendor/nested`]);
|
|
302
|
+
const foreign = path.join(tmp, 'foreign-repository');
|
|
303
|
+
fs.mkdirSync(path.join(foreign, 'out'), { recursive: true });
|
|
304
|
+
fs.writeFileSync(path.join(foreign, 'out/Generated.vue'), source);
|
|
305
|
+
runGit(['init', '--quiet', foreign]);
|
|
306
|
+
assert.equal(fs.realpathSync(runGit(['-C', foreign, 'rev-parse', '--absolute-git-dir']).trim()), fs.realpathSync(path.join(foreign, '.git')));
|
|
307
|
+
runGit(['-C', foreign, 'add', 'out/Generated.vue']);
|
|
308
|
+
const foreignIndex = path.join(foreign, '.git/index');
|
|
309
|
+
const indexBefore = fs.readFileSync(foreignIndex);
|
|
310
|
+
Object.assign(scanEnv, { GIT_DIR: path.join(foreign, '.git'), GIT_WORK_TREE: tmp, GIT_INDEX_FILE: foreignIndex });
|
|
311
|
+
const health = run('--health-check');
|
|
312
|
+
assert.match(health, /\[PENDING\].*Text Kind and Size to Variant \(text-variant\)/);
|
|
313
|
+
assert.match(run('--only', 'text-variant', '--dry-run'), /3 eligible/);
|
|
314
|
+
for (const name of [...included, ...excluded]) assert.equal(fs.readFileSync(path.join(tmp, name), 'utf8'), source);
|
|
315
|
+
scanEnv.GIT_WORK_TREE = foreign;
|
|
316
|
+
run('--only', 'text-variant', '--yes');
|
|
317
|
+
assert.equal(fs.existsSync(path.join(foreign, '.dialtone-migrations')), false);
|
|
318
|
+
assert.deepEqual(fs.readFileSync(foreignIndex), indexBefore);
|
|
319
|
+
for (const name of included) assert.equal(fs.readFileSync(path.join(tmp, name), 'utf8'), '<template><dt-text variant="body-md">Copy</dt-text></template>');
|
|
320
|
+
for (const name of excluded) assert.equal(fs.readFileSync(path.join(tmp, name), 'utf8'), source);
|
|
321
|
+
assert.match(run('--health-check'), /\[DONE\].*Text Kind and Size to Variant \(text-variant\)/);
|
|
322
|
+
const nestedPreview = execFileSync(process.execPath,
|
|
323
|
+
[cli, '--cwd', nested, '--only', 'text-variant', '--dry-run'], { encoding: 'utf8', env: scanEnv });
|
|
324
|
+
assert.match(nestedPreview, /1 eligible/);
|
|
325
|
+
const ceilingEnv = { ...scanEnv, GIT_CEILING_DIRECTORIES: fs.realpathSync(nested) };
|
|
326
|
+
const ignoredDirectory = path.join(nested, 'ignored');
|
|
327
|
+
execFileSync(process.execPath,
|
|
328
|
+
[cli, '--cwd', ignoredDirectory, '--only', 'text-variant', '--yes'], { encoding: 'utf8', env: ceilingEnv });
|
|
329
|
+
assert.equal(fs.readFileSync(path.join(ignoredDirectory, 'Generated.vue'), 'utf8'), source);
|
|
330
|
+
assert.match(execFileSync(process.execPath,
|
|
331
|
+
[cli, '--cwd', ignoredDirectory, '--health-check'], { encoding: 'utf8', env: ceilingEnv }), /No scannable files found/);
|
|
332
|
+
const refusalConfig = path.join(tmp, 'refusal.gitconfig');
|
|
333
|
+
fs.writeFileSync(refusalConfig, '[safe]\n directory =\n');
|
|
334
|
+
const refusedGit = { ...gitEnv, GIT_TEST_ASSUME_DIFFERENT_OWNER: '1',
|
|
335
|
+
GIT_CONFIG_GLOBAL: refusalConfig, GIT_CONFIG_NOSYSTEM: '1' };
|
|
336
|
+
const stage = path.resolve(path.dirname(cli), '../dialtone_migrate_text_variant/index.mjs');
|
|
337
|
+
for (const [script, flag] of [[cli, '--health-check'], [stage, '--yes']]) {
|
|
338
|
+
assert.throws(() => execFileSync(process.execPath, [script, '--cwd', tmp, flag],
|
|
339
|
+
{ encoding: 'utf8', env: refusedGit, stdio: ['ignore', 'pipe', 'pipe'] }), /dubious ownership/);
|
|
340
|
+
}
|
|
341
|
+
for (const name of excluded) assert.equal(fs.readFileSync(path.join(tmp, name), 'utf8'), source);
|
|
342
|
+
} finally {
|
|
343
|
+
fs.rmSync(tmp, { recursive: true, force: true });
|
|
344
|
+
}
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
});
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import fs from 'node:fs/promises';
|
|
4
|
+
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { realpathSync } from 'node:fs';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import readline from 'node:readline/promises';
|
|
8
|
+
import { fileURLToPath } from 'node:url';
|
|
9
|
+
import { gitEnvironment } from '../dialtone_migrate/git_environment.mjs';
|
|
10
|
+
|
|
11
|
+
const SIZES = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'];
|
|
12
|
+
const KINDS = new Set(['headline', 'body', 'label', 'code']);
|
|
13
|
+
const VOID_TAGS = new Set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr']);
|
|
14
|
+
const SAFE_DIRECTIVES = /^v-(?:(?:if|else|else-if|for|show|once|memo|cloak|text|html|slot)(?:[.:]|$)|on(?::|$))/;
|
|
15
|
+
|
|
16
|
+
// Tokenize markup without reserializing it. Attribute values, comments, interpolation
|
|
17
|
+
// strings and raw-text elements must never expose their quoted examples as live tags.
|
|
18
|
+
function * openingTags (content, vue) {
|
|
19
|
+
const tokens = new RegExp([
|
|
20
|
+
/<!--[\s\S]*?(?:-->|$)/.source,
|
|
21
|
+
/\{\{(?:[^'"`]|'(?:\\.|[^'\\])*'|"(?:\\.|[^"\\])*"|`(?:\\.|[^`\\])*`)*?\}\}/.source,
|
|
22
|
+
/<\/?([A-Za-z][\w:-]*)(?=[\s/>])(?:[^>"']|"[^"]*"|'[^']*')*>/.source,
|
|
23
|
+
].join('|'), 'g');
|
|
24
|
+
const stack = [];
|
|
25
|
+
let match;
|
|
26
|
+
while ((match = tokens.exec(content))) {
|
|
27
|
+
if (!match[1]) continue;
|
|
28
|
+
const tag = match[1];
|
|
29
|
+
const closing = match[0].startsWith('</');
|
|
30
|
+
if (closing) {
|
|
31
|
+
const index = stack.map(entry => entry.tag).lastIndexOf(tag);
|
|
32
|
+
if (index !== -1) stack.length = index;
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const inTemplate = !vue || stack[0]?.tag === 'template';
|
|
36
|
+
const attrs = parseAttributes(match[0], tag.length + 1);
|
|
37
|
+
const pre = stack.some(entry => entry.pre) || attrs?.some(attr => attr.name === 'v-pre');
|
|
38
|
+
if (inTemplate && !pre && (tag === 'dt-text' || tag === 'DtText')) {
|
|
39
|
+
yield { start: match.index, attrs };
|
|
40
|
+
}
|
|
41
|
+
const preprocessed = vue && stack.length === 0 && tag === 'template' && attrs?.some(attr => attr.name === 'lang' && attr.value !== 'html');
|
|
42
|
+
const raw = /^(?:script|style|textarea|title|xmp|iframe|noembed|noscript)$/i.test(tag) || (vue && stack.length === 0 && tag !== 'template') || preprocessed;
|
|
43
|
+
if (raw && !match[0].endsWith('/>')) {
|
|
44
|
+
const end = new RegExp(`</${tag}\\s*>`, 'gi');
|
|
45
|
+
end.lastIndex = tokens.lastIndex;
|
|
46
|
+
const close = end.exec(content);
|
|
47
|
+
tokens.lastIndex = close ? end.lastIndex : content.length;
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (!match[0].endsWith('/>') && !VOID_TAGS.has(tag.toLowerCase())) stack.push({ tag, pre });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function parseAttributes (text, start) {
|
|
55
|
+
const attrs = [];
|
|
56
|
+
const pattern = /\s+([^\s=<>/]+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+)))?/y;
|
|
57
|
+
let cursor = start;
|
|
58
|
+
while (!/^\s*\/?\s*>$/.test(text.slice(cursor))) {
|
|
59
|
+
pattern.lastIndex = cursor;
|
|
60
|
+
const match = pattern.exec(text);
|
|
61
|
+
if (!match) return null;
|
|
62
|
+
attrs.push({ name: match[1], value: match[2] ?? match[3] ?? match[4], start: cursor, end: pattern.lastIndex,
|
|
63
|
+
prefix: match[0].slice(0, match[0].indexOf(match[1])) });
|
|
64
|
+
cursor = pattern.lastIndex;
|
|
65
|
+
}
|
|
66
|
+
return attrs;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function propName (name) {
|
|
70
|
+
return name.replace(/^(?::|\.|v-bind:|v-model:)/, '').split('.')[0];
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function literal (attr) {
|
|
74
|
+
if (!attr || attr.value === undefined) return null;
|
|
75
|
+
if (!/^(?::|v-bind:)/.test(attr.name)) return attr.value;
|
|
76
|
+
const value = attr.value.trim();
|
|
77
|
+
const numeric = /^(?:(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?|0[xX][\da-fA-F]+|0[bB][01]+|0[oO][0-7]+)$/;
|
|
78
|
+
if (numeric.test(value)) return String(Number(value));
|
|
79
|
+
const string = /^(?:'([^'\\]*)'|"([^"\\]*)")$/.exec(value);
|
|
80
|
+
return string ? string[1] ?? string[2] : null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function transformContent (content, { vue = false } = {}) {
|
|
84
|
+
const edits = [];
|
|
85
|
+
const diagnostics = [];
|
|
86
|
+
let count = 0;
|
|
87
|
+
let protectedCount = 0;
|
|
88
|
+
for (const tag of openingTags(content, vue)) {
|
|
89
|
+
const attrs = tag.attrs;
|
|
90
|
+
const props = name => attrs?.filter(attr => propName(attr.name) === name) ?? [];
|
|
91
|
+
if (props('variant').length) {
|
|
92
|
+
protectedCount++;
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const kinds = props('kind');
|
|
96
|
+
const sizes = props('size');
|
|
97
|
+
if (attrs && (!kinds.length || !sizes.length)) continue;
|
|
98
|
+
let reason;
|
|
99
|
+
const uncertain = attrs?.some(attr => {
|
|
100
|
+
if (attr.name.startsWith('.') || attr.name.includes('[') || attr.name === 'v-bind' || attr.name.startsWith('v-bind.')) return true;
|
|
101
|
+
if (/^(?::|v-bind:)/.test(attr.name)) return attr.name.includes('.');
|
|
102
|
+
return attr.name.startsWith('v-') && !SAFE_DIRECTIVES.test(attr.name);
|
|
103
|
+
});
|
|
104
|
+
if (!attrs) reason = 'Cannot parse attributes safely';
|
|
105
|
+
else if (uncertain) reason = 'Spread, dynamic argument or directive may supply composition props';
|
|
106
|
+
else if (kinds.length !== 1 || sizes.length !== 1) reason = 'Duplicate or conflicting composition props';
|
|
107
|
+
const kind = literal(kinds[0]);
|
|
108
|
+
const size = literal(sizes[0]);
|
|
109
|
+
const sizeIndex = /^[1-7]00$/.test(size ?? '') ? Number(size) / 100 - 1 : SIZES.indexOf(size);
|
|
110
|
+
if (!reason && (kind === null || size === null)) reason = 'Nonliteral kind or size';
|
|
111
|
+
if (!reason && (!KINDS.has(kind) || sizeIndex < 0 || (kind !== 'headline' && sizeIndex > 3))) {
|
|
112
|
+
reason = 'Unsupported kind/size composition';
|
|
113
|
+
}
|
|
114
|
+
if (reason) {
|
|
115
|
+
const before = content.slice(0, tag.start);
|
|
116
|
+
diagnostics.push({ line: before.split('\n').length, column: tag.start - before.lastIndexOf('\n'), reason,
|
|
117
|
+
action: 'Review composition props and set the intended variant manually.' });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const kindAttr = kinds[0];
|
|
121
|
+
const sizeAttr = sizes[0];
|
|
122
|
+
edits.push({ start: tag.start + kindAttr.start + kindAttr.prefix.length, end: tag.start + kindAttr.end,
|
|
123
|
+
text: `variant="${kind}-${SIZES[sizeIndex]}"` });
|
|
124
|
+
const attributeStart = tag.start + sizeAttr.start + sizeAttr.prefix.length;
|
|
125
|
+
const attributeEnd = tag.start + sizeAttr.end;
|
|
126
|
+
const lineEnd = content.indexOf('\n', attributeEnd);
|
|
127
|
+
const ownLine = /\n[ \t]*$/.test(sizeAttr.prefix) && lineEnd !== -1 &&
|
|
128
|
+
/^[ \t\r]*$/.test(content.slice(attributeEnd, lineEnd));
|
|
129
|
+
// Removing the indentation reaches the line start when size begins its own line;
|
|
130
|
+
// then also drop the line break so no empty line remains. Inline neighbors and
|
|
131
|
+
// closing tags on the same line keep their placement.
|
|
132
|
+
const indent = sizeAttr.prefix.match(/[ \t]*$/)[0].length;
|
|
133
|
+
edits.push({ start: attributeStart - indent, end: ownLine ? lineEnd + 1 : attributeEnd, text: '' });
|
|
134
|
+
count++;
|
|
135
|
+
}
|
|
136
|
+
let transformed = content;
|
|
137
|
+
for (const edit of edits.sort((a, b) => b.start - a.start)) {
|
|
138
|
+
transformed = transformed.slice(0, edit.start) + edit.text + transformed.slice(edit.end);
|
|
139
|
+
}
|
|
140
|
+
return { transformed, count, protectedCount, diagnostics };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// Match the master runner's health-check exclusions without changing other stages.
|
|
144
|
+
const IGNORE = ['node_modules', 'dist', '.git', '.vuepress/public', '.vuepress/.temp', '.vuepress/.cache', 'storybook-static', 'compiled'];
|
|
145
|
+
|
|
146
|
+
async function filesIn (dir) {
|
|
147
|
+
const files = [];
|
|
148
|
+
async function walk (currentDir) {
|
|
149
|
+
let entries;
|
|
150
|
+
try {
|
|
151
|
+
entries = await fs.readdir(currentDir, { withFileTypes: true });
|
|
152
|
+
} catch { return; }
|
|
153
|
+
// Nested repositories need their own --cwd and ignore context.
|
|
154
|
+
if (currentDir !== dir && entries.some(entry => entry.name === '.git')) return;
|
|
155
|
+
for (const entry of entries) {
|
|
156
|
+
const file = path.join(currentDir, entry.name);
|
|
157
|
+
const segments = '/' + file.split(path.sep).join('/') + '/';
|
|
158
|
+
if (IGNORE.some(ignored => segments.includes(`/${ignored}/`))) continue;
|
|
159
|
+
if (entry.isDirectory()) await walk(file);
|
|
160
|
+
else if (entry.isFile() && /\.(?:vue|html)$/.test(entry.name)) files.push(file);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
await walk(dir);
|
|
164
|
+
if (!files.length) return files;
|
|
165
|
+
try {
|
|
166
|
+
const input = files.join('\0') + '\0';
|
|
167
|
+
const output = execFileSync('git', ['check-ignore', '--stdin', '-z'], {
|
|
168
|
+
input, cwd: dir, encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'],
|
|
169
|
+
env: gitEnvironment(dir),
|
|
170
|
+
maxBuffer: Math.max(1024 * 1024, Buffer.byteLength(input) + 1),
|
|
171
|
+
});
|
|
172
|
+
const ignored = new Set(output.split('\0'));
|
|
173
|
+
return files.filter(file => !ignored.has(file));
|
|
174
|
+
} catch (error) {
|
|
175
|
+
const notRepository = error.status === 128 && error.stderr?.includes('not a git repository');
|
|
176
|
+
if (error.status === 1 || notRepository || error.code === 'ENOENT') return files;
|
|
177
|
+
throw error;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
async function main () {
|
|
182
|
+
const args = process.argv.slice(2);
|
|
183
|
+
if (args.includes('--help')) {
|
|
184
|
+
console.log('Usage: dialtone-migrate --only text-variant [--cwd <path>] [--dry-run] [--yes]\nConvert static DtText kind + size pairs. Existing variants are protected.\nNested Git repositories are skipped; target each explicitly with --cwd.');
|
|
185
|
+
return;
|
|
186
|
+
}
|
|
187
|
+
const cwdIndex = args.indexOf('--cwd');
|
|
188
|
+
if (cwdIndex !== -1 && (!args[cwdIndex + 1] || args[cwdIndex + 1].startsWith('--'))) throw new Error('--cwd requires a path');
|
|
189
|
+
const cwd = path.resolve(cwdIndex === -1 ? process.cwd() : args[cwdIndex + 1]);
|
|
190
|
+
const changes = [];
|
|
191
|
+
let eligible = 0;
|
|
192
|
+
let protectedCount = 0;
|
|
193
|
+
let manual = 0;
|
|
194
|
+
for (const file of await filesIn(cwd)) {
|
|
195
|
+
const content = await fs.readFile(file, 'utf8');
|
|
196
|
+
const result = transformContent(content, { vue: file.endsWith('.vue') });
|
|
197
|
+
eligible += result.count;
|
|
198
|
+
protectedCount += result.protectedCount;
|
|
199
|
+
manual += result.diagnostics.length;
|
|
200
|
+
for (const diagnostic of result.diagnostics) {
|
|
201
|
+
console.log(`${path.relative(cwd, file)}:${diagnostic.line}:${diagnostic.column}: ${diagnostic.reason}. ${diagnostic.action}`);
|
|
202
|
+
}
|
|
203
|
+
if (result.count) changes.push({ file, ...result });
|
|
204
|
+
}
|
|
205
|
+
console.log(`Text variants: ${eligible} eligible, ${protectedCount} existing-variant elements unchanged, ${manual} manual review.`);
|
|
206
|
+
if (args.includes('--dry-run')) {
|
|
207
|
+
console.log('--dry-run: No files were modified.');
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (!changes.length) return;
|
|
211
|
+
if (!args.includes('--yes')) {
|
|
212
|
+
const prompt = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
213
|
+
const answer = await prompt.question('Apply Text variant changes? (y/N) ');
|
|
214
|
+
prompt.close();
|
|
215
|
+
if (!/^y(?:es)?$/i.test(answer.trim())) return;
|
|
216
|
+
}
|
|
217
|
+
for (const { file, transformed } of changes) await fs.writeFile(file, transformed, 'utf8');
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
try {
|
|
221
|
+
if (process.argv[1] && realpathSync(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
222
|
+
await main();
|
|
223
|
+
}
|
|
224
|
+
} catch (error) {
|
|
225
|
+
console.error(error);
|
|
226
|
+
process.exitCode = 1;
|
|
227
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { it } from 'node:test';
|
|
2
|
+
import assert from 'node:assert/strict';
|
|
3
|
+
import { transformContent } from './index.mjs';
|
|
4
|
+
|
|
5
|
+
const sizes = ['xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'];
|
|
6
|
+
|
|
7
|
+
it('converts all 38 composition mappings across literal syntax and tag casings', () => {
|
|
8
|
+
for (const kind of ['headline', 'body', 'label', 'code']) {
|
|
9
|
+
for (const [index, size] of sizes.entries()) {
|
|
10
|
+
if (kind !== 'headline' && index > 3) continue;
|
|
11
|
+
for (const value of [size, String((index + 1) * 100)]) {
|
|
12
|
+
for (const tag of ['dt-text', 'DtText']) {
|
|
13
|
+
for (const attrs of [
|
|
14
|
+
`kind='${kind}' size="${value}"`,
|
|
15
|
+
`:size="'${value}'"\n :kind="'${kind}'"`,
|
|
16
|
+
`v-bind:kind="'${kind}'" v-bind:size="${/^\d+$/.test(value) ? value : `'${value}'`}"`,
|
|
17
|
+
]) {
|
|
18
|
+
const result = transformContent(`<${tag} ${attrs}>Copy</${tag}>`);
|
|
19
|
+
assert.equal(result.count, 1, attrs);
|
|
20
|
+
assert.match(result.transformed, new RegExp(`variant="${kind}-${size}"`));
|
|
21
|
+
assert.doesNotMatch(result.transformed, /\b(?:kind|size)=/);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('protects every explicit variant and leaves incomplete pairs outside scope', () => {
|
|
30
|
+
for (const attrs of ['variant=""', ':variant="choice"', 'v-bind:variant="undefined"', '.variant="choice"']) {
|
|
31
|
+
const input = `<dt-text kind="body" size="sm" ${attrs}>Copy</dt-text>`;
|
|
32
|
+
const result = transformContent(input);
|
|
33
|
+
assert.equal(result.transformed, input);
|
|
34
|
+
assert.equal(result.protectedCount, 1);
|
|
35
|
+
}
|
|
36
|
+
for (const attrs of ['kind="body"', 'size="300"']) {
|
|
37
|
+
const input = `<dt-text ${attrs} />`;
|
|
38
|
+
assert.equal(transformContent(input).transformed, input);
|
|
39
|
+
assert.deepEqual(transformContent(input).diagnostics, []);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('leaves uncertain pairs unchanged with actionable line and column diagnostics', () => {
|
|
44
|
+
for (const attrs of [
|
|
45
|
+
'kind="body" size="sm" v-bind="props"',
|
|
46
|
+
'kind="body" size="sm" :[key]="value"',
|
|
47
|
+
'kind="body" size="sm" v-bind:[key]="value"',
|
|
48
|
+
'kind="body" size="sm" :size="200"',
|
|
49
|
+
'kind="body" size="sm" kind="code"',
|
|
50
|
+
'kind="body" :size="compact ? 100 : 300"',
|
|
51
|
+
':kind="getKind()" size="300"',
|
|
52
|
+
'kind="body" size="700"',
|
|
53
|
+
'kind="body" size="0100"',
|
|
54
|
+
'kind="body" size="sm" v-model:kind="kind"',
|
|
55
|
+
'kind="body" size="sm" v-custom="props"',
|
|
56
|
+
'kind="body" size="sm" :size.prop="300"',
|
|
57
|
+
`.kind="'body'" .size="'sm'"`,
|
|
58
|
+
`kind="body" .size="'sm'"`,
|
|
59
|
+
`.kind="'body'" size="sm"`,
|
|
60
|
+
]) {
|
|
61
|
+
const input = `\n<dt-text ${attrs} />`;
|
|
62
|
+
const result = transformContent(input);
|
|
63
|
+
assert.equal(result.transformed, input, attrs);
|
|
64
|
+
assert.equal(result.diagnostics.length, 1, attrs);
|
|
65
|
+
assert.equal(result.diagnostics[0].line, 2);
|
|
66
|
+
assert.equal(result.diagnostics[0].column, 1);
|
|
67
|
+
assert.match(result.diagnostics[0].reason, /.+/);
|
|
68
|
+
assert.match(result.diagnostics[0].action, /review/i);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('preserves unrelated source and ignores examples outside live template regions', () => {
|
|
73
|
+
const example = '<dt-text kind="body" size="300">Example</dt-text>';
|
|
74
|
+
const input = `<docs>${example}</docs>\n<script>const example = '${example}'</script>\n<style>/* ${example} */</style>\n<template>\n<!-- ${example} -->\n<div title='${example}'>{{ '${example}' }}</div>\n<textarea>${example}</textarea>\n<div v-pre>${example}</div>\n<DtText\n as="p" :title="count > 0" kind='body'\n :size="300" @click="go">Keep <b>content</b></DtText>\n</template>`;
|
|
75
|
+
const expected = input.replace('kind=\'body\'', 'variant="body-md"').replace(' :size="300"', '');
|
|
76
|
+
const result = transformContent(input, { vue: true });
|
|
77
|
+
assert.equal(result.transformed, expected);
|
|
78
|
+
assert.equal(result.count, 1);
|
|
79
|
+
const rerun = transformContent(expected, { vue: true });
|
|
80
|
+
assert.equal(rerun.transformed, expected);
|
|
81
|
+
assert.equal(rerun.count, 0);
|
|
82
|
+
assert.equal(transformContent(`<script>${example}</script>${example}`).count, 1);
|
|
83
|
+
for (const [before, after] of [
|
|
84
|
+
['<DtText\n size="300"\n kind="body"\n/>', '<DtText\n variant="body-md"\n/>'],
|
|
85
|
+
['<dt-text\n kind="body"\n size="300"\n as="p"\n>Copy</dt-text>', '<dt-text\n variant="body-md"\n as="p"\n>Copy</dt-text>'],
|
|
86
|
+
['<dt-text\n kind="body"\n size="300"\n/>', '<dt-text\n variant="body-md"\n/>'],
|
|
87
|
+
['<dt-text\n kind="body"\n size="300">Copy</dt-text>', '<dt-text\n variant="body-md"\n>Copy</dt-text>'],
|
|
88
|
+
]) {
|
|
89
|
+
assert.equal(transformContent(before).transformed, after);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('leaves preprocessed templates and escaped interpolation examples untouched', () => {
|
|
94
|
+
const example = '<dt-text kind="body" size="300" />';
|
|
95
|
+
const pug = `<template lang="pug">${example}</template>`;
|
|
96
|
+
assert.equal(transformContent(pug, { vue: true }).transformed, pug);
|
|
97
|
+
const input = `{{ 'it\\'s ${example}' }}${example}`;
|
|
98
|
+
const result = transformContent(input);
|
|
99
|
+
assert.equal(result.count, 1);
|
|
100
|
+
assert.equal(result.transformed, input.replace(/<dt-text kind="body" size="300" \/>$/, '<dt-text variant="body-md" />'));
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('recognizes numeric literal spellings without evaluating expressions', () => {
|
|
104
|
+
for (const value of ['300.0', '3e2', '0x12c', '0b100101100', '0o454']) {
|
|
105
|
+
assert.equal(transformContent(`<dt-text kind="body" :size="${value}" />`).transformed, '<dt-text variant="body-md" />');
|
|
106
|
+
}
|
|
107
|
+
assert.equal(transformContent('<dt-text kind="body" :size="100 + 200" />').count, 0);
|
|
108
|
+
});
|
|
@@ -10857,6 +10857,12 @@ legend .d-label {
|
|
|
10857
10857
|
/* stylelint-disable-next-line meowtec/no-px */
|
|
10858
10858
|
overflow-clip-margin: 32px;
|
|
10859
10859
|
}
|
|
10860
|
+
@supports not (overflow-clip-margin: 1px) {
|
|
10861
|
+
.d-slider__control {
|
|
10862
|
+
overflow: visible;
|
|
10863
|
+
contain: layout;
|
|
10864
|
+
}
|
|
10865
|
+
}
|
|
10860
10866
|
.d-slider__track {
|
|
10861
10867
|
position: absolute;
|
|
10862
10868
|
inset-inline: 0;
|
|
@@ -11162,6 +11168,7 @@ legend .d-label {
|
|
|
11162
11168
|
-webkit-margin-before: var(--dt-spacing-50);
|
|
11163
11169
|
margin-block-start: var(--dt-spacing-50);
|
|
11164
11170
|
overflow: visible;
|
|
11171
|
+
contain: none;
|
|
11165
11172
|
}
|
|
11166
11173
|
.d-slider--vertical .d-slider__track {
|
|
11167
11174
|
inset-inline: unset;
|