Skip to content

Commit e0af275

Browse files
authored
feat(master-script): no-jira migration script ignore gitignore folders (#1314)
1 parent aec9acf commit e0af275

2 files changed

Lines changed: 35 additions & 6 deletions

File tree

packages/dialtone-css/lib/build/js/dialtone_migrate/index.mjs

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* npx dialtone-migrate --only color-stops,hsl-to-oklch
2929
*/
3030

31-
import { spawn } from 'node:child_process';
31+
import { spawn, execFileSync } from 'node:child_process';
3232
import fs from 'fs/promises';
3333
import path from 'path';
3434
import readline from 'readline';
@@ -302,11 +302,12 @@ const MIGRATIONS = [
302302
{
303303
id: 'vue3-to-vue-imports',
304304
name: 'Vue 3 Import Paths',
305-
description: '@dialpad/dialtone-icons/vue3 and @dialpad/dialtone-vue/vue3 import paths renamed to /vue.',
305+
description: '@dialpad/dialtone/vue3, @dialpad/dialtone-icons/vue3, and @dialpad/dialtone-vue/vue3 import paths renamed to /vue.',
306306
category: 'required',
307307
type: 'config',
308308
configName: 'vue3-to-vue-imports',
309309
detectPatterns: [
310+
/@dialpad\/dialtone\/vue3/,
310311
/@dialpad\/dialtone-icons\/vue3/,
311312
/@dialpad\/dialtone-vue\/vue3/,
312313
],
@@ -370,7 +371,7 @@ Examples:
370371
// File walker (shared utility)
371372
// ---------------------------------------------------------------------------
372373

373-
const DEFAULT_IGNORE = ['node_modules', 'dist', '.git', '.vuepress/public', '.vuepress/.temp', '.vuepress/.cache', 'storybook-static'];
374+
const DEFAULT_IGNORE = ['node_modules', 'dist', '.git', '.vuepress/public', '.vuepress/.temp', '.vuepress/.cache', 'storybook-static', 'compiled'];
374375

375376
function isIgnoredPath (fullPath) {
376377
const segments = fullPath.split(path.sep);
@@ -386,6 +387,31 @@ function isIgnoredPath (fullPath) {
386387
});
387388
}
388389

390+
/**
391+
* Filter out files that are ignored by .gitignore using git check-ignore.
392+
* Falls back gracefully if git is not available.
393+
*/
394+
function filterGitIgnored (files, cwd) {
395+
if (files.length === 0) return files;
396+
try {
397+
const input = files.join('\n');
398+
const output = execFileSync('git', ['check-ignore', '--stdin'], {
399+
input,
400+
cwd,
401+
encoding: 'utf8',
402+
stdio: ['pipe', 'pipe', 'ignore'],
403+
});
404+
const ignored = new Set(output.trim().split('\n').filter(Boolean));
405+
return files.filter(f => !ignored.has(f));
406+
} catch (err) {
407+
// status 1 → no paths ignored; status 128 → not a git repo; ENOENT → git missing
408+
if (err.status === 1 || err.status === 128 || err.code === 'ENOENT') {
409+
return files;
410+
}
411+
throw err;
412+
}
413+
}
414+
389415
async function findFiles (dir, extensions) {
390416
const results = [];
391417
async function walk (currentDir) {
@@ -404,7 +430,7 @@ async function findFiles (dir, extensions) {
404430
}
405431
}
406432
await walk(dir);
407-
return results;
433+
return filterGitIgnored(results, dir);
408434
}
409435

410436
// ---------------------------------------------------------------------------

packages/dialtone-css/lib/build/js/dialtone_migration_helper/configs/vue3-to-vue-imports.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55

66
export default {
77
description:
8-
'Renames /vue3 import subpaths to /vue for @dialpad/dialtone-icons and\n' +
9-
'@dialpad/dialtone-vue. After Vue 2 removal, /vue is the canonical path.',
8+
'Renames /vue3 import subpaths to /vue for @dialpad/dialtone,\n' +
9+
'@dialpad/dialtone-icons, and @dialpad/dialtone-vue.\n' +
10+
'After Vue 2 removal, /vue is the canonical path.',
1011
patterns: ['**/*.{vue,js,ts,jsx,tsx,mjs,mts}'],
1112
expressions: [
13+
// @dialpad/dialtone/vue3 → @dialpad/dialtone/vue
14+
{ from: /@dialpad\/dialtone\/vue3/g, to: '@dialpad/dialtone/vue' },
1215
// @dialpad/dialtone-icons/vue3 → @dialpad/dialtone-icons/vue
1316
{ from: /@dialpad\/dialtone-icons\/vue3/g, to: '@dialpad/dialtone-icons/vue' },
1417
// @dialpad/dialtone-vue/vue3 → @dialpad/dialtone-vue (or /vue if used)

0 commit comments

Comments
 (0)