knarr 0.1.3 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -107
- package/dist/add-B_xzUp5y.mjs +3 -0
- package/dist/add-flow-cvrMO_aV.mjs +5 -0
- package/dist/batch-push-DXtZxRx0.mjs +3 -0
- package/dist/build-detect-BTHh2OBm.mjs +3 -0
- package/dist/bundler-detect-Dq-QAbQj.mjs +3 -0
- package/dist/check-CbVdpTsw.mjs +3 -0
- package/dist/chokidar-BkIWf7Ix.mjs +3 -0
- package/dist/clean-CyDDqbBD.mjs +3 -0
- package/dist/cli.mjs +4 -4
- package/dist/config-BJsL6NqN.mjs +4 -0
- package/dist/console-CIiXr7ge.mjs +3 -0
- package/dist/console-CyaBcUd-.mjs +98 -0
- package/dist/dev-kqgY9NjI.mjs +3 -0
- package/dist/dist-CFkjiIqD.mjs +7 -0
- package/dist/doctor-D-S1P0UG.mjs +6 -0
- package/dist/dry-run-BkdMYSIx.mjs +3 -0
- package/dist/errors-BlOfexcH.mjs +3 -0
- package/dist/explain-9Y4SZHjC.mjs +3 -0
- package/dist/format-DRqD29u-.mjs +3 -0
- package/dist/fs-C4juVCTd.mjs +3 -0
- package/dist/fs-CPnWm9CR.mjs +3 -0
- package/dist/fs-DzsciYAL.mjs +757 -0
- package/dist/hints-Hz3V4h3A.mjs +3 -0
- package/dist/history-DRhLwzhq.mjs +3 -0
- package/dist/history-vS3w4EGu.mjs +3 -0
- package/dist/index.d.ts +249 -264
- package/dist/index.mjs +3426 -4668
- package/dist/init-TN84d5jM.mjs +4 -0
- package/dist/init-helpers-CYYWQm-P.mjs +15 -0
- package/dist/injector-nt40JxVt.mjs +3 -0
- package/dist/json-DbSkpxtr.mjs +3 -0
- package/dist/list-9hWJjw19.mjs +3 -0
- package/dist/logger-9C6B9Na8.mjs +3 -0
- package/dist/migrate-Co4qcFt6.mjs +5 -0
- package/dist/nextjs-config-BQgTWZ96.mjs +3 -0
- package/dist/nextjs-config-dUw2J6B9.mjs +4 -0
- package/dist/output-BxR2v-jn.mjs +3 -0
- package/dist/package-manager-DJ8CE0zL.mjs +13 -0
- package/dist/picomatch-B0_Pxgms.mjs +3 -0
- package/dist/preflight-BDsxR2Ct.mjs +3 -0
- package/dist/preflight-MzNjLXiy.mjs +3 -0
- package/dist/publish-C7ZUvHkE.mjs +3 -0
- package/dist/publisher-CvXTbkLP.mjs +4 -0
- package/dist/push-B5KrkILW.mjs +3 -0
- package/dist/push-engine-BpNr8qXR.mjs +3 -0
- package/dist/remove-DkOgVQMZ.mjs +3 -0
- package/dist/remove-J5tY_BFk.mjs +3 -0
- package/dist/reset-ClGouUb5.mjs +3 -0
- package/dist/restore-Bx2V59SL.mjs +3 -0
- package/dist/rollback-RPjHZWtG.mjs +3 -0
- package/dist/rolldown-runtime-BZbIAPMk.mjs +3 -0
- package/dist/shell-RQ7Hf1kp.mjs +3 -0
- package/dist/status-Rnvw6dG2.mjs +3 -0
- package/dist/store-DjPdOKqg.mjs +3 -0
- package/dist/tailwind-source-D1cUiG-t.mjs +5 -0
- package/dist/timer-DqgB175x.mjs +3 -0
- package/dist/topo-sort-DOCpHjT7.mjs +3 -0
- package/dist/topo-sort-yd4jxr_E.mjs +3 -0
- package/dist/tracker-89eW0ArT.mjs +3 -0
- package/dist/tracker-B3Fqx94J.mjs +3 -0
- package/dist/update-CAKFICZu.mjs +3 -0
- package/dist/use-CCx6J0mc.mjs +3 -0
- package/dist/vite-config-BHmawlD2.mjs +12 -0
- package/dist/vite-config-BRlYc4ni.mjs +3 -0
- package/dist/vite-plugin.d.ts +6 -5
- package/dist/vite-plugin.mjs +206 -211
- package/dist/watch-orchestrator-BfuCaZLA.mjs +3 -0
- package/dist/watcher-T123sBDg.mjs +3 -0
- package/dist/webpack-plugin.d.ts +29 -30
- package/dist/webpack-plugin.mjs +140 -138
- package/dist/workspace-CdLSxPFS.mjs +3 -0
- package/dist/workspace-DBxNrowu.mjs +3 -0
- package/dist/xxhash-wasm-D_QjdUuv.mjs +3 -0
- package/package.json +23 -31
- package/dist/add-LQ6WMCGD.mjs +0 -3
- package/dist/bell-SIN4ERLS.mjs +0 -2
- package/dist/check-7CJHAF6Y.mjs +0 -6
- package/dist/chokidar-2G63V464.mjs +0 -4
- package/dist/chunk-3SXN6MQL.mjs +0 -4
- package/dist/chunk-7GCKCCHU.mjs +0 -3
- package/dist/chunk-BH2WXCLS.mjs +0 -4
- package/dist/chunk-CBOYKBSM.mjs +0 -13
- package/dist/chunk-E3HZCU3S.mjs +0 -5
- package/dist/chunk-G7HFTV5Y.mjs +0 -3
- package/dist/chunk-HVN6HBWZ.mjs +0 -3
- package/dist/chunk-ICU4V73X.mjs +0 -3
- package/dist/chunk-IP5ROSRE.mjs +0 -3
- package/dist/chunk-J6HZHQVL.mjs +0 -3
- package/dist/chunk-K6OAYJKS.mjs +0 -6
- package/dist/chunk-KRX4JX6V.mjs +0 -4
- package/dist/chunk-KUQULMM6.mjs +0 -3
- package/dist/chunk-L7O2RSTN.mjs +0 -3
- package/dist/chunk-M3TRMEJV.mjs +0 -3
- package/dist/chunk-MN4DV2NO.mjs +0 -3
- package/dist/chunk-N3B2JO4H.mjs +0 -13
- package/dist/chunk-NGPAGRK4.mjs +0 -7
- package/dist/chunk-NV3ASN6X.mjs +0 -3
- package/dist/chunk-OQDZJP55.mjs +0 -3
- package/dist/chunk-QEH5VHRO.mjs +0 -13
- package/dist/chunk-QFHYSC3K.mjs +0 -3
- package/dist/chunk-QHNHLR6T.mjs +0 -3
- package/dist/chunk-RIHOZDFW.mjs +0 -22
- package/dist/chunk-SMR4HT6A.mjs +0 -3
- package/dist/chunk-SPHWZS5P.mjs +0 -3
- package/dist/chunk-U6O35NZ7.mjs +0 -3
- package/dist/chunk-W2MMKBWU.mjs +0 -3
- package/dist/chunk-WBTSRLB6.mjs +0 -7
- package/dist/chunk-WN3DOKIM.mjs +0 -3
- package/dist/chunk-XDWZZBCM.mjs +0 -3
- package/dist/chunk-Z5K6DFA6.mjs +0 -3
- package/dist/clean-EJIYYQZM.mjs +0 -3
- package/dist/dev-WU5KB5PJ.mjs +0 -3
- package/dist/doctor-W2G34POC.mjs +0 -6
- package/dist/explain-LZLNIMVZ.mjs +0 -5
- package/dist/fs-NU36NNEG.mjs +0 -2
- package/dist/history-MLJHRV3Q.mjs +0 -2
- package/dist/init-SNG5LBZK.mjs +0 -7
- package/dist/list-4PTHMIQ4.mjs +0 -5
- package/dist/migrate-USY26Y5R.mjs +0 -8
- package/dist/nextjs-config-T5D6LOJE.mjs +0 -2
- package/dist/preflight-IXICTR6G.mjs +0 -2
- package/dist/publish-2IH7IQV4.mjs +0 -3
- package/dist/push-W3TM2QYK.mjs +0 -3
- package/dist/remove-MVQOIN2I.mjs +0 -2
- package/dist/reset-BTOJ54MJ.mjs +0 -3
- package/dist/restore-TWOOF2BN.mjs +0 -3
- package/dist/rollback-CFYSE5YG.mjs +0 -3
- package/dist/status-3ZXM3CRH.mjs +0 -4
- package/dist/tailwind-source-HCTY2XDU.mjs +0 -5
- package/dist/topo-sort-ZNGR6D7M.mjs +0 -2
- package/dist/tracker-QAKEXYUJ.mjs +0 -2
- package/dist/update-TGGCUOOO.mjs +0 -3
- package/dist/use-4Z5KXRVR.mjs +0 -3
- package/dist/vite-config-XOGAKYGQ.mjs +0 -2
- package/dist/watch-orchestrator-6BQYU5YS.mjs +0 -3
- package/dist/watcher-ES2APFH4.mjs +0 -3
- package/dist/workspace-T6PNO4L3.mjs +0 -2
- package/dist/xxhash-wasm-I6Q3T2SL.mjs +0 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
interface PublishOptions {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
allowPrivate?: boolean;
|
|
3
|
+
/** Whether to run prepack/postpack lifecycle hooks (default: true) */
|
|
4
|
+
runScripts?: boolean;
|
|
5
|
+
/** Force publish, bypassing hash comparison */
|
|
6
|
+
force?: boolean;
|
|
7
|
+
/** Max historical builds to keep (default: 3). Set to 0 to disable. */
|
|
8
|
+
historyLimit?: number;
|
|
9
9
|
}
|
|
10
10
|
interface PublishResult {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
11
|
+
name: string;
|
|
12
|
+
version: string;
|
|
13
|
+
fileCount: number;
|
|
14
|
+
/** True if content was unchanged and publish was skipped */
|
|
15
|
+
skipped: boolean;
|
|
16
|
+
contentHash: string;
|
|
17
|
+
/** 8-char hex identifier generated on each successful publish */
|
|
18
|
+
buildId: string;
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
21
|
* Publish a package from a directory to the Knarr store.
|
|
@@ -27,121 +27,130 @@ interface PublishResult {
|
|
|
27
27
|
* 5. Copy files to temp dir, then atomic rename to store
|
|
28
28
|
* 6. Write .knarr-meta.json
|
|
29
29
|
*/
|
|
30
|
-
declare function publish(packageDir: string, options?: PublishOptions): Promise<PublishResult>;
|
|
31
|
-
|
|
30
|
+
export declare function publish(packageDir: string, options?: PublishOptions): Promise<PublishResult>;
|
|
32
31
|
/** Metadata stored alongside each package in the Knarr store */
|
|
33
32
|
interface KnarrMeta {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
schemaVersion?: number;
|
|
34
|
+
contentHash: string;
|
|
35
|
+
publishedAt: string;
|
|
36
|
+
sourcePath: string;
|
|
37
|
+
/** 8-char hex ID derived from content hash. Missing in pre-buildId store entries. */
|
|
38
|
+
buildId?: string;
|
|
40
39
|
}
|
|
41
40
|
/** A store entry representing a published package */
|
|
42
41
|
interface StoreEntry {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
name: string;
|
|
43
|
+
version: string;
|
|
44
|
+
packageDir: string;
|
|
45
|
+
meta: KnarrMeta;
|
|
47
46
|
}
|
|
48
47
|
/** Tracks a single linked package in a consumer project */
|
|
49
48
|
interface LinkEntry {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
49
|
+
version: string;
|
|
50
|
+
contentHash: string;
|
|
51
|
+
linkedAt: string;
|
|
52
|
+
sourcePath: string;
|
|
53
|
+
backupExists: boolean;
|
|
54
|
+
packageManager: PackageManager;
|
|
55
|
+
/** 8-char hex ID. Missing in pre-buildId state files. */
|
|
56
|
+
buildId?: string;
|
|
58
57
|
}
|
|
58
|
+
declare const nullPrototype: unique symbol;
|
|
59
|
+
/**
|
|
60
|
+
* A map keyed by untrusted strings (package names, catalog names). It has no
|
|
61
|
+
* prototype, so keys such as `constructor` or `__proto__` are plain data.
|
|
62
|
+
* A `{}` literal does not type-check as one; create it with `ownRecord()`
|
|
63
|
+
* from `src/utils/json.ts`.
|
|
64
|
+
*/
|
|
65
|
+
type OwnRecord<V> = {
|
|
66
|
+
[key: string]: V;
|
|
67
|
+
} & {
|
|
68
|
+
readonly [nullPrototype]: true;
|
|
69
|
+
};
|
|
59
70
|
/** Consumer project state file (.knarr/state.json) */
|
|
60
71
|
interface ConsumerState {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
/** Global consumers registry (~/.knarr/consumers.json) */
|
|
67
|
-
interface ConsumersRegistry {
|
|
68
|
-
/** Maps package name → array of consumer project paths */
|
|
69
|
-
[packageName: string]: string[];
|
|
72
|
+
version: "1";
|
|
73
|
+
packageManager?: PackageManager;
|
|
74
|
+
role?: "consumer" | "library";
|
|
75
|
+
links: OwnRecord<LinkEntry>;
|
|
70
76
|
}
|
|
77
|
+
/** Global consumers registry (~/.knarr/consumers.json): package name → consumer project paths */
|
|
78
|
+
type ConsumersRegistry = OwnRecord<string[]>;
|
|
71
79
|
type PackageManager = "npm" | "pnpm" | "yarn" | "bun";
|
|
72
80
|
/** A historical build stored in the store's history directory */
|
|
73
81
|
interface HistoryEntry {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
82
|
+
buildId: string;
|
|
83
|
+
contentHash: string;
|
|
84
|
+
publishedAt: string;
|
|
85
|
+
sourcePath: string;
|
|
86
|
+
/** Path to the history entry's package directory */
|
|
87
|
+
packageDir: string;
|
|
80
88
|
}
|
|
81
89
|
/** Options for the watch mode */
|
|
82
90
|
interface WatchOptions {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
91
|
+
/** Glob patterns to watch (default: src, lib, dist) */
|
|
92
|
+
patterns?: string[];
|
|
93
|
+
/** Build command to run before publishing */
|
|
94
|
+
buildCmd?: string;
|
|
95
|
+
/** Debounce delay in ms (default: 500) */
|
|
96
|
+
debounce?: number;
|
|
97
|
+
/** Minimum time between builds in ms (default: 500) */
|
|
98
|
+
cooldown?: number;
|
|
99
|
+
/** Ring terminal bell on push success/failure */
|
|
100
|
+
notify?: boolean;
|
|
101
|
+
/** Prefix for log lines, e.g. the package name when several watchers run (dev --all) */
|
|
102
|
+
label?: string;
|
|
103
|
+
/** Enable awaitWriteFinish for large/slow writes (auto-enabled when no buildCmd) */
|
|
104
|
+
awaitWriteFinish?: boolean | {
|
|
105
|
+
stabilityThreshold: number;
|
|
106
|
+
pollInterval: number;
|
|
107
|
+
};
|
|
98
108
|
}
|
|
99
109
|
/** Package.json fields we care about */
|
|
100
110
|
interface PackageJson {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
111
|
+
name: string;
|
|
112
|
+
version: string;
|
|
113
|
+
files?: string[];
|
|
114
|
+
bin?: string | Record<string, string>;
|
|
115
|
+
dependencies?: Record<string, string>;
|
|
116
|
+
devDependencies?: Record<string, string>;
|
|
117
|
+
peerDependencies?: Record<string, string>;
|
|
118
|
+
optionalDependencies?: Record<string, string>;
|
|
119
|
+
peerDependenciesMeta?: Record<string, {
|
|
120
|
+
optional?: boolean;
|
|
121
|
+
}>;
|
|
122
|
+
main?: string;
|
|
123
|
+
module?: string;
|
|
124
|
+
exports?: unknown;
|
|
125
|
+
type?: string;
|
|
126
|
+
private?: boolean;
|
|
127
|
+
scripts?: Record<string, string>;
|
|
128
|
+
types?: string;
|
|
129
|
+
typings?: string;
|
|
130
|
+
browser?: string | Record<string, string>;
|
|
131
|
+
/** Corepack packageManager field, e.g. "pnpm@9.0.0" */
|
|
132
|
+
packageManager?: string;
|
|
133
|
+
publishConfig?: {
|
|
112
134
|
main?: string;
|
|
113
135
|
module?: string;
|
|
114
136
|
exports?: unknown;
|
|
115
|
-
type?: string;
|
|
116
|
-
private?: boolean;
|
|
117
|
-
scripts?: Record<string, string>;
|
|
118
137
|
types?: string;
|
|
119
138
|
typings?: string;
|
|
120
139
|
browser?: string | Record<string, string>;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
main?: string;
|
|
125
|
-
module?: string;
|
|
126
|
-
exports?: unknown;
|
|
127
|
-
types?: string;
|
|
128
|
-
typings?: string;
|
|
129
|
-
browser?: string | Record<string, string>;
|
|
130
|
-
bin?: string | Record<string, string>;
|
|
131
|
-
directory?: string;
|
|
132
|
-
};
|
|
140
|
+
bin?: string | Record<string, string>;
|
|
141
|
+
directory?: string;
|
|
142
|
+
};
|
|
133
143
|
}
|
|
134
|
-
|
|
135
144
|
interface InjectResult {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
copied: number;
|
|
146
|
+
removed: number;
|
|
147
|
+
skipped: number;
|
|
148
|
+
binLinks: number;
|
|
149
|
+
cacheInvalidations: number;
|
|
141
150
|
}
|
|
142
151
|
interface InjectOptions {
|
|
143
|
-
|
|
144
|
-
|
|
152
|
+
/** Force copy all files, bypassing hash comparison */
|
|
153
|
+
force?: boolean;
|
|
145
154
|
}
|
|
146
155
|
/**
|
|
147
156
|
* Inject a package from the store into a consumer's node_modules.
|
|
@@ -150,200 +159,187 @@ interface InjectOptions {
|
|
|
150
159
|
* - pnpm: follow .pnpm/ structure
|
|
151
160
|
* - yarn with nodeLinker: pnpm: follow .store/ structure
|
|
152
161
|
*/
|
|
153
|
-
declare function inject(storeEntry: StoreEntry, consumerPath: string, pm: PackageManager, options?: InjectOptions): Promise<InjectResult>;
|
|
162
|
+
export declare function inject(storeEntry: StoreEntry, consumerPath: string, pm: PackageManager, options?: InjectOptions): Promise<InjectResult>;
|
|
154
163
|
/**
|
|
155
164
|
* Back up the existing installed version of a package before overwriting.
|
|
156
165
|
*/
|
|
157
|
-
declare function backupExisting(consumerPath: string, packageName: string, pm: PackageManager): Promise<boolean>;
|
|
166
|
+
export declare function backupExisting(consumerPath: string, packageName: string, pm: PackageManager): Promise<boolean>;
|
|
158
167
|
/**
|
|
159
168
|
* Restore a backed-up package to node_modules.
|
|
160
169
|
*/
|
|
161
|
-
declare function restoreBackup(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<boolean>;
|
|
170
|
+
export declare function restoreBackup(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<boolean>;
|
|
162
171
|
/**
|
|
163
172
|
* Remove an injected package from node_modules.
|
|
164
173
|
*/
|
|
165
|
-
declare function removeInjected(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<void>;
|
|
174
|
+
export declare function removeInjected(consumerPath: string, packageName: string, pm: PackageManager, version?: string): Promise<void>;
|
|
166
175
|
/**
|
|
167
176
|
* Check for missing transitive dependencies.
|
|
168
177
|
* Returns a list of dependency names that are in the linked package's
|
|
169
178
|
* dependencies but not installed in the consumer's node_modules.
|
|
170
179
|
*/
|
|
171
|
-
declare function checkMissingDeps(storeEntry: StoreEntry, consumerPath: string, pm?: PackageManager): Promise<string[]>;
|
|
172
|
-
|
|
180
|
+
export declare function checkMissingDeps(storeEntry: StoreEntry, consumerPath: string, pm?: PackageManager): Promise<string[]>;
|
|
173
181
|
/** Get a store entry if it exists */
|
|
174
|
-
declare function getStoreEntry(name: string, version: string): Promise<StoreEntry | null>;
|
|
182
|
+
export declare function getStoreEntry(name: string, version: string): Promise<StoreEntry | null>;
|
|
175
183
|
/** Find a store entry by name (any version). Returns the latest by publishedAt. */
|
|
176
|
-
declare function findStoreEntry(name: string): Promise<StoreEntry | null>;
|
|
184
|
+
export declare function findStoreEntry(name: string): Promise<StoreEntry | null>;
|
|
177
185
|
/** List all entries in the store */
|
|
178
|
-
declare function listStoreEntries(): Promise<StoreEntry[]>;
|
|
179
|
-
|
|
186
|
+
export declare function listStoreEntries(): Promise<StoreEntry[]>;
|
|
180
187
|
/** Read the consumer state file, or return an empty state if not found */
|
|
181
|
-
declare function readConsumerState(consumerPath: string): Promise<ConsumerState>;
|
|
188
|
+
export declare function readConsumerState(consumerPath: string): Promise<ConsumerState>;
|
|
182
189
|
/**
|
|
183
190
|
* Read consumer state with reliability information.
|
|
184
191
|
* Returns `reliable: true` when the state is trustworthy (valid file or ENOENT).
|
|
185
192
|
* Returns `reliable: false` when the file exists but is corrupt/unreadable,
|
|
186
193
|
* meaning the consumer might have links we can't see.
|
|
187
194
|
*/
|
|
188
|
-
declare function readConsumerStateSafe(consumerPath: string): Promise<{
|
|
189
|
-
|
|
190
|
-
|
|
195
|
+
export declare function readConsumerStateSafe(consumerPath: string): Promise<{
|
|
196
|
+
state: ConsumerState;
|
|
197
|
+
reliable: boolean;
|
|
191
198
|
}>;
|
|
192
199
|
/** Add or update a link entry in the consumer state */
|
|
193
|
-
declare function addLink(consumerPath: string, packageName: string, entry: LinkEntry): Promise<void>;
|
|
200
|
+
export declare function addLink(consumerPath: string, packageName: string, entry: LinkEntry): Promise<void>;
|
|
194
201
|
/** Remove a link entry from the consumer state */
|
|
195
|
-
declare function removeLink(consumerPath: string, packageName: string): Promise<void>;
|
|
202
|
+
export declare function removeLink(consumerPath: string, packageName: string): Promise<void>;
|
|
196
203
|
/** Get a specific link entry */
|
|
197
|
-
declare function getLink(consumerPath: string, packageName: string): Promise<LinkEntry | null>;
|
|
204
|
+
export declare function getLink(consumerPath: string, packageName: string): Promise<LinkEntry | null>;
|
|
198
205
|
/** Register a consumer for a package */
|
|
199
|
-
declare function registerConsumer(packageName: string, consumerPath: string): Promise<void>;
|
|
206
|
+
export declare function registerConsumer(packageName: string, consumerPath: string): Promise<void>;
|
|
200
207
|
/** Unregister a consumer for a package */
|
|
201
|
-
declare function unregisterConsumer(packageName: string, consumerPath: string): Promise<void>;
|
|
208
|
+
export declare function unregisterConsumer(packageName: string, consumerPath: string): Promise<void>;
|
|
202
209
|
/** Get all consumers for a package */
|
|
203
|
-
declare function getConsumers(packageName: string): Promise<string[]>;
|
|
210
|
+
export declare function getConsumers(packageName: string): Promise<string[]>;
|
|
204
211
|
/**
|
|
205
212
|
* Clean stale consumers — remove registrations for directories that no longer exist.
|
|
206
213
|
* Returns the number of stale entries removed.
|
|
207
214
|
*/
|
|
208
|
-
declare function cleanStaleConsumers(
|
|
209
|
-
|
|
210
|
-
removedPackages: number;
|
|
211
|
-
removedMissingLinks: number;
|
|
212
|
-
skippedUnreliableConsumers: number;
|
|
213
|
-
}>;
|
|
214
|
-
declare function cleanStaleConsumers(options: {
|
|
215
|
-
removeMissingLinks?: boolean;
|
|
215
|
+
export declare function cleanStaleConsumers(options?: {
|
|
216
|
+
removeMissingLinks?: boolean;
|
|
216
217
|
}): Promise<{
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
218
|
+
removedConsumers: number;
|
|
219
|
+
removedPackages: number;
|
|
220
|
+
removedMissingLinks: number;
|
|
221
|
+
skippedUnreliableConsumers: number;
|
|
221
222
|
}>;
|
|
222
|
-
|
|
223
223
|
/**
|
|
224
224
|
* knarr configuration stored in package.json under the "knarr" key.
|
|
225
225
|
* Provides persistent defaults for watch/build/dev behavior.
|
|
226
226
|
*/
|
|
227
227
|
interface KnarrConfig {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
228
|
+
buildCmd?: string;
|
|
229
|
+
watchPatterns?: string[];
|
|
230
|
+
debounce?: number;
|
|
231
|
+
cooldown?: number;
|
|
232
|
+
historyLimit?: number;
|
|
233
|
+
notify?: boolean;
|
|
234
234
|
}
|
|
235
235
|
/**
|
|
236
|
-
* Load knarr configuration from package.json#knarr.
|
|
236
|
+
* Load knarr configuration from package.json#knarr. Every field is validated:
|
|
237
|
+
* wrong types are ignored rather than trusted.
|
|
237
238
|
*/
|
|
238
|
-
declare function loadKnarrConfig(projectDir: string): Promise<KnarrConfig>;
|
|
239
|
-
|
|
239
|
+
export declare function loadKnarrConfig(projectDir: string): Promise<KnarrConfig>;
|
|
240
240
|
/**
|
|
241
241
|
* Simple timer for measuring command execution time.
|
|
242
242
|
*/
|
|
243
|
-
declare class Timer {
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
243
|
+
export declare class Timer {
|
|
244
|
+
private start;
|
|
245
|
+
/** Return elapsed time in ms */
|
|
246
|
+
elapsedMs(): number;
|
|
247
|
+
/** Return human-readable elapsed time (e.g., "1.2s" or "150ms") */
|
|
248
|
+
elapsed(): string;
|
|
249
249
|
}
|
|
250
|
-
|
|
251
250
|
interface PushOptions {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
251
|
+
runScripts?: boolean;
|
|
252
|
+
/** Force copy all files, bypassing hash comparison */
|
|
253
|
+
force?: boolean;
|
|
254
|
+
/** Max historical builds to keep per package */
|
|
255
|
+
historyLimit?: number;
|
|
257
256
|
}
|
|
258
257
|
interface PushConsumerResult {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
258
|
+
consumerPath: string;
|
|
259
|
+
status: "updated" | "failed" | "skipped";
|
|
260
|
+
copied: number;
|
|
261
|
+
removed: number;
|
|
262
|
+
skipped: number;
|
|
263
|
+
binLinks: number;
|
|
264
|
+
cacheInvalidations: number;
|
|
265
|
+
reason?: string;
|
|
266
|
+
error?: string;
|
|
268
267
|
}
|
|
269
268
|
interface PushSummary {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
269
|
+
name: string;
|
|
270
|
+
version: string;
|
|
271
|
+
buildId: string;
|
|
272
|
+
noChange: boolean;
|
|
273
|
+
skippedReason?: string;
|
|
274
|
+
consumers: number;
|
|
275
|
+
updatedConsumers: number;
|
|
276
|
+
failedConsumers: number;
|
|
277
|
+
skippedConsumers: number;
|
|
278
|
+
copied: number;
|
|
279
|
+
removed: number;
|
|
280
|
+
skipped: number;
|
|
281
|
+
binLinks: number;
|
|
282
|
+
cacheInvalidations: number;
|
|
283
|
+
elapsed: number;
|
|
284
|
+
consumerResults: PushConsumerResult[];
|
|
286
285
|
}
|
|
287
286
|
/**
|
|
288
287
|
* Publish a package to the store, then inject into all registered consumers.
|
|
289
288
|
* Shared by both `push` and `dev` commands.
|
|
290
289
|
*/
|
|
291
|
-
declare function doPush(packageDir: string, options?: PushOptions): Promise<PushSummary>;
|
|
290
|
+
export declare function doPush(packageDir: string, options?: PushOptions): Promise<PushSummary>;
|
|
292
291
|
/** Common CLI args shared by push --watch and dev */
|
|
293
292
|
interface WatchArgs {
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
293
|
+
build?: string;
|
|
294
|
+
"skip-build"?: boolean;
|
|
295
|
+
debounce?: string;
|
|
296
|
+
cooldown?: string;
|
|
297
|
+
notify?: boolean;
|
|
298
|
+
"no-cascade"?: boolean;
|
|
300
299
|
}
|
|
301
|
-
|
|
302
300
|
interface PushAllOptions extends PushOptions {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
301
|
+
/**
|
|
302
|
+
* Workspace packages to skip before pushing. Used by watch-mode initial
|
|
303
|
+
* builds so a failed build does not publish stale output.
|
|
304
|
+
*/
|
|
305
|
+
skipPackages?: Iterable<string>;
|
|
308
306
|
}
|
|
309
307
|
/**
|
|
310
308
|
* Push all workspace packages in topological (dependency-first) order.
|
|
311
309
|
* Each package is published and injected sequentially to ensure
|
|
312
310
|
* dependencies are available before dependents.
|
|
313
311
|
*/
|
|
314
|
-
declare function doPushAll(startDir: string, options?: PushAllOptions): Promise<void>;
|
|
315
|
-
|
|
312
|
+
export declare function doPushAll(startDir: string, options?: PushAllOptions): Promise<void>;
|
|
316
313
|
/**
|
|
317
314
|
* Capture the current store entry as a history entry before it gets replaced.
|
|
318
315
|
* Moves the old package/ and .knarr-meta.json into history/<buildId>/.
|
|
319
316
|
*/
|
|
320
|
-
declare function captureHistory(name: string, version: string, oldEntryDir: string, historyLimit?: number): Promise<void>;
|
|
317
|
+
export declare function captureHistory(name: string, version: string, oldEntryDir: string, historyLimit?: number): Promise<void>;
|
|
321
318
|
/**
|
|
322
319
|
* List all history entries for a package, sorted by publishedAt (newest first).
|
|
323
320
|
*/
|
|
324
|
-
declare function listHistory(name: string, version: string): Promise<HistoryEntry[]>;
|
|
321
|
+
export declare function listHistory(name: string, version: string): Promise<HistoryEntry[]>;
|
|
325
322
|
/**
|
|
326
323
|
* Get a specific history entry by buildId.
|
|
327
324
|
*/
|
|
328
|
-
declare function getHistoryEntry(name: string, version: string, buildId: string): Promise<HistoryEntry | null>;
|
|
325
|
+
export declare function getHistoryEntry(name: string, version: string, buildId: string): Promise<HistoryEntry | null>;
|
|
329
326
|
/**
|
|
330
327
|
* Restore a history entry as the current store entry.
|
|
331
328
|
* Moves the history entry back to the main store position.
|
|
332
329
|
*/
|
|
333
|
-
declare function restoreHistoryEntry(name: string, version: string, buildId: string, historyLimit?: number): Promise<HistoryEntry | null>;
|
|
330
|
+
export declare function restoreHistoryEntry(name: string, version: string, buildId: string, historyLimit?: number): Promise<HistoryEntry | null>;
|
|
334
331
|
/**
|
|
335
332
|
* Prune history entries to keep only the most recent `limit` entries.
|
|
336
333
|
*/
|
|
337
|
-
declare function pruneHistory(name: string, version: string, limit: number): Promise<number>;
|
|
334
|
+
export declare function pruneHistory(name: string, version: string, limit: number): Promise<number>;
|
|
338
335
|
/**
|
|
339
336
|
* Remove all history for a package.
|
|
340
337
|
*/
|
|
341
|
-
declare function clearHistory(name: string, version: string): Promise<void>;
|
|
338
|
+
export declare function clearHistory(name: string, version: string): Promise<void>;
|
|
342
339
|
/** Resolve the effective history limit from config or default */
|
|
343
|
-
declare function resolveHistoryLimit(configValue?: number): number;
|
|
344
|
-
|
|
340
|
+
export declare function resolveHistoryLimit(configValue?: number): number;
|
|
345
341
|
/** Kill the active build process if one is running */
|
|
346
|
-
declare function killActiveBuild(): void;
|
|
342
|
+
export declare function killActiveBuild(): void;
|
|
347
343
|
/**
|
|
348
344
|
* Start watching a directory for changes and trigger a callback.
|
|
349
345
|
*
|
|
@@ -353,14 +349,13 @@ declare function killActiveBuild(): void;
|
|
|
353
349
|
* - If a push is already running when new changes arrive, a re-push is queued
|
|
354
350
|
* so the final state is always pushed
|
|
355
351
|
*/
|
|
356
|
-
declare function startWatcher(watchDir: string, options: WatchOptions, onChange: () => Promise<void>): Promise<{
|
|
357
|
-
|
|
352
|
+
export declare function startWatcher(watchDir: string, options: WatchOptions, onChange: () => Promise<void>): Promise<{
|
|
353
|
+
close: () => Promise<void>;
|
|
358
354
|
}>;
|
|
359
355
|
/**
|
|
360
356
|
* Run a build command and return true if it succeeds.
|
|
361
357
|
*/
|
|
362
|
-
declare function runBuildCommand(cmd: string, cwd: string): Promise<boolean>;
|
|
363
|
-
|
|
358
|
+
export declare function runBuildCommand(cmd: string, cwd: string, label?: string): Promise<boolean>;
|
|
364
359
|
/**
|
|
365
360
|
* Orchestrates watch mode for all workspace packages with optional
|
|
366
361
|
* cascading rebuilds. When a package is pushed, its dependents in
|
|
@@ -371,25 +366,24 @@ declare function runBuildCommand(cmd: string, cwd: string): Promise<boolean>;
|
|
|
371
366
|
* building + trigger → queued → building (coalesced)
|
|
372
367
|
* queued + trigger → queued (no-op)
|
|
373
368
|
*/
|
|
374
|
-
declare class WatchOrchestrator {
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
369
|
+
export declare class WatchOrchestrator {
|
|
370
|
+
private packages;
|
|
371
|
+
private dependents;
|
|
372
|
+
private cascade;
|
|
373
|
+
private pushOptions;
|
|
374
|
+
constructor(cascade: boolean);
|
|
375
|
+
start(startDir: string, args: WatchArgs, pushOptions: PushOptions): Promise<void>;
|
|
376
|
+
private onPackagePushed;
|
|
377
|
+
private runExclusive;
|
|
378
|
+
private requestRebuild;
|
|
379
|
+
close(): Promise<void>;
|
|
385
380
|
}
|
|
386
|
-
|
|
387
381
|
type PackageManagerDetectionSource = "packageManager" | "lockfile" | "yarnArtifact" | "default";
|
|
388
382
|
interface PackageManagerDetection {
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
383
|
+
packageManager: PackageManager;
|
|
384
|
+
source: PackageManagerDetectionSource;
|
|
385
|
+
dir: string;
|
|
386
|
+
file?: string;
|
|
393
387
|
}
|
|
394
388
|
/**
|
|
395
389
|
* Detect the package manager used in a project directory.
|
|
@@ -398,20 +392,19 @@ interface PackageManagerDetection {
|
|
|
398
392
|
* Closest match wins. Within the same directory, priority order is maintained.
|
|
399
393
|
* Falls back to "npm" if nothing is found.
|
|
400
394
|
*/
|
|
401
|
-
declare function detectPackageManager(projectDir: string): Promise<PackageManager>;
|
|
395
|
+
export declare function detectPackageManager(projectDir: string): Promise<PackageManager>;
|
|
402
396
|
/**
|
|
403
397
|
* Detect the package manager and return where the decision came from.
|
|
404
398
|
* Useful for distinguishing an explicit npm project from the npm fallback.
|
|
405
399
|
*/
|
|
406
|
-
declare function detectPackageManagerInfo(projectDir: string): Promise<PackageManagerDetection>;
|
|
407
|
-
|
|
400
|
+
export declare function detectPackageManagerInfo(projectDir: string): Promise<PackageManagerDetection>;
|
|
408
401
|
/**
|
|
409
402
|
* Topological sort using Kahn's algorithm.
|
|
410
403
|
* Used to order workspace packages so dependencies are processed first.
|
|
411
404
|
*/
|
|
412
|
-
declare class CycleError extends Error {
|
|
413
|
-
|
|
414
|
-
|
|
405
|
+
export declare class CycleError extends Error {
|
|
406
|
+
readonly cycle: string[];
|
|
407
|
+
constructor(cycle: string[]);
|
|
415
408
|
}
|
|
416
409
|
/**
|
|
417
410
|
* Sort nodes topologically (dependency-first order).
|
|
@@ -419,77 +412,69 @@ declare class CycleError extends Error {
|
|
|
419
412
|
* @returns Nodes in dependency-first order
|
|
420
413
|
* @throws CycleError if a cycle is detected
|
|
421
414
|
*/
|
|
422
|
-
declare function topoSort(graph: Map<string, Set<string>>): string[];
|
|
423
|
-
|
|
415
|
+
export declare function topoSort(graph: Map<string, Set<string>>): string[];
|
|
424
416
|
interface WorkspacePackage {
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
417
|
+
name: string;
|
|
418
|
+
version: string;
|
|
419
|
+
dir: string;
|
|
420
|
+
pkg: PackageJson;
|
|
429
421
|
}
|
|
430
422
|
interface WorkspaceGraph {
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
423
|
+
packages: WorkspacePackage[];
|
|
424
|
+
/** Map of package name → Set of in-workspace dependency names */
|
|
425
|
+
adjacency: Map<string, Set<string>>;
|
|
434
426
|
}
|
|
435
427
|
/**
|
|
436
428
|
* Build a workspace dependency graph for topological sorting.
|
|
437
429
|
* Reads all workspace packages and builds an adjacency map of
|
|
438
430
|
* in-workspace dependencies (both dependencies and devDependencies).
|
|
439
431
|
*/
|
|
440
|
-
declare function buildWorkspaceGraph(startDir: string): Promise<WorkspaceGraph>;
|
|
432
|
+
export declare function buildWorkspaceGraph(startDir: string): Promise<WorkspaceGraph>;
|
|
441
433
|
/**
|
|
442
434
|
* Build a reverse adjacency map: for each package, which packages depend on it.
|
|
443
435
|
* Used by WatchOrchestrator to trigger cascading rebuilds.
|
|
444
436
|
*/
|
|
445
|
-
declare function buildReverseAdjacency(adjacency: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
446
|
-
|
|
437
|
+
export declare function buildReverseAdjacency(adjacency: Map<string, Set<string>>): Map<string, Set<string>>;
|
|
447
438
|
type PreflightSeverity = "warn" | "error";
|
|
448
439
|
interface PreflightIssue {
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
440
|
+
code: string;
|
|
441
|
+
severity: PreflightSeverity;
|
|
442
|
+
message: string;
|
|
452
443
|
}
|
|
453
444
|
/**
|
|
454
445
|
* Run pre-flight validation checks on a package before publishing.
|
|
455
446
|
* Checks entry points, exports, types, and bin paths exist on disk.
|
|
456
447
|
* Returns an array of issues found (empty = all good).
|
|
457
448
|
*/
|
|
458
|
-
declare function runPreflightChecks(packageDir: string): Promise<PreflightIssue[]>;
|
|
459
|
-
|
|
449
|
+
export declare function runPreflightChecks(packageDir: string): Promise<PreflightIssue[]>;
|
|
460
450
|
/**
|
|
461
451
|
* Ring the terminal bell (BEL character).
|
|
462
452
|
* Writes to stderr so it doesn't interfere with --json output on stdout.
|
|
463
453
|
*/
|
|
464
|
-
declare function ringBell(enabled: boolean): void;
|
|
465
|
-
|
|
454
|
+
export declare function ringBell(enabled: boolean): void;
|
|
466
455
|
/** Type guard for Node.js system errors with an error code */
|
|
467
|
-
declare function isNodeError(err: unknown): err is NodeJS.ErrnoException;
|
|
468
|
-
|
|
456
|
+
export declare function isNodeError(err: unknown): err is NodeJS.ErrnoException;
|
|
469
457
|
/** Normalize a file path to use forward slashes (for cross-platform consistency). */
|
|
470
|
-
declare function normalizePath(p: string): string;
|
|
471
|
-
|
|
458
|
+
export declare function normalizePath(p: string): string;
|
|
472
459
|
type MutationType = "copy" | "remove" | "move" | "mkdir" | "write" | "bin-link" | "bin-unlink" | "cache-invalidate" | "lock-skip" | "lifecycle-skip" | "command-skip";
|
|
473
460
|
interface DryRunMutation {
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
461
|
+
type: MutationType;
|
|
462
|
+
path: string;
|
|
463
|
+
dest?: string;
|
|
464
|
+
detail?: string;
|
|
478
465
|
}
|
|
479
466
|
/** Record a mutation that was skipped due to --dry-run */
|
|
480
|
-
declare function recordMutation(mutation: DryRunMutation): void;
|
|
467
|
+
export declare function recordMutation(mutation: DryRunMutation): void;
|
|
481
468
|
/** Print a summary of all recorded dry-run mutations */
|
|
482
|
-
declare function printDryRunReport(): void;
|
|
469
|
+
export declare function printDryRunReport(): void;
|
|
483
470
|
/** Reset recorded mutations (for testing) */
|
|
484
|
-
declare function resetMutations(): void;
|
|
485
|
-
|
|
471
|
+
export declare function resetMutations(): void;
|
|
486
472
|
/**
|
|
487
473
|
* Heuristic to detect configs that are too complex for automatic rewriting.
|
|
488
474
|
* Returns null if safe to rewrite, or a reason string if too complex.
|
|
489
475
|
*/
|
|
490
|
-
declare function isComplexConfig(content: string): {
|
|
491
|
-
|
|
492
|
-
|
|
476
|
+
export declare function isComplexConfig(content: string): {
|
|
477
|
+
complex: boolean;
|
|
478
|
+
reason?: string;
|
|
493
479
|
};
|
|
494
|
-
|
|
495
|
-
export { type ConsumerState, type ConsumersRegistry, CycleError, type DryRunMutation, type HistoryEntry, type InjectOptions, type InjectResult, type KnarrConfig, type KnarrMeta, type LinkEntry, type MutationType, type PackageJson, type PackageManager, type PackageManagerDetection, type PackageManagerDetectionSource, type PreflightIssue, type PreflightSeverity, type PublishOptions, type PublishResult, type PushOptions, type StoreEntry, Timer, type WatchOptions, WatchOrchestrator, type WorkspaceGraph, type WorkspacePackage, addLink, backupExisting, buildReverseAdjacency, buildWorkspaceGraph, captureHistory, checkMissingDeps, cleanStaleConsumers, clearHistory, detectPackageManager, detectPackageManagerInfo, doPush, doPushAll, findStoreEntry, getConsumers, getHistoryEntry, getLink, getStoreEntry, inject, isComplexConfig, isNodeError, killActiveBuild, listHistory, listStoreEntries, loadKnarrConfig, normalizePath, printDryRunReport, pruneHistory, publish, readConsumerState, readConsumerStateSafe, recordMutation, registerConsumer, removeInjected, removeLink, resetMutations, resolveHistoryLimit, restoreBackup, restoreHistoryEntry, ringBell, runBuildCommand, runPreflightChecks, startWatcher, topoSort, unregisterConsumer };
|
|
480
|
+
export type { ConsumerState, ConsumersRegistry, DryRunMutation, HistoryEntry, InjectOptions, InjectResult, KnarrConfig, KnarrMeta, LinkEntry, MutationType, OwnRecord, PackageJson, PackageManager, PackageManagerDetection, PackageManagerDetectionSource, PreflightIssue, PreflightSeverity, PublishOptions, PublishResult, PushOptions, StoreEntry, WatchOptions, WorkspaceGraph, WorkspacePackage };
|