@extrahorizon/exh-cli 1.10.0-dev-103-b6be258 → 1.10.0-dev-104-c76c2f8

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.
@@ -0,0 +1,16 @@
1
+ /// <reference types="yargs" />
2
+ export declare const command = "init <name>";
3
+ export declare const desc = "Create a basic schema configuration file";
4
+ export declare const builder: (yargs: any) => import("yargs").Argv<import("yargs").Omit<{
5
+ name: string;
6
+ }, "path"> & import("yargs").InferredOptionTypes<{
7
+ path: {
8
+ description: string;
9
+ type: "string";
10
+ default: string;
11
+ };
12
+ }>>;
13
+ export declare const handler: ({ name, path }: {
14
+ name: string;
15
+ path: string;
16
+ }) => Promise<void>;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handler = exports.builder = exports.desc = exports.command = void 0;
4
+ const promises_1 = require("fs/promises");
5
+ const osPath = require("path");
6
+ const util_1 = require("../../../helpers/util");
7
+ exports.command = 'init <name>';
8
+ exports.desc = 'Create a basic schema configuration file';
9
+ const builder = (yargs) => (0, util_1.epilogue)(yargs)
10
+ .positional('name', {
11
+ demandOption: true,
12
+ description: 'The name of the new schema',
13
+ type: 'string',
14
+ })
15
+ .options({
16
+ path: {
17
+ description: 'The path to the folder where the schema should be created',
18
+ type: 'string',
19
+ default: './schemas',
20
+ },
21
+ });
22
+ exports.builder = builder;
23
+ const handler = async function init({ name, path }) {
24
+ await (0, promises_1.mkdir)(path, { recursive: true });
25
+ const filePath = osPath.join(path, `${name}.json`);
26
+ await (0, promises_1.writeFile)(filePath, JSON.stringify(createSchema(name), null, 2));
27
+ console.log(`✅ Successfully created ${filePath}`);
28
+ };
29
+ exports.handler = handler;
30
+ function createSchema(name) {
31
+ return {
32
+ $schema: 'https://swagger.extrahorizon.com/cli/1.10.0/config-json-schemas/Schema.json',
33
+ name,
34
+ description: `The ${name} schema`,
35
+ createMode: 'allUsers',
36
+ readMode: ['creator'],
37
+ updateMode: ['creator'],
38
+ deleteMode: ['creator'],
39
+ statuses: {
40
+ new: {},
41
+ },
42
+ creationTransition: {
43
+ type: 'manual',
44
+ toStatus: 'new',
45
+ },
46
+ transitions: [],
47
+ properties: {
48
+ firstProperty: {
49
+ type: 'string',
50
+ },
51
+ },
52
+ };
53
+ }
package/build/index.js CHANGED
@@ -10,6 +10,7 @@ yargs((0, helpers_1.hideBin)(process.argv))
10
10
  .middleware(async (argv) => {
11
11
  const isTTY = tty.isatty(process.stdout.fd);
12
12
  if ((0, lodash_1.isEqual)(argv._, ['login']) ||
13
+ (0, lodash_1.isEqual)(argv._, ['data', 'schemas', 'init']) ||
13
14
  (0, lodash_1.isEqual)(argv._, ['data', 'schemas', 'verify']) ||
14
15
  (0, lodash_1.isEqual)(argv._, ['tasks', 'create-repo']) ||
15
16
  (0, lodash_1.isEqual)(argv._, ['completion']) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@extrahorizon/exh-cli",
3
- "version": "1.10.0-dev-103-b6be258",
3
+ "version": "1.10.0-dev-104-c76c2f8",
4
4
  "main": "build/index.js",
5
5
  "exports": "./build/index.js",
6
6
  "license": "MIT",