@takeshape/cli 9.80.4 → 9.81.3
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/dist/auth.js +2 -18
- package/dist/check-version.js +0 -6
- package/dist/commands/branch/commands/create.js +0 -11
- package/dist/commands/branch/commands/delete.js +0 -11
- package/dist/commands/branch/commands/list.js +0 -9
- package/dist/commands/branch/commands/merge.js +3 -29
- package/dist/commands/branch/commands/promote.js +0 -10
- package/dist/commands/branch/commands/tag-version.js +1 -10
- package/dist/commands/branch/commands/url.js +2 -17
- package/dist/commands/branch/index.js +0 -13
- package/dist/commands/build-or-watch.js +0 -18
- package/dist/commands/deploy/index.js +0 -18
- package/dist/commands/deploy/zip.js +0 -10
- package/dist/commands/export/index.js +0 -6
- package/dist/commands/export/project-export.js +1 -21
- package/dist/commands/export/schema-export.js +0 -21
- package/dist/commands/import/index.js +0 -9
- package/dist/commands/import/project-import.js +8 -45
- package/dist/commands/import/roles-import.js +0 -17
- package/dist/commands/import/schema-import.js +0 -23
- package/dist/commands/link.js +4 -19
- package/dist/commands/login.js +0 -8
- package/dist/commands/logout.js +0 -7
- package/dist/commands/schema.js +0 -7
- package/dist/commands/status.js +0 -5
- package/dist/commands/types.js +1 -6
- package/dist/commands/unlink.js +0 -7
- package/dist/commands/validate.js +0 -14
- package/dist/config.js +2 -31
- package/dist/deprecated.js +0 -3
- package/dist/errors.js +0 -7
- package/dist/files.js +0 -14
- package/dist/graphql.js +2 -19
- package/dist/index.js +0 -6
- package/dist/log.js +0 -3
- package/dist/main.js +0 -6
- package/dist/prompt.js +0 -5
- package/dist/types.js +0 -3
- package/dist/util/api.js +2 -18
- package/dist/util/branches.js +0 -16
- package/dist/util/cached-connector.js +0 -10
- package/dist/util/connector.js +2 -5
- package/dist/util/data.js +0 -16
- package/dist/util/fatal-error.js +0 -4
- package/dist/util/format-error.js +0 -1
- package/dist/util/format-validation-result.js +0 -2
- package/dist/util/fs.js +0 -8
- package/dist/util/generate-types.js +3 -15
- package/dist/util/get-client-schema.js +0 -8
- package/dist/util/glitch.js +0 -12
- package/dist/util/linked-command.js +0 -7
- package/dist/util/login.js +6 -30
- package/dist/util/messages.js +0 -10
- package/dist/util/ora-wrapper.js +0 -6
- package/dist/util/pusher.js +0 -5
- package/dist/util/runner.js +0 -8
- package/dist/util/select-project.js +0 -6
- package/dist/util/spin.js +0 -9
- package/dist/util/upload.js +0 -12
- package/dist/util/watcher.js +0 -5
- package/package.json +7 -7
package/dist/util/data.js
CHANGED
|
@@ -14,15 +14,10 @@ exports.deletePersonalAccessTokenMutation = void 0;
|
|
|
14
14
|
exports.fetchProjects = fetchProjects;
|
|
15
15
|
exports.fetchSites = fetchSites;
|
|
16
16
|
exports.siteListQuery = exports.projectListQuery = exports.laterSite = void 0;
|
|
17
|
-
|
|
18
17
|
var _graphql = require("../graphql");
|
|
19
|
-
|
|
20
18
|
var _errors = require("../errors");
|
|
21
|
-
|
|
22
19
|
var _os = _interopRequireDefault(require("os"));
|
|
23
|
-
|
|
24
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
|
-
|
|
26
21
|
const projectListQuery = `
|
|
27
22
|
{
|
|
28
23
|
projects: tsGetProjectList {
|
|
@@ -44,7 +39,6 @@ const siteListQuery = `
|
|
|
44
39
|
}
|
|
45
40
|
`;
|
|
46
41
|
exports.siteListQuery = siteListQuery;
|
|
47
|
-
|
|
48
42
|
async function fetchProjects(params) {
|
|
49
43
|
try {
|
|
50
44
|
const client = (0, _graphql.createAdminConnector)(params, params.authToken);
|
|
@@ -58,13 +52,11 @@ async function fetchProjects(params) {
|
|
|
58
52
|
throw (0, _errors.formatErrorMessage)(e, 'fetching your projects');
|
|
59
53
|
}
|
|
60
54
|
}
|
|
61
|
-
|
|
62
55
|
const laterSite = {
|
|
63
56
|
name: 'Select site later',
|
|
64
57
|
value: 'NONE'
|
|
65
58
|
};
|
|
66
59
|
exports.laterSite = laterSite;
|
|
67
|
-
|
|
68
60
|
async function fetchSites(params, pathParams) {
|
|
69
61
|
try {
|
|
70
62
|
const client = (0, _graphql.createConnector)(params, params.authToken, pathParams);
|
|
@@ -79,7 +71,6 @@ async function fetchSites(params, pathParams) {
|
|
|
79
71
|
throw (0, _errors.formatErrorMessage)(e, 'fetching your static sites');
|
|
80
72
|
}
|
|
81
73
|
}
|
|
82
|
-
|
|
83
74
|
const createPersonalAccessTokenMutation = (0, _graphql.graphQLQuery)(`
|
|
84
75
|
mutation ($name: String!){
|
|
85
76
|
result: tsCreatePersonalAccessToken(name: $name) {
|
|
@@ -110,11 +101,9 @@ const deleteApiKeyMutation = (0, _graphql.graphQLQuery)(`
|
|
|
110
101
|
}
|
|
111
102
|
`);
|
|
112
103
|
exports.deleteApiKeyMutation = deleteApiKeyMutation;
|
|
113
|
-
|
|
114
104
|
function createKeyName() {
|
|
115
105
|
return `TakeShape CLI ${_os.default.hostname()} ${new Date().toISOString().split('T')[0]}`;
|
|
116
106
|
}
|
|
117
|
-
|
|
118
107
|
async function createPersonalAccessToken(params, userJwt) {
|
|
119
108
|
try {
|
|
120
109
|
const client = (0, _graphql.createAdminConnector)(params, userJwt);
|
|
@@ -125,23 +114,19 @@ async function createPersonalAccessToken(params, userJwt) {
|
|
|
125
114
|
throw (0, _errors.formatErrorMessage)(e, 'creating your personal access token');
|
|
126
115
|
}
|
|
127
116
|
}
|
|
128
|
-
|
|
129
117
|
async function deletePersonalAccessToken(params) {
|
|
130
118
|
try {
|
|
131
119
|
const client = (0, _graphql.createAdminConnector)(params, params.authToken);
|
|
132
|
-
|
|
133
120
|
if (params.personalAccessTokenId) {
|
|
134
121
|
return await deletePersonalAccessTokenMutation(client, {
|
|
135
122
|
id: params.personalAccessTokenId
|
|
136
123
|
});
|
|
137
124
|
}
|
|
138
|
-
|
|
139
125
|
throw new Error('personalAccessTokenId is required');
|
|
140
126
|
} catch (e) {
|
|
141
127
|
throw (0, _errors.formatErrorMessage)(e, 'deleting your personal access token');
|
|
142
128
|
}
|
|
143
129
|
}
|
|
144
|
-
|
|
145
130
|
async function createReadOnlyApiKey(params, pathParams) {
|
|
146
131
|
try {
|
|
147
132
|
const client = (0, _graphql.createAdminConnector)(params, params.authToken, pathParams);
|
|
@@ -152,7 +137,6 @@ async function createReadOnlyApiKey(params, pathParams) {
|
|
|
152
137
|
throw (0, _errors.formatErrorMessage)(e, 'creating your read-only api key');
|
|
153
138
|
}
|
|
154
139
|
}
|
|
155
|
-
|
|
156
140
|
async function deleteApiKey(params, pathParams, apiKeyId) {
|
|
157
141
|
try {
|
|
158
142
|
const client = (0, _graphql.createAdminConnector)(params, params.authToken, pathParams);
|
package/dist/util/fatal-error.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.fatalError = fatalError;
|
|
7
|
-
|
|
8
7
|
var _log = _interopRequireDefault(require("../log"));
|
|
9
|
-
|
|
10
8
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function fatalError(message) {
|
|
15
11
|
(0, _log.default)(_chalk.default.red('Error'), message);
|
|
16
12
|
process.exit(1);
|
|
@@ -4,13 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.formatValidationResult = formatValidationResult;
|
|
7
|
-
|
|
8
7
|
function formatValidationResult(schemaValidationResult) {
|
|
9
8
|
const {
|
|
10
9
|
valid,
|
|
11
10
|
errors
|
|
12
11
|
} = schemaValidationResult;
|
|
13
|
-
|
|
14
12
|
if (!valid && errors) {
|
|
15
13
|
return `Invalid schema:\n ${errors.map(e => `${e.type}: ${e.message} at ${e.path.join('/')}`).join('\n ')}`;
|
|
16
14
|
}
|
package/dist/util/fs.js
CHANGED
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.resolveFromFlag = resolveFromFlag;
|
|
7
|
-
|
|
8
7
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
9
|
-
|
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function resolveFromFlag(from, expectedFilename) {
|
|
15
11
|
if (!_fsExtra.default.existsSync(from)) {
|
|
16
12
|
return {
|
|
@@ -18,23 +14,19 @@ function resolveFromFlag(from, expectedFilename) {
|
|
|
18
14
|
file: from
|
|
19
15
|
};
|
|
20
16
|
}
|
|
21
|
-
|
|
22
17
|
if (_fsExtra.default.lstatSync(from).isFile()) {
|
|
23
18
|
return {
|
|
24
19
|
exists: true,
|
|
25
20
|
file: from
|
|
26
21
|
};
|
|
27
22
|
}
|
|
28
|
-
|
|
29
23
|
const file = _path.default.join(from, expectedFilename);
|
|
30
|
-
|
|
31
24
|
if (_fsExtra.default.existsSync(file) && _fsExtra.default.lstatSync(file).isFile()) {
|
|
32
25
|
return {
|
|
33
26
|
exists: true,
|
|
34
27
|
file
|
|
35
28
|
};
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
return {
|
|
39
31
|
exists: false,
|
|
40
32
|
file
|
|
@@ -4,31 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateTypes = generateTypes;
|
|
7
|
-
|
|
8
7
|
var _fsExtra = require("fs-extra");
|
|
9
|
-
|
|
10
8
|
var _path = require("path");
|
|
11
|
-
|
|
12
9
|
var _graphql = require("graphql");
|
|
13
|
-
|
|
14
10
|
var _core = require("@graphql-codegen/core");
|
|
15
|
-
|
|
16
11
|
var typescriptPlugin = _interopRequireWildcard(require("@graphql-codegen/typescript"));
|
|
17
|
-
|
|
18
12
|
var _load = require("@graphql-tools/load");
|
|
19
|
-
|
|
20
13
|
var _graphqlFileLoader = require("@graphql-tools/graphql-file-loader");
|
|
21
|
-
|
|
22
14
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
23
|
-
|
|
24
15
|
var _log = _interopRequireDefault(require("../log"));
|
|
25
|
-
|
|
26
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
17
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
29
|
-
|
|
30
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
31
|
-
|
|
32
19
|
/** Uses [GraphQL Code Generator](https://www.graphql-code-generator.com/)
|
|
33
20
|
* to create TypeScript definitions from a GraphQL schema file.
|
|
34
21
|
*/
|
|
@@ -46,11 +33,12 @@ async function generateTypes(schemaFile, outputFile) {
|
|
|
46
33
|
// returns the string output, rather than writing to a file
|
|
47
34
|
filename: outputFile,
|
|
48
35
|
schema: (0, _graphql.parse)((0, _graphql.printSchema)(schema)),
|
|
49
|
-
plugins: [
|
|
36
|
+
plugins: [
|
|
37
|
+
// Each plugin should be an object
|
|
50
38
|
{
|
|
51
39
|
typescript: {} // Here you can pass configuration to the plugin
|
|
52
|
-
|
|
53
40
|
}],
|
|
41
|
+
|
|
54
42
|
pluginMap: {
|
|
55
43
|
typescript: typescriptPlugin
|
|
56
44
|
}
|
|
@@ -5,18 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.SCHEMA_FILE_NAME = void 0;
|
|
7
7
|
exports.getClientSchema = getClientSchema;
|
|
8
|
-
|
|
9
8
|
var _graphql = require("graphql");
|
|
10
|
-
|
|
11
9
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
12
|
-
|
|
13
10
|
var _oraWrapper = _interopRequireDefault(require("./ora-wrapper"));
|
|
14
|
-
|
|
15
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
12
|
const SCHEMA_FILE_NAME = 'takeshape-project.graphql';
|
|
18
13
|
exports.SCHEMA_FILE_NAME = SCHEMA_FILE_NAME;
|
|
19
|
-
|
|
20
14
|
async function getClientSchema(connector) {
|
|
21
15
|
const res = await connector({
|
|
22
16
|
query: (0, _graphql.getIntrospectionQuery)()
|
|
@@ -25,7 +19,5 @@ async function getClientSchema(connector) {
|
|
|
25
19
|
const result = (0, _graphql.printSchema)(schema);
|
|
26
20
|
await _fsExtra.default.writeFile(SCHEMA_FILE_NAME, result);
|
|
27
21
|
}
|
|
28
|
-
|
|
29
22
|
var _default = (0, _oraWrapper.default)(getClientSchema, 'Getting client schema.', `Client schema saved as ${SCHEMA_FILE_NAME}.`, 'Failed while getting client schema.');
|
|
30
|
-
|
|
31
23
|
exports.default = _default;
|
package/dist/util/glitch.js
CHANGED
|
@@ -7,39 +7,27 @@ exports.isGlitch = isGlitch;
|
|
|
7
7
|
exports.readDotEnv = readDotEnv;
|
|
8
8
|
exports.updateEnv = updateEnv;
|
|
9
9
|
exports.writeDotEnv = writeDotEnv;
|
|
10
|
-
|
|
11
10
|
var _dotenv = _interopRequireDefault(require("dotenv"));
|
|
12
|
-
|
|
13
11
|
var _dotenvStringify = _interopRequireDefault(require("dotenv-stringify"));
|
|
14
|
-
|
|
15
12
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
16
|
-
|
|
17
13
|
var _path = _interopRequireDefault(require("path"));
|
|
18
|
-
|
|
19
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
15
|
function isGlitch() {
|
|
22
16
|
return Boolean(process.env.GLITCH) || Boolean(process.env.PROJECT_REMIX_CHAIN);
|
|
23
17
|
}
|
|
24
|
-
|
|
25
18
|
function getEnvPath() {
|
|
26
19
|
return _path.default.resolve(process.cwd(), '.env');
|
|
27
20
|
}
|
|
28
|
-
|
|
29
21
|
async function readDotEnv() {
|
|
30
22
|
const path = getEnvPath();
|
|
31
|
-
|
|
32
23
|
if (_fsExtra.default.existsSync(path)) {
|
|
33
24
|
return _dotenv.default.parse(await _fsExtra.default.readFile(path));
|
|
34
25
|
}
|
|
35
|
-
|
|
36
26
|
return {};
|
|
37
27
|
}
|
|
38
|
-
|
|
39
28
|
async function writeDotEnv(env) {
|
|
40
29
|
return _fsExtra.default.writeFile(getEnvPath(), (0, _dotenvStringify.default)(env));
|
|
41
30
|
}
|
|
42
|
-
|
|
43
31
|
async function updateEnv(authToken, project, site = {}) {
|
|
44
32
|
const env = await readDotEnv();
|
|
45
33
|
env.TS_AUTH_TOKEN = authToken;
|
|
@@ -6,39 +6,32 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.linkedCommand = linkedCommand;
|
|
7
7
|
exports.loggedInAndLinkedCommand = loggedInAndLinkedCommand;
|
|
8
8
|
exports.loggedInCommand = loggedInCommand;
|
|
9
|
-
|
|
10
9
|
var _types = require("../types");
|
|
11
|
-
|
|
12
10
|
var _log = require("../log");
|
|
13
|
-
|
|
14
11
|
function assertLinked(params) {
|
|
15
12
|
if (!(0, _types.isLinkedCliConfig)(params)) {
|
|
16
13
|
(0, _log.logError)('Error: Missing project information not initialized please run `takeshape link`.');
|
|
17
14
|
process.exit(1);
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
|
|
21
17
|
function assertLoggedIn(params) {
|
|
22
18
|
if (!(0, _types.isLoggedInCliConfig)(params)) {
|
|
23
19
|
(0, _log.logError)(`Error: You are not logged in to TakeShape. Please run 'takeshape login' to login.`);
|
|
24
20
|
process.exit(1);
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
|
-
|
|
28
23
|
function linkedCommand(handler) {
|
|
29
24
|
return async (cli, params) => {
|
|
30
25
|
assertLinked(params);
|
|
31
26
|
return handler(cli, params);
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
function loggedInCommand(handler) {
|
|
36
30
|
return async (cli, params) => {
|
|
37
31
|
assertLoggedIn(params);
|
|
38
32
|
return handler(cli, params);
|
|
39
33
|
};
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
function loggedInAndLinkedCommand(handler) {
|
|
43
36
|
return async (cli, params) => {
|
|
44
37
|
assertLoggedIn(params);
|
package/dist/util/login.js
CHANGED
|
@@ -8,53 +8,42 @@ exports.attemptOpenForgotPassword = attemptOpenForgotPassword;
|
|
|
8
8
|
exports.loginBrowser = loginBrowser;
|
|
9
9
|
exports.loginCli = loginCli;
|
|
10
10
|
exports.waitingQuestions = exports.loginQuestions = void 0;
|
|
11
|
-
|
|
12
11
|
var _http = _interopRequireDefault(require("http"));
|
|
13
|
-
|
|
14
12
|
var _open = _interopRequireDefault(require("open"));
|
|
15
|
-
|
|
16
13
|
var _prompt = require("../prompt");
|
|
17
|
-
|
|
18
14
|
var _emailValidator = require("email-validator");
|
|
19
|
-
|
|
20
15
|
var _getPort = _interopRequireDefault(require("get-port"));
|
|
21
|
-
|
|
22
16
|
var _auth = require("../auth");
|
|
23
|
-
|
|
24
17
|
var _messages = require("./messages");
|
|
25
|
-
|
|
26
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
19
|
const waitingQuestions = [{
|
|
29
20
|
type: 'input',
|
|
30
21
|
name: 'token',
|
|
31
22
|
message: 'Opening a web browser to log you in. If the browser gives you a token, paste it here:\n'
|
|
32
23
|
}];
|
|
33
24
|
exports.waitingQuestions = waitingQuestions;
|
|
34
|
-
|
|
35
25
|
async function loginBrowser(params) {
|
|
36
26
|
// Port for login page to communicate with the CLI
|
|
37
|
-
const port = await (0, _getPort.default)();
|
|
27
|
+
const port = await (0, _getPort.default)();
|
|
38
28
|
|
|
29
|
+
// Open a browser to the login page
|
|
39
30
|
await (0, _open.default)(`${params.appUrl}/login?returnToCli=true&cliPort=${port}`, {
|
|
40
31
|
wait: false
|
|
41
32
|
});
|
|
42
|
-
let loginPromptUi;
|
|
33
|
+
let loginPromptUi;
|
|
43
34
|
|
|
35
|
+
// Spin up an ad-hoc server to recive the auth token from the login page
|
|
44
36
|
return new Promise((resolve, reject) => {
|
|
45
37
|
const server = _http.default.createServer((req, res) => {
|
|
46
38
|
res.setHeader('Content-Type', 'text/plain');
|
|
47
39
|
res.setHeader('Access-Control-Allow-Origin', params.appUrl);
|
|
48
40
|
res.setHeader('Access-Control-Allow-Headers', 'x-takeshape-token');
|
|
49
|
-
|
|
50
41
|
if (req.method === 'OPTIONS') {
|
|
51
42
|
res.statusCode = 200;
|
|
52
43
|
res.end('Success');
|
|
53
44
|
return;
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
const token = req.headers['x-takeshape-token'];
|
|
57
|
-
|
|
58
47
|
if (typeof token === 'string') {
|
|
59
48
|
res.statusCode = 200;
|
|
60
49
|
res.end('Success');
|
|
@@ -65,16 +54,13 @@ async function loginBrowser(params) {
|
|
|
65
54
|
res.end('Bad Request');
|
|
66
55
|
reject(new Error('Did not receive auth token from webapp.'));
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
if (loginPromptUi) {
|
|
70
58
|
// @ts-expect-error `close` is protected but this is the suggested solution from here:
|
|
71
59
|
// https://github.com/SBoudrias/Inquirer.js/issues/941
|
|
72
60
|
loginPromptUi.close();
|
|
73
61
|
}
|
|
74
|
-
|
|
75
62
|
server.close();
|
|
76
63
|
});
|
|
77
|
-
|
|
78
64
|
server.listen(port, '127.0.0.1', async () => {
|
|
79
65
|
const loginPrompt = (0, _prompt.prompt)(waitingQuestions);
|
|
80
66
|
loginPromptUi = loginPrompt.ui;
|
|
@@ -84,58 +70,48 @@ async function loginBrowser(params) {
|
|
|
84
70
|
});
|
|
85
71
|
});
|
|
86
72
|
}
|
|
87
|
-
|
|
88
73
|
const loginQuestions = [{
|
|
89
74
|
type: 'input',
|
|
90
75
|
name: 'email',
|
|
91
76
|
message: 'Enter your TakeShape email:',
|
|
92
|
-
|
|
93
77
|
validate(input) {
|
|
94
78
|
return (0, _emailValidator.validate)(input) || 'Please enter a valid email';
|
|
95
79
|
}
|
|
96
|
-
|
|
97
80
|
}, {
|
|
98
81
|
type: 'password',
|
|
99
82
|
name: 'password',
|
|
100
83
|
message: 'Enter your TakeShape password:'
|
|
101
84
|
}];
|
|
102
85
|
exports.loginQuestions = loginQuestions;
|
|
103
|
-
|
|
104
86
|
async function attemptLogin(params) {
|
|
105
87
|
const answers = await (0, _prompt.prompt)(loginQuestions);
|
|
106
88
|
return (0, _auth.login)(params.endpoint, answers.email, answers.password);
|
|
107
89
|
}
|
|
108
|
-
|
|
109
90
|
async function attemptOpenForgotPassword(params) {
|
|
110
91
|
const isConfirmed = await (0, _prompt.confirm)('Would you like to open TakeShape to set a password?');
|
|
111
|
-
|
|
112
92
|
if (isConfirmed) {
|
|
113
93
|
await (0, _open.default)(params.appUrl + '/forgot-password', {
|
|
114
94
|
wait: false
|
|
115
95
|
});
|
|
116
96
|
}
|
|
117
97
|
}
|
|
118
|
-
|
|
119
98
|
async function loginCli(params, maxAttempts) {
|
|
120
99
|
let attempts = 0;
|
|
121
|
-
|
|
122
100
|
do {
|
|
123
101
|
attempts++;
|
|
124
|
-
|
|
125
102
|
try {
|
|
126
103
|
// eslint-disable-next-line no-await-in-loop
|
|
127
104
|
return await attemptLogin(params);
|
|
128
105
|
} catch (e) {
|
|
129
106
|
if (e.statusCode === 403) {
|
|
130
107
|
attempts--;
|
|
131
|
-
(0, _messages.missingPasswordMsg)();
|
|
132
|
-
|
|
108
|
+
(0, _messages.missingPasswordMsg)();
|
|
109
|
+
// eslint-disable-next-line no-await-in-loop
|
|
133
110
|
await attemptOpenForgotPassword(params);
|
|
134
111
|
} else {
|
|
135
112
|
(0, _messages.invalidLoginMsg)();
|
|
136
113
|
}
|
|
137
114
|
}
|
|
138
115
|
} while (attempts < maxAttempts);
|
|
139
|
-
|
|
140
116
|
(0, _messages.forgotPasswordWarning)(params);
|
|
141
117
|
}
|
package/dist/util/messages.js
CHANGED
|
@@ -11,13 +11,9 @@ exports.noProjectsError = noProjectsError;
|
|
|
11
11
|
exports.waitingForLogin = void 0;
|
|
12
12
|
exports.warning = warning;
|
|
13
13
|
exports.writingHomeConfigDoneMsg = exports.writingFilesMsg = void 0;
|
|
14
|
-
|
|
15
14
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
16
|
-
|
|
17
15
|
var _log = _interopRequireDefault(require("../log"));
|
|
18
|
-
|
|
19
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
17
|
function warning(msg) {
|
|
22
18
|
return () => {
|
|
23
19
|
msg.split('\n').forEach(line => {
|
|
@@ -25,13 +21,11 @@ function warning(msg) {
|
|
|
25
21
|
});
|
|
26
22
|
};
|
|
27
23
|
}
|
|
28
|
-
|
|
29
24
|
function info(msg) {
|
|
30
25
|
return () => {
|
|
31
26
|
(0, _log.default)(msg);
|
|
32
27
|
};
|
|
33
28
|
}
|
|
34
|
-
|
|
35
29
|
const waitingForLogin = info('Opening a web browser to log you in...');
|
|
36
30
|
exports.waitingForLogin = waitingForLogin;
|
|
37
31
|
const loginSuccess = info('Successfully logged in.');
|
|
@@ -42,19 +36,15 @@ const missingPasswordMsg = info('No password set in TakeShape. Follow the forgot
|
|
|
42
36
|
exports.missingPasswordMsg = missingPasswordMsg;
|
|
43
37
|
const writingFilesMsg = info('Writing .takeshaperc, .graphqlconfig.');
|
|
44
38
|
exports.writingFilesMsg = writingFilesMsg;
|
|
45
|
-
|
|
46
39
|
const writingHomeConfigDoneMsg = path => {
|
|
47
40
|
(0, _log.default)(`Personal access token saved to ${path}`);
|
|
48
41
|
};
|
|
49
|
-
|
|
50
42
|
exports.writingHomeConfigDoneMsg = writingHomeConfigDoneMsg;
|
|
51
43
|
const consoleWarning = warning('**************************************************************************************************\n' + ' Add the following to your vcs ignore file: \n' + ' .takeshaperc \n' + ' .graphqlconfig \n' + '**************************************************************************************************');
|
|
52
44
|
exports.consoleWarning = consoleWarning;
|
|
53
|
-
|
|
54
45
|
function forgotPasswordWarning(params) {
|
|
55
46
|
(0, _log.default)(`If you forgot your credentials please visit ${params.appUrl}/forgot-password`);
|
|
56
47
|
}
|
|
57
|
-
|
|
58
48
|
function noProjectsError(params) {
|
|
59
49
|
(0, _log.default)(`No projects configured. Set one up at ${params.appUrl}/projects`);
|
|
60
50
|
}
|
package/dist/util/ora-wrapper.js
CHANGED
|
@@ -4,19 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = oraWrapper;
|
|
7
|
-
|
|
8
7
|
var _ora = _interopRequireDefault(require("ora"));
|
|
9
|
-
|
|
10
8
|
var _formatError = _interopRequireDefault(require("./format-error"));
|
|
11
|
-
|
|
12
9
|
var _log = require("../log");
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function oraWrapper(fn, start, success, failure) {
|
|
17
12
|
return async (...args) => {
|
|
18
13
|
const spinner = (0, _ora.default)(start).start();
|
|
19
|
-
|
|
20
14
|
try {
|
|
21
15
|
await fn(...args);
|
|
22
16
|
spinner.succeed(success);
|
package/dist/util/pusher.js
CHANGED
|
@@ -5,13 +5,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.handleAction = handleAction;
|
|
7
7
|
exports.subscribe = subscribe;
|
|
8
|
-
|
|
9
8
|
var _api = _interopRequireDefault(require("./api"));
|
|
10
|
-
|
|
11
9
|
var _pusherJs = _interopRequireDefault(require("pusher-js"));
|
|
12
|
-
|
|
13
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
|
|
15
11
|
function handleAction(callback) {
|
|
16
12
|
return action => {
|
|
17
13
|
if (action.type === 'content/CONTENT_UPDATED' || action.type === 'content/CONTENT_CREATED' || action.type === 'content/CONTENT_DELETED') {
|
|
@@ -19,7 +15,6 @@ function handleAction(callback) {
|
|
|
19
15
|
}
|
|
20
16
|
};
|
|
21
17
|
}
|
|
22
|
-
|
|
23
18
|
async function subscribe(params, callback) {
|
|
24
19
|
const config = await (0, _api.default)(params, 'GET', `/project/${params.projectId}/pusher-client-config`);
|
|
25
20
|
const pusher = new _pusherJs.default(config.key, {
|
package/dist/util/runner.js
CHANGED
|
@@ -4,15 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createRunner = createRunner;
|
|
7
|
-
|
|
8
7
|
var _chalk = _interopRequireDefault(require("chalk"));
|
|
9
|
-
|
|
10
8
|
var _formatError = _interopRequireDefault(require("./format-error"));
|
|
11
|
-
|
|
12
9
|
var _log = _interopRequireDefault(require("../log"));
|
|
13
|
-
|
|
14
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
11
|
function createRunner(name, task) {
|
|
17
12
|
let running = false;
|
|
18
13
|
return async (...args) => {
|
|
@@ -20,7 +15,6 @@ function createRunner(name, task) {
|
|
|
20
15
|
running = true;
|
|
21
16
|
const startTime = Date.now();
|
|
22
17
|
(0, _log.default)(`${name} - Started!`);
|
|
23
|
-
|
|
24
18
|
try {
|
|
25
19
|
const stats = await task(...args);
|
|
26
20
|
const totalSeconds = (Date.now() - startTime) / 1000;
|
|
@@ -28,14 +22,12 @@ function createRunner(name, task) {
|
|
|
28
22
|
const {
|
|
29
23
|
warnings
|
|
30
24
|
} = stats;
|
|
31
|
-
|
|
32
25
|
if (warnings !== null && warnings !== void 0 && warnings.length) {
|
|
33
26
|
(0, _log.default)(`${name} - ` + _chalk.default.yellow('Warnings:'));
|
|
34
27
|
warnings.forEach(warning => {
|
|
35
28
|
(0, _log.default)(_chalk.default.yellow(`${warning.source}: ${warning.message}`));
|
|
36
29
|
});
|
|
37
30
|
}
|
|
38
|
-
|
|
39
31
|
running = false;
|
|
40
32
|
} catch (error) {
|
|
41
33
|
(0, _log.default)(`${name} - ` + _chalk.default.red(`Error:\n${(0, _formatError.default)(error)}`));
|
|
@@ -4,20 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.selectProject = selectProject;
|
|
7
|
-
|
|
8
7
|
var _data = require("./data");
|
|
9
|
-
|
|
10
8
|
var _messages = require("./messages");
|
|
11
|
-
|
|
12
9
|
var _prompt = require("../prompt");
|
|
13
|
-
|
|
14
10
|
async function selectProject(params) {
|
|
15
11
|
const projects = await (0, _data.fetchProjects)(params);
|
|
16
|
-
|
|
17
12
|
if (!projects.length) {
|
|
18
13
|
(0, _messages.noProjectsError)(params);
|
|
19
14
|
return;
|
|
20
15
|
}
|
|
21
|
-
|
|
22
16
|
return (0, _prompt.promptList)('Select a project:', projects);
|
|
23
17
|
}
|
package/dist/util/spin.js
CHANGED
|
@@ -4,38 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
-
|
|
8
7
|
var _util = require("@takeshape/util");
|
|
9
|
-
|
|
10
8
|
const SPINTERVAL = 100;
|
|
11
|
-
|
|
12
9
|
async function spin(spinQuery) {
|
|
13
10
|
const res = await spinQuery();
|
|
14
11
|
const status = res === null ? 'running' : res.status;
|
|
15
|
-
|
|
16
12
|
switch (status) {
|
|
17
13
|
case 'running':
|
|
18
14
|
await (0, _util.delay)(SPINTERVAL);
|
|
19
15
|
await spin(spinQuery);
|
|
20
16
|
break;
|
|
21
|
-
|
|
22
17
|
case 'completed':
|
|
23
18
|
break;
|
|
24
|
-
|
|
25
19
|
case 'timeout':
|
|
26
20
|
throw new Error('Export timed out');
|
|
27
|
-
|
|
28
21
|
case 'error':
|
|
29
22
|
if (res !== null && res !== void 0 && res.message) {
|
|
30
23
|
throw new Error(res.message);
|
|
31
24
|
} else {
|
|
32
25
|
throw new Error('An unknown error occurred');
|
|
33
26
|
}
|
|
34
|
-
|
|
35
27
|
default:
|
|
36
28
|
throw new Error(`Unexpected export status: ${status}`);
|
|
37
29
|
}
|
|
38
30
|
}
|
|
39
|
-
|
|
40
31
|
var _default = spin;
|
|
41
32
|
exports.default = _default;
|