@contember/cli 0.12.0-beta.1 → 1.0.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 (86) hide show
  1. package/Dockerfile +3 -1
  2. package/build.sh +1 -4
  3. package/dist/src/commands/deploy/DeployCommand.js +7 -7
  4. package/dist/src/commands/deploy/DeployCommand.js.map +1 -1
  5. package/dist/src/commands/migrations/MigrationAmendCommand.js +10 -10
  6. package/dist/src/commands/migrations/MigrationAmendCommand.js.map +1 -1
  7. package/dist/src/commands/migrations/MigrationDescribeCommand.js +2 -2
  8. package/dist/src/commands/migrations/MigrationDescribeCommand.js.map +1 -1
  9. package/dist/src/commands/migrations/MigrationDiffCommand.js +10 -10
  10. package/dist/src/commands/migrations/MigrationDiffCommand.js.map +1 -1
  11. package/dist/src/commands/migrations/MigrationExecuteCommand.js +9 -9
  12. package/dist/src/commands/migrations/MigrationExecuteCommand.js.map +1 -1
  13. package/dist/src/commands/migrations/MigrationExecuteHelper.d.ts.map +1 -1
  14. package/dist/src/commands/migrations/MigrationExecuteHelper.js +6 -10
  15. package/dist/src/commands/migrations/MigrationExecuteHelper.js.map +1 -1
  16. package/dist/src/commands/migrations/MigrationRebaseCommand.js +4 -4
  17. package/dist/src/commands/migrations/MigrationRebaseCommand.js.map +1 -1
  18. package/dist/src/commands/migrations/MigrationStatusCommand.js +6 -6
  19. package/dist/src/commands/migrations/MigrationStatusCommand.js.map +1 -1
  20. package/dist/src/commands/migrations/MigrationValidationHelper.js +1 -1
  21. package/dist/src/commands/migrations/MigrationValidationHelper.js.map +1 -1
  22. package/dist/src/commands/migrations/SystemApiClientResolver.js +2 -2
  23. package/dist/src/commands/migrations/SystemApiClientResolver.js.map +1 -1
  24. package/dist/src/commands/migrations/index.d.ts +0 -1
  25. package/dist/src/commands/migrations/index.d.ts.map +1 -1
  26. package/dist/src/commands/migrations/index.js +0 -1
  27. package/dist/src/commands/migrations/index.js.map +1 -1
  28. package/dist/src/commands/misc/VersionCommand.js +1 -1
  29. package/dist/src/commands/misc/VersionCommand.js.map +1 -1
  30. package/dist/src/commands/project/ProjectCreateCommand.js +1 -1
  31. package/dist/src/commands/project/ProjectCreateCommand.js.map +1 -1
  32. package/dist/src/commands/project/ProjectPrintSchemaCommand.js +4 -4
  33. package/dist/src/commands/project/ProjectPrintSchemaCommand.js.map +1 -1
  34. package/dist/src/commands/project/ProjectValidateCommand.js +4 -4
  35. package/dist/src/commands/project/ProjectValidateCommand.js.map +1 -1
  36. package/dist/src/commands/tenant/CreateApiKeyCommand.js +3 -3
  37. package/dist/src/commands/tenant/CreateApiKeyCommand.js.map +1 -1
  38. package/dist/src/commands/tenant/InviteCommand.js +3 -3
  39. package/dist/src/commands/tenant/InviteCommand.js.map +1 -1
  40. package/dist/src/commands/tenant/ResetPasswordCommand.js +3 -3
  41. package/dist/src/commands/tenant/ResetPasswordCommand.js.map +1 -1
  42. package/dist/src/commands/tenant/SignInCommand.js +3 -3
  43. package/dist/src/commands/tenant/SignInCommand.js.map +1 -1
  44. package/dist/src/commands/workspace/WorkspaceUpdateApiCommand.js +3 -3
  45. package/dist/src/commands/workspace/WorkspaceUpdateApiCommand.js.map +1 -1
  46. package/dist/src/run.js +2 -3
  47. package/dist/src/run.js.map +1 -1
  48. package/dist/src/tsconfig.tsbuildinfo +1 -1
  49. package/dist/src/utils/admin.d.ts.map +1 -1
  50. package/dist/src/utils/admin.js +5 -5
  51. package/dist/src/utils/admin.js.map +1 -1
  52. package/dist/src/utils/commands.js +1 -1
  53. package/dist/src/utils/commands.js.map +1 -1
  54. package/dist/src/utils/dockerCompose.js +4 -4
  55. package/dist/src/utils/dockerCompose.js.map +1 -1
  56. package/dist/src/utils/instance/interactiveUtils.js +2 -2
  57. package/dist/src/utils/instance/interactiveUtils.js.map +1 -1
  58. package/dist/src/utils/migrations.js +6 -6
  59. package/dist/src/utils/migrations.js.map +1 -1
  60. package/dist/src/utils/npm.js +6 -6
  61. package/dist/src/utils/npm.js.map +1 -1
  62. package/dist/src/utils/schema.js +1 -1
  63. package/dist/src/utils/schema.js.map +1 -1
  64. package/dist/src/utils/system/index.d.ts +1 -1
  65. package/dist/src/utils/system/index.d.ts.map +1 -1
  66. package/dist/src/utils/system/index.js +5 -2
  67. package/dist/src/utils/system/index.js.map +1 -1
  68. package/dist/src/utils/tenant.js +21 -21
  69. package/dist/src/utils/tenant.js.map +1 -1
  70. package/dist/src/utils/workspace.js +3 -3
  71. package/dist/src/utils/workspace.js.map +1 -1
  72. package/dist/src/utils/yaml.js +3 -3
  73. package/dist/src/utils/yaml.js.map +1 -1
  74. package/esbuild.js +15 -0
  75. package/package.json +10 -10
  76. package/src/commands/migrations/MigrationDiffCommand.ts +1 -1
  77. package/src/commands/migrations/MigrationExecuteHelper.ts +3 -7
  78. package/src/commands/migrations/index.ts +0 -1
  79. package/src/run.ts +0 -2
  80. package/src/utils/admin.ts +2 -1
  81. package/src/utils/system/index.ts +5 -2
  82. package/dist/src/commands/migrations/MigrationCreateCommand.d.ts +0 -15
  83. package/dist/src/commands/migrations/MigrationCreateCommand.d.ts.map +0 -1
  84. package/dist/src/commands/migrations/MigrationCreateCommand.js +0 -21
  85. package/dist/src/commands/migrations/MigrationCreateCommand.js.map +0 -1
  86. package/src/commands/migrations/MigrationCreateCommand.ts +0 -28
package/esbuild.js ADDED
@@ -0,0 +1,15 @@
1
+ const esbuild = require('esbuild')
2
+ const { resolvePlugin } = require('../../scripts/esbuild/esbuild')
3
+
4
+ esbuild.build({
5
+ entryPoints: ['./packages/cli/src/run.ts'],
6
+ bundle: true,
7
+ platform: 'node',
8
+ sourcemap: 'external',
9
+ outfile: './dist/run.js',
10
+ plugins: [resolvePlugin],
11
+ external: ['pg-native', 'electron', 'typescript', 'ts-node'],
12
+ }).catch(e => {
13
+ console.error(e)
14
+ process.exit(1)
15
+ })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/cli",
3
- "version": "0.12.0-beta.1",
3
+ "version": "1.0.0-alpha.10",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "contember": "./dist/src/run.js"
@@ -14,15 +14,15 @@
14
14
  "@types/fs-extra": "^9.0.3"
15
15
  },
16
16
  "dependencies": {
17
- "@contember/cli-common": "^0.12.0-beta.1",
18
- "@contember/config-loader": "^0.12.0-beta.1",
19
- "@contember/database-migrations": "^0.12.0-beta.1",
20
- "@contember/dic": "^0.12.0-beta.1",
21
- "@contember/engine-content-api": "^0.12.0-beta.1",
22
- "@contember/schema": "^0.12.0-beta.1",
23
- "@contember/schema-definition": "^0.12.0-beta.1",
24
- "@contember/schema-migrations": "^0.12.0-beta.1",
25
- "@contember/schema-utils": "^0.12.0-beta.1",
17
+ "@contember/cli-common": "^1.0.0-alpha.10",
18
+ "@contember/config-loader": "^1.0.0-alpha.10",
19
+ "@contember/database-migrations": "^1.0.0-alpha.10",
20
+ "@contember/dic": "^1.0.0-alpha.10",
21
+ "@contember/engine-content-api": "^1.0.0-alpha.10",
22
+ "@contember/schema": "^1.0.0-alpha.10",
23
+ "@contember/schema-definition": "^1.0.0-alpha.10",
24
+ "@contember/schema-migrations": "^1.0.0-alpha.10",
25
+ "@contember/schema-utils": "^1.0.0-alpha.10",
26
26
  "@graphql-tools/merge": "^6.2.14",
27
27
  "chalk": "^4.1.0",
28
28
  "chalk-table": "^1.0.2",
@@ -86,7 +86,7 @@ export class MigrationDiffCommand extends Command<Args, Options> {
86
86
  await executeMigrations({
87
87
  client,
88
88
  migrations: status.migrationsToExecute,
89
- requireConfirmation: !yes,
89
+ requireConfirmation: status.migrationsToExecute.length > 1 && !yes,
90
90
  schemaVersionBuilder,
91
91
  migrationDescriber,
92
92
  })
@@ -82,14 +82,10 @@ export const executeMigrations = async ({
82
82
  } while (true)
83
83
  }
84
84
 
85
- const result = await client.migrate(
85
+ await client.migrate(
86
86
  migrations.map(it => it.localMigration),
87
87
  force,
88
88
  )
89
- if (result.ok) {
90
- console.log('Migration executed')
91
- return 0
92
- }
93
- console.error(result.errors)
94
- return 1
89
+ console.log('Migration executed')
90
+ return 0
95
91
  }
@@ -1,5 +1,4 @@
1
1
  export * from './MigrationAmendCommand'
2
- export * from './MigrationCreateCommand'
3
2
  export * from './MigrationDescribeCommand'
4
3
  export * from './MigrationDiffCommand'
5
4
  export * from './MigrationExecuteCommand'
package/src/run.ts CHANGED
@@ -6,7 +6,6 @@ import {
6
6
  DeployCommand,
7
7
  InviteCommand,
8
8
  MigrationAmendCommand,
9
- MigrationCreateCommand,
10
9
  MigrationDescribeCommand,
11
10
  MigrationDiffCommand,
12
11
  MigrationExecuteCommand,
@@ -35,7 +34,6 @@ import {
35
34
  ['migrations:diff']: diffCommandFactory,
36
35
  ['migrations:amend']: () => new MigrationAmendCommand(),
37
36
  ['migrations:describe']: migrationsDescribeFactory,
38
- ['migrations:create']: () => new MigrationCreateCommand(),
39
37
  ['migrations:execute']: () => new MigrationExecuteCommand(),
40
38
  ['migrations:rebase']: () => new MigrationRebaseCommand(),
41
39
  ['migrations:status']: () => new MigrationStatusCommand(),
@@ -10,8 +10,9 @@ export class AdminClient {
10
10
 
11
11
  public async deploy(project: string, files: AdminFiles): Promise<void> {
12
12
  const response = await this.execute('_deploy', 'POST', { project, files })
13
+
13
14
  if (!response.ok) {
14
- throw 'Failed to deploy admin'
15
+ throw `Failed to deploy admin, POST request to ${this.url}/_deploy returned status ${response.status} ${response.statusText}`
15
16
  }
16
17
  }
17
18
 
@@ -40,7 +40,7 @@ export class SystemClient {
40
40
  return new SystemClient(graphqlClient)
41
41
  }
42
42
 
43
- public async migrate(migrations: Migration[], force = false): Promise<MigrateResponse> {
43
+ public async migrate(migrations: Migration[], force = false): Promise<void> {
44
44
  const query = `
45
45
  mutation($migrations: [Migration!]!) {
46
46
  migrate: ${force ? 'forceMigrate' : 'migrate'}(migrations: $migrations) {
@@ -53,13 +53,16 @@ mutation($migrations: [Migration!]!) {
53
53
  }
54
54
  }
55
55
  `
56
- return (
56
+ const result = (
57
57
  await this.apiClient.request<{
58
58
  migrate: { ok: boolean; errors: { code: MigrateErrorCode; migration: string; message: string }[] }
59
59
  }>(query, {
60
60
  migrations,
61
61
  })
62
62
  ).migrate
63
+ if (!result.ok) {
64
+ throw result.errors
65
+ }
63
66
  }
64
67
 
65
68
  public async migrationDelete(version: string): Promise<void> {
@@ -1,15 +0,0 @@
1
- import { Command, CommandConfiguration, Input } from '@contember/cli-common';
2
- declare type Args = {
3
- project: string;
4
- migrationName: string;
5
- };
6
- declare type Options = {
7
- ['migrations-dir']?: string;
8
- ['project-dir']?: string;
9
- };
10
- export declare class MigrationCreateCommand extends Command<Args, Options> {
11
- protected configure(configuration: CommandConfiguration<Args, Options>): void;
12
- protected execute(input: Input<Args, Options>): Promise<number>;
13
- }
14
- export {};
15
- //# sourceMappingURL=MigrationCreateCommand.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MigrationCreateCommand.d.ts","sourceRoot":"","sources":["../../../../src/commands/migrations/MigrationCreateCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAA;AAG5E,aAAK,IAAI,GAAG;IACX,OAAO,EAAE,MAAM,CAAA;IACf,aAAa,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,aAAK,OAAO,GAAG;IACd,CAAC,gBAAgB,CAAC,CAAC,EAAE,MAAM,CAAA;IAC3B,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAA;CACxB,CAAA;AAED,qBAAa,sBAAuB,SAAQ,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;IACjE,SAAS,CAAC,SAAS,CAAC,aAAa,EAAE,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,IAAI;cAK7D,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC;CAQrE"}
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MigrationCreateCommand = void 0;
4
- const cli_common_1 = require("@contember/cli-common");
5
- const MigrationCreateHelper_1 = require("./MigrationCreateHelper");
6
- class MigrationCreateCommand extends cli_common_1.Command {
7
- configure(configuration) {
8
- configuration.description('Creates empty schema migration for given project');
9
- MigrationCreateHelper_1.configureCreateMigrationCommand(configuration);
10
- }
11
- async execute(input) {
12
- return await MigrationCreateHelper_1.executeCreateMigrationCommand(input, async ({ migrationCreator }) => {
13
- const migrationName = input.getArgument('migrationName');
14
- const result = await migrationCreator.createEmpty(migrationName);
15
- console.log(`${result} created`);
16
- return 0;
17
- });
18
- }
19
- }
20
- exports.MigrationCreateCommand = MigrationCreateCommand;
21
- //# sourceMappingURL=MigrationCreateCommand.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MigrationCreateCommand.js","sourceRoot":"","sources":["../../../../src/commands/migrations/MigrationCreateCommand.ts"],"names":[],"mappings":";;;AAAA,sDAA4E;AAC5E,mEAAwG;AAYxG,MAAa,sBAAuB,SAAQ,oBAAsB;IACvD,SAAS,CAAC,aAAkD;QACrE,aAAa,CAAC,WAAW,CAAC,kDAAkD,CAAC,CAAA;QAC7E,uDAA+B,CAAC,aAAa,CAAC,CAAA;IAC/C,CAAC;IAES,KAAK,CAAC,OAAO,CAAC,KAA2B;QAClD,OAAO,MAAM,qDAA6B,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,gBAAgB,EAAE,EAAE,EAAE;YAChF,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;YACxD,MAAM,MAAM,GAAG,MAAM,gBAAgB,CAAC,WAAW,CAAC,aAAa,CAAC,CAAA;YAChE,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,UAAU,CAAC,CAAA;YAChC,OAAO,CAAC,CAAA;QACT,CAAC,CAAC,CAAA;IACH,CAAC;CACD;AAdD,wDAcC"}
@@ -1,28 +0,0 @@
1
- import { Command, CommandConfiguration, Input } from '@contember/cli-common'
2
- import { configureCreateMigrationCommand, executeCreateMigrationCommand } from './MigrationCreateHelper'
3
-
4
- type Args = {
5
- project: string
6
- migrationName: string
7
- }
8
-
9
- type Options = {
10
- ['migrations-dir']?: string
11
- ['project-dir']?: string
12
- }
13
-
14
- export class MigrationCreateCommand extends Command<Args, Options> {
15
- protected configure(configuration: CommandConfiguration<Args, Options>): void {
16
- configuration.description('Creates empty schema migration for given project')
17
- configureCreateMigrationCommand(configuration)
18
- }
19
-
20
- protected async execute(input: Input<Args, Options>): Promise<number> {
21
- return await executeCreateMigrationCommand(input, async ({ migrationCreator }) => {
22
- const migrationName = input.getArgument('migrationName')
23
- const result = await migrationCreator.createEmpty(migrationName)
24
- console.log(`${result} created`)
25
- return 0
26
- })
27
- }
28
- }