@credibledata/cred-cli 0.0.6
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/.github/workflows/build.yml +23 -0
- package/.mocharc.json +10 -0
- package/.prettierignore +2 -0
- package/.prettierrc +4 -0
- package/README-DEV.md +40 -0
- package/README.md +11 -0
- package/bun.lock +1158 -0
- package/dist/client/api.js +7715 -0
- package/dist/client/api.js.map +1 -0
- package/dist/client/base.js +69 -0
- package/dist/client/base.js.map +1 -0
- package/dist/client/common.js +162 -0
- package/dist/client/common.js.map +1 -0
- package/dist/client/configuration.js +44 -0
- package/dist/client/configuration.js.map +1 -0
- package/dist/client/index.js +32 -0
- package/dist/client/index.js.map +1 -0
- package/dist/clientconfiguration.js +205 -0
- package/dist/clientconfiguration.js.map +1 -0
- package/dist/clientconfiguration.spec.js +381 -0
- package/dist/clientconfiguration.spec.js.map +1 -0
- package/dist/commands/add.js +66 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/connection/createconnections.js +89 -0
- package/dist/commands/connection/createconnections.js.map +1 -0
- package/dist/commands/connection/createconnections.spec.js +219 -0
- package/dist/commands/connection/createconnections.spec.js.map +1 -0
- package/dist/commands/connection/deleteconnection.js +52 -0
- package/dist/commands/connection/deleteconnection.js.map +1 -0
- package/dist/commands/connection/deleteconnection.spec.js +130 -0
- package/dist/commands/connection/deleteconnection.spec.js.map +1 -0
- package/dist/commands/connection/listconnections.js +50 -0
- package/dist/commands/connection/listconnections.js.map +1 -0
- package/dist/commands/connection/listconnections.spec.js +117 -0
- package/dist/commands/connection/listconnections.spec.js.map +1 -0
- package/dist/commands/get.js +28 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/group/addmember.js +75 -0
- package/dist/commands/group/addmember.js.map +1 -0
- package/dist/commands/group/addmember.spec.js +148 -0
- package/dist/commands/group/addmember.spec.js.map +1 -0
- package/dist/commands/group/creategroup.js +55 -0
- package/dist/commands/group/creategroup.js.map +1 -0
- package/dist/commands/group/creategroup.spec.js +122 -0
- package/dist/commands/group/creategroup.spec.js.map +1 -0
- package/dist/commands/group/deletegroup.js +48 -0
- package/dist/commands/group/deletegroup.js.map +1 -0
- package/dist/commands/group/deletegroup.spec.js +104 -0
- package/dist/commands/group/deletegroup.spec.js.map +1 -0
- package/dist/commands/group/getgroup.js +50 -0
- package/dist/commands/group/getgroup.js.map +1 -0
- package/dist/commands/group/getgroup.spec.js +111 -0
- package/dist/commands/group/getgroup.spec.js.map +1 -0
- package/dist/commands/group/listgroups.js +56 -0
- package/dist/commands/group/listgroups.js.map +1 -0
- package/dist/commands/group/listgroups.spec.js +118 -0
- package/dist/commands/group/listgroups.spec.js.map +1 -0
- package/dist/commands/group/removemember.js +69 -0
- package/dist/commands/group/removemember.js.map +1 -0
- package/dist/commands/group/removemember.spec.js +138 -0
- package/dist/commands/group/removemember.spec.js.map +1 -0
- package/dist/commands/groupaccesstoken/createToken.js +53 -0
- package/dist/commands/groupaccesstoken/createToken.js.map +1 -0
- package/dist/commands/groupaccesstoken/createToken.spec.js +127 -0
- package/dist/commands/groupaccesstoken/createToken.spec.js.map +1 -0
- package/dist/commands/groupaccesstoken/deleteToken.js +24 -0
- package/dist/commands/groupaccesstoken/deleteToken.js.map +1 -0
- package/dist/commands/groupaccesstoken/deleteToken.spec.js +103 -0
- package/dist/commands/groupaccesstoken/deleteToken.spec.js.map +1 -0
- package/dist/commands/groupaccesstoken/groupContainer.js +71 -0
- package/dist/commands/groupaccesstoken/groupContainer.js.map +1 -0
- package/dist/commands/groupaccesstoken/listTokens.js +25 -0
- package/dist/commands/groupaccesstoken/listTokens.js.map +1 -0
- package/dist/commands/groupaccesstoken/listTokens.spec.js +115 -0
- package/dist/commands/groupaccesstoken/listTokens.spec.js.map +1 -0
- package/dist/commands/list.js +75 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/misc/login.js +290 -0
- package/dist/commands/misc/login.js.map +1 -0
- package/dist/commands/misc/login.spec.js +243 -0
- package/dist/commands/misc/login.spec.js.map +1 -0
- package/dist/commands/misc/logout.js +11 -0
- package/dist/commands/misc/logout.js.map +1 -0
- package/dist/commands/misc/logout.spec.js +30 -0
- package/dist/commands/misc/logout.spec.js.map +1 -0
- package/dist/commands/misc/loopbackOAuth.js +110 -0
- package/dist/commands/misc/loopbackOAuth.js.map +1 -0
- package/dist/commands/misc/set-access-token.js +27 -0
- package/dist/commands/misc/set-access-token.js.map +1 -0
- package/dist/commands/misc/set-access-token.spec.js +65 -0
- package/dist/commands/misc/set-access-token.spec.js.map +1 -0
- package/dist/commands/package/deletepackage.js +54 -0
- package/dist/commands/package/deletepackage.js.map +1 -0
- package/dist/commands/package/deletepackage.spec.js +136 -0
- package/dist/commands/package/deletepackage.spec.js.map +1 -0
- package/dist/commands/package/listpackages.js +57 -0
- package/dist/commands/package/listpackages.js.map +1 -0
- package/dist/commands/package/listpackages.spec.js +129 -0
- package/dist/commands/package/listpackages.spec.js.map +1 -0
- package/dist/commands/package/publish.js +157 -0
- package/dist/commands/package/publish.js.map +1 -0
- package/dist/commands/package/publish.spec.js +511 -0
- package/dist/commands/package/publish.spec.js.map +1 -0
- package/dist/commands/package/updatepackage.js +75 -0
- package/dist/commands/package/updatepackage.js.map +1 -0
- package/dist/commands/package/updatepackage.spec.js +189 -0
- package/dist/commands/package/updatepackage.spec.js.map +1 -0
- package/dist/commands/project/createproject.js +75 -0
- package/dist/commands/project/createproject.js.map +1 -0
- package/dist/commands/project/createproject.spec.js +154 -0
- package/dist/commands/project/createproject.spec.js.map +1 -0
- package/dist/commands/project/deleteproject.js +49 -0
- package/dist/commands/project/deleteproject.js.map +1 -0
- package/dist/commands/project/deleteproject.spec.js +106 -0
- package/dist/commands/project/deleteproject.spec.js.map +1 -0
- package/dist/commands/project/getproject.js +44 -0
- package/dist/commands/project/getproject.js.map +1 -0
- package/dist/commands/project/getproject.spec.js +99 -0
- package/dist/commands/project/getproject.spec.js.map +1 -0
- package/dist/commands/project/listprojects.js +52 -0
- package/dist/commands/project/listprojects.js.map +1 -0
- package/dist/commands/project/listprojects.spec.js +111 -0
- package/dist/commands/project/listprojects.spec.js.map +1 -0
- package/dist/commands/project/setproject.js +26 -0
- package/dist/commands/project/setproject.js.map +1 -0
- package/dist/commands/project/setproject.spec.js +58 -0
- package/dist/commands/project/setproject.spec.js.map +1 -0
- package/dist/commands/project/updateproject.js +68 -0
- package/dist/commands/project/updateproject.js.map +1 -0
- package/dist/commands/project/updateproject.spec.js +129 -0
- package/dist/commands/project/updateproject.spec.js.map +1 -0
- package/dist/commands/rm.js +68 -0
- package/dist/commands/rm.js.map +1 -0
- package/dist/commands/set.js +17 -0
- package/dist/commands/set.js.map +1 -0
- package/dist/commands/update.js +42 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/commands/version/archive-unarchive-version.js +79 -0
- package/dist/commands/version/archive-unarchive-version.js.map +1 -0
- package/dist/commands/version/archive-unarchive-version.spec.js +244 -0
- package/dist/commands/version/archive-unarchive-version.spec.js.map +1 -0
- package/dist/commands/version/listversions.js +46 -0
- package/dist/commands/version/listversions.js.map +1 -0
- package/dist/commands/version/listversions.spec.js +121 -0
- package/dist/commands/version/listversions.spec.js.map +1 -0
- package/dist/common/UserGroupId.js +112 -0
- package/dist/common/UserGroupId.js.map +1 -0
- package/dist/common/UserGroupId.spec.js +92 -0
- package/dist/common/UserGroupId.spec.js.map +1 -0
- package/dist/constants.js +90 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.js +159 -0
- package/dist/index.js.map +1 -0
- package/dist/logger.js +77 -0
- package/dist/logger.js.map +1 -0
- package/dist/logger.spec.js +125 -0
- package/dist/logger.spec.js.map +1 -0
- package/dist/polyfills/file.polyfill.js +6 -0
- package/dist/polyfills/file.polyfill.js.map +1 -0
- package/dist/utils.js +110 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.spec.js +158 -0
- package/dist/utils.spec.js.map +1 -0
- package/dist/validator.js +53 -0
- package/dist/validator.js.map +1 -0
- package/dist/validator.spec.js +41 -0
- package/dist/validator.spec.js.map +1 -0
- package/docker/Dockerfile.ci +18 -0
- package/docker-compose.yml +18 -0
- package/eslint.config.mjs +45 -0
- package/generate-client.sh +27 -0
- package/mocha.setup.ts +4 -0
- package/openapitools.json +7 -0
- package/package.json +75 -0
- package/src/client/.openapi-generator/FILES +9 -0
- package/src/client/.openapi-generator/VERSION +1 -0
- package/src/client/.openapi-generator-ignore +23 -0
- package/src/client/api.ts +9729 -0
- package/src/client/base.ts +86 -0
- package/src/client/common.ts +150 -0
- package/src/client/configuration.ts +110 -0
- package/src/client/git_push.sh +57 -0
- package/src/client/index.ts +18 -0
- package/src/clientconfiguration.spec.ts +490 -0
- package/src/clientconfiguration.ts +263 -0
- package/src/commands/add.ts +125 -0
- package/src/commands/connection/createconnections.spec.ts +403 -0
- package/src/commands/connection/createconnections.ts +109 -0
- package/src/commands/connection/deleteconnection.spec.ts +189 -0
- package/src/commands/connection/deleteconnection.ts +57 -0
- package/src/commands/connection/listconnections.spec.ts +132 -0
- package/src/commands/connection/listconnections.ts +58 -0
- package/src/commands/get.ts +31 -0
- package/src/commands/group/addmember.spec.ts +257 -0
- package/src/commands/group/addmember.ts +85 -0
- package/src/commands/group/creategroup.spec.ts +146 -0
- package/src/commands/group/creategroup.ts +54 -0
- package/src/commands/group/deletegroup.spec.ts +120 -0
- package/src/commands/group/deletegroup.ts +45 -0
- package/src/commands/group/getgroup.spec.ts +129 -0
- package/src/commands/group/getgroup.ts +47 -0
- package/src/commands/group/listgroups.spec.ts +137 -0
- package/src/commands/group/listgroups.ts +45 -0
- package/src/commands/group/removemember.spec.ts +224 -0
- package/src/commands/group/removemember.ts +75 -0
- package/src/commands/groupaccesstoken/createToken.spec.ts +211 -0
- package/src/commands/groupaccesstoken/createToken.ts +72 -0
- package/src/commands/groupaccesstoken/deleteToken.spec.ts +147 -0
- package/src/commands/groupaccesstoken/deleteToken.ts +29 -0
- package/src/commands/groupaccesstoken/groupContainer.ts +83 -0
- package/src/commands/groupaccesstoken/listTokens.spec.ts +147 -0
- package/src/commands/groupaccesstoken/listTokens.ts +29 -0
- package/src/commands/list.ts +131 -0
- package/src/commands/misc/login.spec.ts +213 -0
- package/src/commands/misc/login.ts +325 -0
- package/src/commands/misc/logout.spec.ts +32 -0
- package/src/commands/misc/logout.ts +9 -0
- package/src/commands/misc/loopbackOAuth.ts +127 -0
- package/src/commands/misc/set-access-token.spec.ts +95 -0
- package/src/commands/misc/set-access-token.ts +32 -0
- package/src/commands/package/deletepackage.spec.ts +164 -0
- package/src/commands/package/deletepackage.ts +58 -0
- package/src/commands/package/listpackages.spec.ts +147 -0
- package/src/commands/package/listpackages.ts +67 -0
- package/src/commands/package/publish.spec.ts +597 -0
- package/src/commands/package/publish.ts +211 -0
- package/src/commands/package/updatepackage.spec.ts +319 -0
- package/src/commands/package/updatepackage.ts +95 -0
- package/src/commands/project/createproject.spec.ts +247 -0
- package/src/commands/project/createproject.ts +70 -0
- package/src/commands/project/deleteproject.spec.ts +123 -0
- package/src/commands/project/deleteproject.ts +48 -0
- package/src/commands/project/getproject.spec.ts +109 -0
- package/src/commands/project/getproject.ts +43 -0
- package/src/commands/project/listprojects.spec.ts +121 -0
- package/src/commands/project/listprojects.ts +62 -0
- package/src/commands/project/setproject.spec.ts +63 -0
- package/src/commands/project/setproject.ts +14 -0
- package/src/commands/project/updateproject.spec.ts +217 -0
- package/src/commands/project/updateproject.ts +82 -0
- package/src/commands/rm.ts +101 -0
- package/src/commands/set.ts +16 -0
- package/src/commands/update.ts +64 -0
- package/src/commands/version/archive-unarchive-version.spec.ts +456 -0
- package/src/commands/version/archive-unarchive-version.ts +111 -0
- package/src/commands/version/listversions.spec.ts +138 -0
- package/src/commands/version/listversions.ts +45 -0
- package/src/common/UserGroupId.spec.ts +117 -0
- package/src/common/UserGroupId.ts +137 -0
- package/src/constants.ts +116 -0
- package/src/index.ts +209 -0
- package/src/logger.spec.ts +158 -0
- package/src/logger.ts +86 -0
- package/src/polyfills/file.polyfill.ts +6 -0
- package/src/utils.spec.ts +135 -0
- package/src/utils.ts +115 -0
- package/src/validator.spec.ts +51 -0
- package/src/validator.ts +44 -0
- package/tsconfig.json +17 -0
package/src/utils.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import inquirer from "inquirer";
|
|
3
|
+
import { logAxiosError, logger } from "./logger";
|
|
4
|
+
|
|
5
|
+
export function sleep(time_in_ms: number): Promise<void> {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, time_in_ms));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function prettifyJson(payload: object): string {
|
|
10
|
+
return JSON.stringify(payload, null, 2);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function printOutError(e: Error, debug: boolean) {
|
|
14
|
+
if (axios.isAxiosError(e)) {
|
|
15
|
+
logAxiosError(e, debug);
|
|
16
|
+
} else {
|
|
17
|
+
logger.error("Unexpected error", e);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (debug) {
|
|
21
|
+
logger.debug(e);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export async function getConfirmation(message: string): Promise<boolean> {
|
|
26
|
+
const answer = await inquirer.prompt([
|
|
27
|
+
{
|
|
28
|
+
type: "confirm",
|
|
29
|
+
name: "confirm",
|
|
30
|
+
message,
|
|
31
|
+
},
|
|
32
|
+
]);
|
|
33
|
+
return answer.confirm;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const DEFAULT_PAGE_SIZE = -1; // -1 means return all records
|
|
37
|
+
export const DEFAULT_PAGE = 1;
|
|
38
|
+
export const MAX_PAGE_SIZE = 500;
|
|
39
|
+
|
|
40
|
+
export interface PaginationOptions {
|
|
41
|
+
page?: number;
|
|
42
|
+
pageSize?: number;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function parsePaginationParams(
|
|
46
|
+
page?: string | number,
|
|
47
|
+
pageSize?: string | number,
|
|
48
|
+
): { limit: number; offset: number } {
|
|
49
|
+
// If no page AND no pageSize specified, return all records
|
|
50
|
+
if (page === undefined && pageSize === undefined) {
|
|
51
|
+
logger.info("--page-size not passed, returning all records");
|
|
52
|
+
return { limit: -1, offset: 0 };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Parse pageSize
|
|
56
|
+
const parsedPageSize =
|
|
57
|
+
typeof pageSize === "string" ? parseInt(pageSize, 10) : pageSize;
|
|
58
|
+
|
|
59
|
+
// If pageSize is explicitly -1, return all records
|
|
60
|
+
if (parsedPageSize === -1) {
|
|
61
|
+
return { limit: -1, offset: 0 };
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// If page OR pageSize is provided, use pagination
|
|
65
|
+
// Default pageSize to 100 when page is provided but pageSize is not
|
|
66
|
+
const effectivePageSize =
|
|
67
|
+
parsedPageSize !== undefined && !isNaN(parsedPageSize)
|
|
68
|
+
? parsedPageSize
|
|
69
|
+
: page !== undefined
|
|
70
|
+
? 100
|
|
71
|
+
: DEFAULT_PAGE_SIZE;
|
|
72
|
+
|
|
73
|
+
// If we still have -1 (shouldn't happen, but safety check), return all
|
|
74
|
+
if (effectivePageSize === -1) {
|
|
75
|
+
return { limit: -1, offset: 0 };
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Use pagination logic
|
|
79
|
+
const parsedPage =
|
|
80
|
+
typeof page === "string" ? parseInt(page, 10) : page || DEFAULT_PAGE;
|
|
81
|
+
const validPage = Math.max(1, isNaN(parsedPage) ? DEFAULT_PAGE : parsedPage);
|
|
82
|
+
|
|
83
|
+
const validPageSize = Math.min(
|
|
84
|
+
Math.max(1, effectivePageSize),
|
|
85
|
+
MAX_PAGE_SIZE,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const offset = (validPage - 1) * validPageSize;
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
limit: validPageSize,
|
|
92
|
+
offset: offset,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function extractTotalCount(headers: unknown): number | undefined {
|
|
97
|
+
if (!headers || typeof headers !== "object") {
|
|
98
|
+
return undefined;
|
|
99
|
+
}
|
|
100
|
+
const h = headers as Record<string, unknown>;
|
|
101
|
+
const candidates = [h["x-total-count"], h["Total-Count"], h["total-count"]];
|
|
102
|
+
for (const totalCountHeader of candidates) {
|
|
103
|
+
if (totalCountHeader == null) {
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const raw = Array.isArray(totalCountHeader)
|
|
107
|
+
? totalCountHeader[0]
|
|
108
|
+
: totalCountHeader;
|
|
109
|
+
const count = parseInt(String(raw), 10);
|
|
110
|
+
if (!isNaN(count)) {
|
|
111
|
+
return count;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { expect } from "chai";
|
|
2
|
+
import { validatePath, PathType, validateManifest } from "./validator";
|
|
3
|
+
|
|
4
|
+
describe("validator", () => {
|
|
5
|
+
describe("validatePath", () => {
|
|
6
|
+
it("should return PathType.Invalid for a path not starting with '/'", () => {
|
|
7
|
+
expect(validatePath("invalidPath")).to.equal(PathType.Invalid);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
it("should return PathType.Root for '/'", () => {
|
|
11
|
+
expect(validatePath("/")).to.equal(PathType.Root);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it("should return PathType.Package for a valid package path", () => {
|
|
15
|
+
expect(validatePath("/package123")).to.equal(PathType.Package);
|
|
16
|
+
expect(validatePath("/abc-def")).to.equal(PathType.Package);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it("should return PathType.Invalid for a package path with invalid characters", () => {
|
|
20
|
+
expect(validatePath("/package@123")).to.equal(PathType.Invalid);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it("should return PathType.Version for a valid package and version path", () => {
|
|
24
|
+
expect(validatePath("/package123/1.0.0")).to.equal(PathType.Version);
|
|
25
|
+
expect(validatePath("/abc-def/2.3.4")).to.equal(PathType.Version);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("should return PathType.Invalid for a version path with invalid characters", () => {
|
|
29
|
+
expect(validatePath("/package123/1.0.0-beta")).to.equal(
|
|
30
|
+
PathType.Invalid,
|
|
31
|
+
);
|
|
32
|
+
expect(validatePath("/abc-def/2.3.4!")).to.equal(PathType.Invalid);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it("should return PathType.Invalid for a path with too many segments", () => {
|
|
36
|
+
expect(validatePath("/package123/1.0.0/extra")).to.equal(
|
|
37
|
+
PathType.Invalid,
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe("validateManifest", () => {
|
|
43
|
+
it("should return true if manifest validation passes", () => {
|
|
44
|
+
expect(validateManifest()).to.be.true;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
// it("should log an error and return false if manifest validation fails", () => {
|
|
48
|
+
// expect(validateManifest()).to.be.false;
|
|
49
|
+
// });
|
|
50
|
+
});
|
|
51
|
+
});
|
package/src/validator.ts
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { logger } from "./logger";
|
|
2
|
+
|
|
3
|
+
const idRegex = new RegExp("^[a-zA-Z0-9\\-]+$");
|
|
4
|
+
const versionRegex = new RegExp("^[a-zA-Z0-9\\.]+$");
|
|
5
|
+
export enum PathType {
|
|
6
|
+
Root,
|
|
7
|
+
Package,
|
|
8
|
+
Version,
|
|
9
|
+
Invalid,
|
|
10
|
+
}
|
|
11
|
+
export function validatePath(path: string): PathType {
|
|
12
|
+
if (!path.startsWith("/")) {
|
|
13
|
+
return PathType.Invalid;
|
|
14
|
+
}
|
|
15
|
+
const pathParts = path.split("/");
|
|
16
|
+
if (pathParts.length === 2 && !pathParts[1]) {
|
|
17
|
+
return PathType.Root;
|
|
18
|
+
} else if (pathParts.length === 2 && idRegex.test(pathParts[1])) {
|
|
19
|
+
return PathType.Package;
|
|
20
|
+
} else if (
|
|
21
|
+
pathParts.length === 3 &&
|
|
22
|
+
idRegex.test(pathParts[1]) &&
|
|
23
|
+
versionRegex.test(pathParts[2])
|
|
24
|
+
) {
|
|
25
|
+
return PathType.Version;
|
|
26
|
+
} else {
|
|
27
|
+
return PathType.Invalid;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function validateManifest(): boolean {
|
|
32
|
+
try {
|
|
33
|
+
// const packageManifestJson = fs.readFileSync("malloy-package.json");
|
|
34
|
+
// const packageManifest = JSON.parse(packageManifestJson.toString());
|
|
35
|
+
// TODO: Validate packageManigfest.
|
|
36
|
+
return true;
|
|
37
|
+
} catch (error) {
|
|
38
|
+
let message;
|
|
39
|
+
if (error instanceof Error) message = error.message;
|
|
40
|
+
else message = String(error);
|
|
41
|
+
logger.error("Unable to open and parse manifest: " + message);
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "dist",
|
|
4
|
+
"rootDir": "src",
|
|
5
|
+
"strict": false,
|
|
6
|
+
"target": "es6",
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
"sourceMap": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"moduleResolution": "node",
|
|
11
|
+
"resolveJsonModule": true,
|
|
12
|
+
"skipLibCheck": true,
|
|
13
|
+
"typeRoots": ["./node_modules/@types"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["src/**/*"],
|
|
16
|
+
"exclude": ["node_modules", "dist"]
|
|
17
|
+
}
|