@capawesome/cli 0.0.11 → 0.0.13

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [0.0.13](https://github.com/capawesome-team/cli/compare/v0.0.12...v0.0.13) (2024-08-20)
6
+
7
+
8
+ ### Features
9
+
10
+ * print notice if new version is available ([#7](https://github.com/capawesome-team/cli/issues/7)) ([db88dc3](https://github.com/capawesome-team/cli/commit/db88dc356f6f6f5f73444e341ab749ae68cfdf6a)), closes [#2](https://github.com/capawesome-team/cli/issues/2)
11
+
12
+ ## [0.0.12](https://github.com/capawesome-team/cli/compare/v0.0.11...v0.0.12) (2024-07-25)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **apps:** typo ([2376f13](https://github.com/capawesome-team/cli/commit/2376f1397e4b8e71aeea58fff3b2338d59ab41e7))
18
+
5
19
  ## [0.0.11](https://github.com/capawesome-team/cli/compare/v0.0.10...v0.0.11) (2024-07-12)
6
20
 
7
21
 
@@ -93,7 +93,7 @@ exports.default = (0, citty_1.defineCommand)({
93
93
  }
94
94
  if (!appId) {
95
95
  const apps = yield apps_1.default.findAll();
96
- if (!apps.length) {
96
+ if (apps.length === 0) {
97
97
  consola_1.default.error('You must create an app before creating a bundle.');
98
98
  return;
99
99
  }
@@ -41,7 +41,7 @@ exports.default = (0, citty_1.defineCommand)({
41
41
  return;
42
42
  }
43
43
  // @ts-ignore wait till https://github.com/unjs/consola/pull/280 is merged
44
- appId = yield (0, prompt_1.prompt)('Which app do you want to delete the channel from?', {
44
+ appId = yield (0, prompt_1.prompt)('Which app do you want to create the channel for?', {
45
45
  type: 'select',
46
46
  options: apps.map((app) => ({ label: app.name, value: app.id })),
47
47
  });
package/dist/index.js CHANGED
@@ -29,12 +29,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
30
  const citty_1 = require("citty");
31
31
  const package_json_1 = __importDefault(require("../package.json"));
32
+ const update_1 = __importDefault(require("./services/update"));
32
33
  const main = (0, citty_1.defineCommand)({
33
34
  meta: {
34
35
  name: package_json_1.default.name,
35
36
  version: package_json_1.default.version,
36
37
  description: package_json_1.default.description,
37
38
  },
39
+ setup() {
40
+ // No op
41
+ },
42
+ cleanup() {
43
+ return update_1.default.checkForUpdate();
44
+ },
38
45
  subCommands: {
39
46
  whoami: Promise.resolve().then(() => __importStar(require('./commands/whoami'))).then((mod) => mod.default),
40
47
  login: Promise.resolve().then(() => __importStar(require('./commands/login'))).then((mod) => mod.default),
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
+ return new (P || (P = Promise))(function (resolve, reject) {
28
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
32
+ });
33
+ };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ const consola_1 = __importDefault(require("consola"));
39
+ const semver = __importStar(require("semver"));
40
+ const package_json_1 = __importDefault(require("../../package.json"));
41
+ const http_client_1 = __importDefault(require("../utils/http-client"));
42
+ class UpdateServiceImpl {
43
+ constructor(httpClient) {
44
+ this.httpClient = httpClient;
45
+ }
46
+ checkForUpdate() {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const response = yield this.httpClient.get(`https://registry.npmjs.org/${package_json_1.default.name}/latest`);
49
+ if (!response.success) {
50
+ throw response.error;
51
+ }
52
+ const latestVersion = response.data.version;
53
+ if (semver.gt(latestVersion, package_json_1.default.version)) {
54
+ consola_1.default.warn(`New version of Capawesome CLI available: ${package_json_1.default.name}@${latestVersion}. Please update to receive the latest features and bug fixes.`);
55
+ }
56
+ });
57
+ }
58
+ }
59
+ const updateService = new UpdateServiceImpl(http_client_1.default);
60
+ exports.default = updateService;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,7 +18,8 @@ class HttpClientImpl {
18
18
  delete(url, config) {
19
19
  return __awaiter(this, void 0, void 0, function* () {
20
20
  try {
21
- const res = yield axios_1.default.delete(config_1.API_URL + url, config);
21
+ const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
22
+ const res = yield axios_1.default.delete(urlWithHost, config);
22
23
  return {
23
24
  success: true,
24
25
  status: res.status,
@@ -37,7 +38,8 @@ class HttpClientImpl {
37
38
  get(url, config) {
38
39
  return __awaiter(this, void 0, void 0, function* () {
39
40
  try {
40
- const res = yield axios_1.default.get(config_1.API_URL + url, config);
41
+ const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
42
+ const res = yield axios_1.default.get(urlWithHost, config);
41
43
  return {
42
44
  success: true,
43
45
  status: res.status,
@@ -56,7 +58,8 @@ class HttpClientImpl {
56
58
  patch(url, data, config) {
57
59
  return __awaiter(this, void 0, void 0, function* () {
58
60
  try {
59
- const res = yield axios_1.default.patch(config_1.API_URL + url, data, config);
61
+ const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
62
+ const res = yield axios_1.default.patch(urlWithHost, data, config);
60
63
  return {
61
64
  success: true,
62
65
  status: res.status,
@@ -75,7 +78,8 @@ class HttpClientImpl {
75
78
  post(url, data, config) {
76
79
  return __awaiter(this, void 0, void 0, function* () {
77
80
  try {
78
- const res = yield axios_1.default.post(config_1.API_URL + url, data, config);
81
+ const urlWithHost = url.startsWith('http') ? url : config_1.API_URL + url;
82
+ const res = yield axios_1.default.post(urlWithHost, data, config);
79
83
  return {
80
84
  success: true,
81
85
  status: res.status,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/cli",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
5
5
  "scripts": {
6
6
  "build": "rimraf ./dist && tsc",
@@ -46,12 +46,14 @@
46
46
  "citty": "0.1.6",
47
47
  "consola": "3.2.3",
48
48
  "form-data": "4.0.0",
49
- "rc9": "2.1.1"
49
+ "rc9": "2.1.1",
50
+ "semver": "7.6.3"
50
51
  },
51
52
  "devDependencies": {
52
53
  "@ionic/prettier-config": "4.0.0",
53
54
  "@types/archiver": "6.0.2",
54
55
  "@types/node": "20.11.30",
56
+ "@types/semver": "7.5.8",
55
57
  "commit-and-tag-version": "12.4.0",
56
58
  "prettier": "3.2.5",
57
59
  "rimraf": "5.0.5",