@sprucelabs/spruce-cli 14.29.5 → 14.29.6

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/PkgService.ts"],"names":["PkgService","path","contents","readPackage","options","value","updated","destination","buildPath","fs","outputFileSync","JSON","stringify","_parsedPkg","undefined","diskUtil","doesFileExist","set","packagePath","readFileSync","toString","parsed","parse","err","SpruceError","code","file","originalError","pathUtil","join","cwd","pkg","dependencies","devDependencies","e","shouldCleanupLockFiles","deleteLockFile","bind","execute","args","totalInstalled","totalSkipped","packages","Array","isArray","toInstall","labsModules","thisPackage","isInstalled","shouldForceInstall","startsWith","push","stripLatest","buildCommandAndArgs","executable","doesDirExist","length","files","lock","deleteFile","install","name","replace","dep","version","createRandomTempDir","filter","a","isDev","CommandService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;IAQqBA,U;;;;;;;;;;;;;;;;;;;;;WAGpB,aAAWC,IAAX,EAAoC;AACnC,UAAMC,QAAQ,GAAG,KAAKC,WAAL,EAAjB;AACA,aAAO,iBAAID,QAAJ,EAAcD,IAAd,CAAP;AACA;;;WAED,aAAWG,OAAX,EAGG;AACF,UAAQH,IAAR,GAAwBG,OAAxB,CAAQH,IAAR;AAAA,UAAcI,KAAd,GAAwBD,OAAxB,CAAcC,KAAd;AACA,UAAMH,QAAQ,GAAG,KAAKC,WAAL,EAAjB;AACA,UAAMG,OAAO,GAAG,iBAAIJ,QAAJ,EAAcD,IAAd,EAAoBI,KAApB,CAAhB;AACA,UAAME,WAAW,GAAG,KAAKC,SAAL,EAApB;;AAEAC,0BAAGC,cAAH,CAAkBH,WAAlB,EAA+BI,IAAI,CAACC,SAAL,CAAeN,OAAf,EAAwB,IAAxB,EAA8B,CAA9B,CAA/B;;AACA,WAAKO,UAAL,GAAkBC,SAAlB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athUtil from 'path'\nimport { diskUtil } from '@sprucelabs/spruce-skill-utils'\nimport fs from 'fs-extra'\nimport { set, get } from 'lodash'\nimport SpruceError from '../errors/SpruceError'\nimport { NpmPackage } from '../types/cli.types'\nimport isCi from '../utilities/isCi'\nimport CommandService from './CommandService'\n\nexport interface AddOptions {\n\tisDev?: boolean\n\tshouldForceInstall?: boolean\n\tshouldCleanupLockFiles?: boolean\n}\n\nexport default class PkgService extends CommandService {\n\tprivate _parsedPkg?: Record<string, any>\n\n\tpublic get(path: string | string[]) {\n\t\tconst contents = this.readPackage()\n\t\treturn get(contents, path)\n\t}\n\n\tpublic set(options: {\n\t\tpath: string | string[]\n\t\tvalue: string | Record<string, any> | undefined\n\t}) {\n\t\tconst { path, value } = options\n\t\tconst contents = this.readPackage()\n\t\tconst updated = set(contents, path, value)\n\t\tconst destination = this.buildPath()\n\n\t\tfs.outputFileSync(destination, JSON.stringify(updated, null, 2))\n\t\tthis._parsedPkg = undefined\n\t}\n\n\tpublic doesExist() {\n\t\treturn diskUtil.doesFileExist(this.buildPath())\n\t}\n\n\tpublic unset(path: string | string[]) {\n\t\tthis.set({ path, value: undefined })\n\t}\n\n\tpublic readPackage(): Record<string, any | undefined> {\n\t\tif (this._parsedPkg) {\n\t\t\treturn this._parsedPkg\n\t\t}\n\t\tconst packagePath = this.buildPath()\n\n\t\ttry {\n\t\t\tconst contents = fs.readFileSync(packagePath).toString()\n\t\t\tconst parsed = JSON.parse(contents)\n\t\t\tthis._parsedPkg = parsed\n\n\t\t\treturn parsed\n\t\t} catch (err: any) {\n\t\t\tthrow new SpruceError({\n\t\t\t\tcode: 'FAILED_TO_IMPORT',\n\t\t\t\tfile: packagePath,\n\t\t\t\toriginalError: err,\n\t\t\t})\n\t\t}\n\t}\n\n\tprivate buildPath() {\n\t\treturn pathUtil.join(this.cwd, 'package.json')\n\t}\n\n\tpublic isInstalled(pkg: string) {\n\t\ttry {\n\t\t\tconst contents = this.readPackage()\n\n\t\t\treturn !!contents.dependencies?.[pkg] || !!contents.devDependencies?.[pkg]\n\t\t} catch (e) {\n\t\t\treturn false\n\t\t}\n\t}\n\n\tpublic async install(pkg?: string[] | string, options?: AddOptions) {\n\t\tconst shouldCleanupLockFiles = options?.shouldCleanupLockFiles !== false\n\t\tconst deleteLockFile = shouldCleanupLockFiles\n\t\t\t? this.deleteLockFile.bind(this)\n\t\t\t: () => {}\n\n\t\tif (!pkg) {\n\t\t\tawait this.execute('yarn', { args: ['install'] })\n\t\t\tdeleteLockFile()\n\t\t\treturn { totalInstalled: -1, totalSkipped: -1 }\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst toInstall = []\n\t\tconst labsModules: string[] = []\n\n\t\tlet totalInstalled = 0\n\t\tlet totalSkipped = 0\n\n\t\tfor (const thisPackage of packages) {\n\t\t\tconst isInstalled =\n\t\t\t\t!options?.shouldForceInstall && this.isInstalled(thisPackage)\n\t\t\tif (thisPackage.startsWith('@sprucelabs/') || !isInstalled) {\n\t\t\t\ttoInstall.push(this.stripLatest(thisPackage))\n\t\t\t\ttotalInstalled++\n\t\t\t} else {\n\t\t\t\ttotalSkipped++\n\t\t\t}\n\t\t}\n\n\t\tif (totalInstalled > 0) {\n\t\t\tconst { executable, args } = PkgService.buildCommandAndArgs(\n\t\t\t\ttoInstall,\n\t\t\t\toptions\n\t\t\t)\n\n\t\t\tawait this.execute(executable, {\n\t\t\t\targs,\n\t\t\t})\n\t\t} else if (\n\t\t\t!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))\n\t\t) {\n\t\t\tawait this.execute('yarn', { args: ['install'] })\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tthis._parsedPkg = undefined\n\n\t\treturn { totalInstalled: totalInstalled + labsModules.length, totalSkipped }\n\t}\n\n\tpublic static buildCommandAndArgs(\n\t\ttoInstall: string[],\n\t\toptions: AddOptions | undefined\n\t) {\n\t\tconst args: any[] = [\n\t\t\tisCi() && '--cache-folder',\n\t\t\tisCi() && diskUtil.createRandomTempDir(),\n\t\t\t'add',\n\t\t\t...toInstall,\n\t\t].filter((a) => !!a)\n\n\t\tif (options?.isDev) {\n\t\t\targs.push('-D')\n\t\t}\n\n\t\tconst executable = 'yarn'\n\t\treturn { executable, args }\n\t}\n\n\tpublic deleteLockFile() {\n\t\tconst files = ['package-lock.json', 'yarn.lock']\n\t\tfor (const file of files) {\n\t\t\tconst lock = pathUtil.join(this.cwd, file)\n\t\t\tif (diskUtil.doesFileExist(lock)) {\n\t\t\t\tdiskUtil.deleteFile(lock)\n\t\t\t}\n\t\t}\n\t}\n\n\tpublic async uninstall(pkg: string[] | string) {\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst args: string[] = ['uninstall', ...packages]\n\t\tawait this.execute('npm', {\n\t\t\targs,\n\t\t})\n\n\t\tthis._parsedPkg = undefined\n\n\t\tawait this.install()\n\t}\n\n\tpublic stripLatest(name: string): string {\n\t\treturn name.replace('@latest', '')\n\t}\n\n\tpublic buildPackageName(dep: NpmPackage): string {\n\t\tconst { name, version } = dep\n\t\tif (!version) {\n\t\t\treturn name\n\t\t}\n\n\t\treturn `${name}@${version}`\n\t}\n}\n"],"file":"PkgService.js"}
1
+ {"version":3,"sources":["../../src/services/PkgService.ts"],"names":["PkgService","cwd","commandService","pkg","options","shouldCleanupLockFiles","deleteLockFile","bind","execute","args","totalInstalled","totalSkipped","packages","Array","isArray","toInstall","labsModules","thisPackage","isInstalled","shouldForceInstall","startsWith","push","stripLatest","buildCommandAndArgs","executable","diskUtil","doesDirExist","pathUtil","join","_parsedPkg","undefined","length","install","createRandomTempDir","filter","a","isDev","BasePkgService"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;AAIA;;;;;;;;;;;;IASqBA,U;;;;;AAGpB,sBAAmBC,GAAnB,EAAgCC,cAAhC,EAAgE;AAAA;;AAAA;AAC/D,8BAAMD,GAAN;AAD+D;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A,uBAGO,KAAKV,cAAL,CAAoBM,OAApB,CAA4B,KAA5B,EAAmC;AACxCC,kBAAAA,IAAI,EAAJA;AADwC,iBAAnC,CAHP;;AAAA;AAOC,qBAAKoB,UAAL,GAAkBC,SAAlB;AAPD;AAAA,uBASO,KAAKE,OAAL,EATP;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,O;;;;;;;;;;WAnBA,6BACCjB,SADD,EAECX,OAFD,EAGE;AACD,UAAMK,IAAW,GAAG,CACnB,2BAAU,gBADS,EAEnB,2BAAUgB,2BAASQ,mBAAT,EAFS,EAGnB,KAHmB,6CAIhBlB,SAJgB,GAKlBmB,MALkB,CAKX,UAACC,CAAD;AAAA,eAAO,CAAC,CAACA,CAAT;AAAA,OALW,CAApB;;AAOA,UAAI/B,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEgC,KAAb,EAAoB;AACnB3B,QAAAA,IAAI,CAACY,IAAL,CAAU,IAAV;AACA;;AAED,UAAMG,UAAU,GAAG,MAAnB;AACA,aAAO;AAAEA,QAAAA,UAAU,EAAVA,UAAF;AAAcf,QAAAA,IAAI,EAAJA;AAAd,OAAP;AACA;;;EA/EsC4B,4B","sourcesContent":["import pathUtil from 'path'\nimport {\n\tdiskUtil,\n\tPkgService as BasePkgService,\n} from '@sprucelabs/spruce-skill-utils'\nimport isCi from '../utilities/isCi'\nimport CommandService from './CommandService'\n\nexport interface AddOptions {\n\tisDev?: boolean\n\tshouldForceInstall?: boolean\n\tshouldCleanupLockFiles?: boolean\n}\n\nexport default class PkgService extends BasePkgService {\n\tprivate commandService: CommandService\n\n\tpublic constructor(cwd: string, commandService: CommandService) {\n\t\tsuper(cwd)\n\t\tthis.commandService = commandService\n\t}\n\n\tpublic async install(pkg?: string[] | string, options?: AddOptions) {\n\t\tconst shouldCleanupLockFiles = options?.shouldCleanupLockFiles !== false\n\t\tconst deleteLockFile = shouldCleanupLockFiles\n\t\t\t? this.deleteLockFile.bind(this)\n\t\t\t: () => {}\n\n\t\tif (!pkg) {\n\t\t\tawait this.commandService.execute('yarn', { args: ['install'] })\n\t\t\tdeleteLockFile()\n\t\t\treturn { totalInstalled: -1, totalSkipped: -1 }\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst toInstall = []\n\t\tconst labsModules: string[] = []\n\n\t\tlet totalInstalled = 0\n\t\tlet totalSkipped = 0\n\n\t\tfor (const thisPackage of packages) {\n\t\t\tconst isInstalled =\n\t\t\t\t!options?.shouldForceInstall && this.isInstalled(thisPackage)\n\t\t\tif (thisPackage.startsWith('@sprucelabs/') || !isInstalled) {\n\t\t\t\ttoInstall.push(this.stripLatest(thisPackage))\n\t\t\t\ttotalInstalled++\n\t\t\t} else {\n\t\t\t\ttotalSkipped++\n\t\t\t}\n\t\t}\n\n\t\tif (totalInstalled > 0) {\n\t\t\tconst { executable, args } = PkgService.buildCommandAndArgs(\n\t\t\t\ttoInstall,\n\t\t\t\toptions\n\t\t\t)\n\n\t\t\tawait this.commandService.execute(executable, {\n\t\t\t\targs,\n\t\t\t})\n\t\t} else if (\n\t\t\t!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))\n\t\t) {\n\t\t\tawait this.commandService.execute('yarn', { args: ['install'] })\n\t\t}\n\n\t\tdeleteLockFile()\n\n\t\tthis._parsedPkg = undefined\n\n\t\treturn { totalInstalled: totalInstalled + labsModules.length, totalSkipped }\n\t}\n\n\tpublic static buildCommandAndArgs(\n\t\ttoInstall: string[],\n\t\toptions: AddOptions | undefined\n\t) {\n\t\tconst args: any[] = [\n\t\t\tisCi() && '--cache-folder',\n\t\t\tisCi() && diskUtil.createRandomTempDir(),\n\t\t\t'add',\n\t\t\t...toInstall,\n\t\t].filter((a) => !!a)\n\n\t\tif (options?.isDev) {\n\t\t\targs.push('-D')\n\t\t}\n\n\t\tconst executable = 'yarn'\n\t\treturn { executable, args }\n\t}\n\n\tpublic async uninstall(pkg: string[] | string) {\n\t\tconst packages = Array.isArray(pkg) ? pkg : [pkg]\n\t\tconst args: string[] = ['uninstall', ...packages]\n\t\tawait this.commandService.execute('npm', {\n\t\t\targs,\n\t\t})\n\n\t\tthis._parsedPkg = undefined\n\n\t\tawait this.install()\n\t}\n}\n"],"file":"PkgService.js"}
@@ -1,9 +1,8 @@
1
- import { SettingsService, EnvService } from '@sprucelabs/spruce-skill-utils';
1
+ import { SettingsService, EnvService, AuthService } from '@sprucelabs/spruce-skill-utils';
2
2
  import EventSettingsService from '../features/event/services/EventSettingsService';
3
3
  import RemoteService from '../features/event/services/RemoteService';
4
4
  import SchemaService from '../features/schema/services/SchemaService';
5
5
  import VsCodeService from '../features/vscode/services/VsCodeService';
6
- import AuthService from './AuthService';
7
6
  import BuildService from './BuildService';
8
7
  import CommandService from './CommandService';
9
8
  import DependencyService from './DependencyService';
@@ -21,8 +21,6 @@ var _SchemaService = _interopRequireDefault(require("../features/schema/services
21
21
 
22
22
  var _VsCodeService = _interopRequireDefault(require("../features/vscode/services/VsCodeService"));
23
23
 
24
- var _AuthService = _interopRequireDefault(require("./AuthService"));
25
-
26
24
  var _BuildService = _interopRequireDefault(require("./BuildService"));
27
25
 
28
26
  var _CommandService = _interopRequireDefault(require("./CommandService"));
@@ -59,10 +57,10 @@ var ServiceFactory = /*#__PURE__*/function () {
59
57
 
60
58
  switch (type) {
61
59
  case 'auth':
62
- return new _AuthService["default"](new _spruceSkillUtils.EnvService(cwd), new _PkgService["default"](cwd));
60
+ return _spruceSkillUtils.AuthService.Auth(cwd);
63
61
 
64
62
  case 'pkg':
65
- return new _PkgService["default"](cwd);
63
+ return new _PkgService["default"](cwd, this.Service(cwd, 'command'));
66
64
 
67
65
  case 'env':
68
66
  return new _spruceSkillUtils.EnvService(cwd);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/services/ServiceFactory.ts"],"names":["ServiceFactory","cwd","type","AuthService","EnvService","PkgService","VsCodeService","SchemaService","command","CommandService","LintService","Service","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"mappings":";;;;;;;;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;AAAA;;AACtE,cAAQA,IAAR;AACC,aAAK,MAAL;AACC,iBAAO,IAAIC,uBAAJ,CACN,IAAIC,4BAAJ,CAAeH,GAAf,CADM,EAEN,IAAII,sBAAJ,CAAeJ,GAAf,CAFM,CAAP;;AAID,aAAK,KAAL;AACC,iBAAO,IAAII,sBAAJ,CAAeJ,GAAf,CAAP;;AACD,aAAK,KAAL;AACC,iBAAO,IAAIG,4BAAJ,CAAeH,GAAf,CAAP;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIK,yBAAJ,CAAkBL,GAAlB,CAAP;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIM,yBAAJ,CAAkB;AACxBN,YAAAA,GAAG,EAAHA,GADwB;AAExBO,YAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBR,GAAnB;AAFe,WAAlB,CAAP;;AAID,aAAK,MAAL;AACC,iBAAO,IAAIS,uBAAJ,CAAgBT,GAAhB,EAAqB;AAAA,mBAC3B,KAAI,CAACU,OAAL,CAAaV,GAAb,EAAkB,SAAlB,CAD2B;AAAA,WAArB,CAAP;;AAGD,aAAK,SAAL;AAAgB;AACf,mBAAO,IAAIQ,0BAAJ,CAAmBR,GAAnB,CAAP;AACA;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIW,yBAAJ,CAAkB,IAAIR,4BAAJ,CAAeH,GAAf,CAAlB,CAAP;;AACD,aAAK,aAAL;AACC,iBAAO,IAAIY,8BAAJ,CACN,KAAKC,kBAAL,CAAwBb,GAAxB,CADM,CAAP;;AAGD,aAAK,UAAL;AACC,iBAAO,IAAIc,iCAAJ,CAAiCd,GAAjC,CAAP;;AACD,aAAK,YAAL;AACC,iBAAO,IAAIe,6BAAJ,CACN,IAAID,iCAAJ,CAAiCd,GAAjC,CADM,CAAP;;AAGD,aAAK,QAAL;AACC,iBAAO,KAAKa,kBAAL,CAAwBb,GAAxB,CAAP;;AACD,aAAK,OAAL;AAAc;AACb,gBAAMgB,cAAc,GAAG,IAAIR,0BAAJ,CAAmBR,GAAnB,CAAvB;AACA,mBAAO,IAAIiB,wBAAJ,CACND,cADM,EAEN,IAAIP,uBAAJ,CAAgBT,GAAhB,EAAqB;AAAA,qBAAM,KAAI,CAACU,OAAL,CAAaV,GAAb,EAAkB,SAAlB,CAAN;AAAA,aAArB,CAFM,CAAP;AAIA;;AACD,aAAK,eAAL;AACC,iBAAO,IAAIkB,gCAAJ,CACN,IAAIJ,iCAAJ,CAAoBd,GAApB,CADM,CAAP;;AAGD;AACC,gBAAM,IAAImB,KAAJ,qBAAsBlB,IAAtB,kBAAN;AAlDF;AAoDA,K;;;WAED,4BAA2BD,GAA3B,EAAuD;AACtD,aAAO,IAAIoB,yBAAJ,CAAkB;AACxBpB,QAAAA,GAAG,EAAHA,GADwB;AAExBO,QAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBR,GAAnB;AAFe,OAAlB,CAAP;AAIA","sourcesContent":["import { SettingsService, EnvService } from '@sprucelabs/spruce-skill-utils'\nimport EventSettingsService from '../features/event/services/EventSettingsService'\nimport RemoteService from '../features/event/services/RemoteService'\nimport { FeatureCode } from '../features/features.types'\nimport SchemaService from '../features/schema/services/SchemaService'\nimport VsCodeService from '../features/vscode/services/VsCodeService'\nimport AuthService from './AuthService'\nimport BuildService from './BuildService'\nimport CommandService from './CommandService'\nimport DependencyService from './DependencyService'\nimport ImportService from './ImportService'\nimport LintService from './LintService'\nimport PkgService from './PkgService'\nimport TypeCheckerService from './TypeCheckerService'\n\nexport interface ServiceMap {\n\tpkg: PkgService\n\tvsCode: VsCodeService\n\tschema: SchemaService\n\tlint: LintService\n\tcommand: CommandService\n\ttypeChecker: TypeCheckerService\n\timport: ImportService\n\tbuild: BuildService\n\tsettings: SettingsService\n\tenv: EnvService\n\tauth: AuthService\n\tremote: RemoteService\n\teventSettings: EventSettingsService\n\tdependency: DependencyService\n}\n\nexport type Service = keyof ServiceMap\n\nexport interface ServiceProvider {\n\tService<S extends Service>(type: S, cwd?: string): ServiceMap[S]\n}\nexport default class ServiceFactory {\n\tpublic Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {\n\t\tswitch (type) {\n\t\t\tcase 'auth':\n\t\t\t\treturn new AuthService(\n\t\t\t\t\tnew EnvService(cwd),\n\t\t\t\t\tnew PkgService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(cwd) as ServiceMap[S]\n\t\t\tcase 'env':\n\t\t\t\treturn new EnvService(cwd) as ServiceMap[S]\n\t\t\tcase 'vsCode':\n\t\t\t\treturn new VsCodeService(cwd) as ServiceMap[S]\n\t\t\tcase 'schema':\n\t\t\t\treturn new SchemaService({\n\t\t\t\t\tcwd,\n\t\t\t\t\tcommand: new CommandService(cwd),\n\t\t\t\t}) as ServiceMap[S]\n\t\t\tcase 'lint':\n\t\t\t\treturn new LintService(cwd, () =>\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'command': {\n\t\t\t\treturn new CommandService(cwd) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'remote':\n\t\t\t\treturn new RemoteService(new EnvService(cwd)) as ServiceMap[S]\n\t\t\tcase 'typeChecker':\n\t\t\t\treturn new TypeCheckerService(\n\t\t\t\t\tthis.buildImportService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'settings':\n\t\t\t\treturn new SettingsService<FeatureCode>(cwd) as ServiceMap[S]\n\t\t\tcase 'dependency':\n\t\t\t\treturn new DependencyService(\n\t\t\t\t\tnew SettingsService<FeatureCode>(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'import':\n\t\t\t\treturn this.buildImportService(cwd) as ServiceMap[S]\n\t\t\tcase 'build': {\n\t\t\t\tconst commandService = new CommandService(cwd)\n\t\t\t\treturn new BuildService(\n\t\t\t\t\tcommandService,\n\t\t\t\t\tnew LintService(cwd, () => this.Service(cwd, 'command'))\n\t\t\t\t) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'eventSettings':\n\t\t\t\treturn new EventSettingsService(\n\t\t\t\t\tnew SettingsService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Service \"${type}\" not found`)\n\t\t}\n\t}\n\n\tprivate buildImportService(cwd: string): ImportService {\n\t\treturn new ImportService({\n\t\t\tcwd,\n\t\t\tcommand: new CommandService(cwd),\n\t\t})\n\t}\n}\n"],"file":"ServiceFactory.js"}
1
+ {"version":3,"sources":["../../src/services/ServiceFactory.ts"],"names":["ServiceFactory","cwd","type","AuthService","Auth","PkgService","Service","EnvService","VsCodeService","SchemaService","command","CommandService","LintService","RemoteService","TypeCheckerService","buildImportService","SettingsService","DependencyService","commandService","BuildService","EventSettingsService","Error","ImportService"],"mappings":";;;;;;;;;;;;;AAAA;;AAKA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;IAwBqBA,c;;;;;;;;;;;;;;;;;MACpB,UAAkCC,GAAlC,EAA+CC,IAA/C,EAAuE;AAAA;;AACtE,cAAQA,IAAR;AACC,aAAK,MAAL;AACC,iBAAOC,8BAAYC,IAAZ,CAAiBH,GAAjB,CAAP;;AACD,aAAK,KAAL;AACC,iBAAO,IAAII,sBAAJ,CACNJ,GADM,EAEN,KAAKK,OAAL,CAAaL,GAAb,EAAkB,SAAlB,CAFM,CAAP;;AAID,aAAK,KAAL;AACC,iBAAO,IAAIM,4BAAJ,CAAeN,GAAf,CAAP;;AACD,aAAK,QAAL;AACC,iBAAO,IAAIO,yBAAJ,CAAkBP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B,IAAtB,kBAAN;AAlDF;AAoDA,K;;;WAED,4BAA2BD,GAA3B,EAAuD;AACtD,aAAO,IAAIqB,yBAAJ,CAAkB;AACxBrB,QAAAA,GAAG,EAAHA,GADwB;AAExBS,QAAAA,OAAO,EAAE,IAAIC,0BAAJ,CAAmBV,GAAnB;AAFe,OAAlB,CAAP;AAIA","sourcesContent":["import {\n\tSettingsService,\n\tEnvService,\n\tAuthService,\n} from '@sprucelabs/spruce-skill-utils'\nimport EventSettingsService from '../features/event/services/EventSettingsService'\nimport RemoteService from '../features/event/services/RemoteService'\nimport { FeatureCode } from '../features/features.types'\nimport SchemaService from '../features/schema/services/SchemaService'\nimport VsCodeService from '../features/vscode/services/VsCodeService'\nimport BuildService from './BuildService'\nimport CommandService from './CommandService'\nimport DependencyService from './DependencyService'\nimport ImportService from './ImportService'\nimport LintService from './LintService'\nimport PkgService from './PkgService'\nimport TypeCheckerService from './TypeCheckerService'\n\nexport interface ServiceMap {\n\tpkg: PkgService\n\tvsCode: VsCodeService\n\tschema: SchemaService\n\tlint: LintService\n\tcommand: CommandService\n\ttypeChecker: TypeCheckerService\n\timport: ImportService\n\tbuild: BuildService\n\tsettings: SettingsService\n\tenv: EnvService\n\tauth: AuthService\n\tremote: RemoteService\n\teventSettings: EventSettingsService\n\tdependency: DependencyService\n}\n\nexport type Service = keyof ServiceMap\n\nexport interface ServiceProvider {\n\tService<S extends Service>(type: S, cwd?: string): ServiceMap[S]\n}\nexport default class ServiceFactory {\n\tpublic Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {\n\t\tswitch (type) {\n\t\t\tcase 'auth':\n\t\t\t\treturn AuthService.Auth(cwd) as ServiceMap[S]\n\t\t\tcase 'pkg':\n\t\t\t\treturn new PkgService(\n\t\t\t\t\tcwd,\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'env':\n\t\t\t\treturn new EnvService(cwd) as ServiceMap[S]\n\t\t\tcase 'vsCode':\n\t\t\t\treturn new VsCodeService(cwd) as ServiceMap[S]\n\t\t\tcase 'schema':\n\t\t\t\treturn new SchemaService({\n\t\t\t\t\tcwd,\n\t\t\t\t\tcommand: new CommandService(cwd),\n\t\t\t\t}) as ServiceMap[S]\n\t\t\tcase 'lint':\n\t\t\t\treturn new LintService(cwd, () =>\n\t\t\t\t\tthis.Service(cwd, 'command')\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'command': {\n\t\t\t\treturn new CommandService(cwd) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'remote':\n\t\t\t\treturn new RemoteService(new EnvService(cwd)) as ServiceMap[S]\n\t\t\tcase 'typeChecker':\n\t\t\t\treturn new TypeCheckerService(\n\t\t\t\t\tthis.buildImportService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'settings':\n\t\t\t\treturn new SettingsService<FeatureCode>(cwd) as ServiceMap[S]\n\t\t\tcase 'dependency':\n\t\t\t\treturn new DependencyService(\n\t\t\t\t\tnew SettingsService<FeatureCode>(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tcase 'import':\n\t\t\t\treturn this.buildImportService(cwd) as ServiceMap[S]\n\t\t\tcase 'build': {\n\t\t\t\tconst commandService = new CommandService(cwd)\n\t\t\t\treturn new BuildService(\n\t\t\t\t\tcommandService,\n\t\t\t\t\tnew LintService(cwd, () => this.Service(cwd, 'command'))\n\t\t\t\t) as ServiceMap[S]\n\t\t\t}\n\t\t\tcase 'eventSettings':\n\t\t\t\treturn new EventSettingsService(\n\t\t\t\t\tnew SettingsService(cwd)\n\t\t\t\t) as ServiceMap[S]\n\t\t\tdefault:\n\t\t\t\tthrow new Error(`Service \"${type}\" not found`)\n\t\t}\n\t}\n\n\tprivate buildImportService(cwd: string): ImportService {\n\t\treturn new ImportService({\n\t\t\tcwd,\n\t\t\tcommand: new CommandService(cwd),\n\t\t})\n\t}\n}\n"],"file":"ServiceFactory.js"}
@@ -1,6 +1,7 @@
1
1
  import { SpruceSchemas } from "./../.spruce/schemas/schemas.types";
2
2
  import { FeatureAction, FeatureActionResponse } from '../features/features.types';
3
3
  import { GraphicsInterface as IGraphicsInterface } from './graphicsInterface.types';
4
+ export { NpmPackage } from '@sprucelabs/spruce-skill-utils';
4
5
  export interface GraphicsInterface extends IGraphicsInterface {
5
6
  renderActionSummary(results: ExecutionResults & {
6
7
  totalTime?: number;
@@ -18,11 +19,6 @@ export interface GraphicsInterface extends IGraphicsInterface {
18
19
  export declare type GeneratedFile = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile;
19
20
  export declare type GeneratedDir = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedDir;
20
21
  export declare type GeneratedFileOrDir = SpruceSchemas.SpruceCli.v2020_07_22.WatcherDidDetectChangesEmitPayload['changes'][number];
21
- export interface NpmPackage {
22
- name: string;
23
- version?: string;
24
- isDev?: boolean;
25
- }
26
22
  export interface ExecutionResults extends FeatureActionResponse {
27
23
  featureCode: string;
28
24
  actionCode: string;
@@ -50,4 +46,3 @@ export interface OptionOverrides {
50
46
  export interface BlockedCommands {
51
47
  [command: string]: string;
52
48
  }
53
- export {};
@@ -3,4 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "NpmPackage", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _spruceSkillUtils.NpmPackage;
10
+ }
11
+ });
12
+
13
+ var _spruceSkillUtils = require("@sprucelabs/spruce-skill-utils");
6
14
  //# sourceMappingURL=cli.types.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"cli.types.js"}
1
+ {"version":3,"sources":["../../src/types/cli.types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAMA","sourcesContent":["import { SpruceSchemas } from '#spruce/schemas/schemas.types'\nimport {\n\tFeatureAction,\n\tFeatureActionResponse,\n} from '../features/features.types'\nimport { GraphicsInterface as IGraphicsInterface } from './graphicsInterface.types'\nexport { NpmPackage } from '@sprucelabs/spruce-skill-utils'\n\nexport interface GraphicsInterface extends IGraphicsInterface {\n\trenderActionSummary(results: ExecutionResults & { totalTime?: number }): void\n\tgetCursorPosition(): Promise<{ x: number; y: number } | null>\n\tmoveCursorTo(x: number, y: number): void\n\tclearBelowCursor(): void\n\tclear(): void\n\twaitForEnter(message?: string): Promise<void>\n\tsendInput(message: string): Promise<void>\n}\n\nexport type GeneratedFile = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedFile\nexport type GeneratedDir = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedDir\nexport type GeneratedFileOrDir =\n\tSpruceSchemas.SpruceCli.v2020_07_22.WatcherDidDetectChangesEmitPayload['changes'][number]\n\nexport interface ExecutionResults extends FeatureActionResponse {\n\tfeatureCode: string\n\tactionCode: string\n\theadline: string\n\taction: FeatureAction\n}\n\ntype Skill = Omit<SpruceSchemas.Spruce.v2020_07_22.Skill, 'creators'>\n\nexport type CurrentSkill = Partial<Skill> & {\n\tname: string\n\tisRegistered: boolean\n\tnamespacePascal: string\n}\n\nexport type RegisteredSkill = Omit<\n\tSpruceSchemas.Spruce.v2020_07_22.Skill,\n\t'creators'\n>\n\nexport type UpgradeMode =\n\tSpruceSchemas.SpruceCli.v2020_07_22.UpgradeSkillOptions['upgradeMode']\n\nexport type FileDescription = {\n\tpath: string\n\tdescription: string\n\tshouldOverwriteWhenChanged: boolean\n\tconfirmPromptOnFirstWrite?: string\n}\n\nexport type InternalUpdateHandler = (message: string) => void\n\nexport interface OptionOverrides {\n\t[command: string]: Record<string, any>\n}\n\nexport interface BlockedCommands {\n\t[command: string]: string\n}\n"],"file":"cli.types.js"}
package/package.json CHANGED
@@ -18,7 +18,7 @@
18
18
  ]
19
19
  },
20
20
  "license": "MIT",
21
- "version": "14.29.5",
21
+ "version": "14.29.6",
22
22
  "bin": {
23
23
  "spruce": "./build/index.js"
24
24
  },
@@ -87,8 +87,8 @@
87
87
  "@sprucelabs/spruce-event-plugin": "^18.3.3",
88
88
  "@sprucelabs/spruce-event-utils": "^17.1.339",
89
89
  "@sprucelabs/spruce-skill-booter": "^18.3.3",
90
- "@sprucelabs/spruce-skill-utils": "^22.1.89",
91
- "@sprucelabs/spruce-templates": "^14.29.5",
90
+ "@sprucelabs/spruce-skill-utils": "^22.2.3",
91
+ "@sprucelabs/spruce-templates": "^14.29.6",
92
92
  "@typescript-eslint/eslint-plugin": "^5.6.0",
93
93
  "@typescript-eslint/parser": "^5.6.0",
94
94
  "cfonts": "^2.10.0",
@@ -597,5 +597,5 @@
597
597
  "ora"
598
598
  ]
599
599
  },
600
- "gitHead": "8ccb47496479c9a30dfcf462d76456b6ad6552ed"
600
+ "gitHead": "7e3cfb4f6c0edf37269de5d431eec3b3f19fd3c1"
601
601
  }
@@ -15,8 +15,7 @@ export default class PkgServiceTest extends AbstractSkillTest {
15
15
 
16
16
  @test()
17
17
  protected static async canCreatePkgService() {
18
- const pkg = PkgServiceTest.beforeEach()
19
- assert.isTruthy(pkg)
18
+ assert.isTruthy(this.pkg)
20
19
  }
21
20
 
22
21
  @test()
package/src/cli.ts CHANGED
@@ -361,6 +361,9 @@ export default class Cli implements CliInterface {
361
361
 
362
362
  let auth: SpruceSchemas.Mercury.v2020_12_25.AuthenticateEmitPayload = {}
363
363
 
364
+ const pkg = serviceFactory.Service(cwd, 'pkg')
365
+ const doesPkgExist = pkg.doesExist()
366
+
364
367
  if (options?.skillId && options?.apiKey) {
365
368
  auth = {
366
369
  skillId: options.skillId,
@@ -375,7 +378,7 @@ export default class Cli implements CliInterface {
375
378
  apiKey: skill.apiKey,
376
379
  }
377
380
  }
378
- } else if (shouldAuthAsLoggedInPerson) {
381
+ } else if (doesPkgExist && shouldAuthAsLoggedInPerson) {
379
382
  const person = serviceFactory.Service(cwd, 'auth').getLoggedInPerson()
380
383
 
381
384
  if (person) {
@@ -1,7 +1,6 @@
1
1
  import { buildSchema, SchemaValues } from '@sprucelabs/schema'
2
- import { diskUtil, namesUtil } from '@sprucelabs/spruce-skill-utils'
2
+ import { diskUtil, namesUtil, SkillAuth } from '@sprucelabs/spruce-skill-utils'
3
3
  import SpruceError from '../../../errors/SpruceError'
4
- import { SkillAuth } from '../../../services/AuthService'
5
4
  import actionUtil from '../../../utilities/action.utility'
6
5
  import AbstractAction from '../../AbstractAction'
7
6
  import { FeatureActionResponse } from '../../features.types'
@@ -1,9 +1,8 @@
1
1
  import pathUtil from 'path'
2
- import { diskUtil } from '@sprucelabs/spruce-skill-utils'
3
- import fs from 'fs-extra'
4
- import { set, get } from 'lodash'
5
- import SpruceError from '../errors/SpruceError'
6
- import { NpmPackage } from '../types/cli.types'
2
+ import {
3
+ diskUtil,
4
+ PkgService as BasePkgService,
5
+ } from '@sprucelabs/spruce-skill-utils'
7
6
  import isCi from '../utilities/isCi'
8
7
  import CommandService from './CommandService'
9
8
 
@@ -13,68 +12,12 @@ export interface AddOptions {
13
12
  shouldCleanupLockFiles?: boolean
14
13
  }
15
14
 
16
- export default class PkgService extends CommandService {
17
- private _parsedPkg?: Record<string, any>
15
+ export default class PkgService extends BasePkgService {
16
+ private commandService: CommandService
18
17
 
19
- public get(path: string | string[]) {
20
- const contents = this.readPackage()
21
- return get(contents, path)
22
- }
23
-
24
- public set(options: {
25
- path: string | string[]
26
- value: string | Record<string, any> | undefined
27
- }) {
28
- const { path, value } = options
29
- const contents = this.readPackage()
30
- const updated = set(contents, path, value)
31
- const destination = this.buildPath()
32
-
33
- fs.outputFileSync(destination, JSON.stringify(updated, null, 2))
34
- this._parsedPkg = undefined
35
- }
36
-
37
- public doesExist() {
38
- return diskUtil.doesFileExist(this.buildPath())
39
- }
40
-
41
- public unset(path: string | string[]) {
42
- this.set({ path, value: undefined })
43
- }
44
-
45
- public readPackage(): Record<string, any | undefined> {
46
- if (this._parsedPkg) {
47
- return this._parsedPkg
48
- }
49
- const packagePath = this.buildPath()
50
-
51
- try {
52
- const contents = fs.readFileSync(packagePath).toString()
53
- const parsed = JSON.parse(contents)
54
- this._parsedPkg = parsed
55
-
56
- return parsed
57
- } catch (err: any) {
58
- throw new SpruceError({
59
- code: 'FAILED_TO_IMPORT',
60
- file: packagePath,
61
- originalError: err,
62
- })
63
- }
64
- }
65
-
66
- private buildPath() {
67
- return pathUtil.join(this.cwd, 'package.json')
68
- }
69
-
70
- public isInstalled(pkg: string) {
71
- try {
72
- const contents = this.readPackage()
73
-
74
- return !!contents.dependencies?.[pkg] || !!contents.devDependencies?.[pkg]
75
- } catch (e) {
76
- return false
77
- }
18
+ public constructor(cwd: string, commandService: CommandService) {
19
+ super(cwd)
20
+ this.commandService = commandService
78
21
  }
79
22
 
80
23
  public async install(pkg?: string[] | string, options?: AddOptions) {
@@ -84,7 +27,7 @@ export default class PkgService extends CommandService {
84
27
  : () => {}
85
28
 
86
29
  if (!pkg) {
87
- await this.execute('yarn', { args: ['install'] })
30
+ await this.commandService.execute('yarn', { args: ['install'] })
88
31
  deleteLockFile()
89
32
  return { totalInstalled: -1, totalSkipped: -1 }
90
33
  }
@@ -115,13 +58,13 @@ export default class PkgService extends CommandService {
115
58
  options
116
59
  )
117
60
 
118
- await this.execute(executable, {
61
+ await this.commandService.execute(executable, {
119
62
  args,
120
63
  })
121
64
  } else if (
122
65
  !diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))
123
66
  ) {
124
- await this.execute('yarn', { args: ['install'] })
67
+ await this.commandService.execute('yarn', { args: ['install'] })
125
68
  }
126
69
 
127
70
  deleteLockFile()
@@ -150,20 +93,10 @@ export default class PkgService extends CommandService {
150
93
  return { executable, args }
151
94
  }
152
95
 
153
- public deleteLockFile() {
154
- const files = ['package-lock.json', 'yarn.lock']
155
- for (const file of files) {
156
- const lock = pathUtil.join(this.cwd, file)
157
- if (diskUtil.doesFileExist(lock)) {
158
- diskUtil.deleteFile(lock)
159
- }
160
- }
161
- }
162
-
163
96
  public async uninstall(pkg: string[] | string) {
164
97
  const packages = Array.isArray(pkg) ? pkg : [pkg]
165
98
  const args: string[] = ['uninstall', ...packages]
166
- await this.execute('npm', {
99
+ await this.commandService.execute('npm', {
167
100
  args,
168
101
  })
169
102
 
@@ -171,17 +104,4 @@ export default class PkgService extends CommandService {
171
104
 
172
105
  await this.install()
173
106
  }
174
-
175
- public stripLatest(name: string): string {
176
- return name.replace('@latest', '')
177
- }
178
-
179
- public buildPackageName(dep: NpmPackage): string {
180
- const { name, version } = dep
181
- if (!version) {
182
- return name
183
- }
184
-
185
- return `${name}@${version}`
186
- }
187
107
  }
@@ -1,10 +1,13 @@
1
- import { SettingsService, EnvService } from '@sprucelabs/spruce-skill-utils'
1
+ import {
2
+ SettingsService,
3
+ EnvService,
4
+ AuthService,
5
+ } from '@sprucelabs/spruce-skill-utils'
2
6
  import EventSettingsService from '../features/event/services/EventSettingsService'
3
7
  import RemoteService from '../features/event/services/RemoteService'
4
8
  import { FeatureCode } from '../features/features.types'
5
9
  import SchemaService from '../features/schema/services/SchemaService'
6
10
  import VsCodeService from '../features/vscode/services/VsCodeService'
7
- import AuthService from './AuthService'
8
11
  import BuildService from './BuildService'
9
12
  import CommandService from './CommandService'
10
13
  import DependencyService from './DependencyService'
@@ -39,12 +42,12 @@ export default class ServiceFactory {
39
42
  public Service<S extends Service>(cwd: string, type: S): ServiceMap[S] {
40
43
  switch (type) {
41
44
  case 'auth':
42
- return new AuthService(
43
- new EnvService(cwd),
44
- new PkgService(cwd)
45
- ) as ServiceMap[S]
45
+ return AuthService.Auth(cwd) as ServiceMap[S]
46
46
  case 'pkg':
47
- return new PkgService(cwd) as ServiceMap[S]
47
+ return new PkgService(
48
+ cwd,
49
+ this.Service(cwd, 'command')
50
+ ) as ServiceMap[S]
48
51
  case 'env':
49
52
  return new EnvService(cwd) as ServiceMap[S]
50
53
  case 'vsCode':
@@ -4,6 +4,7 @@ import {
4
4
  FeatureActionResponse,
5
5
  } from '../features/features.types'
6
6
  import { GraphicsInterface as IGraphicsInterface } from './graphicsInterface.types'
7
+ export { NpmPackage } from '@sprucelabs/spruce-skill-utils'
7
8
 
8
9
  export interface GraphicsInterface extends IGraphicsInterface {
9
10
  renderActionSummary(results: ExecutionResults & { totalTime?: number }): void
@@ -20,12 +21,6 @@ export type GeneratedDir = SpruceSchemas.SpruceCli.v2020_07_22.GeneratedDir
20
21
  export type GeneratedFileOrDir =
21
22
  SpruceSchemas.SpruceCli.v2020_07_22.WatcherDidDetectChangesEmitPayload['changes'][number]
22
23
 
23
- export interface NpmPackage {
24
- name: string
25
- version?: string
26
- isDev?: boolean
27
- }
28
-
29
24
  export interface ExecutionResults extends FeatureActionResponse {
30
25
  featureCode: string
31
26
  actionCode: string
@@ -1,14 +0,0 @@
1
- import AbstractCliTest from '../../tests/AbstractCliTest';
2
- export default class AuthServiceTest extends AbstractCliTest {
3
- private static auth;
4
- protected static beforeEach(): Promise<void>;
5
- protected static canInstantiatePersonStore(): Promise<void>;
6
- protected static hasLoggedInPersonMethod(): Promise<void>;
7
- protected static loggedInPersonIsNullWhenNotLoggedIn(): Promise<void>;
8
- protected static cantSaveBadLoggedInPerson(): Promise<void>;
9
- protected static canSaveLoggedInPerson(): void;
10
- protected static canLogOut(): void;
11
- protected static getCurrentSkillReturnsNull(): void;
12
- protected static canSetCurrentSkill(): void;
13
- private static writePackageJson;
14
- }