@sprucelabs/spruce-cli 24.1.0 → 24.1.1
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 +8 -0
- package/build/InFlightEntertainment.d.ts +2 -2
- package/build/__tests__/behavioral/DeployingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/EnablingAndDisablingCache.test.js.map +1 -1
- package/build/__tests__/behavioral/lint/LintService.test.js.map +1 -1
- package/build/__tests__/behavioral/node/CreatingANodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/onboard/StartingOnboarding.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/CreatingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/skill/RebuildingASkill.test.js.map +1 -1
- package/build/__tests__/behavioral/stores/CreatingADataStore.test.js.map +1 -1
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.d.ts +3 -0
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js +42 -1
- package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpdatingDependencies2.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingANodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingANonSpruceNodeModule.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill3.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill4.test.js.map +1 -1
- package/build/__tests__/behavioral/upgrading/UpgradingASkill5.test.js.map +1 -1
- package/build/__tests__/behavioral/views/WatchingSkillViews.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter2.test.js.map +1 -1
- package/build/__tests__/implementation/ActionExecuter4.test.js.map +1 -1
- package/build/__tests__/implementation/FeatureInstaller.test.js.map +1 -1
- package/build/__tests__/implementation/PkgService.test.js.map +1 -1
- package/build/__tests__/implementation/StoreFeature.test.js.map +1 -1
- package/build/boot.js.map +1 -1
- package/build/features/skill/actions/BootAction.js.map +1 -1
- package/build/features/test/TestRunner.d.ts +2 -2
- package/build/features/test/TestRunner.js.map +1 -1
- package/build/features/test/actions/MigrateAction.js +3 -0
- package/build/features/test/actions/MigrateAction.js.map +1 -1
- package/build/features/vscode/services/VsCodeService.d.ts +2 -2
- package/build/features/vscode/services/VsCodeService.js.map +1 -1
- package/build/services/BuildService.d.ts +2 -2
- package/build/services/BuildService.js.map +1 -1
- package/build/services/CommandService.d.ts +20 -12
- package/build/services/CommandService.js +4 -4
- package/build/services/CommandService.js.map +1 -1
- package/build/services/GameService.d.ts +2 -2
- package/build/services/GameService.js.map +1 -1
- package/build/services/ImportService.d.ts +2 -2
- package/build/services/ImportService.js.map +1 -1
- package/build/services/LintService.d.ts +1 -1
- package/build/services/PkgService.d.ts +2 -2
- package/build/services/PkgService.js.map +1 -1
- package/build/services/ServiceFactory.d.ts +2 -2
- package/build/services/ServiceFactory.js.map +1 -1
- package/build/tests/AbstractCliTest.js.map +1 -1
- package/build/tests/CommandFaker.js.map +1 -1
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.d.ts +3 -0
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js +9 -2
- package/build/tests/staticToInstanceMigration/StaticToInstanceMigrator.js.map +1 -1
- package/package.json +3 -3
- package/src/InFlightEntertainment.ts +2 -2
- package/src/__tests__/behavioral/DeployingASkill.test.ts +26 -23
- package/src/__tests__/behavioral/EnablingAndDisablingCache.test.ts +13 -13
- package/src/__tests__/behavioral/lint/LintService.test.ts +3 -3
- package/src/__tests__/behavioral/node/CreatingANodeModule.test.ts +2 -2
- package/src/__tests__/behavioral/onboard/StartingOnboarding.test.ts +2 -2
- package/src/__tests__/behavioral/skill/CreatingASkill.test.ts +2 -2
- package/src/__tests__/behavioral/skill/RebuildingASkill.test.ts +3 -3
- package/src/__tests__/behavioral/stores/CreatingADataStore.test.ts +3 -3
- package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.ts +59 -1
- package/src/__tests__/behavioral/upgrading/UpdatingDependencies2.test.ts +3 -3
- package/src/__tests__/behavioral/upgrading/UpgradingANodeModule.test.ts +6 -6
- package/src/__tests__/behavioral/upgrading/UpgradingANonSpruceNodeModule.test.ts +4 -4
- package/src/__tests__/behavioral/upgrading/UpgradingASkill3.test.ts +9 -9
- package/src/__tests__/behavioral/upgrading/UpgradingASkill4.test.ts +4 -4
- package/src/__tests__/behavioral/upgrading/UpgradingASkill5.test.ts +4 -4
- package/src/__tests__/behavioral/views/WatchingSkillViews.test.ts +2 -2
- package/src/__tests__/implementation/ActionExecuter2.test.ts +2 -2
- package/src/__tests__/implementation/ActionExecuter4.test.ts +3 -3
- package/src/__tests__/implementation/FeatureInstaller.test.ts +2 -2
- package/src/__tests__/implementation/PkgService.test.ts +3 -3
- package/src/__tests__/implementation/StoreFeature.test.ts +2 -2
- package/src/boot.ts +2 -2
- package/src/features/skill/actions/BootAction.ts +2 -2
- package/src/features/test/TestRunner.ts +3 -3
- package/src/features/test/actions/MigrateAction.ts +3 -0
- package/src/features/vscode/services/VsCodeService.ts +2 -2
- package/src/services/BuildService.ts +3 -3
- package/src/services/CommandService.ts +27 -14
- package/src/services/GameService.ts +3 -3
- package/src/services/ImportService.ts +3 -3
- package/src/services/LintService.ts +1 -1
- package/src/services/PkgService.ts +3 -3
- package/src/services/ServiceFactory.ts +6 -6
- package/src/tests/AbstractCliTest.ts +2 -2
- package/src/tests/CommandFaker.ts +4 -4
- package/src/tests/staticToInstanceMigration/StaticToInstanceMigrator.ts +12 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import fsUtil from 'fs'
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
3
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
4
|
-
import
|
|
4
|
+
import CommandServiceImpl from '../../../services/CommandService'
|
|
5
5
|
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
6
6
|
|
|
7
7
|
export default class UpgradingASkill4Test extends AbstractCliTest {
|
|
8
8
|
protected static async beforeEach() {
|
|
9
9
|
await super.beforeEach()
|
|
10
|
-
|
|
10
|
+
CommandServiceImpl.fakeCommand(new RegExp(/rebuild/gis), {
|
|
11
11
|
code: 0,
|
|
12
12
|
})
|
|
13
13
|
}
|
|
@@ -49,8 +49,8 @@ export default class UpgradingASkill4Test extends AbstractCliTest {
|
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
CommandServiceImpl.fakeCommand(/yarn clean/, { code: 0 })
|
|
53
|
+
CommandServiceImpl.fakeCommand(/yarn build.dev/, { code: 0 })
|
|
54
54
|
|
|
55
55
|
await this.Action('node', 'upgrade').execute({})
|
|
56
56
|
|
|
@@ -2,7 +2,7 @@ import { Schema } from '@sprucelabs/schema'
|
|
|
2
2
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
3
3
|
import ActionFactory from '../../../features/ActionFactory'
|
|
4
4
|
import { FeatureAction } from '../../../features/features.types'
|
|
5
|
-
import
|
|
5
|
+
import CommandServiceImpl from '../../../services/CommandService'
|
|
6
6
|
import LintService from '../../../services/LintService'
|
|
7
7
|
import ServiceFactory from '../../../services/ServiceFactory'
|
|
8
8
|
import AbstractCliTest from '../../../tests/AbstractCliTest'
|
|
@@ -50,7 +50,7 @@ export default class UpgradingASkill5Test extends AbstractCliTest {
|
|
|
50
50
|
) {
|
|
51
51
|
await this.FeatureFixture().installCachedFeatures('schemas')
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
CommandServiceImpl.fakeCommand(new RegExp(/yarn/gis), {
|
|
54
54
|
code: 0,
|
|
55
55
|
})
|
|
56
56
|
|
|
@@ -93,7 +93,7 @@ export default class UpgradingASkill5Test extends AbstractCliTest {
|
|
|
93
93
|
let wasMovedBackToDev = false
|
|
94
94
|
let wasMovedBackToProd = false
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
CommandServiceImpl.fakeCommand(new RegExp(/yarn/gis), {
|
|
97
97
|
code: 0,
|
|
98
98
|
callback: (_, args) => {
|
|
99
99
|
if (
|
|
@@ -126,7 +126,7 @@ export default class UpgradingASkill5Test extends AbstractCliTest {
|
|
|
126
126
|
|
|
127
127
|
ServiceFactory.setFactoryClass('lint', SpyLintService)
|
|
128
128
|
|
|
129
|
-
|
|
129
|
+
CommandServiceImpl.fakeCommand(/.*/gi, {
|
|
130
130
|
code: 0,
|
|
131
131
|
callback: (command, args) => {
|
|
132
132
|
this.invocationLog.push([command, ...args].join(' '))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import WatchAction from '../../../features/view/actions/WatchAction'
|
|
3
|
-
import
|
|
3
|
+
import CommandServiceImpl from '../../../services/CommandService'
|
|
4
4
|
import AbstractSkillTest from '../../../tests/AbstractSkillTest'
|
|
5
5
|
|
|
6
6
|
export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
@@ -21,7 +21,7 @@ export default class WatchingSkillViewsTest extends AbstractSkillTest {
|
|
|
21
21
|
@test()
|
|
22
22
|
protected static async shouldCallBoot() {
|
|
23
23
|
let wasHit = false
|
|
24
|
-
|
|
24
|
+
CommandServiceImpl.fakeCommand(
|
|
25
25
|
'SHOULD_WATCH_VIEWS=true MAXIMUM_LOG_PREFIXES_LENGTH=0 yarn boot',
|
|
26
26
|
{
|
|
27
27
|
code: 200,
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
FeatureActionResponse,
|
|
6
6
|
FeatureInstallResponse,
|
|
7
7
|
} from '../../features/features.types'
|
|
8
|
-
import
|
|
8
|
+
import CommandServiceImpl from '../../services/CommandService'
|
|
9
9
|
import AbstractSchemaTest from '../../tests/AbstractSchemaTest'
|
|
10
10
|
import testUtil from '../../tests/utilities/test.utility'
|
|
11
11
|
|
|
@@ -273,7 +273,7 @@ export default class FeatureCommandExecuterContTest extends AbstractSchemaTest {
|
|
|
273
273
|
}
|
|
274
274
|
|
|
275
275
|
private static fakeInstallCommands() {
|
|
276
|
-
|
|
276
|
+
CommandServiceImpl.fakeCommand(new RegExp(/yarn|npm/gis), {
|
|
277
277
|
code: 0,
|
|
278
278
|
})
|
|
279
279
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import { errorAssert } from '@sprucelabs/test-utils'
|
|
3
3
|
import { ENABLE_NPM_CACHE_COMMAND } from '../../features/cache/constants'
|
|
4
|
-
import
|
|
4
|
+
import CommandServiceImpl from '../../services/CommandService'
|
|
5
5
|
import AbstractCliTest from '../../tests/AbstractCliTest'
|
|
6
6
|
|
|
7
7
|
export default class ActionExecuter4Test extends AbstractCliTest {
|
|
8
8
|
protected static async beforeEach() {
|
|
9
9
|
await super.beforeEach()
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
CommandServiceImpl.fakeCommand(/which docker/gis, {
|
|
12
12
|
code: 0,
|
|
13
13
|
})
|
|
14
|
-
|
|
14
|
+
CommandServiceImpl.fakeCommand(ENABLE_NPM_CACHE_COMMAND, {
|
|
15
15
|
code: 0,
|
|
16
16
|
})
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
2
|
import FeatureInstaller from '../../features/FeatureInstaller'
|
|
3
|
-
import
|
|
3
|
+
import CommandServiceImpl from '../../services/CommandService'
|
|
4
4
|
import AbstractCliTest from '../../tests/AbstractCliTest'
|
|
5
5
|
|
|
6
6
|
export default class FeatureInstallerTest extends AbstractCliTest {
|
|
@@ -28,7 +28,7 @@ export default class FeatureInstallerTest extends AbstractCliTest {
|
|
|
28
28
|
|
|
29
29
|
@test()
|
|
30
30
|
protected static async afterPackageInstallIsCalledOncePerFeature() {
|
|
31
|
-
|
|
31
|
+
CommandServiceImpl.fakeCommand(/yarn/, {
|
|
32
32
|
code: 0,
|
|
33
33
|
})
|
|
34
34
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
3
|
-
import
|
|
3
|
+
import CommandServiceImpl from '../../services/CommandService'
|
|
4
4
|
import PkgService from '../../services/PkgService'
|
|
5
5
|
import AbstractSkillTest from '../../tests/AbstractSkillTest'
|
|
6
6
|
|
|
@@ -26,7 +26,7 @@ export default class PkgServiceTest extends AbstractSkillTest {
|
|
|
26
26
|
|
|
27
27
|
@test()
|
|
28
28
|
protected static async handlesAtLatestInName() {
|
|
29
|
-
|
|
29
|
+
CommandServiceImpl.fakeCommand(new RegExp(/yarn/gis), {
|
|
30
30
|
code: 0,
|
|
31
31
|
})
|
|
32
32
|
|
|
@@ -37,7 +37,7 @@ export default class PkgServiceTest extends AbstractSkillTest {
|
|
|
37
37
|
|
|
38
38
|
@test()
|
|
39
39
|
protected static async ifInstallingOnlySpruceModulesShouldNotRunNPMAdd() {
|
|
40
|
-
|
|
40
|
+
CommandServiceImpl.fakeCommand(
|
|
41
41
|
new RegExp(/npm.*?install.*?--no-progress/gis),
|
|
42
42
|
{
|
|
43
43
|
code: 1,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { test, assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import
|
|
2
|
+
import CommandServiceImpl from '../../services/CommandService'
|
|
3
3
|
import AbstractCliTest from '../../tests/AbstractCliTest'
|
|
4
4
|
|
|
5
5
|
export default class StoreFeatureTest extends AbstractCliTest {
|
|
@@ -7,7 +7,7 @@ export default class StoreFeatureTest extends AbstractCliTest {
|
|
|
7
7
|
protected static async syncsOnWillExecute() {
|
|
8
8
|
await this.FeatureFixture().installCachedFeatures('stores')
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
CommandServiceImpl.fakeCommand(/yarn/, {
|
|
11
11
|
code: 0,
|
|
12
12
|
})
|
|
13
13
|
|
package/src/boot.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { CLI_HERO } from './constants'
|
|
|
7
7
|
import { FeatureInstallerImpl } from './features/FeatureInstaller'
|
|
8
8
|
import InFlightEntertainment from './InFlightEntertainment'
|
|
9
9
|
import TerminalInterface from './interfaces/TerminalInterface'
|
|
10
|
-
import
|
|
10
|
+
import CommandServiceImpl from './services/CommandService'
|
|
11
11
|
|
|
12
12
|
export async function run(argv: string[] = []): Promise<void> {
|
|
13
13
|
const program = new Command()
|
|
@@ -73,7 +73,7 @@ async function setupInFlightEntertainment(ui: TerminalInterface) {
|
|
|
73
73
|
TerminalInterface.doesSupportColor() &&
|
|
74
74
|
process.env.ENABLE_INSTALL_ENTERTAINMENT !== 'false'
|
|
75
75
|
) {
|
|
76
|
-
const command = new
|
|
76
|
+
const command = new CommandServiceImpl(
|
|
77
77
|
diskUtil.resolvePath(__dirname, '../')
|
|
78
78
|
)
|
|
79
79
|
InFlightEntertainment.setup({ command, ui })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SpruceSchemas } from '#spruce/schemas/schemas.types'
|
|
2
2
|
import bootSkillOptionsSchema from '#spruce/schemas/spruceCli/v2020_07_22/bootSkillOptions.schema'
|
|
3
3
|
import SpruceError from '../../../errors/SpruceError'
|
|
4
|
-
import
|
|
4
|
+
import CommandServiceImpl from '../../../services/CommandService'
|
|
5
5
|
import AbstractAction from '../../AbstractAction'
|
|
6
6
|
import { FeatureActionResponse } from '../../features.types'
|
|
7
7
|
|
|
@@ -64,7 +64,7 @@ export default class BootAction extends AbstractAction<OptionsSchema> {
|
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
private async boot(
|
|
67
|
-
command:
|
|
67
|
+
command: CommandServiceImpl,
|
|
68
68
|
script: string,
|
|
69
69
|
resolve: (value: unknown) => void,
|
|
70
70
|
reject: (reason?: any) => void
|
|
@@ -7,19 +7,19 @@ import {
|
|
|
7
7
|
import { buildSchema } from '@sprucelabs/schema'
|
|
8
8
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
9
9
|
import SpruceError from '../../errors/SpruceError'
|
|
10
|
-
import
|
|
10
|
+
import CommandServiceImpl from '../../services/CommandService'
|
|
11
11
|
import JestJsonParser from '../../tests/JestJsonParser'
|
|
12
12
|
import { SpruceTestResults } from './test.types'
|
|
13
13
|
|
|
14
14
|
export default class TestRunner extends AbstractEventEmitter<TestRunnerContract> {
|
|
15
15
|
private cwd: string
|
|
16
|
-
private commandService:
|
|
16
|
+
private commandService: CommandServiceImpl
|
|
17
17
|
private wasKilled = false
|
|
18
18
|
private testResults: SpruceTestResults = { totalTestFiles: 0 }
|
|
19
19
|
|
|
20
20
|
public constructor(options: {
|
|
21
21
|
cwd: string
|
|
22
|
-
commandService:
|
|
22
|
+
commandService: CommandServiceImpl
|
|
23
23
|
}) {
|
|
24
24
|
super(testRunnerContract)
|
|
25
25
|
this.cwd = options.cwd
|
|
@@ -14,11 +14,14 @@ export default class MigrationAction extends AbstractAction<OptionsSchema> {
|
|
|
14
14
|
public async execute(): Promise<FeatureActionResponse> {
|
|
15
15
|
const testFinder = StaticTestFinderImpl.Finder()
|
|
16
16
|
const testFileMigrator = StaticToInstanceTestFileMigratorImpl.Migrator()
|
|
17
|
+
const lintService = this.Service('lint')
|
|
17
18
|
const migrator = StaticToInstanceMigratorImpl.Migrator({
|
|
18
19
|
testFinder,
|
|
19
20
|
testFileMigrator,
|
|
21
|
+
lintService,
|
|
20
22
|
})
|
|
21
23
|
|
|
24
|
+
this.ui.startLoading('Migrating tests...')
|
|
22
25
|
const path = diskUtil.resolvePath(this.cwd, 'src', '__tests__')
|
|
23
26
|
const { totalTestsSkipped, totalTestsUpdated } =
|
|
24
27
|
await migrator.run(path)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import semver from 'semver'
|
|
2
|
-
import
|
|
2
|
+
import CommandServiceImpl from '../../../services/CommandService'
|
|
3
3
|
|
|
4
|
-
export default class VsCodeService extends
|
|
4
|
+
export default class VsCodeService extends CommandServiceImpl {
|
|
5
5
|
/** Returns whether or not vscode is installed */
|
|
6
6
|
public async isInstalled(): Promise<boolean> {
|
|
7
7
|
const isInstalled = false
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import CommandServiceImpl from './CommandService'
|
|
2
2
|
import LintService from './LintService'
|
|
3
3
|
|
|
4
4
|
export default class BuildService {
|
|
@@ -10,11 +10,11 @@ export default class BuildService {
|
|
|
10
10
|
return this.commandService.cwd
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
private commandService:
|
|
13
|
+
private commandService: CommandServiceImpl
|
|
14
14
|
private lintService: LintService
|
|
15
15
|
|
|
16
16
|
public constructor(
|
|
17
|
-
commandService:
|
|
17
|
+
commandService: CommandServiceImpl,
|
|
18
18
|
lintService: LintService
|
|
19
19
|
) {
|
|
20
20
|
this.commandService = commandService
|
|
@@ -9,7 +9,7 @@ import SpruceError from '../errors/SpruceError'
|
|
|
9
9
|
|
|
10
10
|
process.setMaxListeners(100)
|
|
11
11
|
|
|
12
|
-
export default class CommandService {
|
|
12
|
+
export default class CommandServiceImpl implements CommandService {
|
|
13
13
|
public cwd: string
|
|
14
14
|
private activeChildProcess: ChildProcess | undefined
|
|
15
15
|
private ignoreCloseErrors = false
|
|
@@ -25,17 +25,7 @@ export default class CommandService {
|
|
|
25
25
|
|
|
26
26
|
public async execute(
|
|
27
27
|
cmd: string,
|
|
28
|
-
options?:
|
|
29
|
-
ignoreErrors?: boolean
|
|
30
|
-
args?: string[]
|
|
31
|
-
shouldStream?: boolean
|
|
32
|
-
outStream?: Writable
|
|
33
|
-
onError?: (error: string) => void
|
|
34
|
-
onData?: (data: string) => void
|
|
35
|
-
spawnOptions?: SpawnOptions
|
|
36
|
-
forceColor?: boolean
|
|
37
|
-
env?: Record<string, any>
|
|
38
|
-
}
|
|
28
|
+
options?: ExecuteCommandOptions
|
|
39
29
|
): Promise<{
|
|
40
30
|
stdout: string
|
|
41
31
|
}> {
|
|
@@ -51,7 +41,7 @@ export default class CommandService {
|
|
|
51
41
|
const { mockResponse, mockKey } = this.getMockResponse(executable, args)
|
|
52
42
|
|
|
53
43
|
if (mockResponse) {
|
|
54
|
-
|
|
44
|
+
CommandServiceImpl.commandsRunCapturedByMockResponses.push(mockKey)
|
|
55
45
|
mockResponse.callback?.(executable, args)
|
|
56
46
|
|
|
57
47
|
if (mockResponse.code !== 0) {
|
|
@@ -174,7 +164,7 @@ export default class CommandService {
|
|
|
174
164
|
|
|
175
165
|
private getMockResponse(executable: string, args: string[]) {
|
|
176
166
|
const mockKey = `${executable} ${args.join(' ')}`.trim()
|
|
177
|
-
const commands =
|
|
167
|
+
const commands = CommandServiceImpl.fakeResponses
|
|
178
168
|
const match = commands.find((r) =>
|
|
179
169
|
r.command instanceof RegExp
|
|
180
170
|
? mockKey.search(r.command) > -1
|
|
@@ -208,3 +198,26 @@ interface FakedCommandResponse {
|
|
|
208
198
|
stderr?: string
|
|
209
199
|
callback?: FakedCommandCallback
|
|
210
200
|
}
|
|
201
|
+
|
|
202
|
+
export interface CommandService {
|
|
203
|
+
execute(
|
|
204
|
+
cmd: string,
|
|
205
|
+
options?: ExecuteCommandOptions
|
|
206
|
+
): Promise<{
|
|
207
|
+
stdout: string
|
|
208
|
+
}>
|
|
209
|
+
kill(): void
|
|
210
|
+
pid(): number | undefined
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export interface ExecuteCommandOptions {
|
|
214
|
+
ignoreErrors?: boolean
|
|
215
|
+
args?: string[]
|
|
216
|
+
shouldStream?: boolean
|
|
217
|
+
outStream?: Writable
|
|
218
|
+
onError?: (error: string) => void
|
|
219
|
+
onData?: (data: string) => void
|
|
220
|
+
spawnOptions?: SpawnOptions
|
|
221
|
+
forceColor?: boolean
|
|
222
|
+
env?: Record<string, any>
|
|
223
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
2
2
|
import TerminalInterface from '../interfaces/TerminalInterface'
|
|
3
|
-
import
|
|
3
|
+
import CommandServiceImpl from './CommandService'
|
|
4
4
|
|
|
5
5
|
export default class GameService {
|
|
6
|
-
private command:
|
|
6
|
+
private command: CommandServiceImpl
|
|
7
7
|
private ui: TerminalInterface
|
|
8
8
|
private statusMessage?: string
|
|
9
9
|
private killed = false
|
|
10
10
|
|
|
11
|
-
public constructor(command:
|
|
11
|
+
public constructor(command: CommandServiceImpl, ui: TerminalInterface) {
|
|
12
12
|
this.command = command
|
|
13
13
|
this.ui = ui
|
|
14
14
|
this.command.cwd = diskUtil.resolvePath(__dirname, '../../')
|
|
@@ -3,7 +3,7 @@ import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
|
3
3
|
import fs from 'fs-extra'
|
|
4
4
|
import md5 from 'md5'
|
|
5
5
|
import SpruceError from '../errors/SpruceError'
|
|
6
|
-
import
|
|
6
|
+
import CommandServiceImpl from './CommandService'
|
|
7
7
|
|
|
8
8
|
export default class ImportService {
|
|
9
9
|
public cwd: string
|
|
@@ -14,10 +14,10 @@ export default class ImportService {
|
|
|
14
14
|
private static cachedImports: Record<string, Record<string, any>> = {}
|
|
15
15
|
private static importCacheDir: string =
|
|
16
16
|
diskUtil.createTempDir('import-service')
|
|
17
|
-
private command:
|
|
17
|
+
private command: CommandServiceImpl
|
|
18
18
|
private static isCachingEnabled: boolean
|
|
19
19
|
|
|
20
|
-
public constructor(options: { cwd: string; command:
|
|
20
|
+
public constructor(options: { cwd: string; command: CommandServiceImpl }) {
|
|
21
21
|
this.cwd = options.cwd
|
|
22
22
|
this.command = options.command
|
|
23
23
|
}
|
|
@@ -2,7 +2,7 @@ import { SchemaError } from '@sprucelabs/schema'
|
|
|
2
2
|
// import { ESLint } from 'eslint'
|
|
3
3
|
// import fs from 'fs-extra'
|
|
4
4
|
import SpruceError from '../errors/SpruceError'
|
|
5
|
-
import CommandService from './CommandService'
|
|
5
|
+
import { CommandService } from './CommandService'
|
|
6
6
|
|
|
7
7
|
export default class LintService {
|
|
8
8
|
public cwd: string
|
|
@@ -4,12 +4,12 @@ import {
|
|
|
4
4
|
PkgService as BasePkgService,
|
|
5
5
|
} from '@sprucelabs/spruce-skill-utils'
|
|
6
6
|
import isCi from '../utilities/isCi'
|
|
7
|
-
import
|
|
7
|
+
import CommandServiceImpl from './CommandService'
|
|
8
8
|
|
|
9
9
|
export default class PkgService extends BasePkgService {
|
|
10
|
-
private commandService:
|
|
10
|
+
private commandService: CommandServiceImpl
|
|
11
11
|
|
|
12
|
-
public constructor(cwd: string, commandService:
|
|
12
|
+
public constructor(cwd: string, commandService: CommandServiceImpl) {
|
|
13
13
|
super(cwd)
|
|
14
14
|
this.commandService = commandService
|
|
15
15
|
}
|
|
@@ -9,7 +9,7 @@ import { FeatureCode } from '../features/features.types'
|
|
|
9
9
|
import SchemaService from '../features/schema/services/SchemaService'
|
|
10
10
|
import VsCodeService from '../features/vscode/services/VsCodeService'
|
|
11
11
|
import BuildService from './BuildService'
|
|
12
|
-
import
|
|
12
|
+
import CommandServiceImpl from './CommandService'
|
|
13
13
|
import DependencyService from './DependencyService'
|
|
14
14
|
import ImportService from './ImportService'
|
|
15
15
|
import LintService from './LintService'
|
|
@@ -41,14 +41,14 @@ export default class ServiceFactory {
|
|
|
41
41
|
case 'schema':
|
|
42
42
|
return new SchemaService({
|
|
43
43
|
cwd,
|
|
44
|
-
command: new
|
|
44
|
+
command: new CommandServiceImpl(cwd),
|
|
45
45
|
}) as ServiceMap[S]
|
|
46
46
|
case 'lint':
|
|
47
47
|
return new (Class ?? LintService)(cwd, () =>
|
|
48
48
|
this.Service(cwd, 'command')
|
|
49
49
|
) as ServiceMap[S]
|
|
50
50
|
case 'command': {
|
|
51
|
-
return new
|
|
51
|
+
return new CommandServiceImpl(cwd) as ServiceMap[S]
|
|
52
52
|
}
|
|
53
53
|
case 'remote':
|
|
54
54
|
return new RemoteService(new EnvService(cwd)) as ServiceMap[S]
|
|
@@ -68,7 +68,7 @@ export default class ServiceFactory {
|
|
|
68
68
|
case 'import':
|
|
69
69
|
return this.buildImportService(cwd) as ServiceMap[S]
|
|
70
70
|
case 'build': {
|
|
71
|
-
const commandService = new
|
|
71
|
+
const commandService = new CommandServiceImpl(cwd)
|
|
72
72
|
return new BuildService(
|
|
73
73
|
commandService,
|
|
74
74
|
this.Service(cwd, 'lint')
|
|
@@ -86,7 +86,7 @@ export default class ServiceFactory {
|
|
|
86
86
|
private buildImportService(cwd: string): ImportService {
|
|
87
87
|
return new ImportService({
|
|
88
88
|
cwd,
|
|
89
|
-
command: new
|
|
89
|
+
command: new CommandServiceImpl(cwd),
|
|
90
90
|
})
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -104,7 +104,7 @@ export interface ServiceMap {
|
|
|
104
104
|
vsCode: VsCodeService
|
|
105
105
|
schema: SchemaService
|
|
106
106
|
lint: LintService
|
|
107
|
-
command:
|
|
107
|
+
command: CommandServiceImpl
|
|
108
108
|
typeChecker: TypeCheckerService
|
|
109
109
|
import: ImportService
|
|
110
110
|
build: BuildService
|
|
@@ -22,7 +22,7 @@ import OnboardingStore from '../features/onboard/stores/OnboardingStore'
|
|
|
22
22
|
import SkillStore from '../features/skill/stores/SkillStore'
|
|
23
23
|
import CliGlobalEmitter, { GlobalEmitter } from '../GlobalEmitter'
|
|
24
24
|
import SpyInterface from '../interfaces/SpyInterface'
|
|
25
|
-
import
|
|
25
|
+
import CommandServiceImpl from '../services/CommandService'
|
|
26
26
|
import ImportService from '../services/ImportService'
|
|
27
27
|
import LintService from '../services/LintService'
|
|
28
28
|
import ServiceFactory, { Service, ServiceMap } from '../services/ServiceFactory'
|
|
@@ -114,7 +114,7 @@ export default abstract class AbstractCliTest extends AbstractSpruceTest {
|
|
|
114
114
|
ImportService.clearCache()
|
|
115
115
|
SkillStore.clearCurrentSkill()
|
|
116
116
|
EventStore.clearCache()
|
|
117
|
-
|
|
117
|
+
CommandServiceImpl.clearFakedResponses()
|
|
118
118
|
MercuryClientFactory.reset()
|
|
119
119
|
MercuryClientFactory.setIsTestMode(false)
|
|
120
120
|
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import
|
|
2
|
+
import CommandServiceImpl from '../services/CommandService'
|
|
3
3
|
|
|
4
4
|
type Command = RegExp | string
|
|
5
5
|
|
|
6
6
|
export default class CommandFaker {
|
|
7
7
|
public fakeCommand(command: Command, code = 0) {
|
|
8
|
-
|
|
8
|
+
CommandServiceImpl.fakeCommand(command, {
|
|
9
9
|
code,
|
|
10
10
|
})
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
public on(command: Command, cb: () => void) {
|
|
14
|
-
|
|
14
|
+
CommandServiceImpl.fakeCommand(command, {
|
|
15
15
|
code: 0,
|
|
16
16
|
callback: cb,
|
|
17
17
|
})
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
public makeCommandThrow(command: Command) {
|
|
21
|
-
|
|
21
|
+
CommandServiceImpl.fakeCommand(command, {
|
|
22
22
|
code: 1,
|
|
23
23
|
callback: () =>
|
|
24
24
|
assert.fail(`${command} should not have been called`),
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { assertOptions } from '@sprucelabs/schema'
|
|
2
2
|
import { diskUtil } from '@sprucelabs/spruce-skill-utils'
|
|
3
|
+
import LintService from '../../services/LintService'
|
|
3
4
|
import StaticTestFinder from './StaticTestFinder'
|
|
4
5
|
import { StaticToInstanceTestFileMigrator } from './StaticToInstanceTestFileMigrator'
|
|
5
6
|
|
|
@@ -13,15 +14,21 @@ export default class StaticToInstanceMigratorImpl
|
|
|
13
14
|
|
|
14
15
|
private testFinder: StaticTestFinder
|
|
15
16
|
private testFileMigrator: StaticToInstanceTestFileMigrator
|
|
17
|
+
private lintService: LintService
|
|
16
18
|
|
|
17
19
|
protected constructor(options: StaticToInstanceMigratorOptions) {
|
|
18
|
-
const { testFinder, testFileMigrator } = options
|
|
20
|
+
const { testFinder, testFileMigrator, lintService } = options
|
|
19
21
|
this.testFinder = testFinder
|
|
20
22
|
this.testFileMigrator = testFileMigrator
|
|
23
|
+
this.lintService = lintService
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
public static Migrator(options: StaticToInstanceMigratorOptions) {
|
|
24
|
-
assertOptions(options, [
|
|
27
|
+
assertOptions(options, [
|
|
28
|
+
'testFinder',
|
|
29
|
+
'testFileMigrator',
|
|
30
|
+
'lintService',
|
|
31
|
+
])
|
|
25
32
|
return new (this.Class ?? this)(options)
|
|
26
33
|
}
|
|
27
34
|
|
|
@@ -43,6 +50,8 @@ export default class StaticToInstanceMigratorImpl
|
|
|
43
50
|
}
|
|
44
51
|
}
|
|
45
52
|
|
|
53
|
+
await this.lintService.fix('**/*.ts')
|
|
54
|
+
|
|
46
55
|
return {
|
|
47
56
|
totalTestsUpdated,
|
|
48
57
|
totalTestsSkipped,
|
|
@@ -61,6 +70,7 @@ export default class StaticToInstanceMigratorImpl
|
|
|
61
70
|
export interface StaticToInstanceMigratorOptions {
|
|
62
71
|
testFinder: StaticTestFinder
|
|
63
72
|
testFileMigrator: StaticToInstanceTestFileMigrator
|
|
73
|
+
lintService: LintService
|
|
64
74
|
}
|
|
65
75
|
|
|
66
76
|
export interface StaticToInstanceMigratorResults {
|