@knocklabs/cli 1.0.2 → 1.0.4

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.
@@ -112,6 +112,10 @@ class AudiencePush extends _basecommand.default {
112
112
  commit: flags.commit,
113
113
  commit_message: flags["commit-message"],
114
114
  audience: audience.content
115
+ }, {
116
+ query: flags.force ? {
117
+ force: true
118
+ } : undefined
115
119
  });
116
120
  // Update the audience directory with the successfully pushed audience
117
121
  // payload from the server.
@@ -158,7 +162,8 @@ _define_property(AudiencePush, "flags", {
158
162
  dependsOn: [
159
163
  "commit"
160
164
  ]
161
- })
165
+ }),
166
+ force: _flag.force
162
167
  });
163
168
  _define_property(AudiencePush, "args", {
164
169
  audienceKey: _core.Args.string({
@@ -162,7 +162,8 @@ _define_property(GuidePush, "flags", {
162
162
  dependsOn: [
163
163
  "commit"
164
164
  ]
165
- })
165
+ }),
166
+ force: _flag.force
166
167
  });
167
168
  _define_property(GuidePush, "args", {
168
169
  guideKey: _core.Args.string({
@@ -168,7 +168,8 @@ _define_property(EmailLayoutPush, "flags", {
168
168
  dependsOn: [
169
169
  "commit"
170
170
  ]
171
- })
171
+ }),
172
+ force: _flag.force
172
173
  });
173
174
  _define_property(EmailLayoutPush, "args", {
174
175
  emailLayoutKey: _core.Args.string({
@@ -165,7 +165,8 @@ _define_property(MessageTypePush, "flags", {
165
165
  dependsOn: [
166
166
  "commit"
167
167
  ]
168
- })
168
+ }),
169
+ force: _flag.force
169
170
  });
170
171
  _define_property(MessageTypePush, "args", {
171
172
  messageTypeKey: _core.Args.string({
@@ -165,7 +165,8 @@ _define_property(PartialPush, "flags", {
165
165
  dependsOn: [
166
166
  "commit"
167
167
  ]
168
- })
168
+ }),
169
+ force: _flag.force
169
170
  });
170
171
  _define_property(PartialPush, "args", {
171
172
  partialKey: _core.Args.string({
@@ -112,6 +112,9 @@ class Push extends _basecommand.default {
112
112
  ...flags["commit-message"] ? [
113
113
  "--commit-message",
114
114
  flags["commit-message"]
115
+ ] : [],
116
+ ...flags.force ? [
117
+ "--force"
115
118
  ] : []
116
119
  ];
117
120
  // Note: Because we're pushing the different resource types sequentially,
@@ -147,7 +150,8 @@ _define_property(Push, "flags", {
147
150
  dependsOn: [
148
151
  "commit"
149
152
  ]
150
- })
153
+ }),
154
+ force: _flag.force
151
155
  });
152
156
  const runResourcePushCommand = async (resourceType, targetDirCtx, args)=>{
153
157
  const subdirPath = _nodepath.resolve(targetDirCtx.abspath, _resources.RESOURCE_SUBDIRS[resourceType]);
@@ -153,7 +153,8 @@ _define_property(TranslationPush, "flags", {
153
153
  dependsOn: [
154
154
  "commit"
155
155
  ]
156
- })
156
+ }),
157
+ force: _flag.force
157
158
  });
158
159
  _define_property(TranslationPush, "args", {
159
160
  translationRef: _core.Args.string({
@@ -162,7 +162,8 @@ _define_property(WorkflowPush, "flags", {
162
162
  dependsOn: [
163
163
  "commit"
164
164
  ]
165
- })
165
+ }),
166
+ force: _flag.force
166
167
  });
167
168
  _define_property(WorkflowPush, "args", {
168
169
  workflowKey: _core.Args.string({
@@ -73,7 +73,8 @@ class ApiV1 {
73
73
  branch: flags.branch,
74
74
  annotate: flags.annotate,
75
75
  commit: flags.commit,
76
- commit_message: flags["commit-message"]
76
+ commit_message: flags["commit-message"],
77
+ force: flags.force
77
78
  });
78
79
  const data = {
79
80
  workflow
@@ -187,7 +188,8 @@ class ApiV1 {
187
188
  branch: flags.branch,
188
189
  commit: flags.commit,
189
190
  commit_message: flags["commit-message"],
190
- namespace: translation.namespace
191
+ namespace: translation.namespace,
192
+ force: flags.force
191
193
  });
192
194
  return this.put(`/translations/${translation.locale_code}`, {
193
195
  translation
@@ -238,7 +240,8 @@ class ApiV1 {
238
240
  branch: flags.branch,
239
241
  annotate: flags.annotate,
240
242
  commit: flags.commit,
241
- commit_message: flags["commit-message"]
243
+ commit_message: flags["commit-message"],
244
+ force: flags.force
242
245
  });
243
246
  const data = {
244
247
  email_layout: layout
@@ -289,7 +292,8 @@ class ApiV1 {
289
292
  branch: flags.branch,
290
293
  annotate: flags.annotate,
291
294
  commit: flags.commit,
292
- commit_message: flags["commit-message"]
295
+ commit_message: flags["commit-message"],
296
+ force: flags.force
293
297
  });
294
298
  const data = {
295
299
  partial
@@ -347,7 +351,8 @@ class ApiV1 {
347
351
  branch: flags.branch,
348
352
  annotate: flags.annotate,
349
353
  commit: flags.commit,
350
- commit_message: flags["commit-message"]
354
+ commit_message: flags["commit-message"],
355
+ force: flags.force
351
356
  });
352
357
  const data = {
353
358
  message_type: messageType
@@ -411,7 +416,8 @@ class ApiV1 {
411
416
  branch: flags.branch,
412
417
  annotate: flags.annotate,
413
418
  commit: flags.commit,
414
- commit_message: flags["commit-message"]
419
+ commit_message: flags["commit-message"],
420
+ force: flags.force
415
421
  });
416
422
  const data = {
417
423
  guide
@@ -21,6 +21,9 @@ _export(exports, {
21
21
  get filePath () {
22
22
  return filePath;
23
23
  },
24
+ get force () {
25
+ return force;
26
+ },
24
27
  get jsonStr () {
25
28
  return jsonStr;
26
29
  },
@@ -152,3 +155,6 @@ const branch = slug({
152
155
  // Using lodash's once avoids unnecessarily reading the branch file multiple times.
153
156
  default: (0, _lodash.once)(_branch.readSlugFromBranchFile)
154
157
  });
158
+ const force = _core.Flags.boolean({
159
+ summary: "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. " + "If you're using this on a non-development environment, you should also ensure you `commit` the changes."
160
+ });
@@ -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
  }
@@ -103,7 +103,8 @@ const formatLanguage = (translation)=>{
103
103
  const isValidLocale = (localeCode)=>Boolean(_localecodes.default.getByTag(localeCode));
104
104
  const isTranslationDir = (dirPath)=>{
105
105
  const locale = _nodepath.basename(dirPath);
106
- return isValidLocale(locale);
106
+ const parentDirName = _nodepath.basename(_nodepath.dirname(dirPath));
107
+ return parentDirName === "translations" && isValidLocale(locale);
107
108
  };
108
109
  const buildTranslationFileCtx = async (dirPath, translationIdentifier, options)=>{
109
110
  const ref = (0, _processorisomorphic.formatRef)(translationIdentifier.localeCode, translationIdentifier.namespace);
@@ -170,7 +170,7 @@ const readAllForCommandTarget = async (target)=>{
170
170
  const dirents = await _fsextra.readdir(targetCtx.abspath, {
171
171
  withFileTypes: true
172
172
  });
173
- const translationDirPaths = dirents.filter((dirent)=>dirent.isDirectory() && (0, _helpers.isTranslationDir)(dirent.name)).map((dirent)=>_nodepath.resolve(targetCtx.abspath, dirent.name));
173
+ const translationDirPaths = dirents.filter((dirent)=>dirent.isDirectory() && (0, _helpers.isValidLocale)(dirent.name)).map((dirent)=>_nodepath.resolve(targetCtx.abspath, dirent.name));
174
174
  const translationFilePaths = (await Promise.all(translationDirPaths.map(async (abspath)=>(0, _helpers.lsTranslationDir)(abspath)))).flat();
175
175
  return readTranslationFiles(translationFilePaths);
176
176
  }
@@ -85,9 +85,6 @@ const evaluateRecursively = async (ctx, currDir)=>{
85
85
  } else if (await _messagetype.isMessageTypeDir(currDir)) {
86
86
  ctx.resourceDir = buildResourceDirContext("message_type", currDir);
87
87
  } else if (_translation.isTranslationDir(currDir)) {
88
- // NOTE: Must keep this check as last in the order of directory-type checks
89
- // since the `isTranslationDir` only checks that the directory name is a
90
- // valid locale name.
91
88
  ctx.resourceDir = buildResourceDirContext("translation", currDir);
92
89
  }
93
90
  }
@@ -289,6 +289,12 @@
289
289
  "hasDynamicHelp": false,
290
290
  "multiple": false,
291
291
  "type": "option"
292
+ },
293
+ "force": {
294
+ "name": "force",
295
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
296
+ "allowNo": false,
297
+ "type": "boolean"
292
298
  }
293
299
  },
294
300
  "hasDynamicHelp": false,
@@ -901,6 +907,12 @@
901
907
  "hasDynamicHelp": false,
902
908
  "multiple": false,
903
909
  "type": "option"
910
+ },
911
+ "force": {
912
+ "name": "force",
913
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
914
+ "allowNo": false,
915
+ "type": "boolean"
904
916
  }
905
917
  },
906
918
  "hasDynamicHelp": false,
@@ -1318,6 +1330,98 @@
1318
1330
  "switch.js"
1319
1331
  ]
1320
1332
  },
1333
+ "channel:list": {
1334
+ "aliases": [],
1335
+ "args": {},
1336
+ "flags": {
1337
+ "json": {
1338
+ "description": "Format output as json.",
1339
+ "helpGroup": "GLOBAL",
1340
+ "name": "json",
1341
+ "allowNo": false,
1342
+ "type": "boolean"
1343
+ },
1344
+ "service-token": {
1345
+ "env": "KNOCK_SERVICE_TOKEN",
1346
+ "name": "service-token",
1347
+ "required": false,
1348
+ "summary": "The service token to authenticate with.",
1349
+ "hasDynamicHelp": false,
1350
+ "multiple": false,
1351
+ "type": "option"
1352
+ },
1353
+ "api-origin": {
1354
+ "hidden": true,
1355
+ "name": "api-origin",
1356
+ "required": false,
1357
+ "hasDynamicHelp": false,
1358
+ "multiple": false,
1359
+ "type": "option"
1360
+ }
1361
+ },
1362
+ "hasDynamicHelp": false,
1363
+ "hiddenAliases": [],
1364
+ "id": "channel:list",
1365
+ "pluginAlias": "@knocklabs/cli",
1366
+ "pluginName": "@knocklabs/cli",
1367
+ "pluginType": "core",
1368
+ "strict": true,
1369
+ "summary": "Display all channels configured for the account.",
1370
+ "enableJsonFlag": true,
1371
+ "isESM": false,
1372
+ "relativePath": [
1373
+ "dist",
1374
+ "commands",
1375
+ "channel",
1376
+ "list.js"
1377
+ ]
1378
+ },
1379
+ "environment:list": {
1380
+ "aliases": [],
1381
+ "args": {},
1382
+ "flags": {
1383
+ "json": {
1384
+ "description": "Format output as json.",
1385
+ "helpGroup": "GLOBAL",
1386
+ "name": "json",
1387
+ "allowNo": false,
1388
+ "type": "boolean"
1389
+ },
1390
+ "service-token": {
1391
+ "env": "KNOCK_SERVICE_TOKEN",
1392
+ "name": "service-token",
1393
+ "required": false,
1394
+ "summary": "The service token to authenticate with.",
1395
+ "hasDynamicHelp": false,
1396
+ "multiple": false,
1397
+ "type": "option"
1398
+ },
1399
+ "api-origin": {
1400
+ "hidden": true,
1401
+ "name": "api-origin",
1402
+ "required": false,
1403
+ "hasDynamicHelp": false,
1404
+ "multiple": false,
1405
+ "type": "option"
1406
+ }
1407
+ },
1408
+ "hasDynamicHelp": false,
1409
+ "hiddenAliases": [],
1410
+ "id": "environment:list",
1411
+ "pluginAlias": "@knocklabs/cli",
1412
+ "pluginName": "@knocklabs/cli",
1413
+ "pluginType": "core",
1414
+ "strict": true,
1415
+ "summary": "Display all environments configured for the account.",
1416
+ "enableJsonFlag": true,
1417
+ "isESM": false,
1418
+ "relativePath": [
1419
+ "dist",
1420
+ "commands",
1421
+ "environment",
1422
+ "list.js"
1423
+ ]
1424
+ },
1321
1425
  "commit:get": {
1322
1426
  "aliases": [],
1323
1427
  "args": {
@@ -1609,98 +1713,6 @@
1609
1713
  "promote.js"
1610
1714
  ]
1611
1715
  },
1612
- "channel:list": {
1613
- "aliases": [],
1614
- "args": {},
1615
- "flags": {
1616
- "json": {
1617
- "description": "Format output as json.",
1618
- "helpGroup": "GLOBAL",
1619
- "name": "json",
1620
- "allowNo": false,
1621
- "type": "boolean"
1622
- },
1623
- "service-token": {
1624
- "env": "KNOCK_SERVICE_TOKEN",
1625
- "name": "service-token",
1626
- "required": false,
1627
- "summary": "The service token to authenticate with.",
1628
- "hasDynamicHelp": false,
1629
- "multiple": false,
1630
- "type": "option"
1631
- },
1632
- "api-origin": {
1633
- "hidden": true,
1634
- "name": "api-origin",
1635
- "required": false,
1636
- "hasDynamicHelp": false,
1637
- "multiple": false,
1638
- "type": "option"
1639
- }
1640
- },
1641
- "hasDynamicHelp": false,
1642
- "hiddenAliases": [],
1643
- "id": "channel:list",
1644
- "pluginAlias": "@knocklabs/cli",
1645
- "pluginName": "@knocklabs/cli",
1646
- "pluginType": "core",
1647
- "strict": true,
1648
- "summary": "Display all channels configured for the account.",
1649
- "enableJsonFlag": true,
1650
- "isESM": false,
1651
- "relativePath": [
1652
- "dist",
1653
- "commands",
1654
- "channel",
1655
- "list.js"
1656
- ]
1657
- },
1658
- "environment:list": {
1659
- "aliases": [],
1660
- "args": {},
1661
- "flags": {
1662
- "json": {
1663
- "description": "Format output as json.",
1664
- "helpGroup": "GLOBAL",
1665
- "name": "json",
1666
- "allowNo": false,
1667
- "type": "boolean"
1668
- },
1669
- "service-token": {
1670
- "env": "KNOCK_SERVICE_TOKEN",
1671
- "name": "service-token",
1672
- "required": false,
1673
- "summary": "The service token to authenticate with.",
1674
- "hasDynamicHelp": false,
1675
- "multiple": false,
1676
- "type": "option"
1677
- },
1678
- "api-origin": {
1679
- "hidden": true,
1680
- "name": "api-origin",
1681
- "required": false,
1682
- "hasDynamicHelp": false,
1683
- "multiple": false,
1684
- "type": "option"
1685
- }
1686
- },
1687
- "hasDynamicHelp": false,
1688
- "hiddenAliases": [],
1689
- "id": "environment:list",
1690
- "pluginAlias": "@knocklabs/cli",
1691
- "pluginName": "@knocklabs/cli",
1692
- "pluginType": "core",
1693
- "strict": true,
1694
- "summary": "Display all environments configured for the account.",
1695
- "enableJsonFlag": true,
1696
- "isESM": false,
1697
- "relativePath": [
1698
- "dist",
1699
- "commands",
1700
- "environment",
1701
- "list.js"
1702
- ]
1703
- },
1704
1716
  "guide:activate": {
1705
1717
  "aliases": [],
1706
1718
  "args": {
@@ -2342,6 +2354,12 @@
2342
2354
  "hasDynamicHelp": false,
2343
2355
  "multiple": false,
2344
2356
  "type": "option"
2357
+ },
2358
+ "force": {
2359
+ "name": "force",
2360
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
2361
+ "allowNo": false,
2362
+ "type": "boolean"
2345
2363
  }
2346
2364
  },
2347
2365
  "hasDynamicHelp": false,
@@ -2914,6 +2932,12 @@
2914
2932
  "hasDynamicHelp": false,
2915
2933
  "multiple": false,
2916
2934
  "type": "option"
2935
+ },
2936
+ "force": {
2937
+ "name": "force",
2938
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
2939
+ "allowNo": false,
2940
+ "type": "boolean"
2917
2941
  }
2918
2942
  },
2919
2943
  "hasDynamicHelp": false,
@@ -3486,6 +3510,12 @@
3486
3510
  "hasDynamicHelp": false,
3487
3511
  "multiple": false,
3488
3512
  "type": "option"
3513
+ },
3514
+ "force": {
3515
+ "name": "force",
3516
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
3517
+ "allowNo": false,
3518
+ "type": "boolean"
3489
3519
  }
3490
3520
  },
3491
3521
  "hasDynamicHelp": false,
@@ -4069,6 +4099,12 @@
4069
4099
  "hasDynamicHelp": false,
4070
4100
  "multiple": false,
4071
4101
  "type": "option"
4102
+ },
4103
+ "force": {
4104
+ "name": "force",
4105
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
4106
+ "allowNo": false,
4107
+ "type": "boolean"
4072
4108
  }
4073
4109
  },
4074
4110
  "hasDynamicHelp": false,
@@ -4519,6 +4555,12 @@
4519
4555
  "hasDynamicHelp": false,
4520
4556
  "multiple": false,
4521
4557
  "type": "option"
4558
+ },
4559
+ "force": {
4560
+ "name": "force",
4561
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
4562
+ "allowNo": false,
4563
+ "type": "boolean"
4522
4564
  }
4523
4565
  },
4524
4566
  "hasDynamicHelp": false,
@@ -5237,6 +5279,12 @@
5237
5279
  "hasDynamicHelp": false,
5238
5280
  "multiple": false,
5239
5281
  "type": "option"
5282
+ },
5283
+ "force": {
5284
+ "name": "force",
5285
+ "summary": "Force pushes the resource or resources to Knock, overwriting whatever is currently stored. If you're using this on a non-development environment, you should also ensure you `commit` the changes.",
5286
+ "allowNo": false,
5287
+ "type": "boolean"
5240
5288
  }
5241
5289
  },
5242
5290
  "hasDynamicHelp": false,
@@ -5423,5 +5471,5 @@
5423
5471
  ]
5424
5472
  }
5425
5473
  },
5426
- "version": "1.0.2"
5474
+ "version": "1.0.4"
5427
5475
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knocklabs/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Knock CLI",
5
5
  "author": "@knocklabs",
6
6
  "bin": {
@@ -16,12 +16,15 @@
16
16
  "/npm-shrinkwrap.json",
17
17
  "/oclif.manifest.json"
18
18
  ],
19
+ "resolutions": {
20
+ "axios": "1.14.0"
21
+ },
19
22
  "dependencies": {
23
+ "@knocklabs/jsonlint": "^2.0.0",
20
24
  "@knocklabs/mgmt": "0.21.0",
21
25
  "@oclif/core": "^3",
22
26
  "@oclif/plugin-help": "^6",
23
- "@prantlf/jsonlint": "^14.1.0",
24
- "axios": "^1.13.5",
27
+ "axios": "1.14.0",
25
28
  "date-fns": "^2.30.0",
26
29
  "degit": "^2.8.4",
27
30
  "enquirer": "^2.4.1",
@@ -37,13 +40,13 @@
37
40
  "devDependencies": {
38
41
  "@oclif/test": "^3",
39
42
  "@swc/cli": "^0.8.0",
40
- "@swc/core": "^1.15.11",
43
+ "@swc/core": "^1.15.18",
41
44
  "@swc/helpers": "^0.5.18",
42
45
  "@types/chai": "^4",
43
46
  "@types/degit": "^2.8.6",
44
47
  "@types/fs-extra": "^11.0.4",
45
48
  "@types/mocha": "^10.0.10",
46
- "@types/node": "^20.19.33",
49
+ "@types/node": "^20.19.37",
47
50
  "chai": "^4",
48
51
  "eslint": "^7.32.0",
49
52
  "eslint-config-oclif": "^4",