@takeshape/cli 9.13.0 → 9.14.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/package.json +14 -9
- package/dist/auth.d.ts +0 -5
- package/dist/auth.d.ts.map +0 -1
- package/dist/auth.js +0 -76
- package/dist/check-version.d.ts +0 -2
- package/dist/check-version.d.ts.map +0 -1
- package/dist/check-version.js +0 -22
- package/dist/commands/branch/commands/create.d.ts +0 -2
- package/dist/commands/branch/commands/create.d.ts.map +0 -1
- package/dist/commands/branch/commands/create.js +0 -67
- package/dist/commands/branch/commands/delete.d.ts +0 -2
- package/dist/commands/branch/commands/delete.d.ts.map +0 -1
- package/dist/commands/branch/commands/delete.js +0 -58
- package/dist/commands/branch/commands/list.d.ts +0 -12
- package/dist/commands/branch/commands/list.d.ts.map +0 -1
- package/dist/commands/branch/commands/list.js +0 -54
- package/dist/commands/branch/commands/merge.d.ts +0 -2
- package/dist/commands/branch/commands/merge.d.ts.map +0 -1
- package/dist/commands/branch/commands/merge.js +0 -158
- package/dist/commands/branch/commands/promote.d.ts +0 -2
- package/dist/commands/branch/commands/promote.d.ts.map +0 -1
- package/dist/commands/branch/commands/promote.js +0 -50
- package/dist/commands/branch/commands/tag-version.d.ts +0 -2
- package/dist/commands/branch/commands/tag-version.d.ts.map +0 -1
- package/dist/commands/branch/commands/tag-version.js +0 -59
- package/dist/commands/branch/commands/url.d.ts +0 -3
- package/dist/commands/branch/commands/url.d.ts.map +0 -1
- package/dist/commands/branch/commands/url.js +0 -84
- package/dist/commands/branch/index.d.ts +0 -4
- package/dist/commands/branch/index.d.ts.map +0 -1
- package/dist/commands/branch/index.js +0 -47
- package/dist/commands/build-or-watch.d.ts +0 -4
- package/dist/commands/build-or-watch.d.ts.map +0 -1
- package/dist/commands/build-or-watch.js +0 -73
- package/dist/commands/deploy/index.d.ts +0 -9
- package/dist/commands/deploy/index.d.ts.map +0 -1
- package/dist/commands/deploy/index.js +0 -74
- package/dist/commands/deploy/zip.d.ts +0 -18
- package/dist/commands/deploy/zip.d.ts.map +0 -1
- package/dist/commands/deploy/zip.js +0 -57
- package/dist/commands/export/index.d.ts +0 -4
- package/dist/commands/export/index.d.ts.map +0 -1
- package/dist/commands/export/index.js +0 -23
- package/dist/commands/export/project-export.d.ts +0 -8
- package/dist/commands/export/project-export.d.ts.map +0 -1
- package/dist/commands/export/project-export.js +0 -109
- package/dist/commands/export/schema-export.d.ts +0 -3
- package/dist/commands/export/schema-export.d.ts.map +0 -1
- package/dist/commands/export/schema-export.js +0 -88
- package/dist/commands/import/index.d.ts +0 -4
- package/dist/commands/import/index.d.ts.map +0 -1
- package/dist/commands/import/index.js +0 -33
- package/dist/commands/import/project-import.d.ts +0 -11
- package/dist/commands/import/project-import.d.ts.map +0 -1
- package/dist/commands/import/project-import.js +0 -198
- package/dist/commands/import/roles-import.d.ts +0 -3
- package/dist/commands/import/roles-import.d.ts.map +0 -1
- package/dist/commands/import/roles-import.js +0 -59
- package/dist/commands/import/schema-import.d.ts +0 -3
- package/dist/commands/import/schema-import.d.ts.map +0 -1
- package/dist/commands/import/schema-import.js +0 -93
- package/dist/commands/link.d.ts +0 -3
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/link.js +0 -63
- package/dist/commands/login.d.ts +0 -4
- package/dist/commands/login.d.ts.map +0 -1
- package/dist/commands/login.js +0 -32
- package/dist/commands/logout.d.ts +0 -4
- package/dist/commands/logout.d.ts.map +0 -1
- package/dist/commands/logout.js +0 -30
- package/dist/commands/schema.d.ts +0 -3
- package/dist/commands/schema.d.ts.map +0 -1
- package/dist/commands/schema.js +0 -25
- package/dist/commands/status.d.ts +0 -3
- package/dist/commands/status.d.ts.map +0 -1
- package/dist/commands/status.js +0 -18
- package/dist/commands/types.d.ts +0 -3
- package/dist/commands/types.d.ts.map +0 -1
- package/dist/commands/types.js +0 -30
- package/dist/commands/unlink.d.ts +0 -4
- package/dist/commands/unlink.d.ts.map +0 -1
- package/dist/commands/unlink.js +0 -30
- package/dist/commands/validate.d.ts +0 -4
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/validate.js +0 -57
- package/dist/config.d.ts +0 -13
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -161
- package/dist/deprecated.d.ts +0 -2
- package/dist/deprecated.d.ts.map +0 -1
- package/dist/deprecated.js +0 -9
- package/dist/errors.d.ts +0 -7
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -36
- package/dist/files.d.ts +0 -4
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -56
- package/dist/graphql.d.ts +0 -22
- package/dist/graphql.d.ts.map +0 -1
- package/dist/graphql.js +0 -104
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -128
- package/dist/log.d.ts +0 -4
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js +0 -21
- package/dist/main.d.ts +0 -2
- package/dist/main.d.ts.map +0 -1
- package/dist/main.js +0 -40
- package/dist/options.d.ts +0 -102
- package/dist/options.d.ts.map +0 -1
- package/dist/options.js +0 -103
- package/dist/prompt.d.ts +0 -11
- package/dist/prompt.d.ts.map +0 -1
- package/dist/prompt.js +0 -39
- package/dist/types.d.ts +0 -47
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js +0 -20
- package/dist/util/api.d.ts +0 -5
- package/dist/util/api.d.ts.map +0 -1
- package/dist/util/api.js +0 -76
- package/dist/util/branches.d.ts +0 -18
- package/dist/util/branches.d.ts.map +0 -1
- package/dist/util/branches.js +0 -77
- package/dist/util/cached-connector.d.ts +0 -5
- package/dist/util/cached-connector.d.ts.map +0 -1
- package/dist/util/cached-connector.js +0 -34
- package/dist/util/connector.d.ts +0 -8
- package/dist/util/connector.d.ts.map +0 -1
- package/dist/util/connector.js +0 -19
- package/dist/util/data.d.ts +0 -39
- package/dist/util/data.d.ts.map +0 -1
- package/dist/util/data.js +0 -165
- package/dist/util/fatal-error.d.ts +0 -2
- package/dist/util/fatal-error.d.ts.map +0 -1
- package/dist/util/fatal-error.js +0 -17
- package/dist/util/format-error.d.ts +0 -2
- package/dist/util/format-error.d.ts.map +0 -1
- package/dist/util/format-error.js +0 -10
- package/dist/util/format-validation-result.d.ts +0 -3
- package/dist/util/format-validation-result.d.ts.map +0 -1
- package/dist/util/format-validation-result.js +0 -17
- package/dist/util/fs.d.ts +0 -5
- package/dist/util/fs.d.ts.map +0 -1
- package/dist/util/fs.js +0 -42
- package/dist/util/generate-types.d.ts +0 -5
- package/dist/util/generate-types.d.ts.map +0 -1
- package/dist/util/generate-types.js +0 -63
- package/dist/util/get-client-schema.d.ts +0 -5
- package/dist/util/get-client-schema.d.ts.map +0 -1
- package/dist/util/get-client-schema.js +0 -31
- package/dist/util/glitch.d.ts +0 -5
- package/dist/util/glitch.d.ts.map +0 -1
- package/dist/util/glitch.js +0 -51
- package/dist/util/linked-command.d.ts +0 -5
- package/dist/util/linked-command.d.ts.map +0 -1
- package/dist/util/linked-command.js +0 -48
- package/dist/util/login.d.ts +0 -21
- package/dist/util/login.d.ts.map +0 -1
- package/dist/util/login.js +0 -141
- package/dist/util/messages.d.ts +0 -13
- package/dist/util/messages.d.ts.map +0 -1
- package/dist/util/messages.js +0 -60
- package/dist/util/ora-wrapper.d.ts +0 -2
- package/dist/util/ora-wrapper.d.ts.map +0 -1
- package/dist/util/ora-wrapper.js +0 -28
- package/dist/util/pusher.d.ts +0 -10
- package/dist/util/pusher.d.ts.map +0 -1
- package/dist/util/pusher.js +0 -34
- package/dist/util/runner.d.ts +0 -2
- package/dist/util/runner.d.ts.map +0 -1
- package/dist/util/runner.js +0 -46
- package/dist/util/select-project.d.ts +0 -4
- package/dist/util/select-project.d.ts.map +0 -1
- package/dist/util/select-project.js +0 -23
- package/dist/util/spin.d.ts +0 -7
- package/dist/util/spin.d.ts.map +0 -1
- package/dist/util/spin.js +0 -41
- package/dist/util/upload.d.ts +0 -5
- package/dist/util/upload.d.ts.map +0 -1
- package/dist/util/upload.js +0 -55
- package/dist/util/watcher.d.ts +0 -2
- package/dist/util/watcher.d.ts.map +0 -1
- package/dist/util/watcher.js +0 -30
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _fatalError = require("../../util/fatal-error");
|
|
9
|
-
|
|
10
|
-
var _api = _interopRequireDefault(require("../../util/api"));
|
|
11
|
-
|
|
12
|
-
var _log = _interopRequireDefault(require("../../log"));
|
|
13
|
-
|
|
14
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
15
|
-
|
|
16
|
-
var _path = _interopRequireDefault(require("path"));
|
|
17
|
-
|
|
18
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
19
|
-
|
|
20
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
21
|
-
|
|
22
|
-
var _linkedCommand = require("../../util/linked-command");
|
|
23
|
-
|
|
24
|
-
var _selectProject = require("../../util/select-project");
|
|
25
|
-
|
|
26
|
-
var _branches = require("../../util/branches");
|
|
27
|
-
|
|
28
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
29
|
-
|
|
30
|
-
const DEFAULT_SCHEMA_FILE_NAME = 'schema.json';
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
takeshape export --schema --to ./path/to
|
|
34
|
-
|
|
35
|
-
Download your project's schema.
|
|
36
|
-
|
|
37
|
-
Options:
|
|
38
|
-
--to: the path to save the download or the full file path, defaults to current directory
|
|
39
|
-
*/
|
|
40
|
-
var _default = (0, _linkedCommand.loggedInCommand)(async (cli, params) => {
|
|
41
|
-
const {
|
|
42
|
-
flags
|
|
43
|
-
} = cli;
|
|
44
|
-
let {
|
|
45
|
-
projectId,
|
|
46
|
-
projectName
|
|
47
|
-
} = params;
|
|
48
|
-
const branchParams = (0, _branches.getBranchParams)(cli);
|
|
49
|
-
let outputPath;
|
|
50
|
-
|
|
51
|
-
if (flags.to) {
|
|
52
|
-
if (flags.to.endsWith('.json')) {
|
|
53
|
-
outputPath = flags.to;
|
|
54
|
-
} else {
|
|
55
|
-
await _fsExtra.default.ensureDir(flags.to);
|
|
56
|
-
outputPath = _path.default.join(flags.to, DEFAULT_SCHEMA_FILE_NAME);
|
|
57
|
-
}
|
|
58
|
-
} else {
|
|
59
|
-
outputPath = _path.default.join('.', DEFAULT_SCHEMA_FILE_NAME);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!projectId) {
|
|
63
|
-
const choice = await (0, _selectProject.selectProject)(params);
|
|
64
|
-
|
|
65
|
-
if (!choice) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
projectId = choice.value;
|
|
70
|
-
projectName = choice.name;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
try {
|
|
74
|
-
(0, _log.default)(`Downloading schema for project ${projectName}…\n`);
|
|
75
|
-
const schema = await (0, _api.default)(params, 'GET', `${(0, _branches.getBranchBasePath)(branchParams, projectId)}/schema`);
|
|
76
|
-
|
|
77
|
-
_fs.default.writeFileSync(outputPath, JSON.stringify(schema, null, 2), {
|
|
78
|
-
encoding: 'utf8'
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
(0, _log.default)(_chalk.default.green(`Success!`), `Schema version ${schema.version} written to ${outputPath}.`);
|
|
82
|
-
process.exit(0);
|
|
83
|
-
} catch (e) {
|
|
84
|
-
return (0, _fatalError.fatalError)(e.message);
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AAEpC,QAAA,MAAM,cAAc,EAAE,OAWrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _projectImport = _interopRequireDefault(require("./project-import"));
|
|
9
|
-
|
|
10
|
-
var _schemaImport = _interopRequireDefault(require("./schema-import"));
|
|
11
|
-
|
|
12
|
-
var _rolesImport = _interopRequireDefault(require("./roles-import"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const commandHandler = async (cli, params) => {
|
|
17
|
-
const {
|
|
18
|
-
flags
|
|
19
|
-
} = cli;
|
|
20
|
-
|
|
21
|
-
if (flags.schema) {
|
|
22
|
-
return (0, _schemaImport.default)(cli, params);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (flags.roles) {
|
|
26
|
-
return (0, _rolesImport.default)(cli, params);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return (0, _projectImport.default)(cli, params);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
var _default = commandHandler;
|
|
33
|
-
exports.default = _default;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
declare type ImportStrategy = 'uri' | 'zip' | 'dir';
|
|
2
|
-
export interface ProjectImport {
|
|
3
|
-
id: string;
|
|
4
|
-
status: string;
|
|
5
|
-
message: string;
|
|
6
|
-
projectId: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function determineImportStrategy(path: string): Promise<ImportStrategy>;
|
|
9
|
-
declare const _default: import("../../types").Handler;
|
|
10
|
-
export default _default;
|
|
11
|
-
//# sourceMappingURL=project-import.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"project-import.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/project-import.ts"],"names":[],"mappings":"AAaA,aAAK,cAAc,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;AAW5C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;CACnB;AA4BD,wBAAsB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAenF;;AAyCD,wBAmDG"}
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
exports.determineImportStrategy = determineImportStrategy;
|
|
8
|
-
|
|
9
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
10
|
-
|
|
11
|
-
var _path = require("path");
|
|
12
|
-
|
|
13
|
-
var _archiver = _interopRequireDefault(require("archiver"));
|
|
14
|
-
|
|
15
|
-
var _streams = require("@takeshape/streams");
|
|
16
|
-
|
|
17
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
18
|
-
|
|
19
|
-
var _log = _interopRequireDefault(require("../../log"));
|
|
20
|
-
|
|
21
|
-
var _upload = require("../../util/upload");
|
|
22
|
-
|
|
23
|
-
var _spin = _interopRequireDefault(require("../../util/spin"));
|
|
24
|
-
|
|
25
|
-
var _graphql = require("../../graphql");
|
|
26
|
-
|
|
27
|
-
var _fatalError = require("../../util/fatal-error");
|
|
28
|
-
|
|
29
|
-
var _linkedCommand = require("../../util/linked-command");
|
|
30
|
-
|
|
31
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
|
-
|
|
33
|
-
var TO;
|
|
34
|
-
|
|
35
|
-
(function (TO) {
|
|
36
|
-
TO["NEW_PROJECT"] = "new-project";
|
|
37
|
-
TO["CURRENT_PROJECT"] = "current-project";
|
|
38
|
-
})(TO || (TO = {}));
|
|
39
|
-
|
|
40
|
-
const startImport = (0, _graphql.graphQLQuery)(`
|
|
41
|
-
mutation ($uri: String!, $name: String, $projectId: String) {
|
|
42
|
-
result: tsImportProject(uri: $uri, name: $name, origin: "@takeshape/cli", projectId: $projectId)
|
|
43
|
-
}
|
|
44
|
-
`);
|
|
45
|
-
const getImport = (0, _graphql.graphQLQuery)(`
|
|
46
|
-
query ($importId: String!) {
|
|
47
|
-
result: tsGetProjectImport(id: $importId) {
|
|
48
|
-
id
|
|
49
|
-
status
|
|
50
|
-
message
|
|
51
|
-
projectId
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
`);
|
|
55
|
-
const getUploadUrl = (0, _graphql.graphQLQuery)(`
|
|
56
|
-
mutation ($filename: String!, $projectId: String) {
|
|
57
|
-
result: tsUploadProject(name: $filename, type: "application/zip", origin: "@takeshape/cli", projectId: $projectId) {
|
|
58
|
-
uri
|
|
59
|
-
importId
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
`);
|
|
63
|
-
|
|
64
|
-
async function determineImportStrategy(path) {
|
|
65
|
-
if (/^https?:\/\/.*/.exec(path) !== null) {
|
|
66
|
-
return 'uri';
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (/\.zip$/.exec(path) !== null) {
|
|
70
|
-
return 'zip';
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
await _fsExtra.default.access(path);
|
|
74
|
-
|
|
75
|
-
if (_fsExtra.default.statSync(path).isDirectory()) {
|
|
76
|
-
return 'dir';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
throw Error('Unrecognized import path provided. Please provide a URI, zip path, or directory path');
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function getTo(to) {
|
|
83
|
-
if (to === undefined) {
|
|
84
|
-
return TO.NEW_PROJECT;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
if (Object.values(TO).includes(to)) {
|
|
88
|
-
return to;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
throw new Error(`Invalid "to" param. Was ${to}, must be one of: ${Object.values(TO).join(', ')}`);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function listenForImportSuccess(client, importId) {
|
|
95
|
-
// Spin until we get a 'success' message or it throws an error
|
|
96
|
-
const spinQuery = getImport.bind(getImport, client, {
|
|
97
|
-
importId
|
|
98
|
-
});
|
|
99
|
-
await (0, _spin.default)(spinQuery); // Return the ID of the project created by the import
|
|
100
|
-
|
|
101
|
-
const {
|
|
102
|
-
projectId
|
|
103
|
-
} = await getImport(client, {
|
|
104
|
-
importId
|
|
105
|
-
});
|
|
106
|
-
return projectId;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
async function uploadZipFile(client, filename, filePath, projectId) {
|
|
110
|
-
const {
|
|
111
|
-
uri,
|
|
112
|
-
importId
|
|
113
|
-
} = await getUploadUrl(client, {
|
|
114
|
-
filename,
|
|
115
|
-
projectId
|
|
116
|
-
});
|
|
117
|
-
await (0, _upload.uploadFile)(filePath, uri);
|
|
118
|
-
return importId;
|
|
119
|
-
}
|
|
120
|
-
/*
|
|
121
|
-
Takeshape import --project
|
|
122
|
-
|
|
123
|
-
Import a project from a path or URL.
|
|
124
|
-
The user must be logged in.
|
|
125
|
-
|
|
126
|
-
Flags:
|
|
127
|
-
--from Either a URI, zip file, or directory to import
|
|
128
|
-
--name Provides a name for the newly imported project.
|
|
129
|
-
Otherwise, the import will use the name in the pattern.yml file.
|
|
130
|
-
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
var _default = (0, _linkedCommand.loggedInCommand)(async (cli, params) => {
|
|
134
|
-
const {
|
|
135
|
-
flags
|
|
136
|
-
} = cli; // We need to get a user token in order for the import to work
|
|
137
|
-
|
|
138
|
-
if (!flags || !flags.from) {
|
|
139
|
-
return (0, _fatalError.fatalError)('No flags provided.');
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
const client = (0, _graphql.createAdminConnector)(params, params.authToken);
|
|
143
|
-
|
|
144
|
-
try {
|
|
145
|
-
const {
|
|
146
|
-
from
|
|
147
|
-
} = flags;
|
|
148
|
-
const strategy = await determineImportStrategy(from);
|
|
149
|
-
const to = getTo(flags.to);
|
|
150
|
-
const projectId = to === TO.CURRENT_PROJECT ? params.projectId : undefined;
|
|
151
|
-
|
|
152
|
-
if (to === TO.CURRENT_PROJECT && projectId === undefined) {
|
|
153
|
-
throw new Error('Not currently linked to a project. Run `takeshape link` to link to a project.');
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
let importId;
|
|
157
|
-
|
|
158
|
-
if (strategy === 'dir') {
|
|
159
|
-
(0, _log.default)(`Zipping up ${from}…`);
|
|
160
|
-
const dirName = (0, _path.basename)(from);
|
|
161
|
-
const [zipPath] = (0, _upload.createTempFile)(`${dirName}.zip`);
|
|
162
|
-
|
|
163
|
-
const output = _fsExtra.default.createWriteStream(zipPath);
|
|
164
|
-
|
|
165
|
-
const archive = (0, _archiver.default)('zip');
|
|
166
|
-
archive.directory(from, false);
|
|
167
|
-
await archive.finalize();
|
|
168
|
-
await (0, _streams.pump)(archive, output);
|
|
169
|
-
(0, _log.default)(`Starting import from ${dirName}.zip…\n`);
|
|
170
|
-
importId = await uploadZipFile(client, `${dirName}.zip`, zipPath, projectId);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (strategy === 'zip') {
|
|
174
|
-
(0, _log.default)(`Starting import from ${from}…\n`);
|
|
175
|
-
const fileName = (0, _path.basename)(from);
|
|
176
|
-
importId = await uploadZipFile(client, fileName, from, projectId);
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (strategy === 'uri') {
|
|
180
|
-
(0, _log.default)(`Starting import from ${from}…\n`);
|
|
181
|
-
importId = await startImport(client, {
|
|
182
|
-
uri: from,
|
|
183
|
-
name: flags.name,
|
|
184
|
-
projectId
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
if (importId) {
|
|
189
|
-
const resultProjectId = await listenForImportSuccess(client, importId);
|
|
190
|
-
(0, _log.default)(_chalk.default.green(`Success!`), `${projectId ? 'Updated' : 'Created'} project ${resultProjectId} from import.`);
|
|
191
|
-
process.exit(0);
|
|
192
|
-
}
|
|
193
|
-
} catch (error) {
|
|
194
|
-
return (0, _fatalError.fatalError)(error.message);
|
|
195
|
-
}
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"roles-import.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/roles-import.ts"],"names":[],"mappings":";AAUA,wBAsBG"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _fatalError = require("../../util/fatal-error");
|
|
9
|
-
|
|
10
|
-
var _linkedCommand = require("../../util/linked-command");
|
|
11
|
-
|
|
12
|
-
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
13
|
-
|
|
14
|
-
var _log = require("../../log");
|
|
15
|
-
|
|
16
|
-
var _api = _interopRequireDefault(require("../../util/api"));
|
|
17
|
-
|
|
18
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
19
|
-
|
|
20
|
-
var _schema = require("@takeshape/schema");
|
|
21
|
-
|
|
22
|
-
var _fs = require("../../util/fs");
|
|
23
|
-
|
|
24
|
-
var _branches = require("../../util/branches");
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
var _default = (0, _linkedCommand.linkedCommand)(async (cli, params) => {
|
|
29
|
-
const {
|
|
30
|
-
flags
|
|
31
|
-
} = cli;
|
|
32
|
-
|
|
33
|
-
if (!flags.from) {
|
|
34
|
-
return (0, _fatalError.fatalError)('No roles file provided. Use `--from path/to/file` or `--from directory`.');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const {
|
|
38
|
-
exists,
|
|
39
|
-
file
|
|
40
|
-
} = (0, _fs.resolveFromFlag)(flags.from, 'roles.json');
|
|
41
|
-
|
|
42
|
-
if (!exists) {
|
|
43
|
-
return (0, _fatalError.fatalError)(`Roles file does not exist: ${file}`);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const branchParams = (0, _branches.getBranchParams)(cli);
|
|
47
|
-
|
|
48
|
-
try {
|
|
49
|
-
const roles = JSON.parse(_fsExtra.default.readFileSync(file).toString());
|
|
50
|
-
const validatedRoles = (0, _schema.ensureValidRoleImport)(roles);
|
|
51
|
-
(0, _log.log)(`Uploading roles from ${file}…\n`);
|
|
52
|
-
await (0, _api.default)(params, 'POST', `${(0, _branches.getBranchBasePath)(branchParams, params.projectId)}/roles`, validatedRoles);
|
|
53
|
-
(0, _log.log)(_chalk.default.green('Success!'), 'Roles updated.');
|
|
54
|
-
} catch (e) {
|
|
55
|
-
return (0, _fatalError.fatalError)(e.message);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema-import.d.ts","sourceRoot":"","sources":["../../../../src/commands/import/schema-import.ts"],"names":[],"mappings":";AAsBA,wBAuCG"}
|
|
@@ -1,93 +0,0 @@
|
|
|
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 _fatalError = require("../../util/fatal-error");
|
|
11
|
-
|
|
12
|
-
var _api = _interopRequireDefault(require("../../util/api"));
|
|
13
|
-
|
|
14
|
-
var _log = _interopRequireDefault(require("../../log"));
|
|
15
|
-
|
|
16
|
-
var _chalk = _interopRequireDefault(require("chalk"));
|
|
17
|
-
|
|
18
|
-
var _schema = require("@takeshape/schema");
|
|
19
|
-
|
|
20
|
-
var _linkedCommand = require("../../util/linked-command");
|
|
21
|
-
|
|
22
|
-
var _formatValidationResult = require("../../util/format-validation-result");
|
|
23
|
-
|
|
24
|
-
var _fs = require("../../util/fs");
|
|
25
|
-
|
|
26
|
-
var _branches = require("../../util/branches");
|
|
27
|
-
|
|
28
|
-
var _url = require("url");
|
|
29
|
-
|
|
30
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
31
|
-
|
|
32
|
-
/*
|
|
33
|
-
takeshape import --schema --from ./path/to/schema.json
|
|
34
|
-
|
|
35
|
-
Replace your project's schema by uploading a new one
|
|
36
|
-
|
|
37
|
-
Flags:
|
|
38
|
-
--from Directory containing a schema.json or path to schema.json file
|
|
39
|
-
--preserveAuth Do not overwrite service authentication
|
|
40
|
-
*/
|
|
41
|
-
var _default = (0, _linkedCommand.linkedCommand)(async (cli, params) => {
|
|
42
|
-
const {
|
|
43
|
-
flags
|
|
44
|
-
} = cli;
|
|
45
|
-
const {
|
|
46
|
-
projectId
|
|
47
|
-
} = params;
|
|
48
|
-
|
|
49
|
-
if (!flags.from) {
|
|
50
|
-
return (0, _fatalError.fatalError)('No schema file provided. Use `--from path/to/file` or `--from directory`.');
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const {
|
|
54
|
-
exists,
|
|
55
|
-
file
|
|
56
|
-
} = (0, _fs.resolveFromFlag)(flags.from, 'schema.json');
|
|
57
|
-
|
|
58
|
-
if (!exists) {
|
|
59
|
-
return (0, _fatalError.fatalError)(`Schema file does not exist: ${file}`);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const branchParams = (0, _branches.getBranchParams)(cli);
|
|
63
|
-
const queryParams = {
|
|
64
|
-
force: 'true'
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
if (flags.preserveAuth) {
|
|
68
|
-
queryParams.preserveAuth = 'true';
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
if (flags.tag) {
|
|
72
|
-
queryParams.tag = flags.tag;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
try {
|
|
76
|
-
const newSchema = JSON.parse(_fsExtra.default.readFileSync(file).toString());
|
|
77
|
-
const validationString = (0, _formatValidationResult.formatValidationResult)((0, _schema.validateProjectSchemaImport)(newSchema));
|
|
78
|
-
|
|
79
|
-
if (validationString) {
|
|
80
|
-
return (0, _fatalError.fatalError)(validationString);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
(0, _log.default)(`Uploading schema from ${file}…\n`);
|
|
84
|
-
const schemaImportPath = `${(0, _branches.getBranchBasePath)(branchParams, projectId)}/schema?${new _url.URLSearchParams(queryParams)}`;
|
|
85
|
-
const uploaded = await (0, _api.default)(params, 'POST', schemaImportPath, newSchema);
|
|
86
|
-
(0, _log.default)(_chalk.default.green('Success!'), `Schema updated to version ${uploaded.version}.`);
|
|
87
|
-
process.exit(0);
|
|
88
|
-
} catch (e) {
|
|
89
|
-
return (0, _fatalError.fatalError)(e.message);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
exports.default = _default;
|
package/dist/commands/link.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../../src/commands/link.ts"],"names":[],"mappings":";AAQA,wBAkCG"}
|
package/dist/commands/link.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _log = _interopRequireDefault(require("../log"));
|
|
9
|
-
|
|
10
|
-
var _prompt = require("../prompt");
|
|
11
|
-
|
|
12
|
-
var _data = require("../util/data");
|
|
13
|
-
|
|
14
|
-
var _config = require("../config");
|
|
15
|
-
|
|
16
|
-
var _linkedCommand = require("../util/linked-command");
|
|
17
|
-
|
|
18
|
-
var _selectProject = require("../util/select-project");
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
22
|
-
var _default = (0, _linkedCommand.loggedInCommand)(async (_, params) => {
|
|
23
|
-
try {
|
|
24
|
-
const project = await (0, _selectProject.selectProject)(params);
|
|
25
|
-
|
|
26
|
-
if (!project) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const sites = await (0, _data.fetchSites)(params, project.value);
|
|
31
|
-
let site;
|
|
32
|
-
|
|
33
|
-
if (sites.length) {
|
|
34
|
-
var _site;
|
|
35
|
-
|
|
36
|
-
site = await (0, _prompt.promptList)('Select a site:', sites);
|
|
37
|
-
|
|
38
|
-
if (((_site = site) === null || _site === void 0 ? void 0 : _site.value) === 'NONE') {
|
|
39
|
-
site = undefined;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const isSameProject = params.projectId === project.value;
|
|
44
|
-
let {
|
|
45
|
-
linkedApiKey
|
|
46
|
-
} = params; // Clean up old API key
|
|
47
|
-
|
|
48
|
-
if (!isSameProject && params.linkedApiKey && params.projectId) {
|
|
49
|
-
await (0, _data.deleteApiKey)(params, params.projectId, params.linkedApiKey.id);
|
|
50
|
-
} // Only create a new API key if project has changed
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!isSameProject || !linkedApiKey) {
|
|
54
|
-
linkedApiKey = await (0, _data.createReadOnlyApiKey)(params, project.value);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
await (0, _config.writeLinkedProjectConfig)(params, linkedApiKey, project, site);
|
|
58
|
-
} catch (e) {
|
|
59
|
-
(0, _log.default)(e);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
exports.default = _default;
|
package/dist/commands/login.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/login.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,OAAO,EAAC,MAAM,UAAU,CAAC;AAIjC,QAAA,MAAM,KAAK,EAAE,OAWZ,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/commands/login.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _log = _interopRequireDefault(require("../log"));
|
|
9
|
-
|
|
10
|
-
var _login = require("../util/login");
|
|
11
|
-
|
|
12
|
-
var _config = require("../config");
|
|
13
|
-
|
|
14
|
-
var _data = require("../util/data");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const login = async (_, params) => {
|
|
19
|
-
try {
|
|
20
|
-
const userJwt = await (params.cliLogin ? (0, _login.loginCli)(params, 3) : (0, _login.loginBrowser)(params));
|
|
21
|
-
|
|
22
|
-
if (userJwt) {
|
|
23
|
-
const personalAccessToken = await (0, _data.createPersonalAccessToken)(params, userJwt);
|
|
24
|
-
await (0, _config.writeHomeConfig)(personalAccessToken);
|
|
25
|
-
}
|
|
26
|
-
} catch (e) {
|
|
27
|
-
(0, _log.default)(e);
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
var _default = login;
|
|
32
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/logout.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,OAAO,EAAsB,MAAM,UAAU,CAAC;AAItD,QAAA,MAAM,MAAM,EAAE,OASb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/dist/commands/logout.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _log = _interopRequireDefault(require("../log"));
|
|
9
|
-
|
|
10
|
-
var _types = require("../types");
|
|
11
|
-
|
|
12
|
-
var _config = require("../config");
|
|
13
|
-
|
|
14
|
-
var _data = require("../util/data");
|
|
15
|
-
|
|
16
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
|
-
const logout = async (_, params) => {
|
|
19
|
-
try {
|
|
20
|
-
if ((0, _types.isLoggedInCliConfig)(params)) {
|
|
21
|
-
await (0, _data.deletePersonalAccessToken)(params);
|
|
22
|
-
(0, _config.deleteHomeConfig)();
|
|
23
|
-
}
|
|
24
|
-
} catch (e) {
|
|
25
|
-
(0, _log.default)(e);
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
var _default = logout;
|
|
30
|
-
exports.default = _default;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/commands/schema.ts"],"names":[],"mappings":";AAKA,wBAGG"}
|