@canonical/summon-component 0.30.0 → 0.31.0
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.
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import * as path from "node:path";
|
|
2
2
|
import { isPascalCase } from "./string-helpers/index.js";
|
|
3
3
|
/**
|
|
4
|
-
* Validate component path
|
|
4
|
+
* Validate component path.
|
|
5
|
+
*
|
|
6
|
+
* Rejects an empty path, an absolute path, or one that escapes the project via
|
|
7
|
+
* `..` segments (all of which would write outside the working tree), and
|
|
8
|
+
* requires the final path segment to be a PascalCase component name.
|
|
5
9
|
*/
|
|
6
10
|
export default function validateComponentPath(value) {
|
|
7
11
|
if (!value || typeof value !== "string") {
|
|
8
12
|
return "Component path is required";
|
|
9
13
|
}
|
|
14
|
+
if (path.isAbsolute(value)) {
|
|
15
|
+
return "Component path must be relative to the project, not absolute";
|
|
16
|
+
}
|
|
17
|
+
const segments = value.split(/[/\\]/);
|
|
18
|
+
if (segments.includes("..")) {
|
|
19
|
+
return "Component path must stay within the project (no '..' segments)";
|
|
20
|
+
}
|
|
10
21
|
const name = path.basename(value);
|
|
11
22
|
if (!isPascalCase(name)) {
|
|
12
23
|
return "Component name must be in PascalCase (e.g., MyComponent)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateComponentPath.js","sourceRoot":"","sources":["../../../src/shared/validateComponentPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD
|
|
1
|
+
{"version":3,"file":"validateComponentPath.js","sourceRoot":"","sources":["../../../src/shared/validateComponentPath.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,KAAc;IAC1D,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACxC,OAAO,4BAA4B,CAAC;IACtC,CAAC;IACD,IAAI,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,8DAA8D,CAAC;IACxE,CAAC;IACD,MAAM,QAAQ,GAAG,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5B,OAAO,gEAAgE,CAAC;IAC1E,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;QACxB,OAAO,0DAA0D,CAAC;IACpE,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Validate component path
|
|
2
|
+
* Validate component path.
|
|
3
|
+
*
|
|
4
|
+
* Rejects an empty path, an absolute path, or one that escapes the project via
|
|
5
|
+
* `..` segments (all of which would write outside the working tree), and
|
|
6
|
+
* requires the final path segment to be a PascalCase component name.
|
|
3
7
|
*/
|
|
4
8
|
export default function validateComponentPath(value: unknown): true | string;
|
|
5
9
|
//# sourceMappingURL=validateComponentPath.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateComponentPath.d.ts","sourceRoot":"","sources":["../../../src/shared/validateComponentPath.ts"],"names":[],"mappings":"AAGA
|
|
1
|
+
{"version":3,"file":"validateComponentPath.d.ts","sourceRoot":"","sources":["../../../src/shared/validateComponentPath.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,GAAG,MAAM,CAgB3E"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/summon-component",
|
|
3
3
|
"description": "Component generators for Summon - React, Svelte and Lit component scaffolding",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/esm/index.js",
|
|
7
7
|
"module": "dist/esm/index.js",
|
|
@@ -46,20 +46,20 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@biomejs/biome": "2.4.9",
|
|
49
|
-
"@canonical/biome-config": "^0.
|
|
50
|
-
"@canonical/typescript-config": "^0.
|
|
51
|
-
"@canonical/webarchitect": "^0.
|
|
49
|
+
"@canonical/biome-config": "^0.31.0",
|
|
50
|
+
"@canonical/typescript-config": "^0.31.0",
|
|
51
|
+
"@canonical/webarchitect": "^0.31.0",
|
|
52
52
|
"@types/bun": "^1.3.10",
|
|
53
53
|
"@types/node": "^24.12.0",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
55
|
"vitest": "^4.0.18"
|
|
56
56
|
},
|
|
57
57
|
"dependencies": {
|
|
58
|
-
"@canonical/utils": "^0.
|
|
58
|
+
"@canonical/utils": "^0.31.0"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"@canonical/summon-core": "^0.
|
|
62
|
-
"@canonical/task": "^0.
|
|
61
|
+
"@canonical/summon-core": "^0.30.0",
|
|
62
|
+
"@canonical/task": "^0.30.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "d4a67ebe42e62b8cf3de77f42f537309ca88d672"
|
|
65
65
|
}
|