@smoothbricks/cli 0.10.2 → 0.10.4

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.
Files changed (133) hide show
  1. package/README.md +31 -23
  2. package/dist/bun/preload.d.ts +13 -0
  3. package/dist/bun/preload.d.ts.map +1 -0
  4. package/dist/bun/preload.js +12 -0
  5. package/dist/cli.js +36 -4
  6. package/dist/generate/index.d.ts.map +1 -1
  7. package/dist/generate/index.js +0 -6
  8. package/dist/github-ci/index.d.ts +17 -2
  9. package/dist/github-ci/index.d.ts.map +1 -1
  10. package/dist/github-ci/index.js +192 -26
  11. package/dist/github-ci/outputs.d.ts +22 -0
  12. package/dist/github-ci/outputs.d.ts.map +1 -0
  13. package/dist/github-ci/outputs.js +648 -0
  14. package/dist/lib/cli-package.js +2 -2
  15. package/dist/lib/json.d.ts +118 -11
  16. package/dist/lib/json.d.ts.map +1 -1
  17. package/dist/lib/json.js +317 -29
  18. package/dist/lib/workspace.d.ts +7 -14
  19. package/dist/lib/workspace.d.ts.map +1 -1
  20. package/dist/lib/workspace.js +76 -82
  21. package/dist/monorepo/ci-workflow.d.ts +2 -0
  22. package/dist/monorepo/ci-workflow.d.ts.map +1 -1
  23. package/dist/monorepo/ci-workflow.js +28 -2
  24. package/dist/monorepo/git-config.js +2 -2
  25. package/dist/monorepo/index.d.ts +3 -1
  26. package/dist/monorepo/index.d.ts.map +1 -1
  27. package/dist/monorepo/index.js +6 -2
  28. package/dist/monorepo/lockfile.d.ts +13 -1
  29. package/dist/monorepo/lockfile.d.ts.map +1 -1
  30. package/dist/monorepo/lockfile.js +33 -21
  31. package/dist/monorepo/managed-files.d.ts +12 -0
  32. package/dist/monorepo/managed-files.d.ts.map +1 -1
  33. package/dist/monorepo/managed-files.js +86 -28
  34. package/dist/monorepo/package-policy.d.ts.map +1 -1
  35. package/dist/monorepo/package-policy.js +78 -45
  36. package/dist/monorepo/packed-manifest.d.ts +5 -2
  37. package/dist/monorepo/packed-manifest.d.ts.map +1 -1
  38. package/dist/monorepo/packed-manifest.js +16 -47
  39. package/dist/monorepo/packed-package.d.ts.map +1 -1
  40. package/dist/monorepo/packed-package.js +28 -16
  41. package/dist/monorepo/packs/index.d.ts +3 -0
  42. package/dist/monorepo/packs/index.d.ts.map +1 -1
  43. package/dist/monorepo/packs/index.js +18 -6
  44. package/dist/monorepo/publish-workflow.d.ts +1 -0
  45. package/dist/monorepo/publish-workflow.d.ts.map +1 -1
  46. package/dist/monorepo/publish-workflow.js +242 -3
  47. package/dist/monorepo/runtime.d.ts +15 -0
  48. package/dist/monorepo/runtime.d.ts.map +1 -1
  49. package/dist/monorepo/runtime.js +66 -12
  50. package/dist/monorepo/tool-validation.d.ts.map +1 -1
  51. package/dist/monorepo/tool-validation.js +32 -23
  52. package/dist/monorepo/wrangler.d.ts.map +1 -1
  53. package/dist/monorepo/wrangler.js +13 -13
  54. package/dist/nx/index.d.ts +12 -4
  55. package/dist/nx/index.d.ts.map +1 -1
  56. package/dist/nx/index.js +86 -19
  57. package/dist/pr/index.d.ts.map +1 -1
  58. package/dist/pr/index.js +28 -32
  59. package/dist/release/candidates.d.ts +3 -2
  60. package/dist/release/candidates.d.ts.map +1 -1
  61. package/dist/release/candidates.js +4 -5
  62. package/dist/release/github-release.d.ts +3 -0
  63. package/dist/release/github-release.d.ts.map +1 -1
  64. package/dist/release/github-release.js +11 -0
  65. package/dist/release/index.d.ts +20 -1
  66. package/dist/release/index.d.ts.map +1 -1
  67. package/dist/release/index.js +221 -89
  68. package/dist/release/orchestration.d.ts +8 -1
  69. package/dist/release/orchestration.d.ts.map +1 -1
  70. package/dist/release/orchestration.js +38 -1
  71. package/dist/wrangler/prepare-env.d.ts +0 -1
  72. package/dist/wrangler/prepare-env.d.ts.map +1 -1
  73. package/dist/wrangler/prepare-env.js +100 -51
  74. package/dist/wrangler/scaffold.d.ts.map +1 -1
  75. package/dist/wrangler/scaffold.js +12 -12
  76. package/managed/raw/git-format-staged.yml +19 -1
  77. package/managed/raw/tooling/direnv/github-actions-bootstrap.sh +6 -0
  78. package/managed/raw/tooling/direnv/merge-newer-pins.sh +3 -3
  79. package/managed/raw/tooling/direnv/setup-environment.ts +187 -19
  80. package/managed/raw/tooling/git-hooks/pre-commit.sh +0 -6
  81. package/managed/templates/github/actions/cache-nix-devenv/action.yml +12 -10
  82. package/managed/templates/github/actions/cache-node-modules/action.yml +6 -2
  83. package/managed/templates/github/actions/cache-nx/action.yml +2 -2
  84. package/managed/templates/github/actions/cache-ttsc-plugins/action.yml +19 -0
  85. package/managed/templates/github/actions/save-nix-devenv/action.yml +11 -3
  86. package/managed/templates/github/actions/setup-devenv/action.yml +5 -0
  87. package/managed/templates/github/workflows/managed-files.yml +80 -0
  88. package/package.json +18 -4
  89. package/src/bun/preload.ts +12 -0
  90. package/src/cli.ts +49 -11
  91. package/src/generate/index.ts +0 -6
  92. package/src/github-ci/index.test.ts +486 -0
  93. package/src/github-ci/index.ts +220 -30
  94. package/src/github-ci/outputs.ts +505 -0
  95. package/src/lib/cli-package.ts +2 -2
  96. package/src/lib/json.ts +291 -32
  97. package/src/lib/workspace.ts +88 -100
  98. package/src/monorepo/__tests__/ci-workflow.test.ts +14 -3
  99. package/src/monorepo/__tests__/publish-workflow.test.ts +222 -1
  100. package/src/monorepo/ci-workflow.ts +28 -2
  101. package/src/monorepo/git-config.ts +2 -2
  102. package/src/monorepo/index.ts +6 -2
  103. package/src/monorepo/lockfile.test.ts +35 -36
  104. package/src/monorepo/lockfile.ts +48 -24
  105. package/src/monorepo/managed-files.test.ts +63 -0
  106. package/src/monorepo/managed-files.ts +94 -34
  107. package/src/monorepo/package-policy.test.ts +70 -51
  108. package/src/monorepo/package-policy.ts +104 -59
  109. package/src/monorepo/packed-manifest.ts +18 -52
  110. package/src/monorepo/packed-package.ts +43 -22
  111. package/src/monorepo/packs/index.test.ts +18 -1
  112. package/src/monorepo/packs/index.ts +20 -7
  113. package/src/monorepo/publish-workflow.ts +482 -3
  114. package/src/monorepo/runtime.test.ts +42 -3
  115. package/src/monorepo/runtime.ts +90 -12
  116. package/src/monorepo/tool-validation.ts +35 -25
  117. package/src/monorepo/wrangler.test.ts +11 -15
  118. package/src/monorepo/wrangler.ts +15 -15
  119. package/src/nx/index.test.ts +43 -0
  120. package/src/nx/index.ts +110 -23
  121. package/src/pr/index.ts +42 -36
  122. package/src/release/__tests__/candidates.test.ts +5 -4
  123. package/src/release/__tests__/fixture-repo.test.ts +18 -16
  124. package/src/release/__tests__/github-release.test.ts +11 -0
  125. package/src/release/__tests__/orchestration.test.ts +57 -2
  126. package/src/release/__tests__/trust-publisher.test.ts +98 -2
  127. package/src/release/candidates.ts +10 -17
  128. package/src/release/github-release.ts +12 -0
  129. package/src/release/index.ts +321 -112
  130. package/src/release/orchestration.ts +55 -3
  131. package/src/wrangler/prepare-env.ts +75 -54
  132. package/src/wrangler/scaffold.test.ts +9 -12
  133. package/src/wrangler/scaffold.ts +13 -13
@@ -1,13 +1,120 @@
1
- import { hasOwn, hasOwnString, isRecord } from '@smoothbricks/validation';
2
- export { hasOwn, hasOwnString, isRecord };
3
- export declare function stringProperty(record: Record<string, unknown>, key: string): string | null;
4
- export declare function recordProperty(record: Record<string, unknown>, key: string): Record<string, unknown> | null;
5
- export declare function getOrCreateRecord(record: Record<string, unknown>, key: string): Record<string, unknown>;
6
- export declare function setStringProperty(record: Record<string, unknown>, key: string, value: string): boolean;
7
- export declare function setMissingStringProperty(record: Record<string, unknown>, key: string, value: string): boolean;
8
- export declare function requiredJsonObject(path: string): Record<string, unknown>;
9
- export declare function readJsonObject(path: string): Record<string, unknown> | null;
10
- export declare function writeJsonObject(path: string, value: Record<string, unknown>): void;
11
- export declare function jsonObjectText(value: Record<string, unknown>): string;
1
+ /** String-keyed dependency / script / engine maps. */
2
+ export type StringMap = Record<string, string>;
3
+ export interface PackageRepository {
4
+ type?: string;
5
+ url?: string;
6
+ directory?: string;
7
+ }
8
+ export interface PackageNxConfig {
9
+ name?: string;
10
+ tags?: string[];
11
+ includedScripts?: string[];
12
+ targets?: Record<string, NxTargetConfig>;
13
+ }
14
+ export interface PackagePublishConfig {
15
+ access?: string;
16
+ }
17
+ export interface PackageSmooGithub {
18
+ pushBranches?: string[];
19
+ }
20
+ export interface PackageSmooConfig {
21
+ github?: PackageSmooGithub;
22
+ }
23
+ export interface PackageWorkspacesObject {
24
+ packages?: string[];
25
+ }
26
+ /**
27
+ * package.json shape used by smoo. Optional fields stay optional so partial
28
+ * manifests parse; mutation helpers create nested objects on demand.
29
+ */
30
+ export interface PackageJson {
31
+ name?: string;
32
+ version?: string;
33
+ private?: boolean;
34
+ license?: string;
35
+ types?: string;
36
+ packageManager?: string;
37
+ files?: string[];
38
+ bin?: string | StringMap;
39
+ exports?: PackageExports;
40
+ workspaces?: string[] | PackageWorkspacesObject;
41
+ dependencies?: StringMap;
42
+ devDependencies?: StringMap;
43
+ peerDependencies?: StringMap;
44
+ optionalDependencies?: StringMap;
45
+ engines?: StringMap;
46
+ scripts?: StringMap;
47
+ publishConfig?: PackagePublishConfig;
48
+ repository?: string | PackageRepository;
49
+ nx?: PackageNxConfig;
50
+ smoo?: PackageSmooConfig;
51
+ }
52
+ /** Recursive package exports map (conditions nest arbitrarily). */
53
+ export type PackageExports = string | PackageExportMap | null | undefined;
54
+ export interface PackageExportMap {
55
+ [condition: string]: PackageExports;
56
+ }
57
+ export interface NxDependsOnObject {
58
+ target: string;
59
+ projects?: string | string[];
60
+ }
61
+ export type NxDependsOn = string | NxDependsOnObject;
62
+ /** Nx target options are executor-specific open bags. */
63
+ export type NxTargetOptions = Record<string, unknown>;
64
+ export type NxInput = string | Record<string, unknown>;
65
+ export interface NxTargetConfig {
66
+ executor?: string;
67
+ dependsOn?: NxDependsOn[];
68
+ outputs?: string[];
69
+ inputs?: NxInput[];
70
+ options?: NxTargetOptions;
71
+ configurations?: Record<string, NxTargetConfig>;
72
+ cache?: boolean;
73
+ command?: string;
74
+ parallelism?: boolean;
75
+ }
76
+ export interface NxProjectJson {
77
+ name?: string;
78
+ root?: string;
79
+ targets?: Record<string, NxTargetConfig>;
80
+ }
81
+ export interface NxJson {
82
+ namedInputs?: Record<string, Array<string | Record<string, unknown>> | string>;
83
+ }
84
+ /** Parse package.json text. Invalid JSON throws; wrong shape returns null. */
85
+ export declare const parsePackageJsonText: (input: string) => PackageJson | null;
86
+ /** Parse `nx show project --json` output. Invalid JSON throws; wrong shape returns null. */
87
+ export declare const parseNxProjectJsonText: (input: string) => NxProjectJson | null;
88
+ /** Parse nx.json text. Invalid JSON throws; wrong shape returns null. */
89
+ export declare const parseNxJsonText: (input: string) => NxJson | null;
90
+ /** Parse a JSON string array. Invalid JSON throws; non-arrays return null. */
91
+ export declare const parseStringArrayText: (input: string) => string[] | null;
92
+ export declare function readJsonObject(path: string): PackageJson | null;
93
+ export declare function requiredJsonObject(path: string): PackageJson;
94
+ export declare function writeJsonObject(path: string, value: object): void;
95
+ export declare function jsonObjectText(value: object): string;
12
96
  export declare function readJson(path: string): unknown;
97
+ export declare function isPackageJson(value: unknown): value is PackageJson;
98
+ /** Ensure package.json.scripts exists. */
99
+ export declare function ensureScripts(pkg: PackageJson): StringMap;
100
+ /** Ensure package.json.dependencies (or other string-map dep field) exists. */
101
+ export declare function ensureDependencyMap(pkg: PackageJson, key: 'dependencies' | 'devDependencies' | 'peerDependencies' | 'optionalDependencies'): StringMap;
102
+ /** Ensure package.json.engines exists. */
103
+ export declare function ensureEngines(pkg: PackageJson): StringMap;
104
+ /** Ensure package.json.nx exists. */
105
+ export declare function ensureNx(pkg: PackageJson): PackageNxConfig;
106
+ /** Ensure package.json.nx.targets exists. */
107
+ export declare function ensureNxTargets(nx: PackageNxConfig): Record<string, NxTargetConfig>;
108
+ /** Ensure package.json.publishConfig exists. */
109
+ export declare function ensurePublishConfig(pkg: PackageJson): PackagePublishConfig;
110
+ /** Ensure package.json.repository is an object (not a string URL). */
111
+ export declare function ensureRepositoryObject(pkg: PackageJson): PackageRepository;
112
+ export declare function setStringProperty(record: StringMap, key: string, value: string): boolean;
113
+ export declare function setMissingStringProperty(record: StringMap, key: string, value: string): boolean;
114
+ export declare function setPackageStringField(pkg: PackageJson, key: 'name' | 'version' | 'license' | 'types' | 'packageManager', value: string): boolean;
115
+ export declare function setMissingPackageStringField(pkg: PackageJson, key: 'name' | 'version' | 'license' | 'types' | 'packageManager', value: string): boolean;
116
+ export declare function setNxName(nx: PackageNxConfig, value: string): boolean;
117
+ export declare function setPublishAccess(publishConfig: PackagePublishConfig, value: string): boolean;
118
+ export declare function setRepositoryField(repository: PackageRepository, key: 'type' | 'url' | 'directory', value: string): boolean;
119
+ export declare function setMissingRepositoryField(repository: PackageRepository, key: 'type' | 'url' | 'directory', value: string): boolean;
13
120
  //# sourceMappingURL=json.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/lib/json.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,CAAC;AAE1C,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG1F;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAG3G;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAQvG;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,M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AAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAMxF;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAM/F;AAED,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,EAChE,KAAK,EAAE,MAAM,GACZ,OAAO,CAMT;AAED,wBAAgB,4BAA4B,CAC1C,GAAG,EAAE,WAAW,EAChB,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,gBAAgB,EAChE,KAAK,EAAE,MAAM,GACZ,OAAO,CAMT;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAMrE;AAED,wBAAgB,gBAAgB,CAAC,aAAa,EAAE,oBAAoB,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAM5F;AAED,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,iBAAiB,EAC7B,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,WAAW,EACjC,KAAK,EAAE,MAAM,GACZ,OAAO,CAMT;AAED,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,iBAAiB,EAC7B,GAAG,EAAE,MAAM,GAAG,KAAK,GAAG,WAAW,EACjC,KAAK,EAAE,MAAM,GACZ,OAAO,CAMT"}
package/dist/lib/json.js CHANGED
@@ -1,21 +1,275 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { hasOwn, hasOwnString, isRecord } from '@smoothbricks/validation';
3
- export { hasOwn, hasOwnString, isRecord };
4
- export function stringProperty(record, key) {
5
- const value = record[key];
6
- return typeof value === 'string' && value.length > 0 ? value : null;
2
+ import typia from 'typia';
3
+ /** Parse package.json text. Invalid JSON throws; wrong shape returns null. */
4
+ export const parsePackageJsonText = (() => {
5
+ const _ip0 = (input, _vctx = {}) => undefined === input["name"] || "string" === typeof input["name"];
6
+ const _ip1 = (input, _vctx = {}) => undefined === input["version"] || "string" === typeof input["version"];
7
+ const _ip2 = (input, _vctx = {}) => undefined === input["private"] || "boolean" === typeof input["private"];
8
+ const _ip3 = (input, _vctx = {}) => undefined === input["license"] || "string" === typeof input["license"];
9
+ const _ip4 = (input, _vctx = {}) => undefined === input["types"] || "string" === typeof input["types"];
10
+ const _ip5 = (input, _vctx = {}) => undefined === input["packageManager"] || "string" === typeof input["packageManager"];
11
+ const _ip6 = (input, _vctx = {}) => undefined === input["files"] || Array.isArray(input["files"]) && input["files"].every(elem => "string" === typeof elem);
12
+ const _ip7 = (input, _vctx = {}) => null !== input["bin"] && (undefined === input["bin"] || "string" === typeof input["bin"] || "object" === typeof input["bin"] && null !== input["bin"] && false === Array.isArray(input["bin"]) && _io1(input["bin"], _vctx));
13
+ const _ip8 = (input, _vctx = {}) => null === input["exports"] || undefined === input["exports"] || "string" === typeof input["exports"] || "object" === typeof input["exports"] && null !== input["exports"] && false === Array.isArray(input["exports"]) && _io2(input["exports"], _vctx);
14
+ const _ip9 = (input, _vctx = {}) => null !== input["workspaces"] && (undefined === input["workspaces"] || (Array.isArray(input["workspaces"]) && input["workspaces"].every(elem => "string" === typeof elem) || "object" === typeof input["workspaces"] && null !== input["workspaces"] && false === Array.isArray(input["workspaces"]) && _io3(input["workspaces"], _vctx)));
15
+ const _ip10 = (input, _vctx = {}) => undefined === input["dependencies"] || "object" === typeof input["dependencies"] && null !== input["dependencies"] && false === Array.isArray(input["dependencies"]) && _io1(input["dependencies"], _vctx);
16
+ const _ip11 = (input, _vctx = {}) => undefined === input["devDependencies"] || "object" === typeof input["devDependencies"] && null !== input["devDependencies"] && false === Array.isArray(input["devDependencies"]) && _io1(input["devDependencies"], _vctx);
17
+ const _ip12 = (input, _vctx = {}) => undefined === input["peerDependencies"] || "object" === typeof input["peerDependencies"] && null !== input["peerDependencies"] && false === Array.isArray(input["peerDependencies"]) && _io1(input["peerDependencies"], _vctx);
18
+ const _ip13 = (input, _vctx = {}) => undefined === input["optionalDependencies"] || "object" === typeof input["optionalDependencies"] && null !== input["optionalDependencies"] && false === Array.isArray(input["optionalDependencies"]) && _io1(input["optionalDependencies"], _vctx);
19
+ const _ip14 = (input, _vctx = {}) => undefined === input["engines"] || "object" === typeof input["engines"] && null !== input["engines"] && false === Array.isArray(input["engines"]) && _io1(input["engines"], _vctx);
20
+ const _ip15 = (input, _vctx = {}) => undefined === input["scripts"] || "object" === typeof input["scripts"] && null !== input["scripts"] && false === Array.isArray(input["scripts"]) && _io1(input["scripts"], _vctx);
21
+ const _ip16 = (input, _vctx = {}) => undefined === input["publishConfig"] || "object" === typeof input["publishConfig"] && null !== input["publishConfig"] && false === Array.isArray(input["publishConfig"]) && _io4(input["publishConfig"], _vctx);
22
+ const _ip17 = (input, _vctx = {}) => null !== input["repository"] && (undefined === input["repository"] || "string" === typeof input["repository"] || "object" === typeof input["repository"] && null !== input["repository"] && false === Array.isArray(input["repository"]) && _io5(input["repository"], _vctx));
23
+ const _ip18 = (input, _vctx = {}) => undefined === input["nx"] || "object" === typeof input["nx"] && null !== input["nx"] && false === Array.isArray(input["nx"]) && _io6(input["nx"], _vctx);
24
+ const _ip19 = (input, _vctx = {}) => undefined === input["smoo"] || "object" === typeof input["smoo"] && null !== input["smoo"] && false === Array.isArray(input["smoo"]) && _io12(input["smoo"], _vctx);
25
+ const _io0 = (input, _vctx = {}) => _ip0(input, _vctx) && _ip1(input, _vctx) && _ip2(input, _vctx) && _ip3(input, _vctx) && _ip4(input, _vctx) && _ip5(input, _vctx) && _ip6(input, _vctx) && _ip7(input, _vctx) && _ip8(input, _vctx) && _ip9(input, _vctx) && _ip10(input, _vctx) && _ip11(input, _vctx) && _ip12(input, _vctx) && _ip13(input, _vctx) && _ip14(input, _vctx) && _ip15(input, _vctx) && _ip16(input, _vctx) && _ip17(input, _vctx) && _ip18(input, _vctx) && _ip19(input, _vctx);
26
+ const _io1 = (input, _vctx = {}) => Object.keys(input).every(key => {
27
+ const value = input[key];
28
+ if (undefined === value)
29
+ return true;
30
+ return "string" === typeof value;
31
+ });
32
+ const _io10 = (input, _vctx = {}) => Object.keys(input).every(key => {
33
+ const value = input[key];
34
+ if (undefined === value)
35
+ return true;
36
+ return true;
37
+ });
38
+ const _io11 = (input, _vctx = {}) => Object.keys(input).every(key => {
39
+ const value = input[key];
40
+ if (undefined === value)
41
+ return true;
42
+ return true;
43
+ });
44
+ const _io12 = (input, _vctx = {}) => undefined === input.github || "object" === typeof input.github && null !== input.github && false === Array.isArray(input.github) && _io13(input.github, _vctx);
45
+ const _io13 = (input, _vctx = {}) => undefined === input.pushBranches || Array.isArray(input.pushBranches) && input.pushBranches.every(elem => "string" === typeof elem);
46
+ const _io2 = (input, _vctx = {}) => (_vctx.io2 || (_vctx.io2 = new WeakSet())).has(input) ? true : (_vctx.io2.add(input), (Object.keys(input).every(key => {
47
+ const value = input[key];
48
+ if (undefined === value)
49
+ return true;
50
+ return null === value || undefined === value || "string" === typeof value || "object" === typeof value && null !== value && false === Array.isArray(value) && _io2(value, _vctx);
51
+ })) || (_vctx.io2.delete(input), false));
52
+ const _io3 = (input, _vctx = {}) => undefined === input.packages || Array.isArray(input.packages) && input.packages.every(elem => "string" === typeof elem);
53
+ const _io4 = (input, _vctx = {}) => undefined === input.access || "string" === typeof input.access;
54
+ const _io5 = (input, _vctx = {}) => (undefined === input.type || "string" === typeof input.type) && (undefined === input.url || "string" === typeof input.url) && (undefined === input.directory || "string" === typeof input.directory);
55
+ const _io6 = (input, _vctx = {}) => _ip0(input, _vctx) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem)) && (undefined === input.includedScripts || Array.isArray(input.includedScripts) && input.includedScripts.every(elem => "string" === typeof elem)) && (undefined === input.targets || "object" === typeof input.targets && null !== input.targets && false === Array.isArray(input.targets) && _io7(input.targets, _vctx));
56
+ const _io7 = (input, _vctx = {}) => (_vctx.io7 || (_vctx.io7 = new WeakSet())).has(input) ? true : (_vctx.io7.add(input), (Object.keys(input).every(key => {
57
+ const value = input[key];
58
+ if (undefined === value)
59
+ return true;
60
+ return "object" === typeof value && null !== value && false === Array.isArray(value) && _io8(value, _vctx);
61
+ })) || (_vctx.io7.delete(input), false));
62
+ const _io8 = (input, _vctx = {}) => (_vctx.io8 || (_vctx.io8 = new WeakSet())).has(input) ? true : (_vctx.io8.add(input), ((undefined === input.executor || "string" === typeof input.executor) && (undefined === input.dependsOn || Array.isArray(input.dependsOn) && input.dependsOn.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io9(elem, _vctx)))) && (undefined === input.outputs || Array.isArray(input.outputs) && input.outputs.every(elem => "string" === typeof elem)) && (undefined === input.inputs || Array.isArray(input.inputs) && input.inputs.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io10(elem, _vctx)))) && (undefined === input.options || "object" === typeof input.options && null !== input.options && false === Array.isArray(input.options) && _io11(input.options, _vctx)) && (undefined === input.configurations || "object" === typeof input.configurations && null !== input.configurations && false === Array.isArray(input.configurations) && _io7(input.configurations, _vctx)) && (undefined === input.cache || "boolean" === typeof input.cache) && (undefined === input.command || "string" === typeof input.command) && (undefined === input.parallelism || "boolean" === typeof input.parallelism)) || (_vctx.io8.delete(input), false));
63
+ const _io9 = (input, _vctx = {}) => "string" === typeof input.target && (null !== input.projects && (undefined === input.projects || "string" === typeof input.projects || Array.isArray(input.projects) && input.projects.every(elem => "string" === typeof elem)));
64
+ const __is = (input, _vctx = {}) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input, _vctx);
65
+ return input => { input = JSON.parse(input); return __is(input) ? input : null; };
66
+ })();
67
+ /** Parse `nx show project --json` output. Invalid JSON throws; wrong shape returns null. */
68
+ export const parseNxProjectJsonText = (() => {
69
+ const _io0 = (input, _vctx = {}) => (undefined === input.name || "string" === typeof input.name) && (undefined === input.root || "string" === typeof input.root) && (undefined === input.targets || "object" === typeof input.targets && null !== input.targets && false === Array.isArray(input.targets) && _io1(input.targets, _vctx));
70
+ const _io1 = (input, _vctx = {}) => (_vctx.io1 || (_vctx.io1 = new WeakSet())).has(input) ? true : (_vctx.io1.add(input), (Object.keys(input).every(key => {
71
+ const value = input[key];
72
+ if (undefined === value)
73
+ return true;
74
+ return "object" === typeof value && null !== value && false === Array.isArray(value) && _io2(value, _vctx);
75
+ })) || (_vctx.io1.delete(input), false));
76
+ const _io2 = (input, _vctx = {}) => (_vctx.io2 || (_vctx.io2 = new WeakSet())).has(input) ? true : (_vctx.io2.add(input), ((undefined === input.executor || "string" === typeof input.executor) && (undefined === input.dependsOn || Array.isArray(input.dependsOn) && input.dependsOn.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io3(elem, _vctx)))) && (undefined === input.outputs || Array.isArray(input.outputs) && input.outputs.every(elem => "string" === typeof elem)) && (undefined === input.inputs || Array.isArray(input.inputs) && input.inputs.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io4(elem, _vctx)))) && (undefined === input.options || "object" === typeof input.options && null !== input.options && false === Array.isArray(input.options) && _io5(input.options, _vctx)) && (undefined === input.configurations || "object" === typeof input.configurations && null !== input.configurations && false === Array.isArray(input.configurations) && _io1(input.configurations, _vctx)) && (undefined === input.cache || "boolean" === typeof input.cache) && (undefined === input.command || "string" === typeof input.command) && (undefined === input.parallelism || "boolean" === typeof input.parallelism)) || (_vctx.io2.delete(input), false));
77
+ const _io3 = (input, _vctx = {}) => "string" === typeof input.target && (null !== input.projects && (undefined === input.projects || "string" === typeof input.projects || Array.isArray(input.projects) && input.projects.every(elem => "string" === typeof elem)));
78
+ const _io4 = (input, _vctx = {}) => Object.keys(input).every(key => {
79
+ const value = input[key];
80
+ if (undefined === value)
81
+ return true;
82
+ return true;
83
+ });
84
+ const _io5 = (input, _vctx = {}) => Object.keys(input).every(key => {
85
+ const value = input[key];
86
+ if (undefined === value)
87
+ return true;
88
+ return true;
89
+ });
90
+ const __is = (input, _vctx = {}) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input, _vctx);
91
+ return input => { input = JSON.parse(input); return __is(input) ? input : null; };
92
+ })();
93
+ /** Parse nx.json text. Invalid JSON throws; wrong shape returns null. */
94
+ export const parseNxJsonText = (() => {
95
+ const _io0 = input => undefined === input.namedInputs || "object" === typeof input.namedInputs && null !== input.namedInputs && false === Array.isArray(input.namedInputs) && _io1(input.namedInputs);
96
+ const _io1 = input => Object.keys(input).every(key => {
97
+ const value = input[key];
98
+ if (undefined === value)
99
+ return true;
100
+ return null !== value && undefined !== value && ("string" === typeof value || Array.isArray(value) && value.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io2(elem))));
101
+ });
102
+ const _io2 = input => Object.keys(input).every(key => {
103
+ const value = input[key];
104
+ if (undefined === value)
105
+ return true;
106
+ return true;
107
+ });
108
+ const __is = input => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input);
109
+ return input => { input = JSON.parse(input); return __is(input) ? input : null; };
110
+ })();
111
+ /** Parse a JSON string array. Invalid JSON throws; non-arrays return null. */
112
+ export const parseStringArrayText = (() => {
113
+ const __is = input => Array.isArray(input) && input.every(elem => "string" === typeof elem);
114
+ return input => { input = JSON.parse(input); return __is(input) ? input : null; };
115
+ })();
116
+ const isPackageJsonValue = (() => {
117
+ const _ip0 = (input, _vctx = {}) => undefined === input["name"] || "string" === typeof input["name"];
118
+ const _ip1 = (input, _vctx = {}) => undefined === input["version"] || "string" === typeof input["version"];
119
+ const _ip2 = (input, _vctx = {}) => undefined === input["private"] || "boolean" === typeof input["private"];
120
+ const _ip3 = (input, _vctx = {}) => undefined === input["license"] || "string" === typeof input["license"];
121
+ const _ip4 = (input, _vctx = {}) => undefined === input["types"] || "string" === typeof input["types"];
122
+ const _ip5 = (input, _vctx = {}) => undefined === input["packageManager"] || "string" === typeof input["packageManager"];
123
+ const _ip6 = (input, _vctx = {}) => undefined === input["files"] || Array.isArray(input["files"]) && input["files"].every(elem => "string" === typeof elem);
124
+ const _ip7 = (input, _vctx = {}) => null !== input["bin"] && (undefined === input["bin"] || "string" === typeof input["bin"] || "object" === typeof input["bin"] && null !== input["bin"] && false === Array.isArray(input["bin"]) && _io1(input["bin"], _vctx));
125
+ const _ip8 = (input, _vctx = {}) => null === input["exports"] || undefined === input["exports"] || "string" === typeof input["exports"] || "object" === typeof input["exports"] && null !== input["exports"] && false === Array.isArray(input["exports"]) && _io2(input["exports"], _vctx);
126
+ const _ip9 = (input, _vctx = {}) => null !== input["workspaces"] && (undefined === input["workspaces"] || (Array.isArray(input["workspaces"]) && input["workspaces"].every(elem => "string" === typeof elem) || "object" === typeof input["workspaces"] && null !== input["workspaces"] && false === Array.isArray(input["workspaces"]) && _io3(input["workspaces"], _vctx)));
127
+ const _ip10 = (input, _vctx = {}) => undefined === input["dependencies"] || "object" === typeof input["dependencies"] && null !== input["dependencies"] && false === Array.isArray(input["dependencies"]) && _io1(input["dependencies"], _vctx);
128
+ const _ip11 = (input, _vctx = {}) => undefined === input["devDependencies"] || "object" === typeof input["devDependencies"] && null !== input["devDependencies"] && false === Array.isArray(input["devDependencies"]) && _io1(input["devDependencies"], _vctx);
129
+ const _ip12 = (input, _vctx = {}) => undefined === input["peerDependencies"] || "object" === typeof input["peerDependencies"] && null !== input["peerDependencies"] && false === Array.isArray(input["peerDependencies"]) && _io1(input["peerDependencies"], _vctx);
130
+ const _ip13 = (input, _vctx = {}) => undefined === input["optionalDependencies"] || "object" === typeof input["optionalDependencies"] && null !== input["optionalDependencies"] && false === Array.isArray(input["optionalDependencies"]) && _io1(input["optionalDependencies"], _vctx);
131
+ const _ip14 = (input, _vctx = {}) => undefined === input["engines"] || "object" === typeof input["engines"] && null !== input["engines"] && false === Array.isArray(input["engines"]) && _io1(input["engines"], _vctx);
132
+ const _ip15 = (input, _vctx = {}) => undefined === input["scripts"] || "object" === typeof input["scripts"] && null !== input["scripts"] && false === Array.isArray(input["scripts"]) && _io1(input["scripts"], _vctx);
133
+ const _ip16 = (input, _vctx = {}) => undefined === input["publishConfig"] || "object" === typeof input["publishConfig"] && null !== input["publishConfig"] && false === Array.isArray(input["publishConfig"]) && _io4(input["publishConfig"], _vctx);
134
+ const _ip17 = (input, _vctx = {}) => null !== input["repository"] && (undefined === input["repository"] || "string" === typeof input["repository"] || "object" === typeof input["repository"] && null !== input["repository"] && false === Array.isArray(input["repository"]) && _io5(input["repository"], _vctx));
135
+ const _ip18 = (input, _vctx = {}) => undefined === input["nx"] || "object" === typeof input["nx"] && null !== input["nx"] && false === Array.isArray(input["nx"]) && _io6(input["nx"], _vctx);
136
+ const _ip19 = (input, _vctx = {}) => undefined === input["smoo"] || "object" === typeof input["smoo"] && null !== input["smoo"] && false === Array.isArray(input["smoo"]) && _io12(input["smoo"], _vctx);
137
+ const _io0 = (input, _vctx = {}) => _ip0(input, _vctx) && _ip1(input, _vctx) && _ip2(input, _vctx) && _ip3(input, _vctx) && _ip4(input, _vctx) && _ip5(input, _vctx) && _ip6(input, _vctx) && _ip7(input, _vctx) && _ip8(input, _vctx) && _ip9(input, _vctx) && _ip10(input, _vctx) && _ip11(input, _vctx) && _ip12(input, _vctx) && _ip13(input, _vctx) && _ip14(input, _vctx) && _ip15(input, _vctx) && _ip16(input, _vctx) && _ip17(input, _vctx) && _ip18(input, _vctx) && _ip19(input, _vctx);
138
+ const _io1 = (input, _vctx = {}) => Object.keys(input).every(key => {
139
+ const value = input[key];
140
+ if (undefined === value)
141
+ return true;
142
+ return "string" === typeof value;
143
+ });
144
+ const _io10 = (input, _vctx = {}) => Object.keys(input).every(key => {
145
+ const value = input[key];
146
+ if (undefined === value)
147
+ return true;
148
+ return true;
149
+ });
150
+ const _io11 = (input, _vctx = {}) => Object.keys(input).every(key => {
151
+ const value = input[key];
152
+ if (undefined === value)
153
+ return true;
154
+ return true;
155
+ });
156
+ const _io12 = (input, _vctx = {}) => undefined === input.github || "object" === typeof input.github && null !== input.github && false === Array.isArray(input.github) && _io13(input.github, _vctx);
157
+ const _io13 = (input, _vctx = {}) => undefined === input.pushBranches || Array.isArray(input.pushBranches) && input.pushBranches.every(elem => "string" === typeof elem);
158
+ const _io2 = (input, _vctx = {}) => (_vctx.io2 || (_vctx.io2 = new WeakSet())).has(input) ? true : (_vctx.io2.add(input), (Object.keys(input).every(key => {
159
+ const value = input[key];
160
+ if (undefined === value)
161
+ return true;
162
+ return null === value || undefined === value || "string" === typeof value || "object" === typeof value && null !== value && false === Array.isArray(value) && _io2(value, _vctx);
163
+ })) || (_vctx.io2.delete(input), false));
164
+ const _io3 = (input, _vctx = {}) => undefined === input.packages || Array.isArray(input.packages) && input.packages.every(elem => "string" === typeof elem);
165
+ const _io4 = (input, _vctx = {}) => undefined === input.access || "string" === typeof input.access;
166
+ const _io5 = (input, _vctx = {}) => (undefined === input.type || "string" === typeof input.type) && (undefined === input.url || "string" === typeof input.url) && (undefined === input.directory || "string" === typeof input.directory);
167
+ const _io6 = (input, _vctx = {}) => _ip0(input, _vctx) && (undefined === input.tags || Array.isArray(input.tags) && input.tags.every(elem => "string" === typeof elem)) && (undefined === input.includedScripts || Array.isArray(input.includedScripts) && input.includedScripts.every(elem => "string" === typeof elem)) && (undefined === input.targets || "object" === typeof input.targets && null !== input.targets && false === Array.isArray(input.targets) && _io7(input.targets, _vctx));
168
+ const _io7 = (input, _vctx = {}) => (_vctx.io7 || (_vctx.io7 = new WeakSet())).has(input) ? true : (_vctx.io7.add(input), (Object.keys(input).every(key => {
169
+ const value = input[key];
170
+ if (undefined === value)
171
+ return true;
172
+ return "object" === typeof value && null !== value && false === Array.isArray(value) && _io8(value, _vctx);
173
+ })) || (_vctx.io7.delete(input), false));
174
+ const _io8 = (input, _vctx = {}) => (_vctx.io8 || (_vctx.io8 = new WeakSet())).has(input) ? true : (_vctx.io8.add(input), ((undefined === input.executor || "string" === typeof input.executor) && (undefined === input.dependsOn || Array.isArray(input.dependsOn) && input.dependsOn.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && _io9(elem, _vctx)))) && (undefined === input.outputs || Array.isArray(input.outputs) && input.outputs.every(elem => "string" === typeof elem)) && (undefined === input.inputs || Array.isArray(input.inputs) && input.inputs.every(elem => null !== elem && undefined !== elem && ("string" === typeof elem || "object" === typeof elem && null !== elem && false === Array.isArray(elem) && _io10(elem, _vctx)))) && (undefined === input.options || "object" === typeof input.options && null !== input.options && false === Array.isArray(input.options) && _io11(input.options, _vctx)) && (undefined === input.configurations || "object" === typeof input.configurations && null !== input.configurations && false === Array.isArray(input.configurations) && _io7(input.configurations, _vctx)) && (undefined === input.cache || "boolean" === typeof input.cache) && (undefined === input.command || "string" === typeof input.command) && (undefined === input.parallelism || "boolean" === typeof input.parallelism)) || (_vctx.io8.delete(input), false));
175
+ const _io9 = (input, _vctx = {}) => "string" === typeof input.target && (null !== input.projects && (undefined === input.projects || "string" === typeof input.projects || Array.isArray(input.projects) && input.projects.every(elem => "string" === typeof elem)));
176
+ return (input, _vctx = {}) => "object" === typeof input && null !== input && false === Array.isArray(input) && _io0(input, _vctx);
177
+ })();
178
+ export function readJsonObject(path) {
179
+ if (!existsSync(path)) {
180
+ return null;
181
+ }
182
+ try {
183
+ return parsePackageJsonText(readFileSync(path, 'utf8'));
184
+ }
185
+ catch {
186
+ return null;
187
+ }
188
+ }
189
+ export function requiredJsonObject(path) {
190
+ const json = readJsonObject(path);
191
+ if (!json) {
192
+ throw new Error(`${path} not found or invalid`);
193
+ }
194
+ return json;
195
+ }
196
+ export function writeJsonObject(path, value) {
197
+ writeFileSync(path, jsonObjectText(value));
198
+ }
199
+ export function jsonObjectText(value) {
200
+ return `${JSON.stringify(value, null, 2)}\n`;
201
+ }
202
+ export function readJson(path) {
203
+ if (!existsSync(path)) {
204
+ return null;
205
+ }
206
+ return JSON.parse(readFileSync(path, 'utf8'));
207
+ }
208
+ export function isPackageJson(value) {
209
+ return isPackageJsonValue(value);
210
+ }
211
+ /** Ensure package.json.scripts exists. */
212
+ export function ensureScripts(pkg) {
213
+ if (isStringMap(pkg.scripts)) {
214
+ return pkg.scripts;
215
+ }
216
+ const next = {};
217
+ pkg.scripts = next;
218
+ return next;
219
+ }
220
+ /** Ensure package.json.dependencies (or other string-map dep field) exists. */
221
+ export function ensureDependencyMap(pkg, key) {
222
+ const current = pkg[key];
223
+ if (isStringMap(current)) {
224
+ return current;
225
+ }
226
+ const next = {};
227
+ pkg[key] = next;
228
+ return next;
229
+ }
230
+ /** Ensure package.json.engines exists. */
231
+ export function ensureEngines(pkg) {
232
+ if (isStringMap(pkg.engines)) {
233
+ return pkg.engines;
234
+ }
235
+ const next = {};
236
+ pkg.engines = next;
237
+ return next;
238
+ }
239
+ /** Ensure package.json.nx exists. */
240
+ export function ensureNx(pkg) {
241
+ if (isPackageNxConfig(pkg.nx)) {
242
+ return pkg.nx;
243
+ }
244
+ const next = {};
245
+ pkg.nx = next;
246
+ return next;
7
247
  }
8
- export function recordProperty(record, key) {
9
- const value = record[key];
10
- return isRecord(value) ? value : null;
248
+ /** Ensure package.json.nx.targets exists. */
249
+ export function ensureNxTargets(nx) {
250
+ if (isNxTargets(nx.targets)) {
251
+ return nx.targets;
252
+ }
253
+ const next = {};
254
+ nx.targets = next;
255
+ return next;
11
256
  }
12
- export function getOrCreateRecord(record, key) {
13
- const value = record[key];
14
- if (isRecord(value)) {
15
- return value;
257
+ /** Ensure package.json.publishConfig exists. */
258
+ export function ensurePublishConfig(pkg) {
259
+ if (isPublishConfig(pkg.publishConfig)) {
260
+ return pkg.publishConfig;
16
261
  }
17
262
  const next = {};
18
- record[key] = next;
263
+ pkg.publishConfig = next;
264
+ return next;
265
+ }
266
+ /** Ensure package.json.repository is an object (not a string URL). */
267
+ export function ensureRepositoryObject(pkg) {
268
+ if (isRepositoryObject(pkg.repository)) {
269
+ return pkg.repository;
270
+ }
271
+ const next = {};
272
+ pkg.repository = next;
19
273
  return next;
20
274
  }
21
275
  export function setStringProperty(record, key, value) {
@@ -32,26 +286,60 @@ export function setMissingStringProperty(record, key, value) {
32
286
  record[key] = value;
33
287
  return true;
34
288
  }
35
- export function requiredJsonObject(path) {
36
- const json = readJsonObject(path);
37
- if (!json) {
38
- throw new Error(`${path} not found or invalid`);
289
+ export function setPackageStringField(pkg, key, value) {
290
+ if (pkg[key] === value) {
291
+ return false;
39
292
  }
40
- return json;
293
+ pkg[key] = value;
294
+ return true;
41
295
  }
42
- export function readJsonObject(path) {
43
- const json = readJson(path);
44
- return isRecord(json) ? json : null;
296
+ export function setMissingPackageStringField(pkg, key, value) {
297
+ if (typeof pkg[key] === 'string') {
298
+ return false;
299
+ }
300
+ pkg[key] = value;
301
+ return true;
45
302
  }
46
- export function writeJsonObject(path, value) {
47
- writeFileSync(path, jsonObjectText(value));
303
+ export function setNxName(nx, value) {
304
+ if (nx.name === value) {
305
+ return false;
306
+ }
307
+ nx.name = value;
308
+ return true;
48
309
  }
49
- export function jsonObjectText(value) {
50
- return `${JSON.stringify(value, null, 2)}\n`;
310
+ export function setPublishAccess(publishConfig, value) {
311
+ if (publishConfig.access === value) {
312
+ return false;
313
+ }
314
+ publishConfig.access = value;
315
+ return true;
51
316
  }
52
- export function readJson(path) {
53
- if (!existsSync(path)) {
54
- return null;
317
+ export function setRepositoryField(repository, key, value) {
318
+ if (repository[key] === value) {
319
+ return false;
55
320
  }
56
- return JSON.parse(readFileSync(path, 'utf8'));
321
+ repository[key] = value;
322
+ return true;
323
+ }
324
+ export function setMissingRepositoryField(repository, key, value) {
325
+ if (typeof repository[key] === 'string') {
326
+ return false;
327
+ }
328
+ repository[key] = value;
329
+ return true;
330
+ }
331
+ function isStringMap(value) {
332
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
333
+ }
334
+ function isPackageNxConfig(value) {
335
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
336
+ }
337
+ function isNxTargets(value) {
338
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
339
+ }
340
+ function isPublishConfig(value) {
341
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
342
+ }
343
+ function isRepositoryObject(value) {
344
+ return value !== null && value !== undefined && typeof value === 'object' && !Array.isArray(value);
57
345
  }
@@ -1,3 +1,5 @@
1
+ import { type PackageJson, type PackageNxConfig, type PackageRepository } from './json.js';
2
+ export type { PackageJson, PackageNxConfig, PackageRepository };
1
3
  export interface PackageInfo {
2
4
  name: string;
3
5
  projectName: string;
@@ -6,7 +8,7 @@ export interface PackageInfo {
6
8
  tags: string[];
7
9
  path: string;
8
10
  packageJsonPath: string;
9
- json: Record<string, unknown>;
11
+ json: PackageJson;
10
12
  }
11
13
  export interface WorkspacePackageManifest {
12
14
  name: string;
@@ -14,23 +16,14 @@ export interface WorkspacePackageManifest {
14
16
  private: boolean;
15
17
  path: string;
16
18
  packageJsonPath: string;
17
- json: Record<string, unknown>;
18
- }
19
- export interface PackageJson extends Record<string, unknown> {
20
- name?: string;
21
- version?: string;
22
- private?: boolean;
23
- workspaces?: unknown;
24
- devDependencies?: unknown;
25
- dependencies?: unknown;
26
- nx?: unknown;
27
- repository?: unknown;
19
+ json: PackageJson;
28
20
  }
29
21
  export interface RepositoryInfo {
30
22
  type: string;
31
23
  url: string;
32
24
  }
33
25
  export declare const workspaceDependencyFields: readonly ['dependencies', 'devDependencies', 'peerDependencies', 'optionalDependencies'];
26
+ export type WorkspaceDependencyField = (typeof workspaceDependencyFields)[number];
34
27
  export declare function listPublicPackages(root: string): PackageInfo[];
35
28
  export declare function listReleasePackages(root: string, rootPackage?: PackageInfo | null): PackageInfo[];
36
29
  export declare function rootRepositoryInfo(root: string): RepositoryInfo | null;
@@ -45,8 +38,8 @@ export declare function getWorkspacePatterns(root: string): string[];
45
38
  export declare function readPackageJson(path: string): PackageInfo | null;
46
39
  export declare function readWorkspacePackageManifest(path: string): WorkspacePackageManifest | null;
47
40
  export declare function readPackageJsonObject(path: string): PackageJson | null;
48
- export declare function getNxTags(pkg: Record<string, unknown>): string[];
49
- export declare function repositoryInfo(pkg: Record<string, unknown>): RepositoryInfo | null;
41
+ export declare function getNxTags(pkg: PackageJson): string[];
42
+ export declare function repositoryInfo(pkg: PackageJson): RepositoryInfo | null;
50
43
  export declare function sameRepositoryAfterNormalization(left: string, right: string): boolean;
51
44
  export declare function escapeRegex(value: string): string;
52
45
  //# sourceMappingURL=workspace.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../../src/lib/workspace.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC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