@takeshape/cli 7.208.1 → 7.209.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.
@@ -1 +1 @@
1
- {"version":3,"file":"schema-import.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/schema-import.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;;AAWD,wBAoCE"}
1
+ {"version":3,"file":"schema-import.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/schema-import.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;;AAWD,wBAkCE"}
@@ -21,6 +21,8 @@ var _linkedCommand = require("../../util/linked-command");
21
21
 
22
22
  var _path = _interopRequireDefault(require("path"));
23
23
 
24
+ var _formatValidationResult = require("../../util/format-validation-result");
25
+
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
27
 
26
28
  /*
@@ -54,13 +56,10 @@ var _default = (0, _linkedCommand.linkedCommand)(async (_, params, flags) => {
54
56
 
55
57
  try {
56
58
  const newSchema = JSON.parse(_fsExtra.default.readFileSync(file).toString());
57
- const {
58
- valid,
59
- errors
60
- } = (0, _schema.validateSchema)(newSchema);
59
+ const validationString = (0, _formatValidationResult.formatValidationResult)((0, _schema.validateSchema)(newSchema));
61
60
 
62
- if (!valid && errors) {
63
- return (0, _fatalError.fatalError)(`Invalid schema:\n ${errors.map(e => `${e.type}: ${e.message} at ${e.path.join('/')}`).join('\n ')}`);
61
+ if (validationString) {
62
+ return (0, _fatalError.fatalError)(validationString);
64
63
  }
65
64
 
66
65
  (0, _log.default)(`Uploading schema from ${file}…\n`);
@@ -0,0 +1,7 @@
1
+ import { CliConfig } from '../types';
2
+ interface ValidateFlags {
3
+ path?: string;
4
+ }
5
+ declare const _default: (_command: string, _params: CliConfig, flags: ValidateFlags) => Promise<void>;
6
+ export default _default;
7
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/commands/validate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAMnC,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;mCAE+B,MAAM,WAAW,SAAS,SAAS,aAAa,KAAG,QAAQ,IAAI,CAAC;AAAhG,wBA6BE"}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
+
10
+ var _log = _interopRequireDefault(require("../log"));
11
+
12
+ var _fatalError = require("../util/fatal-error");
13
+
14
+ var _path = _interopRequireDefault(require("path"));
15
+
16
+ var _formatValidationResult = require("../util/format-validation-result");
17
+
18
+ var _schema = require("@takeshape/schema");
19
+
20
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
+
22
+ var _default = async (_command, _params, flags) => {
23
+ let schemaPath;
24
+
25
+ if (flags.path) {
26
+ if (_fsExtra.default.existsSync(flags.path) && _fsExtra.default.statSync(flags.path).isDirectory()) {
27
+ schemaPath = _path.default.join(flags.path, 'schema.json');
28
+ } else {
29
+ schemaPath = flags.path;
30
+ }
31
+ } else {
32
+ schemaPath = _path.default.join('.', 'schema.json');
33
+ }
34
+
35
+ if (!_fsExtra.default.existsSync(schemaPath)) {
36
+ return (0, _fatalError.fatalError)(`${schemaPath} does not exist. You can download a project schema with 'takeshape export --schema'` + ` or specify a path with 'takeshape validate --path=/path/to/schema.json'`);
37
+ }
38
+
39
+ try {
40
+ const schema = JSON.parse(_fsExtra.default.readFileSync(schemaPath).toString());
41
+ const validationString = (0, _formatValidationResult.formatValidationResult)((0, _schema.validateSchema)(schema));
42
+
43
+ if (validationString) {
44
+ return (0, _fatalError.fatalError)(validationString);
45
+ }
46
+ } catch (e) {
47
+ return (0, _fatalError.fatalError)(e.message);
48
+ }
49
+
50
+ (0, _log.default)(`${schemaPath} is valid.`);
51
+ };
52
+
53
+ exports.default = _default;
package/lib/index.js CHANGED
@@ -26,6 +26,7 @@ const help = `
26
26
  status
27
27
  import
28
28
  export
29
+ validate
29
30
 
30
31
  Options
31
32
  --token, -t TakeShape API auth token
@@ -55,6 +56,9 @@ const help = `
55
56
  --withoutData when using --project skip exporting the data
56
57
  --to specifies the directory to write the exported data to
57
58
 
59
+ validate Options
60
+ --path path to the schema file to validate, or the directory it is in (default "./schema.json")
61
+
58
62
  Examples
59
63
  $ takeshape build --file path/to/tsg.yml
60
64
 
package/lib/main.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.js"],"names":[],"mappings":"AAgBA,qFAQC"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.js"],"names":[],"mappings":"AAiBA,qFAQC"}
package/lib/main.js CHANGED
@@ -20,7 +20,8 @@ const commandPath = {
20
20
  schema: 'schema',
21
21
  status: 'status',
22
22
  import: 'import',
23
- export: 'export'
23
+ export: 'export',
24
+ validate: 'validate'
24
25
  };
25
26
 
26
27
  async function _default(command, params, cli) {
@@ -0,0 +1,3 @@
1
+ import { SchemaValidationResult } from '@takeshape/schema';
2
+ export declare function formatValidationResult(schemaValidationResult: SchemaValidationResult): string | undefined;
3
+ //# sourceMappingURL=format-validation-result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format-validation-result.d.ts","sourceRoot":"","sources":["../../../src/util/format-validation-result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,sBAAsB,EAAC,MAAM,mBAAmB,CAAC;AAEzD,wBAAgB,sBAAsB,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,MAAM,GAAG,SAAS,CAKzG"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatValidationResult = formatValidationResult;
7
+
8
+ function formatValidationResult(schemaValidationResult) {
9
+ const {
10
+ valid,
11
+ errors
12
+ } = schemaValidationResult;
13
+
14
+ if (!valid && errors) {
15
+ return `Invalid schema:\n ${errors.map(e => `${e.type}: ${e.message} at ${e.path.join('/')}`).join('\n ')}`;
16
+ }
17
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/cli",
3
- "version": "7.208.1",
3
+ "version": "7.209.0",
4
4
  "description": "TakeShape CLI",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -20,10 +20,10 @@
20
20
  "lib"
21
21
  ],
22
22
  "dependencies": {
23
- "@takeshape/schema": "7.208.1",
24
- "@takeshape/ssg": "7.208.1",
25
- "@takeshape/streams": "7.208.1",
26
- "@takeshape/util": "7.208.1",
23
+ "@takeshape/schema": "7.209.0",
24
+ "@takeshape/ssg": "7.209.0",
25
+ "@takeshape/streams": "7.209.0",
26
+ "@takeshape/util": "7.209.0",
27
27
  "archiver": "^1.3.0",
28
28
  "async-retry": "^1.2.1",
29
29
  "bluebird": "^3.4.6",