@knocklabs/cli 1.0.0-rc.1 → 1.0.2

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 (34) hide show
  1. package/README.md +332 -64
  2. package/dist/commands/audience/archive.js +120 -0
  3. package/dist/commands/audience/get.js +169 -0
  4. package/dist/commands/audience/list.js +159 -0
  5. package/dist/commands/audience/new.js +243 -0
  6. package/dist/commands/audience/open.js +106 -0
  7. package/dist/commands/audience/pull.js +214 -0
  8. package/dist/commands/audience/push.js +167 -0
  9. package/dist/commands/audience/validate.js +147 -0
  10. package/dist/commands/branch/create.js +40 -3
  11. package/dist/commands/branch/list.js +14 -9
  12. package/dist/commands/branch/switch.js +7 -2
  13. package/dist/commands/guide/open.js +106 -0
  14. package/dist/commands/layout/open.js +106 -0
  15. package/dist/commands/message-type/open.js +106 -0
  16. package/dist/commands/partial/open.js +106 -0
  17. package/dist/commands/pull.js +19 -12
  18. package/dist/commands/push.js +19 -12
  19. package/dist/commands/workflow/open.js +106 -0
  20. package/dist/lib/helpers/git.js +22 -3
  21. package/dist/lib/helpers/project-config.js +1 -0
  22. package/dist/lib/marshal/audience/generator.js +38 -0
  23. package/dist/lib/marshal/audience/helpers.js +142 -0
  24. package/dist/lib/marshal/audience/index.js +23 -0
  25. package/dist/lib/marshal/audience/processor.isomorphic.js +25 -0
  26. package/dist/lib/marshal/audience/reader.js +149 -0
  27. package/dist/lib/marshal/audience/types.js +15 -0
  28. package/dist/lib/marshal/audience/writer.js +177 -0
  29. package/dist/lib/marshal/index.isomorphic.js +18 -14
  30. package/dist/lib/resources.js +3 -0
  31. package/dist/lib/run-context/loader.js +12 -20
  32. package/dist/lib/urls.js +20 -0
  33. package/oclif.manifest.json +1368 -430
  34. package/package.json +11 -11
@@ -8,9 +8,13 @@ Object.defineProperty(exports, "default", {
8
8
  return BranchCreate;
9
9
  }
10
10
  });
11
+ const _enquirer = require("enquirer");
11
12
  const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
12
13
  const _arg = require("../../lib/helpers/arg");
14
+ const _const = require("../../lib/helpers/const");
15
+ const _git = require("../../lib/helpers/git");
13
16
  const _request = require("../../lib/helpers/request");
17
+ const _string = require("../../lib/helpers/string");
14
18
  function _define_property(obj, key, value) {
15
19
  if (key in obj) {
16
20
  Object.defineProperty(obj, key, {
@@ -32,12 +36,45 @@ function _interop_require_default(obj) {
32
36
  class BranchCreate extends _basecommand.default {
33
37
  async run() {
34
38
  const { args, flags } = this.props;
35
- const resp = await this.request(args.slug);
39
+ // If slug is provided, use it directly
40
+ let slug = args.slug;
41
+ // Otherwise, prompt for it with Git branch as default
42
+ if (!slug) {
43
+ slug = await this.promptForBranchSlug();
44
+ }
45
+ if (!slug) {
46
+ return this.error("Invalid slug provided");
47
+ }
48
+ const resp = await this.request(slug);
36
49
  if (flags.json) return resp;
37
50
  this.render(resp);
38
51
  }
52
+ async promptForBranchSlug() {
53
+ const gitBranch = (0, _git.getCurrentGitBranch)();
54
+ const initial = gitBranch ? (0, _string.slugify)(gitBranch) : undefined;
55
+ try {
56
+ const response = await (0, _enquirer.prompt)({
57
+ type: "input",
58
+ name: "slug",
59
+ message: "Branch slug",
60
+ initial,
61
+ validate: (value)=>{
62
+ const slugified = (0, _string.slugify)(value);
63
+ if (!slugified) {
64
+ return "Invalid slug provided";
65
+ }
66
+ return true;
67
+ }
68
+ });
69
+ return (0, _string.slugify)(response.slug);
70
+ } catch {
71
+ return undefined;
72
+ }
73
+ }
39
74
  async request(slug) {
40
- return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.post(`/v1/branches/${slug}`));
75
+ return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.branches.create(slug, {
76
+ environment: _const.KnockEnv.Development
77
+ }));
41
78
  }
42
79
  async render(data) {
43
80
  this.log(`‣ Successfully created branch \`${data.slug}\``);
@@ -48,7 +85,7 @@ _define_property(BranchCreate, "summary", "Creates a new branch off of the devel
48
85
  _define_property(BranchCreate, "enableJsonFlag", true);
49
86
  _define_property(BranchCreate, "args", {
50
87
  slug: _arg.CustomArgs.slug({
51
- required: true,
88
+ required: false,
52
89
  description: "The slug for the new branch"
53
90
  })
54
91
  });
@@ -10,6 +10,7 @@ Object.defineProperty(exports, "default", {
10
10
  });
11
11
  const _core = require("@oclif/core");
12
12
  const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _const = require("../../lib/helpers/const");
13
14
  const _date = require("../../lib/helpers/date");
14
15
  const _page = require("../../lib/helpers/page");
15
16
  const _request = require("../../lib/helpers/request");
@@ -43,28 +44,32 @@ class BranchList extends _basecommand.default {
43
44
  ...this.props.flags,
44
45
  ...pageParams
45
46
  });
46
- return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.get("/v1/branches", {
47
- query: queryParams
47
+ return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.branches.list({
48
+ environment: _const.KnockEnv.Development,
49
+ ...queryParams
48
50
  }));
49
51
  }
50
52
  async render(data) {
51
53
  const { entries } = data;
52
54
  this.log(`‣ Showing ${entries.length} branches off of the development environment\n`);
53
- _core.ux.table(entries, {
55
+ const formattedBranches = entries.map((entry)=>({
56
+ slug: entry.slug,
57
+ created_at: (0, _date.formatDate)(entry.created_at),
58
+ updated_at: (0, _date.formatDate)(entry.updated_at),
59
+ last_commit_at: entry.last_commit_at ? (0, _date.formatDate)(entry.last_commit_at) : "Never"
60
+ }));
61
+ _core.ux.table(formattedBranches, {
54
62
  slug: {
55
63
  header: "Slug"
56
64
  },
57
65
  created_at: {
58
- header: "Created at",
59
- get: (entry)=>(0, _date.formatDate)(entry.created_at)
66
+ header: "Created at"
60
67
  },
61
68
  updated_at: {
62
- header: "Updated at",
63
- get: (entry)=>(0, _date.formatDate)(entry.updated_at)
69
+ header: "Updated at"
64
70
  },
65
71
  last_commit_at: {
66
- header: "Last commit at",
67
- get: (entry)=>entry.last_commit_at ? (0, _date.formatDate)(entry.last_commit_at) : "Never"
72
+ header: "Last commit at"
68
73
  }
69
74
  });
70
75
  return this.prompt(data);
@@ -15,6 +15,7 @@ const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
15
15
  const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
16
16
  const _arg = require("../../lib/helpers/arg");
17
17
  const _branch = require("../../lib/helpers/branch");
18
+ const _const = require("../../lib/helpers/const");
18
19
  const _error = require("../../lib/helpers/error");
19
20
  const _git = require("../../lib/helpers/git");
20
21
  const _request = require("../../lib/helpers/request");
@@ -132,12 +133,16 @@ class BranchSwitch extends _basecommand.default {
132
133
  }
133
134
  }
134
135
  async fetchBranch(slug) {
135
- return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.get(`/v1/branches/${slug}`), {
136
+ return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.branches.retrieve(slug, {
137
+ environment: _const.KnockEnv.Development
138
+ }), {
136
139
  action: "‣ Fetching branch"
137
140
  });
138
141
  }
139
142
  async createBranch(slug) {
140
- return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.post(`/v1/branches/${slug}`), {
143
+ return (0, _request.withSpinnerV2)(()=>this.apiV1.mgmtClient.branches.create(slug, {
144
+ environment: _const.KnockEnv.Development
145
+ }), {
141
146
  action: "‣ Creating branch"
142
147
  });
143
148
  }
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return GuideOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class GuideOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { guideKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewGuideUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, guideKey);
89
+ this.log(`‣ Opening guide \`${guideKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(GuideOpen, "summary", "Open a guide in the Knock dashboard.");
95
+ _define_property(GuideOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(GuideOpen, "args", {
103
+ guideKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return LayoutOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class LayoutOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { layoutKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewLayoutUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, layoutKey);
89
+ this.log(`‣ Opening layout \`${layoutKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(LayoutOpen, "summary", "Open a layout in the Knock dashboard.");
95
+ _define_property(LayoutOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(LayoutOpen, "args", {
103
+ layoutKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return MessageTypeOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class MessageTypeOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { messageTypeKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewMessageTypeUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, messageTypeKey);
89
+ this.log(`‣ Opening message type \`${messageTypeKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(MessageTypeOpen, "summary", "Open a message type in the Knock dashboard.");
95
+ _define_property(MessageTypeOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(MessageTypeOpen, "args", {
103
+ messageTypeKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "default", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return PartialOpen;
9
+ }
10
+ });
11
+ const _core = require("@oclif/core");
12
+ const _basecommand = /*#__PURE__*/ _interop_require_default(require("../../lib/base-command"));
13
+ const _browser = require("../../lib/helpers/browser");
14
+ const _error = require("../../lib/helpers/error");
15
+ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../../lib/helpers/flag"));
16
+ const _request = require("../../lib/helpers/request");
17
+ const _urls = require("../../lib/urls");
18
+ function _define_property(obj, key, value) {
19
+ if (key in obj) {
20
+ Object.defineProperty(obj, key, {
21
+ value: value,
22
+ enumerable: true,
23
+ configurable: true,
24
+ writable: true
25
+ });
26
+ } else {
27
+ obj[key] = value;
28
+ }
29
+ return obj;
30
+ }
31
+ function _interop_require_default(obj) {
32
+ return obj && obj.__esModule ? obj : {
33
+ default: obj
34
+ };
35
+ }
36
+ function _getRequireWildcardCache(nodeInterop) {
37
+ if (typeof WeakMap !== "function") return null;
38
+ var cacheBabelInterop = new WeakMap();
39
+ var cacheNodeInterop = new WeakMap();
40
+ return (_getRequireWildcardCache = function(nodeInterop) {
41
+ return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
42
+ })(nodeInterop);
43
+ }
44
+ function _interop_require_wildcard(obj, nodeInterop) {
45
+ if (!nodeInterop && obj && obj.__esModule) {
46
+ return obj;
47
+ }
48
+ if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
49
+ return {
50
+ default: obj
51
+ };
52
+ }
53
+ var cache = _getRequireWildcardCache(nodeInterop);
54
+ if (cache && cache.has(obj)) {
55
+ return cache.get(obj);
56
+ }
57
+ var newObj = {
58
+ __proto__: null
59
+ };
60
+ var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
61
+ for(var key in obj){
62
+ if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
63
+ var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
64
+ if (desc && (desc.get || desc.set)) {
65
+ Object.defineProperty(newObj, key, desc);
66
+ } else {
67
+ newObj[key] = obj[key];
68
+ }
69
+ }
70
+ }
71
+ newObj.default = obj;
72
+ if (cache) {
73
+ cache.set(obj, newObj);
74
+ }
75
+ return newObj;
76
+ }
77
+ class PartialOpen extends _basecommand.default {
78
+ async run() {
79
+ const whoamiResp = await this.apiV1.whoami();
80
+ if (!(0, _request.isSuccessResp)(whoamiResp)) {
81
+ const message = (0, _request.formatErrorRespMessage)(whoamiResp);
82
+ _core.ux.error(new _error.ApiError(message));
83
+ }
84
+ const { account_slug } = whoamiResp.data;
85
+ const { partialKey } = this.props.args;
86
+ const { environment, branch } = this.props.flags;
87
+ const envOrBranch = branch !== null && branch !== void 0 ? branch : environment;
88
+ const url = (0, _urls.viewPartialUrl)(this.sessionContext.dashboardOrigin, account_slug, envOrBranch, partialKey);
89
+ this.log(`‣ Opening partial \`${partialKey}\` in the Knock dashboard...`);
90
+ this.log(` ${url}`);
91
+ await _browser.browser.openUrl(url);
92
+ }
93
+ }
94
+ _define_property(PartialOpen, "summary", "Open a partial in the Knock dashboard.");
95
+ _define_property(PartialOpen, "flags", {
96
+ environment: _core.Flags.string({
97
+ default: "development",
98
+ summary: "The environment to use."
99
+ }),
100
+ branch: _flag.branch
101
+ });
102
+ _define_property(PartialOpen, "args", {
103
+ partialKey: _core.Args.string({
104
+ required: true
105
+ })
106
+ });
@@ -15,12 +15,13 @@ const _flag = /*#__PURE__*/ _interop_require_wildcard(require("../lib/helpers/fl
15
15
  const _projectconfig = require("../lib/helpers/project-config");
16
16
  const _ux = require("../lib/helpers/ux");
17
17
  const _resources = require("../lib/resources");
18
- const _pull = /*#__PURE__*/ _interop_require_default(require("./guide/pull"));
19
- const _pull1 = /*#__PURE__*/ _interop_require_default(require("./layout/pull"));
20
- const _pull2 = /*#__PURE__*/ _interop_require_default(require("./message-type/pull"));
21
- const _pull3 = /*#__PURE__*/ _interop_require_default(require("./partial/pull"));
22
- const _pull4 = /*#__PURE__*/ _interop_require_default(require("./translation/pull"));
23
- const _pull5 = /*#__PURE__*/ _interop_require_default(require("./workflow/pull"));
18
+ const _pull = /*#__PURE__*/ _interop_require_default(require("./audience/pull"));
19
+ const _pull1 = /*#__PURE__*/ _interop_require_default(require("./guide/pull"));
20
+ const _pull2 = /*#__PURE__*/ _interop_require_default(require("./layout/pull"));
21
+ const _pull3 = /*#__PURE__*/ _interop_require_default(require("./message-type/pull"));
22
+ const _pull4 = /*#__PURE__*/ _interop_require_default(require("./partial/pull"));
23
+ const _pull5 = /*#__PURE__*/ _interop_require_default(require("./translation/pull"));
24
+ const _pull6 = /*#__PURE__*/ _interop_require_default(require("./workflow/pull"));
24
25
  function _define_property(obj, key, value) {
25
26
  if (key in obj) {
26
27
  Object.defineProperty(obj, key, {
@@ -140,39 +141,45 @@ _define_property(Pull, "flags", {
140
141
  const runResourcePullCommand = async (resourceType, targetDirCtx, args)=>{
141
142
  const subdirPath = _nodepath.resolve(targetDirCtx.abspath, _resources.RESOURCE_SUBDIRS[resourceType]);
142
143
  switch(resourceType){
144
+ case "audience":
145
+ return _pull.default.run([
146
+ ...args,
147
+ "--audiences-dir",
148
+ subdirPath
149
+ ]);
143
150
  case "email_layout":
144
- return _pull1.default.run([
151
+ return _pull2.default.run([
145
152
  ...args,
146
153
  "--layouts-dir",
147
154
  subdirPath
148
155
  ]);
149
156
  case "partial":
150
- return _pull3.default.run([
157
+ return _pull4.default.run([
151
158
  ...args,
152
159
  "--partials-dir",
153
160
  subdirPath
154
161
  ]);
155
162
  // TODO(KNO-9451): Include translation in the knock pull
156
163
  case "translation":
157
- return _pull4.default.run([
164
+ return _pull5.default.run([
158
165
  ...args,
159
166
  "--translations-dir",
160
167
  subdirPath
161
168
  ]);
162
169
  case "workflow":
163
- return _pull5.default.run([
170
+ return _pull6.default.run([
164
171
  ...args,
165
172
  "--workflows-dir",
166
173
  subdirPath
167
174
  ]);
168
175
  case "message_type":
169
- return _pull2.default.run([
176
+ return _pull3.default.run([
170
177
  ...args,
171
178
  "--message-types-dir",
172
179
  subdirPath
173
180
  ]);
174
181
  case "guide":
175
- return _pull.default.run([
182
+ return _pull1.default.run([
176
183
  ...args,
177
184
  "--guides-dir",
178
185
  subdirPath