@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.
Files changed (61) hide show
  1. package/dist/auth.js +2 -18
  2. package/dist/check-version.js +0 -6
  3. package/dist/commands/branch/commands/create.js +0 -11
  4. package/dist/commands/branch/commands/delete.js +0 -11
  5. package/dist/commands/branch/commands/list.js +0 -9
  6. package/dist/commands/branch/commands/merge.js +3 -29
  7. package/dist/commands/branch/commands/promote.js +0 -10
  8. package/dist/commands/branch/commands/tag-version.js +1 -10
  9. package/dist/commands/branch/commands/url.js +2 -17
  10. package/dist/commands/branch/index.js +0 -13
  11. package/dist/commands/build-or-watch.js +0 -18
  12. package/dist/commands/deploy/index.js +0 -18
  13. package/dist/commands/deploy/zip.js +0 -10
  14. package/dist/commands/export/index.js +0 -6
  15. package/dist/commands/export/project-export.js +1 -21
  16. package/dist/commands/export/schema-export.js +0 -21
  17. package/dist/commands/import/index.js +0 -9
  18. package/dist/commands/import/project-import.js +8 -45
  19. package/dist/commands/import/roles-import.js +0 -17
  20. package/dist/commands/import/schema-import.js +0 -23
  21. package/dist/commands/link.js +4 -19
  22. package/dist/commands/login.js +0 -8
  23. package/dist/commands/logout.js +0 -7
  24. package/dist/commands/schema.js +0 -7
  25. package/dist/commands/status.js +0 -5
  26. package/dist/commands/types.js +1 -6
  27. package/dist/commands/unlink.js +0 -7
  28. package/dist/commands/validate.js +0 -14
  29. package/dist/config.js +2 -31
  30. package/dist/deprecated.js +0 -3
  31. package/dist/errors.js +0 -7
  32. package/dist/files.js +0 -14
  33. package/dist/graphql.js +2 -19
  34. package/dist/index.js +0 -6
  35. package/dist/log.js +0 -3
  36. package/dist/main.js +0 -6
  37. package/dist/prompt.js +0 -5
  38. package/dist/types.js +0 -3
  39. package/dist/util/api.js +2 -18
  40. package/dist/util/branches.js +0 -16
  41. package/dist/util/cached-connector.js +0 -10
  42. package/dist/util/connector.js +2 -5
  43. package/dist/util/data.js +0 -16
  44. package/dist/util/fatal-error.js +0 -4
  45. package/dist/util/format-error.js +0 -1
  46. package/dist/util/format-validation-result.js +0 -2
  47. package/dist/util/fs.js +0 -8
  48. package/dist/util/generate-types.js +3 -15
  49. package/dist/util/get-client-schema.js +0 -8
  50. package/dist/util/glitch.js +0 -12
  51. package/dist/util/linked-command.js +0 -7
  52. package/dist/util/login.js +6 -30
  53. package/dist/util/messages.js +0 -10
  54. package/dist/util/ora-wrapper.js +0 -6
  55. package/dist/util/pusher.js +0 -5
  56. package/dist/util/runner.js +0 -8
  57. package/dist/util/select-project.js +0 -6
  58. package/dist/util/spin.js +0 -9
  59. package/dist/util/upload.js +0 -12
  60. package/dist/util/watcher.js +0 -5
  61. package/package.json +7 -7
package/dist/auth.js CHANGED
@@ -6,38 +6,28 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.login = login;
7
7
  exports.parseToken = parseToken;
8
8
  exports.projectAuth = projectAuth;
9
-
10
9
  var _nodeFetch = _interopRequireDefault(require("node-fetch"));
11
-
12
10
  var _errors = require("./errors");
13
-
14
11
  var _api = require("./util/api");
15
-
16
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
13
  async function parseToken(res) {
19
14
  try {
20
15
  const body = await res.json();
21
-
22
16
  if (body.token) {
23
17
  return body.token;
24
18
  }
25
- } catch {// ignore parsing error
19
+ } catch {
20
+ // ignore parsing error
26
21
  }
27
-
28
22
  const cookie = res.headers.get('set-cookie');
29
-
30
23
  if (cookie) {
31
24
  const matches = /s=(.+?);/.exec(cookie);
32
-
33
25
  if (matches) {
34
26
  return matches[1];
35
27
  }
36
28
  }
37
-
38
29
  throw new _errors.HTTPError('Forbidden', 403);
39
30
  }
40
-
41
31
  async function fetchToken(method, endpoint, body, headers) {
42
32
  const params = {
43
33
  method,
@@ -46,27 +36,21 @@ async function fetchToken(method, endpoint, body, headers) {
46
36
  ...headers
47
37
  }
48
38
  };
49
-
50
39
  if (body) {
51
40
  params.body = JSON.stringify(body);
52
41
  }
53
-
54
42
  const res = await (0, _nodeFetch.default)(endpoint, params);
55
-
56
43
  if (res.ok) {
57
44
  return parseToken(res);
58
45
  }
59
-
60
46
  throw new _errors.HTTPError(`${res.statusText}`, res.status);
61
47
  }
62
-
63
48
  async function login(endpoint, email, password) {
64
49
  return fetchToken('POST', `${endpoint}/login`, {
65
50
  email,
66
51
  password
67
52
  });
68
53
  }
69
-
70
54
  async function projectAuth(endpoint, projectId, authToken) {
71
55
  try {
72
56
  return await fetchToken('GET', `${endpoint}/project/${projectId}/access-token`, null, (0, _api.getAuthHeader)(authToken));
@@ -4,17 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.checkVersion = checkVersion;
7
-
8
7
  var _semver = _interopRequireDefault(require("semver"));
9
-
10
8
  var _package = require("../package.json");
11
-
12
9
  var _chalk = _interopRequireDefault(require("chalk"));
13
-
14
10
  var _log = _interopRequireDefault(require("./log"));
15
-
16
11
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
17
-
18
12
  function checkVersion(currentVersion) {
19
13
  if (!_semver.default.satisfies(currentVersion, _package.engines.node)) {
20
14
  (0, _log.default)(_chalk.default.yellow(`WARNING: TakeShape CLI does not officially support node ${currentVersion} yet. Please use node version ${_package.engines.node}.`));
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createBranch = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _log = _interopRequireDefault(require("../../../log"));
13
-
14
10
  var _chalk = _interopRequireDefault(require("chalk"));
15
-
16
11
  var _branches = require("../../../util/branches");
17
-
18
12
  var _fatalError = require("../../../util/fatal-error");
19
-
20
13
  var _prettyjson = _interopRequireDefault(require("prettyjson"));
21
-
22
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
-
24
15
  const createBranchMutation = (0, _graphql.graphQLQuery)(`
25
16
  mutation ($input: TSCreateSchemaBranchInput!) {
26
17
  result: tsCreateSchemaBranch(input: $input) {
@@ -38,11 +29,9 @@ const createBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, pa
38
29
  branch,
39
30
  environment
40
31
  } = (0, _branches.getBranchParams)(cli, 'name');
41
-
42
32
  if (environment === 'PRODUCTION') {
43
33
  return (0, _fatalError.fatalError)('There is only one production branch and it already exists');
44
34
  }
45
-
46
35
  try {
47
36
  const client = (0, _graphql.createAdminConnector)(params, params.authToken, params.projectId);
48
37
  const res = await createBranchMutation(client, {
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.deleteBranch = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _log = _interopRequireDefault(require("../../../log"));
13
-
14
10
  var _chalk = _interopRequireDefault(require("chalk"));
15
-
16
11
  var _branches = require("../../../util/branches");
17
-
18
12
  var _fatalError = require("../../../util/fatal-error");
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  const deleteBranchMutation = (0, _graphql.graphQLQuery)(`
23
15
  mutation ($input: TSDeleteSchemaBranchInput!) {
24
16
  result: tsDeleteSchemaBranch(input: $input) {
@@ -33,11 +25,9 @@ const deleteBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, pa
33
25
  branch,
34
26
  environment
35
27
  } = (0, _branches.getBranchParams)(cli, 'name');
36
-
37
28
  if (environment === 'PRODUCTION') {
38
29
  return (0, _fatalError.fatalError)('You cannot delete the production branch');
39
30
  }
40
-
41
31
  const client = (0, _graphql.createAdminConnector)(params, params.authToken, params.projectId);
42
32
  const {
43
33
  deletedBranch
@@ -48,7 +38,6 @@ const deleteBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, pa
48
38
  }
49
39
  });
50
40
  const branchName = branch ?? environment.toLowerCase();
51
-
52
41
  if (deletedBranch) {
53
42
  (0, _log.default)(_chalk.default.green(`Branch "${branchName}" was deleted!`));
54
43
  } else {
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.listBranches = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _log = _interopRequireDefault(require("../../../log"));
13
-
14
10
  var _chalk = _interopRequireDefault(require("chalk"));
15
-
16
11
  var _formatRelative = _interopRequireDefault(require("date-fns/formatRelative"));
17
-
18
12
  var _prettyjson = _interopRequireDefault(require("prettyjson"));
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  const getBranchListQuery = (0, _graphql.graphQLQuery)(`
23
15
  {
24
16
  result: tsGetSchemaBranchList(first: 100) {
@@ -39,7 +31,6 @@ const listBranches = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, pa
39
31
  const {
40
32
  nodes: branches
41
33
  } = await getBranchListQuery(client, {});
42
-
43
34
  for (const branch of branches ?? []) {
44
35
  const env = branch.environment.toLowerCase();
45
36
  const name = branch.branchName ?? env;
@@ -4,24 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.mergeBranch = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _log = _interopRequireDefault(require("../../../log"));
13
-
14
10
  var _chalk = _interopRequireDefault(require("chalk"));
15
-
16
11
  var _branches = require("../../../util/branches");
17
-
18
12
  var _fatalError = require("../../../util/fatal-error");
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
- const getBranchQuery = (0, _graphql.graphQLQuery)(
23
- /* GraphQL */
24
- `
14
+ const getBranchQuery = (0, _graphql.graphQLQuery)( /* GraphQL */`
25
15
  query CliGetBranchQuery($projectId: String!, $environment: TSSchemaBranchEnvironment!, $branchName: String) {
26
16
  result: tsGetSchemaBranch(projectId: $projectId, environment: $environment, branchName: $branchName) {
27
17
  latestVersion {
@@ -32,9 +22,7 @@ const getBranchQuery = (0, _graphql.graphQLQuery)(
32
22
  }
33
23
  }
34
24
  `);
35
- const getBranchParentQuery = (0, _graphql.graphQLQuery)(
36
- /* GraphQL */
37
- `
25
+ const getBranchParentQuery = (0, _graphql.graphQLQuery)( /* GraphQL */`
38
26
  query CliGetBranchParentQuery($projectId: String!, $environment: TSSchemaBranchEnvironment!, $branchName: String) {
39
27
  result: tsGetSchemaBranch(projectId: $projectId, environment: $environment, branchName: $branchName) {
40
28
  parentVersion {
@@ -44,9 +32,7 @@ const getBranchParentQuery = (0, _graphql.graphQLQuery)(
44
32
  }
45
33
  }
46
34
  `);
47
- const mergeBranchMutation = (0, _graphql.graphQLQuery)(
48
- /* GraphQL */
49
- `
35
+ const mergeBranchMutation = (0, _graphql.graphQLQuery)( /* GraphQL */`
50
36
  mutation CliMergeBranchMutation($input: TSMergeSchemaBranchInput!) {
51
37
  result: tsMergeSchemaBranch(input: $input) {
52
38
  dryRun
@@ -61,15 +47,12 @@ const mergeBranchMutation = (0, _graphql.graphQLQuery)(
61
47
  }
62
48
  }
63
49
  `);
64
-
65
50
  function ensureHeadArgs(cli) {
66
51
  if (!cli.flags.head) {
67
52
  throw new Error('You must provide a --head to merge.');
68
53
  }
69
-
70
54
  return (0, _branches.getBranchArgs)(cli.flags.head);
71
55
  }
72
-
73
56
  const mergeBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, params) => {
74
57
  try {
75
58
  const {
@@ -84,17 +67,14 @@ const mergeBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, par
84
67
  const targetInput = cli.flags.target && (0, _branches.getBranchArgs)(cli.flags.target);
85
68
  const client = (0, _graphql.createAdminConnector)(params, params.authToken, projectId);
86
69
  let base;
87
-
88
70
  if (baseInput) {
89
71
  const baseQueryResult = await getBranchQuery(client, {
90
72
  projectId,
91
73
  ...baseInput
92
74
  });
93
-
94
75
  if (!(baseQueryResult !== null && baseQueryResult !== void 0 && baseQueryResult.latestVersion)) {
95
76
  return (0, _fatalError.fatalError)('Base branch does not exist');
96
77
  }
97
-
98
78
  const {
99
79
  environment,
100
80
  branchName
@@ -108,14 +88,11 @@ const mergeBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, par
108
88
  projectId,
109
89
  ...head
110
90
  });
111
-
112
91
  if (!(parentQueryResult !== null && parentQueryResult !== void 0 && parentQueryResult.parentVersion)) {
113
92
  return (0, _fatalError.fatalError)('Head branch does not exist');
114
93
  }
115
-
116
94
  base = parentQueryResult.parentVersion;
117
95
  }
118
-
119
96
  const targetParams = targetInput ? {
120
97
  projectId,
121
98
  ...targetInput
@@ -124,11 +101,9 @@ const mergeBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, par
124
101
  ...base
125
102
  };
126
103
  const branchQueryResult = await getBranchQuery(client, targetParams);
127
-
128
104
  if (!(branchQueryResult !== null && branchQueryResult !== void 0 && branchQueryResult.latestVersion)) {
129
105
  return (0, _fatalError.fatalError)('Target branch does not exist');
130
106
  }
131
-
132
107
  const target = branchQueryResult.latestVersion;
133
108
  const res = await mergeBranchMutation(client, {
134
109
  input: {
@@ -147,7 +122,6 @@ const mergeBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, par
147
122
  const dryRunText = res.dryRun ? _chalk.default.blue('[DRY RUN]') : '';
148
123
  (0, _log.default)(_chalk.default.green(`${dryRunText} Head branch "${headBranchName}" was merged into base branch "${baseBranchName}"`.trim()));
149
124
  (0, _log.default)(_chalk.default.green(`${dryRunText} Target branch "${targetBranchName}" was updated`.trim()));
150
-
151
125
  if (deletedBranchName) {
152
126
  (0, _log.default)(_chalk.default.green(`${dryRunText} Head branch "${headBranchName}" was deleted`.trim()));
153
127
  }
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.promoteBranch = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _log = _interopRequireDefault(require("../../../log"));
13
-
14
10
  var _chalk = _interopRequireDefault(require("chalk"));
15
-
16
11
  var _branches = require("../../../util/branches");
17
-
18
12
  var _fatalError = require("../../../util/fatal-error");
19
-
20
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
21
-
22
14
  const promoteBranchMutation = (0, _graphql.graphQLQuery)(`
23
15
  mutation ($input: TSPromoteSchemaBranchInput!) {
24
16
  result: tsPromoteSchemaBranch(input: $input) {
@@ -33,11 +25,9 @@ const promoteBranch = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, p
33
25
  branch,
34
26
  environment
35
27
  } = (0, _branches.getBranchParams)(cli, 'name');
36
-
37
28
  if (environment === 'PRODUCTION') {
38
29
  return (0, _fatalError.fatalError)('You cannot promote the production branch');
39
30
  }
40
-
41
31
  const client = (0, _graphql.createAdminConnector)(params, params.authToken, params.projectId);
42
32
  await promoteBranchMutation(client, {
43
33
  input: {
@@ -4,18 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.tagBranchVersion = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _branches = require("../../../util/branches");
13
-
14
10
  var _fatalError = require("../../../util/fatal-error");
15
-
16
- const createBranchTag = (0, _graphql.graphQLQuery)(
17
- /* GraphQL */
18
- `
11
+ const createBranchTag = (0, _graphql.graphQLQuery)( /* GraphQL */`
19
12
  mutation ($input: TSCreateSchemaBranchTagInput!) {
20
13
  result: tsCreateSchemaBranchTag(input: $input) {
21
14
  branchVersion {
@@ -36,11 +29,9 @@ const tagBranchVersion = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli
36
29
  tag,
37
30
  hash
38
31
  } = flags;
39
-
40
32
  if (!tag) {
41
33
  return (0, _fatalError.fatalError)('--tag flag is required');
42
34
  }
43
-
44
35
  const client = (0, _graphql.createAdminConnector)(params, params.authToken, params.projectId);
45
36
  const {
46
37
  branchVersion: {
@@ -4,18 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getVersionUrl = exports.getUrl = void 0;
7
-
8
7
  var _linkedCommand = require("../../../util/linked-command");
9
-
10
8
  var _graphql = require("../../../graphql");
11
-
12
9
  var _branches = require("../../../util/branches");
13
-
14
10
  var _fatalError = require("../../../util/fatal-error");
15
-
16
- const getBranchVersionQuery = (0, _graphql.graphQLQuery)(
17
- /* GraphQL */
18
- `
11
+ const getBranchVersionQuery = (0, _graphql.graphQLQuery)( /* GraphQL */`
19
12
  query ($environment: TSSchemaBranchEnvironment!, $branchName: String, $tagName: String, $schemaHash: String) {
20
13
  result: tsGetSchemaBranchVersion(
21
14
  environment: $environment
@@ -27,9 +20,7 @@ const getBranchVersionQuery = (0, _graphql.graphQLQuery)(
27
20
  }
28
21
  }
29
22
  `);
30
- const getBranchQuery = (0, _graphql.graphQLQuery)(
31
- /* GraphQL */
32
- `
23
+ const getBranchQuery = (0, _graphql.graphQLQuery)( /* GraphQL */`
33
24
  query ($environment: TSSchemaBranchEnvironment!, $branchName: String) {
34
25
  result: tsGetSchemaBranch(environment: $environment, branchName: $branchName) {
35
26
  graphqlUrl
@@ -44,11 +35,9 @@ const getVersionUrl = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, p
44
35
  const {
45
36
  flags
46
37
  } = cli;
47
-
48
38
  if (flags.tag && flags.hash) {
49
39
  return (0, _fatalError.fatalError)('Can only provide one of: --tag OR --hash');
50
40
  }
51
-
52
41
  const client = (0, _graphql.createAdminConnector)(params, params.authToken, params.projectId);
53
42
  const result = await getBranchVersionQuery(client, {
54
43
  environment,
@@ -56,11 +45,9 @@ const getVersionUrl = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, p
56
45
  tagName: flags.tag,
57
46
  schemaHash: flags.hash
58
47
  });
59
-
60
48
  if (!result) {
61
49
  return (0, _fatalError.fatalError)('Branch does not exist');
62
50
  }
63
-
64
51
  process.stdout.write(result.graphqlUrl);
65
52
  });
66
53
  exports.getVersionUrl = getVersionUrl;
@@ -74,11 +61,9 @@ const getUrl = (0, _linkedCommand.loggedInAndLinkedCommand)(async (cli, params)
74
61
  environment,
75
62
  branchName: branch
76
63
  });
77
-
78
64
  if (!result) {
79
65
  return (0, _fatalError.fatalError)('Branch does not exist');
80
66
  }
81
-
82
67
  process.stdout.write(result.graphqlUrl);
83
68
  });
84
69
  exports.getUrl = getUrl;
@@ -4,23 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _fatalError = require("../../util/fatal-error");
9
-
10
8
  var _delete = require("./commands/delete");
11
-
12
9
  var _create = require("./commands/create");
13
-
14
10
  var _promote = require("./commands/promote");
15
-
16
11
  var _url = require("./commands/url");
17
-
18
12
  var _list = require("./commands/list");
19
-
20
13
  var _tagVersion = require("./commands/tag-version");
21
-
22
14
  var _merge = require("./commands/merge");
23
-
24
15
  const subcommands = {
25
16
  delete: _delete.deleteBranch,
26
17
  create: _create.createBranch,
@@ -31,17 +22,13 @@ const subcommands = {
31
22
  tagVersion: _tagVersion.tagBranchVersion,
32
23
  merge: _merge.mergeBranch
33
24
  };
34
-
35
25
  const commandHandler = async (cli, params) => {
36
26
  const subCommandName = cli.input[1];
37
27
  const subCommand = subcommands[subCommandName];
38
-
39
28
  if (subCommand) {
40
29
  return subCommand(cli, params);
41
30
  }
42
-
43
31
  (0, _fatalError.fatalError)(`Invalid branch command "${subCommandName}"`);
44
32
  };
45
-
46
33
  var _default = commandHandler;
47
34
  exports.default = _default;
@@ -5,27 +5,16 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.buildHandler = buildHandler;
7
7
  exports.default = void 0;
8
-
9
8
  var _path = _interopRequireDefault(require("path"));
10
-
11
9
  var _ssg = require("@takeshape/ssg");
12
-
13
10
  var _files = require("../files");
14
-
15
11
  var _pusher = require("../util/pusher");
16
-
17
12
  var _linkedCommand = require("../util/linked-command");
18
-
19
13
  var _connector = require("../util/connector");
20
-
21
14
  var _runner = require("../util/runner");
22
-
23
15
  var _watcher = require("../util/watcher");
24
-
25
16
  var _branches = require("../util/branches");
26
-
27
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
28
-
29
18
  function buildHandler(config, params) {
30
19
  const {
31
20
  connector
@@ -34,17 +23,13 @@ function buildHandler(config, params) {
34
23
  if (clearCache && connector.clearCache) {
35
24
  await connector.clearCache();
36
25
  }
37
-
38
26
  const pages = await (0, _ssg.generate)(config, params);
39
27
  return (0, _files.writePages)(config.buildPath)(pages);
40
28
  };
41
29
  }
42
-
43
30
  var _default = (0, _linkedCommand.linkedCommand)(async (cli, params) => {
44
31
  const command = cli.input[0];
45
-
46
32
  const sitePath = _path.default.dirname(params.configFilePath);
47
-
48
33
  const fileLoader = (0, _ssg.createFileSystemLoader)(sitePath);
49
34
  const templateFileLoader = (0, _ssg.createSyncFileSystemLoader)(sitePath);
50
35
  const config = await (0, _ssg.loadConfig)(fileLoader, _path.default.basename(params.configFilePath), {
@@ -59,15 +44,12 @@ var _default = (0, _linkedCommand.linkedCommand)(async (cli, params) => {
59
44
  templateFileLoader
60
45
  }));
61
46
  await Promise.all([build(false), (0, _files.copyStatic)(config)]);
62
-
63
47
  if (command === 'watch') {
64
48
  (0, _watcher.createWatcher)('templates', build.bind(null, false), config.templatePath);
65
49
  (0, _watcher.createWatcher)('static', (0, _files.syncStatic)(config), config.staticPath);
66
-
67
50
  if (params.watchContent) {
68
51
  await (0, _pusher.subscribe)(params, build.bind(null, true));
69
52
  }
70
53
  }
71
54
  });
72
-
73
55
  exports.default = _default;
@@ -5,33 +5,20 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  exports.successMessage = successMessage;
8
-
9
8
  var _path = _interopRequireDefault(require("path"));
10
-
11
9
  var _glob = _interopRequireDefault(require("glob"));
12
-
13
10
  var _ssg = require("@takeshape/ssg");
14
-
15
11
  var _linkedCommand = require("../../util/linked-command");
16
-
17
12
  var _zip = require("./zip");
18
-
19
13
  var _log = _interopRequireDefault(require("../../log"));
20
-
21
14
  var _chalk = _interopRequireDefault(require("chalk"));
22
-
23
15
  var _prettyBytes = _interopRequireDefault(require("pretty-bytes"));
24
-
25
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26
-
27
17
  function countFiles(projectPath, config) {
28
18
  const staticFiles = _glob.default.sync(`${_path.default.join(projectPath, config.staticPath)}/**/*.*`);
29
-
30
19
  const templateFiles = _glob.default.sync(`${_path.default.join(projectPath, config.templatePath)}/**/*.*`);
31
-
32
20
  return staticFiles.length + templateFiles.length;
33
21
  }
34
-
35
22
  function successMessage({
36
23
  siteName,
37
24
  zipSize,
@@ -42,18 +29,14 @@ function successMessage({
42
29
  (0, _log.default)(`Deploy Size: ${_chalk.default.green((0, _prettyBytes.default)(zipSize))}`);
43
30
  (0, _log.default)(`Files Deployed: ${_chalk.default.green(`${fileCount}`)}`);
44
31
  }
45
-
46
32
  var _default = (0, _linkedCommand.linkedCommand)(async (_, params) => {
47
33
  if (!params.siteId || !params.siteName) {
48
34
  (0, _log.default)('Error: no site selected. Please run `takeshape link`.');
49
35
  process.exit(1);
50
36
  }
51
-
52
37
  try {
53
38
  const projectPath = _path.default.dirname(params.configFilePath);
54
-
55
39
  const configFilename = _path.default.basename(params.configFilePath);
56
-
57
40
  const config = await (0, _ssg.loadConfig)((0, _ssg.createFileSystemLoader)(projectPath), configFilename);
58
41
  const zipSize = await (0, _zip.deployZip)({
59
42
  config,
@@ -70,5 +53,4 @@ var _default = (0, _linkedCommand.linkedCommand)(async (_, params) => {
70
53
  process.exit(1);
71
54
  }
72
55
  });
73
-
74
56
  exports.default = _default;
@@ -5,19 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createZip = createZip;
7
7
  exports.deployZip = deployZip;
8
-
9
8
  var _path = _interopRequireDefault(require("path"));
10
-
11
9
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
12
-
13
10
  var _archiver = _interopRequireDefault(require("archiver"));
14
-
15
11
  var _streamToPromise = _interopRequireDefault(require("stream-to-promise"));
16
-
17
12
  var _upload = require("../../util/upload");
18
-
19
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
14
  async function createZip({
22
15
  projectPath,
23
16
  staticPath,
@@ -26,7 +19,6 @@ async function createZip({
26
19
  zipPath
27
20
  }) {
28
21
  const output = _fsExtra.default.createWriteStream(zipPath);
29
-
30
22
  const archive = (0, _archiver.default)('zip');
31
23
  archive.pipe(output);
32
24
  archive.file(configFilePath, {
@@ -37,10 +29,8 @@ async function createZip({
37
29
  await archive.finalize();
38
30
  return (0, _streamToPromise.default)(output);
39
31
  }
40
-
41
32
  async function deployZip(params) {
42
33
  const [zipPath, removeTempFile] = (0, _upload.createTempFile)('deploy.zip');
43
-
44
34
  try {
45
35
  const [uploadUrl] = await Promise.all([(0, _upload.getUploadUrl)(params.params), createZip({
46
36
  zipPath,
@@ -4,20 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _projectExport = _interopRequireDefault(require("./project-export"));
9
-
10
8
  var _schemaExport = _interopRequireDefault(require("./schema-export"));
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  const commandHandler = async (cli, params) => {
15
11
  if (cli.flags.schema) {
16
12
  return (0, _schemaExport.default)(cli, params);
17
13
  }
18
-
19
14
  return (0, _projectExport.default)(cli, params);
20
15
  };
21
-
22
16
  var _default = commandHandler;
23
17
  exports.default = _default;