@sprucelabs/spruce-cli 15.4.5 → 15.4.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.
- package/CHANGELOG.md +24 -0
- package/build/__tests__/behavioral/events/CreatingAListener.test.d.ts +4 -2
- package/build/__tests__/behavioral/events/CreatingAListener.test.js +126 -69
- package/build/__tests__/behavioral/events/CreatingAListener.test.js.map +1 -1
- package/build/features/event/actions/ListenAction.d.ts +1 -0
- package/build/features/event/actions/ListenAction.js +6 -3
- package/build/features/event/actions/ListenAction.js.map +1 -1
- package/build/features/schema/stores/SchemaStore.d.ts +0 -1
- package/build/features/schema/stores/SchemaStore.js +0 -1
- package/build/features/schema/stores/SchemaStore.js.map +1 -1
- package/build/interfaces/TerminalInterface.js +1 -1
- package/build/interfaces/TerminalInterface.js.map +1 -1
- package/package.json +29 -29
- package/src/__tests__/behavioral/events/CreatingAListener.test.ts +41 -24
- package/src/features/event/actions/ListenAction.ts +2 -2
- package/src/features/schema/stores/SchemaStore.ts +0 -2
- package/src/interfaces/TerminalInterface.ts +1 -1
- package/build/.spruce/schemas/spruce/v2020_07_22/profileImage.schema.d.ts +0 -1
- package/build/.spruce/schemas/spruce/v2020_07_22/profileImage.schema.js +0 -14
- package/build/.spruce/schemas/spruce/v2020_07_22/profileImage.schema.js.map +0 -1
- package/src/.spruce/schemas/spruce/v2020_07_22/profileImage.schema.ts +0 -1
|
@@ -4,7 +4,6 @@ import AbstractStore from '../../../stores/AbstractStore';
|
|
|
4
4
|
import { InternalUpdateHandler } from '../../../types/cli.types';
|
|
5
5
|
export declare const coreSchemas: {
|
|
6
6
|
personSchema: import("@sprucelabs/spruce-core-schemas").SpruceSchemas.Spruce.v2020_07_22.PersonSchema;
|
|
7
|
-
profileImageSchema: import("@sprucelabs/spruce-core-schemas").SpruceSchemas.Spruce.v2020_07_22.ProfileImageSchema;
|
|
8
7
|
skillSchema: import("@sprucelabs/spruce-core-schemas").SpruceSchemas.Spruce.v2020_07_22.SkillSchema;
|
|
9
8
|
skillCreatorSchema: import("@sprucelabs/spruce-core-schemas").SpruceSchemas.Spruce.v2020_07_22.SkillCreatorSchema;
|
|
10
9
|
locationSchema: import("@sprucelabs/spruce-core-schemas").SpruceSchemas.Spruce.v2020_07_22.LocationSchema;
|
|
@@ -55,7 +55,6 @@ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Re
|
|
|
55
55
|
|
|
56
56
|
var coreSchemas = {
|
|
57
57
|
personSchema: _spruceCoreSchemas.personSchema,
|
|
58
|
-
profileImageSchema: _spruceCoreSchemas.profileImageSchema,
|
|
59
58
|
skillSchema: _spruceCoreSchemas.skillSchema,
|
|
60
59
|
skillCreatorSchema: _spruceCoreSchemas.skillCreatorSchema,
|
|
61
60
|
locationSchema: _spruceCoreSchemas.locationSchema,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaStore.js","names":["coreSchemas","personSchema","profileImageSchema","skillSchema","skillCreatorSchema","locationSchema","organizationSchema","personOrganizationSchema","personLocationSchema","roleSchema","messageSchema","messageSourceSchema","messageTargetSchema","sendMessageSchema","fullMessageChoicesSchema","DEFAULT_LOCAL_SCHEMA_DIR","SchemaStore","options","localSchemaLookupDir","localSchemaDir","shouldFetchLocalSchemas","shouldFetchRemoteSchemas","shouldEnableVersioning","localNamespace","shouldFetchCoreSchemas","didUpdateHandler","moduleToImportFromWhenRemote","results","errors","schemasByNamespace","CORE_NAMESPACE","Object","values","map","schema","namespace","loadLocalSchemas","locals","schemas","forEach","local","push","emitDidFetchSchemasAndMixinResults","emitter","emit","remoteResults","eventResponseUtil","getAllResponsePayloadsAndErrors","SpruceError","payloads","length","payload","mixinSchemaOrThrowIfExists","idWithVersion","match","find","s","globbyLocalBuilders","matches","localLookupDir","localMatches","importer","Service","bulkImport","imported","c","version","resolveLocalVersion","prepareLocalSchema","err","code","file","originalError","diskUtil","resolvePath","cwd","undefined","versionUtil","extractVersion","constValue","friendlyMessage","generateVersion","dirValue","SchemaError","schemaId","id","localAddonsDir","coreAddons","fieldRegistrations","registration","isLocal","localErrors","Promise","pathUtil","join","importService","importDefault","path","all","localAddons","allFields","filter","addon","fields","AbstractStore"],"sources":["../../../../src/features/schema/stores/SchemaStore.ts"],"sourcesContent":["import pathUtil from 'path'\nimport {\n\tSchema,\n\tFieldRegistration,\n\tfieldRegistrations,\n\tnormalizeSchemaToIdWithVersion,\n\tSchemaError,\n} from '@sprucelabs/schema'\nimport {\n\tpersonSchema,\n\tprofileImageSchema,\n\tskillSchema,\n\tskillCreatorSchema,\n\tlocationSchema,\n\torganizationSchema,\n\tpersonOrganizationSchema,\n\tpersonLocationSchema,\n\troleSchema,\n\tmessageSchema,\n\tmessageSourceSchema,\n\tmessageTargetSchema,\n\tsendMessageSchema,\n\tfullMessageChoicesSchema,\n} from '@sprucelabs/spruce-core-schemas'\nimport { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { versionUtil } from '@sprucelabs/spruce-skill-utils'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { CORE_NAMESPACE } from '@sprucelabs/spruce-skill-utils'\nimport globby from 'globby'\nimport { isEqual, uniqBy } from 'lodash'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractStore from '../../../stores/AbstractStore'\nimport { InternalUpdateHandler } from '../../../types/cli.types'\n\nexport const coreSchemas = {\n\tpersonSchema,\n\tprofileImageSchema,\n\tskillSchema,\n\tskillCreatorSchema,\n\tlocationSchema,\n\torganizationSchema,\n\tpersonOrganizationSchema,\n\tpersonLocationSchema,\n\troleSchema,\n\tmessageSchema,\n\tmessageSourceSchema,\n\tmessageTargetSchema,\n\tsendMessageSchema,\n\tfullMessageChoicesSchema,\n}\n\ninterface AddonItem {\n\tpath: string\n\tregistration: FieldRegistration\n\tisLocal: boolean\n}\n\nexport interface SchemasByNamespace {\n\t[namespace: string]: Schema[]\n}\n\ninterface FetchSchemasResults {\n\tschemasByNamespace: SchemasByNamespace\n\terrors: SpruceError[]\n}\nexport interface FetchedField {\n\tpath?: string\n\tregistration: FieldRegistration\n\tisLocal: boolean\n}\n\ninterface FetchFieldsResults {\n\terrors: SpruceError[]\n\tfields: FetchedField[]\n}\n\nconst DEFAULT_LOCAL_SCHEMA_DIR = 'src/schemas'\n\nexport default class SchemaStore extends AbstractStore {\n\tpublic readonly name = 'schema'\n\n\tpublic async fetchSchemas(options: {\n\t\tlocalSchemaLookupDir?: string\n\t\tshouldFetchRemoteSchemas?: boolean\n\t\tshouldEnableVersioning?: boolean\n\t\tlocalNamespace: string\n\t\tshouldFetchCoreSchemas?: boolean\n\t\tmoduleToImportFromWhenRemote?: string\n\t\tshouldFetchLocalSchemas?: boolean\n\t\tdidUpdateHandler?: InternalUpdateHandler\n\t}): Promise<FetchSchemasResults> {\n\t\tconst {\n\t\t\tlocalSchemaLookupDir: localSchemaDir = DEFAULT_LOCAL_SCHEMA_DIR,\n\t\t\tshouldFetchLocalSchemas = true,\n\t\t\tshouldFetchRemoteSchemas = true,\n\t\t\tshouldEnableVersioning = true,\n\t\t\tlocalNamespace,\n\t\t\tshouldFetchCoreSchemas = true,\n\t\t\tdidUpdateHandler,\n\t\t\tmoduleToImportFromWhenRemote,\n\t\t} = options || {}\n\n\t\tconst results: FetchSchemasResults = {\n\t\t\terrors: [],\n\t\t\tschemasByNamespace: {},\n\t\t}\n\n\t\tif (shouldFetchCoreSchemas) {\n\t\t\tresults.schemasByNamespace[CORE_NAMESPACE] = Object.values(\n\t\t\t\tcoreSchemas\n\t\t\t).map((schema) => ({\n\t\t\t\t...schema,\n\t\t\t\tnamespace: CORE_NAMESPACE,\n\t\t\t}))\n\t\t}\n\n\t\tif (shouldFetchLocalSchemas) {\n\t\t\tconst locals = await this.loadLocalSchemas(\n\t\t\t\tlocalSchemaDir,\n\t\t\t\tlocalNamespace,\n\t\t\t\tshouldEnableVersioning,\n\t\t\t\tdidUpdateHandler\n\t\t\t)\n\n\t\t\tif (moduleToImportFromWhenRemote) {\n\t\t\t\tlocals.schemas.forEach((local) => {\n\t\t\t\t\tlocal.moduleToImportFromWhenRemote = moduleToImportFromWhenRemote\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tresults.schemasByNamespace[localNamespace] = locals.schemas\n\t\t\tresults.errors.push(...locals.errors)\n\t\t}\n\n\t\tif (shouldFetchRemoteSchemas) {\n\t\t\tawait this.emitDidFetchSchemasAndMixinResults(localNamespace, results)\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async emitDidFetchSchemasAndMixinResults(\n\t\tlocalNamespace: string,\n\t\tresults: FetchSchemasResults\n\t) {\n\t\tconst schemas: Schema[] = []\n\t\tfor (const namespace in results.schemasByNamespace) {\n\t\t\tschemas.push(...results.schemasByNamespace[namespace])\n\t\t}\n\n\t\tconst remoteResults = await this.emitter.emit('schema.did-fetch-schemas', {\n\t\t\tschemas,\n\t\t})\n\n\t\tconst { payloads, errors } =\n\t\t\teventResponseUtil.getAllResponsePayloadsAndErrors(\n\t\t\t\tremoteResults,\n\t\t\t\tSpruceError\n\t\t\t)\n\n\t\tif (errors && errors.length > 0) {\n\t\t\tresults.errors.push(...errors)\n\t\t} else {\n\t\t\tpayloads.forEach((payload) => {\n\t\t\t\tpayload?.schemas?.forEach((schema: Schema) => {\n\t\t\t\t\tthis.mixinSchemaOrThrowIfExists(schema, localNamespace, results)\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate mixinSchemaOrThrowIfExists(\n\t\tschema: Schema,\n\t\tlocalNamespace: string,\n\t\tresults: FetchSchemasResults\n\t) {\n\t\tconst namespace = schema.namespace ?? localNamespace\n\n\t\tif (!results.schemasByNamespace[namespace]) {\n\t\t\tresults.schemasByNamespace[namespace] = []\n\t\t}\n\n\t\tconst idWithVersion = normalizeSchemaToIdWithVersion(schema)\n\t\tconst match = results.schemasByNamespace[namespace].find((s) =>\n\t\t\tisEqual(normalizeSchemaToIdWithVersion(s), idWithVersion)\n\t\t)\n\n\t\tif (!match) {\n\t\t\tresults.schemasByNamespace[namespace].push(schema)\n\t\t}\n\t}\n\n\tpublic async hasLocalSchemas() {\n\t\tconst matches = await this.globbyLocalBuilders(DEFAULT_LOCAL_SCHEMA_DIR)\n\t\treturn matches.length > 0\n\t}\n\n\tprivate async loadLocalSchemas(\n\t\tlocalLookupDir: string,\n\t\tlocalNamespace: string,\n\t\tshouldEnableVersioning?: boolean,\n\t\tdidUpdateHandler?: InternalUpdateHandler\n\t) {\n\t\tconst localMatches = await this.globbyLocalBuilders(localLookupDir)\n\n\t\tconst errors: SpruceError[] = []\n\t\tconst schemas: Schema[] = []\n\n\t\tdidUpdateHandler?.(\n\t\t\t`Starting import of ${localMatches.length} schema builders...`\n\t\t)\n\n\t\ttry {\n\t\t\tconst importer = this.Service('import')\n\t\t\tconst imported = await importer.bulkImport(localMatches)\n\n\t\t\tfor (let c = 0; c < localMatches.length; c++) {\n\t\t\t\ttry {\n\t\t\t\t\tconst local = localMatches[c]\n\t\t\t\t\tlet schema = imported[c]\n\n\t\t\t\t\tlet version: undefined | string = this.resolveLocalVersion(\n\t\t\t\t\t\tshouldEnableVersioning,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t\terrors\n\t\t\t\t\t)\n\t\t\t\t\tif (version || shouldEnableVersioning === false) {\n\t\t\t\t\t\tschema = this.prepareLocalSchema(\n\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\tlocalNamespace,\n\t\t\t\t\t\t\tversion,\n\t\t\t\t\t\t\tdidUpdateHandler\n\t\t\t\t\t\t)\n\t\t\t\t\t\tschemas.push(schema)\n\t\t\t\t\t}\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\tcode: 'SCHEMA_FAILED_TO_IMPORT',\n\t\t\t\t\t\t\tfile: err?.options?.file ?? '**UNKNOWN**',\n\t\t\t\t\t\t\toriginalError: err?.originalError ?? err,\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} catch (err: any) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'SCHEMA_FAILED_TO_IMPORT',\n\t\t\t\tfile: err?.options?.file ?? '**UNKNOWN**',\n\t\t\t\toriginalError: err?.originalError ?? err,\n\t\t\t})\n\t\t}\n\n\t\treturn {\n\t\t\tschemas,\n\t\t\terrors,\n\t\t}\n\t}\n\n\tprivate async globbyLocalBuilders(localLookupDir: string) {\n\t\treturn await globby(\n\t\t\tdiskUtil.resolvePath(this.cwd, localLookupDir, '**/*.builder.[t|j]s')\n\t\t)\n\t}\n\n\tprivate resolveLocalVersion(\n\t\tshouldEnableVersioning: boolean | undefined,\n\t\tlocal: string,\n\t\terrors: SpruceError[]\n\t) {\n\t\tlet version: undefined | string\n\n\t\ttry {\n\t\t\tversion =\n\t\t\t\tshouldEnableVersioning === false\n\t\t\t\t\t? undefined\n\t\t\t\t\t: versionUtil.extractVersion(this.cwd, local).constValue\n\t\t} catch (err) {\n\t\t\terrors.push(\n\t\t\t\tnew SpruceError({\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tcode: 'VERSION_MISSING',\n\t\t\t\t\tfriendlyMessage: `It looks like your schema's are not versioned. Make sure schemas are in a directory like src/schemas/${\n\t\t\t\t\t\tversionUtil.generateVersion().dirValue\n\t\t\t\t\t}/*.ts`,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t\treturn version\n\t}\n\n\tprivate prepareLocalSchema(\n\t\tschema: Schema,\n\t\tlocalNamespace: string,\n\t\tversion: string | undefined,\n\t\tdidUpdateHandler: InternalUpdateHandler | undefined\n\t) {\n\t\tlet errors: string[] = []\n\n\t\tif (schema.version) {\n\t\t\terrors.push('version_should_not_be_set')\n\t\t}\n\n\t\tif (schema.namespace) {\n\t\t\terrors.push('namespace_should_not_be_set')\n\t\t}\n\n\t\tschema.namespace = localNamespace\n\n\t\tif (errors.length > 0) {\n\t\t\tthrow new SchemaError({\n\t\t\t\tcode: 'INVALID_SCHEMA',\n\t\t\t\tschemaId: schema.id,\n\t\t\t\terrors,\n\t\t\t\tfriendlyMessage:\n\t\t\t\t\t'You should not set a namespace nor version in your schema builder.',\n\t\t\t})\n\t\t}\n\n\t\tschema.version = version\n\n\t\tdidUpdateHandler?.(`Imported ${schema.id} builder.`)\n\n\t\treturn schema\n\t}\n\n\tpublic async fetchFields(options?: {\n\t\tlocalAddonsDir?: string\n\t}): Promise<FetchFieldsResults> {\n\t\tconst { localAddonsDir } = options || {}\n\n\t\tconst coreAddons = fieldRegistrations.map((registration) => {\n\t\t\treturn {\n\t\t\t\tregistration,\n\t\t\t\tisLocal: false,\n\t\t\t}\n\t\t})\n\n\t\tconst localErrors: SpruceError[] = []\n\n\t\tconst localAddons = !localAddonsDir\n\t\t\t? []\n\t\t\t: await Promise.all(\n\t\t\t\t\t(\n\t\t\t\t\t\tawait globby([\n\t\t\t\t\t\t\tpathUtil.join(localAddonsDir, '/*Field.addon.[t|j]s'),\n\t\t\t\t\t\t])\n\t\t\t\t\t).map(async (file: string) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst importService = this.Service('import')\n\t\t\t\t\t\t\tconst registration =\n\t\t\t\t\t\t\t\tawait importService.importDefault<FieldRegistration>(file)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tpath: file,\n\t\t\t\t\t\t\t\tregistration,\n\t\t\t\t\t\t\t\tisLocal: true,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (err: any) {\n\t\t\t\t\t\t\tlocalErrors.push(\n\t\t\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\t\t\toriginalError: err,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t )\n\n\t\tconst allFields = uniqBy(\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,CAHY,IAKjB,mBALiB,CA7CnB;gBAAA,kCAqDQ;kBACNC,MAAM,EAAEH,SADF;kBAENxE,MAAM,EAAE+D;gBAFF,CArDR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;EAxPwCa,0B"}
|
|
1
|
+
{"version":3,"file":"SchemaStore.js","names":["coreSchemas","personSchema","skillSchema","skillCreatorSchema","locationSchema","organizationSchema","personOrganizationSchema","personLocationSchema","roleSchema","messageSchema","messageSourceSchema","messageTargetSchema","sendMessageSchema","fullMessageChoicesSchema","DEFAULT_LOCAL_SCHEMA_DIR","SchemaStore","options","localSchemaLookupDir","localSchemaDir","shouldFetchLocalSchemas","shouldFetchRemoteSchemas","shouldEnableVersioning","localNamespace","shouldFetchCoreSchemas","didUpdateHandler","moduleToImportFromWhenRemote","results","errors","schemasByNamespace","CORE_NAMESPACE","Object","values","map","schema","namespace","loadLocalSchemas","locals","schemas","forEach","local","push","emitDidFetchSchemasAndMixinResults","emitter","emit","remoteResults","eventResponseUtil","getAllResponsePayloadsAndErrors","SpruceError","payloads","length","payload","mixinSchemaOrThrowIfExists","idWithVersion","match","find","s","globbyLocalBuilders","matches","localLookupDir","localMatches","importer","Service","bulkImport","imported","c","version","resolveLocalVersion","prepareLocalSchema","err","code","file","originalError","diskUtil","resolvePath","cwd","undefined","versionUtil","extractVersion","constValue","friendlyMessage","generateVersion","dirValue","SchemaError","schemaId","id","localAddonsDir","coreAddons","fieldRegistrations","registration","isLocal","localErrors","Promise","pathUtil","join","importService","importDefault","path","all","localAddons","allFields","filter","addon","fields","AbstractStore"],"sources":["../../../../src/features/schema/stores/SchemaStore.ts"],"sourcesContent":["import pathUtil from 'path'\nimport {\n\tSchema,\n\tFieldRegistration,\n\tfieldRegistrations,\n\tnormalizeSchemaToIdWithVersion,\n\tSchemaError,\n} from '@sprucelabs/schema'\nimport {\n\tpersonSchema,\n\tskillSchema,\n\tskillCreatorSchema,\n\tlocationSchema,\n\torganizationSchema,\n\tpersonOrganizationSchema,\n\tpersonLocationSchema,\n\troleSchema,\n\tmessageSchema,\n\tmessageSourceSchema,\n\tmessageTargetSchema,\n\tsendMessageSchema,\n\tfullMessageChoicesSchema,\n} from '@sprucelabs/spruce-core-schemas'\nimport { eventResponseUtil } from '@sprucelabs/spruce-event-utils'\nimport { versionUtil } from '@sprucelabs/spruce-skill-utils'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport { CORE_NAMESPACE } from '@sprucelabs/spruce-skill-utils'\nimport globby from 'globby'\nimport { isEqual, uniqBy } from 'lodash'\nimport SpruceError from '../../../errors/SpruceError'\nimport AbstractStore from '../../../stores/AbstractStore'\nimport { InternalUpdateHandler } from '../../../types/cli.types'\n\nexport const coreSchemas = {\n\tpersonSchema,\n\tskillSchema,\n\tskillCreatorSchema,\n\tlocationSchema,\n\torganizationSchema,\n\tpersonOrganizationSchema,\n\tpersonLocationSchema,\n\troleSchema,\n\tmessageSchema,\n\tmessageSourceSchema,\n\tmessageTargetSchema,\n\tsendMessageSchema,\n\tfullMessageChoicesSchema,\n}\n\ninterface AddonItem {\n\tpath: string\n\tregistration: FieldRegistration\n\tisLocal: boolean\n}\n\nexport interface SchemasByNamespace {\n\t[namespace: string]: Schema[]\n}\n\ninterface FetchSchemasResults {\n\tschemasByNamespace: SchemasByNamespace\n\terrors: SpruceError[]\n}\nexport interface FetchedField {\n\tpath?: string\n\tregistration: FieldRegistration\n\tisLocal: boolean\n}\n\ninterface FetchFieldsResults {\n\terrors: SpruceError[]\n\tfields: FetchedField[]\n}\n\nconst DEFAULT_LOCAL_SCHEMA_DIR = 'src/schemas'\n\nexport default class SchemaStore extends AbstractStore {\n\tpublic readonly name = 'schema'\n\n\tpublic async fetchSchemas(options: {\n\t\tlocalSchemaLookupDir?: string\n\t\tshouldFetchRemoteSchemas?: boolean\n\t\tshouldEnableVersioning?: boolean\n\t\tlocalNamespace: string\n\t\tshouldFetchCoreSchemas?: boolean\n\t\tmoduleToImportFromWhenRemote?: string\n\t\tshouldFetchLocalSchemas?: boolean\n\t\tdidUpdateHandler?: InternalUpdateHandler\n\t}): Promise<FetchSchemasResults> {\n\t\tconst {\n\t\t\tlocalSchemaLookupDir: localSchemaDir = DEFAULT_LOCAL_SCHEMA_DIR,\n\t\t\tshouldFetchLocalSchemas = true,\n\t\t\tshouldFetchRemoteSchemas = true,\n\t\t\tshouldEnableVersioning = true,\n\t\t\tlocalNamespace,\n\t\t\tshouldFetchCoreSchemas = true,\n\t\t\tdidUpdateHandler,\n\t\t\tmoduleToImportFromWhenRemote,\n\t\t} = options || {}\n\n\t\tconst results: FetchSchemasResults = {\n\t\t\terrors: [],\n\t\t\tschemasByNamespace: {},\n\t\t}\n\n\t\tif (shouldFetchCoreSchemas) {\n\t\t\tresults.schemasByNamespace[CORE_NAMESPACE] = Object.values(\n\t\t\t\tcoreSchemas\n\t\t\t).map((schema) => ({\n\t\t\t\t...schema,\n\t\t\t\tnamespace: CORE_NAMESPACE,\n\t\t\t}))\n\t\t}\n\n\t\tif (shouldFetchLocalSchemas) {\n\t\t\tconst locals = await this.loadLocalSchemas(\n\t\t\t\tlocalSchemaDir,\n\t\t\t\tlocalNamespace,\n\t\t\t\tshouldEnableVersioning,\n\t\t\t\tdidUpdateHandler\n\t\t\t)\n\n\t\t\tif (moduleToImportFromWhenRemote) {\n\t\t\t\tlocals.schemas.forEach((local) => {\n\t\t\t\t\tlocal.moduleToImportFromWhenRemote = moduleToImportFromWhenRemote\n\t\t\t\t})\n\t\t\t}\n\n\t\t\tresults.schemasByNamespace[localNamespace] = locals.schemas\n\t\t\tresults.errors.push(...locals.errors)\n\t\t}\n\n\t\tif (shouldFetchRemoteSchemas) {\n\t\t\tawait this.emitDidFetchSchemasAndMixinResults(localNamespace, results)\n\t\t}\n\n\t\treturn results\n\t}\n\n\tprivate async emitDidFetchSchemasAndMixinResults(\n\t\tlocalNamespace: string,\n\t\tresults: FetchSchemasResults\n\t) {\n\t\tconst schemas: Schema[] = []\n\t\tfor (const namespace in results.schemasByNamespace) {\n\t\t\tschemas.push(...results.schemasByNamespace[namespace])\n\t\t}\n\n\t\tconst remoteResults = await this.emitter.emit('schema.did-fetch-schemas', {\n\t\t\tschemas,\n\t\t})\n\n\t\tconst { payloads, errors } =\n\t\t\teventResponseUtil.getAllResponsePayloadsAndErrors(\n\t\t\t\tremoteResults,\n\t\t\t\tSpruceError\n\t\t\t)\n\n\t\tif (errors && errors.length > 0) {\n\t\t\tresults.errors.push(...errors)\n\t\t} else {\n\t\t\tpayloads.forEach((payload) => {\n\t\t\t\tpayload?.schemas?.forEach((schema: Schema) => {\n\t\t\t\t\tthis.mixinSchemaOrThrowIfExists(schema, localNamespace, results)\n\t\t\t\t})\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate mixinSchemaOrThrowIfExists(\n\t\tschema: Schema,\n\t\tlocalNamespace: string,\n\t\tresults: FetchSchemasResults\n\t) {\n\t\tconst namespace = schema.namespace ?? localNamespace\n\n\t\tif (!results.schemasByNamespace[namespace]) {\n\t\t\tresults.schemasByNamespace[namespace] = []\n\t\t}\n\n\t\tconst idWithVersion = normalizeSchemaToIdWithVersion(schema)\n\t\tconst match = results.schemasByNamespace[namespace].find((s) =>\n\t\t\tisEqual(normalizeSchemaToIdWithVersion(s), idWithVersion)\n\t\t)\n\n\t\tif (!match) {\n\t\t\tresults.schemasByNamespace[namespace].push(schema)\n\t\t}\n\t}\n\n\tpublic async hasLocalSchemas() {\n\t\tconst matches = await this.globbyLocalBuilders(DEFAULT_LOCAL_SCHEMA_DIR)\n\t\treturn matches.length > 0\n\t}\n\n\tprivate async loadLocalSchemas(\n\t\tlocalLookupDir: string,\n\t\tlocalNamespace: string,\n\t\tshouldEnableVersioning?: boolean,\n\t\tdidUpdateHandler?: InternalUpdateHandler\n\t) {\n\t\tconst localMatches = await this.globbyLocalBuilders(localLookupDir)\n\n\t\tconst errors: SpruceError[] = []\n\t\tconst schemas: Schema[] = []\n\n\t\tdidUpdateHandler?.(\n\t\t\t`Starting import of ${localMatches.length} schema builders...`\n\t\t)\n\n\t\ttry {\n\t\t\tconst importer = this.Service('import')\n\t\t\tconst imported = await importer.bulkImport(localMatches)\n\n\t\t\tfor (let c = 0; c < localMatches.length; c++) {\n\t\t\t\ttry {\n\t\t\t\t\tconst local = localMatches[c]\n\t\t\t\t\tlet schema = imported[c]\n\n\t\t\t\t\tlet version: undefined | string = this.resolveLocalVersion(\n\t\t\t\t\t\tshouldEnableVersioning,\n\t\t\t\t\t\tlocal,\n\t\t\t\t\t\terrors\n\t\t\t\t\t)\n\t\t\t\t\tif (version || shouldEnableVersioning === false) {\n\t\t\t\t\t\tschema = this.prepareLocalSchema(\n\t\t\t\t\t\t\tschema,\n\t\t\t\t\t\t\tlocalNamespace,\n\t\t\t\t\t\t\tversion,\n\t\t\t\t\t\t\tdidUpdateHandler\n\t\t\t\t\t\t)\n\t\t\t\t\t\tschemas.push(schema)\n\t\t\t\t\t}\n\t\t\t\t} catch (err: any) {\n\t\t\t\t\terrors.push(\n\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\tcode: 'SCHEMA_FAILED_TO_IMPORT',\n\t\t\t\t\t\t\tfile: err?.options?.file ?? '**UNKNOWN**',\n\t\t\t\t\t\t\toriginalError: err?.originalError ?? err,\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} catch (err: any) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'SCHEMA_FAILED_TO_IMPORT',\n\t\t\t\tfile: err?.options?.file ?? '**UNKNOWN**',\n\t\t\t\toriginalError: err?.originalError ?? err,\n\t\t\t})\n\t\t}\n\n\t\treturn {\n\t\t\tschemas,\n\t\t\terrors,\n\t\t}\n\t}\n\n\tprivate async globbyLocalBuilders(localLookupDir: string) {\n\t\treturn await globby(\n\t\t\tdiskUtil.resolvePath(this.cwd, localLookupDir, '**/*.builder.[t|j]s')\n\t\t)\n\t}\n\n\tprivate resolveLocalVersion(\n\t\tshouldEnableVersioning: boolean | undefined,\n\t\tlocal: string,\n\t\terrors: SpruceError[]\n\t) {\n\t\tlet version: undefined | string\n\n\t\ttry {\n\t\t\tversion =\n\t\t\t\tshouldEnableVersioning === false\n\t\t\t\t\t? undefined\n\t\t\t\t\t: versionUtil.extractVersion(this.cwd, local).constValue\n\t\t} catch (err) {\n\t\t\terrors.push(\n\t\t\t\tnew SpruceError({\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\tcode: 'VERSION_MISSING',\n\t\t\t\t\tfriendlyMessage: `It looks like your schema's are not versioned. Make sure schemas are in a directory like src/schemas/${\n\t\t\t\t\t\tversionUtil.generateVersion().dirValue\n\t\t\t\t\t}/*.ts`,\n\t\t\t\t})\n\t\t\t)\n\t\t}\n\t\treturn version\n\t}\n\n\tprivate prepareLocalSchema(\n\t\tschema: Schema,\n\t\tlocalNamespace: string,\n\t\tversion: string | undefined,\n\t\tdidUpdateHandler: InternalUpdateHandler | undefined\n\t) {\n\t\tlet errors: string[] = []\n\n\t\tif (schema.version) {\n\t\t\terrors.push('version_should_not_be_set')\n\t\t}\n\n\t\tif (schema.namespace) {\n\t\t\terrors.push('namespace_should_not_be_set')\n\t\t}\n\n\t\tschema.namespace = localNamespace\n\n\t\tif (errors.length > 0) {\n\t\t\tthrow new SchemaError({\n\t\t\t\tcode: 'INVALID_SCHEMA',\n\t\t\t\tschemaId: schema.id,\n\t\t\t\terrors,\n\t\t\t\tfriendlyMessage:\n\t\t\t\t\t'You should not set a namespace nor version in your schema builder.',\n\t\t\t})\n\t\t}\n\n\t\tschema.version = version\n\n\t\tdidUpdateHandler?.(`Imported ${schema.id} builder.`)\n\n\t\treturn schema\n\t}\n\n\tpublic async fetchFields(options?: {\n\t\tlocalAddonsDir?: string\n\t}): Promise<FetchFieldsResults> {\n\t\tconst { localAddonsDir } = options || {}\n\n\t\tconst coreAddons = fieldRegistrations.map((registration) => {\n\t\t\treturn {\n\t\t\t\tregistration,\n\t\t\t\tisLocal: false,\n\t\t\t}\n\t\t})\n\n\t\tconst localErrors: SpruceError[] = []\n\n\t\tconst localAddons = !localAddonsDir\n\t\t\t? []\n\t\t\t: await Promise.all(\n\t\t\t\t\t(\n\t\t\t\t\t\tawait globby([\n\t\t\t\t\t\t\tpathUtil.join(localAddonsDir, '/*Field.addon.[t|j]s'),\n\t\t\t\t\t\t])\n\t\t\t\t\t).map(async (file: string) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst importService = this.Service('import')\n\t\t\t\t\t\t\tconst registration =\n\t\t\t\t\t\t\t\tawait importService.importDefault<FieldRegistration>(file)\n\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\tpath: file,\n\t\t\t\t\t\t\t\tregistration,\n\t\t\t\t\t\t\t\tisLocal: true,\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (err: any) {\n\t\t\t\t\t\t\tlocalErrors.push(\n\t\t\t\t\t\t\t\tnew SpruceError({\n\t\t\t\t\t\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\t\t\t\t\t\tfile,\n\t\t\t\t\t\t\t\t\toriginalError: err,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\treturn false\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t )\n\n\t\tconst allFields = uniqBy(\n\t\t\t[\n\t\t\t\t...coreAddons,\n\t\t\t\t...(localAddons.filter((addon) => !!addon) as AddonItem[]),\n\t\t\t],\n\t\t\t'registration.type'\n\t\t)\n\n\t\treturn {\n\t\t\tfields: allFields,\n\t\t\terrors: localErrors,\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAOA;;AAeA;;AACA;;AAGA;;AACA;;AACA;;AACA;;;;;;;;;;AAGO,IAAMA,WAAW,GAAG;EAC1BC,YAAY,EAAZA,+BAD0B;EAE1BC,WAAW,EAAXA,8BAF0B;EAG1BC,kBAAkB,E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,0FAqBU,kBAAOsC,IAAP;oBAAA;oBAAA;sBAAA;wBAAA;0BAAA;4BAAA;4BAEEwB,aAFF,GAEkB,MAAI,CAACjC,OAAL,CAAa,QAAb,CAFlB;4BAAA;4BAAA,OAIGiC,aAAa,CAACC,aAAd,CAA+CzB,IAA/C,CAJH;;0BAAA;4BAGEkB,YAHF;4BAAA,kCAMG;8BACNQ,IAAI,EAAE1B,IADA;8BAENkB,YAAY,EAAZA,YAFM;8BAGNC,OAAO,EAAE;4BAHH,CANH;;0BAAA;4BAAA;4BAAA;4BAYJC,WAAW,CAAClD,IAAZ,CACC,IAAIO,uBAAJ,CAAgB;8BACfsB,IAAI,EAAE,kBADS;8BAEfC,IAAI,EAAJA,IAFe;8BAGfC,aAAa;4BAHE,CAAhB,CADD;4BAZI,kCAmBG,KAnBH;;0BAAA;0BAAA;4BAAA;wBAAA;sBAAA;oBAAA;kBAAA,CArBV;;kBAAA;oBAAA;kBAAA;gBAAA;gBAAA;gBAAA,oBAgBkB0B,GAhBlB;;cAAA;gBAAA;;cAAA;gBAcOC,WAdP;gBA6COC,SA7CP,GA6CmB,kEAEbb,UAFa,uCAGZY,WAAW,CAACE,MAAZ,CAAmB,UAACC,KAAD;kBAAA,OAAW,CAAC,CAACA,KAAb;gBAAA,CAAnB,CAHY,IAKjB,mBALiB,CA7CnB;gBAAA,kCAqDQ;kBACNC,MAAM,EAAEH,SADF;kBAENxE,MAAM,EAAE+D;gBAFF,CArDR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;EAxPwCa,0B"}
|
|
@@ -596,7 +596,7 @@ var TerminalInterface = /*#__PURE__*/function () {
|
|
|
596
596
|
});
|
|
597
597
|
|
|
598
598
|
case 27:
|
|
599
|
-
_dirPath = _path["default"].join((_fieldDefinition$defa3 = (_fieldDefinition$defa4 = fieldDefinition.defaultValue) === null || _fieldDefinition$defa4 === void 0 ? void 0 : _fieldDefinition$defa4.
|
|
599
|
+
_dirPath = _path["default"].join((_fieldDefinition$defa3 = (_fieldDefinition$defa4 = fieldDefinition.defaultValue) === null || _fieldDefinition$defa4 === void 0 ? void 0 : _fieldDefinition$defa4.uri) !== null && _fieldDefinition$defa3 !== void 0 ? _fieldDefinition$defa3 : this.cwd, '/'); // Check if directory is empty.
|
|
600
600
|
|
|
601
601
|
_context6.next = 30;
|
|
602
602
|
return (0, _globby["default"])("".concat(_dirPath, "**/*"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TerminalInterface.js","names":["terminalImage","require","fieldCount","generateInquirerFieldName","filterEffectsForCFonts","effects","effect","GraphicsTextEffect","SpruceHeader","Reset","Bold","Dim","Italic","Underline","Inverse","Hidden","Strikethrough","Visible","indexOf","TerminalInterface","cwd","renderStackTraces","log","console","bind","Error","lines","forEach","line","renderLine","object","Green","renderDivider","Object","keys","key","chalk","bold","JSON","stringify","options","headline","dividerEffects","headlineEffects","Blue","bodyEffects","renderHeadline","renderLines","renderObject","bar","results","generatedFiles","files","filter","f","action","updatedFiles","skippedFiles","errors","packagesInstalled","renderHero","summaryLines","length","push","renderSection","featuresUtil","generateCommand","featureCode","actionCode","table","Table","head","colWidths","wordWrap","colAligns","sort","one","two","name","pkg","isDev","toString","file","description","namesUtil","toPascal","hints","err","renderError","totalTime","durationUtil","msToFriendly","message","isSpruce","fonts","say","font","align","space","colors","shouldStripVowels","process","stdout","columns","stripped","replace","gradient","Red","undefined","write","eraseBeforeRender","terminal","eraseLine","Yellow","stopLoading","loader","text","start","stop","question","inquirer","prompt","type","confirmResult","answer","label","bgGreenBright","black","clear","code","colored","emphasize","highlight","value","renderWarning","definition","isPromptActive","fieldDefinition","defaultValue","promptOptions","generatePromptLabel","field","FieldFactory","Field","transformer","toValueType","validate","id","fields","isArray","choices","map","choice","checked","_","includes","SpruceError","friendlyMessage","dirPath","path","join","root","onlyShowDir","fs","existsSync","lstatSync","isDirectory","cleanedPath","directory","extname","response","result","hint","italic","dim","stackLines","cleanStack","splice","stack","AbstractSpruceError","original","originalError","split","removeProgressBar","progressBar","percent","showPercent","eta","showEta","items","totalItems","inline","renderInline","update","image","Promise","resolve","requestCursorLocation","getCursorLocation","x","y","saveCursor","restoreCursor","moveTo","eraseDisplayBelow","_doesSupportColor","isTTy","isTTY"],"sources":["../../src/interfaces/TerminalInterface.ts"],"sourcesContent":["import path from 'path'\nimport AbstractSpruceError from '@sprucelabs/error'\nimport {\n\tFieldFactory,\n\tFieldDefinitionValueType,\n\tareSchemaValuesValid,\n} from '@sprucelabs/schema'\nimport { IField } from '@sprucelabs/schema'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\n// @ts-ignore\nimport fonts from 'cfonts'\nimport chalk from 'chalk'\n// @ts-ignore No definition available\nimport Table from 'cli-table3'\n// @ts-ignore No definition available\nimport emphasize from 'emphasize'\nimport fs from 'fs-extra'\nimport globby from 'globby'\nimport inquirer from 'inquirer'\nimport _ from 'lodash'\nimport { filter } from 'lodash'\nimport ora from 'ora'\nimport { terminal } from 'terminal-kit'\nimport { ProgressBarController } from 'terminal-kit/Terminal'\nimport { FieldDefinitions } from '#spruce/schemas/fields/fields.types'\nimport SpruceError from '../errors/SpruceError'\nimport featuresUtil from '../features/feature.utilities'\nimport { ExecutionResults, GraphicsInterface } from '../types/cli.types'\nimport {\n\tGraphicsTextEffect,\n\tImageDimensions,\n\tProgressBarOptions,\n\tProgressBarUpdateOptions,\n} from '../types/graphicsInterface.types'\nimport durationUtil from '../utilities/duration.utility'\nimport isCi from '../utilities/isCi'\nconst terminalImage = require('terminal-image')\n\nlet fieldCount = 0\nfunction generateInquirerFieldName() {\n\tfieldCount++\n\treturn `field-${fieldCount}`\n}\n\n/** Remove effects cfonts does not support */\nfunction filterEffectsForCFonts(effects: GraphicsTextEffect[]) {\n\treturn filter(\n\t\teffects,\n\t\t(effect) =>\n\t\t\t[\n\t\t\t\tGraphicsTextEffect.SpruceHeader,\n\t\t\t\tGraphicsTextEffect.Reset,\n\t\t\t\tGraphicsTextEffect.Bold,\n\t\t\t\tGraphicsTextEffect.Dim,\n\t\t\t\tGraphicsTextEffect.Italic,\n\t\t\t\tGraphicsTextEffect.Underline,\n\t\t\t\tGraphicsTextEffect.Inverse,\n\t\t\t\tGraphicsTextEffect.Hidden,\n\t\t\t\tGraphicsTextEffect.Strikethrough,\n\t\t\t\tGraphicsTextEffect.Visible,\n\t\t\t].indexOf(effect) === -1\n\t)\n}\n\ntype TerminalSpecificOptions = {\n\teraseBeforeRender?: boolean\n}\n\nexport default class TerminalInterface implements GraphicsInterface {\n\tpublic isPromptActive = false\n\tpublic cwd: string\n\tprivate renderStackTraces = false\n\tprivate static loader?: ora.Ora | null\n\tprivate progressBar: ProgressBarController | null = null\n\tprivate static _doesSupportColor = process?.stdout?.isTTY && !isCi()\n\tprivate log: (...args: any[]) => void\n\n\tpublic constructor(\n\t\tcwd: string,\n\t\trenderStackTraces = false,\n\t\tlog = console.log.bind(console)\n\t) {\n\t\tthis.cwd = cwd\n\t\tthis.renderStackTraces = renderStackTraces\n\t\tthis.log = log\n\t}\n\n\tpublic static doesSupportColor() {\n\t\treturn this._doesSupportColor\n\t}\n\n\tpublic static setDoesSupportColor(isTTy: boolean) {\n\t\tthis._doesSupportColor = isTTy\n\t}\n\n\tpublic async sendInput(): Promise<void> {\n\t\tthrow new Error('sendInput not supported on the TerminalInterface!')\n\t}\n\n\tpublic renderLines(lines: any[], effects?: GraphicsTextEffect[]) {\n\t\tlines.forEach((line) => {\n\t\t\tthis.renderLine(line, effects)\n\t\t})\n\t}\n\n\tpublic renderObject(\n\t\tobject: Record<string, any>,\n\t\teffects: GraphicsTextEffect[] = [GraphicsTextEffect.Green]\n\t) {\n\t\tthis.renderLine('')\n\t\tthis.renderDivider()\n\t\tthis.renderLine('')\n\t\tObject.keys(object).forEach((key) => {\n\t\t\tthis.renderLine(\n\t\t\t\t`${chalk.bold(key)}: ${\n\t\t\t\t\ttypeof object[key] === 'string'\n\t\t\t\t\t\t? object[key]\n\t\t\t\t\t\t: JSON.stringify(object[key])\n\t\t\t\t}`,\n\t\t\t\teffects\n\t\t\t)\n\t\t})\n\t\tthis.renderLine('')\n\t\tthis.renderDivider()\n\t\tthis.renderLine('')\n\t}\n\n\tpublic renderSection(options: {\n\t\theadline?: string\n\t\tlines?: string[]\n\t\tobject?: Record<string, any>\n\t\theadlineEffects?: GraphicsTextEffect[]\n\t\tbodyEffects?: GraphicsTextEffect[]\n\t\tdividerEffects?: GraphicsTextEffect[]\n\t}) {\n\t\tconst {\n\t\t\theadline,\n\t\t\tlines,\n\t\t\tobject,\n\t\t\tdividerEffects = [],\n\t\t\theadlineEffects = [GraphicsTextEffect.Blue, GraphicsTextEffect.Bold],\n\t\t\tbodyEffects = [GraphicsTextEffect.Green],\n\t\t} = options\n\n\t\tif (headline) {\n\t\t\tthis.renderHeadline(`${headline} 🌲🤖`, headlineEffects, dividerEffects)\n\t\t}\n\n\t\tif (lines) {\n\t\t\tthis.renderLines(lines, bodyEffects)\n\n\t\t\tthis.renderLine('')\n\t\t\tthis.renderDivider(dividerEffects)\n\t\t}\n\n\t\tif (object) {\n\t\t\tthis.renderObject(object, bodyEffects)\n\t\t}\n\n\t\tthis.renderLine('')\n\t}\n\n\tpublic renderDivider(effects?: GraphicsTextEffect[]) {\n\t\tconst bar = '=================================================='\n\t\tthis.renderLine(bar, effects)\n\t}\n\n\tpublic renderActionSummary(\n\t\tresults: ExecutionResults & { totalTime?: number }\n\t) {\n\t\tconst generatedFiles =\n\t\t\tresults.files?.filter((f) => f.action === 'generated') ?? []\n\t\tconst updatedFiles =\n\t\t\tresults.files?.filter((f) => f.action === 'updated') ?? []\n\t\tconst skippedFiles =\n\t\t\tresults.files?.filter((f) => f.action === 'skipped') ?? []\n\n\t\tconst errors = results.errors ?? []\n\t\tconst packagesInstalled = results.packagesInstalled ?? []\n\n\t\tthis.renderHero(`${results.headline}`)\n\n\t\tlet summaryLines: string[] = [\n\t\t\terrors.length > 0 ? `Errors: ${errors.length}` : null,\n\t\t\tgeneratedFiles.length > 0\n\t\t\t\t? `Generated files: ${generatedFiles.length}`\n\t\t\t\t: null,\n\t\t\tupdatedFiles.length > 0 ? `Updated files: ${updatedFiles.length}` : null,\n\t\t\tskippedFiles.length > 0 ? `Skipped files: ${skippedFiles.length}` : null,\n\t\t\tpackagesInstalled.length > 0\n\t\t\t\t? `NPM packages installed: ${packagesInstalled.length}`\n\t\t\t\t: null,\n\t\t\t...(results.summaryLines ?? []),\n\t\t].filter((line) => !!line) as string[]\n\n\t\tif (summaryLines.length === 0) {\n\t\t\tsummaryLines.push('Nothing to report!')\n\t\t}\n\t\tthis.renderSection({\n\t\t\theadline: `${featuresUtil.generateCommand(\n\t\t\t\tresults.featureCode,\n\t\t\t\tresults.actionCode\n\t\t\t)} summary`,\n\t\t\tlines: summaryLines,\n\t\t})\n\n\t\tif (packagesInstalled.length > 0) {\n\t\t\tconst table = new Table({\n\t\t\t\thead: ['Name', 'Dev'],\n\t\t\t\tcolWidths: [40, 5],\n\t\t\t\twordWrap: true,\n\t\t\t\tcolAligns: ['left', 'center'],\n\t\t\t})\n\t\t\tpackagesInstalled\n\t\t\t\t.sort((one, two) => (one.name > two.name ? 1 : -1))\n\t\t\t\t.forEach((pkg) => {\n\t\t\t\t\ttable.push([pkg.name, pkg.isDev ? '√' : ''])\n\t\t\t\t})\n\n\t\t\tthis.renderSection({\n\t\t\t\theadline: `NPM packages summary`,\n\t\t\t\tlines: [table.toString()],\n\t\t\t})\n\t\t}\n\n\t\tfor (let files of [generatedFiles, updatedFiles]) {\n\t\t\tif (files.length > 0) {\n\t\t\t\tconst table = new Table({\n\t\t\t\t\thead: ['File', 'Description'],\n\t\t\t\t\twordWrap: true,\n\t\t\t\t})\n\n\t\t\t\tfiles = files.sort()\n\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\ttable.push([file.name, file.description ?? ''])\n\t\t\t\t}\n\n\t\t\t\tthis.renderSection({\n\t\t\t\t\theadline: `${namesUtil.toPascal(files[0].action)} file summary`,\n\t\t\t\t\tlines: [table.toString()],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tif (results.hints) {\n\t\t\tthis.renderSection({\n\t\t\t\theadline: 'Read below 👇',\n\t\t\t\tlines: results.hints,\n\t\t\t})\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tthis.renderHeadline('Errors')\n\t\t\terrors.forEach((err) => this.renderError(err))\n\t\t}\n\n\t\tif (results.totalTime) {\n\t\t\tthis.renderLine(\n\t\t\t\t`Total time: ${durationUtil.msToFriendly(results.totalTime)}`\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic renderHeadline(\n\t\tmessage: string,\n\t\teffects: GraphicsTextEffect[] = [\n\t\t\tGraphicsTextEffect.Blue,\n\t\t\tGraphicsTextEffect.Bold,\n\t\t],\n\t\tdividerEffects: GraphicsTextEffect[] = []\n\t) {\n\t\tconst isSpruce = effects.indexOf(GraphicsTextEffect.SpruceHeader) > -1\n\n\t\tif (isSpruce) {\n\t\t\tfonts.say(message, {\n\t\t\t\tfont: GraphicsTextEffect.SpruceHeader,\n\t\t\t\talign: 'left',\n\t\t\t\tspace: false,\n\t\t\t\tcolors: filterEffectsForCFonts(effects),\n\t\t\t})\n\t\t} else {\n\t\t\tthis.renderDivider(dividerEffects)\n\t\t\tthis.renderLine(message, effects)\n\t\t\tthis.renderDivider(dividerEffects)\n\t\t\tthis.renderLine('')\n\t\t}\n\t}\n\n\tpublic renderHero(message: string, effects?: GraphicsTextEffect[]) {\n\t\tconst shouldStripVowels = process.stdout.columns < 80\n\n\t\tconst stripped = shouldStripVowels\n\t\t\t? message.replace(/[aeiou]/gi, '')\n\t\t\t: message\n\n\t\tfonts.say(stripped, {\n\t\t\t// Font: 'tiny',\n\t\t\talign: 'left',\n\t\t\tgradient: [GraphicsTextEffect.Red, GraphicsTextEffect.Blue],\n\t\t\tcolors: effects ? filterEffectsForCFonts(effects) : undefined,\n\t\t})\n\t}\n\n\tpublic renderHint(message: string) {\n\t\treturn this.renderLine(`👨🏫 ${message}`)\n\t}\n\n\tpublic renderLine(\n\t\tmessage: any,\n\t\teffects: GraphicsTextEffect[] = [],\n\t\toptions?: TerminalSpecificOptions\n\t) {\n\t\tlet write: any = chalk\n\t\teffects.forEach((effect) => {\n\t\t\twrite = write[effect]\n\t\t})\n\n\t\tif (options?.eraseBeforeRender) {\n\t\t\tterminal.eraseLine()\n\t\t}\n\n\t\tthis.log(effects.length > 0 ? write(message) : message)\n\t}\n\n\tpublic renderWarning(message: string) {\n\t\tthis.renderLine(`⚠️ ${message}`, [\n\t\t\tGraphicsTextEffect.Bold,\n\t\t\tGraphicsTextEffect.Yellow,\n\t\t])\n\t}\n\n\tpublic async startLoading(message?: string) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.stopLoading()\n\t\tTerminalInterface.loader = ora({\n\t\t\ttext: message,\n\t\t}).start()\n\t}\n\n\tpublic async stopLoading() {\n\t\tTerminalInterface.loader?.stop()\n\t\tTerminalInterface.loader = null\n\t}\n\n\tpublic async confirm(question: string): Promise<boolean> {\n\t\tconst confirmResult = await inquirer.prompt({\n\t\t\ttype: 'confirm',\n\t\t\tname: 'answer',\n\t\t\tmessage: question,\n\t\t})\n\n\t\treturn !!confirmResult.answer\n\t}\n\n\tpublic async waitForEnter(message?: string) {\n\t\tawait this.prompt({\n\t\t\ttype: 'text',\n\t\t\tlabel: `${message ? message + ' ' : ''}${chalk.bgGreenBright.black(\n\t\t\t\t'hit enter'\n\t\t\t)}`,\n\t\t})\n\t\tthis.renderLine('')\n\t\treturn\n\t}\n\n\tpublic clear() {\n\t\tvoid this.stopLoading()\n\t\tconsole.clear()\n\t}\n\n\tpublic renderCodeSample(code: string) {\n\t\ttry {\n\t\t\tconst colored = emphasize.highlight('js', code).value\n\t\t\tthis.renderLine(colored)\n\t\t} catch (err: any) {\n\t\t\tthis.renderWarning(err)\n\t\t}\n\t}\n\n\tpublic async prompt<T extends FieldDefinitions>(\n\t\tdefinition: T\n\t): Promise<FieldDefinitionValueType<T>> {\n\t\tthis.isPromptActive = true\n\t\tconst name = generateInquirerFieldName()\n\t\tconst fieldDefinition: FieldDefinitions = definition\n\t\tconst { defaultValue } = fieldDefinition\n\n\t\tconst promptOptions: Record<string, any> = {\n\t\t\tdefault: defaultValue,\n\t\t\tname,\n\t\t\tmessage: this.generatePromptLabel(fieldDefinition),\n\t\t}\n\n\t\tconst field = FieldFactory.Field('prompt', fieldDefinition)\n\n\t\tpromptOptions.transformer = (value: string) => {\n\t\t\treturn (field as IField<any>).toValueType(value)\n\t\t}\n\n\t\tpromptOptions.validate = (value: string) => {\n\t\t\treturn areSchemaValuesValid(\n\t\t\t\t{\n\t\t\t\t\tid: 'promptvalidateschema',\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tprompt: fieldDefinition,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ prompt: value }\n\t\t\t)\n\t\t\t// return field.validate(value, {}).length === 0\n\t\t}\n\n\t\tswitch (fieldDefinition.type) {\n\t\t\t// Map select options to prompt list choices\n\t\t\tcase 'boolean':\n\t\t\t\tpromptOptions.type = 'confirm'\n\t\t\t\tbreak\n\n\t\t\tcase 'select':\n\t\t\t\tpromptOptions.type = fieldDefinition.isArray ? 'checkbox' : 'list'\n\n\t\t\t\tpromptOptions.choices = fieldDefinition.options.choices.map(\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t(choice) => ({\n\t\t\t\t\t\tname: choice.label,\n\t\t\t\t\t\tvalue: choice.value,\n\t\t\t\t\t\tchecked: _.includes(fieldDefinition.defaultValue, choice.value),\n\t\t\t\t\t})\n\t\t\t\t)\n\n\t\t\t\tbreak\n\t\t\t// Directory select\n\t\t\t// File select\n\t\t\tcase 'directory': {\n\t\t\t\tif (fieldDefinition.isArray) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'NOT_IMPLEMENTED',\n\t\t\t\t\t\tfriendlyMessage:\n\t\t\t\t\t\t\t'isArray file field not supported, prompt needs to be rewritten with isArray support',\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tconst dirPath = path.join(\n\t\t\t\t\tfieldDefinition.defaultValue?.path ?? this.cwd,\n\t\t\t\t\t'/'\n\t\t\t\t)\n\n\t\t\t\tpromptOptions.type = 'file'\n\t\t\t\tpromptOptions.root = dirPath\n\t\t\t\tpromptOptions.onlyShowDir = true\n\n\t\t\t\t// Only let people select an actual file\n\t\t\t\tpromptOptions.validate = (value: string) => {\n\t\t\t\t\treturn fs.existsSync(value) && fs.lstatSync(value).isDirectory()\n\t\t\t\t}\n\t\t\t\t// Strip out cwd from the paths while selecting\n\t\t\t\tpromptOptions.transformer = (path: string) => {\n\t\t\t\t\tconst cleanedPath = path.replace(promptOptions.root, '')\n\t\t\t\t\treturn cleanedPath.length === 0 ? promptOptions.root : cleanedPath\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'file': {\n\t\t\t\tif (fieldDefinition.isArray) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'NOT_IMPLEMENTED',\n\t\t\t\t\t\tfriendlyMessage:\n\t\t\t\t\t\t\t'isArray file field not supported, prompt needs to be rewritten with isArray support',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst dirPath = path.join(\n\t\t\t\t\tfieldDefinition.defaultValue?.path ?? this.cwd,\n\t\t\t\t\t'/'\n\t\t\t\t)\n\n\t\t\t\t// Check if directory is empty.\n\t\t\t\tconst files = await globby(`${dirPath}**/*`)\n\n\t\t\t\tif (files.length === 0) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'DIRECTORY_EMPTY',\n\t\t\t\t\t\tdirectory: dirPath,\n\t\t\t\t\t\tfriendlyMessage: `I wanted to help you select a file, but none exist in ${dirPath}.`,\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tpromptOptions.type = 'file'\n\t\t\t\tpromptOptions.root = dirPath\n\n\t\t\t\t// Only let people select an actual file\n\t\t\t\tpromptOptions.validate = (value: string) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfs.existsSync(value) &&\n\t\t\t\t\t\t!fs.lstatSync(value).isDirectory() &&\n\t\t\t\t\t\tpath.extname(value) === '.ts'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// Strip out cwd from the paths while selecting\n\t\t\t\tpromptOptions.transformer = (path: string) => {\n\t\t\t\t\tconst cleanedPath = path.replace(promptOptions.root, '')\n\t\t\t\t\treturn cleanedPath.length === 0 ? promptOptions.root : cleanedPath\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// Defaults to input\n\t\t\tdefault:\n\t\t\t\tpromptOptions.type = 'input'\n\t\t}\n\n\t\tconst response = (await inquirer.prompt(promptOptions)) as any\n\n\t\tthis.isPromptActive = false\n\n\t\tconst result =\n\t\t\ttypeof response[name] !== 'undefined'\n\t\t\t\t? (field as IField<any>).toValueType(response[name])\n\t\t\t\t: response[name]\n\n\t\treturn result\n\t}\n\tprivate generatePromptLabel(fieldDefinition: FieldDefinitions): any {\n\t\tlet label = fieldDefinition.label\n\n\t\tif (fieldDefinition.hint) {\n\t\t\tlabel = `${label} ${chalk.italic.dim(`(${fieldDefinition.hint})`)}`\n\t\t}\n\n\t\tlabel = label + ': '\n\n\t\treturn label\n\t}\n\n\tpublic renderError(err: Error) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.stopLoading()\n\n\t\tconst message = err.message\n\t\t// Remove message from stack so the message is not doubled up\n\t\tconst stackLines = this.cleanStack(err)\n\t\tthis.renderSection({\n\t\t\theadline: message,\n\t\t\tlines: this.renderStackTraces ? stackLines.splice(0, 100) : undefined,\n\t\t\theadlineEffects: [GraphicsTextEffect.Bold, GraphicsTextEffect.Red],\n\t\t\tdividerEffects: [GraphicsTextEffect.Red],\n\t\t\tbodyEffects: [GraphicsTextEffect.Red],\n\t\t})\n\t}\n\n\tprivate cleanStack(err: Error) {\n\t\tconst message = err.message\n\t\tlet stack = err.stack ? err.stack.replace(message, '') : ''\n\n\t\tif (err instanceof AbstractSpruceError) {\n\t\t\tlet original = err.originalError\n\t\t\twhile (original) {\n\t\t\t\tstack = stack.replace('Error: ' + original.message, '')\n\t\t\t\toriginal = (original as AbstractSpruceError).originalError\n\t\t\t}\n\t\t}\n\n\t\tconst stackLines = stack.split('\\n')\n\n\t\treturn stackLines\n\t}\n\n\tpublic renderProgressBar(options: ProgressBarOptions): void {\n\t\tthis.removeProgressBar()\n\t\tthis.progressBar = terminal.progressBar({\n\t\t\t...options,\n\t\t\tpercent: options.showPercent,\n\t\t\teta: options.showEta,\n\t\t\titems: options.totalItems,\n\t\t\tinline: options.renderInline,\n\t\t})\n\t}\n\n\tpublic removeProgressBar() {\n\t\tif (this.progressBar) {\n\t\t\tthis.progressBar.stop()\n\t\t\tthis.progressBar = null\n\t\t}\n\t}\n\n\tpublic updateProgressBar(options: ProgressBarUpdateOptions): void {\n\t\tif (this.progressBar) {\n\t\t\tthis.progressBar.update({\n\t\t\t\t...options,\n\t\t\t\titems: options.totalItems,\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async renderImage(\n\t\tpath: string,\n\t\toptions?: ImageDimensions\n\t): Promise<void> {\n\t\tconst image = await terminalImage.file(path, options)\n\t\tthis.renderLine(image)\n\t}\n\n\tpublic async getCursorPosition(): Promise<{ x: number; y: number } | null> {\n\t\treturn new Promise((resolve) => {\n\t\t\tterminal.requestCursorLocation()\n\t\t\tterminal.getCursorLocation((err, x, y) => {\n\t\t\t\tresolve(err ? null : { x: x ?? 0, y: y ?? 0 })\n\t\t\t})\n\t\t})\n\t}\n\n\tpublic saveCursor() {\n\t\tterminal.saveCursor()\n\t}\n\n\tpublic restoreCursor() {\n\t\tterminal.restoreCursor()\n\t}\n\n\tpublic moveCursorTo(x: number, y: number): void {\n\t\tterminal.moveTo(x, y)\n\t}\n\n\tpublic clearBelowCursor(): void {\n\t\tterminal.eraseDisplayBelow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;UAAA;QAAA;MAAA,C;;;;;;;;;;;6GAQA;QAAA;UAAA;YAAA;cAAA;gBAAA,kCACQ,IAAIC,OAAJ,CAAY,UAACC,OAAD,EAAa;kBAC/BrF,sBAASsF,qBAAT;;kBACAtF,sBAASuF,iBAAT,CAA2B,UAAC/G,GAAD,EAAMgH,CAAN,EAASC,CAAT,EAAe;oBACzCJ,OAAO,CAAC7G,GAAG,GAAG,IAAH,GAAU;sBAAEgH,CAAC,EAAEA,CAAF,aAAEA,CAAF,cAAEA,CAAF,GAAO,CAAV;sBAAaC,CAAC,EAAEA,CAAF,aAAEA,CAAF,cAAEA,CAAF,GAAO;oBAArB,CAAd,CAAP;kBACA,CAFD;gBAGA,CALM,CADR;;cAAA;cAAA;gBAAA;YAAA;UAAA;QAAA;MAAA,C;;;;;;;;;;WASA,sBAAoB;MACnBzF,sBAAS0F,UAAT;IACA;;;WAED,yBAAuB;MACtB1F,sBAAS2F,aAAT;IACA;;;WAED,sBAAoBH,CAApB,EAA+BC,CAA/B,EAAgD;MAC/CzF,sBAAS4F,MAAT,CAAgBJ,CAAhB,EAAmBC,CAAnB;IACA;;;WAED,4BAAgC;MAC/BzF,sBAAS6F,iBAAT;IACA;;;WAED,qBAAmB;MAClB7F,sBAASC,SAAT;IACA;;;WA9hBD,4BAAiC;MAChC,OAAO,KAAK6F,iBAAZ;IACA;;;WAED,6BAAkCC,KAAlC,EAAkD;MACjD,KAAKD,iBAAL,GAAyBC,KAAzB;IACA;;;;;;iCAzBmB3L,iB;iCAAAA,iB,uBAMe,aAAAkF,OAAO,UAAP,+DAASC,MAAT,oEAAiByG,KAAjB,KAA0B,CAAC,uB"}
|
|
1
|
+
{"version":3,"file":"TerminalInterface.js","names":["terminalImage","require","fieldCount","generateInquirerFieldName","filterEffectsForCFonts","effects","effect","GraphicsTextEffect","SpruceHeader","Reset","Bold","Dim","Italic","Underline","Inverse","Hidden","Strikethrough","Visible","indexOf","TerminalInterface","cwd","renderStackTraces","log","console","bind","Error","lines","forEach","line","renderLine","object","Green","renderDivider","Object","keys","key","chalk","bold","JSON","stringify","options","headline","dividerEffects","headlineEffects","Blue","bodyEffects","renderHeadline","renderLines","renderObject","bar","results","generatedFiles","files","filter","f","action","updatedFiles","skippedFiles","errors","packagesInstalled","renderHero","summaryLines","length","push","renderSection","featuresUtil","generateCommand","featureCode","actionCode","table","Table","head","colWidths","wordWrap","colAligns","sort","one","two","name","pkg","isDev","toString","file","description","namesUtil","toPascal","hints","err","renderError","totalTime","durationUtil","msToFriendly","message","isSpruce","fonts","say","font","align","space","colors","shouldStripVowels","process","stdout","columns","stripped","replace","gradient","Red","undefined","write","eraseBeforeRender","terminal","eraseLine","Yellow","stopLoading","loader","text","start","stop","question","inquirer","prompt","type","confirmResult","answer","label","bgGreenBright","black","clear","code","colored","emphasize","highlight","value","renderWarning","definition","isPromptActive","fieldDefinition","defaultValue","promptOptions","generatePromptLabel","field","FieldFactory","Field","transformer","toValueType","validate","id","fields","isArray","choices","map","choice","checked","_","includes","SpruceError","friendlyMessage","dirPath","path","join","root","onlyShowDir","fs","existsSync","lstatSync","isDirectory","cleanedPath","uri","directory","extname","response","result","hint","italic","dim","stackLines","cleanStack","splice","stack","AbstractSpruceError","original","originalError","split","removeProgressBar","progressBar","percent","showPercent","eta","showEta","items","totalItems","inline","renderInline","update","image","Promise","resolve","requestCursorLocation","getCursorLocation","x","y","saveCursor","restoreCursor","moveTo","eraseDisplayBelow","_doesSupportColor","isTTy","isTTY"],"sources":["../../src/interfaces/TerminalInterface.ts"],"sourcesContent":["import path from 'path'\nimport AbstractSpruceError from '@sprucelabs/error'\nimport {\n\tFieldFactory,\n\tFieldDefinitionValueType,\n\tareSchemaValuesValid,\n} from '@sprucelabs/schema'\nimport { IField } from '@sprucelabs/schema'\nimport { namesUtil } from '@sprucelabs/spruce-skill-utils'\n// @ts-ignore\nimport fonts from 'cfonts'\nimport chalk from 'chalk'\n// @ts-ignore No definition available\nimport Table from 'cli-table3'\n// @ts-ignore No definition available\nimport emphasize from 'emphasize'\nimport fs from 'fs-extra'\nimport globby from 'globby'\nimport inquirer from 'inquirer'\nimport _ from 'lodash'\nimport { filter } from 'lodash'\nimport ora from 'ora'\nimport { terminal } from 'terminal-kit'\nimport { ProgressBarController } from 'terminal-kit/Terminal'\nimport { FieldDefinitions } from '#spruce/schemas/fields/fields.types'\nimport SpruceError from '../errors/SpruceError'\nimport featuresUtil from '../features/feature.utilities'\nimport { ExecutionResults, GraphicsInterface } from '../types/cli.types'\nimport {\n\tGraphicsTextEffect,\n\tImageDimensions,\n\tProgressBarOptions,\n\tProgressBarUpdateOptions,\n} from '../types/graphicsInterface.types'\nimport durationUtil from '../utilities/duration.utility'\nimport isCi from '../utilities/isCi'\nconst terminalImage = require('terminal-image')\n\nlet fieldCount = 0\nfunction generateInquirerFieldName() {\n\tfieldCount++\n\treturn `field-${fieldCount}`\n}\n\n/** Remove effects cfonts does not support */\nfunction filterEffectsForCFonts(effects: GraphicsTextEffect[]) {\n\treturn filter(\n\t\teffects,\n\t\t(effect) =>\n\t\t\t[\n\t\t\t\tGraphicsTextEffect.SpruceHeader,\n\t\t\t\tGraphicsTextEffect.Reset,\n\t\t\t\tGraphicsTextEffect.Bold,\n\t\t\t\tGraphicsTextEffect.Dim,\n\t\t\t\tGraphicsTextEffect.Italic,\n\t\t\t\tGraphicsTextEffect.Underline,\n\t\t\t\tGraphicsTextEffect.Inverse,\n\t\t\t\tGraphicsTextEffect.Hidden,\n\t\t\t\tGraphicsTextEffect.Strikethrough,\n\t\t\t\tGraphicsTextEffect.Visible,\n\t\t\t].indexOf(effect) === -1\n\t)\n}\n\ntype TerminalSpecificOptions = {\n\teraseBeforeRender?: boolean\n}\n\nexport default class TerminalInterface implements GraphicsInterface {\n\tpublic isPromptActive = false\n\tpublic cwd: string\n\tprivate renderStackTraces = false\n\tprivate static loader?: ora.Ora | null\n\tprivate progressBar: ProgressBarController | null = null\n\tprivate static _doesSupportColor = process?.stdout?.isTTY && !isCi()\n\tprivate log: (...args: any[]) => void\n\n\tpublic constructor(\n\t\tcwd: string,\n\t\trenderStackTraces = false,\n\t\tlog = console.log.bind(console)\n\t) {\n\t\tthis.cwd = cwd\n\t\tthis.renderStackTraces = renderStackTraces\n\t\tthis.log = log\n\t}\n\n\tpublic static doesSupportColor() {\n\t\treturn this._doesSupportColor\n\t}\n\n\tpublic static setDoesSupportColor(isTTy: boolean) {\n\t\tthis._doesSupportColor = isTTy\n\t}\n\n\tpublic async sendInput(): Promise<void> {\n\t\tthrow new Error('sendInput not supported on the TerminalInterface!')\n\t}\n\n\tpublic renderLines(lines: any[], effects?: GraphicsTextEffect[]) {\n\t\tlines.forEach((line) => {\n\t\t\tthis.renderLine(line, effects)\n\t\t})\n\t}\n\n\tpublic renderObject(\n\t\tobject: Record<string, any>,\n\t\teffects: GraphicsTextEffect[] = [GraphicsTextEffect.Green]\n\t) {\n\t\tthis.renderLine('')\n\t\tthis.renderDivider()\n\t\tthis.renderLine('')\n\t\tObject.keys(object).forEach((key) => {\n\t\t\tthis.renderLine(\n\t\t\t\t`${chalk.bold(key)}: ${\n\t\t\t\t\ttypeof object[key] === 'string'\n\t\t\t\t\t\t? object[key]\n\t\t\t\t\t\t: JSON.stringify(object[key])\n\t\t\t\t}`,\n\t\t\t\teffects\n\t\t\t)\n\t\t})\n\t\tthis.renderLine('')\n\t\tthis.renderDivider()\n\t\tthis.renderLine('')\n\t}\n\n\tpublic renderSection(options: {\n\t\theadline?: string\n\t\tlines?: string[]\n\t\tobject?: Record<string, any>\n\t\theadlineEffects?: GraphicsTextEffect[]\n\t\tbodyEffects?: GraphicsTextEffect[]\n\t\tdividerEffects?: GraphicsTextEffect[]\n\t}) {\n\t\tconst {\n\t\t\theadline,\n\t\t\tlines,\n\t\t\tobject,\n\t\t\tdividerEffects = [],\n\t\t\theadlineEffects = [GraphicsTextEffect.Blue, GraphicsTextEffect.Bold],\n\t\t\tbodyEffects = [GraphicsTextEffect.Green],\n\t\t} = options\n\n\t\tif (headline) {\n\t\t\tthis.renderHeadline(`${headline} 🌲🤖`, headlineEffects, dividerEffects)\n\t\t}\n\n\t\tif (lines) {\n\t\t\tthis.renderLines(lines, bodyEffects)\n\n\t\t\tthis.renderLine('')\n\t\t\tthis.renderDivider(dividerEffects)\n\t\t}\n\n\t\tif (object) {\n\t\t\tthis.renderObject(object, bodyEffects)\n\t\t}\n\n\t\tthis.renderLine('')\n\t}\n\n\tpublic renderDivider(effects?: GraphicsTextEffect[]) {\n\t\tconst bar = '=================================================='\n\t\tthis.renderLine(bar, effects)\n\t}\n\n\tpublic renderActionSummary(\n\t\tresults: ExecutionResults & { totalTime?: number }\n\t) {\n\t\tconst generatedFiles =\n\t\t\tresults.files?.filter((f) => f.action === 'generated') ?? []\n\t\tconst updatedFiles =\n\t\t\tresults.files?.filter((f) => f.action === 'updated') ?? []\n\t\tconst skippedFiles =\n\t\t\tresults.files?.filter((f) => f.action === 'skipped') ?? []\n\n\t\tconst errors = results.errors ?? []\n\t\tconst packagesInstalled = results.packagesInstalled ?? []\n\n\t\tthis.renderHero(`${results.headline}`)\n\n\t\tlet summaryLines: string[] = [\n\t\t\terrors.length > 0 ? `Errors: ${errors.length}` : null,\n\t\t\tgeneratedFiles.length > 0\n\t\t\t\t? `Generated files: ${generatedFiles.length}`\n\t\t\t\t: null,\n\t\t\tupdatedFiles.length > 0 ? `Updated files: ${updatedFiles.length}` : null,\n\t\t\tskippedFiles.length > 0 ? `Skipped files: ${skippedFiles.length}` : null,\n\t\t\tpackagesInstalled.length > 0\n\t\t\t\t? `NPM packages installed: ${packagesInstalled.length}`\n\t\t\t\t: null,\n\t\t\t...(results.summaryLines ?? []),\n\t\t].filter((line) => !!line) as string[]\n\n\t\tif (summaryLines.length === 0) {\n\t\t\tsummaryLines.push('Nothing to report!')\n\t\t}\n\t\tthis.renderSection({\n\t\t\theadline: `${featuresUtil.generateCommand(\n\t\t\t\tresults.featureCode,\n\t\t\t\tresults.actionCode\n\t\t\t)} summary`,\n\t\t\tlines: summaryLines,\n\t\t})\n\n\t\tif (packagesInstalled.length > 0) {\n\t\t\tconst table = new Table({\n\t\t\t\thead: ['Name', 'Dev'],\n\t\t\t\tcolWidths: [40, 5],\n\t\t\t\twordWrap: true,\n\t\t\t\tcolAligns: ['left', 'center'],\n\t\t\t})\n\t\t\tpackagesInstalled\n\t\t\t\t.sort((one, two) => (one.name > two.name ? 1 : -1))\n\t\t\t\t.forEach((pkg) => {\n\t\t\t\t\ttable.push([pkg.name, pkg.isDev ? '√' : ''])\n\t\t\t\t})\n\n\t\t\tthis.renderSection({\n\t\t\t\theadline: `NPM packages summary`,\n\t\t\t\tlines: [table.toString()],\n\t\t\t})\n\t\t}\n\n\t\tfor (let files of [generatedFiles, updatedFiles]) {\n\t\t\tif (files.length > 0) {\n\t\t\t\tconst table = new Table({\n\t\t\t\t\thead: ['File', 'Description'],\n\t\t\t\t\twordWrap: true,\n\t\t\t\t})\n\n\t\t\t\tfiles = files.sort()\n\n\t\t\t\tfor (const file of files) {\n\t\t\t\t\ttable.push([file.name, file.description ?? ''])\n\t\t\t\t}\n\n\t\t\t\tthis.renderSection({\n\t\t\t\t\theadline: `${namesUtil.toPascal(files[0].action)} file summary`,\n\t\t\t\t\tlines: [table.toString()],\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\n\t\tif (results.hints) {\n\t\t\tthis.renderSection({\n\t\t\t\theadline: 'Read below 👇',\n\t\t\t\tlines: results.hints,\n\t\t\t})\n\t\t}\n\n\t\tif (errors.length > 0) {\n\t\t\tthis.renderHeadline('Errors')\n\t\t\terrors.forEach((err) => this.renderError(err))\n\t\t}\n\n\t\tif (results.totalTime) {\n\t\t\tthis.renderLine(\n\t\t\t\t`Total time: ${durationUtil.msToFriendly(results.totalTime)}`\n\t\t\t)\n\t\t}\n\t}\n\n\tpublic renderHeadline(\n\t\tmessage: string,\n\t\teffects: GraphicsTextEffect[] = [\n\t\t\tGraphicsTextEffect.Blue,\n\t\t\tGraphicsTextEffect.Bold,\n\t\t],\n\t\tdividerEffects: GraphicsTextEffect[] = []\n\t) {\n\t\tconst isSpruce = effects.indexOf(GraphicsTextEffect.SpruceHeader) > -1\n\n\t\tif (isSpruce) {\n\t\t\tfonts.say(message, {\n\t\t\t\tfont: GraphicsTextEffect.SpruceHeader,\n\t\t\t\talign: 'left',\n\t\t\t\tspace: false,\n\t\t\t\tcolors: filterEffectsForCFonts(effects),\n\t\t\t})\n\t\t} else {\n\t\t\tthis.renderDivider(dividerEffects)\n\t\t\tthis.renderLine(message, effects)\n\t\t\tthis.renderDivider(dividerEffects)\n\t\t\tthis.renderLine('')\n\t\t}\n\t}\n\n\tpublic renderHero(message: string, effects?: GraphicsTextEffect[]) {\n\t\tconst shouldStripVowels = process.stdout.columns < 80\n\n\t\tconst stripped = shouldStripVowels\n\t\t\t? message.replace(/[aeiou]/gi, '')\n\t\t\t: message\n\n\t\tfonts.say(stripped, {\n\t\t\t// Font: 'tiny',\n\t\t\talign: 'left',\n\t\t\tgradient: [GraphicsTextEffect.Red, GraphicsTextEffect.Blue],\n\t\t\tcolors: effects ? filterEffectsForCFonts(effects) : undefined,\n\t\t})\n\t}\n\n\tpublic renderHint(message: string) {\n\t\treturn this.renderLine(`👨🏫 ${message}`)\n\t}\n\n\tpublic renderLine(\n\t\tmessage: any,\n\t\teffects: GraphicsTextEffect[] = [],\n\t\toptions?: TerminalSpecificOptions\n\t) {\n\t\tlet write: any = chalk\n\t\teffects.forEach((effect) => {\n\t\t\twrite = write[effect]\n\t\t})\n\n\t\tif (options?.eraseBeforeRender) {\n\t\t\tterminal.eraseLine()\n\t\t}\n\n\t\tthis.log(effects.length > 0 ? write(message) : message)\n\t}\n\n\tpublic renderWarning(message: string) {\n\t\tthis.renderLine(`⚠️ ${message}`, [\n\t\t\tGraphicsTextEffect.Bold,\n\t\t\tGraphicsTextEffect.Yellow,\n\t\t])\n\t}\n\n\tpublic async startLoading(message?: string) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.stopLoading()\n\t\tTerminalInterface.loader = ora({\n\t\t\ttext: message,\n\t\t}).start()\n\t}\n\n\tpublic async stopLoading() {\n\t\tTerminalInterface.loader?.stop()\n\t\tTerminalInterface.loader = null\n\t}\n\n\tpublic async confirm(question: string): Promise<boolean> {\n\t\tconst confirmResult = await inquirer.prompt({\n\t\t\ttype: 'confirm',\n\t\t\tname: 'answer',\n\t\t\tmessage: question,\n\t\t})\n\n\t\treturn !!confirmResult.answer\n\t}\n\n\tpublic async waitForEnter(message?: string) {\n\t\tawait this.prompt({\n\t\t\ttype: 'text',\n\t\t\tlabel: `${message ? message + ' ' : ''}${chalk.bgGreenBright.black(\n\t\t\t\t'hit enter'\n\t\t\t)}`,\n\t\t})\n\t\tthis.renderLine('')\n\t\treturn\n\t}\n\n\tpublic clear() {\n\t\tvoid this.stopLoading()\n\t\tconsole.clear()\n\t}\n\n\tpublic renderCodeSample(code: string) {\n\t\ttry {\n\t\t\tconst colored = emphasize.highlight('js', code).value\n\t\t\tthis.renderLine(colored)\n\t\t} catch (err: any) {\n\t\t\tthis.renderWarning(err)\n\t\t}\n\t}\n\n\tpublic async prompt<T extends FieldDefinitions>(\n\t\tdefinition: T\n\t): Promise<FieldDefinitionValueType<T>> {\n\t\tthis.isPromptActive = true\n\t\tconst name = generateInquirerFieldName()\n\t\tconst fieldDefinition: FieldDefinitions = definition\n\t\tconst { defaultValue } = fieldDefinition\n\n\t\tconst promptOptions: Record<string, any> = {\n\t\t\tdefault: defaultValue,\n\t\t\tname,\n\t\t\tmessage: this.generatePromptLabel(fieldDefinition),\n\t\t}\n\n\t\tconst field = FieldFactory.Field('prompt', fieldDefinition)\n\n\t\tpromptOptions.transformer = (value: string) => {\n\t\t\treturn (field as IField<any>).toValueType(value)\n\t\t}\n\n\t\tpromptOptions.validate = (value: string) => {\n\t\t\treturn areSchemaValuesValid(\n\t\t\t\t{\n\t\t\t\t\tid: 'promptvalidateschema',\n\t\t\t\t\tfields: {\n\t\t\t\t\t\tprompt: fieldDefinition,\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\t{ prompt: value }\n\t\t\t)\n\t\t\t// return field.validate(value, {}).length === 0\n\t\t}\n\n\t\tswitch (fieldDefinition.type) {\n\t\t\t// Map select options to prompt list choices\n\t\t\tcase 'boolean':\n\t\t\t\tpromptOptions.type = 'confirm'\n\t\t\t\tbreak\n\n\t\t\tcase 'select':\n\t\t\t\tpromptOptions.type = fieldDefinition.isArray ? 'checkbox' : 'list'\n\n\t\t\t\tpromptOptions.choices = fieldDefinition.options.choices.map(\n\t\t\t\t\t// @ts-ignore\n\t\t\t\t\t(choice) => ({\n\t\t\t\t\t\tname: choice.label,\n\t\t\t\t\t\tvalue: choice.value,\n\t\t\t\t\t\tchecked: _.includes(fieldDefinition.defaultValue, choice.value),\n\t\t\t\t\t})\n\t\t\t\t)\n\n\t\t\t\tbreak\n\t\t\t// Directory select\n\t\t\t// File select\n\t\t\tcase 'directory': {\n\t\t\t\tif (fieldDefinition.isArray) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'NOT_IMPLEMENTED',\n\t\t\t\t\t\tfriendlyMessage:\n\t\t\t\t\t\t\t'isArray file field not supported, prompt needs to be rewritten with isArray support',\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tconst dirPath = path.join(\n\t\t\t\t\tfieldDefinition.defaultValue?.path ?? this.cwd,\n\t\t\t\t\t'/'\n\t\t\t\t)\n\n\t\t\t\tpromptOptions.type = 'file'\n\t\t\t\tpromptOptions.root = dirPath\n\t\t\t\tpromptOptions.onlyShowDir = true\n\n\t\t\t\t// Only let people select an actual file\n\t\t\t\tpromptOptions.validate = (value: string) => {\n\t\t\t\t\treturn fs.existsSync(value) && fs.lstatSync(value).isDirectory()\n\t\t\t\t}\n\t\t\t\t// Strip out cwd from the paths while selecting\n\t\t\t\tpromptOptions.transformer = (path: string) => {\n\t\t\t\t\tconst cleanedPath = path.replace(promptOptions.root, '')\n\t\t\t\t\treturn cleanedPath.length === 0 ? promptOptions.root : cleanedPath\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tcase 'file': {\n\t\t\t\tif (fieldDefinition.isArray) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'NOT_IMPLEMENTED',\n\t\t\t\t\t\tfriendlyMessage:\n\t\t\t\t\t\t\t'isArray file field not supported, prompt needs to be rewritten with isArray support',\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t\tconst dirPath = path.join(\n\t\t\t\t\tfieldDefinition.defaultValue?.uri ?? this.cwd,\n\t\t\t\t\t'/'\n\t\t\t\t)\n\n\t\t\t\t// Check if directory is empty.\n\t\t\t\tconst files = await globby(`${dirPath}**/*`)\n\n\t\t\t\tif (files.length === 0) {\n\t\t\t\t\tthrow new SpruceError({\n\t\t\t\t\t\tcode: 'DIRECTORY_EMPTY',\n\t\t\t\t\t\tdirectory: dirPath,\n\t\t\t\t\t\tfriendlyMessage: `I wanted to help you select a file, but none exist in ${dirPath}.`,\n\t\t\t\t\t})\n\t\t\t\t}\n\n\t\t\t\tpromptOptions.type = 'file'\n\t\t\t\tpromptOptions.root = dirPath\n\n\t\t\t\t// Only let people select an actual file\n\t\t\t\tpromptOptions.validate = (value: string) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\tfs.existsSync(value) &&\n\t\t\t\t\t\t!fs.lstatSync(value).isDirectory() &&\n\t\t\t\t\t\tpath.extname(value) === '.ts'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\t// Strip out cwd from the paths while selecting\n\t\t\t\tpromptOptions.transformer = (path: string) => {\n\t\t\t\t\tconst cleanedPath = path.replace(promptOptions.root, '')\n\t\t\t\t\treturn cleanedPath.length === 0 ? promptOptions.root : cleanedPath\n\t\t\t\t}\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\t// Defaults to input\n\t\t\tdefault:\n\t\t\t\tpromptOptions.type = 'input'\n\t\t}\n\n\t\tconst response = (await inquirer.prompt(promptOptions)) as any\n\n\t\tthis.isPromptActive = false\n\n\t\tconst result =\n\t\t\ttypeof response[name] !== 'undefined'\n\t\t\t\t? (field as IField<any>).toValueType(response[name])\n\t\t\t\t: response[name]\n\n\t\treturn result\n\t}\n\tprivate generatePromptLabel(fieldDefinition: FieldDefinitions): any {\n\t\tlet label = fieldDefinition.label\n\n\t\tif (fieldDefinition.hint) {\n\t\t\tlabel = `${label} ${chalk.italic.dim(`(${fieldDefinition.hint})`)}`\n\t\t}\n\n\t\tlabel = label + ': '\n\n\t\treturn label\n\t}\n\n\tpublic renderError(err: Error) {\n\t\t// eslint-disable-next-line @typescript-eslint/no-floating-promises\n\t\tthis.stopLoading()\n\n\t\tconst message = err.message\n\t\t// Remove message from stack so the message is not doubled up\n\t\tconst stackLines = this.cleanStack(err)\n\t\tthis.renderSection({\n\t\t\theadline: message,\n\t\t\tlines: this.renderStackTraces ? stackLines.splice(0, 100) : undefined,\n\t\t\theadlineEffects: [GraphicsTextEffect.Bold, GraphicsTextEffect.Red],\n\t\t\tdividerEffects: [GraphicsTextEffect.Red],\n\t\t\tbodyEffects: [GraphicsTextEffect.Red],\n\t\t})\n\t}\n\n\tprivate cleanStack(err: Error) {\n\t\tconst message = err.message\n\t\tlet stack = err.stack ? err.stack.replace(message, '') : ''\n\n\t\tif (err instanceof AbstractSpruceError) {\n\t\t\tlet original = err.originalError\n\t\t\twhile (original) {\n\t\t\t\tstack = stack.replace('Error: ' + original.message, '')\n\t\t\t\toriginal = (original as AbstractSpruceError).originalError\n\t\t\t}\n\t\t}\n\n\t\tconst stackLines = stack.split('\\n')\n\n\t\treturn stackLines\n\t}\n\n\tpublic renderProgressBar(options: ProgressBarOptions): void {\n\t\tthis.removeProgressBar()\n\t\tthis.progressBar = terminal.progressBar({\n\t\t\t...options,\n\t\t\tpercent: options.showPercent,\n\t\t\teta: options.showEta,\n\t\t\titems: options.totalItems,\n\t\t\tinline: options.renderInline,\n\t\t})\n\t}\n\n\tpublic removeProgressBar() {\n\t\tif (this.progressBar) {\n\t\t\tthis.progressBar.stop()\n\t\t\tthis.progressBar = null\n\t\t}\n\t}\n\n\tpublic updateProgressBar(options: ProgressBarUpdateOptions): void {\n\t\tif (this.progressBar) {\n\t\t\tthis.progressBar.update({\n\t\t\t\t...options,\n\t\t\t\titems: options.totalItems,\n\t\t\t})\n\t\t}\n\t}\n\n\tpublic async renderImage(\n\t\tpath: string,\n\t\toptions?: ImageDimensions\n\t): Promise<void> {\n\t\tconst image = await terminalImage.file(path, options)\n\t\tthis.renderLine(image)\n\t}\n\n\tpublic async getCursorPosition(): Promise<{ x: number; y: number } | null> {\n\t\treturn new Promise((resolve) => {\n\t\t\tterminal.requestCursorLocation()\n\t\t\tterminal.getCursorLocation((err, x, y) => {\n\t\t\t\tresolve(err ? null : { x: x ?? 0, y: y ?? 0 })\n\t\t\t})\n\t\t})\n\t}\n\n\tpublic saveCursor() {\n\t\tterminal.saveCursor()\n\t}\n\n\tpublic restoreCursor() {\n\t\tterminal.restoreCursor()\n\t}\n\n\tpublic moveCursorTo(x: number, y: number): void {\n\t\tterminal.moveTo(x, y)\n\t}\n\n\tpublic clearBelowCursor(): void {\n\t\tterminal.eraseDisplayBelow()\n\t}\n\n\tpublic eraseLine() {\n\t\tterminal.eraseLine()\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAMA;;AAEA;;AACA;;AAEA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AAGA;;AACA;;AAEA;;AAMA;;AACA;;;;;;;;;;;;;;;;;;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,gBAAD,CAA7B;;AAEA,IAAIC,UAAU,GAAG,CAAjB;;AACA,SAASC,yBAAT,GAAqC;EACpCD,UAAU;EACV,uBAAgBA,UAAhB;AACA;AAED;;;AACA,SAASE,sBAAT,CAAgCC,OAAhC,EAA+D;EAC9D,OAAO,oBACNA,OADM,EAEN,UAACC,MAAD;IAAA,OACC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AA,C;;;;;;;;;;WASA,sBAAoB;MACnB1F,sBAAS2F,UAAT;IACA;;;WAED,yBAAuB;MACtB3F,sBAAS4F,aAAT;IACA;;;WAED,sBAAoBH,CAApB,EAA+BC,CAA/B,EAAgD;MAC/C1F,sBAAS6F,MAAT,CAAgBJ,CAAhB,EAAmBC,CAAnB;IACA;;;WAED,4BAAgC;MAC/B1F,sBAAS8F,iBAAT;IACA;;;WAED,qBAAmB;MAClB9F,sBAASC,SAAT;IACA;;;WA9hBD,4BAAiC;MAChC,OAAO,KAAK8F,iBAAZ;IACA;;;WAED,6BAAkCC,KAAlC,EAAkD;MACjD,KAAKD,iBAAL,GAAyBC,KAAzB;IACA;;;;;;iCAzBmB5L,iB;iCAAAA,iB,uBAMe,aAAAkF,OAAO,UAAP,+DAASC,MAAT,oEAAiB0G,KAAjB,KAA0B,CAAC,uB"}
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
20
|
"license": "MIT",
|
|
21
|
-
"version": "15.4.
|
|
21
|
+
"version": "15.4.8",
|
|
22
22
|
"bin": {
|
|
23
23
|
"spruce": "./build/index.js"
|
|
24
24
|
},
|
|
@@ -75,20 +75,20 @@
|
|
|
75
75
|
"@babel/cli": "^7.17.10",
|
|
76
76
|
"@babel/plugin-proposal-decorators": "^7.17.9",
|
|
77
77
|
"@babel/runtime": "^7.17.9",
|
|
78
|
-
"@jest/reporters": "^28.0
|
|
79
|
-
"@sprucelabs/error": "^5.0.
|
|
80
|
-
"@sprucelabs/heartwood-view-controllers": "^71.0.
|
|
81
|
-
"@sprucelabs/jest-json-reporter": "^6.0.
|
|
82
|
-
"@sprucelabs/mercury-client": "^
|
|
83
|
-
"@sprucelabs/mercury-event-emitter": "^
|
|
84
|
-
"@sprucelabs/mercury-types": "^
|
|
85
|
-
"@sprucelabs/schema": "^
|
|
86
|
-
"@sprucelabs/spruce-core-schemas": "^
|
|
87
|
-
"@sprucelabs/spruce-event-plugin": "^31.0.
|
|
88
|
-
"@sprucelabs/spruce-event-utils": "^
|
|
89
|
-
"@sprucelabs/spruce-skill-booter": "^31.0.
|
|
90
|
-
"@sprucelabs/spruce-skill-utils": "^
|
|
91
|
-
"@sprucelabs/spruce-templates": "^15.4.
|
|
78
|
+
"@jest/reporters": "^28.1.0",
|
|
79
|
+
"@sprucelabs/error": "^5.0.452",
|
|
80
|
+
"@sprucelabs/heartwood-view-controllers": "^71.0.12",
|
|
81
|
+
"@sprucelabs/jest-json-reporter": "^6.0.376",
|
|
82
|
+
"@sprucelabs/mercury-client": "^24.0.7",
|
|
83
|
+
"@sprucelabs/mercury-event-emitter": "^24.0.7",
|
|
84
|
+
"@sprucelabs/mercury-types": "^28.0.7",
|
|
85
|
+
"@sprucelabs/schema": "^28.0.6",
|
|
86
|
+
"@sprucelabs/spruce-core-schemas": "^27.0.2",
|
|
87
|
+
"@sprucelabs/spruce-event-plugin": "^31.0.12",
|
|
88
|
+
"@sprucelabs/spruce-event-utils": "^20.1.7",
|
|
89
|
+
"@sprucelabs/spruce-skill-booter": "^31.0.12",
|
|
90
|
+
"@sprucelabs/spruce-skill-utils": "^26.0.5",
|
|
91
|
+
"@sprucelabs/spruce-templates": "^15.4.8",
|
|
92
92
|
"@typescript-eslint/eslint-plugin": "^5.17.0",
|
|
93
93
|
"@typescript-eslint/parser": "^5.17.0",
|
|
94
94
|
"cfonts": "^2.10.1",
|
|
@@ -119,16 +119,16 @@
|
|
|
119
119
|
"uuid": "^8.3.2"
|
|
120
120
|
},
|
|
121
121
|
"devDependencies": {
|
|
122
|
-
"@sprucelabs/data-stores": "^
|
|
122
|
+
"@sprucelabs/data-stores": "^11.2.2",
|
|
123
123
|
"@sprucelabs/jest-sheets-reporter": "^1.3.43",
|
|
124
|
-
"@sprucelabs/mercury-core-events": "^
|
|
125
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
126
|
-
"@sprucelabs/spruce-conversation-plugin": "^31.0.
|
|
127
|
-
"@sprucelabs/spruce-deploy-plugin": "^31.0.
|
|
128
|
-
"@sprucelabs/spruce-store-plugin": "^31.0.
|
|
129
|
-
"@sprucelabs/spruce-test-fixtures": "^31.0.
|
|
130
|
-
"@sprucelabs/test": "^7.7.
|
|
131
|
-
"@sprucelabs/test-utils": "^3.0.
|
|
124
|
+
"@sprucelabs/mercury-core-events": "^4.0.6",
|
|
125
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.40",
|
|
126
|
+
"@sprucelabs/spruce-conversation-plugin": "^31.0.12",
|
|
127
|
+
"@sprucelabs/spruce-deploy-plugin": "^31.0.12",
|
|
128
|
+
"@sprucelabs/spruce-store-plugin": "^31.0.12",
|
|
129
|
+
"@sprucelabs/spruce-test-fixtures": "^31.0.12",
|
|
130
|
+
"@sprucelabs/test": "^7.7.313",
|
|
131
|
+
"@sprucelabs/test-utils": "^3.0.541",
|
|
132
132
|
"@types/blessed": "^0.1.19",
|
|
133
133
|
"@types/eslint": "^8.4.2",
|
|
134
134
|
"@types/fs-extra": "^9.0.13",
|
|
@@ -152,17 +152,17 @@
|
|
|
152
152
|
"concurrently": "^7.1.0",
|
|
153
153
|
"conventional-changelog-sprucelabs": "^1.1.2",
|
|
154
154
|
"dotenv": "^16.0.0",
|
|
155
|
-
"eslint": "^8.
|
|
155
|
+
"eslint": "^8.15.0",
|
|
156
156
|
"eslint-config-spruce": "^10.11.2",
|
|
157
157
|
"find-process": "^1.4.7",
|
|
158
|
-
"jest": "^28.0
|
|
159
|
-
"jest-circus": "^28.0
|
|
158
|
+
"jest": "^28.1.0",
|
|
159
|
+
"jest-circus": "^28.1.0",
|
|
160
160
|
"jest-junit": "^13.2.0",
|
|
161
161
|
"jest-reporters": "^0.0.2",
|
|
162
162
|
"prettier": "^2.6.2",
|
|
163
163
|
"ps-node": "^0.1.6",
|
|
164
164
|
"rimraf": "^3.0.2",
|
|
165
|
-
"ts-jest": "^28.0.
|
|
165
|
+
"ts-jest": "^28.0.2",
|
|
166
166
|
"ts-node": "^10.7.0",
|
|
167
167
|
"tsc-watch": "^5.0.3",
|
|
168
168
|
"tsconfig-paths": "^4.0.0",
|
|
@@ -597,5 +597,5 @@
|
|
|
597
597
|
"terminal-kit"
|
|
598
598
|
]
|
|
599
599
|
},
|
|
600
|
-
"gitHead": "
|
|
600
|
+
"gitHead": "2ac1326edb074dd8e7237b1debb67b7dca88f56f"
|
|
601
601
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MercuryClientFactory } from '@sprucelabs/mercury-client'
|
|
2
2
|
import { coreEventContracts } from '@sprucelabs/mercury-core-events'
|
|
3
|
-
import { EventSignature } from '@sprucelabs/mercury-types'
|
|
3
|
+
import { EventSignature, SpruceSchemas } from '@sprucelabs/mercury-types'
|
|
4
4
|
import { buildSchema } from '@sprucelabs/schema'
|
|
5
5
|
import {
|
|
6
6
|
buildEmitTargetAndPayloadSchema,
|
|
@@ -16,7 +16,9 @@ import {
|
|
|
16
16
|
import { eventFaker } from '@sprucelabs/spruce-test-fixtures'
|
|
17
17
|
import { test, assert } from '@sprucelabs/test'
|
|
18
18
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
19
|
-
import ListenAction
|
|
19
|
+
import ListenAction, {
|
|
20
|
+
CORE_EVENT_NAMESPACE,
|
|
21
|
+
} from '../../../features/event/actions/ListenAction'
|
|
20
22
|
import AbstractEventTest from '../../../tests/AbstractEventTest'
|
|
21
23
|
import testUtil from '../../../tests/utilities/test.utility'
|
|
22
24
|
|
|
@@ -106,7 +108,6 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
106
108
|
@test()
|
|
107
109
|
protected static async creatingANewListenerAsksWhichEventToListenTo() {
|
|
108
110
|
await this.installEventFeature('events')
|
|
109
|
-
|
|
110
111
|
await this.executeAndWaitForInput()
|
|
111
112
|
|
|
112
113
|
let lastInvocation = this.ui.getLastInvocation()
|
|
@@ -125,41 +126,34 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
125
126
|
this.ui.reset()
|
|
126
127
|
}
|
|
127
128
|
|
|
128
|
-
private static async executeAndWaitForInput() {
|
|
129
|
-
void this.listen.execute({})
|
|
130
|
-
await this.waitForInput()
|
|
131
|
-
}
|
|
132
|
-
|
|
133
129
|
@test()
|
|
134
130
|
protected static async loadsContractsFilteringByDependencies() {
|
|
135
|
-
await this.installEventFeature('events')
|
|
136
|
-
MercuryClientFactory.setIsTestMode(true)
|
|
137
|
-
|
|
138
131
|
let passedTarget: any
|
|
139
|
-
await
|
|
132
|
+
await this.fakeGetEventContracts((target) => {
|
|
140
133
|
passedTarget = target
|
|
141
|
-
return {
|
|
142
|
-
contracts: [...(coreEventContracts as any)],
|
|
143
|
-
}
|
|
144
134
|
})
|
|
145
135
|
|
|
146
136
|
const namespace = 'waka'
|
|
147
|
-
this.
|
|
148
|
-
|
|
149
|
-
await this.executeAndWaitForInput()
|
|
137
|
+
await this.installAddDependencyExecuteAndWaitForInput(namespace)
|
|
150
138
|
|
|
151
139
|
assert.isEqualDeep(passedTarget, {
|
|
152
|
-
namespaces: [namespace],
|
|
140
|
+
namespaces: [namespace, CORE_EVENT_NAMESPACE],
|
|
153
141
|
})
|
|
154
142
|
|
|
155
143
|
this.ui.reset()
|
|
156
144
|
}
|
|
157
145
|
|
|
158
|
-
private static
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
private static async fakeGetEventContracts(
|
|
147
|
+
cb?: (
|
|
148
|
+
target?: SpruceSchemas.Mercury.v2020_12_25.GetEventContractsTarget | null
|
|
149
|
+
) => void,
|
|
150
|
+
results?: SpruceSchemas.Mercury.v2020_12_25.GetEventContractsResponsePayload['contracts']
|
|
151
|
+
) {
|
|
152
|
+
await eventFaker.on('get-event-contracts::v2020_12_25', ({ target }) => {
|
|
153
|
+
cb?.(target)
|
|
154
|
+
return {
|
|
155
|
+
contracts: results ?? [...(coreEventContracts as any)],
|
|
156
|
+
}
|
|
163
157
|
})
|
|
164
158
|
}
|
|
165
159
|
|
|
@@ -332,6 +326,29 @@ export default class CreatingAListenerTest extends AbstractEventTest {
|
|
|
332
326
|
await this.Service('typeChecker').check(listenerPath)
|
|
333
327
|
}
|
|
334
328
|
|
|
329
|
+
private static async installAddDependencyExecuteAndWaitForInput(
|
|
330
|
+
namespace: string
|
|
331
|
+
) {
|
|
332
|
+
await this.installEventFeature('events')
|
|
333
|
+
MercuryClientFactory.setIsTestMode(true)
|
|
334
|
+
this.addDependency(namespace)
|
|
335
|
+
await this.executeAndWaitForInput()
|
|
336
|
+
return this.ui.getLastInvocation()
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
private static async executeAndWaitForInput() {
|
|
340
|
+
void this.listen.execute({})
|
|
341
|
+
await this.waitForInput()
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
private static addDependency(namespace: string) {
|
|
345
|
+
const dependencies = this.Service('dependency')
|
|
346
|
+
dependencies.add({
|
|
347
|
+
id: namespace,
|
|
348
|
+
namespace: 'waka',
|
|
349
|
+
})
|
|
350
|
+
}
|
|
351
|
+
|
|
335
352
|
private static async installEventsAndCreateListener() {
|
|
336
353
|
const cli = await this.installEventFeature('events')
|
|
337
354
|
|
|
@@ -24,7 +24,7 @@ import { FeatureActionResponse } from '../../features.types'
|
|
|
24
24
|
import { FetchContractsOptions } from '../stores/EventStore'
|
|
25
25
|
|
|
26
26
|
const SKILL_EVENT_NAMESPACE = 'skill'
|
|
27
|
-
const CORE_EVENT_NAMESPACE =
|
|
27
|
+
export const CORE_EVENT_NAMESPACE = MERCURY_API_NAMESPACE
|
|
28
28
|
|
|
29
29
|
type OptionsSchema =
|
|
30
30
|
SpruceSchemas.SpruceCli.v2020_07_22.ListenEventOptionsSchema
|
|
@@ -164,7 +164,7 @@ export default class ListenAction extends AbstractAction<OptionsSchema> {
|
|
|
164
164
|
namespace !== SKILL_EVENT_NAMESPACE &&
|
|
165
165
|
namespace !== CORE_EVENT_NAMESPACE
|
|
166
166
|
? [namespace]
|
|
167
|
-
: this.getDependencyNamespaces()
|
|
167
|
+
: [...this.getDependencyNamespaces(), 'mercury']
|
|
168
168
|
|
|
169
169
|
const options: FetchContractsOptions = {
|
|
170
170
|
didUpdateHandler: (msg: string) => this.ui.startLoading(msg),
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from '@sprucelabs/schema'
|
|
9
9
|
import {
|
|
10
10
|
personSchema,
|
|
11
|
-
profileImageSchema,
|
|
12
11
|
skillSchema,
|
|
13
12
|
skillCreatorSchema,
|
|
14
13
|
locationSchema,
|
|
@@ -34,7 +33,6 @@ import { InternalUpdateHandler } from '../../../types/cli.types'
|
|
|
34
33
|
|
|
35
34
|
export const coreSchemas = {
|
|
36
35
|
personSchema,
|
|
37
|
-
profileImageSchema,
|
|
38
36
|
skillSchema,
|
|
39
37
|
skillCreatorSchema,
|
|
40
38
|
locationSchema,
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { profileImageSchema as default } from '@sprucelabs/spruce-core-schemas';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _spruceCoreSchemas.profileImageSchema;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
var _spruceCoreSchemas = require("@sprucelabs/spruce-core-schemas");
|
|
14
|
-
//# sourceMappingURL=profileImage.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profileImage.schema.js","names":[],"sources":["../../../../../src/.spruce/schemas/spruce/v2020_07_22/profileImage.schema.ts"],"sourcesContent":["export { profileImageSchema as default } from '@sprucelabs/spruce-core-schemas'\n"],"mappings":";;;;;;;;;;;;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { profileImageSchema as default } from '@sprucelabs/spruce-core-schemas'
|