@sprucelabs/spruce-cli 14.28.4 → 14.28.8

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.
Files changed (37) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/build/__tests__/behavioral/BootingWithBadFiles.test.d.ts +2 -0
  3. package/build/__tests__/behavioral/BootingWithBadFiles.test.js +84 -17
  4. package/build/__tests__/behavioral/BootingWithBadFiles.test.js.map +1 -1
  5. package/build/__tests__/behavioral/events/KeepingEventsInSync2.test.js +1 -1
  6. package/build/__tests__/behavioral/events/KeepingEventsInSync2.test.js.map +1 -1
  7. package/build/__tests__/behavioral/skill/UpgradingASkill2.test.d.ts +1 -1
  8. package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js +10 -20
  9. package/build/__tests__/behavioral/skill/UpgradingASkill2.test.js.map +1 -1
  10. package/build/__tests__/behavioral/{CreatingADataStore.test.d.ts → stores/CreatingADataStore.test.d.ts} +2 -1
  11. package/build/__tests__/behavioral/{CreatingADataStore.test.js → stores/CreatingADataStore.test.js} +87 -57
  12. package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -0
  13. package/build/__tests__/behavioral/{KeepingDataStoresInSync.test.d.ts → stores/KeepingDataStoresInSync.test.d.ts} +2 -2
  14. package/build/__tests__/behavioral/{KeepingDataStoresInSync.test.js → stores/KeepingDataStoresInSync.test.js} +42 -42
  15. package/build/__tests__/behavioral/stores/KeepingDataStoresInSync.test.js.map +1 -0
  16. package/build/cli.d.ts +1 -1
  17. package/build/cli.js +1 -1
  18. package/build/cli.js.map +1 -1
  19. package/build/features/node/NodeFeature.js +6 -11
  20. package/build/features/node/NodeFeature.js.map +1 -1
  21. package/build/features/store/actions/SyncAction.js +11 -10
  22. package/build/features/store/actions/SyncAction.js.map +1 -1
  23. package/build/features/store/writers/StoreWriter.d.ts +6 -0
  24. package/build/features/store/writers/StoreWriter.js +78 -8
  25. package/build/features/store/writers/StoreWriter.js.map +1 -1
  26. package/package.json +28 -28
  27. package/src/__tests__/behavioral/BootingWithBadFiles.test.ts +17 -2
  28. package/src/__tests__/behavioral/events/KeepingEventsInSync2.test.ts +1 -1
  29. package/src/__tests__/behavioral/skill/UpgradingASkill2.test.ts +1 -10
  30. package/src/__tests__/behavioral/{CreatingADataStore.test.ts → stores/CreatingADataStore.test.ts} +13 -6
  31. package/src/__tests__/behavioral/{KeepingDataStoresInSync.test.ts → stores/KeepingDataStoresInSync.test.ts} +6 -6
  32. package/src/cli.ts +2 -2
  33. package/src/features/node/NodeFeature.ts +0 -3
  34. package/src/features/store/actions/SyncAction.ts +2 -1
  35. package/src/features/store/writers/StoreWriter.ts +30 -0
  36. package/build/__tests__/behavioral/CreatingADataStore.test.js.map +0 -1
  37. package/build/__tests__/behavioral/KeepingDataStoresInSync.test.js.map +0 -1
package/build/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli.ts"],"names":["Cli","cwd","featureInstaller","serviceFactory","emitter","attacher","actionExecuter","on","off","emit","options","install","code","getFeature","isInstalled","skill","status","errors","SpruceError","commandService","Service","command","isRunningLocally","execute","results","resultParts","stdout","split","HEALTH_DIVIDER","JSON","parse","error","originalError","apiClients","key","disconnect","program","CliGlobalEmitter","Emitter","process","ImportService","enableCaching","ServiceFactory","apiClientFactory","buildApiClientFactory","storeFactory","StoreFactory","homeDir","osUtil","homedir","ui","graphicsInterface","TerminalInterface","writerFactory","WriterFactory","templates","settings","linter","optionOverrides","loadOptionOverrides","blockedCommands","loadCommandBlocks","actionFactory","ActionFactory","ActionExecuter","featureInstallerFactory","FeatureInstallerFactory","WithAllFeatures","FeatureCommandAttacher","codes","featureCodes","feature","attachFeature","commands","sort","a","b","_name","localeCompare","action","_","args","cli","pkg","blocks","doesExist","get","mapped","overrides","Object","keys","forEach","argParserUtil","bootOptions","apiClientUtil","generateClientCacheKey","connectToApi","connect","eventsContracts","require","MercuryClientFactory","Client","contracts","host","DEFAULT_HOST","allowSelfSignedCrt","client","shouldAuthAsCurrentSkill","shouldAuthAsLoggedInPerson","auth","skillId","apiKey","getCurrentSkill","id","person","getLoggedInPerson","token","length","authenticate","run","argv","Command","storeOptionsAsProperties","option","dirIdx","findIndex","v","dir","newCwd","diskUtil","resolvePath","terminal","env","CLI_RENDER_STACK_TRACES","clear","renderHero","CLI_HERO","isAskingForVersion","json","renderHeadline","version","Boot","HOST","setupInFlightEntertainment","parseAsync","_actionResults","getClients","doesSupportColor","ENABLE_INSTALL_INTERTAINMENT","CommandService","__dirname","InFlightEntertainment","setup","FeatureInstaller","startInFlightIntertainmentHandler","didUpdateHandler","start","message","writeStatus","stopInFlightIntertainmentHandler","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAOA;;AACA;;AACA;;;;;;;;;;;;IAyBqBA,G;AASpB,eACCC,GADD,EAECC,gBAFD,EAGCC,cAHD,EAICC,OAJD,EAKCC,QALD,EAMCC,cAND,EAOE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACD,SAAKL,GAAL,GAAWA,GAAX;AACA,SAAKC,gBAAL,GAAwBA,gBAAxB;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACA;;;;WAUD,uBAAqB;AACpB,aAAO,KAAKD,QAAZ;AACA;;;WAED,6BAA2B;AAC1B,aAAO,KAAKC,cAAZ;AACA;;;;8FAED;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAEQ,sBAAKF,OAAL,EAAaG,EAAb,4BAFR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;+FAKA;AAAA;;AAAA;AAAA;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AtB;;AACAD,gBAAAA,gBAAgB,CAAC,UAACE,OAAD,EAAa;AAC7BN,oDAAsBO,WAAtB,CAAkCD,OAAlC;AACA,iBAFe,CAAhB;AAGA,eALD;;AAOAJ,2CAAiBM,gCAAjB,GAAoD,YAAM;AACzDR,kDAAsBS,IAAtB;AACA,eAFD;AAGA;;AAlBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import osUtil from 'os'\nimport {\n\tConnectionOptions,\n\tMercuryClientFactory,\n} from '@sprucelabs/mercury-client'\nimport { MercuryEventEmitter, SpruceSchemas } from '@sprucelabs/mercury-types'\nimport {\n\tdiskUtil,\n\tHealthCheckResults,\n\tHEALTH_DIVIDER,\n} from '@sprucelabs/spruce-skill-utils'\nimport { templates } from '@sprucelabs/spruce-templates'\nimport { Command, CommanderStatic } from 'commander'\nimport './addons/filePrompt.addon'\nimport { CLI_HERO, DEFAULT_HOST } from './constants'\nimport SpruceError from './errors/SpruceError'\nimport ActionExecuter from './features/ActionExecuter'\nimport ActionFactory from './features/ActionFactory'\nimport FeatureCommandAttacher, {\n\tBlockedCommands,\n\tOptionOverrides,\n} from './features/FeatureCommandAttacher'\nimport FeatureInstaller from './features/FeatureInstaller'\nimport FeatureInstallerFactory from './features/FeatureInstallerFactory'\nimport { FeatureCode, InstallFeatureOptions } from './features/features.types'\nimport CliGlobalEmitter, {\n\tGlobalEmitter,\n\tGlobalEventContract,\n} from './GlobalEmitter'\nimport InFlightEntertainment from './InFlightEntertainment'\nimport TerminalInterface from './interfaces/TerminalInterface'\nimport CommandService from './services/CommandService'\nimport ImportService from './services/ImportService'\nimport PkgService from './services/PkgService'\nimport ServiceFactory from './services/ServiceFactory'\nimport StoreFactory from './stores/StoreFactory'\nimport {\n\tApiClient,\n\tApiClientFactory,\n\tApiClientFactoryOptions,\n} from './types/apiClient.types'\nimport { GraphicsInterface } from './types/cli.types'\nimport apiClientUtil from './utilities/apiClient.utility'\nimport { argParserUtil } from './utilities/argParser.utility'\nimport WriterFactory from './writers/WriterFactory'\n\ninterface HealthOptions {\n\tisRunningLocally?: boolean\n}\n\nexport interface CliInterface extends MercuryEventEmitter<GlobalEventContract> {\n\tinstallFeatures: FeatureInstaller['install']\n\tgetFeature: FeatureInstaller['getFeature']\n\tcheckHealth(options?: HealthOptions): Promise<HealthCheckResults>\n}\n\nexport interface CliBootOptions {\n\tcwd?: string\n\thomeDir?: string\n\tprogram?: CommanderStatic['program']\n\tgraphicsInterface?: GraphicsInterface\n\temitter?: GlobalEmitter\n\tapiClientFactory?: ApiClientFactory\n\tfeatureInstaller?: FeatureInstaller\n\thost?: string\n}\n\ntype PromiseCache = Record<string, Promise<ApiClient>>\n\nexport default class Cli implements CliInterface {\n\tprivate cwd: string\n\tprivate featureInstaller: FeatureInstaller\n\tprivate serviceFactory: ServiceFactory\n\tpublic readonly emitter: GlobalEmitter\n\tprivate static apiClients: PromiseCache = {}\n\tprivate attacher?: FeatureCommandAttacher\n\tprivate actionExecuter?: ActionExecuter\n\n\tprivate constructor(\n\t\tcwd: string,\n\t\tfeatureInstaller: FeatureInstaller,\n\t\tserviceFactory: ServiceFactory,\n\t\temitter: GlobalEmitter,\n\t\tattacher?: FeatureCommandAttacher,\n\t\tactionExecuter?: ActionExecuter\n\t) {\n\t\tthis.cwd = cwd\n\t\tthis.featureInstaller = featureInstaller\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.emitter = emitter\n\t\tthis.attacher = attacher\n\t\tthis.actionExecuter = actionExecuter\n\t}\n\n\tpublic static async resetApiClients() {\n\t\tfor (const key in this.apiClients) {\n\t\t\tawait (await this.apiClients[key]).disconnect()\n\t\t}\n\n\t\tthis.apiClients = {}\n\t}\n\n\tpublic getAttacher() {\n\t\treturn this.attacher\n\t}\n\n\tpublic getActionExecuter() {\n\t\treturn this.actionExecuter\n\t}\n\n\tpublic async on(...args: any[]) {\n\t\t//@ts-ignore\n\t\treturn this.emitter.on(...args)\n\t}\n\n\tpublic async off(...args: any[]) {\n\t\t//@ts-ignore\n\t\treturn this.emitter.off(...args)\n\t}\n\n\tpublic async emit(...args: any[]) {\n\t\t//@ts-ignore\n\t\treturn this.emitter.emit(...args)\n\t}\n\n\tpublic async installFeatures(options: InstallFeatureOptions) {\n\t\treturn this.featureInstaller.install(options)\n\t}\n\n\tpublic getFeature<C extends FeatureCode>(code: C) {\n\t\treturn this.featureInstaller.getFeature(code)\n\t}\n\n\tpublic async checkHealth(\n\t\toptions?: HealthOptions\n\t): Promise<HealthCheckResults> {\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('skill')\n\n\t\tif (!isInstalled) {\n\t\t\treturn {\n\t\t\t\tskill: {\n\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\terrors: [\n\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcode: 'SKILL_NOT_INSTALLED',\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst commandService = this.serviceFactory.Service(this.cwd, 'command')\n\t\t\tconst command =\n\t\t\t\toptions?.isRunningLocally === false\n\t\t\t\t\t? 'yarn health'\n\t\t\t\t\t: 'yarn health.local'\n\t\t\tconst results = await commandService.execute(command)\n\t\t\tconst resultParts = results.stdout.split(HEALTH_DIVIDER)\n\n\t\t\treturn JSON.parse(resultParts[1]) as HealthCheckResults\n\t\t} catch (originalError: any) {\n\t\t\tconst error = new SpruceError({\n\t\t\t\tcode: 'BOOT_ERROR',\n\t\t\t\toriginalError,\n\t\t\t})\n\n\t\t\treturn {\n\t\t\t\tskill: {\n\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\terrors: [error],\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static async Boot(options?: CliBootOptions): Promise<CliInterface> {\n\t\tconst program = options?.program\n\t\tconst emitter = options?.emitter ?? CliGlobalEmitter.Emitter()\n\n\t\tlet cwd = options?.cwd ?? process.cwd()\n\n\t\tImportService.enableCaching()\n\n\t\tconst serviceFactory = new ServiceFactory()\n\t\tconst apiClientFactory =\n\t\t\toptions?.apiClientFactory ??\n\t\t\tCli.buildApiClientFactory(cwd, serviceFactory, options)\n\n\t\tconst storeFactory = new StoreFactory({\n\t\t\tcwd,\n\t\t\tserviceFactory,\n\t\t\thomeDir: options?.homeDir ?? osUtil.homedir(),\n\t\t\temitter,\n\t\t\tapiClientFactory,\n\t\t})\n\n\t\tconst ui = options?.graphicsInterface ?? new TerminalInterface(cwd)\n\t\tlet featureInstaller: FeatureInstaller | undefined\n\n\t\tconst writerFactory = new WriterFactory({\n\t\t\ttemplates,\n\t\t\tui,\n\t\t\tsettings: serviceFactory.Service(cwd, 'settings'),\n\t\t\tlinter: serviceFactory.Service(cwd, 'lint'),\n\t\t})\n\n\t\tconst optionOverrides = this.loadOptionOverrides(\n\t\t\tserviceFactory.Service(cwd, 'pkg')\n\t\t)\n\n\t\tconst blockedCommands = this.loadCommandBlocks(\n\t\t\tserviceFactory.Service(cwd, 'pkg')\n\t\t)\n\n\t\tconst actionFactory = new ActionFactory({\n\t\t\tui,\n\t\t\temitter,\n\t\t\tapiClientFactory,\n\t\t\tcwd,\n\t\t\tserviceFactory,\n\t\t\tstoreFactory,\n\t\t\ttemplates,\n\t\t\twriterFactory,\n\t\t\tblockedCommands,\n\t\t\toptionOverrides,\n\t\t})\n\n\t\tconst actionExecuter = new ActionExecuter({\n\t\t\tactionFactory,\n\t\t\tui,\n\t\t\temitter,\n\t\t\t//@ts-ignore\n\t\t\tfeatureInstallerFactory: () => featureInstaller,\n\t\t})\n\n\t\tfeatureInstaller =\n\t\t\toptions?.featureInstaller ??\n\t\t\tFeatureInstallerFactory.WithAllFeatures({\n\t\t\t\tcwd,\n\t\t\t\tserviceFactory,\n\t\t\t\tstoreFactory,\n\t\t\t\tui,\n\t\t\t\temitter,\n\t\t\t\tapiClientFactory,\n\t\t\t\tactionExecuter,\n\t\t\t})\n\n\t\tlet attacher: FeatureCommandAttacher | undefined\n\n\t\tif (program) {\n\t\t\tattacher = new FeatureCommandAttacher({\n\t\t\t\tprogram,\n\t\t\t\tui,\n\t\t\t\tactionExecuter,\n\t\t\t})\n\n\t\t\tconst codes = FeatureInstallerFactory.featureCodes\n\n\t\t\tfor (const code of codes) {\n\t\t\t\tconst feature = featureInstaller.getFeature(code)\n\t\t\t\tawait attacher.attachFeature(feature)\n\t\t\t}\n\n\t\t\tprogram.commands.sort((a: any, b: any) => a._name.localeCompare(b._name))\n\n\t\t\tprogram.action((_, command) => {\n\t\t\t\tthrow new SpruceError({\n\t\t\t\t\tcode: 'INVALID_COMMAND',\n\t\t\t\t\targs: command.args || [],\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\tconst cli = new Cli(\n\t\t\tcwd,\n\t\t\tfeatureInstaller,\n\t\t\tserviceFactory,\n\t\t\temitter,\n\t\t\tattacher,\n\t\t\tactionExecuter\n\t\t)\n\n\t\treturn cli as CliInterface\n\t}\n\n\tprivate static loadCommandBlocks(pkg: PkgService): BlockedCommands {\n\t\tlet blocks: BlockedCommands = {}\n\t\tif (pkg.doesExist()) {\n\t\t\tblocks = pkg.get('skill.blockedCommands') ?? {}\n\t\t}\n\t\treturn blocks\n\t}\n\n\tprivate static loadOptionOverrides(pkg: PkgService): OptionOverrides {\n\t\tconst mapped: OptionOverrides = {}\n\n\t\tif (pkg.doesExist()) {\n\t\t\tconst overrides = pkg.get('skill.commandOverrides')\n\n\t\t\tObject.keys(overrides ?? {}).forEach((command) => {\n\t\t\t\tconst options = argParserUtil.parse(overrides[command])\n\t\t\t\tmapped[command] = options\n\t\t\t})\n\t\t}\n\t\treturn mapped\n\t}\n\n\tpublic static buildApiClientFactory(\n\t\tcwd: string,\n\t\tserviceFactory: ServiceFactory,\n\t\tbootOptions?: CliBootOptions & ConnectionOptions\n\t): ApiClientFactory {\n\t\tconst apiClientFactory = async (options?: ApiClientFactoryOptions) => {\n\t\t\tconst key = apiClientUtil.generateClientCacheKey(options)\n\n\t\t\tif (!Cli.apiClients[key]) {\n\t\t\t\tCli.apiClients[key] = Cli.connectToApi(\n\t\t\t\t\tcwd,\n\t\t\t\t\tserviceFactory,\n\t\t\t\t\toptions,\n\t\t\t\t\tbootOptions\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn Cli.apiClients[key]\n\t\t}\n\n\t\treturn apiClientFactory\n\t}\n\n\tprivate static async connectToApi(\n\t\tcwd: string,\n\t\tserviceFactory: ServiceFactory,\n\t\toptions?: ApiClientFactoryOptions,\n\t\tbootOptions?: CliBootOptions & ConnectionOptions\n\t): Promise<ApiClient> {\n\t\tconst connect = bootOptions?.apiClientFactory\n\t\t\t? bootOptions.apiClientFactory\n\t\t\t: async () => {\n\t\t\t\t\tconst eventsContracts =\n\t\t\t\t\t\trequire('#spruce/events/events.contract').default\n\n\t\t\t\t\tconst client: ApiClient = await MercuryClientFactory.Client({\n\t\t\t\t\t\tcontracts: eventsContracts as any,\n\t\t\t\t\t\thost: bootOptions?.host ?? DEFAULT_HOST,\n\t\t\t\t\t\tallowSelfSignedCrt: true,\n\t\t\t\t\t\t...bootOptions,\n\t\t\t\t\t})\n\n\t\t\t\t\treturn client\n\t\t\t }\n\n\t\tconst {\n\t\t\tshouldAuthAsCurrentSkill = false,\n\t\t\tshouldAuthAsLoggedInPerson = true,\n\t\t} = options ?? {}\n\n\t\tconst client = await connect()\n\n\t\tlet auth: SpruceSchemas.Mercury.v2020_12_25.AuthenticateEmitPayload = {}\n\n\t\tif (options?.skillId && options?.apiKey) {\n\t\t\tauth = {\n\t\t\t\tskillId: options.skillId,\n\t\t\t\tapiKey: options.apiKey,\n\t\t\t}\n\t\t} else if (shouldAuthAsCurrentSkill) {\n\t\t\tconst skill = serviceFactory.Service(cwd, 'auth').getCurrentSkill()\n\n\t\t\tif (skill) {\n\t\t\t\tauth = {\n\t\t\t\t\tskillId: skill.id,\n\t\t\t\t\tapiKey: skill.apiKey,\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (shouldAuthAsLoggedInPerson) {\n\t\t\tconst person = serviceFactory.Service(cwd, 'auth').getLoggedInPerson()\n\n\t\t\tif (person) {\n\t\t\t\tauth.token = person.token\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(auth).length > 0) {\n\t\t\tawait client.authenticate({\n\t\t\t\t...(auth as any),\n\t\t\t})\n\n\t\t\t//@ts-ignore\n\t\t\tclient.auth = auth\n\t\t}\n\n\t\treturn client\n\t}\n}\n\nexport async function run(argv: string[] = []): Promise<void> {\n\tconst program = new Command()\n\tlet cwd = process.cwd()\n\n\tprogram.storeOptionsAsProperties(false)\n\tprogram.option('--no-color', 'Disable color output in the console')\n\tprogram.option(\n\t\t'-d, --directory <path>',\n\t\t'The working directory to execute the command'\n\t)\n\tprogram.option('-v, --version', 'The version of the cli')\n\n\tconst dirIdx = process.argv.findIndex(\n\t\t(v) => v === '--directory' || v === '-d'\n\t)\n\n\tif (dirIdx > -1) {\n\t\tconst dir = process.argv[dirIdx + 1]\n\t\tconst newCwd = diskUtil.resolvePath(cwd, dir)\n\t\tcwd = newCwd\n\t}\n\n\tconst terminal = new TerminalInterface(\n\t\tcwd,\n\t\tprocess.env.CLI_RENDER_STACK_TRACES !== 'false'\n\t)\n\tterminal.clear()\n\tterminal.renderHero(CLI_HERO)\n\n\tconst isAskingForVersion =\n\t\tprocess.argv.findIndex((v) => v === '--version' || v === '-v') > -1\n\n\tif (isAskingForVersion) {\n\t\tconst json = require('../package.json')\n\t\tterminal.renderHeadline(`Version ${json.version}`)\n\t\treturn\n\t}\n\n\tawait Cli.Boot({\n\t\tprogram,\n\t\tcwd,\n\t\thost: process.env.HOST,\n\t\tgraphicsInterface: terminal,\n\t})\n\n\tawait setupInFlightEntertainment(terminal)\n\n\tconst command = await program.parseAsync(argv)\n\n\t//@ts-ignore\n\tconst results = await command._actionResults[0]\n\n\tfor (const client of MercuryClientFactory.getClients()) {\n\t\tawait client.disconnect()\n\t}\n\n\treturn results\n}\n\nasync function setupInFlightEntertainment(ui: TerminalInterface) {\n\tif (\n\t\tTerminalInterface.doesSupportColor() &&\n\t\tprocess.env.ENABLE_INSTALL_INTERTAINMENT !== 'false'\n\t) {\n\t\tconst command = new CommandService(diskUtil.resolvePath(__dirname, '../'))\n\t\tInFlightEntertainment.setup({ command, ui })\n\n\t\tFeatureInstaller.startInFlightIntertainmentHandler = (didUpdateHandler) => {\n\t\t\tInFlightEntertainment.start()\n\t\t\tdidUpdateHandler((message) => {\n\t\t\t\tInFlightEntertainment.writeStatus(message)\n\t\t\t})\n\t\t}\n\n\t\tFeatureInstaller.stopInFlightIntertainmentHandler = () => {\n\t\t\tInFlightEntertainment.stop()\n\t\t}\n\t}\n}\n"],"file":"cli.js"}
1
+ {"version":3,"sources":["../src/cli.ts"],"names":["Cli","cwd","featureInstaller","serviceFactory","emitter","attacher","actionExecuter","on","off","emit","options","install","code","getFeature","isInstalled","skill","status","errors","SpruceError","commandService","Service","command","shouldRunOnSourceFiles","execute","results","resultParts","stdout","split","HEALTH_DIVIDER","JSON","parse","error","originalError","apiClients","key","disconnect","program","CliGlobalEmitter","Emitter","process","ImportService","enableCaching","ServiceFactory","apiClientFactory","buildApiClientFactory","storeFactory","StoreFactory","homeDir","osUtil","homedir","ui","graphicsInterface","TerminalInterface","writerFactory","WriterFactory","templates","settings","linter","optionOverrides","loadOptionOverrides","blockedCommands","loadCommandBlocks","actionFactory","ActionFactory","ActionExecuter","featureInstallerFactory","FeatureInstallerFactory","WithAllFeatures","FeatureCommandAttacher","codes","featureCodes","feature","attachFeature","commands","sort","a","b","_name","localeCompare","action","_","args","cli","pkg","blocks","doesExist","get","mapped","overrides","Object","keys","forEach","argParserUtil","bootOptions","apiClientUtil","generateClientCacheKey","connectToApi","connect","eventsContracts","require","MercuryClientFactory","Client","contracts","host","DEFAULT_HOST","allowSelfSignedCrt","client","shouldAuthAsCurrentSkill","shouldAuthAsLoggedInPerson","auth","skillId","apiKey","getCurrentSkill","id","person","getLoggedInPerson","token","length","authenticate","run","argv","Command","storeOptionsAsProperties","option","dirIdx","findIndex","v","dir","newCwd","diskUtil","resolvePath","terminal","env","CLI_RENDER_STACK_TRACES","clear","renderHero","CLI_HERO","isAskingForVersion","json","renderHeadline","version","Boot","HOST","setupInFlightEntertainment","parseAsync","_actionResults","getClients","doesSupportColor","ENABLE_INSTALL_INTERTAINMENT","CommandService","__dirname","InFlightEntertainment","setup","FeatureInstaller","startInFlightIntertainmentHandler","didUpdateHandler","start","message","writeStatus","stopInFlightIntertainmentHandler","stop"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAKA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AAEA;;AAIA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAOA;;AACA;;AACA;;;;;;;;;;;;IAyBqBA,G;AASpB,eACCC,GADD,EAECC,gBAFD,EAGCC,cAHD,EAICC,OAJD,EAKCC,QALD,EAMCC,cAND,EAOE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACD,SAAKL,GAAL,GAAWA,GAAX;AACA,SAAKC,gBAAL,GAAwBA,gBAAxB;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACA,SAAKC,OAAL,GAAeA,OAAf;AACA,SAAKC,QAAL,GAAgBA,QAAhB;AACA,SAAKC,cAAL,GAAsBA,cAAtB;AACA;;;;WAUD,uBAAqB;AACpB,aAAO,KAAKD,QAAZ;AACA;;;WAED,6BAA2B;AAC1B,aAAO,KAAKC,cAAZ;AACA;;;;8FAED;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAEQ,sBAAKF,OAAL,EAAaG,EAAb,4BAFR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;+FAKA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kDAEQ,uBAAKH,OAAL,EAAaI,GAAb,8BAFR;;AAAA;AAAA;AAAA;AAA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C;AACA,iBAFe,CAAhB;AAGA,eALD;;AAOAJ,2CAAiBM,gCAAjB,GAAoD,YAAM;AACzDR,kDAAsBS,IAAtB;AACA,eAFD;AAGA;;AAlBF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import osUtil from 'os'\nimport {\n\tConnectionOptions,\n\tMercuryClientFactory,\n} from '@sprucelabs/mercury-client'\nimport { MercuryEventEmitter, SpruceSchemas } from '@sprucelabs/mercury-types'\nimport {\n\tdiskUtil,\n\tHealthCheckResults,\n\tHEALTH_DIVIDER,\n} from '@sprucelabs/spruce-skill-utils'\nimport { templates } from '@sprucelabs/spruce-templates'\nimport { Command, CommanderStatic } from 'commander'\nimport './addons/filePrompt.addon'\nimport { CLI_HERO, DEFAULT_HOST } from './constants'\nimport SpruceError from './errors/SpruceError'\nimport ActionExecuter from './features/ActionExecuter'\nimport ActionFactory from './features/ActionFactory'\nimport FeatureCommandAttacher, {\n\tBlockedCommands,\n\tOptionOverrides,\n} from './features/FeatureCommandAttacher'\nimport FeatureInstaller from './features/FeatureInstaller'\nimport FeatureInstallerFactory from './features/FeatureInstallerFactory'\nimport { FeatureCode, InstallFeatureOptions } from './features/features.types'\nimport CliGlobalEmitter, {\n\tGlobalEmitter,\n\tGlobalEventContract,\n} from './GlobalEmitter'\nimport InFlightEntertainment from './InFlightEntertainment'\nimport TerminalInterface from './interfaces/TerminalInterface'\nimport CommandService from './services/CommandService'\nimport ImportService from './services/ImportService'\nimport PkgService from './services/PkgService'\nimport ServiceFactory from './services/ServiceFactory'\nimport StoreFactory from './stores/StoreFactory'\nimport {\n\tApiClient,\n\tApiClientFactory,\n\tApiClientFactoryOptions,\n} from './types/apiClient.types'\nimport { GraphicsInterface } from './types/cli.types'\nimport apiClientUtil from './utilities/apiClient.utility'\nimport { argParserUtil } from './utilities/argParser.utility'\nimport WriterFactory from './writers/WriterFactory'\n\ninterface HealthOptions {\n\tshouldRunOnSourceFiles?: boolean\n}\n\nexport interface CliInterface extends MercuryEventEmitter<GlobalEventContract> {\n\tinstallFeatures: FeatureInstaller['install']\n\tgetFeature: FeatureInstaller['getFeature']\n\tcheckHealth(options?: HealthOptions): Promise<HealthCheckResults>\n}\n\nexport interface CliBootOptions {\n\tcwd?: string\n\thomeDir?: string\n\tprogram?: CommanderStatic['program']\n\tgraphicsInterface?: GraphicsInterface\n\temitter?: GlobalEmitter\n\tapiClientFactory?: ApiClientFactory\n\tfeatureInstaller?: FeatureInstaller\n\thost?: string\n}\n\ntype PromiseCache = Record<string, Promise<ApiClient>>\n\nexport default class Cli implements CliInterface {\n\tprivate cwd: string\n\tprivate featureInstaller: FeatureInstaller\n\tprivate serviceFactory: ServiceFactory\n\tpublic readonly emitter: GlobalEmitter\n\tprivate static apiClients: PromiseCache = {}\n\tprivate attacher?: FeatureCommandAttacher\n\tprivate actionExecuter?: ActionExecuter\n\n\tprivate constructor(\n\t\tcwd: string,\n\t\tfeatureInstaller: FeatureInstaller,\n\t\tserviceFactory: ServiceFactory,\n\t\temitter: GlobalEmitter,\n\t\tattacher?: FeatureCommandAttacher,\n\t\tactionExecuter?: ActionExecuter\n\t) {\n\t\tthis.cwd = cwd\n\t\tthis.featureInstaller = featureInstaller\n\t\tthis.serviceFactory = serviceFactory\n\t\tthis.emitter = emitter\n\t\tthis.attacher = attacher\n\t\tthis.actionExecuter = actionExecuter\n\t}\n\n\tpublic static async resetApiClients() {\n\t\tfor (const key in this.apiClients) {\n\t\t\tawait (await this.apiClients[key]).disconnect()\n\t\t}\n\n\t\tthis.apiClients = {}\n\t}\n\n\tpublic getAttacher() {\n\t\treturn this.attacher\n\t}\n\n\tpublic getActionExecuter() {\n\t\treturn this.actionExecuter\n\t}\n\n\tpublic async on(...args: any[]) {\n\t\t//@ts-ignore\n\t\treturn this.emitter.on(...args)\n\t}\n\n\tpublic async off(...args: any[]) {\n\t\t//@ts-ignore\n\t\treturn this.emitter.off(...args)\n\t}\n\n\tpublic async emit(...args: any[]) {\n\t\t//@ts-ignore\n\t\treturn this.emitter.emit(...args)\n\t}\n\n\tpublic async installFeatures(options: InstallFeatureOptions) {\n\t\treturn this.featureInstaller.install(options)\n\t}\n\n\tpublic getFeature<C extends FeatureCode>(code: C) {\n\t\treturn this.featureInstaller.getFeature(code)\n\t}\n\n\tpublic async checkHealth(\n\t\toptions?: HealthOptions\n\t): Promise<HealthCheckResults> {\n\t\tconst isInstalled = await this.featureInstaller.isInstalled('skill')\n\n\t\tif (!isInstalled) {\n\t\t\treturn {\n\t\t\t\tskill: {\n\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\terrors: [\n\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t\t\tcode: 'SKILL_NOT_INSTALLED',\n\t\t\t\t\t\t}),\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst commandService = this.serviceFactory.Service(this.cwd, 'command')\n\t\t\tconst command =\n\t\t\t\toptions?.shouldRunOnSourceFiles === false\n\t\t\t\t\t? 'yarn health'\n\t\t\t\t\t: 'yarn health.local'\n\t\t\tconst results = await commandService.execute(command)\n\t\t\tconst resultParts = results.stdout.split(HEALTH_DIVIDER)\n\n\t\t\treturn JSON.parse(resultParts[1]) as HealthCheckResults\n\t\t} catch (originalError: any) {\n\t\t\tconst error = new SpruceError({\n\t\t\t\tcode: 'BOOT_ERROR',\n\t\t\t\toriginalError,\n\t\t\t})\n\n\t\t\treturn {\n\t\t\t\tskill: {\n\t\t\t\t\tstatus: 'failed',\n\t\t\t\t\terrors: [error],\n\t\t\t\t},\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic static async Boot(options?: CliBootOptions): Promise<CliInterface> {\n\t\tconst program = options?.program\n\t\tconst emitter = options?.emitter ?? CliGlobalEmitter.Emitter()\n\n\t\tlet cwd = options?.cwd ?? process.cwd()\n\n\t\tImportService.enableCaching()\n\n\t\tconst serviceFactory = new ServiceFactory()\n\t\tconst apiClientFactory =\n\t\t\toptions?.apiClientFactory ??\n\t\t\tCli.buildApiClientFactory(cwd, serviceFactory, options)\n\n\t\tconst storeFactory = new StoreFactory({\n\t\t\tcwd,\n\t\t\tserviceFactory,\n\t\t\thomeDir: options?.homeDir ?? osUtil.homedir(),\n\t\t\temitter,\n\t\t\tapiClientFactory,\n\t\t})\n\n\t\tconst ui = options?.graphicsInterface ?? new TerminalInterface(cwd)\n\t\tlet featureInstaller: FeatureInstaller | undefined\n\n\t\tconst writerFactory = new WriterFactory({\n\t\t\ttemplates,\n\t\t\tui,\n\t\t\tsettings: serviceFactory.Service(cwd, 'settings'),\n\t\t\tlinter: serviceFactory.Service(cwd, 'lint'),\n\t\t})\n\n\t\tconst optionOverrides = this.loadOptionOverrides(\n\t\t\tserviceFactory.Service(cwd, 'pkg')\n\t\t)\n\n\t\tconst blockedCommands = this.loadCommandBlocks(\n\t\t\tserviceFactory.Service(cwd, 'pkg')\n\t\t)\n\n\t\tconst actionFactory = new ActionFactory({\n\t\t\tui,\n\t\t\temitter,\n\t\t\tapiClientFactory,\n\t\t\tcwd,\n\t\t\tserviceFactory,\n\t\t\tstoreFactory,\n\t\t\ttemplates,\n\t\t\twriterFactory,\n\t\t\tblockedCommands,\n\t\t\toptionOverrides,\n\t\t})\n\n\t\tconst actionExecuter = new ActionExecuter({\n\t\t\tactionFactory,\n\t\t\tui,\n\t\t\temitter,\n\t\t\t//@ts-ignore\n\t\t\tfeatureInstallerFactory: () => featureInstaller,\n\t\t})\n\n\t\tfeatureInstaller =\n\t\t\toptions?.featureInstaller ??\n\t\t\tFeatureInstallerFactory.WithAllFeatures({\n\t\t\t\tcwd,\n\t\t\t\tserviceFactory,\n\t\t\t\tstoreFactory,\n\t\t\t\tui,\n\t\t\t\temitter,\n\t\t\t\tapiClientFactory,\n\t\t\t\tactionExecuter,\n\t\t\t})\n\n\t\tlet attacher: FeatureCommandAttacher | undefined\n\n\t\tif (program) {\n\t\t\tattacher = new FeatureCommandAttacher({\n\t\t\t\tprogram,\n\t\t\t\tui,\n\t\t\t\tactionExecuter,\n\t\t\t})\n\n\t\t\tconst codes = FeatureInstallerFactory.featureCodes\n\n\t\t\tfor (const code of codes) {\n\t\t\t\tconst feature = featureInstaller.getFeature(code)\n\t\t\t\tawait attacher.attachFeature(feature)\n\t\t\t}\n\n\t\t\tprogram.commands.sort((a: any, b: any) => a._name.localeCompare(b._name))\n\n\t\t\tprogram.action((_, command) => {\n\t\t\t\tthrow new SpruceError({\n\t\t\t\t\tcode: 'INVALID_COMMAND',\n\t\t\t\t\targs: command.args || [],\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\n\t\tconst cli = new Cli(\n\t\t\tcwd,\n\t\t\tfeatureInstaller,\n\t\t\tserviceFactory,\n\t\t\temitter,\n\t\t\tattacher,\n\t\t\tactionExecuter\n\t\t)\n\n\t\treturn cli as CliInterface\n\t}\n\n\tprivate static loadCommandBlocks(pkg: PkgService): BlockedCommands {\n\t\tlet blocks: BlockedCommands = {}\n\t\tif (pkg.doesExist()) {\n\t\t\tblocks = pkg.get('skill.blockedCommands') ?? {}\n\t\t}\n\t\treturn blocks\n\t}\n\n\tprivate static loadOptionOverrides(pkg: PkgService): OptionOverrides {\n\t\tconst mapped: OptionOverrides = {}\n\n\t\tif (pkg.doesExist()) {\n\t\t\tconst overrides = pkg.get('skill.commandOverrides')\n\n\t\t\tObject.keys(overrides ?? {}).forEach((command) => {\n\t\t\t\tconst options = argParserUtil.parse(overrides[command])\n\t\t\t\tmapped[command] = options\n\t\t\t})\n\t\t}\n\t\treturn mapped\n\t}\n\n\tpublic static buildApiClientFactory(\n\t\tcwd: string,\n\t\tserviceFactory: ServiceFactory,\n\t\tbootOptions?: CliBootOptions & ConnectionOptions\n\t): ApiClientFactory {\n\t\tconst apiClientFactory = async (options?: ApiClientFactoryOptions) => {\n\t\t\tconst key = apiClientUtil.generateClientCacheKey(options)\n\n\t\t\tif (!Cli.apiClients[key]) {\n\t\t\t\tCli.apiClients[key] = Cli.connectToApi(\n\t\t\t\t\tcwd,\n\t\t\t\t\tserviceFactory,\n\t\t\t\t\toptions,\n\t\t\t\t\tbootOptions\n\t\t\t\t)\n\t\t\t}\n\n\t\t\treturn Cli.apiClients[key]\n\t\t}\n\n\t\treturn apiClientFactory\n\t}\n\n\tprivate static async connectToApi(\n\t\tcwd: string,\n\t\tserviceFactory: ServiceFactory,\n\t\toptions?: ApiClientFactoryOptions,\n\t\tbootOptions?: CliBootOptions & ConnectionOptions\n\t): Promise<ApiClient> {\n\t\tconst connect = bootOptions?.apiClientFactory\n\t\t\t? bootOptions.apiClientFactory\n\t\t\t: async () => {\n\t\t\t\t\tconst eventsContracts =\n\t\t\t\t\t\trequire('#spruce/events/events.contract').default\n\n\t\t\t\t\tconst client: ApiClient = await MercuryClientFactory.Client({\n\t\t\t\t\t\tcontracts: eventsContracts as any,\n\t\t\t\t\t\thost: bootOptions?.host ?? DEFAULT_HOST,\n\t\t\t\t\t\tallowSelfSignedCrt: true,\n\t\t\t\t\t\t...bootOptions,\n\t\t\t\t\t})\n\n\t\t\t\t\treturn client\n\t\t\t }\n\n\t\tconst {\n\t\t\tshouldAuthAsCurrentSkill = false,\n\t\t\tshouldAuthAsLoggedInPerson = true,\n\t\t} = options ?? {}\n\n\t\tconst client = await connect()\n\n\t\tlet auth: SpruceSchemas.Mercury.v2020_12_25.AuthenticateEmitPayload = {}\n\n\t\tif (options?.skillId && options?.apiKey) {\n\t\t\tauth = {\n\t\t\t\tskillId: options.skillId,\n\t\t\t\tapiKey: options.apiKey,\n\t\t\t}\n\t\t} else if (shouldAuthAsCurrentSkill) {\n\t\t\tconst skill = serviceFactory.Service(cwd, 'auth').getCurrentSkill()\n\n\t\t\tif (skill) {\n\t\t\t\tauth = {\n\t\t\t\t\tskillId: skill.id,\n\t\t\t\t\tapiKey: skill.apiKey,\n\t\t\t\t}\n\t\t\t}\n\t\t} else if (shouldAuthAsLoggedInPerson) {\n\t\t\tconst person = serviceFactory.Service(cwd, 'auth').getLoggedInPerson()\n\n\t\t\tif (person) {\n\t\t\t\tauth.token = person.token\n\t\t\t}\n\t\t}\n\n\t\tif (Object.keys(auth).length > 0) {\n\t\t\tawait client.authenticate({\n\t\t\t\t...(auth as any),\n\t\t\t})\n\n\t\t\t//@ts-ignore\n\t\t\tclient.auth = auth\n\t\t}\n\n\t\treturn client\n\t}\n}\n\nexport async function run(argv: string[] = []): Promise<void> {\n\tconst program = new Command()\n\tlet cwd = process.cwd()\n\n\tprogram.storeOptionsAsProperties(false)\n\tprogram.option('--no-color', 'Disable color output in the console')\n\tprogram.option(\n\t\t'-d, --directory <path>',\n\t\t'The working directory to execute the command'\n\t)\n\tprogram.option('-v, --version', 'The version of the cli')\n\n\tconst dirIdx = process.argv.findIndex(\n\t\t(v) => v === '--directory' || v === '-d'\n\t)\n\n\tif (dirIdx > -1) {\n\t\tconst dir = process.argv[dirIdx + 1]\n\t\tconst newCwd = diskUtil.resolvePath(cwd, dir)\n\t\tcwd = newCwd\n\t}\n\n\tconst terminal = new TerminalInterface(\n\t\tcwd,\n\t\tprocess.env.CLI_RENDER_STACK_TRACES !== 'false'\n\t)\n\tterminal.clear()\n\tterminal.renderHero(CLI_HERO)\n\n\tconst isAskingForVersion =\n\t\tprocess.argv.findIndex((v) => v === '--version' || v === '-v') > -1\n\n\tif (isAskingForVersion) {\n\t\tconst json = require('../package.json')\n\t\tterminal.renderHeadline(`Version ${json.version}`)\n\t\treturn\n\t}\n\n\tawait Cli.Boot({\n\t\tprogram,\n\t\tcwd,\n\t\thost: process.env.HOST,\n\t\tgraphicsInterface: terminal,\n\t})\n\n\tawait setupInFlightEntertainment(terminal)\n\n\tconst command = await program.parseAsync(argv)\n\n\t//@ts-ignore\n\tconst results = await command._actionResults[0]\n\n\tfor (const client of MercuryClientFactory.getClients()) {\n\t\tawait client.disconnect()\n\t}\n\n\treturn results\n}\n\nasync function setupInFlightEntertainment(ui: TerminalInterface) {\n\tif (\n\t\tTerminalInterface.doesSupportColor() &&\n\t\tprocess.env.ENABLE_INSTALL_INTERTAINMENT !== 'false'\n\t) {\n\t\tconst command = new CommandService(diskUtil.resolvePath(__dirname, '../'))\n\t\tInFlightEntertainment.setup({ command, ui })\n\n\t\tFeatureInstaller.startInFlightIntertainmentHandler = (didUpdateHandler) => {\n\t\t\tInFlightEntertainment.start()\n\t\t\tdidUpdateHandler((message) => {\n\t\t\t\tInFlightEntertainment.writeStatus(message)\n\t\t\t})\n\t\t}\n\n\t\tFeatureInstaller.stopInFlightIntertainmentHandler = () => {\n\t\t\tInFlightEntertainment.stop()\n\t\t}\n\t}\n}\n"],"file":"cli.js"}
@@ -127,33 +127,28 @@ var NodeFeature = /*#__PURE__*/function (_AbstractFeature) {
127
127
  return this.Service('command').execute('yarn clean.build');
128
128
 
129
129
  case 4:
130
- this.ui.startLoading('Applying lint rules to all files...');
131
- _context3.next = 7;
132
- return this.Service('command').execute('yarn fix.lint');
133
-
134
- case 7:
135
130
  this.ui.startLoading('Rebuilding...');
136
- _context3.next = 10;
131
+ _context3.next = 7;
137
132
  return this.Service('command').execute('yarn build.dev');
138
133
 
139
- case 10:
134
+ case 7:
140
135
  return _context3.abrupt("return", {
141
136
  summaryLines: ['Build cleared.', 'Lint rules applied to source.', 'Code rebuilt successfully.']
142
137
  });
143
138
 
144
- case 13:
145
- _context3.prev = 13;
139
+ case 10:
140
+ _context3.prev = 10;
146
141
  _context3.t0 = _context3["catch"](0);
147
142
  return _context3.abrupt("return", {
148
143
  errors: [_context3.t0]
149
144
  });
150
145
 
151
- case 16:
146
+ case 13:
152
147
  case "end":
153
148
  return _context3.stop();
154
149
  }
155
150
  }
156
- }, _callee3, this, [[0, 13]]);
151
+ }, _callee3, this, [[0, 10]]);
157
152
  }));
158
153
 
159
154
  function handleUpgrade() {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/features/node/NodeFeature.ts"],"names":["NodeFeature","options","nodeFeatureOptionsSchema","universalDevDependencies","universalScripts","universalFileDescriptions","diskUtil","resolvePath","__dirname","doesFileExist","cwd","emitter","on","payload","featureCode","actionCode","handleUpgrade","ui","startLoading","Service","execute","summaryLines","errors","destination","resolveDestination","doesDirExist","createDir","files","name","path","action","Writer","writeNodeModule","written","push","installScripts","pkg","set","value","namesUtil","toKebab","description","unset","Store","setCurrentSkillsNamespace","scriptUpdater","ScriptUpdater","FromFeature","update","AbstractFeature"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AAEA;;AACA;;AAMA;;AACA;;AACA;;;;;;;;;;IAgBqBA,W;;;;;AAoBpB,uBAAmBC,OAAnB,EAA2C;AAAA;;AAAA;AAC1C,8BAAMA,OAAN;AAD0C,6FAjBhB,MAiBgB;AAAA,qGAhBrB,gBAgBqB;AAAA,oGAftB,EAesB;AAAA,qGAdA,EAcA;AAAA,sGAbpBC,8BAaoB;AAAA,gJAZVC,oCAYU;AAAA,kHATvCC,4BASuC;AAAA,6IALvCC,qCAKuC;AAAA,mGAFvBC,2BAASC,WAAT,CAAqBC,SAArB,EAAgC,SAAhC,CAEuB;AAAA,+LA4FtB;AAAA;AAAA;AAAA;AAAA;AAAA,+CACbF,2BAASG,aAAT,CACNH,2BAASC,WAAT,CAAqB,MAAKG,GAA1B,EAA+B,cAA/B,CADM,CADa;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,KA5FsB;AAG1C,SAAK,MAAKC,OAAL,CAAaC,EAAb,CAAgB,qBAAhB;AAAA,gGAAuC,kBAAOC,OAAP;AAAA;AAAA;AAAA;AAAA;AAAA,sBACvCA,OAAO,CAACC,WAAR,KAAwB,MAAxB,IAAkCD,OAAO,CAACE,UAAR,KAAuB,SADlB;AAAA;AAAA;AAAA;;AAAA,kDAEnC,MAAKC,aAAL,EAFmC;;AAAA;AAAA,kDAKpC,EALoC;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAvC;;AAAA;AAAA;AAAA;AAAA,QAAL;AAH0C;AAU1C;;;;;yGACD;AAAA;AAAA;AAAA;AA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C,kBAAAA,GAAG,EAAHA;AAAF,iBAApB,EAA6BkC,yBAA7B,CAAuD3C,OAAO,CAAC2B,IAA/D,CAbP;;AAAA;AAAA,kDAeQ,EAfR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;0GAkBA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA6BL,gBAAAA,WAA7B,8DAA2C,KAAKb,GAAhD;AACOmC,gBAAAA,aADP,GACuBC,0BAAcC,WAAd,CAA0B,IAA1B,EAAgC;AACrDrC,kBAAAA,GAAG,EAAEa;AADgD,iBAAhC,CADvB;AAAA;AAAA,uBAKOsB,aAAa,CAACG,MAAd,EALP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAtGSC,4B","sourcesContent":["import { Schema, SchemaValues } from '@sprucelabs/schema'\nimport { SpruceSchemas } from '@sprucelabs/spruce-core-schemas'\nimport { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport nodeFeatureOptionsSchema from '#spruce/schemas/spruceCli/v2020_07_22/nodeFeatureOptions.schema'\nimport { FileDescription, GeneratedFile } from '../../types/cli.types'\nimport ScriptUpdater from '../../updaters/ScriptUpdater'\nimport AbstractFeature, { FeatureDependency } from '../AbstractFeature'\nimport {\n\tActionOptions,\n\tFeatureActionResponse,\n\tFeatureCode,\n} from '../features.types'\nimport universalDevDependencies from '../universalDevDependencies'\nimport universalFileDescriptions from '../universalFileDescriptions'\nimport universalScripts from '../universalScripts'\n\ntype OptionsSchema =\n\tSpruceSchemas.SpruceCli.v2020_07_22.NodeFeatureOptionsSchema\ntype Options = SpruceSchemas.SpruceCli.v2020_07_22.NodeFeatureOptions\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tnode: NodeFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tnode: SchemaValues<OptionsSchema>\n\t}\n}\n\nexport default class NodeFeature<\n\tS extends OptionsSchema = OptionsSchema\n> extends AbstractFeature<S> {\n\tpublic code: FeatureCode = 'node'\n\tpublic nameReadable = 'nodejs support'\n\tpublic description = ''\n\tpublic dependencies: FeatureDependency[] = []\n\tpublic optionsSchema = nodeFeatureOptionsSchema as S\n\tpublic packageDependencies = [...universalDevDependencies]\n\n\tpublic scripts = {\n\t\t...universalScripts,\n\t}\n\n\tpublic readonly fileDescriptions: FileDescription[] = [\n\t\t...universalFileDescriptions,\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic constructor(options: ActionOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on('feature.did-execute', async (payload) => {\n\t\t\tif (payload.featureCode === 'node' && payload.actionCode === 'upgrade') {\n\t\t\t\treturn this.handleUpgrade()\n\t\t\t}\n\n\t\t\treturn {}\n\t\t})\n\t}\n\tprivate async handleUpgrade(): Promise<FeatureActionResponse> {\n\t\ttry {\n\t\t\tthis.ui.startLoading('Cleaning build...')\n\t\t\tawait this.Service('command').execute('yarn clean.build')\n\n\t\t\tthis.ui.startLoading('Applying lint rules to all files...')\n\t\t\tawait this.Service('command').execute('yarn fix.lint')\n\n\t\t\tthis.ui.startLoading('Rebuilding...')\n\t\t\tawait this.Service('command').execute('yarn build.dev')\n\n\t\t\treturn {\n\t\t\t\tsummaryLines: [\n\t\t\t\t\t'Build cleared.',\n\t\t\t\t\t'Lint rules applied to source.',\n\t\t\t\t\t'Code rebuilt successfully.',\n\t\t\t\t],\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async beforePackageInstall(options: Options) {\n\t\tconst destination = this.resolveDestination(options)\n\n\t\tif (!diskUtil.doesDirExist(destination)) {\n\t\t\tdiskUtil.createDir(destination)\n\t\t}\n\n\t\tconst files: GeneratedFile[] = [\n\t\t\t{\n\t\t\t\tname: 'package.json',\n\t\t\t\tpath: diskUtil.resolvePath(destination, 'package.json'),\n\t\t\t\taction: 'generated',\n\t\t\t},\n\t\t]\n\n\t\tawait this.Service('command', destination).execute('yarn init -y')\n\n\t\tconst written = await this.Writer('node').writeNodeModule(destination)\n\n\t\tfiles.push(...written)\n\n\t\tawait this.installScripts(destination)\n\n\t\treturn { files, cwd: destination }\n\t}\n\n\tprivate resolveDestination(options: Options) {\n\t\treturn diskUtil.resolvePath(this.cwd, options.destination ?? '')\n\t}\n\n\tpublic async afterPackageInstall(\n\t\toptions: S extends Schema ? SchemaValues<S> : undefined\n\t) {\n\t\tconst cwd = this.resolveDestination(options)\n\t\tconst pkg = this.Service('pkg', cwd)\n\n\t\tpkg.set({ path: 'name', value: namesUtil.toKebab(options.name) })\n\t\tpkg.set({ path: 'description', value: options.description })\n\t\tpkg.set({ path: 'version', value: '0.0.1' })\n\n\t\tpkg.unset('main')\n\t\tpkg.unset('license')\n\n\t\tawait this.Store('skill', { cwd }).setCurrentSkillsNamespace(options.name)\n\n\t\treturn {}\n\t}\n\n\tprivate async installScripts(destination = this.cwd) {\n\t\tconst scriptUpdater = ScriptUpdater.FromFeature(this, {\n\t\t\tcwd: destination,\n\t\t})\n\n\t\tawait scriptUpdater.update()\n\t}\n\n\tpublic isInstalled = async (): Promise<boolean> => {\n\t\treturn diskUtil.doesFileExist(\n\t\t\tdiskUtil.resolvePath(this.cwd, 'package.json')\n\t\t)\n\t}\n}\n"],"file":"NodeFeature.js"}
1
+ {"version":3,"sources":["../../../src/features/node/NodeFeature.ts"],"names":["NodeFeature","options","nodeFeatureOptionsSchema","universalDevDependencies","universalScripts","universalFileDescriptions","diskUtil","resolvePath","__dirname","doesFileExist","cwd","emitter","on","payload","featureCode","actionCode","handleUpgrade","ui","startLoading","Service","execute","summaryLines","errors","destination","resolveDestination","doesDirExist","createDir","files","name","path","action","Writer","writeNodeModule","written","push","installScripts","pkg","set","value","namesUtil","toKebab","description","unset","Store","setCurrentSkillsNamespace","scriptUpdater","ScriptUpdater","FromFeature","update","AbstractFeature"],"mappings":";;;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Ea;AADgD,iBAAhC,CADvB;AAAA;AAAA,uBAKOsB,aAAa,CAACG,MAAd,EALP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAnGSC,4B","sourcesContent":["import { Schema, SchemaValues } from '@sprucelabs/schema'\nimport { SpruceSchemas } from '@sprucelabs/spruce-core-schemas'\nimport { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'\nimport nodeFeatureOptionsSchema from '#spruce/schemas/spruceCli/v2020_07_22/nodeFeatureOptions.schema'\nimport { FileDescription, GeneratedFile } from '../../types/cli.types'\nimport ScriptUpdater from '../../updaters/ScriptUpdater'\nimport AbstractFeature, { FeatureDependency } from '../AbstractFeature'\nimport {\n\tActionOptions,\n\tFeatureActionResponse,\n\tFeatureCode,\n} from '../features.types'\nimport universalDevDependencies from '../universalDevDependencies'\nimport universalFileDescriptions from '../universalFileDescriptions'\nimport universalScripts from '../universalScripts'\n\ntype OptionsSchema =\n\tSpruceSchemas.SpruceCli.v2020_07_22.NodeFeatureOptionsSchema\ntype Options = SpruceSchemas.SpruceCli.v2020_07_22.NodeFeatureOptions\n\ndeclare module '../../features/features.types' {\n\tinterface FeatureMap {\n\t\tnode: NodeFeature\n\t}\n\n\tinterface FeatureOptionsMap {\n\t\tnode: SchemaValues<OptionsSchema>\n\t}\n}\n\nexport default class NodeFeature<\n\tS extends OptionsSchema = OptionsSchema\n> extends AbstractFeature<S> {\n\tpublic code: FeatureCode = 'node'\n\tpublic nameReadable = 'nodejs support'\n\tpublic description = ''\n\tpublic dependencies: FeatureDependency[] = []\n\tpublic optionsSchema = nodeFeatureOptionsSchema as S\n\tpublic packageDependencies = [...universalDevDependencies]\n\n\tpublic scripts = {\n\t\t...universalScripts,\n\t}\n\n\tpublic readonly fileDescriptions: FileDescription[] = [\n\t\t...universalFileDescriptions,\n\t]\n\n\tpublic actionsDir = diskUtil.resolvePath(__dirname, 'actions')\n\n\tpublic constructor(options: ActionOptions) {\n\t\tsuper(options)\n\n\t\tvoid this.emitter.on('feature.did-execute', async (payload) => {\n\t\t\tif (payload.featureCode === 'node' && payload.actionCode === 'upgrade') {\n\t\t\t\treturn this.handleUpgrade()\n\t\t\t}\n\n\t\t\treturn {}\n\t\t})\n\t}\n\tprivate async handleUpgrade(): Promise<FeatureActionResponse> {\n\t\ttry {\n\t\t\tthis.ui.startLoading('Cleaning build...')\n\t\t\tawait this.Service('command').execute('yarn clean.build')\n\n\t\t\tthis.ui.startLoading('Rebuilding...')\n\t\t\tawait this.Service('command').execute('yarn build.dev')\n\n\t\t\treturn {\n\t\t\t\tsummaryLines: [\n\t\t\t\t\t'Build cleared.',\n\t\t\t\t\t'Lint rules applied to source.',\n\t\t\t\t\t'Code rebuilt successfully.',\n\t\t\t\t],\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async beforePackageInstall(options: Options) {\n\t\tconst destination = this.resolveDestination(options)\n\n\t\tif (!diskUtil.doesDirExist(destination)) {\n\t\t\tdiskUtil.createDir(destination)\n\t\t}\n\n\t\tconst files: GeneratedFile[] = [\n\t\t\t{\n\t\t\t\tname: 'package.json',\n\t\t\t\tpath: diskUtil.resolvePath(destination, 'package.json'),\n\t\t\t\taction: 'generated',\n\t\t\t},\n\t\t]\n\n\t\tawait this.Service('command', destination).execute('yarn init -y')\n\n\t\tconst written = await this.Writer('node').writeNodeModule(destination)\n\n\t\tfiles.push(...written)\n\n\t\tawait this.installScripts(destination)\n\n\t\treturn { files, cwd: destination }\n\t}\n\n\tprivate resolveDestination(options: Options) {\n\t\treturn diskUtil.resolvePath(this.cwd, options.destination ?? '')\n\t}\n\n\tpublic async afterPackageInstall(\n\t\toptions: S extends Schema ? SchemaValues<S> : undefined\n\t) {\n\t\tconst cwd = this.resolveDestination(options)\n\t\tconst pkg = this.Service('pkg', cwd)\n\n\t\tpkg.set({ path: 'name', value: namesUtil.toKebab(options.name) })\n\t\tpkg.set({ path: 'description', value: options.description })\n\t\tpkg.set({ path: 'version', value: '0.0.1' })\n\n\t\tpkg.unset('main')\n\t\tpkg.unset('license')\n\n\t\tawait this.Store('skill', { cwd }).setCurrentSkillsNamespace(options.name)\n\n\t\treturn {}\n\t}\n\n\tprivate async installScripts(destination = this.cwd) {\n\t\tconst scriptUpdater = ScriptUpdater.FromFeature(this, {\n\t\t\tcwd: destination,\n\t\t})\n\n\t\tawait scriptUpdater.update()\n\t}\n\n\tpublic isInstalled = async (): Promise<boolean> => {\n\t\treturn diskUtil.doesFileExist(\n\t\t\tdiskUtil.resolvePath(this.cwd, 'package.json')\n\t\t)\n\t}\n}\n"],"file":"NodeFeature.js"}
@@ -68,7 +68,7 @@ var SyncAction = /*#__PURE__*/function (_AbstractAction) {
68
68
  key: "execute",
69
69
  value: function () {
70
70
  var _execute = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_options) {
71
- var stores, files, destination, builder, templateItems;
71
+ var stores, files, destination, builder, templateItems, writer;
72
72
  return _regenerator["default"].wrap(function _callee$(_context) {
73
73
  while (1) {
74
74
  switch (_context.prev = _context.next) {
@@ -82,39 +82,40 @@ var SyncAction = /*#__PURE__*/function (_AbstractAction) {
82
82
  files = [];
83
83
 
84
84
  if (!(stores.length > 0)) {
85
- _context.next = 12;
85
+ _context.next = 13;
86
86
  break;
87
87
  }
88
88
 
89
89
  destination = _spruceSkillUtils.diskUtil.resolveHashSprucePath(this.cwd, 'stores');
90
90
  builder = new _StoreTemplateItemBuilder["default"]();
91
91
  templateItems = builder.buildTemplateItems(stores, destination);
92
- _context.next = 11;
93
- return this.Writer('store').writeTypes(destination, {
92
+ writer = this.Writer('store');
93
+ _context.next = 12;
94
+ return writer.writeTypesAndMap(destination, {
94
95
  stores: templateItems
95
96
  });
96
97
 
97
- case 11:
98
+ case 12:
98
99
  files = _context.sent;
99
100
 
100
- case 12:
101
+ case 13:
101
102
  return _context.abrupt("return", {
102
103
  files: files
103
104
  });
104
105
 
105
- case 15:
106
- _context.prev = 15;
106
+ case 16:
107
+ _context.prev = 16;
107
108
  _context.t0 = _context["catch"](0);
108
109
  return _context.abrupt("return", {
109
110
  errors: [_context.t0]
110
111
  });
111
112
 
112
- case 18:
113
+ case 19:
113
114
  case "end":
114
115
  return _context.stop();
115
116
  }
116
117
  }
117
- }, _callee, this, [[0, 15]]);
118
+ }, _callee, this, [[0, 16]]);
118
119
  }));
119
120
 
120
121
  function execute(_x) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/store/actions/SyncAction.ts"],"names":["optionsSchema","id","description","fields","SyncAction","_options","Store","fetchStores","stores","files","length","destination","diskUtil","resolveHashSprucePath","cwd","builder","StoreTemplateItemBuilder","templateItems","buildTemplateItems","Writer","writeTypes","errors","AbstractAction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,yBAAY;AACjCC,EAAAA,EAAE,EAAE,sBAD6B;AAEjCC,EAAAA,WAAW,EACV,uEAHgC;AAIjCC,EAAAA,MAAM,EAAE;AAJyB,CAAZ,CAAtB;;IAUqBC,U;;;;;;;;;;;;;;;sGACGJ,a;uGACC,CAAC,aAAD,C;0GAEvB,2D;;;;;;;mGAED,iBAAqBK,QAArB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEuB,KAAKC,KAAL,CAAW,OAAX,EAAoBC,WAApB,EAFvB;;AAAA;AAEQC,gBAAAA,MAFR;AAIMC,gBAAAA,KAJN,GAI+B,EAJ/B;;AAAA,sBAMMD,MAAM,CAACE,MAAP,GAAgB,CANtB;AAAA;AAAA;AAAA;;AAOSC,gBAAAA,WAPT,GAOuBC,2BAASC,qBAAT,CAA+B,KAAKC,GAApC,EAAyC,QAAzC,CAPvB;AAQSC,gBAAAA,OART,GAQmB,IAAIC,oCAAJ,EARnB;AASSC,gBAAAA,aATT,GASyBF,OAAO,CAACG,kBAAR,CAA2BV,MAA3B,EAAmCG,WAAnC,CATzB;AAAA;AAAA,uBAWiB,KAAKQ,MAAL,CAAY,OAAZ,EAAqBC,UAArB,CAAgCT,WAAhC,EAA6C;AAC1DH,kBAAAA,MAAM,EAAES;AADkD,iBAA7C,CAXjB;;AAAA;AAWGR,gBAAAA,KAXH;;AAAA;AAAA,iDAgBS;AACNA,kBAAAA,KAAK,EAALA;AADM,iBAhBT;;AAAA;AAAA;AAAA;AAAA,iDAoBS;AACNY,kBAAAA,MAAM,EAAE;AADF,iBApBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EANuCC,2B","sourcesContent":["import { buildSchema, SchemaValues } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractAction from '../../AbstractAction'\nimport StoreTemplateItemBuilder from '../templateItemBuilders/StoreTemplateItemBuilder'\n\nconst optionsSchema = buildSchema({\n\tid: 'syncDataStoreOptions',\n\tdescription:\n\t\t\"Only needed if you change a store's name, manually add or remove one.\",\n\tfields: {},\n})\n\ntype OptionsSchema = typeof optionsSchema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class SyncAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema = optionsSchema\n\tpublic commandAliases = ['sync.stores']\n\tpublic invocationMessage =\n\t\t'Generating store types and setting up store factory... 💿'\n\n\tpublic async execute(_options: Options) {\n\t\ttry {\n\t\t\tconst stores = await this.Store('store').fetchStores()\n\n\t\t\tlet files: GeneratedFile[] = []\n\n\t\t\tif (stores.length > 0) {\n\t\t\t\tconst destination = diskUtil.resolveHashSprucePath(this.cwd, 'stores')\n\t\t\t\tconst builder = new StoreTemplateItemBuilder()\n\t\t\t\tconst templateItems = builder.buildTemplateItems(stores, destination)\n\n\t\t\t\tfiles = await this.Writer('store').writeTypes(destination, {\n\t\t\t\t\tstores: templateItems,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tfiles,\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n}\n"],"file":"SyncAction.js"}
1
+ {"version":3,"sources":["../../../../src/features/store/actions/SyncAction.ts"],"names":["optionsSchema","id","description","fields","SyncAction","_options","Store","fetchStores","stores","files","length","destination","diskUtil","resolveHashSprucePath","cwd","builder","StoreTemplateItemBuilder","templateItems","buildTemplateItems","writer","Writer","writeTypesAndMap","errors","AbstractAction"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAEA;;AACA;;;;;;AAEA,IAAMA,aAAa,GAAG,yBAAY;AACjCC,EAAAA,EAAE,EAAE,sBAD6B;AAEjCC,EAAAA,WAAW,EACV,uEAHgC;AAIjCC,EAAAA,MAAM,EAAE;AAJyB,CAAZ,CAAtB;;IAUqBC,U;;;;;;;;;;;;;;;sGACGJ,a;uGACC,CAAC,aAAD,C;0GAEvB,2D;;;;;;;mGAED,iBAAqBK,QAArB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,uBAEuB,KAAKC,KAAL,CAAW,OAAX,EAAoBC,WAApB,EAFvB;;AAAA;AAEQC,gBAAAA,MAFR;AAIMC,gBAAAA,KAJN,GAI+B,EAJ/B;;AAAA,sBAMMD,MAAM,CAACE,MAAP,GAAgB,CANtB;AAAA;AAAA;AAAA;;AAOSC,gBAAAA,WAPT,GAOuBC,2BAASC,qBAAT,CAA+B,KAAKC,GAApC,EAAyC,QAAzC,CAPvB;AAQSC,gBAAAA,OART,GAQmB,IAAIC,oCAAJ,EARnB;AASSC,gBAAAA,aATT,GASyBF,OAAO,CAACG,kBAAR,CAA2BV,MAA3B,EAAmCG,WAAnC,CATzB;AAWSQ,gBAAAA,MAXT,GAWkB,KAAKC,MAAL,CAAY,OAAZ,CAXlB;AAAA;AAAA,uBAYiBD,MAAM,CAACE,gBAAP,CAAwBV,WAAxB,EAAqC;AAClDH,kBAAAA,MAAM,EAAES;AAD0C,iBAArC,CAZjB;;AAAA;AAYGR,gBAAAA,KAZH;;AAAA;AAAA,iDAiBS;AACNA,kBAAAA,KAAK,EAALA;AADM,iBAjBT;;AAAA;AAAA;AAAA;AAAA,iDAqBS;AACNa,kBAAAA,MAAM,EAAE;AADF,iBArBT;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EANuCC,2B","sourcesContent":["import { buildSchema, SchemaValues } from '@sprucelabs/schema'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractAction from '../../AbstractAction'\nimport StoreTemplateItemBuilder from '../templateItemBuilders/StoreTemplateItemBuilder'\n\nconst optionsSchema = buildSchema({\n\tid: 'syncDataStoreOptions',\n\tdescription:\n\t\t\"Only needed if you change a store's name, manually add or remove one.\",\n\tfields: {},\n})\n\ntype OptionsSchema = typeof optionsSchema\ntype Options = SchemaValues<OptionsSchema>\n\nexport default class SyncAction extends AbstractAction<OptionsSchema> {\n\tpublic optionsSchema = optionsSchema\n\tpublic commandAliases = ['sync.stores']\n\tpublic invocationMessage =\n\t\t'Generating store types and setting up store factory... 💿'\n\n\tpublic async execute(_options: Options) {\n\t\ttry {\n\t\t\tconst stores = await this.Store('store').fetchStores()\n\n\t\t\tlet files: GeneratedFile[] = []\n\n\t\t\tif (stores.length > 0) {\n\t\t\t\tconst destination = diskUtil.resolveHashSprucePath(this.cwd, 'stores')\n\t\t\t\tconst builder = new StoreTemplateItemBuilder()\n\t\t\t\tconst templateItems = builder.buildTemplateItems(stores, destination)\n\n\t\t\t\tconst writer = this.Writer('store')\n\t\t\t\tfiles = await writer.writeTypesAndMap(destination, {\n\t\t\t\t\tstores: templateItems,\n\t\t\t\t})\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tfiles,\n\t\t\t}\n\t\t} catch (err) {\n\t\t\treturn {\n\t\t\t\terrors: [err],\n\t\t\t}\n\t\t}\n\t}\n}\n"],"file":"SyncAction.js"}
@@ -3,7 +3,13 @@ import AbstractWriter from '../../../writers/AbstractWriter';
3
3
  export default class StoreWriter extends AbstractWriter {
4
4
  writeStore(destination: string, options: StoreTemplateOptions): Promise<import("@sprucelabs/mercury-types").SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile[]>;
5
5
  writePlugin(cwd: string): Promise<import("../../../writers/AbstractWriter").WriteResults>;
6
+ writeTypesAndMap(destination: string, options: {
7
+ stores: StoreTemplateItem[];
8
+ }): Promise<import("@sprucelabs/mercury-types").SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile[]>;
6
9
  writeTypes(destination: string, options: {
7
10
  stores: StoreTemplateItem[];
8
11
  }): Promise<import("../../../writers/AbstractWriter").WriteResults>;
12
+ writeMap(destination: string, options: {
13
+ stores: StoreTemplateItem[];
14
+ }): Promise<import("../../../writers/AbstractWriter").WriteResults>;
9
15
  }
@@ -9,6 +9,10 @@ exports["default"] = void 0;
9
9
 
10
10
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
11
 
12
+ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
13
+
14
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
+
12
16
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
17
 
14
18
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
@@ -104,37 +108,103 @@ var StoreWriter = /*#__PURE__*/function (_AbstractWriter) {
104
108
  return results;
105
109
  }
106
110
  }, {
107
- key: "writeTypes",
111
+ key: "writeTypesAndMap",
108
112
  value: function () {
109
- var _writeTypes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(destination, options) {
110
- var file, typesContent, files;
113
+ var _writeTypesAndMap = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(destination, options) {
114
+ var _yield$Promise$all, _yield$Promise$all2, types, map;
115
+
111
116
  return _regenerator["default"].wrap(function _callee2$(_context2) {
112
117
  while (1) {
113
118
  switch (_context2.prev = _context2.next) {
119
+ case 0:
120
+ _context2.next = 2;
121
+ return Promise.all([this.writeTypes(destination, options), this.writeMap(destination, options)]);
122
+
123
+ case 2:
124
+ _yield$Promise$all = _context2.sent;
125
+ _yield$Promise$all2 = (0, _slicedToArray2["default"])(_yield$Promise$all, 2);
126
+ types = _yield$Promise$all2[0];
127
+ map = _yield$Promise$all2[1];
128
+ return _context2.abrupt("return", [].concat((0, _toConsumableArray2["default"])(types), (0, _toConsumableArray2["default"])(map)));
129
+
130
+ case 7:
131
+ case "end":
132
+ return _context2.stop();
133
+ }
134
+ }
135
+ }, _callee2, this);
136
+ }));
137
+
138
+ function writeTypesAndMap(_x3, _x4) {
139
+ return _writeTypesAndMap.apply(this, arguments);
140
+ }
141
+
142
+ return writeTypesAndMap;
143
+ }()
144
+ }, {
145
+ key: "writeTypes",
146
+ value: function () {
147
+ var _writeTypes = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(destination, options) {
148
+ var file, typesContent, files;
149
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
150
+ while (1) {
151
+ switch (_context3.prev = _context3.next) {
114
152
  case 0:
115
153
  file = _spruceSkillUtils.diskUtil.resolvePath(destination, 'stores.types.ts');
116
154
  typesContent = this.templates.storeTypes(options);
117
155
  files = this.writeFileIfChangedMixinResults(file, typesContent, 'The type merging for so the StoreFactory properly types you stores.');
118
- _context2.next = 5;
156
+ _context3.next = 5;
119
157
  return this.lint(file);
120
158
 
121
159
  case 5:
122
- return _context2.abrupt("return", files);
160
+ return _context3.abrupt("return", files);
123
161
 
124
162
  case 6:
125
163
  case "end":
126
- return _context2.stop();
164
+ return _context3.stop();
127
165
  }
128
166
  }
129
- }, _callee2, this);
167
+ }, _callee3, this);
130
168
  }));
131
169
 
132
- function writeTypes(_x3, _x4) {
170
+ function writeTypes(_x5, _x6) {
133
171
  return _writeTypes.apply(this, arguments);
134
172
  }
135
173
 
136
174
  return writeTypes;
137
175
  }()
176
+ }, {
177
+ key: "writeMap",
178
+ value: function () {
179
+ var _writeMap = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(destination, options) {
180
+ var file, mapContent, files;
181
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
182
+ while (1) {
183
+ switch (_context4.prev = _context4.next) {
184
+ case 0:
185
+ file = _spruceSkillUtils.diskUtil.resolvePath(destination, 'stores.ts');
186
+ mapContent = this.templates.stores(options);
187
+ files = this.writeFileIfChangedMixinResults(file, mapContent, 'A reference to all your data stores for easy inclusion.');
188
+ _context4.next = 5;
189
+ return this.lint(file);
190
+
191
+ case 5:
192
+ return _context4.abrupt("return", files);
193
+
194
+ case 6:
195
+ case "end":
196
+ return _context4.stop();
197
+ }
198
+ }
199
+ }, _callee4, this);
200
+ }));
201
+
202
+ function writeMap(_x7, _x8) {
203
+ return _writeMap.apply(this, arguments);
204
+ }
205
+
206
+ return writeMap;
207
+ }()
138
208
  }]);
139
209
  return StoreWriter;
140
210
  }(_AbstractWriter2["default"]);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/features/store/writers/StoreWriter.ts"],"names":["StoreWriter","destination","options","namePascalPlural","files","filename","fileDest","diskUtil","resolvePath","doesFileExist","SpruceError","code","contents","templates","store","writeFile","lint","push","action","name","path","cwd","resolveHashSprucePath","pluginContents","storePlugin","results","writeFileIfChangedMixinResults","file","typesContent","storeTypes","AbstractWriter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AAEA;;;;;;IAEqBA,W;;;;;;;;;;;;;sGACpB,iBAAwBC,WAAxB,EAA6CC,OAA7C;AAAA;AAAA;AAAA;AAAA;AAAA;AACSC,gBAAAA,gBADT,GAC8BD,OAD9B,CACSC,gBADT;AAGOC,gB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KAAKf,SAAL,CAAegB,UAAf,CAA0B3B,OAA1B,CANtB;AAQOE,gBAAAA,KARP,GAQe,KAAKsB,8BAAL,CACbC,IADa,EAEbC,YAFa,EAGb,qEAHa,CARf;AAAA;AAAA,uBAcO,KAAKZ,IAAL,CAAUW,IAAV,CAdP;;AAAA;AAAA,kDAgBQvB,KAhBR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EApDwC0B,2B","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport {\n\tStoreTemplateItem,\n\tStoreTemplateOptions,\n} from '@sprucelabs/spruce-templates'\nimport SpruceError from '../../../errors/SpruceError'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nexport default class StoreWriter extends AbstractWriter {\n\tpublic async writeStore(destination: string, options: StoreTemplateOptions) {\n\t\tconst { namePascalPlural } = options\n\n\t\tconst files: GeneratedFile[] = []\n\n\t\tconst filename = `${namePascalPlural}.store.ts`\n\n\t\tconst fileDest = diskUtil.resolvePath(\n\t\t\tdestination,\n\t\t\t'src',\n\t\t\t'stores',\n\t\t\tfilename\n\t\t)\n\n\t\tif (diskUtil.doesFileExist(fileDest)) {\n\t\t\tthrow new SpruceError({ code: 'STORE_EXISTS' })\n\t\t}\n\n\t\tconst contents = this.templates.store(options)\n\n\t\tdiskUtil.writeFile(fileDest, contents)\n\n\t\tawait this.lint(fileDest)\n\n\t\tfiles.push({\n\t\t\taction: 'generated',\n\t\t\tname: filename,\n\t\t\tpath: fileDest,\n\t\t})\n\n\t\treturn files\n\t}\n\n\tpublic writePlugin(cwd: string) {\n\t\tconst destination = diskUtil.resolveHashSprucePath(\n\t\t\tcwd,\n\t\t\t'features',\n\t\t\t'store.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.storePlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Loads all your data stores and connects you to any databases you have configured.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic async writeTypes(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst file = diskUtil.resolvePath(destination, 'stores.types.ts')\n\n\t\tconst typesContent = this.templates.storeTypes(options)\n\n\t\tconst files = this.writeFileIfChangedMixinResults(\n\t\t\tfile,\n\t\t\ttypesContent,\n\t\t\t'The type merging for so the StoreFactory properly types you stores.'\n\t\t)\n\n\t\tawait this.lint(file)\n\n\t\treturn files\n\t}\n}\n"],"file":"StoreWriter.js"}
1
+ {"version":3,"sources":["../../../../src/features/store/writers/StoreWriter.ts"],"names":["StoreWriter","destination","options","namePascalPlural","files","filename","fileDest","diskUtil","resolvePath","doesFileExist","SpruceError","code","contents","templates","store","writeFile","lint","push","action","name","path","cwd","resolveHashSprucePath","pluginContents","storePlugin","results","writeFileIfChangedMixinResults","Promise","all","writeTypes","writeMap","types","map","file","typesContent","storeTypes","mapContent","stores","AbstractWriter"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AAKA;;AAEA;;;;;;IAEqBA,W;;;;;;;;;;;;;sGACpB,iBAAwBC,WAAxB,EAA6CC,OAA7C;AAAA;AAAA;AAAA;AAAA;AAAA;AACSC,gBAAAA,gBADT,GAC8BD,OAD9B,CACSC,gBADT;AAGOC,gBAAAA,KAHP,GAGgC,EAHhC;AAKOC,gBAAAA,QALP,aAKqBF,gBALrB;AAOOG,gBAAAA,QAPP,GAOkBC,2BAASC,WAAT,CAChBP,WADgB,EAEhB,KAFgB,EAGhB,QAHgB,EAIhBI,QAJgB,CAPlB;;AAAA,qBAcKE,2BAASE,aAAT,CAAuBH,QAAvB,CAdL;AAAA;AAAA;AAAA;;AAAA,sBAeQ,IAAII,uBAAJ,CAAgB;AAAEC,kBAAAA,IAAI,EAAE;AAAR,iBAAhB,CAfR;;AAAA;AAkBOC,gBAAAA,QAlBP,GAkBkB,KAAKC,SAAL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C,gBAAAA,YANP,GAMsB,KAAKrB,SAAL,CAAesB,UAAf,CAA0BjC,OAA1B,CANtB;AAQOE,gBAAAA,KARP,GAQe,KAAKsB,8BAAL,CACbO,IADa,EAEbC,YAFa,EAGb,qEAHa,CARf;AAAA;AAAA,uBAcO,KAAKlB,IAAL,CAAUiB,IAAV,CAdP;;AAAA;AAAA,kDAgBQ7B,KAhBR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;;oGAmBA,kBACCH,WADD,EAECC,OAFD;AAAA;AAAA;AAAA;AAAA;AAAA;AAIO+B,gBAAAA,IAJP,GAIc1B,2BAASC,WAAT,CAAqBP,WAArB,EAAkC,WAAlC,CAJd;AAKOmC,gBAAAA,UALP,GAKoB,KAAKvB,SAAL,CAAewB,MAAf,CAAsBnC,OAAtB,CALpB;AAOOE,gBAAAA,KAPP,GAOe,KAAKsB,8BAAL,CACbO,IADa,EAEbG,UAFa,EAGb,yDAHa,CAPf;AAAA;AAAA,uBAaO,KAAKpB,IAAL,CAAUiB,IAAV,CAbP;;AAAA;AAAA,kDAeQ7B,KAfR;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;EAnFwCkC,2B","sourcesContent":["import { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport {\n\tStoreTemplateItem,\n\tStoreTemplateOptions,\n} from '@sprucelabs/spruce-templates'\nimport SpruceError from '../../../errors/SpruceError'\nimport { GeneratedFile } from '../../../types/cli.types'\nimport AbstractWriter from '../../../writers/AbstractWriter'\n\nexport default class StoreWriter extends AbstractWriter {\n\tpublic async writeStore(destination: string, options: StoreTemplateOptions) {\n\t\tconst { namePascalPlural } = options\n\n\t\tconst files: GeneratedFile[] = []\n\n\t\tconst filename = `${namePascalPlural}.store.ts`\n\n\t\tconst fileDest = diskUtil.resolvePath(\n\t\t\tdestination,\n\t\t\t'src',\n\t\t\t'stores',\n\t\t\tfilename\n\t\t)\n\n\t\tif (diskUtil.doesFileExist(fileDest)) {\n\t\t\tthrow new SpruceError({ code: 'STORE_EXISTS' })\n\t\t}\n\n\t\tconst contents = this.templates.store(options)\n\n\t\tdiskUtil.writeFile(fileDest, contents)\n\n\t\tawait this.lint(fileDest)\n\n\t\tfiles.push({\n\t\t\taction: 'generated',\n\t\t\tname: filename,\n\t\t\tpath: fileDest,\n\t\t})\n\n\t\treturn files\n\t}\n\n\tpublic writePlugin(cwd: string) {\n\t\tconst destination = diskUtil.resolveHashSprucePath(\n\t\t\tcwd,\n\t\t\t'features',\n\t\t\t'store.plugin.ts'\n\t\t)\n\n\t\tconst pluginContents = this.templates.storePlugin()\n\n\t\tconst results = this.writeFileIfChangedMixinResults(\n\t\t\tdestination,\n\t\t\tpluginContents,\n\t\t\t'Loads all your data stores and connects you to any databases you have configured.'\n\t\t)\n\n\t\treturn results\n\t}\n\n\tpublic async writeTypesAndMap(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst [types, map] = await Promise.all([\n\t\t\tthis.writeTypes(destination, options),\n\t\t\tthis.writeMap(destination, options),\n\t\t])\n\n\t\treturn [...types, ...map]\n\t}\n\n\tpublic async writeTypes(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst file = diskUtil.resolvePath(destination, 'stores.types.ts')\n\n\t\tconst typesContent = this.templates.storeTypes(options)\n\n\t\tconst files = this.writeFileIfChangedMixinResults(\n\t\t\tfile,\n\t\t\ttypesContent,\n\t\t\t'The type merging for so the StoreFactory properly types you stores.'\n\t\t)\n\n\t\tawait this.lint(file)\n\n\t\treturn files\n\t}\n\n\tpublic async writeMap(\n\t\tdestination: string,\n\t\toptions: { stores: StoreTemplateItem[] }\n\t) {\n\t\tconst file = diskUtil.resolvePath(destination, 'stores.ts')\n\t\tconst mapContent = this.templates.stores(options)\n\n\t\tconst files = this.writeFileIfChangedMixinResults(\n\t\t\tfile,\n\t\t\tmapContent,\n\t\t\t'A reference to all your data stores for easy inclusion.'\n\t\t)\n\n\t\tawait this.lint(file)\n\n\t\treturn files\n\t}\n}\n"],"file":"StoreWriter.js"}
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "license": "MIT",
21
- "version": "14.28.4",
21
+ "version": "14.28.8",
22
22
  "bin": {
23
23
  "spruce": "./build/index.js"
24
24
  },
@@ -76,25 +76,25 @@
76
76
  "@babel/plugin-proposal-decorators": "^7.16.4",
77
77
  "@babel/runtime": "^7.16.3",
78
78
  "@jest/reporters": "^27.4.2",
79
- "@sprucelabs/error": "^5.0.313",
80
- "@sprucelabs/heartwood-view-controllers": "^51.6.23",
81
- "@sprucelabs/jest-json-reporter": "^6.0.262",
82
- "@sprucelabs/mercury-client": "^17.4.13",
83
- "@sprucelabs/mercury-event-emitter": "^17.4.13",
84
- "@sprucelabs/mercury-types": "^26.1.973",
85
- "@sprucelabs/schema": "^25.4.58",
86
- "@sprucelabs/spruce-core-schemas": "^22.6.236",
87
- "@sprucelabs/spruce-event-plugin": "^17.0.2",
88
- "@sprucelabs/spruce-event-utils": "^17.1.249",
89
- "@sprucelabs/spruce-skill-booter": "^17.0.2",
90
- "@sprucelabs/spruce-skill-utils": "^22.1.40",
91
- "@sprucelabs/spruce-templates": "^14.28.4",
79
+ "@sprucelabs/error": "^5.0.317",
80
+ "@sprucelabs/heartwood-view-controllers": "^51.6.51",
81
+ "@sprucelabs/jest-json-reporter": "^6.0.265",
82
+ "@sprucelabs/mercury-client": "^17.4.29",
83
+ "@sprucelabs/mercury-event-emitter": "^17.4.29",
84
+ "@sprucelabs/mercury-types": "^26.1.992",
85
+ "@sprucelabs/schema": "^25.4.67",
86
+ "@sprucelabs/spruce-core-schemas": "^22.6.250",
87
+ "@sprucelabs/spruce-event-plugin": "^17.0.4",
88
+ "@sprucelabs/spruce-event-utils": "^17.1.272",
89
+ "@sprucelabs/spruce-skill-booter": "^17.0.4",
90
+ "@sprucelabs/spruce-skill-utils": "^22.1.50",
91
+ "@sprucelabs/spruce-templates": "^14.28.8",
92
92
  "cfonts": "^2.10.0",
93
93
  "chalk": "^4.1.2",
94
94
  "chokidar": "^3.5.2",
95
95
  "cli-table3": "^0.6.0",
96
96
  "commander": "^7.2.0",
97
- "core-js": "^3.19.2",
97
+ "core-js": "^3.19.3",
98
98
  "emphasize": "^4.2.0",
99
99
  "fs-extra": "^10.0.0",
100
100
  "gifwrap": "SimenB/gifwrap#patch-1",
@@ -117,16 +117,16 @@
117
117
  "uuid": "^8.3.2"
118
118
  },
119
119
  "devDependencies": {
120
- "@sprucelabs/data-stores": "^7.1.46",
121
- "@sprucelabs/jest-sheets-reporter": "^1.2.267",
122
- "@sprucelabs/mercury-core-events": "^1.6.188",
123
- "@sprucelabs/resolve-path-aliases": "^1.0.235",
124
- "@sprucelabs/spruce-conversation-plugin": "^17.0.2",
125
- "@sprucelabs/spruce-deploy-plugin": "^17.0.2",
126
- "@sprucelabs/spruce-store-plugin": "^17.0.2",
127
- "@sprucelabs/spruce-test-fixtures": "^17.0.2",
128
- "@sprucelabs/test": "^7.7.245",
129
- "@sprucelabs/test-utils": "^3.0.296",
120
+ "@sprucelabs/data-stores": "^7.2.0",
121
+ "@sprucelabs/jest-sheets-reporter": "^1.2.268",
122
+ "@sprucelabs/mercury-core-events": "^1.6.215",
123
+ "@sprucelabs/resolve-path-aliases": "^1.0.236",
124
+ "@sprucelabs/spruce-conversation-plugin": "^17.0.4",
125
+ "@sprucelabs/spruce-deploy-plugin": "^17.0.4",
126
+ "@sprucelabs/spruce-store-plugin": "^17.0.4",
127
+ "@sprucelabs/spruce-test-fixtures": "^17.0.4",
128
+ "@sprucelabs/test": "^7.7.248",
129
+ "@sprucelabs/test-utils": "^3.0.301",
130
130
  "@types/blessed": "^0.1.19",
131
131
  "@types/eslint": "^8.2.1",
132
132
  "@types/fs-extra": "^9.0.13",
@@ -157,10 +157,10 @@
157
157
  "jest-circus": "^27.4.2",
158
158
  "jest-junit": "^13.0.0",
159
159
  "jest-reporters": "^0.0.2",
160
- "prettier": "^2.5.0",
160
+ "prettier": "^2.5.1",
161
161
  "ps-node": "^0.1.6",
162
162
  "rimraf": "^3.0.2",
163
- "ts-jest": "^27.0.7",
163
+ "ts-jest": "^27.1.0",
164
164
  "ts-node": "^10.4.0",
165
165
  "tsc-watch": "^4.5.0",
166
166
  "tsconfig-paths": "^3.12.0",
@@ -595,5 +595,5 @@
595
595
  "ora"
596
596
  ]
597
597
  },
598
- "gitHead": "378e6487a21c3bc526641b491e950e9f1e4f7eca"
598
+ "gitHead": "c6881eaf61ca60574a87b6cb8c15738f85ec4f96"
599
599
  }
@@ -7,7 +7,23 @@ export default class BootingWithBadFilesTest extends AbstractCliTest {
7
7
  @test()
8
8
  protected static async bootingWithAEmptySchemaThrowsErrorWithNameOfBadSchema() {
9
9
  await this.FeatureFixture().installCachedFeatures('schemas')
10
+ const bootResults = await this.breakSchemaAndBoot()
11
+ assert.isTruthy(bootResults.errors)
12
+ assert.doesInclude(bootResults.errors[0].message, 'location.schema.ts')
13
+ }
14
+
15
+ @test()
16
+ protected static async disablesSchemaCheckingWithFlag() {
17
+ await this.FeatureFixture().installCachedFeatures('schemas')
18
+ diskUtil.writeFile(
19
+ this.resolvePath('.env'),
20
+ 'SHOULD_VALIDATE_SCHEMAS_ON_BOOT=false'
21
+ )
22
+ const bootResults = await this.breakSchemaAndBoot()
23
+ assert.isFalsy(bootResults.errors)
24
+ }
10
25
 
26
+ private static async breakSchemaAndBoot() {
11
27
  const results = await this.Action('schema', 'sync').execute({})
12
28
 
13
29
  const match = testUtil.assertFileByNameInGeneratedFiles(
@@ -20,8 +36,7 @@ export default class BootingWithBadFilesTest extends AbstractCliTest {
20
36
  const bootResults = await this.Action('skill', 'boot').execute({
21
37
  local: true,
22
38
  })
23
- assert.isTruthy(bootResults.errors)
24
39
 
25
- assert.doesInclude(bootResults.errors[0].message, 'location.schema.ts')
40
+ return bootResults
26
41
  }
27
42
  }
@@ -79,7 +79,7 @@ export default class KeepingEventsInSyncTest extends AbstractEventTest {
79
79
 
80
80
  await this.Service('build').build()
81
81
 
82
- const health = await cli.checkHealth({ isRunningLocally: false })
82
+ const health = await cli.checkHealth({ shouldRunOnSourceFiles: false })
83
83
 
84
84
  assert.isTruthy(health.skill)
85
85
  assert.isFalsy(health.skill.errors)