@contember/cli 1.0.0-rc.7 → 1.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.
Files changed (63) hide show
  1. package/Dockerfile +1 -0
  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 +83 -10
  5. package/dist/src/commands/deploy/DeployCommand.js.map +1 -1
  6. package/dist/src/commands/migrations/MigrationDiffCommand.d.ts.map +1 -1
  7. package/dist/src/commands/migrations/MigrationDiffCommand.js +10 -4
  8. package/dist/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
  9. package/dist/src/commands/migrations/MigrationExecuteCommand.js +1 -1
  10. package/dist/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
  11. package/dist/src/commands/migrations/MigrationExecuteHelper.d.ts.map +1 -1
  12. package/dist/src/commands/migrations/MigrationExecuteHelper.js +3 -0
  13. package/dist/src/commands/migrations/MigrationExecuteHelper.js.map +1 -1
  14. package/dist/src/commands/migrations/MigrationStatusCommand.js +1 -1
  15. package/dist/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  16. package/dist/src/commands/migrations/SystemApiClientResolver.js +1 -1
  17. package/dist/src/commands/migrations/SystemApiClientResolver.js.map +1 -1
  18. package/dist/src/commands/project/ProjectPrintSchemaCommand.js +1 -1
  19. package/dist/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  20. package/dist/src/commands/tenant/CreateApiKeyCommand.js +1 -1
  21. package/dist/src/commands/tenant/CreateApiKeyCommand.js.map +1 -1
  22. package/dist/src/commands/tenant/InviteCommand.js +1 -1
  23. package/dist/src/commands/tenant/InviteCommand.js.map +1 -1
  24. package/dist/src/commands/tenant/ResetPasswordCommand.js +1 -1
  25. package/dist/src/commands/tenant/ResetPasswordCommand.js.map +1 -1
  26. package/dist/src/commands/tenant/SignInCommand.js +1 -1
  27. package/dist/src/commands/tenant/SignInCommand.js.map +1 -1
  28. package/dist/src/tsconfig.tsbuildinfo +1 -1
  29. package/dist/src/utils/admin.d.ts.map +1 -1
  30. package/dist/src/utils/admin.js +3 -1
  31. package/dist/src/utils/admin.js.map +1 -1
  32. package/dist/src/utils/instance/environment.d.ts +0 -1
  33. package/dist/src/utils/instance/environment.d.ts.map +1 -1
  34. package/dist/src/utils/instance/environment.js +0 -5
  35. package/dist/src/utils/instance/environment.js.map +1 -1
  36. package/dist/src/utils/instance/interactiveUtils.d.ts.map +1 -1
  37. package/dist/src/utils/instance/interactiveUtils.js +1 -2
  38. package/dist/src/utils/instance/interactiveUtils.js.map +1 -1
  39. package/dist/src/utils/tenant.d.ts +5 -2
  40. package/dist/src/utils/tenant.d.ts.map +1 -1
  41. package/dist/src/utils/tenant.js +10 -7
  42. package/dist/src/utils/tenant.js.map +1 -1
  43. package/dist/src/utils/token.d.ts +2 -0
  44. package/dist/src/utils/token.d.ts.map +1 -0
  45. package/dist/src/utils/token.js +6 -0
  46. package/dist/src/utils/token.js.map +1 -0
  47. package/package.json +10 -10
  48. package/src/commands/deploy/DeployCommand.ts +88 -14
  49. package/src/commands/migrations/MigrationDiffCommand.ts +11 -4
  50. package/src/commands/migrations/MigrationExecuteCommand.ts +1 -1
  51. package/src/commands/migrations/MigrationExecuteHelper.ts +3 -0
  52. package/src/commands/migrations/MigrationStatusCommand.ts +1 -1
  53. package/src/commands/migrations/SystemApiClientResolver.ts +1 -1
  54. package/src/commands/project/ProjectPrintSchemaCommand.ts +2 -2
  55. package/src/commands/tenant/CreateApiKeyCommand.ts +1 -1
  56. package/src/commands/tenant/InviteCommand.ts +1 -1
  57. package/src/commands/tenant/ResetPasswordCommand.ts +1 -1
  58. package/src/commands/tenant/SignInCommand.ts +1 -1
  59. package/src/utils/admin.ts +3 -1
  60. package/src/utils/instance/environment.ts +0 -3
  61. package/src/utils/instance/interactiveUtils.ts +2 -2
  62. package/src/utils/tenant.ts +14 -6
  63. package/src/utils/token.ts +1 -0
@@ -1,6 +1,7 @@
1
1
  import prompts from 'prompts'
2
2
  import { GraphQLClient } from 'graphql-request'
3
3
  import { InstanceApiEnvironment } from './instance'
4
+ import { Workspace } from '@contember/cli-common'
4
5
 
5
6
  const validatePassword = (password: string) =>
6
7
  password.length < 6 ? 'Password must contain at least 6 characters' : true
@@ -15,9 +16,9 @@ export const createTenantApiUrl = (url: string) => {
15
16
  return url + '/tenant'
16
17
  }
17
18
 
18
- export const interactiveResolveLoginToken = async (instance: InstanceApiEnvironment) => {
19
- if (process.env.CONTEMBER_LOGIN_TOKEN) {
20
- return process.env.CONTEMBER_LOGIN_TOKEN
19
+ export const interactiveResolveLoginToken = async (workspace: Workspace) => {
20
+ if (workspace.env.loginToken) {
21
+ return workspace.env.loginToken
21
22
  }
22
23
  const { loginToken } = await prompts({
23
24
  type: 'text',
@@ -83,12 +84,19 @@ export const interactiveAskForCredentials = async (): Promise<{ email: string; p
83
84
  }
84
85
 
85
86
  export const interactiveResolveApiToken = async ({
87
+ workspace,
86
88
  instance,
89
+ apiToken,
87
90
  }: {
91
+ workspace: Workspace
88
92
  instance: InstanceApiEnvironment
93
+ apiToken?: string
89
94
  }): Promise<string> => {
90
- if (process.env.CONTEMBER_API_TOKEN) {
91
- return process.env.CONTEMBER_API_TOKEN
95
+ if (apiToken) {
96
+ return apiToken
97
+ }
98
+ if (workspace.env.apiToken) {
99
+ return workspace.env.apiToken
92
100
  }
93
101
  const { strategy } = await prompts({
94
102
  type: 'select',
@@ -100,7 +108,7 @@ export const interactiveResolveApiToken = async ({
100
108
  ],
101
109
  })
102
110
  if (strategy === 'signin') {
103
- const loginToken = await interactiveResolveLoginToken(instance)
111
+ const loginToken = await interactiveResolveLoginToken(workspace)
104
112
  return (await interactiveSignIn({ apiUrl: createTenantApiUrl(instance.baseUrl), loginToken, expiration: 60 * 5 }))
105
113
  .sessionToken
106
114
  }
@@ -0,0 +1 @@
1
+ export const maskToken = (token: string) => token.replace(/^(\w{3}).+(\w{3})$/, '$1***$2')