@simbo/platform-check-cli 0.0.0-stage → 1.0.1

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,33 @@
1
+ # @simbo/platform-check-cli
2
+
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 6b70f11: Publish from CI with npm trusted publishing.
8
+
9
+ - This release is the first one published by the release workflow, with
10
+ provenance, instead of by hand; the package itself is unchanged.
11
+
12
+ - Updated dependencies [6b70f11]
13
+ - @simbo/platform-check@1.0.1
14
+
15
+ ## 1.0.0
16
+
17
+ ### Major Changes
18
+
19
+ - 429be5e: Add package `@simbo/platform-check-cli` with the CLI `platform-check`
20
+ for `@simbo/platform-check`.
21
+
22
+ - Reads the options from `platform-check.config.yml`, `.yaml`, `.ts` or `.js`
23
+ in the repository root, or from a file given with `--config`.
24
+ - Prints the supported Node.js release lines, the expected TypeScript settings
25
+ per environment, the data packages and the findings grouped by message, or
26
+ the result as JSON with `--json`.
27
+ - Exits with 0 if everything is current, 1 if there are findings, and 2 on
28
+ errors.
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [429be5e]
33
+ - @simbo/platform-check@1.0.0
package/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright © 2026 Simon Lepel <simbo@simbo.de> (https://simbo.de)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,121 @@
1
- # Temporary Holding Version
1
+ # Platform Check CLI
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 📦
4
+ [**`@simbo/platform-check-cli`**](https://npmjs.com/package/@simbo/platform-check-cli)
5
+
6
+ A CLI that checks whether a repository's **Node.js and ECMAScript platform
7
+ targets are still current** and reports what to raise, lower or update.
8
+
9
+ Uses [`@simbo/platform-check`](https://npmjs.com/package/@simbo/platform-check)
10
+ as a library; see its README for what is checked.
11
+
12
+ ## Requirements
13
+
14
+ Requires Node.js `^24.15.0 || >=26.0.0` and TypeScript 6 in the checked
15
+ repository.
16
+
17
+ The check fetches data from GitHub and the npm registry. Run it on demand or on
18
+ a schedule, not as part of builds or pull request checks.
19
+
20
+ ## Installation
21
+
22
+ Install `@simbo/platform-check-cli` from the npm registry:
23
+
24
+ ```bash
25
+ npm i [-D|-g] @simbo/platform-check-cli
26
+ ```
27
+
28
+ Alternatively, run it using `npx` or a similar tool:
29
+
30
+ ```bash
31
+ npx @simbo/platform-check-cli
32
+ ```
33
+
34
+ ## Usage
35
+
36
+ Run the CLI anywhere in a repository. It checks from the monorepo root, or from
37
+ the current working directory if there is no monorepo:
38
+
39
+ ```bash
40
+ platform-check [--config=<FILE>] [--json]
41
+ ```
42
+
43
+ | Option | Description |
44
+ | ----------------- | --------------------------------------------------------------------- |
45
+ | `--config`, `-c` | A custom path to a YAML, JavaScript or TypeScript configuration file. |
46
+ | `--json` | Prints the result of `platformCheck()` as JSON instead of a report. |
47
+ | `--help`, `-h` | Shows the help. |
48
+ | `--version`, `-v` | Shows the version. |
49
+
50
+ The exit code is `0` if everything is current, `1` if there are findings, and
51
+ `2` on errors, such as when data cannot be fetched.
52
+
53
+ The report shows the supported Node.js release lines, the expected TypeScript
54
+ settings per environment and the data packages, followed by the findings grouped
55
+ by message:
56
+
57
+ ```text
58
+ Node.js maintained 22, 24, 26 · dropped 22 · Active LTS 26 · lowest supported 24.15.0
59
+ node target ES2025 · lib ES2025 · JSON modules yes
60
+ browser target ES2024 · lib ES2022 + es2023.array, es2023.intl, es2024.collection, … · JSON modules no
61
+ Data web-features 3.48.0 · @mdn/browser-compat-data 8.1.11 · caniuse-lite 1.0.30001826 (1.0.30001829 available)
62
+
63
+ ✖ 1 finding:
64
+ lower lib provides APIs that not all supported environments have: es2025.collection
65
+ sites/app/tsconfig.json
66
+ ```
67
+
68
+ ### Configuration File
69
+
70
+ Create `platform-check.config.yml` (or `.yaml`, `.ts`, `.js`) in the root of the
71
+ repository, or provide a custom one using `--config=<FILE>`. It accepts the
72
+ options of
73
+ [`platformCheck()`](https://simbo.de/packages/functions/_simbo_platform-check.platformCheck/)
74
+ except `workingDir`, `date` and `fetch`:
75
+
76
+ ```yaml
77
+ droppedNodeLines:
78
+ - major: 22
79
+ reason: Dropped a few months before its end of life.
80
+ presets:
81
+ - config: '@simbo/tsconfig/node'
82
+ platform: node
83
+ - config: '@simbo/tsconfig/browser'
84
+ platform: browser
85
+ libExceptions:
86
+ - workspace: sites/app
87
+ libs: [ES2025.Collection]
88
+ reason: Polyfilled with core-js.
89
+ ```
90
+
91
+ In TypeScript, `defineConfig()` adds type checking:
92
+
93
+ ```ts
94
+ import { defineConfig } from '@simbo/platform-check-cli';
95
+
96
+ export default defineConfig({
97
+ droppedNodeLines: [
98
+ { major: 22, reason: 'Dropped a few months before its end of life.' },
99
+ ],
100
+ presets: [
101
+ { config: '@simbo/tsconfig/node', platform: 'node' },
102
+ { config: '@simbo/tsconfig/browser', platform: 'browser' },
103
+ ],
104
+ libExceptions: [
105
+ {
106
+ workspace: 'sites/app',
107
+ libs: ['ES2025.Collection'],
108
+ reason: 'Polyfilled with core-js.',
109
+ },
110
+ ],
111
+ });
112
+ ```
113
+
114
+ Without a configuration file, the CLI checks the `node`, `browser` and
115
+ `universal` presets of
116
+ [`@simbo/tsconfig`](https://npmjs.com/package/@simbo/tsconfig), all workspaces
117
+ and `.nvmrc`.
118
+
119
+ ## License
120
+
121
+ [MIT © Simon Lepel](https://simbo.mit-license.org/2026/)
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Validates the CLI arguments parsed by minimist.
3
+ * If validation fails, a user-friendly ValidationError is thrown.
4
+ *
5
+ * @param input - The input to validate.
6
+ * @returns The validated output.
7
+ * @throws {ValidationError} If the input is invalid.
8
+ */
9
+ export declare const validateArgs: (input: unknown) => {
10
+ configFile: string | undefined;
11
+ json: boolean;
12
+ };
@@ -0,0 +1,30 @@
1
+ import { createValidationFunction, nonEmptyStringOrArrayOfStringsSchema } from '@simbo/zodpak';
2
+ import { z } from 'zod';
3
+ const argsSchema = z
4
+ .looseObject({
5
+ /**
6
+ * The config file argument should be a single file path.
7
+ * If multiple file paths are given, only the first one is taken.
8
+ */
9
+ config: nonEmptyStringOrArrayOfStringsSchema
10
+ .optional()
11
+ .transform(value => (Array.isArray(value) ? value[0] : value)),
12
+ /**
13
+ * Whether to print the result as JSON.
14
+ */
15
+ json: z.boolean().optional().default(false),
16
+ })
17
+ .transform(value => ({
18
+ configFile: value.config,
19
+ json: value.json,
20
+ }));
21
+ /**
22
+ * Validates the CLI arguments parsed by minimist.
23
+ * If validation fails, a user-friendly ValidationError is thrown.
24
+ *
25
+ * @param input - The input to validate.
26
+ * @returns The validated output.
27
+ * @throws {ValidationError} If the input is invalid.
28
+ */
29
+ export const validateArgs = createValidationFunction(argsSchema);
30
+ //# sourceMappingURL=args-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"args-schema.js","sourceRoot":"","sources":["../src/args-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,oCAAoC,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,UAAU,GAAG,CAAC;KACjB,WAAW,CAAC;IACX;;;OAGG;IACH,MAAM,EAAE,oCAAoC;SACzC,QAAQ,EAAE;SACV,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEhE;;OAEG;IACH,IAAI,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CAC5C,CAAC;KACD,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IACnB,UAAU,EAAE,KAAK,CAAC,MAAM;IACxB,IAAI,EAAE,KAAK,CAAC,IAAI;CACjB,CAAC,CAAC,CAAC;AAEN;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,wBAAwB,CAAC,UAAU,CAAC,CAAC","sourcesContent":["import { createValidationFunction, nonEmptyStringOrArrayOfStringsSchema } from '@simbo/zodpak';\nimport { z } from 'zod';\n\nconst argsSchema = z\n .looseObject({\n /**\n * The config file argument should be a single file path.\n * If multiple file paths are given, only the first one is taken.\n */\n config: nonEmptyStringOrArrayOfStringsSchema\n .optional()\n .transform(value => (Array.isArray(value) ? value[0] : value)),\n\n /**\n * Whether to print the result as JSON.\n */\n json: z.boolean().optional().default(false),\n })\n .transform(value => ({\n configFile: value.config,\n json: value.json,\n }));\n\n/**\n * Validates the CLI arguments parsed by minimist.\n * If validation fails, a user-friendly ValidationError is thrown.\n *\n * @param input - The input to validate.\n * @returns The validated output.\n * @throws {ValidationError} If the input is invalid.\n */\nexport const validateArgs = createValidationFunction(argsSchema);\n"]}
@@ -0,0 +1,5 @@
1
+ import type { ClirkOptions } from '@simbo/clirk';
2
+ /**
3
+ * The options of the CLI for `clirk`: arguments, help and version.
4
+ */
5
+ export declare const CLI_CONFIG: ClirkOptions;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * The options of the CLI for `clirk`: arguments, help and version.
3
+ */
4
+ export const CLI_CONFIG = {
5
+ importMetaDirname: import.meta.dirname,
6
+ argsOptions: {
7
+ string: ['config'],
8
+ boolean: ['json'],
9
+ alias: { config: ['c'] },
10
+ },
11
+ title: 'Platform Check CLI',
12
+ icon: '🧭',
13
+ description: [
14
+ "Checks whether a repository's Node.js and ECMAScript platform targets are still current.",
15
+ ' ',
16
+ 'It checks engines, @types/node and .nvmrc against the Node.js release schedule, and lib, target and resolveJsonModule of TypeScript configurations against the supported environments.',
17
+ ' ',
18
+ 'Exits with 0 if everything is current, 1 if there are findings, and 2 on errors.',
19
+ ' ',
20
+ 'The base path for all relative paths will be the root path of the monorepo detected from the current working directory, or the current working directory itself.',
21
+ ],
22
+ examples: 'platform-check [OPTIONS]',
23
+ options: {
24
+ config: [
25
+ 'A custom path to a YAML, JavaScript or TypeScript configuration file.',
26
+ 'Defaults to "platform-check.config.(yml|yaml|ts|js)".',
27
+ ],
28
+ json: ['Prints the result as JSON instead of a report.'],
29
+ },
30
+ };
31
+ //# sourceMappingURL=cli-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-config.js","sourceRoot":"","sources":["../src/cli-config.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,iBAAiB,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO;IACtC,WAAW,EAAE;QACX,MAAM,EAAE,CAAC,QAAQ,CAAC;QAClB,OAAO,EAAE,CAAC,MAAM,CAAC;QACjB,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE;KACzB;IACD,KAAK,EAAE,oBAAoB;IAC3B,IAAI,EAAE,IAAI;IACV,WAAW,EAAE;QACX,0FAA0F;QAC1F,GAAG;QACH,wLAAwL;QACxL,GAAG;QACH,kFAAkF;QAClF,GAAG;QACH,kKAAkK;KACnK;IACD,QAAQ,EAAE,0BAA0B;IACpC,OAAO,EAAE;QACP,MAAM,EAAE;YACN,uEAAuE;YACvE,uDAAuD;SACxD;QACD,IAAI,EAAE,CAAC,gDAAgD,CAAC;KACzD;CACF,CAAC","sourcesContent":["import type { ClirkOptions } from '@simbo/clirk';\n\n/**\n * The options of the CLI for `clirk`: arguments, help and version.\n */\nexport const CLI_CONFIG: ClirkOptions = {\n importMetaDirname: import.meta.dirname,\n argsOptions: {\n string: ['config'],\n boolean: ['json'],\n alias: { config: ['c'] },\n },\n title: 'Platform Check CLI',\n icon: '🧭',\n description: [\n \"Checks whether a repository's Node.js and ECMAScript platform targets are still current.\",\n ' ',\n 'It checks engines, @types/node and .nvmrc against the Node.js release schedule, and lib, target and resolveJsonModule of TypeScript configurations against the supported environments.',\n ' ',\n 'Exits with 0 if everything is current, 1 if there are findings, and 2 on errors.',\n ' ',\n 'The base path for all relative paths will be the root path of the monorepo detected from the current working directory, or the current working directory itself.',\n ],\n examples: 'platform-check [OPTIONS]',\n options: {\n config: [\n 'A custom path to a YAML, JavaScript or TypeScript configuration file.',\n 'Defaults to \"platform-check.config.(yml|yaml|ts|js)\".',\n ],\n json: ['Prints the result as JSON instead of a report.'],\n },\n};\n"]}
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/cli.js ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+ import { gracefulExit } from '@simbo/graceful-exit';
3
+ import { platformCheckCli } from './platform-check-cli.js';
4
+ try {
5
+ await gracefulExit(undefined, await platformCheckCli());
6
+ }
7
+ catch (error) {
8
+ await gracefulExit(error, 2);
9
+ }
10
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,IAAI,CAAC;IACH,MAAM,YAAY,CAAC,SAAS,EAAE,MAAM,gBAAgB,EAAE,CAAC,CAAC;AAC1D,CAAC;AAAC,OAAO,KAAK,EAAE,CAAC;IACf,MAAM,YAAY,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;AAC/B,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { gracefulExit } from '@simbo/graceful-exit';\n\nimport { platformCheckCli } from './platform-check-cli.js';\n\ntry {\n await gracefulExit(undefined, await platformCheckCli());\n} catch (error) {\n await gracefulExit(error, 2);\n}\n"]}
@@ -0,0 +1,11 @@
1
+ import type { ValidatedConfig } from './platform-check-cli.types.js';
2
+ /**
3
+ * Creates a config loader function for the platform check.
4
+ *
5
+ * @param rootPath - The absolute path to the repository root.
6
+ * @returns A function that loads the configuration and the path it was loaded from.
7
+ */
8
+ export declare function createConfigLoader(rootPath: string): (filePath?: string) => Promise<{
9
+ config: ValidatedConfig;
10
+ path: string | undefined;
11
+ }>;
@@ -0,0 +1,50 @@
1
+ import { relative, resolve } from 'node:path';
2
+ import { UserFacingError } from '@simbo/user-facing-error';
3
+ import { cosmiconfig } from 'cosmiconfig';
4
+ import { TypeScriptLoader } from 'cosmiconfig-typescript-loader';
5
+ import { validateConfig } from './config-schema.js';
6
+ /**
7
+ * Creates a config loader function for the platform check.
8
+ *
9
+ * @param rootPath - The absolute path to the repository root.
10
+ * @returns A function that loads the configuration and the path it was loaded from.
11
+ */
12
+ export function createConfigLoader(rootPath) {
13
+ const explorer = cosmiconfig('platform-check', {
14
+ searchStrategy: 'none',
15
+ searchPlaces: [
16
+ 'platform-check.config.yml',
17
+ 'platform-check.config.yaml',
18
+ 'platform-check.config.ts',
19
+ 'platform-check.config.js',
20
+ ],
21
+ loaders: {
22
+ '.ts': TypeScriptLoader(),
23
+ },
24
+ // Loaded configs are transformed by zod schema validation
25
+ transform: result => {
26
+ if (result?.config) {
27
+ try {
28
+ result.config = validateConfig(result.config);
29
+ }
30
+ catch (error) {
31
+ throw UserFacingError.from(error, `Failed to parse the config file: ./${relative(rootPath, result.filepath)}`);
32
+ }
33
+ }
34
+ return result;
35
+ },
36
+ });
37
+ /**
38
+ * Loads the platform check configuration.
39
+ *
40
+ * @param filePath - The path to a specific configuration file. Defaults to a list of fallbacks.
41
+ * @returns The configuration and its path relative to the root, if a file was found.
42
+ */
43
+ return async (filePath) => {
44
+ const result = filePath ? await explorer.load(resolve(rootPath, filePath)) : await explorer.search(rootPath);
45
+ return result?.config
46
+ ? { config: result.config, path: `./${relative(rootPath, result.filepath)}` }
47
+ : { config: validateConfig({}), path: undefined };
48
+ };
49
+ }
50
+ //# sourceMappingURL=config-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-loader.js","sourceRoot":"","sources":["../src/config-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,QAAgB;IAEhB,MAAM,QAAQ,GAAG,WAAW,CAAC,gBAAgB,EAAE;QAC7C,cAAc,EAAE,MAAM;QACtB,YAAY,EAAE;YACZ,2BAA2B;YAC3B,4BAA4B;YAC5B,0BAA0B;YAC1B,0BAA0B;SAC3B;QACD,OAAO,EAAE;YACP,KAAK,EAAE,gBAAgB,EAAE;SAC1B;QACD,0DAA0D;QAC1D,SAAS,EAAE,MAAM,CAAC,EAAE;YAClB,IAAI,MAAM,EAAE,MAAM,EAAE,CAAC;gBACnB,IAAI,CAAC;oBACH,MAAM,CAAC,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;gBAC1D,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,eAAe,CAAC,IAAI,CACxB,KAAK,EACL,sCAAsC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,CAC5E,CAAC;gBACJ,CAAC;YACH,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;KACF,CAAC,CAAC;IAEH;;;;;OAKG;IACH,OAAO,KAAK,EAAE,QAAiB,EAAE,EAAE;QACjC,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAC7G,OAAO,MAAM,EAAE,MAAM;YACnB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAyB,EAAE,IAAI,EAAE,KAAK,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE;YAChG,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IACtD,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { relative, resolve } from 'node:path';\n\nimport { UserFacingError } from '@simbo/user-facing-error';\nimport { cosmiconfig } from 'cosmiconfig';\nimport { TypeScriptLoader } from 'cosmiconfig-typescript-loader';\n\nimport { validateConfig } from './config-schema.js';\nimport type { Config, ValidatedConfig } from './platform-check-cli.types.js';\n\n/**\n * Creates a config loader function for the platform check.\n *\n * @param rootPath - The absolute path to the repository root.\n * @returns A function that loads the configuration and the path it was loaded from.\n */\nexport function createConfigLoader(\n rootPath: string,\n): (filePath?: string) => Promise<{ config: ValidatedConfig; path: string | undefined }> {\n const explorer = cosmiconfig('platform-check', {\n searchStrategy: 'none',\n searchPlaces: [\n 'platform-check.config.yml',\n 'platform-check.config.yaml',\n 'platform-check.config.ts',\n 'platform-check.config.js',\n ],\n loaders: {\n '.ts': TypeScriptLoader(),\n },\n // Loaded configs are transformed by zod schema validation\n transform: result => {\n if (result?.config) {\n try {\n result.config = validateConfig(result.config as Config);\n } catch (error) {\n throw UserFacingError.from(\n error,\n `Failed to parse the config file: ./${relative(rootPath, result.filepath)}`,\n );\n }\n }\n return result;\n },\n });\n\n /**\n * Loads the platform check configuration.\n *\n * @param filePath - The path to a specific configuration file. Defaults to a list of fallbacks.\n * @returns The configuration and its path relative to the root, if a file was found.\n */\n return async (filePath?: string) => {\n const result = filePath ? await explorer.load(resolve(rootPath, filePath)) : await explorer.search(rootPath);\n return result?.config\n ? { config: result.config as ValidatedConfig, path: `./${relative(rootPath, result.filepath)}` }\n : { config: validateConfig({}), path: undefined };\n };\n}\n"]}
@@ -0,0 +1,60 @@
1
+ import type { Config } from './platform-check-cli.types.js';
2
+ /**
3
+ * The configuration schema: the options of `@simbo/platform-check` without
4
+ * the working directory, the date and the fetch function.
5
+ */
6
+ export declare const configSchema: import("zod").ZodObject<{
7
+ nvmrc: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodLiteral<false>]>>>;
8
+ droppedNodeLines: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
9
+ major: import("zod").ZodNumber;
10
+ reason: import("zod").ZodString;
11
+ }, import("zod/v4/core").$strict>>>>;
12
+ presets: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
13
+ config: import("zod").ZodString;
14
+ platform: import("zod").ZodEnum<{
15
+ node: "node";
16
+ browser: "browser";
17
+ universal: "universal";
18
+ }>;
19
+ }, import("zod/v4/core").$strict>>>>;
20
+ workspaces: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodBoolean>>;
21
+ libExceptions: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
22
+ workspace: import("zod").ZodString;
23
+ libs: import("zod").ZodArray<import("zod").ZodString>;
24
+ reason: import("zod").ZodString;
25
+ }, import("zod/v4/core").$strict>>>>;
26
+ maxDataAge: import("zod").ZodDefault<import("zod").ZodOptional<import("zod").ZodNumber>>;
27
+ }, import("zod/v4/core").$strict>;
28
+ /**
29
+ * A helper function to define the configuration object with proper types.
30
+ *
31
+ * @param config - The configuration object to define.
32
+ * @returns The defined configuration object.
33
+ */
34
+ export declare const defineConfig: (config: Config) => Config;
35
+ /**
36
+ * Validates the user configuration object.
37
+ * If validation fails, a user-friendly ValidationError is thrown.
38
+ *
39
+ * @param input - The input to validate.
40
+ * @returns The validated output.
41
+ * @throws {ValidationError} If the input is invalid.
42
+ */
43
+ export declare const validateConfig: (input: unknown) => {
44
+ nvmrc: string | false;
45
+ droppedNodeLines: {
46
+ major: number;
47
+ reason: string;
48
+ }[];
49
+ presets: {
50
+ config: string;
51
+ platform: "node" | "browser" | "universal";
52
+ }[];
53
+ workspaces: boolean;
54
+ libExceptions: {
55
+ workspace: string;
56
+ libs: string[];
57
+ reason: string;
58
+ }[];
59
+ maxDataAge: number;
60
+ };
@@ -0,0 +1,24 @@
1
+ import { optionsSchema } from '@simbo/platform-check';
2
+ import { createValidationFunction } from '@simbo/zodpak';
3
+ /**
4
+ * The configuration schema: the options of `@simbo/platform-check` without
5
+ * the working directory, the date and the fetch function.
6
+ */
7
+ export const configSchema = optionsSchema.omit({ workingDir: true, date: true, fetch: true });
8
+ /**
9
+ * A helper function to define the configuration object with proper types.
10
+ *
11
+ * @param config - The configuration object to define.
12
+ * @returns The defined configuration object.
13
+ */
14
+ export const defineConfig = (config) => config;
15
+ /**
16
+ * Validates the user configuration object.
17
+ * If validation fails, a user-friendly ValidationError is thrown.
18
+ *
19
+ * @param input - The input to validate.
20
+ * @returns The validated output.
21
+ * @throws {ValidationError} If the input is invalid.
22
+ */
23
+ export const validateConfig = createValidationFunction(configSchema);
24
+ //# sourceMappingURL=config-schema.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config-schema.js","sourceRoot":"","sources":["../src/config-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAIzD;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9F;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAU,EAAE,CAAC,MAAM,CAAC;AAE/D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,wBAAwB,CAAC,YAAY,CAAC,CAAC","sourcesContent":["import { optionsSchema } from '@simbo/platform-check';\nimport { createValidationFunction } from '@simbo/zodpak';\n\nimport type { Config } from './platform-check-cli.types.js';\n\n/**\n * The configuration schema: the options of `@simbo/platform-check` without\n * the working directory, the date and the fetch function.\n */\nexport const configSchema = optionsSchema.omit({ workingDir: true, date: true, fetch: true });\n\n/**\n * A helper function to define the configuration object with proper types.\n *\n * @param config - The configuration object to define.\n * @returns The defined configuration object.\n */\nexport const defineConfig = (config: Config): Config => config;\n\n/**\n * Validates the user configuration object.\n * If validation fails, a user-friendly ValidationError is thrown.\n *\n * @param input - The input to validate.\n * @returns The validated output.\n * @throws {ValidationError} If the input is invalid.\n */\nexport const validateConfig = createValidationFunction(configSchema);\n"]}
@@ -0,0 +1,4 @@
1
+ export { configSchema, defineConfig } from './config-schema.js';
2
+ export type { Config } from './platform-check-cli.types.js';
3
+ export * from './platform-check-cli.js';
4
+ export type { DroppedNodeLine, LibException, Platform, PresetOption } from '@simbo/platform-check';
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { configSchema, defineConfig } from './config-schema.js';
2
+ export * from './platform-check-cli.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEhE,cAAc,yBAAyB,CAAC","sourcesContent":["export { configSchema, defineConfig } from './config-schema.js';\nexport type { Config } from './platform-check-cli.types.js';\nexport * from './platform-check-cli.js';\n\nexport type { DroppedNodeLine, LibException, Platform, PresetOption } from '@simbo/platform-check';\n"]}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The main entry point for the Platform Check CLI.
3
+ *
4
+ * @param workingDir - The working directory to use.
5
+ * @returns The exit code: 0 if everything is current, 1 if there are findings.
6
+ */
7
+ export declare function platformCheckCli(workingDir?: string): Promise<number>;
@@ -0,0 +1,34 @@
1
+ import { log } from 'node:console';
2
+ import { cwd } from 'node:process';
3
+ import { clirk } from '@simbo/clirk';
4
+ import { findMonorepoRoot } from '@simbo/monorepo-utils';
5
+ import { platformCheck } from '@simbo/platform-check';
6
+ import { dim } from 'yoctocolors';
7
+ import { validateArgs } from './args-schema.js';
8
+ import { CLI_CONFIG } from './cli-config.js';
9
+ import { createConfigLoader } from './config-loader.js';
10
+ import { formatReport } from './report.js';
11
+ /**
12
+ * The main entry point for the Platform Check CLI.
13
+ *
14
+ * @param workingDir - The working directory to use.
15
+ * @returns The exit code: 0 if everything is current, 1 if there are findings.
16
+ */
17
+ export async function platformCheckCli(workingDir = cwd()) {
18
+ const { args } = await clirk(CLI_CONFIG);
19
+ const { configFile, json } = validateArgs(args);
20
+ const rootPath = (await findMonorepoRoot({ workingDir })) ?? workingDir;
21
+ const { config, path } = await createConfigLoader(rootPath)(configFile);
22
+ const result = await platformCheck({ ...config, workingDir: rootPath });
23
+ if (json) {
24
+ log(JSON.stringify(result, undefined, 2));
25
+ }
26
+ else {
27
+ log(dim(path === undefined ? 'No configuration file found, using the defaults.' : `Using configuration from ${path}`));
28
+ const lines = formatReport(result);
29
+ for (const line of lines)
30
+ log(line);
31
+ }
32
+ return result.findings.length > 0 ? 1 : 0;
33
+ }
34
+ //# sourceMappingURL=platform-check-cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-check-cli.js","sourceRoot":"","sources":["../src/platform-check-cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAAU,GAAG,GAAG,EAAE;IACvD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,CAAC;IACzC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IAEhD,MAAM,QAAQ,GAAG,CAAC,MAAM,gBAAgB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,IAAI,UAAU,CAAC;IACxE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,kBAAkB,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,CAAC;IAExE,MAAM,MAAM,GAAG,MAAM,aAAa,CAAC,EAAE,GAAG,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;IAExE,IAAI,IAAI,EAAE,CAAC;QACT,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,GAAG,CACD,GAAG,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,4BAA4B,IAAI,EAAE,CAAC,CAClH,CAAC;QACF,MAAM,KAAK,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QACnC,KAAK,MAAM,IAAI,IAAI,KAAK;YAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import { log } from 'node:console';\nimport { cwd } from 'node:process';\n\nimport { clirk } from '@simbo/clirk';\nimport { findMonorepoRoot } from '@simbo/monorepo-utils';\nimport { platformCheck } from '@simbo/platform-check';\nimport { dim } from 'yoctocolors';\n\nimport { validateArgs } from './args-schema.js';\nimport { CLI_CONFIG } from './cli-config.js';\nimport { createConfigLoader } from './config-loader.js';\nimport { formatReport } from './report.js';\n\n/**\n * The main entry point for the Platform Check CLI.\n *\n * @param workingDir - The working directory to use.\n * @returns The exit code: 0 if everything is current, 1 if there are findings.\n */\nexport async function platformCheckCli(workingDir = cwd()): Promise<number> {\n const { args } = await clirk(CLI_CONFIG);\n const { configFile, json } = validateArgs(args);\n\n const rootPath = (await findMonorepoRoot({ workingDir })) ?? workingDir;\n const { config, path } = await createConfigLoader(rootPath)(configFile);\n\n const result = await platformCheck({ ...config, workingDir: rootPath });\n\n if (json) {\n log(JSON.stringify(result, undefined, 2));\n } else {\n log(\n dim(path === undefined ? 'No configuration file found, using the defaults.' : `Using configuration from ${path}`),\n );\n const lines = formatReport(result);\n for (const line of lines) log(line);\n }\n\n return result.findings.length > 0 ? 1 : 0;\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import type { Finding } from '@simbo/platform-check';
2
+ import type { z } from 'zod';
3
+ import type { configSchema } from './config-schema.js';
4
+ /**
5
+ * The user configuration object.
6
+ */
7
+ export type Config = z.input<typeof configSchema>;
8
+ /**
9
+ * The parsed and validated configuration object.
10
+ */
11
+ export type ValidatedConfig = z.output<typeof configSchema>;
12
+ /**
13
+ * Findings with the same check, change and message.
14
+ */
15
+ export interface FindingGroup extends Omit<Finding, 'subject'> {
16
+ /**
17
+ * The subjects of the findings, in the order they were found.
18
+ */
19
+ subjects: string[];
20
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=platform-check-cli.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-check-cli.types.js","sourceRoot":"","sources":["../src/platform-check-cli.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Finding } from '@simbo/platform-check';\nimport type { z } from 'zod';\n\nimport type { configSchema } from './config-schema.js';\n\n/**\n * The user configuration object.\n */\nexport type Config = z.input<typeof configSchema>;\n\n/**\n * The parsed and validated configuration object.\n */\nexport type ValidatedConfig = z.output<typeof configSchema>;\n\n/**\n * Findings with the same check, change and message.\n */\nexport interface FindingGroup extends Omit<Finding, 'subject'> {\n /**\n * The subjects of the findings, in the order they were found.\n */\n subjects: string[];\n}\n"]}
@@ -0,0 +1,16 @@
1
+ import { type Finding, type PlatformCheckResult } from '@simbo/platform-check';
2
+ import type { FindingGroup } from './platform-check-cli.types.js';
3
+ /**
4
+ * Groups findings with the same check, change and message.
5
+ *
6
+ * @param findings - The findings.
7
+ * @returns The groups, in the order of their first finding.
8
+ */
9
+ export declare function groupFindings(findings: Finding[]): FindingGroup[];
10
+ /**
11
+ * Formats the result of a platform check as report lines.
12
+ *
13
+ * @param result - The result.
14
+ * @returns The report lines.
15
+ */
16
+ export declare function formatReport(result: PlatformCheckResult): string[];
package/dist/report.js ADDED
@@ -0,0 +1,69 @@
1
+ import { failure, success } from '@simbo/cli-output';
2
+ import { formatLibs, formatTarget, } from '@simbo/platform-check';
3
+ import { bold, dim, yellow } from 'yoctocolors';
4
+ /**
5
+ * Groups findings with the same check, change and message.
6
+ *
7
+ * @param findings - The findings.
8
+ * @returns The groups, in the order of their first finding.
9
+ */
10
+ export function groupFindings(findings) {
11
+ const groups = new Map();
12
+ for (const { subject, ...finding } of findings) {
13
+ const key = `${finding.check}\0${finding.change}\0${finding.message}`;
14
+ const group = groups.get(key);
15
+ if (group) {
16
+ group.subjects.push(subject);
17
+ }
18
+ else {
19
+ groups.set(key, { ...finding, subjects: [subject] });
20
+ }
21
+ }
22
+ return [...groups.values()];
23
+ }
24
+ /**
25
+ * Formats a data package with the newer versions that exist.
26
+ *
27
+ * @param data - The version information.
28
+ * @returns The formatted package, such as `web-features 3.48.0 (3.49.0 available)`.
29
+ */
30
+ function formatDataPackage(data) {
31
+ const { name, installed, latestInRange, latest, range } = data;
32
+ const notes = [
33
+ ...(installed === latestInRange ? [] : [`${latestInRange} available`]),
34
+ ...(latest === latestInRange ? [] : [`${latest} outside ${range}`]),
35
+ ];
36
+ return `${name} ${installed}${notes.length === 0 ? '' : dim(` (${notes.join(', ')})`)}`;
37
+ }
38
+ /**
39
+ * Formats the result of a platform check as report lines.
40
+ *
41
+ * @param result - The result.
42
+ * @returns The report lines.
43
+ */
44
+ export function formatReport(result) {
45
+ const { node, typescript, expected, data, findings } = result;
46
+ const lines = [
47
+ `${bold('Node.js')} ${[
48
+ `maintained ${node.maintained.join(', ')}`,
49
+ ...(node.dropped.length > 0 ? [`dropped ${node.dropped.join(', ')}`] : []),
50
+ `Active LTS ${node.activeLts ?? 'none'}`,
51
+ `lowest supported ${node.lowestVersion ?? 'unknown'}`,
52
+ ].join(' · ')}`,
53
+ ];
54
+ for (const [platform, targets] of Object.entries(expected)) {
55
+ lines.push(`${bold(platform)} target ${formatTarget(targets.target)} · lib ${formatLibs(targets.libs, typescript.esLibs)} · JSON modules ${targets.resolveJsonModule ? 'yes' : 'no'}`);
56
+ }
57
+ lines.push(`${bold('Data')} ${data.map(entry => formatDataPackage(entry)).join(' · ')}`, '');
58
+ if (findings.length === 0) {
59
+ lines.push(success('Everything is current.'));
60
+ return lines;
61
+ }
62
+ const groups = groupFindings(findings);
63
+ lines.push(failure(`${findings.length} finding${findings.length === 1 ? '' : 's'}:`));
64
+ for (const { change, message, subjects } of groups) {
65
+ lines.push(` ${yellow(change)} ${message}`, ...subjects.map(subject => dim(` ${subject}`)));
66
+ }
67
+ return lines;
68
+ }
69
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../src/report.ts"],"names":[],"mappings":"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","sourcesContent":["import { failure, success } from '@simbo/cli-output';\nimport {\n formatLibs,\n formatTarget,\n type DataPackage,\n type Finding,\n type PlatformCheckResult,\n} from '@simbo/platform-check';\nimport { bold, dim, yellow } from 'yoctocolors';\n\nimport type { FindingGroup } from './platform-check-cli.types.js';\n\n/**\n * Groups findings with the same check, change and message.\n *\n * @param findings - The findings.\n * @returns The groups, in the order of their first finding.\n */\nexport function groupFindings(findings: Finding[]): FindingGroup[] {\n const groups = new Map<string, FindingGroup>();\n for (const { subject, ...finding } of findings) {\n const key = `${finding.check}\\0${finding.change}\\0${finding.message}`;\n const group = groups.get(key);\n if (group) {\n group.subjects.push(subject);\n } else {\n groups.set(key, { ...finding, subjects: [subject] });\n }\n }\n return [...groups.values()];\n}\n\n/**\n * Formats a data package with the newer versions that exist.\n *\n * @param data - The version information.\n * @returns The formatted package, such as `web-features 3.48.0 (3.49.0 available)`.\n */\nfunction formatDataPackage(data: DataPackage): string {\n const { name, installed, latestInRange, latest, range } = data;\n const notes = [\n ...(installed === latestInRange ? [] : [`${latestInRange} available`]),\n ...(latest === latestInRange ? [] : [`${latest} outside ${range}`]),\n ];\n return `${name} ${installed}${notes.length === 0 ? '' : dim(` (${notes.join(', ')})`)}`;\n}\n\n/**\n * Formats the result of a platform check as report lines.\n *\n * @param result - The result.\n * @returns The report lines.\n */\nexport function formatReport(result: PlatformCheckResult): string[] {\n const { node, typescript, expected, data, findings } = result;\n const lines = [\n `${bold('Node.js')} ${[\n `maintained ${node.maintained.join(', ')}`,\n ...(node.dropped.length > 0 ? [`dropped ${node.dropped.join(', ')}`] : []),\n `Active LTS ${node.activeLts ?? 'none'}`,\n `lowest supported ${node.lowestVersion ?? 'unknown'}`,\n ].join(' · ')}`,\n ];\n for (const [platform, targets] of Object.entries(expected)) {\n lines.push(\n `${bold(platform)} target ${formatTarget(targets.target)} · lib ${formatLibs(targets.libs, typescript.esLibs)} · JSON modules ${targets.resolveJsonModule ? 'yes' : 'no'}`,\n );\n }\n lines.push(`${bold('Data')} ${data.map(entry => formatDataPackage(entry)).join(' · ')}`, '');\n\n if (findings.length === 0) {\n lines.push(success('Everything is current.'));\n return lines;\n }\n const groups = groupFindings(findings);\n lines.push(failure(`${findings.length} finding${findings.length === 1 ? '' : 's'}:`));\n for (const { change, message, subjects } of groups) {\n lines.push(` ${yellow(change)} ${message}`, ...subjects.map(subject => dim(` ${subject}`)));\n }\n return lines;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,88 @@
1
1
  {
2
2
  "name": "@simbo/platform-check-cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "description": "A CLI that checks whether a repository's Node.js and ECMAScript platform targets are still current.",
4
+ "version": "1.0.1",
5
+ "keywords": [
6
+ "platform",
7
+ "node",
8
+ "engines",
9
+ "browsers",
10
+ "baseline",
11
+ "ecmascript",
12
+ "typescript",
13
+ "tsconfig",
14
+ "lib",
15
+ "target",
16
+ "monorepo",
17
+ "check",
18
+ "cli"
19
+ ],
20
+ "author": "Simon Lepel <simbo@simbo.de> (https://simbo.de/)",
21
+ "license": "MIT",
22
+ "homepage": "https://github.com/simbo/packages/tree/main/packages/platform-check-cli",
23
+ "repository": {
24
+ "type": "git",
25
+ "url": "git+https://github.com/simbo/packages.git",
26
+ "directory": "packages/platform-check-cli"
27
+ },
28
+ "bugs": "https://github.com/simbo/packages/issues",
29
+ "engines": {
30
+ "node": "^24.15.0 || >=26.0.0"
31
+ },
32
+ "type": "module",
33
+ "exports": {
34
+ ".": "./dist/index.js"
35
+ },
36
+ "bin": {
37
+ "platform-check": "dist/cli.js"
38
+ },
39
+ "files": [
40
+ "CHANGELOG.md",
41
+ "dist",
42
+ "LICENSE.md",
43
+ "README.md"
44
+ ],
45
+ "dependencies": {
46
+ "@simbo/cli-output": "3.0.0",
47
+ "@simbo/clirk": "3.0.5",
48
+ "@simbo/graceful-exit": "3.0.1",
49
+ "@simbo/monorepo-utils": "4.0.5",
50
+ "@simbo/platform-check": "1.0.1",
51
+ "@simbo/user-facing-error": "3.1.0",
52
+ "@simbo/zodpak": "2.1.0",
53
+ "cosmiconfig": "^10.0.1",
54
+ "cosmiconfig-typescript-loader": "^6.3.0",
55
+ "yoctocolors": "^2.2.0",
56
+ "zod": "^4.6.7"
57
+ },
58
+ "devDependencies": {
59
+ "@simbo/eslint-config": "7.0.0",
60
+ "@simbo/tsconfig": "5.0.0",
61
+ "@types/node": "^24.19.4",
62
+ "@vitest/coverage-v8": "^5.1.2",
63
+ "@vitest/ui": "^5.1.2",
64
+ "eslint": "^10.16.0",
65
+ "jiti": "^2.7.0",
66
+ "typescript": "^6.0.3",
67
+ "vitest": "^5.1.2"
68
+ },
69
+ "peerDependencies": {
70
+ "typescript": "^6"
71
+ },
72
+ "scripts": {
73
+ "build": "tsc --project tsconfig.build.json && chmod +x dist/cli.js",
74
+ "check": "pnpm run check:eslint && pnpm run check:types",
75
+ "check:eslint": "eslint --config ./eslint.config.ts --max-warnings 0",
76
+ "check:pack": "node ../../scripts/check-pack.js",
77
+ "check:types": "tsc --noEmit",
78
+ "clean": "pnpm run clean:dist && pnpm run clean:coverage && pnpm run clean:turbo && pnpm run clean:node_modules",
79
+ "clean:dist": "rm -rf dist",
80
+ "clean:node_modules": "rm -rf node_modules",
81
+ "clean:turbo": "rm -rf .turbo",
82
+ "clean:coverage": "rm -rf coverage",
83
+ "fix:eslint": "pnpm run check:eslint --fix",
84
+ "test": "vitest run --coverage",
85
+ "test:ui": "pnpm run test:watch --ui",
86
+ "test:watch": "vitest dev --coverage"
87
+ }
6
88
  }