@cognite/itg-cli
Advanced tools
Comparing version 0.0.1-alpha.1 to 0.0.1-alpha.2
@@ -1,1 +0,11 @@ | ||
export {}; | ||
export declare const command = "validate"; | ||
export declare const desc = "Validate schema"; | ||
export declare const builder: { | ||
file: { | ||
description: string; | ||
alias: string; | ||
}; | ||
'fail-on-invalid': { | ||
description: string; | ||
}; | ||
}; |
@@ -46,2 +46,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.builder = exports.desc = exports.command = void 0; | ||
var graphql_request_1 = require("graphql-request"); | ||
@@ -57,2 +58,5 @@ var fs_1 = __importDefault(require("fs")); | ||
}, | ||
'fail-on-invalid': { | ||
description: 'Fail when passed an invalid schema', | ||
}, | ||
}; | ||
@@ -78,2 +82,6 @@ var schemaRequest = graphql_request_1.gql(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n query ValidateSchema($schema: String!) {\n ValidateSchema(graphQLSchemaString: $schema) {\n valid\n }\n }\n"], ["\n query ValidateSchema($schema: String!) {\n ValidateSchema(graphQLSchemaString: $schema) {\n valid\n }\n }\n"]))); | ||
res = _a.sent(); | ||
if (!res.ValidateSchema.valid && argv['fail-on-invalid']) { | ||
console.error(chalk_1.default.red('Invalid schema')); | ||
process.exit(1); | ||
} | ||
console.log("Successfully checked validity of schema\n\tRESULT: Schema is " + (res.ValidateSchema.valid ? chalk_1.default.green('valid') : chalk_1.default.red('invalid'))); | ||
@@ -80,0 +88,0 @@ return [2 /*return*/]; |
{ | ||
"name": "@cognite/itg-cli", | ||
"version": "0.0.1-alpha.1", | ||
"version": "0.0.1-alpha.2", | ||
"description": "A CLI for itg.cognite.ai", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/cognitedata/il-tempo-gigante/tree/master/packages/itg-cli", |
# itg - A CLI for https://itg.cognite.ai | ||
## Install | ||
```bash | ||
@@ -19,2 +20,8 @@ npm install -g @cognite/itg-cli | ||
# Check if a schema is valid graphql and fits ITG requirements | ||
itg schema validate -f mymodel.graphql | ||
# For CI/CD, add flag to fail when invalid schema detected | ||
itg schema validate --fail-on-invalid -f mymodel.graphql | ||
# Add and replace a schema in itg | ||
@@ -35,1 +42,5 @@ itg schema update -f mymodel.graphql | ||
Set the COGNITE_CREDENTIALS variable with an api key for the respective cdf project to get access | ||
## CI/CD | ||
We expect the main use of the CLI for CI/CD will be validating and updating schemas. The validate step should be added to the `create pr` workflow, while the update step should be added to the `merge to master` workflow. Remember to include the `--fail-on-invalid` flag in the validate command to avoid false positives in the workflow. |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
80165
1402
45
0