@contember/cli 1.1.1 → 1.2.0-alpha.10

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 +15 -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 +20 -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
@@ -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:')) {
@@ -6,25 +6,30 @@ import { validateMigrations } from '../migrations/MigrationValidationHelper'
6
6
  import { loadSchema } from '../../utils/project/loadSchema'
7
7
 
8
8
  type Args = {
9
- project: string
9
+ project?: string
10
10
  }
11
11
 
12
12
  type Options = {}
13
13
 
14
14
  export class ProjectValidateCommand extends Command<Args, Options> {
15
+ constructor(
16
+ private readonly workspace: Workspace,
17
+ ) {
18
+ super()
19
+ }
20
+
15
21
  protected configure(configuration: CommandConfiguration<Args, Options>): void {
16
22
  configuration.description('Validates project schema')
17
- configuration.argument('project')
23
+ if (!this.workspace.isSingleProjectMode()) {
24
+ configuration.argument('project')
25
+ }
18
26
  }
19
27
 
20
28
  protected async execute(input: Input<Args, Options>): Promise<number> {
21
29
  const [projectName] = [input.getArgument('project')]
22
- const workspace = await Workspace.get(process.cwd())
30
+ const workspace = this.workspace
23
31
 
24
32
  const allProjects = projectName === '.'
25
- if (!allProjects) {
26
- validateProjectName(projectName)
27
- }
28
33
  const projects = allProjects
29
34
  ? await workspace.projects.listProjects()
30
35
  : [await workspace.projects.getProject(projectName, { fuzzy: true })]
@@ -10,6 +10,12 @@ type Args = {
10
10
  type Options = {}
11
11
 
12
12
  export class CreateApiKeyCommand 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 an API key')
15
21
  configuration //
@@ -22,7 +28,7 @@ export class CreateApiKeyCommand extends Command<Args, Options> {
22
28
  if (!process.stdin.isTTY) {
23
29
  throw 'This command is interactive and requires TTY'
24
30
  }
25
- const workspace = await Workspace.get(process.cwd())
31
+ const workspace = this.workspace
26
32
  const instance = await interactiveResolveInstanceEnvironmentFromInput(workspace, input.getArgument('instance'))
27
33
  const apiToken = await interactiveResolveApiToken({ workspace, instance })
28
34
  const tenantClient = TenantClient.create(instance.baseUrl, apiToken)
@@ -10,6 +10,12 @@ type Args = {
10
10
  type Options = {}
11
11
 
12
12
  export class InviteCommand 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('Invites a user by an email')
15
21
  configuration //
@@ -22,7 +28,7 @@ export class InviteCommand extends Command<Args, Options> {
22
28
  if (!process.stdin.isTTY) {
23
29
  throw 'This command is interactive and requires TTY'
24
30
  }
25
- const workspace = await Workspace.get(process.cwd())
31
+ const workspace = this.workspace
26
32
  const instance = await interactiveResolveInstanceEnvironmentFromInput(workspace, input.getArgument('instance'))
27
33
  const apiToken = await interactiveResolveApiToken({ workspace, instance })
28
34
  const tenantClient = TenantClient.create(instance.baseUrl, apiToken)
@@ -10,6 +10,12 @@ type Args = {
10
10
  type Options = {}
11
11
 
12
12
  export class ResetPasswordCommand 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('Resets user password')
15
21
  configuration //
@@ -22,7 +28,7 @@ export class ResetPasswordCommand extends Command<Args, Options> {
22
28
  if (!process.stdin.isTTY) {
23
29
  throw 'This command is interactive and requires TTY'
24
30
  }
25
- const workspace = await Workspace.get(process.cwd())
31
+ const workspace = this.workspace
26
32
  const instance = await interactiveResolveInstanceEnvironmentFromInput(workspace, input.getArgument('instance'))
27
33
  const loginToken = await interactiveResolveLoginToken(workspace)
28
34
  await interactiveResetPassword({ apiUrl: instance.baseUrl, loginToken })
@@ -10,6 +10,12 @@ type Args = {
10
10
  type Options = {}
11
11
 
12
12
  export class SignInCommand 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('Signs in a user')
15
21
  configuration //
@@ -22,7 +28,7 @@ export class SignInCommand extends Command<Args, Options> {
22
28
  if (!process.stdin.isTTY) {
23
29
  throw 'This command is interactive and requires TTY'
24
30
  }
25
- const workspace = await Workspace.get(process.cwd())
31
+ const workspace = this.workspace
26
32
  const instance = await interactiveResolveInstanceEnvironmentFromInput(workspace, input.getArgument('instance'))
27
33
  const loginToken = await interactiveResolveLoginToken(workspace)
28
34
  const { sessionToken } = await interactiveSignIn({ apiUrl: instance.baseUrl, loginToken })
@@ -10,6 +10,12 @@ type Args = {
10
10
  type Options = {}
11
11
 
12
12
  export class WorkspaceUpdateApiCommand 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('Updates Contember API version and all related packages')
15
21
  configuration.argument('version')
@@ -17,7 +23,7 @@ export class WorkspaceUpdateApiCommand extends Command<Args, Options> {
17
23
 
18
24
  protected async execute(input: Input<Args, Options>): Promise<void> {
19
25
  const version = input.getArgument('version')
20
- const workspace = await Workspace.get(process.cwd())
26
+ const workspace = this.workspace
21
27
  const upgradablePackages = ['@contember/schema', '@contember/schema-definition', '@contember/cli']
22
28
 
23
29
  await updateNpmPackages(upgradablePackages.map(it => ({ name: it, version })), workspace.directory)
package/src/run.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Application, CommandManager, getPackageVersion } from '@contember/cli-common'
2
+ import { Application, CommandFactoryList, CommandManager, getPackageVersion, Workspace } from '@contember/cli-common'
3
3
  import {
4
4
  CreateApiKeyCommand,
5
5
  DeployCommand,
@@ -18,34 +18,32 @@ import {
18
18
  SignInCommand,
19
19
  VersionCommand,
20
20
  WorkspaceUpdateApiCommand,
21
- } from './commands';
21
+ } from './commands'
22
22
 
23
23
  (async () => {
24
- const diffCommandFactory = () => new MigrationDiffCommand()
25
- const migrationsDescribeFactory = () => new MigrationDescribeCommand()
26
- const commandManager = new CommandManager({
27
- ['deploy']: () => new DeployCommand(),
24
+ const workspace = await Workspace.get(process.cwd())
25
+ const commands: CommandFactoryList = {
26
+ ['deploy']: () => new DeployCommand(workspace),
28
27
  ['version']: () => new VersionCommand(),
29
- ['migrations:diff']: diffCommandFactory,
30
- ['migrations:amend']: () => new MigrationAmendCommand(),
31
- ['migrations:describe']: migrationsDescribeFactory,
32
- ['migrations:execute']: () => new MigrationExecuteCommand(),
33
- ['migrations:rebase']: () => new MigrationRebaseCommand(),
34
- ['migrations:status']: () => new MigrationStatusCommand(),
35
- ['workspace:update:api']: () => new WorkspaceUpdateApiCommand(),
36
- ['project:create']: () => new ProjectCreateCommand(),
37
- ['project:validate']: () => new ProjectValidateCommand(),
38
- ['project:print-schema']: () => new ProjectPrintSchemaCommand(),
39
- ['project:generate-doc']: () => new ProjectGenerateDocumentation(),
40
- ['tenant:sign-in']: () => new SignInCommand(),
41
- ['tenant:create-api-key']: () => new CreateApiKeyCommand(),
42
- ['tenant:invite']: () => new InviteCommand(),
43
- ['tenant:reset-password']: () => new ResetPasswordCommand(),
44
-
45
- // deprecated
46
- ['migrations:dry-run']: migrationsDescribeFactory,
47
- ['diff']: diffCommandFactory,
48
- })
28
+ ['migrations:diff']: () => new MigrationDiffCommand(workspace),
29
+ ['migrations:amend']: () => new MigrationAmendCommand(workspace),
30
+ ['migrations:describe']: () => new MigrationDescribeCommand(workspace),
31
+ ['migrations:execute']: () => new MigrationExecuteCommand(workspace),
32
+ ['migrations:rebase']: () => new MigrationRebaseCommand(workspace),
33
+ ['migrations:status']: () => new MigrationStatusCommand(workspace),
34
+ ['workspace:update:api']: () => new WorkspaceUpdateApiCommand(workspace),
35
+ ['project:validate']: () => new ProjectValidateCommand(workspace),
36
+ ['project:print-schema']: () => new ProjectPrintSchemaCommand(workspace),
37
+ ['project:generate-doc']: () => new ProjectGenerateDocumentation(workspace),
38
+ ['tenant:sign-in']: () => new SignInCommand(workspace),
39
+ ['tenant:create-api-key']: () => new CreateApiKeyCommand(workspace),
40
+ ['tenant:invite']: () => new InviteCommand(workspace),
41
+ ['tenant:reset-password']: () => new ResetPasswordCommand(workspace),
42
+ }
43
+ if (!workspace.isSingleProjectMode()) {
44
+ commands['project:create'] = () => new ProjectCreateCommand(workspace)
45
+ }
46
+ const commandManager = new CommandManager(commands)
49
47
 
50
48
  const nodeVersion = process.version.match(/^v?(\d+)\..+$/)
51
49
  if (nodeVersion && Number(nodeVersion[1]) < 12) {