@canonical/webarchitect 0.11.0 → 0.12.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.
package/README.md CHANGED
@@ -1,22 +1,47 @@
1
1
  # Webarchitect
2
2
 
3
- A powerful command-line tool for validating project architecture and configuration consistency across development teams and organizations.
3
+ Validates project architecture and configuration against rulesets. Run it to ensure packages follow organizational standards.
4
4
 
5
- ## What is this tool for?
5
+ ```bash
6
+ webarchitect library
7
+ ```
8
+
9
+ ## Built-in Rulesets
10
+
11
+ Pragma uses three rulesets:
12
+
13
+ | Ruleset | License | Use Case |
14
+ |---------|---------|----------|
15
+ | `library` | LGPL-3.0 | Packages consumed by other packages or applications |
16
+ | `tool` | GPL-3.0 | Compiled CLI tools with a build step |
17
+ | `tool-ts` | GPL-3.0 | TypeScript tools that run directly with Bun (no build) |
6
18
 
7
- Webarchitect helps development teams maintain consistent project structures and configuration standards. Think of it as a quality gate that ensures every project in your organization follows the same architectural patterns, uses the same build tools, and maintains the same configuration standards.
19
+ Each ruleset validates package.json structure, required scripts, TypeScript configuration, Biome setup, and license compliance.
8
20
 
9
- ### The Problem It Solves
21
+ ## Quick Example
10
22
 
11
- In large organizations with multiple development teams, projects tend to drift from established standards over time. One team might use different TypeScript configurations, another might have inconsistent package.json structures, and a third might be missing essential development scripts. This inconsistency creates several problems: developers waste time figuring out how each project works, code quality varies between teams, and maintaining projects becomes more difficult as each one follows slightly different patterns.
23
+ A library package includes this in its check script:
12
24
 
13
- Webarchitect addresses this challenge by providing automated validation of project architecture. Instead of relying on documentation that might become outdated or manual code reviews that might miss configuration details, you can define your organization's standards as executable rulesets and validate projects automatically.
25
+ ```json
26
+ {
27
+ "scripts": {
28
+ "check:webarchitect": "webarchitect library"
29
+ }
30
+ }
31
+ ```
14
32
 
15
- ### How It Works
33
+ Running `bun run check:webarchitect` validates that the package has correct exports, required fields, and LGPL-3.0 license.
16
34
 
17
- The tool operates on the concept of "rulesets" - JSON Schema-based definitions that describe what files should exist in a project and what those files should contain. For example, a ruleset might specify that every package must have a `package.json` file with specific required fields, a `biome.json` file that extends your organization's linting configuration, and a TypeScript configuration that follows your team's standards.
35
+ ## What It Validates
18
36
 
19
- When you run webarchitect against a project, it loads the specified ruleset, checks whether the required files exist, and validates that their contents match the expected structure and values. This approach gives you confidence that projects follow your established patterns without requiring manual inspection.
37
+ Webarchitect checks that:
38
+ - `package.json` has required fields (name, version, type, module, types, exports)
39
+ - `biome.json` extends `@canonical/biome-config`
40
+ - `tsconfig.json` exists with proper configuration
41
+ - License matches the ruleset requirement
42
+ - Required scripts exist (build, check, test)
43
+
44
+ When validation fails, you get specific error messages explaining what's wrong and what's expected.
20
45
 
21
46
  ## How to install and run?
22
47
 
@@ -80,6 +105,8 @@ Webarchitect comes with several built-in rulesets that cover common project patt
80
105
 
81
106
  - `package-react`: - Extends base-package with React-specific requirements. This ruleset includes all the base package validations plus verification that React 19 or higher is specified as a dependency, ensuring your React projects use compatible versions.
82
107
 
108
+ - `package-svelte`: Extends the `package` ruleset for Svelte packages by redirecting output to a `dist/` folder built via **`svelte-package`** (necessary to compile components into valid JavaScript with the correct export conditions for bundlers) and requiring `check:ts` to run **`svelte-check`** (essential to leverage Svelte's additional type inference and specific validation logic that standard `tsc` does not provide).
109
+
83
110
  ### Ruleset Inheritance
84
111
 
85
112
  Rulesets can extend other rulesets, creating a hierarchy of validation requirements. For example, package-react extends base-package, which extends base. This means when you validate against package-react, you're actually running all three sets of rules. This inheritance model allows you to build complex validation requirements while keeping individual rulesets focused and maintainable.
@@ -247,6 +274,5 @@ The programmatic API makes it easy to integrate webarchitect into existing build
247
274
 
248
275
  - **Plain Text File Validation** - Webarchitect only validates JSON files. While it can verify that plain text files like LICENSE or README.md exist, it cannot validate their contents. This limitation affects license text verification, documentation standards, and configuration files that use non-JSON formats.
249
276
  - **IDE Integration** - No real-time validation feedback is available yet in code editors. Developers must run webarchitect manually or through build scripts to see validation results. Real-time diagnostics would require Language Server Protocol implementation or editor-specific plugins.
250
- - **Svelte support** - No svelte-specific ruleset has been developed yet.
251
277
  - **Error Code Granularity** - All validation failures return the same exit code (1) regardless of failure type. Missing files, invalid JSON syntax, and schema validation failures are not distinguished programmatically. This limits automated error handling and reporting capabilities.
252
278
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/webarchitect",
3
3
  "description": "A tool to test the compliance with architecture specifications for packages and applications.",
4
- "version": "0.11.0",
4
+ "version": "0.12.0",
5
5
  "type": "module",
6
6
  "module": "src/index.ts",
7
7
  "types": "src/index.ts",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "devDependencies": {
40
40
  "@biomejs/biome": "2.3.11",
41
- "@canonical/biome-config": "^0.11.0",
42
- "@canonical/typescript-config-base": "^0.11.0",
41
+ "@canonical/biome-config": "^0.12.0",
42
+ "@canonical/typescript-config-base": "^0.12.0",
43
43
  "@types/json-schema": "^7.0.15",
44
44
  "typescript": "^5.9.3"
45
45
  },
@@ -48,5 +48,5 @@
48
48
  "chalk": "^5.6.2",
49
49
  "commander": "^14.0.2"
50
50
  },
51
- "gitHead": "29125736059d1880b3d0fc277b218a63a2574f28"
51
+ "gitHead": "0b491caff8f797fef4ba4b7f5514a7c5b915a481"
52
52
  }
@@ -1,4 +1,4 @@
1
1
  {
2
- "$schema": "https://github.com/webarchitect/schemas/main/schema.json",
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
3
  "name": "base"
4
4
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://github.com/webarchitect/schemas/main/schema.json",
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
3
  "name": "library",
4
4
  "extends": ["package"],
5
5
  "package-license": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://github.com/webarchitect/schemas/main/schema.json",
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
3
  "name": "package-react",
4
4
  "extends": ["package"],
5
5
  "package-react": {
@@ -0,0 +1,101 @@
1
+ {
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
+ "name": "package-svelte",
4
+ "extends": ["package"],
5
+ "biome": {
6
+ "file": {
7
+ "name": "biome.json",
8
+ "contains": {
9
+ "type": "object",
10
+ "properties": {
11
+ "extends": {
12
+ "type": "array",
13
+ "items": { "const": "@canonical/biome-config-svelte" },
14
+ "minItems": 1,
15
+ "maxItems": 1
16
+ }
17
+ },
18
+ "required": ["extends"]
19
+ }
20
+ }
21
+ },
22
+ "package-structure": {
23
+ "file": {
24
+ "name": "package.json",
25
+ "contains": {
26
+ "type": "object",
27
+ "properties": {
28
+ "name": {
29
+ "type": "string",
30
+ "pattern": "^@canonical/"
31
+ },
32
+ "version": {
33
+ "type": "string"
34
+ },
35
+ "type": {
36
+ "const": "module"
37
+ },
38
+ "module": {
39
+ "const": "dist/index.js"
40
+ },
41
+ "types": {
42
+ "const": "dist/index.d.ts"
43
+ },
44
+ "files": {
45
+ "type": "array",
46
+ "contains": { "const": "dist" }
47
+ },
48
+ "scripts": {
49
+ "type": "object",
50
+ "properties": {
51
+ "build": {
52
+ "type": "string",
53
+ "pattern": ".*svelte-package.*",
54
+ "description": "Build must use svelte-package"
55
+ },
56
+ "test": {
57
+ "type": "string",
58
+ "description": "Test command (implementation flexible)"
59
+ },
60
+ "check:ts": {
61
+ "type": "string",
62
+ "pattern": "^svelte-check\\s"
63
+ }
64
+ },
65
+ "required": ["build", "test", "check:ts"]
66
+ }
67
+ },
68
+ "required": [
69
+ "name",
70
+ "version",
71
+ "type",
72
+ "module",
73
+ "types",
74
+ "files",
75
+ "scripts"
76
+ ]
77
+ }
78
+ }
79
+ },
80
+ "package-svelte": {
81
+ "file": {
82
+ "name": "package.json",
83
+ "contains": {
84
+ "type": "object",
85
+ "properties": {
86
+ "peerDependencies": {
87
+ "type": "object",
88
+ "properties": {
89
+ "svelte": {
90
+ "type": "string",
91
+ "pattern": "^(\\^|~|>=)?5\\."
92
+ }
93
+ },
94
+ "required": ["svelte"]
95
+ }
96
+ },
97
+ "required": ["peerDependencies"]
98
+ }
99
+ }
100
+ }
101
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://github.com/webarchitect/schemas/main/schema.json",
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
3
  "name": "package",
4
4
  "extends": ["base"],
5
5
  "biome": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://github.com/webarchitect/schemas/main/schema.json",
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
3
  "name": "tool-ts",
4
4
  "extends": ["base"],
5
5
  "biome": {
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://github.com/webarchitect/schemas/main/schema.json",
2
+ "$schema": "https://raw.githubusercontent.com/canonical/pragma/refs/heads/main/packages/webarchitect/src/schema.json",
3
3
  "name": "tool",
4
4
  "extends": ["package"],
5
5
  "package-license": {