UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

55 lines 1.88 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const schema_1 = require("@sprucelabs/schema"); const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils"); class StaticToInstanceMigratorImpl { static diskUtil = spruce_skill_utils_1.diskUtil; static Class; testFinder; testFileMigrator; lintService; constructor(options) { const { testFinder, testFileMigrator, lintService } = options; this.testFinder = testFinder; this.testFileMigrator = testFileMigrator; this.lintService = lintService; } static Migrator(options) { (0, schema_1.assertOptions)(options, [ 'testFinder', 'testFileMigrator', 'lintService', ]); return new (this.Class ?? this)(options); } async run(lookupDir) { (0, schema_1.assertOptions)({ lookupDir }, ['lookupDir']); const matches = await this.testFinder.find(lookupDir); let totalTestsUpdated = 0; let totalTestsSkipped = 0; for (const match of matches) { const contents = this.readFile(match); const updated = this.testFileMigrator.migrate(contents); if (contents === updated) { totalTestsSkipped++; } else { totalTestsUpdated++; this.writeFile(match, updated); } } await this.lintService.fix('**/*.ts'); return { totalTestsUpdated, totalTestsSkipped, }; } readFile(match) { return StaticToInstanceMigratorImpl.diskUtil.readFile(match); } writeFile(match, updated) { StaticToInstanceMigratorImpl.diskUtil.writeFile(match, updated); } } exports.default = StaticToInstanceMigratorImpl; //# sourceMappingURL=StaticToInstanceMigrator.js.map