@knocklabs/cli 1.0.3 → 1.0.5

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.
@@ -77,17 +77,29 @@ function _interop_require_wildcard(obj, nodeInterop) {
77
77
  class Commit extends _basecommand.default {
78
78
  async run() {
79
79
  const { flags } = this.props;
80
+ if (flags["resource-id"] && !flags["resource-type"]) {
81
+ this.error("The --resource-id flag must be used together with --resource-type.");
82
+ }
80
83
  const scope = (0, _command.formatCommandScope)(flags);
81
- // Confirm first as we are about to commit changes to go live in the
82
- // development environment, unless forced.
83
- const prompt = `Commit all changes in the ${scope}?`;
84
+ const qualifier = this.formatResourceQualifier(flags);
85
+ const prompt = qualifier ? `Commit ${qualifier} in the ${scope}?` : `Commit all changes in the ${scope}?`;
84
86
  const input = flags.force || await (0, _ux.promptToConfirm)(prompt);
85
87
  if (!input) return;
86
88
  await (0, _request.withSpinner)(()=>this.apiV1.commitAllChanges(this.props));
87
- this.log(`‣ Successfully committed all changes in ${scope}`);
89
+ const successMsg = qualifier ? `‣ Successfully committed ${qualifier} in ${scope}` : `‣ Successfully committed all changes in ${scope}`;
90
+ this.log(successMsg);
91
+ }
92
+ formatResourceQualifier(flags) {
93
+ if (flags["resource-type"] && flags["resource-id"]) {
94
+ return `\`${flags["resource-type"]}\` changes for \`${flags["resource-id"]}\``;
95
+ }
96
+ if (flags["resource-type"]) {
97
+ return `all \`${flags["resource-type"]}\` changes`;
98
+ }
99
+ return null;
88
100
  }
89
101
  }
90
- _define_property(Commit, "summary", "Commit all changes in development environment.");
102
+ _define_property(Commit, "summary", "Commit all changes in development environment, or only changes for a specific resource type.");
91
103
  _define_property(Commit, "flags", {
92
104
  environment: _core.Flags.string({
93
105
  summary: "Committing changes applies to the development environment only, use `commit promote` to promote changes to a subsequent environment.",
@@ -103,5 +115,19 @@ _define_property(Commit, "flags", {
103
115
  }),
104
116
  force: _core.Flags.boolean({
105
117
  summary: "Remove the confirmation prompt."
118
+ }),
119
+ "resource-type": _core.Flags.string({
120
+ summary: "Commit only changes for the given resource type. Can be used alone or together with --resource-id.",
121
+ options: [
122
+ "email_layout",
123
+ "guide",
124
+ "message_type",
125
+ "partial",
126
+ "translation",
127
+ "workflow"
128
+ ]
129
+ }),
130
+ "resource-id": _core.Flags.string({
131
+ summary: "Commit only changes for the given resource identifier. Must be used together with --resource-type."
106
132
  })
107
133
  });
@@ -138,7 +138,9 @@ class ApiV1 {
138
138
  const params = (0, _objectisomorphic.prune)({
139
139
  environment: flags.environment,
140
140
  branch: flags.branch,
141
- commit_message: flags["commit-message"]
141
+ commit_message: flags["commit-message"],
142
+ resource_type: flags["resource-type"],
143
+ resource_id: flags["resource-id"]
142
144
  });
143
145
  return this.put(`/commits`, {}, {
144
146
  params
@@ -22,7 +22,7 @@ _export(exports, {
22
22
  return tryJsonParse;
23
23
  }
24
24
  });
25
- const _jsonlint = /*#__PURE__*/ _interop_require_wildcard(require("@prantlf/jsonlint"));
25
+ const _jsonlint = /*#__PURE__*/ _interop_require_wildcard(require("@knocklabs/jsonlint"));
26
26
  const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
27
27
  const _error = require("./error");
28
28
  function _getRequireWildcardCache(nodeInterop) {
@@ -73,7 +73,7 @@ const parseJson = (json)=>{
73
73
  try {
74
74
  payload = _jsonlint.parse(json);
75
75
  } catch (error) {
76
- // https://github.com/prantlf/jsonlint#error-handling
76
+ // https://github.com/knocklabs/repackage/tree/main/packages/jsonlint
77
77
  if (!(error instanceof SyntaxError)) throw error;
78
78
  errors.push(new _error.JsonSyntaxError(error.message));
79
79
  }