@decohere/devkit 0.0.1-dev.125 → 0.0.1-dev.5

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 (121) hide show
  1. package/package.json +3 -12
  2. package/src/cli/action.ts +77 -0
  3. package/src/cli/command.ts +173 -0
  4. package/src/cli/index.ts +30 -0
  5. package/src/cli/module.type.ts +48 -0
  6. package/src/cli/options.ts +81 -0
  7. package/src/diagnostics/trace.ts +92 -0
  8. package/src/interop/docker/docker.ts +57 -0
  9. package/src/interop/errors/interop.error.ts +1 -0
  10. package/src/interop/git/git.ts +98 -0
  11. package/{types/src/interop/git/git.types.d.ts → src/interop/git/git.types.ts} +9 -6
  12. package/{es6/src/interop/index.js → src/interop/index.ts} +1 -0
  13. package/src/interop/node/node.ts +38 -0
  14. package/src/interop/npm/npm.ts +168 -0
  15. package/src/interop/npm/npm.types.ts +28 -0
  16. package/src/interop/pnpm/pnpm.ts +22 -0
  17. package/{types/src/interop/pnpm/pnpm.types.d.ts → src/interop/pnpm/pnpm.types.ts} +1 -1
  18. package/src/interop/shell/shell.argv.ts +31 -0
  19. package/src/interop/shell/shell.ts +100 -0
  20. package/src/interop/shell/shell.types.ts +9 -0
  21. package/src/interop/types/detect-package-manager.ts +45 -0
  22. package/src/interop/types/package-manager.ts +7 -0
  23. package/src/interop/yarn/yarn.ts +28 -0
  24. package/{types/src/interop/yarn/yarn.types.d.ts → src/interop/yarn/yarn.types.ts} +1 -1
  25. package/src/io/find-directories.ts +13 -0
  26. package/src/io/find-file.ts +37 -0
  27. package/src/io/watch.ts +290 -0
  28. package/tests/cli/command.model.spec.ts +91 -0
  29. package/tests/diagnostics/trace.spec.ts +319 -0
  30. package/tests/interop/detect-package-manager.spec.ts +70 -0
  31. package/tests/interop/npm.spec.ts +129 -0
  32. package/tests/interop/pnpm.spec.ts +30 -0
  33. package/tests/interop/shell.spec.ts +47 -0
  34. package/tests/interop/yarn.spec.ts +18 -0
  35. package/tests/io/find-file.spec.ts +188 -0
  36. package/tests/io/watch.real-fs.spec.ts +76 -0
  37. package/tests/io/watch.spec.ts +291 -0
  38. package/LICENSE +0 -15
  39. package/commonjs/src/cli/action.js +0 -65
  40. package/commonjs/src/cli/command.js +0 -127
  41. package/commonjs/src/cli/index.js +0 -61
  42. package/commonjs/src/cli/module.type.js +0 -18
  43. package/commonjs/src/cli/options.js +0 -115
  44. package/commonjs/src/diagnostics/index.js +0 -22
  45. package/commonjs/src/diagnostics/trace.js +0 -79
  46. package/commonjs/src/interop/docker/docker.js +0 -54
  47. package/commonjs/src/interop/errors/interop.error.js +0 -12
  48. package/commonjs/src/interop/git/git.js +0 -134
  49. package/commonjs/src/interop/git/git.types.js +0 -4
  50. package/commonjs/src/interop/index.js +0 -97
  51. package/commonjs/src/interop/node/index.js +0 -18
  52. package/commonjs/src/interop/node/node.js +0 -45
  53. package/commonjs/src/interop/npm/npm.js +0 -231
  54. package/commonjs/src/interop/npm/npm.types.js +0 -16
  55. package/commonjs/src/interop/pnpm/pnpm.js +0 -34
  56. package/commonjs/src/interop/pnpm/pnpm.types.js +0 -4
  57. package/commonjs/src/interop/shell/shell.argv.js +0 -45
  58. package/commonjs/src/interop/shell/shell.js +0 -105
  59. package/commonjs/src/interop/shell/shell.types.js +0 -4
  60. package/commonjs/src/interop/types/detect-package-manager.js +0 -71
  61. package/commonjs/src/interop/types/package-manager.js +0 -4
  62. package/commonjs/src/interop/yarn/yarn.js +0 -34
  63. package/commonjs/src/interop/yarn/yarn.types.js +0 -4
  64. package/commonjs/src/io/find-directories.js +0 -21
  65. package/commonjs/src/io/find-file.js +0 -45
  66. package/commonjs/src/io/index.js +0 -20
  67. package/commonjs/src/io/watch.js +0 -261
  68. package/es6/src/cli/action.js +0 -47
  69. package/es6/src/cli/command.js +0 -106
  70. package/es6/src/cli/index.js +0 -4
  71. package/es6/src/cli/module.type.js +0 -11
  72. package/es6/src/cli/options.js +0 -76
  73. package/es6/src/diagnostics/trace.js +0 -61
  74. package/es6/src/interop/docker/docker.js +0 -44
  75. package/es6/src/interop/errors/interop.error.js +0 -2
  76. package/es6/src/interop/git/git.js +0 -124
  77. package/es6/src/interop/git/git.types.js +0 -1
  78. package/es6/src/interop/node/node.js +0 -35
  79. package/es6/src/interop/npm/npm.js +0 -180
  80. package/es6/src/interop/npm/npm.types.js +0 -6
  81. package/es6/src/interop/pnpm/pnpm.js +0 -24
  82. package/es6/src/interop/pnpm/pnpm.types.js +0 -1
  83. package/es6/src/interop/shell/shell.argv.js +0 -35
  84. package/es6/src/interop/shell/shell.js +0 -95
  85. package/es6/src/interop/shell/shell.types.js +0 -1
  86. package/es6/src/interop/types/detect-package-manager.js +0 -50
  87. package/es6/src/interop/types/package-manager.js +0 -1
  88. package/es6/src/interop/yarn/yarn.js +0 -24
  89. package/es6/src/interop/yarn/yarn.types.js +0 -1
  90. package/es6/src/io/find-directories.js +0 -11
  91. package/es6/src/io/find-file.js +0 -27
  92. package/es6/src/io/watch.js +0 -238
  93. package/types/src/cli/action.d.ts +0 -36
  94. package/types/src/cli/command.d.ts +0 -34
  95. package/types/src/cli/index.d.ts +0 -7
  96. package/types/src/cli/module.type.d.ts +0 -36
  97. package/types/src/cli/options.d.ts +0 -28
  98. package/types/src/diagnostics/index.d.ts +0 -1
  99. package/types/src/diagnostics/trace.d.ts +0 -10
  100. package/types/src/interop/docker/docker.d.ts +0 -19
  101. package/types/src/interop/errors/interop.error.d.ts +0 -2
  102. package/types/src/interop/git/git.d.ts +0 -16
  103. package/types/src/interop/index.d.ts +0 -14
  104. package/types/src/interop/node/index.d.ts +0 -1
  105. package/types/src/interop/node/node.d.ts +0 -5
  106. package/types/src/interop/npm/npm.d.ts +0 -29
  107. package/types/src/interop/npm/npm.types.d.ts +0 -24
  108. package/types/src/interop/pnpm/pnpm.d.ts +0 -9
  109. package/types/src/interop/shell/shell.argv.d.ts +0 -5
  110. package/types/src/interop/shell/shell.d.ts +0 -6
  111. package/types/src/interop/shell/shell.types.d.ts +0 -9
  112. package/types/src/interop/types/detect-package-manager.d.ts +0 -4
  113. package/types/src/interop/types/package-manager.d.ts +0 -10
  114. package/types/src/interop/yarn/yarn.d.ts +0 -9
  115. package/types/src/io/find-directories.d.ts +0 -2
  116. package/types/src/io/find-file.d.ts +0 -9
  117. package/types/src/io/index.d.ts +0 -3
  118. package/types/src/io/watch.d.ts +0 -16
  119. /package/{es6/src/diagnostics/index.js → src/diagnostics/index.ts} +0 -0
  120. /package/{es6/src/interop/node/index.js → src/interop/node/index.ts} +0 -0
  121. /package/{es6/src/io/index.js → src/io/index.ts} +0 -0
@@ -1,238 +0,0 @@
1
- import { watch as nativeWatch, readdirSync, statSync } from "node:fs";
2
- import path from "node:path";
3
- import picomatch from "picomatch";
4
- import { FileEx } from "@decohere/core/io";
5
- export const WatchEvents = {
6
- add: "add",
7
- change: "change",
8
- addDir: "addDir",
9
- unlink: "unlink",
10
- unlinkDir: "unlinkDir"
11
- };
12
- export function watch(directory, options = {
13
- cwd: "."
14
- }) {
15
- const { include, ignore, ignoreInitial = false } = options;
16
- const changeCoalesceMs = 25;
17
- const handlers = {
18
- ready: new Set(),
19
- add: new Set(),
20
- change: new Set(),
21
- addDir: new Set(),
22
- unlink: new Set(),
23
- unlinkDir: new Set()
24
- };
25
- let resolveReady;
26
- const ready = new Promise((resolve)=>{
27
- resolveReady = resolve;
28
- });
29
- const snapshot = buildSnapshot(directory);
30
- const isFiltered = (relativePath)=>{
31
- const posixRelativePath = toPosixPath(relativePath);
32
- const posixFullPath = toPosixPath(path.resolve(directory, relativePath));
33
- const matchesEitherPath = (patterns)=>picomatch.isMatch(posixRelativePath, patterns) || picomatch.isMatch(posixFullPath, patterns);
34
- if (include && include.length > 0) {
35
- return !matchesEitherPath(include);
36
- }
37
- if (ignore && ignore.length > 0) {
38
- return matchesEitherPath(ignore);
39
- }
40
- return false;
41
- };
42
- const emit = (event, relativePath)=>{
43
- if (isFiltered(relativePath)) {
44
- return;
45
- }
46
- const fullPath = path.resolve(directory, relativePath);
47
- for (const handler of handlers[event]){
48
- handler(new FileEx({
49
- fullPath,
50
- relativePath
51
- }));
52
- }
53
- };
54
- const pendingChangeTimers = new Map();
55
- const emitChange = (relativePath)=>{
56
- const existing = pendingChangeTimers.get(relativePath);
57
- if (existing != null) {
58
- clearTimeout(existing);
59
- }
60
- const timer = setTimeout(()=>{
61
- pendingChangeTimers.delete(relativePath);
62
- emit("change", relativePath);
63
- }, changeCoalesceMs);
64
- pendingChangeTimers.set(relativePath, timer);
65
- };
66
- const emitReady = ()=>{
67
- for (const handler of handlers.ready){
68
- handler();
69
- }
70
- };
71
- queueMicrotask(()=>{
72
- if (!ignoreInitial) {
73
- for (const [relativePath, entry] of snapshot){
74
- emit(entry.isDirectory ? "addDir" : "add", relativePath);
75
- }
76
- }
77
- emitReady();
78
- resolveReady?.();
79
- resolveReady = undefined;
80
- });
81
- // One non-recursive watcher per directory. Node's recursive mode on Linux tracks files
82
- // individually and goes silent for a file once an editor replaces it with an atomic save
83
- // (write temp file, rename over the original); directory watchers keep seeing it (#505).
84
- const directoryWatchers = new Map();
85
- const watchDirectory = (relativeDir)=>{
86
- if (directoryWatchers.has(relativeDir)) {
87
- return;
88
- }
89
- try {
90
- const watcher = nativeWatch(path.resolve(directory, relativeDir), (_eventType, fileName)=>{
91
- if (fileName != null) {
92
- onFsEvent(path.posix.join(relativeDir, toPosixPath(fileName.toString())));
93
- }
94
- });
95
- watcher.on("error", ()=>unwatchDirectory(relativeDir));
96
- directoryWatchers.set(relativeDir, watcher);
97
- } catch {
98
- // The directory vanished before we could watch it; its unlink event covers it.
99
- }
100
- };
101
- const unwatchDirectory = (relativeDir)=>{
102
- for (const [watchedDir, watcher] of directoryWatchers){
103
- if (watchedDir === relativeDir || watchedDir.startsWith(`${relativeDir}/`)) {
104
- watcher.close();
105
- directoryWatchers.delete(watchedDir);
106
- }
107
- }
108
- };
109
- /** A directory appeared: watch it, and report what was created in it before we were watching. */ const addDirectory = (relativeDir)=>{
110
- watchDirectory(relativeDir);
111
- const found = new Map();
112
- try {
113
- collectSnapshotEntries(directory, path.resolve(directory, relativeDir), found);
114
- } catch {
115
- return;
116
- }
117
- for (const [relativePath, entry] of found){
118
- if (snapshot.has(relativePath)) continue;
119
- snapshot.set(relativePath, entry);
120
- if (entry.isDirectory) watchDirectory(relativePath);
121
- emit(entry.isDirectory ? "addDir" : "add", relativePath);
122
- }
123
- };
124
- /** A directory went away: stop watching it and forget everything that was under it. */ const removeDirectoryContents = (relativeDir)=>{
125
- unwatchDirectory(relativeDir);
126
- // oxlint-disable-next-line unicorn/no-useless-spread -- iterate a copy: the loop deletes from the snapshot
127
- for (const [relativePath, entry] of [
128
- ...snapshot
129
- ]){
130
- if (relativePath.startsWith(`${relativeDir}/`)) {
131
- snapshot.delete(relativePath);
132
- emit(entry.isDirectory ? "unlinkDir" : "unlink", relativePath);
133
- }
134
- }
135
- };
136
- const onFsEvent = (eventPath)=>{
137
- const relativePath = eventPath === "." ? "" : eventPath;
138
- if (relativePath.length === 0) {
139
- return;
140
- }
141
- const fullPath = path.resolve(directory, relativePath);
142
- const previous = snapshot.get(relativePath);
143
- try {
144
- const stat = statSync(fullPath);
145
- const current = toSnapshotEntry(stat);
146
- snapshot.set(relativePath, current);
147
- if (previous == null) {
148
- emit(current.isDirectory ? "addDir" : "add", relativePath);
149
- if (current.isDirectory) addDirectory(relativePath);
150
- return;
151
- }
152
- if (previous.isDirectory !== current.isDirectory) {
153
- if (previous.isDirectory) removeDirectoryContents(relativePath);
154
- emit(previous.isDirectory ? "unlinkDir" : "unlink", relativePath);
155
- emit(current.isDirectory ? "addDir" : "add", relativePath);
156
- return;
157
- }
158
- if (!current.isDirectory && previous.fingerprint !== current.fingerprint) {
159
- emitChange(relativePath);
160
- }
161
- } catch {
162
- if (previous == null) {
163
- return;
164
- }
165
- snapshot.delete(relativePath);
166
- const pending = pendingChangeTimers.get(relativePath);
167
- if (pending != null) {
168
- clearTimeout(pending);
169
- pendingChangeTimers.delete(relativePath);
170
- }
171
- emit(previous.isDirectory ? "unlinkDir" : "unlink", relativePath);
172
- }
173
- };
174
- watchDirectory("");
175
- for (const [relativePath, entry] of snapshot){
176
- if (entry.isDirectory) watchDirectory(relativePath);
177
- }
178
- const watchApi = {
179
- ready,
180
- on (event, handler) {
181
- if (event === "ready") {
182
- handlers.ready.add(handler);
183
- return watchApi;
184
- }
185
- handlers[event].add(handler);
186
- return watchApi;
187
- },
188
- close: ()=>{
189
- for (const pending of pendingChangeTimers.values()){
190
- clearTimeout(pending);
191
- }
192
- pendingChangeTimers.clear();
193
- for (const watcher of directoryWatchers.values()){
194
- watcher.close();
195
- }
196
- directoryWatchers.clear();
197
- }
198
- };
199
- return watchApi;
200
- }
201
- function buildSnapshot(directoryPath) {
202
- const snapshot = new Map();
203
- collectSnapshotEntries(directoryPath, directoryPath, snapshot);
204
- return snapshot;
205
- }
206
- /** Never source, and huge: watching every folder inside them could exhaust OS watch limits. */ const UNWATCHED_DIRECTORIES = new Set([
207
- "node_modules",
208
- ".git"
209
- ]);
210
- function collectSnapshotEntries(rootDirectoryPath, currentDirectoryPath, snapshot) {
211
- for (const entry of readdirSync(currentDirectoryPath, {
212
- encoding: "utf8"
213
- })){
214
- const name = typeof entry === "string" ? entry : String(entry);
215
- const fullPath = path.join(currentDirectoryPath, name);
216
- if (UNWATCHED_DIRECTORIES.has(name)) {
217
- continue;
218
- }
219
- const relativePath = toPosixPath(path.relative(rootDirectoryPath, fullPath));
220
- const stat = statSync(fullPath);
221
- const snapshotEntry = toSnapshotEntry(stat);
222
- snapshot.set(relativePath, snapshotEntry);
223
- if (!snapshotEntry.isDirectory) {
224
- continue;
225
- }
226
- collectSnapshotEntries(rootDirectoryPath, fullPath, snapshot);
227
- }
228
- }
229
- function toSnapshotEntry(stat) {
230
- const isDirectory = stat.isDirectory();
231
- return {
232
- isDirectory,
233
- fingerprint: isDirectory ? `dir:${stat.mtimeMs}` : `file:${stat.mtimeMs}:${stat.size}`
234
- };
235
- }
236
- function toPosixPath(filePath) {
237
- return filePath.split(path.sep).join(path.posix.sep);
238
- }
@@ -1,36 +0,0 @@
1
- import type { Constructable } from "@decohere/core/reflection";
2
- import type { UnionToIntersection } from "@decohere/core/system";
3
- export declare const ActionMap: unique symbol;
4
- export type ActionClassMap = Record<string, Constructable<Action>>;
5
- export interface ResultStatus {
6
- succeeded: boolean;
7
- error?: string;
8
- }
9
- export interface Result {
10
- readonly name: string;
11
- readonly succeeded: boolean;
12
- readonly skipped: boolean;
13
- readonly message: string;
14
- }
15
- export declare class ActionResponse<TData = unknown> implements Result {
16
- static Success<TData>(name: string, data?: TData[]): ActionResponse<TData>;
17
- static Skipped(name: string): ActionResponse<unknown>;
18
- static Blocking(name: string): ActionResponse<unknown>;
19
- static Error<TData = unknown>(name: string, message: string): ActionResponse<TData>;
20
- static Error<TData extends ResultStatus>(name: string, data: TData[]): ActionResponse<TData>;
21
- constructor(data: Partial<ActionResponse<TData>>);
22
- readonly name: string;
23
- readonly succeeded: boolean;
24
- readonly skipped: boolean;
25
- readonly blocking: boolean;
26
- readonly message: string;
27
- readonly data: TData[];
28
- }
29
- export interface Action<T extends object = object> {
30
- run(options: T): Promise<ActionResponse>;
31
- }
32
- export type Actions = Record<string, Action>;
33
- export type ActionOptions<A extends Action> = A extends Action<infer T> ? T : never;
34
- export type MergeOptions<TActions extends Record<string, Action>> = UnionToIntersection<{
35
- [K in keyof TActions]: ActionOptions<TActions[K]>;
36
- }[keyof TActions]>;
@@ -1,34 +0,0 @@
1
- import { Command as CommanderType, type OptionValues } from "commander";
2
- import type { Constructable } from "@decohere/core/reflection";
3
- import type { ActionResponse, Actions } from "./action.js";
4
- export type CommandType = Constructable<DecohereCommand>;
5
- export type CommandHandler = (opts: OptionValues, cmd: DecohereCommand) => Promise<void>;
6
- export type CommandResponse<TActions extends Actions = Actions> = {
7
- [ActionName in keyof TActions]?: ActionResponse;
8
- };
9
- export declare const CommandResponse: {
10
- success<T extends Actions>(_ctx: unknown, responses: CommandResponse<T>): CommandResponse<T>;
11
- help<T extends Actions = Actions>(): CommandResponse<T>;
12
- fromAction(name: string, response: ActionResponse): CommandResponse;
13
- };
14
- /** Thrown when a command execution fails due to action errors. */
15
- export declare class CommandError extends Error {
16
- }
17
- export declare class DecohereCommand<TActions extends Actions = Actions> extends CommanderType {
18
- get actions(): readonly Constructable<import("./action.js").Action>[];
19
- constructor(name?: string | Constructable | Record<string, CommandType>, handler?: CommandHandler);
20
- /**
21
- * Whether the command, with these options, runs until it is stopped (`flux serve`,
22
- * `forge build --watch`). The CLI then listens for SIGINT and SIGTERM from the moment it
23
- * starts, so a stop during start-up still shuts down cleanly; other commands keep Node's
24
- * default, where Ctrl+C ends them at once.
25
- */
26
- runsUntilStopped(_options: OptionValues): boolean;
27
- run(actions: TActions, options: OptionValues): Promise<CommandResponse<TActions>>;
28
- registerSubcommand(command: CommandType, onAction?: CommandHandler): void;
29
- registerSubcommand(commands: Record<string, DecohereCommand | CommandType>, onAction?: CommandHandler): void;
30
- protected runActions(actions: TActions, options: OptionValues): Promise<CommandResponse<TActions>>;
31
- protected getSelectedActions(actions: TActions): Array<[keyof TActions, TActions[keyof TActions]]>;
32
- protected throwOnErrors(responses: CommandResponse<TActions>): void;
33
- private parseCommandName;
34
- }
@@ -1,7 +0,0 @@
1
- export type { Action, ActionClassMap, ActionOptions, Actions, MergeOptions, Result, ResultStatus, } from "./action.js";
2
- export { ActionMap, ActionResponse } from "./action.js";
3
- export type { CommandHandler, CommandType } from "./command.js";
4
- export { CommandError, CommandResponse, DecohereCommand } from "./command.js";
5
- export type { ApplicationModule, CommandMap as CommandClassMap, ModuleConfig, WorkspaceFactoryOptions, } from "./module.type.js";
6
- export { ModuleManifest } from "./module.type.js";
7
- export { ConfigFileOption, ConfigurationOption, DryRunOption, EnvFileIfExistsOption, EnvFileOption, LogLevelOption, NoBuildOptions, NoCleanOptions, ProjectOption, } from "./options.js";
@@ -1,36 +0,0 @@
1
- import type { ContainerBuilder } from "@decohere/core/composition";
2
- import type { ActionClassMap } from "./action.js";
3
- import type { CommandType, DecohereCommand } from "./command.js";
4
- export type CommandMap = Record<string, CommandType>;
5
- export type WorkspaceFactoryOptions = {
6
- configFile?: string;
7
- rootDir?: string;
8
- };
9
- export interface ApplicationModule {
10
- id: string;
11
- dispose?(): void;
12
- asyncDispose?(): Promise<void>;
13
- command: DecohereCommand;
14
- }
15
- export type ModuleConfig = {
16
- actions?: ActionClassMap;
17
- commands?: CommandMap;
18
- };
19
- /**
20
- * Simple declaration interface for a CLI module.
21
- * Extend this and implement the four abstract members.
22
- */
23
- export declare abstract class ModuleManifest {
24
- /** Unique module identifier, used as the root command name. */
25
- abstract readonly id: string;
26
- /** Sub-command classes this module contributes. */
27
- readonly commands: CommandMap;
28
- /** Action classes this module contributes. */
29
- readonly actions: ActionClassMap;
30
- /** The root command class for this module. */
31
- abstract readonly command: CommandType;
32
- /** Register infrastructure services into the DI container. */
33
- registerServices(_builder: ContainerBuilder): void;
34
- /** Lazily create a workspace instance. Return null if this module does not use a workspace. */
35
- createWorkspace(_options: WorkspaceFactoryOptions): Promise<object | null>;
36
- }
@@ -1,28 +0,0 @@
1
- import { Option } from "commander";
2
- export declare class ConfigurationOption extends Option {
3
- constructor(defaultValue: string);
4
- }
5
- export declare class ConfigFileOption extends Option {
6
- constructor(defaultValue?: string);
7
- }
8
- export declare class LogLevelOption extends Option {
9
- constructor();
10
- }
11
- export declare class EnvFileOption extends Option {
12
- constructor();
13
- }
14
- export declare class EnvFileIfExistsOption extends Option {
15
- constructor();
16
- }
17
- export declare class NoCleanOptions extends Option {
18
- constructor(defaultValue: boolean);
19
- }
20
- export declare class NoBuildOptions extends Option {
21
- constructor(defaultValue: boolean);
22
- }
23
- export declare class DryRunOption extends Option {
24
- constructor(description: string, defaultValue?: boolean);
25
- }
26
- export declare class ProjectOption extends Option {
27
- constructor();
28
- }
@@ -1 +0,0 @@
1
- export { Trace, timed, trace } from "./trace.js";
@@ -1,10 +0,0 @@
1
- export declare function trace(target: object, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
2
- /**
3
- * Always-on method timing. Logs duration at `info` regardless of `FORGE_TRACE`.
4
- * Use this to time a specific method without raising the process log level.
5
- */
6
- export declare function timed(target: object, propertyKey: string, descriptor: PropertyDescriptor): PropertyDescriptor;
7
- export declare function Trace(constructor: {
8
- name: string;
9
- prototype: object;
10
- }): void;
@@ -1,19 +0,0 @@
1
- import { Shell } from "../shell/shell.js";
2
- export type DockerBuildOptions = {
3
- cwd?: string;
4
- dockerfile?: string;
5
- tags?: string[];
6
- buildArgs?: Record<string, string>;
7
- secrets?: Record<string, string>;
8
- noCache?: boolean;
9
- pull?: boolean;
10
- };
11
- export type DockerPushOptions = {
12
- cwd?: string;
13
- };
14
- export declare class Docker extends Shell {
15
- readonly name: "docker";
16
- protected program: string;
17
- build(contextDir: string, options?: DockerBuildOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
18
- push(tag: string, options?: DockerPushOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
19
- }
@@ -1,2 +0,0 @@
1
- export declare class InteropError extends Error {
2
- }
@@ -1,16 +0,0 @@
1
- import { Shell } from "../shell/shell.js";
2
- import type { ShellResponse } from "../shell/shell.types.js";
3
- import type { CommitOptions, GitOptions, PushOptions, StageOptions } from "./git.types.js";
4
- export declare class Git extends Shell {
5
- protected program: string;
6
- getModifiedFiles(options?: GitOptions): Promise<string[]>;
7
- getBranchName(options?: GitOptions): Promise<string>;
8
- tag(tag: string, options?: GitOptions): Promise<ShellResponse>;
9
- pushTag(tag: string, options?: GitOptions & {
10
- remote?: string;
11
- }): Promise<ShellResponse>;
12
- commit(message: string, options: CommitOptions): Promise<ShellResponse>;
13
- push(branch: string, options?: PushOptions): Promise<ShellResponse>;
14
- pull(branch: string, options?: GitOptions): Promise<ShellResponse>;
15
- stage(options: StageOptions): Promise<void>;
16
- }
@@ -1,14 +0,0 @@
1
- export * from "./docker/docker.js";
2
- export * from "./git/git.js";
3
- export * as git from "./git/git.types.js";
4
- export * from "./node/node.js";
5
- export * from "./npm/npm.js";
6
- export * as npm from "./npm/npm.types.js";
7
- export * from "./pnpm/pnpm.js";
8
- export * as pnpm from "./pnpm/pnpm.types.js";
9
- export * from "./shell/shell.js";
10
- export * as shell from "./shell/shell.types.js";
11
- export * from "./types/detect-package-manager.js";
12
- export * from "./types/package-manager.js";
13
- export * from "./yarn/yarn.js";
14
- export * as yarn from "./yarn/yarn.types.js";
@@ -1 +0,0 @@
1
- export * from "./node.js";
@@ -1,5 +0,0 @@
1
- import { Shell } from "../shell/shell.js";
2
- export declare class Node extends Shell {
3
- protected program: string;
4
- runScript(script: string, ...args: string[]): Promise<unknown>;
5
- }
@@ -1,29 +0,0 @@
1
- import { Shell } from "../shell/shell.js";
2
- import type { PackageManager } from "../types/package-manager.js";
3
- import type { NpmOptions, PublishOptions, VersionOptions, VersionType } from "./npm.types.js";
4
- export declare class Npm extends Shell implements PackageManager {
5
- readonly name: "npm";
6
- protected program: string;
7
- publish(directory: string, options?: PublishOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
8
- /**
9
- * @description Runs in the directory of the package
10
- * @param options
11
- * @returns
12
- */
13
- version(versionType: VersionType, options: VersionOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
14
- link(directory: string, options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
15
- install(options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
16
- /**
17
- * Install only `dependencies` as real folders: `--omit=dev` skips devDependencies and
18
- * `--no-bin-links` skips the `.bin` symlinks, so the result holds no symlinks at all.
19
- */
20
- installProduction(options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
21
- syncLockFile(options?: NpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
22
- /**
23
- * True when package@version exists on the registry.
24
- * Uses ambient npm config (cwd `.npmrc`); do not pass tokens on argv.
25
- */
26
- private isPublished;
27
- private createTempUserConfig;
28
- private removeTempUserConfig;
29
- }
@@ -1,24 +0,0 @@
1
- export type NpmOptions = {
2
- cwd?: string;
3
- };
4
- export type PublishOptions = {
5
- dryRun?: boolean;
6
- skipIfPublished?: boolean;
7
- authToken?: string;
8
- otp?: string;
9
- provenance?: boolean;
10
- /** @deprecated use channel */
11
- versionType?: VersionType;
12
- channel?: string;
13
- } & NpmOptions;
14
- export type VersionType = "major" | "minor" | "patch" | "prerelease";
15
- export declare const VersionTypes: {
16
- major: "major";
17
- minor: "minor";
18
- patch: "patch";
19
- prerelease: "prerelease";
20
- };
21
- export type VersionOptions = {
22
- preid?: string;
23
- noTag?: boolean;
24
- } & NpmOptions;
@@ -1,9 +0,0 @@
1
- import { Shell } from "../shell/shell.js";
2
- import type { PackageManager } from "../types/package-manager.js";
3
- import type { PnpmOptions } from "./pnpm.types.js";
4
- export declare class Pnpm extends Shell implements PackageManager {
5
- readonly name: "pnpm";
6
- protected program: string;
7
- install(options?: PnpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
8
- syncLockFile(options?: PnpmOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
9
- }
@@ -1,5 +0,0 @@
1
- declare function fields(args: string[]): Record<string, string | boolean | string[]>;
2
- export declare const shellArgv: {
3
- fields: typeof fields;
4
- };
5
- export {};
@@ -1,6 +0,0 @@
1
- import type { ShellOptions, ShellResponse } from "./shell.types.js";
2
- export declare abstract class Shell {
3
- protected abstract program: string;
4
- protected run(options: ShellOptions, ...args: string[]): Promise<ShellResponse>;
5
- private parseStream;
6
- }
@@ -1,9 +0,0 @@
1
- export type ShellResponse = {
2
- message: string;
3
- data: string[];
4
- };
5
- export interface ShellOptions {
6
- cwd?: string;
7
- /** Spawn env. Defaults to `process.env`. Not written to logs. */
8
- env?: NodeJS.ProcessEnv;
9
- }
@@ -1,4 +0,0 @@
1
- import type { PackageManager } from "./package-manager.js";
2
- export declare function detectPackageManager(cwd: string): PackageManager | undefined;
3
- export declare function packageManagerFromString(name: string): PackageManager;
4
- export declare function promptForPackageManager(): Promise<PackageManager>;
@@ -1,10 +0,0 @@
1
- import type { ShellResponse } from "../shell/shell.types.js";
2
- export interface PackageManager {
3
- readonly name: "npm" | "pnpm" | "yarn";
4
- install(options?: {
5
- cwd?: string;
6
- }): Promise<ShellResponse>;
7
- syncLockFile(options?: {
8
- cwd?: string;
9
- }): Promise<ShellResponse>;
10
- }
@@ -1,9 +0,0 @@
1
- import { Shell } from "../shell/shell.js";
2
- import type { PackageManager } from "../types/package-manager.js";
3
- import type { YarnOptions } from "./yarn.types.js";
4
- export declare class Yarn extends Shell implements PackageManager {
5
- readonly name: "yarn";
6
- protected program: string;
7
- install(options?: YarnOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
8
- syncLockFile(options?: YarnOptions): Promise<import("../shell/shell.types.js").ShellResponse>;
9
- }
@@ -1,2 +0,0 @@
1
- import type { Directory } from "@decohere/core/io";
2
- export declare function findDirectories(...pattern: string[]): Promise<Directory[]>;
@@ -1,9 +0,0 @@
1
- import { FileEx } from "@decohere/core/io";
2
- export type FindFileOptions = {
3
- cwd: string;
4
- ignore?: string | string[];
5
- };
6
- export declare function findFile(pattern: string): Promise<{
7
- relativePath: string;
8
- }>;
9
- export declare function findFiles(patterns: string[], options?: FindFileOptions): Promise<FileEx[]>;
@@ -1,3 +0,0 @@
1
- export * from "./find-directories.js";
2
- export * from "./find-file.js";
3
- export * from "./watch.js";
@@ -1,16 +0,0 @@
1
- import { type Watcher } from "@decohere/core/io";
2
- export type WatchOptions = {
3
- include?: string[];
4
- ignore?: string[];
5
- cwd?: string;
6
- ignoreInitial?: boolean;
7
- };
8
- export type WatchEventName = "add" | "change" | "addDir" | "unlink" | "unlinkDir";
9
- export declare const WatchEvents: {
10
- add: "add";
11
- change: "change";
12
- addDir: "addDir";
13
- unlink: "unlink";
14
- unlinkDir: "unlinkDir";
15
- };
16
- export declare function watch(directory: string, options?: WatchOptions): Watcher;
File without changes