@capawesome/cli 1.6.0 → 1.6.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,21 @@
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
+ ## [1.6.2](https://github.com/capawesome-team/cli/compare/v1.6.1...v1.6.2) (2025-03-18)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * invalid hrefs were created for the artifact type `manifest` if path starts with `./` ([5d3f629](https://github.com/capawesome-team/cli/commit/5d3f6299fbfde98705589e1518af654dba7e234f))
11
+
12
+ ## [1.6.1](https://github.com/capawesome-team/cli/compare/v1.6.0...v1.6.1) (2025-03-16)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **apps:bundles:create:** validate zip file if url is passed ([bd1c4c7](https://github.com/capawesome-team/cli/commit/bd1c4c7463ed3a1611ec6da1b2e87eccb0665fed))
18
+ * improve error handling ([949e358](https://github.com/capawesome-team/cli/commit/949e35826d3e75d5077b55966cff75ccd15a54d7))
19
+
5
20
  ## [1.6.0](https://github.com/capawesome-team/cli/compare/v1.5.0...v1.6.0) (2025-03-03)
6
21
 
7
22
 
@@ -152,9 +152,27 @@ exports.default = (0, citty_1.defineCommand)({
152
152
  process.exit(1);
153
153
  }
154
154
  }
155
+ if (path) {
156
+ // Check if the path exists when a path is provided
157
+ const pathExists = yield (0, file_1.fileExistsAtPath)(path);
158
+ if (!pathExists) {
159
+ consola_1.default.error(`The path does not exist.`);
160
+ process.exit(1);
161
+ }
162
+ // Check if the directory contains an index.html file
163
+ const pathIsDirectory = yield (0, file_1.isDirectory)(path);
164
+ if (pathIsDirectory) {
165
+ const files = yield (0, file_1.getFilesInDirectoryAndSubdirectories)(path);
166
+ const indexHtml = files.find((file) => file.href === 'index.html');
167
+ if (!indexHtml) {
168
+ consola_1.default.error('The directory must contain an `index.html` file.');
169
+ process.exit(1);
170
+ }
171
+ }
172
+ }
155
173
  // Check that the path is a directory when creating a bundle with an artifact type
156
174
  if (artifactType === 'manifest' && path) {
157
- const pathIsDirectory = (0, file_1.isDirectory)(path);
175
+ const pathIsDirectory = yield (0, file_1.isDirectory)(path);
158
176
  if (!pathIsDirectory) {
159
177
  consola_1.default.error('The path must be a folder when creating a bundle with an artifact type of `manifest`.');
160
178
  process.exit(1);
@@ -165,14 +183,6 @@ exports.default = (0, citty_1.defineCommand)({
165
183
  consola_1.default.error('It is not yet possible to provide a URL when creating a bundle with an artifact type of `manifest`.');
166
184
  process.exit(1);
167
185
  }
168
- // Check if the path exists when a path is provided
169
- if (path) {
170
- const pathExists = yield (0, file_1.fileExistsAtPath)(path);
171
- if (!pathExists) {
172
- consola_1.default.error(`The path does not exist.`);
173
- process.exit(1);
174
- }
175
- }
176
186
  // Let the user select an app and channel if not provided
177
187
  if (!appId) {
178
188
  const apps = yield apps_1.default.findAll();
@@ -230,6 +240,11 @@ exports.default = (0, citty_1.defineCommand)({
230
240
  let checksum;
231
241
  let signature;
232
242
  if (path && url) {
243
+ // Create the file buffer
244
+ if (!zip_1.default.isZipped(path)) {
245
+ consola_1.default.error('The path must be a zip file when providing a URL.');
246
+ process.exit(1);
247
+ }
233
248
  const fileBuffer = yield (0, buffer_1.createBufferFromPath)(path);
234
249
  // Generate checksum
235
250
  checksum = yield (0, hash_1.createHash)(fileBuffer);
@@ -335,14 +350,12 @@ const uploadFiles = (options) => __awaiter(void 0, void 0, void 0, function* ()
335
350
  fileIndex++;
336
351
  consola_1.default.start(`Uploading file (${fileIndex}/${files.length})...`);
337
352
  const fileBuffer = yield (0, buffer_1.createBufferFromPath)(file.path);
338
- const fileName = file.name;
339
- const href = file.path.replace(options.path + '/', '');
340
353
  yield uploadFile({
341
354
  appId: options.appId,
342
355
  appBundleId: options.appBundleId,
343
356
  fileBuffer,
344
- fileName,
345
- href,
357
+ fileName: file.name,
358
+ href: file.href,
346
359
  privateKeyBuffer: options.privateKeyBuffer,
347
360
  retryOnFailure: true,
348
361
  });
package/dist/index.js CHANGED
@@ -83,5 +83,6 @@ const captureException = (error) => __awaiter(void 0, void 0, void 0, function*
83
83
  yield captureException(error).catch(() => {
84
84
  // No op
85
85
  });
86
+ console.error(error);
86
87
  process.exit(1);
87
88
  }));
@@ -45,7 +45,18 @@ const getFilesInDirectoryAndSubdirectories = (path) => __awaiter(void 0, void 0,
45
45
  yield walk(fullPath);
46
46
  }
47
47
  else {
48
+ let pathToReplace = path;
49
+ // Remove the leading './' from the path
50
+ if (pathToReplace.startsWith('./')) {
51
+ pathToReplace = pathToReplace.replace('./', '');
52
+ }
53
+ let href = fullPath.replace(pathToReplace, '');
54
+ // Remove the leading '/' from the href
55
+ if (href.startsWith('/')) {
56
+ href = href.replace('/', '');
57
+ }
48
58
  files.push({
59
+ href,
49
60
  name: dirEntry.name,
50
61
  path: fullPath,
51
62
  });
@@ -24,14 +24,13 @@ const generateManifestJson = (path) => __awaiter(void 0, void 0, void 0, functio
24
24
  const fileBuffer = yield (0, buffer_1.createBufferFromPath)(file.path);
25
25
  const checksum = yield (0, hash_1.createHash)(fileBuffer);
26
26
  const sizeInBytes = fileBuffer.byteLength;
27
- const href = file.path.replace(path + '/', '');
28
27
  // Skip ignored files
29
28
  if (ignoreFiles.includes(file.name)) {
30
29
  continue;
31
30
  }
32
31
  manifestItems.push({
33
32
  checksum,
34
- href,
33
+ href: file.href,
35
34
  sizeInBytes,
36
35
  });
37
36
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capawesome/cli",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "The Capawesome Cloud Command Line Interface (CLI) to manage Live Updates and more.",
5
5
  "scripts": {
6
6
  "build": "patch-package && rimraf ./dist && tsc",