@decohere/forge 0.0.1-dev.10
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/commonjs/src/actions/build.action.js +108 -0
- package/commonjs/src/actions/clean.action.js +55 -0
- package/commonjs/src/actions/commit.action.js +87 -0
- package/commonjs/src/actions/copy.action.js +83 -0
- package/commonjs/src/actions/dependency-report.action.js +142 -0
- package/commonjs/src/actions/dependency-sync.action.js +100 -0
- package/commonjs/src/actions/index.js +30 -0
- package/commonjs/src/actions/publish.action.js +156 -0
- package/commonjs/src/actions/sync-lock-file.action.js +43 -0
- package/commonjs/src/actions/tag.action.js +76 -0
- package/commonjs/src/actions/version.action.js +209 -0
- package/commonjs/src/actions/watch.action.js +50 -0
- package/commonjs/src/commands/build.command.js +49 -0
- package/commonjs/src/commands/dependency.command.js +88 -0
- package/commonjs/src/commands/forge.command.js +24 -0
- package/commonjs/src/commands/index.js +25 -0
- package/commonjs/src/commands/publish.command.js +32 -0
- package/commonjs/src/commands/tag.command.js +28 -0
- package/commonjs/src/commands/version.command.js +36 -0
- package/commonjs/src/const.js +81 -0
- package/commonjs/src/errors.js +39 -0
- package/commonjs/src/extensions/project.extensions.js +94 -0
- package/commonjs/src/factories/swc-config.factory.js +98 -0
- package/commonjs/src/forge.module.js +109 -0
- package/commonjs/src/index.js +43 -0
- package/commonjs/src/mixins/caches-outputs.mixin.js +42 -0
- package/commonjs/src/mixins/incremental-transform.mixin.js +36 -0
- package/commonjs/src/services/dependency-resolver.service.js +172 -0
- package/commonjs/src/services/file-writer.service.js +232 -0
- package/commonjs/src/services/swc-transpiler.js +228 -0
- package/commonjs/src/services/ts-program-host.js +135 -0
- package/commonjs/src/services/type-emission-program.js +160 -0
- package/commonjs/src/services/type-emitter.js +141 -0
- package/commonjs/src/types/build-target.type.js +17 -0
- package/commonjs/src/types/configuration.type.js +6 -0
- package/commonjs/src/types/dependency.types.js +6 -0
- package/commonjs/src/types/swc-config.type.js +17 -0
- package/commonjs/src/types/transform-response.model.js +64 -0
- package/commonjs/src/types/transformer.type.js +13 -0
- package/commonjs/src/types/workspace-config.type.js +6 -0
- package/commonjs/src/vitest/forge-build.plugin.js +129 -0
- package/commonjs/src/vitest/index.js +13 -0
- package/commonjs/src/workspace.config.js +63 -0
- package/es6/src/actions/build.action.js +100 -0
- package/es6/src/actions/clean.action.js +46 -0
- package/es6/src/actions/commit.action.js +73 -0
- package/es6/src/actions/copy.action.js +69 -0
- package/es6/src/actions/dependency-report.action.js +134 -0
- package/es6/src/actions/dependency-sync.action.js +92 -0
- package/es6/src/actions/index.js +13 -0
- package/es6/src/actions/publish.action.js +147 -0
- package/es6/src/actions/sync-lock-file.action.js +33 -0
- package/es6/src/actions/tag.action.js +67 -0
- package/es6/src/actions/version.action.js +189 -0
- package/es6/src/actions/watch.action.js +41 -0
- package/es6/src/commands/build.command.js +34 -0
- package/es6/src/commands/dependency.command.js +78 -0
- package/es6/src/commands/forge.command.js +14 -0
- package/es6/src/commands/index.js +8 -0
- package/es6/src/commands/publish.command.js +22 -0
- package/es6/src/commands/tag.command.js +18 -0
- package/es6/src/commands/version.command.js +26 -0
- package/es6/src/const.js +60 -0
- package/es6/src/errors.js +18 -0
- package/es6/src/extensions/project.extensions.js +79 -0
- package/es6/src/factories/swc-config.factory.js +83 -0
- package/es6/src/forge.module.js +58 -0
- package/es6/src/index.js +7 -0
- package/es6/src/mixins/caches-outputs.mixin.js +32 -0
- package/es6/src/mixins/incremental-transform.mixin.js +26 -0
- package/es6/src/services/dependency-resolver.service.js +162 -0
- package/es6/src/services/file-writer.service.js +217 -0
- package/es6/src/services/swc-transpiler.js +213 -0
- package/es6/src/services/ts-program-host.js +120 -0
- package/es6/src/services/type-emission-program.js +145 -0
- package/es6/src/services/type-emitter.js +134 -0
- package/es6/src/types/build-target.type.js +7 -0
- package/es6/src/types/configuration.type.js +3 -0
- package/es6/src/types/dependency.types.js +3 -0
- package/es6/src/types/swc-config.type.js +7 -0
- package/es6/src/types/transform-response.model.js +46 -0
- package/es6/src/types/transformer.type.js +3 -0
- package/es6/src/types/workspace-config.type.js +3 -0
- package/es6/src/vitest/forge-build.plugin.js +114 -0
- package/es6/src/vitest/index.js +3 -0
- package/es6/src/workspace.config.js +39 -0
- package/package.json +43 -0
- package/types/src/actions/build.action.d.ts +22 -0
- package/types/src/actions/clean.action.d.ts +13 -0
- package/types/src/actions/commit.action.d.ts +17 -0
- package/types/src/actions/copy.action.d.ts +14 -0
- package/types/src/actions/dependency-report.action.d.ts +36 -0
- package/types/src/actions/dependency-sync.action.d.ts +17 -0
- package/types/src/actions/index.d.ts +11 -0
- package/types/src/actions/publish.action.d.ts +34 -0
- package/types/src/actions/sync-lock-file.action.d.ts +10 -0
- package/types/src/actions/tag.action.d.ts +19 -0
- package/types/src/actions/version.action.d.ts +35 -0
- package/types/src/actions/watch.action.d.ts +14 -0
- package/types/src/commands/build.command.d.ts +16 -0
- package/types/src/commands/dependency.command.d.ts +5 -0
- package/types/src/commands/forge.command.d.ts +6 -0
- package/types/src/commands/index.d.ts +6 -0
- package/types/src/commands/publish.command.d.ts +6 -0
- package/types/src/commands/tag.command.d.ts +6 -0
- package/types/src/commands/version.command.d.ts +12 -0
- package/types/src/const.d.ts +3 -0
- package/types/src/errors.d.ts +4 -0
- package/types/src/extensions/project.extensions.d.ts +17 -0
- package/types/src/factories/swc-config.factory.d.ts +24 -0
- package/types/src/forge.module.d.ts +31 -0
- package/types/src/index.d.ts +9 -0
- package/types/src/mixins/caches-outputs.mixin.d.ts +7 -0
- package/types/src/mixins/incremental-transform.mixin.d.ts +13 -0
- package/types/src/services/dependency-resolver.service.d.ts +15 -0
- package/types/src/services/file-writer.service.d.ts +20 -0
- package/types/src/services/swc-transpiler.d.ts +34 -0
- package/types/src/services/ts-program-host.d.ts +22 -0
- package/types/src/services/type-emission-program.d.ts +22 -0
- package/types/src/services/type-emitter.d.ts +43 -0
- package/types/src/types/build-target.type.d.ts +7 -0
- package/types/src/types/configuration.type.d.ts +6 -0
- package/types/src/types/dependency.types.d.ts +39 -0
- package/types/src/types/swc-config.type.d.ts +9 -0
- package/types/src/types/transform-response.model.d.ts +54 -0
- package/types/src/types/transformer.type.d.ts +37 -0
- package/types/src/types/workspace-config.type.d.ts +13 -0
- package/types/src/vitest/forge-build.plugin.d.ts +18 -0
- package/types/src/vitest/index.d.ts +2 -0
- package/types/src/workspace.config.d.ts +6 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Project } from "@decohere/mesh";
|
|
2
|
+
import { Workspace } from "@decohere/mesh";
|
|
3
|
+
import type { Action, ResultStatus } from "@decohere/nexus/cli";
|
|
4
|
+
import { ActionResponse } from "@decohere/nexus/cli";
|
|
5
|
+
export type PublishOptions = {
|
|
6
|
+
configuration: string;
|
|
7
|
+
channel?: string;
|
|
8
|
+
dryRun?: boolean;
|
|
9
|
+
token?: string;
|
|
10
|
+
otp?: string;
|
|
11
|
+
promptAuth?: boolean;
|
|
12
|
+
promptOtp?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type PublishResponse = ResultStatus & {
|
|
15
|
+
projectName: string;
|
|
16
|
+
message: string;
|
|
17
|
+
packageName?: string;
|
|
18
|
+
};
|
|
19
|
+
export declare class Publish implements Action<PublishOptions> {
|
|
20
|
+
#private;
|
|
21
|
+
private readonly workspace;
|
|
22
|
+
private readonly npm;
|
|
23
|
+
constructor(workspace: Workspace);
|
|
24
|
+
run(options: PublishOptions): Promise<ActionResponse<PublishResponse>>;
|
|
25
|
+
publishProjects(projects: readonly Project[], options: PublishOptions): Promise<(ResultStatus & {
|
|
26
|
+
projectName: string;
|
|
27
|
+
message: string;
|
|
28
|
+
packageName?: string;
|
|
29
|
+
})[]>;
|
|
30
|
+
private publishProject;
|
|
31
|
+
private resolveToken;
|
|
32
|
+
private resolveOtp;
|
|
33
|
+
private promptSecret;
|
|
34
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Action } from "@decohere/nexus/cli";
|
|
2
|
+
import { ActionResponse } from "@decohere/nexus/cli";
|
|
3
|
+
export type SyncLockFileOptions = {
|
|
4
|
+
sync?: boolean;
|
|
5
|
+
dryRun?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare class SyncLockFile implements Action<SyncLockFileOptions> {
|
|
8
|
+
#private;
|
|
9
|
+
run(options: SyncLockFileOptions): Promise<ActionResponse>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Workspace } from "@decohere/mesh";
|
|
2
|
+
import type { Action } from "@decohere/nexus/cli";
|
|
3
|
+
import { ActionResponse } from "@decohere/nexus/cli";
|
|
4
|
+
export type TagOptions = {
|
|
5
|
+
prefix?: string;
|
|
6
|
+
dryRun?: boolean;
|
|
7
|
+
push?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export type TagResponse = {
|
|
10
|
+
tag: string;
|
|
11
|
+
succeeded: boolean;
|
|
12
|
+
error?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare class Tag implements Action<TagOptions> {
|
|
15
|
+
#private;
|
|
16
|
+
private readonly workspace;
|
|
17
|
+
constructor(workspace: Workspace);
|
|
18
|
+
run(options: TagOptions): Promise<ActionResponse<TagResponse>>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Workspace } from "@decohere/mesh";
|
|
2
|
+
import type { Action, ResultStatus } from "@decohere/nexus/cli";
|
|
3
|
+
import { ActionResponse } from "@decohere/nexus/cli";
|
|
4
|
+
import { type VersionType } from "@decohere/nexus/semver";
|
|
5
|
+
export type VersionResponse = ResultStatus & {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
export declare const DefaultChannel = "beta";
|
|
9
|
+
export declare const DefaultReleaseType: "prerelease";
|
|
10
|
+
export type VersionOptions = {
|
|
11
|
+
releaseType?: VersionType;
|
|
12
|
+
channel?: string;
|
|
13
|
+
version?: string;
|
|
14
|
+
dryRun?: boolean;
|
|
15
|
+
commit?: boolean;
|
|
16
|
+
message?: string;
|
|
17
|
+
/** Read pending .changeset entries to determine the highest bump type */
|
|
18
|
+
fromChangesets?: boolean;
|
|
19
|
+
};
|
|
20
|
+
export declare class Version implements Action<VersionOptions> {
|
|
21
|
+
#private;
|
|
22
|
+
private readonly workspace;
|
|
23
|
+
constructor(workspace: Workspace);
|
|
24
|
+
run(options: VersionOptions): Promise<ActionResponse>;
|
|
25
|
+
version(workspace: Workspace, options?: VersionOptions): Promise<ActionResponse<VersionResponse>>;
|
|
26
|
+
private resolveBaseVersion;
|
|
27
|
+
private resolveVersionFromGitTag;
|
|
28
|
+
/**
|
|
29
|
+
* Reads all pending .changeset/*.md entries and returns the highest bump type
|
|
30
|
+
* found across all of them. Precedence: major > minor > patch.
|
|
31
|
+
*/
|
|
32
|
+
private resolveReleaseTypeFromChangesets;
|
|
33
|
+
private getNextVersion;
|
|
34
|
+
private updatePackageJson;
|
|
35
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Workspace } from "@decohere/mesh";
|
|
2
|
+
import type { Action } from "@decohere/nexus/cli";
|
|
3
|
+
import { ActionResponse } from "@decohere/nexus/cli";
|
|
4
|
+
export type WatchOptions = {
|
|
5
|
+
watch: boolean;
|
|
6
|
+
configuration: string;
|
|
7
|
+
};
|
|
8
|
+
export declare class Watch implements Action<WatchOptions> {
|
|
9
|
+
#private;
|
|
10
|
+
private readonly workspace;
|
|
11
|
+
constructor(workspace: Workspace);
|
|
12
|
+
run: (options: WatchOptions) => Promise<ActionResponse>;
|
|
13
|
+
[Symbol.dispose](): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { MergeOptions } from "@decohere/nexus/cli";
|
|
2
|
+
import { CommandResponse, DecohereCommand } from "@decohere/nexus/cli";
|
|
3
|
+
import type { Build } from "../actions/build.action.js";
|
|
4
|
+
import type { Clean } from "../actions/clean.action.js";
|
|
5
|
+
import type { Copy } from "../actions/copy.action.js";
|
|
6
|
+
import type { Watch } from "../actions/watch.action.js";
|
|
7
|
+
export type BuildActions = {
|
|
8
|
+
clean: Clean;
|
|
9
|
+
build: Build;
|
|
10
|
+
watch: Watch;
|
|
11
|
+
copy: Copy;
|
|
12
|
+
};
|
|
13
|
+
export declare class BuildCommand extends DecohereCommand<BuildActions> {
|
|
14
|
+
constructor(name?: string);
|
|
15
|
+
run: (actions: BuildActions, options: MergeOptions<BuildActions>) => Promise<CommandResponse<BuildActions>>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Actions } from "@decohere/nexus/cli";
|
|
2
|
+
import { type CommandHandler, type CommandResponse, type CommandType, DecohereCommand } from "@decohere/nexus/cli";
|
|
3
|
+
export declare class ForgeCommand extends DecohereCommand {
|
|
4
|
+
constructor(commands: Record<string, CommandType>, handler: CommandHandler);
|
|
5
|
+
run(_actions: Actions, _options: never): Promise<CommandResponse>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DecohereCommand } from "@decohere/nexus/cli";
|
|
2
|
+
import { SyncLockFile } from "../actions/sync-lock-file.action.js";
|
|
3
|
+
import { Version } from "../actions/version.action.js";
|
|
4
|
+
type VersionActions = {
|
|
5
|
+
version: Version;
|
|
6
|
+
syncLockFile: SyncLockFile;
|
|
7
|
+
};
|
|
8
|
+
export declare class VersionCommand extends DecohereCommand<VersionActions> {
|
|
9
|
+
get actions(): (typeof SyncLockFile | typeof Version)[];
|
|
10
|
+
constructor(name: string);
|
|
11
|
+
}
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Project } from "@decohere/mesh";
|
|
2
|
+
import type { ForgeConfiguration } from "../types/configuration.type.js";
|
|
3
|
+
import { SwcConfig } from "../types/swc-config.type.js";
|
|
4
|
+
declare module "@decohere/mesh" {
|
|
5
|
+
interface Project {
|
|
6
|
+
getForgeConfiguration(): ForgeConfiguration;
|
|
7
|
+
getSwcConfig(): Promise<SwcConfig>;
|
|
8
|
+
getSwcConfigSync(): SwcConfig;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export declare class ProjectExtensions {
|
|
12
|
+
static getForgeConfiguration(project: Project): ForgeConfiguration;
|
|
13
|
+
static getSwcConfig(project: Project): Promise<SwcConfig>;
|
|
14
|
+
static getSwcConfigSync(project: Project): SwcConfig;
|
|
15
|
+
private static swcConfigPaths;
|
|
16
|
+
private static fileExistsSync;
|
|
17
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { FileEx } from "@decohere/nexus/io";
|
|
2
|
+
import type { Options } from "@swc/core";
|
|
3
|
+
import type { TranspileTarget } from "../types/build-target.type.js";
|
|
4
|
+
import type { SwcConfigOptions } from "../types/swc-config.type.js";
|
|
5
|
+
export declare class SwcConfigFactory {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a base config for a project+target combination, without a filename.
|
|
8
|
+
* Call once per (project, target) and then use createFileConfig() per file.
|
|
9
|
+
*/
|
|
10
|
+
createBaseConfig(buildTarget: TranspileTarget, configOptions: SwcConfigOptions): Options;
|
|
11
|
+
/** Stamps a per-file filename onto a pre-built base config. */
|
|
12
|
+
createFileConfig(file: FileEx, baseConfig: Options): Options;
|
|
13
|
+
/**
|
|
14
|
+
* Validates SWC options against known causes of Rust/NAPI process crashes.
|
|
15
|
+
* Throws a ForgeError with a descriptive message instead of letting the
|
|
16
|
+
* NAPI layer abort the process.
|
|
17
|
+
*
|
|
18
|
+
* Known crash causes:
|
|
19
|
+
* - `jsc.baseUrl` set to a relative path (SWC requires an absolute path)
|
|
20
|
+
*/
|
|
21
|
+
validate(options: Options): void;
|
|
22
|
+
/** Resolves tsconfig baseUrl to an absolute path. Returns undefined if not set. */
|
|
23
|
+
private static getBaseUrl;
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { WorkspaceFactoryOptions } from "@decohere/nexus/cli";
|
|
2
|
+
import { ModuleManifest } from "@decohere/nexus/cli";
|
|
3
|
+
import type { ContainerBuilder } from "@decohere/nexus/composition";
|
|
4
|
+
import * as Actions from "./actions/index.js";
|
|
5
|
+
import * as Commands from "./commands/index.js";
|
|
6
|
+
export declare class ForgeModule extends ModuleManifest {
|
|
7
|
+
readonly id = "forge";
|
|
8
|
+
readonly command: typeof Commands.ForgeCommand;
|
|
9
|
+
readonly actions: {
|
|
10
|
+
clean: typeof Actions.Clean;
|
|
11
|
+
copy: typeof Actions.Copy;
|
|
12
|
+
build: typeof Actions.Build;
|
|
13
|
+
watch: typeof Actions.Watch;
|
|
14
|
+
publish: typeof Actions.Publish;
|
|
15
|
+
syncDependencies: typeof Actions.SyncDependencies;
|
|
16
|
+
syncLockFile: typeof Actions.SyncLockFile;
|
|
17
|
+
reportDependencies: typeof Actions.ReportDependencies;
|
|
18
|
+
version: typeof Actions.Version;
|
|
19
|
+
tag: typeof Actions.Tag;
|
|
20
|
+
commitFiles: typeof Actions.CommitFiles;
|
|
21
|
+
};
|
|
22
|
+
readonly commands: {
|
|
23
|
+
build: typeof Commands.BuildCommand;
|
|
24
|
+
publish: typeof Commands.PublishCommand;
|
|
25
|
+
dependencies: typeof Commands.DependencyCommand;
|
|
26
|
+
version: typeof Commands.VersionCommand;
|
|
27
|
+
tag: typeof Commands.TagCommand;
|
|
28
|
+
};
|
|
29
|
+
registerServices(builder: ContainerBuilder): void;
|
|
30
|
+
createWorkspace(options: WorkspaceFactoryOptions): Promise<import("@decohere/mesh").Workspace>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { ForgeError } from "./errors.js";
|
|
2
|
+
export { ForgeModule } from "./forge.module.js";
|
|
3
|
+
export type { TranspileOptions } from "./services/swc-transpiler.js";
|
|
4
|
+
export { SwcTranspiler } from "./services/swc-transpiler.js";
|
|
5
|
+
export type { BuildTarget, TranspileTarget } from "./types/build-target.type.js";
|
|
6
|
+
export { BuildTargets } from "./types/build-target.type.js";
|
|
7
|
+
export type { ForgeConfiguration } from "./types/configuration.type.js";
|
|
8
|
+
export type { WorkspaceOptions } from "./types/workspace-config.type.js";
|
|
9
|
+
export { Debug as DebugConfiguration, DefaultConfigurations, Release as ReleaseConfiguration, WorkspaceDefaults, } from "./workspace.config.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { TransformResponse } from "../types/transform-response.model.js";
|
|
2
|
+
export declare abstract class CachesOutputs {
|
|
3
|
+
/** Maps source file fullPath -> output TransformResponses for cleanup in watch mode. */
|
|
4
|
+
protected get outputCache(): Map<string, TransformResponse[]>;
|
|
5
|
+
protected cacheOutputs(responses: TransformResponse[]): void;
|
|
6
|
+
protected deleteCachedOutputs(filePath: string): void;
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProjectFileEvent, Workspace } from "@decohere/mesh";
|
|
2
|
+
import type { Observable } from "rxjs";
|
|
3
|
+
import type { TransformResponse } from "../types/transform-response.model.js";
|
|
4
|
+
export declare abstract class IncrementalTransform {
|
|
5
|
+
get incrementalTransform$(): Observable<TransformResponse[]>;
|
|
6
|
+
watch(workspace: Workspace): void;
|
|
7
|
+
/**
|
|
8
|
+
* Called for every workspace file change. Implementations should invalidate
|
|
9
|
+
* any internal caches, perform the incremental transform, and return the results.
|
|
10
|
+
* Return an empty array for deletions or when no output is produced.
|
|
11
|
+
*/
|
|
12
|
+
protected abstract onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PackageJson, Project, Workspace } from "@decohere/mesh";
|
|
2
|
+
import type { DependencyWarning, DriftEntry, Package } from "../types/dependency.types.js";
|
|
3
|
+
export type ProjectDependencies = {
|
|
4
|
+
project: Project;
|
|
5
|
+
updatedPackage: PackageJson;
|
|
6
|
+
warnings: DependencyWarning[];
|
|
7
|
+
};
|
|
8
|
+
export declare class DependencyResolver {
|
|
9
|
+
computeDrift(current: PackageJson, computed: PackageJson): DriftEntry | null;
|
|
10
|
+
getWorkspacePackages(workspace: Workspace, projects: readonly Project[]): Promise<Map<string, Package>>;
|
|
11
|
+
computeProjectDependencies(project: Project, workspacePackages: Map<string, Package>): Promise<ProjectDependencies>;
|
|
12
|
+
private getDependencies;
|
|
13
|
+
private getDependencyFrom;
|
|
14
|
+
private getFileImports;
|
|
15
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Project } from "@decohere/mesh";
|
|
2
|
+
import "../extensions/project.extensions.js";
|
|
3
|
+
import type { TransformResponse } from "../types/transform-response.model.js";
|
|
4
|
+
export declare class FileWriterService {
|
|
5
|
+
#private;
|
|
6
|
+
initialize(): Promise<void>;
|
|
7
|
+
warmup(projects: Project[]): Promise<void>;
|
|
8
|
+
enqueueOutput(response: TransformResponse): void;
|
|
9
|
+
enqueueOutputs(responses: TransformResponse[]): void;
|
|
10
|
+
flush(): Promise<void>;
|
|
11
|
+
private getOutputDirs;
|
|
12
|
+
private loadExistingArtifacts;
|
|
13
|
+
private collectFiles;
|
|
14
|
+
private getWriteConcurrency;
|
|
15
|
+
private startWorkers;
|
|
16
|
+
private runWorker;
|
|
17
|
+
private ensureDirectory;
|
|
18
|
+
private resolveDrain;
|
|
19
|
+
private withConcurrency;
|
|
20
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Project } from "@decohere/mesh";
|
|
2
|
+
import type { FileEx } from "@decohere/nexus/io";
|
|
3
|
+
import { type BuildTarget, type TranspileTarget } from "../types/build-target.type.js";
|
|
4
|
+
import "../extensions/project.extensions.js";
|
|
5
|
+
import type { ProjectFileEvent, Tsconfig } from "@decohere/mesh";
|
|
6
|
+
import { CachesOutputs } from "../mixins/caches-outputs.mixin.js";
|
|
7
|
+
import { IncrementalTransform } from "../mixins/incremental-transform.mixin.js";
|
|
8
|
+
import type { SwcConfig } from "../types/swc-config.type.js";
|
|
9
|
+
import { TransformResponse } from "../types/transform-response.model.js";
|
|
10
|
+
import type { Transformer } from "../types/transformer.type.js";
|
|
11
|
+
export type TranspileOptions = {
|
|
12
|
+
aliasPaths?: boolean;
|
|
13
|
+
tsConfig?: Tsconfig;
|
|
14
|
+
userConfig?: SwcConfig;
|
|
15
|
+
};
|
|
16
|
+
declare const SwcTranspiler_base: abstract new (...args: unknown[]) => CachesOutputs & IncrementalTransform;
|
|
17
|
+
export declare class SwcTranspiler extends SwcTranspiler_base implements Transformer {
|
|
18
|
+
#private;
|
|
19
|
+
buildTargets: BuildTarget[];
|
|
20
|
+
transformProject(projectArrayLike: Project | Project[], fileFilter?: (project: Project) => Promise<FileEx[]>, onOutput?: (response: TransformResponse) => void): Promise<TransformResponse[]>;
|
|
21
|
+
transformFile(fileArrayLike: FileEx[] | FileEx, buildTarget: TranspileTarget, options?: TranspileOptions): Promise<TransformResponse[]>;
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous, single-file variant of `transformFile`.
|
|
24
|
+
* Reads the file with `fs.readFileSync` and transpiles via `swc.transformSync`.
|
|
25
|
+
* Intended for callers that cannot await (e.g. Node.js `registerHooks` load hook).
|
|
26
|
+
*/
|
|
27
|
+
transformFileSync(file: FileEx, buildTarget: TranspileTarget, options?: TranspileOptions): TransformResponse;
|
|
28
|
+
private transformTarget;
|
|
29
|
+
private runTransform;
|
|
30
|
+
protected onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;
|
|
31
|
+
invalidateContentCache(_file: FileEx): void;
|
|
32
|
+
private getFileContent;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { FileEx } from "@decohere/nexus/io";
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a TypeScript CompilerHost with cached file-system calls so that
|
|
5
|
+
* repeated reads during a single build do not hit the disk multiple times.
|
|
6
|
+
*
|
|
7
|
+
* Separating this from TypeEmitter keeps the transformer logic readable and
|
|
8
|
+
* lets the caching/program-creation concerns live in one focused place.
|
|
9
|
+
*/
|
|
10
|
+
export declare class TsProgramHost {
|
|
11
|
+
#private;
|
|
12
|
+
invalidateSourceFile(fileName: string): void;
|
|
13
|
+
hasInvalidated(): boolean;
|
|
14
|
+
/** Returns a stable string key for a set of compiler options that affect host behaviour. */
|
|
15
|
+
hostKey(opts: ts.CompilerOptions): string;
|
|
16
|
+
createHost(compilerOptions: ts.CompilerOptions): ts.CompilerHost;
|
|
17
|
+
createProgram(files: FileEx[], compilerOptions: ts.CompilerOptions, host: ts.CompilerHost, oldProgram?: ts.Program): ts.Program;
|
|
18
|
+
readFileFromDisk(fileName: string): string | undefined;
|
|
19
|
+
fileExistsOnDisk(fileName: string): boolean;
|
|
20
|
+
directoryExists(directoryName: string): boolean;
|
|
21
|
+
getDirectories(directoryName: string): string[];
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Project, Tsconfig } from "@decohere/mesh";
|
|
2
|
+
import type { FileEx } from "@decohere/nexus/io";
|
|
3
|
+
import type { TsProgramHost } from "../services/ts-program-host.js";
|
|
4
|
+
import { TransformResponse } from "../types/transform-response.model.js";
|
|
5
|
+
export type TypeProgramProject = {
|
|
6
|
+
project: Project;
|
|
7
|
+
files: FileEx[];
|
|
8
|
+
tsconfig: Tsconfig;
|
|
9
|
+
};
|
|
10
|
+
export declare class TypeEmissionProgram {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(group: TypeProgramProject[], hostFactory: TsProgramHost);
|
|
13
|
+
private toEmissionTarget;
|
|
14
|
+
private emittedKey;
|
|
15
|
+
private buildTargetMaps;
|
|
16
|
+
addFile(file: FileEx, project: Project): void;
|
|
17
|
+
emit(fileFilter?: (project: Project) => Promise<FileEx[]>, onOutput?: (response: TransformResponse) => void): Promise<TransformResponse[]>;
|
|
18
|
+
private emitAll;
|
|
19
|
+
private emitFiltered;
|
|
20
|
+
private toTransformResponse;
|
|
21
|
+
private toTransformResponseFromTarget;
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Project, ProjectFileEvent } from "@decohere/mesh";
|
|
2
|
+
import type { FileEx } from "@decohere/nexus/io";
|
|
3
|
+
import type ts from "typescript";
|
|
4
|
+
import "../extensions/project.extensions.js";
|
|
5
|
+
import { CachesOutputs } from "../mixins/caches-outputs.mixin.js";
|
|
6
|
+
import { IncrementalTransform } from "../mixins/incremental-transform.mixin.js";
|
|
7
|
+
import { type BuildTarget } from "../types/build-target.type.js";
|
|
8
|
+
import type { TransformResponse } from "../types/transform-response.model.js";
|
|
9
|
+
import type { Transformer } from "../types/transformer.type.js";
|
|
10
|
+
/**
|
|
11
|
+
* Compiler option defaults applied before the user's tsconfig — the user's values override these.
|
|
12
|
+
*
|
|
13
|
+
* lib: ES2022 — avoids loading lib.dom.d.ts (1.8 MB) which TS includes by default
|
|
14
|
+
* when no `lib` is set. Backend packages have no use for browser APIs.
|
|
15
|
+
*
|
|
16
|
+
* types: [] — disables ambient @types auto-discovery. Without this, TS scans
|
|
17
|
+
* every @types/* package in the node_modules hierarchy; in a monorepo that can
|
|
18
|
+
* pull in dozens of unrelated packages. Explicitly imported types still resolve
|
|
19
|
+
* normally; only ambient globals (e.g. Buffer, process) are suppressed — add
|
|
20
|
+
* `types: ["node"]` to a project's tsconfig to restore them.
|
|
21
|
+
*/
|
|
22
|
+
export declare const DEFAULT_TYPE_EMITTER_OPTIONS: Readonly<ts.CompilerOptions>;
|
|
23
|
+
/**
|
|
24
|
+
* Compiler options that TypeEmitter always enforces regardless of what the user's
|
|
25
|
+
* tsconfig specifies. Applied after the user spread so they cannot be overridden.
|
|
26
|
+
*/
|
|
27
|
+
export declare const REQUIRED_TYPE_EMITTER_OPTIONS: Readonly<ts.CompilerOptions>;
|
|
28
|
+
declare const TypeEmitter_base: abstract new (...args: unknown[]) => CachesOutputs & IncrementalTransform;
|
|
29
|
+
export declare class TypeEmitter extends TypeEmitter_base implements Transformer {
|
|
30
|
+
#private;
|
|
31
|
+
buildTargets: BuildTarget[];
|
|
32
|
+
/**
|
|
33
|
+
* Phase 1: fetch files, create TypeScript programs sequentially.
|
|
34
|
+
* Called before transformProject() so that the heavy createProgram work
|
|
35
|
+
* completes before other transformers (SWC/Rayon) start running in parallel.
|
|
36
|
+
*/
|
|
37
|
+
init(projectArrayLike: Project[] | Project, _filter?: (project: Project) => Promise<FileEx[]>): Promise<void>;
|
|
38
|
+
transformProject(projectArrayLike: Project[] | Project, filter?: (project: Project) => Promise<FileEx[]>, onOutput?: (response: TransformResponse) => void): Promise<TransformResponse[]>;
|
|
39
|
+
private preparePrograms;
|
|
40
|
+
protected onIncrementalFileEvent(evt: ProjectFileEvent): Promise<TransformResponse[]>;
|
|
41
|
+
private invalidateReadFileCache;
|
|
42
|
+
}
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ResultStatus } from "@decohere/nexus/cli";
|
|
2
|
+
export type Package = {
|
|
3
|
+
name: string;
|
|
4
|
+
version?: string;
|
|
5
|
+
isInternal?: boolean;
|
|
6
|
+
isDev?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export type ResolvedDependency = {
|
|
9
|
+
name: string;
|
|
10
|
+
version: string;
|
|
11
|
+
internal: boolean;
|
|
12
|
+
missing: false;
|
|
13
|
+
isDev: boolean;
|
|
14
|
+
} | {
|
|
15
|
+
name: string;
|
|
16
|
+
version: undefined;
|
|
17
|
+
internal: undefined;
|
|
18
|
+
missing: true;
|
|
19
|
+
isDev: false;
|
|
20
|
+
};
|
|
21
|
+
export type SyncprojectResult = ResultStatus & {
|
|
22
|
+
projectName: string;
|
|
23
|
+
drift?: DriftEntry | null;
|
|
24
|
+
};
|
|
25
|
+
export type DriftEntry = {
|
|
26
|
+
original: {
|
|
27
|
+
dependencies: Record<string, string>;
|
|
28
|
+
devDependencies: Record<string, string>;
|
|
29
|
+
};
|
|
30
|
+
updated: {
|
|
31
|
+
dependencies: Record<string, string>;
|
|
32
|
+
devDependencies: Record<string, string>;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export type DependencyWarning = {
|
|
36
|
+
file: string;
|
|
37
|
+
line: number;
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { Project } from "@decohere/mesh";
|
|
2
|
+
import type { File } from "@decohere/nexus/io";
|
|
3
|
+
import type { BuildTarget } from "./build-target.type.js";
|
|
4
|
+
export type TransformOutcome = "success" | "failure" | "skipped";
|
|
5
|
+
export declare const TransformOutcomes: {
|
|
6
|
+
success: "success";
|
|
7
|
+
failure: "failure";
|
|
8
|
+
skipped: "skipped";
|
|
9
|
+
};
|
|
10
|
+
type TransformResponseBase = {
|
|
11
|
+
file: File;
|
|
12
|
+
config: unknown;
|
|
13
|
+
project?: Project;
|
|
14
|
+
/** Absolute directory that will contain the output file. Pre-computed by the transformer. */
|
|
15
|
+
outputDir?: string;
|
|
16
|
+
/** Absolute path of the output file (outputDir + fileName). Pre-computed by the transformer. */
|
|
17
|
+
outputPath?: string;
|
|
18
|
+
};
|
|
19
|
+
type TransformSuccess = TransformResponseBase & {
|
|
20
|
+
outcome: "success";
|
|
21
|
+
code: string;
|
|
22
|
+
messages?: string[];
|
|
23
|
+
target: BuildTarget;
|
|
24
|
+
fileName: string;
|
|
25
|
+
};
|
|
26
|
+
type TransformFailure = TransformResponseBase & {
|
|
27
|
+
outcome: "failure";
|
|
28
|
+
messages?: string[];
|
|
29
|
+
target?: BuildTarget;
|
|
30
|
+
fileName?: string;
|
|
31
|
+
};
|
|
32
|
+
type TransformSkipped = TransformResponseBase & {
|
|
33
|
+
outcome: "skipped";
|
|
34
|
+
messages?: string | string[];
|
|
35
|
+
};
|
|
36
|
+
type TransformResponseData<T extends TransformOutcome = TransformOutcome> = T extends "success" ? TransformSuccess : T extends "skipped" ? TransformSkipped : TransformFailure;
|
|
37
|
+
export declare class TransformResponse {
|
|
38
|
+
static Success(data: Omit<TransformResponseData<"success">, "outcome">): TransformResponse;
|
|
39
|
+
static Error(data: Omit<TransformResponseData<"failure">, "outcome">): TransformResponse;
|
|
40
|
+
static Skipped(data: Omit<TransformResponseData<"skipped">, "outcome">): TransformResponse;
|
|
41
|
+
static from(data: TransformResponseData): TransformResponse;
|
|
42
|
+
constructor(data?: Partial<TransformResponseData>);
|
|
43
|
+
readonly file: File;
|
|
44
|
+
readonly outcome: TransformOutcome;
|
|
45
|
+
readonly target?: BuildTarget;
|
|
46
|
+
readonly code: string;
|
|
47
|
+
readonly fileName?: string;
|
|
48
|
+
readonly messages?: string[];
|
|
49
|
+
readonly config: unknown;
|
|
50
|
+
readonly project?: Project;
|
|
51
|
+
readonly outputDir?: string;
|
|
52
|
+
readonly outputPath?: string;
|
|
53
|
+
}
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Project, Workspace } from "@decohere/mesh";
|
|
2
|
+
import type { FileEx } from "@decohere/nexus/io";
|
|
3
|
+
import type { Observable } from "rxjs";
|
|
4
|
+
import type { BuildTarget } from "../types/build-target.type.js";
|
|
5
|
+
import type { TransformResponse } from "./transform-response.model.js";
|
|
6
|
+
export type FileEvent = {
|
|
7
|
+
type: "changed" | "added";
|
|
8
|
+
file: FileEx;
|
|
9
|
+
project?: Project;
|
|
10
|
+
} | {
|
|
11
|
+
type: "deleted";
|
|
12
|
+
file: FileEx;
|
|
13
|
+
project: Project;
|
|
14
|
+
};
|
|
15
|
+
export declare const TransformerKey: unique symbol;
|
|
16
|
+
export interface Transformer {
|
|
17
|
+
readonly buildTargets: BuildTarget[];
|
|
18
|
+
/**
|
|
19
|
+
* Optional pre-build phase that runs sequentially before all transformers'
|
|
20
|
+
* {@link transformProject} calls. Use for expensive CPU-bound setup (e.g.
|
|
21
|
+
* TypeScript createProgram) that must not compete with other transformers'
|
|
22
|
+
* parallel workloads.
|
|
23
|
+
*/
|
|
24
|
+
init?(projects: Project | Project[], fileFilter?: (project: Project) => Promise<FileEx[]>): Promise<void>;
|
|
25
|
+
transformProject(projects: Project | Project[], fileFilter?: (project: Project) => Promise<FileEx[]>, onOutput?: (response: TransformResponse) => void): Promise<TransformResponse[]>;
|
|
26
|
+
/**
|
|
27
|
+
* If implemented, signals this transformer supports incremental (watch) mode.
|
|
28
|
+
* {@link BuildAction} calls this after the initial build, passing the workspace
|
|
29
|
+
* so the transformer can self-subscribe to file change events.
|
|
30
|
+
*/
|
|
31
|
+
watch?(workspace: Workspace): void;
|
|
32
|
+
/**
|
|
33
|
+
* Emits incremental transform results after each file-change cycle.
|
|
34
|
+
* Present when {@link watch} is implemented.
|
|
35
|
+
*/
|
|
36
|
+
incrementalTransform$?: Observable<TransformResponse[]>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ProjectOptions as BaseProjectOptions, WorkspaceOptions as BaseWorkspaceOptions } from "@decohere/mesh";
|
|
2
|
+
import type { Action, CommandType } from "@decohere/nexus/cli";
|
|
3
|
+
import type { Constructable } from "@decohere/nexus/reflection";
|
|
4
|
+
import type { ForgeConfiguration } from "./configuration.type.js";
|
|
5
|
+
export type ProjectOptions = Omit<BaseProjectOptions, "configurations"> & {
|
|
6
|
+
configurations: ForgeConfiguration[];
|
|
7
|
+
};
|
|
8
|
+
export type WorkspaceOptions = Omit<BaseWorkspaceOptions, "configurations" | "projects"> & {
|
|
9
|
+
configurations: ForgeConfiguration[];
|
|
10
|
+
projects?: Record<string, Partial<ProjectOptions>>;
|
|
11
|
+
actions?: Record<string, Constructable<Action>>;
|
|
12
|
+
commands?: Record<string, CommandType>;
|
|
13
|
+
};
|