@raypx-kit/devkit 0.0.0-alpha.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/CHANGELOG.md ADDED
@@ -0,0 +1,21 @@
1
+ # @raypx-kit/devkit
2
+
3
+ ## 0.0.0-alpha.0
4
+
5
+ Initial Raypx Kit prerelease.
6
+
7
+ - Refresh compatible dependencies and use caret ranges for ordinary dependencies;
8
+ keep the coverage provider synchronized with Vite+'s bundled Vitest.
9
+ - Provide configurable workspace discovery, import resolution and architecture checks.
10
+ - Name non-exported implementation paths `internalPath` in import resolution and
11
+ report internal cross-workspace imports consistently.
12
+ - Check publishable workspaces and explicit source-entry mappings before builds,
13
+ with narrowly declared bundled development dependencies.
14
+ - Accept complete workspace metadata maps for explicit, typed repository
15
+ configuration while retaining manifest metadata compatibility and synchronous,
16
+ non-executing discovery.
17
+ - Check Node and Bun version-file declarations in local composite actions under
18
+ `.github/actions/`, including nested action directories and both YAML filename extensions.
19
+ - Include Node/Bun toolchain checks, static catalog reading, Markdown link checks,
20
+ dotenv-aware process and Turbo helpers, and relocated artifact staging and probes.
21
+ - Preserve independent entry points and consumer-owned repository policy.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Zack <heyloyep@gmail.com>
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # @raypx-kit/devkit
2
+
3
+ Maintenance checks and task helpers for Bun monorepos: workspace boundaries,
4
+ toolchain pins, static message catalogs, documentation links and relocated build
5
+ artifacts.
6
+
7
+ ```sh
8
+ bun add -d @raypx-kit/devkit
9
+ ```
10
+
11
+ ESM only, for Node 22.14+ and Bun. Each entry is independent, so a consumer loads
12
+ only the dependencies it uses. The package reads files and spawns processes; it
13
+ contains no product rules, so repositories compose their own policy from it.
14
+
15
+ | Entry | Purpose |
16
+ | ---------------- | ---------------------------------------------------------------------- |
17
+ | `./workspaces` | Discover workspaces, read boundary metadata and resolve imports |
18
+ | `./architecture` | Check dependencies, exports, cycles, platform targets and import leaks |
19
+ | `./toolchain` | Read Node/Bun pins, check every duplicated pin and the active runtimes |
20
+ | `./catalogs` | Read static message catalogs without executing them |
21
+ | `./docs` | Report broken relative Markdown links |
22
+ | `./process` | Run commands, load dotenv files and run Turbo with a guarded cache |
23
+ | `./artifact` | Stage a relocated output and probe a running Node server |
24
+
25
+ ## Workspace architecture
26
+
27
+ Repositories can keep their check policy in a typed file and pass plain data to
28
+ Devkit. For example, a repository with one `packages/messages` workspace can use
29
+ `devkit.config.ts`:
30
+
31
+ ```ts
32
+ import type { ToolchainOptions } from "@raypx-kit/devkit/toolchain";
33
+ import type { Metadata } from "@raypx-kit/devkit/workspaces";
34
+
35
+ export default {
36
+ workspaces: {
37
+ "packages/messages": {
38
+ kind: "library",
39
+ target: "universal",
40
+ entryTargets: { "./client": "browser" },
41
+ sourceTargets: { "src/client/**": "browser" },
42
+ sourceEntries: {
43
+ ".": "./src/index.ts",
44
+ "./client": "./src/client.ts",
45
+ },
46
+ },
47
+ } satisfies Record<string, Metadata>,
48
+ toolchain: {
49
+ documents: ["README.md", "AGENTS.md"],
50
+ turboGlobalDependencies: [".nvmrc", "mise.toml", "devkit.config.ts"],
51
+ } satisfies ToolchainOptions,
52
+ };
53
+ ```
54
+
55
+ The repository's own script imports that trusted configuration explicitly:
56
+
57
+ ```ts
58
+ import { checkArchitecture } from "@raypx-kit/devkit/architecture";
59
+ import { discover } from "@raypx-kit/devkit/workspaces";
60
+ import config from "../devkit.config.js";
61
+
62
+ const index = discover(root, { metadata: config.workspaces });
63
+ const findings = checkArchitecture(index);
64
+ ```
65
+
66
+ `metadata` accepts a `Readonly<Record<string, Metadata>>` keyed by discovered
67
+ workspace paths relative to `root`, such as `packages/messages`. Keys must match
68
+ the discovered paths exactly, without `./` or a trailing slash. The map is the
69
+ complete metadata source: missing and unknown workspaces are findings, and
70
+ manifest metadata is not merged or used as a fallback. Discovery is synchronous;
71
+ it never finds, imports or executes a configuration file. The filename and
72
+ loading mechanism belong to the caller.
73
+
74
+ `kind` is `app`, `library` or `tooling`; targets are `universal`, `browser`,
75
+ `native`, `node` and `bun`. Every workspace is ESM; application workspaces must
76
+ declare `private: true`, while libraries and tooling can be publishable.
77
+
78
+ `sourceEntries` maps a public export key to its maintained TypeScript or
79
+ JavaScript source. Use it when `exports` points to generated output so the gate
80
+ can inspect sources before building. Each mapping must name an existing source
81
+ within its workspace and correspond to an actual export. Without a mapping,
82
+ the check follows the declared export targets directly. Package-root JSON
83
+ configuration exports therefore need no source mapping.
84
+
85
+ `bundledDependencies` lists external development dependencies deliberately bundled
86
+ into the published runtime. Each name must be declared in `devDependencies`, and
87
+ the package build must bundle it. This option permits those source imports; it
88
+ does not exempt workspace boundaries or platform checks. Ordinary runtime
89
+ dependencies and peers remain in their respective manifest fields.
90
+
91
+ Without an explicit `metadata` map, discovery retains the manifest interface.
92
+ Each workspace stores its metadata under `package.json#devkit` by default; a
93
+ custom `metadataKey` selects a different field:
94
+
95
+ ```ts
96
+ const index = discover(root, { metadataKey: "devkit" });
97
+ ```
98
+
99
+ An external map moves checking policy only. Workspace membership, exports and
100
+ dependencies still come from package manifests, and aliases come from workspace
101
+ TypeScript configurations. Keep a repository's typed policy file in its type
102
+ check and build-cache dependencies.
103
+
104
+ `discover` also reports directories under `apps/` and `packages/` without a
105
+ manifest; pass `containers` to change them. `checkArchitecture` statically parses
106
+ runtime sources under `src/`, `server/`, `native/` and `app/` and walks every
107
+ public source entry. It reports public applications and invalid metadata,
108
+ libraries without exports, missing export targets, non-`workspace:*` internal
109
+ ranges, dependency cycles including development dependencies, undeclared runtime
110
+ or type imports, internal cross-workspace paths, application or tooling imports
111
+ from runtime code, test-only imports, host APIs used outside their target and DOM
112
+ globals reachable from universal or native entries.
113
+
114
+ `resolveImport` marks paths that bypass a workspace's public exports with
115
+ `internalPath: true`; architecture findings call these internal cross-workspace
116
+ imports. Package publication status is separate and uses the standard manifest
117
+ `private` field.
118
+
119
+ This package's own tests live under `tests/`; production entries live under
120
+ `src/` and are the only sources included in the library build.
121
+
122
+ ## Toolchain
123
+
124
+ `.nvmrc` pins Node and the root `packageManager` (`bun@x.y.z`) pins Bun. Every
125
+ other declaration must follow those two sources.
126
+
127
+ ```ts
128
+ import { assertToolchainRuntime, checkToolchain, pinnedNode } from "@raypx-kit/devkit/toolchain";
129
+ import config from "../devkit.config.js";
130
+
131
+ const findings = checkToolchain(root, config.toolchain);
132
+ const { node, bun, nodeBinary } = assertToolchainRuntime(root, {
133
+ nodeBinaryEnv: "DEVKIT_NODE_BINARY",
134
+ });
135
+ ```
136
+
137
+ `checkToolchain` checks `engines.node` and both `devEngines` entries (including
138
+ `onFail: "error"`), rejects `.node-version`, `.bun-version` and `.tool-versions`,
139
+ requires `mise.toml` to read the existing pins without `[tools]`, requires every
140
+ `actions/setup-node` and `oven-sh/setup-bun` step to read `.nvmrc` and
141
+ `package.json` in workflows under `.github/workflows/` and composite actions
142
+ under `.github/actions/`, matches the `@types/node` range baseline by major and the
143
+ `@types/bun` range baseline to the Bun pin in every manifest and Bun catalog,
144
+ and checks Dockerfile `node:` and `oven/bun:` images,
145
+ documented `Node x.y.z` and `Bun x.y.z` versions and Turbo global dependencies.
146
+ `pinnedNode` returns the Node executable after checking its version; the binary
147
+ variable selects an executable but never relaxes the version.
148
+
149
+ ## Catalogs and documentation
150
+
151
+ ```ts
152
+ import { readStaticCatalog } from "@raypx-kit/devkit/catalogs";
153
+ import { checkDocumentLinks } from "@raypx-kit/devkit/docs";
154
+
155
+ const en = readStaticCatalog("src/messages/en.ts");
156
+ const broken = checkDocumentLinks(root, ["README.md", "docs/guide.md"]);
157
+ ```
158
+
159
+ `readStaticCatalog` accepts JSON or a module whose default export is an object
160
+ literal of strings, optionally with `as const` or `satisfies`. Computed values,
161
+ spreads and computed keys are rejected, and the module is never executed. Pair it
162
+ with `compareMessageCatalogs` from `@raypx-kit/intl/testing` for ICU parity.
163
+
164
+ ## Processes and artifacts
165
+
166
+ ```ts
167
+ import { pinnedNode } from "@raypx-kit/devkit/toolchain";
168
+ import { probeArtifact } from "@raypx-kit/devkit/artifact";
169
+ import { developmentEnvironment, run, turbo } from "@raypx-kit/devkit/process";
170
+
171
+ await turbo(root, "build", ["--filter", "web"], { trustedCacheEnv: "CACHE_TRUSTED" });
172
+ await probeArtifact({
173
+ name: "web",
174
+ output: `${root}/apps/web/.output`,
175
+ node: pinnedNode(root),
176
+ check: async (base) => {
177
+ if (!(await fetch(base)).ok) throw new Error("home page failed");
178
+ },
179
+ });
180
+ ```
181
+
182
+ `developmentEnvironment` copies the process environment and layers `.env.local`
183
+ and `.env` beneath it without printing values. `turbo` must run under Bun; it
184
+ loads dotenv files for `dev` and `build`, and unless the trusted variable is
185
+ `"true"` removes remote cache credentials and uses the local cache only.
186
+ `stageArtifact` copies an output after rejecting absolute links and links that
187
+ escape it. `probeArtifact` stages the output in a temporary directory, starts its
188
+ entry with the given Node on a free port, waits for the health path, runs the
189
+ check and always stops the server.
@@ -0,0 +1,15 @@
1
+ import { WorkspaceIndex } from "./workspaces.mjs";
2
+ //#region src/architecture.d.ts
3
+ export interface ImportEdge {
4
+ request: string;
5
+ typesOnly: boolean;
6
+ }
7
+ /** Static import, re-export, dynamic import and `import()` type edges, without executing code. */
8
+ export declare function imports(file: string, source: string): ImportEdge[];
9
+ /**
10
+ * Checks workspace metadata, exports, the dependency graph and every runtime import:
11
+ * declarations, internal paths, platform targets, tooling and test-only boundaries.
12
+ */
13
+ export declare function checkArchitecture(index: WorkspaceIndex): string[];
14
+ //#endregion
15
+ //# sourceMappingURL=architecture.d.mts.map