@takeshape/cli 7.205.0 → 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.
- package/lib/commands/import/schema-import.d.ts.map +1 -1
- package/lib/commands/import/schema-import.js +5 -6
- package/lib/commands/validate.d.ts +7 -0
- package/lib/commands/validate.d.ts.map +1 -0
- package/lib/commands/validate.js +53 -0
- package/lib/index.js +4 -0
- package/lib/main.d.ts.map +1 -1
- package/lib/main.js +2 -1
- package/lib/util/format-validation-result.d.ts +3 -0
- package/lib/util/format-validation-result.d.ts.map +1 -0
- package/lib/util/format-validation-result.js +17 -0
- package/package.json +5 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema-import.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/schema-import.ts"],"names":[],"mappings":"
|
|
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 (
|
|
63
|
-
return (0, _fatalError.fatalError)(
|
|
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 @@
|
|
|
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":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.js"],"names":[],"mappings":"AAiBA,qFAQC"}
|
package/lib/main.js
CHANGED
|
@@ -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.
|
|
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.
|
|
24
|
-
"@takeshape/ssg": "7.
|
|
25
|
-
"@takeshape/streams": "7.
|
|
26
|
-
"@takeshape/util": "7.
|
|
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",
|