@sprucelabs/spruce-cli 27.0.4 → 27.1.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/.spruce/schemas/schemas.types.d.ts +10 -0
  3. package/build/.spruce/schemas/spruceCli/v2020_07_22/upgradeSkillOptions.schema.js +8 -0
  4. package/build/.spruce/schemas/spruceCli/v2020_07_22/upgradeSkillOptions.schema.js.map +1 -1
  5. package/build/GlobalEmitter.d.ts +6 -0
  6. package/build/GlobalEmitter.js +6 -0
  7. package/build/GlobalEmitter.js.map +1 -1
  8. package/build/InFlightEntertainment.d.ts +2 -2
  9. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js +4 -0
  10. package/build/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.js.map +1 -1
  11. package/build/__tests__/behavioral/upgrading/UpgradingASkillSkippingBuild.test.d.ts +5 -0
  12. package/build/__tests__/behavioral/upgrading/UpgradingASkillSkippingBuild.test.js +29 -0
  13. package/build/__tests__/behavioral/upgrading/UpgradingASkillSkippingBuild.test.js.map +1 -0
  14. package/build/features/ActionExecuter.js +1 -0
  15. package/build/features/ActionExecuter.js.map +1 -1
  16. package/build/features/node/NodeFeature.js +5 -3
  17. package/build/features/node/NodeFeature.js.map +1 -1
  18. package/build/schemas/v2020_07_22/upgradeSkillOptions.builder.d.ts +6 -0
  19. package/build/schemas/v2020_07_22/upgradeSkillOptions.builder.js +6 -0
  20. package/build/schemas/v2020_07_22/upgradeSkillOptions.builder.js.map +1 -1
  21. package/build/services/BuildService.d.ts +2 -2
  22. package/build/services/BuildService.js +2 -2
  23. package/build/services/BuildService.js.map +1 -1
  24. package/build/services/CommandService.d.ts +5 -1
  25. package/build/services/CommandService.js +6 -0
  26. package/build/services/CommandService.js.map +1 -1
  27. package/build/services/GameService.d.ts +2 -2
  28. package/build/services/GameService.js +1 -1
  29. package/build/services/GameService.js.map +1 -1
  30. package/build/tests/CommandFaker.js +1 -1
  31. package/build/tests/CommandFaker.js.map +1 -1
  32. package/package.json +9 -9
  33. package/src/.spruce/schemas/schemas.types.ts +147 -137
  34. package/src/.spruce/schemas/spruceCli/v2020_07_22/upgradeSkillOptions.schema.ts +8 -0
  35. package/src/GlobalEmitter.ts +6 -0
  36. package/src/InFlightEntertainment.ts +2 -2
  37. package/src/__tests__/behavioral/tests/migrationToInstance/StaticToInstanceMigrator.test.ts +5 -0
  38. package/src/__tests__/behavioral/upgrading/UpgradingASkillSkippingBuild.test.ts +17 -0
  39. package/src/features/ActionExecuter.ts +1 -0
  40. package/src/features/node/NodeFeature.ts +5 -3
  41. package/src/schemas/v2020_07_22/upgradeSkillOptions.builder.ts +6 -0
  42. package/src/services/BuildService.ts +5 -5
  43. package/src/services/CommandService.ts +11 -1
  44. package/src/services/GameService.ts +4 -4
  45. package/src/tests/CommandFaker.ts +1 -1
@@ -0,0 +1,17 @@
1
+ import { assert, test } from '@sprucelabs/test-utils'
2
+ import AbstractSkillTest from '../../../tests/AbstractSkillTest'
3
+
4
+ export default class UpgradingASkillSkippingBuildTest extends AbstractSkillTest {
5
+ protected static skillCacheKey = 'skills'
6
+ @test()
7
+ protected static async canSkipCleaningAndBuildingOnUpgrade() {
8
+ this.commandFaker.fakeInstall()
9
+ this.commandFaker.fakeCleanBuild(1)
10
+
11
+ const { errors } = await this.Action('node', 'upgrade').execute({
12
+ shouldBuild: false,
13
+ })
14
+
15
+ assert.isFalsy(errors, 'Should not have tried to build.')
16
+ }
17
+ }
@@ -139,6 +139,7 @@ export default class ActionExecuter {
139
139
  results: response,
140
140
  featureCode,
141
141
  actionCode,
142
+ options: actionOptions,
142
143
  }
143
144
  )
144
145
 
@@ -38,9 +38,11 @@ export default class NodeFeature<
38
38
  super(options)
39
39
 
40
40
  void this.emitter.on('feature.did-execute', async (payload) => {
41
+ const { featureCode, actionCode, options } = payload
41
42
  const shouldUpgrade =
42
- payload.featureCode === 'node' &&
43
- payload.actionCode === 'upgrade' &&
43
+ featureCode === 'node' &&
44
+ actionCode === 'upgrade' &&
45
+ options?.shouldBuild !== false &&
44
46
  this.features.isInSpruceModule()
45
47
 
46
48
  if (shouldUpgrade) {
@@ -68,7 +70,7 @@ export default class NodeFeature<
68
70
 
69
71
  return {
70
72
  summaryLines: [
71
- 'Build cleared.',
73
+ 'Old built files cleared.',
72
74
  'Lint rules applied to source.',
73
75
  'Code rebuilt successfully.',
74
76
  ],
@@ -6,6 +6,12 @@ export default buildSchema({
6
6
  description:
7
7
  'Upgrade. Everything. Heads up, this can take a few minutes. ⏱',
8
8
  fields: {
9
+ shouldBuild: {
10
+ type: 'boolean',
11
+ label: 'Build after upgrade',
12
+ defaultValue: true,
13
+ hint: 'Should I build your source after the upgrade?',
14
+ },
9
15
  upgradeMode: {
10
16
  type: 'select',
11
17
  label: 'Upgrade mode',
@@ -1,20 +1,20 @@
1
- import CommandServiceImpl from './CommandService'
1
+ import { CommandService } from './CommandService'
2
2
  import LintService from './LintService'
3
3
 
4
4
  export default class BuildService {
5
5
  public set cwd(cwd: string) {
6
- this.commandService.cwd = cwd
6
+ this.commandService.setCwd(cwd)
7
7
  }
8
8
 
9
9
  public get cwd() {
10
- return this.commandService.cwd
10
+ return this.commandService.getCwd()
11
11
  }
12
12
 
13
- private commandService: CommandServiceImpl
13
+ private commandService: CommandService
14
14
  private lintService: LintService
15
15
 
16
16
  public constructor(
17
- commandService: CommandServiceImpl,
17
+ commandService: CommandService,
18
18
  lintService: LintService
19
19
  ) {
20
20
  this.commandService = commandService
@@ -10,7 +10,7 @@ import SpruceError from '../errors/SpruceError'
10
10
  process.setMaxListeners(100)
11
11
 
12
12
  export default class CommandServiceImpl implements CommandService {
13
- public cwd: string
13
+ private cwd: string
14
14
  private activeChildProcess: ChildProcess | undefined
15
15
  private ignoreCloseErrors = false
16
16
  private static fakeResponses: {
@@ -23,6 +23,14 @@ export default class CommandServiceImpl implements CommandService {
23
23
  this.cwd = cwd
24
24
  }
25
25
 
26
+ public getCwd() {
27
+ return this.cwd
28
+ }
29
+
30
+ public setCwd(cwd: string) {
31
+ this.cwd = cwd
32
+ }
33
+
26
34
  public async execute(
27
35
  cmd: string,
28
36
  options?: ExecuteCommandOptions
@@ -206,6 +214,8 @@ export interface CommandService {
206
214
  ): Promise<{
207
215
  stdout: string
208
216
  }>
217
+ getCwd(): string
218
+ setCwd(cwd: string): void
209
219
  kill(): void
210
220
  pid(): number | undefined
211
221
  }
@@ -1,17 +1,17 @@
1
1
  import { diskUtil } from '@sprucelabs/spruce-skill-utils'
2
2
  import TerminalInterface from '../interfaces/TerminalInterface'
3
- import CommandServiceImpl from './CommandService'
3
+ import { CommandService } from './CommandService'
4
4
 
5
5
  export default class GameService {
6
- private command: CommandServiceImpl
6
+ private command: CommandService
7
7
  private ui: TerminalInterface
8
8
  private statusMessage?: string
9
9
  private killed = false
10
10
 
11
- public constructor(command: CommandServiceImpl, ui: TerminalInterface) {
11
+ public constructor(command: CommandService, ui: TerminalInterface) {
12
12
  this.command = command
13
13
  this.ui = ui
14
- this.command.cwd = diskUtil.resolvePath(__dirname, '../../')
14
+ this.command.setCwd(diskUtil.resolvePath(__dirname, '../../'))
15
15
  }
16
16
 
17
17
  public setStatusMessage(message: string) {
@@ -39,6 +39,6 @@ export default class CommandFaker {
39
39
  }
40
40
 
41
41
  public fakeInstall(code = 0) {
42
- this.fakeCommand(/.*?install/gis, code)
42
+ this.fakeCommand(/.*?(add|install)/gis, code)
43
43
  }
44
44
  }