@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.
- package/Dockerfile +1 -0
- package/dist/src/commands/deploy/DeployCommand.d.ts +3 -1
- package/dist/src/commands/deploy/DeployCommand.d.ts.map +1 -1
- package/dist/src/commands/deploy/DeployCommand.js +83 -10
- package/dist/src/commands/deploy/DeployCommand.js.map +1 -1
- package/dist/src/commands/migrations/MigrationDiffCommand.d.ts.map +1 -1
- package/dist/src/commands/migrations/MigrationDiffCommand.js +10 -4
- package/dist/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
- package/dist/src/commands/migrations/MigrationExecuteCommand.js +1 -1
- package/dist/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
- package/dist/src/commands/migrations/MigrationExecuteHelper.d.ts.map +1 -1
- package/dist/src/commands/migrations/MigrationExecuteHelper.js +3 -0
- package/dist/src/commands/migrations/MigrationExecuteHelper.js.map +1 -1
- package/dist/src/commands/migrations/MigrationStatusCommand.js +1 -1
- package/dist/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
- package/dist/src/commands/migrations/SystemApiClientResolver.js +1 -1
- package/dist/src/commands/migrations/SystemApiClientResolver.js.map +1 -1
- package/dist/src/commands/project/ProjectPrintSchemaCommand.js +1 -1
- package/dist/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
- package/dist/src/commands/tenant/CreateApiKeyCommand.js +1 -1
- package/dist/src/commands/tenant/CreateApiKeyCommand.js.map +1 -1
- package/dist/src/commands/tenant/InviteCommand.js +1 -1
- package/dist/src/commands/tenant/InviteCommand.js.map +1 -1
- package/dist/src/commands/tenant/ResetPasswordCommand.js +1 -1
- package/dist/src/commands/tenant/ResetPasswordCommand.js.map +1 -1
- package/dist/src/commands/tenant/SignInCommand.js +1 -1
- package/dist/src/commands/tenant/SignInCommand.js.map +1 -1
- package/dist/src/tsconfig.tsbuildinfo +1 -1
- package/dist/src/utils/admin.d.ts.map +1 -1
- package/dist/src/utils/admin.js +3 -1
- package/dist/src/utils/admin.js.map +1 -1
- package/dist/src/utils/instance/environment.d.ts +0 -1
- package/dist/src/utils/instance/environment.d.ts.map +1 -1
- package/dist/src/utils/instance/environment.js +0 -5
- package/dist/src/utils/instance/environment.js.map +1 -1
- package/dist/src/utils/instance/interactiveUtils.d.ts.map +1 -1
- package/dist/src/utils/instance/interactiveUtils.js +1 -2
- package/dist/src/utils/instance/interactiveUtils.js.map +1 -1
- package/dist/src/utils/tenant.d.ts +5 -2
- package/dist/src/utils/tenant.d.ts.map +1 -1
- package/dist/src/utils/tenant.js +10 -7
- package/dist/src/utils/tenant.js.map +1 -1
- package/dist/src/utils/token.d.ts +2 -0
- package/dist/src/utils/token.d.ts.map +1 -0
- package/dist/src/utils/token.js +6 -0
- package/dist/src/utils/token.js.map +1 -0
- package/package.json +10 -10
- package/src/commands/deploy/DeployCommand.ts +88 -14
- package/src/commands/migrations/MigrationDiffCommand.ts +11 -4
- package/src/commands/migrations/MigrationExecuteCommand.ts +1 -1
- package/src/commands/migrations/MigrationExecuteHelper.ts +3 -0
- package/src/commands/migrations/MigrationStatusCommand.ts +1 -1
- package/src/commands/migrations/SystemApiClientResolver.ts +1 -1
- package/src/commands/project/ProjectPrintSchemaCommand.ts +2 -2
- package/src/commands/tenant/CreateApiKeyCommand.ts +1 -1
- package/src/commands/tenant/InviteCommand.ts +1 -1
- package/src/commands/tenant/ResetPasswordCommand.ts +1 -1
- package/src/commands/tenant/SignInCommand.ts +1 -1
- package/src/utils/admin.ts +3 -1
- package/src/utils/instance/environment.ts +0 -3
- package/src/utils/instance/interactiveUtils.ts +2 -2
- package/src/utils/tenant.ts +14 -6
- package/src/utils/token.ts +1 -0
package/src/utils/tenant.ts
CHANGED
|
@@ -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 (
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
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 (
|
|
91
|
-
return
|
|
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(
|
|
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')
|