@knocklabs/cli 0.2.1 → 0.2.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/README.md +258 -36
- package/dist/commands/branch/create.js +1 -1
- package/dist/commands/branch/delete.js +1 -1
- package/dist/commands/branch/exit.js +44 -0
- package/dist/commands/branch/switch.js +161 -0
- package/dist/commands/commit/get.js +4 -4
- package/dist/commands/commit/index.js +47 -2
- package/dist/commands/commit/list.js +61 -13
- package/dist/commands/guide/activate.js +48 -4
- package/dist/commands/guide/generate-types.js +4 -1
- package/dist/commands/guide/get.js +46 -3
- package/dist/commands/guide/list.js +46 -3
- package/dist/commands/guide/pull.js +6 -4
- package/dist/commands/guide/push.js +4 -3
- package/dist/commands/guide/validate.js +4 -3
- package/dist/commands/layout/get.js +46 -1
- package/dist/commands/layout/list.js +46 -1
- package/dist/commands/layout/pull.js +6 -2
- package/dist/commands/layout/push.js +4 -1
- package/dist/commands/layout/validate.js +4 -1
- package/dist/commands/login.js +1 -0
- package/dist/commands/logout.js +1 -0
- package/dist/commands/message-type/get.js +46 -3
- package/dist/commands/message-type/list.js +46 -3
- package/dist/commands/message-type/pull.js +6 -4
- package/dist/commands/message-type/push.js +4 -3
- package/dist/commands/message-type/validate.js +4 -3
- package/dist/commands/partial/get.js +46 -1
- package/dist/commands/partial/list.js +46 -1
- package/dist/commands/partial/pull.js +6 -2
- package/dist/commands/partial/push.js +4 -1
- package/dist/commands/partial/validate.js +6 -1
- package/dist/commands/pull.js +28 -8
- package/dist/commands/push.js +27 -8
- package/dist/commands/translation/get.js +5 -1
- package/dist/commands/translation/list.js +5 -1
- package/dist/commands/translation/pull.js +8 -3
- package/dist/commands/translation/push.js +4 -1
- package/dist/commands/translation/validate.js +4 -1
- package/dist/commands/workflow/activate.js +47 -3
- package/dist/commands/workflow/generate-types.js +4 -1
- package/dist/commands/workflow/get.js +9 -4
- package/dist/commands/workflow/list.js +5 -1
- package/dist/commands/workflow/pull.js +6 -2
- package/dist/commands/workflow/push.js +4 -1
- package/dist/commands/workflow/run.js +46 -2
- package/dist/commands/workflow/validate.js +4 -1
- package/dist/lib/api-v1.js +35 -12
- package/dist/lib/helpers/arg.js +6 -5
- package/dist/lib/helpers/branch.js +124 -0
- package/dist/lib/helpers/command.js +14 -0
- package/dist/lib/helpers/error.js +5 -0
- package/dist/lib/helpers/flag.js +23 -0
- package/dist/lib/helpers/git.js +25 -0
- package/dist/lib/helpers/request.js +1 -1
- package/dist/lib/helpers/string.js +4 -0
- package/dist/lib/marshal/commit/index.js +0 -1
- package/dist/lib/marshal/translation/helpers.js +1 -1
- package/dist/lib/resources.js +6 -1
- package/dist/lib/urls.js +4 -0
- package/oclif.manifest.json +414 -50
- package/package.json +15 -5
- package/dist/commands/ping.js +0 -37
- package/dist/lib/marshal/commit/types.js +0 -5
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "formatCommandScope", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return formatCommandScope;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const formatCommandScope = (flags)=>{
|
|
12
|
+
const { environment, branch } = flags;
|
|
13
|
+
return `\`${branch !== null && branch !== void 0 ? branch : environment}\` ${branch ? "branch" : "environment"}`;
|
|
14
|
+
};
|
|
@@ -58,6 +58,11 @@ class CustomError extends Error {
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
class ApiError extends CustomError {
|
|
61
|
+
constructor(message, status, code){
|
|
62
|
+
super(message), _define_property(this, "status", void 0), _define_property(this, "code", void 0);
|
|
63
|
+
this.status = status;
|
|
64
|
+
this.code = code;
|
|
65
|
+
}
|
|
61
66
|
}
|
|
62
67
|
class JsonSyntaxError extends CustomError {
|
|
63
68
|
}
|
package/dist/lib/helpers/flag.js
CHANGED
|
@@ -12,6 +12,9 @@ _export(exports, {
|
|
|
12
12
|
get booleanStr () {
|
|
13
13
|
return booleanStr;
|
|
14
14
|
},
|
|
15
|
+
get branch () {
|
|
16
|
+
return branch;
|
|
17
|
+
},
|
|
15
18
|
get dirPath () {
|
|
16
19
|
return dirPath;
|
|
17
20
|
},
|
|
@@ -31,7 +34,10 @@ _export(exports, {
|
|
|
31
34
|
const _nodepath = /*#__PURE__*/ _interop_require_wildcard(require("node:path"));
|
|
32
35
|
const _core = require("@oclif/core");
|
|
33
36
|
const _fsextra = /*#__PURE__*/ _interop_require_wildcard(require("fs-extra"));
|
|
37
|
+
const _lodash = require("lodash");
|
|
38
|
+
const _branch = require("./branch");
|
|
34
39
|
const _json = require("./json");
|
|
40
|
+
const _string = require("./string");
|
|
35
41
|
function _getRequireWildcardCache(nodeInterop) {
|
|
36
42
|
if (typeof WeakMap !== "function") return null;
|
|
37
43
|
var cacheBabelInterop = new WeakMap();
|
|
@@ -131,3 +137,20 @@ const maybeJsonStrAsList = _core.Flags.custom({
|
|
|
131
137
|
];
|
|
132
138
|
}
|
|
133
139
|
});
|
|
140
|
+
const slug = _core.Flags.custom({
|
|
141
|
+
parse: async (str)=>{
|
|
142
|
+
const slugifiedInput = (0, _string.slugify)(str);
|
|
143
|
+
if (!slugifiedInput) {
|
|
144
|
+
throw new Error("Invalid slug provided");
|
|
145
|
+
}
|
|
146
|
+
return slugifiedInput;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
const branch = slug({
|
|
150
|
+
summary: "The slug of the branch to use.",
|
|
151
|
+
// TODO Hide until branching is released in GA
|
|
152
|
+
hidden: true,
|
|
153
|
+
// Memoize this flag's default. oclif runs this default function even when the flag is unused.
|
|
154
|
+
// Using lodash's once avoids unnecessarily reading the branch file multiple times.
|
|
155
|
+
default: (0, _lodash.once)(_branch.readSlugFromBranchFile)
|
|
156
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "isFileIgnoredByGit", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return isFileIgnoredByGit;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _nodechild_process = require("node:child_process");
|
|
12
|
+
const isFileIgnoredByGit = async (currDir, filePath)=>{
|
|
13
|
+
try {
|
|
14
|
+
(0, _nodechild_process.execSync)(`git check-ignore "${filePath}"`, {
|
|
15
|
+
cwd: currDir,
|
|
16
|
+
// Suppress output since we only care about exit status
|
|
17
|
+
stdio: "pipe"
|
|
18
|
+
});
|
|
19
|
+
// If we reach here, git check-ignore returned exit status 0 (file is ignored)
|
|
20
|
+
// See https://git-scm.com/docs/git-check-ignore#_exit_status
|
|
21
|
+
return true;
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
@@ -90,7 +90,7 @@ const withSpinnerV2 = async (requestFn, opts = {})=>{
|
|
|
90
90
|
} catch (error) {
|
|
91
91
|
if (error instanceof _mgmt.default.APIError) {
|
|
92
92
|
const message = formatMgmtError(error);
|
|
93
|
-
return _core.ux.error(new _error.ApiError(message));
|
|
93
|
+
return _core.ux.error(new _error.ApiError(message, error.status, error.error.code));
|
|
94
94
|
}
|
|
95
95
|
throw error;
|
|
96
96
|
}
|
|
@@ -16,6 +16,9 @@ _export(exports, {
|
|
|
16
16
|
},
|
|
17
17
|
get indentString () {
|
|
18
18
|
return indentString;
|
|
19
|
+
},
|
|
20
|
+
get slugify () {
|
|
21
|
+
return slugify;
|
|
19
22
|
}
|
|
20
23
|
});
|
|
21
24
|
const SLUG_FORMAT_RE = /^[\w-]+$/;
|
|
@@ -44,3 +47,4 @@ const indentString = (string, count = 0, options = {})=>{
|
|
|
44
47
|
const regex = includeEmptyLines ? /^/gm : /^(?!\s*$)/gm;
|
|
45
48
|
return string.replace(regex, indent.repeat(count));
|
|
46
49
|
};
|
|
50
|
+
const slugify = (input)=>input.toLowerCase().trim().replace(/\s+/g, "-");
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
5
|
_export_star(require("./helpers"), exports);
|
|
6
|
-
_export_star(require("./types"), exports);
|
|
7
6
|
function _export_star(from, to) {
|
|
8
7
|
Object.keys(from).forEach(function(k) {
|
|
9
8
|
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
@@ -178,7 +178,7 @@ const ensureValidCommandTarget = async (props, runContext)=>{
|
|
|
178
178
|
if (resourceDirCtx && resourceDirCtx.key !== localeCode) {
|
|
179
179
|
return _core.ux.error(`Cannot run ${commandId} with \`${args.translationRef}\` inside a ${resourceDirCtx.key} directory`);
|
|
180
180
|
}
|
|
181
|
-
const targetDirPath = resourceDirCtx ? resourceDirCtx.abspath : _nodepath.resolve(runCwd, localeCode);
|
|
181
|
+
const targetDirPath = resourceDirCtx ? resourceDirCtx.abspath : flags["translations-dir"] ? _nodepath.resolve(flags["translations-dir"].abspath, localeCode) : _nodepath.resolve(runCwd, localeCode);
|
|
182
182
|
// Got translationRef arg but no --all flag, which means target only a single
|
|
183
183
|
// translation file.
|
|
184
184
|
if (!flags.all) {
|
package/dist/lib/resources.js
CHANGED
|
@@ -22,11 +22,16 @@ const ALL_RESOURCE_TYPES = [
|
|
|
22
22
|
// Email layouts next, as workflows with email channel steps may reference them
|
|
23
23
|
"email_layout",
|
|
24
24
|
"workflow",
|
|
25
|
+
// Message types then guides, as guides use message types.
|
|
26
|
+
"message_type",
|
|
27
|
+
"guide",
|
|
25
28
|
"translation"
|
|
26
29
|
];
|
|
27
30
|
const RESOURCE_SUBDIRS = {
|
|
28
31
|
email_layout: "layouts",
|
|
29
32
|
partial: "partials",
|
|
30
33
|
translation: "translations",
|
|
31
|
-
workflow: "workflows"
|
|
34
|
+
workflow: "workflows",
|
|
35
|
+
message_type: "message-types",
|
|
36
|
+
guide: "guides"
|
|
32
37
|
};
|
package/dist/lib/urls.js
CHANGED
|
@@ -23,6 +23,9 @@ _export(exports, {
|
|
|
23
23
|
},
|
|
24
24
|
get authSuccessUrl () {
|
|
25
25
|
return authSuccessUrl;
|
|
26
|
+
},
|
|
27
|
+
get viewWorkflowUrl () {
|
|
28
|
+
return viewWorkflowUrl;
|
|
26
29
|
}
|
|
27
30
|
});
|
|
28
31
|
const DEFAULT_DASHBOARD_URL = "https://dashboard.knock.app";
|
|
@@ -30,3 +33,4 @@ const DEFAULT_AUTH_URL = "https://signin.knock.app";
|
|
|
30
33
|
const DEFAULT_API_URL = "https://control.knock.app";
|
|
31
34
|
const authSuccessUrl = (dashboardUrl)=>`${dashboardUrl}/auth/oauth/cli`;
|
|
32
35
|
const authErrorUrl = (dashboardUrl, error)=>`${dashboardUrl}/auth/oauth/cli?error=${error}`;
|
|
36
|
+
const viewWorkflowUrl = (dashboardUrl, accountSlug, envOrBranchSlug, workflowKey)=>`${dashboardUrl}/${accountSlug}/${envOrBranchSlug.toLowerCase()}/workflows/${workflowKey}`;
|