@appsemble/cli 0.36.5 → 0.36.6

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 CHANGED
@@ -1,9 +1,9 @@
1
- # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.5/config/assets/logo.svg) Appsemble CLI
1
+ # ![](https://gitlab.com/appsemble/appsemble/-/raw/0.36.6/config/assets/logo.svg) Appsemble CLI
2
2
 
3
3
  > Manage apps and blocks from the command line.
4
4
 
5
5
  [![npm](https://img.shields.io/npm/v/@appsemble/cli)](https://www.npmjs.com/package/@appsemble/cli)
6
- [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.5/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.5)
6
+ [![GitLab CI](https://gitlab.com/appsemble/appsemble/badges/0.36.6/pipeline.svg)](https://gitlab.com/appsemble/appsemble/-/releases/0.36.6)
7
7
  [![Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://prettier.io)
8
8
 
9
9
  ## Table of Contents
@@ -323,5 +323,5 @@ appsemble run-cronjobs --interval 30
323
323
 
324
324
  ## License
325
325
 
326
- [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.5/LICENSE.md) ©
326
+ [LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.36.6/LICENSE.md) ©
327
327
  [Appsemble](https://appsemble.com)
package/lib/output.d.ts CHANGED
@@ -1,2 +1,10 @@
1
1
  import { type ValidationError } from 'jsonschema';
2
+ /**
3
+ * Format validation errors from an Axios response as `file:line:col` messages when possible.
4
+ *
5
+ * @param filename The YAML file path shown in the output.
6
+ * @param yaml The YAML source text.
7
+ * @param errors The validation errors returned by the API.
8
+ * @returns A newline-separated list of formatted validation messages.
9
+ */
2
10
  export declare function printAxiosError(filename: string, yaml: string, errors: ValidationError[]): string;
package/lib/output.js CHANGED
@@ -1,15 +1,58 @@
1
- import { isNode, LineCounter, parseDocument } from 'yaml';
1
+ import { isAlias, isNode, LineCounter, parseDocument, YAMLMap, YAMLSeq, } from 'yaml';
2
+ /**
3
+ * Resolve a validation path to the original YAML node, even when the path crosses aliases.
4
+ *
5
+ * Validation errors are produced from the fully expanded app definition, but the YAML AST still
6
+ * contains alias nodes such as `*item-form-fields`. `doc.getIn()` stops at those aliases,
7
+ * so we walk the path manually and resolve aliases along the way to recover the source node.
8
+ *
9
+ * @param doc The parsed YAML document.
10
+ * @param path The validation error path, e.g. `['form', 'fields', 0, 'type']`.
11
+ * @returns The YAML node at the given path, or `undefined` if the path is invalid.
12
+ */
13
+ function getNodeAtPath(doc, path) {
14
+ function resolveNode(node, docu) {
15
+ return isAlias(node) ? node.resolve(docu) : node;
16
+ }
17
+ let current = doc.contents;
18
+ for (const segment of path) {
19
+ current = resolveNode(current, doc);
20
+ if (current instanceof YAMLMap) {
21
+ current = current.get(segment, true);
22
+ }
23
+ else if (current instanceof YAMLSeq) {
24
+ if (typeof segment !== 'number') {
25
+ return undefined;
26
+ }
27
+ const item = current.items[segment];
28
+ current = isNode(item) ? item : undefined;
29
+ }
30
+ else {
31
+ return undefined;
32
+ }
33
+ if (current == null) {
34
+ return undefined;
35
+ }
36
+ }
37
+ return resolveNode(current, doc);
38
+ }
39
+ /**
40
+ * Format validation errors from an Axios response as `file:line:col` messages when possible.
41
+ *
42
+ * @param filename The YAML file path shown in the output.
43
+ * @param yaml The YAML source text.
44
+ * @param errors The validation errors returned by the API.
45
+ * @returns A newline-separated list of formatted validation messages.
46
+ */
2
47
  export function printAxiosError(filename, yaml, errors) {
3
48
  const lineCounter = new LineCounter();
4
49
  const doc = parseDocument(yaml, { lineCounter });
5
50
  return errors
6
51
  .map((error) => {
7
- const node = doc.getIn(error.path, true);
52
+ const node = getNodeAtPath(doc, error.path);
8
53
  let result = filename;
9
- if (isNode(node)) {
10
- // @ts-expect-error 2345 argument of type is not assignable to parameter of type
11
- // (strictNullChecks)
12
- const { col, line } = lineCounter.linePos(node.range?.[0]);
54
+ if (isNode(node) && node.range) {
55
+ const { col, line } = lineCounter.linePos(node.range[0]);
13
56
  result += `:${line}:${col}`;
14
57
  }
15
58
  return `${result} ${error.message}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appsemble/cli",
3
- "version": "0.36.5",
3
+ "version": "0.36.6",
4
4
  "description": "The CLI for developing with Appsemble apps and blocks",
5
5
  "keywords": [
6
6
  "app",
@@ -44,10 +44,10 @@
44
44
  "test": "vitest"
45
45
  },
46
46
  "dependencies": {
47
- "@appsemble/node-utils": "0.36.5",
48
- "@appsemble/types": "0.36.5",
49
- "@appsemble/lang-sdk": "0.36.5",
50
- "@appsemble/utils": "0.36.5",
47
+ "@appsemble/node-utils": "0.36.6",
48
+ "@appsemble/types": "0.36.6",
49
+ "@appsemble/lang-sdk": "0.36.6",
50
+ "@appsemble/utils": "0.36.6",
51
51
  "@fortawesome/fontawesome-common-types": "^6.0.0",
52
52
  "@inquirer/prompts": "^8.0.0",
53
53
  "@koa/cors": "^5.0.0",
@@ -57,7 +57,7 @@
57
57
  "comment-parser": "^1.0.0",
58
58
  "cosmiconfig": "^7.0.0",
59
59
  "csvtojson": "^2.0.0",
60
- "esbuild": "^0.26.0",
60
+ "esbuild": "^0.27.0",
61
61
  "fast-glob": "^3.0.0",
62
62
  "form-data": "^4.0.4",
63
63
  "global-cache-dir": "^6.0.0",
@@ -89,8 +89,8 @@
89
89
  "yargs": "^17.0.0"
90
90
  },
91
91
  "devDependencies": {
92
- "@appsemble/types": "0.36.5",
93
- "@appsemble/server": "0.36.5",
92
+ "@appsemble/types": "0.36.6",
93
+ "@appsemble/server": "0.36.6",
94
94
  "@types/concat-stream": "2.0.3",
95
95
  "@types/koa__cors": "5.0.1",
96
96
  "@types/koa-compress": "4.0.7",
@@ -6,7 +6,7 @@ pages:
6
6
  - name: Example Page A
7
7
  blocks:
8
8
  - type: action-button
9
- version: 0.36.5
9
+ version: 0.36.6
10
10
  parameters:
11
11
  icon: arrow-right
12
12
  actions:
@@ -17,7 +17,7 @@ pages:
17
17
  - name: Example Page B
18
18
  blocks:
19
19
  - type: action-button
20
- version: 0.36.5
20
+ version: 0.36.6
21
21
  parameters:
22
22
  icon: arrow-left
23
23
  actions:
@@ -5,7 +5,7 @@
5
5
  "*.css"
6
6
  ],
7
7
  "dependencies": {
8
- "@appsemble/sdk": "0.36.5",
8
+ "@appsemble/sdk": "0.36.6",
9
9
  "mini-jsx": "^4.0.0"
10
10
  }
11
11
  }
@@ -5,8 +5,8 @@
5
5
  "*.css"
6
6
  ],
7
7
  "dependencies": {
8
- "@appsemble/preact": "0.36.5",
9
- "@appsemble/sdk": "0.36.5",
8
+ "@appsemble/preact": "0.36.6",
9
+ "@appsemble/sdk": "0.36.6",
10
10
  "preact": "^10.0.0"
11
11
  }
12
12
  }
@@ -5,6 +5,6 @@
5
5
  "*.css"
6
6
  ],
7
7
  "dependencies": {
8
- "@appsemble/sdk": "0.36.5"
8
+ "@appsemble/sdk": "0.36.6"
9
9
  }
10
10
  }