angular/packages/localize/tools/src/migrate/cli.ts
Alan Agius 45f899a272 refactor: replace fast-glob usage with tinyglobby (#60264)
Usage of the `fast-glob` package has been replaced with the `tinyglobby` package. The change reduces the number of transitive dependencies related to these packages from 17 to 2 while also maintaining equivalent functionality. This was also changed in the Angular CLI packages.

PR Close #60264
2025-03-07 10:57:23 -08:00

56 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.dev/license
*/
import {
ConsoleLogger,
LogLevel,
NodeJSFileSystem,
setFileSystem,
} from '@angular/compiler-cli/private/localize';
import {globSync} from 'tinyglobby';
import yargs from 'yargs';
import {migrateFiles} from './index';
const args = process.argv.slice(2);
const options = yargs(args)
.option('r', {
alias: 'root',
default: '.',
describe:
'The root path for other paths provided in these options.\n' +
'This should either be absolute or relative to the current working directory.',
type: 'string',
})
.option('f', {
alias: 'files',
required: true,
describe:
'A glob pattern indicating what files to migrate. This should be relative to the root path',
type: 'string',
})
.option('m', {
alias: 'mapFile',
required: true,
describe:
'Path to the migration mapping file generated by `localize-extract`. This should be relative to the root path.',
type: 'string',
})
.strict()
.help()
.parseSync();
const fs = new NodeJSFileSystem();
setFileSystem(fs);
const rootPath = options.r;
const translationFilePaths = globSync(options.f, {cwd: rootPath, onlyFiles: true});
const logger = new ConsoleLogger(LogLevel.warn);
migrateFiles({rootPath, translationFilePaths, mappingFilePath: options.m, logger});
process.exit(0);