@decohere/workspace 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.
- package/package.json +3 -13
- package/src/const.ts +19 -0
- package/src/errors.ts +1 -0
- package/src/factories/config.factory.ts +21 -0
- package/src/factories/find-workspace-root.ts +32 -0
- package/src/factories/project.factory.ts +75 -0
- package/src/factories/workspace.factory.ts +44 -0
- package/{types/src/index.d.ts → src/index.ts} +7 -1
- package/src/models/has-package-json.mixin.ts +30 -0
- package/src/models/has-tsconfig.mixin.ts +48 -0
- package/src/models/package-aliases.ts +130 -0
- package/src/models/package-json.model.ts +231 -0
- package/src/models/project-file-event.ts +9 -0
- package/src/models/project.model.ts +340 -0
- package/src/models/source-extensions.ts +59 -0
- package/src/models/tsconfig.model.ts +81 -0
- package/src/models/workspace-config.type.ts +57 -0
- package/src/models/workspace.model.ts +178 -0
- package/tests/find-workspace-root.spec.ts +30 -0
- package/tests/package-aliases.spec.ts +160 -0
- package/tests/package-json.model.spec.ts +78 -0
- package/tests/project.factory.spec.ts +100 -0
- package/tests/source-extensions.spec.ts +33 -0
- package/tests/workspace.factory.spec.ts +147 -0
- package/LICENSE +0 -15
- package/commonjs/src/const.js +0 -69
- package/commonjs/src/errors.js +0 -12
- package/commonjs/src/factories/config.factory.js +0 -90
- package/commonjs/src/factories/find-workspace-root.js +0 -37
- package/commonjs/src/factories/project.factory.js +0 -73
- package/commonjs/src/factories/workspace.factory.js +0 -50
- package/commonjs/src/index.js +0 -74
- package/commonjs/src/models/has-package-json.mixin.js +0 -50
- package/commonjs/src/models/has-tsconfig.mixin.js +0 -75
- package/commonjs/src/models/package-aliases.js +0 -112
- package/commonjs/src/models/package-json.model.js +0 -202
- package/commonjs/src/models/project-file-event.js +0 -4
- package/commonjs/src/models/project.model.js +0 -316
- package/commonjs/src/models/source-extensions.js +0 -81
- package/commonjs/src/models/tsconfig.model.js +0 -97
- package/commonjs/src/models/workspace-config.type.js +0 -7
- package/commonjs/src/models/workspace.model.js +0 -153
- package/es6/src/const.js +0 -36
- package/es6/src/errors.js +0 -2
- package/es6/src/factories/config.factory.js +0 -34
- package/es6/src/factories/find-workspace-root.js +0 -26
- package/es6/src/factories/project.factory.js +0 -58
- package/es6/src/factories/workspace.factory.js +0 -35
- package/es6/src/index.js +0 -14
- package/es6/src/models/has-package-json.mixin.js +0 -35
- package/es6/src/models/has-tsconfig.mixin.js +0 -60
- package/es6/src/models/package-aliases.js +0 -97
- package/es6/src/models/package-json.model.js +0 -192
- package/es6/src/models/project-file-event.js +0 -1
- package/es6/src/models/project.model.js +0 -301
- package/es6/src/models/source-extensions.js +0 -66
- package/es6/src/models/tsconfig.model.js +0 -74
- package/es6/src/models/workspace-config.type.js +0 -4
- package/es6/src/models/workspace.model.js +0 -143
- package/types/src/const.d.ts +0 -8
- package/types/src/errors.d.ts +0 -2
- package/types/src/factories/config.factory.d.ts +0 -6
- package/types/src/factories/find-workspace-root.d.ts +0 -6
- package/types/src/factories/project.factory.d.ts +0 -8
- package/types/src/factories/workspace.factory.d.ts +0 -9
- package/types/src/models/has-package-json.mixin.d.ts +0 -9
- package/types/src/models/has-tsconfig.mixin.d.ts +0 -11
- package/types/src/models/package-aliases.d.ts +0 -28
- package/types/src/models/package-json.model.d.ts +0 -40
- package/types/src/models/project-file-event.d.ts +0 -9
- package/types/src/models/project.model.d.ts +0 -64
- package/types/src/models/source-extensions.d.ts +0 -22
- package/types/src/models/tsconfig.model.d.ts +0 -11
- package/types/src/models/workspace-config.type.d.ts +0 -52
- package/types/src/models/workspace.model.d.ts +0 -40
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { Project } from "./project.model.js";
|
|
2
|
-
export type PackageAliases = {
|
|
3
|
-
/** Absolute base for SWC `jsc.paths` / specifier resolution. */
|
|
4
|
-
baseUrl: string;
|
|
5
|
-
/** Package-name and `name/*` keys, values relative to `baseUrl`. */
|
|
6
|
-
paths: Record<string, string[]>;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Convention aliases from workspace packages, then tsconfig `paths` for the same keys.
|
|
10
|
-
* Prefer `Workspace.getPackageAliases` when a workspace is available.
|
|
11
|
-
*/
|
|
12
|
-
declare function build(projects: readonly Project[], options: {
|
|
13
|
-
baseUrl: string;
|
|
14
|
-
tsconfigPaths?: Record<string, string[]>;
|
|
15
|
-
}): PackageAliases;
|
|
16
|
-
/** Bare import specifier that is not relative, absolute, or a node/file URL. */
|
|
17
|
-
declare function isBareSpecifier(specifier: string): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Resolve a bare specifier through package aliases (SWC-style `paths`
|
|
20
|
-
* relative to `baseUrl`) to an absolute `.ts` path. Longest key wins.
|
|
21
|
-
*/
|
|
22
|
-
declare function resolvePath(specifier: string, paths: Record<string, string[]>, baseUrl: string): string | null;
|
|
23
|
-
export declare const packageAliases: {
|
|
24
|
-
build: typeof build;
|
|
25
|
-
isBareSpecifier: typeof isBareSpecifier;
|
|
26
|
-
resolvePath: typeof resolvePath;
|
|
27
|
-
};
|
|
28
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export type RepositoryReference = string | {
|
|
2
|
-
type?: string;
|
|
3
|
-
url?: string;
|
|
4
|
-
directory?: string;
|
|
5
|
-
};
|
|
6
|
-
export type PackageExports = string | {
|
|
7
|
-
[key: string]: PackageExports;
|
|
8
|
-
};
|
|
9
|
-
export declare class PackageJson {
|
|
10
|
-
private static readonly PACKAGE_JSON_KEY_ORDER;
|
|
11
|
-
constructor(data?: Partial<PackageJson>);
|
|
12
|
-
sort(): this;
|
|
13
|
-
withVersion(version: string): PackageJson;
|
|
14
|
-
withDependencies(dependencies: Record<string, string>): PackageJson;
|
|
15
|
-
withDevDependencies(devDependencies: Record<string, string>): PackageJson;
|
|
16
|
-
withPeerDependencies(peerDependencies: Record<string, string>): PackageJson;
|
|
17
|
-
toJSON(): string;
|
|
18
|
-
getRepositoryOwner(): string;
|
|
19
|
-
getRepositoryName(): string;
|
|
20
|
-
getRepositoryFullName(): string;
|
|
21
|
-
private sortDependencyMap;
|
|
22
|
-
private sortPackageJsonKeys;
|
|
23
|
-
private toSortedPackageJsonRecord;
|
|
24
|
-
private repositoryReferenceToString;
|
|
25
|
-
private parseRepository;
|
|
26
|
-
private parseRepositoryFromUrl;
|
|
27
|
-
private sanitizeRepositoryName;
|
|
28
|
-
readonly name: string;
|
|
29
|
-
version: string;
|
|
30
|
-
readonly repository?: RepositoryReference;
|
|
31
|
-
readonly main: string;
|
|
32
|
-
/** `exports` as written in package.json: a path, or a map of subpaths (values may be condition maps). */
|
|
33
|
-
readonly exports?: PackageExports;
|
|
34
|
-
readonly peerDependencies?: Record<string, string>;
|
|
35
|
-
readonly optionalDependencies?: Record<string, string>;
|
|
36
|
-
readonly scripts: Record<string, string>;
|
|
37
|
-
dependencies: Record<string, string>;
|
|
38
|
-
devDependencies: Record<string, string>;
|
|
39
|
-
readonly private?: boolean;
|
|
40
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { FileEx } from "@decohere/core/io";
|
|
2
|
-
import type { WatchEventName } from "@decohere/devkit/io";
|
|
3
|
-
import type { Project } from "./project.model.js";
|
|
4
|
-
export type ProjectFileEvent = {
|
|
5
|
-
eventName: WatchEventName;
|
|
6
|
-
project: Project;
|
|
7
|
-
configuration: string;
|
|
8
|
-
file: FileEx;
|
|
9
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { FileEx, Watcher } from "@decohere/core/io";
|
|
2
|
-
import { HasPackageJson } from "./has-package-json.mixin.js";
|
|
3
|
-
import { HasTsConfig } from "./has-tsconfig.mixin.js";
|
|
4
|
-
import { PackageJson } from "./package-json.model.js";
|
|
5
|
-
import type { ProjectFileEvent } from "./project-file-event.js";
|
|
6
|
-
import type { Configuration, WorkspaceOptions } from "./workspace-config.type.js";
|
|
7
|
-
export type ProjectConfig = {
|
|
8
|
-
projectDir?: string;
|
|
9
|
-
packageJson?: PackageJson;
|
|
10
|
-
} & WorkspaceOptions;
|
|
11
|
-
export type ProjectSeed = {
|
|
12
|
-
name: string;
|
|
13
|
-
config?: ProjectConfig;
|
|
14
|
-
};
|
|
15
|
-
declare const Project_base: abstract new (...args: unknown[]) => HasPackageJson & HasTsConfig;
|
|
16
|
-
export declare class Project extends Project_base {
|
|
17
|
-
#private;
|
|
18
|
-
protected packageJson?: PackageJson;
|
|
19
|
-
constructor(name: string, config?: ProjectConfig, selectedConfigurationName?: string);
|
|
20
|
-
get name(): string;
|
|
21
|
-
get isPrivate(): boolean;
|
|
22
|
-
toString(): string;
|
|
23
|
-
get projectDirectory(): string;
|
|
24
|
-
get projectRoot(): string;
|
|
25
|
-
get configuration(): Configuration;
|
|
26
|
-
protected get packageJsonDirectory(): string;
|
|
27
|
-
protected get tsConfigDirectory(): string;
|
|
28
|
-
protected get fallbackTsConfigDirectory(): string | undefined;
|
|
29
|
-
get rootDir(): string;
|
|
30
|
-
get include(): string[];
|
|
31
|
-
get ignore(): string[];
|
|
32
|
-
get copyFiles(): string[];
|
|
33
|
-
get dockerConfig(): import("./workspace-config.type.js").DockerConfig;
|
|
34
|
-
get uiConfig(): import("./workspace-config.type.js").UiConfig;
|
|
35
|
-
get configurations(): Configuration[];
|
|
36
|
-
get projectFileChanged$(): import("rxjs").Observable<ProjectFileEvent>;
|
|
37
|
-
getAllFiles(): Promise<FileEx[]>;
|
|
38
|
-
isSourceFile(file: FileEx): boolean;
|
|
39
|
-
watch(configuration: string): Promise<Watcher>;
|
|
40
|
-
stopWatching(): void;
|
|
41
|
-
getRootOut(): string;
|
|
42
|
-
getOutDir(target?: string): string;
|
|
43
|
-
getConfiguration(name: string): Configuration;
|
|
44
|
-
/**
|
|
45
|
-
* The package's entry source file. A TypeScript `main` (the workspace convention,
|
|
46
|
-
* `src/index.ts`) is used as written. A `main` or `exports["."]` that describes the published
|
|
47
|
-
* layout (`index.js`, `./es6/src/index.js`) is mapped back to the source it was built from,
|
|
48
|
-
* falling back to `src/index.ts` (#518).
|
|
49
|
-
*/
|
|
50
|
-
getSourceEntryPath(): string;
|
|
51
|
-
/**
|
|
52
|
-
* The source file each subpath in package.json `exports` names, such as `./auth` →
|
|
53
|
-
* `<project>/src/auth/auth.extensions.ts` (#518). Exports point at the release layout
|
|
54
|
-
* (`./es6/src/auth/auth.extensions.js`); the source is the part from `src/`, with its
|
|
55
|
-
* TypeScript extension. Wildcard subpaths, and targets with no such source file, are left out.
|
|
56
|
-
*/
|
|
57
|
-
getSourceExports(): Record<string, string>;
|
|
58
|
-
[Symbol.dispose](): void;
|
|
59
|
-
private getWorkspaceOut;
|
|
60
|
-
private updateSourceFileCache;
|
|
61
|
-
private matchesSourcePattern;
|
|
62
|
-
private resolveConfiguration;
|
|
63
|
-
}
|
|
64
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/** Whether a path is a TypeScript source (not a declaration file). */
|
|
2
|
-
declare function isSource(file: string): boolean;
|
|
3
|
-
/**
|
|
4
|
-
* The source files a path written in an import (or a built path) could name, most likely first:
|
|
5
|
-
* itself when it is already a source, else the same stem with each matching source extension.
|
|
6
|
-
*/
|
|
7
|
-
declare function candidates(file: string): string[];
|
|
8
|
-
/** The extension a source builds to: `.mts` to `.mjs`, `.cts` to `.cjs`, the rest to `.js`. */
|
|
9
|
-
declare function outputExtension(file: string): string;
|
|
10
|
-
/** The path a source builds to: `a.mts` to `a.mjs`, `a.cts` to `a.cjs`, `a.ts` and `a.tsx` to `a.js`. */
|
|
11
|
-
declare function outputPath(file: string): string;
|
|
12
|
-
/** Whether a source is CommonJS (`.cts`); everything else compiles as an ES module. */
|
|
13
|
-
declare function isCommonJs(file: string): boolean;
|
|
14
|
-
export declare const sourceExtensions: {
|
|
15
|
-
SOURCE: readonly [".ts", ".tsx", ".mts", ".cts"];
|
|
16
|
-
isSource: typeof isSource;
|
|
17
|
-
candidates: typeof candidates;
|
|
18
|
-
outputExtension: typeof outputExtension;
|
|
19
|
-
outputPath: typeof outputPath;
|
|
20
|
-
isCommonJs: typeof isCommonJs;
|
|
21
|
-
};
|
|
22
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ts, { type CompilerOptions } from "typescript";
|
|
2
|
-
export declare const DEFAULT_COMPILER_OPTIONS: CompilerOptions;
|
|
3
|
-
export declare class Tsconfig {
|
|
4
|
-
static default(): Tsconfig;
|
|
5
|
-
static parse(filePath: string): Promise<Tsconfig>;
|
|
6
|
-
static parseSync(filePath: string): Tsconfig;
|
|
7
|
-
private static fileExistsSync;
|
|
8
|
-
constructor(data?: Partial<Tsconfig>);
|
|
9
|
-
readonly compilerOptions: CompilerOptions;
|
|
10
|
-
readonly errors: readonly ts.Diagnostic[];
|
|
11
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generic configuration for a workspace build profile.
|
|
3
|
-
* Concrete tools (e.g. @decohere/forge) extend this with tool-specific fields.
|
|
4
|
-
*/
|
|
5
|
-
export type Configuration = {
|
|
6
|
-
name: string;
|
|
7
|
-
include?: string[];
|
|
8
|
-
ignore?: string[];
|
|
9
|
-
/** Extra globs to copy into the configuration outDir (non-transpiled assets). */
|
|
10
|
-
copyFiles?: string[];
|
|
11
|
-
/** If true, the output is packed into a folder per project directory. */
|
|
12
|
-
pack?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export type DockerConfig = {
|
|
15
|
-
image?: string;
|
|
16
|
-
dockerfile?: string;
|
|
17
|
-
buildArgs?: Record<string, string>;
|
|
18
|
-
secrets?: Record<string, string>;
|
|
19
|
-
tags?: string[];
|
|
20
|
-
push?: boolean;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* The UI a deployable serves from its API (`withStatic` in `@decohere/http`). `forge package` copies the
|
|
24
|
-
* UI project's build output into the deployable's `.package/` folder.
|
|
25
|
-
*/
|
|
26
|
-
export type UiConfig = {
|
|
27
|
-
/** Package name of the UI project, e.g. `@app/shop.web`. */
|
|
28
|
-
project: string;
|
|
29
|
-
/** The UI project's build output folder, relative to that project. Defaults to `dist`. */
|
|
30
|
-
output?: string;
|
|
31
|
-
/** Where it lands inside `.package/`, which is also the folder the API serves. Defaults to `ui`. */
|
|
32
|
-
to?: string;
|
|
33
|
-
};
|
|
34
|
-
export type WorkspaceFactoryOptions = {
|
|
35
|
-
rootDir?: string;
|
|
36
|
-
configFile?: string;
|
|
37
|
-
};
|
|
38
|
-
export type ProjectOptions = {
|
|
39
|
-
include?: string[];
|
|
40
|
-
ignore?: string[];
|
|
41
|
-
copyFiles: string[];
|
|
42
|
-
configurations: Configuration[];
|
|
43
|
-
docker?: DockerConfig;
|
|
44
|
-
ui?: UiConfig;
|
|
45
|
-
};
|
|
46
|
-
export type WorkspaceOptions = {
|
|
47
|
-
rootDir?: string;
|
|
48
|
-
outDir: string;
|
|
49
|
-
includeProjects: string[];
|
|
50
|
-
ignoreProjects: string[];
|
|
51
|
-
projects?: Record<string, Partial<ProjectOptions>>;
|
|
52
|
-
} & ProjectOptions;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { HasPackageJson } from "./has-package-json.mixin.js";
|
|
2
|
-
import { HasTsConfig } from "./has-tsconfig.mixin.js";
|
|
3
|
-
import { type PackageAliases } from "./package-aliases.js";
|
|
4
|
-
import { PackageJson } from "./package-json.model.js";
|
|
5
|
-
import { Project, type ProjectSeed } from "./project.model.js";
|
|
6
|
-
import type { ProjectFileEvent } from "./project-file-event.js";
|
|
7
|
-
import type { WorkspaceOptions } from "./workspace-config.type.js";
|
|
8
|
-
export type WorkspaceInitOptions = {
|
|
9
|
-
packageJson?: PackageJson;
|
|
10
|
-
config: Partial<WorkspaceOptions>;
|
|
11
|
-
projects: ProjectSeed[];
|
|
12
|
-
};
|
|
13
|
-
declare const Workspace_base: abstract new (...args: unknown[]) => HasPackageJson & HasTsConfig;
|
|
14
|
-
export declare class Workspace extends Workspace_base {
|
|
15
|
-
#private;
|
|
16
|
-
protected packageJson?: PackageJson;
|
|
17
|
-
constructor(options?: Partial<WorkspaceInitOptions>);
|
|
18
|
-
get name(): string;
|
|
19
|
-
protected get projectSeeds(): readonly ProjectSeed[];
|
|
20
|
-
getProjects(configuration: string): readonly Project[];
|
|
21
|
-
get rootDir(): string;
|
|
22
|
-
get packageJsonDirectory(): string;
|
|
23
|
-
protected get tsConfigDirectory(): string;
|
|
24
|
-
protected get fallbackTsConfigDirectory(): string | undefined;
|
|
25
|
-
/**
|
|
26
|
-
* Package-name aliases for this configuration: workspace convention, then
|
|
27
|
-
* workspace `tsconfig.json` `paths` overrides. Forge and Flux must use this
|
|
28
|
-
* instead of assembling the map themselves.
|
|
29
|
-
*/
|
|
30
|
-
getPackageAliases(configuration: string): PackageAliases;
|
|
31
|
-
watch(configuration: string): Promise<void>;
|
|
32
|
-
stopWatching(): void;
|
|
33
|
-
[Symbol.dispose](): void;
|
|
34
|
-
get projectFileChanged$(): import("rxjs").Observable<ProjectFileEvent>;
|
|
35
|
-
findProject(filePath: string, buildConfig: string): Promise<Project | undefined>;
|
|
36
|
-
private sourcePathsOf;
|
|
37
|
-
private validateWorkspace;
|
|
38
|
-
private findDuplicateProjectSeeds;
|
|
39
|
-
}
|
|
40
|
-
export {};
|