@takeshape/cli 7.194.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/README.md +9 -0
- package/lib/auth.d.ts +5 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +76 -0
- package/lib/check-version.d.ts +2 -0
- package/lib/check-version.d.ts.map +1 -0
- package/lib/check-version.js +22 -0
- package/lib/commands/build-or-watch.d.ts +4 -0
- package/lib/commands/build-or-watch.d.ts.map +1 -0
- package/lib/commands/build-or-watch.js +69 -0
- package/lib/commands/deploy/index.d.ts +9 -0
- package/lib/commands/deploy/index.d.ts.map +1 -0
- package/lib/commands/deploy/index.js +74 -0
- package/lib/commands/deploy/zip.d.ts +18 -0
- package/lib/commands/deploy/zip.d.ts.map +1 -0
- package/lib/commands/deploy/zip.js +57 -0
- package/lib/commands/export/index.d.ts +6 -0
- package/lib/commands/export/index.d.ts.map +1 -0
- package/lib/commands/export/index.js +23 -0
- package/lib/commands/export/project-export.d.ts +13 -0
- package/lib/commands/export/project-export.d.ts.map +1 -0
- package/lib/commands/export/project-export.js +104 -0
- package/lib/commands/export/schema-export.d.ts +7 -0
- package/lib/commands/export/schema-export.d.ts.map +1 -0
- package/lib/commands/export/schema-export.js +80 -0
- package/lib/commands/import/index.d.ts +6 -0
- package/lib/commands/import/index.d.ts.map +1 -0
- package/lib/commands/import/index.js +23 -0
- package/lib/commands/import/project-import.d.ts +16 -0
- package/lib/commands/import/project-import.d.ts.map +1 -0
- package/lib/commands/import/project-import.js +167 -0
- package/lib/commands/import/schema-import.d.ts +7 -0
- package/lib/commands/import/schema-import.d.ts.map +1 -0
- package/lib/commands/import/schema-import.js +75 -0
- package/lib/commands/link.d.ts +3 -0
- package/lib/commands/link.d.ts.map +1 -0
- package/lib/commands/link.js +61 -0
- package/lib/commands/login.d.ts +4 -0
- package/lib/commands/login.d.ts.map +1 -0
- package/lib/commands/login.js +31 -0
- package/lib/commands/logout.d.ts +4 -0
- package/lib/commands/logout.d.ts.map +1 -0
- package/lib/commands/logout.js +29 -0
- package/lib/commands/schema.d.ts +3 -0
- package/lib/commands/schema.d.ts.map +1 -0
- package/lib/commands/schema.js +23 -0
- package/lib/commands/status.d.ts +3 -0
- package/lib/commands/status.d.ts.map +1 -0
- package/lib/commands/status.js +20 -0
- package/lib/commands/unlink.d.ts +4 -0
- package/lib/commands/unlink.d.ts.map +1 -0
- package/lib/commands/unlink.js +29 -0
- package/lib/config.d.ts +14 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +161 -0
- package/lib/deprecated.d.ts +2 -0
- package/lib/deprecated.d.ts.map +1 -0
- package/lib/deprecated.js +9 -0
- package/lib/errors.d.ts +7 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +36 -0
- package/lib/files.d.ts +5 -0
- package/lib/files.d.ts.map +1 -0
- package/lib/files.js +53 -0
- package/lib/graphql.d.ts +14 -0
- package/lib/graphql.d.ts.map +1 -0
- package/lib/graphql.js +94 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +78 -0
- package/lib/log.d.ts +4 -0
- package/lib/log.d.ts.map +1 -0
- package/lib/log.js +21 -0
- package/lib/main.d.ts +2 -0
- package/lib/main.d.ts.map +1 -0
- package/lib/main.js +36 -0
- package/lib/prompt.d.ts +11 -0
- package/lib/prompt.d.ts.map +1 -0
- package/lib/prompt.js +39 -0
- package/lib/types.d.ts +45 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +20 -0
- package/lib/util/api.d.ts +5 -0
- package/lib/util/api.d.ts.map +1 -0
- package/lib/util/api.js +66 -0
- package/lib/util/cached-connector.d.ts +5 -0
- package/lib/util/cached-connector.d.ts.map +1 -0
- package/lib/util/cached-connector.js +34 -0
- package/lib/util/connector.d.ts +7 -0
- package/lib/util/connector.d.ts.map +1 -0
- package/lib/util/connector.js +19 -0
- package/lib/util/data.d.ts +38 -0
- package/lib/util/data.d.ts.map +1 -0
- package/lib/util/data.js +156 -0
- package/lib/util/fatal-error.d.ts +2 -0
- package/lib/util/fatal-error.d.ts.map +1 -0
- package/lib/util/fatal-error.js +17 -0
- package/lib/util/format-error.d.ts +2 -0
- package/lib/util/format-error.d.ts.map +1 -0
- package/lib/util/format-error.js +10 -0
- package/lib/util/get-client-schema.d.ts +4 -0
- package/lib/util/get-client-schema.d.ts.map +1 -0
- package/lib/util/get-client-schema.js +28 -0
- package/lib/util/glitch.d.ts +5 -0
- package/lib/util/glitch.d.ts.map +1 -0
- package/lib/util/glitch.js +51 -0
- package/lib/util/linked-command.d.ts +4 -0
- package/lib/util/linked-command.d.ts.map +1 -0
- package/lib/util/linked-command.js +33 -0
- package/lib/util/login.d.ts +16 -0
- package/lib/util/login.d.ts.map +1 -0
- package/lib/util/login.js +123 -0
- package/lib/util/messages.d.ts +13 -0
- package/lib/util/messages.d.ts.map +1 -0
- package/lib/util/messages.js +57 -0
- package/lib/util/ora-wrapper.d.ts +2 -0
- package/lib/util/ora-wrapper.d.ts.map +1 -0
- package/lib/util/ora-wrapper.js +28 -0
- package/lib/util/pusher.d.ts +4 -0
- package/lib/util/pusher.d.ts.map +1 -0
- package/lib/util/pusher.js +45 -0
- package/lib/util/runner.d.ts +2 -0
- package/lib/util/runner.d.ts.map +1 -0
- package/lib/util/runner.js +44 -0
- package/lib/util/select-project.d.ts +4 -0
- package/lib/util/select-project.d.ts.map +1 -0
- package/lib/util/select-project.js +23 -0
- package/lib/util/spin.d.ts +7 -0
- package/lib/util/spin.d.ts.map +1 -0
- package/lib/util/spin.js +41 -0
- package/lib/util/upload.d.ts +5 -0
- package/lib/util/upload.d.ts.map +1 -0
- package/lib/util/upload.js +55 -0
- package/lib/util/watcher.d.ts +2 -0
- package/lib/util/watcher.d.ts.map +1 -0
- package/lib/util/watcher.js +30 -0
- package/package.json +90 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[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MAAM,CAAC;CACtB;AAED,oBAAY,uBAAuB,GAAG,iBAAiB,GAAG,eAAe,CAAC;AAE1E,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,IAAI,eAAe,CAEpF;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,IAAI,iBAAiB,CAExF;AAED,wBAAgB,yBAAyB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,IAAI,uBAAuB,CAEpG;AAED,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,GAAG,CAAC;IACV,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,oBAAY,MAAM,GAAG,CAAC,MAAM,EAAE,oBAAoB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC"}
|
package/lib/types.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isLinkedCliConfig = isLinkedCliConfig;
|
|
7
|
+
exports.isLoggedInCliConfig = isLoggedInCliConfig;
|
|
8
|
+
exports.isLoggedInAndLinkedConfig = isLoggedInAndLinkedConfig;
|
|
9
|
+
|
|
10
|
+
function isLinkedCliConfig(cliConfig) {
|
|
11
|
+
return cliConfig.projectId !== undefined && cliConfig.linkedApiKey !== undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function isLoggedInCliConfig(cliConfig) {
|
|
15
|
+
return cliConfig.personalAccessTokenId !== undefined && cliConfig.authToken !== undefined;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isLoggedInAndLinkedConfig(cliConfig) {
|
|
19
|
+
return isLinkedCliConfig(cliConfig) && isLoggedInCliConfig(cliConfig);
|
|
20
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { CliConfig } from '../types';
|
|
2
|
+
export declare function isJWT(str: string): boolean;
|
|
3
|
+
export declare function getAuthHeader(authToken?: string): Record<string, string>;
|
|
4
|
+
export default function api<T = any>(params: CliConfig, method: string, path: string, body?: any): Promise<T>;
|
|
5
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/util/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAanC,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAG1C;AAED,wBAAgB,aAAa,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMxE;AAED,wBAA8B,GAAG,CAAC,CAAC,GAAG,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,CAqBlH"}
|
package/lib/util/api.js
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isJWT = isJWT;
|
|
7
|
+
exports.getAuthHeader = getAuthHeader;
|
|
8
|
+
exports.default = api;
|
|
9
|
+
|
|
10
|
+
var _nodeFetch = _interopRequireDefault(require("node-fetch"));
|
|
11
|
+
|
|
12
|
+
var _errors = require("../errors");
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
function isValidHeader(str) {
|
|
17
|
+
const json = Buffer.from(str, 'base64').toString('utf8');
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
const header = JSON.parse(json);
|
|
21
|
+
return header.typ === 'JWT';
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function isJWT(str) {
|
|
28
|
+
const parts = str.split('.');
|
|
29
|
+
return parts.length === 3 && isValidHeader(parts[0]);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function getAuthHeader(authToken) {
|
|
33
|
+
if (!authToken) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return isJWT(authToken) ? {
|
|
38
|
+
'X-TakeShape-Token': authToken
|
|
39
|
+
} : {
|
|
40
|
+
Authorization: `Bearer ${authToken}`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function api(params, method, path, body) {
|
|
45
|
+
var _params$authToken, _params$linkedApiKey;
|
|
46
|
+
|
|
47
|
+
const requestParams = {
|
|
48
|
+
method,
|
|
49
|
+
headers: { ...getAuthHeader((_params$authToken = params.authToken) !== null && _params$authToken !== void 0 ? _params$authToken : (_params$linkedApiKey = params.linkedApiKey) === null || _params$linkedApiKey === void 0 ? void 0 : _params$linkedApiKey.apiKey),
|
|
50
|
+
'Content-Type': 'application/json'
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
if (body) {
|
|
55
|
+
requestParams.body = JSON.stringify(body);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const endpoint = `${params.endpoint}${path}`;
|
|
59
|
+
const res = await (0, _nodeFetch.default)(endpoint, requestParams);
|
|
60
|
+
|
|
61
|
+
if (res.ok) {
|
|
62
|
+
return res.json();
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
throw new _errors.HTTPError(`${res.statusText}`, res.status);
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cached-connector.d.ts","sourceRoot":"","sources":["../../../src/util/cached-connector.js"],"names":[],"mappings":"AAMA;;;EAeC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.connectorWithCache = connectorWithCache;
|
|
7
|
+
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
|
|
10
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
11
|
+
|
|
12
|
+
var _objectHash = _interopRequireDefault(require("object-hash"));
|
|
13
|
+
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
16
|
+
const cacheDir = '.cache';
|
|
17
|
+
|
|
18
|
+
function connectorWithCache(connector) {
|
|
19
|
+
const decorated = async params => {
|
|
20
|
+
const cachePath = _path.default.join(cacheDir, `${(0, _objectHash.default)(params)}.json`);
|
|
21
|
+
|
|
22
|
+
if (await _fsExtra.default.pathExists(cachePath)) {
|
|
23
|
+
return _fsExtra.default.readJSON(cachePath);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const [result] = await Promise.all([connector(params), _fsExtra.default.mkdirs(cacheDir)]);
|
|
27
|
+
await _fsExtra.default.writeJSON(cachePath, result);
|
|
28
|
+
return result;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
decorated.clearCache = async () => _fsExtra.default.remove(cacheDir);
|
|
32
|
+
|
|
33
|
+
return decorated;
|
|
34
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { GraphQLConnectorOptions } from '../graphql';
|
|
2
|
+
import { LinkedCliConfig } from '../types';
|
|
3
|
+
export declare function createConnector(params: LinkedCliConfig, options?: GraphQLConnectorOptions): import("../../../ssg/src/types").GraphQLConnector | {
|
|
4
|
+
(params: any): Promise<any>;
|
|
5
|
+
clearCache(): Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=connector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"connector.d.ts","sourceRoot":"","sources":["../../../src/util/connector.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,uBAAuB,EAAC,MAAM,YAAY,CAAC;AAE3F,OAAO,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAEzC,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,uBAAuB;;;EAKzF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createConnector = createConnector;
|
|
7
|
+
|
|
8
|
+
var _ssg = require("@takeshape/ssg");
|
|
9
|
+
|
|
10
|
+
var _graphql = require("../graphql");
|
|
11
|
+
|
|
12
|
+
var _cachedConnector = require("./cached-connector");
|
|
13
|
+
|
|
14
|
+
function createConnector(params, options) {
|
|
15
|
+
var _params$linkedApiKey;
|
|
16
|
+
|
|
17
|
+
const connector = (0, _ssg.connectorWithMigrations)((0, _graphql.createConnector)(params, (_params$linkedApiKey = params.linkedApiKey) === null || _params$linkedApiKey === void 0 ? void 0 : _params$linkedApiKey.apiKey, params.projectId, options));
|
|
18
|
+
return options !== null && options !== void 0 && options.cache ? (0, _cachedConnector.connectorWithCache)(connector) : connector;
|
|
19
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LoggedInCliConfig, CliConfig } from '../types';
|
|
2
|
+
import { Choice } from '../prompt';
|
|
3
|
+
export declare const projectListQuery = "\n {\n projects: tsGetProjectList {\n value: id\n name\n invite\n }\n }\n";
|
|
4
|
+
export declare const siteListQuery = "\n {\n sites: getTsStaticSiteList {\n items {\n value: _id\n name: title\n }\n }\n }\n";
|
|
5
|
+
export interface ProjectChoice extends Choice {
|
|
6
|
+
invite: unknown;
|
|
7
|
+
}
|
|
8
|
+
export declare function fetchProjects(params: LoggedInCliConfig): Promise<Choice[]>;
|
|
9
|
+
export declare const laterSite: {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function fetchSites(params: LoggedInCliConfig, projectId: string): Promise<Choice[]>;
|
|
14
|
+
export interface PersonalAccessToken {
|
|
15
|
+
accessToken: string;
|
|
16
|
+
id: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ApiKey {
|
|
19
|
+
id: string;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
}
|
|
22
|
+
export declare const createPersonalAccessTokenMutation: (client: import("../types").Client, variables: {
|
|
23
|
+
name: string;
|
|
24
|
+
}) => Promise<PersonalAccessToken>;
|
|
25
|
+
export declare const createReadOnlyApiKeyMutation: (client: import("../types").Client, variables: {
|
|
26
|
+
name: string;
|
|
27
|
+
}) => Promise<ApiKey>;
|
|
28
|
+
export declare const deletePersonalAccessTokenMutation: (client: import("../types").Client, variables: {
|
|
29
|
+
id: string;
|
|
30
|
+
}) => Promise<boolean>;
|
|
31
|
+
export declare const deleteApiKeyMutation: (client: import("../types").Client, variables: {
|
|
32
|
+
id: string;
|
|
33
|
+
}) => Promise<boolean>;
|
|
34
|
+
export declare function createPersonalAccessToken(params: CliConfig, userJwt: string): Promise<PersonalAccessToken>;
|
|
35
|
+
export declare function deletePersonalAccessToken(params: LoggedInCliConfig): Promise<boolean>;
|
|
36
|
+
export declare function createReadOnlyApiKey(params: LoggedInCliConfig, projectId: string): Promise<ApiKey>;
|
|
37
|
+
export declare function deleteApiKey(params: LoggedInCliConfig, projectId: string, apiKeyId: string): Promise<boolean>;
|
|
38
|
+
//# sourceMappingURL=data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":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Y,CAAC,MAAM,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,oBAOhG"}
|
package/lib/util/data.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fetchProjects = fetchProjects;
|
|
7
|
+
exports.fetchSites = fetchSites;
|
|
8
|
+
exports.createPersonalAccessToken = createPersonalAccessToken;
|
|
9
|
+
exports.deletePersonalAccessToken = deletePersonalAccessToken;
|
|
10
|
+
exports.createReadOnlyApiKey = createReadOnlyApiKey;
|
|
11
|
+
exports.deleteApiKey = deleteApiKey;
|
|
12
|
+
exports.deleteApiKeyMutation = exports.deletePersonalAccessTokenMutation = exports.createReadOnlyApiKeyMutation = exports.createPersonalAccessTokenMutation = exports.laterSite = exports.siteListQuery = exports.projectListQuery = void 0;
|
|
13
|
+
|
|
14
|
+
var _graphql = require("../graphql");
|
|
15
|
+
|
|
16
|
+
var _errors = require("../errors");
|
|
17
|
+
|
|
18
|
+
var _os = _interopRequireDefault(require("os"));
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
22
|
+
const projectListQuery = `
|
|
23
|
+
{
|
|
24
|
+
projects: tsGetProjectList {
|
|
25
|
+
value: id
|
|
26
|
+
name
|
|
27
|
+
invite
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
exports.projectListQuery = projectListQuery;
|
|
32
|
+
const siteListQuery = `
|
|
33
|
+
{
|
|
34
|
+
sites: getTsStaticSiteList {
|
|
35
|
+
items {
|
|
36
|
+
value: _id
|
|
37
|
+
name: title
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
exports.siteListQuery = siteListQuery;
|
|
43
|
+
|
|
44
|
+
async function fetchProjects(params) {
|
|
45
|
+
try {
|
|
46
|
+
const client = (0, _graphql.createAdminConnector)(params, params.authToken);
|
|
47
|
+
const {
|
|
48
|
+
data
|
|
49
|
+
} = await client({
|
|
50
|
+
query: projectListQuery
|
|
51
|
+
});
|
|
52
|
+
return data.projects.filter(p => (p === null || p === void 0 ? void 0 : p.invite) === null);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
throw (0, _errors.formatErrorMessage)(e, 'fetching your projects');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const laterSite = {
|
|
59
|
+
name: 'Select site later',
|
|
60
|
+
value: 'NONE'
|
|
61
|
+
};
|
|
62
|
+
exports.laterSite = laterSite;
|
|
63
|
+
|
|
64
|
+
async function fetchSites(params, projectId) {
|
|
65
|
+
try {
|
|
66
|
+
const client = (0, _graphql.createConnector)(params, params.authToken, projectId);
|
|
67
|
+
const {
|
|
68
|
+
data
|
|
69
|
+
} = await client({
|
|
70
|
+
query: siteListQuery
|
|
71
|
+
});
|
|
72
|
+
const sites = data.sites.items;
|
|
73
|
+
return sites.length ? sites.concat([laterSite]) : sites;
|
|
74
|
+
} catch (e) {
|
|
75
|
+
throw (0, _errors.formatErrorMessage)(e, 'fetching your static sites');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const createPersonalAccessTokenMutation = (0, _graphql.graphQLQuery)(`
|
|
80
|
+
mutation ($name: String!){
|
|
81
|
+
result: tsCreatePersonalAccessToken(name: $name) {
|
|
82
|
+
accessToken
|
|
83
|
+
id
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
`);
|
|
87
|
+
exports.createPersonalAccessTokenMutation = createPersonalAccessTokenMutation;
|
|
88
|
+
const createReadOnlyApiKeyMutation = (0, _graphql.graphQLQuery)(`
|
|
89
|
+
mutation ($name: String!){
|
|
90
|
+
result: tsCreateApiKey(name: $name role: "read") {
|
|
91
|
+
id
|
|
92
|
+
apiKey
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
`);
|
|
96
|
+
exports.createReadOnlyApiKeyMutation = createReadOnlyApiKeyMutation;
|
|
97
|
+
const deletePersonalAccessTokenMutation = (0, _graphql.graphQLQuery)(`
|
|
98
|
+
mutation ($id: ID!){
|
|
99
|
+
result: tsDeletePersonalAccessToken(id: $id)
|
|
100
|
+
}
|
|
101
|
+
`);
|
|
102
|
+
exports.deletePersonalAccessTokenMutation = deletePersonalAccessTokenMutation;
|
|
103
|
+
const deleteApiKeyMutation = (0, _graphql.graphQLQuery)(`
|
|
104
|
+
mutation ($id: ID!){
|
|
105
|
+
result: tsDeleteApiKey(id: $id)
|
|
106
|
+
}
|
|
107
|
+
`);
|
|
108
|
+
exports.deleteApiKeyMutation = deleteApiKeyMutation;
|
|
109
|
+
|
|
110
|
+
function createKeyName() {
|
|
111
|
+
return `TakeShape CLI ${_os.default.hostname()} ${new Date().toISOString().split('T')[0]}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function createPersonalAccessToken(params, userJwt) {
|
|
115
|
+
try {
|
|
116
|
+
const client = (0, _graphql.createAdminConnector)(params, userJwt);
|
|
117
|
+
return await createPersonalAccessTokenMutation(client, {
|
|
118
|
+
name: createKeyName()
|
|
119
|
+
});
|
|
120
|
+
} catch (e) {
|
|
121
|
+
throw (0, _errors.formatErrorMessage)(e, 'creating your personal access token');
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
async function deletePersonalAccessToken(params) {
|
|
126
|
+
try {
|
|
127
|
+
const client = (0, _graphql.createAdminConnector)(params, params.authToken);
|
|
128
|
+
return await deletePersonalAccessTokenMutation(client, {
|
|
129
|
+
id: params.personalAccessTokenId
|
|
130
|
+
});
|
|
131
|
+
} catch (e) {
|
|
132
|
+
throw (0, _errors.formatErrorMessage)(e, 'deleting your personal access token');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
async function createReadOnlyApiKey(params, projectId) {
|
|
137
|
+
try {
|
|
138
|
+
const client = (0, _graphql.createAdminConnector)(params, params.authToken, projectId);
|
|
139
|
+
return await createReadOnlyApiKeyMutation(client, {
|
|
140
|
+
name: createKeyName()
|
|
141
|
+
});
|
|
142
|
+
} catch (e) {
|
|
143
|
+
throw (0, _errors.formatErrorMessage)(e, 'creating your read-only api key');
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async function deleteApiKey(params, projectId, apiKeyId) {
|
|
148
|
+
try {
|
|
149
|
+
const client = (0, _graphql.createAdminConnector)(params, params.authToken, projectId);
|
|
150
|
+
return await deleteApiKeyMutation(client, {
|
|
151
|
+
id: apiKeyId
|
|
152
|
+
});
|
|
153
|
+
} catch (e) {
|
|
154
|
+
throw (0, _errors.formatErrorMessage)(e, 'deleting your api key');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fatal-error.d.ts","sourceRoot":"","sources":["../../../src/util/fatal-error.ts"],"names":[],"mappings":"AAGA,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,CAGjD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fatalError = fatalError;
|
|
7
|
+
|
|
8
|
+
var _log = _interopRequireDefault(require("../log"));
|
|
9
|
+
|
|
10
|
+
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
+
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
|
|
14
|
+
function fatalError(message) {
|
|
15
|
+
(0, _log.default)(_chalk.default.red('Error'), message);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-error.d.ts","sourceRoot":"","sources":["../../../src/util/format-error.js"],"names":[],"mappings":"AAAA,qDAEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-client-schema.d.ts","sourceRoot":"","sources":["../../../src/util/get-client-schema.js"],"names":[],"mappings":"AAIA,+DAMC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getClientSchema = getClientSchema;
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
|
|
9
|
+
var _graphql = require("graphql");
|
|
10
|
+
|
|
11
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
12
|
+
|
|
13
|
+
var _oraWrapper = _interopRequireDefault(require("./ora-wrapper"));
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
+
|
|
17
|
+
async function getClientSchema(connector) {
|
|
18
|
+
const res = await connector({
|
|
19
|
+
query: _graphql.introspectionQuery
|
|
20
|
+
});
|
|
21
|
+
const schema = (0, _graphql.buildClientSchema)(res.data);
|
|
22
|
+
const result = (0, _graphql.printSchema)(schema);
|
|
23
|
+
await _fsExtra.default.writeFile('takeshape-project.graphql', result);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var _default = (0, _oraWrapper.default)(getClientSchema, 'Getting client schema.', 'Client schema saved as takeshape-project.graphql.', 'Failed while getting client schema.');
|
|
27
|
+
|
|
28
|
+
exports.default = _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"glitch.d.ts","sourceRoot":"","sources":["../../../src/util/glitch.js"],"names":[],"mappings":"AAKA,oCAEC;AAMD,2CAMC;AAED,qDAEC;AAED,kFAUC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isGlitch = isGlitch;
|
|
7
|
+
exports.readDotEnv = readDotEnv;
|
|
8
|
+
exports.writeDotEnv = writeDotEnv;
|
|
9
|
+
exports.updateEnv = updateEnv;
|
|
10
|
+
|
|
11
|
+
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
12
|
+
|
|
13
|
+
var _dotenvStringify = _interopRequireDefault(require("dotenv-stringify"));
|
|
14
|
+
|
|
15
|
+
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
16
|
+
|
|
17
|
+
var _path = _interopRequireDefault(require("path"));
|
|
18
|
+
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
|
|
21
|
+
function isGlitch() {
|
|
22
|
+
return Boolean(process.env.GLITCH) || Boolean(process.env.PROJECT_REMIX_CHAIN);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getEnvPath() {
|
|
26
|
+
return _path.default.resolve(process.cwd(), '.env');
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function readDotEnv() {
|
|
30
|
+
const path = getEnvPath();
|
|
31
|
+
|
|
32
|
+
if (_fsExtra.default.existsSync(path)) {
|
|
33
|
+
return _dotenv.default.parse(await _fsExtra.default.readFile(path));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return {};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function writeDotEnv(env) {
|
|
40
|
+
return _fsExtra.default.writeFile(getEnvPath(), (0, _dotenvStringify.default)(env));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
async function updateEnv(authToken, project, site = {}) {
|
|
44
|
+
const env = await readDotEnv();
|
|
45
|
+
env.TS_AUTH_TOKEN = authToken;
|
|
46
|
+
env.TS_PROJECT_ID = project.value;
|
|
47
|
+
env.TS_PROJECT_NAME = project.name;
|
|
48
|
+
env.TS_SITE_ID = site.value;
|
|
49
|
+
env.TS_SITE_NAME = site.name;
|
|
50
|
+
await writeDotEnv(env);
|
|
51
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AuthedHandler, Handler, LinkedHandler } from '../types';
|
|
2
|
+
export declare function linkedCommand<Flags>(handler: LinkedHandler<Flags>): Handler<Flags>;
|
|
3
|
+
export declare function loggedInCommand<Flags>(handler: AuthedHandler<Flags>): Handler<Flags>;
|
|
4
|
+
//# sourceMappingURL=linked-command.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"linked-command.d.ts","sourceRoot":"","sources":["../../../src/util/linked-command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAa,OAAO,EAA0C,aAAa,EAAC,MAAM,UAAU,CAAC;AAGlH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CASlF;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CASpF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.linkedCommand = linkedCommand;
|
|
7
|
+
exports.loggedInCommand = loggedInCommand;
|
|
8
|
+
|
|
9
|
+
var _types = require("../types");
|
|
10
|
+
|
|
11
|
+
var _log = require("../log");
|
|
12
|
+
|
|
13
|
+
function linkedCommand(handler) {
|
|
14
|
+
return async (command, params, flags) => {
|
|
15
|
+
if (!(0, _types.isLinkedCliConfig)(params)) {
|
|
16
|
+
(0, _log.logError)('Error: Missing project information not initialized please run `takeshape link`.');
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return handler(command, params, flags);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function loggedInCommand(handler) {
|
|
25
|
+
return async (command, params, flags) => {
|
|
26
|
+
if (!(0, _types.isLoggedInCliConfig)(params)) {
|
|
27
|
+
(0, _log.logError)(`Error: You are not logged in to TakeShape. Please run 'takeshape login' to login.`);
|
|
28
|
+
process.exit(1);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return handler(command, params, flags);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CliConfig } from '../types';
|
|
2
|
+
export declare function loginBrowser(params: CliConfig): Promise<string>;
|
|
3
|
+
export declare const loginQuestions: ({
|
|
4
|
+
type: string;
|
|
5
|
+
name: string;
|
|
6
|
+
message: string;
|
|
7
|
+
validate(input: string): true | "Please enter a valid email";
|
|
8
|
+
} | {
|
|
9
|
+
type: string;
|
|
10
|
+
name: string;
|
|
11
|
+
message: string;
|
|
12
|
+
})[];
|
|
13
|
+
export declare function attemptLogin(params: CliConfig): Promise<string>;
|
|
14
|
+
export declare function attemptOpenForgotPassword(params: CliConfig): Promise<void>;
|
|
15
|
+
export declare function loginCli(params: CliConfig, maxAttempts: number): Promise<string | undefined>;
|
|
16
|
+
//# sourceMappingURL=login.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/util/login.ts"],"names":[],"mappings":"AAOA,OAAO,EAAC,SAAS,EAAC,MAAM,UAAU,CAAC;AAEnC,wBAAsB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAmCrE;AAED,eAAO,MAAM,cAAc;;;;oBAKP,MAAM;;;;;IASzB,CAAC;AAEF,wBAAsB,YAAY,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,MAAM,CAAC,CAGrE;AAED,wBAAsB,yBAAyB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAKhF;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAoBlG"}
|