@contember/cli 1.1.2 → 1.2.0-alpha.11

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 (98) hide show
  1. package/Dockerfile +2 -2
  2. package/dist/src/commands/deploy/DeployCommand.d.ts +3 -1
  3. package/dist/src/commands/deploy/DeployCommand.d.ts.map +1 -1
  4. package/dist/src/commands/deploy/DeployCommand.js +10 -15
  5. package/dist/src/commands/deploy/DeployCommand.js.map +1 -1
  6. package/dist/src/commands/migrations/MigrationAmendCommand.d.ts +4 -2
  7. package/dist/src/commands/migrations/MigrationAmendCommand.d.ts.map +1 -1
  8. package/dist/src/commands/migrations/MigrationAmendCommand.js +8 -2
  9. package/dist/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
  10. package/dist/src/commands/migrations/MigrationCreateHelper.d.ts +5 -4
  11. package/dist/src/commands/migrations/MigrationCreateHelper.d.ts.map +1 -1
  12. package/dist/src/commands/migrations/MigrationCreateHelper.js +2 -9
  13. package/dist/src/commands/migrations/MigrationCreateHelper.js.map +1 -1
  14. package/dist/src/commands/migrations/MigrationDescribeCommand.d.ts +4 -1
  15. package/dist/src/commands/migrations/MigrationDescribeCommand.d.ts.map +1 -1
  16. package/dist/src/commands/migrations/MigrationDescribeCommand.js +8 -3
  17. package/dist/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
  18. package/dist/src/commands/migrations/MigrationDiffCommand.d.ts +4 -2
  19. package/dist/src/commands/migrations/MigrationDiffCommand.d.ts.map +1 -1
  20. package/dist/src/commands/migrations/MigrationDiffCommand.js +9 -2
  21. package/dist/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
  22. package/dist/src/commands/migrations/MigrationExecuteCommand.d.ts +4 -2
  23. package/dist/src/commands/migrations/MigrationExecuteCommand.d.ts.map +1 -1
  24. package/dist/src/commands/migrations/MigrationExecuteCommand.js +8 -5
  25. package/dist/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
  26. package/dist/src/commands/migrations/MigrationRebaseCommand.d.ts +4 -2
  27. package/dist/src/commands/migrations/MigrationRebaseCommand.d.ts.map +1 -1
  28. package/dist/src/commands/migrations/MigrationRebaseCommand.js +8 -2
  29. package/dist/src/commands/migrations/MigrationRebaseCommand.js.map +1 -1
  30. package/dist/src/commands/migrations/MigrationStatusCommand.d.ts +4 -1
  31. package/dist/src/commands/migrations/MigrationStatusCommand.d.ts.map +1 -1
  32. package/dist/src/commands/migrations/MigrationStatusCommand.js +8 -3
  33. package/dist/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  34. package/dist/src/commands/migrations/SystemApiClientResolver.d.ts +3 -3
  35. package/dist/src/commands/migrations/SystemApiClientResolver.d.ts.map +1 -1
  36. package/dist/src/commands/project/ProjectCreateCommand.d.ts +3 -0
  37. package/dist/src/commands/project/ProjectCreateCommand.d.ts.map +1 -1
  38. package/dist/src/commands/project/ProjectCreateCommand.js +5 -1
  39. package/dist/src/commands/project/ProjectCreateCommand.js.map +1 -1
  40. package/dist/src/commands/project/ProjectGenerateDocumentation.d.ts +4 -2
  41. package/dist/src/commands/project/ProjectGenerateDocumentation.d.ts.map +1 -1
  42. package/dist/src/commands/project/ProjectGenerateDocumentation.js +8 -4
  43. package/dist/src/commands/project/ProjectGenerateDocumentation.js.map +1 -1
  44. package/dist/src/commands/project/ProjectPrintSchemaCommand.d.ts +4 -1
  45. package/dist/src/commands/project/ProjectPrintSchemaCommand.d.ts.map +1 -1
  46. package/dist/src/commands/project/ProjectPrintSchemaCommand.js +10 -6
  47. package/dist/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  48. package/dist/src/commands/project/ProjectValidateCommand.d.ts +4 -2
  49. package/dist/src/commands/project/ProjectValidateCommand.d.ts.map +1 -1
  50. package/dist/src/commands/project/ProjectValidateCommand.js +8 -5
  51. package/dist/src/commands/project/ProjectValidateCommand.js.map +1 -1
  52. package/dist/src/commands/tenant/CreateApiKeyCommand.d.ts +3 -0
  53. package/dist/src/commands/tenant/CreateApiKeyCommand.d.ts.map +1 -1
  54. package/dist/src/commands/tenant/CreateApiKeyCommand.js +5 -2
  55. package/dist/src/commands/tenant/CreateApiKeyCommand.js.map +1 -1
  56. package/dist/src/commands/tenant/InviteCommand.d.ts +3 -0
  57. package/dist/src/commands/tenant/InviteCommand.d.ts.map +1 -1
  58. package/dist/src/commands/tenant/InviteCommand.js +5 -2
  59. package/dist/src/commands/tenant/InviteCommand.js.map +1 -1
  60. package/dist/src/commands/tenant/ResetPasswordCommand.d.ts +3 -0
  61. package/dist/src/commands/tenant/ResetPasswordCommand.d.ts.map +1 -1
  62. package/dist/src/commands/tenant/ResetPasswordCommand.js +5 -2
  63. package/dist/src/commands/tenant/ResetPasswordCommand.js.map +1 -1
  64. package/dist/src/commands/tenant/SignInCommand.d.ts +3 -0
  65. package/dist/src/commands/tenant/SignInCommand.d.ts.map +1 -1
  66. package/dist/src/commands/tenant/SignInCommand.js +5 -2
  67. package/dist/src/commands/tenant/SignInCommand.js.map +1 -1
  68. package/dist/src/commands/workspace/WorkspaceUpdateApiCommand.d.ts +3 -1
  69. package/dist/src/commands/workspace/WorkspaceUpdateApiCommand.d.ts.map +1 -1
  70. package/dist/src/commands/workspace/WorkspaceUpdateApiCommand.js +5 -1
  71. package/dist/src/commands/workspace/WorkspaceUpdateApiCommand.js.map +1 -1
  72. package/dist/src/run.js +22 -23
  73. package/dist/src/run.js.map +1 -1
  74. package/dist/src/tsconfig.tsbuildinfo +1 -1
  75. package/dist/src/utils/instance/interactiveUtils.d.ts +1 -1
  76. package/dist/src/utils/instance/interactiveUtils.d.ts.map +1 -1
  77. package/dist/src/utils/project/resources/out.css +97 -14
  78. package/dist/src/utils/schema.d.ts +2 -2
  79. package/dist/src/utils/schema.d.ts.map +1 -1
  80. package/package.json +15 -16
  81. package/src/commands/deploy/DeployCommand.ts +14 -15
  82. package/src/commands/migrations/MigrationAmendCommand.ts +12 -3
  83. package/src/commands/migrations/MigrationCreateHelper.ts +2 -7
  84. package/src/commands/migrations/MigrationDescribeCommand.ts +11 -3
  85. package/src/commands/migrations/MigrationDiffCommand.ts +14 -4
  86. package/src/commands/migrations/MigrationExecuteCommand.ts +11 -6
  87. package/src/commands/migrations/MigrationRebaseCommand.ts +13 -3
  88. package/src/commands/migrations/MigrationStatusCommand.ts +11 -3
  89. package/src/commands/project/ProjectCreateCommand.ts +7 -1
  90. package/src/commands/project/ProjectGenerateDocumentation.ts +12 -7
  91. package/src/commands/project/ProjectPrintSchemaCommand.ts +12 -5
  92. package/src/commands/project/ProjectValidateCommand.ts +11 -6
  93. package/src/commands/tenant/CreateApiKeyCommand.ts +7 -1
  94. package/src/commands/tenant/InviteCommand.ts +7 -1
  95. package/src/commands/tenant/ResetPasswordCommand.ts +7 -1
  96. package/src/commands/tenant/SignInCommand.ts +7 -1
  97. package/src/commands/workspace/WorkspaceUpdateApiCommand.ts +7 -1
  98. package/src/run.ts +24 -26
@@ -1,4 +1,4 @@
1
1
  import { InstanceApiEnvironment } from './environment';
2
2
  import { Workspace } from '@contember/cli-common';
3
- export declare const interactiveResolveInstanceEnvironmentFromInput: (workspace: Workspace, instance?: string | undefined) => Promise<InstanceApiEnvironment>;
3
+ export declare const interactiveResolveInstanceEnvironmentFromInput: (workspace: Workspace, instance?: string) => Promise<InstanceApiEnvironment>;
4
4
  //# sourceMappingURL=interactiveUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interactiveUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/instance/interactiveUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAgBjD,eAAO,MAAM,8CAA8C,cAC/C,SAAS,oCAElB,QAAQ,sBAAsB,CAkBhC,CAAA"}
1
+ {"version":3,"file":"interactiveUtils.d.ts","sourceRoot":"","sources":["../../../../src/utils/instance/interactiveUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAA;AAgBjD,eAAO,MAAM,8CAA8C,cAC/C,SAAS,aACT,MAAM,KACf,QAAQ,sBAAsB,CAkBhC,CAAA"}
@@ -1,5 +1,5 @@
1
1
  /*
2
- ! tailwindcss v3.0.24 | MIT License | https://tailwindcss.com
2
+ ! tailwindcss v3.1.8 | MIT License | https://tailwindcss.com
3
3
  */
4
4
 
5
5
  /*
@@ -187,6 +187,8 @@ textarea {
187
187
  /* 1 */
188
188
  font-size: 100%;
189
189
  /* 1 */
190
+ font-weight: inherit;
191
+ /* 1 */
190
192
  line-height: inherit;
191
193
  /* 1 */
192
194
  color: inherit;
@@ -353,13 +355,6 @@ input::-moz-placeholder, textarea::-moz-placeholder {
353
355
  /* 2 */
354
356
  }
355
357
 
356
- input:-ms-input-placeholder, textarea:-ms-input-placeholder {
357
- opacity: 1;
358
- /* 1 */
359
- color: #9ca3af;
360
- /* 2 */
361
- }
362
-
363
358
  input::placeholder,
364
359
  textarea::placeholder {
365
360
  opacity: 1;
@@ -415,15 +410,103 @@ video {
415
410
  height: auto;
416
411
  }
417
412
 
418
- /*
419
- Ensure the default browser behavior of the `hidden` attribute.
420
- */
413
+ *, ::before, ::after {
414
+ --tw-border-spacing-x: 0;
415
+ --tw-border-spacing-y: 0;
416
+ --tw-translate-x: 0;
417
+ --tw-translate-y: 0;
418
+ --tw-rotate: 0;
419
+ --tw-skew-x: 0;
420
+ --tw-skew-y: 0;
421
+ --tw-scale-x: 1;
422
+ --tw-scale-y: 1;
423
+ --tw-pan-x: ;
424
+ --tw-pan-y: ;
425
+ --tw-pinch-zoom: ;
426
+ --tw-scroll-snap-strictness: proximity;
427
+ --tw-ordinal: ;
428
+ --tw-slashed-zero: ;
429
+ --tw-numeric-figure: ;
430
+ --tw-numeric-spacing: ;
431
+ --tw-numeric-fraction: ;
432
+ --tw-ring-inset: ;
433
+ --tw-ring-offset-width: 0px;
434
+ --tw-ring-offset-color: #fff;
435
+ --tw-ring-color: rgb(59 130 246 / 0.5);
436
+ --tw-ring-offset-shadow: 0 0 #0000;
437
+ --tw-ring-shadow: 0 0 #0000;
438
+ --tw-shadow: 0 0 #0000;
439
+ --tw-shadow-colored: 0 0 #0000;
440
+ --tw-blur: ;
441
+ --tw-brightness: ;
442
+ --tw-contrast: ;
443
+ --tw-grayscale: ;
444
+ --tw-hue-rotate: ;
445
+ --tw-invert: ;
446
+ --tw-saturate: ;
447
+ --tw-sepia: ;
448
+ --tw-drop-shadow: ;
449
+ --tw-backdrop-blur: ;
450
+ --tw-backdrop-brightness: ;
451
+ --tw-backdrop-contrast: ;
452
+ --tw-backdrop-grayscale: ;
453
+ --tw-backdrop-hue-rotate: ;
454
+ --tw-backdrop-invert: ;
455
+ --tw-backdrop-opacity: ;
456
+ --tw-backdrop-saturate: ;
457
+ --tw-backdrop-sepia: ;
458
+ }
421
459
 
422
- [hidden] {
423
- display: none;
460
+ ::-webkit-backdrop {
461
+ --tw-border-spacing-x: 0;
462
+ --tw-border-spacing-y: 0;
463
+ --tw-translate-x: 0;
464
+ --tw-translate-y: 0;
465
+ --tw-rotate: 0;
466
+ --tw-skew-x: 0;
467
+ --tw-skew-y: 0;
468
+ --tw-scale-x: 1;
469
+ --tw-scale-y: 1;
470
+ --tw-pan-x: ;
471
+ --tw-pan-y: ;
472
+ --tw-pinch-zoom: ;
473
+ --tw-scroll-snap-strictness: proximity;
474
+ --tw-ordinal: ;
475
+ --tw-slashed-zero: ;
476
+ --tw-numeric-figure: ;
477
+ --tw-numeric-spacing: ;
478
+ --tw-numeric-fraction: ;
479
+ --tw-ring-inset: ;
480
+ --tw-ring-offset-width: 0px;
481
+ --tw-ring-offset-color: #fff;
482
+ --tw-ring-color: rgb(59 130 246 / 0.5);
483
+ --tw-ring-offset-shadow: 0 0 #0000;
484
+ --tw-ring-shadow: 0 0 #0000;
485
+ --tw-shadow: 0 0 #0000;
486
+ --tw-shadow-colored: 0 0 #0000;
487
+ --tw-blur: ;
488
+ --tw-brightness: ;
489
+ --tw-contrast: ;
490
+ --tw-grayscale: ;
491
+ --tw-hue-rotate: ;
492
+ --tw-invert: ;
493
+ --tw-saturate: ;
494
+ --tw-sepia: ;
495
+ --tw-drop-shadow: ;
496
+ --tw-backdrop-blur: ;
497
+ --tw-backdrop-brightness: ;
498
+ --tw-backdrop-contrast: ;
499
+ --tw-backdrop-grayscale: ;
500
+ --tw-backdrop-hue-rotate: ;
501
+ --tw-backdrop-invert: ;
502
+ --tw-backdrop-opacity: ;
503
+ --tw-backdrop-saturate: ;
504
+ --tw-backdrop-sepia: ;
424
505
  }
425
506
 
426
- *, ::before, ::after {
507
+ ::backdrop {
508
+ --tw-border-spacing-x: 0;
509
+ --tw-border-spacing-y: 0;
427
510
  --tw-translate-x: 0;
428
511
  --tw-translate-y: 0;
429
512
  --tw-rotate: 0;
@@ -1,5 +1,5 @@
1
1
  import { ValidationError } from '@contember/schema-utils';
2
2
  import { Schema } from '@contember/schema';
3
- export declare const printValidationErrors: (errors: ValidationError[], message?: string | undefined) => void;
4
- export declare const validateSchemaAndPrintErrors: (schema: Schema, message?: string | undefined) => boolean;
3
+ export declare const printValidationErrors: (errors: ValidationError[], message?: string) => void;
4
+ export declare const validateSchemaAndPrintErrors: (schema: Schema, message?: string) => boolean;
5
5
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,eAAO,MAAM,qBAAqB,WAAY,eAAe,EAAE,uCAS9D,CAAA;AAED,eAAO,MAAM,4BAA4B,WAAY,MAAM,mCAAqB,OAI/E,CAAA"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/utils/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAC1E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAE1C,eAAO,MAAM,qBAAqB,WAAY,eAAe,EAAE,YAAY,MAAM,SAShF,CAAA;AAED,eAAO,MAAM,4BAA4B,WAAY,MAAM,YAAY,MAAM,KAAG,OAI/E,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/cli",
3
- "version": "1.1.2",
3
+ "version": "1.2.0-alpha.11",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "contember": "./dist/src/run.js"
@@ -18,24 +18,23 @@
18
18
  "tailwindcss": "^3.0.24"
19
19
  },
20
20
  "dependencies": {
21
- "@contember/cli-common": "^1.1.2",
22
- "@contember/config-loader": "^1.1.2",
23
- "@contember/database-migrations": "^1.1.2",
24
- "@contember/dic": "^1.1.2",
25
- "@contember/engine-content-api": "^1.1.2",
26
- "@contember/schema": "^1.1.2",
27
- "@contember/schema-definition": "^1.1.2",
28
- "@contember/schema-migrations": "^1.1.2",
29
- "@contember/schema-utils": "^1.1.2",
30
- "@graphql-tools/merge": "^6.2.14",
31
- "chalk": "^4.1.0",
21
+ "@contember/cli-common": "^1.2.0-alpha.11",
22
+ "@contember/config-loader": "^1.2.0-alpha.11",
23
+ "@contember/database-migrations": "^1.2.0-alpha.11",
24
+ "@contember/dic": "^1.2.0-alpha.11",
25
+ "@contember/engine-content-api": "^1.2.0-alpha.11",
26
+ "@contember/schema": "^1.2.0-alpha.11",
27
+ "@contember/schema-definition": "^1.2.0-alpha.11",
28
+ "@contember/schema-migrations": "^1.2.0-alpha.11",
29
+ "@contember/schema-utils": "^1.2.0-alpha.11",
30
+ "chalk": "^4.1.2",
32
31
  "chalk-table": "^1.0.2",
33
- "esbuild": "^0.14.14",
32
+ "esbuild": "^0.14.54",
34
33
  "get-port": "^5.0.0",
35
- "graphql": "^15.4.0",
36
- "graphql-request": "^3.3.0",
34
+ "graphql": "^16.5.0",
35
+ "graphql-request": "^4.3.0",
37
36
  "js-yaml": "^4.1.0",
38
- "node-fetch": "^2.6.1",
37
+ "node-fetch": "^2.0",
39
38
  "pg": "^8.5.0",
40
39
  "preact": "^10.7.1",
41
40
  "preact-render-to-string": "^5.2.0",
@@ -13,7 +13,7 @@ import { MigrationsContainerFactory } from '../../MigrationsContainer'
13
13
  import { AdminClient, readAdminFiles } from '../../utils/admin'
14
14
  import { URL } from 'url'
15
15
  import prompts from 'prompts'
16
- import { createMigrationStatusTable, printMigrationDescription } from '../../utils/migrations'
16
+ import { createMigrationStatusTable } from '../../utils/migrations'
17
17
  import { maskToken } from '../../utils/token'
18
18
 
19
19
  type Args = {
@@ -26,32 +26,31 @@ type Options = ExecuteMigrationOptions & {
26
26
  }
27
27
 
28
28
  export class DeployCommand extends Command<Args, Options> {
29
+ constructor(
30
+ private readonly workspace: Workspace,
31
+ ) {
32
+ super()
33
+ }
34
+
29
35
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
30
36
  configuration.description('Deploy Contember project')
31
37
  configuration.argument('dsn')
32
- configuration.argument('project').optional()
38
+ if (!this.workspace.isSingleProjectMode()) {
39
+ configuration.argument('project').optional()
40
+ }
33
41
  configuration.option('admin').valueRequired()
34
42
  configureExecuteMigrationCommand(configuration)
35
43
  }
36
44
 
37
45
  protected async execute(input: Input<Args, Options>): Promise<void | number> {
38
46
  const [dsn, projectName] = this.getNormalizedInput(input)
39
- const workspace = await Workspace.get(process.cwd())
40
- let project: Project
47
+ const project = await this.workspace.projects.getProject(projectName, { fuzzy: true })
41
48
 
42
49
  let apiUrl = input.getOption('instance')
43
50
  let adminEndpoint = input.getOption('admin')
44
51
 
45
52
  let apiTokenFromDsn: string | undefined = undefined
46
- if (projectName) {
47
- project = await workspace.projects.getProject(projectName, { fuzzy: true })
48
- } else {
49
- const projects = await workspace.projects.listProjects()
50
- if (projects.length !== 1) {
51
- throw 'Please specify a local name project'
52
- }
53
- project = projects[0]
54
- }
53
+
55
54
  let remoteProject = input.getOption('remote-project') || project.name
56
55
  if (dsn) {
57
56
  const uri = new URL(dsn)
@@ -62,8 +61,8 @@ export class DeployCommand extends Command<Args, Options> {
62
61
  apiTokenFromDsn = uri.password
63
62
  adminEndpoint = (uri.protocol === 'contember-unsecure:' ? 'http://' : 'https://') + uri.host
64
63
  }
65
- const instance = await interactiveResolveInstanceEnvironmentFromInput(workspace, apiUrl ?? (adminEndpoint ? adminEndpoint + '/_api' : undefined))
66
- const apiToken = await interactiveResolveApiToken({ workspace, instance, apiToken: apiTokenFromDsn })
64
+ const instance = await interactiveResolveInstanceEnvironmentFromInput(this.workspace, apiUrl ?? (adminEndpoint ? adminEndpoint + '/_api' : undefined))
65
+ const apiToken = await interactiveResolveApiToken({ workspace: this.workspace, instance, apiToken: apiTokenFromDsn })
67
66
  console.log('')
68
67
  console.log('Contember project deployment configuration:')
69
68
  console.log(`Local project name: ${project.name}`)
@@ -1,4 +1,4 @@
1
- import { Command, CommandConfiguration, Input } from '@contember/cli-common'
1
+ import { Command, CommandConfiguration, Input, Workspace } from '@contember/cli-common'
2
2
  import { printValidationErrors } from '../../utils/schema'
3
3
  import { InvalidSchemaException } from '@contember/schema-migrations'
4
4
  import { executeCreateMigrationCommand } from './MigrationCreateHelper'
@@ -16,7 +16,7 @@ import { validateMigrations } from './MigrationValidationHelper'
16
16
  import { loadSchema } from '../../utils/project/loadSchema'
17
17
 
18
18
  type Args = {
19
- project: string
19
+ project?: string
20
20
  migration?: string
21
21
  }
22
22
 
@@ -26,9 +26,17 @@ type Options = {
26
26
  }
27
27
 
28
28
  export class MigrationAmendCommand extends Command<Args, Options> {
29
+ constructor(
30
+ private readonly workspace: Workspace,
31
+ ) {
32
+ super()
33
+ }
34
+
29
35
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
30
36
  configuration.description('Amends latest migration')
31
- configuration.argument('project')
37
+ if (!this.workspace.isSingleProjectMode()) {
38
+ configuration.argument('project')
39
+ }
32
40
  configuration.argument('migration').optional()
33
41
  configuration.option('force').description('Ignore migrations order and missing migrations (dev only)')
34
42
  configuration //
@@ -40,6 +48,7 @@ export class MigrationAmendCommand extends Command<Args, Options> {
40
48
  protected async execute(input: Input<Args, Options>): Promise<number> {
41
49
  return await executeCreateMigrationCommand(
42
50
  input,
51
+ { workspace: this.workspace },
43
52
  async ({
44
53
  schemaVersionBuilder,
45
54
  migrationsResolver,
@@ -11,19 +11,15 @@ import {
11
11
  import { Workspace, Project } from '@contember/cli-common'
12
12
 
13
13
  type Args = {
14
- project: string
14
+ project?: string
15
15
  migrationName: string
16
16
  }
17
17
 
18
18
  type Options = {}
19
19
 
20
- export const configureCreateMigrationCommand = (configuration: CommandConfiguration<Args, Options>) => {
21
- configuration.argument('project')
22
- configuration.argument('migrationName')
23
- }
24
-
25
20
  export const executeCreateMigrationCommand = async (
26
21
  input: Input<Pick<Args, 'project'>, Options>,
22
+ { workspace }: {workspace: Workspace},
27
23
  createMigrationCallback: (args: {
28
24
  workspace: Workspace
29
25
  project: Project
@@ -36,7 +32,6 @@ export const executeCreateMigrationCommand = async (
36
32
  }) => Promise<number>,
37
33
  ) => {
38
34
  const projectName = input.getArgument('project')
39
- const workspace = await Workspace.get(process.cwd())
40
35
  const allProjects = projectName === '.'
41
36
  const projects = allProjects
42
37
  ? await workspace.projects.listProjects()
@@ -7,7 +7,7 @@ import { Schema } from '@contember/schema'
7
7
  import { Workspace } from '@contember/cli-common'
8
8
 
9
9
  type Args = {
10
- project: string
10
+ project?: string
11
11
  migration?: string
12
12
  }
13
13
 
@@ -48,9 +48,17 @@ let printMigrationDescription = async function (
48
48
  }
49
49
 
50
50
  export class MigrationDescribeCommand extends Command<Args, Options> {
51
+ constructor(
52
+ private readonly workspace: Workspace,
53
+ ) {
54
+ super()
55
+ }
56
+
51
57
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
52
58
  configuration.description('Describes a migration')
53
- configuration.argument('project')
59
+ if (!this.workspace.isSingleProjectMode()) {
60
+ configuration.argument('project')
61
+ }
54
62
  configuration.argument('migration').optional()
55
63
  configuration.option('sql-only').valueNone()
56
64
  configuration.option('no-sql').valueNone()
@@ -59,7 +67,7 @@ export class MigrationDescribeCommand extends Command<Args, Options> {
59
67
  protected async execute(input: Input<Args, Options>): Promise<void> {
60
68
  const projectName = input.getArgument('project')
61
69
 
62
- const workspace = await Workspace.get(process.cwd())
70
+ const workspace = this.workspace
63
71
  const project = await workspace.projects.getProject(projectName, { fuzzy: true })
64
72
  const migrationsDir = await project.migrationsDir
65
73
  const container = new MigrationsContainerFactory(migrationsDir).create()
@@ -1,7 +1,7 @@
1
- import { Command, CommandConfiguration, Input } from '@contember/cli-common'
1
+ import { Command, CommandConfiguration, Input, Workspace } from '@contember/cli-common'
2
2
  import { printValidationErrors } from '../../utils/schema'
3
3
  import { InvalidSchemaException } from '@contember/schema-migrations'
4
- import { configureCreateMigrationCommand, executeCreateMigrationCommand } from './MigrationCreateHelper'
4
+ import { executeCreateMigrationCommand } from './MigrationCreateHelper'
5
5
  import { createMigrationStatusTable, printMigrationDescription } from '../../utils/migrations'
6
6
  import { executeMigrations, resolveMigrationStatus } from './MigrationExecuteHelper'
7
7
  import prompts from 'prompts'
@@ -11,7 +11,7 @@ import { SystemClient } from '../../utils/system'
11
11
  import { loadSchema } from '../../utils/project/loadSchema'
12
12
 
13
13
  type Args = {
14
- project: string
14
+ project?: string
15
15
  migrationName: string
16
16
  }
17
17
 
@@ -21,9 +21,18 @@ type Options = {
21
21
  }
22
22
 
23
23
  export class MigrationDiffCommand extends Command<Args, Options> {
24
+ constructor(
25
+ private readonly workspace: Workspace,
26
+ ) {
27
+ super()
28
+ }
29
+
24
30
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
25
31
  configuration.description('Creates schema migration diff for given project')
26
- configureCreateMigrationCommand(configuration)
32
+ if (!this.workspace.isSingleProjectMode()) {
33
+ configuration.argument('project')
34
+ }
35
+ configuration.argument('migrationName')
27
36
  configuration.option('execute').valueNone()
28
37
  configuration //
29
38
  .option('yes')
@@ -34,6 +43,7 @@ export class MigrationDiffCommand extends Command<Args, Options> {
34
43
  protected async execute(input: Input<Args, Options>): Promise<number> {
35
44
  return await executeCreateMigrationCommand(
36
45
  input,
46
+ { workspace: this.workspace },
37
47
  async ({
38
48
  schemaVersionBuilder,
39
49
  migrationsResolver,
@@ -13,7 +13,7 @@ import { interactiveResolveApiToken, TenantClient } from '../../utils/tenant'
13
13
  import { SystemClient } from '../../utils/system'
14
14
 
15
15
  type Args = {
16
- project: string
16
+ project?: string
17
17
  migration?: string
18
18
  }
19
19
 
@@ -22,9 +22,17 @@ type Options = ExecuteMigrationOptions & {
22
22
  }
23
23
 
24
24
  export class MigrationExecuteCommand extends Command<Args, Options> {
25
+ constructor(
26
+ private readonly workspace: Workspace,
27
+ ) {
28
+ super()
29
+ }
30
+
25
31
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
26
32
  configuration.description('Executes migrations on an instance')
27
- configuration.argument('project')
33
+ if (!this.workspace.isSingleProjectMode()) {
34
+ configuration.argument('project')
35
+ }
28
36
  configuration.argument('migration').optional()
29
37
  configuration.option('force').description('Ignore migrations order and missing migrations (dev only)')
30
38
  configureExecuteMigrationCommand(configuration)
@@ -33,12 +41,9 @@ export class MigrationExecuteCommand extends Command<Args, Options> {
33
41
  protected async execute(input: Input<Args, Options>): Promise<number> {
34
42
  const projectName = input.getArgument('project')
35
43
 
36
- const workspace = await Workspace.get(process.cwd())
44
+ const workspace = this.workspace
37
45
 
38
46
  const allProjects = projectName === '.'
39
- if (!allProjects) {
40
- validateProjectName(projectName)
41
- }
42
47
  const remoteProjectOption = input?.getOption('remote-project')
43
48
  if (remoteProjectOption && allProjects) {
44
49
  throw 'Option remote-project can be used only for a single project'
@@ -1,4 +1,4 @@
1
- import { Command, CommandConfiguration, Input } from '@contember/cli-common'
1
+ import { Command, CommandConfiguration, Input, Workspace } from '@contember/cli-common'
2
2
  import { MigrationVersionHelper } from '@contember/schema-migrations'
3
3
  import { executeCreateMigrationCommand } from './MigrationCreateHelper'
4
4
  import { getMigrationByName } from '../../utils/migrations'
@@ -7,7 +7,7 @@ import { emptySchema } from '@contember/schema-utils'
7
7
  import { validateMigrations } from './MigrationValidationHelper'
8
8
 
9
9
  type Args = {
10
- project: string
10
+ project?: string
11
11
  migration: string[]
12
12
  }
13
13
 
@@ -16,9 +16,18 @@ type Options = {
16
16
  }
17
17
 
18
18
  export class MigrationRebaseCommand extends Command<Args, Options> {
19
+ constructor(
20
+ private readonly workspace: Workspace,
21
+ ) {
22
+ super()
23
+ }
24
+
25
+
19
26
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
20
27
  configuration.description('Rebase migrations on filesystem and in local instance')
21
- configuration.argument('project')
28
+ if (!this.workspace.isSingleProjectMode()) {
29
+ configuration.argument('project')
30
+ }
22
31
  configuration.argument('migration').variadic()
23
32
  configuration //
24
33
  .option('yes')
@@ -29,6 +38,7 @@ export class MigrationRebaseCommand extends Command<Args, Options> {
29
38
  protected async execute(input: Input<Args, Options>): Promise<number> {
30
39
  return await executeCreateMigrationCommand(
31
40
  input,
41
+ { workspace: this.workspace },
32
42
  async ({
33
43
  schemaVersionBuilder,
34
44
  migrationsResolver,
@@ -8,7 +8,7 @@ import chalk from 'chalk'
8
8
  import { Workspace } from '@contember/cli-common'
9
9
 
10
10
  type Args = {
11
- project: string
11
+ project?: string
12
12
  }
13
13
 
14
14
  type Options = {
@@ -20,9 +20,17 @@ type Options = {
20
20
  }
21
21
 
22
22
  export class MigrationStatusCommand extends Command<Args, Options> {
23
+ constructor(
24
+ private readonly workspace: Workspace,
25
+ ) {
26
+ super()
27
+ }
28
+
23
29
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
24
30
  configuration.description('Shows status of executed migrations on an instance & sync status')
25
- configuration.argument('project')
31
+ if (!this.workspace.isSingleProjectMode()) {
32
+ configuration.argument('project')
33
+ }
26
34
  configuration //
27
35
  .option('instance')
28
36
  .valueRequired()
@@ -48,7 +56,7 @@ export class MigrationStatusCommand extends Command<Args, Options> {
48
56
  protected async execute(input: Input<Args, Options>): Promise<number> {
49
57
  const projectName = input.getArgument('project')
50
58
 
51
- const workspace = await Workspace.get(process.cwd())
59
+ const workspace = this.workspace
52
60
  const project = await workspace.projects.getProject(projectName, { fuzzy: true })
53
61
  const migrationsDir = await project.migrationsDir
54
62
  const container = new MigrationsContainerFactory(migrationsDir).create()
@@ -10,6 +10,12 @@ type Options = {
10
10
  }
11
11
 
12
12
  export class ProjectCreateCommand extends Command<Args, Options> {
13
+ constructor(
14
+ private readonly workspace: Workspace,
15
+ ) {
16
+ super()
17
+ }
18
+
13
19
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
14
20
  configuration.description('Creates a new Contember project')
15
21
  configuration.argument('project')
@@ -19,7 +25,7 @@ export class ProjectCreateCommand extends Command<Args, Options> {
19
25
  protected async execute(input: Input<Args, Options>): Promise<void> {
20
26
  const [projectName] = [input.getArgument('project')]
21
27
  validateProjectName(projectName)
22
- const workspace = await Workspace.get(process.cwd())
28
+ const workspace = this.workspace
23
29
 
24
30
  const template = input.getOption('template')
25
31
  await workspace.projects.createProject(projectName, { template })
@@ -1,4 +1,4 @@
1
- import { Command, CommandConfiguration, Input, validateProjectName, Workspace } from '@contember/cli-common'
1
+ import { Command, CommandConfiguration, Input, Workspace } from '@contember/cli-common'
2
2
  import { validateSchemaAndPrintErrors } from '../../utils/schema'
3
3
  import { loadSchema } from '../../utils/project/loadSchema'
4
4
  import { renderProjectInfoHtml } from '../../utils/project/projectDescribe'
@@ -6,7 +6,7 @@ import { writeFile } from 'fs/promises'
6
6
  import { join } from 'path'
7
7
 
8
8
  type Args = {
9
- project: string
9
+ project?: string
10
10
  }
11
11
 
12
12
  type Options = {
@@ -14,18 +14,23 @@ type Options = {
14
14
  }
15
15
 
16
16
  export class ProjectGenerateDocumentation extends Command<Args, Options> {
17
+ constructor(
18
+ private readonly workspace: Workspace,
19
+ ) {
20
+ super()
21
+ }
22
+
17
23
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
18
24
  configuration.description('Generates HTML documentation from project schema')
19
- configuration.argument('project')
25
+ if (!this.workspace.isSingleProjectMode()) {
26
+ configuration.argument('project')
27
+ }
20
28
  configuration.option('output').valueRequired().description('file name or "stdout"')
21
29
  }
22
30
 
23
31
  protected async execute(input: Input<Args, Options>): Promise<number> {
24
32
  const projectName = input.getArgument('project')
25
- const workspace = await Workspace.get(process.cwd())
26
-
27
- validateProjectName(projectName)
28
- const project = await workspace.projects.getProject(projectName, { fuzzy: true })
33
+ const project = await this.workspace.projects.getProject(projectName, { fuzzy: true })
29
34
  const schema = await loadSchema(project)
30
35
  if (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {
31
36
  return 1
@@ -10,11 +10,11 @@ import {
10
10
  Authorizator,
11
11
  } from '@contember/engine-content-api'
12
12
  import { DocumentNode, printSchema } from 'graphql'
13
- import { mergeSchemas } from '@graphql-tools/merge'
13
+ import { mergeSchemas } from '@graphql-tools/schema'
14
14
  import { loadSchema } from '../../utils/project/loadSchema'
15
15
 
16
16
  type Args = {
17
- project: string
17
+ project?: string
18
18
  }
19
19
 
20
20
  type Options = {
@@ -23,19 +23,26 @@ type Options = {
23
23
  }
24
24
 
25
25
  export class ProjectPrintSchemaCommand extends Command<Args, Options> {
26
+ constructor(
27
+ private readonly workspace: Workspace,
28
+ ) {
29
+ super()
30
+ }
31
+
26
32
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
27
33
  configuration.description('Prints project schema')
28
- configuration.argument('project')
34
+ if (!this.workspace.isSingleProjectMode()) {
35
+ configuration.argument('project')
36
+ }
29
37
  configuration.option('format').valueRequired().description('graphql|introspection|schema')
30
38
  configuration.option('role').valueArray()
31
39
  }
32
40
 
33
41
  protected async execute(input: Input<Args, Options>): Promise<number> {
34
42
  const projectName = input.getArgument('project')
35
- const workspace = await Workspace.get(process.cwd())
43
+ const workspace = this.workspace
36
44
  const format = input.getOption('format') || 'graphql'
37
45
 
38
- validateProjectName(projectName)
39
46
  const project = await workspace.projects.getProject(projectName, { fuzzy: true })
40
47
  const schema = await loadSchema(project)
41
48
  if (!validateSchemaAndPrintErrors(schema, 'Defined schema is invalid:')) {