@contember/cli 1.4.0-rc.1 → 1.4.0-rc.3

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.
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.updateYaml = void 0;
7
7
  const cli_common_1 = require("@contember/cli-common");
8
- const cjs_1 = __importDefault(require("yawn-yaml/cjs"));
8
+ const yawn_yaml_1 = __importDefault(require("yawn-yaml"));
9
9
  const config_loader_1 = require("@contember/config-loader");
10
10
  const js_yaml_1 = __importDefault(require("js-yaml"));
11
11
  const promises_1 = require("node:fs/promises");
@@ -20,7 +20,7 @@ const updateYaml = async (path, updater, options = {}) => {
20
20
  let newConfig = '';
21
21
  const mergeUtils = { merge: (a, b) => config_loader_1.Merger.merge(a, b) };
22
22
  if (config) {
23
- const yawn = new cjs_1.default(config);
23
+ const yawn = new yawn_yaml_1.default(config);
24
24
  yawn.json = updater(yawn.json, mergeUtils);
25
25
  newConfig = yawn.yaml;
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"yaml.js","sourceRoot":"","sources":["../../../src/utils/yaml.ts"],"names":[],"mappings":";;;;;;AAAA,sDAA6E;AAC7E,wDAAgC;AAChC,4DAAiD;AACjD,sDAA4B;AAC5B,+CAAsD;AAO/C,MAAM,UAAU,GAAG,KAAK,EAC9B,IAAY,EACZ,OAAkC,EAClC,UAAuC,EAAE,EACxC,EAAE;IACH,IAAI,MAAM,GAAG,EAAE,CAAA;IACf,IAAI,MAAM,IAAA,uBAAU,EAAC,IAAI,CAAC,EAAE;QAC3B,MAAM,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;KACnD;SAAM,IAAI,OAAO,CAAC,aAAa,KAAK,IAAI,EAAE;QAC1C,MAAM,IAAI,KAAK,CAAC,QAAQ,IAAI,kBAA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ED,IAAI,SAAS,GAAG,EAAE,CAAA;IAClB,MAAM,UAAU,GAAG,EAAE,KAAK,EAAE,CAAC,CAAa,EAAE,CAAa,EAAE,EAAE,CAAC,sBAAM,CAAC,KAAK,CAAgB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAA;IACjG,IAAI,MAAM,EAAE;QACX,MAAM,IAAI,GAAG,IAAI,mBAAI,CAAC,MAAM,CAAC,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;QAC1C,SAAS,GAAG,IAAI,CAAC,IAAI,CAAA;KACrB;SAAM;QACN,SAAS,GAAG,iBAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAA;KAChD;IAED,MAAM,IAAA,oBAAS,EAAC,IAAI,EAAE,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAA;AACvD,CAAC,CAAA;AAvBY,QAAA,UAAU,cAuBtB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contember/cli",
3
- "version": "1.4.0-rc.1",
3
+ "version": "1.4.0-rc.3",
4
4
  "license": "Apache-2.0",
5
5
  "bin": {
6
6
  "contember": "./dist/src/run.js"
@@ -20,15 +20,15 @@
20
20
  "tailwindcss": "^3.3.5"
21
21
  },
22
22
  "dependencies": {
23
- "@contember/cli-common": "1.4.0-rc.1",
24
- "@contember/config-loader": "1.4.0-rc.1",
25
- "@contember/database": "1.4.0-rc.1",
26
- "@contember/dic": "1.4.0-rc.1",
27
- "@contember/engine-content-api": "1.4.0-rc.1",
28
- "@contember/migrations-client": "1.4.0-rc.1",
29
- "@contember/schema": "1.4.0-rc.1",
30
- "@contember/schema-migrations": "1.4.0-rc.1",
31
- "@contember/schema-utils": "1.4.0-rc.1",
23
+ "@contember/cli-common": "1.4.0-rc.3",
24
+ "@contember/config-loader": "1.4.0-rc.3",
25
+ "@contember/database": "1.4.0-rc.3",
26
+ "@contember/dic": "1.4.0-rc.3",
27
+ "@contember/engine-content-api": "1.4.0-rc.3",
28
+ "@contember/migrations-client": "1.4.0-rc.3",
29
+ "@contember/schema": "1.4.0-rc.3",
30
+ "@contember/schema-migrations": "1.4.0-rc.3",
31
+ "@contember/schema-utils": "1.4.0-rc.3",
32
32
  "@graphql-tools/schema": "^10.0.0",
33
33
  "chalk": "^4.1.2",
34
34
  "chalk-table": "^1.0.2",
@@ -41,6 +41,6 @@
41
41
  "preact-render-to-string": "^6.3.1",
42
42
  "prompts": "^2.4.2",
43
43
  "semver": "^7.5.4",
44
- "yawn-yaml": "^1.5.0"
44
+ "yawn-yaml": "^2.2.0"
45
45
  }
46
46
  }
@@ -4,13 +4,17 @@ import { dataExport, resolveProject } from './utils'
4
4
  import { maskToken } from '../../utils/token'
5
5
  import { pipeline } from 'node:stream/promises'
6
6
  import { printProgressLine } from '../../utils/stdio'
7
+ import { createGunzip, createGzip } from 'node:zlib'
7
8
 
8
9
  type Args = {
9
10
  source?: string
10
11
  }
11
12
  type Options = {
12
13
  'include-system'?: boolean
14
+ /** @deprecated */
13
15
  'no-gzip'?: boolean
16
+ 'no-gzip-output'?: boolean
17
+ 'no-gzip-transfer'?: boolean
14
18
  output?: string
15
19
  }
16
20
 
@@ -28,7 +32,9 @@ export class ExportCommand extends Command<Args, Options> {
28
32
  from.optional()
29
33
  }
30
34
  configuration.option('include-system').valueNone()
31
- configuration.option('no-gzip').valueNone()
35
+ configuration.option('no-gzip').valueNone().deprecated()
36
+ configuration.option('no-gzip-transfer').valueNone()
37
+ configuration.option('no-gzip-output').valueNone()
32
38
  configuration.option('output').valueRequired()
33
39
  }
34
40
 
@@ -43,10 +49,16 @@ export class ExportCommand extends Command<Args, Options> {
43
49
  console.log(`API URL: ${project.baseUrl}`)
44
50
  console.log(`Token: ${maskToken(project.token)}`)
45
51
 
46
- const noGzip = input.getOption('no-gzip') === true
52
+ const gzipOutput = !input.getOption('no-gzip-output') && !input.getOption('no-gzip')
53
+ const gzipTransfer = !input.getOption('no-gzip-transfer')
54
+
47
55
  const includeSystem = input.getOption('include-system') === true
48
56
 
49
- const response = await dataExport({ project, includeSystem, noGzip })
57
+ const response = await dataExport({
58
+ project,
59
+ includeSystem,
60
+ gzip: gzipTransfer,
61
+ })
50
62
 
51
63
  let transferred = 0
52
64
  let start = Date.now()
@@ -62,11 +74,16 @@ export class ExportCommand extends Command<Args, Options> {
62
74
  }
63
75
  })
64
76
 
65
- const fileName = input.getOption('output') ?? `${project.project}.jsonl${noGzip ? '' : '.gz'}`
77
+ const fileName = input.getOption('output') ?? `${project.project}.jsonl${gzipOutput ? '.gz' : ''}`
66
78
  const fileStream = createWriteStream(fileName)
67
79
 
68
- await pipeline(response, fileStream)
80
+ const responseStream = gzipOutput === gzipTransfer
81
+ ? response
82
+ : response.pipe(gzipOutput ? createGzip() : createGunzip())
83
+
84
+ await pipeline(responseStream, fileStream)
69
85
 
70
86
  console.log('\nExport done.')
87
+ console.log(`Data saved to ${fileName}`)
71
88
  }
72
89
  }
@@ -12,6 +12,7 @@ type Args = {
12
12
  }
13
13
  type Options = {
14
14
  'yes': boolean
15
+ 'no-gzip-transfer'?: boolean
15
16
  }
16
17
 
17
18
  export class ImportCommand extends Command<Args, Options> {
@@ -28,6 +29,7 @@ export class ImportCommand extends Command<Args, Options> {
28
29
  if (this.workspace.isSingleProjectMode()) {
29
30
  from.optional()
30
31
  }
32
+ configuration.option('no-gzip-transfer').valueNone()
31
33
  configuration.option('yes').valueNone()
32
34
  }
33
35
 
@@ -47,7 +49,13 @@ export class ImportCommand extends Command<Args, Options> {
47
49
  const file = input.getArgument('file')
48
50
  const baseInputStream = createReadStream(file)
49
51
  const stream = (file.endsWith('.gz') ? baseInputStream.pipe(createGunzip()) : baseInputStream)
50
- const response = await dataImport({ stream: stream, project, printProgress: printProgressLine })
52
+ const gzipTransfer = !input.getOption('no-gzip-transfer')
53
+ const response = await dataImport({
54
+ stream: stream,
55
+ project,
56
+ printProgress: printProgressLine,
57
+ gzip: gzipTransfer,
58
+ })
51
59
  console.log('')
52
60
  const responseData = JSON.parse((await readStream(response)).toString())
53
61
  if (responseData.ok) {
@@ -3,6 +3,7 @@ import { confirmImport, dataExport, dataImport, resolveProject } from './utils'
3
3
  import { maskToken } from '../../utils/token'
4
4
  import { printProgressLine } from '../../utils/stdio'
5
5
  import { readStream } from '../../utils/stream'
6
+ import { createGunzip } from 'node:zlib'
6
7
 
7
8
  type Args = {
8
9
  source: string
@@ -10,6 +11,7 @@ type Args = {
10
11
  }
11
12
  type Options = {
12
13
  'include-system'?: boolean
14
+ 'no-gzip-transfer'?: boolean
13
15
  yes: boolean
14
16
  }
15
17
 
@@ -28,6 +30,7 @@ export class TransferCommand extends Command<Args, Options> {
28
30
  target.optional()
29
31
  }
30
32
  configuration.option('include-system').valueNone()
33
+ configuration.option('no-gzip-transfer').valueNone()
31
34
  configuration.option('yes').valueNone()
32
35
  }
33
36
 
@@ -54,9 +57,14 @@ export class TransferCommand extends Command<Args, Options> {
54
57
  }
55
58
 
56
59
  const includeSystem = input.getOption('include-system') === true
57
- const exportResponse = (await dataExport({ project: sourceProject, includeSystem, noGzip: true }))
60
+ const gzipTransfer = !input.getOption('no-gzip-transfer')
61
+ const exportResponse = (await dataExport({ project: sourceProject, includeSystem, gzip: gzipTransfer }))
62
+ const ungzipedResponse = gzipTransfer ? exportResponse.pipe(createGunzip()) : exportResponse
58
63
  const importResponse = await dataImport({
59
- stream: exportResponse, project: targetProject, printProgress: printProgressLine,
64
+ stream: ungzipedResponse,
65
+ project: targetProject,
66
+ printProgress: printProgressLine,
67
+ gzip: gzipTransfer,
60
68
  })
61
69
  console.log('')
62
70
 
@@ -7,6 +7,7 @@ import { parseDsn } from '../../utils/dsn'
7
7
  import { interactiveResolveInstanceEnvironmentFromInput } from '../../utils/instance'
8
8
  import { interactiveResolveApiToken } from '../../utils/tenant'
9
9
  import prompts from 'prompts'
10
+ import { createGzip } from 'node:zlib'
10
11
 
11
12
  export type ProjectEndpoint = {
12
13
  token: string
@@ -30,7 +31,7 @@ export const resolveProject = async ({ projectOrDsn, workspace }: { projectOrDsn
30
31
 
31
32
  }
32
33
 
33
- export const dataImport = async ({ printProgress, stream, project: { project, token, baseUrl } }: { stream: Readable; project: ProjectEndpoint; printProgress: (message: string) => void }) => {
34
+ export const dataImport = async ({ printProgress, stream, project: { project, token, baseUrl }, gzip }: { stream: Readable; project: ProjectEndpoint; printProgress: (message: string) => void; gzip: boolean }) => {
34
35
  let table = ''
35
36
  let rowCount = 0
36
37
  let rowTotal = 0
@@ -71,17 +72,18 @@ export const dataImport = async ({ printProgress, stream, project: { project, to
71
72
  token,
72
73
  headers: {
73
74
  'Content-type': 'application/x-ndjson',
75
+ ...(gzip ? { 'Content-Encoding': 'gzip' } : {}),
74
76
  },
75
- body: inputStream,
77
+ body: gzip ? inputStream.pipe(createGzip()) : inputStream,
76
78
  })
77
79
  }
78
80
 
79
- export const dataExport = async ({ project: { project, token, baseUrl }, noGzip, includeSystem }: { project: ProjectEndpoint; includeSystem: boolean; noGzip: boolean }) => {
81
+ export const dataExport = async ({ project: { project, token, baseUrl }, gzip, includeSystem }: { project: ProjectEndpoint; includeSystem: boolean; gzip: boolean }) => {
80
82
  return await executeRequest({
81
83
  url: `${baseUrl}/export`,
82
84
  token,
83
85
  headers: {
84
- 'Accept-Encoding': noGzip ? 'identity' : 'gzip',
86
+ 'Accept-Encoding': gzip ? 'gzip' : 'identity',
85
87
  'Content-type': 'application/json',
86
88
  },
87
89
  body: JSON.stringify({
package/src/utils/yaml.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JSONObject, JSONPrimitive, pathExists } from '@contember/cli-common'
2
- import YAWN from 'yawn-yaml/cjs'
2
+ import YAWN from 'yawn-yaml'
3
3
  import { Merger } from '@contember/config-loader'
4
4
  import jsyaml from 'js-yaml'
5
5
  import { readFile, writeFile } from 'node:fs/promises'
@@ -1,7 +0,0 @@
1
- declare module 'yawn-yaml/cjs' {
2
- export default class YAWN {
3
- json: any
4
- readonly yaml: string
5
- constructor(yaml: string)
6
- }
7
- }