@sprucelabs/spruce-cli 28.2.3 → 29.0.0
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 +16 -0
- package/build/.spruce/errors/errors.types.d.ts +23 -2
- package/build/.spruce/errors/options.types.d.ts +4 -1
- package/build/.spruce/errors/spruceCli/directoryNotGoModule.schema.d.ts +3 -0
- package/build/.spruce/errors/spruceCli/directoryNotGoModule.schema.js +20 -0
- package/build/.spruce/errors/spruceCli/directoryNotGoModule.schema.js.map +1 -0
- package/build/__tests__/behavioral/OverridingCommandsInPackageJson.test.d.ts +7 -2
- package/build/__tests__/behavioral/OverridingCommandsInPackageJson.test.js +36 -13
- package/build/__tests__/behavioral/OverridingCommandsInPackageJson.test.js.map +1 -1
- package/build/__tests__/behavioral/features/InstallFeaturesInGo.test.d.ts +5 -0
- package/build/__tests__/behavioral/features/InstallFeaturesInGo.test.js +32 -0
- package/build/__tests__/behavioral/features/InstallFeaturesInGo.test.js.map +1 -0
- package/build/__tests__/behavioral/organization/CreatingAnOrg.test.d.ts +5 -0
- package/build/__tests__/behavioral/organization/CreatingAnOrg.test.js +21 -13
- package/build/__tests__/behavioral/organization/CreatingAnOrg.test.js.map +1 -1
- package/build/__tests__/behavioral/schemas/KeepingSchemasInSync.test.d.ts +1 -1
- package/build/__tests__/behavioral/schemas/KeepingSchemasInSync.test.js +7 -7
- package/build/__tests__/behavioral/schemas/KeepingSchemasInSync.test.js.map +1 -1
- package/build/__tests__/behavioral/schemas/SyncingCoreSchemasInGo.test.d.ts +39 -0
- package/build/__tests__/behavioral/schemas/SyncingCoreSchemasInGo.test.js +289 -0
- package/build/__tests__/behavioral/schemas/SyncingCoreSchemasInGo.test.js.map +1 -0
- package/build/__tests__/behavioral/schemas/SyncingSchemasInChildDirInGo.test.d.ts +7 -0
- package/build/__tests__/behavioral/schemas/SyncingSchemasInChildDirInGo.test.js +46 -0
- package/build/__tests__/behavioral/schemas/SyncingSchemasInChildDirInGo.test.js.map +1 -0
- package/build/__tests__/behavioral/schemas/SyncingSchemasInGo.test.d.ts +5 -0
- package/build/__tests__/behavioral/schemas/SyncingSchemasInGo.test.js +31 -0
- package/build/__tests__/behavioral/schemas/SyncingSchemasInGo.test.js.map +1 -0
- package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js +1 -1
- package/build/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js +10 -1
- package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js.map +1 -1
- package/build/__tests__/implementation/SkillStore.test.d.ts +5 -0
- package/build/__tests__/implementation/SkillStore.test.js +37 -0
- package/build/__tests__/implementation/SkillStore.test.js.map +1 -1
- package/build/__tests__/support/EventFaker.d.ts +4 -0
- package/build/__tests__/support/EventFaker.js +16 -0
- package/build/__tests__/support/EventFaker.js.map +1 -1
- package/build/cli/Cli.js +12 -9
- package/build/cli/Cli.js.map +1 -1
- package/build/errors/SpruceError.js +3 -0
- package/build/errors/SpruceError.js.map +1 -1
- package/build/errors/directoryNotGoModule.builder.d.ts +12 -0
- package/build/errors/directoryNotGoModule.builder.js +15 -0
- package/build/errors/directoryNotGoModule.builder.js.map +1 -0
- package/build/features/AbstractAction.d.ts +1 -0
- package/build/features/AbstractAction.js +5 -1
- package/build/features/AbstractAction.js.map +1 -1
- package/build/features/AbstractFeature.d.ts +8 -1
- package/build/features/AbstractFeature.js +12 -1
- package/build/features/AbstractFeature.js.map +1 -1
- package/build/features/ActionFactory.js +1 -2
- package/build/features/ActionFactory.js.map +1 -1
- package/build/features/ActionQuestionAsker.js +0 -1
- package/build/features/ActionQuestionAsker.js.map +1 -1
- package/build/features/FeatureInstaller.d.ts +1 -0
- package/build/features/FeatureInstaller.js +21 -7
- package/build/features/FeatureInstaller.js.map +1 -1
- package/build/features/FeatureInstallerFactory.d.ts +1 -0
- package/build/features/FeatureInstallerFactory.js +7 -0
- package/build/features/FeatureInstallerFactory.js.map +1 -1
- package/build/features/OverrideActionDecorator.js +1 -1
- package/build/features/OverrideActionDecorator.js.map +1 -1
- package/build/features/VersionResolver.js +1 -1
- package/build/features/VersionResolver.js.map +1 -1
- package/build/features/agent/AgentFeature.d.ts +1 -1
- package/build/features/agent/AgentFeature.js +1 -1
- package/build/features/agent/AgentFeature.js.map +1 -1
- package/build/features/conversation/ConversationFeature.d.ts +1 -1
- package/build/features/conversation/ConversationFeature.js +1 -1
- package/build/features/conversation/ConversationFeature.js.map +1 -1
- package/build/features/dependencies/DependencyFeature.d.ts +0 -1
- package/build/features/dependencies/DependencyFeature.js +0 -1
- package/build/features/dependencies/DependencyFeature.js.map +1 -1
- package/build/features/deploy/DeployFeature.d.ts +1 -1
- package/build/features/deploy/DeployFeature.js +1 -1
- package/build/features/deploy/DeployFeature.js.map +1 -1
- package/build/features/error/ErrorFeature.d.ts +1 -1
- package/build/features/error/ErrorFeature.js +1 -1
- package/build/features/error/ErrorFeature.js.map +1 -1
- package/build/features/event/EventFeature.d.ts +1 -1
- package/build/features/event/EventFeature.js +1 -1
- package/build/features/event/EventFeature.js.map +1 -1
- package/build/features/eventContract/EventContractFeature.d.ts +1 -3
- package/build/features/eventContract/EventContractFeature.js +0 -2
- package/build/features/eventContract/EventContractFeature.js.map +1 -1
- package/build/features/node/NodeFeature.d.ts +1 -1
- package/build/features/node/NodeFeature.js +1 -1
- package/build/features/node/NodeFeature.js.map +1 -1
- package/build/features/onboard/OnboardFeature.d.ts +1 -3
- package/build/features/onboard/OnboardFeature.js +0 -2
- package/build/features/onboard/OnboardFeature.js.map +1 -1
- package/build/features/organization/OrganizationFeature.d.ts +0 -1
- package/build/features/organization/OrganizationFeature.js +0 -1
- package/build/features/organization/OrganizationFeature.js.map +1 -1
- package/build/features/permission/PermissionFeature.d.ts +2 -3
- package/build/features/permission/PermissionFeature.js +1 -2
- package/build/features/permission/PermissionFeature.js.map +1 -1
- package/build/features/person/PersonFeature.d.ts +1 -3
- package/build/features/person/PersonFeature.js +0 -2
- package/build/features/person/PersonFeature.js.map +1 -1
- package/build/features/polish/PolishFeature.d.ts +1 -1
- package/build/features/polish/PolishFeature.js +1 -1
- package/build/features/polish/PolishFeature.js.map +1 -1
- package/build/features/sandbox/SandboxFeature.d.ts +0 -1
- package/build/features/sandbox/SandboxFeature.js +0 -1
- package/build/features/sandbox/SandboxFeature.js.map +1 -1
- package/build/features/schema/SchemaFeature.d.ts +2 -3
- package/build/features/schema/SchemaFeature.js +6 -1
- package/build/features/schema/SchemaFeature.js.map +1 -1
- package/build/features/schema/actions/SyncAction.d.ts +5 -2
- package/build/features/schema/actions/SyncAction.js +50 -16
- package/build/features/schema/actions/SyncAction.js.map +1 -1
- package/build/features/schema/utilities/schemaDisk.utility.d.ts +7 -0
- package/build/features/schema/utilities/schemaDisk.utility.js +22 -4
- package/build/features/schema/utilities/schemaDisk.utility.js.map +1 -1
- package/build/features/schema/utilities/schemaGenerator.utility.d.ts +1 -0
- package/build/features/schema/utilities/schemaGenerator.utility.js +18 -10
- package/build/features/schema/utilities/schemaGenerator.utility.js.map +1 -1
- package/build/features/schema/writers/SchemaWriter.d.ts +9 -9
- package/build/features/schema/writers/SchemaWriter.js +38 -17
- package/build/features/schema/writers/SchemaWriter.js.map +1 -1
- package/build/features/skill/SkillFeature.d.ts +1 -1
- package/build/features/skill/SkillFeature.js +1 -1
- package/build/features/skill/SkillFeature.js.map +1 -1
- package/build/features/skill/stores/SkillStore.d.ts +4 -0
- package/build/features/skill/stores/SkillStore.js +37 -3
- package/build/features/skill/stores/SkillStore.js.map +1 -1
- package/build/features/store/StoreFeature.d.ts +1 -1
- package/build/features/store/StoreFeature.js +1 -1
- package/build/features/store/StoreFeature.js.map +1 -1
- package/build/features/test/TestFeature.d.ts +1 -1
- package/build/features/test/TestFeature.js +1 -1
- package/build/features/test/TestFeature.js.map +1 -1
- package/build/features/test/TestReporter.js +1 -1
- package/build/features/test/TestReporter.js.map +1 -1
- package/build/features/view/ViewFeature.d.ts +1 -1
- package/build/features/view/ViewFeature.js +1 -1
- package/build/features/view/ViewFeature.js.map +1 -1
- package/build/migration/EsLint9Migrator.d.ts +1 -0
- package/build/packageManager/NodePackageManager.d.ts +14 -0
- package/build/packageManager/NodePackageManager.js +88 -0
- package/build/packageManager/NodePackageManager.js.map +1 -0
- package/build/packageManager/packageManager.types.d.ts +16 -0
- package/build/packageManager/packageManager.types.js +3 -0
- package/build/packageManager/packageManager.types.js.map +1 -0
- package/build/services/GoPackageManager.d.ts +10 -0
- package/build/services/GoPackageManager.js +39 -0
- package/build/services/GoPackageManager.js.map +1 -0
- package/build/services/PkgService.d.ts +3 -7
- package/build/services/PkgService.js +13 -68
- package/build/services/PkgService.js.map +1 -1
- package/build/templateItemBuilders/SchemaTemplateItemBuilder.js.map +1 -1
- package/build/tests/AbstractCliTest.d.ts +5 -1
- package/build/tests/AbstractCliTest.js +15 -3
- package/build/tests/AbstractCliTest.js.map +1 -1
- package/build/tests/fixtures/FeatureFixture.js +4 -1
- package/build/tests/fixtures/FeatureFixture.js.map +1 -1
- package/build/tests/fixtures/GoFixture.d.ts +12 -0
- package/build/tests/fixtures/GoFixture.js +39 -0
- package/build/tests/fixtures/GoFixture.js.map +1 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.d.ts +1 -0
- package/build/widgets/terminalKit/TkTextWidget.js +1 -1
- package/build/widgets/terminalKit/TkTextWidget.js.map +1 -1
- package/build/writers/AbstractWriter.js +7 -6
- package/build/writers/AbstractWriter.js.map +1 -1
- package/package.json +29 -29
- package/src/.spruce/errors/errors.types.ts +32 -2
- package/src/.spruce/errors/options.types.ts +4 -1
- package/src/.spruce/errors/spruceCli/directoryNotGoModule.schema.ts +23 -0
- package/src/__tests__/behavioral/OverridingCommandsInPackageJson.test.ts +60 -13
- package/src/__tests__/behavioral/features/InstallFeaturesInGo.test.ts +17 -0
- package/src/__tests__/behavioral/organization/CreatingAnOrg.test.ts +29 -22
- package/src/__tests__/behavioral/schemas/KeepingSchemasInSync.test.ts +6 -9
- package/src/__tests__/behavioral/schemas/SyncingCoreSchemasInGo.test.ts +376 -0
- package/src/__tests__/behavioral/schemas/SyncingSchemasInChildDirInGo.test.ts +46 -0
- package/src/__tests__/behavioral/schemas/SyncingSchemasInGo.test.ts +23 -0
- package/src/__tests__/behavioral/tests/SelectingAnAbstractTestClass.test.ts +1 -1
- package/src/__tests__/behavioral/upgrading/UpdatingDependencies2.test.ts +15 -2
- package/src/__tests__/implementation/SkillStore.test.ts +44 -1
- package/src/__tests__/support/EventFaker.ts +29 -0
- package/src/cli/Cli.ts +20 -12
- package/src/errors/SpruceError.ts +4 -0
- package/src/errors/directoryNotGoModule.builder.ts +13 -0
- package/src/features/AbstractAction.ts +6 -4
- package/src/features/AbstractFeature.ts +20 -1
- package/src/features/ActionFactory.ts +2 -2
- package/src/features/ActionQuestionAsker.ts +0 -1
- package/src/features/FeatureInstaller.ts +30 -6
- package/src/features/FeatureInstallerFactory.ts +9 -0
- package/src/features/OverrideActionDecorator.ts +1 -1
- package/src/features/VersionResolver.ts +2 -1
- package/src/features/agent/AgentFeature.ts +1 -1
- package/src/features/conversation/ConversationFeature.ts +1 -1
- package/src/features/dependencies/DependencyFeature.ts +0 -1
- package/src/features/deploy/DeployFeature.ts +1 -1
- package/src/features/error/ErrorFeature.ts +1 -1
- package/src/features/event/EventFeature.ts +1 -1
- package/src/features/eventContract/EventContractFeature.ts +1 -3
- package/src/features/node/NodeFeature.ts +1 -1
- package/src/features/onboard/OnboardFeature.ts +1 -7
- package/src/features/organization/OrganizationFeature.ts +0 -1
- package/src/features/permission/PermissionFeature.ts +1 -3
- package/src/features/person/PersonFeature.ts +1 -4
- package/src/features/polish/PolishFeature.ts +1 -1
- package/src/features/sandbox/SandboxFeature.ts +0 -1
- package/src/features/schema/SchemaFeature.ts +8 -2
- package/src/features/schema/actions/SyncAction.ts +68 -26
- package/src/features/schema/utilities/schemaDisk.utility.ts +43 -11
- package/src/features/schema/utilities/schemaGenerator.utility.ts +33 -13
- package/src/features/schema/writers/SchemaWriter.ts +71 -25
- package/src/features/skill/SkillFeature.ts +1 -1
- package/src/features/skill/stores/SkillStore.ts +47 -5
- package/src/features/store/StoreFeature.ts +1 -1
- package/src/features/test/TestFeature.ts +1 -1
- package/src/features/test/TestReporter.ts +1 -1
- package/src/features/view/ViewFeature.ts +1 -1
- package/src/packageManager/NodePackageManager.ts +115 -0
- package/src/packageManager/packageManager.types.ts +21 -0
- package/src/services/GoPackageManager.ts +45 -0
- package/src/services/PkgService.ts +17 -92
- package/src/templateItemBuilders/SchemaTemplateItemBuilder.ts +6 -6
- package/src/tests/AbstractCliTest.ts +19 -5
- package/src/tests/fixtures/FeatureFixture.ts +3 -1
- package/src/tests/fixtures/GoFixture.ts +39 -0
- package/src/widgets/terminalKit/TkTextWidget.ts +1 -1
- package/src/writers/AbstractWriter.ts +15 -6
|
@@ -54,7 +54,7 @@ export default class TestReporter {
|
|
|
54
54
|
private minWidth = 50
|
|
55
55
|
private isRpTraining: boolean
|
|
56
56
|
private trainingTokenPopup?: PopupWidget
|
|
57
|
-
private shouldStripCwdFromErrors =
|
|
57
|
+
private shouldStripCwdFromErrors = true
|
|
58
58
|
// private orientationWhenErrorLogWasShown: TestReporterOrientation =
|
|
59
59
|
// 'landscape'
|
|
60
60
|
|
|
@@ -9,7 +9,7 @@ export default class ViewFeature extends AbstractFeature {
|
|
|
9
9
|
public code: FeatureCode = 'view'
|
|
10
10
|
public actionsDir = diskUtil.resolvePath(__dirname, 'actions')
|
|
11
11
|
|
|
12
|
-
public readonly
|
|
12
|
+
public readonly _packageDependencies: NpmPackage[] = [
|
|
13
13
|
{
|
|
14
14
|
name: '@sprucelabs/heartwood-view-controllers@latest',
|
|
15
15
|
},
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import pathUtil from 'path'
|
|
2
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
|
+
import { CommandService } from '../services/CommandService'
|
|
4
|
+
import PkgService, { AddOptions } from '../services/PkgService'
|
|
5
|
+
import isCi from '../utilities/isCi'
|
|
6
|
+
import {
|
|
7
|
+
PackageManager,
|
|
8
|
+
PackageManagerConstructorOptions,
|
|
9
|
+
} from './packageManager.types'
|
|
10
|
+
|
|
11
|
+
export default class NodePackageManager implements PackageManager {
|
|
12
|
+
private pkgService: PkgService
|
|
13
|
+
private cwd: string
|
|
14
|
+
private commandService: CommandService
|
|
15
|
+
|
|
16
|
+
public constructor(options: PackageManagerConstructorOptions) {
|
|
17
|
+
const { pkgService, commandService, cwd } = options
|
|
18
|
+
this.pkgService = pkgService
|
|
19
|
+
this.commandService = commandService
|
|
20
|
+
this.cwd = cwd
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async installDependencies(
|
|
24
|
+
pkg?: string[] | string,
|
|
25
|
+
options?: AddOptions
|
|
26
|
+
) {
|
|
27
|
+
const shouldCleanupLockFiles = options?.shouldCleanupLockFiles !== false
|
|
28
|
+
const deleteLockFile = shouldCleanupLockFiles
|
|
29
|
+
? () => this.pkgService.deleteLockFile()
|
|
30
|
+
: () => {}
|
|
31
|
+
|
|
32
|
+
if (!pkg) {
|
|
33
|
+
await this.commandService.execute('yarn', { args: ['install'] })
|
|
34
|
+
deleteLockFile()
|
|
35
|
+
return { totalInstalled: -1, totalSkipped: -1 }
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
deleteLockFile()
|
|
39
|
+
|
|
40
|
+
const packages = Array.isArray(pkg) ? pkg : [pkg]
|
|
41
|
+
const toInstall = []
|
|
42
|
+
const labsModules: string[] = []
|
|
43
|
+
|
|
44
|
+
let totalInstalled = 0
|
|
45
|
+
let totalSkipped = 0
|
|
46
|
+
|
|
47
|
+
for (const thisPackage of packages) {
|
|
48
|
+
const isInstalled =
|
|
49
|
+
!options?.shouldForceInstall &&
|
|
50
|
+
this.pkgService.isInstalled(thisPackage)
|
|
51
|
+
if (thisPackage.startsWith('@sprucelabs/') || !isInstalled) {
|
|
52
|
+
toInstall.push(this.pkgService.stripLatest(thisPackage))
|
|
53
|
+
totalInstalled++
|
|
54
|
+
} else {
|
|
55
|
+
totalSkipped++
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (totalInstalled > 0) {
|
|
60
|
+
const { executable, args } = this.buildCommandAndArgs(
|
|
61
|
+
toInstall,
|
|
62
|
+
options
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
const isInWorkspace = this.pkgService.get('workspaces')?.length > 0
|
|
66
|
+
if (isInWorkspace) {
|
|
67
|
+
args.push('-W')
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
await this.commandService.execute(executable, {
|
|
71
|
+
args,
|
|
72
|
+
})
|
|
73
|
+
} else if (
|
|
74
|
+
!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))
|
|
75
|
+
) {
|
|
76
|
+
await this.commandService.execute('yarn', { args: ['install'] })
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
deleteLockFile()
|
|
80
|
+
|
|
81
|
+
return {
|
|
82
|
+
totalInstalled: totalInstalled + labsModules.length,
|
|
83
|
+
totalSkipped,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
public async uninstallDependencies(pkg: string[] | string) {
|
|
88
|
+
const packages = Array.isArray(pkg) ? pkg : [pkg]
|
|
89
|
+
const args: string[] = ['uninstall', ...packages]
|
|
90
|
+
await this.commandService.execute('npm', {
|
|
91
|
+
args,
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
await this.installDependencies()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
private buildCommandAndArgs(
|
|
98
|
+
toInstall: string[],
|
|
99
|
+
options: AddOptions | undefined
|
|
100
|
+
) {
|
|
101
|
+
const args: any[] = [
|
|
102
|
+
isCi() && '--cache-folder',
|
|
103
|
+
isCi() && diskUtil.createRandomTempDir(),
|
|
104
|
+
'add',
|
|
105
|
+
...toInstall,
|
|
106
|
+
].filter((a) => !!a)
|
|
107
|
+
|
|
108
|
+
if (options?.isDev) {
|
|
109
|
+
args.push('-D')
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const executable = 'yarn'
|
|
113
|
+
return { executable, args }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CommandService } from '../services/CommandService'
|
|
2
|
+
import PkgService, { AddOptions } from '../services/PkgService'
|
|
3
|
+
|
|
4
|
+
export interface PackageManager {
|
|
5
|
+
installDependencies(
|
|
6
|
+
pkg?: string[] | string,
|
|
7
|
+
options?: AddOptions
|
|
8
|
+
): Promise<{
|
|
9
|
+
totalInstalled: number
|
|
10
|
+
totalSkipped: number
|
|
11
|
+
}>
|
|
12
|
+
uninstallDependencies?(dependencies: string[] | string): Promise<void>
|
|
13
|
+
isInstalled?(pkg: string): boolean
|
|
14
|
+
deleteLockFile?(): void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface PackageManagerConstructorOptions {
|
|
18
|
+
pkgService: PkgService
|
|
19
|
+
commandService: CommandService
|
|
20
|
+
cwd: string
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
|
+
import {
|
|
3
|
+
PackageManager,
|
|
4
|
+
PackageManagerConstructorOptions,
|
|
5
|
+
} from '../packageManager/packageManager.types'
|
|
6
|
+
import { CommandService } from './CommandService'
|
|
7
|
+
|
|
8
|
+
export class GoPackageManager implements PackageManager {
|
|
9
|
+
private commandService: CommandService
|
|
10
|
+
public constructor(options: PackageManagerConstructorOptions) {
|
|
11
|
+
const { commandService } = options
|
|
12
|
+
this.commandService = commandService
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public async installDependencies(pkg?: string[] | string) {
|
|
16
|
+
const first = Array.isArray(pkg) ? pkg[0] : pkg
|
|
17
|
+
if (first) {
|
|
18
|
+
await this.commandService.execute('go', {
|
|
19
|
+
args: ['get', first],
|
|
20
|
+
env: this.buildEnv(),
|
|
21
|
+
})
|
|
22
|
+
return {
|
|
23
|
+
totalInstalled: 1,
|
|
24
|
+
totalSkipped: 0,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
totalInstalled: 0,
|
|
30
|
+
totalSkipped: 0,
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private buildEnv() {
|
|
35
|
+
const cwd = this.commandService.getCwd()
|
|
36
|
+
const goCacheDir = diskUtil.resolvePath(cwd, '.go-cache')
|
|
37
|
+
|
|
38
|
+
diskUtil.createDir(goCacheDir)
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
HOME: process.env.HOME ?? cwd,
|
|
42
|
+
GOCACHE: process.env.GOCACHE ?? goCacheDir,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -1,114 +1,39 @@
|
|
|
1
|
-
import pathUtil from 'path'
|
|
2
1
|
import {
|
|
3
2
|
diskUtil,
|
|
4
3
|
PkgService as BasePkgService,
|
|
5
4
|
} from '@sprucelabs/spruce-skill-utils'
|
|
6
|
-
import
|
|
5
|
+
import NodePackageManager from '../packageManager/NodePackageManager'
|
|
6
|
+
import { PackageManager } from '../packageManager/packageManager.types'
|
|
7
7
|
import CommandServiceImpl from './CommandService'
|
|
8
|
+
import { GoPackageManager } from './GoPackageManager'
|
|
8
9
|
|
|
9
10
|
export default class PkgService extends BasePkgService {
|
|
10
|
-
private
|
|
11
|
+
private packageManager: PackageManager
|
|
11
12
|
|
|
12
13
|
public constructor(cwd: string, commandService: CommandServiceImpl) {
|
|
13
14
|
super(cwd)
|
|
14
|
-
|
|
15
|
+
const PackageManagerClass =
|
|
16
|
+
diskUtil.detectProjectLanguage(cwd) === 'go'
|
|
17
|
+
? GoPackageManager
|
|
18
|
+
: NodePackageManager
|
|
19
|
+
|
|
20
|
+
this.packageManager = new PackageManagerClass({
|
|
21
|
+
cwd,
|
|
22
|
+
commandService,
|
|
23
|
+
pkgService: this,
|
|
24
|
+
})
|
|
15
25
|
}
|
|
16
26
|
|
|
17
27
|
public async install(pkg?: string[] | string, options?: AddOptions) {
|
|
18
|
-
|
|
19
|
-
const deleteLockFile = shouldCleanupLockFiles
|
|
20
|
-
? this.deleteLockFile.bind(this)
|
|
21
|
-
: () => {}
|
|
22
|
-
|
|
23
|
-
if (!pkg) {
|
|
24
|
-
await this.commandService.execute('yarn', { args: ['install'] })
|
|
25
|
-
deleteLockFile()
|
|
26
|
-
return { totalInstalled: -1, totalSkipped: -1 }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
deleteLockFile()
|
|
30
|
-
|
|
31
|
-
const packages = Array.isArray(pkg) ? pkg : [pkg]
|
|
32
|
-
const toInstall = []
|
|
33
|
-
const labsModules: string[] = []
|
|
34
|
-
|
|
35
|
-
let totalInstalled = 0
|
|
36
|
-
let totalSkipped = 0
|
|
37
|
-
|
|
38
|
-
for (const thisPackage of packages) {
|
|
39
|
-
const isInstalled =
|
|
40
|
-
!options?.shouldForceInstall && this.isInstalled(thisPackage)
|
|
41
|
-
if (thisPackage.startsWith('@sprucelabs/') || !isInstalled) {
|
|
42
|
-
toInstall.push(this.stripLatest(thisPackage))
|
|
43
|
-
totalInstalled++
|
|
44
|
-
} else {
|
|
45
|
-
totalSkipped++
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (totalInstalled > 0) {
|
|
50
|
-
const { executable, args } = PkgService.buildCommandAndArgs(
|
|
51
|
-
toInstall,
|
|
52
|
-
options
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
const isInWorkspace = this.get('workspaces')?.length > 0
|
|
56
|
-
if (isInWorkspace) {
|
|
57
|
-
args.push('-W')
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await this.commandService.execute(executable, {
|
|
61
|
-
args,
|
|
62
|
-
})
|
|
63
|
-
} else if (
|
|
64
|
-
!diskUtil.doesDirExist(pathUtil.join(this.cwd, 'node_modules'))
|
|
65
|
-
) {
|
|
66
|
-
await this.commandService.execute('yarn', { args: ['install'] })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
deleteLockFile()
|
|
70
|
-
|
|
71
|
-
this._parsedPkg = undefined
|
|
72
|
-
|
|
73
|
-
return {
|
|
74
|
-
totalInstalled: totalInstalled + labsModules.length,
|
|
75
|
-
totalSkipped,
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public static buildCommandAndArgs(
|
|
80
|
-
toInstall: string[],
|
|
81
|
-
options: AddOptions | undefined
|
|
82
|
-
) {
|
|
83
|
-
const args: any[] = [
|
|
84
|
-
isCi() && '--cache-folder',
|
|
85
|
-
isCi() && diskUtil.createRandomTempDir(),
|
|
86
|
-
'add',
|
|
87
|
-
...toInstall,
|
|
88
|
-
].filter((a) => !!a)
|
|
89
|
-
|
|
90
|
-
if (options?.isDev) {
|
|
91
|
-
args.push('-D')
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
const executable = 'yarn'
|
|
95
|
-
return { executable, args }
|
|
28
|
+
return this.packageManager.installDependencies(pkg, options)
|
|
96
29
|
}
|
|
97
30
|
|
|
98
31
|
public getSkillNamespace() {
|
|
99
|
-
return this.get('skill.namespace')
|
|
32
|
+
return this.get('skill.namespace') as string
|
|
100
33
|
}
|
|
101
34
|
|
|
102
35
|
public async uninstall(pkg: string[] | string) {
|
|
103
|
-
|
|
104
|
-
const args: string[] = ['uninstall', ...packages]
|
|
105
|
-
await this.commandService.execute('npm', {
|
|
106
|
-
args,
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
this._parsedPkg = undefined
|
|
110
|
-
|
|
111
|
-
await this.install()
|
|
36
|
+
return this.packageManager.uninstallDependencies?.(pkg)
|
|
112
37
|
}
|
|
113
38
|
}
|
|
114
39
|
|
|
@@ -14,12 +14,6 @@ import SpruceError from '../errors/SpruceError'
|
|
|
14
14
|
import { SchemasByNamespace } from '../features/schema/stores/SchemaStore'
|
|
15
15
|
import schemaUtil from '../features/schema/utilities/schema.utility'
|
|
16
16
|
|
|
17
|
-
interface SchemaWithDependencies {
|
|
18
|
-
schema: Schema
|
|
19
|
-
dependencies: SchemaIdWithVersion[]
|
|
20
|
-
isNested: boolean
|
|
21
|
-
}
|
|
22
|
-
|
|
23
17
|
export default class SchemaTemplateItemBuilder {
|
|
24
18
|
private schemasByKey: Record<string, SchemaWithDependencies> = {}
|
|
25
19
|
private localNamespace: string
|
|
@@ -251,3 +245,9 @@ export default class SchemaTemplateItemBuilder {
|
|
|
251
245
|
return undefined
|
|
252
246
|
}
|
|
253
247
|
}
|
|
248
|
+
|
|
249
|
+
interface SchemaWithDependencies {
|
|
250
|
+
schema: Schema
|
|
251
|
+
dependencies: SchemaIdWithVersion[]
|
|
252
|
+
isNested: boolean
|
|
253
|
+
}
|
|
@@ -38,6 +38,7 @@ import CommandFaker from './CommandFaker'
|
|
|
38
38
|
import FeatureFixture, {
|
|
39
39
|
FeatureFixtureOptions,
|
|
40
40
|
} from './fixtures/FeatureFixture'
|
|
41
|
+
import GoFixture from './fixtures/GoFixture'
|
|
41
42
|
import MercuryFixture from './fixtures/MercuryFixture'
|
|
42
43
|
import OrganizationFixture from './fixtures/OrganizationFixture'
|
|
43
44
|
import PersonFixture from './fixtures/PersonFixture'
|
|
@@ -58,6 +59,7 @@ export default abstract class AbstractCliTest extends AbstractSpruceTest {
|
|
|
58
59
|
private static skillFixture?: SkillFixture
|
|
59
60
|
private static _featureInstaller?: FeatureInstaller
|
|
60
61
|
private static viewFixture?: ViewFixture
|
|
62
|
+
private static goFixture?: GoFixture
|
|
61
63
|
private static originalEnv: Record<string, string | undefined>
|
|
62
64
|
private static _writers?: WriterFactory
|
|
63
65
|
protected static eventFaker: EventFaker
|
|
@@ -99,16 +101,13 @@ export default abstract class AbstractCliTest extends AbstractSpruceTest {
|
|
|
99
101
|
|
|
100
102
|
AuthService.homeDir = this.homeDir
|
|
101
103
|
|
|
102
|
-
this._emitter = undefined
|
|
103
|
-
this._featureInstaller = undefined
|
|
104
|
-
|
|
105
104
|
OnboardingStore.overrideCwd(diskUtil.createRandomTempDir())
|
|
106
105
|
|
|
107
106
|
this.ui.reset()
|
|
108
107
|
this.ui.invocations = []
|
|
109
108
|
this.ui.setCursorPosition({ x: 0, y: 0 })
|
|
110
109
|
|
|
111
|
-
this.
|
|
110
|
+
this.setCwd(this.cwd)
|
|
112
111
|
|
|
113
112
|
ImportService.clearCache()
|
|
114
113
|
SkillStoreImpl.clearCurrentSkill()
|
|
@@ -166,13 +165,20 @@ export default abstract class AbstractCliTest extends AbstractSpruceTest {
|
|
|
166
165
|
}
|
|
167
166
|
}
|
|
168
167
|
|
|
169
|
-
|
|
168
|
+
protected static clearFixtures() {
|
|
169
|
+
this._featureInstaller = undefined
|
|
170
170
|
this._emitter = undefined
|
|
171
171
|
this.mercuryFixture = undefined
|
|
172
172
|
this.organizationFixture = undefined
|
|
173
173
|
this.personFixture = undefined
|
|
174
174
|
this.skillFixture = undefined
|
|
175
175
|
this.viewFixture = undefined
|
|
176
|
+
this.goFixture = undefined
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
protected static setCwd(cwd: string) {
|
|
180
|
+
this.clearFixtures()
|
|
181
|
+
this.cwd = cwd
|
|
176
182
|
}
|
|
177
183
|
|
|
178
184
|
protected static freshTmpDir() {
|
|
@@ -267,6 +273,14 @@ export default abstract class AbstractCliTest extends AbstractSpruceTest {
|
|
|
267
273
|
return this.personFixture
|
|
268
274
|
}
|
|
269
275
|
|
|
276
|
+
protected static get go() {
|
|
277
|
+
if (!this.goFixture) {
|
|
278
|
+
this.goFixture = new GoFixture(this.Service('command'))
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return this.goFixture
|
|
282
|
+
}
|
|
283
|
+
|
|
270
284
|
protected static getViewFixture() {
|
|
271
285
|
if (!this.viewFixture) {
|
|
272
286
|
const viewWriter = this.writers.Writer('view', {
|
|
@@ -47,7 +47,9 @@ export default class FeatureFixture implements ServiceProvider {
|
|
|
47
47
|
|
|
48
48
|
public static deleteOldSkillDirs() {
|
|
49
49
|
for (const dir of this.dirsToDelete) {
|
|
50
|
-
|
|
50
|
+
try {
|
|
51
|
+
diskUtil.deleteDir(dir)
|
|
52
|
+
} catch {}
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
this.dirsToDelete = []
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import os from 'os'
|
|
2
|
+
import { generateId } from '@sprucelabs/test-utils'
|
|
3
|
+
import { CommandService } from '../../services/CommandService'
|
|
4
|
+
|
|
5
|
+
export default class GoFixture {
|
|
6
|
+
private cmdService: CommandService
|
|
7
|
+
public constructor(cmdService: CommandService) {
|
|
8
|
+
this.cmdService = cmdService
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
public async initGoProject(name?: string) {
|
|
12
|
+
const moduleName = `github.com/${generateId()}/${name ?? generateId()}`
|
|
13
|
+
await this.cmdService.execute(`go mod init ${moduleName}`, {
|
|
14
|
+
env: this.buildEnv(),
|
|
15
|
+
})
|
|
16
|
+
return moduleName
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public setCwd(dir: string) {
|
|
20
|
+
this.cmdService.setCwd(dir)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public async exec(command: string, arg1: string) {
|
|
24
|
+
return this.cmdService.execute(`go`, {
|
|
25
|
+
args: [command, arg1],
|
|
26
|
+
env: this.buildEnv(),
|
|
27
|
+
})
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
private buildEnv() {
|
|
31
|
+
return {
|
|
32
|
+
HOME: os.homedir(),
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async vet() {
|
|
37
|
+
await this.exec('vet', './...')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -154,7 +154,7 @@ export default class TkTextWidget extends TkBaseWidget implements TextWidget {
|
|
|
154
154
|
return segment
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
-
if ('{}[]'.includes(segment)) {
|
|
157
|
+
if ('{}[]()'.includes(segment)) {
|
|
158
158
|
// Terminal-kit drops single-character chunks when parsing ANSI
|
|
159
159
|
// sequences, so pad with a zero-width space to keep braces visible.
|
|
160
160
|
return `${segment}`
|
|
@@ -24,12 +24,21 @@ export default abstract class AbstractWriter {
|
|
|
24
24
|
protected isLintEnabled = true
|
|
25
25
|
|
|
26
26
|
public constructor(options: WriterOptions) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const {
|
|
28
|
+
templates,
|
|
29
|
+
term,
|
|
30
|
+
upgradeMode,
|
|
31
|
+
fileDescriptions,
|
|
32
|
+
linter,
|
|
33
|
+
settings,
|
|
34
|
+
} = options
|
|
35
|
+
|
|
36
|
+
this.templates = templates
|
|
37
|
+
this.ui = term
|
|
38
|
+
this.upgradeMode = upgradeMode
|
|
39
|
+
this.fileDescriptions = fileDescriptions
|
|
40
|
+
this.linter = linter
|
|
41
|
+
this.settings = settings
|
|
33
42
|
}
|
|
34
43
|
|
|
35
44
|
protected async lint(file: string) {
|