UNPKG

@sprucelabs/spruce-cli

Version:

Command line interface for building Spruce skills.

72 lines 3.65 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const spruce_skill_utils_1 = require("@sprucelabs/spruce-skill-utils"); const test_utils_1 = require("@sprucelabs/test-utils"); const CommandService_1 = __importDefault(require("../../services/CommandService")); const AbstractSkillTest_1 = __importDefault(require("../../tests/AbstractSkillTest")); class PkgServiceTest extends AbstractSkillTest_1.default { static skillCacheKey = 'skills'; static pkg; static async beforeEach() { await super.beforeEach(); this.pkg = this.Service('pkg'); } static async canCreatePkgService() { test_utils_1.assert.isTruthy(this.pkg); } static async installANonSpruceLabsModuleMakesItsVersionAnActualVersion() { const version = this.pkg.get('dependencies.dotenv'); test_utils_1.assert.isNotEqual(version, 'latest'); } static async handlesAtLatestInName() { CommandService_1.default.fakeCommand(new RegExp(/yarn/gis), { code: 0, }); await this.pkg.install('@sprucelabs/heartwood-view-controllers@latest'); this.pkg.isInstalled('@sprucelabs/heartwood-view-controllers'); } static async ifInstallingOnlySpruceModulesShouldNotRunNPMAdd() { CommandService_1.default.fakeCommand(new RegExp(/npm.*?install.*?--no-progress/gis), { code: 1, }); const { totalInstalled } = await this.pkg.install('@sprucelabs/jest-json-reporter'); test_utils_1.assert.isEqual(totalInstalled, 1); const expectedPath = this.resolvePath('node_modules', '@sprucelabs', 'jest-json-reporter'); test_utils_1.assert.isTrue(spruce_skill_utils_1.diskUtil.doesFileExist(expectedPath), `No module installed at ${expectedPath}.`); } static async installingSpruceAndOtherModulesDoesntRemoveSpruceModule() { const { totalInstalled } = await this.pkg.install([ 'moment', '@sprucelabs/calendar-utils', ]); test_utils_1.assert.isEqual(totalInstalled, 2); const expectedPath = this.resolvePath('node_modules', '@sprucelabs', 'calendar-utils'); test_utils_1.assert.isTrue(spruce_skill_utils_1.diskUtil.doesFileExist(expectedPath), `No module installed at ${expectedPath}.`); } } exports.default = PkgServiceTest; __decorate([ (0, test_utils_1.test)() ], PkgServiceTest, "canCreatePkgService", null); __decorate([ (0, test_utils_1.test)() ], PkgServiceTest, "installANonSpruceLabsModuleMakesItsVersionAnActualVersion", null); __decorate([ (0, test_utils_1.test)() ], PkgServiceTest, "handlesAtLatestInName", null); __decorate([ (0, test_utils_1.test)() ], PkgServiceTest, "ifInstallingOnlySpruceModulesShouldNotRunNPMAdd", null); __decorate([ (0, test_utils_1.test)() ], PkgServiceTest, "installingSpruceAndOtherModulesDoesntRemoveSpruceModule", null); //# sourceMappingURL=PkgService.test.js.map