@open-xchange/app-suite-ui-sdk 0.1.1 → 0.1.3
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 +39 -13
- package/lib/doctor.js +33 -10
- package/lib/tools.js +8 -0
- package/package.json +7 -4
- package/toolchain.json +4 -0
package/README.md
CHANGED
|
@@ -2,11 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Shared build, lint and test tooling for OX App Suite UI projects: core ui, plugins, customer plugins and services with a UI build.
|
|
4
4
|
|
|
5
|
-
A project depends on this one package instead of vite, eslint, stylelint, vitest, lefthook and their plugins. A tool bump or a security fix becomes one SDK release. Renovate then rolls it out to every project with one automerged MR.
|
|
6
|
-
|
|
7
|
-
## Status
|
|
8
|
-
|
|
9
|
-
Version 0.1 ships the CLI, the configs and `doctor`. Not in place yet: automatic release on merge, the downstream core ui pipeline that gates SDK MRs, and the SDK renovate preset with the `doctor --fix` post-upgrade task.
|
|
5
|
+
A project depends on this one package instead of vite, eslint, stylelint, vitest, lefthook and their plugins. A tool bump or a security fix becomes one SDK release. Renovate then rolls it out to every project with one automerged MR.
|
|
10
6
|
|
|
11
7
|
## Setup
|
|
12
8
|
|
|
@@ -18,6 +14,17 @@ pnpm install
|
|
|
18
14
|
|
|
19
15
|
`doctor --fix` removes the tooling the SDK provides from `package.json`, points the scripts at `ui-sdk`, and writes the pnpm settings the SDK needs into `pnpm-workspace.yaml`.
|
|
20
16
|
|
|
17
|
+
For renovate, the project's `renovate.json` only extends the SDK preset:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
|
|
22
|
+
"extends": ["local>openxchange/appsuite/web-foundation/renovate:app-suite-ui-sdk"]
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The preset automerges updates, and after an SDK bump it runs `ui-sdk doctor --fix` in the same MR. SDK minor releases below 1.0.0 and SDK majors wait for review.
|
|
27
|
+
|
|
21
28
|
## Commands
|
|
22
29
|
|
|
23
30
|
| Command | Runs | Default arguments |
|
|
@@ -33,7 +40,7 @@ pnpm install
|
|
|
33
40
|
|
|
34
41
|
Arguments after the command replace the defaults and go straight to the tool, for example `ui-sdk lint src spec --fix`. `msgmerge` needs gettext installed.
|
|
35
42
|
|
|
36
|
-
The tools
|
|
43
|
+
The tools come from the SDK's own dependencies. After `ui-sdk doctor --fix`, the `publicHoistPattern` makes pnpm link `vite`, `vitest`, `eslint`, `stylelint` and `tsc` into `node_modules/.bin`, so `pnpm exec vite` works too. Scripts use `ui-sdk`, which falls back to the SDK config when the project has none; plain `vite` does not.
|
|
37
44
|
|
|
38
45
|
## Configs
|
|
39
46
|
|
|
@@ -81,19 +88,24 @@ extends:
|
|
|
81
88
|
- Scripts call `ui-sdk` instead of the tools. `--fix` rewrites simple cases like `vite build` or `eslint src` and keeps their arguments. Chained scripts get a warning and need a manual change.
|
|
82
89
|
- `pnpm-workspace.yaml` has `publicHoistPattern` (so editors and test files find eslint, stylelint, typescript, vite and vitest), `allowBuilds`, `minimumReleaseAgeExclude` for `@open-xchange/*` (pnpm otherwise refuses a freshly released SDK version, which blocks the renovate bump), and the SDK security overrides.
|
|
83
90
|
- `lefthook.yml` extends the SDK config.
|
|
84
|
-
-
|
|
91
|
+
- `renovate.json` extends the `app-suite-ui-sdk` preset. `--fix` creates the file when it is missing. An existing file without the preset only gets a warning, because projects keep their own rules there.
|
|
92
|
+
- rlsy is installed globally. That is a warning only.
|
|
85
93
|
|
|
86
|
-
|
|
94
|
+
`ui-sdk doctor` exits non-zero while errors remain, so a CI job that runs it fails on drift. Add that job to the project's pipeline.
|
|
87
95
|
|
|
88
96
|
## Security overrides
|
|
89
97
|
|
|
90
98
|
pnpm reads `overrides` only from the project root, so the SDK cannot pin a patched transitive version for its consumers by itself. Instead, [security-overrides.json](security-overrides.json) lists the overrides, and `doctor --fix` writes them into the project's `pnpm-workspace.yaml` with a `# managed by ui-sdk` comment. Managed overrides that the SDK no longer lists are removed again. An override the project set itself always wins, and doctor only warns about it.
|
|
91
99
|
|
|
92
|
-
|
|
100
|
+
A daily scheduled pipeline (with `SECURITY_OVERRIDES=true`) finds the overrides itself: it installs the packed SDK into a temporary project, runs `pnpm audit --fix` there and adds every new override to the list. If it finds one, it opens an MR with a `Security:` commit that merges once its pipeline passes, test projects included.
|
|
101
|
+
|
|
102
|
+
To add an override by hand, add it here and commit it with the `Security:` prefix. A push to `main` with such a commit releases right away instead of waiting for the weekly release. The renovate SDK bump in each project then runs `ui-sdk doctor --fix` as a post-upgrade task and automerges. For an urgent fix in one project, run `pnpm exec ui-sdk audit --fix`.
|
|
93
103
|
|
|
94
104
|
## Releasing
|
|
95
105
|
|
|
96
|
-
Releasing stays out of the SDK. Projects release with a globally installed [rlsy](https://gitlab.com/openxchange/appsuite/web-foundation/rlsy) (`pnpm add -g rlsy`) and get no `release` script.
|
|
106
|
+
Releasing stays out of the SDK. Projects release with a globally installed [rlsy](https://gitlab.com/openxchange/appsuite/web-foundation/rlsy) (`pnpm add -g rlsy`) and get no `release` script.
|
|
107
|
+
|
|
108
|
+
The SDK itself releases once a week. A scheduled pipeline on `main` runs `rlsy --yes`, which picks the version from the commits since the last release and counts renovate's "Update dependency" commits as changes. A security change does not wait: when a push to `main` brings a commit with `[SECURITY]` (renovate's security updates) or a `Security:` commit, the release job releases right away. Running a pipeline on `main` by hand also releases. The tag the release job pushes starts the publish job.
|
|
97
109
|
|
|
98
110
|
## Decisions
|
|
99
111
|
|
|
@@ -107,12 +119,26 @@ Agreed on 2026-11-03.
|
|
|
107
119
|
- **`doctor --fix` writes visible settings** into `package.json` and `pnpm-workspace.yaml` instead of injecting them at install time.
|
|
108
120
|
- **Same tools everywhere.** lefthook, the SDK's pnpm and Node version, enforced by `ui-sdk doctor` in CI.
|
|
109
121
|
- **`@open-xchange/lint` stays its own package.** The SDK pins it and re-exports it.
|
|
110
|
-
- **Semver, released
|
|
111
|
-
- **
|
|
112
|
-
- **Renovate everywhere** through
|
|
122
|
+
- **Semver, released weekly.** Security changes release right away. A tool bump that breaks consumers is a major. Consumers automerge minor and patch updates and review majors.
|
|
123
|
+
- **Test projects gate releases.** Every SDK pipeline installs the packed SDK into the projects in [test-projects](test-projects) and runs `doctor --fix`, `lint`, `stylelint`, `test`, `build` and `audit` there. A core ui pipeline per SDK MR was too heavy for every dependency bump.
|
|
124
|
+
- **Renovate everywhere** through the `app-suite-ui-sdk` preset in [web-foundation/renovate](https://gitlab.com/openxchange/appsuite/web-foundation/renovate). Every project has the short `renovate.json` from Setup.
|
|
113
125
|
- **e2e is out of scope** and gets its own SDK.
|
|
114
126
|
- **Rollout:** core ui first, then the other vite projects, then the customer plugins.
|
|
115
127
|
|
|
128
|
+
## Development
|
|
129
|
+
|
|
130
|
+
```sh
|
|
131
|
+
pnpm test # unit tests
|
|
132
|
+
pnpm test:projects # packs the SDK and runs it in each test project
|
|
133
|
+
pnpm test:projects vite-vue # only one project
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
`pnpm test:projects` copies each project from [test-projects](test-projects) into a temporary directory, installs the packed SDK there, and deletes the directory afterwards. It needs network access for the install and the audit. The test projects:
|
|
137
|
+
|
|
138
|
+
- `customer-plugin`: a drifted customer plugin with eslint 8, release-it and no build.
|
|
139
|
+
- `vite-vue`: vite with Vue, scss, po files and a unit test.
|
|
140
|
+
- `vite-tailwind`: vite with Tailwind.
|
|
141
|
+
|
|
116
142
|
## License
|
|
117
143
|
|
|
118
144
|
MIT
|
package/lib/doctor.js
CHANGED
|
@@ -3,7 +3,7 @@ import { existsSync, readFileSync, writeFileSync } from 'node:fs'
|
|
|
3
3
|
import { createRequire } from 'node:module'
|
|
4
4
|
import path from 'node:path'
|
|
5
5
|
import { isMap, isScalar, parseDocument, Scalar } from 'yaml'
|
|
6
|
-
import { sdkPackage, sdkRoot } from './tools.js'
|
|
6
|
+
import { sdkPackage, sdkRoot, toolchain } from './tools.js'
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url)
|
|
9
9
|
|
|
@@ -57,14 +57,14 @@ export function checkPackageJson (pkg, { provided = providedPackages() } = {}) {
|
|
|
57
57
|
const findings = []
|
|
58
58
|
const fixed = structuredClone(pkg)
|
|
59
59
|
|
|
60
|
-
if (pkg.packageManager !==
|
|
61
|
-
findings.push({ level: 'error', fixable: true, message: `packageManager is ${pkg.packageManager ?? 'unset'}, expected ${
|
|
62
|
-
fixed.packageManager =
|
|
60
|
+
if (pkg.packageManager !== toolchain.packageManager) {
|
|
61
|
+
findings.push({ level: 'error', fixable: true, message: `packageManager is ${pkg.packageManager ?? 'unset'}, expected ${toolchain.packageManager}` })
|
|
62
|
+
fixed.packageManager = toolchain.packageManager
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
if (pkg.engines?.node !==
|
|
66
|
-
findings.push({ level: 'error', fixable: true, message: `engines.node is ${pkg.engines?.node ?? 'unset'}, expected ${
|
|
67
|
-
fixed.engines = { ...pkg.engines, node:
|
|
65
|
+
if (pkg.engines?.node !== toolchain.node) {
|
|
66
|
+
findings.push({ level: 'error', fixable: true, message: `engines.node is ${pkg.engines?.node ?? 'unset'}, expected ${toolchain.node}` })
|
|
67
|
+
fixed.engines = { ...pkg.engines, node: toolchain.node }
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
for (const field of ['dependencies', 'devDependencies']) {
|
|
@@ -186,6 +186,28 @@ export function checkLefthook (source) {
|
|
|
186
186
|
return { findings: [{ level: 'warn', fixable: false, message: `lefthook.yml does not extend ${extendsPath}` }], fixed: source }
|
|
187
187
|
}
|
|
188
188
|
|
|
189
|
+
export const RENOVATE_PRESET = 'local>openxchange/appsuite/web-foundation/renovate:app-suite-ui-sdk'
|
|
190
|
+
|
|
191
|
+
export function checkRenovate (source) {
|
|
192
|
+
if (source === undefined) {
|
|
193
|
+
return {
|
|
194
|
+
findings: [{ level: 'error', fixable: true, message: 'renovate.json is missing' }],
|
|
195
|
+
fixed: JSON.stringify({
|
|
196
|
+
$schema: 'https://docs.renovatebot.com/renovate-schema.json',
|
|
197
|
+
extends: [RENOVATE_PRESET]
|
|
198
|
+
}, null, 2) + '\n'
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
let config
|
|
202
|
+
try {
|
|
203
|
+
config = JSON.parse(source)
|
|
204
|
+
} catch {
|
|
205
|
+
return { findings: [{ level: 'error', fixable: false, message: 'renovate.json is not valid JSON' }], fixed: source }
|
|
206
|
+
}
|
|
207
|
+
if ((config.extends || []).includes(RENOVATE_PRESET)) return { findings: [], fixed: source }
|
|
208
|
+
return { findings: [{ level: 'warn', fixable: false, message: `renovate.json does not extend ${RENOVATE_PRESET}` }], fixed: source }
|
|
209
|
+
}
|
|
210
|
+
|
|
189
211
|
function readIfExists (file) {
|
|
190
212
|
return existsSync(file) ? readFileSync(file, 'utf8') : undefined
|
|
191
213
|
}
|
|
@@ -198,7 +220,8 @@ export function doctor (cwd, { fix = false, log = console.log } = {}) {
|
|
|
198
220
|
const files = {
|
|
199
221
|
'package.json': path.join(cwd, 'package.json'),
|
|
200
222
|
'pnpm-workspace.yaml': path.join(cwd, 'pnpm-workspace.yaml'),
|
|
201
|
-
'lefthook.yml': path.join(cwd, 'lefthook.yml')
|
|
223
|
+
'lefthook.yml': path.join(cwd, 'lefthook.yml'),
|
|
224
|
+
'renovate.json': path.join(cwd, 'renovate.json')
|
|
202
225
|
}
|
|
203
226
|
|
|
204
227
|
const pkgSource = readFileSync(files['package.json'], 'utf8')
|
|
@@ -208,12 +231,12 @@ export function doctor (cwd, { fix = false, log = console.log } = {}) {
|
|
|
208
231
|
return { findings, fixed: JSON.stringify(fixed, null, 2) + '\n' }
|
|
209
232
|
})(),
|
|
210
233
|
'pnpm-workspace.yaml': checkWorkspace(readIfExists(files['pnpm-workspace.yaml'])),
|
|
211
|
-
'lefthook.yml': checkLefthook(readIfExists(files['lefthook.yml']))
|
|
234
|
+
'lefthook.yml': checkLefthook(readIfExists(files['lefthook.yml'])),
|
|
235
|
+
'renovate.json': checkRenovate(readIfExists(files['renovate.json']))
|
|
212
236
|
}
|
|
213
237
|
|
|
214
238
|
const general = []
|
|
215
239
|
if (!hasCommand('rlsy')) general.push({ level: 'warn', fixable: false, message: 'rlsy is not installed globally (pnpm add -g rlsy); releases need it' })
|
|
216
|
-
if (!existsSync(path.join(cwd, 'renovate.json'))) general.push({ level: 'warn', fixable: false, message: 'renovate.json is missing' })
|
|
217
240
|
|
|
218
241
|
let remainingErrors = 0
|
|
219
242
|
for (const [name, { findings, fixed }] of Object.entries(results)) {
|
package/lib/tools.js
CHANGED
|
@@ -9,6 +9,14 @@ const require = createRequire(import.meta.url)
|
|
|
9
9
|
export const sdkRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
|
|
10
10
|
export const sdkPackage = JSON.parse(readFileSync(path.join(sdkRoot, 'package.json'), 'utf8'))
|
|
11
11
|
|
|
12
|
+
function readToolchain () {
|
|
13
|
+
const file = path.join(sdkRoot, 'toolchain.json')
|
|
14
|
+
if (existsSync(file)) return JSON.parse(readFileSync(file, 'utf8'))
|
|
15
|
+
return { packageManager: sdkPackage.packageManager, node: sdkPackage.engines.node }
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const toolchain = readToolchain()
|
|
19
|
+
|
|
12
20
|
export function resolveBin (pkg, { bin: binName = pkg, via } = {}) {
|
|
13
21
|
const resolver = via ? createRequire(require.resolve(`${via}/package.json`)) : require
|
|
14
22
|
const manifestPath = resolver.resolve(`${pkg}/package.json`)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-xchange/app-suite-ui-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Shared build, lint and test tooling for OX App Suite UI projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"bin",
|
|
18
18
|
"configs",
|
|
19
19
|
"lib",
|
|
20
|
-
"security-overrides.json"
|
|
20
|
+
"security-overrides.json",
|
|
21
|
+
"toolchain.json"
|
|
21
22
|
],
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|
|
@@ -56,10 +57,12 @@
|
|
|
56
57
|
"yaml": "2.9.1"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
59
|
-
"rlsy": "0.4.
|
|
60
|
+
"rlsy": "0.4.2"
|
|
60
61
|
},
|
|
61
62
|
"scripts": {
|
|
62
63
|
"lint": "node bin/ui-sdk.js lint",
|
|
63
|
-
"test": "vitest --run"
|
|
64
|
+
"test": "vitest --run",
|
|
65
|
+
"test:projects": "node scripts/test-projects.js",
|
|
66
|
+
"security:overrides": "node scripts/security-overrides.js"
|
|
64
67
|
}
|
|
65
68
|
}
|
package/toolchain.json
ADDED